@unbrained/pm-cli 2026.8.22 → 2026.8.23

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 (168) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +28 -0
  3. package/dist/cli/error-guidance.d.ts +13 -0
  4. package/dist/cli/error-guidance.js +62 -6
  5. package/dist/cli/main.js +13 -4
  6. package/dist/cli/register-mutation.js +6 -6
  7. package/dist/cli/register-operations.d.ts +73 -0
  8. package/dist/cli/register-operations.js +39 -14
  9. package/dist/cli/register-setup.js +3 -3
  10. package/dist/cli/schema-registration-helpers.d.ts +8 -1
  11. package/dist/cli/schema-registration-helpers.js +14 -5
  12. package/dist/cli-bundle/bundle-manifest.json +155 -155
  13. package/dist/cli-bundle/chunks/chunk-3ENVHX6C.js +36 -0
  14. package/dist/cli-bundle/chunks/{chunk-QI2CT3IX.js → chunk-DW2CGEMU.js} +2 -2
  15. package/dist/cli-bundle/chunks/{chunk-WG4STC36.js → chunk-EG6CLDZT.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-MYYI3ZOA.js → chunk-F3AI2JFL.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-U6GQ4VMV.js → chunk-HWZ6CELB.js} +4 -4
  18. package/dist/cli-bundle/chunks/chunk-HZBMLSZI.js +201 -0
  19. package/dist/cli-bundle/chunks/chunk-JB4KZWBF.js +3 -0
  20. package/dist/cli-bundle/chunks/chunk-KPH73XXJ.js +2 -0
  21. package/dist/cli-bundle/chunks/{chunk-BWX4SK46.js → chunk-KXPMB2YL.js} +58 -58
  22. package/dist/cli-bundle/chunks/{chunk-MZTZQTMS.js → chunk-QDVHNHAQ.js} +2 -2
  23. package/dist/cli-bundle/chunks/chunk-TFI5V5N2.js +13 -0
  24. package/dist/cli-bundle/chunks/{register-list-query-HZKBQNWW.js → register-list-query-UJB5FMV2.js} +2 -2
  25. package/dist/cli-bundle/chunks/register-mutation-NX5XE4VX.js +20 -0
  26. package/dist/cli-bundle/chunks/register-operations-RXIJIYXC.js +2 -0
  27. package/dist/cli-bundle/chunks/{register-setup-QK4OTOXN.js → register-setup-GFUZEKRE.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/{chunk-2POVTNLY.js → chunk-37Z4OEAP.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/chunk-3UPTYG44.js +8 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-E2EWYPY6.js → chunk-5S7E72FY.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/{chunk-GMYPD4FX.js → chunk-AUFH5H35.js} +2 -2
  32. package/dist/cli-bundle/focused-chunks/chunk-E7X25GC3.js +2 -0
  33. package/dist/cli-bundle/focused-chunks/{chunk-3LKU6PTJ.js → chunk-FQCSTBWE.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/{chunk-6S2MO3Q3.js → chunk-FZS4H32O.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/chunk-IFLWKY2R.js +156 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-PMGJUFNQ.js → chunk-JOWDB2MH.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/chunk-LYVSW5VM.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/chunk-MRCNF3U6.js +2 -0
  39. package/dist/cli-bundle/focused-chunks/{chunk-A2BC5PQL.js → chunk-OFVUGTLJ.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-2ARQGDDW.js → chunk-OGLQBL46.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/{chunk-R6SR45XU.js → chunk-OY7QAV4Y.js} +48 -47
  42. package/dist/cli-bundle/focused-chunks/chunk-QGFNI65N.js +26 -0
  43. package/dist/cli-bundle/focused-chunks/{chunk-D6RBZEJJ.js → chunk-R27IDGHD.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-UYRFYCDQ.js +5 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-PH2OXXVZ.js → chunk-ZHVA42R5.js} +9 -9
  46. package/dist/cli-bundle/main.js +13 -13
  47. package/dist/cli-bundle/sdk-authoring.js +1 -1
  48. package/dist/cli-bundle/sdk-contracts.js +2 -2
  49. package/dist/cli-bundle/sdk-core.js +40 -40
  50. package/dist/cli-bundle/sdk-governance.js +1 -1
  51. package/dist/cli-bundle/sdk-graph.js +1 -1
  52. package/dist/cli-bundle/sdk-merge.js +33 -32
  53. package/dist/cli-bundle/sdk-query.js +1 -1
  54. package/dist/cli-bundle/sdk-runtime.js +1 -1
  55. package/dist/cli-bundle/sdk-testing.js +1 -1
  56. package/dist/cli-bundle/sdk.js +5 -5
  57. package/dist/core/config/nested-settings.js +8 -2
  58. package/dist/core/config/positional-value.d.ts +1 -1
  59. package/dist/core/config/positional-value.js +5 -2
  60. package/dist/core/history/history.js +3 -3
  61. package/dist/core/item/item-format.js +66 -12
  62. package/dist/core/reproducibility/context.d.ts +4 -0
  63. package/dist/core/reproducibility/context.js +14 -8
  64. package/dist/core/shared/author.d.ts +55 -1
  65. package/dist/core/shared/author.js +333 -16
  66. package/dist/core/shared/constants.js +3 -2
  67. package/dist/core/store/settings-validator.d.ts +1 -0
  68. package/dist/core/store/settings-validator.js +6 -3
  69. package/dist/core/store/settings.js +5 -2
  70. package/dist/mcp/server.d.ts +1 -1
  71. package/dist/mcp/server.js +30 -9
  72. package/dist/sdk/agent/identity-config.d.ts +63 -0
  73. package/dist/sdk/agent/identity-config.js +107 -0
  74. package/dist/sdk/agent/refusal-corpus-contracts.d.ts +76 -0
  75. package/dist/sdk/agent/refusal-corpus-contracts.js +194 -0
  76. package/dist/sdk/cli-contracts/agent-output-contracts.js +6 -4
  77. package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -0
  78. package/dist/sdk/cli-contracts/enum-contracts.js +9 -2
  79. package/dist/sdk/cli-contracts/flag-contracts.js +9 -2
  80. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +4 -4
  81. package/dist/sdk/cli-contracts/registration-helpers.js +5 -2
  82. package/dist/sdk/cli-contracts/tool-parameter-tables.js +22 -2
  83. package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
  84. package/dist/sdk/cli-contracts/tool-schema.js +14 -3
  85. package/dist/sdk/cli-contracts.d.ts +3 -3
  86. package/dist/sdk/cli-contracts.js +4 -4
  87. package/dist/sdk/config.d.ts +6 -1
  88. package/dist/sdk/config.js +119 -14
  89. package/dist/sdk/context-intent-contracts.js +4 -2
  90. package/dist/sdk/core-governance.d.ts +1 -1
  91. package/dist/sdk/core-governance.js +3 -3
  92. package/dist/sdk/extension/scaffold.js +11 -5
  93. package/dist/sdk/flag-invocation-contracts.js +4 -2
  94. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +50 -2
  95. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +87 -38
  96. package/dist/sdk/governance/assurance-action.js +30 -10
  97. package/dist/sdk/governance/validate.d.ts +2 -2
  98. package/dist/sdk/governance/validate.js +39 -14
  99. package/dist/sdk/index.d.ts +7 -2
  100. package/dist/sdk/index.js +8 -3
  101. package/dist/sdk/lifecycle/create.js +6 -3
  102. package/dist/sdk/lifecycle/update.js +5 -3
  103. package/dist/sdk/merge/three-way.js +105 -26
  104. package/dist/sdk/read-output-budget.d.ts +21 -0
  105. package/dist/sdk/read-output-budget.js +39 -2
  106. package/dist/sdk/read-output-contracts.d.ts +5 -3
  107. package/dist/sdk/read-output-contracts.js +20 -12
  108. package/dist/sdk/reproducibility/process.d.ts +19 -0
  109. package/dist/sdk/reproducibility/process.js +88 -0
  110. package/dist/sdk/runtime-primitives.d.ts +1 -1
  111. package/dist/sdk/runtime-primitives.js +3 -3
  112. package/dist/sdk/runtime.js +6 -5
  113. package/dist/sdk/test/batch.d.ts +6 -0
  114. package/dist/sdk/test/batch.js +15 -3
  115. package/dist/sdk/test/entry.d.ts +1 -1
  116. package/dist/sdk/test/entry.js +3 -2
  117. package/dist/sdk/test/execution.d.ts +28 -3
  118. package/dist/sdk/test/execution.js +193 -34
  119. package/dist/sdk/test/parsers.d.ts +6 -0
  120. package/dist/sdk/test/parsers.js +21 -2
  121. package/dist/sdk/test/trust.d.ts +33 -0
  122. package/dist/sdk/test/trust.js +207 -0
  123. package/dist/types.d.ts +23 -0
  124. package/dist/types.js +2 -2
  125. package/docs/AGENT_PROVENANCE_ADR.md +41 -5
  126. package/docs/CONFIGURATION.md +4 -0
  127. package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +19 -2
  128. package/docs/MERGE_SAFETY.md +15 -1
  129. package/docs/READ_OUTPUT_CONTRACTS.md +11 -1
  130. package/docs/REPRODUCIBLE_WORKSPACES.md +42 -8
  131. package/docs/SDK.md +9 -0
  132. package/docs/SDK_AGENT_SESSION_CONTEXT.md +6 -4
  133. package/docs/SDK_EVIDENCE_TRACEABILITY.md +1 -1
  134. package/docs/TESTING.md +75 -8
  135. package/docs/agent-task-token-baseline.json +2 -2
  136. package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
  137. package/marketplace.json +2 -2
  138. package/package.json +2 -2
  139. package/packages/pm-beads/package.json +1 -1
  140. package/packages/pm-calendar/package.json +1 -1
  141. package/packages/pm-command-kit/package.json +1 -1
  142. package/packages/pm-digital-twin/package.json +1 -1
  143. package/packages/pm-governance-audit/package.json +1 -1
  144. package/packages/pm-guide-shell/package.json +1 -1
  145. package/packages/pm-kanban/package.json +1 -1
  146. package/packages/pm-lifecycle-hooks/package.json +1 -1
  147. package/packages/pm-linked-test-adapters/package.json +1 -1
  148. package/packages/pm-search-advanced/package.json +1 -1
  149. package/packages/pm-templates/package.json +1 -1
  150. package/packages/pm-todos/package.json +1 -1
  151. package/packages/pm-vcs/package.json +1 -1
  152. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  153. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  154. package/sdk/public-surface.json +427 -17
  155. package/dist/cli-bundle/chunks/chunk-EMWDM5FI.js +0 -13
  156. package/dist/cli-bundle/chunks/chunk-HYG6LRL4.js +0 -200
  157. package/dist/cli-bundle/chunks/chunk-SMWXHMVB.js +0 -35
  158. package/dist/cli-bundle/chunks/chunk-VMMIL3SI.js +0 -2
  159. package/dist/cli-bundle/chunks/chunk-YBPJAOQQ.js +0 -3
  160. package/dist/cli-bundle/chunks/register-mutation-HTKEEGRD.js +0 -20
  161. package/dist/cli-bundle/chunks/register-operations-6EMRWJJY.js +0 -2
  162. package/dist/cli-bundle/focused-chunks/chunk-2AZT5WXZ.js +0 -2
  163. package/dist/cli-bundle/focused-chunks/chunk-5SHSBMX2.js +0 -2
  164. package/dist/cli-bundle/focused-chunks/chunk-C4S4A4JJ.js +0 -5
  165. package/dist/cli-bundle/focused-chunks/chunk-L5LDSRO2.js +0 -155
  166. package/dist/cli-bundle/focused-chunks/chunk-MB37AYN6.js +0 -26
  167. package/dist/cli-bundle/focused-chunks/chunk-MCOR37QK.js +0 -2
  168. package/dist/cli-bundle/focused-chunks/chunk-WZE4LIPW.js +0 -8
@@ -9,7 +9,7 @@
9
9
  * definition for multi-branch agent workflows.
10
10
  */
11
11
 
12
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3c9d6924-ae7c-57c3-a346-1e2189c532fa")}catch(e){}}();
12
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="393f6460-bf8b-5479-8e3e-cac6f2680823")}catch(e){}}();
13
13
  import { historyEntriesToRaw, reanchorHistoryEntries, } from "../../core/history/replay.js";
14
14
  import { canonicalDocument, parseItemDocument, serializeItemDocument, } from "../../core/item/item-format.js";
15
15
  import { EXIT_CODE } from "../../core/shared/constants.js";
@@ -318,6 +318,58 @@ function unionCollection(base, ours, theirs) {
318
318
  }
319
319
  return merged;
320
320
  }
321
+ function linkedTestDefinitionIdentity(value) {
322
+ /* c8 ignore start -- canonical item parsing normalizes linked-test entries to object records */
323
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
324
+ return stableStringify(value);
325
+ }
326
+ /* c8 ignore stop */
327
+ const { provenance: _provenance, ...definition } = value;
328
+ return stableStringify(definition);
329
+ }
330
+ function markMergedLinkedTest(value) {
331
+ /* c8 ignore start -- canonical item parsing normalizes linked-test entries to object records */
332
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
333
+ return value;
334
+ }
335
+ /* c8 ignore stop */
336
+ const test = value;
337
+ if (!test.provenance) {
338
+ return {
339
+ ...test,
340
+ // Legacy entries contributed by another branch must not regain implicit
341
+ // local trust. This incomplete merge marker is preserved by normalization
342
+ // and refused until an operator acknowledges it in the receiving clone.
343
+ provenance: { source_kind: "merge_union" },
344
+ };
345
+ }
346
+ return {
347
+ ...test,
348
+ provenance: {
349
+ ...test.provenance,
350
+ source_kind: "merge_union",
351
+ },
352
+ };
353
+ }
354
+ function unionLinkedTests(base, ours, theirs) {
355
+ const toEntries = (value) => Array.isArray(value) ? value : [];
356
+ const baseIds = new Set(toEntries(base).map(linkedTestDefinitionIdentity));
357
+ const oursEntries = toEntries(ours);
358
+ const oursIds = new Set(oursEntries.map(linkedTestDefinitionIdentity));
359
+ const theirsEntries = toEntries(theirs);
360
+ const theirsIds = new Set(theirsEntries.map(linkedTestDefinitionIdentity));
361
+ const merged = oursEntries.filter((entry) => {
362
+ const identity = linkedTestDefinitionIdentity(entry);
363
+ return !baseIds.has(identity) || theirsIds.has(identity);
364
+ });
365
+ for (const entry of theirsEntries) {
366
+ const identity = linkedTestDefinitionIdentity(entry);
367
+ if (!oursIds.has(identity) && !baseIds.has(identity)) {
368
+ merged.push(markMergedLinkedTest(entry));
369
+ }
370
+ }
371
+ return merged;
372
+ }
321
373
  function latestTimestamp(ours, theirs) {
322
374
  return compareTimestampStrings(String(ours), String(theirs)) >= 0
323
375
  ? ours
@@ -362,6 +414,40 @@ function parseItemMergeSide(raw, label, options) {
362
414
  throw new PmCliError(`Item merge input (${label}) is not a readable item document: ${String(error)}`, EXIT_CODE.GENERIC_FAILURE);
363
415
  }
364
416
  }
417
+ /** Merge one collection field and report whether the field was handled. */
418
+ function mergeItemUnionField(params) {
419
+ if (!params.unionFieldSet.has(params.field))
420
+ return false;
421
+ const union = params.field === "tests"
422
+ ? unionLinkedTests(params.baseValue, params.oursValue, params.theirsValue)
423
+ : unionCollection(params.baseValue, params.oursValue, params.theirsValue);
424
+ params.accumulator.merged[params.field] = union;
425
+ if (!jsonEquals(union, params.oursValue)) {
426
+ params.accumulator.unionFields.push(params.field);
427
+ }
428
+ return true;
429
+ }
430
+ /** Merge one scalar field while preserving conflict evidence. */
431
+ function mergeItemScalarField(params) {
432
+ const outcome = mergeItemScalarThreeWay(params.baseValue, params.oursValue, params.theirsValue, params.preferred, params.conflictResolution);
433
+ if (outcome.value !== undefined) {
434
+ params.accumulator.merged[params.field] = outcome.value;
435
+ }
436
+ if (outcome.conflict) {
437
+ params.accumulator.conflictFields.push(params.field);
438
+ params.accumulator.conflictDecisions.push({
439
+ field: params.field,
440
+ base: params.baseValue,
441
+ ours: params.oursValue,
442
+ theirs: params.theirsValue,
443
+ retained: outcome.value,
444
+ discarded: outcome.from_theirs ? params.oursValue : params.theirsValue,
445
+ });
446
+ }
447
+ else if (outcome.from_theirs) {
448
+ params.accumulator.fieldsFromTheirs.push(params.field);
449
+ }
450
+ }
365
451
  function mergeItemMetadataRecords(baseRecord, oursRecord, theirsRecord, preferred, conflictResolution) {
366
452
  const unionFieldSet = new Set(ITEM_UNION_COLLECTION_FIELDS);
367
453
  const latestFieldSet = new Set(ITEM_LATEST_TIMESTAMP_FIELDS);
@@ -379,39 +465,32 @@ function mergeItemMetadataRecords(baseRecord, oursRecord, theirsRecord, preferre
379
465
  const baseValue = baseRecord[field];
380
466
  const oursValue = oursRecord[field];
381
467
  const theirsValue = theirsRecord[field];
382
- if (unionFieldSet.has(field)) {
383
- const union = unionCollection(baseValue, oursValue, theirsValue);
468
+ if (mergeItemUnionField({
469
+ field,
470
+ baseValue,
471
+ oursValue,
472
+ theirsValue,
473
+ unionFieldSet,
474
+ accumulator,
475
+ })) {
384
476
  // `fieldNames` is derived from both records' own keys, so a collection
385
477
  // reached here is declared by at least one side. Preserve even an empty
386
478
  // result (`tags` is required) so serialization never drops it.
387
- accumulator.merged[field] = union;
388
- if (!jsonEquals(union, oursValue)) {
389
- accumulator.unionFields.push(field);
390
- }
391
479
  continue;
392
480
  }
393
481
  if (latestFieldSet.has(field)) {
394
482
  accumulator.merged[field] = latestTimestamp(oursValue, theirsValue);
395
483
  continue;
396
484
  }
397
- const outcome = mergeItemScalarThreeWay(baseValue, oursValue, theirsValue, preferred, conflictResolution);
398
- if (outcome.value !== undefined) {
399
- accumulator.merged[field] = outcome.value;
400
- }
401
- if (outcome.conflict) {
402
- accumulator.conflictFields.push(field);
403
- accumulator.conflictDecisions.push({
404
- field,
405
- base: baseValue,
406
- ours: oursValue,
407
- theirs: theirsValue,
408
- retained: outcome.value,
409
- discarded: outcome.from_theirs ? oursValue : theirsValue,
410
- });
411
- }
412
- else if (outcome.from_theirs) {
413
- accumulator.fieldsFromTheirs.push(field);
414
- }
485
+ mergeItemScalarField({
486
+ field,
487
+ baseValue,
488
+ oursValue,
489
+ theirsValue,
490
+ preferred,
491
+ conflictResolution,
492
+ accumulator,
493
+ });
415
494
  }
416
495
  return accumulator;
417
496
  }
@@ -625,4 +704,4 @@ export function mergeJsonDocuments(baseRaw, oursRaw, theirsRaw, options = {}) {
625
704
  };
626
705
  }
627
706
  //# sourceMappingURL=three-way.js.map
628
- //# debugId=3c9d6924-ae7c-57c3-a346-1e2189c532fa
707
+ //# debugId=393f6460-bf8b-5479-8e3e-cac6f2680823
@@ -5,6 +5,27 @@
5
5
  * read-output contract without expanding its public declaration module.
6
6
  */
7
7
  import type { PmReadOutputReceipt } from "./read-output-contracts.js";
8
+ /** Input to the deterministic finite-retry recommendation contract. */
9
+ export interface PmReadOutputRecoveryBudgetInput {
10
+ /** Ceiling that already bound and truncated the response. */
11
+ effective_budget_tokens: number;
12
+ /** Measured cost of the useful result before row compaction. */
13
+ measured_result_tokens: number;
14
+ }
15
+ /** Executable next-budget recommendation shared by CLI, SDK, and MCP. */
16
+ export interface PmReadOutputRecoveryBudget {
17
+ /** Rounded finite retry ceiling, or the only truthful safe fallback. */
18
+ output_budget: number | "unbounded";
19
+ /** Ratio to the binding request, absent when finite arithmetic is unsafe. */
20
+ recovery_budget_multiplier: number | null;
21
+ /** Stable algorithm revision for consumers and fixtures. */
22
+ rule_version: "v1";
23
+ }
24
+ /**
25
+ * Recommend a retry that is strictly larger than both the binding request and
26
+ * the pre-compaction result, with a 25% envelope margin rounded to 100 tokens.
27
+ */
28
+ export declare function resolveReadOutputRecoveryBudget(input: PmReadOutputRecoveryBudgetInput): PmReadOutputRecoveryBudget;
8
29
  /** Estimate the conservative token cost of a JSON-shaped result. */
9
30
  export declare function estimateReadOutputTokens(result: unknown): number;
10
31
  /** Update a receipt to the fixed-point estimate of the result containing it. */
@@ -1,8 +1,45 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="737ac274-c165-5d1a-8b8e-cb5d57a81c46")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="02a0bd0c-6ab0-5193-807b-00394a4712b7")}catch(e){}}();
3
3
  import { countReadOutputRows, readOutputBudgetCollections, } from "./read-output-rows.js";
4
4
  const MAX_ESTIMATE_ITERATIONS = 8;
5
5
  const MAX_COMPACTION_ITERATIONS = 64;
6
+ const RECOVERY_MARGIN_NUMERATOR = 5;
7
+ const RECOVERY_MARGIN_DENOMINATOR = 4;
8
+ const RECOVERY_ROUNDING_TOKENS = 100;
9
+ /**
10
+ * Recommend a retry that is strictly larger than both the binding request and
11
+ * the pre-compaction result, with a 25% envelope margin rounded to 100 tokens.
12
+ */
13
+ export function resolveReadOutputRecoveryBudget(input) {
14
+ const binding = Math.trunc(input.effective_budget_tokens);
15
+ const measured = Math.trunc(input.measured_result_tokens);
16
+ if (!Number.isSafeInteger(binding) ||
17
+ binding <= 0 ||
18
+ !Number.isSafeInteger(measured) ||
19
+ measured <= 0) {
20
+ return {
21
+ output_budget: "unbounded",
22
+ recovery_budget_multiplier: null,
23
+ rule_version: "v1",
24
+ };
25
+ }
26
+ const baseline = Math.max(binding + 1, measured);
27
+ const withMargin = Math.ceil((baseline * RECOVERY_MARGIN_NUMERATOR) / RECOVERY_MARGIN_DENOMINATOR);
28
+ const rounded = Math.ceil(withMargin / RECOVERY_ROUNDING_TOKENS) *
29
+ RECOVERY_ROUNDING_TOKENS;
30
+ if (!Number.isSafeInteger(rounded)) {
31
+ return {
32
+ output_budget: "unbounded",
33
+ recovery_budget_multiplier: null,
34
+ rule_version: "v1",
35
+ };
36
+ }
37
+ return {
38
+ output_budget: rounded,
39
+ recovery_budget_multiplier: rounded / binding,
40
+ rule_version: "v1",
41
+ };
42
+ }
6
43
  /** Estimate the conservative token cost of a JSON-shaped result. */
7
44
  export function estimateReadOutputTokens(result) {
8
45
  return Math.ceil(Buffer.byteLength(JSON.stringify(result), "utf8") / 4);
@@ -96,4 +133,4 @@ export function compactReadOutputToBudget(result, receipt, budget, minimumRowsBy
96
133
  return compacted;
97
134
  }
98
135
  //# sourceMappingURL=read-output-budget.js.map
99
- //# debugId=737ac274-c165-5d1a-8b8e-cb5d57a81c46
136
+ //# debugId=02a0bd0c-6ab0-5193-807b-00394a4712b7
@@ -1,3 +1,5 @@
1
+ export { resolveReadOutputRecoveryBudget } from "./read-output-budget.js";
2
+ export type { PmReadOutputRecoveryBudget, PmReadOutputRecoveryBudgetInput, } from "./read-output-budget.js";
1
3
  export { decodeReadOutputContinuationCursor, encodeReadOutputContinuationCursor, } from "./read-output/continuation.js";
2
4
  import { type PmReadOutputSessionReceipt, type PmReadOutputSessionState } from "./read-output-session.js";
3
5
  /** Stable output dimensions shared by every read surface. */
@@ -142,7 +144,7 @@ export interface PmReadOutputTruncationDisclosure {
142
144
  /** Whether at least one declared row collection can be resumed within the budget. */
143
145
  continuation_available: boolean;
144
146
  /** Maximum next-page useful-result budget relative to the current budget. */
145
- recovery_budget_multiplier: 1;
147
+ recovery_budget_multiplier: number | null;
146
148
  /** Bounded continuation instructions for every compacted declared row path. */
147
149
  continuations: PmReadOutputContinuation[];
148
150
  /** Executable recovery instruction for retrieving the complete result. */
@@ -160,10 +162,10 @@ export interface PmReadOutputTruncationDisclosure {
160
162
  } | {
161
163
  cli: string;
162
164
  sdk: {
163
- outputBudget: number;
165
+ outputBudget: number | "unbounded";
164
166
  };
165
167
  mcp: {
166
- outputBudget: number;
168
+ outputBudget: number | "unbounded";
167
169
  };
168
170
  };
169
171
  }
@@ -5,10 +5,11 @@
5
5
  * surface without coupling package authors to command-specific option names.
6
6
  */
7
7
 
8
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a1272c1f-c03e-580c-8c44-6b3ddeedd240")}catch(e){}}();
8
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="76c9c2d0-951d-579e-916e-e8d54d4a8be9")}catch(e){}}();
9
9
  import { EXIT_CODE } from "../core/shared/constants.js";
10
10
  import { PmCliError } from "../core/shared/errors.js";
11
- import { compactReadOutputToBudget, estimateReadOutputTokens, updateReadOutputReceiptEstimate, } from "./read-output-budget.js";
11
+ import { compactReadOutputToBudget, estimateReadOutputTokens, resolveReadOutputRecoveryBudget, updateReadOutputReceiptEstimate, } from "./read-output-budget.js";
12
+ export { resolveReadOutputRecoveryBudget } from "./read-output-budget.js";
12
13
  import { resolvePmCommandOutputBudget } from "./cli-contracts/agent-output-contracts.js";
13
14
  import { boundReadOutputRows, countReadOutputRows, mapReadOutputRows, readOutputBudgetCollections, readOutputContinuationRowCollections, readOutputRowPaths, } from "./read-output-rows.js";
14
15
  import { applyReadOutputContinuation, decodeReadOutputContinuationCursor, encodeReadOutputContinuationCursor, prioritizeAssuranceAssertions, readOutputCollectionFingerprint, } from "./read-output/continuation.js";
@@ -979,7 +980,7 @@ function canReturnReadOutputUnchanged(resolved, session, result) {
979
980
  * without this an explicitly requested unbounded read is silently downgraded and
980
981
  * the only working recovery is never named.
981
982
  */
982
- function attachReadOutputTruncationDisclosure(projected, resolved, receipt, bindingBudget, continuationCursorRebased, collectionsBeforeBudget) {
983
+ function attachReadOutputTruncationDisclosure(projected, resolved, receipt, bindingBudget, continuationCursorRebased, measuredResultTokens, collectionsBeforeBudget) {
983
984
  if (!receipt.rows_compacted)
984
985
  return;
985
986
  const overridden = resolved.amount?.value === "unbounded" ? ["amount"] : [];
@@ -1013,6 +1014,10 @@ function attachReadOutputTruncationDisclosure(projected, resolved, receipt, bind
1013
1014
  ];
1014
1015
  });
1015
1016
  const primary = continuations[0];
1017
+ const recoveryBudget = resolveReadOutputRecoveryBudget({
1018
+ effective_budget_tokens: bindingBudget.tokens,
1019
+ measured_result_tokens: measuredResultTokens,
1020
+ });
1016
1021
  if (primary && typeof projected.next_cursor !== "string") {
1017
1022
  projected.next_cursor = primary.cursor;
1018
1023
  }
@@ -1029,11 +1034,13 @@ function attachReadOutputTruncationDisclosure(projected, resolved, receipt, bind
1029
1034
  compacted_row_paths: receipt.compacted_row_paths,
1030
1035
  continuation_cursor_rebased: continuationCursorRebased,
1031
1036
  continuation_available: continuations.length > 0,
1032
- recovery_budget_multiplier: 1,
1037
+ recovery_budget_multiplier: primary
1038
+ ? 1
1039
+ : recoveryBudget.recovery_budget_multiplier,
1033
1040
  continuations,
1034
1041
  restore_with: primary
1035
1042
  ? "Use recovery binding."
1036
- : "Increase --output-budget because no declared row collection can be continued.",
1043
+ : `Retry with --output-budget ${recoveryBudget.output_budget} because no declared row collection can be continued.`,
1037
1044
  recovery: primary
1038
1045
  ? {
1039
1046
  cursor: primary.cursor,
@@ -1042,9 +1049,9 @@ function attachReadOutputTruncationDisclosure(projected, resolved, receipt, bind
1042
1049
  mcp: "outputCursor",
1043
1050
  }
1044
1051
  : {
1045
- cli: "--output-budget 1200",
1046
- sdk: { outputBudget: 1200 },
1047
- mcp: { outputBudget: 1200 },
1052
+ cli: `--output-budget ${recoveryBudget.output_budget}`,
1053
+ sdk: { outputBudget: recoveryBudget.output_budget },
1054
+ mcp: { outputBudget: recoveryBudget.output_budget },
1048
1055
  },
1049
1056
  };
1050
1057
  }
@@ -1115,7 +1122,7 @@ function captureReadOutputContinuationState(projected, cursor, options) {
1115
1122
  : options.after,
1116
1123
  };
1117
1124
  }
1118
- function compactReadOutputProjection(projected, resolved, receipt, bindingBudget, session, continuationState) {
1125
+ function compactReadOutputProjection(projected, resolved, receipt, bindingBudget, session, continuationState, measuredResultTokens) {
1119
1126
  const assuranceMinimumRows = resolved.command === "assurance" && Array.isArray(projected.assertions)
1120
1127
  ? projected.assertions.filter((row) => isRecord(row) && row.verdict !== "pass").length
1121
1128
  : 0;
@@ -1123,7 +1130,7 @@ function compactReadOutputProjection(projected, resolved, receipt, bindingBudget
1123
1130
  ? new Map([["assertions", assuranceMinimumRows]])
1124
1131
  : new Map());
1125
1132
  const continuationCursorRebased = rebaseBudgetCompactedCursor(compacted, continuationState.originalItemCount, continuationState.cursorSource, continuationState.cursorContinuesExistingPage);
1126
- attachReadOutputTruncationDisclosure(compacted, resolved, receipt, bindingBudget, continuationCursorRebased, continuationState.collectionsBeforeBudget);
1133
+ attachReadOutputTruncationDisclosure(compacted, resolved, receipt, bindingBudget, continuationCursorRebased, measuredResultTokens, continuationState.collectionsBeforeBudget);
1127
1134
  if (session !== undefined) {
1128
1135
  compacted = attachReadOutputSessionContracts(compacted, session, receipt);
1129
1136
  }
@@ -1176,7 +1183,8 @@ export function applyReadOutputDimensions(command, options, result) {
1176
1183
  updateReadOutputReceiptEstimate(projected, receipt);
1177
1184
  if (bindingBudget !== undefined &&
1178
1185
  receipt.estimated_tokens > bindingBudget.tokens) {
1179
- projected = compactReadOutputProjection(projected, resolved, receipt, bindingBudget, session, continuationState);
1186
+ const measuredResultTokens = receipt.estimated_tokens;
1187
+ projected = compactReadOutputProjection(projected, resolved, receipt, bindingBudget, session, continuationState, measuredResultTokens);
1180
1188
  }
1181
1189
  if (bindingBudget !== undefined &&
1182
1190
  receipt.estimated_tokens > bindingBudget.tokens) {
@@ -1199,4 +1207,4 @@ export function resolveReadOutputEncoding(command, options) {
1199
1207
  : undefined;
1200
1208
  }
1201
1209
  //# sourceMappingURL=read-output-contracts.js.map
1202
- //# debugId=a1272c1f-c03e-580c-8c44-6b3ddeedd240
1210
+ //# debugId=76c9c2d0-951d-579e-916e-e8d54d4a8be9
@@ -0,0 +1,19 @@
1
+ import { type ReproducibleExecutionSettings, type ReproducibleExecutionRunner } from "../../core/reproducibility/context.js";
2
+ /** Stable environment-variable names understood by every pm process transport. */
3
+ export declare const PM_REPRODUCIBLE_PROCESS_ENV: Readonly<{
4
+ readonly clock: "PM_CLOCK";
5
+ readonly tickMs: "PM_CLOCK_TICK_MS";
6
+ readonly seed: "PM_SEED";
7
+ }>;
8
+ /** Environment-shaped input accepted by the reproducible process adapter. */
9
+ export type ReproducibleProcessEnvironment = Readonly<Record<string, string | undefined>>;
10
+ /** Public deterministic settings installed by recipes and process transports. */
11
+ export type { ReproducibleExecutionSettings };
12
+ /** Runner used by long-lived transports whose serial operations share one sequence. */
13
+ export type ReproducibleProcessRunner = ReproducibleExecutionRunner;
14
+ /** Resolve validated deterministic settings, or undefined when no opt-in is present. */
15
+ export declare function resolveReproducibleProcessEnvironment(environment: ReproducibleProcessEnvironment): ReproducibleExecutionSettings | undefined;
16
+ /** Create one process-lifetime runner for long-lived serial transports such as MCP. */
17
+ export declare function createReproducibleProcessRunner(environment: ReproducibleProcessEnvironment): ReproducibleProcessRunner;
18
+ /** Run one process transport operation under its declared deterministic context. */
19
+ export declare function runWithReproducibleProcessEnvironment<T>(environment: ReproducibleProcessEnvironment, operation: () => Promise<T>): Promise<T>;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @module sdk/reproducible-process
3
+ *
4
+ * Owns the process-environment contract that lets CLI and MCP transports enter
5
+ * the same deterministic execution context as SDK workspace recipes.
6
+ */
7
+
8
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ae031bac-f5a1-5762-9c58-0410b8f1f86d")}catch(e){}}();
9
+ import { EXIT_CODE } from "../../core/shared/constants.js";
10
+ import { PmCliError } from "../../core/shared/errors.js";
11
+ import { isRfc3339DateTime } from "../../core/shared/time.js";
12
+ import { createReproducibleExecutionRunner, validateReproducibleExecutionSettings, } from "../../core/reproducibility/context.js";
13
+ /** Stable environment-variable names understood by every pm process transport. */
14
+ export const PM_REPRODUCIBLE_PROCESS_ENV = Object.freeze({
15
+ clock: "PM_CLOCK",
16
+ tickMs: "PM_CLOCK_TICK_MS",
17
+ seed: "PM_SEED",
18
+ });
19
+ function invalidProcessEnvironment(message, reason, field, providedFields) {
20
+ return new PmCliError(message, EXIT_CODE.USAGE, {
21
+ code: "invalid_reproducible_process_environment",
22
+ reason,
23
+ field,
24
+ required: `${PM_REPRODUCIBLE_PROCESS_ENV.clock} and ${PM_REPRODUCIBLE_PROCESS_ENV.seed}; ${PM_REPRODUCIBLE_PROCESS_ENV.tickMs} is optional`,
25
+ nextSteps: [
26
+ `Set ${PM_REPRODUCIBLE_PROCESS_ENV.clock} to an ISO-8601 instant with Z or a numeric UTC offset and ${PM_REPRODUCIBLE_PROCESS_ENV.seed} to a non-empty reproducibility seed.`,
27
+ `Optionally set ${PM_REPRODUCIBLE_PROCESS_ENV.tickMs} to a non-negative integer; it defaults to 1.`,
28
+ `Unset all three variables to retain normal wall-clock and cryptographic-random behavior.`,
29
+ ],
30
+ recovery: {
31
+ recovery_mode: "compact",
32
+ provided_fields: providedFields,
33
+ missing_required_fields: reason === "incomplete"
34
+ ? [
35
+ PM_REPRODUCIBLE_PROCESS_ENV.clock,
36
+ PM_REPRODUCIBLE_PROCESS_ENV.seed,
37
+ ].filter((name) => !providedFields.includes(name))
38
+ : undefined,
39
+ },
40
+ });
41
+ }
42
+ /** Resolve validated deterministic settings, or undefined when no opt-in is present. */
43
+ export function resolveReproducibleProcessEnvironment(environment) {
44
+ const clock = environment[PM_REPRODUCIBLE_PROCESS_ENV.clock];
45
+ const tick = environment[PM_REPRODUCIBLE_PROCESS_ENV.tickMs];
46
+ const seed = environment[PM_REPRODUCIBLE_PROCESS_ENV.seed];
47
+ const providedFields = [
48
+ [PM_REPRODUCIBLE_PROCESS_ENV.clock, clock],
49
+ [PM_REPRODUCIBLE_PROCESS_ENV.tickMs, tick],
50
+ [PM_REPRODUCIBLE_PROCESS_ENV.seed, seed],
51
+ ]
52
+ .filter((entry) => entry[1] !== undefined)
53
+ .map(([name]) => name);
54
+ if (providedFields.length === 0) {
55
+ return undefined;
56
+ }
57
+ if (clock === undefined || seed === undefined) {
58
+ throw invalidProcessEnvironment("Reproducible process execution requires PM_CLOCK and PM_SEED together.", "incomplete", clock === undefined
59
+ ? PM_REPRODUCIBLE_PROCESS_ENV.clock
60
+ : PM_REPRODUCIBLE_PROCESS_ENV.seed, providedFields);
61
+ }
62
+ if (seed.trim().length === 0) {
63
+ throw invalidProcessEnvironment(`${PM_REPRODUCIBLE_PROCESS_ENV.seed} must not be empty.`, "invalid_value", PM_REPRODUCIBLE_PROCESS_ENV.seed, providedFields);
64
+ }
65
+ if (!isRfc3339DateTime(clock)) {
66
+ throw invalidProcessEnvironment(`${PM_REPRODUCIBLE_PROCESS_ENV.clock} must be a valid ISO-8601 instant with Z or a numeric UTC offset.`, "invalid_value", PM_REPRODUCIBLE_PROCESS_ENV.clock, providedFields);
67
+ }
68
+ const tickMs = tick === undefined ? 1 : Number(tick);
69
+ if (tick?.trim().length === 0 ||
70
+ !Number.isSafeInteger(tickMs) ||
71
+ tickMs < 0) {
72
+ throw invalidProcessEnvironment(`${PM_REPRODUCIBLE_PROCESS_ENV.tickMs} must be a non-negative integer.`, "invalid_value", PM_REPRODUCIBLE_PROCESS_ENV.tickMs, providedFields);
73
+ }
74
+ return validateReproducibleExecutionSettings({ clock, seed, tickMs });
75
+ }
76
+ /** Create one process-lifetime runner for long-lived serial transports such as MCP. */
77
+ export function createReproducibleProcessRunner(environment) {
78
+ const settings = resolveReproducibleProcessEnvironment(environment);
79
+ return settings === undefined
80
+ ? (operation) => operation()
81
+ : createReproducibleExecutionRunner(settings);
82
+ }
83
+ /** Run one process transport operation under its declared deterministic context. */
84
+ export async function runWithReproducibleProcessEnvironment(environment, operation) {
85
+ return createReproducibleProcessRunner(environment)(operation);
86
+ }
87
+ //# sourceMappingURL=process.js.map
88
+ //# debugId=ae031bac-f5a1-5762-9c58-0410b8f1f86d
@@ -53,7 +53,7 @@ export { type VectorizationEmbeddingIdentity, type VectorizationEmbeddingMetadat
53
53
  export { sentryCaptureCliError, sentryFinishCommandSpan, sentryFlush, sentryLogCliUsageError, sentrySetCommandContext, sentryStartCommandSpan, } from "../core/sentry/helpers.js";
54
54
  export { ensureSentryInit } from "../core/sentry/instrument.js";
55
55
  export { clearFocusedItem, getFocusedItem, setFocusedItem, } from "../core/session/session-state.js";
56
- export { readAuthorEnvironment, diagnoseAgentIdentity, resolveAuthor, resolveClaimPrincipal, runWithHarnessDetectionSignals, runWithWorkspaceHarnessSignalDescriptors, type AgentClientInfo, writeAuthorEnvironment, } from "../core/shared/author.js";
56
+ export { readAuthorEnvironment, diagnoseAgentIdentity, resolveAuthor, resolveClaimPrincipal, runWithHarnessDetectionSignals, runWithWorkspaceHarnessSignalDescriptors, BUILTIN_AGENT_PROVENANCE_ADAPTERS, listAgentProvenanceAdapters, normalizeAgentProvenanceAdapterValue, registerAgentProvenanceAdapters, type AgentProvenanceAdapter, type AgentClientInfo, writeAuthorEnvironment, } from "../core/shared/author.js";
57
57
  export { agentSessionEnvironment, boundAgentEpisodeIdentity, runWithAgentSessionContext, resolveAgentSessionContextFromSignals, type AgentEpisodeIdentity, type AgentSessionContext, } from "../core/shared/agent-session-context.js";
58
58
  export { evaluateMutationGuard, isMutationAction, listMutationActions, scanMutationSecrets, type EvaluateMutationGuardOptions, type MutationGuardResult, type MutationGuardSettings, type SecretGuardFinding, type SecretGuardMode, } from "./mutation-guard.js";
59
59
  export { jaccardSimilarity, normalizeSimilarityText, scoreItemSimilarity, tokenizeSimilarityText, type ItemSimilarityScore, } from "./similarity-scoring.js";
@@ -7,7 +7,7 @@
7
7
  * prefer the typed operations exported by the main SDK barrel.
8
8
  */
9
9
 
10
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1bcfba24-e761-571c-96e6-36bbc12d2814")}catch(e){}}();
10
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="472ea74c-138f-584f-b363-e76e100e124c")}catch(e){}}();
11
11
  export { createCheckpointId, loadMutationCheckpoint, restoreCheckpointItems, writeMutationCheckpoint, } from "../core/checkpoint/mutation-checkpoint.js";
12
12
  export { flattenFlagListValue, resolveFlagValueKind, } from "../core/extensions/flag-value-types.js";
13
13
  export { createUnknownSubcommandError, } from "./agent/subcommand-recovery.js";
@@ -55,7 +55,7 @@ export { buildVectorizationEmbeddingIdentity, buildVectorizationEmbeddingMetadat
55
55
  export { sentryCaptureCliError, sentryFinishCommandSpan, sentryFlush, sentryLogCliUsageError, sentrySetCommandContext, sentryStartCommandSpan, } from "../core/sentry/helpers.js";
56
56
  export { ensureSentryInit } from "../core/sentry/instrument.js";
57
57
  export { clearFocusedItem, getFocusedItem, setFocusedItem, } from "../core/session/session-state.js";
58
- export { readAuthorEnvironment, diagnoseAgentIdentity, resolveAuthor, resolveClaimPrincipal, runWithHarnessDetectionSignals, runWithWorkspaceHarnessSignalDescriptors, writeAuthorEnvironment, } from "../core/shared/author.js";
58
+ export { readAuthorEnvironment, diagnoseAgentIdentity, resolveAuthor, resolveClaimPrincipal, runWithHarnessDetectionSignals, runWithWorkspaceHarnessSignalDescriptors, BUILTIN_AGENT_PROVENANCE_ADAPTERS, listAgentProvenanceAdapters, normalizeAgentProvenanceAdapterValue, registerAgentProvenanceAdapters, writeAuthorEnvironment, } from "../core/shared/author.js";
59
59
  export { agentSessionEnvironment, boundAgentEpisodeIdentity, runWithAgentSessionContext, resolveAgentSessionContextFromSignals, } from "../core/shared/agent-session-context.js";
60
60
  export { evaluateMutationGuard, isMutationAction, listMutationActions, scanMutationSecrets, } from "./mutation-guard.js";
61
61
  export { jaccardSimilarity, normalizeSimilarityText, scoreItemSimilarity, tokenizeSimilarityText, } from "./similarity-scoring.js";
@@ -81,4 +81,4 @@ export { maybeRunFirstUseTelemetryPrompt } from "../core/telemetry/consent.js";
81
81
  export { deriveTelemetryCommandResolution, } from "../core/telemetry/observability.js";
82
82
  export { emitTelemetryErrorEvent, finishTelemetryCommand, startTelemetryCommand, } from "../core/telemetry/runtime.js";
83
83
  //# sourceMappingURL=runtime-primitives.js.map
84
- //# debugId=1bcfba24-e761-571c-96e6-36bbc12d2814
84
+ //# debugId=472ea74c-138f-584f-b363-e76e100e124c
@@ -4,7 +4,7 @@
4
4
  * Defines public SDK APIs and package-author helpers for Runtime.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a27b9b88-a8de-5e38-ab7f-dfcc61d1fad6")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="600f391a-c960-5dda-a85a-04d3fa8b1a51")}catch(e){}}();
8
8
  export { PM_GITIGNORE_END, PM_GITIGNORE_START, ensurePmGitignore, getPmGitignoreBlock, } from "./workspace.js";
9
9
  export { SEARCH_EXTENSION_FLAG_DEFINITIONS } from "./extension-contracts.js";
10
10
  export * from "./cli-contracts/agent-output-contracts.js";
@@ -1457,12 +1457,13 @@ function runMcpConfigAction(ctx) {
1457
1457
  const configAction = readString(ctx.args, "configAction") ??
1458
1458
  readString(ctx.options, "configAction") ??
1459
1459
  readString(ctx.options, "action");
1460
- if (configAction === undefined) {
1460
+ if (configAction === undefined)
1461
1461
  throw new PmCliError("Missing required argument: configAction", 64);
1462
- }
1462
+ const value = readString(ctx.args, "value") ?? readString(ctx.options, "value");
1463
+ const options = readString(ctx.options, "policy") !== undefined && value !== undefined ? { ...ctx.options, value } : ctx.options;
1463
1464
  return runConfig(readString(ctx.args, "scope") ??
1464
1465
  readString(ctx.options, "scope") ??
1465
- "project", configAction, readString(ctx.args, "key") ?? readString(ctx.options, "key"), ctx.options, ctx.global, readString(ctx.args, "value") ?? readString(ctx.options, "value"));
1466
+ "project", configAction, readString(ctx.args, "key") ?? readString(ctx.options, "key"), options, ctx.global, readString(ctx.options, "policy") === undefined ? value : undefined);
1466
1467
  }
1467
1468
  function runMcpActivityAction(ctx) {
1468
1469
  const options = ctx.options;
@@ -1945,4 +1946,4 @@ async function loadWorkspaceExtensionRegistrations(pmRoot, settings, cwd) {
1945
1946
  }
1946
1947
  }
1947
1948
  //# sourceMappingURL=runtime.js.map
1948
- //# debugId=a27b9b88-a8de-5e38-ab7f-dfcc61d1fad6
1949
+ //# debugId=600f391a-c960-5dda-a85a-04d3fa8b1a51
@@ -25,6 +25,12 @@ export interface TestAllCommandOptions {
25
25
  pmContext?: string;
26
26
  /** Value that configures or reports override linked pm context for this contract. */
27
27
  overrideLinkedPmContext?: boolean;
28
+ /** Source-workspace visibility and working-directory mode. */
29
+ workspaceContext?: string;
30
+ /** Force run-level source-workspace mode over linked metadata. */
31
+ overrideLinkedWorkspaceContext?: boolean;
32
+ /** Explicitly permit untrusted commands when project policy also permits them. */
33
+ allowUntrustedLinkedTests?: boolean;
28
34
  /** Value that configures or reports fail on context mismatch for this contract. */
29
35
  failOnContextMismatch?: boolean;
30
36
  /** Value that configures or reports fail on skipped for this contract. */
@@ -4,7 +4,7 @@
4
4
  * Implements the pm test all command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bb2758a5-a5c1-5f6e-be42-0e173fe16fe3")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5d3405c0-14e6-51f5-97a1-355438fd0199")}catch(e){}}();
8
8
  import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
9
  import { getActiveExtensionRegistrations } from "../../core/extensions/index.js";
10
10
  import { resolveItemTypeRegistry } from "../../core/item/type-registry.js";
@@ -80,6 +80,10 @@ const normalizePmContextModeSignature = (value) => {
80
80
  const normalized = value?.trim().toLowerCase();
81
81
  return normalized && normalized.length > 0 ? normalized : "none";
82
82
  };
83
+ const normalizeWorkspaceContextModeSignature = (value) => {
84
+ const normalized = value?.trim().toLowerCase();
85
+ return normalized && normalized.length > 0 ? normalized : "source";
86
+ };
83
87
  /** Sorts and deduplicates optional assertion string lists. */
84
88
  const normalizeAssertionStrings = (values) => [...new Set(values ?? [])].sort((left, right) => left.localeCompare(right));
85
89
  /** Sorts optional assertion maps into deterministic key order. */
@@ -110,9 +114,10 @@ const buildLinkedTestKey = (test) => {
110
114
  const envSet = normalizeEnvSetSignature(test.env_set);
111
115
  const envClear = normalizeEnvClearSignature(test.env_clear);
112
116
  const pmContextMode = normalizePmContextModeSignature(test.pm_context_mode);
117
+ const workspaceContextMode = normalizeWorkspaceContextModeSignature(test.workspace_context_mode);
113
118
  const sharedHostSafe = test.shared_host_safe === true ? "true" : "false";
114
119
  const assertions = normalizeAssertionSignature(test);
115
- return `${resolveLinkedTestTargetSignature(test)}:${envSet}:${envClear}:${pmContextMode}:${sharedHostSafe}:${assertions}`;
120
+ return `${resolveLinkedTestTargetSignature(test)}:${envSet}:${envClear}:${pmContextMode}:${workspaceContextMode}:${sharedHostSafe}:${assertions}`;
116
121
  };
117
122
  const maxTimeoutSeconds = (current, candidate) => {
118
123
  if (candidate === undefined) {
@@ -227,6 +232,11 @@ const runTestAllItem = async (entry, context) => {
227
232
  requireAssertionsForPm: context.options.requireAssertionsForPm,
228
233
  checkContext: context.options.checkContext,
229
234
  autoPmContext: context.options.autoPmContext,
235
+ workspaceContext: context.options.workspaceContext,
236
+ overrideLinkedWorkspaceContext: context.options.overrideLinkedWorkspaceContext,
237
+ pmRoot: context.pmRoot,
238
+ allowUntrustedLinkedTests: context.options.allowUntrustedLinkedTests,
239
+ untrustedLinkedTestsPolicyEnabled: context.settings.testing.allow_untrusted_linked_tests,
230
240
  })
231
241
  : [];
232
242
  let executedIndex = 0;
@@ -307,6 +317,8 @@ const appendTestAllItemTracking = async (entry, summary, runResults, context) =>
307
317
  command: result.command.trim(),
308
318
  requested_pm_context_mode: result.execution_context?.requested_pm_context_mode,
309
319
  pm_context_mode: result.execution_context?.pm_context_mode,
320
+ workspace_context_mode: result.execution_context?.workspace_context_mode,
321
+ trust_reason: result.execution_context?.trust.reason,
310
322
  })),
311
323
  },
312
324
  });
@@ -495,4 +507,4 @@ export const _testOnlyTestAll = {
495
507
  formatTrackingError,
496
508
  };
497
509
  //# sourceMappingURL=batch.js.map
498
- //# debugId=bb2758a5-a5c1-5f6e-be42-0e173fe16fe3
510
+ //# debugId=5d3405c0-14e6-51f5-97a1-355438fd0199
@@ -1,5 +1,5 @@
1
1
  /** Public contract for structured linked test keys, shared by SDK and presentation-layer consumers. */
2
- export declare const STRUCTURED_LINKED_TEST_KEYS: readonly ["command", "cmd", "path", "scope", "timeout", "timeout_seconds", "pm_context_mode", "env_set", "env_clear", "shared_host_safe", "assert_stdout_contains", "assert_stdout_regex", "assert_stderr_contains", "assert_stderr_regex", "assert_stdout_min_lines", "assert_json_field_equals", "assert_json_field_gte", "note"];
2
+ export declare const STRUCTURED_LINKED_TEST_KEYS: readonly ["command", "cmd", "path", "scope", "timeout", "timeout_seconds", "pm_context_mode", "workspace_context_mode", "env_set", "env_clear", "shared_host_safe", "assert_stdout_contains", "assert_stdout_regex", "assert_stderr_contains", "assert_stderr_regex", "assert_stdout_min_lines", "assert_json_field_equals", "assert_json_field_gte", "note"];
3
3
  /** Implements looks like structured linked test entry for the public runtime surface of this module. */
4
4
  export declare function looksLikeStructuredLinkedTestEntry(raw: string): boolean;
5
5
  /** Implements normalize structured linked test entry for the public runtime surface of this module. */