@skrr-ai/cli 0.1.166 → 0.1.168
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-command.js +0 -1
- package/dist/commands/activity/scan-older.d.ts +1 -1
- package/dist/commands/activity/scan-older.js +5 -4
- package/dist/commands/agent/message/approve.d.ts +1 -0
- package/dist/commands/agent/message/approve.js +6 -2
- package/dist/commands/agent/message/decline.d.ts +1 -0
- package/dist/commands/agent/message/decline.js +6 -2
- package/dist/commands/agent/message/pending.js +5 -2
- package/dist/commands/agent/message/review.d.ts +13 -0
- package/dist/commands/agent/message/review.js +68 -0
- package/dist/commands/agents/always-on/recovery-close.d.ts +28 -0
- package/dist/commands/agents/always-on/recovery-close.js +60 -0
- package/dist/commands/agents/always-on/recovery-review.d.ts +22 -0
- package/dist/commands/agents/always-on/recovery-review.js +190 -0
- package/dist/commands/apps/installations/compatibility.js +1 -1
- package/dist/commands/apps/installations/list.js +3 -0
- package/dist/commands/apps/installations/show.js +3 -0
- package/dist/commands/duties/show.js +10 -0
- package/dist/commands/goals/key-results/assess.d.ts +2 -3
- package/dist/commands/goals/key-results/assess.js +5 -12
- package/dist/commands/harnesses/removal-references.d.ts +16 -0
- package/dist/commands/harnesses/removal-references.js +61 -0
- package/dist/commands/tasks/actionability.js +8 -3
- package/dist/commands/tasks/complete.js +35 -17
- package/dist/commands/tasks/expectations/assess.d.ts +1 -0
- package/dist/commands/tasks/expectations/assess.js +50 -21
- package/dist/commands/tasks/expectations.js +5 -2
- package/dist/commands/tasks/judge.d.ts +1 -0
- package/dist/commands/tasks/judge.js +17 -2
- package/dist/commands/tasks/result/submit.js +26 -17
- package/dist/commands/tasks/review-queue.js +2 -1
- package/dist/commands/tasks/review.d.ts +1 -0
- package/dist/commands/tasks/review.js +24 -3
- package/dist/commands/tasks/show.d.ts +13 -0
- package/dist/commands/tasks/show.js +41 -3
- package/dist/commands/tasks/updates/add.d.ts +1 -0
- package/dist/commands/tasks/updates/add.js +71 -21
- package/dist/commands/tasks/updates/list.d.ts +4 -0
- package/dist/commands/tasks/updates/list.js +3 -1
- package/dist/commands/tasks/waive.d.ts +1 -0
- package/dist/commands/tasks/waive.js +17 -2
- package/dist/generated/agent-guides.json +20 -20
- package/dist/lib/agent-activity.d.ts +3 -1
- package/dist/lib/agent-activity.js +50 -11
- package/dist/lib/appInstallations.js +1 -1
- package/dist/lib/harnesses.d.ts +24 -0
- package/dist/lib/harnesses.js +4 -0
- package/dist/lib/reference-syntax.d.ts +28 -0
- package/dist/lib/reference-syntax.js +91 -0
- package/dist/lib/runtime-context.js +6 -0
- package/dist/lib/task-closure.d.ts +1 -1
- package/dist/lib/task-closure.js +1 -1
- package/dist/lib/task-operations.d.ts +28 -6
- package/dist/lib/task-operations.js +77 -4
- package/dist/lib/task-preflight.js +8 -3
- package/dist/lib/task-write-attribution.d.ts +183 -19
- package/dist/lib/task-write-attribution.js +270 -39
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.js +63 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.js +71 -0
- package/dist/node_modules/@skrr-ai/data-provider/index.js +11416 -11290
- package/oclif.manifest.json +395 -16
- package/package.json +2 -2
|
@@ -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
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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";
|
|
@@ -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
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
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:
|
|
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 (
|
|
37
|
-
`
|
|
38
|
-
'
|
|
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
|
|
44
|
-
|
|
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 {
|
|
@@ -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,
|