@aigne/agent-runtime 1.12.0-beta.5
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/LICENSE.md +26 -0
- package/README.md +79 -0
- package/dist/agent-runners/ai-runner.cjs +133 -0
- package/dist/agent-runners/ai-runner.d.cts +33 -0
- package/dist/agent-runners/ai-runner.d.cts.map +1 -0
- package/dist/agent-runners/ai-runner.d.mts +33 -0
- package/dist/agent-runners/ai-runner.d.mts.map +1 -0
- package/dist/agent-runners/ai-runner.mjs +134 -0
- package/dist/agent-runners/ai-runner.mjs.map +1 -0
- package/dist/agent-runners/ash-runner.cjs +272 -0
- package/dist/agent-runners/ash-runner.d.cts +30 -0
- package/dist/agent-runners/ash-runner.d.cts.map +1 -0
- package/dist/agent-runners/ash-runner.d.mts +30 -0
- package/dist/agent-runners/ash-runner.d.mts.map +1 -0
- package/dist/agent-runners/ash-runner.mjs +273 -0
- package/dist/agent-runners/ash-runner.mjs.map +1 -0
- package/dist/agent-runners/budget.cjs +71 -0
- package/dist/agent-runners/budget.d.cts +40 -0
- package/dist/agent-runners/budget.d.cts.map +1 -0
- package/dist/agent-runners/budget.d.mts +40 -0
- package/dist/agent-runners/budget.d.mts.map +1 -0
- package/dist/agent-runners/budget.mjs +67 -0
- package/dist/agent-runners/budget.mjs.map +1 -0
- package/dist/agent-runners/code-runner.cjs +61 -0
- package/dist/agent-runners/code-runner.mjs +61 -0
- package/dist/agent-runners/code-runner.mjs.map +1 -0
- package/dist/agent-runners/env-whitelist.cjs +36 -0
- package/dist/agent-runners/env-whitelist.d.cts +5 -0
- package/dist/agent-runners/env-whitelist.d.cts.map +1 -0
- package/dist/agent-runners/env-whitelist.d.mts +5 -0
- package/dist/agent-runners/env-whitelist.d.mts.map +1 -0
- package/dist/agent-runners/env-whitelist.mjs +36 -0
- package/dist/agent-runners/env-whitelist.mjs.map +1 -0
- package/dist/agent-runners/guide-rails.cjs +47 -0
- package/dist/agent-runners/guide-rails.d.cts +16 -0
- package/dist/agent-runners/guide-rails.d.cts.map +1 -0
- package/dist/agent-runners/guide-rails.d.mts +16 -0
- package/dist/agent-runners/guide-rails.d.mts.map +1 -0
- package/dist/agent-runners/guide-rails.mjs +48 -0
- package/dist/agent-runners/guide-rails.mjs.map +1 -0
- package/dist/agent-runners/hook-channel.cjs +55 -0
- package/dist/agent-runners/hook-channel.d.cts +38 -0
- package/dist/agent-runners/hook-channel.d.cts.map +1 -0
- package/dist/agent-runners/hook-channel.d.mts +38 -0
- package/dist/agent-runners/hook-channel.d.mts.map +1 -0
- package/dist/agent-runners/hook-channel.mjs +55 -0
- package/dist/agent-runners/hook-channel.mjs.map +1 -0
- package/dist/agent-runners/hooks.cjs +107 -0
- package/dist/agent-runners/hooks.d.cts +41 -0
- package/dist/agent-runners/hooks.d.cts.map +1 -0
- package/dist/agent-runners/hooks.d.mts +41 -0
- package/dist/agent-runners/hooks.d.mts.map +1 -0
- package/dist/agent-runners/hooks.mjs +107 -0
- package/dist/agent-runners/hooks.mjs.map +1 -0
- package/dist/agent-runners/memory-afs.cjs +342 -0
- package/dist/agent-runners/memory-afs.d.cts +221 -0
- package/dist/agent-runners/memory-afs.d.cts.map +1 -0
- package/dist/agent-runners/memory-afs.d.mts +221 -0
- package/dist/agent-runners/memory-afs.d.mts.map +1 -0
- package/dist/agent-runners/memory-afs.mjs +326 -0
- package/dist/agent-runners/memory-afs.mjs.map +1 -0
- package/dist/agent-runners/memory-archive.cjs +263 -0
- package/dist/agent-runners/memory-archive.d.cts +47 -0
- package/dist/agent-runners/memory-archive.d.cts.map +1 -0
- package/dist/agent-runners/memory-archive.d.mts +47 -0
- package/dist/agent-runners/memory-archive.d.mts.map +1 -0
- package/dist/agent-runners/memory-archive.mjs +257 -0
- package/dist/agent-runners/memory-archive.mjs.map +1 -0
- package/dist/agent-runners/orchestrator-runner.cjs +302 -0
- package/dist/agent-runners/orchestrator-runner.d.cts +23 -0
- package/dist/agent-runners/orchestrator-runner.d.cts.map +1 -0
- package/dist/agent-runners/orchestrator-runner.d.mts +23 -0
- package/dist/agent-runners/orchestrator-runner.d.mts.map +1 -0
- package/dist/agent-runners/orchestrator-runner.mjs +303 -0
- package/dist/agent-runners/orchestrator-runner.mjs.map +1 -0
- package/dist/agent-runners/orchestrator-state.cjs +68 -0
- package/dist/agent-runners/orchestrator-state.d.cts +23 -0
- package/dist/agent-runners/orchestrator-state.d.cts.map +1 -0
- package/dist/agent-runners/orchestrator-state.d.mts +23 -0
- package/dist/agent-runners/orchestrator-state.d.mts.map +1 -0
- package/dist/agent-runners/orchestrator-state.mjs +65 -0
- package/dist/agent-runners/orchestrator-state.mjs.map +1 -0
- package/dist/agent-runners/retry.cjs +30 -0
- package/dist/agent-runners/retry.d.cts +13 -0
- package/dist/agent-runners/retry.d.cts.map +1 -0
- package/dist/agent-runners/retry.d.mts +13 -0
- package/dist/agent-runners/retry.d.mts.map +1 -0
- package/dist/agent-runners/retry.mjs +30 -0
- package/dist/agent-runners/retry.mjs.map +1 -0
- package/dist/agent-runners/scratchpad-afs.cjs +276 -0
- package/dist/agent-runners/scratchpad-afs.d.cts +103 -0
- package/dist/agent-runners/scratchpad-afs.d.cts.map +1 -0
- package/dist/agent-runners/scratchpad-afs.d.mts +103 -0
- package/dist/agent-runners/scratchpad-afs.d.mts.map +1 -0
- package/dist/agent-runners/scratchpad-afs.mjs +271 -0
- package/dist/agent-runners/scratchpad-afs.mjs.map +1 -0
- package/dist/agent-runners/stream-router.cjs +72 -0
- package/dist/agent-runners/stream-router.d.cts +22 -0
- package/dist/agent-runners/stream-router.d.cts.map +1 -0
- package/dist/agent-runners/stream-router.d.mts +22 -0
- package/dist/agent-runners/stream-router.d.mts.map +1 -0
- package/dist/agent-runners/stream-router.mjs +72 -0
- package/dist/agent-runners/stream-router.mjs.map +1 -0
- package/dist/agent-runners/system-prompt.cjs +35 -0
- package/dist/agent-runners/system-prompt.d.cts +17 -0
- package/dist/agent-runners/system-prompt.d.cts.map +1 -0
- package/dist/agent-runners/system-prompt.d.mts +17 -0
- package/dist/agent-runners/system-prompt.d.mts.map +1 -0
- package/dist/agent-runners/system-prompt.mjs +34 -0
- package/dist/agent-runners/system-prompt.mjs.map +1 -0
- package/dist/agent-runners/team-modes/aggregates.cjs +36 -0
- package/dist/agent-runners/team-modes/aggregates.mjs +35 -0
- package/dist/agent-runners/team-modes/aggregates.mjs.map +1 -0
- package/dist/agent-runners/team-modes/iterate.cjs +46 -0
- package/dist/agent-runners/team-modes/iterate.mjs +47 -0
- package/dist/agent-runners/team-modes/iterate.mjs.map +1 -0
- package/dist/agent-runners/team-modes/parallel.cjs +59 -0
- package/dist/agent-runners/team-modes/parallel.mjs +60 -0
- package/dist/agent-runners/team-modes/parallel.mjs.map +1 -0
- package/dist/agent-runners/team-modes/reflection.cjs +155 -0
- package/dist/agent-runners/team-modes/reflection.mjs +156 -0
- package/dist/agent-runners/team-modes/reflection.mjs.map +1 -0
- package/dist/agent-runners/team-modes/sequential.cjs +63 -0
- package/dist/agent-runners/team-modes/sequential.mjs +64 -0
- package/dist/agent-runners/team-modes/sequential.mjs.map +1 -0
- package/dist/agent-runners/team-modes/utils.cjs +39 -0
- package/dist/agent-runners/team-modes/utils.mjs +36 -0
- package/dist/agent-runners/team-modes/utils.mjs.map +1 -0
- package/dist/agent-runners/team-runner.cjs +277 -0
- package/dist/agent-runners/team-runner.d.cts +34 -0
- package/dist/agent-runners/team-runner.d.cts.map +1 -0
- package/dist/agent-runners/team-runner.d.mts +34 -0
- package/dist/agent-runners/team-runner.d.mts.map +1 -0
- package/dist/agent-runners/team-runner.mjs +278 -0
- package/dist/agent-runners/team-runner.mjs.map +1 -0
- package/dist/agent-runners/template-context.cjs +32 -0
- package/dist/agent-runners/template-context.d.cts +43 -0
- package/dist/agent-runners/template-context.d.cts.map +1 -0
- package/dist/agent-runners/template-context.d.mts +43 -0
- package/dist/agent-runners/template-context.d.mts.map +1 -0
- package/dist/agent-runners/template-context.mjs +33 -0
- package/dist/agent-runners/template-context.mjs.map +1 -0
- package/dist/index.cjs +123 -0
- package/dist/index.d.cts +29 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.mjs +29 -0
- package/dist/program/agent-action.cjs +496 -0
- package/dist/program/agent-action.d.cts +42 -0
- package/dist/program/agent-action.d.cts.map +1 -0
- package/dist/program/agent-action.d.mts +42 -0
- package/dist/program/agent-action.d.mts.map +1 -0
- package/dist/program/agent-action.mjs +497 -0
- package/dist/program/agent-action.mjs.map +1 -0
- package/dist/program/agent-messages-tools.cjs +137 -0
- package/dist/program/agent-messages-tools.d.cts +59 -0
- package/dist/program/agent-messages-tools.d.cts.map +1 -0
- package/dist/program/agent-messages-tools.d.mts +59 -0
- package/dist/program/agent-messages-tools.d.mts.map +1 -0
- package/dist/program/agent-messages-tools.mjs +130 -0
- package/dist/program/agent-messages-tools.mjs.map +1 -0
- package/dist/program/agent-runner-registry.cjs +314 -0
- package/dist/program/agent-runner-registry.d.cts +52 -0
- package/dist/program/agent-runner-registry.d.cts.map +1 -0
- package/dist/program/agent-runner-registry.d.mts +52 -0
- package/dist/program/agent-runner-registry.d.mts.map +1 -0
- package/dist/program/agent-runner-registry.mjs +313 -0
- package/dist/program/agent-runner-registry.mjs.map +1 -0
- package/dist/program/agent-subscribe.cjs +72 -0
- package/dist/program/agent-subscribe.d.cts +18 -0
- package/dist/program/agent-subscribe.d.cts.map +1 -0
- package/dist/program/agent-subscribe.d.mts +18 -0
- package/dist/program/agent-subscribe.d.mts.map +1 -0
- package/dist/program/agent-subscribe.mjs +73 -0
- package/dist/program/agent-subscribe.mjs.map +1 -0
- package/dist/program/agent-tools.cjs +135 -0
- package/dist/program/agent-tools.d.cts +35 -0
- package/dist/program/agent-tools.d.cts.map +1 -0
- package/dist/program/agent-tools.d.mts +35 -0
- package/dist/program/agent-tools.d.mts.map +1 -0
- package/dist/program/agent-tools.mjs +136 -0
- package/dist/program/agent-tools.mjs.map +1 -0
- package/dist/program/manifest-nesting.cjs +57 -0
- package/dist/program/manifest-nesting.d.cts +13 -0
- package/dist/program/manifest-nesting.d.cts.map +1 -0
- package/dist/program/manifest-nesting.d.mts +13 -0
- package/dist/program/manifest-nesting.d.mts.map +1 -0
- package/dist/program/manifest-nesting.mjs +57 -0
- package/dist/program/manifest-nesting.mjs.map +1 -0
- package/dist/program/result-contract.cjs +55 -0
- package/dist/program/result-contract.d.cts +23 -0
- package/dist/program/result-contract.d.cts.map +1 -0
- package/dist/program/result-contract.d.mts +23 -0
- package/dist/program/result-contract.d.mts.map +1 -0
- package/dist/program/result-contract.mjs +51 -0
- package/dist/program/result-contract.mjs.map +1 -0
- package/dist/program/runner-error.cjs +71 -0
- package/dist/program/runner-error.d.cts +25 -0
- package/dist/program/runner-error.d.cts.map +1 -0
- package/dist/program/runner-error.d.mts +25 -0
- package/dist/program/runner-error.d.mts.map +1 -0
- package/dist/program/runner-error.mjs +72 -0
- package/dist/program/runner-error.mjs.map +1 -0
- package/dist/program/scoped-afs.cjs +538 -0
- package/dist/program/scoped-afs.d.cts +245 -0
- package/dist/program/scoped-afs.d.cts.map +1 -0
- package/dist/program/scoped-afs.d.mts +245 -0
- package/dist/program/scoped-afs.d.mts.map +1 -0
- package/dist/program/scoped-afs.mjs +531 -0
- package/dist/program/scoped-afs.mjs.map +1 -0
- package/dist/program/session-hierarchy.cjs +1 -0
- package/dist/program/session-hierarchy.d.cts +2 -0
- package/dist/program/session-hierarchy.d.mts +2 -0
- package/dist/program/session-hierarchy.mjs +3 -0
- package/dist/program/tool-discovery/ash-frontmatter.cjs +83 -0
- package/dist/program/tool-discovery/ash-frontmatter.d.cts +21 -0
- package/dist/program/tool-discovery/ash-frontmatter.d.cts.map +1 -0
- package/dist/program/tool-discovery/ash-frontmatter.d.mts +21 -0
- package/dist/program/tool-discovery/ash-frontmatter.d.mts.map +1 -0
- package/dist/program/tool-discovery/ash-frontmatter.mjs +84 -0
- package/dist/program/tool-discovery/ash-frontmatter.mjs.map +1 -0
- package/dist/program/tool-discovery/dot-path-resolver.cjs +60 -0
- package/dist/program/tool-discovery/dot-path-resolver.mjs +61 -0
- package/dist/program/tool-discovery/dot-path-resolver.mjs.map +1 -0
- package/dist/program/tool-discovery/skill-gate.cjs +36 -0
- package/dist/program/tool-discovery/skill-gate.d.cts +10 -0
- package/dist/program/tool-discovery/skill-gate.d.cts.map +1 -0
- package/dist/program/tool-discovery/skill-gate.d.mts +10 -0
- package/dist/program/tool-discovery/skill-gate.d.mts.map +1 -0
- package/dist/program/tool-discovery/skill-gate.mjs +35 -0
- package/dist/program/tool-discovery/skill-gate.mjs.map +1 -0
- package/dist/providers/basic/ash/dist/index.cjs +1809 -0
- package/dist/providers/basic/ash/dist/index.mjs +1807 -0
- package/dist/providers/basic/ash/dist/index.mjs.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
const require_index = require('../providers/basic/ash/dist/index.cjs');
|
|
2
|
+
const require_dot_path_resolver = require('./tool-discovery/dot-path-resolver.cjs');
|
|
3
|
+
const require_guide_rails = require('../agent-runners/guide-rails.cjs');
|
|
4
|
+
const require_system_prompt = require('../agent-runners/system-prompt.cjs');
|
|
5
|
+
const require_retry = require('../agent-runners/retry.cjs');
|
|
6
|
+
const require_result_contract = require('./result-contract.cjs');
|
|
7
|
+
const require_runner_error = require('./runner-error.cjs');
|
|
8
|
+
const require_agent_runner_registry = require('./agent-runner-registry.cjs');
|
|
9
|
+
let ufo = require("ufo");
|
|
10
|
+
|
|
11
|
+
//#region src/program/agent-action.ts
|
|
12
|
+
const MAX_PAYLOAD_BYTES = 1024 * 1024;
|
|
13
|
+
const BLOCKED_FIELDS = new Set([
|
|
14
|
+
"_system_append",
|
|
15
|
+
"_budget_override",
|
|
16
|
+
"_model_override",
|
|
17
|
+
"_parent_session",
|
|
18
|
+
"_parent_budget_remaining",
|
|
19
|
+
"_chain"
|
|
20
|
+
]);
|
|
21
|
+
function buildInputSchema(inputKey, override) {
|
|
22
|
+
if (override && typeof override === "object") return override;
|
|
23
|
+
return {
|
|
24
|
+
type: "object",
|
|
25
|
+
properties: { [inputKey]: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: `Input for the agent (key: ${inputKey})`
|
|
28
|
+
} },
|
|
29
|
+
required: [inputKey]
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function sanitizeArgs(args) {
|
|
33
|
+
const sanitized = {};
|
|
34
|
+
for (const [key, value] of Object.entries(args)) if (!BLOCKED_FIELDS.has(key)) sanitized[key] = value;
|
|
35
|
+
return sanitized;
|
|
36
|
+
}
|
|
37
|
+
const SAFE_META_KEYS = new Set([
|
|
38
|
+
"run_id",
|
|
39
|
+
"rounds",
|
|
40
|
+
"tokens_used",
|
|
41
|
+
"sub_runs",
|
|
42
|
+
"scratch_path",
|
|
43
|
+
"mode",
|
|
44
|
+
"pipeline_steps",
|
|
45
|
+
"members_run",
|
|
46
|
+
"max_iterations_hit",
|
|
47
|
+
"warnings",
|
|
48
|
+
"session",
|
|
49
|
+
"parent_session",
|
|
50
|
+
"depth",
|
|
51
|
+
"chain",
|
|
52
|
+
"hook_events",
|
|
53
|
+
"hook_events_path",
|
|
54
|
+
"max_concurrency",
|
|
55
|
+
"member_run_ids",
|
|
56
|
+
"completed_steps",
|
|
57
|
+
"iterations",
|
|
58
|
+
"items_count",
|
|
59
|
+
"render",
|
|
60
|
+
"context"
|
|
61
|
+
]);
|
|
62
|
+
/**
|
|
63
|
+
* B9 — accept only the documented shape: { template_vars: string[] }.
|
|
64
|
+
* Anything else (primitives, arrays, foreign keys) is rejected so the
|
|
65
|
+
* envelope can't leak arbitrary runner internals through _meta.
|
|
66
|
+
*/
|
|
67
|
+
function sanitizeRenderMeta(raw) {
|
|
68
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
69
|
+
const vars = raw.template_vars;
|
|
70
|
+
if (!Array.isArray(vars)) return void 0;
|
|
71
|
+
return { template_vars: vars.filter((v) => typeof v === "string") };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* B9 — accept only the documented shape: { system: string }. Empty string is
|
|
75
|
+
* allowed (ai-runner sets it to "" when no system prompt is configured).
|
|
76
|
+
*/
|
|
77
|
+
function sanitizeContextMeta(raw) {
|
|
78
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
79
|
+
const sys = raw.system;
|
|
80
|
+
if (typeof sys !== "string") return void 0;
|
|
81
|
+
return { system: sys };
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* B24 — strip any leading path so a full session path like
|
|
85
|
+
* `/instance/.sessions/agent/deep-42` is recorded as `deep-42` in _meta.
|
|
86
|
+
* Callers (MCP, LLM tool results) receive only the opaque id.
|
|
87
|
+
*/
|
|
88
|
+
function sessionBasename(value) {
|
|
89
|
+
const trimmed = value.replace(/\/+$/, "");
|
|
90
|
+
const idx = trimmed.lastIndexOf("/");
|
|
91
|
+
return idx >= 0 ? trimmed.slice(idx + 1) : trimmed;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* B23 — coerce any runner-reported count into a non-negative finite integer.
|
|
95
|
+
*
|
|
96
|
+
* The result-contract promises `rounds`/`tokens_used`/`sub_runs` are always
|
|
97
|
+
* numbers. Runners have historically leaked strings (`"5"`), NaN, Infinity,
|
|
98
|
+
* and negative values. Silent passthrough breaks downstream consumers that
|
|
99
|
+
* e.g. render `_meta.tokens_used.toLocaleString()`.
|
|
100
|
+
*/
|
|
101
|
+
function coerceCount(raw) {
|
|
102
|
+
const n = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw) : NaN;
|
|
103
|
+
if (!Number.isFinite(n)) return 0;
|
|
104
|
+
return Math.max(0, Math.floor(n));
|
|
105
|
+
}
|
|
106
|
+
function shapeOutput(runnerOutput, options) {
|
|
107
|
+
if (!runnerOutput || typeof runnerOutput !== "object") {
|
|
108
|
+
const baseMeta = {
|
|
109
|
+
run_id: crypto.randomUUID(),
|
|
110
|
+
rounds: 0,
|
|
111
|
+
tokens_used: 0,
|
|
112
|
+
sub_runs: 0
|
|
113
|
+
};
|
|
114
|
+
const ctx0 = options?.context;
|
|
115
|
+
if (ctx0) {
|
|
116
|
+
if (typeof ctx0.session === "string" && ctx0.session.length > 0) baseMeta.session = sessionBasename(ctx0.session);
|
|
117
|
+
if (Array.isArray(ctx0.chain)) {
|
|
118
|
+
const cleaned = ctx0.chain.filter((s) => typeof s === "string" && s.length > 0);
|
|
119
|
+
if (cleaned.length > 0) baseMeta.chain = cleaned;
|
|
120
|
+
baseMeta.depth = cleaned.length;
|
|
121
|
+
} else if (ctx0.session !== void 0) baseMeta.depth = 0;
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
result: runnerOutput ?? null,
|
|
125
|
+
_meta: baseMeta
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const out = runnerOutput;
|
|
129
|
+
const warnings = [];
|
|
130
|
+
const runnerMeta = out._meta && typeof out._meta === "object" ? out._meta : {};
|
|
131
|
+
const data = out.data && typeof out.data === "object" ? out.data : {};
|
|
132
|
+
const hasStructuredShape = "data" in out || "result" in out || "_meta" in out || "success" in out || "error" in out;
|
|
133
|
+
const isFailureEnvelope = out.success === false;
|
|
134
|
+
let resultValue;
|
|
135
|
+
if (isFailureEnvelope) resultValue = data.result !== void 0 ? data.result : null;
|
|
136
|
+
else if (!hasStructuredShape) resultValue = runnerOutput;
|
|
137
|
+
else if (out.result !== void 0) resultValue = out.result;
|
|
138
|
+
else if (data.result !== void 0) resultValue = data.result;
|
|
139
|
+
else if (out.data !== void 0 && out.data !== null && typeof out.data === "object") {
|
|
140
|
+
const { _meta: _dataMeta, ...rest } = data;
|
|
141
|
+
resultValue = Object.keys(rest).length > 0 ? rest : null;
|
|
142
|
+
} else if (out.data !== void 0) resultValue = out.data;
|
|
143
|
+
else resultValue = null;
|
|
144
|
+
const resultIsEmpty = resultValue === void 0 || resultValue === null || typeof resultValue === "object" && Object.keys(resultValue).length === 0;
|
|
145
|
+
if (options?.outputKey && resultIsEmpty) {
|
|
146
|
+
warnings.push({
|
|
147
|
+
code: "OUTPUT_KEY_MISSING",
|
|
148
|
+
message: `Expected output key "${options.outputKey}" but runner returned no result`
|
|
149
|
+
});
|
|
150
|
+
resultValue = null;
|
|
151
|
+
}
|
|
152
|
+
if (resultValue != null && !require_result_contract.isJsonSafe(resultValue)) {
|
|
153
|
+
warnings.push({
|
|
154
|
+
code: "RESULT_NOT_JSON_SAFE",
|
|
155
|
+
message: "Result contains circular references or non-serializable values"
|
|
156
|
+
});
|
|
157
|
+
resultValue = null;
|
|
158
|
+
}
|
|
159
|
+
const runIdRaw = runnerMeta.run_id ?? data.run_id;
|
|
160
|
+
const meta = {
|
|
161
|
+
run_id: typeof runIdRaw === "string" && runIdRaw.length > 0 ? runIdRaw : crypto.randomUUID(),
|
|
162
|
+
rounds: coerceCount(runnerMeta.rounds ?? runnerMeta.iterations ?? data.rounds),
|
|
163
|
+
tokens_used: coerceCount(runnerMeta.tokens_used ?? data.total_tokens),
|
|
164
|
+
sub_runs: coerceCount(runnerMeta.sub_runs ?? data.sub_runs)
|
|
165
|
+
};
|
|
166
|
+
const rawScratch = runnerMeta.scratch_path ?? data.scratch_path;
|
|
167
|
+
if (typeof rawScratch === "string") meta.scratch_path = require_result_contract.sanitizeScratchPath(rawScratch);
|
|
168
|
+
for (const key of Object.keys(runnerMeta)) if (SAFE_META_KEYS.has(key) && !(key in meta)) if (key === "render") {
|
|
169
|
+
const cleaned = sanitizeRenderMeta(runnerMeta[key]);
|
|
170
|
+
if (cleaned) meta[key] = cleaned;
|
|
171
|
+
} else if (key === "context") {
|
|
172
|
+
const cleaned = sanitizeContextMeta(runnerMeta[key]);
|
|
173
|
+
if (cleaned) meta[key] = cleaned;
|
|
174
|
+
} else meta[key] = runnerMeta[key];
|
|
175
|
+
const ctx = options?.context;
|
|
176
|
+
if (ctx) {
|
|
177
|
+
if (typeof ctx.session === "string" && ctx.session.length > 0) meta.session = sessionBasename(ctx.session);
|
|
178
|
+
if (Array.isArray(ctx.chain)) {
|
|
179
|
+
const cleaned = ctx.chain.filter((s) => typeof s === "string" && s.length > 0);
|
|
180
|
+
if (cleaned.length > 0) meta.chain = cleaned;
|
|
181
|
+
meta.depth = cleaned.length;
|
|
182
|
+
} else if (ctx.session !== void 0) meta.depth = 0;
|
|
183
|
+
}
|
|
184
|
+
if (runnerMeta.env && typeof runnerMeta.env === "object") meta.env = require_result_contract.sanitizeMetaEnv(runnerMeta.env);
|
|
185
|
+
if (warnings.length > 0) meta.warnings = warnings;
|
|
186
|
+
return {
|
|
187
|
+
result: resultValue,
|
|
188
|
+
_meta: meta
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function estimatePayloadSize(args) {
|
|
192
|
+
let size = 0;
|
|
193
|
+
for (const value of Object.values(args)) if (typeof value === "string") size += value.length;
|
|
194
|
+
else if (value instanceof Uint8Array) size += value.length;
|
|
195
|
+
else if (typeof value === "function" || typeof value === "symbol") {} else if (value !== null && value !== void 0) try {
|
|
196
|
+
const serialized = JSON.stringify(value);
|
|
197
|
+
if (typeof serialized === "string") size += serialized.length;
|
|
198
|
+
} catch {}
|
|
199
|
+
return size;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* B29 — Compile a statically-known tool catalog from `manifest.tools` so
|
|
203
|
+
* `/.actions/run/.meta` can surface the LLM's tool surface without having to
|
|
204
|
+
* invoke the agent.
|
|
205
|
+
*
|
|
206
|
+
* This is the dot-path resolver pass only — `.ash` frontmatter discovery and
|
|
207
|
+
* skill-gated helpers require AFS I/O and happen later inside the runner. The
|
|
208
|
+
* catalog returned here covers:
|
|
209
|
+
* - resolved bare-path declarations (`./knowledge/` → `<root>/knowledge/**`)
|
|
210
|
+
* - object-form declarations (passed through verbatim)
|
|
211
|
+
* - built-in `.actions/cancel` and `.actions/status` (auto-registered for
|
|
212
|
+
* every agent blocklet, so they must always appear)
|
|
213
|
+
*
|
|
214
|
+
* Invalid declarations (absolute paths, null bytes, …) surface as structured
|
|
215
|
+
* warnings instead of silently dropping — one bad tool must not poison the
|
|
216
|
+
* rest (mirrors the S13 "data loss prevention" contract).
|
|
217
|
+
*/
|
|
218
|
+
function compileStaticToolCatalog(manifest, mountPath, actionPrefix) {
|
|
219
|
+
const catalog = [];
|
|
220
|
+
const warnings = [];
|
|
221
|
+
const tools = manifest.tools ?? [];
|
|
222
|
+
for (const raw of tools) if (typeof raw === "string") try {
|
|
223
|
+
const [resolved] = require_dot_path_resolver.resolveDotPaths([raw], mountPath);
|
|
224
|
+
if (resolved) catalog.push(resolved);
|
|
225
|
+
} catch (err) {
|
|
226
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
227
|
+
const code = msg.startsWith("TOOL_PATH_OUTSIDE_BLOCKLET") ? "TOOL_PATH_OUTSIDE_BLOCKLET" : "TOOL_PATH_INVALID";
|
|
228
|
+
warnings.push({
|
|
229
|
+
code,
|
|
230
|
+
path: raw,
|
|
231
|
+
message: msg
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
else if (raw && typeof raw === "object") {
|
|
235
|
+
const entry = raw;
|
|
236
|
+
if (typeof entry.path !== "string" || entry.path.length === 0) {
|
|
237
|
+
warnings.push({
|
|
238
|
+
code: "TOOL_PATH_INVALID",
|
|
239
|
+
message: "object tool entry missing 'path' field"
|
|
240
|
+
});
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
catalog.push({
|
|
244
|
+
path: entry.path,
|
|
245
|
+
ops: require_index.withQueryPairing(entry.ops ?? [
|
|
246
|
+
"read",
|
|
247
|
+
"list",
|
|
248
|
+
"search"
|
|
249
|
+
]),
|
|
250
|
+
...entry.maxDepth != null ? { maxDepth: entry.maxDepth } : {}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
const cancelName = actionPrefix ? `${actionPrefix}-cancel` : "cancel";
|
|
254
|
+
const statusName = actionPrefix ? `${actionPrefix}-status` : "status";
|
|
255
|
+
catalog.push({
|
|
256
|
+
path: (0, ufo.joinURL)(mountPath, `.actions/${cancelName}`),
|
|
257
|
+
ops: ["exec"]
|
|
258
|
+
});
|
|
259
|
+
catalog.push({
|
|
260
|
+
path: (0, ufo.joinURL)(mountPath, `.actions/${statusName}`),
|
|
261
|
+
ops: ["exec"]
|
|
262
|
+
});
|
|
263
|
+
return {
|
|
264
|
+
catalog,
|
|
265
|
+
warnings
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function createAgentActionHandlers(manifest, _mountPath, options) {
|
|
269
|
+
const inputKey = manifest.inputKey ?? "message";
|
|
270
|
+
const inputSchema = buildInputSchema(inputKey, manifest.inputSchema);
|
|
271
|
+
const actionPrefix = options?.actionPrefix;
|
|
272
|
+
const runName = actionPrefix ? `${actionPrefix}-run` : "run";
|
|
273
|
+
const cancelName = actionPrefix ? `${actionPrefix}-cancel` : "cancel";
|
|
274
|
+
const statusName = actionPrefix ? `${actionPrefix}-status` : "status";
|
|
275
|
+
const { catalog: toolCatalog, warnings: catalogWarnings } = compileStaticToolCatalog(manifest, _mountPath, actionPrefix);
|
|
276
|
+
const runEntry = {
|
|
277
|
+
id: runName,
|
|
278
|
+
path: `/.actions/${runName}`,
|
|
279
|
+
summary: `Run agent "${manifest.name}"`,
|
|
280
|
+
meta: {
|
|
281
|
+
kind: "afs:executable",
|
|
282
|
+
kinds: ["afs:executable", "afs:node"],
|
|
283
|
+
effect: "write",
|
|
284
|
+
tool_catalog: toolCatalog,
|
|
285
|
+
...catalogWarnings.length > 0 ? { warnings: catalogWarnings } : {}
|
|
286
|
+
},
|
|
287
|
+
actions: [{
|
|
288
|
+
name: runName,
|
|
289
|
+
description: `Execute the "${manifest.name}" agent with the given input`,
|
|
290
|
+
inputSchema,
|
|
291
|
+
effect: "write"
|
|
292
|
+
}]
|
|
293
|
+
};
|
|
294
|
+
const cancelEntry = {
|
|
295
|
+
id: cancelName,
|
|
296
|
+
path: `/.actions/${cancelName}`,
|
|
297
|
+
summary: `Cancel a running agent session for "${manifest.name}"`,
|
|
298
|
+
meta: {
|
|
299
|
+
kind: "afs:executable",
|
|
300
|
+
kinds: ["afs:executable", "afs:node"],
|
|
301
|
+
effect: "write"
|
|
302
|
+
},
|
|
303
|
+
actions: [{
|
|
304
|
+
name: cancelName,
|
|
305
|
+
effect: "write",
|
|
306
|
+
description: `Cancel the "${manifest.name}" agent run for a given session`,
|
|
307
|
+
inputSchema: {
|
|
308
|
+
type: "object",
|
|
309
|
+
properties: { session: {
|
|
310
|
+
type: "string",
|
|
311
|
+
description: "Session ID to cancel"
|
|
312
|
+
} },
|
|
313
|
+
required: ["session"]
|
|
314
|
+
}
|
|
315
|
+
}]
|
|
316
|
+
};
|
|
317
|
+
const statusEntry = {
|
|
318
|
+
id: statusName,
|
|
319
|
+
path: `/.actions/${statusName}`,
|
|
320
|
+
summary: `Get agent run status for "${manifest.name}"`,
|
|
321
|
+
meta: {
|
|
322
|
+
kind: "afs:executable",
|
|
323
|
+
kinds: ["afs:executable", "afs:node"],
|
|
324
|
+
effect: "read"
|
|
325
|
+
},
|
|
326
|
+
actions: [{
|
|
327
|
+
name: statusName,
|
|
328
|
+
effect: "read",
|
|
329
|
+
description: `Get the current status of a "${manifest.name}" agent run`,
|
|
330
|
+
inputSchema: {
|
|
331
|
+
type: "object",
|
|
332
|
+
properties: { session: {
|
|
333
|
+
type: "string",
|
|
334
|
+
description: "Session ID to check"
|
|
335
|
+
} }
|
|
336
|
+
}
|
|
337
|
+
}]
|
|
338
|
+
};
|
|
339
|
+
return {
|
|
340
|
+
run: {
|
|
341
|
+
entry: runEntry,
|
|
342
|
+
inputSchema,
|
|
343
|
+
handler: async (args, context) => {
|
|
344
|
+
const sanitized = sanitizeArgs(args);
|
|
345
|
+
if (estimatePayloadSize(sanitized) > MAX_PAYLOAD_BYTES) return {
|
|
346
|
+
success: false,
|
|
347
|
+
error: {
|
|
348
|
+
code: "PAYLOAD_TOO_LARGE",
|
|
349
|
+
message: "Input payload exceeds 1 MB limit"
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
const inputValue = sanitized[inputKey];
|
|
353
|
+
if (inputValue === void 0 || inputValue === null) return {
|
|
354
|
+
success: false,
|
|
355
|
+
error: {
|
|
356
|
+
code: "INPUT_SCHEMA_INVALID",
|
|
357
|
+
message: `Missing required field: ${inputKey}`,
|
|
358
|
+
details: { field: inputKey }
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
const expectedType = (inputSchema?.properties)?.[inputKey]?.type;
|
|
362
|
+
if ((expectedType === void 0 || expectedType === "string") && typeof inputValue !== "string") return {
|
|
363
|
+
success: false,
|
|
364
|
+
error: {
|
|
365
|
+
code: "INPUT_SCHEMA_INVALID",
|
|
366
|
+
message: `Field "${inputKey}" must be a string, got ${typeof inputValue}`,
|
|
367
|
+
details: { field: inputKey }
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
if (!context) return {
|
|
371
|
+
success: false,
|
|
372
|
+
error: {
|
|
373
|
+
code: "INTERNAL_ERROR",
|
|
374
|
+
message: "No runner context provided"
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
try {
|
|
378
|
+
const runner = require_agent_runner_registry.getRunnerForType(manifest.type);
|
|
379
|
+
const systemAppend = require_system_prompt.sanitizeSystemAppend(args._system_append);
|
|
380
|
+
const enrichedContext = {
|
|
381
|
+
...context,
|
|
382
|
+
session: typeof args.session === "string" ? args.session : context.session,
|
|
383
|
+
parentSession: args._parent_session ?? void 0,
|
|
384
|
+
chain: Array.isArray(args._chain) ? args._chain : void 0,
|
|
385
|
+
systemAppend
|
|
386
|
+
};
|
|
387
|
+
const result = await require_retry.withRetry(() => runner(sanitized, enrichedContext), manifest.retry, (r) => r?.success === false);
|
|
388
|
+
let effectiveResult = result;
|
|
389
|
+
if (result?.success !== false && manifest.guideRails && manifest.guideRails.length > 0) {
|
|
390
|
+
const decision = await require_guide_rails.runGuideRails(enrichedContext.afs, manifest.guideRails, sanitized, result?.data ?? result, { mountPath: enrichedContext.mountPath });
|
|
391
|
+
if (decision.abort) {
|
|
392
|
+
const shapedAbort = shapeOutput(null, {
|
|
393
|
+
outputKey: manifest.outputKey,
|
|
394
|
+
context: {
|
|
395
|
+
session: enrichedContext.session,
|
|
396
|
+
chain: enrichedContext.chain
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
return {
|
|
400
|
+
success: false,
|
|
401
|
+
error: {
|
|
402
|
+
code: "GUIDE_RAIL_ABORT",
|
|
403
|
+
message: decision.reason ?? "GuideRail aborted"
|
|
404
|
+
},
|
|
405
|
+
data: shapedAbort
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
if (decision.output !== void 0) effectiveResult = {
|
|
409
|
+
...result,
|
|
410
|
+
data: decision.output
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
const shaped = shapeOutput(effectiveResult, {
|
|
414
|
+
outputKey: manifest.outputKey,
|
|
415
|
+
context: {
|
|
416
|
+
session: enrichedContext.session,
|
|
417
|
+
chain: enrichedContext.chain
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
if (result?.success === false) return {
|
|
421
|
+
success: false,
|
|
422
|
+
error: require_runner_error.normalizeRunnerError(result?.error ?? {
|
|
423
|
+
code: "RUNNER_FAILED",
|
|
424
|
+
message: "Runner reported failure"
|
|
425
|
+
}),
|
|
426
|
+
data: shaped
|
|
427
|
+
};
|
|
428
|
+
return {
|
|
429
|
+
success: true,
|
|
430
|
+
data: shaped
|
|
431
|
+
};
|
|
432
|
+
} catch (err) {
|
|
433
|
+
const sessionFromArgs = typeof args.session === "string" ? args.session : context.session;
|
|
434
|
+
const chainFromArgs = Array.isArray(args._chain) ? args._chain : void 0;
|
|
435
|
+
const shapedOnError = shapeOutput(null, {
|
|
436
|
+
outputKey: manifest.outputKey,
|
|
437
|
+
context: {
|
|
438
|
+
session: sessionFromArgs,
|
|
439
|
+
chain: chainFromArgs
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
return {
|
|
443
|
+
success: false,
|
|
444
|
+
error: require_runner_error.normalizeRunnerError(err),
|
|
445
|
+
data: shapedOnError
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
sanitizeArgs,
|
|
450
|
+
shapeOutput
|
|
451
|
+
},
|
|
452
|
+
cancel: {
|
|
453
|
+
entry: cancelEntry,
|
|
454
|
+
inputSchema: cancelEntry.actions[0].inputSchema,
|
|
455
|
+
handler: async (args) => {
|
|
456
|
+
const session = args.session;
|
|
457
|
+
if (session) return {
|
|
458
|
+
success: false,
|
|
459
|
+
error: {
|
|
460
|
+
code: "SESSION_NOT_FOUND",
|
|
461
|
+
message: `Session "${session}" not found`
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
return {
|
|
465
|
+
success: true,
|
|
466
|
+
data: { cancelled: true }
|
|
467
|
+
};
|
|
468
|
+
},
|
|
469
|
+
sanitizeArgs,
|
|
470
|
+
shapeOutput
|
|
471
|
+
},
|
|
472
|
+
status: {
|
|
473
|
+
entry: statusEntry,
|
|
474
|
+
inputSchema: statusEntry.actions[0].inputSchema,
|
|
475
|
+
handler: async (args) => {
|
|
476
|
+
const session = args.session;
|
|
477
|
+
if (session) return {
|
|
478
|
+
success: false,
|
|
479
|
+
error: {
|
|
480
|
+
code: "SESSION_NOT_FOUND",
|
|
481
|
+
message: `Session "${session}" not found`
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
return {
|
|
485
|
+
success: true,
|
|
486
|
+
data: { state: "unknown" }
|
|
487
|
+
};
|
|
488
|
+
},
|
|
489
|
+
sanitizeArgs,
|
|
490
|
+
shapeOutput
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
//#endregion
|
|
496
|
+
exports.createAgentActionHandlers = createAgentActionHandlers;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RunnerContext } from "./agent-runner-registry.cjs";
|
|
2
|
+
import { AFSEntry, AFSExecResult, AgentManifest } from "@aigne/afs";
|
|
3
|
+
|
|
4
|
+
//#region src/program/agent-action.d.ts
|
|
5
|
+
interface AgentActionHandler {
|
|
6
|
+
entry: AFSEntry;
|
|
7
|
+
inputSchema: Record<string, unknown>;
|
|
8
|
+
handler: (args: Record<string, unknown>, context?: RunnerContext) => Promise<AFSExecResult>;
|
|
9
|
+
sanitizeArgs: (args: Record<string, unknown>) => Record<string, unknown>;
|
|
10
|
+
shapeOutput: (runnerOutput: unknown, options?: {
|
|
11
|
+
outputKey?: string;
|
|
12
|
+
context?: {
|
|
13
|
+
session?: string;
|
|
14
|
+
chain?: string[];
|
|
15
|
+
};
|
|
16
|
+
}) => {
|
|
17
|
+
result: any;
|
|
18
|
+
_meta: Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface AgentActionHandlers {
|
|
22
|
+
run: AgentActionHandler;
|
|
23
|
+
cancel: AgentActionHandler;
|
|
24
|
+
status: AgentActionHandler;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for `createAgentActionHandlers`.
|
|
28
|
+
*
|
|
29
|
+
* `actionPrefix` is used by the blocklet manager when registering nested
|
|
30
|
+
* agents under a single blocklet's runtime AFS. Without a prefix, every
|
|
31
|
+
* blocklet would collide on the unqualified `run`/`cancel`/`status` keys
|
|
32
|
+
* after the second nested manifest. With `actionPrefix: "s1"`, the
|
|
33
|
+
* registered names become `s1-run`/`s1-cancel`/`s1-status`, and any
|
|
34
|
+
* catalog references the LLM sees rewrite to match.
|
|
35
|
+
*/
|
|
36
|
+
interface CreateAgentActionHandlersOptions {
|
|
37
|
+
actionPrefix?: string;
|
|
38
|
+
}
|
|
39
|
+
declare function createAgentActionHandlers(manifest: AgentManifest, _mountPath: string, options?: CreateAgentActionHandlersOptions): AgentActionHandlers;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { AgentActionHandler, AgentActionHandlers, createAgentActionHandlers };
|
|
42
|
+
//# sourceMappingURL=agent-action.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-action.d.cts","names":[],"sources":["../../src/program/agent-action.ts"],"mappings":";;;;UA6BiB,kBAAA;EACf,KAAA,EAAO,QAAA;EACP,WAAA,EAAa,MAAA;EACb,OAAA,GAAU,IAAA,EAAM,MAAA,mBAAyB,OAAA,GAAU,aAAA,KAAkB,OAAA,CAAQ,aAAA;EAC7E,YAAA,GAAe,IAAA,EAAM,MAAA,sBAA4B,MAAA;EACjD,WAAA,GACE,YAAA,WACA,OAAA;IACE,SAAA;IACA,OAAA;MAAY,OAAA;MAAkB,KAAA;IAAA;EAAA;IAE3B,MAAA;IAAa,KAAA,EAAO,MAAA;EAAA;AAAA;AAAA,UAGZ,mBAAA;EACf,GAAA,EAAK,kBAAA;EACL,MAAA,EAAQ,kBAAA;EACR,MAAA,EAAQ,kBAAA;AAAA;;;;;;;;;;;UA+WO,gCAAA;EACf,YAAA;AAAA;AAAA,iBAGc,yBAAA,CACd,QAAA,EAAU,aAAA,EACV,UAAA,UACA,OAAA,GAAU,gCAAA,GACT,mBAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RunnerContext } from "./agent-runner-registry.mjs";
|
|
2
|
+
import { AFSEntry, AFSExecResult, AgentManifest } from "@aigne/afs";
|
|
3
|
+
|
|
4
|
+
//#region src/program/agent-action.d.ts
|
|
5
|
+
interface AgentActionHandler {
|
|
6
|
+
entry: AFSEntry;
|
|
7
|
+
inputSchema: Record<string, unknown>;
|
|
8
|
+
handler: (args: Record<string, unknown>, context?: RunnerContext) => Promise<AFSExecResult>;
|
|
9
|
+
sanitizeArgs: (args: Record<string, unknown>) => Record<string, unknown>;
|
|
10
|
+
shapeOutput: (runnerOutput: unknown, options?: {
|
|
11
|
+
outputKey?: string;
|
|
12
|
+
context?: {
|
|
13
|
+
session?: string;
|
|
14
|
+
chain?: string[];
|
|
15
|
+
};
|
|
16
|
+
}) => {
|
|
17
|
+
result: any;
|
|
18
|
+
_meta: Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface AgentActionHandlers {
|
|
22
|
+
run: AgentActionHandler;
|
|
23
|
+
cancel: AgentActionHandler;
|
|
24
|
+
status: AgentActionHandler;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for `createAgentActionHandlers`.
|
|
28
|
+
*
|
|
29
|
+
* `actionPrefix` is used by the blocklet manager when registering nested
|
|
30
|
+
* agents under a single blocklet's runtime AFS. Without a prefix, every
|
|
31
|
+
* blocklet would collide on the unqualified `run`/`cancel`/`status` keys
|
|
32
|
+
* after the second nested manifest. With `actionPrefix: "s1"`, the
|
|
33
|
+
* registered names become `s1-run`/`s1-cancel`/`s1-status`, and any
|
|
34
|
+
* catalog references the LLM sees rewrite to match.
|
|
35
|
+
*/
|
|
36
|
+
interface CreateAgentActionHandlersOptions {
|
|
37
|
+
actionPrefix?: string;
|
|
38
|
+
}
|
|
39
|
+
declare function createAgentActionHandlers(manifest: AgentManifest, _mountPath: string, options?: CreateAgentActionHandlersOptions): AgentActionHandlers;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { AgentActionHandler, AgentActionHandlers, createAgentActionHandlers };
|
|
42
|
+
//# sourceMappingURL=agent-action.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-action.d.mts","names":[],"sources":["../../src/program/agent-action.ts"],"mappings":";;;;UA6BiB,kBAAA;EACf,KAAA,EAAO,QAAA;EACP,WAAA,EAAa,MAAA;EACb,OAAA,GAAU,IAAA,EAAM,MAAA,mBAAyB,OAAA,GAAU,aAAA,KAAkB,OAAA,CAAQ,aAAA;EAC7E,YAAA,GAAe,IAAA,EAAM,MAAA,sBAA4B,MAAA;EACjD,WAAA,GACE,YAAA,WACA,OAAA;IACE,SAAA;IACA,OAAA;MAAY,OAAA;MAAkB,KAAA;IAAA;EAAA;IAE3B,MAAA;IAAa,KAAA,EAAO,MAAA;EAAA;AAAA;AAAA,UAGZ,mBAAA;EACf,GAAA,EAAK,kBAAA;EACL,MAAA,EAAQ,kBAAA;EACR,MAAA,EAAQ,kBAAA;AAAA;;;;;;;;;;;UA+WO,gCAAA;EACf,YAAA;AAAA;AAAA,iBAGc,yBAAA,CACd,QAAA,EAAU,aAAA,EACV,UAAA,UACA,OAAA,GAAU,gCAAA,GACT,mBAAA"}
|