@vicary/pi-subagents 0.85.0 → 0.86.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 (51) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/bundle/agents.js +3 -3
  3. package/bundle/child-tool-plan.js +2 -2
  4. package/bundle/{chunk-QZL2ZZPM.js → chunk-2DITXA3H.js} +11 -11
  5. package/bundle/{chunk-KEY3UQMQ.js → chunk-374MZFF4.js} +1 -1
  6. package/bundle/{chunk-CS4O36CZ.js → chunk-3RKFH2UZ.js} +5 -5
  7. package/bundle/{chunk-7MAE3DJV.js → chunk-5H4BICQZ.js} +1 -1
  8. package/bundle/{chunk-RV5OGHLO.js → chunk-6VD7BGIC.js} +2 -2
  9. package/bundle/{chunk-KDMFBYFM.js → chunk-77ASNIEM.js} +1 -1
  10. package/bundle/{chunk-O7CPL6H4.js → chunk-7QA7ZA46.js} +9 -9
  11. package/bundle/{chunk-HFTBF7SG.js → chunk-7ZUFN6ME.js} +1 -1
  12. package/bundle/{chunk-LTPH2DXH.js → chunk-BGXEAYUM.js} +3 -3
  13. package/bundle/{chunk-JO67XSKD.js → chunk-BU6PFPVX.js} +4 -4
  14. package/bundle/{chunk-A7VJ5XXE.js → chunk-CJHFDQFJ.js} +4 -4
  15. package/bundle/{chunk-B3OOJJA6.js → chunk-DD22RXYJ.js} +39 -45
  16. package/bundle/{chunk-LGMILZNE.js → chunk-GJGTMLPE.js} +2 -2
  17. package/bundle/{chunk-HS4WPO6B.js → chunk-GLVJMI6R.js} +5 -5
  18. package/bundle/{chunk-PHZP3KHB.js → chunk-GRJHIXYF.js} +1 -1
  19. package/bundle/{chunk-QO75KJBT.js → chunk-LGINOOY5.js} +2 -2
  20. package/bundle/{chunk-GCSLVFCX.js → chunk-NAFLUJ26.js} +1 -1
  21. package/bundle/{chunk-PVIVCDG2.js → chunk-PYOAIN3V.js} +2 -2
  22. package/bundle/{chunk-YZBCREP5.js → chunk-QFLPV64W.js} +35 -31
  23. package/bundle/{chunk-UX4SCV5N.js → chunk-QGO6HXHG.js} +80 -35
  24. package/bundle/{chunk-H2NLFTC5.js → chunk-S2Q75LP3.js} +1 -1
  25. package/bundle/{chunk-KZ34KQQH.js → chunk-UR7OW5S7.js} +4 -4
  26. package/bundle/{chunk-VEZMZDTW.js → chunk-WHC2XHGF.js} +24 -23
  27. package/bundle/{chunk-L2ENOFVZ.js → chunk-WN2E5XHN.js} +66 -26
  28. package/bundle/{chunk-JHBQ7N2L.js → chunk-XOFYXQKZ.js} +2 -2
  29. package/bundle/{chunk-N7B2KD74.js → chunk-YK3QYNLE.js} +1 -1
  30. package/bundle/{chunk-T5V5BRCL.js → chunk-ZPY5QZCS.js} +1 -1
  31. package/bundle/control-channel.js +2 -2
  32. package/bundle/index.js +1 -1
  33. package/bundle/intercom-bridge.js +2 -2
  34. package/bundle/preflight.js +8 -8
  35. package/bundle/project-panes.js +3 -3
  36. package/docs/agents.md +6 -0
  37. package/docs/configuration.md +2 -2
  38. package/docs/tool-reference.md +2 -0
  39. package/package.json +2 -2
  40. package/src/extension/tool-activation.js +10 -1
  41. package/src/extension/tool-description.d.ts +1 -1
  42. package/src/extension/tool-description.js +8 -8
  43. package/src/runs/background/run-status.js +5 -4
  44. package/src/runs/background/subagent-runner.js +6 -6
  45. package/src/runs/shared/acceptance.js +69 -26
  46. package/src/runs/shared/external-cli-contract.d.ts +49 -0
  47. package/src/runs/shared/external-cli-contract.js +18 -13
  48. package/src/runs/shared/structured-output.js +10 -3
  49. package/src/shared/types.d.ts +57 -48
  50. package/src/tui/render.js +83 -22
  51. package/src/workflows/workflow-receipt.js +36 -53
@@ -10,10 +10,10 @@ import {
10
10
  setInlineWorkflowCoverage,
11
11
  setMainThinkingLevelSource,
12
12
  widgetRenderKey
13
- } from "./chunk-L2ENOFVZ.js";
13
+ } from "./chunk-WN2E5XHN.js";
14
14
  import {
15
15
  package_default
16
- } from "./chunk-HFTBF7SG.js";
16
+ } from "./chunk-7ZUFN6ME.js";
17
17
  import {
18
18
  EXTERNAL_JOB_BRIDGE_REQUEST_DIR,
19
19
  REVIVAL_ORIGIN_FILE,
@@ -62,7 +62,7 @@ import {
62
62
  snapshotProviderDiagnostics,
63
63
  workflowResumeClaimState,
64
64
  workflowResumeRefusal
65
- } from "./chunk-B3OOJJA6.js";
65
+ } from "./chunk-DD22RXYJ.js";
66
66
  import {
67
67
  SUBAGENT_CHILD_ENV,
68
68
  SUBAGENT_PARENT_SESSION_ENV,
@@ -82,14 +82,14 @@ import {
82
82
  resolvePiSessionId,
83
83
  resolveWaitToolConfig,
84
84
  setDeclarationPinning
85
- } from "./chunk-A7VJ5XXE.js";
85
+ } from "./chunk-CJHFDQFJ.js";
86
86
  import {
87
87
  deliverAsyncRunStop,
88
88
  ownerConfirmedDead,
89
89
  readSessionMessagesTail,
90
90
  resolveSubagentRunId,
91
91
  restoreForegroundRunHistory
92
- } from "./chunk-KZ34KQQH.js";
92
+ } from "./chunk-UR7OW5S7.js";
93
93
  import {
94
94
  ASYNC_STATUS_SNAPSHOT_KIND,
95
95
  ASYNC_STATUS_SNAPSHOT_VERSION,
@@ -105,7 +105,7 @@ import {
105
105
  resolveAsyncStatusChild,
106
106
  runLaunchDir,
107
107
  stopStoppableAsyncStatusChildren
108
- } from "./chunk-LTPH2DXH.js";
108
+ } from "./chunk-BGXEAYUM.js";
109
109
  import {
110
110
  CONTACT_SUPERVISOR_TOOL_NAME,
111
111
  NATIVE_SUPERVISOR_TOOL_NAME,
@@ -115,7 +115,7 @@ import {
115
115
  parseSupervisorReplyData,
116
116
  parseSupervisorRequestDetails,
117
117
  topLevelSupervisorTool
118
- } from "./chunk-T5V5BRCL.js";
118
+ } from "./chunk-ZPY5QZCS.js";
119
119
  import {
120
120
  MODEL_ONLY_TOOL,
121
121
  canRenderComponents,
@@ -140,7 +140,7 @@ import {
140
140
  resolveDisabledFeatureSurface,
141
141
  resolveMaxActiveAsyncRunsPerSession,
142
142
  resolveScheduledStoreRoot
143
- } from "./chunk-RV5OGHLO.js";
143
+ } from "./chunk-6VD7BGIC.js";
144
144
  import {
145
145
  ACTIVE_RUN_INDEX_DIR,
146
146
  MissionNotFoundError,
@@ -191,28 +191,28 @@ import {
191
191
  withWorkflowChildRunModel,
192
192
  writeAsyncResultFile,
193
193
  writeResultIndexForData
194
- } from "./chunk-LGMILZNE.js";
195
- import "./chunk-7MAE3DJV.js";
194
+ } from "./chunk-GJGTMLPE.js";
195
+ import "./chunk-5H4BICQZ.js";
196
196
  import {
197
197
  shouldUseNativeFsWatch
198
198
  } from "./chunk-NIXWDZZV.js";
199
199
  import {
200
200
  validateIntercomBridgeConfig
201
- } from "./chunk-KDMFBYFM.js";
201
+ } from "./chunk-77ASNIEM.js";
202
202
  import "./chunk-7F6RKT6W.js";
203
- import "./chunk-KEY3UQMQ.js";
203
+ import "./chunk-374MZFF4.js";
204
204
  import "./chunk-CTPAE36Y.js";
205
205
  import {
206
206
  listHerdrProjectPaneRoots,
207
207
  restoreHerdrProjectPaneSnapshots
208
- } from "./chunk-PVIVCDG2.js";
208
+ } from "./chunk-PYOAIN3V.js";
209
209
  import "./chunk-7J4ZXMY7.js";
210
210
  import {
211
211
  cleanupAllArtifactDirs,
212
212
  cleanupOldArtifacts,
213
213
  getArtifactPaths,
214
214
  getArtifactsDir
215
- } from "./chunk-PHZP3KHB.js";
215
+ } from "./chunk-GRJHIXYF.js";
216
216
  import {
217
217
  listBackgroundWorkProviders
218
218
  } from "./chunk-XA3DY6UG.js";
@@ -220,12 +220,12 @@ import "./chunk-YYREO77V.js";
220
220
  import "./chunk-UKG4V45O.js";
221
221
  import {
222
222
  registerRuntimeAgentEventListener
223
- } from "./chunk-H2NLFTC5.js";
223
+ } from "./chunk-S2Q75LP3.js";
224
224
  import {
225
225
  clearRuntimeAgentsForPi,
226
226
  listRuntimeAgentConfigs,
227
227
  mergeRuntimeAgents
228
- } from "./chunk-GCSLVFCX.js";
228
+ } from "./chunk-NAFLUJ26.js";
229
229
  import {
230
230
  DEFAULT_FILE_SYSTEM_RETRY_DELAYS_MS,
231
231
  DEFAULT_WAIT_TOOL_NAME,
@@ -268,7 +268,7 @@ import {
268
268
  waitToolName,
269
269
  withSettingsFileLease,
270
270
  writeAtomicJson
271
- } from "./chunk-UX4SCV5N.js";
271
+ } from "./chunk-QGO6HXHG.js";
272
272
  import {
273
273
  DEFAULT_ARTIFACT_CONFIG,
274
274
  DIRS,
@@ -5360,7 +5360,7 @@ function registerSlashCommands(pi, state, options = {}) {
5360
5360
  }
5361
5361
  fleetOpen = true;
5362
5362
  try {
5363
- const { openSubagentFleet } = await import("./chunk-O7CPL6H4.js");
5363
+ const { openSubagentFleet } = await import("./chunk-7QA7ZA46.js");
5364
5364
  await openSubagentFleet(ctx, state, { asyncDirRoot: DIRS.async, inspectorPlugins: () => getInspectorPlugins(pi), resultsDir: DIRS.results, fleetKeybindings: options.fleetKeybindings });
5365
5365
  } finally {
5366
5366
  fleetOpen = false;
@@ -7990,7 +7990,12 @@ function applyRecordedSelection(pi, ctx, mode, replyOwed) {
7990
7990
  const available = pi.getAllTools();
7991
7991
  if (!Array.isArray(available) || !Array.isArray(pi.getActiveTools())) return true;
7992
7992
  if (!available.some((tool) => tool.name === LOADER_NAME)) return true;
7993
- const messages = ctx.sessionManager.buildSessionContext().messages;
7993
+ let messages = ctx.sessionManager.buildSessionContext().messages;
7994
+ if (messages[0]?.role === "system" && messages[1]?.role === "compactionSummary") {
7995
+ const branch = ctx.sessionManager.getBranch();
7996
+ const history = branch.slice(0, branch.findLastIndex((entry) => entry.type === "compaction")).flatMap((entry) => entry.type === "message" && entry.message.role === "system" ? [entry.message] : []);
7997
+ messages = [...history, ...messages.slice(1)];
7998
+ }
7994
7999
  const lost = messages.find((message2) => message2.role === "system" || message2.role === "compactionSummary")?.role === "compactionSummary";
7995
8000
  if (lost || hasNativeToolSelection(messages)) {
7996
8001
  const recorded = /* @__PURE__ */ new Set();
@@ -8164,7 +8169,6 @@ var allEnabled = featureText(resolveDisabledFeatureSurface({}));
8164
8169
  var DEFAULT_SUBAGENT_TOOL_DESCRIPTION = essentials(allEnabled);
8165
8170
  var SUBAGENT_TOOL_PROMPT_SNIPPET = "Delegate focused work to child agents; compose multi-child work in one workflow call.";
8166
8171
  var STRUCTURED_SUBAGENT_TOOL_PROMPT_SNIPPET = "Delegate focused work to child agents; compose multi-child work in one chain or tasks call.";
8167
- var COMPACT_SUBAGENT_TOOL_DESCRIPTION = DEFAULT_SUBAGENT_TOOL_DESCRIPTION;
8168
8172
  var FULL_SUBAGENT_TOOL_DESCRIPTION = fullDescription(allEnabled);
8169
8173
  function isToolDescriptionMode(value) {
8170
8174
  return value === "full" || value === "compact" || value === "custom";
@@ -8191,15 +8195,15 @@ function customDescriptionPaths(options) {
8191
8195
  path12.join(agentDir, CUSTOM_TOOL_DESCRIPTION_FILE)
8192
8196
  ];
8193
8197
  }
8194
- function renderCustomTemplate(template, options) {
8198
+ function renderCustomTemplate(template, on, options) {
8195
8199
  const cwd = options?.cwd ?? process.cwd();
8196
8200
  const agentDir = options?.agentDir ?? getAgentDir();
8197
8201
  const projectConfigDir = getProjectConfigDir(cwd);
8198
8202
  const variables = {
8199
- fullDescription: () => FULL_SUBAGENT_TOOL_DESCRIPTION,
8200
- full: () => FULL_SUBAGENT_TOOL_DESCRIPTION,
8201
- compactDescription: () => COMPACT_SUBAGENT_TOOL_DESCRIPTION,
8202
- compact: () => COMPACT_SUBAGENT_TOOL_DESCRIPTION,
8203
+ fullDescription: () => fullDescription(on),
8204
+ full: () => fullDescription(on),
8205
+ compactDescription: () => essentials(on),
8206
+ compact: () => essentials(on),
8203
8207
  safetyGuidance: () => SUBAGENT_SAFETY_GUIDANCE,
8204
8208
  safety: () => SUBAGENT_SAFETY_GUIDANCE,
8205
8209
  agentDir: () => agentDir,
@@ -8212,7 +8216,7 @@ function renderCustomTemplate(template, options) {
8212
8216
  return raw;
8213
8217
  });
8214
8218
  }
8215
- function loadCustomToolDescription(options) {
8219
+ function loadCustomToolDescription(on, options) {
8216
8220
  for (const filePath of customDescriptionPaths(options)) {
8217
8221
  let stat;
8218
8222
  try {
@@ -8236,7 +8240,7 @@ function loadCustomToolDescription(options) {
8236
8240
  warn(options, `Ignoring empty custom tool description '${filePath}'.`);
8237
8241
  continue;
8238
8242
  }
8239
- const rendered = renderCustomTemplate(template, options).trim();
8243
+ const rendered = renderCustomTemplate(template, on, options).trim();
8240
8244
  if (!rendered) {
8241
8245
  warn(options, `Ignoring custom tool description '${filePath}' because it rendered empty.`);
8242
8246
  continue;
@@ -8265,7 +8269,7 @@ function describeSubagentTool(config, options) {
8265
8269
  const mode = resolveToolDescriptionMode(config, options);
8266
8270
  if (mode === "compact") return essentials(on);
8267
8271
  if (mode === "custom") {
8268
- const custom = loadCustomToolDescription(options);
8272
+ const custom = loadCustomToolDescription(on, options);
8269
8273
  if (custom) return withMandatorySafetyGuidance(custom);
8270
8274
  warn(options, `${CUSTOM_TOOL_DESCRIPTION_FILE} was not found or valid for toolDescriptionMode "custom"; using full description.`);
8271
8275
  }
@@ -8761,7 +8765,7 @@ function registerSubagentExtension(pi) {
8761
8765
  const ctx = withLastUiContext((current) => current);
8762
8766
  if (!ctx) return;
8763
8767
  try {
8764
- const { openSubagentFleet } = await import("./chunk-O7CPL6H4.js");
8768
+ const { openSubagentFleet } = await import("./chunk-7QA7ZA46.js");
8765
8769
  await openSubagentFleet(ctx, state, { initialKey: itemKey, asyncDirRoot: DIRS.async, resultsDir: DIRS.results, fleetKeybindings: config.fleetKeybindings, inspectorPlugins: () => getInspectorPlugins(pi) });
8766
8770
  } catch (error) {
8767
8771
  if (isStaleExtensionContextError(error)) {
@@ -8970,7 +8974,7 @@ function registerSubagentExtension(pi) {
8970
8974
  let executor;
8971
8975
  let executorPromise;
8972
8976
  let executorModulePromise;
8973
- const loadExecutorModule = () => executorModulePromise ??= import("./chunk-VEZMZDTW.js");
8977
+ const loadExecutorModule = () => executorModulePromise ??= import("./chunk-WHC2XHGF.js");
8974
8978
  const getExecutor = () => {
8975
8979
  executorPromise ??= loadExecutorModule().then(({ createSubagentExecutor }) => {
8976
8980
  executor = createSubagentExecutor(executorDeps);
@@ -8984,7 +8988,7 @@ function registerSubagentExtension(pi) {
8984
8988
  modulePreloadTimer = setTimeout(() => {
8985
8989
  loadExecutorModule().catch(() => {
8986
8990
  });
8987
- if (fleetViewEnabled) import("./chunk-O7CPL6H4.js").catch(() => {
8991
+ if (fleetViewEnabled) import("./chunk-7QA7ZA46.js").catch(() => {
8988
8992
  });
8989
8993
  }, MODULE_PRELOAD_DELAY_MS);
8990
8994
  modulePreloadTimer.unref?.();
@@ -171,6 +171,14 @@ function validateCodeOwnedProfileRunner(agent) {
171
171
  }
172
172
  return void 0;
173
173
  }
174
+ var EXTERNAL_CLI_ADAPTER_SAFETY = {
175
+ "codex-exec": { sandbox: "read-only", approvalPolicy: "never", ephemeral: true },
176
+ "codex-exec-writer": { access: "workspace-write", sandbox: "workspace-write", approvalPolicy: "never", ephemeral: true },
177
+ "claude-code": { access: "read-only", authentication: "existing-cli-required", permissionMode: "plan", tools: "none", mcp: "empty-strict", settingSources: "user", userSettingsTrust: "required", sessionPersistence: false },
178
+ "claude-code-writer": { access: "workspace-write", authentication: "existing-cli-required", permissionMode: "acceptEdits", tools: "Read,Write,Edit,Glob,Grep", mcp: "empty-strict", settingSources: "user", userSettingsTrust: "required", sessionPersistence: false },
179
+ "cursor-agent": { access: "read-only", authentication: "cursor-api-key-or-existing-login", mode: "ask", sandbox: "enabled", workspaceTrust: "existing-required", sessionReuse: false },
180
+ "cursor-agent-writer": { access: "workspace-write", authentication: "cursor-api-key-or-existing-login", mode: "print", sandbox: "enabled", workspaceTrust: "existing-required", sessionReuse: false }
181
+ };
174
182
  function parseExternalCliCapabilityNarrowing(value, label) {
175
183
  if (value === void 0) return void 0;
176
184
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} must be an object.`);
@@ -183,13 +191,8 @@ function parseExternalCliCapabilityNarrowing(value, label) {
183
191
  return input;
184
192
  }
185
193
  function resolveExternalCliRunnerStatus(input) {
186
- const codexExec = input.adapter === "codex-exec";
187
- const codexExecWriter = input.adapter === "codex-exec-writer";
188
- const claudeCode = input.adapter === "claude-code";
189
- const claudeCodeWriter = input.adapter === "claude-code-writer";
190
- const cursorAgent = input.adapter === "cursor-agent";
191
- const cursorAgentWriter = input.adapter === "cursor-agent-writer";
192
- const cursor = cursorAgent || cursorAgentWriter;
194
+ const cursor = input.adapter === "cursor-agent" || input.adapter === "cursor-agent-writer";
195
+ const profileSafety = input.adapter ? EXTERNAL_CLI_ADAPTER_SAFETY[input.adapter] : void 0;
193
196
  const unsupported = cursor ? PROMPT_FILE_UNSUPPORTED : UNSUPPORTED;
194
197
  return {
195
198
  type: "external-cli",
@@ -197,12 +200,11 @@ function resolveExternalCliRunnerStatus(input) {
197
200
  args: input.args ?? [],
198
201
  promptDelivery: cursor ? "prompt-file" : input.promptDelivery ?? "stdin",
199
202
  adapter: { id: input.adapter ?? "external-cli", version: 1, executionMode: cursor ? "one-shot-prompt-file" : "one-shot-stdin" },
200
- ...codexExec ? { safety: { sandbox: "read-only", approvalPolicy: "never", ephemeral: true } } : {},
201
- ...codexExecWriter ? { safety: { access: "workspace-write", sandbox: "workspace-write", approvalPolicy: "never", ephemeral: true } } : {},
202
- ...claudeCode ? { safety: { access: "read-only", authentication: "existing-cli-required", permissionMode: "plan", tools: "none", mcp: "empty-strict", settingSources: "user", userSettingsTrust: "required", sessionPersistence: false } } : {},
203
- ...claudeCodeWriter ? { safety: { access: "workspace-write", authentication: "existing-cli-required", permissionMode: "acceptEdits", tools: "Read,Write,Edit,Glob,Grep", mcp: "empty-strict", settingSources: "user", userSettingsTrust: "required", sessionPersistence: false } } : {},
204
- ...cursorAgent ? { safety: { access: "read-only", authentication: "cursor-api-key-or-existing-login", mode: "ask", sandbox: "enabled", workspaceTrust: "existing-required", sessionReuse: false } } : {},
205
- ...cursorAgentWriter ? { safety: { access: "workspace-write", authentication: "cursor-api-key-or-existing-login", mode: "print", sandbox: "enabled", workspaceTrust: "existing-required", sessionReuse: false } } : {},
203
+ ...profileSafety ? {
204
+ safety: { ...profileSafety },
205
+ // A Herdr saved machine launches the remote adapter binary, never runner.command.
206
+ safetySource: { measured: false, ...input.machine ? {} : { command: input.command } }
207
+ } : {},
206
208
  ...input.machine ? { machine: input.machine } : {},
207
209
  capabilities: {
208
210
  stop: true,
@@ -250,6 +252,7 @@ function externalCliReceiptMetadata(input) {
250
252
  capabilities: { ...runner.capabilities },
251
253
  ...machine ? { machine: { ...machine, ...machine.remoteGit ? { remoteGit: { ...machine.remoteGit } } : {} } } : {},
252
254
  ...runner.safety ? { safety: { ...runner.safety } } : {},
255
+ ...runner.safetySource ? { safetySource: { ...runner.safetySource } } : {},
253
256
  ...input.externalProcess ? {
254
257
  outputArtifacts: {
255
258
  stdoutPath: input.externalProcess.stdoutPath,
@@ -1812,8 +1815,13 @@ function validateWithCompile(compile, schema, value) {
1812
1815
  } catch (error) {
1813
1816
  return { status: "invalid", message: `invalid outputSchema: ${error instanceof Error ? error.message : String(error)}` };
1814
1817
  }
1815
- if (validator.Check(value)) return { status: "valid" };
1816
- const originalErrors = [...validator.Errors(value)];
1818
+ let originalErrors;
1819
+ try {
1820
+ if (validator.Check(value)) return { status: "valid" };
1821
+ originalErrors = [...validator.Errors(value)];
1822
+ } catch (error) {
1823
+ return { status: "invalid", message: `outputSchema cannot be validated (cyclic or too deep): ${error instanceof Error ? error.message : String(error)}` };
1824
+ }
1817
1825
  const errors = [];
1818
1826
  const uniqueErrors = /* @__PURE__ */ new Set();
1819
1827
  const seen = /* @__PURE__ */ new Set();
@@ -3203,12 +3211,30 @@ function verifyRedactionEnv(env) {
3203
3211
  return value.length >= 4 && SENSITIVE_ENV_KEY_PATTERN.test(key);
3204
3212
  }));
3205
3213
  }
3206
- function redactVerifyEnv(value, env) {
3214
+ function verifySecrets(env) {
3215
+ return [...new Set(Object.values(verifyRedactionEnv(env)).filter(Boolean))].sort((left, right) => right.length - left.length);
3216
+ }
3217
+ function redactSecrets(value, secrets) {
3207
3218
  let redacted = value;
3208
- const secrets = [...new Set(Object.values(verifyRedactionEnv(env)).filter(Boolean))].sort((left, right) => right.length - left.length);
3209
3219
  for (const secret of secrets) redacted = redacted.replaceAll(secret, "[REDACTED]");
3210
3220
  return redacted;
3211
3221
  }
3222
+ function redactVerifyEnv(value, env) {
3223
+ return redactSecrets(value, verifySecrets(env));
3224
+ }
3225
+ function parseRedactedVerifyValue(text, secrets) {
3226
+ return JSON.parse(text, (_key, value, context) => {
3227
+ if (typeof value === "string") return redactSecrets(value, secrets);
3228
+ if (typeof value === "number" && secrets.length > 0) {
3229
+ const source = context?.source;
3230
+ return source !== void 0 && redactSecrets(source, secrets) === source ? value : "[REDACTED]";
3231
+ }
3232
+ if (value && typeof value === "object" && !Array.isArray(value)) {
3233
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [redactSecrets(key, secrets), item]));
3234
+ }
3235
+ return value;
3236
+ });
3237
+ }
3212
3238
  var DEFAULT_VERIFY_TIMEOUT_MS = 12e4;
3213
3239
  function hash(value) {
3214
3240
  return createHash2("sha256").update(value).digest("hex");
@@ -3234,32 +3260,48 @@ function isCachedVerifyResult(value) {
3234
3260
  return typeof result.id === "string" && typeof result.command === "string" && (typeof result.exitCode === "number" || result.exitCode === null) && (result.status === "passed" || result.status === "failed" || result.status === "timed-out" || result.status === "allowed-failure") && typeof result.durationMs === "number";
3235
3261
  }
3236
3262
  var TYPED_VERIFY_OUTPUT_MAX_BYTES = 12e3;
3237
- async function applyTypedVerifyOutput(command, run) {
3263
+ async function applyTypedVerifyOutput(command, run, rawStdout) {
3238
3264
  if (run.status !== "passed") return;
3239
- const stdout = run.stdout ?? "";
3265
+ const secrets = verifySecrets(command.env);
3266
+ const stdout = rawStdout.trim();
3240
3267
  const fail = (message) => {
3241
3268
  run.status = "failed";
3242
- run.structuredOutputError = message;
3269
+ run.structuredOutputError = redactSecrets(message, secrets);
3243
3270
  };
3244
- if (!stdout.trim()) return fail('output: "json" command printed nothing on stdout.');
3245
- if (stdout.endsWith("...[truncated]")) return fail(`output: "json" stdout exceeded ${TYPED_VERIFY_OUTPUT_MAX_BYTES} characters and was truncated.`);
3271
+ if (!stdout) return fail('output: "json" command printed nothing on stdout.');
3272
+ if (stdout.length > TYPED_VERIFY_OUTPUT_MAX_BYTES) return fail(`output: "json" stdout exceeded ${TYPED_VERIFY_OUTPUT_MAX_BYTES} characters and was truncated.`);
3246
3273
  let value;
3247
3274
  try {
3248
3275
  value = JSON.parse(stdout);
3249
- } catch (error) {
3250
- return fail(`output: "json" stdout is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
3276
+ } catch {
3277
+ let reason = "parse failed";
3278
+ try {
3279
+ JSON.parse(redactSecrets(stdout, secrets));
3280
+ } catch (error) {
3281
+ reason = error instanceof Error ? error.message : String(error);
3282
+ }
3283
+ return fail(`output: "json" stdout is not valid JSON: ${reason}`);
3251
3284
  }
3285
+ const redactedValue = parseRedactedVerifyValue(stdout, secrets);
3252
3286
  if (command.schema) {
3253
3287
  const validation = await validateStructuredOutputValue(command.schema, value);
3254
- if (validation.status === "invalid") return fail(`output: "json" stdout does not match gate.schema: ${validation.message}`);
3288
+ if (validation.status === "invalid") {
3289
+ const redactedValidation = await validateStructuredOutputValue(command.schema, redactedValue);
3290
+ return fail(`output: "json" stdout does not match gate.schema${redactedValidation.status === "invalid" ? `: ${redactedValidation.message}` : "."}`);
3291
+ }
3255
3292
  }
3256
- run.structuredOutput = value;
3293
+ run.structuredOutput = redactedValue;
3257
3294
  }
3258
3295
  function typedVerifyOutput(ledger) {
3259
3296
  const run = ledger?.verifyRuns?.find((entry) => entry.structuredOutput !== void 0);
3260
3297
  return run ? { value: run.structuredOutput } : void 0;
3261
3298
  }
3262
3299
  async function runMemoizedVerifyCommand(command, defaultCwd, options = {}) {
3300
+ if (command.output === "json") {
3301
+ const { run, rawStdout } = await runVerifyCommand(command, defaultCwd, options);
3302
+ await applyTypedVerifyOutput(command, run, rawStdout);
3303
+ return run;
3304
+ }
3263
3305
  const cwd = command.cwd ? path8.resolve(defaultCwd, command.cwd) : defaultCwd;
3264
3306
  let workspaceState;
3265
3307
  try {
@@ -3267,8 +3309,8 @@ async function runMemoizedVerifyCommand(command, defaultCwd, options = {}) {
3267
3309
  } catch {
3268
3310
  workspaceState = void 0;
3269
3311
  }
3270
- if (!workspaceState || !options.artifactsDir || !options.runId || command.output === "json") {
3271
- return runVerifyCommand(command, defaultCwd, options);
3312
+ if (!workspaceState || !options.artifactsDir || !options.runId) {
3313
+ return (await runVerifyCommand(command, defaultCwd, options)).run;
3272
3314
  }
3273
3315
  const envKeys = Object.keys(command.env ?? {}).sort();
3274
3316
  const envHash = hash(JSON.stringify(Object.fromEntries(Object.entries(effectiveVerifyEnv(command.env)).sort(([left], [right]) => left.localeCompare(right)))));
@@ -3292,7 +3334,7 @@ async function runMemoizedVerifyCommand(command, defaultCwd, options = {}) {
3292
3334
  }
3293
3335
  } catch {
3294
3336
  }
3295
- const result = await runVerifyCommand(command, defaultCwd, options);
3337
+ const { run: result } = await runVerifyCommand(command, defaultCwd, options);
3296
3338
  const evidenced = { ...result, artifactPath, cacheKey, memoized: false, envKeys, envHash, workspaceState };
3297
3339
  try {
3298
3340
  fs8.mkdirSync(path8.dirname(artifactPath), { recursive: true });
@@ -3366,11 +3408,14 @@ function runVerifyCommand(command, defaultCwd, options = {}) {
3366
3408
  if (hardKill) clearTimeout(hardKill);
3367
3409
  options.signal?.removeEventListener("abort", abortVerification);
3368
3410
  resolve12({
3369
- id: command.id,
3370
- command: command.command,
3371
- cwd,
3372
- durationMs: Date.now() - startedAt,
3373
- ...result
3411
+ run: {
3412
+ id: command.id,
3413
+ command: command.command,
3414
+ cwd,
3415
+ durationMs: Date.now() - startedAt,
3416
+ ...result
3417
+ },
3418
+ rawStdout: stdout
3374
3419
  });
3375
3420
  };
3376
3421
  const abortVerification = () => {
@@ -3492,7 +3537,6 @@ async function evaluateAcceptance(input) {
3492
3537
  artifactsDir: input.artifactsDir,
3493
3538
  runId: input.runId
3494
3539
  });
3495
- if (command.output === "json") await applyTypedVerifyOutput(command, run);
3496
3540
  ledger.verifyRuns.push(run);
3497
3541
  if (input.signal?.aborted) break;
3498
3542
  }
@@ -8550,6 +8594,7 @@ export {
8550
8594
  CODE_OWNED_EXTERNAL_CLI_ADAPTER_LABEL,
8551
8595
  isCodeOwnedExternalCliAdapterId,
8552
8596
  validateCodeOwnedProfileRunner,
8597
+ EXTERNAL_CLI_ADAPTER_SAFETY,
8553
8598
  parseExternalCliCapabilityNarrowing,
8554
8599
  resolveExternalCliRunnerStatus,
8555
8600
  normalizeExternalCliRunnerStatus,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  registerRuntimeAgent
3
- } from "./chunk-GCSLVFCX.js";
3
+ } from "./chunk-NAFLUJ26.js";
4
4
 
5
5
  // src/agents/runtime-agent-events.ts
6
6
  var RUNTIME_AGENT_REGISTER_EVENT = "pi-subagents:runtime-agent-register:v1";
@@ -12,7 +12,7 @@ import {
12
12
  summarizeContextModes,
13
13
  utf8Tail,
14
14
  workflowPreflightLaneForRuntimeKey
15
- } from "./chunk-LTPH2DXH.js";
15
+ } from "./chunk-BGXEAYUM.js";
16
16
  import {
17
17
  ownsRun
18
18
  } from "./chunk-HXRB42AF.js";
@@ -34,11 +34,11 @@ import {
34
34
  updateActiveRunIndex,
35
35
  validateModelResponseAliases,
36
36
  writeAsyncResultFile
37
- } from "./chunk-LGMILZNE.js";
37
+ } from "./chunk-GJGTMLPE.js";
38
38
  import {
39
39
  deliverStopRequest,
40
40
  stopInboxClosedPath
41
- } from "./chunk-7MAE3DJV.js";
41
+ } from "./chunk-5H4BICQZ.js";
42
42
  import {
43
43
  SUBAGENT_STOPPED_MESSAGE,
44
44
  formatDuration,
@@ -50,7 +50,7 @@ import {
50
50
  waitToolName,
51
51
  writeAtomicJson,
52
52
  writePrivateAtomicJson
53
- } from "./chunk-UX4SCV5N.js";
53
+ } from "./chunk-QGO6HXHG.js";
54
54
  import {
55
55
  DIRS
56
56
  } from "./chunk-JEZOSEWG.js";
@@ -3,7 +3,7 @@ import {
3
3
  projectRuntimeAcknowledgedExtensions,
4
4
  registerSubagentPromptBoundary,
5
5
  registerSubagentPromptRuntime
6
- } from "./chunk-HS4WPO6B.js";
6
+ } from "./chunk-GLVJMI6R.js";
7
7
  import {
8
8
  INSPECTOR_ACTIONS,
9
9
  canQueueRetainedAsyncFollowUp,
@@ -25,12 +25,12 @@ import {
25
25
  updateSteeringTarget,
26
26
  waitForSteeringAction,
27
27
  workflowAsyncChildSteeringGuidance
28
- } from "./chunk-CS4O36CZ.js";
28
+ } from "./chunk-3RKFH2UZ.js";
29
29
  import {
30
30
  PLACED_RESTORE_UNSUPPORTED,
31
31
  formatHerdrMachineRunnerUnsupported,
32
32
  resolveMachinePlacement
33
- } from "./chunk-N7B2KD74.js";
33
+ } from "./chunk-YK3QYNLE.js";
34
34
  import {
35
35
  COMPLETION_ACTION,
36
36
  DEFAULT_CONTROL_CONFIG,
@@ -119,7 +119,7 @@ import {
119
119
  workflowScriptDigest,
120
120
  workflowStopCause,
121
121
  writeWorkflowReceipt
122
- } from "./chunk-B3OOJJA6.js";
122
+ } from "./chunk-DD22RXYJ.js";
123
123
  import {
124
124
  SUBAGENT_PARENT_SESSION_ENV,
125
125
  applyWatchdogLaunchRules,
@@ -132,7 +132,7 @@ import {
132
132
  resolveWatchdogConfig,
133
133
  sendRuleViolationWarning,
134
134
  writeWatchdogModelSettings
135
- } from "./chunk-A7VJ5XXE.js";
135
+ } from "./chunk-CJHFDQFJ.js";
136
136
  import {
137
137
  MAX_REMEMBERED_FOREGROUND_RUNS,
138
138
  discardRunningForegroundRun,
@@ -145,7 +145,7 @@ import {
145
145
  resolveSubagentRunId,
146
146
  resolveWorkflowChatProgress,
147
147
  stopAsyncRun
148
- } from "./chunk-KZ34KQQH.js";
148
+ } from "./chunk-UR7OW5S7.js";
149
149
  import {
150
150
  RunFanoutLimitError,
151
151
  annotateWorkflowPreflightTrace,
@@ -206,12 +206,12 @@ import {
206
206
  writeRunFanoutBudgetDescriptor,
207
207
  writeWorkflowLaunchRecord,
208
208
  writeWorktreeSetupHandoff
209
- } from "./chunk-LTPH2DXH.js";
209
+ } from "./chunk-BGXEAYUM.js";
210
210
  import {
211
211
  NATIVE_SUPERVISOR_TOOL_NAME,
212
212
  createNativeSupervisorChannel,
213
213
  resolveSupervisorChannelDir
214
- } from "./chunk-T5V5BRCL.js";
214
+ } from "./chunk-ZPY5QZCS.js";
215
215
  import {
216
216
  MODEL_ONLY_TOOL,
217
217
  inheritedSessionIds,
@@ -234,10 +234,10 @@ import {
234
234
  canPreferFork,
235
235
  createForkContextResolver,
236
236
  resolveSubagentLaunchContext
237
- } from "./chunk-JHBQ7N2L.js";
237
+ } from "./chunk-XOFYXQKZ.js";
238
238
  import {
239
239
  handleRefinementAction
240
- } from "./chunk-QO75KJBT.js";
240
+ } from "./chunk-LGINOOY5.js";
241
241
  import {
242
242
  ActiveAsyncCapacityError,
243
243
  acquireActiveAsyncCapacity,
@@ -252,7 +252,7 @@ import {
252
252
  resolveDisabledFeatureSurface,
253
253
  resolveMaxActiveAsyncRunsPerSession,
254
254
  transferActiveAsyncCapacity
255
- } from "./chunk-RV5OGHLO.js";
255
+ } from "./chunk-6VD7BGIC.js";
256
256
  import {
257
257
  DEFAULT_STALE_TERMINAL_ACTIVE_MARKER_MS,
258
258
  MACHINE_DIFF_OPTIONS,
@@ -338,7 +338,7 @@ import {
338
338
  writeNestedControlRequest,
339
339
  writeNestedControlResult,
340
340
  writeNestedEvent
341
- } from "./chunk-LGMILZNE.js";
341
+ } from "./chunk-GJGTMLPE.js";
342
342
  import {
343
343
  closeSteerInbox,
344
344
  consumeSteerRequests,
@@ -346,7 +346,7 @@ import {
346
346
  readRevivalBriefs,
347
347
  requestAsyncSteer,
348
348
  watchAsyncControlInbox
349
- } from "./chunk-7MAE3DJV.js";
349
+ } from "./chunk-5H4BICQZ.js";
350
350
  import "./chunk-NIXWDZZV.js";
351
351
  import {
352
352
  INTERCOM_BRIDGE_MARKER,
@@ -355,7 +355,7 @@ import {
355
355
  resolveIntercomBridge,
356
356
  resolveIntercomSessionTarget,
357
357
  resolveSubagentIntercomTarget
358
- } from "./chunk-KDMFBYFM.js";
358
+ } from "./chunk-77ASNIEM.js";
359
359
  import {
360
360
  agentDefinitionDigest,
361
361
  resolveLaunchBinding,
@@ -370,7 +370,7 @@ import {
370
370
  resolvePiLaunchToolPlan,
371
371
  resolveRuntimeModulePath,
372
372
  supervisorChannelDir
373
- } from "./chunk-KEY3UQMQ.js";
373
+ } from "./chunk-374MZFF4.js";
374
374
  import {
375
375
  assertRequiredChildExtensionsAdmitted,
376
376
  hasMandatoryRequiredChildExtensions,
@@ -381,7 +381,7 @@ import {
381
381
  import {
382
382
  HERDR_PROJECT_PANE_ACTIONS,
383
383
  handleHerdrProjectPaneAction
384
- } from "./chunk-PVIVCDG2.js";
384
+ } from "./chunk-PYOAIN3V.js";
385
385
  import "./chunk-7J4ZXMY7.js";
386
386
  import {
387
387
  PROJECT_SUBAGENTS_RELATIVE_DIR,
@@ -394,12 +394,12 @@ import {
394
394
  getProjectSubagentsDir,
395
395
  writeArtifact,
396
396
  writeMetadata
397
- } from "./chunk-PHZP3KHB.js";
397
+ } from "./chunk-GRJHIXYF.js";
398
398
  import "./chunk-XA3DY6UG.js";
399
399
  import {
400
400
  getExternalJobProvider
401
401
  } from "./chunk-YYREO77V.js";
402
- import "./chunk-GCSLVFCX.js";
402
+ import "./chunk-NAFLUJ26.js";
403
403
  import {
404
404
  ChainOutputValidationError,
405
405
  DEFAULT_WAIT_TOOL_NAME,
@@ -550,7 +550,7 @@ import {
550
550
  writeAtomicJson,
551
551
  writeInitialProgressFile,
552
552
  writePrivateAtomicJson
553
- } from "./chunk-UX4SCV5N.js";
553
+ } from "./chunk-QGO6HXHG.js";
554
554
  import {
555
555
  CHAIN_RUNS_DIR,
556
556
  DEFAULT_ARTIFACT_CONFIG,
@@ -8873,10 +8873,11 @@ Extensions denied: ${status.capabilityCeiling.denyExtensions ? "yes" : "no"} (so
8873
8873
  lines.push(` Runner: external-cli (${runner.command}${runner.args.length ? ` ${runner.args.join(" ")}` : ""})`);
8874
8874
  lines.push(` Adapter: ${runner.adapter.id} v${runner.adapter.version} (${runner.adapter.executionMode})`);
8875
8875
  if (runner.safety) {
8876
- if ("approvalPolicy" in runner.safety) lines.push(` Safety: ${"access" in runner.safety ? `access=${runner.safety.access}, ` : ""}sandbox=${runner.safety.sandbox}, approval=${runner.safety.approvalPolicy}, ephemeral=${runner.safety.ephemeral}`);
8877
- else if ("mode" in runner.safety) lines.push(` Safety: access=${runner.safety.access}, auth=${runner.safety.authentication}, mode=${runner.safety.mode}, sandbox=${runner.safety.sandbox}, workspaceTrust=${runner.safety.workspaceTrust}, sessionReuse=${runner.safety.sessionReuse}`);
8878
- else if ("authentication" in runner.safety) lines.push(` Safety: access=${runner.safety.access}, auth=${runner.safety.authentication}, permission=${runner.safety.permissionMode}, tools=${runner.safety.tools}, mcp=${runner.safety.mcp}, settings=${runner.safety.settingSources}, settingsTrust=${runner.safety.userSettingsTrust}, persistence=${runner.safety.sessionPersistence}`);
8879
- else lines.push(` Safety: access=read-only, permission=${runner.safety.permissionMode}, tools=${runner.safety.tools}, mcp=${runner.safety.mcp}, settings=${runner.safety.settingSources}, persistence=${runner.safety.sessionPersistence}`);
8876
+ const safetyLabel = " Safety (adapter profile, not measured):";
8877
+ if ("approvalPolicy" in runner.safety) lines.push(`${safetyLabel} ${"access" in runner.safety ? `access=${runner.safety.access}, ` : ""}sandbox=${runner.safety.sandbox}, approval=${runner.safety.approvalPolicy}, ephemeral=${runner.safety.ephemeral}`);
8878
+ else if ("mode" in runner.safety) lines.push(`${safetyLabel} access=${runner.safety.access}, auth=${runner.safety.authentication}, mode=${runner.safety.mode}, sandbox=${runner.safety.sandbox}, workspaceTrust=${runner.safety.workspaceTrust}, sessionReuse=${runner.safety.sessionReuse}`);
8879
+ else if ("authentication" in runner.safety) lines.push(`${safetyLabel} access=${runner.safety.access}, auth=${runner.safety.authentication}, permission=${runner.safety.permissionMode}, tools=${runner.safety.tools}, mcp=${runner.safety.mcp}, settings=${runner.safety.settingSources}, settingsTrust=${runner.safety.userSettingsTrust}, persistence=${runner.safety.sessionPersistence}`);
8880
+ else lines.push(`${safetyLabel} access=read-only, permission=${runner.safety.permissionMode}, tools=${runner.safety.tools}, mcp=${runner.safety.mcp}, settings=${runner.safety.settingSources}, persistence=${runner.safety.sessionPersistence}`);
8880
8881
  }
8881
8882
  lines.push(` Capabilities: stop=${runner.capabilities.stop}, steer=false, resume=false, structuredOutput=false, toolEvents=false, supervisor=unsupported, forkContext=false, extensionBindings=false`);
8882
8883
  lines.push(` Unsupported steer: ${runner.unsupportedReasons.steer}`);