@skrr-ai/cli 0.1.207 → 0.1.209

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 (168) hide show
  1. package/dist/commands/agent/message/no-reply.js +1 -1
  2. package/dist/commands/agent/message/react.d.ts +23 -0
  3. package/dist/commands/agent/message/react.js +125 -0
  4. package/dist/commands/agent/message/resolve.d.ts +31 -0
  5. package/dist/commands/agent/message/resolve.js +111 -0
  6. package/dist/commands/agent/message/retract.js +1 -1
  7. package/dist/commands/agent/message/send.d.ts +25 -6
  8. package/dist/commands/agent/message/send.js +135 -30
  9. package/dist/commands/agent/request/list.d.ts +15 -0
  10. package/dist/commands/agent/request/list.js +82 -0
  11. package/dist/commands/agent/request/send.d.ts +18 -0
  12. package/dist/commands/agent/request/send.js +56 -0
  13. package/dist/commands/agents/access/approve.d.ts +17 -0
  14. package/dist/commands/agents/access/approve.js +94 -0
  15. package/dist/commands/agents/access/deny.d.ts +10 -0
  16. package/dist/commands/agents/access/deny.js +36 -0
  17. package/dist/commands/agents/access/list.d.ts +10 -0
  18. package/dist/commands/agents/access/list.js +55 -0
  19. package/dist/commands/agents/access/reach.d.ts +13 -0
  20. package/dist/commands/agents/access/reach.js +53 -0
  21. package/dist/commands/agents/access/revoke.d.ts +13 -0
  22. package/dist/commands/agents/access/revoke.js +50 -0
  23. package/dist/commands/agents/always-on/recovery-review.d.ts +5 -0
  24. package/dist/commands/agents/always-on/recovery-review.js +16 -0
  25. package/dist/commands/agents/chat.d.ts +8 -0
  26. package/dist/commands/agents/chat.js +369 -90
  27. package/dist/commands/agents/import.d.ts +15 -1
  28. package/dist/commands/agents/import.js +212 -24
  29. package/dist/commands/agents/intuitions/accept.d.ts +0 -1
  30. package/dist/commands/agents/intuitions/accept.js +22 -7
  31. package/dist/commands/agents/intuitions/generate.d.ts +0 -1
  32. package/dist/commands/agents/intuitions/generate.js +4 -16
  33. package/dist/commands/agents/intuitions/list.js +9 -3
  34. package/dist/commands/agents/intuitions/resume.d.ts +11 -0
  35. package/dist/commands/agents/intuitions/resume.js +37 -0
  36. package/dist/commands/agents/manager/status.js +7 -6
  37. package/dist/commands/agents/not-for-task.d.ts +24 -0
  38. package/dist/commands/agents/not-for-task.js +60 -0
  39. package/dist/commands/agents/schedule-overview.d.ts +20 -0
  40. package/dist/commands/agents/schedule-overview.js +35 -2
  41. package/dist/commands/agents/shared-memory.d.ts +24 -0
  42. package/dist/commands/agents/shared-memory.js +67 -0
  43. package/dist/commands/agents/stop.d.ts +23 -0
  44. package/dist/commands/agents/stop.js +61 -0
  45. package/dist/commands/agents/update.d.ts +7 -0
  46. package/dist/commands/agents/update.js +45 -2
  47. package/dist/commands/agents/visibility.d.ts +1 -0
  48. package/dist/commands/agents/visibility.js +14 -0
  49. package/dist/commands/code/migrate.js +3 -1
  50. package/dist/commands/convos/messages.js +5 -0
  51. package/dist/commands/convos/transcript.js +2 -2
  52. package/dist/commands/daemon/logs.d.ts +3 -1
  53. package/dist/commands/daemon/logs.js +6 -2
  54. package/dist/commands/duties/advance-next.js +16 -7
  55. package/dist/commands/duties/preflight.js +17 -13
  56. package/dist/commands/followups/show.js +9 -0
  57. package/dist/commands/followups/watch-pr.d.ts +27 -0
  58. package/dist/commands/followups/watch-pr.js +124 -0
  59. package/dist/commands/harnesses/evaluations/evidence.js +2 -2
  60. package/dist/commands/harnesses/evaluations/grant.js +1 -1
  61. package/dist/commands/harnesses/evaluations/revoke.js +1 -1
  62. package/dist/commands/harnesses/evaluations/show.js +1 -1
  63. package/dist/commands/harnesses/rollouts/grant.js +1 -1
  64. package/dist/commands/harnesses/rollouts/revoke.js +1 -1
  65. package/dist/commands/machines/hosted/identity-evaluations/revoke.js +1 -1
  66. package/dist/commands/machines/hosted/identity-evaluations/show.js +1 -1
  67. package/dist/commands/memory/consolidation/index.d.ts +20 -0
  68. package/dist/commands/memory/consolidation/index.js +78 -0
  69. package/dist/commands/memory/consolidation/resume.d.ts +14 -0
  70. package/dist/commands/memory/consolidation/resume.js +46 -0
  71. package/dist/commands/memory/consolidation/undo.d.ts +18 -0
  72. package/dist/commands/memory/consolidation/undo.js +61 -0
  73. package/dist/commands/messages/list.js +9 -1
  74. package/dist/commands/slack/mutes.d.ts +10 -0
  75. package/dist/commands/slack/mutes.js +62 -0
  76. package/dist/commands/slack/unmute.d.ts +12 -0
  77. package/dist/commands/slack/unmute.js +44 -0
  78. package/dist/commands/tasks/actionability.js +10 -0
  79. package/dist/commands/tasks/ask.d.ts +50 -0
  80. package/dist/commands/tasks/ask.js +190 -0
  81. package/dist/commands/tasks/bulk-update.js +12 -0
  82. package/dist/commands/tasks/handover.js +14 -0
  83. package/dist/commands/tasks/input/answer.js +8 -2
  84. package/dist/commands/tasks/input/show.d.ts +26 -0
  85. package/dist/commands/tasks/input/show.js +185 -17
  86. package/dist/commands/tasks/list.d.ts +8 -0
  87. package/dist/commands/tasks/list.js +50 -9
  88. package/dist/commands/tasks/move.d.ts +3 -0
  89. package/dist/commands/tasks/move.js +71 -1
  90. package/dist/commands/tasks/result/show.js +19 -7
  91. package/dist/commands/tasks/result/submit.js +3 -0
  92. package/dist/commands/tasks/runs.d.ts +4 -1
  93. package/dist/commands/tasks/runs.js +22 -3
  94. package/dist/commands/tasks/show.d.ts +4 -3
  95. package/dist/commands/tasks/show.js +40 -7
  96. package/dist/commands/tasks/start.js +35 -16
  97. package/dist/commands/tasks/update.d.ts +1 -0
  98. package/dist/commands/tasks/update.js +55 -1
  99. package/dist/commands/tasks/updates/add.js +3 -0
  100. package/dist/commands/tasks/wait.d.ts +20 -0
  101. package/dist/commands/tasks/wait.js +103 -2
  102. package/dist/generated/agent-guides.json +892 -183
  103. package/dist/generated/managed-instruction-guides.json +1 -1
  104. package/dist/lib/agent-access-command.d.ts +19 -0
  105. package/dist/lib/agent-access-command.js +44 -0
  106. package/dist/lib/agent-access.d.ts +18 -0
  107. package/dist/lib/agent-access.js +48 -0
  108. package/dist/lib/agent-import/apply.d.ts +50 -0
  109. package/dist/lib/agent-import/apply.js +85 -0
  110. package/dist/lib/agent-import/plan.d.ts +132 -0
  111. package/dist/lib/agent-import/plan.js +504 -0
  112. package/dist/lib/agent-import/reader.d.ts +94 -0
  113. package/dist/lib/agent-import/reader.js +326 -0
  114. package/dist/lib/agent-import/schedule.d.ts +46 -0
  115. package/dist/lib/agent-import/schedule.js +220 -0
  116. package/dist/lib/agent-import/sources.d.ts +124 -0
  117. package/dist/lib/agent-import/sources.js +797 -0
  118. package/dist/lib/chat-stop.d.ts +17 -0
  119. package/dist/lib/chat-stop.js +70 -0
  120. package/dist/lib/cloud-reply.d.ts +21 -0
  121. package/dist/lib/cloud-reply.js +52 -0
  122. package/dist/lib/duties.js +24 -4
  123. package/dist/lib/duty-ledgers.js +19 -2
  124. package/dist/lib/file-mime.js +8 -0
  125. package/dist/lib/followups.d.ts +61 -0
  126. package/dist/lib/followups.js +39 -0
  127. package/dist/lib/handover-interview.d.ts +18 -0
  128. package/dist/lib/handover-interview.js +53 -0
  129. package/dist/lib/inbound-messages.d.ts +156 -0
  130. package/dist/lib/inbound-messages.js +375 -0
  131. package/dist/lib/input-queue.js +2 -1
  132. package/dist/lib/intuition-look.d.ts +10 -0
  133. package/dist/lib/intuition-look.js +64 -0
  134. package/dist/lib/message-intent.d.ts +18 -2
  135. package/dist/lib/message-intent.js +23 -1
  136. package/dist/lib/preflight-copy.d.ts +16 -1
  137. package/dist/lib/preflight-copy.js +33 -1
  138. package/dist/lib/record-output.d.ts +1 -1
  139. package/dist/lib/record-output.js +2 -0
  140. package/dist/lib/skill-import.d.ts +19 -0
  141. package/dist/lib/skill-import.js +34 -0
  142. package/dist/lib/slack-thread-mutes.d.ts +25 -0
  143. package/dist/lib/slack-thread-mutes.js +12 -0
  144. package/dist/lib/task-carriers.d.ts +18 -0
  145. package/dist/lib/task-carriers.js +43 -0
  146. package/dist/lib/task-extras.d.ts +5 -0
  147. package/dist/lib/task-extras.js +5 -0
  148. package/dist/lib/task-operations.d.ts +2 -0
  149. package/dist/lib/task-operations.js +28 -4
  150. package/dist/lib/task-preflight.js +1 -0
  151. package/dist/lib/task-recurrence-summary.d.ts +15 -0
  152. package/dist/lib/task-recurrence-summary.js +22 -0
  153. package/dist/lib/task-review-notice.d.ts +21 -0
  154. package/dist/lib/task-review-notice.js +46 -0
  155. package/dist/lib/task-version.d.ts +53 -0
  156. package/dist/lib/task-version.js +89 -0
  157. package/dist/lib/task-write-attribution.d.ts +7 -0
  158. package/dist/lib/task-write-attribution.js +14 -0
  159. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelopeBridge.js +6 -1
  160. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.d.ts +75 -0
  161. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.js +124 -0
  162. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelopeBridge.js +45 -15
  163. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.d.ts +75 -0
  164. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.js +141 -0
  165. package/dist/node_modules/@skrr-ai/auth-core/package.json +11 -1
  166. package/dist/node_modules/@skrr-ai/data-provider/index.js +13492 -12505
  167. package/oclif.manifest.json +2090 -132
  168. package/package.json +9 -2
@@ -29,6 +29,8 @@ 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
31
  const agent_chat_queue_1 = require("../../lib/agent-chat-queue");
32
+ const inbound_messages_1 = require("../../lib/inbound-messages");
33
+ const cloud_reply_1 = require("../../lib/cloud-reply");
32
34
  const local_skills_1 = require("../../lib/local-skills");
33
35
  /**
34
36
  * Exit code for a run the USER stopped watching, by pressing Ctrl-C.
@@ -555,36 +557,43 @@ class AgentsChat extends base_command_1.BaseCommand {
555
557
  'second one. Pass your own key to re-attach to a start from another process: the same ' +
556
558
  'key and prompt return the original turn; a different prompt under it is refused.',
557
559
  }),
560
+ 'after-current': core_1.Flags.boolean({
561
+ description: 'Send this message for after the agent finishes what it is doing, instead of letting ' +
562
+ 'it reach the work in progress. The message is kept on the server at once and starts ' +
563
+ 'its own turn when the running one ends. Needs --conversation or --thread-root.',
564
+ }),
558
565
  '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.',
566
+ description: 'The same as --after-current: when the conversation already has a turn running, this ' +
567
+ 'message waits for it to end and then starts its own turn. The CLI follows it until ' +
568
+ 'then and streams the reply, for up to --wait-timeout. Against a server that cannot ' +
569
+ 'keep the message, the CLI asks again every few seconds under the same ' +
570
+ '--idempotency-key instead.',
563
571
  }),
564
572
  '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.`,
573
+ description: 'Seconds --wait-for-idle follows the message before giving up ' +
574
+ `(default ${agent_chat_start_1.DEFAULT_WAIT_FOR_IDLE_TIMEOUT_MS / 1000}). The message stays on the server ` +
575
+ 'and is still sent when the running turn ends.',
567
576
  min: 1,
568
577
  dependsOn: ['wait-for-idle'],
569
578
  }),
570
579
  '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.',
580
+ description: 'In an existing conversation a message is never refused because the agent is busy: ' +
581
+ 'the server keeps it and decides how the agent sees it (it reaches the work in ' +
582
+ 'progress, the agent reads it while it works, or it waits for its own turn). ' +
583
+ '`queue` is --after-current; `steer` is the default; `fail` refuses the message when a ' +
584
+ 'turn is running, as older versions did. Needs --conversation or --thread-root.',
576
585
  options: [...agent_chat_queue_1.WHEN_BUSY_MODES],
577
586
  }),
578
587
  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'],
588
+ description: 'In an existing conversation, return once the server has the message instead of ' +
589
+ 'following it: no wait for its turn to start, nor for what the agent decided while it ' +
590
+ 'worked. See what became of it with `agents queue list --conversation <id>` or in the chat.',
582
591
  }),
583
592
  '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.`,
593
+ description: 'Seconds the CLI follows a message that waits for its own turn before giving up ' +
594
+ `(default ${agent_chat_queue_1.DEFAULT_QUEUE_WAIT_SECONDS}). The message stays on the server when it runs ` +
595
+ 'out and is still sent.',
586
596
  min: 1,
587
- dependsOn: ['when-busy'],
588
597
  }),
589
598
  'repair-wait': core_1.Flags.integer({
590
599
  description: 'Seconds to keep waiting when a platform update restarts the server relaying a turn ' +
@@ -813,10 +822,234 @@ class AgentsChat extends base_command_1.BaseCommand {
813
822
  });
814
823
  }
815
824
  }
825
+ /**
826
+ * Inbound messages: in an existing conversation the message goes to the server's ingress, which
827
+ * keeps it at once and decides how the agent sees it, so a busy agent is never a refusal.
828
+ * Returns the turn to stream, `null` when there is nothing to stream (the message reached the
829
+ * agent another way, or `--detach`), or `'legacy'` when this server has no ingress.
830
+ */
831
+ async sendThroughIngress(input) {
832
+ const conversationId = input.params.conversationId;
833
+ let sent;
834
+ try {
835
+ sent = await (0, agent_chat_start_1.startWithReplay)(() => (0, inbound_messages_1.sendInboundMessage)(input.params, {
836
+ messageId: (0, inbound_messages_1.inboundMessageIdFor)(input.startKey),
837
+ intent: input.intent,
838
+ }), {
839
+ onReplay: ({ attempt, of, waitMs }) => this.warn(`The server did not confirm the message; sending it again in ` +
840
+ `${Math.round(waitMs / 1000)}s (${attempt}/${of}). It keeps the one it already ` +
841
+ `has rather than a second copy.`),
842
+ });
843
+ }
844
+ catch (err) {
845
+ if ((0, inbound_messages_1.ingressMissing)(err))
846
+ return 'legacy';
847
+ if (err instanceof agent_chat_start_1.StartNotConfirmed) {
848
+ this.warn((0, agent_chat_start_1.startNotConfirmedHint)(input.startKey, err.attempts));
849
+ this.handleApiError(err.lastError);
850
+ }
851
+ this.handleApiError(err);
852
+ }
853
+ const { answer } = sent;
854
+ const messageId = answer.message?.messageId ?? sent.messageId;
855
+ const record = {
856
+ messageId,
857
+ conversationId,
858
+ route: answer.route,
859
+ state: answer.delivery?.state ?? null,
860
+ ...(answer.idempotentReplay ? { replayed: true } : {}),
861
+ };
862
+ const sentence = (0, inbound_messages_1.deliverySentence)(answer.delivery) ?? inbound_messages_1.ROUTE_COPY.hold;
863
+ if (input.jsonl)
864
+ (0, agentic_stream_1.writeJsonLine)(process.stdout, { type: 'message.sent', ...record, sentence });
865
+ // A notice on the way, never on stdout unless it is a JSONL event.
866
+ const notice = (type, line, extra = {}) => {
867
+ if (input.jsonl)
868
+ (0, agentic_stream_1.writeJsonLine)(process.stdout, { type, messageId, ...extra, message: line });
869
+ else
870
+ this.warn(line);
871
+ };
872
+ // The command's answer when there is no reply to stream.
873
+ const finish = (extra, lines) => {
874
+ if (input.json) {
875
+ this.log(JSON.stringify({ ...record, delivery: answer.delivery, ...extra }, null, 2));
876
+ }
877
+ else if (!input.jsonl) {
878
+ for (const line of lines)
879
+ this.log(line);
880
+ }
881
+ return null;
882
+ };
883
+ const next = (0, inbound_messages_1.nextAfterSend)(answer);
884
+ switch (next.kind) {
885
+ case 'turn':
886
+ return {
887
+ sessionId: next.sessionId,
888
+ conversationId,
889
+ responseMessageId: next.responseMessageId,
890
+ };
891
+ case 'delivered': {
892
+ const handling = answer.delivery?.handling;
893
+ const hint = (0, inbound_messages_1.notForTaskHint)(this.config.bin, conversationId, messageId, handling?.[handling.length - 1]);
894
+ return finish({ sentence, ...(hint ? { hint } : {}) }, hint ? [sentence, hint] : [sentence]);
895
+ }
896
+ case 'failed':
897
+ return this.failWithCliError({
898
+ message: sentence,
899
+ code: 'MESSAGE_NOT_DELIVERED',
900
+ exit: 1,
901
+ retryable: answer.delivery?.failed?.reason === 'usage_limit',
902
+ details: { ...record, reason: answer.delivery?.failed?.reason ?? null },
903
+ });
904
+ case 'glance': {
905
+ if (input.detach)
906
+ return finish({ sentence }, [sentence]);
907
+ if (!input.json && !input.jsonl)
908
+ this.warn(sentence);
909
+ const outcome = await (0, inbound_messages_1.waitForGlance)(conversationId, messageId);
910
+ const handled = outcome.handling
911
+ ? (0, inbound_messages_1.handlingSentence)(outcome.handling)
912
+ : 'Your agent has not decided about this yet. It has the message; its answer will be ' +
913
+ 'in the chat.';
914
+ if (input.jsonl) {
915
+ (0, agentic_stream_1.writeJsonLine)(process.stdout, {
916
+ type: 'message.handled',
917
+ messageId,
918
+ handling: outcome.handling,
919
+ reply: outcome.reply,
920
+ message: handled,
921
+ });
922
+ }
923
+ // A reply from the cloud says so before its words: it could not see the machine's files.
924
+ const label = outcome.reply?.cloudReply
925
+ ? (0, cloud_reply_1.cloudReplyLine)({ communication: { cloudReply: outcome.reply.cloudReply } })
926
+ : null;
927
+ const taskHint = (0, inbound_messages_1.notForTaskHint)(this.config.bin, conversationId, messageId, outcome.handling);
928
+ return finish({
929
+ handling: outcome.handling,
930
+ reply: outcome.reply,
931
+ sentence: handled,
932
+ ...(taskHint ? { hint: taskHint } : {}),
933
+ }, [label, outcome.reply?.text, handled, taskHint].filter((line) => !!line));
934
+ }
935
+ case 'wait':
936
+ break;
937
+ }
938
+ // The message waits for a turn of its own. Follow it until that turn starts, then stream it,
939
+ // when the caller asked to wait or the turn is only starting. Otherwise say why it waits and
940
+ // return: a script is never held for half an hour it did not ask for (decision 6.6).
941
+ notice('message.held', sentence);
942
+ const listHint = `${this.config.bin} agents queue list --conversation ${conversationId}`;
943
+ const starting = answer.route === 'new_turn';
944
+ if (input.detach || (!input.follow && !starting)) {
945
+ const where = `The message is kept and is sent by itself; see it with \`${listHint}\`, or pass ` +
946
+ '--wait-for-idle to follow it and stream the reply.';
947
+ return finish({ sentence, hint: where }, input.detach ? [] : [where]);
948
+ }
949
+ let waited;
950
+ try {
951
+ waited = await (0, agent_chat_queue_1.waitForQueuedTurn)({
952
+ conversationId,
953
+ clientInputId: messageId,
954
+ sessionId: sent.sessionId,
955
+ responseMessageId: sent.responseMessageId,
956
+ }, {
957
+ timeoutMs: input.timeoutMs,
958
+ onPaused: (line) => notice('message.paused', line),
959
+ });
960
+ }
961
+ catch (err) {
962
+ this.handleApiError(err);
963
+ }
964
+ switch (waited.outcome) {
965
+ case 'sent':
966
+ return {
967
+ sessionId: sent.sessionId,
968
+ conversationId,
969
+ responseMessageId: sent.responseMessageId,
970
+ };
971
+ case 'held':
972
+ return this.failWithCliError({
973
+ message: `Your message is kept but not sent: ${waited.reason}${waited.card.holdMessage ? ` ${waited.card.holdMessage}` : ''} See it with \`${listHint}\`.`,
974
+ code: 'INPUT_QUEUE_HELD',
975
+ status: 409,
976
+ exit: 1,
977
+ retryable: false,
978
+ details: {
979
+ ...record,
980
+ cardId: waited.card.cardId,
981
+ holdReason: waited.card.holdReason ?? null,
982
+ holdCode: waited.card.holdCode ?? null,
983
+ },
984
+ });
985
+ case 'not_sent': {
986
+ // It left the queue without a turn of its own: read what became of it.
987
+ let now;
988
+ try {
989
+ now = await (0, inbound_messages_1.readMessageDelivery)(conversationId, messageId);
990
+ }
991
+ catch (err) {
992
+ this.handleApiError(err);
993
+ }
994
+ if (!now) {
995
+ return this.failWithCliError({
996
+ message: 'The message was taken back from another screen, so it was not sent.',
997
+ code: 'MESSAGE_WITHDRAWN',
998
+ status: 409,
999
+ exit: 1,
1000
+ retryable: false,
1001
+ details: record,
1002
+ });
1003
+ }
1004
+ if (now.delivery?.state === 'failed') {
1005
+ return this.failWithCliError({
1006
+ message: (0, inbound_messages_1.deliverySentence)(now.delivery) ?? inbound_messages_1.FAILED_COPY.refused,
1007
+ code: 'MESSAGE_NOT_DELIVERED',
1008
+ exit: 1,
1009
+ retryable: now.delivery.failed?.reason === 'usage_limit',
1010
+ details: { ...record, reason: now.delivery.failed?.reason ?? null },
1011
+ });
1012
+ }
1013
+ const line = (0, inbound_messages_1.deliverySentence)(now.delivery) ?? 'Your agent has the message.';
1014
+ return finish({ delivery: now.delivery, sentence: line }, [line]);
1015
+ }
1016
+ default:
1017
+ return this.failWithCliError({
1018
+ message: `Your agent was still working after ${Math.round(input.timeoutMs / 1000)}s. ` +
1019
+ `Your message is kept and is sent when it finishes; see it with \`${listHint}\`.`,
1020
+ code: 'INPUT_QUEUE_WAIT_TIMEOUT',
1021
+ status: 408,
1022
+ exit: 1,
1023
+ retryable: true,
1024
+ details: record,
1025
+ });
1026
+ }
1027
+ }
816
1028
  async run() {
817
1029
  this.requireAuth();
818
1030
  const { args, flags } = await this.parse(AgentsChat);
819
- const whenBusy = flags['when-busy'] ?? 'fail';
1031
+ const explicitWhenBusy = flags['when-busy'];
1032
+ // An older server without the ingress: `--after-current` falls back to its queue (below).
1033
+ let whenBusy = explicitWhenBusy ?? 'fail';
1034
+ const inConversation = Boolean(flags.conversation || flags['thread-root']);
1035
+ if (flags['after-current']) {
1036
+ if (!inConversation) {
1037
+ this.error('--after-current needs --conversation or --thread-root: a new conversation has ' +
1038
+ 'nothing running to wait for.', { exit: 2 });
1039
+ }
1040
+ if (explicitWhenBusy === 'fail' || explicitWhenBusy === 'steer') {
1041
+ this.error(`--after-current and --when-busy ${explicitWhenBusy} ask for different things; pass one.`, { exit: 2 });
1042
+ }
1043
+ if (flags.quick)
1044
+ this.error('--after-current needs a runtime turn; remove --quick.', { exit: 2 });
1045
+ }
1046
+ if ((flags.detach || flags['queue-timeout'] !== undefined) && !inConversation) {
1047
+ this.error('--detach and --queue-timeout need --conversation or --thread-root: they follow a ' +
1048
+ 'message the server keeps in an existing conversation.', { exit: 2 });
1049
+ }
1050
+ if (flags.detach && explicitWhenBusy === 'fail') {
1051
+ this.error('--detach has nothing to follow with --when-busy fail; pass one.', { exit: 2 });
1052
+ }
820
1053
  if (whenBusy !== 'fail' && flags['wait-for-idle']) {
821
1054
  this.error('--when-busy and --wait-for-idle are two answers to the same question; pass one.', {
822
1055
  exit: 2,
@@ -998,85 +1231,125 @@ class AgentsChat extends base_command_1.BaseCommand {
998
1231
  this.error(`--idempotency-key must be ${agent_chat_start_1.START_KEY_RULE}.`, { exit: 2 });
999
1232
  }
1000
1233
  const startKey = suppliedStartKey ?? (0, agent_chat_start_1.newStartKey)();
1234
+ const turnText = contextParts ? `${contextParts}\n\n${prompt}` : prompt;
1001
1235
  let started;
1002
- try {
1003
- started = await (0, agent_chat_start_1.startWithReplay)(() => data_provider_1.dataService.startAgenticChat({
1004
- agentId: args.agentId,
1005
- taskId: boundTaskId,
1006
- text: contextParts ? `${contextParts}\n\n${prompt}` : prompt,
1007
- conversationId: threadConversationId,
1008
- workspaceId: process.env.OVERSKY_WORKSPACE_ID,
1009
- clientRequestId: startKey,
1010
- // The server resolves each ref against the session's daemon, so the
1011
- // turn is asked to run on the machine that listed them. An agent whose
1012
- // execution policy places it elsewhere keeps that placement, and the
1013
- // run fails saying why rather than running without the skill.
1014
- ...daemonPinFields(localSkills, flags.daemon),
1015
- ...permissionModeFields(flags['permission-mode']),
1016
- }), {
1017
- // stderr, so stdout and --json/--jsonl stay parseable.
1018
- onReplay: ({ attempt, of, waitMs }) => this.warn(`The server did not confirm the start; sending the same request again in ` +
1019
- `${Math.round(waitMs / 1000)}s (${attempt}/${of}). It returns the turn it ` +
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
- : {}),
1236
+ // Inbound messages: a message to an existing conversation goes to the ingress, which keeps it
1237
+ // and decides how the agent sees it. `--when-busy fail` asks for the older refusal instead.
1238
+ let viaIngress = false;
1239
+ if (threadConversationId && explicitWhenBusy !== 'fail') {
1240
+ const sent = await this.sendThroughIngress({
1241
+ params: {
1242
+ agentId: args.agentId,
1243
+ taskId: boundTaskId,
1244
+ text: turnText,
1245
+ conversationId: threadConversationId,
1246
+ workspaceId: process.env.OVERSKY_WORKSPACE_ID,
1247
+ ...daemonPinFields(localSkills, flags.daemon),
1248
+ ...permissionModeFields(flags['permission-mode']),
1249
+ },
1250
+ startKey,
1251
+ intent: flags['after-current'] || flags['wait-for-idle'] || whenBusy === 'queue'
1252
+ ? 'after_current'
1253
+ : 'now',
1254
+ detach: Boolean(flags.detach),
1255
+ follow: Boolean(flags['after-current'] || flags['wait-for-idle'] || explicitWhenBusy),
1256
+ timeoutMs: flags['wait-for-idle']
1257
+ ? (flags['wait-timeout'] ?? agent_chat_start_1.DEFAULT_WAIT_FOR_IDLE_TIMEOUT_MS / 1000) * 1000
1258
+ : (flags['queue-timeout'] ?? agent_chat_queue_1.DEFAULT_QUEUE_WAIT_SECONDS) * 1000,
1259
+ json: Boolean(flags.json),
1260
+ jsonl: Boolean(flags.jsonl),
1029
1261
  });
1262
+ if (sent === null)
1263
+ return;
1264
+ if (sent === 'legacy') {
1265
+ if (flags['after-current'] && whenBusy === 'fail')
1266
+ whenBusy = 'queue';
1267
+ }
1268
+ else {
1269
+ started = sent;
1270
+ viaIngress = true;
1271
+ }
1030
1272
  }
1031
- catch (err) {
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,
1273
+ if (!viaIngress) {
1274
+ try {
1275
+ started = await (0, agent_chat_start_1.startWithReplay)(() => data_provider_1.dataService.startAgenticChat({
1276
+ agentId: args.agentId,
1277
+ taskId: boundTaskId,
1278
+ text: turnText,
1040
1279
  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),
1280
+ workspaceId: process.env.OVERSKY_WORKSPACE_ID,
1281
+ clientRequestId: startKey,
1282
+ // The server resolves each ref against the session's daemon, so the
1283
+ // turn is asked to run on the machine that listed them. An agent whose
1284
+ // execution policy places it elsewhere keeps that placement, and the
1285
+ // run fails saying why rather than running without the skill.
1286
+ ...daemonPinFields(localSkills, flags.daemon),
1287
+ ...permissionModeFields(flags['permission-mode']),
1288
+ }), {
1289
+ // stderr, so stdout and --json/--jsonl stay parseable.
1290
+ onReplay: ({ attempt, of, waitMs }) => this.warn(`The server did not confirm the start; sending the same request again in ` +
1291
+ `${Math.round(waitMs / 1000)}s (${attempt}/${of}). It returns the turn it ` +
1292
+ `already accepted rather than starting a second one.`),
1293
+ ...(flags['wait-for-idle']
1294
+ ? {
1295
+ waitForIdle: {
1296
+ timeoutMs: (flags['wait-timeout'] ?? agent_chat_start_1.DEFAULT_WAIT_FOR_IDLE_TIMEOUT_MS / 1000) * 1000,
1297
+ onBusy: (info) => this.warn((0, agent_chat_start_1.busyWaitNotice)(info, threadConversationId)),
1298
+ },
1299
+ }
1300
+ : {}),
1054
1301
  });
1055
- if (!queued)
1056
- return;
1057
- started = queued;
1058
1302
  }
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,
1303
+ catch (err) {
1304
+ // OSK-32920 — a conversation that already has a turn running answers
1305
+ // `429 conversation_busy`. Read by the generic path it printed the server's
1306
+ // "Please wait." with no word on whether anything was sent or how to wait.
1307
+ const busy = (0, agent_chat_start_1.busyStartFailure)(err, threadConversationId);
1308
+ // G7 — or the turn is queued on the server (or steered into the running one).
1309
+ if (busy && whenBusy !== 'fail' && threadConversationId) {
1310
+ const queued = await this.startThroughQueue({
1311
+ whenBusy,
1312
+ conversationId: threadConversationId,
1313
+ startKey,
1314
+ params: {
1315
+ agentId: args.agentId,
1316
+ taskId: boundTaskId,
1317
+ text: turnText,
1318
+ conversationId: threadConversationId,
1319
+ workspaceId: process.env.OVERSKY_WORKSPACE_ID,
1320
+ ...daemonPinFields(localSkills, flags.daemon),
1321
+ ...permissionModeFields(flags['permission-mode']),
1322
+ },
1323
+ detach: Boolean(flags.detach),
1324
+ timeoutMs: (flags['queue-timeout'] ?? agent_chat_queue_1.DEFAULT_QUEUE_WAIT_SECONDS) * 1000,
1325
+ json: Boolean(flags.json || flags.jsonl),
1068
1326
  });
1327
+ if (!queued)
1328
+ return;
1329
+ started = queued;
1069
1330
  }
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);
1331
+ else {
1332
+ if (busy) {
1333
+ this.failWithCliError({
1334
+ message: busy.message,
1335
+ code: busy.code,
1336
+ status: busy.status,
1337
+ exit: 1,
1338
+ retryable: busy.retryable,
1339
+ details: busy.details,
1340
+ });
1341
+ }
1342
+ if (err instanceof agent_chat_start_1.StartNotConfirmed) {
1343
+ this.warn((0, agent_chat_start_1.startNotConfirmedHint)(startKey, err.attempts));
1344
+ this.handleApiError(err.lastError);
1345
+ }
1346
+ // A refused start was the one API error on this command that escaped
1347
+ // `handleApiError`: it fell through to the generic catch, which printed
1348
+ // `HTTP 400 Bad Request — POST …/api/agentic/chat` under the code
1349
+ // CLI_PARSE_ERROR and dropped the body that said WHY ("The configured
1350
+ // model is not supported."). The reader had to guess (OSK-4897).
1351
+ this.handleApiError(err);
1073
1352
  }
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);
1080
1353
  }
1081
1354
  }
1082
1355
  if (!started)
@@ -1087,12 +1360,18 @@ class AgentsChat extends base_command_1.BaseCommand {
1087
1360
  // answer used to be adopted; a workspace the caller chose still wins, and
1088
1361
  // an autonomous process still never takes one. It also tells us whether
1089
1362
  // this server chooses the workspace itself, for the next turn.
1090
- const workspaceDefault = (0, agent_home_workspace_1.recordAgentHomeDefaultObservation)(this.config?.cacheDir, this.cliConfig.baseURL, started);
1363
+ // A message to the ingress answers with no workspace of its own: the conversation already
1364
+ // has one, so there is nothing to observe or adopt.
1365
+ const workspaceDefault = viaIngress
1366
+ ? null
1367
+ : (0, agent_home_workspace_1.recordAgentHomeDefaultObservation)(this.config?.cacheDir, this.cliConfig.baseURL, started);
1091
1368
  if (serverChoosesWorkspace && workspaceDefault === 'unsupported') {
1092
1369
  this.warn('This server no longer chooses the agent’s home workspace, so this turn ran without ' +
1093
1370
  'one. The next turn will select it again; pass --workspace to choose one now.');
1094
1371
  }
1095
- (0, agent_home_workspace_1.commitAgentHomeWorkspaceDefault)(typeof started.workspaceId === 'string' && started.workspaceId ? started.workspaceId : null);
1372
+ if (!viaIngress) {
1373
+ (0, agent_home_workspace_1.commitAgentHomeWorkspaceDefault)(typeof started.workspaceId === 'string' && started.workspaceId ? started.workspaceId : null);
1374
+ }
1096
1375
  if (!started.sessionId) {
1097
1376
  this.error('Agentic chat was accepted without a session ID; cannot attach the stream.', {
1098
1377
  exit: 1,
@@ -1,7 +1,9 @@
1
1
  import { BaseCommand } from '../../base-command';
2
2
  /**
3
3
  * Bring a Claude Code asset in: a subagent (`.claude/agents/<name>.md`) or a
4
- * skill (`SKILL.md`, or the directory holding one).
4
+ * skill (`SKILL.md`, or the directory holding one). Or bring a whole bot over
5
+ * from OpenClaw, Hermes or Orca: point it at the bot's folder (see
6
+ * `lib/agent-import/`), read the plan, and say yes.
5
7
  *
6
8
  * A subagent becomes an agent spec document — printed or written with
7
9
  * `--output`, or pushed onto an existing agent with `--agent` (the same push
@@ -23,6 +25,10 @@ export default class AgentsImport extends BaseCommand {
23
25
  agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
26
  output: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
27
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
28
+ from: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
29
+ 'source-agent': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
30
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
31
+ 'replace-persona': import("@oclif/core/interfaces").BooleanFlag<boolean>;
26
32
  };
27
33
  run(): Promise<void>;
28
34
  private convert;
@@ -34,4 +40,12 @@ export default class AgentsImport extends BaseCommand {
34
40
  */
35
41
  private importAgent;
36
42
  private importSkill;
43
+ /** A folder with no SKILL.md whose layout is an OpenClaw, Hermes or Orca bot's. */
44
+ private isBotFolder;
45
+ /**
46
+ * Bring a bot over from another app. Reads the folder (never a key file, never a secret-looking
47
+ * line, never a link out of it), shows the plan, and writes only after a yes: the prompt on a
48
+ * terminal, `--yes` anywhere else. Without `--agent` it shows the plan and writes nothing.
49
+ */
50
+ private importBot;
37
51
  }