@skrr-ai/cli 0.1.207 → 0.1.209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/dist/commands/agent/message/no-reply.js +1 -1
  2. package/dist/commands/agent/message/react.d.ts +23 -0
  3. package/dist/commands/agent/message/react.js +125 -0
  4. package/dist/commands/agent/message/resolve.d.ts +31 -0
  5. package/dist/commands/agent/message/resolve.js +111 -0
  6. package/dist/commands/agent/message/retract.js +1 -1
  7. package/dist/commands/agent/message/send.d.ts +25 -6
  8. package/dist/commands/agent/message/send.js +135 -30
  9. package/dist/commands/agent/request/list.d.ts +15 -0
  10. package/dist/commands/agent/request/list.js +82 -0
  11. package/dist/commands/agent/request/send.d.ts +18 -0
  12. package/dist/commands/agent/request/send.js +56 -0
  13. package/dist/commands/agents/access/approve.d.ts +17 -0
  14. package/dist/commands/agents/access/approve.js +94 -0
  15. package/dist/commands/agents/access/deny.d.ts +10 -0
  16. package/dist/commands/agents/access/deny.js +36 -0
  17. package/dist/commands/agents/access/list.d.ts +10 -0
  18. package/dist/commands/agents/access/list.js +55 -0
  19. package/dist/commands/agents/access/reach.d.ts +13 -0
  20. package/dist/commands/agents/access/reach.js +53 -0
  21. package/dist/commands/agents/access/revoke.d.ts +13 -0
  22. package/dist/commands/agents/access/revoke.js +50 -0
  23. package/dist/commands/agents/always-on/recovery-review.d.ts +5 -0
  24. package/dist/commands/agents/always-on/recovery-review.js +16 -0
  25. package/dist/commands/agents/chat.d.ts +8 -0
  26. package/dist/commands/agents/chat.js +369 -90
  27. package/dist/commands/agents/import.d.ts +15 -1
  28. package/dist/commands/agents/import.js +212 -24
  29. package/dist/commands/agents/intuitions/accept.d.ts +0 -1
  30. package/dist/commands/agents/intuitions/accept.js +22 -7
  31. package/dist/commands/agents/intuitions/generate.d.ts +0 -1
  32. package/dist/commands/agents/intuitions/generate.js +4 -16
  33. package/dist/commands/agents/intuitions/list.js +9 -3
  34. package/dist/commands/agents/intuitions/resume.d.ts +11 -0
  35. package/dist/commands/agents/intuitions/resume.js +37 -0
  36. package/dist/commands/agents/manager/status.js +7 -6
  37. package/dist/commands/agents/not-for-task.d.ts +24 -0
  38. package/dist/commands/agents/not-for-task.js +60 -0
  39. package/dist/commands/agents/schedule-overview.d.ts +20 -0
  40. package/dist/commands/agents/schedule-overview.js +35 -2
  41. package/dist/commands/agents/shared-memory.d.ts +24 -0
  42. package/dist/commands/agents/shared-memory.js +67 -0
  43. package/dist/commands/agents/stop.d.ts +23 -0
  44. package/dist/commands/agents/stop.js +61 -0
  45. package/dist/commands/agents/update.d.ts +7 -0
  46. package/dist/commands/agents/update.js +45 -2
  47. package/dist/commands/agents/visibility.d.ts +1 -0
  48. package/dist/commands/agents/visibility.js +14 -0
  49. package/dist/commands/code/migrate.js +3 -1
  50. package/dist/commands/convos/messages.js +5 -0
  51. package/dist/commands/convos/transcript.js +2 -2
  52. package/dist/commands/daemon/logs.d.ts +3 -1
  53. package/dist/commands/daemon/logs.js +6 -2
  54. package/dist/commands/duties/advance-next.js +16 -7
  55. package/dist/commands/duties/preflight.js +17 -13
  56. package/dist/commands/followups/show.js +9 -0
  57. package/dist/commands/followups/watch-pr.d.ts +27 -0
  58. package/dist/commands/followups/watch-pr.js +124 -0
  59. package/dist/commands/harnesses/evaluations/evidence.js +2 -2
  60. package/dist/commands/harnesses/evaluations/grant.js +1 -1
  61. package/dist/commands/harnesses/evaluations/revoke.js +1 -1
  62. package/dist/commands/harnesses/evaluations/show.js +1 -1
  63. package/dist/commands/harnesses/rollouts/grant.js +1 -1
  64. package/dist/commands/harnesses/rollouts/revoke.js +1 -1
  65. package/dist/commands/machines/hosted/identity-evaluations/revoke.js +1 -1
  66. package/dist/commands/machines/hosted/identity-evaluations/show.js +1 -1
  67. package/dist/commands/memory/consolidation/index.d.ts +20 -0
  68. package/dist/commands/memory/consolidation/index.js +78 -0
  69. package/dist/commands/memory/consolidation/resume.d.ts +14 -0
  70. package/dist/commands/memory/consolidation/resume.js +46 -0
  71. package/dist/commands/memory/consolidation/undo.d.ts +18 -0
  72. package/dist/commands/memory/consolidation/undo.js +61 -0
  73. package/dist/commands/messages/list.js +9 -1
  74. package/dist/commands/slack/mutes.d.ts +10 -0
  75. package/dist/commands/slack/mutes.js +62 -0
  76. package/dist/commands/slack/unmute.d.ts +12 -0
  77. package/dist/commands/slack/unmute.js +44 -0
  78. package/dist/commands/tasks/actionability.js +10 -0
  79. package/dist/commands/tasks/ask.d.ts +50 -0
  80. package/dist/commands/tasks/ask.js +190 -0
  81. package/dist/commands/tasks/bulk-update.js +12 -0
  82. package/dist/commands/tasks/handover.js +14 -0
  83. package/dist/commands/tasks/input/answer.js +8 -2
  84. package/dist/commands/tasks/input/show.d.ts +26 -0
  85. package/dist/commands/tasks/input/show.js +185 -17
  86. package/dist/commands/tasks/list.d.ts +8 -0
  87. package/dist/commands/tasks/list.js +50 -9
  88. package/dist/commands/tasks/move.d.ts +3 -0
  89. package/dist/commands/tasks/move.js +71 -1
  90. package/dist/commands/tasks/result/show.js +19 -7
  91. package/dist/commands/tasks/result/submit.js +3 -0
  92. package/dist/commands/tasks/runs.d.ts +4 -1
  93. package/dist/commands/tasks/runs.js +22 -3
  94. package/dist/commands/tasks/show.d.ts +4 -3
  95. package/dist/commands/tasks/show.js +40 -7
  96. package/dist/commands/tasks/start.js +35 -16
  97. package/dist/commands/tasks/update.d.ts +1 -0
  98. package/dist/commands/tasks/update.js +55 -1
  99. package/dist/commands/tasks/updates/add.js +3 -0
  100. package/dist/commands/tasks/wait.d.ts +20 -0
  101. package/dist/commands/tasks/wait.js +103 -2
  102. package/dist/generated/agent-guides.json +892 -183
  103. package/dist/generated/managed-instruction-guides.json +1 -1
  104. package/dist/lib/agent-access-command.d.ts +19 -0
  105. package/dist/lib/agent-access-command.js +44 -0
  106. package/dist/lib/agent-access.d.ts +18 -0
  107. package/dist/lib/agent-access.js +48 -0
  108. package/dist/lib/agent-import/apply.d.ts +50 -0
  109. package/dist/lib/agent-import/apply.js +85 -0
  110. package/dist/lib/agent-import/plan.d.ts +132 -0
  111. package/dist/lib/agent-import/plan.js +504 -0
  112. package/dist/lib/agent-import/reader.d.ts +94 -0
  113. package/dist/lib/agent-import/reader.js +326 -0
  114. package/dist/lib/agent-import/schedule.d.ts +46 -0
  115. package/dist/lib/agent-import/schedule.js +220 -0
  116. package/dist/lib/agent-import/sources.d.ts +124 -0
  117. package/dist/lib/agent-import/sources.js +797 -0
  118. package/dist/lib/chat-stop.d.ts +17 -0
  119. package/dist/lib/chat-stop.js +70 -0
  120. package/dist/lib/cloud-reply.d.ts +21 -0
  121. package/dist/lib/cloud-reply.js +52 -0
  122. package/dist/lib/duties.js +24 -4
  123. package/dist/lib/duty-ledgers.js +19 -2
  124. package/dist/lib/file-mime.js +8 -0
  125. package/dist/lib/followups.d.ts +61 -0
  126. package/dist/lib/followups.js +39 -0
  127. package/dist/lib/handover-interview.d.ts +18 -0
  128. package/dist/lib/handover-interview.js +53 -0
  129. package/dist/lib/inbound-messages.d.ts +156 -0
  130. package/dist/lib/inbound-messages.js +375 -0
  131. package/dist/lib/input-queue.js +2 -1
  132. package/dist/lib/intuition-look.d.ts +10 -0
  133. package/dist/lib/intuition-look.js +64 -0
  134. package/dist/lib/message-intent.d.ts +18 -2
  135. package/dist/lib/message-intent.js +23 -1
  136. package/dist/lib/preflight-copy.d.ts +16 -1
  137. package/dist/lib/preflight-copy.js +33 -1
  138. package/dist/lib/record-output.d.ts +1 -1
  139. package/dist/lib/record-output.js +2 -0
  140. package/dist/lib/skill-import.d.ts +19 -0
  141. package/dist/lib/skill-import.js +34 -0
  142. package/dist/lib/slack-thread-mutes.d.ts +25 -0
  143. package/dist/lib/slack-thread-mutes.js +12 -0
  144. package/dist/lib/task-carriers.d.ts +18 -0
  145. package/dist/lib/task-carriers.js +43 -0
  146. package/dist/lib/task-extras.d.ts +5 -0
  147. package/dist/lib/task-extras.js +5 -0
  148. package/dist/lib/task-operations.d.ts +2 -0
  149. package/dist/lib/task-operations.js +28 -4
  150. package/dist/lib/task-preflight.js +1 -0
  151. package/dist/lib/task-recurrence-summary.d.ts +15 -0
  152. package/dist/lib/task-recurrence-summary.js +22 -0
  153. package/dist/lib/task-review-notice.d.ts +21 -0
  154. package/dist/lib/task-review-notice.js +46 -0
  155. package/dist/lib/task-version.d.ts +53 -0
  156. package/dist/lib/task-version.js +89 -0
  157. package/dist/lib/task-write-attribution.d.ts +7 -0
  158. package/dist/lib/task-write-attribution.js +14 -0
  159. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelopeBridge.js +6 -1
  160. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.d.ts +75 -0
  161. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.js +124 -0
  162. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelopeBridge.js +45 -15
  163. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.d.ts +75 -0
  164. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.js +141 -0
  165. package/dist/node_modules/@skrr-ai/auth-core/package.json +11 -1
  166. package/dist/node_modules/@skrr-ai/data-provider/index.js +13492 -12505
  167. package/oclif.manifest.json +2090 -132
  168. package/package.json +9 -2
@@ -0,0 +1,89 @@
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.taskVersionLine = taskVersionLine;
6
+ exports.writtenTaskVersionLine = writtenTaskVersionLine;
7
+ exports.taskVersionConflictOf = taskVersionConflictOf;
8
+ exports.describeTaskVersionConflict = describeTaskVersionConflict;
9
+ exports.taskVersionFenceRefusal = taskVersionFenceRefusal;
10
+ /**
11
+ * The CLI half of a version-fenced Task write (`--expected-version`).
12
+ *
13
+ * The server's half is the CAS on `Task.version` (`PATCH /api/tasks/:id` and
14
+ * `PATCH /api/tasks/:id/move`), which refuses with `TASK_VERSION_CONFLICT`
15
+ * when the Task moved on. That refusal is only useful if it says what to do
16
+ * next, and the next step is never "retry": the caller decided from a Task
17
+ * that no longer exists, so it reads the Task again and decides again.
18
+ *
19
+ * The idempotency rule needs nothing here: a body that carries a numeric
20
+ * `expectedVersion` takes the request-derived key (`idempotency.ts` rule 3),
21
+ * so a retry after a lost response replays the first answer instead of
22
+ * conflicting with its own write.
23
+ */
24
+ const data_provider_1 = require("@skrr-ai/data-provider");
25
+ Object.defineProperty(exports, "TASK_VERSION_CONFLICT_CODE", { enumerable: true, get: function () { return data_provider_1.TASK_VERSION_CONFLICT_CODE; } });
26
+ const base_command_1 = require("../base-command");
27
+ /** The CLI's refusal for a change the version fence cannot carry. */
28
+ exports.TASK_VERSION_FENCE_UNSUPPORTED = 'TASK_VERSION_FENCE_UNSUPPORTED';
29
+ exports.EXPECTED_VERSION_FLAG_HELP = 'Only write if the task is still at this version (the Version that `tasks show` prints). ' +
30
+ 'A task that changed since is refused with TASK_VERSION_CONFLICT and nothing is changed.';
31
+ function versionOf(value) {
32
+ return typeof value === 'number' && Number.isInteger(value) && value >= 0 ? value : undefined;
33
+ }
34
+ /** The version a Task reports, with an absent field read as 0 (the server's own reading). */
35
+ function taskVersionOf(task) {
36
+ return versionOf(task?.version) ?? 0;
37
+ }
38
+ /** The `Version:` line `tasks show` prints, with the flag that uses it. */
39
+ function taskVersionLine(version) {
40
+ return `Version: ${version} (update only from this read: --expected-version ${version})`;
41
+ }
42
+ /**
43
+ * The same line after a write, from the version the server answered with, or
44
+ * null when it answered without one. Every user edit moves the version, fenced
45
+ * or not, so the version a caller read before its own write is already stale:
46
+ * this is the one to fence the next write on.
47
+ */
48
+ function writtenTaskVersionLine(task) {
49
+ const version = versionOf(task?.version);
50
+ return version === undefined ? null : taskVersionLine(version);
51
+ }
52
+ /** The two versions of a `TASK_VERSION_CONFLICT` refusal, or null for any other error. */
53
+ function taskVersionConflictOf(err) {
54
+ const refusal = (0, base_command_1.apiRefusal)(err);
55
+ if (refusal.code !== data_provider_1.TASK_VERSION_CONFLICT_CODE)
56
+ return null;
57
+ return {
58
+ expectedVersion: versionOf(refusal.body?.expectedVersion),
59
+ currentVersion: versionOf(refusal.body?.currentVersion),
60
+ };
61
+ }
62
+ /**
63
+ * The conflict as a sentence that names the next step. `expectedVersion` is the
64
+ * one the caller sent, which the server echoes on `move` but not on `update`.
65
+ */
66
+ function describeTaskVersionConflict({ taskRef, expectedVersion, currentVersion, bin, }) {
67
+ return (0, data_provider_1.describeTaskVersionConflictWith)({
68
+ taskRef,
69
+ expectedVersion,
70
+ currentVersion,
71
+ reread: `\`${bin} tasks show ${taskRef}\``,
72
+ again: (version) => `run it again with --expected-version ${version}`,
73
+ });
74
+ }
75
+ /**
76
+ * Why `tasks update --expected-version` cannot send this patch, or null when
77
+ * the fence carries all of it. The fenced server path writes only
78
+ * `TASK_VERSIONED_PATCH_FIELDS` and silently drops the rest, so sending
79
+ * anything else would report an update that partly did not happen.
80
+ */
81
+ function taskVersionFenceRefusal(patch) {
82
+ const outside = (0, data_provider_1.taskPatchKeysOutsideVersionFence)(patch);
83
+ if (outside.length === 0)
84
+ return null;
85
+ return (`--expected-version cannot carry ${outside.map((key) => `\`${key}\``).join(', ')}: ` +
86
+ 'a version-checked update writes only plain fields, and would drop these without saying so. ' +
87
+ 'State the whole list instead of adding or removing one (for example --assignee-agent rather ' +
88
+ 'than --add-assignee-agent), or run this change without --expected-version.');
89
+ }
@@ -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.
@@ -365,7 +365,12 @@ async function initNewIndependentCredEnvelope(profile) {
365
365
  if (!stat.isDirectory() || stat.isSymbolicLink() || (stat.mode & 63) !== 0 || typeof process.getuid === "function" && stat.uid !== process.getuid()) {
366
366
  throw new Error("Background credential enrollment is unavailable");
367
367
  }
368
- const artifacts = ["device-private-key", "device-public-key.jwk", "auth-binding.json", "auth.json"];
368
+ const artifacts = [
369
+ "device-private-key",
370
+ "device-public-key.jwk",
371
+ "auth-binding.json",
372
+ "auth.json"
373
+ ];
369
374
  const artifactDirs = [dir, ...resolved.legacyDir ? [resolved.legacyDir] : []];
370
375
  const assertEmpty = () => {
371
376
  if (paths.some(present) || artifactDirs.some((root) => artifacts.some((name) => present(import_node_path.default.join(root, name)))) || wrappedDekFilePath(profile) !== resolved.canonicalPath) {
@@ -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
+ });
@@ -208,7 +208,7 @@ async function withCredEnvelopeLock(profile, body) {
208
208
  /**
209
209
  * Sticky record of the last consolidation refusal for this process — two usable
210
210
  * and DIFFERENT wrapped DEKs for one profile. Surfaced through
211
- * `describeCredEnvelopeState()` so `skrr status` / `oversky status` can say so:
211
+ * `describeCredEnvelopeState()` so `skrr whoami` and `skrrd status` can say so:
212
212
  * the split cannot be repaired here (each side's secrets live in its own
213
213
  * keychain namespace, sealed under its own DEK, and re-sealing them is not
214
214
  * auth-core's to do), so being loud about it IS the remedy.
@@ -501,8 +501,12 @@ export async function initExistingCredEnvelope(profile) {
501
501
  const target = wrappedDekFilePath(profile);
502
502
  fd = fs.openSync(target, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW ?? 0));
503
503
  const before = fs.fstatSync(fd);
504
- const safe = (stat) => stat.isFile() && stat.nlink === 1 && stat.size > 0 && stat.size <= 65_536 &&
505
- (stat.mode & 0o077) === 0 && (typeof process.getuid !== 'function' || stat.uid === process.getuid());
504
+ const safe = (stat) => stat.isFile() &&
505
+ stat.nlink === 1 &&
506
+ stat.size > 0 &&
507
+ stat.size <= 65_536 &&
508
+ (stat.mode & 0o077) === 0 &&
509
+ (typeof process.getuid !== 'function' || stat.uid === process.getuid());
506
510
  if (!safe(before))
507
511
  throw new Error('unsafe envelope');
508
512
  const readBounded = () => {
@@ -529,18 +533,32 @@ export async function initExistingCredEnvelope(profile) {
529
533
  throw new Error('changed envelope');
530
534
  const after = fs.fstatSync(fd);
531
535
  const current = fs.lstatSync(target);
532
- if (!safe(after) || !safe(current) || before.dev !== after.dev || before.ino !== after.ino ||
533
- before.dev !== current.dev || before.ino !== current.ino || before.size !== after.size ||
534
- before.size !== current.size || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs ||
535
- before.mtimeMs !== current.mtimeMs || before.ctimeMs !== current.ctimeMs ||
536
- wrappedDekFilePath(profile) !== target || _state.kind !== 'uninit') {
536
+ if (!safe(after) ||
537
+ !safe(current) ||
538
+ before.dev !== after.dev ||
539
+ before.ino !== after.ino ||
540
+ before.dev !== current.dev ||
541
+ before.ino !== current.ino ||
542
+ before.size !== after.size ||
543
+ before.size !== current.size ||
544
+ before.mtimeMs !== after.mtimeMs ||
545
+ before.ctimeMs !== after.ctimeMs ||
546
+ before.mtimeMs !== current.mtimeMs ||
547
+ before.ctimeMs !== current.ctimeMs ||
548
+ wrappedDekFilePath(profile) !== target ||
549
+ _state.kind !== 'uninit') {
537
550
  throw new Error('changed envelope');
538
551
  }
539
552
  for (const old of _retiredDeks)
540
553
  old.fill(0);
541
554
  _retiredDeks = [];
542
- _state = { kind: 'active', dek: candidate, kekId: kek.id,
543
- kekKind: typeof kek.kind === 'string' || kek.kind === null ? (kek.kind ?? null) : null, profile };
555
+ _state = {
556
+ kind: 'active',
557
+ dek: candidate,
558
+ kekId: kek.id,
559
+ kekKind: typeof kek.kind === 'string' || kek.kind === null ? (kek.kind ?? null) : null,
560
+ profile,
561
+ };
544
562
  candidate = undefined;
545
563
  }
546
564
  catch {
@@ -582,14 +600,22 @@ export async function initNewIndependentCredEnvelope(profile) {
582
600
  // recovery, not first enrollment, even if a retried caller says otherwise.
583
601
  const dir = resolved.canonicalDir;
584
602
  const stat = fs.lstatSync(dir);
585
- if (!stat.isDirectory() || stat.isSymbolicLink() || (stat.mode & 0o077) !== 0 ||
603
+ if (!stat.isDirectory() ||
604
+ stat.isSymbolicLink() ||
605
+ (stat.mode & 0o077) !== 0 ||
586
606
  (typeof process.getuid === 'function' && stat.uid !== process.getuid())) {
587
607
  throw new Error('Background credential enrollment is unavailable');
588
608
  }
589
- const artifacts = ['device-private-key', 'device-public-key.jwk', 'auth-binding.json', 'auth.json'];
609
+ const artifacts = [
610
+ 'device-private-key',
611
+ 'device-public-key.jwk',
612
+ 'auth-binding.json',
613
+ 'auth.json',
614
+ ];
590
615
  const artifactDirs = [dir, ...(resolved.legacyDir ? [resolved.legacyDir] : [])];
591
616
  const assertEmpty = () => {
592
- if (paths.some(present) || artifactDirs.some((root) => artifacts.some((name) => present(path.join(root, name)))) ||
617
+ if (paths.some(present) ||
618
+ artifactDirs.some((root) => artifacts.some((name) => present(path.join(root, name)))) ||
593
619
  wrappedDekFilePath(profile) !== resolved.canonicalPath) {
594
620
  throw new Error('Background credential enrollment needs recovery');
595
621
  }
@@ -612,7 +638,9 @@ export async function initNewIndependentCredEnvelope(profile) {
612
638
  return await initExistingCredEnvelope(profile);
613
639
  assertEmpty();
614
640
  const temporaryPath = path.join(dir, `.cred-dek-enrollment.${randomBytes(12).toString('hex')}.tmp`);
615
- const fd = fs.openSync(temporaryPath, fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_EXCL |
641
+ const fd = fs.openSync(temporaryPath, fs.constants.O_WRONLY |
642
+ fs.constants.O_CREAT |
643
+ fs.constants.O_EXCL |
616
644
  (fs.constants.O_NOFOLLOW ?? 0), 0o600);
617
645
  temp = temporaryPath;
618
646
  try {
@@ -834,7 +862,9 @@ export async function initCredEnvelope(profile) {
834
862
  // was sealed under it.
835
863
  if (unwrapAttemptedAndFailed && dek === null) {
836
864
  _kekRotationDetected = true;
837
- const keptAs = unreadableWrapped ? keepUnreadableWrappedDek(profile, unreadableWrapped) : null;
865
+ const keptAs = unreadableWrapped
866
+ ? keepUnreadableWrappedDek(profile, unreadableWrapped)
867
+ : null;
838
868
  emit('cred_envelope.kek_rotated', false, {
839
869
  kekId: kek.id,
840
870
  kekKind: captureKind(),
@@ -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;