@autopilot-agent/core 0.2.0 → 0.4.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/README.md +10 -4
- package/dist/experimental/index.js +159 -59
- package/dist/experimental/index.mjs +159 -59
- package/dist/failure.d.ts +3 -0
- package/dist/failure.js +1 -0
- package/dist/failure.mjs +1 -0
- package/dist/index.d.ts +30 -5
- package/dist/index.js +346 -214
- package/dist/index.mjs +346 -214
- package/dist/internal/agent-runtime.d.ts +87 -2
- package/dist/internal/kernel/model-sampler.d.ts +5 -0
- package/dist/internal/kernel/run-context.d.ts +6 -0
- package/dist/internal/kernel/session-images.d.ts +21 -0
- package/dist/internal/kernel/turn-usage.d.ts +14 -0
- package/dist/internal/lib/document-parser.js +2 -2
- package/dist/internal/lib/image-normalization.d.ts +16 -0
- package/dist/internal/lib/llm.d.ts +7 -1
- package/dist/internal/lib/llm.js +3 -3
- package/dist/internal/lib/pdf-processor.js +1 -1
- package/dist/internal/tools/builtins/browser-tool.d.ts +13 -0
- package/dist/internal/tools/builtins/open-preview-tool.d.ts +5 -1
- package/dist/internal/tools/builtins/read-output-budget.d.ts +5 -0
- package/dist/internal/tools/builtins/render-ui-tool.d.ts +11 -0
- package/dist/internal/tools/builtins/static-preview.d.ts +15 -0
- package/dist/internal/tools/builtins/thread-tools.d.ts +125 -0
- package/dist/internal/tools/builtins/vision-analyze-tool.d.ts +1 -0
- package/dist/internal/tools/mcp-images.d.ts +6 -0
- package/dist/internal/tools/mcp-runtime.d.ts +4 -0
- package/dist/internal/tools/permissions/command-policy.d.ts +2 -0
- package/dist/internal/tools/policy-engine.d.ts +1 -0
- package/dist/internal/tools/process-utils.d.ts +1 -0
- package/dist/internal/tools/thread-observation-display.d.ts +2 -0
- package/dist/internal/tools/types.d.ts +21 -0
- package/dist/internal/types/agent-message.d.ts +12 -2
- package/dist/internal/types/index.d.ts +1 -1
- package/dist/runtime/adapters/memory/memory-lease-store.d.ts +6 -0
- package/dist/runtime/adapters/memory/memory-session-store.d.ts +14 -0
- package/dist/runtime/adapters/memory/memory-thread-store.d.ts +24 -0
- package/dist/runtime/adapters/memory/memory-transcript-store.d.ts +9 -0
- package/dist/runtime/application/approval-service.d.ts +5 -0
- package/dist/runtime/application/input-inbox-service.d.ts +1 -1
- package/dist/runtime/application/runtime-facts.d.ts +54 -0
- package/dist/runtime/application/session-service.d.ts +9 -0
- package/dist/runtime/application/thread-delivery-service.d.ts +97 -0
- package/dist/runtime/application/thread-execution-host.d.ts +7 -0
- package/dist/runtime/application/thread-service.d.ts +1027 -0
- package/dist/runtime/application/thread-task.d.ts +11 -0
- package/dist/runtime/application/thread-tool-binding.d.ts +218 -0
- package/dist/runtime/application/turn/turn-capability-ceiling.d.ts +2 -0
- package/dist/runtime/application/turn/turn-compaction-coordinator.d.ts +2 -1
- package/dist/runtime/application/turn/turn-event-recorder.d.ts +1 -0
- package/dist/runtime/application/turn/turn-execution-view.d.ts +43 -0
- package/dist/runtime/application/turn/turn-recovery-service.d.ts +14 -0
- package/dist/runtime/application/turn-service.d.ts +28 -0
- package/dist/runtime/application/user-question-service.d.ts +1 -0
- package/dist/runtime/bootstrap/runtime-bootstrap-service.d.ts +2 -0
- package/dist/runtime/domain/frozen-run-config.d.ts +2 -0
- package/dist/runtime/domain/index.d.ts +16 -1
- package/dist/runtime/domain/input-inbox.d.ts +16 -0
- package/dist/runtime/domain/model-ref.d.ts +1 -1
- package/dist/runtime/domain/session-presentation.d.ts +9 -0
- package/dist/runtime/domain/thread-collaboration.d.ts +179 -0
- package/dist/runtime/domain/turn.d.ts +8 -0
- package/dist/runtime/ports/index.d.ts +6 -0
- package/dist/runtime/ports/lease-store.d.ts +4 -0
- package/dist/runtime/ports/session-image-store.d.ts +26 -0
- package/dist/runtime/ports/session-store.d.ts +16 -0
- package/dist/runtime/ports/thread-handoff.d.ts +14 -0
- package/dist/runtime/ports/thread-store.d.ts +15 -0
- package/dist/runtime/ports/transcript-store.d.ts +8 -0
- package/dist/runtime/protocol/browser-capability.d.ts +81 -0
- package/dist/runtime/protocol/browser-operation.d.ts +89 -0
- package/dist/runtime/protocol/chat-capability.d.ts +1 -0
- package/dist/runtime/protocol/error-code.d.ts +1 -1
- package/dist/runtime/protocol/frozen-run-config-view.d.ts +2 -1
- package/dist/runtime/protocol/index.d.ts +2 -1
- package/dist/runtime/protocol/recoverable-turn-view.d.ts +3 -0
- package/dist/runtime/protocol/run-config.d.ts +13 -0
- package/dist/runtime/protocol/threads-capability.d.ts +14 -0
- package/dist/runtime/protocol/web-capability.d.ts +5 -1
- package/dist/runtime/protocol/work-preview-capability.d.ts +1 -0
- package/dist/runtime/provider/anthropic-messages-adapter.d.ts +4 -2
- package/dist/runtime/provider/api-protocol.d.ts +16 -2
- package/dist/runtime/provider/compatibility-presets.d.ts +19 -0
- package/dist/runtime/provider/frozen-provider-config.d.ts +4 -1
- package/dist/runtime/provider/index.d.ts +4 -2
- package/dist/runtime/provider/model-capability-catalog.d.ts +7 -0
- package/dist/runtime/provider/model-sample-resolver.d.ts +3 -2
- package/dist/runtime/provider/openai-chat-completions-adapter.d.ts +5 -1
- package/dist/runtime/provider/openai-responses-adapter.d.ts +22 -0
- package/dist/runtime/provider/provider-failure-guidance.d.ts +4 -0
- package/dist/runtime/provider/provider-failure-normalization.d.ts +9 -0
- package/dist/runtime/public/agent-runtime.d.ts +5 -0
- package/dist/ui/catalog.d.ts +870 -0
- package/dist/ui/document.d.ts +580 -0
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.mjs +1 -0
- package/package.json +17 -3
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { AgentThreadsCapability } from "../../../runtime/application/thread-tool-binding";
|
|
2
|
+
import type { AgentToolDefinition } from "../types";
|
|
3
|
+
export declare function createThreadTools(capability: AgentThreadsCapability): {
|
|
4
|
+
resumeThread: AgentToolDefinition<{
|
|
5
|
+
threadId: string;
|
|
6
|
+
expectedTurnId: string;
|
|
7
|
+
groupId?: string | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
accepted: true;
|
|
10
|
+
controlId: string;
|
|
11
|
+
recoveryAction?: "open_target_continue";
|
|
12
|
+
}>;
|
|
13
|
+
createThread: AgentToolDefinition<{
|
|
14
|
+
groupId?: string | undefined;
|
|
15
|
+
title?: string | undefined;
|
|
16
|
+
roleLabel?: string | undefined;
|
|
17
|
+
modelRef?: {
|
|
18
|
+
provider: string;
|
|
19
|
+
modelId: string;
|
|
20
|
+
} | undefined;
|
|
21
|
+
reasoningEffort?: "low" | "medium" | "high" | "max" | "none" | "xhigh" | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
threadId: string;
|
|
24
|
+
groupId: string;
|
|
25
|
+
parentThreadId: string;
|
|
26
|
+
relativeLink: string;
|
|
27
|
+
}>;
|
|
28
|
+
listThreads: AgentToolDefinition<{
|
|
29
|
+
groupId?: string | undefined;
|
|
30
|
+
cursor?: string | undefined;
|
|
31
|
+
limit?: number | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
items: import("../../../runtime/application/thread-tool-binding").AgentThreadMemberView[];
|
|
34
|
+
nextCursor?: string;
|
|
35
|
+
}>;
|
|
36
|
+
readThread: AgentToolDefinition<{
|
|
37
|
+
threadId: string;
|
|
38
|
+
groupId?: string | undefined;
|
|
39
|
+
cursor?: string | undefined;
|
|
40
|
+
limit?: number | undefined;
|
|
41
|
+
}, import("../../../runtime/application/thread-tool-binding").AgentThreadReadResult>;
|
|
42
|
+
sendThread: AgentToolDefinition<{
|
|
43
|
+
threadId: string;
|
|
44
|
+
content: string;
|
|
45
|
+
groupId?: string | undefined;
|
|
46
|
+
mode?: "notify" | "run" | "steer" | undefined;
|
|
47
|
+
replyTo?: string | undefined;
|
|
48
|
+
expectedTurnId?: string | undefined;
|
|
49
|
+
handoff?: {
|
|
50
|
+
title: string;
|
|
51
|
+
markdown: string;
|
|
52
|
+
} | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
messageId: string;
|
|
55
|
+
mode: import("../../..").ThreadMessage["mode"];
|
|
56
|
+
expectedTurnId?: string;
|
|
57
|
+
taskId?: string;
|
|
58
|
+
deliverySeq: number;
|
|
59
|
+
deliveryStatus: import("../../..").ThreadMessage["deliveryStatus"];
|
|
60
|
+
handoffRef?: import("../../..").ThreadHandoffRef;
|
|
61
|
+
}>;
|
|
62
|
+
waitThreads: AgentToolDefinition<{
|
|
63
|
+
targets: {
|
|
64
|
+
threadId: string;
|
|
65
|
+
taskId?: string | undefined;
|
|
66
|
+
cursor?: string | undefined;
|
|
67
|
+
}[];
|
|
68
|
+
timeoutMs: number;
|
|
69
|
+
groupId?: string | undefined;
|
|
70
|
+
followUntilTerminal?: boolean | undefined;
|
|
71
|
+
reportingInstructions?: string | undefined;
|
|
72
|
+
}, import("../../..").WaitResult>;
|
|
73
|
+
readSharedState: AgentToolDefinition<{
|
|
74
|
+
groupId?: string | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
value: Record<string, unknown>;
|
|
77
|
+
revision: number;
|
|
78
|
+
updatedAt: number;
|
|
79
|
+
updatedBy: import("../../..").ThreadActor;
|
|
80
|
+
}>;
|
|
81
|
+
updateSharedState: AgentToolDefinition<{
|
|
82
|
+
expectedRevision: number;
|
|
83
|
+
operations: ({
|
|
84
|
+
op: "set";
|
|
85
|
+
key: string;
|
|
86
|
+
value: string | number | boolean | Record<string, unknown> | unknown[] | null;
|
|
87
|
+
} | {
|
|
88
|
+
op: "remove";
|
|
89
|
+
key: string;
|
|
90
|
+
})[];
|
|
91
|
+
groupId?: string | undefined;
|
|
92
|
+
}, {
|
|
93
|
+
revision: number;
|
|
94
|
+
}>;
|
|
95
|
+
reportProgress: AgentToolDefinition<{
|
|
96
|
+
kind: "completed" | "failed" | "blocked" | "progress" | "milestone";
|
|
97
|
+
summary: string;
|
|
98
|
+
groupId?: string | undefined;
|
|
99
|
+
evidence?: {
|
|
100
|
+
turnId?: string | undefined;
|
|
101
|
+
messageId?: string | undefined;
|
|
102
|
+
} | undefined;
|
|
103
|
+
}, {
|
|
104
|
+
progressSeq: number;
|
|
105
|
+
taskId: string;
|
|
106
|
+
taskProgressSeq: number;
|
|
107
|
+
}>;
|
|
108
|
+
readProgress: AgentToolDefinition<{
|
|
109
|
+
threadId: string;
|
|
110
|
+
groupId?: string | undefined;
|
|
111
|
+
taskId?: string | undefined;
|
|
112
|
+
cursor?: string | undefined;
|
|
113
|
+
limit?: number | undefined;
|
|
114
|
+
kinds?: ("completed" | "failed" | "blocked" | "progress" | "milestone")[] | undefined;
|
|
115
|
+
}, import("../../../runtime/application/thread-tool-binding").AgentThreadProgressPage>;
|
|
116
|
+
interruptThread: AgentToolDefinition<{
|
|
117
|
+
threadId: string;
|
|
118
|
+
expectedTurnId: string;
|
|
119
|
+
groupId?: string | undefined;
|
|
120
|
+
}, {
|
|
121
|
+
accepted: true;
|
|
122
|
+
controlId: string;
|
|
123
|
+
hostOffline: boolean;
|
|
124
|
+
}>;
|
|
125
|
+
};
|
|
@@ -3,6 +3,7 @@ import type { AgentToolDefinition } from "../types";
|
|
|
3
3
|
declare const visionAnalyzeSchema: z.ZodObject<{
|
|
4
4
|
path: z.ZodString;
|
|
5
5
|
prompt: z.ZodString;
|
|
6
|
+
expectedSha256: z.ZodOptional<z.ZodString>;
|
|
6
7
|
}, z.core.$strict>;
|
|
7
8
|
export declare function createVisionAnalyzeTool(): AgentToolDefinition<z.infer<typeof visionAnalyzeSchema>, Record<string, unknown>>;
|
|
8
9
|
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SessionImageStore } from "../../runtime/ports/session-image-store";
|
|
2
|
+
import type { AgentImageReference } from "../types/agent-message";
|
|
3
|
+
export declare function prepareMcpImages(output: unknown, store: SessionImageStore | undefined, sessionId: string | undefined, signal?: AbortSignal): Promise<{
|
|
4
|
+
output: unknown;
|
|
5
|
+
images: AgentImageReference[];
|
|
6
|
+
}>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CredentialStore } from "../../runtime/ports";
|
|
2
2
|
import { type McpCapability, type McpServerConfig } from "../../runtime/protocol";
|
|
3
3
|
import type { AgentToolDefinition, SandboxExecutionBinding, ToolActionFacts, ToolExecutionContext, ToolPermissionMode } from "./types";
|
|
4
|
+
import type { SessionImageStore } from "../../runtime/ports/session-image-store";
|
|
4
5
|
export type McpServerState = "configured" | "starting" | "ready" | "degraded" | "failed" | "stopped";
|
|
5
6
|
export interface McpRuntimeDiagnostic {
|
|
6
7
|
serverName: string;
|
|
@@ -8,6 +9,8 @@ export interface McpRuntimeDiagnostic {
|
|
|
8
9
|
}
|
|
9
10
|
export interface McpRuntimeOptions {
|
|
10
11
|
capability: McpCapability;
|
|
12
|
+
sessionId?: string;
|
|
13
|
+
sessionImageStore?: SessionImageStore;
|
|
11
14
|
workspaceRoot?: string;
|
|
12
15
|
workspaceTrusted?: boolean;
|
|
13
16
|
resolvePersistentGrant?: ToolExecutionContext["resolvePersistentGrant"];
|
|
@@ -18,6 +21,7 @@ export interface McpRuntimeOptions {
|
|
|
18
21
|
export declare function createMcpServerStartActionFacts(server: McpServerConfig): ToolActionFacts;
|
|
19
22
|
export declare class McpStdioRuntime {
|
|
20
23
|
private readonly options;
|
|
24
|
+
private readonly imageReferences;
|
|
21
25
|
private readonly policyEngine;
|
|
22
26
|
private readonly servers;
|
|
23
27
|
private readonly tools;
|
|
@@ -4,11 +4,13 @@ export interface CommandRule {
|
|
|
4
4
|
decision: ToolPermissionDecision;
|
|
5
5
|
risk: CommandRisk;
|
|
6
6
|
reason: string;
|
|
7
|
+
requireSingleApproval?: true;
|
|
7
8
|
}
|
|
8
9
|
export interface CommandPolicyResult {
|
|
9
10
|
decision: ToolPermissionDecision;
|
|
10
11
|
risk: CommandRisk;
|
|
11
12
|
reason: string;
|
|
13
|
+
requireSingleApproval?: true;
|
|
12
14
|
}
|
|
13
15
|
export declare const defaultCommandRules: CommandRule[];
|
|
14
16
|
export declare function normalizeProgramName(program: string): string;
|
|
@@ -11,6 +11,7 @@ export interface PolicyEvaluationInput {
|
|
|
11
11
|
}
|
|
12
12
|
export declare class PolicyEngine {
|
|
13
13
|
canUsePersistentGrant(context: ToolExecutionContext, facts: ToolActionFacts): boolean;
|
|
14
|
+
requiresSingleApproval(context: ToolExecutionContext, facts: ToolActionFacts): boolean;
|
|
14
15
|
evaluate(input: PolicyEvaluationInput): ToolPolicyResult;
|
|
15
16
|
private allowsAutoApprove;
|
|
16
17
|
}
|
|
@@ -131,6 +131,12 @@ export interface ToolJobDisplayFacts {
|
|
|
131
131
|
waitOutcome?: import("../../runtime/domain").JobReadView["waitOutcome"];
|
|
132
132
|
}
|
|
133
133
|
export interface ToolDisplayFacts {
|
|
134
|
+
observation?: {
|
|
135
|
+
key: string;
|
|
136
|
+
phase: string;
|
|
137
|
+
lines: string[];
|
|
138
|
+
approvalTargets?: string[];
|
|
139
|
+
};
|
|
134
140
|
titleKey: string;
|
|
135
141
|
target?: string;
|
|
136
142
|
summary?: string;
|
|
@@ -190,6 +196,7 @@ export type ToolExecutionResult = {
|
|
|
190
196
|
output: unknown;
|
|
191
197
|
meta: ToolExecutionMeta;
|
|
192
198
|
display?: ToolDisplayFacts;
|
|
199
|
+
images?: import("../types/agent-message").AgentImageReference[];
|
|
193
200
|
} | {
|
|
194
201
|
status: "question_required";
|
|
195
202
|
callId: string;
|
|
@@ -243,6 +250,7 @@ export interface ToolActionFacts {
|
|
|
243
250
|
stableConstraint?: string;
|
|
244
251
|
hardDenyReason?: string;
|
|
245
252
|
requiresApproval?: boolean;
|
|
253
|
+
requireSingleApproval?: true;
|
|
246
254
|
externalMutation?: boolean;
|
|
247
255
|
externalTarget?: {
|
|
248
256
|
canonicalTarget: string;
|
|
@@ -280,6 +288,11 @@ export interface ToolEvent {
|
|
|
280
288
|
errorCode?: string;
|
|
281
289
|
}
|
|
282
290
|
export interface ToolExecutionContext {
|
|
291
|
+
reportingAgreement?: {
|
|
292
|
+
taskId: string;
|
|
293
|
+
explicit: boolean;
|
|
294
|
+
};
|
|
295
|
+
hostToolAdmission?: (tool: AgentToolDefinition<any, any>) => Promise<void>;
|
|
283
296
|
hostMutationProtection?: import("../../runtime/ports/host-mutation-protection").HostMutationProtection;
|
|
284
297
|
executionSessionId?: string;
|
|
285
298
|
externalExecutionAuthority?: ExternalExecutionAuthority;
|
|
@@ -290,6 +303,7 @@ export interface ToolExecutionContext {
|
|
|
290
303
|
workspaceTrusted?: boolean;
|
|
291
304
|
signal?: AbortSignal;
|
|
292
305
|
toolCallId?: string;
|
|
306
|
+
browserApprovalConsumed?: true;
|
|
293
307
|
webFetchRedirectsRemaining?: number;
|
|
294
308
|
fileMutations?: {
|
|
295
309
|
store: FileMutationStore;
|
|
@@ -307,6 +321,7 @@ export interface ToolExecutionContext {
|
|
|
307
321
|
mimeType: string;
|
|
308
322
|
}>;
|
|
309
323
|
};
|
|
324
|
+
getVisibleMessages?: () => readonly import("../types/agent-message").AgentMessage[];
|
|
310
325
|
fileReadStates?: Map<string, {
|
|
311
326
|
sha256: string;
|
|
312
327
|
mtimeMs: number;
|
|
@@ -374,6 +389,7 @@ export interface AgentToolDefinition<TInput, TOutput> {
|
|
|
374
389
|
createActionFacts(input: TInput, context: ToolExecutionContext): ToolActionFacts | Promise<ToolActionFacts>;
|
|
375
390
|
execute(input: TInput, context: ToolExecutionContext): Promise<TOutput>;
|
|
376
391
|
serializeOutput(output: TOutput): unknown;
|
|
392
|
+
getImageReferences?(output: TOutput): import("../types/agent-message").AgentImageReference[];
|
|
377
393
|
projectDisplayDetail?(output: TOutput): ToolDisplayDetail | undefined;
|
|
378
394
|
createExecutionResult?(input: TInput, output: TOutput, context: {
|
|
379
395
|
callId: string;
|
|
@@ -388,7 +404,12 @@ export interface ToolModelDefinition {
|
|
|
388
404
|
inputSchema: Record<string, unknown>;
|
|
389
405
|
}
|
|
390
406
|
export interface ToolExecutionOptions {
|
|
407
|
+
reportingAgreement?: {
|
|
408
|
+
taskId: string;
|
|
409
|
+
explicit: boolean;
|
|
410
|
+
};
|
|
391
411
|
signal?: AbortSignal;
|
|
412
|
+
approvalOnly?: boolean;
|
|
392
413
|
timeoutMs?: number;
|
|
393
414
|
onProgress?: (callId: string, chunk: string) => void;
|
|
394
415
|
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
export type AgentMessageRole = "system" | "user" | "assistant";
|
|
2
2
|
export type AgentJsonObject = Record<string, unknown>;
|
|
3
|
+
export interface AgentImageReference {
|
|
4
|
+
type: "image-ref";
|
|
5
|
+
id: string;
|
|
6
|
+
sha256: string;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
3
10
|
export type AgentContentBlock = {
|
|
4
11
|
type: "text";
|
|
5
12
|
text: string;
|
|
6
|
-
} | {
|
|
13
|
+
} | AgentImageReference | {
|
|
7
14
|
type: "reasoning";
|
|
8
15
|
text: string;
|
|
9
16
|
} | {
|
|
@@ -19,12 +26,13 @@ export type AgentContentBlock = {
|
|
|
19
26
|
text: string;
|
|
20
27
|
}>;
|
|
21
28
|
isError: boolean;
|
|
29
|
+
images?: AgentImageReference[];
|
|
22
30
|
};
|
|
23
31
|
export interface AgentMessage {
|
|
24
32
|
role: AgentMessageRole;
|
|
25
33
|
content: AgentContentBlock[];
|
|
26
34
|
adapterReplayState?: {
|
|
27
|
-
apiProtocol: "anthropic-messages" | "openai-chat-completions";
|
|
35
|
+
apiProtocol: "anthropic-messages" | "openai-chat-completions" | "openai-responses";
|
|
28
36
|
value: unknown;
|
|
29
37
|
};
|
|
30
38
|
}
|
|
@@ -39,11 +47,13 @@ export declare function getAgentToolCalls(message: AgentMessage): Array<{
|
|
|
39
47
|
input: AgentJsonObject;
|
|
40
48
|
}>;
|
|
41
49
|
export declare function getAgentMessageText(message: AgentMessage): string;
|
|
50
|
+
export declare function getAgentImageReferences(message: AgentMessage): AgentImageReference[];
|
|
42
51
|
export declare function createAgentTextMessage(role: AgentMessageRole, text: string): AgentMessage;
|
|
43
52
|
export declare function createAgentToolResultMessage(input: {
|
|
44
53
|
toolCallId: string;
|
|
45
54
|
text: string;
|
|
46
55
|
isError: boolean;
|
|
56
|
+
images?: AgentImageReference[];
|
|
47
57
|
}): AgentMessage;
|
|
48
58
|
export interface AgentToolPairingScan {
|
|
49
59
|
messages: AgentMessage[];
|
|
@@ -28,7 +28,7 @@ export interface ModelSampleOptions {
|
|
|
28
28
|
};
|
|
29
29
|
model?: string;
|
|
30
30
|
thinking?: "enabled" | "disabled" | "auto";
|
|
31
|
-
reasoningEffort?: "low" | "medium" | "high" | "max";
|
|
31
|
+
reasoningEffort?: "none" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
32
32
|
temperature?: number;
|
|
33
33
|
topP?: number;
|
|
34
34
|
maxTokens?: number;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { AgentLease } from "../../../internal/agent-runtime";
|
|
2
2
|
import type { LeaseStore } from "../../ports";
|
|
3
|
+
interface MemoryLeaseRecord {
|
|
4
|
+
turnId: string;
|
|
5
|
+
lease: AgentLease;
|
|
6
|
+
}
|
|
3
7
|
export declare class MemoryLeaseStore implements LeaseStore {
|
|
4
8
|
private leases;
|
|
9
|
+
readCurrent(sessionId: string): Promise<MemoryLeaseRecord | null>;
|
|
5
10
|
acquire(input: {
|
|
6
11
|
sessionId: string;
|
|
7
12
|
turnId: string;
|
|
@@ -20,3 +25,4 @@ export declare class MemoryLeaseStore implements LeaseStore {
|
|
|
20
25
|
}): Promise<boolean>;
|
|
21
26
|
deleteBySession(sessionId: string): Promise<void>;
|
|
22
27
|
}
|
|
28
|
+
export {};
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import type { Session } from "../../domain";
|
|
2
2
|
import type { SessionStore } from "../../ports";
|
|
3
|
+
import type { SessionDirectoryPage, SessionDirectoryQuery } from "../../ports/session-store";
|
|
3
4
|
export declare class MemorySessionStore implements SessionStore {
|
|
4
5
|
private sessions;
|
|
5
6
|
get(id: string): Promise<Session | null>;
|
|
6
7
|
list(): Promise<Session[]>;
|
|
8
|
+
getDirectoryEntry(id: string): Promise<{
|
|
9
|
+
id: string;
|
|
10
|
+
title: string | undefined;
|
|
11
|
+
productMode: import("../../domain").ProductMode | undefined;
|
|
12
|
+
projectId: string | undefined;
|
|
13
|
+
chatRetrievalMode: import("../../domain").ChatRetrievalMode | undefined;
|
|
14
|
+
status: import("../../domain").SessionStatus;
|
|
15
|
+
activeTurnId: string | undefined;
|
|
16
|
+
createdAt: number;
|
|
17
|
+
updatedAt: number;
|
|
18
|
+
} | null>;
|
|
19
|
+
listDirectoryPage(query: SessionDirectoryQuery): Promise<SessionDirectoryPage>;
|
|
20
|
+
createIfAbsent(session: Session): Promise<boolean>;
|
|
7
21
|
save(session: Session): Promise<void>;
|
|
8
22
|
delete(id: string): Promise<boolean>;
|
|
9
23
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ThreadControl, ThreadMessage, ThreadEvent } from "../../domain/thread-collaboration";
|
|
2
|
+
import type { ThreadStore } from "../../ports/thread-store";
|
|
3
|
+
export declare class MemoryThreadStore implements ThreadStore {
|
|
4
|
+
private controls;
|
|
5
|
+
private messages;
|
|
6
|
+
private events;
|
|
7
|
+
private requests;
|
|
8
|
+
private listeners;
|
|
9
|
+
verifyRequest(id: string, groupId: string, payloadDigest: string): Promise<void>;
|
|
10
|
+
reserveRequest(id: string, groupId: string, payloadDigest: string): Promise<void>;
|
|
11
|
+
private locks;
|
|
12
|
+
withSessionLock<T>(threadId: string, operation: () => Promise<T>): Promise<T>;
|
|
13
|
+
hasMembership(threadId: string): Promise<boolean>;
|
|
14
|
+
writeEvent(event: ThreadEvent): Promise<void>;
|
|
15
|
+
readEvent(groupId: string, seq: number): Promise<ThreadEvent | null>;
|
|
16
|
+
private messageKey;
|
|
17
|
+
writeMessage(message: ThreadMessage): Promise<void>;
|
|
18
|
+
readMessage(groupId: string, threadId: string, seq: number): Promise<ThreadMessage | null>;
|
|
19
|
+
readControl(groupId: string): Promise<ThreadControl | null>;
|
|
20
|
+
compareAndSetControl(groupId: string, expectedRevision: number | null, value: ThreadControl): Promise<boolean>;
|
|
21
|
+
listGroups(): Promise<string[]>;
|
|
22
|
+
subscribe(groupId: string, listener: () => void): () => void;
|
|
23
|
+
private notify;
|
|
24
|
+
}
|
|
@@ -2,7 +2,16 @@ import type { AgentEventEnvelope } from "../../protocol";
|
|
|
2
2
|
import type { TranscriptStore } from "../../ports";
|
|
3
3
|
export declare class MemoryTranscriptStore implements TranscriptStore {
|
|
4
4
|
private transcripts;
|
|
5
|
+
private generations;
|
|
5
6
|
append(sessionId: string, envelope: AgentEventEnvelope): Promise<void>;
|
|
6
7
|
getEvents(sessionId: string): Promise<AgentEventEnvelope[]>;
|
|
8
|
+
readPage(sessionId: string, options: {
|
|
9
|
+
cursor?: string;
|
|
10
|
+
limit: number;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
items: AgentEventEnvelope[];
|
|
13
|
+
nextCursor?: string;
|
|
14
|
+
cursor?: string;
|
|
15
|
+
}>;
|
|
7
16
|
deleteBySession(sessionId: string): Promise<void>;
|
|
8
17
|
}
|
|
@@ -2,12 +2,17 @@ import type { ApprovalStore, CheckpointStore, Clock, ExternalPermissionProjector
|
|
|
2
2
|
import { type ApprovalDecision, type PersistentGrant, type SubmitApprovalInput } from "../domain/approval";
|
|
3
3
|
import { type ExternalExecutionAuthorization } from "../domain/external-execution";
|
|
4
4
|
import type { ExternalExecutionAuthority } from "../../internal/tools/types";
|
|
5
|
+
import type { TurnExecutionView } from "./turn/turn-execution-view";
|
|
5
6
|
export interface ApprovalServiceDependencies {
|
|
6
7
|
approvalStore: ApprovalStore;
|
|
7
8
|
checkpointStore: CheckpointStore;
|
|
8
9
|
transcriptStore: TranscriptStore;
|
|
9
10
|
turnStore: TurnStore;
|
|
10
11
|
clock: Clock;
|
|
12
|
+
readExecution?(input: {
|
|
13
|
+
sessionId: string;
|
|
14
|
+
turnId: string;
|
|
15
|
+
}): Promise<TurnExecutionView | null>;
|
|
11
16
|
externalRuleProjector?: ExternalPermissionProjector;
|
|
12
17
|
}
|
|
13
18
|
export interface RevokePersistentGrantResult {
|
|
@@ -9,4 +9,4 @@ export interface InputInboxService {
|
|
|
9
9
|
cancel(inputId: string): Promise<boolean>;
|
|
10
10
|
}
|
|
11
11
|
export declare function createInputInboxService(inbox: InputInbox): InputInboxService;
|
|
12
|
-
export declare function createAgentInputInboxCapability(inbox: InputInbox, sessionId: string, turnId: string): import("../../internal/agent-runtime").AgentInputInboxCapability;
|
|
12
|
+
export declare function createAgentInputInboxCapability(inbox: InputInbox, sessionId: string, turnId: string, imageStore?: import("../ports/session-image-store").SessionImageStore): import("../../internal/agent-runtime").AgentInputInboxCapability;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { RuntimePorts } from "../ports";
|
|
2
|
+
import type { AgentEventEnvelope } from "../protocol";
|
|
3
|
+
export interface RuntimeFact {
|
|
4
|
+
protocol: 1;
|
|
5
|
+
source: "core";
|
|
6
|
+
eventId: string;
|
|
7
|
+
sessionId: string;
|
|
8
|
+
turnId: string;
|
|
9
|
+
sequence: number;
|
|
10
|
+
timestamp: string;
|
|
11
|
+
eventType: string;
|
|
12
|
+
payload: {
|
|
13
|
+
callId?: string;
|
|
14
|
+
requestId?: string;
|
|
15
|
+
approvalId?: string;
|
|
16
|
+
inputId?: string;
|
|
17
|
+
status?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface RuntimeFactSnapshot {
|
|
21
|
+
protocol: 1;
|
|
22
|
+
sessionId: string;
|
|
23
|
+
cursor?: string;
|
|
24
|
+
consistency: "overlap";
|
|
25
|
+
execution: null | {
|
|
26
|
+
turnId: string;
|
|
27
|
+
status: string;
|
|
28
|
+
execution: "active" | "inactive" | "unconfirmed" | "lost";
|
|
29
|
+
lastSeq: number;
|
|
30
|
+
result?: string;
|
|
31
|
+
waiting?: string;
|
|
32
|
+
interaction?: {
|
|
33
|
+
state: string;
|
|
34
|
+
requestId?: string;
|
|
35
|
+
approvalId?: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export declare function projectRuntimeFact(envelope: AgentEventEnvelope): RuntimeFact | null;
|
|
40
|
+
export declare function createRuntimeFacts(ports: RuntimePorts): {
|
|
41
|
+
read: (input: {
|
|
42
|
+
sessionId: string;
|
|
43
|
+
cursor?: string;
|
|
44
|
+
limit: number;
|
|
45
|
+
}) => Promise<{
|
|
46
|
+
items: RuntimeFact[];
|
|
47
|
+
cursor: string | undefined;
|
|
48
|
+
nextCursor: string | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
snapshot: (input: {
|
|
51
|
+
sessionId: string;
|
|
52
|
+
}) => Promise<RuntimeFactSnapshot>;
|
|
53
|
+
};
|
|
54
|
+
export type RuntimeFacts = ReturnType<typeof createRuntimeFacts>;
|
|
@@ -2,9 +2,11 @@ import type { ProductMode, ChatRetrievalMode } from "../domain/product-mode";
|
|
|
2
2
|
import type { RuntimePorts } from "../ports";
|
|
3
3
|
import type { Session, SessionPersistenceMode, SessionRunConfig } from "../domain";
|
|
4
4
|
import type { JobService } from "./job-service";
|
|
5
|
+
import type { SessionDirectoryPage, SessionDirectoryQuery } from "../ports/session-store";
|
|
5
6
|
export interface SessionService {
|
|
6
7
|
create(input: CreateSessionInput): Promise<Session>;
|
|
7
8
|
list(): Promise<Session[]>;
|
|
9
|
+
listDirectoryPage(query: SessionDirectoryQuery): Promise<SessionDirectoryPage>;
|
|
8
10
|
get(id: string): Promise<Session | null>;
|
|
9
11
|
save(session: Session): Promise<void>;
|
|
10
12
|
setDefaultRunConfig(id: string, runConfig: SessionRunConfig): Promise<Session>;
|
|
@@ -12,6 +14,7 @@ export interface SessionService {
|
|
|
12
14
|
delete(id: string): Promise<boolean>;
|
|
13
15
|
}
|
|
14
16
|
export interface CreateSessionInput {
|
|
17
|
+
managedExecution?: Session["managedExecution"];
|
|
15
18
|
id?: string;
|
|
16
19
|
productMode?: ProductMode;
|
|
17
20
|
chatRetrievalMode?: ChatRetrievalMode;
|
|
@@ -21,3 +24,9 @@ export interface CreateSessionInput {
|
|
|
21
24
|
defaultRunConfig?: SessionRunConfig;
|
|
22
25
|
}
|
|
23
26
|
export declare function createSessionService(ports: RuntimePorts, jobService?: JobService): SessionService;
|
|
27
|
+
export declare function createSessionForThread(ports: RuntimePorts, input: CreateSessionInput & {
|
|
28
|
+
id: string;
|
|
29
|
+
}, creation: {
|
|
30
|
+
creationId: string;
|
|
31
|
+
source: NonNullable<Session["creationSource"]>;
|
|
32
|
+
}): Promise<Session>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { RuntimePorts } from "../ports";
|
|
2
|
+
import type { ThreadStore } from "../ports/thread-store";
|
|
3
|
+
import type { ThreadControl, ThreadControlIntent, ThreadDelivery, ThreadDeliveryReason, ThreadMessage } from "../domain/thread-collaboration";
|
|
4
|
+
export interface ThreadDeliveryHostContext {
|
|
5
|
+
workspaceId: string;
|
|
6
|
+
executionHost?: string;
|
|
7
|
+
stateRootId: string;
|
|
8
|
+
ownerId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ThreadStartDelivery {
|
|
11
|
+
groupId: string;
|
|
12
|
+
message: ThreadMessage;
|
|
13
|
+
delivery: ThreadDelivery;
|
|
14
|
+
}
|
|
15
|
+
export interface ThreadReconcileResult {
|
|
16
|
+
requeued: string[];
|
|
17
|
+
delivered: string[];
|
|
18
|
+
recoveryRequired: string[];
|
|
19
|
+
observing: string[];
|
|
20
|
+
}
|
|
21
|
+
export declare function createThreadDeliveryService(ports: RuntimePorts, store: ThreadStore, context: ThreadDeliveryHostContext): {
|
|
22
|
+
ownerId: string;
|
|
23
|
+
leaseStaleMs: number;
|
|
24
|
+
listGroups: () => Promise<string[]>;
|
|
25
|
+
querySnapshot: () => Promise<ThreadControl[]>;
|
|
26
|
+
readGroup: (groupId: string) => Promise<ThreadControl | null>;
|
|
27
|
+
claimDeliveries: (input: {
|
|
28
|
+
activeThreads: readonly string[];
|
|
29
|
+
limit?: number;
|
|
30
|
+
snapshot?: readonly ThreadControl[];
|
|
31
|
+
}) => Promise<ThreadStartDelivery[]>;
|
|
32
|
+
heartbeat: (input: {
|
|
33
|
+
groupId: string;
|
|
34
|
+
messageId: string;
|
|
35
|
+
}) => Promise<boolean>;
|
|
36
|
+
completeDelivery: (input: {
|
|
37
|
+
groupId: string;
|
|
38
|
+
messageId: string;
|
|
39
|
+
turnId: string;
|
|
40
|
+
}) => Promise<void>;
|
|
41
|
+
failDelivery: (input: {
|
|
42
|
+
groupId: string;
|
|
43
|
+
messageId: string;
|
|
44
|
+
reason: ThreadDeliveryReason;
|
|
45
|
+
}) => Promise<void>;
|
|
46
|
+
releaseDelivery: (input: {
|
|
47
|
+
groupId: string;
|
|
48
|
+
messageId: string;
|
|
49
|
+
}) => Promise<void>;
|
|
50
|
+
reconcile: (input?: {
|
|
51
|
+
staleMs?: number;
|
|
52
|
+
activeMessageIds?: readonly string[];
|
|
53
|
+
snapshot?: readonly ThreadControl[];
|
|
54
|
+
}) => Promise<ThreadReconcileResult>;
|
|
55
|
+
pendingInteractionContinuations: (snapshot?: readonly ThreadControl[]) => Promise<(ThreadControlIntent & {
|
|
56
|
+
groupId: string;
|
|
57
|
+
})[]>;
|
|
58
|
+
claimInteractionContinuation: (input: {
|
|
59
|
+
groupId: string;
|
|
60
|
+
controlId: string;
|
|
61
|
+
}) => Promise<boolean>;
|
|
62
|
+
settleInteractionContinuation: (input: Parameters<(input: {
|
|
63
|
+
groupId: string;
|
|
64
|
+
controlId: string;
|
|
65
|
+
status?: "pending" | "executing" | "completed" | "failed";
|
|
66
|
+
failureCode?: "BOUNDARY_CHANGED" | "CONTINUE_FAILED";
|
|
67
|
+
failureDiagnostic?: import("../domain/thread-collaboration").ThreadControlIntent["failureDiagnostic"];
|
|
68
|
+
}) => Promise<void>>[0]) => Promise<void>;
|
|
69
|
+
pendingResumes: (snapshot?: readonly ThreadControl[]) => Promise<{
|
|
70
|
+
groupId: string;
|
|
71
|
+
controlId: string;
|
|
72
|
+
threadId: string;
|
|
73
|
+
expectedTurnId: string;
|
|
74
|
+
checkpointDigest?: string;
|
|
75
|
+
}[]>;
|
|
76
|
+
claimResume: (input: {
|
|
77
|
+
groupId: string;
|
|
78
|
+
controlId: string;
|
|
79
|
+
}) => Promise<boolean>;
|
|
80
|
+
rejectResume: (input: {
|
|
81
|
+
groupId: string;
|
|
82
|
+
controlId: string;
|
|
83
|
+
}) => Promise<void>;
|
|
84
|
+
pendingInterrupts: (snapshot?: readonly ThreadControl[]) => Promise<{
|
|
85
|
+
groupId: string;
|
|
86
|
+
controlId: string;
|
|
87
|
+
threadId: string;
|
|
88
|
+
expectedTurnId: string;
|
|
89
|
+
}[]>;
|
|
90
|
+
settleInterrupt: (input: {
|
|
91
|
+
groupId: string;
|
|
92
|
+
controlId: string;
|
|
93
|
+
applied: boolean;
|
|
94
|
+
}) => Promise<void>;
|
|
95
|
+
recordHostOffline: (groupId: string) => Promise<void>;
|
|
96
|
+
};
|
|
97
|
+
export type ThreadDeliveryService = ReturnType<typeof createThreadDeliveryService>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RuntimePorts } from "../ports";
|
|
2
|
+
import type { ThreadControl } from "../domain/thread-collaboration";
|
|
3
|
+
export declare function readFrozenThreadExecutionHost(ports: RuntimePorts, threadId: string): Promise<string | undefined>;
|
|
4
|
+
export declare function inferThreadExecutionHost(ports: RuntimePorts, control: ThreadControl, threadId: string): Promise<string | undefined>;
|
|
5
|
+
export declare function withThreadExecutionHost(control: ThreadControl, threadId: string, executionHost: string): ThreadControl;
|
|
6
|
+
export declare function resolveThreadExecutionHost(ports: RuntimePorts, groupId: string, threadId: string): Promise<string | undefined>;
|
|
7
|
+
export declare function assertThreadExecutionHost(ports: RuntimePorts, sessionId: string, projectId: string | undefined, executionHost: string | undefined, continuing?: boolean): Promise<void>;
|