pi-better-harness 0.34.2 → 0.35.1
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/pi-agent-catalog.mjs +4 -0
- package/node_modules/pi-better-subagents/README.md +6 -1
- package/node_modules/pi-better-subagents/agent-catalog.mjs +29 -0
- package/node_modules/pi-better-subagents/docs/agent-catalog.md +1 -1
- package/node_modules/pi-better-subagents/docs/agent-model-resolution.md +1 -1
- package/node_modules/pi-better-subagents/docs/worker-catalog.md +116 -0
- package/node_modules/pi-better-subagents/model-resolution-core.ts +1074 -0
- package/node_modules/pi-better-subagents/model-resolution.ts +17 -1056
- package/node_modules/pi-better-subagents/package.json +13 -1
- package/node_modules/pi-better-subagents/roles/role.developer.md +1 -0
- package/node_modules/pi-better-subagents/task-guard.ts +10 -3
- package/node_modules/pi-better-subagents/task-runtime.mjs +5 -2
- package/node_modules/pi-better-subagents/task-tool-owner.ts +21 -0
- package/node_modules/pi-better-subagents/worker-catalog.ts +162 -0
- package/package.json +5 -3
|
@@ -110,13 +110,18 @@ line says so, for example
|
|
|
110
110
|
|
|
111
111
|
## When To Use
|
|
112
112
|
|
|
113
|
+
Skills can use the same role definitions on Pi and Codex through the standalone
|
|
114
|
+
`pi-agent-catalog` JSON CLI, without starting Pi. The CLI checks supplied host
|
|
115
|
+
capabilities and returns a worker plan; it never launches workers or substitutes
|
|
116
|
+
prompt text for model selection. See [shared worker catalog](docs/worker-catalog.md).
|
|
117
|
+
|
|
113
118
|
Use this package for independent coding, review, research, or verification work that can finish later. Do not use it for steps that need immediate foreground interaction or user clarification.
|
|
114
119
|
|
|
115
120
|
## Compatibility
|
|
116
121
|
|
|
117
122
|
| Requirement | Support |
|
|
118
123
|
|-------------|---------|
|
|
119
|
-
| Pi | Required |
|
|
124
|
+
| Pi | Required for worker execution through this extension; not for standalone catalog planning |
|
|
120
125
|
| Install method | `pi install npm:pi-better-subagents` |
|
|
121
126
|
| macOS sandboxing | Supported when enabled |
|
|
122
127
|
| Linux sandboxing | Requires usable `bubblewrap` when enabled |
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync, realpathSync } from 'node:fs';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
|
|
5
|
+
export async function runCli(args = process.argv.slice(2), input = () => readFileSync(0, 'utf8')) {
|
|
6
|
+
if (args.includes('--help')) {
|
|
7
|
+
console.log('pi-agent-catalog [resolve-workers] < request.json\nResolves shared agent roles against explicit host model and effort capabilities. No workers are launched.');
|
|
8
|
+
return 0;
|
|
9
|
+
}
|
|
10
|
+
if (args.length > 1 || (args.length === 1 && args[0] !== 'resolve-workers')) {
|
|
11
|
+
console.error('Usage: pi-agent-catalog [resolve-workers] < request.json');
|
|
12
|
+
return 2;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
// Register only for this import. The portable resolver never loads Pi extensions or credentials.
|
|
16
|
+
const { tsImport } = await import('tsx/esm/api');
|
|
17
|
+
const { planWorkers } = await tsImport('./worker-catalog.ts', import.meta.url);
|
|
18
|
+
const text = input();
|
|
19
|
+
if (Buffer.byteLength(text) > 1024 * 1024) throw new Error('worker request exceeds 1 MiB');
|
|
20
|
+
console.log(JSON.stringify(planWorkers(JSON.parse(text))));
|
|
21
|
+
return 0;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error(`pi-agent-catalog: ${error.message}`);
|
|
24
|
+
console.log(JSON.stringify({ version: 1, ok: false, code: 'worker-catalog-error', reason: error.message }));
|
|
25
|
+
return 2;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href) process.exitCode = await runCli();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Native agent catalog (`pi-agent/v1`)
|
|
2
2
|
|
|
3
|
-
Portable role and named-agent definitions for `pi-better-subagents`. This is the local contract for DEV-23 / GitHub #289. It is not an Agentier importer
|
|
3
|
+
Portable role and named-agent definitions for `pi-better-subagents`. This is the local contract for DEV-23 / GitHub #289. It is not an Agentier importer or a second launch path. The [shared worker catalog](worker-catalog.md) exposes these definitions to skills on Pi and Codex through host-specific planning, without launching workers itself.
|
|
4
4
|
|
|
5
5
|
Normative behavior is DEV-23 and the accepted ADR `docs/adr/0003-native-agent-catalog-live-inheritance.md`. Field names below are the engineering schema those decisions require.
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Agent model resolution
|
|
2
2
|
|
|
3
|
-
Resolver for DEV-23 model and effort choices. `model-resolution.ts`
|
|
3
|
+
Resolver for DEV-23 model and effort choices. `model-resolution-core.ts` owns portable resolution; `model-resolution.ts` supplies Pi's effort-support helper. Neither spawns a child or edits the catalog. Lifecycle calls the Pi adapter before `spawnSubagentRun`. Skills on other hosts use the [shared worker catalog](worker-catalog.md).
|
|
4
4
|
|
|
5
5
|
Normative rules are R3, R4, R8, and the resolver half of R10. Prose parsing and real Pi delegation stay with the acceptance unit.
|
|
6
6
|
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Shared worker catalog
|
|
2
|
+
|
|
3
|
+
Skills request roles; the harness catalog owns their instructions, preferred
|
|
4
|
+
models, and effort. Skills must not turn a model recommendation into an explicit
|
|
5
|
+
launch override. This interface plans workers; it does not launch them.
|
|
6
|
+
|
|
7
|
+
`pi-agent-catalog [resolve-workers]` reads one JSON request from stdin and emits
|
|
8
|
+
one JSON plan. Install the harness or subagents npm package to expose the binary,
|
|
9
|
+
or run its `agent-catalog.mjs` directly. No Pi session, credentials, provider
|
|
10
|
+
discovery, extensions, or network connection is needed. The CLI uses the packaged
|
|
11
|
+
`tsx` loader; the portable TypeScript API is `pi-better-subagents/catalog`.
|
|
12
|
+
|
|
13
|
+
## Request
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"version": 1,
|
|
18
|
+
"harness": "codex",
|
|
19
|
+
"cwd": "/workspace/project",
|
|
20
|
+
"projectTrusted": false,
|
|
21
|
+
"available": [
|
|
22
|
+
{
|
|
23
|
+
"model": "openai/gpt-6.1-sol",
|
|
24
|
+
"nativeModel": "gpt-6.1-sol",
|
|
25
|
+
"supportedEfforts": ["low", "medium", "high"]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"model": "openai/gpt-6-luna",
|
|
29
|
+
"nativeModel": "gpt-6-luna",
|
|
30
|
+
"supportedEfforts": ["low", "medium", "high"]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"model": "openai/gpt-6-astra",
|
|
34
|
+
"nativeModel": "gpt-6-astra",
|
|
35
|
+
"supportedEfforts": ["low", "medium", "high"]
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"launchCapabilities": {
|
|
39
|
+
"model": true,
|
|
40
|
+
"effort": true,
|
|
41
|
+
"instructions": true
|
|
42
|
+
},
|
|
43
|
+
"hostPreferences": {
|
|
44
|
+
"developer": {"model": "openai/gpt-6.1-sol", "effort": "high"}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This is an example shape, not evidence that these models or controls are available
|
|
50
|
+
in any Codex installation. The caller supplies capabilities from its current host.
|
|
51
|
+
Do not copy an availability list from Pi, infer supported effort from a model name,
|
|
52
|
+
or treat a configured model as available without runtime evidence. A native model
|
|
53
|
+
name maps to exactly one canonical `provider/model`; ambiguous mappings fail.
|
|
54
|
+
|
|
55
|
+
The catalog still uses project > personal > bundled definitions. Personal storage
|
|
56
|
+
is `userRoot`, then `PI_CODING_AGENT_DIR`, then `~/.pi/agent`, shared across hosts.
|
|
57
|
+
The CLI never scans `.codex/agents` or writes user configuration. Project catalog
|
|
58
|
+
files contribute only when `projectTrusted` is explicitly true. Host preferences
|
|
59
|
+
are supplied configuration, not another copied catalog or a write to a role.
|
|
60
|
+
|
|
61
|
+
Optional `overrides` selects `implementer`, `explorer`, `diagnoser`, or `reviewer`:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{"overrides": {"implementer": {"model": "deepseek/deepseek-flash@max"}}}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Model and effort resolve independently: task override > host preference > catalog
|
|
68
|
+
default. A model-only override keeps the resolved effort. Unsupported explicit
|
|
69
|
+
model/effort choices block; inherited effort can use the catalog's documented
|
|
70
|
+
nearest-level adjustment. Pi retains its existing tier/foreground fallback policy.
|
|
71
|
+
Codex and Claude Code require an explicit configured `tiers` policy or
|
|
72
|
+
`fallbackToForeground: true` to permit those default-model substitutions. An
|
|
73
|
+
explicit task or host model is never silently substituted.
|
|
74
|
+
|
|
75
|
+
## Plan And Execution
|
|
76
|
+
|
|
77
|
+
The plan maps implementer and diagnoser to Developer, explorer to Explorer, and
|
|
78
|
+
reviewer to Reviewer. Every worker reports `role`, `model`, `nativeModel`, `effort`,
|
|
79
|
+
`instructions`, `selection`, `catalogDigest`, `diagnostics`,
|
|
80
|
+
and `launch`. All four use the same immutable catalog snapshot. A reviewer that
|
|
81
|
+
resolves to the implementer's model blocks preflight; the skill must not invent
|
|
82
|
+
another model to make the check pass.
|
|
83
|
+
|
|
84
|
+
- **Pi:** `launch` is `{role: "developer"}` by default. Only explicit task or host
|
|
85
|
+
model/effort choices add `model` or `thinking`. The coordinator adds its task
|
|
86
|
+
prompt, alias, workspace, and authorized controls to the existing spawn tool.
|
|
87
|
+
Live Pi launch resolution remains authoritative, including branch-local session
|
|
88
|
+
preferences that an out-of-process CLI cannot read. Record the actual launch
|
|
89
|
+
provenance, not just the preflight prediction.
|
|
90
|
+
- **Codex / Claude Code:** `launch` contains the verified native `model`, `effort`,
|
|
91
|
+
and resolved role `instructions`. The adapter uses actual launch/configuration
|
|
92
|
+
controls supported by its current surface and appends the task instructions.
|
|
93
|
+
If the surface cannot apply a required field, do not launch. Saying a model name
|
|
94
|
+
in a worker prompt is not model selection. This API is a plan, not a claim that
|
|
95
|
+
every native `spawn_agent` surface supports per-call model or effort fields.
|
|
96
|
+
|
|
97
|
+
The catalog grants no sandbox, tool, filesystem, credential, or delegation
|
|
98
|
+
permissions. Existing host launch controls still apply.
|
|
99
|
+
|
|
100
|
+
On a blocked plan, `ok` is false and **every** `launch` is null. A model recorded
|
|
101
|
+
in an unsuccessful decision is diagnostic evidence, not launch authorization.
|
|
102
|
+
The CLI returns status 0 for a valid plan, including a blocked plan, and status 2
|
|
103
|
+
for malformed input or an invocation error. Consumers must check `ok`, not just
|
|
104
|
+
the process exit status. No automatic retry, install, or post-start substitution
|
|
105
|
+
is performed.
|
|
106
|
+
|
|
107
|
+
## Modules
|
|
108
|
+
|
|
109
|
+
- `catalog-schema.ts`, `catalog-store.ts`, `catalog-resolver.ts`: existing shared
|
|
110
|
+
definitions and live inheritance, unchanged storage format.
|
|
111
|
+
- `model-resolution-core.ts`: portable availability and effort resolution, with
|
|
112
|
+
host-provided supported effort levels or an injected effort-support function.
|
|
113
|
+
- `model-resolution.ts`: Pi wrapper, supplying `getSupportedThinkingLevels` from
|
|
114
|
+
Pi's registry. Existing Pi callers retain their API and semantics.
|
|
115
|
+
- `worker-catalog.ts`: workflow slots, host adaptation, independence, and a single
|
|
116
|
+
batch snapshot. It does not import a Pi SDK.
|