@myagentroam/agent 0.11.39 → 0.11.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/catalog-file.d.ts +2 -0
- package/dist/cli/main.js +11 -4
- package/dist/cli/subagent/control.d.ts +56 -0
- package/dist/cli/subagent/control.js +219 -0
- package/dist/cli/subagent/history.d.ts +17 -0
- package/dist/cli/subagent/history.js +85 -0
- package/dist/cli/subagent/index.d.ts +10 -0
- package/dist/cli/subagent/index.js +94 -0
- package/dist/cli/subagent/native.d.ts +91 -0
- package/dist/cli/subagent/native.js +359 -0
- package/dist/cli/subagent/observations.d.ts +57 -0
- package/dist/cli/subagent/observations.js +351 -0
- package/dist/cli/subagent/query.d.ts +4 -0
- package/dist/cli/subagent/query.js +114 -0
- package/dist/cli/subagent/resources.d.ts +3 -0
- package/dist/cli/subagent/resources.js +112 -0
- package/dist/cli/subagent/snapshot.d.ts +77 -0
- package/dist/cli/subagent/snapshot.js +127 -0
- package/dist/cli/subagent/start.d.ts +24 -0
- package/dist/cli/subagent/start.js +201 -0
- package/dist/cli/subagent/wait-output.d.ts +19 -0
- package/dist/cli/subagent/wait-output.js +56 -0
- package/dist/cli/subagent/wait.d.ts +175 -0
- package/dist/cli/subagent/wait.js +453 -0
- package/dist/extensions/contracts.d.ts +2 -5
- package/dist/extensions/manager.d.ts +0 -2
- package/dist/extensions/manager.js +1 -2
- package/dist/extensions/models.d.ts +3 -0
- package/dist/extensions/operation.d.ts +8 -0
- package/dist/extensions/operation.js +3 -0
- package/dist/extensions/services.d.ts +9 -1
- package/dist/extensions/services.js +26 -3
- package/dist/extensions/session-context.d.ts +18 -0
- package/dist/extensions/session-context.js +4 -0
- package/dist/extensions/session-input.d.ts +2 -2
- package/dist/extensions/session-input.js +3 -4
- package/dist/extensions/session-messages.d.ts +1 -1
- package/dist/extensions/session-tools.js +20 -3
- package/dist/extensions/session.d.ts +1 -4
- package/dist/extensions/session.js +2 -16
- package/dist/extensions/tools.js +21 -3
- package/dist/extensions.d.ts +5 -2
- package/dist/extensions.js +2 -1
- package/dist/host/local-agent-host.d.ts +2 -2
- package/dist/host/local-exec-tool.d.ts +1 -1
- package/dist/host/local-exec-tool.js +28 -3
- package/dist/host/local-tool-registry.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/model/configuration.d.ts +3 -1
- package/dist/model/configuration.js +1 -0
- package/dist/model/openai-responses.js +5 -0
- package/dist/model/responses-request.js +9 -0
- package/dist/prompts/index.js +1 -3
- package/dist/prompts/resources.d.ts +1 -5
- package/dist/prompts/resources.js +3 -12
- package/dist/prompts/subagent.d.ts +1 -1
- package/dist/prompts/subagent.js +1 -1
- package/dist/runtime/context/gc-candidates-web.d.ts +6 -0
- package/dist/runtime/context/gc-candidates-web.js +53 -1
- package/dist/runtime/context/gc-candidates.js +1 -9
- package/dist/runtime/context/gc.js +19 -11
- package/dist/runtime/context/projection.js +1 -0
- package/dist/runtime/events.d.ts +4 -3
- package/dist/runtime/execution-handle.d.ts +2 -0
- package/dist/runtime/wait.js +12 -2
- package/dist/sdk/agent.js +94 -5
- package/dist/sdk/execution-context-coordinator.d.ts +2 -3
- package/dist/sdk/execution-context-coordinator.js +3 -3
- package/dist/sdk/execution-input.d.ts +3 -4
- package/dist/sdk/execution-input.js +31 -25
- package/dist/sdk/execution-round-preparation.d.ts +1 -1
- package/dist/sdk/execution-round-preparation.js +4 -4
- package/dist/sdk/execution-tool-catalog.js +2 -10
- package/dist/sdk/execution-tool-scope.d.ts +1 -3
- package/dist/sdk/execution-tool-scope.js +10 -12
- package/dist/sdk/extension-models.js +3 -0
- package/dist/sdk/extension-session-launch.d.ts +3 -2
- package/dist/sdk/extension-session-launch.js +2 -3
- package/dist/sdk/extension-tools.js +0 -2
- package/dist/sdk/native-steer.d.ts +2 -2
- package/dist/sdk/native-steer.js +2 -2
- package/dist/sdk/session-composition.d.ts +2 -17
- package/dist/sdk/session-execution-factory.d.ts +2 -3
- package/dist/sdk/session-execution-factory.js +20 -114
- package/dist/sdk/session-execution.d.ts +13 -7
- package/dist/sdk/session-execution.js +11 -3
- package/dist/sdk/session-extension-messages.d.ts +1 -3
- package/dist/sdk/session-extension-messages.js +14 -9
- package/dist/sdk/session-extension-prompt.js +1 -3
- package/dist/sdk/session-maintenance.d.ts +1 -0
- package/dist/sdk/session-maintenance.js +16 -7
- package/dist/sdk/session-open.d.ts +2 -3
- package/dist/sdk/session-open.js +5 -24
- package/dist/sdk/session-runtime.d.ts +19 -8
- package/dist/sdk/session-runtime.js +36 -30
- package/dist/sdk/session.d.ts +3 -2
- package/dist/sdk/session.js +22 -89
- package/dist/sdk/types.d.ts +36 -0
- package/dist/session/catalog.d.ts +22 -1
- package/dist/session/catalog.js +102 -0
- package/dist/session/context-gc-checkpoint.js +30 -1
- package/dist/session/context-gc-contract.d.ts +7 -0
- package/dist/session/context-gc-replacements.d.ts +3 -0
- package/dist/session/context-gc-replacements.js +26 -0
- package/dist/session/store/contracts.d.ts +2 -2
- package/dist/session/store/jsonl/directory-index.d.ts +1 -1
- package/dist/session/store/jsonl/directory-index.js +18 -17
- package/dist/session/store/jsonl/history.js +1 -1
- package/dist/session/store/jsonl/index-transaction.js +2 -8
- package/dist/session/store/jsonl/jsonl-store.d.ts +1 -1
- package/dist/session/store/jsonl/jsonl-store.js +24 -9
- package/dist/session/types.d.ts +1 -0
- package/dist/tools/agent/sleep.js +1 -1
- package/dist/tools/callers.js +1 -12
- package/dist/tools/code-mode/dispatch.js +5 -2
- package/dist/tools/code-mode/index.d.ts +1 -1
- package/dist/tools/code-mode/index.js +2 -0
- package/dist/tools/contracts.d.ts +20 -0
- package/dist/tools/execution-limits.d.ts +5 -20
- package/dist/tools/execution-limits.js +0 -2
- package/dist/tools/execution.js +16 -4
- package/dist/tools/local/exec.js +8 -2
- package/dist/tools/output-projection.d.ts +5 -2
- package/dist/tools/output-projection.js +133 -92
- package/dist/tools/registry.js +1 -13
- package/dist/tools/runtime-context.d.ts +1 -21
- package/package.json +2 -2
- package/dist/extensions/agents.d.ts +0 -100
- package/dist/extensions/agents.js +0 -121
- package/dist/runtime/context/gc-candidates-subagent.d.ts +0 -6
- package/dist/runtime/context/gc-candidates-subagent.js +0 -100
- package/dist/sdk/extension-agent-controller.d.ts +0 -3
- package/dist/sdk/extension-agent-controller.js +0 -69
- package/dist/sdk/extension-agents.d.ts +0 -9
- package/dist/sdk/extension-agents.js +0 -58
- package/dist/sdk/subagent-backend.d.ts +0 -3
- package/dist/sdk/subagent-backend.js +0 -49
- package/dist/subagent/contracts.d.ts +0 -107
- package/dist/subagent/contracts.js +0 -1
- package/dist/subagent/limits.d.ts +0 -17
- package/dist/subagent/limits.js +0 -17
- package/dist/subagent/model-update.d.ts +0 -2
- package/dist/subagent/model-update.js +0 -81
- package/dist/subagent/session-controller.d.ts +0 -87
- package/dist/subagent/session-controller.js +0 -1343
- package/dist/subagent/task.d.ts +0 -134
- package/dist/subagent/task.js +0 -436
- package/dist/subagent/turn-contracts.d.ts +0 -64
- package/dist/subagent/turn-contracts.js +0 -1
- package/dist/subagent/wait-targets.d.ts +0 -10
- package/dist/subagent/wait-targets.js +0 -26
- package/dist/subagent/wait.d.ts +0 -26
- package/dist/subagent/wait.js +0 -73
- package/dist/tools/agent/agent-cancel.d.ts +0 -7
- package/dist/tools/agent/agent-cancel.js +0 -29
- package/dist/tools/agent/agent-message.d.ts +0 -7
- package/dist/tools/agent/agent-message.js +0 -57
- package/dist/tools/agent/agent-start.d.ts +0 -12
- package/dist/tools/agent/agent-start.js +0 -106
- package/dist/tools/agent/agent-wait.d.ts +0 -7
- package/dist/tools/agent/agent-wait.js +0 -91
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/** Owns round retries when late input or resource collection invalidates a candidate. */
|
|
2
2
|
export function createExecutionRoundPreparer(ports) {
|
|
3
3
|
return async (continuation) => {
|
|
4
|
-
let
|
|
4
|
+
let includeSessionContext = true;
|
|
5
5
|
for (;;) {
|
|
6
|
-
await ports.prepareInputs(
|
|
6
|
+
await ports.prepareInputs(includeSessionContext);
|
|
7
7
|
const candidate = await ports.buildCandidate(continuation);
|
|
8
8
|
if (await ports.adoptLateInput()) {
|
|
9
|
-
|
|
9
|
+
includeSessionContext = false;
|
|
10
10
|
continue;
|
|
11
11
|
}
|
|
12
12
|
const prepared = await ports.prepareResources(candidate);
|
|
13
13
|
if ('round' in prepared)
|
|
14
14
|
return prepared.round;
|
|
15
|
-
|
|
15
|
+
includeSessionContext = false;
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
}
|
|
@@ -5,7 +5,6 @@ import { assertMcpToolCatalog } from '../tools/mcp/catalog.js';
|
|
|
5
5
|
import { DeferredMcpRegistry } from '../tools/mcp/tool-search.js';
|
|
6
6
|
import { discoveredMcpToolNames, rebindMcpToolSearchOutputs } from '../tools/mcp/history.js';
|
|
7
7
|
import { BUILTIN_TOOL_DEFINITIONS } from '../tools/registry.js';
|
|
8
|
-
import { agentStartToolDefinitionWithModels } from '../tools/agent/agent-start.js';
|
|
9
8
|
import { toolCallers } from '../tools/callers.js';
|
|
10
9
|
import { ExecutionToolSources } from './extension-tools.js';
|
|
11
10
|
/** Initializes one Execution's catalog before Extension attachment owns its bindings. */
|
|
@@ -36,11 +35,7 @@ export async function initializeExecutionToolCatalog(input) {
|
|
|
36
35
|
const extensions = (await host.listExecutionExtensions?.(context)) ?? {};
|
|
37
36
|
if (extensions.tools?.some((tool) => tool.name.startsWith('mcp__')))
|
|
38
37
|
throw new AgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Host tools cannot use the MCP namespace.');
|
|
39
|
-
const builtins = BUILTIN_TOOL_DEFINITIONS
|
|
40
|
-
? agentStartToolDefinitionWithModels([...input.models.values()]
|
|
41
|
-
.filter((configuration) => configuration.conversationModel !== false)
|
|
42
|
-
.map(({ id, name, reasoningEfforts }) => ({ id, name, reasoningEfforts })))
|
|
43
|
-
: tool);
|
|
38
|
+
const builtins = BUILTIN_TOOL_DEFINITIONS;
|
|
44
39
|
const tools = [
|
|
45
40
|
...builtins,
|
|
46
41
|
...(extensions.tools ?? []),
|
|
@@ -62,10 +57,7 @@ export class ExecutionToolCatalog {
|
|
|
62
57
|
}
|
|
63
58
|
eligible(tool) {
|
|
64
59
|
toolCallers(tool);
|
|
65
|
-
if (this.input.child &&
|
|
66
|
-
(tool.agentScope === 'ROOT_ONLY' ||
|
|
67
|
-
tool.name.startsWith('agent_') ||
|
|
68
|
-
tool.name === 'question'))
|
|
60
|
+
if (this.input.child && (tool.agentScope === 'ROOT_ONLY' || tool.name === 'question'))
|
|
69
61
|
return false;
|
|
70
62
|
if (tool.name === 'tool_search')
|
|
71
63
|
return this.input.registry.hasDeferred;
|
|
@@ -11,7 +11,6 @@ import type { ExtensionSession } from '../extensions/session.js';
|
|
|
11
11
|
import type { ExtensionOperations, ExtensionOperationContext } from '../extensions/operation.js';
|
|
12
12
|
import type { ExtensionPromptComposition } from '../extensions/prompt-composition.js';
|
|
13
13
|
import type { DeferredMcpRegistry } from '../tools/mcp/tool-search.js';
|
|
14
|
-
import type { SubagentSessionController } from '../subagent/session-controller.js';
|
|
15
14
|
import type { ResolvedModelConfiguration } from './model-runtime.js';
|
|
16
15
|
import type { ExecutionMode } from './types.js';
|
|
17
16
|
import type { CompactFlight } from '../runtime/compaction/coordinator.js';
|
|
@@ -31,8 +30,7 @@ export declare function createExecutionToolScope(input: {
|
|
|
31
30
|
readonly todo: ToolRuntimeContext['todo'];
|
|
32
31
|
readonly waitInterrupt: ToolRuntimeContext['waitInterrupt'];
|
|
33
32
|
readonly skills: ToolRuntimeContext['skills'];
|
|
34
|
-
readonly
|
|
35
|
-
readonly coreExtensions: Pick<ExtensionSession, 'epoch' | 'agentAction' | 'withTools' | 'invoke' | 'assertLive' | 'pin' | 'diagnose' | 'composeModelSystem'>;
|
|
33
|
+
readonly coreExtensions: Pick<ExtensionSession, 'epoch' | 'withTools' | 'invoke' | 'assertLive' | 'pin' | 'diagnose' | 'composeModelSystem' | 'services'>;
|
|
36
34
|
readonly operations: Pick<ExtensionOperations, 'enter'>;
|
|
37
35
|
readonly scheduleTool: SessionRuntime['scheduleTool'];
|
|
38
36
|
readonly sources: Pick<ExecutionToolSources, 'withFrame' | 'assertActive'>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { bindAgentController } from './extension-agent-controller.js';
|
|
2
1
|
import { createExecutionCodeModeContext } from './execution-code-mode.js';
|
|
3
2
|
import { currentExecutionImages } from '../tools/output-projection.js';
|
|
4
3
|
import { requestSmartCompaction } from '../runtime/compaction/smart.js';
|
|
5
4
|
import { renderPromptSections } from '../prompts/prompt-sections.js';
|
|
6
5
|
import { withToolPermissions } from '../tools/permissions.js';
|
|
6
|
+
import { SESSION_CONTEXT_PROVIDER } from '../extensions/session-context.js';
|
|
7
7
|
/** Capture immutable round tool identities, parent scope and resource capabilities. */
|
|
8
8
|
export function createExecutionToolScope(input) {
|
|
9
|
-
const { store, host, sessionId, executionId, turnId, mode, controller, sessionWriterOwner, selectedModel, permissionPolicy, todo, waitInterrupt, skills,
|
|
9
|
+
const { store, host, sessionId, executionId, turnId, mode, controller, sessionWriterOwner, selectedModel, permissionPolicy, todo, waitInterrupt, skills, coreExtensions, operations, scheduleTool, sources, mcpRegistry, autoPermissionPrompt, currentExecutionToolImages, inputImageBytes, snapshotTools, baseTools, captureTools, promptComposition, smartInput, modelInputImages, startCompact, preparedPrompt, clearPreparedPrompt, operation, emit } = input;
|
|
10
10
|
const captureRoundToolScope = () => {
|
|
11
11
|
const roundTools = snapshotTools();
|
|
12
12
|
const availableBindings = captureTools();
|
|
@@ -22,10 +22,10 @@ export function createExecutionToolScope(input) {
|
|
|
22
22
|
const roundMcpExpectations = new Map(roundTools
|
|
23
23
|
.filter((tool) => roundBindings.get(tool.name)?.mcp !== undefined)
|
|
24
24
|
.map((tool) => [tool.name, mcpRegistry.expectedTool(tool.name)]));
|
|
25
|
-
const parentFrame = subagents === undefined || mode === 'compact'
|
|
26
|
-
? undefined
|
|
27
|
-
: subagents.captureParentFrame(executionId);
|
|
28
25
|
const roundSmartInput = smartInput();
|
|
26
|
+
const modelMessages = mode === 'compact'
|
|
27
|
+
? undefined
|
|
28
|
+
: coreExtensions.services.resolve(SESSION_CONTEXT_PROVIDER)?.wake;
|
|
29
29
|
const toolContext = {
|
|
30
30
|
imageStore: store,
|
|
31
31
|
host: host,
|
|
@@ -47,12 +47,7 @@ export function createExecutionToolScope(input) {
|
|
|
47
47
|
permissionPolicy,
|
|
48
48
|
writeToolResultResource: (text) => store.writeToolResultResource(sessionId, text),
|
|
49
49
|
todo,
|
|
50
|
-
...(
|
|
51
|
-
? {}
|
|
52
|
-
: {
|
|
53
|
-
subagents: bindAgentController(subagents.captureExecution(executionId), coreExtensions.agentAction),
|
|
54
|
-
subagentMessages: subagents.modelMessages
|
|
55
|
-
}),
|
|
50
|
+
...(modelMessages === undefined ? {} : { contextUpdates: modelMessages }),
|
|
56
51
|
mode,
|
|
57
52
|
sessionId,
|
|
58
53
|
executionId,
|
|
@@ -72,9 +67,12 @@ export function createExecutionToolScope(input) {
|
|
|
72
67
|
...(context.parentCallId === undefined
|
|
73
68
|
? {}
|
|
74
69
|
: { parentToolCallId: context.parentCallId }),
|
|
70
|
+
...(context.waitInterrupt === undefined
|
|
71
|
+
? {}
|
|
72
|
+
: { waitInterrupt: context.waitInterrupt }),
|
|
75
73
|
signal: context.signal
|
|
76
74
|
}, (operation) => coreExtensions.invoke(call, operation, roundBindings))));
|
|
77
|
-
return sources.withFrame(context,
|
|
75
|
+
return sources.withFrame(context, invoke);
|
|
78
76
|
}
|
|
79
77
|
};
|
|
80
78
|
const recentImages = async () => {
|
|
@@ -16,6 +16,9 @@ export function createExtensionModels(state, createAdapter, activeAdapters, reso
|
|
|
16
16
|
maxOutputTokens: model.maxOutputTokens,
|
|
17
17
|
inputCapabilities: Object.freeze([...model.inputCapabilities]),
|
|
18
18
|
reasoningEfforts: Object.freeze([...model.reasoningEfforts]),
|
|
19
|
+
defaultReasoningEffort: model.defaultReasoningEffort,
|
|
20
|
+
conversationModel: model.conversationModel !== false,
|
|
21
|
+
subagentModel: model.subagentModel === true,
|
|
19
22
|
isDefault: model.id === defaultModelId
|
|
20
23
|
})));
|
|
21
24
|
},
|
|
@@ -3,7 +3,7 @@ import type { ExtensionOperationContext } from '../extensions/operation.js';
|
|
|
3
3
|
import type { ExecutionMode, RunInput } from './types.js';
|
|
4
4
|
import type { InternalExecutionHandle, InternalExecutionOptions } from './session-execution.js';
|
|
5
5
|
/** Adapts committed Extension input to an independently owned Execution. */
|
|
6
|
-
export declare function createExtensionSessionLaunch(
|
|
6
|
+
export declare function createExtensionSessionLaunch(start: (mode: ExecutionMode, input: RunInput, options: InternalExecutionOptions) => InternalExecutionHandle): (entry: SessionInputEntry, request: Exclude<ExtensionSessionRequest, {
|
|
7
7
|
kind: "append";
|
|
8
8
|
}>, call: ExtensionOperationContext) => Promise<InternalExecutionHandle & {
|
|
9
9
|
inputCommitted: Promise<ExtensionSessionActionResult>;
|
|
@@ -14,5 +14,6 @@ export declare function extensionInputSource(call: ExtensionOperationContext, pr
|
|
|
14
14
|
ownerInstanceId?: string;
|
|
15
15
|
extensionId?: string;
|
|
16
16
|
operationId: string;
|
|
17
|
-
|
|
17
|
+
sessionId: string;
|
|
18
|
+
actor: "model" | "extension" | "sdk" | "code-mode";
|
|
18
19
|
};
|
|
@@ -2,10 +2,8 @@ import { AgentError } from '../error.js';
|
|
|
2
2
|
import { DEFAULT_COMPACTION_FOCUS } from '../runtime/compaction/history.js';
|
|
3
3
|
import { recordSessionInputCommit } from '../extensions/session-input.js';
|
|
4
4
|
/** Adapts committed Extension input to an independently owned Execution. */
|
|
5
|
-
export function createExtensionSessionLaunch(
|
|
5
|
+
export function createExtensionSessionLaunch(start) {
|
|
6
6
|
return async (entry, request, call) => {
|
|
7
|
-
if (sourceType !== 'user')
|
|
8
|
-
throw new AgentError('MAR_AGENT_SESSION_INPUT_UNAVAILABLE', 'Idle subagent input must use its task controller.');
|
|
9
7
|
let resolveInput;
|
|
10
8
|
let rejectInput;
|
|
11
9
|
const inputCommitted = new Promise((resolve, reject) => {
|
|
@@ -64,6 +62,7 @@ export function createExtensionSessionLaunch(sourceType, start) {
|
|
|
64
62
|
export function extensionInputSource(call, provenance, modelAttribution) {
|
|
65
63
|
return {
|
|
66
64
|
operationId: call.operationId,
|
|
65
|
+
sessionId: call.sessionId,
|
|
67
66
|
actor: call.actor,
|
|
68
67
|
...(call.extensionId ? { extensionId: call.extensionId } : {}),
|
|
69
68
|
...(call.ownerInstanceId ? { ownerInstanceId: call.ownerInstanceId } : {}),
|
|
@@ -38,8 +38,6 @@ export class ExecutionToolSources {
|
|
|
38
38
|
return false;
|
|
39
39
|
if (definition.name === 'skill')
|
|
40
40
|
return context.skills.size > 0;
|
|
41
|
-
if (['agent_start', 'agent_wait', 'agent_message', 'agent_cancel'].includes(definition.name))
|
|
42
|
-
return context.subagents !== undefined;
|
|
43
41
|
if (definition.name === 'tool_search')
|
|
44
42
|
return (this.#currentFrame()?.searchMcpTools !== undefined || this.#scope !== undefined);
|
|
45
43
|
return true;
|
|
@@ -11,10 +11,10 @@ export declare function createNativeSteer(input: {
|
|
|
11
11
|
isOpen(): boolean;
|
|
12
12
|
operation<T>(action: (call: ExtensionOperationContext) => T): T;
|
|
13
13
|
admit(content: ExtensionPromptInput, call: ExtensionOperationContext, write: (content: ExtensionPromptInput, call: ExtensionOperationContext) => Promise<ExtensionPromptResult>): Promise<unknown>;
|
|
14
|
-
receive(content: ExtensionPromptInput, clientMessageId: string, call: ExtensionOperationContext): Promise<SessionRecord>;
|
|
14
|
+
receive(content: ExtensionPromptInput, clientMessageId: string, call: ExtensionOperationContext, source?: import('../extensions/session-input.js').ExtensionInputSource): Promise<SessionRecord>;
|
|
15
15
|
notify(entry: Extract<SteerResult, {
|
|
16
16
|
status: 'accepted';
|
|
17
17
|
}>['entry']): Promise<unknown>;
|
|
18
18
|
diagnose(): void;
|
|
19
19
|
wake(): void;
|
|
20
|
-
}): (request: SteerInput) => Promise<SteerResult>;
|
|
20
|
+
}): (request: SteerInput, source?: import('../extensions/session-input.js').ExtensionInputSource) => Promise<SteerResult>;
|
package/dist/sdk/native-steer.js
CHANGED
|
@@ -5,7 +5,7 @@ import { imageMetadata } from '../session/catalog.js';
|
|
|
5
5
|
export function createNativeSteer(input) {
|
|
6
6
|
const retries = new Map();
|
|
7
7
|
let admissionTail = Promise.resolve();
|
|
8
|
-
return async (request) => {
|
|
8
|
+
return async (request, source) => {
|
|
9
9
|
if (request.expectedExecutionId !== input.executionId)
|
|
10
10
|
return Promise.resolve({ status: 'notAccepted' });
|
|
11
11
|
const previous = retries.get(request.clientMessageId);
|
|
@@ -39,7 +39,7 @@ export function createNativeSteer(input) {
|
|
|
39
39
|
result.resolve({ status: 'notAccepted' });
|
|
40
40
|
return {};
|
|
41
41
|
}
|
|
42
|
-
const record = await input.receive(actual, request.clientMessageId, effective);
|
|
42
|
+
const record = await input.receive(actual, request.clientMessageId, effective, source);
|
|
43
43
|
committed = true;
|
|
44
44
|
entry.nativeSteer.recordId = record.recordId;
|
|
45
45
|
const payload = record.payload;
|
|
@@ -1,28 +1,12 @@
|
|
|
1
1
|
import type { AgentHost, HostDescription } from '../host/contracts.js';
|
|
2
2
|
import type { ExtensionManager } from '../extensions/manager.js';
|
|
3
|
-
import type { ExtensionOperationContext } from '../extensions/operation.js';
|
|
4
|
-
import type { AgentReasoningEffort } from '../model/configuration.js';
|
|
5
3
|
import type { ModelAdapter } from '../model/contracts.js';
|
|
6
4
|
import type { SessionStore } from '../session/store/contracts.js';
|
|
7
|
-
import type { SubagentMailboxMessage, SubagentMessageDelivery, SubagentTurnHandle } from '../subagent/session-controller.js';
|
|
8
5
|
import type { ResolvedModelConfiguration } from './model-runtime.js';
|
|
9
6
|
import type { SessionRegistry } from './session-registry.js';
|
|
10
7
|
import type { SessionRuntime } from './session-runtime.js';
|
|
11
8
|
import type { AgentSession, CreateAgentOptions } from './types.js';
|
|
12
|
-
export
|
|
13
|
-
startSubagentTurn(input: {
|
|
14
|
-
readonly permissionMode?: import('../tools/permissions.js').PermissionMode;
|
|
15
|
-
readonly prompt: string;
|
|
16
|
-
readonly modelId: string;
|
|
17
|
-
readonly reasoningEffort: AgentReasoningEffort;
|
|
18
|
-
readonly role: 'general-purpose' | 'explore';
|
|
19
|
-
readonly initialMailbox: readonly SubagentMailboxMessage[];
|
|
20
|
-
readonly turnId: string;
|
|
21
|
-
readonly delivery?: SubagentMessageDelivery;
|
|
22
|
-
readonly mcpExecutionScopeId?: string;
|
|
23
|
-
readonly origin?: ExtensionOperationContext;
|
|
24
|
-
}): SubagentTurnHandle;
|
|
25
|
-
}
|
|
9
|
+
export type InternalAgentSession = AgentSession;
|
|
26
10
|
/** Agent-owned resources and identities shared with Session orchestration. */
|
|
27
11
|
export interface AgentSessionComposition {
|
|
28
12
|
readonly activeExecutionAdapters: {
|
|
@@ -31,6 +15,7 @@ export interface AgentSessionComposition {
|
|
|
31
15
|
};
|
|
32
16
|
readonly sessionRuntimes: SessionRegistry<SessionRuntime>;
|
|
33
17
|
readonly sessionWriterOwner: object;
|
|
18
|
+
readonly onExecutionRegistered: (runtime: SessionRuntime) => void;
|
|
34
19
|
}
|
|
35
20
|
export interface SessionServices {
|
|
36
21
|
readonly host: AgentHost;
|
|
@@ -11,7 +11,7 @@ import type { ToolHost } from '../tools/runtime-context.js';
|
|
|
11
11
|
import { type InternalExecutionHandle, type InternalExecutionOptions } from './session-execution.js';
|
|
12
12
|
import { SessionRuntime } from './session-runtime.js';
|
|
13
13
|
import type { CreateAgentOptions, ExecutionMode, RunInput } from './types.js';
|
|
14
|
-
import type { AgentSessionComposition,
|
|
14
|
+
import type { AgentSessionComposition, SessionServices } from './session-composition.js';
|
|
15
15
|
/** Composes the execution-owned workflow from Session capabilities. */
|
|
16
16
|
export declare function createSessionExecutionFactory(ports: {
|
|
17
17
|
assertCanStart: SessionServices['assertCanStart'];
|
|
@@ -26,7 +26,7 @@ export declare function createSessionExecutionFactory(ports: {
|
|
|
26
26
|
sessionWriterOwner: object;
|
|
27
27
|
activeExecutionAdapters: AgentSessionComposition['activeExecutionAdapters'];
|
|
28
28
|
sessionId: string;
|
|
29
|
-
sessionRuntime: Pick<SessionRuntime, 'assertCanExecute' | 'bindExecutionContext' | 'deactivateExecution' | 'joinRecordProjection' | 'registerExecution' | '
|
|
29
|
+
sessionRuntime: Pick<SessionRuntime, 'assertCanExecute' | 'bindExecutionContext' | 'deactivateExecution' | 'joinRecordProjection' | 'registerExecution' | 'publishEvent' | 'restoreExecutionState' | 'scheduleTool' | 'sessionBackend' | 'unbindExecutionContext' | 'unregisterExecution' | 'updateContextualWorldState' | 'recordRequest' | 'completeRequest'>;
|
|
30
30
|
sessionSource: Awaited<ReturnType<SessionStore['getSession']>>['source'];
|
|
31
31
|
logicalWorkspace: string;
|
|
32
32
|
instructionWorkspace: string;
|
|
@@ -39,5 +39,4 @@ export declare function createSessionExecutionFactory(ports: {
|
|
|
39
39
|
appendExtensionMessage(entry: SessionInputEntry, request: Extract<ExtensionSessionRequest, {
|
|
40
40
|
kind: 'append';
|
|
41
41
|
}>, call: ExtensionOperationContext): Promise<ExtensionSessionActionResult>;
|
|
42
|
-
startSubagentTurn(id: string, input: Parameters<InternalAgentSession['startSubagentTurn']>[0]): Promise<ReturnType<InternalAgentSession['startSubagentTurn']>>;
|
|
43
42
|
}): (mode: ExecutionMode, input: RunInput, internal?: InternalExecutionOptions) => InternalExecutionHandle;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { restoreMessages } from '../runtime/context/restore.js';
|
|
2
2
|
import { latestModelUsage, reasoningEffortBaseline } from '../runtime/context/usage.js';
|
|
3
3
|
import { publicModelUsage } from '../runtime/event-projection.js';
|
|
4
|
+
import { truncateModelText } from '../runtime/token-budget.js';
|
|
4
5
|
import { executeRoundTools } from '../tools/execution.js';
|
|
5
6
|
import { rebindMcpToolSearchOutputs } from '../tools/mcp/history.js';
|
|
6
7
|
import { ExecutionToolPermissions, projectPermissionTool, resolvePermissionMode, withToolPermissions } from '../tools/permissions.js';
|
|
@@ -24,6 +25,7 @@ import { ResourceInputProjection } from './resource-input.js';
|
|
|
24
25
|
import { createHash, randomUUID } from 'node:crypto';
|
|
25
26
|
import { AgentError, describeAgentError } from '../error.js';
|
|
26
27
|
import { transformCoreModelStream } from '../extensions/model-stream.js';
|
|
28
|
+
import { SESSION_CONTEXT_PROVIDER } from '../extensions/session-context.js';
|
|
27
29
|
import { invokeCorePromptSubmission } from '../extensions/prompt-input.js';
|
|
28
30
|
import { prepareModelConfiguration } from '../model/request-configuration.js';
|
|
29
31
|
import { MAR_AGENT_PROMPT_VERSION } from '../prompts/index.js';
|
|
@@ -38,12 +40,9 @@ import { loadAgentInstructions, renderAgentInstructions } from '../runtime/conte
|
|
|
38
40
|
import { normalizeMessagesForModel } from '../runtime/context/normalize.js';
|
|
39
41
|
import { compactSummaryFromCheckpoint } from '../session/record-projection.js';
|
|
40
42
|
import { SessionExecution } from './session-execution.js';
|
|
41
|
-
function restoreSubagentOrigin(origin) {
|
|
42
|
-
return { ...origin.correlation, signal: origin.signal };
|
|
43
|
-
}
|
|
44
43
|
/** Composes the execution-owned workflow from Session capabilities. */
|
|
45
44
|
export function createSessionExecutionFactory(ports) {
|
|
46
|
-
const { assertCanStart, extensions: extensionManager, baseTools: extensionBaseTools, hasCustomAdapters, modelState, host, store, description, settings, sessionWriterOwner, activeExecutionAdapters, sessionId, sessionRuntime, sessionSource, logicalWorkspace, instructionWorkspace, currentEnvironment, buildSessionPromptSections, sessionAdapter, refreshSessionAdapters, sessionInputs, withRecordProjection, appendExtensionMessage
|
|
45
|
+
const { assertCanStart, extensions: extensionManager, baseTools: extensionBaseTools, hasCustomAdapters, modelState, host, store, description, settings, sessionWriterOwner, activeExecutionAdapters, sessionId, sessionRuntime, sessionSource, logicalWorkspace, instructionWorkspace, currentEnvironment, buildSessionPromptSections, sessionAdapter, refreshSessionAdapters, sessionInputs, withRecordProjection, appendExtensionMessage } = ports;
|
|
47
46
|
const execution = (mode, input, internal = {}) => {
|
|
48
47
|
assertCanStart(sessionId);
|
|
49
48
|
sessionRuntime.assertCanExecute();
|
|
@@ -83,49 +82,6 @@ export function createSessionExecutionFactory(ports) {
|
|
|
83
82
|
const manualCompactionId = mode === 'compact' ? randomUUID() : undefined;
|
|
84
83
|
sessionRuntime.registerExecution(executionOwner);
|
|
85
84
|
const inputs = sessionInputs();
|
|
86
|
-
const acceptParent = (message) => {
|
|
87
|
-
const origin = message.delivery?.origin === undefined
|
|
88
|
-
? undefined
|
|
89
|
-
: restoreSubagentOrigin(message.delivery.origin);
|
|
90
|
-
const signal = AbortSignal.any([
|
|
91
|
-
controller.signal,
|
|
92
|
-
...(message.delivery?.signal === undefined ? [] : [message.delivery.signal])
|
|
93
|
-
]);
|
|
94
|
-
if (signal.aborted) {
|
|
95
|
-
message.delivery?.settled?.('cancelled');
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const accept = (call) => {
|
|
99
|
-
const entry = inputs.accept({ kind: 'submit', input: { text: message.text } }, call, (request, call, leaf) => leaf(request, call), 'accepted', message);
|
|
100
|
-
void entry.terminal.then(() => {
|
|
101
|
-
if (entry.receipt.status === 'cancelled' || entry.receipt.status === 'failed')
|
|
102
|
-
message.delivery?.settled?.(entry.receipt.status);
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
if (origin) {
|
|
106
|
-
accept(Object.freeze({
|
|
107
|
-
...origin,
|
|
108
|
-
sessionId,
|
|
109
|
-
sessionEpoch: extensionManager.session(sessionId)?.epoch ?? 0,
|
|
110
|
-
signal,
|
|
111
|
-
executionId,
|
|
112
|
-
turnId
|
|
113
|
-
}));
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
extensionManager.operations.enter({
|
|
117
|
-
sessionId,
|
|
118
|
-
sessionEpoch: extensionManager.session(sessionId)?.epoch ?? 0,
|
|
119
|
-
actor: 'sdk',
|
|
120
|
-
entry: 'native-api',
|
|
121
|
-
signal,
|
|
122
|
-
executionId,
|
|
123
|
-
turnId
|
|
124
|
-
}, accept);
|
|
125
|
-
};
|
|
126
|
-
for (const message of internal.initialMailbox ?? [])
|
|
127
|
-
acceptParent(message);
|
|
128
|
-
let acceptsMailbox = sessionSource.type === 'subagent' && mode !== 'compact';
|
|
129
85
|
let acceptsSteer = false;
|
|
130
86
|
let exhaustedModelAttempt;
|
|
131
87
|
const eventPorts = {
|
|
@@ -143,6 +99,7 @@ export function createSessionExecutionFactory(ports) {
|
|
|
143
99
|
messageSources.set(message, stored);
|
|
144
100
|
}
|
|
145
101
|
},
|
|
102
|
+
observe: (event) => sessionRuntime.publishEvent(event),
|
|
146
103
|
...(internal.publishHostEvents === false
|
|
147
104
|
? {}
|
|
148
105
|
: { publish: (full) => host.emit(full) })
|
|
@@ -187,7 +144,6 @@ export function createSessionExecutionFactory(ports) {
|
|
|
187
144
|
let releaseImageBytes;
|
|
188
145
|
const contextGc = new ContextGcRuntime();
|
|
189
146
|
let selectedAdapter;
|
|
190
|
-
const subagents = sessionSource.type === 'user' ? sessionRuntime.subagents : undefined;
|
|
191
147
|
executionOwner.start({
|
|
192
148
|
scope: (run) => withToolPermissions(permissionPolicy, run),
|
|
193
149
|
prepareProgram: async () => {
|
|
@@ -255,14 +211,13 @@ export function createSessionExecutionFactory(ports) {
|
|
|
255
211
|
let smartInput;
|
|
256
212
|
let compactContext;
|
|
257
213
|
let startCompact;
|
|
258
|
-
const { startInitialInput, receiveSteer,
|
|
214
|
+
const { startInitialInput, receiveSteer, appendExtensionContext, appendMailboxMessages } = createExecutionInput({
|
|
259
215
|
host,
|
|
260
216
|
store,
|
|
261
217
|
sessionId,
|
|
262
218
|
executionId,
|
|
263
219
|
turnId,
|
|
264
220
|
mode,
|
|
265
|
-
source: sessionSource.type,
|
|
266
221
|
controller,
|
|
267
222
|
inputs,
|
|
268
223
|
messages,
|
|
@@ -320,49 +275,6 @@ export function createSessionExecutionFactory(ports) {
|
|
|
320
275
|
const initialSmartTokens = latestSmartContextTokens(contextRecords, selectedModel.id, selectedModel.contextWindowTokens);
|
|
321
276
|
const compactUserTokenLimit = Math.min(20_000, Math.floor(selectedModel.contextWindowTokens / 8));
|
|
322
277
|
const reasoningEffort = input.reasoningEffort ?? selectedModel.defaultReasoningEffort;
|
|
323
|
-
if (mode !== 'compact' && subagents)
|
|
324
|
-
await subagents.beginParentExecution({
|
|
325
|
-
executionId,
|
|
326
|
-
modelId: selectedModel.id,
|
|
327
|
-
reasoningEffort,
|
|
328
|
-
models: executionModels,
|
|
329
|
-
emitTerminal: async (task) => emit({
|
|
330
|
-
type: 'subagent.completed',
|
|
331
|
-
agentId: task.agentId,
|
|
332
|
-
description: task.description,
|
|
333
|
-
status: task.status,
|
|
334
|
-
...(task.permissionStop === undefined
|
|
335
|
-
? {}
|
|
336
|
-
: { permissionStop: task.permissionStop }),
|
|
337
|
-
...(task.modelId === undefined ? {} : { modelId: task.modelId }),
|
|
338
|
-
...(task.modelName === undefined ? {} : { modelName: task.modelName }),
|
|
339
|
-
...(task.reasoningEffort === undefined
|
|
340
|
-
? {}
|
|
341
|
-
: { reasoningEffort: task.reasoningEffort }),
|
|
342
|
-
...(task.latestMessage === undefined ? {} : { latestMessage: task.latestMessage }),
|
|
343
|
-
...(task.latestActivity === undefined
|
|
344
|
-
? {}
|
|
345
|
-
: { latestActivity: task.latestActivity }),
|
|
346
|
-
...(task.errorCode === undefined ? {} : { errorCode: task.errorCode }),
|
|
347
|
-
...(task.errorMessage === undefined ? {} : { errorMessage: task.errorMessage })
|
|
348
|
-
}),
|
|
349
|
-
startTurn: async (turn) => {
|
|
350
|
-
return startSubagentTurn(turn.sessionId, {
|
|
351
|
-
permissionMode: permissionPolicy.mode,
|
|
352
|
-
prompt: turn.prompt,
|
|
353
|
-
modelId: turn.modelId,
|
|
354
|
-
reasoningEffort: turn.reasoningEffort,
|
|
355
|
-
role: turn.role,
|
|
356
|
-
initialMailbox: turn.initialMailbox,
|
|
357
|
-
turnId: turn.turnId,
|
|
358
|
-
...(turn.origin === undefined
|
|
359
|
-
? {}
|
|
360
|
-
: { origin: restoreSubagentOrigin(turn.origin) }),
|
|
361
|
-
mcpExecutionScopeId: executionId,
|
|
362
|
-
...(turn.delivery ? { delivery: turn.delivery } : {})
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
278
|
const catalogContext = {
|
|
367
279
|
sessionId,
|
|
368
280
|
executionId,
|
|
@@ -472,17 +384,21 @@ export function createSessionExecutionFactory(ports) {
|
|
|
472
384
|
toolCatalog.refresh();
|
|
473
385
|
const restoreMcpDiscovery = () => toolCatalog.restore();
|
|
474
386
|
const loadRetainedSessionResources = async () => {
|
|
475
|
-
await subagents?.prepareSessionResources(controller.signal);
|
|
476
387
|
const hostResources = (await host.listSessionResources?.(sessionId)) ?? {
|
|
477
388
|
processes: []
|
|
478
389
|
};
|
|
390
|
+
const provider = coreExtensions.services.resolve(SESSION_CONTEXT_PROVIDER);
|
|
391
|
+
const extensions = (await provider?.resources?.(controller.signal)) ?? [];
|
|
392
|
+
controller.signal.throwIfAborted();
|
|
479
393
|
return {
|
|
480
394
|
...(hostResources.idleTtlMs === undefined
|
|
481
395
|
? {}
|
|
482
396
|
: { idleTtlMs: hostResources.idleTtlMs }),
|
|
483
397
|
processes: hostResources.processes,
|
|
484
398
|
...(hostResources.codeCells ? { codeCells: hostResources.codeCells } : {}),
|
|
485
|
-
|
|
399
|
+
extensions: extensions
|
|
400
|
+
.slice(0, 8)
|
|
401
|
+
.map((value) => truncateModelText(value, 32768, 'extension resource').content)
|
|
486
402
|
};
|
|
487
403
|
};
|
|
488
404
|
await modelContext.initializeWorldState();
|
|
@@ -520,7 +436,6 @@ export function createSessionExecutionFactory(ports) {
|
|
|
520
436
|
todo,
|
|
521
437
|
waitInterrupt,
|
|
522
438
|
skills: instructionContext?.skills ?? new Map(),
|
|
523
|
-
subagents,
|
|
524
439
|
coreExtensions,
|
|
525
440
|
operations: extensionManager.operations,
|
|
526
441
|
scheduleTool: sessionRuntime.scheduleTool,
|
|
@@ -665,7 +580,6 @@ export function createSessionExecutionFactory(ports) {
|
|
|
665
580
|
workspace: logicalWorkspace,
|
|
666
581
|
platform: description.platform
|
|
667
582
|
},
|
|
668
|
-
child: sessionSource.type === 'subagent',
|
|
669
583
|
start: (value) => startCompact(value),
|
|
670
584
|
wait: (value) => compactContext(value),
|
|
671
585
|
activeProcesses: async () => {
|
|
@@ -760,10 +674,12 @@ export function createSessionExecutionFactory(ports) {
|
|
|
760
674
|
return;
|
|
761
675
|
}
|
|
762
676
|
const prepareRound = createExecutionRoundPreparer({
|
|
763
|
-
prepareInputs: (
|
|
764
|
-
|
|
677
|
+
prepareInputs: (includeSessionContext) => contextCoordinator.prepareInputs({
|
|
678
|
+
includeSessionContext,
|
|
765
679
|
appendMailbox: appendMailboxMessages,
|
|
766
|
-
|
|
680
|
+
appendSessionContext: async () => {
|
|
681
|
+
await appendExtensionContext(coreExtensions.services.resolve(SESSION_CONTEXT_PROVIDER));
|
|
682
|
+
},
|
|
767
683
|
refreshTools: () => {
|
|
768
684
|
updateMcpRegistry();
|
|
769
685
|
toolCatalog.refresh();
|
|
@@ -807,9 +723,7 @@ export function createSessionExecutionFactory(ports) {
|
|
|
807
723
|
},
|
|
808
724
|
prepareResources: async ({ candidateRequest, request, toolScope }) => {
|
|
809
725
|
resourceInput.observe(candidateRequest.messages);
|
|
810
|
-
const media =
|
|
811
|
-
? undefined
|
|
812
|
-
: await resourceInput.gcCandidate(request, candidateRequest.images);
|
|
726
|
+
const media = await resourceInput.gcCandidate(request, candidateRequest.images);
|
|
813
727
|
if (media?.reason === 'HARD_LIMIT') {
|
|
814
728
|
const committed = await contextCoordinator.gc({ request, toolScope }, modelLifecycle.usage, media);
|
|
815
729
|
if (committed)
|
|
@@ -854,7 +768,6 @@ export function createSessionExecutionFactory(ports) {
|
|
|
854
768
|
hasPending: () => inputs.hasBoundaryPending && !inputs.executing,
|
|
855
769
|
append: appendMailboxMessages,
|
|
856
770
|
close: () => {
|
|
857
|
-
acceptsMailbox = false;
|
|
858
771
|
acceptsSteer = false;
|
|
859
772
|
}
|
|
860
773
|
}
|
|
@@ -881,7 +794,6 @@ export function createSessionExecutionFactory(ports) {
|
|
|
881
794
|
};
|
|
882
795
|
},
|
|
883
796
|
beforeFailure: async (error) => {
|
|
884
|
-
acceptsMailbox = false;
|
|
885
797
|
acceptsSteer = false;
|
|
886
798
|
executionOwner.stopSteer();
|
|
887
799
|
await sessionRuntime.joinRecordProjection();
|
|
@@ -890,21 +802,20 @@ export function createSessionExecutionFactory(ports) {
|
|
|
890
802
|
},
|
|
891
803
|
diagnostic: (error) => modelAttemptFailureDiagnostic(describeAgentError(error, 'MAR_AGENT_EXECUTION_FAILED'), exhaustedModelAttempt),
|
|
892
804
|
emit,
|
|
893
|
-
endParent: () =>
|
|
805
|
+
endParent: () => { },
|
|
894
806
|
finalize: (failed) => executionOwner.finish({
|
|
895
807
|
failed,
|
|
896
808
|
reason: controller.signal.reason ?? new AgentError('MAR_AGENT_CANCELLED', 'Execution ended.'),
|
|
897
809
|
releaseImageBytes: () => releaseImageBytes?.(),
|
|
898
810
|
revokeBindings: () => {
|
|
899
811
|
executionOwner.revokeViews(new AgentError('MAR_AGENT_CANCELLED', 'Execution ended.'));
|
|
900
|
-
acceptsMailbox = false;
|
|
901
812
|
},
|
|
902
813
|
closeToolSources: () => {
|
|
903
814
|
executionToolSources?.close();
|
|
904
815
|
executionOwner.detachToolSources();
|
|
905
816
|
},
|
|
906
817
|
detachAbort: () => internal.signal?.removeEventListener('abort', abortSource),
|
|
907
|
-
endParent: () =>
|
|
818
|
+
endParent: () => { },
|
|
908
819
|
deactivate: () => {
|
|
909
820
|
sessionRuntime.unbindExecutionContext(executionContext);
|
|
910
821
|
sessionRuntime.deactivateExecution(executionOwner);
|
|
@@ -916,12 +827,7 @@ export function createSessionExecutionFactory(ports) {
|
|
|
916
827
|
sessionRuntime.unregisterExecution(executionOwner);
|
|
917
828
|
}
|
|
918
829
|
});
|
|
919
|
-
return executionOwner.handle(
|
|
920
|
-
if (!acceptsMailbox || controller.signal.aborted)
|
|
921
|
-
return false;
|
|
922
|
-
acceptParent({ text: message, ...(delivery ? { delivery } : {}) });
|
|
923
|
-
return true;
|
|
924
|
-
});
|
|
830
|
+
return executionOwner.handle();
|
|
925
831
|
};
|
|
926
832
|
return execution;
|
|
927
833
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ExtensionInputSource } from '../extensions/session-input.js';
|
|
2
|
-
import type { SubagentMailboxMessage } from '../subagent/session-controller.js';
|
|
3
2
|
import { AsyncQueue } from '../runtime/async-queue.js';
|
|
4
3
|
import { ExecutionLoop } from '../runtime/execution.js';
|
|
5
4
|
import type { RoundToolScope } from '../tools/execution.js';
|
|
@@ -7,7 +6,6 @@ import { CompactCoordinator } from '../runtime/compaction/coordinator.js';
|
|
|
7
6
|
import { CompactRequests } from '../runtime/compaction/requests.js';
|
|
8
7
|
import type { ExecutionMode, ExecutionResult, AgentEvent } from './types.js';
|
|
9
8
|
import type { ModelAdapter, ModelTurnSession } from '../model/contracts.js';
|
|
10
|
-
import type { SubagentMessageDelivery } from '../subagent/session-controller.js';
|
|
11
9
|
import type { SessionModelMessage } from '../session/model-request.js';
|
|
12
10
|
import type { ExecutionToolSources } from './extension-tools.js';
|
|
13
11
|
import type { ExecutionHandle } from './types.js';
|
|
@@ -23,15 +21,12 @@ export interface InternalExecutionOptions {
|
|
|
23
21
|
readonly modelText?: string;
|
|
24
22
|
readonly inputContext?: readonly string[];
|
|
25
23
|
readonly modelContext?: readonly string[];
|
|
26
|
-
readonly initialMailbox?: readonly SubagentMailboxMessage[];
|
|
27
24
|
readonly turnId?: string;
|
|
28
|
-
readonly delivery?: SubagentMessageDelivery;
|
|
29
25
|
readonly mcpExecutionScopeId?: string;
|
|
30
26
|
}
|
|
31
27
|
export interface InternalExecutionHandle extends ExecutionHandle {
|
|
32
28
|
readonly persistedEvents: boolean;
|
|
33
29
|
readonly turnId: string;
|
|
34
|
-
enqueueMessage(message: string, delivery?: SubagentMessageDelivery): boolean;
|
|
35
30
|
}
|
|
36
31
|
export interface SessionExecutionContext {
|
|
37
32
|
readonly executionId: string;
|
|
@@ -39,7 +34,7 @@ export interface SessionExecutionContext {
|
|
|
39
34
|
readonly mode: ExecutionMode;
|
|
40
35
|
readonly models: ReadonlyMap<string, ResolvedModelConfiguration>;
|
|
41
36
|
readonly instruction: string | undefined;
|
|
42
|
-
readonly steer?: ((input: import('./types.js').SteerInput) => Promise<import('./types.js').SteerResult>) | undefined;
|
|
37
|
+
readonly steer?: ((input: import('./types.js').SteerInput, source?: import('../extensions/session-input.js').ExtensionInputSource) => Promise<import('./types.js').SteerResult>) | undefined;
|
|
43
38
|
readonly compactRequests?: CompactRequests | undefined;
|
|
44
39
|
readonly requestMessages?: {
|
|
45
40
|
read(): readonly SessionModelMessage[];
|
|
@@ -52,6 +47,7 @@ export interface SessionExecutionContext {
|
|
|
52
47
|
export type ExecutionEventPayload<T = AgentEvent> = T extends AgentEvent ? Omit<T, 'eventId' | 'sequence' | 'timestamp' | 'sessionId' | 'executionId' | 'turnId'> : never;
|
|
53
48
|
export interface ExecutionEventPorts {
|
|
54
49
|
persist(event: AgentEvent, payload: AgentEvent): Promise<void>;
|
|
50
|
+
observe?(event: AgentEvent): void;
|
|
55
51
|
publish?(event: AgentEvent): void | Promise<void>;
|
|
56
52
|
hasRetainedLease?(): boolean;
|
|
57
53
|
}
|
|
@@ -80,6 +76,16 @@ export declare class SessionExecution {
|
|
|
80
76
|
readonly generation: number;
|
|
81
77
|
readonly instruction: string | undefined;
|
|
82
78
|
};
|
|
79
|
+
get observedTerminal(): (import("./types.js").AgentEventBase & {
|
|
80
|
+
type: "execution.completed";
|
|
81
|
+
permissionStop?: import("../host.js").PermissionStop;
|
|
82
|
+
}) | (import("./types.js").AgentEventBase & {
|
|
83
|
+
type: "execution.failed";
|
|
84
|
+
code: string;
|
|
85
|
+
message?: string;
|
|
86
|
+
}) | (import("./types.js").AgentEventBase & {
|
|
87
|
+
type: "execution.cancelled";
|
|
88
|
+
}) | undefined;
|
|
83
89
|
bindViews(views: Partial<Pick<SessionExecutionContext, 'requestMessages' | 'appendedMessages' | 'toolSources'>>): void;
|
|
84
90
|
acceptSteer(steer: NonNullable<SessionExecutionContext['steer']>): void;
|
|
85
91
|
stopSteer(): void;
|
|
@@ -157,7 +163,7 @@ export declare class SessionExecution {
|
|
|
157
163
|
readonly settle: (status: ExecutionResult['status']) => void;
|
|
158
164
|
}): void;
|
|
159
165
|
join(): Promise<ExecutionResult> | undefined;
|
|
160
|
-
handle(
|
|
166
|
+
handle(): InternalExecutionHandle;
|
|
161
167
|
cancel(reason?: unknown): void;
|
|
162
168
|
}
|
|
163
169
|
export {};
|