@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,178 @@
1
+ export type FsCapabilityMessage = {
2
+ capability: "aplg.fs";
3
+ method: "transfer.openRead";
4
+ direction: "request";
5
+ value: {
6
+ path: string;
7
+ };
8
+ } | {
9
+ capability: "aplg.fs";
10
+ method: "transfer.openRead";
11
+ direction: "result";
12
+ value: {
13
+ handle: string;
14
+ size: number;
15
+ };
16
+ } | {
17
+ capability: "aplg.fs";
18
+ method: "transfer.openWrite";
19
+ direction: "request";
20
+ value: {
21
+ path: string;
22
+ size: number;
23
+ mode: "w" | "wx" | "a" | "ax";
24
+ };
25
+ } | {
26
+ capability: "aplg.fs";
27
+ method: "transfer.openWrite";
28
+ direction: "result";
29
+ value: {
30
+ handle: string;
31
+ };
32
+ } | {
33
+ capability: "aplg.fs";
34
+ method: "transfer.pull";
35
+ direction: "request";
36
+ value: {
37
+ handle: string;
38
+ offset: number;
39
+ length: number;
40
+ };
41
+ } | {
42
+ capability: "aplg.fs";
43
+ method: "transfer.pull";
44
+ direction: "result";
45
+ value: {
46
+ offset: number;
47
+ dataBase64: string;
48
+ };
49
+ } | {
50
+ capability: "aplg.fs";
51
+ method: "transfer.push";
52
+ direction: "request";
53
+ value: {
54
+ handle: string;
55
+ offset: number;
56
+ dataBase64: string;
57
+ };
58
+ } | {
59
+ capability: "aplg.fs";
60
+ method: "transfer.push";
61
+ direction: "result";
62
+ value: {
63
+ written: number;
64
+ };
65
+ } | {
66
+ capability: "aplg.fs";
67
+ method: "transfer.finish";
68
+ direction: "request";
69
+ value: {
70
+ handle: string;
71
+ };
72
+ } | {
73
+ capability: "aplg.fs";
74
+ method: "transfer.finish";
75
+ direction: "result";
76
+ value: null;
77
+ } | {
78
+ capability: "aplg.fs";
79
+ method: "transfer.abort";
80
+ direction: "request";
81
+ value: {
82
+ handle: string;
83
+ };
84
+ } | {
85
+ capability: "aplg.fs";
86
+ method: "transfer.abort";
87
+ direction: "result";
88
+ value: null;
89
+ } | {
90
+ capability: "aplg.fs";
91
+ method: "stat";
92
+ direction: "request";
93
+ value: {
94
+ path: string;
95
+ };
96
+ } | {
97
+ capability: "aplg.fs";
98
+ method: "stat";
99
+ direction: "result";
100
+ value: {
101
+ kind: "file" | "directory";
102
+ size: number;
103
+ mtimeMs: number;
104
+ };
105
+ } | {
106
+ capability: "aplg.fs";
107
+ method: "readdir";
108
+ direction: "request";
109
+ value: {
110
+ path: string;
111
+ };
112
+ } | {
113
+ capability: "aplg.fs";
114
+ method: "readdir";
115
+ direction: "result";
116
+ /**
117
+ * @maxItems 10000
118
+ */
119
+ value: {
120
+ name: string;
121
+ kind: "file" | "directory";
122
+ }[];
123
+ } | {
124
+ capability: "aplg.fs";
125
+ method: "mkdir";
126
+ direction: "request";
127
+ value: {
128
+ path: string;
129
+ recursive: boolean;
130
+ };
131
+ } | {
132
+ capability: "aplg.fs";
133
+ method: "mkdir";
134
+ direction: "result";
135
+ value: {
136
+ createdPath: null | string;
137
+ };
138
+ } | {
139
+ capability: "aplg.fs";
140
+ method: "rename";
141
+ direction: "request";
142
+ value: {
143
+ from: string;
144
+ to: string;
145
+ };
146
+ } | {
147
+ capability: "aplg.fs";
148
+ method: "rename";
149
+ direction: "result";
150
+ value: null;
151
+ } | {
152
+ capability: "aplg.fs";
153
+ method: "copyFile";
154
+ direction: "request";
155
+ value: {
156
+ from: string;
157
+ to: string;
158
+ };
159
+ } | {
160
+ capability: "aplg.fs";
161
+ method: "copyFile";
162
+ direction: "result";
163
+ value: null;
164
+ } | {
165
+ capability: "aplg.fs";
166
+ method: "rm";
167
+ direction: "request";
168
+ value: {
169
+ path: string;
170
+ recursive: boolean;
171
+ force: boolean;
172
+ };
173
+ } | {
174
+ capability: "aplg.fs";
175
+ method: "rm";
176
+ direction: "result";
177
+ value: null;
178
+ };
@@ -0,0 +1,17 @@
1
+ export type HostEvent = {
2
+ kind: "capability.event";
3
+ sessionId: string;
4
+ subscriptionId: string;
5
+ seq: number;
6
+ payload: JsonValue;
7
+ } | {
8
+ kind: "session.closed";
9
+ sessionId: string;
10
+ reason: string;
11
+ } | {
12
+ kind: "transport.state";
13
+ state: "connected" | "disconnected";
14
+ };
15
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
16
+ [k: string]: JsonValue;
17
+ };
@@ -0,0 +1,64 @@
1
+ export type Range = string;
2
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
3
+ [k: string]: JsonValue;
4
+ };
5
+ export interface Manifest {
6
+ manifestVersion: 1;
7
+ id: string;
8
+ name: string;
9
+ version: string;
10
+ description: string;
11
+ license: string;
12
+ engines: {
13
+ aplg: Range;
14
+ };
15
+ entry: string;
16
+ activation: "view";
17
+ requires: CapabilityRanges;
18
+ optional: CapabilityRanges;
19
+ permissions: {
20
+ /**
21
+ * @maxItems 2
22
+ */
23
+ filesystem: {
24
+ root: "plugin-data" | "user-selected";
25
+ /**
26
+ * @minItems 1
27
+ * @maxItems 2
28
+ */
29
+ access: ("read" | "write")[];
30
+ }[];
31
+ /**
32
+ * @maxItems 64
33
+ */
34
+ network: {
35
+ /**
36
+ * @minItems 1
37
+ * @maxItems 64
38
+ */
39
+ origins: string[];
40
+ /**
41
+ * @minItems 1
42
+ * @maxItems 9
43
+ */
44
+ methods: ("GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "CONNECT" | "TRACE")[];
45
+ }[];
46
+ native: boolean;
47
+ };
48
+ contributes: {
49
+ /**
50
+ * @minItems 1
51
+ * @maxItems 32
52
+ */
53
+ views: {
54
+ id: string;
55
+ title: string;
56
+ }[];
57
+ };
58
+ extensions?: {
59
+ [k: string]: JsonValue;
60
+ };
61
+ }
62
+ export interface CapabilityRanges {
63
+ [k: string]: Range;
64
+ }
@@ -0,0 +1,93 @@
1
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
2
+ [k: string]: JsonValue;
3
+ };
4
+ export interface SessionDescriptor {
5
+ sessionId: string;
6
+ manifest: Manifest;
7
+ assetUrl: string;
8
+ info: {
9
+ protocol: "aplg/1";
10
+ apiVersion: string;
11
+ plugin: {
12
+ id: string;
13
+ version: string;
14
+ packageSha256: string;
15
+ };
16
+ capabilities: {
17
+ [k: string]: {
18
+ version: string;
19
+ /**
20
+ * @minItems 1
21
+ * @maxItems 128
22
+ */
23
+ methods: string[];
24
+ };
25
+ };
26
+ limits: {
27
+ controlBytes: number;
28
+ fileChunkBytes: number;
29
+ fileBytes: number;
30
+ fileTransfers: number;
31
+ };
32
+ };
33
+ }
34
+ export interface Manifest {
35
+ manifestVersion: 1;
36
+ id: string;
37
+ name: string;
38
+ version: string;
39
+ description: string;
40
+ license: string;
41
+ engines: {
42
+ aplg: string;
43
+ };
44
+ entry: string;
45
+ activation: "view";
46
+ requires: CapabilityRanges;
47
+ optional: CapabilityRanges;
48
+ permissions: {
49
+ /**
50
+ * @maxItems 2
51
+ */
52
+ filesystem: {
53
+ root: "plugin-data" | "user-selected";
54
+ /**
55
+ * @minItems 1
56
+ * @maxItems 2
57
+ */
58
+ access: ("read" | "write")[];
59
+ }[];
60
+ /**
61
+ * @maxItems 64
62
+ */
63
+ network: {
64
+ /**
65
+ * @minItems 1
66
+ * @maxItems 64
67
+ */
68
+ origins: string[];
69
+ /**
70
+ * @minItems 1
71
+ * @maxItems 9
72
+ */
73
+ methods: ("GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "CONNECT" | "TRACE")[];
74
+ }[];
75
+ native: boolean;
76
+ };
77
+ contributes: {
78
+ /**
79
+ * @minItems 1
80
+ * @maxItems 32
81
+ */
82
+ views: {
83
+ id: string;
84
+ title: string;
85
+ }[];
86
+ };
87
+ extensions?: {
88
+ [k: string]: JsonValue;
89
+ };
90
+ }
91
+ export interface CapabilityRanges {
92
+ [k: string]: string;
93
+ }
@@ -0,0 +1,6 @@
1
+ export type { StandardCapabilityMessage } from "./capabilities.generated.js";
2
+ export type { FsCapabilityMessage } from "./fs.generated.js";
3
+ export type { HostEvent } from "./host-event.generated.js";
4
+ export type { Manifest } from "./manifest.generated.js";
5
+ export type { SessionDescriptor } from "./session.generated.js";
6
+ export type { WireMessage } from "./wire.generated.js";
@@ -0,0 +1,24 @@
1
+ export function validateFsCapabilityMessageSchema(data: any, { instancePath, parentData, parentDataProperty, rootData }?: {
2
+ instancePath?: string | undefined;
3
+ rootData?: any;
4
+ }): boolean;
5
+ export function validateHostEventSchema(data: any, { instancePath, parentData, parentDataProperty, rootData }?: {
6
+ instancePath?: string | undefined;
7
+ rootData?: any;
8
+ }): boolean;
9
+ export function validateManifestSchema(data: any, { instancePath, parentData, parentDataProperty, rootData }?: {
10
+ instancePath?: string | undefined;
11
+ rootData?: any;
12
+ }): boolean;
13
+ export function validateSessionDescriptorSchema(data: any, { instancePath, parentData, parentDataProperty, rootData }?: {
14
+ instancePath?: string | undefined;
15
+ rootData?: any;
16
+ }): boolean;
17
+ export function validateStandardCapabilityMessageSchema(data: any, { instancePath, parentData, parentDataProperty, rootData }?: {
18
+ instancePath?: string | undefined;
19
+ rootData?: any;
20
+ }): boolean;
21
+ export function validateWireMessageSchema(data: any, { instancePath, parentData, parentDataProperty, rootData }?: {
22
+ instancePath?: string | undefined;
23
+ rootData?: any;
24
+ }): boolean;
@@ -0,0 +1,63 @@
1
+ export type WireMessage = {
2
+ protocol: "aplg/1";
3
+ kind: "request";
4
+ id: string;
5
+ operation: "capability.call";
6
+ args: {
7
+ capability: string;
8
+ method: string;
9
+ params: JsonValue;
10
+ };
11
+ } | {
12
+ protocol: "aplg/1";
13
+ kind: "request";
14
+ id: string;
15
+ operation: "subscription.open";
16
+ args: {
17
+ capability: string;
18
+ topic: string;
19
+ };
20
+ } | {
21
+ protocol: "aplg/1";
22
+ kind: "request";
23
+ id: string;
24
+ operation: "subscription.close";
25
+ args: {
26
+ subscriptionId: string;
27
+ };
28
+ } | {
29
+ protocol: "aplg/1";
30
+ kind: "request";
31
+ id: string;
32
+ operation: "request.cancel";
33
+ args: {
34
+ requestId: string;
35
+ };
36
+ } | {
37
+ protocol: "aplg/1";
38
+ kind: "result";
39
+ id: string;
40
+ value: JsonValue;
41
+ } | {
42
+ protocol: "aplg/1";
43
+ kind: "error";
44
+ id: string;
45
+ error: {
46
+ code: string;
47
+ message: string;
48
+ details?: JsonValue;
49
+ };
50
+ } | {
51
+ protocol: "aplg/1";
52
+ kind: "event";
53
+ subscriptionId: string;
54
+ seq: number;
55
+ payload: JsonValue;
56
+ } | {
57
+ protocol: "aplg/1";
58
+ kind: "connection";
59
+ state: "connected" | "disconnected" | "closed";
60
+ };
61
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
62
+ [k: string]: JsonValue;
63
+ };
@@ -0,0 +1,18 @@
1
+ export type { Manifest } from "./generated/types.generated.js";
2
+ export type { JsonValue, JsonObject, Diagnostic, ValidationResult } from "./types.js";
3
+ export { validateManifest, parseManifest, satisfiesApiRange } from "./manifest.js";
4
+ export { normalizeArchivePath, validateVirtualPath } from "./path-policy.js";
5
+ export { protocolVersion, apiVersion, limits } from "./limits.js";
6
+ export { default as manifestSchema } from "./schema/manifest.schema.json";
7
+ export type { WireMessage, HostEvent, SessionDescriptor, StandardCapabilityMessage, FsCapabilityMessage } from "./generated/types.generated.js";
8
+ export type { SessionInfo, CapabilityInfo, PluginRequest, PluginOperation, HostOperation, Unsubscribe, HostTransport } from "./wire.js";
9
+ export { validateWireMessage, validateHostEvent } from "./wire.js";
10
+ export { validateSessionDescriptor } from "./session.js";
11
+ export { standardCapabilities, validateCapabilityRequest, validateCapabilityResult } from "./capabilities.js";
12
+ export { default as wireSchema } from "./schema/wire.schema.json";
13
+ export { default as sessionSchema } from "./schema/session.schema.json";
14
+ export { default as capabilitySchema } from "./schema/capabilities.schema.json";
15
+ export { default as fsSchema } from "./schema/fs.schema.json";
16
+ export { default as hostEventSchema } from "./schema/host-event.schema.json";
17
+ export { AplgError, errorCodes, toErrorPayload } from "./errors.js";
18
+ export type { AplgErrorCode, ErrorPayload } from "./errors.js";