@agenteer/stdlib 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/context/context_curator.d.ts +115 -0
- package/dist/context/context_curator.d.ts.map +1 -0
- package/dist/context/context_curator.js +132 -0
- package/dist/context/context_curator.js.map +1 -0
- package/dist/humans/approval_gate.d.ts +82 -0
- package/dist/humans/approval_gate.d.ts.map +1 -0
- package/dist/humans/approval_gate.js +76 -0
- package/dist/humans/approval_gate.js.map +1 -0
- package/dist/humans/ask_user.d.ts +79 -0
- package/dist/humans/ask_user.d.ts.map +1 -0
- package/dist/humans/ask_user.js +101 -0
- package/dist/humans/ask_user.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/meta/cross_check.d.ts +96 -0
- package/dist/meta/cross_check.d.ts.map +1 -0
- package/dist/meta/cross_check.js +165 -0
- package/dist/meta/cross_check.js.map +1 -0
- package/dist/meta/judge_with_stripped_ctx.d.ts +75 -0
- package/dist/meta/judge_with_stripped_ctx.d.ts.map +1 -0
- package/dist/meta/judge_with_stripped_ctx.js +151 -0
- package/dist/meta/judge_with_stripped_ctx.js.map +1 -0
- package/dist/meta/parallel_fanout.d.ts +83 -0
- package/dist/meta/parallel_fanout.d.ts.map +1 -0
- package/dist/meta/parallel_fanout.js +120 -0
- package/dist/meta/parallel_fanout.js.map +1 -0
- package/dist/meta/repair_loop.d.ts +90 -0
- package/dist/meta/repair_loop.d.ts.map +1 -0
- package/dist/meta/repair_loop.js +230 -0
- package/dist/meta/repair_loop.js.map +1 -0
- package/dist/planner/default_planner.d.ts +88 -0
- package/dist/planner/default_planner.d.ts.map +1 -0
- package/dist/planner/default_planner.js +156 -0
- package/dist/planner/default_planner.js.map +1 -0
- package/dist/primitives/file_read.d.ts +60 -0
- package/dist/primitives/file_read.d.ts.map +1 -0
- package/dist/primitives/file_read.js +68 -0
- package/dist/primitives/file_read.js.map +1 -0
- package/dist/primitives/file_write.d.ts +60 -0
- package/dist/primitives/file_write.d.ts.map +1 -0
- package/dist/primitives/file_write.js +66 -0
- package/dist/primitives/file_write.js.map +1 -0
- package/dist/primitives/llm_call.d.ts +85 -0
- package/dist/primitives/llm_call.d.ts.map +1 -0
- package/dist/primitives/llm_call.js +99 -0
- package/dist/primitives/llm_call.js.map +1 -0
- package/dist/primitives/shell_exec.d.ts +66 -0
- package/dist/primitives/shell_exec.d.ts.map +1 -0
- package/dist/primitives/shell_exec.js +106 -0
- package/dist/primitives/shell_exec.js.map +1 -0
- package/dist/primitives/tool_call.d.ts +62 -0
- package/dist/primitives/tool_call.d.ts.map +1 -0
- package/dist/primitives/tool_call.js +69 -0
- package/dist/primitives/tool_call.js.map +1 -0
- package/dist/shared/capture.d.ts +34 -0
- package/dist/shared/capture.d.ts.map +1 -0
- package/dist/shared/capture.js +124 -0
- package/dist/shared/capture.js.map +1 -0
- package/dist/shared/ctx.d.ts +14 -0
- package/dist/shared/ctx.d.ts.map +1 -0
- package/dist/shared/ctx.js +48 -0
- package/dist/shared/ctx.js.map +1 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/validator.d.ts +47 -0
- package/dist/shared/validator.d.ts.map +1 -0
- package/dist/shared/validator.js +41 -0
- package/dist/shared/validator.js.map +1 -0
- package/dist/validators/compile.d.ts +83 -0
- package/dist/validators/compile.d.ts.map +1 -0
- package/dist/validators/compile.js +126 -0
- package/dist/validators/compile.js.map +1 -0
- package/dist/validators/json_schema_validate.d.ts +72 -0
- package/dist/validators/json_schema_validate.d.ts.map +1 -0
- package/dist/validators/json_schema_validate.js +85 -0
- package/dist/validators/json_schema_validate.js.map +1 -0
- package/dist/validators/regex_check.d.ts +64 -0
- package/dist/validators/regex_check.d.ts.map +1 -0
- package/dist/validators/regex_check.js +85 -0
- package/dist/validators/regex_check.js.map +1 -0
- package/dist/validators/test_run.d.ts +74 -0
- package/dist/validators/test_run.d.ts.map +1 -0
- package/dist/validators/test_run.js +149 -0
- package/dist/validators/test_run.js.map +1 -0
- package/dist/validators/typecheck.d.ts +61 -0
- package/dist/validators/typecheck.d.ts.map +1 -0
- package/dist/validators/typecheck.js +89 -0
- package/dist/validators/typecheck.js.map +1 -0
- package/package.json +61 -0
- package/src/context/context_curator.ts +154 -0
- package/src/humans/approval_gate.ts +101 -0
- package/src/humans/ask_user.ts +137 -0
- package/src/index.ts +149 -0
- package/src/meta/cross_check.ts +219 -0
- package/src/meta/judge_with_stripped_ctx.ts +171 -0
- package/src/meta/parallel_fanout.ts +142 -0
- package/src/meta/repair_loop.ts +267 -0
- package/src/planner/default_planner.ts +182 -0
- package/src/primitives/file_read.ts +82 -0
- package/src/primitives/file_write.ts +80 -0
- package/src/primitives/llm_call.ts +113 -0
- package/src/primitives/shell_exec.ts +122 -0
- package/src/primitives/tool_call.ts +84 -0
- package/src/shared/capture.ts +155 -0
- package/src/shared/ctx.ts +45 -0
- package/src/shared/index.ts +17 -0
- package/src/shared/validator.ts +51 -0
- package/src/validators/compile.ts +175 -0
- package/src/validators/json_schema_validate.ts +103 -0
- package/src/validators/regex_check.ts +107 -0
- package/src/validators/test_run.ts +199 -0
- package/src/validators/typecheck.ts +121 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agenteer/node-file-read` — permissioned filesystem read (sub-plan 03 §3).
|
|
3
|
+
*
|
|
4
|
+
* Deterministic. Declares `fs.read:*`; actual scope attenuation happens at
|
|
5
|
+
* spawn time. At dispatch the permission kernel synthesizes the concrete
|
|
6
|
+
* `fs.read:<path>` capability and checks against `granted`.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { makeManifest, } from "@agenteer/core";
|
|
10
|
+
const MANIFEST = makeManifest({
|
|
11
|
+
id: "@agenteer/node-file-read",
|
|
12
|
+
name: "file_read",
|
|
13
|
+
description: "Read a file from disk into a string. Capability-gated at dispatch.",
|
|
14
|
+
determinism: "deterministic",
|
|
15
|
+
// Static caps: none. Dynamic augmentation derives the concrete fs.read
|
|
16
|
+
// scope from input.path at spawn time (master plan §R4).
|
|
17
|
+
required_actions: [],
|
|
18
|
+
dynamic_actions: true,
|
|
19
|
+
dynamic_action_spec: "fs.read:${input.path}",
|
|
20
|
+
tags: ["primitive", "fs"],
|
|
21
|
+
side_effects: {
|
|
22
|
+
writes_fs: false,
|
|
23
|
+
network: false,
|
|
24
|
+
mutates_ctx: true,
|
|
25
|
+
emits_ctx_variants: ["artifact.file_read"],
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const InputSchema = z.object({
|
|
29
|
+
path: z.string().min(1),
|
|
30
|
+
/** Optional ctx tag to emit the content under via ctx_patch.set. */
|
|
31
|
+
emit_as: z.string().optional(),
|
|
32
|
+
});
|
|
33
|
+
const OutputSchema = z.object({
|
|
34
|
+
path: z.string(),
|
|
35
|
+
content: z.string(),
|
|
36
|
+
bytes: z.number().int().nonnegative(),
|
|
37
|
+
});
|
|
38
|
+
export function fileReadFactory() {
|
|
39
|
+
return {
|
|
40
|
+
manifest: MANIFEST,
|
|
41
|
+
inputSchema: InputSchema,
|
|
42
|
+
outputSchema: OutputSchema,
|
|
43
|
+
ctx: [],
|
|
44
|
+
model: null,
|
|
45
|
+
async execute(input, handle) {
|
|
46
|
+
const { path, emit_as } = input.original;
|
|
47
|
+
try {
|
|
48
|
+
const content = await handle.callAction("fs.read", { path });
|
|
49
|
+
return {
|
|
50
|
+
kind: "output",
|
|
51
|
+
value: { path, content, bytes: Buffer.byteLength(content, "utf8") },
|
|
52
|
+
...(emit_as ? { ctx_patch: { set: { [emit_as]: content } } } : {}),
|
|
53
|
+
evidence: { verdict: "pass" },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
return {
|
|
58
|
+
kind: "failed",
|
|
59
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
60
|
+
retryable: false,
|
|
61
|
+
evidence: { verdict: "fail" },
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export const fileReadManifest = MANIFEST;
|
|
68
|
+
//# sourceMappingURL=file_read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file_read.js","sourceRoot":"","sources":["../../src/primitives/file_read.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,YAAY,GAMb,MAAM,gBAAgB,CAAC;AAExB,MAAM,QAAQ,GAAiB,YAAY,CAAC;IAC1C,EAAE,EAAE,0BAA0B;IAC9B,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,oEAAoE;IACjF,WAAW,EAAE,eAAe;IAC5B,uEAAuE;IACvE,yDAAyD;IACzD,gBAAgB,EAAE,EAAE;IACpB,eAAe,EAAE,IAAI;IACrB,mBAAmB,EAAE,uBAAuB;IAC5C,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;IACzB,YAAY,EAAE;QACZ,SAAS,EAAE,KAAK;QAChB,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,IAAI;QACjB,kBAAkB,EAAE,CAAC,oBAAoB,CAAC;KAC3C;CACF,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,oEAAoE;IACpE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,IAAI,EAAE,C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AC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agenteer/node-file-write` — permissioned filesystem write (sub-plan 03 §4).
|
|
3
|
+
*
|
|
4
|
+
* Deterministic w.r.t. (path, content), though authors often want to
|
|
5
|
+
* mark it stochastic if the upstream producer was an LLM — the wrapper
|
|
6
|
+
* node is the right place for that. `fs.write:<path>` is checked at
|
|
7
|
+
* dispatch; the hard denylist applies unconditionally.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { type Node } from "@agenteer/core";
|
|
11
|
+
declare const InputSchema: z.ZodObject<{
|
|
12
|
+
path: z.ZodString;
|
|
13
|
+
content: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
declare const OutputSchema: z.ZodObject<{
|
|
16
|
+
path: z.ZodString;
|
|
17
|
+
bytes: z.ZodNumber;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
type Input = z.infer<typeof InputSchema>;
|
|
20
|
+
type Output = z.infer<typeof OutputSchema>;
|
|
21
|
+
export declare function fileWriteFactory(): Node<Input, Output>;
|
|
22
|
+
export declare const fileWriteManifest: {
|
|
23
|
+
manifest_version: 1;
|
|
24
|
+
id: string;
|
|
25
|
+
version: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
required_actions: string[];
|
|
29
|
+
required_capabilities: {
|
|
30
|
+
tool_use: boolean;
|
|
31
|
+
vision: boolean;
|
|
32
|
+
structured_output: "any" | "native" | "text_parse";
|
|
33
|
+
min_context_tokens?: number | undefined;
|
|
34
|
+
};
|
|
35
|
+
dynamic_actions: boolean;
|
|
36
|
+
side_effects: {
|
|
37
|
+
writes_fs: boolean;
|
|
38
|
+
network: boolean;
|
|
39
|
+
mutates_ctx: boolean;
|
|
40
|
+
emits_ctx_variants: string[];
|
|
41
|
+
reads_ctx_variants: string[];
|
|
42
|
+
};
|
|
43
|
+
determinism: "deterministic" | "stochastic";
|
|
44
|
+
tags: string[];
|
|
45
|
+
author: string;
|
|
46
|
+
license: string;
|
|
47
|
+
input_schema?: unknown;
|
|
48
|
+
output_schema?: unknown;
|
|
49
|
+
dynamic_action_spec?: string | undefined;
|
|
50
|
+
homepage?: string | undefined;
|
|
51
|
+
repository?: string | undefined;
|
|
52
|
+
planner_hints?: {
|
|
53
|
+
cost_tier?: "cheap" | "medium" | "expensive" | undefined;
|
|
54
|
+
latency_tier?: "medium" | "fast" | "slow" | undefined;
|
|
55
|
+
typical_use?: string | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
sha256?: string | undefined;
|
|
58
|
+
};
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=file_write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file_write.d.ts","sourceRoot":"","sources":["../../src/primitives/file_write.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,KAAK,IAAI,EAKV,MAAM,gBAAgB,CAAC;AAkBxB,QAAA,MAAM,WAAW;;;iBAGf,CAAC;AAEH,QAAA,MAAM,YAAY;;;iBAGhB,CAAC;AAEH,KAAK,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACzC,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAE3C,wBAAgB,gBAAgB,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CA6BtD;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAW,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agenteer/node-file-write` — permissioned filesystem write (sub-plan 03 §4).
|
|
3
|
+
*
|
|
4
|
+
* Deterministic w.r.t. (path, content), though authors often want to
|
|
5
|
+
* mark it stochastic if the upstream producer was an LLM — the wrapper
|
|
6
|
+
* node is the right place for that. `fs.write:<path>` is checked at
|
|
7
|
+
* dispatch; the hard denylist applies unconditionally.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { makeManifest, } from "@agenteer/core";
|
|
11
|
+
const MANIFEST = makeManifest({
|
|
12
|
+
id: "@agenteer/node-file-write",
|
|
13
|
+
name: "file_write",
|
|
14
|
+
description: "Write a file to disk. Capability-gated; denylist enforced.",
|
|
15
|
+
determinism: "deterministic",
|
|
16
|
+
required_actions: [],
|
|
17
|
+
dynamic_actions: true,
|
|
18
|
+
dynamic_action_spec: "fs.write:${input.path}",
|
|
19
|
+
tags: ["primitive", "fs"],
|
|
20
|
+
side_effects: {
|
|
21
|
+
writes_fs: true,
|
|
22
|
+
network: false,
|
|
23
|
+
mutates_ctx: false,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const InputSchema = z.object({
|
|
27
|
+
path: z.string().min(1),
|
|
28
|
+
content: z.string(),
|
|
29
|
+
});
|
|
30
|
+
const OutputSchema = z.object({
|
|
31
|
+
path: z.string(),
|
|
32
|
+
bytes: z.number().int().nonnegative(),
|
|
33
|
+
});
|
|
34
|
+
export function fileWriteFactory() {
|
|
35
|
+
return {
|
|
36
|
+
manifest: MANIFEST,
|
|
37
|
+
inputSchema: InputSchema,
|
|
38
|
+
outputSchema: OutputSchema,
|
|
39
|
+
ctx: [],
|
|
40
|
+
model: null,
|
|
41
|
+
async execute(input, handle) {
|
|
42
|
+
const { path, content } = input.original;
|
|
43
|
+
try {
|
|
44
|
+
const { bytes } = await handle.callAction("fs.write", {
|
|
45
|
+
path,
|
|
46
|
+
content,
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
kind: "output",
|
|
50
|
+
value: { path, bytes },
|
|
51
|
+
evidence: { verdict: "pass" },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
return {
|
|
56
|
+
kind: "failed",
|
|
57
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
58
|
+
retryable: false,
|
|
59
|
+
evidence: { verdict: "fail" },
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export const fileWriteManifest = MANIFEST;
|
|
66
|
+
//# sourceMappingURL=file_write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file_write.js","sourceRoot":"","sources":["../../src/primitives/file_write.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,YAAY,GAMb,MAAM,gBAAgB,CAAC;AAExB,MAAM,QAAQ,GAAiB,YAAY,CAAC;IAC1C,EAAE,EAAE,2BAA2B;IAC/B,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,4DAA4D;IACzE,WAAW,EAAE,eAAe;IAC5B,gBAAgB,EAAE,EAAE;IACpB,eAAe,EAAE,IAAI;IACrB,mBAAmB,EAAE,wBAAwB;IAC7C,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;IACzB,YAAY,EAAE;QACZ,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,KAAK;KACnB;CACF,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;CACtC,CAAC,CAAC;AAKH,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,QAAQ,EAAE,QAAQ;QAClB,WAAW,EAAE,WAAW;QACxB,YAAY,EAAE,YAAY;QAC1B,GAAG,EAAE,EAAE;QACP,KAAK,EAAE,IAAI;QACX,KAAK,CAAC,OAAO,CAAC,KAAuB,EAAE,MAAyB;YAC9D,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC;YACzC,IAAI,CAAC;gBACH,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAoB,UAAU,EAAE;oBACvE,IAAI;oBACJ,OAAO;iBACR,CAAC,CAAC;gBACH,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;oBACtB,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;iBAC9B,CAAC;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;oBACxD,SAAS,EAAE,KAAK;oBAChB,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;iBAC9B,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agenteer/node-llm-call` — typed prompt + typed output via a model (sub-plan 03 §1).
|
|
3
|
+
*
|
|
4
|
+
* M2 scope: the structured-output wrapper with native-first / text-parse
|
|
5
|
+
* fallback lives in `@agenteer/trust/structured` (M3). Here we:
|
|
6
|
+
* - validate the input shape,
|
|
7
|
+
* - call `handle.callModel` which the runtime routes through the
|
|
8
|
+
* permission kernel + ModelProvider,
|
|
9
|
+
* - emit an Artifact ctx item with the validated value.
|
|
10
|
+
*
|
|
11
|
+
* Response schema is carried on `input.schema` as a Zod type. For
|
|
12
|
+
* third-party wire delivery (JSON-only), the M6 registry serializes
|
|
13
|
+
* schemas; that path is still future work.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import { type Node } from "@agenteer/core";
|
|
17
|
+
declare const InputSchema: z.ZodObject<{
|
|
18
|
+
model_id: z.ZodString;
|
|
19
|
+
prompt: z.ZodString;
|
|
20
|
+
system: z.ZodOptional<z.ZodString>;
|
|
21
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
emit_as: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
declare const OutputSchema: z.ZodObject<{
|
|
26
|
+
value: z.ZodUnknown;
|
|
27
|
+
model: z.ZodString;
|
|
28
|
+
tokens: z.ZodObject<{
|
|
29
|
+
prompt: z.ZodNumber;
|
|
30
|
+
completion: z.ZodNumber;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
method: z.ZodEnum<{
|
|
33
|
+
native: "native";
|
|
34
|
+
text_parse: "text_parse";
|
|
35
|
+
mock: "mock";
|
|
36
|
+
}>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
type Input = z.infer<typeof InputSchema>;
|
|
39
|
+
type Output = z.infer<typeof OutputSchema>;
|
|
40
|
+
/**
|
|
41
|
+
* Factory. Accepts an optional response schema — nodes authored on top of
|
|
42
|
+
* `llm_call` typically pass a concrete Zod here. When absent, the return
|
|
43
|
+
* value is passed through unchecked (the manifest's `output_schema` still
|
|
44
|
+
* enforces the outer wrapper shape).
|
|
45
|
+
*/
|
|
46
|
+
export declare function llmCallFactory(responseSchema?: z.ZodTypeAny): () => Node<Input, Output>;
|
|
47
|
+
export declare const llmCallManifest: {
|
|
48
|
+
manifest_version: 1;
|
|
49
|
+
id: string;
|
|
50
|
+
version: string;
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
required_actions: string[];
|
|
54
|
+
required_capabilities: {
|
|
55
|
+
tool_use: boolean;
|
|
56
|
+
vision: boolean;
|
|
57
|
+
structured_output: "any" | "native" | "text_parse";
|
|
58
|
+
min_context_tokens?: number | undefined;
|
|
59
|
+
};
|
|
60
|
+
dynamic_actions: boolean;
|
|
61
|
+
side_effects: {
|
|
62
|
+
writes_fs: boolean;
|
|
63
|
+
network: boolean;
|
|
64
|
+
mutates_ctx: boolean;
|
|
65
|
+
emits_ctx_variants: string[];
|
|
66
|
+
reads_ctx_variants: string[];
|
|
67
|
+
};
|
|
68
|
+
determinism: "deterministic" | "stochastic";
|
|
69
|
+
tags: string[];
|
|
70
|
+
author: string;
|
|
71
|
+
license: string;
|
|
72
|
+
input_schema?: unknown;
|
|
73
|
+
output_schema?: unknown;
|
|
74
|
+
dynamic_action_spec?: string | undefined;
|
|
75
|
+
homepage?: string | undefined;
|
|
76
|
+
repository?: string | undefined;
|
|
77
|
+
planner_hints?: {
|
|
78
|
+
cost_tier?: "cheap" | "medium" | "expensive" | undefined;
|
|
79
|
+
latency_tier?: "medium" | "fast" | "slow" | undefined;
|
|
80
|
+
typical_use?: string | undefined;
|
|
81
|
+
} | undefined;
|
|
82
|
+
sha256?: string | undefined;
|
|
83
|
+
};
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=llm_call.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm_call.d.ts","sourceRoot":"","sources":["../../src/primitives/llm_call.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,KAAK,IAAI,EAKV,MAAM,gBAAgB,CAAC;AAmBxB,QAAA,MAAM,WAAW;;;;;;;iBAQf,CAAC;AAEH,QAAA,MAAM,YAAY;;;;;;;;;;;;iBAKhB,CAAC;AAEH,KAAK,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACzC,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAE3C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,UAAU,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CA0CvF;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAW,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agenteer/node-llm-call` — typed prompt + typed output via a model (sub-plan 03 §1).
|
|
3
|
+
*
|
|
4
|
+
* M2 scope: the structured-output wrapper with native-first / text-parse
|
|
5
|
+
* fallback lives in `@agenteer/trust/structured` (M3). Here we:
|
|
6
|
+
* - validate the input shape,
|
|
7
|
+
* - call `handle.callModel` which the runtime routes through the
|
|
8
|
+
* permission kernel + ModelProvider,
|
|
9
|
+
* - emit an Artifact ctx item with the validated value.
|
|
10
|
+
*
|
|
11
|
+
* Response schema is carried on `input.schema` as a Zod type. For
|
|
12
|
+
* third-party wire delivery (JSON-only), the M6 registry serializes
|
|
13
|
+
* schemas; that path is still future work.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import { makeManifest, } from "@agenteer/core";
|
|
17
|
+
const MANIFEST = makeManifest({
|
|
18
|
+
id: "@agenteer/node-llm-call",
|
|
19
|
+
name: "llm_call",
|
|
20
|
+
description: "Call a configured model with a structured schema; return the validated value.",
|
|
21
|
+
determinism: "stochastic",
|
|
22
|
+
required_actions: [],
|
|
23
|
+
dynamic_actions: true,
|
|
24
|
+
dynamic_action_spec: "model:${input.model_id}",
|
|
25
|
+
tags: ["primitive", "llm"],
|
|
26
|
+
side_effects: {
|
|
27
|
+
writes_fs: false,
|
|
28
|
+
network: true,
|
|
29
|
+
mutates_ctx: true,
|
|
30
|
+
emits_ctx_variants: ["artifact.llm_call"],
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const InputSchema = z.object({
|
|
34
|
+
model_id: z.string().min(1),
|
|
35
|
+
prompt: z.string().min(1),
|
|
36
|
+
system: z.string().optional(),
|
|
37
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
38
|
+
max_tokens: z.number().int().min(1).optional(),
|
|
39
|
+
/** Tag under which the validated value is appended to context. */
|
|
40
|
+
emit_as: z.string().optional(),
|
|
41
|
+
});
|
|
42
|
+
const OutputSchema = z.object({
|
|
43
|
+
value: z.unknown(),
|
|
44
|
+
model: z.string(),
|
|
45
|
+
tokens: z.object({ prompt: z.number().int(), completion: z.number().int() }),
|
|
46
|
+
method: z.enum(["native", "text_parse", "mock"]),
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Factory. Accepts an optional response schema — nodes authored on top of
|
|
50
|
+
* `llm_call` typically pass a concrete Zod here. When absent, the return
|
|
51
|
+
* value is passed through unchecked (the manifest's `output_schema` still
|
|
52
|
+
* enforces the outer wrapper shape).
|
|
53
|
+
*/
|
|
54
|
+
export function llmCallFactory(responseSchema) {
|
|
55
|
+
return () => ({
|
|
56
|
+
manifest: MANIFEST,
|
|
57
|
+
inputSchema: InputSchema,
|
|
58
|
+
outputSchema: OutputSchema,
|
|
59
|
+
ctx: [],
|
|
60
|
+
model: null, // resolved dynamically via input.model_id
|
|
61
|
+
async execute(input, handle) {
|
|
62
|
+
const { model_id, prompt, system, temperature, max_tokens, emit_as } = input.original;
|
|
63
|
+
try {
|
|
64
|
+
const res = await handle.callModel({
|
|
65
|
+
model_id,
|
|
66
|
+
prompt,
|
|
67
|
+
...(system !== undefined ? { system } : {}),
|
|
68
|
+
...(temperature !== undefined ? { temperature } : {}),
|
|
69
|
+
...(max_tokens !== undefined ? { max_tokens } : {}),
|
|
70
|
+
...(responseSchema ? { schema: responseSchema } : {}),
|
|
71
|
+
});
|
|
72
|
+
const value = {
|
|
73
|
+
value: res.value,
|
|
74
|
+
model: res.model,
|
|
75
|
+
tokens: res.tokens,
|
|
76
|
+
method: res.method,
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
kind: "output",
|
|
80
|
+
value,
|
|
81
|
+
...(emit_as ? { ctx_patch: { set: { [emit_as]: res.value } } } : {}),
|
|
82
|
+
evidence: { verdict: "pass" },
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
87
|
+
const retryable = /timeout|rate.?limit|5\d\d/i.test(reason);
|
|
88
|
+
return {
|
|
89
|
+
kind: "failed",
|
|
90
|
+
reason,
|
|
91
|
+
retryable,
|
|
92
|
+
evidence: { verdict: "fail" },
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
export const llmCallManifest = MANIFEST;
|
|
99
|
+
//# sourceMappingURL=llm_call.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm_call.js","sourceRoot":"","sources":["../../src/primitives/llm_call.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,YAAY,GAMb,MAAM,gBAAgB,CAAC;AAExB,MAAM,QAAQ,GAAiB,YAAY,CAAC;IAC1C,EAAE,EAAE,yBAAyB;IAC7B,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,+EAA+E;IAC5F,WAAW,EAAE,YAAY;IACzB,gBAAgB,EAAE,EAAE;IACpB,eAAe,EAAE,IAAI;IACrB,mBAAmB,EAAE,yBAAyB;IAC9C,IAAI,EAAE,CAA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GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACpE,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;iBAC9B,CAAC;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChE,MAAM,SAAS,GAAG,4BAA4B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAC5D,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,MAAM;oBACN,SAAS;oBACT,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;iBAC9B,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agenteer/node-shell-exec` — permissioned subprocess (sub-plan 03 §5).
|
|
3
|
+
*
|
|
4
|
+
* `shell.exec` is intentionally coarse (sub-plan 02 §1.1.4). Dispatch
|
|
5
|
+
* checks capability + denylist on cwd; the runtime's §R1 snapshot wrap
|
|
6
|
+
* catches writes that escape the declared `fs.write` scope. Streaming
|
|
7
|
+
* stdout/stderr uses the shared capture utility so `compile` / `test_run`
|
|
8
|
+
* behave identically.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { type Node } from "@agenteer/core";
|
|
12
|
+
declare const InputSchema: z.ZodObject<{
|
|
13
|
+
command: z.ZodString;
|
|
14
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
15
|
+
timeout_ms: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
stdin: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
declare const OutputSchema: z.ZodObject<{
|
|
19
|
+
exit_code: z.ZodNumber;
|
|
20
|
+
stdout: z.ZodString;
|
|
21
|
+
stderr: z.ZodString;
|
|
22
|
+
duration_ms: z.ZodNumber;
|
|
23
|
+
timed_out: z.ZodBoolean;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
type Input = z.input<typeof InputSchema>;
|
|
26
|
+
type Output = z.infer<typeof OutputSchema>;
|
|
27
|
+
export declare function shellExecFactory(): Node<Input, Output>;
|
|
28
|
+
export declare const shellExecManifest: {
|
|
29
|
+
manifest_version: 1;
|
|
30
|
+
id: string;
|
|
31
|
+
version: string;
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
required_actions: string[];
|
|
35
|
+
required_capabilities: {
|
|
36
|
+
tool_use: boolean;
|
|
37
|
+
vision: boolean;
|
|
38
|
+
structured_output: "any" | "native" | "text_parse";
|
|
39
|
+
min_context_tokens?: number | undefined;
|
|
40
|
+
};
|
|
41
|
+
dynamic_actions: boolean;
|
|
42
|
+
side_effects: {
|
|
43
|
+
writes_fs: boolean;
|
|
44
|
+
network: boolean;
|
|
45
|
+
mutates_ctx: boolean;
|
|
46
|
+
emits_ctx_variants: string[];
|
|
47
|
+
reads_ctx_variants: string[];
|
|
48
|
+
};
|
|
49
|
+
determinism: "deterministic" | "stochastic";
|
|
50
|
+
tags: string[];
|
|
51
|
+
author: string;
|
|
52
|
+
license: string;
|
|
53
|
+
input_schema?: unknown;
|
|
54
|
+
output_schema?: unknown;
|
|
55
|
+
dynamic_action_spec?: string | undefined;
|
|
56
|
+
homepage?: string | undefined;
|
|
57
|
+
repository?: string | undefined;
|
|
58
|
+
planner_hints?: {
|
|
59
|
+
cost_tier?: "cheap" | "medium" | "expensive" | undefined;
|
|
60
|
+
latency_tier?: "medium" | "fast" | "slow" | undefined;
|
|
61
|
+
typical_use?: string | undefined;
|
|
62
|
+
} | undefined;
|
|
63
|
+
sha256?: string | undefined;
|
|
64
|
+
};
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=shell_exec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell_exec.d.ts","sourceRoot":"","sources":["../../src/primitives/shell_exec.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAIL,KAAK,IAAI,EAKV,MAAM,gBAAgB,CAAC;AAYxB,QAAA,MAAM,WAAW;;;;;iBAKf,CAAC;AAEH,QAAA,MAAM,YAAY;;;;;;iBAMhB,CAAC;AAEH,KAAK,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACzC,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAE3C,wBAAgB,gBAAgB,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAqEtD;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAW,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agenteer/node-shell-exec` — permissioned subprocess (sub-plan 03 §5).
|
|
3
|
+
*
|
|
4
|
+
* `shell.exec` is intentionally coarse (sub-plan 02 §1.1.4). Dispatch
|
|
5
|
+
* checks capability + denylist on cwd; the runtime's §R1 snapshot wrap
|
|
6
|
+
* catches writes that escape the declared `fs.write` scope. Streaming
|
|
7
|
+
* stdout/stderr uses the shared capture utility so `compile` / `test_run`
|
|
8
|
+
* behave identically.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { authorizeOperation, assertNotDenied, makeManifest, } from "@agenteer/core";
|
|
12
|
+
import { runCommand, tailOf } from "../shared/index.js";
|
|
13
|
+
const MANIFEST = makeManifest({
|
|
14
|
+
id: "@agenteer/node-shell-exec",
|
|
15
|
+
name: "shell_exec",
|
|
16
|
+
description: "Execute a shell command. Captures stdout/stderr/exit_code. Coarse-grained.",
|
|
17
|
+
determinism: "stochastic",
|
|
18
|
+
required_actions: ["shell.exec:"],
|
|
19
|
+
tags: ["primitive", "shell"],
|
|
20
|
+
});
|
|
21
|
+
const InputSchema = z.object({
|
|
22
|
+
command: z.string().min(1),
|
|
23
|
+
cwd: z.string().optional(),
|
|
24
|
+
timeout_ms: z.number().int().min(1).max(600_000).default(120_000),
|
|
25
|
+
stdin: z.string().optional(),
|
|
26
|
+
});
|
|
27
|
+
const OutputSchema = z.object({
|
|
28
|
+
exit_code: z.number().int(),
|
|
29
|
+
stdout: z.string(),
|
|
30
|
+
stderr: z.string(),
|
|
31
|
+
duration_ms: z.number().int().nonnegative(),
|
|
32
|
+
timed_out: z.boolean(),
|
|
33
|
+
});
|
|
34
|
+
export function shellExecFactory() {
|
|
35
|
+
return {
|
|
36
|
+
manifest: MANIFEST,
|
|
37
|
+
inputSchema: InputSchema,
|
|
38
|
+
outputSchema: OutputSchema,
|
|
39
|
+
ctx: [],
|
|
40
|
+
model: null,
|
|
41
|
+
async execute(input, handle) {
|
|
42
|
+
const { command, cwd, stdin } = input.original;
|
|
43
|
+
const timeout_ms = input.original.timeout_ms ?? 120_000;
|
|
44
|
+
try {
|
|
45
|
+
authorizeOperation(handle.granted, { kind: "shell.exec" });
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
return {
|
|
49
|
+
kind: "failed",
|
|
50
|
+
reason: `permission_denied: ${err instanceof Error ? err.message : String(err)}`,
|
|
51
|
+
retryable: false,
|
|
52
|
+
evidence: { verdict: "fail" },
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (cwd) {
|
|
56
|
+
try {
|
|
57
|
+
assertNotDenied(cwd);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
return {
|
|
61
|
+
kind: "failed",
|
|
62
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
63
|
+
retryable: false,
|
|
64
|
+
evidence: { verdict: "fail" },
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const r = await runCommand(command, {
|
|
70
|
+
...(cwd !== undefined ? { cwd } : {}),
|
|
71
|
+
...(stdin !== undefined ? { stdin } : {}),
|
|
72
|
+
timeout_ms,
|
|
73
|
+
signal: handle.signal,
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
kind: "output",
|
|
77
|
+
value: {
|
|
78
|
+
exit_code: r.exit_code,
|
|
79
|
+
stdout: r.stdout,
|
|
80
|
+
stderr: r.stderr,
|
|
81
|
+
duration_ms: r.duration_ms,
|
|
82
|
+
timed_out: r.timed_out,
|
|
83
|
+
},
|
|
84
|
+
evidence: {
|
|
85
|
+
verdict: r.exit_code === 0 && !r.timed_out ? "pass" : "fail",
|
|
86
|
+
tool_output: {
|
|
87
|
+
command,
|
|
88
|
+
exit_code: r.exit_code,
|
|
89
|
+
stdout_tail: tailOf(r.stdout),
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
return {
|
|
96
|
+
kind: "failed",
|
|
97
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
98
|
+
retryable: true,
|
|
99
|
+
evidence: { verdict: "fail" },
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export const shellExecManifest = MANIFEST;
|
|
106
|
+
//# sourceMappingURL=shell_exec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell_exec.js","sourceRoot":"","sources":["../../src/primitives/shell_exec.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,YAAY,GAMb,MAAM,gBAAgB,CAAC;AACxB,OAAO,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E,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACzC,UAAU;oBACV,MAAM,EAAE,MAAM,CAAC,MAAM;iBACtB,CAAC,CAAC;gBACH,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE;wBACL,SAAS,EAAE,CAAC,CAAC,SAAS;wBACtB,MAAM,EAAE,CAAC,CAAC,MAAM;wBAChB,MAAM,EAAE,CAAC,CAAC,MAAM;wBAChB,WAAW,EAAE,CAAC,CAAC,WAAW;wBAC1B,SAAS,EAAE,CAAC,CAAC,SAAS;qBACvB;oBACD,QAAQ,EAAE;wBACR,OAAO,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;wBAC5D,WAAW,EAAE;4BACX,OAAO;4BACP,SAAS,EAAE,CAAC,CAAC,SAAS;4BACtB,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;yBAC9B;qBACF;iBACF,CAAC;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;oBACxD,SAAS,EAAE,IAAI;oBACf,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;iBAC9B,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agenteer/node-tool-call` — primitive for invoking a registered tool
|
|
3
|
+
* (sub-plan 03 §2). §R4 honest dynamic-action disclosure:
|
|
4
|
+
* dynamic_actions: true
|
|
5
|
+
* dynamic_action_spec: "tool:${input.tool_name}"
|
|
6
|
+
*
|
|
7
|
+
* The permission kernel synthesizes `tool:<concrete_name>` at spawn time
|
|
8
|
+
* and checks against the parent's granted set. Tools themselves are
|
|
9
|
+
* adapters injected via `Runtime({ toolRegistry })`.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { type Node } from "@agenteer/core";
|
|
13
|
+
declare const InputSchema: z.ZodObject<{
|
|
14
|
+
tool_name: z.ZodString;
|
|
15
|
+
args: z.ZodUnknown;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
declare const OutputSchema: z.ZodObject<{
|
|
18
|
+
tool_name: z.ZodString;
|
|
19
|
+
value: z.ZodUnknown;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
type Input = z.input<typeof InputSchema>;
|
|
22
|
+
type Output = z.infer<typeof OutputSchema>;
|
|
23
|
+
export declare function toolCallFactory(): Node<Input, Output>;
|
|
24
|
+
export declare const toolCallManifest: {
|
|
25
|
+
manifest_version: 1;
|
|
26
|
+
id: string;
|
|
27
|
+
version: string;
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
required_actions: string[];
|
|
31
|
+
required_capabilities: {
|
|
32
|
+
tool_use: boolean;
|
|
33
|
+
vision: boolean;
|
|
34
|
+
structured_output: "any" | "native" | "text_parse";
|
|
35
|
+
min_context_tokens?: number | undefined;
|
|
36
|
+
};
|
|
37
|
+
dynamic_actions: boolean;
|
|
38
|
+
side_effects: {
|
|
39
|
+
writes_fs: boolean;
|
|
40
|
+
network: boolean;
|
|
41
|
+
mutates_ctx: boolean;
|
|
42
|
+
emits_ctx_variants: string[];
|
|
43
|
+
reads_ctx_variants: string[];
|
|
44
|
+
};
|
|
45
|
+
determinism: "deterministic" | "stochastic";
|
|
46
|
+
tags: string[];
|
|
47
|
+
author: string;
|
|
48
|
+
license: string;
|
|
49
|
+
input_schema?: unknown;
|
|
50
|
+
output_schema?: unknown;
|
|
51
|
+
dynamic_action_spec?: string | undefined;
|
|
52
|
+
homepage?: string | undefined;
|
|
53
|
+
repository?: string | undefined;
|
|
54
|
+
planner_hints?: {
|
|
55
|
+
cost_tier?: "cheap" | "medium" | "expensive" | undefined;
|
|
56
|
+
latency_tier?: "medium" | "fast" | "slow" | undefined;
|
|
57
|
+
typical_use?: string | undefined;
|
|
58
|
+
} | undefined;
|
|
59
|
+
sha256?: string | undefined;
|
|
60
|
+
};
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=tool_call.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool_call.d.ts","sourceRoot":"","sources":["../../src/primitives/tool_call.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,KAAK,IAAI,EAKV,MAAM,gBAAgB,CAAC;AAmBxB,QAAA,MAAM,WAAW;;;iBAGf,CAAC;AAEH,QAAA,MAAM,YAAY;;;iBAGhB,CAAC;AAEH,KAAK,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACzC,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAE3C,wBAAgB,eAAe,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CA8BrD;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAW,CAAC"}
|