@otto-code/protocol 0.6.7 → 0.7.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.
package/dist/messages.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { TerminalActivitySchema } from "./terminal-activity.js";
3
- import { OrchestrationGraphSchema, RunSchema } from "./orchestration.js";
3
+ import { OrchestrationGraphSchema, PromptTemplateSchema, RunSchema } from "./orchestration.js";
4
4
  import { ArtifactMetadataSchema } from "./artifacts/types.js";
5
5
  import { ArtifactListRequestSchema, ArtifactCreateRequestSchema, ArtifactUpdateRequestSchema, ArtifactRegenerateRequestSchema, ArtifactCancelRequestSchema, ArtifactDeleteRequestSchema, ArtifactStarRequestSchema, ArtifactGetContentRequestSchema, ArtifactListResponseSchema, ArtifactCreateResponseSchema, ArtifactUpdateResponseSchema, ArtifactRegenerateResponseSchema, ArtifactCancelResponseSchema, ArtifactDeleteResponseSchema, ArtifactStarResponseSchema, ArtifactGetContentResponseSchema, ArtifactCreatedNotificationSchema, ArtifactUpdatedNotificationSchema, ArtifactDeletedNotificationSchema, } from "./artifacts/rpc-schemas.js";
6
6
  import { CLIENT_CAPS } from "./client-capabilities.js";
@@ -84,6 +84,53 @@ const MutableBrowserToolsConfigSchema = z
84
84
  enabled: z.boolean().default(false),
85
85
  })
86
86
  .passthrough();
87
+ /**
88
+ * Language-server code intelligence, host-scoped because the servers are processes
89
+ * on the daemon's machine — they follow the host, not the client.
90
+ *
91
+ * `enabled` defaults **on** and that is safe: nothing spawns until a
92
+ * code-intelligence action needs a language in a workspace, so an unused language
93
+ * costs nothing. What the switch guarantees is that off means off — no server
94
+ * spawns for any workspace, and the ctags index still serves the outline and the
95
+ * fuzzy finder.
96
+ *
97
+ * `languages` keys are registry row ids (`typescript`, `python`, `csharp`, …). An
98
+ * absent key means "use the row's own default", so a new row ships with its
99
+ * intended default rather than reading as disabled.
100
+ */
101
+ const MutableLspConfigSchema = z
102
+ .object({
103
+ enabled: z.boolean().default(true),
104
+ languages: z.record(z.string(), z.boolean()).default({}),
105
+ /** Hard LRU cap on simultaneously running servers, across all workspaces. */
106
+ maxRunningServers: z.number().int().positive().default(6),
107
+ idleMinutes: z.number().int().positive().default(10),
108
+ /** Shorter allowance for workspaces the user is not currently looking at. */
109
+ backgroundIdleMinutes: z.number().int().positive().default(2),
110
+ })
111
+ .passthrough();
112
+ /**
113
+ * "Microsoft .NET Solution Management" — the Solution view's own switch.
114
+ *
115
+ * **A sibling of `lsp`, not a member of it.** Turning C# code intelligence off does not turn
116
+ * this off and vice versa: they are independent capabilities that happen to share a language,
117
+ * and nesting this inside the LSP settings object would imply exactly the coupling that
118
+ * decision rejects. (It would also be wrong on the facts — LSP has no project-structure
119
+ * request, so nothing here rides on a language server.)
120
+ *
121
+ * Defaults **off**: the feature spawns a process and evaluates MSBuild. Disabled is genuinely
122
+ * off, not merely hidden — no discovery walk, no `.sln` read, no `.csproj` parse, no sidecar,
123
+ * no cache, no watcher, and no view switcher. The daemon reads this before scheduling any work,
124
+ * so a disabled feature costs exactly one boolean check.
125
+ */
126
+ const MutableDotnetSolutionConfigSchema = z
127
+ .object({
128
+ enabled: z.boolean().default(false),
129
+ /** Hard cap on simultaneously running sidecars, across all workspaces. */
130
+ maxRunningProbes: z.number().int().positive().default(2),
131
+ idleMinutes: z.number().int().positive().default(10),
132
+ })
133
+ .passthrough();
87
134
  // Speech engine ids and model ids stay plain strings on the wire so adding an
88
135
  // engine or model never breaks an older peer; the daemon validates values
89
136
  // against its own catalog when applying a patch.
@@ -244,6 +291,13 @@ export const AgentPersonalitySchema = z
244
291
  spinner: AgentPersonalitySpinnerSchema.optional(),
245
292
  voice: AgentPersonalityVoiceSchema.optional(),
246
293
  voiceCues: AgentPersonalityVoiceCuesSchema.optional(),
294
+ // Whether this personality accrues lessons across sessions (personality
295
+ // memory). ABSENT MEANS ON: a personality with no lessons injects nothing
296
+ // and costs nothing, so an off-by-default switch would only mean the feature
297
+ // never starts working for anyone who did not go looking for it. The switch
298
+ // exists to stop a personality accruing, not to start it.
299
+ // See docs/agent-personalities.md § Memory.
300
+ memoryEnabled: z.boolean().optional(),
247
301
  })
248
302
  .passthrough();
249
303
  const MutableAgentPersonalitiesConfigSchema = z
@@ -402,6 +456,24 @@ export const MutableDaemonConfigSchema = z
402
456
  // empty so a new client parsing an old daemon's config still sees a
403
457
  // well-formed array.
404
458
  savedProviderEndpoints: z.array(SavedProviderEndpointSchema).default([]),
459
+ // Language-server code intelligence. Gated by server_info features.lsp; the
460
+ // default section is well-formed so a new client parsing an old daemon's config
461
+ // still renders the screen.
462
+ lsp: MutableLspConfigSchema.default({
463
+ enabled: true,
464
+ languages: {},
465
+ maxRunningServers: 6,
466
+ idleMinutes: 10,
467
+ backgroundIdleMinutes: 2,
468
+ }),
469
+ // The Solution view's switch. Gated by server_info features.solutionView; the default
470
+ // section is well-formed and OFF, so a new client parsing an old daemon's config renders
471
+ // the row without ever implying the feature is running.
472
+ dotnetSolutionManagement: MutableDotnetSolutionConfigSchema.default({
473
+ enabled: false,
474
+ maxRunningProbes: 2,
475
+ idleMinutes: 10,
476
+ }),
405
477
  })
406
478
  .passthrough();
407
479
  export const MutableDaemonConfigPatchSchema = z
@@ -442,6 +514,11 @@ export const MutableDaemonConfigPatchSchema = z
442
514
  // Gated by server_info features.savedProviderEndpoints. Replaces the full
443
515
  // array (read-modify-write), so forgetting an endpoint drops it from disk.
444
516
  savedProviderEndpoints: z.array(SavedProviderEndpointSchema).optional(),
517
+ // Gated by server_info features.lsp; patches deep-merge, so a `languages`
518
+ // patch replaces only the keys it names.
519
+ lsp: MutableLspConfigSchema.partial().optional(),
520
+ // Gated by server_info features.solutionView; patches deep-merge.
521
+ dotnetSolutionManagement: MutableDotnetSolutionConfigSchema.partial().optional(),
445
522
  })
446
523
  .partial()
447
524
  .passthrough();
@@ -563,6 +640,14 @@ const ContextCompositionSchema = z.object({
563
640
  reasoning: z.number().optional(),
564
641
  subagentResults: z.number().optional(),
565
642
  });
643
+ // Declared above AgentUsageSchema on purpose: a schema referenced before its
644
+ // declaration is a build-time ReferenceError in the zod-aot output.
645
+ const AgentContextCategorySchema = z.object({
646
+ /** Provider-supplied display label, not translated and not an enum. */
647
+ name: z.string(),
648
+ tokens: z.number(),
649
+ isDeferred: z.boolean().optional(),
650
+ });
566
651
  const AgentUsageSchema = z.object({
567
652
  inputTokens: z.number().optional(),
568
653
  cachedInputTokens: z.number().optional(),
@@ -575,6 +660,10 @@ const AgentUsageSchema = z.object({
575
660
  // Provider-graded context breakdown for the visualizer ring/bar; absent ⇒
576
661
  // occupancy only (pre-composition behavior). See ContextComposition.
577
662
  contextComposition: ContextCompositionSchema.optional(),
663
+ // The provider's own labelled split — same accounting as
664
+ // `agent.context.get_usage`, pushed on the snapshot. Preferred over
665
+ // contextComposition; absent ⇒ fall back to the estimate, then to occupancy.
666
+ contextCategories: z.array(AgentContextCategorySchema).optional(),
578
667
  });
579
668
  const AgentSessionConfigSchema = z.object({
580
669
  provider: AgentProviderSchema,
@@ -919,6 +1008,52 @@ const AgentRuntimeInfoSchema = z.object({
919
1008
  modeId: z.string().nullable().optional(),
920
1009
  extra: z.record(z.string(), z.unknown()).optional(),
921
1010
  });
1011
+ /**
1012
+ * One message parked for delivery as an agent's NEXT turn (`delivery: "queue"`).
1013
+ * The daemon owns the queue; this is the read-only projection the Queue track
1014
+ * renders. Declared above AgentSnapshotPayloadSchema — zod-aot emits schemas in
1015
+ * source order, so a forward reference is a build-time ReferenceError.
1016
+ */
1017
+ export const QueuedAgentMessagePayloadSchema = z.object({
1018
+ id: z.string(),
1019
+ /** Leading text of the message, truncated for display. */
1020
+ preview: z.string(),
1021
+ enqueuedAt: z.string(),
1022
+ attachmentCount: z.number().int().nonnegative().optional(),
1023
+ });
1024
+ /**
1025
+ * An agent's LIFETIME SPEND, kept as the real token split plus the provider's
1026
+ * own cost — the raw material for "what did this chat cost".
1027
+ *
1028
+ * Deliberately distinct from context-window occupancy (`agent.context.get_usage`
1029
+ * and `lastUsage.contextWindow*`), which answers "how full am I" and shares no
1030
+ * units with this. Conflating the two is why the numbers used to feel wrong; the
1031
+ * UI must never mix them. See docs/glossary.md.
1032
+ *
1033
+ * `costUsd` is only ever a provider's OWN reported cost, already de-inflated so
1034
+ * a parent never carries what its sub-agents reported. It is NEVER derived from
1035
+ * a $/M rate table — a rate keyed off a model id misprices a gateway serving
1036
+ * that model at its own prices (docs/subagent-accounting.md, pricing invariant).
1037
+ * `costCoverage` says how far it can be trusted, so a surface can show a floor
1038
+ * or an honest blank rather than a confident wrong figure.
1039
+ *
1040
+ * Declared above AgentSnapshotPayloadSchema — zod-aot emits schemas in source
1041
+ * order, so a forward reference is a build-time ReferenceError.
1042
+ */
1043
+ export const AgentCumulativeUsageSchema = z.object({
1044
+ inputTokens: z.number().optional(),
1045
+ cachedInputTokens: z.number().optional(),
1046
+ cacheCreationInputTokens: z.number().optional(),
1047
+ outputTokens: z.number().optional(),
1048
+ /** Provider-reported cost booked so far. Absent ⇒ nothing was priceable. */
1049
+ costUsd: z.number().optional(),
1050
+ /**
1051
+ * `complete` — every token-bearing turn was priced; `costUsd` is the total.
1052
+ * `partial` — some turns were unpriced; `costUsd` is a FLOOR, present it as
1053
+ * one. `none` — nothing priceable; show tokens and a blank, never an estimate.
1054
+ */
1055
+ costCoverage: z.enum(["complete", "partial", "none"]).optional(),
1056
+ });
922
1057
  export const AgentSnapshotPayloadSchema = z.object({
923
1058
  id: z.string(),
924
1059
  provider: AgentProviderSchema,
@@ -946,6 +1081,30 @@ export const AgentSnapshotPayloadSchema = z.object({
946
1081
  // additive; absent ⇒ no readout. Old clients ignore it.
947
1082
  // See docs/agent-lifecycle.md (Item 3).
948
1083
  cumulativeTokens: z.number().optional(),
1084
+ // The same lifetime spend as `cumulativeTokens`, but as the REAL split plus
1085
+ // the provider's own cost, so a chat total can be priced honestly instead of
1086
+ // flattened to one scalar and multiplied by a guessed rate. Its token leaves
1087
+ // sum to `cumulativeTokens`; a client that ignores this loses only the split
1088
+ // and the cost. Absent ⇒ the daemon predates the field or reported nothing.
1089
+ // COMPAT(cumulativeUsage): added in v0.7.0; gated on
1090
+ // server_info.features.cumulativeUsage, drop the gate when floor >= v0.7.0.
1091
+ // See docs/subagent-accounting.md (Chat totals).
1092
+ cumulativeUsage: AgentCumulativeUsageSchema.optional(),
1093
+ // Liveness signals for the sub-agents track: how much work this agent has done
1094
+ // (`toolUseCount`, cumulative and monotonic) and what it is doing right now
1095
+ // (`currentTool`, the latest tool name, cleared once the agent is terminal —
1096
+ // a finished agent isn't "running Bash"). Both are purely additive optional
1097
+ // leaves: a provider that can't report them leaves them absent and the row
1098
+ // omits the readout rather than showing a wrong value.
1099
+ // COMPAT(subagentLiveness): added in v0.6.7; old clients ignore both.
1100
+ // See docs/chat-lifecycle.md (the subagents track).
1101
+ toolUseCount: z.number().optional(),
1102
+ currentTool: z.string().optional(),
1103
+ // Messages parked for delivery as this agent's NEXT turn (delivery: "queue").
1104
+ // Daemon-owned and ephemeral — the composer's Queue track renders straight
1105
+ // from this. Absent/empty ⇒ nothing queued; old clients ignore it.
1106
+ // COMPAT(steerQueue): added in v0.6.8, drop the gate when floor >= v0.6.8.
1107
+ queuedMessages: z.array(QueuedAgentMessagePayloadSchema).optional(),
949
1108
  lastError: z.string().optional(),
950
1109
  title: z.string().nullable(),
951
1110
  labels: z.record(z.string(), z.string()).default({}),
@@ -1046,6 +1205,45 @@ export const CloseItemsRequestMessageSchema = z.object({
1046
1205
  terminalIds: z.array(z.string()).default([]),
1047
1206
  requestId: z.string(),
1048
1207
  });
1208
+ // ── History management ──────────────────────────────────────────────────────
1209
+ // Bulk counterpart to the existing flat `delete_agent_request`: hard-delete
1210
+ // every archived chat record at or past a cutoff in one server-side pass. It has
1211
+ // to be server-side because the history list is cursor-paginated across hosts,
1212
+ // so the client never holds the whole archived set.
1213
+ //
1214
+ // Deleting a chat removes OTTO's record only. The provider's own on-disk
1215
+ // transcript (Claude's `~/.claude/projects/**/<sessionId>.jsonl`, Codex threads,
1216
+ // OpenCode sessions) is deliberately left in place: Otto never created it,
1217
+ // another tool still reads it, and silently deleting another tool's state is not
1218
+ // ours to do. There is intentionally **no** opt-in flag for provider data on the
1219
+ // wire — the UI discloses what stays behind instead. See docs/chat-lifecycle.md.
1220
+ // Gated by server_info.features.historyDelete.
1221
+ export const HistoryAgentsClearArchivedRequestSchema = z.object({
1222
+ type: z.literal("history.agents.clear_archived.request"),
1223
+ // 0 = every archived chat. N = only chats archived at least N days ago.
1224
+ olderThanDays: z.number().int().min(0).default(0),
1225
+ // Safe by default: a request that omits the flag previews instead of deleting.
1226
+ // The client always sends it explicitly.
1227
+ dryRun: z.boolean().default(true),
1228
+ requestId: z.string(),
1229
+ });
1230
+ export const HistoryAgentsClearArchivedResponseSchema = z.object({
1231
+ type: z.literal("history.agents.clear_archived.response"),
1232
+ payload: z.object({
1233
+ // How many archived records the cutoff selected — the number the confirm
1234
+ // dialog quotes back after a dry run.
1235
+ matched: z.number().int().nonnegative(),
1236
+ deleted: z.number().int().nonnegative(),
1237
+ failed: z.number().int().nonnegative(),
1238
+ // Ids actually deleted, so the client drops exactly those rows from its
1239
+ // caches. Empty on a dry run. Unlike close_items_response, a destructive
1240
+ // batch reports per-item outcome rather than silently omitting failures.
1241
+ agentIds: z.array(z.string()),
1242
+ dryRun: z.boolean(),
1243
+ error: z.string().nullable(),
1244
+ requestId: z.string(),
1245
+ }),
1246
+ });
1049
1247
  export const UpdateAgentRequestMessageSchema = z.object({
1050
1248
  type: z.literal("update_agent_request"),
1051
1249
  agentId: z.string(),
@@ -1326,6 +1524,47 @@ export const SendAgentMessageRequestSchema = z.object({
1326
1524
  messageId: z.string().optional(), // Client-provided ID for deduplication
1327
1525
  images: z.array(ImageAttachmentSchema).optional(),
1328
1526
  attachments: AgentAttachmentsSchema,
1527
+ // How to reach a BUSY agent. "interrupt" (default, and what every older
1528
+ // client means by omitting this) cancels the in-flight turn and runs this
1529
+ // instead; "queue" lets the turn finish and runs this as the next one.
1530
+ // Against an idle agent both run immediately.
1531
+ // COMPAT(steerQueue): added in v0.6.8, drop the gate when floor >= v0.6.8.
1532
+ delivery: z.enum(["interrupt", "queue"]).optional(),
1533
+ });
1534
+ /** Pull one message back out of an agent's queue (Queue-track edit / send now). */
1535
+ export const AgentQueueRemoveRequestMessageSchema = z.object({
1536
+ type: z.literal("agent.queue.remove.request"),
1537
+ requestId: z.string(),
1538
+ /** Accepts full ID, unique prefix, or exact full title (server resolves). */
1539
+ agentId: z.string(),
1540
+ /** The queued message's `id` from `AgentSnapshotPayload.queuedMessages`. */
1541
+ messageId: z.string(),
1542
+ });
1543
+ /**
1544
+ * Move one queued message to a different position in an agent's queue.
1545
+ *
1546
+ * Order is what the queue means, so this is the edit that changes the next
1547
+ * turn's content without changing the queue's membership. The daemon resolves
1548
+ * `messageId` fresh and clamps `toIndex`, so a client acting on a snapshot that
1549
+ * is one drain stale reorders what is actually there or reports `moved: false`.
1550
+ * COMPAT(steerQueueReorder): added in v0.6.9, drop the gate when floor >= v0.6.9.
1551
+ */
1552
+ export const AgentQueueReorderRequestMessageSchema = z.object({
1553
+ type: z.literal("agent.queue.reorder.request"),
1554
+ requestId: z.string(),
1555
+ /** Accepts full ID, unique prefix, or exact full title (server resolves). */
1556
+ agentId: z.string(),
1557
+ /** The queued message's `id` from `AgentSnapshotPayload.queuedMessages`. */
1558
+ messageId: z.string(),
1559
+ /** Zero-based destination, clamped to the queue's current length. */
1560
+ toIndex: z.number().int().nonnegative(),
1561
+ });
1562
+ /** Drop every message queued behind an agent's current turn. */
1563
+ export const AgentQueueClearRequestMessageSchema = z.object({
1564
+ type: z.literal("agent.queue.clear.request"),
1565
+ requestId: z.string(),
1566
+ /** Accepts full ID, unique prefix, or exact full title (server resolves). */
1567
+ agentId: z.string(),
1329
1568
  });
1330
1569
  export const WaitForFinishRequestSchema = z.object({
1331
1570
  type: z.literal("wait_for_finish_request"),
@@ -1926,7 +2165,7 @@ export const SuggestedTasksChangedSchema = z.object({
1926
2165
  }),
1927
2166
  });
1928
2167
  // Context Management — the daemon's accounting of everything a provider sends
1929
- // before the user types (see projects/context-management/context-management.md).
2168
+ // before the user types (see docs/context-management.md).
1930
2169
  //
1931
2170
  // Two distinctions carry the whole feature and must not be collapsed on the
1932
2171
  // wire: an `import` edge is inlined into the request while a `reference` edge
@@ -1977,8 +2216,8 @@ export const ContextFindingSchema = z.object({
1977
2216
  relatedNodeIds: z.array(z.string()).optional(),
1978
2217
  // The node this finding is about. Redundant while the finding sits on its
1979
2218
  // node, load-bearing once the report flattens them all into one list — that
1980
- // list is the "Worth fixing" tab, and without this a row cannot say where it
1981
- // came from or take you there.
2219
+ // list is the "Issues" tab, and without this a row cannot say where it came
2220
+ // from or take you there.
1982
2221
  nodeId: z.string().optional(),
1983
2222
  // 1-based line of `range.start` in that node's file, so the fix list can jump
1984
2223
  // the editor without the client re-reading bytes to count newlines.
@@ -1986,6 +2225,16 @@ export const ContextFindingSchema = z.object({
1986
2225
  // Last line of the range, so the client can select the whole offending span
1987
2226
  // rather than dropping a cursor at the top of it.
1988
2227
  lineEnd: z.number().optional(),
2228
+ // True for kinds a mechanical delete can resolve on its own (dead links, a
2229
+ // duplicate block) — false/absent for kinds that need judgment (which side
2230
+ // of an import cycle to cut, how to split an oversized entry). Computed
2231
+ // server-side, once, in `locateFinding` — the only place that knows the kind
2232
+ // vocabulary, so the fix-all button never has to guess.
2233
+ fixable: z.boolean().optional(),
2234
+ // The exact text at `range` when the file was scanned. `context.findings.fix`
2235
+ // verifies this still matches before deleting, the same staleness guard
2236
+ // `context.edge.convert` uses for `rawTarget`.
2237
+ snippet: z.string().optional(),
1989
2238
  });
1990
2239
  export const ContextNodeSchema = z.object({
1991
2240
  id: z.string(),
@@ -2036,6 +2285,16 @@ export const ContextReportSchema = z.object({
2036
2285
  workingRoom: z.number(),
2037
2286
  aggregateSeverity: ContextSeveritySchema,
2038
2287
  findings: z.array(ContextFindingSchema),
2288
+ // Which personality this report was evaluated FOR. Context became
2289
+ // personality-specific once personalities accrue memory, so a report is only
2290
+ // interpretable alongside the identity it was measured against.
2291
+ // COMPAT(personalityMemory): additive; absent = the pre-memory, personality-agnostic report.
2292
+ personalityId: z.string().optional(),
2293
+ // That personality's injected memory brief, in tokens. Folded into the
2294
+ // `otto_injected` category total rather than a new category: ContextCategory
2295
+ // is a z.enum travelling daemon->client, so a new member would make a new
2296
+ // daemon's report unparseable by an older client.
2297
+ personalityMemoryTokens: z.number().optional(),
2039
2298
  });
2040
2299
  // Pushed with the full current report whenever a watched context file changes.
2041
2300
  // Full-report reconciliation, same idiom as suggested_tasks_changed.
@@ -2054,6 +2313,10 @@ export const ContextReportGetRequestMessageSchema = z.object({
2054
2313
  workspaceId: z.string(),
2055
2314
  provider: z.string().optional(),
2056
2315
  windowTokens: z.number().optional(),
2316
+ // "Evaluate as if this personality were running here": folds that
2317
+ // personality's injected memory brief into the report's fixed weight. Omitted
2318
+ // means the personality-agnostic report.
2319
+ personalityId: z.string().optional(),
2057
2320
  });
2058
2321
  export const ContextReportGetResponseMessageSchema = z.object({
2059
2322
  type: z.literal("context.report.get.response"),
@@ -2083,6 +2346,154 @@ export const ContextEdgeConvertResponseMessageSchema = z.object({
2083
2346
  error: z.string().optional(),
2084
2347
  }),
2085
2348
  });
2349
+ // Deletes every mechanically-fixable finding's range in one pass — the
2350
+ // "Fix all" button in the Issues tab. Each item names the file, the range the
2351
+ // scan flagged, and the snippet expected there; a file that changed since the
2352
+ // scan is skipped rather than corrupted (charter §7.5).
2353
+ export const ContextFindingsFixRequestMessageSchema = z.object({
2354
+ type: z.literal("context.findings.fix.request"),
2355
+ requestId: z.string(),
2356
+ workspaceId: z.string(),
2357
+ findings: z.array(z.object({
2358
+ filePath: z.string(),
2359
+ range: ContextRangeSchema,
2360
+ snippet: z.string(),
2361
+ })),
2362
+ });
2363
+ export const ContextFindingsFixResponseMessageSchema = z.object({
2364
+ type: z.literal("context.findings.fix.response"),
2365
+ payload: z.object({
2366
+ requestId: z.string(),
2367
+ fixedCount: z.number(),
2368
+ failedCount: z.number(),
2369
+ errors: z.array(z.string()),
2370
+ }),
2371
+ });
2372
+ // ---------------------------------------------------------------------------
2373
+ // Personality memory — the lessons a named personality accrues across sessions.
2374
+ // See docs/agent-personalities.md § Memory.
2375
+ // ---------------------------------------------------------------------------
2376
+ // Plain strings on the wire, like personality roles and effort levels, so the
2377
+ // daemon can grow the vocabulary without breaking old peers. Logical values:
2378
+ // scope "project" | "global"; source "agent" | "user" | "review" | "transfer".
2379
+ export const PersonalityMemoryEntrySchema = z
2380
+ .object({
2381
+ id: z.string(),
2382
+ text: z.string(),
2383
+ scope: z.string(),
2384
+ // Absolute, daemon-side. Present only on project-scoped entries.
2385
+ projectRoot: z.string().optional(),
2386
+ createdAt: z.string(),
2387
+ updatedAt: z.string(),
2388
+ source: z.string(),
2389
+ // How many times the lesson has been restated. Drives injection order and
2390
+ // is shown in the brief, because a repeatedly-relearned gotcha is stronger
2391
+ // evidence than a one-off observation.
2392
+ reinforcedCount: z.number().optional(),
2393
+ transferredFrom: z.string().optional(),
2394
+ })
2395
+ .passthrough();
2396
+ export const PersonalityMemoryListRequestMessageSchema = z.object({
2397
+ type: z.literal("personality.memory.list.request"),
2398
+ requestId: z.string(),
2399
+ personalityId: z.string(),
2400
+ // Which project's lessons count as in-scope for the returned brief. Prefer
2401
+ // `workspaceId` and let the daemon resolve the root: a client computing repo
2402
+ // roots would disagree with the daemon the moment a worktree is involved.
2403
+ workspaceId: z.string().optional(),
2404
+ // Explicit root, for callers with no workspace. Ignored when `workspaceId`
2405
+ // resolves. Omitted (with no workspace) means global lessons only.
2406
+ projectRoot: z.string().optional(),
2407
+ });
2408
+ export const PersonalityMemoryListResponseMessageSchema = z.object({
2409
+ type: z.literal("personality.memory.list.response"),
2410
+ payload: z.object({
2411
+ requestId: z.string(),
2412
+ personalityId: z.string(),
2413
+ personalityName: z.string(),
2414
+ /** Whether this personality is accruing (the `memoryEnabled` switch). */
2415
+ enabled: z.boolean(),
2416
+ /** Every stored entry, including other projects' — the UI shows them all. */
2417
+ entries: z.array(PersonalityMemoryEntrySchema),
2418
+ // The EXACT text the daemon would inject for `projectRoot`, not a
2419
+ // reconstruction. Memory is only trustworthy if it is inspectable, and the
2420
+ // only way the shown text cannot drift from the injected text is for both
2421
+ // to come from one composer.
2422
+ brief: z.string(),
2423
+ briefTokens: z.number(),
2424
+ /** Entries the injection budget cut, so the UI can say so. */
2425
+ briefOmittedCount: z.number().optional(),
2426
+ // The root the brief was composed for, so the UI can tell a project-scoped
2427
+ // entry that applies here from one belonging to another project. Without it
2428
+ // every project entry looks the same and an empty brief next to a list of
2429
+ // lessons reads as a bug. Absent when the request named no workspace.
2430
+ projectRoot: z.string().optional(),
2431
+ }),
2432
+ });
2433
+ // One write RPC covers add / edit / delete: no `entryId` = add a new lesson,
2434
+ // `drop: true` = forget one. The user-facing editing path from Context
2435
+ // Management (charter §2.4).
2436
+ export const PersonalityMemoryUpdateRequestMessageSchema = z.object({
2437
+ type: z.literal("personality.memory.update.request"),
2438
+ requestId: z.string(),
2439
+ personalityId: z.string(),
2440
+ entryId: z.string().optional(),
2441
+ text: z.string().optional(),
2442
+ scope: z.string().optional(),
2443
+ // Which project a `scope: "project"` write binds to. Same rule as the list
2444
+ // request: prefer `workspaceId` and let the daemon resolve the root, because a
2445
+ // project-scoped entry whose root does not match the daemon's resolution is
2446
+ // filtered out of every brief and is therefore stored but never sent.
2447
+ workspaceId: z.string().optional(),
2448
+ // Explicit root, for callers with no workspace. Ignored when `workspaceId`
2449
+ // resolves.
2450
+ projectRoot: z.string().optional(),
2451
+ drop: z.boolean().optional(),
2452
+ });
2453
+ export const PersonalityMemoryUpdateResponseMessageSchema = z.object({
2454
+ type: z.literal("personality.memory.update.response"),
2455
+ payload: z.object({
2456
+ requestId: z.string(),
2457
+ ok: z.boolean(),
2458
+ error: z.string().optional(),
2459
+ }),
2460
+ });
2461
+ // Deleting a personality must never silently destroy what it learned, so the
2462
+ // delete flow resolves here first: `mode: "transfer"` moves the lessons to
2463
+ // `toPersonalityId` (merging near-duplicates), `mode: "delete"` discards them.
2464
+ export const PersonalityMemoryTransferRequestMessageSchema = z.object({
2465
+ type: z.literal("personality.memory.transfer.request"),
2466
+ requestId: z.string(),
2467
+ fromPersonalityId: z.string(),
2468
+ toPersonalityId: z.string().optional(),
2469
+ mode: z.string(),
2470
+ });
2471
+ export const PersonalityMemoryTransferResponseMessageSchema = z.object({
2472
+ type: z.literal("personality.memory.transfer.response"),
2473
+ payload: z.object({
2474
+ requestId: z.string(),
2475
+ ok: z.boolean(),
2476
+ /** Entries that landed as new rows in the destination. */
2477
+ transferred: z.number().optional(),
2478
+ /** Entries that merged into a lesson the destination already knew. */
2479
+ merged: z.number().optional(),
2480
+ error: z.string().optional(),
2481
+ }),
2482
+ });
2483
+ // Per-personality lesson counts. Its own RPC over its own file, mirroring
2484
+ // agentPersonalities.get_stats — counts must not ride the daemon-config
2485
+ // broadcast, or every recorded lesson would fan a config change to every client.
2486
+ export const PersonalityMemoryStatsRequestMessageSchema = z.object({
2487
+ type: z.literal("personality.memory.stats.request"),
2488
+ requestId: z.string(),
2489
+ });
2490
+ export const PersonalityMemoryStatsResponseMessageSchema = z.object({
2491
+ type: z.literal("personality.memory.stats.response"),
2492
+ payload: z.object({
2493
+ requestId: z.string(),
2494
+ counts: z.record(z.string(), z.number()),
2495
+ }),
2496
+ });
2086
2497
  // Aggregate outcome for a start/dismiss over one or more tasks. `succeeded`/
2087
2498
  // `failed` count the tasks acted on so the client can report "Started 3 tasks";
2088
2499
  // `error` collects any per-task failure messages (the failed tasks' chips stay).
@@ -2397,8 +2808,27 @@ export const RunsClearResponseSchema = z.object({
2397
2808
  requestId: z.string(),
2398
2809
  }),
2399
2810
  });
2811
+ // Delete one run by id. Terminal (done/failed/canceled) and draft runs only —
2812
+ // deleting an active run is refused so a cleanup click can't silently orphan
2813
+ // running agents; cancel it first. Gated by server_info.features.runsDelete.
2814
+ export const RunsDeleteRequestSchema = z.object({
2815
+ type: z.literal("runs.delete.request"),
2816
+ requestId: z.string(),
2817
+ runId: z.string(),
2818
+ });
2819
+ export const RunsDeleteResponseSchema = z.object({
2820
+ type: z.literal("runs.delete.response"),
2821
+ payload: z.object({
2822
+ // The deleted id, or absent when nothing was deleted (unknown or still
2823
+ // active) — `error` then carries why.
2824
+ runId: z.string().optional(),
2825
+ error: z.string().optional(),
2826
+ requestId: z.string(),
2827
+ }),
2828
+ });
2400
2829
  // Broadcast to every connected client (including the requester) so all
2401
2830
  // caches drop the same runs, mirroring runs.updated.notification's upsert.
2831
+ // Serves both runs.clear (many ids) and runs.delete (one).
2402
2832
  export const RunsClearedNotificationSchema = z.object({
2403
2833
  type: z.literal("runs.cleared.notification"),
2404
2834
  payload: z.object({
@@ -2457,12 +2887,60 @@ export const RunsGraphsChangedNotificationSchema = z.object({
2457
2887
  graphs: z.array(OrchestrationGraphSchema),
2458
2888
  }),
2459
2889
  });
2890
+ // ── Prompt templates ────────────────────────────────────────────────────────
2891
+ // Host-level reusable prompts and snippets a graph node can bind to. Same shape
2892
+ // as the graph trio above, for the same reason: one store, list/save/delete,
2893
+ // plus a full-list push so every client converges.
2894
+ export const RunsTemplatesListRequestSchema = z.object({
2895
+ type: z.literal("runs.templates.list.request"),
2896
+ requestId: z.string(),
2897
+ });
2898
+ export const RunsTemplatesListResponseSchema = z.object({
2899
+ type: z.literal("runs.templates.list.response"),
2900
+ payload: z.object({
2901
+ templates: z.array(PromptTemplateSchema),
2902
+ requestId: z.string(),
2903
+ }),
2904
+ });
2905
+ export const RunsTemplatesSaveRequestSchema = z.object({
2906
+ type: z.literal("runs.templates.save.request"),
2907
+ template: PromptTemplateSchema,
2908
+ requestId: z.string(),
2909
+ });
2910
+ export const RunsTemplatesSaveResponseSchema = z.object({
2911
+ type: z.literal("runs.templates.save.response"),
2912
+ payload: z.object({
2913
+ template: PromptTemplateSchema.optional(),
2914
+ error: z.string().optional(),
2915
+ requestId: z.string(),
2916
+ }),
2917
+ });
2918
+ export const RunsTemplatesDeleteRequestSchema = z.object({
2919
+ type: z.literal("runs.templates.delete.request"),
2920
+ templateId: z.string(),
2921
+ requestId: z.string(),
2922
+ });
2923
+ export const RunsTemplatesDeleteResponseSchema = z.object({
2924
+ type: z.literal("runs.templates.delete.response"),
2925
+ payload: z.object({
2926
+ deleted: z.boolean(),
2927
+ error: z.string().optional(),
2928
+ requestId: z.string(),
2929
+ }),
2930
+ });
2931
+ export const RunsTemplatesChangedNotificationSchema = z.object({
2932
+ type: z.literal("runs.templates.changed.notification"),
2933
+ payload: z.object({
2934
+ templates: z.array(PromptTemplateSchema),
2935
+ }),
2936
+ });
2460
2937
  // Start (or draft) a user-initiated orchestration from the New Orchestration
2461
2938
  // dialog. `flavor` is an open vocabulary: "ai" (prompt-and-go — the daemon
2462
2939
  // spawns an orchestrator agent that declares its own plan via start_run) or
2463
2940
  // "graph" (deterministic — the daemon executes `graphId` with `graphInputs`).
2464
2941
  // `draft: true` creates the record without executing (the designer flow);
2465
- // `runId` executes an existing draft in place.
2942
+ // `runId` executes an existing draft in place — or, with `draft: true`, re-saves
2943
+ // that draft in place (Edit Orchestration).
2466
2944
  export const RunsStartRequestSchema = z.object({
2467
2945
  type: z.literal("runs.start.request"),
2468
2946
  flavor: z.string(),
@@ -2857,6 +3335,96 @@ export const ProjectAddRequestSchema = z.object({
2857
3335
  cwd: z.string(),
2858
3336
  requestId: z.string(),
2859
3337
  });
3338
+ // ── New project scaffolding ──────────────────────────────────────────────
3339
+ // project.add takes a directory that already exists. Scaffolding is the other
3340
+ // half: create the directory, optionally give it a git repo (fresh, or cloned
3341
+ // from a remote), optionally create that remote on a connected hosting
3342
+ // provider, then register the result as a project. One RPC rather than a
3343
+ // client-driven sequence so a half-finished project can never be left behind by
3344
+ // a dropped socket — the daemon owns the whole transaction.
3345
+ // COMPAT(projectScaffold): added in v0.6.9. Gated by server_info.features.projectScaffold.
3346
+ // Built-in .gitignore starters. Deliberately a short list of the ecosystems Otto
3347
+ // itself works in — this is a convenience, not a mirror of github/gitignore. The
3348
+ // wire field stays an open string so a newer daemon can add one without an older
3349
+ // client's validator rejecting the message.
3350
+ export const PROJECT_SCAFFOLD_GITIGNORE_TEMPLATE_IDS = [
3351
+ "node",
3352
+ "python",
3353
+ "go",
3354
+ "rust",
3355
+ "java",
3356
+ "dotnet",
3357
+ ];
3358
+ // Where the working tree comes from.
3359
+ export const ProjectScaffoldGitSchema = z.discriminatedUnion("kind", [
3360
+ // A plain directory. No repository is created.
3361
+ z.object({ kind: z.literal("none") }),
3362
+ z.object({
3363
+ kind: z.literal("init"),
3364
+ // Branch the fresh repo starts on. Absent means the daemon's git default.
3365
+ initialBranch: z.string().optional(),
3366
+ // Starter files written before the first commit.
3367
+ addReadme: z.boolean().optional(),
3368
+ // Identifier of a built-in .gitignore template (see PROJECT_SCAFFOLD_GITIGNORE_TEMPLATE_IDS).
3369
+ gitignoreTemplate: z.string().optional(),
3370
+ // Commit whatever starter files were written. Required for a push.
3371
+ initialCommit: z.boolean().optional(),
3372
+ // Create the repository on a hosting provider, wire it as `origin`, and push.
3373
+ // Requires the provider's createRepository capability.
3374
+ remote: z
3375
+ .object({
3376
+ providerId: GitHostingProviderIdWireSchema,
3377
+ // Account/organization/workspace to create under. Null means the
3378
+ // provider's default for the authenticated identity.
3379
+ owner: z.string().nullable(),
3380
+ name: z.string(),
3381
+ description: z.string().optional(),
3382
+ visibility: z.enum(["private", "public"]),
3383
+ })
3384
+ .optional(),
3385
+ }),
3386
+ z.object({
3387
+ kind: z.literal("clone"),
3388
+ // Any URL `git clone` accepts (https, ssh, scp-style).
3389
+ url: z.string(),
3390
+ }),
3391
+ ]);
3392
+ export const ProjectScaffoldRequestSchema = z.object({
3393
+ type: z.literal("project.scaffold.request"),
3394
+ requestId: z.string(),
3395
+ // Existing directory that will contain the new project folder.
3396
+ parentDirectory: z.string(),
3397
+ // Single path segment created inside parentDirectory. For a clone this may be
3398
+ // omitted, in which case the daemon derives it from the repository URL.
3399
+ folderName: z.string().optional(),
3400
+ git: ProjectScaffoldGitSchema,
3401
+ });
3402
+ // Steps are reported in the order the daemon runs them. New daemons may add
3403
+ // steps, so the wire form stays an open string and clients label unknown ids
3404
+ // generically instead of dropping the progress message.
3405
+ export const ProjectScaffoldStepIdSchema = z.string();
3406
+ export const ProjectScaffoldStepStatusSchema = z.enum(["running", "done", "skipped", "failed"]);
3407
+ export const ProjectScaffoldStepSchema = z.object({
3408
+ id: ProjectScaffoldStepIdSchema,
3409
+ status: ProjectScaffoldStepStatusSchema,
3410
+ detail: z.string().nullable(),
3411
+ });
3412
+ // Repository enumeration for the clone picker, and owner enumeration for the
3413
+ // "create a new remote" form. Both are host-level (no repo cwd exists yet), so
3414
+ // they address a provider directly instead of resolving one from a checkout.
3415
+ export const HostingListRepositoriesRequestSchema = z.object({
3416
+ type: z.literal("hosting.list_repositories.request"),
3417
+ provider: GitHostingProviderIdWireSchema,
3418
+ // Substring filter applied by the provider where it supports one.
3419
+ query: z.string().optional(),
3420
+ limit: z.number().int().min(1).max(100).optional(),
3421
+ requestId: z.string(),
3422
+ });
3423
+ export const HostingListOwnersRequestSchema = z.object({
3424
+ type: z.literal("hosting.list_owners.request"),
3425
+ provider: GitHostingProviderIdWireSchema,
3426
+ requestId: z.string(),
3427
+ });
2860
3428
  export const ArchiveWorkspaceRequestSchema = z.object({
2861
3429
  type: z.literal("archive_workspace_request"),
2862
3430
  workspaceId: z.string(),
@@ -2879,6 +3447,18 @@ export const WorkspaceArchivePreflightRequestSchema = z.object({
2879
3447
  requestId: z.string(),
2880
3448
  workspaceId: z.string(),
2881
3449
  });
3450
+ // Repoint a worktree-backed workspace's base branch — what the Changes view diffs
3451
+ // against, and what merge-into-base and PR creation target. On a stacked branch the
3452
+ // useful base is the parent branch, not the repo default, the same way a forge PR
3453
+ // carries an explicit base. A null baseRef resets to the repository default branch.
3454
+ // COMPAT(worktreeDiffBase): added in v0.6.8.
3455
+ export const WorktreeBaseRefSetRequestSchema = z.object({
3456
+ type: z.literal("worktree.baseRef.set.request"),
3457
+ requestId: z.string(),
3458
+ workspaceId: z.string(),
3459
+ // Branch name, with or without an `origin/` prefix; null resets to the default branch.
3460
+ baseRef: z.string().nullable(),
3461
+ });
2882
3462
  // Create a new workspace record. Unlike open_project, this never deduplicates by
2883
3463
  // directory: it always produces a fresh workspace. The source discriminates
2884
3464
  // between an existing local directory and a newly created otto worktree.
@@ -2980,6 +3560,8 @@ const FileExplorerEntrySchema = z.object({
2980
3560
  modifiedAt: z.string(),
2981
3561
  });
2982
3562
  export const FileEolSchema = z.enum(["lf", "crlf"]);
3563
+ /** What a directory entry is. Shared by the file-mutation RPCs below. */
3564
+ export const FileEntryKindSchema = z.enum(["file", "directory"]);
2983
3565
  const FileExplorerFileSchema = z.object({
2984
3566
  path: z.string(),
2985
3567
  kind: z.enum(["text", "image", "binary"]),
@@ -3045,6 +3627,96 @@ export const FileWriteRequestSchema = z.object({
3045
3627
  eol: FileEolSchema.optional(),
3046
3628
  requestId: z.string(),
3047
3629
  });
3630
+ /**
3631
+ * The general file-mutation surface: create, delete, rename/move.
3632
+ *
3633
+ * Deliberately separate from `file.write.request`, which is the text editor's
3634
+ * conditional *content* save. These three change what exists in the directory
3635
+ * rather than what is inside a file, and unlike `file.write` they are
3636
+ * **workspace-bounded**: the daemon refuses a `cwd` outside every known Otto
3637
+ * workspace, the way directory listing already does. Editing a stray file the
3638
+ * user opened by path is one thing; unlinking one is another.
3639
+ *
3640
+ * `path` is workspace-relative throughout, matching every other file RPC.
3641
+ */
3642
+ export const FileCreateRequestSchema = z.object({
3643
+ type: z.literal("file.create.request"),
3644
+ cwd: z.string(),
3645
+ path: z.string(),
3646
+ kind: FileEntryKindSchema,
3647
+ requestId: z.string(),
3648
+ });
3649
+ /**
3650
+ * Permanent delete — an unlink, not a move to the OS trash. The daemon may be
3651
+ * headless, remote, or inside WSL, where there is no reliable trash to move to;
3652
+ * a "deleted" file that silently stayed on disk in one environment and vanished
3653
+ * in another would be worse than either. The client's confirmation says so.
3654
+ */
3655
+ export const FileDeleteRequestSchema = z.object({
3656
+ type: z.literal("file.delete.request"),
3657
+ cwd: z.string(),
3658
+ path: z.string(),
3659
+ // Required to delete a directory that has children. Absent (the default) a
3660
+ // non-empty directory comes back as `not_empty` and nothing is removed, so a
3661
+ // client that never asks can never recursively wipe a tree by accident.
3662
+ recursive: z.boolean().optional(),
3663
+ requestId: z.string(),
3664
+ });
3665
+ /**
3666
+ * Rename and move are the same operation — a move is a rename whose new path
3667
+ * has a different parent. Never clobbers: an occupied destination comes back as
3668
+ * `exists` and nothing moves. There is no overwrite flag on purpose, so this
3669
+ * RPC cannot destroy a file the user did not name.
3670
+ */
3671
+ export const FileRenameRequestSchema = z.object({
3672
+ type: z.literal("file.rename.request"),
3673
+ cwd: z.string(),
3674
+ path: z.string(),
3675
+ newPath: z.string(),
3676
+ requestId: z.string(),
3677
+ });
3678
+ /**
3679
+ * Refine — an AI rewrite the user reviews as a diff before anything is written.
3680
+ * This RPC only *proposes*: it reads nothing from disk and writes nothing. The
3681
+ * accepted result goes back through `file.write.request` like any other save,
3682
+ * so the conditional-write precondition still guards it.
3683
+ *
3684
+ * `base` travels from the client rather than being re-read on the daemon, so
3685
+ * the model rewrites exactly the document the user is looking at and the diff
3686
+ * they review is the diff of what they saw.
3687
+ */
3688
+ /**
3689
+ * One document in a refine request. `id` is opaque and client-minted; the model
3690
+ * never sees it and the daemon only echoes it back. That is deliberate: the
3691
+ * client maps id -> absolute path itself, so a model that mangles or invents a
3692
+ * filename cannot misroute a write. `label` is the only path-ish thing the
3693
+ * model sees, and it exists purely so the prompt can say which file is which.
3694
+ */
3695
+ export const FileRefineDocumentSchema = z.object({
3696
+ id: z.string().min(1),
3697
+ label: z.string(),
3698
+ content: z.string(),
3699
+ });
3700
+ /** A file the model may read for context but must never rewrite. */
3701
+ export const FileRefineReferenceSchema = z.object({
3702
+ label: z.string(),
3703
+ content: z.string(),
3704
+ });
3705
+ export const FileRefineRequestSchema = z.object({
3706
+ type: z.literal("file.refine.request"),
3707
+ // Provider resolution only — which workspace's mini-task chain runs this.
3708
+ // Documents are NOT read from disk here; they travel on the wire.
3709
+ cwd: z.string(),
3710
+ // What the model may rewrite. The blast radius of the whole request: a file
3711
+ // absent from this list cannot be changed, whatever the model returns.
3712
+ documents: z.array(FileRefineDocumentSchema).min(1),
3713
+ // What it may read to understand the first list. Optional so an old client
3714
+ // that only sends documents still parses.
3715
+ references: z.array(FileRefineReferenceSchema).optional(),
3716
+ // The user's plain-language instruction, possibly seeded from a preset.
3717
+ instruction: z.string(),
3718
+ requestId: z.string(),
3719
+ });
3048
3720
  // Subscriptions exist only for paths open in tabs; the daemon cleans them up
3049
3721
  // when the session ends.
3050
3722
  export const FileWatchSubscribeRequestSchema = z.object({
@@ -3079,73 +3751,242 @@ export const CodeOutlineRequestSchema = z.object({
3079
3751
  requestId: z.string(),
3080
3752
  });
3081
3753
  /**
3082
- * Project-wide search ("Find in Files" semantics: explicit search, not
3083
- * per-keystroke). Results stream as file.search.result events correlated by
3084
- * searchId (= this requestId); a new search from the same session supersedes
3085
- * any in-flight one.
3754
+ * LSP-backed code intelligence (projects/lsp-code-intelligence). Distinct from the
3755
+ * ctags `code.symbols` RPC above in the only way that matters: it carries a
3756
+ * **position**, so the daemon can resolve the reference under the cursor instead of
3757
+ * matching a name.
3758
+ *
3759
+ * Line and column are **1-based** here, matching `CodeSymbolLocation` and the rest of
3760
+ * Otto. LSP itself is 0-based; that conversion is the daemon's business and does not
3761
+ * reach the wire.
3086
3762
  */
3087
- export const FileSearchRequestSchema = z.object({
3088
- type: z.literal("file.search.request"),
3763
+ export const CodeDefinitionRequestSchema = z.object({
3764
+ type: z.literal("code.definition.request"),
3089
3765
  cwd: z.string(),
3090
- query: z.string(),
3091
- caseSensitive: z.boolean().optional(),
3092
- wholeWord: z.boolean().optional(),
3093
- regexp: z.boolean().optional(),
3094
- include: z.string().optional(),
3095
- exclude: z.string().optional(),
3096
- requestId: z.string(),
3097
- });
3098
- const FileReplaceMatchSchema = z.object({
3099
- /** 1-based line number. */
3766
+ path: z.string(),
3100
3767
  line: z.number().int().positive(),
3101
- /** 1-based character column of the match start. */
3102
3768
  column: z.number().int().positive(),
3103
- /** Match length in characters. */
3104
- length: z.number().int().nonnegative(),
3769
+ requestId: z.string(),
3105
3770
  });
3106
3771
  /**
3107
- * Preview-first project replace. Each file carries the hash the preview was
3108
- * built against files changed since are skipped and reported, never
3109
- * corrupted. The replacement string is literal (no capture references in v1).
3772
+ * The editor's current buffer text, so definitions resolve against unsaved edits
3773
+ * rather than stale disk content. Sent debounced, not per keystroke.
3110
3774
  */
3111
- export const FileReplaceRequestSchema = z.object({
3112
- type: z.literal("file.replace.request"),
3775
+ export const CodeDocumentSyncRequestSchema = z.object({
3776
+ type: z.literal("code.document.sync.request"),
3113
3777
  cwd: z.string(),
3114
- replacement: z.string(),
3115
- files: z.array(z.object({
3116
- path: z.string(),
3117
- expectedHash: z.string(),
3118
- matches: z.array(FileReplaceMatchSchema),
3119
- })),
3778
+ path: z.string(),
3779
+ text: z.string(),
3120
3780
  requestId: z.string(),
3121
3781
  });
3122
- export const ClearAgentAttentionMessageSchema = z.object({
3123
- type: z.literal("clear_agent_attention"),
3124
- agentId: z.union([z.string(), z.array(z.string())]),
3125
- requestId: z.string().optional(),
3126
- });
3127
- export const ClientHeartbeatMessageSchema = z.object({
3128
- type: z.literal("client_heartbeat"),
3129
- deviceType: z.enum(["web", "mobile"]),
3130
- focusedAgentId: z.string().nullable(),
3131
- // COMPAT(terminalFocusHeartbeat): added in v0.1.97, remove optional default after 2026-12-13 once old clients no longer send heartbeats without terminal focus.
3132
- focusedTerminalId: z.string().nullable().optional().default(null),
3133
- lastActivityAt: z.string(),
3134
- appVisible: z.boolean(),
3135
- appVisibilityChangedAt: z.string().optional(),
3136
- });
3137
- export const PingMessageSchema = z.object({
3138
- type: z.literal("ping"),
3782
+ export const CodeDocumentCloseRequestSchema = z.object({
3783
+ type: z.literal("code.document.close.request"),
3784
+ cwd: z.string(),
3785
+ path: z.string(),
3139
3786
  requestId: z.string(),
3140
- clientSentAt: z.number().int().optional(),
3141
3787
  });
3142
- const ListCommandsDraftConfigSchema = z.object({
3143
- provider: AgentProviderSchema,
3788
+ /**
3789
+ * The rest of the position-based code-intelligence family. All three carry a 1-based
3790
+ * position like `code.definition`, and all three are answered against the mirrored
3791
+ * buffer rather than the file on disk.
3792
+ */
3793
+ export const CodeHoverRequestSchema = z.object({
3794
+ type: z.literal("code.hover.request"),
3144
3795
  cwd: z.string(),
3145
- modeId: z.string().optional(),
3146
- model: z.string().optional(),
3147
- thinkingOptionId: z.string().optional(),
3148
- featureValues: z.record(z.string(), z.unknown()).optional(),
3796
+ path: z.string(),
3797
+ line: z.number().int().positive(),
3798
+ column: z.number().int().positive(),
3799
+ requestId: z.string(),
3800
+ });
3801
+ export const CodeReferencesRequestSchema = z.object({
3802
+ type: z.literal("code.references.request"),
3803
+ cwd: z.string(),
3804
+ path: z.string(),
3805
+ line: z.number().int().positive(),
3806
+ column: z.number().int().positive(),
3807
+ requestId: z.string(),
3808
+ });
3809
+ /**
3810
+ * A rename **dry run**. Deliberately not "do the rename": the daemon computes every edit
3811
+ * and returns them for the user to audit, because a rename's blast radius is the whole
3812
+ * project. Nothing is written by this request.
3813
+ */
3814
+ export const CodeRenamePreviewRequestSchema = z.object({
3815
+ type: z.literal("code.rename.preview.request"),
3816
+ cwd: z.string(),
3817
+ path: z.string(),
3818
+ line: z.number().int().positive(),
3819
+ column: z.number().int().positive(),
3820
+ newName: z.string().min(1),
3821
+ requestId: z.string(),
3822
+ });
3823
+ /**
3824
+ * Execute a rename the user has audited. **The edits are deliberately NOT on this request.**
3825
+ *
3826
+ * The client sends back only the `planId` it was shown; the daemon recomputes the plan and
3827
+ * refuses unless the identity matches. A request that carried its own edit list would be a
3828
+ * remote arbitrary-write primitive wearing a rename's name — any client could post any text
3829
+ * at any path. This shape makes the daemon's own language server the sole author of what
3830
+ * gets written, and the plan id the proof that the user saw it.
3831
+ */
3832
+ export const CodeRenameApplyRequestSchema = z.object({
3833
+ type: z.literal("code.rename.apply.request"),
3834
+ cwd: z.string(),
3835
+ path: z.string(),
3836
+ line: z.number().int().positive(),
3837
+ column: z.number().int().positive(),
3838
+ newName: z.string().min(1),
3839
+ /** From the preview response. Identity of the exact plan the user approved. */
3840
+ planId: z.string().min(1),
3841
+ requestId: z.string(),
3842
+ });
3843
+ /**
3844
+ * Undo a run. Carries only the run's id — the daemon holds the before-images.
3845
+ *
3846
+ * Declared here, with the other inbound rename schemas, rather than beside its response
3847
+ * further down: `SessionInboundMessageSchema` is a top-level const, so a schema it names
3848
+ * must already be initialized when that line runs. Below the union it is a
3849
+ * ReferenceError at import time, not a type error.
3850
+ */
3851
+ export const CodeRenameUndoRequestSchema = z.object({
3852
+ type: z.literal("code.rename.undo.request"),
3853
+ cwd: z.string(),
3854
+ runId: z.string().min(1),
3855
+ requestId: z.string(),
3856
+ });
3857
+ /**
3858
+ * Live language-server state for the Daemon → Code screen. Separate from the daemon
3859
+ * config RPCs because none of it is configuration: which servers this machine can
3860
+ * actually supply, and which are running right now.
3861
+ *
3862
+ * `cwd` scopes the availability check — a server can be present in one workspace's
3863
+ * `node_modules` and absent in another's.
3864
+ */
3865
+ export const LspServersListRequestSchema = z.object({
3866
+ type: z.literal("lsp.servers.list.request"),
3867
+ cwd: z.string(),
3868
+ requestId: z.string(),
3869
+ });
3870
+ /** Stop one running server, so a user who suspects it of hogging memory can kill it. */
3871
+ export const LspServerStopRequestSchema = z.object({
3872
+ type: z.literal("lsp.server.stop.request"),
3873
+ rootPath: z.string(),
3874
+ serverId: z.string(),
3875
+ requestId: z.string(),
3876
+ });
3877
+ /**
3878
+ * The Solution view (projects/solution-view). A second lens on the Files module showing the tree
3879
+ * as the build system sees it rather than as the filesystem lays it out.
3880
+ *
3881
+ * **Independent of the LSP family above, despite sharing the `code.` domain.** There is no
3882
+ * project-structure request in the Language Server Protocol — not one Otto has yet to wire, one
3883
+ * that does not exist — so this subsystem builds its own model through Microsoft's solution
3884
+ * libraries. Turning C# code intelligence off does not turn this off, and vice versa.
3885
+ *
3886
+ * Discovery is separate from loading on purpose: `list` decides whether the switcher appears at
3887
+ * all, so it runs for every workspace and must stay cheap (a directory walk, no process). Only
3888
+ * `get_tree` reaches the .NET sidecar.
3889
+ *
3890
+ * COMPAT(solutionView): added in v0.6.8; gate lives in features.solutionView.
3891
+ */
3892
+ export const CodeSolutionListRequestSchema = z.object({
3893
+ type: z.literal("code.solution.list.request"),
3894
+ cwd: z.string(),
3895
+ requestId: z.string(),
3896
+ });
3897
+ /**
3898
+ * One solution's organisation: folders, the projects inside them, and the configurations. No file
3899
+ * membership — that is `load_project`, paid per project on expand, because evaluating fifty
3900
+ * projects to render a collapsed tree is the cost this design exists to avoid.
3901
+ */
3902
+ export const CodeSolutionGetTreeRequestSchema = z.object({
3903
+ type: z.literal("code.solution.get_tree.request"),
3904
+ cwd: z.string(),
3905
+ /** Workspace-relative, as reported by `list`. */
3906
+ solutionPath: z.string(),
3907
+ requestId: z.string(),
3908
+ });
3909
+ /**
3910
+ * One project's evaluated file membership. `solutionPath` scopes the sidecar instance so two
3911
+ * solutions in one repo never share a warm `ProjectCollection` — and so Phase 4 has the selection
3912
+ * it needs for `--solution`.
3913
+ */
3914
+ export const CodeSolutionLoadProjectRequestSchema = z.object({
3915
+ type: z.literal("code.solution.load_project.request"),
3916
+ cwd: z.string(),
3917
+ solutionPath: z.string(),
3918
+ /** Workspace-relative, or absolute when the solution names a project outside the workspace. */
3919
+ projectPath: z.string(),
3920
+ requestId: z.string(),
3921
+ });
3922
+ /**
3923
+ * Project-wide search ("Find in Files" semantics: explicit search, not
3924
+ * per-keystroke). Results stream as file.search.result events correlated by
3925
+ * searchId (= this requestId); a new search from the same session supersedes
3926
+ * any in-flight one.
3927
+ */
3928
+ export const FileSearchRequestSchema = z.object({
3929
+ type: z.literal("file.search.request"),
3930
+ cwd: z.string(),
3931
+ query: z.string(),
3932
+ caseSensitive: z.boolean().optional(),
3933
+ wholeWord: z.boolean().optional(),
3934
+ regexp: z.boolean().optional(),
3935
+ include: z.string().optional(),
3936
+ exclude: z.string().optional(),
3937
+ requestId: z.string(),
3938
+ });
3939
+ const FileReplaceMatchSchema = z.object({
3940
+ /** 1-based line number. */
3941
+ line: z.number().int().positive(),
3942
+ /** 1-based character column of the match start. */
3943
+ column: z.number().int().positive(),
3944
+ /** Match length in characters. */
3945
+ length: z.number().int().nonnegative(),
3946
+ });
3947
+ /**
3948
+ * Preview-first project replace. Each file carries the hash the preview was
3949
+ * built against — files changed since are skipped and reported, never
3950
+ * corrupted. The replacement string is literal (no capture references in v1).
3951
+ */
3952
+ export const FileReplaceRequestSchema = z.object({
3953
+ type: z.literal("file.replace.request"),
3954
+ cwd: z.string(),
3955
+ replacement: z.string(),
3956
+ files: z.array(z.object({
3957
+ path: z.string(),
3958
+ expectedHash: z.string(),
3959
+ matches: z.array(FileReplaceMatchSchema),
3960
+ })),
3961
+ requestId: z.string(),
3962
+ });
3963
+ export const ClearAgentAttentionMessageSchema = z.object({
3964
+ type: z.literal("clear_agent_attention"),
3965
+ agentId: z.union([z.string(), z.array(z.string())]),
3966
+ requestId: z.string().optional(),
3967
+ });
3968
+ export const ClientHeartbeatMessageSchema = z.object({
3969
+ type: z.literal("client_heartbeat"),
3970
+ deviceType: z.enum(["web", "mobile"]),
3971
+ focusedAgentId: z.string().nullable(),
3972
+ // COMPAT(terminalFocusHeartbeat): added in v0.1.97, remove optional default after 2026-12-13 once old clients no longer send heartbeats without terminal focus.
3973
+ focusedTerminalId: z.string().nullable().optional().default(null),
3974
+ lastActivityAt: z.string(),
3975
+ appVisible: z.boolean(),
3976
+ appVisibilityChangedAt: z.string().optional(),
3977
+ });
3978
+ export const PingMessageSchema = z.object({
3979
+ type: z.literal("ping"),
3980
+ requestId: z.string(),
3981
+ clientSentAt: z.number().int().optional(),
3982
+ });
3983
+ const ListCommandsDraftConfigSchema = z.object({
3984
+ provider: AgentProviderSchema,
3985
+ cwd: z.string(),
3986
+ modeId: z.string().optional(),
3987
+ model: z.string().optional(),
3988
+ thinkingOptionId: z.string().optional(),
3989
+ featureValues: z.record(z.string(), z.unknown()).optional(),
3149
3990
  });
3150
3991
  export const ListProviderFeaturesRequestMessageSchema = z.object({
3151
3992
  type: z.literal("list_provider_features_request"),
@@ -3266,6 +4107,7 @@ export const SessionInboundMessageSchema = z.discriminatedUnion("type", [
3266
4107
  DeleteAgentRequestMessageSchema,
3267
4108
  ArchiveAgentRequestMessageSchema,
3268
4109
  CloseItemsRequestMessageSchema,
4110
+ HistoryAgentsClearArchivedRequestSchema,
3269
4111
  UpdateAgentRequestMessageSchema,
3270
4112
  ProjectRenameRequestSchema,
3271
4113
  ProjectRemoveRequestSchema,
@@ -3305,6 +4147,11 @@ export const SessionInboundMessageSchema = z.discriminatedUnion("type", [
3305
4147
  StatsActivityGetRequestMessageSchema,
3306
4148
  ContextReportGetRequestMessageSchema,
3307
4149
  ContextEdgeConvertRequestMessageSchema,
4150
+ ContextFindingsFixRequestMessageSchema,
4151
+ PersonalityMemoryListRequestMessageSchema,
4152
+ PersonalityMemoryUpdateRequestMessageSchema,
4153
+ PersonalityMemoryTransferRequestMessageSchema,
4154
+ PersonalityMemoryStatsRequestMessageSchema,
3308
4155
  StatsActivityResetRequestMessageSchema,
3309
4156
  UsageLogGetRequestMessageSchema,
3310
4157
  AgentContextGetUsageRequestMessageSchema,
@@ -3329,6 +4176,9 @@ export const SessionInboundMessageSchema = z.discriminatedUnion("type", [
3329
4176
  TasksSuggestedDismissRequestMessageSchema,
3330
4177
  AgentPersonalitySetRequestMessageSchema,
3331
4178
  AgentRewindRequestMessageSchema,
4179
+ AgentQueueRemoveRequestMessageSchema,
4180
+ AgentQueueReorderRequestMessageSchema,
4181
+ AgentQueueClearRequestMessageSchema,
3332
4182
  AgentPermissionResponseMessageSchema,
3333
4183
  CheckoutStatusRequestSchema,
3334
4184
  SubscribeCheckoutDiffRequestSchema,
@@ -3346,9 +4196,13 @@ export const SessionInboundMessageSchema = z.discriminatedUnion("type", [
3346
4196
  RunsGateRespondRequestSchema,
3347
4197
  RunsCancelRequestSchema,
3348
4198
  RunsClearRequestSchema,
4199
+ RunsDeleteRequestSchema,
3349
4200
  RunsGraphsListRequestSchema,
3350
4201
  RunsGraphsSaveRequestSchema,
3351
4202
  RunsGraphsDeleteRequestSchema,
4203
+ RunsTemplatesListRequestSchema,
4204
+ RunsTemplatesSaveRequestSchema,
4205
+ RunsTemplatesDeleteRequestSchema,
3352
4206
  RunsStartRequestSchema,
3353
4207
  CheckoutMergeRequestSchema,
3354
4208
  CheckoutMergeFromBaseRequestSchema,
@@ -3384,8 +4238,12 @@ export const SessionInboundMessageSchema = z.discriminatedUnion("type", [
3384
4238
  LegacyOpenInEditorRequestSchema,
3385
4239
  OpenProjectRequestSchema,
3386
4240
  ProjectAddRequestSchema,
4241
+ ProjectScaffoldRequestSchema,
4242
+ HostingListRepositoriesRequestSchema,
4243
+ HostingListOwnersRequestSchema,
3387
4244
  ArchiveWorkspaceRequestSchema,
3388
4245
  WorkspaceArchivePreflightRequestSchema,
4246
+ WorktreeBaseRefSetRequestSchema,
3389
4247
  WorktreeReattachListRequestSchema,
3390
4248
  WorktreeReattachRequestSchema,
3391
4249
  WorkspaceCreateRequestSchema,
@@ -3395,6 +4253,10 @@ export const SessionInboundMessageSchema = z.discriminatedUnion("type", [
3395
4253
  FileDownloadTokenRequestSchema,
3396
4254
  FileUploadRequestSchema,
3397
4255
  FileWriteRequestSchema,
4256
+ FileCreateRequestSchema,
4257
+ FileDeleteRequestSchema,
4258
+ FileRenameRequestSchema,
4259
+ FileRefineRequestSchema,
3398
4260
  FileWatchSubscribeRequestSchema,
3399
4261
  FileWatchUnsubscribeRequestSchema,
3400
4262
  FileSearchRequestSchema,
@@ -3402,6 +4264,19 @@ export const SessionInboundMessageSchema = z.discriminatedUnion("type", [
3402
4264
  CodeListFilesRequestSchema,
3403
4265
  CodeSymbolsRequestSchema,
3404
4266
  CodeOutlineRequestSchema,
4267
+ CodeDefinitionRequestSchema,
4268
+ CodeDocumentSyncRequestSchema,
4269
+ CodeDocumentCloseRequestSchema,
4270
+ CodeHoverRequestSchema,
4271
+ CodeReferencesRequestSchema,
4272
+ CodeRenamePreviewRequestSchema,
4273
+ CodeRenameApplyRequestSchema,
4274
+ CodeRenameUndoRequestSchema,
4275
+ LspServersListRequestSchema,
4276
+ LspServerStopRequestSchema,
4277
+ CodeSolutionListRequestSchema,
4278
+ CodeSolutionGetTreeRequestSchema,
4279
+ CodeSolutionLoadProjectRequestSchema,
3405
4280
  ClearAgentAttentionMessageSchema,
3406
4281
  ClientHeartbeatMessageSchema,
3407
4282
  PingMessageSchema,
@@ -3609,6 +4484,12 @@ export const ServerInfoStatusPayloadSchema = z
3609
4484
  projectRemove: z.boolean().optional(),
3610
4485
  // COMPAT(projectAdd): added in v0.1.97, drop the gate when floor >= v0.1.97.
3611
4486
  projectAdd: z.boolean().optional(),
4487
+ // COMPAT(projectScaffold): added in v0.6.9, drop the gate when floor >= v0.6.9.
4488
+ // The daemon can create a project directory from scratch (mkdir, git
4489
+ // init/clone, optional remote creation) instead of only adopting one
4490
+ // that already exists. Without it the New project page offers the
4491
+ // open-an-existing-folder path only.
4492
+ projectScaffold: z.boolean().optional(),
3612
4493
  // COMPAT(worktreeRestore): added in v0.1.97, drop the gate when floor >= v0.1.97
3613
4494
  worktreeRestore: z.boolean().optional(),
3614
4495
  // COMPAT(providerUsageList): added in v0.1.98, drop the gate when daemon floor >= v0.1.98.
@@ -3637,6 +4518,25 @@ export const ServerInfoStatusPayloadSchema = z
3637
4518
  retainedTranscripts: z.boolean().optional(),
3638
4519
  // COMPAT(suggestedTasks): added in v0.5.6, drop the gate when daemon floor >= v0.5.6.
3639
4520
  suggestedTasks: z.boolean().optional(),
4521
+ // COMPAT(steerQueue): added in v0.6.8, drop the gate when daemon floor >= v0.6.8.
4522
+ // Daemon owns a per-agent queue of steering messages, accepts
4523
+ // `delivery: "queue"` on send, reports `queuedMessages` on the agent
4524
+ // snapshot, and serves agent.queue.remove/clear. Without it the
4525
+ // composer keeps its own local queue — that is the pre-existing
4526
+ // behavior, not a degraded build of this feature.
4527
+ steerQueue: z.boolean().optional(),
4528
+ // Daemon serves agent.queue.reorder. Separate from `steerQueue`
4529
+ // because a daemon on 0.6.8 owns a queue but cannot re-order it;
4530
+ // without this the move controls are absent (the queue still works).
4531
+ // COMPAT(steerQueueReorder): added in v0.6.9, drop the gate when daemon floor >= v0.6.9.
4532
+ steerQueueReorder: z.boolean().optional(),
4533
+ // Daemon reports `cumulativeUsage` (the lifetime in/cached/out split
4534
+ // plus its own booked cost) on every agent snapshot, so a chat's total
4535
+ // spend can be summed and priced honestly. Without it the client shows
4536
+ // token totals only and no cost — NOT an estimated cost, which is the
4537
+ // behavior this feature exists to remove.
4538
+ // COMPAT(cumulativeUsage): added in v0.7.0, drop the gate when daemon floor >= v0.7.0.
4539
+ cumulativeUsage: z.boolean().optional(),
3640
4540
  // Daemon can resolve and evaluate the provider's context graph, serve
3641
4541
  // context.report.* and push context_report_changed. Without it the
3642
4542
  // client hides both the Context Management tab and the composer
@@ -3646,10 +4546,38 @@ export const ServerInfoStatusPayloadSchema = z
3646
4546
  contextManagement: z.boolean().optional(),
3647
4547
  // COMPAT(textEditor): added in v0.4.4, drop the gate when daemon floor >= v0.4.4.
3648
4548
  textEditor: z.boolean().optional(),
4549
+ // Refine — the daemon can turn a pinned document plus an instruction
4550
+ // into a proposed rewrite (`file.refine.*`). Without it the Refine
4551
+ // entry is absent: there is no client-side substitute for a model, and
4552
+ // a degraded "open a chat instead" path is exactly the unreviewed edit
4553
+ // Refine exists to replace.
4554
+ // COMPAT(refine): added in v0.6.9, drop the gate when daemon floor >= v0.6.9.
4555
+ refine: z.boolean().optional(),
4556
+ // Personality memory — the daemon stores per-personality lessons, injects
4557
+ // them at spawn, and serves personality.memory.*. Without it the client
4558
+ // hides the Memory tab, the accrual indicator and the transfer-on-delete
4559
+ // choice: storage is daemon-side by definition, so there is nothing a
4560
+ // client-side fallback could read.
4561
+ // COMPAT(personalityMemory): added in v0.7.0, drop the gate when daemon floor >= v0.7.0.
4562
+ personalityMemory: z.boolean().optional(),
3649
4563
  // COMPAT(projectSearch): added in v0.4.4, drop the gate when daemon floor >= v0.4.4.
3650
4564
  projectSearch: z.boolean().optional(),
3651
4565
  // COMPAT(codeIndex): added in v0.4.4, drop the gate when daemon floor >= v0.4.4.
3652
4566
  codeIndex: z.boolean().optional(),
4567
+ // Language-server-backed definitions (`code.definition`, `code.document.*`).
4568
+ // Separate from `codeIndex`: that gate covers the ctags path, which stays as
4569
+ // the outline/fuzzy-finder source and the no-server fallback.
4570
+ // COMPAT(lsp): added in v0.6.8, drop the gate when daemon floor >= v0.6.8.
4571
+ lsp: z.boolean().optional(),
4572
+ // The Solution view — the daemon can discover solutions and serve
4573
+ // `code.solution.*`. Deliberately NOT implied by `lsp`: there is no
4574
+ // project-structure request in LSP, so this subsystem is independent of
4575
+ // language servers and of the C# row's on/off state. Without the flag the
4576
+ // client never shows the view switcher and never asks — there is no
4577
+ // client-side substitute for reading a solution, and a hand-parsed
4578
+ // half-tree is exactly the mistake this design exists to avoid.
4579
+ // COMPAT(solutionView): added in v0.6.8, drop the gate when daemon floor >= v0.6.8.
4580
+ solutionView: z.boolean().optional(),
3653
4581
  // COMPAT(artifactsToolGroup): added in v0.4.5, drop the gate when daemon floor >= v0.4.5.
3654
4582
  artifactsToolGroup: z.boolean().optional(),
3655
4583
  // COMPAT(speechSettings): added in v0.4.5, drop the gate when daemon floor >= v0.4.5.
@@ -3690,6 +4618,12 @@ export const ServerInfoStatusPayloadSchema = z
3690
4618
  worktreeArchiveBranchCleanup: z.boolean().optional(),
3691
4619
  // COMPAT(worktreeReattach): added in v0.6.7, drop the gate when daemon floor >= v0.6.7.
3692
4620
  worktreeReattach: z.boolean().optional(),
4621
+ // Set when the daemon can repoint a worktree's stored base branch
4622
+ // (worktree.baseRef.set.*). Without it the client renders the base as a
4623
+ // read-only "vs <base>" label — there is no client-side override, since only
4624
+ // the daemon can write the worktree's metadata.
4625
+ // COMPAT(worktreeDiffBase): added in v0.6.8, drop the gate when daemon floor >= v0.6.8.
4626
+ worktreeDiffBase: z.boolean().optional(),
3693
4627
  // Set when the daemon persists the host-level hideMergeIntoBaseAction
3694
4628
  // workspace policy (read/written via the daemon config RPCs). Without
3695
4629
  // it the client hides the Workspaces toggle, since patching the field
@@ -3708,6 +4642,12 @@ export const ServerInfoStatusPayloadSchema = z
3708
4642
  activityStats: z.boolean().optional(),
3709
4643
  // COMPAT(runsClear): added in v0.5.3, drop the gate when daemon floor >= v0.5.3.
3710
4644
  runsClear: z.boolean().optional(),
4645
+ // COMPAT(runsDelete): added in v0.6.8, drop the gate when daemon floor >= v0.6.8.
4646
+ runsDelete: z.boolean().optional(),
4647
+ // COMPAT(runsDraftEdit): added in v0.6.8, drop the gate when daemon floor >= v0.6.8.
4648
+ // The daemon accepts `runs.start` with `draft: true` AND a `runId`,
4649
+ // re-saving that draft in place instead of minting a second one.
4650
+ runsDraftEdit: z.boolean().optional(),
3711
4651
  // COMPAT(orchestrationGraphs): added in v0.6.7, drop the gate when daemon floor >= v0.6.7.
3712
4652
  orchestrationGraphs: z.boolean().optional(),
3713
4653
  // COMPAT(projectLinks): added in v0.5.6, drop the gate when daemon floor >= v0.5.6.
@@ -3765,6 +4705,22 @@ export const ServerInfoStatusPayloadSchema = z
3765
4705
  // counters + the itemized ledger). The client gates the Metrics screen's
3766
4706
  // "Reset" button on this; an old daemon simply doesn't offer it.
3767
4707
  statsReset: z.boolean().optional(),
4708
+ // COMPAT(historyDelete): added in v0.7.0, drop the gate when daemon floor >= v0.7.0.
4709
+ // Set when the daemon offers hard delete for chat records: per-row via
4710
+ // the existing `delete_agent_request`, and in bulk via
4711
+ // `history.agents.clear_archived`. Archive has always been a soft delete
4712
+ // with no counterpart; this is the counterpart. Deleting removes Otto's
4713
+ // record only — provider transcripts are never touched (see the
4714
+ // clear_archived schema). The client hides both affordances when this is
4715
+ // absent rather than shipping a degraded path.
4716
+ historyDelete: z.boolean().optional(),
4717
+ // COMPAT(fileMutations): added in v0.7.0, drop the gate when daemon floor >= v0.7.0.
4718
+ // Set when the daemon serves `file.create`, `file.delete` and
4719
+ // `file.rename` — creating, removing and moving entries, as opposed to
4720
+ // `file.write`, which only changes what is inside an existing file.
4721
+ // There is no client-side substitute (the client never touches the
4722
+ // filesystem), so an old daemon simply does not get the menu items.
4723
+ fileMutations: z.boolean().optional(),
3768
4724
  })
3769
4725
  .optional(),
3770
4726
  })
@@ -3847,7 +4803,70 @@ export const DaemonConfigChangedStatusPayloadSchema = z
3847
4803
  config: MutableDaemonConfigSchema,
3848
4804
  })
3849
4805
  .passthrough();
4806
+ /**
4807
+ * Which workspaces currently have a language server starting up or indexing. Sent as
4808
+ * the whole busy set rather than per-workspace transitions: the only consumer is a
4809
+ * spinner, so an idempotent snapshot cannot drift out of sync the way a missed
4810
+ * transition would.
4811
+ *
4812
+ * Separate from the workspace status bucket on purpose — indexing is not the workspace
4813
+ * "working", and folding it in would mislabel a quiet workspace as busy with agent work.
4814
+ */
4815
+ export const LspActivityChangedStatusPayloadSchema = z
4816
+ .object({
4817
+ status: z.literal("lsp_activity_changed"),
4818
+ /** Absolute workspace roots with language-server work in flight. */
4819
+ busyRoots: z.array(z.string()),
4820
+ })
4821
+ .passthrough();
4822
+ /**
4823
+ * Compiler severity, named rather than numbered. LSP uses 1–4; a magic number on the
4824
+ * wire would have every consumer re-deriving which one is a warning.
4825
+ */
4826
+ export const CodeDiagnosticSeveritySchema = z.enum(["error", "warning", "info", "hint"]);
4827
+ /** One problem the language server reported, 1-based like every other position. */
4828
+ export const CodeDiagnosticSchema = z.object({
4829
+ line: z.number().int().positive(),
4830
+ column: z.number().int().positive(),
4831
+ endLine: z.number().int().positive(),
4832
+ endColumn: z.number().int().positive(),
4833
+ severity: CodeDiagnosticSeveritySchema,
4834
+ message: z.string(),
4835
+ /** Who says so — `ts`, `pyright`, a linter behind the server. */
4836
+ source: z.string().optional(),
4837
+ /** The server's own code for the rule or error, e.g. TypeScript's `2345`. */
4838
+ code: z.string().optional(),
4839
+ /** Documentation for that rule, when the server offers one — oxlint does. */
4840
+ codeHref: z.string().optional(),
4841
+ /** Which registry row published it, so two servers on one file stay attributable. */
4842
+ serverId: z.string().optional(),
4843
+ });
4844
+ /**
4845
+ * Diagnostics for one open document, pushed unsolicited.
4846
+ *
4847
+ * This is the one part of code intelligence that is not request/response:
4848
+ * `textDocument/publishDiagnostics` arrives whenever the server has recomputed, which is
4849
+ * whenever it feels like it. So it is a status broadcast, and the payload is the document's
4850
+ * **whole** current set — never a delta. A missed delta would leave a stale squiggle on a
4851
+ * line the user already fixed, and an idempotent snapshot cannot drift.
4852
+ *
4853
+ * Only documents a client has synced produce these. A server may know about every file in
4854
+ * the project; pushing all of it would be unbounded, and nothing can render a marker in a
4855
+ * file that is not open.
4856
+ */
4857
+ export const LspDiagnosticsChangedStatusPayloadSchema = z
4858
+ .object({
4859
+ status: z.literal("lsp_diagnostics_changed"),
4860
+ /** Workspace root the document belongs to. */
4861
+ cwd: z.string(),
4862
+ /** Absolute path of the document these describe. */
4863
+ path: z.string(),
4864
+ diagnostics: z.array(CodeDiagnosticSchema),
4865
+ })
4866
+ .passthrough();
3850
4867
  export const KnownStatusPayloadSchema = z.discriminatedUnion("status", [
4868
+ LspActivityChangedStatusPayloadSchema,
4869
+ LspDiagnosticsChangedStatusPayloadSchema,
3851
4870
  AgentCreatedStatusPayloadSchema,
3852
4871
  AgentCreateFailedStatusPayloadSchema,
3853
4872
  AgentResumedStatusPayloadSchema,
@@ -4172,6 +5191,22 @@ export const WorkspaceUpdateMessageSchema = z.object({
4172
5191
  }),
4173
5192
  ]),
4174
5193
  });
5194
+ // A project's own metadata changed (today: the user renamed it). The workspace
5195
+ // channel can only carry a project's name inside its workspaces' descriptors, so
5196
+ // a project with no active workspaces had no live channel at all — its name only
5197
+ // refreshed on the next full workspace fetch. This is the project-level channel:
5198
+ // it fires whether or not the project currently has workspaces, and the daemon
5199
+ // fans it out to every connected session because project metadata is host-global.
5200
+ export const ProjectUpdatedNotificationSchema = z.object({
5201
+ type: z.literal("project.updated.notification"),
5202
+ payload: z.object({
5203
+ project: WorkspaceProjectDescriptorPayloadSchema,
5204
+ // False means the project has no active workspaces right now, so the client
5205
+ // keeps it in the empty-project bucket instead of expecting a workspace
5206
+ // descriptor to carry its name.
5207
+ hasActiveWorkspaces: z.boolean(),
5208
+ }),
5209
+ });
4175
5210
  export const ScriptStatusUpdateMessageSchema = z.object({
4176
5211
  type: z.literal("script_status_update"),
4177
5212
  payload: z.object({
@@ -4220,6 +5255,89 @@ export const ProjectAddResponseSchema = z.object({
4220
5255
  errorCode: z.enum(["directory_not_found"]).nullish().catch(null),
4221
5256
  }),
4222
5257
  });
5258
+ // COMPAT(projectScaffold): added in v0.6.9.
5259
+ export const ProjectScaffoldResponseSchema = z.object({
5260
+ type: z.literal("project.scaffold.response"),
5261
+ payload: z.object({
5262
+ requestId: z.string(),
5263
+ // Registered project on success. Null whenever any step failed — the
5264
+ // daemon does not register a half-built directory.
5265
+ project: WorkspaceProjectDescriptorPayloadSchema.nullable(),
5266
+ // Absolute path of the created directory. Non-null even on a late failure
5267
+ // (e.g. push rejected) so the UI can tell the user what is on disk.
5268
+ path: z.string().nullable(),
5269
+ // Remote the repo was wired to, when one was created or cloned from.
5270
+ remoteUrl: z.string().nullable(),
5271
+ error: z.string().nullable(),
5272
+ // Unknown codes from newer daemons degrade to null; clients fall back to `error`.
5273
+ errorCode: z
5274
+ .enum([
5275
+ "parent_not_found",
5276
+ "invalid_name",
5277
+ "already_exists",
5278
+ "git_unavailable",
5279
+ "git_failed",
5280
+ "provider_unavailable",
5281
+ "remote_failed",
5282
+ "clone_failed",
5283
+ "register_failed",
5284
+ ])
5285
+ .nullish()
5286
+ .catch(null),
5287
+ // Terminal state of every step the daemon ran, in run order.
5288
+ steps: z.array(ProjectScaffoldStepSchema),
5289
+ }),
5290
+ });
5291
+ // Uncorrelated progress stream for an in-flight scaffold, keyed by the request's
5292
+ // requestId. Purely advisory: the response carries the authoritative step list,
5293
+ // so a client that ignores these still gets a correct result.
5294
+ export const ProjectScaffoldProgressSchema = z.object({
5295
+ type: z.literal("project.scaffold.progress"),
5296
+ payload: z.object({
5297
+ requestId: z.string(),
5298
+ step: ProjectScaffoldStepIdSchema,
5299
+ status: ProjectScaffoldStepStatusSchema,
5300
+ detail: z.string().nullable(),
5301
+ }),
5302
+ });
5303
+ export const HostingRepositorySummarySchema = z.object({
5304
+ // Provider-unique identifier, e.g. "owner/name" or "workspace/slug".
5305
+ fullName: z.string(),
5306
+ name: z.string(),
5307
+ owner: z.string(),
5308
+ cloneUrl: z.string(),
5309
+ isPrivate: z.boolean(),
5310
+ description: z.string().nullable(),
5311
+ // ISO-8601. Clients sort most-recent-first when present.
5312
+ updatedAt: z.string().nullable(),
5313
+ });
5314
+ export const HostingOwnerSummarySchema = z.object({
5315
+ // Value to send back as `owner` when creating a repository.
5316
+ id: z.string(),
5317
+ label: z.string(),
5318
+ // Open string: providers name this differently (org, workspace, team).
5319
+ kind: z.string(),
5320
+ });
5321
+ // COMPAT(projectScaffold): added in v0.6.9.
5322
+ export const HostingListRepositoriesResponseSchema = z.object({
5323
+ type: z.literal("hosting.list_repositories.response"),
5324
+ payload: z.object({
5325
+ requestId: z.string(),
5326
+ provider: GitHostingProviderIdWireSchema,
5327
+ repositories: z.array(HostingRepositorySummarySchema),
5328
+ error: z.string().nullable(),
5329
+ }),
5330
+ });
5331
+ // COMPAT(projectScaffold): added in v0.6.9.
5332
+ export const HostingListOwnersResponseSchema = z.object({
5333
+ type: z.literal("hosting.list_owners.response"),
5334
+ payload: z.object({
5335
+ requestId: z.string(),
5336
+ provider: GitHostingProviderIdWireSchema,
5337
+ owners: z.array(HostingOwnerSummarySchema),
5338
+ error: z.string().nullable(),
5339
+ }),
5340
+ });
4223
5341
  export const StartWorkspaceScriptResponseMessageSchema = z.object({
4224
5342
  type: z.literal("start_workspace_script_response"),
4225
5343
  payload: z.object({
@@ -4297,6 +5415,19 @@ export const WorkspaceArchivePreflightResponseSchema = z.object({
4297
5415
  error: z.string().nullable(),
4298
5416
  }),
4299
5417
  });
5418
+ // COMPAT(worktreeDiffBase): added in v0.6.8.
5419
+ export const WorktreeBaseRefSetResponseSchema = z.object({
5420
+ type: z.literal("worktree.baseRef.set.response"),
5421
+ payload: z.object({
5422
+ requestId: z.string(),
5423
+ workspaceId: z.string(),
5424
+ // The stored base branch after the write; null when the write failed.
5425
+ baseRef: z.string().nullable(),
5426
+ // The stored base is the repository default branch (no stacked-branch override).
5427
+ isDefault: z.boolean(),
5428
+ error: z.string().nullable(),
5429
+ }),
5430
+ });
4300
5431
  // A re-attachable Otto worktree surfaced by worktree.reattach.list.
4301
5432
  // COMPAT(worktreeReattach): added in v0.6.7.
4302
5433
  export const WorktreeReattachCandidateSchema = z.object({
@@ -4389,6 +5520,52 @@ export const AgentForkContextResponseMessageSchema = z.object({
4389
5520
  error: z.string().nullable(),
4390
5521
  }),
4391
5522
  });
5523
+ export const AgentQueueRemoveResponseMessageSchema = z.object({
5524
+ type: z.literal("agent.queue.remove.response"),
5525
+ payload: z.object({
5526
+ requestId: z.string(),
5527
+ agentId: z.string(),
5528
+ /**
5529
+ * The removed message's text, handed back so the composer can put it back
5530
+ * in the box for editing or re-send it right away. Null when the id was
5531
+ * already gone — the turn drained it while the tap was in flight.
5532
+ * Attachments are not echoed: the client that queued the message keeps its
5533
+ * own local copy keyed by `id` (see the composer's queued-attachment
5534
+ * sidecar), and a client that never queued it has nothing to restore.
5535
+ */
5536
+ removed: z
5537
+ .object({
5538
+ id: z.string(),
5539
+ text: z.string(),
5540
+ })
5541
+ .nullable(),
5542
+ error: z.string().nullable(),
5543
+ }),
5544
+ });
5545
+ export const AgentQueueReorderResponseMessageSchema = z.object({
5546
+ type: z.literal("agent.queue.reorder.response"),
5547
+ payload: z.object({
5548
+ requestId: z.string(),
5549
+ agentId: z.string(),
5550
+ /**
5551
+ * False when the id was already gone (the turn drained it while the tap was
5552
+ * in flight) or the entry was already at that position. The authoritative
5553
+ * order arrives on the agent snapshot either way, so a client only needs
5554
+ * this to decide whether to surface an error.
5555
+ */
5556
+ moved: z.boolean(),
5557
+ error: z.string().nullable(),
5558
+ }),
5559
+ });
5560
+ export const AgentQueueClearResponseMessageSchema = z.object({
5561
+ type: z.literal("agent.queue.clear.response"),
5562
+ payload: z.object({
5563
+ requestId: z.string(),
5564
+ agentId: z.string(),
5565
+ clearedCount: z.number().int().nonnegative(),
5566
+ error: z.string().nullable(),
5567
+ }),
5568
+ });
4392
5569
  export const CancelAgentResponseMessageSchema = z.object({
4393
5570
  type: z.literal("cancel_agent_response"),
4394
5571
  payload: z.object({
@@ -4443,6 +5620,13 @@ export const SendAgentMessageResponseMessageSchema = z.object({
4443
5620
  agentId: z.string(),
4444
5621
  accepted: z.boolean(),
4445
5622
  error: z.string().nullable(),
5623
+ // Set when the message was parked for the next turn rather than dispatched
5624
+ // (`delivery: "queue"` against a busy agent). `queuedMessageId` is the
5625
+ // entry's id in `AgentSnapshotPayload.queuedMessages` — the key the sender
5626
+ // uses to find its own entry again. Absent ⇒ dispatched now (or old daemon).
5627
+ // COMPAT(steerQueue): added in v0.6.8, drop the gate when floor >= v0.6.8.
5628
+ queued: z.boolean().optional(),
5629
+ queuedMessageId: z.string().optional(),
4446
5630
  }),
4447
5631
  });
4448
5632
  export const WaitForFinishResponseMessageSchema = z.object({
@@ -4711,6 +5895,12 @@ const CheckoutStatusCommonSchema = z.object({
4711
5895
  cwd: z.string(),
4712
5896
  error: CheckoutErrorSchema.nullable(),
4713
5897
  requestId: z.string(),
5898
+ // Daemon clock (epoch ms) at which the git-tracking fields below were measured.
5899
+ // One writer stamps it, so clients can compare two payloads and drop an
5900
+ // out-of-order push instead of clobbering newer git state.
5901
+ // COMPAT(checkoutStatusGitStateAt): added in v0.6.8; absent from older daemons.
5902
+ // Drop the optional marker when floor >= v0.6.8 (target 2027-01-24).
5903
+ gitStateAt: z.number().optional(),
4714
5904
  });
4715
5905
  const CheckoutStatusNotGitSchema = CheckoutStatusCommonSchema.extend({
4716
5906
  isGit: z.literal(false),
@@ -4867,6 +6057,12 @@ const CheckoutPrStatusPayloadSchema = z.object({
4867
6057
  });
4868
6058
  const CheckoutStatusUpdateMetadataSchema = z.object({
4869
6059
  prStatus: CheckoutPrStatusPayloadSchema.optional(),
6060
+ // True when the push refreshed only PR/check state (the hosting PR-status poll).
6061
+ // The git block on such a payload is an unrefreshed echo of the last snapshot,
6062
+ // so clients must apply `prStatus` and leave their git-tracking state alone.
6063
+ // COMPAT(checkoutStatusPrStatusOnly): added in v0.6.8; absent from older daemons.
6064
+ // Drop the default when floor >= v0.6.8 (target 2027-01-24).
6065
+ prStatusOnly: z.boolean().optional().default(false),
4870
6066
  });
4871
6067
  export const CheckoutStatusUpdateSchema = z.object({
4872
6068
  type: z.literal("checkout_status_update"),
@@ -5637,6 +6833,110 @@ export const FileWriteResponseSchema = z.object({
5637
6833
  requestId: z.string(),
5638
6834
  }),
5639
6835
  });
6836
+ /**
6837
+ * Create outcome. `exists` is its own status rather than an error string: it is
6838
+ * the one failure the client can act on (offer a different name) instead of
6839
+ * merely reporting.
6840
+ */
6841
+ export const FileCreateResultSchema = z.discriminatedUnion("status", [
6842
+ z.object({
6843
+ status: z.literal("ok"),
6844
+ // Echoed back normalized (forward slashes, workspace-relative) so the client
6845
+ // selects the entry it will actually see in the next listing.
6846
+ path: z.string(),
6847
+ kind: FileEntryKindSchema,
6848
+ modifiedAt: z.string(),
6849
+ size: z.number(),
6850
+ }),
6851
+ z.object({ status: z.literal("exists") }),
6852
+ z.object({ status: z.literal("error"), message: z.string() }),
6853
+ ]);
6854
+ export const FileCreateResponseSchema = z.object({
6855
+ type: z.literal("file.create.response"),
6856
+ payload: z.object({
6857
+ cwd: z.string(),
6858
+ path: z.string(),
6859
+ result: FileCreateResultSchema,
6860
+ requestId: z.string(),
6861
+ }),
6862
+ });
6863
+ /**
6864
+ * Delete outcome. `not_empty` means the target is a directory with children and
6865
+ * the request did not set `recursive` — nothing was removed, and the client can
6866
+ * re-ask with the stronger confirmation.
6867
+ */
6868
+ export const FileDeleteResultSchema = z.discriminatedUnion("status", [
6869
+ z.object({
6870
+ status: z.literal("ok"),
6871
+ path: z.string(),
6872
+ kind: FileEntryKindSchema,
6873
+ }),
6874
+ z.object({ status: z.literal("not_found") }),
6875
+ z.object({ status: z.literal("not_empty") }),
6876
+ z.object({ status: z.literal("error"), message: z.string() }),
6877
+ ]);
6878
+ export const FileDeleteResponseSchema = z.object({
6879
+ type: z.literal("file.delete.response"),
6880
+ payload: z.object({
6881
+ cwd: z.string(),
6882
+ path: z.string(),
6883
+ result: FileDeleteResultSchema,
6884
+ requestId: z.string(),
6885
+ }),
6886
+ });
6887
+ /** Rename/move outcome. `exists` means the destination was occupied; nothing moved. */
6888
+ export const FileRenameResultSchema = z.discriminatedUnion("status", [
6889
+ z.object({
6890
+ status: z.literal("ok"),
6891
+ from: z.string(),
6892
+ to: z.string(),
6893
+ kind: FileEntryKindSchema,
6894
+ }),
6895
+ z.object({ status: z.literal("not_found") }),
6896
+ z.object({ status: z.literal("exists") }),
6897
+ z.object({ status: z.literal("error"), message: z.string() }),
6898
+ ]);
6899
+ export const FileRenameResponseSchema = z.object({
6900
+ type: z.literal("file.rename.response"),
6901
+ payload: z.object({
6902
+ cwd: z.string(),
6903
+ path: z.string(),
6904
+ newPath: z.string(),
6905
+ result: FileRenameResultSchema,
6906
+ requestId: z.string(),
6907
+ }),
6908
+ });
6909
+ /**
6910
+ * A refine proposal: the whole rewritten text of each document the model chose
6911
+ * to change, keyed by the id the request minted. Documents it left alone are
6912
+ * simply absent, and ids the request never sent are dropped by the daemon.
6913
+ *
6914
+ * The client diffs each one against the base it pinned, so a truncated or
6915
+ * chatty answer shows up as a diff the user can refuse rather than as a
6916
+ * corrupted file.
6917
+ */
6918
+ export const FileRefineFileSchema = z.object({
6919
+ id: z.string().min(1),
6920
+ content: z.string(),
6921
+ });
6922
+ export const FileRefineResultSchema = z.discriminatedUnion("status", [
6923
+ z.object({
6924
+ status: z.literal("ok"),
6925
+ files: z.array(FileRefineFileSchema),
6926
+ }),
6927
+ z.object({
6928
+ status: z.literal("error"),
6929
+ message: z.string(),
6930
+ }),
6931
+ ]);
6932
+ export const FileRefineResponseSchema = z.object({
6933
+ type: z.literal("file.refine.response"),
6934
+ payload: z.object({
6935
+ cwd: z.string(),
6936
+ result: FileRefineResultSchema,
6937
+ requestId: z.string(),
6938
+ }),
6939
+ });
5640
6940
  export const FileWatchSubscribeResponseSchema = z.object({
5641
6941
  type: z.literal("file.watch.subscribe.response"),
5642
6942
  payload: z.object({
@@ -5685,6 +6985,370 @@ export const CodeSymbolsResponseSchema = z.object({
5685
6985
  requestId: z.string(),
5686
6986
  }),
5687
6987
  });
6988
+ /** 1-based, like `CodeSymbolLocation`. The end pair is present when the server gave a range. */
6989
+ export const CodeDefinitionLocationSchema = z.object({
6990
+ path: z.string(),
6991
+ line: z.number().int().positive(),
6992
+ column: z.number().int().positive(),
6993
+ endLine: z.number().int().positive().optional(),
6994
+ endColumn: z.number().int().positive().optional(),
6995
+ /**
6996
+ * Which registry row answered (`typescript`, `csharp`, …). The multi-hit picker
6997
+ * shows it, so a user looking at two candidates can tell whether a language server
6998
+ * resolved them or the name index guessed — which changes how much to trust the
6999
+ * list. Absent from old daemons.
7000
+ */
7001
+ serverId: z.string().optional(),
7002
+ });
7003
+ /**
7004
+ * Three-valued on purpose. `unavailable` (no server for this language on the host) and
7005
+ * `indexing` (the server is up but still building its project model) are different
7006
+ * answers to the user, and neither is "not found" — reporting either as an empty
7007
+ * result is how a working feature reads as broken.
7008
+ */
7009
+ export const CodeDefinitionStatusSchema = z.enum(["ok", "indexing", "unavailable"]);
7010
+ export const CodeDefinitionResponseSchema = z.object({
7011
+ type: z.literal("code.definition.response"),
7012
+ payload: z.object({
7013
+ cwd: z.string(),
7014
+ path: z.string(),
7015
+ status: CodeDefinitionStatusSchema,
7016
+ locations: z.array(CodeDefinitionLocationSchema),
7017
+ error: z.string().nullable(),
7018
+ requestId: z.string(),
7019
+ }),
7020
+ });
7021
+ export const CodeDocumentSyncResponseSchema = z.object({
7022
+ type: z.literal("code.document.sync.response"),
7023
+ payload: z.object({
7024
+ cwd: z.string(),
7025
+ path: z.string(),
7026
+ ok: z.boolean(),
7027
+ error: z.string().nullable(),
7028
+ requestId: z.string(),
7029
+ }),
7030
+ });
7031
+ export const CodeDocumentCloseResponseSchema = z.object({
7032
+ type: z.literal("code.document.close.response"),
7033
+ payload: z.object({
7034
+ cwd: z.string(),
7035
+ path: z.string(),
7036
+ ok: z.boolean(),
7037
+ error: z.string().nullable(),
7038
+ requestId: z.string(),
7039
+ }),
7040
+ });
7041
+ /** 1-based, like every other position on the wire. */
7042
+ export const CodeHoverRangeSchema = z.object({
7043
+ line: z.number().int().positive(),
7044
+ column: z.number().int().positive(),
7045
+ endLine: z.number().int().positive(),
7046
+ endColumn: z.number().int().positive(),
7047
+ });
7048
+ export const CodeHoverResponseSchema = z.object({
7049
+ type: z.literal("code.hover.response"),
7050
+ payload: z.object({
7051
+ cwd: z.string(),
7052
+ path: z.string(),
7053
+ status: CodeDefinitionStatusSchema,
7054
+ /** Markdown, or null when the server had nothing to say about this position. */
7055
+ markdown: z.string().nullable(),
7056
+ range: CodeHoverRangeSchema.nullable(),
7057
+ serverId: z.string().nullable(),
7058
+ error: z.string().nullable(),
7059
+ requestId: z.string(),
7060
+ }),
7061
+ });
7062
+ export const CodeReferencesResponseSchema = z.object({
7063
+ type: z.literal("code.references.response"),
7064
+ payload: z.object({
7065
+ cwd: z.string(),
7066
+ path: z.string(),
7067
+ status: CodeDefinitionStatusSchema,
7068
+ locations: z.array(CodeDefinitionLocationSchema),
7069
+ error: z.string().nullable(),
7070
+ requestId: z.string(),
7071
+ }),
7072
+ });
7073
+ export const CodeRenameEditSchema = z.object({
7074
+ line: z.number().int().positive(),
7075
+ column: z.number().int().positive(),
7076
+ endLine: z.number().int().positive(),
7077
+ endColumn: z.number().int().positive(),
7078
+ newText: z.string(),
7079
+ /**
7080
+ * The text this edit expects to replace. Carried so the dry run can show what is being
7081
+ * changed rather than only what it becomes — and, on the daemon side, so the run can tell
7082
+ * that a file moved under the plan. For a rename this is always one identifier.
7083
+ */
7084
+ oldText: z.string().default(""),
7085
+ });
7086
+ export const CodeRenameFilePlanSchema = z.object({
7087
+ path: z.string(),
7088
+ edits: z.array(CodeRenameEditSchema),
7089
+ });
7090
+ export const CodeRenamePreviewResponseSchema = z.object({
7091
+ type: z.literal("code.rename.preview.response"),
7092
+ payload: z.object({
7093
+ cwd: z.string(),
7094
+ path: z.string(),
7095
+ newName: z.string(),
7096
+ status: CodeDefinitionStatusSchema,
7097
+ /** Sorted by path, and by position within each file, so an audit reads in order. */
7098
+ files: z.array(CodeRenameFilePlanSchema),
7099
+ /** Blast radius, so the dry-run tab can lead with it. */
7100
+ fileCount: z.number().int().nonnegative(),
7101
+ editCount: z.number().int().nonnegative(),
7102
+ /**
7103
+ * Identity of this exact plan, echoed back on apply. Computed by the daemon so there is
7104
+ * one definition of "the same plan" rather than two that can drift apart.
7105
+ */
7106
+ planId: z.string().default(""),
7107
+ error: z.string().nullable(),
7108
+ requestId: z.string(),
7109
+ }),
7110
+ });
7111
+ /**
7112
+ * Five-valued, because the ways a rename can fail to happen are things a user needs told
7113
+ * apart: still loading, no server, the plan moved, or the server pointed outside the
7114
+ * workspace. Collapsing them into one failure is how "nothing happened" becomes unexplainable.
7115
+ */
7116
+ /**
7117
+ * Whether the run HAPPENED — deliberately not whether everything applied.
7118
+ *
7119
+ * A run where two of fourteen edits no longer fit is still a run that took place, and the
7120
+ * twelve that landed are real. Collapsing that into a failure would hide them, and hiding a
7121
+ * write is the one thing an auditable edit surface must never do. Per-edit fate lives in the
7122
+ * file outcomes; `complete` is the single-glance answer.
7123
+ */
7124
+ export const CodeRenameApplyStatusSchema = z.enum(["ok", "expired", "escaped"]);
7125
+ export const CodeRenameFileOutcomeKindSchema = z.enum(["applied", "partial", "failed"]);
7126
+ /** What happened to one file in a run. */
7127
+ export const CodeRenameFileOutcomeSchema = z.object({
7128
+ path: z.string(),
7129
+ kind: CodeRenameFileOutcomeKindSchema,
7130
+ appliedEdits: z.number().int().nonnegative(),
7131
+ skippedEdits: z.number().int().nonnegative(),
7132
+ /** Why, whenever anything was skipped or the file failed outright. */
7133
+ reason: z.string().nullable(),
7134
+ });
7135
+ export const CodeRenameUndoStatusSchema = z.enum(["ok", "expired"]);
7136
+ export const CodeRenameUndoFileKindSchema = z.enum(["restored", "changedSince", "failed"]);
7137
+ /**
7138
+ * What happened to one file during an undo. `changedSince` is the important one: the file was
7139
+ * edited after the run, so restoring would have destroyed that work and it was left alone.
7140
+ */
7141
+ export const CodeRenameUndoFileSchema = z.object({
7142
+ path: z.string(),
7143
+ kind: CodeRenameUndoFileKindSchema,
7144
+ reason: z.string().nullable(),
7145
+ });
7146
+ export const CodeRenameUndoResponseSchema = z.object({
7147
+ type: z.literal("code.rename.undo.response"),
7148
+ payload: z.object({
7149
+ cwd: z.string(),
7150
+ runId: z.string(),
7151
+ status: CodeRenameUndoStatusSchema,
7152
+ files: z.array(CodeRenameUndoFileSchema),
7153
+ restoredFiles: z.number().int().nonnegative(),
7154
+ /** True only when every file the run wrote was put back. */
7155
+ complete: z.boolean(),
7156
+ error: z.string().nullable(),
7157
+ requestId: z.string(),
7158
+ }),
7159
+ });
7160
+ export const CodeRenameApplyResponseSchema = z.object({
7161
+ type: z.literal("code.rename.apply.response"),
7162
+ payload: z.object({
7163
+ cwd: z.string(),
7164
+ path: z.string(),
7165
+ newName: z.string(),
7166
+ status: CodeRenameApplyStatusSchema,
7167
+ /** Identity of this run, for undo. Null when nothing ran. */
7168
+ runId: z.string().nullable(),
7169
+ files: z.array(CodeRenameFileOutcomeSchema),
7170
+ appliedFiles: z.number().int().nonnegative(),
7171
+ appliedEdits: z.number().int().nonnegative(),
7172
+ skippedEdits: z.number().int().nonnegative(),
7173
+ /** True only when every planned edit landed. */
7174
+ complete: z.boolean(),
7175
+ error: z.string().nullable(),
7176
+ requestId: z.string(),
7177
+ }),
7178
+ });
7179
+ export const LspLanguageStateSchema = z.object({
7180
+ id: z.string(),
7181
+ enabled: z.boolean(),
7182
+ /** Whether the host can actually supply this server right now. */
7183
+ installed: z.boolean(),
7184
+ running: z.boolean(),
7185
+ /** Which discovery rung supplied it (`workspaceBin` / `bundled` / `path`), or null. */
7186
+ rung: z.string().nullable(),
7187
+ bin: z.string(),
7188
+ extensions: z.array(z.string()),
7189
+ /** Plain-words index cost, so the toggle states its own price. */
7190
+ indexCost: z.string(),
7191
+ });
7192
+ export const LspRunningServerSchema = z.object({
7193
+ rootPath: z.string(),
7194
+ serverId: z.string(),
7195
+ uptimeMs: z.number(),
7196
+ lastUsedAt: z.number(),
7197
+ });
7198
+ export const LspServersListResponseSchema = z.object({
7199
+ type: z.literal("lsp.servers.list.response"),
7200
+ payload: z.object({
7201
+ cwd: z.string(),
7202
+ languages: z.array(LspLanguageStateSchema),
7203
+ running: z.array(LspRunningServerSchema),
7204
+ error: z.string().nullable(),
7205
+ requestId: z.string(),
7206
+ }),
7207
+ });
7208
+ export const LspServerStopResponseSchema = z.object({
7209
+ type: z.literal("lsp.server.stop.response"),
7210
+ payload: z.object({
7211
+ rootPath: z.string(),
7212
+ serverId: z.string(),
7213
+ ok: z.boolean(),
7214
+ error: z.string().nullable(),
7215
+ requestId: z.string(),
7216
+ }),
7217
+ });
7218
+ /**
7219
+ * Solution view responses (projects/solution-view).
7220
+ *
7221
+ * COMPAT(solutionView): added in v0.6.8, drop the gate when daemon floor >= v0.6.8.
7222
+ */
7223
+ export const SolutionFormatSchema = z.enum(["sln", "slnx"]);
7224
+ /** One solution a workspace contains. Enough to populate the switcher's picker, nothing more. */
7225
+ export const SolutionRefSchema = z.object({
7226
+ /** Workspace-relative, forward slashes — the identity used by every later request. */
7227
+ path: z.string(),
7228
+ /** File name without the extension, which is what a .NET developer calls the solution. */
7229
+ name: z.string(),
7230
+ format: SolutionFormatSchema,
7231
+ });
7232
+ export const CodeSolutionListResponseSchema = z.object({
7233
+ type: z.literal("code.solution.list.response"),
7234
+ payload: z.object({
7235
+ cwd: z.string(),
7236
+ /**
7237
+ * Empty means the switcher never appears and the Files tab behaves exactly as it does today.
7238
+ * That is also what a disabled feature, a host with no .NET SDK, and a workspace with no
7239
+ * solution all return — the client has one silent case to handle, not four.
7240
+ */
7241
+ solutions: z.array(SolutionRefSchema),
7242
+ error: z.string().nullable(),
7243
+ requestId: z.string(),
7244
+ }),
7245
+ });
7246
+ /**
7247
+ * Solution structure is flat on the wire with parent links, not nested.
7248
+ *
7249
+ * A recursive payload would have to be walked to be used, and every consumer would write that
7250
+ * walk again; the file explorer already turns a flat listing plus an expanded-path set into rows,
7251
+ * so this hands it the same shape it already consumes.
7252
+ */
7253
+ export const SolutionTreeFolderSchema = z.object({
7254
+ /** Solution-internal, e.g. `/Src/`. Folders are virtual: they have no filesystem location. */
7255
+ path: z.string(),
7256
+ name: z.string(),
7257
+ parentPath: z.string().nullable(),
7258
+ });
7259
+ export const SolutionTreeProjectSchema = z.object({
7260
+ id: z.string(),
7261
+ name: z.string(),
7262
+ /**
7263
+ * Workspace-relative when the project sits inside the workspace, absolute (forward-slashed)
7264
+ * when it does not. `outsideWorkspace` says which, so nothing has to guess by inspecting the
7265
+ * string.
7266
+ */
7267
+ path: z.string(),
7268
+ /**
7269
+ * A project the solution names outside the workspace root. Shown and opened like any other —
7270
+ * the solution file is the authority naming it, so this is not free browsing — but editing one
7271
+ * warns, and it is absent from every git surface. See docs/solution-view.md.
7272
+ */
7273
+ outsideWorkspace: z.boolean(),
7274
+ /** The solution folder containing it, or null for a project at the solution root. */
7275
+ folderPath: z.string().nullable(),
7276
+ /** Project type GUID, lowercased. Absent on old daemons. */
7277
+ typeId: z.string().optional(),
7278
+ });
7279
+ export const CodeSolutionGetTreeResponseSchema = z.object({
7280
+ type: z.literal("code.solution.get_tree.response"),
7281
+ payload: z.object({
7282
+ cwd: z.string(),
7283
+ solutionPath: z.string(),
7284
+ name: z.string().default(""),
7285
+ format: SolutionFormatSchema.default("sln"),
7286
+ folders: z.array(SolutionTreeFolderSchema),
7287
+ projects: z.array(SolutionTreeProjectSchema),
7288
+ /** Solution configurations and platforms — first-class .NET concepts no CLI surfaces. */
7289
+ buildTypes: z.array(z.string()),
7290
+ platforms: z.array(z.string()),
7291
+ error: z.string().nullable(),
7292
+ requestId: z.string(),
7293
+ }),
7294
+ });
7295
+ /**
7296
+ * Three-valued for the same reason the code-intelligence family is: "the host cannot supply
7297
+ * this", "MSBuild refused this project", and "here are its files" are different things to tell a
7298
+ * user, and reporting the first two as an empty file list is how a working feature reads as
7299
+ * broken. One project that fails must not blank the tree, so this status is per project.
7300
+ */
7301
+ export const SolutionProjectStatusSchema = z.enum(["ok", "failed", "unavailable"]);
7302
+ /**
7303
+ * One entry in a project's evaluated membership, flat with parent links like the folders above.
7304
+ *
7305
+ * `isImplicit` is what a filesystem tree structurally cannot show and what Phase 2 turns on: an
7306
+ * item contributed by the SDK's default globs is one that creating the file already adds, while
7307
+ * an item the project file itself declares needs a real `.csproj` edit.
7308
+ */
7309
+ export const SolutionProjectNodeSchema = z.discriminatedUnion("kind", [
7310
+ z.object({
7311
+ kind: z.literal("directory"),
7312
+ id: z.string(),
7313
+ parentId: z.string().nullable(),
7314
+ name: z.string(),
7315
+ path: z.string(),
7316
+ outsideWorkspace: z.boolean(),
7317
+ }),
7318
+ z.object({
7319
+ kind: z.literal("file"),
7320
+ id: z.string(),
7321
+ parentId: z.string().nullable(),
7322
+ name: z.string(),
7323
+ path: z.string(),
7324
+ outsideWorkspace: z.boolean(),
7325
+ /** `Compile`, `Content`, `EmbeddedResource`, … — MSBuild's own item type. */
7326
+ itemType: z.string(),
7327
+ isImplicit: z.boolean(),
7328
+ }),
7329
+ ]);
7330
+ export const SolutionPackageReferenceSchema = z.object({
7331
+ name: z.string(),
7332
+ version: z.string().nullable(),
7333
+ });
7334
+ export const CodeSolutionLoadProjectResponseSchema = z.object({
7335
+ type: z.literal("code.solution.load_project.response"),
7336
+ payload: z.object({
7337
+ cwd: z.string(),
7338
+ solutionPath: z.string(),
7339
+ projectPath: z.string(),
7340
+ status: SolutionProjectStatusSchema,
7341
+ nodes: z.array(SolutionProjectNodeSchema),
7342
+ projectReferences: z.array(z.string()),
7343
+ packageReferences: z.array(SolutionPackageReferenceSchema),
7344
+ targetFrameworks: z.array(z.string()),
7345
+ outputType: z.string().nullable(),
7346
+ isSdkStyle: z.boolean(),
7347
+ /** MSBuild's own message when `status` is `failed`, verbatim. */
7348
+ error: z.string().nullable(),
7349
+ requestId: z.string(),
7350
+ }),
7351
+ });
5688
7352
  export const CodeOutlineResponseSchema = z.object({
5689
7353
  type: z.literal("code.outline.response"),
5690
7354
  payload: z.object({
@@ -6113,12 +7777,15 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
6113
7777
  FetchRecentProviderSessionsResponseMessageSchema,
6114
7778
  FetchWorkspacesResponseMessageSchema,
6115
7779
  ProjectAddResponseSchema,
7780
+ ProjectScaffoldResponseSchema,
7781
+ ProjectScaffoldProgressSchema,
6116
7782
  OpenProjectResponseMessageSchema,
6117
7783
  StartWorkspaceScriptResponseMessageSchema,
6118
7784
  LegacyListAvailableEditorsResponseMessageSchema,
6119
7785
  LegacyOpenInEditorResponseMessageSchema,
6120
7786
  ArchiveWorkspaceResponseMessageSchema,
6121
7787
  WorkspaceArchivePreflightResponseSchema,
7788
+ WorktreeBaseRefSetResponseSchema,
6122
7789
  WorktreeReattachListResponseSchema,
6123
7790
  WorktreeReattachResponseSchema,
6124
7791
  FetchAgentResponseMessageSchema,
@@ -6148,6 +7815,9 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
6148
7815
  SetAgentThinkingResponseMessageSchema,
6149
7816
  SetAgentFeatureResponseMessageSchema,
6150
7817
  AgentDetachResponseMessageSchema,
7818
+ AgentQueueRemoveResponseMessageSchema,
7819
+ AgentQueueReorderResponseMessageSchema,
7820
+ AgentQueueClearResponseMessageSchema,
6151
7821
  AgentSubagentStopResponseMessageSchema,
6152
7822
  AgentBackgroundTaskStopResponseMessageSchema,
6153
7823
  AgentBackgroundTaskClearResponseMessageSchema,
@@ -6160,6 +7830,7 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
6160
7830
  AgentRewindResponseMessageSchema,
6161
7831
  UpdateAgentResponseMessageSchema,
6162
7832
  ProjectRenameResponseSchema,
7833
+ ProjectUpdatedNotificationSchema,
6163
7834
  ProjectRemoveResponseSchema,
6164
7835
  ProjectLinksListResponseSchema,
6165
7836
  ProjectLinksSetResponseSchema,
@@ -6170,6 +7841,7 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
6170
7841
  AgentPermissionRequestMessageSchema,
6171
7842
  AgentPermissionResolvedMessageSchema,
6172
7843
  AgentDeletedMessageSchema,
7844
+ HistoryAgentsClearArchivedResponseSchema,
6173
7845
  AgentArchivedMessageSchema,
6174
7846
  CloseItemsResponseSchema,
6175
7847
  CheckoutStatusResponseSchema,
@@ -6191,11 +7863,16 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
6191
7863
  RunsGateRespondResponseSchema,
6192
7864
  RunsCancelResponseSchema,
6193
7865
  RunsClearResponseSchema,
7866
+ RunsDeleteResponseSchema,
6194
7867
  RunsClearedNotificationSchema,
6195
7868
  RunsGraphsListResponseSchema,
6196
7869
  RunsGraphsSaveResponseSchema,
6197
7870
  RunsGraphsDeleteResponseSchema,
6198
7871
  RunsGraphsChangedNotificationSchema,
7872
+ RunsTemplatesListResponseSchema,
7873
+ RunsTemplatesSaveResponseSchema,
7874
+ RunsTemplatesDeleteResponseSchema,
7875
+ RunsTemplatesChangedNotificationSchema,
6199
7876
  RunsStartResponseSchema,
6200
7877
  CheckoutMergeResponseSchema,
6201
7878
  CheckoutMergeFromBaseResponseSchema,
@@ -6222,6 +7899,8 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
6222
7899
  GitHubSearchResponseSchema,
6223
7900
  HostingSearchResponseSchema,
6224
7901
  HostingAuthStatusResponseSchema,
7902
+ HostingListRepositoriesResponseSchema,
7903
+ HostingListOwnersResponseSchema,
6225
7904
  DirectorySuggestionsResponseSchema,
6226
7905
  OttoWorktreeListResponseSchema,
6227
7906
  OttoWorktreeArchiveResponseSchema,
@@ -6231,6 +7910,10 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
6231
7910
  FileDownloadTokenResponseSchema,
6232
7911
  FileUploadResponseSchema,
6233
7912
  FileWriteResponseSchema,
7913
+ FileCreateResponseSchema,
7914
+ FileDeleteResponseSchema,
7915
+ FileRenameResponseSchema,
7916
+ FileRefineResponseSchema,
6234
7917
  FileWatchSubscribeResponseSchema,
6235
7918
  FileWatchUnsubscribeResponseSchema,
6236
7919
  FileWatchEventSchema,
@@ -6240,6 +7923,19 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
6240
7923
  CodeListFilesResponseSchema,
6241
7924
  CodeSymbolsResponseSchema,
6242
7925
  CodeOutlineResponseSchema,
7926
+ CodeDefinitionResponseSchema,
7927
+ CodeDocumentSyncResponseSchema,
7928
+ CodeDocumentCloseResponseSchema,
7929
+ CodeHoverResponseSchema,
7930
+ CodeReferencesResponseSchema,
7931
+ CodeRenamePreviewResponseSchema,
7932
+ CodeRenameApplyResponseSchema,
7933
+ CodeRenameUndoResponseSchema,
7934
+ LspServersListResponseSchema,
7935
+ LspServerStopResponseSchema,
7936
+ CodeSolutionListResponseSchema,
7937
+ CodeSolutionGetTreeResponseSchema,
7938
+ CodeSolutionLoadProjectResponseSchema,
6243
7939
  ListProviderModelsResponseMessageSchema,
6244
7940
  ListProviderModesResponseMessageSchema,
6245
7941
  ListProviderFeaturesResponseMessageSchema,
@@ -6252,6 +7948,11 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
6252
7948
  StatsActivityGetResponseMessageSchema,
6253
7949
  ContextReportGetResponseMessageSchema,
6254
7950
  ContextEdgeConvertResponseMessageSchema,
7951
+ ContextFindingsFixResponseMessageSchema,
7952
+ PersonalityMemoryListResponseMessageSchema,
7953
+ PersonalityMemoryUpdateResponseMessageSchema,
7954
+ PersonalityMemoryTransferResponseMessageSchema,
7955
+ PersonalityMemoryStatsResponseMessageSchema,
6255
7956
  StatsActivityResetResponseMessageSchema,
6256
7957
  UsageLogGetResponseMessageSchema,
6257
7958
  ActivityStatsChangedSchema,