@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
|
@@ -22,9 +22,12 @@ function proactiveBaselineLines(b) {
|
|
|
22
22
|
(b.systemLoops.blocked?.length
|
|
23
23
|
? ` (cannot run: ${b.systemLoops.blocked.map((loop) => `${loop.role} - ${loop.reason}`).join(', ')})`
|
|
24
24
|
: '');
|
|
25
|
+
// `enabled` is each watcher's own switch. The task/goal and memory scans also wait for
|
|
26
|
+
// Always-On, the way the Duty checks do (OSK-33262); the other watchers do not.
|
|
25
27
|
const watchers = b.watchers.status === 'unknown'
|
|
26
28
|
? 'unknown'
|
|
27
|
-
: `${b.watchers.total} (${b.watchers.enabled} enabled;
|
|
29
|
+
: `${b.watchers.total} (${b.watchers.enabled} enabled; ` +
|
|
30
|
+
'task/goal and memory scans run only while Always-On is on)';
|
|
28
31
|
// `unknown` also means "present, but who wrote it is not recorded" (a Compass applied from a
|
|
29
32
|
// spec, say); only an unreadable one is listed under `unknown[]`. Printing "Compass unknown"
|
|
30
33
|
// beside an empty `unknown` list read like a failed read (OSK-22348).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ChatStopPreview, type ChatStopReceipt, type StopScope, type ChatStopTaskOutcome } from '@skrr-ai/data-provider';
|
|
2
|
+
/**
|
|
3
|
+
* Stop in an Agent's chat from a terminal (inbound messages, decision D9): what Stop all would
|
|
4
|
+
* stop, the stop itself, and the CLI's words for its receipt. A plain Stop stops the
|
|
5
|
+
* conversation's own work and never a Task; `--all` also stops the Tasks it launched.
|
|
6
|
+
*/
|
|
7
|
+
/** What became of a Task Stop all looked at, after its name. One entry per outcome. */
|
|
8
|
+
export declare const STOP_TASK_OUTCOME_WORDS: Record<ChatStopTaskOutcome, string>;
|
|
9
|
+
export declare function readStopPreview(conversationId: string): Promise<ChatStopPreview>;
|
|
10
|
+
export declare function requestStop(conversationId: string, scope: StopScope, stopId: string): Promise<ChatStopReceipt>;
|
|
11
|
+
/** The receipt as lines: what stopped, what keeps running, and that nothing is undone. */
|
|
12
|
+
export declare function describeStopReceipt(receipt: ChatStopReceipt, hint: {
|
|
13
|
+
bin: string;
|
|
14
|
+
conversationId: string;
|
|
15
|
+
}): string[];
|
|
16
|
+
/** The preview as lines, for `--dry-run`. */
|
|
17
|
+
export declare function describeStopPreview(preview: ChatStopPreview): string[];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STOP_TASK_OUTCOME_WORDS = void 0;
|
|
4
|
+
exports.readStopPreview = readStopPreview;
|
|
5
|
+
exports.requestStop = requestStop;
|
|
6
|
+
exports.describeStopReceipt = describeStopReceipt;
|
|
7
|
+
exports.describeStopPreview = describeStopPreview;
|
|
8
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
9
|
+
/**
|
|
10
|
+
* Stop in an Agent's chat from a terminal (inbound messages, decision D9): what Stop all would
|
|
11
|
+
* stop, the stop itself, and the CLI's words for its receipt. A plain Stop stops the
|
|
12
|
+
* conversation's own work and never a Task; `--all` also stops the Tasks it launched.
|
|
13
|
+
*/
|
|
14
|
+
/** What became of a Task Stop all looked at, after its name. One entry per outcome. */
|
|
15
|
+
exports.STOP_TASK_OUTCOME_WORDS = {
|
|
16
|
+
stopped: 'stopped',
|
|
17
|
+
not_running: 'had already finished',
|
|
18
|
+
not_allowed: 'not stopped: you can no longer change it',
|
|
19
|
+
unconfirmed: 'may still be running; stop it from its own card',
|
|
20
|
+
};
|
|
21
|
+
function readStopPreview(conversationId) {
|
|
22
|
+
return data_provider_1.dataService.getConversationStopPreview(conversationId);
|
|
23
|
+
}
|
|
24
|
+
function requestStop(conversationId, scope, stopId) {
|
|
25
|
+
return data_provider_1.dataService.stopConversationWork(conversationId, { scope, stopId });
|
|
26
|
+
}
|
|
27
|
+
function names(tasks) {
|
|
28
|
+
return tasks.map(data_provider_1.chatStopTaskName).join(', ');
|
|
29
|
+
}
|
|
30
|
+
const tasksWord = (count) => (count === 1 ? 'Task' : 'Tasks');
|
|
31
|
+
/** The receipt as lines: what stopped, what keeps running, and that nothing is undone. */
|
|
32
|
+
function describeStopReceipt(receipt, hint) {
|
|
33
|
+
const lines = [];
|
|
34
|
+
const stopped = receipt.tasks.filter((task) => task.outcome === 'stopped');
|
|
35
|
+
if (receipt.workStopped)
|
|
36
|
+
lines.push('Stopped what your agent was doing in this conversation.');
|
|
37
|
+
else
|
|
38
|
+
lines.push('Your agent was not working in this conversation.');
|
|
39
|
+
for (const task of receipt.tasks) {
|
|
40
|
+
lines.push(` ${(0, data_provider_1.chatStopTaskName)(task)}: ${exports.STOP_TASK_OUTCOME_WORDS[task.outcome]}`);
|
|
41
|
+
}
|
|
42
|
+
const still = receipt.stillRunning;
|
|
43
|
+
if (still && still.length > 0) {
|
|
44
|
+
const count = still.length;
|
|
45
|
+
lines.push(receipt.scope === 'all'
|
|
46
|
+
? `${count} ${tasksWord(count)} it started may still be running: ${names(still)}.`
|
|
47
|
+
: `${count} ${tasksWord(count)} it started from here ${count === 1 ? 'keeps' : 'keep'} running: ${names(still)}. ` +
|
|
48
|
+
`Stop them too with \`${hint.bin} agents stop --conversation ${hint.conversationId} --all\`.`);
|
|
49
|
+
}
|
|
50
|
+
if (receipt.workStopped || stopped.length > 0) {
|
|
51
|
+
lines.push('What was already done is not undone.');
|
|
52
|
+
}
|
|
53
|
+
return lines;
|
|
54
|
+
}
|
|
55
|
+
/** The preview as lines, for `--dry-run`. */
|
|
56
|
+
function describeStopPreview(preview) {
|
|
57
|
+
const lines = [
|
|
58
|
+
preview.workRunning
|
|
59
|
+
? 'Your agent is working in this conversation; Stop stops that.'
|
|
60
|
+
: 'Your agent is not working in this conversation.',
|
|
61
|
+
];
|
|
62
|
+
if (preview.tasks.length === 0) {
|
|
63
|
+
lines.push('No Task it started from here is running.');
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const count = preview.tasks.length;
|
|
67
|
+
lines.push(`--all also stops ${count} ${tasksWord(count)} it started from here: ${names(preview.tasks)}.`);
|
|
68
|
+
}
|
|
69
|
+
return lines;
|
|
70
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An agent that answered from the cloud while its machine could not (inbound messages, decision
|
|
3
|
+
* D4). The sentences match the web's (`client/src/components/Chat/Messages/Delivery/
|
|
4
|
+
* cloudReplyCopy.ts`), and each table is a `Record` over the contract's closed list, so a new
|
|
5
|
+
* reason does not compile without words here.
|
|
6
|
+
*/
|
|
7
|
+
import { type CloudReplyReason, type CloudReplySettingRefusal, type MessageCloudReply } from '@skrr-ai/data-provider';
|
|
8
|
+
type Named = (machine?: string) => string;
|
|
9
|
+
/** The label on the agent message, and what became of the person's message. */
|
|
10
|
+
export declare const CLOUD_REPLY_COPY: Record<CloudReplyReason, {
|
|
11
|
+
label: Named;
|
|
12
|
+
deferred: Named;
|
|
13
|
+
notCarriedOut: Named;
|
|
14
|
+
}>;
|
|
15
|
+
/** The label for an agent message's metadata, or null when it was not written from the cloud. */
|
|
16
|
+
export declare function cloudReplyLine(metadata: unknown): string | null;
|
|
17
|
+
/** What a handling written from the cloud says, for the decisions whose words differ. */
|
|
18
|
+
export declare function cloudHandlingSentence(cloud: MessageCloudReply, kind: 'deferred' | 'not_carried_out'): string;
|
|
19
|
+
/** Why the setting could not be turned on. */
|
|
20
|
+
export declare const CLOUD_REPLY_SETTING_REFUSAL_COPY: Record<CloudReplySettingRefusal, string>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLOUD_REPLY_SETTING_REFUSAL_COPY = exports.CLOUD_REPLY_COPY = void 0;
|
|
4
|
+
exports.cloudReplyLine = cloudReplyLine;
|
|
5
|
+
exports.cloudHandlingSentence = cloudHandlingSentence;
|
|
6
|
+
/**
|
|
7
|
+
* An agent that answered from the cloud while its machine could not (inbound messages, decision
|
|
8
|
+
* D4). The sentences match the web's (`client/src/components/Chat/Messages/Delivery/
|
|
9
|
+
* cloudReplyCopy.ts`), and each table is a `Record` over the contract's closed list, so a new
|
|
10
|
+
* reason does not compile without words here.
|
|
11
|
+
*/
|
|
12
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
13
|
+
const UNTIL_WORK_ENDS = "It will take it up when it finishes what it's doing.";
|
|
14
|
+
/** The label on the agent message, and what became of the person's message. */
|
|
15
|
+
exports.CLOUD_REPLY_COPY = {
|
|
16
|
+
machine_offline: {
|
|
17
|
+
label: (m) => m
|
|
18
|
+
? `From the cloud: ${m} was offline, so your agent couldn't see its files.`
|
|
19
|
+
: "From the cloud: your agent's machine was offline, so it couldn't see its files.",
|
|
20
|
+
deferred: (m) => m
|
|
21
|
+
? `Your agent will take this up on ${m} when it's back.`
|
|
22
|
+
: 'Your agent will take this up when its machine is back.',
|
|
23
|
+
notCarriedOut: (m) => m
|
|
24
|
+
? `Your agent couldn't do this from the cloud. It will take it up on ${m} when it's back.`
|
|
25
|
+
: "Your agent couldn't do this from the cloud. It will take it up when its machine is back.",
|
|
26
|
+
},
|
|
27
|
+
machine_busy: {
|
|
28
|
+
label: (m) => m
|
|
29
|
+
? `From the cloud: ${m} was busy, so your agent couldn't see its files.`
|
|
30
|
+
: "From the cloud: your agent's machine was busy, so it couldn't see its files.",
|
|
31
|
+
// A busy machine still runs the work: what waits there waits for that work.
|
|
32
|
+
deferred: () => "Your agent will take this up when it finishes what it's doing.",
|
|
33
|
+
notCarriedOut: () => `Your agent couldn't do this from the cloud. ${UNTIL_WORK_ENDS}`,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
/** The label for an agent message's metadata, or null when it was not written from the cloud. */
|
|
37
|
+
function cloudReplyLine(metadata) {
|
|
38
|
+
const cloud = (0, data_provider_1.messageCloudReply)(metadata);
|
|
39
|
+
return cloud ? exports.CLOUD_REPLY_COPY[cloud.reason].label(cloud.machineName) : null;
|
|
40
|
+
}
|
|
41
|
+
/** What a handling written from the cloud says, for the decisions whose words differ. */
|
|
42
|
+
function cloudHandlingSentence(cloud, kind) {
|
|
43
|
+
const copy = exports.CLOUD_REPLY_COPY[cloud.reason];
|
|
44
|
+
return kind === 'deferred'
|
|
45
|
+
? copy.deferred(cloud.machineName)
|
|
46
|
+
: copy.notCarriedOut(cloud.machineName);
|
|
47
|
+
}
|
|
48
|
+
/** Why the setting could not be turned on. */
|
|
49
|
+
exports.CLOUD_REPLY_SETTING_REFUSAL_COPY = {
|
|
50
|
+
cloud_reply_needs_cloud_target: "Answering from the cloud needs a cloud runtime in this agent's runtime order. Add an Agent " +
|
|
51
|
+
'Worker or a Hosted Machine to it, then turn this on.',
|
|
52
|
+
};
|
package/dist/lib/duties.d.ts
CHANGED
|
@@ -1150,6 +1150,16 @@ export declare function renderCheckList(checks: DutyCheckView[], log: (line: str
|
|
|
1150
1150
|
type ReadModelRecord = Record<string, unknown>;
|
|
1151
1151
|
/** Human view for `duties ledger`; JSON remains the automation surface. */
|
|
1152
1152
|
export declare function renderDutyLedger(ledger: ReadModelRecord, log: (line: string) => void): void;
|
|
1153
|
+
/**
|
|
1154
|
+
* Why a Run was started, on one line, from the server's `startedBecause` (OSK-20265): its text, then
|
|
1155
|
+
* whether it was derived, cut, or a retry. `null` when the server sent none (a server older than the
|
|
1156
|
+
* record): nothing is invented, and the Run's `reason`, its LATEST transition, is not a substitute.
|
|
1157
|
+
* Read defensively, because the ledger carries it untyped. `retryOfRunId` is derived on the server
|
|
1158
|
+
* without a lookup, so it is printed as a claim, `(not checked)`.
|
|
1159
|
+
*/
|
|
1160
|
+
export declare function describeRunStart(start: unknown): string | null;
|
|
1161
|
+
/** `run <id> started because: …` for every surface that lists Runs; `null` when the server did not say. */
|
|
1162
|
+
export declare function runStartLine(runId: unknown, start: unknown, noun?: 'run' | 'Run'): string | null;
|
|
1153
1163
|
export declare function renderDutyTrace(trace: ReadModelRecord, log: (line: string) => void): void;
|
|
1154
1164
|
export declare function renderProactivenessScorecard(scorecard: ReadModelRecord, log: (line: string) => void): void;
|
|
1155
1165
|
/** A run the server marks as held for its owner's result recovery review (OSK-24685). */
|
package/dist/lib/duties.js
CHANGED
|
@@ -43,6 +43,8 @@ exports.renderDutySummary = renderDutySummary;
|
|
|
43
43
|
exports.describeWakeDecision = describeWakeDecision;
|
|
44
44
|
exports.renderCheckList = renderCheckList;
|
|
45
45
|
exports.renderDutyLedger = renderDutyLedger;
|
|
46
|
+
exports.describeRunStart = describeRunStart;
|
|
47
|
+
exports.runStartLine = runStartLine;
|
|
46
48
|
exports.renderDutyTrace = renderDutyTrace;
|
|
47
49
|
exports.renderProactivenessScorecard = renderProactivenessScorecard;
|
|
48
50
|
exports.isHeldCycleRun = isHeldCycleRun;
|
|
@@ -225,7 +227,8 @@ exports.dutyApi = {
|
|
|
225
227
|
livenessSweep: () => data_provider_2.request.get('/api/duties/liveness/sweep'),
|
|
226
228
|
/** One agent's Duties, system roles included, each with its loop status. */
|
|
227
229
|
roster: (agentId) => data_provider_2.request.get((0, triggers_1.withQuery)('/api/duties/roster', {
|
|
228
|
-
agentId,
|
|
230
|
+
agentId,
|
|
231
|
+
coverage: 'current-agent',
|
|
229
232
|
})),
|
|
230
233
|
/** Is this Duty's loop installed and working. */
|
|
231
234
|
loopStatus: (id, currentContractFallback = false) => data_provider_2.request.get((0, triggers_1.withQuery)(`${base(id)}/loop-status`, {
|
|
@@ -1277,9 +1280,17 @@ function describeOperationFix(duty, operation) {
|
|
|
1277
1280
|
// its remedy are facts about that Run and stay true. Dropping them was
|
|
1278
1281
|
// exactly the case being fixed: paused after a refusal, contract edited since.
|
|
1279
1282
|
// The label says which Run the sentence is about instead.
|
|
1283
|
+
//
|
|
1284
|
+
// That holds only for a remedy of a failure code. A fix without a code
|
|
1285
|
+
// describes a condition the sweep saw (a run held for review, an owner
|
|
1286
|
+
// blocker), and a superseded verdict means the read no longer sees it:
|
|
1287
|
+
// printing "review and close it" for a hold already closed sent the owner
|
|
1288
|
+
// to a review that no longer existed (OSK-33237).
|
|
1280
1289
|
const liveness = duty.state?.liveness;
|
|
1281
1290
|
const lastRunFix = liveness && typeof liveness.diagnosisFix === 'string' ? liveness.diagnosisFix.trim() : '';
|
|
1282
|
-
|
|
1291
|
+
const conditionGone = liveness?.current === false &&
|
|
1292
|
+
!(typeof liveness.diagnosisCode === 'string' && liveness.diagnosisCode);
|
|
1293
|
+
if (lastRunFix && lastRunFix !== remediation && !conditionGone) {
|
|
1283
1294
|
lines.push({ label: lastRunLabel(liveness, lines.length > 0), text: lastRunFix });
|
|
1284
1295
|
}
|
|
1285
1296
|
return lines;
|
|
@@ -1838,17 +1849,29 @@ function renderDutyLedger(ledger, log) {
|
|
|
1838
1849
|
turns: describeRunCount(record(item.usage), 'turns'),
|
|
1839
1850
|
tools: describeRunCount(record(item.usage), 'toolCallCount'),
|
|
1840
1851
|
reason: text(firstValue(item, ['reason', 'error']), ''),
|
|
1841
|
-
finished: text(firstValue(item, [
|
|
1852
|
+
finished: text(firstValue(item, [
|
|
1853
|
+
'completedAt',
|
|
1854
|
+
'updatedAt',
|
|
1855
|
+
'claimedAt',
|
|
1856
|
+
'queuedAt',
|
|
1857
|
+
'reservedAt',
|
|
1858
|
+
'startedAt',
|
|
1859
|
+
])),
|
|
1842
1860
|
})), [
|
|
1843
1861
|
{ key: 'id', header: 'RUN ID', verbatim: true },
|
|
1844
1862
|
{ key: 'status', header: 'STATUS', maxWidth: 12 },
|
|
1845
1863
|
{ key: 'attempt', header: 'ATTEMPT' },
|
|
1846
1864
|
{ key: 'turns', header: 'TURNS' },
|
|
1847
1865
|
{ key: 'tools', header: 'TOOLS' },
|
|
1848
|
-
|
|
1866
|
+
// A Run's `reason` is its LATEST transition (`daemon_session_response` once it has
|
|
1867
|
+
// finished), not why it started; that is the `started because` line below (OSK-20265).
|
|
1868
|
+
{ key: 'reason', header: 'LAST REASON', maxWidth: 36 },
|
|
1849
1869
|
{ key: 'finished', header: 'LAST UPDATED', maxWidth: 24 },
|
|
1850
1870
|
], 'No runs recorded.', log);
|
|
1851
1871
|
for (const run of runs) {
|
|
1872
|
+
const started = runStartLine(run.id, run.startedBecause, 'Run');
|
|
1873
|
+
if (started)
|
|
1874
|
+
log(started);
|
|
1852
1875
|
renderDutyResultContext(run.outcome, run.id, log);
|
|
1853
1876
|
}
|
|
1854
1877
|
}
|
|
@@ -1910,6 +1933,60 @@ function renderRunWait(waiting, runId, log) {
|
|
|
1910
1933
|
if (fix)
|
|
1911
1934
|
log(` Fix: ${fix}`);
|
|
1912
1935
|
}
|
|
1936
|
+
/**
|
|
1937
|
+
* What a reader is told about where a `startedBecause` answer came from (OSK-20265). Every basis the
|
|
1938
|
+
* server knows says so in its own text (`Derived from …`, `Not recorded: …`, `No start reason was
|
|
1939
|
+
* given …`, `… was removed when …`), so none adds a suffix, which would only repeat it. Typed by the
|
|
1940
|
+
* data-provider vocabulary, so a basis added there fails to compile here until it is decided.
|
|
1941
|
+
*/
|
|
1942
|
+
const RUN_START_BASIS_SUFFIX = {
|
|
1943
|
+
recorded: '',
|
|
1944
|
+
erased: '',
|
|
1945
|
+
not_given: '',
|
|
1946
|
+
derived_from_check: '',
|
|
1947
|
+
derived_from_run: '',
|
|
1948
|
+
};
|
|
1949
|
+
/** A basis this CLI does not know yet is named by its code rather than passed off as recorded. */
|
|
1950
|
+
function runStartBasisSuffix(basis) {
|
|
1951
|
+
if (data_provider_2.DUTY_RUN_START_BASES.includes(basis)) {
|
|
1952
|
+
return RUN_START_BASIS_SUFFIX[basis];
|
|
1953
|
+
}
|
|
1954
|
+
return typeof basis === 'string' && basis ? ` (basis: ${basis})` : '';
|
|
1955
|
+
}
|
|
1956
|
+
/**
|
|
1957
|
+
* Why a Run was started, on one line, from the server's `startedBecause` (OSK-20265): its text, then
|
|
1958
|
+
* whether it was derived, cut, or a retry. `null` when the server sent none (a server older than the
|
|
1959
|
+
* record): nothing is invented, and the Run's `reason`, its LATEST transition, is not a substitute.
|
|
1960
|
+
* Read defensively, because the ledger carries it untyped. `retryOfRunId` is derived on the server
|
|
1961
|
+
* without a lookup, so it is printed as a claim, `(not checked)`.
|
|
1962
|
+
*/
|
|
1963
|
+
function describeRunStart(start) {
|
|
1964
|
+
const value = record(start);
|
|
1965
|
+
if (!value || typeof value.text !== 'string')
|
|
1966
|
+
return null;
|
|
1967
|
+
const why = (0, format_1.collapseWhitespace)(value.text);
|
|
1968
|
+
if (!why)
|
|
1969
|
+
return null;
|
|
1970
|
+
const basisSuffix = runStartBasisSuffix(value.basis);
|
|
1971
|
+
// A cut record is stored at its bound (1,000), so its own length says what was kept without a
|
|
1972
|
+
// second copy of the limit here.
|
|
1973
|
+
const original = value.originalLength;
|
|
1974
|
+
const of = typeof original === 'number' && Number.isSafeInteger(original) && original > 0
|
|
1975
|
+
? ` of ${original.toLocaleString('en-US')}`
|
|
1976
|
+
: '';
|
|
1977
|
+
const cut = value.truncated === true
|
|
1978
|
+
? ` [cut to ${value.text.length.toLocaleString('en-US')}${of} characters]`
|
|
1979
|
+
: '';
|
|
1980
|
+
const retryOf = typeof value.retryOfRunId === 'string' && value.retryOfRunId.trim()
|
|
1981
|
+
? ` — retry of run ${value.retryOfRunId.trim()} (not checked)`
|
|
1982
|
+
: '';
|
|
1983
|
+
return `${why}${basisSuffix}${cut}${retryOf}`;
|
|
1984
|
+
}
|
|
1985
|
+
/** `run <id> started because: …` for every surface that lists Runs; `null` when the server did not say. */
|
|
1986
|
+
function runStartLine(runId, start, noun = 'run') {
|
|
1987
|
+
const why = describeRunStart(start);
|
|
1988
|
+
return why ? `${noun} ${text(runId)} started because: ${why}` : null;
|
|
1989
|
+
}
|
|
1913
1990
|
function renderDutyTrace(trace, log) {
|
|
1914
1991
|
const events = records(trace.events);
|
|
1915
1992
|
renderRows(events.map((item) => ({
|
|
@@ -2047,6 +2124,9 @@ const CYCLE_GLYPH = {
|
|
|
2047
2124
|
// An applied result whose agent said work is warranted and left nothing the platform can see
|
|
2048
2125
|
// (OSK-21608): not a tick, because the work is still owed, and not a stop, because it applied.
|
|
2049
2126
|
owed: '◐',
|
|
2127
|
+
// An applied result whose workspace result never arrived (OSK-20281): not a tick either, because
|
|
2128
|
+
// nobody saw what the Run did to the files.
|
|
2129
|
+
workspaceUnknown: '◇',
|
|
2050
2130
|
};
|
|
2051
2131
|
/** The scheduler instant in UTC; `-` when the time is unknown. */
|
|
2052
2132
|
function cycleTime(value) {
|
|
@@ -2085,6 +2165,11 @@ function cycleSummary(cycle) {
|
|
|
2085
2165
|
? `${cycle.advancementKinds.join(', ')} — ${data_provider_2.DUTY_CYCLE_OWED_SENTENCE}`
|
|
2086
2166
|
: data_provider_2.DUTY_CYCLE_OWED_SENTENCE;
|
|
2087
2167
|
}
|
|
2168
|
+
if (cycle.workspaceUnknown) {
|
|
2169
|
+
return cycle.advancementKinds?.length
|
|
2170
|
+
? `${cycle.advancementKinds.join(', ')} — ${data_provider_2.DUTY_CYCLE_WORKSPACE_UNKNOWN_SENTENCE}`
|
|
2171
|
+
: data_provider_2.DUTY_CYCLE_WORKSPACE_UNKNOWN_SENTENCE;
|
|
2172
|
+
}
|
|
2088
2173
|
return cycle.advancementKinds?.length
|
|
2089
2174
|
? cycle.advancementKinds.join(', ')
|
|
2090
2175
|
: 'applied an agent result';
|
|
@@ -2177,14 +2262,23 @@ function formatDutyCycles(page) {
|
|
|
2177
2262
|
// `✓ advanced` above a stopped Run reads as if the work had moved (OSK-21240).
|
|
2178
2263
|
const echo = (0, data_provider_2.isRecordOnlyEchoCycle)(cycle);
|
|
2179
2264
|
const owed = !echo && cycle.outcome === 'advanced' && cycle.owed === true;
|
|
2265
|
+
const workspaceUnknown = !echo && !owed && cycle.outcome === 'advanced' && cycle.workspaceUnknown === true;
|
|
2180
2266
|
const glyph = echo
|
|
2181
2267
|
? CYCLE_GLYPH.quiet
|
|
2182
2268
|
: owed
|
|
2183
2269
|
? CYCLE_GLYPH.owed
|
|
2184
|
-
:
|
|
2270
|
+
: workspaceUnknown
|
|
2271
|
+
? CYCLE_GLYPH.workspaceUnknown
|
|
2272
|
+
: CYCLE_GLYPH[cycle.outcome] || '?';
|
|
2185
2273
|
const wakeSaved = isRecordedDutyWake(cycle);
|
|
2186
2274
|
const outcomeWord = cycle.confirmedDelivery ? 'delivered' : String(cycle.outcome);
|
|
2187
|
-
const word = echo || wakeSaved
|
|
2275
|
+
const word = echo || wakeSaved
|
|
2276
|
+
? 'recorded'
|
|
2277
|
+
: owed
|
|
2278
|
+
? 'owed'
|
|
2279
|
+
: workspaceUnknown && !cycle.confirmedDelivery
|
|
2280
|
+
? 'unknown'
|
|
2281
|
+
: outcomeWord;
|
|
2188
2282
|
lines.push(`${cycleTime(cycle.startedAt)} ${glyph} ${word.padEnd(9)} ${cycleWake(cycle).padEnd(18)} ${echo ? recordOnlyEchoSummary(cycle) : cycleSummary(cycle)}`);
|
|
2189
2283
|
if (cycle.confirmedDelivery?.verification) {
|
|
2190
2284
|
lines.push(` ${cycle.confirmedDelivery.verification}`);
|
|
@@ -2209,6 +2303,9 @@ function formatDutyCycles(page) {
|
|
|
2209
2303
|
lines.push(` task ${task.identifier || task.id} ${task.status || '-'} — ${label}`);
|
|
2210
2304
|
}
|
|
2211
2305
|
for (const run of cycle.runs || []) {
|
|
2306
|
+
const started = runStartLine(run.id, run.startedBecause);
|
|
2307
|
+
if (started)
|
|
2308
|
+
lines.push(` ${started}`);
|
|
2212
2309
|
if (run.decision) {
|
|
2213
2310
|
const label = run.decision === 'action_warranted' ? 'Action warranted' : 'No action warranted';
|
|
2214
2311
|
lines.push(` run ${run.id} ${label}${run.decisionSummary ? ` — ${run.decisionSummary}` : ''}`);
|
|
@@ -2294,7 +2391,11 @@ function wakeOutcomeLines(run) {
|
|
|
2294
2391
|
function formatDutyExplanation(explanation) {
|
|
2295
2392
|
const cycle = explanation.cycle;
|
|
2296
2393
|
const wakeSaved = isRecordedDutyWake(cycle);
|
|
2297
|
-
const outcomeWord = wakeSaved
|
|
2394
|
+
const outcomeWord = wakeSaved
|
|
2395
|
+
? 'wake saved'
|
|
2396
|
+
: cycle?.confirmedDelivery
|
|
2397
|
+
? 'delivered'
|
|
2398
|
+
: cycle?.outcome;
|
|
2298
2399
|
const lines = [
|
|
2299
2400
|
cycle
|
|
2300
2401
|
? `Latest cycle: ${cycleTime(cycle.startedAt)} ${outcomeWord} (${cycle.id})`
|
|
@@ -2326,6 +2427,9 @@ function formatDutyExplanation(explanation) {
|
|
|
2326
2427
|
if (cycle) {
|
|
2327
2428
|
lines.push(...platformFetchLines(cycle));
|
|
2328
2429
|
for (const run of cycle.runs || []) {
|
|
2430
|
+
const started = runStartLine(run.id, run.startedBecause);
|
|
2431
|
+
if (started)
|
|
2432
|
+
lines.push(` ${started}`);
|
|
2329
2433
|
if (run.reportPayload)
|
|
2330
2434
|
lines.push(` run ${run.id} report: ${run.reportPayload.status === 'rejected' ? 'structured report rejected; plain summary used' : 'structured report validated (delivery tracked separately)'}`);
|
|
2331
2435
|
for (const line of hypothesisRefusalLines(run))
|
package/dist/lib/duty-ledgers.js
CHANGED
|
@@ -106,20 +106,35 @@ function renderReflection(review, log) {
|
|
|
106
106
|
{ key: 'check', header: 'CHECK' },
|
|
107
107
|
], log);
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* What a row says about a refuted step (OSK-33241): how many times it was refuted, and when it may
|
|
111
|
+
* be tried again, or, on a re-apply after the wait, when that wait ended. Empty for any other row.
|
|
112
|
+
*/
|
|
113
|
+
function refutation(row) {
|
|
114
|
+
const count = typeof row.refutedCount === 'number' ? `${row.refutedCount}×` : '';
|
|
115
|
+
const until = text(row.retryAfter, '');
|
|
116
|
+
const decided = Date.parse(text(row.decidedAt, ''));
|
|
117
|
+
const waitEnded = Boolean(until) && Number.isFinite(decided) && Date.parse(until) <= decided;
|
|
118
|
+
const wait = until ? `${waitEnded ? 'wait ended' : 'retry after'} ${until}` : '';
|
|
119
|
+
return [count, wait].filter(Boolean).join(' · ');
|
|
120
|
+
}
|
|
109
121
|
function renderCadenceDecisions(list, log) {
|
|
110
122
|
const rows = (Array.isArray(list?.data) ? list.data : []);
|
|
111
123
|
if (rows.length === 0) {
|
|
112
124
|
log('No cadence decisions recorded.');
|
|
113
125
|
return;
|
|
114
126
|
}
|
|
115
|
-
|
|
127
|
+
const refuted = rows.map(refutation);
|
|
128
|
+
(0, format_1.renderTable)(rows.map((row, index) => ({
|
|
116
129
|
when: text(row.decidedAt),
|
|
117
130
|
mode: text(row.mode),
|
|
118
131
|
disposition: text(row.disposition),
|
|
119
132
|
direction: text(row.direction),
|
|
120
133
|
interval: `${minutes(row.currentIntervalMs)} → ${minutes(row.candidateIntervalMs)}`,
|
|
121
134
|
confidence: typeof row.confidence === 'number' ? row.confidence.toFixed(2) : '-',
|
|
122
|
-
|
|
135
|
+
// A `recently_refuted` hold names the signal it set aside.
|
|
136
|
+
reason: brief(row.signalReason ? `${text(row.reason)} (${text(row.signalReason)})` : row.reason, 70),
|
|
137
|
+
refuted: refuted[index] || '-',
|
|
123
138
|
})), [
|
|
124
139
|
{ key: 'when', header: 'DECIDED' },
|
|
125
140
|
{ key: 'mode', header: 'MODE' },
|
|
@@ -128,5 +143,7 @@ function renderCadenceDecisions(list, log) {
|
|
|
128
143
|
{ key: 'interval', header: 'INTERVAL' },
|
|
129
144
|
{ key: 'confidence', header: 'CONFIDENCE' },
|
|
130
145
|
{ key: 'reason', header: 'REASON', maxWidth: 70 },
|
|
146
|
+
// Only when a row has something to say, so a ledger with no refutation reads as before.
|
|
147
|
+
...(refuted.some(Boolean) ? [{ key: 'refuted', header: 'REFUTED' }] : []),
|
|
131
148
|
], log);
|
|
132
149
|
}
|
package/dist/lib/file-mime.js
CHANGED
|
@@ -35,6 +35,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.mimeTypeForFilename = mimeTypeForFilename;
|
|
37
37
|
const path = __importStar(require("node:path"));
|
|
38
|
+
// JavaScript and TypeScript source keeps the labels the generic file endpoint
|
|
39
|
+
// accepts (`text/javascript`, `application/typescript`). A Task stores it as
|
|
40
|
+
// plain text under its own name and only ever serves it as a download
|
|
41
|
+
// (OSK-20289), so the label is a declaration, not how the file is served.
|
|
38
42
|
const MIME_TYPES = {
|
|
39
43
|
'.3gp': 'video/3gp',
|
|
40
44
|
'.aac': 'audio/aac',
|
|
@@ -43,6 +47,7 @@ const MIME_TYPES = {
|
|
|
43
47
|
'.cjs': 'text/javascript',
|
|
44
48
|
'.cpp': 'text/x-c++',
|
|
45
49
|
'.cs': 'text/x-csharp',
|
|
50
|
+
'.cts': 'application/typescript',
|
|
46
51
|
'.css': 'text/css',
|
|
47
52
|
'.csv': 'text/csv',
|
|
48
53
|
'.cxx': 'text/x-c++',
|
|
@@ -63,6 +68,7 @@ const MIME_TYPES = {
|
|
|
63
68
|
'.jpg': 'image/jpeg',
|
|
64
69
|
'.js': 'text/javascript',
|
|
65
70
|
'.json': 'application/json',
|
|
71
|
+
'.jsx': 'text/javascript',
|
|
66
72
|
// A stream of JSON values is text evidence, not one JSON document.
|
|
67
73
|
// Preserve the original bytes and filename rather than forcing an array.
|
|
68
74
|
'.jsonl': 'text/plain',
|
|
@@ -74,6 +80,7 @@ const MIME_TYPES = {
|
|
|
74
80
|
'.mjs': 'text/javascript',
|
|
75
81
|
'.mkv': 'video/mkv',
|
|
76
82
|
'.mov': 'video/quicktime',
|
|
83
|
+
'.mts': 'application/typescript',
|
|
77
84
|
'.mp3': 'audio/mpeg',
|
|
78
85
|
'.mp4': 'video/mp4',
|
|
79
86
|
'.ogv': 'video/ogv',
|
|
@@ -92,6 +99,7 @@ const MIME_TYPES = {
|
|
|
92
99
|
'.tex': 'text/x-tex',
|
|
93
100
|
'.txt': 'text/plain',
|
|
94
101
|
'.ts': 'application/typescript',
|
|
102
|
+
'.tsx': 'application/typescript',
|
|
95
103
|
'.tsv': 'text/tab-separated-values',
|
|
96
104
|
'.vtt': 'text/vtt',
|
|
97
105
|
'.wav': 'audio/wav',
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { dataService, type AgentReplyRefusal, type GlanceDecisionKind, type GlanceFallbackReason, type InboundMessageAccepted, type InboundMessageReturned, type InboundReturnRefusal, type InboundReturnTaskOutcome, type InboundRoute, type InboundSendIntent, type MessageDelivery, type MessageDeliveryHandling, type MessageDeliveryHeld, type MessageFailedReason, type MessageHeldReason, type MessageReactionEmoji, type MessageCloudReply } from '@skrr-ai/data-provider';
|
|
2
|
+
type AgenticChatParams = Parameters<typeof dataService.startAgenticChat>[0];
|
|
3
|
+
type HeldDetail = MessageDeliveryHeld['detail'];
|
|
4
|
+
export declare const HELD_COPY: Record<MessageHeldReason, (detail?: HeldDetail) => string>;
|
|
5
|
+
export declare const FAILED_COPY: Record<MessageFailedReason, string>;
|
|
6
|
+
/** What the route says the moment the message is kept, before anything read it. */
|
|
7
|
+
export declare const ROUTE_COPY: Record<InboundRoute, string>;
|
|
8
|
+
/** A glance's decision. `null` where the agent's own words are the whole answer. */
|
|
9
|
+
export declare const GLANCE_COPY: Record<GlanceDecisionKind, string | null>;
|
|
10
|
+
export declare const FALLBACK_COPY: Record<GlanceFallbackReason, string>;
|
|
11
|
+
/** A reply or reaction the server refused, in the CLI's words. */
|
|
12
|
+
export declare const AGENT_REPLY_REFUSAL_COPY: Record<AgentReplyRefusal, string>;
|
|
13
|
+
/**
|
|
14
|
+
* `--reply-to` (or a payload's `replyTo`): absent is `null`; otherwise 1-10 message ids, trimmed
|
|
15
|
+
* and without repeats. The server proves each one; this only refuses a list it could never accept.
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeReplyTo(value: unknown): string[] | null | 'invalid';
|
|
18
|
+
/**
|
|
19
|
+
* A reply or reaction the server refused, when it named a refusal this CLI knows: the code, and
|
|
20
|
+
* the ids a reply could not prove. The DM route names it `errorType`, the session gateway `reason`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function agentReplyRefusalOf(err: unknown): {
|
|
23
|
+
code: AgentReplyRefusal;
|
|
24
|
+
missing?: string[];
|
|
25
|
+
} | null;
|
|
26
|
+
/** A plain name for each reaction, so a terminal never has to type an emoji. */
|
|
27
|
+
export declare const REACTION_NAMES: Record<MessageReactionEmoji, string>;
|
|
28
|
+
/** An emoji, or its plain name, as one of the contract's reactions; null when it is neither. */
|
|
29
|
+
export declare function reactionFromInput(input: string): MessageReactionEmoji | null;
|
|
30
|
+
/** The one sentence for a message's delivery, as a surface draws it. */
|
|
31
|
+
export declare function deliverySentence(delivery: MessageDelivery | null | undefined): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* "Not for this Task" (Q6): the message is back in this conversation, and what became of the Task
|
|
34
|
+
* it had gone to. The web's words (`deliveryCopy.ts`, `RETURN_COPY`), with and without the title.
|
|
35
|
+
*/
|
|
36
|
+
export declare const RETURN_OUTCOME_COPY: Record<InboundReturnTaskOutcome, (title?: string) => string>;
|
|
37
|
+
/** Why "Not for this Task" was refused (`INBOUND_RETURN_REFUSALS`). */
|
|
38
|
+
export declare const RETURN_REFUSAL_COPY: Record<InboundReturnRefusal, string>;
|
|
39
|
+
/** The sentence for a message brought back from a Task: a `returned` handling, or the answer's. */
|
|
40
|
+
export declare function returnedSentence(returned: Pick<MessageDeliveryHandling, 'from'> & {
|
|
41
|
+
taskOutcome?: InboundReturnTaskOutcome | null;
|
|
42
|
+
}): string;
|
|
43
|
+
/** What a recorded handling says, or null when it adds nothing to the agent's own words. */
|
|
44
|
+
export declare function handlingSentence(handling: MessageDeliveryHandling | undefined): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* The message id for one invocation's start key. The ingress takes letters, digits, `_` and `-`;
|
|
47
|
+
* a key outside that becomes a hash of itself, so a replay of the same invocation names the same
|
|
48
|
+
* message and two different keys never share one.
|
|
49
|
+
*/
|
|
50
|
+
export declare function inboundMessageIdFor(startKey: string): string;
|
|
51
|
+
/** Whether a failed send came from a server that has no ingress (a 404 with no code of its own). */
|
|
52
|
+
export declare function ingressMissing(err: unknown): boolean;
|
|
53
|
+
export interface InboundSend {
|
|
54
|
+
answer: InboundMessageAccepted;
|
|
55
|
+
messageId: string;
|
|
56
|
+
/** The turn the message starts when it waits first: the CLI chooses its ids, so it can follow. */
|
|
57
|
+
sessionId: string;
|
|
58
|
+
responseMessageId: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Send the message `startAgenticChat(params)` would have started a turn with. The submission is
|
|
62
|
+
* the same body, frozen at send; the turn it starts (now or later) uses the ids chosen here.
|
|
63
|
+
*/
|
|
64
|
+
export declare function sendInboundMessage(params: AgenticChatParams & {
|
|
65
|
+
conversationId: string;
|
|
66
|
+
}, { messageId, intent, deps, }: {
|
|
67
|
+
messageId: string;
|
|
68
|
+
intent: InboundSendIntent;
|
|
69
|
+
deps?: {
|
|
70
|
+
send?: typeof dataService.sendConversationMessage;
|
|
71
|
+
};
|
|
72
|
+
}): Promise<InboundSend>;
|
|
73
|
+
/**
|
|
74
|
+
* "Not for this Task": bring back a message the platform or a glance passed to a Task, and have it
|
|
75
|
+
* delivered in this conversation again. The Task is told, and its response stopped when it was
|
|
76
|
+
* for this message alone. A retry, or a second call, answers with the message as it is.
|
|
77
|
+
*/
|
|
78
|
+
export declare function returnInboundMessage(conversationId: string, messageId: string, deps?: {
|
|
79
|
+
send?: typeof dataService.returnConversationMessage;
|
|
80
|
+
}): Promise<InboundMessageReturned>;
|
|
81
|
+
/**
|
|
82
|
+
* The next step a person may take when their message went to a Task, or null when it did not (or
|
|
83
|
+
* already came back): bring it back to the conversation.
|
|
84
|
+
*/
|
|
85
|
+
export declare function notForTaskHint(bin: string, conversationId: string, messageId: string, handling: MessageDeliveryHandling | null | undefined): string | null;
|
|
86
|
+
/** The words for a refusal of "Not for this Task", or null when it is not one of its codes. */
|
|
87
|
+
export declare function returnRefusalOf(err: unknown): string | null;
|
|
88
|
+
/**
|
|
89
|
+
* What the CLI does next with an accepted message.
|
|
90
|
+
* - `turn`: it started (or joined) a turn whose reply the CLI can stream.
|
|
91
|
+
* - `wait`: it waits for a turn of its own; follow its queue card, then stream that turn.
|
|
92
|
+
* - `glance`: the agent is reading it while it works; wait for what it decided.
|
|
93
|
+
* - `delivered`: it reached the agent and there is no reply of its own to stream.
|
|
94
|
+
* - `failed`: it will not be read as it is.
|
|
95
|
+
*/
|
|
96
|
+
export type InboundNext = {
|
|
97
|
+
kind: 'turn';
|
|
98
|
+
sessionId: string;
|
|
99
|
+
responseMessageId: string;
|
|
100
|
+
} | {
|
|
101
|
+
kind: 'wait';
|
|
102
|
+
} | {
|
|
103
|
+
kind: 'glance';
|
|
104
|
+
} | {
|
|
105
|
+
kind: 'delivered';
|
|
106
|
+
} | {
|
|
107
|
+
kind: 'failed';
|
|
108
|
+
};
|
|
109
|
+
export declare function nextAfterSend(answer: InboundMessageAccepted): InboundNext;
|
|
110
|
+
export interface GlanceOutcome {
|
|
111
|
+
/** The last handling a glance or its fallback recorded, or null when the wait ran out. */
|
|
112
|
+
handling: MessageDeliveryHandling | null;
|
|
113
|
+
/** The agent's reply to the message, when it wrote one; `cloudReply` when from the cloud. */
|
|
114
|
+
reply: {
|
|
115
|
+
messageId: string;
|
|
116
|
+
text: string;
|
|
117
|
+
cloudReply?: MessageCloudReply;
|
|
118
|
+
} | null;
|
|
119
|
+
}
|
|
120
|
+
type MessageRow = {
|
|
121
|
+
messageId?: string;
|
|
122
|
+
text?: string;
|
|
123
|
+
isCreatedByUser?: boolean;
|
|
124
|
+
delivery?: MessageDelivery | null;
|
|
125
|
+
metadata?: {
|
|
126
|
+
communication?: {
|
|
127
|
+
replyTo?: unknown;
|
|
128
|
+
cloudReply?: unknown;
|
|
129
|
+
};
|
|
130
|
+
} | null;
|
|
131
|
+
};
|
|
132
|
+
/** How long a glance can take to settle: its wall clock, its lease, and a margin. */
|
|
133
|
+
export declare const GLANCE_WAIT_MS: number;
|
|
134
|
+
/**
|
|
135
|
+
* Wait for what a glance decided about one message: read the conversation until the message
|
|
136
|
+
* carries a glance's handling (or the platform's fallback), and pick up the reply that names it.
|
|
137
|
+
*/
|
|
138
|
+
export declare function waitForGlance(conversationId: string, messageId: string, { timeoutMs, deps, }?: {
|
|
139
|
+
timeoutMs?: number;
|
|
140
|
+
deps?: {
|
|
141
|
+
messages?: (conversationId: string) => Promise<MessageRow[] | undefined>;
|
|
142
|
+
sleep?: (ms: number) => Promise<void>;
|
|
143
|
+
now?: () => number;
|
|
144
|
+
};
|
|
145
|
+
}): Promise<GlanceOutcome>;
|
|
146
|
+
/**
|
|
147
|
+
* A message's delivery now, read from the conversation, or `null` when the message is gone (it was
|
|
148
|
+
* taken back from another screen). Used when its card leaves the queue without a turn of its own:
|
|
149
|
+
* it may have been read with another message.
|
|
150
|
+
*/
|
|
151
|
+
export declare function readMessageDelivery(conversationId: string, messageId: string, deps?: {
|
|
152
|
+
messages?: (conversationId: string) => Promise<MessageRow[] | undefined>;
|
|
153
|
+
}): Promise<{
|
|
154
|
+
delivery: MessageDelivery | null;
|
|
155
|
+
} | null>;
|
|
156
|
+
export {};
|