agency-lang 0.0.93 → 0.0.95
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/dist/lib/agents/agency-agent/subagents/code.js +628 -0
- package/dist/lib/agents/agency-agent/subagents/plan.js +445 -0
- package/dist/lib/agents/agency-agent/subagents/task.js +557 -0
- package/dist/lib/backends/typescriptBuilder.js +1 -1
- package/dist/lib/ir/prettyPrint.js +2 -1
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.js +1 -1
- package/package.json +2 -2
- package/stdlib/_utils.js +51 -0
- package/stdlib/agent.js +7 -3
- package/stdlib/array.js +364 -413
- package/stdlib/fs.js +7 -3
- package/stdlib/index.js +228 -225
- package/stdlib/lib/process.js +29 -0
- package/stdlib/lib/test.js +3 -0
- package/stdlib/math.js +7 -3
- package/stdlib/object.js +1160 -950
- package/stdlib/path.js +7 -3
- package/stdlib/shell.js +7 -3
- package/stdlib/strategy.js +7 -3
- package/stdlib/system.js +7 -3
- package/stdlib/ui.js +25 -19
- package/stdlib/weather.js +3 -3
- package/stdlib/consensus.js +0 -480
- package/stdlib/firstValid.js +0 -507
- package/stdlib/http.js +0 -739
- package/stdlib/retry.js +0 -647
- package/stdlib/sample.js +0 -471
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
import { print, __printTool, __printToolParams, printJSON, __printJSONTool, __printJSONToolParams, input, __inputTool, __inputToolParams, sleep, __sleepTool, __sleepToolParams, round, __roundTool, __roundToolParams, fetch, __fetchTool, __fetchToolParams, fetchJSON, __fetchJSONTool, __fetchJSONToolParams, read, __readTool, __readToolParams, write, __writeTool, __writeToolParams, readImage, __readImageTool, __readImageToolParams, notify, __notifyTool, __notifyToolParams } from "/Users/adityabhargava/agency-lang/stdlib/index.js";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import process from "process";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { color, nanoid } from "agency-lang";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import {
|
|
8
|
+
RuntimeContext,
|
|
9
|
+
ThreadStore,
|
|
10
|
+
setupFunction,
|
|
11
|
+
callHook,
|
|
12
|
+
interrupt,
|
|
13
|
+
isInterrupt,
|
|
14
|
+
isDebugger,
|
|
15
|
+
debugStep,
|
|
16
|
+
respondToInterrupt as _respondToInterrupt,
|
|
17
|
+
approveInterrupt as _approveInterrupt,
|
|
18
|
+
rejectInterrupt as _rejectInterrupt,
|
|
19
|
+
resolveInterrupt as _resolveInterrupt,
|
|
20
|
+
modifyInterrupt as _modifyInterrupt,
|
|
21
|
+
rewindFrom as _rewindFrom,
|
|
22
|
+
ToolCallError,
|
|
23
|
+
RestoreSignal,
|
|
24
|
+
readSkill as _readSkillRaw,
|
|
25
|
+
readSkillTool as __readSkillTool,
|
|
26
|
+
readSkillToolParams as __readSkillToolParams,
|
|
27
|
+
_builtinTool as __builtinTool
|
|
28
|
+
} from "agency-lang/runtime";
|
|
29
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
30
|
+
const __dirname = path.dirname(__filename);
|
|
31
|
+
const __cwd = process.cwd();
|
|
32
|
+
const getDirname = () => __dirname;
|
|
33
|
+
const __globalCtx = new RuntimeContext({
|
|
34
|
+
statelogConfig: {
|
|
35
|
+
host: "https://agency-lang.com",
|
|
36
|
+
apiKey: process.env["STATELOG_API_KEY"] || "",
|
|
37
|
+
projectId: "agency-lang",
|
|
38
|
+
debugMode: false
|
|
39
|
+
},
|
|
40
|
+
smoltalkDefaults: {
|
|
41
|
+
openAiApiKey: process.env["OPENAI_API_KEY"] || "",
|
|
42
|
+
googleApiKey: process.env["GEMINI_API_KEY"] || "",
|
|
43
|
+
model: "gpt-4o-mini",
|
|
44
|
+
logLevel: "warn",
|
|
45
|
+
statelog: {
|
|
46
|
+
host: "https://agency-lang.com",
|
|
47
|
+
projectId: "smoltalk",
|
|
48
|
+
apiKey: process.env["STATELOG_SMOLTALK_API_KEY"] || "",
|
|
49
|
+
traceId: nanoid()
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
dirname: __dirname
|
|
53
|
+
});
|
|
54
|
+
const graph = __globalCtx.graph;
|
|
55
|
+
function readSkill({ filepath }) {
|
|
56
|
+
return _readSkillRaw({ filepath, dirname: __dirname });
|
|
57
|
+
}
|
|
58
|
+
function tool(__name) {
|
|
59
|
+
return __builtinTool(__name, __toolRegistry);
|
|
60
|
+
}
|
|
61
|
+
function approve(value) {
|
|
62
|
+
return { type: "approved", value };
|
|
63
|
+
}
|
|
64
|
+
function reject(value) {
|
|
65
|
+
return { type: "rejected", value };
|
|
66
|
+
}
|
|
67
|
+
const respondToInterrupt = (interrupt2, response, opts) => _respondToInterrupt({ ctx: __globalCtx, interrupt: interrupt2, interruptResponse: response, overrides: opts?.overrides, metadata: opts?.metadata });
|
|
68
|
+
const approveInterrupt = (interrupt2, opts) => _approveInterrupt({ ctx: __globalCtx, interrupt: interrupt2, overrides: opts?.overrides, metadata: opts?.metadata });
|
|
69
|
+
const rejectInterrupt = (interrupt2, opts) => _rejectInterrupt({ ctx: __globalCtx, interrupt: interrupt2, overrides: opts?.overrides, metadata: opts?.metadata });
|
|
70
|
+
const modifyInterrupt = (interrupt2, newArguments, opts) => _modifyInterrupt({ ctx: __globalCtx, interrupt: interrupt2, newArguments, overrides: opts?.overrides, metadata: opts?.metadata });
|
|
71
|
+
const resolveInterrupt = (interrupt2, value, opts) => _resolveInterrupt({ ctx: __globalCtx, interrupt: interrupt2, value, overrides: opts?.overrides, metadata: opts?.metadata });
|
|
72
|
+
const rewindFrom = (checkpoint2, overrides, opts) => _rewindFrom({ ctx: __globalCtx, checkpoint: checkpoint2, overrides, metadata: opts?.metadata });
|
|
73
|
+
const __setDebugger = (dbg) => {
|
|
74
|
+
__globalCtx.debugger = dbg;
|
|
75
|
+
};
|
|
76
|
+
const __getCheckpoints = () => __globalCtx.checkpoints;
|
|
77
|
+
function __initializeGlobals(__ctx) {
|
|
78
|
+
__ctx.globals.set("lib/agents/agency-agent/subagents/code.agency", "code", {
|
|
79
|
+
"contents": ``
|
|
80
|
+
});
|
|
81
|
+
__ctx.globals.markInitialized("lib/agents/agency-agent/subagents/code.agency");
|
|
82
|
+
}
|
|
83
|
+
const __writeCodeTool = {
|
|
84
|
+
name: "writeCode",
|
|
85
|
+
description: `Use this tool to write code to a file. The tool takes in a string of code content and replaces the existing code with it.
|
|
86
|
+
The tool returns the current state of the code after your modification.`,
|
|
87
|
+
schema: z.object({ "content": z.string() })
|
|
88
|
+
};
|
|
89
|
+
const __writeCodeToolParams = ["content"];
|
|
90
|
+
const __appendCodeTool = {
|
|
91
|
+
name: "appendCode",
|
|
92
|
+
description: `Use this tool to incrementally write code to a file. The tool takes in a string of code content and appends it to the existing code.
|
|
93
|
+
The tool returns the current state of the code after your modification.`,
|
|
94
|
+
schema: z.object({ "content": z.string() })
|
|
95
|
+
};
|
|
96
|
+
const __appendCodeToolParams = ["content"];
|
|
97
|
+
const __readCodeTool = {
|
|
98
|
+
name: "readCode",
|
|
99
|
+
description: `Use this tool to read the current code. This is useful to see what code has been written so far as you build it out over multiple steps.`,
|
|
100
|
+
schema: z.object({})
|
|
101
|
+
};
|
|
102
|
+
const __readCodeToolParams = [];
|
|
103
|
+
const __toolRegistry = {
|
|
104
|
+
writeCode: {
|
|
105
|
+
definition: __writeCodeTool,
|
|
106
|
+
handler: {
|
|
107
|
+
name: "writeCode",
|
|
108
|
+
params: __writeCodeToolParams,
|
|
109
|
+
execute: writeCode,
|
|
110
|
+
isBuiltin: false
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
appendCode: {
|
|
114
|
+
definition: __appendCodeTool,
|
|
115
|
+
handler: {
|
|
116
|
+
name: "appendCode",
|
|
117
|
+
params: __appendCodeToolParams,
|
|
118
|
+
execute: appendCode,
|
|
119
|
+
isBuiltin: false
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
readCode: {
|
|
123
|
+
definition: __readCodeTool,
|
|
124
|
+
handler: {
|
|
125
|
+
name: "readCode",
|
|
126
|
+
params: __readCodeToolParams,
|
|
127
|
+
execute: readCode,
|
|
128
|
+
isBuiltin: false
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
print: {
|
|
132
|
+
definition: __printTool,
|
|
133
|
+
handler: {
|
|
134
|
+
name: "print",
|
|
135
|
+
params: __printToolParams,
|
|
136
|
+
execute: print,
|
|
137
|
+
isBuiltin: false
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
printJSON: {
|
|
141
|
+
definition: __printJSONTool,
|
|
142
|
+
handler: {
|
|
143
|
+
name: "printJSON",
|
|
144
|
+
params: __printJSONToolParams,
|
|
145
|
+
execute: printJSON,
|
|
146
|
+
isBuiltin: false
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
input: {
|
|
150
|
+
definition: __inputTool,
|
|
151
|
+
handler: {
|
|
152
|
+
name: "input",
|
|
153
|
+
params: __inputToolParams,
|
|
154
|
+
execute: input,
|
|
155
|
+
isBuiltin: false
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
sleep: {
|
|
159
|
+
definition: __sleepTool,
|
|
160
|
+
handler: {
|
|
161
|
+
name: "sleep",
|
|
162
|
+
params: __sleepToolParams,
|
|
163
|
+
execute: sleep,
|
|
164
|
+
isBuiltin: false
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
round: {
|
|
168
|
+
definition: __roundTool,
|
|
169
|
+
handler: {
|
|
170
|
+
name: "round",
|
|
171
|
+
params: __roundToolParams,
|
|
172
|
+
execute: round,
|
|
173
|
+
isBuiltin: false
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
fetch: {
|
|
177
|
+
definition: __fetchTool,
|
|
178
|
+
handler: {
|
|
179
|
+
name: "fetch",
|
|
180
|
+
params: __fetchToolParams,
|
|
181
|
+
execute: fetch,
|
|
182
|
+
isBuiltin: false
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
fetchJSON: {
|
|
186
|
+
definition: __fetchJSONTool,
|
|
187
|
+
handler: {
|
|
188
|
+
name: "fetchJSON",
|
|
189
|
+
params: __fetchJSONToolParams,
|
|
190
|
+
execute: fetchJSON,
|
|
191
|
+
isBuiltin: false
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
read: {
|
|
195
|
+
definition: __readTool,
|
|
196
|
+
handler: {
|
|
197
|
+
name: "read",
|
|
198
|
+
params: __readToolParams,
|
|
199
|
+
execute: read,
|
|
200
|
+
isBuiltin: false
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
write: {
|
|
204
|
+
definition: __writeTool,
|
|
205
|
+
handler: {
|
|
206
|
+
name: "write",
|
|
207
|
+
params: __writeToolParams,
|
|
208
|
+
execute: write,
|
|
209
|
+
isBuiltin: false
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
readImage: {
|
|
213
|
+
definition: __readImageTool,
|
|
214
|
+
handler: {
|
|
215
|
+
name: "readImage",
|
|
216
|
+
params: __readImageToolParams,
|
|
217
|
+
execute: readImage,
|
|
218
|
+
isBuiltin: false
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
notify: {
|
|
222
|
+
definition: __notifyTool,
|
|
223
|
+
handler: {
|
|
224
|
+
name: "notify",
|
|
225
|
+
params: __notifyToolParams,
|
|
226
|
+
execute: notify,
|
|
227
|
+
isBuiltin: false
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
readSkill: {
|
|
231
|
+
definition: __readSkillTool,
|
|
232
|
+
handler: {
|
|
233
|
+
name: "readSkill",
|
|
234
|
+
params: __readSkillToolParams,
|
|
235
|
+
execute: readSkill,
|
|
236
|
+
isBuiltin: true
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
async function writeCode(content, __state = void 0) {
|
|
241
|
+
const __setupData = setupFunction({
|
|
242
|
+
state: __state
|
|
243
|
+
});
|
|
244
|
+
const __stack = __setupData.stack;
|
|
245
|
+
const __step = __setupData.step;
|
|
246
|
+
const __self = __setupData.self;
|
|
247
|
+
const __threads = __setupData.threads;
|
|
248
|
+
const __ctx = __state?.ctx || __globalCtx;
|
|
249
|
+
const statelogClient = __ctx.statelogClient;
|
|
250
|
+
const __graph = __ctx.graph;
|
|
251
|
+
let __forked;
|
|
252
|
+
if (!__ctx.globals.isInitialized("lib/agents/agency-agent/subagents/code.agency")) {
|
|
253
|
+
__initializeGlobals(__ctx);
|
|
254
|
+
}
|
|
255
|
+
let __funcStartTime = performance.now();
|
|
256
|
+
await callHook({
|
|
257
|
+
callbacks: __ctx.callbacks,
|
|
258
|
+
name: "onFunctionStart",
|
|
259
|
+
data: {
|
|
260
|
+
functionName: "writeCode",
|
|
261
|
+
args: {
|
|
262
|
+
content
|
|
263
|
+
},
|
|
264
|
+
isBuiltin: false
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
await __ctx.audit({
|
|
268
|
+
type: "functionCall",
|
|
269
|
+
functionName: "writeCode",
|
|
270
|
+
args: {
|
|
271
|
+
content
|
|
272
|
+
},
|
|
273
|
+
result: void 0
|
|
274
|
+
});
|
|
275
|
+
__stack.args["content"] = content;
|
|
276
|
+
__self.__retryable = __self.__retryable ?? true;
|
|
277
|
+
try {
|
|
278
|
+
if (__step <= 0) {
|
|
279
|
+
__stack.step++;
|
|
280
|
+
}
|
|
281
|
+
if (__step <= 1) {
|
|
282
|
+
const __dbg = await debugStep(__ctx, __state, {
|
|
283
|
+
moduleId: "lib/agents/agency-agent/subagents/code.agency",
|
|
284
|
+
scopeName: "writeCode",
|
|
285
|
+
stepPath: "1",
|
|
286
|
+
label: null,
|
|
287
|
+
nodeContext: false
|
|
288
|
+
});
|
|
289
|
+
if (__dbg) {
|
|
290
|
+
return __dbg;
|
|
291
|
+
}
|
|
292
|
+
__stack.step++;
|
|
293
|
+
}
|
|
294
|
+
if (__step <= 2) {
|
|
295
|
+
const __funcResult = await print(color.green(`Overwriting code with new content`), {
|
|
296
|
+
ctx: __ctx,
|
|
297
|
+
threads: new ThreadStore(),
|
|
298
|
+
interruptData: __state?.interruptData
|
|
299
|
+
});
|
|
300
|
+
if (isInterrupt(__funcResult)) {
|
|
301
|
+
await __ctx.pendingPromises.awaitAll();
|
|
302
|
+
return {
|
|
303
|
+
data: __funcResult
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
await __ctx.audit({
|
|
307
|
+
type: "assignment",
|
|
308
|
+
variable: "__funcResult",
|
|
309
|
+
value: __funcResult
|
|
310
|
+
});
|
|
311
|
+
__stack.step++;
|
|
312
|
+
}
|
|
313
|
+
if (__step <= 3) {
|
|
314
|
+
const __dbg = await debugStep(__ctx, __state, {
|
|
315
|
+
moduleId: "lib/agents/agency-agent/subagents/code.agency",
|
|
316
|
+
scopeName: "writeCode",
|
|
317
|
+
stepPath: "3",
|
|
318
|
+
label: null,
|
|
319
|
+
nodeContext: false
|
|
320
|
+
});
|
|
321
|
+
if (__dbg) {
|
|
322
|
+
return __dbg;
|
|
323
|
+
}
|
|
324
|
+
__stack.step++;
|
|
325
|
+
}
|
|
326
|
+
if (__step <= 4) {
|
|
327
|
+
const __funcResult = await print(__stack.args.content, {
|
|
328
|
+
ctx: __ctx,
|
|
329
|
+
threads: new ThreadStore(),
|
|
330
|
+
interruptData: __state?.interruptData
|
|
331
|
+
});
|
|
332
|
+
if (isInterrupt(__funcResult)) {
|
|
333
|
+
await __ctx.pendingPromises.awaitAll();
|
|
334
|
+
return {
|
|
335
|
+
data: __funcResult
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
await __ctx.audit({
|
|
339
|
+
type: "assignment",
|
|
340
|
+
variable: "__funcResult",
|
|
341
|
+
value: __funcResult
|
|
342
|
+
});
|
|
343
|
+
__stack.step++;
|
|
344
|
+
}
|
|
345
|
+
if (__step <= 5) {
|
|
346
|
+
const __dbg = await debugStep(__ctx, __state, {
|
|
347
|
+
moduleId: "lib/agents/agency-agent/subagents/code.agency",
|
|
348
|
+
scopeName: "writeCode",
|
|
349
|
+
stepPath: "5",
|
|
350
|
+
label: null,
|
|
351
|
+
nodeContext: false
|
|
352
|
+
});
|
|
353
|
+
if (__dbg) {
|
|
354
|
+
return __dbg;
|
|
355
|
+
}
|
|
356
|
+
__stack.step++;
|
|
357
|
+
}
|
|
358
|
+
if (__step <= 6) {
|
|
359
|
+
__ctx.globals.get("lib/agents/agency-agent/subagents/code.agency", "code").contents = __stack.args.content;
|
|
360
|
+
await __ctx.audit({
|
|
361
|
+
type: "assignment",
|
|
362
|
+
variable: '__ctx.globals.get("lib/agents/agency-agent/subagents/code.agency", "code").contents',
|
|
363
|
+
value: __ctx.globals.get("lib/agents/agency-agent/subagents/code.agency", "code").contents
|
|
364
|
+
});
|
|
365
|
+
__stack.step++;
|
|
366
|
+
}
|
|
367
|
+
if (__step <= 7) {
|
|
368
|
+
const __dbg = await debugStep(__ctx, __state, {
|
|
369
|
+
moduleId: "lib/agents/agency-agent/subagents/code.agency",
|
|
370
|
+
scopeName: "writeCode",
|
|
371
|
+
stepPath: "7",
|
|
372
|
+
label: null,
|
|
373
|
+
nodeContext: false
|
|
374
|
+
});
|
|
375
|
+
if (__dbg) {
|
|
376
|
+
return __dbg;
|
|
377
|
+
}
|
|
378
|
+
__stack.step++;
|
|
379
|
+
}
|
|
380
|
+
if (__step <= 8) {
|
|
381
|
+
const __auditReturnValue = __ctx.globals.get("lib/agents/agency-agent/subagents/code.agency", "code").contents;
|
|
382
|
+
await __ctx.audit({
|
|
383
|
+
type: "return",
|
|
384
|
+
value: __auditReturnValue
|
|
385
|
+
});
|
|
386
|
+
return __auditReturnValue;
|
|
387
|
+
__stack.step++;
|
|
388
|
+
}
|
|
389
|
+
} catch (__error) {
|
|
390
|
+
if (__error instanceof RestoreSignal) {
|
|
391
|
+
throw __error;
|
|
392
|
+
}
|
|
393
|
+
if (__error instanceof ToolCallError) {
|
|
394
|
+
__error.retryable = __error.retryable && __self.__retryable;
|
|
395
|
+
throw __error;
|
|
396
|
+
}
|
|
397
|
+
throw new ToolCallError(__error, { retryable: __self.__retryable });
|
|
398
|
+
} finally {
|
|
399
|
+
if (!__state?.isForked) {
|
|
400
|
+
__ctx.stateStack.pop();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
await callHook({
|
|
404
|
+
callbacks: __ctx.callbacks,
|
|
405
|
+
name: "onFunctionEnd",
|
|
406
|
+
data: {
|
|
407
|
+
functionName: "writeCode",
|
|
408
|
+
timeTaken: performance.now() - __funcStartTime
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
async function appendCode(content, __state = void 0) {
|
|
413
|
+
const __setupData = setupFunction({
|
|
414
|
+
state: __state
|
|
415
|
+
});
|
|
416
|
+
const __stack = __setupData.stack;
|
|
417
|
+
const __step = __setupData.step;
|
|
418
|
+
const __self = __setupData.self;
|
|
419
|
+
const __threads = __setupData.threads;
|
|
420
|
+
const __ctx = __state?.ctx || __globalCtx;
|
|
421
|
+
const statelogClient = __ctx.statelogClient;
|
|
422
|
+
const __graph = __ctx.graph;
|
|
423
|
+
let __forked;
|
|
424
|
+
if (!__ctx.globals.isInitialized("lib/agents/agency-agent/subagents/code.agency")) {
|
|
425
|
+
__initializeGlobals(__ctx);
|
|
426
|
+
}
|
|
427
|
+
let __funcStartTime = performance.now();
|
|
428
|
+
await callHook({
|
|
429
|
+
callbacks: __ctx.callbacks,
|
|
430
|
+
name: "onFunctionStart",
|
|
431
|
+
data: {
|
|
432
|
+
functionName: "appendCode",
|
|
433
|
+
args: {
|
|
434
|
+
content
|
|
435
|
+
},
|
|
436
|
+
isBuiltin: false
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
await __ctx.audit({
|
|
440
|
+
type: "functionCall",
|
|
441
|
+
functionName: "appendCode",
|
|
442
|
+
args: {
|
|
443
|
+
content
|
|
444
|
+
},
|
|
445
|
+
result: void 0
|
|
446
|
+
});
|
|
447
|
+
__stack.args["content"] = content;
|
|
448
|
+
__self.__retryable = __self.__retryable ?? true;
|
|
449
|
+
try {
|
|
450
|
+
if (__step <= 0) {
|
|
451
|
+
__stack.step++;
|
|
452
|
+
}
|
|
453
|
+
if (__step <= 1) {
|
|
454
|
+
const __dbg = await debugStep(__ctx, __state, {
|
|
455
|
+
moduleId: "lib/agents/agency-agent/subagents/code.agency",
|
|
456
|
+
scopeName: "appendCode",
|
|
457
|
+
stepPath: "1",
|
|
458
|
+
label: null,
|
|
459
|
+
nodeContext: false
|
|
460
|
+
});
|
|
461
|
+
if (__dbg) {
|
|
462
|
+
return __dbg;
|
|
463
|
+
}
|
|
464
|
+
__stack.step++;
|
|
465
|
+
}
|
|
466
|
+
if (__step <= 2) {
|
|
467
|
+
__ctx.globals.get("lib/agents/agency-agent/subagents/code.agency", "code").contents = __ctx.globals.get("lib/agents/agency-agent/subagents/code.agency", "code").contents + `
|
|
468
|
+
${__stack.args.content}`;
|
|
469
|
+
await __ctx.audit({
|
|
470
|
+
type: "assignment",
|
|
471
|
+
variable: '__ctx.globals.get("lib/agents/agency-agent/subagents/code.agency", "code").contents',
|
|
472
|
+
value: __ctx.globals.get("lib/agents/agency-agent/subagents/code.agency", "code").contents
|
|
473
|
+
});
|
|
474
|
+
__stack.step++;
|
|
475
|
+
}
|
|
476
|
+
if (__step <= 3) {
|
|
477
|
+
const __dbg = await debugStep(__ctx, __state, {
|
|
478
|
+
moduleId: "lib/agents/agency-agent/subagents/code.agency",
|
|
479
|
+
scopeName: "appendCode",
|
|
480
|
+
stepPath: "3",
|
|
481
|
+
label: null,
|
|
482
|
+
nodeContext: false
|
|
483
|
+
});
|
|
484
|
+
if (__dbg) {
|
|
485
|
+
return __dbg;
|
|
486
|
+
}
|
|
487
|
+
__stack.step++;
|
|
488
|
+
}
|
|
489
|
+
if (__step <= 4) {
|
|
490
|
+
const __auditReturnValue = __ctx.globals.get("lib/agents/agency-agent/subagents/code.agency", "code").contents;
|
|
491
|
+
await __ctx.audit({
|
|
492
|
+
type: "return",
|
|
493
|
+
value: __auditReturnValue
|
|
494
|
+
});
|
|
495
|
+
return __auditReturnValue;
|
|
496
|
+
__stack.step++;
|
|
497
|
+
}
|
|
498
|
+
} catch (__error) {
|
|
499
|
+
if (__error instanceof RestoreSignal) {
|
|
500
|
+
throw __error;
|
|
501
|
+
}
|
|
502
|
+
if (__error instanceof ToolCallError) {
|
|
503
|
+
__error.retryable = __error.retryable && __self.__retryable;
|
|
504
|
+
throw __error;
|
|
505
|
+
}
|
|
506
|
+
throw new ToolCallError(__error, { retryable: __self.__retryable });
|
|
507
|
+
} finally {
|
|
508
|
+
if (!__state?.isForked) {
|
|
509
|
+
__ctx.stateStack.pop();
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
await callHook({
|
|
513
|
+
callbacks: __ctx.callbacks,
|
|
514
|
+
name: "onFunctionEnd",
|
|
515
|
+
data: {
|
|
516
|
+
functionName: "appendCode",
|
|
517
|
+
timeTaken: performance.now() - __funcStartTime
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
async function readCode(__state = void 0) {
|
|
522
|
+
const __setupData = setupFunction({
|
|
523
|
+
state: __state
|
|
524
|
+
});
|
|
525
|
+
const __stack = __setupData.stack;
|
|
526
|
+
const __step = __setupData.step;
|
|
527
|
+
const __self = __setupData.self;
|
|
528
|
+
const __threads = __setupData.threads;
|
|
529
|
+
const __ctx = __state?.ctx || __globalCtx;
|
|
530
|
+
const statelogClient = __ctx.statelogClient;
|
|
531
|
+
const __graph = __ctx.graph;
|
|
532
|
+
let __forked;
|
|
533
|
+
if (!__ctx.globals.isInitialized("lib/agents/agency-agent/subagents/code.agency")) {
|
|
534
|
+
__initializeGlobals(__ctx);
|
|
535
|
+
}
|
|
536
|
+
let __funcStartTime = performance.now();
|
|
537
|
+
await callHook({
|
|
538
|
+
callbacks: __ctx.callbacks,
|
|
539
|
+
name: "onFunctionStart",
|
|
540
|
+
data: {
|
|
541
|
+
functionName: "readCode",
|
|
542
|
+
args: {},
|
|
543
|
+
isBuiltin: false
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
await __ctx.audit({
|
|
547
|
+
type: "functionCall",
|
|
548
|
+
functionName: "readCode",
|
|
549
|
+
args: {},
|
|
550
|
+
result: void 0
|
|
551
|
+
});
|
|
552
|
+
__self.__retryable = __self.__retryable ?? true;
|
|
553
|
+
try {
|
|
554
|
+
if (__step <= 0) {
|
|
555
|
+
__stack.step++;
|
|
556
|
+
}
|
|
557
|
+
if (__step <= 1) {
|
|
558
|
+
const __dbg = await debugStep(__ctx, __state, {
|
|
559
|
+
moduleId: "lib/agents/agency-agent/subagents/code.agency",
|
|
560
|
+
scopeName: "readCode",
|
|
561
|
+
stepPath: "1",
|
|
562
|
+
label: null,
|
|
563
|
+
nodeContext: false
|
|
564
|
+
});
|
|
565
|
+
if (__dbg) {
|
|
566
|
+
return __dbg;
|
|
567
|
+
}
|
|
568
|
+
__stack.step++;
|
|
569
|
+
}
|
|
570
|
+
if (__step <= 2) {
|
|
571
|
+
const __auditReturnValue = __ctx.globals.get("lib/agents/agency-agent/subagents/code.agency", "code").contents;
|
|
572
|
+
await __ctx.audit({
|
|
573
|
+
type: "return",
|
|
574
|
+
value: __auditReturnValue
|
|
575
|
+
});
|
|
576
|
+
return __auditReturnValue;
|
|
577
|
+
__stack.step++;
|
|
578
|
+
}
|
|
579
|
+
} catch (__error) {
|
|
580
|
+
if (__error instanceof RestoreSignal) {
|
|
581
|
+
throw __error;
|
|
582
|
+
}
|
|
583
|
+
if (__error instanceof ToolCallError) {
|
|
584
|
+
__error.retryable = __error.retryable && __self.__retryable;
|
|
585
|
+
throw __error;
|
|
586
|
+
}
|
|
587
|
+
throw new ToolCallError(__error, { retryable: __self.__retryable });
|
|
588
|
+
} finally {
|
|
589
|
+
if (!__state?.isForked) {
|
|
590
|
+
__ctx.stateStack.pop();
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
await callHook({
|
|
594
|
+
callbacks: __ctx.callbacks,
|
|
595
|
+
name: "onFunctionEnd",
|
|
596
|
+
data: {
|
|
597
|
+
functionName: "readCode",
|
|
598
|
+
timeTaken: performance.now() - __funcStartTime
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
var stdin_default = graph;
|
|
603
|
+
const __sourceMap = { "lib/agents/agency-agent/subagents/code.agency:writeCode": { "1": { "line": 14, "col": 2 }, "2": { "line": 14, "col": 2 }, "3": { "line": 15, "col": 2 }, "4": { "line": 15, "col": 2 }, "5": { "line": 16, "col": 2 }, "6": { "line": 16, "col": 2 }, "7": { "line": 17, "col": 2 }, "8": { "line": 17, "col": 2 } }, "lib/agents/agency-agent/subagents/code.agency:appendCode": { "1": { "line": 25, "col": 2 }, "2": { "line": 25, "col": 2 }, "3": { "line": 26, "col": 2 }, "4": { "line": 26, "col": 2 } }, "lib/agents/agency-agent/subagents/code.agency:readCode": { "1": { "line": 33, "col": 2 }, "2": { "line": 33, "col": 2 } } };
|
|
604
|
+
export {
|
|
605
|
+
__appendCodeTool,
|
|
606
|
+
__appendCodeToolParams,
|
|
607
|
+
__getCheckpoints,
|
|
608
|
+
__readCodeTool,
|
|
609
|
+
__readCodeToolParams,
|
|
610
|
+
__setDebugger,
|
|
611
|
+
__sourceMap,
|
|
612
|
+
__writeCodeTool,
|
|
613
|
+
__writeCodeToolParams,
|
|
614
|
+
appendCode,
|
|
615
|
+
approveInterrupt,
|
|
616
|
+
stdin_default as default,
|
|
617
|
+
interrupt,
|
|
618
|
+
isDebugger,
|
|
619
|
+
isInterrupt,
|
|
620
|
+
modifyInterrupt,
|
|
621
|
+
readCode,
|
|
622
|
+
readSkill,
|
|
623
|
+
rejectInterrupt,
|
|
624
|
+
resolveInterrupt,
|
|
625
|
+
respondToInterrupt,
|
|
626
|
+
rewindFrom,
|
|
627
|
+
writeCode
|
|
628
|
+
};
|