@skrr-ai/cli 0.1.207 → 0.1.208
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/commands/agent/message/resolve.d.ts +31 -0
- package/dist/commands/agent/message/resolve.js +111 -0
- package/dist/commands/agent/message/send.d.ts +17 -5
- package/dist/commands/agent/message/send.js +77 -26
- package/dist/commands/agent/request/list.d.ts +15 -0
- package/dist/commands/agent/request/list.js +82 -0
- package/dist/commands/agent/request/send.d.ts +18 -0
- package/dist/commands/agent/request/send.js +56 -0
- package/dist/commands/agents/access/approve.d.ts +17 -0
- package/dist/commands/agents/access/approve.js +94 -0
- package/dist/commands/agents/access/deny.d.ts +10 -0
- package/dist/commands/agents/access/deny.js +36 -0
- package/dist/commands/agents/access/list.d.ts +10 -0
- package/dist/commands/agents/access/list.js +53 -0
- package/dist/commands/agents/access/reach.d.ts +13 -0
- package/dist/commands/agents/access/reach.js +53 -0
- package/dist/commands/agents/access/revoke.d.ts +13 -0
- package/dist/commands/agents/access/revoke.js +50 -0
- package/dist/commands/agents/import.d.ts +15 -1
- package/dist/commands/agents/import.js +211 -23
- package/dist/commands/agents/intuitions/accept.d.ts +0 -1
- package/dist/commands/agents/intuitions/accept.js +22 -7
- package/dist/commands/agents/intuitions/generate.d.ts +0 -1
- package/dist/commands/agents/intuitions/generate.js +4 -16
- package/dist/commands/agents/intuitions/list.js +9 -3
- package/dist/commands/agents/intuitions/resume.d.ts +11 -0
- package/dist/commands/agents/intuitions/resume.js +37 -0
- package/dist/commands/agents/shared-memory.d.ts +24 -0
- package/dist/commands/agents/shared-memory.js +67 -0
- package/dist/commands/agents/visibility.d.ts +1 -0
- package/dist/commands/agents/visibility.js +14 -0
- package/dist/commands/code/migrate.js +3 -1
- package/dist/commands/duties/advance-next.js +15 -6
- package/dist/commands/followups/show.js +9 -0
- package/dist/commands/followups/watch-pr.d.ts +27 -0
- package/dist/commands/followups/watch-pr.js +123 -0
- package/dist/commands/memory/consolidation/index.d.ts +20 -0
- package/dist/commands/memory/consolidation/index.js +78 -0
- package/dist/commands/memory/consolidation/resume.d.ts +14 -0
- package/dist/commands/memory/consolidation/resume.js +46 -0
- package/dist/commands/memory/consolidation/undo.d.ts +18 -0
- package/dist/commands/memory/consolidation/undo.js +60 -0
- package/dist/commands/slack/mutes.d.ts +10 -0
- package/dist/commands/slack/mutes.js +62 -0
- package/dist/commands/slack/unmute.d.ts +12 -0
- package/dist/commands/slack/unmute.js +44 -0
- package/dist/commands/tasks/actionability.js +9 -0
- package/dist/commands/tasks/ask.d.ts +50 -0
- package/dist/commands/tasks/ask.js +190 -0
- package/dist/commands/tasks/handover.js +14 -0
- package/dist/commands/tasks/input/answer.js +8 -2
- package/dist/commands/tasks/input/show.d.ts +26 -0
- package/dist/commands/tasks/input/show.js +185 -17
- package/dist/commands/tasks/move.d.ts +11 -0
- package/dist/commands/tasks/move.js +82 -1
- package/dist/commands/tasks/result/submit.js +3 -0
- package/dist/commands/tasks/runs.d.ts +4 -1
- package/dist/commands/tasks/runs.js +22 -3
- package/dist/commands/tasks/show.js +22 -1
- package/dist/commands/tasks/update.d.ts +1 -0
- package/dist/commands/tasks/update.js +52 -1
- package/dist/commands/tasks/updates/add.js +3 -0
- package/dist/commands/tasks/wait.d.ts +20 -0
- package/dist/commands/tasks/wait.js +102 -1
- package/dist/generated/agent-guides.json +501 -92
- package/dist/generated/managed-instruction-guides.json +1 -1
- package/dist/lib/agent-access-command.d.ts +19 -0
- package/dist/lib/agent-access-command.js +44 -0
- package/dist/lib/agent-access.d.ts +18 -0
- package/dist/lib/agent-access.js +48 -0
- package/dist/lib/agent-import/apply.d.ts +50 -0
- package/dist/lib/agent-import/apply.js +85 -0
- package/dist/lib/agent-import/plan.d.ts +132 -0
- package/dist/lib/agent-import/plan.js +504 -0
- package/dist/lib/agent-import/reader.d.ts +94 -0
- package/dist/lib/agent-import/reader.js +326 -0
- package/dist/lib/agent-import/schedule.d.ts +46 -0
- package/dist/lib/agent-import/schedule.js +220 -0
- package/dist/lib/agent-import/sources.d.ts +124 -0
- package/dist/lib/agent-import/sources.js +797 -0
- package/dist/lib/followups.d.ts +61 -0
- package/dist/lib/followups.js +39 -0
- package/dist/lib/handover-interview.d.ts +18 -0
- package/dist/lib/handover-interview.js +53 -0
- package/dist/lib/input-queue.js +2 -1
- package/dist/lib/intuition-look.d.ts +10 -0
- package/dist/lib/intuition-look.js +64 -0
- package/dist/lib/record-output.d.ts +1 -1
- package/dist/lib/record-output.js +2 -0
- package/dist/lib/skill-import.d.ts +19 -0
- package/dist/lib/skill-import.js +34 -0
- package/dist/lib/slack-thread-mutes.d.ts +25 -0
- package/dist/lib/slack-thread-mutes.js +12 -0
- package/dist/lib/task-carriers.d.ts +18 -0
- package/dist/lib/task-carriers.js +43 -0
- package/dist/lib/task-extras.d.ts +5 -0
- package/dist/lib/task-extras.js +5 -0
- package/dist/lib/task-recurrence-summary.d.ts +15 -0
- package/dist/lib/task-recurrence-summary.js +22 -0
- package/dist/lib/task-version.d.ts +44 -0
- package/dist/lib/task-version.js +73 -0
- package/dist/lib/task-write-attribution.d.ts +7 -0
- package/dist/lib/task-write-attribution.js +14 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.d.ts +75 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.js +124 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.d.ts +75 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.js +141 -0
- package/dist/node_modules/@skrr-ai/auth-core/package.json +10 -0
- package/dist/node_modules/@skrr-ai/data-provider/index.js +13323 -12577
- package/oclif.manifest.json +1787 -107
- package/package.json +5 -2
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EXPECTED_VERSION_FLAG_HELP = exports.TASK_VERSION_FENCE_UNSUPPORTED = exports.TASK_VERSION_CONFLICT_CODE = void 0;
|
|
4
|
+
exports.taskVersionOf = taskVersionOf;
|
|
5
|
+
exports.taskVersionConflictOf = taskVersionConflictOf;
|
|
6
|
+
exports.describeTaskVersionConflict = describeTaskVersionConflict;
|
|
7
|
+
exports.taskVersionFenceRefusal = taskVersionFenceRefusal;
|
|
8
|
+
/**
|
|
9
|
+
* The CLI half of a version-fenced Task write (`--expected-version`).
|
|
10
|
+
*
|
|
11
|
+
* The server's half is the CAS on `Task.version` (`PATCH /api/tasks/:id` and
|
|
12
|
+
* `PATCH /api/tasks/:id/move`), which refuses with `TASK_VERSION_CONFLICT`
|
|
13
|
+
* when the Task moved on. That refusal is only useful if it says what to do
|
|
14
|
+
* next, and the next step is never "retry": the caller decided from a Task
|
|
15
|
+
* that no longer exists, so it reads the Task again and decides again.
|
|
16
|
+
*
|
|
17
|
+
* The idempotency rule needs nothing here: a body that carries a numeric
|
|
18
|
+
* `expectedVersion` takes the request-derived key (`idempotency.ts` rule 3),
|
|
19
|
+
* so a retry after a lost response replays the first answer instead of
|
|
20
|
+
* conflicting with its own write.
|
|
21
|
+
*/
|
|
22
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
23
|
+
Object.defineProperty(exports, "TASK_VERSION_CONFLICT_CODE", { enumerable: true, get: function () { return data_provider_1.TASK_VERSION_CONFLICT_CODE; } });
|
|
24
|
+
const base_command_1 = require("../base-command");
|
|
25
|
+
/** The CLI's refusal for a change the version fence cannot carry. */
|
|
26
|
+
exports.TASK_VERSION_FENCE_UNSUPPORTED = 'TASK_VERSION_FENCE_UNSUPPORTED';
|
|
27
|
+
exports.EXPECTED_VERSION_FLAG_HELP = 'Only write if the task is still at this version (the Version that `tasks show` prints). ' +
|
|
28
|
+
'A task that changed since is refused with TASK_VERSION_CONFLICT and nothing is changed.';
|
|
29
|
+
function versionOf(value) {
|
|
30
|
+
return typeof value === 'number' && Number.isInteger(value) && value >= 0 ? value : undefined;
|
|
31
|
+
}
|
|
32
|
+
/** The version a Task reports, with an absent field read as 0 (the server's own reading). */
|
|
33
|
+
function taskVersionOf(task) {
|
|
34
|
+
return versionOf(task?.version) ?? 0;
|
|
35
|
+
}
|
|
36
|
+
/** The two versions of a `TASK_VERSION_CONFLICT` refusal, or null for any other error. */
|
|
37
|
+
function taskVersionConflictOf(err) {
|
|
38
|
+
const refusal = (0, base_command_1.apiRefusal)(err);
|
|
39
|
+
if (refusal.code !== data_provider_1.TASK_VERSION_CONFLICT_CODE)
|
|
40
|
+
return null;
|
|
41
|
+
return {
|
|
42
|
+
expectedVersion: versionOf(refusal.body?.expectedVersion),
|
|
43
|
+
currentVersion: versionOf(refusal.body?.currentVersion),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The conflict as a sentence that names the next step. `expectedVersion` is the
|
|
48
|
+
* one the caller sent, which the server echoes on `move` but not on `update`.
|
|
49
|
+
*/
|
|
50
|
+
function describeTaskVersionConflict({ taskRef, expectedVersion, currentVersion, bin, }) {
|
|
51
|
+
return (0, data_provider_1.describeTaskVersionConflictWith)({
|
|
52
|
+
taskRef,
|
|
53
|
+
expectedVersion,
|
|
54
|
+
currentVersion,
|
|
55
|
+
reread: `\`${bin} tasks show ${taskRef}\``,
|
|
56
|
+
again: (version) => `run it again with --expected-version ${version}`,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Why `tasks update --expected-version` cannot send this patch, or null when
|
|
61
|
+
* the fence carries all of it. The fenced server path writes only
|
|
62
|
+
* `TASK_VERSIONED_PATCH_FIELDS` and silently drops the rest, so sending
|
|
63
|
+
* anything else would report an update that partly did not happen.
|
|
64
|
+
*/
|
|
65
|
+
function taskVersionFenceRefusal(patch) {
|
|
66
|
+
const outside = (0, data_provider_1.taskPatchKeysOutsideVersionFence)(patch);
|
|
67
|
+
if (outside.length === 0)
|
|
68
|
+
return null;
|
|
69
|
+
return (`--expected-version cannot carry ${outside.map((key) => `\`${key}\``).join(', ')}: ` +
|
|
70
|
+
'a version-checked update writes only plain fields, and would drop these without saying so. ' +
|
|
71
|
+
'State the whole list instead of adding or removing one (for example --assignee-agent rather ' +
|
|
72
|
+
'than --add-assignee-agent), or run this change without --expected-version.');
|
|
73
|
+
}
|
|
@@ -75,6 +75,13 @@ export declare function taskWriteOutcome(receipt: unknown, record: TaskWriteReco
|
|
|
75
75
|
* phrase every surface uses (`principalChannelPhrase`), which marks the tool as declared.
|
|
76
76
|
*/
|
|
77
77
|
export declare function describeAttributedTo(attributedTo: AttributedTo): string;
|
|
78
|
+
/**
|
|
79
|
+
* The line saying this write started its Task (OSK-33197). Recording a
|
|
80
|
+
* `progress`, `finding` or `verification` Update, or a Result, on a Task nobody
|
|
81
|
+
* had started moves it to its Space's started state; the receipt names where it
|
|
82
|
+
* went, so the person and the agent are told rather than left to notice.
|
|
83
|
+
*/
|
|
84
|
+
export declare function taskStartedLine(receipt: unknown, task: string): string | null;
|
|
78
85
|
/**
|
|
79
86
|
* The lines a write prints. The first is the outcome: `<Verb> <what> — attributed to <whom>.`, or,
|
|
80
87
|
* for an idempotent replay, that the same record already existed and nothing new was written.
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ACCOUNT_ATTRIBUTION_NOTICE = exports.AGENT_BINDING_GUIDANCE = exports.PERSON_CONFIRMATION_REQUIRED = exports.confirmAsMeFlag = exports.TASK_WRITE_RECORDS = void 0;
|
|
4
4
|
exports.taskWriteOutcome = taskWriteOutcome;
|
|
5
5
|
exports.describeAttributedTo = describeAttributedTo;
|
|
6
|
+
exports.taskStartedLine = taskStartedLine;
|
|
6
7
|
exports.taskWriteOutcomeLines = taskWriteOutcomeLines;
|
|
7
8
|
exports.receiptAttribution = receiptAttribution;
|
|
8
9
|
exports.personJudgementGate = personJudgementGate;
|
|
@@ -128,6 +129,19 @@ function describeAttributedTo(attributedTo) {
|
|
|
128
129
|
return id ? `the ${id} integration` : 'an integration';
|
|
129
130
|
return 'nobody the receipt names';
|
|
130
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* The line saying this write started its Task (OSK-33197). Recording a
|
|
134
|
+
* `progress`, `finding` or `verification` Update, or a Result, on a Task nobody
|
|
135
|
+
* had started moves it to its Space's started state; the receipt names where it
|
|
136
|
+
* went, so the person and the agent are told rather than left to notice.
|
|
137
|
+
*/
|
|
138
|
+
function taskStartedLine(receipt, task) {
|
|
139
|
+
const status = receipt?.taskStarted
|
|
140
|
+
?.status;
|
|
141
|
+
if (typeof status !== 'string' || !status)
|
|
142
|
+
return null;
|
|
143
|
+
return `Started ${task}: it had not been started, so recording this work moved it to ${status}.`;
|
|
144
|
+
}
|
|
131
145
|
/**
|
|
132
146
|
* The lines a write prints. The first is the outcome: `<Verb> <what> — attributed to <whom>.`, or,
|
|
133
147
|
* for an idempotent replay, that the same record already existed and nothing new was written.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn pacing: a reminder, inside a long chat turn, that the person has not heard from it for a
|
|
3
|
+
* while (OSK-33221).
|
|
4
|
+
*
|
|
5
|
+
* A model working through a half-hour turn has no clock. It can be told "a time you gave is a
|
|
6
|
+
* promise" and still not notice that twenty minutes have passed, because nothing in its context
|
|
7
|
+
* moves with time. The conversation context now carries the server's measurement
|
|
8
|
+
* (`currentTurn.elapsedMs` / `quietForMs`), but only when the model thinks to read it. This module
|
|
9
|
+
* is the other half: the harness that runs the turn watches the gap and, once it reaches the
|
|
10
|
+
* threshold, adds one sentence to the next tool result.
|
|
11
|
+
*
|
|
12
|
+
* Shared by the two harnesses that can do that, so the policy and the words exist once:
|
|
13
|
+
* - the daemon's Claude Agent SDK engine, through a PostToolUse hook, on a chat turn whose
|
|
14
|
+
* request carried `turnPacing` (sent only to a daemon announcing `TURN_PACING_CAPABILITY`);
|
|
15
|
+
* - the cloud Agent Worker, through its own PostToolUse hook, on a turn that has `send_message`.
|
|
16
|
+
*
|
|
17
|
+
* It is evaluated on tool activity, never on a timer: a turn that is not calling tools has nobody
|
|
18
|
+
* to tell, and a timer would be a fourth scheduling mechanism the scheduling architecture forbids.
|
|
19
|
+
* It never sends, delays or refuses anything. It says the gap once per quiet window and leaves the
|
|
20
|
+
* judgement to the Agent: "if they would be wondering", never "send now". A schedule is exactly
|
|
21
|
+
* what the doctrine tells the Agent not to keep, so the reminder may not become one.
|
|
22
|
+
*/
|
|
23
|
+
/** A daemon that announces this reads `turnPacing` on a session request and acts on it. */
|
|
24
|
+
export declare const TURN_PACING_CAPABILITY = "session_turn_pacing_v1";
|
|
25
|
+
/** Bounds on the threshold a request may carry: a minute, and six hours. */
|
|
26
|
+
export declare const TURN_PACING_LIMITS: Readonly<{
|
|
27
|
+
minQuietReminderAfterMs: 60000;
|
|
28
|
+
maxQuietReminderAfterMs: number;
|
|
29
|
+
}>;
|
|
30
|
+
/** The default threshold: ten minutes of a turn the person has heard nothing from. */
|
|
31
|
+
export declare const DEFAULT_QUIET_REMINDER_AFTER_MS: number;
|
|
32
|
+
export interface TurnPacingV1 {
|
|
33
|
+
version: 1;
|
|
34
|
+
/** How long a running turn may go without a message to the person before it is reminded. */
|
|
35
|
+
quietReminderAfterMs: number;
|
|
36
|
+
}
|
|
37
|
+
/** A strict read of the wire field. Anything it does not understand is no pacing at all. */
|
|
38
|
+
export declare function readTurnPacing(value: unknown): TurnPacingV1 | null;
|
|
39
|
+
/**
|
|
40
|
+
* The threshold a deployment configured: `SKRR_TURN_QUIET_REMINDER_MS` (milliseconds), `off` to
|
|
41
|
+
* turn the reminder off, unset for the default. A value outside the limits is the default, not an
|
|
42
|
+
* error: a typo must not turn the reminder into a stream of them, nor silently off.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveQuietReminderAfterMs(raw: string | undefined | null): number | null;
|
|
45
|
+
export declare function isAgentMessageSendCommand(command: unknown): boolean;
|
|
46
|
+
/** Where the reminder is shown: a daemon harness (CLI) or a cloud turn (`send_message`). */
|
|
47
|
+
export type TurnPacingSurface = 'cli' | 'tool';
|
|
48
|
+
/**
|
|
49
|
+
* The reminder, in one short paragraph. It states the gap, names the two reasons a person would
|
|
50
|
+
* want to hear (they would be wondering; a time you gave is close), and says it will not repeat,
|
|
51
|
+
* so ignoring it when nothing would help is a legitimate answer. No example message: an example
|
|
52
|
+
* in a reminder is copied (C14, recommendation 5).
|
|
53
|
+
*/
|
|
54
|
+
export declare function renderQuietTurnReminder({ quietForMs, elapsedMs, sentDuringTurn, surface, }: {
|
|
55
|
+
quietForMs: number;
|
|
56
|
+
elapsedMs: number;
|
|
57
|
+
sentDuringTurn: boolean;
|
|
58
|
+
surface: TurnPacingSurface;
|
|
59
|
+
}): string;
|
|
60
|
+
export interface QuietTurnMonitor {
|
|
61
|
+
/** The turn sent the person a message at `at` (ms since the epoch). */
|
|
62
|
+
noteSent(at?: number): void;
|
|
63
|
+
/** The reminder to add now, once per quiet window, or null. */
|
|
64
|
+
check(at?: number): string | null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* One turn's quiet window. It opens when the turn starts and again at every message the turn
|
|
68
|
+
* sends; it reminds once per window, when the gap first reaches the threshold.
|
|
69
|
+
*/
|
|
70
|
+
export declare function createQuietTurnMonitor({ startedAt, quietReminderAfterMs, surface, now, }: {
|
|
71
|
+
startedAt: number;
|
|
72
|
+
quietReminderAfterMs: number;
|
|
73
|
+
surface: TurnPacingSurface;
|
|
74
|
+
now?: () => number;
|
|
75
|
+
}): QuietTurnMonitor;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var turnPacing_exports = {};
|
|
20
|
+
__export(turnPacing_exports, {
|
|
21
|
+
DEFAULT_QUIET_REMINDER_AFTER_MS: () => DEFAULT_QUIET_REMINDER_AFTER_MS,
|
|
22
|
+
TURN_PACING_CAPABILITY: () => TURN_PACING_CAPABILITY,
|
|
23
|
+
TURN_PACING_LIMITS: () => TURN_PACING_LIMITS,
|
|
24
|
+
createQuietTurnMonitor: () => createQuietTurnMonitor,
|
|
25
|
+
isAgentMessageSendCommand: () => isAgentMessageSendCommand,
|
|
26
|
+
readTurnPacing: () => readTurnPacing,
|
|
27
|
+
renderQuietTurnReminder: () => renderQuietTurnReminder,
|
|
28
|
+
resolveQuietReminderAfterMs: () => resolveQuietReminderAfterMs
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(turnPacing_exports);
|
|
31
|
+
const TURN_PACING_CAPABILITY = "session_turn_pacing_v1";
|
|
32
|
+
const TURN_PACING_LIMITS = Object.freeze({
|
|
33
|
+
minQuietReminderAfterMs: 6e4,
|
|
34
|
+
maxQuietReminderAfterMs: 6 * 60 * 60 * 1e3
|
|
35
|
+
});
|
|
36
|
+
const DEFAULT_QUIET_REMINDER_AFTER_MS = 10 * 60 * 1e3;
|
|
37
|
+
function readTurnPacing(value) {
|
|
38
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
39
|
+
return null;
|
|
40
|
+
const record = value;
|
|
41
|
+
const keys = Object.keys(record);
|
|
42
|
+
if (keys.some((key) => key !== "version" && key !== "quietReminderAfterMs"))
|
|
43
|
+
return null;
|
|
44
|
+
const after = record.quietReminderAfterMs;
|
|
45
|
+
if (record.version !== 1 || typeof after !== "number" || !Number.isSafeInteger(after))
|
|
46
|
+
return null;
|
|
47
|
+
if (after < TURN_PACING_LIMITS.minQuietReminderAfterMs || after > TURN_PACING_LIMITS.maxQuietReminderAfterMs) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return { version: 1, quietReminderAfterMs: after };
|
|
51
|
+
}
|
|
52
|
+
const OFF_VALUES = /* @__PURE__ */ new Set(["off", "0", "false", "no", "disabled"]);
|
|
53
|
+
function resolveQuietReminderAfterMs(raw) {
|
|
54
|
+
const value = String(raw ?? "").trim().toLowerCase();
|
|
55
|
+
if (!value)
|
|
56
|
+
return DEFAULT_QUIET_REMINDER_AFTER_MS;
|
|
57
|
+
if (OFF_VALUES.has(value))
|
|
58
|
+
return null;
|
|
59
|
+
const parsed = Number(value);
|
|
60
|
+
if (!Number.isSafeInteger(parsed) || parsed < TURN_PACING_LIMITS.minQuietReminderAfterMs || parsed > TURN_PACING_LIMITS.maxQuietReminderAfterMs) {
|
|
61
|
+
return DEFAULT_QUIET_REMINDER_AFTER_MS;
|
|
62
|
+
}
|
|
63
|
+
return parsed;
|
|
64
|
+
}
|
|
65
|
+
const SEND_COMMAND = /(?:^|[\s;&|(`])(?:[^\s;&|()`]*\/)?skrr\s+agent\s+message\s+send(?=\s|$)/g;
|
|
66
|
+
const HELP_FLAG = /(?:^|\s)(?:--help|-h)(?=\s|$)/;
|
|
67
|
+
function isAgentMessageSendCommand(command) {
|
|
68
|
+
if (typeof command !== "string")
|
|
69
|
+
return false;
|
|
70
|
+
for (const match of command.matchAll(SEND_COMMAND)) {
|
|
71
|
+
const args = command.slice(match.index + match[0].length).split(/[;&|\n]/, 1)[0] ?? "";
|
|
72
|
+
if (!HELP_FLAG.test(args))
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const minutes = (ms) => Math.max(1, Math.floor(ms / 6e4));
|
|
78
|
+
const plural = (n) => n === 1 ? "1 minute" : `${n} minutes`;
|
|
79
|
+
function renderQuietTurnReminder({ quietForMs, elapsedMs, sentDuringTurn, surface }) {
|
|
80
|
+
const gap = sentDuringTurn ? `This turn has run ${plural(minutes(elapsedMs))}, and the person last heard from it ${plural(minutes(quietForMs))} ago.` : `This turn has run ${plural(minutes(elapsedMs))} and has not sent the person anything yet.`;
|
|
81
|
+
const how = surface === "cli" ? "one short status with `skrr agent message send` (keep one --status-key, so it replaces the last)" : "one short status with send_message (keep one statusKey, so it replaces the last)";
|
|
82
|
+
return [
|
|
83
|
+
`[skrr] ${gap}`,
|
|
84
|
+
`If they would be wondering by now, or a time you gave is close, ${how} keeps them confident: what is newly true and when you expect to finish.`,
|
|
85
|
+
"If nothing would help them, carry on. This reminder does not repeat until this turn sends a message."
|
|
86
|
+
].join(" ");
|
|
87
|
+
}
|
|
88
|
+
function createQuietTurnMonitor({ startedAt, quietReminderAfterMs, surface, now = Date.now }) {
|
|
89
|
+
let lastHeardAt = startedAt;
|
|
90
|
+
let sentDuringTurn = false;
|
|
91
|
+
let remindedThisWindow = false;
|
|
92
|
+
return {
|
|
93
|
+
noteSent(at = now()) {
|
|
94
|
+
lastHeardAt = Math.max(lastHeardAt, at);
|
|
95
|
+
sentDuringTurn = true;
|
|
96
|
+
remindedThisWindow = false;
|
|
97
|
+
},
|
|
98
|
+
check(at = now()) {
|
|
99
|
+
if (remindedThisWindow)
|
|
100
|
+
return null;
|
|
101
|
+
const quietForMs = at - lastHeardAt;
|
|
102
|
+
if (!(quietForMs >= quietReminderAfterMs))
|
|
103
|
+
return null;
|
|
104
|
+
remindedThisWindow = true;
|
|
105
|
+
return renderQuietTurnReminder({
|
|
106
|
+
quietForMs,
|
|
107
|
+
elapsedMs: at - startedAt,
|
|
108
|
+
sentDuringTurn,
|
|
109
|
+
surface
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
115
|
+
0 && (module.exports = {
|
|
116
|
+
DEFAULT_QUIET_REMINDER_AFTER_MS,
|
|
117
|
+
TURN_PACING_CAPABILITY,
|
|
118
|
+
TURN_PACING_LIMITS,
|
|
119
|
+
createQuietTurnMonitor,
|
|
120
|
+
isAgentMessageSendCommand,
|
|
121
|
+
readTurnPacing,
|
|
122
|
+
renderQuietTurnReminder,
|
|
123
|
+
resolveQuietReminderAfterMs
|
|
124
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn pacing: a reminder, inside a long chat turn, that the person has not heard from it for a
|
|
3
|
+
* while (OSK-33221).
|
|
4
|
+
*
|
|
5
|
+
* A model working through a half-hour turn has no clock. It can be told "a time you gave is a
|
|
6
|
+
* promise" and still not notice that twenty minutes have passed, because nothing in its context
|
|
7
|
+
* moves with time. The conversation context now carries the server's measurement
|
|
8
|
+
* (`currentTurn.elapsedMs` / `quietForMs`), but only when the model thinks to read it. This module
|
|
9
|
+
* is the other half: the harness that runs the turn watches the gap and, once it reaches the
|
|
10
|
+
* threshold, adds one sentence to the next tool result.
|
|
11
|
+
*
|
|
12
|
+
* Shared by the two harnesses that can do that, so the policy and the words exist once:
|
|
13
|
+
* - the daemon's Claude Agent SDK engine, through a PostToolUse hook, on a chat turn whose
|
|
14
|
+
* request carried `turnPacing` (sent only to a daemon announcing `TURN_PACING_CAPABILITY`);
|
|
15
|
+
* - the cloud Agent Worker, through its own PostToolUse hook, on a turn that has `send_message`.
|
|
16
|
+
*
|
|
17
|
+
* It is evaluated on tool activity, never on a timer: a turn that is not calling tools has nobody
|
|
18
|
+
* to tell, and a timer would be a fourth scheduling mechanism the scheduling architecture forbids.
|
|
19
|
+
* It never sends, delays or refuses anything. It says the gap once per quiet window and leaves the
|
|
20
|
+
* judgement to the Agent: "if they would be wondering", never "send now". A schedule is exactly
|
|
21
|
+
* what the doctrine tells the Agent not to keep, so the reminder may not become one.
|
|
22
|
+
*/
|
|
23
|
+
/** A daemon that announces this reads `turnPacing` on a session request and acts on it. */
|
|
24
|
+
export declare const TURN_PACING_CAPABILITY = "session_turn_pacing_v1";
|
|
25
|
+
/** Bounds on the threshold a request may carry: a minute, and six hours. */
|
|
26
|
+
export declare const TURN_PACING_LIMITS: Readonly<{
|
|
27
|
+
minQuietReminderAfterMs: 60000;
|
|
28
|
+
maxQuietReminderAfterMs: number;
|
|
29
|
+
}>;
|
|
30
|
+
/** The default threshold: ten minutes of a turn the person has heard nothing from. */
|
|
31
|
+
export declare const DEFAULT_QUIET_REMINDER_AFTER_MS: number;
|
|
32
|
+
export interface TurnPacingV1 {
|
|
33
|
+
version: 1;
|
|
34
|
+
/** How long a running turn may go without a message to the person before it is reminded. */
|
|
35
|
+
quietReminderAfterMs: number;
|
|
36
|
+
}
|
|
37
|
+
/** A strict read of the wire field. Anything it does not understand is no pacing at all. */
|
|
38
|
+
export declare function readTurnPacing(value: unknown): TurnPacingV1 | null;
|
|
39
|
+
/**
|
|
40
|
+
* The threshold a deployment configured: `SKRR_TURN_QUIET_REMINDER_MS` (milliseconds), `off` to
|
|
41
|
+
* turn the reminder off, unset for the default. A value outside the limits is the default, not an
|
|
42
|
+
* error: a typo must not turn the reminder into a stream of them, nor silently off.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveQuietReminderAfterMs(raw: string | undefined | null): number | null;
|
|
45
|
+
export declare function isAgentMessageSendCommand(command: unknown): boolean;
|
|
46
|
+
/** Where the reminder is shown: a daemon harness (CLI) or a cloud turn (`send_message`). */
|
|
47
|
+
export type TurnPacingSurface = 'cli' | 'tool';
|
|
48
|
+
/**
|
|
49
|
+
* The reminder, in one short paragraph. It states the gap, names the two reasons a person would
|
|
50
|
+
* want to hear (they would be wondering; a time you gave is close), and says it will not repeat,
|
|
51
|
+
* so ignoring it when nothing would help is a legitimate answer. No example message: an example
|
|
52
|
+
* in a reminder is copied (C14, recommendation 5).
|
|
53
|
+
*/
|
|
54
|
+
export declare function renderQuietTurnReminder({ quietForMs, elapsedMs, sentDuringTurn, surface, }: {
|
|
55
|
+
quietForMs: number;
|
|
56
|
+
elapsedMs: number;
|
|
57
|
+
sentDuringTurn: boolean;
|
|
58
|
+
surface: TurnPacingSurface;
|
|
59
|
+
}): string;
|
|
60
|
+
export interface QuietTurnMonitor {
|
|
61
|
+
/** The turn sent the person a message at `at` (ms since the epoch). */
|
|
62
|
+
noteSent(at?: number): void;
|
|
63
|
+
/** The reminder to add now, once per quiet window, or null. */
|
|
64
|
+
check(at?: number): string | null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* One turn's quiet window. It opens when the turn starts and again at every message the turn
|
|
68
|
+
* sends; it reminds once per window, when the gap first reaches the threshold.
|
|
69
|
+
*/
|
|
70
|
+
export declare function createQuietTurnMonitor({ startedAt, quietReminderAfterMs, surface, now, }: {
|
|
71
|
+
startedAt: number;
|
|
72
|
+
quietReminderAfterMs: number;
|
|
73
|
+
surface: TurnPacingSurface;
|
|
74
|
+
now?: () => number;
|
|
75
|
+
}): QuietTurnMonitor;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn pacing: a reminder, inside a long chat turn, that the person has not heard from it for a
|
|
3
|
+
* while (OSK-33221).
|
|
4
|
+
*
|
|
5
|
+
* A model working through a half-hour turn has no clock. It can be told "a time you gave is a
|
|
6
|
+
* promise" and still not notice that twenty minutes have passed, because nothing in its context
|
|
7
|
+
* moves with time. The conversation context now carries the server's measurement
|
|
8
|
+
* (`currentTurn.elapsedMs` / `quietForMs`), but only when the model thinks to read it. This module
|
|
9
|
+
* is the other half: the harness that runs the turn watches the gap and, once it reaches the
|
|
10
|
+
* threshold, adds one sentence to the next tool result.
|
|
11
|
+
*
|
|
12
|
+
* Shared by the two harnesses that can do that, so the policy and the words exist once:
|
|
13
|
+
* - the daemon's Claude Agent SDK engine, through a PostToolUse hook, on a chat turn whose
|
|
14
|
+
* request carried `turnPacing` (sent only to a daemon announcing `TURN_PACING_CAPABILITY`);
|
|
15
|
+
* - the cloud Agent Worker, through its own PostToolUse hook, on a turn that has `send_message`.
|
|
16
|
+
*
|
|
17
|
+
* It is evaluated on tool activity, never on a timer: a turn that is not calling tools has nobody
|
|
18
|
+
* to tell, and a timer would be a fourth scheduling mechanism the scheduling architecture forbids.
|
|
19
|
+
* It never sends, delays or refuses anything. It says the gap once per quiet window and leaves the
|
|
20
|
+
* judgement to the Agent: "if they would be wondering", never "send now". A schedule is exactly
|
|
21
|
+
* what the doctrine tells the Agent not to keep, so the reminder may not become one.
|
|
22
|
+
*/
|
|
23
|
+
/** A daemon that announces this reads `turnPacing` on a session request and acts on it. */
|
|
24
|
+
export const TURN_PACING_CAPABILITY = 'session_turn_pacing_v1';
|
|
25
|
+
/** Bounds on the threshold a request may carry: a minute, and six hours. */
|
|
26
|
+
export const TURN_PACING_LIMITS = Object.freeze({
|
|
27
|
+
minQuietReminderAfterMs: 60_000,
|
|
28
|
+
maxQuietReminderAfterMs: 6 * 60 * 60 * 1000,
|
|
29
|
+
});
|
|
30
|
+
/** The default threshold: ten minutes of a turn the person has heard nothing from. */
|
|
31
|
+
export const DEFAULT_QUIET_REMINDER_AFTER_MS = 10 * 60 * 1000;
|
|
32
|
+
/** A strict read of the wire field. Anything it does not understand is no pacing at all. */
|
|
33
|
+
export function readTurnPacing(value) {
|
|
34
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
35
|
+
return null;
|
|
36
|
+
const record = value;
|
|
37
|
+
const keys = Object.keys(record);
|
|
38
|
+
if (keys.some((key) => key !== 'version' && key !== 'quietReminderAfterMs'))
|
|
39
|
+
return null;
|
|
40
|
+
const after = record.quietReminderAfterMs;
|
|
41
|
+
if (record.version !== 1 || typeof after !== 'number' || !Number.isSafeInteger(after))
|
|
42
|
+
return null;
|
|
43
|
+
if (after < TURN_PACING_LIMITS.minQuietReminderAfterMs ||
|
|
44
|
+
after > TURN_PACING_LIMITS.maxQuietReminderAfterMs) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return { version: 1, quietReminderAfterMs: after };
|
|
48
|
+
}
|
|
49
|
+
const OFF_VALUES = new Set(['off', '0', 'false', 'no', 'disabled']);
|
|
50
|
+
/**
|
|
51
|
+
* The threshold a deployment configured: `SKRR_TURN_QUIET_REMINDER_MS` (milliseconds), `off` to
|
|
52
|
+
* turn the reminder off, unset for the default. A value outside the limits is the default, not an
|
|
53
|
+
* error: a typo must not turn the reminder into a stream of them, nor silently off.
|
|
54
|
+
*/
|
|
55
|
+
export function resolveQuietReminderAfterMs(raw) {
|
|
56
|
+
const value = String(raw ?? '')
|
|
57
|
+
.trim()
|
|
58
|
+
.toLowerCase();
|
|
59
|
+
if (!value)
|
|
60
|
+
return DEFAULT_QUIET_REMINDER_AFTER_MS;
|
|
61
|
+
if (OFF_VALUES.has(value))
|
|
62
|
+
return null;
|
|
63
|
+
const parsed = Number(value);
|
|
64
|
+
if (!Number.isSafeInteger(parsed) ||
|
|
65
|
+
parsed < TURN_PACING_LIMITS.minQuietReminderAfterMs ||
|
|
66
|
+
parsed > TURN_PACING_LIMITS.maxQuietReminderAfterMs) {
|
|
67
|
+
return DEFAULT_QUIET_REMINDER_AFTER_MS;
|
|
68
|
+
}
|
|
69
|
+
return parsed;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Whether a shell command sends the person a message: `skrr agent message send`, the one
|
|
73
|
+
* sanctioned path from a daemon session. Read from the command the harness ran, because the send
|
|
74
|
+
* goes from the CLI straight to the server and leaves nothing on the machine to read. `--help` is
|
|
75
|
+
* not a send. A command that only mentions the words in a string can read as one; the cost is one
|
|
76
|
+
* reminder too few, never one too many.
|
|
77
|
+
*/
|
|
78
|
+
const SEND_COMMAND = /(?:^|[\s;&|(`])(?:[^\s;&|()`]*\/)?skrr\s+agent\s+message\s+send(?=\s|$)/g;
|
|
79
|
+
const HELP_FLAG = /(?:^|\s)(?:--help|-h)(?=\s|$)/;
|
|
80
|
+
export function isAgentMessageSendCommand(command) {
|
|
81
|
+
if (typeof command !== 'string')
|
|
82
|
+
return false;
|
|
83
|
+
for (const match of command.matchAll(SEND_COMMAND)) {
|
|
84
|
+
// This invocation's own arguments: up to the next command separator.
|
|
85
|
+
const args = command.slice(match.index + match[0].length).split(/[;&|\n]/, 1)[0] ?? '';
|
|
86
|
+
if (!HELP_FLAG.test(args))
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
const minutes = (ms) => Math.max(1, Math.floor(ms / 60_000));
|
|
92
|
+
const plural = (n) => (n === 1 ? '1 minute' : `${n} minutes`);
|
|
93
|
+
/**
|
|
94
|
+
* The reminder, in one short paragraph. It states the gap, names the two reasons a person would
|
|
95
|
+
* want to hear (they would be wondering; a time you gave is close), and says it will not repeat,
|
|
96
|
+
* so ignoring it when nothing would help is a legitimate answer. No example message: an example
|
|
97
|
+
* in a reminder is copied (C14, recommendation 5).
|
|
98
|
+
*/
|
|
99
|
+
export function renderQuietTurnReminder({ quietForMs, elapsedMs, sentDuringTurn, surface, }) {
|
|
100
|
+
const gap = sentDuringTurn
|
|
101
|
+
? `This turn has run ${plural(minutes(elapsedMs))}, and the person last heard from it ${plural(minutes(quietForMs))} ago.`
|
|
102
|
+
: `This turn has run ${plural(minutes(elapsedMs))} and has not sent the person anything yet.`;
|
|
103
|
+
const how = surface === 'cli'
|
|
104
|
+
? 'one short status with `skrr agent message send` (keep one --status-key, so it replaces the last)'
|
|
105
|
+
: 'one short status with send_message (keep one statusKey, so it replaces the last)';
|
|
106
|
+
return [
|
|
107
|
+
`[skrr] ${gap}`,
|
|
108
|
+
`If they would be wondering by now, or a time you gave is close, ${how} keeps them confident: what is newly true and when you expect to finish.`,
|
|
109
|
+
'If nothing would help them, carry on. This reminder does not repeat until this turn sends a message.',
|
|
110
|
+
].join(' ');
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* One turn's quiet window. It opens when the turn starts and again at every message the turn
|
|
114
|
+
* sends; it reminds once per window, when the gap first reaches the threshold.
|
|
115
|
+
*/
|
|
116
|
+
export function createQuietTurnMonitor({ startedAt, quietReminderAfterMs, surface, now = Date.now, }) {
|
|
117
|
+
let lastHeardAt = startedAt;
|
|
118
|
+
let sentDuringTurn = false;
|
|
119
|
+
let remindedThisWindow = false;
|
|
120
|
+
return {
|
|
121
|
+
noteSent(at = now()) {
|
|
122
|
+
lastHeardAt = Math.max(lastHeardAt, at);
|
|
123
|
+
sentDuringTurn = true;
|
|
124
|
+
remindedThisWindow = false;
|
|
125
|
+
},
|
|
126
|
+
check(at = now()) {
|
|
127
|
+
if (remindedThisWindow)
|
|
128
|
+
return null;
|
|
129
|
+
const quietForMs = at - lastHeardAt;
|
|
130
|
+
if (!(quietForMs >= quietReminderAfterMs))
|
|
131
|
+
return null;
|
|
132
|
+
remindedThisWindow = true;
|
|
133
|
+
return renderQuietTurnReminder({
|
|
134
|
+
quietForMs,
|
|
135
|
+
elapsedMs: at - startedAt,
|
|
136
|
+
sentDuringTurn,
|
|
137
|
+
surface,
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -387,6 +387,16 @@
|
|
|
387
387
|
"default": "./dist/cjs/toolOperationOutcome.js"
|
|
388
388
|
}
|
|
389
389
|
},
|
|
390
|
+
"./turn-pacing": {
|
|
391
|
+
"import": {
|
|
392
|
+
"types": "./dist/esm/turnPacing.d.ts",
|
|
393
|
+
"default": "./dist/esm/turnPacing.js"
|
|
394
|
+
},
|
|
395
|
+
"require": {
|
|
396
|
+
"types": "./dist/cjs/turnPacing.d.ts",
|
|
397
|
+
"default": "./dist/cjs/turnPacing.js"
|
|
398
|
+
}
|
|
399
|
+
},
|
|
390
400
|
"./local-session-import-limits": {
|
|
391
401
|
"import": {
|
|
392
402
|
"types": "./dist/esm/localSessionImportLimits.d.ts",
|