@pome-sh/cli 0.7.0 → 0.9.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 (154) hide show
  1. package/dist/build-info.json +3 -3
  2. package/dist/src/cli/agent-identity.js +7 -2
  3. package/dist/src/cli/compile-seeds.js +51 -5
  4. package/dist/src/cli/docs-topics.js +5 -3
  5. package/dist/src/cli/main.js +21 -11
  6. package/dist/src/cli/project-config.d.ts +8 -0
  7. package/dist/src/cli/project-config.js +18 -0
  8. package/dist/src/cli/register.d.ts +15 -0
  9. package/dist/src/cli/register.js +26 -3
  10. package/dist/src/cli/session.d.ts +10 -0
  11. package/dist/src/cli/session.js +28 -2
  12. package/dist/src/fix-prompt/index.d.ts +1 -1
  13. package/dist/src/fix-prompt/index.js +2 -2
  14. package/dist/src/fix-prompt/prompt.d.ts +2 -2
  15. package/dist/src/fix-prompt/prompt.js +9 -9
  16. package/dist/src/hosted/client.d.ts +8 -2
  17. package/dist/src/hosted/client.js +108 -26
  18. package/dist/src/hosted/errors.d.ts +14 -0
  19. package/dist/src/hosted/errors.js +22 -0
  20. package/dist/src/hosted/evalResultCache.d.ts +4 -4
  21. package/dist/src/hosted/evalResultCache.js +10 -3
  22. package/dist/src/recorder/artifacts.d.ts +1 -1
  23. package/dist/src/recorder/artifacts.js +8 -1
  24. package/dist/src/runner/runTask.d.ts +14 -0
  25. package/dist/src/runner/runTaskHosted.js +9 -2
  26. package/dist/src/runner/runTrialGroup.js +4 -1
  27. package/dist/src/task/taskSchema.d.ts +52 -16
  28. package/node_modules/@pome-sh/shared-types/dist/seed-state.d.ts +27 -0
  29. package/node_modules/@pome-sh/shared-types/dist/seed-state.js +12 -0
  30. package/node_modules/@pome-sh/shared-types/dist/seed-state.js.map +1 -1
  31. package/node_modules/@pome-sh/shared-types/dist/task.d.ts +18 -0
  32. package/node_modules/@pome-sh/shared-types/package.json +1 -1
  33. package/node_modules/@pome-sh/shared-types/trace-contract.json +1 -1
  34. package/node_modules/@pome-sh/twin-gmail/CHANGELOG.md +21 -0
  35. package/node_modules/@pome-sh/twin-gmail/HOSTED.md +37 -15
  36. package/node_modules/@pome-sh/twin-gmail/LIMITS.md +10 -0
  37. package/node_modules/@pome-sh/twin-gmail/README.md +52 -11
  38. package/node_modules/@pome-sh/twin-gmail/dist/fixtures/mcp-tools-list.canonical.json +242 -7
  39. package/node_modules/@pome-sh/twin-gmail/dist/src/db.js +6 -0
  40. package/node_modules/@pome-sh/twin-gmail/dist/src/db.js.map +1 -1
  41. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/drafts.d.ts +41 -0
  42. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/drafts.js +138 -0
  43. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/drafts.js.map +1 -0
  44. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/filters.d.ts +10 -0
  45. package/node_modules/@pome-sh/twin-gmail/dist/src/{domain-search.js → domain/filters.js} +52 -36
  46. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/filters.js.map +1 -0
  47. package/node_modules/@pome-sh/twin-gmail/dist/src/{domain.d.ts → domain/gmail-domain.d.ts} +45 -34
  48. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/gmail-domain.js +174 -0
  49. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/gmail-domain.js.map +1 -0
  50. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/hydrate.d.ts +8 -0
  51. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/hydrate.js +122 -0
  52. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/hydrate.js.map +1 -0
  53. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/index.d.ts +4 -0
  54. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/index.js +5 -0
  55. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/index.js.map +1 -0
  56. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/labels.d.ts +40 -0
  57. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/labels.js +122 -0
  58. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/labels.js.map +1 -0
  59. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/messages.d.ts +49 -0
  60. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/messages.js +276 -0
  61. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/messages.js.map +1 -0
  62. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/search-sql.d.ts +19 -0
  63. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/search-sql.js +179 -0
  64. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/search-sql.js.map +1 -0
  65. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/settings.d.ts +27 -0
  66. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/settings.js +98 -0
  67. package/node_modules/@pome-sh/twin-gmail/dist/src/domain/settings.js.map +1 -0
  68. package/node_modules/@pome-sh/twin-gmail/dist/src/errors.js +2 -0
  69. package/node_modules/@pome-sh/twin-gmail/dist/src/errors.js.map +1 -1
  70. package/node_modules/@pome-sh/twin-gmail/dist/src/faults.d.ts +21 -0
  71. package/node_modules/@pome-sh/twin-gmail/dist/src/faults.js +52 -0
  72. package/node_modules/@pome-sh/twin-gmail/dist/src/faults.js.map +1 -0
  73. package/node_modules/@pome-sh/twin-gmail/dist/src/identity.d.ts +1 -6
  74. package/node_modules/@pome-sh/twin-gmail/dist/src/identity.js +0 -11
  75. package/node_modules/@pome-sh/twin-gmail/dist/src/identity.js.map +1 -1
  76. package/node_modules/@pome-sh/twin-gmail/dist/src/index.d.ts +4 -3
  77. package/node_modules/@pome-sh/twin-gmail/dist/src/index.js +3 -3
  78. package/node_modules/@pome-sh/twin-gmail/dist/src/index.js.map +1 -1
  79. package/node_modules/@pome-sh/twin-gmail/dist/src/mcp-schemas.d.ts +48 -0
  80. package/node_modules/@pome-sh/twin-gmail/dist/src/mcp-schemas.js +23 -0
  81. package/node_modules/@pome-sh/twin-gmail/dist/src/mcp-schemas.js.map +1 -1
  82. package/node_modules/@pome-sh/twin-gmail/dist/src/mcp.d.ts +1 -1
  83. package/node_modules/@pome-sh/twin-gmail/dist/src/mcp.js +39 -1
  84. package/node_modules/@pome-sh/twin-gmail/dist/src/mcp.js.map +1 -1
  85. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-routes-drafts.js +4 -5
  86. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-routes-drafts.js.map +1 -1
  87. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-routes-kit.d.ts +2 -3
  88. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-routes-kit.js +4 -4
  89. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-routes-kit.js.map +1 -1
  90. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-routes-messages.js +7 -8
  91. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-routes-messages.js.map +1 -1
  92. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-routes-resources.js +20 -21
  93. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-routes-resources.js.map +1 -1
  94. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-routes.d.ts +1 -1
  95. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-serializers.d.ts +2 -4
  96. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-serializers.js +4 -6
  97. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-serializers.js.map +1 -1
  98. package/node_modules/@pome-sh/twin-gmail/dist/src/search-match.d.ts +4 -0
  99. package/node_modules/@pome-sh/twin-gmail/dist/src/search-match.js +179 -0
  100. package/node_modules/@pome-sh/twin-gmail/dist/src/search-match.js.map +1 -0
  101. package/node_modules/@pome-sh/twin-gmail/dist/src/search-parse.d.ts +61 -0
  102. package/node_modules/@pome-sh/twin-gmail/dist/src/search-parse.js +318 -0
  103. package/node_modules/@pome-sh/twin-gmail/dist/src/search-parse.js.map +1 -0
  104. package/node_modules/@pome-sh/twin-gmail/dist/src/search.d.ts +3 -61
  105. package/node_modules/@pome-sh/twin-gmail/dist/src/search.js +2 -503
  106. package/node_modules/@pome-sh/twin-gmail/dist/src/search.js.map +1 -1
  107. package/node_modules/@pome-sh/twin-gmail/dist/src/seed.d.ts +13 -4
  108. package/node_modules/@pome-sh/twin-gmail/dist/src/seed.js +3 -1
  109. package/node_modules/@pome-sh/twin-gmail/dist/src/seed.js.map +1 -1
  110. package/node_modules/@pome-sh/twin-gmail/dist/src/server.js +1 -1
  111. package/node_modules/@pome-sh/twin-gmail/dist/src/server.js.map +1 -1
  112. package/node_modules/@pome-sh/twin-gmail/dist/src/storage.js +1 -1
  113. package/node_modules/@pome-sh/twin-gmail/dist/src/storage.js.map +1 -1
  114. package/node_modules/@pome-sh/twin-gmail/dist/src/twin.d.ts +2 -3
  115. package/node_modules/@pome-sh/twin-gmail/dist/src/twin.js +1 -4
  116. package/node_modules/@pome-sh/twin-gmail/dist/src/twin.js.map +1 -1
  117. package/node_modules/@pome-sh/twin-gmail/dist/src/types.d.ts +1 -0
  118. package/node_modules/@pome-sh/twin-gmail/fidelity.inventory.json +42 -435
  119. package/node_modules/@pome-sh/twin-gmail/fixtures/README.md +4 -4
  120. package/node_modules/@pome-sh/twin-gmail/fixtures/mcp-tools-list.canonical.json +242 -7
  121. package/node_modules/@pome-sh/twin-gmail/fixtures/mcp-tools-list.meta.json +3 -3
  122. package/node_modules/@pome-sh/twin-gmail/package.json +3 -2
  123. package/node_modules/hono/dist/cjs/client/utils.js +1 -1
  124. package/node_modules/hono/dist/cjs/helper/streaming/sse.js +5 -4
  125. package/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
  126. package/node_modules/hono/dist/cjs/middleware/compress/index.js +2 -1
  127. package/node_modules/hono/dist/cjs/middleware/method-override/index.js +5 -3
  128. package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +10 -4
  129. package/node_modules/hono/dist/cjs/request.js +8 -3
  130. package/node_modules/hono/dist/cjs/utils/accept.js +1 -1
  131. package/node_modules/hono/dist/cjs/utils/body.js +6 -0
  132. package/node_modules/hono/dist/cjs/utils/url.js +1 -1
  133. package/node_modules/hono/dist/client/utils.js +1 -1
  134. package/node_modules/hono/dist/helper/streaming/sse.js +5 -4
  135. package/node_modules/hono/dist/middleware/cache/index.js +1 -1
  136. package/node_modules/hono/dist/middleware/compress/index.js +2 -1
  137. package/node_modules/hono/dist/middleware/method-override/index.js +5 -3
  138. package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +10 -4
  139. package/node_modules/hono/dist/request.js +8 -3
  140. package/node_modules/hono/dist/types/adapter/aws-lambda/types.d.ts +9 -0
  141. package/node_modules/hono/dist/types/helper/websocket/index.d.ts +1 -1
  142. package/node_modules/hono/dist/types/middleware/combine/index.d.ts +1 -1
  143. package/node_modules/hono/dist/utils/accept.js +1 -1
  144. package/node_modules/hono/dist/utils/body.js +6 -0
  145. package/node_modules/hono/dist/utils/url.js +1 -1
  146. package/node_modules/hono/package.json +3 -3
  147. package/package.json +3 -3
  148. package/node_modules/@pome-sh/twin-gmail/dist/src/domain-search.d.ts +0 -5
  149. package/node_modules/@pome-sh/twin-gmail/dist/src/domain-search.js.map +0 -1
  150. package/node_modules/@pome-sh/twin-gmail/dist/src/domain.js +0 -407
  151. package/node_modules/@pome-sh/twin-gmail/dist/src/domain.js.map +0 -1
  152. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-store.d.ts +0 -75
  153. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-store.js +0 -282
  154. package/node_modules/@pome-sh/twin-gmail/dist/src/rest-store.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "pome-sh",
3
- "version": "0.7.0",
4
- "git_sha": "c07382656e095899efa7d46c96a12830869e9cbb",
5
- "build_time": "2026-07-24T16:38:09.759Z"
3
+ "version": "0.9.0",
4
+ "git_sha": "2412f1350c8c75dbc179884982228467f4452bf2",
5
+ "build_time": "2026-07-27T16:54:03.861Z"
6
6
  }
@@ -13,7 +13,7 @@ import { dirname } from "node:path";
13
13
  import { postAgentResolver, resolveSeams, } from "./agent-resolver.js";
14
14
  import { resolveCredentials } from "./credentials.js";
15
15
  import { ensurePomeGitignored, readLinkCache, resolveCachedAgentId, writeLinkCache, } from "./link-cache.js";
16
- import { readManifest } from "./project-config.js";
16
+ import { normalizeManifestTwins, readManifest } from "./project-config.js";
17
17
  export async function resolveRunAgentIdentity(input) {
18
18
  const manifestRead = await readManifest(input.startDir);
19
19
  if (!manifestRead) {
@@ -38,13 +38,18 @@ export async function resolveRunAgentIdentity(input) {
38
38
  if (cachedId) {
39
39
  return { ...base, agentId: cachedId };
40
40
  }
41
- // Silent re-resolution — a run never prompts for a near-miss.
41
+ // Silent re-resolution — a run never prompts for a near-miss. Send the
42
+ // manifest's twins so a fork / first `pome run` that auto-creates the agent
43
+ // enables the declared services instead of the server's `github` default
44
+ // (F-926); the server merges additively, so this is safe when the agent
45
+ // already exists.
42
46
  const resolved = await postAgentResolver(creds, {
43
47
  name: agent.name ?? agent.slug,
44
48
  slug: agent.slug,
45
49
  description: agent.description,
46
50
  version: agent.version,
47
51
  framework: agent.framework,
52
+ twins: normalizeManifestTwins(manifestRead.manifest.twins),
48
53
  }, resolveSeams({ stdinIsTTY: false }));
49
54
  if (creds.teamId) {
50
55
  await writeLinkCache(projectDir, { agent_id: resolved.id, team_id: creds.teamId });
@@ -18,6 +18,17 @@ import { compileSeedHosted } from "../task/seed-compiler-hosted.js";
18
18
  import { verifySeedWithTwin } from "../task/seed-verifier.js";
19
19
  import { exitCodeFor } from "../hosted/errors.js";
20
20
  const SIDECAR_META_VERSION = 1;
21
+ /**
22
+ * Sidecars written by hand rather than by the compiler mark themselves with
23
+ * this sentinel. It is a statement of provenance, not a cache state: the seeds
24
+ * that carry it encode adversarial setups (a backdoored PR, a fabricated green
25
+ * CI status, an exfiltration lure) that a recompile would quietly rewrite,
26
+ * changing what the task tests while the run still reports normally. So it
27
+ * outranks even `--force`; to recompile one, delete the sidecar or drop its
28
+ * `_meta` first.
29
+ */
30
+ const HAND_AUTHORED_MARKER = "hand-authored";
31
+ const HAND_AUTHORED_SOURCE_HASH = `sha256:${HAND_AUTHORED_MARKER}`;
21
32
  export async function runCompileSeeds(target, opts) {
22
33
  const files = await resolveTaskFiles(target ?? "tasks");
23
34
  if (files.length === 0) {
@@ -56,15 +67,20 @@ async function compileOne(taskPath, opts) {
56
67
  if (seedText.length === 0) {
57
68
  return { path: taskPath, status: "skipped-no-seed", message: "no ## Seed State section" };
58
69
  }
59
- // Stripe scenarios use a different schema; v1 only supports github. Check
60
- // twin first so Stripe scenarios are silently skipped without surfacing
61
- // misleading "still on inline JSON" warnings.
70
+ // Other twins use a different schema; v1 only emits a flat github seed. Check
71
+ // twin first so those tasks are silently skipped without surfacing misleading
72
+ // "still on inline JSON" warnings.
73
+ //
74
+ // A task naming github *alongside* another twin is seeded from a per-twin
75
+ // envelope (`{ github: {...}, linear: {...} }`), so compiling it would replace
76
+ // the envelope with a github-only seed and drop the other twin's half.
62
77
  const twins = readTwinsFromConfig(markdown);
63
- if (twins.length > 0 && !twins.includes("github")) {
78
+ const githubOnly = twins.length === 1 && twins[0] === "github";
79
+ if (twins.length > 0 && !githubOnly) {
64
80
  return {
65
81
  path: taskPath,
66
82
  status: "skipped-unsupported-twin",
67
- message: `twins=${twins.join(",")} not supported yet`
83
+ message: `twins=${twins.join(",")} only single-twin github tasks are supported yet`
68
84
  };
69
85
  }
70
86
  // Heuristic: if the section is a fenced JSON block, this scenario is still
@@ -79,6 +95,16 @@ async function compileOne(taskPath, opts) {
79
95
  }
80
96
  const sidecarPath = sidecarPathFor(taskPath);
81
97
  const proseHash = hashProse(seedText);
98
+ // Checked ahead of `--force` and ahead of the cache: this is authorship, not
99
+ // staleness. The sentinel can never equal a real sha256, so without this the
100
+ // cache always misses and the hand-authored seed is silently overwritten.
101
+ if (existsSync(sidecarPath) && (await isHandAuthored(sidecarPath))) {
102
+ return {
103
+ path: taskPath,
104
+ status: "skipped-hand-authored",
105
+ message: `hand-authored seed left untouched (${sidecarPath}) — delete it or drop its _meta to recompile`
106
+ };
107
+ }
82
108
  // Cache check only applies to local compile — hosted callers may have
83
109
  // different model versions than the locally-pinned COMPILER_MODEL, and the
84
110
  // cloud has its own edge cache to avoid duplicate work anyway.
@@ -186,6 +212,24 @@ async function readSidecarMeta(path) {
186
212
  return null;
187
213
  }
188
214
  }
215
+ /**
216
+ * Deliberately more lenient than `sidecarMetaSchema`: a hand-edited sidecar may
217
+ * carry only the sentinel and omit `version`/`compiled_at`. Failing that parse
218
+ * would fall through to a recompile — the exact overwrite this guards against —
219
+ * so any `_meta` bearing either sentinel field counts.
220
+ */
221
+ async function isHandAuthored(path) {
222
+ try {
223
+ const raw = await readFile(path, "utf8");
224
+ const meta = JSON.parse(raw)._meta;
225
+ if (!meta)
226
+ return false;
227
+ return meta.model === HAND_AUTHORED_MARKER || meta.source_hash === HAND_AUTHORED_SOURCE_HASH;
228
+ }
229
+ catch {
230
+ return false;
231
+ }
232
+ }
189
233
  async function resolveTaskFiles(target) {
190
234
  const abs = resolve(target);
191
235
  if (!existsSync(abs))
@@ -202,6 +246,8 @@ function statusStamp(status) {
202
246
  return "OK ";
203
247
  case "skipped-cached":
204
248
  return "skip";
249
+ case "skipped-hand-authored":
250
+ return "keep";
205
251
  case "skipped-no-seed":
206
252
  return "skip";
207
253
  case "skipped-unsupported-twin":
@@ -117,9 +117,11 @@ export const DOCS_TOPICS = [
117
117
  {
118
118
  id: "cli-tasks",
119
119
  title: "pome tasks",
120
- // F-892`path` still points at /docs/cli/scenarios: the docs.pome.sh page
121
- // is renamed by the M4 docs door, not here. Repoint once that lands.
122
- path: "/docs/cli/scenarios",
120
+ // F-912the M4 docs door renamed the docs.pome.sh page from
121
+ // /docs/cli/scenarios to /docs/cli/tasks (a redirect keeps the old URL
122
+ // alive), so `path` now points at the new route. The "scenarios" keyword
123
+ // stays so `pome docs scenarios` still resolves to this topic.
124
+ path: "/docs/cli/tasks",
123
125
  keywords: ["tasks", "scenarios", "catalog", "copy", "library", "twin"],
124
126
  },
125
127
  {
@@ -272,7 +272,7 @@ export function createProgram() {
272
272
  .argument("<name>", "Human-readable agent name (e.g. \"triage-bot\")")
273
273
  .option("--api-url <url>", "Control-plane URL", process.env.POME_API_URL ?? DEFAULT_CONTROL_PLANE_URL)
274
274
  .option("--force", "Re-resolve the agent even when .pome/link.json already links one", false)
275
- .option("--twins <list>", "Comma-separated services this agent may exercise (e.g. github,slack). Default: the cloud's default enablement.")
275
+ .option("--twins <list>", "Comma-separated services this agent may exercise (e.g. github,slack), unioned with the manifest's twins. Default: the manifest's twins, else the cloud's default enablement.")
276
276
  .description("Create a cloud agent under the current team and write agent.slug to pome.json")
277
277
  .action(async (name, opts) => {
278
278
  try {
@@ -360,12 +360,22 @@ export function createProgram() {
360
360
  .description("Stop a hosted session (aliased as `kill`)")
361
361
  .argument("<session-id>", "Session id (ses_…)")
362
362
  .option("--api-url <url>", "Control-plane URL", process.env.POME_API_URL ?? DEFAULT_CONTROL_PLANE_URL)
363
+ .option("--discard", "Confirm destroying a session whose run has not been graded (F-983)", false)
363
364
  .action(async (sessionId, opts) => {
364
365
  try {
365
- await runSessionStop({ apiBaseUrl: opts.apiUrl, sessionId });
366
+ await runSessionStop({
367
+ apiBaseUrl: opts.apiUrl,
368
+ sessionId,
369
+ discard: opts.discard === true,
370
+ });
366
371
  }
367
372
  catch (err) {
368
- console.error(friendlyHostedError(err));
373
+ // runSessionStop already prints the full refusal detail for
374
+ // HostedDiscardRefusedError; friendlyHostedError returns "" for it
375
+ // so we don't print a duplicate (or bare blank) line here.
376
+ const friendly = friendlyHostedError(err);
377
+ if (friendly)
378
+ console.error(friendly);
369
379
  process.exitCode = 2;
370
380
  }
371
381
  });
@@ -558,7 +568,7 @@ export function createProgram() {
558
568
  // documented exit codes. Anything else falls through to Commander
559
569
  // (treated like self-host).
560
570
  try {
561
- // FDRS-636 — effective trial count: -n wins, else the scenario
571
+ // FDRS-636 — effective trial count: -n wins, else the task
562
572
  // config's `runs` field (both capped at 20). k>1 takes the
563
573
  // trial-group path; k=1 stays EXACTLY the single-run path
564
574
  // below (no group is ever stamped for it).
@@ -769,7 +779,7 @@ export function createProgram() {
769
779
  .argument("[task]", "Path to the task .md file (only with an events.jsonl target)")
770
780
  .description("Assemble a paste-into-IDE fix prompt (no LLM call, no network). With no args, reads the latest FAILED run set under ./runs: the persisted cloud verdicts (verdict.json) become grouped failure signatures over the raw traces, in one prompt. Point it at a trial run dir to target that set, or use the legacy `<events.jsonl> <task.md>` form for a single trace.")
771
781
  .action(async (target, taskArg) => {
772
- // Legacy 2-arg form: <events.jsonl> <scenario.md> — unchanged
782
+ // Legacy 2-arg form: <events.jsonl> <task.md> — unchanged
773
783
  // (CAPTURE-ONLY, FDRS-657: raw trace + declared criteria, no verdict).
774
784
  if (target !== undefined && target.endsWith(".jsonl")) {
775
785
  if (!taskArg) {
@@ -777,7 +787,7 @@ export function createProgram() {
777
787
  process.exitCode = 5;
778
788
  return;
779
789
  }
780
- const [eventsRaw, scenario] = await Promise.all([
790
+ const [eventsRaw, task] = await Promise.all([
781
791
  readFile(resolve(target), "utf8"),
782
792
  parseTaskFile(resolve(taskArg)),
783
793
  ]);
@@ -786,7 +796,7 @@ export function createProgram() {
786
796
  .map((line) => line.trim())
787
797
  .filter((line) => line.length > 0)
788
798
  .map((line) => JSON.parse(line));
789
- console.log(buildFixPrompt({ events, scenario }));
799
+ console.log(buildFixPrompt({ events, task }));
790
800
  return;
791
801
  }
792
802
  if (taskArg !== undefined) {
@@ -810,14 +820,14 @@ export function createProgram() {
810
820
  return;
811
821
  }
812
822
  const set = discovery.set;
813
- let scenario = null;
823
+ let task = null;
814
824
  try {
815
- scenario = await parseTaskFile(resolve(set.taskPath));
825
+ task = await parseTaskFile(resolve(set.taskPath));
816
826
  }
817
827
  catch {
818
828
  // Task file moved/edited since the run — the prompt degrades to the
819
829
  // verdict-embedded criteria.
820
- scenario = null;
830
+ task = null;
821
831
  }
822
832
  const trials = [];
823
833
  for (const [idx, t] of set.trials.entries()) {
@@ -831,7 +841,7 @@ export function createProgram() {
831
841
  console.log(buildGroupFixPrompt({
832
842
  taskName: set.taskName,
833
843
  groupId: set.groupId,
834
- scenario,
844
+ task,
835
845
  trials,
836
846
  }));
837
847
  });
@@ -27,3 +27,11 @@ export declare function readRequiredManifest(startDir?: string): Promise<Manifes
27
27
  * pretty-printed with a trailing newline; YAML carries the schema pointer as a
28
28
  * language-server comment (the `$schema` key is dropped from the YAML body). */
29
29
  export declare function writeManifest(path: string, format: ManifestFormat, data: Record<string, unknown>): Promise<void>;
30
+ /** Normalize the manifest's `twins` to canonical (trim + lowercase, de-duped)
31
+ * twin ids for the `POST /v1/agents` body. The manifest schema keeps `twins`
32
+ * open (min(1) strings, not checked against MOUNTED_TWINS), so entries are
33
+ * normalized but NOT validated here — the server returns a friendly error for
34
+ * an unknown twin. Returns undefined when nothing survives so the cloud's
35
+ * default enablement still applies. Shared by the register command and the
36
+ * run-path identity resolver (F-926). */
37
+ export declare function normalizeManifestTwins(manifestTwins: readonly string[] | undefined): string[] | undefined;
@@ -114,6 +114,24 @@ function slugErrorMessage(raw, path) {
114
114
  const base = `Invalid agent.slug in ${path}: must match ${SLUG_RE} (lowercase kebab-case, max 64 chars).`;
115
115
  return suggestion.length > 0 ? `${base} Did you mean "${suggestion}"?` : base;
116
116
  }
117
+ /** Normalize the manifest's `twins` to canonical (trim + lowercase, de-duped)
118
+ * twin ids for the `POST /v1/agents` body. The manifest schema keeps `twins`
119
+ * open (min(1) strings, not checked against MOUNTED_TWINS), so entries are
120
+ * normalized but NOT validated here — the server returns a friendly error for
121
+ * an unknown twin. Returns undefined when nothing survives so the cloud's
122
+ * default enablement still applies. Shared by the register command and the
123
+ * run-path identity resolver (F-926). */
124
+ export function normalizeManifestTwins(manifestTwins) {
125
+ if (manifestTwins === undefined)
126
+ return undefined;
127
+ const out = new Set();
128
+ for (const twin of manifestTwins) {
129
+ const norm = twin.trim().toLowerCase();
130
+ if (norm.length > 0)
131
+ out.add(norm);
132
+ }
133
+ return out.size > 0 ? [...out] : undefined;
134
+ }
117
135
  async function fileExists(path) {
118
136
  try {
119
137
  await readFile(path, "utf8");
@@ -14,5 +14,20 @@ interface RegisterAgentOptions extends InteractiveSeams {
14
14
  }
15
15
  /** Normalize a `--twins github,slack` comma list to a validated twin array. */
16
16
  export declare function normalizeRegisterTwins(raw: string | undefined): string[] | undefined;
17
+ /** Effective register twins = the manifest's declared `twins` (the default twin
18
+ * set for runs) unioned with any `--twins` flag additions (F-926). Before this,
19
+ * the CLI sent only the flag, so a manifest like `twins: ["gmail"]` never
20
+ * reached `POST /v1/agents` and the server's `github` default won — the first
21
+ * `pome run` then errored with "Requested twins are not enabled".
22
+ *
23
+ * Union is the correct client shape because the server merges additively (never
24
+ * removes), so there is no "reduce" semantics to preserve; sending more is
25
+ * always safe. Manifest entries are normalized (trim + lowercase) to match the
26
+ * flag path and the canonical lowercase twin ids; they are intentionally NOT
27
+ * validated against MOUNTED_TWINS here (the manifest schema keeps `twins` open,
28
+ * and the server returns a friendly error for an unknown twin). Returns
29
+ * undefined when neither source contributes so the cloud's default enablement
30
+ * still applies. */
31
+ export declare function mergeRegisterTwins(manifestTwins: readonly string[] | undefined, flagTwins: readonly string[] | undefined): string[] | undefined;
17
32
  export declare function runRegisterAgent(opts: RegisterAgentOptions): Promise<void>;
18
33
  export { friendlyHostedError };
@@ -19,7 +19,7 @@ import { postAgentResolver, resolveSeams, } from "./agent-resolver.js";
19
19
  import { resolveCredentials } from "./credentials.js";
20
20
  import { suggestFramework } from "./frameworks.js";
21
21
  import { ensurePomeGitignored, readLinkCache, resolveCachedAgentId, writeLinkCache, } from "./link-cache.js";
22
- import { readRequiredManifest, writeManifest, } from "./project-config.js";
22
+ import { normalizeManifestTwins, readRequiredManifest, writeManifest, } from "./project-config.js";
23
23
  import { friendlyHostedError } from "./session.js";
24
24
  const SCHEMA_URL = "https://pome.sh/schemas/v1/pome.json";
25
25
  /** Normalize a `--twins github,slack` comma list to a validated twin array. */
@@ -39,6 +39,26 @@ export function normalizeRegisterTwins(raw) {
39
39
  }
40
40
  return [...new Set(twins)];
41
41
  }
42
+ /** Effective register twins = the manifest's declared `twins` (the default twin
43
+ * set for runs) unioned with any `--twins` flag additions (F-926). Before this,
44
+ * the CLI sent only the flag, so a manifest like `twins: ["gmail"]` never
45
+ * reached `POST /v1/agents` and the server's `github` default won — the first
46
+ * `pome run` then errored with "Requested twins are not enabled".
47
+ *
48
+ * Union is the correct client shape because the server merges additively (never
49
+ * removes), so there is no "reduce" semantics to preserve; sending more is
50
+ * always safe. Manifest entries are normalized (trim + lowercase) to match the
51
+ * flag path and the canonical lowercase twin ids; they are intentionally NOT
52
+ * validated against MOUNTED_TWINS here (the manifest schema keeps `twins` open,
53
+ * and the server returns a friendly error for an unknown twin). Returns
54
+ * undefined when neither source contributes so the cloud's default enablement
55
+ * still applies. */
56
+ export function mergeRegisterTwins(manifestTwins, flagTwins) {
57
+ const merged = new Set(normalizeManifestTwins(manifestTwins) ?? []);
58
+ for (const twin of flagTwins ?? [])
59
+ merged.add(twin);
60
+ return merged.size > 0 ? [...merged] : undefined;
61
+ }
42
62
  // ── Persist: manifest + link cache + gitignore ──────────────────────────────
43
63
  /** Read the manifest's existing agent block (for round-trip preservation and
44
64
  * did-you-mean input) without forcing schema defaults. */
@@ -141,12 +161,15 @@ export async function runRegisterAgent(opts) {
141
161
  return;
142
162
  }
143
163
  }
164
+ // Send the manifest's declared twins (unioned with any --twins flag) so the
165
+ // cloud's enabled services match the manifest, not the server default (F-926).
166
+ const twins = mergeRegisterTwins(manifestRead.manifest.twins, opts.twins);
144
167
  const agent = await createAndPersistAgent({
145
168
  creds,
146
169
  name: opts.name,
147
170
  manifestRead,
148
171
  projectDir,
149
- twins: opts.twins,
172
+ twins,
150
173
  seams: resolveSeams(opts),
151
174
  });
152
175
  const displayName = stripControlCharacters(agent.display_name);
@@ -156,7 +179,7 @@ export async function runRegisterAgent(opts) {
156
179
  if (agent.enabled_services !== undefined) {
157
180
  console.error(`Enabled services: ${agent.enabled_services.length > 0 ? agent.enabled_services.join(", ") : "(none)"}.`);
158
181
  }
159
- else if (opts.twins && opts.twins.length > 0) {
182
+ else if (twins && twins.length > 0) {
160
183
  console.error("Enabled services: not reported by this pome cloud (older control plane) — twin scoping may not have taken effect.");
161
184
  }
162
185
  // Deep-link the registered agent's dashboard page. `/agents/<slug>` is the
@@ -21,5 +21,15 @@ export declare function runSessionList(opts: {
21
21
  export declare function runSessionStop(opts: {
22
22
  apiBaseUrl: string;
23
23
  sessionId: string;
24
+ /** F-983: confirm destroying a session whose run has not been graded.
25
+ * Off by default — a human-typed destructive command gets the refusal
26
+ * printed instead of silently discarding the evidence. */
27
+ discard?: boolean;
24
28
  }): Promise<void>;
29
+ /** Empty string means "already fully reported — print nothing more". Only
30
+ * `HostedDiscardRefusedError` returns it today: `runSessionStop` above just
31
+ * printed the complete multi-line refusal (session, task, open time, the
32
+ * `--discard` escape hatch), so falling through to `err.message` here would
33
+ * either duplicate that or, when the server omits `error.message`, print a
34
+ * bare blank line. Callers must skip printing when this returns "". */
25
35
  export declare function friendlyHostedError(err: unknown): string;
@@ -4,7 +4,7 @@ import { chmod, mkdir, writeFile } from "node:fs/promises";
4
4
  import { dirname } from "node:path";
5
5
  import { MOUNTED_TWINS } from "@pome-sh/shared-types";
6
6
  import { createHostedClient, perTwinReturnedByCloud } from "../hosted/client.js";
7
- import { HostedAuthError, HostedOrchError, HostedQuotaError, } from "../hosted/errors.js";
7
+ import { HostedAuthError, HostedDiscardRefusedError, HostedOrchError, HostedQuotaError, } from "../hosted/errors.js";
8
8
  import { resolveRunAgentIdentity } from "./agent-identity.js";
9
9
  import { resolveCredentials } from "./credentials.js";
10
10
  import { DEFAULT_DASHBOARD_URL } from "./defaults.js";
@@ -242,10 +242,36 @@ export async function runSessionStop(opts) {
242
242
  baseUrl: creds.apiBaseUrl,
243
243
  apiKey: creds.apiKey,
244
244
  });
245
- await client.deleteSession(opts.sessionId, false);
245
+ try {
246
+ await client.deleteSession(opts.sessionId, false, {
247
+ discard: opts.discard === true,
248
+ });
249
+ }
250
+ catch (err) {
251
+ if (err instanceof HostedDiscardRefusedError) {
252
+ console.error(`Refused to stop ${err.sessionId}: it is still open (${err.state}), so its ` +
253
+ `run has not been graded — Pome creates the run row at finalize, and ` +
254
+ `stopping now discards it.`);
255
+ if (err.taskName)
256
+ console.error(` Task: ${err.taskName}`);
257
+ console.error(` Open for ${err.openSeconds}s.`);
258
+ console.error(` To keep the run, finalize it instead. To discard it anyway: ` +
259
+ `pome session stop ${err.sessionId} --discard`);
260
+ }
261
+ throw err;
262
+ }
246
263
  console.error(`Stopped session ${opts.sessionId}.`);
247
264
  }
265
+ /** Empty string means "already fully reported — print nothing more". Only
266
+ * `HostedDiscardRefusedError` returns it today: `runSessionStop` above just
267
+ * printed the complete multi-line refusal (session, task, open time, the
268
+ * `--discard` escape hatch), so falling through to `err.message` here would
269
+ * either duplicate that or, when the server omits `error.message`, print a
270
+ * bare blank line. Callers must skip printing when this returns "". */
248
271
  export function friendlyHostedError(err) {
272
+ if (err instanceof HostedDiscardRefusedError) {
273
+ return "";
274
+ }
249
275
  if (err instanceof HostedAuthError) {
250
276
  return `${err.message} · Run \`pome login\` or set a valid POME_API_KEY.`;
251
277
  }
@@ -1,6 +1,6 @@
1
1
  import { type FixPromptContext, type GroupFixPromptContext } from "./prompt.js";
2
2
  /**
3
- * Build the paste-into-IDE fix prompt from the raw trace + the scenario's
3
+ * Build the paste-into-IDE fix prompt from the raw trace + the task's
4
4
  * criteria. PURE + synchronous — no network, no LLM, no local judge.
5
5
  *
6
6
  * The output is a complete prompt: the system instructions (how to write the
@@ -4,11 +4,11 @@
4
4
  // (FDRS-657). CAPTURE-ONLY: no LLM/judge call happens here. The former BYOK
5
5
  // CLI-side judge call (`callJudge`) that generated the handoff was removed;
6
6
  // this now returns the fully-assembled prompt (system instructions + the
7
- // scenario's criteria + the captured trace) for the developer to paste into
7
+ // task's criteria + the captured trace) for the developer to paste into
8
8
  // their own coding assistant.
9
9
  import { FIX_PROMPT_SYSTEM_PROMPT, buildFixUserPrompt, buildGroupFixUserPrompt, } from "./prompt.js";
10
10
  /**
11
- * Build the paste-into-IDE fix prompt from the raw trace + the scenario's
11
+ * Build the paste-into-IDE fix prompt from the raw trace + the task's
12
12
  * criteria. PURE + synchronous — no network, no LLM, no local judge.
13
13
  *
14
14
  * The output is a complete prompt: the system instructions (how to write the
@@ -6,7 +6,7 @@ export declare const FIX_PROMPT_SYSTEM_PROMPT: string;
6
6
  export declare function escapeTagContent(text: string): string;
7
7
  export interface FixPromptContext {
8
8
  events: RecorderEvent[];
9
- scenario: Task;
9
+ task: Task;
10
10
  }
11
11
  export declare function buildFixUserPrompt(ctx: FixPromptContext): string;
12
12
  export interface TrialFixInput {
@@ -22,7 +22,7 @@ export interface GroupFixPromptContext {
22
22
  groupId: string | null;
23
23
  /** Parsed task file when it still resolves. Null degrades the prompt to
24
24
  * the verdict-embedded criteria (the file may have moved since the run). */
25
- scenario: Task | null;
25
+ task: Task | null;
26
26
  /** Completed trials of the run set (verdict.json present), run order. */
27
27
  trials: TrialFixInput[];
28
28
  }
@@ -3,7 +3,7 @@
3
3
  // Assembles the paste-into-IDE fix prompt for a failed run (FDRS-657).
4
4
  //
5
5
  // CAPTURE-ONLY: the OSS CLI does NOT call an LLM here. `pome fix-prompt`
6
- // assembles a self-contained prompt — system instructions + the scenario's
6
+ // assembles a self-contained prompt — system instructions + the task's
7
7
  // criteria + the raw captured trace — and prints it so the developer can paste
8
8
  // it into THEIR own coding assistant (Cursor / Claude Code). The former BYOK
9
9
  // local-judge call that generated the handoff CLI-side was removed under
@@ -87,10 +87,10 @@ function renderCriteria(criteria) {
87
87
  .join("\n");
88
88
  }
89
89
  export function buildFixUserPrompt(ctx) {
90
- const criteria = redactSecrets(renderCriteria(ctx.scenario.criteria));
90
+ const criteria = redactSecrets(renderCriteria(ctx.task.criteria));
91
91
  const trace = renderEvents(ctx.events.map((event) => redactEvent(event)));
92
- const taskTitle = redactSecrets(ctx.scenario.title);
93
- const taskPrompt = redactSecrets(ctx.scenario.prompt);
92
+ const taskTitle = redactSecrets(ctx.task.title);
93
+ const taskPrompt = redactSecrets(ctx.task.prompt);
94
94
  return `## Task
95
95
  ${taskTitle}
96
96
 
@@ -192,15 +192,15 @@ export function buildGroupFixUserPrompt(ctx) {
192
192
  const representative = representativeFailingTrial(ctx.trials);
193
193
  const otherFailing = ctx.trials.filter((t) => !t.verdict.passed && t !== representative);
194
194
  const signatures = redactSecrets(renderGroupedSignatures(ctx.trials));
195
- const criteriaBlock = ctx.scenario
196
- ? redactSecrets(renderCriteria(ctx.scenario.criteria))
195
+ const criteriaBlock = ctx.task
196
+ ? redactSecrets(renderCriteria(ctx.task.criteria))
197
197
  : redactSecrets(renderCriteria((ctx.trials[0]?.verdict.criteria_results ?? []).map((r) => ({
198
198
  type: r.criterion.type,
199
199
  text: r.criterion.text,
200
200
  }))));
201
- const promptBlock = ctx.scenario
202
- ? redactSecrets(ctx.scenario.prompt)
203
- : `(task file not found at ${ctx.trials[0]?.verdict.scenario_path ?? "?"} — criteria above come from the cloud verdicts)`;
201
+ const promptBlock = ctx.task
202
+ ? redactSecrets(ctx.task.prompt)
203
+ : `(task file not found at ${ctx.trials[0]?.verdict.task_path ?? "?"} — criteria above come from the cloud verdicts)`;
204
204
  const sections = [];
205
205
  sections.push(`## Run set (cloud-judged)
206
206
  task ${redactSecrets(ctx.taskName)} · ${ctx.groupId ? `group ${ctx.groupId}` : "single run"} · ${passed} of ${completed} completed trials passed`);
@@ -197,7 +197,13 @@ export interface HostedClient {
197
197
  * for the feature-detection contract (a 404 here means an older control
198
198
  * plane; callers must tolerate it silently). */
199
199
  requestMetaUploadUrl(sessionId: string): Promise<MetaUploadUrlResponse>;
200
- /** @param bestEffort default true — hosted runner swallows network errors on teardown */
201
- deleteSession(sessionId: string, bestEffort?: boolean): Promise<void>;
200
+ /** @param bestEffort default true — hosted runner swallows network errors on teardown
201
+ * @param opts.discard F-983 set true to confirm discarding an ungraded
202
+ * session after catching {@link HostedDiscardRefusedError}. Never implied
203
+ * by `bestEffort`: a refusal is a deliberate server decision, not
204
+ * transport noise. */
205
+ deleteSession(sessionId: string, bestEffort?: boolean, opts?: {
206
+ discard?: boolean;
207
+ }): Promise<void>;
202
208
  }
203
209
  export declare function createHostedClient(config: HostedClientConfig): HostedClient;