@autopilot-agent/adapters 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 +11 -5
- package/dist/index.d.ts +9 -1
- package/dist/index.js +2024 -528
- package/dist/index.mjs +1996 -514
- package/dist/node/create-node-chat-capability-loader.d.ts +1 -0
- package/dist/node/desktop-status-protocol.d.ts +62 -0
- package/dist/node/file-utils.d.ts +10 -0
- package/dist/node/host-identity.d.ts +2 -0
- package/dist/node/node-errors.d.ts +13 -2
- package/dist/node/runtime-owner.d.ts +1 -0
- package/dist/node/settings/node-user-settings-service.d.ts +11 -1
- package/dist/node/state-root.d.ts +1 -1
- package/dist/node/state-upgrade.d.ts +2 -0
- package/dist/node/stores/node-session-image-store.d.ts +2 -0
- package/dist/node/stores/node-thread-store.d.ts +2 -0
- package/dist/node/stores/session-directory.d.ts +1 -0
- package/dist/node/thread-handoff.d.ts +5 -0
- package/dist/node/thread-runner.d.ts +57 -0
- package/package.json +2 -2
|
@@ -3,6 +3,7 @@ import type { NodeChatStorage } from "./create-node-chat-storage";
|
|
|
3
3
|
export declare const NODE_CHAT_KNOWLEDGE_SPACE_ID = "chat-knowledge-v1";
|
|
4
4
|
export interface NodeChatCapabilityLoaderOptions {
|
|
5
5
|
storage: NodeChatStorage;
|
|
6
|
+
interactiveUi?: boolean;
|
|
6
7
|
visionAnalyzer?: VisionAnalyzer;
|
|
7
8
|
loadKnowledge?: (input: ChatCapabilityBinding & {
|
|
8
9
|
knowledgeRoot: string;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare const DESKTOP_STATUS_VERSION = 1;
|
|
2
|
+
export declare const DESKTOP_STATUS_FRAME_BYTES: number;
|
|
3
|
+
export declare const DESKTOP_STATUS_QUEUE_BYTES: number;
|
|
4
|
+
export interface DesktopSessionStatus {
|
|
5
|
+
sessionId: string;
|
|
6
|
+
turnId?: string;
|
|
7
|
+
selected: boolean;
|
|
8
|
+
relation: "opened" | "locallyDriven" | "relatedObserved";
|
|
9
|
+
freshness: "fresh" | "unknown";
|
|
10
|
+
status: "idle" | "running" | "waiting_approval" | "waiting_user_input" | "completed" | "failed" | "interrupted";
|
|
11
|
+
execution?: "active" | "inactive" | "unconfirmed" | "lost";
|
|
12
|
+
waiting?: "approval" | "user_input" | "threads";
|
|
13
|
+
result?: "completed" | "failed" | "interrupted" | "limit_reached";
|
|
14
|
+
interaction?: "pending" | "decided" | "expired" | "unconfirmed";
|
|
15
|
+
continuation?: "pending" | "applied" | "rejected" | "claimed" | "executing" | "completed" | "failed";
|
|
16
|
+
recoverable?: boolean;
|
|
17
|
+
lastSeq: number;
|
|
18
|
+
}
|
|
19
|
+
export interface DesktopWorkspaceStatus {
|
|
20
|
+
workspaceId: string;
|
|
21
|
+
stateRootId: string;
|
|
22
|
+
projectId: string;
|
|
23
|
+
displayName: string;
|
|
24
|
+
}
|
|
25
|
+
export interface DesktopStatusIdentity {
|
|
26
|
+
desktopInstanceId: string;
|
|
27
|
+
paneId: string;
|
|
28
|
+
generation: number;
|
|
29
|
+
apInstanceId: string;
|
|
30
|
+
}
|
|
31
|
+
export type DesktopStatusFrame = DesktopStatusIdentity & {
|
|
32
|
+
protocolVersion: 1;
|
|
33
|
+
seq: number;
|
|
34
|
+
} & ({
|
|
35
|
+
type: "hello";
|
|
36
|
+
token: string;
|
|
37
|
+
cliVersion: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: "snapshot";
|
|
40
|
+
snapshotId: string;
|
|
41
|
+
part: number;
|
|
42
|
+
final: boolean;
|
|
43
|
+
lifecycle: "starting" | "ready";
|
|
44
|
+
workspace?: DesktopWorkspaceStatus;
|
|
45
|
+
sessions: DesktopSessionStatus[];
|
|
46
|
+
} | {
|
|
47
|
+
type: "heartbeat";
|
|
48
|
+
} | {
|
|
49
|
+
type: "ap_exiting";
|
|
50
|
+
});
|
|
51
|
+
export type DesktopStatusReply = {
|
|
52
|
+
type: "accepted" | "ack" | "resync_required";
|
|
53
|
+
seq: number;
|
|
54
|
+
};
|
|
55
|
+
export declare function isDesktopStatusId(value: unknown): value is string;
|
|
56
|
+
export declare function isDesktopSessionStatus(value: unknown): value is DesktopSessionStatus;
|
|
57
|
+
export declare function isDesktopStatusFrame(value: unknown): value is DesktopStatusFrame;
|
|
58
|
+
export declare function isDesktopStatusReply(value: unknown): value is DesktopStatusReply;
|
|
59
|
+
export declare class DesktopStatusLines {
|
|
60
|
+
private pending;
|
|
61
|
+
push(chunk: Buffer): unknown[];
|
|
62
|
+
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export interface FileOperationDiagnostic {
|
|
2
|
+
phase: "lock" | "temporary_write" | "rename" | "cleanup";
|
|
3
|
+
osCode?: string;
|
|
4
|
+
lockWaitMs?: number;
|
|
5
|
+
attempts?: number;
|
|
6
|
+
elapsedMs?: number;
|
|
7
|
+
cleanupFailed?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function getFileOperationDiagnostic(error: unknown): FileOperationDiagnostic | undefined;
|
|
1
10
|
export interface JsonlCorruptionDiagnostic {
|
|
2
11
|
code: "DURABLE_JSONL_CORRUPTED";
|
|
3
12
|
line: number;
|
|
@@ -9,6 +18,7 @@ export declare function withFileLock<T>(filePath: string, operation: () => T | P
|
|
|
9
18
|
export declare function withAsyncFileLock<T>(filePath: string, operation: () => T | Promise<T>): Promise<T>;
|
|
10
19
|
export declare function ensureParentDirectory(filePath: string): void;
|
|
11
20
|
export declare function atomicReplace(filePath: string, content: string): void;
|
|
21
|
+
export declare function replaceSessionFile(filePath: string, content: string): Promise<void>;
|
|
12
22
|
export declare function safeFilePath(directory: string, key: string, extension: string): string;
|
|
13
23
|
export declare function readJsonFile<T>(filePath: string): T | null;
|
|
14
24
|
export declare function readJsonLines<T>(filePath: string): {
|
|
@@ -15,10 +15,21 @@ export interface NodeStateRecoveryDiagnostic {
|
|
|
15
15
|
backupPath?: string;
|
|
16
16
|
reasonCode: NodeStateErrorCode | NodeChatErrorCode | AgentErrorCode;
|
|
17
17
|
}
|
|
18
|
+
export interface NodeStorageDiagnostic {
|
|
19
|
+
operation: "session_save";
|
|
20
|
+
target: "session";
|
|
21
|
+
phase: "prepare" | "identity" | "lock" | "temporary_write" | "rename" | "cleanup";
|
|
22
|
+
osCode?: string;
|
|
23
|
+
lockWaitMs?: number;
|
|
24
|
+
attempts?: number;
|
|
25
|
+
elapsedMs?: number;
|
|
26
|
+
cleanupFailed?: boolean;
|
|
27
|
+
}
|
|
18
28
|
export declare class NodeStateError extends Error {
|
|
19
29
|
#private;
|
|
20
30
|
readonly code: NodeStateErrorCode;
|
|
21
|
-
constructor(code: NodeStateErrorCode, recovery?: NodeStateRecoveryDiagnostic);
|
|
31
|
+
constructor(code: NodeStateErrorCode, recovery?: NodeStateRecoveryDiagnostic, storage?: NodeStorageDiagnostic);
|
|
32
|
+
getStorageDiagnostic(): NodeStorageDiagnostic | undefined;
|
|
22
33
|
getRecoveryDiagnostic(): NodeStateRecoveryDiagnostic | undefined;
|
|
23
34
|
}
|
|
24
35
|
export declare class NodeChatError extends Error {
|
|
@@ -26,5 +37,5 @@ export declare class NodeChatError extends Error {
|
|
|
26
37
|
constructor(code: NodeChatErrorCode);
|
|
27
38
|
}
|
|
28
39
|
export declare function createNodeIdentityError(code: NodeIdentityErrorCode): AgentRuntimeError;
|
|
29
|
-
export declare function toNodeBoundaryError(error: unknown, fallback: NodeStateErrorCode | NodeChatErrorCode): NodeStateError | NodeChatError | AgentRuntimeError;
|
|
40
|
+
export declare function toNodeBoundaryError(error: unknown, fallback: NodeStateErrorCode | NodeChatErrorCode, storage?: NodeStorageDiagnostic): NodeStateError | NodeChatError | AgentRuntimeError;
|
|
30
41
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withNodeRuntimeOwner<T>(stateRoot: string, operation: () => Promise<T>): Promise<T>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ApiProtocol, type ProviderRouteProfile, type ReasoningEffort } from "@autopilot-agent/core";
|
|
1
2
|
declare const RAG_ROLE_CONTRACT: Readonly<{
|
|
2
3
|
readonly textRerank: {
|
|
3
4
|
readonly provider: "bailian";
|
|
@@ -22,6 +23,8 @@ declare const RAG_ROLE_CONTRACT: Readonly<{
|
|
|
22
23
|
}>;
|
|
23
24
|
type RagConnectionRole = keyof typeof RAG_ROLE_CONTRACT;
|
|
24
25
|
export interface MainSettingsCategoryInput {
|
|
26
|
+
apiProtocol?: ApiProtocol;
|
|
27
|
+
compatibilityPreset?: ProviderRouteProfile["compatibilityPreset"];
|
|
25
28
|
baseUrl: string;
|
|
26
29
|
model: string;
|
|
27
30
|
apiKey?: string;
|
|
@@ -30,12 +33,17 @@ export interface MainSettingsCategoryInput {
|
|
|
30
33
|
sonnetModel?: string;
|
|
31
34
|
haikuModel?: string;
|
|
32
35
|
subagentModel?: string;
|
|
33
|
-
effort?: "auto" |
|
|
36
|
+
effort?: "auto" | ReasoningEffort;
|
|
34
37
|
maxOutputTokens?: number;
|
|
35
38
|
compactWindow?: number;
|
|
36
39
|
timeoutMs?: number;
|
|
37
40
|
alwaysThinkingEnabled?: boolean;
|
|
38
41
|
}
|
|
42
|
+
export type MainModelCapabilitiesInput = Pick<MainSettingsCategoryInput, "apiProtocol" | "compatibilityPreset" | "baseUrl" | "model">;
|
|
43
|
+
export interface MainModelCapabilities {
|
|
44
|
+
supportedReasoningEfforts: readonly ReasoningEffort[];
|
|
45
|
+
supportsToolCalls: boolean;
|
|
46
|
+
}
|
|
39
47
|
export interface RagSettingsCategoryConnectionInput {
|
|
40
48
|
provider: "bailian" | "openai-compatible" | "dashscope";
|
|
41
49
|
baseUrl: string;
|
|
@@ -91,7 +99,9 @@ export declare class NodeUserSettingsError extends Error {
|
|
|
91
99
|
export declare function createNodeUserSettingsService(options?: {
|
|
92
100
|
homeDirectory?: string;
|
|
93
101
|
fetchImpl?: typeof fetch;
|
|
102
|
+
env?: NodeJS.ProcessEnv;
|
|
94
103
|
}): {
|
|
104
|
+
getMainModelCapabilities(input: MainModelCapabilitiesInput): MainModelCapabilities;
|
|
95
105
|
refreshMainModelCatalog(): Promise<MainModelCatalogResult>;
|
|
96
106
|
getStatus(): UserSettingsStatus;
|
|
97
107
|
getRevision(): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type NodeStateSchemaDiagnostic } from "./state-schema-manager";
|
|
2
2
|
import { type JsonlCorruptionDiagnostic } from "./file-utils";
|
|
3
|
-
export declare const NODE_STATE_SCHEMA_VERSION =
|
|
3
|
+
export declare const NODE_STATE_SCHEMA_VERSION = 8;
|
|
4
4
|
export declare const NODE_WORKSPACE_ID_VERSION = 1;
|
|
5
5
|
export interface NodeStateCorruptionDiagnostic extends JsonlCorruptionDiagnostic {
|
|
6
6
|
file: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readSessionDirectoryRecord(filePath: string, id: string): Promise<import("@autopilot-agent/core").Session>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ThreadHandoffWriter } from "@autopilot-agent/core";
|
|
2
|
+
export interface CreateNodeThreadHandoffWriterOptions {
|
|
3
|
+
workspaceRoot: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function createNodeThreadHandoffWriter(options: CreateNodeThreadHandoffWriterOptions): ThreadHandoffWriter;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type ThreadControlIntent } from "@autopilot-agent/core";
|
|
2
|
+
import type { AgentRuntime, RuntimePorts, ThreadActor, ThreadDeliveryService, ThreadHandoffRef, ThreadMessage, ThreadReconcileResult } from "@autopilot-agent/core";
|
|
3
|
+
export interface NodeThreadRunnerPrompt {
|
|
4
|
+
content: string;
|
|
5
|
+
messageId: string;
|
|
6
|
+
from: ThreadActor;
|
|
7
|
+
handoff?: ThreadHandoffRef;
|
|
8
|
+
handoffDisplay?: ThreadMessage["handoffDisplay"];
|
|
9
|
+
}
|
|
10
|
+
export interface NodeThreadRunnerOptions {
|
|
11
|
+
delivery: ThreadDeliveryService;
|
|
12
|
+
runtime: AgentRuntime;
|
|
13
|
+
ports: RuntimePorts;
|
|
14
|
+
pollIntervalMs?: number;
|
|
15
|
+
heartbeatMs?: number;
|
|
16
|
+
staleMs?: number;
|
|
17
|
+
reconcileEveryMs?: number;
|
|
18
|
+
onError?: (error: unknown, continuation?: Pick<ThreadControlIntent, "threadId" | "expectedTurnId" | "controlId" | "approvalId" | "requestId" | "failureDiagnostic">) => void;
|
|
19
|
+
onTurnStarted?: (input: {
|
|
20
|
+
threadId: string;
|
|
21
|
+
turnId: string;
|
|
22
|
+
prompt: NodeThreadRunnerPrompt;
|
|
23
|
+
}) => Promise<void> | void;
|
|
24
|
+
onTurnSettled?: (input: {
|
|
25
|
+
threadId: string;
|
|
26
|
+
turnId: string;
|
|
27
|
+
}) => Promise<void> | void;
|
|
28
|
+
}
|
|
29
|
+
export interface NodeThreadRunnerStopReport {
|
|
30
|
+
stopped: boolean;
|
|
31
|
+
cancelledTurnIds: string[];
|
|
32
|
+
unconfirmedTurnIds: string[];
|
|
33
|
+
releasedMessageIds: string[];
|
|
34
|
+
waitingTurnIds?: string[];
|
|
35
|
+
pendingMessageIds?: string[];
|
|
36
|
+
recoverableTurnIds?: string[];
|
|
37
|
+
}
|
|
38
|
+
export interface NodeThreadRunner {
|
|
39
|
+
listExecutions(): Array<{
|
|
40
|
+
threadId: string;
|
|
41
|
+
turnId: string;
|
|
42
|
+
}>;
|
|
43
|
+
start(): Promise<void>;
|
|
44
|
+
stop(): Promise<NodeThreadRunnerStopReport>;
|
|
45
|
+
kick(): void;
|
|
46
|
+
isRunning(): boolean;
|
|
47
|
+
reconcile(): Promise<ThreadReconcileResult>;
|
|
48
|
+
registerExecution(input: {
|
|
49
|
+
threadId: string;
|
|
50
|
+
turnId: string;
|
|
51
|
+
cancel(): void;
|
|
52
|
+
}): {
|
|
53
|
+
activate(): void;
|
|
54
|
+
release(): void;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export declare function createNodeThreadRunner(options: NodeThreadRunnerOptions): NodeThreadRunner;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autopilot-agent/adapters",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@anthropic-ai/sandbox-runtime": "0.0.78",
|
|
45
|
-
"@autopilot-agent/core": "0.
|
|
45
|
+
"@autopilot-agent/core": "0.4.0",
|
|
46
46
|
"js-yaml": "4.3.0",
|
|
47
47
|
"linkedom": "0.18.12"
|
|
48
48
|
},
|