agent-bios 0.19.4 → 0.20.1
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/DEPENDENCIES.md +20 -5
- package/README.md +14 -19
- package/claude/agents/frontier.md +1 -1
- package/claude/guides/claude-prompting.md +475 -234
- package/claude/guides/cli-multi-model-workflow.md +8 -7
- package/claude/guides/gpt-prompting.md +319 -144
- package/claude/guides/session-distill-workflow.md +93 -43
- package/claude/guides/tooling-gotchas.md +3 -1
- package/codex/agents/frontier.toml +1 -1
- package/codex/agents/reviewer.toml +1 -1
- package/codex/agents/workhorse.toml +1 -1
- package/codex/guides/claude-prompting.md +475 -234
- package/codex/guides/cli-multi-model-workflow.md +8 -7
- package/codex/guides/gpt-prompting.md +319 -144
- package/codex/guides/session-distill-workflow.md +93 -43
- package/codex/guides/tooling-gotchas.md +3 -1
- package/compose/assemble.py +4 -1
- package/compose/canary.sh +8 -6
- package/compose/host_platform.py +158 -15
- package/compose/instructions-state.py +183 -41
- package/compose/instructions_install.py +222 -27
- package/compose/instructions_session.py +250 -75
- package/compose/instructions_setup_cli.py +2 -36
- package/compose/instructions_store.py +160 -3
- package/compose/instructions_transaction.py +29 -5
- package/docs/advanced-launch.md +5 -1
- package/docs/releases/0.20.0.md +102 -0
- package/docs/releases/0.20.1.md +76 -0
- package/install.sh +42 -14
- package/launch/agent-launch.py +152 -18
- package/launch/agent-launch.toml +28 -16
- package/launch/agent-launch.zsh +104 -13
- package/launch/claude_subcommands.py +179 -0
- package/launch/shell_integration.py +7 -1
- package/learn/collect-learning.py +60 -9
- package/learn/migrate-learnings.py +70 -4
- package/learn/redact.py +2 -1
- package/package.json +36 -3
- package/provenance.json +1 -1
- package/session-cost.py +80 -9
- package/session-distill/coverage.json +6 -0
- package/session-distill/distill.py +2575 -0
- package/session-distill/grammar/__init__.py +0 -0
- package/session-distill/grammar/owner_lines.py +874 -0
- package/session-distill/originators.json +9 -0
- package/session-distill/packets/cross_review.md +31 -0
- package/session-distill/packets/form.md +86 -0
- package/session-distill/packets/judge.md +81 -0
- package/session-distill/packets/placement_contract.md +90 -0
- package/session-distill/packets/propose.md +124 -0
- package/session-distill/packets/read.md +57 -0
- package/session-distill/packets/reconsider.md +53 -0
- package/session-distill/packets/s7b.md +65 -0
- package/session-distill/packets/s9b.md +39 -0
- package/session-distill/packets/stitch.md +35 -0
- package/session-distill/packets/sweep.md +33 -0
- package/session-distill/runlib/__init__.py +0 -0
- package/session-distill/runlib/bound.py +1102 -0
- package/session-distill/runlib/breaker.py +467 -0
- package/session-distill/runlib/census.py +2347 -0
- package/session-distill/runlib/claims.py +420 -0
- package/session-distill/runlib/controls.py +902 -0
- package/session-distill/runlib/coverage.py +881 -0
- package/session-distill/runlib/declare.py +888 -0
- package/session-distill/runlib/delivery_evidence.py +1145 -0
- package/session-distill/runlib/derive.py +812 -0
- package/session-distill/runlib/destinations.py +3072 -0
- package/session-distill/runlib/dispatch.py +7940 -0
- package/session-distill/runlib/drift.py +1077 -0
- package/session-distill/runlib/entry.py +401 -0
- package/session-distill/runlib/evidence.py +890 -0
- package/session-distill/runlib/exposure.py +1162 -0
- package/session-distill/runlib/gate.py +2727 -0
- package/session-distill/runlib/gitread.py +79 -0
- package/session-distill/runlib/inventory.py +19624 -0
- package/session-distill/runlib/journal.py +1919 -0
- package/session-distill/runlib/ledger.py +3210 -0
- package/session-distill/runlib/ledger_compat.py +101 -0
- package/session-distill/runlib/ledger_migration.py +190 -0
- package/session-distill/runlib/lifecycle_intake.py +693 -0
- package/session-distill/runlib/lineage.py +454 -0
- package/session-distill/runlib/measures.py +249 -0
- package/session-distill/runlib/monitor.py +1180 -0
- package/session-distill/runlib/operations.py +522 -0
- package/session-distill/runlib/packet.py +838 -0
- package/session-distill/runlib/placement.py +1769 -0
- package/session-distill/runlib/projection.py +4090 -0
- package/session-distill/runlib/ranking.py +740 -0
- package/session-distill/runlib/receipts.py +200 -0
- package/session-distill/runlib/records.py +1965 -0
- package/session-distill/runlib/search.py +249 -0
- package/session-distill/runlib/sequencing.py +829 -0
- package/session-distill/runlib/sources.py +641 -0
- package/session-distill/runlib/stage_adjudicate.py +845 -0
- package/session-distill/runlib/stage_apply.py +1378 -0
- package/session-distill/runlib/stage_approvals.py +758 -0
- package/session-distill/runlib/stage_close.py +1220 -0
- package/session-distill/runlib/stage_confirm.py +929 -0
- package/session-distill/runlib/stage_delivery.py +3080 -0
- package/session-distill/runlib/stage_form.py +2576 -0
- package/session-distill/runlib/stage_judge.py +4248 -0
- package/session-distill/runlib/stage_propose.py +3307 -0
- package/session-distill/runlib/stage_read.py +5179 -0
- package/session-distill/runlib/stage_render.py +2739 -0
- package/session-distill/runlib/stage_retrieve.py +924 -0
- package/session-distill/runlib/stage_review_korean.py +1002 -0
- package/session-distill/runlib/stage_review_proposals.py +1292 -0
- package/session-distill/runlib/stagelock.py +412 -0
- package/session-distill/runlib/stop.py +1061 -0
- package/session-distill/runlib/targets.py +809 -0
- package/session-distill/runlib/usage.py +280 -0
- package/session-distill/runlib/validate.py +319 -0
- package/session-distill/runlib/views.py +4327 -0
- package/session-distill/schemas/adjudication.schema.json +35 -0
- package/session-distill/schemas/approval.schema.json +35 -0
- package/session-distill/schemas/census.schema.json +128 -0
- package/session-distill/schemas/checks.schema.json +207 -0
- package/session-distill/schemas/claim.schema.json +16 -0
- package/session-distill/schemas/confirmation.schema.json +24 -0
- package/session-distill/schemas/coverage.schema.json +66 -0
- package/session-distill/schemas/cross_review.schema.json +24 -0
- package/session-distill/schemas/event.schema.json +20 -0
- package/session-distill/schemas/evidence.schema.json +20 -0
- package/session-distill/schemas/expected_observation.schema.json +18 -0
- package/session-distill/schemas/form.schema.json +103 -0
- package/session-distill/schemas/intake.schema.json +71 -0
- package/session-distill/schemas/inventory.schema.json +872 -0
- package/session-distill/schemas/judge.schema.json +77 -0
- package/session-distill/schemas/ledger.schema.json +313 -0
- package/session-distill/schemas/observation.schema.json +16 -0
- package/session-distill/schemas/propose.schema.json +555 -0
- package/session-distill/schemas/read.schema.json +76 -0
- package/session-distill/schemas/reconsider.schema.json +122 -0
- package/session-distill/schemas/run.schema.json +150 -0
- package/session-distill/schemas/s7b.schema.json +200 -0
- package/session-distill/schemas/s9b.schema.json +28 -0
- package/session-distill/schemas/stitch.schema.json +25 -0
- package/session-distill/schemas/sweep.schema.json +25 -0
- package/session-distill/seats.json +149 -0
- package/session-distill/tables/allowed_pairs.json +257 -0
- package/session-distill/tables/controls.json +30 -0
- package/session-distill/tables/delivery_evidence.json +36 -0
- package/session-distill/tables/delivery_evidence_fixtures.json +731 -0
- package/session-distill/tables/destinations.json +684 -0
- package/session-distill/tables/drift_layers.json +68 -0
- package/session-distill/tables/exposure_rules.json +192 -0
- package/session-distill/tables/placement_rules.json +148 -0
- package/session-distill/tables/propose_fixtures.json +154 -0
- package/session-distill/tables/ranking.json +194 -0
- package/session-distill/tables/redundancy.json +10 -0
- package/session-distill/tables/structural_rules.json +44 -0
- package/session-distill/tables/transition_fixtures.json +398 -0
- package/session-distill/tables/transitions.json +69 -0
- package/session-distill/tables/unit_outcome.json +67 -0
- package/session-distill/tables/unit_outcome_fixtures.json +2364 -0
- package/wrappers/claude-run.sh +481 -33
- package/wrappers/claude_hermetic_evidence.py +1423 -0
- package/wrappers/codex-helm.sh +46 -15
- package/wrappers/codex-run.sh +183 -20
- package/wrappers/codex_frame_filter.py +1199 -0
- package/wrappers/codex_protocol.py +737 -0
- package/wrappers/jsonl_lines.py +65 -0
package/wrappers/claude-run.sh
CHANGED
|
@@ -24,19 +24,76 @@
|
|
|
24
24
|
# hash of the bytes the tool returned, and the seat it actually sent. Unset, it
|
|
25
25
|
# behaves exactly as it would without this block and writes nothing.
|
|
26
26
|
#
|
|
27
|
-
#
|
|
27
|
+
# Profiles (instruction/config reach), the vocabulary codex-run uses:
|
|
28
|
+
# inherit (default) the caller's HOME and CLAUDE_CONFIG_DIR: the owner's CLAUDE.md files,
|
|
29
|
+
# skills, settings and memory all load. The argv is the one this adapter
|
|
30
|
+
# has always sent.
|
|
31
|
+
# hermetic one call in a cell — a fresh HOME, CLAUDE_CONFIG_DIR and working
|
|
32
|
+
# directory, under a root outside the caller's HOME — with an environment
|
|
33
|
+
# built from scratch, the subscription token in the child environment only,
|
|
34
|
+
# and `--safe-mode --setting-sources "" --strict-mcp-config
|
|
35
|
+
# --disable-slash-commands --tools ""`: no CLAUDE.md from the working
|
|
36
|
+
# directory, its ancestors or the configuration home, no skill, no memory,
|
|
37
|
+
# no MCP server, no hook. The session is persisted, because its transcript
|
|
38
|
+
# is the only record of what the host loaded, and
|
|
39
|
+
# claude_hermetic_evidence.py (beside this file, never looked up anywhere
|
|
40
|
+
# else) renders it into REVIEW_CAPTURE_DIR/host.json. Declared instructions
|
|
41
|
+
# reach the call only through --append-system-prompt-file with the sha256
|
|
42
|
+
# they were declared at. `--use producing` grants Read alone, confined to
|
|
43
|
+
# the --manifest directory by a path-scoped allow rule.
|
|
44
|
+
#
|
|
45
|
+
# Verified against claude 2.1.221 (inherit). The hermetic flag set is verified per host version by
|
|
46
|
+
# the author-side re-pin, on the version session-distill/seats.json pins.
|
|
28
47
|
set -euo pipefail
|
|
29
48
|
|
|
30
49
|
usage() {
|
|
31
50
|
cat <<'USAGE'
|
|
32
|
-
Usage: claude-run.sh [--
|
|
33
|
-
[--
|
|
51
|
+
Usage: claude-run.sh [--profile inherit|hermetic] [--model M --effort E]
|
|
52
|
+
[--permission-mode MODE] [--cd DIR] [--schema FILE]
|
|
53
|
+
[--max-output-tokens N] [-- ARG ...] < packet
|
|
54
|
+
claude-run.sh --profile hermetic --call-id ID (--cell-root DIR | DISTILL_CELL)
|
|
55
|
+
--claude-bin PATH --host-version V
|
|
56
|
+
[--use judge|producing|authoring] [--tools Read --manifest DIR]
|
|
57
|
+
[--append-system-prompt-file F --declared-sha256 H]... ... < packet
|
|
58
|
+
--profile instruction/config reach (default: inherit)
|
|
59
|
+
inherit the caller's HOME and CLAUDE_CONFIG_DIR, everything they load
|
|
60
|
+
hermetic a fresh cell per call: no CLAUDE.md, skill, memory, MCP server or
|
|
61
|
+
hook of the caller's, the token in the child environment only
|
|
34
62
|
--model M model to pin (required for a receipt)
|
|
35
63
|
--effort E reasoning effort to pin (required for a receipt)
|
|
36
64
|
--permission-mode MODE
|
|
37
|
-
claude permission mode (default: the no-edit posture below)
|
|
38
|
-
--cd DIR working root
|
|
39
|
-
--
|
|
65
|
+
claude permission mode (default: the no-edit posture below; inherit only)
|
|
66
|
+
--cd DIR working root (hermetic default: the cell's own empty working directory)
|
|
67
|
+
--schema F --json-schema: the final result carries structured_output for this schema
|
|
68
|
+
--max-output-tokens N
|
|
69
|
+
CLAUDE_CODE_MAX_OUTPUT_TOKENS for the call; a longer answer ends max_tokens
|
|
70
|
+
--claude-bin PATH --host-version V
|
|
71
|
+
the versioned claude executable (never a symlink) and the version it must
|
|
72
|
+
report; a mismatch is refused as HOST_VERSION_MISMATCH (required by hermetic)
|
|
73
|
+
--call-id ID the call this dispatch serves; names the cell (hermetic)
|
|
74
|
+
--cell-root DIR
|
|
75
|
+
where the cell <DIR>/<ID>/{home,config,cwd} is made and, after the call,
|
|
76
|
+
deleted. It may not lie under the operator's home, must be the operator's
|
|
77
|
+
own with mode 700, and neither it nor an ancestor may hold CLAUDE.md,
|
|
78
|
+
CLAUDE.local.md, AGENTS.md, .claude/, .codex/, .mcp.json or a settings file
|
|
79
|
+
--use U judge (default) or authoring: no tools at all; producing: Read only
|
|
80
|
+
--tools Read --manifest DIR
|
|
81
|
+
the producing profile's one tool, allowed inside DIR and refused elsewhere
|
|
82
|
+
--append-system-prompt-file F --declared-sha256 H
|
|
83
|
+
a declared instruction file and the sha256 it was declared at (repeatable);
|
|
84
|
+
the capture records the sha256 of what was sent, so an edit after the
|
|
85
|
+
declaration is visible to the gate
|
|
86
|
+
--server-policy FILE
|
|
87
|
+
the run's server-policy record (what --server-policy-probe printed), stated in
|
|
88
|
+
the capture's and the receipt's hermeticity; without it the server-delivered
|
|
89
|
+
policy is recorded as unknown, never as clean (hermetic)
|
|
90
|
+
--server-policy-probe
|
|
91
|
+
make no call: run `claude doctor` once in the cell, with the call's environment
|
|
92
|
+
and stdin closed, and print as one JSON line the status of its "Managed
|
|
93
|
+
settings (remote):" line and the verdict (clean, not confirmed, unknown);
|
|
94
|
+
nothing else of its output is kept (hermetic)
|
|
95
|
+
-- everything after is passed to claude verbatim (expert override); under
|
|
96
|
+
hermetic it changes the recorded flag-set hash
|
|
40
97
|
|
|
41
98
|
If either seat pin is missing, dispatch continues with a warning and no receipt.
|
|
42
99
|
|
|
@@ -45,21 +102,104 @@ Environment (the adapter calling convention; all optional):
|
|
|
45
102
|
REVIEW_METHOD_ID the review method this dispatch serves
|
|
46
103
|
REVIEW_ORDERING_SEED, REVIEW_SWAP_GROUP
|
|
47
104
|
the orchestrator's panel controls, copied into the receipt
|
|
105
|
+
REVIEW_CAPTURE_DIR directory for the call's capture: stream.jsonl (hermetic, appended as
|
|
106
|
+
it arrives), host.json and actions.jsonl
|
|
107
|
+
DISTILL_CELL a cell {home,config,cwd} the caller made and deletes itself
|
|
108
|
+
DISTILL_CALL_ID the call id when --call-id is not given
|
|
109
|
+
CLAUDE_RUN_TOKEN_FILE
|
|
110
|
+
a file holding CLAUDE_CODE_OAUTH_TOKEN=...; read into the child
|
|
111
|
+
environment only (hermetic; otherwise CLAUDE_CODE_OAUTH_TOKEN is used)
|
|
112
|
+
|
|
113
|
+
A dispatcher calls one hermetic Claude call as (the arguments in brackets per call):
|
|
114
|
+
claude-run.sh --profile hermetic --model M --effort E --cell-root ROOT --call-id ID --cd CWD
|
|
115
|
+
--claude-bin VERSIONED_PATH --host-version V --max-output-tokens N [--schema F]
|
|
116
|
+
[--use producing --tools Read --manifest DIR] [--server-policy FILE]
|
|
117
|
+
with DISTILL_CELL (the cell it made under ROOT), REVIEW_CAPTURE_DIR and the token in the
|
|
118
|
+
environment; the packet on stdin; the result object on stdout; exit status mirrored.
|
|
119
|
+
Once per run, before the first such call, it asks for the server-policy record as
|
|
120
|
+
claude-run.sh --profile hermetic --server-policy-probe --cell-root ROOT --call-id ID
|
|
121
|
+
--claude-bin VERSIONED_PATH --host-version V
|
|
122
|
+
with DISTILL_CELL and the token in the environment, and hands the record to every call.
|
|
48
123
|
USAGE
|
|
49
124
|
}
|
|
50
125
|
|
|
126
|
+
# The profile decides what several claude flags mean here, so it is read before the rest.
|
|
127
|
+
profile=inherit
|
|
128
|
+
scan=("$@")
|
|
129
|
+
i=0
|
|
130
|
+
while [ "$i" -lt "${#scan[@]}" ]; do
|
|
131
|
+
case "${scan[$i]}" in
|
|
132
|
+
--) break ;;
|
|
133
|
+
--profile) profile="${scan[$((i + 1))]:-}"; i=$((i + 1)) ;;
|
|
134
|
+
--profile=*) profile="${scan[$i]#*=}" ;;
|
|
135
|
+
esac
|
|
136
|
+
i=$((i + 1))
|
|
137
|
+
done
|
|
138
|
+
case "$profile" in
|
|
139
|
+
inherit|hermetic) ;;
|
|
140
|
+
*) echo "claude-run: ADAPTER_ARGUMENT_INVALID --profile must be inherit|hermetic" >&2; exit 2 ;;
|
|
141
|
+
esac
|
|
142
|
+
|
|
51
143
|
model=""
|
|
52
144
|
effort=""
|
|
53
145
|
permission_mode=""
|
|
54
146
|
cd_dir=""
|
|
55
147
|
passthrough=()
|
|
148
|
+
call_id="${DISTILL_CALL_ID:-}"
|
|
149
|
+
cell_root=""
|
|
150
|
+
claude_bin=""
|
|
151
|
+
host_version=""
|
|
152
|
+
schema=""
|
|
153
|
+
max_output=""
|
|
154
|
+
use=""
|
|
155
|
+
tools=""
|
|
156
|
+
manifest=""
|
|
157
|
+
server_policy=""
|
|
158
|
+
server_policy_probe=0
|
|
159
|
+
append_files=()
|
|
160
|
+
append_declared=()
|
|
56
161
|
|
|
57
162
|
while [ $# -gt 0 ]; do
|
|
58
163
|
case "$1" in
|
|
164
|
+
--profile) shift 2 ;;
|
|
165
|
+
--profile=*) shift ;;
|
|
59
166
|
--model) model="${2:?--model needs a value}"; shift 2 ;;
|
|
60
167
|
--effort) effort="${2:?--effort needs a value}"; shift 2 ;;
|
|
61
168
|
--permission-mode) permission_mode="${2:?--permission-mode needs a value}"; shift 2 ;;
|
|
62
169
|
--cd) cd_dir="${2:?--cd needs a value}"; shift 2 ;;
|
|
170
|
+
# Not claude flags: before this adapter knew them they reached claude and failed there.
|
|
171
|
+
--call-id) call_id="${2:?--call-id needs a value}"; shift 2 ;;
|
|
172
|
+
--cell-root) cell_root="${2:?--cell-root needs a value}"; shift 2 ;;
|
|
173
|
+
--claude-bin) claude_bin="${2:?--claude-bin needs a value}"; shift 2 ;;
|
|
174
|
+
--host-version) host_version="${2:?--host-version needs a value}"; shift 2 ;;
|
|
175
|
+
--schema) schema="${2:?--schema needs a value}"; shift 2 ;;
|
|
176
|
+
--max-output-tokens) max_output="${2:?--max-output-tokens needs a value}"; shift 2 ;;
|
|
177
|
+
--use|--manifest|--declared-sha256|--server-policy)
|
|
178
|
+
if [ "$profile" != hermetic ]; then
|
|
179
|
+
echo "claude-run: ADAPTER_ARGUMENT_INVALID $1 applies only to --profile hermetic" >&2; exit 2
|
|
180
|
+
fi
|
|
181
|
+
case "$1" in
|
|
182
|
+
--use) use="${2:?--use needs a value}" ;;
|
|
183
|
+
--manifest) manifest="${2:?--manifest needs a value}" ;;
|
|
184
|
+
--declared-sha256) append_declared+=("${2:?--declared-sha256 needs a value}") ;;
|
|
185
|
+
--server-policy) server_policy="${2:?--server-policy needs a value}" ;;
|
|
186
|
+
esac
|
|
187
|
+
shift 2 ;;
|
|
188
|
+
--server-policy-probe)
|
|
189
|
+
if [ "$profile" != hermetic ]; then
|
|
190
|
+
echo "claude-run: ADAPTER_ARGUMENT_INVALID $1 applies only to --profile hermetic" >&2; exit 2
|
|
191
|
+
fi
|
|
192
|
+
server_policy_probe=1; shift ;;
|
|
193
|
+
# claude's own flags, which the hermetic profile owns: under inherit they are forwarded
|
|
194
|
+
# one token at a time, exactly as before the profile existed.
|
|
195
|
+
--tools|--append-system-prompt-file)
|
|
196
|
+
if [ "$profile" = hermetic ]; then
|
|
197
|
+
if [ "$1" = --tools ]; then tools="${2?--tools needs a value}"
|
|
198
|
+
else append_files+=("${2:?--append-system-prompt-file needs a value}"); fi
|
|
199
|
+
shift 2
|
|
200
|
+
else
|
|
201
|
+
passthrough+=("$1"); shift
|
|
202
|
+
fi ;;
|
|
63
203
|
--) shift; while [ $# -gt 0 ]; do passthrough+=("$1"); shift; done ;;
|
|
64
204
|
-p|--print) shift ;; # already implied; a caller carrying it over is not an error
|
|
65
205
|
-) shift ;;
|
|
@@ -72,7 +212,63 @@ while [ $# -gt 0 ]; do
|
|
|
72
212
|
esac
|
|
73
213
|
done
|
|
74
214
|
|
|
75
|
-
|
|
215
|
+
case "$max_output" in
|
|
216
|
+
''|*[!0-9]*) [ -z "$max_output" ] || { echo "claude-run: ADAPTER_ARGUMENT_INVALID --max-output-tokens must be a whole number" >&2; exit 2; } ;;
|
|
217
|
+
esac
|
|
218
|
+
if [ -n "$schema" ] && [ ! -f "$schema" ]; then
|
|
219
|
+
echo "claude-run: ADAPTER_ARGUMENT_INVALID --schema: not a file: $schema" >&2
|
|
220
|
+
exit 2
|
|
221
|
+
fi
|
|
222
|
+
if [ "$profile" = hermetic ]; then
|
|
223
|
+
use="${use:-judge}"
|
|
224
|
+
case "$use" in
|
|
225
|
+
judge|authoring)
|
|
226
|
+
if [ -n "$tools" ] || [ -n "$manifest" ]; then
|
|
227
|
+
echo "claude-run: ADAPTER_ARGUMENT_INVALID --use $use grants no tool; --tools and --manifest are the producing profile's" >&2; exit 2
|
|
228
|
+
fi ;;
|
|
229
|
+
producing)
|
|
230
|
+
# Read is the one tool the host path-scopes; Grep, Glob and Bash it does not, so search
|
|
231
|
+
# is done before dispatch and a request for any of them is refused as ungranted.
|
|
232
|
+
if [ "$tools" != Read ] || [ -z "$manifest" ]; then
|
|
233
|
+
echo "claude-run: ADAPTER_ARGUMENT_INVALID --use producing needs --tools Read and --manifest DIR" >&2; exit 2
|
|
234
|
+
fi
|
|
235
|
+
if [ ! -d "$manifest" ]; then
|
|
236
|
+
echo "claude-run: ADAPTER_ARGUMENT_INVALID --manifest: not a directory: $manifest" >&2; exit 2
|
|
237
|
+
fi
|
|
238
|
+
manifest="$(cd -P "$manifest" && pwd)" ;;
|
|
239
|
+
*) echo "claude-run: ADAPTER_ARGUMENT_INVALID --use must be judge|producing|authoring" >&2; exit 2 ;;
|
|
240
|
+
esac
|
|
241
|
+
if [ -n "$permission_mode" ]; then
|
|
242
|
+
echo "claude-run: ADAPTER_ARGUMENT_INVALID --permission-mode is fixed by --profile hermetic" >&2; exit 2
|
|
243
|
+
fi
|
|
244
|
+
if [ "${#append_files[@]}" -ne "${#append_declared[@]}" ]; then
|
|
245
|
+
echo "claude-run: ADAPTER_ARGUMENT_INVALID every --append-system-prompt-file needs its --declared-sha256" >&2; exit 2
|
|
246
|
+
fi
|
|
247
|
+
if [ "${#append_files[@]}" -gt 0 ]; then
|
|
248
|
+
for f in "${append_files[@]}"; do
|
|
249
|
+
[ -f "$f" ] || { echo "claude-run: ADAPTER_ARGUMENT_INVALID --append-system-prompt-file: not a file: $f" >&2; exit 2; }
|
|
250
|
+
done
|
|
251
|
+
fi
|
|
252
|
+
case "$call_id" in
|
|
253
|
+
''|.|..|*/*) echo "claude-run: CALL_ID_MISSING --profile hermetic needs a --call-id (a plain name)" >&2; exit 2 ;;
|
|
254
|
+
esac
|
|
255
|
+
if [ -z "$claude_bin" ] || [ -z "$host_version" ]; then
|
|
256
|
+
echo "claude-run: HOST_BINARY_UNPINNED --profile hermetic needs --claude-bin PATH and --host-version V (the pinned host)" >&2; exit 2
|
|
257
|
+
fi
|
|
258
|
+
fi
|
|
259
|
+
if [ -n "$claude_bin" ]; then
|
|
260
|
+
# The versioned file itself: a symlink is what an auto-update moves between two calls of one run.
|
|
261
|
+
if [ -z "$host_version" ]; then
|
|
262
|
+
echo "claude-run: HOST_VERSION_UNPINNED --claude-bin needs the --host-version it is pinned at" >&2; exit 2
|
|
263
|
+
fi
|
|
264
|
+
if [ -L "$claude_bin" ] || [ ! -f "$claude_bin" ] || [ ! -x "$claude_bin" ]; then
|
|
265
|
+
echo "claude-run: HOST_BINARY_UNPINNED --claude-bin must be the versioned executable, not a symlink: $claude_bin" >&2
|
|
266
|
+
exit 2
|
|
267
|
+
fi
|
|
268
|
+
claude_bin="$(cd -P "$(dirname "$claude_bin")" && pwd)/$(basename "$claude_bin")"
|
|
269
|
+
fi
|
|
270
|
+
|
|
271
|
+
if [ "$server_policy_probe" = 0 ] && { [ -z "$model" ] || [ -z "$effort" ]; }; then
|
|
76
272
|
# Warn and dispatch, matching codex-run. Refusing outright was right while nothing
|
|
77
273
|
# called this file; on the live path it converts "the review ran unpinned" into "the
|
|
78
274
|
# review did not run", and the honest signal already exists — an unpinned dispatch
|
|
@@ -87,15 +283,33 @@ fi
|
|
|
87
283
|
args=(-p)
|
|
88
284
|
if [ -n "$model" ]; then args+=(--model "$model"); fi
|
|
89
285
|
if [ -n "$effort" ]; then args+=(--effort "$effort"); fi
|
|
90
|
-
|
|
91
|
-
|
|
286
|
+
profile_flags=()
|
|
287
|
+
if [ "$profile" = hermetic ]; then
|
|
288
|
+
# The flag set seats.json pins per host version (session-distill/seats.json, author-side):
|
|
289
|
+
# --bare is not usable, because it never reads the subscription token.
|
|
290
|
+
profile_flags=(--safe-mode --setting-sources "" --strict-mcp-config --disable-slash-commands)
|
|
291
|
+
if [ "$use" = producing ]; then
|
|
292
|
+
# `//` anchors the rule at the filesystem root; under -p a request no allow rule covers
|
|
293
|
+
# is refused without a prompt (dontAsk), and the refusal is recorded in the transcript.
|
|
294
|
+
profile_flags+=(--tools Read --allowedTools "Read(/$manifest/**)" --permission-mode dontAsk)
|
|
295
|
+
else
|
|
296
|
+
profile_flags+=(--tools "")
|
|
297
|
+
fi
|
|
298
|
+
args+=(--output-format stream-json --verbose --include-partial-messages "${profile_flags[@]}")
|
|
299
|
+
elif [ -n "$permission_mode" ]; then
|
|
300
|
+
profile_flags=(--permission-mode "$permission_mode")
|
|
301
|
+
args+=("${profile_flags[@]}")
|
|
92
302
|
else
|
|
93
303
|
# Deny the mutating tools rather than picking a permission mode: `plan` would also
|
|
94
304
|
# reframe the task as planning, and a reviewer asked for a plan writes one.
|
|
95
|
-
|
|
305
|
+
profile_flags=(--disallowed-tools Edit Write NotebookEdit)
|
|
306
|
+
args+=("${profile_flags[@]}")
|
|
96
307
|
fi
|
|
97
|
-
if [ -n "$cd_dir" ]
|
|
98
|
-
|
|
308
|
+
if [ -n "$cd_dir" ] && [ "$profile" = inherit ]; then
|
|
309
|
+
args+=(--add-dir "$cd_dir")
|
|
310
|
+
profile_flags+=(--add-dir "$cd_dir")
|
|
311
|
+
fi
|
|
312
|
+
if [ -n "$schema" ]; then args+=(--json-schema "$(cat "$schema")"); fi
|
|
99
313
|
|
|
100
314
|
# `--cd` names the working root, exactly as codex-run's does, and claude has no flag
|
|
101
315
|
# that carries that meaning — `--add-dir` widens what the tool may reach and moves the
|
|
@@ -104,11 +318,182 @@ if [ "${#passthrough[@]}" -gt 0 ]; then args+=("${passthrough[@]}"); fi
|
|
|
104
318
|
# reachable anyway, but a caller reading the argv sees the reach it asked for named.
|
|
105
319
|
if [ -n "$cd_dir" ]; then
|
|
106
320
|
if [ ! -d "$cd_dir" ]; then
|
|
107
|
-
echo "claude-run: --cd: not a directory: $cd_dir" >&2
|
|
321
|
+
echo "claude-run: CELL_CWD_MISSING --cd: not a directory: $cd_dir" >&2
|
|
108
322
|
exit 2
|
|
109
323
|
fi
|
|
110
324
|
fi
|
|
111
325
|
|
|
326
|
+
cleanup_paths=()
|
|
327
|
+
cleanup_all() {
|
|
328
|
+
if [ "${#cleanup_paths[@]}" -gt 0 ]; then
|
|
329
|
+
for p in "${cleanup_paths[@]}"; do rm -rf "$p"; done
|
|
330
|
+
fi
|
|
331
|
+
}
|
|
332
|
+
trap cleanup_all EXIT
|
|
333
|
+
|
|
334
|
+
# The evidence helper travels beside this file and is never looked up anywhere else: a
|
|
335
|
+
# copy found in a checkout or on PATH would render a capture with code the release did
|
|
336
|
+
# not ship. Symlinks are resolved first, so a linked adapter still finds its own sibling.
|
|
337
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
338
|
+
while [ -L "$SOURCE" ]; do
|
|
339
|
+
LINKDIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
340
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
341
|
+
case "$SOURCE" in
|
|
342
|
+
/*) ;;
|
|
343
|
+
*) SOURCE="$LINKDIR/$SOURCE" ;;
|
|
344
|
+
esac
|
|
345
|
+
done
|
|
346
|
+
helper="$(cd -P "$(dirname "$SOURCE")" && pwd)/claude_hermetic_evidence.py"
|
|
347
|
+
|
|
348
|
+
cell="${DISTILL_CELL:-}"
|
|
349
|
+
capture="${REVIEW_CAPTURE_DIR:-}"
|
|
350
|
+
run_token=""
|
|
351
|
+
session_id=""
|
|
352
|
+
# The inherit profile renders evidence only inside a cell: outside one, its configuration
|
|
353
|
+
# home is the owner's, and nothing of the owner's is copied into a capture.
|
|
354
|
+
needs_evidence=0
|
|
355
|
+
if [ "$profile" = hermetic ] || { [ -n "$cell" ] && [ -n "$capture" ]; }; then needs_evidence=1; fi
|
|
356
|
+
if [ "$needs_evidence" = 1 ]; then
|
|
357
|
+
if [ ! -f "$helper" ]; then
|
|
358
|
+
echo "claude-run: CAPTURE_HELPER_MISSING the evidence helper is missing beside the adapter: $helper" >&2
|
|
359
|
+
exit 2
|
|
360
|
+
fi
|
|
361
|
+
command -v python3 >/dev/null 2>&1 || { echo "claude-run: CAPTURE_HELPER_MISSING python3 is required by $helper" >&2; exit 2; }
|
|
362
|
+
fi
|
|
363
|
+
|
|
364
|
+
# Builtins only: the token never reaches an argv (where any process listing shows it), a
|
|
365
|
+
# file or a log. It goes to the child's environment and nowhere else.
|
|
366
|
+
read_token() {
|
|
367
|
+
local line
|
|
368
|
+
if [ -n "${CLAUDE_RUN_TOKEN_FILE:-}" ]; then
|
|
369
|
+
[ -r "$CLAUDE_RUN_TOKEN_FILE" ] || return 1
|
|
370
|
+
while IFS= read -r line || [ -n "$line" ]; do
|
|
371
|
+
line="${line#export }"
|
|
372
|
+
case "$line" in CLAUDE_CODE_OAUTH_TOKEN=*) run_token="${line#*=}" ;; esac
|
|
373
|
+
done < "$CLAUDE_RUN_TOKEN_FILE"
|
|
374
|
+
run_token="${run_token%\"}"; run_token="${run_token#\"}"
|
|
375
|
+
run_token="${run_token%\'}"; run_token="${run_token#\'}"
|
|
376
|
+
else
|
|
377
|
+
run_token="${CLAUDE_CODE_OAUTH_TOKEN:-}"
|
|
378
|
+
fi
|
|
379
|
+
[ -n "$run_token" ]
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
# Plan P5, before anything is made: the cell root outside the operator's home (from the account
|
|
383
|
+
# database, so a HOME pointed elsewhere changes nothing), the operator's own, mode 700, and no
|
|
384
|
+
# instruction surface in it or any ancestor.
|
|
385
|
+
if [ "$profile" = hermetic ]; then
|
|
386
|
+
python3 "$helper" check-root --root "${cell_root:-$(dirname "$cell")}" --home "$HOME" || exit 2
|
|
387
|
+
fi
|
|
388
|
+
if [ -n "$cell" ]; then
|
|
389
|
+
for part in home config cwd; do
|
|
390
|
+
[ -d "$cell/$part" ] || { echo "claude-run: CELL_LAYOUT_INVALID DISTILL_CELL has no $part/ directory: $cell" >&2; exit 2; }
|
|
391
|
+
done
|
|
392
|
+
elif [ "$profile" = hermetic ]; then
|
|
393
|
+
if [ -z "$cell_root" ]; then
|
|
394
|
+
echo "claude-run: ADAPTER_ARGUMENT_INVALID --profile hermetic needs --cell-root DIR (or a DISTILL_CELL)" >&2
|
|
395
|
+
exit 2
|
|
396
|
+
fi
|
|
397
|
+
[ -d "$cell_root" ] || mkdir -p -m 700 "$cell_root"
|
|
398
|
+
cell="$cell_root/$call_id"
|
|
399
|
+
if [ -e "$cell" ]; then
|
|
400
|
+
echo "claude-run: CELL_EXISTS the cell already exists: $cell" >&2
|
|
401
|
+
exit 2
|
|
402
|
+
fi
|
|
403
|
+
mkdir -m 700 "$cell"
|
|
404
|
+
cleanup_paths+=("$cell") # this adapter made it, so it goes when the call is done
|
|
405
|
+
mkdir "$cell/home" "$cell/config" "$cell/cwd"
|
|
406
|
+
fi
|
|
407
|
+
|
|
408
|
+
# Inside a cell the working directory is the cell's unless the caller names another.
|
|
409
|
+
if [ -n "$cell" ] && [ -z "$cd_dir" ]; then cd_dir="$cell/cwd"; fi
|
|
410
|
+
if [ "$profile" = hermetic ]; then
|
|
411
|
+
mkdir -p "$cell/tmp"
|
|
412
|
+
if ! read_token; then
|
|
413
|
+
echo "claude-run: TOKEN_MISSING --profile hermetic needs the subscription token: CLAUDE_CODE_OAUTH_TOKEN," >&2
|
|
414
|
+
echo " or CLAUDE_RUN_TOKEN_FILE naming a file that holds CLAUDE_CODE_OAUTH_TOKEN=..." >&2
|
|
415
|
+
exit 2
|
|
416
|
+
fi
|
|
417
|
+
elif [ -n "$cell" ] && [ -n "${CLAUDE_RUN_TOKEN_FILE:-}" ]; then
|
|
418
|
+
read_token || { echo "claude-run: TOKEN_MISSING CLAUDE_RUN_TOKEN_FILE holds no CLAUDE_CODE_OAUTH_TOKEN" >&2; exit 2; }
|
|
419
|
+
fi
|
|
420
|
+
|
|
421
|
+
# The cell used is the cell validated: it and its homes resolve beneath the checked root, and the
|
|
422
|
+
# producing profile reads only the working directory the manifest declares.
|
|
423
|
+
if [ "$profile" = hermetic ]; then
|
|
424
|
+
python3 "$helper" bind --root "${cell_root:-$(dirname "$cell")}" --cell "$cell" --cwd "$cd_dir" \
|
|
425
|
+
${manifest:+--manifest "$manifest"} || exit 2
|
|
426
|
+
fi
|
|
427
|
+
|
|
428
|
+
# The pinned host must report the version its flag set was measured on (plan P2). Asked in an
|
|
429
|
+
# environment as bare as the call's, from inside the cell, so the question reads nothing of the
|
|
430
|
+
# caller's and writes nothing the call will see.
|
|
431
|
+
if [ -n "$claude_bin" ]; then
|
|
432
|
+
version_dir="${cell:+$cell/tmp}"
|
|
433
|
+
[ -z "$version_dir" ] || mkdir -p "$version_dir"
|
|
434
|
+
reported="$(
|
|
435
|
+
for name in $(compgen -e); do unset "$name" 2>/dev/null || true; done
|
|
436
|
+
export PATH=/usr/bin:/bin:/usr/sbin:/sbin DISABLE_AUTOUPDATER=1
|
|
437
|
+
if [ -n "$cell" ]; then export HOME="$cell/home" CLAUDE_CONFIG_DIR="$cell/config"; cd "$version_dir" || { echo "claude-run: HOST_VERSION_MISMATCH cannot enter $version_dir to ask $claude_bin its version" >&2; exit 1; }; fi
|
|
438
|
+
exec "$claude_bin" --version </dev/null 2>/dev/null
|
|
439
|
+
)" || true
|
|
440
|
+
reported="${reported%%
|
|
441
|
+
*}"
|
|
442
|
+
case "$reported" in
|
|
443
|
+
"$host_version"|"$host_version "*) ;;
|
|
444
|
+
*) echo "claude-run: HOST_VERSION_MISMATCH $claude_bin reports '${reported}', the call is pinned at $host_version" >&2
|
|
445
|
+
exit 2 ;;
|
|
446
|
+
esac
|
|
447
|
+
fi
|
|
448
|
+
|
|
449
|
+
# The server-delivered policy (D-20261102-252c92), asked once per run in a cell of its own with exactly
|
|
450
|
+
# the environment the call gets, so the organisation the token belongs to is the one reported. The
|
|
451
|
+
# helper runs `claude doctor` with stdin closed and a bound, and prints only the status of its one line.
|
|
452
|
+
if [ "$server_policy_probe" = 1 ]; then
|
|
453
|
+
py="$(command -v python3)"
|
|
454
|
+
(
|
|
455
|
+
for name in $(compgen -e); do unset "$name" 2>/dev/null || true; done
|
|
456
|
+
export PATH=/usr/bin:/bin:/usr/sbin:/sbin HOME="$cell/home" CLAUDE_CONFIG_DIR="$cell/config" \
|
|
457
|
+
TMPDIR="$cell/tmp" LANG=en_US.UTF-8 DISABLE_AUTOUPDATER=1
|
|
458
|
+
export CLAUDE_CODE_OAUTH_TOKEN="$run_token"
|
|
459
|
+
cd "$cd_dir" && exec "$py" "$helper" server-policy --claude-bin "$claude_bin"
|
|
460
|
+
)
|
|
461
|
+
exit $?
|
|
462
|
+
fi
|
|
463
|
+
|
|
464
|
+
work=""
|
|
465
|
+
if [ "$needs_evidence" = 1 ] || [ -n "${REVIEW_RECEIPT_DIR:-}" ]; then
|
|
466
|
+
work="$(mktemp -d "${TMPDIR:-/tmp}/claude-run-XXXXXX")"
|
|
467
|
+
cleanup_paths+=("$work")
|
|
468
|
+
fi
|
|
469
|
+
appended_names=()
|
|
470
|
+
appended_snaps=()
|
|
471
|
+
if [ "$needs_evidence" = 1 ]; then
|
|
472
|
+
strict=()
|
|
473
|
+
if [ "$profile" = hermetic ]; then strict=(--strict); fi
|
|
474
|
+
session_id="$(python3 "$helper" prepare --cell "$cell" --cwd "${cd_dir:-$PWD}" --home "$HOME" \
|
|
475
|
+
--out "$work/pre.json" ${strict[@]+"${strict[@]}"})" || exit 2
|
|
476
|
+
fi
|
|
477
|
+
if [ "$profile" = hermetic ]; then
|
|
478
|
+
args+=(--session-id "$session_id")
|
|
479
|
+
# Each declared file is read once, here, into the cell, and the call is given that copy:
|
|
480
|
+
# what the host appends and what the capture hashes are then the same bytes, and an edit
|
|
481
|
+
# made after the declaration shows as a different sha256 rather than racing the host.
|
|
482
|
+
if [ "${#append_files[@]}" -gt 0 ]; then
|
|
483
|
+
mkdir -p "$cell/declared"
|
|
484
|
+
n=0
|
|
485
|
+
for f in "${append_files[@]}"; do
|
|
486
|
+
n=$((n + 1))
|
|
487
|
+
snap="$cell/declared/$n-$(basename "$f")"
|
|
488
|
+
cp "$f" "$snap"
|
|
489
|
+
appended_names+=("$(basename "$f")")
|
|
490
|
+
appended_snaps+=("$snap")
|
|
491
|
+
args+=(--append-system-prompt-file "$snap")
|
|
492
|
+
done
|
|
493
|
+
fi
|
|
494
|
+
fi
|
|
495
|
+
if [ "${#passthrough[@]}" -gt 0 ]; then args+=("${passthrough[@]}"); fi
|
|
496
|
+
|
|
112
497
|
# The seat the tool ACTUALLY ran on, read back out of the assembled argv rather than
|
|
113
498
|
# taken from this wrapper's own pins. Claude takes the LAST --model/--effort on its
|
|
114
499
|
# command line (verified against 2.1.232 with a reversed-order control), and this
|
|
@@ -131,32 +516,43 @@ last_flag_value() {
|
|
|
131
516
|
sent_model="$(last_flag_value --model "${args[@]}")"
|
|
132
517
|
sent_effort="$(last_flag_value --effort "${args[@]}")"
|
|
133
518
|
|
|
519
|
+
# Exactly these names reach the hermetic child; everything the caller exported is dropped.
|
|
520
|
+
child_env_names=(PATH HOME CLAUDE_CONFIG_DIR TMPDIR LANG DISABLE_AUTOUPDATER CLAUDE_CODE_OAUTH_TOKEN)
|
|
521
|
+
if [ -n "$max_output" ]; then child_env_names+=(CLAUDE_CODE_MAX_OUTPUT_TOKENS); fi
|
|
522
|
+
|
|
134
523
|
# Dispatching in a subshell keeps the cd off every path that runs afterwards: the
|
|
135
524
|
# receipt's own temp dir, the launcher lookup and a relative REVIEW_RECEIPT_DIR all
|
|
136
525
|
# resolve against the caller's cwd exactly as they did before this flag worked.
|
|
137
526
|
dispatch_claude() {
|
|
138
|
-
if [
|
|
139
|
-
(
|
|
140
|
-
|
|
141
|
-
|
|
527
|
+
if [ "$profile" = hermetic ]; then
|
|
528
|
+
(
|
|
529
|
+
for name in $(compgen -e); do unset "$name" 2>/dev/null || true; done
|
|
530
|
+
export PATH=/usr/bin:/bin:/usr/sbin:/sbin HOME="$cell/home" CLAUDE_CONFIG_DIR="$cell/config" \
|
|
531
|
+
TMPDIR="$cell/tmp" LANG=en_US.UTF-8 DISABLE_AUTOUPDATER=1
|
|
532
|
+
export CLAUDE_CODE_OAUTH_TOKEN="$run_token"
|
|
533
|
+
if [ -n "$max_output" ]; then export CLAUDE_CODE_MAX_OUTPUT_TOKENS="$max_output"; fi
|
|
534
|
+
cd "$cd_dir" && exec "$claude_bin" "${args[@]}"
|
|
535
|
+
)
|
|
536
|
+
return
|
|
142
537
|
fi
|
|
538
|
+
(
|
|
539
|
+
# Inside a cell the inherit profile still loads whatever the cell holds — which is what
|
|
540
|
+
# makes it the loading counterpart of hermetic — but never the owner's own homes.
|
|
541
|
+
if [ -n "$cell" ]; then export HOME="$cell/home" CLAUDE_CONFIG_DIR="$cell/config"; fi
|
|
542
|
+
if [ -n "$run_token" ]; then export CLAUDE_CODE_OAUTH_TOKEN="$run_token"; fi
|
|
543
|
+
if [ -n "$max_output" ]; then export CLAUDE_CODE_MAX_OUTPUT_TOKENS="$max_output"; fi
|
|
544
|
+
if [ -n "$cd_dir" ]; then cd "$cd_dir" || { echo "claude-run: CELL_CWD_MISSING cannot enter the working directory $cd_dir" >&2; exit 1; }; fi
|
|
545
|
+
exec "${claude_bin:-claude}" "${args[@]}"
|
|
546
|
+
)
|
|
143
547
|
}
|
|
144
548
|
|
|
145
|
-
cleanup_paths=()
|
|
146
|
-
cleanup_all() {
|
|
147
|
-
if [ "${#cleanup_paths[@]}" -gt 0 ]; then
|
|
148
|
-
for p in "${cleanup_paths[@]}"; do rm -rf "$p"; done
|
|
149
|
-
fi
|
|
150
|
-
}
|
|
151
|
-
trap cleanup_all EXIT
|
|
152
|
-
|
|
153
549
|
# Dispatch audit, mirroring codex-run: the line goes to the log file only, because
|
|
154
550
|
# stdout carries the review result and stderr carries claude's own progress.
|
|
155
551
|
log_home="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
|
|
156
552
|
mkdir -p "$log_home/log" 2>/dev/null || true
|
|
157
|
-
printf '%s dispatch model=%s effort=%s permission=%s\n' \
|
|
553
|
+
printf '%s dispatch model=%s effort=%s permission=%s profile=%s%s\n' \
|
|
158
554
|
"$(date +%Y-%m-%dT%H:%M:%S%z)" "${sent_model:-UNPINNED}" "${sent_effort:-UNPINNED}" \
|
|
159
|
-
"${permission_mode:-no-edit-tools}" \
|
|
555
|
+
"${permission_mode:-no-edit-tools}" "$profile" "${call_id:+ call=$call_id}" \
|
|
160
556
|
>> "$log_home/log/claude-run-dispatch.log" 2>/dev/null || true
|
|
161
557
|
|
|
162
558
|
emit_receipt() {
|
|
@@ -164,6 +560,7 @@ emit_receipt() {
|
|
|
164
560
|
# own exit status is what this script returns. A missing receipt adjudicates to
|
|
165
561
|
# UNKNOWN, which is the honest outcome — silence is not evidence of failure.
|
|
166
562
|
local status="$1" packet="$2" result="$3" launcher
|
|
563
|
+
shift 3
|
|
167
564
|
launcher="${AGENT_LAUNCH_BIN:-$HOME/.local/bin/agent-launch}"
|
|
168
565
|
if [ ! -x "$launcher" ]; then
|
|
169
566
|
launcher="$(command -v agent-launch 2>/dev/null || true)"
|
|
@@ -178,22 +575,31 @@ emit_receipt() {
|
|
|
178
575
|
# The provider is core knowledge and not a flag: this adapter reaches exactly one
|
|
179
576
|
# family, so letting a caller name a different one would only ever be a false claim.
|
|
180
577
|
"$launcher" --emit-receipt "${REVIEW_METHOD_ID:-}" "anthropic:$sent_model/$sent_effort" \
|
|
181
|
-
"$status" "$packet" "$result" >/dev/null \
|
|
578
|
+
"$status" "$packet" "$result" "$@" >/dev/null \
|
|
182
579
|
|| echo "claude-run: WARNING: receipt not emitted" >&2
|
|
183
580
|
}
|
|
184
581
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
582
|
+
stream=""
|
|
583
|
+
if [ "$profile" = hermetic ]; then
|
|
584
|
+
# The stream is appended as it arrives, so a supervisor can follow the call live; stdout
|
|
585
|
+
# carries only the closing result object, once the evidence is rendered.
|
|
586
|
+
stream="${capture:-$work}/stream.jsonl"
|
|
587
|
+
mkdir -p "$(dirname "$stream")"
|
|
588
|
+
cat > "$work/packet"
|
|
589
|
+
set +e
|
|
590
|
+
dispatch_claude < "$work/packet" >> "$stream"
|
|
591
|
+
status=$?
|
|
592
|
+
set -e
|
|
593
|
+
elif [ -n "$work" ]; then
|
|
188
594
|
# stdin is captured rather than inherited ONLY on this branch: hashing the packet
|
|
189
595
|
# requires holding it, and teeing stdout requires a pipe. Both change the channel
|
|
190
|
-
# shape, so neither is reached unless a receipt was actually asked for.
|
|
596
|
+
# shape, so neither is reached unless a receipt or a capture was actually asked for.
|
|
191
597
|
cat > "$work/packet"
|
|
192
598
|
set +e
|
|
193
599
|
dispatch_claude < "$work/packet" | tee "$work/result"
|
|
194
600
|
status=${PIPESTATUS[0]}
|
|
195
601
|
set -e
|
|
196
|
-
|
|
602
|
+
stream="$work/result"
|
|
197
603
|
else
|
|
198
604
|
set +e
|
|
199
605
|
dispatch_claude
|
|
@@ -201,4 +607,46 @@ else
|
|
|
201
607
|
set -e
|
|
202
608
|
fi
|
|
203
609
|
|
|
610
|
+
if [ "$needs_evidence" = 1 ]; then
|
|
611
|
+
render=(render --capture "${capture:-$work/capture}" --config "$cell/config" --listing "$work/pre.json"
|
|
612
|
+
--stream "$stream" --call-id "$call_id" --profile "$profile" --binary "${claude_bin:-claude}"
|
|
613
|
+
--evidence-out "$work/evidence")
|
|
614
|
+
for f in ${profile_flags[@]+"${profile_flags[@]}"}; do render+=("--flag=$f"); done
|
|
615
|
+
for f in ${passthrough[@]+"${passthrough[@]}"}; do render+=("--extra=$f"); done
|
|
616
|
+
if [ -n "$schema" ]; then render+=(--schema "$schema"); fi
|
|
617
|
+
if [ "$profile" = hermetic ]; then
|
|
618
|
+
render+=(--session-id "$session_id" --use "$use" --print-result)
|
|
619
|
+
if [ -n "$manifest" ]; then render+=(--manifest "$manifest"); fi
|
|
620
|
+
if [ -n "$server_policy" ]; then render+=(--server-policy "$server_policy"); fi
|
|
621
|
+
for n in "${child_env_names[@]}"; do render+=(--env-name "$n"); done
|
|
622
|
+
i=0
|
|
623
|
+
while [ "$i" -lt "${#appended_snaps[@]}" ]; do
|
|
624
|
+
render+=(--appended-name "${appended_names[$i]}" --appended-file "${appended_snaps[$i]}"
|
|
625
|
+
--appended-declared "${append_declared[$i]}")
|
|
626
|
+
i=$((i + 1))
|
|
627
|
+
done
|
|
628
|
+
if python3 "$helper" "${render[@]}" > "$work/result"; then
|
|
629
|
+
cat "$work/result"
|
|
630
|
+
else
|
|
631
|
+
# A hermetic call without its evidence is not a completed call, whatever claude said.
|
|
632
|
+
echo "claude-run: the evidence of call $call_id could not be rendered" >&2
|
|
633
|
+
[ "$status" -ne 0 ] || status=70
|
|
634
|
+
fi
|
|
635
|
+
elif ! python3 "$helper" "${render[@]}" >/dev/null; then
|
|
636
|
+
echo "claude-run: WARNING: the evidence of call $call_id could not be rendered" >&2
|
|
637
|
+
fi
|
|
638
|
+
# A cell this adapter made is deleted on exit; its transcripts are evidence, kept first.
|
|
639
|
+
if [ -n "$capture" ] && [ -z "${DISTILL_CELL:-}" ] && [ -d "$cell/config/projects" ]; then
|
|
640
|
+
cp -R "$cell/config/projects" "$capture/transcripts"
|
|
641
|
+
fi
|
|
642
|
+
fi
|
|
643
|
+
|
|
644
|
+
if [ -n "${REVIEW_RECEIPT_DIR:-}" ]; then
|
|
645
|
+
evidence=()
|
|
646
|
+
if [ -f "$work/evidence" ]; then
|
|
647
|
+
while IFS= read -r line; do evidence+=(--evidence "$line"); done < "$work/evidence"
|
|
648
|
+
fi
|
|
649
|
+
emit_receipt "$status" "$work/packet" "$work/result" ${evidence[@]+"${evidence[@]}"}
|
|
650
|
+
fi
|
|
651
|
+
|
|
204
652
|
exit "$status"
|