@yitom/acp-client 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 (41) hide show
  1. package/README.md +119 -0
  2. package/dist/auth/auth-method-order.d.ts +9 -0
  3. package/dist/auth/connect-auth-decision.d.ts +18 -0
  4. package/dist/auth/connect-auth-gate.d.ts +35 -0
  5. package/dist/client/acp-client.d.ts +110 -0
  6. package/dist/client/acp-fs.d.ts +15 -0
  7. package/dist/client/acp-paths.d.ts +8 -0
  8. package/dist/client/acp-proxy-service.d.ts +14 -0
  9. package/dist/client/acp-terminal.d.ts +36 -0
  10. package/dist/client/client-handlers.d.ts +27 -0
  11. package/dist/client/sdk-client.d.ts +32 -0
  12. package/dist/client/session-open.d.ts +39 -0
  13. package/dist/contracts/index.d.ts +277 -0
  14. package/dist/index.cjs +3279 -0
  15. package/dist/index.d.ts +33 -0
  16. package/dist/index.js +3242 -0
  17. package/dist/mcp/inkdown-mcp-rpc.d.ts +14 -0
  18. package/dist/mcp/inkdown-mcp-toc-tools.d.ts +3 -0
  19. package/dist/mcp/inkdown-mcp-tools.d.ts +31 -0
  20. package/dist/process/process-manager.d.ts +59 -0
  21. package/dist/runtimes/agy/index.d.ts +19 -0
  22. package/dist/runtimes/claude/index.d.ts +13 -0
  23. package/dist/runtimes/codex/codex-auth-preflight.d.ts +10 -0
  24. package/dist/runtimes/codex/codex-provider-home.d.ts +20 -0
  25. package/dist/runtimes/codex/codex-provider.d.ts +13 -0
  26. package/dist/runtimes/codex/index.d.ts +16 -0
  27. package/dist/runtimes/copilot/index.d.ts +14 -0
  28. package/dist/runtimes/cursor/index.d.ts +66 -0
  29. package/dist/runtimes/deepseek/index.d.ts +34 -0
  30. package/dist/runtimes/gemini/index.d.ts +13 -0
  31. package/dist/runtimes/index.d.ts +54 -0
  32. package/dist/runtimes/opencode/index.d.ts +28 -0
  33. package/dist/session/agent-registry.d.ts +4 -0
  34. package/dist/session/config-options.d.ts +17 -0
  35. package/dist/session/session-capabilities.d.ts +10 -0
  36. package/dist/transport/terminal-output-buffer.d.ts +11 -0
  37. package/docs/adding-an-agent.md +121 -0
  38. package/docs/api-reference.md +104 -0
  39. package/docs/getting-started.md +164 -0
  40. package/docs/tauri-integration.md +107 -0
  41. package/package.json +44 -0
@@ -0,0 +1,277 @@
1
+ /**
2
+ * @yitom/acp-client 核心契约与数据类型
3
+ *
4
+ * 自包含的跨平台 ACP 规范定义,零外部私有包依赖。
5
+ */
6
+ export type AppErrorCode = 'CANCELLED' | 'API_UNAVAILABLE' | 'FILE_READ_ERROR' | 'FILE_WRITE_ERROR' | 'FILE_NOT_FOUND' | 'WORKSPACE_SCAN_ERROR' | 'UNSUPPORTED_FORMAT' | 'ACP_SPAWN_ERROR' | 'ACP_PROTOCOL_ERROR' | 'ACP_NOT_CONNECTED' | 'ACP_TIMEOUT' | 'BUN_NOT_INSTALLED' | 'OCR_TOC_EMPTY' | 'OCR_PAGE_EMPTY' | 'OCR_FAILED' | 'INVALID_ARGUMENT' | 'INVALID_STATE' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'NETWORK_ERROR' | 'SYNC_ERROR' | 'UNKNOWN';
7
+ export interface AppError {
8
+ code: AppErrorCode;
9
+ message: string;
10
+ }
11
+ export declare function isCancelled(error: AppError): boolean;
12
+ export declare function isAppError(value: unknown): value is AppError;
13
+ export declare function toAppError(error: unknown, fallbackMessage: string): AppError;
14
+ export type Result<T, E = AppError> = {
15
+ ok: true;
16
+ value: T;
17
+ } | {
18
+ ok: false;
19
+ error: E;
20
+ };
21
+ export declare function ok<T>(value: T): Result<T, never>;
22
+ export declare function err<E>(error: E): Result<never, E>;
23
+ export declare function isOk<T, E>(result: Result<T, E>): result is {
24
+ ok: true;
25
+ value: T;
26
+ };
27
+ export declare function isErr<T, E>(result: Result<T, E>): result is {
28
+ ok: false;
29
+ error: E;
30
+ };
31
+ export type AcpConnectionStatus = 'disconnected' | 'connecting' | 'awaiting_auth' | 'connected' | 'error';
32
+ export interface AcpRuntimeInfo {
33
+ id: string;
34
+ name: string;
35
+ description: string;
36
+ command: string;
37
+ args: string[];
38
+ requiredEnvKeys: string[];
39
+ authHint?: string;
40
+ }
41
+ export interface AcpConnectPayload {
42
+ runtimeId: string;
43
+ cwd?: string;
44
+ resumeSessionId?: string;
45
+ hasLocalHistory?: boolean;
46
+ }
47
+ export declare const INKDOWN_SETTLE_COMPLETE_KIND = "inkdown_settle_complete";
48
+ export interface AcpAuthMethod {
49
+ id: string;
50
+ name?: string;
51
+ description?: string;
52
+ type?: string;
53
+ }
54
+ export type AcpSessionRestoreMethod = 'resume' | 'load' | 'new';
55
+ export interface AcpSessionRestoreAttempt {
56
+ method: 'resume' | 'load';
57
+ ok: boolean;
58
+ tries: number;
59
+ error?: string;
60
+ }
61
+ export interface AcpPromptCapabilities {
62
+ image?: boolean;
63
+ audio?: boolean;
64
+ embeddedContext?: boolean;
65
+ }
66
+ export type AcpContentBlock = {
67
+ type: 'text';
68
+ text: string;
69
+ } | {
70
+ type: 'resource_link';
71
+ uri: string;
72
+ name: string;
73
+ mimeType?: string;
74
+ size?: number;
75
+ } | {
76
+ type: 'image';
77
+ data: string;
78
+ mimeType: string;
79
+ uri?: string;
80
+ };
81
+ export interface AcpConnectReadyResult {
82
+ phase: 'ready';
83
+ runtimeId: string;
84
+ sessionId: string;
85
+ protocolVersion: number;
86
+ agentName?: string;
87
+ agentVersion?: string;
88
+ configOptions?: AcpConfigOption[];
89
+ loadSessionSupported?: boolean;
90
+ resumeSessionSupported?: boolean;
91
+ promptCapabilities?: AcpPromptCapabilities;
92
+ sessionRestored?: boolean;
93
+ restoreMethod?: AcpSessionRestoreMethod;
94
+ requestedSessionId?: string;
95
+ restoreAttempts?: AcpSessionRestoreAttempt[];
96
+ modelCatalog?: string[];
97
+ }
98
+ export interface AcpConnectNeedsAuthResult {
99
+ phase: 'needs_auth';
100
+ runtimeId: string;
101
+ protocolVersion: number;
102
+ agentName?: string;
103
+ agentVersion?: string;
104
+ authMethods: AcpAuthMethod[];
105
+ loadSessionSupported?: boolean;
106
+ resumeSessionSupported?: boolean;
107
+ promptCapabilities?: AcpPromptCapabilities;
108
+ }
109
+ export type AcpConnectResult = AcpConnectReadyResult | AcpConnectNeedsAuthResult;
110
+ export interface AcpAuthenticatePayload {
111
+ methodId: string;
112
+ }
113
+ export interface AcpLoadSessionPayload {
114
+ sessionId: string;
115
+ cwd?: string;
116
+ secondary?: boolean;
117
+ }
118
+ export interface AcpConfigOptionValue {
119
+ value: string;
120
+ name: string;
121
+ description?: string;
122
+ }
123
+ export interface AcpConfigOption {
124
+ configId: string;
125
+ name: string;
126
+ description?: string;
127
+ category?: string;
128
+ type: 'select' | 'boolean' | string;
129
+ currentValue?: string | boolean | number;
130
+ options?: AcpConfigOptionValue[];
131
+ }
132
+ export interface AcpSetConfigOptionPayload {
133
+ sessionId: string;
134
+ configId: string;
135
+ value: string | boolean | number;
136
+ }
137
+ export interface AcpSetConfigOptionResult {
138
+ configOptions: AcpConfigOption[];
139
+ }
140
+ export interface AcpSessionNewPayload {
141
+ cwd?: string;
142
+ toolScope?: 'full' | 'toc';
143
+ }
144
+ export interface AcpSessionNewResult {
145
+ sessionId: string;
146
+ configOptions?: AcpConfigOption[];
147
+ }
148
+ export interface AcpPromptPayload {
149
+ sessionId: string;
150
+ prompt: AcpContentBlock[];
151
+ }
152
+ export interface AcpPromptResult {
153
+ stopReason: string;
154
+ }
155
+ export interface AcpCancelPayload {
156
+ sessionId: string;
157
+ }
158
+ export type AcpToolCallStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'cancelled' | string;
159
+ export type AcpToolCallKind = 'read' | 'edit' | 'delete' | 'move' | 'search' | 'execute' | 'think' | 'fetch' | 'other' | string;
160
+ export interface AcpSessionUpdateEvent {
161
+ sessionId: string;
162
+ update: Record<string, unknown>;
163
+ }
164
+ export interface AcpStatusChangedEvent {
165
+ status: AcpConnectionStatus;
166
+ runtimeId?: string;
167
+ sessionId?: string | null;
168
+ errorMessage?: string;
169
+ }
170
+ export interface AcpPermissionRequestEvent {
171
+ requestId: number;
172
+ sessionId?: string;
173
+ toolCall?: Record<string, unknown>;
174
+ options?: unknown[];
175
+ rawParams: Record<string, unknown>;
176
+ summary?: string;
177
+ }
178
+ export type AcpPermissionOutcome = {
179
+ outcome: 'selected';
180
+ optionId: string;
181
+ } | {
182
+ outcome: 'cancelled';
183
+ };
184
+ export interface AcpPermissionResponsePayload {
185
+ requestId: number;
186
+ outcome: AcpPermissionOutcome;
187
+ }
188
+ export interface InkdownSnapshotArgs {
189
+ path?: string;
190
+ range?: [number, number];
191
+ query?: string;
192
+ limit?: number;
193
+ flatIndex?: number;
194
+ title?: string;
195
+ note?: string;
196
+ excerpt?: string;
197
+ kind?: 'highlight' | 'note' | 'auto';
198
+ filter?: 'all' | 'highlights' | 'bookmarks';
199
+ chapters?: Array<{
200
+ flatIndex: number;
201
+ title: string;
202
+ reason: string;
203
+ }>;
204
+ marks?: Array<{
205
+ excerpt: string;
206
+ note?: string;
207
+ flatIndex?: number;
208
+ kind?: 'highlight' | 'note' | 'auto';
209
+ }>;
210
+ op?: string;
211
+ fingerprint?: string;
212
+ entries?: unknown;
213
+ entry?: unknown;
214
+ index?: number;
215
+ [key: string]: unknown;
216
+ }
217
+ export type InkdownSnapshotResource = InkdownVirtualResource | 'search' | 'selection' | 'chapter' | 'marks' | 'highlights' | 'create-bookmark' | 'create-note' | 'propose-note' | 'propose-mark' | 'suggest-chapters' | 'toc-draft-read' | 'toc-draft-write' | 'content-audit';
218
+ export interface AcpSnapshotRequestEvent {
219
+ requestId: number;
220
+ resource: InkdownSnapshotResource;
221
+ args?: InkdownSnapshotArgs;
222
+ }
223
+ export type AcpSnapshotResponsePayload = {
224
+ requestId: number;
225
+ ok: true;
226
+ content: string;
227
+ } | {
228
+ requestId: number;
229
+ ok: false;
230
+ message: string;
231
+ };
232
+ export declare const INKDOWN_VIRTUAL_DIR = ".inkdown/agent";
233
+ export declare const INKDOWN_VIRTUAL_RESOURCES: readonly ['focused.json', 'toc.json', 'chapter.txt', 'viewport.txt'];
234
+ export type InkdownVirtualResource = (typeof INKDOWN_VIRTUAL_RESOURCES)[number];
235
+ export declare function parseInkdownVirtualPath(filePath: string, workspaceRoot: string): InkdownVirtualResource | null;
236
+ export declare function isInkdownVirtualDirPath(filePath: string, workspaceRoot: string): boolean;
237
+ export interface AcpAuthPreflightResult {
238
+ codexHome: string;
239
+ hasCodexHome: boolean;
240
+ hasAuthFile: boolean;
241
+ hasApiKeyEnv: boolean;
242
+ looksLoggedIn: boolean;
243
+ }
244
+ export interface AcpAuthPreflightPayload {
245
+ runtimeId?: string;
246
+ }
247
+ export type CodexAuthPreflight = AcpAuthPreflightResult;
248
+ export interface AcpProviderConfig {
249
+ name?: string;
250
+ baseUrl: string;
251
+ model: string;
252
+ wireApi: 'chat' | 'responses';
253
+ }
254
+ export interface AcpProviderSavePayload extends AcpProviderConfig {
255
+ apiKey: string;
256
+ }
257
+ export interface AcpProviderStatus {
258
+ configured: boolean;
259
+ name?: string;
260
+ baseUrl?: string;
261
+ model?: string;
262
+ wireApi?: 'chat' | 'responses';
263
+ hasApiKey: boolean;
264
+ }
265
+ export interface AcpProxySettings {
266
+ enabled: boolean;
267
+ host: string;
268
+ port: number;
269
+ }
270
+ export declare const CODEX_ACP_NPM_PACKAGE: '@agentclientprotocol/codex-acp';
271
+ export declare const CLAUDE_ACP_NPM_PACKAGE: '@agentclientprotocol/claude-agent-acp';
272
+ export declare const DEEPSEEK_DSH_NPM_PACKAGE: '@deepseek-ai/dsh';
273
+ export declare const AGY_ACP_NPM_PACKAGE: '@yitom/agy-acp-map';
274
+ export declare const LEGACY_ZED_CODEX_ACP_NPM_PACKAGE: '@zed-industries/codex-acp';
275
+ export declare const DEFAULT_ACP_RUNTIME_ID = "codex-acp";
276
+ export declare const BUILTIN_ACP_RUNTIMES: readonly AcpRuntimeInfo[];
277
+ export declare function findBuiltinAcpRuntime(id: string): AcpRuntimeInfo | undefined;