@autopilot-agent/core 0.1.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 +57 -3
- package/dist/experimental/index.js +67 -59
- package/dist/experimental/index.mjs +67 -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 +35 -7
- package/dist/index.js +242 -211
- package/dist/index.mjs +242 -211
- package/dist/internal/agent-runtime.d.ts +92 -3
- package/dist/internal/kernel/completion-policy.d.ts +4 -0
- package/dist/internal/kernel/model-sampler.d.ts +5 -0
- package/dist/internal/kernel/run-context.d.ts +12 -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/tool-scheduler.d.ts +1 -0
- package/dist/internal/tools/builtins/open-preview-tool.d.ts +22 -0
- 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/run-command-tool.d.ts +2 -2
- package/dist/internal/tools/builtins/start-background-job-tool.d.ts +9 -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/todo-write-tool.d.ts +14 -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 +9 -0
- package/dist/internal/tools/normalized-tool-input.d.ts +1 -0
- package/dist/internal/tools/permissions/command-policy.d.ts +11 -0
- package/dist/internal/tools/permissions/external-execution-policy.d.ts +14 -0
- package/dist/internal/tools/permissions/mutation-policy.d.ts +7 -0
- package/dist/internal/tools/permissions/path-access-policy.d.ts +13 -0
- package/dist/internal/tools/permissions/workspace-path.d.ts +5 -0
- package/dist/internal/tools/policy-engine.d.ts +1 -0
- package/dist/internal/tools/process-utils.d.ts +12 -0
- package/dist/internal/tools/sandbox-policy-resolver.d.ts +2 -0
- package/dist/internal/tools/thread-observation-display.d.ts +2 -0
- package/dist/internal/tools/tool-executor.d.ts +2 -1
- package/dist/internal/tools/types.d.ts +84 -2
- package/dist/internal/types/agent-message.d.ts +11 -1
- package/dist/runtime/adapters/memory/memory-approval-store.d.ts +39 -0
- package/dist/runtime/adapters/memory/memory-file-mutation-store.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 +74 -3
- package/dist/runtime/application/input-inbox-service.d.ts +1 -1
- package/dist/runtime/application/job-execution-facts.d.ts +2 -0
- package/dist/runtime/application/job-service-ownership.d.ts +5 -0
- package/dist/runtime/application/job-service.d.ts +9 -0
- 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-conversation-builder.d.ts +3 -3
- 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/turn-runtime-config-resolver.d.ts +2 -2
- package/dist/runtime/application/turn-service.d.ts +28 -0
- package/dist/runtime/application/undo-service.d.ts +4 -0
- package/dist/runtime/application/user-question-service.d.ts +1 -0
- package/dist/runtime/bootstrap/runtime-bootstrap-service.d.ts +2 -1
- package/dist/runtime/config/autopilot-settings.d.ts +9 -0
- package/dist/runtime/config/runtime-limits.d.ts +2 -4
- package/dist/runtime/domain/approval.d.ts +18 -0
- package/dist/runtime/domain/external-execution.d.ts +42 -0
- package/dist/runtime/domain/external-permissions.d.ts +32 -0
- package/dist/runtime/domain/frozen-run-config.d.ts +3 -0
- package/dist/runtime/domain/index.d.ts +13 -3
- package/dist/runtime/domain/input-inbox.d.ts +16 -0
- package/dist/runtime/domain/job-service-url.d.ts +3 -0
- package/dist/runtime/domain/job.d.ts +18 -0
- package/dist/runtime/domain/sandbox-policy.d.ts +30 -0
- package/dist/runtime/domain/session-presentation.d.ts +9 -0
- package/dist/runtime/domain/thread-collaboration.d.ts +179 -0
- package/dist/runtime/domain/todo.d.ts +4 -0
- package/dist/runtime/ports/approval-store.d.ts +39 -1
- package/dist/runtime/ports/external-permission-projector.d.ts +14 -0
- package/dist/runtime/ports/file-mutation-store.d.ts +1 -1
- package/dist/runtime/ports/host-mutation-protection.d.ts +7 -0
- package/dist/runtime/ports/index.d.ts +13 -1
- package/dist/runtime/ports/lease-store.d.ts +4 -0
- package/dist/runtime/ports/sandbox-port.d.ts +1 -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/index.d.ts +1 -0
- package/dist/runtime/protocol/recoverable-turn-view.d.ts +4 -1
- package/dist/runtime/protocol/run-config.d.ts +4 -0
- package/dist/runtime/protocol/threads-capability.d.ts +14 -0
- package/dist/runtime/protocol/work-preview-capability.d.ts +24 -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
|
@@ -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
|
}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import type { ApprovalStore, CheckpointStore, Clock, TranscriptStore, TurnStore } from "../ports";
|
|
2
|
-
import type
|
|
1
|
+
import type { ApprovalStore, CheckpointStore, Clock, ExternalPermissionProjector, TranscriptStore, TurnStore } from "../ports";
|
|
2
|
+
import { type ApprovalDecision, type PersistentGrant, type SubmitApprovalInput } from "../domain/approval";
|
|
3
|
+
import { type ExternalExecutionAuthorization } from "../domain/external-execution";
|
|
4
|
+
import type { ExternalExecutionAuthority } from "../../internal/tools/types";
|
|
5
|
+
import type { TurnExecutionView } from "./turn/turn-execution-view";
|
|
3
6
|
export interface ApprovalServiceDependencies {
|
|
4
7
|
approvalStore: ApprovalStore;
|
|
5
8
|
checkpointStore: CheckpointStore;
|
|
6
9
|
transcriptStore: TranscriptStore;
|
|
7
10
|
turnStore: TurnStore;
|
|
8
11
|
clock: Clock;
|
|
12
|
+
readExecution?(input: {
|
|
13
|
+
sessionId: string;
|
|
14
|
+
turnId: string;
|
|
15
|
+
}): Promise<TurnExecutionView | null>;
|
|
16
|
+
externalRuleProjector?: ExternalPermissionProjector;
|
|
17
|
+
}
|
|
18
|
+
export interface RevokePersistentGrantResult {
|
|
19
|
+
deleted: boolean;
|
|
20
|
+
ruleRemoved: boolean;
|
|
9
21
|
}
|
|
10
22
|
export interface ApprovalService {
|
|
11
23
|
submit(input: SubmitApprovalInput): Promise<ApprovalDecision>;
|
|
@@ -20,5 +32,64 @@ export interface ApprovalService {
|
|
|
20
32
|
toolName: string;
|
|
21
33
|
constraint: string;
|
|
22
34
|
}): Promise<boolean>;
|
|
35
|
+
listPersistentGrants(input?: {
|
|
36
|
+
workspaceRoot?: string;
|
|
37
|
+
sessionId?: string;
|
|
38
|
+
}): Promise<PersistentGrant[]>;
|
|
39
|
+
revokePersistentGrant(input: {
|
|
40
|
+
workspaceRoot: string;
|
|
41
|
+
sessionId: string;
|
|
42
|
+
toolName: string;
|
|
43
|
+
constraint: string;
|
|
44
|
+
}): Promise<RevokePersistentGrantResult>;
|
|
45
|
+
}
|
|
46
|
+
export interface InternalApprovalService extends ApprovalService {
|
|
47
|
+
freezeExecutionApproval(input: {
|
|
48
|
+
sessionId: string;
|
|
49
|
+
turnId: string;
|
|
50
|
+
workspaceRoot: string;
|
|
51
|
+
} & Parameters<ExternalExecutionAuthority["freeze"]>[0]): Promise<void>;
|
|
52
|
+
authorizeExecution(input: {
|
|
53
|
+
sessionId: string;
|
|
54
|
+
turnId: string;
|
|
55
|
+
workspaceRoot: string;
|
|
56
|
+
} & Parameters<ExternalExecutionAuthority["authorize"]>[0]): Promise<ExternalExecutionAuthorization | null>;
|
|
57
|
+
resolveExternalRestriction(input: {
|
|
58
|
+
workspaceRoot: string;
|
|
59
|
+
toolName: string;
|
|
60
|
+
constraint: string;
|
|
61
|
+
}): Promise<"allow" | "ask" | "deny">;
|
|
62
|
+
consumeFileApproval(input: {
|
|
63
|
+
sessionId: string;
|
|
64
|
+
turnId: string;
|
|
65
|
+
approvalId: string;
|
|
66
|
+
constraint: string;
|
|
67
|
+
callId: string;
|
|
68
|
+
normalizedInputHash: string;
|
|
69
|
+
now: string;
|
|
70
|
+
}): Promise<boolean>;
|
|
71
|
+
consumeDegradeApproval(input: {
|
|
72
|
+
sessionId: string;
|
|
73
|
+
turnId: string;
|
|
74
|
+
approvalId: string;
|
|
75
|
+
constraint: string;
|
|
76
|
+
callId: string;
|
|
77
|
+
normalizedInputHash: string;
|
|
78
|
+
now: string;
|
|
79
|
+
}): Promise<boolean>;
|
|
80
|
+
hasTaskFileSetGrant(input: {
|
|
81
|
+
sessionId: string;
|
|
82
|
+
turnId: string;
|
|
83
|
+
workspaceRoot: string;
|
|
84
|
+
path: string;
|
|
85
|
+
operation: "create" | "edit";
|
|
86
|
+
}): Promise<boolean>;
|
|
87
|
+
hasExternalTaskFileSetGrant(input: {
|
|
88
|
+
sessionId: string;
|
|
89
|
+
turnId: string;
|
|
90
|
+
workspaceRoot: string;
|
|
91
|
+
canonicalTarget: string;
|
|
92
|
+
operation: "create" | "edit";
|
|
93
|
+
}): Promise<boolean>;
|
|
23
94
|
}
|
|
24
|
-
export declare function createApprovalService(dependencies: ApprovalServiceDependencies):
|
|
95
|
+
export declare function createApprovalService(dependencies: ApprovalServiceDependencies): InternalApprovalService;
|
|
@@ -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,5 @@
|
|
|
1
|
+
export interface JobServiceOwnershipProbe {
|
|
2
|
+
listenerPids(port: number): Promise<readonly number[] | undefined>;
|
|
3
|
+
ancestry(pid: number): Promise<readonly number[] | undefined>;
|
|
4
|
+
}
|
|
5
|
+
export declare function createDefaultJobServiceOwnershipProbe(): JobServiceOwnershipProbe;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type ChildProcess } from "node:child_process";
|
|
2
2
|
import type { Job, JobListView, JobOutputView, JobPollResult, JobReadView, JobView, PollJobInput, StartJobInput } from "../domain";
|
|
3
|
+
import { type ManagedExecutionControl } from "../domain/sandbox-policy";
|
|
3
4
|
import { type JobOwnerProbe, type JobStore, type ProjectStore, type SandboxPort, type SessionStore } from "../ports";
|
|
4
5
|
import { AgentRuntimeError as RuntimeError } from "../protocol";
|
|
5
6
|
import { BoundedOutputBuffer } from "../../internal/tools/process-utils";
|
|
6
7
|
import { JobOutputProjector } from "./job-output-projection";
|
|
8
|
+
import { type JobServiceOwnershipProbe } from "./job-service-ownership";
|
|
7
9
|
export interface JobService {
|
|
8
10
|
start(input: StartJobInput): Promise<Job>;
|
|
9
11
|
poll(input: PollJobInput): Promise<JobPollResult>;
|
|
@@ -42,6 +44,10 @@ export interface SessionJobService {
|
|
|
42
44
|
jobId: string;
|
|
43
45
|
source: "agent" | "host";
|
|
44
46
|
}): Promise<JobView>;
|
|
47
|
+
verifyServiceOwnership(input: {
|
|
48
|
+
jobId: string;
|
|
49
|
+
serviceUrl: string;
|
|
50
|
+
}): Promise<"owned" | "unowned" | "unverifiable">;
|
|
45
51
|
}
|
|
46
52
|
export interface InternalJobService extends JobService {
|
|
47
53
|
withSessionLock<T>(sessionId: string, operation: () => Promise<T>): Promise<T>;
|
|
@@ -54,6 +60,7 @@ export interface CreateJobServiceOptions {
|
|
|
54
60
|
runtimeInstanceId?: string;
|
|
55
61
|
hostProcessId?: number;
|
|
56
62
|
now?: () => number;
|
|
63
|
+
serviceProbe?: JobServiceOwnershipProbe;
|
|
57
64
|
}
|
|
58
65
|
interface ActiveJob {
|
|
59
66
|
child: ChildProcess;
|
|
@@ -68,6 +75,7 @@ interface ActiveJob {
|
|
|
68
75
|
transitionTail: Promise<void>;
|
|
69
76
|
closeResult?: {
|
|
70
77
|
exitCode: number | null;
|
|
78
|
+
signal?: NodeJS.Signals | null;
|
|
71
79
|
};
|
|
72
80
|
initialized: boolean;
|
|
73
81
|
projectorFlushed: boolean;
|
|
@@ -78,6 +86,7 @@ interface ActiveJob {
|
|
|
78
86
|
sandboxExecution?: {
|
|
79
87
|
port: SandboxPort;
|
|
80
88
|
executionId: string;
|
|
89
|
+
control?: ManagedExecutionControl;
|
|
81
90
|
};
|
|
82
91
|
}
|
|
83
92
|
export declare class ProcessManager {
|
|
@@ -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>;
|