@ai-setting/roy-agent-core 1.5.14-test → 1.5.15-test
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/package.json +1 -1
- package/dist/config/index.d.ts +0 -1250
- package/dist/config/index.js +0 -32
- package/dist/env/agent/index.d.ts +0 -2279
- package/dist/env/agent/index.js +0 -24
- package/dist/env/commands/index.d.ts +0 -1131
- package/dist/env/commands/index.js +0 -14
- package/dist/env/debug/formatters/index.d.ts +0 -236
- package/dist/env/debug/formatters/index.js +0 -11
- package/dist/env/debug/index.d.ts +0 -1652
- package/dist/env/debug/index.js +0 -26
- package/dist/env/hook/index.d.ts +0 -279
- package/dist/env/hook/index.js +0 -29
- package/dist/env/index.d.ts +0 -3481
- package/dist/env/index.js +0 -82
- package/dist/env/llm/index.d.ts +0 -1760
- package/dist/env/llm/index.js +0 -40
- package/dist/env/log-trace/index.d.ts +0 -1574
- package/dist/env/log-trace/index.js +0 -83
- package/dist/env/mcp/index.d.ts +0 -1331
- package/dist/env/mcp/index.js +0 -39
- package/dist/env/mcp/tool/index.d.ts +0 -183
- package/dist/env/mcp/tool/index.js +0 -14
- package/dist/env/memory/built-in/index.d.ts +0 -232
- package/dist/env/memory/built-in/index.js +0 -11
- package/dist/env/memory/index.d.ts +0 -1799
- package/dist/env/memory/index.js +0 -56
- package/dist/env/memory/plugin/index.d.ts +0 -747
- package/dist/env/memory/plugin/index.js +0 -36
- package/dist/env/prompt/index.d.ts +0 -1164
- package/dist/env/prompt/index.js +0 -20
- package/dist/env/session/index.d.ts +0 -1908
- package/dist/env/session/index.js +0 -25
- package/dist/env/session/storage/index.d.ts +0 -564
- package/dist/env/session/storage/index.js +0 -18
- package/dist/env/skill/index.d.ts +0 -1266
- package/dist/env/skill/index.js +0 -34
- package/dist/env/skill/tool/index.d.ts +0 -193
- package/dist/env/skill/tool/index.js +0 -9
- package/dist/env/task/delegate/index.d.ts +0 -1612
- package/dist/env/task/delegate/index.js +0 -18
- package/dist/env/task/events/index.d.ts +0 -171
- package/dist/env/task/events/index.js +0 -7
- package/dist/env/task/hooks/index.d.ts +0 -624
- package/dist/env/task/hooks/index.js +0 -7
- package/dist/env/task/index.d.ts +0 -1553
- package/dist/env/task/index.js +0 -34
- package/dist/env/task/plugins/index.d.ts +0 -466
- package/dist/env/task/plugins/index.js +0 -23
- package/dist/env/task/storage/index.d.ts +0 -241
- package/dist/env/task/storage/index.js +0 -14
- package/dist/env/task/tools/index.d.ts +0 -1485
- package/dist/env/task/tools/index.js +0 -17
- package/dist/env/task/tools/operation/index.d.ts +0 -1484
- package/dist/env/task/tools/operation/index.js +0 -15
- package/dist/env/tool/built-in/index.d.ts +0 -218
- package/dist/env/tool/built-in/index.js +0 -25
- package/dist/env/tool/index.d.ts +0 -1396
- package/dist/env/tool/index.js +0 -39
- package/dist/env/workflow/decorators/index.d.ts +0 -2161
- package/dist/env/workflow/decorators/index.js +0 -27
- package/dist/env/workflow/engine/index.d.ts +0 -3453
- package/dist/env/workflow/engine/index.js +0 -28
- package/dist/env/workflow/index.d.ts +0 -3546
- package/dist/env/workflow/index.js +0 -136
- package/dist/env/workflow/nodes/index.d.ts +0 -2092
- package/dist/env/workflow/nodes/index.js +0 -19
- package/dist/env/workflow/service/index.d.ts +0 -227
- package/dist/env/workflow/service/index.js +0 -13
- package/dist/env/workflow/storage/index.d.ts +0 -165
- package/dist/env/workflow/storage/index.js +0 -27
- package/dist/env/workflow/tools/index.d.ts +0 -416
- package/dist/env/workflow/tools/index.js +0 -159
- package/dist/env/workflow/types/index.d.ts +0 -2255
- package/dist/env/workflow/types/index.js +0 -98
- package/dist/env/workflow/utils/index.d.ts +0 -2031
- package/dist/env/workflow/utils/index.js +0 -637
- package/dist/index.d.ts +0 -7858
- package/dist/index.js +0 -399
- package/dist/shared/@ai-setting/roy-agent-core-0rtxwr28.js +0 -258
- package/dist/shared/@ai-setting/roy-agent-core-0vbdz0x7.js +0 -36
- package/dist/shared/@ai-setting/roy-agent-core-1akcqxj9.js +0 -349
- package/dist/shared/@ai-setting/roy-agent-core-1ce3fqrk.js +0 -117
- package/dist/shared/@ai-setting/roy-agent-core-2dhd60aw.js +0 -11
- package/dist/shared/@ai-setting/roy-agent-core-3jywqmdd.js +0 -393
- package/dist/shared/@ai-setting/roy-agent-core-3rr5k71j.js +0 -200
- package/dist/shared/@ai-setting/roy-agent-core-44hnfb02.js +0 -299
- package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +0 -206
- package/dist/shared/@ai-setting/roy-agent-core-4txzpsbt.js +0 -393
- package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +0 -350
- package/dist/shared/@ai-setting/roy-agent-core-69jskqjg.js +0 -180
- package/dist/shared/@ai-setting/roy-agent-core-6kvtahqv.js +0 -408
- package/dist/shared/@ai-setting/roy-agent-core-7fgf85wc.js +0 -284
- package/dist/shared/@ai-setting/roy-agent-core-81w1963m.js +0 -762
- package/dist/shared/@ai-setting/roy-agent-core-8gxth0eh.js +0 -10
- package/dist/shared/@ai-setting/roy-agent-core-92z6t4he.js +0 -14
- package/dist/shared/@ai-setting/roy-agent-core-93zfb3r1.js +0 -922
- package/dist/shared/@ai-setting/roy-agent-core-9yxb3ty9.js +0 -15
- package/dist/shared/@ai-setting/roy-agent-core-b0x5dda6.js +0 -1130
- package/dist/shared/@ai-setting/roy-agent-core-bcbqy27c.js +0 -14
- package/dist/shared/@ai-setting/roy-agent-core-bvr1761x.js +0 -653
- package/dist/shared/@ai-setting/roy-agent-core-ctdhjv68.js +0 -93
- package/dist/shared/@ai-setting/roy-agent-core-d7cyjkf7.js +0 -872
- package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +0 -11
- package/dist/shared/@ai-setting/roy-agent-core-e25xkv53.js +0 -64
- package/dist/shared/@ai-setting/roy-agent-core-eajcvp4e.js +0 -378
- package/dist/shared/@ai-setting/roy-agent-core-f7q2x5z6.js +0 -492
- package/dist/shared/@ai-setting/roy-agent-core-fs0mn2jk.js +0 -52
- package/dist/shared/@ai-setting/roy-agent-core-g1s2h0e5.js +0 -171
- package/dist/shared/@ai-setting/roy-agent-core-g99pxzn5.js +0 -862
- package/dist/shared/@ai-setting/roy-agent-core-gbqcyegm.js +0 -1387
- package/dist/shared/@ai-setting/roy-agent-core-gjq1yk68.js +0 -208
- package/dist/shared/@ai-setting/roy-agent-core-gq20wsgv.js +0 -139
- package/dist/shared/@ai-setting/roy-agent-core-gwc4h96n.js +0 -534
- package/dist/shared/@ai-setting/roy-agent-core-jfh9q2qh.js +0 -204
- package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +0 -603
- package/dist/shared/@ai-setting/roy-agent-core-kkbwepqb.js +0 -97
- package/dist/shared/@ai-setting/roy-agent-core-pjr12nnd.js +0 -587
- package/dist/shared/@ai-setting/roy-agent-core-psv4v63c.js +0 -176
- package/dist/shared/@ai-setting/roy-agent-core-psvxt4c9.js +0 -60
- package/dist/shared/@ai-setting/roy-agent-core-qqceba6k.js +0 -442
- package/dist/shared/@ai-setting/roy-agent-core-qxhq8ven.js +0 -57
- package/dist/shared/@ai-setting/roy-agent-core-qxnbvgwe.js +0 -66
- package/dist/shared/@ai-setting/roy-agent-core-r9ezzemr.js +0 -10
- package/dist/shared/@ai-setting/roy-agent-core-rhmtwnw1.js +0 -267
- package/dist/shared/@ai-setting/roy-agent-core-rvv6ydff.js +0 -584
- package/dist/shared/@ai-setting/roy-agent-core-rvxg1wps.js +0 -102
- package/dist/shared/@ai-setting/roy-agent-core-satmq6sh.js +0 -549
- package/dist/shared/@ai-setting/roy-agent-core-sx7wsvnn.js +0 -15
- package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +0 -213
- package/dist/shared/@ai-setting/roy-agent-core-vf215qfv.js +0 -812
- package/dist/shared/@ai-setting/roy-agent-core-vkz81f7v.js +0 -1316
- package/dist/shared/@ai-setting/roy-agent-core-vn2bc59q.js +0 -1205
- package/dist/shared/@ai-setting/roy-agent-core-wa1kzqky.js +0 -328
- package/dist/shared/@ai-setting/roy-agent-core-wft9ra24.js +0 -20
- package/dist/shared/@ai-setting/roy-agent-core-wrcy0h6z.js +0 -2098
- package/dist/shared/@ai-setting/roy-agent-core-xq8hhqb8.js +0 -419
- package/dist/shared/@ai-setting/roy-agent-core-xs5rsgat.js +0 -368
- package/dist/shared/@ai-setting/roy-agent-core-zbkpc41z.js +0 -377
- package/dist/shared/@ai-setting/roy-agent-core-zgypchmt.js +0 -172
- package/dist/shared/@ai-setting/roy-agent-core-zpn0bqa8.js +0 -103
|
@@ -1,549 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
exports_tracer_provider,
|
|
3
|
-
init_propagation,
|
|
4
|
-
init_tracer_provider,
|
|
5
|
-
propagation
|
|
6
|
-
} from "./roy-agent-core-xs5rsgat.js";
|
|
7
|
-
import {
|
|
8
|
-
__toCommonJS
|
|
9
|
-
} from "./roy-agent-core-fs0mn2jk.js";
|
|
10
|
-
|
|
11
|
-
// src/env/tool/built-in/bash.ts
|
|
12
|
-
init_propagation();
|
|
13
|
-
import { z } from "zod";
|
|
14
|
-
import { exec } from "child_process";
|
|
15
|
-
import { promisify } from "util";
|
|
16
|
-
var execAsync = promisify(exec);
|
|
17
|
-
function getCurrentSpanContext() {
|
|
18
|
-
try {
|
|
19
|
-
const { getTracerProvider } = (init_tracer_provider(), __toCommonJS(exports_tracer_provider));
|
|
20
|
-
const provider = getTracerProvider();
|
|
21
|
-
if (!provider.isInitialized()) {
|
|
22
|
-
throw new Error("Provider not initialized");
|
|
23
|
-
}
|
|
24
|
-
const tracer = provider.getTracer("roy-tracer");
|
|
25
|
-
const ctx = tracer.getCurrentContext();
|
|
26
|
-
if (ctx && ctx.traceId && ctx.spanId) {
|
|
27
|
-
return ctx;
|
|
28
|
-
}
|
|
29
|
-
} catch {}
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
function getCurrentTraceId() {
|
|
33
|
-
const ctx = getCurrentSpanContext();
|
|
34
|
-
if (ctx) {
|
|
35
|
-
return ctx.traceId;
|
|
36
|
-
}
|
|
37
|
-
return process.env.TRACE_ID;
|
|
38
|
-
}
|
|
39
|
-
var bashTool = {
|
|
40
|
-
name: "bash",
|
|
41
|
-
description: "Execute shell commands in the terminal. Use this to run system commands, scripts, or interact with the file system.",
|
|
42
|
-
parameters: z.object({
|
|
43
|
-
command: z.string().describe("The shell command to execute"),
|
|
44
|
-
workdir: z.string().optional().describe("Working directory for the command"),
|
|
45
|
-
timeout: z.number().int().positive().optional().describe("Timeout in milliseconds"),
|
|
46
|
-
env: z.record(z.string()).optional().describe("Additional environment variables")
|
|
47
|
-
}),
|
|
48
|
-
sandbox: {
|
|
49
|
-
enabled: true,
|
|
50
|
-
config: {
|
|
51
|
-
filesystem: {
|
|
52
|
-
denyRead: ["/etc/shadow", "/etc/sudoers", "/etc/sudoers.d/*"],
|
|
53
|
-
denyWrite: ["/etc", "/usr/bin", "/usr/sbin", "/bin", "/sbin"]
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
permission: {
|
|
58
|
-
requireConfirmation: true,
|
|
59
|
-
level: "dangerous"
|
|
60
|
-
},
|
|
61
|
-
metadata: {
|
|
62
|
-
category: "system",
|
|
63
|
-
tags: ["shell", "command", "terminal", "exec"],
|
|
64
|
-
version: "1.2.0"
|
|
65
|
-
},
|
|
66
|
-
execute: async (args, ctx) => {
|
|
67
|
-
const startTime = Date.now();
|
|
68
|
-
const { command, workdir, timeout = 60000, env } = args;
|
|
69
|
-
const currentSpanCtx = getCurrentSpanContext();
|
|
70
|
-
const traceId = currentSpanCtx?.traceId || getCurrentTraceId();
|
|
71
|
-
const options = {
|
|
72
|
-
timeout
|
|
73
|
-
};
|
|
74
|
-
if (workdir || ctx.workdir) {
|
|
75
|
-
options.cwd = workdir || ctx.workdir;
|
|
76
|
-
}
|
|
77
|
-
const childEnv = {};
|
|
78
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
79
|
-
if (value !== undefined) {
|
|
80
|
-
childEnv[key] = value;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (currentSpanCtx) {
|
|
84
|
-
const carrier = {};
|
|
85
|
-
propagation.inject(carrier, currentSpanCtx);
|
|
86
|
-
if (carrier["TRACEPARENT"]) {
|
|
87
|
-
childEnv["TRACEPARENT"] = carrier["TRACEPARENT"];
|
|
88
|
-
}
|
|
89
|
-
childEnv["TRACE_ID"] = currentSpanCtx.traceId;
|
|
90
|
-
childEnv["PARENT_SPAN_ID"] = currentSpanCtx.spanId;
|
|
91
|
-
} else if (traceId) {
|
|
92
|
-
const spanId2 = Math.floor(Math.random() * 18446744073709552000).toString(16).padStart(16, "0");
|
|
93
|
-
childEnv["TRACEPARENT"] = `00-${traceId}-${spanId2}-01`;
|
|
94
|
-
childEnv["TRACE_ID"] = traceId;
|
|
95
|
-
}
|
|
96
|
-
if (env) {
|
|
97
|
-
Object.assign(childEnv, env);
|
|
98
|
-
}
|
|
99
|
-
options.env = childEnv;
|
|
100
|
-
let otelSpan = undefined;
|
|
101
|
-
try {
|
|
102
|
-
const { getTracerProvider } = (init_tracer_provider(), __toCommonJS(exports_tracer_provider));
|
|
103
|
-
const provider = getTracerProvider();
|
|
104
|
-
const tracer = provider.getTracer("roy-tracer");
|
|
105
|
-
otelSpan = tracer.startSpan(`bash: ${command.slice(0, 50)}${command.length > 50 ? "..." : ""}`, {
|
|
106
|
-
attributes: {
|
|
107
|
-
"bash.command": command.slice(0, 200),
|
|
108
|
-
"bash.workdir": workdir || ctx.workdir || "",
|
|
109
|
-
"bash.timeout": timeout
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
} catch {}
|
|
113
|
-
const spanId = otelSpan?.spanContext?.spanId;
|
|
114
|
-
try {
|
|
115
|
-
const { stdout, stderr } = await execAsync(command, options);
|
|
116
|
-
if (otelSpan) {
|
|
117
|
-
otelSpan.end({ stdout, stderr });
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
success: true,
|
|
121
|
-
output: stdout || "(no output)",
|
|
122
|
-
metadata: {
|
|
123
|
-
execution_time_ms: Date.now() - startTime,
|
|
124
|
-
stdout,
|
|
125
|
-
stderr,
|
|
126
|
-
exit_code: 0,
|
|
127
|
-
trace_id: traceId,
|
|
128
|
-
parent_span_id: currentSpanCtx?.spanId,
|
|
129
|
-
span_id: spanId
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
} catch (error) {
|
|
133
|
-
const exitCode = error.code || 1;
|
|
134
|
-
const stdout = error.stdout || "";
|
|
135
|
-
const stderr = error.stderr || error.message;
|
|
136
|
-
const execError = new Error(stderr);
|
|
137
|
-
execError.name = "BashExecutionError";
|
|
138
|
-
if (otelSpan) {
|
|
139
|
-
otelSpan.end(undefined, execError);
|
|
140
|
-
}
|
|
141
|
-
return {
|
|
142
|
-
success: exitCode === 0,
|
|
143
|
-
output: stdout || "(no output)",
|
|
144
|
-
error: stderr,
|
|
145
|
-
metadata: {
|
|
146
|
-
execution_time_ms: Date.now() - startTime,
|
|
147
|
-
stdout,
|
|
148
|
-
stderr,
|
|
149
|
-
exit_code: exitCode,
|
|
150
|
-
trace_id: traceId,
|
|
151
|
-
parent_span_id: currentSpanCtx?.spanId,
|
|
152
|
-
span_id: spanId
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
// src/env/tool/built-in/echo.ts
|
|
160
|
-
var echoTool = {
|
|
161
|
-
name: "echo",
|
|
162
|
-
description: "Echo a message to the console. Useful for logging in workflows.",
|
|
163
|
-
parameters: {
|
|
164
|
-
name: "message",
|
|
165
|
-
schema: {
|
|
166
|
-
type: "string",
|
|
167
|
-
description: "The message to echo"
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
execute: async (args, _ctx) => {
|
|
171
|
-
const message = args?.message || "(no message)";
|
|
172
|
-
return {
|
|
173
|
-
success: true,
|
|
174
|
-
output: message,
|
|
175
|
-
metadata: {
|
|
176
|
-
execution_time_ms: 0
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
// src/env/tool/built-in/glob.ts
|
|
183
|
-
import { z as z2 } from "zod";
|
|
184
|
-
import { glob as globAsync } from "glob";
|
|
185
|
-
var globTool = {
|
|
186
|
-
name: "glob",
|
|
187
|
-
description: "Search for files matching a glob pattern. Use this to find files by name patterns like **/*.ts or **/*.md.",
|
|
188
|
-
parameters: z2.object({
|
|
189
|
-
pattern: z2.string().describe("Glob pattern to match (e.g., **/*.ts, **/*.md)"),
|
|
190
|
-
cwd: z2.string().optional().describe("Working directory to search in"),
|
|
191
|
-
maxResults: z2.number().int().positive().optional().describe("Maximum number of results to return"),
|
|
192
|
-
ignore: z2.array(z2.string()).optional().describe("Patterns to ignore")
|
|
193
|
-
}),
|
|
194
|
-
sandbox: {
|
|
195
|
-
enabled: true
|
|
196
|
-
},
|
|
197
|
-
metadata: {
|
|
198
|
-
category: "file",
|
|
199
|
-
tags: ["search", "file", "glob", "pattern"],
|
|
200
|
-
version: "1.0.0"
|
|
201
|
-
},
|
|
202
|
-
execute: async (args, ctx) => {
|
|
203
|
-
const startTime = Date.now();
|
|
204
|
-
const { pattern, cwd, maxResults = 100, ignore } = args;
|
|
205
|
-
const searchDir = cwd || ctx.workdir || process.cwd();
|
|
206
|
-
try {
|
|
207
|
-
const files = await globAsync(pattern, {
|
|
208
|
-
cwd: searchDir,
|
|
209
|
-
ignore: ignore || ["**/node_modules/**", "**/.git/**"],
|
|
210
|
-
maxDepth: 20
|
|
211
|
-
});
|
|
212
|
-
const limitedFiles = files.slice(0, maxResults);
|
|
213
|
-
const output = limitedFiles.join(`
|
|
214
|
-
`);
|
|
215
|
-
return {
|
|
216
|
-
success: true,
|
|
217
|
-
output,
|
|
218
|
-
metadata: {
|
|
219
|
-
execution_time_ms: Date.now() - startTime,
|
|
220
|
-
output_size: output.length,
|
|
221
|
-
total_matches: files.length,
|
|
222
|
-
returned_matches: limitedFiles.length
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
} catch (error) {
|
|
226
|
-
return {
|
|
227
|
-
success: false,
|
|
228
|
-
output: "",
|
|
229
|
-
error: error instanceof Error ? error.message : String(error),
|
|
230
|
-
metadata: {
|
|
231
|
-
execution_time_ms: Date.now() - startTime
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
// src/env/tool/built-in/read-file.ts
|
|
239
|
-
import { z as z3 } from "zod";
|
|
240
|
-
import { readFile } from "fs/promises";
|
|
241
|
-
var readFileTool = {
|
|
242
|
-
name: "read_file",
|
|
243
|
-
description: "Read the contents of a file. Use this to read source code, configuration files, or any text files.",
|
|
244
|
-
parameters: z3.object({
|
|
245
|
-
path: z3.string().describe("The file path to read"),
|
|
246
|
-
offset: z3.number().int().nonnegative().optional().describe("Line offset to start reading from"),
|
|
247
|
-
limit: z3.number().int().positive().optional().describe("Number of lines to read"),
|
|
248
|
-
encoding: z3.enum(["utf-8", "base64"]).default("utf-8").optional().describe("File encoding")
|
|
249
|
-
}),
|
|
250
|
-
sandbox: {
|
|
251
|
-
enabled: true,
|
|
252
|
-
config: {
|
|
253
|
-
filesystem: {
|
|
254
|
-
denyRead: ["/etc/shadow", "/etc/sudoers", "/root/.ssh"]
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
permission: {
|
|
259
|
-
level: "safe"
|
|
260
|
-
},
|
|
261
|
-
metadata: {
|
|
262
|
-
category: "file",
|
|
263
|
-
tags: ["read", "file", "io"],
|
|
264
|
-
version: "1.0.0"
|
|
265
|
-
},
|
|
266
|
-
execute: async (args, ctx) => {
|
|
267
|
-
const startTime = Date.now();
|
|
268
|
-
const { path: filePath, offset, limit, encoding = "utf-8" } = args;
|
|
269
|
-
try {
|
|
270
|
-
const content = await readFile(filePath, encoding);
|
|
271
|
-
let output;
|
|
272
|
-
const contentBuffer = content;
|
|
273
|
-
const contentStr = typeof contentBuffer === "string" ? contentBuffer : contentBuffer.toString(encoding);
|
|
274
|
-
if (offset !== undefined || limit !== undefined) {
|
|
275
|
-
const lines = contentStr.split(`
|
|
276
|
-
`);
|
|
277
|
-
const startLine = offset || 0;
|
|
278
|
-
const endLine = limit ? startLine + limit : lines.length;
|
|
279
|
-
output = lines.slice(startLine, endLine).join(`
|
|
280
|
-
`);
|
|
281
|
-
} else {
|
|
282
|
-
output = contentStr;
|
|
283
|
-
}
|
|
284
|
-
return {
|
|
285
|
-
success: true,
|
|
286
|
-
output,
|
|
287
|
-
metadata: {
|
|
288
|
-
execution_time_ms: Date.now() - startTime,
|
|
289
|
-
output_size: output.length,
|
|
290
|
-
file_path: filePath
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
} catch (error) {
|
|
294
|
-
return {
|
|
295
|
-
success: false,
|
|
296
|
-
output: "",
|
|
297
|
-
error: error instanceof Error ? error.message : String(error),
|
|
298
|
-
metadata: {
|
|
299
|
-
execution_time_ms: Date.now() - startTime
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
// src/env/tool/built-in/write-file.ts
|
|
307
|
-
import { z as z4 } from "zod";
|
|
308
|
-
import { writeFile, mkdir } from "fs/promises";
|
|
309
|
-
import { dirname } from "path";
|
|
310
|
-
var writeFileTool = {
|
|
311
|
-
name: "write_file",
|
|
312
|
-
description: "Write content to a file. Use this to create new files or overwrite existing ones.",
|
|
313
|
-
parameters: z4.object({
|
|
314
|
-
path: z4.string().describe("The file path to write to"),
|
|
315
|
-
content: z4.string().describe("The content to write"),
|
|
316
|
-
createDirs: z4.boolean().default(false).optional().describe("Create parent directories if they don't exist"),
|
|
317
|
-
append: z4.boolean().default(false).optional().describe("Append to file instead of overwrite")
|
|
318
|
-
}),
|
|
319
|
-
sandbox: {
|
|
320
|
-
enabled: true,
|
|
321
|
-
config: {
|
|
322
|
-
filesystem: {
|
|
323
|
-
denyWrite: ["/etc", "/usr", "/bin", "/sbin", "/boot", "/sys"]
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
permission: {
|
|
328
|
-
requireConfirmation: true,
|
|
329
|
-
level: "dangerous"
|
|
330
|
-
},
|
|
331
|
-
metadata: {
|
|
332
|
-
category: "file",
|
|
333
|
-
tags: ["write", "file", "io", "create"],
|
|
334
|
-
version: "1.0.0"
|
|
335
|
-
},
|
|
336
|
-
execute: async (args, ctx) => {
|
|
337
|
-
const startTime = Date.now();
|
|
338
|
-
const { path: filePath, content, createDirs = false, append = false } = args;
|
|
339
|
-
try {
|
|
340
|
-
if (createDirs) {
|
|
341
|
-
await mkdir(dirname(filePath), { recursive: true });
|
|
342
|
-
}
|
|
343
|
-
const flags = append ? "a" : "w";
|
|
344
|
-
await writeFile(filePath, content, { flag: flags });
|
|
345
|
-
return {
|
|
346
|
-
success: true,
|
|
347
|
-
output: append ? `Content appended to: ${filePath}` : `File written: ${filePath}`,
|
|
348
|
-
metadata: {
|
|
349
|
-
execution_time_ms: Date.now() - startTime,
|
|
350
|
-
output_size: content.length,
|
|
351
|
-
file_path: filePath
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
} catch (error) {
|
|
355
|
-
return {
|
|
356
|
-
success: false,
|
|
357
|
-
output: "",
|
|
358
|
-
error: error instanceof Error ? error.message : String(error),
|
|
359
|
-
metadata: {
|
|
360
|
-
execution_time_ms: Date.now() - startTime
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
// src/env/tool/built-in/edit-file.ts
|
|
368
|
-
import { z as z5 } from "zod";
|
|
369
|
-
import { readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
370
|
-
var editFileTool = {
|
|
371
|
-
name: "edit_file",
|
|
372
|
-
description: "Edit a file by replacing specific text. Use this to make targeted changes to files by specifying what to find and what to replace.",
|
|
373
|
-
parameters: z5.object({
|
|
374
|
-
path: z5.string().describe("The file path to edit"),
|
|
375
|
-
oldString: z5.string().describe("The text to find and replace"),
|
|
376
|
-
newString: z5.string().describe("The replacement text"),
|
|
377
|
-
replaceAll: z5.boolean().default(false).optional().describe("Replace all occurrences instead of just the first")
|
|
378
|
-
}),
|
|
379
|
-
sandbox: {
|
|
380
|
-
enabled: true,
|
|
381
|
-
config: {
|
|
382
|
-
filesystem: {
|
|
383
|
-
denyWrite: ["/etc", "/usr/bin", "/usr/sbin", "/bin", "/sbin"]
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
},
|
|
387
|
-
permission: {
|
|
388
|
-
requireConfirmation: true,
|
|
389
|
-
level: "dangerous"
|
|
390
|
-
},
|
|
391
|
-
metadata: {
|
|
392
|
-
category: "file",
|
|
393
|
-
tags: ["edit", "file", "replace", "modify"],
|
|
394
|
-
version: "1.0.0"
|
|
395
|
-
},
|
|
396
|
-
execute: async (args, ctx) => {
|
|
397
|
-
const startTime = Date.now();
|
|
398
|
-
const { path: filePath, oldString, newString, replaceAll = false } = args;
|
|
399
|
-
try {
|
|
400
|
-
const content = await readFile2(filePath, "utf-8");
|
|
401
|
-
const searchPattern = replaceAll ? new RegExp(escapeRegExp(oldString), "g") : new RegExp(escapeRegExp(oldString));
|
|
402
|
-
if (!searchPattern.test(content)) {
|
|
403
|
-
return {
|
|
404
|
-
success: false,
|
|
405
|
-
output: "",
|
|
406
|
-
error: `Could not find "${oldString}" in file ${filePath}`,
|
|
407
|
-
metadata: {
|
|
408
|
-
execution_time_ms: Date.now() - startTime
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
const newContent = replaceAll ? content.replace(new RegExp(escapeRegExp(oldString), "g"), newString) : content.replace(oldString, newString);
|
|
413
|
-
await writeFile2(filePath, newContent, "utf-8");
|
|
414
|
-
return {
|
|
415
|
-
success: true,
|
|
416
|
-
output: replaceAll ? `Replaced all occurrences in: ${filePath}` : `Replaced text in: ${filePath}`,
|
|
417
|
-
metadata: {
|
|
418
|
-
execution_time_ms: Date.now() - startTime,
|
|
419
|
-
file_path: filePath
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
} catch (error) {
|
|
423
|
-
return {
|
|
424
|
-
success: false,
|
|
425
|
-
output: "",
|
|
426
|
-
error: error instanceof Error ? error.message : String(error),
|
|
427
|
-
metadata: {
|
|
428
|
-
execution_time_ms: Date.now() - startTime
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
function escapeRegExp(string) {
|
|
435
|
-
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// src/env/tool/built-in/grep.ts
|
|
439
|
-
import { z as z6 } from "zod";
|
|
440
|
-
import { readFile as readFile3 } from "fs/promises";
|
|
441
|
-
import { glob as globAsync2 } from "glob";
|
|
442
|
-
var grepTool = {
|
|
443
|
-
name: "grep",
|
|
444
|
-
description: "Search for text patterns in files. Use this to find specific strings, code patterns, or content across multiple files.",
|
|
445
|
-
parameters: z6.object({
|
|
446
|
-
pattern: z6.string().describe("The pattern to search for"),
|
|
447
|
-
path: z6.string().optional().describe("File or directory path to search in"),
|
|
448
|
-
include: z6.string().optional().describe("Glob pattern for files to include (e.g., *.ts, *.js)"),
|
|
449
|
-
caseSensitive: z6.boolean().default(true).optional().describe("Whether the search should be case sensitive"),
|
|
450
|
-
maxResults: z6.number().int().positive().default(50).optional().describe("Maximum number of results"),
|
|
451
|
-
showLineNumbers: z6.boolean().default(true).optional().describe("Show line numbers in results")
|
|
452
|
-
}),
|
|
453
|
-
sandbox: {
|
|
454
|
-
enabled: true
|
|
455
|
-
},
|
|
456
|
-
metadata: {
|
|
457
|
-
category: "file",
|
|
458
|
-
tags: ["search", "grep", "find", "pattern"],
|
|
459
|
-
version: "1.0.0"
|
|
460
|
-
},
|
|
461
|
-
execute: async (args, ctx) => {
|
|
462
|
-
const startTime = Date.now();
|
|
463
|
-
const {
|
|
464
|
-
pattern,
|
|
465
|
-
path: searchPath,
|
|
466
|
-
include,
|
|
467
|
-
caseSensitive = true,
|
|
468
|
-
maxResults = 50,
|
|
469
|
-
showLineNumbers = true
|
|
470
|
-
} = args;
|
|
471
|
-
const basePath = searchPath || ctx.workdir || process.cwd();
|
|
472
|
-
try {
|
|
473
|
-
let files = [];
|
|
474
|
-
if (include) {
|
|
475
|
-
files = await globAsync2(include, {
|
|
476
|
-
cwd: basePath,
|
|
477
|
-
ignore: ["**/node_modules/**", "**/.git/**"],
|
|
478
|
-
maxDepth: 10
|
|
479
|
-
});
|
|
480
|
-
} else {
|
|
481
|
-
files = await globAsync2("**/*", {
|
|
482
|
-
cwd: basePath,
|
|
483
|
-
ignore: ["**/node_modules/**", "**/.git/**"],
|
|
484
|
-
maxDepth: 10
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
const results = [];
|
|
488
|
-
const regexFlags = caseSensitive ? "" : "i";
|
|
489
|
-
const regex = new RegExp(pattern, regexFlags);
|
|
490
|
-
for (const file of files) {
|
|
491
|
-
if (results.length >= maxResults)
|
|
492
|
-
break;
|
|
493
|
-
try {
|
|
494
|
-
const content = await readFile3(`${basePath}/${file}`, "utf-8");
|
|
495
|
-
const lines = content.split(`
|
|
496
|
-
`);
|
|
497
|
-
for (let i = 0;i < lines.length; i++) {
|
|
498
|
-
if (regex.test(lines[i])) {
|
|
499
|
-
const lineNum = showLineNumbers ? `${i + 1}:` : "";
|
|
500
|
-
results.push(`${file}:${lineNum}${lines[i]}`);
|
|
501
|
-
if (results.length >= maxResults)
|
|
502
|
-
break;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
} catch {}
|
|
506
|
-
}
|
|
507
|
-
const output = results.join(`
|
|
508
|
-
`) || "(no matches found)";
|
|
509
|
-
return {
|
|
510
|
-
success: true,
|
|
511
|
-
output,
|
|
512
|
-
metadata: {
|
|
513
|
-
execution_time_ms: Date.now() - startTime,
|
|
514
|
-
output_size: output.length,
|
|
515
|
-
matches_count: results.length,
|
|
516
|
-
files_searched: files.length
|
|
517
|
-
}
|
|
518
|
-
};
|
|
519
|
-
} catch (error) {
|
|
520
|
-
return {
|
|
521
|
-
success: false,
|
|
522
|
-
output: "",
|
|
523
|
-
error: error instanceof Error ? error.message : String(error),
|
|
524
|
-
metadata: {
|
|
525
|
-
execution_time_ms: Date.now() - startTime
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
// src/env/tool/built-in/index.ts
|
|
533
|
-
function getAllBuiltInTools() {
|
|
534
|
-
return [
|
|
535
|
-
bashTool,
|
|
536
|
-
echoTool,
|
|
537
|
-
globTool,
|
|
538
|
-
readFileTool,
|
|
539
|
-
writeFileTool,
|
|
540
|
-
editFileTool,
|
|
541
|
-
grepTool
|
|
542
|
-
];
|
|
543
|
-
}
|
|
544
|
-
function getBuiltInTool(name) {
|
|
545
|
-
const tools = getAllBuiltInTools();
|
|
546
|
-
return tools.find((t) => t.name === name);
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
export { bashTool, echoTool, globTool, readFileTool, writeFileTool, editFileTool, grepTool, getAllBuiltInTools, getBuiltInTool };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
OTelTracerProvider,
|
|
3
|
-
getTracerProvider,
|
|
4
|
-
init_tracer_provider,
|
|
5
|
-
resetTracerProvider
|
|
6
|
-
} from "./roy-agent-core-xs5rsgat.js";
|
|
7
|
-
import"./roy-agent-core-psv4v63c.js";
|
|
8
|
-
import"./roy-agent-core-fs0mn2jk.js";
|
|
9
|
-
init_tracer_provider();
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
resetTracerProvider,
|
|
13
|
-
getTracerProvider,
|
|
14
|
-
OTelTracerProvider
|
|
15
|
-
};
|