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.cjs CHANGED
@@ -140,7 +140,10 @@ var OrchestratorAsync = class {
140
140
  constructor(opts = {}) {
141
141
  this._abortController = null;
142
142
  this._insecure = false;
143
- this._baseUrl = (opts.baseUrl ?? "http://localhost:8080").replace(/\/+$/, "");
143
+ this._baseUrl = (opts.baseUrl ?? "http://localhost:8080").replace(
144
+ /\/+$/,
145
+ ""
146
+ );
144
147
  this._apiKey = opts.apiKey;
145
148
  this._getToken = opts.getToken;
146
149
  this._timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
@@ -162,11 +165,11 @@ var OrchestratorAsync = class {
162
165
  async _resolveHeaders() {
163
166
  const headers = {};
164
167
  if (this._apiKey) {
165
- headers["Authorization"] = `Bearer ${this._apiKey}`;
168
+ headers.Authorization = `Bearer ${this._apiKey}`;
166
169
  } else if (this._getToken) {
167
170
  const token = await this._getToken();
168
171
  if (token) {
169
- headers["Authorization"] = `Bearer ${token}`;
172
+ headers.Authorization = `Bearer ${token}`;
170
173
  }
171
174
  }
172
175
  return headers;
@@ -314,34 +317,54 @@ var OrchestratorAsync = class {
314
317
  // Tasks
315
318
  // ------------------------------------------------------------------
316
319
  async listTasks(params) {
317
- const data = await this._get("/tasks", {
318
- workflow_id: params?.workflowId,
319
- status: params?.status,
320
- limit: params?.limit,
321
- offset: params?.offset,
322
- sort_by: params?.sortBy,
323
- sort_order: params?.sortOrder
320
+ const headers = {};
321
+ if (params?.locale) headers["X-Locale"] = params.locale;
322
+ const data = await this._request("GET", "/tasks", {
323
+ params: {
324
+ page: params?.page,
325
+ limit: params?.limit,
326
+ order_by: params?.orderBy,
327
+ order_direction: params?.orderDirection,
328
+ workflow_id: params?.workflowId
329
+ },
330
+ headers
324
331
  });
325
- const tasks = (data.tasks ?? []).map(buildTaskSummary);
332
+ const tasks = (data.tasks ?? []).map(
333
+ buildTaskSummary
334
+ );
326
335
  return { tasks, pagination: buildPagination(data) };
327
336
  }
328
337
  async createTask(params) {
329
- const data = await this._post("/tasks", {
338
+ const data = await this._post("/task/create", {
330
339
  workflow_id: params.workflowId,
331
340
  goal_prompt: params.goalPrompt,
332
341
  max_iterations: params.maxIterations,
333
- options: params.options,
342
+ reasoning_effort: params.reasoningEffort,
343
+ system_prompt: params.systemPrompt,
344
+ developer_prompt: params.developerPrompt,
334
345
  ticket_id: params.ticketId,
335
- title: params.title,
336
- model_id: params.modelId
346
+ ticket_text: params.ticketText,
347
+ summary: params.summary,
348
+ problem_summary: params.problemSummary,
349
+ solution_strategy: params.solutionStrategy,
350
+ agent_model_id: params.agentModelId,
351
+ orchestrator_model_id: params.orchestratorModelId,
352
+ available_tools: params.availableTools,
353
+ attachment_ids: params.attachmentIds,
354
+ options: params.options
337
355
  });
338
356
  return {
339
357
  taskId: data.taskId ?? data.task_id ?? "",
340
358
  status: data.status ?? ""
341
359
  };
342
360
  }
343
- async getTaskStatus(taskId) {
344
- const data = await this._get(`/tasks/${taskId}`);
361
+ async getTaskStatus(taskId, locale) {
362
+ const headers = {};
363
+ if (locale) headers["X-Locale"] = locale;
364
+ const data = await this._request("GET", "/task/status", {
365
+ params: { task_id: taskId },
366
+ headers
367
+ });
345
368
  return {
346
369
  ...buildTaskSummary(data),
347
370
  subtaskIds: data.subtaskIds ?? data.subtask_ids ?? [],
@@ -349,26 +372,45 @@ var OrchestratorAsync = class {
349
372
  options: data.options ?? null
350
373
  };
351
374
  }
352
- async getTaskConversation(taskId) {
353
- const data = await this._get(`/tasks/${taskId}/conversation`);
375
+ async setTaskStatus(taskId, status) {
376
+ const data = await this._post("/task/set_status", {
377
+ task_id: taskId,
378
+ status
379
+ });
380
+ return { message: data.message ?? "" };
381
+ }
382
+ async getTaskConversation(taskId, params) {
383
+ const headers = {};
384
+ if (params?.locale) headers["X-Locale"] = params.locale;
385
+ const data = await this._request("GET", "/task/conversation", {
386
+ params: {
387
+ task_id: taskId,
388
+ include_summaries: params?.includeSummaries,
389
+ exclude_archived: params?.excludeArchived
390
+ },
391
+ headers
392
+ });
354
393
  return {
355
394
  taskId: data.taskId ?? data.task_id ?? taskId,
356
- conversation: (data.conversation ?? []).map(
357
- (m) => m
358
- )
395
+ conversation: (data.conversation ?? []).map((m) => m)
359
396
  };
360
397
  }
361
398
  async getArchivedMessageContent(taskId, messageId) {
362
399
  return this._get(
363
- `/tasks/${taskId}/conversation/messages/${messageId}/archived`
400
+ "/task/message/archived-content",
401
+ { task_id: taskId, message_id: messageId }
364
402
  );
365
403
  }
366
404
  async getTaskCompactions(taskId) {
367
- const data = await this._get(`/tasks/${taskId}/compactions`);
405
+ const data = await this._get("/task/compactions", {
406
+ task_id: taskId
407
+ });
368
408
  return data.compactions ?? [];
369
409
  }
370
410
  async getTaskJournal(taskId) {
371
- const data = await this._get(`/tasks/${taskId}/journal`);
411
+ const data = await this._get("/task/journal", {
412
+ task_id: taskId
413
+ });
372
414
  return {
373
415
  taskId: data.taskId ?? data.task_id ?? taskId,
374
416
  exists: data.exists ?? false,
@@ -379,11 +421,22 @@ var OrchestratorAsync = class {
379
421
  };
380
422
  }
381
423
  async cancelTask(taskId) {
382
- const data = await this._post(`/tasks/${taskId}/cancel`);
383
- return { message: data.message ?? "" };
424
+ const data = await this._post("/task/cancel", {
425
+ task_id: taskId
426
+ });
427
+ return {
428
+ taskId: data.taskId ?? data.task_id ?? taskId,
429
+ killed: data.killed ?? false,
430
+ via: data.via ?? "none",
431
+ holderId: data.holderId ?? data.holder_id ?? void 0,
432
+ reason: data.reason ?? void 0,
433
+ message: data.message ?? ""
434
+ };
384
435
  }
385
436
  async deleteTask(taskId) {
386
- const data = await this._delete(`/tasks/${taskId}`);
437
+ const data = await this._post("/task/delete", {
438
+ task_id: taskId
439
+ });
387
440
  return {
388
441
  deletedTasks: data.deletedTasks ?? data.deleted_tasks ?? [],
389
442
  failedTasks: data.failedTasks ?? data.failed_tasks ?? [],
@@ -392,7 +445,10 @@ var OrchestratorAsync = class {
392
445
  };
393
446
  }
394
447
  async deleteTasks(taskIds) {
395
- const data = await this._post("/tasks/delete", { task_ids: taskIds });
448
+ const data = await this._post(
449
+ "/task/delete/multiple",
450
+ { task_ids: taskIds }
451
+ );
396
452
  return {
397
453
  deletedTasks: data.deletedTasks ?? data.deleted_tasks ?? [],
398
454
  failedTasks: data.failedTasks ?? data.failed_tasks ?? [],
@@ -403,11 +459,11 @@ var OrchestratorAsync = class {
403
459
  // ------------------------------------------------------------------
404
460
  // Attachments
405
461
  // ------------------------------------------------------------------
406
- async uploadAttachment(taskId, file, filename) {
462
+ async uploadAttachment(file, filename) {
407
463
  const formData = new FormData();
408
464
  formData.append("file", file, filename);
409
465
  const headers = await this._resolveHeaders();
410
- const response = await this._fetch(this._makeUrl(`/tasks/${taskId}/attachments`), {
466
+ const response = await this._fetch(this._makeUrl("/attachment"), {
411
467
  method: "POST",
412
468
  headers: { ...headers },
413
469
  body: formData
@@ -429,11 +485,12 @@ var OrchestratorAsync = class {
429
485
  tokenCount: data.tokenCount ?? data.token_count ?? null
430
486
  };
431
487
  }
432
- async downloadAttachment(taskId, attachmentId) {
488
+ async downloadAttachment(attachmentId) {
433
489
  const headers = await this._resolveHeaders();
434
- const response = await this._fetch(this._makeUrl(`/tasks/${taskId}/attachments/${attachmentId}`), {
435
- headers
436
- });
490
+ const response = await this._fetch(
491
+ this._makeUrl(`/attachment/${attachmentId}`),
492
+ { headers }
493
+ );
437
494
  if (!response.ok) {
438
495
  throw new OrchestratorAPIError(
439
496
  `Attachment download failed: ${response.statusText}`,
@@ -445,224 +502,363 @@ var OrchestratorAsync = class {
445
502
  // ------------------------------------------------------------------
446
503
  // Interactive workflow
447
504
  // ------------------------------------------------------------------
448
- async sendInteractiveMessage(taskId, content) {
449
- const data = await this._post(`/tasks/${taskId}/interactive/message`, {
450
- content
451
- });
505
+ async sendInteractiveMessage(taskId, message, attachmentIds) {
506
+ const data = await this._post(
507
+ "/task/interactive/message",
508
+ { task_id: taskId, message, attachment_ids: attachmentIds }
509
+ );
452
510
  return { message: data.message ?? "" };
453
511
  }
454
512
  async markInteractiveComplete(taskId) {
455
- const data = await this._post(`/tasks/${taskId}/interactive/complete`);
513
+ const data = await this._post(
514
+ "/task/interactive/mark_complete",
515
+ { task_id: taskId }
516
+ );
456
517
  return { message: data.message ?? "" };
457
518
  }
458
519
  async markInteractiveFailed(taskId) {
459
- const data = await this._post(`/tasks/${taskId}/interactive/failed`);
520
+ const data = await this._post(
521
+ "/task/interactive/mark_failed",
522
+ { task_id: taskId }
523
+ );
460
524
  return { message: data.message ?? "" };
461
525
  }
462
- async approveInteractiveAction(taskId) {
463
- const data = await this._post(`/tasks/${taskId}/interactive/approve`);
526
+ async approveInteractiveAction(taskId, approved = true) {
527
+ const data = await this._post(
528
+ "/task/interactive/action",
529
+ { task_id: taskId, approved }
530
+ );
531
+ return { message: data.message ?? "" };
532
+ }
533
+ async stopInteractive(taskId) {
534
+ const data = await this._post(
535
+ "/task/interactive/stop",
536
+ { task_id: taskId }
537
+ );
464
538
  return { message: data.message ?? "" };
465
539
  }
466
540
  // ------------------------------------------------------------------
467
541
  // Proactive workflow
468
542
  // ------------------------------------------------------------------
469
- async sendProactiveGuide(taskId, guide) {
470
- const data = await this._post(`/tasks/${taskId}/proactive/guide`, {
471
- guide
472
- });
543
+ async sendProactiveGuide(taskId, message, attachmentIds) {
544
+ const data = await this._post(
545
+ "/task/proactive/guide",
546
+ { task_id: taskId, message, attachment_ids: attachmentIds }
547
+ );
473
548
  return { message: data.message ?? "" };
474
549
  }
475
550
  async respondProactiveHelp(taskId, response) {
476
- const data = await this._post(`/tasks/${taskId}/proactive/respond`, {
477
- response
478
- });
551
+ const data = await this._post(
552
+ "/task/proactive/help",
553
+ { task_id: taskId, response }
554
+ );
479
555
  return { message: data.message ?? "" };
480
556
  }
481
- async approveProactiveAction(taskId) {
482
- const data = await this._post(`/tasks/${taskId}/proactive/approve`);
557
+ async approveProactiveAction(taskId, approved = true) {
558
+ const data = await this._post(
559
+ "/task/proactive/action",
560
+ { task_id: taskId, approved }
561
+ );
483
562
  return { message: data.message ?? "" };
484
563
  }
485
564
  // ------------------------------------------------------------------
486
565
  // Ticket workflow
487
566
  // ------------------------------------------------------------------
488
- async sendTicketGuide(taskId, guide) {
489
- const data = await this._post(`/tasks/${taskId}/ticket/guide`, {
490
- guide
491
- });
567
+ async sendTicketGuide(taskId, message, attachmentIds) {
568
+ const data = await this._post(
569
+ "/task/ticket/guide",
570
+ { task_id: taskId, message, attachment_ids: attachmentIds }
571
+ );
492
572
  return { message: data.message ?? "" };
493
573
  }
494
574
  async respondTicketHelp(taskId, response) {
495
- const data = await this._post(`/tasks/${taskId}/ticket/respond`, {
496
- response
497
- });
575
+ const data = await this._post(
576
+ "/task/ticket/help",
577
+ { task_id: taskId, response }
578
+ );
498
579
  return { message: data.message ?? "" };
499
580
  }
500
- async approveTicketAction(taskId) {
501
- const data = await this._post(`/tasks/${taskId}/ticket/approve`);
581
+ async approveTicketAction(taskId, approved = true) {
582
+ const data = await this._post(
583
+ "/task/ticket/action",
584
+ { task_id: taskId, approved }
585
+ );
502
586
  return { message: data.message ?? "" };
503
587
  }
504
588
  async wakeTicket(taskId) {
505
- const data = await this._post(`/tasks/${taskId}/ticket/wake`);
589
+ const data = await this._post(
590
+ "/task/ticket/wake",
591
+ { task_id: taskId }
592
+ );
506
593
  return { message: data.message ?? "" };
507
594
  }
508
595
  // ------------------------------------------------------------------
509
596
  // Matrix workflow
510
597
  // ------------------------------------------------------------------
511
- async sendMatrixMessage(taskId, content) {
512
- const data = await this._post(`/tasks/${taskId}/matrix/message`, {
513
- content
514
- });
598
+ async sendMatrixMessage(taskId, message, attachmentIds) {
599
+ const data = await this._post(
600
+ "/task/matrix/message",
601
+ { task_id: taskId, message, attachment_ids: attachmentIds }
602
+ );
515
603
  return { message: data.message ?? "" };
516
604
  }
517
605
  async markMatrixComplete(taskId) {
518
- const data = await this._post(`/tasks/${taskId}/matrix/complete`);
606
+ const data = await this._post(
607
+ "/task/matrix/mark_complete",
608
+ { task_id: taskId }
609
+ );
519
610
  return { message: data.message ?? "" };
520
611
  }
521
612
  async markMatrixFailed(taskId) {
522
- const data = await this._post(`/tasks/${taskId}/matrix/failed`);
613
+ const data = await this._post(
614
+ "/task/matrix/mark_failed",
615
+ { task_id: taskId }
616
+ );
523
617
  return { message: data.message ?? "" };
524
618
  }
525
- async approveMatrixAction(taskId) {
526
- const data = await this._post(`/tasks/${taskId}/matrix/approve`);
619
+ async approveMatrixAction(taskId, approved = true) {
620
+ const data = await this._post(
621
+ "/task/matrix/action",
622
+ { task_id: taskId, approved }
623
+ );
527
624
  return { message: data.message ?? "" };
528
625
  }
529
- async getMatrixConversation(taskId) {
530
- const data = await this._get(`/tasks/${taskId}/matrix/conversation`);
626
+ async getMatrixConversation(taskId, phase, includeSummaries) {
627
+ const data = await this._get(
628
+ "/task/matrix/conversation",
629
+ {
630
+ task_id: taskId,
631
+ phase,
632
+ include_summaries: includeSummaries
633
+ }
634
+ );
531
635
  return {
532
636
  taskId: data.taskId ?? data.task_id ?? taskId,
533
- conversation: (data.conversation ?? []).map(
534
- (m) => m
535
- )
637
+ conversation: (data.conversation ?? []).map((m) => m)
536
638
  };
537
639
  }
538
640
  // ------------------------------------------------------------------
539
641
  // VSA workflow
540
642
  // ------------------------------------------------------------------
541
643
  async createVSATask(params) {
542
- const data = await this._post("/tasks/vsa", {
644
+ const body = {
645
+ user_id: params.userId,
543
646
  goal_prompt: params.goalPrompt,
544
647
  title: params.title,
545
- model_id: params.modelId
546
- });
648
+ agent_model_id: params.agentModelId,
649
+ orchestrator_model_id: params.orchestratorModelId,
650
+ attachment_ids: params.attachmentIds,
651
+ options: params.options
652
+ };
653
+ if (params.delegatedToken !== void 0) {
654
+ body.delegated_token = params.delegatedToken;
655
+ }
656
+ const data = await this._post(
657
+ "/task/vsa/create",
658
+ body
659
+ );
547
660
  return {
548
661
  taskId: data.taskId ?? data.task_id ?? "",
549
662
  status: data.status ?? ""
550
663
  };
551
664
  }
552
- async sendVSAMessage(taskId, content) {
553
- const data = await this._post(`/tasks/${taskId}/vsa/message`, {
554
- content
555
- });
665
+ async sendVSAMessage(taskId, message, options) {
666
+ const body = {
667
+ task_id: taskId,
668
+ message,
669
+ attachment_ids: options?.attachmentIds
670
+ };
671
+ if (options?.delegatedToken !== void 0) {
672
+ body.delegated_token = options.delegatedToken;
673
+ }
674
+ const data = await this._post(
675
+ "/task/vsa/message",
676
+ body
677
+ );
556
678
  return { message: data.message ?? "" };
557
679
  }
558
680
  async renameVSATask(taskId, title) {
559
- const data = await this._post(`/tasks/${taskId}/vsa/rename`, {
681
+ const data = await this._post("/task/vsa/rename", {
682
+ task_id: taskId,
560
683
  title
561
684
  });
562
685
  return { message: data.message ?? "" };
563
686
  }
564
687
  async regenerateVSATitle(taskId) {
565
- const data = await this._post(`/tasks/${taskId}/vsa/regenerate-title`);
688
+ const data = await this._post(
689
+ "/task/vsa/regenerate_title",
690
+ { task_id: taskId }
691
+ );
566
692
  return { message: data.message ?? "" };
567
693
  }
568
694
  async markVSAComplete(taskId) {
569
- const data = await this._post(`/tasks/${taskId}/vsa/complete`);
695
+ const data = await this._post(
696
+ "/task/vsa/mark_complete",
697
+ { task_id: taskId }
698
+ );
570
699
  return { message: data.message ?? "" };
571
700
  }
572
701
  async markVSAFailed(taskId) {
573
- const data = await this._post(`/tasks/${taskId}/vsa/failed`);
702
+ const data = await this._post(
703
+ "/task/vsa/mark_failed",
704
+ { task_id: taskId }
705
+ );
574
706
  return { message: data.message ?? "" };
575
707
  }
576
708
  async stopVSA(taskId) {
577
- const data = await this._post(`/tasks/${taskId}/vsa/stop`);
709
+ const data = await this._post("/task/vsa/stop", {
710
+ task_id: taskId
711
+ });
578
712
  return { message: data.message ?? "" };
579
713
  }
580
714
  async deleteVSA(taskId) {
581
- const data = await this._delete(`/tasks/${taskId}/vsa`);
715
+ const data = await this._post("/task/vsa/delete", {
716
+ task_id: taskId
717
+ });
582
718
  return { message: data.message ?? "" };
583
719
  }
584
- async listVSATasks(params) {
585
- const data = await this._get("/tasks/vsa", {
586
- status: params?.status,
720
+ async listVSATasks(userId, params) {
721
+ const data = await this._get("/task/vsa/list", {
722
+ user_id: userId,
587
723
  limit: params?.limit,
588
724
  offset: params?.offset
589
725
  });
590
- const tasks = (data.tasks ?? []).map(buildTaskSummary);
726
+ const tasks = (data.tasks ?? []).map(
727
+ buildTaskSummary
728
+ );
591
729
  return { tasks, pagination: buildPagination(data) };
592
730
  }
593
- async searchVSATasks(query) {
594
- const data = await this._get("/tasks/vsa/search", { q: query });
595
- const tasks = (data.tasks ?? []).map(buildTaskSummary);
731
+ async searchVSATasks(userId, query, limit) {
732
+ const data = await this._get("/task/vsa/search", {
733
+ user_id: userId,
734
+ query,
735
+ limit
736
+ });
737
+ const tasks = (data.tasks ?? []).map(
738
+ buildTaskSummary
739
+ );
596
740
  return { tasks, pagination: buildPagination(data) };
597
741
  }
598
742
  async deleteVSATasksBulk(taskIds) {
599
- const data = await this._post("/tasks/vsa/delete-bulk", {
600
- task_ids: taskIds
601
- });
602
- return { message: data.message ?? "" };
743
+ const data = await this._post(
744
+ "/task/vsa/delete_bulk",
745
+ { task_ids: taskIds }
746
+ );
747
+ return {
748
+ deletedTasks: data.deletedTasks ?? data.deleted_tasks ?? [],
749
+ failedTasks: data.failedTasks ?? data.failed_tasks ?? [],
750
+ totalDeleted: data.totalDeleted ?? data.total_deleted ?? 0,
751
+ totalFailed: data.totalFailed ?? data.total_failed ?? 0
752
+ };
603
753
  }
604
754
  // ------------------------------------------------------------------
605
- // MIO workflow
755
+ // MIO (self_managed) workflow
606
756
  // ------------------------------------------------------------------
607
- async sendMioMessage(taskId, content) {
608
- const data = await this._post(`/tasks/${taskId}/mio/message`, {
609
- content
610
- });
757
+ async sendMioMessage(taskId, message, attachmentIds) {
758
+ const data = await this._post(
759
+ "/task/self_managed/message",
760
+ { task_id: taskId, message, attachment_ids: attachmentIds }
761
+ );
611
762
  return { message: data.message ?? "" };
612
763
  }
613
- async approveMioAction(taskId) {
614
- const data = await this._post(`/tasks/${taskId}/mio/approve`);
764
+ async approveMioAction(taskId, approved = true, feedback) {
765
+ const data = await this._post(
766
+ "/task/self_managed/action",
767
+ { task_id: taskId, approved, feedback }
768
+ );
615
769
  return { message: data.message ?? "" };
616
770
  }
617
771
  async wakeMio(taskId) {
618
- const data = await this._post(`/tasks/${taskId}/mio/wake`);
772
+ const data = await this._post(
773
+ "/task/self_managed/wake",
774
+ { task_id: taskId }
775
+ );
619
776
  return { message: data.message ?? "" };
620
777
  }
621
778
  async sendMioUserAway(taskId) {
622
- const data = await this._post(`/tasks/${taskId}/mio/user-away`);
779
+ const data = await this._post(
780
+ "/task/self_managed/user_away",
781
+ { task_id: taskId }
782
+ );
623
783
  return { message: data.message ?? "" };
624
784
  }
625
785
  async markMioComplete(taskId) {
626
- const data = await this._post(`/tasks/${taskId}/mio/complete`);
786
+ const data = await this._post(
787
+ "/task/self_managed/mark_complete",
788
+ { task_id: taskId }
789
+ );
627
790
  return { message: data.message ?? "" };
628
791
  }
629
792
  async markMioFailed(taskId) {
630
- const data = await this._post(`/tasks/${taskId}/mio/failed`);
793
+ const data = await this._post(
794
+ "/task/self_managed/mark_failed",
795
+ { task_id: taskId }
796
+ );
631
797
  return { message: data.message ?? "" };
632
798
  }
633
799
  async archiveMio(taskId) {
634
- const data = await this._post(`/tasks/${taskId}/mio/archive`);
800
+ const data = await this._post(
801
+ "/task/self_managed/archive",
802
+ { task_id: taskId }
803
+ );
635
804
  return { message: data.message ?? "" };
636
805
  }
637
806
  async getMioContext(taskId) {
638
- const data = await this._get(`/tasks/${taskId}/mio/context`);
807
+ const data = await this._get(
808
+ "/task/self_managed/context",
809
+ { task_id: taskId }
810
+ );
639
811
  return {
640
812
  taskId: data.taskId ?? data.task_id ?? taskId,
813
+ modelId: data.modelId ?? data.model_id ?? "",
641
814
  currentTokens: data.currentTokens ?? data.current_tokens ?? 0,
642
815
  contextLimit: data.contextLimit ?? data.context_limit ?? 0,
643
816
  usagePercentage: data.usagePercentage ?? data.usage_percentage ?? 0,
644
- archivedCount: data.archivedCount ?? data.archived_count ?? 0,
645
- activeCount: data.activeCount ?? data.active_count ?? 0
817
+ totalMessages: data.totalMessages ?? data.total_messages ?? 0,
818
+ activeMessages: data.activeMessages ?? data.active_messages ?? 0,
819
+ archivedMessages: data.archivedMessages ?? data.archived_messages ?? 0,
820
+ messagesWithoutTokenCount: data.messagesWithoutTokenCount ?? data.messages_without_token_count ?? 0
821
+ };
822
+ }
823
+ async getMioMemories(taskId, includeCommon) {
824
+ const data = await this._get(
825
+ "/task/self_managed/memories",
826
+ { task_id: taskId, include_common: includeCommon }
827
+ );
828
+ return {
829
+ memories: data.memories ?? [],
830
+ total: data.total ?? 0
646
831
  };
647
832
  }
648
833
  // ------------------------------------------------------------------
649
834
  // Tools
650
835
  // ------------------------------------------------------------------
651
836
  async listTools() {
652
- const data = await this._get("/tools");
837
+ const data = await this._get("/tools/all");
653
838
  return {
654
- tools: (data.tools ?? data.tools ?? []).map(
839
+ tools: (data.tools ?? []).map(
655
840
  (t) => t
656
841
  ),
657
842
  totalTools: data.totalTools ?? data.total_tools ?? 0,
658
843
  servers: data.servers ?? []
659
844
  };
660
845
  }
846
+ async getToolCatalog() {
847
+ return this._get("/tools/catalog");
848
+ }
849
+ async refreshMCPTools() {
850
+ return this._post("/tools/mcp/refresh");
851
+ }
852
+ async validateToolCatalog() {
853
+ return this._get("/tools/validate");
854
+ }
661
855
  // ------------------------------------------------------------------
662
856
  // Debug / Admin
663
857
  // ------------------------------------------------------------------
664
858
  async getWorkflowStates() {
665
- const data = await this._get("/debug/workflow-states");
859
+ const data = await this._get(
860
+ "/debug/workflow_states"
861
+ );
666
862
  return {
667
863
  validStates: data.validStates ?? data.valid_states ?? {},
668
864
  processableStates: data.processableStates ?? data.processable_states ?? {},
@@ -672,79 +868,116 @@ var OrchestratorAsync = class {
672
868
  };
673
869
  }
674
870
  async updateTaskModels(taskId, models) {
675
- const data = await this._post(`/tasks/${taskId}/models`, {
676
- agent: models.agent,
677
- orchestrator: models.orchestrator
678
- });
871
+ const data = await this._post(
872
+ "/debug/task/models",
873
+ {
874
+ task_id: taskId,
875
+ agent_model_id: models.agentModelId,
876
+ orchestrator_model_id: models.orchestratorModelId
877
+ }
878
+ );
679
879
  return { message: data.message ?? "" };
680
880
  }
681
- async updateTaskIteration(taskId, iteration) {
682
- const data = await this._post(`/tasks/${taskId}/iteration`, {
683
- iteration
684
- });
881
+ async updateTaskIteration(taskId, iteration, maxIterations) {
882
+ const data = await this._post(
883
+ "/debug/task/iteration",
884
+ { task_id: taskId, iteration, max_iterations: maxIterations }
885
+ );
685
886
  return { message: data.message ?? "" };
686
887
  }
687
888
  async updateTaskWorkflowData(taskId, workflowData) {
688
- const data = await this._post(`/tasks/${taskId}/workflow-data`, {
689
- workflow_data: workflowData
690
- });
889
+ const data = await this._post(
890
+ "/debug/task/workflow_data",
891
+ { task_id: taskId, workflow_data: workflowData }
892
+ );
691
893
  return { message: data.message ?? "" };
692
894
  }
693
895
  async deleteMessage(taskId, messageId) {
694
- const data = await this._delete(
695
- `/tasks/${taskId}/conversation/messages/${messageId}`
896
+ const data = await this._post(
897
+ "/debug/task/message/delete",
898
+ { task_id: taskId, message_id: messageId }
696
899
  );
697
900
  return { message: data.message ?? "" };
698
901
  }
699
902
  async deleteMessages(taskId, messageIds) {
700
903
  const data = await this._post(
701
- `/tasks/${taskId}/conversation/messages/delete`,
702
- { message_ids: messageIds }
904
+ "/debug/task/message/delete/multiple",
905
+ { task_id: taskId, message_ids: messageIds }
703
906
  );
704
- return { message: data.message ?? "" };
907
+ return {
908
+ deletedIds: data.deletedIds ?? data.deleted_ids ?? [],
909
+ failedIds: data.failedIds ?? data.failed_ids ?? [],
910
+ totalDeleted: data.totalDeleted ?? data.total_deleted ?? 0,
911
+ totalFailed: data.totalFailed ?? data.total_failed ?? 0
912
+ };
705
913
  }
706
914
  async updateMessage(taskId, messageId, update) {
707
- const data = await this._put(
708
- `/tasks/${taskId}/conversation/messages/${messageId}`,
709
- update
915
+ const data = await this._post(
916
+ "/debug/task/message/update",
917
+ { task_id: taskId, message_id: messageId, ...update }
710
918
  );
711
919
  return { message: data.message ?? "" };
712
920
  }
713
921
  async resetMatrixToPhase(taskId, phase) {
714
922
  const data = await this._post(
715
- `/tasks/${taskId}/matrix/reset`,
716
- { phase }
923
+ "/debug/task/matrix/reset_to_phase",
924
+ { task_id: taskId, phase }
717
925
  );
718
926
  return { message: data.message ?? "" };
719
927
  }
720
- async getMessageTranslations(taskId, messageId, locale) {
721
- const params = {};
722
- if (locale) params.locale = locale;
928
+ async getMessageTranslations(taskId, messageId) {
723
929
  const data = await this._get(
724
- `/tasks/${taskId}/conversation/messages/${messageId}/translations`,
725
- params
930
+ `/debug/task/${taskId}/message/${messageId}/translations`
726
931
  );
727
932
  return {
728
933
  messageId: data.messageId ?? data.message_id ?? messageId,
729
- translations: (data.translations ?? []).map(
730
- (t) => t
731
- )
934
+ translations: (data.translations ?? []).map((t) => t)
732
935
  };
733
936
  }
734
937
  // ------------------------------------------------------------------
735
938
  // Error events
736
939
  // ------------------------------------------------------------------
737
940
  async listErrors(params) {
738
- const queryParams = {};
739
- if (params?.since) queryParams.since = params.since;
740
- if (params?.severity) queryParams.severity = params.severity;
741
- if (params?.source) queryParams.source = params.source;
742
- if (params?.limit) queryParams.limit = params.limit;
743
- if (params?.offset) queryParams.offset = params.offset;
744
- const data = await this._get("/errors", queryParams);
745
- return (data.errors ?? []).map(
746
- (e) => e
747
- );
941
+ const authHeaders = await this._resolveHeaders();
942
+ const url = new URL(this._makeUrl("/errors"));
943
+ if (params?.page !== void 0)
944
+ url.searchParams.set("page", String(params.page));
945
+ if (params?.limit !== void 0)
946
+ url.searchParams.set("limit", String(params.limit));
947
+ if (params?.taskId) url.searchParams.set("task_id", params.taskId);
948
+ if (params?.workflowId)
949
+ url.searchParams.set("workflow_id", params.workflowId);
950
+ if (params?.errorCode) url.searchParams.set("error_code", params.errorCode);
951
+ if (params?.exceptionType)
952
+ url.searchParams.set("exception_type", params.exceptionType);
953
+ if (params?.holderId) url.searchParams.set("holder_id", params.holderId);
954
+ if (params?.requestId) url.searchParams.set("request_id", params.requestId);
955
+ if (params?.search) url.searchParams.set("search", params.search);
956
+ if (params?.since) url.searchParams.set("since", params.since);
957
+ if (params?.until) url.searchParams.set("until", params.until);
958
+ if (params?.orderDirection)
959
+ url.searchParams.set("order_direction", params.orderDirection);
960
+ for (const s of params?.severity ?? []) {
961
+ url.searchParams.append("severity", s);
962
+ }
963
+ for (const s of params?.source ?? []) {
964
+ url.searchParams.append("source", s);
965
+ }
966
+ const response = await this._fetch(url.toString(), {
967
+ method: "GET",
968
+ headers: { ...authHeaders }
969
+ });
970
+ if (!response.ok) {
971
+ throw new OrchestratorAPIError(
972
+ `listErrors failed: ${response.statusText}`,
973
+ response.status
974
+ );
975
+ }
976
+ const data = await response.json();
977
+ return {
978
+ items: (data.items ?? data.errors ?? []).map((e) => e),
979
+ pagination: buildPagination(data)
980
+ };
748
981
  }
749
982
  async getErrorDetail(errorId) {
750
983
  return this._get(`/errors/${errorId}`);
@@ -769,13 +1002,13 @@ var OrchestratorAsync = class {
769
1002
  return this._get("/health");
770
1003
  }
771
1004
  async healthDetailed() {
772
- return this._get("/health/detail");
1005
+ return this._get("/health/detailed");
773
1006
  }
774
1007
  async ready() {
775
1008
  return this._get("/ready");
776
1009
  }
777
1010
  async healthLeader() {
778
- return this._get("/leader");
1011
+ return this._get("/health/leader");
779
1012
  }
780
1013
  async getMetrics(types) {
781
1014
  const params = {};
@@ -786,82 +1019,122 @@ var OrchestratorAsync = class {
786
1019
  // Configuration
787
1020
  // ------------------------------------------------------------------
788
1021
  async getSystemStatus() {
789
- return this._get("/config/status");
1022
+ return this._get("/configuration/system/status");
790
1023
  }
791
1024
  async updateSettings(settings) {
792
- return this._post("/config/settings", settings);
1025
+ return this._post("/configuration/system/settings", settings);
793
1026
  }
794
1027
  async getConfigurationStatus() {
795
- return this._get("/config");
1028
+ return this._get("/configuration/status");
796
1029
  }
797
1030
  async setAgentModel(model) {
798
- const data = await this._post("/config/models/agent", { model });
1031
+ const data = await this._post(
1032
+ "/configuration/agent",
1033
+ { model_name: model }
1034
+ );
799
1035
  return { message: data.message ?? "" };
800
1036
  }
801
1037
  async setOrchestratorModel(model) {
802
- const data = await this._post("/config/models/orchestrator", { model });
1038
+ const data = await this._post(
1039
+ "/configuration/orchestrator",
1040
+ { model_name: model }
1041
+ );
803
1042
  return { message: data.message ?? "" };
804
1043
  }
805
1044
  async getLLMBackendStatus() {
806
- return this._get("/config/llmbackends");
1045
+ return this._get(
1046
+ "/configuration/llmbackend/status"
1047
+ );
807
1048
  }
808
1049
  async addLLMBackend(host, apiKey) {
809
- const data = await this._post("/config/llmbackends", {
810
- host,
811
- api_key: apiKey
812
- });
1050
+ const data = await this._post(
1051
+ "/configuration/llmbackend/add",
1052
+ { backends: [{ url: host, api_key: apiKey }] }
1053
+ );
813
1054
  return { message: data.message ?? "" };
814
1055
  }
815
1056
  async removeLLMBackend(host) {
816
- const data = await this._delete(`/config/llmbackends/${encodeURIComponent(host)}`);
1057
+ const data = await this._post(
1058
+ "/configuration/llmbackend/remove",
1059
+ { host }
1060
+ );
817
1061
  return { message: data.message ?? "" };
818
1062
  }
819
1063
  async getMCPServerStatus() {
820
- return this._get("/config/mcpservers");
1064
+ return this._get(
1065
+ "/configuration/mcpserver/status"
1066
+ );
821
1067
  }
822
1068
  async addMCPServer(host, apiKey) {
823
- const data = await this._post("/config/mcpservers", {
824
- host,
825
- api_key: apiKey
826
- });
1069
+ const data = await this._post(
1070
+ "/configuration/mcpserver/add",
1071
+ { servers: [{ url: host, api_key: apiKey }] }
1072
+ );
827
1073
  return { message: data.message ?? "" };
828
1074
  }
829
1075
  async removeMCPServer(host) {
830
- const data = await this._delete(`/config/mcpservers/${encodeURIComponent(host)}`);
1076
+ const data = await this._post(
1077
+ "/configuration/mcpserver/remove",
1078
+ { host }
1079
+ );
831
1080
  return { message: data.message ?? "" };
832
1081
  }
833
1082
  async getTaskHandlerStatus() {
834
- return this._get("/config/taskhandler");
1083
+ return this._get("/configuration/taskhandler/status");
835
1084
  }
836
1085
  async getTaskHandlerStatusLocal() {
837
- return this._get("/config/taskhandler/local");
1086
+ return this._get(
1087
+ "/configuration/taskhandler/status/local"
1088
+ );
838
1089
  }
839
1090
  async setConcurrentTasksPerReplica(maxTasks) {
840
- const data = await this._post("/config/taskhandler/concurrency", {
841
- max_tasks: maxTasks
842
- });
1091
+ const data = await this._request(
1092
+ "POST",
1093
+ "/configuration/taskhandler/concurrent-per-replica",
1094
+ { params: { max_tasks: maxTasks } }
1095
+ );
843
1096
  return { message: data.message ?? "" };
844
1097
  }
845
1098
  async getSummaryWorkerStatus() {
846
- return this._get("/config/summary-worker");
1099
+ return this._get(
1100
+ "/configuration/summary-worker/status"
1101
+ );
847
1102
  }
848
1103
  async setCompactorModel(modelName) {
849
- const data = await this._post("/config/models/compactor", {
850
- model_name: modelName
851
- });
1104
+ const data = await this._post(
1105
+ "/configuration/summary-worker/model",
1106
+ { model_name: modelName }
1107
+ );
852
1108
  return { message: data.message ?? "" };
853
1109
  }
854
1110
  async setTranslateModel(modelName) {
855
- const data = await this._post("/config/models/translate", {
856
- model_name: modelName
857
- });
1111
+ const data = await this._post(
1112
+ "/configuration/summary-worker/translate-model",
1113
+ { model_name: modelName }
1114
+ );
858
1115
  return { message: data.message ?? "" };
859
1116
  }
860
1117
  async getTokenWorkerStatus() {
861
- return this._get("/config/token-worker");
1118
+ return this._get("/configuration/token-worker/status");
862
1119
  }
863
1120
  async getSlotsStatus() {
864
- return this._get("/config/slots");
1121
+ return this._get("/configuration/slots/status");
1122
+ }
1123
+ async getSubagentsStatus() {
1124
+ return this._get("/configuration/subagents/status");
1125
+ }
1126
+ async setSubagentsEnabled(enabled) {
1127
+ const data = await this._post(
1128
+ "/configuration/subagents",
1129
+ { enabled }
1130
+ );
1131
+ return { message: data.message ?? "" };
1132
+ }
1133
+ async reloadServices() {
1134
+ return this._post("/configuration/reload");
1135
+ }
1136
+ async getReloadStatus() {
1137
+ return this._get("/configuration/reload/status");
865
1138
  }
866
1139
  // ------------------------------------------------------------------
867
1140
  // Auth / WebSocket status
@@ -877,10 +1150,13 @@ var OrchestratorAsync = class {
877
1150
  // ------------------------------------------------------------------
878
1151
  async *streamTaskStatus(taskId) {
879
1152
  const headers = await this._resolveHeaders();
880
- headers["Accept"] = "text/event-stream";
881
- const response = await this._fetch(this._makeUrl(`/tasks/${taskId}/stream`), {
882
- headers
883
- });
1153
+ headers.Accept = "text/event-stream";
1154
+ const response = await this._fetch(
1155
+ this._makeUrl(
1156
+ `/task/stream_status?task_id=${encodeURIComponent(taskId)}`
1157
+ ),
1158
+ { headers }
1159
+ );
884
1160
  if (!response.ok) {
885
1161
  throw new OrchestratorAPIError(
886
1162
  `Stream connection failed: ${response.statusText}`,
@@ -920,7 +1196,9 @@ function combineSignals(...signals) {
920
1196
  controller.abort(signal.reason);
921
1197
  return controller.signal;
922
1198
  }
923
- signal.addEventListener("abort", () => controller.abort(signal.reason), { once: true });
1199
+ signal.addEventListener("abort", () => controller.abort(signal.reason), {
1200
+ once: true
1201
+ });
924
1202
  }
925
1203
  return controller.signal;
926
1204
  }
@@ -944,11 +1222,14 @@ var Orchestrator = class {
944
1222
  createTask(params) {
945
1223
  return runSync(this._async.createTask(params));
946
1224
  }
947
- getTaskStatus(taskId) {
948
- return runSync(this._async.getTaskStatus(taskId));
1225
+ getTaskStatus(taskId, locale) {
1226
+ return runSync(this._async.getTaskStatus(taskId, locale));
949
1227
  }
950
- getTaskConversation(taskId) {
951
- return runSync(this._async.getTaskConversation(taskId));
1228
+ setTaskStatus(taskId, status) {
1229
+ return runSync(this._async.setTaskStatus(taskId, status));
1230
+ }
1231
+ getTaskConversation(taskId, params) {
1232
+ return runSync(this._async.getTaskConversation(taskId, params));
952
1233
  }
953
1234
  getArchivedMessageContent(taskId, messageId) {
954
1235
  return runSync(this._async.getArchivedMessageContent(taskId, messageId));
@@ -971,17 +1252,19 @@ var Orchestrator = class {
971
1252
  // ------------------------------------------------------------------
972
1253
  // Attachments
973
1254
  // ------------------------------------------------------------------
974
- uploadAttachment(taskId, file, filename) {
975
- return runSync(this._async.uploadAttachment(taskId, file, filename));
1255
+ uploadAttachment(file, filename) {
1256
+ return runSync(this._async.uploadAttachment(file, filename));
976
1257
  }
977
- downloadAttachment(taskId, attachmentId) {
978
- return runSync(this._async.downloadAttachment(taskId, attachmentId));
1258
+ downloadAttachment(attachmentId) {
1259
+ return runSync(this._async.downloadAttachment(attachmentId));
979
1260
  }
980
1261
  // ------------------------------------------------------------------
981
1262
  // Interactive workflow
982
1263
  // ------------------------------------------------------------------
983
- sendInteractiveMessage(taskId, content) {
984
- return runSync(this._async.sendInteractiveMessage(taskId, content));
1264
+ sendInteractiveMessage(taskId, message, attachmentIds) {
1265
+ return runSync(
1266
+ this._async.sendInteractiveMessage(taskId, message, attachmentIds)
1267
+ );
985
1268
  }
986
1269
  markInteractiveComplete(taskId) {
987
1270
  return runSync(this._async.markInteractiveComplete(taskId));
@@ -989,32 +1272,37 @@ var Orchestrator = class {
989
1272
  markInteractiveFailed(taskId) {
990
1273
  return runSync(this._async.markInteractiveFailed(taskId));
991
1274
  }
992
- approveInteractiveAction(taskId) {
993
- return runSync(this._async.approveInteractiveAction(taskId));
1275
+ approveInteractiveAction(taskId, approved = true) {
1276
+ return runSync(this._async.approveInteractiveAction(taskId, approved));
1277
+ }
1278
+ stopInteractive(taskId) {
1279
+ return runSync(this._async.stopInteractive(taskId));
994
1280
  }
995
1281
  // ------------------------------------------------------------------
996
1282
  // Proactive workflow
997
1283
  // ------------------------------------------------------------------
998
- sendProactiveGuide(taskId, guide) {
999
- return runSync(this._async.sendProactiveGuide(taskId, guide));
1284
+ sendProactiveGuide(taskId, message, attachmentIds) {
1285
+ return runSync(
1286
+ this._async.sendProactiveGuide(taskId, message, attachmentIds)
1287
+ );
1000
1288
  }
1001
1289
  respondProactiveHelp(taskId, response) {
1002
1290
  return runSync(this._async.respondProactiveHelp(taskId, response));
1003
1291
  }
1004
- approveProactiveAction(taskId) {
1005
- return runSync(this._async.approveProactiveAction(taskId));
1292
+ approveProactiveAction(taskId, approved = true) {
1293
+ return runSync(this._async.approveProactiveAction(taskId, approved));
1006
1294
  }
1007
1295
  // ------------------------------------------------------------------
1008
1296
  // Ticket workflow
1009
1297
  // ------------------------------------------------------------------
1010
- sendTicketGuide(taskId, guide) {
1011
- return runSync(this._async.sendTicketGuide(taskId, guide));
1298
+ sendTicketGuide(taskId, message, attachmentIds) {
1299
+ return runSync(this._async.sendTicketGuide(taskId, message, attachmentIds));
1012
1300
  }
1013
1301
  respondTicketHelp(taskId, response) {
1014
1302
  return runSync(this._async.respondTicketHelp(taskId, response));
1015
1303
  }
1016
- approveTicketAction(taskId) {
1017
- return runSync(this._async.approveTicketAction(taskId));
1304
+ approveTicketAction(taskId, approved = true) {
1305
+ return runSync(this._async.approveTicketAction(taskId, approved));
1018
1306
  }
1019
1307
  wakeTicket(taskId) {
1020
1308
  return runSync(this._async.wakeTicket(taskId));
@@ -1022,8 +1310,10 @@ var Orchestrator = class {
1022
1310
  // ------------------------------------------------------------------
1023
1311
  // Matrix workflow
1024
1312
  // ------------------------------------------------------------------
1025
- sendMatrixMessage(taskId, content) {
1026
- return runSync(this._async.sendMatrixMessage(taskId, content));
1313
+ sendMatrixMessage(taskId, message, attachmentIds) {
1314
+ return runSync(
1315
+ this._async.sendMatrixMessage(taskId, message, attachmentIds)
1316
+ );
1027
1317
  }
1028
1318
  markMatrixComplete(taskId) {
1029
1319
  return runSync(this._async.markMatrixComplete(taskId));
@@ -1031,11 +1321,13 @@ var Orchestrator = class {
1031
1321
  markMatrixFailed(taskId) {
1032
1322
  return runSync(this._async.markMatrixFailed(taskId));
1033
1323
  }
1034
- approveMatrixAction(taskId) {
1035
- return runSync(this._async.approveMatrixAction(taskId));
1324
+ approveMatrixAction(taskId, approved = true) {
1325
+ return runSync(this._async.approveMatrixAction(taskId, approved));
1036
1326
  }
1037
- getMatrixConversation(taskId) {
1038
- return runSync(this._async.getMatrixConversation(taskId));
1327
+ getMatrixConversation(taskId, phase, includeSummaries) {
1328
+ return runSync(
1329
+ this._async.getMatrixConversation(taskId, phase, includeSummaries)
1330
+ );
1039
1331
  }
1040
1332
  // ------------------------------------------------------------------
1041
1333
  // VSA workflow
@@ -1043,8 +1335,8 @@ var Orchestrator = class {
1043
1335
  createVSATask(params) {
1044
1336
  return runSync(this._async.createVSATask(params));
1045
1337
  }
1046
- sendVSAMessage(taskId, content) {
1047
- return runSync(this._async.sendVSAMessage(taskId, content));
1338
+ sendVSAMessage(taskId, message, options) {
1339
+ return runSync(this._async.sendVSAMessage(taskId, message, options));
1048
1340
  }
1049
1341
  renameVSATask(taskId, title) {
1050
1342
  return runSync(this._async.renameVSATask(taskId, title));
@@ -1064,23 +1356,23 @@ var Orchestrator = class {
1064
1356
  deleteVSA(taskId) {
1065
1357
  return runSync(this._async.deleteVSA(taskId));
1066
1358
  }
1067
- listVSATasks(params) {
1068
- return runSync(this._async.listVSATasks(params));
1359
+ listVSATasks(userId, params) {
1360
+ return runSync(this._async.listVSATasks(userId, params));
1069
1361
  }
1070
- searchVSATasks(query) {
1071
- return runSync(this._async.searchVSATasks(query));
1362
+ searchVSATasks(userId, query, limit) {
1363
+ return runSync(this._async.searchVSATasks(userId, query, limit));
1072
1364
  }
1073
1365
  deleteVSATasksBulk(taskIds) {
1074
1366
  return runSync(this._async.deleteVSATasksBulk(taskIds));
1075
1367
  }
1076
1368
  // ------------------------------------------------------------------
1077
- // MIO workflow
1369
+ // MIO (self_managed) workflow
1078
1370
  // ------------------------------------------------------------------
1079
- sendMioMessage(taskId, content) {
1080
- return runSync(this._async.sendMioMessage(taskId, content));
1371
+ sendMioMessage(taskId, message, attachmentIds) {
1372
+ return runSync(this._async.sendMioMessage(taskId, message, attachmentIds));
1081
1373
  }
1082
- approveMioAction(taskId) {
1083
- return runSync(this._async.approveMioAction(taskId));
1374
+ approveMioAction(taskId, approved = true, feedback) {
1375
+ return runSync(this._async.approveMioAction(taskId, approved, feedback));
1084
1376
  }
1085
1377
  wakeMio(taskId) {
1086
1378
  return runSync(this._async.wakeMio(taskId));
@@ -1100,12 +1392,24 @@ var Orchestrator = class {
1100
1392
  getMioContext(taskId) {
1101
1393
  return runSync(this._async.getMioContext(taskId));
1102
1394
  }
1395
+ getMioMemories(taskId, includeCommon) {
1396
+ return runSync(this._async.getMioMemories(taskId, includeCommon));
1397
+ }
1103
1398
  // ------------------------------------------------------------------
1104
1399
  // Tools
1105
1400
  // ------------------------------------------------------------------
1106
1401
  listTools() {
1107
1402
  return runSync(this._async.listTools());
1108
1403
  }
1404
+ getToolCatalog() {
1405
+ return runSync(this._async.getToolCatalog());
1406
+ }
1407
+ refreshMCPTools() {
1408
+ return runSync(this._async.refreshMCPTools());
1409
+ }
1410
+ validateToolCatalog() {
1411
+ return runSync(this._async.validateToolCatalog());
1412
+ }
1109
1413
  // ------------------------------------------------------------------
1110
1414
  // Debug / Admin
1111
1415
  // ------------------------------------------------------------------
@@ -1115,8 +1419,10 @@ var Orchestrator = class {
1115
1419
  updateTaskModels(taskId, models) {
1116
1420
  return runSync(this._async.updateTaskModels(taskId, models));
1117
1421
  }
1118
- updateTaskIteration(taskId, iteration) {
1119
- return runSync(this._async.updateTaskIteration(taskId, iteration));
1422
+ updateTaskIteration(taskId, iteration, maxIterations) {
1423
+ return runSync(
1424
+ this._async.updateTaskIteration(taskId, iteration, maxIterations)
1425
+ );
1120
1426
  }
1121
1427
  updateTaskWorkflowData(taskId, workflowData) {
1122
1428
  return runSync(this._async.updateTaskWorkflowData(taskId, workflowData));
@@ -1133,8 +1439,8 @@ var Orchestrator = class {
1133
1439
  resetMatrixToPhase(taskId, phase) {
1134
1440
  return runSync(this._async.resetMatrixToPhase(taskId, phase));
1135
1441
  }
1136
- getMessageTranslations(taskId, messageId, locale) {
1137
- return runSync(this._async.getMessageTranslations(taskId, messageId, locale));
1442
+ getMessageTranslations(taskId, messageId) {
1443
+ return runSync(this._async.getMessageTranslations(taskId, messageId));
1138
1444
  }
1139
1445
  // ------------------------------------------------------------------
1140
1446
  // Error events
@@ -1232,6 +1538,18 @@ var Orchestrator = class {
1232
1538
  getSlotsStatus() {
1233
1539
  return runSync(this._async.getSlotsStatus());
1234
1540
  }
1541
+ getSubagentsStatus() {
1542
+ return runSync(this._async.getSubagentsStatus());
1543
+ }
1544
+ setSubagentsEnabled(enabled) {
1545
+ return runSync(this._async.setSubagentsEnabled(enabled));
1546
+ }
1547
+ reloadServices() {
1548
+ return runSync(this._async.reloadServices());
1549
+ }
1550
+ getReloadStatus() {
1551
+ return runSync(this._async.getReloadStatus());
1552
+ }
1235
1553
  // ------------------------------------------------------------------
1236
1554
  // Auth / WebSocket status
1237
1555
  // ------------------------------------------------------------------
@@ -1403,11 +1721,15 @@ var RealtimeClient = class {
1403
1721
  this._socket.on("disconnect", () => {
1404
1722
  this._connected = false;
1405
1723
  });
1724
+ this._socket.on("message", (payload) => this._dispatch(payload));
1406
1725
  return new Promise((resolve, reject) => {
1407
- const socket = this._socket;
1408
- socket.on("connect", () => resolve());
1409
- socket.on("connect_error", (err) => reject(err));
1410
- if (socket.connected) {
1726
+ if (!this._socket) {
1727
+ reject(new Error("RealtimeClient not connected"));
1728
+ return;
1729
+ }
1730
+ this._socket.on("connect", () => resolve());
1731
+ this._socket.on("connect_error", (err) => reject(err));
1732
+ if (this._socket.connected) {
1411
1733
  resolve();
1412
1734
  }
1413
1735
  });
@@ -1419,48 +1741,132 @@ var RealtimeClient = class {
1419
1741
  }
1420
1742
  this._connected = false;
1421
1743
  }
1744
+ /**
1745
+ * Dispatch a message envelope to registered handlers.
1746
+ * The server sends: socket.emit("message", {type: "message", event: {..., event_type: "...", ...}})
1747
+ */
1748
+ _dispatch(payload) {
1749
+ const envelope = payload;
1750
+ const event = envelope.event ?? envelope;
1751
+ const eventType = event.event_type;
1752
+ if (!eventType) return;
1753
+ const handlers = this._handlers.get(eventType);
1754
+ if (handlers) {
1755
+ for (const h of handlers) {
1756
+ h(event);
1757
+ }
1758
+ }
1759
+ }
1422
1760
  /**
1423
1761
  * Subscribe to realtime events for a specific task.
1762
+ * Emits a `join` event with `{rooms: ["task:{taskId}"]}`.
1424
1763
  */
1425
- async subscribeTask(taskId) {
1764
+ subscribeTask(taskId) {
1426
1765
  if (!this._socket) throw new Error("RealtimeClient not connected");
1427
- return new Promise((resolve, reject) => {
1428
- this._socket.emit("subscribe", { task_id: taskId }, (response) => {
1429
- if (response.ok) resolve();
1430
- else reject(new Error(response.error ?? "Subscription failed"));
1431
- });
1432
- });
1766
+ this._socket.emit("join", { rooms: [`task:${taskId}`] });
1433
1767
  }
1434
1768
  /**
1435
1769
  * Unsubscribe from realtime events for a specific task.
1770
+ * Emits a `leave` event with `{rooms: ["task:{taskId}"]}`.
1436
1771
  */
1437
- async unsubscribeTask(taskId) {
1772
+ unsubscribeTask(taskId) {
1438
1773
  if (!this._socket) throw new Error("RealtimeClient not connected");
1439
- return new Promise((resolve, reject) => {
1440
- this._socket.emit("unsubscribe", { task_id: taskId }, (response) => {
1441
- if (response.ok) resolve();
1442
- else reject(new Error(response.error ?? "Unsubscription failed"));
1443
- });
1444
- });
1774
+ this._socket.emit("leave", { rooms: [`task:${taskId}`] });
1775
+ }
1776
+ /**
1777
+ * Subscribe to event-type-scoped rooms.
1778
+ * e.g. subscribeEvents("task_created", "task_deleted")
1779
+ */
1780
+ subscribeEvents(...eventTypes) {
1781
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1782
+ const rooms = eventTypes.map((t) => `event:${t}`);
1783
+ this._socket.emit("join", { rooms });
1784
+ }
1785
+ /**
1786
+ * Unsubscribe from event-type-scoped rooms.
1787
+ */
1788
+ unsubscribeEvents(...eventTypes) {
1789
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1790
+ const rooms = eventTypes.map((t) => `event:${t}`);
1791
+ this._socket.emit("leave", { rooms });
1792
+ }
1793
+ /**
1794
+ * Subscribe to the `all` broadcast room (receives all events).
1795
+ */
1796
+ subscribeAll() {
1797
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1798
+ this._socket.emit("join", { rooms: ["all"] });
1799
+ }
1800
+ /**
1801
+ * Subscribe to a locale-specific room.
1802
+ */
1803
+ subscribeLocale(locale) {
1804
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1805
+ this._socket.emit("join", { rooms: [`locale:${locale}`] });
1806
+ }
1807
+ /**
1808
+ * Unsubscribe from a locale-specific room.
1809
+ */
1810
+ unsubscribeLocale(locale) {
1811
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1812
+ this._socket.emit("leave", { rooms: [`locale:${locale}`] });
1813
+ }
1814
+ /**
1815
+ * Join arbitrary rooms by name.
1816
+ */
1817
+ joinRooms(rooms) {
1818
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1819
+ this._socket.emit("join", { rooms });
1820
+ }
1821
+ /**
1822
+ * Leave arbitrary rooms by name.
1823
+ */
1824
+ leaveRooms(rooms) {
1825
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1826
+ this._socket.emit("leave", { rooms });
1827
+ }
1828
+ /**
1829
+ * Send a ping to the server.
1830
+ */
1831
+ ping() {
1832
+ if (!this._socket) throw new Error("RealtimeClient not connected");
1833
+ this._socket.emit("ping");
1445
1834
  }
1446
1835
  /**
1447
1836
  * Register a handler for a specific event type.
1837
+ *
1838
+ * Domain events (task_created, task_status_changed, etc.) are dispatched
1839
+ * via the message envelope. Raw socket events (connect, disconnect,
1840
+ * connection_established, rooms_updated, pong) are wired directly.
1448
1841
  */
1449
1842
  on(event, handler) {
1450
1843
  if (!this._handlers.has(event)) {
1451
1844
  this._handlers.set(event, /* @__PURE__ */ new Set());
1452
1845
  if (this._socket) {
1453
- this._socket.on(event, (...args) => {
1454
- const handlers = this._handlers.get(event);
1455
- if (handlers) {
1456
- for (const h of handlers) {
1457
- h(...args);
1846
+ const rawSocketEvents = /* @__PURE__ */ new Set([
1847
+ "connect",
1848
+ "disconnect",
1849
+ "connect_error",
1850
+ "connection_established",
1851
+ "rooms_updated",
1852
+ "pong"
1853
+ ]);
1854
+ if (rawSocketEvents.has(event)) {
1855
+ this._socket.on(event, (...args) => {
1856
+ const handlers2 = this._handlers.get(event);
1857
+ if (handlers2) {
1858
+ for (const h of handlers2) {
1859
+ h(...args);
1860
+ }
1458
1861
  }
1459
- }
1460
- });
1862
+ });
1863
+ }
1461
1864
  }
1462
1865
  }
1463
- this._handlers.get(event).add(handler);
1866
+ const handlers = this._handlers.get(event);
1867
+ if (handlers) {
1868
+ handlers.add(handler);
1869
+ }
1464
1870
  }
1465
1871
  /**
1466
1872
  * Remove a registered handler.
@@ -1482,12 +1888,11 @@ var RealtimeClient = class {
1482
1888
  */
1483
1889
  wait() {
1484
1890
  return new Promise((resolve) => {
1485
- const socket = this._socket;
1486
- if (!socket) {
1891
+ if (!this._socket) {
1487
1892
  resolve();
1488
1893
  return;
1489
1894
  }
1490
- socket.on("disconnect", () => resolve());
1895
+ this._socket.on("disconnect", () => resolve());
1491
1896
  });
1492
1897
  }
1493
1898
  };