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