@toddzheng024/dscode-bundle 0.4.0 → 0.5.0
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/THIRD_PARTY_NOTICES.md +15 -0
- package/cordis.patch.yml +3 -3
- package/package.json +7 -1
- package/plugins/clipboard-image/clipboard-image.swift +56 -0
- package/plugins/clipboard-image/index.mjs +70 -0
- package/plugins/code-review/git.mjs +95 -0
- package/plugins/code-review/index.mjs +88 -0
- package/plugins/dscode/index.mjs +17 -3
- package/plugins/session-metrics/index.mjs +6 -2
- package/plugins/session-metrics/rate.mjs +62 -0
- package/plugins/session-metrics/view.mjs +15 -9
- package/plugins/tui-tools/doctor-cli.mjs +22 -0
- package/plugins/tui-tools/doctor.mjs +141 -0
- package/plugins/tui-tools/index.mjs +14 -6
- package/plugins/ultra/policy.mjs +12 -1
- package/plugins/worktree-subagent/worktree.mjs +50 -0
- package/presets/dscode/agent.cordis.yml +7 -2
- package/vendor/deepseek/index.js +12 -2
- package/vendor/subagent/index.js +29 -9
- package/vendor/subagent-core/LICENSE +21 -0
- package/vendor/subagent-core/index.js +3232 -0
- package/vendor/subagent-core/invariant.js +76 -0
- package/vendor/subagent-core/typert.host.d.ts +3 -0
- package/vendor/subagent-core/typert.host.js +964 -0
- package/vendor/subagent-core/typert.remote-client.d.ts +27 -0
- package/vendor/subagent-core/typert.remote-client.js +160 -0
- package/vendor/subagent-core/types/assistant-output.d.ts +48 -0
- package/vendor/subagent-core/types/assistant-output.js +73 -0
- package/vendor/subagent-core/types/catalog.d.ts +77 -0
- package/vendor/subagent-core/types/catalog.js +103 -0
- package/vendor/subagent-core/types/child-agent.d.ts +150 -0
- package/vendor/subagent-core/types/child-agent.js +207 -0
- package/vendor/subagent-core/types/client.d.ts +8 -0
- package/vendor/subagent-core/types/client.js +7 -0
- package/vendor/subagent-core/types/continuation-activation.d.ts +251 -0
- package/vendor/subagent-core/types/continuation-activation.js +663 -0
- package/vendor/subagent-core/types/continuation-messages.d.ts +62 -0
- package/vendor/subagent-core/types/continuation-messages.js +102 -0
- package/vendor/subagent-core/types/continuation.d.ts +124 -0
- package/vendor/subagent-core/types/continuation.js +455 -0
- package/vendor/subagent-core/types/control-types.d.ts +146 -0
- package/vendor/subagent-core/types/control-types.js +9 -0
- package/vendor/subagent-core/types/control.d.ts +71 -0
- package/vendor/subagent-core/types/control.js +116 -0
- package/vendor/subagent-core/types/depth.d.ts +31 -0
- package/vendor/subagent-core/types/depth.js +39 -0
- package/vendor/subagent-core/types/descriptor.d.ts +144 -0
- package/vendor/subagent-core/types/descriptor.js +193 -0
- package/vendor/subagent-core/types/error.d.ts +11 -0
- package/vendor/subagent-core/types/error.js +14 -0
- package/vendor/subagent-core/types/inbox.d.ts +43 -0
- package/vendor/subagent-core/types/inbox.js +61 -0
- package/vendor/subagent-core/types/index.d.ts +316 -0
- package/vendor/subagent-core/types/index.js +511 -0
- package/vendor/subagent-core/types/internal.d.ts +58 -0
- package/vendor/subagent-core/types/internal.js +58 -0
- package/vendor/subagent-core/types/invariant.d.ts +13 -0
- package/vendor/subagent-core/types/invariant.js +91 -0
- package/vendor/subagent-core/types/lifecycle.d.ts +113 -0
- package/vendor/subagent-core/types/lifecycle.js +178 -0
- package/vendor/subagent-core/types/list-children.d.ts +65 -0
- package/vendor/subagent-core/types/list-children.js +381 -0
- package/vendor/subagent-core/types/out-of-process.d.ts +118 -0
- package/vendor/subagent-core/types/out-of-process.js +219 -0
- package/vendor/subagent-core/types/projection-types.d.ts +74 -0
- package/vendor/subagent-core/types/projection-types.js +7 -0
- package/vendor/subagent-core/types/projection.d.ts +95 -0
- package/vendor/subagent-core/types/projection.js +151 -0
- package/vendor/subagent-core/types/run-settlement.d.ts +17 -0
- package/vendor/subagent-core/types/run-settlement.js +70 -0
- package/vendor/subagent-core/types/types.d.ts +377 -0
- package/vendor/subagent-core/types/types.js +19 -0
- package/vendor/subagent-driver/LICENSE +21 -0
- package/vendor/subagent-driver/index.js +255 -0
- package/vendor/subagent-driver/types/index.d.ts +33 -0
- package/vendor/subagent-driver/types/structured.d.ts +42 -0
- package/vendor/subagent-fork/LICENSE +21 -0
- package/vendor/subagent-fork/index.js +61 -0
- package/vendor/subagent-fork/types/index.d.ts +20 -0
- package/vendor/subagent-spawn/LICENSE +21 -0
- package/vendor/subagent-spawn/index.js +45 -0
- package/vendor/subagent-spawn/types/index.d.ts +19 -0
- package/vendor/terminal/LICENSE +21 -0
- package/vendor/terminal/index.js +1013 -0
- package/vendor/terminal/types/config.d.ts +71 -0
- package/vendor/terminal/types/index.d.ts +36 -0
- package/vendor/terminal/types/sanitize.d.ts +47 -0
- package/vendor/terminal/types/session.d.ts +87 -0
- package/vendor/tui/dscode-clipboard-image/clipboard-image.swift +56 -0
- package/vendor/tui/dscode-clipboard-image/index.mjs +70 -0
- package/vendor/tui/index.mjs +301 -78
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared in-process child composition: the delegation-depth budget, the
|
|
3
|
+
* durable session metadata, the resolved child `AgentOptions`, the delegated
|
|
4
|
+
* policy seed, and the scoped setup a child agent needs. Both the one-shot
|
|
5
|
+
* provider driver and the continuation manager compose children this way, so
|
|
6
|
+
* depth accounting, lineage stamping, and delegation policy have one home.
|
|
7
|
+
*
|
|
8
|
+
* @module @deepseek-ai/dsh-subagent/child-agent
|
|
9
|
+
*/
|
|
10
|
+
import { delegationDepthOf } from "./depth.js";
|
|
11
|
+
/** Thrown when starting a child would exceed the requested depth cap. */
|
|
12
|
+
export class SubagentDepthError extends Error {
|
|
13
|
+
attemptedDepth;
|
|
14
|
+
maxDepth;
|
|
15
|
+
constructor(attemptedDepth, maxDepth) {
|
|
16
|
+
super(`subagent depth ${attemptedDepth} exceeds maxDepth ${maxDepth}`);
|
|
17
|
+
this.attemptedDepth = attemptedDepth;
|
|
18
|
+
this.maxDepth = maxDepth;
|
|
19
|
+
this.name = 'SubagentDepthError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolve the child's delegation depth from its parent and enforce an optional
|
|
24
|
+
* cap. The persisted parent header is the monotone floor, so a resumed parent
|
|
25
|
+
* cannot delegate as if it were top-level.
|
|
26
|
+
* @param parent - the delegating parent agent.
|
|
27
|
+
* @param maxDepth - optional absolute cap the resolved depth must not exceed.
|
|
28
|
+
* @returns the child's non-negative safe-integer depth.
|
|
29
|
+
* @throws {SubagentDepthError} when the resolved depth exceeds `maxDepth`.
|
|
30
|
+
* @throws {RangeError} when the resolved depth leaves the safe-integer range.
|
|
31
|
+
*/
|
|
32
|
+
export function resolveChildDepth(parent, maxDepth) {
|
|
33
|
+
const childDepth = delegationDepthOf(parent) + 1;
|
|
34
|
+
if (!Number.isSafeInteger(childDepth)) {
|
|
35
|
+
throw new RangeError('subagent child depth exceeds the safe-integer range');
|
|
36
|
+
}
|
|
37
|
+
if (maxDepth !== undefined && childDepth > maxDepth) {
|
|
38
|
+
throw new SubagentDepthError(childDepth, maxDepth);
|
|
39
|
+
}
|
|
40
|
+
return childDepth;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Resolve the parent values inherited by a child. The latest request header
|
|
44
|
+
* owns provider, model, and reasoning effort after request-time selection;
|
|
45
|
+
* creation options remain the fallback before the first request and retain
|
|
46
|
+
* the configured output-token limit.
|
|
47
|
+
* @param parent - delegating parent Agent.
|
|
48
|
+
* @returns detached Agent options for child-option merging.
|
|
49
|
+
*/
|
|
50
|
+
export function parentAgentOptionsForDelegation(parent) {
|
|
51
|
+
const requestConfig = parent.session.requestHeader()?.config;
|
|
52
|
+
if (requestConfig === undefined)
|
|
53
|
+
return { ...parent.options };
|
|
54
|
+
const { provider: _createdProvider, model: _createdModel, reasoningEffort: _createdReasoningEffort, ...createdOptions } = parent.options;
|
|
55
|
+
return {
|
|
56
|
+
...createdOptions,
|
|
57
|
+
provider: requestConfig.provider,
|
|
58
|
+
model: requestConfig.model,
|
|
59
|
+
...requestConfig.reasoningEffort === undefined
|
|
60
|
+
? {}
|
|
61
|
+
: { reasoningEffort: requestConfig.reasoningEffort },
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Resolve the child's `AgentOptions`: the parent's provider/model,
|
|
66
|
+
* reasoning-effort, and maxTokens values unless the request overrides them,
|
|
67
|
+
* stamped with the child's own delegation depth. Changing the route without
|
|
68
|
+
* naming an effort clears the parent's route-owned effort so the selected
|
|
69
|
+
* model resolves its own default.
|
|
70
|
+
* @param parent - the delegating parent whose route the child inherits.
|
|
71
|
+
* @param requested - per-child overrides, if any.
|
|
72
|
+
* @param childDepth - the resolved delegation depth to stamp.
|
|
73
|
+
* @returns the resolved options for `ctx.agents.create()`.
|
|
74
|
+
*/
|
|
75
|
+
export function resolveChildAgentOptions(parent, requested, childDepth) {
|
|
76
|
+
const parentOptions = parentAgentOptionsForDelegation(parent);
|
|
77
|
+
const parentProvider = parentOptions.provider;
|
|
78
|
+
const parentModel = parentOptions.model;
|
|
79
|
+
const parentReasoningEffort = parentOptions.reasoningEffort;
|
|
80
|
+
const parentMaxTokens = parentOptions.maxTokens;
|
|
81
|
+
const resolved = {
|
|
82
|
+
...parentProvider !== undefined ? { provider: parentProvider } : {},
|
|
83
|
+
...parentModel !== undefined ? { model: parentModel } : {},
|
|
84
|
+
...parentReasoningEffort !== undefined ? { reasoningEffort: parentReasoningEffort } : {},
|
|
85
|
+
...parentMaxTokens !== undefined ? { maxTokens: parentMaxTokens } : {},
|
|
86
|
+
...requested,
|
|
87
|
+
subagentDepth: childDepth,
|
|
88
|
+
};
|
|
89
|
+
const routeChanged = resolved.provider !== parentProvider || resolved.model !== parentModel;
|
|
90
|
+
if (routeChanged && requested?.reasoningEffort === undefined)
|
|
91
|
+
delete resolved.reasoningEffort;
|
|
92
|
+
return resolved;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Build the child session's durable creation metadata: the parent's workspace,
|
|
96
|
+
* its direct lineage, coarse product origin, the recursion budget that must
|
|
97
|
+
* survive persistence, the seed boundary that separates inherited parent
|
|
98
|
+
* history from child work, and the composition the child runs under.
|
|
99
|
+
*
|
|
100
|
+
* The preset is read from the parent's LIVE scope chain rather than from its
|
|
101
|
+
* header, because a parent that switched preset while blank runs on the newer
|
|
102
|
+
* composition and its header still names the older one. Recording it is what
|
|
103
|
+
* makes a child's history reconstructable: without it a cold read of the child
|
|
104
|
+
* resolves the deployment default and rebuilds turns under a tool set the
|
|
105
|
+
* child never had.
|
|
106
|
+
* @param parent - the delegating parent agent.
|
|
107
|
+
* @param childDepth - the resolved delegation depth to persist.
|
|
108
|
+
* @param isSeeded - whether this child inherits a parent-log prefix, including an explicitly empty one.
|
|
109
|
+
* @returns the `meta` for `ctx.agents.create()`.
|
|
110
|
+
*/
|
|
111
|
+
export function childSessionMeta(parent, childDepth, isSeeded) {
|
|
112
|
+
const parentHeader = parent.session.header;
|
|
113
|
+
const agentPreset = parent.ctx.get('agentPresets')?.composedPreset(parent.ctx);
|
|
114
|
+
return {
|
|
115
|
+
...parentHeader.cwd !== undefined ? { cwd: parentHeader.cwd } : {},
|
|
116
|
+
...agentPreset === undefined ? {} : { agentPreset },
|
|
117
|
+
parentSession: parentHeader.id,
|
|
118
|
+
isSeeded,
|
|
119
|
+
// Navigation classification only; the descriptor remains the authority
|
|
120
|
+
// for mode and continuation capability.
|
|
121
|
+
origin: 'subagent',
|
|
122
|
+
// Durable: the recursion budget must survive persistence and resume.
|
|
123
|
+
delegationDepth: childDepth,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Model-facing delegation-scope statement for every in-process child. A
|
|
128
|
+
* runtime-context contribution rather than a system-prompt section, so the
|
|
129
|
+
* deployment's system prompt stays uniform across parents and children.
|
|
130
|
+
*/
|
|
131
|
+
export const SUBAGENT_DELEGATION_CONTEXT = 'You are a delegated subagent: your permission scope was fixed when you were started and cannot be '
|
|
132
|
+
+ 'widened from inside this session — operations that require approval are rejected automatically. '
|
|
133
|
+
+ 'When the task needs access beyond that scope, do not retry the denied operation; state the '
|
|
134
|
+
+ 'limitation in your reply so the delegating agent can handle it.';
|
|
135
|
+
/**
|
|
136
|
+
* Compose one child inside its creation window: join its parent's preset,
|
|
137
|
+
* register the fixed delegation-scope statement, then apply the child's own
|
|
138
|
+
* shadowing persona section and tool restriction, all owned by the child's
|
|
139
|
+
* scope and therefore invisible to its parent and siblings. Creation and cold
|
|
140
|
+
* resume both pass through here.
|
|
141
|
+
*
|
|
142
|
+
* The join comes first and the child's own registrations second, which is the
|
|
143
|
+
* order the layering already implies — the nearest scope wins a name, and a
|
|
144
|
+
* per-child restriction intersects with everything its chain admits — but
|
|
145
|
+
* stating it here keeps the two steps from being read as independent.
|
|
146
|
+
*
|
|
147
|
+
* The join and the per-child registrations live in ONE call because a child
|
|
148
|
+
* composed without the join is exactly the defect this function exists to
|
|
149
|
+
* prevent: with every model-facing row on the agent plane, a child that joins
|
|
150
|
+
* no preset sees an empty tool registry and none of its parent's prompt
|
|
151
|
+
* sections. Taking the parent as a parameter is what makes that omission
|
|
152
|
+
* unrepresentable at the call sites.
|
|
153
|
+
* @param childCtx - the child agent's scoped creation context.
|
|
154
|
+
* @param parent - the delegating parent whose composition the child joins.
|
|
155
|
+
* @param composition - the per-child persona and tool filter to install.
|
|
156
|
+
*/
|
|
157
|
+
export function applyChildComposition(childCtx, parent, composition) {
|
|
158
|
+
childCtx.get('agentPresets')?.composeFrom(childCtx, parent.ctx);
|
|
159
|
+
childCtx.systemPrompt.context({
|
|
160
|
+
name: 'subagent:delegation',
|
|
161
|
+
order: childCtx.systemPrompt.getContextOrder('SUBAGENT_DELEGATION'),
|
|
162
|
+
text: SUBAGENT_DELEGATION_CONTEXT,
|
|
163
|
+
});
|
|
164
|
+
if (composition.persona !== undefined) {
|
|
165
|
+
childCtx.systemPrompt.section({
|
|
166
|
+
name: 'deployment:persona-prefix',
|
|
167
|
+
order: childCtx.systemPrompt.getSectionOrder('DEPLOYMENT_PERSONA_PREFIX'),
|
|
168
|
+
text: composition.persona,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (composition.toolFilter !== undefined)
|
|
172
|
+
childCtx.tools.restrict(composition.toolFilter);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Capture the policy to seed into one delegation. Call synchronously before
|
|
176
|
+
* the child start's first await: a later parent switch belongs to the
|
|
177
|
+
* parent's future, not to this child. Only the parent session's explicit
|
|
178
|
+
* sandbox override is captured — never deployment defaults or one-shot
|
|
179
|
+
* grants — and the approval policy is pinned to `'never'` regardless of the
|
|
180
|
+
* parent's own policy.
|
|
181
|
+
* @param parent - the delegating parent agent.
|
|
182
|
+
* @returns the sandbox override (or `undefined` without one) and the approval pin.
|
|
183
|
+
*/
|
|
184
|
+
export function captureDelegatedPolicyOverrides(parent) {
|
|
185
|
+
return {
|
|
186
|
+
sandboxMode: parent.ctx.get('sandboxPolicy')?.overrideOf(parent.session),
|
|
187
|
+
approvalPolicy: parent.ctx.get('approval') === undefined ? undefined : 'never',
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Append the captured delegation policy onto the child's own log as
|
|
192
|
+
* `source: 'delegation'` events inside the unpublished creation window, so the
|
|
193
|
+
* child's effective policy is reconstructable from its log alone. Appends land
|
|
194
|
+
* after any fork seed, so fresh policy wins stale seed state; later child
|
|
195
|
+
* switches still win over these events.
|
|
196
|
+
* @param childSession - the unpublished child's session.
|
|
197
|
+
* @param overrides - the policy captured at delegation.
|
|
198
|
+
*/
|
|
199
|
+
export function appendDelegatedPolicyOverrides(childSession, overrides) {
|
|
200
|
+
if (overrides.sandboxMode !== undefined) {
|
|
201
|
+
childSession.append('sandbox/mode', { mode: overrides.sandboxMode, source: 'delegation' });
|
|
202
|
+
}
|
|
203
|
+
if (overrides.approvalPolicy !== undefined) {
|
|
204
|
+
childSession.append('approval/policy', { policy: overrides.approvalPolicy, source: 'delegation' });
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=child-agent.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe subagent projection and control vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* @module @deepseek-ai/dsh-subagent/client
|
|
5
|
+
*/
|
|
6
|
+
export type * from './control-types.ts';
|
|
7
|
+
export type { SubagentCatalogEntry, SubagentIdentityProjection, SubagentTimingProjection } from './projection-types.ts';
|
|
8
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-local Activation ownership for continuable subagents: admission,
|
|
3
|
+
* parent-child residency, serialized delivery, settlement, and disposal.
|
|
4
|
+
*
|
|
5
|
+
* The continuation manager owns durable request orchestration and delegates
|
|
6
|
+
* every mutable residency decision to this registry, so delivery and teardown
|
|
7
|
+
* share one child lock and one Activation map.
|
|
8
|
+
*
|
|
9
|
+
* @module @deepseek-ai/dsh-subagent/continuation-activation
|
|
10
|
+
*/
|
|
11
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
+
import type { Agent, AgentHandle, AgentOptions, CreateAgentOptions } from '@deepseek-ai/dsh-agent';
|
|
13
|
+
import type { MessageId } from '@deepseek-ai/dsh-llm';
|
|
14
|
+
import type { SessionEvent, SessionId, SessionLogOffset as SessionLogOffsetType, UserMessage } from '@deepseek-ai/dsh-session';
|
|
15
|
+
import type { ToolRestriction } from '@deepseek-ai/dsh-tools';
|
|
16
|
+
import type { DelegatedPolicyOverrides } from './child-agent.ts';
|
|
17
|
+
import type { SubagentDescriptorData } from './descriptor.ts';
|
|
18
|
+
import { SubagentInbox } from './inbox.ts';
|
|
19
|
+
import type { SubagentDelivery } from './inbox.ts';
|
|
20
|
+
import type { ActivationObserver } from './lifecycle.ts';
|
|
21
|
+
/**
|
|
22
|
+
* One residency epoch for a reconstructed continuable child Agent. It directly
|
|
23
|
+
* owns the published `AgentHandle`; the registry's private activation-owner
|
|
24
|
+
* scope is its structural Cordis owner.
|
|
25
|
+
*/
|
|
26
|
+
export interface Activation {
|
|
27
|
+
/** The durable child this Activation is an epoch of. */
|
|
28
|
+
readonly childId: SessionId;
|
|
29
|
+
/**
|
|
30
|
+
* The durable direct parent, stored because settlement delivery must resolve
|
|
31
|
+
* that parent after the child handle is gone. {@link ancestry} cannot answer
|
|
32
|
+
* it: a `WeakSet` is not enumerable, and the child's own header is only
|
|
33
|
+
* reachable through a handle disposal has already released.
|
|
34
|
+
*/
|
|
35
|
+
readonly parentSession: SessionId;
|
|
36
|
+
/** The provider name recorded in the durable descriptor. */
|
|
37
|
+
readonly provider: string;
|
|
38
|
+
/** The retained live Agent handle, disposed exactly once at settlement. */
|
|
39
|
+
readonly handle: AgentHandle;
|
|
40
|
+
/** The Activation-local admission and close wrapper around the handle's Agent inbox. */
|
|
41
|
+
readonly inbox: SubagentInbox;
|
|
42
|
+
/**
|
|
43
|
+
* Exact live Agent ancestry observed when this Activation materialized.
|
|
44
|
+
* Weak membership preserves host-scope identity across an intermediate
|
|
45
|
+
* ancestor leaving the registry without retaining that ancestor's runtime.
|
|
46
|
+
*/
|
|
47
|
+
readonly ancestry: WeakSet<Agent>;
|
|
48
|
+
/**
|
|
49
|
+
* Session ids of the child Activations this one owns. Because one Session has
|
|
50
|
+
* at most one live Activation, the id identifies the live child without
|
|
51
|
+
* another runtime-incarnation reference. Non-empty blocks settlement.
|
|
52
|
+
*/
|
|
53
|
+
readonly ownedChildren: Set<SessionId>;
|
|
54
|
+
/** The lifecycle observer that emits this epoch's start and terminal edges. */
|
|
55
|
+
readonly observer: ActivationObserver;
|
|
56
|
+
/**
|
|
57
|
+
* Whether any delivery to this child was ever accepted. A materialization
|
|
58
|
+
* rolled back before its first acceptance is a child the caller was told does
|
|
59
|
+
* not exist, so its teardown owes the parent no settlement account.
|
|
60
|
+
*/
|
|
61
|
+
announced: boolean;
|
|
62
|
+
/** Renewed whenever a settlement watcher must re-check residency state. */
|
|
63
|
+
poke: PromiseWithResolvers<void>;
|
|
64
|
+
}
|
|
65
|
+
/** Inputs shared by fresh and resumed Activation materialization. */
|
|
66
|
+
export interface MaterializeInputs {
|
|
67
|
+
childId: SessionId;
|
|
68
|
+
provider: string;
|
|
69
|
+
parent: Agent;
|
|
70
|
+
/**
|
|
71
|
+
* Creation inputs; absent for a cold resume, which loads the persisted
|
|
72
|
+
* session — including the delegation policy events a fresh creation seeded,
|
|
73
|
+
* so a resume never re-captures the parent's policy.
|
|
74
|
+
*/
|
|
75
|
+
create?: {
|
|
76
|
+
seed: readonly SessionEvent[] | undefined;
|
|
77
|
+
meta: NonNullable<CreateAgentOptions['meta']>;
|
|
78
|
+
/** Exact parent-log prefix length inside {@link seed}. */
|
|
79
|
+
inheritedEventCount: SessionLogOffsetType;
|
|
80
|
+
/** Policy captured at delegation: the parent's sandbox override plus the approval pin. */
|
|
81
|
+
delegatedPolicies: DelegatedPolicyOverrides;
|
|
82
|
+
/** Child-owned composition record appended after the inherited marker. */
|
|
83
|
+
descriptor: SubagentDescriptorData;
|
|
84
|
+
};
|
|
85
|
+
agentOptions: AgentOptions;
|
|
86
|
+
composition: {
|
|
87
|
+
persona?: string | undefined;
|
|
88
|
+
toolFilter?: ToolRestriction | undefined;
|
|
89
|
+
};
|
|
90
|
+
signal: AbortSignal;
|
|
91
|
+
}
|
|
92
|
+
/** Serialize each durable child's delivery, release, and disposal. */
|
|
93
|
+
export declare class ChildLock {
|
|
94
|
+
private tails;
|
|
95
|
+
/**
|
|
96
|
+
* Run `operation` after every previously queued operation for `childId`.
|
|
97
|
+
* @param childId - the durable child whose operations are linearized.
|
|
98
|
+
* @param operation - the critical section to run in order.
|
|
99
|
+
* @returns the operation's own settlement.
|
|
100
|
+
*/
|
|
101
|
+
run<T>(childId: SessionId, operation: () => Promise<T>): Promise<T>;
|
|
102
|
+
}
|
|
103
|
+
/** Own the complete process-local lifetime of continuable child Activations. */
|
|
104
|
+
export declare class ContinuableActivationRegistry {
|
|
105
|
+
private readonly ctx;
|
|
106
|
+
private readonly observeActivation;
|
|
107
|
+
/** Child session id → its live Activation. Process-local, never durable. */
|
|
108
|
+
private readonly resident;
|
|
109
|
+
/** Materializations admitted before drain, tracked through publication or rollback. */
|
|
110
|
+
private readonly materializations;
|
|
111
|
+
/** Per-child serializer shared by delivery, release, and disposal. */
|
|
112
|
+
readonly locks: ChildLock;
|
|
113
|
+
/** Structural Cordis owner of every Activation handle. */
|
|
114
|
+
readonly ownerCtx: Context;
|
|
115
|
+
/**
|
|
116
|
+
* Exact roots whose host teardown has begun, with the live lineage members
|
|
117
|
+
* observed under each root. Entries remain until that exact root leaves the
|
|
118
|
+
* Agent registry, closing admission throughout its host's teardown without
|
|
119
|
+
* poisoning a later same-id replacement.
|
|
120
|
+
*/
|
|
121
|
+
private readonly closingScopes;
|
|
122
|
+
private draining;
|
|
123
|
+
/**
|
|
124
|
+
* Build one registry inside the service's Agent-injected context.
|
|
125
|
+
* @param ctx - context providing Agents, Sessions, and teardown ownership.
|
|
126
|
+
* @param observeActivation - build the lifecycle observer for one residency epoch.
|
|
127
|
+
*/
|
|
128
|
+
constructor(ctx: Context, observeActivation: (provider: string, childId: SessionId, parent: Agent) => ActivationObserver);
|
|
129
|
+
/**
|
|
130
|
+
* Return the live Activation for a durable child id, if resident.
|
|
131
|
+
* @param childId - durable child session id to look up.
|
|
132
|
+
* @returns the process-local Activation, or `undefined` when it is not resident.
|
|
133
|
+
*/
|
|
134
|
+
get(childId: SessionId): Activation | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Reject one child identity already owned by a live Agent or Session.
|
|
137
|
+
* @param childId - proposed durable child session id.
|
|
138
|
+
*/
|
|
139
|
+
assertChildIdAvailable(childId: SessionId): void;
|
|
140
|
+
/**
|
|
141
|
+
* Pre-register `childId` in a continuation-managed parent's owned set so the
|
|
142
|
+
* parent cannot settle while a caller is still establishing or resuming that
|
|
143
|
+
* child. Returns a releaser for the failure path; it removes only a hold
|
|
144
|
+
* this call added, and leaves ownership in place once a live Activation for
|
|
145
|
+
* the child exists.
|
|
146
|
+
* @param parent - the live direct parent the operation is admitted under.
|
|
147
|
+
* @param childId - the durable child the operation addresses.
|
|
148
|
+
* @returns the failure-path releaser; a no-op when nothing was added.
|
|
149
|
+
*/
|
|
150
|
+
holdOwnership(parent: Agent, childId: SessionId): () => void;
|
|
151
|
+
/**
|
|
152
|
+
* Interrupt one live continuable child's current turn under the supplied authority.
|
|
153
|
+
* @param targetSessionId - the durable child session id to interrupt.
|
|
154
|
+
* @param authority - the human parent address or exact live ancestor Agent.
|
|
155
|
+
*/
|
|
156
|
+
interrupt(targetSessionId: SessionId, authority: {
|
|
157
|
+
readonly kind: 'user';
|
|
158
|
+
readonly parentSessionId: SessionId;
|
|
159
|
+
} | {
|
|
160
|
+
readonly kind: 'ancestor';
|
|
161
|
+
readonly agent: Agent;
|
|
162
|
+
}): void;
|
|
163
|
+
/**
|
|
164
|
+
* Send through a receiving parent's Activation inbox when it has one.
|
|
165
|
+
* @param parent - exact live Agent receiving the message.
|
|
166
|
+
* @param message - durable user message to deliver.
|
|
167
|
+
* @param delivery - receiving inbox destination.
|
|
168
|
+
*/
|
|
169
|
+
sendWaking(parent: Agent, message: UserMessage, delivery: SubagentDelivery): void;
|
|
170
|
+
/**
|
|
171
|
+
* Close admission, await every already-admitted materialization through
|
|
172
|
+
* publication or rollback, then dispose the stable live Activation graph
|
|
173
|
+
* child-first.
|
|
174
|
+
*/
|
|
175
|
+
drain(): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Stop only the continuable descendants of exact live host-owned parents.
|
|
178
|
+
* @param parents - exact live roots whose continuable descendants must stop.
|
|
179
|
+
*/
|
|
180
|
+
drainDescendants(parents: readonly Agent[]): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Release selected resident direct children of one exact live parent.
|
|
183
|
+
* @param parent - exact live direct parent authorizing the selected release.
|
|
184
|
+
* @param childIds - durable direct-child ids to release when resident.
|
|
185
|
+
*/
|
|
186
|
+
drainChildren(parent: Agent, childIds: readonly SessionId[]): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Reject new admission once the registry or this exact parent tree began draining.
|
|
189
|
+
* @param agent - exact live Agent whose lineage determines admission.
|
|
190
|
+
*/
|
|
191
|
+
assertAdmitting(agent: Agent): void;
|
|
192
|
+
/**
|
|
193
|
+
* Authorize one operation against the durable direct-parent lineage.
|
|
194
|
+
* @param parent - exact live Agent claiming direct-parent authority.
|
|
195
|
+
* @param childId - durable child session id addressed by the operation.
|
|
196
|
+
* @param parentSession - durable direct-parent id recorded by the child.
|
|
197
|
+
*/
|
|
198
|
+
authorizeLineage(parent: Agent, childId: SessionId, parentSession: SessionId | undefined): void;
|
|
199
|
+
/**
|
|
200
|
+
* Create or resume one child Agent and publish its Activation.
|
|
201
|
+
* @param inputs - reconstruction and admission inputs for the residency epoch.
|
|
202
|
+
* @returns the published process-local Activation.
|
|
203
|
+
*/
|
|
204
|
+
materialize(inputs: MaterializeInputs): Promise<Activation>;
|
|
205
|
+
/**
|
|
206
|
+
* Cross the final admission cutoff and submit without yielding.
|
|
207
|
+
* @param activation - the exact resident child receiving the message.
|
|
208
|
+
* @param message - the already-built durable user message.
|
|
209
|
+
* @param delivery - the Agent inbox destination.
|
|
210
|
+
* @param parent - exact live direct parent authorizing admission.
|
|
211
|
+
* @param signal - caller cancellation before inbox acceptance.
|
|
212
|
+
* @returns the accepted durable message id.
|
|
213
|
+
*/
|
|
214
|
+
submitAdmitted(activation: Activation, message: UserMessage, delivery: SubagentDelivery, parent: Agent, signal: AbortSignal): MessageId;
|
|
215
|
+
/**
|
|
216
|
+
* Stop and release one Activation through its memoized close transaction.
|
|
217
|
+
* @param activation - exact residency epoch to close.
|
|
218
|
+
* @param finalStateFlushed - whether natural settlement already flushed final state.
|
|
219
|
+
* @returns the shared close transaction.
|
|
220
|
+
*/
|
|
221
|
+
dispose(activation: Activation, finalStateFlushed?: boolean): Promise<void>;
|
|
222
|
+
/** Dispose independent roots and report every branch failure after all settle. */
|
|
223
|
+
private disposeRoots;
|
|
224
|
+
/** Return the retained member set for one exact scoped-teardown root. */
|
|
225
|
+
private closingMembers;
|
|
226
|
+
/** Return the exact currently resolvable ancestry from `agent` upward. */
|
|
227
|
+
private liveLineage;
|
|
228
|
+
/** Return the teardown that closed continuable admission for this agent's lineage. */
|
|
229
|
+
private closingTeardownFor;
|
|
230
|
+
/** Perform one tracked materialization through publication or rollback. */
|
|
231
|
+
private materializeTracked;
|
|
232
|
+
/** Release an Activation whose start edge was not published. */
|
|
233
|
+
private rollbackUnpublished;
|
|
234
|
+
/** Register the child in a continuation-managed parent's owned set. */
|
|
235
|
+
private acquireOwnership;
|
|
236
|
+
/** Remove one child from its live owner's set and let that owner re-check settlement. */
|
|
237
|
+
private releaseOwnership;
|
|
238
|
+
/** Let a settlement watcher re-check residency after relevant state changes. */
|
|
239
|
+
private wake;
|
|
240
|
+
/** Follow one Activation to natural settlement. */
|
|
241
|
+
private watchSettlement;
|
|
242
|
+
/** Classify one Inbox and owned-child observation without reading Agent execution state. */
|
|
243
|
+
private settlementState;
|
|
244
|
+
/** Propagate stop synchronously, then finish the child-first release. */
|
|
245
|
+
private finishDisposal;
|
|
246
|
+
/** Tell the durable direct parent how this Activation ended. */
|
|
247
|
+
private notifySettlement;
|
|
248
|
+
/** Request a best-effort final session flush before closing natural-settlement admission. */
|
|
249
|
+
private flushFinalState;
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=continuation-activation.d.ts.map
|