@autopilot-agent/adapters 0.0.0-stage → 0.1.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 +5 -2
- package/dist/index.d.ts +63 -0
- package/dist/index.js +21020 -0
- package/dist/index.mjs +20958 -0
- package/dist/node/capabilities/context-budget.d.ts +15 -0
- package/dist/node/capabilities/instruction-store.d.ts +9 -0
- package/dist/node/capabilities/mcp-loader.d.ts +2 -0
- package/dist/node/capabilities/memory-retriever.d.ts +5 -0
- package/dist/node/capabilities/skill-discovery.d.ts +3 -0
- package/dist/node/capabilities/web/anthropic-web-search.d.ts +13 -0
- package/dist/node/capabilities/web/deepseek-responses-search.d.ts +17 -0
- package/dist/node/capabilities/web/safe-web-fetch.d.ts +22 -0
- package/dist/node/capabilities/web/url-policy.d.ts +15 -0
- package/dist/node/capabilities/web/web-search-provider.d.ts +11 -0
- package/dist/node/capabilities/web/xiaomi-mimo-chat-search.d.ts +17 -0
- package/dist/node/chat-state.d.ts +12 -0
- package/dist/node/create-node-capability-loader.d.ts +12 -0
- package/dist/node/create-node-chat-capability-loader.d.ts +12 -0
- package/dist/node/create-node-chat-storage.d.ts +41 -0
- package/dist/node/create-node-runtime-ports.d.ts +13 -0
- package/dist/node/file-utils.d.ts +18 -0
- package/dist/node/job-owner-probe.d.ts +2 -0
- package/dist/node/node-errors.d.ts +30 -0
- package/dist/node/rag/node-rag-runtime.d.ts +58 -0
- package/dist/node/sandbox/node-sandbox-port.d.ts +11 -0
- package/dist/node/sandbox/srt-module.d.ts +68 -0
- package/dist/node/sandbox/windows-sandbox-command.d.ts +9 -0
- package/dist/node/sandbox/windows-sandbox-setup.d.ts +8 -0
- package/dist/node/session-record.d.ts +3 -0
- package/dist/node/settings/node-settings-loader.d.ts +32 -0
- package/dist/node/settings/node-settings-writer.d.ts +8 -0
- package/dist/node/settings/node-user-settings-service.d.ts +95 -0
- package/dist/node/settings/user-config-directory.d.ts +9 -0
- package/dist/node/state-root.d.ts +47 -0
- package/dist/node/state-schema-manager.d.ts +25 -0
- package/dist/node/stores/node-approval-store.d.ts +3 -0
- package/dist/node/stores/node-chat-attachment-store.d.ts +53 -0
- package/dist/node/stores/node-checkpoint-store.d.ts +3 -0
- package/dist/node/stores/node-clock.d.ts +2 -0
- package/dist/node/stores/node-credential-store.d.ts +7 -0
- package/dist/node/stores/node-event-sink.d.ts +3 -0
- package/dist/node/stores/node-file-mutation-store.d.ts +3 -0
- package/dist/node/stores/node-input-inbox.d.ts +3 -0
- package/dist/node/stores/node-job-store.d.ts +3 -0
- package/dist/node/stores/node-lease-store.d.ts +3 -0
- package/dist/node/stores/node-project-store.d.ts +3 -0
- package/dist/node/stores/node-session-resource-store.d.ts +2 -0
- package/dist/node/stores/node-session-store.d.ts +6 -0
- package/dist/node/stores/node-transcript-store.d.ts +3 -0
- package/dist/node/stores/node-turn-store.d.ts +3 -0
- package/dist/node/stores/node-user-question-store.d.ts +3 -0
- package/dist/node/trust-policy.d.ts +23 -0
- package/dist/node/types.d.ts +22 -0
- package/dist/node/workspace-adapter.d.ts +3 -0
- package/dist/node/workspace-registry.d.ts +17 -0
- package/package.json +54 -4
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface NodeContextBudgetSnapshot {
|
|
2
|
+
estimatedTokens: number;
|
|
3
|
+
sections: Record<string, number>;
|
|
4
|
+
diagnostics: string[];
|
|
5
|
+
compactNeeded: boolean;
|
|
6
|
+
contextWindowTokens?: number;
|
|
7
|
+
triggerTokens?: number;
|
|
8
|
+
targetTokens?: number;
|
|
9
|
+
usageRatio?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const DEFAULT_CONTEXT_WINDOW_TOKENS = 128000;
|
|
12
|
+
export declare const DEFAULT_COMPACT_TRIGGER_RATIO = 0.8;
|
|
13
|
+
export declare const DEFAULT_COMPACT_TARGET_RATIO = 0.55;
|
|
14
|
+
export declare function estimateTokens(value: string): number;
|
|
15
|
+
export declare function createContextBudget(sections: Record<string, string>, env?: NodeJS.ProcessEnv): NodeContextBudgetSnapshot;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FrozenInstruction } from "@autopilot-agent/core";
|
|
2
|
+
export interface NodeFrozenInstruction extends FrozenInstruction {
|
|
3
|
+
lineCount: number;
|
|
4
|
+
}
|
|
5
|
+
export interface InstructionDiscovery {
|
|
6
|
+
instructions: NodeFrozenInstruction[];
|
|
7
|
+
diagnostics: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function discoverInstructions(workspaceRoot: string, targetDirectory?: string): InstructionDiscovery;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FrozenMemorySnippet } from "@autopilot-agent/core";
|
|
2
|
+
export declare function getNodeMemoryWorkspaceId(workspaceRoot: string): string;
|
|
3
|
+
export declare function getNodeMemoryDirectory(stateRoot: string, workspaceRoot: string): string;
|
|
4
|
+
export declare function getLegacyWebMemoryDirectory(workspaceRoot: string, cwd?: string): string;
|
|
5
|
+
export declare function retrieveNodeMemories(_stateRoot: string, _workspaceRoot: string, _query: string, _maxItems?: number): FrozenMemorySnippet[];
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AgentSkillsCapability } from "@autopilot-agent/core";
|
|
2
|
+
import type { NodeCapabilityLoaderOptions } from "../types";
|
|
3
|
+
export declare function createSkillsCapability(workspaceRoot: string, options?: NodeCapabilityLoaderOptions): AgentSkillsCapability | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CredentialRef, type CredentialStore, type WebSearchCapability } from "@autopilot-agent/core";
|
|
2
|
+
export declare const DEEPSEEK_ANTHROPIC_SEARCH_OFFICIAL_BASE_URL = "https://api.deepseek.com/anthropic";
|
|
3
|
+
export declare const DEEPSEEK_ANTHROPIC_SEARCH_ENDPOINT = "https://api.deepseek.com/anthropic/v1/messages";
|
|
4
|
+
export declare const DEEPSEEK_ANTHROPIC_SEARCH_MODEL = "deepseek-flash";
|
|
5
|
+
export interface CreateAnthropicWebSearchOptions {
|
|
6
|
+
credentialRef: CredentialRef;
|
|
7
|
+
credentialStore: CredentialStore;
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
model?: string;
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
}
|
|
12
|
+
export declare function createAnthropicWebSearchCapability(options: CreateAnthropicWebSearchOptions): WebSearchCapability;
|
|
13
|
+
export declare function probeAnthropicWebSearchConnectivity(baseUrl: string, fetchImplementation: typeof fetch, signal?: AbortSignal): Promise<"reachable" | "server_error">;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CredentialRef, type CredentialStore, type WebSearchCapability } from "@autopilot-agent/core";
|
|
2
|
+
export declare const DEEPSEEK_RESPONSES_SEARCH_ENDPOINT = "https://api.deepseek.com/responses";
|
|
3
|
+
export declare const DEEPSEEK_RESPONSES_SEARCH_MODEL = "deepseek-flash";
|
|
4
|
+
export interface CreateDeepSeekResponsesSearchOptions {
|
|
5
|
+
credentialRef: CredentialRef;
|
|
6
|
+
credentialStore: CredentialStore;
|
|
7
|
+
model?: string;
|
|
8
|
+
fetch?: typeof fetch;
|
|
9
|
+
}
|
|
10
|
+
export interface CreateResponsesWebSearchOptions extends CreateDeepSeekResponsesSearchOptions {
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
model: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function createResponsesWebSearchCapability(options: CreateResponsesWebSearchOptions): WebSearchCapability;
|
|
15
|
+
export declare function createDeepSeekResponsesSearchCapability(options: CreateDeepSeekResponsesSearchOptions): WebSearchCapability;
|
|
16
|
+
export declare function probeDeepSeekResponsesSearchConnectivity(fetchImplementation: typeof fetch, signal?: AbortSignal): Promise<"reachable" | "server_error">;
|
|
17
|
+
export declare function probeResponsesWebSearchConnectivity(baseUrl: string, fetchImplementation: typeof fetch, signal?: AbortSignal): Promise<"reachable" | "server_error">;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type IncomingHttpHeaders } from "node:http";
|
|
2
|
+
import { type Readable } from "node:stream";
|
|
3
|
+
import { type WebFetchCapability } from "@autopilot-agent/core";
|
|
4
|
+
import { type WebFetchDnsResolver, type WebFetchResolvedAddress } from "./url-policy";
|
|
5
|
+
export interface WebFetchHttpResponse {
|
|
6
|
+
statusCode: number;
|
|
7
|
+
headers: IncomingHttpHeaders;
|
|
8
|
+
body: Readable;
|
|
9
|
+
abort(): void;
|
|
10
|
+
}
|
|
11
|
+
export interface WebFetchHttpRequest {
|
|
12
|
+
url: URL;
|
|
13
|
+
address: WebFetchResolvedAddress;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
export type WebFetchHttpClient = (request: WebFetchHttpRequest) => Promise<WebFetchHttpResponse>;
|
|
17
|
+
export interface SafeWebFetchOptions {
|
|
18
|
+
resolveDns?: WebFetchDnsResolver;
|
|
19
|
+
request?: WebFetchHttpClient;
|
|
20
|
+
}
|
|
21
|
+
export declare function requestPinnedWebUrl(input: WebFetchHttpRequest): Promise<WebFetchHttpResponse>;
|
|
22
|
+
export declare function createSafeWebFetchCapability(options?: SafeWebFetchOptions): WebFetchCapability;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface WebFetchResolvedAddress {
|
|
2
|
+
address: string;
|
|
3
|
+
family: 4 | 6;
|
|
4
|
+
}
|
|
5
|
+
export type WebFetchDnsResolver = (hostname: string, signal?: AbortSignal) => Promise<readonly WebFetchResolvedAddress[]>;
|
|
6
|
+
export interface ValidatedWebUrl {
|
|
7
|
+
url: URL;
|
|
8
|
+
addresses: WebFetchResolvedAddress[];
|
|
9
|
+
}
|
|
10
|
+
export declare function resolveWebFetchDns(hostname: string, signal?: AbortSignal): Promise<WebFetchResolvedAddress[]>;
|
|
11
|
+
export declare function isPublicWebAddress(address: string, family?: 4 | 6): boolean;
|
|
12
|
+
export declare function validatePublicWebUrl(rawUrl: string | URL, options?: {
|
|
13
|
+
resolveDns?: WebFetchDnsResolver;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}): Promise<ValidatedWebUrl>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CredentialRef, CredentialStore, WebSearchCapability } from "@autopilot-agent/core";
|
|
2
|
+
export type WebSearchProviderConnectivity = "reachable" | "server_error" | "unsupported";
|
|
3
|
+
export interface CreateWebSearchProviderCapabilityOptions {
|
|
4
|
+
credentialRef: CredentialRef;
|
|
5
|
+
credentialStore: CredentialStore;
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
model: string;
|
|
8
|
+
fetch?: typeof fetch;
|
|
9
|
+
}
|
|
10
|
+
export declare function createWebSearchProviderCapability(options: CreateWebSearchProviderCapabilityOptions): WebSearchCapability | undefined;
|
|
11
|
+
export declare function probeWebSearchProviderConnectivity(provider: string, baseUrl: string, fetchImplementation: typeof fetch, signal?: AbortSignal): Promise<WebSearchProviderConnectivity>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CredentialRef, type CredentialStore, type WebSearchCapability } from "@autopilot-agent/core";
|
|
2
|
+
export declare const XIAOMI_MIMO_CHAT_SEARCH_MODEL = "mimo-v2.5";
|
|
3
|
+
export declare const XIAOMI_MIMO_CHAT_SEARCH_OFFICIAL_BASE_URL = "https://api.xiaomimimo.com/v1";
|
|
4
|
+
export declare const XIAOMI_MIMO_CHAT_SEARCH_ENDPOINT = "https://api.xiaomimimo.com/v1/chat/completions";
|
|
5
|
+
export interface CreateXiaomiMiMoOfficialChatSearchOptions {
|
|
6
|
+
credentialRef: CredentialRef;
|
|
7
|
+
credentialStore: CredentialStore;
|
|
8
|
+
model?: string;
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
}
|
|
11
|
+
export interface CreateXiaomiMiMoChatSearchOptions extends CreateXiaomiMiMoOfficialChatSearchOptions {
|
|
12
|
+
baseUrl: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function createXiaomiMiMoChatWebSearchCapability(options: CreateXiaomiMiMoChatSearchOptions): WebSearchCapability;
|
|
15
|
+
export declare function createXiaomiMiMoOfficialChatSearchCapability(options: CreateXiaomiMiMoOfficialChatSearchOptions): WebSearchCapability;
|
|
16
|
+
export declare function probeXiaomiMiMoChatSearchConnectivity(baseUrl: string, fetchImplementation: typeof fetch, signal?: AbortSignal): Promise<"reachable" | "server_error">;
|
|
17
|
+
export declare function probeXiaomiMiMoOfficialChatSearchConnectivity(fetchImplementation: typeof fetch, signal?: AbortSignal): Promise<"reachable" | "server_error">;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface NodeChatStatePaths {
|
|
2
|
+
root: string;
|
|
3
|
+
stateRoot: string;
|
|
4
|
+
attachmentsRoot: string;
|
|
5
|
+
knowledgeRoot: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function resolveNodeChatStatePaths(options?: {
|
|
8
|
+
globalStateRoot?: string;
|
|
9
|
+
}): NodeChatStatePaths;
|
|
10
|
+
export declare function assertSafeNodePath(root: string, target: string): void;
|
|
11
|
+
export declare function ensureChatDirectory(root: string, target: string): void;
|
|
12
|
+
export declare function initializeNodeChatDirectories(paths: NodeChatStatePaths): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentContextSnapshot, AgentSkillsCapability, ChatCapabilityBinding, McpCapability, WebCapability } from "@autopilot-agent/core";
|
|
2
|
+
import type { NodeCapabilityLoaderOptions } from "./types";
|
|
3
|
+
import { type WebSearchProviderConnectivity } from "./capabilities/web/web-search-provider";
|
|
4
|
+
export interface NodeCapabilityLoader {
|
|
5
|
+
loadMcp(workspaceRoot: string): McpCapability | undefined;
|
|
6
|
+
loadContext(workspaceRoot: string, query?: string): AgentContextSnapshot;
|
|
7
|
+
loadSkills(workspaceRoot: string): AgentSkillsCapability | undefined;
|
|
8
|
+
loadWeb(workspaceRoot: string): Promise<WebCapability | undefined>;
|
|
9
|
+
loadChatWeb(binding: ChatCapabilityBinding | Pick<ChatCapabilityBinding, "retrievalMode">): Promise<WebCapability | undefined>;
|
|
10
|
+
probeWebSearchConnectivity(workspaceRoot: string, signal?: AbortSignal): Promise<WebSearchProviderConnectivity>;
|
|
11
|
+
}
|
|
12
|
+
export declare function createNodeCapabilityLoader(options?: NodeCapabilityLoaderOptions): NodeCapabilityLoader;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ChatCapability, ChatCapabilityBinding, VisionAnalyzer } from "@autopilot-agent/core";
|
|
2
|
+
import type { NodeChatStorage } from "./create-node-chat-storage";
|
|
3
|
+
export declare const NODE_CHAT_KNOWLEDGE_SPACE_ID = "chat-knowledge-v1";
|
|
4
|
+
export interface NodeChatCapabilityLoaderOptions {
|
|
5
|
+
storage: NodeChatStorage;
|
|
6
|
+
visionAnalyzer?: VisionAnalyzer;
|
|
7
|
+
loadKnowledge?: (input: ChatCapabilityBinding & {
|
|
8
|
+
knowledgeRoot: string;
|
|
9
|
+
knowledgeSpaceId: string;
|
|
10
|
+
}) => Promise<Pick<ChatCapability, "knowledge" | "authorizeRef" | "readImage">>;
|
|
11
|
+
}
|
|
12
|
+
export declare function createNodeChatCapabilityLoader(options: NodeChatCapabilityLoaderOptions): (binding: ChatCapabilityBinding) => Promise<ChatCapability>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { RuntimePorts } from "@autopilot-agent/core";
|
|
2
|
+
import { type NodeChatAttachmentStoreOptions } from "./stores/node-chat-attachment-store";
|
|
3
|
+
export interface CreateNodeChatStorageOptions {
|
|
4
|
+
globalStateRoot?: string;
|
|
5
|
+
env?: NodeJS.ProcessEnv;
|
|
6
|
+
userSettingsPath?: string;
|
|
7
|
+
now?: () => number;
|
|
8
|
+
parseDocument?: NodeChatAttachmentStoreOptions["parseDocument"];
|
|
9
|
+
}
|
|
10
|
+
export declare function createNodeChatStorage(options?: CreateNodeChatStorageOptions): {
|
|
11
|
+
paths: import("./chat-state").NodeChatStatePaths;
|
|
12
|
+
ports: RuntimePorts;
|
|
13
|
+
attachments: {
|
|
14
|
+
put: (input: {
|
|
15
|
+
sessionId: string;
|
|
16
|
+
displayName: string;
|
|
17
|
+
bytes: Uint8Array;
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
}) => Promise<import("./stores/node-chat-attachment-store").NodeChatAttachment>;
|
|
20
|
+
list: (sessionId: string) => Promise<import("./stores/node-chat-attachment-store").NodeChatAttachment[]>;
|
|
21
|
+
authorizeRef: (sessionId: string, ref: string, kind: "image" | "document") => Promise<boolean>;
|
|
22
|
+
readAttachment: (sessionId: string, ref: string, signal?: AbortSignal) => Promise<{
|
|
23
|
+
text: any;
|
|
24
|
+
pageImages: import("@autopilot-agent/core").ChatAttachmentGrant[];
|
|
25
|
+
}>;
|
|
26
|
+
readBytes: (sessionId: string, ref: string, signal?: AbortSignal) => Promise<{
|
|
27
|
+
bytes: Uint8Array<ArrayBuffer>;
|
|
28
|
+
mimeType: string;
|
|
29
|
+
}>;
|
|
30
|
+
deleteBySession: (sessionId: string) => Promise<void>;
|
|
31
|
+
cleanupExpired: (input?: {
|
|
32
|
+
limit?: number;
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
}) => Promise<string[]>;
|
|
35
|
+
startMaintenance: (onError: (code: "CHAT_ATTACHMENT_CLEANUP_FAILED") => void, signal?: AbortSignal) => Promise<() => void>;
|
|
36
|
+
isSessionDeleting: (sessionId: string) => boolean;
|
|
37
|
+
withActiveSession: <T>(sessionId: string, operation: () => Promise<T>) => Promise<T>;
|
|
38
|
+
sanitizeSession: (session: import("@autopilot-agent/core").Session) => import("@autopilot-agent/core").Session;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type NodeChatStorage = ReturnType<typeof createNodeChatStorage>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ProductMode, type RuntimePorts } from "@autopilot-agent/core";
|
|
2
|
+
import { createNodeCapabilityLoader } from "./create-node-capability-loader";
|
|
3
|
+
import type { NodeStoreOptions } from "./types";
|
|
4
|
+
export interface NodeRuntimePortsOptions extends NodeStoreOptions {
|
|
5
|
+
productMode?: ProductMode;
|
|
6
|
+
workspaceRoot?: string;
|
|
7
|
+
cwd?: string;
|
|
8
|
+
env?: NodeJS.ProcessEnv;
|
|
9
|
+
userSettingsPath?: string;
|
|
10
|
+
sandboxTempRoot?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function createNodeRuntimePorts(options: NodeRuntimePortsOptions): RuntimePorts;
|
|
13
|
+
export { createNodeCapabilityLoader };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface JsonlCorruptionDiagnostic {
|
|
2
|
+
code: "DURABLE_JSONL_CORRUPTED";
|
|
3
|
+
line: number;
|
|
4
|
+
reason: "INVALID_JSON";
|
|
5
|
+
}
|
|
6
|
+
export declare function withFileLock<T>(filePath: string, operation: () => T | Promise<T>): Promise<T>;
|
|
7
|
+
export declare function withAsyncFileLock<T>(filePath: string, operation: () => T | Promise<T>): Promise<T>;
|
|
8
|
+
export declare function ensureParentDirectory(filePath: string): void;
|
|
9
|
+
export declare function atomicReplace(filePath: string, content: string): void;
|
|
10
|
+
export declare function safeFilePath(directory: string, key: string, extension: string): string;
|
|
11
|
+
export declare function readJsonFile<T>(filePath: string): T | null;
|
|
12
|
+
export declare function readJsonLines<T>(filePath: string): {
|
|
13
|
+
values: T[];
|
|
14
|
+
lines: string[];
|
|
15
|
+
diagnostics: JsonlCorruptionDiagnostic[];
|
|
16
|
+
};
|
|
17
|
+
export declare function appendJsonLine(filePath: string, serialized: string): void;
|
|
18
|
+
export declare function appendUniqueJsonLine(filePath: string, serialized: string): Promise<void>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AgentRuntimeError, type AgentErrorCode } from "@autopilot-agent/core";
|
|
2
|
+
declare const stateCodes: readonly ["STATE_SESSION_CORRUPTED", "STATE_STORAGE_UNAVAILABLE", "STATE_STORAGE_UNSAFE_PATH", "STATE_SCHEMA_UNSAFE_PATH", "STATE_SCHEMA_BUSY", "STATE_SCHEMA_RECOVERY_REQUIRED", "STATE_SCHEMA_MANIFEST_CORRUPTED", "STATE_SCHEMA_VERSION_INVALID", "STATE_SCHEMA_VERSION_UNSUPPORTED", "STATE_SCHEMA_MIGRATION_MISSING", "STATE_SCHEMA_MIGRATION_FAILED"];
|
|
3
|
+
declare const chatCodes: readonly ["CHAT_STATE_ROOT_INVALID", "CHAT_ATTACHMENT_UNAVAILABLE", "CHAT_ATTACHMENT_CANCELLED", "CHAT_ATTACHMENT_PARSER_UNAVAILABLE", "CHAT_ATTACHMENT_CLEANUP_FAILED", "CHAT_SESSION_DELETING", "CHAT_UPLOAD_MODE_MISMATCH", "CHAT_ATTACHMENT_STORE_REQUIRED", "CHAT_KNOWLEDGE_UNAVAILABLE"];
|
|
4
|
+
declare const runtimeMessages: {
|
|
5
|
+
readonly SESSION_MODE_MISMATCH: "Session 产品模式与归属不匹配";
|
|
6
|
+
readonly CHAT_RETRIEVAL_MODE_LOCKED: "Chat 检索模式已冻结";
|
|
7
|
+
readonly WORKSPACE_REQUIRED: "Work 需要有效工作区归属";
|
|
8
|
+
};
|
|
9
|
+
export type NodeStateErrorCode = typeof stateCodes[number];
|
|
10
|
+
export type NodeChatErrorCode = typeof chatCodes[number];
|
|
11
|
+
type NodeIdentityErrorCode = keyof typeof runtimeMessages;
|
|
12
|
+
export interface NodeStateRecoveryDiagnostic {
|
|
13
|
+
fromVersion: number;
|
|
14
|
+
toVersion: number;
|
|
15
|
+
backupPath?: string;
|
|
16
|
+
reasonCode: NodeStateErrorCode | NodeChatErrorCode | AgentErrorCode;
|
|
17
|
+
}
|
|
18
|
+
export declare class NodeStateError extends Error {
|
|
19
|
+
#private;
|
|
20
|
+
readonly code: NodeStateErrorCode;
|
|
21
|
+
constructor(code: NodeStateErrorCode, recovery?: NodeStateRecoveryDiagnostic);
|
|
22
|
+
getRecoveryDiagnostic(): NodeStateRecoveryDiagnostic | undefined;
|
|
23
|
+
}
|
|
24
|
+
export declare class NodeChatError extends Error {
|
|
25
|
+
readonly code: NodeChatErrorCode;
|
|
26
|
+
constructor(code: NodeChatErrorCode);
|
|
27
|
+
}
|
|
28
|
+
export declare function createNodeIdentityError(code: NodeIdentityErrorCode): AgentRuntimeError;
|
|
29
|
+
export declare function toNodeBoundaryError(error: unknown, fallback: NodeStateErrorCode | NodeChatErrorCode): NodeStateError | NodeChatError | AgentRuntimeError;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
interface RagConnectionSnapshot {
|
|
2
|
+
provider: "bailian" | "openai-compatible" | "dashscope";
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
model: string;
|
|
5
|
+
credentialRef: {
|
|
6
|
+
provider: string;
|
|
7
|
+
key: string;
|
|
8
|
+
};
|
|
9
|
+
dimension?: number;
|
|
10
|
+
}
|
|
11
|
+
interface RagSettingsSnapshot {
|
|
12
|
+
rag: Partial<Record<"textRerank" | "visionRerank" | "textEmbedding" | "multimodalEmbedding", RagConnectionSnapshot>>;
|
|
13
|
+
diagnostics?: ReadonlyArray<{
|
|
14
|
+
code: string;
|
|
15
|
+
field?: string;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
interface NodeEmbeddingConnection {
|
|
19
|
+
provider: string;
|
|
20
|
+
baseUrl: string;
|
|
21
|
+
model: string;
|
|
22
|
+
dimension: number;
|
|
23
|
+
normalization: "raw" | "provider-normalized";
|
|
24
|
+
pipelineVersion: "rag-v2";
|
|
25
|
+
resolveApiKey: () => Promise<string | undefined> | string | undefined;
|
|
26
|
+
fetch?: typeof fetch;
|
|
27
|
+
}
|
|
28
|
+
export interface CreateNodeRagRuntimeOptions {
|
|
29
|
+
settings: RagSettingsSnapshot;
|
|
30
|
+
userSettingsPath: string;
|
|
31
|
+
env?: NodeJS.ProcessEnv;
|
|
32
|
+
rerankFetch?: typeof fetch;
|
|
33
|
+
embeddingFetch?: typeof fetch;
|
|
34
|
+
}
|
|
35
|
+
export declare function createNodeRagRuntime(options: CreateNodeRagRuntimeOptions): {
|
|
36
|
+
rerank: {
|
|
37
|
+
defaultPolicy: {
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
text: {
|
|
40
|
+
provider: "bailian";
|
|
41
|
+
baseUrl: string;
|
|
42
|
+
model: string;
|
|
43
|
+
} | undefined;
|
|
44
|
+
vision: {
|
|
45
|
+
provider: "bailian";
|
|
46
|
+
baseUrl: string;
|
|
47
|
+
model: string;
|
|
48
|
+
} | undefined;
|
|
49
|
+
};
|
|
50
|
+
resolveApiKey: (role: "text" | "vision") => string | Promise<string | undefined> | undefined;
|
|
51
|
+
fetch: typeof fetch | undefined;
|
|
52
|
+
};
|
|
53
|
+
embedding: {
|
|
54
|
+
text: NodeEmbeddingConnection | undefined;
|
|
55
|
+
multimodal: NodeEmbeddingConnection | undefined;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type SandboxPort, type SandboxPolicy } from "@autopilot-agent/core";
|
|
2
|
+
import { type SrtRuntimeSurface } from "./srt-module";
|
|
3
|
+
export interface NodeSandboxPortOptions {
|
|
4
|
+
workspaceRoot: string;
|
|
5
|
+
tempRoot?: string;
|
|
6
|
+
windowsSrtWinExe?: string;
|
|
7
|
+
loadModule?: () => Promise<SrtRuntimeSurface>;
|
|
8
|
+
}
|
|
9
|
+
export declare function serializePosixCommand(program: string, args: readonly string[], tempRoot?: string): string;
|
|
10
|
+
export declare function buildSrtRuntimeConfig(policy: SandboxPolicy): Record<string, unknown>;
|
|
11
|
+
export declare function createNodeSandboxPort(options: NodeSandboxPortOptions): SandboxPort;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export interface SrtSandboxManagerSurface {
|
|
2
|
+
initialize(runtimeConfig: unknown): Promise<void>;
|
|
3
|
+
isSupportedPlatform(): boolean;
|
|
4
|
+
isSandboxingEnabled(): boolean;
|
|
5
|
+
checkDependencies(): {
|
|
6
|
+
warnings: string[];
|
|
7
|
+
errors: string[];
|
|
8
|
+
};
|
|
9
|
+
waitForNetworkInitialization(): Promise<boolean>;
|
|
10
|
+
wrapWithSandboxArgv(command: string, binShell?: string | {
|
|
11
|
+
exe: string;
|
|
12
|
+
args: readonly string[];
|
|
13
|
+
}, customConfig?: unknown, abortSignal?: AbortSignal, cwd?: string, options?: {
|
|
14
|
+
commandId?: string;
|
|
15
|
+
commandText?: string;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
argv: string[];
|
|
18
|
+
env: NodeJS.ProcessEnv;
|
|
19
|
+
}>;
|
|
20
|
+
cleanupAfterCommand(): void;
|
|
21
|
+
reset(): Promise<void>;
|
|
22
|
+
updateConfig(newConfig: unknown): void;
|
|
23
|
+
}
|
|
24
|
+
export interface SrtWindowsSurface {
|
|
25
|
+
checkWindowsSandboxStatusAsync(options?: {
|
|
26
|
+
srtWin?: {
|
|
27
|
+
exe: string;
|
|
28
|
+
prependArgs: readonly string[];
|
|
29
|
+
};
|
|
30
|
+
}): Promise<{
|
|
31
|
+
user: {
|
|
32
|
+
provisioned: boolean;
|
|
33
|
+
credPresent: boolean;
|
|
34
|
+
realUserSid: string;
|
|
35
|
+
};
|
|
36
|
+
wfp: {
|
|
37
|
+
state: "absent" | "installed" | "cannot-read";
|
|
38
|
+
filters: number;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
installWindowsSandboxAsync(options?: {
|
|
42
|
+
srtWin?: {
|
|
43
|
+
exe: string;
|
|
44
|
+
prependArgs: readonly string[];
|
|
45
|
+
};
|
|
46
|
+
force?: boolean;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
wfp: {
|
|
49
|
+
state: string;
|
|
50
|
+
filters: number;
|
|
51
|
+
};
|
|
52
|
+
user: {
|
|
53
|
+
provisioned: boolean;
|
|
54
|
+
credPresent: boolean;
|
|
55
|
+
};
|
|
56
|
+
cancelled?: true;
|
|
57
|
+
}>;
|
|
58
|
+
WindowsSandboxError: new (code: string, message: string, subcommand?: string) => Error & {
|
|
59
|
+
code: string;
|
|
60
|
+
};
|
|
61
|
+
VENDORED_SRT_WIN_EXE: string;
|
|
62
|
+
}
|
|
63
|
+
export interface SrtRuntimeSurface extends SrtWindowsSurface {
|
|
64
|
+
SandboxManager: SrtSandboxManagerSurface;
|
|
65
|
+
}
|
|
66
|
+
export type SrtModule = typeof import("@anthropic-ai/sandbox-runtime");
|
|
67
|
+
export declare function readSrtVersion(): string | undefined;
|
|
68
|
+
export declare function loadSrtRuntimeSurface(): Promise<SrtRuntimeSurface>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function resolveWindowsSandboxRunner(vendored: string, explicit?: string): string;
|
|
2
|
+
export declare function resolveWindowsSandboxCommand(program: string, args: readonly string[]): {
|
|
3
|
+
exe: string;
|
|
4
|
+
args: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare function finalizeWindowsSandboxArgv(argv: readonly string[], target: {
|
|
7
|
+
exe: string;
|
|
8
|
+
args: readonly string[];
|
|
9
|
+
}, tempRoot?: string): string[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type SandboxCapabilityReport } from "@autopilot-agent/core";
|
|
2
|
+
import { type SrtRuntimeSurface } from "./srt-module";
|
|
3
|
+
export interface WindowsSandboxSetupOptions {
|
|
4
|
+
srtWinExe?: string;
|
|
5
|
+
loadModule?: () => Promise<SrtRuntimeSurface>;
|
|
6
|
+
}
|
|
7
|
+
export declare function readWindowsSandboxCapability(options?: WindowsSandboxSetupOptions): Promise<SandboxCapabilityReport>;
|
|
8
|
+
export declare function runWindowsSandboxSetup(options?: WindowsSandboxSetupOptions): Promise<SandboxCapabilityReport>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { type ResolvedAutopilotSettings } from "@autopilot-agent/core";
|
|
3
|
+
export interface NodeSettingsPaths {
|
|
4
|
+
user: string;
|
|
5
|
+
project: string;
|
|
6
|
+
local: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LoadedNodeSettings {
|
|
9
|
+
settings: ResolvedAutopilotSettings;
|
|
10
|
+
paths: NodeSettingsPaths;
|
|
11
|
+
}
|
|
12
|
+
export interface LoadedNodeUserSettings {
|
|
13
|
+
settings: ResolvedAutopilotSettings;
|
|
14
|
+
paths: Pick<NodeSettingsPaths, "user">;
|
|
15
|
+
}
|
|
16
|
+
export interface CreateNodeSettingsLoaderOptions {
|
|
17
|
+
homeDirectory?: string;
|
|
18
|
+
debounceMs?: number;
|
|
19
|
+
}
|
|
20
|
+
type NodePathApi = Pick<typeof path, "join" | "resolve">;
|
|
21
|
+
export interface NodeSettingsLoader {
|
|
22
|
+
load(workspaceRoot: string): LoadedNodeSettings;
|
|
23
|
+
watch(workspaceRoot: string, onReload: (loaded: LoadedNodeSettings) => void): () => void;
|
|
24
|
+
}
|
|
25
|
+
export interface NodeUserSettingsLoader {
|
|
26
|
+
loadUser(): LoadedNodeUserSettings;
|
|
27
|
+
watchUser(onReload: (loaded: LoadedNodeUserSettings) => void): () => void;
|
|
28
|
+
}
|
|
29
|
+
export declare function resolveNodeUserSettingsPath(homeDirectory?: string | undefined, pathApi?: Pick<typeof path, "join" | "isAbsolute">): string;
|
|
30
|
+
export declare function resolveNodeSettingsPaths(workspaceRoot: string, homeDirectory?: string, pathApi?: NodePathApi): NodeSettingsPaths;
|
|
31
|
+
export declare function createNodeSettingsLoader(options?: CreateNodeSettingsLoaderOptions): NodeSettingsLoader & NodeUserSettingsLoader;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type AutopilotSettingsScope } from "@autopilot-agent/core";
|
|
2
|
+
import { type CreateNodeSettingsLoaderOptions } from "./node-settings-loader";
|
|
3
|
+
export interface NodeSettingsWriter {
|
|
4
|
+
get(scope: AutopilotSettingsScope, key: string, workspaceRoot: string): unknown;
|
|
5
|
+
show(scope: AutopilotSettingsScope, workspaceRoot: string): Record<string, unknown>;
|
|
6
|
+
set(scope: AutopilotSettingsScope, key: string, value: string, workspaceRoot: string): Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export declare function createNodeSettingsWriter(options?: CreateNodeSettingsLoaderOptions): NodeSettingsWriter;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
declare const RAG_ROLE_CONTRACT: Readonly<{
|
|
2
|
+
readonly textRerank: {
|
|
3
|
+
readonly provider: "bailian";
|
|
4
|
+
readonly key: "RAG_TEXT_RERANK_API_KEY";
|
|
5
|
+
readonly dimension: false;
|
|
6
|
+
};
|
|
7
|
+
readonly visionRerank: {
|
|
8
|
+
readonly provider: "bailian";
|
|
9
|
+
readonly key: "RAG_VISION_RERANK_API_KEY";
|
|
10
|
+
readonly dimension: false;
|
|
11
|
+
};
|
|
12
|
+
readonly textEmbedding: {
|
|
13
|
+
readonly provider: "openai-compatible";
|
|
14
|
+
readonly key: "RAG_TEXT_EMBEDDING_API_KEY";
|
|
15
|
+
readonly dimension: true;
|
|
16
|
+
};
|
|
17
|
+
readonly multimodalEmbedding: {
|
|
18
|
+
readonly provider: "dashscope";
|
|
19
|
+
readonly key: "RAG_MULTIMODAL_EMBEDDING_API_KEY";
|
|
20
|
+
readonly dimension: true;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
type RagConnectionRole = keyof typeof RAG_ROLE_CONTRACT;
|
|
24
|
+
export interface MainSettingsCategoryInput {
|
|
25
|
+
baseUrl: string;
|
|
26
|
+
model: string;
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
availableModels?: string[];
|
|
29
|
+
opusModel?: string;
|
|
30
|
+
sonnetModel?: string;
|
|
31
|
+
haikuModel?: string;
|
|
32
|
+
subagentModel?: string;
|
|
33
|
+
effort?: "auto" | "low" | "medium" | "high" | "max";
|
|
34
|
+
maxOutputTokens?: number;
|
|
35
|
+
compactWindow?: number;
|
|
36
|
+
timeoutMs?: number;
|
|
37
|
+
alwaysThinkingEnabled?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface RagSettingsCategoryConnectionInput {
|
|
40
|
+
provider: "bailian" | "openai-compatible" | "dashscope";
|
|
41
|
+
baseUrl: string;
|
|
42
|
+
model: string;
|
|
43
|
+
apiKey?: string;
|
|
44
|
+
dimension?: number;
|
|
45
|
+
}
|
|
46
|
+
export type RagSettingsCategoryInput = Partial<Record<RagConnectionRole, RagSettingsCategoryConnectionInput | null>>;
|
|
47
|
+
export interface WebSearchSettingsCategoryInput {
|
|
48
|
+
enabled: boolean;
|
|
49
|
+
useMainKey: boolean;
|
|
50
|
+
provider: "deepseek" | "openai-compatible" | "xiaomi-mimo";
|
|
51
|
+
baseUrl: string;
|
|
52
|
+
model: string;
|
|
53
|
+
apiKey?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface UserSettingsStatus {
|
|
56
|
+
revision: string;
|
|
57
|
+
main: Omit<MainSettingsCategoryInput, "apiKey"> & {
|
|
58
|
+
provider: "deepseek" | "custom";
|
|
59
|
+
configured: boolean;
|
|
60
|
+
};
|
|
61
|
+
search: Omit<WebSearchSettingsCategoryInput, "apiKey"> & {
|
|
62
|
+
configured: boolean;
|
|
63
|
+
};
|
|
64
|
+
rag: Record<RagConnectionRole, RagSettingsCategoryConnectionInput & {
|
|
65
|
+
configured: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
}
|
|
68
|
+
export interface MainSettingsCategoryUpdate {
|
|
69
|
+
main: MainSettingsCategoryInput;
|
|
70
|
+
search: WebSearchSettingsCategoryInput;
|
|
71
|
+
}
|
|
72
|
+
export interface UserSettingsWriteResult {
|
|
73
|
+
revision: string;
|
|
74
|
+
configured: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface MainModelCatalogResult {
|
|
77
|
+
models: string[];
|
|
78
|
+
source: "official" | "maintained";
|
|
79
|
+
}
|
|
80
|
+
export declare class NodeUserSettingsError extends Error {
|
|
81
|
+
readonly code: "SETTINGS_INVALID" | "SETTINGS_CHANGED" | "SETTINGS_INPUT_INVALID" | "SETTINGS_KEY_REQUIRED" | "SETTINGS_MIGRATION_CONFLICT";
|
|
82
|
+
constructor(code: "SETTINGS_INVALID" | "SETTINGS_CHANGED" | "SETTINGS_INPUT_INVALID" | "SETTINGS_KEY_REQUIRED" | "SETTINGS_MIGRATION_CONFLICT");
|
|
83
|
+
}
|
|
84
|
+
export declare function createNodeUserSettingsService(options?: {
|
|
85
|
+
homeDirectory?: string;
|
|
86
|
+
fetchImpl?: typeof fetch;
|
|
87
|
+
}): {
|
|
88
|
+
refreshMainModelCatalog(): Promise<MainModelCatalogResult>;
|
|
89
|
+
getStatus(): UserSettingsStatus;
|
|
90
|
+
getRevision(): string;
|
|
91
|
+
saveMain(input: MainSettingsCategoryInput, revision?: string): Promise<UserSettingsWriteResult>;
|
|
92
|
+
saveMainCategory(input: MainSettingsCategoryUpdate, revision?: string): Promise<UserSettingsWriteResult>;
|
|
93
|
+
saveRag(input: RagSettingsCategoryInput, revision?: string): Promise<UserSettingsWriteResult>;
|
|
94
|
+
};
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type UserConfigDirectoryErrorCode = "AUTOPILOT_HOME_UNRESOLVED" | "AUTOPILOT_CONFIG_ROOT_NOT_DIRECTORY" | "AUTOPILOT_CONFIG_ROOT_UNSAFE_LINK" | "AUTOPILOT_CONFIG_ROOT_UNAVAILABLE";
|
|
2
|
+
export declare class UserConfigDirectoryError extends Error {
|
|
3
|
+
readonly code: UserConfigDirectoryErrorCode;
|
|
4
|
+
constructor(code: UserConfigDirectoryErrorCode);
|
|
5
|
+
}
|
|
6
|
+
export interface EnsureUserConfigDirectoryOptions {
|
|
7
|
+
homeDirectory?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function ensureUserConfigDirectory(options?: EnsureUserConfigDirectoryOptions): string;
|