agent-bios 0.19.3 → 0.20.0
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 +62 -20
- package/INSTALL.md +1 -1
- package/README.md +16 -21
- package/claude/agents/frontier.md +1 -1
- package/claude/agents/sweep.md +2 -1
- package/claude/agents/workhorse.md +2 -2
- package/claude/guides/claude-prompting.md +494 -167
- package/claude/guides/cli-multi-model-workflow.md +8 -7
- package/claude/guides/gpt-prompting.md +241 -111
- package/claude/guides/session-distill-workflow.md +93 -43
- package/claude/guides/tooling-gotchas.md +3 -1
- package/codex/agents/reviewer.toml +2 -2
- package/codex/agents/sweep.toml +1 -1
- package/codex/agents/workhorse.toml +2 -2
- package/codex/guides/claude-prompting.md +494 -167
- package/codex/guides/cli-multi-model-workflow.md +8 -7
- package/codex/guides/gpt-prompting.md +241 -111
- 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_app.py +2 -2
- package/compose/instructions_install.py +222 -27
- package/compose/instructions_session.py +250 -75
- package/compose/instructions_setup.py +6 -6
- package/compose/instructions_setup_cli.py +2 -36
- package/compose/instructions_setup_i18n.py +3 -3
- package/compose/instructions_store.py +160 -3
- package/compose/instructions_transaction.py +29 -5
- package/compose/instructions_ui_runtime.py +2 -2
- package/compose/setup/START.md +1 -1
- package/docs/advanced-launch.md +4 -0
- package/docs/releases/0.19.4.md +99 -0
- package/docs/releases/0.20.0.md +102 -0
- package/docs/setup.md +4 -4
- package/install.sh +54 -20
- package/launch/agent-launch.py +171 -22
- package/launch/agent-launch.toml +64 -29
- package/launch/agent-launch.zsh +104 -13
- package/launch/claude_subcommands.py +179 -0
- package/launch/provision-venv.sh +1 -1
- 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 +37 -4
- package/provenance.json +1 -1
- package/session-cost.py +141 -18
- 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 +7939 -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 +44 -13
- 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/codex-helm.sh
CHANGED
|
@@ -24,7 +24,7 @@ Reach:
|
|
|
24
24
|
--reach custom CODEX_HOME from --home
|
|
25
25
|
|
|
26
26
|
Options:
|
|
27
|
-
--model MODEL Main model (default gpt-
|
|
27
|
+
--model MODEL Main model (default gpt-6.1-sol)
|
|
28
28
|
--effort EFFORT Reasoning effort override (default xhigh; ultra explicitly opts in)
|
|
29
29
|
--sandbox MODE Disable default bypass; use read-only | workspace-write | danger-full-access
|
|
30
30
|
--cd DIR Working root for Codex (default current directory; hermetic defaults empty)
|
|
@@ -41,8 +41,11 @@ Options:
|
|
|
41
41
|
wrapper defaults (repeatable)
|
|
42
42
|
-h, --help Show this help
|
|
43
43
|
|
|
44
|
-
Prompt can be passed as arguments, stdin, or both.
|
|
45
|
-
|
|
44
|
+
Prompt can be passed as arguments, stdin, or both. Stdin is read when no prompt
|
|
45
|
+
argument is given, or where a prompt argument is `-`: with other arguments beside
|
|
46
|
+
it, stdin is appended in a <stdin> block. Beside a prompt argument without `-`, a
|
|
47
|
+
redirected file is still appended; a pipe or socket is left unread, and a note
|
|
48
|
+
on stderr says so. --dry-run never reads stdin.
|
|
46
49
|
USAGE
|
|
47
50
|
}
|
|
48
51
|
|
|
@@ -103,6 +106,7 @@ while [ $# -gt 0 ]; do
|
|
|
103
106
|
-c) extra_c+=("${2:?-c needs a value}"); shift 2 ;;
|
|
104
107
|
-h|--help) usage; exit 0 ;;
|
|
105
108
|
--) shift; prompt_parts+=("$@"); break ;;
|
|
109
|
+
-) prompt_parts+=("-"); shift ;;
|
|
106
110
|
-*) echo "codex-helm: unknown argument: $1" >&2; usage >&2; exit 2 ;;
|
|
107
111
|
*) prompt_parts+=("$1"); shift ;;
|
|
108
112
|
esac
|
|
@@ -119,22 +123,22 @@ esac
|
|
|
119
123
|
|
|
120
124
|
case "$mode" in
|
|
121
125
|
auto|implement)
|
|
122
|
-
: "${model:=gpt-
|
|
126
|
+
: "${model:=gpt-6.1-sol}"
|
|
123
127
|
: "${effort:=xhigh}"
|
|
124
128
|
: "${sandbox:=workspace-write}"
|
|
125
129
|
;;
|
|
126
130
|
review)
|
|
127
|
-
: "${model:=gpt-
|
|
131
|
+
: "${model:=gpt-6.1-sol}"
|
|
128
132
|
: "${effort:=xhigh}"
|
|
129
133
|
: "${sandbox:=read-only}"
|
|
130
134
|
;;
|
|
131
135
|
scout)
|
|
132
|
-
: "${model:=gpt-
|
|
136
|
+
: "${model:=gpt-6.1-sol}"
|
|
133
137
|
: "${effort:=xhigh}"
|
|
134
138
|
: "${sandbox:=read-only}"
|
|
135
139
|
;;
|
|
136
140
|
single)
|
|
137
|
-
: "${model:=gpt-
|
|
141
|
+
: "${model:=gpt-6.1-sol}"
|
|
138
142
|
: "${effort:=xhigh}"
|
|
139
143
|
: "${sandbox:=workspace-write}"
|
|
140
144
|
fanout=0
|
|
@@ -191,12 +195,39 @@ if [ "${#extra_c[@]}" -gt 0 ]; then
|
|
|
191
195
|
done
|
|
192
196
|
fi
|
|
193
197
|
|
|
198
|
+
# Stdin is read when it is the prompt's source: no prompt argument (and not a terminal), or a `-` among
|
|
199
|
+
# the arguments. Read unconditionally, an open stdin nobody writes to (a caller's inherited pipe) hung
|
|
200
|
+
# every call, --dry-run included, at 0% CPU. Beside a prompt argument without `-`, a redirected file is
|
|
201
|
+
# still read, since a file cannot hang; a pipe or socket, where an idle writer and a slow one look the
|
|
202
|
+
# same, is left unread and said so, never dropped in silence. --dry-run never reads stdin.
|
|
194
203
|
user_prompt=""
|
|
195
|
-
|
|
196
|
-
|
|
204
|
+
read_stdin=0
|
|
205
|
+
kept_parts=()
|
|
206
|
+
if [ "${#prompt_parts[@]}" -eq 0 ]; then
|
|
207
|
+
[ -t 0 ] || read_stdin=1
|
|
208
|
+
else
|
|
209
|
+
for part in "${prompt_parts[@]}"; do
|
|
210
|
+
if [ "$part" = "-" ]; then read_stdin=1; else kept_parts+=("$part"); fi
|
|
211
|
+
done
|
|
212
|
+
if [ "$read_stdin" -eq 0 ]; then
|
|
213
|
+
if [ -f /dev/stdin ]; then
|
|
214
|
+
read_stdin=1
|
|
215
|
+
elif [ -p /dev/stdin ] || [ -S /dev/stdin ]; then
|
|
216
|
+
kind="a pipe"; [ -S /dev/stdin ] && kind="a socket"
|
|
217
|
+
echo "codex-helm: stdin is $kind and was not read, because a prompt argument was given without -; add - to the arguments to append stdin in a <stdin> block" >&2
|
|
218
|
+
fi
|
|
219
|
+
fi
|
|
197
220
|
fi
|
|
198
|
-
if [
|
|
199
|
-
|
|
221
|
+
if [ "${#kept_parts[@]}" -gt 0 ]; then
|
|
222
|
+
user_prompt="${kept_parts[*]}"
|
|
223
|
+
fi
|
|
224
|
+
stdin_prompt=""
|
|
225
|
+
if [ "$read_stdin" -eq 1 ]; then
|
|
226
|
+
if [ "$dry_run" -eq 1 ]; then
|
|
227
|
+
[ "${#prompt_parts[@]}" -gt 0 ] && stdin_prompt="<stdin: not read under --dry-run>"
|
|
228
|
+
else
|
|
229
|
+
stdin_prompt="$(cat)"
|
|
230
|
+
fi
|
|
200
231
|
if [ -n "$stdin_prompt" ]; then
|
|
201
232
|
if [ -n "$user_prompt" ]; then
|
|
202
233
|
user_prompt="$user_prompt
|
|
@@ -210,7 +241,7 @@ $stdin_prompt
|
|
|
210
241
|
fi
|
|
211
242
|
fi
|
|
212
243
|
if [ -z "$user_prompt" ]; then
|
|
213
|
-
echo "codex-helm: prompt required via arguments or stdin" >&2
|
|
244
|
+
echo "codex-helm: prompt required via arguments or stdin (--dry-run reads no stdin; pass the prompt as arguments)" >&2
|
|
214
245
|
exit 2
|
|
215
246
|
fi
|
|
216
247
|
|
|
@@ -233,7 +264,7 @@ EOF
|
|
|
233
264
|
if [ "$fanout" -eq 1 ]; then
|
|
234
265
|
cat <<EOF
|
|
235
266
|
- Fan-out is authorized when delegation gates fire; do de-minimis work directly. Native multi-agent is off unless the main is explicit Ultra.
|
|
236
|
-
- Internal roles via codex-run --profile inherit and bounded stdin packet: WORKHORSE=gpt-
|
|
267
|
+
- Internal roles via codex-run --profile inherit and bounded stdin packet: WORKHORSE=gpt-6.1-sol/high/read-only-or-workspace-write; SWEEP=gpt-6-luna/max/read-only; REVIEWER=gpt-6.1-sol/high/read-only.
|
|
237
268
|
- Native spawn cannot pin role/effort. Do not use native spawn_agent for FRONTIER. Use codex-run with gpt-6-astra/read-only and task-fit effort: max default, Ultra for divisible work, lower when cost/latency dominates.
|
|
238
269
|
- Internal FRONTIER command base: $codex_run --profile inherit --model gpt-6-astra --effort <effort> --multi-agent auto --sandbox read-only --cd "\$PWD" -c agents.max_threads=$max_threads -c agents.max_depth=$max_depth. The adapter enables native multi-agent only for ultra. Send a self-contained packet on stdin; never full-history resume.
|
|
239
270
|
- Run independent units in parallel; respect depth/thread limits; wait and synthesize bounded reports.
|
package/wrappers/codex-run.sh
CHANGED
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
# Profiles (instruction/config reach):
|
|
15
15
|
# inherit (default) real CODEX_HOME → global + project AGENTS.md + full config.toml
|
|
16
16
|
# hermetic fresh temp CODEX_HOME (auth copied only) + --ignore-user-config,
|
|
17
|
-
#
|
|
18
|
-
#
|
|
17
|
+
# an empty temp HOME, project_doc_max_bytes=0, cwd defaulting to an
|
|
18
|
+
# empty temp workspace → NO AGENTS.md (global or project, even with
|
|
19
|
+
# --cd inside a repository), NO user skills, NO user config: an
|
|
20
|
+
# independent, uncontaminated lens
|
|
19
21
|
# custom --home DIR CODEX_HOME=DIR → exactly the AGENTS.md/config you place in DIR
|
|
20
22
|
#
|
|
21
23
|
# The prompt is read from stdin. `codex exec` writes the final message to stdout
|
|
@@ -28,7 +30,17 @@
|
|
|
28
30
|
# existed and writes nothing. The dispatch-audit line below predates receipts and stays:
|
|
29
31
|
# it is a human-readable trail, not an adjudicable record.
|
|
30
32
|
#
|
|
31
|
-
#
|
|
33
|
+
# Capture: with --capture DIR (or REVIEW_CAPTURE_DIR) and a call id (REVIEW_CALL_ID), the
|
|
34
|
+
# adapter records what this one call showed about itself into DIR, through
|
|
35
|
+
# codex_frame_filter.py beside the adapter: the effective context rendered beforehand with the
|
|
36
|
+
# call's own homes and overrides (prompt-input.txt, instruction-sources.json), codex's --json
|
|
37
|
+
# thread and turn events, the server's frames and otel rows reduced to an allow-list (no prompt
|
|
38
|
+
# or output text is kept), host.json and usage.json; the receipt carries the evidence keys.
|
|
39
|
+
# The frames come only from the caller's RUST_LOG (tungstenite::protocol=trace,
|
|
40
|
+
# codex_otel.log_only=info, codex_core::responses_retry=warn): without it the capture is
|
|
41
|
+
# silent and the call cannot be attested. stderr still carries codex's whole stream.
|
|
42
|
+
#
|
|
43
|
+
# Verified against codex-cli 0.144.1; capture against 0.163.0.
|
|
32
44
|
set -euo pipefail
|
|
33
45
|
|
|
34
46
|
usage() {
|
|
@@ -38,10 +50,11 @@ Usage: codex-run.sh [--profile inherit|hermetic|custom] [--home DIR]
|
|
|
38
50
|
[--bypass-sandbox]
|
|
39
51
|
[--multi-agent auto|on|off]
|
|
40
52
|
[--schema FILE] [--codex-profile NAME] [-p NAME]
|
|
41
|
-
[-c key=value ...] [-] < prompt
|
|
53
|
+
[--capture DIR] [-c key=value ...] [-] < prompt
|
|
42
54
|
--profile instruction/config reach (default: inherit)
|
|
43
55
|
inherit real CODEX_HOME -> global+project AGENTS.md + full config.toml
|
|
44
|
-
hermetic temp CODEX_HOME
|
|
56
|
+
hermetic temp CODEX_HOME + empty HOME -> NO AGENTS.md, NO user
|
|
57
|
+
skills, NO user config (auth only), even with --cd
|
|
45
58
|
custom CODEX_HOME=--home -> exactly what you place in that dir
|
|
46
59
|
--home DIR CODEX_HOME for --profile custom (required for custom)
|
|
47
60
|
--model M -m: model to use
|
|
@@ -58,6 +71,8 @@ Usage: codex-run.sh [--profile inherit|hermetic|custom] [--home DIR]
|
|
|
58
71
|
Codex config profile: layer $CODEX_HOME/<name>.config.toml
|
|
59
72
|
-c k=v expert pass-through config override (repeatable); may override
|
|
60
73
|
wrapper defaults, e.g. -c model_verbosity="low"
|
|
74
|
+
--capture DIR
|
|
75
|
+
record this call's evidence into DIR (empty or new); needs REVIEW_CALL_ID
|
|
61
76
|
- optional explicit stdin marker
|
|
62
77
|
|
|
63
78
|
Environment (the adapter calling convention; all optional):
|
|
@@ -65,6 +80,14 @@ Environment (the adapter calling convention; all optional):
|
|
|
65
80
|
REVIEW_METHOD_ID the review method this dispatch serves
|
|
66
81
|
REVIEW_ORDERING_SEED, REVIEW_SWAP_GROUP
|
|
67
82
|
the orchestrator's panel controls, copied into the receipt
|
|
83
|
+
REVIEW_CAPTURE_DIR as --capture DIR
|
|
84
|
+
REVIEW_CALL_ID the call a capture belongs to (DISTILL_CALL_ID is read when unset)
|
|
85
|
+
REVIEW_CONTEXT_MANIFEST
|
|
86
|
+
the call's declared context manifest (JSON), hashed into the receipt
|
|
87
|
+
CODEX_RUN_BIN the codex executable a capture runs (default: codex on PATH, links
|
|
88
|
+
resolved to the versioned file)
|
|
89
|
+
CODEX_RUN_VERSION the codex-cli version a capture is pinned to; required, checked first
|
|
90
|
+
RUST_LOG the trace channels a capture reads; passed to codex unchanged
|
|
68
91
|
USAGE
|
|
69
92
|
}
|
|
70
93
|
|
|
@@ -79,6 +102,7 @@ cd_dir=""
|
|
|
79
102
|
schema=""
|
|
80
103
|
codex_profile=""
|
|
81
104
|
extra_c=()
|
|
105
|
+
capture_dir="${REVIEW_CAPTURE_DIR:-}"
|
|
82
106
|
|
|
83
107
|
while [ $# -gt 0 ]; do
|
|
84
108
|
case "$1" in
|
|
@@ -93,29 +117,30 @@ while [ $# -gt 0 ]; do
|
|
|
93
117
|
--schema) schema="${2:?--schema needs a value}"; shift 2 ;;
|
|
94
118
|
--codex-profile|-p) codex_profile="${2:?--codex-profile needs a value}"; shift 2 ;;
|
|
95
119
|
-c) extra_c+=("${2:?-c needs a value}"); shift 2 ;;
|
|
120
|
+
--capture) capture_dir="${2:?--capture needs a value}"; shift 2 ;;
|
|
96
121
|
-) shift ;;
|
|
97
122
|
-h|--help) usage; exit 0 ;;
|
|
98
|
-
*) echo "codex-run: unknown argument: $1" >&2; usage >&2; exit 2 ;;
|
|
123
|
+
*) echo "codex-run: ADAPTER_ARGUMENT_INVALID unknown argument: $1" >&2; usage >&2; exit 2 ;;
|
|
99
124
|
esac
|
|
100
125
|
done
|
|
101
126
|
|
|
102
127
|
case "$profile" in
|
|
103
128
|
inherit|hermetic|custom) ;;
|
|
104
|
-
*) echo "codex-run: --profile must be inherit|hermetic|custom" >&2; exit 2 ;;
|
|
129
|
+
*) echo "codex-run: ADAPTER_ARGUMENT_INVALID --profile must be inherit|hermetic|custom" >&2; exit 2 ;;
|
|
105
130
|
esac
|
|
106
131
|
case "$multi_agent" in
|
|
107
132
|
""|auto|on|off) ;;
|
|
108
|
-
*) echo "codex-run: --multi-agent must be auto|on|off" >&2; exit 2 ;;
|
|
133
|
+
*) echo "codex-run: ADAPTER_ARGUMENT_INVALID --multi-agent must be auto|on|off" >&2; exit 2 ;;
|
|
109
134
|
esac
|
|
110
135
|
|
|
111
136
|
config_key_from_override() {
|
|
112
137
|
kv="$1"
|
|
113
138
|
case "$kv" in
|
|
114
139
|
*=*) key="${kv%%=*}" ;;
|
|
115
|
-
*) echo "codex-run: -c must be key=value: $kv" >&2; exit 2 ;;
|
|
140
|
+
*) echo "codex-run: ADAPTER_ARGUMENT_INVALID -c must be key=value: $kv" >&2; exit 2 ;;
|
|
116
141
|
esac
|
|
117
142
|
case "$key" in
|
|
118
|
-
''|*[!A-Za-z0-9_.-]*) echo "codex-run: invalid -c key: $key" >&2; exit 2 ;;
|
|
143
|
+
''|*[!A-Za-z0-9_.-]*) echo "codex-run: ADAPTER_ARGUMENT_INVALID invalid -c key: $key" >&2; exit 2 ;;
|
|
119
144
|
esac
|
|
120
145
|
printf '%s\n' "$key"
|
|
121
146
|
}
|
|
@@ -128,6 +153,8 @@ fi
|
|
|
128
153
|
|
|
129
154
|
real_home="${CODEX_HOME:-$HOME/.codex}"
|
|
130
155
|
run_home="$real_home"
|
|
156
|
+
child_home="$HOME"
|
|
157
|
+
run_env=()
|
|
131
158
|
cleanup_paths=()
|
|
132
159
|
cleanup_all() {
|
|
133
160
|
if [ "${#cleanup_paths[@]}" -gt 0 ]; then
|
|
@@ -136,22 +163,49 @@ cleanup_all() {
|
|
|
136
163
|
}
|
|
137
164
|
trap cleanup_all EXIT
|
|
138
165
|
|
|
166
|
+
# A hermetic call's temp home holds an auth.json copy, and the EXIT trap cannot run when the
|
|
167
|
+
# wrapper is SIGKILLed. Each temp home therefore names its owner's PID, and every start removes
|
|
168
|
+
# the ones left behind: only this user's real directories (find -type d never follows a
|
|
169
|
+
# symlink) whose owner PID no longer exists and which are older than stale_after_min. The
|
|
170
|
+
# wrapper sets no call timeout of its own, so the age is a fixed bound well past any call
|
|
171
|
+
# and the PID test is what keeps a live call in another session untouched. ps, not kill -0,
|
|
172
|
+
# because kill -0 also fails on another user's live process.
|
|
173
|
+
stale_after_min=1440
|
|
174
|
+
sweep_stale_homes() {
|
|
175
|
+
local tmp="${TMPDIR:-/tmp}" dir pid
|
|
176
|
+
[ -d "$tmp" ] || return 0
|
|
177
|
+
while IFS= read -r dir; do
|
|
178
|
+
pid="${dir##*/codex-run-home.}"
|
|
179
|
+
pid="${pid%%.*}"
|
|
180
|
+
case "$pid" in ''|*[!0-9]*) continue ;; esac
|
|
181
|
+
if ps -p "$pid" >/dev/null 2>&1; then continue; fi
|
|
182
|
+
rm -rf "$dir" && echo "codex-run: removed stale temp home $dir (owner pid $pid gone)" >&2
|
|
183
|
+
done < <(find "${tmp%/}/" -maxdepth 1 -type d -name 'codex-run-home.*.*' -user "$(id -u)" -mmin "+$stale_after_min" 2>/dev/null)
|
|
184
|
+
}
|
|
185
|
+
sweep_stale_homes
|
|
186
|
+
|
|
139
187
|
if [ "$profile" = "hermetic" ]; then
|
|
140
|
-
root="$(mktemp -d "${TMPDIR:-/tmp}/codex-run-XXXXXX")"
|
|
188
|
+
root="$(mktemp -d "${TMPDIR:-/tmp}/codex-run-home.$$.XXXXXX")"
|
|
141
189
|
cleanup_paths+=("$root")
|
|
142
190
|
run_home="$root/home"
|
|
143
191
|
mkdir -p "$run_home"
|
|
144
192
|
# Auth still resolves from CODEX_HOME even with --ignore-user-config, so carry
|
|
145
193
|
# only auth.json across; leave AGENTS.md and config.toml behind.
|
|
146
194
|
cp "$real_home/auth.json" "$run_home/auth.json" 2>/dev/null || true
|
|
147
|
-
#
|
|
195
|
+
# Codex also reads user skills from HOME, so the child gets an empty one. Only the
|
|
196
|
+
# child: receipts below still resolve the launcher from the caller's HOME.
|
|
197
|
+
mkdir -p "$root/user-home"
|
|
198
|
+
child_home="$root/user-home"
|
|
199
|
+
run_env+=(HOME="$child_home")
|
|
200
|
+
# Default cwd to an empty workspace; project_doc_max_bytes=0 (added below) keeps a
|
|
201
|
+
# caller's --cd inside a repository from loading its AGENTS.md files.
|
|
148
202
|
if [ -z "$cd_dir" ]; then
|
|
149
203
|
cd_dir="$root/workspace"
|
|
150
204
|
mkdir -p "$cd_dir"
|
|
151
205
|
fi
|
|
152
206
|
elif [ "$profile" = "custom" ]; then
|
|
153
|
-
if [ -z "$home" ]; then echo "codex-run: --profile custom requires --home DIR" >&2; exit 2; fi
|
|
154
|
-
if [ ! -d "$home" ]; then echo "codex-run: --home not a directory: $home" >&2; exit 2; fi
|
|
207
|
+
if [ -z "$home" ]; then echo "codex-run: ADAPTER_ARGUMENT_INVALID --profile custom requires --home DIR" >&2; exit 2; fi
|
|
208
|
+
if [ ! -d "$home" ]; then echo "codex-run: ADAPTER_ARGUMENT_INVALID --home not a directory: $home" >&2; exit 2; fi
|
|
155
209
|
run_home="$home"
|
|
156
210
|
fi
|
|
157
211
|
|
|
@@ -161,7 +215,10 @@ if [ "$bypass_sandbox" -eq 1 ]; then
|
|
|
161
215
|
else
|
|
162
216
|
args+=(--sandbox "$sandbox")
|
|
163
217
|
fi
|
|
164
|
-
|
|
218
|
+
# The profile's flag set, one list: what codex receives and what a capture hashes.
|
|
219
|
+
profile_flags=()
|
|
220
|
+
if [ "$profile" = "hermetic" ]; then profile_flags=(--ignore-user-config --ephemeral -c project_doc_max_bytes=0); fi
|
|
221
|
+
if [ "${#profile_flags[@]}" -gt 0 ]; then args+=("${profile_flags[@]}"); fi
|
|
165
222
|
if [ -n "$model" ]; then args+=(--model "$model"); fi
|
|
166
223
|
if [ -n "$cd_dir" ]; then args+=(--cd "$cd_dir"); fi
|
|
167
224
|
if [ -n "$schema" ]; then args+=(--output-schema "$schema"); fi
|
|
@@ -211,7 +268,7 @@ emit_receipt() {
|
|
|
211
268
|
# Recording never breaks dispatch: every failure here is a warning and codex's own
|
|
212
269
|
# exit status is what this script returns. A missing receipt adjudicates to UNKNOWN,
|
|
213
270
|
# which is the honest outcome — silence is not evidence of failure.
|
|
214
|
-
status="$1"; packet="$2"; result="$3"
|
|
271
|
+
status="$1"; packet="$2"; result="$3"; shift 3
|
|
215
272
|
launcher="${AGENT_LAUNCH_BIN:-$HOME/.local/bin/agent-launch}"
|
|
216
273
|
if [ ! -x "$launcher" ]; then
|
|
217
274
|
launcher="$(command -v agent-launch 2>/dev/null || true)"
|
|
@@ -224,11 +281,117 @@ emit_receipt() {
|
|
|
224
281
|
# unpinned dispatch names no seat at all, so the receipt is refused rather than
|
|
225
282
|
# invented — which is the same failure the warning above already reports.
|
|
226
283
|
"$launcher" --emit-receipt "${REVIEW_METHOD_ID:-}" \
|
|
227
|
-
"openai:${cmodel:-$model}/${ceffort:-$effort}" "$status" "$packet" "$result" >/dev/null \
|
|
284
|
+
"openai:${cmodel:-$model}/${ceffort:-$effort}" "$status" "$packet" "$result" "$@" >/dev/null \
|
|
228
285
|
|| echo "codex-run: WARNING: receipt not emitted" >&2
|
|
229
286
|
}
|
|
230
287
|
|
|
231
|
-
if [ -n "$
|
|
288
|
+
if [ -n "$capture_dir" ]; then
|
|
289
|
+
# The helper travels with the adapter (the release and the compatibility bin both put it
|
|
290
|
+
# beside this file); resolving it anywhere else would let a checkout stand in for a release.
|
|
291
|
+
self="${BASH_SOURCE[0]}"
|
|
292
|
+
while [ -L "$self" ]; do
|
|
293
|
+
link="$(readlink "$self")"
|
|
294
|
+
case "$link" in /*) self="$link" ;; *) self="$(dirname "$self")/$link" ;; esac
|
|
295
|
+
done
|
|
296
|
+
helper="$(cd "$(dirname "$self")" && pwd)/codex_frame_filter.py"
|
|
297
|
+
if [ ! -f "$helper" ]; then
|
|
298
|
+
echo "codex-run: CAPTURE_HELPER_MISSING capture helper missing beside the adapter: $helper" >&2; exit 3
|
|
299
|
+
fi
|
|
300
|
+
# A named Codex configuration profile layers settings and instructions the rendering below
|
|
301
|
+
# cannot reproduce, so a capture refuses one rather than record evidence of another call.
|
|
302
|
+
named_profile="$codex_profile"
|
|
303
|
+
if [ "${#extra_c[@]}" -gt 0 ]; then
|
|
304
|
+
for kv in "${extra_c[@]}"; do
|
|
305
|
+
case "$kv" in profile=*) named_profile="${kv#profile=}" ;; esac
|
|
306
|
+
done
|
|
307
|
+
fi
|
|
308
|
+
if [ -n "$named_profile" ]; then
|
|
309
|
+
echo "codex-run: CODEX_PROFILE_UNSUPPORTED capture cannot render Codex profile '$named_profile'; drop -p/--codex-profile or -c profile=" >&2
|
|
310
|
+
exit 2
|
|
311
|
+
fi
|
|
312
|
+
call_id="${REVIEW_CALL_ID:-${DISTILL_CALL_ID:-}}"
|
|
313
|
+
if [ -z "$call_id" ]; then
|
|
314
|
+
echo "codex-run: CALL_ID_MISSING a capture needs REVIEW_CALL_ID, the call this capture belongs to" >&2; exit 2
|
|
315
|
+
fi
|
|
316
|
+
mkdir -p "$capture_dir"
|
|
317
|
+
if [ -n "$(ls -A "$capture_dir")" ]; then
|
|
318
|
+
echo "codex-run: CAPTURE_DIR_NOT_EMPTY the capture directory holds files already (one capture per call): $capture_dir" >&2; exit 2
|
|
319
|
+
fi
|
|
320
|
+
case ",${RUST_LOG:-}," in
|
|
321
|
+
*,tungstenite::protocol=trace,*) ;;
|
|
322
|
+
*) echo "codex-run: WARNING: RUST_LOG does not open tungstenite::protocol=trace; no frame will name the model that answered" >&2 ;;
|
|
323
|
+
esac
|
|
324
|
+
# One executable for the rendering, the host record, the version check and the call: the
|
|
325
|
+
# versioned file the caller pins (CODEX_RUN_BIN, else codex on PATH with its links resolved),
|
|
326
|
+
# at the version the caller pins (CODEX_RUN_VERSION), checked before anything is sent.
|
|
327
|
+
codex_bin="${CODEX_RUN_BIN:-$(command -v codex 2>/dev/null || true)}"
|
|
328
|
+
if [ -z "$codex_bin" ] || [ ! -x "$codex_bin" ]; then
|
|
329
|
+
echo "codex-run: HOST_BINARY_UNPINNED a capture needs the pinned codex executable: CODEX_RUN_BIN names none that exists (${CODEX_RUN_BIN:-unset}), and PATH has none" >&2; exit 2
|
|
330
|
+
fi
|
|
331
|
+
while [ -L "$codex_bin" ]; do
|
|
332
|
+
link="$(readlink "$codex_bin")"
|
|
333
|
+
case "$link" in /*) codex_bin="$link" ;; *) codex_bin="$(dirname "$codex_bin")/$link" ;; esac
|
|
334
|
+
done
|
|
335
|
+
codex_bin="$(cd -P "$(dirname "$codex_bin")" && pwd)/$(basename "$codex_bin")"
|
|
336
|
+
if [ -z "${CODEX_RUN_VERSION:-}" ]; then
|
|
337
|
+
echo "codex-run: HOST_VERSION_UNPINNED a capture needs CODEX_RUN_VERSION, the codex-cli version the call is pinned to" >&2; exit 2
|
|
338
|
+
fi
|
|
339
|
+
codex_version="$(env CODEX_HOME="$run_home" HOME="$child_home" DISABLE_AUTOUPDATER=1 "$codex_bin" --version 2>/dev/null || true)"
|
|
340
|
+
if [ "$codex_version" != "codex-cli $CODEX_RUN_VERSION" ]; then
|
|
341
|
+
echo "codex-run: HOST_VERSION_MISMATCH $codex_bin reports '$codex_version', the call is pinned to codex-cli $CODEX_RUN_VERSION" >&2
|
|
342
|
+
exit 3
|
|
343
|
+
fi
|
|
344
|
+
[ -n "$cd_dir" ] || cd_dir="$PWD"
|
|
345
|
+
work="$(mktemp -d "${TMPDIR:-/tmp}/codex-run-capture-XXXXXX")"
|
|
346
|
+
cleanup_paths+=("$work")
|
|
347
|
+
cat > "$work/packet"
|
|
348
|
+
# The rendering sees what the call will: the same homes and working directory, every -c
|
|
349
|
+
# the call passes, and the model, approval and sandbox exec sets from its own flags.
|
|
350
|
+
render_c=(-c 'approval_policy="never"')
|
|
351
|
+
if [ "$bypass_sandbox" -eq 1 ]; then render_c+=(-c 'sandbox_mode="danger-full-access"')
|
|
352
|
+
else render_c+=(-c "sandbox_mode=\"$sandbox\""); fi
|
|
353
|
+
if [ -n "$model" ]; then render_c+=(-c "model=\"$model\""); fi
|
|
354
|
+
prev=""
|
|
355
|
+
for a in "${args[@]}"; do
|
|
356
|
+
if [ "$prev" = "-c" ]; then render_c+=(-c "$a"); fi
|
|
357
|
+
prev="$a"
|
|
358
|
+
done
|
|
359
|
+
env ${run_env[@]+"${run_env[@]}"} DISABLE_AUTOUPDATER=1 python3 "$helper" context --codex "$codex_bin" \
|
|
360
|
+
--version "$CODEX_RUN_VERSION" --codex-home "$run_home" --child-home "$child_home" \
|
|
361
|
+
--cwd "$cd_dir" --capture "$capture_dir" --work "$work" "${render_c[@]}" \
|
|
362
|
+
|| { echo "codex-run: CONTEXT_EVIDENCE_MISSING the effective-context evidence failed, so nothing is dispatched" >&2; exit 3; }
|
|
363
|
+
t0="$(python3 -c 'import time; print(int(time.time() * 1000))')"
|
|
364
|
+
set +e
|
|
365
|
+
# codex's stdout (the --json events) goes to fd 9, its stderr through the filter, which
|
|
366
|
+
# passes every line on to this script's stderr and keeps the reduced records.
|
|
367
|
+
exec 9> "$work/events.raw"
|
|
368
|
+
env ${run_env[@]+"${run_env[@]}"} CODEX_HOME="$run_home" DISABLE_AUTOUPDATER=1 "$codex_bin" "${args[@]}" --json -o "$work/result" \
|
|
369
|
+
< "$work/packet" 2>&1 >&9 9>&- \
|
|
370
|
+
| python3 "$helper" filter --frames "$capture_dir/frames.jsonl" --rust-log "${RUST_LOG:-}" 9>&-
|
|
371
|
+
status=${PIPESTATUS[0]}
|
|
372
|
+
exec 9>&-
|
|
373
|
+
set -e
|
|
374
|
+
t1="$(python3 -c 'import time; print(int(time.time() * 1000))')"
|
|
375
|
+
python3 "$helper" events --out "$capture_dir/events.jsonl" < "$work/events.raw" \
|
|
376
|
+
|| echo "codex-run: WARNING: events not captured" >&2
|
|
377
|
+
# the bytes delivered on stdout are the final message and one newline, as without capture
|
|
378
|
+
if [ -s "$work/result" ]; then { cat "$work/result"; printf '\n'; } > "$work/stdout"; else : > "$work/stdout"; fi
|
|
379
|
+
flag_args=()
|
|
380
|
+
if [ "${#profile_flags[@]}" -gt 0 ]; then
|
|
381
|
+
for f in "${profile_flags[@]}"; do flag_args+=("--flag=$f"); done
|
|
382
|
+
fi
|
|
383
|
+
evidence=()
|
|
384
|
+
while IFS= read -r line; do evidence+=(--evidence "$line"); done < <(
|
|
385
|
+
python3 "$helper" finish --capture "$capture_dir" --work "$work" --call-id "$call_id" --profile "$profile" \
|
|
386
|
+
--cwd "$cd_dir" --packet "$work/packet" --model "${cmodel:-$model}" --effort "${ceffort:-$effort}" \
|
|
387
|
+
--exit-status "$status" --wall-ms "$((t1 - t0))" ${schema:+--schema "$schema"} \
|
|
388
|
+
${REVIEW_CONTEXT_MANIFEST:+--manifest "$REVIEW_CONTEXT_MANIFEST"} ${flag_args[@]+"${flag_args[@]}"} \
|
|
389
|
+
|| echo "codex-run: WARNING: capture not finished" >&2)
|
|
390
|
+
cat "$work/stdout"
|
|
391
|
+
if [ -n "${REVIEW_RECEIPT_DIR:-}" ]; then
|
|
392
|
+
emit_receipt "$status" "$work/packet" "$work/stdout" ${evidence[@]+"${evidence[@]}"}
|
|
393
|
+
fi
|
|
394
|
+
elif [ -n "${REVIEW_RECEIPT_DIR:-}" ]; then
|
|
232
395
|
# stdin is captured rather than inherited ONLY on this branch: hashing the packet
|
|
233
396
|
# requires holding it, and teeing stdout requires a pipe. Both change the channel
|
|
234
397
|
# shape, so neither is reached unless a receipt was actually asked for.
|
|
@@ -236,14 +399,14 @@ if [ -n "${REVIEW_RECEIPT_DIR:-}" ]; then
|
|
|
236
399
|
cleanup_paths+=("$work")
|
|
237
400
|
cat > "$work/packet"
|
|
238
401
|
set +e
|
|
239
|
-
CODEX_HOME="$run_home" codex "${args[@]}" < "$work/packet" | tee "$work/result"
|
|
402
|
+
env ${run_env[@]+"${run_env[@]}"} CODEX_HOME="$run_home" codex "${args[@]}" < "$work/packet" | tee "$work/result"
|
|
240
403
|
status=${PIPESTATUS[0]}
|
|
241
404
|
set -e
|
|
242
405
|
emit_receipt "$status" "$work/packet" "$work/result"
|
|
243
406
|
else
|
|
244
407
|
# stdin, stdout, and stderr already match this adapter's channel contract.
|
|
245
408
|
set +e
|
|
246
|
-
CODEX_HOME="$run_home" codex "${args[@]}"
|
|
409
|
+
env ${run_env[@]+"${run_env[@]}"} CODEX_HOME="$run_home" codex "${args[@]}"
|
|
247
410
|
status=$?
|
|
248
411
|
set -e
|
|
249
412
|
fi
|