@inflatable-cookie/longhorn 0.5.0 → 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.
Files changed (167) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -7
  3. package/src/agent-control/generated/protocol.ts +228 -0
  4. package/src/agent-control/index.ts +1 -5
  5. package/src/agent-control/inject.ts +4 -1
  6. package/src/agent-control/selection.ts +42 -25
  7. package/src/agent-control/shim.ts +428 -198
  8. package/src/bridge/direct.ts +1 -1
  9. package/src/bridge/generated/fields.ts +4 -3
  10. package/src/bridge/generated/protocol.ts +62 -7
  11. package/src/bridge/generated/variant-fields.ts +1 -1
  12. package/src/bridge/job.ts +49 -12
  13. package/src/bridge/loopback.ts +7 -25
  14. package/src/bridge/operation.ts +13 -43
  15. package/src/bridge/router.ts +10 -23
  16. package/src/bridge/runtime/connection.ts +78 -109
  17. package/src/bridge/runtime/policy.ts +8 -28
  18. package/src/bridge/runtime/retry.ts +6 -18
  19. package/src/bridge/session.ts +4 -14
  20. package/src/bridge/stream/connection.ts +24 -55
  21. package/src/bridge/stream/source.ts +2 -6
  22. package/src/bridge/stream/tracker.ts +12 -12
  23. package/src/bridge/supervision.ts +104 -97
  24. package/src/bridge/validation/base.ts +21 -63
  25. package/src/bridge/validation/jobs.ts +11 -25
  26. package/src/bridge/validation/negotiation.ts +28 -43
  27. package/src/bridge/validation/operations.ts +29 -65
  28. package/src/bridge/validation/streams.ts +3 -10
  29. package/src/commands/client.ts +37 -28
  30. package/src/commands/controller.ts +119 -96
  31. package/src/commands/generated/fields.ts +7 -6
  32. package/src/commands/generated/protocol.ts +28 -1
  33. package/src/commands/generated/variant-fields.ts +1 -1
  34. package/src/commands/keyboard.ts +94 -100
  35. package/src/commands/physical-code.ts +11 -0
  36. package/src/commands/ports.ts +8 -13
  37. package/src/commands/projectors.ts +100 -75
  38. package/src/commands/validation.ts +434 -241
  39. package/src/config/client.ts +9 -22
  40. package/src/config/generated/base.ts +22 -6
  41. package/src/config/generated/fields.ts +4 -3
  42. package/src/config/generated/label-template.ts +1 -1
  43. package/src/config/generated/labels.ts +1 -1
  44. package/src/config/generated/protocol.ts +1 -1
  45. package/src/config/generated/restore.ts +35 -12
  46. package/src/config/generated/variant-fields.ts +1 -1
  47. package/src/config/names.ts +6 -12
  48. package/src/config/validation/commands.ts +11 -25
  49. package/src/config/validation/outcomes.ts +163 -70
  50. package/src/config/validation/primitives.ts +35 -80
  51. package/src/config/validation/projection.ts +100 -128
  52. package/src/core/connection.ts +187 -83
  53. package/src/core/controller-lifecycle.ts +144 -0
  54. package/src/core/generated/identifiers.ts +4 -0
  55. package/src/core/identifiers.ts +40 -0
  56. package/src/core/index.ts +10 -1
  57. package/src/core/json-value.ts +58 -0
  58. package/src/core/listeners.ts +35 -0
  59. package/src/core/record.ts +80 -0
  60. package/src/core/transport.ts +9 -11
  61. package/src/core/wire-copy.ts +7 -0
  62. package/src/history/client.ts +11 -13
  63. package/src/history/controller.ts +106 -108
  64. package/src/history/direct.ts +1 -3
  65. package/src/history/generated/fields.ts +4 -3
  66. package/src/history/generated/protocol.ts +8 -5
  67. package/src/history/generated/variant-fields.ts +1 -1
  68. package/src/history/ports.ts +7 -4
  69. package/src/history/serialized.ts +9 -13
  70. package/src/history/validation.ts +69 -75
  71. package/src/history-tree/client.ts +89 -11
  72. package/src/history-tree/controller.ts +380 -96
  73. package/src/history-tree/direct.ts +3 -1
  74. package/src/history-tree/generated/fields.ts +5 -3
  75. package/src/history-tree/generated/protocol.ts +43 -7
  76. package/src/history-tree/generated/variant-fields.ts +7 -1
  77. package/src/history-tree/ports.ts +12 -5
  78. package/src/history-tree/serialized.ts +39 -11
  79. package/src/history-tree/validation.ts +286 -78
  80. package/src/layout/generated/protocol.ts +4 -3
  81. package/src/layout/generated/variant-fields.ts +47 -0
  82. package/src/layout/index.ts +1 -1
  83. package/src/layout/ratio.ts +10 -9
  84. package/src/layout/validation.ts +98 -32
  85. package/src/layout/visibility.ts +1 -2
  86. package/src/licence/client.ts +48 -7
  87. package/src/licence/controller.ts +127 -70
  88. package/src/licence/direct.ts +3 -1
  89. package/src/licence/generated/fields.ts +4 -3
  90. package/src/licence/generated/key-conformance.json +28 -0
  91. package/src/licence/generated/protocol.ts +9 -5
  92. package/src/licence/generated/variant-fields.ts +1 -1
  93. package/src/licence/key.ts +42 -18
  94. package/src/licence/ports.ts +10 -3
  95. package/src/licence/serialized.ts +32 -9
  96. package/src/licence/validation.ts +134 -43
  97. package/src/native-content/client.ts +207 -234
  98. package/src/native-content/generated/fields.ts +6 -6
  99. package/src/native-content/generated/protocol.ts +16 -5
  100. package/src/native-content/generated/variant-fields.ts +1 -1
  101. package/src/native-content/ports.ts +11 -16
  102. package/src/native-content/serialized.ts +12 -19
  103. package/src/native-content/validation/base.ts +57 -80
  104. package/src/native-content/validation/messages.ts +24 -35
  105. package/src/native-content/validation/state.ts +31 -33
  106. package/src/notifications/client.ts +85 -51
  107. package/src/notifications/controller.ts +400 -145
  108. package/src/notifications/direct.ts +3 -1
  109. package/src/notifications/generated/fields.ts +4 -3
  110. package/src/notifications/generated/labels.ts +1 -1
  111. package/src/notifications/generated/protocol.ts +5 -1
  112. package/src/notifications/generated/variant-fields.ts +1 -1
  113. package/src/notifications/ports.ts +9 -4
  114. package/src/notifications/serialized.ts +11 -9
  115. package/src/notifications/tone.ts +1 -1
  116. package/src/notifications/validation.ts +165 -71
  117. package/src/operation/bridge.ts +187 -60
  118. package/src/operation/client.ts +48 -62
  119. package/src/operation/controller.ts +67 -97
  120. package/src/operation/direct.ts +1 -3
  121. package/src/operation/generated/fields.ts +4 -3
  122. package/src/operation/generated/labels.ts +1 -1
  123. package/src/operation/generated/protocol.ts +5 -1
  124. package/src/operation/generated/variant-fields.ts +1 -1
  125. package/src/operation/ports.ts +12 -10
  126. package/src/operation/serialized.ts +8 -9
  127. package/src/operation/validation.ts +189 -104
  128. package/src/settings/client.ts +11 -44
  129. package/src/settings/connection.ts +35 -53
  130. package/src/settings/generated/fields.ts +5 -4
  131. package/src/settings/generated/protocol.ts +14 -5
  132. package/src/settings/generated/variant-fields.ts +1 -1
  133. package/src/settings/names.ts +2 -4
  134. package/src/settings/registry.ts +23 -25
  135. package/src/settings/validation/authority.ts +21 -19
  136. package/src/settings/validation/command.ts +22 -41
  137. package/src/settings/validation/error.ts +2 -8
  138. package/src/settings/validation/primitives.ts +46 -97
  139. package/src/settings/validation/projection.ts +8 -24
  140. package/src/settings/validation/registry.ts +33 -79
  141. package/src/surface-transfer/client.ts +6 -18
  142. package/src/surface-transfer/generated/fields.ts +3 -3
  143. package/src/surface-transfer/generated/protocol.ts +3 -3
  144. package/src/surface-transfer/generated/variant-fields.ts +1 -1
  145. package/src/surface-transfer/validation.ts +91 -86
  146. package/src/surfaces/client.ts +33 -55
  147. package/src/surfaces/generated/fields.ts +3 -3
  148. package/src/surfaces/generated/protocol.ts +1 -1
  149. package/src/surfaces/generated/variant-fields.ts +1 -1
  150. package/src/surfaces/validation.ts +227 -99
  151. package/src/transfer/client.ts +26 -60
  152. package/src/transfer/connection.ts +29 -51
  153. package/src/transfer/generated/fields.ts +7 -6
  154. package/src/transfer/generated/protocol.ts +13 -5
  155. package/src/transfer/generated/variant-fields.ts +1 -1
  156. package/src/transfer/index.ts +8 -1
  157. package/src/transfer/payload.ts +20 -35
  158. package/src/transfer/validation.ts +169 -119
  159. package/src/update/client.ts +86 -9
  160. package/src/update/controller.ts +264 -116
  161. package/src/update/direct.ts +3 -1
  162. package/src/update/generated/fields.ts +5 -4
  163. package/src/update/generated/protocol.ts +25 -9
  164. package/src/update/generated/variant-fields.ts +4 -2
  165. package/src/update/ports.ts +14 -6
  166. package/src/update/serialized.ts +36 -10
  167. package/src/update/validation.ts +118 -48
@@ -1,6 +1,7 @@
1
+ import { ControllerLifecycle } from "../core/controller-lifecycle.ts";
1
2
  import { CommandClient } from "./client.ts";
3
+ import { COMMAND_KEYMAP_PROTOCOL_VERSION } from "./generated/protocol.ts";
2
4
  import type {
3
- CommandArguments,
4
5
  CommandInvocation,
5
6
  CommandKeymapMutationResult,
6
7
  CommandKeymapPatch,
@@ -13,15 +14,9 @@ import type {
13
14
  CommandExecutionOutcome,
14
15
  CommandExecutionSource,
15
16
  CommandPorts,
16
- CommandUnlisten,
17
17
  } from "./ports.ts";
18
- import {
19
- joinCommandState,
20
- projectCommandSurfaces,
21
- searchCommands,
22
- type CommandJoinedState,
23
- type CommandSurfaceProjection,
24
- } from "./projectors.ts";
18
+ import { joinCommandState, projectCommandSurfaces, searchCommands } from "./projectors.ts";
19
+ import type { CommandJoinedState, CommandSurfaceProjection } from "./projectors.ts";
25
20
 
26
21
  export type CommandControllerStatus =
27
22
  | { readonly kind: "idle" }
@@ -47,13 +42,18 @@ export type CommandMutationStatus =
47
42
  | { readonly kind: "conflict"; readonly detail: string }
48
43
  | { readonly kind: "failed"; readonly error: unknown };
49
44
 
45
+ /** The newest search failed. The loaded commands stay authoritative. */
46
+ export interface CommandSearchFailure {
47
+ readonly error: unknown;
48
+ }
49
+
50
50
  export interface CommandControllerOptions {
51
51
  readonly ports: CommandPorts;
52
52
  readonly platform: CommandPlatform;
53
53
  readonly search?: (
54
54
  records: CommandJoinedState["catalogue"]["commands"],
55
55
  query: string,
56
- ) => Promise<readonly CommandSearchHit[]>;
56
+ ) => Promise<ReadonlyArray<CommandSearchHit>>;
57
57
  }
58
58
 
59
59
  export class CommandController {
@@ -65,21 +65,19 @@ export class CommandController {
65
65
  #mutation: CommandMutationStatus = { kind: "idle" };
66
66
  #model: CommandJoinedState | undefined;
67
67
  #projection: CommandSurfaceProjection | undefined;
68
- #searchHits: readonly CommandSearchHit[] = [];
68
+ #searchHits: ReadonlyArray<CommandSearchHit> = [];
69
+ #searchFailure: CommandSearchFailure | undefined;
69
70
  #query = "";
70
71
  #draft: CommandKeymapPatch | undefined;
71
- #unlisten: CommandUnlisten[] = [];
72
- #lifecycleRevision = 0;
73
72
  #loadRevision = 0;
73
+ #mutationRevision = 0;
74
74
  #searchRevision = 0;
75
- #started = false;
75
+ readonly #lifecycle = new ControllerLifecycle();
76
76
 
77
77
  constructor(options: CommandControllerOptions) {
78
78
  this.#client = new CommandClient(options.ports);
79
79
  this.#platform = options.platform;
80
- this.#search =
81
- options.search ??
82
- (async (records, query) => searchCommands(records, query));
80
+ this.#search = options.search ?? (async (records, query) => searchCommands(records, query));
83
81
  }
84
82
 
85
83
  get status(): CommandControllerStatus {
@@ -102,10 +100,14 @@ export class CommandController {
102
100
  return this.#query;
103
101
  }
104
102
 
105
- get searchHits(): readonly CommandSearchHit[] {
103
+ get searchHits(): ReadonlyArray<CommandSearchHit> {
106
104
  return this.#searchHits;
107
105
  }
108
106
 
107
+ get searchFailure(): CommandSearchFailure | undefined {
108
+ return this.#searchFailure;
109
+ }
110
+
109
111
  get draft(): CommandKeymapPatch | undefined {
110
112
  return this.#draft;
111
113
  }
@@ -119,55 +121,56 @@ export class CommandController {
119
121
  return () => this.#observers.delete(observer);
120
122
  }
121
123
 
122
- async start(): Promise<void> {
123
- if (this.#started) return;
124
- this.#started = true;
125
- const lifecycleRevision = ++this.#lifecycleRevision;
126
- this.#setStatus({ kind: "loading" });
127
- try {
128
- const unlisten = await this.#client.listen(() => {
129
- void this.refresh();
130
- });
131
- if (
132
- !this.#started ||
133
- lifecycleRevision !== this.#lifecycleRevision
134
- ) {
135
- await disposeAll(unlisten);
136
- return;
137
- }
138
- this.#unlisten.push(...unlisten);
139
- await this.refresh();
140
- } catch (error) {
141
- if (
142
- this.#started &&
143
- lifecycleRevision === this.#lifecycleRevision
144
- ) {
145
- this.#setStatus({ kind: "failed", error });
146
- }
147
- }
124
+ start(): Promise<void> {
125
+ return this.#lifecycle.start({
126
+ loading: () => this.#setStatus({ kind: "loading" }),
127
+ connect: async ({ isCurrent, own }) => {
128
+ const unlisten = await this.#client.listen(() => {
129
+ if (isCurrent()) {
130
+ void this.refresh();
131
+ }
132
+ });
133
+ await own(...unlisten);
134
+ if (isCurrent()) {
135
+ await this.refresh();
136
+ }
137
+ },
138
+ failed: (error) => this.#setStatus({ kind: "failed", error }),
139
+ });
148
140
  }
149
141
 
150
- async stop(): Promise<void> {
151
- this.#started = false;
152
- this.#lifecycleRevision += 1;
153
- this.#loadRevision += 1;
154
- this.#searchRevision += 1;
155
- const unlisten = this.#unlisten.splice(0);
156
- await disposeAll(unlisten);
157
- this.#model = undefined;
158
- this.#projection = undefined;
159
- this.#searchHits = [];
160
- this.#query = "";
161
- this.#draft = undefined;
162
- this.#mutation = { kind: "idle" };
163
- this.#setStatus({ kind: "idle" });
142
+ /** Replaces the current subscription, including after a reported failure. */
143
+ restart(): Promise<void> {
144
+ return this.#lifecycle.restart(
145
+ this.status,
146
+ () => this.stop(),
147
+ () => this.start(),
148
+ );
149
+ }
150
+
151
+ stop(): Promise<void> {
152
+ return this.#lifecycle.stop(() => {
153
+ this.#loadRevision += 1;
154
+ this.#searchRevision += 1;
155
+ this.#mutationRevision += 1;
156
+ this.#model = undefined;
157
+ this.#projection = undefined;
158
+ this.#searchHits = [];
159
+ this.#searchFailure = undefined;
160
+ this.#query = "";
161
+ this.#draft = undefined;
162
+ this.#mutation = { kind: "idle" };
163
+ this.#setStatus({ kind: "idle" });
164
+ });
164
165
  }
165
166
 
166
167
  async refresh(): Promise<void> {
167
168
  const revision = ++this.#loadRevision;
168
169
  try {
169
170
  const loaded = await this.#client.load();
170
- if (!this.#started || revision !== this.#loadRevision) return;
171
+ if (!this.#lifecycle.active || revision !== this.#loadRevision) {
172
+ return;
173
+ }
171
174
  if (loaded.keymap.status === "recovery") {
172
175
  this.#model = undefined;
173
176
  this.#projection = undefined;
@@ -187,34 +190,45 @@ export class CommandController {
187
190
  return;
188
191
  }
189
192
  this.#install(
190
- joinCommandState(
191
- loaded.catalogue,
192
- loaded.keymap.snapshot,
193
- loaded.availability,
194
- ),
193
+ joinCommandState(loaded.catalogue, loaded.keymap.snapshot, loaded.availability),
195
194
  );
196
195
  this.#setStatus({ kind: "ready" });
197
- await this.search(this.#query);
198
196
  } catch (error) {
199
- if (this.#started && revision === this.#loadRevision) {
197
+ if (this.#lifecycle.active && revision === this.#loadRevision) {
200
198
  this.#setStatus({ kind: "failed", error });
201
199
  }
200
+ return;
202
201
  }
202
+ // A consumer search is not part of the load. `search` records its failure
203
+ // in `searchFailure`, so the rejection has nowhere further to go here.
204
+ await this.search(this.#query).catch(() => {});
203
205
  }
204
206
 
205
- async search(query: string): Promise<readonly CommandSearchHit[]> {
207
+ async search(query: string): Promise<ReadonlyArray<CommandSearchHit>> {
206
208
  this.#query = query;
207
209
  const model = this.#model;
208
210
  const revision = ++this.#searchRevision;
209
211
  if (model === undefined) {
210
212
  this.#searchHits = [];
213
+ this.#searchFailure = undefined;
211
214
  this.#notify();
212
215
  return [];
213
216
  }
214
- const hits = await this.#search(model.catalogue.commands, query);
217
+ let hits: ReadonlyArray<CommandSearchHit>;
218
+ try {
219
+ hits = await this.#search(model.catalogue.commands, query);
220
+ } catch (error) {
221
+ if (revision === this.#searchRevision && model === this.#model) {
222
+ this.#searchHits = [];
223
+ this.#searchFailure = { error };
224
+ this.#notify();
225
+ }
226
+ throw error;
227
+ }
215
228
  if (revision !== this.#searchRevision || model !== this.#model) {
216
229
  return hits;
217
230
  }
231
+ this.#searchFailure = undefined;
218
232
  const visible = new Set(this.#projection?.palette.map(({ id }) => id));
219
233
  this.#searchHits = hits.filter(({ record }) => visible.has(record.id));
220
234
  this.#notify();
@@ -246,12 +260,14 @@ export class CommandController {
246
260
  }
247
261
 
248
262
  stageKeymapPatch(patch: CommandKeymapPatch): void {
263
+ this.#mutationRevision += 1;
249
264
  this.#draft = patch;
250
265
  this.#mutation = { kind: "dirty" };
251
266
  this.#notify();
252
267
  }
253
268
 
254
269
  cancelKeymapDraft(): void {
270
+ this.#mutationRevision += 1;
255
271
  this.#draft = undefined;
256
272
  this.#mutation = { kind: "idle" };
257
273
  this.#notify();
@@ -260,20 +276,23 @@ export class CommandController {
260
276
  async applyKeymapDraft(): Promise<boolean> {
261
277
  const model = this.#requiredModel();
262
278
  const patch = this.#draft;
263
- if (patch === undefined) return true;
279
+ if (patch === undefined) {
280
+ return true;
281
+ }
264
282
  const base = model.keymap;
265
- const operationRevision = ++this.#loadRevision;
283
+ const operationRevision = ++this.#mutationRevision;
266
284
  this.#mutation = { kind: "previewing" };
267
285
  this.#notify();
268
286
  try {
269
287
  const preview = await this.#client.preview({
288
+ protocolVersion: COMMAND_KEYMAP_PROTOCOL_VERSION,
270
289
  registryGeneration: model.catalogue.registryGeneration,
271
290
  keymapRevision: base.state.revision,
272
291
  activePresetId: base.state.activePresetId,
273
292
  activePresetVersion: base.activePresetVersion,
274
293
  patch,
275
294
  });
276
- if (operationRevision !== this.#loadRevision || patch !== this.#draft) {
295
+ if (operationRevision !== this.#mutationRevision) {
277
296
  return false;
278
297
  }
279
298
  if (preview.status !== "accepted") {
@@ -290,17 +309,21 @@ export class CommandController {
290
309
  }
291
310
  this.#mutation = { kind: "committing" };
292
311
  this.#notify();
312
+ if (operationRevision !== this.#mutationRevision) {
313
+ return false;
314
+ }
293
315
  const result = await this.#client.commit({
316
+ protocolVersion: COMMAND_KEYMAP_PROTOCOL_VERSION,
294
317
  requestId: this.#client.nextRequestId(),
295
318
  evidence: preview.evidence,
296
319
  patch,
297
320
  });
298
- if (operationRevision !== this.#loadRevision || patch !== this.#draft) {
321
+ if (operationRevision !== this.#mutationRevision) {
299
322
  return false;
300
323
  }
301
324
  return this.#finishMutation(result);
302
325
  } catch (error) {
303
- if (operationRevision === this.#loadRevision) {
326
+ if (operationRevision === this.#mutationRevision) {
304
327
  this.#mutation = { kind: "failed", error };
305
328
  this.#notify();
306
329
  }
@@ -311,21 +334,27 @@ export class CommandController {
311
334
  async resetKeymap(): Promise<boolean> {
312
335
  const model = this.#requiredModel();
313
336
  const base = model.keymap;
314
- const operationRevision = ++this.#loadRevision;
337
+ const operationRevision = ++this.#mutationRevision;
315
338
  this.#mutation = { kind: "committing" };
316
339
  this.#notify();
340
+ if (operationRevision !== this.#mutationRevision) {
341
+ return false;
342
+ }
317
343
  try {
318
344
  const result = await this.#client.reset({
345
+ protocolVersion: COMMAND_KEYMAP_PROTOCOL_VERSION,
319
346
  requestId: this.#client.nextRequestId(),
320
347
  registryGeneration: model.catalogue.registryGeneration,
321
348
  keymapRevision: base.state.revision,
322
349
  activePresetId: base.state.activePresetId,
323
350
  activePresetVersion: base.activePresetVersion,
324
351
  });
325
- if (operationRevision !== this.#loadRevision) return false;
352
+ if (operationRevision !== this.#mutationRevision) {
353
+ return false;
354
+ }
326
355
  return this.#finishMutation(result);
327
356
  } catch (error) {
328
- if (operationRevision === this.#loadRevision) {
357
+ if (operationRevision === this.#mutationRevision) {
329
358
  this.#mutation = { kind: "failed", error };
330
359
  this.#notify();
331
360
  }
@@ -344,42 +373,38 @@ export class CommandController {
344
373
  this.#mutation = {
345
374
  kind: "conflict",
346
375
  detail:
347
- result.status === "rejected"
348
- ? result.rejection.detail
349
- : "Keybindings changed elsewhere",
376
+ result.status === "rejected" ? result.rejection.detail : "Keybindings changed elsewhere",
350
377
  };
351
378
  this.#notify();
352
379
  return false;
353
380
  }
354
381
 
355
382
  #applyMutationSnapshot(snapshot: CommandKeymapSnapshot): void {
356
- const model = this.#requiredModel();
383
+ const model = this.#model;
384
+ if (model === undefined) {
385
+ return;
386
+ }
357
387
  if (snapshot.registryGeneration !== model.catalogue.registryGeneration) {
358
388
  void this.refresh();
359
389
  return;
360
390
  }
361
- this.#install(
362
- joinCommandState(model.catalogue, snapshot, model.availability),
363
- );
391
+ this.#install(joinCommandState(model.catalogue, snapshot, model.availability));
364
392
  }
365
393
 
366
394
  #install(model: CommandJoinedState): void {
367
395
  const current = this.#model;
368
396
  if (
369
397
  current !== undefined &&
370
- (model.catalogue.registryGeneration <
371
- current.catalogue.registryGeneration ||
372
- (model.catalogue.registryGeneration ===
373
- current.catalogue.registryGeneration &&
398
+ (model.catalogue.registryGeneration < current.catalogue.registryGeneration ||
399
+ (model.catalogue.registryGeneration === current.catalogue.registryGeneration &&
374
400
  (model.keymap.state.revision < current.keymap.state.revision ||
375
- model.availability.contextRevision <
376
- current.availability.contextRevision)))
401
+ model.availability.contextRevision < current.availability.contextRevision)))
377
402
  ) {
378
403
  return;
379
404
  }
405
+ const projection = projectCommandSurfaces(model, this.#platform);
380
406
  this.#model = model;
381
- this.#projection = projectCommandSurfaces(model, this.#platform);
382
- this.#notify();
407
+ this.#projection = projection;
383
408
  }
384
409
 
385
410
  #requiredModel(): CommandJoinedState {
@@ -395,7 +420,9 @@ export class CommandController {
395
420
  }
396
421
 
397
422
  #notify(): void {
398
- for (const observer of this.#observers) observer();
423
+ for (const observer of this.#observers) {
424
+ observer();
425
+ }
399
426
  }
400
427
  }
401
428
 
@@ -405,7 +432,3 @@ export class CommandControllerUnavailableError extends Error {
405
432
  this.name = "CommandControllerUnavailableError";
406
433
  }
407
434
  }
408
-
409
- async function disposeAll(unlisten: readonly CommandUnlisten[]): Promise<void> {
410
- await Promise.allSettled(unlisten.map((dispose) => dispose()));
411
- }
@@ -1,9 +1,9 @@
1
- // @generated by `effigy generate:commands`; do not edit.
1
+ // @generated by `effigy generate:bindings`; do not edit.
2
2
  // Allowed field names per protocol type, from the Rust structs.
3
3
  // A `record()` given one of these rejects unknown and missing keys —
4
4
  // contract 010's Boundary Validation Target.
5
5
 
6
- export const COMMANDS_FIELDS: Record<string, readonly string[]> = {
6
+ export const COMMANDS_FIELDS = {
7
7
  "CommandArgumentField": ["id", "required", "default", "kind"],
8
8
  "CommandVisibility": ["hidden", "palette", "menu", "shortcut", "settings", "help"],
9
9
  "CommandDiscoveryRecord": ["id", "label", "description", "categoryPath", "keywords", "icon", "visibility", "textInputPolicy", "arguments"],
@@ -31,13 +31,14 @@ export const COMMANDS_FIELDS: Record<string, readonly string[]> = {
31
31
  "CommandKeymapState": ["revision", "activePresetId", "overrides"],
32
32
  "CommandKeymapPatch": ["activePresetId", "clearOverrides", "removeBindingIds", "upsertOverrides"],
33
33
  "CommandKeymapCommitEvidence": ["registryGeneration", "keymapRevision", "activePresetId", "activePresetVersion", "patchDigest"],
34
- "CommandKeymapPreview": ["registryGeneration", "keymapRevision", "activePresetId", "activePresetVersion", "patch"],
35
- "CommandKeymapCommit": ["requestId", "evidence", "patch"],
36
- "CommandKeymapReset": ["requestId", "registryGeneration", "keymapRevision", "activePresetId", "activePresetVersion"],
34
+ "CommandKeymapPreview": ["protocolVersion", "registryGeneration", "keymapRevision", "activePresetId", "activePresetVersion", "patch"],
35
+ "CommandKeymapCommit": ["protocolVersion", "requestId", "evidence", "patch"],
36
+ "CommandKeymapReset": ["protocolVersion", "requestId", "registryGeneration", "keymapRevision", "activePresetId", "activePresetVersion"],
37
37
  "CommandKeymapDiagnostic": ["code", "detail"],
38
38
  "CommandKeymapSnapshot": ["protocolVersion", "registryGeneration", "registryDigest", "state", "activePresetVersion", "bindings", "conflicts", "origin", "diagnostics"],
39
39
  "CommandKeymapChangedEvent": ["protocolVersion", "registryGeneration", "keymapRevision"],
40
40
  "CommandKeymapRejection": ["code", "detail"],
41
41
  "CommandKeymapRecovery": ["code", "detail", "sourcePreserved"],
42
42
  "CommandKeymapMutationReceipt": ["requestId", "previousRevision", "committedRevision", "outcome", "durability", "patchDigest"],
43
- };
43
+ "CommandHostError": ["code", "message", "retryable"],
44
+ } as const;
@@ -1,8 +1,19 @@
1
- // @generated by `effigy generate:commands`; do not edit.
1
+ // @generated by `effigy generate:bindings`; do not edit.
2
2
  // Rust serde types are the wire authority.
3
3
 
4
4
  export const COMMAND_KEYMAP_PROTOCOL_VERSION = 1 as const;
5
5
  export const COMMAND_MAXIMUM_PHYSICAL_CODE_BYTES = 64 as const;
6
+ export const COMMAND_MAXIMUM_DIAGNOSTIC_BYTES = 4096 as const;
7
+ export const COMMAND_MAXIMUM_KEYWORD_BYTES = 65536 as const;
8
+ export const COMMAND_MAXIMUM_AVAILABILITY_RECORDS = 65536 as const;
9
+ export const COMMAND_MAXIMUM_ARGUMENT_DEPTH = 121 as const;
10
+ export const COMMAND_PLATFORMS = ["macOs","windows","linux"] as const;
11
+ export const COMMAND_PLATFORM_SCOPES = ["any","macOs","windows","linux"] as const;
12
+ export const COMMAND_TEXT_INPUT_POLICIES = ["blocked","allowed"] as const;
13
+ export const COMMAND_AVAILABILITY_STATES = ["available","unavailable","hidden","unsupported"] as const;
14
+ export const COMMAND_AVAILABILITY_REASON_KINDS = ["contextNotAllowed","missingCapability","consumer"] as const;
15
+ export const COMMAND_BINDING_SOURCE_KINDS = ["preset","replacement","addedOverride"] as const;
16
+ export const COMMAND_ARGUMENT_SCHEMA_SHAPES = ["none","object"] as const;
6
17
  export const COMMAND_KEYMAP_LOAD_STATUSES = ["loaded","recovery","unavailable"] as const;
7
18
  export const COMMAND_KEYMAP_PREVIEW_STATUSES = ["accepted","stale","rejected"] as const;
8
19
  export const COMMAND_KEYMAP_MUTATION_STATUSES = ["applied","stale","rejected"] as const;
@@ -622,6 +633,10 @@ activePresetVersion: SchemaVersion,
622
633
  patchDigest: CommandKeymapPatchDigest, };
623
634
 
624
635
  export type CommandKeymapPreview = {
636
+ /**
637
+ * Exact protocol line.
638
+ */
639
+ protocolVersion: CommandKeymapProtocolVersion,
625
640
  /**
626
641
  * Expected sealed registry generation.
627
642
  */
@@ -644,6 +659,10 @@ activePresetVersion: SchemaVersion,
644
659
  patch: CommandKeymapPatch, };
645
660
 
646
661
  export type CommandKeymapCommit = {
662
+ /**
663
+ * Exact protocol line.
664
+ */
665
+ protocolVersion: CommandKeymapProtocolVersion,
647
666
  /**
648
667
  * Correlation identity.
649
668
  */
@@ -658,6 +677,10 @@ evidence: CommandKeymapCommitEvidence,
658
677
  patch: CommandKeymapPatch, };
659
678
 
660
679
  export type CommandKeymapReset = {
680
+ /**
681
+ * Exact protocol line.
682
+ */
683
+ protocolVersion: CommandKeymapProtocolVersion,
661
684
  /**
662
685
  * Correlation identity.
663
686
  */
@@ -874,3 +897,7 @@ snapshot: CommandKeymapSnapshot,
874
897
  * Proposed conflicts when available.
875
898
  */
876
899
  conflicts: Array<CommandKeymapConflict>, };
900
+
901
+ export type CommandHostErrorCode = "authorityUnavailable" | "stateUnavailable" | "eventPublication";
902
+
903
+ export type CommandHostError = { "code": CommandHostErrorCode, "message": string, "retryable": boolean, };
@@ -1,4 +1,4 @@
1
- // @generated by `effigy generate:commands`; do not edit.
1
+ // @generated by `effigy generate:bindings`; do not edit.
2
2
  // Allowed field names per tagged-union variant, from the Rust enums.
3
3
  // Keyed by type, then by discriminant. The discriminant itself is in
4
4
  // each list, because `exact()` compares every key.