@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
package/README.md CHANGED
@@ -9,8 +9,8 @@ effigy check:bindings
9
9
  effigy test:ts
10
10
  ```
11
11
 
12
- Every domain is a subpath. `@inflatable-cookie/longhorn` itself resolves to
13
- `core`, the base every other domain builds on.
12
+ Every domain is a subpath. The bare package name resolves to nothing: import
13
+ `/core`, the base every other domain builds on, by its subpath.
14
14
 
15
15
  | Subpath | Domain |
16
16
  | --- | --- |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inflatable-cookie/longhorn",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,13 +9,7 @@
9
9
  },
10
10
  "homepage": "https://github.com/inflatable-cookie/longhorn#readme",
11
11
  "type": "module",
12
- "types": "./src/core/index.ts",
13
12
  "exports": {
14
- ".": {
15
- "types": "./src/core/index.ts",
16
- "import": "./src/core/index.ts",
17
- "default": "./src/core/index.ts"
18
- },
19
13
  "./agent-control": {
20
14
  "types": "./src/agent-control/index.ts",
21
15
  "import": "./src/agent-control/index.ts",
@@ -0,0 +1,228 @@
1
+ // @generated by `effigy generate:bindings`; do not edit.
2
+
3
+ export type ElementRef = string;
4
+
5
+ export type WebviewLabel = string;
6
+
7
+ export type SelectionId = string;
8
+
9
+ export type WindowId = string;
10
+
11
+ export type CommandId = string;
12
+
13
+ export type SemanticNode = {
14
+ /**
15
+ * Reference stamped into the live DOM for this element.
16
+ */
17
+ elementRef: ElementRef,
18
+ /**
19
+ * Accessibility-style role, e.g. `button`, `textbox`.
20
+ */
21
+ role: string,
22
+ /**
23
+ * Accessible name, when the element has one.
24
+ */
25
+ name: string | null,
26
+ /**
27
+ * Current value, when the role carries one.
28
+ */
29
+ value: string | null,
30
+ /**
31
+ * State tokens, e.g. `disabled`, `checked`, `expanded`.
32
+ */
33
+ states: Array<string>,
34
+ /**
35
+ * Child elements.
36
+ */
37
+ children: Array<SemanticNode>, };
38
+
39
+ export type PageState = {
40
+ /**
41
+ * Current document URL.
42
+ */
43
+ url: string,
44
+ /**
45
+ * Current document title.
46
+ */
47
+ title: string, };
48
+
49
+ export type PageEvent = { "kind": "console",
50
+ /**
51
+ * Sequence of the message within the document.
52
+ */
53
+ seq: number,
54
+ /**
55
+ * Console level reported by the page.
56
+ */
57
+ level: string,
58
+ /**
59
+ * Text logged by the page.
60
+ */
61
+ text: string, } | { "kind": "error",
62
+ /**
63
+ * Sequence of the error within the document.
64
+ */
65
+ seq: number,
66
+ /**
67
+ * Error message reported by the page.
68
+ */
69
+ message: string, } | { "kind": "navigation",
70
+ /**
71
+ * Sequence of the navigation within the document.
72
+ */
73
+ seq: number,
74
+ /**
75
+ * New page URL.
76
+ */
77
+ url: string, };
78
+
79
+ export type PageEventBatch = {
80
+ /**
81
+ * Identity of the document whose ring produced this batch.
82
+ */
83
+ epoch: string,
84
+ /**
85
+ * Events after the requested cursor, or all retained events after a reload.
86
+ */
87
+ events: Array<PageEvent>,
88
+ /**
89
+ * Sequence number the ring will assign to the next event.
90
+ */
91
+ nextSeq: number,
92
+ /**
93
+ * Count of events evicted from this document's ring.
94
+ */
95
+ dropped: number, };
96
+
97
+ export type WaitPredicate = { "predicate": "refResolve",
98
+ /**
99
+ * Element expected to resolve.
100
+ */
101
+ element: ElementRef, } | { "predicate": "refAbsent",
102
+ /**
103
+ * Element expected to be gone.
104
+ */
105
+ element: ElementRef, } | { "predicate": "pageUrlContains",
106
+ /**
107
+ * Substring expected in the URL.
108
+ */
109
+ needle: string, } | { "predicate": "pageTitleContains",
110
+ /**
111
+ * Substring expected in the title.
112
+ */
113
+ needle: string, };
114
+
115
+ export type FileInputFile = {
116
+ /**
117
+ * File name presented to the page (`File.name`).
118
+ */
119
+ name: string,
120
+ /**
121
+ * Optional media type presented to the page (`File.type`). Serialized as
122
+ * `null` when absent, so the shim receives the shape its binding declares.
123
+ */
124
+ mediaType: string | null,
125
+ /**
126
+ * Standard base64 of the file bytes.
127
+ */
128
+ contentBase64: string, };
129
+
130
+ export type ToolError = { "error": "unresolvedRef",
131
+ /**
132
+ * Ref that failed to resolve.
133
+ */
134
+ element: ElementRef, } | { "error": "unknownWindow",
135
+ /**
136
+ * Window that was not found.
137
+ */
138
+ window: WindowId, } | { "error": "unknownWebview",
139
+ /**
140
+ * Webview label that was not found.
141
+ */
142
+ webview: WebviewLabel, } | { "error": "waitTimeout",
143
+ /**
144
+ * Bound that elapsed, in milliseconds.
145
+ */
146
+ timeoutMs: number, } | { "error": "evaluationFailed",
147
+ /**
148
+ * Host-provided failure detail.
149
+ */
150
+ message: string, } | { "error": "commandFailed",
151
+ /**
152
+ * Command that failed.
153
+ */
154
+ command: CommandId,
155
+ /**
156
+ * Host-provided failure detail.
157
+ */
158
+ message: string, } | { "error": "unsupported",
159
+ /**
160
+ * What cannot be served, and why.
161
+ */
162
+ message: string, } | { "error": "hostFailure",
163
+ /**
164
+ * Host-provided failure detail.
165
+ */
166
+ message: string, } | { "error": "unknownSelection",
167
+ /**
168
+ * Id that was not found.
169
+ */
170
+ id: SelectionId, } | { "error": "expiredSelection",
171
+ /**
172
+ * Id that had already expired.
173
+ */
174
+ id: SelectionId, } | { "error": "settledSelection",
175
+ /**
176
+ * Id that had already settled.
177
+ */
178
+ id: SelectionId, } | { "error": "malformedSelection",
179
+ /**
180
+ * What was wrong with the answer.
181
+ */
182
+ message: string, } | { "error": "cancelledSelection",
183
+ /**
184
+ * Id that was cancelled before settlement.
185
+ */
186
+ id: SelectionId, } | { "error": "invalidArgument",
187
+ /**
188
+ * What was invalid about the argument.
189
+ */
190
+ message: string, };
191
+
192
+ export type SelectionKind = "open" | "save";
193
+
194
+ export type SelectionFilter = {
195
+ /**
196
+ * Filter display name.
197
+ */
198
+ name: string,
199
+ /**
200
+ * File extensions without a leading dot.
201
+ */
202
+ extensions: Array<string>, };
203
+
204
+ export type BeginSelectionArgs = {
205
+ /**
206
+ * Open or save.
207
+ */
208
+ kind: SelectionKind,
209
+ /**
210
+ * Directory intent; only meaningful for open.
211
+ */
212
+ directory: boolean,
213
+ /**
214
+ * Multiple paths; only meaningful for open.
215
+ */
216
+ multiple: boolean,
217
+ /**
218
+ * Optional extension filters. Hints for the agent; not enforced.
219
+ */
220
+ filters: Array<SelectionFilter>,
221
+ /**
222
+ * Dialog title, when the caller supplied one.
223
+ */
224
+ title: string | null,
225
+ /**
226
+ * Default-path hint, never an answer.
227
+ */
228
+ defaultPath: string | null, };
@@ -10,15 +10,11 @@ export {
10
10
  TRUNCATED_ROLE,
11
11
  installAgentControlShim,
12
12
  type AgentControlApi,
13
- type FileInputFile,
14
- type PageEvent,
15
- type PageState,
16
- type SemanticNode,
17
13
  type ShimResult,
18
14
  type ShimWorld,
19
15
  type ToolErrorBody,
20
- type WaitPredicate,
21
16
  } from "./shim.ts";
17
+ export type * from "./generated/protocol.ts";
22
18
  export {
23
19
  BEGIN_SELECTION_COMMAND,
24
20
  SELECTION_ORIGIN_AGENT,
@@ -1,4 +1,7 @@
1
- import { installAgentControlShim, type ShimWorld } from "./shim.ts";
1
+ import { installAgentControlShim } from "./shim.ts";
2
+ import type { ShimWorld } from "./shim.ts";
2
3
 
4
+ // The standalone IIFE runs in the browser world carrying these DOM globals.
5
+ // oxlint-disable-next-line typescript/no-unsafe-type-assertion, quality/no-chained-type-assertions -- The injection host supplies the browser world, including its dynamically installed shim key.
3
6
  const target = globalThis as unknown as ShimWorld;
4
7
  installAgentControlShim(target);
@@ -4,7 +4,9 @@
4
4
  //! opens. Human-originated calls pass the original options to the plugin
5
5
  //! unchanged. Origin is the in-page shim, not an active-server flag.
6
6
 
7
- import { SHIM_GLOBAL, type AgentControlApi } from "./shim.ts";
7
+ import type { BeginSelectionArgs, SelectionFilter, SelectionKind } from "./generated/protocol.ts";
8
+ import { SHIM_GLOBAL } from "./shim.ts";
9
+ import type { AgentControlApi } from "./shim.ts";
8
10
 
9
11
  /** Renderer invoke name. Host-protocol pairs this with the Rust command. */
10
12
  export const BEGIN_SELECTION_COMMAND = "longhorn_agent_control_begin_selection";
@@ -21,15 +23,12 @@ export const SELECTION_ORIGIN_HUMAN = "human";
21
23
  /** Serializable origin a consumer passes into its own command arguments. */
22
24
  export type SelectionOrigin = typeof SELECTION_ORIGIN_AGENT | typeof SELECTION_ORIGIN_HUMAN;
23
25
 
24
- export type DialogFilter = {
25
- name: string;
26
- extensions: string[];
27
- };
26
+ export type DialogFilter = SelectionFilter;
28
27
 
29
28
  export type OpenDialogOptions = {
30
29
  title?: string;
31
30
  defaultPath?: string;
32
- filters?: DialogFilter[];
31
+ filters?: Array<DialogFilter>;
33
32
  multiple?: boolean;
34
33
  directory?: boolean;
35
34
  };
@@ -37,10 +36,10 @@ export type OpenDialogOptions = {
37
36
  export type SaveDialogOptions = {
38
37
  title?: string;
39
38
  defaultPath?: string;
40
- filters?: DialogFilter[];
39
+ filters?: Array<DialogFilter>;
41
40
  };
42
41
 
43
- export type OpenDialogResult = string | string[] | null;
42
+ export type OpenDialogResult = string | Array<string> | null;
44
43
  export type SaveDialogResult = string | null;
45
44
 
46
45
  export type FileSelectionPorts = {
@@ -66,24 +65,24 @@ function isAgentOriginated(world: FileSelectionWorld): boolean {
66
65
  * Page origin as a command-argument token. Reads the installed shim;
67
66
  * with no shim, or when the shim reports human, the token is `"human"`.
68
67
  */
68
+ // oxlint-disable-next-line quality/no-object-parameters -- The world is a page global with an optional shim, including plain host test doubles.
69
69
  export function currentSelectionOrigin(world: object = globalThis): SelectionOrigin {
70
- return isAgentOriginated(world as FileSelectionWorld)
71
- ? SELECTION_ORIGIN_AGENT
72
- : SELECTION_ORIGIN_HUMAN;
70
+ return isAgentOriginated(world) ? SELECTION_ORIGIN_AGENT : SELECTION_ORIGIN_HUMAN;
73
71
  }
74
72
 
75
73
  function beginOptions(
76
- kind: "open" | "save",
77
- options: OpenDialogOptions | SaveDialogOptions | undefined,
78
- ): Record<string, unknown> {
79
- const open = kind === "open" ? (options as OpenDialogOptions | undefined) : undefined;
74
+ kind: SelectionKind,
75
+ options: OpenDialogOptions | undefined,
76
+ ): BeginSelectionArgs {
77
+ const open = kind === "open" ? options : undefined;
78
+ const { filters = [], title, defaultPath } = options ?? {};
80
79
  return {
81
80
  kind,
82
81
  directory: open?.directory ?? false,
83
82
  multiple: open?.multiple ?? false,
84
- filters: options?.filters ?? [],
85
- title: options?.title,
86
- defaultPath: options?.defaultPath,
83
+ filters,
84
+ title: title ?? null,
85
+ defaultPath: defaultPath ?? null,
87
86
  };
88
87
  }
89
88
 
@@ -93,21 +92,39 @@ function beginOptions(
93
92
  */
94
93
  export function bindFileSelection(
95
94
  ports: FileSelectionPorts,
95
+ // oxlint-disable-next-line quality/no-object-parameters -- The world is a page global with an optional shim.
96
96
  world: object = globalThis,
97
97
  ): FileSelectionApi {
98
- const originWorld = world as FileSelectionWorld;
99
98
  return {
100
99
  open: async (options?: OpenDialogOptions) => {
101
- if (!isAgentOriginated(originWorld)) return ports.pluginOpen(options);
102
- return (await ports.invoke(BEGIN_SELECTION_COMMAND, {
100
+ if (!isAgentOriginated(world)) {
101
+ return ports.pluginOpen(options);
102
+ }
103
+ const result = await ports.invoke(BEGIN_SELECTION_COMMAND, {
103
104
  options: beginOptions("open", options),
104
- })) as OpenDialogResult;
105
+ });
106
+ if (result === null || typeof result === "string") {
107
+ return result;
108
+ }
109
+ if (
110
+ Array.isArray(result) &&
111
+ result.every((path): path is string => typeof path === "string")
112
+ ) {
113
+ return result;
114
+ }
115
+ throw new TypeError("invalid agent open-dialog result");
105
116
  },
106
117
  save: async (options?: SaveDialogOptions) => {
107
- if (!isAgentOriginated(originWorld)) return ports.pluginSave(options);
108
- return (await ports.invoke(BEGIN_SELECTION_COMMAND, {
118
+ if (!isAgentOriginated(world)) {
119
+ return ports.pluginSave(options);
120
+ }
121
+ const result = await ports.invoke(BEGIN_SELECTION_COMMAND, {
109
122
  options: beginOptions("save", options),
110
- })) as SaveDialogResult;
123
+ });
124
+ if (result === null || typeof result === "string") {
125
+ return result;
126
+ }
127
+ throw new TypeError("invalid agent save-dialog result");
111
128
  },
112
129
  };
113
130
  }