omp packages

@abhishek944/pi-herdr0.2.0

Herdr Core agent lifecycle tools, the bundled coordination skill, and the editable subagent model routing policy for Pi.

GitHub Actions Published 22 hours ago MIT AND Apache-2.0 ~227 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-herdr

Herdr Core agent lifecycle tools and the bundled herdr coordination skill for Pi, together with the editable model-routing-policy skill that supplies subagent provider, model, thinking and Fast choices, and the usage fallback that switches to the policy's default rule when a model's plan usage is exhausted. Version 0.1.0 extracts the existing tools from pi-tasks without renaming them.

Install and compatibility

Install this package together with the compatible local pi-tasks working source that provides the version-1 delegation bridge. Published @abhishek944/pi-tasks@0.15.0 does not have that bridge and still registers the legacy Agent tools. The coordinated local source keeps version 0.15.0; the number alone does not establish compatibility.

pi install /path/to/compatible/pi-tasks
pi install git:github.com/abhishek944/pi-herdr

Replace the legacy pi-tasks source rather than loading both sources. Preserve unrelated package settings. Reload (/reload) or restart Pi after changing packages. If an Agent name is already registered, pi-herdr reports migration instructions and blocks Agent calls instead of overriding tools. A missing or incompatible bridge fails before AgentCreate launches a worker.

Requirements: a modern Pi host supporting nested tool calls, active Work/Todo tools, Herdr Core (hc), and updated pi-loop-monitor tools that support hcTerminalId, wait for the Core subscription-ready receipt, and expose structured MonitorList summaries. Every new worker receives Browse MCP. Isolated mode installs Chrome DevTools MCP 1.14.0 as a pi-herdr dependency and ships the verified unpacked Browse extension 0.1.6.311 under assets/browser-extension/; neither requires a temporary path or global config edit. The two external prerequisites are the browse CLI on PATH and the Aside browser executable at /Applications/Aside.app/Contents/MacOS/Aside on macOS. The verified combination was Browse 0.1.5, Chrome DevTools MCP 1.14.0, and unpacked extension 0.1.6.311 on macOS; other versions and browsers are untested. Override with PI_HERDR_BROWSE_BIN, PI_HERDR_DEVTOOLS_MCP_BIN, PI_HERDR_ASIDE_BIN, or PI_HERDR_BROWSE_EXTENSION_DIR only when a different local installation is required. Reinstall pi-herdr dependencies with npm install in the package if the DevTools MCP bin is missing. PI_HERDR_BROWSE_PORT may pin any TCP port from 1 to 65535 except 19988; otherwise an OS-assigned available loopback port is used. Browse does not support port 0 for isolated relays, and 19988 is reserved for the shared relay and is deliberately rejected. Running mode needs no extra setup, but it requires a Browse MCP configured for new Pi sessions; AgentCreate verifies the registration, not live browser connectivity. The Herdr app (herdr-app) is optional: only an explicitly presented worker (present: true) and AgentFocus use it, and the default Core-only lifecycle never calls it. Host Pi modules are peers, not bundled runtime copies. Local development requires those peers available in the dependency tree.

Tools

Tool Purpose
AgentCreate Derive and create the canonical delegated-task directory, provision Browse access, launch interactive Pi through hc, verify native readiness, register monitoring, link/block its task, and return handles plus an unsent assignment. browser: { mode: "isolated" } is the default; browser: { mode: "running" } reuses the already connected Browse MCP. Returns status: "ready" or, after launch, status: "partial" with the same handles and an AgentResume next step; partial state retains presentRequested/presentation and marks an unfinished required tab in missing. Core-only by default; present: true adds a verified dedicated visible Task-ID-named app tab.
AgentResume Finish startup for the same worker returned by a partial AgentCreate. Validates the timing descriptor and task directory, proves Core ownership through the parent and pi.task/pi.session labels, requires idle Pi, verifies/finishes a required present: true dedicated task-named tab, reuses the recorded browser resources and one ready Core subscription or replaces a non-ready one, and attaches timing/linkage. Never relaunches, provisions a second browser, dispatches a required visible worker as hidden, duplicates monitoring, bypasses prompts or fabricates timing.
AgentList List Core terminals, including unrelated terminals.
AgentStatus Inspect one returned Core terminal address.
AgentOutput Read its screen/history (existing default 50 lines, maximum 200).
AgentSend Send a prompt without force or waiting.
AgentInterrupt Send Escape without closing the terminal.
AgentClose Stop the owned worker, clean its isolated browser resources and release its reservation before removing the Core record. If cleanup fails, the terminal and monitor handles remain available for retry. A partial worker whose monitor was never created can be closed with only terminalId. Running-mode browsers and the user's relay are never changed.
AgentFocus Show an existing Core agent through the Herdr app. A terminal that owns a pane, or another machine's terminal, gets normal agent.focus; a pane-less sub-agent opens its own terminal.peek screen overlay over the current tab without navigating to its parent. This assumes hc and the running app target the same Core; it does not perform Pet Town's verified_world cross-Core anchor. Reports focused: false with a reason when no app is available or the agent cannot be shown.

For an existing owner: delegate task, AgentCreate derives and creates the canonical task directory. Root sessions omit parentTaskDir; a delegated worker passes the exact parentTaskDir from its assignment:

AgentCreate({
  workId: "W1", taskId: "T2",
  // parentTaskDir: "<exact parentTaskDir from your assignment>", // delegated workers only
  // present: true, // optional: adopt the worker into its own visible task-named app tab
  // browser: { mode: "running" }, // optional; omit or use { mode: "isolated" } for a task-owned browser
  assignment: "Review the approved change without editing files.",
  provider: "<selected-provider>", model: "<selected-model>", thinking: "high",
  onSignal: "Inspect the actual worker output and import its measured timing."
})

A root caller gets var/<host-sessionId>/<workId>/<taskId>/. A delegated caller gets <parentTaskDir>/<host-sessionId>/<workId>/<taskId>/. Do not shell-read the session ID or pre-create either directory; the tool returns the resolved taskDir after creating it. Direct hc CLI launches still prepare their canonical directories manually.

An active First Mate coordinator may pass worktree: "<name>" for a direct assignment; the tool provisions or reuses a detached checkout and uses that checkout's var/ root. A worker inherits its worktree and may delegate only with writeScope: "artifacts" and its inherited parentTaskDir; selecting a different worktree is rejected. A reservation prevents another registered source writer from acquiring the checkout. An uncertain launch retains its reservation and browser resources for inspection.

These are coordination controls, not an OS sandbox: writeScope: "artifacts" is an admission and assignment policy, not enforcement against arbitrary process writes. Pathname symlink checks are not race-proof confinement. parentTaskDir is checked for its shape and containment, but is not independently proven equal to the original assignment ancestry. Do not treat these controls as a security boundary against an untrusted agent.

Browser access

Every worker receives Browse MCP through codemode. The input is only browser?: { mode: "isolated" | "running" }; there is no off mode and no browserId or tabId input.

  • Omitted or { mode: "isolated" }: AgentCreate verifies the prerequisites before launching, creates a task-owned headless Aside profile, unpacked extension, relay home, OS-assigned loopback relay port (or the explicit PI_HERDR_BROWSE_PORT when set), and generated Pi extension under <taskDir>/browser/, then registers a task-specific Browse MCP server (isolated_agent_<taskId>) for the worker and excludes configured Browse tools from that worker. Launch attempts are serialized until the relay proves it owns the port; a taken dynamic reservation is retried. The bundled extension accepts that actual port only from the task-owned private pairing file and pins the isolated profile to it. Automatic discovery and the shared relay on 19988 are unchanged; Browse does not support port 0. Chrome DevTools MCP is an internal provisioning client and is not exposed to the worker. The prepared assignment names the Browse server. Isolated provisioning fails closed when a prerequisite is missing; it never installs a package or changes global MCP configuration.
  • { mode: "running" }: AgentCreate checks that a Browse MCP registration is available to new Pi sessions and gives the worker instructions to query live Browse status and choose exactly one browser through Browse itself. If none or several plausibly apply, if the relay is disconnected, or if a personal profile would be used without explicit live permission, the worker asks and stops. No browser, profile, relay, or pairing code is created, and there is no silent fallback to isolated mode.

The isolated resource manifest records mode, server name, owned paths, port, relay instance and process ids, and terminal ownership. It never stores pairing codes, relay tokens, cookies, or credential values. AgentResume reuses the recorded resources; AgentClose stops only the owned DevTools client and relay, then removes only <taskDir>/browser/. The user's relay, browser, profile and tabs are never stopped or changed.

Creation returns status: "ready", taskDir, terminalId, monitorId, reportPath, presented, assignment, and assignmentSent: false; tabId is included only when present: true adopted and verified a real app tab. MonitorCreate waits for the Core subscription-ready receipt before creation succeeds. Confirm MonitorList shows that readiness, then AgentSend the assignment. Keep that monitor for follow-ups. Signals, idle state and process exit are not proof of task completion: read output/files, verify results, import timing and only then close owned resources.

Completing a delegate task with its Core worker record still linked appends one advisory to the TodoUpdate result. pi-herdr emits it only after hc get proves the terminal is a child of this host with matching pi.session and pi.task labels, so nested delegation and unrelated terminals are never targeted. The parent decides whether a real follow-up dependency remains or whether to send /close, read improvements.md, import timing, then AgentClose; the advisory itself sends no command, changes no task status, and repeats only if the task is completed again. Recording a real follow-up as blocked with dependentOn="another-agent" is not a completion transition.

A failure after the worker terminal exists returns a successful tool result with status: "partial", the phase that failed, completed/missing handles, presentRequested/presentation, the error, the prepared assignment and next: AgentResume. When present: true was requested but the dedicated tab was not verified, missing includes presentation; the next step includes present: true. It never relaunches or cleans up automatically. Pre-launch failures still throw because there is no worker to resume. Presentation is checked for an open app space before launch, so a missing app fails before a worker exists; an adoption failure after launch reports the live terminal for the caller to inspect or close.

AgentResume({ workId, taskId, terminalId, taskDir, reportPath, present?, onSignal, onDone? }) resumes that exact worker. It validates the registered timing path through pi-tasks, requires the directory to end with the current session/work/task below the worker checkout's var/, and proves the Core terminal is a child of this host with matching pi.task/pi.session labels. A present: true requirement is preserved from the partial result or recovered from the worker's herdr.space launch label. When required, resume verifies and finishes that same worker's dedicated task-named tab before it can return ready; if the parent is not shown or the tab cannot be verified, it returns partial with presentation still missing and a concrete app dependency. It never dispatches a required visible worker as hidden. Recovery may persist validated browser ownership before checking readiness. A non-idle Pi is reported as not_ready and receives no input, monitor, or task-link attachment. It reuses a ready running monitor; a running monitor that never reported ready is stopped before exactly one replacement is created; more than one running subscription is an error. It then attaches delegate linkage/timing and reports timing: "placeholder" | "measured". A placeholder stays unknown until the worker's own TaskTimeExport writes measured effort; resume never writes or calculates time. Post-validation failures return partial for another resume attempt, not a relaunch.

Use the bundled herdr skill for the complete authorization, model-routing, worker-local tracking and nested artifact contract. Mutation tools require tracked main-conversation work, never /ask or /btw; list/status/output retain their read-only behavior. Core-only workers need no app, space, tab or adoption label, so headless hosts can use the Agent tools; only requested presentation and focus touch the app. No legacy Herdr TUI fallback, HERDR_ENV requirement, worker registry or automatic recovery is added.

Bundled skills

Skill Purpose
herdr Authorization, delegation, Core/app lifecycle, monitoring and artifact contract for the Agent tools.
model-routing-policy Default subagent provider, model, thinking level and Fast mode, kept as one editable JSON block inside a skill file, including the default rule the usage fallback switches to.

skills/model-routing-policy/SKILL.md is the only copy of the routing defaults. Its policy is one json block (rules plus the notes that qualify them) inside the Markdown body; the frontmatter and prose stay as they are. implement, agent-review, herdr, firstmate, and the package-provided grill-me and ui-ux-grill-me skills read it by name before launching agents. Edit that skill — or Herdr's Routing panel, which edits the same block — to change the choices; explicit user choices still override it and the parent agent's model is unchanged. Nothing in the extension hard-codes those model names, so an edit takes effect after /reload or a restart without rebuilding. The Routing panel only writes the file: it never reloads or updates a running agent.

The policy was previously a standalone global skill managed by the shared skills repository. This package is now its source of truth. After the package loads, remove any old ~/.agents/skills/model-routing-policy/ copy so Pi does not discover both sources under the same name.

Usage fallback

When a turn ends with a confirmed plan or workspace usage limit, the extension acts on that turn itself, before Pi retries the request and before any queued message starts a run. It reads the rule whose when is exactly default, switches the session to its model with pi.setModel(), applies its thinking level, and lets the interrupted work resume on that model; a retry or a queued run already uses the fallback, so the exhausted model is asked exactly once. Provider wording for a transient throttle, an authentication failure, a context-window error, a cancellation, or a generic billing problem never triggers it, and it never forces Fast mode. The switch overrides responsibility-specific rules only for work already in progress; new subagents still follow those rules.

Occasionally there is nothing safe to switch to: the default rule is missing or invalid, it names the exhausted model, its model is not in the registry, or its credentials are absent. Then the extension reports why and aborts the operation immediately. That stops Pi's own retry and the settlement boundary, and therefore pi-tasks auto-continue, so no further request reaches the exhausted model. Pi's abort path returns queued input to the editor in interactive mode; the extension also records the reason and any queued text in a session entry so nothing is lost silently. Both decisions happen on the failed turn, so extension load order and handler order do not affect them.

Usage fallback needs no build-time model name: change the default rule in the skill (or through the Routing panel) and the next exhaustion uses it after /reload.

Ownership

  • pi-herdr: Agent tools, Core/app lifecycle orchestration, and the bundled herdr and model-routing-policy skills.
  • pi-tasks: Work/Todo records, timing, delegate metadata and task displays, including their UI CLI helpers.
  • pi-loop-monitor: continuous supervision and wake delivery.
  • Core / Herdr app: processes by Core / optional visible tabs and focus by the app. The default lifecycle is Core-only; presentation is an explicit per-worker opt-in.

The synchronous pi-tasks:delegation-api event request {version: 1, respond(api)} discovers task-owned assignment, timing, binding, and link operations. AgentCreate checks the persisted worktree binding before provisioning. Prepare creates the task directory under the selected checkout's real var/ and registers an expected report path in the parent task; it does not write the worker's report. An unstarted registration is removed after a proven prelaunch failure. The worker exports its own report, and import checks parent assignment and worker identity across checkout roots. Existing parent-created placeholder reports remain supported. Attach records timing/link metadata and blocks the parent; detach clears the link. The bridge validates current-session ownership and active tracking tools, rejecting retained APIs after session replacement. There are no cross-install internal imports.

Development and licenses

Run npm run typecheck, npm run lint, npm run build, and npm pack --dry-run for static verification. Generated dist/, the skill and license notices ship with the package. Live interactive end-to-end verification is user-owned.

Agent code is MIT, copyright (c) 2026 Abhishek Tatikella, extracted from pi-tasks. model-routing-policy is original package content under the same MIT license. The locally adapted Herdr-derived skill retains Apache-2.0 provenance. See LICENSE and THIRD_PARTY_NOTICES.md; the MIT code license does not relicense the skill.