pi-daddy 0.14.0 → 0.16.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.
- package/CHANGELOG.md +123 -0
- package/README.md +37 -14
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +10 -4
- package/dist/cli.js.map +1 -1
- package/dist/executor.d.ts +38 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +93 -0
- package/dist/executor.js.map +1 -0
- package/dist/grant-store.d.ts +68 -0
- package/dist/grant-store.d.ts.map +1 -0
- package/dist/grant-store.js +142 -0
- package/dist/grant-store.js.map +1 -0
- package/dist/herdr-cli.d.ts +78 -0
- package/dist/herdr-cli.d.ts.map +1 -0
- package/dist/herdr-cli.js +113 -0
- package/dist/herdr-cli.js.map +1 -0
- package/dist/herdr-name.d.ts +37 -0
- package/dist/herdr-name.d.ts.map +1 -0
- package/dist/herdr-name.js +59 -0
- package/dist/herdr-name.js.map +1 -0
- package/dist/herdr-poll.d.ts +104 -0
- package/dist/herdr-poll.d.ts.map +1 -0
- package/dist/herdr-poll.js +150 -0
- package/dist/herdr-poll.js.map +1 -0
- package/dist/herdr-stage.d.ts +40 -0
- package/dist/herdr-stage.d.ts.map +1 -0
- package/dist/herdr-stage.js +54 -0
- package/dist/herdr-stage.js.map +1 -0
- package/dist/ledger-report.d.ts +18 -0
- package/dist/ledger-report.d.ts.map +1 -1
- package/dist/ledger-report.js +10 -0
- package/dist/ledger-report.js.map +1 -1
- package/dist/ledger.d.ts +17 -0
- package/dist/ledger.d.ts.map +1 -1
- package/dist/ledger.js +1 -0
- package/dist/ledger.js.map +1 -1
- package/dist/pane-reaper.d.ts +66 -4
- package/dist/pane-reaper.d.ts.map +1 -1
- package/dist/pane-reaper.js +131 -9
- package/dist/pane-reaper.js.map +1 -1
- package/dist/progress.d.ts +96 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +167 -0
- package/dist/progress.js.map +1 -0
- package/dist/run-child.d.ts +27 -0
- package/dist/run-child.d.ts.map +1 -1
- package/dist/run-child.js +84 -7
- package/dist/run-child.js.map +1 -1
- package/dist/run-herdr.d.ts +41 -28
- package/dist/run-herdr.d.ts.map +1 -1
- package/dist/run-herdr.js +150 -167
- package/dist/run-herdr.js.map +1 -1
- package/dist/skill-packages.d.ts +16 -0
- package/dist/skill-packages.d.ts.map +1 -1
- package/dist/skill-packages.js +39 -10
- package/dist/skill-packages.js.map +1 -1
- package/extensions/delegation.ts +94 -2
- package/extensions/grants-command.ts +57 -1
- package/extensions/grants.ts +109 -165
- package/extensions/init-command.ts +132 -0
- package/extensions/run-delegation.ts +70 -8
- package/extensions/session-report.ts +231 -0
- package/extensions/session.ts +138 -17
- package/extensions/tripwire.ts +44 -0
- package/package.json +17 -1
- package/src/cli.ts +10 -4
- package/src/executor.ts +122 -0
- package/src/grant-store.ts +151 -0
- package/src/herdr-cli.ts +125 -0
- package/src/herdr-name.ts +61 -0
- package/src/herdr-poll.ts +185 -0
- package/src/herdr-stage.ts +55 -0
- package/src/ledger-report.ts +21 -0
- package/src/ledger.ts +18 -0
- package/src/pane-reaper.ts +147 -9
- package/src/progress.ts +206 -0
- package/src/run-child.ts +96 -7
- package/src/run-herdr.ts +170 -174
- package/src/skill-packages.ts +41 -10
package/CHANGELOG.md
CHANGED
|
@@ -93,6 +93,129 @@ resolution, enforcement, approvals or the ledger changed — this is the part be
|
|
|
93
93
|
defect as the `exports` map that worked in the tree and threw for every consumer, and the second time that
|
|
94
94
|
script has caught it.
|
|
95
95
|
|
|
96
|
+
## 0.16.0 — children you can watch, in panes chosen for you
|
|
97
|
+
|
|
98
|
+
**If herdr is running, your sub-agents now run in herdr panes without you configuring anything — and the
|
|
99
|
+
parent shows what each one is doing while it works.** Two ADRs, shipped together.
|
|
100
|
+
|
|
101
|
+
### `PI_GRANTS_HERDR` is three-state, and unset now means *probe* (ADR-0031)
|
|
102
|
+
|
|
103
|
+
| Value | Behaviour |
|
|
104
|
+
| :--- | :--- |
|
|
105
|
+
| unset | Probe once at session start (`herdr tab list`, 2s bound). A server that **answers** ⇒ herdr panes; anything else ⇒ captured subprocess. |
|
|
106
|
+
| `1` | Demand herdr. **Every delegation refuses** if it is unreachable — no fallback. |
|
|
107
|
+
| `0` | Demand the captured subprocess. No probe. |
|
|
108
|
+
|
|
109
|
+
**Not a `PATH` check.** A binary with no server behind it would make every delegation fail at `tab create`, on
|
|
110
|
+
a path nobody chose — so only a *reachable* server counts. This reverses part of ADR-0016 point 6, which
|
|
111
|
+
refused auto-detection on the grounds that a run must not "silently relocate"; the answer to *silently* is that
|
|
112
|
+
the executor is now named at session start, in `/grants`, and per child in the ledger.
|
|
113
|
+
|
|
114
|
+
**What to do about it:** nothing, unless you relied on an unset variable meaning subprocesses. If you did, set
|
|
115
|
+
`PI_GRANTS_HERDR=0`.
|
|
116
|
+
|
|
117
|
+
A stale `PI_GRANTS_HERDR=1` in a shell profile still breaks delegation on a machine without herdr — **as it did in
|
|
118
|
+
0.15.0**, where every child failed at `tab create`. There was never a fallback to lose. What changed is that the
|
|
119
|
+
failure is reported at session start, names the variable, and says what to set instead, rather than surfacing as a
|
|
120
|
+
per-delegation spawn error.
|
|
121
|
+
|
|
122
|
+
### A running delegation is visible (ADR-0032)
|
|
123
|
+
|
|
124
|
+
Both tools discarded pi's `onUpdate`, so a delegation showed the bare word `delegate` from the call until the
|
|
125
|
+
result — up to ten minutes, and the same one word for all eight children of a `delegate_all`. Now there is one
|
|
126
|
+
status block per call, redrawn in place, with a three-line tail per child and its herdr agent and pane id:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
2 children · herdr panes
|
|
130
|
+
|
|
131
|
+
review agent review-d0.1 pane w7:t12 running 0:42
|
|
132
|
+
3 findings so far: unchecked nil at
|
|
133
|
+
session.ts:88, missing expiry compare…
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Both executors stream. The block is a **display, never the result** — the answer is still what the child
|
|
137
|
+
returned.
|
|
138
|
+
|
|
139
|
+
### Panes live until you get your prompt back
|
|
140
|
+
|
|
141
|
+
A pane used to be destroyed the instant its child settled, so a twenty-second child's pane was gone before
|
|
142
|
+
anyone could switch to it. Panes now belong to the **agent run** and are swept at `agent_settled`, capped at 8
|
|
143
|
+
at once, with process `exit` as the backstop. `PI_GRANTS_HERDR_KEEP_PANE=1` still means *not even then*.
|
|
144
|
+
|
|
145
|
+
A child's pane also defaults to the **parent's own herdr workspace** now, so switching to one is a tab away
|
|
146
|
+
rather than a workspace away.
|
|
147
|
+
|
|
148
|
+
### Fixed before release — eighteen defects from six independent reviewers
|
|
149
|
+
|
|
150
|
+
Everything above was implemented, then attacked by six reviewers with one written hypothesis each. Two were
|
|
151
|
+
shipping blockers, and they change what the herdr path guarantees:
|
|
152
|
+
|
|
153
|
+
- **`herdr agent stop` does not exist.** Measured against herdr 0.7.5. Three call sites issued it for nothing, and
|
|
154
|
+
`docs/probes/g16-herdr` asserted it worked — from a rerun block that was never run. Closing the tab is the only
|
|
155
|
+
kill herdr offers, so an unsettled child now loses its tab at once; leaving it would have left a governed child
|
|
156
|
+
working with its grant after its result was reported.
|
|
157
|
+
- **herdr binds an agent name to its tab.** With panes outliving their calls, the **second `delegate` of every
|
|
158
|
+
turn** failed with `agent_name_taken`. Names are now unique per spawn.
|
|
159
|
+
- **The 8-pane cap killed live siblings**, because pi runs tool calls in parallel by default. Only *settled* panes
|
|
160
|
+
are reclaimable now; if they are all live the cap yields rather than enforcing.
|
|
161
|
+
- **The pane reader amplified output 89,000×** once a pane scrolled or passed the output cap: `agent read` returns
|
|
162
|
+
a snapshot of a bounded terminal and was being diffed as an append-only stream.
|
|
163
|
+
- **The output cap counted bytes but truncated by UTF-16 code units** — 2048 bytes through the 1024 default on
|
|
164
|
+
non-ASCII — and a multi-byte character split across a pipe boundary became U+FFFD **in the child's answer**.
|
|
165
|
+
Both pre-existing, both fixed.
|
|
166
|
+
- **A failed pane read came back as the child's successful answer**, and a truncated pane never said so.
|
|
167
|
+
- **The session-start executor line never reached pi's TUI**, because consecutive `info` notifies overwrite each
|
|
168
|
+
other — which also means `holding [...]` has been silently overwritten since the spawnable summary was added.
|
|
169
|
+
All info lines are now one message.
|
|
170
|
+
- **The approval dialog ran before the refusal**, so a demanded-but-unreachable herdr could bank a 30-day approval
|
|
171
|
+
for a delegation it then refused.
|
|
172
|
+
|
|
173
|
+
Six tests that could not fail were rewritten, each re-verified by re-applying the mutation that had defeated it,
|
|
174
|
+
and coverage was added where it was simply absent — including that nothing verified a real spawn records
|
|
175
|
+
`executor: "herdr"`. 461 unit tests, up from 442.
|
|
176
|
+
|
|
177
|
+
### Also
|
|
178
|
+
|
|
179
|
+
- **`/grants ledger` tallies executors**, so "which children ran in panes?" no longer needs `jq`.
|
|
180
|
+
- **The tripwire names `delegate_all`.** It said only *"Use `delegate` instead"*, and a request for parallel
|
|
181
|
+
work was answered with a single sequential call as a result.
|
|
182
|
+
- **The ledger records `executor` per child** — required, not optional. The executor is decided by a probe now,
|
|
183
|
+
so nothing outside the record preserves which one ran, and the two paths do not produce the same argv.
|
|
184
|
+
- **R-62 re-rated L×L → M×L.** Its "low severity" rested on the herdr executor being opt-in, which is no
|
|
185
|
+
longer true. The failure is unchanged; how often anyone meets it is not.
|
|
186
|
+
|
|
187
|
+
## 0.15.0 — `/grants init`, a grant that survives without an env var, and a setup that was wrong
|
|
188
|
+
|
|
189
|
+
**Setup is two steps instead of five, and one of the five was wrong.**
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
pi install npm:pi-daddy
|
|
193
|
+
pi install npm:principal-pi-skills
|
|
194
|
+
pi
|
|
195
|
+
/grants init
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
- **`pi install`, not `npm install`.** This package's own documentation said `npm install`, and that is not
|
|
199
|
+
how pi packages are installed: `pi install` registers the package in pi's settings, which is what makes
|
|
200
|
+
the extension auto-load, and it installs to `$PI_CODING_AGENT_DIR/npm/node_modules` rather than the
|
|
201
|
+
project. **`init` searched only the project and so found nothing for anyone who followed pi's own
|
|
202
|
+
instructions** — telling them to install a package they had just installed. It now searches both roots,
|
|
203
|
+
project first so a pinned copy outranks the machine-wide one.
|
|
204
|
+
- **`/grants init`** scaffolds definitions, asks about the capabilities that can change your machine, and
|
|
205
|
+
applies the answer to the session you are already in — **no `source`, no restart**.
|
|
206
|
+
- **A grant can now come from a store**, at `$PI_CODING_AGENT_DIR/grants/<project>.json` — **outside** your
|
|
207
|
+
project, because a ceiling a child holding `tool:write` could rewrite is not a ceiling. `PI_GRANTS_GRANT`
|
|
208
|
+
**always wins**: it is how a child is governed and how CI is configured. `.pi/grants.env` is still written
|
|
209
|
+
and still worth committing — it is the reviewable record, no longer what the enforcer reads. (ADR-0030)
|
|
210
|
+
- **The dialog does not ask questions whose answers cannot matter.** `tool:bash` subsumes `write` and
|
|
211
|
+
`edit`, so once bash is granted those are conferred; asking anyway let an operator answer *no* to
|
|
212
|
+
`tool:write` and then watch `build` be allowed it. It now reports them as already conferred instead.
|
|
213
|
+
- **An unknown `/grants` subcommand is refused rather than ignored.** `/grants init` used to print the
|
|
214
|
+
ordinary status screen with the word silently dropped, so a command that did not exist looked like it had
|
|
215
|
+
worked.
|
|
216
|
+
- **`init` counted authorisations and called them declarations** — "7 skill(s), 3 declaring allowed-tools"
|
|
217
|
+
when all seven declared.
|
|
218
|
+
|
|
96
219
|
## 0.13.0 — the approvals file gets the lock the ledger already had, and two silences end
|
|
97
220
|
|
|
98
221
|
Closing the last items that were open rather than out of scope, then **red-teaming the result**: an
|
package/README.md
CHANGED
|
@@ -183,11 +183,19 @@ delegate_all({ children: [ {…}, {…}, {…} ] }) // several
|
|
|
183
183
|
|
|
184
184
|
### Two executors, one plan
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
Either a captured child process, or a visible, attachable **herdr** pane — the same governed argv, the same
|
|
187
|
+
`--tools` enforcement, somewhere you can watch it.
|
|
188
188
|
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
**Which one runs is decided by a probe (ADR-0031).** `PI_GRANTS_HERDR` is three-state: **unset** probes once at
|
|
190
|
+
session start (`herdr tab list`, 2s bound) and uses panes if a server *answers*; **`1`** demands herdr and
|
|
191
|
+
**refuses every delegation** if it is unreachable, rather than quietly relocating; **`0`** demands subprocesses and
|
|
192
|
+
skips the probe. Which one was chosen is printed at session start, shown by `/grants`, and recorded per child in
|
|
193
|
+
the ledger.
|
|
194
|
+
|
|
195
|
+
Still **never auto-detected from `herdr` being on `PATH`** — a binary with no server behind it would make every
|
|
196
|
+
delegation fail at `tab create`, on a path nobody chose. Only a reachable server counts.
|
|
197
|
+
|
|
198
|
+
A child's pane goes in **your own herdr workspace** by default, so switching to one is a tab away. Constraints found by building it are in `docs/probes/g16-herdr` — herdr has
|
|
191
199
|
no `--env` (the grant rides on the pane, which the agent's shell inherits), `agent start` types argv into a
|
|
192
200
|
shell so a multi-line argument must be staged to a file, and `agent wait --until idle` matches the state the
|
|
193
201
|
agent was *already* in, so settling requires a state counter to advance.
|
|
@@ -339,10 +347,18 @@ installed. Every transcript below is **copied from a run**, not retyped — the
|
|
|
339
347
|
this section abridges output it says so.
|
|
340
348
|
|
|
341
349
|
```bash
|
|
342
|
-
|
|
343
|
-
|
|
350
|
+
pi install npm:pi-daddy
|
|
351
|
+
pi install npm:principal-pi-skills
|
|
352
|
+
pi # then, inside pi:
|
|
353
|
+
/grants init
|
|
344
354
|
```
|
|
345
355
|
|
|
356
|
+
**`pi install`, not `npm install`** — it registers the package with pi, which is what makes the extension
|
|
357
|
+
auto-load; presence in `node_modules` alone does nothing. `/grants init` asks only about the capabilities
|
|
358
|
+
that can change your machine and applies the answer to the running session, no restart (ADR-0030).
|
|
359
|
+
`npx pi-daddy init` does the same scaffolding from a shell, and both search pi's install root as well as
|
|
360
|
+
the project's.
|
|
361
|
+
|
|
346
362
|
```
|
|
347
363
|
found principal-pi-skills@2.3.1 — 7 skill(s), 0 declaring allowed-tools
|
|
348
364
|
wrote .pi/skills/decide/SKILL.md
|
|
@@ -453,9 +469,9 @@ everything below it.
|
|
|
453
469
|
| `PI_GRANTS_CHILD_TIMEOUT` | `600` (seconds) | Wall-clock limit for a child. Inherited by descendants — an operator preference, deliberately *not* attenuating state. |
|
|
454
470
|
| `PI_GRANTS_FANOUT` | `8` | **Subtree budget**: total descendants this session may create. Attenuates downward like depth. Malformed or `0` falls back to the default — a bound a typo can switch off is not a bound. |
|
|
455
471
|
| `PI_GRANTS_PARENT_ID` | `d0` | This session's ledger id; set by the parent. Makes sibling records joinable into a tree. |
|
|
456
|
-
| `PI_GRANTS_HERDR` | unset |
|
|
457
|
-
| `PI_GRANTS_HERDR_WORKSPACE` |
|
|
458
|
-
| `PI_GRANTS_HERDR_KEEP_PANE` | unset | `1` keeps each child's pane for inspection. Off by default: a fan-out would flood the workspace. |
|
|
472
|
+
| `PI_GRANTS_HERDR` | unset ⇒ **probe** | Three-state. Unset probes for a reachable herdr and uses panes if one answers; `1` demands panes and refuses every delegation if herdr is unreachable; `0` demands captured subprocesses. Never detected from `herdr` merely being on `PATH`. |
|
|
473
|
+
| `PI_GRANTS_HERDR_WORKSPACE` | the parent's `HERDR_WORKSPACE_ID` | herdr workspace for spawned panes. Defaults to the workspace this session is in, so a child is a tab away rather than a workspace away. |
|
|
474
|
+
| `PI_GRANTS_HERDR_KEEP_PANE` | unset | `1` keeps each child's pane for inspection, and no sweep closes it. Off by default: a fan-out would flood the workspace. |
|
|
459
475
|
| `PI_CODING_AGENT_DIR` | `~/.pi/agent` | pi's own variable, not ours — but it decides where persisted approvals live, so it is listed here. |
|
|
460
476
|
|
|
461
477
|
**A malformed value disables spawning; it never falls back to a default.** An unreadable
|
|
@@ -661,11 +677,18 @@ Known gaps, stated because a gap nobody wrote down is the one that surprises som
|
|
|
661
677
|
- **`bash` escapes governance.** Out of scope by decision (ADR-0012).
|
|
662
678
|
- **`subagents:rpc:spawn` bypasses the tripwire.** Unfixable from here.
|
|
663
679
|
- **The ledger is verified at session start** when one is configured: a damaged trail announces itself, an intact one stays quiet.
|
|
664
|
-
- **
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
680
|
+
- **A pane outlives its tool call only if its child settled.** A child that answered keeps its pane so you can
|
|
681
|
+
read it, and it is swept when you get your prompt back (`agent_settled`), with process `exit` as a backstop. A
|
|
682
|
+
child that did **not** settle — timeout, abort, failed start — loses its tab at once, because closing the tab is
|
|
683
|
+
the only way to stop a herdr agent (`herdr agent stop` does not exist). At most 8 panes are open at once, and
|
|
684
|
+
only *settled* ones are ever reclaimed: if they are all live the cap yields rather than killing a child.
|
|
685
|
+
- **Pane cleanup does not cover being killed outright.** SIGKILL, and a SIGTERM nothing else is listening for,
|
|
686
|
+
run no `exit` handlers — by Node's design — so a pane can be orphaned; `herdr tab close <id>` is the remedy. No
|
|
687
|
+
signal handler is installed, deliberately: one here would suppress Node's default termination and turn pi's
|
|
688
|
+
*"interrupt this turn"* into *"exit pi"* (R-62, re-rated M×L now that panes are the default path).
|
|
689
|
+
- **A running delegation is visible.** One status block per call — per child: its definition, its herdr agent, its
|
|
690
|
+
pane id, its state, elapsed time, and the last three lines it printed. Bounded in height and width, so a fan-out
|
|
691
|
+
cannot flood your screen. It is a **display, never the result**.
|
|
669
692
|
- **A definition's *instructions* are governed only by identity.** `agent:<name>` says which file may be
|
|
670
693
|
spawned and the digest says which version ran, but nothing reads a body and judges what it says — the
|
|
671
694
|
operator authorises a file, and its contents are their responsibility.
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAyBH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,oFAAoF;IACpF,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAoCpD;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAyBH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,oFAAoF;IACpF,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAoCpD;AAkID,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA0B1D"}
|
package/dist/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ import { relative, resolve as resolvePath } from "node:path";
|
|
|
18
18
|
import { pathToFileURL } from "node:url";
|
|
19
19
|
import { UnsafeGrantError } from "./grant-env.js";
|
|
20
20
|
import { applyInit, countDeclaring, planInit } from "./init.js";
|
|
21
|
-
import { discoverSkillPackages } from "./skill-packages.js";
|
|
21
|
+
import { discoverSkillPackages, skillPackageRoots } from "./skill-packages.js";
|
|
22
22
|
const USAGE = `pi-daddy — capability governance for pi sub-agents
|
|
23
23
|
|
|
24
24
|
Usage:
|
|
@@ -85,9 +85,15 @@ export function parseArgs(argv) {
|
|
|
85
85
|
async function init(cwd, force) {
|
|
86
86
|
const packages = await discoverSkillPackages(cwd);
|
|
87
87
|
if (packages.length === 0) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
// Names BOTH roots it looked in, and offers pi's own install command first. The previous message named
|
|
89
|
+
// only `<cwd>/node_modules` and said "npm install …" — so an operator who had just run
|
|
90
|
+
// `pi install npm:principal-pi-skills`, which installs to the agent root, was told to install a package
|
|
91
|
+
// they had already installed (R-75).
|
|
92
|
+
console.log(`pi-daddy init: no installed package declares skills (a package.json "pi": {"skills": [...]} ` +
|
|
93
|
+
`field). Nothing to scaffold.\n\nLooked in:\n` +
|
|
94
|
+
skillPackageRoots(cwd).map((r) => ` ${r}\n`).join("") +
|
|
95
|
+
`\n pi install npm:principal-pi-skills # seven skills, and registers it with pi\n` +
|
|
96
|
+
` npm install principal-pi-skills # or pin it in this project instead`);
|
|
91
97
|
return 0;
|
|
92
98
|
}
|
|
93
99
|
let plan;
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAiB,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAwC,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE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G;IAC1G,+EAA+E;IAC/E,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE;IAC5B,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACzG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC,EAAE,CAAC;AACL,IAAI,eAAe,EAAE,CAAC;IACpB,OAAO,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which executor runs a governed child — ADR-0031.
|
|
3
|
+
*
|
|
4
|
+
* `PI_GRANTS_HERDR` is three-state, and **absent means probe**. That reverses ADR-0016 point 6's opt-in, and
|
|
5
|
+
* the reversal is narrower than it sounds: nothing is detected from `herdr` being on `PATH` (option C, rejected
|
|
6
|
+
* by name), only from a server that *answered*. The grant, the depth bound, the gate and `--tools` enforcement
|
|
7
|
+
* are identical either way — `planSpawn` produces one plan and both executors enforce it.
|
|
8
|
+
*
|
|
9
|
+
* **Pure on purpose.** The probe is I/O and lives in `herdr-cli.ts`; the DECISION is a table, and a table that
|
|
10
|
+
* fits on one screen is the only reason a reversal like this is reviewable at all.
|
|
11
|
+
*
|
|
12
|
+
* The disclosure string is part of the return value rather than composed at the call site, because ADR-0031's
|
|
13
|
+
* defence against "this relocates silently" is that every outcome says what it chose AND what to set instead.
|
|
14
|
+
* Two call sites composing that separately is how one of them comes to omit it (R-28).
|
|
15
|
+
*/
|
|
16
|
+
import type { HerdrProbe } from "./herdr-cli.ts";
|
|
17
|
+
export declare const ENV_HERDR = "PI_GRANTS_HERDR";
|
|
18
|
+
export type ExecutorKind = "herdr" | "process";
|
|
19
|
+
export interface ExecutorChoice {
|
|
20
|
+
kind: ExecutorKind;
|
|
21
|
+
/** The operator named it: `PI_GRANTS_HERDR` was exactly `0` or `1`. */
|
|
22
|
+
forced: boolean;
|
|
23
|
+
/** Whether a probe was needed at all — false only for `0`. */
|
|
24
|
+
probed: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Set ONLY when herdr was demanded and is unreachable. Every delegation must refuse with this.
|
|
27
|
+
*
|
|
28
|
+
* Note that `kind` stays `"herdr"` in that case, deliberately: nothing downstream may mistake a refusing
|
|
29
|
+
* session for a working process-executor one.
|
|
30
|
+
*/
|
|
31
|
+
refusal?: string;
|
|
32
|
+
/** One line for the session banner and `/grants`. Always present. */
|
|
33
|
+
disclosure: string;
|
|
34
|
+
}
|
|
35
|
+
/** `0` is the one value that needs no probe: the operator ruled herdr out, so asking is pure cost. */
|
|
36
|
+
export declare function needsProbe(raw: string | undefined): boolean;
|
|
37
|
+
export declare function chooseExecutor(raw: string | undefined, probe: HerdrProbe | null): ExecutorChoice;
|
|
38
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,SAAS,oBAAoB,CAAC;AAE3C,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,uEAAuE;IACvE,MAAM,EAAE,OAAO,CAAC;IAChB,8DAA8D;IAC9D,MAAM,EAAE,OAAO,CAAC;IAChB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,sGAAsG;AACtG,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAE3D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,cAAc,CA6EhG"}
|
package/dist/executor.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which executor runs a governed child — ADR-0031.
|
|
3
|
+
*
|
|
4
|
+
* `PI_GRANTS_HERDR` is three-state, and **absent means probe**. That reverses ADR-0016 point 6's opt-in, and
|
|
5
|
+
* the reversal is narrower than it sounds: nothing is detected from `herdr` being on `PATH` (option C, rejected
|
|
6
|
+
* by name), only from a server that *answered*. The grant, the depth bound, the gate and `--tools` enforcement
|
|
7
|
+
* are identical either way — `planSpawn` produces one plan and both executors enforce it.
|
|
8
|
+
*
|
|
9
|
+
* **Pure on purpose.** The probe is I/O and lives in `herdr-cli.ts`; the DECISION is a table, and a table that
|
|
10
|
+
* fits on one screen is the only reason a reversal like this is reviewable at all.
|
|
11
|
+
*
|
|
12
|
+
* The disclosure string is part of the return value rather than composed at the call site, because ADR-0031's
|
|
13
|
+
* defence against "this relocates silently" is that every outcome says what it chose AND what to set instead.
|
|
14
|
+
* Two call sites composing that separately is how one of them comes to omit it (R-28).
|
|
15
|
+
*/
|
|
16
|
+
export const ENV_HERDR = "PI_GRANTS_HERDR";
|
|
17
|
+
/** `0` is the one value that needs no probe: the operator ruled herdr out, so asking is pure cost. */
|
|
18
|
+
export function needsProbe(raw) {
|
|
19
|
+
return raw === undefined || raw === "1";
|
|
20
|
+
}
|
|
21
|
+
export function chooseExecutor(raw, probe) {
|
|
22
|
+
if (raw === "0") {
|
|
23
|
+
return {
|
|
24
|
+
kind: "process",
|
|
25
|
+
forced: true,
|
|
26
|
+
probed: false,
|
|
27
|
+
disclosure: "captured subprocess (PI_GRANTS_HERDR=0) — children have no terminal",
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (raw === "1") {
|
|
31
|
+
if (probe?.ok) {
|
|
32
|
+
return { kind: "herdr", forced: true, probed: true, disclosure: "herdr panes (PI_GRANTS_HERDR=1)" };
|
|
33
|
+
}
|
|
34
|
+
// Refusal, not fallback — the operator's decision of 2026-08-17, against the alternative of falling back
|
|
35
|
+
// loudly. A fallback nobody reads is R-25's shape; refusing keeps the ledger unable to name a child that
|
|
36
|
+
// ran somewhere nobody chose. A `null` probe lands here too: if the probe failed so badly it produced no
|
|
37
|
+
// result, herdr was still demanded, and failing closed means refusing.
|
|
38
|
+
const why = probe?.error ?? "the herdr probe did not succeed";
|
|
39
|
+
return {
|
|
40
|
+
kind: "herdr",
|
|
41
|
+
forced: true,
|
|
42
|
+
probed: true,
|
|
43
|
+
refusal: `PI_GRANTS_HERDR=1 demands the herdr executor and herdr is not answering (${why}). ` +
|
|
44
|
+
`Delegation is refused rather than quietly relocated to a captured subprocess, so this session's ` +
|
|
45
|
+
`ledger can never contain a child that ran somewhere nobody chose. Start herdr, or unset ` +
|
|
46
|
+
`PI_GRANTS_HERDR to let this session probe, or set PI_GRANTS_HERDR=0 to choose subprocesses.`,
|
|
47
|
+
disclosure: `herdr panes DEMANDED but unreachable (${why}) — every delegation will refuse`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (raw !== undefined) {
|
|
51
|
+
// Rule 8: fail closed and be loud. An unrecognised value must not relocate a run, and must not break
|
|
52
|
+
// delegation either — the operator meant *something*, and the dependency-free executor is the safe read.
|
|
53
|
+
// The empty string lands here rather than with `undefined`, which keeps absent-versus-empty
|
|
54
|
+
// distinguishable exactly as `PI_GRANTS_GATED` does.
|
|
55
|
+
return {
|
|
56
|
+
kind: "process",
|
|
57
|
+
forced: false,
|
|
58
|
+
probed: probe !== null,
|
|
59
|
+
disclosure: `captured subprocess — PI_GRANTS_HERDR is set to an unrecognised value and was ignored. ` +
|
|
60
|
+
`Use 1 (demand herdr panes), 0 (demand subprocesses), or unset it to probe.`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (probe?.ok) {
|
|
64
|
+
return { kind: "herdr", forced: false, probed: true, disclosure: "herdr panes (probed — herdr is answering)" };
|
|
65
|
+
}
|
|
66
|
+
if (probe === null) {
|
|
67
|
+
// **The pre-probe seed, and it must not claim a probe happened.** `createGrantsSession` builds a choice
|
|
68
|
+
// synchronously with `probe: null` because S-5 forces the factory to run before any hook; `resolveExecutor`
|
|
69
|
+
// replaces it during `session_start`. This branch previously fell through to the one below and reported
|
|
70
|
+
// `probed: true` with the word "(probed)" in its disclosure — a fabricated observation, indistinguishable
|
|
71
|
+
// from a real negative probe.
|
|
72
|
+
//
|
|
73
|
+
// Unreachable in practice today (pi awaits the `session_start` emit before the first prompt, verified by a
|
|
74
|
+
// reviewer against real pi), which is exactly why it is worth making honest rather than leaving to be
|
|
75
|
+
// discovered: if a throw ever strands a session on this reading, the disclosure should say so.
|
|
76
|
+
return {
|
|
77
|
+
kind: "process",
|
|
78
|
+
forced: false,
|
|
79
|
+
probed: false,
|
|
80
|
+
disclosure: "not yet probed — settling at session start",
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
kind: "process",
|
|
85
|
+
forced: false,
|
|
86
|
+
probed: true,
|
|
87
|
+
// Names the remedy on the same line as the state. The gap that produced ADR-0031 was not that the
|
|
88
|
+
// operator could not see which executor ran — it was that seeing it would not have told them what to do.
|
|
89
|
+
disclosure: `captured subprocess (probed — no herdr answering${probe?.error ? `: ${probe.error}` : ""}). ` +
|
|
90
|
+
`Set PI_GRANTS_HERDR=1 to demand panes.`,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,CAAC,MAAM,SAAS,GAAG,iBAAiB,CAAC;AAqB3C,sGAAsG;AACtG,MAAM,UAAU,UAAU,CAAC,GAAuB;IAChD,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,GAAG,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAuB,EAAE,KAAwB;IAC9E,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;QAChB,OAAO;YACL,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,qEAAqE;SAClF,CAAC;IACJ,CAAC;IAED,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,KAAK,EAAE,EAAE,EAAE,CAAC;YACd,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,iCAAiC,EAAE,CAAC;QACtG,CAAC;QACD,yGAAyG;QACzG,yGAAyG;QACzG,yGAAyG;QACzG,uEAAuE;QACvE,MAAM,GAAG,GAAG,KAAK,EAAE,KAAK,IAAI,iCAAiC,CAAC;QAC9D,OAAO;YACL,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,IAAI;YACZ,OAAO,EACL,4EAA4E,GAAG,KAAK;gBACpF,kGAAkG;gBAClG,0FAA0F;gBAC1F,6FAA6F;YAC/F,UAAU,EAAE,yCAAyC,GAAG,kCAAkC;SAC3F,CAAC;IACJ,CAAC;IAED,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,qGAAqG;QACrG,yGAAyG;QACzG,4FAA4F;QAC5F,qDAAqD;QACrD,OAAO;YACL,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,KAAK,KAAK,IAAI;YACtB,UAAU,EACR,yFAAyF;gBACzF,4EAA4E;SAC/E,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,EAAE,EAAE,EAAE,CAAC;QACd,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,2CAA2C,EAAE,CAAC;IACjH,CAAC;IACD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,wGAAwG;QACxG,4GAA4G;QAC5G,wGAAwG;QACxG,0GAA0G;QAC1G,8BAA8B;QAC9B,EAAE;QACF,2GAA2G;QAC3G,sGAAsG;QACtG,+FAA+F;QAC/F,OAAO;YACL,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,4CAA4C;SACzD,CAAC;IACJ,CAAC;IACD,OAAO;QACL,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,IAAI;QACZ,kGAAkG;QAClG,yGAAyG;QACzG,UAAU,EACR,mDAAmD,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK;YAC9F,wCAAwC;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The grant for a directory, stored **outside** it.
|
|
3
|
+
*
|
|
4
|
+
* `PI_GRANTS_GRANT` is the propagation channel to children and stays exactly as it was — a parent writes
|
|
5
|
+
* it once per session and every child inherits it. What this adds is a second *source* for the root
|
|
6
|
+
* session's own grant, so an operator does not have to `source` a file and restart pi to be governed.
|
|
7
|
+
*
|
|
8
|
+
* **Outside the workspace, and that is the whole design.** A grant is a ceiling; a ceiling a governed child
|
|
9
|
+
* can rewrite is not a ceiling. `<cwd>/.pi/grants.env` is writable by any child holding `tool:write`, so
|
|
10
|
+
* storing the live grant there would let a child widen the *next* session's ceiling — ADR-0014's
|
|
11
|
+
* self-defeating case verbatim, which is why persisted approvals were moved out of the workspace in the
|
|
12
|
+
* first place. This reuses that pattern exactly: `$PI_CODING_AGENT_DIR/grants/<slug>-<hash>.json`, keyed by
|
|
13
|
+
* the directory, unwritable by a narrowed child because a narrowed child holds no write access to `$HOME`.
|
|
14
|
+
*
|
|
15
|
+
* **It does not defend against a child holding `bash`** (ADR-0012). Nothing here does.
|
|
16
|
+
*
|
|
17
|
+
* `.pi/grants.env` is still written by `init` and is still worth committing — it is the *reviewable record*
|
|
18
|
+
* of the decision, diffable in a PR. It is simply no longer the thing the enforcer reads.
|
|
19
|
+
*/
|
|
20
|
+
import type { Capability } from "./resolve.ts";
|
|
21
|
+
/**
|
|
22
|
+
* Where this directory's grant lives.
|
|
23
|
+
*
|
|
24
|
+
* Slug plus a 64-bit hash, exactly as `approvalsPath` does it and for the same two reasons: the basename
|
|
25
|
+
* keeps the directory legible to a human reading it, and the hash is what makes it unambiguous, since two
|
|
26
|
+
* checkouts can share a basename.
|
|
27
|
+
*/
|
|
28
|
+
export declare function grantStorePath(cwd: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Parse a store file's text into a grant, or null.
|
|
31
|
+
*
|
|
32
|
+
* Split out from the readers so the **one** validation lives in one place: both the sync and async paths
|
|
33
|
+
* must agree, and two parsers is how they come to disagree.
|
|
34
|
+
*
|
|
35
|
+
* Fails closed on every doubt — a malformed file grants nothing rather than something. The `cwd` check is
|
|
36
|
+
* R-27's: a file copied to another machine or another checkout describes a directory that is not this one,
|
|
37
|
+
* and honouring it would let a grant travel somewhere nobody authorised it for.
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseGrantFile(text: string, cwd: string): Capability[] | null;
|
|
40
|
+
/**
|
|
41
|
+
* Read this directory's stored grant, synchronously.
|
|
42
|
+
*
|
|
43
|
+
* **Sync on purpose, and this is the constraint that shapes the feature.** Whether `delegate` is registered
|
|
44
|
+
* at all is decided when the extension factory runs (S-5: a session without `tool:delegate` must not be
|
|
45
|
+
* offered the tool), and that is before any `await` is possible. An async read would resolve after the
|
|
46
|
+
* decision it exists to inform, so the store would silently fail to grant delegation — the exact class of
|
|
47
|
+
* defect R-38 and R-39 were.
|
|
48
|
+
*/
|
|
49
|
+
export declare function loadGrantSync(cwd: string): Capability[] | null;
|
|
50
|
+
/** Async twin, for callers that already have one. Same parser, so they cannot disagree. */
|
|
51
|
+
export declare function loadGrant(cwd: string): Promise<Capability[] | null>;
|
|
52
|
+
export type SaveOutcome = "saved" | "failed" | "busy";
|
|
53
|
+
/**
|
|
54
|
+
* Write this directory's grant.
|
|
55
|
+
*
|
|
56
|
+
* Locked with the same lock the ledger and the approval store use, for the same reason: two sessions in one
|
|
57
|
+
* directory running `/grants init` concurrently must not interleave. A lock this cannot take yields `busy`
|
|
58
|
+
* and changes nothing — the caller reports it and the operator retries, which is the honest outcome for a
|
|
59
|
+
* write that never looked at the file (R-68).
|
|
60
|
+
*
|
|
61
|
+
* `wx` on the temp file refuses to follow a pre-existing symlink, and `rename` is atomic within a
|
|
62
|
+
* filesystem, so a reader never sees a half-written grant. Both copied from `writeFileSafely`, deliberately
|
|
63
|
+
* — a second, subtly different atomic-write is how the two come to disagree about what "safe" meant.
|
|
64
|
+
*/
|
|
65
|
+
export declare function saveGrant(cwd: string, grant: Capability[]): Promise<SaveOutcome>;
|
|
66
|
+
/** Remove this directory's stored grant. True when a file was there to remove. */
|
|
67
|
+
export declare function clearGrant(cwd: string): Promise<boolean>;
|
|
68
|
+
//# sourceMappingURL=grant-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grant-store.d.ts","sourceRoot":"","sources":["../src/grant-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AASH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgB/C;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,EAAE,GAAG,IAAI,CAW7E;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,EAAE,GAAG,IAAI,CAM9D;AAED,2FAA2F;AAC3F,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,CAMzE;AAED,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEtD;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAmBtF;AAED,kFAAkF;AAClF,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAS9D"}
|