agent-relay-sdk 0.2.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.
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;
@@ -373,6 +795,9 @@ export type ChannelRouteTarget = {
373
795
  } | {
374
796
  type: "pool";
375
797
  id: string;
798
+ } | {
799
+ type: "policy";
800
+ id: string;
376
801
  };
377
802
  export type ChannelBindingMode = "exclusive" | "broadcast";
378
803
  export interface ChannelBinding {
@@ -423,6 +848,20 @@ export interface ChannelSummary {
423
848
  lastSeen: number;
424
849
  meta?: Record<string, unknown>;
425
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
+ }
426
865
  export interface TaskStatusInput {
427
866
  status: TaskStatus;
428
867
  agentId?: string;
@@ -452,6 +891,26 @@ export interface InboxState {
452
891
  threads: InboxThreadState[];
453
892
  drafts: InboxDraft[];
454
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
+ }
455
914
  export type ActivityKind = "message" | "reply" | "question" | "operator" | "pair" | "task" | "state";
456
915
  export interface ActivityEvent {
457
916
  id: number;
@@ -490,15 +949,215 @@ export interface ActivityEventInput {
490
949
  export type OrchestratorStatus = "online" | "offline";
491
950
  export type SpawnProvider = "claude" | "codex";
492
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
+ }
493
1146
  export interface Orchestrator {
494
1147
  id: string;
495
1148
  hostname: string;
496
1149
  status: OrchestratorStatus;
497
1150
  agentId: string;
498
1151
  providers: SpawnProvider[];
1152
+ providerStatus?: ProviderStatusReport[];
1153
+ providerCatalog?: ProviderCatalogSummary[];
499
1154
  baseDir: string;
500
1155
  apiUrl?: string;
501
1156
  envKeys: string[];
1157
+ package?: RuntimePackageMetadata;
1158
+ contracts?: RuntimeContracts;
1159
+ capabilities?: RuntimeCapabilities;
1160
+ contractCompatibility?: ContractCompatibility;
502
1161
  version?: string;
503
1162
  protocolVersion?: number;
504
1163
  gitSha?: string;
@@ -509,51 +1168,205 @@ export interface Orchestrator {
509
1168
  createdAt: number;
510
1169
  }
511
1170
  export interface OrchestratorHealth {
512
- status: "ok" | "warn" | "error";
1171
+ status: "ok" | "warn" | "restart-required" | "upgrade-required" | "unknown";
513
1172
  restartRequired: boolean;
1173
+ upgradeRequired?: boolean;
514
1174
  issues: Array<{
515
- code: "missing-version" | "outdated" | "protocol-mismatch" | "restart-required";
1175
+ code: "missing-version" | "package-drift" | "missing-contract" | "protocol-mismatch" | "restart-required" | "upgrade-required";
516
1176
  detail: string;
517
1177
  }>;
518
1178
  }
519
1179
  export interface ManagedAgent {
520
1180
  agentId: string;
521
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;
522
1192
  tmuxSession: string;
523
1193
  cwd: string;
524
1194
  label?: string;
525
1195
  approvalMode: SpawnApprovalMode;
1196
+ policyName?: string;
1197
+ spawnRequestId?: string;
1198
+ automationRunId?: string;
526
1199
  pid?: number;
527
1200
  startedAt: number;
528
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
+ }
529
1242
  export interface RegisterOrchestratorInput {
530
1243
  id: string;
531
1244
  hostname: string;
532
1245
  providers: SpawnProvider[];
1246
+ providerStatus?: ProviderStatusReport[];
1247
+ providerCatalog?: ProviderCatalogSummary[];
533
1248
  baseDir: string;
534
1249
  apiUrl?: string;
535
1250
  envKeys?: string[];
1251
+ package?: RuntimePackageMetadata;
1252
+ contracts?: RuntimeContracts;
1253
+ capabilities?: RuntimeCapabilities;
536
1254
  version?: string;
537
1255
  protocolVersion?: number;
538
1256
  gitSha?: string;
539
1257
  meta?: Record<string, unknown>;
540
1258
  }
541
1259
  export interface OrchestratorRuntimeInput {
1260
+ package?: RuntimePackageMetadata;
1261
+ contracts?: RuntimeContracts;
1262
+ capabilities?: RuntimeCapabilities;
542
1263
  version?: string;
543
1264
  protocolVersion?: number;
544
1265
  gitSha?: string;
1266
+ providers?: SpawnProvider[];
1267
+ providerStatus?: ProviderStatusReport[];
1268
+ providerCatalog?: ProviderCatalogSummary[];
545
1269
  }
546
1270
  export interface OrchestratorSpawnInput {
547
1271
  provider: SpawnProvider;
1272
+ model?: string;
1273
+ effort?: SpawnEffort;
548
1274
  cwd?: string;
1275
+ workspaceMode?: WorkspaceMode;
549
1276
  label?: string;
550
1277
  approvalMode?: SpawnApprovalMode;
551
1278
  prompt?: string;
1279
+ systemPromptAppend?: string;
552
1280
  env?: Record<string, string>;
553
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
+ }
554
1362
  export interface OrchestratorSpawnResult {
555
1363
  orchestratorId: string;
556
1364
  provider: SpawnProvider;
1365
+ sessionName?: string;
1366
+ supervisor?: "process" | "systemd" | "unknown";
1367
+ systemdUnit?: string;
1368
+ terminalSession?: string;
1369
+ terminalAvailable?: boolean;
557
1370
  tmuxSession: string;
558
1371
  cwd: string;
559
1372
  label?: string;
@@ -577,9 +1390,11 @@ export interface RecipeAgent {
577
1390
  capabilities: string[];
578
1391
  label?: string;
579
1392
  tags?: string[];
1393
+ memoryTags?: string[];
580
1394
  approvalMode?: "open" | "guarded" | "read-only";
581
1395
  prompt?: string;
582
1396
  model?: string;
1397
+ effort?: SpawnEffort;
583
1398
  env?: Record<string, string>;
584
1399
  }
585
1400
  export interface RecipeWorkflow {
@@ -595,6 +1410,19 @@ export interface RecipeRoute {
595
1410
  export interface RecipeLifecycle {
596
1411
  mode?: "persistent" | "ephemeral";
597
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;
598
1426
  }
599
1427
  export interface RecipeInstance {
600
1428
  id: string;
@@ -604,6 +1432,7 @@ export interface RecipeInstance {
604
1432
  orchestratorId: string;
605
1433
  status: "starting" | "running" | "stopping" | "stopped" | "failed";
606
1434
  agents: RecipeAgentInstance[];
1435
+ artifacts?: Artifact[];
607
1436
  startedAt: number;
608
1437
  stoppedAt?: number;
609
1438
  startedBy: string;
@@ -620,16 +1449,105 @@ export interface ComponentToken {
620
1449
  sub: string;
621
1450
  role: "provider" | "channel" | "orchestrator" | "admin" | "dashboard" | string;
622
1451
  scope: string[];
1452
+ constraints?: TokenConstraints;
623
1453
  iat: number;
624
1454
  exp?: number;
625
1455
  jti?: string;
626
1456
  }
627
- 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
+ }
628
1540
  export interface HealthCheck {
629
1541
  name: string;
630
1542
  status: "ok" | "warn" | "error";
631
1543
  detail?: string;
632
1544
  count?: number;
1545
+ subjects?: Array<{
1546
+ id: string;
1547
+ label?: string;
1548
+ status?: string;
1549
+ detail?: string;
1550
+ }>;
633
1551
  }
634
1552
  export interface HealthReport {
635
1553
  status: "ok" | "degraded" | "error";