@paigy/harness 0.1.0 → 0.1.3

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 (4) hide show
  1. package/README.md +16 -0
  2. package/dist/cli.js +18633 -49
  3. package/dist/main.js +15 -6
  4. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -12386,15 +12386,17 @@ function optionFor(options, decision) {
12386
12386
  return options.find((o) => o.kind === want)?.optionId ?? null;
12387
12387
  }
12388
12388
  function createAcpDriver(opts) {
12389
- return new AcpDriver(opts.cwd, opts.mode);
12389
+ return new AcpDriver(opts.cwd, opts.mode, opts.mcp ?? []);
12390
12390
  }
12391
12391
  var AcpDriver = class {
12392
- constructor(cwd, mode) {
12392
+ constructor(cwd, mode, mcp = []) {
12393
12393
  this.cwd = cwd;
12394
12394
  this.mode = mode;
12395
+ this.mcp = mcp;
12395
12396
  }
12396
12397
  cwd;
12397
12398
  mode;
12399
+ mcp;
12398
12400
  nextId = 1;
12399
12401
  initId;
12400
12402
  sessionNewId;
@@ -12470,7 +12472,7 @@ var AcpDriver = class {
12470
12472
  this.sessionNewId = this.nextId++;
12471
12473
  return {
12472
12474
  events: [],
12473
- writes: [frame({ id: this.sessionNewId, method: "session/new", params: { cwd: this.cwd, mcpServers: [] } })]
12475
+ writes: [frame({ id: this.sessionNewId, method: "session/new", params: { cwd: this.cwd, mcpServers: this.mcp } })]
12474
12476
  };
12475
12477
  }
12476
12478
  if (msg.id === this.sessionNewId) {
@@ -12619,7 +12621,7 @@ function startSession(opts) {
12619
12621
  opts.onEvent({ kind: "idle", failed: code !== 0, ...code ? { result: `exited ${code}` } : {} });
12620
12622
  });
12621
12623
  child.on("error", (e) => opts.onEvent({ kind: "error", message: e.message }));
12622
- const driver = createAcpDriver({ cwd, mode: opts.mode });
12624
+ const driver = createAcpDriver({ cwd, mode: opts.mode, ...opts.mcp ? { mcp: opts.mcp } : {} });
12623
12625
  let buffer = "";
12624
12626
  child.stdout?.on("data", (chunk) => {
12625
12627
  const { lines, rest } = splitLines(buffer, String(chunk));
@@ -13512,9 +13514,10 @@ async function drainInput(state, deps = {}) {
13512
13514
  return [];
13513
13515
  }
13514
13516
  const ours = (parentId) => state.exclusive || parentId === state.parentId;
13517
+ const claimable = (notificationId) => !state.sharedWithAgent || (state.mine?.has(notificationId) ?? false);
13515
13518
  const mine = [
13516
- ...work.replies.filter((r) => ours(r.parentId)).map((r) => ({ notificationId: r.notificationId, parentId: r.parentId, answer: r.answer })),
13517
- ...work.requests.filter((r) => ours(r.parentId)).map((r) => ({ notificationId: r.notificationId, parentId: r.parentId, answer: { kind: "text", text: r.text } }))
13519
+ ...work.replies.filter((r) => ours(r.parentId) && claimable(r.notificationId)).map((r) => ({ notificationId: r.notificationId, parentId: r.parentId, answer: r.answer })),
13520
+ ...work.requests.filter((r) => ours(r.parentId) && claimable(r.notificationId)).map((r) => ({ notificationId: r.notificationId, parentId: r.parentId, answer: { kind: "text", text: r.text } }))
13518
13521
  ];
13519
13522
  const claimed = [];
13520
13523
  for (const item of mine) {
@@ -13664,6 +13667,7 @@ async function mirror(event, state, deps = {}) {
13664
13667
  try {
13665
13668
  const req = NotifyRequestSchema2.parse(entry);
13666
13669
  const { notificationId, parentId } = await (deps.submit ?? submitNotification)(req);
13670
+ (state.mine ??= /* @__PURE__ */ new Set()).add(notificationId);
13667
13671
  return { parentId, notificationId };
13668
13672
  } catch {
13669
13673
  return {};
@@ -13678,6 +13682,7 @@ async function askPermission(event, state, deps = {}) {
13678
13682
  if (!entry) return { decision: { allow: false, reason: "Could not ask" } };
13679
13683
  try {
13680
13684
  const sent = await (deps.submit ?? submitNotification)(NotifyRequestSchema2.parse(entry));
13685
+ (state.mine ??= /* @__PURE__ */ new Set()).add(sent.notificationId);
13681
13686
  const answer = await awaitAnswer(state, sent.notificationId);
13682
13687
  return { decision: decisionFrom(answer), parentId: sent.parentId };
13683
13688
  } catch (e) {
@@ -13696,6 +13701,7 @@ async function askQuestion(question, state, deps = {}) {
13696
13701
  };
13697
13702
  try {
13698
13703
  const sent = await (deps.submit ?? submitNotification)(NotifyRequestSchema2.parse(entry));
13704
+ (state.mine ??= /* @__PURE__ */ new Set()).add(sent.notificationId);
13699
13705
  return spokenText(await awaitAnswer(state, sent.notificationId));
13700
13706
  } catch {
13701
13707
  return null;
@@ -13773,10 +13779,13 @@ function runHarness(opts) {
13773
13779
  }
13774
13780
  }
13775
13781
  }
13782
+ const paigyMcp = opts.exclusive && opts.token ? [{ name: "paigy", command: "npx", args: ["-y", "@paigy/mcp@latest"], env: { PAIGY_TOKEN: opts.token } }] : void 0;
13783
+ if (paigyMcp) state.sharedWithAgent = true;
13776
13784
  session = startSession({
13777
13785
  harness: opts.harness,
13778
13786
  cwd: opts.cwd,
13779
13787
  mode: opts.mode,
13788
+ ...paigyMcp ? { mcp: paigyMcp } : {},
13780
13789
  ...opts.bin ? { bin: opts.bin } : {},
13781
13790
  onEvent: (event) => void handle(event).catch((err) => opts.log(`\u26A0 ${err.message}`))
13782
13791
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paigy/harness",
3
- "version": "0.1.0",
3
+ "version": "0.1.3",
4
4
  "description": "Run Claude Code / Codex on this machine, bridged to Paigy — launchable from your phone.",
5
5
  "license": "MIT",
6
6
  "type": "module",