create-byan-agent 2.41.0 → 2.42.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.
@@ -0,0 +1,140 @@
1
+ # Codex Auto-Delegation
2
+
3
+ Hand delegable work to Codex on your **ChatGPT subscription** (no API credit)
4
+ when Claude nears its 5h limit — automatically, from inside Claude Code.
5
+
6
+ This is the native, opt-in layer on top of the Codex load-balancer pool
7
+ (`docs/loadbalancer-multipool.md`). It does not replace judgment: only delegable
8
+ work crosses the line.
9
+
10
+ ## What it does
11
+
12
+ Every turn, a `UserPromptSubmit` hook estimates how much of the Claude 5h window
13
+ you have burned and looks at the task you just asked for. If the task is
14
+ delegable (code / mechanical) — or if you are over the pressure threshold — BYAN
15
+ injects a one-line advisory nudge proposing you hand it to Codex via
16
+ `codex:codex-rescue --model gpt-5.4`. You still decide, and you still verify
17
+ Codex's output before commit.
18
+
19
+ Three triggers, in priority order:
20
+
21
+ 1. **Pressure** — estimated Claude 5h usage `>= threshold` (default **80%**) ->
22
+ propose offloading **everything** delegable this session.
23
+ 2. **Nature** — the request looks like delegable coding work -> propose handing
24
+ **that** task over. Works with no gauge at all.
25
+ 3. **Perf** (opt-in, off by default) — a configurable forces table says Codex is
26
+ reputed stronger for this kind of task. See "Perf routing" below.
27
+
28
+ **The red line** (held): only delegable natures are proposed. Judgment,
29
+ analysis, soul and verification stay on Claude.
30
+
31
+ ## Enable it
32
+
33
+ At install (`npx create-byan-agent`), the Codex step asks:
34
+
35
+ > Add Codex as a backup pool?
36
+
37
+ Before that optional backup-pool prompt, the yanstaller performs the native Codex
38
+ setup whenever Codex is selected (Codex-only or Claude+Codex):
39
+
40
+ 1. it writes the BYAN MCP entry into `~/.codex/config.toml`;
41
+ 2. it installs BYAN's native Codex skills into `~/.codex/skills`, including the
42
+ `byan` entrypoint skill used by `$byan`;
43
+ 3. it keeps the project-local `.codex/prompts/` stubs for backward
44
+ compatibility.
45
+
46
+ If `~/.codex` does not exist yet, the yanstaller creates it because Codex was
47
+ explicitly selected.
48
+
49
+ Those are separate from auto-delegation. Without the native skills, Codex may
50
+ have the MCP server wired but still fail to expose `$byan` / BYAN skill
51
+ invocations on a fresh machine.
52
+
53
+ Answer yes to the backup-pool prompt and it links your local Codex (the
54
+ `codex login` session — your ChatGPT subscription, **not** an API key) and writes
55
+ `_byan/_config/autodelegate.json`, which **arms** the hook. Without that file the
56
+ hook is a silent no-op (disarmed by default).
57
+
58
+ Non-interactive install: set `BYAN_CODEX_AUTODELEGATE=1`.
59
+
60
+ If Codex is not linked yet, the installer prints the device-flow to run on the
61
+ machine (needed on a headless server, where the default localhost browser
62
+ redirect fails):
63
+
64
+ ```
65
+ codex login --device-auth
66
+ ```
67
+
68
+ then re-run the installer.
69
+
70
+ ### The entitled model (why gpt-5.4)
71
+
72
+ On a ChatGPT subscription the OpenAI backend rejects every `-codex`-suffixed
73
+ model (`gpt-5-codex`, `gpt-5.x-codex`) — those ids are API-key only. The plain
74
+ `gpt-5.x` family (e.g. `gpt-5.4`) is the entitled one. That is why the invocation
75
+ pins `--model gpt-5.4`. See `src/loadbalancer/providers/codex-provider.js`
76
+ (`resolveCodexModel`).
77
+
78
+ ## Configure it
79
+
80
+ `_byan/_config/autodelegate.json`:
81
+
82
+ | Key | Default | Meaning |
83
+ |-----|---------|---------|
84
+ | `enabled` | `true` (once written) | Master switch. Delete the file or set `false` to disarm. |
85
+ | `threshold` | `80` | Pressure percentage that flips to "offload everything delegable". |
86
+ | `budget` | `null` | Your plan's rough token ceiling for the 5h window. Without it, `pct` is null and only the nature trigger fires (see caveat). |
87
+ | `invocation` | `codex:codex-rescue --model gpt-5.4` | What the nudge tells BYAN to run. |
88
+ | `perfRouting` | `false` | Enable the perf trigger. |
89
+ | `perfForces` | `[]` | The forces table (see below). |
90
+
91
+ Session escape hatch: `touch .byan-codex-autodelegate/off` silences the nudge
92
+ without editing the config; remove it to re-enable.
93
+
94
+ ## The honest caveats
95
+
96
+ - **The 5h gauge is an ESTIMATE, not Anthropic's number.** No provider exposes a
97
+ machine-readable 5h quota; `/usage` fetches the authoritative figure live and
98
+ does not persist it. The estimator sums the real per-message token counts from
99
+ your local transcripts (`~/.claude/projects/*/*.jsonl`) over the rolling 5h
100
+ window, weighting cache reads at 0.1 (they are billed roughly a tenth and
101
+ repeat every turn). It is proportional, not exact — and `pct` is only computed
102
+ when you set a `budget`. Without a budget, delegation runs on the nature
103
+ trigger alone.
104
+ - **`~/.claude` is a native accelerator, not a source of truth** (PORTABLE-3).
105
+ If it is absent the estimator degrades to `pct: null` and the feature falls
106
+ back to nature-based delegation. The feature keeps working.
107
+ - **Perf routing is a heuristic below the L2 floor.** "Model X is better at task
108
+ Y" is a performance claim; BYAN's fact-check floor for performance is L2 (a
109
+ reproducible benchmark). A community arena such as designarena.ai is weaker
110
+ than that. So the forces table ships empty — it asserts nothing until you
111
+ populate it, and every match is tagged `heuristic`, not presented as measured.
112
+
113
+ ## Perf routing (opt-in)
114
+
115
+ Set `perfRouting: true` and fill `perfForces` with entries:
116
+
117
+ ```json
118
+ {
119
+ "perfRouting": true,
120
+ "perfForces": [
121
+ { "category": "bulk-refactor", "pattern": "rename across|codemod", "favors": "codex" }
122
+ ]
123
+ }
124
+ ```
125
+
126
+ `pattern` is a case-insensitive regex matched against your request. `favors:
127
+ "codex"` pushes a delegation nudge even below the pressure threshold. Populate it
128
+ from your own benchmarks, or from an arena taken as a weak signal — BYAN tags it
129
+ heuristic either way.
130
+
131
+ ## Files
132
+
133
+ | Piece | File |
134
+ |-------|------|
135
+ | Usage estimator | `.claude/hooks/lib/usage-estimator.js` |
136
+ | Decision core + nudge | `.claude/hooks/lib/autodelegate-decision.js` |
137
+ | Perf routing | `.claude/hooks/lib/perf-routing.js` |
138
+ | Hook | `.claude/hooks/codex-autodelegate.js` |
139
+ | Installer opt-in | `install/lib/codex-autodelegate-setup.js` |
140
+ | Native Codex MCP + skills setup | `install/lib/codex-native-setup.js` |
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "create-byan-agent",
3
- "version": "2.41.0",
3
+ "version": "2.42.0",
4
4
  "description": "BYAN v2.8 - Intelligent AI agent creator with ELO trust system + scientific fact-check + Hermes universal dispatcher + native Claude Code integration (hooks, skills, MCP server). Multi-platform (Claude Code, Codex). Merise Agile + TDD + 71 Mantras. ~54% LLM cost savings.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
7
7
  "create-byan-agent": "./install/bin/create-byan-agent-v2.js",
8
8
  "byan-v2": "./install/bin/create-byan-agent-v2.js",
9
9
  "byan-cleanup": "./install/bin/byan-cleanup.js",
10
+ "byan-handoff": "./install/bin/byan-handoff.js",
10
11
  "byan-ledger": "./install/bin/byan-ledger.js",
11
12
  "byan-kanban": "./install/bin/byan-kanban.js",
12
13
  "update-byan-agent": "./update-byan-agent/bin/update-byan-agent.js"