@cotal-ai/herdr 0.0.0 → 0.18.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/LICENSE +202 -0
- package/README.md +95 -8
- package/dist/driver.d.ts +140 -0
- package/dist/driver.d.ts.map +1 -0
- package/dist/driver.js +543 -0
- package/dist/driver.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime.d.ts +30 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +230 -0
- package/dist/runtime.js.map +1 -0
- package/package.json +29 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,12 +1,99 @@
|
|
|
1
1
|
# @cotal-ai/herdr
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
The [Herdr](https://herdr.dev/) integration: a thin driver over the herdr CLI (start a pane running
|
|
4
|
+
a command, send keys, close it) plus a self-registering `herdr` `Runtime` provider. Importing it
|
|
5
|
+
registers the provider with the core `Registry`, so the manager can spawn agents into Herdr panes
|
|
6
|
+
without depending on this package.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[Cotal repository](https://github.com/Cotal-AI/Cotal/tree/main/extensions/herdr) at the same
|
|
10
|
-
version as the rest of the `@cotal-ai/*` packages.
|
|
8
|
+
**Tier:** `extensions/`. Peer-depends [`@cotal-ai/core`](../../packages/core); self-registers on
|
|
9
|
+
import.
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
**Requires herdr >= 0.8.0** (`brew install herdr`, or see [herdr.dev](https://herdr.dev/)). This is
|
|
12
|
+
a hard floor, not a preference: 0.7.x exposed `agent start --cwd -- <argv>` and `agent send`, both of
|
|
13
|
+
which 0.8.0 removed, and there is no shared subset. `available()` reads the version rather than
|
|
14
|
+
merely probing that the binary runs, so an older herdr reports the runtime as unavailable instead of
|
|
15
|
+
advertising it as ready and then failing every spawn.
|
|
16
|
+
|
|
17
|
+
## What it does
|
|
18
|
+
|
|
19
|
+
**`Runtime` (`herdr`)** — each agent gets its own pane in a DEDICATED named Herdr session
|
|
20
|
+
(`cotal-<space>`, its own server and socket — never your default Herdr session, so no Cotal
|
|
21
|
+
operation can touch unrelated panes). The session server is started headless on first spawn and
|
|
22
|
+
owns the panes, so agents keep running when the manager's terminal goes away; watch them with
|
|
23
|
+
`herdr session attach cotal-<space>`.
|
|
24
|
+
|
|
25
|
+
By default every agent gets its own workspace and name-labeled tab; set `COTAL_HERDR_LAYOUT=split`
|
|
26
|
+
on the manager to fold agents into one shared tab instead (an unknown value fails loud). Graceful
|
|
27
|
+
stop types `/exit` then closes the pane; hard stop closes immediately.
|
|
28
|
+
|
|
29
|
+
## How a spawn works
|
|
30
|
+
|
|
31
|
+
herdr 0.8.0 has no "create a pane running this command" primitive — `agent start` attaches a
|
|
32
|
+
*recognized agent kind* to an existing pane, `pane split` needs a pane to split from, and a fresh
|
|
33
|
+
headless server has no workspace, tab, or pane at all. So a spawn is:
|
|
34
|
+
|
|
35
|
+
1. `workspace create --cwd <cwd> --label <name> --no-focus` — one call yielding a workspace, a tab,
|
|
36
|
+
and a root pane, with the working directory honoured. This is also what makes the
|
|
37
|
+
one-tab-per-agent layout free rather than a follow-up move.
|
|
38
|
+
2. `tab rename <tab_id> <name>` — `--label` names the *workspace*; the tab strip is what an operator
|
|
39
|
+
actually reads, and it would otherwise show a bare number.
|
|
40
|
+
3. `pane run <pane_id> "exec <command>"` — the `exec` is load-bearing. A plain `pane run` leaves the
|
|
41
|
+
pane's shell alive after the command exits, so the pane would outlive the agent and an exit could
|
|
42
|
+
never be proven. `exec` replaces the shell, so herdr closes the pane exactly when the agent exits.
|
|
43
|
+
4. Poll `pane process-info` until the process actually appears, bounded. `pane run` types into a
|
|
44
|
+
shell, so a successful call proves the keystrokes were delivered, not that anything started; if
|
|
45
|
+
the process never appears the half-built workspace is torn down and the spawn throws.
|
|
46
|
+
|
|
47
|
+
Lifecycle is keyed off Herdr's globally-unique `terminal_id`; the workspace-scoped public `pane_id`
|
|
48
|
+
(which changes when a pane is moved) is re-resolved before every pane-scoped call, off the
|
|
49
|
+
session-wide pane inventory. Exit waits poll that inventory and fail closed on provider errors — a
|
|
50
|
+
failed inventory throws rather than reporting a false exit.
|
|
51
|
+
|
|
52
|
+
## Secrets
|
|
53
|
+
|
|
54
|
+
Connector env (identity, credentials, control token) rides an owner-only (`0600`) launcher script in
|
|
55
|
+
a private `0700` directory; herdr only ever sees `node <script>`, and the script removes its own
|
|
56
|
+
directory as soon as it has loaded.
|
|
57
|
+
|
|
58
|
+
**Do not "simplify" this to herdr's native `--env KEY=VALUE`.** It is available on both
|
|
59
|
+
`workspace create` and `tab create`, and it puts the value straight into the pane's scrollback,
|
|
60
|
+
where `herdr pane read` returns it verbatim. The launcher exists precisely to avoid that.
|
|
61
|
+
|
|
62
|
+
## Not in herdr's Agents sidebar
|
|
63
|
+
|
|
64
|
+
Spawned agents do **not** appear in Herdr's Agents sidebar, and this is a property of 0.8.0 rather
|
|
65
|
+
than something the driver could fix: herdr reserves its agent registry for a fixed set of recognized
|
|
66
|
+
kinds (`pi`, `claude`, `codex`, `gemini`, `cursor`, …) attached to an existing pane via
|
|
67
|
+
`agent start --kind`. A Cotal agent runs an arbitrary launcher, so it is never one of those kinds,
|
|
68
|
+
and `agent get`/`agent list` cannot see it. Agents are identified instead by their tab label and by
|
|
69
|
+
a `cotal` metadata token on the pane (visible in `pane get` and the pane UI).
|
|
70
|
+
|
|
71
|
+
## Usage
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
cotal ext add @cotal-ai/herdr
|
|
75
|
+
cotal supervise --runtime herdr
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Library composition roots can instead import it explicitly:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import "@cotal-ai/herdr"; // self-registers; no other setup needed
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Testing
|
|
85
|
+
|
|
86
|
+
`pnpm smoke:herdr` runs the suite against a real herdr server in isolated named sessions. It skips
|
|
87
|
+
with a loud notice when herdr is absent or too old — and CI installs herdr so that skip never
|
|
88
|
+
silently stands in for a pass.
|
|
89
|
+
|
|
90
|
+
## Differences from `@cotal-ai/tmux`
|
|
91
|
+
|
|
92
|
+
Same shape (native-watch, no PTY streaming; a shared per-space session), but panes live in a Herdr
|
|
93
|
+
session whose server also tracks pane status natively, and the runtime is pane-based rather than
|
|
94
|
+
window-based. A failed server start is detected early via POSIX `ps` where present; without it
|
|
95
|
+
(Windows, a ps-less container) death is never assumed — the same failure surfaces at the bounded
|
|
96
|
+
startup window, with the server's own stderr either way.
|
|
97
|
+
|
|
98
|
+
See [docs/architecture.md](../../docs/architecture.md) (*Manager*) and the
|
|
99
|
+
[root AGENTS.md](../../AGENTS.md) for the tier rules.
|
package/dist/driver.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/** A structured error from the herdr CLI/socket API (e.g. `pane_not_found`). */
|
|
2
|
+
export declare class HerdrCliError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
constructor(code: string, message: string);
|
|
5
|
+
}
|
|
6
|
+
/** Oldest herdr whose CLI contract this driver speaks: `workspace create` + `pane run`, and
|
|
7
|
+
* `pane send-text`. 0.7.x exposed `agent start --cwd -- argv` and `agent send` instead, which
|
|
8
|
+
* 0.8.0 removed outright — there is no shared subset, so an older herdr is refused rather than
|
|
9
|
+
* silently half-supported. */
|
|
10
|
+
export declare const MIN_HERDR: readonly [0, 8, 0];
|
|
11
|
+
/** `herdr --version` prints e.g. `herdr 0.8.0`. Returns the numeric triple, or undefined when the
|
|
12
|
+
* output does not carry a parseable version (a fork, a wrapper, a future format change). */
|
|
13
|
+
export declare function parseVersion(out: string): [number, number, number] | undefined;
|
|
14
|
+
/** True if a herdr this driver can actually drive is on PATH. Deliberately checks the VERSION and
|
|
15
|
+
* not merely that the binary executes: a bare `--version` probe reports 0.7.x as available, so the
|
|
16
|
+
* CLI advertises the runtime as ready and every spawn then dies on `unknown option: --cwd`. An
|
|
17
|
+
* unparseable version reads as unavailable — uncertainty must not advertise readiness. The session
|
|
18
|
+
* server is provisioned separately ({@link ensureServer}), like tmux's auto-created sessions. */
|
|
19
|
+
export declare function available(): boolean;
|
|
20
|
+
/** The installed herdr version as text, for error messages. Empty when it cannot be determined. */
|
|
21
|
+
export declare function versionText(): string;
|
|
22
|
+
/** One live pane/agent row as herdr reports it. `terminalId` is the globally-unique stable
|
|
23
|
+
* identity; `paneId` is the CURRENT public id (workspace-scoped, changes when a pane moves
|
|
24
|
+
* across workspaces) and must be re-resolved before every pane-scoped operation. */
|
|
25
|
+
export interface HerdrAgent {
|
|
26
|
+
terminalId: string;
|
|
27
|
+
paneId: string;
|
|
28
|
+
workspaceId: string;
|
|
29
|
+
}
|
|
30
|
+
/** Run one herdr CLI command scoped to `session` and return the parsed JSON `result`.
|
|
31
|
+
* Every invocation carries `--session` explicitly so no call can ever hit the ambient/default
|
|
32
|
+
* Herdr session. A JSON `{error}` becomes a {@link HerdrCliError}; missing/non-JSON output
|
|
33
|
+
* throws — except for `void: true` commands (send-keys, report-metadata), which herdr
|
|
34
|
+
* acknowledges with a bare exit 0 and no output. */
|
|
35
|
+
export declare function run(session: string, args: string[], opts?: {
|
|
36
|
+
void?: boolean;
|
|
37
|
+
}): Record<string, unknown>;
|
|
38
|
+
/** True if the session's server answers on its socket. `herdr status server` exits 0 either
|
|
39
|
+
* way, so the answer is in the text. */
|
|
40
|
+
export declare function serverRunning(session: string): boolean;
|
|
41
|
+
/** Ensure the named session's headless server is up, starting one when absent (the herdr
|
|
42
|
+
* analog of tmux's auto-created detached session). Fails loud if it doesn't come up — a dead
|
|
43
|
+
* or wedged start throws WITH the server's own stderr, and the swallowed `error` event means
|
|
44
|
+
* a spawn failure can never surface as an uncaught exception in the caller later. */
|
|
45
|
+
export declare function ensureServer(session: string): void;
|
|
46
|
+
/** POSIX single-quote escaping. `pane run` hands its argument to the pane's interactive SHELL, so
|
|
47
|
+
* unlike every other call in this driver the command is not argv — each word must be quoted or a
|
|
48
|
+
* path containing a space, quote, or `$` becomes multiple words or a substitution. */
|
|
49
|
+
export declare function shellQuote(word: string): string;
|
|
50
|
+
/** The names one foreground-process record can be matched by, most authoritative first.
|
|
51
|
+
*
|
|
52
|
+
* herdr's `pane process-info` shape is PLATFORM-DEPENDENT, which is not documented anywhere and
|
|
53
|
+
* is the whole reason this helper exists:
|
|
54
|
+
*
|
|
55
|
+
* macOS {"argv0":"node","argv":["/usr/local/bin/node","x.mjs"],"name":"node",…}
|
|
56
|
+
* Linux { "argv":["sleep","30"], "name":"sleep",…}
|
|
57
|
+
*
|
|
58
|
+
* Linux omits `argv0` entirely. Reading it alone matched on macOS and NEVER on Linux, so no
|
|
59
|
+
* agent could start there at all — the readiness poll below simply timed out on every spawn.
|
|
60
|
+
*
|
|
61
|
+
* `name` is deliberately NOT consulted: it is the kernel's comm string, truncated to 15 bytes on
|
|
62
|
+
* Linux and version-suffixed on macOS ("python3.13"), so matching it would trade a false negative
|
|
63
|
+
* for a false positive — and a readiness probe that lies green is worse than one that lies red. */
|
|
64
|
+
export declare function processNames(proc: unknown): string[];
|
|
65
|
+
/** True when `proc` was invoked as `command`, compared by BASENAME: herdr reports either a bare
|
|
66
|
+
* name (`node`) or an absolute path depending on platform and field, while the caller passes an
|
|
67
|
+
* absolute interpreter path (`process.execPath`). A literal comparison matches neither reliably. */
|
|
68
|
+
export declare function processIsCommand(proc: unknown, command: string): boolean;
|
|
69
|
+
/** The pane's foreground processes as herdr reports them, or `[]` when it cannot say. */
|
|
70
|
+
export declare function foregroundProcesses(session: string, paneId: string): Record<string, unknown>[];
|
|
71
|
+
/** The pid of the pane's foreground process running `command`, or undefined when it is not there. */
|
|
72
|
+
export declare function foregroundPid(session: string, paneId: string, command: string): number | undefined;
|
|
73
|
+
/** Start `argv` in its own workspace of `session` and return its stable refs.
|
|
74
|
+
*
|
|
75
|
+
* herdr 0.8.0 has no "create a pane running this command" primitive: `agent start` attaches a
|
|
76
|
+
* RECOGNIZED agent kind to an existing pane, `pane split` needs a pane to split from, and a fresh
|
|
77
|
+
* headless server has no workspace, tab or pane at all. So the bootstrap is `workspace create`
|
|
78
|
+
* (which yields a workspace + tab + root pane in one call, honouring --cwd) followed by `pane run`
|
|
79
|
+
* into that root pane. One workspace per agent also gives the name-labeled-tab layout for free.
|
|
80
|
+
*
|
|
81
|
+
* The command is `exec`'d deliberately: a plain `pane run` leaves the pane's shell alive after the
|
|
82
|
+
* command exits, so the pane would outlive the agent and {@link terminalState} could never prove an
|
|
83
|
+
* exit. `exec` replaces the shell, so herdr closes the pane exactly when the agent exits — which is
|
|
84
|
+
* the property the whole lifecycle design rests on.
|
|
85
|
+
*
|
|
86
|
+
* Fails loud and leaves nothing behind: if the process does not appear within the readiness window
|
|
87
|
+
* the half-built workspace is torn down before throwing. */
|
|
88
|
+
export declare function agentStart(session: string, name: string, cwd: string, argv: string[]): HerdrAgent;
|
|
89
|
+
/** The CURRENT record for a terminal id, or undefined when it is gone.
|
|
90
|
+
*
|
|
91
|
+
* Resolved off the pane inventory rather than `agent get`: in herdr 0.8.0 an "agent" is a
|
|
92
|
+
* RECOGNIZED KIND (pi, claude, codex, …) attached to a pane, so a pane we started with
|
|
93
|
+
* {@link agentStart} never appears in the agent registry and `agent get` reports it as gone. The
|
|
94
|
+
* pane inventory is the only view that sees it, and it is session-wide (`--workspace` merely
|
|
95
|
+
* narrows), so a pane that moved workspaces is still found.
|
|
96
|
+
*
|
|
97
|
+
* A failed inventory THROWS rather than reporting undefined — uncertainty must never read as gone,
|
|
98
|
+
* or a live agent gets torn down as a corpse. */
|
|
99
|
+
export declare function agentInfo(session: string, terminalId: string): HerdrAgent | undefined;
|
|
100
|
+
export type TerminalState = "running" | "exited";
|
|
101
|
+
/** Authoritative liveness for a terminal id: ONLY a successful full pane inventory that no
|
|
102
|
+
* longer contains it proves exit (herdr closes a pane when its command exits). Every failed
|
|
103
|
+
* inventory — including an absent/refused session socket, which may be a transient server
|
|
104
|
+
* restart or a permission problem — throws rather than report a false exit. */
|
|
105
|
+
export declare function terminalState(session: string, terminalId: string): TerminalState;
|
|
106
|
+
/** Bounded polling over the authoritative pane inventory. */
|
|
107
|
+
export declare function waitForTerminalExit(session: string, terminalId: string, opts?: {
|
|
108
|
+
timeoutMs?: number;
|
|
109
|
+
pollMs?: number;
|
|
110
|
+
}): Promise<void>;
|
|
111
|
+
/** Type literal text into a pane. Pane-scoped: the caller must pass a freshly re-resolved pane id
|
|
112
|
+
* ({@link agentInfo}), never a cached one. (herdr 0.8.0 removed `agent send`; `pane send-text` is
|
|
113
|
+
* the replacement, and it is addressed by pane rather than terminal.) */
|
|
114
|
+
export declare function sendText(session: string, paneId: string, text: string): void;
|
|
115
|
+
/** Send a named key (e.g. `enter`, `ctrl+c`) to a pane. Pane-scoped: the caller must pass a
|
|
116
|
+
* freshly re-resolved pane id ({@link agentInfo}), never a cached one. */
|
|
117
|
+
export declare function sendKeys(session: string, paneId: string, key: string): void;
|
|
118
|
+
/** Close a pane. Idempotent for an already-gone pane only; every other error propagates. */
|
|
119
|
+
export declare function closePane(session: string, paneId: string): void;
|
|
120
|
+
/** Every tab in the session, newest last. Used to find a tab to share under the `split` layout. */
|
|
121
|
+
export declare function tabIds(session: string): string[];
|
|
122
|
+
/** Move a pane into an EXISTING tab, splitting it, and return the pane's updated record — the
|
|
123
|
+
* public pane id changes. `terminalId` pins the response: a malformed or wrong-terminal record is
|
|
124
|
+
* rejected so a bad reply can never make later metadata/cleanup target a different terminal.
|
|
125
|
+
* Used only by the opt-in `split` layout; the default one-workspace-per-agent layout needs no move
|
|
126
|
+
* at all, because {@link agentStart} already lands each agent in its own name-labeled tab. */
|
|
127
|
+
export declare function paneMoveIntoTab(session: string, paneId: string, tabId: string, terminalId: string): HerdrAgent;
|
|
128
|
+
/** Attach Cotal identity to a pane as display metadata tokens (visible in herdr's pane/agent
|
|
129
|
+
* UI). Values ride argv — never a shell — so no quoting/injection surface. */
|
|
130
|
+
export declare function reportMetadata(session: string, paneId: string, source: string, tokens: Record<string, string>): void;
|
|
131
|
+
/** Stop the named session's server (used by teardown/smoke; production sessions stay up —
|
|
132
|
+
* that persistence is the point of the runtime).
|
|
133
|
+
*
|
|
134
|
+
* `session stop` takes a POSITIONAL name, not `--session`, so it cannot go through {@link run}.
|
|
135
|
+
* Only "it was not running" is absorbed, matched on herdr's exact `session_stop_failed` code —
|
|
136
|
+
* which it reports on stdout with exit 0, so the output has to be read rather than ignored. Every
|
|
137
|
+
* other structured error (permission, protocol) propagates: a teardown that cannot say it failed
|
|
138
|
+
* is worse than no teardown, because it reports success either way. */
|
|
139
|
+
export declare function stopSession(session: string): void;
|
|
140
|
+
//# sourceMappingURL=driver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAcA,gFAAgF;AAChF,qBAAa,aAAc,SAAQ,KAAK;IAEpC,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AAED;;;+BAG+B;AAC/B,eAAO,MAAM,SAAS,oBAAqB,CAAC;AAE5C;6FAC6F;AAC7F,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,E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