@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,245 @@
|
|
|
1
|
+
import { BudgetConfig } from "../agent-runners/budget.cjs";
|
|
2
|
+
import { ScratchProvider, ScratchRetention } from "../agent-runners/scratchpad-afs.cjs";
|
|
3
|
+
import { AFSRoot, AgentManifest } from "@aigne/afs";
|
|
4
|
+
import { ToolEntry } from "@aigne/afs-ash";
|
|
5
|
+
|
|
6
|
+
//#region src/program/scoped-afs.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Chain-depth hard cap. Mirrors `HARD_CAP` in
|
|
9
|
+
* `providers/basic/ash/src/spawn-depth.ts`; kept in sync manually because
|
|
10
|
+
* importing across package boundaries for a constant isn't worth the
|
|
11
|
+
* dependency. Any change there must be reflected here.
|
|
12
|
+
*
|
|
13
|
+
* Semantics match `spawn-depth.ts`: a child whose post-increment depth
|
|
14
|
+
* would be **>= HARD_CAP** is rejected with `CHAIN_DEPTH_EXCEEDED`. With
|
|
15
|
+
* root.chainDepth = 0 this means the deepest reachable child is depth 9;
|
|
16
|
+
* attempting to spawn depth 10 throws.
|
|
17
|
+
*/
|
|
18
|
+
declare const CHAIN_DEPTH_HARD_CAP = 10;
|
|
19
|
+
/**
|
|
20
|
+
* Mutable budget accounting backing a single scope's `/.meta/budget/*`
|
|
21
|
+
* mount and its exec middleware. `rootSession` is the mutex key shared by
|
|
22
|
+
* every scope in one spawn chain; ancestor aggregation happens naturally
|
|
23
|
+
* because `child.exec` delegates to `parent.exec` through the prototype
|
|
24
|
+
* chain, so each ancestor's middleware runs once per call and applies its
|
|
25
|
+
* own increment — no parent pointer needed.
|
|
26
|
+
*/
|
|
27
|
+
interface BudgetState {
|
|
28
|
+
readonly rootSession: string;
|
|
29
|
+
readonly limit: number;
|
|
30
|
+
consumed: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Per-scope descriptor threaded through every AFS call a runner makes.
|
|
34
|
+
*
|
|
35
|
+
* - `session` — this scope's session id (not the underlying WS session)
|
|
36
|
+
* - `parentSession` — the session that spawned us (used for event aggregation)
|
|
37
|
+
* - `rootSession` — the session at the root of the spawn chain. All children
|
|
38
|
+
* of the same root share this value; P4's budget exec middleware uses it
|
|
39
|
+
* as the mutex key so concurrent sub-runs serialize correctly against the
|
|
40
|
+
* same budget file. Root scope: rootSession === session.
|
|
41
|
+
* - `chainDepth` — distance from the root scope (root = 0). Enforced against
|
|
42
|
+
* `CHAIN_DEPTH_HARD_CAP` on every `projectForChild` call.
|
|
43
|
+
* - `allowedPaths` — paths visible inside this scope. Populated from the
|
|
44
|
+
* intersection of the parent's `allowedTools` and the child manifest's
|
|
45
|
+
* declared tools (P1).
|
|
46
|
+
* - `allowedTools` — intersected `ToolEntry[]` (paths + ops + maxDepth +
|
|
47
|
+
* exclude_actions). Carried alongside `allowedPaths` because runners
|
|
48
|
+
* need the ops metadata to build the LLM tool catalog; the `.actions/`
|
|
49
|
+
* mount in later phases will let consumers list tools directly from the
|
|
50
|
+
* scope and this field will become a cache.
|
|
51
|
+
*/
|
|
52
|
+
interface AgentScopeDescriptorFields {
|
|
53
|
+
readonly session: string;
|
|
54
|
+
readonly parentSession?: string;
|
|
55
|
+
readonly rootSession: string;
|
|
56
|
+
readonly chainDepth: number;
|
|
57
|
+
readonly allowedPaths: readonly string[];
|
|
58
|
+
readonly allowedTools: readonly ToolEntry[];
|
|
59
|
+
/**
|
|
60
|
+
* Tenant string that the scope's `/memory/` mount was instantiated with.
|
|
61
|
+
* Absent on scopes where `manifest.memory` is falsy — child scopes inherit
|
|
62
|
+
* this value when they declare `memory: true` without an explicit domain.
|
|
63
|
+
* See `docs/architecture/agent-memory.md` §3.3 for the precedence ladder.
|
|
64
|
+
*/
|
|
65
|
+
readonly memoryDomain?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Live budget state backing this scope's `/.meta/budget/*` mount. Absent
|
|
68
|
+
* on scopes that never opted into budget tracking (legacy callers that
|
|
69
|
+
* synthesize a scope without declaring a limit). When present, the exec
|
|
70
|
+
* middleware reads/writes this object under the rootSession mutex;
|
|
71
|
+
* children created via `projectForChild` inherit a new state whose
|
|
72
|
+
* `parent` pointer links here so decrements walk up the chain.
|
|
73
|
+
*/
|
|
74
|
+
readonly budget?: BudgetState;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A scoped AFS view handed to an agent runner. Same shape as `AFSRoot`
|
|
78
|
+
* (list/read/write/exec/…) with an extra `scope` descriptor.
|
|
79
|
+
*
|
|
80
|
+
* Runners read session / chain / permissions from `scope` rather than
|
|
81
|
+
* from their own arguments. The five sibling phases (P1 tools, P2 scratch,
|
|
82
|
+
* P3 memory, P4 budget, P5 session) wire mounts into the scope so the
|
|
83
|
+
* runner never needs provider-specific fields on its context.
|
|
84
|
+
*/
|
|
85
|
+
interface AgentScope extends AFSRoot {
|
|
86
|
+
readonly scope: AgentScopeDescriptorFields;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Options accepted by `projectForChild`.
|
|
90
|
+
*
|
|
91
|
+
* **Closed at 3 fields** — permission-widening fields (tools / budget /
|
|
92
|
+
* scratch / memory / budgetRemaining / …) are intentionally absent. The
|
|
93
|
+
* implementation must derive those from `childManifest` and the parent
|
|
94
|
+
* scope. Extending this type to smuggle in a wider budget or tool set
|
|
95
|
+
* defeats the whole point of scope-based projection.
|
|
96
|
+
*/
|
|
97
|
+
interface ProjectForChildOptions {
|
|
98
|
+
/** Required — where the child agent lives in the parent's mount tree (e.g. "members/reviewer"). */
|
|
99
|
+
readonly memberPath: string;
|
|
100
|
+
/** Required — scratch/memory/tools/budget are all derived from this. */
|
|
101
|
+
readonly childManifest: AgentManifest;
|
|
102
|
+
/**
|
|
103
|
+
* Optional — if omitted, the runtime generates
|
|
104
|
+
* `${parent.scope.session}.${memberName}.${counter}`. Must not contain
|
|
105
|
+
* path separators, null bytes, or be empty.
|
|
106
|
+
*/
|
|
107
|
+
readonly session?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Phase 2 sandbox serialization target. When the runtime needs to hand a
|
|
111
|
+
* scope to an out-of-process worker (code agent, sandboxed MCP server, …),
|
|
112
|
+
* it serializes to this descriptor and the far side rebuilds an AgentScope
|
|
113
|
+
* backed by an MCP bridge.
|
|
114
|
+
*
|
|
115
|
+
* Phase 0 only defines the shape — `toJSON()` throws until Phase 2 lands.
|
|
116
|
+
*/
|
|
117
|
+
interface AgentScopeDescriptor {
|
|
118
|
+
readonly kind: "agent-scope";
|
|
119
|
+
readonly session: string;
|
|
120
|
+
readonly parentSession?: string;
|
|
121
|
+
readonly rootSession: string;
|
|
122
|
+
readonly chainDepth: number;
|
|
123
|
+
readonly allowedPaths: readonly string[];
|
|
124
|
+
readonly mountDescriptors: ReadonlyArray<{
|
|
125
|
+
readonly path: string;
|
|
126
|
+
readonly providerDescriptor: unknown;
|
|
127
|
+
}>;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Normalize a manifest's `tools` field into `ToolEntry[]`, rejecting shapes
|
|
131
|
+
* that would let a dispatcher smuggle traversal or typo past intersection:
|
|
132
|
+
* - non-string / empty path → TOOL_PATH_INVALID
|
|
133
|
+
* - path containing `..` or `\0` → TOOL_PATH_INVALID
|
|
134
|
+
* - ops must be a non-empty string[] when provided
|
|
135
|
+
*
|
|
136
|
+
* The Phase 1 contract: one call site (projectForChild) owns normalization;
|
|
137
|
+
* older runner-local normalize helpers delegate here.
|
|
138
|
+
*/
|
|
139
|
+
declare function normalizeManifestTools(manifest: {
|
|
140
|
+
tools?: AgentManifest["tools"];
|
|
141
|
+
}): ToolEntry[];
|
|
142
|
+
/**
|
|
143
|
+
* Lift a raw `AFSRoot` into a root-level `AgentScope`. Root scopes are
|
|
144
|
+
* unbounded by construction — `scope.allowedTools` is the caller's own
|
|
145
|
+
* manifest tools (or fully permissive when omitted), and `chainDepth` is 0.
|
|
146
|
+
*
|
|
147
|
+
* Top-level runners (agent-run action handler, test harnesses) use this to
|
|
148
|
+
* bootstrap the scope chain; downstream runners never construct a root
|
|
149
|
+
* scope themselves. Omit `manifestTools` (or pass `[]`) to keep the root
|
|
150
|
+
* fully permissive — useful for tests that don't declare tools.
|
|
151
|
+
*/
|
|
152
|
+
declare function rootAgentScope(afs: AFSRoot, opts: {
|
|
153
|
+
session: string;
|
|
154
|
+
manifestTools?: ToolEntry[];
|
|
155
|
+
/**
|
|
156
|
+
* Optional manifest budget config for the root scope. When set, the
|
|
157
|
+
* returned scope carries a `/.meta/budget/*` mount and the exec
|
|
158
|
+
* middleware; children projected from it inherit clamped budgets.
|
|
159
|
+
* Omitted → scope is unbudgeted (legacy behaviour).
|
|
160
|
+
*/
|
|
161
|
+
budget?: BudgetConfig;
|
|
162
|
+
/**
|
|
163
|
+
* Optional memory domain to stamp into the root scope descriptor.
|
|
164
|
+
* Callers that pre-attached a `/memory/*` mount (e.g. team-runner when
|
|
165
|
+
* the team manifest declares memory at the top level) pass the domain
|
|
166
|
+
* so downstream `scope.memoryDomain` reads resolve authoritatively.
|
|
167
|
+
* Omitted → scope carries no memory domain (legacy behaviour).
|
|
168
|
+
*/
|
|
169
|
+
memoryDomain?: string;
|
|
170
|
+
}): AgentScope;
|
|
171
|
+
/**
|
|
172
|
+
* Top-level runner bootstrap — if the caller's AFS is already a scope, use
|
|
173
|
+
* it verbatim; otherwise synthesize a root scope and attach a fresh
|
|
174
|
+
* `/scratch/*` mount. Team and orchestrator runners call this so hook
|
|
175
|
+
* events and `state.yml` writes land in the scope-local scratch rather
|
|
176
|
+
* than the legacy `/modules/memory/runs/` tree.
|
|
177
|
+
*
|
|
178
|
+
* Pass `manifestTools` + `session` to drive the synthetic root scope's
|
|
179
|
+
* descriptor; the caller's own manifest is typically the source, and
|
|
180
|
+
* `scratchRetention` follows `manifest.scratch` (run → session default).
|
|
181
|
+
*/
|
|
182
|
+
declare function ensureScopeWithMounts(afs: AFSRoot, opts: {
|
|
183
|
+
session: string;
|
|
184
|
+
manifestTools?: ToolEntry[];
|
|
185
|
+
scratchRetention?: ScratchRetention;
|
|
186
|
+
scratchProvider?: ScratchProvider;
|
|
187
|
+
/**
|
|
188
|
+
* Manifest budget for the synthetic root scope. Forwarded to
|
|
189
|
+
* `rootAgentScope` so the bootstrap scope carries the budget mount
|
|
190
|
+
* and children projected from it inherit the clamp. Optional — when
|
|
191
|
+
* unset, the scope stays unbudgeted (legacy behaviour).
|
|
192
|
+
*/
|
|
193
|
+
budget?: BudgetConfig;
|
|
194
|
+
/**
|
|
195
|
+
* Top-level team's `manifest.memory`. When the team declares memory,
|
|
196
|
+
* the synthetic root scope stamps `memoryDomain` so downstream G2
|
|
197
|
+
* handoff read-through resolves authoritatively without re-reading
|
|
198
|
+
* the manifest. Does NOT attach a memory mount — the caller is
|
|
199
|
+
* expected to have one already (tests use `attachMemoryMount`;
|
|
200
|
+
* production wires via the per-scope scaffolding).
|
|
201
|
+
*/
|
|
202
|
+
memory?: unknown;
|
|
203
|
+
}): AgentScope;
|
|
204
|
+
/**
|
|
205
|
+
* Resolve the `AgentScope` a parent runner projects children from.
|
|
206
|
+
*
|
|
207
|
+
* Phase 6 — if the caller already handed us a scoped AFS (via
|
|
208
|
+
* `projectForChild` / `ensureScopeWithMounts`), reuse it: its `allowedTools`
|
|
209
|
+
* is already the post-intersection view. Otherwise synthesize a root scope
|
|
210
|
+
* from the caller's `manifest.tools`, normalized via `normalizeManifestTools`
|
|
211
|
+
* for a single source of truth. Callers that want a tighter inherited
|
|
212
|
+
* set must hand over a scoped AFS built via `projectForChild` or
|
|
213
|
+
* `ensureScopeWithMounts`.
|
|
214
|
+
*/
|
|
215
|
+
declare function resolveParentAgentScope(opts: {
|
|
216
|
+
afs: AFSRoot;
|
|
217
|
+
manifest: AgentManifest;
|
|
218
|
+
session?: string;
|
|
219
|
+
}): AgentScope;
|
|
220
|
+
/**
|
|
221
|
+
* Narrow down `parent` for a child agent:
|
|
222
|
+
* - path projection via existing `projectSubAgent` (rewrite + readonly)
|
|
223
|
+
* - tool ACL intersection via existing `intersectTools` (paths + ops)
|
|
224
|
+
* - scope descriptor: session / rootSession / chainDepth+1 / allowedPaths
|
|
225
|
+
*
|
|
226
|
+
* If the parent has a non-empty `scope.allowedTools` and the child declares
|
|
227
|
+
* a non-empty `manifest.tools` that doesn't overlap (intersection empty),
|
|
228
|
+
* we throw `TOOL_INTERSECTION_EMPTY` — an empty intersection means the
|
|
229
|
+
* dispatcher has asked for an unreachable child scope, which is a hard
|
|
230
|
+
* error rather than a silently-permissive default.
|
|
231
|
+
*
|
|
232
|
+
* See design.md §5 for the full six-step mount composition; P2–P5 add
|
|
233
|
+
* scratch / memory / budget / session arms to the same function.
|
|
234
|
+
*/
|
|
235
|
+
declare function projectForChild(parent: AgentScope, options: ProjectForChildOptions): AgentScope;
|
|
236
|
+
/**
|
|
237
|
+
* Phase 2 target — serialize a scope for cross-process hand-off (MCP
|
|
238
|
+
* sandbox worker, code-agent runner, …). Always throws in Phase 0/1 so
|
|
239
|
+
* no caller is tempted to persist a partial descriptor before the sandbox
|
|
240
|
+
* boundary exists.
|
|
241
|
+
*/
|
|
242
|
+
declare function toJSON(_scope: AgentScope): AgentScopeDescriptor;
|
|
243
|
+
//#endregion
|
|
244
|
+
export { AgentScope, AgentScopeDescriptor, AgentScopeDescriptorFields, CHAIN_DEPTH_HARD_CAP, ProjectForChildOptions, ensureScopeWithMounts, normalizeManifestTools, projectForChild, resolveParentAgentScope, rootAgentScope, toJSON };
|
|
245
|
+
//# sourceMappingURL=scoped-afs.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped-afs.d.cts","names":[],"sources":["../../src/program/scoped-afs.ts"],"mappings":";;;;;;;;;;;AAmZA;;;;;;cAxVa,oBAAA;;;AAqWb;;;;;;UApRiB,WAAA;EAAA,SACN,WAAA;EAAA,SACA,KAAA;EACT,QAAA;AAAA;;;;;;;;AAibF;;;;;;;;;;;;;UA/MiB,0BAAA;EAAA,SACN,OAAA;EAAA,SACA,aAAA;EAAA,SACA,WAAA;EAAA,SACA,UAAA;EAAA,SACA,YAAA;EAAA,SACA,YAAA,WAAuB,SAAA;EA8NrB;AAsCb;;;;;EAtCa,SAvNF,YAAA;EAmQW;;;;;;;;EAAA,SA1PX,MAAA,GAAS,WAAA;AAAA;;;;;;;;;;UAYH,UAAA,SAAmB,OAAA;EAAA,SACzB,KAAA,EAAO,0BAAA;AAAA;;;;;;;;;;UAYD,sBAAA;EAkRL;EAAA,SAhRD,UAAA;EA8Q6B;EAAA,SA5Q7B,aAAA,EAAe,aAAA;EAgRZ;;AAoCd;;;EApCc,SA1QH,OAAA;AAAA;;;;;;;;;UAWM,oBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,aAAA;EAAA,SACA,WAAA;EAAA,SACA,UAAA;EAAA,SACA,YAAA;EAAA,SACA,gBAAA,EAAkB,aAAA;IAAA,SAChB,IAAA;IAAA,SACA,kBAAA;EAAA;AAAA;;;;;;;;;;;iBA8CG,sBAAA,CAAuB,QAAA;EAAY,KAAA,GAAQ,aAAA;AAAA,IAA2B,SAAA;;;;;;;;;;;iBAoFtE,cAAA,CACd,GAAA,EAAK,OAAA,EACL,IAAA;EACE,OAAA;EACA,aAAA,GAAgB,SAAA;;;;;;;EAOhB,MAAA,GAAS,YAAA;;;;;;;;EAQT,YAAA;AAAA,IAED,UAAA;;;;;;;;;;;;iBAsCa,qBAAA,CACd,GAAA,EAAK,OAAA,EACL,IAAA;EACE,OAAA;EACA,aAAA,GAAgB,SAAA;EAChB,gBAAA,GAAmB,gBAAA;EACnB,eAAA,GAAkB,eAAA;;;;;;;EAOlB,MAAA,GAAS,YAAA;;;;;;;;;EAST,MAAA;AAAA,IAED,UAAA;;;;;;;;;;;;iBA6Ba,uBAAA,CAAwB,IAAA;EACtC,GAAA,EAAK,OAAA;EACL,QAAA,EAAU,aAAA;EACV,OAAA;AAAA,IACE,UAAA;;;;;;;;;;;;;;;;iBAoCY,eAAA,CAAgB,MAAA,EAAQ,UAAA,EAAY,OAAA,EAAS,sBAAA,GAAyB,UAAA;;;;;;;iBA8JtE,MAAA,CAAO,MAAA,EAAQ,UAAA,GAAa,oBAAA"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { BudgetConfig } from "../agent-runners/budget.mjs";
|
|
2
|
+
import { ScratchProvider, ScratchRetention } from "../agent-runners/scratchpad-afs.mjs";
|
|
3
|
+
import { AFSRoot, AgentManifest } from "@aigne/afs";
|
|
4
|
+
import { ToolEntry } from "@aigne/afs-ash";
|
|
5
|
+
|
|
6
|
+
//#region src/program/scoped-afs.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Chain-depth hard cap. Mirrors `HARD_CAP` in
|
|
9
|
+
* `providers/basic/ash/src/spawn-depth.ts`; kept in sync manually because
|
|
10
|
+
* importing across package boundaries for a constant isn't worth the
|
|
11
|
+
* dependency. Any change there must be reflected here.
|
|
12
|
+
*
|
|
13
|
+
* Semantics match `spawn-depth.ts`: a child whose post-increment depth
|
|
14
|
+
* would be **>= HARD_CAP** is rejected with `CHAIN_DEPTH_EXCEEDED`. With
|
|
15
|
+
* root.chainDepth = 0 this means the deepest reachable child is depth 9;
|
|
16
|
+
* attempting to spawn depth 10 throws.
|
|
17
|
+
*/
|
|
18
|
+
declare const CHAIN_DEPTH_HARD_CAP = 10;
|
|
19
|
+
/**
|
|
20
|
+
* Mutable budget accounting backing a single scope's `/.meta/budget/*`
|
|
21
|
+
* mount and its exec middleware. `rootSession` is the mutex key shared by
|
|
22
|
+
* every scope in one spawn chain; ancestor aggregation happens naturally
|
|
23
|
+
* because `child.exec` delegates to `parent.exec` through the prototype
|
|
24
|
+
* chain, so each ancestor's middleware runs once per call and applies its
|
|
25
|
+
* own increment — no parent pointer needed.
|
|
26
|
+
*/
|
|
27
|
+
interface BudgetState {
|
|
28
|
+
readonly rootSession: string;
|
|
29
|
+
readonly limit: number;
|
|
30
|
+
consumed: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Per-scope descriptor threaded through every AFS call a runner makes.
|
|
34
|
+
*
|
|
35
|
+
* - `session` — this scope's session id (not the underlying WS session)
|
|
36
|
+
* - `parentSession` — the session that spawned us (used for event aggregation)
|
|
37
|
+
* - `rootSession` — the session at the root of the spawn chain. All children
|
|
38
|
+
* of the same root share this value; P4's budget exec middleware uses it
|
|
39
|
+
* as the mutex key so concurrent sub-runs serialize correctly against the
|
|
40
|
+
* same budget file. Root scope: rootSession === session.
|
|
41
|
+
* - `chainDepth` — distance from the root scope (root = 0). Enforced against
|
|
42
|
+
* `CHAIN_DEPTH_HARD_CAP` on every `projectForChild` call.
|
|
43
|
+
* - `allowedPaths` — paths visible inside this scope. Populated from the
|
|
44
|
+
* intersection of the parent's `allowedTools` and the child manifest's
|
|
45
|
+
* declared tools (P1).
|
|
46
|
+
* - `allowedTools` — intersected `ToolEntry[]` (paths + ops + maxDepth +
|
|
47
|
+
* exclude_actions). Carried alongside `allowedPaths` because runners
|
|
48
|
+
* need the ops metadata to build the LLM tool catalog; the `.actions/`
|
|
49
|
+
* mount in later phases will let consumers list tools directly from the
|
|
50
|
+
* scope and this field will become a cache.
|
|
51
|
+
*/
|
|
52
|
+
interface AgentScopeDescriptorFields {
|
|
53
|
+
readonly session: string;
|
|
54
|
+
readonly parentSession?: string;
|
|
55
|
+
readonly rootSession: string;
|
|
56
|
+
readonly chainDepth: number;
|
|
57
|
+
readonly allowedPaths: readonly string[];
|
|
58
|
+
readonly allowedTools: readonly ToolEntry[];
|
|
59
|
+
/**
|
|
60
|
+
* Tenant string that the scope's `/memory/` mount was instantiated with.
|
|
61
|
+
* Absent on scopes where `manifest.memory` is falsy — child scopes inherit
|
|
62
|
+
* this value when they declare `memory: true` without an explicit domain.
|
|
63
|
+
* See `docs/architecture/agent-memory.md` §3.3 for the precedence ladder.
|
|
64
|
+
*/
|
|
65
|
+
readonly memoryDomain?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Live budget state backing this scope's `/.meta/budget/*` mount. Absent
|
|
68
|
+
* on scopes that never opted into budget tracking (legacy callers that
|
|
69
|
+
* synthesize a scope without declaring a limit). When present, the exec
|
|
70
|
+
* middleware reads/writes this object under the rootSession mutex;
|
|
71
|
+
* children created via `projectForChild` inherit a new state whose
|
|
72
|
+
* `parent` pointer links here so decrements walk up the chain.
|
|
73
|
+
*/
|
|
74
|
+
readonly budget?: BudgetState;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A scoped AFS view handed to an agent runner. Same shape as `AFSRoot`
|
|
78
|
+
* (list/read/write/exec/…) with an extra `scope` descriptor.
|
|
79
|
+
*
|
|
80
|
+
* Runners read session / chain / permissions from `scope` rather than
|
|
81
|
+
* from their own arguments. The five sibling phases (P1 tools, P2 scratch,
|
|
82
|
+
* P3 memory, P4 budget, P5 session) wire mounts into the scope so the
|
|
83
|
+
* runner never needs provider-specific fields on its context.
|
|
84
|
+
*/
|
|
85
|
+
interface AgentScope extends AFSRoot {
|
|
86
|
+
readonly scope: AgentScopeDescriptorFields;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Options accepted by `projectForChild`.
|
|
90
|
+
*
|
|
91
|
+
* **Closed at 3 fields** — permission-widening fields (tools / budget /
|
|
92
|
+
* scratch / memory / budgetRemaining / …) are intentionally absent. The
|
|
93
|
+
* implementation must derive those from `childManifest` and the parent
|
|
94
|
+
* scope. Extending this type to smuggle in a wider budget or tool set
|
|
95
|
+
* defeats the whole point of scope-based projection.
|
|
96
|
+
*/
|
|
97
|
+
interface ProjectForChildOptions {
|
|
98
|
+
/** Required — where the child agent lives in the parent's mount tree (e.g. "members/reviewer"). */
|
|
99
|
+
readonly memberPath: string;
|
|
100
|
+
/** Required — scratch/memory/tools/budget are all derived from this. */
|
|
101
|
+
readonly childManifest: AgentManifest;
|
|
102
|
+
/**
|
|
103
|
+
* Optional — if omitted, the runtime generates
|
|
104
|
+
* `${parent.scope.session}.${memberName}.${counter}`. Must not contain
|
|
105
|
+
* path separators, null bytes, or be empty.
|
|
106
|
+
*/
|
|
107
|
+
readonly session?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Phase 2 sandbox serialization target. When the runtime needs to hand a
|
|
111
|
+
* scope to an out-of-process worker (code agent, sandboxed MCP server, …),
|
|
112
|
+
* it serializes to this descriptor and the far side rebuilds an AgentScope
|
|
113
|
+
* backed by an MCP bridge.
|
|
114
|
+
*
|
|
115
|
+
* Phase 0 only defines the shape — `toJSON()` throws until Phase 2 lands.
|
|
116
|
+
*/
|
|
117
|
+
interface AgentScopeDescriptor {
|
|
118
|
+
readonly kind: "agent-scope";
|
|
119
|
+
readonly session: string;
|
|
120
|
+
readonly parentSession?: string;
|
|
121
|
+
readonly rootSession: string;
|
|
122
|
+
readonly chainDepth: number;
|
|
123
|
+
readonly allowedPaths: readonly string[];
|
|
124
|
+
readonly mountDescriptors: ReadonlyArray<{
|
|
125
|
+
readonly path: string;
|
|
126
|
+
readonly providerDescriptor: unknown;
|
|
127
|
+
}>;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Normalize a manifest's `tools` field into `ToolEntry[]`, rejecting shapes
|
|
131
|
+
* that would let a dispatcher smuggle traversal or typo past intersection:
|
|
132
|
+
* - non-string / empty path → TOOL_PATH_INVALID
|
|
133
|
+
* - path containing `..` or `\0` → TOOL_PATH_INVALID
|
|
134
|
+
* - ops must be a non-empty string[] when provided
|
|
135
|
+
*
|
|
136
|
+
* The Phase 1 contract: one call site (projectForChild) owns normalization;
|
|
137
|
+
* older runner-local normalize helpers delegate here.
|
|
138
|
+
*/
|
|
139
|
+
declare function normalizeManifestTools(manifest: {
|
|
140
|
+
tools?: AgentManifest["tools"];
|
|
141
|
+
}): ToolEntry[];
|
|
142
|
+
/**
|
|
143
|
+
* Lift a raw `AFSRoot` into a root-level `AgentScope`. Root scopes are
|
|
144
|
+
* unbounded by construction — `scope.allowedTools` is the caller's own
|
|
145
|
+
* manifest tools (or fully permissive when omitted), and `chainDepth` is 0.
|
|
146
|
+
*
|
|
147
|
+
* Top-level runners (agent-run action handler, test harnesses) use this to
|
|
148
|
+
* bootstrap the scope chain; downstream runners never construct a root
|
|
149
|
+
* scope themselves. Omit `manifestTools` (or pass `[]`) to keep the root
|
|
150
|
+
* fully permissive — useful for tests that don't declare tools.
|
|
151
|
+
*/
|
|
152
|
+
declare function rootAgentScope(afs: AFSRoot, opts: {
|
|
153
|
+
session: string;
|
|
154
|
+
manifestTools?: ToolEntry[];
|
|
155
|
+
/**
|
|
156
|
+
* Optional manifest budget config for the root scope. When set, the
|
|
157
|
+
* returned scope carries a `/.meta/budget/*` mount and the exec
|
|
158
|
+
* middleware; children projected from it inherit clamped budgets.
|
|
159
|
+
* Omitted → scope is unbudgeted (legacy behaviour).
|
|
160
|
+
*/
|
|
161
|
+
budget?: BudgetConfig;
|
|
162
|
+
/**
|
|
163
|
+
* Optional memory domain to stamp into the root scope descriptor.
|
|
164
|
+
* Callers that pre-attached a `/memory/*` mount (e.g. team-runner when
|
|
165
|
+
* the team manifest declares memory at the top level) pass the domain
|
|
166
|
+
* so downstream `scope.memoryDomain` reads resolve authoritatively.
|
|
167
|
+
* Omitted → scope carries no memory domain (legacy behaviour).
|
|
168
|
+
*/
|
|
169
|
+
memoryDomain?: string;
|
|
170
|
+
}): AgentScope;
|
|
171
|
+
/**
|
|
172
|
+
* Top-level runner bootstrap — if the caller's AFS is already a scope, use
|
|
173
|
+
* it verbatim; otherwise synthesize a root scope and attach a fresh
|
|
174
|
+
* `/scratch/*` mount. Team and orchestrator runners call this so hook
|
|
175
|
+
* events and `state.yml` writes land in the scope-local scratch rather
|
|
176
|
+
* than the legacy `/modules/memory/runs/` tree.
|
|
177
|
+
*
|
|
178
|
+
* Pass `manifestTools` + `session` to drive the synthetic root scope's
|
|
179
|
+
* descriptor; the caller's own manifest is typically the source, and
|
|
180
|
+
* `scratchRetention` follows `manifest.scratch` (run → session default).
|
|
181
|
+
*/
|
|
182
|
+
declare function ensureScopeWithMounts(afs: AFSRoot, opts: {
|
|
183
|
+
session: string;
|
|
184
|
+
manifestTools?: ToolEntry[];
|
|
185
|
+
scratchRetention?: ScratchRetention;
|
|
186
|
+
scratchProvider?: ScratchProvider;
|
|
187
|
+
/**
|
|
188
|
+
* Manifest budget for the synthetic root scope. Forwarded to
|
|
189
|
+
* `rootAgentScope` so the bootstrap scope carries the budget mount
|
|
190
|
+
* and children projected from it inherit the clamp. Optional — when
|
|
191
|
+
* unset, the scope stays unbudgeted (legacy behaviour).
|
|
192
|
+
*/
|
|
193
|
+
budget?: BudgetConfig;
|
|
194
|
+
/**
|
|
195
|
+
* Top-level team's `manifest.memory`. When the team declares memory,
|
|
196
|
+
* the synthetic root scope stamps `memoryDomain` so downstream G2
|
|
197
|
+
* handoff read-through resolves authoritatively without re-reading
|
|
198
|
+
* the manifest. Does NOT attach a memory mount — the caller is
|
|
199
|
+
* expected to have one already (tests use `attachMemoryMount`;
|
|
200
|
+
* production wires via the per-scope scaffolding).
|
|
201
|
+
*/
|
|
202
|
+
memory?: unknown;
|
|
203
|
+
}): AgentScope;
|
|
204
|
+
/**
|
|
205
|
+
* Resolve the `AgentScope` a parent runner projects children from.
|
|
206
|
+
*
|
|
207
|
+
* Phase 6 — if the caller already handed us a scoped AFS (via
|
|
208
|
+
* `projectForChild` / `ensureScopeWithMounts`), reuse it: its `allowedTools`
|
|
209
|
+
* is already the post-intersection view. Otherwise synthesize a root scope
|
|
210
|
+
* from the caller's `manifest.tools`, normalized via `normalizeManifestTools`
|
|
211
|
+
* for a single source of truth. Callers that want a tighter inherited
|
|
212
|
+
* set must hand over a scoped AFS built via `projectForChild` or
|
|
213
|
+
* `ensureScopeWithMounts`.
|
|
214
|
+
*/
|
|
215
|
+
declare function resolveParentAgentScope(opts: {
|
|
216
|
+
afs: AFSRoot;
|
|
217
|
+
manifest: AgentManifest;
|
|
218
|
+
session?: string;
|
|
219
|
+
}): AgentScope;
|
|
220
|
+
/**
|
|
221
|
+
* Narrow down `parent` for a child agent:
|
|
222
|
+
* - path projection via existing `projectSubAgent` (rewrite + readonly)
|
|
223
|
+
* - tool ACL intersection via existing `intersectTools` (paths + ops)
|
|
224
|
+
* - scope descriptor: session / rootSession / chainDepth+1 / allowedPaths
|
|
225
|
+
*
|
|
226
|
+
* If the parent has a non-empty `scope.allowedTools` and the child declares
|
|
227
|
+
* a non-empty `manifest.tools` that doesn't overlap (intersection empty),
|
|
228
|
+
* we throw `TOOL_INTERSECTION_EMPTY` — an empty intersection means the
|
|
229
|
+
* dispatcher has asked for an unreachable child scope, which is a hard
|
|
230
|
+
* error rather than a silently-permissive default.
|
|
231
|
+
*
|
|
232
|
+
* See design.md §5 for the full six-step mount composition; P2–P5 add
|
|
233
|
+
* scratch / memory / budget / session arms to the same function.
|
|
234
|
+
*/
|
|
235
|
+
declare function projectForChild(parent: AgentScope, options: ProjectForChildOptions): AgentScope;
|
|
236
|
+
/**
|
|
237
|
+
* Phase 2 target — serialize a scope for cross-process hand-off (MCP
|
|
238
|
+
* sandbox worker, code-agent runner, …). Always throws in Phase 0/1 so
|
|
239
|
+
* no caller is tempted to persist a partial descriptor before the sandbox
|
|
240
|
+
* boundary exists.
|
|
241
|
+
*/
|
|
242
|
+
declare function toJSON(_scope: AgentScope): AgentScopeDescriptor;
|
|
243
|
+
//#endregion
|
|
244
|
+
export { AgentScope, AgentScopeDescriptor, AgentScopeDescriptorFields, CHAIN_DEPTH_HARD_CAP, ProjectForChildOptions, ensureScopeWithMounts, normalizeManifestTools, projectForChild, resolveParentAgentScope, rootAgentScope, toJSON };
|
|
245
|
+
//# sourceMappingURL=scoped-afs.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped-afs.d.mts","names":[],"sources":["../../src/program/scoped-afs.ts"],"mappings":";;;;;;;;;;;AAmZA;;;;;;cAxVa,oBAAA;;;AAqWb;;;;;;UApRiB,WAAA;EAAA,SACN,WAAA;EAAA,SACA,KAAA;EACT,QAAA;AAAA;;;;;;;;AAibF;;;;;;;;;;;;;UA/MiB,0BAAA;EAAA,SACN,OAAA;EAAA,SACA,aAAA;EAAA,SACA,WAAA;EAAA,SACA,UAAA;EAAA,SACA,YAAA;EAAA,SACA,YAAA,WAAuB,SAAA;EA8NrB;AAsCb;;;;;EAtCa,SAvNF,YAAA;EAmQW;;;;;;;;EAAA,SA1PX,MAAA,GAAS,WAAA;AAAA;;;;;;;;;;UAYH,UAAA,SAAmB,OAAA;EAAA,SACzB,KAAA,EAAO,0BAAA;AAAA;;;;;;;;;;UAYD,sBAAA;EAkRL;EAAA,SAhRD,UAAA;EA8Q6B;EAAA,SA5Q7B,aAAA,EAAe,aAAA;EAgRZ;;AAoCd;;;EApCc,SA1QH,OAAA;AAAA;;;;;;;;;UAWM,oBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,aAAA;EAAA,SACA,WAAA;EAAA,SACA,UAAA;EAAA,SACA,YAAA;EAAA,SACA,gBAAA,EAAkB,aAAA;IAAA,SAChB,IAAA;IAAA,SACA,kBAAA;EAAA;AAAA;;;;;;;;;;;iBA8CG,sBAAA,CAAuB,QAAA;EAAY,KAAA,GAAQ,aAAA;AAAA,IAA2B,SAAA;;;;;;;;;;;iBAoFtE,cAAA,CACd,GAAA,EAAK,OAAA,EACL,IAAA;EACE,OAAA;EACA,aAAA,GAAgB,SAAA;;;;;;;EAOhB,MAAA,GAAS,YAAA;;;;;;;;EAQT,YAAA;AAAA,IAED,UAAA;;;;;;;;;;;;iBAsCa,qBAAA,CACd,GAAA,EAAK,OAAA,EACL,IAAA;EACE,OAAA;EACA,aAAA,GAAgB,SAAA;EAChB,gBAAA,GAAmB,gBAAA;EACnB,eAAA,GAAkB,eAAA;;;;;;;EAOlB,MAAA,GAAS,YAAA;;;;;;;;;EAST,MAAA;AAAA,IAED,UAAA;;;;;;;;;;;;iBA6Ba,uBAAA,CAAwB,IAAA;EACtC,GAAA,EAAK,OAAA;EACL,QAAA,EAAU,aAAA;EACV,OAAA;AAAA,IACE,UAAA;;;;;;;;;;;;;;;;iBAoCY,eAAA,CAAgB,MAAA,EAAQ,UAAA,EAAY,OAAA,EAAS,sBAAA,GAAyB,UAAA;;;;;;;iBA8JtE,MAAA,CAAO,MAAA,EAAQ,UAAA,GAAa,oBAAA"}
|