@kbediako/codex-orchestrator 0.1.7 → 0.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbediako/codex-orchestrator",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "bin": {
@@ -15,6 +15,7 @@
15
15
  "dist/types/**",
16
16
  "schemas/**",
17
17
  "templates/**",
18
+ "skills/**",
18
19
  "README.md",
19
20
  "LICENSE"
20
21
  ],
@@ -0,0 +1,54 @@
1
+ # Delegation Guide (Detailed)
2
+
3
+ Use this guide for deeper context on delegation behavior, tool surfaces, and troubleshooting.
4
+
5
+ ## Mental model
6
+
7
+ - The delegation MCP server is a local stdio process (`codex-orchestrator delegation-server`).
8
+ - It does **not** provide general tools itself; it only exposes `delegate.*` + optional `github.*` tools.
9
+ - Child runs get tools based on `delegate.mode` + `delegate.tool_profile` + repo caps.
10
+
11
+ ## Background-run pattern (preferred)
12
+
13
+ When delegation is disabled in the current session, spawn a background run:
14
+
15
+ ```
16
+ codex exec \
17
+ -c 'mcp_servers.delegation.enabled=true' \
18
+ "Use delegate.* tools to <task>. Return a short summary and any artifacts."
19
+ ```
20
+
21
+ Notes:
22
+ - `codex exec` is non-interactive; progress goes to stderr, final message to stdout.
23
+ - Add `-c 'features.skills=false'` for minimal background runs.
24
+ - Use `-o /path/to/output.txt` if you want the final summary captured in a file.
25
+ - If the run needs `delegate.spawn/pause/cancel`, add `-c 'delegate.mode=full'`.
26
+ - If it only needs `delegate.question.*` (and optional `delegate.status`), add `-c 'delegate.mode=question_only'`.
27
+ - Non-interactive runs can still require approvals; resolve them via the UI/TUI and the run will resume.
28
+
29
+ ## Minimal tool surface
30
+
31
+ - Use `delegate.mode=question_only` by default.
32
+ - Switch to `full` only when the child needs `delegate.spawn/pause/cancel` (nested delegation or run control).
33
+ - Keep `delegate.tool_profile` minimal; it must intersect the repo’s `delegate.allowed_tool_servers`.
34
+ - `github.*` tools are controlled by repo GitHub allowlists, not by `delegate.mode` or `delegate.tool_profile`.
35
+
36
+ ## Repo-scoped config
37
+
38
+ If you need delegation to respect a repo’s `.codex/orchestrator.toml` (e.g., sandbox.network caps), pass `--repo <path>` to the MCP server registration or MCP args.
39
+
40
+ ## Version guard (JSONL handshake)
41
+
42
+ Delegation MCP expects JSONL. Use `codex-orchestrator >= 0.1.8`.
43
+
44
+ - Check: `codex-orchestrator --version`
45
+ - Update global: `npm i -g @kbediako/codex-orchestrator@0.1.8`
46
+ - Or pin via npx: `npx -y @kbediako/codex-orchestrator@0.1.8 delegation-server`
47
+
48
+ ## Common failures
49
+
50
+ - **Handshake failed / connection closed**: Usually an older binary (0.1.5) or framed responses.
51
+ - **Unknown tool**: The delegation server only exposes `delegate.*` (and `github.*` if enabled).
52
+ - **Tool profile ignored**: The repo’s `delegate.allowed_tool_servers` may be empty, or names are invalid.
53
+ - **Missing control files**: delegate tools rely on `control_endpoint.json` in the run directory.
54
+ - **Run identifiers**: status/pause/cancel require `manifest_path`; question queue requires `parent_manifest_path`.
@@ -0,0 +1,145 @@
1
+ ---
2
+ name: delegation-usage
3
+ description: Use when enabling or operating the Codex delegation MCP server and tools (delegate.spawn, delegate.question.*, delegate.cancel, github.merge confirmation flow), or when configuring delegation mode/tool_profile to delegate work while keeping MCP disabled by default.
4
+ ---
5
+
6
+ # Delegation Usage
7
+
8
+ ## Overview
9
+
10
+ Use this skill to enable and operate delegation MCP tools without leaving the MCP server on by default. It focuses on safe, minimal‑context use: only enable delegation when you intend to delegate work.
11
+
12
+ ## Quick-start workflow (canned)
13
+
14
+ Use this when delegation is off in the current run and you want a background Codex run to handle delegation:
15
+
16
+ ```
17
+ codex exec \
18
+ -c 'mcp_servers.delegation.enabled=true' \
19
+ "Use delegate.* tools to <task>. Return a short summary and any artifacts."
20
+ ```
21
+
22
+ Optional (only if you need it):
23
+ - Add `--repo /path/to/repo` to the MCP args when registering the server or when you need repo-scoped config.
24
+ - Add `-c 'features.skills=false'` for a minimal, deterministic background run.
25
+ - Add `-c 'delegate.mode=question_only'` when the child only needs `delegate.question.*` (and optional `delegate.status`).
26
+ - Add `-c 'delegate.mode=full'` when the child needs `delegate.spawn/pause/cancel` (nested delegation / run control).
27
+
28
+ For deeper background patterns and troubleshooting, see `DELEGATION_GUIDE.md`.
29
+
30
+ ## Delegation‑first policy
31
+
32
+ - Default to delegation unless the task is trivial.
33
+ - Delegate when the work spans >1 domain, touches more than ~2 files, needs verification/research, or is likely to run >10 minutes.
34
+ - Spawn one delegate per workstream with narrow scope and acceptance criteria.
35
+ - Use `delegate.mode=question_only` unless the child truly needs full tool access.
36
+ - Ask delegates for short, structured summaries and to write details into files/artifacts instead of long chat dumps.
37
+ - Skip delegation only for tiny single‑file edits or when delegation overhead outweighs the work.
38
+
39
+ ## Workflow
40
+
41
+ ### 0) One-time setup (register the MCP server)
42
+
43
+ - Register the delegation server once:
44
+ - `codex mcp add delegation -- codex-orchestrator delegation-server`
45
+ - Optional (recommended for repo-scoped config): append `--repo /path/to/repo` to the args.
46
+ - Per-run `-c 'mcp_servers.delegation.enabled=true'` only works **after** registration.
47
+ - If `delegate.*` tools are missing mid-task, start a new run with:
48
+ - `codex -c 'mcp_servers.delegation.enabled=true' ...`
49
+ - Prefer using a background terminal (non-interactive) so you can continue without asking the user to relaunch.
50
+ - If delegation is unavailable and the user asked to delegate, **do not get stuck**:
51
+ - Explain delegation is disabled in this run and give the enable command above.
52
+ - Unless they explicitly want a delegation test, proceed locally using background tools (terminal commands or built-in tools) and deliver the result.
53
+
54
+ ### 0a) Version guard (JSONL handshake)
55
+
56
+ - Delegation MCP uses JSONL; ensure the server binary is **0.1.8+**:
57
+ - `codex-orchestrator --version` should be `>= 0.1.8`
58
+ - If not, update global install: `npm i -g @kbediako/codex-orchestrator@0.1.8`
59
+ - Alternative: pin the MCP server to `npx -y @kbediako/codex-orchestrator@0.1.8` for deterministic behavior.
60
+
61
+ ### 0b) Background terminal bootstrap (required when MCP is disabled)
62
+
63
+ When `delegate.*` is missing in the current session, immediately spawn a **background** Codex run with delegation enabled and hand it the narrow task. Use `codex exec` so it completes without interaction and you can capture output:
64
+
65
+ ```
66
+ codex exec \
67
+ -c mcp_servers.delegation.enabled=true \
68
+ -c mcp_servers.openaiDeveloperDocs.enabled=true \
69
+ "Use delegate.* tools to <task>. Return a short summary and any artifacts."
70
+ ```
71
+
72
+ Guidance for background runs:
73
+ - `codex exec` streams progress to `stderr` and prints the final message to `stdout`, so you can pipe or redirect safely.
74
+ - Use `--json` for JSONL events, or `-o <path>` to write the final message to a file while still printing to stdout.
75
+ - If you need a multi-step run, use `codex exec resume --last "<follow-up>"` to continue the same session.
76
+ - Non-interactive runs can still hit `confirmation_required`; approvals happen via the UI/TUI and the run resumes after approval.
77
+
78
+ ### 1) Enable delegation only for the run you need
79
+
80
+ - Keep `mcp_servers.delegation.enabled = false` in `~/.codex/config.toml`.
81
+ - Enable per run:
82
+ - Example: `codex -c 'mcp_servers.delegation.enabled=true' ...`
83
+ - Using `-c` keeps your default config unchanged, so delegation is off again next run.
84
+
85
+ ### 2) Spawn a delegate run (delegate.spawn)
86
+
87
+ - Use `delegate.spawn` when you want a child run with a reduced tool surface.
88
+ - Set `delegate.mode` explicitly: `question_only` or `full`.
89
+ - `question_only`: only constrains the `delegate.*` namespace (question queue + optional status).
90
+ - `full`: enables the full delegate tool surface, including nested delegation.
91
+ - Use `full` only when the child needs `delegate.spawn/pause/cancel` (nested delegation or run control). Other tools (shell/web/filesystem/etc) are governed by `delegate.tool_profile` + repo allowlists and can be available in `question_only`.
92
+ - Note: `github.*` registration is independent of `delegate.mode` and may still be available if repo-allowed.
93
+ - Set `delegate.tool_profile` separately to the minimum necessary tools.
94
+ - Effective tool profile = intersection with repo `delegate.allowed_tool_servers`.
95
+ - If the repo omits `delegate.allowed_tool_servers`, the cap defaults to `[]` and extra tools are ignored.
96
+ - Names must match `^[A-Za-z0-9_-]+$`; invalid entries (e.g., `;`, `/`, `\n`, `=`) are ignored.
97
+ - `github.*` tools are not gated by `delegate.tool_profile`; they are controlled by repo GitHub allowlists.
98
+ - Keep `delegate.tool_profile` minimal; avoid networked tools unless required.
99
+ - Nested delegation is off by default; only use `full` when `delegate.allow_nested=true` and you intend recursion.
100
+
101
+ #### Minimal-context delegate instruction template
102
+
103
+ ```
104
+ Goal: <one sentence>
105
+ Scope: <files/areas to touch>
106
+ Allowed tools: <tool_profile list>
107
+ Constraints: <must/ must-not>
108
+ Output: <patch + short summary>
109
+ Evidence: write detailed notes to artifacts/<name>.md (no long logs in chat)
110
+ Acceptance: <3-5 bullets>
111
+ ```
112
+
113
+ ### 3) Ask the parent a question (delegate.question.enqueue / poll)
114
+
115
+ - Child calls `delegate.question.enqueue` to send an escalation to the parent run.
116
+ - The parent/human answers via the UI/approval channel.
117
+ - Child calls `delegate.question.poll` to fetch status/answer. `wait_ms` is capped to **10s** per call. If you need longer waits, loop with brief pauses:
118
+
119
+ ```
120
+ repeat:
121
+ poll(wait_ms=10000)
122
+ if status in {answered, expired, dismissed}: stop
123
+ sleep/backoff briefly (e.g., 250–500ms, with jitter)
124
+ ```
125
+ - On `expired`, check `fallback_action` (from `delegate.question.expiry_fallback`) and follow it; default is pause.
126
+
127
+ ### 4) Confirm‑to‑act behavior (delegate.cancel, github.merge)
128
+
129
+ - Do **not** supply `confirm_nonce`. The runner injects it after approval.
130
+ - If confirmation is required, you’ll receive `confirmation_required` and the run may pause.
131
+ - Confirmations are only retried on confirmation‑specific error codes; generic errors are surfaced directly.
132
+ - On `confirmation_required`, **do not** retry the action; wait for approval/resume. If it expires, re‑request with a fresh tool call.
133
+
134
+ ### 5) Run identifiers (manifest paths)
135
+
136
+ - Stateful calls require `manifest_path` (delegate.status/pause/cancel) to locate the run.
137
+ - Question queue calls require `parent_manifest_path` for the same reason.
138
+
139
+ ## Common pitfalls
140
+
141
+ - **Long waits:** `wait_ms` never blocks longer than 10s per call; use polling.
142
+ - **Tool profile mismatch:** child tool profile must be allowed by repo policy; invalid or unsafe names are ignored.
143
+ - **Confirmation misuse:** never pass `confirm_nonce` from model/tool input; it is runner‑injected only.
144
+ - **Secrets exposure:** never include secrets/tokens/PII in delegate prompts or files.
145
+ - **Missing control files:** delegate tools rely on `control_endpoint.json` in the run directory; older runs may not have it.