agency-lang 0.0.95 → 0.0.97
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/ir/prettyPrint.js +2 -2
- package/dist/lib/parsers/parsers.d.ts +1 -1
- package/dist/lib/parsers/parsers.js +1 -1
- package/dist/lib/templates/backends/agency/template.d.ts +1 -1
- package/dist/lib/templates/backends/agency/template.js +0 -1
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.js +1 -1
- package/package.json +1 -1
- package/stdlib/agent.js +42 -160
- package/stdlib/fs.js +94 -212
- package/stdlib/math.js +42 -160
- package/stdlib/path.js +94 -212
- package/stdlib/shell.js +94 -212
- package/stdlib/strategy.js +68 -186
- package/stdlib/system.js +55 -173
|
@@ -59,8 +59,8 @@ export function printTs(node, indent = 0) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
case "varDecl": {
|
|
62
|
-
|
|
63
|
-
let s = `var ${node.name}`;
|
|
62
|
+
let s = `${node.declKind} ${node.name}`;
|
|
63
|
+
// let s = `var ${node.name}`;
|
|
64
64
|
if (node.typeAnnotation)
|
|
65
65
|
s += `: ${node.typeAnnotation}`;
|
|
66
66
|
if (node.initializer)
|
|
@@ -28,7 +28,7 @@ export declare const comma: Parser<(string[] | ",")[]>;
|
|
|
28
28
|
export declare const plusSign: Parser<("+" | string[])[]>;
|
|
29
29
|
export declare const commaWithNewline: Parser<(string[] | ",")[]>;
|
|
30
30
|
export declare const varNameChar: Parser<string>;
|
|
31
|
-
export declare const AGENCY_TEMPLATE_OFFSET =
|
|
31
|
+
export declare const AGENCY_TEMPLATE_OFFSET = 2;
|
|
32
32
|
/**
|
|
33
33
|
* Wraps a parser to add a `loc` field from tarsec's withSpan.
|
|
34
34
|
* Converts Span { start: Position, end: Position } to SourceLocation { line, col, start, end }.
|
|
@@ -23,7 +23,7 @@ export const varNameChar = oneOf("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST
|
|
|
23
23
|
However, because every agency code gets rendered in a template that imports some standard functions,
|
|
24
24
|
the line numbers would be off if we didn't account for the template lines.
|
|
25
25
|
*/
|
|
26
|
-
export const AGENCY_TEMPLATE_OFFSET =
|
|
26
|
+
export const AGENCY_TEMPLATE_OFFSET = 2;
|
|
27
27
|
/**
|
|
28
28
|
* Wraps a parser to add a `loc` field from tarsec's withSpan.
|
|
29
29
|
* Converts Span { start: Position, end: Position } to SourceLocation { line, col, start, end }.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const template = "import { print, printJSON, input, sleep, round, fetch, fetchJSON, read, write, readImage, notify, range, mostCommon, keys, values, entries } from \"std::index\";\
|
|
1
|
+
export declare const template = "import { print, printJSON, input, sleep, round, fetch, fetchJSON, read, write, readImage, notify, range, mostCommon, keys, values, entries } from \"std::index\";\n\n{{{body:string}}}";
|
|
2
2
|
export type TemplateType = {
|
|
3
3
|
body: string;
|
|
4
4
|
};
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// Any manual changes will be lost.
|
|
4
4
|
import { apply } from "typestache";
|
|
5
5
|
export const template = `import { print, printJSON, input, sleep, round, fetch, fetchJSON, read, write, readImage, notify, range, mostCommon, keys, values, entries } from "std::index";
|
|
6
|
-
import { map, filter, exclude, find, findIndex, reduce, flatMap, every, some, count, sortBy, unique, groupBy } from "std::array";
|
|
7
6
|
|
|
8
7
|
{{{body:string}}}`;
|
|
9
8
|
const render = (args) => {
|
package/dist/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.0.
|
|
1
|
+
export declare const VERSION = "0.0.96";
|
package/dist/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.0.
|
|
1
|
+
export const VERSION = "0.0.96";
|
package/package.json
CHANGED
package/stdlib/agent.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
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, range, __rangeTool, __rangeToolParams, mostCommon, __mostCommonTool, __mostCommonToolParams, keys, __keysTool, __keysToolParams, values, __valuesTool, __valuesToolParams, entries, __entriesTool, __entriesToolParams } from "/Users/adityabhargava/worktrees/agency-lang/stdlib/index.js";
|
|
2
|
-
import { map, __mapTool, __mapToolParams, filter, __filterTool, __filterToolParams, exclude, __excludeTool, __excludeToolParams, find, __findTool, __findToolParams, findIndex, __findIndexTool, __findIndexToolParams, reduce, __reduceTool, __reduceToolParams, flatMap, __flatMapTool, __flatMapToolParams, every, __everyTool, __everyToolParams, some, __someTool, __someToolParams, count, __countTool, __countToolParams, sortBy, __sortByTool, __sortByToolParams, unique, __uniqueTool, __uniqueToolParams, groupBy, __groupByTool, __groupByToolParams } from "/Users/adityabhargava/worktrees/agency-lang/stdlib/array.js";
|
|
3
2
|
import { fileURLToPath } from "url";
|
|
4
3
|
import __process from "process";
|
|
5
4
|
import { z } from "zod";
|
|
@@ -34,7 +33,7 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
34
33
|
const __dirname = path.dirname(__filename);
|
|
35
34
|
const __cwd = __process.cwd();
|
|
36
35
|
const getDirname = () => __dirname;
|
|
37
|
-
|
|
36
|
+
var __globalCtx = new RuntimeContext({
|
|
38
37
|
statelogConfig: {
|
|
39
38
|
host: "https://statelog.adit.io",
|
|
40
39
|
apiKey: __process.env["STATELOG_API_KEY"] || "",
|
|
@@ -59,7 +58,7 @@ const __globalCtx = new RuntimeContext({
|
|
|
59
58
|
traceDir: "traces"
|
|
60
59
|
}
|
|
61
60
|
});
|
|
62
|
-
|
|
61
|
+
var graph = __globalCtx.graph;
|
|
63
62
|
function readSkill({ filepath }) {
|
|
64
63
|
return _readSkillRaw({ filepath, dirname: __dirname });
|
|
65
64
|
}
|
|
@@ -92,25 +91,25 @@ async function __initializeGlobals(__ctx) {
|
|
|
92
91
|
__ctx.globals.markInitialized("stdlib/agent.agency");
|
|
93
92
|
__ctx.globals.set("stdlib/agent.agency", "_todos", []);
|
|
94
93
|
}
|
|
95
|
-
|
|
94
|
+
var __todoWriteTool = {
|
|
96
95
|
name: "todoWrite",
|
|
97
96
|
description: `Replace the current todo list. Each todo has an id, text, and status (one of 'pending', 'in_progress', 'completed'). Use this to track multi-step work as you go: mark a todo 'in_progress' before starting it and 'completed' when done. Returns the new list.`,
|
|
98
97
|
schema: z.object({ "todos": z.array(z.object({ "id": z.string(), "text": z.string(), "status": z.union([z.literal("pending"), z.literal("in_progress"), z.literal("completed")]) })) })
|
|
99
98
|
};
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
var __todoWriteToolParams = ["todos"];
|
|
100
|
+
var __todoListTool = {
|
|
102
101
|
name: "todoList",
|
|
103
102
|
description: `Return the current todo list.`,
|
|
104
103
|
schema: z.object({})
|
|
105
104
|
};
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
var __todoListToolParams = [];
|
|
106
|
+
var __questionTool = {
|
|
108
107
|
name: "question",
|
|
109
108
|
description: `Ask the user a question and wait for their reply. Unlike input(), this raises an interrupt so the host (CLI, web UI, etc.) can present the prompt in its own way; the host resolves the interrupt with the answer string.`,
|
|
110
109
|
schema: z.object({ "prompt": z.string() })
|
|
111
110
|
};
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
var __questionToolParams = ["prompt"];
|
|
112
|
+
var __toolRegistry = {
|
|
114
113
|
todoWrite: {
|
|
115
114
|
definition: __todoWriteTool,
|
|
116
115
|
handler: {
|
|
@@ -282,123 +281,6 @@ const __toolRegistry = {
|
|
|
282
281
|
isBuiltin: false
|
|
283
282
|
}
|
|
284
283
|
},
|
|
285
|
-
map: {
|
|
286
|
-
definition: __mapTool,
|
|
287
|
-
handler: {
|
|
288
|
-
name: "map",
|
|
289
|
-
params: __mapToolParams,
|
|
290
|
-
execute: map,
|
|
291
|
-
isBuiltin: false
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
filter: {
|
|
295
|
-
definition: __filterTool,
|
|
296
|
-
handler: {
|
|
297
|
-
name: "filter",
|
|
298
|
-
params: __filterToolParams,
|
|
299
|
-
execute: filter,
|
|
300
|
-
isBuiltin: false
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
exclude: {
|
|
304
|
-
definition: __excludeTool,
|
|
305
|
-
handler: {
|
|
306
|
-
name: "exclude",
|
|
307
|
-
params: __excludeToolParams,
|
|
308
|
-
execute: exclude,
|
|
309
|
-
isBuiltin: false
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
find: {
|
|
313
|
-
definition: __findTool,
|
|
314
|
-
handler: {
|
|
315
|
-
name: "find",
|
|
316
|
-
params: __findToolParams,
|
|
317
|
-
execute: find,
|
|
318
|
-
isBuiltin: false
|
|
319
|
-
}
|
|
320
|
-
},
|
|
321
|
-
findIndex: {
|
|
322
|
-
definition: __findIndexTool,
|
|
323
|
-
handler: {
|
|
324
|
-
name: "findIndex",
|
|
325
|
-
params: __findIndexToolParams,
|
|
326
|
-
execute: findIndex,
|
|
327
|
-
isBuiltin: false
|
|
328
|
-
}
|
|
329
|
-
},
|
|
330
|
-
reduce: {
|
|
331
|
-
definition: __reduceTool,
|
|
332
|
-
handler: {
|
|
333
|
-
name: "reduce",
|
|
334
|
-
params: __reduceToolParams,
|
|
335
|
-
execute: reduce,
|
|
336
|
-
isBuiltin: false
|
|
337
|
-
}
|
|
338
|
-
},
|
|
339
|
-
flatMap: {
|
|
340
|
-
definition: __flatMapTool,
|
|
341
|
-
handler: {
|
|
342
|
-
name: "flatMap",
|
|
343
|
-
params: __flatMapToolParams,
|
|
344
|
-
execute: flatMap,
|
|
345
|
-
isBuiltin: false
|
|
346
|
-
}
|
|
347
|
-
},
|
|
348
|
-
every: {
|
|
349
|
-
definition: __everyTool,
|
|
350
|
-
handler: {
|
|
351
|
-
name: "every",
|
|
352
|
-
params: __everyToolParams,
|
|
353
|
-
execute: every,
|
|
354
|
-
isBuiltin: false
|
|
355
|
-
}
|
|
356
|
-
},
|
|
357
|
-
some: {
|
|
358
|
-
definition: __someTool,
|
|
359
|
-
handler: {
|
|
360
|
-
name: "some",
|
|
361
|
-
params: __someToolParams,
|
|
362
|
-
execute: some,
|
|
363
|
-
isBuiltin: false
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
count: {
|
|
367
|
-
definition: __countTool,
|
|
368
|
-
handler: {
|
|
369
|
-
name: "count",
|
|
370
|
-
params: __countToolParams,
|
|
371
|
-
execute: count,
|
|
372
|
-
isBuiltin: false
|
|
373
|
-
}
|
|
374
|
-
},
|
|
375
|
-
sortBy: {
|
|
376
|
-
definition: __sortByTool,
|
|
377
|
-
handler: {
|
|
378
|
-
name: "sortBy",
|
|
379
|
-
params: __sortByToolParams,
|
|
380
|
-
execute: sortBy,
|
|
381
|
-
isBuiltin: false
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
unique: {
|
|
385
|
-
definition: __uniqueTool,
|
|
386
|
-
handler: {
|
|
387
|
-
name: "unique",
|
|
388
|
-
params: __uniqueToolParams,
|
|
389
|
-
execute: unique,
|
|
390
|
-
isBuiltin: false
|
|
391
|
-
}
|
|
392
|
-
},
|
|
393
|
-
groupBy: {
|
|
394
|
-
definition: __groupByTool,
|
|
395
|
-
handler: {
|
|
396
|
-
name: "groupBy",
|
|
397
|
-
params: __groupByToolParams,
|
|
398
|
-
execute: groupBy,
|
|
399
|
-
isBuiltin: false
|
|
400
|
-
}
|
|
401
|
-
},
|
|
402
284
|
readSkill: {
|
|
403
285
|
definition: __readSkillTool,
|
|
404
286
|
handler: {
|
|
@@ -410,22 +292,22 @@ const __toolRegistry = {
|
|
|
410
292
|
}
|
|
411
293
|
};
|
|
412
294
|
async function todoWrite(todos, __state = void 0) {
|
|
413
|
-
|
|
295
|
+
var __setupData = setupFunction({
|
|
414
296
|
state: __state
|
|
415
297
|
});
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
298
|
+
var __stack = __setupData.stack;
|
|
299
|
+
var __step = __setupData.step;
|
|
300
|
+
var __self = __setupData.self;
|
|
301
|
+
var __threads = __setupData.threads;
|
|
302
|
+
var __ctx = __state?.ctx || __globalCtx;
|
|
303
|
+
var statelogClient = __ctx.statelogClient;
|
|
304
|
+
var __graph = __ctx.graph;
|
|
305
|
+
var __forked;
|
|
306
|
+
var __functionCompleted = false;
|
|
425
307
|
if (!__ctx.globals.isInitialized("stdlib/agent.agency")) {
|
|
426
308
|
await __initializeGlobals(__ctx);
|
|
427
309
|
}
|
|
428
|
-
|
|
310
|
+
var __funcStartTime = performance.now();
|
|
429
311
|
await callHook({
|
|
430
312
|
callbacks: __ctx.callbacks,
|
|
431
313
|
name: "onFunctionStart",
|
|
@@ -498,22 +380,22 @@ async function todoWrite(todos, __state = void 0) {
|
|
|
498
380
|
}
|
|
499
381
|
}
|
|
500
382
|
async function todoList(__state = void 0) {
|
|
501
|
-
|
|
383
|
+
var __setupData = setupFunction({
|
|
502
384
|
state: __state
|
|
503
385
|
});
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
386
|
+
var __stack = __setupData.stack;
|
|
387
|
+
var __step = __setupData.step;
|
|
388
|
+
var __self = __setupData.self;
|
|
389
|
+
var __threads = __setupData.threads;
|
|
390
|
+
var __ctx = __state?.ctx || __globalCtx;
|
|
391
|
+
var statelogClient = __ctx.statelogClient;
|
|
392
|
+
var __graph = __ctx.graph;
|
|
393
|
+
var __forked;
|
|
394
|
+
var __functionCompleted = false;
|
|
513
395
|
if (!__ctx.globals.isInitialized("stdlib/agent.agency")) {
|
|
514
396
|
await __initializeGlobals(__ctx);
|
|
515
397
|
}
|
|
516
|
-
|
|
398
|
+
var __funcStartTime = performance.now();
|
|
517
399
|
await callHook({
|
|
518
400
|
callbacks: __ctx.callbacks,
|
|
519
401
|
name: "onFunctionStart",
|
|
@@ -576,22 +458,22 @@ async function todoList(__state = void 0) {
|
|
|
576
458
|
}
|
|
577
459
|
}
|
|
578
460
|
async function question(prompt, __state = void 0) {
|
|
579
|
-
|
|
461
|
+
var __setupData = setupFunction({
|
|
580
462
|
state: __state
|
|
581
463
|
});
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
464
|
+
var __stack = __setupData.stack;
|
|
465
|
+
var __step = __setupData.step;
|
|
466
|
+
var __self = __setupData.self;
|
|
467
|
+
var __threads = __setupData.threads;
|
|
468
|
+
var __ctx = __state?.ctx || __globalCtx;
|
|
469
|
+
var statelogClient = __ctx.statelogClient;
|
|
470
|
+
var __graph = __ctx.graph;
|
|
471
|
+
var __forked;
|
|
472
|
+
var __functionCompleted = false;
|
|
591
473
|
if (!__ctx.globals.isInitialized("stdlib/agent.agency")) {
|
|
592
474
|
await __initializeGlobals(__ctx);
|
|
593
475
|
}
|
|
594
|
-
|
|
476
|
+
var __funcStartTime = performance.now();
|
|
595
477
|
await callHook({
|
|
596
478
|
callbacks: __ctx.callbacks,
|
|
597
479
|
name: "onFunctionStart",
|