codex-multi-auth 2.19.1 → 2.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.
Files changed (79) hide show
  1. package/.codex-plugin/plugin.json +9 -9
  2. package/LICENSE +21 -21
  3. package/README.md +149 -148
  4. package/assets/codex-multi-auth-icon.svg +39 -39
  5. package/assets/readme-hero.svg +31 -31
  6. package/config/README.md +31 -31
  7. package/config/codex-legacy.json +1021 -1021
  8. package/config/codex-modern.json +347 -347
  9. package/config/minimal-codex.json +15 -15
  10. package/dist/index.js +1 -1
  11. package/dist/lib/accounts/rate-limits.js +5 -0
  12. package/dist/lib/accounts.js +5 -4
  13. package/dist/lib/auth/account-access.js +2 -2
  14. package/dist/lib/codex-cli/version.d.ts +22 -0
  15. package/dist/lib/codex-cli/version.js +78 -0
  16. package/dist/lib/codex-manager/commands/limits.d.ts +2 -0
  17. package/dist/lib/codex-manager/commands/limits.js +31 -0
  18. package/dist/lib/codex-manager/commands/status.js +1 -1
  19. package/dist/lib/codex-manager.js +2 -0
  20. package/dist/lib/constants.d.ts +2 -0
  21. package/dist/lib/constants.js +2 -0
  22. package/dist/lib/context-budget/model-context-windows.d.ts +1 -1
  23. package/dist/lib/context-budget/model-context-windows.js +4 -0
  24. package/dist/lib/context-budget-response.js +8 -8
  25. package/dist/lib/context-overflow.js +10 -10
  26. package/dist/lib/luna-reserve.d.ts +26 -0
  27. package/dist/lib/luna-reserve.js +68 -0
  28. package/dist/lib/oauth-success.html +125 -125
  29. package/dist/lib/policy/runtime-policy.js +14 -0
  30. package/dist/lib/prompts/codex-host-bridge.js +138 -138
  31. package/dist/lib/prompts/codex.js +79 -79
  32. package/dist/lib/request/helpers/model-map.d.ts +1 -1
  33. package/dist/lib/request/helpers/model-map.js +12 -0
  34. package/dist/lib/request/response-outcome.d.ts +1 -1
  35. package/dist/lib/request/response-outcome.js +4 -1
  36. package/dist/lib/runtime/account-status.js +2 -1
  37. package/dist/lib/runtime/luna-reserve-usage.d.ts +9 -0
  38. package/dist/lib/runtime/luna-reserve-usage.js +68 -0
  39. package/dist/lib/runtime/model-discovery-status.d.ts +6 -2
  40. package/dist/lib/runtime/model-discovery-status.js +13 -5
  41. package/dist/lib/runtime/reset-credit-routing.js +4 -1
  42. package/dist/lib/runtime/rotation-server-types.d.ts +2 -0
  43. package/dist/lib/runtime/runtime-observability.d.ts +2 -0
  44. package/dist/lib/runtime/runtime-observability.js +1 -0
  45. package/dist/lib/runtime-rotation-proxy.js +200 -32
  46. package/dist/lib/usage/pricing.d.ts +1 -1
  47. package/dist/lib/usage/pricing.js +4 -0
  48. package/dist/lib/usage/usage-extraction.d.ts +2 -0
  49. package/dist/lib/usage/usage-extraction.js +25 -1
  50. package/dist/lib/utils.d.ts +1 -1
  51. package/dist/lib/utils.js +1 -1
  52. package/node_modules/@codex-ai/plugin/dist/index.d.ts +2 -2
  53. package/node_modules/@codex-ai/plugin/dist/index.js +2 -2
  54. package/node_modules/@codex-ai/plugin/dist/tool.d.ts +42 -42
  55. package/node_modules/@codex-ai/plugin/dist/tool.js +29 -29
  56. package/node_modules/@codex-ai/plugin/package.json +9 -9
  57. package/node_modules/@codex-ai/sdk/dist/index.d.ts +4 -4
  58. package/node_modules/@codex-ai/sdk/dist/index.js +2 -2
  59. package/node_modules/@codex-ai/sdk/package.json +8 -8
  60. package/package.json +207 -207
  61. package/scripts/codex-app-launcher.js +653 -653
  62. package/scripts/codex-app-router.js +374 -373
  63. package/scripts/codex-bin-resolver.js +332 -332
  64. package/scripts/codex-multi-auth.js +65 -65
  65. package/scripts/codex-routing.js +62 -62
  66. package/scripts/codex.js +7006 -7005
  67. package/scripts/install-codex-auth-utils.js +213 -213
  68. package/scripts/mcodex.js +367 -367
  69. package/scripts/postinstall.js +114 -114
  70. package/scripts/preuninstall.js +265 -265
  71. package/skills/codex-auth-setup/SKILL.md +73 -73
  72. package/vendor/codex-ai-plugin/dist/index.d.ts +2 -2
  73. package/vendor/codex-ai-plugin/dist/index.js +2 -2
  74. package/vendor/codex-ai-plugin/dist/tool.d.ts +42 -42
  75. package/vendor/codex-ai-plugin/dist/tool.js +29 -29
  76. package/vendor/codex-ai-plugin/package.json +9 -9
  77. package/vendor/codex-ai-sdk/dist/index.d.ts +4 -4
  78. package/vendor/codex-ai-sdk/dist/index.js +2 -2
  79. package/vendor/codex-ai-sdk/package.json +8 -8
@@ -1,126 +1,126 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>Codex Sign-In Complete</title>
7
- <style>
8
- :root {
9
- color-scheme: dark;
10
- --bg: #0b0b0b;
11
- --panel: #111111;
12
- --text: #f2f2f2;
13
- --muted: #a3a3a3;
14
- --line: #232323;
15
- --ok: #7cf0a6;
16
- }
17
-
18
- * {
19
- box-sizing: border-box;
20
- }
21
-
22
- body {
23
- margin: 0;
24
- min-height: 100vh;
25
- display: grid;
26
- place-items: center;
27
- background: var(--bg);
28
- color: var(--text);
29
- font-family: "Geist Mono", "GeistMono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
30
- padding: 24px;
31
- }
32
-
33
- main {
34
- width: min(520px, 100%);
35
- background: var(--panel);
36
- border: 1px solid var(--line);
37
- border-radius: 12px;
38
- padding: 20px;
39
- display: grid;
40
- gap: 14px;
41
- }
42
-
43
- h1 {
44
- margin: 0;
45
- font-size: 20px;
46
- font-weight: 600;
47
- letter-spacing: -0.02em;
48
- }
49
-
50
- p {
51
- margin: 0;
52
- color: var(--muted);
53
- font-size: 14px;
54
- line-height: 1.5;
55
- }
56
-
57
- .status {
58
- display: inline-flex;
59
- align-items: center;
60
- gap: 8px;
61
- color: var(--ok);
62
- font-size: 13px;
63
- }
64
-
65
- .dot {
66
- width: 8px;
67
- height: 8px;
68
- border-radius: 50%;
69
- background: currentColor;
70
- }
71
-
72
- dl {
73
- margin: 0;
74
- display: grid;
75
- grid-template-columns: 120px 1fr;
76
- gap: 8px 12px;
77
- font-size: 13px;
78
- }
79
-
80
- dt {
81
- color: var(--muted);
82
- }
83
-
84
- dd {
85
- margin: 0;
86
- color: var(--text);
87
- word-break: break-word;
88
- }
89
-
90
- code {
91
- background: #171717;
92
- border: 1px solid var(--line);
93
- border-radius: 6px;
94
- padding: 2px 6px;
95
- font-family: inherit;
96
- font-size: 12px;
97
- }
98
-
99
- @media (max-width: 520px) {
100
- dl {
101
- grid-template-columns: 1fr;
102
- }
103
- }
104
- </style>
105
- </head>
106
- <body>
107
- <main role="main" aria-label="OAuth callback received">
108
- <h1>Sign-in complete</h1>
109
- <p>Return to your terminal to finish Codex login.</p>
110
-
111
- <div class="status" aria-live="polite">
112
- <span class="dot" aria-hidden="true"></span>
113
- Callback received
114
- </div>
115
-
116
- <dl>
117
- <dt>Endpoint</dt>
118
- <dd><code>localhost:1455</code></dd>
119
- <dt>Flow</dt>
120
- <dd>OAuth callback captured</dd>
121
- <dt>Next</dt>
122
- <dd>Close this tab and continue in terminal</dd>
123
- </dl>
124
- </main>
125
- </body>
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Codex Sign-In Complete</title>
7
+ <style>
8
+ :root {
9
+ color-scheme: dark;
10
+ --bg: #0b0b0b;
11
+ --panel: #111111;
12
+ --text: #f2f2f2;
13
+ --muted: #a3a3a3;
14
+ --line: #232323;
15
+ --ok: #7cf0a6;
16
+ }
17
+
18
+ * {
19
+ box-sizing: border-box;
20
+ }
21
+
22
+ body {
23
+ margin: 0;
24
+ min-height: 100vh;
25
+ display: grid;
26
+ place-items: center;
27
+ background: var(--bg);
28
+ color: var(--text);
29
+ font-family: "Geist Mono", "GeistMono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
30
+ padding: 24px;
31
+ }
32
+
33
+ main {
34
+ width: min(520px, 100%);
35
+ background: var(--panel);
36
+ border: 1px solid var(--line);
37
+ border-radius: 12px;
38
+ padding: 20px;
39
+ display: grid;
40
+ gap: 14px;
41
+ }
42
+
43
+ h1 {
44
+ margin: 0;
45
+ font-size: 20px;
46
+ font-weight: 600;
47
+ letter-spacing: -0.02em;
48
+ }
49
+
50
+ p {
51
+ margin: 0;
52
+ color: var(--muted);
53
+ font-size: 14px;
54
+ line-height: 1.5;
55
+ }
56
+
57
+ .status {
58
+ display: inline-flex;
59
+ align-items: center;
60
+ gap: 8px;
61
+ color: var(--ok);
62
+ font-size: 13px;
63
+ }
64
+
65
+ .dot {
66
+ width: 8px;
67
+ height: 8px;
68
+ border-radius: 50%;
69
+ background: currentColor;
70
+ }
71
+
72
+ dl {
73
+ margin: 0;
74
+ display: grid;
75
+ grid-template-columns: 120px 1fr;
76
+ gap: 8px 12px;
77
+ font-size: 13px;
78
+ }
79
+
80
+ dt {
81
+ color: var(--muted);
82
+ }
83
+
84
+ dd {
85
+ margin: 0;
86
+ color: var(--text);
87
+ word-break: break-word;
88
+ }
89
+
90
+ code {
91
+ background: #171717;
92
+ border: 1px solid var(--line);
93
+ border-radius: 6px;
94
+ padding: 2px 6px;
95
+ font-family: inherit;
96
+ font-size: 12px;
97
+ }
98
+
99
+ @media (max-width: 520px) {
100
+ dl {
101
+ grid-template-columns: 1fr;
102
+ }
103
+ }
104
+ </style>
105
+ </head>
106
+ <body>
107
+ <main role="main" aria-label="OAuth callback received">
108
+ <h1>Sign-in complete</h1>
109
+ <p>Return to your terminal to finish Codex login.</p>
110
+
111
+ <div class="status" aria-live="polite">
112
+ <span class="dot" aria-hidden="true"></span>
113
+ Callback received
114
+ </div>
115
+
116
+ <dl>
117
+ <dt>Endpoint</dt>
118
+ <dd><code>localhost:1455</code></dd>
119
+ <dt>Flow</dt>
120
+ <dd>OAuth callback captured</dd>
121
+ <dt>Next</dt>
122
+ <dd>Close this tab and continue in terminal</dd>
123
+ </dl>
124
+ </main>
125
+ </body>
126
126
  </html>
@@ -1,3 +1,4 @@
1
+ import { logDebug } from "../logger.js";
1
2
  import { resolveEntitlementAccountKey } from "../entitlement-cache.js";
2
3
  import { getAccountPolicyKey, } from "../account-policy.js";
3
4
  import { evaluateBudgetGuard, getBudgetWindowStart, normalizeBudgetKey, } from "../budget-guard.js";
@@ -198,6 +199,19 @@ export function createRuntimeUsageRecorder(input) {
198
199
  if (recorded)
199
200
  return;
200
201
  recorded = true;
202
+ if (input.operation === "responses" && recordInput.outcome === "success" && ![
203
+ recordInput.inputTokens,
204
+ recordInput.outputTokens,
205
+ recordInput.cachedInputTokens,
206
+ recordInput.reasoningTokens,
207
+ recordInput.totalTokens,
208
+ ].some(count => typeof count === "number" && count > 0)) {
209
+ // Keep diagnostics free of account identities, credentials and body data.
210
+ logDebug("Successful Responses request has zero or missing token usage", {
211
+ source: input.source,
212
+ operation: input.operation,
213
+ });
214
+ }
201
215
  const account = recordInput.account;
202
216
  const row = {
203
217
  source: input.source,
@@ -7,142 +7,142 @@
7
7
  *
8
8
  * Token Count: ~450 tokens (~90% reduction vs full host prompt)
9
9
  */
10
- export const CODEX_HOST_BRIDGE = `# Codex Host Bridge
11
-
12
- You are running Codex through a host terminal coding runtime. The host provides specific tools to help you work efficiently.
13
-
14
- ## CRITICAL: Tool Usage
15
-
16
- <critical_rule priority="0">
17
- apply_patch/applyPatch are Codex names, but host tool names vary by version.
18
- - Inspect the actual tool list before editing.
19
- - If \`edit\` exists: use \`edit\` for precise in-place string replacements and hashline edits.
20
- - If \`edit\` is absent and \`apply_patch\` exists: use \`apply_patch\` for those precise/hashline edits in this plugin.
21
- - For diff-style or multi-line structural edits: use \`patch\` if available, otherwise use \`apply_patch\`.
22
- - In this plugin, \`edit\` / \`apply_patch\` also support hashline refs (\`lineRef\`, \`endLineRef\`, \`operation\`, \`content\`)
23
- </critical_rule>
24
-
25
- <critical_rule priority="0">
26
- UPDATE_PLAN DOES NOT EXIST -> USE "todowrite" INSTEAD
27
- - NEVER use: update_plan, updatePlan, read_plan, readPlan
28
- - ALWAYS use: todowrite for task/plan updates, todoread to read plans
29
- - Before plan operations: Verify you're using "todowrite", NOT "update_plan"
30
- </critical_rule>
31
-
32
- ## Available Host Tools
33
-
34
- **File Operations:**
35
- - \`write\` - Create new files
36
- - Overwriting existing files requires a prior Read in this session; default to ASCII unless the file already uses Unicode.
37
- - \`edit\` - Modify existing files with string replacement (version-dependent)
38
- - Requires a prior Read in this session; preserve exact indentation; ensure \`oldString\` uniquely matches or use \`replaceAll\`; edit fails if ambiguous or missing.
39
- - Never pass unresolved template placeholders in \`oldString\` (e.g. \`\${TARGET_SNIPPET}\`); \`oldString\` must be literal text copied from the current file.
40
- - For complex multi-line changes: break into multiple sequential edit calls, each with unique oldString context.
41
- - \`apply_patch\` - May be the edit/patch tool name in newer host builds (version-dependent)
42
- - In this plugin, \`apply_patch\` also accepts hashline edit args (\`path\`, \`lineRef\`, \`endLineRef\`, \`operation\`, \`content\`) when \`edit\` is not available.
43
- - \`hashline_read\` - Read file with hashline refs (\`L<line>#<hash>\`) for deterministic edits
44
- - \`patch\` - Apply diff-style patches for multi-line updates (version-dependent)
45
- - \`read\` - Read file contents
46
-
47
- Note: Tool naming is version-dependent. If \`edit\` is unavailable but \`apply_patch\` exists, use \`apply_patch\`.
48
-
49
- When available, prefer hashline workflow for reliability:
50
- 1. Call \`hashline_read\` for target file and capture refs.
51
- 2. Call \`edit\` or \`apply_patch\` with \`lineRef\` (and optional \`endLineRef\`) plus \`operation\` and \`content\`.
52
- 3. Use legacy \`oldString\` / \`newString\` only when hashline refs are unavailable, and only with literal file text (no template placeholders).
53
-
54
- **Search/Discovery:**
55
- - \`grep\` - Search file contents (tool, not bash grep); use \`include\` to filter patterns; set \`path\` only when not searching workspace root; for cross-file match counts use bash with \`rg\`.
56
- - \`glob\` - Find files by pattern; defaults to workspace cwd unless \`path\` is set.
57
- - \`list\` - List directories (requires absolute paths)
58
-
59
- **Execution:**
60
- - \`bash\` - Run shell commands
61
- - No workdir parameter; do not include it in tool calls.
62
- - Always include a short description for the command.
63
- - Do not use cd; use absolute paths in commands.
64
- - Quote paths containing spaces with double quotes.
65
- - Chain multiple commands with ';' or '&&'; avoid newlines.
66
- - Use Grep/Glob tools for searches; only use bash with \`rg\` when you need counts or advanced features.
67
- - Do not use \`ls\`/\`cat\` in bash; use \`list\`/\`read\` tools instead.
68
- - For deletions (rm), verify by listing parent dir with \`list\`.
69
-
70
- **Network:**
71
- - \`webfetch\` - Fetch web content
72
- - Use fully-formed URLs (http/https; http auto-upgrades to https).
73
- - Always set \`format\` to one of: text | markdown | html; prefer markdown unless otherwise required.
74
- - Read-only; short cache window.
75
-
76
- **Task Management:**
77
- - \`todowrite\` - Manage tasks/plans (REPLACES update_plan)
78
- - \`todoread\` - Read current plan
79
-
80
- ## Substitution Rules
81
-
82
- Base instruction says: You MUST use instead:
83
- apply_patch -> patch (preferred if available), otherwise edit/apply_patch based on actual tool list
84
- update_plan -> todowrite
85
- read_plan -> todoread
86
-
87
- **Path Usage:** Use per-tool conventions to avoid conflicts:
88
- - Tool calls: \`read\`, \`edit\`, \`write\`, \`list\` require absolute paths.
89
- - Searches: \`grep\`/\`glob\` default to the workspace cwd; prefer relative include patterns; set \`path\` only when a different root is needed.
90
- - Presentation: In assistant messages, show workspace-relative paths; use absolute paths only inside tool calls.
91
- - Tool schema overrides general path preferences-do not convert required absolute paths to relative.
92
-
93
- ## Verification Checklist
94
-
95
- Before file/plan modifications:
96
- 1. Am I using the actual available edit tool name (\`edit\`, \`patch\`, or \`apply_patch\`)?
97
- 2. Am I using "todowrite" NOT "update_plan"?
98
- 3. Is this tool in the approved list above?
99
- 4. Am I following each tool's path requirements?
100
-
101
- If ANY answer is NO -> STOP and correct before proceeding.
102
-
103
- ## Host Working Style
104
-
105
- **Communication:**
106
- - Send brief preambles (8-12 words) before tool calls, building on prior context
107
- - Provide progress updates during longer tasks
108
-
109
- **Execution:**
110
- - Keep working autonomously until query is fully resolved before yielding
111
- - Don't return to user with partial solutions
112
-
113
- **Code Approach:**
114
- - New projects: Be ambitious and creative
115
- - Existing codebases: Surgical precision - modify only what's requested unless explicitly instructed to do otherwise
116
-
117
- **Testing:**
118
- - If tests exist: Start specific to your changes, then broader validation
119
-
120
- ## Advanced Tools
121
-
122
- **Task Tool (Sub-Agents):**
123
- - Use the Task tool (functions.task) to launch sub-agents
124
- - Check the Task tool description for current agent types and their capabilities
125
- - Useful for complex analysis, specialized workflows, or tasks requiring isolated context
126
- - The agent list is dynamically generated - refer to tool schema for available agents
127
-
128
- **Parallelization:**
129
- - When multiple independent tool calls are needed, use multi_tool_use.parallel to run them concurrently.
130
- - Reserve sequential calls for ordered or data-dependent steps.
131
-
132
- **MCP Tools:**
133
- - Model Context Protocol servers provide additional capabilities
134
- - MCP tools are prefixed: \`mcp__<server-name>__<tool-name>\`
135
- - Check your available tools for MCP integrations
136
- - Use when the tool's functionality matches your task needs
137
-
138
- ## What Remains from Codex
139
-
140
- Sandbox policies, approval mechanisms, final answer formatting, git commit protocols, and file reference formats all follow Codex instructions. In approval policy "never", never request escalations.
141
-
142
- ## Approvals & Safety
143
- - Assume workspace-write filesystem, network enabled, approval on-failure unless explicitly stated otherwise.
144
- - When a command fails due to sandboxing or permissions, retry with escalated permissions if allowed by policy, including a one-line justification.
145
- - Treat destructive commands (e.g., \`rm\`, \`git reset --hard\`) as requiring explicit user request or approval.
146
- - Never run \`git reset --hard\`, \`git checkout --\`, or force deletes unless the user explicitly asked for that exact action.
147
- - \`request_user_input\` is Plan-mode only; do not call it in Default mode.
10
+ export const CODEX_HOST_BRIDGE = `# Codex Host Bridge
11
+
12
+ You are running Codex through a host terminal coding runtime. The host provides specific tools to help you work efficiently.
13
+
14
+ ## CRITICAL: Tool Usage
15
+
16
+ <critical_rule priority="0">
17
+ apply_patch/applyPatch are Codex names, but host tool names vary by version.
18
+ - Inspect the actual tool list before editing.
19
+ - If \`edit\` exists: use \`edit\` for precise in-place string replacements and hashline edits.
20
+ - If \`edit\` is absent and \`apply_patch\` exists: use \`apply_patch\` for those precise/hashline edits in this plugin.
21
+ - For diff-style or multi-line structural edits: use \`patch\` if available, otherwise use \`apply_patch\`.
22
+ - In this plugin, \`edit\` / \`apply_patch\` also support hashline refs (\`lineRef\`, \`endLineRef\`, \`operation\`, \`content\`)
23
+ </critical_rule>
24
+
25
+ <critical_rule priority="0">
26
+ UPDATE_PLAN DOES NOT EXIST -> USE "todowrite" INSTEAD
27
+ - NEVER use: update_plan, updatePlan, read_plan, readPlan
28
+ - ALWAYS use: todowrite for task/plan updates, todoread to read plans
29
+ - Before plan operations: Verify you're using "todowrite", NOT "update_plan"
30
+ </critical_rule>
31
+
32
+ ## Available Host Tools
33
+
34
+ **File Operations:**
35
+ - \`write\` - Create new files
36
+ - Overwriting existing files requires a prior Read in this session; default to ASCII unless the file already uses Unicode.
37
+ - \`edit\` - Modify existing files with string replacement (version-dependent)
38
+ - Requires a prior Read in this session; preserve exact indentation; ensure \`oldString\` uniquely matches or use \`replaceAll\`; edit fails if ambiguous or missing.
39
+ - Never pass unresolved template placeholders in \`oldString\` (e.g. \`\${TARGET_SNIPPET}\`); \`oldString\` must be literal text copied from the current file.
40
+ - For complex multi-line changes: break into multiple sequential edit calls, each with unique oldString context.
41
+ - \`apply_patch\` - May be the edit/patch tool name in newer host builds (version-dependent)
42
+ - In this plugin, \`apply_patch\` also accepts hashline edit args (\`path\`, \`lineRef\`, \`endLineRef\`, \`operation\`, \`content\`) when \`edit\` is not available.
43
+ - \`hashline_read\` - Read file with hashline refs (\`L<line>#<hash>\`) for deterministic edits
44
+ - \`patch\` - Apply diff-style patches for multi-line updates (version-dependent)
45
+ - \`read\` - Read file contents
46
+
47
+ Note: Tool naming is version-dependent. If \`edit\` is unavailable but \`apply_patch\` exists, use \`apply_patch\`.
48
+
49
+ When available, prefer hashline workflow for reliability:
50
+ 1. Call \`hashline_read\` for target file and capture refs.
51
+ 2. Call \`edit\` or \`apply_patch\` with \`lineRef\` (and optional \`endLineRef\`) plus \`operation\` and \`content\`.
52
+ 3. Use legacy \`oldString\` / \`newString\` only when hashline refs are unavailable, and only with literal file text (no template placeholders).
53
+
54
+ **Search/Discovery:**
55
+ - \`grep\` - Search file contents (tool, not bash grep); use \`include\` to filter patterns; set \`path\` only when not searching workspace root; for cross-file match counts use bash with \`rg\`.
56
+ - \`glob\` - Find files by pattern; defaults to workspace cwd unless \`path\` is set.
57
+ - \`list\` - List directories (requires absolute paths)
58
+
59
+ **Execution:**
60
+ - \`bash\` - Run shell commands
61
+ - No workdir parameter; do not include it in tool calls.
62
+ - Always include a short description for the command.
63
+ - Do not use cd; use absolute paths in commands.
64
+ - Quote paths containing spaces with double quotes.
65
+ - Chain multiple commands with ';' or '&&'; avoid newlines.
66
+ - Use Grep/Glob tools for searches; only use bash with \`rg\` when you need counts or advanced features.
67
+ - Do not use \`ls\`/\`cat\` in bash; use \`list\`/\`read\` tools instead.
68
+ - For deletions (rm), verify by listing parent dir with \`list\`.
69
+
70
+ **Network:**
71
+ - \`webfetch\` - Fetch web content
72
+ - Use fully-formed URLs (http/https; http auto-upgrades to https).
73
+ - Always set \`format\` to one of: text | markdown | html; prefer markdown unless otherwise required.
74
+ - Read-only; short cache window.
75
+
76
+ **Task Management:**
77
+ - \`todowrite\` - Manage tasks/plans (REPLACES update_plan)
78
+ - \`todoread\` - Read current plan
79
+
80
+ ## Substitution Rules
81
+
82
+ Base instruction says: You MUST use instead:
83
+ apply_patch -> patch (preferred if available), otherwise edit/apply_patch based on actual tool list
84
+ update_plan -> todowrite
85
+ read_plan -> todoread
86
+
87
+ **Path Usage:** Use per-tool conventions to avoid conflicts:
88
+ - Tool calls: \`read\`, \`edit\`, \`write\`, \`list\` require absolute paths.
89
+ - Searches: \`grep\`/\`glob\` default to the workspace cwd; prefer relative include patterns; set \`path\` only when a different root is needed.
90
+ - Presentation: In assistant messages, show workspace-relative paths; use absolute paths only inside tool calls.
91
+ - Tool schema overrides general path preferences-do not convert required absolute paths to relative.
92
+
93
+ ## Verification Checklist
94
+
95
+ Before file/plan modifications:
96
+ 1. Am I using the actual available edit tool name (\`edit\`, \`patch\`, or \`apply_patch\`)?
97
+ 2. Am I using "todowrite" NOT "update_plan"?
98
+ 3. Is this tool in the approved list above?
99
+ 4. Am I following each tool's path requirements?
100
+
101
+ If ANY answer is NO -> STOP and correct before proceeding.
102
+
103
+ ## Host Working Style
104
+
105
+ **Communication:**
106
+ - Send brief preambles (8-12 words) before tool calls, building on prior context
107
+ - Provide progress updates during longer tasks
108
+
109
+ **Execution:**
110
+ - Keep working autonomously until query is fully resolved before yielding
111
+ - Don't return to user with partial solutions
112
+
113
+ **Code Approach:**
114
+ - New projects: Be ambitious and creative
115
+ - Existing codebases: Surgical precision - modify only what's requested unless explicitly instructed to do otherwise
116
+
117
+ **Testing:**
118
+ - If tests exist: Start specific to your changes, then broader validation
119
+
120
+ ## Advanced Tools
121
+
122
+ **Task Tool (Sub-Agents):**
123
+ - Use the Task tool (functions.task) to launch sub-agents
124
+ - Check the Task tool description for current agent types and their capabilities
125
+ - Useful for complex analysis, specialized workflows, or tasks requiring isolated context
126
+ - The agent list is dynamically generated - refer to tool schema for available agents
127
+
128
+ **Parallelization:**
129
+ - When multiple independent tool calls are needed, use multi_tool_use.parallel to run them concurrently.
130
+ - Reserve sequential calls for ordered or data-dependent steps.
131
+
132
+ **MCP Tools:**
133
+ - Model Context Protocol servers provide additional capabilities
134
+ - MCP tools are prefixed: \`mcp__<server-name>__<tool-name>\`
135
+ - Check your available tools for MCP integrations
136
+ - Use when the tool's functionality matches your task needs
137
+
138
+ ## What Remains from Codex
139
+
140
+ Sandbox policies, approval mechanisms, final answer formatting, git commit protocols, and file reference formats all follow Codex instructions. In approval policy "never", never request escalations.
141
+
142
+ ## Approvals & Safety
143
+ - Assume workspace-write filesystem, network enabled, approval on-failure unless explicitly stated otherwise.
144
+ - When a command fails due to sandboxing or permissions, retry with escalated permissions if allowed by policy, including a one-line justification.
145
+ - Treat destructive commands (e.g., \`rm\`, \`git reset --hard\`) as requiring explicit user request or approval.
146
+ - Never run \`git reset --hard\`, \`git checkout --\`, or force deletes unless the user explicitly asked for that exact action.
147
+ - \`request_user_input\` is Plan-mode only; do not call it in Default mode.
148
148
  - When uncertain, prefer non-destructive verification first (e.g., confirm file existence with \`list\`, then delete with \`bash\`).`;