@termaxjs/web-ai 0.1.1
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/LICENSE +201 -0
- package/dist/config.d.ts +511 -0
- package/dist/config.js +708 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/lib/compact.d.ts +8 -0
- package/dist/lib/compact.js +179 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.js +4 -0
- package/dist/lib/miniWindowGeometry.d.ts +17 -0
- package/dist/lib/miniWindowGeometry.js +59 -0
- package/dist/lib/redact.d.ts +1 -0
- package/dist/lib/redact.js +34 -0
- package/dist/lib/security.d.ts +72 -0
- package/dist/lib/security.js +376 -0
- package/dist/tools/agent.d.ts +4 -0
- package/dist/tools/agent.js +22 -0
- package/dist/tools/context.d.ts +30 -0
- package/dist/tools/context.js +8 -0
- package/dist/tools/edit.d.ts +27 -0
- package/dist/tools/edit.js +161 -0
- package/dist/tools/fs.d.ts +93 -0
- package/dist/tools/fs.js +215 -0
- package/dist/tools/search.d.ts +48 -0
- package/dist/tools/search.js +118 -0
- package/dist/tools/shell.d.ts +7 -0
- package/dist/tools/shell.js +37 -0
- package/dist/tools/subagent.d.ts +2 -0
- package/dist/tools/subagent.js +3 -0
- package/dist/tools/terminal.d.ts +44 -0
- package/dist/tools/terminal.js +100 -0
- package/dist/tools/todo.d.ts +2 -0
- package/dist/tools/todo.js +3 -0
- package/dist/tools/tools.d.ts +236 -0
- package/dist/tools/tools.js +42 -0
- package/dist/types.d.ts +10 -0
- package/dist/types.js +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
export { resolvePath, type ToolContext } from "./context.js";
|
|
2
|
+
export { buildFsTools } from "./fs.js";
|
|
3
|
+
export { buildSearchTools } from "./search.js";
|
|
4
|
+
/**
|
|
5
|
+
* AI tool definitions.
|
|
6
|
+
*
|
|
7
|
+
* Approval policy:
|
|
8
|
+
* - Read-only tools (`read_file`, `list_directory`, `grep`, `glob`)
|
|
9
|
+
* auto-execute, but go through the security guard which refuses obvious
|
|
10
|
+
* secret paths (.env*, .ssh/, credentials, etc.).
|
|
11
|
+
* - Mutating tools (`write_file`, `edit`, `multi_edit`, `create_directory`,
|
|
12
|
+
* `run_command`) require explicit user approval — the AI SDK pauses on
|
|
13
|
+
* tool-call and surfaces a `tool-approval-request` part that the UI
|
|
14
|
+
* renders as a confirmation card.
|
|
15
|
+
* - `edit` / `multi_edit` additionally enforce a read-before-edit invariant
|
|
16
|
+
* (the model must have called read_file on the path earlier in the
|
|
17
|
+
* session).
|
|
18
|
+
*
|
|
19
|
+
* The model sees absolute paths only after they are resolved against the
|
|
20
|
+
* active terminal's cwd (provided via `getCwd`); it should not invent paths
|
|
21
|
+
* outside that.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildTools(ctx: import("./context.js").ToolContext): {
|
|
24
|
+
readonly run_subagent: any;
|
|
25
|
+
readonly suggest_command: import("ai").Tool<{
|
|
26
|
+
command: string;
|
|
27
|
+
explanation?: string | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
error: string;
|
|
30
|
+
command?: undefined;
|
|
31
|
+
explanation?: undefined;
|
|
32
|
+
} | {
|
|
33
|
+
command: string;
|
|
34
|
+
explanation: string | undefined;
|
|
35
|
+
error?: undefined;
|
|
36
|
+
}>;
|
|
37
|
+
readonly get_terminal_output: import("ai").Tool<{
|
|
38
|
+
lines?: number | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
error: string;
|
|
41
|
+
output?: undefined;
|
|
42
|
+
note?: undefined;
|
|
43
|
+
lines_returned?: undefined;
|
|
44
|
+
} | {
|
|
45
|
+
output: string;
|
|
46
|
+
note: string;
|
|
47
|
+
error?: undefined;
|
|
48
|
+
lines_returned?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
output: string;
|
|
51
|
+
lines_returned: number;
|
|
52
|
+
error?: undefined;
|
|
53
|
+
note?: undefined;
|
|
54
|
+
}>;
|
|
55
|
+
readonly open_preview: import("ai").Tool<{
|
|
56
|
+
url: string;
|
|
57
|
+
}, {
|
|
58
|
+
error: string;
|
|
59
|
+
url: string;
|
|
60
|
+
ok?: undefined;
|
|
61
|
+
} | {
|
|
62
|
+
url: string;
|
|
63
|
+
ok: boolean;
|
|
64
|
+
error?: undefined;
|
|
65
|
+
}>;
|
|
66
|
+
readonly bash_run: import("ai").Tool<{
|
|
67
|
+
command: string;
|
|
68
|
+
timeout_secs?: number | undefined;
|
|
69
|
+
}, any>;
|
|
70
|
+
readonly grep: import("ai").Tool<{
|
|
71
|
+
pattern: string;
|
|
72
|
+
root?: string | undefined;
|
|
73
|
+
glob?: string[] | undefined;
|
|
74
|
+
case_insensitive?: boolean | undefined;
|
|
75
|
+
max_results?: number | undefined;
|
|
76
|
+
}, {
|
|
77
|
+
error: string;
|
|
78
|
+
root?: undefined;
|
|
79
|
+
hits?: undefined;
|
|
80
|
+
truncated?: undefined;
|
|
81
|
+
files_scanned?: undefined;
|
|
82
|
+
} | {
|
|
83
|
+
error: string;
|
|
84
|
+
root: string;
|
|
85
|
+
hits?: undefined;
|
|
86
|
+
truncated?: undefined;
|
|
87
|
+
files_scanned?: undefined;
|
|
88
|
+
} | {
|
|
89
|
+
root: string;
|
|
90
|
+
hits: any;
|
|
91
|
+
truncated: any;
|
|
92
|
+
files_scanned: any;
|
|
93
|
+
error?: undefined;
|
|
94
|
+
}>;
|
|
95
|
+
readonly glob: import("ai").Tool<{
|
|
96
|
+
pattern: string;
|
|
97
|
+
root?: string | undefined;
|
|
98
|
+
max_results?: number | undefined;
|
|
99
|
+
}, {
|
|
100
|
+
error: string;
|
|
101
|
+
root?: undefined;
|
|
102
|
+
hits?: undefined;
|
|
103
|
+
truncated?: undefined;
|
|
104
|
+
} | {
|
|
105
|
+
error: string;
|
|
106
|
+
root: string;
|
|
107
|
+
hits?: undefined;
|
|
108
|
+
truncated?: undefined;
|
|
109
|
+
} | {
|
|
110
|
+
root: string;
|
|
111
|
+
hits: any;
|
|
112
|
+
truncated: any;
|
|
113
|
+
error?: undefined;
|
|
114
|
+
}>;
|
|
115
|
+
readonly edit: import("ai").Tool<{
|
|
116
|
+
path: string;
|
|
117
|
+
old_string: string;
|
|
118
|
+
new_string: string;
|
|
119
|
+
replace_all?: boolean | undefined;
|
|
120
|
+
}, {
|
|
121
|
+
ok: true;
|
|
122
|
+
replacements: number;
|
|
123
|
+
bytesWritten: number;
|
|
124
|
+
path: string;
|
|
125
|
+
} | {
|
|
126
|
+
error: string;
|
|
127
|
+
path: string;
|
|
128
|
+
}>;
|
|
129
|
+
readonly multi_edit: import("ai").Tool<{
|
|
130
|
+
path: string;
|
|
131
|
+
edits: {
|
|
132
|
+
old_string: string;
|
|
133
|
+
new_string: string;
|
|
134
|
+
replace_all?: boolean | undefined;
|
|
135
|
+
}[];
|
|
136
|
+
}, {
|
|
137
|
+
ok: true;
|
|
138
|
+
replacements: number;
|
|
139
|
+
bytesWritten: number;
|
|
140
|
+
path: string;
|
|
141
|
+
} | {
|
|
142
|
+
error: string;
|
|
143
|
+
path: string;
|
|
144
|
+
}>;
|
|
145
|
+
readonly read_file: import("ai").Tool<{
|
|
146
|
+
path: string;
|
|
147
|
+
offset?: number | undefined;
|
|
148
|
+
limit?: number | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
error: string;
|
|
151
|
+
path: string;
|
|
152
|
+
size?: undefined;
|
|
153
|
+
unchanged?: undefined;
|
|
154
|
+
} | {
|
|
155
|
+
error: string;
|
|
156
|
+
path: string;
|
|
157
|
+
size: any;
|
|
158
|
+
unchanged?: undefined;
|
|
159
|
+
} | {
|
|
160
|
+
path: string;
|
|
161
|
+
unchanged: boolean;
|
|
162
|
+
size: any;
|
|
163
|
+
error?: undefined;
|
|
164
|
+
} | {
|
|
165
|
+
truncated?: boolean | undefined;
|
|
166
|
+
hint?: string | undefined;
|
|
167
|
+
path: string;
|
|
168
|
+
content: any;
|
|
169
|
+
size: any;
|
|
170
|
+
total_lines: any;
|
|
171
|
+
error?: undefined;
|
|
172
|
+
unchanged?: undefined;
|
|
173
|
+
} | {
|
|
174
|
+
truncated?: boolean | undefined;
|
|
175
|
+
path: string;
|
|
176
|
+
content: any;
|
|
177
|
+
size: any;
|
|
178
|
+
total_lines: any;
|
|
179
|
+
start_line: number;
|
|
180
|
+
end_line: number;
|
|
181
|
+
error?: undefined;
|
|
182
|
+
unchanged?: undefined;
|
|
183
|
+
}>;
|
|
184
|
+
readonly list_directory: import("ai").Tool<{
|
|
185
|
+
path: string;
|
|
186
|
+
}, {
|
|
187
|
+
error: string;
|
|
188
|
+
path: string;
|
|
189
|
+
entries?: undefined;
|
|
190
|
+
} | {
|
|
191
|
+
path: string;
|
|
192
|
+
entries: any;
|
|
193
|
+
error?: undefined;
|
|
194
|
+
}>;
|
|
195
|
+
readonly write_file: import("ai").Tool<{
|
|
196
|
+
path: string;
|
|
197
|
+
content: string;
|
|
198
|
+
}, {
|
|
199
|
+
error: string;
|
|
200
|
+
path: string;
|
|
201
|
+
queued_for_plan_review?: undefined;
|
|
202
|
+
ok?: undefined;
|
|
203
|
+
bytesWritten?: undefined;
|
|
204
|
+
} | {
|
|
205
|
+
path: string;
|
|
206
|
+
queued_for_plan_review: boolean;
|
|
207
|
+
ok: boolean;
|
|
208
|
+
error?: undefined;
|
|
209
|
+
bytesWritten?: undefined;
|
|
210
|
+
} | {
|
|
211
|
+
path: string;
|
|
212
|
+
bytesWritten: number;
|
|
213
|
+
ok: boolean;
|
|
214
|
+
error?: undefined;
|
|
215
|
+
queued_for_plan_review?: undefined;
|
|
216
|
+
}>;
|
|
217
|
+
readonly create_directory: import("ai").Tool<{
|
|
218
|
+
path: string;
|
|
219
|
+
}, {
|
|
220
|
+
error: string;
|
|
221
|
+
path: string;
|
|
222
|
+
queued_for_plan_review?: undefined;
|
|
223
|
+
ok?: undefined;
|
|
224
|
+
} | {
|
|
225
|
+
path: string;
|
|
226
|
+
queued_for_plan_review: boolean;
|
|
227
|
+
ok: boolean;
|
|
228
|
+
error?: undefined;
|
|
229
|
+
} | {
|
|
230
|
+
path: string;
|
|
231
|
+
ok: boolean;
|
|
232
|
+
error?: undefined;
|
|
233
|
+
queued_for_plan_review?: undefined;
|
|
234
|
+
}>;
|
|
235
|
+
};
|
|
236
|
+
export type ChatTools = ReturnType<typeof buildTools>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { buildManagedAgentTools } from "./agent.js";
|
|
2
|
+
import { buildEditTools } from "./edit.js";
|
|
3
|
+
import { buildFsTools } from "./fs.js";
|
|
4
|
+
import { buildSearchTools } from "./search.js";
|
|
5
|
+
import { buildShellTools } from "./shell.js";
|
|
6
|
+
import { buildSubagentTools } from "./subagent.js";
|
|
7
|
+
import { buildTerminalTools } from "./terminal.js";
|
|
8
|
+
import { buildTodoTools } from "./todo.js";
|
|
9
|
+
export { resolvePath } from "./context.js";
|
|
10
|
+
export { buildFsTools } from "./fs.js";
|
|
11
|
+
export { buildSearchTools } from "./search.js";
|
|
12
|
+
/**
|
|
13
|
+
* AI tool definitions.
|
|
14
|
+
*
|
|
15
|
+
* Approval policy:
|
|
16
|
+
* - Read-only tools (`read_file`, `list_directory`, `grep`, `glob`)
|
|
17
|
+
* auto-execute, but go through the security guard which refuses obvious
|
|
18
|
+
* secret paths (.env*, .ssh/, credentials, etc.).
|
|
19
|
+
* - Mutating tools (`write_file`, `edit`, `multi_edit`, `create_directory`,
|
|
20
|
+
* `run_command`) require explicit user approval — the AI SDK pauses on
|
|
21
|
+
* tool-call and surfaces a `tool-approval-request` part that the UI
|
|
22
|
+
* renders as a confirmation card.
|
|
23
|
+
* - `edit` / `multi_edit` additionally enforce a read-before-edit invariant
|
|
24
|
+
* (the model must have called read_file on the path earlier in the
|
|
25
|
+
* session).
|
|
26
|
+
*
|
|
27
|
+
* The model sees absolute paths only after they are resolved against the
|
|
28
|
+
* active terminal's cwd (provided via `getCwd`); it should not invent paths
|
|
29
|
+
* outside that.
|
|
30
|
+
*/
|
|
31
|
+
export function buildTools(ctx) {
|
|
32
|
+
return {
|
|
33
|
+
...buildFsTools(ctx),
|
|
34
|
+
...buildEditTools(ctx),
|
|
35
|
+
...buildSearchTools(ctx),
|
|
36
|
+
...buildShellTools(ctx),
|
|
37
|
+
...buildSubagentTools(ctx),
|
|
38
|
+
...buildTerminalTools(ctx),
|
|
39
|
+
...buildTodoTools(ctx),
|
|
40
|
+
...buildManagedAgentTools(ctx),
|
|
41
|
+
};
|
|
42
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface AiAdapter {
|
|
2
|
+
getKey: (providerId: string) => Promise<string | null>;
|
|
3
|
+
native: any;
|
|
4
|
+
isPlanActive: () => boolean;
|
|
5
|
+
enqueuePlanEdit: (edit: any) => void;
|
|
6
|
+
getWorkspaceEnv: () => Promise<Record<string, string>>;
|
|
7
|
+
getWorkspaceScopeKey: () => Promise<string>;
|
|
8
|
+
writeToTerminalSession: (sessionId: string, data: string) => void;
|
|
9
|
+
spawnManagedAgent: (opts: any) => Promise<any>;
|
|
10
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@termaxjs/web-ai",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Headless AI engine for Termax",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./tools": {
|
|
15
|
+
"types": "./dist/tools/tools.d.ts",
|
|
16
|
+
"import": "./dist/tools/tools.js",
|
|
17
|
+
"default": "./dist/tools/tools.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"zustand": "^5.0.0"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@ai-sdk/anthropic": "^3.0.81",
|
|
25
|
+
"@ai-sdk/cerebras": "^2.0.54",
|
|
26
|
+
"@ai-sdk/google": "^3.0.80",
|
|
27
|
+
"@ai-sdk/groq": "^3.0.39",
|
|
28
|
+
"@ai-sdk/openai": "^3.0.67",
|
|
29
|
+
"ai": "^6.0.196",
|
|
30
|
+
"zod": "^4.4.3"
|
|
31
|
+
},
|
|
32
|
+
"type": "module",
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"typescript": "^5.7.2",
|
|
35
|
+
"vitest": "^3.0.5"
|
|
36
|
+
},
|
|
37
|
+
"license": "Apache-2.0",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"LICENSE",
|
|
41
|
+
"README.md"
|
|
42
|
+
],
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsc",
|
|
48
|
+
"check-types": "tsc --noEmit",
|
|
49
|
+
"test": "vitest run --passWithNoTests"
|
|
50
|
+
}
|
|
51
|
+
}
|