@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.
Files changed (56) hide show
  1. package/README.md +5 -2
  2. package/dist/index.d.ts +63 -0
  3. package/dist/index.js +21020 -0
  4. package/dist/index.mjs +20958 -0
  5. package/dist/node/capabilities/context-budget.d.ts +15 -0
  6. package/dist/node/capabilities/instruction-store.d.ts +9 -0
  7. package/dist/node/capabilities/mcp-loader.d.ts +2 -0
  8. package/dist/node/capabilities/memory-retriever.d.ts +5 -0
  9. package/dist/node/capabilities/skill-discovery.d.ts +3 -0
  10. package/dist/node/capabilities/web/anthropic-web-search.d.ts +13 -0
  11. package/dist/node/capabilities/web/deepseek-responses-search.d.ts +17 -0
  12. package/dist/node/capabilities/web/safe-web-fetch.d.ts +22 -0
  13. package/dist/node/capabilities/web/url-policy.d.ts +15 -0
  14. package/dist/node/capabilities/web/web-search-provider.d.ts +11 -0
  15. package/dist/node/capabilities/web/xiaomi-mimo-chat-search.d.ts +17 -0
  16. package/dist/node/chat-state.d.ts +12 -0
  17. package/dist/node/create-node-capability-loader.d.ts +12 -0
  18. package/dist/node/create-node-chat-capability-loader.d.ts +12 -0
  19. package/dist/node/create-node-chat-storage.d.ts +41 -0
  20. package/dist/node/create-node-runtime-ports.d.ts +13 -0
  21. package/dist/node/file-utils.d.ts +18 -0
  22. package/dist/node/job-owner-probe.d.ts +2 -0
  23. package/dist/node/node-errors.d.ts +30 -0
  24. package/dist/node/rag/node-rag-runtime.d.ts +58 -0
  25. package/dist/node/sandbox/node-sandbox-port.d.ts +11 -0
  26. package/dist/node/sandbox/srt-module.d.ts +68 -0
  27. package/dist/node/sandbox/windows-sandbox-command.d.ts +9 -0
  28. package/dist/node/sandbox/windows-sandbox-setup.d.ts +8 -0
  29. package/dist/node/session-record.d.ts +3 -0
  30. package/dist/node/settings/node-settings-loader.d.ts +32 -0
  31. package/dist/node/settings/node-settings-writer.d.ts +8 -0
  32. package/dist/node/settings/node-user-settings-service.d.ts +95 -0
  33. package/dist/node/settings/user-config-directory.d.ts +9 -0
  34. package/dist/node/state-root.d.ts +47 -0
  35. package/dist/node/state-schema-manager.d.ts +25 -0
  36. package/dist/node/stores/node-approval-store.d.ts +3 -0
  37. package/dist/node/stores/node-chat-attachment-store.d.ts +53 -0
  38. package/dist/node/stores/node-checkpoint-store.d.ts +3 -0
  39. package/dist/node/stores/node-clock.d.ts +2 -0
  40. package/dist/node/stores/node-credential-store.d.ts +7 -0
  41. package/dist/node/stores/node-event-sink.d.ts +3 -0
  42. package/dist/node/stores/node-file-mutation-store.d.ts +3 -0
  43. package/dist/node/stores/node-input-inbox.d.ts +3 -0
  44. package/dist/node/stores/node-job-store.d.ts +3 -0
  45. package/dist/node/stores/node-lease-store.d.ts +3 -0
  46. package/dist/node/stores/node-project-store.d.ts +3 -0
  47. package/dist/node/stores/node-session-resource-store.d.ts +2 -0
  48. package/dist/node/stores/node-session-store.d.ts +6 -0
  49. package/dist/node/stores/node-transcript-store.d.ts +3 -0
  50. package/dist/node/stores/node-turn-store.d.ts +3 -0
  51. package/dist/node/stores/node-user-question-store.d.ts +3 -0
  52. package/dist/node/trust-policy.d.ts +23 -0
  53. package/dist/node/types.d.ts +22 -0
  54. package/dist/node/workspace-adapter.d.ts +3 -0
  55. package/dist/node/workspace-registry.d.ts +17 -0
  56. package/package.json +54 -4
@@ -0,0 +1,47 @@
1
+ import { type NodeStateSchemaDiagnostic } from "./state-schema-manager";
2
+ import { type JsonlCorruptionDiagnostic } from "./file-utils";
3
+ export declare const NODE_STATE_SCHEMA_VERSION = 6;
4
+ export declare const NODE_WORKSPACE_ID_VERSION = 1;
5
+ export interface NodeStateCorruptionDiagnostic extends JsonlCorruptionDiagnostic {
6
+ file: string;
7
+ }
8
+ export interface NodeStatePaths {
9
+ root: string;
10
+ schemaFile: string;
11
+ sessionsDir: string;
12
+ checkpointsDir: string;
13
+ transcriptsDir: string;
14
+ projectsDir: string;
15
+ turnsDir: string;
16
+ approvalsDir: string;
17
+ inboxDir: string;
18
+ leasesDir: string;
19
+ jobsDir: string;
20
+ mutationsDir: string;
21
+ mutationBlobsDir: string;
22
+ mutationLocksDir: string;
23
+ undoTransactionsDir: string;
24
+ questionsDir: string;
25
+ }
26
+ export declare function canonicalizeNodePath(candidate: string, baseDirectory?: string): string;
27
+ export declare function createNodeWorkspaceId(workspaceRoot: string, baseDirectory?: string): string;
28
+ export declare function resolveNodeGlobalStateRoot(options?: {
29
+ globalStateRoot?: string;
30
+ cwd?: string;
31
+ }): string;
32
+ export declare function resolveNodeStateRoot(options?: {
33
+ stateRoot?: string;
34
+ workspaceRoot?: string;
35
+ globalStateRoot?: string;
36
+ cwd?: string;
37
+ }): string;
38
+ export declare function resolveNodeTrustRoot(options: {
39
+ stateRoot: string;
40
+ trustRoot?: string;
41
+ }): string;
42
+ export declare function getNodeStatePaths(stateRoot: string): NodeStatePaths;
43
+ export declare function assertNodeStateSchema(stateRoot: string): void;
44
+ export declare function ensureNodeStateRoot(stateRoot: string): NodeStatePaths;
45
+ export declare function initializeNodeStateRoot(stateRoot: string): NodeStatePaths;
46
+ export declare function getNodeStateSchemaDiagnostic(stateRoot: string): NodeStateSchemaDiagnostic | undefined;
47
+ export declare function getNodeStateCorruptionDiagnostics(stateRoot: string): NodeStateCorruptionDiagnostic[];
@@ -0,0 +1,25 @@
1
+ export interface NodeStateSchemaMigration {
2
+ fromVersion: number;
3
+ toVersion: number;
4
+ migrate(stagingRoot: string): void;
5
+ }
6
+ export interface NodeStateSchemaDiagnostic {
7
+ code: "STATE_SCHEMA_MIGRATED";
8
+ fromVersion: number;
9
+ toVersion: number;
10
+ backupPath: string;
11
+ migratedAt: string;
12
+ }
13
+ export interface CreateNodeStateSchemaManagerOptions {
14
+ stateRoot: string;
15
+ targetVersion: number;
16
+ migrations: readonly NodeStateSchemaMigration[];
17
+ }
18
+ export interface NodeStateSchemaManager {
19
+ detectVersion(): number;
20
+ migrate(fromVersion?: number, toVersion?: number): NodeStateSchemaDiagnostic | undefined;
21
+ backup(fromVersion: number, toVersion: number): string | undefined;
22
+ verify(expectedVersion?: number): void;
23
+ getDiagnostics(): NodeStateSchemaDiagnostic | undefined;
24
+ }
25
+ export declare function createNodeStateSchemaManager(options: CreateNodeStateSchemaManagerOptions): NodeStateSchemaManager;
@@ -0,0 +1,3 @@
1
+ import type { ApprovalStore } from "@autopilot-agent/core";
2
+ import type { NodeStoreOptions } from "../types";
3
+ export declare function createNodeApprovalStore(options: NodeStoreOptions): ApprovalStore;
@@ -0,0 +1,53 @@
1
+ import type { ChatAttachmentGrant, Session, SessionStore } from "@autopilot-agent/core";
2
+ import { type NodeChatStatePaths } from "../chat-state";
3
+ export declare const CHAT_ATTACHMENT_TTL_MS: number;
4
+ export interface NodeChatAttachment extends ChatAttachmentGrant {
5
+ displayName: string;
6
+ mimeType: string;
7
+ byteLength: number;
8
+ createdAt: number;
9
+ sha256: string;
10
+ status: "active";
11
+ }
12
+ export interface NodeChatParsedDocument {
13
+ text: string;
14
+ pages?: readonly Uint8Array[];
15
+ }
16
+ export interface NodeChatAttachmentStoreOptions {
17
+ paths: NodeChatStatePaths;
18
+ sessionStore: SessionStore;
19
+ now?: () => number;
20
+ parseDocument?: (input: {
21
+ bytes: Uint8Array;
22
+ mimeType: string;
23
+ signal?: AbortSignal;
24
+ }) => Promise<NodeChatParsedDocument>;
25
+ }
26
+ export declare function createNodeChatAttachmentStore(options: NodeChatAttachmentStoreOptions): {
27
+ put: (input: {
28
+ sessionId: string;
29
+ displayName: string;
30
+ bytes: Uint8Array;
31
+ signal?: AbortSignal;
32
+ }) => Promise<NodeChatAttachment>;
33
+ list: (sessionId: string) => Promise<NodeChatAttachment[]>;
34
+ authorizeRef: (sessionId: string, ref: string, kind: "image" | "document") => Promise<boolean>;
35
+ readAttachment: (sessionId: string, ref: string, signal?: AbortSignal) => Promise<{
36
+ text: any;
37
+ pageImages: ChatAttachmentGrant[];
38
+ }>;
39
+ readBytes: (sessionId: string, ref: string, signal?: AbortSignal) => Promise<{
40
+ bytes: Uint8Array<ArrayBuffer>;
41
+ mimeType: string;
42
+ }>;
43
+ deleteBySession: (sessionId: string) => Promise<void>;
44
+ cleanupExpired: (input?: {
45
+ limit?: number;
46
+ signal?: AbortSignal;
47
+ }) => Promise<string[]>;
48
+ startMaintenance: (onError: (code: "CHAT_ATTACHMENT_CLEANUP_FAILED") => void, signal?: AbortSignal) => Promise<() => void>;
49
+ isSessionDeleting: (sessionId: string) => boolean;
50
+ withActiveSession: <T>(sessionId: string, operation: () => Promise<T>) => Promise<T>;
51
+ sanitizeSession: (session: Session) => Session;
52
+ };
53
+ export type NodeChatAttachmentStore = ReturnType<typeof createNodeChatAttachmentStore>;
@@ -0,0 +1,3 @@
1
+ import type { CheckpointStore } from "@autopilot-agent/core";
2
+ import type { NodeStoreOptions } from "../types";
3
+ export declare function createNodeCheckpointStore(options: NodeStoreOptions): CheckpointStore;
@@ -0,0 +1,2 @@
1
+ import type { Clock } from "@autopilot-agent/core";
2
+ export declare function createNodeClock(): Clock;
@@ -0,0 +1,7 @@
1
+ import type { CredentialStore } from "@autopilot-agent/core";
2
+ export interface CreateNodeCredentialStoreOptions {
3
+ env?: NodeJS.ProcessEnv;
4
+ userSettingsPath?: string;
5
+ snapshot?: boolean;
6
+ }
7
+ export declare function createNodeCredentialStore(options?: CreateNodeCredentialStoreOptions): CredentialStore;
@@ -0,0 +1,3 @@
1
+ import type { EventSink } from "@autopilot-agent/core";
2
+ import type { NodeStoreOptions } from "../types";
3
+ export declare function createNodeEventSink(_options: NodeStoreOptions): EventSink;
@@ -0,0 +1,3 @@
1
+ import type { FileMutationStore } from "@autopilot-agent/core";
2
+ import type { NodeStoreOptions } from "../types";
3
+ export declare function createNodeFileMutationStore(options: NodeStoreOptions): FileMutationStore;
@@ -0,0 +1,3 @@
1
+ import type { InputInbox } from "@autopilot-agent/core";
2
+ import type { NodeStoreOptions } from "../types";
3
+ export declare function createNodeInputInbox(options: NodeStoreOptions): InputInbox;
@@ -0,0 +1,3 @@
1
+ import type { JobStore } from "@autopilot-agent/core";
2
+ import type { NodeStoreOptions } from "../types";
3
+ export declare function createNodeJobStore(options: NodeStoreOptions): JobStore;
@@ -0,0 +1,3 @@
1
+ import type { LeaseStore } from "@autopilot-agent/core";
2
+ import type { NodeStoreOptions } from "../types";
3
+ export declare function createNodeLeaseStore(options: NodeStoreOptions): LeaseStore;
@@ -0,0 +1,3 @@
1
+ import type { ProjectStore } from "@autopilot-agent/core";
2
+ import type { NodeStoreOptions } from "../types";
3
+ export declare function createNodeProjectStore(options: NodeStoreOptions): ProjectStore;
@@ -0,0 +1,2 @@
1
+ import type { SessionResourceStore } from "@autopilot-agent/core";
2
+ export declare function createNodeSessionResourceStore(workspaceRoot: string): SessionResourceStore;
@@ -0,0 +1,6 @@
1
+ import type { ProductMode, SessionStore } from "@autopilot-agent/core";
2
+ import type { NodeStoreOptions } from "../types";
3
+ export interface NodeSessionStoreOptions extends NodeStoreOptions {
4
+ productMode?: ProductMode;
5
+ }
6
+ export declare function createNodeSessionStore(options: NodeSessionStoreOptions): SessionStore;
@@ -0,0 +1,3 @@
1
+ import type { TranscriptStore } from "@autopilot-agent/core";
2
+ import type { NodeStoreOptions } from "../types";
3
+ export declare function createNodeTranscriptStore(options: NodeStoreOptions): TranscriptStore;
@@ -0,0 +1,3 @@
1
+ import type { TurnStore } from "@autopilot-agent/core";
2
+ import type { NodeStoreOptions } from "../types";
3
+ export declare function createNodeTurnStore(options: NodeStoreOptions): TurnStore;
@@ -0,0 +1,3 @@
1
+ import type { UserQuestionStore } from "@autopilot-agent/core";
2
+ import type { NodeStoreOptions } from "../types";
3
+ export declare function createNodeUserQuestionStore(options: NodeStoreOptions): UserQuestionStore;
@@ -0,0 +1,23 @@
1
+ import type { WorkspaceTrustEntry, WorkspaceTrustPolicy, WorkspaceTrustStatus } from "@autopilot-agent/core";
2
+ import type { NodeTrustPolicyOptions } from "./types";
3
+ export interface NodeTrustEntry {
4
+ workspaceRoot: string;
5
+ status: WorkspaceTrustStatus;
6
+ grantedAt?: number;
7
+ expiresAt?: number;
8
+ source: WorkspaceTrustEntry["source"];
9
+ reason?: string;
10
+ }
11
+ export declare function createNodeTrustStore(options: NodeTrustPolicyOptions): {
12
+ getTrustEntry(workspaceRoot: string): NodeTrustEntry;
13
+ isTrusted(workspaceRoot: string): boolean;
14
+ grantTrust(workspaceRoot: string, settings?: {
15
+ expiresAt?: number;
16
+ source?: NodeTrustEntry["source"];
17
+ reason?: string;
18
+ }): NodeTrustEntry;
19
+ denyTrust(workspaceRoot: string, reason?: string): NodeTrustEntry;
20
+ revokeTrust(workspaceRoot: string): NodeTrustEntry;
21
+ listTrustEntries(): NodeTrustEntry[];
22
+ };
23
+ export declare function createNodeTrustPolicy(options: NodeTrustPolicyOptions): WorkspaceTrustPolicy;
@@ -0,0 +1,22 @@
1
+ export interface NodeStoreOptions {
2
+ stateRoot: string;
3
+ }
4
+ export interface NodeWorkspaceAdapterOptions {
5
+ workspaceRoot?: string;
6
+ cwd?: string;
7
+ env?: NodeJS.ProcessEnv;
8
+ }
9
+ export interface NodeTrustPolicyOptions {
10
+ stateRoot: string;
11
+ trustRoot?: string;
12
+ beforeWrite?: (requiredBytes: number) => void;
13
+ now?: () => number;
14
+ }
15
+ export interface NodeCapabilityLoaderOptions {
16
+ env?: NodeJS.ProcessEnv;
17
+ homeDirectory?: string;
18
+ stateRoot?: string;
19
+ settingsLoader?: Pick<import("./settings/node-settings-loader").NodeSettingsLoader, "load"> & Partial<Pick<import("./settings/node-settings-loader").NodeUserSettingsLoader, "loadUser">>;
20
+ webSearchFetch?: typeof fetch;
21
+ webSearchConnectivityFetch?: typeof fetch;
22
+ }
@@ -0,0 +1,3 @@
1
+ import type { WorkspaceAdapter } from "@autopilot-agent/core";
2
+ import type { NodeWorkspaceAdapterOptions } from "./types";
3
+ export declare function createNodeWorkspaceAdapter(options?: NodeWorkspaceAdapterOptions): WorkspaceAdapter;
@@ -0,0 +1,17 @@
1
+ export interface WorkspaceRegistryEntry {
2
+ workspaceId: string;
3
+ workspaceRoot: string;
4
+ displayName: string;
5
+ lastOpenedAt: number;
6
+ }
7
+ export interface WorkspaceRegistry {
8
+ list(): WorkspaceRegistryEntry[];
9
+ get(workspaceId: string): WorkspaceRegistryEntry | undefined;
10
+ register(workspaceRoot: string): WorkspaceRegistryEntry;
11
+ remove(workspaceId: string): boolean;
12
+ }
13
+ export declare function createNodeWorkspaceRegistry(options?: {
14
+ globalStateRoot?: string;
15
+ cwd?: string;
16
+ now?: () => number;
17
+ }): WorkspaceRegistry;
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "@autopilot-agent/adapters",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "publishConfig": {
5
+ "access": "public",
6
+ "registry": "https://registry.npmjs.org/"
7
+ },
8
+ "main": "dist/index.js",
9
+ "module": "dist/index.mjs",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.mjs",
15
+ "require": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist/**/*.js",
20
+ "dist/**/*.mjs",
21
+ "dist/**/*.d.ts",
22
+ "!**/*.map",
23
+ "!**/*.{test,spec,bench}.*",
24
+ "!**/*-fixture*.*",
25
+ "!**/{test,tests,test-*,__tests__,__mocks__,contract-test,fixtures,coverage,playwright-report,test-results}/**",
26
+ "!**/{agent,agents,.agent-tests,.agents,.codex,.cursor,.idea,.vscode}/**",
27
+ "!**/{.git,.hg,.svn,.github,.gitlab}/**",
28
+ "!**/{.local,.autopilot,.cache,.npm-cache,.turbo,.next,.vite,__pycache__,node_modules,src,dist-types}/**",
29
+ "!**/*.{log,tsbuildinfo,tmp,temp,bak,orig,rej,swp,swo,pyc,pyo,tgz,tar,zip,7z,rar,db,sqlite,sqlite3,wal,shm}",
30
+ "!**/*.{pem,key,p12,pfx,crt,cer}",
31
+ "!**/{.env*,.npmrc*,.yarnrc*,.pnp.*,AGENTS.md,CLAUDE.md,.DS_Store,Thumbs.db}",
32
+ "!**/{settings.json,settings.local.json,mcp.json,credentials.json,credentials.local.json,package-lock.json,npm-shrinkwrap.json,yarn.lock,pnpm-lock.yaml,bun.lockb}",
33
+ "!**/{tsconfig*,vitest.config.*,vite.config.*,playwright.config.*,eslint.config.*,jest.config.*,turbo.json}"
34
+ ],
35
+ "scripts": {
36
+ "prepack": "npm run build && node ../../scripts/check-npm-pack.mjs packages/adapters",
37
+ "build": "node scripts/build-adapters.mjs",
38
+ "typecheck": "tsc --noEmit",
39
+ "lint": "eslint src test --ext .ts",
40
+ "test": "vitest run --config vitest.config.ts",
41
+ "test:watch": "vitest --config vitest.config.ts"
42
+ },
43
+ "dependencies": {
44
+ "@anthropic-ai/sandbox-runtime": "0.0.78",
45
+ "@autopilot-agent/core": "0.1.0",
46
+ "js-yaml": "4.3.0",
47
+ "linkedom": "0.18.12"
48
+ },
49
+ "devDependencies": {
50
+ "@types/node": "^20",
51
+ "esbuild": "^0.28.1",
52
+ "typescript": "^5",
53
+ "vitest": "^3.2.4"
54
+ },
55
+ "description": "Autopilot Agent 的 Node.js 宿主适配器。"
56
+ }