@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
@@ -1,16 +1,265 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ACCOUNT_ATTRIBUTION_NOTICE = exports.AGENT_BINDING_GUIDANCE = void 0;
3
+ exports.ACCOUNT_ATTRIBUTION_NOTICE = exports.AGENT_BINDING_GUIDANCE = exports.PERSON_CONFIRMATION_REQUIRED = exports.confirmAsMeFlag = exports.TASK_WRITE_RECORDS = void 0;
4
+ exports.taskWriteOutcome = taskWriteOutcome;
5
+ exports.describeAttributedTo = describeAttributedTo;
6
+ exports.taskWriteOutcomeLines = taskWriteOutcomeLines;
7
+ exports.receiptAttribution = receiptAttribution;
8
+ exports.personJudgementGate = personJudgementGate;
9
+ exports.handStartedCodingAgent = handStartedCodingAgent;
10
+ exports.declaredToolSource = declaredToolSource;
11
+ exports.personConfirmationRefusal = personConfirmationRefusal;
12
+ exports.shellArg = shellArg;
4
13
  exports.unboundRuntimeSetup = unboundRuntimeSetup;
5
14
  exports.agentBindingGuidance = agentBindingGuidance;
6
- exports.taskWriteAttribution = taskWriteAttribution;
7
- exports.attributionLines = attributionLines;
8
15
  exports.runtimeWriteAttribution = runtimeWriteAttribution;
16
+ const core_1 = require("@oclif/core");
17
+ const data_provider_1 = require("@skrr-ai/data-provider");
18
+ const harness_context_1 = require("./harness-context");
19
+ const runtime_context_1 = require("./runtime-context");
20
+ /** Which canonical record a receipt carries, and the field that names its author. */
21
+ exports.TASK_WRITE_RECORDS = {
22
+ assessment: 'assessedBy',
23
+ result: 'submittedBy',
24
+ review: 'reviewedBy',
25
+ update: 'authoredBy',
26
+ };
27
+ function objectAt(value, key) {
28
+ if (!value || typeof value !== 'object')
29
+ return null;
30
+ const found = value[key];
31
+ return found && typeof found === 'object' ? found : null;
32
+ }
33
+ function principalOf(row, field) {
34
+ const value = row?.[field];
35
+ return value && typeof value === 'object' && typeof value.kind === 'string'
36
+ ? value
37
+ : null;
38
+ }
39
+ function attributedToOf(principal) {
40
+ if (!principal)
41
+ return { kind: 'unattributed', id: null, via: null };
42
+ if (principal.kind === 'human') {
43
+ return {
44
+ kind: 'person',
45
+ id: principal.userId ?? null,
46
+ via: (0, data_provider_1.isCredentialChannel)(principal.via) ? principal.via : null,
47
+ ...(typeof principal.declaredTool === 'string' && principal.declaredTool
48
+ ? { declaredTool: principal.declaredTool }
49
+ : {}),
50
+ };
51
+ }
52
+ if (principal.kind === 'agent')
53
+ return { kind: 'agent', id: principal.agentId ?? null, via: null };
54
+ if (principal.kind === 'system')
55
+ return { kind: 'system', id: principal.service ?? null, via: null };
56
+ if (principal.kind === 'integration') {
57
+ return { kind: 'integration', id: principal.provider ?? null, via: null };
58
+ }
59
+ return { kind: 'unattributed', id: null, via: null };
60
+ }
61
+ /**
62
+ * Read the outcome of a Task write from the server's receipt.
63
+ *
64
+ * Every field comes from the receipt. Nothing is inferred from local runtime hints: a missing
65
+ * author stays `unattributed`, and the evidence level is the one the server computed and returned
66
+ * (`evidence.level`). A receipt without it, from an older server, reports what it did before (the
67
+ * method, assertion and shortfall the record carries) and no level, rather than a level derived
68
+ * here, which would be a second copy of the server's rule.
69
+ */
70
+ function taskWriteOutcome(receipt, record) {
71
+ const row = objectAt(receipt, record);
72
+ const principal = principalOf(row, exports.TASK_WRITE_RECORDS[record]);
73
+ const shortfall = objectAt(row, 'evidenceShortfall');
74
+ const level = objectAt(receipt, 'evidence')?.level;
75
+ const evidence = {
76
+ ...((0, data_provider_1.isTaskEvidenceLevel)(level) ? { level } : {}),
77
+ ...(typeof row?.method === 'string' ? { method: row.method } : {}),
78
+ ...(typeof row?.assertion === 'string' ? { assertion: row.assertion } : {}),
79
+ ...(shortfall &&
80
+ typeof shortfall.required === 'string' &&
81
+ typeof shortfall.provided === 'string'
82
+ ? { shortfall: { required: shortfall.required, provided: shortfall.provided } }
83
+ : {}),
84
+ };
85
+ const warnings = [];
86
+ if (!principal) {
87
+ warnings.push({
88
+ code: 'ATTRIBUTION_NOT_IN_RECEIPT',
89
+ message: 'The server receipt does not name who this is attributed to; nothing is inferred locally.',
90
+ });
91
+ }
92
+ if (evidence.shortfall) {
93
+ warnings.push({
94
+ code: 'EVIDENCE_BELOW_DECLARED_BAR',
95
+ message: `Settled below the evidence bar the Expectation declares: vouched at ` +
96
+ `${evidence.shortfall.provided}, asked for ${evidence.shortfall.required}.`,
97
+ });
98
+ }
99
+ return {
100
+ recorded: true,
101
+ replayed: receipt?.idempotent === true,
102
+ attributedTo: attributedToOf(principal),
103
+ evidence,
104
+ warnings,
105
+ };
106
+ }
107
+ /**
108
+ * `the signed-in account (person u-1, via CLI credential)`, `Agent agent_x`, … A person whose CLI
109
+ * declared a tool reads `(person u-1, via CLI credential · declared: Claude Code)`: the same
110
+ * phrase every surface uses (`principalChannelPhrase`), which marks the tool as declared.
111
+ */
112
+ function describeAttributedTo(attributedTo) {
113
+ const { kind, id, via, declaredTool } = attributedTo;
114
+ if (kind === 'person') {
115
+ const detail = [
116
+ id ? `person ${id}` : 'person',
117
+ (0, data_provider_1.principalChannelPhrase)({ kind: 'human', via, declaredTool }),
118
+ ]
119
+ .filter(Boolean)
120
+ .join(', ');
121
+ return `the signed-in account (${detail})`;
122
+ }
123
+ if (kind === 'agent')
124
+ return id ? `Agent ${id}` : 'an Agent';
125
+ if (kind === 'system')
126
+ return id ? `the system (${id})` : 'the system';
127
+ if (kind === 'integration')
128
+ return id ? `the ${id} integration` : 'an integration';
129
+ return 'nobody the receipt names';
130
+ }
131
+ /**
132
+ * The lines a write prints. The first is the outcome: `<Verb> <what> — attributed to <whom>.`, or,
133
+ * for an idempotent replay, that the same record already existed and nothing new was written.
134
+ * When the server returned the evidence level it computed, `Evidence level: <level>.` comes next.
135
+ * Warnings follow, one line each. Nothing after a success reads like a refusal.
136
+ */
137
+ function taskWriteOutcomeLines({ verb, what }, outcome) {
138
+ const done = outcome.replayed
139
+ ? `Already ${verb.toLowerCase()} ${what} by an earlier identical request; nothing new was written`
140
+ : `${verb} ${what}`;
141
+ const first = outcome.attributedTo.kind === 'unattributed'
142
+ ? `${done}. The server receipt does not name who it is attributed to; nothing is inferred locally.`
143
+ : `${done} — attributed to ${describeAttributedTo(outcome.attributedTo)}.`;
144
+ const level = outcome.evidence.level ? [`Evidence level: ${outcome.evidence.level}.`] : [];
145
+ const rest = outcome.warnings
146
+ .filter((warning) => warning.code !== 'ATTRIBUTION_NOT_IN_RECEIPT')
147
+ .map((warning) => warning.message);
148
+ return [first, ...level, ...rest];
149
+ }
150
+ /**
151
+ * The `attribution` field `--json` carried before `attributedTo` existed, kept so a reader of
152
+ * `attribution.principal` keeps working. The principal exactly as the server recorded it.
153
+ */
154
+ function receiptAttribution(receipt, record) {
155
+ const row = objectAt(receipt, record);
156
+ return {
157
+ source: 'server_receipt',
158
+ principal: principalOf(row, exports.TASK_WRITE_RECORDS[record]),
159
+ ...(typeof row?.method === 'string' ? { method: row.method } : {}),
160
+ };
161
+ }
162
+ /** The `--confirm-as-me` flag, one definition for every command that records a judgement. */
163
+ exports.confirmAsMeFlag = core_1.Flags.boolean({
164
+ description: "Record this judgement as the signed-in person's. Required from a coding-agent shell the " +
165
+ 'person started by hand (Claude Code, Codex), where the write is attributed to the person, ' +
166
+ 'not the agent; pass it only when the person asked for the judgement to be theirs.',
167
+ });
168
+ /**
169
+ * The refusal, or null, for a judgement about to be written. Null unless this is a hand-started
170
+ * coding-agent shell and `--confirm-as-me` was not given. Decided before any network call, so a
171
+ * refusal has written nothing. `command` is read only to rebuild the command line for the refusal.
172
+ */
173
+ function personJudgementGate(command, { confirmed, judgement, task, env = process.env, }) {
174
+ if (confirmed)
175
+ return null;
176
+ const codingAgent = handStartedCodingAgent(env);
177
+ if (!codingAgent)
178
+ return null;
179
+ const bin = command.config?.bin || 'skrr';
180
+ const words = (command.id || '').split(':').filter(Boolean).join(' ');
181
+ const typed = (command.argv || []).map(shellArg).join(' ');
182
+ const rerun = [bin, words, typed || '…', '--confirm-as-me'].filter(Boolean).join(' ');
183
+ return personConfirmationRefusal({ codingAgent, judgement, rerun, bin, task });
184
+ }
185
+ /**
186
+ * The coding agent this `skrr` runs inside, when it was started by hand there.
187
+ *
188
+ * Returns the tool key (`claude-code`, `codex`, …) only for a process the daemon did NOT start: a
189
+ * daemon-started session carries its own Agent runtime, and its Task writes are the Agent's. For a
190
+ * hand-started one the CLI login is the person's, so every Task write is attributed to the person.
191
+ * The key comes from the tool's own environment marker; a hint for wording and defaults, never
192
+ * evidence of anything, and its absence proves nothing either.
193
+ */
194
+ function handStartedCodingAgent(env = process.env) {
195
+ if ((0, harness_context_1.isHarnessCliContext)(env))
196
+ return null;
197
+ return (0, runtime_context_1.detectExternalTool)(env);
198
+ }
199
+ /**
200
+ * What a person's Task write declares about the shell it runs in: `{ source: { externalTool } }`
201
+ * when `handStartedCodingAgent` found a coding agent the person started by hand, `{}` otherwise.
202
+ *
203
+ * The same field, on the same body key, that a direct message sends (`buildCliSourceMetadata`,
204
+ * `source.externalTool`), and only the field: nothing is sent that was not detected. The server
205
+ * stores it beside the person as `declaredTool` and every surface shows it marked as declared.
206
+ * The marker comes from the person's own tool, so it is the client's word: displayed, never
207
+ * trusted, and never part of who the write is attributed to (owner decision 2026-11-12, OSK-24355).
208
+ * A daemon-started session sends nothing; its writes are its Agent's, proven by its Run.
209
+ */
210
+ function declaredToolSource(env = process.env) {
211
+ const externalTool = handStartedCodingAgent(env);
212
+ return externalTool ? { source: { externalTool } } : {};
213
+ }
214
+ exports.PERSON_CONFIRMATION_REQUIRED = 'PERSON_CONFIRMATION_REQUIRED';
9
215
  /**
10
- * An unbound shell is normal for a person starting the CLI by hand. The useful
11
- * answer is not an invitation to forge an environment variable; it is the
12
- * smallest truthful route to learn which local engines are registered, choose
13
- * a local Code identity, or enter an assigned task's authenticated runtime.
216
+ * The refusal a judgement gets from a hand-started coding-agent shell without `--confirm-as-me`.
217
+ *
218
+ * Nothing has been written when this is returned. It names the two truthful ways on: the person
219
+ * asked for it to be theirs (re-run with the flag), or the agent records what it checked as a
220
+ * `verification` Update and leaves the judgement to the person. `tasks start` is NOT offered: it
221
+ * hands the Task to its assigned Agent in a NEW session, so suggesting it to an agent already doing
222
+ * the work would start a second worker rather than attribute this one.
223
+ */
224
+ function personConfirmationRefusal({ codingAgent, judgement, rerun, bin, task, }) {
225
+ const verification = `${bin} tasks updates add ${task} --type verification --summary "<what you checked>" ` +
226
+ `--data '{"claim":"<claim>","result":"passed","evidenceRefs":[]}'`;
227
+ return {
228
+ code: exports.PERSON_CONFIRMATION_REQUIRED,
229
+ message: [
230
+ `Nothing was recorded. This shell runs inside ${codingAgent}, and ${judgement} would be ` +
231
+ `stored as the signed-in person's judgement, not the agent's.`,
232
+ `→ If the person asked for it to be recorded as theirs: ${rerun}`,
233
+ `→ Otherwise record what you checked and leave the judgement to them: ${verification}`,
234
+ ].join('\n'),
235
+ details: {
236
+ codingAgent,
237
+ attributedTo: 'person',
238
+ written: false,
239
+ nextSteps: [
240
+ {
241
+ kind: 'confirm_as_person',
242
+ command: rerun,
243
+ description: 'Only when the person asked for this judgement to be recorded as theirs. It is recorded as the person, with the credential channel it came through.',
244
+ },
245
+ {
246
+ kind: 'record_verification',
247
+ command: verification,
248
+ description: 'Record what was checked, with its evidence, as an Update, and leave the judgement to the person.',
249
+ },
250
+ ],
251
+ },
252
+ };
253
+ }
254
+ /** Quote one argument for a copy-pasteable command line, only when it needs it. */
255
+ function shellArg(value) {
256
+ return /^[A-Za-z0-9_./:@%+=,-]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
257
+ }
258
+ /**
259
+ * An unbound shell is normal for a person starting the CLI by hand. The useful answer is not an
260
+ * invitation to forge an environment variable; it is the smallest truthful route to learn which
261
+ * local engines are registered, choose a local Code identity, or hand an assigned Task to its
262
+ * Agent's own runtime.
14
263
  */
15
264
  function unboundRuntimeSetup(bin = 'skrr') {
16
265
  return [
@@ -27,46 +276,28 @@ function unboundRuntimeSetup(bin = 'skrr') {
27
276
  {
28
277
  kind: 'start_assigned_task',
29
278
  command: `${bin} tasks start <task>`,
30
- description: 'For an assigned Task, enter its authenticated Agent runtime and execute that Task.',
279
+ description: "Hand an assigned Task to its Agent, which runs it in a new session in its own authenticated runtime; that session's Task writes are recorded as the Agent.",
31
280
  },
32
281
  ];
33
282
  }
283
+ /**
284
+ * What `skrr context` says in a shell with no Agent runtime. A statement of how writes are
285
+ * recorded, not a refusal: nothing here stops a write.
286
+ */
34
287
  function agentBindingGuidance(bin = 'skrr') {
35
288
  const [harnesses, codeAgent, task] = unboundRuntimeSetup(bin);
36
- return (`This shell is not an authenticated Agent runtime. Inspect registered local engines with \`${harnesses.command}\`; ` +
37
- `inspect the local managed Code identity with \`${codeAgent.command}\`; and for an assigned Task, start it with \`${task.command}\`. ` +
38
- 'An --agent flag or an environment Agent id cannot establish authenticated authorship.');
289
+ return ('Task writes from this shell are recorded as the signed-in account. An Agent is recorded as ' +
290
+ `the author only from its own authenticated runtime: \`${task.command}\` hands an assigned Task ` +
291
+ 'to its Agent in a new session. `--agent` and Agent id variables choose which Agent speaks; ' +
292
+ 'they do not change who a Task write is recorded as. ' +
293
+ `Inspect registered local engines with \`${harnesses.command}\` and the local managed Code ` +
294
+ `identity with \`${codeAgent.command}\`.`);
39
295
  }
40
296
  /** Compatibility for receipts and surfaces that do not know the invoked bin name. */
41
297
  exports.AGENT_BINDING_GUIDANCE = agentBindingGuidance();
42
- exports.ACCOUNT_ATTRIBUTION_NOTICE = 'Without authenticated Agent provenance, Task writes are attributed to the signed-in account. ' +
43
- 'An account-attributed assessment is not proof of an independent human check.';
44
- /** Use the persisted server receipt, never the process's claimed Agent identity. */
45
- function taskWriteAttribution(receipt, field) {
46
- const record = receipt && typeof receipt === 'object' ? receipt : {};
47
- const entity = record[field === 'assessedBy' ? 'assessment' : 'result'];
48
- const row = entity && typeof entity === 'object' ? entity : {};
49
- const value = row[field];
50
- const principal = value && typeof value === 'object' && typeof value.kind === 'string'
51
- ? value : null;
52
- return {
53
- source: 'server_receipt',
54
- principal,
55
- ...(typeof row.method === 'string' ? { method: row.method } : {}),
56
- notice: principal?.kind === 'human' ? exports.ACCOUNT_ATTRIBUTION_NOTICE
57
- : !principal ? 'The server receipt did not identify the author; no authorship is inferred from local runtime hints.' : null,
58
- ...(!principal || principal.kind === 'human' ? { bindingGuidance: exports.AGENT_BINDING_GUIDANCE } : {}),
59
- };
60
- }
61
- function attributionLines(attribution) {
62
- const actor = attribution.principal;
63
- return [
64
- actor ? `Recorded author: ${actor.kind} (${actor.userId || actor.agentId || actor.service || 'id unavailable'}).`
65
- : 'Recorded author: unavailable in server receipt.',
66
- ...(attribution.notice ? [attribution.notice] : []),
67
- ...(attribution.bindingGuidance ? [attribution.bindingGuidance] : []),
68
- ];
69
- }
298
+ exports.ACCOUNT_ATTRIBUTION_NOTICE = 'Without authenticated Agent provenance, Task writes are attributed to the signed-in account, ' +
299
+ 'with the credential channel they came through. An account-attributed assessment is not proof ' +
300
+ 'of an independent human check.';
70
301
  /** Environment hints explain local execution only; the server verifies every write. */
71
302
  function runtimeWriteAttribution(runtime) {
72
303
  return {
@@ -32,6 +32,8 @@ export declare function stampRequest<E>(err: E, method: string, url: unknown): E
32
32
  export declare function isKnownWrite(request: FailedRequest | undefined): request is FailedRequest;
33
33
  /** Does the server keep a replay receipt for this request? False unless the registry says so. */
34
34
  export declare function requestHasReceipt(request: FailedRequest | undefined): boolean;
35
+ /** Automatic replay requires the same request key and a server-declared receipt. */
36
+ export declare function isRequestReplaySafe(method: string, url: string | undefined, headers?: Record<string, unknown>): boolean;
35
37
  /**
36
38
  * Did the request provably never leave this machine? A refused connection or a failed name lookup sends no bytes, so
37
39
  * "nothing happened" is a fact there, not a guess. A timeout or a reset is not: the server may have read the request.
@@ -6,6 +6,7 @@ exports.requestOfError = requestOfError;
6
6
  exports.stampRequest = stampRequest;
7
7
  exports.isKnownWrite = isKnownWrite;
8
8
  exports.requestHasReceipt = requestHasReceipt;
9
+ exports.isRequestReplaySafe = isRequestReplaySafe;
9
10
  exports.requestNeverSent = requestNeverSent;
10
11
  exports.classifyRequestOutcome = classifyRequestOutcome;
11
12
  exports.isAmbiguousStatus = isAmbiguousStatus;
@@ -77,6 +78,19 @@ function isKnownWrite(request) {
77
78
  function requestHasReceipt(request) {
78
79
  return (0, data_provider_1.routeHasReplayReceipt)(request?.method, request?.path);
79
80
  }
81
+ /** Automatic replay requires the same request key and a server-declared receipt. */
82
+ function isRequestReplaySafe(method, url, headers) {
83
+ if (READ_METHODS.includes(method.toUpperCase()))
84
+ return true;
85
+ const keys = Object.entries(headers ?? {}).filter(([name]) => name.toLowerCase() === 'x-idempotency-key');
86
+ const rawKey = keys.length === 1 ? keys[0][1] : undefined;
87
+ // Match api/server/utils/idempotencyKey.js. The server ignores invalid keys.
88
+ return (typeof rawKey === 'string' &&
89
+ rawKey.trim().length > 0 &&
90
+ rawKey.trim().length <= 200 &&
91
+ /^[A-Za-z0-9._:/-]+$/.test(rawKey.trim()) &&
92
+ requestHasReceipt({ method, path: url }));
93
+ }
80
94
  const NEVER_SENT_CODES = ['ECONNREFUSED', 'ENOTFOUND', 'EAI_AGAIN'];
81
95
  /**
82
96
  * Did the request provably never leave this machine? A refused connection or a failed name lookup sends no bytes, so
@@ -308,6 +308,68 @@ const TOOLS = [
308
308
  capability: "wire_chunking_v1"
309
309
  })
310
310
  ];
311
+ const LOCAL_SESSION = [
312
+ toDaemon("daemon:local-session-import:v1", "Browse, page, inspect and prove a prefix of the Codex and Claude Code sessions on this computer. Read-only; the single call the import catalog and history worker make.", {
313
+ delivery: "acked",
314
+ carriers: RPC,
315
+ stability: "experimental",
316
+ capability: "local_session_import_v1"
317
+ }),
318
+ toDaemon("daemon:local-claude-snapshot:v1", "Open, page and verify a bounded, connection-pinned read of one Claude Code session.", {
319
+ delivery: "acked",
320
+ carriers: RPC,
321
+ stability: "experimental",
322
+ capability: "local_session_claude_snapshot_v1"
323
+ }),
324
+ toDaemon("daemon:local-codex-snapshot:v1", "Open, page and verify a bounded, connection-pinned read of one Codex session.", {
325
+ delivery: "acked",
326
+ carriers: RPC,
327
+ stability: "experimental",
328
+ capability: "local_session_codex_snapshot_v1"
329
+ }),
330
+ toDaemon("daemon:local-codex-turn:v1", "Continue a Codex session in place: a one-shot delivery claimed from the server and journaled before the provider starts. No daemon announces its capability yet.", {
331
+ delivery: "acked",
332
+ carriers: RPC,
333
+ stability: "experimental",
334
+ capability: "local_session_native_turn_v1"
335
+ }),
336
+ toDaemon("daemon:local-claude-turn:v1", "Continue a Claude Code session in place: a one-shot delivery claimed from the server and journaled before the provider starts. No daemon announces its capability yet.", {
337
+ delivery: "acked",
338
+ carriers: RPC,
339
+ stability: "experimental",
340
+ capability: "local_session_claude_native_turn_v1"
341
+ }),
342
+ toDaemon("daemon:local-session-stop:v1", "Ask the running native turn this daemon claimed to stop. Gated by the continuing capability of its provider.", {
343
+ delivery: "acked",
344
+ carriers: RPC,
345
+ stability: "experimental",
346
+ capability: "local_session_native_turn_v1"
347
+ }),
348
+ toDaemon("daemon:local-session-fork:v1", "Create an independent native copy of a session with the provider's own fork. No daemon announces its capability yet.", {
349
+ delivery: "acked",
350
+ carriers: RPC,
351
+ stability: "experimental",
352
+ capability: "local_session_fork_v1"
353
+ }),
354
+ toDaemon("daemon:local-session-fork-recovery:v1", "Read back, without creating anything, the receipt of a fork whose reply was lost.", {
355
+ delivery: "acked",
356
+ carriers: RPC,
357
+ stability: "experimental",
358
+ capability: "local_session_fork_v1"
359
+ }),
360
+ toDaemon("daemon:local-session-start:v1", "Start a new native session from a pending Chat, journaling the candidate before the first message. No daemon announces its capability yet.", {
361
+ delivery: "acked",
362
+ carriers: RPC,
363
+ stability: "experimental",
364
+ capability: "local_session_pending_start_v1"
365
+ }),
366
+ toDaemon("daemon:local-session-start-recovery:v1", "Read back what a first start left on this machine, so a lost reply is settled by evidence and never by a resend.", {
367
+ delivery: "acked",
368
+ carriers: RPC,
369
+ stability: "experimental",
370
+ capability: "local_session_start_recovery_v1"
371
+ })
372
+ ];
311
373
  const TERMINALS = [
312
374
  toDaemon("daemon:terminal:start", "Open a terminal (persistent when `persistent: true` and announced).", {
313
375
  delivery: "acked",
@@ -562,6 +624,7 @@ const DAEMON_WIRE = Object.freeze([
562
624
  ...CONNECTION,
563
625
  ...RPC_ENVELOPE,
564
626
  ...RPC_METHODS,
627
+ ...LOCAL_SESSION,
565
628
  ...SESSIONS,
566
629
  ...TOOLS,
567
630
  ...TERMINALS,
@@ -353,6 +353,76 @@ const TOOLS = [
353
353
  }),
354
354
  ];
355
355
  // ---------------------------------------------------------------------------
356
+ // Local session import (Codex and Claude Code sessions on a person's own machine)
357
+ // ---------------------------------------------------------------------------
358
+ // Every method here is an `rpc:request` method the API calls and the daemon answers (`daemon/src/
359
+ // local-session-import/host.ts`), `experimental` until the feature has shipped, and unvalidated: the
360
+ // daemon validates each payload by hand against the owner and machine it was claimed for, and the
361
+ // shape is still allowed to move. The server refuses to call one the daemon did not announce, and
362
+ // a daemon announces nothing for continuing or forking a session yet.
363
+ const LOCAL_SESSION = [
364
+ toDaemon('daemon:local-session-import:v1', 'Browse, page, inspect and prove a prefix of the Codex and Claude Code sessions on this computer. Read-only; the single call the import catalog and history worker make.', {
365
+ delivery: 'acked',
366
+ carriers: RPC,
367
+ stability: 'experimental',
368
+ capability: 'local_session_import_v1',
369
+ }),
370
+ toDaemon('daemon:local-claude-snapshot:v1', 'Open, page and verify a bounded, connection-pinned read of one Claude Code session.', {
371
+ delivery: 'acked',
372
+ carriers: RPC,
373
+ stability: 'experimental',
374
+ capability: 'local_session_claude_snapshot_v1',
375
+ }),
376
+ toDaemon('daemon:local-codex-snapshot:v1', 'Open, page and verify a bounded, connection-pinned read of one Codex session.', {
377
+ delivery: 'acked',
378
+ carriers: RPC,
379
+ stability: 'experimental',
380
+ capability: 'local_session_codex_snapshot_v1',
381
+ }),
382
+ toDaemon('daemon:local-codex-turn:v1', 'Continue a Codex session in place: a one-shot delivery claimed from the server and journaled before the provider starts. No daemon announces its capability yet.', {
383
+ delivery: 'acked',
384
+ carriers: RPC,
385
+ stability: 'experimental',
386
+ capability: 'local_session_native_turn_v1',
387
+ }),
388
+ toDaemon('daemon:local-claude-turn:v1', 'Continue a Claude Code session in place: a one-shot delivery claimed from the server and journaled before the provider starts. No daemon announces its capability yet.', {
389
+ delivery: 'acked',
390
+ carriers: RPC,
391
+ stability: 'experimental',
392
+ capability: 'local_session_claude_native_turn_v1',
393
+ }),
394
+ toDaemon('daemon:local-session-stop:v1', 'Ask the running native turn this daemon claimed to stop. Gated by the continuing capability of its provider.', {
395
+ delivery: 'acked',
396
+ carriers: RPC,
397
+ stability: 'experimental',
398
+ capability: 'local_session_native_turn_v1',
399
+ }),
400
+ toDaemon('daemon:local-session-fork:v1', "Create an independent native copy of a session with the provider's own fork. No daemon announces its capability yet.", {
401
+ delivery: 'acked',
402
+ carriers: RPC,
403
+ stability: 'experimental',
404
+ capability: 'local_session_fork_v1',
405
+ }),
406
+ toDaemon('daemon:local-session-fork-recovery:v1', 'Read back, without creating anything, the receipt of a fork whose reply was lost.', {
407
+ delivery: 'acked',
408
+ carriers: RPC,
409
+ stability: 'experimental',
410
+ capability: 'local_session_fork_v1',
411
+ }),
412
+ toDaemon('daemon:local-session-start:v1', 'Start a new native session from a pending Chat, journaling the candidate before the first message. No daemon announces its capability yet.', {
413
+ delivery: 'acked',
414
+ carriers: RPC,
415
+ stability: 'experimental',
416
+ capability: 'local_session_pending_start_v1',
417
+ }),
418
+ toDaemon('daemon:local-session-start-recovery:v1', 'Read back what a first start left on this machine, so a lost reply is settled by evidence and never by a resend.', {
419
+ delivery: 'acked',
420
+ carriers: RPC,
421
+ stability: 'experimental',
422
+ capability: 'local_session_start_recovery_v1',
423
+ }),
424
+ ];
425
+ // ---------------------------------------------------------------------------
356
426
  // Terminals
357
427
  // ---------------------------------------------------------------------------
358
428
  const TERMINALS = [
@@ -635,6 +705,7 @@ export const DAEMON_WIRE = Object.freeze([
635
705
  ...CONNECTION,
636
706
  ...RPC_ENVELOPE,
637
707
  ...RPC_METHODS,
708
+ ...LOCAL_SESSION,
638
709
  ...SESSIONS,
639
710
  ...TOOLS,
640
711
  ...TERMINALS,