pi-herdr-managed-agents 0.1.0-beta.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/AUDIT.md +81 -0
- package/LICENSE +21 -0
- package/README.md +130 -0
- package/RELEASING.md +57 -0
- package/extensions/shared/tool-call-timeout.ts +104 -0
- package/extensions/subagents/index.ts +951 -0
- package/extensions/subagents/src/backend.ts +72 -0
- package/extensions/subagents/src/backends/claude.ts +703 -0
- package/extensions/subagents/src/backends/codex.ts +1060 -0
- package/extensions/subagents/src/backends/herdr.ts +1518 -0
- package/extensions/subagents/src/backends/pi.ts +576 -0
- package/extensions/subagents/src/backends/stub.ts +308 -0
- package/extensions/subagents/src/by-the-way.ts +21 -0
- package/extensions/subagents/src/domain.ts +269 -0
- package/extensions/subagents/src/format.ts +74 -0
- package/extensions/subagents/src/manager.ts +805 -0
- package/extensions/subagents/src/prompt.ts +151 -0
- package/extensions/subagents/src/result-delivery.ts +33 -0
- package/extensions/subagents/src/runtime.ts +64 -0
- package/extensions/subagents/src/ui/takeover.ts +583 -0
- package/extensions/subagents/src/ui/transcript.ts +182 -0
- package/package.json +71 -0
- package/skills/herdr-managed-agents/SKILL.md +54 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The unified backend interface: one `SubagentBackend` per agent runtime
|
|
3
|
+
* (pi, Claude Code, Codex), all producing the same `SubagentSession` shape.
|
|
4
|
+
*
|
|
5
|
+
* Implementations:
|
|
6
|
+
* - inside Herdr: real interactive Pi, Claude Code, and Codex CLIs in panes;
|
|
7
|
+
* - outside Herdr: in-process Pi SDK, Claude Agent SDK, and Codex app-server.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { Effect, Scope, Stream } from "effect";
|
|
11
|
+
import { Context } from "effect";
|
|
12
|
+
import type {
|
|
13
|
+
BackendName,
|
|
14
|
+
SendError,
|
|
15
|
+
SpawnError,
|
|
16
|
+
SpawnTask,
|
|
17
|
+
SubagentEvent,
|
|
18
|
+
SubagentMeta,
|
|
19
|
+
} from "./domain.ts";
|
|
20
|
+
|
|
21
|
+
export interface BackendCapabilities {
|
|
22
|
+
/** Can send() steer a live run (vs. only starting a fresh run when idle). */
|
|
23
|
+
readonly steering: boolean;
|
|
24
|
+
readonly modelSelection: boolean;
|
|
25
|
+
readonly reasoningEffort: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A live subagent session. The manager is the single consumer of `events`;
|
|
30
|
+
* it folds them into the `SubagentSnapshot` everything else reads.
|
|
31
|
+
*/
|
|
32
|
+
export interface SubagentSession {
|
|
33
|
+
/** Current metadata snapshot. Updates also arrive as MetaChanged events. */
|
|
34
|
+
readonly meta: Effect.Effect<SubagentMeta>;
|
|
35
|
+
/**
|
|
36
|
+
* All activity, normalized. Ends when the session's scope closes. Every
|
|
37
|
+
* run started within the session terminates with a RunSettled event.
|
|
38
|
+
*/
|
|
39
|
+
readonly events: Stream.Stream<SubagentEvent>;
|
|
40
|
+
/**
|
|
41
|
+
* Steer the active run, or start a fresh run when idle (v1 `manager.send`
|
|
42
|
+
* semantics — the "is a run active" decision is backend-native state).
|
|
43
|
+
*/
|
|
44
|
+
send(text: string): Effect.Effect<void, SendError>;
|
|
45
|
+
/**
|
|
46
|
+
* Interrupt the active run. Resolves once the backend acknowledges; the
|
|
47
|
+
* corresponding RunSettled(Interrupted) arrives on `events`. Callers bound
|
|
48
|
+
* this with a timeout and fall back to closing the session scope.
|
|
49
|
+
*/
|
|
50
|
+
readonly interrupt: Effect.Effect<void>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface SubagentBackend {
|
|
54
|
+
readonly name: BackendName;
|
|
55
|
+
readonly capabilities: BackendCapabilities;
|
|
56
|
+
/** Probe availability (binary on PATH, SDK importable, credentials). */
|
|
57
|
+
readonly available: Effect.Effect<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Spawn a session. Scoped: closing the scope interrupts/kills the
|
|
60
|
+
* underlying session or process and ends `events`. Fire-and-forget
|
|
61
|
+
* semantics (background fibers, result delivery) live in the manager.
|
|
62
|
+
*/
|
|
63
|
+
spawn(
|
|
64
|
+
task: SpawnTask,
|
|
65
|
+
): Effect.Effect<SubagentSession, SpawnError, Scope.Scope>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Registry of all wired backends, keyed by name. */
|
|
69
|
+
export class BackendRegistry extends Context.Service<
|
|
70
|
+
BackendRegistry,
|
|
71
|
+
ReadonlyMap<BackendName, SubagentBackend>
|
|
72
|
+
>()("subagents/BackendRegistry") {}
|