@skrr-ai/cli 0.1.165 → 0.1.167

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 (97) hide show
  1. package/dist/base-command.js +0 -1
  2. package/dist/commands/activity/scan-older.d.ts +1 -1
  3. package/dist/commands/activity/scan-older.js +5 -4
  4. package/dist/commands/agent/message/approve.d.ts +1 -0
  5. package/dist/commands/agent/message/approve.js +6 -2
  6. package/dist/commands/agent/message/decline.d.ts +1 -0
  7. package/dist/commands/agent/message/decline.js +6 -2
  8. package/dist/commands/agent/message/pending.js +5 -2
  9. package/dist/commands/agent/message/review.d.ts +13 -0
  10. package/dist/commands/agent/message/review.js +68 -0
  11. package/dist/commands/agents/always-on/recovery-close.d.ts +28 -0
  12. package/dist/commands/agents/always-on/recovery-close.js +60 -0
  13. package/dist/commands/agents/always-on/recovery-review.d.ts +22 -0
  14. package/dist/commands/agents/always-on/recovery-review.js +190 -0
  15. package/dist/commands/apps/installations/compatibility.js +1 -1
  16. package/dist/commands/apps/installations/list.js +3 -0
  17. package/dist/commands/apps/installations/migrate/abort.d.ts +13 -0
  18. package/dist/commands/apps/installations/migrate/abort.js +45 -0
  19. package/dist/commands/apps/installations/migrate/cutover.d.ts +15 -0
  20. package/dist/commands/apps/installations/migrate/cutover.js +102 -0
  21. package/dist/commands/apps/installations/migrate/plan.d.ts +13 -0
  22. package/dist/commands/apps/installations/migrate/plan.js +51 -0
  23. package/dist/commands/apps/installations/migrate/rollback.d.ts +16 -0
  24. package/dist/commands/apps/installations/migrate/rollback.js +103 -0
  25. package/dist/commands/apps/installations/migrate/stage.d.ts +15 -0
  26. package/dist/commands/apps/installations/migrate/stage.js +96 -0
  27. package/dist/commands/apps/installations/migrate/status.d.ts +12 -0
  28. package/dist/commands/apps/installations/migrate/status.js +52 -0
  29. package/dist/commands/apps/installations/migrate/validate.d.ts +14 -0
  30. package/dist/commands/apps/installations/migrate/validate.js +58 -0
  31. package/dist/commands/apps/installations/show.js +8 -6
  32. package/dist/commands/apps/operations/check.js +1 -1
  33. package/dist/commands/apps/resume.js +1 -1
  34. package/dist/commands/apps/settings/set.js +22 -10
  35. package/dist/commands/duties/show.js +10 -0
  36. package/dist/commands/goals/key-results/assess.d.ts +2 -3
  37. package/dist/commands/goals/key-results/assess.js +5 -12
  38. package/dist/commands/harnesses/removal-references.d.ts +16 -0
  39. package/dist/commands/harnesses/removal-references.js +61 -0
  40. package/dist/commands/tasks/actionability.js +8 -3
  41. package/dist/commands/tasks/complete.js +35 -17
  42. package/dist/commands/tasks/expectations/assess.d.ts +1 -0
  43. package/dist/commands/tasks/expectations/assess.js +50 -21
  44. package/dist/commands/tasks/expectations.js +5 -2
  45. package/dist/commands/tasks/judge.d.ts +1 -0
  46. package/dist/commands/tasks/judge.js +17 -2
  47. package/dist/commands/tasks/result/submit.js +26 -17
  48. package/dist/commands/tasks/review-queue.js +2 -1
  49. package/dist/commands/tasks/review.d.ts +1 -0
  50. package/dist/commands/tasks/review.js +24 -3
  51. package/dist/commands/tasks/show.d.ts +13 -0
  52. package/dist/commands/tasks/show.js +41 -3
  53. package/dist/commands/tasks/updates/add.d.ts +1 -0
  54. package/dist/commands/tasks/updates/add.js +71 -21
  55. package/dist/commands/tasks/updates/list.d.ts +4 -0
  56. package/dist/commands/tasks/updates/list.js +3 -1
  57. package/dist/commands/tasks/waive.d.ts +1 -0
  58. package/dist/commands/tasks/waive.js +17 -2
  59. package/dist/generated/agent-guides.json +20 -20
  60. package/dist/lib/agent-activity.d.ts +3 -1
  61. package/dist/lib/agent-activity.js +50 -11
  62. package/dist/lib/api-fetch.js +32 -5
  63. package/dist/lib/appCompatibility.js +1 -1
  64. package/dist/lib/appData.d.ts +1 -1
  65. package/dist/lib/appData.js +6 -2
  66. package/dist/lib/appDataMigration.d.ts +204 -0
  67. package/dist/lib/appDataMigration.js +753 -0
  68. package/dist/lib/appDataMigrationCommand.d.ts +39 -0
  69. package/dist/lib/appDataMigrationCommand.js +90 -0
  70. package/dist/lib/appInstallations.d.ts +8 -0
  71. package/dist/lib/appInstallations.js +55 -2
  72. package/dist/lib/apps-command.js +17 -10
  73. package/dist/lib/harnesses.d.ts +24 -0
  74. package/dist/lib/harnesses.js +4 -0
  75. package/dist/lib/node-adapter.d.ts +0 -2
  76. package/dist/lib/node-adapter.js +46 -42
  77. package/dist/lib/rate-limit-retry.d.ts +4 -5
  78. package/dist/lib/rate-limit-retry.js +6 -10
  79. package/dist/lib/reference-syntax.d.ts +28 -0
  80. package/dist/lib/reference-syntax.js +91 -0
  81. package/dist/lib/refresh.d.ts +2 -0
  82. package/dist/lib/refresh.js +6 -0
  83. package/dist/lib/runtime-context.js +6 -0
  84. package/dist/lib/task-closure.d.ts +1 -1
  85. package/dist/lib/task-closure.js +1 -1
  86. package/dist/lib/task-operations.d.ts +28 -6
  87. package/dist/lib/task-operations.js +77 -4
  88. package/dist/lib/task-preflight.js +8 -3
  89. package/dist/lib/task-write-attribution.d.ts +183 -19
  90. package/dist/lib/task-write-attribution.js +270 -39
  91. package/dist/lib/write-outcome.d.ts +2 -0
  92. package/dist/lib/write-outcome.js +14 -0
  93. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.js +63 -0
  94. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.js +71 -0
  95. package/dist/node_modules/@skrr-ai/data-provider/index.js +11635 -11306
  96. package/oclif.manifest.json +1387 -412
  97. package/package.json +5 -2
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReferenceSyntaxError = exports.REFERENCE_SYNTAX_EXAMPLES = void 0;
4
+ exports.parseReference = parseReference;
5
+ exports.parseReferences = parseReferences;
6
+ exports.liftReferenceEntries = liftReferenceEntries;
7
+ /**
8
+ * `<kind>:<id-or-uri>`: the one way a reference is written on the command line.
9
+ *
10
+ * Five commands take one as a flag value (`tasks complete --evidence`, `tasks result submit
11
+ * --evidence`, `tasks expectations assess --evidence`, `tasks updates add --reference` and
12
+ * `--evidence`, `goals key-results assess --evidence`), and each used to split it itself. They
13
+ * disagreed: `complete` and `key-results assess` refused `task:` with nothing after the colon, and
14
+ * the others sent it on for the server to refuse; `complete` read a value starting with `/` as a
15
+ * uri, and the others read it as an id. All of them split a bare URL at its own scheme, so
16
+ * `https://example.com/x` became kind `https` with id `//example.com/x`.
17
+ *
18
+ * The server's shape is `{ kind, id?, uri?, label?, version?, digest? }`, with `kind` and one of
19
+ * `id`/`uri` required (`taskReferenceSchema`, api/server/services/TaskUpdates/updateDataContract.js).
20
+ * This module only spells it; the server stays the validator.
21
+ */
22
+ /** A value with a scheme and an authority (`https://…`, `file:///…`, `s3://…`) is a whole URL. */
23
+ const BARE_URL_RE = /^[a-z][a-z0-9+.-]*:\/\//i;
24
+ /** After the kind, a value is a location rather than an id when it is one of these. */
25
+ const URI_SCHEME_RE = /^(?:https?|file):/i;
26
+ /** The accepted spellings, as error messages and help name them. */
27
+ exports.REFERENCE_SYNTAX_EXAMPLES = 'such as task:OSK-42, pr:https://github.com/acme/app/pull/482 or https://ci.example.com/runs/77';
28
+ class ReferenceSyntaxError extends Error {
29
+ constructor(message) {
30
+ super(message);
31
+ this.name = 'ReferenceSyntaxError';
32
+ }
33
+ }
34
+ exports.ReferenceSyntaxError = ReferenceSyntaxError;
35
+ function isUriValue(value) {
36
+ return BARE_URL_RE.test(value) || URI_SCHEME_RE.test(value) || value.startsWith('/');
37
+ }
38
+ /**
39
+ * Read one `<kind>:<id-or-uri>`, or a bare URL, into a reference. Throws a
40
+ * {@link ReferenceSyntaxError} naming `flag` when there is no kind or nothing after the colon.
41
+ *
42
+ * https://x/pr/1 → { kind: 'url', uri: 'https://x/pr/1' }
43
+ * pr:https://x/pr/1 → { kind: 'pr', uri: 'https://x/pr/1' }
44
+ * file:/tmp/report.txt → { kind: 'file', uri: '/tmp/report.txt' }
45
+ * task:OSK-42 → { kind: 'task', id: 'OSK-42' }
46
+ */
47
+ function parseReference(raw, flag) {
48
+ const text = raw.trim();
49
+ if (BARE_URL_RE.test(text))
50
+ return { kind: 'url', uri: text };
51
+ const split = text.indexOf(':');
52
+ const kind = split > 0 ? text.slice(0, split).trim() : '';
53
+ const value = split > 0 ? text.slice(split + 1).trim() : '';
54
+ if (!kind || !value) {
55
+ let why = 'nothing follows the colon';
56
+ if (split < 0)
57
+ why = 'there is no kind';
58
+ else if (!kind)
59
+ why = 'the kind before the colon is empty';
60
+ throw new ReferenceSyntaxError(`${flag} must be <kind>:<id-or-uri> or a URL, ${exports.REFERENCE_SYNTAX_EXAMPLES} ` +
61
+ `(got "${raw}": ${why}).`);
62
+ }
63
+ return isUriValue(value) ? { kind, uri: value } : { kind, id: value };
64
+ }
65
+ /** {@link parseReference} for every value of a repeatable flag; an absent flag is `[]`. */
66
+ function parseReferences(raws, flag) {
67
+ return (raws ?? []).map((raw) => parseReference(raw, flag));
68
+ }
69
+ /**
70
+ * The entries of an `evidenceRefs` array written by hand in JSON, with each STRING entry turned
71
+ * into the object the server takes: a URL, or `<kind>:<id-or-uri>`. Anything that is not a string
72
+ * passes through untouched, because the server is the validator of the object form.
73
+ *
74
+ * A string that is neither is refused here, naming its index, so the first attempt does not
75
+ * travel to the server to learn the shape (`data.evidenceRefs.0: expected object, received
76
+ * string`).
77
+ */
78
+ function liftReferenceEntries(entries, field) {
79
+ return entries.map((entry, index) => {
80
+ if (typeof entry !== 'string')
81
+ return entry;
82
+ try {
83
+ return parseReference(entry, `${field}[${index}]`);
84
+ }
85
+ catch {
86
+ throw new ReferenceSyntaxError(`${field}[${index}] is "${entry}", which is not a reference. An entry is an object ` +
87
+ '{"kind":"…","id":"…"} or {"kind":"…","uri":"…"} (label optional), a URL, or a ' +
88
+ `"<kind>:<id-or-uri>" string, ${exports.REFERENCE_SYNTAX_EXAMPLES}.`);
89
+ }
90
+ });
91
+ }
@@ -56,6 +56,8 @@ export interface EnsureFreshCliCredentialResult {
56
56
  refreshFailureCode?: string;
57
57
  skippedReason?: 'no_token' | 'ci_token' | 'personal_access_token' | 'external_source' | 'env_override' | 'bare_mode' | 'fresh' | 'no_refresh_token' | 'refresh_failed';
58
58
  }
59
+ /** An opaque token uses the stored expiry metadata when ensureFreshCliCredential runs. */
60
+ export declare function cliCredentialNeedsRefresh(token: string | null | undefined): boolean;
59
61
  /**
60
62
  * Ensure the active CLI credential has enough remaining lifetime for a
61
63
  * normal command run. Uses the same storage and refresh endpoint as the
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TransientAuthFailure = exports.PermanentAuthFailure = exports.CliRefreshUnavailableError = exports.CLI_REFRESH_EARLY_MS = void 0;
4
4
  exports.getCliOrigin = getCliOrigin;
5
+ exports.cliCredentialNeedsRefresh = cliCredentialNeedsRefresh;
5
6
  exports.ensureFreshCliCredential = ensureFreshCliCredential;
6
7
  exports.refreshCliToken = refreshCliToken;
7
8
  exports.revokeCurrentRefreshToken = revokeCurrentRefreshToken;
@@ -66,6 +67,11 @@ function expiryFromToken(token) {
66
67
  const exp = (0, auth_core_1.decodeJwtExpiry)(token);
67
68
  return typeof exp === 'number' && Number.isFinite(exp) ? exp * 1000 : undefined;
68
69
  }
70
+ /** An opaque token uses the stored expiry metadata when ensureFreshCliCredential runs. */
71
+ function cliCredentialNeedsRefresh(token) {
72
+ const expiresAt = expiryFromToken(token);
73
+ return expiresAt === undefined || expiresAt - Date.now() <= exports.CLI_REFRESH_EARLY_MS;
74
+ }
69
75
  function accessExpiryMs(bundle, token) {
70
76
  if (typeof bundle?.expiresAt === 'number' && Number.isFinite(bundle.expiresAt)) {
71
77
  return bundle.expiresAt;
@@ -139,6 +139,12 @@ function detectExternalTool(env = process.env) {
139
139
  if (claudeCode && claudeCode !== '0' && claudeCode !== 'false') {
140
140
  return 'claude-code';
141
141
  }
142
+ // Codex marks the commands it runs in its sandbox (`CODEX_SANDBOX=seatbelt` on macOS,
143
+ // `CODEX_SANDBOX_NETWORK_DISABLED=1` when the network is off). A full-access Codex sets
144
+ // neither, so this finds some Codex shells, not all: a hint, and its absence proves nothing.
145
+ if (envValue(env, 'CODEX_SANDBOX') || envValue(env, 'CODEX_SANDBOX_NETWORK_DISABLED')) {
146
+ return 'codex';
147
+ }
142
148
  return null;
143
149
  }
144
150
  function envFirst(env, names) {
@@ -58,6 +58,6 @@ export declare function reopenRequiredLines({ bin, task, command, }: {
58
58
  task: string;
59
59
  command: 'result submit' | 'complete';
60
60
  }): string[];
61
- /** `met (agent)` vs `met (person)` — shared with the web through data-provider. */
61
+ /** `met (agent)`, `met (person via CLI credential)` — shared with the web through data-provider. */
62
62
  export { describeAssessorKind as describeAssessor } from '@skrr-ai/data-provider';
63
63
  export { describeClosure as closureSnapshotLines, type TaskClosureSnapshot as ClosureSnapshot, } from '@skrr-ai/data-provider';
@@ -130,7 +130,7 @@ function reopenRequiredLines({ bin, task, command, }) {
130
130
  : `→ Then submit again, or submit and close in one step: ${bin} tasks complete ${task} --summary "…"`,
131
131
  ];
132
132
  }
133
- /** `met (agent)` vs `met (person)` — shared with the web through data-provider. */
133
+ /** `met (agent)`, `met (person via CLI credential)` — shared with the web through data-provider. */
134
134
  var data_provider_2 = require("@skrr-ai/data-provider");
135
135
  Object.defineProperty(exports, "describeAssessor", { enumerable: true, get: function () { return data_provider_2.describeAssessorKind; } });
136
136
  function truncate(value, max) {
@@ -1,13 +1,35 @@
1
+ /** The fields of a Task that decide which assignment command fixes it. */
2
+ export type TaskAssignmentState = {
3
+ executionMode?: unknown;
4
+ assigneeAgentIds?: unknown;
5
+ assigneeUserIds?: unknown;
6
+ };
7
+ /** One command that carries out a server-declared action, and what it does when there is a choice. */
8
+ export type TaskActionRemedy = {
9
+ command: string;
10
+ what?: string;
11
+ };
12
+ type TaskActionContext = {
13
+ allowedActions?: ReadonlyArray<{
14
+ action: string;
15
+ }>;
16
+ /** The Task itself, when the caller has it. Without it, `assign_task` lists every way to assign. */
17
+ task?: TaskAssignmentState;
18
+ };
1
19
  /**
2
20
  * Documentation and display paths only. The server still owns allowedActions.
3
21
  *
4
22
  * `skrr tasks guide`'s command map retired into the tasks guide's `commands`
5
23
  * section (`skrr guide tasks commands`), the one copy every surface reads;
6
- * what remains here is the action→command remedies preflight and
24
+ * what remains here is the action→command remedies `tasks show`, preflight and
7
25
  * actionability render into server-declared allowedActions.
26
+ *
27
+ * Most actions have one command. `assign_task` can have several (see
28
+ * `assignTaskRemedies`), so a renderer lists every entry, not only the first.
8
29
  */
9
- export declare function taskActionCommand(action: string, taskId: string, targetId: string | undefined, bin?: string, context?: {
10
- allowedActions?: ReadonlyArray<{
11
- action: string;
12
- }>;
13
- }): string | undefined;
30
+ export declare function taskActionRemedies(action: string, taskId: string, targetId: string | undefined, bin?: string, context?: TaskActionContext): TaskActionRemedy[];
31
+ /** One row per remedy: the command, then what it does, with the notes lined up. */
32
+ export declare function taskActionRemedyRows(remedies: readonly TaskActionRemedy[]): string[];
33
+ /** The first command for an action. A renderer should list `taskActionRemedies` instead. */
34
+ export declare function taskActionCommand(action: string, taskId: string, targetId: string | undefined, bin?: string, context?: TaskActionContext): string | undefined;
35
+ export {};
@@ -1,21 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.taskActionRemedies = taskActionRemedies;
4
+ exports.taskActionRemedyRows = taskActionRemedyRows;
3
5
  exports.taskActionCommand = taskActionCommand;
6
+ const data_provider_1 = require("@skrr-ai/data-provider");
4
7
  const shell_quote_1 = require("./shell-quote");
5
8
  /**
6
9
  * Documentation and display paths only. The server still owns allowedActions.
7
10
  *
8
11
  * `skrr tasks guide`'s command map retired into the tasks guide's `commands`
9
12
  * section (`skrr guide tasks commands`), the one copy every surface reads;
10
- * what remains here is the action→command remedies preflight and
13
+ * what remains here is the action→command remedies `tasks show`, preflight and
11
14
  * actionability render into server-declared allowedActions.
15
+ *
16
+ * Most actions have one command. `assign_task` can have several (see
17
+ * `assignTaskRemedies`), so a renderer lists every entry, not only the first.
12
18
  */
13
- function taskActionCommand(action, taskId, targetId, bin = 'skrr', context = {}) {
19
+ function taskActionRemedies(action, taskId, targetId, bin = 'skrr', context = {}) {
14
20
  const task = (0, shell_quote_1.shellQuoteArg)(taskId);
15
21
  const target = targetId ? (0, shell_quote_1.shellQuoteArg)(targetId) : '<id>';
22
+ if (action === 'assign_task') {
23
+ return assignTaskRemedies(task, context.task).map((remedy) => ({
24
+ ...remedy,
25
+ command: `${bin} ${remedy.command}`,
26
+ }));
27
+ }
16
28
  const commands = {
17
29
  answer_human_input: `tasks input answer ${task} --request ${target} --text <answer>`,
18
- assign_task: `tasks assign ${task} --help`,
19
30
  // Managed work already has a current Result. Its server-declared
20
31
  // continuation surface distinguishes closing from submitting a new Result.
21
32
  complete_task: context.allowedActions?.some((item) => item.action === 'continue_task')
@@ -36,5 +47,67 @@ function taskActionCommand(action, taskId, targetId, bin = 'skrr', context = {})
36
47
  triage_task: `tasks triage ${task}`,
37
48
  unschedule_task: `tasks unschedule ${task}`,
38
49
  };
39
- return commands[action] ? `${bin} ${commands[action]}` : undefined;
50
+ return commands[action] ? [{ command: `${bin} ${commands[action]}` }] : [];
51
+ }
52
+ /** One row per remedy: the command, then what it does, with the notes lined up. */
53
+ function taskActionRemedyRows(remedies) {
54
+ const width = Math.max(0, ...remedies.filter((r) => r.what).map((r) => r.command.length));
55
+ return remedies.map(({ command, what }) => what ? `${command.padEnd(width)} ${what}` : command);
56
+ }
57
+ /** The first command for an action. A renderer should list `taskActionRemedies` instead. */
58
+ function taskActionCommand(action, taskId, targetId, bin = 'skrr', context = {}) {
59
+ return taskActionRemedies(action, taskId, targetId, bin, context)[0]?.command;
60
+ }
61
+ /**
62
+ * The commands that answer `assign_task`.
63
+ *
64
+ * The server says "Choose an executor and assignee" (or, for a started Task,
65
+ * "has no assigned executor") and this used to point at `tasks assign --help`,
66
+ * so the reader learned what was missing and not how to supply it (OSK-24355).
67
+ *
68
+ * Assigning settles both halves: when no executor was declared, the server
69
+ * records the assignee's kind as the executor. `tasks update --execution-mode`
70
+ * sets the executor without assigning anyone. When an executor WAS declared,
71
+ * only an assignee of that kind is needed, or the executor can be switched to
72
+ * the kind already assigned.
73
+ */
74
+ function assignTaskRemedies(task, state) {
75
+ const agent = { command: `tasks assign ${task} --agent <agent>`, what: 'an Agent does it' };
76
+ const person = { command: `tasks assign ${task} <person>`, what: 'a person does it' };
77
+ const executor = state ? (0, data_provider_1.resolveTaskExecutor)(state) : null;
78
+ if (executor?.source === 'declared') {
79
+ const hasUsers = hasIds(state?.assigneeUserIds);
80
+ const hasAgents = hasIds(state?.assigneeAgentIds);
81
+ if (executor.mode === 'agent') {
82
+ return hasUsers
83
+ ? [
84
+ agent,
85
+ {
86
+ command: `tasks update ${task} --execution-mode human`,
87
+ what: 'the assigned person does it',
88
+ },
89
+ ]
90
+ : [agent];
91
+ }
92
+ return hasAgents
93
+ ? [
94
+ person,
95
+ {
96
+ command: `tasks update ${task} --execution-mode agent`,
97
+ what: 'the assigned Agent does it',
98
+ },
99
+ ]
100
+ : [person];
101
+ }
102
+ return [
103
+ agent,
104
+ person,
105
+ {
106
+ command: `tasks update ${task} --execution-mode <agent|human>`,
107
+ what: 'choose the executor only',
108
+ },
109
+ ];
110
+ }
111
+ function hasIds(values) {
112
+ return Array.isArray(values) && values.some(Boolean);
40
113
  }
@@ -135,10 +135,15 @@ function taskPreflightLines(report, bin = 'skrr') {
135
135
  if (a.actorRefs?.length)
136
136
  lines.push(`Eligible actors: ${a.actorRefs.map((ref) => `${ref.kind}:${ref.id}`).join(', ')}`);
137
137
  for (const action of a.allowedActions) {
138
- const command = (0, task_operations_1.taskActionCommand)(action.action, report.taskId, action.targetId, bin, {
138
+ const rows = (0, task_operations_1.taskActionRemedyRows)((0, task_operations_1.taskActionRemedies)(action.action, report.taskId, action.targetId, bin, {
139
139
  allowedActions: a.allowedActions,
140
- });
141
- lines.push(` ${action.action}${command ? ` → ${command}` : ' (no single CLI remedy is mapped)'}`);
140
+ }));
141
+ if (rows.length === 0)
142
+ lines.push(` ${action.action} (no single CLI remedy is mapped)`);
143
+ // An action with more than one command (assign_task) lists each under the first.
144
+ rows.forEach((row, index) => lines.push(index === 0
145
+ ? ` ${action.action} → ${row}`
146
+ : ` ${' '.repeat(action.action.length)} ${row}`));
142
147
  }
143
148
  lines.push('Allowed actions describe the workflow; the caller must still have permission to perform them.');
144
149
  }
@@ -1,35 +1,199 @@
1
+ import { type CredentialChannel, type TaskEvidenceLevel, type TaskWriteSource } from '@skrr-ai/data-provider';
1
2
  import { readRuntimeContext } from './runtime-context';
3
+ type Principal = {
4
+ kind: string;
5
+ userId?: string;
6
+ agentId?: string;
7
+ service?: string;
8
+ provider?: string;
9
+ via?: string;
10
+ declaredTool?: string;
11
+ };
12
+ /** Which canonical record a receipt carries, and the field that names its author. */
13
+ export declare const TASK_WRITE_RECORDS: {
14
+ readonly assessment: "assessedBy";
15
+ readonly result: "submittedBy";
16
+ readonly review: "reviewedBy";
17
+ readonly update: "authoredBy";
18
+ };
19
+ export type TaskWriteRecord = keyof typeof TASK_WRITE_RECORDS;
20
+ export type AttributedTo = {
21
+ /** `person` for a human principal: the signed-in account, through `via`. */
22
+ kind: 'person' | 'agent' | 'system' | 'integration' | 'unattributed';
23
+ id: string | null;
24
+ /** A person's credential channel, when the server recorded one; a label, never presence. */
25
+ via: CredentialChannel | null;
26
+ /**
27
+ * The tool a person's CLI declared it runs inside (`claude-code`, `codex`), when the server
28
+ * recorded one. The client's word, never evidence. Omitted when the receipt has none, so a
29
+ * receipt from before it was recorded prints exactly what it did.
30
+ */
31
+ declaredTool?: string;
32
+ };
33
+ export type TaskWriteWarning = {
34
+ code: string;
35
+ message: string;
36
+ };
37
+ export type TaskWriteEvidence = {
38
+ /**
39
+ * The evidence level the server computed for this write (`self_reported` … `external_receipt`),
40
+ * read from the receipt's `evidence.level`. Absent when the server did not send one (an older
41
+ * server, or an Agent runtime's session route); the CLI never derives it.
42
+ */
43
+ level?: TaskEvidenceLevel;
44
+ /** Assessments: `human_judgement` or `automatic`, as the server recorded it. */
45
+ method?: string;
46
+ /** Updates: the assertion level the server recorded (`actor_reported`, …). */
47
+ assertion?: string;
48
+ /** A `met` below the Expectation's declared bar: what was asked and what this assessor gave. */
49
+ shortfall?: {
50
+ required: string;
51
+ provided: string;
52
+ };
53
+ };
54
+ export type TaskWriteOutcome = {
55
+ recorded: true;
56
+ /** True when the server answered an idempotent replay: the SAME record, nothing new written. */
57
+ replayed: boolean;
58
+ attributedTo: AttributedTo;
59
+ evidence: TaskWriteEvidence;
60
+ warnings: TaskWriteWarning[];
61
+ };
62
+ /**
63
+ * Read the outcome of a Task write from the server's receipt.
64
+ *
65
+ * Every field comes from the receipt. Nothing is inferred from local runtime hints: a missing
66
+ * author stays `unattributed`, and the evidence level is the one the server computed and returned
67
+ * (`evidence.level`). A receipt without it, from an older server, reports what it did before (the
68
+ * method, assertion and shortfall the record carries) and no level, rather than a level derived
69
+ * here, which would be a second copy of the server's rule.
70
+ */
71
+ export declare function taskWriteOutcome(receipt: unknown, record: TaskWriteRecord): TaskWriteOutcome;
72
+ /**
73
+ * `the signed-in account (person u-1, via CLI credential)`, `Agent agent_x`, … A person whose CLI
74
+ * declared a tool reads `(person u-1, via CLI credential · declared: Claude Code)`: the same
75
+ * phrase every surface uses (`principalChannelPhrase`), which marks the tool as declared.
76
+ */
77
+ export declare function describeAttributedTo(attributedTo: AttributedTo): string;
78
+ /**
79
+ * The lines a write prints. The first is the outcome: `<Verb> <what> — attributed to <whom>.`, or,
80
+ * for an idempotent replay, that the same record already existed and nothing new was written.
81
+ * When the server returned the evidence level it computed, `Evidence level: <level>.` comes next.
82
+ * Warnings follow, one line each. Nothing after a success reads like a refusal.
83
+ */
84
+ export declare function taskWriteOutcomeLines({ verb, what }: {
85
+ verb: 'Recorded' | 'Submitted';
86
+ what: string;
87
+ }, outcome: TaskWriteOutcome): string[];
88
+ /**
89
+ * The `attribution` field `--json` carried before `attributedTo` existed, kept so a reader of
90
+ * `attribution.principal` keeps working. The principal exactly as the server recorded it.
91
+ */
92
+ export declare function receiptAttribution(receipt: unknown, record: TaskWriteRecord): {
93
+ method?: string | undefined;
94
+ source: "server_receipt";
95
+ principal: Principal | null;
96
+ };
97
+ /** The `--confirm-as-me` flag, one definition for every command that records a judgement. */
98
+ export declare const confirmAsMeFlag: import("@oclif/core/interfaces").BooleanFlag<boolean>;
99
+ /** The part of an oclif command the gate reads, and only when it refuses. */
100
+ export type JudgementInvocation = {
101
+ readonly config?: {
102
+ readonly bin: string;
103
+ };
104
+ readonly id?: string;
105
+ readonly argv?: readonly string[];
106
+ };
107
+ /**
108
+ * The refusal, or null, for a judgement about to be written. Null unless this is a hand-started
109
+ * coding-agent shell and `--confirm-as-me` was not given. Decided before any network call, so a
110
+ * refusal has written nothing. `command` is read only to rebuild the command line for the refusal.
111
+ */
112
+ export declare function personJudgementGate(command: JudgementInvocation, { confirmed, judgement, task, env, }: {
113
+ confirmed: boolean | undefined;
114
+ judgement: string;
115
+ task: string;
116
+ env?: Readonly<Record<string, string | undefined>>;
117
+ }): PersonConfirmationRefusal | null;
118
+ /**
119
+ * The coding agent this `skrr` runs inside, when it was started by hand there.
120
+ *
121
+ * Returns the tool key (`claude-code`, `codex`, …) only for a process the daemon did NOT start: a
122
+ * daemon-started session carries its own Agent runtime, and its Task writes are the Agent's. For a
123
+ * hand-started one the CLI login is the person's, so every Task write is attributed to the person.
124
+ * The key comes from the tool's own environment marker; a hint for wording and defaults, never
125
+ * evidence of anything, and its absence proves nothing either.
126
+ */
127
+ export declare function handStartedCodingAgent(env?: Readonly<Record<string, string | undefined>>): string | null;
128
+ /**
129
+ * What a person's Task write declares about the shell it runs in: `{ source: { externalTool } }`
130
+ * when `handStartedCodingAgent` found a coding agent the person started by hand, `{}` otherwise.
131
+ *
132
+ * The same field, on the same body key, that a direct message sends (`buildCliSourceMetadata`,
133
+ * `source.externalTool`), and only the field: nothing is sent that was not detected. The server
134
+ * stores it beside the person as `declaredTool` and every surface shows it marked as declared.
135
+ * The marker comes from the person's own tool, so it is the client's word: displayed, never
136
+ * trusted, and never part of who the write is attributed to (owner decision 2026-11-12, OSK-24355).
137
+ * A daemon-started session sends nothing; its writes are its Agent's, proven by its Run.
138
+ */
139
+ export declare function declaredToolSource(env?: Readonly<Record<string, string | undefined>>): {
140
+ source?: TaskWriteSource;
141
+ };
142
+ export declare const PERSON_CONFIRMATION_REQUIRED = "PERSON_CONFIRMATION_REQUIRED";
143
+ export type PersonConfirmationRefusal = {
144
+ code: typeof PERSON_CONFIRMATION_REQUIRED;
145
+ message: string;
146
+ details: {
147
+ codingAgent: string;
148
+ attributedTo: 'person';
149
+ written: false;
150
+ nextSteps: Array<{
151
+ kind: string;
152
+ command: string;
153
+ description: string;
154
+ }>;
155
+ };
156
+ };
157
+ /**
158
+ * The refusal a judgement gets from a hand-started coding-agent shell without `--confirm-as-me`.
159
+ *
160
+ * Nothing has been written when this is returned. It names the two truthful ways on: the person
161
+ * asked for it to be theirs (re-run with the flag), or the agent records what it checked as a
162
+ * `verification` Update and leaves the judgement to the person. `tasks start` is NOT offered: it
163
+ * hands the Task to its assigned Agent in a NEW session, so suggesting it to an agent already doing
164
+ * the work would start a second worker rather than attribute this one.
165
+ */
166
+ export declare function personConfirmationRefusal({ codingAgent, judgement, rerun, bin, task, }: {
167
+ codingAgent: string;
168
+ /** `assessing e1 as met`, `accepting Result tr_1`, … */
169
+ judgement: string;
170
+ /** The command as it should be re-run, with `--confirm-as-me` appended. */
171
+ rerun: string;
172
+ bin: string;
173
+ task: string;
174
+ }): PersonConfirmationRefusal;
175
+ /** Quote one argument for a copy-pasteable command line, only when it needs it. */
176
+ export declare function shellArg(value: string): string;
2
177
  export type UnboundRuntimeSetupStep = {
3
178
  kind: 'inspect_local_harnesses' | 'inspect_local_code_agent' | 'start_assigned_task';
4
179
  command: string;
5
180
  description: string;
6
181
  };
7
182
  /**
8
- * An unbound shell is normal for a person starting the CLI by hand. The useful
9
- * answer is not an invitation to forge an environment variable; it is the
10
- * smallest truthful route to learn which local engines are registered, choose
11
- * a local Code identity, or enter an assigned task's authenticated runtime.
183
+ * An unbound shell is normal for a person starting the CLI by hand. The useful answer is not an
184
+ * invitation to forge an environment variable; it is the smallest truthful route to learn which
185
+ * local engines are registered, choose a local Code identity, or hand an assigned Task to its
186
+ * Agent's own runtime.
12
187
  */
13
188
  export declare function unboundRuntimeSetup(bin?: string): UnboundRuntimeSetupStep[];
189
+ /**
190
+ * What `skrr context` says in a shell with no Agent runtime. A statement of how writes are
191
+ * recorded, not a refusal: nothing here stops a write.
192
+ */
14
193
  export declare function agentBindingGuidance(bin?: string): string;
15
194
  /** Compatibility for receipts and surfaces that do not know the invoked bin name. */
16
195
  export declare const AGENT_BINDING_GUIDANCE: string;
17
196
  export declare const ACCOUNT_ATTRIBUTION_NOTICE: string;
18
- type Principal = {
19
- kind: string;
20
- userId?: string;
21
- agentId?: string;
22
- service?: string;
23
- };
24
- /** Use the persisted server receipt, never the process's claimed Agent identity. */
25
- export declare function taskWriteAttribution(receipt: unknown, field: 'assessedBy' | 'submittedBy'): {
26
- bindingGuidance?: string | undefined;
27
- notice: string | null;
28
- method?: string | undefined;
29
- source: "server_receipt";
30
- principal: Principal | null;
31
- };
32
- export declare function attributionLines(attribution: ReturnType<typeof taskWriteAttribution>): string[];
33
197
  /** Environment hints explain local execution only; the server verifies every write. */
34
198
  export declare function runtimeWriteAttribution(runtime: ReturnType<typeof readRuntimeContext>): {
35
199
  authority: "authenticated_server_principal";