@unicity-astrid/sdk 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.
- package/README.md +120 -0
- package/dist/approval.d.ts +23 -0
- package/dist/approval.d.ts.map +1 -0
- package/dist/approval.js +29 -0
- package/dist/approval.js.map +1 -0
- package/dist/capabilities.d.ts +14 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +19 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/capsule.d.ts +39 -0
- package/dist/capsule.d.ts.map +1 -0
- package/dist/capsule.js +67 -0
- package/dist/capsule.js.map +1 -0
- package/dist/contracts.d.ts +1104 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +4 -0
- package/dist/contracts.js.map +1 -0
- package/dist/elicit.d.ts +30 -0
- package/dist/elicit.d.ts.map +1 -0
- package/dist/elicit.js +103 -0
- package/dist/elicit.js.map +1 -0
- package/dist/env.d.ts +19 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +27 -0
- package/dist/env.js.map +1 -0
- package/dist/errors.d.ts +46 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +108 -0
- package/dist/errors.js.map +1 -0
- package/dist/fs.d.ts +135 -0
- package/dist/fs.d.ts.map +1 -0
- package/dist/fs.js +257 -0
- package/dist/fs.js.map +1 -0
- package/dist/http.d.ts +90 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +276 -0
- package/dist/http.js.map +1 -0
- package/dist/identity.d.ts +46 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +69 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptors.d.ts +21 -0
- package/dist/interceptors.d.ts.map +1 -0
- package/dist/interceptors.js +22 -0
- package/dist/interceptors.js.map +1 -0
- package/dist/ipc.d.ts +143 -0
- package/dist/ipc.d.ts.map +1 -0
- package/dist/ipc.js +261 -0
- package/dist/ipc.js.map +1 -0
- package/dist/kv.d.ts +45 -0
- package/dist/kv.d.ts.map +1 -0
- package/dist/kv.js +91 -0
- package/dist/kv.js.map +1 -0
- package/dist/log.d.ts +17 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +40 -0
- package/dist/log.js.map +1 -0
- package/dist/net.d.ts +154 -0
- package/dist/net.d.ts.map +1 -0
- package/dist/net.js +421 -0
- package/dist/net.js.map +1 -0
- package/dist/process.d.ts +77 -0
- package/dist/process.d.ts.map +1 -0
- package/dist/process.js +128 -0
- package/dist/process.js.map +1 -0
- package/dist/runtime/bridge.d.ts +34 -0
- package/dist/runtime/bridge.d.ts.map +1 -0
- package/dist/runtime/bridge.js +326 -0
- package/dist/runtime/bridge.js.map +1 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/registry.d.ts +58 -0
- package/dist/runtime/registry.d.ts.map +1 -0
- package/dist/runtime/registry.js +129 -0
- package/dist/runtime/registry.js.map +1 -0
- package/dist/runtime.d.ts +36 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +50 -0
- package/dist/runtime.js.map +1 -0
- package/dist/time.d.ts +29 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +43 -0
- package/dist/time.js.map +1 -0
- package/dist/tool.d.ts +48 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +86 -0
- package/dist/tool.js.map +1 -0
- package/dist/uplink.d.ts +27 -0
- package/dist/uplink.d.ts.map +1 -0
- package/dist/uplink.js +36 -0
- package/dist/uplink.js.map +1 -0
- package/package.json +38 -0
- package/src/approval.ts +38 -0
- package/src/capabilities.ts +22 -0
- package/src/capsule.ts +90 -0
- package/src/contracts.ts +1189 -0
- package/src/elicit.ts +136 -0
- package/src/env.ts +31 -0
- package/src/errors.ts +122 -0
- package/src/fs.ts +357 -0
- package/src/http.ts +345 -0
- package/src/identity.ts +101 -0
- package/src/index.ts +83 -0
- package/src/interceptors.ts +25 -0
- package/src/ipc.ts +354 -0
- package/src/kv.ts +123 -0
- package/src/log.ts +43 -0
- package/src/net.ts +545 -0
- package/src/process.ts +205 -0
- package/src/runtime/bridge.ts +374 -0
- package/src/runtime/index.ts +11 -0
- package/src/runtime/registry.ts +178 -0
- package/src/runtime.ts +70 -0
- package/src/time.ts +48 -0
- package/src/tool.ts +125 -0
- package/src/uplink.ts +49 -0
- package/src/wit-imports.d.ts +689 -0
- package/wit-contracts/astrid-contracts.wit +1266 -0
|
@@ -0,0 +1,689 @@
|
|
|
1
|
+
// Ambient type declarations for the Astrid host imports that ComponentizeJS
|
|
2
|
+
// resolves at componentize time. After PR #752 (kernel) the host ABI is split
|
|
3
|
+
// into per-domain frozen packages at @1.0.0, and foundation I/O lives in the
|
|
4
|
+
// dedicated `astrid:io` package.
|
|
5
|
+
//
|
|
6
|
+
// The JS-side import shape is `"astrid:<domain>/host@1.0.0"` (or
|
|
7
|
+
// `"astrid:io/<iface>@1.0.0"` for foundation primitives), with kebab-case WIT
|
|
8
|
+
// names mapped to camelCase per the ComponentizeJS bindgen convention. WIT
|
|
9
|
+
// resources surface as JS classes with private constructors, instance methods,
|
|
10
|
+
// and a `[Symbol.dispose]` registered automatically by the host runtime.
|
|
11
|
+
//
|
|
12
|
+
// Per-domain `error-code` variants are imported as discriminated `{ tag, val }`
|
|
13
|
+
// objects matching the bindgen output. Throwing host calls reject with the
|
|
14
|
+
// same shape — `errors.ts` catches and rewraps into `SysError` so capsules see
|
|
15
|
+
// a unified error class with a typed `code`.
|
|
16
|
+
//
|
|
17
|
+
// One ambient module per WIT interface. Version is always `@1.0.0` after the
|
|
18
|
+
// per-domain split. Omitting the version causes a Wizer-time "module not
|
|
19
|
+
// found" error (see Phase 0 findings).
|
|
20
|
+
|
|
21
|
+
// ────────────────────────────────────────────────────────────────────
|
|
22
|
+
// astrid:io/error — downcastable error resource
|
|
23
|
+
// ────────────────────────────────────────────────────────────────────
|
|
24
|
+
declare module "astrid:io/error@1.0.0" {
|
|
25
|
+
export class Error {
|
|
26
|
+
private constructor();
|
|
27
|
+
toDebugString(): string;
|
|
28
|
+
[Symbol.dispose](): void;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ────────────────────────────────────────────────────────────────────
|
|
33
|
+
// astrid:io/poll — readiness multiplexing
|
|
34
|
+
// ────────────────────────────────────────────────────────────────────
|
|
35
|
+
declare module "astrid:io/poll@1.0.0" {
|
|
36
|
+
export type ErrorCode =
|
|
37
|
+
| { tag: "invalid-input" }
|
|
38
|
+
| { tag: "closed" }
|
|
39
|
+
| { tag: "too-large" }
|
|
40
|
+
| { tag: "cancelled" }
|
|
41
|
+
| { tag: "unknown"; val: string };
|
|
42
|
+
|
|
43
|
+
export class Pollable {
|
|
44
|
+
private constructor();
|
|
45
|
+
ready(): boolean;
|
|
46
|
+
block(): void;
|
|
47
|
+
[Symbol.dispose](): void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function poll(pollables: Pollable[]): Uint32Array;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ────────────────────────────────────────────────────────────────────
|
|
54
|
+
// astrid:io/streams — byte streams
|
|
55
|
+
// ────────────────────────────────────────────────────────────────────
|
|
56
|
+
declare module "astrid:io/streams@1.0.0" {
|
|
57
|
+
import type { Error as IoError } from "astrid:io/error@1.0.0";
|
|
58
|
+
import type { Pollable } from "astrid:io/poll@1.0.0";
|
|
59
|
+
|
|
60
|
+
export type StreamError =
|
|
61
|
+
| { tag: "last-operation-failed"; val: IoError }
|
|
62
|
+
| { tag: "closed" };
|
|
63
|
+
|
|
64
|
+
export class InputStream {
|
|
65
|
+
private constructor();
|
|
66
|
+
read(len: bigint): Uint8Array;
|
|
67
|
+
blockingRead(len: bigint): Uint8Array;
|
|
68
|
+
skip(len: bigint): bigint;
|
|
69
|
+
blockingSkip(len: bigint): bigint;
|
|
70
|
+
subscribe(): Pollable;
|
|
71
|
+
[Symbol.dispose](): void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export class OutputStream {
|
|
75
|
+
private constructor();
|
|
76
|
+
checkWrite(): bigint;
|
|
77
|
+
write(contents: Uint8Array): void;
|
|
78
|
+
blockingWriteAndFlush(contents: Uint8Array): void;
|
|
79
|
+
flush(): void;
|
|
80
|
+
blockingFlush(): void;
|
|
81
|
+
subscribe(): Pollable;
|
|
82
|
+
writeZeroes(len: bigint): void;
|
|
83
|
+
blockingWriteZeroesAndFlush(len: bigint): void;
|
|
84
|
+
splice(src: InputStream, len: bigint): bigint;
|
|
85
|
+
blockingSplice(src: InputStream, len: bigint): bigint;
|
|
86
|
+
[Symbol.dispose](): void;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ────────────────────────────────────────────────────────────────────
|
|
91
|
+
// astrid:ipc/host
|
|
92
|
+
// ────────────────────────────────────────────────────────────────────
|
|
93
|
+
declare module "astrid:ipc/host@1.0.0" {
|
|
94
|
+
import type { Pollable } from "astrid:io/poll@1.0.0";
|
|
95
|
+
|
|
96
|
+
export type ErrorCode =
|
|
97
|
+
| { tag: "capability-denied" }
|
|
98
|
+
| { tag: "invalid-input" }
|
|
99
|
+
| { tag: "closed" }
|
|
100
|
+
| { tag: "rate-limited" }
|
|
101
|
+
| { tag: "backpressure" }
|
|
102
|
+
| { tag: "quota" }
|
|
103
|
+
| { tag: "timeout" }
|
|
104
|
+
| { tag: "unknown"; val: string };
|
|
105
|
+
|
|
106
|
+
export type PrincipalAttribution =
|
|
107
|
+
| { tag: "verified"; val: string }
|
|
108
|
+
| { tag: "claimed"; val: string }
|
|
109
|
+
| { tag: "system" };
|
|
110
|
+
|
|
111
|
+
export interface IpcMessage {
|
|
112
|
+
topic: string;
|
|
113
|
+
payload: string;
|
|
114
|
+
sourceId: string;
|
|
115
|
+
principal: PrincipalAttribution;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface IpcEnvelope {
|
|
119
|
+
messages: IpcMessage[];
|
|
120
|
+
dropped: bigint;
|
|
121
|
+
lagged: bigint;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface InterceptorBinding {
|
|
125
|
+
handleId: bigint;
|
|
126
|
+
action: string;
|
|
127
|
+
topic: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export class Subscription {
|
|
131
|
+
private constructor();
|
|
132
|
+
poll(): IpcEnvelope;
|
|
133
|
+
recv(timeoutMs: bigint): IpcEnvelope;
|
|
134
|
+
subscribeReadiness(): Pollable;
|
|
135
|
+
[Symbol.dispose](): void;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function publish(topic: string, payload: string): void;
|
|
139
|
+
export function publishAs(topic: string, payload: string, principal: string): void;
|
|
140
|
+
export function subscribe(topicPattern: string): Subscription;
|
|
141
|
+
export function getInterceptorBindings(): InterceptorBinding[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ────────────────────────────────────────────────────────────────────
|
|
145
|
+
// astrid:kv/host
|
|
146
|
+
// ────────────────────────────────────────────────────────────────────
|
|
147
|
+
declare module "astrid:kv/host@1.0.0" {
|
|
148
|
+
export type ErrorCode =
|
|
149
|
+
| { tag: "invalid-key" }
|
|
150
|
+
| { tag: "too-large" }
|
|
151
|
+
| { tag: "quota" }
|
|
152
|
+
| { tag: "cas-mismatch" }
|
|
153
|
+
| { tag: "unknown"; val: string };
|
|
154
|
+
|
|
155
|
+
export interface KeyPage {
|
|
156
|
+
keys: string[];
|
|
157
|
+
nextCursor: string | undefined;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function kvGet(key: string): Uint8Array | undefined;
|
|
161
|
+
export function kvSet(key: string, value: Uint8Array): void;
|
|
162
|
+
export function kvDelete(key: string): void;
|
|
163
|
+
export function kvListKeys(prefix: string): string[];
|
|
164
|
+
export function kvListKeysPage(
|
|
165
|
+
prefix: string,
|
|
166
|
+
cursor: string | undefined,
|
|
167
|
+
limit: number,
|
|
168
|
+
): KeyPage;
|
|
169
|
+
export function kvClearPrefix(prefix: string): bigint;
|
|
170
|
+
export function kvCas(
|
|
171
|
+
key: string,
|
|
172
|
+
expected: Uint8Array | undefined,
|
|
173
|
+
newValue: Uint8Array,
|
|
174
|
+
): boolean;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ────────────────────────────────────────────────────────────────────
|
|
178
|
+
// astrid:fs/host
|
|
179
|
+
// ────────────────────────────────────────────────────────────────────
|
|
180
|
+
declare module "astrid:fs/host@1.0.0" {
|
|
181
|
+
export type ErrorCode =
|
|
182
|
+
| { tag: "not-found" }
|
|
183
|
+
| { tag: "access" }
|
|
184
|
+
| { tag: "capability-denied" }
|
|
185
|
+
| { tag: "boundary-escape" }
|
|
186
|
+
| { tag: "invalid-path" }
|
|
187
|
+
| { tag: "would-block" }
|
|
188
|
+
| { tag: "is-directory" }
|
|
189
|
+
| { tag: "not-directory" }
|
|
190
|
+
| { tag: "not-empty" }
|
|
191
|
+
| { tag: "too-large" }
|
|
192
|
+
| { tag: "quota" }
|
|
193
|
+
| { tag: "cross-vfs" }
|
|
194
|
+
| { tag: "already-exists" }
|
|
195
|
+
| { tag: "closed" }
|
|
196
|
+
| { tag: "unknown"; val: string };
|
|
197
|
+
|
|
198
|
+
export type FileType =
|
|
199
|
+
| "type-unknown"
|
|
200
|
+
| "regular"
|
|
201
|
+
| "directory"
|
|
202
|
+
| "symlink"
|
|
203
|
+
| "block-device"
|
|
204
|
+
| "character-device"
|
|
205
|
+
| "fifo"
|
|
206
|
+
| "socket";
|
|
207
|
+
|
|
208
|
+
export type OpenMode = "read" | "write" | "append" | "read-write";
|
|
209
|
+
|
|
210
|
+
export interface Datetime {
|
|
211
|
+
seconds: bigint;
|
|
212
|
+
nanoseconds: number;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface FileStat {
|
|
216
|
+
size: bigint;
|
|
217
|
+
kind: FileType;
|
|
218
|
+
mode: number;
|
|
219
|
+
modified: Datetime | undefined;
|
|
220
|
+
created: Datetime | undefined;
|
|
221
|
+
accessed: Datetime | undefined;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export class FileHandle {
|
|
225
|
+
private constructor();
|
|
226
|
+
readAt(offset: bigint, maxBytes: number): Uint8Array;
|
|
227
|
+
writeAt(offset: bigint, data: Uint8Array): number;
|
|
228
|
+
syncData(): void;
|
|
229
|
+
syncAll(): void;
|
|
230
|
+
stat(): FileStat;
|
|
231
|
+
setLen(size: bigint): void;
|
|
232
|
+
[Symbol.dispose](): void;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function fsOpen(path: string, mode: OpenMode): FileHandle;
|
|
236
|
+
export function fsExists(path: string): boolean;
|
|
237
|
+
export function fsMkdir(path: string): void;
|
|
238
|
+
export function fsMkdirAll(path: string): void;
|
|
239
|
+
export function fsReaddir(path: string): string[];
|
|
240
|
+
export function fsStat(path: string): FileStat;
|
|
241
|
+
export function fsStatSymlink(path: string): FileStat;
|
|
242
|
+
export function fsUnlink(path: string): void;
|
|
243
|
+
export function readFile(path: string): Uint8Array;
|
|
244
|
+
export function writeFile(path: string, content: Uint8Array): void;
|
|
245
|
+
export function fsAppend(path: string, content: Uint8Array): void;
|
|
246
|
+
export function fsCopy(src: string, dst: string): void;
|
|
247
|
+
export function fsRename(src: string, dst: string): void;
|
|
248
|
+
export function fsRemoveDirAll(path: string): bigint;
|
|
249
|
+
export function fsCanonicalize(path: string): string;
|
|
250
|
+
export function fsReadLink(path: string): string;
|
|
251
|
+
export function fsHardLink(src: string, linkPath: string): void;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ────────────────────────────────────────────────────────────────────
|
|
255
|
+
// astrid:net/host
|
|
256
|
+
// ────────────────────────────────────────────────────────────────────
|
|
257
|
+
declare module "astrid:net/host@1.0.0" {
|
|
258
|
+
import type { Pollable } from "astrid:io/poll@1.0.0";
|
|
259
|
+
import type { InputStream, OutputStream } from "astrid:io/streams@1.0.0";
|
|
260
|
+
|
|
261
|
+
export type ErrorCode =
|
|
262
|
+
| { tag: "would-block" }
|
|
263
|
+
| { tag: "closed" }
|
|
264
|
+
| { tag: "capability-denied" }
|
|
265
|
+
| { tag: "airlock-rejected" }
|
|
266
|
+
| { tag: "connection-refused" }
|
|
267
|
+
| { tag: "connection-reset" }
|
|
268
|
+
| { tag: "timeout" }
|
|
269
|
+
| { tag: "address-in-use" }
|
|
270
|
+
| { tag: "address-not-available" }
|
|
271
|
+
| { tag: "name-unresolvable" }
|
|
272
|
+
| { tag: "invalid-handle" }
|
|
273
|
+
| { tag: "not-tcp" }
|
|
274
|
+
| { tag: "quota" }
|
|
275
|
+
| { tag: "unknown"; val: string };
|
|
276
|
+
|
|
277
|
+
export type NetReadStatus =
|
|
278
|
+
| { tag: "data"; val: Uint8Array }
|
|
279
|
+
| { tag: "closed" }
|
|
280
|
+
| { tag: "pending" };
|
|
281
|
+
|
|
282
|
+
export type ShutdownHow = "receive" | "send" | "both";
|
|
283
|
+
|
|
284
|
+
export interface UdpDatagram {
|
|
285
|
+
data: Uint8Array;
|
|
286
|
+
peerHost: string;
|
|
287
|
+
peerPort: number;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export class UnixListener {
|
|
291
|
+
private constructor();
|
|
292
|
+
accept(): TcpStream;
|
|
293
|
+
pollAccept(timeoutMs: bigint): TcpStream | undefined;
|
|
294
|
+
subscribeReadiness(): Pollable;
|
|
295
|
+
[Symbol.dispose](): void;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export class TcpListener {
|
|
299
|
+
private constructor();
|
|
300
|
+
accept(): TcpStream;
|
|
301
|
+
pollAccept(timeoutMs: bigint): TcpStream | undefined;
|
|
302
|
+
localAddr(): string;
|
|
303
|
+
subscribeReadiness(): Pollable;
|
|
304
|
+
[Symbol.dispose](): void;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export class TcpStream {
|
|
308
|
+
private constructor();
|
|
309
|
+
read(): NetReadStatus;
|
|
310
|
+
write(data: Uint8Array): void;
|
|
311
|
+
readBytes(maxBytes: number): Uint8Array;
|
|
312
|
+
writeBytes(data: Uint8Array): number;
|
|
313
|
+
peek(maxBytes: number): Uint8Array;
|
|
314
|
+
shutdown(how: ShutdownHow): void;
|
|
315
|
+
peerAddr(): string;
|
|
316
|
+
localAddr(): string;
|
|
317
|
+
setNodelay(nodelay: boolean): void;
|
|
318
|
+
nodelay(): boolean;
|
|
319
|
+
setReadTimeout(timeoutMs: bigint | undefined): void;
|
|
320
|
+
readTimeout(): bigint | undefined;
|
|
321
|
+
setWriteTimeout(timeoutMs: bigint | undefined): void;
|
|
322
|
+
writeTimeout(): bigint | undefined;
|
|
323
|
+
setHopLimit(hops: number): void;
|
|
324
|
+
hopLimit(): number;
|
|
325
|
+
setKeepalive(keepaliveSecs: bigint | undefined): void;
|
|
326
|
+
keepalive(): bigint | undefined;
|
|
327
|
+
setLinger(lingerMs: bigint | undefined): void;
|
|
328
|
+
linger(): bigint | undefined;
|
|
329
|
+
setReuseaddr(reuse: boolean): void;
|
|
330
|
+
reuseaddr(): boolean;
|
|
331
|
+
subscribeReadable(): Pollable;
|
|
332
|
+
readStream(): InputStream;
|
|
333
|
+
writeStream(): OutputStream;
|
|
334
|
+
[Symbol.dispose](): void;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export class UdpSocket {
|
|
338
|
+
private constructor();
|
|
339
|
+
sendTo(data: Uint8Array, peerHost: string, peerPort: number): number;
|
|
340
|
+
recvFrom(maxBytes: number): UdpDatagram | undefined;
|
|
341
|
+
connect(peerHost: string, peerPort: number): void;
|
|
342
|
+
disconnect(): void;
|
|
343
|
+
send(data: Uint8Array): number;
|
|
344
|
+
recv(maxBytes: number): Uint8Array | undefined;
|
|
345
|
+
peerAddr(): string | undefined;
|
|
346
|
+
setReadTimeout(timeoutMs: bigint | undefined): void;
|
|
347
|
+
localAddr(): string;
|
|
348
|
+
subscribeReadable(): Pollable;
|
|
349
|
+
[Symbol.dispose](): void;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export function bindUnix(): UnixListener;
|
|
353
|
+
export function bindTcp(host: string, port: number): TcpListener;
|
|
354
|
+
export function connectTcp(host: string, port: number): TcpStream;
|
|
355
|
+
export function udpBind(host: string, port: number): UdpSocket;
|
|
356
|
+
export function lookupHost(host: string): string[];
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// ────────────────────────────────────────────────────────────────────
|
|
360
|
+
// astrid:http/host
|
|
361
|
+
// ────────────────────────────────────────────────────────────────────
|
|
362
|
+
declare module "astrid:http/host@1.0.0" {
|
|
363
|
+
import type { Pollable } from "astrid:io/poll@1.0.0";
|
|
364
|
+
import type { InputStream } from "astrid:io/streams@1.0.0";
|
|
365
|
+
|
|
366
|
+
export type ErrorCode =
|
|
367
|
+
| { tag: "capability-denied" }
|
|
368
|
+
| { tag: "invalid-request" }
|
|
369
|
+
| { tag: "dns-error" }
|
|
370
|
+
| { tag: "airlock-rejected" }
|
|
371
|
+
| { tag: "tls-error" }
|
|
372
|
+
| { tag: "timeout" }
|
|
373
|
+
| { tag: "connection-error" }
|
|
374
|
+
| { tag: "body-too-large" }
|
|
375
|
+
| { tag: "closed" }
|
|
376
|
+
| { tag: "quota" }
|
|
377
|
+
| { tag: "protocol"; val: string }
|
|
378
|
+
| { tag: "unknown"; val: string };
|
|
379
|
+
|
|
380
|
+
export type HttpMethod =
|
|
381
|
+
| { tag: "get" }
|
|
382
|
+
| { tag: "head" }
|
|
383
|
+
| { tag: "post" }
|
|
384
|
+
| { tag: "put" }
|
|
385
|
+
| { tag: "delete" }
|
|
386
|
+
| { tag: "connect" }
|
|
387
|
+
| { tag: "options" }
|
|
388
|
+
| { tag: "trace" }
|
|
389
|
+
| { tag: "patch" }
|
|
390
|
+
| { tag: "other"; val: string };
|
|
391
|
+
|
|
392
|
+
export interface KeyValuePair {
|
|
393
|
+
key: string;
|
|
394
|
+
value: string;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export interface HttpRequestData {
|
|
398
|
+
url: string;
|
|
399
|
+
method: HttpMethod;
|
|
400
|
+
headers: KeyValuePair[];
|
|
401
|
+
body: Uint8Array | undefined;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export interface HttpResponseData {
|
|
405
|
+
status: number;
|
|
406
|
+
headers: KeyValuePair[];
|
|
407
|
+
body: Uint8Array;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export class HttpStream {
|
|
411
|
+
private constructor();
|
|
412
|
+
status(): number;
|
|
413
|
+
headers(): KeyValuePair[];
|
|
414
|
+
readChunk(): Uint8Array;
|
|
415
|
+
close(): void;
|
|
416
|
+
subscribeReadable(): Pollable;
|
|
417
|
+
bodyStream(): InputStream;
|
|
418
|
+
[Symbol.dispose](): void;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
export function httpRequest(request: HttpRequestData): HttpResponseData;
|
|
422
|
+
export function httpStreamStart(request: HttpRequestData): HttpStream;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// ────────────────────────────────────────────────────────────────────
|
|
426
|
+
// astrid:sys/host
|
|
427
|
+
// ────────────────────────────────────────────────────────────────────
|
|
428
|
+
declare module "astrid:sys/host@1.0.0" {
|
|
429
|
+
export type ErrorCode =
|
|
430
|
+
| { tag: "capability-denied" }
|
|
431
|
+
| { tag: "config-key-reserved" }
|
|
432
|
+
| { tag: "too-large" }
|
|
433
|
+
| { tag: "registry-unavailable" }
|
|
434
|
+
| { tag: "cancelled" }
|
|
435
|
+
| { tag: "unknown"; val: string };
|
|
436
|
+
|
|
437
|
+
export type LogLevel = "trace" | "debug" | "info" | "warn" | "error";
|
|
438
|
+
|
|
439
|
+
export interface CallerContext {
|
|
440
|
+
principal: string | undefined;
|
|
441
|
+
sourceId: string;
|
|
442
|
+
timestamp: string;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export interface CapabilityCheckRequest {
|
|
446
|
+
sourceUuid: string;
|
|
447
|
+
capability: string;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export interface CapabilityCheckResponse {
|
|
451
|
+
allowed: boolean;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export function getConfig(key: string): string | undefined;
|
|
455
|
+
export function getCaller(): CallerContext;
|
|
456
|
+
export function log(level: LogLevel, message: string): void;
|
|
457
|
+
export function signalReady(): void;
|
|
458
|
+
export function clockMs(): bigint;
|
|
459
|
+
export function clockMonotonicNs(): bigint;
|
|
460
|
+
export function sleepNs(durationNs: bigint): void;
|
|
461
|
+
export function randomBytes(length: bigint): Uint8Array;
|
|
462
|
+
export function checkCapsuleCapability(
|
|
463
|
+
request: CapabilityCheckRequest,
|
|
464
|
+
): CapabilityCheckResponse;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// ────────────────────────────────────────────────────────────────────
|
|
468
|
+
// astrid:process/host
|
|
469
|
+
// ────────────────────────────────────────────────────────────────────
|
|
470
|
+
declare module "astrid:process/host@1.0.0" {
|
|
471
|
+
import type { Pollable } from "astrid:io/poll@1.0.0";
|
|
472
|
+
|
|
473
|
+
export type ErrorCode =
|
|
474
|
+
| { tag: "capability-denied" }
|
|
475
|
+
| { tag: "invalid-input" }
|
|
476
|
+
| { tag: "boundary-escape" }
|
|
477
|
+
| { tag: "quota" }
|
|
478
|
+
| { tag: "too-large" }
|
|
479
|
+
| { tag: "closed" }
|
|
480
|
+
| { tag: "cancelled" }
|
|
481
|
+
| { tag: "wait-timeout" }
|
|
482
|
+
| { tag: "unknown"; val: string };
|
|
483
|
+
|
|
484
|
+
export type ProcessSignal = "term" | "hup" | "usr1" | "usr2" | "int";
|
|
485
|
+
|
|
486
|
+
export interface EnvVar {
|
|
487
|
+
key: string;
|
|
488
|
+
value: string;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export interface SpawnRequest {
|
|
492
|
+
cmd: string;
|
|
493
|
+
args: string[];
|
|
494
|
+
stdin: Uint8Array | undefined;
|
|
495
|
+
env: EnvVar[];
|
|
496
|
+
cwd: string | undefined;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
export interface ExitInfo {
|
|
500
|
+
exitCode: number | undefined;
|
|
501
|
+
signal: number | undefined;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export interface ProcessResult {
|
|
505
|
+
stdout: string;
|
|
506
|
+
stderr: string;
|
|
507
|
+
exit: ExitInfo;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export interface ReadLogsResult {
|
|
511
|
+
stdout: string;
|
|
512
|
+
stderr: string;
|
|
513
|
+
running: boolean;
|
|
514
|
+
exit: ExitInfo | undefined;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export interface KillResult {
|
|
518
|
+
killed: boolean;
|
|
519
|
+
exit: ExitInfo | undefined;
|
|
520
|
+
stdout: string;
|
|
521
|
+
stderr: string;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
export class ProcessHandle {
|
|
525
|
+
private constructor();
|
|
526
|
+
readLogs(): ReadLogsResult;
|
|
527
|
+
writeStdin(data: Uint8Array): number;
|
|
528
|
+
closeStdin(): void;
|
|
529
|
+
signal(sig: ProcessSignal): void;
|
|
530
|
+
kill(): KillResult;
|
|
531
|
+
wait(timeoutMs: bigint | undefined): ExitInfo;
|
|
532
|
+
waitWithOutput(timeoutMs: bigint | undefined): ProcessResult;
|
|
533
|
+
osPid(): number;
|
|
534
|
+
subscribeExit(): Pollable;
|
|
535
|
+
subscribeLogs(): Pollable;
|
|
536
|
+
[Symbol.dispose](): void;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export function spawn(request: SpawnRequest): ProcessResult;
|
|
540
|
+
export function spawnBackground(request: SpawnRequest): ProcessHandle;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// ────────────────────────────────────────────────────────────────────
|
|
544
|
+
// astrid:uplink/host
|
|
545
|
+
// ────────────────────────────────────────────────────────────────────
|
|
546
|
+
declare module "astrid:uplink/host@1.0.0" {
|
|
547
|
+
export type ErrorCode =
|
|
548
|
+
| { tag: "capability-denied" }
|
|
549
|
+
| { tag: "invalid-input" }
|
|
550
|
+
| { tag: "invalid-profile" }
|
|
551
|
+
| { tag: "unknown-uplink" }
|
|
552
|
+
| { tag: "no-session" }
|
|
553
|
+
| { tag: "quota" }
|
|
554
|
+
| { tag: "unknown"; val: string };
|
|
555
|
+
|
|
556
|
+
export type UplinkProfile = "chat" | "interactive" | "notify" | "bridge";
|
|
557
|
+
|
|
558
|
+
export function uplinkRegister(
|
|
559
|
+
name: string,
|
|
560
|
+
platform: string,
|
|
561
|
+
profile: UplinkProfile,
|
|
562
|
+
): string;
|
|
563
|
+
export function uplinkSend(
|
|
564
|
+
uplinkId: string,
|
|
565
|
+
platformUserId: string,
|
|
566
|
+
content: string,
|
|
567
|
+
): boolean;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// ────────────────────────────────────────────────────────────────────
|
|
571
|
+
// astrid:elicit/host
|
|
572
|
+
// ────────────────────────────────────────────────────────────────────
|
|
573
|
+
declare module "astrid:elicit/host@1.0.0" {
|
|
574
|
+
export type ErrorCode =
|
|
575
|
+
| { tag: "not-in-lifecycle" }
|
|
576
|
+
| { tag: "timeout" }
|
|
577
|
+
| { tag: "cancelled" }
|
|
578
|
+
| { tag: "invalid-input" }
|
|
579
|
+
| { tag: "store-unavailable" }
|
|
580
|
+
| { tag: "unknown"; val: string };
|
|
581
|
+
|
|
582
|
+
export type ElicitType = "text" | "secret" | "select" | "array";
|
|
583
|
+
|
|
584
|
+
export interface ElicitRequest {
|
|
585
|
+
kind: ElicitType;
|
|
586
|
+
key: string;
|
|
587
|
+
description: string;
|
|
588
|
+
options: string[] | undefined;
|
|
589
|
+
defaultValue: string | undefined;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
export type ElicitResponse =
|
|
593
|
+
| { tag: "value"; val: string }
|
|
594
|
+
| { tag: "values"; val: string[] }
|
|
595
|
+
| { tag: "secret-stored" };
|
|
596
|
+
|
|
597
|
+
export function elicit(request: ElicitRequest): ElicitResponse;
|
|
598
|
+
export function hasSecret(key: string): boolean;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// ────────────────────────────────────────────────────────────────────
|
|
602
|
+
// astrid:approval/host
|
|
603
|
+
// ────────────────────────────────────────────────────────────────────
|
|
604
|
+
declare module "astrid:approval/host@1.0.0" {
|
|
605
|
+
export type ErrorCode =
|
|
606
|
+
| { tag: "invalid-input" }
|
|
607
|
+
| { tag: "timeout" }
|
|
608
|
+
| { tag: "store-unavailable" }
|
|
609
|
+
| { tag: "unknown"; val: string };
|
|
610
|
+
|
|
611
|
+
export type ApprovalDecision =
|
|
612
|
+
| "denied"
|
|
613
|
+
| "approved"
|
|
614
|
+
| "approved-session"
|
|
615
|
+
| "approved-always"
|
|
616
|
+
| "allowance";
|
|
617
|
+
|
|
618
|
+
export interface ApprovalRequest {
|
|
619
|
+
action: string;
|
|
620
|
+
targetResource: string;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
export interface ApprovalResponse {
|
|
624
|
+
decision: ApprovalDecision;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
export function requestApproval(request: ApprovalRequest): ApprovalResponse;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// ────────────────────────────────────────────────────────────────────
|
|
631
|
+
// astrid:identity/host
|
|
632
|
+
// ────────────────────────────────────────────────────────────────────
|
|
633
|
+
declare module "astrid:identity/host@1.0.0" {
|
|
634
|
+
export type ErrorCode =
|
|
635
|
+
| { tag: "capability-denied" }
|
|
636
|
+
| { tag: "invalid-input" }
|
|
637
|
+
| { tag: "user-not-found" }
|
|
638
|
+
| { tag: "link-not-found" }
|
|
639
|
+
| { tag: "already-linked" }
|
|
640
|
+
| { tag: "store-unavailable" }
|
|
641
|
+
| { tag: "unknown"; val: string };
|
|
642
|
+
|
|
643
|
+
export interface IdentityResolveRequest {
|
|
644
|
+
platform: string;
|
|
645
|
+
platformUserId: string;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
export interface IdentityResolveResponse {
|
|
649
|
+
userId: string;
|
|
650
|
+
displayName: string | undefined;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
export interface IdentityLinkRequest {
|
|
654
|
+
platform: string;
|
|
655
|
+
platformUserId: string;
|
|
656
|
+
astridUserId: string;
|
|
657
|
+
method: string;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
export interface IdentityUnlinkRequest {
|
|
661
|
+
platform: string;
|
|
662
|
+
platformUserId: string;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
export interface IdentityCreateUserRequest {
|
|
666
|
+
displayName: string | undefined;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
export interface IdentityCreateUserResponse {
|
|
670
|
+
userId: string;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
export interface PlatformLink {
|
|
674
|
+
platform: string;
|
|
675
|
+
platformUserId: string;
|
|
676
|
+
linkedAt: string;
|
|
677
|
+
method: string;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
export function identityResolve(
|
|
681
|
+
request: IdentityResolveRequest,
|
|
682
|
+
): IdentityResolveResponse;
|
|
683
|
+
export function identityLink(request: IdentityLinkRequest): void;
|
|
684
|
+
export function identityUnlink(request: IdentityUnlinkRequest): void;
|
|
685
|
+
export function identityCreateUser(
|
|
686
|
+
request: IdentityCreateUserRequest,
|
|
687
|
+
): IdentityCreateUserResponse;
|
|
688
|
+
export function identityListLinks(astridUserId: string): PlatformLink[];
|
|
689
|
+
}
|