@byokit/herdr 0.1.0-next.dbe7142 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,18 +24,36 @@ export function agentRecord(o) {
24
24
  name: o.name,
25
25
  agent: o.kind,
26
26
  display_agent: o.name,
27
+ title: o.name,
27
28
  agent_status: 'idle',
28
29
  interactive_ready: true,
29
30
  launch_pending: false,
30
31
  revision: o.revision,
32
+ terminal_id: `term-${o.paneId}`,
33
+ focused: o.focused ?? false,
31
34
  agent_session: { source: `herdr:${o.kind}`, agent: o.kind, kind: 'id', value: `gen-${o.paneId}` },
32
35
  };
33
36
  }
37
+ export function pluginRecord(o) {
38
+ return {
39
+ plugin_id: o.seed.plugin_id,
40
+ name: o.seed.name ?? o.seed.plugin_id,
41
+ version: o.seed.version ?? '0.0.0',
42
+ manifest_path: `${o.dir}/plugins/${o.seed.plugin_id}/herdr.plugin.json`,
43
+ plugin_root: `${o.dir}/plugins/${o.seed.plugin_id}`,
44
+ enabled: o.seed.enabled ?? true,
45
+ };
46
+ }
47
+ export function paneScroll() {
48
+ return { offset_from_bottom: 0, max_offset_from_bottom: 0, viewport_rows: ROWS };
49
+ }
34
50
  export function createWorld(o) {
35
51
  const workspace = {
36
52
  workspace_id: 'w1',
37
53
  label: o.cwd,
38
54
  focused: true,
55
+ number: 1,
56
+ tokens: {},
39
57
  worktree: {
40
58
  repo_key: 'fake-herdr',
41
59
  repo_name: 'fake-herdr',
@@ -58,6 +76,8 @@ export function createWorld(o) {
58
76
  tokens: {},
59
77
  rect: paneRect(0, 2),
60
78
  text: ['ready.'],
79
+ revision: 0,
80
+ scroll: paneScroll(),
61
81
  };
62
82
  const kind = o.kinds[0] ?? 'pi';
63
83
  const agentPane = {
@@ -69,12 +89,15 @@ export function createWorld(o) {
69
89
  label: kind,
70
90
  terminal_title: `${kind} · ${kind}`,
71
91
  terminal_title_stripped: `${kind} · ${kind}`,
92
+ revision: 0,
93
+ scroll: paneScroll(), // its own scroll: the spread would alias the shell's object
72
94
  };
73
95
  const agent = agentRecord({
74
96
  paneId: agentPane.pane_id, tabId: tab.tab_id, workspaceId: 'w1', cwd: o.cwd,
75
97
  name: kind, kind, revision: 0,
76
98
  });
77
- return { cwd: o.cwd, workspaces: [workspace], tabs: [tab], panes: [shell, agentPane], agents: [agent] };
99
+ const plugins = (o.plugins ?? []).map((seed) => pluginRecord({ dir: o.cwd, seed }));
100
+ return { cwd: o.cwd, workspaces: [workspace], tabs: [tab], panes: [shell, agentPane], agents: [agent], plugins };
78
101
  }
79
102
  export function relayoutTab(world, tabId) {
80
103
  const panes = world.panes.filter((pane) => pane.tab_id === tabId);
@@ -1,4 +1,4 @@
1
- export { startFakeHerdr, type FakeHerdr, type FakeHerdrOptions } from './fake-herdr/server.ts';
1
+ export { startFakeHerdr, type AgentStartFault, type FakeHerdr, type FakeHerdrOptions } from './fake-herdr/server.ts';
2
2
  export { writeBinShim, main as fakeHerdrBinMain } from './fake-herdr/bin.ts';
3
3
  export { createWorld, type FakeWorld } from './fake-herdr/world.ts';
4
- export { herdrContract, type HerdrContractBench } from './contract.ts';
4
+ export { herdrContract, type HerdrContractBench, type HerdrContractOptions, type HerdrContractTestFn, type HerdrContractTestContext } from './contract.ts';
@@ -1,6 +1,15 @@
1
1
  // The kit's fake Herdr and contract suite (docs/runtime-kits.md 6.8). Built in H6; H3/H5 run the
2
2
  // contract against the fake, H9 against the real pinned Herdr. Tests import this by relative path —
3
3
  // the package's public exports stay the kit surface.
4
+ //
5
+ // The fake's documented test handle is `FakeHerdr`: `fake.world` is the LIVE world the server
6
+ // answers from (mutable, with seeded ids from `world.seed`), `fake.emit` routes frames to the
7
+ // sockets watching them (filtered kinds reach only their pane's watchers), `fake.watching()`
8
+ // lists the watched panes, `fake.snapshotCount()` counts `session.snapshot` calls, and the
9
+ // `holdSnapshot`/`failNextSnapshot`/`holdAck`/`failNextAck` hooks script slow or failing answers.
10
+ // The bin shim speaks real terminal frames (`{ type: 'terminal.frame', full, bytes }`, plus a
11
+ // `data` alias) with `terminal.resize`/`terminal.input` on stdin, and `api schema` prints the
12
+ // pinned v0.9.1 snapshot.
4
13
  export { startFakeHerdr } from "./fake-herdr/server.js";
5
14
  export { writeBinShim, main as fakeHerdrBinMain } from "./fake-herdr/bin.js";
6
15
  export { createWorld } from "./fake-herdr/world.js";
package/dist/types.d.ts CHANGED
@@ -2,6 +2,10 @@ export type HerdrState = {
2
2
  phase: 'stopped' | 'connecting' | 'ready' | 'reconnecting' | 'needs-update' | 'missing' | 'failed';
3
3
  why?: 'binary' | 'socket' | 'version' | 'server-exited';
4
4
  };
5
+ export type HerdrProtocolRange = {
6
+ min?: number;
7
+ max?: number;
8
+ };
5
9
  export type HerdrKitOptions = {
6
10
  mode: 'adopt';
7
11
  bin: string;
@@ -9,7 +13,9 @@ export type HerdrKitOptions = {
9
13
  env?: Record<string, string>;
10
14
  path?: string[];
11
15
  transport?: HerdrTransport;
16
+ protocolRange?: HerdrProtocolRange;
12
17
  onState?: (s: HerdrState) => void;
18
+ onLog?: (message: string) => void;
13
19
  } | {
14
20
  mode: 'own';
15
21
  bin: string;
@@ -17,14 +23,21 @@ export type HerdrKitOptions = {
17
23
  env?: Record<string, string>;
18
24
  path?: string[];
19
25
  transport?: HerdrTransport;
26
+ protocolRange?: HerdrProtocolRange;
20
27
  onState?: (s: HerdrState) => void;
28
+ onLog?: (message: string) => void;
29
+ };
30
+ export type HerdrSubscribeStop = (() => void) & {
31
+ ready: Promise<boolean>;
32
+ onReconnect(fn: () => void): void;
33
+ onDisconnect(fn: () => void): void;
21
34
  };
22
35
  export interface HerdrTransport {
23
36
  call(method: string, params: Record<string, unknown>, timeoutMs?: number): Promise<unknown>;
24
37
  subscribe(subs: {
25
38
  type: string;
26
39
  [k: string]: unknown;
27
- }[], on: (e: HerdrEvent) => void, onError: (code: string, message: string) => void): () => void;
40
+ }[], on: (e: HerdrEvent) => void, onError: (code: string, message: string) => void): HerdrSubscribeStop;
28
41
  close(): void;
29
42
  }
30
43
  export type HerdrEvent = {
@@ -56,7 +69,7 @@ export type StartAgent = {
56
69
  pane: string;
57
70
  };
58
71
  worktree?: {
59
- branch: string;
72
+ branch?: string;
60
73
  base?: string;
61
74
  };
62
75
  args?: string[];
@@ -78,28 +91,57 @@ export type BlockedAgent = {
78
91
  prompt: string;
79
92
  since: number;
80
93
  };
94
+ export type AgentSessionRef = {
95
+ source: string;
96
+ agent: string;
97
+ kind: string;
98
+ value: string;
99
+ };
100
+ export type HerdrSnapshotWorktree = {
101
+ repoKey: string;
102
+ repoName: string;
103
+ repoRoot: string;
104
+ checkoutPath: string;
105
+ isLinkedWorktree: boolean;
106
+ };
107
+ export type HerdrSnapshotAgent = {
108
+ kind?: string;
109
+ name?: string;
110
+ displayAgent?: string;
111
+ title?: string;
112
+ status: AgentStatus;
113
+ revision: number;
114
+ launchPending?: boolean;
115
+ interactiveReady?: boolean;
116
+ agentSession?: AgentSessionRef;
117
+ foregroundCwd?: string;
118
+ };
119
+ export type HerdrSnapshotPane = {
120
+ id: string;
121
+ cwd?: string;
122
+ label?: string;
123
+ focused: boolean;
124
+ terminalTitle?: string;
125
+ tokens?: Record<string, string>;
126
+ agent?: HerdrSnapshotAgent;
127
+ };
128
+ export type HerdrSnapshotTab = {
129
+ id: string;
130
+ label: string;
131
+ panes: HerdrSnapshotPane[];
132
+ };
133
+ export type HerdrSnapshotWorkspace = {
134
+ id: string;
135
+ label: string;
136
+ focused: boolean;
137
+ number: number;
138
+ tokens?: Record<string, string>;
139
+ worktree?: HerdrSnapshotWorktree;
140
+ tabs: HerdrSnapshotTab[];
141
+ };
81
142
  export type HerdrSnapshot = {
82
143
  connected: boolean;
83
- workspaces: {
84
- id: string;
85
- label: string;
86
- tabs: {
87
- id: string;
88
- label: string;
89
- panes: {
90
- id: string;
91
- cwd?: string;
92
- agent?: {
93
- kind?: string;
94
- name?: string;
95
- status: AgentStatus;
96
- revision: number;
97
- launchPending?: boolean;
98
- interactiveReady?: boolean;
99
- };
100
- }[];
101
- }[];
102
- }[];
144
+ workspaces: HerdrSnapshotWorkspace[];
103
145
  };
104
146
  export type TerminalSession = {
105
147
  ready: Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byokit/herdr",
3
- "version": "0.1.0-next.dbe7142",
3
+ "version": "0.1.1",
4
4
  "description": "Drive the Herdr on this computer — workspaces, tabs, panes, agents and blocked-approval answers — from an app, or hand it to a phone over @byokit/link.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -17,6 +17,10 @@
17
17
  "types": "./dist/index.d.ts",
18
18
  "default": "./dist/index.js"
19
19
  },
20
+ "./binary": {
21
+ "types": "./dist/binary.d.ts",
22
+ "default": "./dist/binary.js"
23
+ },
20
24
  "./device": {
21
25
  "react-native": {
22
26
  "types": "./dist/device.d.ts",
@@ -48,8 +52,8 @@
48
52
  "prepack": "tsc -b && node ../../scripts/fix-words-dts.cjs"
49
53
  },
50
54
  "dependencies": {
51
- "@byokit/link": "0.3.1",
52
- "@byokit/relay": "0.1.3",
55
+ "@byokit/link": "0.3.2",
56
+ "@byokit/relay": "0.2.0",
53
57
  "@byokit/reach": "0.2.0",
54
58
  "@byokit/seal": "0.1.0",
55
59
  "ws": "8.21.3"