pi-herdsman 0.3.2 → 0.5.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.
@@ -2,11 +2,12 @@
2
2
 
3
3
  [Documentation index](../README.md) · [supervision reference](supervision.md)
4
4
 
5
- `agent` is the structured model-facing API for managed agents. It has exactly six actions:
5
+ `agent` is the structured model-facing API for managed agents. It has seven actions:
6
6
 
7
7
  ```text
8
8
  list
9
9
  delegate
10
+ continue
10
11
  steer
11
12
  reply
12
13
  close
@@ -19,12 +20,6 @@ controllers.
19
20
 
20
21
  ## `delegate`
21
22
 
22
- Delegation has exactly two strict variants. The required field (`definition` or
23
- `session`) selects the variant; there is no target discriminator.
24
- Every variant rejects additional properties.
25
-
26
- ### Definition
27
-
28
23
  ```json
29
24
  {
30
25
  "action": "delegate",
@@ -42,39 +37,38 @@ the source for a new derived context; otherwise a new Pi session is launched.
42
37
  Each accepted definition delegation creates one agent generation for one
43
38
  assignment. The terminal result is delivered once and the agent is cleaned up.
44
39
 
45
- ### Session
40
+ ## `continue`
46
41
 
47
42
  ```json
48
43
  {
49
- "action": "delegate",
44
+ "action": "continue",
50
45
  "session": "<exact .jsonl path or full UUID>",
51
46
  "task": "Continue the investigation"
52
47
  }
53
48
  ```
54
49
 
55
- Allowed fields are `action`, `session`, `task`, optional `label`, `files`, and
56
- `timeoutMs`. The exact saved session supplies its cwd, definition identity, and
57
- historical Pi context. Session delegation always creates a new agent generation
50
+ Allowed fields are `action`, `session`, `task`, optional `files`, and
51
+ `timeoutMs`. The exact saved session path or full UUID supplies its cwd,
52
+ definition identity, and historical Pi context. Continuation always creates a new agent generation
58
53
  for one assignment with a live label; it never assigns work to an existing
59
- agent. The saved definition must currently resolve to an enabled, authorized
60
- effective definition, whose current configuration is used for the new
61
- generation.
54
+ agent. `continue` does not accept `cwd` or `fork`; the cwd comes from the saved
55
+ session. The saved definition is resolved again from current configuration and
56
+ must currently be enabled and authorized; its current effective configuration
57
+ is used for the new generation.
62
58
  Concurrent or otherwise conflicting managed representations of the exact
63
- session fail closed. The controller's own active Pi session cannot be delegated
64
- to itself; use definition delegation with `fork` when a separate derived
65
- context is required.
66
-
67
- `label` is optional on both delegation variants and identifies the live
68
- generation, not the continuation session. When omitted, Herdsman chooses a
69
- fresh available label derived from the effective agent definition. An explicit
70
- label is used exactly as the live label; if that label is occupied, delegation
71
- fails with `agent_label_exists`.
72
-
73
- All successful delegation results use `action: "delegate"` and include
74
- `agent`, `definition`, request, session, and startup evidence where available.
75
- Delegation returns after durable acceptance, not completion. A terminal result
76
- also makes the exact session identity prominent so it can be used with a later
77
- `delegate.session` call.
59
+ session fail closed. The controller's own active Pi session cannot be continued
60
+ to itself; use `delegate` with `fork` when a separate derived context is
61
+ required.
62
+
63
+ The saved session's logical label is inherited exactly for the continued
64
+ generation. A caller cannot provide a continuation label; if the inherited
65
+ label is occupied, continuation fails with `agent_label_exists`.
66
+
67
+ Successful `delegate` results use `action: "delegate"`; successful `continue`
68
+ results use `action: "continue"`. Both include `agent`, `definition`, request,
69
+ session, and startup evidence where available. Both return after durable
70
+ acceptance, not completion. A terminal result makes the exact session identity
71
+ prominent for a later `continue` call.
78
72
 
79
73
  ## `list`
80
74
 
@@ -105,8 +99,9 @@ Each actionable live agent record includes:
105
99
  `available_actions` is authoritative model guidance for the current snapshot.
106
100
  Do not infer eligibility from `state`. Active work may list `steer`; a valid
107
101
  correlated pending `ask_owner` may list `reply`; exact direct ownership may list
108
- `close`. `available_actions` never lists `delegate`: an agent cannot receive a
109
- second assignment. Descendant visibility does not grant control. Lead orphan
102
+ `close`. `available_actions` never lists `delegate` or `continue`: these are
103
+ controller operations, not controls on an already-live agent. An agent cannot
104
+ receive a second assignment. Descendant visibility does not grant control. Lead orphan
110
105
  recovery may expose only `close`. Unknown and recovery-only records are
111
106
  non-actionable. Every operation rechecks identity, ownership, mailbox state, and
112
107
  lifecycle immediately before mutation.
@@ -146,15 +141,15 @@ mailbox records, lifecycle, or available controls.
146
141
 
147
142
  ## `files` and `timeoutMs`
148
143
 
149
- `files` is valid on all `delegate` variants and on `steer` and `reply`; it is not
144
+ `files` is valid on `delegate` and `continue`, and on `steer` and `reply`; it is not
150
145
  valid on `list` or `close`. Paths are resolved from the controller cwd, checked
151
146
  as readable regular files, canonicalized with `realpath`, and embedded only
152
147
  when the exact message limit permits. Otherwise they remain canonical references.
153
148
 
154
- `timeoutMs` is valid on definition and session delegation and must be an integer
149
+ `timeoutMs` is valid on `delegate` and `continue` and must be an integer
155
150
  from `5001` through `300000`. The startup budget reserves one bounded diagnostic
156
- window. Current message limits are governed by global/default
157
- settings and the fixed mailbox protocol ceiling. Managed mailbox records use
151
+ window. Current message limits are governed by the Herdsman config file and its
152
+ defaults, plus the fixed mailbox protocol ceiling. Managed mailbox records use
158
153
  protocol V4 in the `mailboxes-v4` namespace, and control requests use the marker prefix
159
154
  `__PI_HERDSMAN_AGENT_V4__:`.
160
155
 
@@ -216,7 +211,7 @@ and has one correlated final result. Delivery goes to the exact owning Pi
216
211
  session and occurs exactly once. Model-visible completion wording uses
217
212
  `agent=<agent>`, `definition=<definition>`, `session=<id>`,
218
213
  `request=<id>`, and status. Details retain durable `agentLabel`,
219
- `agentDefinition`, `piSessionId`, `piSessionFile`, result paths, elapsed time,
214
+ `agentDefinition`, `piSessionId`, `piSessionFile`, result references, elapsed time,
220
215
  context usage, truncation, and persistence-error evidence. The agent is cleaned
221
216
  up after the terminal result is delivered; the Pi session remains available for
222
217
  continuation.
@@ -19,18 +19,18 @@ Commands require a lead Pi session with UI.
19
19
 
20
20
  The plain command opens a native Pi selection menu with `Running`,
21
21
  `Definitions`, `Layout`, `Message limits`, and `Stop all…` destinations. The
22
- Message limits view edits the independent global inline attachment and mailbox
23
- payload limits. It is available only to a lead Pi session with UI. Current
22
+ Message limits view edits the user-wide inline attachment and mailbox payload
23
+ limits. It is available only to a lead Pi session with UI. Current
24
24
  values and presets show a rough token equivalent using four UTF-8 bytes per
25
25
  token. The enforced limits are bytes, not tokens.
26
26
 
27
27
  ## `/agents definitions`
28
28
 
29
29
  Opens the native Definitions menu for the effective bundled, project, and
30
- global roster. Project definitions are included only when the trusted project
31
- setting `piHerdsman.projectAgents` is `true`. Project participation is marked
32
- `[project]`; a global override adds `*` (so `[project] *` means both layers
33
- contribute). Edits write global overrides only.
30
+ global roster. Project definitions are included when Pi considers the project
31
+ trusted. Project participation is marked `[project]`; a global override adds
32
+ `*` (so `[project] *` means both layers contribute). Edits write global
33
+ overrides only.
34
34
 
35
35
  The details view can show:
36
36
 
@@ -78,7 +78,7 @@ Details re-resolves the selected definition when opened, so it reflects current
78
78
  overlays and body references even if the menu remained open while configuration
79
79
  changed.
80
80
 
81
- Changes apply to future definition delegations and session continuations, not
81
+ Changes apply to future `delegate` assignments and `continue` assignments, not
82
82
  already-running agents or the lead Pi session.
83
83
 
84
84
  Standalone global definitions are editable too. Removing a field from one uses
@@ -2,137 +2,77 @@
2
2
 
3
3
  [Documentation index](../README.md)
4
4
 
5
- Pi Herdsman intentionally has very little settings state.
6
-
7
- Agent behavior lives in Markdown definitions. The extension settings currently
8
- own agent placement.
9
-
10
- ## Agent placement
11
-
12
- Settings shape:
13
-
14
- ```json
15
- {
16
- "piHerdsman": {
17
- "spawnPlacement": "subtree"
18
- }
19
- }
20
- ```
21
-
22
- Supported values:
5
+ Pi Herdsman keeps its configuration in one flat, user-wide file:
23
6
 
24
7
  ```text
25
- tab
26
- subtree
27
- split
8
+ <Pi agent directory>/pi-herdsman/config.json
28
9
  ```
29
10
 
30
- Default:
11
+ The default location is `~/.pi/agent/pi-herdsman/config.json`. Pi's native
12
+ `getAgentDir()` determines the agent directory, so setting
13
+ `PI_CODING_AGENT_DIR` relocates the file to
14
+ `$PI_CODING_AGENT_DIR/pi-herdsman/config.json`.
31
15
 
32
- ```text
33
- subtree
34
- ```
35
-
36
- When no `spawnPlacement` value is configured, it resolves to `subtree`.
37
- Unrecognized values remain invalid and resolve to `tab`.
38
-
39
- `tab` places future direct agents owned by a lead in one dedicated agents tab.
16
+ Project trust and project settings do not affect Herdsman configuration.
17
+ Agent definitions remain a separate feature and continue to use the bundled,
18
+ project-local, and user agent-definition locations described in the
19
+ [agent-definition guide](../guides/agent-definitions.md).
40
20
 
41
- `subtree` gives each future lead-direct agent its own tab. Descendants always
42
- split inside their owner's current tab.
21
+ ## Schema and defaults
43
22
 
44
- `split` places future lead-direct agents by splitting from the caller's current
45
- pane. Descendants always split inside their owner's current tab.
46
-
47
- This affects future starts, not existing agents.
48
-
49
- ## Message limits
50
-
51
- Pi Herdsman uses two independent byte settings:
23
+ The file contains only explicitly configured overrides. The accepted flat
24
+ schema is:
52
25
 
53
26
  ```json
54
27
  {
55
- "piHerdsman": {
56
- "inlineAttachmentLimitBytes": 131072,
57
- "mailboxPayloadLimitBytes": 131072
58
- }
28
+ "spawnPlacement": "subtree",
29
+ "inlineAttachmentLimitBytes": 131072,
30
+ "mailboxPayloadLimitBytes": 131072
59
31
  }
60
32
  ```
61
33
 
62
- Each accepts an integer from 1024 bytes (1 KiB) through 1048576 bytes (1 MiB)
63
- and defaults to 131072 bytes (128 KiB). The inline limit applies per file;
64
- eligible complete strict UTF-8 files are embedded in caller order only when
65
- the exact serialized mailbox record fits. Other files remain canonical
66
- references. The mailbox limit is the exact serialized `RequestRecord`,
67
- `AskRecord`, or text-only chief supervision record admission size. Chief
68
- supervision also has an existing fixed 8 KiB record ceiling, so its effective
69
- admission limit is the smaller of the configured mailbox limit and 8 KiB.
70
-
71
- Only valid global values affect runtime behavior. Invalid global values are
72
- ignored rather than clamped, and project-local values for these two keys are
73
- inert. Configure the global values through `/agents` → `Message limits`; the
74
- fixed 1 MiB protocol safety ceiling remains in force for reading existing
75
- mailbox records.
76
-
77
- ## Settings scope
78
-
79
- Pi Herdsman reads Pi settings through Pi's settings manager.
80
-
81
- Global settings are stored in the Pi agent directory's `settings.json`
82
- (default `~/.pi/agent/settings.json`).
83
-
84
- Project settings are stored in:
85
-
86
- ```text
87
- <project>/.pi/settings.json
88
- ```
89
-
90
- A project placement value is effective only when:
91
-
92
- - the project is trusted by Pi; and
93
- - the project setting is `tab`, `subtree`, or `split`.
34
+ An absent file means these defaults:
94
35
 
95
- If no valid trusted project placement is active, the global value is used.
36
+ | Field | Default | Allowed values |
37
+ | ---------------------------- | -----------------: | ------------------------------------------------- |
38
+ | `spawnPlacement` | `subtree` | `tab`, `subtree`, `split` |
39
+ | `inlineAttachmentLimitBytes` | `131072` (128 KiB) | integer from 1024 (1 KiB) through 1048576 (1 MiB) |
40
+ | `mailboxPayloadLimitBytes` | `131072` (128 KiB) | integer from 1024 (1 KiB) through 1048576 (1 MiB) |
96
41
 
97
- `/agents placement` opens a native selector showing the effective value and
98
- offering `tab`, `subtree`, or `split`. Selecting a value writes to the current effective
99
- scope and verifies the value after writing; the confirmation reports whether
100
- that scope is `project` or `global`.
42
+ Malformed JSON, a non-object root, unknown fields, and invalid known values
43
+ are errors. Reads do not create the directory or file. Configuration changes
44
+ through `/agents` update this single file atomically.
101
45
 
102
- ## Agent definitions are not extension settings
46
+ `inlineAttachmentLimitBytes` applies per file. Eligible complete strict UTF-8
47
+ files are embedded only when the exact serialized mailbox record fits; other
48
+ files remain canonical references. `mailboxPayloadLimitBytes` limits the exact
49
+ serialized request, ask, or chief message record. Chief messages also retain
50
+ their fixed 8 KiB protocol ceiling.
103
51
 
104
- Do not put per-agent model, thinking, tool, skill, extension, body, or
105
- delegation policy in `piHerdsman`.
52
+ Placement affects future starts, not existing agents. `tab` uses one lead-owned
53
+ agents tab, `subtree` gives each lead-direct agent its own tab, and `split`
54
+ splits from the caller's pane. Nested delegation always splits in its owner's
55
+ current tab.
106
56
 
107
- Those belong in Markdown agent definitions.
57
+ ## Reset
108
58
 
109
- Trusted project-local definitions can be enabled with this project-only
110
- discovery gate in `<cwd>/.pi/settings.json`:
59
+ Stop active Pi and Herdsman processes first; running processes may recreate
60
+ runtime state. Then delete the complete Herdsman directory at this canonical
61
+ location:
111
62
 
112
- ```json
113
- { "piHerdsman": { "projectAgents": true } }
63
+ ```text
64
+ <resolved Pi agent directory>/pi-herdsman/
114
65
  ```
115
66
 
116
- The default is disabled, and a global `projectAgents` value has no effect.
117
- This setting enables discovery only; agent models, tools, bodies, extensions,
118
- and delegation remain in Markdown definitions.
119
-
120
- See:
121
-
122
- - [Agent definitions](../guides/agent-definitions.md)
123
- - [Agent-definition schema](agent-definition-schema.md)
124
-
125
- ## herdr integration
126
-
127
- The required Pi integration is installed separately:
128
-
129
- ```sh
130
- herdr integration install pi
131
- herdr integration status
132
- ```
67
+ `<resolved Pi agent directory>` means the result of Pi's native
68
+ `getAgentDir()`. With a custom `PI_CODING_AGENT_DIR`, Pi resolves that value
69
+ (including values such as `~`) before appending `pi-herdsman`; do not construct
70
+ the path by concatenating the raw environment variable yourself. Use the
71
+ native file-management operation for the current platform to delete that
72
+ directory.
133
73
 
134
- Pi Herdsman requires integration version `2` or newer for supported native session
135
- identity/restore behavior.
74
+ The next process starts with the defaults and recreates only the runtime state
75
+ it needs.
136
76
 
137
77
  ## See also
138
78
 
@@ -38,7 +38,7 @@ must not be presented as exhausted cleanup.
38
38
  | Category | Meaning |
39
39
  | -------------------------- | ----------------------------------------------------------------------------------- |
40
40
  | `not_running_inside_herdr` | Required herdr environment is missing. |
41
- | `agent_label_exists` | Requested/generated live label conflicts with an existing agent. |
41
+ | `agent_label_exists` | Requested, inherited, or generated live label conflicts with an existing agent. |
42
42
  | `pane_not_ready` | Agent pane/startup did not reach the required readiness boundary. |
43
43
  | `target_not_found` | Exact requested identity or ownership evidence was not found. |
44
44
  | `target_ambiguous` | More than one live candidate matched an identity that must be exact. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-herdsman",
3
- "version": "0.3.2",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "description": "Asynchronous Pi agent orchestration with nested delegation, parallel execution, and supervision in herdr.",
6
6
  "license": "Apache-2.0",
@@ -41,17 +41,18 @@
41
41
  "image": "https://raw.githubusercontent.com/boadij/pi-herdsman/main/docs/assets/thumbnail.webp"
42
42
  },
43
43
  "scripts": {
44
- "test": "node --experimental-test-module-mocks --test --test-timeout=10000",
44
+ "test": "node --experimental-test-module-mocks --import=./scripts/test-env.mjs --test --test-timeout=10000",
45
45
  "check": "node scripts/check.mjs",
46
46
  "build": "node scripts/build.mjs",
47
47
  "package:audit": "node scripts/package-audit.mjs",
48
- "release:check": "npm run check && npm run build && npm run package:audit && npm publish --dry-run --ignore-scripts",
48
+ "validate": "npm run check && npm run build && npm run package:audit",
49
+ "release:check": "npm run validate && npm publish --dry-run --ignore-scripts",
49
50
  "prepack": "npm run build"
50
51
  },
51
52
  "peerDependencies": {
52
- "@earendil-works/pi-ai": "*",
53
- "@earendil-works/pi-coding-agent": "*",
54
- "@earendil-works/pi-tui": "*",
53
+ "@earendil-works/pi-ai": ">=0.84.2 <0.86.0",
54
+ "@earendil-works/pi-coding-agent": ">=0.84.2 <0.86.0",
55
+ "@earendil-works/pi-tui": ">=0.84.2 <0.86.0",
55
56
  "typebox": "*"
56
57
  },
57
58
  "devDependencies": {