agent-relay-sdk 0.1.0 → 0.2.1

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 (43) hide show
  1. package/dist/bus-client.d.ts +45 -2
  2. package/dist/bus-client.d.ts.map +1 -1
  3. package/dist/bus-client.js +157 -3
  4. package/dist/bus-client.js.map +1 -1
  5. package/dist/claim-tracker.d.ts +19 -0
  6. package/dist/claim-tracker.d.ts.map +1 -0
  7. package/dist/claim-tracker.js +26 -0
  8. package/dist/claim-tracker.js.map +1 -0
  9. package/dist/context-probe.d.ts +43 -0
  10. package/dist/context-probe.d.ts.map +1 -0
  11. package/dist/context-probe.js +210 -0
  12. package/dist/context-probe.js.map +1 -0
  13. package/dist/contracts.d.ts +27 -0
  14. package/dist/contracts.d.ts.map +1 -0
  15. package/dist/contracts.js +34 -0
  16. package/dist/contracts.js.map +1 -0
  17. package/dist/http-client.d.ts +66 -5
  18. package/dist/http-client.d.ts.map +1 -1
  19. package/dist/http-client.js +148 -9
  20. package/dist/http-client.js.map +1 -1
  21. package/dist/index.d.ts +4 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +4 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/protocol.d.ts +9 -1
  26. package/dist/protocol.d.ts.map +1 -1
  27. package/dist/protocol.js.map +1 -1
  28. package/dist/provider-catalog.d.ts +80 -0
  29. package/dist/provider-catalog.d.ts.map +1 -0
  30. package/dist/provider-catalog.js +84 -0
  31. package/dist/provider-catalog.js.map +1 -0
  32. package/dist/types.d.ts +921 -4
  33. package/dist/types.d.ts.map +1 -1
  34. package/package.json +17 -1
  35. package/src/bus-client.ts +176 -4
  36. package/src/claim-tracker.ts +40 -0
  37. package/src/context-probe.ts +257 -0
  38. package/src/contracts.ts +47 -0
  39. package/src/http-client.ts +166 -11
  40. package/src/index.ts +4 -0
  41. package/src/protocol.ts +10 -0
  42. package/src/provider-catalog.ts +174 -0
  43. package/src/types.ts +1035 -8
package/dist/types.d.ts CHANGED
@@ -12,12 +12,335 @@ export interface AgentCard {
12
12
  status: AgentStatus;
13
13
  instanceId?: string;
14
14
  epoch: number;
15
+ providerCapabilities?: ProviderCapabilities;
16
+ context?: ContextState;
15
17
  meta?: Record<string, unknown>;
16
18
  lastSeen: number;
17
19
  createdAt: number;
18
20
  }
19
21
  export type AgentStatus = "online" | "idle" | "busy" | "stale" | "offline";
22
+ export type CapabilitySource = "catalog" | "provider" | "runtime" | "override" | "estimate";
23
+ export type CapabilityConfidence = "declared" | "reported" | "verified" | "estimated" | "unknown";
24
+ export interface ProviderCapabilities {
25
+ lifecycle: {
26
+ managed: boolean;
27
+ shutdownHard: boolean;
28
+ restartHard: boolean;
29
+ semanticStatus?: boolean;
30
+ reconnect?: boolean;
31
+ hibernate?: boolean;
32
+ resume?: boolean;
33
+ };
34
+ model?: {
35
+ provider?: SpawnProvider | string;
36
+ id?: string;
37
+ alias?: string;
38
+ providerModel?: string;
39
+ effort?: SpawnEffort | string;
40
+ source: CapabilitySource;
41
+ confidence: CapabilityConfidence;
42
+ lastUpdatedAt?: number;
43
+ };
44
+ session?: {
45
+ approvalMode?: SpawnApprovalMode | string;
46
+ fileRead?: boolean;
47
+ fileWrite?: boolean;
48
+ shell?: boolean;
49
+ source: CapabilitySource;
50
+ confidence: CapabilityConfidence;
51
+ lastUpdatedAt?: number;
52
+ };
53
+ context?: {
54
+ stats?: {
55
+ source: "api" | "statusline" | "hook" | "estimate";
56
+ confidence: "exact" | "reported" | "estimated";
57
+ };
58
+ compact?: boolean;
59
+ clear?: boolean;
60
+ inject?: boolean;
61
+ fork?: boolean;
62
+ rollback?: boolean;
63
+ archive?: boolean;
64
+ };
65
+ terminal?: {
66
+ live?: {
67
+ read?: boolean;
68
+ write?: boolean;
69
+ };
70
+ attach?: {
71
+ create?: boolean;
72
+ read?: boolean;
73
+ write?: boolean;
74
+ detach?: boolean;
75
+ };
76
+ };
77
+ source: CapabilitySource;
78
+ confidence: CapabilityConfidence;
79
+ lastUpdatedAt: number;
80
+ }
81
+ export type ContextLifecycleState = "fresh" | "primed" | "working" | "cooling" | "compacting" | "hibernating";
82
+ export interface ContextProbeMetrics {
83
+ agentId: string;
84
+ contextPercent: number;
85
+ tokensUsed?: number;
86
+ tokensMax?: number;
87
+ quotaUsed?: number;
88
+ quotaLimit?: number;
89
+ quotaResetIn?: number;
90
+ model?: string;
91
+ effort?: string;
92
+ source: "statusline" | "hook" | "api" | "estimate";
93
+ confidence: "exact" | "reported" | "estimated";
94
+ timestamp: number;
95
+ }
96
+ export interface ContextState {
97
+ utilization: number;
98
+ tokensUsed?: number;
99
+ tokensMax?: number;
100
+ lifecycleState: ContextLifecycleState;
101
+ warmTopics: string[];
102
+ activeMemories: string[];
103
+ tasksSinceCompact: number;
104
+ lastCompactedAt?: number;
105
+ lastUpdatedAt: number;
106
+ source: "statusline" | "hook" | "api" | "estimate";
107
+ confidence: "exact" | "reported" | "estimated";
108
+ }
109
+ export interface ContextSnapshot {
110
+ id: number;
111
+ agentId: string;
112
+ context: ContextState;
113
+ utilization: number;
114
+ lifecycleState: ContextLifecycleState;
115
+ tokensUsed?: number;
116
+ tokensMax?: number;
117
+ source: ContextState["source"];
118
+ confidence: ContextState["confidence"];
119
+ capturedAt: number;
120
+ }
121
+ export type MemoryType = "organization" | "role" | "project" | "task" | "interaction" | "agent";
122
+ export type MemoryVisibility = "private" | "project" | "org" | "public";
123
+ export type MemorySensitivity = "public" | "normal" | "sensitive" | "secret";
124
+ export type MemoryConfidence = "reported" | "inferred" | "verified";
125
+ export type MemoryRedactionState = "raw" | "redacted" | "rejected";
126
+ export interface Memory {
127
+ id: string;
128
+ type: MemoryType;
129
+ scope: string;
130
+ title: string;
131
+ content: string;
132
+ tags: string[];
133
+ visibility: MemoryVisibility;
134
+ sensitivity: MemorySensitivity;
135
+ confidence: MemoryConfidence;
136
+ redactionState: MemoryRedactionState;
137
+ relevanceScore: number;
138
+ sourceAgent?: string;
139
+ sourceTask?: number;
140
+ createdBy?: string;
141
+ contentHash?: string;
142
+ metadata: Record<string, unknown>;
143
+ accessCount: number;
144
+ lastAccessedAt?: number;
145
+ createdAt: number;
146
+ updatedAt: number;
147
+ expiresAt?: number;
148
+ }
149
+ export interface CreateMemoryInput {
150
+ type: MemoryType;
151
+ scope: string;
152
+ title: string;
153
+ content: string;
154
+ tags?: string[];
155
+ visibility?: MemoryVisibility;
156
+ sensitivity?: MemorySensitivity;
157
+ confidence?: MemoryConfidence;
158
+ redactionState?: MemoryRedactionState;
159
+ relevanceScore?: number;
160
+ sourceAgent?: string;
161
+ sourceTask?: number;
162
+ createdBy?: string;
163
+ metadata?: Record<string, unknown>;
164
+ ttlMs?: number;
165
+ }
166
+ export interface UpdateMemoryInput {
167
+ title?: string;
168
+ content?: string;
169
+ tags?: string[];
170
+ visibility?: MemoryVisibility;
171
+ sensitivity?: MemorySensitivity;
172
+ confidence?: MemoryConfidence;
173
+ redactionState?: MemoryRedactionState;
174
+ relevanceScore?: number;
175
+ metadata?: Record<string, unknown>;
176
+ expiresAt?: number | null;
177
+ }
178
+ export interface MemoryQuery {
179
+ type?: MemoryType;
180
+ scope?: string;
181
+ tags?: string[];
182
+ minRelevance?: number;
183
+ limit?: number;
184
+ includeExpired?: boolean;
185
+ visibility?: MemoryVisibility;
186
+ includeSensitive?: boolean;
187
+ }
188
+ export interface MemorySearchResult {
189
+ memories: Memory[];
190
+ total: number;
191
+ }
192
+ export interface PackagedMemory {
193
+ memory: Memory;
194
+ reason: string;
195
+ priority: 1 | 2 | 3;
196
+ score?: number;
197
+ }
198
+ export interface TaskRoutingHints {
199
+ id?: number;
200
+ title?: string;
201
+ text?: string;
202
+ scope?: string;
203
+ tags?: string[];
204
+ capabilities?: string[];
205
+ target?: string;
206
+ }
207
+ export interface ContextBudget {
208
+ maxTokens: number;
209
+ maxMemories: number;
210
+ priorityCutoff: 1 | 2 | 3;
211
+ }
212
+ export interface TaskHistorySummary {
213
+ taskId: number;
214
+ agentId: string;
215
+ status: string;
216
+ summary?: string;
217
+ completedAt?: number;
218
+ }
219
+ export interface ContextPackage {
220
+ memories: PackagedMemory[];
221
+ rolePrompt?: string;
222
+ recentContext?: string;
223
+ taskHistory?: TaskHistorySummary[];
224
+ estimatedTokens: number;
225
+ }
226
+ export interface ContextPackageRequest {
227
+ task: TaskRoutingHints;
228
+ agent: AgentCard;
229
+ budget: ContextBudget;
230
+ memories?: Memory[];
231
+ }
232
+ export interface MemoryStats {
233
+ total: number;
234
+ byType: Partial<Record<MemoryType, number>>;
235
+ byScope: Record<string, number>;
236
+ bySensitivity: Partial<Record<MemorySensitivity, number>>;
237
+ }
238
+ export type ActiveMemoryClearReason = "compact" | "clearContext" | "restart" | "shutdown" | "manual";
239
+ export interface MemoryBrokerCapabilities {
240
+ search: true;
241
+ create: boolean;
242
+ update: boolean;
243
+ delete: boolean;
244
+ stats: boolean;
245
+ assemble: boolean;
246
+ activeTracking: boolean;
247
+ activeList: boolean;
248
+ external: boolean;
249
+ }
250
+ export interface MemoryBrokerContext {
251
+ now: number;
252
+ actor: string;
253
+ scopes: string[];
254
+ relayUrl?: string;
255
+ requestId?: string;
256
+ }
257
+ export type MemoryBrokerKind = "sqlite" | "http" | "command";
258
+ export interface SqliteMemoryBrokerConfig {
259
+ type: "sqlite";
260
+ }
261
+ export interface HttpMemoryBrokerConfig {
262
+ type: "http";
263
+ url: string;
264
+ tokenEnv?: string;
265
+ timeoutMs?: number;
266
+ }
267
+ export interface CommandMemoryBrokerConfig {
268
+ type: "command";
269
+ command: string;
270
+ args?: string[];
271
+ timeoutMs?: number;
272
+ }
273
+ export type MemoryBrokerConfig = SqliteMemoryBrokerConfig | HttpMemoryBrokerConfig | CommandMemoryBrokerConfig;
20
274
  export type MessageKind = "chat" | "channel.event" | "task" | "pair" | "control" | "system";
275
+ export type ArtifactKind = "image" | "audio" | "video" | "document" | "archive" | "other";
276
+ export type ArtifactSensitivity = "public" | "normal" | "sensitive" | "secret";
277
+ export type ArtifactVisibility = "private" | "project" | "org";
278
+ export type ArtifactRole = "media" | "patch" | "report" | "log" | "output" | "input";
279
+ export interface ArtifactBlob {
280
+ digest: string;
281
+ storageUri: string;
282
+ mediaType: string;
283
+ size: number;
284
+ createdAt: number;
285
+ }
286
+ export interface ArtifactLink {
287
+ id: string;
288
+ artifactId: string;
289
+ entityType: "message" | "task" | "recipeRun" | "recipeStep" | "channelEvent";
290
+ entityId: string;
291
+ role?: ArtifactRole;
292
+ title?: string;
293
+ createdBy: string;
294
+ createdAt: number;
295
+ }
296
+ export interface Artifact {
297
+ id: string;
298
+ blobDigest: string;
299
+ mediaType: string;
300
+ kind: ArtifactKind;
301
+ filename?: string;
302
+ size: number;
303
+ digest: string;
304
+ visibility: ArtifactVisibility;
305
+ sensitivity: ArtifactSensitivity;
306
+ createdBy: string;
307
+ createdAt: number;
308
+ expiresAt?: number;
309
+ metadata: Record<string, unknown>;
310
+ links?: ArtifactLink[];
311
+ url?: string;
312
+ }
313
+ export interface AttachmentRef {
314
+ artifactId: string;
315
+ kind?: ArtifactKind;
316
+ role?: ArtifactRole;
317
+ title?: string;
318
+ ref?: AttachmentSourceRef;
319
+ metadata?: Record<string, unknown>;
320
+ }
321
+ export interface ChannelAttachmentRef {
322
+ artifactId?: string;
323
+ kind?: ArtifactKind;
324
+ role?: ArtifactRole;
325
+ title?: string;
326
+ ref?: AttachmentSourceRef;
327
+ metadata?: Record<string, unknown>;
328
+ }
329
+ export type AttachmentSourceRef = {
330
+ type: "relay-blob";
331
+ id: string;
332
+ [key: string]: unknown;
333
+ } | {
334
+ type: "external-url";
335
+ url: string;
336
+ [key: string]: unknown;
337
+ } | {
338
+ type: "channel-file";
339
+ id: string;
340
+ provider?: string;
341
+ uniqueId?: string;
342
+ [key: string]: unknown;
343
+ };
21
344
  export interface Message {
22
345
  id: number;
23
346
  from: string;
@@ -33,11 +356,68 @@ export interface Message {
33
356
  claimedAt?: number;
34
357
  claimExpiresAt?: number;
35
358
  idempotencyKey?: string;
359
+ deliveryStatus?: MessageDeliveryStatus;
360
+ deliveryAttempts?: number;
361
+ deliveryLastError?: string;
362
+ deliveryNextRetryAt?: number;
363
+ deliveryPoisonReason?: string;
364
+ deliveryUpdatedAt?: number;
365
+ queuedAt?: number;
366
+ maxAgeSeconds?: number;
367
+ resolvedToAgent?: string;
36
368
  payload: Record<string, unknown>;
37
369
  meta?: Record<string, unknown>;
370
+ reactions?: MessageReaction[];
38
371
  readBy: string[];
39
372
  createdAt: number;
40
373
  }
374
+ export interface ReplyObligation {
375
+ messageId: number;
376
+ agentId: string;
377
+ from: string;
378
+ kind: MessageKind;
379
+ subject?: string;
380
+ channel?: string;
381
+ bodyPreview: string;
382
+ createdAt: number;
383
+ replyCommand: string;
384
+ }
385
+ export interface MessageReaction {
386
+ messageId: number;
387
+ actorId: string;
388
+ emoji: string;
389
+ createdAt: number;
390
+ updatedAt: number;
391
+ }
392
+ export type RelayNotificationKind = "message" | "reply" | "error" | "agent.blocked";
393
+ export type RelayNotificationSeverity = "info" | "warning" | "error";
394
+ export interface RelayNotification {
395
+ id: string;
396
+ kind: RelayNotificationKind;
397
+ severity: RelayNotificationSeverity;
398
+ title: string;
399
+ body: string;
400
+ messageId?: number;
401
+ agentId?: string;
402
+ threadPeer?: string;
403
+ view?: "chat" | "messages" | "agents" | "work" | "tasks" | "channels" | "overview";
404
+ createdAt: number;
405
+ }
406
+ export type MessageDeliveryStatus = "pending" | "delivered" | "queued" | "failed" | "dead";
407
+ export interface MessageDeliveryAttempt {
408
+ id: number;
409
+ messageId: number;
410
+ agentId?: string;
411
+ action: "attempt" | "retry-now" | "mark-dead" | "clear";
412
+ status: MessageDeliveryStatus;
413
+ error?: string;
414
+ nextRetryAt?: number;
415
+ poisonReason?: string;
416
+ createdAt: number;
417
+ }
418
+ export interface MessageDeliveryState extends Pick<Message, "id" | "to" | "deliveryStatus" | "deliveryAttempts" | "deliveryLastError" | "deliveryNextRetryAt" | "deliveryPoisonReason" | "deliveryUpdatedAt" | "queuedAt" | "maxAgeSeconds" | "resolvedToAgent"> {
419
+ attempts: MessageDeliveryAttempt[];
420
+ }
41
421
  export interface SendMessageInput {
42
422
  from: string;
43
423
  to: string;
@@ -48,6 +428,8 @@ export interface SendMessageInput {
48
428
  replyTo?: number;
49
429
  claimable?: boolean;
50
430
  idempotencyKey?: string;
431
+ maxAgeSeconds?: number;
432
+ attachments?: AttachmentRef[];
51
433
  payload?: Record<string, unknown>;
52
434
  meta?: Record<string, unknown>;
53
435
  }
@@ -152,6 +534,8 @@ export interface RegisterAgentInput {
152
534
  ready?: boolean;
153
535
  status?: AgentCard["status"];
154
536
  instanceId?: string;
537
+ providerCapabilities?: ProviderCapabilities;
538
+ context?: ContextState;
155
539
  meta?: Record<string, unknown>;
156
540
  }
157
541
  export interface AgentSessionGuard {
@@ -232,6 +616,7 @@ export interface IntegrationEventInput {
232
616
  channel?: string;
233
617
  dedupeKey?: string;
234
618
  externalUrl?: string;
619
+ attachments?: AttachmentRef[];
235
620
  metadata?: Record<string, unknown>;
236
621
  }
237
622
  export interface IntegrationTaskStats {
@@ -245,8 +630,19 @@ export interface IntegrationTaskStats {
245
630
  }
246
631
  export interface IntegrationSummary {
247
632
  name: string;
633
+ displayName?: string;
634
+ description?: string;
635
+ enabled: boolean;
248
636
  configured: boolean;
249
637
  observed: boolean;
638
+ type?: string;
639
+ icon?: string;
640
+ accentColor?: string;
641
+ tags: string[];
642
+ homepageUrl?: string;
643
+ repositoryUrl?: string;
644
+ docsUrl?: string;
645
+ manifest?: Record<string, unknown>;
250
646
  scopes: string[];
251
647
  targets: string[];
252
648
  channels: string[];
@@ -259,6 +655,23 @@ export interface IntegrationSummary {
259
655
  };
260
656
  taskStats: IntegrationTaskStats;
261
657
  }
658
+ export type RuntimeContractName = "relayApi" | "orchestratorProtocol" | "runnerProtocol" | "providerPluginProtocol";
659
+ export type RuntimeContracts = Partial<Record<RuntimeContractName, number>>;
660
+ export type RuntimeCapabilities = Record<string, boolean>;
661
+ export interface RuntimePackageMetadata {
662
+ name: string;
663
+ version: string;
664
+ }
665
+ export interface ContractCompatibilityIssue {
666
+ contract: string;
667
+ expected: string;
668
+ actual?: number;
669
+ }
670
+ export interface ContractCompatibility {
671
+ status: "compatible" | "incompatible" | "unknown";
672
+ compatible: boolean;
673
+ issues: ContractCompatibilityIssue[];
674
+ }
262
675
  export type AutomationKind = "scheduled_task";
263
676
  export type AutomationCatchUpPolicy = "skip" | "run_once" | "run_all";
264
677
  export type AutomationConcurrencyPolicy = "skip" | "queue" | "replace";
@@ -276,13 +689,22 @@ export interface AutomationExistingAgentPolicy {
276
689
  export interface AutomationOnDemandAgentPolicy {
277
690
  mode: "on_demand_agent";
278
691
  provider: SpawnProvider;
692
+ model?: string;
693
+ effort?: SpawnEffort;
279
694
  cwd?: string;
695
+ workspaceMode?: WorkspaceMode;
280
696
  profile?: string;
281
697
  approvalMode?: SpawnApprovalMode;
282
698
  keepAlive?: boolean;
699
+ runtimeBudget?: AutomationRuntimeBudget;
283
700
  shutdownAfterMs?: number;
284
701
  }
285
702
  export type AutomationTargetPolicy = AutomationExistingAgentPolicy | AutomationOnDemandAgentPolicy;
703
+ export interface AutomationRuntimeBudget {
704
+ maxRuntimeMs: number;
705
+ warnAtMs?: number;
706
+ warningMessage?: string;
707
+ }
286
708
  export interface AutomationTaskTemplate {
287
709
  title: string;
288
710
  body: string;
@@ -320,7 +742,6 @@ export interface AutomationRun {
320
742
  spawnedAgentId?: string;
321
743
  taskId?: number;
322
744
  messageId?: number;
323
- controlMessageId?: number;
324
745
  error?: string;
325
746
  result?: Record<string, unknown>;
326
747
  meta: Record<string, unknown>;
@@ -374,6 +795,9 @@ export type ChannelRouteTarget = {
374
795
  } | {
375
796
  type: "pool";
376
797
  id: string;
798
+ } | {
799
+ type: "policy";
800
+ id: string;
377
801
  };
378
802
  export type ChannelBindingMode = "exclusive" | "broadcast";
379
803
  export interface ChannelBinding {
@@ -424,6 +848,20 @@ export interface ChannelSummary {
424
848
  lastSeen: number;
425
849
  meta?: Record<string, unknown>;
426
850
  }
851
+ export interface ChannelEventInput {
852
+ body?: string;
853
+ payload: Record<string, unknown>;
854
+ attachments?: ChannelAttachmentRef[];
855
+ conversationId?: string;
856
+ idempotencyKey?: string;
857
+ instanceId?: string;
858
+ epoch?: number;
859
+ }
860
+ export interface ChannelEventResult {
861
+ messages: Message[];
862
+ bindings: ChannelBinding[];
863
+ created: boolean;
864
+ }
427
865
  export interface TaskStatusInput {
428
866
  status: TaskStatus;
429
867
  agentId?: string;
@@ -453,6 +891,26 @@ export interface InboxState {
453
891
  threads: InboxThreadState[];
454
892
  drafts: InboxDraft[];
455
893
  }
894
+ export interface ChatHistoryImportEntry {
895
+ position: number;
896
+ originalMessageId: number;
897
+ originalFrom: string;
898
+ originalTo: string;
899
+ originalCreatedAt: number;
900
+ message: Message;
901
+ }
902
+ export interface ChatHistoryImport {
903
+ id: string;
904
+ targetAgentId?: string;
905
+ targetSpawnRequestId?: string;
906
+ sourcePeerId: string;
907
+ sourceAgentId?: string;
908
+ sourceThreadId?: string;
909
+ sourceAgentLabel?: string;
910
+ importedBy: string;
911
+ importedAt: number;
912
+ entries: ChatHistoryImportEntry[];
913
+ }
456
914
  export type ActivityKind = "message" | "reply" | "question" | "operator" | "pair" | "task" | "state";
457
915
  export interface ActivityEvent {
458
916
  id: number;
@@ -491,15 +949,215 @@ export interface ActivityEventInput {
491
949
  export type OrchestratorStatus = "online" | "offline";
492
950
  export type SpawnProvider = "claude" | "codex";
493
951
  export type SpawnApprovalMode = "open" | "guarded" | "read-only";
952
+ export type SpawnEffort = "low" | "medium" | "high" | "xhigh" | "max";
953
+ export type WorkspaceMode = "isolated" | "shared" | "inherit";
954
+ export type WorkspaceStatus = "active" | "ready" | "conflict" | "review_requested" | "merge_planned" | "abandoned" | "cleanup_requested" | "cleaned";
955
+ export interface WorkspaceProbeWorktree {
956
+ path: string;
957
+ branch?: string;
958
+ headSha?: string;
959
+ bare?: boolean;
960
+ detached?: boolean;
961
+ prunable?: boolean;
962
+ locked?: boolean;
963
+ reason?: string;
964
+ }
965
+ export interface WorkspaceProbe {
966
+ path: string;
967
+ isGitRepo: boolean;
968
+ repoRoot?: string;
969
+ branch?: string;
970
+ headSha?: string;
971
+ dirty?: boolean;
972
+ detached?: boolean;
973
+ worktrees?: WorkspaceProbeWorktree[];
974
+ error?: string;
975
+ }
976
+ export interface WorkspaceMetadata {
977
+ id?: string;
978
+ mode: WorkspaceMode;
979
+ requestedMode?: WorkspaceMode;
980
+ repoRoot?: string;
981
+ sourceCwd?: string;
982
+ worktreePath?: string;
983
+ branch?: string;
984
+ baseRef?: string;
985
+ baseSha?: string;
986
+ status?: WorkspaceStatus;
987
+ stewardAgentId?: string;
988
+ probe?: WorkspaceProbe;
989
+ }
990
+ export interface WorkspaceRecord {
991
+ id: string;
992
+ repoRoot: string;
993
+ sourceCwd: string;
994
+ worktreePath: string;
995
+ branch?: string;
996
+ baseRef?: string;
997
+ baseSha?: string;
998
+ mode: WorkspaceMode;
999
+ requestedMode?: WorkspaceMode;
1000
+ status: WorkspaceStatus;
1001
+ ownerAgentId?: string;
1002
+ ownerPolicyName?: string;
1003
+ ownerAutomationRunId?: string;
1004
+ stewardAgentId?: string;
1005
+ metadata: Record<string, unknown>;
1006
+ createdAt: number;
1007
+ updatedAt: number;
1008
+ readyAt?: number;
1009
+ cleanedAt?: number;
1010
+ }
1011
+ export interface ConfigEntry<T = unknown> {
1012
+ namespace: string;
1013
+ key: string;
1014
+ value: T;
1015
+ version: number;
1016
+ updatedAt: string;
1017
+ updatedBy?: string;
1018
+ }
1019
+ export interface ConfigHistoryEntry<T = unknown> {
1020
+ id: number;
1021
+ namespace: string;
1022
+ key: string;
1023
+ value: T;
1024
+ version: number;
1025
+ changedAt: string;
1026
+ changedBy?: string;
1027
+ }
1028
+ export type ManagedAgentStatus = "stopped" | "starting" | "running" | "stopping" | "backoff";
1029
+ export interface ManagedAgentState {
1030
+ policyName: string;
1031
+ status: ManagedAgentStatus;
1032
+ agentId?: string;
1033
+ orchestratorId: string;
1034
+ provider: SpawnProvider;
1035
+ tmuxSession?: string;
1036
+ spawnRequestId?: string;
1037
+ workspaceId?: string;
1038
+ workspacePath?: string;
1039
+ workspaceBranch?: string;
1040
+ lastSpawnAt?: number;
1041
+ lastStopAt?: number;
1042
+ healthySince?: number;
1043
+ restartCount: number;
1044
+ consecutiveFailures: number;
1045
+ backoffUntil?: number;
1046
+ lastError?: string;
1047
+ updatedAt: number;
1048
+ }
1049
+ export type SpawnPolicyMode = "always-on" | "on-demand";
1050
+ export type AgentProfileProvider = SpawnProvider | "any";
1051
+ export type AgentProfileBase = "host" | "minimal" | "isolated";
1052
+ export type AgentProfileInstructionPolicy = "allow" | "ignore";
1053
+ export type AgentProfileCategoryMode = "host" | "profile" | "repo" | "none";
1054
+ export type AgentProfileFilesystemScope = "repo" | "workspace" | "host";
1055
+ export interface AgentProfileAssetRef {
1056
+ source: "relay" | "repo" | "inline" | "provider";
1057
+ ref: string;
1058
+ enabled: boolean;
1059
+ provider?: AgentProfileProvider;
1060
+ meta?: Record<string, unknown>;
1061
+ }
1062
+ export interface AgentProfile {
1063
+ name: string;
1064
+ description?: string;
1065
+ provider?: AgentProfileProvider;
1066
+ base: AgentProfileBase;
1067
+ builtIn?: boolean;
1068
+ instructions: {
1069
+ system?: string;
1070
+ append: string[];
1071
+ repoInstructions: AgentProfileInstructionPolicy;
1072
+ globalInstructions: AgentProfileInstructionPolicy;
1073
+ };
1074
+ relay: {
1075
+ context: boolean;
1076
+ skills: boolean;
1077
+ plugins: boolean;
1078
+ statusLine: boolean;
1079
+ };
1080
+ skills: AgentProfileAssetRef[];
1081
+ plugins: AgentProfileAssetRef[];
1082
+ mcp: {
1083
+ mode: AgentProfileCategoryMode;
1084
+ servers?: Record<string, unknown>;
1085
+ };
1086
+ hooks: {
1087
+ mode: AgentProfileCategoryMode;
1088
+ };
1089
+ permissions: {
1090
+ mode?: SpawnApprovalMode;
1091
+ filesystem: AgentProfileFilesystemScope;
1092
+ };
1093
+ env: Record<string, string>;
1094
+ providerOptions: Record<string, unknown>;
1095
+ }
1096
+ export type AgentProfileProjectionResult = "applied" | "partial" | "unsupported" | "not-applicable";
1097
+ export interface AgentProfileProjectionEntry {
1098
+ capability: string;
1099
+ requested: string;
1100
+ result: AgentProfileProjectionResult;
1101
+ detail: string;
1102
+ }
1103
+ export interface AgentProfileProjectionReport {
1104
+ profileName: string;
1105
+ provider: SpawnProvider;
1106
+ base: AgentProfileBase;
1107
+ generatedAt: number;
1108
+ entries: AgentProfileProjectionEntry[];
1109
+ warnings: string[];
1110
+ unsupported: string[];
1111
+ }
1112
+ export interface SpawnPolicy {
1113
+ name: string;
1114
+ description?: string;
1115
+ enabled?: boolean;
1116
+ orchestratorId: string;
1117
+ cwd: string;
1118
+ provider: SpawnProvider;
1119
+ workspaceMode?: WorkspaceMode;
1120
+ rig?: string;
1121
+ model?: string;
1122
+ effort?: SpawnEffort;
1123
+ profile?: string;
1124
+ providerArgs: string[];
1125
+ prompt?: string;
1126
+ tags: string[];
1127
+ capabilities: string[];
1128
+ label?: string;
1129
+ mode: SpawnPolicyMode;
1130
+ permissionMode: SpawnApprovalMode;
1131
+ restartOnUpdate: boolean;
1132
+ scheduledDailyRestart: boolean;
1133
+ onDemand?: {
1134
+ keepaliveSeconds: number;
1135
+ idleDefinition: "no-activity";
1136
+ };
1137
+ backoff: {
1138
+ schedule: number[];
1139
+ resetAfterSeconds: number;
1140
+ };
1141
+ binding?: {
1142
+ type: "channel";
1143
+ channelId: string;
1144
+ };
1145
+ }
494
1146
  export interface Orchestrator {
495
1147
  id: string;
496
1148
  hostname: string;
497
1149
  status: OrchestratorStatus;
498
1150
  agentId: string;
499
1151
  providers: SpawnProvider[];
1152
+ providerStatus?: ProviderStatusReport[];
1153
+ providerCatalog?: ProviderCatalogSummary[];
500
1154
  baseDir: string;
501
1155
  apiUrl?: string;
502
1156
  envKeys: string[];
1157
+ package?: RuntimePackageMetadata;
1158
+ contracts?: RuntimeContracts;
1159
+ capabilities?: RuntimeCapabilities;
1160
+ contractCompatibility?: ContractCompatibility;
503
1161
  version?: string;
504
1162
  protocolVersion?: number;
505
1163
  gitSha?: string;
@@ -510,51 +1168,205 @@ export interface Orchestrator {
510
1168
  createdAt: number;
511
1169
  }
512
1170
  export interface OrchestratorHealth {
513
- status: "ok" | "warn" | "error";
1171
+ status: "ok" | "warn" | "restart-required" | "upgrade-required" | "unknown";
514
1172
  restartRequired: boolean;
1173
+ upgradeRequired?: boolean;
515
1174
  issues: Array<{
516
- code: "missing-version" | "outdated" | "protocol-mismatch" | "restart-required";
1175
+ code: "missing-version" | "package-drift" | "missing-contract" | "protocol-mismatch" | "restart-required" | "upgrade-required";
517
1176
  detail: string;
518
1177
  }>;
519
1178
  }
520
1179
  export interface ManagedAgent {
521
1180
  agentId: string;
522
1181
  provider: SpawnProvider;
1182
+ model?: string;
1183
+ effort?: SpawnEffort;
1184
+ profile?: string;
1185
+ workspaceMode?: WorkspaceMode;
1186
+ workspace?: WorkspaceMetadata;
1187
+ sessionName?: string;
1188
+ supervisor?: "process" | "systemd" | "unknown";
1189
+ systemdUnit?: string;
1190
+ terminalSession?: string;
1191
+ terminalAvailable?: boolean;
523
1192
  tmuxSession: string;
524
1193
  cwd: string;
525
1194
  label?: string;
526
1195
  approvalMode: SpawnApprovalMode;
1196
+ policyName?: string;
1197
+ spawnRequestId?: string;
1198
+ automationRunId?: string;
527
1199
  pid?: number;
528
1200
  startedAt: number;
529
1201
  }
1202
+ export interface ManagedSessionExitDiagnostics {
1203
+ agentId: string;
1204
+ provider: SpawnProvider;
1205
+ workspaceMode?: WorkspaceMode;
1206
+ workspace?: WorkspaceMetadata;
1207
+ sessionName?: string;
1208
+ tmuxSession: string;
1209
+ cwd: string;
1210
+ label?: string;
1211
+ policyName?: string;
1212
+ spawnRequestId?: string;
1213
+ automationRunId?: string;
1214
+ supervisor: "process" | "systemd" | "unknown";
1215
+ systemdUnit?: string;
1216
+ terminalSession?: string;
1217
+ terminalAvailable?: boolean;
1218
+ pid?: number;
1219
+ currentPid?: number;
1220
+ startedAt: number;
1221
+ detectedAt: number;
1222
+ runtimeMs: number;
1223
+ logFile?: string;
1224
+ logBytes?: number;
1225
+ logEmpty?: boolean;
1226
+ logTail?: string[];
1227
+ runnerInfoFile?: string;
1228
+ runnerInfoPresent?: boolean;
1229
+ systemd?: {
1230
+ unit: string;
1231
+ activeState?: string;
1232
+ subState?: string;
1233
+ result?: string;
1234
+ execMainCode?: string;
1235
+ execMainStatus?: string;
1236
+ mainPid?: number;
1237
+ unavailable?: string;
1238
+ };
1239
+ unavailable?: string[];
1240
+ lastError: string;
1241
+ }
530
1242
  export interface RegisterOrchestratorInput {
531
1243
  id: string;
532
1244
  hostname: string;
533
1245
  providers: SpawnProvider[];
1246
+ providerStatus?: ProviderStatusReport[];
1247
+ providerCatalog?: ProviderCatalogSummary[];
534
1248
  baseDir: string;
535
1249
  apiUrl?: string;
536
1250
  envKeys?: string[];
1251
+ package?: RuntimePackageMetadata;
1252
+ contracts?: RuntimeContracts;
1253
+ capabilities?: RuntimeCapabilities;
537
1254
  version?: string;
538
1255
  protocolVersion?: number;
539
1256
  gitSha?: string;
540
1257
  meta?: Record<string, unknown>;
541
1258
  }
542
1259
  export interface OrchestratorRuntimeInput {
1260
+ package?: RuntimePackageMetadata;
1261
+ contracts?: RuntimeContracts;
1262
+ capabilities?: RuntimeCapabilities;
543
1263
  version?: string;
544
1264
  protocolVersion?: number;
545
1265
  gitSha?: string;
1266
+ providers?: SpawnProvider[];
1267
+ providerStatus?: ProviderStatusReport[];
1268
+ providerCatalog?: ProviderCatalogSummary[];
546
1269
  }
547
1270
  export interface OrchestratorSpawnInput {
548
1271
  provider: SpawnProvider;
1272
+ model?: string;
1273
+ effort?: SpawnEffort;
549
1274
  cwd?: string;
1275
+ workspaceMode?: WorkspaceMode;
550
1276
  label?: string;
551
1277
  approvalMode?: SpawnApprovalMode;
552
1278
  prompt?: string;
1279
+ systemPromptAppend?: string;
553
1280
  env?: Record<string, string>;
554
1281
  }
1282
+ export interface ProviderStatusReport {
1283
+ name: SpawnProvider;
1284
+ available: boolean;
1285
+ checkedAt: number;
1286
+ reason?: string;
1287
+ version?: string;
1288
+ features?: Record<string, boolean>;
1289
+ cli?: {
1290
+ command: string;
1291
+ path?: string;
1292
+ ok: boolean;
1293
+ version?: string;
1294
+ error?: string;
1295
+ };
1296
+ runner?: {
1297
+ command: string;
1298
+ path?: string;
1299
+ ok: boolean;
1300
+ version?: string;
1301
+ error?: string;
1302
+ };
1303
+ }
1304
+ export interface ProviderCatalogSummary {
1305
+ provider: SpawnProvider;
1306
+ label: string;
1307
+ defaultModel?: string;
1308
+ models: Array<{
1309
+ alias: string;
1310
+ label: string;
1311
+ providerModel: string;
1312
+ efforts: SpawnEffort[];
1313
+ defaultEffort?: SpawnEffort;
1314
+ limits?: {
1315
+ contextWindowTokens?: {
1316
+ value: number;
1317
+ source: "catalog" | "provider" | "runtime" | "override";
1318
+ confidence: "declared" | "verified" | "estimated" | "unknown";
1319
+ lastUpdatedAt?: number;
1320
+ };
1321
+ maxOutputTokens?: {
1322
+ value: number;
1323
+ source: "catalog" | "provider" | "runtime" | "override";
1324
+ confidence: "declared" | "verified" | "estimated" | "unknown";
1325
+ lastUpdatedAt?: number;
1326
+ };
1327
+ };
1328
+ capabilities?: {
1329
+ modalities: {
1330
+ input: {
1331
+ text: boolean;
1332
+ image?: boolean;
1333
+ audio?: boolean;
1334
+ video?: boolean;
1335
+ pdf?: boolean;
1336
+ };
1337
+ output: {
1338
+ text: boolean;
1339
+ image?: boolean;
1340
+ audio?: boolean;
1341
+ video?: boolean;
1342
+ };
1343
+ };
1344
+ tools?: {
1345
+ code?: boolean;
1346
+ review?: boolean;
1347
+ debug?: boolean;
1348
+ refactor?: boolean;
1349
+ shell?: boolean;
1350
+ fileRead?: boolean;
1351
+ fileWrite?: boolean;
1352
+ webSearch?: boolean;
1353
+ imageGeneration?: boolean;
1354
+ imageEditing?: boolean;
1355
+ };
1356
+ source: "catalog" | "provider" | "runtime" | "override";
1357
+ confidence: "declared" | "verified" | "estimated" | "unknown";
1358
+ lastUpdatedAt?: number;
1359
+ };
1360
+ }>;
1361
+ }
555
1362
  export interface OrchestratorSpawnResult {
556
1363
  orchestratorId: string;
557
1364
  provider: SpawnProvider;
1365
+ sessionName?: string;
1366
+ supervisor?: "process" | "systemd" | "unknown";
1367
+ systemdUnit?: string;
1368
+ terminalSession?: string;
1369
+ terminalAvailable?: boolean;
558
1370
  tmuxSession: string;
559
1371
  cwd: string;
560
1372
  label?: string;
@@ -578,9 +1390,11 @@ export interface RecipeAgent {
578
1390
  capabilities: string[];
579
1391
  label?: string;
580
1392
  tags?: string[];
1393
+ memoryTags?: string[];
581
1394
  approvalMode?: "open" | "guarded" | "read-only";
582
1395
  prompt?: string;
583
1396
  model?: string;
1397
+ effort?: SpawnEffort;
584
1398
  env?: Record<string, string>;
585
1399
  }
586
1400
  export interface RecipeWorkflow {
@@ -596,6 +1410,19 @@ export interface RecipeRoute {
596
1410
  export interface RecipeLifecycle {
597
1411
  mode?: "persistent" | "ephemeral";
598
1412
  idleTimeoutMs?: number;
1413
+ memory?: RecipeMemoryPolicy;
1414
+ }
1415
+ export interface RecipeMemoryPolicy {
1416
+ injectOnAssign?: boolean;
1417
+ autoCapture?: boolean;
1418
+ captureTypes?: MemoryType[];
1419
+ memoryTags?: string[];
1420
+ alwaysReload?: string[];
1421
+ scope?: string;
1422
+ maxTokens?: number;
1423
+ maxMemories?: number;
1424
+ priorityCutoff?: 1 | 2 | 3;
1425
+ ttlMs?: number;
599
1426
  }
600
1427
  export interface RecipeInstance {
601
1428
  id: string;
@@ -605,6 +1432,7 @@ export interface RecipeInstance {
605
1432
  orchestratorId: string;
606
1433
  status: "starting" | "running" | "stopping" | "stopped" | "failed";
607
1434
  agents: RecipeAgentInstance[];
1435
+ artifacts?: Artifact[];
608
1436
  startedAt: number;
609
1437
  stoppedAt?: number;
610
1438
  startedBy: string;
@@ -621,16 +1449,105 @@ export interface ComponentToken {
621
1449
  sub: string;
622
1450
  role: "provider" | "channel" | "orchestrator" | "admin" | "dashboard" | string;
623
1451
  scope: string[];
1452
+ constraints?: TokenConstraints;
624
1453
  iat: number;
625
1454
  exp?: number;
626
1455
  jti?: string;
627
1456
  }
628
- export type TokenScope = "agent:read" | "agent:write" | "message:send" | "message:read" | "command:spawn" | "command:shutdown" | "command:*" | "task:read" | "task:write" | "recipe:start" | "recipe:stop" | "admin:*";
1457
+ export interface TokenRecord {
1458
+ jti: string;
1459
+ sub: string;
1460
+ role: string;
1461
+ scope: string[];
1462
+ constraints?: TokenConstraints;
1463
+ profileId?: string;
1464
+ issuedAt: number;
1465
+ expiresAt?: number;
1466
+ revokedAt?: number;
1467
+ createdBy?: string;
1468
+ }
1469
+ export interface TokenProfile {
1470
+ id: string;
1471
+ name: string;
1472
+ description?: string;
1473
+ role: string;
1474
+ scope: string[];
1475
+ constraints?: TokenConstraints;
1476
+ ttlSeconds?: number;
1477
+ builtIn: boolean;
1478
+ createdAt: number;
1479
+ updatedAt: number;
1480
+ createdBy?: string;
1481
+ }
1482
+ export interface CreateTokenProfileInput {
1483
+ id?: string;
1484
+ name: string;
1485
+ description?: string;
1486
+ role: string;
1487
+ scope: string[];
1488
+ constraints?: TokenConstraints;
1489
+ ttlSeconds?: number;
1490
+ createdBy?: string;
1491
+ }
1492
+ export type UpdateTokenProfileInput = Partial<Omit<CreateTokenProfileInput, "id">>;
1493
+ export interface TokenConstraints {
1494
+ agents?: string[];
1495
+ policies?: string[];
1496
+ parentAgents?: string[];
1497
+ targets?: string[];
1498
+ channels?: string[];
1499
+ orchestrators?: string[];
1500
+ hosts?: string[];
1501
+ cwd?: string;
1502
+ cwdPrefixes?: string[];
1503
+ taskIds?: string[];
1504
+ memoryScopes?: string[];
1505
+ integrationNames?: string[];
1506
+ spawnRequestIds?: string[];
1507
+ terminalAttach?: boolean;
1508
+ logsRead?: boolean;
1509
+ canDelegate?: boolean;
1510
+ }
1511
+ export type TokenScope = "system:admin" | "token:read" | "token:write" | "agent:read" | "agent:write" | "message:read" | "message:send" | "task:read" | "task:write" | "command:read" | "command:write" | "command:*" | "artifact:read" | "artifact:write" | "artifact:admin" | "memory:read" | "memory:write" | "memory:admin" | "mcp:use" | "terminal:attach" | "logs:read" | "integration:read" | "integration:write" | "channel:read" | "channel:write" | "stats:read" | "health:read" | "events:read" | "command:spawn" | "command:shutdown" | "recipe:start" | "recipe:stop" | "admin:*";
1512
+ export interface MaintenanceJob {
1513
+ id: string;
1514
+ title: string;
1515
+ description?: string;
1516
+ intervalMs: number;
1517
+ timeoutMs: number;
1518
+ enabled: boolean;
1519
+ runOnStart: boolean;
1520
+ lastRunAt?: number;
1521
+ nextRunAt?: number;
1522
+ lastDurationMs?: number;
1523
+ lastStatus: "idle" | "running" | "succeeded" | "failed" | "disabled";
1524
+ lastError?: string;
1525
+ lastResult?: Record<string, unknown>;
1526
+ consecutiveFailures: number;
1527
+ running: boolean;
1528
+ leaseUntil?: number;
1529
+ updatedAt: number;
1530
+ }
1531
+ export interface MaintenanceJobRun {
1532
+ id: string;
1533
+ status: "succeeded" | "failed" | "skipped";
1534
+ startedAt: number;
1535
+ finishedAt: number;
1536
+ durationMs: number;
1537
+ result?: Record<string, unknown>;
1538
+ error?: string;
1539
+ }
629
1540
  export interface HealthCheck {
630
1541
  name: string;
631
1542
  status: "ok" | "warn" | "error";
632
1543
  detail?: string;
633
1544
  count?: number;
1545
+ subjects?: Array<{
1546
+ id: string;
1547
+ label?: string;
1548
+ status?: string;
1549
+ detail?: string;
1550
+ }>;
634
1551
  }
635
1552
  export interface HealthReport {
636
1553
  status: "ok" | "degraded" | "error";