agency-lang 0.6.3 → 0.6.4
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/optimize/baseOptimizer.js +7 -2
- package/dist/lib/optimize/baseOptimizer.workdir.test.d.ts +1 -0
- package/dist/lib/optimize/baseOptimizer.workdir.test.js +77 -0
- package/dist/lib/stdlib/version.d.ts +1 -1
- package/dist/lib/stdlib/version.js +1 -1
- package/dist/lib/typeChecker/capabilities.test.d.ts +1 -0
- package/dist/lib/typeChecker/capabilities.test.js +74 -0
- package/package.json +1 -1
- package/stdlib/capabilities.agency +60 -0
- package/stdlib/capabilities.js +172 -0
|
@@ -182,8 +182,13 @@ export class BaseOptimizer {
|
|
|
182
182
|
/** Default runInput: run the agent for one input via the eval-run subprocess path (named args). */
|
|
183
183
|
async runInputViaEval(ws, entryFile, input, id) {
|
|
184
184
|
// Now that eval and optimize share the Input type, the input flows straight
|
|
185
|
-
// through — we
|
|
186
|
-
|
|
185
|
+
// through — we pin the id so artifacts land in a predictable directory, and
|
|
186
|
+
// default working_dir to the forked workspace. The workspace is a full copy
|
|
187
|
+
// of the source tree, so seeding each per-input workdir from it gives the
|
|
188
|
+
// agent an isolated copy of the project as its cwd; without this the workdir
|
|
189
|
+
// is created empty and relative file references (e.g. exec on a repo path)
|
|
190
|
+
// resolve against nothing. An input that names its own working_dir wins.
|
|
191
|
+
const spec = { ...input, id, working_dir: input.working_dir ?? ws.dir };
|
|
187
192
|
this.runCounter += 1;
|
|
188
193
|
const result = await evalRunLoadedInputs({
|
|
189
194
|
agent: path.join(ws.dir, entryFile),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as os from "os";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { BaseGrader } from "./grading/baseGrader.js";
|
|
6
|
+
import { BaseOptimizer } from "./baseOptimizer.js";
|
|
7
|
+
// Capture the spec the default eval-run path hands to the eval runner so we can
|
|
8
|
+
// assert it carries a working_dir (without spawning a real agent subprocess).
|
|
9
|
+
const { mockEval } = vi.hoisted(() => ({ mockEval: vi.fn() }));
|
|
10
|
+
vi.mock("@/cli/eval/run.js", () => ({
|
|
11
|
+
evalRunLoadedInputs: mockEval,
|
|
12
|
+
optimizeEvalRecordExtractor: {},
|
|
13
|
+
resolveEvalRunTarget: vi.fn(),
|
|
14
|
+
}));
|
|
15
|
+
class FixedGrader extends BaseGrader {
|
|
16
|
+
grade;
|
|
17
|
+
defaultName = "fixed";
|
|
18
|
+
constructor(grade, options = {}) {
|
|
19
|
+
super(options);
|
|
20
|
+
this.grade = grade;
|
|
21
|
+
}
|
|
22
|
+
_run(_input) { return Promise.resolve(this.grade); }
|
|
23
|
+
}
|
|
24
|
+
/** Concrete subclass exposing `evaluate` so we can drive the default runInput path. */
|
|
25
|
+
class Probe extends BaseOptimizer {
|
|
26
|
+
name = "probe";
|
|
27
|
+
async optimizeTargets() { return {}; }
|
|
28
|
+
evaluateAt(ws, entry, inputs) {
|
|
29
|
+
return this.evaluate(ws, entry, inputs);
|
|
30
|
+
}
|
|
31
|
+
forkAt(dir) { return this.fork(dir); }
|
|
32
|
+
}
|
|
33
|
+
describe("BaseOptimizer.runInputViaEval working_dir", () => {
|
|
34
|
+
let root;
|
|
35
|
+
let src;
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
root = fs.mkdtempSync(path.join(os.tmpdir(), "bo-wd-"));
|
|
38
|
+
src = path.join(root, "src");
|
|
39
|
+
fs.mkdirSync(src);
|
|
40
|
+
fs.writeFileSync(path.join(src, "agent.agency"), "node main() {}\n");
|
|
41
|
+
// A sibling file the agent would reference relative to its cwd (the workdir).
|
|
42
|
+
fs.writeFileSync(path.join(src, "data.txt"), "hello\n");
|
|
43
|
+
mockEval.mockImplementation(async (args) => {
|
|
44
|
+
const input = args.inputs[0];
|
|
45
|
+
const recordPath = path.join(root, `${args.runId}-record.json`);
|
|
46
|
+
fs.writeFileSync(recordPath, JSON.stringify({ evalOutputs: [{ value: "out" }] }));
|
|
47
|
+
return { inputs: [{ status: "success", evalRecordPath: recordPath, input }] };
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
afterEach(() => {
|
|
51
|
+
mockEval.mockReset();
|
|
52
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
53
|
+
});
|
|
54
|
+
function probe() {
|
|
55
|
+
return new Probe({ graders: [new FixedGrader({ score: { kind: "scalar", value: 1 } })], iterations: 1, config: {}, runsDir: root, runId: "r" }, { workspaceRoot: path.join(root, "ws") });
|
|
56
|
+
}
|
|
57
|
+
it("points the per-input working_dir at the forked workspace so its files land in the workdir", async () => {
|
|
58
|
+
const p = probe();
|
|
59
|
+
const ws = p.forkAt(src);
|
|
60
|
+
await p.evaluateAt(ws, "agent.agency", [{ id: "a", args: {} }]);
|
|
61
|
+
expect(mockEval).toHaveBeenCalledTimes(1);
|
|
62
|
+
const spec = mockEval.mock.calls[0][0].inputs[0];
|
|
63
|
+
// The workspace is a full copy of the source tree; the per-input workdir must
|
|
64
|
+
// be seeded from it, or relative file references resolve against an empty dir.
|
|
65
|
+
expect(spec.working_dir).toBe(ws.dir);
|
|
66
|
+
expect(fs.existsSync(path.join(ws.dir, "data.txt"))).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
it("preserves an input-provided working_dir instead of overriding it", async () => {
|
|
69
|
+
const p = probe();
|
|
70
|
+
const ws = p.forkAt(src);
|
|
71
|
+
const custom = path.join(root, "custom");
|
|
72
|
+
fs.mkdirSync(custom);
|
|
73
|
+
await p.evaluateAt(ws, "agent.agency", [{ id: "a", args: {}, working_dir: custom }]);
|
|
74
|
+
const spec = mockEval.mock.calls[0][0].inputs[0];
|
|
75
|
+
expect(spec.working_dir).toBe(custom);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.4
|
|
1
|
+
export declare const VERSION = "0.6.4";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.4
|
|
1
|
+
export const VERSION = "0.6.4";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { typecheckSource } from "./testUtils.js";
|
|
3
|
+
// Errors from the raises / effect-set diagnostics only.
|
|
4
|
+
function capErrors(src) {
|
|
5
|
+
return typecheckSource(src).filter((e) => /raises effect|not an effect set/.test(e.message));
|
|
6
|
+
}
|
|
7
|
+
const hasEffectError = (errs, effect) => errs.some((e) => e.message.includes(`raises effect '${effect}'`));
|
|
8
|
+
// A node that calls the real, globally-available `read` — a pure read, and
|
|
9
|
+
// the only real stdlib call these tests make — under a given raises clause.
|
|
10
|
+
function nodeUsingRead(setExpr, importName) {
|
|
11
|
+
return (`import { ${importName} } from "std::capabilities"\n` +
|
|
12
|
+
`node main(): string raises ${setExpr} {\n` +
|
|
13
|
+
` read("f.txt") with approve\n` +
|
|
14
|
+
` return "ok"\n}`);
|
|
15
|
+
}
|
|
16
|
+
describe("std::capabilities — sets containing filesystem read permit a real read()", () => {
|
|
17
|
+
// Validated against reality: the real `read` raises std::read, and these
|
|
18
|
+
// sets must contain it. A broken/unresolved set would reject the call.
|
|
19
|
+
it("FileRead permits read()", () => {
|
|
20
|
+
expect(capErrors(nodeUsingRead("<FileRead>", "FileRead"))).toHaveLength(0);
|
|
21
|
+
});
|
|
22
|
+
it("FileSystem (composite of FileRead + FileWrite) permits read()", () => {
|
|
23
|
+
expect(capErrors(nodeUsingRead("<FileSystem>", "FileSystem"))).toHaveLength(0);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe("std::capabilities — non-read sets reject read() and resolve to real members", () => {
|
|
27
|
+
// For sets with no filesystem-read member, a real read() must be rejected.
|
|
28
|
+
// Asserting the rejection message lists a REAL member proves the set
|
|
29
|
+
// actually resolved to its declared contents — if it had silently failed
|
|
30
|
+
// to resolve, the message would echo the bare alias name (e.g. `<FileWrite>`)
|
|
31
|
+
// instead of the member effects.
|
|
32
|
+
const cases = [
|
|
33
|
+
["FileWrite", "std::write"],
|
|
34
|
+
["Shell", "std::bash"],
|
|
35
|
+
["Messaging", "std::sendEmail"],
|
|
36
|
+
["Auth", "std::authorize"],
|
|
37
|
+
];
|
|
38
|
+
cases.forEach(([set, member]) => {
|
|
39
|
+
it(`${set} rejects read() and resolves to include ${member}`, () => {
|
|
40
|
+
const errs = capErrors(nodeUsingRead(`<${set}>`, set));
|
|
41
|
+
const err = errs.find((e) => e.message.includes("raises effect 'std::read'"));
|
|
42
|
+
expect(err, `${set} should reject std::read`).toBeDefined();
|
|
43
|
+
// Proves the set resolved to its real contents, not a literal fallback.
|
|
44
|
+
expect(err.message).toContain(member);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe("std::capabilities — read-capable non-filesystem sets permit their own read effect but exclude std::read", () => {
|
|
49
|
+
// These sets contain a read/query effect of their own. We positively
|
|
50
|
+
// confirm membership of that READ effect (synthetic raise of a read effect
|
|
51
|
+
// — no write/delete calls) AND that filesystem read is still excluded.
|
|
52
|
+
// Together this proves the set resolved correctly: it contains its member
|
|
53
|
+
// and does not contain std::read.
|
|
54
|
+
const cases = [
|
|
55
|
+
["Network", "std::http::fetch"],
|
|
56
|
+
["Calendar", "std::listEvents"],
|
|
57
|
+
["Secrets", "std::getSecret"],
|
|
58
|
+
["Memory", "std::memory::recall"],
|
|
59
|
+
];
|
|
60
|
+
cases.forEach(([set, readEffect]) => {
|
|
61
|
+
it(`${set} permits ${readEffect} but not std::read`, () => {
|
|
62
|
+
const src = `import { ${set} } from "std::capabilities"\n` +
|
|
63
|
+
`node main(): string raises <${set}> {\n` +
|
|
64
|
+
` raise ${readEffect}("m", {})\n` +
|
|
65
|
+
` read("f.txt") with approve\n` +
|
|
66
|
+
` return "ok"\n}`;
|
|
67
|
+
const errs = capErrors(src);
|
|
68
|
+
// member is allowed (no error for it) ...
|
|
69
|
+
expect(hasEffectError(errs, readEffect)).toBe(false);
|
|
70
|
+
// ... but std::read is not in the set, so it is rejected.
|
|
71
|
+
expect(hasEffectError(errs, "std::read")).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
package/package.json
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** @module
|
|
2
|
+
Standard **capability** effect sets — named groups of the interrupt
|
|
3
|
+
effects the standard library raises, for use in `raises` clauses.
|
|
4
|
+
|
|
5
|
+
A `raises` clause is an *allowlist* (an upper bound), so these sets are
|
|
6
|
+
composable building blocks you union together to say what a function or
|
|
7
|
+
node is permitted to do:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { FileRead, Network } from "std::capabilities"
|
|
11
|
+
|
|
12
|
+
// may read files and make network calls — nothing else
|
|
13
|
+
node main() raises <FileRead, Network> { ... }
|
|
14
|
+
|
|
15
|
+
// read-only inspection
|
|
16
|
+
node audit() raises <FileRead> { ... }
|
|
17
|
+
|
|
18
|
+
// guaranteed to perform no interrupting actions
|
|
19
|
+
def pure() raises <> { ... }
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The sets are purely mechanical groupings by capability; they encode no
|
|
23
|
+
security judgement (e.g. there is intentionally no "read-only" set that
|
|
24
|
+
decides whether a network fetch counts as a read). Compose the pieces
|
|
25
|
+
you need.
|
|
26
|
+
|
|
27
|
+
Note: these constrain callers. Individual functions should still declare
|
|
28
|
+
the specific effect they raise (e.g. `raises <std::read>`), not a whole
|
|
29
|
+
capability set.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** Read-only filesystem access: reading files and listing/searching paths. */
|
|
33
|
+
export effectSet FileRead = <std::read, std::readImage, std::ls, std::glob, std::grep>
|
|
34
|
+
|
|
35
|
+
/** Filesystem mutation: creating, editing, moving, copying, and deleting. */
|
|
36
|
+
export effectSet FileWrite = <std::write, std::edit, std::applyPatch, std::mkdir, std::move, std::copy, std::remove>
|
|
37
|
+
|
|
38
|
+
/** All filesystem access — reads and writes. */
|
|
39
|
+
export effectSet FileSystem = <FileRead, FileWrite>
|
|
40
|
+
|
|
41
|
+
/** Arbitrary command / process execution. The sharpest edge — grant with care. */
|
|
42
|
+
export effectSet Shell = <std::bash, std::exec, std::run>
|
|
43
|
+
|
|
44
|
+
/** Anything that talks to the outside world over the network. */
|
|
45
|
+
export effectSet Network = <std::http::fetch, std::http::fetchJSON, std::http::fetchMarkdown, std::search, std::weather, std::browserUse, std::wikipedia::article, std::wikipedia::search, std::wikipedia::summary>
|
|
46
|
+
|
|
47
|
+
/** Sending messages to people: email, SMS, and iMessage. */
|
|
48
|
+
export effectSet Messaging = <std::sendEmail, std::sendSms, std::sendIMessage>
|
|
49
|
+
|
|
50
|
+
/** Reading and writing credentials in the system keyring. */
|
|
51
|
+
export effectSet Secrets = <std::getSecret, std::setSecret, std::deleteSecret>
|
|
52
|
+
|
|
53
|
+
/** OAuth-style authorization flows: granting, fetching, and revoking access. */
|
|
54
|
+
export effectSet Auth = <std::authorize, std::getAccessToken, std::revokeAuth>
|
|
55
|
+
|
|
56
|
+
/** Calendar access: listing and mutating events (incl. calendar authorization). */
|
|
57
|
+
export effectSet Calendar = <std::listEvents, std::createEvent, std::updateEvent, std::deleteEvent, std::authorizeCalendar>
|
|
58
|
+
|
|
59
|
+
/** Agent long-term memory: recall, remember, forget, and enable/disable. */
|
|
60
|
+
export effectSet Memory = <std::memory::recall, std::memory::remember, std::memory::forget, std::memory::enableMemory, std::memory::disableMemory>
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { print, printJSON, parseJSON, input, sleep, round, read, write, readImage, notify, range, mostCommon, keys, values, entries, emit, callback } from "agency-lang/stdlib/index.js";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import __process from "process";
|
|
4
|
+
import { z } from "agency-lang/zod";
|
|
5
|
+
import { nanoid } from "agency-lang";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import {
|
|
8
|
+
RuntimeContext,
|
|
9
|
+
checkpoint as __checkpoint_impl,
|
|
10
|
+
getCheckpoint as __getCheckpoint_impl,
|
|
11
|
+
restore as __restore_impl,
|
|
12
|
+
_run as __runtime_run_impl,
|
|
13
|
+
interrupt,
|
|
14
|
+
isInterrupt,
|
|
15
|
+
hasInterrupts,
|
|
16
|
+
isDebugger,
|
|
17
|
+
respondToInterrupts as _respondToInterrupts,
|
|
18
|
+
rewindFrom as _rewindFrom,
|
|
19
|
+
runExportedFunction as _runExportedFunction,
|
|
20
|
+
__registerGlobalsInit,
|
|
21
|
+
AgencyFunction as __AgencyFunction,
|
|
22
|
+
functionRefReviver as __functionRefReviver,
|
|
23
|
+
DeterministicClient as __DeterministicClient
|
|
24
|
+
} from "agency-lang/runtime";
|
|
25
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
26
|
+
const __dirname = path.dirname(__filename);
|
|
27
|
+
const __cwd = __process.cwd();
|
|
28
|
+
const getDirname = () => __dirname;
|
|
29
|
+
const __globalCtx = new RuntimeContext({
|
|
30
|
+
statelogConfig: {
|
|
31
|
+
host: "https://statelog.adit.io",
|
|
32
|
+
apiKey: __process.env["STATELOG_API_KEY"] || "",
|
|
33
|
+
projectId: "agency-lang",
|
|
34
|
+
debugMode: false,
|
|
35
|
+
observability: true,
|
|
36
|
+
logFile: "log.jsonl"
|
|
37
|
+
},
|
|
38
|
+
smoltalkDefaults: {
|
|
39
|
+
openAiApiKey: __process.env["OPENAI_API_KEY"] || "",
|
|
40
|
+
googleApiKey: __process.env["GEMINI_API_KEY"] || "",
|
|
41
|
+
anthropicApiKey: __process.env["ANTHROPIC_API_KEY"] || "",
|
|
42
|
+
model: "gpt-4o-mini",
|
|
43
|
+
logLevel: "warn",
|
|
44
|
+
statelog: {
|
|
45
|
+
host: "https://statelog.adit.io",
|
|
46
|
+
projectId: "smoltalk",
|
|
47
|
+
apiKey: __process.env["STATELOG_SMOLTALK_API_KEY"] || "",
|
|
48
|
+
traceId: nanoid()
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
dirname: __dirname,
|
|
52
|
+
logLevel: "info",
|
|
53
|
+
traceConfig: {
|
|
54
|
+
program: "stdlib/capabilities.agency"
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const graph = __globalCtx.graph;
|
|
58
|
+
function approve(value) {
|
|
59
|
+
return { type: "approve", value };
|
|
60
|
+
}
|
|
61
|
+
function reject(value) {
|
|
62
|
+
return { type: "reject", value };
|
|
63
|
+
}
|
|
64
|
+
function propagate() {
|
|
65
|
+
return { type: "propagate" };
|
|
66
|
+
}
|
|
67
|
+
const respondToInterrupts = (interrupts, responses, opts) => _respondToInterrupts({ ctx: __globalCtx, interrupts, responses, overrides: opts?.overrides, metadata: opts?.metadata, registerTopLevelCallbacks: __registerTopLevelCallbacks, moduleDir: __dirname });
|
|
68
|
+
const rewindFrom = (checkpoint2, overrides, opts) => _rewindFrom({ ctx: __globalCtx, checkpoint: checkpoint2, overrides, metadata: opts?.metadata, registerTopLevelCallbacks: __registerTopLevelCallbacks, moduleDir: __dirname });
|
|
69
|
+
const __invokeFunction = (fn, namedArgs) => _runExportedFunction({ ctx: __globalCtx, fn, namedArgs, initializeGlobals: __initializeGlobals, registerTopLevelCallbacks: __registerTopLevelCallbacks, moduleDir: __dirname });
|
|
70
|
+
const __setDebugger = (dbg) => {
|
|
71
|
+
__globalCtx.debuggerState = dbg;
|
|
72
|
+
};
|
|
73
|
+
const __setTraceFile = (filePath) => {
|
|
74
|
+
__globalCtx.traceConfig.traceFile = filePath;
|
|
75
|
+
};
|
|
76
|
+
const __setLLMClient = (client) => {
|
|
77
|
+
__globalCtx.setLLMClient(client);
|
|
78
|
+
};
|
|
79
|
+
const __getCheckpoints = () => __globalCtx.checkpoints;
|
|
80
|
+
if (__process.env.AGENCY_LLM_MOCKS) {
|
|
81
|
+
__globalCtx.setLLMClient(
|
|
82
|
+
new __DeterministicClient(JSON.parse(__process.env.AGENCY_LLM_MOCKS))
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
const __toolRegistry = __functionRefReviver.registry ??= {};
|
|
86
|
+
function __registerTool(value, _aliasName) {
|
|
87
|
+
if (__AgencyFunction.isAgencyFunction(value)) {
|
|
88
|
+
__toolRegistry[`${value.module}:${value.name}`] = value;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const checkpoint = __AgencyFunction.create({ name: "checkpoint", module: "__runtime", fn: __checkpoint_impl, params: [], toolDefinition: null }, __toolRegistry);
|
|
92
|
+
const getCheckpoint = __AgencyFunction.create({ name: "getCheckpoint", module: "__runtime", fn: __getCheckpoint_impl, params: [{ name: "checkpointId", hasDefault: false, defaultValue: void 0, variadic: false }], toolDefinition: null }, __toolRegistry);
|
|
93
|
+
const restore = __AgencyFunction.create({ name: "restore", module: "__runtime", fn: __restore_impl, params: [{ name: "checkpointIdOrCheckpoint", hasDefault: false, defaultValue: void 0, variadic: false }, { name: "options", hasDefault: false, defaultValue: void 0, variadic: false }], toolDefinition: null }, __toolRegistry);
|
|
94
|
+
const _run = __AgencyFunction.create({ name: "_run", module: "__runtime", fn: __runtime_run_impl, params: [{ name: "compiled", hasDefault: false, defaultValue: void 0, variadic: false }, { name: "node", hasDefault: false, defaultValue: void 0, variadic: false }, { name: "args", hasDefault: false, defaultValue: void 0, variadic: false }, { name: "wallClock", hasDefault: false, defaultValue: void 0, variadic: false }, { name: "memory", hasDefault: false, defaultValue: void 0, variadic: false }, { name: "ipcPayload", hasDefault: false, defaultValue: void 0, variadic: false }, { name: "stdout", hasDefault: false, defaultValue: void 0, variadic: false }, { name: "configOverrides", hasDefault: false, defaultValue: void 0, variadic: false }, { name: "cwd", hasDefault: false, defaultValue: void 0, variadic: false }], toolDefinition: null }, __toolRegistry);
|
|
95
|
+
function setLLMClient(client) {
|
|
96
|
+
__globalCtx.setLLMClient(client);
|
|
97
|
+
}
|
|
98
|
+
function registerTools(tools) {
|
|
99
|
+
for (const tool of tools) {
|
|
100
|
+
if (__AgencyFunction.isAgencyFunction(tool)) {
|
|
101
|
+
__toolRegistry[`${tool.module}:${tool.name}`] = tool;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
__registerTool(print);
|
|
106
|
+
__registerTool(printJSON);
|
|
107
|
+
__registerTool(parseJSON);
|
|
108
|
+
__registerTool(input);
|
|
109
|
+
__registerTool(sleep);
|
|
110
|
+
__registerTool(round);
|
|
111
|
+
__registerTool(read);
|
|
112
|
+
__registerTool(write);
|
|
113
|
+
__registerTool(readImage);
|
|
114
|
+
__registerTool(notify);
|
|
115
|
+
__registerTool(range);
|
|
116
|
+
__registerTool(mostCommon);
|
|
117
|
+
__registerTool(keys);
|
|
118
|
+
__registerTool(values);
|
|
119
|
+
__registerTool(entries);
|
|
120
|
+
__registerTool(emit);
|
|
121
|
+
__registerTool(callback);
|
|
122
|
+
async function __initializeGlobals(__ctx) {
|
|
123
|
+
if (__ctx.globals.isInitialized("stdlib/capabilities.agency")) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
__ctx.globals.markInitialized("stdlib/capabilities.agency");
|
|
127
|
+
}
|
|
128
|
+
__registerGlobalsInit("stdlib/capabilities.agency", __initializeGlobals);
|
|
129
|
+
async function __registerTopLevelCallbacks(__ctx) {
|
|
130
|
+
__ctx.topLevelCallbacks = [];
|
|
131
|
+
}
|
|
132
|
+
__functionRefReviver.registry = __toolRegistry;
|
|
133
|
+
const FileRead = z.union([z.literal("std::read"), z.literal("std::readImage"), z.literal("std::ls"), z.literal("std::glob"), z.literal("std::grep")]);
|
|
134
|
+
const FileWrite = z.union([z.literal("std::write"), z.literal("std::edit"), z.literal("std::applyPatch"), z.literal("std::mkdir"), z.literal("std::move"), z.literal("std::copy"), z.literal("std::remove")]);
|
|
135
|
+
const FileSystem = z.union([FileRead, FileWrite]);
|
|
136
|
+
const Shell = z.union([z.literal("std::bash"), z.literal("std::exec"), z.literal("std::run")]);
|
|
137
|
+
const Network = z.union([z.literal("std::http::fetch"), z.literal("std::http::fetchJSON"), z.literal("std::http::fetchMarkdown"), z.literal("std::search"), z.literal("std::weather"), z.literal("std::browserUse"), z.literal("std::wikipedia::article"), z.literal("std::wikipedia::search"), z.literal("std::wikipedia::summary")]);
|
|
138
|
+
const Messaging = z.union([z.literal("std::sendEmail"), z.literal("std::sendSms"), z.literal("std::sendIMessage")]);
|
|
139
|
+
const Secrets = z.union([z.literal("std::getSecret"), z.literal("std::setSecret"), z.literal("std::deleteSecret")]);
|
|
140
|
+
const Auth = z.union([z.literal("std::authorize"), z.literal("std::getAccessToken"), z.literal("std::revokeAuth")]);
|
|
141
|
+
const Calendar = z.union([z.literal("std::listEvents"), z.literal("std::createEvent"), z.literal("std::updateEvent"), z.literal("std::deleteEvent"), z.literal("std::authorizeCalendar")]);
|
|
142
|
+
const Memory = z.union([z.literal("std::memory::recall"), z.literal("std::memory::remember"), z.literal("std::memory::forget"), z.literal("std::memory::enableMemory"), z.literal("std::memory::disableMemory")]);
|
|
143
|
+
var stdin_default = graph;
|
|
144
|
+
const __sourceMap = {};
|
|
145
|
+
export {
|
|
146
|
+
Auth,
|
|
147
|
+
Calendar,
|
|
148
|
+
FileRead,
|
|
149
|
+
FileSystem,
|
|
150
|
+
FileWrite,
|
|
151
|
+
Memory,
|
|
152
|
+
Messaging,
|
|
153
|
+
Network,
|
|
154
|
+
Secrets,
|
|
155
|
+
Shell,
|
|
156
|
+
__getCheckpoints,
|
|
157
|
+
__invokeFunction,
|
|
158
|
+
__setDebugger,
|
|
159
|
+
__setLLMClient,
|
|
160
|
+
__setTraceFile,
|
|
161
|
+
__sourceMap,
|
|
162
|
+
__toolRegistry,
|
|
163
|
+
approve,
|
|
164
|
+
stdin_default as default,
|
|
165
|
+
hasInterrupts,
|
|
166
|
+
interrupt,
|
|
167
|
+
isDebugger,
|
|
168
|
+
isInterrupt,
|
|
169
|
+
reject,
|
|
170
|
+
respondToInterrupts,
|
|
171
|
+
rewindFrom
|
|
172
|
+
};
|