@skrr-ai/cli 0.1.202 → 0.1.206

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.
Files changed (71) hide show
  1. package/bin/dev-fallback.js +47 -29
  2. package/bin/dev.cjs +6 -0
  3. package/dist/base-command.js +1 -1
  4. package/dist/commands/agent/message/context.d.ts +3 -0
  5. package/dist/commands/agent/message/context.js +33 -1
  6. package/dist/commands/agent/message/no-reply.d.ts +17 -0
  7. package/dist/commands/agent/message/no-reply.js +54 -0
  8. package/dist/commands/agent/message/retract.d.ts +24 -0
  9. package/dist/commands/agent/message/retract.js +167 -0
  10. package/dist/commands/agent/message/send.d.ts +53 -3
  11. package/dist/commands/agent/message/send.js +148 -4
  12. package/dist/commands/agents/chat.d.ts +12 -0
  13. package/dist/commands/agents/chat.js +258 -25
  14. package/dist/commands/agents/manager/status.d.ts +9 -0
  15. package/dist/commands/agents/manager/status.js +84 -0
  16. package/dist/commands/agents/queue/clear.d.ts +13 -0
  17. package/dist/commands/agents/queue/clear.js +31 -0
  18. package/dist/commands/agents/queue/list.d.ts +10 -0
  19. package/dist/commands/agents/queue/list.js +34 -0
  20. package/dist/commands/agents/queue/move.d.ts +16 -0
  21. package/dist/commands/agents/queue/move.js +33 -0
  22. package/dist/commands/agents/queue/pause.d.ts +7 -0
  23. package/dist/commands/agents/queue/pause.js +24 -0
  24. package/dist/commands/agents/queue/resume.d.ts +7 -0
  25. package/dist/commands/agents/queue/resume.js +24 -0
  26. package/dist/commands/agents/queue/steer.d.ts +14 -0
  27. package/dist/commands/agents/queue/steer.js +38 -0
  28. package/dist/commands/agents/queue/withdraw.d.ts +10 -0
  29. package/dist/commands/agents/queue/withdraw.js +27 -0
  30. package/dist/commands/agents/supervision.d.ts +1 -0
  31. package/dist/commands/agents/supervision.js +28 -9
  32. package/dist/commands/convos/transcript.d.ts +48 -0
  33. package/dist/commands/convos/transcript.js +461 -0
  34. package/dist/commands/duties/advance-next.d.ts +17 -0
  35. package/dist/commands/duties/advance-next.js +122 -0
  36. package/dist/commands/duties/pack/plan.js +45 -0
  37. package/dist/commands/duties/preflight.d.ts +1 -0
  38. package/dist/commands/duties/preflight.js +18 -2
  39. package/dist/commands/spaces/auto-executor/preview.js +6 -2
  40. package/dist/commands/spaces/charter/revise.d.ts +16 -0
  41. package/dist/commands/spaces/charter/revise.js +84 -0
  42. package/dist/commands/spaces/skills/propose.d.ts +1 -0
  43. package/dist/commands/spaces/skills/propose.js +5 -0
  44. package/dist/commands/tasks/create.js +16 -1
  45. package/dist/commands/tasks/result/show.js +6 -3
  46. package/dist/commands/tasks/start.d.ts +3 -0
  47. package/dist/commands/tasks/start.js +12 -1
  48. package/dist/commands/triggers/capabilities.js +14 -4
  49. package/dist/generated/agent-guides.json +258 -24
  50. package/dist/lib/agent-chat-queue-command.d.ts +29 -0
  51. package/dist/lib/agent-chat-queue-command.js +75 -0
  52. package/dist/lib/agent-chat-queue.d.ts +77 -0
  53. package/dist/lib/agent-chat-queue.js +245 -0
  54. package/dist/lib/agent-chat-start.d.ts +101 -0
  55. package/dist/lib/agent-chat-start.js +151 -6
  56. package/dist/lib/duties.d.ts +5 -1
  57. package/dist/lib/duties.js +16 -5
  58. package/dist/lib/duty-product.js +6 -0
  59. package/dist/lib/input-queue.d.ts +18 -0
  60. package/dist/lib/input-queue.js +59 -0
  61. package/dist/lib/message-intent.d.ts +26 -3
  62. package/dist/lib/message-intent.js +7 -1
  63. package/dist/lib/task-runtime-headers.d.ts +5 -0
  64. package/dist/lib/task-runtime-headers.js +28 -8
  65. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.d.ts +16 -15
  66. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.js +0 -22
  67. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.d.ts +16 -15
  68. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.js +0 -22
  69. package/dist/node_modules/@skrr-ai/data-provider/index.js +11690 -11370
  70. package/oclif.manifest.json +1635 -332
  71. package/package.json +10 -4
@@ -28,6 +28,7 @@ const agent_chat_start_1 = require("../../lib/agent-chat-start");
28
28
  const agent_home_workspace_1 = require("../../lib/agent-home-workspace");
29
29
  const agentic_stream_1 = require("../../lib/agentic-stream");
30
30
  const web_url_1 = require("../../lib/web-url");
31
+ const agent_chat_queue_1 = require("../../lib/agent-chat-queue");
31
32
  const local_skills_1 = require("../../lib/local-skills");
32
33
  /**
33
34
  * Exit code for a run the USER stopped watching, by pressing Ctrl-C.
@@ -144,7 +145,9 @@ function jsonlTextForm(flags) {
144
145
  */
145
146
  function cancelledRunMessage(input) {
146
147
  return (`Run ${input.sessionId} cancelled: the server confirmed it ended.` +
147
- (input.conversationId ? ` Continue the conversation with --conversation ${input.conversationId}.` : ''));
148
+ (input.conversationId
149
+ ? ` Continue the conversation with --conversation ${input.conversationId}.`
150
+ : ''));
148
151
  }
149
152
  /**
150
153
  * What the durable record says about a turn, read from its messages.
@@ -165,8 +168,11 @@ function reconcileTerminalFromMessages(messages, responseMessageId) {
165
168
  if (!row)
166
169
  return null;
167
170
  const projection = row.metadata && typeof row.metadata === 'object'
168
- ? row.metadata.publicProjection : undefined;
169
- const publicProjection = (0, data_provider_1.isDecodedPublicProjection)(projection) ? { publicProjection: projection } : {};
171
+ ? row.metadata.publicProjection
172
+ : undefined;
173
+ const publicProjection = (0, data_provider_1.isDecodedPublicProjection)(projection)
174
+ ? { publicProjection: projection }
175
+ : {};
170
176
  const failure = (0, data_provider_1.resolveMessageFailure)(row);
171
177
  if (failure) {
172
178
  return {
@@ -225,8 +231,11 @@ function handoverStateFromMessages(messages, responseMessageId) {
225
231
  if (!row)
226
232
  return { state: 'pending' };
227
233
  const projection = row.metadata && typeof row.metadata === 'object'
228
- ? row.metadata.publicProjection : undefined;
229
- const publicProjection = (0, data_provider_1.isDecodedPublicProjection)(projection) ? { publicProjection: projection } : {};
234
+ ? row.metadata.publicProjection
235
+ : undefined;
236
+ const publicProjection = (0, data_provider_1.isDecodedPublicProjection)(projection)
237
+ ? { publicProjection: projection }
238
+ : {};
230
239
  const failure = (0, data_provider_1.resolveMessageFailure)(row);
231
240
  if (failure) {
232
241
  if (agenticErrorSubtype(row) === agentic_stream_1.DAEMON_HANDOVER_REASON)
@@ -337,7 +346,8 @@ function admittedRouting(runtime) {
337
346
  const routing = {
338
347
  ...(typeof selectedKind === 'string' && selectedKind ? { selectedKind } : {}),
339
348
  ...(typeof selectedExecutionSelector === 'string' && selectedExecutionSelector
340
- ? { selectedExecutionSelector } : {}),
349
+ ? { selectedExecutionSelector }
350
+ : {}),
341
351
  ...(typeof fallbackUsed === 'boolean' ? { fallbackUsed } : {}),
342
352
  };
343
353
  return Object.keys(routing).length ? routing : undefined;
@@ -455,7 +465,10 @@ class AgentsChat extends base_command_1.BaseCommand {
455
465
  static flags = {
456
466
  prompt: core_1.Flags.string({ description: 'Prompt to send to the agent', required: true }),
457
467
  context: core_1.Flags.string({ description: 'Additional context for the turn' }),
458
- conversation: core_1.Flags.string({ description: 'Existing conversation ID; defaults to a new turn' }),
468
+ conversation: core_1.Flags.string({
469
+ description: 'Existing conversation ID. A normal turn without a chat target opens a standalone conversation. ' +
470
+ 'For Main Chat, use agentChat.activeConversationId from `skrr dm show <agent-id> --json`.',
471
+ }),
459
472
  'thread-root': core_1.Flags.string({
460
473
  description: 'Open/reply in the Agent Chat Thread rooted at this main-message ID. Mutually exclusive with --conversation.',
461
474
  }),
@@ -525,7 +538,8 @@ class AgentsChat extends base_command_1.BaseCommand {
525
538
  'the machine finished; `run.failed` with `handover.outcome: "machine_failed"` and the ' +
526
539
  'machine\'s reason when it did not; or `run.failed` with `handover.outcome: "expired"` ' +
527
540
  'and the original failure when --repair-wait ran out (exit 1 for both). Ctrl-C during ' +
528
- 'the wait emits `run.detached` with `handedOver: true` and exits 130. Whenever a run ' +
541
+ 'the wait emits `run.detached` with `handedOver: true` and exits 130. A confirmed ' +
542
+ 'Ctrl-C cancellation emits `run.result` with `status: "aborted"` and exits 130. Whenever a run ' +
529
543
  'fails, `run.failed` carries `message`, the reason in words as the platform gave it (the ' +
530
544
  'same sentence a terminal prints after `Error:`), beside the short `reason`.',
531
545
  }),
@@ -533,12 +547,45 @@ class AgentsChat extends base_command_1.BaseCommand {
533
547
  description: 'Emit the final one-shot response as JSON (use with --no-stream)',
534
548
  }),
535
549
  'idempotency-key': core_1.Flags.string({
536
- description: 'Name this start (' + agent_chat_start_1.START_KEY_RULE + '). The CLI already names every start and, when ' +
550
+ description: 'Name this start (' +
551
+ agent_chat_start_1.START_KEY_RULE +
552
+ '). The CLI already names every start and, when ' +
537
553
  'the server does not confirm one (a 502, 503 or 504, or a dropped connection), sends the ' +
538
554
  'same request again so the server returns the turn it accepted instead of starting a ' +
539
555
  'second one. Pass your own key to re-attach to a start from another process: the same ' +
540
556
  'key and prompt return the original turn; a different prompt under it is refused.',
541
557
  }),
558
+ 'wait-for-idle': core_1.Flags.boolean({
559
+ description: 'When the conversation already has a turn running, wait for it to end and then send ' +
560
+ 'this turn, instead of failing at once. The CLI asks again every few seconds (at most ' +
561
+ 'every 15) under the same --idempotency-key, so it never starts this turn twice. ' +
562
+ 'Gives up after --wait-timeout.',
563
+ }),
564
+ 'wait-timeout': core_1.Flags.integer({
565
+ description: 'Seconds --wait-for-idle waits for the running turn before giving up ' +
566
+ `(default ${agent_chat_start_1.DEFAULT_WAIT_FOR_IDLE_TIMEOUT_MS / 1000}). Nothing is sent when it runs out.`,
567
+ min: 1,
568
+ dependsOn: ['wait-for-idle'],
569
+ }),
570
+ 'when-busy': core_1.Flags.string({
571
+ description: 'What to do when the conversation already has a turn running: fail (the default), ' +
572
+ 'queue the turn on the server so it is sent when the running turn ends, or steer it ' +
573
+ 'into the running turn (it waits in the queue when the turn takes no input, and a ' +
574
+ 'command never steers). Needs --conversation. A queued turn is followed until it is ' +
575
+ 'sent and its reply is streamed, unless --detach.',
576
+ options: [...agent_chat_queue_1.WHEN_BUSY_MODES],
577
+ }),
578
+ detach: core_1.Flags.boolean({
579
+ description: 'With --when-busy queue or steer, return once the message is in the queue instead of ' +
580
+ 'waiting for it to be sent. See it with `agents queue list --conversation <id>`.',
581
+ dependsOn: ['when-busy'],
582
+ }),
583
+ 'queue-timeout': core_1.Flags.integer({
584
+ description: 'Seconds --when-busy waits for a queued message to be sent before giving up ' +
585
+ `(default ${agent_chat_queue_1.DEFAULT_QUEUE_WAIT_SECONDS}). The message stays queued when it runs out.`,
586
+ min: 1,
587
+ dependsOn: ['when-busy'],
588
+ }),
542
589
  'repair-wait': core_1.Flags.integer({
543
590
  description: 'Seconds to keep waiting when a platform update restarts the server relaying a turn ' +
544
591
  'your machine is still running. The server repairs the reply onto the conversation ' +
@@ -645,9 +692,144 @@ class AgentsChat extends base_command_1.BaseCommand {
645
692
  }
646
693
  return { daemonId, refs };
647
694
  }
695
+ /**
696
+ * G7 — the conversation is busy and the caller asked for the turn to be queued (or steered)
697
+ * instead of refused. Returns the coordinates of the turn once it is started, so the caller
698
+ * attaches to it exactly as after a direct start, or `null` when there is nothing to stream (the
699
+ * message joined the running turn, or `--detach`).
700
+ */
701
+ async startThroughQueue(input) {
702
+ const fail = (err) => {
703
+ const refusal = (0, agent_chat_queue_1.queueErrorOf)(err);
704
+ if (!refusal)
705
+ this.handleApiError(err);
706
+ return this.failWithCliError({
707
+ message: refusal.message,
708
+ code: refusal.code,
709
+ status: refusal.status,
710
+ exit: 1,
711
+ retryable: refusal.retryable,
712
+ details: { conversationId: input.conversationId },
713
+ });
714
+ };
715
+ const emit = (record, line) => {
716
+ if (input.json)
717
+ (0, agentic_stream_1.writeJsonLine)(process.stdout, record);
718
+ else
719
+ this.warn(line);
720
+ };
721
+ let queued;
722
+ try {
723
+ queued = await (0, agent_chat_queue_1.queueAgentChatTurn)(input.params, { clientInputId: input.startKey });
724
+ }
725
+ catch (err) {
726
+ return fail(err);
727
+ }
728
+ const { submitted } = queued;
729
+ if (submitted.outcome === 'started' && submitted.start) {
730
+ // The running turn ended between the refusal and the submit: this turn started now.
731
+ return submitted.start;
732
+ }
733
+ const startedHere = {
734
+ sessionId: queued.sessionId,
735
+ conversationId: input.conversationId,
736
+ responseMessageId: queued.responseMessageId,
737
+ };
738
+ emit({
739
+ type: 'input.queued',
740
+ conversationId: input.conversationId,
741
+ cardId: submitted.cardId,
742
+ position: submitted.position,
743
+ sessionId: queued.sessionId,
744
+ }, `The conversation has a turn running, so this message was queued on the server ` +
745
+ `(card ${submitted.cardId}, position ${(submitted.position ?? 0) + 1}). It is sent when ` +
746
+ 'that turn ends.');
747
+ if (input.whenBusy === 'steer') {
748
+ try {
749
+ const steered = await (0, agent_chat_queue_1.steerCard)(input.conversationId, submitted.cardId);
750
+ emit({ type: 'input.steer', outcome: steered.outcome, cardId: submitted.cardId }, (0, agent_chat_queue_1.steerOutcomeSentence)(steered.outcome));
751
+ if (steered.outcome === 'sent')
752
+ return null;
753
+ if (steered.outcome === 'next_turn')
754
+ return startedHere;
755
+ }
756
+ catch (err) {
757
+ const refusal = (0, agent_chat_queue_1.queueErrorOf)(err);
758
+ // The card stays queued: say why it could not steer and keep following it.
759
+ if (!refusal)
760
+ return fail(err);
761
+ emit({ type: 'input.steer', outcome: 'refused', code: refusal.code, cardId: submitted.cardId }, refusal.message);
762
+ }
763
+ }
764
+ if (input.detach)
765
+ return null;
766
+ let waited;
767
+ try {
768
+ waited = await (0, agent_chat_queue_1.waitForQueuedTurn)(queued, {
769
+ timeoutMs: input.timeoutMs,
770
+ onPaused: (sentence) => emit({ type: 'input.paused', message: sentence }, sentence),
771
+ });
772
+ }
773
+ catch (err) {
774
+ return fail(err);
775
+ }
776
+ const listHint = `${this.config.bin} agents queue list --conversation ${input.conversationId}`;
777
+ switch (waited.outcome) {
778
+ case 'sent':
779
+ return startedHere;
780
+ case 'held':
781
+ return this.failWithCliError({
782
+ message: `The queued message could not be sent: ${waited.reason}${waited.card.holdMessage ? ` ${waited.card.holdMessage}` : ''} It is held in the queue; see it with \`${listHint}\`.`,
783
+ code: 'INPUT_QUEUE_HELD',
784
+ status: 409,
785
+ exit: 1,
786
+ retryable: false,
787
+ details: {
788
+ conversationId: input.conversationId,
789
+ cardId: waited.card.cardId,
790
+ holdReason: waited.card.holdReason ?? null,
791
+ holdCode: waited.card.holdCode ?? null,
792
+ },
793
+ });
794
+ case 'not_sent':
795
+ return this.failWithCliError({
796
+ message: 'The queued message left the queue without being sent; it was probably withdrawn ' +
797
+ 'from another screen.',
798
+ code: 'INPUT_QUEUE_NOT_SENT',
799
+ status: 409,
800
+ exit: 1,
801
+ retryable: false,
802
+ details: { conversationId: input.conversationId, cardId: submitted.cardId },
803
+ });
804
+ default:
805
+ return this.failWithCliError({
806
+ message: `The running turn had not finished after ${Math.round(input.timeoutMs / 1000)}s. ` +
807
+ `The message is still queued and will be sent when it does; see it with \`${listHint}\`.`,
808
+ code: 'INPUT_QUEUE_WAIT_TIMEOUT',
809
+ status: 408,
810
+ exit: 1,
811
+ retryable: true,
812
+ details: { conversationId: input.conversationId, cardId: submitted.cardId },
813
+ });
814
+ }
815
+ }
648
816
  async run() {
649
817
  this.requireAuth();
650
818
  const { args, flags } = await this.parse(AgentsChat);
819
+ const whenBusy = flags['when-busy'] ?? 'fail';
820
+ if (whenBusy !== 'fail' && flags['wait-for-idle']) {
821
+ this.error('--when-busy and --wait-for-idle are two answers to the same question; pass one.', {
822
+ exit: 2,
823
+ });
824
+ }
825
+ if (whenBusy !== 'fail' && !flags.conversation && !flags['thread-root']) {
826
+ this.error('--when-busy needs --conversation: a new conversation is never busy.', {
827
+ exit: 2,
828
+ });
829
+ }
830
+ if (whenBusy !== 'fail' && flags.quick) {
831
+ this.error('--when-busy needs a runtime turn; remove --quick.', { exit: 2 });
832
+ }
651
833
  if (flags.quick && flags.task)
652
834
  this.error('--task requires a runtime session; remove --quick to bind this turn.', {
653
835
  exit: 2,
@@ -836,20 +1018,69 @@ class AgentsChat extends base_command_1.BaseCommand {
836
1018
  onReplay: ({ attempt, of, waitMs }) => this.warn(`The server did not confirm the start; sending the same request again in ` +
837
1019
  `${Math.round(waitMs / 1000)}s (${attempt}/${of}). It returns the turn it ` +
838
1020
  `already accepted rather than starting a second one.`),
1021
+ ...(flags['wait-for-idle']
1022
+ ? {
1023
+ waitForIdle: {
1024
+ timeoutMs: (flags['wait-timeout'] ?? agent_chat_start_1.DEFAULT_WAIT_FOR_IDLE_TIMEOUT_MS / 1000) * 1000,
1025
+ onBusy: (info) => this.warn((0, agent_chat_start_1.busyWaitNotice)(info, threadConversationId)),
1026
+ },
1027
+ }
1028
+ : {}),
839
1029
  });
840
1030
  }
841
1031
  catch (err) {
842
- if (err instanceof agent_chat_start_1.StartNotConfirmed) {
843
- this.warn((0, agent_chat_start_1.startNotConfirmedHint)(startKey, err.attempts));
844
- this.handleApiError(err.lastError);
1032
+ // OSK-32920 — a conversation that already has a turn running answers
1033
+ // `429 conversation_busy`. Read by the generic path it printed the server's
1034
+ // "Please wait." with no word on whether anything was sent or how to wait.
1035
+ const busy = (0, agent_chat_start_1.busyStartFailure)(err, threadConversationId);
1036
+ // G7 — or the turn is queued on the server (or steered into the running one).
1037
+ if (busy && whenBusy !== 'fail' && threadConversationId) {
1038
+ const queued = await this.startThroughQueue({
1039
+ whenBusy,
1040
+ conversationId: threadConversationId,
1041
+ startKey,
1042
+ params: {
1043
+ agentId: args.agentId,
1044
+ taskId: boundTaskId,
1045
+ text: contextParts ? `${contextParts}\n\n${prompt}` : prompt,
1046
+ conversationId: threadConversationId,
1047
+ workspaceId: process.env.OVERSKY_WORKSPACE_ID,
1048
+ ...daemonPinFields(localSkills, flags.daemon),
1049
+ ...permissionModeFields(flags['permission-mode']),
1050
+ },
1051
+ detach: Boolean(flags.detach),
1052
+ timeoutMs: (flags['queue-timeout'] ?? agent_chat_queue_1.DEFAULT_QUEUE_WAIT_SECONDS) * 1000,
1053
+ json: Boolean(flags.json || flags.jsonl),
1054
+ });
1055
+ if (!queued)
1056
+ return;
1057
+ started = queued;
1058
+ }
1059
+ else {
1060
+ if (busy) {
1061
+ this.failWithCliError({
1062
+ message: busy.message,
1063
+ code: busy.code,
1064
+ status: busy.status,
1065
+ exit: 1,
1066
+ retryable: busy.retryable,
1067
+ details: busy.details,
1068
+ });
1069
+ }
1070
+ if (err instanceof agent_chat_start_1.StartNotConfirmed) {
1071
+ this.warn((0, agent_chat_start_1.startNotConfirmedHint)(startKey, err.attempts));
1072
+ this.handleApiError(err.lastError);
1073
+ }
1074
+ // A refused start was the one API error on this command that escaped
1075
+ // `handleApiError`: it fell through to the generic catch, which printed
1076
+ // `HTTP 400 Bad Request — POST …/api/agentic/chat` under the code
1077
+ // CLI_PARSE_ERROR and dropped the body that said WHY ("The configured
1078
+ // model is not supported."). The reader had to guess (OSK-4897).
1079
+ this.handleApiError(err);
845
1080
  }
846
- // A refused start was the one API error on this command that escaped
847
- // `handleApiError`: it fell through to the generic catch, which printed
848
- // `HTTP 400 Bad Request — POST …/api/agentic/chat` under the code
849
- // CLI_PARSE_ERROR and dropped the body that said WHY ("The configured
850
- // model is not supported."). The reader had to guess (OSK-4897).
851
- this.handleApiError(err);
852
1081
  }
1082
+ if (!started)
1083
+ return;
853
1084
  // OSK-13599 — the acceptance names the workspace the turn runs in. Adopt it
854
1085
  // for the rest of this turn (the stream's header, the message reads that
855
1086
  // reconcile its end, envelope replay) exactly as the pre-flight read's
@@ -879,7 +1110,9 @@ class AgentsChat extends base_command_1.BaseCommand {
879
1110
  conversationId: started.conversationId,
880
1111
  ...(flags['thread-root'] ? { threadRootMessageId: flags['thread-root'] } : {}),
881
1112
  responseMessageId: started.responseMessageId,
882
- ...(admittedRouting(started.runtime) ? { admittedRouting: admittedRouting(started.runtime) } : {}),
1113
+ ...(admittedRouting(started.runtime)
1114
+ ? { admittedRouting: admittedRouting(started.runtime) }
1115
+ : {}),
883
1116
  // OSK-13599 — where the turn runs and who chose it, when the server
884
1117
  // says (`request` | `agent_home`); absent against an older server.
885
1118
  ...(workspaceDefault === 'supported'
@@ -1115,6 +1348,7 @@ class AgentsChat extends base_command_1.BaseCommand {
1115
1348
  this.error(message, { exit });
1116
1349
  }
1117
1350
  const result = reconciled ?? outcome;
1351
+ const cancelledBy = result.status === 'aborted' ? interruptedBy : null;
1118
1352
  if (flags.jsonl) {
1119
1353
  // The event stream already contains the terminal event. This summary
1120
1354
  // makes shell consumers able to find the final text without replaying
@@ -1145,19 +1379,18 @@ class AgentsChat extends base_command_1.BaseCommand {
1145
1379
  text: result.text,
1146
1380
  conversationId: started.conversationId,
1147
1381
  });
1148
- if (noOutput)
1382
+ if (noOutput && !cancelledBy)
1149
1383
  this.error(noOutput, { exit: 1 });
1150
- this.log(result.text);
1384
+ if (!noOutput)
1385
+ this.log(result.text);
1151
1386
  }
1152
1387
  else if (result.status === 'aborted' && interruptedBy !== 'SIGHUP') {
1153
1388
  // Streaming human mode: say the cancel took, rather than leave the keypress warning last.
1154
1389
  // (Not after SIGHUP: the terminal that would show it is gone.)
1155
1390
  this.log(`\n${cancelledRunMessage({ sessionId: started.sessionId, conversationId: started.conversationId })}`);
1156
1391
  }
1157
- // A run stopped by SIGTERM or SIGHUP ends the way a shell reports a process the signal killed,
1158
- // so a script can tell a cancelled run from one that finished. Ctrl-C keeps its existing status
1159
- // (a cancel that took is a success, a detach is 130).
1160
- if (interruptedBy === 'SIGTERM' || interruptedBy === 'SIGHUP') {
1392
+ // If completion wins the Ctrl-C race, preserve the completed run's exit status.
1393
+ if (cancelledBy || interruptedBy === 'SIGTERM' || interruptedBy === 'SIGHUP') {
1161
1394
  process.exitCode = interruptExitCode(interruptedBy);
1162
1395
  }
1163
1396
  }
@@ -0,0 +1,9 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ export default class AgentsManagerStatus extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const data_provider_1 = require("@skrr-ai/data-provider");
5
+ const base_command_1 = require("../../../base-command");
6
+ const duties_1 = require("../../../lib/duties");
7
+ const duty_history_source_1 = require("../../../lib/duty-history-source");
8
+ const web_url_1 = require("../../../lib/web-url");
9
+ class AgentsManagerStatus extends base_command_1.BaseCommand {
10
+ static description = 'Show your Agent Manager, staffing review Duty, and latest check';
11
+ static examples = [
12
+ '<%= config.bin %> agents manager status',
13
+ '<%= config.bin %> agents manager status --workspace <workspace-id> --json',
14
+ ];
15
+ static flags = {
16
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
17
+ };
18
+ async run() {
19
+ this.requireAuth();
20
+ const { flags } = await this.parse(AgentsManagerStatus);
21
+ try {
22
+ const { workspaceId, agent: manager, duty: staffingDuty } = await data_provider_1.dataService.getAgentManagerStatus();
23
+ const agent = manager && (0, web_url_1.withAgentUrl)(this.cliConfig.baseURL, manager);
24
+ const detail = staffingDuty ? await duties_1.dutyApi.get(staffingDuty.id) : null;
25
+ const duty = staffingDuty && (0, web_url_1.withDutyUrl)(this.cliConfig.baseURL, {
26
+ ...staffingDuty,
27
+ status: detail?.duty?.status ?? staffingDuty.status,
28
+ });
29
+ const historyAvailable = detail ? (0, duty_history_source_1.hasVerifiedDutyHistorySource)(detail) : null;
30
+ const operatingTrigger = historyAvailable ? detail?.operatingState?.trigger : null;
31
+ const trigger = operatingTrigger
32
+ ? { status: operatingTrigger.status, nextWake: operatingTrigger.nextWake ?? null }
33
+ : null;
34
+ const check = historyAvailable ? detail?.latestCheck : null;
35
+ const latestCheck = check
36
+ ? {
37
+ id: check.id,
38
+ status: check.status,
39
+ completedAt: check.completedAt ?? null,
40
+ url: duty?.url
41
+ ? `${duty.url}?view=activity&checkId=${encodeURIComponent(check.id)}`
42
+ : null,
43
+ }
44
+ : null;
45
+ if (flags.json) {
46
+ this.log(JSON.stringify({ workspaceId, agent, duty, trigger, historyAvailable, latestCheck }, null, 2));
47
+ return;
48
+ }
49
+ if (!agent) {
50
+ this.log(workspaceId
51
+ ? 'You do not have an Agent Manager in this workspace.'
52
+ : 'Your Personal Workspace is unavailable.');
53
+ return;
54
+ }
55
+ this.log(`Agent Manager: ${agent.name} (${agent.id})`);
56
+ if (agent.url)
57
+ this.log(agent.url);
58
+ this.log(`Always-On: ${agent.alwaysOn ? 'enabled' : 'Standby'}`);
59
+ if (!duty) {
60
+ this.log('Staffing review: no Duty configured');
61
+ return;
62
+ }
63
+ this.log(`Staffing review: ${duty.status}`);
64
+ if (duty.url)
65
+ this.log(duty.url);
66
+ if (trigger)
67
+ this.log(`Trigger: ${trigger.status}`);
68
+ if (trigger?.nextWake?.at)
69
+ this.log(`Next check: ${trigger.nextWake.at}`);
70
+ if (latestCheck) {
71
+ this.log(`Latest check: ${latestCheck.status}${latestCheck.completedAt ? ` · ${latestCheck.completedAt}` : ''}`);
72
+ if (latestCheck.url)
73
+ this.log(latestCheck.url);
74
+ }
75
+ else {
76
+ this.log(historyAvailable ? 'Latest check: none recorded' : 'Check history is unavailable.');
77
+ }
78
+ }
79
+ catch (err) {
80
+ this.handleApiError(err);
81
+ }
82
+ }
83
+ }
84
+ exports.default = AgentsManagerStatus;
@@ -0,0 +1,13 @@
1
+ import { AgentChatQueueCommand } from '../../../lib/agent-chat-queue-command';
2
+ /**
3
+ * `skrr agents queue clear --conversation <id> --yes` — withdraw every waiting message. A message
4
+ * already being sent is not withdrawn.
5
+ */
6
+ export default class AgentsQueueClear extends AgentChatQueueCommand {
7
+ static description: string;
8
+ static examples: string[];
9
+ static flags: {
10
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const agent_chat_queue_command_1 = require("../../../lib/agent-chat-queue-command");
5
+ const agent_chat_queue_1 = require("../../../lib/agent-chat-queue");
6
+ /**
7
+ * `skrr agents queue clear --conversation <id> --yes` — withdraw every waiting message. A message
8
+ * already being sent is not withdrawn.
9
+ */
10
+ class AgentsQueueClear extends agent_chat_queue_command_1.AgentChatQueueCommand {
11
+ static description = 'Withdraw every waiting message from a conversation queue';
12
+ static examples = [
13
+ '<%= config.bin %> agents queue clear --conversation <conversation-id> --yes',
14
+ ];
15
+ static flags = {
16
+ yes: core_1.Flags.boolean({ description: 'Confirm: nothing withdrawn is sent', required: true }),
17
+ };
18
+ async run() {
19
+ this.requireAuth();
20
+ const { flags } = await this.parse(AgentsQueueClear);
21
+ let snapshot;
22
+ try {
23
+ snapshot = await (0, agent_chat_queue_1.clearQueue)(flags.conversation);
24
+ }
25
+ catch (err) {
26
+ this.failQueue(err, flags.conversation);
27
+ }
28
+ this.printQueue(snapshot, flags.json, 'Withdrew every waiting message. Nothing was sent.');
29
+ }
30
+ }
31
+ exports.default = AgentsQueueClear;
@@ -0,0 +1,10 @@
1
+ import { AgentChatQueueCommand } from '../../../lib/agent-chat-queue-command';
2
+ /**
3
+ * `skrr agents queue list --conversation <id>` — the messages queued on a conversation while its
4
+ * agent works (G1), in the order they will be sent, with any pause and why a card is held.
5
+ */
6
+ export default class AgentsQueueList extends AgentChatQueueCommand {
7
+ static description: string;
8
+ static examples: string[];
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const agent_chat_queue_command_1 = require("../../../lib/agent-chat-queue-command");
4
+ const agent_chat_queue_1 = require("../../../lib/agent-chat-queue");
5
+ const list_output_1 = require("../../../lib/list-output");
6
+ /**
7
+ * `skrr agents queue list --conversation <id>` — the messages queued on a conversation while its
8
+ * agent works (G1), in the order they will be sent, with any pause and why a card is held.
9
+ */
10
+ class AgentsQueueList extends agent_chat_queue_command_1.AgentChatQueueCommand {
11
+ static description = 'List the messages queued on a conversation while its agent works';
12
+ static examples = [
13
+ '<%= config.bin %> agents queue list --conversation <conversation-id>',
14
+ '<%= config.bin %> agents queue list --conversation <conversation-id> --json',
15
+ ];
16
+ async run() {
17
+ this.requireAuth();
18
+ const { flags } = await this.parse(AgentsQueueList);
19
+ let read;
20
+ try {
21
+ read = await (0, agent_chat_queue_1.readQueue)(flags.conversation);
22
+ }
23
+ catch (err) {
24
+ this.failQueue(err, flags.conversation);
25
+ }
26
+ if (flags.json) {
27
+ // The list envelope (`data` is the cards in order), with the snapshot's own fields beside it.
28
+ this.printJsonResult((0, list_output_1.listResult)(read, 'cards'));
29
+ return;
30
+ }
31
+ this.printQueue(read, false);
32
+ }
33
+ }
34
+ exports.default = AgentsQueueList;
@@ -0,0 +1,16 @@
1
+ import { AgentChatQueueCommand } from '../../../lib/agent-chat-queue-command';
2
+ /**
3
+ * `skrr agents queue move <card> --to <position> --conversation <id>` — change the order the
4
+ * queued messages are sent in. A message being sent stays first.
5
+ */
6
+ export default class AgentsQueueMove extends AgentChatQueueCommand {
7
+ static description: string;
8
+ static examples: string[];
9
+ static args: {
10
+ card: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
11
+ };
12
+ static flags: {
13
+ to: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
14
+ };
15
+ run(): Promise<void>;
16
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const agent_chat_queue_command_1 = require("../../../lib/agent-chat-queue-command");
5
+ const agent_chat_queue_1 = require("../../../lib/agent-chat-queue");
6
+ /**
7
+ * `skrr agents queue move <card> --to <position> --conversation <id>` — change the order the
8
+ * queued messages are sent in. A message being sent stays first.
9
+ */
10
+ class AgentsQueueMove extends agent_chat_queue_command_1.AgentChatQueueCommand {
11
+ static description = 'Move a queued message to another position';
12
+ static examples = [
13
+ '<%= config.bin %> agents queue move "#3" --to 1 --conversation <conversation-id>',
14
+ ];
15
+ static args = agent_chat_queue_command_1.AgentChatQueueCommand.cardArg;
16
+ static flags = {
17
+ to: core_1.Flags.integer({ description: 'New position, 1 is sent next', required: true, min: 1 }),
18
+ };
19
+ async run() {
20
+ this.requireAuth();
21
+ const { args, flags } = await this.parse(AgentsQueueMove);
22
+ const { card, read } = await this.findCard(flags.conversation, args.card);
23
+ let snapshot;
24
+ try {
25
+ snapshot = await (0, agent_chat_queue_1.moveCard)(flags.conversation, card.cardId, flags.to - 1, read.version);
26
+ }
27
+ catch (err) {
28
+ this.failQueue(err, flags.conversation);
29
+ }
30
+ this.printQueue(snapshot, flags.json);
31
+ }
32
+ }
33
+ exports.default = AgentsQueueMove;
@@ -0,0 +1,7 @@
1
+ import { AgentChatQueueCommand } from '../../../lib/agent-chat-queue-command';
2
+ /** `skrr agents queue pause --conversation <id>`. */
3
+ export default class AgentsQueuePause extends AgentChatQueueCommand {
4
+ static description: string;
5
+ static examples: string[];
6
+ run(): Promise<void>;
7
+ }