@grackle-ai/ahp 0.131.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 (153) hide show
  1. package/dist/index.d.ts +23 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +23 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/vendor/ahp/action-origin.generated.d.ts +33 -0
  6. package/dist/vendor/ahp/action-origin.generated.d.ts.map +1 -0
  7. package/dist/vendor/ahp/action-origin.generated.js +71 -0
  8. package/dist/vendor/ahp/action-origin.generated.js.map +1 -0
  9. package/dist/vendor/ahp/actions.d.ts +14 -0
  10. package/dist/vendor/ahp/actions.d.ts.map +1 -0
  11. package/dist/vendor/ahp/actions.js +15 -0
  12. package/dist/vendor/ahp/actions.js.map +1 -0
  13. package/dist/vendor/ahp/channels-changeset/actions.d.ts +87 -0
  14. package/dist/vendor/ahp/channels-changeset/actions.d.ts.map +1 -0
  15. package/dist/vendor/ahp/channels-changeset/actions.js +9 -0
  16. package/dist/vendor/ahp/channels-changeset/actions.js.map +1 -0
  17. package/dist/vendor/ahp/channels-changeset/commands.d.ts +103 -0
  18. package/dist/vendor/ahp/channels-changeset/commands.d.ts.map +1 -0
  19. package/dist/vendor/ahp/channels-changeset/commands.js +22 -0
  20. package/dist/vendor/ahp/channels-changeset/commands.js.map +1 -0
  21. package/dist/vendor/ahp/channels-changeset/reducer.d.ts +18 -0
  22. package/dist/vendor/ahp/channels-changeset/reducer.d.ts.map +1 -0
  23. package/dist/vendor/ahp/channels-changeset/reducer.js +65 -0
  24. package/dist/vendor/ahp/channels-changeset/reducer.js.map +1 -0
  25. package/dist/vendor/ahp/channels-changeset/state.d.ts +155 -0
  26. package/dist/vendor/ahp/channels-changeset/state.d.ts.map +1 -0
  27. package/dist/vendor/ahp/channels-changeset/state.js +39 -0
  28. package/dist/vendor/ahp/channels-changeset/state.js.map +1 -0
  29. package/dist/vendor/ahp/channels-otlp/notifications.d.ts +121 -0
  30. package/dist/vendor/ahp/channels-otlp/notifications.d.ts.map +1 -0
  31. package/dist/vendor/ahp/channels-otlp/notifications.js +11 -0
  32. package/dist/vendor/ahp/channels-otlp/notifications.js.map +1 -0
  33. package/dist/vendor/ahp/channels-otlp/state.d.ts +65 -0
  34. package/dist/vendor/ahp/channels-otlp/state.d.ts.map +1 -0
  35. package/dist/vendor/ahp/channels-otlp/state.js +10 -0
  36. package/dist/vendor/ahp/channels-otlp/state.js.map +1 -0
  37. package/dist/vendor/ahp/channels-root/actions.d.ts +62 -0
  38. package/dist/vendor/ahp/channels-root/actions.d.ts.map +1 -0
  39. package/dist/vendor/ahp/channels-root/actions.js +8 -0
  40. package/dist/vendor/ahp/channels-root/actions.js.map +1 -0
  41. package/dist/vendor/ahp/channels-root/commands.d.ts +172 -0
  42. package/dist/vendor/ahp/channels-root/commands.d.ts.map +1 -0
  43. package/dist/vendor/ahp/channels-root/commands.js +10 -0
  44. package/dist/vendor/ahp/channels-root/commands.js.map +1 -0
  45. package/dist/vendor/ahp/channels-root/notifications.d.ts +136 -0
  46. package/dist/vendor/ahp/channels-root/notifications.d.ts.map +1 -0
  47. package/dist/vendor/ahp/channels-root/notifications.js +9 -0
  48. package/dist/vendor/ahp/channels-root/notifications.js.map +1 -0
  49. package/dist/vendor/ahp/channels-root/reducer.d.ts +12 -0
  50. package/dist/vendor/ahp/channels-root/reducer.d.ts.map +1 -0
  51. package/dist/vendor/ahp/channels-root/reducer.js +36 -0
  52. package/dist/vendor/ahp/channels-root/reducer.js.map +1 -0
  53. package/dist/vendor/ahp/channels-root/state.d.ts +123 -0
  54. package/dist/vendor/ahp/channels-root/state.d.ts.map +1 -0
  55. package/dist/vendor/ahp/channels-root/state.js +19 -0
  56. package/dist/vendor/ahp/channels-root/state.js.map +1 -0
  57. package/dist/vendor/ahp/channels-session/actions.d.ts +736 -0
  58. package/dist/vendor/ahp/channels-session/actions.d.ts.map +1 -0
  59. package/dist/vendor/ahp/channels-session/actions.js +8 -0
  60. package/dist/vendor/ahp/channels-session/actions.js.map +1 -0
  61. package/dist/vendor/ahp/channels-session/commands.d.ts +261 -0
  62. package/dist/vendor/ahp/channels-session/commands.d.ts.map +1 -0
  63. package/dist/vendor/ahp/channels-session/commands.js +23 -0
  64. package/dist/vendor/ahp/channels-session/commands.js.map +1 -0
  65. package/dist/vendor/ahp/channels-session/reducer.d.ts +14 -0
  66. package/dist/vendor/ahp/channels-session/reducer.d.ts.map +1 -0
  67. package/dist/vendor/ahp/channels-session/reducer.js +703 -0
  68. package/dist/vendor/ahp/channels-session/reducer.js.map +1 -0
  69. package/dist/vendor/ahp/channels-session/state.d.ts +1217 -0
  70. package/dist/vendor/ahp/channels-session/state.d.ts.map +1 -0
  71. package/dist/vendor/ahp/channels-session/state.js +229 -0
  72. package/dist/vendor/ahp/channels-session/state.js.map +1 -0
  73. package/dist/vendor/ahp/channels-terminal/actions.d.ts +185 -0
  74. package/dist/vendor/ahp/channels-terminal/actions.d.ts.map +1 -0
  75. package/dist/vendor/ahp/channels-terminal/actions.js +8 -0
  76. package/dist/vendor/ahp/channels-terminal/actions.js.map +1 -0
  77. package/dist/vendor/ahp/channels-terminal/commands.d.ts +50 -0
  78. package/dist/vendor/ahp/channels-terminal/commands.d.ts.map +1 -0
  79. package/dist/vendor/ahp/channels-terminal/commands.js +8 -0
  80. package/dist/vendor/ahp/channels-terminal/commands.js.map +1 -0
  81. package/dist/vendor/ahp/channels-terminal/reducer.d.ts +12 -0
  82. package/dist/vendor/ahp/channels-terminal/reducer.d.ts.map +1 -0
  83. package/dist/vendor/ahp/channels-terminal/reducer.js +80 -0
  84. package/dist/vendor/ahp/channels-terminal/reducer.js.map +1 -0
  85. package/dist/vendor/ahp/channels-terminal/state.d.ts +151 -0
  86. package/dist/vendor/ahp/channels-terminal/state.d.ts.map +1 -0
  87. package/dist/vendor/ahp/channels-terminal/state.js +18 -0
  88. package/dist/vendor/ahp/channels-terminal/state.js.map +1 -0
  89. package/dist/vendor/ahp/commands.d.ts +14 -0
  90. package/dist/vendor/ahp/commands.d.ts.map +1 -0
  91. package/dist/vendor/ahp/commands.js +15 -0
  92. package/dist/vendor/ahp/commands.js.map +1 -0
  93. package/dist/vendor/ahp/common/actions.d.ts +107 -0
  94. package/dist/vendor/ahp/common/actions.d.ts.map +1 -0
  95. package/dist/vendor/ahp/common/actions.js +77 -0
  96. package/dist/vendor/ahp/common/actions.js.map +1 -0
  97. package/dist/vendor/ahp/common/commands.d.ts +594 -0
  98. package/dist/vendor/ahp/common/commands.d.ts.map +1 -0
  99. package/dist/vendor/ahp/common/commands.js +32 -0
  100. package/dist/vendor/ahp/common/commands.js.map +1 -0
  101. package/dist/vendor/ahp/common/errors.d.ts +184 -0
  102. package/dist/vendor/ahp/common/errors.d.ts.map +1 -0
  103. package/dist/vendor/ahp/common/errors.js +82 -0
  104. package/dist/vendor/ahp/common/errors.js.map +1 -0
  105. package/dist/vendor/ahp/common/messages.d.ts +330 -0
  106. package/dist/vendor/ahp/common/messages.d.ts.map +1 -0
  107. package/dist/vendor/ahp/common/messages.js +11 -0
  108. package/dist/vendor/ahp/common/messages.js.map +1 -0
  109. package/dist/vendor/ahp/common/notifications.d.ts +58 -0
  110. package/dist/vendor/ahp/common/notifications.d.ts.map +1 -0
  111. package/dist/vendor/ahp/common/notifications.js +20 -0
  112. package/dist/vendor/ahp/common/notifications.js.map +1 -0
  113. package/dist/vendor/ahp/common/reducer-helpers.d.ts +24 -0
  114. package/dist/vendor/ahp/common/reducer-helpers.d.ts.map +1 -0
  115. package/dist/vendor/ahp/common/reducer-helpers.js +31 -0
  116. package/dist/vendor/ahp/common/reducer-helpers.js.map +1 -0
  117. package/dist/vendor/ahp/common/state.d.ts +286 -0
  118. package/dist/vendor/ahp/common/state.d.ts.map +1 -0
  119. package/dist/vendor/ahp/common/state.js +11 -0
  120. package/dist/vendor/ahp/common/state.js.map +1 -0
  121. package/dist/vendor/ahp/errors.d.ts +8 -0
  122. package/dist/vendor/ahp/errors.d.ts.map +1 -0
  123. package/dist/vendor/ahp/errors.js +9 -0
  124. package/dist/vendor/ahp/errors.js.map +1 -0
  125. package/dist/vendor/ahp/index.d.ts +24 -0
  126. package/dist/vendor/ahp/index.d.ts.map +1 -0
  127. package/dist/vendor/ahp/index.js +21 -0
  128. package/dist/vendor/ahp/index.js.map +1 -0
  129. package/dist/vendor/ahp/messages.d.ts +8 -0
  130. package/dist/vendor/ahp/messages.d.ts.map +1 -0
  131. package/dist/vendor/ahp/messages.js +9 -0
  132. package/dist/vendor/ahp/messages.js.map +1 -0
  133. package/dist/vendor/ahp/notifications.d.ts +11 -0
  134. package/dist/vendor/ahp/notifications.d.ts.map +1 -0
  135. package/dist/vendor/ahp/notifications.js +12 -0
  136. package/dist/vendor/ahp/notifications.js.map +1 -0
  137. package/dist/vendor/ahp/reducers.d.ts +12 -0
  138. package/dist/vendor/ahp/reducers.d.ts.map +1 -0
  139. package/dist/vendor/ahp/reducers.js +13 -0
  140. package/dist/vendor/ahp/reducers.js.map +1 -0
  141. package/dist/vendor/ahp/state.d.ts +15 -0
  142. package/dist/vendor/ahp/state.d.ts.map +1 -0
  143. package/dist/vendor/ahp/state.js +16 -0
  144. package/dist/vendor/ahp/state.js.map +1 -0
  145. package/dist/vendor/ahp/version/message-checks.d.ts +15 -0
  146. package/dist/vendor/ahp/version/message-checks.d.ts.map +1 -0
  147. package/dist/vendor/ahp/version/message-checks.js +16 -0
  148. package/dist/vendor/ahp/version/message-checks.js.map +1 -0
  149. package/dist/vendor/ahp/version/registry.d.ts +56 -0
  150. package/dist/vendor/ahp/version/registry.d.ts.map +1 -0
  151. package/dist/vendor/ahp/version/registry.js +138 -0
  152. package/dist/vendor/ahp/version/registry.js.map +1 -0
  153. package/package.json +47 -0
@@ -0,0 +1,594 @@
1
+ /**
2
+ * Common Command Types — Connection-level commands (handshake, ping,
3
+ * reconnect, subscribe/unsubscribe, dispatchAction) plus the filesystem
4
+ * `resource*` family and `authenticate` that aren't specific to any one
5
+ * state channel.
6
+ *
7
+ * @module common/commands
8
+ */
9
+ import type { URI, Snapshot } from './state.js';
10
+ import type { ActionEnvelope, StateAction } from './actions.js';
11
+ import type { TelemetryCapabilities } from '../channels-otlp/state.js';
12
+ /**
13
+ * Base shape every command's params extends.
14
+ *
15
+ * `channel` identifies the channel the command targets, mirroring the
16
+ * `channel` field on every protocol notification. For commands that operate
17
+ * on a specific channel (a session, terminal, or changeset), `channel` is
18
+ * that channel's URI. For commands that are connection-level rather than
19
+ * channel-scoped (e.g. {@link InitializeParams | `initialize`},
20
+ * {@link PingParams | `ping`}, {@link ListSessionsParams | `listSessions`},
21
+ * the `resource*` filesystem commands, and {@link AuthenticateParams |
22
+ * `authenticate`}), the params type narrows `channel` to the literal
23
+ * root URI `'ahp-root://'`.
24
+ *
25
+ * This invariant lets implementations route every incoming message —
26
+ * request, response, or notification — by inspecting `params.channel`
27
+ * without needing to know the per-method param shape.
28
+ *
29
+ * @category Commands
30
+ */
31
+ export interface BaseParams {
32
+ /** Channel URI this command targets. */
33
+ channel: URI;
34
+ }
35
+ /**
36
+ * Establishes a new connection and negotiates the protocol version.
37
+ * This MUST be the first message sent by the client.
38
+ *
39
+ * @category Commands
40
+ * @method initialize
41
+ * @direction Client → Server
42
+ * @messageType Request
43
+ * @version 1
44
+ * @see {@link /specification/lifecycle | Lifecycle} for the full handshake flow.
45
+ */
46
+ export interface InitializeParams extends BaseParams {
47
+ channel: 'ahp-root://';
48
+ /**
49
+ * Protocol versions the client is willing to speak, ordered from most
50
+ * preferred to least preferred. Each entry is a [SemVer](https://semver.org)
51
+ * `MAJOR.MINOR.PATCH` string (e.g. `"0.1.0"`).
52
+ *
53
+ * The server selects one entry and returns it as `InitializeResult.protocolVersion`.
54
+ * If the server cannot speak any of the offered versions, it MUST return
55
+ * error code `-32005` (`UnsupportedProtocolVersion`).
56
+ */
57
+ protocolVersions: string[];
58
+ /** Unique client identifier */
59
+ clientId: string;
60
+ /** URIs to subscribe to during handshake */
61
+ initialSubscriptions?: URI[];
62
+ /**
63
+ * IETF BCP 47 language tag indicating the client's preferred locale
64
+ * (e.g. `"en-US"`, `"ja"`). The server SHOULD use this to localise
65
+ * user-facing strings such as confirmation option labels.
66
+ */
67
+ locale?: string;
68
+ }
69
+ /**
70
+ * Result of the `initialize` command.
71
+ *
72
+ * `protocolVersion` is the version the server has selected from the client's
73
+ * `protocolVersions` list. The client and server MUST use this version for
74
+ * the rest of the connection. If the server cannot speak any of the offered
75
+ * versions it MUST return error code `-32005` (`UnsupportedProtocolVersion`)
76
+ * instead of a result.
77
+ */
78
+ export interface InitializeResult {
79
+ /**
80
+ * Protocol version selected by the server. MUST be one of the entries in
81
+ * `InitializeParams.protocolVersions`. Formatted as a [SemVer](https://semver.org)
82
+ * `MAJOR.MINOR.PATCH` string (e.g. `"0.1.0"`).
83
+ */
84
+ protocolVersion: string;
85
+ /** Current server sequence number */
86
+ serverSeq: number;
87
+ /** Snapshots for each `initialSubscriptions` URI */
88
+ snapshots: Snapshot[];
89
+ /** Suggested default directory for remote filesystem browsing */
90
+ defaultDirectory?: URI;
91
+ /**
92
+ * Characters that, when typed in a {@link UserMessage} input, SHOULD cause
93
+ * the client to issue a `completions` request with
94
+ * {@link CompletionItemKind.UserMessage}. Typically includes characters like
95
+ * `'@'` or `'/'`.
96
+ */
97
+ completionTriggerCharacters?: string[];
98
+ /**
99
+ * OTLP telemetry channels the host emits, if any. Each populated field is
100
+ * either a literal `ahp-otlp:` channel URI or an RFC 6570 URI template a
101
+ * client expands before subscribing (currently only the `logs` channel
102
+ * defines a template variable, `{level}`, for subscriber-side severity
103
+ * filtering). Clients MAY ignore signals they cannot process.
104
+ *
105
+ * @see {@link /specification/telemetry-channel | Telemetry Channel}
106
+ */
107
+ telemetry?: TelemetryCapabilities;
108
+ }
109
+ /**
110
+ * Verifies that the AHP connection is still alive and keeps it from being
111
+ * closed by idle-timeout intermediaries (proxies, load balancers, etc.).
112
+ *
113
+ * The server MUST respond regardless of whether the client has completed
114
+ * `initialize` or holds any subscriptions. Ping carries no payload in either
115
+ * direction; the response itself is the signal.
116
+ *
117
+ * @category Commands
118
+ * @method ping
119
+ * @direction Client → Server
120
+ * @messageType Request
121
+ * @version 0.1.0
122
+ */
123
+ export interface PingParams extends BaseParams {
124
+ channel: 'ahp-root://';
125
+ }
126
+ /**
127
+ * Discriminant for reconnect result types.
128
+ *
129
+ * @category Commands
130
+ */
131
+ export declare enum ReconnectResultType {
132
+ Replay = "replay",
133
+ Snapshot = "snapshot"
134
+ }
135
+ /**
136
+ * Re-establishes a dropped connection. The server replays missed actions or
137
+ * provides fresh snapshots.
138
+ *
139
+ * @category Commands
140
+ * @method reconnect
141
+ * @direction Client → Server
142
+ * @messageType Request
143
+ * @version 1
144
+ * @see {@link /specification/lifecycle | Lifecycle} for details.
145
+ */
146
+ export interface ReconnectParams extends BaseParams {
147
+ channel: 'ahp-root://';
148
+ /** Client identifier from the original connection */
149
+ clientId: string;
150
+ /** Last `serverSeq` the client received */
151
+ lastSeenServerSeq: number;
152
+ /** URIs the client was subscribed to */
153
+ subscriptions: URI[];
154
+ }
155
+ /**
156
+ * Reconnect result when the server can replay from the requested sequence.
157
+ *
158
+ * The server MUST include all replayed data in the response.
159
+ */
160
+ export interface ReconnectReplayResult {
161
+ /** Discriminant */
162
+ type: ReconnectResultType.Replay;
163
+ /** Missed action envelopes since `lastSeenServerSeq` */
164
+ actions: ActionEnvelope[];
165
+ /**
166
+ * URIs from `ReconnectParams.subscriptions` that the server cannot resume.
167
+ * This includes resources that no longer exist (e.g. disposed sessions or
168
+ * terminals) as well as resources the client is no longer permitted to
169
+ * observe. Clients SHOULD drop these from their local subscription set.
170
+ */
171
+ missing: URI[];
172
+ }
173
+ /**
174
+ * Reconnect result when the gap exceeds the replay buffer.
175
+ */
176
+ export interface ReconnectSnapshotResult {
177
+ /** Discriminant */
178
+ type: ReconnectResultType.Snapshot;
179
+ /** Fresh snapshots for each subscription */
180
+ snapshots: Snapshot[];
181
+ }
182
+ /** Result of the `reconnect` command. */
183
+ export type ReconnectResult = ReconnectReplayResult | ReconnectSnapshotResult;
184
+ /**
185
+ * Subscribe to a URI-identified channel.
186
+ *
187
+ * A channel MAY have state associated with it (e.g. root, sessions,
188
+ * terminals) or be stateless (pure pub/sub for streaming data). For
189
+ * state-bearing channels the result includes a snapshot; for stateless
190
+ * channels `snapshot` is omitted.
191
+ *
192
+ * @category Commands
193
+ * @method subscribe
194
+ * @direction Client → Server
195
+ * @messageType Request
196
+ * @version 1
197
+ * @see {@link /specification/subscriptions | Subscriptions}
198
+ */
199
+ export interface SubscribeParams extends BaseParams {
200
+ }
201
+ /**
202
+ * Result of the `subscribe` command.
203
+ *
204
+ * `snapshot` is present when the subscribed channel has associated state, and
205
+ * absent for stateless channels.
206
+ */
207
+ export interface SubscribeResult {
208
+ /** Snapshot of the subscribed channel's state (omitted for stateless channels) */
209
+ snapshot?: Snapshot;
210
+ }
211
+ /**
212
+ * Stop receiving updates for a channel.
213
+ *
214
+ * @category Commands
215
+ * @method unsubscribe
216
+ * @direction Client → Server
217
+ * @messageType Notification
218
+ * @version 1
219
+ * @see {@link /specification/subscriptions | Subscriptions}
220
+ */
221
+ export interface UnsubscribeParams {
222
+ /** Channel URI to unsubscribe from */
223
+ channel: URI;
224
+ }
225
+ /**
226
+ * Fire-and-forget action dispatch (write-ahead). The client applies actions
227
+ * optimistically to local state and the server echoes them back as an
228
+ * {@link ActionEnvelope} once accepted.
229
+ *
230
+ * The client → server method is named `dispatchAction`; the server's reply
231
+ * arrives on the server → client `action` notification (params:
232
+ * {@link ActionEnvelope}).
233
+ *
234
+ * @category Commands
235
+ * @method dispatchAction
236
+ * @direction Client → Server
237
+ * @messageType Notification
238
+ * @version 1
239
+ * @see {@link /guide/actions | Actions} for the full list of client-dispatchable actions.
240
+ */
241
+ export interface DispatchActionParams {
242
+ /** Channel URI this action targets */
243
+ channel: URI;
244
+ /** Client sequence number */
245
+ clientSeq: number;
246
+ /** The action to dispatch */
247
+ action: StateAction;
248
+ }
249
+ /**
250
+ * Encoding of fetched content data.
251
+ *
252
+ * @category Commands
253
+ */
254
+ export declare enum ContentEncoding {
255
+ Base64 = "base64",
256
+ Utf8 = "utf-8"
257
+ }
258
+ /**
259
+ * Reads the content of a resource by URI.
260
+ *
261
+ * Content references keep the state tree small by storing large data (images,
262
+ * long tool outputs) by reference rather than inline.
263
+ *
264
+ * Binary content (images, etc.) MUST use `base64` encoding. Text content MAY
265
+ * use `utf-8` encoding.
266
+ *
267
+ * @category Commands
268
+ * @method resourceRead
269
+ * @direction Client → Server
270
+ * @messageType Request
271
+ * @version 1
272
+ * @throws `NotFound` (`-32008`) if the URI does not exist.
273
+ * @throws `PermissionDenied` (`-32009`) if the client is not permitted to read the URI.
274
+ * @example
275
+ * ```jsonc
276
+ * // Client → Server
277
+ * { "jsonrpc": "2.0", "id": 10, "method": "resourceRead",
278
+ * "params": { "uri": "ahp-session:/<uuid>/content/img-1" } }
279
+ *
280
+ * // Server → Client
281
+ * { "jsonrpc": "2.0", "id": 10, "result": {
282
+ * "data": "iVBORw0KGgo...",
283
+ * "encoding": "base64",
284
+ * "contentType": "image/png"
285
+ * }}
286
+ * ```
287
+ */
288
+ export interface ResourceReadParams extends BaseParams {
289
+ channel: 'ahp-root://';
290
+ /** Content URI from a `ContentRef` */
291
+ uri: string;
292
+ /** Preferred encoding for the returned data (default: server-chosen) */
293
+ encoding?: ContentEncoding;
294
+ }
295
+ /**
296
+ * Result of the `resourceRead` command.
297
+ *
298
+ * The server SHOULD honor the `encoding` requested in the params. If the
299
+ * server cannot provide the requested encoding, it MUST fall back to either
300
+ * `base64` or `utf-8`.
301
+ */
302
+ export interface ResourceReadResult {
303
+ /** Content encoded as a string */
304
+ data: string;
305
+ /** How `data` is encoded */
306
+ encoding: ContentEncoding;
307
+ /** Content type (e.g. `"image/png"`, `"text/plain"`) */
308
+ contentType?: string;
309
+ }
310
+ /**
311
+ * Writes content to a file on the server's filesystem.
312
+ *
313
+ * Binary content (images, etc.) MUST use `base64` encoding. Text content MAY
314
+ * use `utf-8` encoding.
315
+ *
316
+ * If the file does not exist, it is created. If the file already exists, it is
317
+ * overwritten unless `createOnly` is set.
318
+ *
319
+ * @category Commands
320
+ * @method resourceWrite
321
+ * @direction Client → Server
322
+ * @messageType Request
323
+ * @version 1
324
+ * @throws `NotFound` (`-32008`) if the parent directory does not exist.
325
+ * @throws `PermissionDenied` (`-32009`) if the client is not permitted to write to the path.
326
+ * @throws `AlreadyExists` (`-32010`) if `createOnly` is set and the file already exists.
327
+ * @example
328
+ * ```jsonc
329
+ * // Client → Server
330
+ * { "jsonrpc": "2.0", "id": 11, "method": "resourceWrite",
331
+ * "params": { "uri": "file:///workspace/hello.txt", "data": "SGVsbG8=",
332
+ * "encoding": "base64", "contentType": "text/plain" } }
333
+ *
334
+ * // Server → Client
335
+ * { "jsonrpc": "2.0", "id": 11, "result": {} }
336
+ * ```
337
+ */
338
+ export interface ResourceWriteParams extends BaseParams {
339
+ channel: 'ahp-root://';
340
+ /** Target file URI on the server filesystem */
341
+ uri: URI;
342
+ /** Content encoded as a string */
343
+ data: string;
344
+ /** How `data` is encoded */
345
+ encoding: ContentEncoding;
346
+ /** Content type (e.g. `"text/plain"`, `"image/png"`) */
347
+ contentType?: string;
348
+ /**
349
+ * If `true`, the server MUST fail if the file already exists instead of
350
+ * overwriting it. Useful for safe creation of new files.
351
+ */
352
+ createOnly?: boolean;
353
+ }
354
+ /**
355
+ * Result of the `resourceWrite` command.
356
+ *
357
+ * An empty object on success.
358
+ */
359
+ export interface ResourceWriteResult {
360
+ }
361
+ /**
362
+ * Lists directory entries at a file URI on the server's filesystem.
363
+ *
364
+ * This is intended for remote folder pickers and similar UI that needs to let
365
+ * users navigate the server's local filesystem.
366
+ *
367
+ * The server MUST return success only if the target exists and is a directory.
368
+ * If the target does not exist, is not a directory, or cannot be accessed, the
369
+ * server MUST return a JSON-RPC error.
370
+ *
371
+ * @category Commands
372
+ * @method resourceList
373
+ * @direction Client → Server
374
+ * @messageType Request
375
+ * @version 1
376
+ * @throws `NotFound` (`-32008`) if the directory does not exist.
377
+ * @throws `PermissionDenied` (`-32009`) if the client is not permitted to browse the directory.
378
+ */
379
+ export interface ResourceListParams extends BaseParams {
380
+ channel: 'ahp-root://';
381
+ /** Directory URI on the server filesystem */
382
+ uri: URI;
383
+ }
384
+ /**
385
+ * Directory entry returned by `resourceList`.
386
+ */
387
+ export interface DirectoryEntry {
388
+ /** Base name of the entry */
389
+ name: string;
390
+ /** Whether the entry is a file or directory */
391
+ type: 'file' | 'directory';
392
+ }
393
+ /**
394
+ * Result of the `resourceList` command.
395
+ */
396
+ export interface ResourceListResult {
397
+ /** Entries directly contained in the requested directory */
398
+ entries: DirectoryEntry[];
399
+ }
400
+ /**
401
+ * Copies a resource from one URI to another on the server's filesystem.
402
+ *
403
+ * If the destination already exists, it is overwritten unless `failIfExists`
404
+ * is set.
405
+ *
406
+ * @category Commands
407
+ * @method resourceCopy
408
+ * @direction Client → Server
409
+ * @messageType Request
410
+ * @version 1
411
+ * @throws `NotFound` (`-32008`) if the source does not exist.
412
+ * @throws `PermissionDenied` (`-32009`) if the client is not permitted to read the source or write to the destination.
413
+ * @throws `AlreadyExists` (`-32010`) if `failIfExists` is set and the destination already exists.
414
+ */
415
+ export interface ResourceCopyParams extends BaseParams {
416
+ channel: 'ahp-root://';
417
+ /** Source URI to copy from */
418
+ source: URI;
419
+ /** Destination URI to copy to */
420
+ destination: URI;
421
+ /**
422
+ * If `true`, the server MUST fail if the destination already exists instead
423
+ * of overwriting it.
424
+ */
425
+ failIfExists?: boolean;
426
+ }
427
+ /**
428
+ * Result of the `resourceCopy` command.
429
+ *
430
+ * An empty object on success.
431
+ */
432
+ export interface ResourceCopyResult {
433
+ }
434
+ /**
435
+ * Deletes a resource at a URI on the server's filesystem.
436
+ *
437
+ * @category Commands
438
+ * @method resourceDelete
439
+ * @direction Client → Server
440
+ * @messageType Request
441
+ * @version 1
442
+ * @throws `NotFound` (`-32008`) if the resource does not exist.
443
+ * @throws `PermissionDenied` (`-32009`) if the client is not permitted to delete the resource.
444
+ */
445
+ export interface ResourceDeleteParams extends BaseParams {
446
+ channel: 'ahp-root://';
447
+ /** URI of the resource to delete */
448
+ uri: URI;
449
+ /**
450
+ * If `true` and the target is a directory, delete it and all its contents
451
+ * recursively. If `false` (default), deleting a non-empty directory MUST fail.
452
+ */
453
+ recursive?: boolean;
454
+ }
455
+ /**
456
+ * Result of the `resourceDelete` command.
457
+ *
458
+ * An empty object on success.
459
+ */
460
+ export interface ResourceDeleteResult {
461
+ }
462
+ /**
463
+ * Requests permission to access a resource on the receiver's filesystem.
464
+ *
465
+ * `resourceRequest` is symmetrical and MAY be sent in either direction: a
466
+ * client asks the server to grant access to a server-side resource, or a
467
+ * server asks the client to grant access to a client-side resource. The
468
+ * receiver decides whether to allow, deny, or prompt the user for the
469
+ * requested access.
470
+ *
471
+ * If the receiver denies access, it MUST respond with `PermissionDenied`
472
+ * (-32009). The error data MAY include a `ResourceRequestParams` value
473
+ * describing the access the caller would need to be granted for the
474
+ * operation to succeed; see `PermissionDeniedErrorData` in
475
+ * `types/errors.ts`.
476
+ *
477
+ * After a successful `resourceRequest`, the caller MAY use the corresponding
478
+ * `resource*` commands (e.g. `resourceRead`, `resourceWrite`) to perform the
479
+ * operation. Receivers MAY rescind access at any time by returning
480
+ * `PermissionDenied` on subsequent operations.
481
+ *
482
+ * Either `read`, `write`, or both SHOULD be set to `true`. A request with
483
+ * neither flag set is treated as `read: true` by receivers.
484
+ *
485
+ * @category Commands
486
+ * @method resourceRequest
487
+ * @direction Client ↔ Server
488
+ * @messageType Request
489
+ * @version 1
490
+ * @throws `PermissionDenied` (`-32009`) if access is denied.
491
+ */
492
+ export interface ResourceRequestParams extends BaseParams {
493
+ channel: 'ahp-root://';
494
+ /**
495
+ * Resource URI being requested. Typically a `file:` URI on the receiver's
496
+ * filesystem, but any URI scheme that the receiver mediates access to is
497
+ * allowed.
498
+ */
499
+ uri: URI;
500
+ /** Whether the caller needs read access to the resource. */
501
+ read?: boolean;
502
+ /** Whether the caller needs write access to the resource. */
503
+ write?: boolean;
504
+ }
505
+ /**
506
+ * Result of the `resourceRequest` command.
507
+ *
508
+ * An empty object on success.
509
+ */
510
+ export interface ResourceRequestResult {
511
+ }
512
+ /**
513
+ * Moves (renames) a resource from one URI to another on the server's filesystem.
514
+ *
515
+ * If the destination already exists, it is overwritten unless `failIfExists`
516
+ * is set.
517
+ *
518
+ * @category Commands
519
+ * @method resourceMove
520
+ * @direction Client → Server
521
+ * @messageType Request
522
+ * @version 1
523
+ * @throws `NotFound` (`-32008`) if the source does not exist.
524
+ * @throws `PermissionDenied` (`-32009`) if the client is not permitted to move the resource.
525
+ * @throws `AlreadyExists` (`-32010`) if `failIfExists` is set and the destination already exists.
526
+ */
527
+ export interface ResourceMoveParams extends BaseParams {
528
+ channel: 'ahp-root://';
529
+ /** Source URI to move from */
530
+ source: URI;
531
+ /** Destination URI to move to */
532
+ destination: URI;
533
+ /**
534
+ * If `true`, the server MUST fail if the destination already exists instead
535
+ * of overwriting it.
536
+ */
537
+ failIfExists?: boolean;
538
+ }
539
+ /**
540
+ * Result of the `resourceMove` command.
541
+ *
542
+ * An empty object on success.
543
+ */
544
+ export interface ResourceMoveResult {
545
+ }
546
+ /**
547
+ * Pushes a Bearer token for a protected resource. The `resource` field MUST
548
+ * match a `ProtectedResourceMetadata.resource` value declared by an agent
549
+ * in `AgentInfo.protectedResources`.
550
+ *
551
+ * Tokens are delivered using [RFC 6750](https://datatracker.ietf.org/doc/html/rfc6750)
552
+ * (Bearer Token Usage) semantics. The client obtains the token from the
553
+ * authorization server(s) listed in the resource's metadata and pushes it
554
+ * to the server via this command.
555
+ *
556
+ * @category Commands
557
+ * @method authenticate
558
+ * @direction Client → Server
559
+ * @messageType Request
560
+ * @version 1
561
+ * @see {@link /specification/authentication | Authentication}
562
+ * @example
563
+ * ```jsonc
564
+ * // Client → Server
565
+ * { "jsonrpc": "2.0", "id": 3, "method": "authenticate",
566
+ * "params": { "channel": "ahp-root://", "resource": "https://api.github.com", "token": "gho_xxxx" } }
567
+ *
568
+ * // Server → Client (success)
569
+ * { "jsonrpc": "2.0", "id": 3, "result": {} }
570
+ *
571
+ * // Server → Client (failure — invalid token)
572
+ * { "jsonrpc": "2.0", "id": 3, "error": { "code": -32007, "message": "Invalid token" } }
573
+ * ```
574
+ */
575
+ export interface AuthenticateParams extends BaseParams {
576
+ channel: 'ahp-root://';
577
+ /**
578
+ * The protected resource identifier. MUST match a `resource` value from
579
+ * `ProtectedResourceMetadata` declared in `AgentInfo.protectedResources`.
580
+ */
581
+ resource: string;
582
+ /** Bearer token obtained from the resource's authorization server */
583
+ token: string;
584
+ }
585
+ /**
586
+ * Result of the `authenticate` command.
587
+ *
588
+ * An empty object on success. If the token is invalid or the resource is
589
+ * unrecognized, the server MUST return a JSON-RPC error (e.g. `AuthRequired`
590
+ * `-32007` or `InvalidParams` `-32602`).
591
+ */
592
+ export interface AuthenticateResult {
593
+ }
594
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../src/vendor/ahp/common/commands.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAIvE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,OAAO,EAAE,GAAG,CAAC;CACd;AAID;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,OAAO,EAAE,aAAa,CAAC;IACvB;;;;;;;;OAQG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,+BAA+B;IAC/B,QAAQ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IACvD,OAAO,EAAE,aAAa,CAAC;IACvB;;;;OAIG;IACH,GAAG,EAAE,GAAG,CAAC;IACT,4DAA4D;IAC5D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,6DAA6D;IAC7D,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;CACrC;AAID;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,OAAO,EAAE,aAAa,CAAC;IACvB,8BAA8B;IAC9B,MAAM,EAAE,GAAG,CAAC;IACZ,iCAAiC;IACjC,WAAW,EAAE,GAAG,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;CAClC;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,OAAO,EAAE,aAAa,CAAC;IACvB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;CAClC"}
@@ -0,0 +1,32 @@
1
+ /* eslint-disable -- vendored third-party code, see SOURCE.md */
2
+ /**
3
+ * Common Command Types — Connection-level commands (handshake, ping,
4
+ * reconnect, subscribe/unsubscribe, dispatchAction) plus the filesystem
5
+ * `resource*` family and `authenticate` that aren't specific to any one
6
+ * state channel.
7
+ *
8
+ * @module common/commands
9
+ */
10
+ // ─── reconnect ───────────────────────────────────────────────────────────────
11
+ /**
12
+ * Discriminant for reconnect result types.
13
+ *
14
+ * @category Commands
15
+ */
16
+ export var ReconnectResultType;
17
+ (function (ReconnectResultType) {
18
+ ReconnectResultType["Replay"] = "replay";
19
+ ReconnectResultType["Snapshot"] = "snapshot";
20
+ })(ReconnectResultType || (ReconnectResultType = {}));
21
+ // ─── resourceRead ────────────────────────────────────────────────────────
22
+ /**
23
+ * Encoding of fetched content data.
24
+ *
25
+ * @category Commands
26
+ */
27
+ export var ContentEncoding;
28
+ (function (ContentEncoding) {
29
+ ContentEncoding["Base64"] = "base64";
30
+ ContentEncoding["Utf8"] = "utf-8";
31
+ })(ContentEncoding || (ContentEncoding = {}));
32
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../../src/vendor/ahp/common/commands.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE;;;;;;;GAOG;AAkIH,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,CAAN,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,wCAAiB,CAAA;IACjB,4CAAqB,CAAA;AACvB,CAAC,EAHW,mBAAmB,KAAnB,mBAAmB,QAG9B;AAiID,4EAA4E;AAE5E;;;;GAIG;AACH,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,iCAAc,CAAA;AAChB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B"}