@agentuity/coder 1.0.59 → 2.0.0-beta.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/src/protocol.ts CHANGED
@@ -94,13 +94,7 @@ export interface HubConfig {
94
94
 
95
95
  export interface InitMessage {
96
96
  type: 'init';
97
- role: 'lead' | 'sub_agent' | 'controller';
98
97
  sessionId?: string;
99
- resume?: {
100
- sessionFile: string;
101
- piSessionId?: string;
102
- cwd?: string;
103
- };
104
98
  tools?: HubToolDefinition[];
105
99
  commands?: HubCommandDefinition[];
106
100
  agents?: AgentDefinition[];
@@ -111,7 +105,6 @@ export interface InitMessage {
111
105
  };
112
106
  thinkingLevel?: string;
113
107
  task?: string;
114
- agentRole?: string;
115
108
  }
116
109
 
117
110
  export interface EventRequest {
@@ -166,15 +159,10 @@ export interface PingMessage {
166
159
  timestamp: number;
167
160
  }
168
161
 
169
- export interface BootstrapReadyMessage {
170
- type: 'bootstrap_ready';
171
- }
172
-
173
162
  export type HubClientMessage =
174
163
  | HubRequest
175
164
  | SessionEntryMessage
176
165
  | SessionWriteMessage
177
- | BootstrapReadyMessage
178
166
  | RpcCommandMessage
179
167
  | RpcUiResponseMessage
180
168
  | PingMessage;
@@ -207,14 +195,6 @@ export interface ConnectionRejectedMessage {
207
195
  timestamp: number;
208
196
  }
209
197
 
210
- export interface ProtocolErrorMessage {
211
- type: 'protocol_error';
212
- code: string;
213
- message: string;
214
- sessionId?: string;
215
- timestamp: number;
216
- }
217
-
218
198
  export interface ConversationEntry {
219
199
  type:
220
200
  | 'message'
@@ -222,9 +202,6 @@ export interface ConversationEntry {
222
202
  | 'tool_call'
223
203
  | 'tool_result'
224
204
  | 'task_result'
225
- | 'runtime_status'
226
- | 'runtime_output'
227
- | 'runtime_preview'
228
205
  | 'turn'
229
206
  | 'user_prompt';
230
207
  agent?: string;
@@ -233,29 +210,6 @@ export interface ConversationEntry {
233
210
  toolName?: string;
234
211
  toolArgs?: Record<string, unknown>;
235
212
  toolCallId?: string;
236
- runtime?:
237
- | {
238
- id?: string;
239
- command?: string;
240
- status?: string;
241
- stream?: string;
242
- exitCode?: number;
243
- }
244
- | undefined;
245
- preview?:
246
- | {
247
- id?: string;
248
- url?: string;
249
- status?: string;
250
- label?: string;
251
- }
252
- | undefined;
253
- attachments?: Array<{
254
- id?: string;
255
- filename?: string;
256
- mime?: string;
257
- size?: number;
258
- }>;
259
213
  isError?: boolean;
260
214
  taskId?: string;
261
215
  turnId?: string;
@@ -265,28 +219,16 @@ export interface ConversationEntry {
265
219
  timestamp: number;
266
220
  }
267
221
 
268
- export interface SessionTaskState {
222
+ export interface HydrationTaskState {
269
223
  taskId: string;
270
224
  agent: string;
271
225
  status: 'running' | 'completed' | 'failed';
272
226
  prompt: string;
273
- startedAt?: string;
274
- completedAt?: string;
275
227
  duration?: number;
276
228
  result?: string;
277
229
  error?: string;
278
230
  }
279
231
 
280
- export type HydrationTaskState = SessionTaskState;
281
-
282
- export interface SessionTaskProjection<TTaskState = SessionTaskState> {
283
- tasks: TTaskState[];
284
- }
285
-
286
- export interface SessionStreamWorkExtension {
287
- stream?: SessionStreamProjection;
288
- }
289
-
290
232
  export interface SessionParticipant {
291
233
  id: string;
292
234
  role: 'lead' | 'observer' | 'controller';
@@ -305,252 +247,59 @@ export interface SessionStreamProjection extends SessionStreamBlock {
305
247
  tasks: Record<string, SessionStreamBlock>;
306
248
  }
307
249
 
308
- export type WorkflowMode = 'standard' | 'loop';
309
- export type LoopStatus =
310
- | 'idle'
311
- | 'starting'
312
- | 'running'
313
- | 'paused'
314
- | 'awaiting_input'
315
- | 'blocked'
316
- | 'completed'
317
- | 'failed'
318
- | 'cancelled';
319
-
320
- export interface SessionLoopState {
321
- workflowMode: WorkflowMode;
322
- loopId?: string;
323
- status: LoopStatus;
324
- goal?: string;
325
- summary?: string;
326
- nextAction?: string;
327
- blockers: string[];
328
- iteration: number;
329
- maxIterations: number;
330
- autoContinue: boolean;
331
- allowDetached: boolean;
332
- recoveryAttempts: number;
333
- awaitingUser: boolean;
334
- activePrdKey?: string;
335
- activePrdTaskId?: string;
336
- coordinationJobId?: string;
337
- currentWaveId?: string;
338
- currentWaveLabel?: string;
339
- lastCheckpointSummary?: string;
340
- startedAt?: number;
341
- updatedAt?: number;
342
- lastCheckpointAt?: number;
343
- completedAt?: number;
344
- lastError?: string;
345
- }
346
-
347
- export type SessionBucket = 'running' | 'paused' | 'provisioning' | 'history';
348
-
349
- export interface SessionSkillRef {
350
- skillId: string;
351
- repo: string;
352
- name?: string;
353
- url?: string;
354
- }
355
-
356
- export interface SessionListDiagnostics {
357
- inactiveRunningTasks: Array<{
358
- taskId: string;
359
- agent: string;
360
- inactivityMs: number;
361
- startedAt: string;
362
- lastActivityAt?: string;
363
- }>;
364
- }
365
-
366
- export interface SessionListItem {
250
+ export interface SessionSnapshot {
367
251
  sessionId: string;
368
252
  label: string;
369
- status: string;
370
- mode: 'sandbox' | 'tui';
371
- sessionKind?: string;
372
- parentSessionId?: string;
373
- coordinationJobId?: string;
374
- workflowMode: WorkflowMode;
375
- loopStatus?: SessionLoopState['status'];
376
- loopIteration?: number;
377
- createdAt: string;
378
- taskCount: number;
379
- subAgentCount: number;
380
- observerCount: number;
381
- participantCount: number;
382
- tags: string[];
383
- skills: SessionSkillRef[];
384
- defaultAgent?: string;
385
- bucket: SessionBucket;
386
- runtimeAvailable: boolean;
387
- controlAvailable: boolean;
388
- historyOnly: boolean;
389
- diagnostics?: SessionListDiagnostics;
390
- }
391
-
392
- export interface SandboxSessionListItem {
393
- sessionId: string;
394
- sandboxId: string;
395
- status: string;
396
- task?: string;
397
- metadata?: Record<string, unknown>;
398
- wsConnected: boolean;
399
- }
400
-
401
- export interface SessionListResponse {
402
- sessions: {
403
- websocket: SessionListItem[];
404
- sandbox: SandboxSessionListItem[];
405
- };
406
- total: number;
407
- }
408
-
409
- export interface SessionDetailParticipant {
410
- id: string;
411
- role: string;
412
- transport: string;
413
- connectedAt: string;
414
- idle?: boolean;
415
- }
416
-
417
- export interface SessionAgentActivity {
418
- name?: string;
419
- status: string;
420
- currentTool?: string;
421
- currentToolArgs?: string;
422
- toolCallCount: number;
423
- lastActivity: number;
424
- totalElapsed?: number;
425
- }
426
-
427
- export interface SessionObservedProjection {
428
- turnCount: number;
429
- lastAgentModel?: string;
430
- compactionCount: number;
431
- }
432
-
433
- export interface SessionDeckGenerationState {
434
- state: string;
435
- requestedAt?: number;
436
- startedAt?: number;
437
- completedAt?: number;
438
- title?: string;
439
- deckType?: string;
440
- prdKey?: string;
441
- prdTaskId?: string;
442
- todoId?: string;
443
- error?: string;
444
- url?: string;
445
- }
446
-
447
- export interface SessionProductProjection {
448
- activePrdKey?: string;
449
- activePrdTaskId?: string;
450
- deckGeneration?: SessionDeckGenerationState;
451
- }
452
-
453
- export interface SessionActivityWorkExtensions {
454
- agentActivity?: Record<string, SessionAgentActivity>;
455
- diagnostics?: SessionListDiagnostics;
456
- }
457
-
458
- export interface SessionWorkProjection<TTaskState = SessionTaskState>
459
- extends SessionTaskProjection<TTaskState>,
460
- SessionStreamWorkExtension,
461
- SessionActivityWorkExtensions {
462
- workflowMode: WorkflowMode;
463
- }
464
-
465
- export interface SessionWorkflowProjection {
466
- workflowMode: WorkflowMode;
467
- loop?: SessionLoopState;
468
- }
469
-
470
- export interface SessionLoopResponse extends Omit<SessionWorkflowProjection, 'loop'> {
471
- sessionId: string;
472
- loop: SessionLoopState | null;
473
- }
474
-
475
- export interface SessionUsageAgentSummary {
476
- inputTokens: number;
477
- outputTokens: number;
478
- reasoningTokens: number;
479
- costUsd: number;
480
- updatedAt: number;
481
- }
482
-
483
- export interface SessionUsageSummary {
484
- inputTokens: number;
485
- outputTokens: number;
486
- reasoningTokens: number;
487
- costUsd: number;
488
- updatedAt: number;
489
- byAgent?: Record<string, SessionUsageAgentSummary>;
490
- }
491
-
492
- export interface SessionSnapshotCore extends SessionTaskProjection {
493
- sessionId: string;
494
- label: string;
495
- status: string;
253
+ status: 'active' | 'paused' | 'shutdown' | 'archived' | 'error' | 'stopped';
496
254
  createdAt: string;
497
255
  mode: 'sandbox' | 'tui';
498
- workflowMode: WorkflowMode;
499
- participants: SessionDetailParticipant[];
500
256
  task?: string;
501
257
  error?: string;
502
- bucket: SessionBucket;
503
- runtimeAvailable: boolean;
504
- controlAvailable: boolean;
505
- historyOnly: boolean;
506
- }
507
-
508
- export interface SessionSnapshotHistoryExtensions {
509
- streamId: string | null;
510
- streamUrl: string | null;
511
- }
512
-
513
- export interface SessionSnapshotWorkExtensions
514
- extends SessionStreamWorkExtension,
515
- SessionActivityWorkExtensions {
516
- agentActivity: Record<string, SessionAgentActivity>;
517
- usage: SessionUsageSummary;
518
- }
519
-
520
- export interface SessionSnapshotWorkflowExtensions
521
- extends Pick<SessionWorkflowProjection, 'loop'> {}
522
-
523
- export interface SessionSnapshotMetadataExtensions {
258
+ streamId?: string | null;
259
+ streamUrl?: string | null;
524
260
  context: {
525
261
  branch?: string;
526
262
  workingDirectory?: string;
527
263
  };
528
- observed?: SessionObservedProjection;
529
- product?: SessionProductProjection;
530
- tags: string[];
531
- skills: SessionSkillRef[];
264
+ participants: SessionParticipant[];
265
+ tasks: Array<{
266
+ taskId: string;
267
+ agent: string;
268
+ status: 'running' | 'completed' | 'failed';
269
+ prompt: string;
270
+ duration?: number;
271
+ startedAt?: string;
272
+ completedAt?: string;
273
+ }>;
274
+ agentActivity: Record<
275
+ string,
276
+ {
277
+ name?: string;
278
+ status: string;
279
+ currentTool?: string;
280
+ currentToolArgs?: string;
281
+ toolCallCount: number;
282
+ lastActivity: number;
283
+ totalElapsed?: number;
284
+ }
285
+ >;
286
+ stream?: SessionStreamProjection;
287
+ tags?: string[];
532
288
  defaultAgent?: string;
533
- workers?: SessionListItem[];
289
+ bucket?: 'running' | 'paused' | 'provisioning' | 'history';
290
+ runtimeAvailable?: boolean;
291
+ controlAvailable?: boolean;
292
+ historyOnly?: boolean;
534
293
  }
535
294
 
536
- export interface SessionSnapshotExtensions
537
- extends SessionSnapshotHistoryExtensions,
538
- SessionSnapshotWorkExtensions,
539
- SessionSnapshotWorkflowExtensions,
540
- SessionSnapshotMetadataExtensions {}
541
-
542
- export interface SessionSnapshot extends SessionSnapshotCore, SessionSnapshotExtensions {}
543
-
544
- export interface CoderHubHydrationMessage
545
- extends SessionTaskProjection<HydrationTaskState>,
546
- SessionStreamWorkExtension {
295
+ export interface CoderHubHydrationMessage {
547
296
  type: 'session_hydration';
548
297
  sessionId: string;
549
- label?: string;
550
298
  resumedAt: number;
551
299
  entries: ConversationEntry[];
300
+ tasks: HydrationTaskState[];
301
+ stream?: SessionStreamProjection;
552
302
  task?: string;
553
- leadConnected?: boolean;
554
303
  streamingState?: {
555
304
  isStreaming?: boolean;
556
305
  activeTasks?: Array<{
@@ -578,133 +327,6 @@ export interface BroadcastEventMessage {
578
327
  timestamp?: number;
579
328
  }
580
329
 
581
- export type ReplayEntry = ConversationEntry;
582
-
583
- export interface ReplayHistoryResponse {
584
- sessionId: string;
585
- entriesSource: 'durable_stream' | 'session_entries' | 'event_history' | 'none';
586
- sourceCounts?: {
587
- durableStream: number;
588
- sessionEntries: number;
589
- eventHistory: number;
590
- };
591
- entries: ReplayEntry[];
592
- }
593
-
594
- export interface SessionEventHistoryItem {
595
- id: number;
596
- event: string;
597
- category: string;
598
- agent?: string;
599
- taskId?: string;
600
- payload: Record<string, unknown>;
601
- occurredAt: string;
602
- ingestedAt: string;
603
- }
604
-
605
- export interface SessionEventHistoryResponse {
606
- sessionId: string;
607
- events: SessionEventHistoryItem[];
608
- }
609
-
610
- export interface SessionParticipantHistoryItem {
611
- id: string;
612
- role: string;
613
- transport: string;
614
- agentRole?: string;
615
- connectedAt: string;
616
- disconnectedAt?: string;
617
- lastActivityAt: string;
618
- metadata?: Record<string, unknown>;
619
- }
620
-
621
- export interface SessionParticipantsResponse {
622
- sessionId: string;
623
- participants: SessionParticipantHistoryItem[];
624
- }
625
-
626
- export interface SessionTodoSummary {
627
- open: number;
628
- in_progress: number;
629
- done: number;
630
- closed: number;
631
- cancelled: number;
632
- }
633
-
634
- export interface SessionTodoAssignee {
635
- id: string;
636
- name: string;
637
- type?: string;
638
- }
639
-
640
- export interface SessionTodoItem {
641
- id: string;
642
- title: string;
643
- status: 'open' | 'in_progress' | 'done' | 'closed' | 'cancelled';
644
- type?: string | null;
645
- priority?: string | null;
646
- parentTaskId?: string | null;
647
- prdKey?: string | null;
648
- externalRef?: string | null;
649
- taskKey?: string | null;
650
- origin?: string | null;
651
- kind?: string | null;
652
- assignee?: SessionTodoAssignee | null;
653
- lastSessionId?: string | null;
654
- sessionIds: string[];
655
- tags: string[];
656
- memoryKeys: string[];
657
- memoryIds: string[];
658
- touchedByAgents: string[];
659
- lastTouchedByAgent?: string | null;
660
- attachments: Array<Record<string, unknown>>;
661
- attachmentCount: number;
662
- createdAt: string;
663
- updatedAt: string;
664
- }
665
-
666
- export interface SessionTodoListResponse {
667
- sessionId: string;
668
- ok: boolean;
669
- op: 'session_todo_list';
670
- count: number;
671
- summary: SessionTodoSummary;
672
- todos: SessionTodoItem[];
673
- unavailable?: boolean;
674
- message?: string;
675
- }
676
-
677
- export type SseSessionSnapshotParticipant = SessionDetailParticipant;
678
-
679
- export interface SseHydrationTaskState {
680
- taskId: string;
681
- agent: string;
682
- status: SessionTaskState['status'];
683
- prompt: string;
684
- }
685
-
686
- export interface SseSessionSnapshotMessage {
687
- type: 'snapshot';
688
- sessionId: string;
689
- label: string;
690
- status: string;
691
- createdAt: string;
692
- mode: 'sandbox' | 'tui';
693
- participants: SseSessionSnapshotParticipant[];
694
- taskCount: number;
695
- agentActivity: Record<string, SessionAgentActivity>;
696
- stream?: SessionStreamProjection;
697
- }
698
-
699
- export interface SseHydrationMessage
700
- extends SessionTaskProjection<SseHydrationTaskState>,
701
- SessionStreamWorkExtension {
702
- type: 'hydration';
703
- sessionId: string;
704
- entries: ConversationEntry[];
705
- task?: string;
706
- }
707
-
708
330
  export interface RpcEventMessage {
709
331
  type: 'rpc_event';
710
332
  event: Record<string, unknown>;
@@ -730,9 +352,6 @@ export type ServerMessage =
730
352
  | CoderHubStreamReadyMessage
731
353
  | CoderHubSessionResumeMessage
732
354
  | ConnectionRejectedMessage
733
- | ProtocolErrorMessage
734
- | SseSessionSnapshotMessage
735
- | SseHydrationMessage
736
355
  | PresenceEventMessage
737
356
  | BroadcastEventMessage
738
357
  | RpcEventMessage
@@ -265,6 +265,11 @@ export class RemoteSession {
265
265
 
266
266
  this.ws.onopen = () => {
267
267
  log('WebSocket connected');
268
+ try {
269
+ this.ws?.send(JSON.stringify({ type: 'controller_ready' }));
270
+ } catch {
271
+ // Let the normal init timeout surface if bootstrap cannot start.
272
+ }
268
273
  };
269
274
 
270
275
  this.ws.onmessage = (event: MessageEvent) => {
@@ -287,17 +292,11 @@ export class RemoteSession {
287
292
  this.connected = true;
288
293
  this.reconnectAttempts = 0;
289
294
  if (data.sessionId) this.sessionId = data.sessionId as string;
290
- if (typeof data.label === 'string') this.label = data.label;
291
295
  this.applyLifecycle({
292
296
  type: 'init',
293
297
  sessionId: typeof data.sessionId === 'string' ? data.sessionId : undefined,
294
298
  label: typeof data.label === 'string' ? data.label : undefined,
295
299
  });
296
- try {
297
- this.ws?.send(JSON.stringify({ type: 'bootstrap_ready' }));
298
- } catch {
299
- // Let the close/error path surface bootstrap failure.
300
- }
301
300
  log(`Connected to session ${this.sessionId}`);
302
301
  this.notifyConnectionChange('connected');
303
302
  resolve();
@@ -317,25 +316,6 @@ export class RemoteSession {
317
316
  return;
318
317
  }
319
318
 
320
- if (type === 'protocol_error') {
321
- clearTimeout(connectTimeout);
322
- const msg = (data.message as string) || 'Hub protocol error';
323
- this.applyLifecycle({
324
- type: 'rpc_command_error',
325
- error: msg,
326
- paused: false,
327
- });
328
- this.dispatchEvent({
329
- type: 'protocol_error',
330
- ...data,
331
- _source: 'hub',
332
- } as RpcEvent);
333
- if (!this.connected) {
334
- reject(new Error(msg));
335
- }
336
- return;
337
- }
338
-
339
319
  if (type === 'session_resume') {
340
320
  this.applyLifecycle({
341
321
  type: 'session_resume',
@@ -425,7 +405,7 @@ export class RemoteSession {
425
405
  return;
426
406
  }
427
407
 
428
- // Legacy/raw RPC messages tolerated but not expected on the controller path.
408
+ // Raw RPC messages (from Durable Stream replay historical, not live)
429
409
  if (type === 'rpc_event') {
430
410
  const rpcEvent = data.event as RpcEvent;
431
411
  if (rpcEvent) {