orchestrator-client 5.6.0 → 5.7.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/index.js CHANGED
@@ -82,7 +82,10 @@ var OrchestratorAsync = class {
82
82
  constructor(opts = {}) {
83
83
  this._abortController = null;
84
84
  this._insecure = false;
85
- this._baseUrl = (opts.baseUrl ?? "http://localhost:8080").replace(/\/+$/, "");
85
+ this._baseUrl = (opts.baseUrl ?? "http://localhost:8080").replace(
86
+ /\/+$/,
87
+ ""
88
+ );
86
89
  this._apiKey = opts.apiKey;
87
90
  this._getToken = opts.getToken;
88
91
  this._timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
@@ -104,11 +107,11 @@ var OrchestratorAsync = class {
104
107
  async _resolveHeaders() {
105
108
  const headers = {};
106
109
  if (this._apiKey) {
107
- headers["Authorization"] = `Bearer ${this._apiKey}`;
110
+ headers.Authorization = `Bearer ${this._apiKey}`;
108
111
  } else if (this._getToken) {
109
112
  const token = await this._getToken();
110
113
  if (token) {
111
- headers["Authorization"] = `Bearer ${token}`;
114
+ headers.Authorization = `Bearer ${token}`;
112
115
  }
113
116
  }
114
117
  return headers;
@@ -256,34 +259,54 @@ var OrchestratorAsync = class {
256
259
  // Tasks
257
260
  // ------------------------------------------------------------------
258
261
  async listTasks(params) {
259
- const data = await this._get("/tasks", {
260
- workflow_id: params?.workflowId,
261
- status: params?.status,
262
- limit: params?.limit,
263
- offset: params?.offset,
264
- sort_by: params?.sortBy,
265
- sort_order: params?.sortOrder
262
+ const headers = {};
263
+ if (params?.locale) headers["X-Locale"] = params.locale;
264
+ const data = await this._request("GET", "/tasks", {
265
+ params: {
266
+ page: params?.page,
267
+ limit: params?.limit,
268
+ order_by: params?.orderBy,
269
+ order_direction: params?.orderDirection,
270
+ workflow_id: params?.workflowId
271
+ },
272
+ headers
266
273
  });
267
- const tasks = (data.tasks ?? []).map(buildTaskSummary);
274
+ const tasks = (data.tasks ?? []).map(
275
+ buildTaskSummary
276
+ );
268
277
  return { tasks, pagination: buildPagination(data) };
269
278
  }
270
279
  async createTask(params) {
271
- const data = await this._post("/tasks", {
280
+ const data = await this._post("/task/create", {
272
281
  workflow_id: params.workflowId,
273
282
  goal_prompt: params.goalPrompt,
274
283
  max_iterations: params.maxIterations,
275
- options: params.options,
284
+ reasoning_effort: params.reasoningEffort,
285
+ system_prompt: params.systemPrompt,
286
+ developer_prompt: params.developerPrompt,
276
287
  ticket_id: params.ticketId,
277
- title: params.title,
278
- model_id: params.modelId
288
+ ticket_text: params.ticketText,
289
+ summary: params.summary,
290
+ problem_summary: params.problemSummary,
291
+ solution_strategy: params.solutionStrategy,
292
+ agent_model_id: params.agentModelId,
293
+ orchestrator_model_id: params.orchestratorModelId,
294
+ available_tools: params.availableTools,
295
+ attachment_ids: params.attachmentIds,
296
+ options: params.options
279
297
  });
280
298
  return {
281
299
  taskId: data.taskId ?? data.task_id ?? "",
282
300
  status: data.status ?? ""
283
301
  };
284
302
  }
285
- async getTaskStatus(taskId) {
286
- const data = await this._get(`/tasks/${taskId}`);
303
+ async getTaskStatus(taskId, locale) {
304
+ const headers = {};
305
+ if (locale) headers["X-Locale"] = locale;
306
+ const data = await this._request("GET", "/task/status", {
307
+ params: { task_id: taskId },
308
+ headers
309
+ });
287
310
  return {
288
311
  ...buildTaskSummary(data),
289
312
  subtaskIds: data.subtaskIds ?? data.subtask_ids ?? [],
@@ -291,26 +314,45 @@ var OrchestratorAsync = class {
291
314
  options: data.options ?? null
292
315
  };
293
316
  }
294
- async getTaskConversation(taskId) {
295
- const data = await this._get(`/tasks/${taskId}/conversation`);
317
+ async setTaskStatus(taskId, status) {
318
+ const data = await this._post("/task/set_status", {
319
+ task_id: taskId,
320
+ status
321
+ });
322
+ return { message: data.message ?? "" };
323
+ }
324
+ async getTaskConversation(taskId, params) {
325
+ const headers = {};
326
+ if (params?.locale) headers["X-Locale"] = params.locale;
327
+ const data = await this._request("GET", "/task/conversation", {
328
+ params: {
329
+ task_id: taskId,
330
+ include_summaries: params?.includeSummaries,
331
+ exclude_archived: params?.excludeArchived
332
+ },
333
+ headers
334
+ });
296
335
  return {
297
336
  taskId: data.taskId ?? data.task_id ?? taskId,
298
- conversation: (data.conversation ?? []).map(
299
- (m) => m
300
- )
337
+ conversation: (data.conversation ?? []).map((m) => m)
301
338
  };
302
339
  }
303
340
  async getArchivedMessageContent(taskId, messageId) {
304
341
  return this._get(
305
- `/tasks/${taskId}/conversation/messages/${messageId}/archived`
342
+ "/task/message/archived-content",
343
+ { task_id: taskId, message_id: messageId }
306
344
  );
307
345
  }
308
346
  async getTaskCompactions(taskId) {
309
- const data = await this._get(`/tasks/${taskId}/compactions`);
347
+ const data = await this._get("/task/compactions", {
348
+ task_id: taskId
349
+ });
310
350
  return data.compactions ?? [];
311
351
  }
312
352
  async getTaskJournal(taskId) {
313
- const data = await this._get(`/tasks/${taskId}/journal`);
353
+ const data = await this._get("/task/journal", {
354
+ task_id: taskId
355
+ });
314
356
  return {
315
357
  taskId: data.taskId ?? data.task_id ?? taskId,
316
358
  exists: data.exists ?? false,
@@ -321,11 +363,22 @@ var OrchestratorAsync = class {
321
363
  };
322
364
  }
323
365
  async cancelTask(taskId) {
324
- const data = await this._post(`/tasks/${taskId}/cancel`);
325
- return { message: data.message ?? "" };
366
+ const data = await this._post("/task/cancel", {
367
+ task_id: taskId
368
+ });
369
+ return {
370
+ taskId: data.taskId ?? data.task_id ?? taskId,
371
+ killed: data.killed ?? false,
372
+ via: data.via ?? "none",
373
+ holderId: data.holderId ?? data.holder_id ?? void 0,
374
+ reason: data.reason ?? void 0,
375
+ message: data.message ?? ""
376
+ };
326
377
  }
327
378
  async deleteTask(taskId) {
328
- const data = await this._delete(`/tasks/${taskId}`);
379
+ const data = await this._post("/task/delete", {
380
+ task_id: taskId
381
+ });
329
382
  return {
330
383
  deletedTasks: data.deletedTasks ?? data.deleted_tasks ?? [],
331
384
  failedTasks: data.failedTasks ?? data.failed_tasks ?? [],
@@ -334,7 +387,10 @@ var OrchestratorAsync = class {
334
387
  };
335
388
  }
336
389
  async deleteTasks(taskIds) {
337
- const data = await this._post("/tasks/delete", { task_ids: taskIds });
390
+ const data = await this._post(
391
+ "/task/delete/multiple",
392
+ { task_ids: taskIds }
393
+ );
338
394
  return {
339
395
  deletedTasks: data.deletedTasks ?? data.deleted_tasks ?? [],
340
396
  failedTasks: data.failedTasks ?? data.failed_tasks ?? [],
@@ -345,11 +401,11 @@ var OrchestratorAsync = class {
345
401
  // ------------------------------------------------------------------
346
402
  // Attachments
347
403
  // ------------------------------------------------------------------
348
- async uploadAttachment(taskId, file, filename) {
404
+ async uploadAttachment(file, filename) {
349
405
  const formData = new FormData();
350
406
  formData.append("file", file, filename);
351
407
  const headers = await this._resolveHeaders();
352
- const response = await this._fetch(this._makeUrl(`/tasks/${taskId}/attachments`), {
408
+ const response = await this._fetch(this._makeUrl("/attachment"), {
353
409
  method: "POST",
354
410
  headers: { ...headers },
355
411
  body: formData
@@ -371,11 +427,12 @@ var OrchestratorAsync = class {
371
427
  tokenCount: data.tokenCount ?? data.token_count ?? null
372
428
  };
373
429
  }
374
- async downloadAttachment(taskId, attachmentId) {
430
+ async downloadAttachment(attachmentId) {
375
431
  const headers = await this._resolveHeaders();
376
- const response = await this._fetch(this._makeUrl(`/tasks/${taskId}/attachments/${attachmentId}`), {
377
- headers
378
- });
432
+ const response = await this._fetch(
433
+ this._makeUrl(`/attachment/${attachmentId}`),
434
+ { headers }
435
+ );
379
436
  if (!response.ok) {
380
437
  throw new OrchestratorAPIError(
381
438
  `Attachment download failed: ${response.statusText}`,
@@ -387,224 +444,363 @@ var OrchestratorAsync = class {
387
444
  // ------------------------------------------------------------------
388
445
  // Interactive workflow
389
446
  // ------------------------------------------------------------------
390
- async sendInteractiveMessage(taskId, content) {
391
- const data = await this._post(`/tasks/${taskId}/interactive/message`, {
392
- content
393
- });
447
+ async sendInteractiveMessage(taskId, message, attachmentIds) {
448
+ const data = await this._post(
449
+ "/task/interactive/message",
450
+ { task_id: taskId, message, attachment_ids: attachmentIds }
451
+ );
394
452
  return { message: data.message ?? "" };
395
453
  }
396
454
  async markInteractiveComplete(taskId) {
397
- const data = await this._post(`/tasks/${taskId}/interactive/complete`);
455
+ const data = await this._post(
456
+ "/task/interactive/mark_complete",
457
+ { task_id: taskId }
458
+ );
398
459
  return { message: data.message ?? "" };
399
460
  }
400
461
  async markInteractiveFailed(taskId) {
401
- const data = await this._post(`/tasks/${taskId}/interactive/failed`);
462
+ const data = await this._post(
463
+ "/task/interactive/mark_failed",
464
+ { task_id: taskId }
465
+ );
402
466
  return { message: data.message ?? "" };
403
467
  }
404
- async approveInteractiveAction(taskId) {
405
- const data = await this._post(`/tasks/${taskId}/interactive/approve`);
468
+ async approveInteractiveAction(taskId, approved = true) {
469
+ const data = await this._post(
470
+ "/task/interactive/action",
471
+ { task_id: taskId, approved }
472
+ );
473
+ return { message: data.message ?? "" };
474
+ }
475
+ async stopInteractive(taskId) {
476
+ const data = await this._post(
477
+ "/task/interactive/stop",
478
+ { task_id: taskId }
479
+ );
406
480
  return { message: data.message ?? "" };
407
481
  }
408
482
  // ------------------------------------------------------------------
409
483
  // Proactive workflow
410
484
  // ------------------------------------------------------------------
411
- async sendProactiveGuide(taskId, guide) {
412
- const data = await this._post(`/tasks/${taskId}/proactive/guide`, {
413
- guide
414
- });
485
+ async sendProactiveGuide(taskId, message, attachmentIds) {
486
+ const data = await this._post(
487
+ "/task/proactive/guide",
488
+ { task_id: taskId, message, attachment_ids: attachmentIds }
489
+ );
415
490
  return { message: data.message ?? "" };
416
491
  }
417
492
  async respondProactiveHelp(taskId, response) {
418
- const data = await this._post(`/tasks/${taskId}/proactive/respond`, {
419
- response
420
- });
493
+ const data = await this._post(
494
+ "/task/proactive/help",
495
+ { task_id: taskId, response }
496
+ );
421
497
  return { message: data.message ?? "" };
422
498
  }
423
- async approveProactiveAction(taskId) {
424
- const data = await this._post(`/tasks/${taskId}/proactive/approve`);
499
+ async approveProactiveAction(taskId, approved = true) {
500
+ const data = await this._post(
501
+ "/task/proactive/action",
502
+ { task_id: taskId, approved }
503
+ );
425
504
  return { message: data.message ?? "" };
426
505
  }
427
506
  // ------------------------------------------------------------------
428
507
  // Ticket workflow
429
508
  // ------------------------------------------------------------------
430
- async sendTicketGuide(taskId, guide) {
431
- const data = await this._post(`/tasks/${taskId}/ticket/guide`, {
432
- guide
433
- });
509
+ async sendTicketGuide(taskId, message, attachmentIds) {
510
+ const data = await this._post(
511
+ "/task/ticket/guide",
512
+ { task_id: taskId, message, attachment_ids: attachmentIds }
513
+ );
434
514
  return { message: data.message ?? "" };
435
515
  }
436
516
  async respondTicketHelp(taskId, response) {
437
- const data = await this._post(`/tasks/${taskId}/ticket/respond`, {
438
- response
439
- });
517
+ const data = await this._post(
518
+ "/task/ticket/help",
519
+ { task_id: taskId, response }
520
+ );
440
521
  return { message: data.message ?? "" };
441
522
  }
442
- async approveTicketAction(taskId) {
443
- const data = await this._post(`/tasks/${taskId}/ticket/approve`);
523
+ async approveTicketAction(taskId, approved = true) {
524
+ const data = await this._post(
525
+ "/task/ticket/action",
526
+ { task_id: taskId, approved }
527
+ );
444
528
  return { message: data.message ?? "" };
445
529
  }
446
530
  async wakeTicket(taskId) {
447
- const data = await this._post(`/tasks/${taskId}/ticket/wake`);
531
+ const data = await this._post(
532
+ "/task/ticket/wake",
533
+ { task_id: taskId }
534
+ );
448
535
  return { message: data.message ?? "" };
449
536
  }
450
537
  // ------------------------------------------------------------------
451
538
  // Matrix workflow
452
539
  // ------------------------------------------------------------------
453
- async sendMatrixMessage(taskId, content) {
454
- const data = await this._post(`/tasks/${taskId}/matrix/message`, {
455
- content
456
- });
540
+ async sendMatrixMessage(taskId, message, attachmentIds) {
541
+ const data = await this._post(
542
+ "/task/matrix/message",
543
+ { task_id: taskId, message, attachment_ids: attachmentIds }
544
+ );
457
545
  return { message: data.message ?? "" };
458
546
  }
459
547
  async markMatrixComplete(taskId) {
460
- const data = await this._post(`/tasks/${taskId}/matrix/complete`);
548
+ const data = await this._post(
549
+ "/task/matrix/mark_complete",
550
+ { task_id: taskId }
551
+ );
461
552
  return { message: data.message ?? "" };
462
553
  }
463
554
  async markMatrixFailed(taskId) {
464
- const data = await this._post(`/tasks/${taskId}/matrix/failed`);
555
+ const data = await this._post(
556
+ "/task/matrix/mark_failed",
557
+ { task_id: taskId }
558
+ );
465
559
  return { message: data.message ?? "" };
466
560
  }
467
- async approveMatrixAction(taskId) {
468
- const data = await this._post(`/tasks/${taskId}/matrix/approve`);
561
+ async approveMatrixAction(taskId, approved = true) {
562
+ const data = await this._post(
563
+ "/task/matrix/action",
564
+ { task_id: taskId, approved }
565
+ );
469
566
  return { message: data.message ?? "" };
470
567
  }
471
- async getMatrixConversation(taskId) {
472
- const data = await this._get(`/tasks/${taskId}/matrix/conversation`);
568
+ async getMatrixConversation(taskId, phase, includeSummaries) {
569
+ const data = await this._get(
570
+ "/task/matrix/conversation",
571
+ {
572
+ task_id: taskId,
573
+ phase,
574
+ include_summaries: includeSummaries
575
+ }
576
+ );
473
577
  return {
474
578
  taskId: data.taskId ?? data.task_id ?? taskId,
475
- conversation: (data.conversation ?? []).map(
476
- (m) => m
477
- )
579
+ conversation: (data.conversation ?? []).map((m) => m)
478
580
  };
479
581
  }
480
582
  // ------------------------------------------------------------------
481
583
  // VSA workflow
482
584
  // ------------------------------------------------------------------
483
585
  async createVSATask(params) {
484
- const data = await this._post("/tasks/vsa", {
586
+ const body = {
587
+ user_id: params.userId,
485
588
  goal_prompt: params.goalPrompt,
486
589
  title: params.title,
487
- model_id: params.modelId
488
- });
590
+ agent_model_id: params.agentModelId,
591
+ orchestrator_model_id: params.orchestratorModelId,
592
+ attachment_ids: params.attachmentIds,
593
+ options: params.options
594
+ };
595
+ if (params.delegatedToken !== void 0) {
596
+ body.delegated_token = params.delegatedToken;
597
+ }
598
+ const data = await this._post(
599
+ "/task/vsa/create",
600
+ body
601
+ );
489
602
  return {
490
603
  taskId: data.taskId ?? data.task_id ?? "",
491
604
  status: data.status ?? ""
492
605
  };
493
606
  }
494
- async sendVSAMessage(taskId, content) {
495
- const data = await this._post(`/tasks/${taskId}/vsa/message`, {
496
- content
497
- });
607
+ async sendVSAMessage(taskId, message, options) {
608
+ const body = {
609
+ task_id: taskId,
610
+ message,
611
+ attachment_ids: options?.attachmentIds
612
+ };
613
+ if (options?.delegatedToken !== void 0) {
614
+ body.delegated_token = options.delegatedToken;
615
+ }
616
+ const data = await this._post(
617
+ "/task/vsa/message",
618
+ body
619
+ );
498
620
  return { message: data.message ?? "" };
499
621
  }
500
622
  async renameVSATask(taskId, title) {
501
- const data = await this._post(`/tasks/${taskId}/vsa/rename`, {
623
+ const data = await this._post("/task/vsa/rename", {
624
+ task_id: taskId,
502
625
  title
503
626
  });
504
627
  return { message: data.message ?? "" };
505
628
  }
506
629
  async regenerateVSATitle(taskId) {
507
- const data = await this._post(`/tasks/${taskId}/vsa/regenerate-title`);
630
+ const data = await this._post(
631
+ "/task/vsa/regenerate_title",
632
+ { task_id: taskId }
633
+ );
508
634
  return { message: data.message ?? "" };
509
635
  }
510
636
  async markVSAComplete(taskId) {
511
- const data = await this._post(`/tasks/${taskId}/vsa/complete`);
637
+ const data = await this._post(
638
+ "/task/vsa/mark_complete",
639
+ { task_id: taskId }
640
+ );
512
641
  return { message: data.message ?? "" };
513
642
  }
514
643
  async markVSAFailed(taskId) {
515
- const data = await this._post(`/tasks/${taskId}/vsa/failed`);
644
+ const data = await this._post(
645
+ "/task/vsa/mark_failed",
646
+ { task_id: taskId }
647
+ );
516
648
  return { message: data.message ?? "" };
517
649
  }
518
650
  async stopVSA(taskId) {
519
- const data = await this._post(`/tasks/${taskId}/vsa/stop`);
651
+ const data = await this._post("/task/vsa/stop", {
652
+ task_id: taskId
653
+ });
520
654
  return { message: data.message ?? "" };
521
655
  }
522
656
  async deleteVSA(taskId) {
523
- const data = await this._delete(`/tasks/${taskId}/vsa`);
657
+ const data = await this._post("/task/vsa/delete", {
658
+ task_id: taskId
659
+ });
524
660
  return { message: data.message ?? "" };
525
661
  }
526
- async listVSATasks(params) {
527
- const data = await this._get("/tasks/vsa", {
528
- status: params?.status,
662
+ async listVSATasks(userId, params) {
663
+ const data = await this._get("/task/vsa/list", {
664
+ user_id: userId,
529
665
  limit: params?.limit,
530
666
  offset: params?.offset
531
667
  });
532
- const tasks = (data.tasks ?? []).map(buildTaskSummary);
668
+ const tasks = (data.tasks ?? []).map(
669
+ buildTaskSummary
670
+ );
533
671
  return { tasks, pagination: buildPagination(data) };
534
672
  }
535
- async searchVSATasks(query) {
536
- const data = await this._get("/tasks/vsa/search", { q: query });
537
- const tasks = (data.tasks ?? []).map(buildTaskSummary);
673
+ async searchVSATasks(userId, query, limit) {
674
+ const data = await this._get("/task/vsa/search", {
675
+ user_id: userId,
676
+ query,
677
+ limit
678
+ });
679
+ const tasks = (data.tasks ?? []).map(
680
+ buildTaskSummary
681
+ );
538
682
  return { tasks, pagination: buildPagination(data) };
539
683
  }
540
684
  async deleteVSATasksBulk(taskIds) {
541
- const data = await this._post("/tasks/vsa/delete-bulk", {
542
- task_ids: taskIds
543
- });
544
- return { message: data.message ?? "" };
685
+ const data = await this._post(
686
+ "/task/vsa/delete_bulk",
687
+ { task_ids: taskIds }
688
+ );
689
+ return {
690
+ deletedTasks: data.deletedTasks ?? data.deleted_tasks ?? [],
691
+ failedTasks: data.failedTasks ?? data.failed_tasks ?? [],
692
+ totalDeleted: data.totalDeleted ?? data.total_deleted ?? 0,
693
+ totalFailed: data.totalFailed ?? data.total_failed ?? 0
694
+ };
545
695
  }
546
696
  // ------------------------------------------------------------------
547
- // MIO workflow
697
+ // MIO (self_managed) workflow
548
698
  // ------------------------------------------------------------------
549
- async sendMioMessage(taskId, content) {
550
- const data = await this._post(`/tasks/${taskId}/mio/message`, {
551
- content
552
- });
699
+ async sendMioMessage(taskId, message, attachmentIds) {
700
+ const data = await this._post(
701
+ "/task/self_managed/message",
702
+ { task_id: taskId, message, attachment_ids: attachmentIds }
703
+ );
553
704
  return { message: data.message ?? "" };
554
705
  }
555
- async approveMioAction(taskId) {
556
- const data = await this._post(`/tasks/${taskId}/mio/approve`);
706
+ async approveMioAction(taskId, approved = true, feedback) {
707
+ const data = await this._post(
708
+ "/task/self_managed/action",
709
+ { task_id: taskId, approved, feedback }
710
+ );
557
711
  return { message: data.message ?? "" };
558
712
  }
559
713
  async wakeMio(taskId) {
560
- const data = await this._post(`/tasks/${taskId}/mio/wake`);
714
+ const data = await this._post(
715
+ "/task/self_managed/wake",
716
+ { task_id: taskId }
717
+ );
561
718
  return { message: data.message ?? "" };
562
719
  }
563
720
  async sendMioUserAway(taskId) {
564
- const data = await this._post(`/tasks/${taskId}/mio/user-away`);
721
+ const data = await this._post(
722
+ "/task/self_managed/user_away",
723
+ { task_id: taskId }
724
+ );
565
725
  return { message: data.message ?? "" };
566
726
  }
567
727
  async markMioComplete(taskId) {
568
- const data = await this._post(`/tasks/${taskId}/mio/complete`);
728
+ const data = await this._post(
729
+ "/task/self_managed/mark_complete",
730
+ { task_id: taskId }
731
+ );
569
732
  return { message: data.message ?? "" };
570
733
  }
571
734
  async markMioFailed(taskId) {
572
- const data = await this._post(`/tasks/${taskId}/mio/failed`);
735
+ const data = await this._post(
736
+ "/task/self_managed/mark_failed",
737
+ { task_id: taskId }
738
+ );
573
739
  return { message: data.message ?? "" };
574
740
  }
575
741
  async archiveMio(taskId) {
576
- const data = await this._post(`/tasks/${taskId}/mio/archive`);
742
+ const data = await this._post(
743
+ "/task/self_managed/archive",
744
+ { task_id: taskId }
745
+ );
577
746
  return { message: data.message ?? "" };
578
747
  }
579
748
  async getMioContext(taskId) {
580
- const data = await this._get(`/tasks/${taskId}/mio/context`);
749
+ const data = await this._get(
750
+ "/task/self_managed/context",
751
+ { task_id: taskId }
752
+ );
581
753
  return {
582
754
  taskId: data.taskId ?? data.task_id ?? taskId,
755
+ modelId: data.modelId ?? data.model_id ?? "",
583
756
  currentTokens: data.currentTokens ?? data.current_tokens ?? 0,
584
757
  contextLimit: data.contextLimit ?? data.context_limit ?? 0,
585
758
  usagePercentage: data.usagePercentage ?? data.usage_percentage ?? 0,
586
- archivedCount: data.archivedCount ?? data.archived_count ?? 0,
587
- activeCount: data.activeCount ?? data.active_count ?? 0
759
+ totalMessages: data.totalMessages ?? data.total_messages ?? 0,
760
+ activeMessages: data.activeMessages ?? data.active_messages ?? 0,
761
+ archivedMessages: data.archivedMessages ?? data.archived_messages ?? 0,
762
+ messagesWithoutTokenCount: data.messagesWithoutTokenCount ?? data.messages_without_token_count ?? 0
763
+ };
764
+ }
765
+ async getMioMemories(taskId, includeCommon) {
766
+ const data = await this._get(
767
+ "/task/self_managed/memories",
768
+ { task_id: taskId, include_common: includeCommon }
769
+ );
770
+ return {
771
+ memories: data.memories ?? [],
772
+ total: data.total ?? 0
588
773
  };
589
774
  }
590
775
  // ------------------------------------------------------------------
591
776
  // Tools
592
777
  // ------------------------------------------------------------------
593
778
  async listTools() {
594
- const data = await this._get("/tools");
779
+ const data = await this._get("/tools/all");
595
780
  return {
596
- tools: (data.tools ?? data.tools ?? []).map(
781
+ tools: (data.tools ?? []).map(
597
782
  (t) => t
598
783
  ),
599
784
  totalTools: data.totalTools ?? data.total_tools ?? 0,
600
785
  servers: data.servers ?? []
601
786
  };
602
787
  }
788
+ async getToolCatalog() {
789
+ return this._get("/tools/catalog");
790
+ }
791
+ async refreshMCPTools() {
792
+ return this._post("/tools/mcp/refresh");
793
+ }
794
+ async validateToolCatalog() {
795
+ return this._get("/tools/validate");
796
+ }
603
797
  // ------------------------------------------------------------------
604
798
  // Debug / Admin
605
799
  // ------------------------------------------------------------------
606
800
  async getWorkflowStates() {
607
- const data = await this._get("/debug/workflow-states");
801
+ const data = await this._get(
802
+ "/debug/workflow_states"
803
+ );
608
804
  return {
609
805
  validStates: data.validStates ?? data.valid_states ?? {},
610
806
  processableStates: data.processableStates ?? data.processable_states ?? {},
@@ -614,79 +810,116 @@ var OrchestratorAsync = class {
614
810
  };
615
811
  }
616
812
  async updateTaskModels(taskId, models) {
617
- const data = await this._post(`/tasks/${taskId}/models`, {
618
- agent: models.agent,
619
- orchestrator: models.orchestrator
620
- });
813
+ const data = await this._post(
814
+ "/debug/task/models",
815
+ {
816
+ task_id: taskId,
817
+ agent_model_id: models.agentModelId,
818
+ orchestrator_model_id: models.orchestratorModelId
819
+ }
820
+ );
621
821
  return { message: data.message ?? "" };
622
822
  }
623
- async updateTaskIteration(taskId, iteration) {
624
- const data = await this._post(`/tasks/${taskId}/iteration`, {
625
- iteration
626
- });
823
+ async updateTaskIteration(taskId, iteration, maxIterations) {
824
+ const data = await this._post(
825
+ "/debug/task/iteration",
826
+ { task_id: taskId, iteration, max_iterations: maxIterations }
827
+ );
627
828
  return { message: data.message ?? "" };
628
829
  }
629
830
  async updateTaskWorkflowData(taskId, workflowData) {
630
- const data = await this._post(`/tasks/${taskId}/workflow-data`, {
631
- workflow_data: workflowData
632
- });
831
+ const data = await this._post(
832
+ "/debug/task/workflow_data",
833
+ { task_id: taskId, workflow_data: workflowData }
834
+ );
633
835
  return { message: data.message ?? "" };
634
836
  }
635
837
  async deleteMessage(taskId, messageId) {
636
- const data = await this._delete(
637
- `/tasks/${taskId}/conversation/messages/${messageId}`
838
+ const data = await this._post(
839
+ "/debug/task/message/delete",
840
+ { task_id: taskId, message_id: messageId }
638
841
  );
639
842
  return { message: data.message ?? "" };
640
843
  }
641
844
  async deleteMessages(taskId, messageIds) {
642
845
  const data = await this._post(
643
- `/tasks/${taskId}/conversation/messages/delete`,
644
- { message_ids: messageIds }
846
+ "/debug/task/message/delete/multiple",
847
+ { task_id: taskId, message_ids: messageIds }
645
848
  );
646
- return { message: data.message ?? "" };
849
+ return {
850
+ deletedIds: data.deletedIds ?? data.deleted_ids ?? [],
851
+ failedIds: data.failedIds ?? data.failed_ids ?? [],
852
+ totalDeleted: data.totalDeleted ?? data.total_deleted ?? 0,
853
+ totalFailed: data.totalFailed ?? data.total_failed ?? 0
854
+ };
647
855
  }
648
856
  async updateMessage(taskId, messageId, update) {
649
- const data = await this._put(
650
- `/tasks/${taskId}/conversation/messages/${messageId}`,
651
- update
857
+ const data = await this._post(
858
+ "/debug/task/message/update",
859
+ { task_id: taskId, message_id: messageId, ...update }
652
860
  );
653
861
  return { message: data.message ?? "" };
654
862
  }
655
863
  async resetMatrixToPhase(taskId, phase) {
656
864
  const data = await this._post(
657
- `/tasks/${taskId}/matrix/reset`,
658
- { phase }
865
+ "/debug/task/matrix/reset_to_phase",
866
+ { task_id: taskId, phase }
659
867
  );
660
868
  return { message: data.message ?? "" };
661
869
  }
662
- async getMessageTranslations(taskId, messageId, locale) {
663
- const params = {};
664
- if (locale) params.locale = locale;
870
+ async getMessageTranslations(taskId, messageId) {
665
871
  const data = await this._get(
666
- `/tasks/${taskId}/conversation/messages/${messageId}/translations`,
667
- params
872
+ `/debug/task/${taskId}/message/${messageId}/translations`
668
873
  );
669
874
  return {
670
875
  messageId: data.messageId ?? data.message_id ?? messageId,
671
- translations: (data.translations ?? []).map(
672
- (t) => t
673
- )
876
+ translations: (data.translations ?? []).map((t) => t)
674
877
  };
675
878
  }
676
879
  // ------------------------------------------------------------------
677
880
  // Error events
678
881
  // ------------------------------------------------------------------
679
882
  async listErrors(params) {
680
- const queryParams = {};
681
- if (params?.since) queryParams.since = params.since;
682
- if (params?.severity) queryParams.severity = params.severity;
683
- if (params?.source) queryParams.source = params.source;
684
- if (params?.limit) queryParams.limit = params.limit;
685
- if (params?.offset) queryParams.offset = params.offset;
686
- const data = await this._get("/errors", queryParams);
687
- return (data.errors ?? []).map(
688
- (e) => e
689
- );
883
+ const authHeaders = await this._resolveHeaders();
884
+ const url = new URL(this._makeUrl("/errors"));
885
+ if (params?.page !== void 0)
886
+ url.searchParams.set("page", String(params.page));
887
+ if (params?.limit !== void 0)
888
+ url.searchParams.set("limit", String(params.limit));
889
+ if (params?.taskId) url.searchParams.set("task_id", params.taskId);
890
+ if (params?.workflowId)
891
+ url.searchParams.set("workflow_id", params.workflowId);
892
+ if (params?.errorCode) url.searchParams.set("error_code", params.errorCode);
893
+ if (params?.exceptionType)
894
+ url.searchParams.set("exception_type", params.exceptionType);
895
+ if (params?.holderId) url.searchParams.set("holder_id", params.holderId);
896
+ if (params?.requestId) url.searchParams.set("request_id", params.requestId);
897
+ if (params?.search) url.searchParams.set("search", params.search);
898
+ if (params?.since) url.searchParams.set("since", params.since);
899
+ if (params?.until) url.searchParams.set("until", params.until);
900
+ if (params?.orderDirection)
901
+ url.searchParams.set("order_direction", params.orderDirection);
902
+ for (const s of params?.severity ?? []) {
903
+ url.searchParams.append("severity", s);
904
+ }
905
+ for (const s of params?.source ?? []) {
906
+ url.searchParams.append("source", s);
907
+ }
908
+ const response = await this._fetch(url.toString(), {
909
+ method: "GET",
910
+ headers: { ...authHeaders }
911
+ });
912
+ if (!response.ok) {
913
+ throw new OrchestratorAPIError(
914
+ `listErrors failed: ${response.statusText}`,
915
+ response.status
916
+ );
917
+ }
918
+ const data = await response.json();
919
+ return {
920
+ items: (data.items ?? data.errors ?? []).map((e) => e),
921
+ pagination: buildPagination(data)
922
+ };
690
923
  }
691
924
  async getErrorDetail(errorId) {
692
925
  return this._get(`/errors/${errorId}`);
@@ -711,13 +944,13 @@ var OrchestratorAsync = class {
711
944
  return this._get("/health");
712
945
  }
713
946
  async healthDetailed() {
714
- return this._get("/health/detail");
947
+ return this._get("/health/detailed");
715
948
  }
716
949
  async ready() {
717
950
  return this._get("/ready");
718
951
  }
719
952
  async healthLeader() {
720
- return this._get("/leader");
953
+ return this._get("/health/leader");
721
954
  }
722
955
  async getMetrics(types) {
723
956
  const params = {};
@@ -728,82 +961,122 @@ var OrchestratorAsync = class {
728
961
  // Configuration
729
962
  // ------------------------------------------------------------------
730
963
  async getSystemStatus() {
731
- return this._get("/config/status");
964
+ return this._get("/configuration/system/status");
732
965
  }
733
966
  async updateSettings(settings) {
734
- return this._post("/config/settings", settings);
967
+ return this._post("/configuration/system/settings", settings);
735
968
  }
736
969
  async getConfigurationStatus() {
737
- return this._get("/config");
970
+ return this._get("/configuration/status");
738
971
  }
739
972
  async setAgentModel(model) {
740
- const data = await this._post("/config/models/agent", { model });
973
+ const data = await this._post(
974
+ "/configuration/agent",
975
+ { model_name: model }
976
+ );
741
977
  return { message: data.message ?? "" };
742
978
  }
743
979
  async setOrchestratorModel(model) {
744
- const data = await this._post("/config/models/orchestrator", { model });
980
+ const data = await this._post(
981
+ "/configuration/orchestrator",
982
+ { model_name: model }
983
+ );
745
984
  return { message: data.message ?? "" };
746
985
  }
747
986
  async getLLMBackendStatus() {
748
- return this._get("/config/llmbackends");
987
+ return this._get(
988
+ "/configuration/llmbackend/status"
989
+ );
749
990
  }
750
991
  async addLLMBackend(host, apiKey) {
751
- const data = await this._post("/config/llmbackends", {
752
- host,
753
- api_key: apiKey
754
- });
992
+ const data = await this._post(
993
+ "/configuration/llmbackend/add",
994
+ { backends: [{ url: host, api_key: apiKey }] }
995
+ );
755
996
  return { message: data.message ?? "" };
756
997
  }
757
998
  async removeLLMBackend(host) {
758
- const data = await this._delete(`/config/llmbackends/${encodeURIComponent(host)}`);
999
+ const data = await this._post(
1000
+ "/configuration/llmbackend/remove",
1001
+ { host }
1002
+ );
759
1003
  return { message: data.message ?? "" };
760
1004
  }
761
1005
  async getMCPServerStatus() {
762
- return this._get("/config/mcpservers");
1006
+ return this._get(
1007
+ "/configuration/mcpserver/status"
1008
+ );
763
1009
  }
764
1010
  async addMCPServer(host, apiKey) {
765
- const data = await this._post("/config/mcpservers", {
766
- host,
767
- api_key: apiKey
768
- });
1011
+ const data = await this._post(
1012
+ "/configuration/mcpserver/add",
1013
+ { servers: [{ url: host, api_key: apiKey }] }
1014
+ );
769
1015
  return { message: data.message ?? "" };
770
1016
  }
771
1017
  async removeMCPServer(host) {
772
- const data = await this._delete(`/config/mcpservers/${encodeURIComponent(host)}`);
1018
+ const data = await this._post(
1019
+ "/configuration/mcpserver/remove",
1020
+ { host }
1021
+ );
773
1022
  return { message: data.message ?? "" };
774
1023
  }
775
1024
  async getTaskHandlerStatus() {
776
- return this._get("/config/taskhandler");
1025
+ return this._get("/configuration/taskhandler/status");
777
1026
  }
778
1027
  async getTaskHandlerStatusLocal() {
779
- return this._get("/config/taskhandler/local");
1028
+ return this._get(
1029
+ "/configuration/taskhandler/status/local"
1030
+ );
780
1031
  }
781
1032
  async setConcurrentTasksPerReplica(maxTasks) {
782
- const data = await this._post("/config/taskhandler/concurrency", {
783
- max_tasks: maxTasks
784
- });
1033
+ const data = await this._request(
1034
+ "POST",
1035
+ "/configuration/taskhandler/concurrent-per-replica",
1036
+ { params: { max_tasks: maxTasks } }
1037
+ );
785
1038
  return { message: data.message ?? "" };
786
1039
  }
787
1040
  async getSummaryWorkerStatus() {
788
- return this._get("/config/summary-worker");
1041
+ return this._get(
1042
+ "/configuration/summary-worker/status"
1043
+ );
789
1044
  }
790
1045
  async setCompactorModel(modelName) {
791
- const data = await this._post("/config/models/compactor", {
792
- model_name: modelName
793
- });
1046
+ const data = await this._post(
1047
+ "/configuration/summary-worker/model",
1048
+ { model_name: modelName }
1049
+ );
794
1050
  return { message: data.message ?? "" };
795
1051
  }
796
1052
  async setTranslateModel(modelName) {
797
- const data = await this._post("/config/models/translate", {
798
- model_name: modelName
799
- });
1053
+ const data = await this._post(
1054
+ "/configuration/summary-worker/translate-model",
1055
+ { model_name: modelName }
1056
+ );
800
1057
  return { message: data.message ?? "" };
801
1058
  }
802
1059
  async getTokenWorkerStatus() {
803
- return this._get("/config/token-worker");
1060
+ return this._get("/configuration/token-worker/status");
804
1061
  }
805
1062
  async getSlotsStatus() {
806
- return this._get("/config/slots");
1063
+ return this._get("/configuration/slots/status");
1064
+ }
1065
+ async getSubagentsStatus() {
1066
+ return this._get("/configuration/subagents/status");
1067
+ }
1068
+ async setSubagentsEnabled(enabled) {
1069
+ const data = await this._post(
1070
+ "/configuration/subagents",
1071
+ { enabled }
1072
+ );
1073
+ return { message: data.message ?? "" };
1074
+ }
1075
+ async reloadServices() {
1076
+ return this._post("/configuration/reload");
1077
+ }
1078
+ async getReloadStatus() {
1079
+ return this._get("/configuration/reload/status");
807
1080
  }
808
1081
  // ------------------------------------------------------------------
809
1082
  // Auth / WebSocket status
@@ -819,10 +1092,13 @@ var OrchestratorAsync = class {
819
1092
  // ------------------------------------------------------------------
820
1093
  async *streamTaskStatus(taskId) {
821
1094
  const headers = await this._resolveHeaders();
822
- headers["Accept"] = "text/event-stream";
823
- const response = await this._fetch(this._makeUrl(`/tasks/${taskId}/stream`), {
824
- headers
825
- });
1095
+ headers.Accept = "text/event-stream";
1096
+ const response = await this._fetch(
1097
+ this._makeUrl(
1098
+ `/task/stream_status?task_id=${encodeURIComponent(taskId)}`
1099
+ ),
1100
+ { headers }
1101
+ );
826
1102
  if (!response.ok) {
827
1103
  throw new OrchestratorAPIError(
828
1104
  `Stream connection failed: ${response.statusText}`,
@@ -862,7 +1138,9 @@ function combineSignals(...signals) {
862
1138
  controller.abort(signal.reason);
863
1139
  return controller.signal;
864
1140
  }
865
- signal.addEventListener("abort", () => controller.abort(signal.reason), { once: true });
1141
+ signal.addEventListener("abort", () => controller.abort(signal.reason), {
1142
+ once: true
1143
+ });
866
1144
  }
867
1145
  return controller.signal;
868
1146
  }
@@ -886,11 +1164,14 @@ var Orchestrator = class {
886
1164
  createTask(params) {
887
1165
  return runSync(this._async.createTask(params));
888
1166
  }
889
- getTaskStatus(taskId) {
890
- return runSync(this._async.getTaskStatus(taskId));
1167
+ getTaskStatus(taskId, locale) {
1168
+ return runSync(this._async.getTaskStatus(taskId, locale));
891
1169
  }
892
- getTaskConversation(taskId) {
893
- return runSync(this._async.getTaskConversation(taskId));
1170
+ setTaskStatus(taskId, status) {
1171
+ return runSync(this._async.setTaskStatus(taskId, status));
1172
+ }
1173
+ getTaskConversation(taskId, params) {
1174
+ return runSync(this._async.getTaskConversation(taskId, params));
894
1175
  }
895
1176
  getArchivedMessageContent(taskId, messageId) {
896
1177
  return runSync(this._async.getArchivedMessageContent(taskId, messageId));
@@ -913,17 +1194,19 @@ var Orchestrator = class {
913
1194
  // ------------------------------------------------------------------
914
1195
  // Attachments
915
1196
  // ------------------------------------------------------------------
916
- uploadAttachment(taskId, file, filename) {
917
- return runSync(this._async.uploadAttachment(taskId, file, filename));
1197
+ uploadAttachment(file, filename) {
1198
+ return runSync(this._async.uploadAttachment(file, filename));
918
1199
  }
919
- downloadAttachment(taskId, attachmentId) {
920
- return runSync(this._async.downloadAttachment(taskId, attachmentId));
1200
+ downloadAttachment(attachmentId) {
1201
+ return runSync(this._async.downloadAttachment(attachmentId));
921
1202
  }
922
1203
  // ------------------------------------------------------------------
923
1204
  // Interactive workflow
924
1205
  // ------------------------------------------------------------------
925
- sendInteractiveMessage(taskId, content) {
926
- return runSync(this._async.sendInteractiveMessage(taskId, content));
1206
+ sendInteractiveMessage(taskId, message, attachmentIds) {
1207
+ return runSync(
1208
+ this._async.sendInteractiveMessage(taskId, message, attachmentIds)
1209
+ );
927
1210
  }
928
1211
  markInteractiveComplete(taskId) {
929
1212
  return runSync(this._async.markInteractiveComplete(taskId));
@@ -931,32 +1214,37 @@ var Orchestrator = class {
931
1214
  markInteractiveFailed(taskId) {
932
1215
  return runSync(this._async.markInteractiveFailed(taskId));
933
1216
  }
934
- approveInteractiveAction(taskId) {
935
- return runSync(this._async.approveInteractiveAction(taskId));
1217
+ approveInteractiveAction(taskId, approved = true) {
1218
+ return runSync(this._async.approveInteractiveAction(taskId, approved));
1219
+ }
1220
+ stopInteractive(taskId) {
1221
+ return runSync(this._async.stopInteractive(taskId));
936
1222
  }
937
1223
  // ------------------------------------------------------------------
938
1224
  // Proactive workflow
939
1225
  // ------------------------------------------------------------------
940
- sendProactiveGuide(taskId, guide) {
941
- return runSync(this._async.sendProactiveGuide(taskId, guide));
1226
+ sendProactiveGuide(taskId, message, attachmentIds) {
1227
+ return runSync(
1228
+ this._async.sendProactiveGuide(taskId, message, attachmentIds)
1229
+ );
942
1230
  }
943
1231
  respondProactiveHelp(taskId, response) {
944
1232
  return runSync(this._async.respondProactiveHelp(taskId, response));
945
1233
  }
946
- approveProactiveAction(taskId) {
947
- return runSync(this._async.approveProactiveAction(taskId));
1234
+ approveProactiveAction(taskId, approved = true) {
1235
+ return runSync(this._async.approveProactiveAction(taskId, approved));
948
1236
  }
949
1237
  // ------------------------------------------------------------------
950
1238
  // Ticket workflow
951
1239
  // ------------------------------------------------------------------
952
- sendTicketGuide(taskId, guide) {
953
- return runSync(this._async.sendTicketGuide(taskId, guide));
1240
+ sendTicketGuide(taskId, message, attachmentIds) {
1241
+ return runSync(this._async.sendTicketGuide(taskId, message, attachmentIds));
954
1242
  }
955
1243
  respondTicketHelp(taskId, response) {
956
1244
  return runSync(this._async.respondTicketHelp(taskId, response));
957
1245
  }
958
- approveTicketAction(taskId) {
959
- return runSync(this._async.approveTicketAction(taskId));
1246
+ approveTicketAction(taskId, approved = true) {
1247
+ return runSync(this._async.approveTicketAction(taskId, approved));
960
1248
  }
961
1249
  wakeTicket(taskId) {
962
1250
  return runSync(this._async.wakeTicket(taskId));
@@ -964,8 +1252,10 @@ var Orchestrator = class {
964
1252
  // ------------------------------------------------------------------
965
1253
  // Matrix workflow
966
1254
  // ------------------------------------------------------------------
967
- sendMatrixMessage(taskId, content) {
968
- return runSync(this._async.sendMatrixMessage(taskId, content));
1255
+ sendMatrixMessage(taskId, message, attachmentIds) {
1256
+ return runSync(
1257
+ this._async.sendMatrixMessage(taskId, message, attachmentIds)
1258
+ );
969
1259
  }
970
1260
  markMatrixComplete(taskId) {
971
1261
  return runSync(this._async.markMatrixComplete(taskId));
@@ -973,11 +1263,13 @@ var Orchestrator = class {
973
1263
  markMatrixFailed(taskId) {
974
1264
  return runSync(this._async.markMatrixFailed(taskId));
975
1265
  }
976
- approveMatrixAction(taskId) {
977
- return runSync(this._async.approveMatrixAction(taskId));
1266
+ approveMatrixAction(taskId, approved = true) {
1267
+ return runSync(this._async.approveMatrixAction(taskId, approved));
978
1268
  }
979
- getMatrixConversation(taskId) {
980
- return runSync(this._async.getMatrixConversation(taskId));
1269
+ getMatrixConversation(taskId, phase, includeSummaries) {
1270
+ return runSync(
1271
+ this._async.getMatrixConversation(taskId, phase, includeSummaries)
1272
+ );
981
1273
  }
982
1274
  // ------------------------------------------------------------------
983
1275
  // VSA workflow
@@ -985,8 +1277,8 @@ var Orchestrator = class {
985
1277
  createVSATask(params) {
986
1278
  return runSync(this._async.createVSATask(params));
987
1279
  }
988
- sendVSAMessage(taskId, content) {
989
- return runSync(this._async.sendVSAMessage(taskId, content));
1280
+ sendVSAMessage(taskId, message, options) {
1281
+ return runSync(this._async.sendVSAMessage(taskId, message, options));
990
1282
  }
991
1283
  renameVSATask(taskId, title) {
992
1284
  return runSync(this._async.renameVSATask(taskId, title));
@@ -1006,23 +1298,23 @@ var Orchestrator = class {
1006
1298
  deleteVSA(taskId) {
1007
1299
  return runSync(this._async.deleteVSA(taskId));
1008
1300
  }
1009
- listVSATasks(params) {
1010
- return runSync(this._async.listVSATasks(params));
1301
+ listVSATasks(userId, params) {
1302
+ return runSync(this._async.listVSATasks(userId, params));
1011
1303
  }
1012
- searchVSATasks(query) {
1013
- return runSync(this._async.searchVSATasks(query));
1304
+ searchVSATasks(userId, query, limit) {
1305
+ return runSync(this._async.searchVSATasks(userId, query, limit));
1014
1306
  }
1015
1307
  deleteVSATasksBulk(taskIds) {
1016
1308
  return runSync(this._async.deleteVSATasksBulk(taskIds));
1017
1309
  }
1018
1310
  // ------------------------------------------------------------------
1019
- // MIO workflow
1311
+ // MIO (self_managed) workflow
1020
1312
  // ------------------------------------------------------------------
1021
- sendMioMessage(taskId, content) {
1022
- return runSync(this._async.sendMioMessage(taskId, content));
1313
+ sendMioMessage(taskId, message, attachmentIds) {
1314
+ return runSync(this._async.sendMioMessage(taskId, message, attachmentIds));
1023
1315
  }
1024
- approveMioAction(taskId) {
1025
- return runSync(this._async.approveMioAction(taskId));
1316
+ approveMioAction(taskId, approved = true, feedback) {
1317
+ return runSync(this._async.approveMioAction(taskId, approved, feedback));
1026
1318
  }
1027
1319
  wakeMio(taskId) {
1028
1320
  return runSync(this._async.wakeMio(taskId));
@@ -1042,12 +1334,24 @@ var Orchestrator = class {
1042
1334
  getMioContext(taskId) {
1043
1335
  return runSync(this._async.getMioContext(taskId));
1044
1336
  }
1337
+ getMioMemories(taskId, includeCommon) {
1338
+ return runSync(this._async.getMioMemories(taskId, includeCommon));
1339
+ }
1045
1340
  // ------------------------------------------------------------------
1046
1341
  // Tools
1047
1342
  // ------------------------------------------------------------------
1048
1343
  listTools() {
1049
1344
  return runSync(this._async.listTools());
1050
1345
  }
1346
+ getToolCatalog() {
1347
+ return runSync(this._async.getToolCatalog());
1348
+ }
1349
+ refreshMCPTools() {
1350
+ return runSync(this._async.refreshMCPTools());
1351
+ }
1352
+ validateToolCatalog() {
1353
+ return runSync(this._async.validateToolCatalog());
1354
+ }
1051
1355
  // ------------------------------------------------------------------
1052
1356
  // Debug / Admin
1053
1357
  // ------------------------------------------------------------------
@@ -1057,8 +1361,10 @@ var Orchestrator = class {
1057
1361
  updateTaskModels(taskId, models) {
1058
1362
  return runSync(this._async.updateTaskModels(taskId, models));
1059
1363
  }
1060
- updateTaskIteration(taskId, iteration) {
1061
- return runSync(this._async.updateTaskIteration(taskId, iteration));
1364
+ updateTaskIteration(taskId, iteration, maxIterations) {
1365
+ return runSync(
1366
+ this._async.updateTaskIteration(taskId, iteration, maxIterations)
1367
+ );
1062
1368
  }
1063
1369
  updateTaskWorkflowData(taskId, workflowData) {
1064
1370
  return runSync(this._async.updateTaskWorkflowData(taskId, workflowData));
@@ -1075,8 +1381,8 @@ var Orchestrator = class {
1075
1381
  resetMatrixToPhase(taskId, phase) {
1076
1382
  return runSync(this._async.resetMatrixToPhase(taskId, phase));
1077
1383
  }
1078
- getMessageTranslations(taskId, messageId, locale) {
1079
- return runSync(this._async.getMessageTranslations(taskId, messageId, locale));
1384
+ getMessageTranslations(taskId, messageId) {
1385
+ return runSync(this._async.getMessageTranslations(taskId, messageId));
1080
1386
  }
1081
1387
  // ------------------------------------------------------------------
1082
1388
  // Error events
@@ -1174,6 +1480,18 @@ var Orchestrator = class {
1174
1480
  getSlotsStatus() {
1175
1481
  return runSync(this._async.getSlotsStatus());
1176
1482
  }
1483
+ getSubagentsStatus() {
1484
+ return runSync(this._async.getSubagentsStatus());
1485
+ }
1486
+ setSubagentsEnabled(enabled) {
1487
+ return runSync(this._async.setSubagentsEnabled(enabled));
1488
+ }
1489
+ reloadServices() {
1490
+ return runSync(this._async.reloadServices());
1491
+ }
1492
+ getReloadStatus() {
1493
+ return runSync(this._async.getReloadStatus());
1494
+ }
1177
1495
  // ------------------------------------------------------------------
1178
1496
  // Auth / WebSocket status
1179
1497
  // ------------------------------------------------------------------
@@ -1345,11 +1663,15 @@ var RealtimeClient = class {
1345
1663
  this._socket.on("disconnect", () => {
1346
1664
  this._connected = false;
1347
1665
  });
1666
+ this._socket.on("message", (payload) => this._dispatch(payload));
1348
1667
  return new Promise((resolve, reject) => {
1349
- const socket = this._socket;
1350
- socket.on("connect", () => resolve());
1351
- socket.on("connect_error", (err) => reject(err));
1352
- if (socket.connected) {
1668
+ if (!this._socket) {
1669
+ reject(new Error("RealtimeClient not connected"));
1670
+ return;
1671
+ }
1672
+ this._socket.on("connect", () => resolve());
1673
+ this._socket.on("connect_error", (err) => reject(err));
1674
+ if (this._socket.connected) {
1353
1675
  resolve();
1354
1676
  }
1355
1677
  });
@@ -1361,48 +1683,132 @@ var RealtimeClient = class {
1361
1683
  }
1362
1684
  this._connected = false;
1363
1685
  }
1686
+ /**
1687
+ * Dispatch a message envelope to registered handlers.
1688
+ * The server sends: socket.emit("message", {type: "message", event: {..., event_type: "...", ...}})
1689
+ */
1690
+ _dispatch(payload) {
1691
+ const envelope = payload;
1692
+ const event = envelope.event ?? envelope;
1693
+ const eventType = event.event_type;
1694
+ if (!eventType) return;
1695
+ const handlers = this._handlers.get(eventType);
1696
+ if (handlers) {
1697
+ for (const h of handlers) {
1698
+ h(event);
1699
+ }
1700
+ }
1701
+ }
1364
1702
  /**
1365
1703
  * Subscribe to realtime events for a specific task.
1704
+ * Emits a `join` event with `{rooms: ["task:{taskId}"]}`.
1366
1705
  */
1367
- async subscribeTask(taskId) {
1706
+ subscribeTask(taskId) {
1368
1707
  if (!this._socket) throw new Error("RealtimeClient not connected");
1369
- return new Promise((resolve, reject) => {
1370
- this._socket.emit("subscribe", { task_id: taskId }, (response) => {
1371
- if (response.ok) resolve();
1372
- else reject(new Error(response.error ?? "Subscription failed"));
1373
- });
1374
- });
1708
+ this._socket.emit("join", { rooms: [`task:${taskId}`] });
1375
1709
  }
1376
1710
  /**
1377
1711
  * Unsubscribe from realtime events for a specific task.
1712
+ * Emits a `leave` event with `{rooms: ["task:{taskId}"]}`.
1378
1713
  */
1379
- async unsubscribeTask(taskId) {
1714
+ unsubscribeTask(taskId) {
1380
1715
  if (!this._socket) throw new Error("RealtimeClient not connected");
1381
- return new Promise((resolve, reject) => {
1382
- this._socket.emit("unsubscribe", { task_id: taskId }, (response) => {
1383
- if (response.ok) resolve();
1384
- else reject(new Error(response.error ?? "Unsubscription failed"));
1385
- });
1386
- });
1716
+ this._socket.emit("leave", { rooms: [`task:${taskId}`] });
1717
+ }
1718
+ /**
1719
+ * Subscribe to event-type-scoped rooms.
1720
+ * e.g. subscribeEvents("task_created", "task_deleted")
1721
+ */
1722
+ subscribeEvents(...eventTypes) {
1723
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1724
+ const rooms = eventTypes.map((t) => `event:${t}`);
1725
+ this._socket.emit("join", { rooms });
1726
+ }
1727
+ /**
1728
+ * Unsubscribe from event-type-scoped rooms.
1729
+ */
1730
+ unsubscribeEvents(...eventTypes) {
1731
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1732
+ const rooms = eventTypes.map((t) => `event:${t}`);
1733
+ this._socket.emit("leave", { rooms });
1734
+ }
1735
+ /**
1736
+ * Subscribe to the `all` broadcast room (receives all events).
1737
+ */
1738
+ subscribeAll() {
1739
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1740
+ this._socket.emit("join", { rooms: ["all"] });
1741
+ }
1742
+ /**
1743
+ * Subscribe to a locale-specific room.
1744
+ */
1745
+ subscribeLocale(locale) {
1746
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1747
+ this._socket.emit("join", { rooms: [`locale:${locale}`] });
1748
+ }
1749
+ /**
1750
+ * Unsubscribe from a locale-specific room.
1751
+ */
1752
+ unsubscribeLocale(locale) {
1753
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1754
+ this._socket.emit("leave", { rooms: [`locale:${locale}`] });
1755
+ }
1756
+ /**
1757
+ * Join arbitrary rooms by name.
1758
+ */
1759
+ joinRooms(rooms) {
1760
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1761
+ this._socket.emit("join", { rooms });
1762
+ }
1763
+ /**
1764
+ * Leave arbitrary rooms by name.
1765
+ */
1766
+ leaveRooms(rooms) {
1767
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1768
+ this._socket.emit("leave", { rooms });
1769
+ }
1770
+ /**
1771
+ * Send a ping to the server.
1772
+ */
1773
+ ping() {
1774
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1775
+ this._socket.emit("ping");
1387
1776
  }
1388
1777
  /**
1389
1778
  * Register a handler for a specific event type.
1779
+ *
1780
+ * Domain events (task_created, task_status_changed, etc.) are dispatched
1781
+ * via the message envelope. Raw socket events (connect, disconnect,
1782
+ * connection_established, rooms_updated, pong) are wired directly.
1390
1783
  */
1391
1784
  on(event, handler) {
1392
1785
  if (!this._handlers.has(event)) {
1393
1786
  this._handlers.set(event, /* @__PURE__ */ new Set());
1394
1787
  if (this._socket) {
1395
- this._socket.on(event, (...args) => {
1396
- const handlers = this._handlers.get(event);
1397
- if (handlers) {
1398
- for (const h of handlers) {
1399
- h(...args);
1788
+ const rawSocketEvents = /* @__PURE__ */ new Set([
1789
+ "connect",
1790
+ "disconnect",
1791
+ "connect_error",
1792
+ "connection_established",
1793
+ "rooms_updated",
1794
+ "pong"
1795
+ ]);
1796
+ if (rawSocketEvents.has(event)) {
1797
+ this._socket.on(event, (...args) => {
1798
+ const handlers2 = this._handlers.get(event);
1799
+ if (handlers2) {
1800
+ for (const h of handlers2) {
1801
+ h(...args);
1802
+ }
1400
1803
  }
1401
- }
1402
- });
1804
+ });
1805
+ }
1403
1806
  }
1404
1807
  }
1405
- this._handlers.get(event).add(handler);
1808
+ const handlers = this._handlers.get(event);
1809
+ if (handlers) {
1810
+ handlers.add(handler);
1811
+ }
1406
1812
  }
1407
1813
  /**
1408
1814
  * Remove a registered handler.
@@ -1424,12 +1830,11 @@ var RealtimeClient = class {
1424
1830
  */
1425
1831
  wait() {
1426
1832
  return new Promise((resolve) => {
1427
- const socket = this._socket;
1428
- if (!socket) {
1833
+ if (!this._socket) {
1429
1834
  resolve();
1430
1835
  return;
1431
1836
  }
1432
- socket.on("disconnect", () => resolve());
1837
+ this._socket.on("disconnect", () => resolve());
1433
1838
  });
1434
1839
  }
1435
1840
  };