pi-agent-swarm 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -6
- package/dist/chunks/{menu-RH6GY6U4.ts → menu-NLK5I2DA.ts} +15 -2
- package/dist/chunks/menu-NLK5I2DA.ts.map +7 -0
- package/dist/index.ts +7755 -924
- package/dist/index.ts.map +4 -4
- package/package.json +4 -4
- package/src/auto-name.ts +137 -28
- package/src/budget.ts +268 -0
- package/src/context-recycling.ts +712 -0
- package/src/external-runtime.ts +374 -0
- package/src/fanout.ts +219 -0
- package/src/launch-envelope.ts +115 -0
- package/src/lead-mcp-bridge.ts +516 -0
- package/src/leader-handoff-bridge.ts +155 -0
- package/src/leader-recycling.ts +752 -0
- package/src/leader-runtime.ts +1098 -0
- package/src/leader-session-runtime.ts +71 -0
- package/src/ledger.ts +351 -0
- package/src/menu.ts +16 -2
- package/src/model-catalog.ts +213 -0
- package/src/org.ts +242 -0
- package/src/pi-agent-swarm.ts +55 -2
- package/src/profile-probe.ts +143 -0
- package/src/profiles.ts +621 -0
- package/src/protocol.ts +14 -3
- package/src/reload-handoff.ts +3 -0
- package/src/resource-lease.ts +250 -0
- package/src/reviewer.ts +191 -0
- package/src/settings.ts +335 -10
- package/src/swarm-controller.ts +2207 -89
- package/src/tools.ts +244 -7
- package/src/transport.ts +17 -0
- package/src/worktree.ts +86 -0
- package/dist/chunks/menu-RH6GY6U4.ts.map +0 -7
package/README.md
CHANGED
|
@@ -14,6 +14,9 @@ Every agent is a real terminal window tiled by your window manager — never a h
|
|
|
14
14
|
- Waits for the child to authenticate before reporting that the new session is ready.
|
|
15
15
|
- Connects explicitly joined same-user sessions through owner-only local sockets and ephemeral invites.
|
|
16
16
|
- Delivers notifications without a model turn and bounds each allowed request to one turn.
|
|
17
|
+
- Supports explicit follow-up requests so a leader can review a worker's reply and continue the same session.
|
|
18
|
+
- Recycles an opted-in unfinished worker at a stable boundary after a soft context threshold, preserving a concise project-local handoff for its successor.
|
|
19
|
+
- Optionally hands off a long-running leader in the same terminal, restoring its model, identity, group, and expected worker replies.
|
|
17
20
|
- Relays user input from a worker window into the leader's model context.
|
|
18
21
|
- Shows a colored footer badge with the session name, id, and role, degrading through full, compact, and minimal tiers as the terminal narrows.
|
|
19
22
|
- Authenticates and bounds local protocol traffic, peers, retries, rates, deadlines, and diagnostics.
|
|
@@ -49,10 +52,20 @@ Review extension source before installing it.
|
|
|
49
52
|
|
|
50
53
|
## 🚀 Quick start
|
|
51
54
|
|
|
52
|
-
Run `/swarm` to open the menu and spawn a worker Pi session, rename this session,
|
|
55
|
+
Run `/swarm` to open the menu and spawn a worker Pi session, rename this session, change its footer color, or toggle follow-up requests.
|
|
53
56
|
Start a local group with `/swarm start`, then ask your model to launch a child session with the `session_spawn` tool; the child joins the group automatically.
|
|
54
57
|
Before creating a window, Pi Agent Swarm asks for the configured launch confirmation.
|
|
55
58
|
|
|
59
|
+
For a review-and-revise workflow, select **Allow paid turns from trusted peers** when spawning, or set `allowRequests: true` in `session_spawn`.
|
|
60
|
+
The worker can then report with `session_bus reply`, and the leader can request revisions in that same session with `session_bus send mode=request`.
|
|
61
|
+
In an existing joined session, the local user can run `/swarm requests on` to enable this workflow and `/swarm requests off` to block it again.
|
|
62
|
+
|
|
63
|
+
For long or unpredictable work, set `contextRecycling` in `session_spawn` and launch with a task. After a turn finishes at or above the soft threshold, an unfinished worker enters `handoff_pending`, publishes a structured handoff with `session_bus`, and freezes. The leader starts one bounded successor with the same cwd, model, request permission, and lineage. The current turn is never aborted merely for crossing the threshold; a completed task is not replaced. A worker that cannot publish a handoff after two attempts stays frozen on a durable `failed` lineage, and the leader is notified.
|
|
64
|
+
|
|
65
|
+
See [Worker context recycling and handoff storage](../../docs/worker-context-recycling.md) for lifecycle and recovery details.
|
|
66
|
+
|
|
67
|
+
Leader recycling is separately opt-in through `leaderRecycling.enabled`. In `ask` mode an armed advisory lets the leader decline; `auto` mode instructs it to publish at a non-aborted settled boundary. Three consecutive automatic failures open a lineage-persisted circuit that survives reload and failed replacement attempts; only a fully restored successor resets it, while manual `/swarm handoff` remains available. Run `/swarm handoff` to request a handoff manually, including while the agent is streaming. The `leader_handoff` tool writes the ten-section artifact, then the same terminal creates a successor with the outgoing session as parent. See [Leader context recycling](../../docs/leader-context-recycling.md).
|
|
68
|
+
|
|
56
69
|
## 🧭 Launch flow
|
|
57
70
|
|
|
58
71
|
Edit `pi-agent-swarm.json` to change final launch confirmation or toggle lead-workspace pinning.
|
|
@@ -78,6 +91,8 @@ Creates a separate Pi process in an external terminal window.
|
|
|
78
91
|
| Parameter | Required | Description |
|
|
79
92
|
| --- | --- | --- |
|
|
80
93
|
| `direction` | No | `right`, `down`, `left`, or `up`; defaults to `right`. |
|
|
94
|
+
| `allowRequests` | No | Allows trusted peers to request follow-up turns after the initial task; defaults to `false`. |
|
|
95
|
+
| `contextRecycling` | No | Opts into automatic lineage handoff. Fields: `taskProfile` (`short`, `long`, or `auto`), optional `maxContextPercent` (1–100, default 50), and optional `maxReplacements` (0–10, default 3). |
|
|
81
96
|
| `task` | No | First task sent only after authenticated readiness. |
|
|
82
97
|
| `name` | No | Child session display name. |
|
|
83
98
|
| `color` | No | Child color: a palette name or a `#rrggbb` hex. |
|
|
@@ -87,6 +102,7 @@ Creates a separate Pi process in an external terminal window.
|
|
|
87
102
|
The tool supports only TUI and RPC modes because launch may require confirmation.
|
|
88
103
|
In JSON and print modes, it fails before creating a group, launcher, or window.
|
|
89
104
|
Successful details include `terminalId` and `terminalVersion`.
|
|
105
|
+
Context recycling requires a non-empty initial task and `allowRequests: true`. The replacement budget is authorization for automatic launches, not a per-turn deadline.
|
|
90
106
|
|
|
91
107
|
### `session_bus`
|
|
92
108
|
|
|
@@ -96,20 +112,30 @@ Lists or messages sessions in the active Pi Agent Swarm group.
|
|
|
96
112
|
| --- | --- | --- |
|
|
97
113
|
| `list` | none | Lists authenticated live peers and request policy. |
|
|
98
114
|
| `send` | `targetSessionId`, `message`, optional `mode` | Sends `notify` by default or a permitted one-turn `request`. |
|
|
99
|
-
| `reply` | `targetSessionId`, `message`, `replyTo` | Correlates a reply without starting another automatic turn. |
|
|
115
|
+
| `reply` | `targetSessionId`, `message`, `replyTo`, optional `taskStatus` | Correlates a reply without starting another automatic turn. `taskStatus` is `working` or `completed`. |
|
|
116
|
+
| `send` | `kind: "handoff"`, `handoff` | Publishes the current worker's structured handoff to the leader without injecting it into model context. |
|
|
100
117
|
| `shutdown` | `targetSessionId` | Asks a peer to shut down gracefully. |
|
|
101
118
|
|
|
102
119
|
An accepted acknowledgement means the recipient extension accepted or deduplicated the message, not that the remote agent completed the work.
|
|
103
|
-
Rejected and busy acknowledgements use stable codes such as `requests_disabled`, `rate_limited`, `target_busy`, `shutdown_unauthorized`, and `delivery_failed`.
|
|
120
|
+
Rejected and busy acknowledgements use stable codes such as `requests_disabled`, `context_handoff`, `rate_limited`, `target_busy`, `shutdown_unauthorized`, and `delivery_failed`.
|
|
121
|
+
A recycled worker that is frozen for handoff, replacement, or retirement answers requests with `context_handoff` so a leader does not mistake the freeze for a disabled request policy.
|
|
104
122
|
Rate-limited responses may include a bounded retry delay.
|
|
105
123
|
Peer-list text and details share a 40 KiB UTF-8 result budget below Pi's tool-output limit.
|
|
106
124
|
|
|
125
|
+
A handoff requires `originalObjective`, `currentState`, `completedWork`, `remainingWork`, `modifiedFiles`, `verification`, `decisions`, `blocker`, `nextAction`, and `artifacts`. Artifacts are absolute paths within the worker project, not inline logs. The leader receives only the bounded handoff path and its launch metadata; it reads the document when constructing the successor kickoff. `taskStatus` is available on `reply` and defaults to `completed`; ordinary `send` remains a working notification or request.
|
|
126
|
+
|
|
127
|
+
### `leader_handoff`
|
|
128
|
+
|
|
129
|
+
Publishes the current lead session's ten-section handoff and stages a same-terminal successor. It uses the same bounded fields as worker handoff. During `session_start`, after settings load and before the first request, the active-tool list excludes it by default or includes it when leader recycling is enabled. Calls are rejected when leader recycling is disabled, from non-lead sessions, without a persisted session file, or when another handoff is already staged. Call it alone in its assistant batch; mixed or duplicate batches reject the handoff, and no tools may run after a successful handoff is staged. Success returns `terminate: true`; the actual replacement begins only after the current agent run settles. Once the successor atomically commits the next lineage generation, recovery failures only degrade individual steps and warn: they never roll leadership or worker ownership back to the closed predecessor. See [Leader context recycling](../../docs/leader-context-recycling.md) for replacement and retry behavior.
|
|
130
|
+
|
|
107
131
|
## 💬 Commands
|
|
108
132
|
|
|
109
133
|
| Command | Purpose |
|
|
110
134
|
| --- | --- |
|
|
111
135
|
| `/swarm` | Open the menu to spawn a worker, rename this session, or set its color. |
|
|
112
136
|
| `/swarm start` | Start a local group with this session as lead. |
|
|
137
|
+
| `/swarm requests <on\|off>` | Allow or block follow-up agent requests in this joined session; blocked by default. |
|
|
138
|
+
| `/swarm handoff` | Ask the lead model to publish a leader handoff and continue in a same-terminal successor; requires `leaderRecycling.enabled`. |
|
|
113
139
|
| `/swarm <piagentswarm:v1:invite>` | Review the join confirmation and join one ephemeral local group. |
|
|
114
140
|
| `/lead` | Promote a session to leader or inspect the current leader. |
|
|
115
141
|
| `/color` | Set the current session's footer color. |
|
|
@@ -145,7 +171,15 @@ Edit user settings in `<getAgentDir()>/pi-agent-swarm.json`, normally `~/.pi/age
|
|
|
145
171
|
"confirmSessionLaunch": true,
|
|
146
172
|
"pinToLeadWorkspace": false,
|
|
147
173
|
"autoName": true,
|
|
148
|
-
"autoNameModel": "anthropic/claude-haiku-4-5"
|
|
174
|
+
"autoNameModel": "anthropic/claude-haiku-4-5",
|
|
175
|
+
"leaderRecycling": {
|
|
176
|
+
"enabled": false,
|
|
177
|
+
"mode": "ask",
|
|
178
|
+
"softContextPercent": 50,
|
|
179
|
+
"softContextTokens": 100000,
|
|
180
|
+
"highWaterPercent": 75,
|
|
181
|
+
"maxReplacements": 3
|
|
182
|
+
}
|
|
149
183
|
}
|
|
150
184
|
```
|
|
151
185
|
|
|
@@ -155,8 +189,9 @@ Edit user settings in `<getAgentDir()>/pi-agent-swarm.json`, normally `~/.pi/age
|
|
|
155
189
|
| `externalCommand` | any terminal command | `alacritty -e` | Command used to open each new window. |
|
|
156
190
|
| `confirmSessionLaunch` | `true`, `false` | `true` | Shows or skips the final launch preview for tool launches. |
|
|
157
191
|
| `pinToLeadWorkspace` | `true`, `false` | `false` | Moves each new window onto the lead session's workspace instead of the focused one. |
|
|
158
|
-
| `autoName` | `true`, `false` | `true` | Renames a human-started session from the bootstrap `MANAGER-<id>` name to a `MAN-<title>` summary of its first three completed turns. The rename uses a one-shot completion, retries on later turns if the completion fails, and steps aside forever as soon as you set a name yourself. Spawned child sessions keep their launch names. |
|
|
192
|
+
| `autoName` | `true`, `false` | `true` | Renames a human-started session from the bootstrap `MANAGER-<id>` name to a `MAN-<title>` summary of its first three completed turns (or after the first completed external-agent run reported over the extension-neutral `pi-agent-swarm:external-turn:v1` event on `pi.events` with at least 20 user characters). The rename uses a one-shot completion, ignores proxy/tool status noise, retries on later turns if the completion fails, and steps aside forever as soon as you set a name yourself. Spawned child sessions keep their launch names. |
|
|
159
193
|
| `autoNameModel` | `provider/id` | unset | Model used for the `MAN-<title>` completion. When unset, the session's current model is used, so no extra authentication is needed. An unresolvable value keeps the default name and reports a warning. |
|
|
194
|
+
| `leaderRecycling` | object | disabled | Leader handoff policy: `enabled` defaults to `false`; `mode` is `ask` or `auto`; soft thresholds default to 50% and 100,000 tokens; high water defaults to 75%; at most three replacements are authorized by default. Invalid fields fall back individually with warnings. |
|
|
160
195
|
|
|
161
196
|
Pi Agent Swarm does not read project settings or extension-specific environment-variable overrides.
|
|
162
197
|
A missing file uses the defaults without creating the file.
|
|
@@ -171,13 +206,14 @@ Version-3 messages normally expire after two minutes and cannot declare a lifeti
|
|
|
171
206
|
Accepted message ids remain deduplicated for ten minutes, longer than their valid delivery window.
|
|
172
207
|
A copied invite is still a reusable bearer secret, so discard it or start a new group when you need to rotate access.
|
|
173
208
|
A short-lived in-process handoff preserves a group across `/reload` for the same `sessionManager` only.
|
|
174
|
-
Membership does not carry into `/new`, `/resume`, or another logical session without a new invite.
|
|
209
|
+
Membership does not carry into ordinary `/new`, `/resume`, or another logical session without a new invite. The single exception is an explicitly staged leader handoff: its token-bound successor rejoins the group, broadcasts the new lead, and restores expected worker replies. Replies arriving during restoration are rejected rather than ghost-acknowledged, and failed deferred delivery retains its body for recovery with a warning.
|
|
175
210
|
|
|
176
211
|
The terminal child receives an internal launch-only environment envelope containing a parent-only kickoff capability.
|
|
177
212
|
The child consumes and deletes those values during `session_start` before Pi tools can inherit them.
|
|
178
213
|
These values are not user settings or supported environment overrides.
|
|
179
214
|
|
|
180
215
|
Incoming agent requests are blocked by default.
|
|
216
|
+
Enable them explicitly during spawn or with `/swarm requests on` in the target session.
|
|
181
217
|
Enabling them permits trusted invite holders to start paid model turns that may edit the same workspace concurrently.
|
|
182
218
|
|
|
183
219
|
## 🔒 Security and privacy
|
|
@@ -198,6 +234,8 @@ Enabling them permits trusted invite holders to start paid model turns that may
|
|
|
198
234
|
- Pi Agent Swarm does not retain invites as durable settings or group state, but a recipient can copy and reuse one until every holder discards it or moves to a new group.
|
|
199
235
|
- Invites are not placed in tool output, status, notifications, custom renderers, or model context.
|
|
200
236
|
- Launch values briefly exist in a private `0700` launcher that unlinks itself before starting Pi, so terminal command metadata cannot retain them.
|
|
237
|
+
- Worker and leader lineage/handoff files are project-local, owner-restricted, atomically published, and excluded by `.pi/agent-swarm/.gitignore`. Leader records use the separate `leader-lineages/` tree. They reject bearer secrets and artifact paths outside the project, but are not a boundary against same-user processes.
|
|
238
|
+
- Handoffs contain structured progress and artifact references rather than a copied session transcript. Large artifacts remain opt-in reads.
|
|
201
239
|
- Peer names, paths, messages, model ids, and errors are treated as untrusted terminal text and sanitized only at display boundaries.
|
|
202
240
|
- A same-user process or another privileged Pi extension is outside the security boundary and may inspect process arguments, private runtime files, memory, or environment.
|
|
203
241
|
- Pi Agent Swarm separates groups but does not sandbox them from the operating-system user.
|
|
@@ -11,12 +11,13 @@ var PALETTE_OPTIONS = [
|
|
|
11
11
|
{ label: "muted (default, low-saturation GitHub colors)", value: "muted" },
|
|
12
12
|
{ label: "bright (vivid GitHub colors)", value: "bright" }
|
|
13
13
|
];
|
|
14
|
+
var REQUEST_OPTIONS = ["Block (default)", "Allow paid turns from trusted peers"];
|
|
14
15
|
function createSwarmMenu(source) {
|
|
15
16
|
const getState = ({ signal } = {}) => source.snapshot(signal);
|
|
16
17
|
const menu = {
|
|
17
18
|
start: "main",
|
|
18
19
|
screens: {
|
|
19
|
-
main: () => ({
|
|
20
|
+
main: ({ state }) => ({
|
|
20
21
|
kind: "actions",
|
|
21
22
|
title: "Pi Agent Swarm",
|
|
22
23
|
lines: ["Spawn workers and manage this session's badge."],
|
|
@@ -40,6 +41,11 @@ function createSwarmMenu(source) {
|
|
|
40
41
|
id: "theme",
|
|
41
42
|
label: "Set theme",
|
|
42
43
|
action: "setTheme"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "requests",
|
|
47
|
+
label: `Follow-up requests: ${state.acceptsRequests ? "allowed" : "blocked"}`,
|
|
48
|
+
action: "setRequests"
|
|
43
49
|
}
|
|
44
50
|
],
|
|
45
51
|
hint: "close"
|
|
@@ -51,6 +57,8 @@ function createSwarmMenu(source) {
|
|
|
51
57
|
signal
|
|
52
58
|
});
|
|
53
59
|
if (!directionChoice || signal.aborted) return { kind: "stay" };
|
|
60
|
+
const requestChoice = await ctx.ui.select("Follow-up agent requests", [...REQUEST_OPTIONS], { signal });
|
|
61
|
+
if (!requestChoice || signal.aborted) return { kind: "stay" };
|
|
54
62
|
const task = await ctx.ui.input("Optional first task", "Submit an empty value for an idle child session", {
|
|
55
63
|
signal
|
|
56
64
|
});
|
|
@@ -59,6 +67,7 @@ function createSwarmMenu(source) {
|
|
|
59
67
|
ctx,
|
|
60
68
|
{
|
|
61
69
|
direction: directionChoice.toLowerCase(),
|
|
70
|
+
allowRequests: requestChoice === "Allow paid turns from trusted peers",
|
|
62
71
|
...task ? { task } : {}
|
|
63
72
|
},
|
|
64
73
|
signal
|
|
@@ -81,6 +90,10 @@ function createSwarmMenu(source) {
|
|
|
81
90
|
await source.setColor(ctx, choice, signal);
|
|
82
91
|
return { kind: "stay" };
|
|
83
92
|
},
|
|
93
|
+
setRequests: async ({ ctx, state }) => {
|
|
94
|
+
await source.setRequests(ctx, !state.acceptsRequests);
|
|
95
|
+
return { kind: "stay" };
|
|
96
|
+
},
|
|
84
97
|
setTheme: async ({ ctx, signal }) => {
|
|
85
98
|
const choice = await ctx.ui.select(
|
|
86
99
|
"Roster theme (badge palette)",
|
|
@@ -116,4 +129,4 @@ export {
|
|
|
116
129
|
createSwarmMenu,
|
|
117
130
|
showSwarmMenu
|
|
118
131
|
};
|
|
119
|
-
//# sourceMappingURL=menu-
|
|
132
|
+
//# sourceMappingURL=menu-NLK5I2DA.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/menu.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ExtensionCommandContext } from \"@earendil-works/pi-coding-agent\";\nimport type { MenuDefinition } from \"@narumitw/pi-tui-kit\";\nimport { SWARM_COLORS, type SwarmColorPaletteName } from \"./color.js\";\nimport type { SpawnSessionInput, SwarmSnapshot } from \"./swarm-controller.js\";\nimport { safeError } from \"./text.js\";\n\nexport interface SwarmMenuState extends SwarmSnapshot {}\n\nexport interface SwarmMenuSource {\n snapshot(signal?: AbortSignal): Promise<SwarmMenuState>;\n spawn(ctx: ExtensionCommandContext, input: SpawnSessionInput, signal?: AbortSignal): Promise<void>;\n rename(ctx: ExtensionCommandContext, name: string, signal?: AbortSignal): Promise<void>;\n setColor(ctx: ExtensionCommandContext, color: string, signal?: AbortSignal): Promise<void>;\n setPalette(ctx: ExtensionCommandContext, palette: SwarmColorPaletteName, signal?: AbortSignal): Promise<void>;\n setRequests(ctx: ExtensionCommandContext, value: boolean): Promise<void>;\n}\n\ntype Screen = \"main\";\ntype Action = \"spawn\" | \"rename\" | \"setColor\" | \"setTheme\" | \"setRequests\";\n\nconst DIRECTION_OPTIONS = [\"Right\", \"Down\", \"Left\", \"Up\"] as const;\nconst PALETTE_OPTIONS = [\n { label: \"muted (default, low-saturation GitHub colors)\", value: \"muted\" },\n { label: \"bright (vivid GitHub colors)\", value: \"bright\" },\n] as const satisfies readonly { label: string; value: SwarmColorPaletteName }[];\nconst REQUEST_OPTIONS = [\"Block (default)\", \"Allow paid turns from trusted peers\"] as const;\n\nexport function createSwarmMenu(source: SwarmMenuSource) {\n const getState = ({ signal }: { signal?: AbortSignal } = {}) => source.snapshot(signal);\n const menu: MenuDefinition<SwarmMenuState, Screen, Action> = {\n start: \"main\",\n screens: {\n main: ({ state }) => ({\n kind: \"actions\",\n title: \"Pi Agent Swarm\",\n lines: [\"Spawn workers and manage this session's badge.\"],\n items: [\n {\n id: \"spawn\",\n label: \"Spawn\",\n action: \"spawn\",\n },\n {\n id: \"rename\",\n label: \"Rename\",\n action: \"rename\",\n },\n {\n id: \"color\",\n label: \"Set color\",\n action: \"setColor\",\n },\n {\n id: \"theme\",\n label: \"Set theme\",\n action: \"setTheme\",\n },\n {\n id: \"requests\",\n label: `Follow-up requests: ${state.acceptsRequests ? \"allowed\" : \"blocked\"}`,\n action: \"setRequests\",\n },\n ],\n hint: \"close\",\n }),\n },\n actions: {\n spawn: async ({ ctx, signal }) => {\n const directionChoice = await ctx.ui.select(\"Terminal window direction\", [...DIRECTION_OPTIONS], {\n signal,\n });\n if (!directionChoice || signal.aborted) return { kind: \"stay\" };\n const requestChoice = await ctx.ui.select(\"Follow-up agent requests\", [...REQUEST_OPTIONS], { signal });\n if (!requestChoice || signal.aborted) return { kind: \"stay\" };\n const task = await ctx.ui.input(\"Optional first task\", \"Submit an empty value for an idle child session\", {\n signal,\n });\n if (task === undefined || signal.aborted) return { kind: \"stay\" };\n await source.spawn(\n ctx,\n {\n direction: directionChoice.toLowerCase() as SpawnSessionInput[\"direction\"],\n allowRequests: requestChoice === \"Allow paid turns from trusted peers\",\n ...(task ? { task } : {}),\n },\n signal,\n );\n return { kind: \"close\" };\n },\n rename: async ({ ctx, signal, state }) => {\n const name = await ctx.ui.input(\"Rename session\", state.self?.name ?? \"Enter a new session name\", {\n signal,\n });\n if (name === undefined || !name.trim() || signal.aborted) return { kind: \"stay\" };\n await source.rename(ctx, name, signal);\n return { kind: \"stay\" };\n },\n setColor: async ({ ctx, signal }) => {\n const choice = await ctx.ui.select(\"Session color\", [...SWARM_COLORS.map((color) => color.name)], {\n signal,\n });\n if (!choice || signal.aborted) return { kind: \"stay\" };\n await source.setColor(ctx, choice, signal);\n return { kind: \"stay\" };\n },\n setRequests: async ({ ctx, state }) => {\n await source.setRequests(ctx, !state.acceptsRequests);\n return { kind: \"stay\" };\n },\n setTheme: async ({ ctx, signal }) => {\n const choice = await ctx.ui.select(\n \"Roster theme (badge palette)\",\n PALETTE_OPTIONS.map((option) => option.label),\n { signal },\n );\n if (!choice || signal.aborted) return { kind: \"stay\" };\n const palette = PALETTE_OPTIONS.find((option) => option.label === choice)?.value;\n if (!palette) return { kind: \"stay\" };\n await source.setPalette(ctx, palette, signal);\n return { kind: \"stay\" };\n },\n },\n };\n return { menu, getState };\n}\n\nexport async function showSwarmMenu(\n ctx: ExtensionCommandContext,\n source: SwarmMenuSource,\n ownership: { signal: AbortSignal; isCurrent(): boolean },\n): Promise<void> {\n const { runMenu } = await import(\"@narumitw/pi-tui-kit\");\n if (ownership.signal.aborted || !ownership.isCurrent()) return;\n const controller = createSwarmMenu(source);\n await runMenu(ctx, controller.menu, {\n getState: controller.getState,\n signal: ownership.signal,\n isCurrent: ownership.isCurrent,\n onError: (_ctx, error) => {\n if (ownership.isCurrent() && !ownership.signal.aborted) {\n ctx.ui.notify(`Pi Agent Swarm failed: ${safeError(error)}`, \"error\");\n }\n },\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAoBA,IAAM,oBAAoB,CAAC,SAAS,QAAQ,QAAQ,I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