@otto-code/protocol 0.5.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 (102) hide show
  1. package/README.md +12 -0
  2. package/dist/agent-attention-notification.d.ts +41 -0
  3. package/dist/agent-attention-notification.js +140 -0
  4. package/dist/agent-labels.d.ts +7 -0
  5. package/dist/agent-labels.js +11 -0
  6. package/dist/agent-lifecycle.d.ts +3 -0
  7. package/dist/agent-lifecycle.js +8 -0
  8. package/dist/agent-personalities.d.ts +32 -0
  9. package/dist/agent-personalities.js +69 -0
  10. package/dist/agent-state-bucket.d.ts +14 -0
  11. package/dist/agent-state-bucket.js +41 -0
  12. package/dist/agent-title-limits.d.ts +2 -0
  13. package/dist/agent-title-limits.js +2 -0
  14. package/dist/agent-types.d.ts +479 -0
  15. package/dist/agent-types.js +22 -0
  16. package/dist/artifacts/rpc-schemas.d.ts +396 -0
  17. package/dist/artifacts/rpc-schemas.js +175 -0
  18. package/dist/artifacts/types.d.ts +166 -0
  19. package/dist/artifacts/types.js +73 -0
  20. package/dist/binary-frames/demux.d.ts +11 -0
  21. package/dist/binary-frames/demux.js +23 -0
  22. package/dist/binary-frames/file-transfer.d.ts +50 -0
  23. package/dist/binary-frames/file-transfer.js +107 -0
  24. package/dist/binary-frames/index.d.ts +4 -0
  25. package/dist/binary-frames/index.js +4 -0
  26. package/dist/binary-frames/terminal.d.ts +31 -0
  27. package/dist/binary-frames/terminal.js +99 -0
  28. package/dist/branch-slug.d.ts +14 -0
  29. package/dist/branch-slug.js +49 -0
  30. package/dist/browser-automation/capabilities.d.ts +7 -0
  31. package/dist/browser-automation/capabilities.js +31 -0
  32. package/dist/browser-automation/rpc-schemas.d.ts +1329 -0
  33. package/dist/browser-automation/rpc-schemas.js +555 -0
  34. package/dist/chat/rpc-schemas.d.ts +158 -0
  35. package/dist/chat/rpc-schemas.js +103 -0
  36. package/dist/chat/types.d.ts +30 -0
  37. package/dist/chat/types.js +22 -0
  38. package/dist/client-capabilities.d.ts +8 -0
  39. package/dist/client-capabilities.js +16 -0
  40. package/dist/connection-offer.d.ts +36 -0
  41. package/dist/connection-offer.js +53 -0
  42. package/dist/daemon-endpoints.d.ts +47 -0
  43. package/dist/daemon-endpoints.js +201 -0
  44. package/dist/default-personalities.d.ts +3 -0
  45. package/dist/default-personalities.js +127 -0
  46. package/dist/effort.d.ts +32 -0
  47. package/dist/effort.js +99 -0
  48. package/dist/error-utils.d.ts +11 -0
  49. package/dist/error-utils.js +27 -0
  50. package/dist/generated/validation/ws-outbound.aot.d.ts +2 -0
  51. package/dist/generated/validation/ws-outbound.aot.js +48755 -0
  52. package/dist/git-hosting.d.ts +21 -0
  53. package/dist/git-hosting.js +36 -0
  54. package/dist/git-remote.d.ts +18 -0
  55. package/dist/git-remote.js +84 -0
  56. package/dist/host-connection-schema.d.ts +11 -0
  57. package/dist/host-connection-schema.js +9 -0
  58. package/dist/literal-union.d.ts +2 -0
  59. package/dist/literal-union.js +2 -0
  60. package/dist/loop/rpc-schemas.d.ts +636 -0
  61. package/dist/loop/rpc-schemas.js +163 -0
  62. package/dist/messages.d.ts +38505 -0
  63. package/dist/messages.js +4719 -0
  64. package/dist/otto-config-schema.d.ts +136 -0
  65. package/dist/otto-config-schema.js +96 -0
  66. package/dist/path-utils.d.ts +2 -0
  67. package/dist/path-utils.js +16 -0
  68. package/dist/provider-config.d.ts +266 -0
  69. package/dist/provider-config.js +238 -0
  70. package/dist/provider-icon-names.d.ts +5 -0
  71. package/dist/provider-icon-names.js +52 -0
  72. package/dist/provider-manifest.d.ts +34 -0
  73. package/dist/provider-manifest.js +227 -0
  74. package/dist/schedule/cron-expression.d.ts +13 -0
  75. package/dist/schedule/cron-expression.js +97 -0
  76. package/dist/schedule/rpc-schemas.d.ts +667 -0
  77. package/dist/schedule/rpc-schemas.js +155 -0
  78. package/dist/schedule/types.d.ts +236 -0
  79. package/dist/schedule/types.js +84 -0
  80. package/dist/terminal-activity.d.ts +21 -0
  81. package/dist/terminal-activity.js +25 -0
  82. package/dist/terminal-input-mode.d.ts +26 -0
  83. package/dist/terminal-input-mode.js +151 -0
  84. package/dist/terminal-key-input.d.ts +13 -0
  85. package/dist/terminal-key-input.js +201 -0
  86. package/dist/terminal-profiles.d.ts +6 -0
  87. package/dist/terminal-profiles.js +28 -0
  88. package/dist/terminal-snapshot.d.ts +3 -0
  89. package/dist/terminal-snapshot.js +178 -0
  90. package/dist/terminal-stream-protocol.d.ts +2 -0
  91. package/dist/terminal-stream-protocol.js +2 -0
  92. package/dist/terminal-subscription-key.d.ts +2 -0
  93. package/dist/terminal-subscription-key.js +9 -0
  94. package/dist/tool-call-display.d.ts +11 -0
  95. package/dist/tool-call-display.js +135 -0
  96. package/dist/tool-name-normalization.d.ts +9 -0
  97. package/dist/tool-name-normalization.js +82 -0
  98. package/dist/validation/ws-outbound-schema-metadata.d.ts +7256 -0
  99. package/dist/validation/ws-outbound-schema-metadata.js +3 -0
  100. package/dist/validation/ws-outbound.d.ts +12 -0
  101. package/dist/validation/ws-outbound.js +8 -0
  102. package/package.json +42 -0
@@ -0,0 +1,479 @@
1
+ import type { AgentAttachment } from "./messages.js";
2
+ export type AgentProvider = string;
3
+ export interface AgentMetadata {
4
+ [key: string]: unknown;
5
+ }
6
+ export type AgentProviderNotice = {
7
+ type: "info";
8
+ message: string;
9
+ } | {
10
+ type: "warning";
11
+ message: string;
12
+ } | {
13
+ type: "error";
14
+ message: string;
15
+ };
16
+ /**
17
+ * Stdio-based MCP server (spawns a subprocess).
18
+ */
19
+ export interface McpStdioServerConfig {
20
+ type: "stdio";
21
+ command: string;
22
+ args?: string[];
23
+ env?: Record<string, string>;
24
+ /**
25
+ * When true, all tools from this server are always included in the prompt
26
+ * and never deferred behind tool search. Honored by the Claude provider.
27
+ */
28
+ alwaysLoad?: boolean;
29
+ }
30
+ /**
31
+ * HTTP-based MCP server.
32
+ */
33
+ export interface McpHttpServerConfig {
34
+ type: "http";
35
+ url: string;
36
+ headers?: Record<string, string>;
37
+ /**
38
+ * When true, all tools from this server are always included in the prompt
39
+ * and never deferred behind tool search. Honored by the Claude provider.
40
+ */
41
+ alwaysLoad?: boolean;
42
+ }
43
+ /**
44
+ * SSE-based MCP server (Server-Sent Events over HTTP).
45
+ */
46
+ export interface McpSseServerConfig {
47
+ type: "sse";
48
+ url: string;
49
+ headers?: Record<string, string>;
50
+ /**
51
+ * When true, all tools from this server are always included in the prompt
52
+ * and never deferred behind tool search. Honored by the Claude provider.
53
+ */
54
+ alwaysLoad?: boolean;
55
+ }
56
+ /**
57
+ * Canonical MCP server configuration.
58
+ * Discriminated union by `type` field.
59
+ * Each provider normalizes this to their expected format.
60
+ */
61
+ export type McpServerConfig = McpStdioServerConfig | McpHttpServerConfig | McpSseServerConfig;
62
+ export interface AgentMode {
63
+ id: string;
64
+ label: string;
65
+ description?: string;
66
+ icon?: string;
67
+ colorTier?: string;
68
+ }
69
+ export type ProviderStatus = "ready" | "loading" | "error" | "unavailable";
70
+ export interface AgentModelDefinition {
71
+ provider: AgentProvider;
72
+ id: string;
73
+ label: string;
74
+ description?: string;
75
+ isDefault?: boolean;
76
+ metadata?: AgentMetadata;
77
+ contextWindowMaxTokens?: number;
78
+ thinkingOptions?: AgentSelectOption[];
79
+ defaultThinkingOptionId?: string;
80
+ }
81
+ export interface AgentSelectOption {
82
+ id: string;
83
+ label: string;
84
+ description?: string;
85
+ isDefault?: boolean;
86
+ metadata?: AgentMetadata;
87
+ }
88
+ export declare function normalizeAgentModelDefinition(model: AgentModelDefinition): AgentModelDefinition;
89
+ export interface ProviderSnapshotEntry {
90
+ provider: AgentProvider;
91
+ status: ProviderStatus;
92
+ enabled: boolean;
93
+ error?: string;
94
+ models?: AgentModelDefinition[];
95
+ modes?: AgentMode[];
96
+ fetchedAt?: string;
97
+ label?: string;
98
+ description?: string;
99
+ defaultModeId?: string | null;
100
+ }
101
+ export interface AgentFeatureToggle {
102
+ type: "toggle";
103
+ id: string;
104
+ label: string;
105
+ description?: string;
106
+ tooltip?: string;
107
+ icon?: string;
108
+ value: boolean;
109
+ }
110
+ export interface AgentFeatureSelect {
111
+ type: "select";
112
+ id: string;
113
+ label: string;
114
+ description?: string;
115
+ tooltip?: string;
116
+ icon?: string;
117
+ value: string | null;
118
+ options: AgentSelectOption[];
119
+ }
120
+ export type AgentFeature = AgentFeatureToggle | AgentFeatureSelect;
121
+ export interface AgentCapabilityFlags {
122
+ [capability: string]: boolean | undefined;
123
+ supportsStreaming: boolean;
124
+ supportsSessionPersistence: boolean;
125
+ supportsSessionListing?: boolean;
126
+ supportsDynamicModes: boolean;
127
+ supportsMcpServers: boolean;
128
+ supportsReasoningStream: boolean;
129
+ supportsToolInvocations: boolean;
130
+ supportsRewindConversation?: boolean;
131
+ supportsRewindFiles?: boolean;
132
+ supportsRewindBoth?: boolean;
133
+ }
134
+ export interface AgentPersistenceHandle {
135
+ provider: AgentProvider;
136
+ sessionId: string;
137
+ /** Provider specific handle (Codex thread id, Claude resume token, etc). */
138
+ nativeHandle?: string;
139
+ metadata?: AgentMetadata;
140
+ }
141
+ export type AgentPromptContentBlock = {
142
+ type: "text";
143
+ text: string;
144
+ } | {
145
+ type: "image";
146
+ data: string;
147
+ mimeType: string;
148
+ } | AgentAttachment;
149
+ export type AgentPromptInput = string | AgentPromptContentBlock[];
150
+ export interface AgentRunOptions {
151
+ outputSchema?: unknown;
152
+ resumeFrom?: AgentPersistenceHandle;
153
+ maxThinkingTokens?: number;
154
+ }
155
+ export interface AgentUsage {
156
+ inputTokens?: number;
157
+ cachedInputTokens?: number;
158
+ outputTokens?: number;
159
+ totalCostUsd?: number;
160
+ contextWindowMaxTokens?: number;
161
+ contextWindowUsedTokens?: number;
162
+ }
163
+ export declare const TOOL_CALL_ICON_NAMES: readonly ["wrench", "square_terminal", "eye", "pencil", "search", "bot", "sparkles", "brain", "mic_vocal"];
164
+ export type ToolCallIconName = (typeof TOOL_CALL_ICON_NAMES)[number];
165
+ export type ToolCallDetail = {
166
+ type: "shell";
167
+ command: string;
168
+ cwd?: string;
169
+ output?: string;
170
+ exitCode?: number | null;
171
+ } | {
172
+ type: "read";
173
+ filePath: string;
174
+ content?: string;
175
+ offset?: number;
176
+ limit?: number;
177
+ } | {
178
+ type: "edit";
179
+ filePath: string;
180
+ oldString?: string;
181
+ newString?: string;
182
+ unifiedDiff?: string;
183
+ } | {
184
+ type: "write";
185
+ filePath: string;
186
+ content?: string;
187
+ } | {
188
+ type: "search";
189
+ query: string;
190
+ toolName?: "search" | "grep" | "glob" | "web_search";
191
+ content?: string;
192
+ filePaths?: string[];
193
+ webResults?: Array<{
194
+ title: string;
195
+ url: string;
196
+ }>;
197
+ annotations?: string[];
198
+ numFiles?: number;
199
+ numMatches?: number;
200
+ durationMs?: number;
201
+ durationSeconds?: number;
202
+ truncated?: boolean;
203
+ mode?: "content" | "files_with_matches" | "count";
204
+ } | {
205
+ type: "fetch";
206
+ url: string;
207
+ prompt?: string;
208
+ result?: string;
209
+ code?: number;
210
+ codeText?: string;
211
+ bytes?: number;
212
+ durationMs?: number;
213
+ } | {
214
+ type: "worktree_setup";
215
+ worktreePath: string;
216
+ branchName: string;
217
+ log: string;
218
+ commands: Array<{
219
+ index: number;
220
+ command: string;
221
+ cwd: string;
222
+ log: string;
223
+ status: "running" | "completed" | "failed";
224
+ exitCode: number | null;
225
+ durationMs?: number;
226
+ }>;
227
+ truncated?: boolean;
228
+ } | {
229
+ type: "sub_agent";
230
+ subAgentType?: string;
231
+ description?: string;
232
+ childSessionId?: string;
233
+ log: string;
234
+ actions?: Array<{
235
+ index: number;
236
+ toolName: string;
237
+ summary?: string;
238
+ }>;
239
+ } | {
240
+ type: "plain_text";
241
+ label?: string;
242
+ text?: string;
243
+ icon?: ToolCallIconName;
244
+ } | {
245
+ type: "plan";
246
+ text: string;
247
+ } | {
248
+ type: "unknown";
249
+ input: unknown;
250
+ output: unknown;
251
+ };
252
+ interface ToolCallBase {
253
+ [key: string]: unknown;
254
+ type: "tool_call";
255
+ callId: string;
256
+ name: string;
257
+ detail: ToolCallDetail;
258
+ metadata?: Record<string, unknown>;
259
+ }
260
+ type ToolCallRunningTimelineItem = ToolCallBase & {
261
+ status: "running";
262
+ error: null;
263
+ };
264
+ type ToolCallCompletedTimelineItem = ToolCallBase & {
265
+ status: "completed";
266
+ error: null;
267
+ };
268
+ type ToolCallFailedTimelineItem = ToolCallBase & {
269
+ status: "failed";
270
+ error: unknown;
271
+ };
272
+ type ToolCallCanceledTimelineItem = ToolCallBase & {
273
+ status: "canceled";
274
+ error: null;
275
+ };
276
+ export type ToolCallTimelineItem = ToolCallRunningTimelineItem | ToolCallCompletedTimelineItem | ToolCallFailedTimelineItem | ToolCallCanceledTimelineItem;
277
+ export interface CompactionTimelineItem {
278
+ [key: string]: unknown;
279
+ type: "compaction";
280
+ status: "loading" | "completed" | "failed";
281
+ trigger?: "auto" | "manual";
282
+ preTokens?: number;
283
+ postTokens?: number;
284
+ }
285
+ export type AgentTimelineItem = {
286
+ type: "user_message";
287
+ text: string;
288
+ messageId?: string;
289
+ } | {
290
+ type: "assistant_message";
291
+ text: string;
292
+ messageId?: string;
293
+ } | {
294
+ type: "reasoning";
295
+ text: string;
296
+ } | ToolCallTimelineItem | {
297
+ type: "todo";
298
+ items: {
299
+ text: string;
300
+ completed: boolean;
301
+ }[];
302
+ } | {
303
+ type: "error";
304
+ message: string;
305
+ } | CompactionTimelineItem;
306
+ export type AgentStreamEvent = {
307
+ type: "thread_started";
308
+ sessionId: string;
309
+ provider: AgentProvider;
310
+ } | {
311
+ type: "turn_started";
312
+ provider: AgentProvider;
313
+ turnId?: string;
314
+ } | {
315
+ type: "turn_completed";
316
+ provider: AgentProvider;
317
+ usage?: AgentUsage;
318
+ turnId?: string;
319
+ } | {
320
+ type: "usage_updated";
321
+ provider: AgentProvider;
322
+ usage: AgentUsage;
323
+ turnId?: string;
324
+ } | {
325
+ type: "mode_changed";
326
+ provider: AgentProvider;
327
+ currentModeId: string | null;
328
+ availableModes: AgentMode[];
329
+ } | {
330
+ type: "model_changed";
331
+ provider: AgentProvider;
332
+ runtimeInfo: AgentRuntimeInfo;
333
+ } | {
334
+ type: "thinking_option_changed";
335
+ provider: AgentProvider;
336
+ thinkingOptionId: string | null;
337
+ } | {
338
+ type: "turn_failed";
339
+ provider: AgentProvider;
340
+ error: string;
341
+ code?: string;
342
+ diagnostic?: string;
343
+ turnId?: string;
344
+ } | {
345
+ type: "turn_canceled";
346
+ provider: AgentProvider;
347
+ reason: string;
348
+ turnId?: string;
349
+ } | {
350
+ type: "timeline";
351
+ item: AgentTimelineItem;
352
+ provider: AgentProvider;
353
+ turnId?: string;
354
+ timestamp?: string;
355
+ } | {
356
+ type: "permission_requested";
357
+ provider: AgentProvider;
358
+ request: AgentPermissionRequest;
359
+ turnId?: string;
360
+ } | {
361
+ type: "permission_resolved";
362
+ provider: AgentProvider;
363
+ requestId: string;
364
+ resolution: AgentPermissionResponse;
365
+ turnId?: string;
366
+ } | {
367
+ type: "attention_required";
368
+ provider: AgentProvider;
369
+ reason: "finished" | "error" | "permission";
370
+ timestamp: string;
371
+ } | {
372
+ type: "observed_subagent_updated";
373
+ provider: AgentProvider;
374
+ update: ObservedSubagentUpdate;
375
+ } | {
376
+ type: "observed_subagent_timeline";
377
+ provider: AgentProvider;
378
+ key: string;
379
+ item: AgentTimelineItem;
380
+ turnId?: string;
381
+ timestamp?: string;
382
+ };
383
+ export declare function getAgentStreamEventTurnId(event: AgentStreamEvent): string | undefined;
384
+ /**
385
+ * A provider-managed subagent (Claude `Task` / ultracode fan-out) reported by a
386
+ * provider so the daemon can promote it to a read-only, separately-watchable
387
+ * "observed subagent". `key` is a provider-local stable identifier (Claude: the
388
+ * Task tool_use id); the daemon namespaces it under the owning agent. See
389
+ * projects/observed-subagents/observed-subagents.md.
390
+ */
391
+ export interface ObservedSubagentUpdate {
392
+ key: string;
393
+ /** Provider task id, used to stop the subagent (Claude: `task_id`). */
394
+ taskId?: string;
395
+ sessionId?: string | null;
396
+ subAgentType?: string;
397
+ description?: string;
398
+ status: "initializing" | "running" | "idle" | "error" | "closed";
399
+ requiresAttention?: boolean;
400
+ usage?: AgentUsage;
401
+ }
402
+ export type AgentPermissionRequestKind = "tool" | "plan" | "question" | "mode" | "other";
403
+ export type AgentPermissionUpdate = AgentMetadata;
404
+ export interface AgentPermissionAction {
405
+ id: string;
406
+ label: string;
407
+ behavior: "allow" | "deny";
408
+ variant?: "primary" | "secondary" | "danger";
409
+ intent?: "implement" | "implement_resume" | "dismiss";
410
+ }
411
+ export interface AgentPermissionRequest {
412
+ id: string;
413
+ provider: AgentProvider;
414
+ name: string;
415
+ kind: AgentPermissionRequestKind;
416
+ title?: string;
417
+ description?: string;
418
+ input?: AgentMetadata;
419
+ detail?: ToolCallDetail;
420
+ suggestions?: AgentPermissionUpdate[];
421
+ actions?: AgentPermissionAction[];
422
+ metadata?: AgentMetadata;
423
+ }
424
+ export type AgentPermissionResponse = {
425
+ behavior: "allow";
426
+ selectedActionId?: string;
427
+ updatedInput?: AgentMetadata;
428
+ updatedPermissions?: AgentPermissionUpdate[];
429
+ } | {
430
+ behavior: "deny";
431
+ selectedActionId?: string;
432
+ message?: string;
433
+ interrupt?: boolean;
434
+ };
435
+ export interface AgentRunResult {
436
+ sessionId: string;
437
+ finalText: string;
438
+ usage?: AgentUsage;
439
+ timeline: AgentTimelineItem[];
440
+ canceled?: boolean;
441
+ }
442
+ export interface AgentSessionConfig {
443
+ provider: AgentProvider;
444
+ cwd: string;
445
+ /**
446
+ * Provider-agnostic system/developer instruction string.
447
+ * Mapped by each provider to its native instruction field.
448
+ */
449
+ systemPrompt?: string;
450
+ modeId?: string;
451
+ model?: string;
452
+ thinkingOptionId?: string;
453
+ featureValues?: Record<string, unknown>;
454
+ title?: string | null;
455
+ approvalPolicy?: string;
456
+ sandboxMode?: string;
457
+ networkAccess?: boolean;
458
+ webSearch?: boolean;
459
+ extra?: {
460
+ codex?: AgentMetadata;
461
+ claude?: AgentMetadata;
462
+ };
463
+ mcpServers?: Record<string, McpServerConfig>;
464
+ /**
465
+ * Internal agents are hidden from listings and don't trigger notifications.
466
+ * They are used for ephemeral system tasks like commit/PR generation.
467
+ */
468
+ internal?: boolean;
469
+ }
470
+ export interface AgentRuntimeInfo {
471
+ provider: AgentProvider;
472
+ sessionId: string | null;
473
+ model?: string | null;
474
+ thinkingOptionId?: string | null;
475
+ modeId?: string | null;
476
+ extra?: AgentMetadata;
477
+ }
478
+ export {};
479
+ //# sourceMappingURL=agent-types.d.ts.map
@@ -0,0 +1,22 @@
1
+ export function normalizeAgentModelDefinition(model) {
2
+ const defaultThinkingOptionId = model.defaultThinkingOptionId ?? model.thinkingOptions?.find((option) => option.isDefault)?.id;
3
+ if (!defaultThinkingOptionId || defaultThinkingOptionId === model.defaultThinkingOptionId) {
4
+ return model;
5
+ }
6
+ return { ...model, defaultThinkingOptionId };
7
+ }
8
+ export const TOOL_CALL_ICON_NAMES = [
9
+ "wrench",
10
+ "square_terminal",
11
+ "eye",
12
+ "pencil",
13
+ "search",
14
+ "bot",
15
+ "sparkles",
16
+ "brain",
17
+ "mic_vocal",
18
+ ];
19
+ export function getAgentStreamEventTurnId(event) {
20
+ return "turnId" in event ? event.turnId : undefined;
21
+ }
22
+ //# sourceMappingURL=agent-types.js.map