subconscious-cli 4.1.3 → 4.1.4
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/bin/agents.js +28 -6
- package/bin/native/subc-tui-darwin-amd64 +0 -0
- package/bin/native/subc-tui-darwin-arm64 +0 -0
- package/bin/native/subc-tui-linux-amd64 +0 -0
- package/bin/native/subc-tui-linux-arm64 +0 -0
- package/bin/native/subc-tui-windows-amd64.exe +0 -0
- package/bin/native/subc-tui-windows-arm64.exe +0 -0
- package/bin/profiles.js +25 -0
- package/bin/registry.generated.json +1 -1
- package/bin/runbook/codex/hooks-lib.sh +32 -2
- package/bin/runbook/codex/install.sh +10 -0
- package/bin/runbook/codex/run.sh +111 -55
- package/package.json +1 -1
package/bin/agents.js
CHANGED
|
@@ -32,6 +32,15 @@ import { compareVersions } from './update-check.js';
|
|
|
32
32
|
|
|
33
33
|
export const MIN_CLAUDE_CODE_VERSION = '2.1.242';
|
|
34
34
|
|
|
35
|
+
// First Codex that honours `multi_agent_version: "v2"` in the model catalog,
|
|
36
|
+
// found by installing each release and reading what it advertises: 0.142.5 and
|
|
37
|
+
// below offer no subagent namespace at all, 0.143.0 offers `collaboration`.
|
|
38
|
+
//
|
|
39
|
+
// Below this the catalog field is not rejected, it is ignored - the run simply
|
|
40
|
+
// has no subagents and nothing says why. That silence is the reason for a
|
|
41
|
+
// version gate rather than a note in the docs.
|
|
42
|
+
export const MIN_CODEX_VERSION = '0.143.0';
|
|
43
|
+
|
|
35
44
|
// --- Registry (single source of truth, generated copy shipped in the package).
|
|
36
45
|
const registry = JSON.parse(
|
|
37
46
|
readFileSync(new URL('./registry.generated.json', import.meta.url), 'utf-8'),
|
|
@@ -193,10 +202,10 @@ const AGENT_HELP = {
|
|
|
193
202
|
codex: {
|
|
194
203
|
usage: 'subc [-p NAME] codex [help|install|status|uninstall] [Codex arguments...]',
|
|
195
204
|
behavior:
|
|
196
|
-
'Launches Codex with a temporary Subconscious provider catalog. Compaction hooks are merged into ~/.codex/hooks.json and removed with subc codex uninstall.',
|
|
205
|
+
'Launches Codex with a temporary Subconscious provider catalog. Compaction hooks are merged into ~/.codex/hooks.json on first launch and removed with subc codex uninstall; Codex will not run them until you trust them with /hooks once.',
|
|
197
206
|
options: [
|
|
198
207
|
['help', 'Show this help'],
|
|
199
|
-
['install', 'Install
|
|
208
|
+
['install', 'Install the Subconscious compaction hooks (then trust with /hooks)'],
|
|
200
209
|
['status', 'Inspect the installed compaction hooks'],
|
|
201
210
|
['uninstall', 'Remove only the Subconscious Codex hooks'],
|
|
202
211
|
['--model MODEL', 'Override the profile model for this launch'],
|
|
@@ -205,7 +214,9 @@ const AGENT_HELP = {
|
|
|
205
214
|
['--auto-compact-token-limit N', 'Override the automatic compaction threshold'],
|
|
206
215
|
['--reasoning-effort LEVEL', 'Use none, low, medium, high, or max'],
|
|
207
216
|
['--external-tools', 'Enable Codex apps/plugins for this launch'],
|
|
208
|
-
['--
|
|
217
|
+
['--stream-idle-timeout MS', 'Allow a longer silent think before timing out'],
|
|
218
|
+
['--max-subagents N', 'Subagents allowed to run at once (default 4)'],
|
|
219
|
+
['--subagent-effort LEVEL', 'Effort for subagents, separate from the parent'],
|
|
209
220
|
['-- ARGS...', 'Pass remaining arguments to Codex'],
|
|
210
221
|
],
|
|
211
222
|
},
|
|
@@ -625,6 +636,10 @@ export function parseClaudeVersion(text) {
|
|
|
625
636
|
}
|
|
626
637
|
|
|
627
638
|
export function claudeVersionNeedsUpgrade(installed, minimum = MIN_CLAUDE_CODE_VERSION) {
|
|
639
|
+
return versionNeedsUpgrade(installed, minimum);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
export function versionNeedsUpgrade(installed, minimum) {
|
|
628
643
|
return Boolean(installed && minimum && compareVersions(installed, minimum) < 0);
|
|
629
644
|
}
|
|
630
645
|
|
|
@@ -649,13 +664,20 @@ export function readClaudeVersion(bin, binDir, options = {}) {
|
|
|
649
664
|
}
|
|
650
665
|
}
|
|
651
666
|
|
|
667
|
+
const MINIMUM_VERSIONS = {
|
|
668
|
+
'claude-code': { minimum: MIN_CLAUDE_CODE_VERSION, label: 'Claude Code' },
|
|
669
|
+
// Below this, subagents are silently absent rather than broken.
|
|
670
|
+
codex: { minimum: MIN_CODEX_VERSION, label: 'Codex' },
|
|
671
|
+
};
|
|
672
|
+
|
|
652
673
|
async function ensureClaudeCompatible(agent, binDir) {
|
|
653
|
-
|
|
674
|
+
const requirement = MINIMUM_VERSIONS[agent.id];
|
|
675
|
+
if (!requirement) return;
|
|
654
676
|
const version = readClaudeVersion(agent.bin, binDir);
|
|
655
|
-
if (!
|
|
677
|
+
if (!versionNeedsUpgrade(version, requirement.minimum)) return;
|
|
656
678
|
|
|
657
679
|
console.error(
|
|
658
|
-
`\n Minimum supported
|
|
680
|
+
`\n Minimum supported ${requirement.label} version is ${requirement.minimum}. Your version is ${version}. Upgrade to get the best experience.\n`,
|
|
659
681
|
);
|
|
660
682
|
console.error(` Upgrade it with:`);
|
|
661
683
|
console.error(` ${c.cyan}${agent.install}${c.reset}`);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/bin/profiles.js
CHANGED
|
@@ -144,6 +144,28 @@ const SETTINGS = {
|
|
|
144
144
|
type: 'integer',
|
|
145
145
|
min: 1,
|
|
146
146
|
},
|
|
147
|
+
CODEX_SUBAGENT_REASONING_EFFORT: {
|
|
148
|
+
key: 'CODEX_SUBAGENT_REASONING_EFFORT',
|
|
149
|
+
label: 'Subagent reasoning effort',
|
|
150
|
+
description:
|
|
151
|
+
'Effort for Codex subagents, set separately from the parent: a marathon model at max thinks for minutes without emitting a token, and a subagent turn is one uninterrupted think, so inheriting max makes every delegated subtask look like a hang.',
|
|
152
|
+
type: 'text',
|
|
153
|
+
},
|
|
154
|
+
CODEX_MULTI_AGENT_VERSION: {
|
|
155
|
+
key: 'CODEX_MULTI_AGENT_VERSION',
|
|
156
|
+
label: 'Codex multi-agent version',
|
|
157
|
+
description:
|
|
158
|
+
'Which subagent implementation Codex offers: v2 gives the collaboration tools. Leave empty to turn subagents off entirely.',
|
|
159
|
+
type: 'text',
|
|
160
|
+
},
|
|
161
|
+
CODEX_STREAM_IDLE_TIMEOUT_MS: {
|
|
162
|
+
key: 'CODEX_STREAM_IDLE_TIMEOUT_MS',
|
|
163
|
+
label: 'Stream idle timeout (ms)',
|
|
164
|
+
description:
|
|
165
|
+
'How long Codex waits on a silent stream before giving up. Needs to exceed the longest think the model will take.',
|
|
166
|
+
type: 'integer',
|
|
167
|
+
min: 1,
|
|
168
|
+
},
|
|
147
169
|
MAX_SUBAGENT_SPAWN_DEPTH: {
|
|
148
170
|
key: 'MAX_SUBAGENT_SPAWN_DEPTH',
|
|
149
171
|
label: 'Subagent spawn depth',
|
|
@@ -305,6 +327,9 @@ const AGENT_SETTING_KEYS = {
|
|
|
305
327
|
'CODEX_AUTO_COMPACT_TOKEN_LIMIT',
|
|
306
328
|
'CODEX_REASONING_EFFORT',
|
|
307
329
|
'CODEX_EXTERNAL_TOOLS',
|
|
330
|
+
'CODEX_STREAM_IDLE_TIMEOUT_MS',
|
|
331
|
+
'CODEX_MULTI_AGENT_VERSION',
|
|
332
|
+
'CODEX_SUBAGENT_REASONING_EFFORT',
|
|
308
333
|
'MAX_CONCURRENT_SUBAGENTS',
|
|
309
334
|
],
|
|
310
335
|
opencode: ['OPENCODE_API_KEY', 'OPENCODE_CONTEXT_LIMIT', 'OPENCODE_OUTPUT_LIMIT'],
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
"uninstall"
|
|
168
168
|
]
|
|
169
169
|
},
|
|
170
|
-
"launch": "codex -c model={model} -c model_provider=subconscious -c web_search=disabled -c model_providers.subconscious.name=Subconscious -c model_providers.subconscious.base_url={baseUrlV1} -c model_providers.subconscious.wire_api=responses -c model_providers.subconscious.env_key=SUBCONSCIOUS_API_KEY -c model_providers.subconscious.stream_idle_timeout_ms=
|
|
170
|
+
"launch": "codex -c model={model} -c model_provider=subconscious -c web_search=disabled -c model_providers.subconscious.name=Subconscious -c model_providers.subconscious.base_url={baseUrlV1} -c model_providers.subconscious.wire_api=responses -c model_providers.subconscious.env_key=SUBCONSCIOUS_API_KEY -c model_providers.subconscious.stream_idle_timeout_ms=900000",
|
|
171
171
|
"env": {
|
|
172
172
|
"SUBCONSCIOUS_API_KEY": "{apiKey}",
|
|
173
173
|
"SUBCONSCIOUS_GATEWAY_URL": "{baseUrl}"
|
|
@@ -61,6 +61,30 @@ EOF
|
|
|
61
61
|
chmod 600 "$HOOKS_ENV_FILE"
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
# True when our hooks, hook script and env file are all already in place and
|
|
65
|
+
# current, so there is nothing to write.
|
|
66
|
+
#
|
|
67
|
+
# This matters more than it looks. Codex asks the user to trust a hook before
|
|
68
|
+
# it will run one, and it decides what is "new" from what is on disk. Rewriting
|
|
69
|
+
# an identical hook on every single launch meant the trust prompt never went
|
|
70
|
+
# away and the compaction hooks never actually ran - we were re-introducing
|
|
71
|
+
# ourselves as a stranger several times a day.
|
|
72
|
+
codex_hooks_current() {
|
|
73
|
+
[[ -f "$HOOKS_JSON" ]] || return 1
|
|
74
|
+
codex_hooks_json_valid || return 1
|
|
75
|
+
[[ -x "$HOOK_DST" ]] || return 1
|
|
76
|
+
[[ -f "${HOOK_SRC:-}" ]] || return 1
|
|
77
|
+
cmp -s "$HOOK_SRC" "$HOOK_DST" || return 1
|
|
78
|
+
[[ -f "$HOOKS_ENV_FILE" ]] || return 1
|
|
79
|
+
grep -q "SUBCONSCIOUS_GATEWAY_URL='${GATEWAY_URL%/}'" "$HOOKS_ENV_FILE" || return 1
|
|
80
|
+
grep -q "SUBCONSCIOUS_API_KEY='${API_KEY}'" "$HOOKS_ENV_FILE" || return 1
|
|
81
|
+
# Our entry present under both compaction events, and exactly once each.
|
|
82
|
+
jq -e --arg m "$MARKER" '
|
|
83
|
+
def ours: [ .[]?.hooks[]? | select((.command // "") | tostring | contains($m)) ] | length;
|
|
84
|
+
(.hooks.PreCompact | ours) == 1 and (.hooks.PostCompact | ours) == 1
|
|
85
|
+
' "$HOOKS_JSON" >/dev/null 2>&1
|
|
86
|
+
}
|
|
87
|
+
|
|
64
88
|
# codex_ensure_hooks [strict|best-effort]
|
|
65
89
|
codex_ensure_hooks() {
|
|
66
90
|
local mode="${1:-strict}"
|
|
@@ -91,12 +115,18 @@ codex_ensure_hooks() {
|
|
|
91
115
|
if [[ ! -f "$HOOKS_JSON" ]]; then
|
|
92
116
|
printf '%s\n' '{"hooks":{}}' >"$HOOKS_JSON"
|
|
93
117
|
fi
|
|
118
|
+
if codex_hooks_current; then
|
|
119
|
+
# Already installed and unchanged. Saying nothing is the point: a message
|
|
120
|
+
# on every launch trains the user to ignore it, and rewriting the file
|
|
121
|
+
# would reset the trust they have already granted.
|
|
122
|
+
return 0
|
|
123
|
+
fi
|
|
94
124
|
codex_write_hook_script
|
|
95
125
|
codex_write_hooks_env
|
|
96
126
|
codex_strip_hook_entries
|
|
97
127
|
codex_append_hook_groups
|
|
98
|
-
echo "
|
|
99
|
-
echo "
|
|
128
|
+
echo "Installed Subconscious compaction hooks in $HOOKS_JSON"
|
|
129
|
+
echo "These do not run until you trust them: type /hooks inside Codex once."
|
|
100
130
|
}
|
|
101
131
|
|
|
102
132
|
codex_uninstall_hooks() {
|
|
@@ -33,6 +33,16 @@ Usage:
|
|
|
33
33
|
|
|
34
34
|
Merges Subconscious compaction hooks into ~/.codex/hooks.json. Does not write
|
|
35
35
|
config.toml. Launch Codex with subc codex.
|
|
36
|
+
|
|
37
|
+
The hooks report compaction start and end to the gateway, which is what lets a
|
|
38
|
+
conversation's turns stay correlated across a compaction boundary.
|
|
39
|
+
|
|
40
|
+
Codex will not run a hook until you trust it. After installing, type /hooks
|
|
41
|
+
inside Codex once and approve them; until then they are present but inert.
|
|
42
|
+
Non-interactive runs have nobody to ask, so `codex exec` can only run them with
|
|
43
|
+
--dangerously-bypass-hook-trust, which is yours to opt into and is never passed
|
|
44
|
+
for you. Fleet installs should ship the hooks through Codex's managed
|
|
45
|
+
(MDM) configuration, which is trusted without prompting.
|
|
36
46
|
EOF
|
|
37
47
|
}
|
|
38
48
|
|
package/bin/runbook/codex/run.sh
CHANGED
|
@@ -6,20 +6,24 @@
|
|
|
6
6
|
# The model catalog (needed to suppress the "model metadata not found" warning)
|
|
7
7
|
# is written to a temp file that is cleaned up on exit.
|
|
8
8
|
#
|
|
9
|
-
# Subagents are
|
|
10
|
-
#
|
|
11
|
-
# "
|
|
12
|
-
#
|
|
9
|
+
# Subagents are ON by default. The per-model `multi_agent_version` catalog
|
|
10
|
+
# field selects WHICH implementation Codex offers, not whether it offers one:
|
|
11
|
+
# "v2" gives the `collaboration` namespace, and an empty value falls back to
|
|
12
|
+
# the older `multi_agent_v1` namespace rather than turning subagents off.
|
|
13
|
+
# Only `agents.enabled=false` actually disables them, so clearing
|
|
14
|
+
# CODEX_MULTI_AGENT_VERSION does both.
|
|
13
15
|
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
16
|
+
# This needs a gateway that round-trips Codex's namespaced tools. Codex sends
|
|
17
|
+
# them as `type: "namespace"` and resolves an incoming call by namespace plus
|
|
18
|
+
# name, so a gateway that flattens the namespace for the model must restore it
|
|
19
|
+
# on the way back, or every call fails with "unsupported call: spawn_agent".
|
|
17
20
|
#
|
|
18
21
|
# Usage:
|
|
19
22
|
# ./run.sh # uses GATEWAY_URL/API_KEY from ../.env
|
|
20
23
|
# ./run.sh --context-window 5000000 -- --resume
|
|
21
|
-
# ./run.sh --
|
|
22
|
-
# ./run.sh --subagents
|
|
24
|
+
# ./run.sh --stream-idle-timeout 1800000 # allow a 30min silent think
|
|
25
|
+
# ./run.sh --max-subagents 12 # raise the concurrent-subagent ceiling
|
|
26
|
+
# ./run.sh --subagent-effort low # cheaper subagents than the parent
|
|
23
27
|
# ./run.sh --external-tools # include Codex apps/plugins (may exceed gateway tool limits)
|
|
24
28
|
#
|
|
25
29
|
# Config: copy ../env.example to ../.env and edit. .env is gitignored.
|
|
@@ -41,16 +45,31 @@ if [[ -f "$SHARED_ENV" ]]; then set -a; source "$SHARED_ENV"; set +a; fi
|
|
|
41
45
|
GATEWAY_URL="${GATEWAY_URL:-}"
|
|
42
46
|
API_KEY="${CODEX_API_KEY:-${API_KEY:-}}"
|
|
43
47
|
MODEL="${MODEL:-subconscious/glm-5.3-marathon}"
|
|
44
|
-
MAX_CONCURRENT_SUBAGENTS="${MAX_CONCURRENT_SUBAGENTS:-
|
|
45
|
-
|
|
48
|
+
MAX_CONCURRENT_SUBAGENTS="${MAX_CONCURRENT_SUBAGENTS:-}"
|
|
49
|
+
# Effort for spawned agents, independent of the parent's. Empty inherits the
|
|
50
|
+
# Codex default. See the note above SUBAGENT_ARGS for why max is a poor choice.
|
|
51
|
+
#
|
|
52
|
+
# Low rather than medium: the gateway rounds medium up to high for GLM, and at
|
|
53
|
+
# high a subagent handed an open-ended task keeps deliberating without ever
|
|
54
|
+
# writing the closing `</think>`. The turn then comes back as one long block of
|
|
55
|
+
# prose with no tool call, so the agent reports success having produced no
|
|
56
|
+
# files. Measured against the worker on one broad task: low closed and called a
|
|
57
|
+
# tool in ~1.5k characters, high ran past 76k and was still going.
|
|
58
|
+
CODEX_SUBAGENT_REASONING_EFFORT="${CODEX_SUBAGENT_REASONING_EFFORT-low}"
|
|
46
59
|
EXTERNAL_TOOLS="${CODEX_EXTERNAL_TOOLS:-false}"
|
|
47
60
|
CODEX_CONTEXT_WINDOW="${CODEX_CONTEXT_WINDOW:-5000000}"
|
|
48
61
|
CODEX_MAX_CONTEXT_WINDOW="${CODEX_MAX_CONTEXT_WINDOW:-}"
|
|
49
62
|
CODEX_AUTO_COMPACT_TOKEN_LIMIT="${CODEX_AUTO_COMPACT_TOKEN_LIMIT:-4500000}"
|
|
50
63
|
CODEX_REASONING_EFFORT="${CODEX_REASONING_EFFORT:-max}"
|
|
51
|
-
|
|
52
|
-
#
|
|
53
|
-
|
|
64
|
+
# How long Codex waits on a silent stream before giving up. The marathon models
|
|
65
|
+
# at max reasoning effort routinely think for longer than five minutes without
|
|
66
|
+
# emitting a token, and a subagent's turn is one uninterrupted think with no
|
|
67
|
+
# visible progress, so the old 300s ceiling cut off work that was still running.
|
|
68
|
+
CODEX_STREAM_IDLE_TIMEOUT_MS="${CODEX_STREAM_IDLE_TIMEOUT_MS:-900000}"
|
|
69
|
+
# Codex gates its subagent tools on this per-model catalog field. Only "v2" is
|
|
70
|
+
# honored by current releases; "v1" registers nothing. Set to empty to opt out.
|
|
71
|
+
# Unset defaults to v2; an explicitly empty value opts out, so use `-` not `:-`.
|
|
72
|
+
CODEX_MULTI_AGENT_VERSION="${CODEX_MULTI_AGENT_VERSION-v2}"
|
|
54
73
|
|
|
55
74
|
# Parse args (only when executed, not sourced)
|
|
56
75
|
PASSTHRU=()
|
|
@@ -73,9 +92,17 @@ if [[ "${BASH_SOURCE[0]:-$0}" == "${0}" ]]; then
|
|
|
73
92
|
CODEX_REASONING_EFFORT="${2:-}"
|
|
74
93
|
shift 2
|
|
75
94
|
;;
|
|
76
|
-
--
|
|
77
|
-
|
|
78
|
-
shift
|
|
95
|
+
--stream-idle-timeout)
|
|
96
|
+
CODEX_STREAM_IDLE_TIMEOUT_MS="${2:-}"
|
|
97
|
+
shift 2
|
|
98
|
+
;;
|
|
99
|
+
--max-subagents)
|
|
100
|
+
MAX_CONCURRENT_SUBAGENTS="${2:-}"
|
|
101
|
+
shift 2
|
|
102
|
+
;;
|
|
103
|
+
--subagent-effort)
|
|
104
|
+
CODEX_SUBAGENT_REASONING_EFFORT="${2:-}"
|
|
105
|
+
shift 2
|
|
79
106
|
;;
|
|
80
107
|
--external-tools)
|
|
81
108
|
EXTERNAL_TOOLS=true
|
|
@@ -134,7 +161,10 @@ while IFS= read -r model_id; do
|
|
|
134
161
|
done <<< "${SUBCONSCIOUS_MODELS:-$DEFAULT_SUBCONSCIOUS_MODELS}"
|
|
135
162
|
|
|
136
163
|
write_model_catalog() {
|
|
137
|
-
local catalog_file="$1" model_id vision_fields index=0
|
|
164
|
+
local catalog_file="$1" model_id vision_fields index=0 multi_agent_json="null"
|
|
165
|
+
if [[ -n "$CODEX_MULTI_AGENT_VERSION" ]]; then
|
|
166
|
+
multi_agent_json="\"${CODEX_MULTI_AGENT_VERSION}\""
|
|
167
|
+
fi
|
|
138
168
|
{
|
|
139
169
|
printf '{\n "models": [\n'
|
|
140
170
|
for model_id in "${SUPPORTED_MODELS[@]}"; do
|
|
@@ -154,7 +184,13 @@ write_model_catalog() {
|
|
|
154
184
|
"max_context_window": ${CODEX_MAX_CONTEXT_WINDOW},
|
|
155
185
|
"auto_compact_token_limit": ${CODEX_AUTO_COMPACT_TOKEN_LIMIT},
|
|
156
186
|
"effective_context_window_percent": 95,
|
|
157
|
-
"supported_reasoning_levels": [
|
|
187
|
+
"supported_reasoning_levels": [
|
|
188
|
+
{ "effort": "none", "description": "No additional reasoning" },
|
|
189
|
+
{ "effort": "low", "description": "Fast responses with lighter reasoning" },
|
|
190
|
+
{ "effort": "medium", "description": "Balances speed and reasoning depth" },
|
|
191
|
+
{ "effort": "high", "description": "Greater reasoning depth for complex problems" },
|
|
192
|
+
{ "effort": "max", "description": "Maximum reasoning depth for the hardest problems" }
|
|
193
|
+
],
|
|
158
194
|
"shell_type": "shell_command",
|
|
159
195
|
"visibility": "list",
|
|
160
196
|
"supported_in_api": true,
|
|
@@ -175,6 +211,8 @@ write_model_catalog() {
|
|
|
175
211
|
"apply_patch_tool_type": "freeform",
|
|
176
212
|
"truncation_policy": { "mode": "tokens", "limit": 10000 },
|
|
177
213
|
"supports_parallel_tool_calls": true,
|
|
214
|
+
"multi_agent_version": ${multi_agent_json},
|
|
215
|
+
"use_responses_lite": false,
|
|
178
216
|
"experimental_supported_tools": []${vision_fields}
|
|
179
217
|
}
|
|
180
218
|
EOF
|
|
@@ -197,6 +235,41 @@ if [[ "$EXTERNAL_TOOLS" != "true" ]]; then
|
|
|
197
235
|
)
|
|
198
236
|
fi
|
|
199
237
|
|
|
238
|
+
# Bound the subagent tree when the catalog turns it on. Codex still only spawns
|
|
239
|
+
# a subagent when the user asks for one; these are ceilings, not defaults.
|
|
240
|
+
#
|
|
241
|
+
# Codex documents no nesting-depth limit, so a subagent can spawn its own
|
|
242
|
+
# subagent and the tree can grow deeper than you asked for. Capping concurrency
|
|
243
|
+
# is the only lever available.
|
|
244
|
+
#
|
|
245
|
+
# Subagent reasoning effort is set separately from the parent's on purpose: the
|
|
246
|
+
# marathon models at max effort think for many minutes without emitting a
|
|
247
|
+
# token, and a subagent turn is one uninterrupted think, so inheriting max
|
|
248
|
+
# makes every delegated subtask look like a hang.
|
|
249
|
+
# Applied after argument parsing so --max-subagents can win. Four is a floor
|
|
250
|
+
# rather than a considered limit: Codex's own default is three, and exceeding
|
|
251
|
+
# either one fails the spawn outright rather than queueing it, so a run that
|
|
252
|
+
# wants more should say so instead of collecting retries.
|
|
253
|
+
MAX_CONCURRENT_SUBAGENTS="${MAX_CONCURRENT_SUBAGENTS:-4}"
|
|
254
|
+
|
|
255
|
+
SUBAGENT_ARGS=()
|
|
256
|
+
if [[ -z "$CODEX_MULTI_AGENT_VERSION" ]]; then
|
|
257
|
+
# Clearing the catalog field alone only downgrades Codex to multi-agent v1,
|
|
258
|
+
# whose tools this gateway has never been exercised against. Turn the
|
|
259
|
+
# feature off outright instead.
|
|
260
|
+
SUBAGENT_ARGS=(-c agents.enabled=false)
|
|
261
|
+
else
|
|
262
|
+
SUBAGENT_ARGS=(
|
|
263
|
+
-c agents.max_concurrent_threads_per_session="${MAX_CONCURRENT_SUBAGENTS}"
|
|
264
|
+
-c agents.interrupt_message=true
|
|
265
|
+
)
|
|
266
|
+
if [[ -n "$CODEX_SUBAGENT_REASONING_EFFORT" ]]; then
|
|
267
|
+
SUBAGENT_ARGS+=(
|
|
268
|
+
-c agents.default_subagent_reasoning_effort="${CODEX_SUBAGENT_REASONING_EFFORT}"
|
|
269
|
+
)
|
|
270
|
+
fi
|
|
271
|
+
fi
|
|
272
|
+
|
|
200
273
|
if [[ -z "$GATEWAY_URL" || -z "$API_KEY" ]]; then
|
|
201
274
|
echo "error: GATEWAY_URL and API_KEY must be set in ../.env" >&2
|
|
202
275
|
exit 1
|
|
@@ -206,6 +279,10 @@ export SUBCONSCIOUS_API_KEY="$API_KEY"
|
|
|
206
279
|
export SUBCONSCIOUS_GATEWAY_URL="${GATEWAY_URL%/}"
|
|
207
280
|
|
|
208
281
|
# Merge compaction hooks without replacing ~/.codex/hooks.json or config.toml.
|
|
282
|
+
# `codex_ensure_hooks` returns early when they are already current, so a launch
|
|
283
|
+
# that changes nothing writes nothing: Codex decides what counts as a new hook
|
|
284
|
+
# from what is on disk, and rewriting an identical one reset the trust the user
|
|
285
|
+
# had already granted.
|
|
209
286
|
HOOK_SRC="${SCRIPT_DIR}/hook.sh"
|
|
210
287
|
# shellcheck source=hooks-lib.sh
|
|
211
288
|
source "${SCRIPT_DIR}/hooks-lib.sh"
|
|
@@ -220,43 +297,22 @@ write_model_catalog "$CATALOG_FILE"
|
|
|
220
297
|
|
|
221
298
|
# If sourced, just export env and return.
|
|
222
299
|
if [[ "${BASH_SOURCE[0]:-$0}" != "${0}" ]]; then
|
|
223
|
-
export GATEWAY_URL CATALOG_FILE MAX_CONCURRENT_SUBAGENTS
|
|
300
|
+
export GATEWAY_URL CATALOG_FILE MAX_CONCURRENT_SUBAGENTS CODEX_SUBAGENT_REASONING_EFFORT
|
|
224
301
|
return 0 2>/dev/null || true
|
|
225
302
|
fi
|
|
226
303
|
|
|
227
304
|
# Ephemeral config via -c flags — nothing is written to ~/.codex/config.toml.
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
-c model_providers.subconscious.name=Subconscious \
|
|
243
|
-
-c model_providers.subconscious.base_url="${GATEWAY_URL}/v1" \
|
|
244
|
-
-c model_providers.subconscious.wire_api=responses \
|
|
245
|
-
-c model_providers.subconscious.env_key=SUBCONSCIOUS_API_KEY \
|
|
246
|
-
-c model_providers.subconscious.stream_idle_timeout_ms=300000 \
|
|
247
|
-
${PASSTHRU[@]+"${PASSTHRU[@]}"}
|
|
248
|
-
else
|
|
249
|
-
exec codex \
|
|
250
|
-
-c model="${MODEL}" \
|
|
251
|
-
-c model_provider=subconscious \
|
|
252
|
-
-c model_catalog_json="${CATALOG_FILE}" \
|
|
253
|
-
-c model_reasoning_effort="${CODEX_REASONING_EFFORT}" \
|
|
254
|
-
-c web_search=disabled \
|
|
255
|
-
${EXTERNAL_TOOL_ARGS[@]+"${EXTERNAL_TOOL_ARGS[@]}"} \
|
|
256
|
-
-c model_providers.subconscious.name=Subconscious \
|
|
257
|
-
-c model_providers.subconscious.base_url="${GATEWAY_URL}/v1" \
|
|
258
|
-
-c model_providers.subconscious.wire_api=responses \
|
|
259
|
-
-c model_providers.subconscious.env_key=SUBCONSCIOUS_API_KEY \
|
|
260
|
-
-c model_providers.subconscious.stream_idle_timeout_ms=300000 \
|
|
261
|
-
${PASSTHRU[@]+"${PASSTHRU[@]}"}
|
|
262
|
-
fi
|
|
305
|
+
exec codex \
|
|
306
|
+
-c model="${MODEL}" \
|
|
307
|
+
-c model_provider=subconscious \
|
|
308
|
+
-c model_catalog_json="${CATALOG_FILE}" \
|
|
309
|
+
-c model_reasoning_effort="${CODEX_REASONING_EFFORT}" \
|
|
310
|
+
-c web_search=disabled \
|
|
311
|
+
${EXTERNAL_TOOL_ARGS[@]+"${EXTERNAL_TOOL_ARGS[@]}"} \
|
|
312
|
+
${SUBAGENT_ARGS[@]+"${SUBAGENT_ARGS[@]}"} \
|
|
313
|
+
-c model_providers.subconscious.name=Subconscious \
|
|
314
|
+
-c model_providers.subconscious.base_url="${GATEWAY_URL}/v1" \
|
|
315
|
+
-c model_providers.subconscious.wire_api=responses \
|
|
316
|
+
-c model_providers.subconscious.env_key=SUBCONSCIOUS_API_KEY \
|
|
317
|
+
-c model_providers.subconscious.stream_idle_timeout_ms="${CODEX_STREAM_IDLE_TIMEOUT_MS}" \
|
|
318
|
+
${PASSTHRU[@]+"${PASSTHRU[@]}"}
|
package/package.json
CHANGED