pi-daddy 0.25.0 → 0.25.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/CHANGELOG.md +11 -0
- package/README.md +1 -1
- package/THIRD_PARTY_LICENSES/herdr-Apache-2.0.txt +201 -0
- package/THIRD_PARTY_NOTICES.md +7 -0
- package/dist/herdr-pi-lifecycle.d.ts +8 -0
- package/dist/herdr-pi-lifecycle.d.ts.map +1 -0
- package/dist/herdr-pi-lifecycle.js +22 -0
- package/dist/herdr-pi-lifecycle.js.map +1 -0
- package/dist/herdr-poll.d.ts +21 -0
- package/dist/herdr-poll.d.ts.map +1 -1
- package/dist/herdr-poll.js +52 -3
- package/dist/herdr-poll.js.map +1 -1
- package/dist/herdr-start.d.ts +9 -0
- package/dist/herdr-start.d.ts.map +1 -0
- package/dist/herdr-start.js +15 -0
- package/dist/herdr-start.js.map +1 -0
- package/dist/run-herdr.d.ts +3 -3
- package/dist/run-herdr.d.ts.map +1 -1
- package/dist/run-herdr.js +28 -33
- package/dist/run-herdr.js.map +1 -1
- package/dist/vendor/herdr-pi-lifecycle.d.ts +2 -0
- package/dist/vendor/herdr-pi-lifecycle.d.ts.map +1 -0
- package/dist/vendor/herdr-pi-lifecycle.js +223 -0
- package/dist/vendor/herdr-pi-lifecycle.js.map +1 -0
- package/package.json +3 -1
- package/src/herdr-pi-lifecycle.ts +21 -0
- package/src/herdr-poll.ts +52 -2
- package/src/herdr-start.ts +20 -0
- package/src/run-herdr.ts +28 -40
- package/src/vendor/herdr-pi-lifecycle.ts +257 -0
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,17 @@ the record of how the package got here and are worth keeping; they are not worth
|
|
|
12
12
|
> the record of how the package arrived at what it does, and because the reasoning behind each one is
|
|
13
13
|
> usually the clearest statement of why the current behaviour is what it is.
|
|
14
14
|
|
|
15
|
+
## 0.25.1 — reliable Herdr child completion (2026-09-12)
|
|
16
|
+
|
|
17
|
+
- Fix a governed child finishing while its parent keeps waiting with Pi 0.85.1 and Herdr 0.8.2.
|
|
18
|
+
Children explicitly load the pinned, lifecycle-only Herdr integration; general extension discovery
|
|
19
|
+
stays disabled and the granted tool surface is unchanged.
|
|
20
|
+
- Require native idle activation before prompting and a newer terminal sequence before settlement.
|
|
21
|
+
Missing activation or stale terminal state refuses within a bounded wait and cleans up the child.
|
|
22
|
+
- Preserve existing public exports and ship the upstream Apache-2.0 notice and license.
|
|
23
|
+
- Verified route: Pi 0.85.1 / Herdr 0.8.2. Ordinary subprocess compatibility is unchanged.
|
|
24
|
+
This does not repair standalone Herdr screen detection or the separate first-use host setup errors.
|
|
25
|
+
|
|
15
26
|
## 0.25.0 — practical daily steering and measured orders (2026-09-12)
|
|
16
27
|
|
|
17
28
|
- Add protocol-safe dashboard relink, exact active-attempt cancellation and durable measured-session spawn acknowledgement. Unknown/protocol-incompatible plugins still fail closed.
|
package/README.md
CHANGED
|
@@ -887,4 +887,4 @@ Known gaps, stated because a gap nobody wrote down is the one that surprises som
|
|
|
887
887
|
|
|
888
888
|
`docs/SPEC.md` in the repository is the authoritative current-state document; the ADRs hold the reasoning.
|
|
889
889
|
|
|
890
|
-
Requires pi ≥ 0.83.0
|
|
890
|
+
Requires pi ≥ 0.83.0 and Node ≥ 22.19. The ordinary subprocess route retains that floor; the bundled native Herdr lifecycle child route is verified with Herdr 0.8.2 and Pi 0.85.1 and refuses if its lifecycle authority cannot activate. MIT.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
## Herdr Pi lifecycle integration
|
|
4
|
+
|
|
5
|
+
`src/vendor/herdr-pi-lifecycle.ts` is the unmodified official Herdr Pi lifecycle integration, copied from Herdr `v0.8.2`, blob `67bc41889abc2791d6dcdfe8279bdc24186cc6fe` (SHA-256 `9b1c41cd72520fc2abe5f2a2aec995c12a926cce844df472c7fd5fcae4f4dbfa`).
|
|
6
|
+
|
|
7
|
+
It is licensed under Apache License 2.0. A copy of that license is distributed at `THIRD_PARTY_LICENSES/herdr-Apache-2.0.txt`.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explicit `-e` survives Pi's `--no-extensions`; only this audited source is loaded for a Herdr child.
|
|
3
|
+
*
|
|
4
|
+
* Source-loaded tests resolve the adjacent vendor file. Installed builds resolve the packed `src/` copy,
|
|
5
|
+
* deliberately rather than discovering an operator's extension directory.
|
|
6
|
+
*/
|
|
7
|
+
export declare function bundledHerdrPiLifecycleExtension(): string;
|
|
8
|
+
//# sourceMappingURL=herdr-pi-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"herdr-pi-lifecycle.d.ts","sourceRoot":"","sources":["../src/herdr-pi-lifecycle.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAgB,gCAAgC,IAAI,MAAM,CAUzD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Locate the pinned, lifecycle-only Herdr Pi integration shipped with this package. */
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
/**
|
|
5
|
+
* Explicit `-e` survives Pi's `--no-extensions`; only this audited source is loaded for a Herdr child.
|
|
6
|
+
*
|
|
7
|
+
* Source-loaded tests resolve the adjacent vendor file. Installed builds resolve the packed `src/` copy,
|
|
8
|
+
* deliberately rather than discovering an operator's extension directory.
|
|
9
|
+
*/
|
|
10
|
+
export function bundledHerdrPiLifecycleExtension() {
|
|
11
|
+
const candidates = [
|
|
12
|
+
new URL("./vendor/herdr-pi-lifecycle.ts", import.meta.url),
|
|
13
|
+
new URL("../src/vendor/herdr-pi-lifecycle.ts", import.meta.url),
|
|
14
|
+
];
|
|
15
|
+
for (const candidate of candidates) {
|
|
16
|
+
const path = fileURLToPath(candidate);
|
|
17
|
+
if (existsSync(path))
|
|
18
|
+
return path;
|
|
19
|
+
}
|
|
20
|
+
throw new Error("the bundled Herdr Pi lifecycle integration is missing from this package");
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=herdr-pi-lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"herdr-pi-lifecycle.js","sourceRoot":"","sources":["../src/herdr-pi-lifecycle.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC;IAC9C,MAAM,UAAU,GAAG;QACjB,IAAI,GAAG,CAAC,gCAAgC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAC1D,IAAI,GAAG,CAAC,qCAAqC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;KAChE,CAAC;IACF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,IAAI,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;QACtC,IAAI,UAAU,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IACpC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;AAC7F,CAAC"}
|
package/dist/herdr-poll.d.ts
CHANGED
|
@@ -44,6 +44,15 @@ export declare function observeHerdrSession(agent: unknown, pane: string | undef
|
|
|
44
44
|
export declare function seqOf(result: Record<string, unknown> | undefined): number;
|
|
45
45
|
/** How often to poll `agent get` while waiting for the child to settle. */
|
|
46
46
|
export declare const POLL_INTERVAL_MS = 750;
|
|
47
|
+
/**
|
|
48
|
+
* A prompt accepted from a terminal state must produce an observable lifecycle change promptly.
|
|
49
|
+
*
|
|
50
|
+
* Herdr 0.8's `agent prompt --wait` documents this same five-second bound. We retain polling because it
|
|
51
|
+
* supplies the bounded live pane snapshots, but refuse rather than holding a parent for twenty minutes when
|
|
52
|
+
* the only reported state remains the pre-prompt terminal state. That is a detector/integration failure, not
|
|
53
|
+
* evidence that a child settled.
|
|
54
|
+
*/
|
|
55
|
+
export declare const FRESH_LIFECYCLE_TIMEOUT_MS = 5000;
|
|
47
56
|
/** Lines of pane tail reported per poll. Matches the status block's own tail, so nothing is fetched unused. */
|
|
48
57
|
export declare const DEFAULT_SNAPSHOT_LINES = 3;
|
|
49
58
|
/**
|
|
@@ -59,6 +68,18 @@ export declare const DEFAULT_SNAPSHOT_LINES = 3;
|
|
|
59
68
|
* `state_change_seq` has advanced past the value observed before prompting. `agent wait` is deliberately
|
|
60
69
|
* not used at all: its contract cannot express "settled *after* this point".
|
|
61
70
|
*/
|
|
71
|
+
/**
|
|
72
|
+
* Establish the bundled Pi lifecycle reporter's idle baseline before prompt dispatch.
|
|
73
|
+
*
|
|
74
|
+
* `screen_detection_skipped` is Herdr's reported fact that a full lifecycle authority owns this pane.
|
|
75
|
+
* Waiting for it prevents the reporter's asynchronously queued initial idle report from becoming a
|
|
76
|
+
* post-prompt sequence advance. This is not completion: no prompt has been sent at this point.
|
|
77
|
+
*/
|
|
78
|
+
export declare function waitForLifecycleBaseline(exec: HerdrExec, request: PollTarget, deadline: number): Promise<{
|
|
79
|
+
before?: number;
|
|
80
|
+
aborted?: boolean;
|
|
81
|
+
spawnError?: string;
|
|
82
|
+
}>;
|
|
62
83
|
export declare function waitForSettled(exec: HerdrExec, request: PollTarget, before: number, deadline: number, maxOutputBytes: number): Promise<{
|
|
63
84
|
status?: string;
|
|
64
85
|
timedOut?: boolean;
|
package/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;CAAE,CAAC,CAuBpE"}
|
package/dist/herdr-poll.js
CHANGED
|
@@ -31,6 +31,15 @@ export function seqOf(result) {
|
|
|
31
31
|
}
|
|
32
32
|
/** How often to poll `agent get` while waiting for the child to settle. */
|
|
33
33
|
export const POLL_INTERVAL_MS = 750;
|
|
34
|
+
/**
|
|
35
|
+
* A prompt accepted from a terminal state must produce an observable lifecycle change promptly.
|
|
36
|
+
*
|
|
37
|
+
* Herdr 0.8's `agent prompt --wait` documents this same five-second bound. We retain polling because it
|
|
38
|
+
* supplies the bounded live pane snapshots, but refuse rather than holding a parent for twenty minutes when
|
|
39
|
+
* the only reported state remains the pre-prompt terminal state. That is a detector/integration failure, not
|
|
40
|
+
* evidence that a child settled.
|
|
41
|
+
*/
|
|
42
|
+
export const FRESH_LIFECYCLE_TIMEOUT_MS = 5_000;
|
|
34
43
|
/** Lines of pane tail reported per poll. Matches the status block's own tail, so nothing is fetched unused. */
|
|
35
44
|
export const DEFAULT_SNAPSHOT_LINES = 3;
|
|
36
45
|
/**
|
|
@@ -46,6 +55,30 @@ export const DEFAULT_SNAPSHOT_LINES = 3;
|
|
|
46
55
|
* `state_change_seq` has advanced past the value observed before prompting. `agent wait` is deliberately
|
|
47
56
|
* not used at all: its contract cannot express "settled *after* this point".
|
|
48
57
|
*/
|
|
58
|
+
/**
|
|
59
|
+
* Establish the bundled Pi lifecycle reporter's idle baseline before prompt dispatch.
|
|
60
|
+
*
|
|
61
|
+
* `screen_detection_skipped` is Herdr's reported fact that a full lifecycle authority owns this pane.
|
|
62
|
+
* Waiting for it prevents the reporter's asynchronously queued initial idle report from becoming a
|
|
63
|
+
* post-prompt sequence advance. This is not completion: no prompt has been sent at this point.
|
|
64
|
+
*/
|
|
65
|
+
export async function waitForLifecycleBaseline(exec, request, deadline) {
|
|
66
|
+
const interval = request.pollIntervalMs ?? POLL_INTERVAL_MS;
|
|
67
|
+
for (;;) {
|
|
68
|
+
if (request.signal?.aborted)
|
|
69
|
+
return { aborted: true };
|
|
70
|
+
if (Date.now() >= deadline)
|
|
71
|
+
return { spawnError: "Herdr did not activate the bundled Pi lifecycle reporter before prompt dispatch" };
|
|
72
|
+
const reply = parseReply(await exec(["agent", "get", request.name]));
|
|
73
|
+
if (reply.error)
|
|
74
|
+
return { spawnError: `herdr agent get failed: ${reply.error}` };
|
|
75
|
+
const agent = (reply.result?.agent ?? reply.result ?? {});
|
|
76
|
+
const seq = typeof agent.state_change_seq === "number" ? agent.state_change_seq : -1;
|
|
77
|
+
if (agent.screen_detection_skipped === true && agent.agent_status && TERMINAL.has(agent.agent_status) && seq >= 0)
|
|
78
|
+
return { before: seq };
|
|
79
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(interval, Math.max(0, deadline - Date.now()))));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
49
82
|
export async function waitForSettled(exec, request, before, deadline, maxOutputBytes) {
|
|
50
83
|
const interval = request.pollIntervalMs ?? POLL_INTERVAL_MS;
|
|
51
84
|
// ADR-0032. The pane is read on every poll so the parent can show what the child is doing, rather than the
|
|
@@ -54,6 +87,7 @@ export async function waitForSettled(exec, request, before, deadline, maxOutputB
|
|
|
54
87
|
// No cross-poll state is kept, deliberately: the previous design remembered what it had reported so it could
|
|
55
88
|
// send a diff, and that is what broke — see `tailLines`. A snapshot needs no memory.
|
|
56
89
|
const keep = request.snapshotLines ?? DEFAULT_SNAPSHOT_LINES;
|
|
90
|
+
let staleTerminalSince;
|
|
57
91
|
for (;;) {
|
|
58
92
|
if (request.signal?.aborted)
|
|
59
93
|
return { aborted: true };
|
|
@@ -84,9 +118,24 @@ export async function waitForSettled(exec, request, before, deadline, maxOutputB
|
|
|
84
118
|
/* display only — a renderer must not break a governed run */
|
|
85
119
|
}
|
|
86
120
|
}
|
|
87
|
-
if (status && TERMINAL.has(status)
|
|
88
|
-
|
|
89
|
-
|
|
121
|
+
if (status && TERMINAL.has(status)) {
|
|
122
|
+
if (seq > before)
|
|
123
|
+
return { status };
|
|
124
|
+
// Do not turn this pane's text into a completion signal. A known agent whose screen rule misses a new
|
|
125
|
+
// UI shape falls back to idle, precisely the state R-33 says is unsafe to accept. A stable stale
|
|
126
|
+
// terminal state for this bounded interval is instead a loud compatibility refusal (issue #43).
|
|
127
|
+
staleTerminalSince ??= Date.now();
|
|
128
|
+
if (Date.now() - staleTerminalSince >= FRESH_LIFECYCLE_TIMEOUT_MS) {
|
|
129
|
+
return {
|
|
130
|
+
spawnError: `herdr reported ${status} without a post-prompt lifecycle change for ${FRESH_LIFECYCLE_TIMEOUT_MS}ms; ` +
|
|
131
|
+
"refusing to treat the pre-prompt terminal state as completion. Update Herdr's Pi detector or inspect its lifecycle reporting.",
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
staleTerminalSince = undefined;
|
|
137
|
+
}
|
|
138
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(interval, Math.max(0, deadline - Date.now()))));
|
|
90
139
|
}
|
|
91
140
|
}
|
|
92
141
|
/**
|
package/dist/herdr-poll.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"herdr-poll.js","sourceRoot":"","sources":["../src/herdr-poll.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAkB,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AA8B5D,4GAA4G;AAC5G,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAEtD,0FAA0F;AAC1F,MAAM,UAAU,mBAAmB,CAAC,KAAc,EAAE,IAAwB,EAAE,IAAsC;IAClH,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI;QAAE,OAAO;IAC3B,IAAI,CAAC;QAAC,MAAM,SAAS,GAAG,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QA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AAM,CAAC;QACP,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC;IACtB,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,cAAc;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACjF,sGAAsG;IACtG,qGAAqG;IACrG,yFAAyF;IACzF,EAAE;IACF,iGAAiG;IACjG,4GAA4G;IAC5G,sGAAsG;IACtG,8DAA8D;IAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACzG,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Start a Pi agent only after its newly-created Herdr pane reaches a shell prompt. */
|
|
2
|
+
import { type HerdrExec } from "./herdr-cli.ts";
|
|
3
|
+
/** Retry cadence for Herdr's documented `agent_pane_busy` startup race. */
|
|
4
|
+
export declare const PANE_READY_POLL_MS = 300;
|
|
5
|
+
export declare function startHerdrAgent(exec: HerdrExec, name: string, paneId: string, args: string[], deadline: number): Promise<{
|
|
6
|
+
result?: Record<string, unknown>;
|
|
7
|
+
error?: string;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=herdr-start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"herdr-start.d.ts","sourceRoot":"","sources":["../src/herdr-start.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE5D,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,wBAAsB,eAAe,CACnC,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAO/D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Start a Pi agent only after its newly-created Herdr pane reaches a shell prompt. */
|
|
2
|
+
import { parseReply } from "./herdr-cli.js";
|
|
3
|
+
/** Retry cadence for Herdr's documented `agent_pane_busy` startup race. */
|
|
4
|
+
export const PANE_READY_POLL_MS = 300;
|
|
5
|
+
export async function startHerdrAgent(exec, name, paneId, args, deadline) {
|
|
6
|
+
for (;;) {
|
|
7
|
+
const reply = parseReply(await exec(["agent", "start", name, "--kind", "pi", "--pane", paneId, "--", ...args]));
|
|
8
|
+
if (!reply.error)
|
|
9
|
+
return reply;
|
|
10
|
+
if (!/not an available shell|agent_pane_busy/.test(reply.error) || Date.now() >= deadline)
|
|
11
|
+
return reply;
|
|
12
|
+
await new Promise((resolve) => setTimeout(resolve, PANE_READY_POLL_MS));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=herdr-start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"herdr-start.js","sourceRoot":"","sources":["../src/herdr-start.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,EAAE,UAAU,EAAkB,MAAM,gBAAgB,CAAC;AAE5D,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAe,EACf,IAAY,EACZ,MAAc,EACd,IAAc,EACd,QAAgB;IAEhB,SAAS,CAAC;QACR,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAChH,IAAI,CAAC,KAAK,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QAC/B,IAAI,CAAC,wCAAwC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ;YAAE,OAAO,KAAK,CAAC;QACxG,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAChF,CAAC;AACH,CAAC"}
|
package/dist/run-herdr.d.ts
CHANGED
|
@@ -34,13 +34,15 @@ export { type HerdrExec, parseReply } from "./herdr-cli.ts";
|
|
|
34
34
|
export { splitSystemPrompt, stageSystemPrompt } from "./herdr-stage.ts";
|
|
35
35
|
/** Re-exported: the name rules moved to `./herdr-name.ts` under the ceiling; tests import them here. */
|
|
36
36
|
export { uniqueAgentName } from "./herdr-name.ts";
|
|
37
|
+
/** Re-exported after startup retry extraction; existing executor importers keep this public constant. */
|
|
38
|
+
export { PANE_READY_POLL_MS } from "./herdr-start.ts";
|
|
37
39
|
/**
|
|
38
40
|
* Re-exported so `test/run-herdr.test.ts` and any importer keep reaching these where they always were.
|
|
39
41
|
*
|
|
40
42
|
* `POLL_INTERVAL_MS` and `newSuffix` moved to `./herdr-poll.ts` under the 400-line ceiling; the names are part
|
|
41
43
|
* of this module's surface and moving a file should not move an export.
|
|
42
44
|
*/
|
|
43
|
-
export { DEFAULT_SNAPSHOT_LINES, POLL_INTERVAL_MS, readPane, tailLines, waitForSettled, type PollTarget } from "./herdr-poll.ts";
|
|
45
|
+
export { DEFAULT_SNAPSHOT_LINES, POLL_INTERVAL_MS, readPane, tailLines, waitForLifecycleBaseline, waitForSettled, type PollTarget } from "./herdr-poll.ts";
|
|
44
46
|
export interface HerdrRunRequest {
|
|
45
47
|
/** `planSpawn` args **without** the prompt — see `prompt`. */
|
|
46
48
|
args: string[];
|
|
@@ -107,8 +109,6 @@ export interface HerdrRunRequest {
|
|
|
107
109
|
export declare class HerdrWriterCloseError extends Error {
|
|
108
110
|
constructor(tabId: string);
|
|
109
111
|
}
|
|
110
|
-
/** How often to retry `agent start` while a freshly created pane is still reaching its shell prompt. */
|
|
111
|
-
export declare const PANE_READY_POLL_MS = 300;
|
|
112
112
|
/**
|
|
113
113
|
* Run one governed child in a pane and return its output.
|
|
114
114
|
*
|
package/dist/run-herdr.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-herdr.d.ts","sourceRoot":"","sources":["../src/run-herdr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,
|
|
1
|
+
{"version":3,"file":"run-herdr.d.ts","sourceRoot":"","sources":["../src/run-herdr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAuG,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMvJ;;;;;GAKG;AACH,OAAO,EAAE,KAAK,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5D,gHAAgH;AAChH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxE,wGAAwG;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,yGAAyG;AACzG,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD;;;;;GAKG;AACH,OAAO,EAAE,s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C;IACtC,kBAAkB,CAAC,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACtD,uGAAuG;IACvG,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kGAAkG;IAClG,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAGD,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,KAAK,EAAE,MAAM;CAI1B;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CA2PpF"}
|
package/dist/run-herdr.js
CHANGED
|
@@ -25,9 +25,11 @@ import { runWithFinalizers } from "./finalization.js";
|
|
|
25
25
|
import { DEFAULT_MAX_OUTPUT_BYTES, DEFAULT_TIMEOUT_MS } from "./run-child.js";
|
|
26
26
|
import { MAX_OPEN_PANES, markPaneSettled, trackPane, trimOpenPanes, untrackPane } from "./pane-reaper.js";
|
|
27
27
|
import { defaultExec, parseReply } from "./herdr-cli.js";
|
|
28
|
-
import { readPane,
|
|
28
|
+
import { FRESH_LIFECYCLE_TIMEOUT_MS, readPane, waitForLifecycleBaseline, waitForSettled, observeHerdrSession } from "./herdr-poll.js";
|
|
29
29
|
import { stageSystemPrompt } from "./herdr-stage.js";
|
|
30
30
|
import { uniqueAgentName } from "./herdr-name.js";
|
|
31
|
+
import { bundledHerdrPiLifecycleExtension } from "./herdr-pi-lifecycle.js";
|
|
32
|
+
import { startHerdrAgent } from "./herdr-start.js";
|
|
31
33
|
/**
|
|
32
34
|
* Re-exported so importers of the executor still reach the protocol at the name they always used.
|
|
33
35
|
*
|
|
@@ -39,21 +41,21 @@ export { parseReply } from "./herdr-cli.js";
|
|
|
39
41
|
export { splitSystemPrompt, stageSystemPrompt } from "./herdr-stage.js";
|
|
40
42
|
/** Re-exported: the name rules moved to `./herdr-name.ts` under the ceiling; tests import them here. */
|
|
41
43
|
export { uniqueAgentName } from "./herdr-name.js";
|
|
44
|
+
/** Re-exported after startup retry extraction; existing executor importers keep this public constant. */
|
|
45
|
+
export { PANE_READY_POLL_MS } from "./herdr-start.js";
|
|
42
46
|
/**
|
|
43
47
|
* Re-exported so `test/run-herdr.test.ts` and any importer keep reaching these where they always were.
|
|
44
48
|
*
|
|
45
49
|
* `POLL_INTERVAL_MS` and `newSuffix` moved to `./herdr-poll.ts` under the 400-line ceiling; the names are part
|
|
46
50
|
* of this module's surface and moving a file should not move an export.
|
|
47
51
|
*/
|
|
48
|
-
export { DEFAULT_SNAPSHOT_LINES, POLL_INTERVAL_MS, readPane, tailLines, waitForSettled } from "./herdr-poll.js";
|
|
52
|
+
export { DEFAULT_SNAPSHOT_LINES, POLL_INTERVAL_MS, readPane, tailLines, waitForLifecycleBaseline, waitForSettled } from "./herdr-poll.js";
|
|
49
53
|
export class HerdrWriterCloseError extends Error {
|
|
50
54
|
constructor(tabId) {
|
|
51
55
|
super(`herdr writer tab ${tabId} could not be closed; retaining its workspace lease`);
|
|
52
56
|
this.name = "HerdrWriterCloseError";
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
|
-
/** How often to retry `agent start` while a freshly created pane is still reaching its shell prompt. */
|
|
56
|
-
export const PANE_READY_POLL_MS = 300;
|
|
57
59
|
/**
|
|
58
60
|
* Run one governed child in a pane and return its output.
|
|
59
61
|
*
|
|
@@ -88,7 +90,18 @@ export async function runHerdrPane(request) {
|
|
|
88
90
|
if (staged.error)
|
|
89
91
|
return { ...empty, spawnError: staged.error };
|
|
90
92
|
const promptDir = staged.promptDir;
|
|
91
|
-
|
|
93
|
+
let lifecycleExtension;
|
|
94
|
+
try {
|
|
95
|
+
lifecycleExtension = bundledHerdrPiLifecycleExtension();
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (promptDir)
|
|
99
|
+
await rm(promptDir, { recursive: true, force: true }).catch(() => undefined);
|
|
100
|
+
return { ...empty, spawnError: String(error) };
|
|
101
|
+
}
|
|
102
|
+
// Pi's `--no-extensions` disables discovery, not this explicit, package-pinned lifecycle reporter. It
|
|
103
|
+
// registers no tools; pi's existing `--tools` allowlist remains the governed child surface.
|
|
104
|
+
const effectiveArgs = [...staged.args, "-e", lifecycleExtension];
|
|
92
105
|
const create = ["tab", "create", "--label", request.name, "--cwd", request.cwd];
|
|
93
106
|
if (request.workspace)
|
|
94
107
|
create.push("--workspace", request.workspace);
|
|
@@ -239,11 +252,17 @@ export async function runHerdrPane(request) {
|
|
|
239
252
|
// early `return` from a failed start or prompt — leaves it false, so `cleanup` closes the tab.
|
|
240
253
|
let settledCleanly = false;
|
|
241
254
|
return runWithFinalizers(async () => {
|
|
242
|
-
const started = await
|
|
255
|
+
const started = await startHerdrAgent(exec, agentName, paneId, effectiveArgs, deadline);
|
|
243
256
|
if (started.error)
|
|
244
257
|
return { ...empty, spawnError: `herdr agent start failed: ${started.error}` };
|
|
245
|
-
// The
|
|
246
|
-
|
|
258
|
+
// The bundled reporter queues its initial idle state asynchronously. Establish its native-authority
|
|
259
|
+
// baseline before prompting, otherwise that initial report could advance the counter after prompt and
|
|
260
|
+
// be mistaken for settlement.
|
|
261
|
+
const baseline = await waitForLifecycleBaseline(exec, { ...request, name: agentName, nativePaneId: paneId }, Math.min(deadline, Date.now() + FRESH_LIFECYCLE_TIMEOUT_MS));
|
|
262
|
+
if (baseline.aborted)
|
|
263
|
+
return { ...empty, aborted: true };
|
|
264
|
+
if (baseline.spawnError || baseline.before === undefined)
|
|
265
|
+
return { ...empty, spawnError: baseline.spawnError ?? "Herdr lifecycle baseline is unavailable" };
|
|
247
266
|
observeHerdrSession(started.result?.agent, paneId, request.onSessionReference);
|
|
248
267
|
const prompted = parseReply(await exec(["agent", "prompt", agentName, request.prompt]));
|
|
249
268
|
if (prompted.error)
|
|
@@ -256,7 +275,7 @@ export async function runHerdrPane(request) {
|
|
|
256
275
|
/* display/observation only */
|
|
257
276
|
}
|
|
258
277
|
}
|
|
259
|
-
const settled = await waitForSettled(exec, { ...request, name: agentName, nativePaneId: paneId }, before, deadline, maxOutputBytes);
|
|
278
|
+
const settled = await waitForSettled(exec, { ...request, name: agentName, nativePaneId: paneId }, baseline.before, deadline, maxOutputBytes);
|
|
260
279
|
if (settled.aborted || settled.timedOut) {
|
|
261
280
|
// Still read: a timed-out child usually produced something, and a partial answer labelled partial is
|
|
262
281
|
// more useful than none. R-03's rule — a missing result must never look like an empty one.
|
|
@@ -313,28 +332,4 @@ export async function runHerdrPane(request) {
|
|
|
313
332
|
run: () => cleanup(settledCleanly),
|
|
314
333
|
}]);
|
|
315
334
|
}
|
|
316
|
-
/**
|
|
317
|
-
* Start the agent, retrying while the pane is still coming up.
|
|
318
|
-
*
|
|
319
|
-
* **Measured, and only visible once automated.** A pane created by `tab create` is not immediately at a
|
|
320
|
-
* shell prompt, and `herdr agent start` requires one — it fails with
|
|
321
|
-
* `agent_pane_busy: … is not an available shell`. Driving the two commands by hand hid this completely,
|
|
322
|
-
* because the think-time between them was longer than the shell took to start; the first scripted run hit
|
|
323
|
-
* it every time.
|
|
324
|
-
*
|
|
325
|
-
* Retried rather than preceded by a fixed sleep: a sleep long enough for a loaded machine is wasted on
|
|
326
|
-
* every spawn, and a fan-out pays it per child. Only the busy condition is retried — any other error is a
|
|
327
|
-
* real failure and returns immediately.
|
|
328
|
-
*/
|
|
329
|
-
async function startAgent(exec, name, paneId, args, deadline) {
|
|
330
|
-
for (;;) {
|
|
331
|
-
const reply = parseReply(await exec(["agent", "start", name, "--kind", "pi", "--pane", paneId, "--", ...args]));
|
|
332
|
-
if (!reply.error)
|
|
333
|
-
return reply;
|
|
334
|
-
const busy = /not an available shell|agent_pane_busy/.test(reply.error);
|
|
335
|
-
if (!busy || Date.now() >= deadline)
|
|
336
|
-
return reply;
|
|
337
|
-
await new Promise((r) => setTimeout(r, PANE_READY_POLL_MS));
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
335
|
//# sourceMappingURL=run-herdr.js.map
|