pi-herdsman 0.34.1 → 0.35.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/SKILL.md +12 -10
- package/dist/agent-definitions/manager.md +1 -1
- package/dist/index.js +202 -73
- package/dist/index.js.map +3 -3
- package/docs/concepts/coordination.md +15 -10
- package/docs/coordination-api.md +4 -3
- package/docs/development/smoke-testing.md +2 -2
- package/docs/guides/customizing-agents.md +1 -1
- package/docs/guides/handoffs.md +10 -9
- package/docs/guides/project-orchestration.md +13 -12
- package/docs/guides/recovery.md +1 -1
- package/docs/reference/agent-definition-schema.md +2 -2
- package/docs/reference/agent.md +1 -1
- package/docs/reference/commands.md +2 -2
- package/docs/reference/peer.md +54 -7
- package/docs/reference/staff.md +15 -14
- package/docs/reference/status-widget.md +8 -4
- package/package.json +1 -1
package/SKILL.md
CHANGED
|
@@ -412,8 +412,8 @@ through `files`.
|
|
|
412
412
|
|
|
413
413
|
Chief uses `list_staff`, `inspect_staff`, `read_staff_transcript`, and
|
|
414
414
|
`message_staff`. Manager has those same direct-report tools, peer tools, and
|
|
415
|
-
`
|
|
416
|
-
For administrative removal of
|
|
415
|
+
`delegate_work`, `resume_work`, `stop_lead`, `remove_worktree`, and `integrate_branch`.
|
|
416
|
+
For administrative removal of assignment-owned evidence, use the Manager's
|
|
417
417
|
**Retained evidence** menu and its **Remove requirement…** action. Inherited
|
|
418
418
|
requirements are protected; snapshots and accepted Agent evidence remain
|
|
419
419
|
unchanged.
|
|
@@ -447,8 +447,9 @@ not ownership or project-resolution authority.
|
|
|
447
447
|
|
|
448
448
|
Pi Herdsman uses one durable vocabulary:
|
|
449
449
|
|
|
450
|
-
- a **project** is the
|
|
451
|
-
worktree group
|
|
450
|
+
- a **project** is the coordination scope of one verified local Git repository's
|
|
451
|
+
Herdr worktree group. A worktree is a physical checkout, not an independent
|
|
452
|
+
project or ownership record;
|
|
452
453
|
- a **Manager** explicitly assumes dedicated project coordination from that
|
|
453
454
|
group's primary workspace and does not own supervised Leads' Agents. It may
|
|
454
455
|
separately delegate directly to definitions in its effective `agents`
|
|
@@ -456,10 +457,11 @@ Pi Herdsman uses one durable vocabulary:
|
|
|
456
457
|
ordinary Leads in the verified worktree group are direct reports for
|
|
457
458
|
observation and communication. Leads own technical decisions and orchestrate
|
|
458
459
|
execution through their Agent trees;
|
|
459
|
-
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
460
|
+
- a work assignment is a durable branch-scoped objective assigned to an exact
|
|
461
|
+
managed Lead, keyed by repository identity and semantic branch, not by Manager
|
|
462
|
+
session. Its branch is the work handle. A
|
|
463
|
+
Manager uses `delegate_work` with a task and optional branch to start new
|
|
464
|
+
project work, and `resume_work` with its branch to resume an existing
|
|
463
465
|
assignment. A successful matching Herdr removal event or verified Git
|
|
464
466
|
worktree inventory showing the checkout absent retires that assignment and
|
|
465
467
|
pending project messages. Unavailable or ambiguous inventory preserves the
|
|
@@ -467,7 +469,7 @@ Pi Herdsman uses one durable vocabulary:
|
|
|
467
469
|
its remaining Git branch;
|
|
468
470
|
- the Manager owns project-level integration decisions. When separately
|
|
469
471
|
authorized by the Manager local-merge policy, it can accept the exact
|
|
470
|
-
validated source revision and use `
|
|
472
|
+
validated source revision and use `integrate_branch` to fast-forward that
|
|
471
473
|
assigned branch into the verified primary branch. A `needs_update` result
|
|
472
474
|
means ask the responsible Lead to incorporate the reported target revision,
|
|
473
475
|
resolve actual conflicts, validate, and report the new exact HEAD; it does
|
|
@@ -478,7 +480,7 @@ Pi Herdsman uses one durable vocabulary:
|
|
|
478
480
|
including reconciling an already-absent checkout only after Git proves that
|
|
479
481
|
SHA is on the verified primary branch;
|
|
480
482
|
- each completed direct turn by an assigned Lead is automatically returned as a
|
|
481
|
-
|
|
483
|
+
assignment update to the current or a replacement Manager; if managed Agent
|
|
482
484
|
work is active, the herd run owns the handoff until it settles, and the
|
|
483
485
|
settled response summarizes outcome, validation, and important unresolved
|
|
484
486
|
points. These handoffs are nonterminal; Managers treat routine results as
|
|
@@ -17,7 +17,7 @@ Leave technical investigation, implementation, review, validation, and
|
|
|
17
17
|
integration to that Lead and its Agents rather than doing or delegating
|
|
18
18
|
the work yourself.
|
|
19
19
|
|
|
20
|
-
When local Manager merge permission is enabled, you may use `
|
|
20
|
+
When local Manager merge permission is enabled, you may use `integrate_branch`
|
|
21
21
|
only for an exact assigned branch after accepting its validated full source
|
|
22
22
|
SHA. It fast-forwards the verified primary branch only. If the target has
|
|
23
23
|
advanced, ask the responsible Lead to incorporate the target, preserve prior
|
package/dist/index.js
CHANGED
|
@@ -5576,14 +5576,21 @@ function renderSupervisionRows(reports, width, options2 = {}, selectedLead) {
|
|
|
5576
5576
|
const branchWidth = width - visibleWidth(prefix) - visibleWidth(suffix) - telemetryWidth;
|
|
5577
5577
|
const displayedBranch = safeLine(item.work.branch, branchWidth);
|
|
5578
5578
|
const branchText = themed(options2.theme, "muted", displayedBranch);
|
|
5579
|
+
const truncatedBranch = displayedBranch !== item.work.branch;
|
|
5580
|
+
const clickRegion = truncatedBranch && visibleWidth(displayedBranch) > visibleWidth("\u2026") ? {
|
|
5581
|
+
from: visibleWidth(prefix),
|
|
5582
|
+
to: visibleWidth(prefix) + visibleWidth(displayedBranch)
|
|
5583
|
+
} : void 0;
|
|
5584
|
+
const canFocusLead = status === "fresh" && item.work.status === "active" && lead && lead.compatibility !== "incompatible";
|
|
5579
5585
|
return {
|
|
5580
5586
|
text: safeLine(
|
|
5581
5587
|
`${themed(options2.theme, "muted", `${branch} ${navigation}`)}${markerText} ${branchText}${themed(options2.theme, "muted", suffix)}${telemetry.map((value2) => themed(options2.theme, "muted", ` ${value2}`)).join("")}`,
|
|
5582
5588
|
width
|
|
5583
5589
|
),
|
|
5584
|
-
...
|
|
5590
|
+
...canFocusLead && (!truncatedBranch || clickRegion) ? {
|
|
5585
5591
|
label: item.work.branch,
|
|
5586
|
-
intent: { kind: "session", sessionId: lead.lead }
|
|
5592
|
+
intent: { kind: "session", sessionId: lead.lead },
|
|
5593
|
+
...clickRegion ? { clickRegion } : {}
|
|
5587
5594
|
} : {}
|
|
5588
5595
|
};
|
|
5589
5596
|
}),
|
|
@@ -5831,13 +5838,17 @@ function createSupervisionWidget(getLeads, getStatus, role2 = "chief", theme, on
|
|
|
5831
5838
|
}).filter(({ text }) => text.length > 0);
|
|
5832
5839
|
hits = [];
|
|
5833
5840
|
rows.forEach((row, index) => {
|
|
5834
|
-
if (row.intent
|
|
5841
|
+
if (!row.intent || !row.label) return;
|
|
5842
|
+
if (row.clickRegion) {
|
|
5843
|
+
hits.push({ row: index, ...row.clickRegion, intent: row.intent });
|
|
5844
|
+
} else if (identifyingLabelVisible(row.text, row.label, width)) {
|
|
5835
5845
|
hits.push({
|
|
5836
5846
|
row: index,
|
|
5837
5847
|
from: 0,
|
|
5838
5848
|
to: Math.min(width, visibleWidth(row.text)),
|
|
5839
5849
|
intent: row.intent
|
|
5840
5850
|
});
|
|
5851
|
+
}
|
|
5841
5852
|
});
|
|
5842
5853
|
return rows.map(({ text }) => text);
|
|
5843
5854
|
},
|
|
@@ -5904,6 +5915,35 @@ function value(v) {
|
|
|
5904
5915
|
function peerMessageStatus(details) {
|
|
5905
5916
|
return details.accepted === true ? "accepted remotely" : details.accepted === false ? "queued for remote retry" : details.remoteSessionId ? "reply queued" : "peer message queued";
|
|
5906
5917
|
}
|
|
5918
|
+
function peerRemoteDiagnosticLines(diagnostics, reportedOmitted) {
|
|
5919
|
+
const lines = [];
|
|
5920
|
+
const visibleDiagnostics = diagnostics.slice(0, maxRemoteDiagnostics);
|
|
5921
|
+
for (const item of visibleDiagnostics) {
|
|
5922
|
+
if (!item || typeof item !== "object") continue;
|
|
5923
|
+
const diagnostic = item;
|
|
5924
|
+
const message = remoteDiagnosticMessages[value(diagnostic.reason)];
|
|
5925
|
+
if (!message) continue;
|
|
5926
|
+
const machine = collapseDisplayText(value(diagnostic.machine), 80);
|
|
5927
|
+
const peer = collapseDisplayText(value(diagnostic.peer), 80);
|
|
5928
|
+
const subject = [machine, peer].filter(Boolean).join(" \xB7 ");
|
|
5929
|
+
lines.push(` ${subject || "saved machines"} \xB7 ${message[0]}`);
|
|
5930
|
+
const localBuild = collapseDisplayText(value(diagnostic.local_build), 48);
|
|
5931
|
+
const remoteBuild = collapseDisplayText(value(diagnostic.remote_build), 48);
|
|
5932
|
+
if (localBuild) lines.push(` local ${localBuild}`);
|
|
5933
|
+
if (remoteBuild) lines.push(` remote ${remoteBuild}`);
|
|
5934
|
+
lines.push(` Check: ${message[1]}`);
|
|
5935
|
+
}
|
|
5936
|
+
const omitted = reportedOmitted + Math.max(0, diagnostics.length - visibleDiagnostics.length);
|
|
5937
|
+
if (omitted)
|
|
5938
|
+
lines.push(
|
|
5939
|
+
` ${omitted} additional diagnostic${omitted === 1 ? "" : "s"} omitted`
|
|
5940
|
+
);
|
|
5941
|
+
return lines;
|
|
5942
|
+
}
|
|
5943
|
+
function remoteDiagnosticOmittedCount(details) {
|
|
5944
|
+
const count = details.remote_diagnostics_omitted;
|
|
5945
|
+
return typeof count === "number" && Number.isSafeInteger(count) && count > 0 ? count : 0;
|
|
5946
|
+
}
|
|
5907
5947
|
function agentDefinitionSuffix(label, definition) {
|
|
5908
5948
|
const name = value(definition);
|
|
5909
5949
|
return name && name !== label ? ` \xB7 ${name}` : "";
|
|
@@ -6500,7 +6540,7 @@ function coordinationBody(action, args) {
|
|
|
6500
6540
|
return typeof text === "string" && text.trim() ? { label, text } : void 0;
|
|
6501
6541
|
}
|
|
6502
6542
|
function coordinationHeader(tool, verb, target, theme) {
|
|
6503
|
-
const title = tool === "agent" ? verb === "list" ? "list agents" : verb === "transcript" ? "read agent transcript" : `${verb} agent` : tool === "staff" ? verb === "transcript" ? "read staff transcript" : `${verb} ${verb === "delegate" || verb === "resume" ? "
|
|
6543
|
+
const title = tool === "agent" ? verb === "list" ? "list agents" : verb === "transcript" ? "read agent transcript" : `${verb} agent` : tool === "staff" ? verb === "transcript" ? "read staff transcript" : verb === "merge" ? "integrate branch" : `${verb} ${verb === "delegate" || verb === "resume" ? "work" : verb === "stop" ? "lead" : verb === "remove" ? "worktree" : "staff"}` : tool === "peer" ? verb === "list" ? "list peers" : "message peer" : `${verb} supervisor`;
|
|
6504
6544
|
return `${humanText(theme, "toolTitle", theme.bold(title))}${target ? ` ${humanText(theme, "accent", target)}` : ""}`;
|
|
6505
6545
|
}
|
|
6506
6546
|
function renderExpandedCoordinationCall(tool, action, args, theme, header) {
|
|
@@ -6705,7 +6745,8 @@ function agentHierarchy(details) {
|
|
|
6705
6745
|
}
|
|
6706
6746
|
function expandedResultLines(tool, action, details, args, theme, activeRole) {
|
|
6707
6747
|
const display = value(details.display_name) || value(details.agent) || value(details.label) || value(details.session) || value(args.agent) || value(args.label) || "agent";
|
|
6708
|
-
const
|
|
6748
|
+
const staffWorkOutcome = tool === "staff" && details.ok === true ? action === "delegate" ? "work assigned" : action === "resume" ? details.already_running === true ? "work already running" : "work resumed" : void 0 : void 0;
|
|
6749
|
+
const heading = staffWorkOutcome ?? (tool === "staff" && action === "merge" && details.ok === true ? "integrate branch" : action === "list" ? tool === "staff" ? "staff" : tool === "peer" ? "peer" : "agents" : tool === "peer" && action === "message" ? peerMessageStatus(details) : action === "inspect" ? `inspect ${display}` : tool === "staff" && action === "remove" ? "remove worktree" : action === "delegate" || action === "continue" ? `${display} started` : tool === "supervisor" ? "sent to supervisor" : action === "steer" ? "steering queued" : action === "interrupt" ? "interrupt accepted" : tool === "agent" && action === "reply" ? `reply sent to ${display}` : action === "close" ? `${display} closed` : `${action} ${display}`);
|
|
6709
6750
|
const lines = [heading];
|
|
6710
6751
|
const fields = [
|
|
6711
6752
|
["definition", details.definition ?? details.agent_definition],
|
|
@@ -6814,12 +6855,13 @@ function expandedResultLines(tool, action, details, args, theme, activeRole) {
|
|
|
6814
6855
|
];
|
|
6815
6856
|
})
|
|
6816
6857
|
);
|
|
6817
|
-
const
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6858
|
+
const remoteDiagnostics = Array.isArray(details.remote_diagnostics) ? details.remote_diagnostics : [];
|
|
6859
|
+
const diagnosticLines = peerRemoteDiagnosticLines(
|
|
6860
|
+
remoteDiagnostics,
|
|
6861
|
+
remoteDiagnosticOmittedCount(details)
|
|
6862
|
+
);
|
|
6863
|
+
if (diagnosticLines.length)
|
|
6864
|
+
lines.push("", "remote diagnostics", ...diagnosticLines);
|
|
6823
6865
|
return lines;
|
|
6824
6866
|
}
|
|
6825
6867
|
const reports = Array.isArray(details.reports) ? details.reports : [];
|
|
@@ -6827,7 +6869,7 @@ function expandedResultLines(tool, action, details, args, theme, activeRole) {
|
|
|
6827
6869
|
lines.push(
|
|
6828
6870
|
"",
|
|
6829
6871
|
...work.length ? [
|
|
6830
|
-
"
|
|
6872
|
+
"Managed work:",
|
|
6831
6873
|
...work.flatMap((item) => {
|
|
6832
6874
|
if (!item || typeof item !== "object") return [];
|
|
6833
6875
|
const branch = value(item.branch) || "unknown";
|
|
@@ -6990,7 +7032,7 @@ ${expandedResultLines(tool, action, details, args, theme, context?.activeRole).s
|
|
|
6990
7032
|
}
|
|
6991
7033
|
if (!expanded && tool === "staff" && ["delegate", "resume", "stop"].includes(action)) {
|
|
6992
7034
|
const branch = value(details.branch) || value(args.branch) || "project";
|
|
6993
|
-
const outcome = action === "delegate" ? `
|
|
7035
|
+
const outcome = action === "delegate" ? `work assigned \xB7 ${branch}` : action === "resume" ? details.already_running === true ? `work already running \xB7 ${branch}` : `work resumed \xB7 ${branch}` : `Lead stopped \xB7 ${branch} preserved`;
|
|
6994
7036
|
return new WidthSafeText(statusLine(theme, "success", "\u2713", outcome), 0, 0);
|
|
6995
7037
|
}
|
|
6996
7038
|
if (expanded)
|
|
@@ -7060,7 +7102,14 @@ ${humanText(theme, "warning", ` ! descendant continuation warning \xB7 Ctrl+O`)
|
|
|
7060
7102
|
if (tool === "peer" && action === "list") {
|
|
7061
7103
|
const peers = Array.isArray(details.peers) ? details.peers : [];
|
|
7062
7104
|
const replyOnly = Array.isArray(details.reply_only) ? details.reply_only : [];
|
|
7063
|
-
const
|
|
7105
|
+
const diagnostics = Array.isArray(details.remote_diagnostics) ? details.remote_diagnostics : [];
|
|
7106
|
+
const warningCount = diagnostics.length + remoteDiagnosticOmittedCount(details);
|
|
7107
|
+
const peerCount = warningCount || replyOnly.length ? `${peers.length} discovered` : `${peers.length} peer${peers.length === 1 ? "" : "s"}`;
|
|
7108
|
+
const summary = [
|
|
7109
|
+
`peer \xB7 ${peerCount}`,
|
|
7110
|
+
...replyOnly.length ? [`${replyOnly.length} reply-only`] : [],
|
|
7111
|
+
...warningCount ? [`${warningCount} warning${warningCount === 1 ? "" : "s"}`] : []
|
|
7112
|
+
].join(" \xB7 ");
|
|
7064
7113
|
return new WidthSafeText(humanText(theme, "toolTitle", summary), 0, 0);
|
|
7065
7114
|
}
|
|
7066
7115
|
if (tool === "peer" && action === "message")
|
|
@@ -7250,7 +7299,7 @@ function renderCoordinationMessage(kind, message, options2, theme) {
|
|
|
7250
7299
|
`;
|
|
7251
7300
|
break;
|
|
7252
7301
|
case "project_message":
|
|
7253
|
-
heading = d?.branch ? `
|
|
7302
|
+
heading = d?.branch ? `Assignment update \xB7 ${d.branch}` : "Assignment update";
|
|
7254
7303
|
if (d?.branch && d?.fromSessionId)
|
|
7255
7304
|
prefix = `Project ${d.branch} from lead ${d.fromSessionId}:
|
|
7256
7305
|
|
|
@@ -7497,7 +7546,7 @@ function renderAgentLostMessage(message, options2, theme) {
|
|
|
7497
7546
|
function createStatusWidget(invalidate, theme, onFocus) {
|
|
7498
7547
|
return new StatusWidget(invalidate, theme, onFocus);
|
|
7499
7548
|
}
|
|
7500
|
-
var LIFECYCLE, animates, STATE_COLOR, MIN_TASK_WIDTH, STATUS_LAYOUTS, SUPERVISION_GROUPS, MANAGER_METADATA_LAYOUTS, SUPERVISION_CONTEXT_MAX_BYTES, WidthSafeText, spinner, StatusWidget;
|
|
7549
|
+
var LIFECYCLE, animates, STATE_COLOR, MIN_TASK_WIDTH, STATUS_LAYOUTS, SUPERVISION_GROUPS, MANAGER_METADATA_LAYOUTS, SUPERVISION_CONTEXT_MAX_BYTES, remoteDiagnosticMessages, maxRemoteDiagnostics, WidthSafeText, spinner, StatusWidget;
|
|
7501
7550
|
var init_presentation = __esm({
|
|
7502
7551
|
"extension/presentation.ts"() {
|
|
7503
7552
|
init_agent_definitions();
|
|
@@ -7541,6 +7590,30 @@ var init_presentation = __esm({
|
|
|
7541
7590
|
{ elapsed: false, context: false }
|
|
7542
7591
|
];
|
|
7543
7592
|
SUPERVISION_CONTEXT_MAX_BYTES = 16 * 1024;
|
|
7593
|
+
remoteDiagnosticMessages = {
|
|
7594
|
+
machine_list_failed: [
|
|
7595
|
+
"Saved Herdr machines could not be listed",
|
|
7596
|
+
"Check Herdr machine status."
|
|
7597
|
+
],
|
|
7598
|
+
herdr_not_reachable: [
|
|
7599
|
+
"Herdr reachability not confirmed",
|
|
7600
|
+
"Check Herdr machine status; reconnect interactively if needed."
|
|
7601
|
+
],
|
|
7602
|
+
probe_failed: [
|
|
7603
|
+
"Remote peer probe failed",
|
|
7604
|
+
"Check Herdr machine status and the remote Pi session."
|
|
7605
|
+
],
|
|
7606
|
+
build_mismatch: ["Peer build mismatch", "Reload the outdated Pi session."],
|
|
7607
|
+
build_unverified: [
|
|
7608
|
+
"Peer build could not be verified",
|
|
7609
|
+
"Reload the remote Pi session to publish build identity."
|
|
7610
|
+
],
|
|
7611
|
+
eligibility_unverified: [
|
|
7612
|
+
"Ordinary-Lead eligibility could not be verified",
|
|
7613
|
+
"Check the remote assignment scan before relying on Lead results."
|
|
7614
|
+
]
|
|
7615
|
+
};
|
|
7616
|
+
maxRemoteDiagnostics = 20;
|
|
7544
7617
|
WidthSafeText = class extends Text {
|
|
7545
7618
|
render(width) {
|
|
7546
7619
|
return super.render(width).map(
|
|
@@ -21983,7 +22056,7 @@ import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
|
21983
22056
|
// package.json
|
|
21984
22057
|
var package_default = {
|
|
21985
22058
|
name: "pi-herdsman",
|
|
21986
|
-
version: "0.
|
|
22059
|
+
version: "0.35.0",
|
|
21987
22060
|
type: "module",
|
|
21988
22061
|
description: "Asynchronous Pi subagents and agent fleet orchestration for parallel coding agents with nested delegation, background work, and supervision in herdr.",
|
|
21989
22062
|
license: "Apache-2.0",
|
|
@@ -26709,7 +26782,7 @@ function createLeadSupervisionRuntime(host) {
|
|
|
26709
26782
|
);
|
|
26710
26783
|
const entries = assignment.requiredEvidence ?? [];
|
|
26711
26784
|
if (!entries.length) {
|
|
26712
|
-
ctx.ui.notify("This
|
|
26785
|
+
ctx.ui.notify("This assignment has no required evidence.", "info");
|
|
26713
26786
|
} else {
|
|
26714
26787
|
const selectedEvidence = await uiActions.selectMenu(
|
|
26715
26788
|
ctx,
|
|
@@ -29186,7 +29259,7 @@ Subsequent explicitly requested removals here can proceed without a per-removal
|
|
|
29186
29259
|
}
|
|
29187
29260
|
};
|
|
29188
29261
|
const activateProjectLeadLocked = async (operation, ctx, signal) => {
|
|
29189
|
-
const operationName = operation.action === "resume" ? "
|
|
29262
|
+
const operationName = operation.action === "resume" ? "resume_work" : "delegate_work";
|
|
29190
29263
|
const manager = await currentManager(ctx);
|
|
29191
29264
|
if (!manager || !leadRuntime.managerLease || !sameManagerDescriptor2(manager, leadRuntime.managerLease.descriptor))
|
|
29192
29265
|
throw new Error("Manager lease is no longer active");
|
|
@@ -29234,11 +29307,11 @@ Subsequent explicitly requested removals here can proceed without a per-removal
|
|
|
29234
29307
|
throw new Error("Project assignment belongs to another repository");
|
|
29235
29308
|
if (operation.action === "delegate" && currentAssignment)
|
|
29236
29309
|
throw new Error(
|
|
29237
|
-
`Work already exists on ${branch}; resume it with
|
|
29310
|
+
`Work already exists on ${branch}; resume it with resume_work.`
|
|
29238
29311
|
);
|
|
29239
29312
|
if (operation.action === "resume" && !currentAssignment)
|
|
29240
29313
|
throw new Error(
|
|
29241
|
-
`No existing work was found on ${branch}; start it with
|
|
29314
|
+
`No existing work was found on ${branch}; start it with delegate_work and a task.`
|
|
29242
29315
|
);
|
|
29243
29316
|
const presentationTask = operation.action === "resume" ? projectTaskSummary(currentAssignment.text) : void 0;
|
|
29244
29317
|
const id = operation.action === "resume" ? currentAssignment.id : operation.id;
|
|
@@ -29340,7 +29413,7 @@ Subsequent explicitly requested removals here can proceed without a per-removal
|
|
|
29340
29413
|
const suppliedFiles = resolveMessageFiles2(
|
|
29341
29414
|
ctx,
|
|
29342
29415
|
operation.files,
|
|
29343
|
-
"
|
|
29416
|
+
"delegate_work"
|
|
29344
29417
|
);
|
|
29345
29418
|
const projectBrief = persistRequiredEvidenceSnapshot(
|
|
29346
29419
|
id,
|
|
@@ -29350,7 +29423,7 @@ Subsequent explicitly requested removals here can proceed without a per-removal
|
|
|
29350
29423
|
const attachedEvidence = [];
|
|
29351
29424
|
for (const file2 of suppliedFiles)
|
|
29352
29425
|
attachedEvidence.push(
|
|
29353
|
-
...typeof file2 === "string" ? persistRequiredTextFiles(id, [file2], ctx.cwd, "
|
|
29426
|
+
...typeof file2 === "string" ? persistRequiredTextFiles(id, [file2], ctx.cwd, "delegate_work") : [{ id: randomUUID14(), name: file2.ref, result: file2 }]
|
|
29354
29427
|
);
|
|
29355
29428
|
const requiredEvidence = [projectBrief, ...attachedEvidence];
|
|
29356
29429
|
const prepared = prepareMessageInput2(
|
|
@@ -29359,7 +29432,7 @@ Subsequent explicitly requested removals here can proceed without a per-removal
|
|
|
29359
29432
|
(evidence) => "path" in evidence ? [evidence.path] : [evidence.result]
|
|
29360
29433
|
),
|
|
29361
29434
|
ctx.cwd,
|
|
29362
|
-
"
|
|
29435
|
+
"delegate_work",
|
|
29363
29436
|
"Task",
|
|
29364
29437
|
{
|
|
29365
29438
|
inlineLimitBytes: limits.inline.bytes,
|
|
@@ -29504,7 +29577,7 @@ Subsequent explicitly requested removals here can proceed without a per-removal
|
|
|
29504
29577
|
() => {
|
|
29505
29578
|
if (readProjectAssignment2(runtime, manager.repoKey, assignment.branch))
|
|
29506
29579
|
throw new Error(
|
|
29507
|
-
`Work already exists on ${assignment.branch}; resume it with
|
|
29580
|
+
`Work already exists on ${assignment.branch}; resume it with resume_work.`
|
|
29508
29581
|
);
|
|
29509
29582
|
writeProjectAssignment2(runtime, assignment);
|
|
29510
29583
|
},
|
|
@@ -30208,7 +30281,9 @@ Subsequent explicitly requested removals here can proceed without a per-removal
|
|
|
30208
30281
|
};
|
|
30209
30282
|
const updateAssignmentEvidence = async (_id, params, _signal, _update, ctx, onPersisted) => {
|
|
30210
30283
|
if (host.activeRole() !== "manager")
|
|
30211
|
-
throw new Error(
|
|
30284
|
+
throw new Error(
|
|
30285
|
+
"Only the Manager can update assignment required evidence"
|
|
30286
|
+
);
|
|
30212
30287
|
if (!params.branch?.trim())
|
|
30213
30288
|
throw new Error("Manager must provide the exact assigned project branch");
|
|
30214
30289
|
const manager = await host.currentManager(ctx);
|
|
@@ -30392,7 +30467,7 @@ ${(updated.requiredEvidence ?? []).map((entry) => `- ${entry.id}: ${entry.name}`
|
|
|
30392
30467
|
};
|
|
30393
30468
|
const inspectRequiredEvidence = async (branch, ctx) => {
|
|
30394
30469
|
if (host.activeRole() !== "manager")
|
|
30395
|
-
throw new Error("Only the Manager can inspect
|
|
30470
|
+
throw new Error("Only the Manager can inspect assignment requirements");
|
|
30396
30471
|
const manager = await host.currentManager(ctx);
|
|
30397
30472
|
const lease = host.managerLease();
|
|
30398
30473
|
if (!manager || !lease || host.leadRuntime.roleSuspended || !host.sameManagerDescriptor(manager, lease.descriptor))
|
|
@@ -30407,7 +30482,7 @@ ${(updated.requiredEvidence ?? []).map((entry) => `- ${entry.id}: ${entry.name}`
|
|
|
30407
30482
|
};
|
|
30408
30483
|
const removeRequiredEvidence = async (branch, id, expectedAssignment, ctx) => {
|
|
30409
30484
|
if (host.activeRole() !== "manager")
|
|
30410
|
-
throw new Error("Only the Manager can remove
|
|
30485
|
+
throw new Error("Only the Manager can remove assignment requirements");
|
|
30411
30486
|
await updateAssignmentEvidence(
|
|
30412
30487
|
"manager-required-evidence",
|
|
30413
30488
|
{
|
|
@@ -31073,6 +31148,7 @@ function createLeadCoordinationRuntime(host) {
|
|
|
31073
31148
|
latestCustomMessageText(ctx, supervisorStateType)
|
|
31074
31149
|
);
|
|
31075
31150
|
};
|
|
31151
|
+
const maxRemoteDiagnostics2 = 20;
|
|
31076
31152
|
const remotePeerRoutes = /* @__PURE__ */ new Map();
|
|
31077
31153
|
const ambiguousRemoteSessions = /* @__PURE__ */ new Set();
|
|
31078
31154
|
const lastPeerCorrespondenceErrors = /* @__PURE__ */ new Map();
|
|
@@ -31353,11 +31429,26 @@ ${conflicts.map((binding) => `${binding.ref} \u2192 ${binding.canonicalRef}`).jo
|
|
|
31353
31429
|
workspace_label: record2.workspaceLabel ?? ""
|
|
31354
31430
|
});
|
|
31355
31431
|
}
|
|
31356
|
-
const
|
|
31432
|
+
const remoteDiagnostics = [];
|
|
31433
|
+
let remoteDiagnosticsOmitted = 0;
|
|
31434
|
+
const addRemoteDiagnostic = (diagnostic) => {
|
|
31435
|
+
if (remoteDiagnostics.length < maxRemoteDiagnostics2)
|
|
31436
|
+
remoteDiagnostics.push(diagnostic);
|
|
31437
|
+
else remoteDiagnosticsOmitted++;
|
|
31438
|
+
};
|
|
31439
|
+
const diagnosticLabel = (value2, fallback) => {
|
|
31440
|
+
const text = typeof value2 === "string" ? value2.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu, " ").replace(/\s+/gu, " ").trim() : "";
|
|
31441
|
+
if (!text) return fallback;
|
|
31442
|
+
const characters = Array.from(text);
|
|
31443
|
+
return characters.length > 80 ? `${characters.slice(0, 79).join("")}\u2026` : text;
|
|
31444
|
+
};
|
|
31445
|
+
const diagnosticBuild = (build) => diagnosticLabel(formatRuntimeBuild(build), "unknown");
|
|
31357
31446
|
const localPeerSessions = new Set(peers.map((peer) => peer.session));
|
|
31358
31447
|
const discoveredRemotePeerRoutes = new Map(remotePeerRoutes);
|
|
31359
31448
|
const previousAmbiguousSessions = new Set(ambiguousRemoteSessions);
|
|
31360
31449
|
const discoveredAmbiguousSessions = /* @__PURE__ */ new Set();
|
|
31450
|
+
let machineListingFailed = false;
|
|
31451
|
+
let machineDiscoveryIncomplete = false;
|
|
31361
31452
|
if (remoteDiscoveryEligible) {
|
|
31362
31453
|
let machines;
|
|
31363
31454
|
let machineListingSucceeded = false;
|
|
@@ -31366,7 +31457,9 @@ ${conflicts.map((binding) => `${binding.ref} \u2192 ${binding.canonicalRef}`).jo
|
|
|
31366
31457
|
machineListingSucceeded = true;
|
|
31367
31458
|
} catch {
|
|
31368
31459
|
machines = [];
|
|
31369
|
-
|
|
31460
|
+
machineListingFailed = true;
|
|
31461
|
+
machineDiscoveryIncomplete = true;
|
|
31462
|
+
addRemoteDiagnostic({ reason: "machine_list_failed" });
|
|
31370
31463
|
}
|
|
31371
31464
|
if (machineListingSucceeded) {
|
|
31372
31465
|
const listedMachines = new Map(
|
|
@@ -31386,7 +31479,11 @@ ${conflicts.map((binding) => `${binding.ref} \u2192 ${binding.canonicalRef}`).jo
|
|
|
31386
31479
|
for (const machine of machines) {
|
|
31387
31480
|
if (signal?.aborted) break;
|
|
31388
31481
|
if (!machine.reachable) {
|
|
31389
|
-
|
|
31482
|
+
machineDiscoveryIncomplete = true;
|
|
31483
|
+
addRemoteDiagnostic({
|
|
31484
|
+
machine: diagnosticLabel(machine.label, "machine"),
|
|
31485
|
+
reason: "herdr_not_reachable"
|
|
31486
|
+
});
|
|
31390
31487
|
continue;
|
|
31391
31488
|
}
|
|
31392
31489
|
let identityEstablished = false;
|
|
@@ -31394,24 +31491,51 @@ ${conflicts.map((binding) => `${binding.ref} \u2192 ${binding.canonicalRef}`).jo
|
|
|
31394
31491
|
const snapshot = await probePeerEndpoint(machine, signal);
|
|
31395
31492
|
if (signal?.aborted) break;
|
|
31396
31493
|
identityEstablished = true;
|
|
31494
|
+
const ordinaryLeadScanIncomplete = activeRole() === "lead" && snapshot.ordinaryLeadsComplete !== true;
|
|
31495
|
+
if (ordinaryLeadScanIncomplete) {
|
|
31496
|
+
machineDiscoveryIncomplete = true;
|
|
31497
|
+
addRemoteDiagnostic({
|
|
31498
|
+
machine: diagnosticLabel(machine.label, "machine"),
|
|
31499
|
+
reason: "eligibility_unverified"
|
|
31500
|
+
});
|
|
31501
|
+
}
|
|
31397
31502
|
for (const [session, route] of discoveredRemotePeerRoutes)
|
|
31398
|
-
if (route.machine.id === machine.id)
|
|
31503
|
+
if (route.machine.id === machine.id && (!ordinaryLeadScanIncomplete || route.role !== "lead"))
|
|
31399
31504
|
discoveredRemotePeerRoutes.delete(session);
|
|
31505
|
+
if (ordinaryLeadScanIncomplete)
|
|
31506
|
+
for (const [session, route] of remotePeerRoutes) {
|
|
31507
|
+
if (route.machine.id !== machine.id || route.role !== "lead")
|
|
31508
|
+
continue;
|
|
31509
|
+
if (discoveredRemotePeerRoutes.has(session)) {
|
|
31510
|
+
discoveredAmbiguousSessions.add(session);
|
|
31511
|
+
discoveredRemotePeerRoutes.delete(session);
|
|
31512
|
+
} else discoveredRemotePeerRoutes.set(session, route);
|
|
31513
|
+
}
|
|
31400
31514
|
for (const remote of snapshot.peers) {
|
|
31401
31515
|
const remoteRole = activeRole();
|
|
31402
31516
|
if (remote.role !== remoteRole || remoteRole === "lead" && (snapshot.ordinaryLeadsComplete !== true || remote.sessionKind !== "ordinary") || remote.piSessionId === self || localPeerSessions.has(remote.piSessionId) || !remote.claim?.id || discoveredAmbiguousSessions.has(remote.piSessionId))
|
|
31403
31517
|
continue;
|
|
31404
|
-
|
|
31405
|
-
|
|
31406
|
-
|
|
31407
|
-
|
|
31408
|
-
|
|
31409
|
-
|
|
31410
|
-
|
|
31411
|
-
|
|
31412
|
-
|
|
31413
|
-
|
|
31414
|
-
|
|
31518
|
+
const peerHint = diagnosticLabel(
|
|
31519
|
+
remote.name,
|
|
31520
|
+
`peer-${remote.piSessionId.slice(0, 8)}`
|
|
31521
|
+
);
|
|
31522
|
+
if (!isRuntimeBuild(remote.build)) {
|
|
31523
|
+
addRemoteDiagnostic({
|
|
31524
|
+
machine: diagnosticLabel(machine.label, "machine"),
|
|
31525
|
+
reason: "build_unverified",
|
|
31526
|
+
peer: peerHint
|
|
31527
|
+
});
|
|
31528
|
+
continue;
|
|
31529
|
+
}
|
|
31530
|
+
if (!sameRuntimeBuild2(HERDSMAN_BUILD2, remote.build)) {
|
|
31531
|
+
addRemoteDiagnostic({
|
|
31532
|
+
machine: diagnosticLabel(machine.label, "machine"),
|
|
31533
|
+
reason: "build_mismatch",
|
|
31534
|
+
peer: peerHint,
|
|
31535
|
+
local_build: diagnosticBuild(HERDSMAN_BUILD2),
|
|
31536
|
+
remote_build: diagnosticBuild(remote.build)
|
|
31537
|
+
});
|
|
31538
|
+
continue;
|
|
31415
31539
|
}
|
|
31416
31540
|
const route = discoveredRemotePeerRoutes.get(remote.piSessionId);
|
|
31417
31541
|
if (route) {
|
|
@@ -31691,7 +31815,11 @@ ${receivedRefs.join("\n")}` : ""}`,
|
|
|
31691
31815
|
if (identityEstablished) {
|
|
31692
31816
|
appendDurableError2(pi, ctx, "pi_herdsman_state_error", error2);
|
|
31693
31817
|
} else {
|
|
31694
|
-
|
|
31818
|
+
machineDiscoveryIncomplete = true;
|
|
31819
|
+
addRemoteDiagnostic({
|
|
31820
|
+
machine: diagnosticLabel(machine.label, "machine"),
|
|
31821
|
+
reason: "probe_failed"
|
|
31822
|
+
});
|
|
31695
31823
|
for (const [session, route] of discoveredRemotePeerRoutes)
|
|
31696
31824
|
if (route.machine.id === machine.id)
|
|
31697
31825
|
discoveredRemotePeerRoutes.delete(session);
|
|
@@ -31708,7 +31836,7 @@ ${receivedRefs.join("\n")}` : ""}`,
|
|
|
31708
31836
|
}
|
|
31709
31837
|
}
|
|
31710
31838
|
}
|
|
31711
|
-
if (
|
|
31839
|
+
if (machineDiscoveryIncomplete) {
|
|
31712
31840
|
for (const session of previousAmbiguousSessions)
|
|
31713
31841
|
discoveredAmbiguousSessions.add(session);
|
|
31714
31842
|
}
|
|
@@ -31721,7 +31849,7 @@ ${receivedRefs.join("\n")}` : ""}`,
|
|
|
31721
31849
|
if (index >= 0) peers.splice(index, 1);
|
|
31722
31850
|
}
|
|
31723
31851
|
}
|
|
31724
|
-
if ((activeRole() === "manager" || activeRole() === "lead") && discovery === latestPeerDiscovery && !signal?.aborted && !
|
|
31852
|
+
if ((activeRole() === "manager" || activeRole() === "lead") && discovery === latestPeerDiscovery && !signal?.aborted && !machineListingFailed) {
|
|
31725
31853
|
remotePeerRoutes.clear();
|
|
31726
31854
|
for (const [session, route] of discoveredRemotePeerRoutes)
|
|
31727
31855
|
remotePeerRoutes.set(session, route);
|
|
@@ -31751,25 +31879,26 @@ ${receivedRefs.join("\n")}` : ""}`,
|
|
|
31751
31879
|
...correspondence.originDisplay?.name ? { name: correspondence.originDisplay.name } : {},
|
|
31752
31880
|
...correspondence.originDisplay?.workspaceLabel ? { workspace_label: correspondence.originDisplay.workspaceLabel } : {}
|
|
31753
31881
|
}));
|
|
31882
|
+
const discoveryPayload = {
|
|
31883
|
+
self,
|
|
31884
|
+
peers,
|
|
31885
|
+
...replyOnly.length ? { reply_only: replyOnly } : {},
|
|
31886
|
+
...remoteDiagnostics.length ? {
|
|
31887
|
+
remote_diagnostics: remoteDiagnostics,
|
|
31888
|
+
...remoteDiagnosticsOmitted ? { remote_diagnostics_omitted: remoteDiagnosticsOmitted } : {}
|
|
31889
|
+
} : {}
|
|
31890
|
+
};
|
|
31754
31891
|
return {
|
|
31755
31892
|
content: [
|
|
31756
31893
|
{
|
|
31757
31894
|
type: "text",
|
|
31758
|
-
text: JSON.stringify(
|
|
31759
|
-
self,
|
|
31760
|
-
peers,
|
|
31761
|
-
...replyOnly.length ? { reply_only: replyOnly } : {},
|
|
31762
|
-
...unavailableMachines.length ? { unavailable_machines: [...new Set(unavailableMachines)] } : {}
|
|
31763
|
-
})
|
|
31895
|
+
text: JSON.stringify(discoveryPayload)
|
|
31764
31896
|
}
|
|
31765
31897
|
],
|
|
31766
31898
|
details: {
|
|
31767
31899
|
ok: true,
|
|
31768
31900
|
action: "list",
|
|
31769
|
-
|
|
31770
|
-
peers,
|
|
31771
|
-
...replyOnly.length ? { reply_only: replyOnly } : {},
|
|
31772
|
-
...unavailableMachines.length ? { unavailable_machines: [...new Set(unavailableMachines)] } : {}
|
|
31901
|
+
...discoveryPayload
|
|
31773
31902
|
}
|
|
31774
31903
|
};
|
|
31775
31904
|
}
|
|
@@ -34974,11 +35103,11 @@ var MANAGER_TOOLS = [
|
|
|
34974
35103
|
...SUPERVISOR_TOOLS,
|
|
34975
35104
|
...PEER_TOOLS,
|
|
34976
35105
|
...STAFF_TOOLS,
|
|
34977
|
-
"
|
|
34978
|
-
"
|
|
35106
|
+
"delegate_work",
|
|
35107
|
+
"resume_work",
|
|
34979
35108
|
"stop_lead",
|
|
34980
35109
|
"remove_worktree",
|
|
34981
|
-
"
|
|
35110
|
+
"integrate_branch"
|
|
34982
35111
|
];
|
|
34983
35112
|
var LEAD_COORDINATION_TOOLS = [
|
|
34984
35113
|
...AGENT_COORDINATION_TOOLS,
|
|
@@ -34994,10 +35123,10 @@ var ORDINARY_LEAD_CHARTER = `## Lead role
|
|
|
34994
35123
|
You are an ordinary Lead for this Pi session.
|
|
34995
35124
|
${COMMON_LEAD_GUIDANCE}
|
|
34996
35125
|
Your Agent assignments and file handoffs are recipient-specific. Peer messages coordinate work but do not independently transfer execution ownership.`;
|
|
34997
|
-
var MANAGED_LEAD_GUIDANCE = `Managed Lead identity is permanent for this exact Pi session. Only a current exact
|
|
34998
|
-
For a verified managed project assignment, required
|
|
34999
|
-
A Lead's delegation task and ordinary files are recipient-specific; they do not create
|
|
35000
|
-
Only the Manager can designate continuing
|
|
35126
|
+
var MANAGED_LEAD_GUIDANCE = `Managed Lead identity is permanent for this exact Pi session. Only a current exact work assignment permits execution of that assignment; unavailable or retired assignment state does not grant ordinary Lead execution authority. Exactly owned Agent recovery remains separate. Use native Pi /fork or /clone for independent ordinary continuation; this does not create a separate Git checkout or fresh process configuration.
|
|
35127
|
+
For a verified managed project assignment, assignment required evidence is automatically inherited by newly accepted descendant Agent assignments; sibling Lead assignments do not automatically inherit it.
|
|
35128
|
+
A Lead's delegation task and ordinary files are recipient-specific; they do not create assignment requirements.
|
|
35129
|
+
Only the Manager can designate continuing requirements for an assignment.
|
|
35001
35130
|
Send proposed continuing requirements and available supporting evidence to the Manager for evaluation.
|
|
35002
35131
|
For assigned project work, include routine proposed requirements, completion, and review readiness in your normal response; Herdsman delivers it to the Manager automatically.
|
|
35003
35132
|
For assigned project work, use message_supervisor for timely coordination or explicit evidence transfer, not for a separate completion announcement.
|
|
@@ -35613,11 +35742,11 @@ Use reply_agent with agent="${ask.agentLabel}" to answer this question.`,
|
|
|
35613
35742
|
...PEER_TOOLS,
|
|
35614
35743
|
...STAFF_TOOLS,
|
|
35615
35744
|
"read_evidence",
|
|
35616
|
-
"
|
|
35617
|
-
"
|
|
35745
|
+
"delegate_work",
|
|
35746
|
+
"resume_work",
|
|
35618
35747
|
"stop_lead",
|
|
35619
35748
|
"remove_worktree",
|
|
35620
|
-
"
|
|
35749
|
+
"integrate_branch"
|
|
35621
35750
|
];
|
|
35622
35751
|
if (processRole === "managed-agent") {
|
|
35623
35752
|
leadStatusRuntime = createAgentStatusRuntime();
|
|
@@ -36351,9 +36480,9 @@ ${summary}`,
|
|
|
36351
36480
|
});
|
|
36352
36481
|
pi.registerTool({
|
|
36353
36482
|
...staffTool,
|
|
36354
|
-
name: "
|
|
36355
|
-
label: "delegate
|
|
36356
|
-
description: "Start new
|
|
36483
|
+
name: "delegate_work",
|
|
36484
|
+
label: "delegate work",
|
|
36485
|
+
description: "Start a new work assignment, reusing an unoccupied Herdr worktree when available. The initial task and supplied files become required assignment evidence; use resume_work for existing work.",
|
|
36357
36486
|
parameters: staffDelegateParameters,
|
|
36358
36487
|
promptSnippet: void 0,
|
|
36359
36488
|
promptGuidelines: [FILE_HANDOFF_GUIDANCE],
|
|
@@ -36369,8 +36498,8 @@ ${summary}`,
|
|
|
36369
36498
|
});
|
|
36370
36499
|
pi.registerTool({
|
|
36371
36500
|
...staffTool,
|
|
36372
|
-
name: "
|
|
36373
|
-
label: "resume
|
|
36501
|
+
name: "resume_work",
|
|
36502
|
+
label: "resume work",
|
|
36374
36503
|
description: "Reuse an already-running Lead for the exact branch; otherwise resume its existing assignment without creating a duplicate.",
|
|
36375
36504
|
parameters: staffBranchParameters,
|
|
36376
36505
|
promptSnippet: void 0,
|
|
@@ -36403,8 +36532,8 @@ ${summary}`,
|
|
|
36403
36532
|
});
|
|
36404
36533
|
pi.registerTool({
|
|
36405
36534
|
...staffTool,
|
|
36406
|
-
name: "
|
|
36407
|
-
label: "
|
|
36535
|
+
name: "integrate_branch",
|
|
36536
|
+
label: "integrate branch",
|
|
36408
36537
|
description: "Integrate an assigned local branch into the verified primary branch using fast-forward-only Git. Supply the exact full source SHA accepted after validation. This may stop running managed execution before integration. If a later step fails after execution stops, it is not automatically restarted. Verified integration triggers guarded cleanup, but integration and cleanup can complete separately; do not treat integration alone as full finalization.",
|
|
36409
36538
|
parameters: Type3.Object(
|
|
36410
36539
|
{
|