@dorokuma/herdsman 0.13.6 → 0.14.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.
Files changed (57) hide show
  1. package/README.md +2 -2
  2. package/dist/src/agent-history/discovery.d.ts +47 -11
  3. package/dist/src/agent-history/discovery.d.ts.map +1 -1
  4. package/dist/src/agent-history/discovery.js +242 -468
  5. package/dist/src/agent-history/discovery.js.map +1 -1
  6. package/dist/src/agent-history/service.d.ts +4 -7
  7. package/dist/src/agent-history/service.d.ts.map +1 -1
  8. package/dist/src/agent-history/service.js +46 -30
  9. package/dist/src/agent-history/service.js.map +1 -1
  10. package/dist/src/daemon/agent-event-reconciler.js +6 -10
  11. package/dist/src/daemon/agent-event-reconciler.js.map +1 -1
  12. package/dist/src/daemon/herdr-session-watch-manager.js +2 -2
  13. package/dist/src/daemon/herdr-session-watch-manager.js.map +1 -1
  14. package/dist/src/daemon/observability-server.js +6 -6
  15. package/dist/src/daemon/observability-server.js.map +1 -1
  16. package/dist/src/db/agents.d.ts +0 -2
  17. package/dist/src/db/agents.d.ts.map +1 -1
  18. package/dist/src/db/agents.js +14 -57
  19. package/dist/src/db/agents.js.map +1 -1
  20. package/dist/src/herdr/pane-identity-resolver.d.ts +11 -0
  21. package/dist/src/herdr/pane-identity-resolver.d.ts.map +1 -1
  22. package/dist/src/herdr/pane-identity-resolver.js +27 -15
  23. package/dist/src/herdr/pane-identity-resolver.js.map +1 -1
  24. package/dist/src/herdr/session-list.d.ts.map +1 -1
  25. package/dist/src/herdr/session-list.js +4 -2
  26. package/dist/src/herdr/session-list.js.map +1 -1
  27. package/dist/src/observability/agent-context-service.d.ts +4 -10
  28. package/dist/src/observability/agent-context-service.d.ts.map +1 -1
  29. package/dist/src/observability/agent-context-service.js +37 -58
  30. package/dist/src/observability/agent-context-service.js.map +1 -1
  31. package/dist/src/observability/agent-index-service.d.ts.map +1 -1
  32. package/dist/src/observability/agent-index-service.js +15 -22
  33. package/dist/src/observability/agent-index-service.js.map +1 -1
  34. package/dist/src/observability/contracts.d.ts +1 -2
  35. package/dist/src/observability/contracts.d.ts.map +1 -1
  36. package/dist/src/observability/contracts.js.map +1 -1
  37. package/package.json +1 -1
  38. package/dist/src/agent-history/claude-reader.d.ts +0 -10
  39. package/dist/src/agent-history/claude-reader.d.ts.map +0 -1
  40. package/dist/src/agent-history/claude-reader.js +0 -90
  41. package/dist/src/agent-history/claude-reader.js.map +0 -1
  42. package/dist/src/agent-history/codex-reader.d.ts +0 -10
  43. package/dist/src/agent-history/codex-reader.d.ts.map +0 -1
  44. package/dist/src/agent-history/codex-reader.js +0 -119
  45. package/dist/src/agent-history/codex-reader.js.map +0 -1
  46. package/dist/src/agent-history/gemini-reader.d.ts +0 -10
  47. package/dist/src/agent-history/gemini-reader.d.ts.map +0 -1
  48. package/dist/src/agent-history/gemini-reader.js +0 -96
  49. package/dist/src/agent-history/gemini-reader.js.map +0 -1
  50. package/dist/src/agent-history/grok-reader.d.ts +0 -11
  51. package/dist/src/agent-history/grok-reader.d.ts.map +0 -1
  52. package/dist/src/agent-history/grok-reader.js +0 -54
  53. package/dist/src/agent-history/grok-reader.js.map +0 -1
  54. package/dist/src/agent-history/opencode-reader.d.ts +0 -10
  55. package/dist/src/agent-history/opencode-reader.d.ts.map +0 -1
  56. package/dist/src/agent-history/opencode-reader.js +0 -90
  57. package/dist/src/agent-history/opencode-reader.js.map +0 -1
package/README.md CHANGED
@@ -6,7 +6,7 @@ Herdsman is a daemon-backed observability layer for coding agents running in Her
6
6
 
7
7
  Herdr's `herdr agent read` reads terminal streams or scrollback. Herdsman instead reads agent session data so callers can retrieve work status, structured message excerpts, compact tool results, and unread outcomes without parsing terminal output. Herdsman is read-only; use the official Herdr CLI or skill for agent start, prompts, waits, pane operations, and terminal control.
8
8
 
9
- Herdsman currently supports session history from Claude Code, Codex, Gemini CLI, OpenCode, Pi, Grok, and Antigravity CLI.
9
+ Herdsman resolves each pane's session history from the session identifier Herdr reports for that pane, never by scanning agent directories. It supports exactly two agents, both through values Herdr itself reports. Pi panes normally get a session path straight from Herdr, and Herdsman reads that file; when the pi integration cannot read its own session file path it sends an id instead, which Herdsman does not resolve — a pi session file name cannot be derived from its id alone — so such a pane reports no history. Antigravity CLI (`agy`) panes report a conversation id, and because that id names the conversation's own database file, Herdsman resolves it to `<home>/.gemini/antigravity-cli/conversations/<id>.db`, and only for a single exact match. Every other agent reports no history, whether or not Herdr has an integration for it (`herdr integration install <agent>`): Herdsman deliberately does not resolve any other agent's session identifier and never reads any other agent's session store. When the official value cannot be resolved — the agent has no installed integration, an id has no derivation Herdsman can verify, or the file is missing or fails Herdsman's file-safety checks — Herdsman logs one warning and reports the pane without history rather than guessing.
10
10
 
11
11
  ## Development conventions
12
12
 
@@ -130,7 +130,7 @@ Set `filter_upstream_errors: false` to restore waking on every outcome. `HERDSMA
130
130
  Install the optional plugin from the GitHub release tag:
131
131
 
132
132
  ```bash
133
- herdr plugin install dorokuma/herdsman/packages/herdsman-herdr-plugin --ref v0.13.6 --yes
133
+ herdr plugin install dorokuma/herdsman/packages/herdsman-herdr-plugin --ref v0.14.0 --yes
134
134
  ```
135
135
 
136
136
  Use the release tag that matches the installed Herdsman CLI version.
@@ -1,23 +1,59 @@
1
1
  import type { AgentHistoryRef, AgentSessionRef } from "../observability/contracts.js";
2
+ /**
3
+ * Herdsman supports session history for exactly two agents, by decision:
4
+ *
5
+ * 1. `pi` — Herdr's own integration reports the session file itself, so the
6
+ * official `agent_session.kind == "path"` value is used as-is after the
7
+ * file-safety gate (this is the generic path channel, not a pi-only branch).
8
+ * 2. `agy` — Herdr reports only `kind == "id"`, and an agy conversation id is
9
+ * the name of its own conversation database, so the id resolves to exactly
10
+ * one candidate:
11
+ * - `agy` -> `<home>/.gemini/antigravity-cli/conversations/<id>.db`
12
+ *
13
+ * Every other agent — whether or not Herdr has an integration for it — is
14
+ * deliberately not resolved: herdsman does not walk agent directories, rank
15
+ * candidates by mtime/cwd, match role directories from the terminal title, or
16
+ * pick "the newest plausible file". An unresolvable pane is an explicit failure:
17
+ * one `console.warn` naming the official values plus the derived candidate path,
18
+ * then `null`.
19
+ */
2
20
  export declare const ALLOWED_SESSION_ROOTS: readonly ["/tmp/herdr-role-sessions"];
3
- export declare const DISCOVERY_RECENCY_GRACE_MS = 30000;
4
- export declare const FALLBACK_DISCOVERY_RECENCY_GRACE_MS: number;
5
21
  export type AgentHistoryLookupInput = {
6
22
  agent: string | null;
7
23
  agentSession: AgentSessionRef | null;
8
- cwd: string | null;
9
- foregroundCwd: string | null;
10
- firstSeenAtMs?: number;
11
- grokHome?: string;
12
24
  herdrSessionName?: string;
13
25
  homeDir?: string;
14
- occupiedSessionPaths?: ReadonlySet<string>;
15
- terminalTitle?: string | null;
26
+ paneId?: string | null;
16
27
  };
17
- export declare function discoverAgentHistory(input: AgentHistoryLookupInput): Promise<AgentHistoryRef | null>;
28
+ export declare function discoveryLookupKey(input: AgentHistoryLookupInput): string;
29
+ /**
30
+ * True while the very same official values are still inside their retry window,
31
+ * so callers can skip the lookup the pane would otherwise repeat every round.
32
+ */
33
+ export declare function discoveryFailureFresh(input: AgentHistoryLookupInput, now?: number): boolean;
34
+ export declare function discoverAgentHistory(input: AgentHistoryLookupInput, options?: {
35
+ force?: boolean;
36
+ }): Promise<AgentHistoryRef | null>;
37
+ /**
38
+ * Maps an official `agent_session` to the reader that can read it. Only the two
39
+ * supported agents have a reader; everything else is `unknown`, which every
40
+ * reader rejects. `source` looks like `herdr:<agent>`, so segments are matched
41
+ * whole — `herdr:copilot` contains "pi" and must never be read as a pi session.
42
+ */
18
43
  export declare function historySourceFromSessionRef(ref: AgentSessionRef): AgentHistoryRef["source"];
19
44
  export declare function safeAllowedSessionPath(value: string, homeDir?: string): string | null;
20
- export declare function usesShortDiscoveryRecency(input: Pick<AgentHistoryLookupInput, "agent" | "agentSession" | "terminalTitle">): boolean;
21
- export declare function discoveryRecencyGraceMs(input: Pick<AgentHistoryLookupInput, "agent" | "agentSession" | "terminalTitle">): number;
45
+ /**
46
+ * File-safety gate for an official session path reported by Herdr.
47
+ *
48
+ * Herdr only reports back the value an installed agent integration handed it
49
+ * (`pane.report_agent_session`), so the *root* of an official path is not
50
+ * guessed any more and is deliberately not whitelisted: pi keeps its sessions
51
+ * under its own agent home, and a fixed root list would silently reject those
52
+ * official values. What is still enforced is that herdsman only reads a regular,
53
+ * non-symlink file it owns and that no other principal can rewrite behind it.
54
+ * `safeAllowedSessionPath` keeps the root whitelist for the herdsman-pi
55
+ * registration protocol, where a pane claims a path itself.
56
+ */
57
+ export declare function safeOfficialSessionPath(value: string): string | null;
22
58
  export declare function sessionPathAllowedByShape(value: string, homeDir?: string): boolean;
23
59
  //# sourceMappingURL=discovery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/agent-history/discovery.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAerF,eAAO,MAAM,qBAAqB,uCAAwC,CAAC;AAE3E,eAAO,MAAM,0BAA0B,QAAS,CAAC;AACjD,eAAO,MAAM,mCAAmC,QAAc,CAAC;AAC/D,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,YAAY,EAAE,eAAe,GAAG,IAAI,CAAC;IACrC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AASF,wBAAsB,oBAA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