@inflatable-cookie/longhorn 0.6.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 (133) 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/selection.ts +10 -8
  6. package/src/agent-control/shim.ts +149 -77
  7. package/src/bridge/generated/fields.ts +1 -1
  8. package/src/bridge/generated/protocol.ts +55 -4
  9. package/src/bridge/generated/variant-fields.ts +1 -1
  10. package/src/bridge/job.ts +49 -2
  11. package/src/bridge/runtime/connection.ts +11 -14
  12. package/src/bridge/stream/connection.ts +14 -23
  13. package/src/bridge/stream/tracker.ts +5 -0
  14. package/src/bridge/supervision.ts +102 -80
  15. package/src/bridge/validation/base.ts +7 -27
  16. package/src/bridge/validation/negotiation.ts +1 -6
  17. package/src/bridge/validation/operations.ts +2 -14
  18. package/src/commands/client.ts +16 -2
  19. package/src/commands/controller.ts +96 -58
  20. package/src/commands/generated/fields.ts +4 -4
  21. package/src/commands/generated/protocol.ts +24 -1
  22. package/src/commands/generated/variant-fields.ts +1 -1
  23. package/src/commands/keyboard.ts +4 -13
  24. package/src/commands/physical-code.ts +11 -0
  25. package/src/commands/ports.ts +2 -1
  26. package/src/commands/projectors.ts +52 -29
  27. package/src/commands/validation.ts +408 -188
  28. package/src/config/client.ts +3 -3
  29. package/src/config/generated/base.ts +22 -6
  30. package/src/config/generated/fields.ts +2 -1
  31. package/src/config/generated/label-template.ts +1 -1
  32. package/src/config/generated/labels.ts +1 -1
  33. package/src/config/generated/protocol.ts +1 -1
  34. package/src/config/generated/restore.ts +35 -12
  35. package/src/config/generated/variant-fields.ts +1 -1
  36. package/src/config/validation/commands.ts +11 -13
  37. package/src/config/validation/outcomes.ts +147 -46
  38. package/src/config/validation/primitives.ts +11 -39
  39. package/src/config/validation/projection.ts +44 -44
  40. package/src/core/connection.ts +124 -29
  41. package/src/core/controller-lifecycle.ts +144 -0
  42. package/src/core/generated/identifiers.ts +4 -0
  43. package/src/core/identifiers.ts +40 -0
  44. package/src/core/index.ts +10 -1
  45. package/src/core/json-value.ts +58 -0
  46. package/src/core/listeners.ts +35 -0
  47. package/src/core/record.ts +76 -0
  48. package/src/core/transport.ts +10 -1
  49. package/src/core/wire-copy.ts +1 -0
  50. package/src/history/client.ts +11 -7
  51. package/src/history/controller.ts +72 -74
  52. package/src/history/generated/fields.ts +2 -1
  53. package/src/history/generated/protocol.ts +8 -5
  54. package/src/history/generated/variant-fields.ts +1 -1
  55. package/src/history/ports.ts +7 -2
  56. package/src/history/validation.ts +15 -37
  57. package/src/history-tree/client.ts +15 -13
  58. package/src/history-tree/controller.ts +131 -90
  59. package/src/history-tree/generated/fields.ts +3 -1
  60. package/src/history-tree/generated/protocol.ts +43 -7
  61. package/src/history-tree/generated/variant-fields.ts +7 -1
  62. package/src/history-tree/ports.ts +9 -4
  63. package/src/history-tree/validation.ts +44 -35
  64. package/src/layout/generated/protocol.ts +2 -1
  65. package/src/layout/generated/variant-fields.ts +47 -0
  66. package/src/layout/index.ts +1 -1
  67. package/src/layout/ratio.ts +9 -2
  68. package/src/layout/validation.ts +88 -13
  69. package/src/licence/client.ts +11 -7
  70. package/src/licence/controller.ts +64 -43
  71. package/src/licence/generated/fields.ts +2 -1
  72. package/src/licence/generated/protocol.ts +8 -4
  73. package/src/licence/generated/variant-fields.ts +1 -1
  74. package/src/licence/key.ts +2 -6
  75. package/src/licence/ports.ts +7 -2
  76. package/src/licence/validation.ts +27 -20
  77. package/src/native-content/client.ts +32 -1
  78. package/src/native-content/generated/fields.ts +4 -4
  79. package/src/native-content/generated/protocol.ts +16 -5
  80. package/src/native-content/generated/variant-fields.ts +1 -1
  81. package/src/native-content/ports.ts +2 -1
  82. package/src/native-content/validation/base.ts +16 -46
  83. package/src/native-content/validation/messages.ts +3 -0
  84. package/src/notifications/client.ts +17 -39
  85. package/src/notifications/controller.ts +266 -165
  86. package/src/notifications/generated/fields.ts +2 -1
  87. package/src/notifications/generated/labels.ts +1 -1
  88. package/src/notifications/generated/protocol.ts +5 -1
  89. package/src/notifications/generated/variant-fields.ts +1 -1
  90. package/src/notifications/ports.ts +2 -1
  91. package/src/notifications/tone.ts +1 -1
  92. package/src/notifications/validation.ts +41 -51
  93. package/src/operation/bridge.ts +79 -19
  94. package/src/operation/client.ts +17 -45
  95. package/src/operation/controller.ts +38 -59
  96. package/src/operation/generated/fields.ts +2 -1
  97. package/src/operation/generated/labels.ts +1 -1
  98. package/src/operation/generated/protocol.ts +5 -1
  99. package/src/operation/generated/variant-fields.ts +1 -1
  100. package/src/operation/ports.ts +2 -1
  101. package/src/operation/validation.ts +48 -50
  102. package/src/settings/connection.ts +10 -14
  103. package/src/settings/generated/fields.ts +2 -1
  104. package/src/settings/generated/protocol.ts +5 -1
  105. package/src/settings/generated/variant-fields.ts +1 -1
  106. package/src/settings/validation/authority.ts +2 -2
  107. package/src/settings/validation/command.ts +5 -4
  108. package/src/settings/validation/primitives.ts +32 -67
  109. package/src/settings/validation/registry.ts +13 -11
  110. package/src/surface-transfer/generated/fields.ts +1 -1
  111. package/src/surface-transfer/generated/protocol.ts +3 -3
  112. package/src/surface-transfer/generated/variant-fields.ts +1 -1
  113. package/src/surface-transfer/validation.ts +76 -53
  114. package/src/surfaces/client.ts +26 -38
  115. package/src/surfaces/generated/fields.ts +1 -1
  116. package/src/surfaces/generated/protocol.ts +1 -1
  117. package/src/surfaces/generated/variant-fields.ts +1 -1
  118. package/src/surfaces/validation.ts +198 -61
  119. package/src/transfer/connection.ts +25 -39
  120. package/src/transfer/generated/fields.ts +2 -1
  121. package/src/transfer/generated/protocol.ts +9 -1
  122. package/src/transfer/generated/variant-fields.ts +1 -1
  123. package/src/transfer/index.ts +8 -1
  124. package/src/transfer/payload.ts +12 -9
  125. package/src/transfer/validation.ts +146 -60
  126. package/src/update/client.ts +43 -16
  127. package/src/update/controller.ts +187 -104
  128. package/src/update/generated/fields.ts +2 -1
  129. package/src/update/generated/protocol.ts +19 -7
  130. package/src/update/generated/variant-fields.ts +3 -2
  131. package/src/update/ports.ts +11 -7
  132. package/src/update/serialized.ts +8 -6
  133. package/src/update/validation.ts +18 -28
@@ -1,4 +1,4 @@
1
- import { isRecord } from "../core/record.ts";
1
+ import { checkWireFields, readWireRecord, wireVariantFields } from "../core/record.ts";
2
2
  import { UPDATE_FIELDS } from "./generated/fields.ts";
3
3
  import {
4
4
  UPDATE_AVAILABILITY_STATES,
@@ -73,6 +73,7 @@ export function assertUpdateOutcome(value: unknown): asserts value is UpdateOutc
73
73
  exact(root, "$", variantFields("UpdateOutcomeProjection", root, "$"));
74
74
  if (root.status === "rejected") {
75
75
  oneOf(root.code, "$.code", UPDATE_REJECTION_CODES);
76
+ optionalString(root.detail, "$.detail");
76
77
  }
77
78
  assertUpdateSnapshot(root.snapshot);
78
79
  }
@@ -159,14 +160,14 @@ function availability(value: unknown, path: string): void {
159
160
  oneOf(root.reason, `${path}.reason`, UPDATE_OFFER_REASONS);
160
161
  optionalString(root.notes, `${path}.notes`);
161
162
  }
162
- // Ahead-of-channel is the one state whose fields a surface must be able to
163
- // read to say anything useful: "you are on 1.3.0-nightly.4 and production
164
- // publishes 1.2.9" is the whole message, and Card 154 calls it the single
165
- // most likely support question the feature generates.
163
+ // The surface needs both versions to explain why the channel has no offer.
166
164
  if (root.state === "aheadOfChannel") {
167
165
  version(root.installed, `${path}.installed`);
168
166
  version(root.channel, `${path}.channel`);
169
167
  }
168
+ if (root.state === "unavailableForTarget") {
169
+ version(root.version, `${path}.version`);
170
+ }
170
171
  if (root.state === "withheldByRollout") {
171
172
  version(root.version, `${path}.version`);
172
173
  }
@@ -213,25 +214,18 @@ function commandBase(value: unknown, expected: ReadonlyArray<string>): void {
213
214
  positive(root.authorityEpoch, "$.authorityEpoch");
214
215
  }
215
216
 
216
- /**
217
- * Allowed keys for one variant, from the generated map.
218
- *
219
- * A missing entry means the generator failed to read the union, not that a
220
- * consumer sent something odd — every caller runs `oneOf` over the
221
- * discriminant first, so an unknown one is already rejected by then.
222
- */
223
217
  function variantFields(
224
218
  type: string,
225
219
  value: Record<string, unknown>,
226
220
  path: string,
227
221
  ): ReadonlyArray<string> {
228
- const discriminant = value[UPDATE_VARIANT_FIELDS_DISCRIMINANTS[type] ?? "kind"];
229
- const fields =
230
- typeof discriminant === "string" ? UPDATE_VARIANT_FIELDS[type]?.[discriminant] : undefined;
231
- if (fields === undefined) {
232
- fail(path, `no generated fields for ${type}.${String(discriminant)}`);
233
- }
234
- return fields;
222
+ return wireVariantFields(
223
+ UPDATE_VARIANT_FIELDS,
224
+ UPDATE_VARIANT_FIELDS_DISCRIMINANTS,
225
+ type,
226
+ value,
227
+ (discriminant) => fail(path, `no generated fields for ${type}.${String(discriminant)}`),
228
+ );
235
229
  }
236
230
 
237
231
  function noPayload(value: unknown): void {
@@ -251,21 +245,17 @@ function noPayload(value: unknown): void {
251
245
  visit(value, "$");
252
246
  }
253
247
  function object(value: unknown, path: string): Record<string, unknown> {
254
- if (!isRecord(value)) {
255
- fail(path, "expected object");
256
- }
257
- return value;
248
+ const result = readWireRecord(value, () => fail(path, "expected object"));
249
+ return result;
258
250
  }
259
251
  function exact(
260
252
  value: Record<string, unknown>,
261
253
  path: string,
262
254
  expected: ReadonlyArray<string>,
263
255
  ): void {
264
- const actual = Object.keys(value).sort();
265
- const wanted = [...expected].sort();
266
- if (actual.length !== wanted.length || actual.some((key, index) => key !== wanted[index])) {
267
- fail(path, `unexpected keys: ${actual.join(",")}`);
268
- }
256
+ checkWireFields(value, expected, () =>
257
+ fail(path, `unexpected keys: ${Object.keys(value).sort().join(",")}`),
258
+ );
269
259
  }
270
260
  function protocol(value: unknown, path: string): void {
271
261
  if (value !== UPDATE_PROTOCOL_VERSION) {