@skrr-ai/cli 0.1.208 → 0.1.210
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/base-command.js +2 -1
- package/dist/commands/agent/message/no-reply.js +1 -1
- package/dist/commands/agent/message/react.d.ts +23 -0
- package/dist/commands/agent/message/react.js +128 -0
- package/dist/commands/agent/message/resolve.js +1 -1
- package/dist/commands/agent/message/retract.js +1 -1
- package/dist/commands/agent/message/send.d.ts +8 -13
- package/dist/commands/agent/message/send.js +60 -28
- package/dist/commands/agents/access/approve.js +1 -1
- package/dist/commands/agents/access/deny.js +1 -1
- package/dist/commands/agents/access/list.js +3 -1
- package/dist/commands/agents/access/reach.js +1 -1
- package/dist/commands/agents/access/revoke.js +1 -1
- package/dist/commands/agents/always-on/recovery-review.d.ts +10 -0
- package/dist/commands/agents/always-on/recovery-review.js +45 -0
- package/dist/commands/agents/chat.d.ts +22 -0
- package/dist/commands/agents/chat.js +400 -90
- package/dist/commands/agents/import.js +3 -3
- package/dist/commands/agents/manager/status.js +7 -6
- package/dist/commands/agents/not-for-task.d.ts +24 -0
- package/dist/commands/agents/not-for-task.js +64 -0
- package/dist/commands/agents/schedule-overview.d.ts +20 -0
- package/dist/commands/agents/schedule-overview.js +35 -2
- package/dist/commands/agents/shared-memory.js +1 -1
- package/dist/commands/agents/stop.d.ts +23 -0
- package/dist/commands/agents/stop.js +61 -0
- package/dist/commands/agents/update.d.ts +7 -0
- package/dist/commands/agents/update.js +45 -2
- package/dist/commands/convos/messages.js +5 -0
- package/dist/commands/convos/transcript.js +2 -2
- package/dist/commands/daemon/logs.d.ts +3 -1
- package/dist/commands/daemon/logs.js +6 -2
- package/dist/commands/dm/work.js +38 -9
- package/dist/commands/duties/advance-next.js +1 -1
- package/dist/commands/duties/preflight.js +17 -13
- package/dist/commands/duties/show.js +5 -0
- package/dist/commands/followups/watch-pr.js +2 -1
- package/dist/commands/harnesses/evaluations/evidence.js +2 -2
- package/dist/commands/harnesses/evaluations/grant.js +1 -1
- package/dist/commands/harnesses/evaluations/revoke.js +1 -1
- package/dist/commands/harnesses/evaluations/show.js +1 -1
- package/dist/commands/harnesses/rollouts/grant.js +1 -1
- package/dist/commands/harnesses/rollouts/revoke.js +1 -1
- package/dist/commands/machines/hosted/identity-evaluations/revoke.js +1 -1
- package/dist/commands/machines/hosted/identity-evaluations/show.js +1 -1
- package/dist/commands/memory/consolidation/undo.js +1 -0
- package/dist/commands/messages/list.js +9 -1
- package/dist/commands/slack/mutes.js +1 -1
- package/dist/commands/slack/unmute.js +1 -1
- package/dist/commands/tasks/actionability.js +1 -0
- package/dist/commands/tasks/ask.d.ts +2 -0
- package/dist/commands/tasks/ask.js +7 -1
- package/dist/commands/tasks/bulk-update.js +12 -0
- package/dist/commands/tasks/deliverable/add.d.ts +2 -0
- package/dist/commands/tasks/deliverable/add.js +25 -6
- package/dist/commands/tasks/input/show.d.ts +2 -0
- package/dist/commands/tasks/input/show.js +18 -3
- package/dist/commands/tasks/list.d.ts +8 -0
- package/dist/commands/tasks/list.js +50 -9
- package/dist/commands/tasks/move.d.ts +2 -10
- package/dist/commands/tasks/move.js +7 -18
- package/dist/commands/tasks/resource/add.d.ts +2 -0
- package/dist/commands/tasks/resource/add.js +11 -1
- package/dist/commands/tasks/result/show.js +19 -7
- package/dist/commands/tasks/show.d.ts +4 -3
- package/dist/commands/tasks/show.js +20 -8
- package/dist/commands/tasks/start.js +35 -16
- package/dist/commands/tasks/update.js +3 -0
- package/dist/commands/tasks/wait.js +2 -2
- package/dist/generated/agent-guides.json +483 -183
- package/dist/lib/agent-proactive-baseline.js +4 -1
- package/dist/lib/chat-stop.d.ts +17 -0
- package/dist/lib/chat-stop.js +70 -0
- package/dist/lib/cloud-reply.d.ts +21 -0
- package/dist/lib/cloud-reply.js +52 -0
- package/dist/lib/duties.d.ts +10 -0
- package/dist/lib/duties.js +111 -7
- package/dist/lib/duty-ledgers.js +19 -2
- package/dist/lib/file-mime.js +8 -0
- package/dist/lib/inbound-messages.d.ts +156 -0
- package/dist/lib/inbound-messages.js +375 -0
- package/dist/lib/message-intent.d.ts +18 -2
- package/dist/lib/message-intent.js +23 -1
- package/dist/lib/preflight-copy.d.ts +16 -1
- package/dist/lib/preflight-copy.js +33 -1
- package/dist/lib/space-resolver.d.ts +9 -0
- package/dist/lib/space-resolver.js +13 -0
- package/dist/lib/task-operations.d.ts +2 -0
- package/dist/lib/task-operations.js +28 -4
- package/dist/lib/task-preflight.js +1 -0
- package/dist/lib/task-review-notice.d.ts +21 -0
- package/dist/lib/task-review-notice.js +46 -0
- package/dist/lib/task-version.d.ts +9 -0
- package/dist/lib/task-version.js +16 -0
- package/dist/lib/task-work.js +5 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelopeBridge.js +6 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/managedWorkRuntime.d.ts +5 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/managedWorkRuntime.js +21 -4
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelopeBridge.js +45 -15
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/managedWorkRuntime.d.ts +5 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/managedWorkRuntime.js +31 -5
- package/dist/node_modules/@skrr-ai/auth-core/package.json +1 -1
- package/dist/node_modules/@skrr-ai/data-provider/index.js +12307 -11838
- package/oclif.manifest.json +307 -23
- package/package.json +6 -2
|
@@ -15,6 +15,8 @@ exports.inspectTurnCommand = inspectTurnCommand;
|
|
|
15
15
|
exports.noOutputFailureMessage = noOutputFailureMessage;
|
|
16
16
|
exports.agentRunFailureMessage = agentRunFailureMessage;
|
|
17
17
|
exports.admittedRouting = admittedRouting;
|
|
18
|
+
exports.interactionUnavailableFrom = interactionUnavailableFrom;
|
|
19
|
+
exports.interactionUnavailableWarning = interactionUnavailableWarning;
|
|
18
20
|
exports.noStreamJsonPayload = noStreamJsonPayload;
|
|
19
21
|
exports.chatStreamHeaderLines = chatStreamHeaderLines;
|
|
20
22
|
exports.daemonPinFields = daemonPinFields;
|
|
@@ -29,6 +31,8 @@ const agent_home_workspace_1 = require("../../lib/agent-home-workspace");
|
|
|
29
31
|
const agentic_stream_1 = require("../../lib/agentic-stream");
|
|
30
32
|
const web_url_1 = require("../../lib/web-url");
|
|
31
33
|
const agent_chat_queue_1 = require("../../lib/agent-chat-queue");
|
|
34
|
+
const inbound_messages_1 = require("../../lib/inbound-messages");
|
|
35
|
+
const cloud_reply_1 = require("../../lib/cloud-reply");
|
|
32
36
|
const local_skills_1 = require("../../lib/local-skills");
|
|
33
37
|
/**
|
|
34
38
|
* Exit code for a run the USER stopped watching, by pressing Ctrl-C.
|
|
@@ -352,9 +356,30 @@ function admittedRouting(runtime) {
|
|
|
352
356
|
};
|
|
353
357
|
return Object.keys(routing).length ? routing : undefined;
|
|
354
358
|
}
|
|
359
|
+
function interactionUnavailableFrom(event) {
|
|
360
|
+
if (!event || typeof event !== 'object')
|
|
361
|
+
return undefined;
|
|
362
|
+
const raw = event.interactionUnavailable;
|
|
363
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw))
|
|
364
|
+
return undefined;
|
|
365
|
+
const notice = {};
|
|
366
|
+
for (const key of ['capability', 'reason', 'message', 'provider']) {
|
|
367
|
+
const value = raw[key];
|
|
368
|
+
if (typeof value === 'string' && value.trim())
|
|
369
|
+
notice[key] = value.trim();
|
|
370
|
+
}
|
|
371
|
+
return notice.reason || notice.message ? notice : undefined;
|
|
372
|
+
}
|
|
373
|
+
/** The line a person reads under the answer. The server's own sentence says what to change. */
|
|
374
|
+
function interactionUnavailableWarning(notice) {
|
|
375
|
+
return notice.message
|
|
376
|
+
? `This turn ran without its managed Task tools. ${notice.message}`
|
|
377
|
+
: `This turn ran without its managed Task tools (${notice.reason}).`;
|
|
378
|
+
}
|
|
355
379
|
function noStreamJsonPayload(input) {
|
|
356
380
|
const { result, conversationId, agentId, baseURL, threadRootMessageId } = input;
|
|
357
381
|
const routing = admittedRouting(input.admittedRuntime);
|
|
382
|
+
const interactionUnavailable = interactionUnavailableFrom(result.lastEvent);
|
|
358
383
|
return {
|
|
359
384
|
mode: 'no-stream',
|
|
360
385
|
executed: true,
|
|
@@ -385,6 +410,7 @@ function noStreamJsonPayload(input) {
|
|
|
385
410
|
...(typeof result.lastEvent?.harnessModel === 'string' && result.lastEvent.harnessModel
|
|
386
411
|
? { harnessModel: result.lastEvent.harnessModel }
|
|
387
412
|
: {}),
|
|
413
|
+
...(interactionUnavailable ? { interactionUnavailable } : {}),
|
|
388
414
|
...(result.status === 'failed'
|
|
389
415
|
? {
|
|
390
416
|
failureReason: result.lastEvent?.reason ??
|
|
@@ -555,36 +581,43 @@ class AgentsChat extends base_command_1.BaseCommand {
|
|
|
555
581
|
'second one. Pass your own key to re-attach to a start from another process: the same ' +
|
|
556
582
|
'key and prompt return the original turn; a different prompt under it is refused.',
|
|
557
583
|
}),
|
|
584
|
+
'after-current': core_1.Flags.boolean({
|
|
585
|
+
description: 'Send this message for after the agent finishes what it is doing, instead of letting ' +
|
|
586
|
+
'it reach the work in progress. The message is kept on the server at once and starts ' +
|
|
587
|
+
'its own turn when the running one ends. Needs --conversation or --thread-root.',
|
|
588
|
+
}),
|
|
558
589
|
'wait-for-idle': core_1.Flags.boolean({
|
|
559
|
-
description: '
|
|
560
|
-
'
|
|
561
|
-
'
|
|
562
|
-
'
|
|
590
|
+
description: 'The same as --after-current: when the conversation already has a turn running, this ' +
|
|
591
|
+
'message waits for it to end and then starts its own turn. The CLI follows it until ' +
|
|
592
|
+
'then and streams the reply, for up to --wait-timeout. Against a server that cannot ' +
|
|
593
|
+
'keep the message, the CLI asks again every few seconds under the same ' +
|
|
594
|
+
'--idempotency-key instead.',
|
|
563
595
|
}),
|
|
564
596
|
'wait-timeout': core_1.Flags.integer({
|
|
565
|
-
description: 'Seconds --wait-for-idle
|
|
566
|
-
`(default ${agent_chat_start_1.DEFAULT_WAIT_FOR_IDLE_TIMEOUT_MS / 1000}).
|
|
597
|
+
description: 'Seconds --wait-for-idle follows the message before giving up ' +
|
|
598
|
+
`(default ${agent_chat_start_1.DEFAULT_WAIT_FOR_IDLE_TIMEOUT_MS / 1000}). The message stays on the server ` +
|
|
599
|
+
'and is still sent when the running turn ends.',
|
|
567
600
|
min: 1,
|
|
568
601
|
dependsOn: ['wait-for-idle'],
|
|
569
602
|
}),
|
|
570
603
|
'when-busy': core_1.Flags.string({
|
|
571
|
-
description: '
|
|
572
|
-
'
|
|
573
|
-
'
|
|
574
|
-
'
|
|
575
|
-
'
|
|
604
|
+
description: 'In an existing conversation a message is never refused because the agent is busy: ' +
|
|
605
|
+
'the server keeps it and decides how the agent sees it (it reaches the work in ' +
|
|
606
|
+
'progress, the agent reads it while it works, or it waits for its own turn). ' +
|
|
607
|
+
'`queue` is --after-current; `steer` is the default; `fail` refuses the message when a ' +
|
|
608
|
+
'turn is running, as older versions did. Needs --conversation or --thread-root.',
|
|
576
609
|
options: [...agent_chat_queue_1.WHEN_BUSY_MODES],
|
|
577
610
|
}),
|
|
578
611
|
detach: core_1.Flags.boolean({
|
|
579
|
-
description: '
|
|
580
|
-
'
|
|
581
|
-
|
|
612
|
+
description: 'In an existing conversation, return once the server has the message instead of ' +
|
|
613
|
+
'following it: no wait for its turn to start, nor for what the agent decided while it ' +
|
|
614
|
+
'worked. See what became of it with `agents queue list --conversation <id>` or in the chat.',
|
|
582
615
|
}),
|
|
583
616
|
'queue-timeout': core_1.Flags.integer({
|
|
584
|
-
description: 'Seconds
|
|
585
|
-
`(default ${agent_chat_queue_1.DEFAULT_QUEUE_WAIT_SECONDS}). The message stays
|
|
617
|
+
description: 'Seconds the CLI follows a message that waits for its own turn before giving up ' +
|
|
618
|
+
`(default ${agent_chat_queue_1.DEFAULT_QUEUE_WAIT_SECONDS}). The message stays on the server when it runs ` +
|
|
619
|
+
'out and is still sent.',
|
|
586
620
|
min: 1,
|
|
587
|
-
dependsOn: ['when-busy'],
|
|
588
621
|
}),
|
|
589
622
|
'repair-wait': core_1.Flags.integer({
|
|
590
623
|
description: 'Seconds to keep waiting when a platform update restarts the server relaying a turn ' +
|
|
@@ -813,10 +846,234 @@ class AgentsChat extends base_command_1.BaseCommand {
|
|
|
813
846
|
});
|
|
814
847
|
}
|
|
815
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* Inbound messages: in an existing conversation the message goes to the server's ingress, which
|
|
851
|
+
* keeps it at once and decides how the agent sees it, so a busy agent is never a refusal.
|
|
852
|
+
* Returns the turn to stream, `null` when there is nothing to stream (the message reached the
|
|
853
|
+
* agent another way, or `--detach`), or `'legacy'` when this server has no ingress.
|
|
854
|
+
*/
|
|
855
|
+
async sendThroughIngress(input) {
|
|
856
|
+
const conversationId = input.params.conversationId;
|
|
857
|
+
let sent;
|
|
858
|
+
try {
|
|
859
|
+
sent = await (0, agent_chat_start_1.startWithReplay)(() => (0, inbound_messages_1.sendInboundMessage)(input.params, {
|
|
860
|
+
messageId: (0, inbound_messages_1.inboundMessageIdFor)(input.startKey),
|
|
861
|
+
intent: input.intent,
|
|
862
|
+
}), {
|
|
863
|
+
onReplay: ({ attempt, of, waitMs }) => this.warn(`The server did not confirm the message; sending it again in ` +
|
|
864
|
+
`${Math.round(waitMs / 1000)}s (${attempt}/${of}). It keeps the one it already ` +
|
|
865
|
+
`has rather than a second copy.`),
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
catch (err) {
|
|
869
|
+
if ((0, inbound_messages_1.ingressMissing)(err))
|
|
870
|
+
return 'legacy';
|
|
871
|
+
if (err instanceof agent_chat_start_1.StartNotConfirmed) {
|
|
872
|
+
this.warn((0, agent_chat_start_1.startNotConfirmedHint)(input.startKey, err.attempts));
|
|
873
|
+
this.handleApiError(err.lastError);
|
|
874
|
+
}
|
|
875
|
+
this.handleApiError(err);
|
|
876
|
+
}
|
|
877
|
+
const { answer } = sent;
|
|
878
|
+
const messageId = answer.message?.messageId ?? sent.messageId;
|
|
879
|
+
const record = {
|
|
880
|
+
messageId,
|
|
881
|
+
conversationId,
|
|
882
|
+
route: answer.route,
|
|
883
|
+
state: answer.delivery?.state ?? null,
|
|
884
|
+
...(answer.idempotentReplay ? { replayed: true } : {}),
|
|
885
|
+
};
|
|
886
|
+
const sentence = (0, inbound_messages_1.deliverySentence)(answer.delivery) ?? inbound_messages_1.ROUTE_COPY.hold;
|
|
887
|
+
if (input.jsonl)
|
|
888
|
+
(0, agentic_stream_1.writeJsonLine)(process.stdout, { type: 'message.sent', ...record, sentence });
|
|
889
|
+
// A notice on the way, never on stdout unless it is a JSONL event.
|
|
890
|
+
const notice = (type, line, extra = {}) => {
|
|
891
|
+
if (input.jsonl)
|
|
892
|
+
(0, agentic_stream_1.writeJsonLine)(process.stdout, { type, messageId, ...extra, message: line });
|
|
893
|
+
else
|
|
894
|
+
this.warn(line);
|
|
895
|
+
};
|
|
896
|
+
// The command's answer when there is no reply to stream.
|
|
897
|
+
const finish = (extra, lines) => {
|
|
898
|
+
if (input.json) {
|
|
899
|
+
this.printJsonResult({ ...record, delivery: answer.delivery, ...extra });
|
|
900
|
+
}
|
|
901
|
+
else if (!input.jsonl) {
|
|
902
|
+
for (const line of lines)
|
|
903
|
+
this.log(line);
|
|
904
|
+
}
|
|
905
|
+
return null;
|
|
906
|
+
};
|
|
907
|
+
const next = (0, inbound_messages_1.nextAfterSend)(answer);
|
|
908
|
+
switch (next.kind) {
|
|
909
|
+
case 'turn':
|
|
910
|
+
return {
|
|
911
|
+
sessionId: next.sessionId,
|
|
912
|
+
conversationId,
|
|
913
|
+
responseMessageId: next.responseMessageId,
|
|
914
|
+
};
|
|
915
|
+
case 'delivered': {
|
|
916
|
+
const handling = answer.delivery?.handling;
|
|
917
|
+
const hint = (0, inbound_messages_1.notForTaskHint)(this.config.bin, conversationId, messageId, handling?.[handling.length - 1]);
|
|
918
|
+
return finish({ sentence, ...(hint ? { hint } : {}) }, hint ? [sentence, hint] : [sentence]);
|
|
919
|
+
}
|
|
920
|
+
case 'failed':
|
|
921
|
+
return this.failWithCliError({
|
|
922
|
+
message: sentence,
|
|
923
|
+
code: 'MESSAGE_NOT_DELIVERED',
|
|
924
|
+
exit: 1,
|
|
925
|
+
retryable: answer.delivery?.failed?.reason === 'usage_limit',
|
|
926
|
+
details: { ...record, reason: answer.delivery?.failed?.reason ?? null },
|
|
927
|
+
});
|
|
928
|
+
case 'glance': {
|
|
929
|
+
if (input.detach)
|
|
930
|
+
return finish({ sentence }, [sentence]);
|
|
931
|
+
if (!input.json && !input.jsonl)
|
|
932
|
+
this.warn(sentence);
|
|
933
|
+
const outcome = await (0, inbound_messages_1.waitForGlance)(conversationId, messageId);
|
|
934
|
+
const handled = outcome.handling
|
|
935
|
+
? (0, inbound_messages_1.handlingSentence)(outcome.handling)
|
|
936
|
+
: 'Your agent has not decided about this yet. It has the message; its answer will be ' +
|
|
937
|
+
'in the chat.';
|
|
938
|
+
if (input.jsonl) {
|
|
939
|
+
(0, agentic_stream_1.writeJsonLine)(process.stdout, {
|
|
940
|
+
type: 'message.handled',
|
|
941
|
+
messageId,
|
|
942
|
+
handling: outcome.handling,
|
|
943
|
+
reply: outcome.reply,
|
|
944
|
+
message: handled,
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
// A reply from the cloud says so before its words: it could not see the machine's files.
|
|
948
|
+
const label = outcome.reply?.cloudReply
|
|
949
|
+
? (0, cloud_reply_1.cloudReplyLine)({ communication: { cloudReply: outcome.reply.cloudReply } })
|
|
950
|
+
: null;
|
|
951
|
+
const taskHint = (0, inbound_messages_1.notForTaskHint)(this.config.bin, conversationId, messageId, outcome.handling);
|
|
952
|
+
return finish({
|
|
953
|
+
handling: outcome.handling,
|
|
954
|
+
reply: outcome.reply,
|
|
955
|
+
sentence: handled,
|
|
956
|
+
...(taskHint ? { hint: taskHint } : {}),
|
|
957
|
+
}, [label, outcome.reply?.text, handled, taskHint].filter((line) => !!line));
|
|
958
|
+
}
|
|
959
|
+
case 'wait':
|
|
960
|
+
break;
|
|
961
|
+
}
|
|
962
|
+
// The message waits for a turn of its own. Follow it until that turn starts, then stream it,
|
|
963
|
+
// when the caller asked to wait or the turn is only starting. Otherwise say why it waits and
|
|
964
|
+
// return: a script is never held for half an hour it did not ask for (decision 6.6).
|
|
965
|
+
notice('message.held', sentence);
|
|
966
|
+
const listHint = `${this.config.bin} agents queue list --conversation ${conversationId}`;
|
|
967
|
+
const starting = answer.route === 'new_turn';
|
|
968
|
+
if (input.detach || (!input.follow && !starting)) {
|
|
969
|
+
const where = `The message is kept and is sent by itself; see it with \`${listHint}\`, or pass ` +
|
|
970
|
+
'--wait-for-idle to follow it and stream the reply.';
|
|
971
|
+
return finish({ sentence, hint: where }, input.detach ? [] : [where]);
|
|
972
|
+
}
|
|
973
|
+
let waited;
|
|
974
|
+
try {
|
|
975
|
+
waited = await (0, agent_chat_queue_1.waitForQueuedTurn)({
|
|
976
|
+
conversationId,
|
|
977
|
+
clientInputId: messageId,
|
|
978
|
+
sessionId: sent.sessionId,
|
|
979
|
+
responseMessageId: sent.responseMessageId,
|
|
980
|
+
}, {
|
|
981
|
+
timeoutMs: input.timeoutMs,
|
|
982
|
+
onPaused: (line) => notice('message.paused', line),
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
catch (err) {
|
|
986
|
+
this.handleApiError(err);
|
|
987
|
+
}
|
|
988
|
+
switch (waited.outcome) {
|
|
989
|
+
case 'sent':
|
|
990
|
+
return {
|
|
991
|
+
sessionId: sent.sessionId,
|
|
992
|
+
conversationId,
|
|
993
|
+
responseMessageId: sent.responseMessageId,
|
|
994
|
+
};
|
|
995
|
+
case 'held':
|
|
996
|
+
return this.failWithCliError({
|
|
997
|
+
message: `Your message is kept but not sent: ${waited.reason}${waited.card.holdMessage ? ` ${waited.card.holdMessage}` : ''} See it with \`${listHint}\`.`,
|
|
998
|
+
code: 'INPUT_QUEUE_HELD',
|
|
999
|
+
status: 409,
|
|
1000
|
+
exit: 1,
|
|
1001
|
+
retryable: false,
|
|
1002
|
+
details: {
|
|
1003
|
+
...record,
|
|
1004
|
+
cardId: waited.card.cardId,
|
|
1005
|
+
holdReason: waited.card.holdReason ?? null,
|
|
1006
|
+
holdCode: waited.card.holdCode ?? null,
|
|
1007
|
+
},
|
|
1008
|
+
});
|
|
1009
|
+
case 'not_sent': {
|
|
1010
|
+
// It left the queue without a turn of its own: read what became of it.
|
|
1011
|
+
let now;
|
|
1012
|
+
try {
|
|
1013
|
+
now = await (0, inbound_messages_1.readMessageDelivery)(conversationId, messageId);
|
|
1014
|
+
}
|
|
1015
|
+
catch (err) {
|
|
1016
|
+
this.handleApiError(err);
|
|
1017
|
+
}
|
|
1018
|
+
if (!now) {
|
|
1019
|
+
return this.failWithCliError({
|
|
1020
|
+
message: 'The message was taken back from another screen, so it was not sent.',
|
|
1021
|
+
code: 'MESSAGE_WITHDRAWN',
|
|
1022
|
+
status: 409,
|
|
1023
|
+
exit: 1,
|
|
1024
|
+
retryable: false,
|
|
1025
|
+
details: record,
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
if (now.delivery?.state === 'failed') {
|
|
1029
|
+
return this.failWithCliError({
|
|
1030
|
+
message: (0, inbound_messages_1.deliverySentence)(now.delivery) ?? inbound_messages_1.FAILED_COPY.refused,
|
|
1031
|
+
code: 'MESSAGE_NOT_DELIVERED',
|
|
1032
|
+
exit: 1,
|
|
1033
|
+
retryable: now.delivery.failed?.reason === 'usage_limit',
|
|
1034
|
+
details: { ...record, reason: now.delivery.failed?.reason ?? null },
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
const line = (0, inbound_messages_1.deliverySentence)(now.delivery) ?? 'Your agent has the message.';
|
|
1038
|
+
return finish({ delivery: now.delivery, sentence: line }, [line]);
|
|
1039
|
+
}
|
|
1040
|
+
default:
|
|
1041
|
+
return this.failWithCliError({
|
|
1042
|
+
message: `Your agent was still working after ${Math.round(input.timeoutMs / 1000)}s. ` +
|
|
1043
|
+
`Your message is kept and is sent when it finishes; see it with \`${listHint}\`.`,
|
|
1044
|
+
code: 'INPUT_QUEUE_WAIT_TIMEOUT',
|
|
1045
|
+
status: 408,
|
|
1046
|
+
exit: 1,
|
|
1047
|
+
retryable: true,
|
|
1048
|
+
details: record,
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
816
1052
|
async run() {
|
|
817
1053
|
this.requireAuth();
|
|
818
1054
|
const { args, flags } = await this.parse(AgentsChat);
|
|
819
|
-
const
|
|
1055
|
+
const explicitWhenBusy = flags['when-busy'];
|
|
1056
|
+
// An older server without the ingress: `--after-current` falls back to its queue (below).
|
|
1057
|
+
let whenBusy = explicitWhenBusy ?? 'fail';
|
|
1058
|
+
const inConversation = Boolean(flags.conversation || flags['thread-root']);
|
|
1059
|
+
if (flags['after-current']) {
|
|
1060
|
+
if (!inConversation) {
|
|
1061
|
+
this.error('--after-current needs --conversation or --thread-root: a new conversation has ' +
|
|
1062
|
+
'nothing running to wait for.', { exit: 2 });
|
|
1063
|
+
}
|
|
1064
|
+
if (explicitWhenBusy === 'fail' || explicitWhenBusy === 'steer') {
|
|
1065
|
+
this.error(`--after-current and --when-busy ${explicitWhenBusy} ask for different things; pass one.`, { exit: 2 });
|
|
1066
|
+
}
|
|
1067
|
+
if (flags.quick)
|
|
1068
|
+
this.error('--after-current needs a runtime turn; remove --quick.', { exit: 2 });
|
|
1069
|
+
}
|
|
1070
|
+
if ((flags.detach || flags['queue-timeout'] !== undefined) && !inConversation) {
|
|
1071
|
+
this.error('--detach and --queue-timeout need --conversation or --thread-root: they follow a ' +
|
|
1072
|
+
'message the server keeps in an existing conversation.', { exit: 2 });
|
|
1073
|
+
}
|
|
1074
|
+
if (flags.detach && explicitWhenBusy === 'fail') {
|
|
1075
|
+
this.error('--detach has nothing to follow with --when-busy fail; pass one.', { exit: 2 });
|
|
1076
|
+
}
|
|
820
1077
|
if (whenBusy !== 'fail' && flags['wait-for-idle']) {
|
|
821
1078
|
this.error('--when-busy and --wait-for-idle are two answers to the same question; pass one.', {
|
|
822
1079
|
exit: 2,
|
|
@@ -998,85 +1255,125 @@ class AgentsChat extends base_command_1.BaseCommand {
|
|
|
998
1255
|
this.error(`--idempotency-key must be ${agent_chat_start_1.START_KEY_RULE}.`, { exit: 2 });
|
|
999
1256
|
}
|
|
1000
1257
|
const startKey = suppliedStartKey ?? (0, agent_chat_start_1.newStartKey)();
|
|
1258
|
+
const turnText = contextParts ? `${contextParts}\n\n${prompt}` : prompt;
|
|
1001
1259
|
let started;
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
}
|
|
1028
|
-
: {}),
|
|
1260
|
+
// Inbound messages: a message to an existing conversation goes to the ingress, which keeps it
|
|
1261
|
+
// and decides how the agent sees it. `--when-busy fail` asks for the older refusal instead.
|
|
1262
|
+
let viaIngress = false;
|
|
1263
|
+
if (threadConversationId && explicitWhenBusy !== 'fail') {
|
|
1264
|
+
const sent = await this.sendThroughIngress({
|
|
1265
|
+
params: {
|
|
1266
|
+
agentId: args.agentId,
|
|
1267
|
+
taskId: boundTaskId,
|
|
1268
|
+
text: turnText,
|
|
1269
|
+
conversationId: threadConversationId,
|
|
1270
|
+
workspaceId: process.env.OVERSKY_WORKSPACE_ID,
|
|
1271
|
+
...daemonPinFields(localSkills, flags.daemon),
|
|
1272
|
+
...permissionModeFields(flags['permission-mode']),
|
|
1273
|
+
},
|
|
1274
|
+
startKey,
|
|
1275
|
+
intent: flags['after-current'] || flags['wait-for-idle'] || whenBusy === 'queue'
|
|
1276
|
+
? 'after_current'
|
|
1277
|
+
: 'now',
|
|
1278
|
+
detach: Boolean(flags.detach),
|
|
1279
|
+
follow: Boolean(flags['after-current'] || flags['wait-for-idle'] || explicitWhenBusy),
|
|
1280
|
+
timeoutMs: flags['wait-for-idle']
|
|
1281
|
+
? (flags['wait-timeout'] ?? agent_chat_start_1.DEFAULT_WAIT_FOR_IDLE_TIMEOUT_MS / 1000) * 1000
|
|
1282
|
+
: (flags['queue-timeout'] ?? agent_chat_queue_1.DEFAULT_QUEUE_WAIT_SECONDS) * 1000,
|
|
1283
|
+
json: Boolean(flags.json),
|
|
1284
|
+
jsonl: Boolean(flags.jsonl),
|
|
1029
1285
|
});
|
|
1286
|
+
if (sent === null)
|
|
1287
|
+
return;
|
|
1288
|
+
if (sent === 'legacy') {
|
|
1289
|
+
if (flags['after-current'] && whenBusy === 'fail')
|
|
1290
|
+
whenBusy = 'queue';
|
|
1291
|
+
}
|
|
1292
|
+
else {
|
|
1293
|
+
started = sent;
|
|
1294
|
+
viaIngress = true;
|
|
1295
|
+
}
|
|
1030
1296
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
if (busy && whenBusy !== 'fail' && threadConversationId) {
|
|
1038
|
-
const queued = await this.startThroughQueue({
|
|
1039
|
-
whenBusy,
|
|
1297
|
+
if (!viaIngress) {
|
|
1298
|
+
try {
|
|
1299
|
+
started = await (0, agent_chat_start_1.startWithReplay)(() => data_provider_1.dataService.startAgenticChat({
|
|
1300
|
+
agentId: args.agentId,
|
|
1301
|
+
taskId: boundTaskId,
|
|
1302
|
+
text: turnText,
|
|
1040
1303
|
conversationId: threadConversationId,
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1304
|
+
workspaceId: process.env.OVERSKY_WORKSPACE_ID,
|
|
1305
|
+
clientRequestId: startKey,
|
|
1306
|
+
// The server resolves each ref against the session's daemon, so the
|
|
1307
|
+
// turn is asked to run on the machine that listed them. An agent whose
|
|
1308
|
+
// execution policy places it elsewhere keeps that placement, and the
|
|
1309
|
+
// run fails saying why rather than running without the skill.
|
|
1310
|
+
...daemonPinFields(localSkills, flags.daemon),
|
|
1311
|
+
...permissionModeFields(flags['permission-mode']),
|
|
1312
|
+
}), {
|
|
1313
|
+
// stderr, so stdout and --json/--jsonl stay parseable.
|
|
1314
|
+
onReplay: ({ attempt, of, waitMs }) => this.warn(`The server did not confirm the start; sending the same request again in ` +
|
|
1315
|
+
`${Math.round(waitMs / 1000)}s (${attempt}/${of}). It returns the turn it ` +
|
|
1316
|
+
`already accepted rather than starting a second one.`),
|
|
1317
|
+
...(flags['wait-for-idle']
|
|
1318
|
+
? {
|
|
1319
|
+
waitForIdle: {
|
|
1320
|
+
timeoutMs: (flags['wait-timeout'] ?? agent_chat_start_1.DEFAULT_WAIT_FOR_IDLE_TIMEOUT_MS / 1000) * 1000,
|
|
1321
|
+
onBusy: (info) => this.warn((0, agent_chat_start_1.busyWaitNotice)(info, threadConversationId)),
|
|
1322
|
+
},
|
|
1323
|
+
}
|
|
1324
|
+
: {}),
|
|
1054
1325
|
});
|
|
1055
|
-
if (!queued)
|
|
1056
|
-
return;
|
|
1057
|
-
started = queued;
|
|
1058
1326
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1327
|
+
catch (err) {
|
|
1328
|
+
// OSK-32920 — a conversation that already has a turn running answers
|
|
1329
|
+
// `429 conversation_busy`. Read by the generic path it printed the server's
|
|
1330
|
+
// "Please wait." with no word on whether anything was sent or how to wait.
|
|
1331
|
+
const busy = (0, agent_chat_start_1.busyStartFailure)(err, threadConversationId);
|
|
1332
|
+
// G7 — or the turn is queued on the server (or steered into the running one).
|
|
1333
|
+
if (busy && whenBusy !== 'fail' && threadConversationId) {
|
|
1334
|
+
const queued = await this.startThroughQueue({
|
|
1335
|
+
whenBusy,
|
|
1336
|
+
conversationId: threadConversationId,
|
|
1337
|
+
startKey,
|
|
1338
|
+
params: {
|
|
1339
|
+
agentId: args.agentId,
|
|
1340
|
+
taskId: boundTaskId,
|
|
1341
|
+
text: turnText,
|
|
1342
|
+
conversationId: threadConversationId,
|
|
1343
|
+
workspaceId: process.env.OVERSKY_WORKSPACE_ID,
|
|
1344
|
+
...daemonPinFields(localSkills, flags.daemon),
|
|
1345
|
+
...permissionModeFields(flags['permission-mode']),
|
|
1346
|
+
},
|
|
1347
|
+
detach: Boolean(flags.detach),
|
|
1348
|
+
timeoutMs: (flags['queue-timeout'] ?? agent_chat_queue_1.DEFAULT_QUEUE_WAIT_SECONDS) * 1000,
|
|
1349
|
+
json: Boolean(flags.json || flags.jsonl),
|
|
1068
1350
|
});
|
|
1351
|
+
if (!queued)
|
|
1352
|
+
return;
|
|
1353
|
+
started = queued;
|
|
1069
1354
|
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1355
|
+
else {
|
|
1356
|
+
if (busy) {
|
|
1357
|
+
this.failWithCliError({
|
|
1358
|
+
message: busy.message,
|
|
1359
|
+
code: busy.code,
|
|
1360
|
+
status: busy.status,
|
|
1361
|
+
exit: 1,
|
|
1362
|
+
retryable: busy.retryable,
|
|
1363
|
+
details: busy.details,
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
if (err instanceof agent_chat_start_1.StartNotConfirmed) {
|
|
1367
|
+
this.warn((0, agent_chat_start_1.startNotConfirmedHint)(startKey, err.attempts));
|
|
1368
|
+
this.handleApiError(err.lastError);
|
|
1369
|
+
}
|
|
1370
|
+
// A refused start was the one API error on this command that escaped
|
|
1371
|
+
// `handleApiError`: it fell through to the generic catch, which printed
|
|
1372
|
+
// `HTTP 400 Bad Request — POST …/api/agentic/chat` under the code
|
|
1373
|
+
// CLI_PARSE_ERROR and dropped the body that said WHY ("The configured
|
|
1374
|
+
// model is not supported."). The reader had to guess (OSK-4897).
|
|
1375
|
+
this.handleApiError(err);
|
|
1073
1376
|
}
|
|
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
1377
|
}
|
|
1081
1378
|
}
|
|
1082
1379
|
if (!started)
|
|
@@ -1087,12 +1384,18 @@ class AgentsChat extends base_command_1.BaseCommand {
|
|
|
1087
1384
|
// answer used to be adopted; a workspace the caller chose still wins, and
|
|
1088
1385
|
// an autonomous process still never takes one. It also tells us whether
|
|
1089
1386
|
// this server chooses the workspace itself, for the next turn.
|
|
1090
|
-
|
|
1387
|
+
// A message to the ingress answers with no workspace of its own: the conversation already
|
|
1388
|
+
// has one, so there is nothing to observe or adopt.
|
|
1389
|
+
const workspaceDefault = viaIngress
|
|
1390
|
+
? null
|
|
1391
|
+
: (0, agent_home_workspace_1.recordAgentHomeDefaultObservation)(this.config?.cacheDir, this.cliConfig.baseURL, started);
|
|
1091
1392
|
if (serverChoosesWorkspace && workspaceDefault === 'unsupported') {
|
|
1092
1393
|
this.warn('This server no longer chooses the agent’s home workspace, so this turn ran without ' +
|
|
1093
1394
|
'one. The next turn will select it again; pass --workspace to choose one now.');
|
|
1094
1395
|
}
|
|
1095
|
-
(
|
|
1396
|
+
if (!viaIngress) {
|
|
1397
|
+
(0, agent_home_workspace_1.commitAgentHomeWorkspaceDefault)(typeof started.workspaceId === 'string' && started.workspaceId ? started.workspaceId : null);
|
|
1398
|
+
}
|
|
1096
1399
|
if (!started.sessionId) {
|
|
1097
1400
|
this.error('Agentic chat was accepted without a session ID; cannot attach the stream.', {
|
|
1098
1401
|
exit: 1,
|
|
@@ -1389,6 +1692,13 @@ class AgentsChat extends base_command_1.BaseCommand {
|
|
|
1389
1692
|
// (Not after SIGHUP: the terminal that would show it is gone.)
|
|
1390
1693
|
this.log(`\n${cancelledRunMessage({ sessionId: started.sessionId, conversationId: started.conversationId })}`);
|
|
1391
1694
|
}
|
|
1695
|
+
// Human modes say it under the answer, on stderr. `--jsonl` carries it on `run.completed`
|
|
1696
|
+
// and `run.result`, `--json` in its payload (OSK-33192).
|
|
1697
|
+
const downgraded = !flags.jsonl && !(quiet && flags.json) && result.status === 'completed'
|
|
1698
|
+
? interactionUnavailableFrom(result.lastEvent)
|
|
1699
|
+
: undefined;
|
|
1700
|
+
if (downgraded)
|
|
1701
|
+
this.warn(interactionUnavailableWarning(downgraded));
|
|
1392
1702
|
// If completion wins the Ctrl-C race, preserve the completed run's exit status.
|
|
1393
1703
|
if (cancelledBy || interruptedBy === 'SIGTERM' || interruptedBy === 'SIGHUP') {
|
|
1394
1704
|
process.exitCode = interruptExitCode(interruptedBy);
|
|
@@ -216,7 +216,7 @@ class AgentsImport extends base_command_1.BaseCommand {
|
|
|
216
216
|
});
|
|
217
217
|
}
|
|
218
218
|
if (flags.json) {
|
|
219
|
-
this.
|
|
219
|
+
this.printJsonResult({ output: flags.output, document, dropped });
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
222
|
this.log(`Wrote ${Object.keys(document.spec).length} field(s) to ${flags.output}.`);
|
|
@@ -275,7 +275,7 @@ class AgentsImport extends base_command_1.BaseCommand {
|
|
|
275
275
|
this.handleApiError(err, { subject: `skill ${skill.name}` });
|
|
276
276
|
}
|
|
277
277
|
if (flags.json) {
|
|
278
|
-
this.
|
|
278
|
+
this.printJsonResult({ skill: created, attachedTo: flags.agent ?? null, dropped });
|
|
279
279
|
return;
|
|
280
280
|
}
|
|
281
281
|
this.log(flags.agent
|
|
@@ -352,7 +352,7 @@ class AgentsImport extends base_command_1.BaseCommand {
|
|
|
352
352
|
};
|
|
353
353
|
if (!flags.agent) {
|
|
354
354
|
if (flags.json) {
|
|
355
|
-
this.
|
|
355
|
+
this.printJsonResult({ applied: false, ...(0, plan_1.planForOutput)(plan) });
|
|
356
356
|
return;
|
|
357
357
|
}
|
|
358
358
|
showPlan();
|
|
@@ -19,13 +19,14 @@ class AgentsManagerStatus extends base_command_1.BaseCommand {
|
|
|
19
19
|
this.requireAuth();
|
|
20
20
|
const { flags } = await this.parse(AgentsManagerStatus);
|
|
21
21
|
try {
|
|
22
|
-
const { workspaceId, agent: manager, duty: staffingDuty } = await data_provider_1.dataService.getAgentManagerStatus();
|
|
22
|
+
const { workspaceId, agent: manager, duty: staffingDuty, } = await data_provider_1.dataService.getAgentManagerStatus();
|
|
23
23
|
const agent = manager && (0, web_url_1.withAgentUrl)(this.cliConfig.baseURL, manager);
|
|
24
24
|
const detail = staffingDuty ? await duties_1.dutyApi.get(staffingDuty.id) : null;
|
|
25
|
-
const duty = staffingDuty &&
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const duty = staffingDuty &&
|
|
26
|
+
(0, web_url_1.withDutyUrl)(this.cliConfig.baseURL, {
|
|
27
|
+
...staffingDuty,
|
|
28
|
+
status: detail?.duty?.status ?? staffingDuty.status,
|
|
29
|
+
});
|
|
29
30
|
const historyAvailable = detail ? (0, duty_history_source_1.hasVerifiedDutyHistorySource)(detail) : null;
|
|
30
31
|
const operatingTrigger = historyAvailable ? detail?.operatingState?.trigger : null;
|
|
31
32
|
const trigger = operatingTrigger
|
|
@@ -43,7 +44,7 @@ class AgentsManagerStatus extends base_command_1.BaseCommand {
|
|
|
43
44
|
}
|
|
44
45
|
: null;
|
|
45
46
|
if (flags.json) {
|
|
46
|
-
this.
|
|
47
|
+
this.printJsonResult({ workspaceId, agent, duty, trigger, historyAvailable, latestCheck });
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
50
|
if (!agent) {
|