@ai-switch/tauri-plugin-runtime 0.1.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 (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +327 -0
  3. package/THIRD_PARTY_NOTICES.md +210 -0
  4. package/dist/bridge/handshake.d.ts +11 -0
  5. package/dist/bridge/json-codec.d.ts +4 -0
  6. package/dist/bridge/rpc-peer.d.ts +7 -0
  7. package/dist/bridge/rpc-types.d.ts +20 -0
  8. package/dist/chunk-CFQSUF5W.js +1794 -0
  9. package/dist/chunk-JSBRDJBE.js +30 -0
  10. package/dist/chunk-K5YWIJN6.js +389 -0
  11. package/dist/chunk-PW7XHHWG.js +403 -0
  12. package/dist/chunk-RKQEK7DY.js +13879 -0
  13. package/dist/chunk-WT62GTMC.js +18 -0
  14. package/dist/chunk-YI6NQ6WR.js +513 -0
  15. package/dist/host/event-router.d.ts +19 -0
  16. package/dist/host/file-handles.d.ts +15 -0
  17. package/dist/host/host.d.ts +2 -0
  18. package/dist/host/index.d.ts +4 -0
  19. package/dist/host/index.js +791 -0
  20. package/dist/host/policy.d.ts +7 -0
  21. package/dist/host/requests.d.ts +13 -0
  22. package/dist/host/types.d.ts +19 -0
  23. package/dist/host/view.d.ts +18 -0
  24. package/dist/index.d.ts +2 -0
  25. package/dist/index.js +9 -0
  26. package/dist/node/buffer.d.ts +7 -0
  27. package/dist/node/buffer.js +8 -0
  28. package/dist/node/events.d.ts +12 -0
  29. package/dist/node/events.js +458 -0
  30. package/dist/node/fs/backend.d.ts +8 -0
  31. package/dist/node/fs/callback-types.d.ts +43 -0
  32. package/dist/node/fs/callbacks.d.ts +3 -0
  33. package/dist/node/fs/client.d.ts +3 -0
  34. package/dist/node/fs/errors.d.ts +5 -0
  35. package/dist/node/fs/lifecycle.d.ts +11 -0
  36. package/dist/node/fs/options.d.ts +7 -0
  37. package/dist/node/fs/promises.d.ts +33 -0
  38. package/dist/node/fs/promises.js +30 -0
  39. package/dist/node/fs/transfer.d.ts +7 -0
  40. package/dist/node/fs/types.d.ts +86 -0
  41. package/dist/node/fs.d.ts +36 -0
  42. package/dist/node/fs.js +92 -0
  43. package/dist/node/path.d.ts +20 -0
  44. package/dist/node/path.js +434 -0
  45. package/dist/plugin/client.d.ts +4 -0
  46. package/dist/plugin/connection.d.ts +6 -0
  47. package/dist/plugin/errors.d.ts +3 -0
  48. package/dist/plugin/index.d.ts +6 -0
  49. package/dist/plugin/index.js +12 -0
  50. package/dist/plugin/types.d.ts +28 -0
  51. package/dist/protocol/capabilities.d.ts +8 -0
  52. package/dist/protocol/errors.d.ts +14 -0
  53. package/dist/protocol/generated/capabilities.generated.d.ts +56 -0
  54. package/dist/protocol/generated/fs.generated.d.ts +178 -0
  55. package/dist/protocol/generated/host-event.generated.d.ts +17 -0
  56. package/dist/protocol/generated/manifest.generated.d.ts +64 -0
  57. package/dist/protocol/generated/session.generated.d.ts +93 -0
  58. package/dist/protocol/generated/types.generated.d.ts +6 -0
  59. package/dist/protocol/generated/validators.generated.d.mts +24 -0
  60. package/dist/protocol/generated/wire.generated.d.ts +63 -0
  61. package/dist/protocol/index.d.ts +18 -0
  62. package/dist/protocol/index.js +746 -0
  63. package/dist/protocol/json-safety.d.ts +3 -0
  64. package/dist/protocol/limits.d.ts +11 -0
  65. package/dist/protocol/manifest.d.ts +5 -0
  66. package/dist/protocol/path-policy.d.ts +2 -0
  67. package/dist/protocol/schema/capabilities.schema.json +301 -0
  68. package/dist/protocol/schema/fs.schema.json +900 -0
  69. package/dist/protocol/schema/host-event.schema.json +116 -0
  70. package/dist/protocol/schema/manifest.schema.json +60 -0
  71. package/dist/protocol/schema/session.schema.json +145 -0
  72. package/dist/protocol/schema/wire.schema.json +358 -0
  73. package/dist/protocol/session.d.ts +3 -0
  74. package/dist/protocol/types.d.ts +27 -0
  75. package/dist/protocol/validation.d.ts +2 -0
  76. package/dist/protocol/wire.d.ts +16 -0
  77. package/package.json +95 -0
@@ -0,0 +1,434 @@
1
+ import {
2
+ __commonJS,
3
+ __toESM
4
+ } from "../chunk-JSBRDJBE.js";
5
+
6
+ // ../../node_modules/.pnpm/path-browserify@1.0.1/node_modules/path-browserify/index.js
7
+ var require_path_browserify = __commonJS({
8
+ "../../node_modules/.pnpm/path-browserify@1.0.1/node_modules/path-browserify/index.js"(exports, module) {
9
+ "use strict";
10
+ function assertPath(path) {
11
+ if (typeof path !== "string") {
12
+ throw new TypeError("Path must be a string. Received " + JSON.stringify(path));
13
+ }
14
+ }
15
+ function normalizeStringPosix(path, allowAboveRoot) {
16
+ var res = "";
17
+ var lastSegmentLength = 0;
18
+ var lastSlash = -1;
19
+ var dots = 0;
20
+ var code;
21
+ for (var i = 0; i <= path.length; ++i) {
22
+ if (i < path.length)
23
+ code = path.charCodeAt(i);
24
+ else if (code === 47)
25
+ break;
26
+ else
27
+ code = 47;
28
+ if (code === 47) {
29
+ if (lastSlash === i - 1 || dots === 1) {
30
+ } else if (lastSlash !== i - 1 && dots === 2) {
31
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
32
+ if (res.length > 2) {
33
+ var lastSlashIndex = res.lastIndexOf("/");
34
+ if (lastSlashIndex !== res.length - 1) {
35
+ if (lastSlashIndex === -1) {
36
+ res = "";
37
+ lastSegmentLength = 0;
38
+ } else {
39
+ res = res.slice(0, lastSlashIndex);
40
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
41
+ }
42
+ lastSlash = i;
43
+ dots = 0;
44
+ continue;
45
+ }
46
+ } else if (res.length === 2 || res.length === 1) {
47
+ res = "";
48
+ lastSegmentLength = 0;
49
+ lastSlash = i;
50
+ dots = 0;
51
+ continue;
52
+ }
53
+ }
54
+ if (allowAboveRoot) {
55
+ if (res.length > 0)
56
+ res += "/..";
57
+ else
58
+ res = "..";
59
+ lastSegmentLength = 2;
60
+ }
61
+ } else {
62
+ if (res.length > 0)
63
+ res += "/" + path.slice(lastSlash + 1, i);
64
+ else
65
+ res = path.slice(lastSlash + 1, i);
66
+ lastSegmentLength = i - lastSlash - 1;
67
+ }
68
+ lastSlash = i;
69
+ dots = 0;
70
+ } else if (code === 46 && dots !== -1) {
71
+ ++dots;
72
+ } else {
73
+ dots = -1;
74
+ }
75
+ }
76
+ return res;
77
+ }
78
+ function _format(sep, pathObject) {
79
+ var dir = pathObject.dir || pathObject.root;
80
+ var base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
81
+ if (!dir) {
82
+ return base;
83
+ }
84
+ if (dir === pathObject.root) {
85
+ return dir + base;
86
+ }
87
+ return dir + sep + base;
88
+ }
89
+ var posix2 = {
90
+ // path.resolve([from ...], to)
91
+ resolve: function resolve2() {
92
+ var resolvedPath = "";
93
+ var resolvedAbsolute = false;
94
+ var cwd;
95
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
96
+ var path;
97
+ if (i >= 0)
98
+ path = arguments[i];
99
+ else {
100
+ if (cwd === void 0)
101
+ cwd = process.cwd();
102
+ path = cwd;
103
+ }
104
+ assertPath(path);
105
+ if (path.length === 0) {
106
+ continue;
107
+ }
108
+ resolvedPath = path + "/" + resolvedPath;
109
+ resolvedAbsolute = path.charCodeAt(0) === 47;
110
+ }
111
+ resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
112
+ if (resolvedAbsolute) {
113
+ if (resolvedPath.length > 0)
114
+ return "/" + resolvedPath;
115
+ else
116
+ return "/";
117
+ } else if (resolvedPath.length > 0) {
118
+ return resolvedPath;
119
+ } else {
120
+ return ".";
121
+ }
122
+ },
123
+ normalize: function normalize2(path) {
124
+ assertPath(path);
125
+ if (path.length === 0) return ".";
126
+ var isAbsolute2 = path.charCodeAt(0) === 47;
127
+ var trailingSeparator = path.charCodeAt(path.length - 1) === 47;
128
+ path = normalizeStringPosix(path, !isAbsolute2);
129
+ if (path.length === 0 && !isAbsolute2) path = ".";
130
+ if (path.length > 0 && trailingSeparator) path += "/";
131
+ if (isAbsolute2) return "/" + path;
132
+ return path;
133
+ },
134
+ isAbsolute: function isAbsolute2(path) {
135
+ assertPath(path);
136
+ return path.length > 0 && path.charCodeAt(0) === 47;
137
+ },
138
+ join: function join2() {
139
+ if (arguments.length === 0)
140
+ return ".";
141
+ var joined;
142
+ for (var i = 0; i < arguments.length; ++i) {
143
+ var arg = arguments[i];
144
+ assertPath(arg);
145
+ if (arg.length > 0) {
146
+ if (joined === void 0)
147
+ joined = arg;
148
+ else
149
+ joined += "/" + arg;
150
+ }
151
+ }
152
+ if (joined === void 0)
153
+ return ".";
154
+ return posix2.normalize(joined);
155
+ },
156
+ relative: function relative2(from, to) {
157
+ assertPath(from);
158
+ assertPath(to);
159
+ if (from === to) return "";
160
+ from = posix2.resolve(from);
161
+ to = posix2.resolve(to);
162
+ if (from === to) return "";
163
+ var fromStart = 1;
164
+ for (; fromStart < from.length; ++fromStart) {
165
+ if (from.charCodeAt(fromStart) !== 47)
166
+ break;
167
+ }
168
+ var fromEnd = from.length;
169
+ var fromLen = fromEnd - fromStart;
170
+ var toStart = 1;
171
+ for (; toStart < to.length; ++toStart) {
172
+ if (to.charCodeAt(toStart) !== 47)
173
+ break;
174
+ }
175
+ var toEnd = to.length;
176
+ var toLen = toEnd - toStart;
177
+ var length = fromLen < toLen ? fromLen : toLen;
178
+ var lastCommonSep = -1;
179
+ var i = 0;
180
+ for (; i <= length; ++i) {
181
+ if (i === length) {
182
+ if (toLen > length) {
183
+ if (to.charCodeAt(toStart + i) === 47) {
184
+ return to.slice(toStart + i + 1);
185
+ } else if (i === 0) {
186
+ return to.slice(toStart + i);
187
+ }
188
+ } else if (fromLen > length) {
189
+ if (from.charCodeAt(fromStart + i) === 47) {
190
+ lastCommonSep = i;
191
+ } else if (i === 0) {
192
+ lastCommonSep = 0;
193
+ }
194
+ }
195
+ break;
196
+ }
197
+ var fromCode = from.charCodeAt(fromStart + i);
198
+ var toCode = to.charCodeAt(toStart + i);
199
+ if (fromCode !== toCode)
200
+ break;
201
+ else if (fromCode === 47)
202
+ lastCommonSep = i;
203
+ }
204
+ var out = "";
205
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
206
+ if (i === fromEnd || from.charCodeAt(i) === 47) {
207
+ if (out.length === 0)
208
+ out += "..";
209
+ else
210
+ out += "/..";
211
+ }
212
+ }
213
+ if (out.length > 0)
214
+ return out + to.slice(toStart + lastCommonSep);
215
+ else {
216
+ toStart += lastCommonSep;
217
+ if (to.charCodeAt(toStart) === 47)
218
+ ++toStart;
219
+ return to.slice(toStart);
220
+ }
221
+ },
222
+ _makeLong: function _makeLong(path) {
223
+ return path;
224
+ },
225
+ dirname: function dirname2(path) {
226
+ assertPath(path);
227
+ if (path.length === 0) return ".";
228
+ var code = path.charCodeAt(0);
229
+ var hasRoot = code === 47;
230
+ var end = -1;
231
+ var matchedSlash = true;
232
+ for (var i = path.length - 1; i >= 1; --i) {
233
+ code = path.charCodeAt(i);
234
+ if (code === 47) {
235
+ if (!matchedSlash) {
236
+ end = i;
237
+ break;
238
+ }
239
+ } else {
240
+ matchedSlash = false;
241
+ }
242
+ }
243
+ if (end === -1) return hasRoot ? "/" : ".";
244
+ if (hasRoot && end === 1) return "//";
245
+ return path.slice(0, end);
246
+ },
247
+ basename: function basename2(path, ext) {
248
+ if (ext !== void 0 && typeof ext !== "string") throw new TypeError('"ext" argument must be a string');
249
+ assertPath(path);
250
+ var start = 0;
251
+ var end = -1;
252
+ var matchedSlash = true;
253
+ var i;
254
+ if (ext !== void 0 && ext.length > 0 && ext.length <= path.length) {
255
+ if (ext.length === path.length && ext === path) return "";
256
+ var extIdx = ext.length - 1;
257
+ var firstNonSlashEnd = -1;
258
+ for (i = path.length - 1; i >= 0; --i) {
259
+ var code = path.charCodeAt(i);
260
+ if (code === 47) {
261
+ if (!matchedSlash) {
262
+ start = i + 1;
263
+ break;
264
+ }
265
+ } else {
266
+ if (firstNonSlashEnd === -1) {
267
+ matchedSlash = false;
268
+ firstNonSlashEnd = i + 1;
269
+ }
270
+ if (extIdx >= 0) {
271
+ if (code === ext.charCodeAt(extIdx)) {
272
+ if (--extIdx === -1) {
273
+ end = i;
274
+ }
275
+ } else {
276
+ extIdx = -1;
277
+ end = firstNonSlashEnd;
278
+ }
279
+ }
280
+ }
281
+ }
282
+ if (start === end) end = firstNonSlashEnd;
283
+ else if (end === -1) end = path.length;
284
+ return path.slice(start, end);
285
+ } else {
286
+ for (i = path.length - 1; i >= 0; --i) {
287
+ if (path.charCodeAt(i) === 47) {
288
+ if (!matchedSlash) {
289
+ start = i + 1;
290
+ break;
291
+ }
292
+ } else if (end === -1) {
293
+ matchedSlash = false;
294
+ end = i + 1;
295
+ }
296
+ }
297
+ if (end === -1) return "";
298
+ return path.slice(start, end);
299
+ }
300
+ },
301
+ extname: function extname2(path) {
302
+ assertPath(path);
303
+ var startDot = -1;
304
+ var startPart = 0;
305
+ var end = -1;
306
+ var matchedSlash = true;
307
+ var preDotState = 0;
308
+ for (var i = path.length - 1; i >= 0; --i) {
309
+ var code = path.charCodeAt(i);
310
+ if (code === 47) {
311
+ if (!matchedSlash) {
312
+ startPart = i + 1;
313
+ break;
314
+ }
315
+ continue;
316
+ }
317
+ if (end === -1) {
318
+ matchedSlash = false;
319
+ end = i + 1;
320
+ }
321
+ if (code === 46) {
322
+ if (startDot === -1)
323
+ startDot = i;
324
+ else if (preDotState !== 1)
325
+ preDotState = 1;
326
+ } else if (startDot !== -1) {
327
+ preDotState = -1;
328
+ }
329
+ }
330
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
331
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
332
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
333
+ return "";
334
+ }
335
+ return path.slice(startDot, end);
336
+ },
337
+ format: function format(pathObject) {
338
+ if (pathObject === null || typeof pathObject !== "object") {
339
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
340
+ }
341
+ return _format("/", pathObject);
342
+ },
343
+ parse: function parse(path) {
344
+ assertPath(path);
345
+ var ret = { root: "", dir: "", base: "", ext: "", name: "" };
346
+ if (path.length === 0) return ret;
347
+ var code = path.charCodeAt(0);
348
+ var isAbsolute2 = code === 47;
349
+ var start;
350
+ if (isAbsolute2) {
351
+ ret.root = "/";
352
+ start = 1;
353
+ } else {
354
+ start = 0;
355
+ }
356
+ var startDot = -1;
357
+ var startPart = 0;
358
+ var end = -1;
359
+ var matchedSlash = true;
360
+ var i = path.length - 1;
361
+ var preDotState = 0;
362
+ for (; i >= start; --i) {
363
+ code = path.charCodeAt(i);
364
+ if (code === 47) {
365
+ if (!matchedSlash) {
366
+ startPart = i + 1;
367
+ break;
368
+ }
369
+ continue;
370
+ }
371
+ if (end === -1) {
372
+ matchedSlash = false;
373
+ end = i + 1;
374
+ }
375
+ if (code === 46) {
376
+ if (startDot === -1) startDot = i;
377
+ else if (preDotState !== 1) preDotState = 1;
378
+ } else if (startDot !== -1) {
379
+ preDotState = -1;
380
+ }
381
+ }
382
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
383
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
384
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
385
+ if (end !== -1) {
386
+ if (startPart === 0 && isAbsolute2) ret.base = ret.name = path.slice(1, end);
387
+ else ret.base = ret.name = path.slice(startPart, end);
388
+ }
389
+ } else {
390
+ if (startPart === 0 && isAbsolute2) {
391
+ ret.name = path.slice(1, startDot);
392
+ ret.base = path.slice(1, end);
393
+ } else {
394
+ ret.name = path.slice(startPart, startDot);
395
+ ret.base = path.slice(startPart, end);
396
+ }
397
+ ret.ext = path.slice(startDot, end);
398
+ }
399
+ if (startPart > 0) ret.dir = path.slice(0, startPart - 1);
400
+ else if (isAbsolute2) ret.dir = "/";
401
+ return ret;
402
+ },
403
+ sep: "/",
404
+ delimiter: ":",
405
+ win32: null,
406
+ posix: null
407
+ };
408
+ posix2.posix = posix2;
409
+ module.exports = posix2;
410
+ }
411
+ });
412
+
413
+ // src/node/path.ts
414
+ var import_path_browserify = __toESM(require_path_browserify(), 1);
415
+ var join = (...parts) => import_path_browserify.default.join(...parts);
416
+ var resolve = (...parts) => import_path_browserify.default.resolve("/data", ...parts);
417
+ var normalize = (path) => import_path_browserify.default.normalize(path);
418
+ var dirname = (path) => import_path_browserify.default.dirname(path);
419
+ var basename = (path, suffix) => import_path_browserify.default.basename(path, suffix);
420
+ var extname = (path) => import_path_browserify.default.extname(path);
421
+ var isAbsolute = (path) => import_path_browserify.default.isAbsolute(path);
422
+ var relative = (from, to) => import_path_browserify.default.relative(resolve(from), resolve(to));
423
+ var path_default = Object.freeze({ join, resolve, normalize, dirname, basename, extname, relative, isAbsolute });
424
+ export {
425
+ basename,
426
+ path_default as default,
427
+ dirname,
428
+ extname,
429
+ isAbsolute,
430
+ join,
431
+ normalize,
432
+ relative,
433
+ resolve
434
+ };
@@ -0,0 +1,4 @@
1
+ import type { SessionInfo } from "../protocol/wire.js";
2
+ import type { RpcPeer } from "../bridge/rpc-types.js";
3
+ import type { PluginApi } from "./types.js";
4
+ export declare function createPluginClient(peer: RpcPeer, sessionInfo: SessionInfo): PluginApi;
@@ -0,0 +1,6 @@
1
+ import type { SessionInfo } from "../protocol/wire.js";
2
+ import type { ConnectionState, PluginApi } from "./types.js";
3
+ export declare function getPluginClient(): Promise<PluginApi>;
4
+ export declare function connectPlugin(): Promise<SessionInfo>;
5
+ export declare function supportsCapability(name: string, range?: string): boolean;
6
+ export declare function onConnectionChange(callback: (state: ConnectionState) => void): () => void;
@@ -0,0 +1,3 @@
1
+ import { type ErrorPayload } from "../protocol/errors.js";
2
+ /** The caller must already have validated the remote wire envelope. */
3
+ export declare function fromErrorPayload(payload: ErrorPayload): Error;
@@ -0,0 +1,6 @@
1
+ import { connectPlugin } from "./connection.js";
2
+ import type { PluginApi } from "./types.js";
3
+ export { connectPlugin };
4
+ export type { CallOptions, ConnectionState, DirectorySelection, PluginApi } from "./types.js";
5
+ /** Importing the public entry never connects or touches browser globals. */
6
+ export declare const aplg: PluginApi;
@@ -0,0 +1,12 @@
1
+ import {
2
+ aplg,
3
+ connectPlugin
4
+ } from "../chunk-K5YWIJN6.js";
5
+ import "../chunk-PW7XHHWG.js";
6
+ import "../chunk-RKQEK7DY.js";
7
+ import "../chunk-WT62GTMC.js";
8
+ import "../chunk-JSBRDJBE.js";
9
+ export {
10
+ aplg,
11
+ connectPlugin
12
+ };
@@ -0,0 +1,28 @@
1
+ import type { CallOptions } from "../bridge/rpc-types.js";
2
+ import type { SessionInfo, Unsubscribe } from "../protocol/wire.js";
3
+ import type { JsonValue } from "../protocol/types.js";
4
+ export type ConnectionState = "connected" | "disconnected" | "closed";
5
+ export type DirectorySelection = {
6
+ path: string;
7
+ access: "read" | "readwrite";
8
+ } | null;
9
+ export interface PluginApi {
10
+ ready(): Promise<SessionInfo>;
11
+ capabilities: {
12
+ supports(name: string, range?: string): boolean;
13
+ };
14
+ call<T extends JsonValue>(capability: string, method: string, params?: JsonValue, options?: CallOptions): Promise<T>;
15
+ subscribe(capability: string, topic: string, handler: (payload: JsonValue) => void): Promise<Unsubscribe>;
16
+ onConnectionChange(handler: (state: ConnectionState) => void): Unsubscribe;
17
+ storage: {
18
+ get(key: string): Promise<JsonValue>;
19
+ set(key: string, value: JsonValue): Promise<void>;
20
+ remove(key: string): Promise<void>;
21
+ };
22
+ dialog: {
23
+ pickDirectory(options?: {
24
+ access?: "read" | "readwrite";
25
+ }): Promise<DirectorySelection>;
26
+ };
27
+ }
28
+ export type { CallOptions };
@@ -0,0 +1,8 @@
1
+ import type { JsonValue, ValidationResult } from "./types.js";
2
+ /** Methods come from the authoritative schemas, not a second handwritten list. */
3
+ export declare const standardCapabilities: Readonly<Record<string, {
4
+ readonly version: string;
5
+ readonly methods: readonly string[];
6
+ }>>;
7
+ export declare function validateCapabilityRequest(capability: string, method: string, params: unknown): ValidationResult<JsonValue>;
8
+ export declare function validateCapabilityResult(capability: string, method: string, result: unknown): ValidationResult<JsonValue>;
@@ -0,0 +1,14 @@
1
+ import type { JsonValue } from "./types.js";
2
+ import type { WireMessage } from "./generated/types.generated.js";
3
+ export type ErrorPayload = Extract<WireMessage, {
4
+ kind: "error";
5
+ }>["error"];
6
+ export declare const errorCodes: readonly ["E_CAPABILITY_UNAVAILABLE", "E_PERMISSION_DENIED", "E_SESSION_CLOSED", "E_TIMEOUT", "E_CANCELLED", "E_LIMIT_EXCEEDED", "E_PROTOCOL_MISMATCH", "E_INVALID_ARGUMENT", "E_INVALID_MESSAGE", "E_HOST_UNAVAILABLE"];
7
+ export type AplgErrorCode = typeof errorCodes[number];
8
+ /** Only construct this with a deliberately public message and JSON details. */
9
+ export declare class AplgError extends Error {
10
+ readonly code: AplgErrorCode;
11
+ readonly details?: JsonValue;
12
+ constructor(code: AplgErrorCode, message: string, details?: JsonValue);
13
+ }
14
+ export declare function toErrorPayload(error: unknown): ErrorPayload;
@@ -0,0 +1,56 @@
1
+ export type StandardCapabilityMessage = {
2
+ capability: "aplg.storage";
3
+ method: "get";
4
+ direction: "request";
5
+ value: {
6
+ key: string;
7
+ };
8
+ } | {
9
+ capability: "aplg.storage";
10
+ method: "get";
11
+ direction: "result";
12
+ value: JsonValue;
13
+ } | {
14
+ capability: "aplg.storage";
15
+ method: "set";
16
+ direction: "request";
17
+ value: {
18
+ key: string;
19
+ value: JsonValue;
20
+ };
21
+ } | {
22
+ capability: "aplg.storage";
23
+ method: "set";
24
+ direction: "result";
25
+ value: null;
26
+ } | {
27
+ capability: "aplg.storage";
28
+ method: "remove";
29
+ direction: "request";
30
+ value: {
31
+ key: string;
32
+ };
33
+ } | {
34
+ capability: "aplg.storage";
35
+ method: "remove";
36
+ direction: "result";
37
+ value: null;
38
+ } | {
39
+ capability: "aplg.dialog";
40
+ method: "pickDirectory";
41
+ direction: "request";
42
+ value: {
43
+ access?: "read" | "readwrite";
44
+ };
45
+ } | {
46
+ capability: "aplg.dialog";
47
+ method: "pickDirectory";
48
+ direction: "result";
49
+ value: null | {
50
+ path: string;
51
+ access: "read" | "readwrite";
52
+ };
53
+ };
54
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
55
+ [k: string]: JsonValue;
56
+ };