Dropstone Docs

கஸ்டம் டூல்ஸ்

Dropstone-ல் LLM அழைக்கக்கூடிய டூல்ஸ் உருவாக்கவும்.

கஸ்டம் டூல்ஸ் என்பது நீங்கள் உருவாக்கிய ஃபங்க்ஷன்கள் ஆகும், அவை உரையாடல்களின் போது LLM அழைக்கலாம். அவை Dropstone-ன் built-in tools போன்ற read, write, மற்றும் bash உடன் சேர்ந்து வேலை செய்கின்றன.


டூல் உருவாக்குதல்

டூல்ஸ் TypeScript அல்லது JavaScript ஃபைல்களாக வரையறுக்கப்படுகின்றன. டூல் வரையறை தன்னை TS/JS ஆகும், ஆனால் அது செய்யும் வேலை எந்த மொழியிலும் செயல்படுத்தப்படலாம்: shell scripts, Python, Go, Bun-ன் shell helpers-ல் இருந்து நீங்கள் spawn செய்யக்கூடிய எதுவும்.


இருப்பிடம்

அவை வரையறுக்கப்படலாம்:

  • உள்ளூரில் உங்கள் project-ன் .dropstone/tools/ directory-ல் வைப்பதன் மூலம்.
  • அல்லது globally, ~/.config/dropstone/tools/ இல் வைப்பதன் மூலம்.

संरचना

டூல்ஸ் உருவாக்குவதற்கான எளிய வழி tool() helper ஐ பயன்படுத்துவது ஆகும், இது type-safety மற்றும் validation வழங்குகிறது.

import { tool } from "@blankline/dropstone-plugin"

export default tool({
  description: "Query the project database",
  args: {
    query: tool.schema.string().describe("SQL query to execute"),
  },
  async execute(args) {
    // Your database logic here
    return `Executed query: ${args.query}`
  },
})

ஃபைல்பெயர் டூல் பெயர் ஆக மாறுகிறது. மேலே உள்ளவை database டூல் உருவாக்குகிறது.


ஒரு ஃபைலுக்கு பல டூல்ஸ்

நீங்கள் ஒரு ஃபைலிலிருந்து பல டூல்ஸ் export செய்யலாம். ஒவ்வொரு export தனிப்பட்ட டூல் ஆக மாறுகிறது, பெயர் <filename>_<exportname>:

import { tool } from "@blankline/dropstone-plugin"

export const add = tool({
  description: "Add two numbers",
  args: {
    a: tool.schema.number().describe("First number"),
    b: tool.schema.number().describe("Second number"),
  },
  async execute(args) {
    return args.a + args.b
  },
})

export const multiply = tool({
  description: "Multiply two numbers",
  args: {
    a: tool.schema.number().describe("First number"),
    b: tool.schema.number().describe("Second number"),
  },
  async execute(args) {
    return args.a * args.b
  },
})

இது இரண்டு டூல்ஸ் உருவாக்குகிறது: math_add மற்றும் math_multiply.


Built-in டூல்ஸ் உடன் பெயர் மோதல்கள்

கஸ்டம் டூல்ஸ் டூல் பெயரால் keyed செய்யப்படுகின்றன. ஒரு கஸ்டம் டூல் built-in டூல்ஸ் போன்ற பெயரைப் பயன்படுத்தினால், கஸ்டம் டூல் முன்னுரிமை பெறுகிறது.

உதாரணமாக, இந்த ஃபைல் built-in bash டூல் மாற்றுகிறது:

import { tool } from "@blankline/dropstone-plugin"

export default tool({
  description: "Restricted bash wrapper",
  args: {
    command: tool.schema.string(),
  },
  async execute(args) {
    return `blocked: ${args.command}`
  },
})

Note:

நீங்கள் intentionally built-in டூல் மாற்ற விரும்பாவிட்டால் தனிப்பட்ட பெயர்களை விரும்பவும். நீங்கள் built-in டூல் disable செய்ய விரும்பினால் ஆனால் அதை override செய்ய விரும்பவில்லை என்றால், permissions ஐ பயன்படுத்தவும்.


Arguments

நீங்கள் tool.schema ஐ பயன்படுத்தலாம், இது Zod ஆகும், argument types வரையறுக்க.

args: {
  query: tool.schema.string().describe("SQL query to execute")
}

நீங்கள் Zod ஐ நேரடியாக import செய்து plain object return செய்யலாம்:

import { z } from "zod"

export default {
  description: "Tool description",
  args: {
    param: z.string().describe("Parameter description"),
  },
  async execute(args, context) {
    // Tool implementation
    return "result"
  },
}

Context

டூல்ஸ் தற்போதைய session பற்றிய context பெறுகின்றன:

import { tool } from "@blankline/dropstone-plugin"

export default tool({
  description: "Get project information",
  args: {},
  async execute(args, context) {
    // Access context information
    const { agent, sessionID, messageID, directory, worktree } = context
    return `Agent: ${agent}, Session: ${sessionID}, Message: ${messageID}, Directory: ${directory}, Worktree: ${worktree}`
  },
})

Session working directory-க்கு context.directory ஐ பயன்படுத்தவும். Git worktree root-க்கு context.worktree ஐ பயன்படுத்தவும்.


உதாரணங்கள்

Python-ல் ஒரு டூல் எழுதவும்

நீங்கள் உங்கள் டூல்ஸ் எந்த மொழியிலும் எழுதலாம். இரண்டு எண்களைச் சேர்க்க Python ஐ பயன்படுத்தும் உதாரணம் இங்கே உள்ளது.

முதலில், Python script-ஆக டூல் உருவாக்கவும்:

import sys

a = int(sys.argv[1])
b = int(sys.argv[2])
print(a + b)

பின்னர் அதை invoke செய்யும் டூல் வரையறை உருவாக்கவும்:

import { tool } from "@blankline/dropstone-plugin"
import path from "path"

export default tool({
  description: "Add two numbers using Python",
  args: {
    a: tool.schema.number().describe("First number"),
    b: tool.schema.number().describe("Second number"),
  },
  async execute(args, context) {
    const script = path.join(context.worktree, ".dropstone/tools/add.py")
    const result = await Bun.$`python3 ${script} ${args.a} ${args.b}`.text()
    return result.trim()
  },
})

இங்கே நாம் Python script ஐ run செய்ய Bun.$ utility ஐ பயன்படுத்துகிறோம்.

Ctrl+I