@paigy/harness 0.3.49 → 0.3.51

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/README.md CHANGED
@@ -185,14 +185,32 @@ own `~/.paigy` slot:
185
185
  paigy-harness hatch "Voice bug hunter"
186
186
  ```
187
187
 
188
- To start a HELPER session, use `launch`, not hatch: it picks the helper's own session id, mints
189
- the identity bound to it, places the brief as the helper's first Goal (under `--under GOAL`
190
- when given), and starts the session on it — so every Paigy call the helper makes is its own:
188
+ To start a HELPER session, use `launch`, not hatch. It does not run the session itself: it asks this
189
+ computer's host to (`POST /api/sessions`, the door the phone launches through) and returns as soon as
190
+ the launch is accepted, printing the session id, its name and its brief's Goal. The host mints the
191
+ helper's identity bound to its own session, places the brief as its first Goal (under `--under GOAL`
192
+ when given) and runs it like a phone launch, so it shows on the Agents screen, ends from there and
193
+ outlives the shell that asked. The host must be running (`paigy-harness host`, or the service); if it
194
+ is not, `launch` says so and the session waits until it is.
191
195
 
192
196
  ```sh
193
- paigy-harness launch "Deploy check" --under <goalId> --harness claude "get CI green and merge"
197
+ paigy-harness launch "Deploy check" --under <goalId> --harness claude --cwd ~/projects/paigy "get CI green and merge"
194
198
  ```
195
199
 
200
+ Who may launch (owner, 2026-11-13):
201
+
202
+ - **An agent** (a shell whose process speaks as an agent identity) launches only what the person
203
+ approved: it passes `--approval QUESTION_ID`, the question it asked them about this session, once
204
+ answered. Without it, `launch` refuses before sending anything.
205
+ - **You, at your own computer**, with only its own credential: `launch` asks
206
+ `Start <name> on <harness> in <folder>? [y/N]` and needs a terminal to ask in. That prompt is a
207
+ client-side guard; what bounds the computer's credential is the server's rule that it launches on
208
+ that computer only. With no terminal and no agent identity it refuses, and the app's New session is
209
+ the way.
210
+
211
+ `--cwd` (default: here) must be a folder the host granted, or a repo it advertises inside one; a
212
+ refusal lists what each computer offers.
213
+
196
214
  Hatched agents appear on the phone's Agents screen like any pairing — renameable,
197
215
  re-voiceable, revocable.
198
216
 
@@ -239,7 +257,7 @@ allow-list, a Stop button, and the log.
239
257
 
240
258
  Headless flags: `--harness claude|codex|agy|grok`, `--mode bypass|ask`, `--cwd DIR`,
241
259
  `--grace SECONDS`, `--doctor`; subcommands `host [--grant DIR]…`,
242
- `hatch NAME` and `launch NAME [--under GOAL] BRIEF…`. In ask mode the CLI is TERMINAL-FIRST: a blocked action or open
260
+ `hatch NAME` and `launch NAME [--under GOAL] [--approval QUESTION] BRIEF…` (the host runs it). In ask mode the CLI is TERMINAL-FIRST: a blocked action or open
243
261
  question prints in the terminal and waits `--grace` (default 90s); a person at the
244
262
  keyboard answers in place, an unattended terminal escalates to your phone (0 = phone
245
263
  immediately; non-TTY runs always go straight to the phone).
package/dist/cli.js CHANGED
@@ -27233,9 +27233,9 @@ var coerce = {
27233
27233
  var NEVER = INVALID;
27234
27234
 
27235
27235
  // src/cli-args.ts
27236
- var USAGE = "usage: paigy-harness setup | pair | host [--grant DIR]\u2026 | service | enable-tools [--scope user|project] | hatch NAME [--voice KEY] [--slot SLOT] | launch NAME [--under GOAL] [--voice KEY] [--harness \u2026] [--mode \u2026] [--cwd DIR] BRIEF\u2026 | handoff | [--harness claude|codex|agy|grok] [--mode bypass|ask] [--cwd DIR] [--grace SECONDS] [--doctor] PROMPT\u2026";
27236
+ var USAGE = "usage: paigy-harness setup | pair | host [--grant DIR]\u2026 | service | enable-tools [--scope user|project] | hatch NAME [--voice KEY] [--slot SLOT] | launch NAME [--under GOAL] [--approval QUESTION] [--voice KEY] [--harness \u2026] [--model ID] [--mode \u2026] [--cwd DIR] BRIEF\u2026 | handoff | [--harness claude|codex|agy|grok] [--model ID] [--mode bypass|ask] [--cwd DIR] [--grace SECONDS] [--doctor] PROMPT\u2026";
27237
27237
  function parseArgs(argv) {
27238
- const args = { harness: "claude", mode: "bypass", cwd: process.cwd(), doctor: false, help: false, host: false, pair: false, service: false, setup: false, enableTools: false, scope: "user", grant: [], hatch: null, voice: null, slot: null, launch: null, under: null, graceSeconds: 90, prompt: "", handoff: false };
27238
+ const args = { harness: "claude", mode: "bypass", cwd: process.cwd(), doctor: false, help: false, host: false, pair: false, service: false, setup: false, enableTools: false, scope: "user", grant: [], hatch: null, voice: null, slot: null, launch: null, under: null, approval: null, model: null, graceSeconds: 90, prompt: "", handoff: false };
27239
27239
  const words = [];
27240
27240
  let commandPosition = true;
27241
27241
  for (let i = 0; i < argv.length; i++) {
@@ -27247,6 +27247,10 @@ function parseArgs(argv) {
27247
27247
  const v = next();
27248
27248
  if (v !== "claude" && v !== "codex" && v !== "agy" && v !== "grok") return { error: `--harness must be claude, codex, agy, or grok, got ${v ?? "nothing"}` };
27249
27249
  args.harness = v;
27250
+ } else if (arg === "--model") {
27251
+ const v = next();
27252
+ if (!v || v.startsWith("-")) return { error: "--model needs a model id, as your harness names it" };
27253
+ args.model = v;
27250
27254
  } else if (arg === "--mode") {
27251
27255
  const v = next();
27252
27256
  if (v !== "bypass" && v !== "ask") return { error: `--mode must be bypass or ask, got ${v ?? "nothing"}` };
@@ -27303,6 +27307,10 @@ function parseArgs(argv) {
27303
27307
  const v = next();
27304
27308
  if (!v || !external_exports.string().uuid().safeParse(v).success) return { error: "--under needs a Goal UUID" };
27305
27309
  args.under = v;
27310
+ } else if (arg === "--approval") {
27311
+ const v = next();
27312
+ if (!v || !external_exports.string().uuid().safeParse(v).success) return { error: "--approval needs the answered question's id (its whole UUID)" };
27313
+ args.approval = v;
27306
27314
  } else if (arg?.startsWith("--")) {
27307
27315
  return { error: `unknown flag ${arg}` };
27308
27316
  } else if (arg) {
@@ -27312,6 +27320,7 @@ function parseArgs(argv) {
27312
27320
  args.prompt = words.join(" ");
27313
27321
  if (args.help) return args;
27314
27322
  if (args.under && !args.launch) return { error: "--under requires launch NAME" };
27323
+ if (args.approval && !args.launch) return { error: "--approval requires launch NAME" };
27315
27324
  if (args.launch && !args.prompt) return { error: 'launch needs a brief: paigy-harness launch "Deploy check" "brief"' };
27316
27325
  if (!args.doctor && !args.handoff && !args.hatch && !args.host && !args.pair && !args.service && !args.setup && !args.enableTools && !args.prompt) return { error: "a prompt is required (or setup / --doctor / pair / host / service / enable-tools / hatch NAME / handoff)" };
27317
27326
  return args;
@@ -27361,6 +27370,74 @@ function lineageName(parent, name, max = NAME_MAX) {
27361
27370
  return own.slice(0, max);
27362
27371
  }
27363
27372
 
27373
+ // src/launch.ts
27374
+ async function launchViaHost(args, deps) {
27375
+ const asAgent = !!deps.agentToken;
27376
+ const name = lineageName(asAgent ? deps.parentName : null, args.launch);
27377
+ const spec = {
27378
+ name,
27379
+ harness: args.harness,
27380
+ brief: args.prompt,
27381
+ workspace: args.cwd,
27382
+ mode: args.mode,
27383
+ ...args.model ? { model: args.model } : {},
27384
+ ...args.under ? { parentGoalId: args.under } : {},
27385
+ ...deps.deviceTokenId ? { hostTokenId: deps.deviceTokenId } : {}
27386
+ };
27387
+ let token;
27388
+ let input;
27389
+ if (asAgent) {
27390
+ if (!args.approval) {
27391
+ deps.error(`\u270B ${name} was not launched: an agent launches only a session the person approved.`);
27392
+ deps.error(" Ask them first: one question, on the Goal it is for, naming the session, its role, model and mode.");
27393
+ deps.error(" Once they answer, launch again with that question's id: --approval QUESTION_ID");
27394
+ return 1;
27395
+ }
27396
+ token = deps.agentToken;
27397
+ input = { ...spec, approvalQuestionId: args.approval };
27398
+ } else {
27399
+ if (!deps.deviceToken) {
27400
+ deps.error(`\u270B ${name} was not launched: this computer is not connected to Paigy. Connect it with: paigy-harness pair`);
27401
+ return 1;
27402
+ }
27403
+ if (!deps.isTTY) {
27404
+ deps.error(`\u270B ${name} was not launched: there is no agent identity here and nobody at a terminal to confirm it.`);
27405
+ deps.error(" Start it from the app instead: Agents \u2192 New session.");
27406
+ return 1;
27407
+ }
27408
+ if (args.approval) deps.log(" (--approval is for an agent's launch; at your own computer you confirm it here instead)");
27409
+ if (!await deps.confirm(`Start ${name} on ${args.harness} in ${args.cwd}? [y/N] `)) {
27410
+ deps.error(`\u270B ${name} was not launched.`);
27411
+ return 1;
27412
+ }
27413
+ token = deps.deviceToken;
27414
+ input = spec;
27415
+ }
27416
+ let launched;
27417
+ try {
27418
+ launched = await deps.launch(input, { token });
27419
+ } catch (e) {
27420
+ const body = e.body ?? {};
27421
+ deps.error(`\u270B ${name} was not launched: ${typeof body.error === "string" ? body.error : e.message}${typeof body.why === "string" ? ` (${body.why})` : ""}`);
27422
+ if (typeof body.message === "string") deps.error(` ${body.message}`);
27423
+ for (const offer of body.offers ?? []) {
27424
+ deps.error(` ${offer.name ?? "a computer"}: ${(offer.harnesses ?? []).join(", ") || "no harness ready"} in ${[...offer.workspaces ?? [], ...offer.repos ?? []].join(", ") || "no granted folder"}`);
27425
+ }
27426
+ return 1;
27427
+ }
27428
+ const goal = launched.placed?.goalId;
27429
+ deps.log(`\u2713 launched "${launched.name ?? name}"${launched.name ? "" : " (unnamed: you already have an agent with that name)"} \u2014 session ${launched.sessionId}${goal ? `, its brief is Goal ${goal}` : ""}.`);
27430
+ if (launched.hostLive === false) {
27431
+ deps.log(" \u26A0 This computer's Paigy host is not running, so the session waits until it is. Start it with:");
27432
+ deps.log(" paigy-harness host (or keep it running as a service: paigy-harness service)");
27433
+ } else if (launched.hostLive === true) {
27434
+ deps.log(" The host runs it; it shows on your phone's Agents screen and ends from there.");
27435
+ } else {
27436
+ deps.log(" The host runs it once it claims it (Paigy could not tell whether the host is running).");
27437
+ }
27438
+ return 0;
27439
+ }
27440
+
27364
27441
  // ../../packages/sdk/dist/index.js
27365
27442
  import { createRequire as __sdkCreateRequire } from "module";
27366
27443
  import { execFileSync } from "child_process";
@@ -29233,6 +29310,20 @@ var SendFeedbackSchema = external_exports.object({
29233
29310
  kind: external_exports.enum(["bug", "idea", "other"]).default("other").describe("bug: something Paigy does wrong. idea: something it should do. other: anything else.")
29234
29311
  }).strict();
29235
29312
  var SEND_FEEDBACK_DESCRIPTION = "Send feedback about Paigy itself (a bug report, an idea) straight to the Paigy team. Send it only when the person asked you to, or agreed when you offered: it goes to Paigy, never to the person, and nobody answers it here. Not for your work or a question for the person: use contact for those. Returns whether it was stored.";
29313
+ var LAUNCH_HARNESSES = ["claude", "codex", "grok", "agy"];
29314
+ var LaunchToolSchema = external_exports.object({
29315
+ name: external_exports.string().trim().min(1).max(60).describe("The session's role name, as the person will see it."),
29316
+ harness: external_exports.enum(LAUNCH_HARNESSES).describe("What runs it."),
29317
+ brief: goalOutcome.describe(`The session's first Goal: what to do, one paragraph of at most ${GOAL_OUTCOME_MAX} characters.`),
29318
+ approvalQuestionId: external_exports.string().uuid().describe("The questionId (the whole UUID) of the question you asked the person that names this session, once they answered it: a board card's, or one you ask first."),
29319
+ workspace: external_exports.string().trim().min(1).optional().describe("A folder the host granted. Name it or repo."),
29320
+ repo: external_exports.string().trim().min(1).max(200).optional().describe("The repo the work is in (owner/name); the session opens in it."),
29321
+ model: external_exports.string().trim().min(1).max(100).optional().describe("The model the card approved, passed to the harness."),
29322
+ mode: external_exports.enum(["ask", "bypass"]).optional().describe("bypass (default): every tool call allowed. ask: each blocked action goes to the person's phone."),
29323
+ parentGoalId: external_exports.string().uuid().optional().describe("The Goal the brief goes under, such as the Team project."),
29324
+ hostTokenId: external_exports.string().uuid().optional().describe("The computer to run it on. Omitted: the live host that offers it.")
29325
+ }).strict();
29326
+ var LAUNCH_DESCRIPTION = "Start a new agent session on one of your person's computers: their host runs it as it runs a launch from their phone. Only what the person approved: a board card they answered, or else ask them first, one question on the Goal it is for naming the session, its role, model and mode; pass that question's questionId as approvalQuestionId. brief becomes the session's first Goal, under parentGoalId when given. Name a workspace the host granted or the repo. mode is bypass unless ask. A refusal says why. Returns sessionId, the agent, the brief's goalId and next.";
29236
29327
  var AGENT_TOOLS = [
29237
29328
  { name: "configure", title: "Who am I", annotations: READS, description: CONFIGURE_IDENTITY_DESCRIPTION, inputSchema: mcpInputSchema(ConfigureIdentitySchema) },
29238
29329
  { name: "contact", title: "Contact the person", annotations: SENDS, description: CONTACT_DESCRIPTION, inputSchema: CONTACT_SCHEMA },
@@ -29242,6 +29333,7 @@ var AGENT_TOOLS = [
29242
29333
  { name: "search", title: "Search history", annotations: READS, description: SEARCH_DESCRIPTION, inputSchema: mcpInputSchema(SearchToolSchema) },
29243
29334
  { name: "check_activity", title: "Recent agent activity", annotations: READS, description: "Read your person's agents that contributed in the last 24 hours, newest first: at most 30 agents and their five most recently touched Goals, with their latest entry headline and time. Use get_goals to read a Goal and its other contributors before starting overlapping work. Read-only; no arguments.", inputSchema: mcpInputSchema(CheckActivitySchema) },
29244
29335
  { name: "send_feedback", title: "Send feedback to Paigy", annotations: SENDS, description: SEND_FEEDBACK_DESCRIPTION, inputSchema: mcpInputSchema(SendFeedbackSchema) },
29336
+ { name: "launch", title: "Launch a session", annotations: SENDS, description: LAUNCH_DESCRIPTION, inputSchema: mcpInputSchema(LaunchToolSchema) },
29245
29337
  // THE GUIDE FROM INSIDE THE MCP (owner, 2026-10-27): the skill's text, needing no identity (`help.ts`).
29246
29338
  { name: "help", title: "Paigy guide", annotations: READS, description: HELP_DESCRIPTION, inputSchema: mcpInputSchema(HelpSchema) }
29247
29339
  ];
@@ -30703,6 +30795,9 @@ var DeviceTokenSchema = external_exports.object({
30703
30795
  /** Local host recovery must preserve the launch's runtime and Paigy identity. */
30704
30796
  harness: external_exports.enum(["claude", "codex", "agy", "grok"]).optional(),
30705
30797
  session_id: external_exports.string().uuid().optional(),
30798
+ /** How the launch asked for it to run (`GET /api/sessions/claim` `mode`), so every wake of this slot
30799
+ * runs it the same way. Absent is bypass (owner, 2026-11-13), as every slot written before it. */
30800
+ mode: external_exports.enum(["ask", "bypass"]).optional(),
30706
30801
  /** A conversation the host must not resume: its context is full, so every turn fails
30707
30802
  * ("Prompt is too long"). Written when a run hits it (`run.ts` `onFull`); the host skips a slot
30708
30803
  * whose resumable session is this one, so its Goals reach the dead-agent handoff instead of a
@@ -31015,7 +31110,7 @@ function updateSlot(agent2, patch) {
31015
31110
  }
31016
31111
  function slotIdentity(agent2) {
31017
31112
  const t = readTokenFile()[agent2];
31018
- return { name: t?.name ?? null, voice: t?.voice ?? null, tokenId: t?.token_id ?? null, workspace: t?.workspace ?? null, harness: t?.harness ?? null, sessionId: t?.session_id ?? null, fullSession: t?.full_session ?? null };
31113
+ return { name: t?.name ?? null, voice: t?.voice ?? null, tokenId: t?.token_id ?? null, workspace: t?.workspace ?? null, harness: t?.harness ?? null, sessionId: t?.session_id ?? null, fullSession: t?.full_session ?? null, mode: t?.mode ?? null };
31019
31114
  }
31020
31115
  var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
31021
31116
  function readToken(agent2 = agentName()) {
@@ -31134,16 +31229,11 @@ async function getGoals(goalIds, opts = {}, read3 = {}) {
31134
31229
  return (await res.json()).goals;
31135
31230
  }
31136
31231
  var AWAIT_WINDOW_MS = 45e3;
31137
- async function hatch(name, voice = null, opts = {}) {
31138
- const res = await ensureAuthed(await (opts.reach ?? reach)(`${BACKEND_URL}/api/hatch`, {
31232
+ async function hatch(name, voice = null) {
31233
+ const res = await ensureAuthed(await reach(`${BACKEND_URL}/api/hatch`, {
31139
31234
  method: "POST",
31140
31235
  headers: { "content-type": "application/json", authorization: `Bearer ${authToken()}` },
31141
- body: JSON.stringify({
31142
- name,
31143
- voice,
31144
- ...opts.brief ? { brief: opts.brief } : {},
31145
- ...opts.parentGoalId ? { parentGoalId: opts.parentGoalId } : {}
31146
- })
31236
+ body: JSON.stringify({ name, voice })
31147
31237
  }));
31148
31238
  if (!res.ok) throw new Error(`hatch failed: ${res.status} ${await res.text()}`);
31149
31239
  return await res.json();
@@ -31162,6 +31252,16 @@ async function readIdentity(opts = {}) {
31162
31252
  if (!res.ok) await fail("read_identity", res);
31163
31253
  return await res.json();
31164
31254
  }
31255
+ async function launchSession(input, opts = {}) {
31256
+ const { brief, ...rest } = input;
31257
+ const res = await ensureAuthed(await (opts.reach ?? reach)(`${BACKEND_URL}/api/sessions`, {
31258
+ method: "POST",
31259
+ headers: { "content-type": "application/json", authorization: `Bearer ${authToken(opts.token) ?? ""}` },
31260
+ body: JSON.stringify({ ...rest, prompt: brief })
31261
+ }));
31262
+ if (!res.ok) await fail("launch", res);
31263
+ return await res.json();
31264
+ }
31165
31265
  async function claimSessions(opts = {}) {
31166
31266
  const res = await ensureAuthed(await reach(`${BACKEND_URL}/api/sessions/claim`, {
31167
31267
  headers: { authorization: `Bearer ${authToken(opts.token)}` }
@@ -31517,7 +31617,6 @@ ${block2}`;
31517
31617
 
31518
31618
  // src/cli.ts
31519
31619
  var import_qrcode = __toESM(require_lib(), 1);
31520
- import { randomUUID as randomUUID5 } from "crypto";
31521
31620
  import { hostname } from "os";
31522
31621
  import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "fs";
31523
31622
  import { execFile as execFile2, execSync as execSync2 } from "child_process";
@@ -33867,6 +33966,20 @@ var SendFeedbackSchema2 = external_exports.object({
33867
33966
  kind: external_exports.enum(["bug", "idea", "other"]).default("other").describe("bug: something Paigy does wrong. idea: something it should do. other: anything else.")
33868
33967
  }).strict();
33869
33968
  var SEND_FEEDBACK_DESCRIPTION2 = "Send feedback about Paigy itself (a bug report, an idea) straight to the Paigy team. Send it only when the person asked you to, or agreed when you offered: it goes to Paigy, never to the person, and nobody answers it here. Not for your work or a question for the person: use contact for those. Returns whether it was stored.";
33969
+ var LAUNCH_HARNESSES2 = ["claude", "codex", "grok", "agy"];
33970
+ var LaunchToolSchema2 = external_exports.object({
33971
+ name: external_exports.string().trim().min(1).max(60).describe("The session's role name, as the person will see it."),
33972
+ harness: external_exports.enum(LAUNCH_HARNESSES2).describe("What runs it."),
33973
+ brief: goalOutcome2.describe(`The session's first Goal: what to do, one paragraph of at most ${GOAL_OUTCOME_MAX2} characters.`),
33974
+ approvalQuestionId: external_exports.string().uuid().describe("The questionId (the whole UUID) of the question you asked the person that names this session, once they answered it: a board card's, or one you ask first."),
33975
+ workspace: external_exports.string().trim().min(1).optional().describe("A folder the host granted. Name it or repo."),
33976
+ repo: external_exports.string().trim().min(1).max(200).optional().describe("The repo the work is in (owner/name); the session opens in it."),
33977
+ model: external_exports.string().trim().min(1).max(100).optional().describe("The model the card approved, passed to the harness."),
33978
+ mode: external_exports.enum(["ask", "bypass"]).optional().describe("bypass (default): every tool call allowed. ask: each blocked action goes to the person's phone."),
33979
+ parentGoalId: external_exports.string().uuid().optional().describe("The Goal the brief goes under, such as the Team project."),
33980
+ hostTokenId: external_exports.string().uuid().optional().describe("The computer to run it on. Omitted: the live host that offers it.")
33981
+ }).strict();
33982
+ var LAUNCH_DESCRIPTION2 = "Start a new agent session on one of your person's computers: their host runs it as it runs a launch from their phone. Only what the person approved: a board card they answered, or else ask them first, one question on the Goal it is for naming the session, its role, model and mode; pass that question's questionId as approvalQuestionId. brief becomes the session's first Goal, under parentGoalId when given. Name a workspace the host granted or the repo. mode is bypass unless ask. A refusal says why. Returns sessionId, the agent, the brief's goalId and next.";
33870
33983
  var AGENT_TOOLS2 = [
33871
33984
  { name: "configure", title: "Who am I", annotations: READS2, description: CONFIGURE_IDENTITY_DESCRIPTION2, inputSchema: mcpInputSchema2(ConfigureIdentitySchema2) },
33872
33985
  { name: "contact", title: "Contact the person", annotations: SENDS2, description: CONTACT_DESCRIPTION2, inputSchema: CONTACT_SCHEMA2 },
@@ -33876,6 +33989,7 @@ var AGENT_TOOLS2 = [
33876
33989
  { name: "search", title: "Search history", annotations: READS2, description: SEARCH_DESCRIPTION2, inputSchema: mcpInputSchema2(SearchToolSchema2) },
33877
33990
  { name: "check_activity", title: "Recent agent activity", annotations: READS2, description: "Read your person's agents that contributed in the last 24 hours, newest first: at most 30 agents and their five most recently touched Goals, with their latest entry headline and time. Use get_goals to read a Goal and its other contributors before starting overlapping work. Read-only; no arguments.", inputSchema: mcpInputSchema2(CheckActivitySchema2) },
33878
33991
  { name: "send_feedback", title: "Send feedback to Paigy", annotations: SENDS2, description: SEND_FEEDBACK_DESCRIPTION2, inputSchema: mcpInputSchema2(SendFeedbackSchema2) },
33992
+ { name: "launch", title: "Launch a session", annotations: SENDS2, description: LAUNCH_DESCRIPTION2, inputSchema: mcpInputSchema2(LaunchToolSchema2) },
33879
33993
  // THE GUIDE FROM INSIDE THE MCP (owner, 2026-10-27): the skill's text, needing no identity (`help.ts`).
33880
33994
  { name: "help", title: "Paigy guide", annotations: READS2, description: HELP_DESCRIPTION2, inputSchema: mcpInputSchema2(HelpSchema2) }
33881
33995
  ];
@@ -35346,6 +35460,9 @@ var DeviceTokenSchema2 = external_exports.object({
35346
35460
  /** Local host recovery must preserve the launch's runtime and Paigy identity. */
35347
35461
  harness: external_exports.enum(["claude", "codex", "agy", "grok"]).optional(),
35348
35462
  session_id: external_exports.string().uuid().optional(),
35463
+ /** How the launch asked for it to run (`GET /api/sessions/claim` `mode`), so every wake of this slot
35464
+ * runs it the same way. Absent is bypass (owner, 2026-11-13), as every slot written before it. */
35465
+ mode: external_exports.enum(["ask", "bypass"]).optional(),
35349
35466
  /** A conversation the host must not resume: its context is full, so every turn fails
35350
35467
  * ("Prompt is too long"). Written when a run hits it (`run.ts` `onFull`); the host skips a slot
35351
35468
  * whose resumable session is this one, so its Goals reach the dead-agent handoff instead of a
@@ -36437,6 +36554,7 @@ ${event.message}`, state, rail, { log: opts.log });
36437
36554
  ...opts.token ? { token: opts.token } : {},
36438
36555
  ...opts.resume ? { resume: opts.resume } : {},
36439
36556
  ...opts.session ? { session: opts.session } : {},
36557
+ ...opts.model ? { model: opts.model } : {},
36440
36558
  ...opts.bin ? { bin: opts.bin } : {},
36441
36559
  ...inbox ? { inbox: inbox.dir } : {},
36442
36560
  onExit: () => {
@@ -36895,6 +37013,7 @@ var claimedRun = (sessionId2) => {
36895
37013
  return { slot, key: runKey(slot) };
36896
37014
  };
36897
37015
  var launchRun = (spec) => ({ session: spec.sessionId, model: spec.model });
37016
+ var launchMode = (mode) => mode === "ask" ? "ask" : "bypass";
36898
37017
  var BOUND_ELSEWHERE_MS = 10 * 6e4;
36899
37018
  var boundElsewhere = /* @__PURE__ */ new Map();
36900
37019
  var BOUND_SKIP = "is bound to the session it was paired in, which this host cannot name \u2014 run `paigy-harness handoff` as it, in its folder, to record it";
@@ -37035,7 +37154,8 @@ function startHost(opts) {
37035
37154
  device: null,
37036
37155
  workspace: spec.workspace,
37037
37156
  harness: spec.harness,
37038
- session_id: spec.sessionId
37157
+ session_id: spec.sessionId,
37158
+ mode: launchMode(spec.mode)
37039
37159
  }, slot);
37040
37160
  } catch {
37041
37161
  log("Cannot persist launch identity/runtime; session was not started. Check local storage and relaunch.");
@@ -37044,7 +37164,7 @@ function startHost(opts) {
37044
37164
  const run = runHarness({
37045
37165
  harness: spec.harness,
37046
37166
  cwd: workspace,
37047
- mode: "bypass",
37167
+ mode: launchMode(spec.mode),
37048
37168
  prompt: "",
37049
37169
  token: spec.token,
37050
37170
  ...launchRun(spec),
@@ -37063,7 +37183,7 @@ function startHost(opts) {
37063
37183
  void heartbeat(void 0, { token: spec.token }).catch(() => {
37064
37184
  });
37065
37185
  void refreshIdentities();
37066
- opts.log(`\u25B6 phone-launched ${label} (${spec.harness}) in ${spec.workspace}`);
37186
+ opts.log(`\u25B6 launched ${label} (${spec.harness}, ${launchMode(spec.mode)}) in ${spec.workspace}`);
37067
37187
  }
37068
37188
  const ends = await claimSessionEnds(asHost).catch(() => []);
37069
37189
  for (const end of ends) {
@@ -37210,9 +37330,10 @@ function startHost(opts) {
37210
37330
  }
37211
37331
  const log = (line) => opts.log(`[${label}] ${line}`);
37212
37332
  const run = runHarness({
37333
+ // A wake runs the session the way its launch asked (the slot keeps it), bypass when it named none.
37213
37334
  harness,
37214
37335
  cwd: workspace,
37215
- mode: "bypass",
37336
+ mode: launchMode(identity.mode),
37216
37337
  prompt: "",
37217
37338
  token,
37218
37339
  ...identity.sessionId ? { session: identity.sessionId } : {},
@@ -37494,7 +37615,7 @@ async function main() {
37494
37615
  console.log(" service install the host as a login service (macOS)");
37495
37616
  console.log(" enable-tools allowlist Paigy's tools in Claude Code so they don't prompt each time");
37496
37617
  console.log(" hatch NAME mint a sibling identity from this machine's credential");
37497
- console.log(' launch NAME "brief" start a helper session with its own identity and its brief as its first Goal [--under GOAL]');
37618
+ console.log(` launch NAME "brief" ask this computer's host to run a helper session, its brief as its first Goal [--under GOAL] [--approval QUESTION]`);
37498
37619
  console.log(" handoff pin this terminal's identity here so your phone can resume it");
37499
37620
  console.log(" --doctor report which agent CLIs are installed and ready");
37500
37621
  console.log("");
@@ -37710,29 +37831,36 @@ async function main() {
37710
37831
  });
37711
37832
  return;
37712
37833
  }
37834
+ if (parsed.launch) {
37835
+ const device = readSlot("Desktop") || null;
37836
+ const own = readToken() || null;
37837
+ const code = await launchViaHost({ ...parsed, launch: parsed.launch }, {
37838
+ agentToken: own && own !== device ? own : null,
37839
+ parentName: slotName(agentName()),
37840
+ deviceToken: device,
37841
+ deviceTokenId: slotIdentity("Desktop").tokenId,
37842
+ isTTY: !!process.stdin.isTTY && !!process.stdout.isTTY,
37843
+ confirm: async (question) => {
37844
+ const readline = await import("readline/promises");
37845
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
37846
+ try {
37847
+ return /^\s*y(es)?\s*$/i.test(await rl.question(question));
37848
+ } finally {
37849
+ rl.close();
37850
+ }
37851
+ },
37852
+ launch: launchSession,
37853
+ log: (line) => console.log(line),
37854
+ error: (line) => console.error(line)
37855
+ });
37856
+ process.exit(code);
37857
+ }
37713
37858
  const state = detectAll().find((a) => a.name === parsed.harness);
37714
37859
  if (state && state.status !== "ready") {
37715
37860
  const hint = state.hint ?? "setup incomplete";
37716
37861
  console.error(`\u270B ${state.label}: ${hint}`);
37717
37862
  process.exit(1);
37718
37863
  }
37719
- let launched;
37720
- if (parsed.launch) {
37721
- const parent = slotName(agentName());
37722
- const name = lineageName(parent, parsed.launch);
37723
- overrideToken(readSlot("Desktop") || null);
37724
- const session = randomUUID5();
37725
- const minted = await hatch(name, parsed.voice ?? null, {
37726
- reach: reachAs(session),
37727
- brief: parsed.prompt,
37728
- ...parsed.under ? { parentGoalId: parsed.under } : {}
37729
- }).catch((e) => {
37730
- console.error(`\u270B the helper was not launched: ${e.message}`);
37731
- process.exit(1);
37732
- }).finally(() => overrideToken(null));
37733
- launched = { token: minted.token, session, ...minted.goalId ? { goalId: minted.goalId } : {} };
37734
- console.log(`\u2713 launched "${minted.name ?? name}"${minted.name ? "" : " (unnamed: you already have an agent with that name)"}, on its own session; its Goal is ${minted.goalId ?? "missing"}`);
37735
- }
37736
37864
  const askTerminal = async (promptText) => {
37737
37865
  if (parsed.graceSeconds <= 0 || !process.stdin.isTTY) return null;
37738
37866
  const readline = await import("readline/promises");
@@ -37753,10 +37881,9 @@ async function main() {
37753
37881
  harness: parsed.harness,
37754
37882
  cwd: parsed.cwd,
37755
37883
  mode: parsed.mode,
37756
- // hatch already admitted this brief; the pump must not admit it again after completion.
37757
- prompt: launched ? "" : parsed.prompt,
37884
+ ...parsed.model ? { model: parsed.model } : {},
37885
+ prompt: parsed.prompt,
37758
37886
  ...state?.bin ? { bin: state.bin } : {},
37759
- ...launched ? { token: launched.token, session: launched.session } : {},
37760
37887
  localAsk: {
37761
37888
  permission: async (summary) => {
37762
37889
  const said = await askTerminal(`\u23F8 blocked: ${summary} \u2014 allow? [y/n]`);
@@ -37768,7 +37895,7 @@ async function main() {
37768
37895
  });
37769
37896
  const beat2 = async () => {
37770
37897
  try {
37771
- await heartbeat(void 0, launched ? { token: launched.token } : {});
37898
+ await heartbeat();
37772
37899
  signedOut = false;
37773
37900
  } catch (e) {
37774
37901
  if (!isUnauthorized(e) || signedOut) return;
package/dist/main.js CHANGED
@@ -10494,6 +10494,20 @@ var SendFeedbackSchema = external_exports.object({
10494
10494
  kind: external_exports.enum(["bug", "idea", "other"]).default("other").describe("bug: something Paigy does wrong. idea: something it should do. other: anything else.")
10495
10495
  }).strict();
10496
10496
  var SEND_FEEDBACK_DESCRIPTION = "Send feedback about Paigy itself (a bug report, an idea) straight to the Paigy team. Send it only when the person asked you to, or agreed when you offered: it goes to Paigy, never to the person, and nobody answers it here. Not for your work or a question for the person: use contact for those. Returns whether it was stored.";
10497
+ var LAUNCH_HARNESSES = ["claude", "codex", "grok", "agy"];
10498
+ var LaunchToolSchema = external_exports.object({
10499
+ name: external_exports.string().trim().min(1).max(60).describe("The session's role name, as the person will see it."),
10500
+ harness: external_exports.enum(LAUNCH_HARNESSES).describe("What runs it."),
10501
+ brief: goalOutcome.describe(`The session's first Goal: what to do, one paragraph of at most ${GOAL_OUTCOME_MAX} characters.`),
10502
+ approvalQuestionId: external_exports.string().uuid().describe("The questionId (the whole UUID) of the question you asked the person that names this session, once they answered it: a board card's, or one you ask first."),
10503
+ workspace: external_exports.string().trim().min(1).optional().describe("A folder the host granted. Name it or repo."),
10504
+ repo: external_exports.string().trim().min(1).max(200).optional().describe("The repo the work is in (owner/name); the session opens in it."),
10505
+ model: external_exports.string().trim().min(1).max(100).optional().describe("The model the card approved, passed to the harness."),
10506
+ mode: external_exports.enum(["ask", "bypass"]).optional().describe("bypass (default): every tool call allowed. ask: each blocked action goes to the person's phone."),
10507
+ parentGoalId: external_exports.string().uuid().optional().describe("The Goal the brief goes under, such as the Team project."),
10508
+ hostTokenId: external_exports.string().uuid().optional().describe("The computer to run it on. Omitted: the live host that offers it.")
10509
+ }).strict();
10510
+ var LAUNCH_DESCRIPTION = "Start a new agent session on one of your person's computers: their host runs it as it runs a launch from their phone. Only what the person approved: a board card they answered, or else ask them first, one question on the Goal it is for naming the session, its role, model and mode; pass that question's questionId as approvalQuestionId. brief becomes the session's first Goal, under parentGoalId when given. Name a workspace the host granted or the repo. mode is bypass unless ask. A refusal says why. Returns sessionId, the agent, the brief's goalId and next.";
10497
10511
  var AGENT_TOOLS = [
10498
10512
  { name: "configure", title: "Who am I", annotations: READS, description: CONFIGURE_IDENTITY_DESCRIPTION, inputSchema: mcpInputSchema(ConfigureIdentitySchema) },
10499
10513
  { name: "contact", title: "Contact the person", annotations: SENDS, description: CONTACT_DESCRIPTION, inputSchema: CONTACT_SCHEMA },
@@ -10503,6 +10517,7 @@ var AGENT_TOOLS = [
10503
10517
  { name: "search", title: "Search history", annotations: READS, description: SEARCH_DESCRIPTION, inputSchema: mcpInputSchema(SearchToolSchema) },
10504
10518
  { name: "check_activity", title: "Recent agent activity", annotations: READS, description: "Read your person's agents that contributed in the last 24 hours, newest first: at most 30 agents and their five most recently touched Goals, with their latest entry headline and time. Use get_goals to read a Goal and its other contributors before starting overlapping work. Read-only; no arguments.", inputSchema: mcpInputSchema(CheckActivitySchema) },
10505
10519
  { name: "send_feedback", title: "Send feedback to Paigy", annotations: SENDS, description: SEND_FEEDBACK_DESCRIPTION, inputSchema: mcpInputSchema(SendFeedbackSchema) },
10520
+ { name: "launch", title: "Launch a session", annotations: SENDS, description: LAUNCH_DESCRIPTION, inputSchema: mcpInputSchema(LaunchToolSchema) },
10506
10521
  // THE GUIDE FROM INSIDE THE MCP (owner, 2026-10-27): the skill's text, needing no identity (`help.ts`).
10507
10522
  { name: "help", title: "Paigy guide", annotations: READS, description: HELP_DESCRIPTION, inputSchema: mcpInputSchema(HelpSchema) }
10508
10523
  ];
@@ -11964,6 +11979,9 @@ var DeviceTokenSchema = external_exports.object({
11964
11979
  /** Local host recovery must preserve the launch's runtime and Paigy identity. */
11965
11980
  harness: external_exports.enum(["claude", "codex", "agy", "grok"]).optional(),
11966
11981
  session_id: external_exports.string().uuid().optional(),
11982
+ /** How the launch asked for it to run (`GET /api/sessions/claim` `mode`), so every wake of this slot
11983
+ * runs it the same way. Absent is bypass (owner, 2026-11-13), as every slot written before it. */
11984
+ mode: external_exports.enum(["ask", "bypass"]).optional(),
11967
11985
  /** A conversation the host must not resume: its context is full, so every turn fails
11968
11986
  * ("Prompt is too long"). Written when a run hits it (`run.ts` `onFull`); the host skips a slot
11969
11987
  * whose resumable session is this one, so its Goals reach the dead-agent handoff instead of a
@@ -12276,7 +12294,7 @@ function updateSlot(agent2, patch) {
12276
12294
  }
12277
12295
  function slotIdentity(agent2) {
12278
12296
  const t = readTokenFile()[agent2];
12279
- return { name: t?.name ?? null, voice: t?.voice ?? null, tokenId: t?.token_id ?? null, workspace: t?.workspace ?? null, harness: t?.harness ?? null, sessionId: t?.session_id ?? null, fullSession: t?.full_session ?? null };
12297
+ return { name: t?.name ?? null, voice: t?.voice ?? null, tokenId: t?.token_id ?? null, workspace: t?.workspace ?? null, harness: t?.harness ?? null, sessionId: t?.session_id ?? null, fullSession: t?.full_session ?? null, mode: t?.mode ?? null };
12280
12298
  }
12281
12299
  var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
12282
12300
  function readToken(agent2 = agentName()) {
@@ -14644,6 +14662,20 @@ var SendFeedbackSchema2 = external_exports.object({
14644
14662
  kind: external_exports.enum(["bug", "idea", "other"]).default("other").describe("bug: something Paigy does wrong. idea: something it should do. other: anything else.")
14645
14663
  }).strict();
14646
14664
  var SEND_FEEDBACK_DESCRIPTION2 = "Send feedback about Paigy itself (a bug report, an idea) straight to the Paigy team. Send it only when the person asked you to, or agreed when you offered: it goes to Paigy, never to the person, and nobody answers it here. Not for your work or a question for the person: use contact for those. Returns whether it was stored.";
14665
+ var LAUNCH_HARNESSES2 = ["claude", "codex", "grok", "agy"];
14666
+ var LaunchToolSchema2 = external_exports.object({
14667
+ name: external_exports.string().trim().min(1).max(60).describe("The session's role name, as the person will see it."),
14668
+ harness: external_exports.enum(LAUNCH_HARNESSES2).describe("What runs it."),
14669
+ brief: goalOutcome2.describe(`The session's first Goal: what to do, one paragraph of at most ${GOAL_OUTCOME_MAX2} characters.`),
14670
+ approvalQuestionId: external_exports.string().uuid().describe("The questionId (the whole UUID) of the question you asked the person that names this session, once they answered it: a board card's, or one you ask first."),
14671
+ workspace: external_exports.string().trim().min(1).optional().describe("A folder the host granted. Name it or repo."),
14672
+ repo: external_exports.string().trim().min(1).max(200).optional().describe("The repo the work is in (owner/name); the session opens in it."),
14673
+ model: external_exports.string().trim().min(1).max(100).optional().describe("The model the card approved, passed to the harness."),
14674
+ mode: external_exports.enum(["ask", "bypass"]).optional().describe("bypass (default): every tool call allowed. ask: each blocked action goes to the person's phone."),
14675
+ parentGoalId: external_exports.string().uuid().optional().describe("The Goal the brief goes under, such as the Team project."),
14676
+ hostTokenId: external_exports.string().uuid().optional().describe("The computer to run it on. Omitted: the live host that offers it.")
14677
+ }).strict();
14678
+ var LAUNCH_DESCRIPTION2 = "Start a new agent session on one of your person's computers: their host runs it as it runs a launch from their phone. Only what the person approved: a board card they answered, or else ask them first, one question on the Goal it is for naming the session, its role, model and mode; pass that question's questionId as approvalQuestionId. brief becomes the session's first Goal, under parentGoalId when given. Name a workspace the host granted or the repo. mode is bypass unless ask. A refusal says why. Returns sessionId, the agent, the brief's goalId and next.";
14647
14679
  var AGENT_TOOLS2 = [
14648
14680
  { name: "configure", title: "Who am I", annotations: READS2, description: CONFIGURE_IDENTITY_DESCRIPTION2, inputSchema: mcpInputSchema2(ConfigureIdentitySchema2) },
14649
14681
  { name: "contact", title: "Contact the person", annotations: SENDS2, description: CONTACT_DESCRIPTION2, inputSchema: CONTACT_SCHEMA2 },
@@ -14653,6 +14685,7 @@ var AGENT_TOOLS2 = [
14653
14685
  { name: "search", title: "Search history", annotations: READS2, description: SEARCH_DESCRIPTION2, inputSchema: mcpInputSchema2(SearchToolSchema2) },
14654
14686
  { name: "check_activity", title: "Recent agent activity", annotations: READS2, description: "Read your person's agents that contributed in the last 24 hours, newest first: at most 30 agents and their five most recently touched Goals, with their latest entry headline and time. Use get_goals to read a Goal and its other contributors before starting overlapping work. Read-only; no arguments.", inputSchema: mcpInputSchema2(CheckActivitySchema2) },
14655
14687
  { name: "send_feedback", title: "Send feedback to Paigy", annotations: SENDS2, description: SEND_FEEDBACK_DESCRIPTION2, inputSchema: mcpInputSchema2(SendFeedbackSchema2) },
14688
+ { name: "launch", title: "Launch a session", annotations: SENDS2, description: LAUNCH_DESCRIPTION2, inputSchema: mcpInputSchema2(LaunchToolSchema2) },
14656
14689
  // THE GUIDE FROM INSIDE THE MCP (owner, 2026-10-27): the skill's text, needing no identity (`help.ts`).
14657
14690
  { name: "help", title: "Paigy guide", annotations: READS2, description: HELP_DESCRIPTION2, inputSchema: mcpInputSchema2(HelpSchema2) }
14658
14691
  ];
@@ -16123,6 +16156,9 @@ var DeviceTokenSchema2 = external_exports.object({
16123
16156
  /** Local host recovery must preserve the launch's runtime and Paigy identity. */
16124
16157
  harness: external_exports.enum(["claude", "codex", "agy", "grok"]).optional(),
16125
16158
  session_id: external_exports.string().uuid().optional(),
16159
+ /** How the launch asked for it to run (`GET /api/sessions/claim` `mode`), so every wake of this slot
16160
+ * runs it the same way. Absent is bypass (owner, 2026-11-13), as every slot written before it. */
16161
+ mode: external_exports.enum(["ask", "bypass"]).optional(),
16126
16162
  /** A conversation the host must not resume: its context is full, so every turn fails
16127
16163
  * ("Prompt is too long"). Written when a run hits it (`run.ts` `onFull`); the host skips a slot
16128
16164
  * whose resumable session is this one, so its Goals reach the dead-agent handoff instead of a
@@ -18086,6 +18122,7 @@ ${event.message}`, state, rail, { log: opts.log });
18086
18122
  ...opts.token ? { token: opts.token } : {},
18087
18123
  ...opts.resume ? { resume: opts.resume } : {},
18088
18124
  ...opts.session ? { session: opts.session } : {},
18125
+ ...opts.model ? { model: opts.model } : {},
18089
18126
  ...opts.bin ? { bin: opts.bin } : {},
18090
18127
  ...inbox ? { inbox: inbox.dir } : {},
18091
18128
  onExit: () => {
@@ -18237,6 +18274,7 @@ var claimedRun = (sessionId2) => {
18237
18274
  return { slot, key: runKey(slot) };
18238
18275
  };
18239
18276
  var launchRun = (spec) => ({ session: spec.sessionId, model: spec.model });
18277
+ var launchMode = (mode) => mode === "ask" ? "ask" : "bypass";
18240
18278
  var BOUND_ELSEWHERE_MS = 10 * 6e4;
18241
18279
  var boundElsewhere = /* @__PURE__ */ new Map();
18242
18280
  var BOUND_SKIP = "is bound to the session it was paired in, which this host cannot name \u2014 run `paigy-harness handoff` as it, in its folder, to record it";
@@ -18377,7 +18415,8 @@ function startHost(opts) {
18377
18415
  device: null,
18378
18416
  workspace: spec.workspace,
18379
18417
  harness: spec.harness,
18380
- session_id: spec.sessionId
18418
+ session_id: spec.sessionId,
18419
+ mode: launchMode(spec.mode)
18381
18420
  }, slot);
18382
18421
  } catch {
18383
18422
  log2("Cannot persist launch identity/runtime; session was not started. Check local storage and relaunch.");
@@ -18386,7 +18425,7 @@ function startHost(opts) {
18386
18425
  const run = runHarness({
18387
18426
  harness: spec.harness,
18388
18427
  cwd: workspace,
18389
- mode: "bypass",
18428
+ mode: launchMode(spec.mode),
18390
18429
  prompt: "",
18391
18430
  token: spec.token,
18392
18431
  ...launchRun(spec),
@@ -18405,7 +18444,7 @@ function startHost(opts) {
18405
18444
  void heartbeat(void 0, { token: spec.token }).catch(() => {
18406
18445
  });
18407
18446
  void refreshIdentities();
18408
- opts.log(`\u25B6 phone-launched ${label} (${spec.harness}) in ${spec.workspace}`);
18447
+ opts.log(`\u25B6 launched ${label} (${spec.harness}, ${launchMode(spec.mode)}) in ${spec.workspace}`);
18409
18448
  }
18410
18449
  const ends = await claimSessionEnds(asHost).catch(() => []);
18411
18450
  for (const end of ends) {
@@ -18552,9 +18591,10 @@ function startHost(opts) {
18552
18591
  }
18553
18592
  const log2 = (line) => opts.log(`[${label}] ${line}`);
18554
18593
  const run = runHarness({
18594
+ // A wake runs the session the way its launch asked (the slot keeps it), bypass when it named none.
18555
18595
  harness,
18556
18596
  cwd: workspace,
18557
- mode: "bypass",
18597
+ mode: launchMode(identity.mode),
18558
18598
  prompt: "",
18559
18599
  token,
18560
18600
  ...identity.sessionId ? { session: identity.sessionId } : {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paigy/harness",
3
- "version": "0.3.49",
3
+ "version": "0.3.51",
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",