agentool 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -21
- package/dist/chunk-44AFQ2B7.js +30 -0
- package/dist/{chunk-Y7KOKDFP.js → chunk-4HIATLKI.js} +1 -4
- package/dist/chunk-4HXAKPQH.cjs +36 -0
- package/dist/chunk-56CL4JCW.cjs +53 -0
- package/dist/{chunk-U2YMJM25.cjs → chunk-5O55DKOB.cjs} +1 -4
- package/dist/{chunk-IMZQ7ELK.cjs → chunk-5TDZF4IM.cjs} +10 -9
- package/dist/{chunk-JCTBB7H2.cjs → chunk-6DJSWTWQ.cjs} +1 -1
- package/dist/{chunk-ZHCMEQJJ.js → chunk-ACGW44YT.js} +3 -3
- package/dist/chunk-E6NBEYZD.js +51 -0
- package/dist/{chunk-7QL4BQCH.js → chunk-ECYT46FP.js} +1 -1
- package/dist/{chunk-QEJV2KZ4.cjs → chunk-HNP7JDQC.cjs} +14 -14
- package/dist/chunk-HNUL2CID.cjs +34 -0
- package/dist/chunk-IEX4NOVN.cjs +48 -0
- package/dist/chunk-IRRNYFI5.js +48 -0
- package/dist/chunk-L5JH4I77.cjs +51 -0
- package/dist/chunk-LK6SQH2G.cjs +30 -0
- package/dist/chunk-LTE5NG4D.js +53 -0
- package/dist/{chunk-TBVHHF3H.cjs → chunk-OM2UFTGS.cjs} +3 -3
- package/dist/{chunk-S6QEY7UY.js → chunk-P6Z5XFDS.js} +2 -2
- package/dist/chunk-S7IVHOA6.js +75 -0
- package/dist/chunk-TMW3XKKJ.js +34 -0
- package/dist/{chunk-XKG2A3EW.js → chunk-UDIG7332.js} +14 -14
- package/dist/chunk-VXZ4RKJI.js +36 -0
- package/dist/{chunk-6MDPYALY.js → chunk-XAQGZ374.js} +10 -9
- package/dist/{chunk-MXFW3XY6.cjs → chunk-ZBLQV6UO.cjs} +2 -2
- package/dist/chunk-ZFQZWXOI.cjs +75 -0
- package/dist/edit/index.cjs +2 -2
- package/dist/edit/index.d.cts +2 -2
- package/dist/edit/index.d.ts +2 -2
- package/dist/edit/index.js +1 -1
- package/dist/grep/index.cjs +2 -2
- package/dist/grep/index.js +1 -1
- package/dist/index.cjs +42 -11
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +53 -22
- package/dist/lsp/index.cjs +2 -2
- package/dist/lsp/index.d.cts +6 -9
- package/dist/lsp/index.d.ts +6 -9
- package/dist/lsp/index.js +1 -1
- package/dist/read/index.cjs +2 -2
- package/dist/read/index.js +1 -1
- package/dist/task-create/index.cjs +9 -0
- package/dist/task-create/index.d.cts +19 -0
- package/dist/task-create/index.d.ts +19 -0
- package/dist/task-create/index.js +9 -0
- package/dist/task-get/index.cjs +9 -0
- package/dist/task-get/index.d.cts +15 -0
- package/dist/task-get/index.d.ts +15 -0
- package/dist/task-get/index.js +9 -0
- package/dist/task-list/index.cjs +9 -0
- package/dist/task-list/index.d.cts +11 -0
- package/dist/task-list/index.d.ts +11 -0
- package/dist/task-list/index.js +9 -0
- package/dist/task-update/index.cjs +9 -0
- package/dist/task-update/index.d.cts +31 -0
- package/dist/task-update/index.d.ts +31 -0
- package/dist/task-update/index.js +9 -0
- package/dist/tool-search/index.cjs +8 -0
- package/dist/tool-search/index.d.cts +18 -0
- package/dist/tool-search/index.d.ts +18 -0
- package/dist/tool-search/index.js +8 -0
- package/dist/web-fetch/index.cjs +2 -2
- package/dist/web-fetch/index.d.cts +0 -2
- package/dist/web-fetch/index.d.ts +0 -2
- package/dist/web-fetch/index.js +1 -1
- package/dist/web-search/index.cjs +8 -0
- package/dist/web-search/index.d.cts +21 -0
- package/dist/web-search/index.d.ts +21 -0
- package/dist/web-search/index.js +8 -0
- package/dist/write/index.cjs +2 -2
- package/dist/write/index.js +1 -1
- package/package.json +31 -6
- package/dist/chunk-FAEGCFTO.js +0 -136
- package/dist/chunk-XLD2Y3SS.cjs +0 -136
- package/dist/task/index.cjs +0 -8
- package/dist/task/index.d.cts +0 -67
- package/dist/task/index.d.ts +0 -67
- package/dist/task/index.js +0 -8
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as ai from 'ai';
|
|
2
|
+
|
|
3
|
+
interface ToolSearchConfig {
|
|
4
|
+
/** Registry of available tools to search through. */
|
|
5
|
+
tools?: Record<string, {
|
|
6
|
+
description: string;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
declare function createToolSearch(config?: ToolSearchConfig): ai.Tool<{
|
|
10
|
+
query: string;
|
|
11
|
+
max_results: number;
|
|
12
|
+
}, string>;
|
|
13
|
+
declare const toolSearch: ai.Tool<{
|
|
14
|
+
query: string;
|
|
15
|
+
max_results: number;
|
|
16
|
+
}, string>;
|
|
17
|
+
|
|
18
|
+
export { type ToolSearchConfig, createToolSearch, toolSearch };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as ai from 'ai';
|
|
2
|
+
|
|
3
|
+
interface ToolSearchConfig {
|
|
4
|
+
/** Registry of available tools to search through. */
|
|
5
|
+
tools?: Record<string, {
|
|
6
|
+
description: string;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
declare function createToolSearch(config?: ToolSearchConfig): ai.Tool<{
|
|
10
|
+
query: string;
|
|
11
|
+
max_results: number;
|
|
12
|
+
}, string>;
|
|
13
|
+
declare const toolSearch: ai.Tool<{
|
|
14
|
+
query: string;
|
|
15
|
+
max_results: number;
|
|
16
|
+
}, string>;
|
|
17
|
+
|
|
18
|
+
export { type ToolSearchConfig, createToolSearch, toolSearch };
|
package/dist/web-fetch/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk5O55DKOBcjs = require('../chunk-5O55DKOB.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.createWebFetch =
|
|
8
|
+
exports.createWebFetch = _chunk5O55DKOBcjs.createWebFetch; exports.webFetch = _chunk5O55DKOBcjs.webFetch;
|
|
@@ -36,7 +36,6 @@ interface WebFetchConfig extends TimeoutConfig {
|
|
|
36
36
|
*/
|
|
37
37
|
declare function createWebFetch(config?: WebFetchConfig): ai.Tool<{
|
|
38
38
|
url: string;
|
|
39
|
-
prompt?: string | undefined;
|
|
40
39
|
}, string>;
|
|
41
40
|
/**
|
|
42
41
|
* Pre-configured web-fetch tool with default settings.
|
|
@@ -50,7 +49,6 @@ declare function createWebFetch(config?: WebFetchConfig): ai.Tool<{
|
|
|
50
49
|
*/
|
|
51
50
|
declare const webFetch: ai.Tool<{
|
|
52
51
|
url: string;
|
|
53
|
-
prompt?: string | undefined;
|
|
54
52
|
}, string>;
|
|
55
53
|
|
|
56
54
|
export { type WebFetchConfig, createWebFetch, webFetch };
|
|
@@ -36,7 +36,6 @@ interface WebFetchConfig extends TimeoutConfig {
|
|
|
36
36
|
*/
|
|
37
37
|
declare function createWebFetch(config?: WebFetchConfig): ai.Tool<{
|
|
38
38
|
url: string;
|
|
39
|
-
prompt?: string | undefined;
|
|
40
39
|
}, string>;
|
|
41
40
|
/**
|
|
42
41
|
* Pre-configured web-fetch tool with default settings.
|
|
@@ -50,7 +49,6 @@ declare function createWebFetch(config?: WebFetchConfig): ai.Tool<{
|
|
|
50
49
|
*/
|
|
51
50
|
declare const webFetch: ai.Tool<{
|
|
52
51
|
url: string;
|
|
53
|
-
prompt?: string | undefined;
|
|
54
52
|
}, string>;
|
|
55
53
|
|
|
56
54
|
export { type WebFetchConfig, createWebFetch, webFetch };
|
package/dist/web-fetch/index.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as ai from 'ai';
|
|
2
|
+
|
|
3
|
+
interface WebSearchConfig {
|
|
4
|
+
/** Callback to perform the actual search. Users provide their own implementation. */
|
|
5
|
+
onSearch?: (query: string, opts: {
|
|
6
|
+
allowed_domains?: string[];
|
|
7
|
+
blocked_domains?: string[];
|
|
8
|
+
}) => Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
declare function createWebSearch(config?: WebSearchConfig): ai.Tool<{
|
|
11
|
+
query: string;
|
|
12
|
+
allowed_domains?: string[] | undefined;
|
|
13
|
+
blocked_domains?: string[] | undefined;
|
|
14
|
+
}, string>;
|
|
15
|
+
declare const webSearch: ai.Tool<{
|
|
16
|
+
query: string;
|
|
17
|
+
allowed_domains?: string[] | undefined;
|
|
18
|
+
blocked_domains?: string[] | undefined;
|
|
19
|
+
}, string>;
|
|
20
|
+
|
|
21
|
+
export { type WebSearchConfig, createWebSearch, webSearch };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as ai from 'ai';
|
|
2
|
+
|
|
3
|
+
interface WebSearchConfig {
|
|
4
|
+
/** Callback to perform the actual search. Users provide their own implementation. */
|
|
5
|
+
onSearch?: (query: string, opts: {
|
|
6
|
+
allowed_domains?: string[];
|
|
7
|
+
blocked_domains?: string[];
|
|
8
|
+
}) => Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
declare function createWebSearch(config?: WebSearchConfig): ai.Tool<{
|
|
11
|
+
query: string;
|
|
12
|
+
allowed_domains?: string[] | undefined;
|
|
13
|
+
blocked_domains?: string[] | undefined;
|
|
14
|
+
}, string>;
|
|
15
|
+
declare const webSearch: ai.Tool<{
|
|
16
|
+
query: string;
|
|
17
|
+
allowed_domains?: string[] | undefined;
|
|
18
|
+
blocked_domains?: string[] | undefined;
|
|
19
|
+
}, string>;
|
|
20
|
+
|
|
21
|
+
export { type WebSearchConfig, createWebSearch, webSearch };
|
package/dist/write/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk6DJSWTWQcjs = require('../chunk-6DJSWTWQ.cjs');
|
|
5
5
|
require('../chunk-CAEVLIQB.cjs');
|
|
6
6
|
require('../chunk-QZ5GS6HW.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
exports.createWrite =
|
|
10
|
+
exports.createWrite = _chunk6DJSWTWQcjs.createWrite; exports.write = _chunk6DJSWTWQcjs.write;
|
package/dist/write/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentool",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "22 AI agent tools as standalone Vercel AI SDK modules",
|
|
6
6
|
"author": "Z-M-Huang",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"repository": {
|
|
@@ -89,10 +89,35 @@
|
|
|
89
89
|
"import": "./dist/diff/index.js",
|
|
90
90
|
"require": "./dist/diff/index.cjs"
|
|
91
91
|
},
|
|
92
|
-
"./task": {
|
|
93
|
-
"types": "./dist/task/index.d.ts",
|
|
94
|
-
"import": "./dist/task/index.js",
|
|
95
|
-
"require": "./dist/task/index.cjs"
|
|
92
|
+
"./task-create": {
|
|
93
|
+
"types": "./dist/task-create/index.d.ts",
|
|
94
|
+
"import": "./dist/task-create/index.js",
|
|
95
|
+
"require": "./dist/task-create/index.cjs"
|
|
96
|
+
},
|
|
97
|
+
"./task-get": {
|
|
98
|
+
"types": "./dist/task-get/index.d.ts",
|
|
99
|
+
"import": "./dist/task-get/index.js",
|
|
100
|
+
"require": "./dist/task-get/index.cjs"
|
|
101
|
+
},
|
|
102
|
+
"./task-update": {
|
|
103
|
+
"types": "./dist/task-update/index.d.ts",
|
|
104
|
+
"import": "./dist/task-update/index.js",
|
|
105
|
+
"require": "./dist/task-update/index.cjs"
|
|
106
|
+
},
|
|
107
|
+
"./task-list": {
|
|
108
|
+
"types": "./dist/task-list/index.d.ts",
|
|
109
|
+
"import": "./dist/task-list/index.js",
|
|
110
|
+
"require": "./dist/task-list/index.cjs"
|
|
111
|
+
},
|
|
112
|
+
"./web-search": {
|
|
113
|
+
"types": "./dist/web-search/index.d.ts",
|
|
114
|
+
"import": "./dist/web-search/index.js",
|
|
115
|
+
"require": "./dist/web-search/index.cjs"
|
|
116
|
+
},
|
|
117
|
+
"./tool-search": {
|
|
118
|
+
"types": "./dist/tool-search/index.d.ts",
|
|
119
|
+
"import": "./dist/tool-search/index.js",
|
|
120
|
+
"require": "./dist/tool-search/index.cjs"
|
|
96
121
|
},
|
|
97
122
|
"./lsp": {
|
|
98
123
|
"types": "./dist/lsp/index.d.ts",
|
package/dist/chunk-FAEGCFTO.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
// src/task/index.ts
|
|
2
|
-
import { tool } from "ai";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
5
|
-
import { dirname, join } from "path";
|
|
6
|
-
import { randomBytes } from "crypto";
|
|
7
|
-
function generateId() {
|
|
8
|
-
return randomBytes(4).toString("hex");
|
|
9
|
-
}
|
|
10
|
-
async function loadTasks(filePath) {
|
|
11
|
-
try {
|
|
12
|
-
const data = await readFile(filePath, "utf-8");
|
|
13
|
-
return JSON.parse(data);
|
|
14
|
-
} catch {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
async function saveTasks(filePath, tasks) {
|
|
19
|
-
await mkdir(dirname(filePath), { recursive: true });
|
|
20
|
-
await writeFile(filePath, JSON.stringify(tasks, null, 2), "utf-8");
|
|
21
|
-
}
|
|
22
|
-
function formatTask(t) {
|
|
23
|
-
return [
|
|
24
|
-
`ID: ${t.id}`,
|
|
25
|
-
`Subject: ${t.subject}`,
|
|
26
|
-
`Description: ${t.description}`,
|
|
27
|
-
`Status: ${t.status}`,
|
|
28
|
-
`Created: ${t.createdAt}`,
|
|
29
|
-
`Updated: ${t.updatedAt}`
|
|
30
|
-
].join("\n");
|
|
31
|
-
}
|
|
32
|
-
function createTask(config = {}) {
|
|
33
|
-
const cwd = config.cwd ?? process.cwd();
|
|
34
|
-
const tasksFile = config.tasksFile ?? join(cwd, ".agentool", "tasks.json");
|
|
35
|
-
return tool({
|
|
36
|
-
description: "JSON file-based task tracker. Use this to create, get, update, list, and delete tasks. Each task has an id, subject, description, status, and timestamps.",
|
|
37
|
-
inputSchema: z.object({
|
|
38
|
-
action: z.enum(["create", "get", "update", "list", "delete"]).describe(
|
|
39
|
-
"The operation to perform"
|
|
40
|
-
),
|
|
41
|
-
id: z.string().optional().describe(
|
|
42
|
-
"Task id (required for get, update, delete)"
|
|
43
|
-
),
|
|
44
|
-
subject: z.string().optional().describe(
|
|
45
|
-
"Task subject (required for create, optional for update)"
|
|
46
|
-
),
|
|
47
|
-
description: z.string().optional().describe(
|
|
48
|
-
"Task description (required for create, optional for update)"
|
|
49
|
-
),
|
|
50
|
-
status: z.enum(["pending", "in_progress", "completed"]).optional().describe(
|
|
51
|
-
"Task status (optional for create/update, defaults to pending)"
|
|
52
|
-
)
|
|
53
|
-
}),
|
|
54
|
-
execute: async ({ action, id, subject, description, status }) => {
|
|
55
|
-
try {
|
|
56
|
-
switch (action) {
|
|
57
|
-
case "create":
|
|
58
|
-
return await createEntry(tasksFile, subject, description, status);
|
|
59
|
-
case "list":
|
|
60
|
-
return await listEntries(tasksFile);
|
|
61
|
-
case "get":
|
|
62
|
-
return await getEntry(tasksFile, id);
|
|
63
|
-
case "update":
|
|
64
|
-
return await updateEntry(tasksFile, id, subject, description, status);
|
|
65
|
-
case "delete":
|
|
66
|
-
return await deleteEntry(tasksFile, id);
|
|
67
|
-
default:
|
|
68
|
-
return `Error [task]: Unknown action "${String(action)}".`;
|
|
69
|
-
}
|
|
70
|
-
} catch (error) {
|
|
71
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
72
|
-
return `Error [task]: ${msg}`;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
async function createEntry(filePath, subject, description, status) {
|
|
78
|
-
if (!subject) return "Error [task]: Subject is required for create action.";
|
|
79
|
-
if (!description) return "Error [task]: Description is required for create action.";
|
|
80
|
-
const tasks = await loadTasks(filePath);
|
|
81
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
82
|
-
const entry = {
|
|
83
|
-
id: generateId(),
|
|
84
|
-
subject,
|
|
85
|
-
description,
|
|
86
|
-
status: status ?? "pending",
|
|
87
|
-
createdAt: now,
|
|
88
|
-
updatedAt: now
|
|
89
|
-
};
|
|
90
|
-
tasks.push(entry);
|
|
91
|
-
await saveTasks(filePath, tasks);
|
|
92
|
-
return `Created task ${entry.id}.
|
|
93
|
-
${formatTask(entry)}`;
|
|
94
|
-
}
|
|
95
|
-
async function listEntries(filePath) {
|
|
96
|
-
const tasks = await loadTasks(filePath);
|
|
97
|
-
if (tasks.length === 0) return "No tasks found.";
|
|
98
|
-
return tasks.map(formatTask).join("\n---\n");
|
|
99
|
-
}
|
|
100
|
-
async function getEntry(filePath, id) {
|
|
101
|
-
if (!id) return "Error [task]: ID is required for get action.";
|
|
102
|
-
const tasks = await loadTasks(filePath);
|
|
103
|
-
const found = tasks.find((t) => t.id === id);
|
|
104
|
-
if (!found) return `Error [task]: Task "${id}" not found.`;
|
|
105
|
-
return formatTask(found);
|
|
106
|
-
}
|
|
107
|
-
async function updateEntry(filePath, id, subject, description, status) {
|
|
108
|
-
if (!id) return "Error [task]: ID is required for update action.";
|
|
109
|
-
const tasks = await loadTasks(filePath);
|
|
110
|
-
const idx = tasks.findIndex((t) => t.id === id);
|
|
111
|
-
if (idx === -1) return `Error [task]: Task "${id}" not found.`;
|
|
112
|
-
const entry = tasks[idx];
|
|
113
|
-
if (subject) entry.subject = subject;
|
|
114
|
-
if (description) entry.description = description;
|
|
115
|
-
if (status) entry.status = status;
|
|
116
|
-
entry.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
117
|
-
tasks[idx] = entry;
|
|
118
|
-
await saveTasks(filePath, tasks);
|
|
119
|
-
return `Updated task ${id}.
|
|
120
|
-
${formatTask(entry)}`;
|
|
121
|
-
}
|
|
122
|
-
async function deleteEntry(filePath, id) {
|
|
123
|
-
if (!id) return "Error [task]: ID is required for delete action.";
|
|
124
|
-
const tasks = await loadTasks(filePath);
|
|
125
|
-
const idx = tasks.findIndex((t) => t.id === id);
|
|
126
|
-
if (idx === -1) return `Error [task]: Task "${id}" not found.`;
|
|
127
|
-
tasks.splice(idx, 1);
|
|
128
|
-
await saveTasks(filePath, tasks);
|
|
129
|
-
return `Deleted task "${id}".`;
|
|
130
|
-
}
|
|
131
|
-
var task = createTask();
|
|
132
|
-
|
|
133
|
-
export {
|
|
134
|
-
createTask,
|
|
135
|
-
task
|
|
136
|
-
};
|
package/dist/chunk-XLD2Y3SS.cjs
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/task/index.ts
|
|
2
|
-
var _ai = require('ai');
|
|
3
|
-
var _zod = require('zod');
|
|
4
|
-
var _promises = require('fs/promises');
|
|
5
|
-
var _path = require('path');
|
|
6
|
-
var _crypto = require('crypto');
|
|
7
|
-
function generateId() {
|
|
8
|
-
return _crypto.randomBytes.call(void 0, 4).toString("hex");
|
|
9
|
-
}
|
|
10
|
-
async function loadTasks(filePath) {
|
|
11
|
-
try {
|
|
12
|
-
const data = await _promises.readFile.call(void 0, filePath, "utf-8");
|
|
13
|
-
return JSON.parse(data);
|
|
14
|
-
} catch (e) {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
async function saveTasks(filePath, tasks) {
|
|
19
|
-
await _promises.mkdir.call(void 0, _path.dirname.call(void 0, filePath), { recursive: true });
|
|
20
|
-
await _promises.writeFile.call(void 0, filePath, JSON.stringify(tasks, null, 2), "utf-8");
|
|
21
|
-
}
|
|
22
|
-
function formatTask(t) {
|
|
23
|
-
return [
|
|
24
|
-
`ID: ${t.id}`,
|
|
25
|
-
`Subject: ${t.subject}`,
|
|
26
|
-
`Description: ${t.description}`,
|
|
27
|
-
`Status: ${t.status}`,
|
|
28
|
-
`Created: ${t.createdAt}`,
|
|
29
|
-
`Updated: ${t.updatedAt}`
|
|
30
|
-
].join("\n");
|
|
31
|
-
}
|
|
32
|
-
function createTask(config = {}) {
|
|
33
|
-
const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
|
|
34
|
-
const tasksFile = _nullishCoalesce(config.tasksFile, () => ( _path.join.call(void 0, cwd, ".agentool", "tasks.json")));
|
|
35
|
-
return _ai.tool.call(void 0, {
|
|
36
|
-
description: "JSON file-based task tracker. Use this to create, get, update, list, and delete tasks. Each task has an id, subject, description, status, and timestamps.",
|
|
37
|
-
inputSchema: _zod.z.object({
|
|
38
|
-
action: _zod.z.enum(["create", "get", "update", "list", "delete"]).describe(
|
|
39
|
-
"The operation to perform"
|
|
40
|
-
),
|
|
41
|
-
id: _zod.z.string().optional().describe(
|
|
42
|
-
"Task id (required for get, update, delete)"
|
|
43
|
-
),
|
|
44
|
-
subject: _zod.z.string().optional().describe(
|
|
45
|
-
"Task subject (required for create, optional for update)"
|
|
46
|
-
),
|
|
47
|
-
description: _zod.z.string().optional().describe(
|
|
48
|
-
"Task description (required for create, optional for update)"
|
|
49
|
-
),
|
|
50
|
-
status: _zod.z.enum(["pending", "in_progress", "completed"]).optional().describe(
|
|
51
|
-
"Task status (optional for create/update, defaults to pending)"
|
|
52
|
-
)
|
|
53
|
-
}),
|
|
54
|
-
execute: async ({ action, id, subject, description, status }) => {
|
|
55
|
-
try {
|
|
56
|
-
switch (action) {
|
|
57
|
-
case "create":
|
|
58
|
-
return await createEntry(tasksFile, subject, description, status);
|
|
59
|
-
case "list":
|
|
60
|
-
return await listEntries(tasksFile);
|
|
61
|
-
case "get":
|
|
62
|
-
return await getEntry(tasksFile, id);
|
|
63
|
-
case "update":
|
|
64
|
-
return await updateEntry(tasksFile, id, subject, description, status);
|
|
65
|
-
case "delete":
|
|
66
|
-
return await deleteEntry(tasksFile, id);
|
|
67
|
-
default:
|
|
68
|
-
return `Error [task]: Unknown action "${String(action)}".`;
|
|
69
|
-
}
|
|
70
|
-
} catch (error) {
|
|
71
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
72
|
-
return `Error [task]: ${msg}`;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
async function createEntry(filePath, subject, description, status) {
|
|
78
|
-
if (!subject) return "Error [task]: Subject is required for create action.";
|
|
79
|
-
if (!description) return "Error [task]: Description is required for create action.";
|
|
80
|
-
const tasks = await loadTasks(filePath);
|
|
81
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
82
|
-
const entry = {
|
|
83
|
-
id: generateId(),
|
|
84
|
-
subject,
|
|
85
|
-
description,
|
|
86
|
-
status: _nullishCoalesce(status, () => ( "pending")),
|
|
87
|
-
createdAt: now,
|
|
88
|
-
updatedAt: now
|
|
89
|
-
};
|
|
90
|
-
tasks.push(entry);
|
|
91
|
-
await saveTasks(filePath, tasks);
|
|
92
|
-
return `Created task ${entry.id}.
|
|
93
|
-
${formatTask(entry)}`;
|
|
94
|
-
}
|
|
95
|
-
async function listEntries(filePath) {
|
|
96
|
-
const tasks = await loadTasks(filePath);
|
|
97
|
-
if (tasks.length === 0) return "No tasks found.";
|
|
98
|
-
return tasks.map(formatTask).join("\n---\n");
|
|
99
|
-
}
|
|
100
|
-
async function getEntry(filePath, id) {
|
|
101
|
-
if (!id) return "Error [task]: ID is required for get action.";
|
|
102
|
-
const tasks = await loadTasks(filePath);
|
|
103
|
-
const found = tasks.find((t) => t.id === id);
|
|
104
|
-
if (!found) return `Error [task]: Task "${id}" not found.`;
|
|
105
|
-
return formatTask(found);
|
|
106
|
-
}
|
|
107
|
-
async function updateEntry(filePath, id, subject, description, status) {
|
|
108
|
-
if (!id) return "Error [task]: ID is required for update action.";
|
|
109
|
-
const tasks = await loadTasks(filePath);
|
|
110
|
-
const idx = tasks.findIndex((t) => t.id === id);
|
|
111
|
-
if (idx === -1) return `Error [task]: Task "${id}" not found.`;
|
|
112
|
-
const entry = tasks[idx];
|
|
113
|
-
if (subject) entry.subject = subject;
|
|
114
|
-
if (description) entry.description = description;
|
|
115
|
-
if (status) entry.status = status;
|
|
116
|
-
entry.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
117
|
-
tasks[idx] = entry;
|
|
118
|
-
await saveTasks(filePath, tasks);
|
|
119
|
-
return `Updated task ${id}.
|
|
120
|
-
${formatTask(entry)}`;
|
|
121
|
-
}
|
|
122
|
-
async function deleteEntry(filePath, id) {
|
|
123
|
-
if (!id) return "Error [task]: ID is required for delete action.";
|
|
124
|
-
const tasks = await loadTasks(filePath);
|
|
125
|
-
const idx = tasks.findIndex((t) => t.id === id);
|
|
126
|
-
if (idx === -1) return `Error [task]: Task "${id}" not found.`;
|
|
127
|
-
tasks.splice(idx, 1);
|
|
128
|
-
await saveTasks(filePath, tasks);
|
|
129
|
-
return `Deleted task "${id}".`;
|
|
130
|
-
}
|
|
131
|
-
var task = createTask();
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
exports.createTask = createTask; exports.task = task;
|
package/dist/task/index.cjs
DELETED
package/dist/task/index.d.cts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as ai from 'ai';
|
|
2
|
-
import { B as BaseToolConfig } from '../types-3QPDuCXN.cjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Configuration for the task tool.
|
|
6
|
-
* Extends {@link BaseToolConfig} with an optional tasks file path.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import type { TaskConfig } from 'agentool/task';
|
|
11
|
-
* const config: TaskConfig = { cwd: '/my/project' };
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
interface TaskConfig extends BaseToolConfig {
|
|
15
|
-
/** Path to the tasks JSON file. Defaults to `<cwd>/.agentool/tasks.json`. */
|
|
16
|
-
tasksFile?: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Creates a task tool that provides JSON file-based task tracking.
|
|
20
|
-
*
|
|
21
|
-
* Tasks are stored in a single JSON file with CRUD operations.
|
|
22
|
-
* Each task has an id, subject, description, status, and timestamps.
|
|
23
|
-
* Execute never throws; errors are returned as descriptive strings.
|
|
24
|
-
*
|
|
25
|
-
* @param config - Optional configuration for cwd and tasks file path.
|
|
26
|
-
* @returns A Vercel AI SDK tool with `description`, `parameters`, and `execute`.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* import { createTask } from 'agentool/task';
|
|
31
|
-
*
|
|
32
|
-
* const taskTool = createTask({ cwd: '/my/project' });
|
|
33
|
-
* const result = await taskTool.execute(
|
|
34
|
-
* { action: 'create', subject: 'Fix bug', description: 'Fix the login bug' },
|
|
35
|
-
* { toolCallId: 'id', messages: [] },
|
|
36
|
-
* );
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
declare function createTask(config?: TaskConfig): ai.Tool<{
|
|
40
|
-
action: "list" | "delete" | "create" | "get" | "update";
|
|
41
|
-
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
42
|
-
description?: string | undefined;
|
|
43
|
-
id?: string | undefined;
|
|
44
|
-
subject?: string | undefined;
|
|
45
|
-
}, string>;
|
|
46
|
-
/**
|
|
47
|
-
* Default task tool instance using `.agentool/tasks.json` under the current
|
|
48
|
-
* working directory.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```typescript
|
|
52
|
-
* import { task } from 'agentool/task';
|
|
53
|
-
* const result = await task.execute(
|
|
54
|
-
* { action: 'list' },
|
|
55
|
-
* { toolCallId: 'id', messages: [] },
|
|
56
|
-
* );
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
declare const task: ai.Tool<{
|
|
60
|
-
action: "list" | "delete" | "create" | "get" | "update";
|
|
61
|
-
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
62
|
-
description?: string | undefined;
|
|
63
|
-
id?: string | undefined;
|
|
64
|
-
subject?: string | undefined;
|
|
65
|
-
}, string>;
|
|
66
|
-
|
|
67
|
-
export { type TaskConfig, createTask, task };
|
package/dist/task/index.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as ai from 'ai';
|
|
2
|
-
import { B as BaseToolConfig } from '../types-3QPDuCXN.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Configuration for the task tool.
|
|
6
|
-
* Extends {@link BaseToolConfig} with an optional tasks file path.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import type { TaskConfig } from 'agentool/task';
|
|
11
|
-
* const config: TaskConfig = { cwd: '/my/project' };
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
interface TaskConfig extends BaseToolConfig {
|
|
15
|
-
/** Path to the tasks JSON file. Defaults to `<cwd>/.agentool/tasks.json`. */
|
|
16
|
-
tasksFile?: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Creates a task tool that provides JSON file-based task tracking.
|
|
20
|
-
*
|
|
21
|
-
* Tasks are stored in a single JSON file with CRUD operations.
|
|
22
|
-
* Each task has an id, subject, description, status, and timestamps.
|
|
23
|
-
* Execute never throws; errors are returned as descriptive strings.
|
|
24
|
-
*
|
|
25
|
-
* @param config - Optional configuration for cwd and tasks file path.
|
|
26
|
-
* @returns A Vercel AI SDK tool with `description`, `parameters`, and `execute`.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* import { createTask } from 'agentool/task';
|
|
31
|
-
*
|
|
32
|
-
* const taskTool = createTask({ cwd: '/my/project' });
|
|
33
|
-
* const result = await taskTool.execute(
|
|
34
|
-
* { action: 'create', subject: 'Fix bug', description: 'Fix the login bug' },
|
|
35
|
-
* { toolCallId: 'id', messages: [] },
|
|
36
|
-
* );
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
declare function createTask(config?: TaskConfig): ai.Tool<{
|
|
40
|
-
action: "list" | "delete" | "create" | "get" | "update";
|
|
41
|
-
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
42
|
-
description?: string | undefined;
|
|
43
|
-
id?: string | undefined;
|
|
44
|
-
subject?: string | undefined;
|
|
45
|
-
}, string>;
|
|
46
|
-
/**
|
|
47
|
-
* Default task tool instance using `.agentool/tasks.json` under the current
|
|
48
|
-
* working directory.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```typescript
|
|
52
|
-
* import { task } from 'agentool/task';
|
|
53
|
-
* const result = await task.execute(
|
|
54
|
-
* { action: 'list' },
|
|
55
|
-
* { toolCallId: 'id', messages: [] },
|
|
56
|
-
* );
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
declare const task: ai.Tool<{
|
|
60
|
-
action: "list" | "delete" | "create" | "get" | "update";
|
|
61
|
-
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
62
|
-
description?: string | undefined;
|
|
63
|
-
id?: string | undefined;
|
|
64
|
-
subject?: string | undefined;
|
|
65
|
-
}, string>;
|
|
66
|
-
|
|
67
|
-
export { type TaskConfig, createTask, task };
|