@autopilot-agent/core 0.2.0 → 0.3.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 +6 -4
- package/dist/experimental/index.js +64 -59
- package/dist/experimental/index.mjs +64 -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 +23 -3
- package/dist/index.js +241 -214
- package/dist/index.mjs +241 -214
- package/dist/internal/agent-runtime.d.ts +79 -2
- package/dist/internal/kernel/model-sampler.d.ts +5 -0
- package/dist/internal/kernel/run-context.d.ts +4 -0
- package/dist/internal/kernel/session-images.d.ts +21 -0
- package/dist/internal/kernel/turn-usage.d.ts +13 -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 +6 -1
- package/dist/internal/lib/llm.js +3 -3
- package/dist/internal/lib/pdf-processor.js +1 -1
- 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/process-utils.d.ts +1 -0
- package/dist/internal/tools/thread-observation-display.d.ts +2 -0
- package/dist/internal/tools/types.d.ts +18 -0
- package/dist/internal/types/agent-message.d.ts +11 -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/session-service.d.ts +8 -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-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 +12 -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/domain/frozen-run-config.d.ts +1 -0
- package/dist/runtime/domain/index.d.ts +7 -1
- package/dist/runtime/domain/input-inbox.d.ts +16 -0
- package/dist/runtime/domain/session-presentation.d.ts +9 -0
- package/dist/runtime/domain/thread-collaboration.d.ts +179 -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/chat-capability.d.ts +1 -0
- package/dist/runtime/protocol/error-code.d.ts +1 -1
- package/dist/runtime/protocol/recoverable-turn-view.d.ts +3 -0
- package/dist/runtime/protocol/run-config.d.ts +1 -0
- package/dist/runtime/protocol/threads-capability.d.ts +14 -0
- 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/frozen-provider-config.d.ts +1 -0
- package/dist/runtime/provider/index.d.ts +1 -1
- package/dist/runtime/provider/model-capability-catalog.d.ts +2 -0
- package/dist/runtime/provider/openai-chat-completions-adapter.d.ts +2 -1
- 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 +4 -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 -1
|
@@ -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" | 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;
|
|
@@ -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;
|
|
@@ -280,6 +287,10 @@ export interface ToolEvent {
|
|
|
280
287
|
errorCode?: string;
|
|
281
288
|
}
|
|
282
289
|
export interface ToolExecutionContext {
|
|
290
|
+
reportingAgreement?: {
|
|
291
|
+
taskId: string;
|
|
292
|
+
explicit: boolean;
|
|
293
|
+
};
|
|
283
294
|
hostMutationProtection?: import("../../runtime/ports/host-mutation-protection").HostMutationProtection;
|
|
284
295
|
executionSessionId?: string;
|
|
285
296
|
externalExecutionAuthority?: ExternalExecutionAuthority;
|
|
@@ -307,6 +318,7 @@ export interface ToolExecutionContext {
|
|
|
307
318
|
mimeType: string;
|
|
308
319
|
}>;
|
|
309
320
|
};
|
|
321
|
+
getVisibleMessages?: () => readonly import("../types/agent-message").AgentMessage[];
|
|
310
322
|
fileReadStates?: Map<string, {
|
|
311
323
|
sha256: string;
|
|
312
324
|
mtimeMs: number;
|
|
@@ -374,6 +386,7 @@ export interface AgentToolDefinition<TInput, TOutput> {
|
|
|
374
386
|
createActionFacts(input: TInput, context: ToolExecutionContext): ToolActionFacts | Promise<ToolActionFacts>;
|
|
375
387
|
execute(input: TInput, context: ToolExecutionContext): Promise<TOutput>;
|
|
376
388
|
serializeOutput(output: TOutput): unknown;
|
|
389
|
+
getImageReferences?(output: TOutput): import("../types/agent-message").AgentImageReference[];
|
|
377
390
|
projectDisplayDetail?(output: TOutput): ToolDisplayDetail | undefined;
|
|
378
391
|
createExecutionResult?(input: TInput, output: TOutput, context: {
|
|
379
392
|
callId: string;
|
|
@@ -388,7 +401,12 @@ export interface ToolModelDefinition {
|
|
|
388
401
|
inputSchema: Record<string, unknown>;
|
|
389
402
|
}
|
|
390
403
|
export interface ToolExecutionOptions {
|
|
404
|
+
reportingAgreement?: {
|
|
405
|
+
taskId: string;
|
|
406
|
+
explicit: boolean;
|
|
407
|
+
};
|
|
391
408
|
signal?: AbortSignal;
|
|
409
|
+
approvalOnly?: boolean;
|
|
392
410
|
timeoutMs?: number;
|
|
393
411
|
onProgress?: (callId: string, chunk: string) => void;
|
|
394
412
|
}
|
|
@@ -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,6 +26,7 @@ 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;
|
|
@@ -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[];
|
|
@@ -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;
|
|
@@ -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>;
|
|
@@ -21,3 +23,9 @@ export interface CreateSessionInput {
|
|
|
21
23
|
defaultRunConfig?: SessionRunConfig;
|
|
22
24
|
}
|
|
23
25
|
export declare function createSessionService(ports: RuntimePorts, jobService?: JobService): SessionService;
|
|
26
|
+
export declare function createSessionForThread(ports: RuntimePorts, input: CreateSessionInput & {
|
|
27
|
+
id: string;
|
|
28
|
+
}, creation: {
|
|
29
|
+
creationId: string;
|
|
30
|
+
source: NonNullable<Session["creationSource"]>;
|
|
31
|
+
}): 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>;
|