@causyne/agent 1.10.21 → 1.11.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 (55) hide show
  1. package/native-skills/media/professional-document-publishing/SKILL.md +44 -0
  2. package/native-skills/media/screenplay-and-shotlist-forge/SKILL.md +42 -0
  3. package/package.json +1 -1
  4. package/src/acp/client.js +235 -0
  5. package/src/acp/client.ts +282 -0
  6. package/src/acp/peerProfiles.js +122 -0
  7. package/src/acp/peerProfiles.ts +128 -0
  8. package/src/acp/protocol.js +54 -0
  9. package/src/acp/protocol.ts +434 -0
  10. package/src/acp/server.js +609 -0
  11. package/src/acp/server.ts +676 -0
  12. package/src/agentLoop.d.ts +43 -0
  13. package/src/agentLoop.js +142 -8
  14. package/src/commands.js +203 -0
  15. package/src/compiledSkills.js +10 -0
  16. package/src/documentEngine/antiSlopAuditor.js +156 -0
  17. package/src/documentEngine/antiSlopAuditor.ts +221 -0
  18. package/src/documentEngine/documentForge.js +443 -0
  19. package/src/documentEngine/documentForge.ts +519 -0
  20. package/src/documentEngine/screenplayFormatter.js +336 -0
  21. package/src/documentEngine/screenplayFormatter.ts +407 -0
  22. package/src/entrypoint.js +13 -0
  23. package/src/execSafe.js +10 -13
  24. package/src/execSafe.ts +25 -0
  25. package/src/modelRouter.js +56 -123
  26. package/src/modelRouter.ts +134 -0
  27. package/src/observer/advisory.js +164 -0
  28. package/src/observer/advisory.ts +171 -0
  29. package/src/observer/coldObserver.js +462 -0
  30. package/src/observer/coldObserver.ts +540 -0
  31. package/src/observer/evidence.js +435 -0
  32. package/src/observer/evidence.ts +499 -0
  33. package/src/perception.js +303 -118
  34. package/src/perception.ts +387 -0
  35. package/src/procSignal.js +15 -16
  36. package/src/procSignal.ts +31 -0
  37. package/src/promptMentions.js +170 -0
  38. package/src/promptMentions.ts +212 -0
  39. package/src/sandbox.js +1 -1
  40. package/src/textDiff.js +117 -109
  41. package/src/textDiff.ts +169 -0
  42. package/src/toolPacks.js +5 -2
  43. package/src/tools/documentForge.js +215 -0
  44. package/src/tools/documentForge.ts +265 -0
  45. package/src/tools/peerAgent.js +102 -0
  46. package/src/tools/peerAgent.ts +116 -0
  47. package/src/tools/registry.js +3 -1
  48. package/src/tui/completion.js +97 -41
  49. package/src/tui/prompt.js +17 -17
  50. package/src/uncertainty.js +93 -205
  51. package/src/uncertainty.ts +255 -0
  52. package/src/utils/paths.js +15 -18
  53. package/src/utils/paths.ts +36 -0
  54. package/src/vfeTracker.js +122 -181
  55. package/src/vfeTracker.ts +242 -0
@@ -0,0 +1,434 @@
1
+ /**
2
+ * Agent Client Protocol (ACP) types for Causyne Agent.
3
+ *
4
+ * JSON-RPC 2.0 over stdio with newline-delimited framing. The shapes here
5
+ * follow the published ACP schema; the agent advertises only the capabilities
6
+ * it actually implements.
7
+ */
8
+
9
+ export const ACP_PROTOCOL_VERSION = 1;
10
+
11
+ export const ACP_METHODS = {
12
+ INITIALIZE: 'initialize',
13
+ NEW_SESSION: 'session/new',
14
+ PROMPT: 'session/prompt',
15
+ CANCEL: 'session/cancel',
16
+ UPDATE: 'session/update',
17
+ LOAD: 'session/load',
18
+ LIST: 'session/list',
19
+ CLOSE: 'session/close',
20
+ SET_MODE: 'session/set_mode',
21
+ REQUEST_PERMISSION: 'session/request_permission',
22
+ READ_TEXT_FILE: 'fs/read_text_file',
23
+ WRITE_TEXT_FILE: 'fs/write_text_file'
24
+ } as const;
25
+
26
+ export const ACP_ERROR_CODES = {
27
+ PARSE_ERROR: -32700,
28
+ INVALID_REQUEST: -32600,
29
+ METHOD_NOT_FOUND: -32601,
30
+ INVALID_PARAMS: -32602,
31
+ INTERNAL_ERROR: -32603,
32
+ AUTH_REQUIRED: -32000,
33
+ RESOURCE_NOT_FOUND: -32002,
34
+ REQUEST_CANCELLED: -32800
35
+ } as const;
36
+
37
+ export interface JsonRpcRequest<T = Record<string, unknown>> {
38
+ jsonrpc: '2.0';
39
+ id: string | number;
40
+ method: string;
41
+ params?: T;
42
+ }
43
+
44
+ export interface JsonRpcResponse<T = unknown> {
45
+ jsonrpc: '2.0';
46
+ id: string | number | null;
47
+ result?: T;
48
+ error?: JsonRpcError;
49
+ }
50
+
51
+ export interface JsonRpcNotification<T = Record<string, unknown>> {
52
+ jsonrpc: '2.0';
53
+ method: string;
54
+ params?: T;
55
+ }
56
+
57
+ export interface JsonRpcError {
58
+ code: number;
59
+ message: string;
60
+ data?: unknown;
61
+ }
62
+
63
+ export interface ContentBlockText {
64
+ type: 'text';
65
+ text: string;
66
+ annotations?: unknown;
67
+ }
68
+
69
+ export interface ContentBlockImage {
70
+ type: 'image';
71
+ mimeType: string;
72
+ data: string;
73
+ }
74
+
75
+ export interface ContentBlockAudio {
76
+ type: 'audio';
77
+ mimeType: string;
78
+ data: string;
79
+ }
80
+
81
+ export interface ContentBlockResourceLink {
82
+ type: 'resource_link';
83
+ uri: string;
84
+ name: string;
85
+ description?: string;
86
+ mimeType?: string;
87
+ size?: number;
88
+ title?: string;
89
+ }
90
+
91
+ export interface EmbeddedResource {
92
+ uri: string;
93
+ mimeType?: string;
94
+ text?: string;
95
+ blob?: string;
96
+ }
97
+
98
+ export interface ContentBlockResource {
99
+ type: 'resource';
100
+ resource: EmbeddedResource;
101
+ }
102
+
103
+ export type ContentBlock =
104
+ | ContentBlockText
105
+ | ContentBlockImage
106
+ | ContentBlockAudio
107
+ | ContentBlockResourceLink
108
+ | ContentBlockResource;
109
+
110
+ export interface ClientInfo {
111
+ name: string;
112
+ title?: string;
113
+ version?: string;
114
+ }
115
+
116
+ export interface FileSystemCapabilities {
117
+ readTextFile?: boolean;
118
+ writeTextFile?: boolean;
119
+ }
120
+
121
+ export interface SessionClientCapabilities {
122
+ notices?: boolean;
123
+ }
124
+
125
+ export interface ClientCapabilities {
126
+ fs?: FileSystemCapabilities;
127
+ terminal?: boolean;
128
+ session?: SessionClientCapabilities;
129
+ }
130
+
131
+ export interface InitializeRequest {
132
+ protocolVersion: number;
133
+ clientCapabilities?: ClientCapabilities;
134
+ clientInfo?: ClientInfo;
135
+ }
136
+
137
+ export interface PromptCapabilities {
138
+ image?: boolean;
139
+ audio?: boolean;
140
+ embeddedContext?: boolean;
141
+ }
142
+
143
+ export interface McpCapabilities {
144
+ http?: boolean;
145
+ sse?: boolean;
146
+ }
147
+
148
+ export interface SessionCapabilities {
149
+ list?: Record<string, never>;
150
+ delete?: Record<string, never>;
151
+ additionalDirectories?: Record<string, never>;
152
+ close?: Record<string, never>;
153
+ }
154
+
155
+ export interface AgentCapabilities {
156
+ loadSession?: boolean;
157
+ promptCapabilities?: PromptCapabilities;
158
+ mcpCapabilities?: McpCapabilities;
159
+ sessionCapabilities?: SessionCapabilities;
160
+ }
161
+
162
+ export interface AgentInfo {
163
+ name: string;
164
+ title?: string;
165
+ version: string;
166
+ }
167
+
168
+ export interface InitializeResult {
169
+ protocolVersion: number;
170
+ agentCapabilities: AgentCapabilities;
171
+ agentInfo?: AgentInfo;
172
+ authMethods?: unknown[];
173
+ }
174
+
175
+ export interface SessionMode {
176
+ id: string;
177
+ name: string;
178
+ description?: string;
179
+ }
180
+
181
+ export interface SessionModeState {
182
+ currentModeId: string;
183
+ availableModes: SessionMode[];
184
+ }
185
+
186
+ export interface McpServer {
187
+ name: string;
188
+ command?: string;
189
+ args?: string[];
190
+ env?: Array<{ name: string; value: string }> | Record<string, string>;
191
+ url?: string;
192
+ type?: string;
193
+ }
194
+
195
+ export interface NewSessionRequest {
196
+ cwd: string;
197
+ mcpServers: McpServer[];
198
+ additionalDirectories?: string[];
199
+ }
200
+
201
+ export interface NewSessionResponse {
202
+ sessionId: string;
203
+ modes?: SessionModeState;
204
+ }
205
+
206
+ export interface PromptRequest {
207
+ sessionId: string;
208
+ prompt: ContentBlock[];
209
+ messageId?: string;
210
+ }
211
+
212
+ export type StopReason = 'end_turn' | 'max_tokens' | 'max_turn_requests' | 'refusal' | 'cancelled';
213
+
214
+ export interface PromptResponse {
215
+ stopReason: StopReason;
216
+ }
217
+
218
+ export interface SetSessionModeRequest {
219
+ sessionId: string;
220
+ modeId: string;
221
+ }
222
+
223
+ export type SetSessionModeResponse = Record<string, never>;
224
+
225
+ export interface CancelNotification {
226
+ sessionId: string;
227
+ }
228
+
229
+ export interface ListSessionsRequest {
230
+ cwd?: string;
231
+ cursor?: string;
232
+ }
233
+
234
+ export interface SessionInfo {
235
+ sessionId: string;
236
+ cwd: string;
237
+ title?: string;
238
+ updatedAt?: string;
239
+ }
240
+
241
+ export interface ListSessionsResponse {
242
+ sessions: SessionInfo[];
243
+ nextCursor?: string;
244
+ }
245
+
246
+ export interface CloseSessionRequest {
247
+ sessionId: string;
248
+ }
249
+
250
+ export type CloseSessionResponse = Record<string, never>;
251
+
252
+ export type ToolCallStatus = 'pending' | 'in_progress' | 'completed' | 'failed';
253
+
254
+ export type ToolKind =
255
+ | 'read'
256
+ | 'edit'
257
+ | 'delete'
258
+ | 'move'
259
+ | 'search'
260
+ | 'execute'
261
+ | 'think'
262
+ | 'fetch'
263
+ | 'switch_mode'
264
+ | 'other';
265
+
266
+ export interface ToolCallContentBlock {
267
+ type: 'content';
268
+ content: ContentBlock;
269
+ }
270
+
271
+ export interface ToolCallContentDiff {
272
+ type: 'diff';
273
+ path: string;
274
+ oldText?: string | null;
275
+ newText: string;
276
+ }
277
+
278
+ export interface ToolCallContentTerminal {
279
+ type: 'terminal';
280
+ terminalId: string;
281
+ }
282
+
283
+ export type ToolCallContent = ToolCallContentBlock | ToolCallContentDiff | ToolCallContentTerminal;
284
+
285
+ export interface ToolCallLocation {
286
+ path: string;
287
+ line?: number;
288
+ }
289
+
290
+ export interface ToolCall {
291
+ toolCallId: string;
292
+ title: string;
293
+ kind?: ToolKind;
294
+ status?: ToolCallStatus;
295
+ content?: ToolCallContent[];
296
+ locations?: ToolCallLocation[];
297
+ rawInput?: unknown;
298
+ rawOutput?: unknown;
299
+ }
300
+
301
+ export interface AgentMessageChunkUpdate {
302
+ sessionUpdate: 'agent_message_chunk';
303
+ content: ContentBlock;
304
+ }
305
+
306
+ export interface AgentThoughtChunkUpdate {
307
+ sessionUpdate: 'agent_thought_chunk';
308
+ content: ContentBlock;
309
+ }
310
+
311
+ export interface UserMessageChunkUpdate {
312
+ sessionUpdate: 'user_message_chunk';
313
+ content: ContentBlock;
314
+ }
315
+
316
+ export interface ToolCallUpdateNotification {
317
+ sessionUpdate: 'tool_call';
318
+ toolCallId: string;
319
+ title: string;
320
+ kind?: ToolKind;
321
+ status?: ToolCallStatus;
322
+ content?: ToolCallContent[];
323
+ locations?: ToolCallLocation[];
324
+ rawInput?: unknown;
325
+ rawOutput?: unknown;
326
+ }
327
+
328
+ export interface ToolCallStatusUpdateNotification {
329
+ sessionUpdate: 'tool_call_update';
330
+ toolCallId: string;
331
+ title?: string;
332
+ kind?: ToolKind;
333
+ status?: ToolCallStatus;
334
+ content?: ToolCallContent[];
335
+ rawOutput?: unknown;
336
+ }
337
+
338
+ export interface PlanEntryUpdate {
339
+ content: string;
340
+ priority: 'high' | 'medium' | 'low';
341
+ status: 'pending' | 'in_progress' | 'completed';
342
+ }
343
+
344
+ export interface PlanUpdateNotification {
345
+ sessionUpdate: 'plan';
346
+ entries: PlanEntryUpdate[];
347
+ }
348
+
349
+ export interface CurrentModeUpdateNotification {
350
+ sessionUpdate: 'current_mode_update';
351
+ currentModeId: string;
352
+ }
353
+
354
+ export type SessionUpdate =
355
+ | AgentMessageChunkUpdate
356
+ | AgentThoughtChunkUpdate
357
+ | UserMessageChunkUpdate
358
+ | ToolCallUpdateNotification
359
+ | ToolCallStatusUpdateNotification
360
+ | PlanUpdateNotification
361
+ | CurrentModeUpdateNotification;
362
+
363
+ export interface SessionNotification {
364
+ sessionId: string;
365
+ update: SessionUpdate;
366
+ }
367
+
368
+ export type PermissionOptionKind = 'allow_once' | 'allow_always' | 'reject_once' | 'reject_always';
369
+
370
+ export interface PermissionOption {
371
+ optionId: string;
372
+ name: string;
373
+ kind: PermissionOptionKind;
374
+ }
375
+
376
+ export interface RequestPermissionRequest {
377
+ sessionId: string;
378
+ toolCall: ToolCall;
379
+ options: PermissionOption[];
380
+ }
381
+
382
+ export interface PermissionSelectedOutcome {
383
+ outcome: 'selected';
384
+ optionId: string;
385
+ }
386
+
387
+ export interface PermissionCancelledOutcome {
388
+ outcome: 'cancelled';
389
+ }
390
+
391
+ export type RequestPermissionResponse = {
392
+ outcome: PermissionSelectedOutcome | PermissionCancelledOutcome;
393
+ };
394
+
395
+ export interface ReadTextFileRequest {
396
+ sessionId: string;
397
+ path: string;
398
+ line?: number;
399
+ limit?: number;
400
+ }
401
+
402
+ export interface ReadTextFileResponse {
403
+ content: string;
404
+ }
405
+
406
+ export interface WriteTextFileRequest {
407
+ sessionId: string;
408
+ path: string;
409
+ content: string;
410
+ }
411
+
412
+ export type WriteTextFileResponse = Record<string, never>;
413
+
414
+ export function isJsonRpcRequest(value: unknown): value is JsonRpcRequest {
415
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) return false;
416
+ const record = value as Record<string, unknown>;
417
+ return record.jsonrpc === '2.0'
418
+ && (typeof record.id === 'string' || typeof record.id === 'number')
419
+ && typeof record.method === 'string';
420
+ }
421
+
422
+ export function isJsonRpcResponse(value: unknown): value is JsonRpcResponse {
423
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) return false;
424
+ const record = value as Record<string, unknown>;
425
+ return record.jsonrpc === '2.0'
426
+ && (typeof record.id === 'string' || typeof record.id === 'number' || record.id === null)
427
+ && ('result' in record || 'error' in record);
428
+ }
429
+
430
+ export function isJsonRpcNotification(value: unknown): value is JsonRpcNotification {
431
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) return false;
432
+ const record = value as Record<string, unknown>;
433
+ return record.jsonrpc === '2.0' && typeof record.method === 'string' && !('id' in record);
434
+ }