@ikenga/contract 0.6.0 → 0.9.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 (74) hide show
  1. package/README.md +56 -11
  2. package/dist/canvas/Canvas.d.ts +7 -0
  3. package/dist/canvas/Canvas.d.ts.map +1 -0
  4. package/dist/canvas/Canvas.js +115 -0
  5. package/dist/canvas/Canvas.js.map +1 -0
  6. package/dist/canvas/canvas.css +579 -0
  7. package/dist/canvas/index.d.ts +7 -0
  8. package/dist/canvas/index.d.ts.map +1 -0
  9. package/dist/canvas/index.js +4 -0
  10. package/dist/canvas/index.js.map +1 -0
  11. package/dist/canvas/types.d.ts +45 -0
  12. package/dist/canvas/types.d.ts.map +1 -0
  13. package/dist/canvas/types.js +2 -0
  14. package/dist/canvas/types.js.map +1 -0
  15. package/dist/canvas/use-drag-snap.d.ts +33 -0
  16. package/dist/canvas/use-drag-snap.d.ts.map +1 -0
  17. package/dist/canvas/use-drag-snap.js +73 -0
  18. package/dist/canvas/use-drag-snap.js.map +1 -0
  19. package/dist/canvas/use-pan-zoom.d.ts +32 -0
  20. package/dist/canvas/use-pan-zoom.d.ts.map +1 -0
  21. package/dist/canvas/use-pan-zoom.js +161 -0
  22. package/dist/canvas/use-pan-zoom.js.map +1 -0
  23. package/dist/engine/index.d.ts +2 -0
  24. package/dist/engine/index.d.ts.map +1 -1
  25. package/dist/engine/index.js +2 -0
  26. package/dist/engine/index.js.map +1 -1
  27. package/dist/engine/portability.d.ts +113 -0
  28. package/dist/engine/portability.d.ts.map +1 -0
  29. package/dist/engine/portability.js +17 -0
  30. package/dist/engine/portability.js.map +1 -0
  31. package/dist/engine/subagent-transcoder.d.ts +24 -0
  32. package/dist/engine/subagent-transcoder.d.ts.map +1 -0
  33. package/dist/engine/subagent-transcoder.js +341 -0
  34. package/dist/engine/subagent-transcoder.js.map +1 -0
  35. package/dist/engine.d.ts +574 -0
  36. package/dist/engine.d.ts.map +1 -0
  37. package/dist/engine.js +85 -0
  38. package/dist/engine.js.map +1 -0
  39. package/dist/host-verbs.d.ts +194 -0
  40. package/dist/host-verbs.d.ts.map +1 -0
  41. package/dist/host-verbs.js +15 -0
  42. package/dist/host-verbs.js.map +1 -0
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1 -0
  46. package/dist/index.js.map +1 -1
  47. package/dist/manifest.d.ts +376 -19
  48. package/dist/manifest.d.ts.map +1 -1
  49. package/dist/manifest.js +95 -4
  50. package/dist/manifest.js.map +1 -1
  51. package/dist/registry.d.ts +364 -36
  52. package/dist/registry.d.ts.map +1 -1
  53. package/dist/registry.js +9 -0
  54. package/dist/registry.js.map +1 -1
  55. package/dist/scopes.js +1 -1
  56. package/dist/scopes.js.map +1 -1
  57. package/package.json +36 -10
  58. package/schemas/registry/index-v1.json +11 -0
  59. package/src/canvas/Canvas.tsx +161 -0
  60. package/src/canvas/canvas.css +579 -0
  61. package/src/canvas/index.ts +14 -0
  62. package/src/canvas/types.ts +48 -0
  63. package/src/canvas/use-drag-snap.ts +107 -0
  64. package/src/canvas/use-pan-zoom.ts +211 -0
  65. package/src/engine/index.ts +2 -0
  66. package/src/engine/portability.ts +123 -0
  67. package/src/engine/subagent-transcoder.test.ts +306 -0
  68. package/src/engine/subagent-transcoder.ts +333 -0
  69. package/src/host-verbs.ts +207 -0
  70. package/src/index.ts +1 -0
  71. package/src/manifest.test.ts +97 -0
  72. package/src/manifest.ts +109 -4
  73. package/src/registry.ts +9 -0
  74. package/src/scopes.ts +1 -1
@@ -0,0 +1,574 @@
1
+ import { z } from 'zod';
2
+ export interface SessionOpts {
3
+ cwd?: string;
4
+ systemPrompt?: string;
5
+ toolAllowList?: string[];
6
+ /** Caller pkg id, used by the engine for per-pkg billing/audit. */
7
+ callerPkg?: string;
8
+ }
9
+ export interface Session {
10
+ readonly id: string;
11
+ /** Best-effort cancellation. Resolves once the engine has stopped streaming. */
12
+ cancel(): Promise<void>;
13
+ }
14
+ export type EngineEvent = {
15
+ type: 'message_delta';
16
+ text: string;
17
+ } | {
18
+ type: 'tool_use';
19
+ tool: string;
20
+ input: unknown;
21
+ toolUseId: string;
22
+ } | {
23
+ type: 'tool_result';
24
+ toolUseId: string;
25
+ output: unknown;
26
+ isError?: boolean;
27
+ } | {
28
+ type: 'thinking_delta';
29
+ text: string;
30
+ } | {
31
+ type: 'usage';
32
+ inputTokens: number;
33
+ outputTokens: number;
34
+ cacheCreationTokens?: number;
35
+ cacheReadTokens?: number;
36
+ } | {
37
+ type: 'done';
38
+ reason: 'stop' | 'cancel' | 'error';
39
+ error?: string;
40
+ };
41
+ export interface McpServerSpec {
42
+ id: string;
43
+ command: string;
44
+ args?: string[];
45
+ env?: Record<string, string>;
46
+ }
47
+ /**
48
+ * Capability flags every engine adapter advertises. This is the canonical
49
+ * shape consumed by both the shell-side ChatAdapter layer and any pkg that
50
+ * needs to reason about adapter features (wizard, settings UI, telemetry).
51
+ *
52
+ * Fields are intentionally a *superset* of what any single adapter
53
+ * supports — an adapter sets the ones it implements to `true` and the
54
+ * rest to `false`. Adding a new flag is a non-breaking schema change so
55
+ * long as adapters default it to `false` until they implement it.
56
+ */
57
+ export declare const AgentCapabilitiesSchema: z.ZodObject<{
58
+ /** Streams partial responses as they arrive (vs. all-at-once). */
59
+ streaming: z.ZodBoolean;
60
+ /** Invokes external tools / function calls during a turn. */
61
+ toolUse: z.ZodBoolean;
62
+ /** Emits an extended-thinking / reasoning channel separate from output. */
63
+ thinking: z.ZodBoolean;
64
+ /** Produces structured artifacts (code blocks, files, images) the host renders. */
65
+ artifacts: z.ZodBoolean;
66
+ /** Accepts file attachments as part of an input. */
67
+ fileAttachments: z.ZodBoolean;
68
+ /** Accepts image input (vision). */
69
+ imageInput: z.ZodBoolean;
70
+ /** Recognises a `/slash` command vocabulary. */
71
+ slashCommands: z.ZodBoolean;
72
+ /** Lets the user switch models mid-thread. */
73
+ modelSwitching: z.ZodBoolean;
74
+ /** Uses prompt-caching for repeated context (Anthropic-specific today). */
75
+ promptCaching: z.ZodBoolean;
76
+ /** Runs agentic tools (recursive sub-agents, long-running loops). */
77
+ agenticTools: z.ZodBoolean;
78
+ /** Speaks MCP — can register and route through MCP servers. */
79
+ mcp: z.ZodBoolean;
80
+ /** Can resume a prior session by id. */
81
+ sessionResume: z.ZodBoolean;
82
+ }, "strip", z.ZodTypeAny, {
83
+ mcp: boolean;
84
+ streaming: boolean;
85
+ toolUse: boolean;
86
+ thinking: boolean;
87
+ artifacts: boolean;
88
+ fileAttachments: boolean;
89
+ imageInput: boolean;
90
+ slashCommands: boolean;
91
+ modelSwitching: boolean;
92
+ promptCaching: boolean;
93
+ agenticTools: boolean;
94
+ sessionResume: boolean;
95
+ }, {
96
+ mcp: boolean;
97
+ streaming: boolean;
98
+ toolUse: boolean;
99
+ thinking: boolean;
100
+ artifacts: boolean;
101
+ fileAttachments: boolean;
102
+ imageInput: boolean;
103
+ slashCommands: boolean;
104
+ modelSwitching: boolean;
105
+ promptCaching: boolean;
106
+ agenticTools: boolean;
107
+ sessionResume: boolean;
108
+ }>;
109
+ export type AgentCapabilities = z.infer<typeof AgentCapabilitiesSchema>;
110
+ /**
111
+ * Per-adapter onboarding requirements surfaced in the first-run wizard.
112
+ * The wizard composes these instead of hardcoding per-agent forms —
113
+ * every engine pkg owns its own setup story.
114
+ */
115
+ export declare const EngineOnboardingSchema: z.ZodObject<{
116
+ /** Stronghold-vault keys this adapter needs at runtime (e.g. `ANTHROPIC_API_KEY`). */
117
+ requiredVaultKeys: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
118
+ /** Plain env-vars the adapter expects on the host shell. */
119
+ requiredEnvVars: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
120
+ /**
121
+ * CLI command the user can run to authenticate. The wizard surfaces this
122
+ * as a copy-to-clipboard hint — it never shells out on the user's behalf.
123
+ */
124
+ authCommand: z.ZodOptional<z.ZodString>;
125
+ /** Docs URL for setting up this adapter. */
126
+ docsUrl: z.ZodOptional<z.ZodString>;
127
+ }, "strip", z.ZodTypeAny, {
128
+ requiredVaultKeys: string[];
129
+ requiredEnvVars: string[];
130
+ authCommand?: string | undefined;
131
+ docsUrl?: string | undefined;
132
+ }, {
133
+ requiredVaultKeys?: string[] | undefined;
134
+ requiredEnvVars?: string[] | undefined;
135
+ authCommand?: string | undefined;
136
+ docsUrl?: string | undefined;
137
+ }>;
138
+ export type EngineOnboarding = z.infer<typeof EngineOnboardingSchema>;
139
+ /**
140
+ * Manifest block declared by engine-* pkgs. Read by the shell's
141
+ * `AdapterLoader` at pkg-discovery time; consumed by the wizard to compose
142
+ * adapter-specific onboarding hints.
143
+ */
144
+ export declare const EngineProvidesSchema: z.ZodObject<{
145
+ /**
146
+ * Stable id — matches the detection-side agent id (e.g. `claude-code`,
147
+ * `codex`, `aider`, `noop`). The wizard's `selected_agent_id` is matched
148
+ * against this field at adapter-resolve time.
149
+ */
150
+ agentId: z.ZodString;
151
+ /** Display name; overrides any detection-side display if both present. */
152
+ display: z.ZodOptional<z.ZodString>;
153
+ /** Snapshot of what this adapter implements. */
154
+ capabilities: z.ZodObject<{
155
+ /** Streams partial responses as they arrive (vs. all-at-once). */
156
+ streaming: z.ZodBoolean;
157
+ /** Invokes external tools / function calls during a turn. */
158
+ toolUse: z.ZodBoolean;
159
+ /** Emits an extended-thinking / reasoning channel separate from output. */
160
+ thinking: z.ZodBoolean;
161
+ /** Produces structured artifacts (code blocks, files, images) the host renders. */
162
+ artifacts: z.ZodBoolean;
163
+ /** Accepts file attachments as part of an input. */
164
+ fileAttachments: z.ZodBoolean;
165
+ /** Accepts image input (vision). */
166
+ imageInput: z.ZodBoolean;
167
+ /** Recognises a `/slash` command vocabulary. */
168
+ slashCommands: z.ZodBoolean;
169
+ /** Lets the user switch models mid-thread. */
170
+ modelSwitching: z.ZodBoolean;
171
+ /** Uses prompt-caching for repeated context (Anthropic-specific today). */
172
+ promptCaching: z.ZodBoolean;
173
+ /** Runs agentic tools (recursive sub-agents, long-running loops). */
174
+ agenticTools: z.ZodBoolean;
175
+ /** Speaks MCP — can register and route through MCP servers. */
176
+ mcp: z.ZodBoolean;
177
+ /** Can resume a prior session by id. */
178
+ sessionResume: z.ZodBoolean;
179
+ }, "strip", z.ZodTypeAny, {
180
+ mcp: boolean;
181
+ streaming: boolean;
182
+ toolUse: boolean;
183
+ thinking: boolean;
184
+ artifacts: boolean;
185
+ fileAttachments: boolean;
186
+ imageInput: boolean;
187
+ slashCommands: boolean;
188
+ modelSwitching: boolean;
189
+ promptCaching: boolean;
190
+ agenticTools: boolean;
191
+ sessionResume: boolean;
192
+ }, {
193
+ mcp: boolean;
194
+ streaming: boolean;
195
+ toolUse: boolean;
196
+ thinking: boolean;
197
+ artifacts: boolean;
198
+ fileAttachments: boolean;
199
+ imageInput: boolean;
200
+ slashCommands: boolean;
201
+ modelSwitching: boolean;
202
+ promptCaching: boolean;
203
+ agenticTools: boolean;
204
+ sessionResume: boolean;
205
+ }>;
206
+ /** Onboarding requirements composed by the wizard. */
207
+ onboarding: z.ZodDefault<z.ZodObject<{
208
+ /** Stronghold-vault keys this adapter needs at runtime (e.g. `ANTHROPIC_API_KEY`). */
209
+ requiredVaultKeys: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
210
+ /** Plain env-vars the adapter expects on the host shell. */
211
+ requiredEnvVars: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
212
+ /**
213
+ * CLI command the user can run to authenticate. The wizard surfaces this
214
+ * as a copy-to-clipboard hint — it never shells out on the user's behalf.
215
+ */
216
+ authCommand: z.ZodOptional<z.ZodString>;
217
+ /** Docs URL for setting up this adapter. */
218
+ docsUrl: z.ZodOptional<z.ZodString>;
219
+ }, "strip", z.ZodTypeAny, {
220
+ requiredVaultKeys: string[];
221
+ requiredEnvVars: string[];
222
+ authCommand?: string | undefined;
223
+ docsUrl?: string | undefined;
224
+ }, {
225
+ requiredVaultKeys?: string[] | undefined;
226
+ requiredEnvVars?: string[] | undefined;
227
+ authCommand?: string | undefined;
228
+ docsUrl?: string | undefined;
229
+ }>>;
230
+ }, "strip", z.ZodTypeAny, {
231
+ capabilities: {
232
+ mcp: boolean;
233
+ streaming: boolean;
234
+ toolUse: boolean;
235
+ thinking: boolean;
236
+ artifacts: boolean;
237
+ fileAttachments: boolean;
238
+ imageInput: boolean;
239
+ slashCommands: boolean;
240
+ modelSwitching: boolean;
241
+ promptCaching: boolean;
242
+ agenticTools: boolean;
243
+ sessionResume: boolean;
244
+ };
245
+ agentId: string;
246
+ onboarding: {
247
+ requiredVaultKeys: string[];
248
+ requiredEnvVars: string[];
249
+ authCommand?: string | undefined;
250
+ docsUrl?: string | undefined;
251
+ };
252
+ display?: string | undefined;
253
+ }, {
254
+ capabilities: {
255
+ mcp: boolean;
256
+ streaming: boolean;
257
+ toolUse: boolean;
258
+ thinking: boolean;
259
+ artifacts: boolean;
260
+ fileAttachments: boolean;
261
+ imageInput: boolean;
262
+ slashCommands: boolean;
263
+ modelSwitching: boolean;
264
+ promptCaching: boolean;
265
+ agenticTools: boolean;
266
+ sessionResume: boolean;
267
+ };
268
+ agentId: string;
269
+ display?: string | undefined;
270
+ onboarding?: {
271
+ requiredVaultKeys?: string[] | undefined;
272
+ requiredEnvVars?: string[] | undefined;
273
+ authCommand?: string | undefined;
274
+ docsUrl?: string | undefined;
275
+ } | undefined;
276
+ }>;
277
+ export type EngineProvides = z.infer<typeof EngineProvidesSchema>;
278
+ export interface Engine {
279
+ /** Stable identifier — matches the pkg id of the engine adapter. */
280
+ readonly id: string;
281
+ /** Human-readable adapter version. */
282
+ readonly version: string;
283
+ /**
284
+ * Static metadata copied from the loading manifest's `engine` block.
285
+ * Required: every adapter must surface its agentId / display / capabilities
286
+ * / onboarding so the shell and wizard can introspect without re-parsing
287
+ * the manifest.
288
+ */
289
+ readonly metadata: {
290
+ agentId: string;
291
+ display: string;
292
+ capabilities: AgentCapabilities;
293
+ onboarding: EngineOnboarding;
294
+ };
295
+ /** Open a new session. Sessions are cheap; create one per pkg invocation. */
296
+ startSession(opts: SessionOpts): Promise<Session>;
297
+ /** Send input and stream events. The iterable completes on `done`. */
298
+ stream(session: Session, input: string): AsyncIterable<EngineEvent>;
299
+ /** Register an MCP server with the engine. Idempotent on `id`. */
300
+ registerMcpServer(spec: McpServerSpec): Promise<void>;
301
+ /** Unregister an MCP server. */
302
+ unregisterMcpServer(id: string): Promise<void>;
303
+ /** Health check — used by the kernel before routing pkg requests. */
304
+ healthCheck(): Promise<{
305
+ ok: boolean;
306
+ reason?: string;
307
+ }>;
308
+ }
309
+ /**
310
+ * Loader the shell uses to bring engine-* pkgs online at boot, tear them
311
+ * down on removal, and gracefully fall back when the user's
312
+ * `selected_agent_id` has no installed adapter.
313
+ *
314
+ * Implementation lives shell-side (post-Phase-7); this interface lets
315
+ * the contract pin the shape so engine pkgs and the shell agree on the
316
+ * load lifecycle.
317
+ */
318
+ export interface AdapterLoader {
319
+ /**
320
+ * Load + register the engine for a given pkg manifest. The manifest must
321
+ * carry an `engine` block (see `EngineProvidesSchema`); the loader
322
+ * resolves the adapter implementation and threads the manifest's
323
+ * metadata into the returned `Engine.metadata`.
324
+ */
325
+ load(manifest: {
326
+ id: string;
327
+ engine: EngineProvides;
328
+ }): Promise<Engine>;
329
+ /** Unload — used on pkg removal. After this resolves the agentId is unregistered. */
330
+ unload(agentId: string): Promise<void>;
331
+ /**
332
+ * Fallback returned when the requested agentId has no registered loader.
333
+ * Implementations MUST return a working `engine-noop` (or equivalent
334
+ * inert) adapter so the chat surface never dead-ends.
335
+ */
336
+ fallback(): Engine;
337
+ }
338
+ /** ACP `ProtocolVersion`. Numeric. V1 = 1. */
339
+ export type AcpProtocolVersion = number;
340
+ export interface AcpInitializeRequest {
341
+ protocolVersion: AcpProtocolVersion;
342
+ /** Optional `_meta` passthrough; the in-process shell ignores it. */
343
+ _meta?: Record<string, unknown>;
344
+ }
345
+ export interface AcpPromptCapabilities {
346
+ image: boolean;
347
+ audio: boolean;
348
+ embeddedContext: boolean;
349
+ }
350
+ export interface AcpMcpCapabilities {
351
+ http: boolean;
352
+ sse: boolean;
353
+ }
354
+ export interface AcpAgentCapabilities {
355
+ loadSession: boolean;
356
+ promptCapabilities: AcpPromptCapabilities;
357
+ mcpCapabilities: AcpMcpCapabilities;
358
+ }
359
+ export interface AcpInitializeResponse {
360
+ protocolVersion: AcpProtocolVersion;
361
+ agentCapabilities: AcpAgentCapabilities;
362
+ /** Authentication methods the agent supports — opaque structure passed
363
+ * through to the wizard. */
364
+ authMethods?: unknown[];
365
+ _meta?: Record<string, unknown>;
366
+ }
367
+ export interface AcpTextContentBlock {
368
+ type: 'text';
369
+ text: string;
370
+ }
371
+ /** ACP `ContentBlock::Image`. `data` is raw base64 with NO `data:` URI prefix. */
372
+ export interface AcpImageContentBlock {
373
+ type: 'image';
374
+ data: string;
375
+ mimeType: string;
376
+ uri?: string;
377
+ }
378
+ export type AcpContentBlock = AcpTextContentBlock | AcpImageContentBlock | {
379
+ type: 'audio';
380
+ data: string;
381
+ mimeType: string;
382
+ } | {
383
+ type: 'resource_link';
384
+ name: string;
385
+ uri: string;
386
+ } | {
387
+ type: 'resource';
388
+ resource: unknown;
389
+ };
390
+ export interface AcpNewSessionRequest {
391
+ cwd: string;
392
+ mcpServers: McpServerSpec[];
393
+ _meta?: Record<string, unknown>;
394
+ }
395
+ /** The four canonical ACP session modes the Rust ACP server advertises. */
396
+ export type AcpSessionModeId = 'plan' | 'default' | 'auto' | 'bypassPermissions';
397
+ export interface AcpSessionMode {
398
+ id: AcpSessionModeId;
399
+ name: string;
400
+ description?: string;
401
+ _meta?: Record<string, unknown>;
402
+ }
403
+ export interface AcpSessionModes {
404
+ currentModeId: AcpSessionModeId;
405
+ availableModes: AcpSessionMode[];
406
+ _meta?: Record<string, unknown>;
407
+ }
408
+ export interface AcpNewSessionResponse {
409
+ sessionId: string;
410
+ modes?: AcpSessionModes;
411
+ models?: unknown;
412
+ configOptions?: unknown[];
413
+ _meta?: Record<string, unknown>;
414
+ }
415
+ export interface AcpPromptRequest {
416
+ sessionId: string;
417
+ prompt: AcpContentBlock[];
418
+ messageId?: string;
419
+ _meta?: Record<string, unknown>;
420
+ }
421
+ export type AcpStopReason = 'end_turn' | 'max_tokens' | 'max_turn_requests' | 'refusal' | 'cancelled';
422
+ export interface AcpPromptResponse {
423
+ stopReason: AcpStopReason;
424
+ userMessageId?: string;
425
+ usage?: unknown;
426
+ _meta?: Record<string, unknown>;
427
+ }
428
+ /** ACP `SessionUpdate` discriminated union. Open-ended on the `string` tail
429
+ * so adapter-specific extensions don't break TS consumers. */
430
+ export type AcpSessionUpdate = {
431
+ sessionUpdate: 'agent_message_chunk';
432
+ content: AcpContentBlock;
433
+ messageId?: string;
434
+ } | {
435
+ sessionUpdate: 'agent_thought_chunk';
436
+ content: AcpContentBlock;
437
+ messageId?: string;
438
+ } | {
439
+ sessionUpdate: 'user_message_chunk';
440
+ content: AcpContentBlock;
441
+ } | {
442
+ sessionUpdate: 'tool_call';
443
+ toolCallId: string;
444
+ title: string;
445
+ kind?: string;
446
+ status?: string;
447
+ content?: unknown[];
448
+ rawInput?: unknown;
449
+ _meta?: Record<string, unknown>;
450
+ } | {
451
+ sessionUpdate: 'tool_call_update';
452
+ toolCallId: string;
453
+ fields: {
454
+ status?: string;
455
+ content?: unknown[];
456
+ rawOutput?: unknown;
457
+ };
458
+ _meta?: Record<string, unknown>;
459
+ } | {
460
+ sessionUpdate: 'current_mode_update';
461
+ currentModeId: AcpSessionModeId;
462
+ } | {
463
+ sessionUpdate: 'plan_update';
464
+ plan: unknown;
465
+ } | {
466
+ sessionUpdate: string;
467
+ [k: string]: unknown;
468
+ };
469
+ export interface AcpSessionNotification {
470
+ sessionId: string;
471
+ update: AcpSessionUpdate;
472
+ _meta?: Record<string, unknown>;
473
+ }
474
+ export type AcpPermissionOptionKind = 'allow_once' | 'allow_always' | 'reject_once' | 'reject_always';
475
+ export interface AcpPermissionOption {
476
+ optionId: string;
477
+ name: string;
478
+ kind: AcpPermissionOptionKind;
479
+ }
480
+ export interface AcpToolCallSummary {
481
+ toolCallId: string;
482
+ title?: string;
483
+ kind?: string;
484
+ status?: string;
485
+ content?: unknown[];
486
+ rawInput?: unknown;
487
+ rawOutput?: unknown;
488
+ }
489
+ export interface AcpRequestPermissionRequest {
490
+ sessionId: string;
491
+ toolCall: AcpToolCallSummary;
492
+ options: AcpPermissionOption[];
493
+ _meta?: Record<string, unknown>;
494
+ }
495
+ export type AcpRequestPermissionOutcome = {
496
+ outcome: 'cancelled';
497
+ } | {
498
+ outcome: 'selected';
499
+ optionId: string;
500
+ };
501
+ export interface AcpRequestPermissionResponse {
502
+ outcome: AcpRequestPermissionOutcome;
503
+ _meta?: Record<string, unknown>;
504
+ }
505
+ /** Wire envelope: pairs a `requestId` with the request body so the client
506
+ * reply can address the parked Rust-side oneshot. */
507
+ export interface AcpPermissionRequestEnvelope {
508
+ requestId: string;
509
+ request: AcpRequestPermissionRequest;
510
+ }
511
+ export interface AcpLoadSessionResponse {
512
+ /** Optional mode advertisement so the picker can hydrate without paying
513
+ * the cold-spawn cost of `newSession`. */
514
+ modes?: AcpSessionModes;
515
+ }
516
+ export interface AcpForkResult {
517
+ newThreadId: string;
518
+ sourceThreadId: string;
519
+ branchedFromTurn?: number;
520
+ }
521
+ export interface AcpForkOpts {
522
+ upToTurn?: number;
523
+ label?: string;
524
+ }
525
+ export type AcpNotifyKind = 'notification' | 'permissionRequest';
526
+ export interface AcpNotifyPayload {
527
+ threadId: string;
528
+ title: string;
529
+ body: string;
530
+ kind: AcpNotifyKind;
531
+ }
532
+ /**
533
+ * ACP-shaped engine adapter. Implementations:
534
+ * - `pkgs/engine-claude-code` — wraps the in-process Rust ACP server.
535
+ * - future: `pkgs/engine-codex`, `pkgs/engine-aider` — each speaking the
536
+ * same wire shapes.
537
+ *
538
+ * Method names mirror ACP verbatim (`newSession`, `prompt`, `cancel`,
539
+ * `setMode`, `loadSession`, `forkSession`, `respondPermission`) so the wire
540
+ * layer, adapter layer, and host shell share one vocabulary.
541
+ *
542
+ * Subscriptions return a synchronous `() => void` unsubscribe — the
543
+ * implementation may resolve the underlying tauri-listener asynchronously
544
+ * but the caller can drop the registration immediately on unmount.
545
+ */
546
+ export interface AcpEngine {
547
+ initialize(req: AcpInitializeRequest): Promise<AcpInitializeResponse>;
548
+ /** Mint a new session. The agent may lazily spawn its child on the first
549
+ * `prompt` rather than during `newSession` itself. */
550
+ newSession(req: AcpNewSessionRequest): Promise<AcpNewSessionResponse>;
551
+ /** Send a turn. Resolves when the turn ends; in-progress events flow via
552
+ * `onSessionUpdate`. */
553
+ prompt(req: AcpPromptRequest): Promise<AcpPromptResponse>;
554
+ /** Clean interrupt. Preserves the transcript and keeps the child alive
555
+ * for the next turn. */
556
+ cancel(sessionId: string): Promise<void>;
557
+ /** Switch the session's permission mode. */
558
+ setMode(sessionId: string, modeId: AcpSessionModeId): Promise<void>;
559
+ /** Re-attach to an existing session by id. The child stays lazy. */
560
+ loadSession(sessionId: string): Promise<AcpLoadSessionResponse>;
561
+ /** Clone a session from a chosen turn. The new thread inherits the source's
562
+ * on-disk transcript so the first prompt resumes from the cutoff. */
563
+ forkSession(sourceSessionId: string, opts?: AcpForkOpts): Promise<AcpForkResult>;
564
+ /** Subscribe to session updates. Returns a sync unsubscribe. */
565
+ onSessionUpdate(sessionId: string, callback: (update: AcpSessionUpdate) => void): () => void;
566
+ /** Subscribe to permission requests for this session. Reply via
567
+ * `respondPermission`. Returns a sync unsubscribe. */
568
+ onPermissionRequest(sessionId: string, callback: (envelope: AcpPermissionRequestEnvelope) => void): () => void;
569
+ /** Reply to a parked permission request. */
570
+ respondPermission(requestId: string, response: AcpRequestPermissionResponse): Promise<void>;
571
+ /** Subscribe to OS-attention notifications. Returns a sync unsubscribe. */
572
+ onNotify(callback: (payload: AcpNotifyPayload) => void): () => void;
573
+ }
574
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["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,CAAC,IAAI,CAAC,CAAC;IAEpE,oEAAoE;IACpE,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAEhE;0EACsE;IACtE,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAEjF,gEAAgE;IAChE,eAAe,CACb,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,GAC3C,MAAM,IAAI,CAAC;IAEd;2DACuD;IACvD,mBAAmB,CACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,QAAQ,EAAE,4BAA4B,KAAK,IAAI,GACzD,MAAM,IAAI,CAAC;IAEd,4CAA4C;IAC5C,iBAAiB,CACf,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,4BAA4B,GACrC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACrE"}
package/dist/engine.js ADDED
@@ -0,0 +1,85 @@
1
+ // Engine adapter contract. Implementations:
2
+ // - engine-claude-code (default, ships preinstalled)
3
+ // - engine-codex (future)
4
+ // - engine-aider (future)
5
+ // - engine-noop (testing / shell-without-AI mode)
6
+ import { z } from 'zod';
7
+ // ---------- Capabilities (single source of truth) ----------
8
+ /**
9
+ * Capability flags every engine adapter advertises. This is the canonical
10
+ * shape consumed by both the shell-side ChatAdapter layer and any pkg that
11
+ * needs to reason about adapter features (wizard, settings UI, telemetry).
12
+ *
13
+ * Fields are intentionally a *superset* of what any single adapter
14
+ * supports — an adapter sets the ones it implements to `true` and the
15
+ * rest to `false`. Adding a new flag is a non-breaking schema change so
16
+ * long as adapters default it to `false` until they implement it.
17
+ */
18
+ export const AgentCapabilitiesSchema = z.object({
19
+ /** Streams partial responses as they arrive (vs. all-at-once). */
20
+ streaming: z.boolean(),
21
+ /** Invokes external tools / function calls during a turn. */
22
+ toolUse: z.boolean(),
23
+ /** Emits an extended-thinking / reasoning channel separate from output. */
24
+ thinking: z.boolean(),
25
+ /** Produces structured artifacts (code blocks, files, images) the host renders. */
26
+ artifacts: z.boolean(),
27
+ /** Accepts file attachments as part of an input. */
28
+ fileAttachments: z.boolean(),
29
+ /** Accepts image input (vision). */
30
+ imageInput: z.boolean(),
31
+ /** Recognises a `/slash` command vocabulary. */
32
+ slashCommands: z.boolean(),
33
+ /** Lets the user switch models mid-thread. */
34
+ modelSwitching: z.boolean(),
35
+ /** Uses prompt-caching for repeated context (Anthropic-specific today). */
36
+ promptCaching: z.boolean(),
37
+ /** Runs agentic tools (recursive sub-agents, long-running loops). */
38
+ agenticTools: z.boolean(),
39
+ /** Speaks MCP — can register and route through MCP servers. */
40
+ mcp: z.boolean(),
41
+ /** Can resume a prior session by id. */
42
+ sessionResume: z.boolean(),
43
+ });
44
+ // ---------- Engine pkg manifest "engine" block ----------
45
+ /**
46
+ * Per-adapter onboarding requirements surfaced in the first-run wizard.
47
+ * The wizard composes these instead of hardcoding per-agent forms —
48
+ * every engine pkg owns its own setup story.
49
+ */
50
+ export const EngineOnboardingSchema = z.object({
51
+ /** Stronghold-vault keys this adapter needs at runtime (e.g. `ANTHROPIC_API_KEY`). */
52
+ requiredVaultKeys: z.array(z.string()).default([]),
53
+ /** Plain env-vars the adapter expects on the host shell. */
54
+ requiredEnvVars: z.array(z.string()).default([]),
55
+ /**
56
+ * CLI command the user can run to authenticate. The wizard surfaces this
57
+ * as a copy-to-clipboard hint — it never shells out on the user's behalf.
58
+ */
59
+ authCommand: z.string().optional(),
60
+ /** Docs URL for setting up this adapter. */
61
+ docsUrl: z.string().url().optional(),
62
+ });
63
+ /**
64
+ * Manifest block declared by engine-* pkgs. Read by the shell's
65
+ * `AdapterLoader` at pkg-discovery time; consumed by the wizard to compose
66
+ * adapter-specific onboarding hints.
67
+ */
68
+ export const EngineProvidesSchema = z.object({
69
+ /**
70
+ * Stable id — matches the detection-side agent id (e.g. `claude-code`,
71
+ * `codex`, `aider`, `noop`). The wizard's `selected_agent_id` is matched
72
+ * against this field at adapter-resolve time.
73
+ */
74
+ agentId: z.string().min(1),
75
+ /** Display name; overrides any detection-side display if both present. */
76
+ display: z.string().optional(),
77
+ /** Snapshot of what this adapter implements. */
78
+ capabilities: AgentCapabilitiesSchema,
79
+ /** Onboarding requirements composed by the wizard. */
80
+ onboarding: EngineOnboardingSchema.default({
81
+ requiredVaultKeys: [],
82
+ requiredEnvVars: [],
83
+ }),
84
+ });
85
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,wDAAwD;AACxD,mCAAmC;AACnC,mCAAmC;AACnC,4DAA4D;AAE5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA+BxB,8DAA8D;AAE9D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,kEAAkE;IAClE,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;IACtB,6DAA6D;IAC7D,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,2EAA2E;IAC3E,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,mFAAmF;IACnF,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;IACtB,oDAAoD;IACpD,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE;IAC5B,oCAAoC;IACpC,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE;IACvB,gDAAgD;IAChD,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE;IAC1B,8CAA8C;IAC9C,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE;IAC3B,2EAA2E;IAC3E,aAAa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