agent-relay-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bus-client.d.ts +82 -0
- package/dist/bus-client.d.ts.map +1 -0
- package/dist/bus-client.js +277 -0
- package/dist/bus-client.js.map +1 -0
- package/dist/http-client.d.ts +49 -0
- package/dist/http-client.d.ts.map +1 -0
- package/dist/http-client.js +143 -0
- package/dist/http-client.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +128 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +143 -0
- package/dist/protocol.js.map +1 -0
- package/dist/provider-base.d.ts +47 -0
- package/dist/provider-base.d.ts.map +1 -0
- package/dist/provider-base.js +66 -0
- package/dist/provider-base.js.map +1 -0
- package/dist/reconnect.d.ts +17 -0
- package/dist/reconnect.d.ts.map +1 -0
- package/dist/reconnect.js +47 -0
- package/dist/reconnect.js.map +1 -0
- package/dist/types.d.ts +642 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
- package/src/bus-client.ts +337 -0
- package/src/http-client.ts +158 -0
- package/src/index.ts +6 -0
- package/src/protocol.ts +286 -0
- package/src/provider-base.ts +101 -0
- package/src/reconnect.ts +62 -0
- package/src/types.ts +740 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
export type AgentKind = "provider" | "channel" | "orchestrator" | "system" | "user";
|
|
2
|
+
|
|
3
|
+
export interface AgentCard {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
kind: AgentKind;
|
|
7
|
+
label?: string; // human-friendly alias; acts as a fan-out target ("label:foo")
|
|
8
|
+
tags: string[];
|
|
9
|
+
machine?: string;
|
|
10
|
+
rig?: string;
|
|
11
|
+
capabilities: string[];
|
|
12
|
+
ready: boolean;
|
|
13
|
+
status: AgentStatus;
|
|
14
|
+
instanceId?: string;
|
|
15
|
+
epoch: number;
|
|
16
|
+
meta?: Record<string, unknown>;
|
|
17
|
+
lastSeen: number;
|
|
18
|
+
createdAt: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type AgentStatus = "online" | "idle" | "busy" | "stale" | "offline";
|
|
22
|
+
|
|
23
|
+
export type MessageKind =
|
|
24
|
+
| "chat"
|
|
25
|
+
| "channel.event"
|
|
26
|
+
| "task"
|
|
27
|
+
| "pair"
|
|
28
|
+
| "control"
|
|
29
|
+
| "system";
|
|
30
|
+
|
|
31
|
+
export interface Message {
|
|
32
|
+
id: number;
|
|
33
|
+
from: string;
|
|
34
|
+
to: string; // agent-id | "tag:<name>" | "broadcast" | "cap:<name>"
|
|
35
|
+
kind: MessageKind;
|
|
36
|
+
channel?: string;
|
|
37
|
+
subject?: string;
|
|
38
|
+
body: string;
|
|
39
|
+
threadId?: number;
|
|
40
|
+
replyTo?: number;
|
|
41
|
+
claimable?: boolean;
|
|
42
|
+
claimedBy?: string;
|
|
43
|
+
claimedAt?: number;
|
|
44
|
+
claimExpiresAt?: number;
|
|
45
|
+
idempotencyKey?: string;
|
|
46
|
+
payload: Record<string, unknown>;
|
|
47
|
+
meta?: Record<string, unknown>;
|
|
48
|
+
readBy: string[];
|
|
49
|
+
createdAt: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface SendMessageInput {
|
|
53
|
+
from: string;
|
|
54
|
+
to: string;
|
|
55
|
+
kind?: MessageKind;
|
|
56
|
+
channel?: string;
|
|
57
|
+
subject?: string;
|
|
58
|
+
body: string;
|
|
59
|
+
replyTo?: number;
|
|
60
|
+
claimable?: boolean;
|
|
61
|
+
idempotencyKey?: string;
|
|
62
|
+
payload?: Record<string, unknown>;
|
|
63
|
+
meta?: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type ConnectorKind = "channel" | "event" | "provider" | "orchestrator";
|
|
67
|
+
export type ConnectorAction = "install" | "uninstall" | "enable" | "disable" | "start" | "stop" | "restart" | "status" | "doctor";
|
|
68
|
+
|
|
69
|
+
export interface ConnectorManifest {
|
|
70
|
+
schema: "agent-relay.connector.v1";
|
|
71
|
+
id: string;
|
|
72
|
+
kind: ConnectorKind;
|
|
73
|
+
packageName?: string;
|
|
74
|
+
binary: string;
|
|
75
|
+
displayName: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
version: string;
|
|
78
|
+
capabilities: string[];
|
|
79
|
+
commands: Partial<Record<ConnectorAction, string[]>>;
|
|
80
|
+
configSchema?: Record<string, unknown>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface ConnectorRuntime {
|
|
84
|
+
installed: boolean;
|
|
85
|
+
enabled?: boolean;
|
|
86
|
+
running?: boolean;
|
|
87
|
+
status?: "ok" | "warn" | "error" | "unknown";
|
|
88
|
+
detail?: string;
|
|
89
|
+
updatedAt?: string;
|
|
90
|
+
raw?: unknown;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface ConnectorSummary {
|
|
94
|
+
id: string;
|
|
95
|
+
kind: ConnectorKind;
|
|
96
|
+
displayName: string;
|
|
97
|
+
description?: string;
|
|
98
|
+
version: string;
|
|
99
|
+
packageName?: string;
|
|
100
|
+
binary: string;
|
|
101
|
+
capabilities: string[];
|
|
102
|
+
registryPath: string;
|
|
103
|
+
manifest: ConnectorManifest;
|
|
104
|
+
config?: Record<string, unknown>;
|
|
105
|
+
state?: Record<string, unknown>;
|
|
106
|
+
runtime: ConnectorRuntime;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface ConnectorActionResult {
|
|
110
|
+
connectorId: string;
|
|
111
|
+
action: ConnectorAction;
|
|
112
|
+
command?: string[];
|
|
113
|
+
ok: boolean;
|
|
114
|
+
exitCode?: number | null;
|
|
115
|
+
stdout?: string;
|
|
116
|
+
stderr?: string;
|
|
117
|
+
parsed?: unknown;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export type PairStatus = "pending" | "active" | "ended" | "rejected" | "expired";
|
|
121
|
+
|
|
122
|
+
export interface PairSession {
|
|
123
|
+
id: string;
|
|
124
|
+
requesterId: string;
|
|
125
|
+
targetId: string;
|
|
126
|
+
status: PairStatus;
|
|
127
|
+
objective?: string;
|
|
128
|
+
createdAt: number;
|
|
129
|
+
updatedAt: number;
|
|
130
|
+
expiresAt: number;
|
|
131
|
+
acceptedAt?: number;
|
|
132
|
+
endedAt?: number;
|
|
133
|
+
endedBy?: string;
|
|
134
|
+
lastMessageAt?: number;
|
|
135
|
+
meta: Record<string, unknown>;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface CreatePairInput {
|
|
139
|
+
from: string;
|
|
140
|
+
target: string;
|
|
141
|
+
objective?: string;
|
|
142
|
+
ttlMs?: number;
|
|
143
|
+
meta?: Record<string, unknown>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface PairActionInput {
|
|
147
|
+
agentId: string;
|
|
148
|
+
reason?: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface PairMessageInput {
|
|
152
|
+
from: string;
|
|
153
|
+
body: string;
|
|
154
|
+
subject?: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface PollQuery {
|
|
158
|
+
for: string; // agent-id
|
|
159
|
+
since?: number; // unix ms (createdAt cursor)
|
|
160
|
+
sinceId?: number; // monotonic message id cursor (preferred — avoids same-ms collisions)
|
|
161
|
+
unread?: boolean;
|
|
162
|
+
channel?: string;
|
|
163
|
+
limit?: number;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface RegisterAgentInput {
|
|
167
|
+
id: string;
|
|
168
|
+
name: string;
|
|
169
|
+
kind?: AgentKind;
|
|
170
|
+
label?: string | null;
|
|
171
|
+
tags?: string[];
|
|
172
|
+
machine?: string;
|
|
173
|
+
rig?: string;
|
|
174
|
+
capabilities?: string[];
|
|
175
|
+
ready?: boolean;
|
|
176
|
+
status?: AgentCard["status"];
|
|
177
|
+
instanceId?: string;
|
|
178
|
+
meta?: Record<string, unknown>;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface AgentSessionGuard {
|
|
182
|
+
instanceId?: string;
|
|
183
|
+
epoch?: number;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export type TaskSeverity = "info" | "warning" | "critical";
|
|
187
|
+
export type TaskStatus =
|
|
188
|
+
| "open"
|
|
189
|
+
| "claimed"
|
|
190
|
+
| "in_progress"
|
|
191
|
+
| "blocked"
|
|
192
|
+
| "orphaned"
|
|
193
|
+
| "done"
|
|
194
|
+
| "failed"
|
|
195
|
+
| "canceled";
|
|
196
|
+
|
|
197
|
+
export type CommandStatus =
|
|
198
|
+
| "pending"
|
|
199
|
+
| "accepted"
|
|
200
|
+
| "running"
|
|
201
|
+
| "succeeded"
|
|
202
|
+
| "failed"
|
|
203
|
+
| "timed_out"
|
|
204
|
+
| "rejected"
|
|
205
|
+
| "canceled";
|
|
206
|
+
|
|
207
|
+
export interface Command {
|
|
208
|
+
id: string;
|
|
209
|
+
type: string;
|
|
210
|
+
source: string;
|
|
211
|
+
target: string;
|
|
212
|
+
params: Record<string, unknown>;
|
|
213
|
+
status: CommandStatus;
|
|
214
|
+
result?: Record<string, unknown>;
|
|
215
|
+
error?: string;
|
|
216
|
+
correlationId?: string;
|
|
217
|
+
createdAt: number;
|
|
218
|
+
updatedAt: number;
|
|
219
|
+
expiresAt?: number;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface CreateCommandInput {
|
|
223
|
+
type: string;
|
|
224
|
+
source: string;
|
|
225
|
+
target: string;
|
|
226
|
+
params?: Record<string, unknown>;
|
|
227
|
+
correlationId?: string;
|
|
228
|
+
ttlMs?: number;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface UpdateCommandInput {
|
|
232
|
+
status?: CommandStatus;
|
|
233
|
+
result?: Record<string, unknown>;
|
|
234
|
+
error?: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface Task {
|
|
238
|
+
id: number;
|
|
239
|
+
source: string;
|
|
240
|
+
title: string;
|
|
241
|
+
body: string;
|
|
242
|
+
severity: TaskSeverity;
|
|
243
|
+
status: TaskStatus;
|
|
244
|
+
target: string;
|
|
245
|
+
channel?: string;
|
|
246
|
+
dedupeKey?: string;
|
|
247
|
+
externalUrl?: string;
|
|
248
|
+
occurrenceCount: number;
|
|
249
|
+
claimedBy?: string;
|
|
250
|
+
claimedAt?: number;
|
|
251
|
+
claimExpiresAt?: number;
|
|
252
|
+
messageId?: number;
|
|
253
|
+
result?: string;
|
|
254
|
+
metadata: Record<string, unknown>;
|
|
255
|
+
createdAt: number;
|
|
256
|
+
updatedAt: number;
|
|
257
|
+
lastSeenAt: number;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export interface TaskEvent {
|
|
261
|
+
id: number;
|
|
262
|
+
taskId: number;
|
|
263
|
+
source: string;
|
|
264
|
+
type: string;
|
|
265
|
+
severity: TaskSeverity;
|
|
266
|
+
title: string;
|
|
267
|
+
body: string;
|
|
268
|
+
metadata: Record<string, unknown>;
|
|
269
|
+
createdAt: number;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface IntegrationEventInput {
|
|
273
|
+
source?: string;
|
|
274
|
+
type?: string;
|
|
275
|
+
severity?: TaskSeverity;
|
|
276
|
+
status?: TaskStatus | "resolved";
|
|
277
|
+
title: string;
|
|
278
|
+
body: string;
|
|
279
|
+
target: string;
|
|
280
|
+
channel?: string;
|
|
281
|
+
dedupeKey?: string;
|
|
282
|
+
externalUrl?: string;
|
|
283
|
+
metadata?: Record<string, unknown>;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export interface IntegrationTaskStats {
|
|
287
|
+
source: string;
|
|
288
|
+
tasks: number;
|
|
289
|
+
openTasks: number;
|
|
290
|
+
waitingTasks: number;
|
|
291
|
+
failedTasks: number;
|
|
292
|
+
lastSeenAt?: number;
|
|
293
|
+
lastUpdatedAt?: number;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export interface IntegrationSummary {
|
|
297
|
+
name: string;
|
|
298
|
+
configured: boolean;
|
|
299
|
+
observed: boolean;
|
|
300
|
+
scopes: string[];
|
|
301
|
+
targets: string[];
|
|
302
|
+
channels: string[];
|
|
303
|
+
callbackHost?: string;
|
|
304
|
+
callbackConfigured: boolean;
|
|
305
|
+
rateLimit: {
|
|
306
|
+
limitPerMinute: number;
|
|
307
|
+
currentWindowCount: number;
|
|
308
|
+
windowStartedAt?: number;
|
|
309
|
+
};
|
|
310
|
+
taskStats: IntegrationTaskStats;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export type AutomationKind = "scheduled_task";
|
|
314
|
+
export type AutomationCatchUpPolicy = "skip" | "run_once" | "run_all";
|
|
315
|
+
export type AutomationConcurrencyPolicy = "skip" | "queue" | "replace";
|
|
316
|
+
export type AutomationRunStatus =
|
|
317
|
+
| "scheduled"
|
|
318
|
+
| "dispatching"
|
|
319
|
+
| "waiting_agent"
|
|
320
|
+
| "running"
|
|
321
|
+
| "succeeded"
|
|
322
|
+
| "failed"
|
|
323
|
+
| "canceled"
|
|
324
|
+
| "timed_out";
|
|
325
|
+
|
|
326
|
+
export interface AutomationExistingAgentPolicy {
|
|
327
|
+
mode: "existing_agent";
|
|
328
|
+
selector: {
|
|
329
|
+
provider?: SpawnProvider;
|
|
330
|
+
label?: string;
|
|
331
|
+
tags?: string[];
|
|
332
|
+
capabilities?: string[];
|
|
333
|
+
};
|
|
334
|
+
ifNoMatch?: "fail" | "spawn";
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export interface AutomationOnDemandAgentPolicy {
|
|
338
|
+
mode: "on_demand_agent";
|
|
339
|
+
provider: SpawnProvider;
|
|
340
|
+
cwd?: string;
|
|
341
|
+
profile?: string;
|
|
342
|
+
approvalMode?: SpawnApprovalMode;
|
|
343
|
+
keepAlive?: boolean;
|
|
344
|
+
shutdownAfterMs?: number;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export type AutomationTargetPolicy = AutomationExistingAgentPolicy | AutomationOnDemandAgentPolicy;
|
|
348
|
+
|
|
349
|
+
export interface AutomationTaskTemplate {
|
|
350
|
+
title: string;
|
|
351
|
+
body: string;
|
|
352
|
+
severity?: TaskSeverity;
|
|
353
|
+
dedupeKey?: string;
|
|
354
|
+
externalUrl?: string;
|
|
355
|
+
metadata?: Record<string, unknown>;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export interface Automation {
|
|
359
|
+
id: string;
|
|
360
|
+
kind: AutomationKind;
|
|
361
|
+
name: string;
|
|
362
|
+
description?: string;
|
|
363
|
+
enabled: boolean;
|
|
364
|
+
schedule: string;
|
|
365
|
+
timezone: string;
|
|
366
|
+
nextRunAt?: number;
|
|
367
|
+
catchUpPolicy: AutomationCatchUpPolicy;
|
|
368
|
+
concurrencyPolicy: AutomationConcurrencyPolicy;
|
|
369
|
+
orchestratorId: string;
|
|
370
|
+
targetPolicy: AutomationTargetPolicy;
|
|
371
|
+
taskTemplate: AutomationTaskTemplate;
|
|
372
|
+
createdAt: number;
|
|
373
|
+
updatedAt: number;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export interface AutomationRun {
|
|
377
|
+
id: string;
|
|
378
|
+
automationId: string;
|
|
379
|
+
status: AutomationRunStatus;
|
|
380
|
+
scheduledFor: number;
|
|
381
|
+
startedAt?: number;
|
|
382
|
+
finishedAt?: number;
|
|
383
|
+
orchestratorId: string;
|
|
384
|
+
targetAgentId?: string;
|
|
385
|
+
spawnedAgentId?: string;
|
|
386
|
+
taskId?: number;
|
|
387
|
+
messageId?: number;
|
|
388
|
+
controlMessageId?: number;
|
|
389
|
+
error?: string;
|
|
390
|
+
result?: Record<string, unknown>;
|
|
391
|
+
meta: Record<string, unknown>;
|
|
392
|
+
createdAt: number;
|
|
393
|
+
updatedAt: number;
|
|
394
|
+
shutdownRequestedAt?: number;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export interface CreateAutomationInput {
|
|
398
|
+
kind?: AutomationKind;
|
|
399
|
+
name: string;
|
|
400
|
+
description?: string;
|
|
401
|
+
enabled?: boolean;
|
|
402
|
+
schedule: string;
|
|
403
|
+
timezone?: string;
|
|
404
|
+
catchUpPolicy?: AutomationCatchUpPolicy;
|
|
405
|
+
concurrencyPolicy?: AutomationConcurrencyPolicy;
|
|
406
|
+
orchestratorId: string;
|
|
407
|
+
targetPolicy: AutomationTargetPolicy;
|
|
408
|
+
taskTemplate: AutomationTaskTemplate;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export interface UpdateAutomationInput {
|
|
412
|
+
name?: string;
|
|
413
|
+
description?: string | null;
|
|
414
|
+
enabled?: boolean;
|
|
415
|
+
schedule?: string;
|
|
416
|
+
timezone?: string;
|
|
417
|
+
catchUpPolicy?: AutomationCatchUpPolicy;
|
|
418
|
+
concurrencyPolicy?: AutomationConcurrencyPolicy;
|
|
419
|
+
orchestratorId?: string;
|
|
420
|
+
targetPolicy?: AutomationTargetPolicy;
|
|
421
|
+
taskTemplate?: AutomationTaskTemplate;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export type ChannelDirection = "inbound" | "outbound" | "bidirectional";
|
|
425
|
+
|
|
426
|
+
export type ChannelRouteTarget =
|
|
427
|
+
| { type: "agent"; id: string }
|
|
428
|
+
| { type: "label"; id: string }
|
|
429
|
+
| { type: "tag"; id: string }
|
|
430
|
+
| { type: "capability"; id: string }
|
|
431
|
+
| { type: "broadcast" }
|
|
432
|
+
| { type: "orchestrator"; id: string }
|
|
433
|
+
| { type: "pool"; id: string };
|
|
434
|
+
|
|
435
|
+
export type ChannelBindingMode = "exclusive" | "broadcast";
|
|
436
|
+
|
|
437
|
+
export interface ChannelBinding {
|
|
438
|
+
id: string;
|
|
439
|
+
channelId: string;
|
|
440
|
+
conversationId?: string;
|
|
441
|
+
target: ChannelRouteTarget;
|
|
442
|
+
mode: ChannelBindingMode;
|
|
443
|
+
priority: number;
|
|
444
|
+
createdAt: number;
|
|
445
|
+
updatedAt: number;
|
|
446
|
+
poolSelector?: string;
|
|
447
|
+
poolAgentId?: string;
|
|
448
|
+
poolAgentEpoch?: number;
|
|
449
|
+
poolClaimExpiresAt?: number;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export interface ChannelTargetHealth {
|
|
453
|
+
status: "ok" | "warning" | "error";
|
|
454
|
+
detail: string;
|
|
455
|
+
target: ChannelRouteTarget;
|
|
456
|
+
matches: Array<{
|
|
457
|
+
id: string;
|
|
458
|
+
name: string;
|
|
459
|
+
status: AgentCard["status"];
|
|
460
|
+
ready: boolean;
|
|
461
|
+
lastSeen: number;
|
|
462
|
+
label?: string;
|
|
463
|
+
tags: string[];
|
|
464
|
+
capabilities: string[];
|
|
465
|
+
}>;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export interface ChannelSummary {
|
|
469
|
+
id: string;
|
|
470
|
+
name: string;
|
|
471
|
+
type: string;
|
|
472
|
+
transport: string;
|
|
473
|
+
agentId: string;
|
|
474
|
+
accountId: string;
|
|
475
|
+
status: AgentCard["status"];
|
|
476
|
+
ready: boolean;
|
|
477
|
+
direction: ChannelDirection;
|
|
478
|
+
target?: string;
|
|
479
|
+
binding?: ChannelBinding;
|
|
480
|
+
targetHealth?: ChannelTargetHealth;
|
|
481
|
+
topicChannels: string[];
|
|
482
|
+
capabilities: string[];
|
|
483
|
+
tags: string[];
|
|
484
|
+
lastSeen: number;
|
|
485
|
+
meta?: Record<string, unknown>;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export interface TaskStatusInput {
|
|
489
|
+
status: TaskStatus;
|
|
490
|
+
agentId?: string;
|
|
491
|
+
instanceId?: string;
|
|
492
|
+
epoch?: number;
|
|
493
|
+
result?: string;
|
|
494
|
+
body?: string;
|
|
495
|
+
metadata?: Record<string, unknown>;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export interface InboxThreadState {
|
|
499
|
+
operatorId: string;
|
|
500
|
+
peerId: string;
|
|
501
|
+
readCursorMessageId?: number;
|
|
502
|
+
archivedAtMessageId?: number;
|
|
503
|
+
updatedAt: number;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export interface InboxDraft {
|
|
507
|
+
operatorId: string;
|
|
508
|
+
peerId: string;
|
|
509
|
+
body: string;
|
|
510
|
+
subject?: string;
|
|
511
|
+
channel?: string;
|
|
512
|
+
updatedAt: number;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
export interface InboxState {
|
|
516
|
+
operatorId: string;
|
|
517
|
+
threads: InboxThreadState[];
|
|
518
|
+
drafts: InboxDraft[];
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export type ActivityKind = "message" | "reply" | "question" | "operator" | "pair" | "task" | "state";
|
|
522
|
+
|
|
523
|
+
export interface ActivityEvent {
|
|
524
|
+
id: number;
|
|
525
|
+
operatorId?: string;
|
|
526
|
+
clientId?: string;
|
|
527
|
+
kind: ActivityKind;
|
|
528
|
+
title: string;
|
|
529
|
+
body?: string;
|
|
530
|
+
meta?: string;
|
|
531
|
+
icon?: string;
|
|
532
|
+
view?: string;
|
|
533
|
+
peer?: string;
|
|
534
|
+
messageId?: number;
|
|
535
|
+
pairId?: string;
|
|
536
|
+
taskId?: number;
|
|
537
|
+
agentId?: string;
|
|
538
|
+
metadata: Record<string, unknown>;
|
|
539
|
+
createdAt: number;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
export interface ActivityEventInput {
|
|
543
|
+
operatorId?: string;
|
|
544
|
+
clientId?: string;
|
|
545
|
+
kind: ActivityKind;
|
|
546
|
+
title: string;
|
|
547
|
+
body?: string;
|
|
548
|
+
meta?: string;
|
|
549
|
+
icon?: string;
|
|
550
|
+
view?: string;
|
|
551
|
+
peer?: string;
|
|
552
|
+
messageId?: number;
|
|
553
|
+
pairId?: string;
|
|
554
|
+
taskId?: number;
|
|
555
|
+
agentId?: string;
|
|
556
|
+
metadata?: Record<string, unknown>;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// --- Orchestrators ---
|
|
560
|
+
|
|
561
|
+
export type OrchestratorStatus = "online" | "offline";
|
|
562
|
+
export type SpawnProvider = "claude" | "codex";
|
|
563
|
+
export type SpawnApprovalMode = "open" | "guarded" | "read-only";
|
|
564
|
+
|
|
565
|
+
export interface Orchestrator {
|
|
566
|
+
id: string;
|
|
567
|
+
hostname: string;
|
|
568
|
+
status: OrchestratorStatus;
|
|
569
|
+
agentId: string; // relay agent id for messaging
|
|
570
|
+
providers: SpawnProvider[];
|
|
571
|
+
baseDir: string;
|
|
572
|
+
apiUrl?: string;
|
|
573
|
+
envKeys: string[]; // names only, never values
|
|
574
|
+
version?: string;
|
|
575
|
+
protocolVersion?: number;
|
|
576
|
+
gitSha?: string;
|
|
577
|
+
health?: OrchestratorHealth;
|
|
578
|
+
meta: Record<string, unknown>;
|
|
579
|
+
managedAgents: ManagedAgent[];
|
|
580
|
+
lastSeen: number;
|
|
581
|
+
createdAt: number;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export interface OrchestratorHealth {
|
|
585
|
+
status: "ok" | "warn" | "error";
|
|
586
|
+
restartRequired: boolean;
|
|
587
|
+
issues: Array<{
|
|
588
|
+
code: "missing-version" | "outdated" | "protocol-mismatch" | "restart-required";
|
|
589
|
+
detail: string;
|
|
590
|
+
}>;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
export interface ManagedAgent {
|
|
594
|
+
agentId: string;
|
|
595
|
+
provider: SpawnProvider;
|
|
596
|
+
tmuxSession: string;
|
|
597
|
+
cwd: string;
|
|
598
|
+
label?: string;
|
|
599
|
+
approvalMode: SpawnApprovalMode;
|
|
600
|
+
pid?: number;
|
|
601
|
+
startedAt: number;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
export interface RegisterOrchestratorInput {
|
|
605
|
+
id: string;
|
|
606
|
+
hostname: string;
|
|
607
|
+
providers: SpawnProvider[];
|
|
608
|
+
baseDir: string;
|
|
609
|
+
apiUrl?: string;
|
|
610
|
+
envKeys?: string[];
|
|
611
|
+
version?: string;
|
|
612
|
+
protocolVersion?: number;
|
|
613
|
+
gitSha?: string;
|
|
614
|
+
meta?: Record<string, unknown>;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
export interface OrchestratorRuntimeInput {
|
|
618
|
+
version?: string;
|
|
619
|
+
protocolVersion?: number;
|
|
620
|
+
gitSha?: string;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
export interface OrchestratorSpawnInput {
|
|
624
|
+
provider: SpawnProvider;
|
|
625
|
+
cwd?: string;
|
|
626
|
+
label?: string;
|
|
627
|
+
approvalMode?: SpawnApprovalMode;
|
|
628
|
+
prompt?: string;
|
|
629
|
+
env?: Record<string, string>;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
export interface OrchestratorSpawnResult {
|
|
633
|
+
orchestratorId: string;
|
|
634
|
+
provider: SpawnProvider;
|
|
635
|
+
tmuxSession: string;
|
|
636
|
+
cwd: string;
|
|
637
|
+
label?: string;
|
|
638
|
+
approvalMode: SpawnApprovalMode;
|
|
639
|
+
pid?: number;
|
|
640
|
+
startedAt: number;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
export interface Recipe {
|
|
644
|
+
name: string;
|
|
645
|
+
description: string;
|
|
646
|
+
version?: string;
|
|
647
|
+
author?: string;
|
|
648
|
+
agents: RecipeAgent[];
|
|
649
|
+
workflow?: RecipeWorkflow;
|
|
650
|
+
lifecycle?: RecipeLifecycle;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
export interface RecipeAgent {
|
|
654
|
+
role: string;
|
|
655
|
+
provider: "claude" | "codex";
|
|
656
|
+
count?: number;
|
|
657
|
+
capabilities: string[];
|
|
658
|
+
label?: string;
|
|
659
|
+
tags?: string[];
|
|
660
|
+
approvalMode?: "open" | "guarded" | "read-only";
|
|
661
|
+
prompt?: string;
|
|
662
|
+
model?: string;
|
|
663
|
+
env?: Record<string, string>;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
export interface RecipeWorkflow {
|
|
667
|
+
trigger?: string;
|
|
668
|
+
fanOut?: "all" | "first";
|
|
669
|
+
collect?: string;
|
|
670
|
+
routing?: RecipeRoute[];
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
export interface RecipeRoute {
|
|
674
|
+
pattern: string;
|
|
675
|
+
pipeline: string[];
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
export interface RecipeLifecycle {
|
|
679
|
+
mode?: "persistent" | "ephemeral";
|
|
680
|
+
idleTimeoutMs?: number;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
export interface RecipeInstance {
|
|
684
|
+
id: string;
|
|
685
|
+
recipeName: string;
|
|
686
|
+
recipeSource: "builtin" | "user";
|
|
687
|
+
cwd: string;
|
|
688
|
+
orchestratorId: string;
|
|
689
|
+
status: "starting" | "running" | "stopping" | "stopped" | "failed";
|
|
690
|
+
agents: RecipeAgentInstance[];
|
|
691
|
+
startedAt: number;
|
|
692
|
+
stoppedAt?: number;
|
|
693
|
+
startedBy: string;
|
|
694
|
+
error?: string;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
export interface RecipeAgentInstance {
|
|
698
|
+
role: string;
|
|
699
|
+
agentId: string;
|
|
700
|
+
provider: string;
|
|
701
|
+
status: "spawning" | "running" | "stopping" | "stopped" | "failed";
|
|
702
|
+
index?: number;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
export interface ComponentToken {
|
|
706
|
+
sub: string;
|
|
707
|
+
role: "provider" | "channel" | "orchestrator" | "admin" | "dashboard" | string;
|
|
708
|
+
scope: string[];
|
|
709
|
+
iat: number;
|
|
710
|
+
exp?: number;
|
|
711
|
+
jti?: string;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
export type TokenScope =
|
|
715
|
+
| "agent:read"
|
|
716
|
+
| "agent:write"
|
|
717
|
+
| "message:send"
|
|
718
|
+
| "message:read"
|
|
719
|
+
| "command:spawn"
|
|
720
|
+
| "command:shutdown"
|
|
721
|
+
| "command:*"
|
|
722
|
+
| "task:read"
|
|
723
|
+
| "task:write"
|
|
724
|
+
| "recipe:start"
|
|
725
|
+
| "recipe:stop"
|
|
726
|
+
| "admin:*";
|
|
727
|
+
|
|
728
|
+
export interface HealthCheck {
|
|
729
|
+
name: string;
|
|
730
|
+
status: "ok" | "warn" | "error";
|
|
731
|
+
detail?: string;
|
|
732
|
+
count?: number;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
export interface HealthReport {
|
|
736
|
+
status: "ok" | "degraded" | "error";
|
|
737
|
+
version: string;
|
|
738
|
+
generatedAt: number;
|
|
739
|
+
checks: HealthCheck[];
|
|
740
|
+
}
|