@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.
Files changed (124) hide show
  1. package/README.md +120 -0
  2. package/dist/approval.d.ts +23 -0
  3. package/dist/approval.d.ts.map +1 -0
  4. package/dist/approval.js +29 -0
  5. package/dist/approval.js.map +1 -0
  6. package/dist/capabilities.d.ts +14 -0
  7. package/dist/capabilities.d.ts.map +1 -0
  8. package/dist/capabilities.js +19 -0
  9. package/dist/capabilities.js.map +1 -0
  10. package/dist/capsule.d.ts +39 -0
  11. package/dist/capsule.d.ts.map +1 -0
  12. package/dist/capsule.js +67 -0
  13. package/dist/capsule.js.map +1 -0
  14. package/dist/contracts.d.ts +1104 -0
  15. package/dist/contracts.d.ts.map +1 -0
  16. package/dist/contracts.js +4 -0
  17. package/dist/contracts.js.map +1 -0
  18. package/dist/elicit.d.ts +30 -0
  19. package/dist/elicit.d.ts.map +1 -0
  20. package/dist/elicit.js +103 -0
  21. package/dist/elicit.js.map +1 -0
  22. package/dist/env.d.ts +19 -0
  23. package/dist/env.d.ts.map +1 -0
  24. package/dist/env.js +27 -0
  25. package/dist/env.js.map +1 -0
  26. package/dist/errors.d.ts +46 -0
  27. package/dist/errors.d.ts.map +1 -0
  28. package/dist/errors.js +108 -0
  29. package/dist/errors.js.map +1 -0
  30. package/dist/fs.d.ts +135 -0
  31. package/dist/fs.d.ts.map +1 -0
  32. package/dist/fs.js +257 -0
  33. package/dist/fs.js.map +1 -0
  34. package/dist/http.d.ts +90 -0
  35. package/dist/http.d.ts.map +1 -0
  36. package/dist/http.js +276 -0
  37. package/dist/http.js.map +1 -0
  38. package/dist/identity.d.ts +46 -0
  39. package/dist/identity.d.ts.map +1 -0
  40. package/dist/identity.js +69 -0
  41. package/dist/identity.js.map +1 -0
  42. package/dist/index.d.ts +30 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +27 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/interceptors.d.ts +21 -0
  47. package/dist/interceptors.d.ts.map +1 -0
  48. package/dist/interceptors.js +22 -0
  49. package/dist/interceptors.js.map +1 -0
  50. package/dist/ipc.d.ts +143 -0
  51. package/dist/ipc.d.ts.map +1 -0
  52. package/dist/ipc.js +261 -0
  53. package/dist/ipc.js.map +1 -0
  54. package/dist/kv.d.ts +45 -0
  55. package/dist/kv.d.ts.map +1 -0
  56. package/dist/kv.js +91 -0
  57. package/dist/kv.js.map +1 -0
  58. package/dist/log.d.ts +17 -0
  59. package/dist/log.d.ts.map +1 -0
  60. package/dist/log.js +40 -0
  61. package/dist/log.js.map +1 -0
  62. package/dist/net.d.ts +154 -0
  63. package/dist/net.d.ts.map +1 -0
  64. package/dist/net.js +421 -0
  65. package/dist/net.js.map +1 -0
  66. package/dist/process.d.ts +77 -0
  67. package/dist/process.d.ts.map +1 -0
  68. package/dist/process.js +128 -0
  69. package/dist/process.js.map +1 -0
  70. package/dist/runtime/bridge.d.ts +34 -0
  71. package/dist/runtime/bridge.d.ts.map +1 -0
  72. package/dist/runtime/bridge.js +326 -0
  73. package/dist/runtime/bridge.js.map +1 -0
  74. package/dist/runtime/index.d.ts +3 -0
  75. package/dist/runtime/index.d.ts.map +1 -0
  76. package/dist/runtime/index.js +3 -0
  77. package/dist/runtime/index.js.map +1 -0
  78. package/dist/runtime/registry.d.ts +58 -0
  79. package/dist/runtime/registry.d.ts.map +1 -0
  80. package/dist/runtime/registry.js +129 -0
  81. package/dist/runtime/registry.js.map +1 -0
  82. package/dist/runtime.d.ts +36 -0
  83. package/dist/runtime.d.ts.map +1 -0
  84. package/dist/runtime.js +50 -0
  85. package/dist/runtime.js.map +1 -0
  86. package/dist/time.d.ts +29 -0
  87. package/dist/time.d.ts.map +1 -0
  88. package/dist/time.js +43 -0
  89. package/dist/time.js.map +1 -0
  90. package/dist/tool.d.ts +48 -0
  91. package/dist/tool.d.ts.map +1 -0
  92. package/dist/tool.js +86 -0
  93. package/dist/tool.js.map +1 -0
  94. package/dist/uplink.d.ts +27 -0
  95. package/dist/uplink.d.ts.map +1 -0
  96. package/dist/uplink.js +36 -0
  97. package/dist/uplink.js.map +1 -0
  98. package/package.json +38 -0
  99. package/src/approval.ts +38 -0
  100. package/src/capabilities.ts +22 -0
  101. package/src/capsule.ts +90 -0
  102. package/src/contracts.ts +1189 -0
  103. package/src/elicit.ts +136 -0
  104. package/src/env.ts +31 -0
  105. package/src/errors.ts +122 -0
  106. package/src/fs.ts +357 -0
  107. package/src/http.ts +345 -0
  108. package/src/identity.ts +101 -0
  109. package/src/index.ts +83 -0
  110. package/src/interceptors.ts +25 -0
  111. package/src/ipc.ts +354 -0
  112. package/src/kv.ts +123 -0
  113. package/src/log.ts +43 -0
  114. package/src/net.ts +545 -0
  115. package/src/process.ts +205 -0
  116. package/src/runtime/bridge.ts +374 -0
  117. package/src/runtime/index.ts +11 -0
  118. package/src/runtime/registry.ts +178 -0
  119. package/src/runtime.ts +70 -0
  120. package/src/time.ts +48 -0
  121. package/src/tool.ts +125 -0
  122. package/src/uplink.ts +49 -0
  123. package/src/wit-imports.d.ts +689 -0
  124. package/wit-contracts/astrid-contracts.wit +1266 -0
@@ -0,0 +1,1189 @@
1
+ // Auto-generated by @unicity-astrid/build from a WIT file. Do not edit by hand.
2
+ // Mirror of `astrid_sdk_macros::wit_events!` output.
3
+
4
+ /** Types generated from the `types` WIT interface. */
5
+ export namespace types {
6
+ /** A conversation message. */
7
+ export interface Message {
8
+ role: MessageRole;
9
+ content: MessageContent;
10
+ }
11
+
12
+ export type MessageRole = "system" | "user" | "assistant" | "tool";
13
+
14
+ /** Message content — text, tool calls, tool results, or mixed. */
15
+ export type MessageContent =
16
+ | { tag: "text"; value: string }
17
+ | { tag: "tool_calls"; value: ToolCall[] }
18
+ | { tag: "tool_result"; value: ToolCallResult }
19
+ | { tag: "multi_part"; value: ContentPart[] };
20
+
21
+ export type ContentPart =
22
+ | { tag: "text"; value: string }
23
+ | { tag: "image"; value: ImageData };
24
+
25
+ export interface ImageData {
26
+ data: string;
27
+ media_type: string;
28
+ }
29
+
30
+ /** A tool call requested by the model. */
31
+ export interface ToolCall {
32
+ /** Tool call identifier. */
33
+ id: string;
34
+ /** Name of the tool to invoke. */
35
+ name: string;
36
+ /** JSON-encoded arguments (serde_json::Value in Rust). */
37
+ arguments: string;
38
+ }
39
+
40
+ /** Result of executing a tool call. */
41
+ export interface ToolCallResult {
42
+ call_id: string;
43
+ content: string;
44
+ is_error: boolean;
45
+ }
46
+
47
+ /** A tool definition provided to the model. */
48
+ export interface ToolDefinition {
49
+ name: string;
50
+ description?: string;
51
+ input_schema: string;
52
+ }
53
+
54
+ /** Token usage statistics. */
55
+ export interface Usage {
56
+ input_tokens: bigint;
57
+ output_tokens: bigint;
58
+ }
59
+
60
+ }
61
+
62
+ /** Types generated from the `agent` WIT interface. */
63
+ export namespace agent {
64
+ /** A response generated by the agent for the user. */
65
+ export interface Response {
66
+ /** The text output (may be a streaming delta or a complete reply). */
67
+ text: string;
68
+ /** True if this is the final response in the turn. */
69
+ is_final: boolean;
70
+ /** Session ID for multi-session attribution. */
71
+ session_id: string;
72
+ }
73
+
74
+ /**
75
+ * Notification that the active session has changed (e.g. cleared,
76
+ * branched, restored). Uplinks use this to refresh their view.
77
+ */
78
+ export interface SessionChanged {
79
+ /** The session ID that is now active. */
80
+ session_id: string;
81
+ /** Optional ID of the session that was previously active. */
82
+ previous_session_id?: string;
83
+ /** Reason for the change (e.g. "clear", "restore", "branch"). */
84
+ reason: string;
85
+ }
86
+
87
+ }
88
+
89
+ /** Types generated from the `approval` WIT interface. */
90
+ export namespace approval {
91
+ /** An interceptor or capsule request for human authorization. */
92
+ export interface Required {
93
+ /** Correlation ID matching the response. */
94
+ request_id: string;
95
+ /** The action being requested (e.g. `"git push"`). */
96
+ action: string;
97
+ /** The resource target (e.g. full command string). */
98
+ target_resource: string;
99
+ /** Justification shown to the user. */
100
+ reason: string;
101
+ }
102
+
103
+ /** Response to an approval request. */
104
+ export interface Response {
105
+ /** Must match the `request-id` from the originating request. */
106
+ request_id: string;
107
+ /**
108
+ * The user's decision (e.g. `"approve"`, `"deny"`,
109
+ * `"approve_session"`, `"approve_always"`, `"allowance"`).
110
+ */
111
+ decision: string;
112
+ /** Optional reason for the decision. */
113
+ reason?: string;
114
+ }
115
+
116
+ }
117
+
118
+ /** Types generated from the `client` WIT interface. */
119
+ export namespace client {
120
+ /** A client has connected to an uplink. */
121
+ export interface Connect {
122
+ /** Optional client identifier (e.g. process name + PID). */
123
+ client_id?: string;
124
+ }
125
+
126
+ /** A client is disconnecting gracefully. */
127
+ export interface Disconnect {
128
+ /** Optional reason for disconnection (e.g. "quit", "timeout"). */
129
+ reason?: string;
130
+ }
131
+
132
+ }
133
+
134
+ /** Types generated from the `context` WIT interface. */
135
+ export namespace context {
136
+ /** Request to compact messages within a token budget. */
137
+ export interface CompactRequest {
138
+ session_id: string;
139
+ messages: types.Message[];
140
+ max_tokens: bigint;
141
+ target_tokens: bigint;
142
+ }
143
+
144
+ /** Result of compaction. */
145
+ export interface CompactResponse {
146
+ messages: types.Message[];
147
+ compacted: boolean;
148
+ messages_removed: number;
149
+ strategy: string;
150
+ }
151
+
152
+ /** Request to estimate token count for messages. */
153
+ export interface EstimateRequest {
154
+ messages: types.Message[];
155
+ }
156
+
157
+ /** Token count estimate. */
158
+ export interface EstimateResponse {
159
+ estimated_tokens: bigint;
160
+ }
161
+
162
+ /** Hook payload sent before compaction (plugins can influence). */
163
+ export interface BeforeCompactionHook {
164
+ session_id: string;
165
+ messages: types.Message[];
166
+ message_count: number;
167
+ estimated_tokens: bigint;
168
+ max_tokens: bigint;
169
+ response_topic: string;
170
+ }
171
+
172
+ /** Plugin response to before-compaction hook. */
173
+ export interface BeforeCompactionHookResponse {
174
+ skip?: boolean;
175
+ pinned_message_ids: string[];
176
+ custom_strategy?: string;
177
+ }
178
+
179
+ /** Notification after compaction completes. */
180
+ export interface AfterCompactionEvent {
181
+ session_id: string;
182
+ messages_before: number;
183
+ messages_after: number;
184
+ tokens_before: bigint;
185
+ tokens_after: bigint;
186
+ strategy_used: string;
187
+ }
188
+
189
+ }
190
+
191
+ /** Types generated from the `elicit` WIT interface. */
192
+ export namespace elicit {
193
+ /** A lifecycle hook is requesting user input. */
194
+ export interface Request {
195
+ /** Correlation ID matching the response. */
196
+ request_id: string;
197
+ /** The capsule requesting input. */
198
+ capsule_id: string;
199
+ /** Field descriptor reusing the onboarding schema. */
200
+ field: onboarding.Field;
201
+ }
202
+
203
+ /** Response to an elicit request. */
204
+ export interface Response {
205
+ /** Must match the `request-id` from the originating request. */
206
+ request_id: string;
207
+ /** The user's input. Absent if the user cancelled. */
208
+ value?: string;
209
+ /** For `array`-type fields, the collected items. */
210
+ values?: string[];
211
+ }
212
+
213
+ }
214
+
215
+ /** Types generated from the `hook` WIT interface. */
216
+ export namespace hook {
217
+ /** Lifecycle events emitted by the kernel. */
218
+ export type LifecycleEvent = "session_created" | "session_ended" | "tool_call_started" | "tool_call_completed" | "tool_result_persisting" | "message_received" | "message_sending" | "message_sent" | "sub_agent_spawned" | "sub_agent_completed" | "sub_agent_failed" | "sub_agent_cancelled" | "context_compaction_started" | "context_compaction_completed" | "kernel_started" | "kernel_shutdown";
219
+
220
+ /** Merged result from hook fan-out. */
221
+ export interface HookResult {
222
+ /** Whether the operation should be skipped. */
223
+ skip?: boolean;
224
+ /** Merged data from interceptor responses (opaque JSON). */
225
+ data?: string;
226
+ }
227
+
228
+ }
229
+
230
+ /** Types generated from the `llm` WIT interface. */
231
+ export namespace llm {
232
+ /**
233
+ * Request asking an LLM-provider capsule to describe itself.
234
+ * Topic: `llm.v1.request.describe`. The registry capsule fans this
235
+ * out to discover available providers and their per-provider
236
+ * request / stream topics.
237
+ */
238
+ export interface DescribeRequest {
239
+ /**
240
+ * Correlation ID for the response. The provider replies on
241
+ * `llm.v1.response.describe.<correlation-id>`.
242
+ */
243
+ correlation_id: string;
244
+ }
245
+
246
+ /**
247
+ * Provider self-description response.
248
+ * Topic: `llm.v1.response.describe.<correlation-id>`.
249
+ */
250
+ export interface DescribeResponse {
251
+ /** Must match the `correlation-id` from the originating request. */
252
+ correlation_id: string;
253
+ /**
254
+ * Provider entries the capsule offers (one capsule may expose
255
+ * multiple models — e.g. an OpenAI-compatible front-end serving
256
+ * several model IDs).
257
+ */
258
+ providers: registry.ProviderEntry[];
259
+ }
260
+
261
+ /** Request to generate a response. */
262
+ export interface GenerateRequest {
263
+ request_id: string;
264
+ model: string;
265
+ messages: types.Message[];
266
+ tools: types.ToolDefinition[];
267
+ /** System prompt. */
268
+ system: string;
269
+ }
270
+
271
+ /** A streaming event from the provider. */
272
+ export type StreamEvent =
273
+ | { tag: "text_delta"; value: string }
274
+ | { tag: "tool_call_start"; value: ToolCallStartEvent }
275
+ | { tag: "tool_call_delta"; value: ToolCallDeltaEvent }
276
+ | { tag: "tool_call_end"; value: ToolCallEndEvent }
277
+ | { tag: "reasoning_delta"; value: string }
278
+ | { tag: "usage"; value: types.Usage }
279
+ | { tag: "done" }
280
+ | { tag: "error"; value: string };
281
+
282
+ export interface ToolCallStartEvent {
283
+ id: string;
284
+ name: string;
285
+ }
286
+
287
+ export interface ToolCallDeltaEvent {
288
+ id: string;
289
+ args_delta: string;
290
+ }
291
+
292
+ export interface ToolCallEndEvent {
293
+ id: string;
294
+ }
295
+
296
+ /** Final (non-streaming) response. */
297
+ export interface GenerateResponse {
298
+ message: types.Message;
299
+ has_tool_calls: boolean;
300
+ stop_reason: StopReason;
301
+ usage: types.Usage;
302
+ }
303
+
304
+ export type StopReason = "end_turn" | "max_tokens" | "tool_use" | "stop_sequence";
305
+
306
+ }
307
+
308
+ /** Types generated from the `onboarding` WIT interface. */
309
+ export namespace onboarding {
310
+ /** A capsule needs environment variables to be provided by the user. */
311
+ export interface Required {
312
+ /** The ID of the capsule requiring onboarding. */
313
+ capsule_id: string;
314
+ /** Rich field descriptors for each missing env var. */
315
+ fields: Field[];
316
+ }
317
+
318
+ /** A field descriptor for capsule onboarding. */
319
+ export interface Field {
320
+ /** The environment variable key. */
321
+ key: string;
322
+ /** The prompt shown to the user. */
323
+ prompt: string;
324
+ /** Optional description for additional context. */
325
+ description?: string;
326
+ /** The input type for this field. */
327
+ field_type: FieldType;
328
+ /** Optional default value. */
329
+ default?: string;
330
+ /** Placeholder hint text shown when the input is empty (e.g. `"sk-..."`). */
331
+ placeholder?: string;
332
+ }
333
+
334
+ /** The type of input expected for an onboarding field. */
335
+ export type FieldType =
336
+ | { tag: "text" }
337
+ | { tag: "secret" }
338
+ | { tag: "choice"; value: string[] }
339
+ | { tag: "array" };
340
+
341
+ }
342
+
343
+ /** Types generated from the `prompt` WIT interface. */
344
+ export namespace prompt {
345
+ /** Request to assemble a prompt for LLM generation. */
346
+ export interface AssembleRequest {
347
+ messages: types.Message[];
348
+ system_prompt: string;
349
+ request_id: string;
350
+ model: string;
351
+ provider: string;
352
+ session_id?: string;
353
+ }
354
+
355
+ /** Assembled prompt ready for LLM. */
356
+ export interface AssembleResponse {
357
+ system_prompt: string;
358
+ user_context_prefix: string;
359
+ request_id: string;
360
+ session_id?: string;
361
+ /** Collected tool schemas from tool-providing capsules. */
362
+ tools: types.ToolDefinition[];
363
+ /** Session conversation history messages. */
364
+ messages: types.Message[];
365
+ }
366
+
367
+ /** Hook payload sent before prompt build (plugins inject context). */
368
+ export interface BeforeBuildHook {
369
+ messages: types.Message[];
370
+ system_prompt: string;
371
+ request_id: string;
372
+ model: string;
373
+ provider: string;
374
+ response_topic: string;
375
+ }
376
+
377
+ /** Plugin response to before-build hook. */
378
+ export interface BeforeBuildHookResponse {
379
+ prepend_system_context?: string;
380
+ append_system_context?: string;
381
+ system_prompt?: string;
382
+ prepend_context?: string;
383
+ }
384
+
385
+ /** Notification after prompt is built. */
386
+ export interface AfterBuildEvent {
387
+ system_prompt: string;
388
+ user_context_prefix: string;
389
+ request_id: string;
390
+ }
391
+
392
+ }
393
+
394
+ /** Types generated from the `registry` WIT interface. */
395
+ export namespace registry {
396
+ /** An available LLM provider entry. */
397
+ export interface ProviderEntry {
398
+ /** Model ID (e.g. "gpt-5.4", "claude-sonnet-4-20250514"). */
399
+ id: string;
400
+ /** Human-readable description. */
401
+ description: string;
402
+ /** IPC topic to publish LLM requests to. */
403
+ request_topic: string;
404
+ /** IPC topic the provider streams responses on. */
405
+ stream_topic: string;
406
+ /** Model capabilities (e.g. "text", "vision", "tools"). */
407
+ capabilities: string[];
408
+ /** Provider's context window size in tokens. */
409
+ context_window?: bigint;
410
+ /** Provider's max output tokens per request. */
411
+ max_output_tokens?: bigint;
412
+ }
413
+
414
+ /** A single option in a selection picker. */
415
+ export interface SelectionOption {
416
+ /** Machine-readable identifier sent back on the callback. */
417
+ id: string;
418
+ /** Human-readable label shown in the picker. */
419
+ label: string;
420
+ /** Optional description shown alongside the label. */
421
+ description?: string;
422
+ }
423
+
424
+ /**
425
+ * Capsule asking the user to choose from a set of options. Used by
426
+ * the registry to drive the LLM-provider picker UI in the TUI.
427
+ * Topic: `registry.v1.selection.required`.
428
+ */
429
+ export interface SelectionRequired {
430
+ /** Correlation ID for the callback. */
431
+ request_id: string;
432
+ /** Title or prompt shown above the list. */
433
+ title: string;
434
+ /** The selectable options. */
435
+ options: SelectionOption[];
436
+ /** IPC topic to publish the user's choice back on. */
437
+ callback_topic: string;
438
+ }
439
+
440
+ /**
441
+ * User's selection sent back to the requesting capsule.
442
+ * Topic: `registry.v1.selection.callback` (or the `callback-topic`
443
+ * declared in the matching `selection-required`).
444
+ */
445
+ export interface SelectionCallback {
446
+ /**
447
+ * Must match the `request-id` from the originating
448
+ * `selection-required`.
449
+ */
450
+ request_id: string;
451
+ /** `id` of the chosen `selection-option`. */
452
+ selected_id: string;
453
+ }
454
+
455
+ }
456
+
457
+ /** Types generated from the `session` WIT interface. */
458
+ export namespace session {
459
+ /** Request to fetch conversation history. */
460
+ export interface GetMessagesRequest {
461
+ session_id: string;
462
+ correlation_id: string;
463
+ append_before_read?: types.Message[];
464
+ }
465
+
466
+ /** Response containing conversation history. */
467
+ export interface GetMessagesResponse {
468
+ correlation_id: string;
469
+ messages: types.Message[];
470
+ }
471
+
472
+ /** Request to clear a session and start fresh. */
473
+ export interface ClearRequest {
474
+ session_id: string;
475
+ correlation_id: string;
476
+ }
477
+
478
+ /** Response confirming session cleared. */
479
+ export interface ClearResponse {
480
+ correlation_id: string;
481
+ new_session_id: string;
482
+ old_session_id: string;
483
+ }
484
+
485
+ /** Fire-and-forget append to conversation history. */
486
+ export interface AppendRequest {
487
+ session_id: string;
488
+ messages: types.Message[];
489
+ }
490
+
491
+ /**
492
+ * Broadcast notification that a session was cleared. Distinct from
493
+ * `clear-request`/`clear-response` (the request/response pair the
494
+ * session capsule handles): this is a fan-out event the agent loop
495
+ * publishes after a successful clear so unrelated capsules can drop
496
+ * any per-session ephemeral state. Topic: `session.v1.clear`.
497
+ */
498
+ export interface SessionCleared {
499
+ /** Session ID that was cleared. */
500
+ session_id: string;
501
+ }
502
+
503
+ }
504
+
505
+ /** Types generated from the `spark` WIT interface. */
506
+ export namespace spark {
507
+ /** Request to build the agent's system prompt. */
508
+ export interface BuildRequest {
509
+ workspace_root: string;
510
+ session_id?: string;
511
+ }
512
+
513
+ /** Response with the assembled system prompt. */
514
+ export interface BuildResponse {
515
+ prompt: string;
516
+ session_id?: string;
517
+ }
518
+
519
+ }
520
+
521
+ /** Types generated from the `system` WIT interface. */
522
+ export namespace system {
523
+ /**
524
+ * Published once after every capsule has reported ready, signalling
525
+ * that the agent stack is fully online. Topic: `astrid.v1.capsules_loaded`.
526
+ */
527
+ export interface CapsulesLoaded {
528
+ /** IDs of every capsule that successfully loaded. */
529
+ capsule_ids: string[];
530
+ }
531
+
532
+ /**
533
+ * Periodic kernel watchdog tick, used by long-lived capsules to age
534
+ * out stale state (timeouts, abandoned correlations, etc.).
535
+ * Topic: `astrid.v1.watchdog.tick`.
536
+ */
537
+ export interface WatchdogTick {
538
+ /** Wall-clock time of the tick (UNIX epoch milliseconds). */
539
+ timestamp_ms: bigint;
540
+ }
541
+
542
+ /**
543
+ * Warning emitted when a subscriber falls behind and the bus had to
544
+ * drop messages. Subscribers can use this as a signal to drain or
545
+ * resubscribe. Topic: `astrid.v1.event_bus.lagged`.
546
+ */
547
+ export interface EventBusLagged {
548
+ /** Topic that lagged. */
549
+ topic: string;
550
+ /** Number of messages dropped. */
551
+ dropped: bigint;
552
+ }
553
+
554
+ /**
555
+ * Cooperative restart signal — the kernel asks long-lived capsules
556
+ * to flush ephemeral state and re-arm. Topic: `system.v1.lifecycle.restart`.
557
+ */
558
+ export interface LifecycleRestart {
559
+ /** Reason for the restart (e.g. `"config-reload"`, `"upgrade"`). */
560
+ reason: string;
561
+ }
562
+
563
+ /**
564
+ * A slash-command typed by a human in an uplink. The CLI capsule
565
+ * publishes this when the user enters `/<command> [args]`. Routed
566
+ * to the capsule that registered the command name via its manifest.
567
+ * Topic: `cli.v1.command.execute`.
568
+ */
569
+ export interface CommandExecute {
570
+ /** The command name (without the leading slash). */
571
+ name: string;
572
+ /** JSON-encoded arguments (parsed by the receiving capsule). */
573
+ arguments: string;
574
+ /** Session ID the command was issued in. */
575
+ session_id: string;
576
+ }
577
+
578
+ }
579
+
580
+ /** Types generated from the `tool` WIT interface. */
581
+ export namespace tool {
582
+ /** Request to cancel in-flight tool executions. */
583
+ export interface CancelRequest {
584
+ call_ids: string[];
585
+ }
586
+
587
+ /**
588
+ * Request asking a tool-providing capsule to enumerate its tools.
589
+ * Topic: `tool.v1.request.describe`. Empty payload — every responder
590
+ * returns its full tool list. Routed by the SDK macro from
591
+ * `#[astrid::tool(...)]` attributes.
592
+ */
593
+ export interface DescribeRequest {
594
+ /**
595
+ * Correlation ID for the response. The capsule replies on
596
+ * `tool.v1.response.describe.<correlation-id>`.
597
+ */
598
+ correlation_id: string;
599
+ }
600
+
601
+ /**
602
+ * Response listing the tools a capsule provides.
603
+ * Topic: `tool.v1.response.describe.<correlation-id>`.
604
+ */
605
+ export interface DescribeResponse {
606
+ /** Must match the `correlation-id` from the originating request. */
607
+ correlation_id: string;
608
+ /** The capsule's exposed tools. */
609
+ tools: types.ToolDefinition[];
610
+ }
611
+
612
+ }
613
+
614
+ /** Types generated from the `user` WIT interface. */
615
+ export namespace user {
616
+ /** A prompt typed by a human via an uplink. */
617
+ export interface Prompt {
618
+ /** The raw text input. */
619
+ text: string;
620
+ /** Session ID for conversation continuity. Defaults to `"default"`. */
621
+ session_id: string;
622
+ /**
623
+ * Optional extra context (JSON-encoded) — e.g. attachments,
624
+ * metadata, or per-turn flags the uplink wants to forward.
625
+ */
626
+ context?: string;
627
+ }
628
+
629
+ }
630
+
631
+ /** Types generated from the `users` WIT interface. */
632
+ export namespace users {
633
+ /**
634
+ * Multi-tenant request envelope.
635
+ *
636
+ * Carries provenance ("which uplink, on behalf of which end-user")
637
+ * and a correlation token so the originating uplink can match the
638
+ * response back to the inflight request among many concurrent
639
+ * end-users on a single principal.
640
+ *
641
+ * Pending the broader admin-API correlation convention (kernel
642
+ * issue #748), `source` lives on this interface; once that
643
+ * convention formalizes a shared envelope, this record migrates
644
+ * to the shared location and the records below import it instead.
645
+ */
646
+ export interface Source {
647
+ /**
648
+ * Originating uplink capsule — e.g. `"cli"`, `"sphere"`,
649
+ * `"discord"`, `"telegram"`. Identifies the capsule making
650
+ * the request (for audit and routing); distinct from
651
+ * `frontend-link.platform`, which identifies the external
652
+ * service being linked.
653
+ */
654
+ uplink: string;
655
+ /**
656
+ * AstridUserId of the requester when known. `None` for
657
+ * system flows or pre-login pairing requests.
658
+ */
659
+ user_id?: string;
660
+ /**
661
+ * Correlation token. The requester subscribes to the response
662
+ * topic and filters incoming responses by this string.
663
+ */
664
+ correlation_id: string;
665
+ }
666
+
667
+ /**
668
+ * Canonical Astrid user identity.
669
+ *
670
+ * One record per human within the principal's user directory.
671
+ * `id` is the stable UUID — every `frontend-link` points at this.
672
+ */
673
+ export interface AstridUser {
674
+ /**
675
+ * UUID v4 string (lowercase, hyphenated). Stable for the
676
+ * lifetime of the user; never reused.
677
+ */
678
+ id: string;
679
+ /**
680
+ * Optional ed25519 public key (32 bytes raw). Set via
681
+ * `set-public-key`; used by future verification flows.
682
+ */
683
+ public_key?: number[];
684
+ /**
685
+ * Operator/canonical Astrid-side display name. Mutable via
686
+ * `set-display-name`. Distinct from any platform-side name.
687
+ */
688
+ display_name?: string;
689
+ /** Creation timestamp, RFC 3339 string. */
690
+ created_at: string;
691
+ }
692
+
693
+ /**
694
+ * A platform-to-Astrid-user identity link.
695
+ *
696
+ * Composite key: `(platform, platform-instance?, platform-user-id)`.
697
+ * Exactly one link may exist per triple; relinking overwrites.
698
+ */
699
+ export interface FrontendLink {
700
+ /**
701
+ * Normalized platform name (lowercased, trimmed) —
702
+ * e.g. `"discord"`, `"telegram"`, `"nostr"`, `"slack"`,
703
+ * `"matrix"`, `"email"`, `"x"`, `"github"`.
704
+ */
705
+ platform: string;
706
+ /**
707
+ * Optional platform instance for federated / multi-tenant
708
+ * platforms: Slack workspace, IRC network, XMPP server,
709
+ * Mattermost instance. `None` for globally-scoped platforms
710
+ * (Discord, Telegram, X) and for federated platforms whose
711
+ * identifier already embeds the homeserver in the user-id
712
+ * (Matrix `@alice:server.org`, Mastodon `@a@server.social`).
713
+ */
714
+ platform_instance?: string;
715
+ /**
716
+ * Platform-specific stable opaque user identifier
717
+ * (Discord snowflake, Telegram int64, Slack `U...`, Nostr
718
+ * npub, email address, E.164 phone). Never the user's
719
+ * mutable handle.
720
+ */
721
+ platform_user_id: string;
722
+ /** The Astrid user UUID this platform identity maps to. */
723
+ astrid_user_id: string;
724
+ /**
725
+ * When this link was created (RFC 3339). Refreshed on
726
+ * upsert relink.
727
+ */
728
+ linked_at: string;
729
+ /**
730
+ * How this link was established — `"admin"`, `"system"`,
731
+ * `"chat_command"`, `"passkey"`, `"self_declared"`, etc.
732
+ * Recorded for audit. Free-form string.
733
+ */
734
+ method: string;
735
+ /**
736
+ * Platform's *global* display name at link time —
737
+ * e.g. Discord global username `"alice"`, Telegram
738
+ * `@alice`, X handle. Mutable: re-link to refresh.
739
+ * Distinct from any per-context override
740
+ * (see `context-identity`) and from `astrid-user.display-name`
741
+ * (the operator-set canonical Astrid name).
742
+ */
743
+ display_name?: string;
744
+ }
745
+
746
+ /**
747
+ * Per-context display-name overlay on a `frontend-link`.
748
+ *
749
+ * One row per `(platform, platform-instance?, platform-user-id, context-id)`
750
+ * tuple. The capsule does NOT parse `context-id`; uplinks define
751
+ * per-platform schemes. Common conventions:
752
+ *
753
+ * - Discord per-guild nickname: `context-id = "guild:{guild-id}"`
754
+ * - Matrix per-room display name: `context-id = "room:{room-id}"`
755
+ * - Slack per-channel profile: `context-id = "channel:{channel-id}"`
756
+ * (workspace lives in `platform-instance`)
757
+ * - Mattermost per-team: `context-id = "team:{team-id}"`
758
+ * - Single-context platforms (X, SMS): no rows ever created
759
+ *
760
+ * Per-context attributes beyond `display-name` (roles, custom
761
+ * fields, preferences) intentionally do NOT live here. They
762
+ * belong in memory or a future authz capsule.
763
+ */
764
+ export interface ContextIdentity {
765
+ platform: string;
766
+ platform_instance?: string;
767
+ platform_user_id: string;
768
+ /** Opaque per-platform context key. */
769
+ context_id: string;
770
+ /** What this user is called *in this context*. */
771
+ display_name: string;
772
+ /** Last update timestamp (RFC 3339). */
773
+ updated_at: string;
774
+ }
775
+
776
+ /**
777
+ * Resolve a platform identity to an Astrid user, optionally
778
+ * scoped to a context for display-name layering.
779
+ * Topic: `users.v1.resolve.request`.
780
+ */
781
+ export interface ResolveRequest {
782
+ source: Source;
783
+ platform: string;
784
+ platform_instance?: string;
785
+ platform_user_id: string;
786
+ /**
787
+ * Optional context. When set, the response's `display-name`
788
+ * uses the per-context override if one exists. When None,
789
+ * only the link-global and canonical fallbacks apply.
790
+ */
791
+ context_id?: string;
792
+ }
793
+
794
+ /**
795
+ * Response for resolve.
796
+ * Topic: `users.v1.resolve.response`.
797
+ *
798
+ * A clean "no link exists" is `user = none` with `error = none`.
799
+ * Validation or storage failures populate `error` and leave the
800
+ * other success fields empty.
801
+ */
802
+ export interface ResolveResponse {
803
+ correlation_id: string;
804
+ user?: AstridUser;
805
+ /**
806
+ * The right name to address this user. Resolution order
807
+ * (first non-empty wins):
808
+ * 1. `context-identity.display-name` (if `context-id` was
809
+ * provided in the request and an override exists)
810
+ * 2. `frontend-link.display-name` (the platform-side name)
811
+ * 3. `astrid-user.display-name` (the canonical Astrid name)
812
+ * `None` if none of the three layers carry a name.
813
+ */
814
+ display_name?: string;
815
+ /**
816
+ * Which layer produced `display-name`. One of `"context"`,
817
+ * `"link"`, `"canonical"`. `None` when `display-name` is `None`.
818
+ */
819
+ display_name_source?: string;
820
+ error?: string;
821
+ }
822
+
823
+ /**
824
+ * Link a platform identity to an existing Astrid user. Upsert
825
+ * semantics: an existing link for the same
826
+ * `(platform, platform-instance?, platform-user-id)` is overwritten.
827
+ * Topic: `users.v1.link.request`.
828
+ */
829
+ export interface LinkRequest {
830
+ source: Source;
831
+ platform: string;
832
+ platform_instance?: string;
833
+ platform_user_id: string;
834
+ /** Target Astrid user UUID. Must already exist. */
835
+ astrid_user_id: string;
836
+ /** Audit string — how this link was established. */
837
+ method: string;
838
+ /**
839
+ * Optional platform-side global display name at link time.
840
+ * Stored on the resulting `frontend-link` for later
841
+ * resolution / display.
842
+ */
843
+ display_name?: string;
844
+ }
845
+
846
+ /**
847
+ * Response for link.
848
+ * Topic: `users.v1.link.response`.
849
+ */
850
+ export interface LinkResponse {
851
+ correlation_id: string;
852
+ link?: FrontendLink;
853
+ error?: string;
854
+ }
855
+
856
+ /**
857
+ * Remove a platform link. Also clears any
858
+ * `context-identity` overlays attached to it (cascading).
859
+ * Topic: `users.v1.unlink.request`.
860
+ */
861
+ export interface UnlinkRequest {
862
+ source: Source;
863
+ platform: string;
864
+ platform_instance?: string;
865
+ platform_user_id: string;
866
+ }
867
+
868
+ /**
869
+ * Response for unlink.
870
+ * Topic: `users.v1.unlink.response`.
871
+ */
872
+ export interface UnlinkResponse {
873
+ correlation_id: string;
874
+ /**
875
+ * `true` if a link existed and was removed; `false` for a
876
+ * no-op delete (link was already absent).
877
+ */
878
+ removed: boolean;
879
+ error?: string;
880
+ }
881
+
882
+ /**
883
+ * Create a new Astrid user.
884
+ * Topic: `users.v1.create.request`.
885
+ */
886
+ export interface CreateRequest {
887
+ source: Source;
888
+ /**
889
+ * Optional canonical display name. Rejected if it contains
890
+ * `/` or `\0`.
891
+ */
892
+ display_name?: string;
893
+ }
894
+
895
+ /**
896
+ * Response for create.
897
+ * Topic: `users.v1.create.response`.
898
+ */
899
+ export interface CreateResponse {
900
+ correlation_id: string;
901
+ user?: AstridUser;
902
+ error?: string;
903
+ }
904
+
905
+ /**
906
+ * Change an `AstridUser`'s canonical `display-name` without
907
+ * rotating the UUID or breaking any links.
908
+ * Topic: `users.v1.set_display_name.request`.
909
+ *
910
+ * `display-name = None` clears the name. To leave it unchanged,
911
+ * don't issue the request.
912
+ */
913
+ export interface SetDisplayNameRequest {
914
+ source: Source;
915
+ astrid_user_id: string;
916
+ display_name?: string;
917
+ }
918
+
919
+ /**
920
+ * Response for set-display-name.
921
+ * Topic: `users.v1.set_display_name.response`.
922
+ */
923
+ export interface SetDisplayNameResponse {
924
+ correlation_id: string;
925
+ user?: AstridUser;
926
+ error?: string;
927
+ }
928
+
929
+ /**
930
+ * Set or clear an `AstridUser`'s `public-key` without rotating
931
+ * the UUID.
932
+ * Topic: `users.v1.set_public_key.request`.
933
+ *
934
+ * `public-key = None` clears the key.
935
+ */
936
+ export interface SetPublicKeyRequest {
937
+ source: Source;
938
+ astrid_user_id: string;
939
+ public_key?: number[];
940
+ }
941
+
942
+ /**
943
+ * Response for set-public-key.
944
+ * Topic: `users.v1.set_public_key.response`.
945
+ */
946
+ export interface SetPublicKeyResponse {
947
+ correlation_id: string;
948
+ user?: AstridUser;
949
+ error?: string;
950
+ }
951
+
952
+ /**
953
+ * List every platform link for one Astrid user.
954
+ * Topic: `users.v1.links.request`.
955
+ */
956
+ export interface LinksRequest {
957
+ source: Source;
958
+ astrid_user_id: string;
959
+ }
960
+
961
+ /**
962
+ * Response for links.
963
+ * Topic: `users.v1.links.response`.
964
+ */
965
+ export interface LinksResponse {
966
+ correlation_id: string;
967
+ links: FrontendLink[];
968
+ error?: string;
969
+ }
970
+
971
+ /**
972
+ * Fetch a user record by UUID.
973
+ * Topic: `users.v1.get.request`.
974
+ */
975
+ export interface GetRequest {
976
+ source: Source;
977
+ astrid_user_id: string;
978
+ }
979
+
980
+ /**
981
+ * Response for get.
982
+ * Topic: `users.v1.get.response`.
983
+ */
984
+ export interface GetResponse {
985
+ correlation_id: string;
986
+ user?: AstridUser;
987
+ error?: string;
988
+ }
989
+
990
+ /**
991
+ * Delete a user, every link pointing at it, and every
992
+ * per-context overlay tied to those links.
993
+ * Idempotent — deleting an absent UUID returns `deleted = false`.
994
+ * Topic: `users.v1.delete.request`.
995
+ */
996
+ export interface DeleteRequest {
997
+ source: Source;
998
+ astrid_user_id: string;
999
+ }
1000
+
1001
+ /**
1002
+ * Response for delete.
1003
+ * Topic: `users.v1.delete.response`.
1004
+ */
1005
+ export interface DeleteResponse {
1006
+ correlation_id: string;
1007
+ /** `true` when a user record existed and was deleted. */
1008
+ deleted: boolean;
1009
+ error?: string;
1010
+ }
1011
+
1012
+ /**
1013
+ * List every user record in the principal's store. Paginated.
1014
+ * Topic: `users.v1.list.request`.
1015
+ */
1016
+ export interface ListRequest {
1017
+ source: Source;
1018
+ /**
1019
+ * Cursor from a prior `list-response.next-cursor`. `None`
1020
+ * on the first call.
1021
+ */
1022
+ cursor?: string;
1023
+ /**
1024
+ * Maximum users to return. `None` lets the capsule pick a
1025
+ * sensible default (current impl: 100).
1026
+ */
1027
+ limit?: number;
1028
+ }
1029
+
1030
+ /**
1031
+ * Response for list.
1032
+ * Topic: `users.v1.list.response`.
1033
+ */
1034
+ export interface ListResponse {
1035
+ correlation_id: string;
1036
+ users: AstridUser[];
1037
+ /**
1038
+ * Pass back as `list-request.cursor` to get the next page.
1039
+ * `None` when no more pages remain.
1040
+ */
1041
+ next_cursor?: string;
1042
+ error?: string;
1043
+ }
1044
+
1045
+ /**
1046
+ * Set (or upsert) a per-context display-name override for a
1047
+ * linked platform identity. The underlying `frontend-link` must
1048
+ * already exist — context overlays cannot dangle.
1049
+ * Topic: `users.v1.context.set.request`.
1050
+ */
1051
+ export interface ContextSetRequest {
1052
+ source: Source;
1053
+ platform: string;
1054
+ platform_instance?: string;
1055
+ platform_user_id: string;
1056
+ context_id: string;
1057
+ display_name: string;
1058
+ }
1059
+
1060
+ /**
1061
+ * Response for context-set.
1062
+ * Topic: `users.v1.context.set.response`.
1063
+ */
1064
+ export interface ContextSetResponse {
1065
+ correlation_id: string;
1066
+ context_identity?: ContextIdentity;
1067
+ error?: string;
1068
+ }
1069
+
1070
+ /**
1071
+ * Clear a per-context display-name override. Leaves the link
1072
+ * itself and the global link-level display-name untouched.
1073
+ * Topic: `users.v1.context.clear.request`.
1074
+ */
1075
+ export interface ContextClearRequest {
1076
+ source: Source;
1077
+ platform: string;
1078
+ platform_instance?: string;
1079
+ platform_user_id: string;
1080
+ context_id: string;
1081
+ }
1082
+
1083
+ /**
1084
+ * Response for context-clear.
1085
+ * Topic: `users.v1.context.clear.response`.
1086
+ */
1087
+ export interface ContextClearResponse {
1088
+ correlation_id: string;
1089
+ /**
1090
+ * `true` if an overlay existed and was removed; `false` for
1091
+ * a no-op clear.
1092
+ */
1093
+ removed: boolean;
1094
+ error?: string;
1095
+ }
1096
+
1097
+ /**
1098
+ * Fetch the per-context override for one
1099
+ * `(link, context-id)` pair. Useful when the caller wants the
1100
+ * raw override without the `resolve`-style fallback chain.
1101
+ * Topic: `users.v1.context.get.request`.
1102
+ */
1103
+ export interface ContextGetRequest {
1104
+ source: Source;
1105
+ platform: string;
1106
+ platform_instance?: string;
1107
+ platform_user_id: string;
1108
+ context_id: string;
1109
+ }
1110
+
1111
+ /**
1112
+ * Response for context-get.
1113
+ * Topic: `users.v1.context.get.response`.
1114
+ */
1115
+ export interface ContextGetResponse {
1116
+ correlation_id: string;
1117
+ context_identity?: ContextIdentity;
1118
+ /**
1119
+ * The same user resolved through the underlying link, when
1120
+ * it exists. Saves the caller a separate `resolve` call.
1121
+ */
1122
+ astrid_user_id?: string;
1123
+ error?: string;
1124
+ }
1125
+
1126
+ /**
1127
+ * List every context overlay attached to one Astrid user, across
1128
+ * platforms and contexts. Paginated.
1129
+ * Topic: `users.v1.context.list_for_user.request`.
1130
+ */
1131
+ export interface ContextListForUserRequest {
1132
+ source: Source;
1133
+ astrid_user_id: string;
1134
+ cursor?: string;
1135
+ limit?: number;
1136
+ }
1137
+
1138
+ /**
1139
+ * Response for context-list-for-user.
1140
+ * Topic: `users.v1.context.list_for_user.response`.
1141
+ */
1142
+ export interface ContextListForUserResponse {
1143
+ correlation_id: string;
1144
+ contexts: ContextIdentity[];
1145
+ next_cursor?: string;
1146
+ error?: string;
1147
+ }
1148
+
1149
+ /**
1150
+ * List every user known in one specific context (e.g. every
1151
+ * member of one Discord guild who has a per-guild nickname
1152
+ * recorded). Returns the context overlay rows plus the resolved
1153
+ * `astrid-user-id` for each, so the caller can build a member
1154
+ * roster in one paginated call. Paginated.
1155
+ * Topic: `users.v1.context.list_in_context.request`.
1156
+ */
1157
+ export interface ContextListInContextRequest {
1158
+ source: Source;
1159
+ platform: string;
1160
+ platform_instance?: string;
1161
+ context_id: string;
1162
+ cursor?: string;
1163
+ limit?: number;
1164
+ }
1165
+
1166
+ /** One row of the context-list-in-context response. */
1167
+ export interface ContextMember {
1168
+ context_identity: ContextIdentity;
1169
+ /**
1170
+ * Resolved Astrid user UUID via the underlying link, when
1171
+ * the link still exists. `None` indicates a stale overlay
1172
+ * (link was unlinked but overlay wasn't cleared — the
1173
+ * capsule cleans these on unlink, so this should be rare).
1174
+ */
1175
+ astrid_user_id?: string;
1176
+ }
1177
+
1178
+ /**
1179
+ * Response for context-list-in-context.
1180
+ * Topic: `users.v1.context.list_in_context.response`.
1181
+ */
1182
+ export interface ContextListInContextResponse {
1183
+ correlation_id: string;
1184
+ members: ContextMember[];
1185
+ next_cursor?: string;
1186
+ error?: string;
1187
+ }
1188
+
1189
+ }