perchai-cli 2.4.15 → 2.4.16

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 (2) hide show
  1. package/dist/perch.mjs +20 -11
  2. package/package.json +1 -1
package/dist/perch.mjs CHANGED
@@ -75566,6 +75566,7 @@ var init_payroll = __esm({
75566
75566
  // lib/perchBusinessTools/index.ts
75567
75567
  var init_perchBusinessTools = __esm({
75568
75568
  "lib/perchBusinessTools/index.ts"() {
75569
+ "use strict";
75569
75570
  init_generateAPAuditPacket();
75570
75571
  init_inventoryFolder();
75571
75572
  init_loadBusinessTables();
@@ -83130,7 +83131,6 @@ function truncateHistoryLine(value, max2) {
83130
83131
  }
83131
83132
  var init_operatorTruth = __esm({
83132
83133
  "features/perchTerminal/runtime/operatorTruth.ts"() {
83133
- "use strict";
83134
83134
  }
83135
83135
  });
83136
83136
 
@@ -134242,7 +134242,7 @@ function validateArgs(name, args) {
134242
134242
  return "run_sandbox_code.command must be a non-empty string when provided.";
134243
134243
  if (args.language !== void 0 && args.language !== "python" && args.language !== "node")
134244
134244
  return 'run_sandbox_code.language must be either "python" or "node" when provided.';
134245
- if (args.code !== void 0 && !hasCode)
134245
+ if (args.code !== void 0 && !hasCode && !hasCommand)
134246
134246
  return "run_sandbox_code.code must be a non-empty string when provided.";
134247
134247
  }
134248
134248
  if (args.label !== void 0 && typeof args.label !== "string")
@@ -199727,7 +199727,6 @@ function containsBrowserDeliveryTask(tasks) {
199727
199727
  var BROWSER_DELIVERY_ROLE_IDS;
199728
199728
  var init_browserDeliveryLock = __esm({
199729
199729
  "features/perchTerminal/agentPlatform/browserDeliveryLock.ts"() {
199730
- "use strict";
199731
199730
  BROWSER_DELIVERY_ROLE_IDS = /* @__PURE__ */ new Set([
199732
199731
  "doc_writer",
199733
199732
  "email_sender",
@@ -219705,17 +219704,18 @@ async function runLiveAgentsLoop(input) {
219705
219704
  }
219706
219705
  const mode = effectiveChatMode;
219707
219706
  const loopTools = tools;
219708
- const loopSystemPrompt = appendLiveTurnContract(context.systemPrompt, {
219707
+ const sandboxExecutionRequired = sandboxExecutionRequiredByUserText(turn.trimmedInput, loopTools);
219708
+ const loopSystemPromptBase = appendLiveTurnContract(context.systemPrompt, {
219709
219709
  chatMode: mode,
219710
219710
  toolsAvailable: loopTools.length > 0,
219711
219711
  userObjective: turn.trimmedInput,
219712
219712
  planGateRejected
219713
219713
  });
219714
+ const loopSystemPrompt = sandboxExecutionRequired ? appendSandboxExecutionRequiredContract(loopSystemPromptBase) : loopSystemPromptBase;
219714
219715
  const threadSession = turn.threadId ? getThreadSessionFromMemory(turn.threadId) : null;
219715
219716
  const contextCompaction = threadSession?.contextCompaction ?? null;
219716
219717
  const approvedToolCall = approvedToolCallFromState(workflowState);
219717
219718
  const runLoop = input.loopRunner ?? runModelToolLoop;
219718
- const sandboxExecutionRequired = sandboxExecutionRequiredByUserText(turn.trimmedInput, loopTools);
219719
219719
  const loopInput = {
219720
219720
  signal: deps.signal ?? void 0,
219721
219721
  lane: loopLane,
@@ -219746,7 +219746,7 @@ async function runLiveAgentsLoop(input) {
219746
219746
  forcedInitialToolCall: approvedToolCall ?? turn.forcedInitialToolCall ?? null,
219747
219747
  forcedInitialToolCallApproved: Boolean(approvedToolCall),
219748
219748
  stopAfterForcedInitialToolCall: Boolean(approvedToolCall),
219749
- forceToolUse: turn.forceToolUse === true || sandboxExecutionRequired,
219749
+ forceToolUse: turn.forceToolUse === true,
219750
219750
  mcpTools: turn.mcpTools ?? [],
219751
219751
  maxIterations: turnHasBrowserOperatorTools(loopTools) ? 24 : turn.coordinatorSessionActive ? 20 : void 0,
219752
219752
  attachOperatorScreenshots: turnHasBrowserOperatorTools(loopTools),
@@ -219843,10 +219843,11 @@ async function runLiveAgentsLoop(input) {
219843
219843
  if (sandboxExecutionRequired && loopResult.ok && !hasRunSandboxCodeToolCall(loopResult)) {
219844
219844
  loopResult = await runLoop({
219845
219845
  ...loopInput,
219846
- forceToolUse: true,
219847
- systemPrompt: `${loopInput.systemPrompt.trim()}
219848
-
219849
- Sandbox execution is explicitly required by the user. This turn is incomplete until you call run_sandbox_code. Use the command field when possible; pass source file paths in sources and read copied files from input/. The sandbox tool result already captures stdout/stderr and produced files; do not try to read output/report.json from the host filesystem after the run. Do not mention internal model, provider, or lane details in the user-facing answer. Do not finish with prose before a sandbox run.`
219846
+ forceToolUse: false,
219847
+ systemPrompt: appendSandboxExecutionRequiredContract(
219848
+ loopInput.systemPrompt,
219849
+ true
219850
+ )
219850
219851
  });
219851
219852
  }
219852
219853
  if (sandboxExecutionRequired && loopResult.ok && !hasRunSandboxCodeToolCall(loopResult)) {
@@ -219977,6 +219978,12 @@ function sandboxExecutionRequiredByUserText(userText, tools) {
219977
219978
  if (!mentionsSandbox) return false;
219978
219979
  return /\b(use|run|execute|call|primary|required|mandatory|must|final numbers|must come from|do not stop)\b/.test(normalized) || /sandbox.{0,80}(primary|required|mandatory|must|execute|run|numbers|code)/.test(normalized) || /(primary|required|mandatory|must|execute|run|numbers|code).{0,80}sandbox/.test(normalized);
219979
219980
  }
219981
+ function appendSandboxExecutionRequiredContract(systemPrompt, retry = false) {
219982
+ const prefix = retry ? "The previous attempt did not call run_sandbox_code." : "Sandbox execution is explicitly required by the user.";
219983
+ return `${systemPrompt.trim()}
219984
+
219985
+ ${prefix} This turn is incomplete until you call run_sandbox_code. Use the command field when possible; pass source file paths in sources and read copied files from input/. The sandbox tool result already captures stdout/stderr and produced files; do not try to read output/report.json from the host filesystem after the run. Do not mention internal model, provider, or lane details in the user-facing answer. Do not finish with prose before a sandbox run.`;
219986
+ }
219980
219987
  function hasRunSandboxCodeToolCall(loopResult) {
219981
219988
  return loopResult.toolCalls.some((call) => call.toolName === TOOL_NAMES.runSandboxCode);
219982
219989
  }
@@ -222813,7 +222820,9 @@ function maybeWarnCategoryDrift(input) {
222813
222820
  const drift = sum - input.headlineTokens;
222814
222821
  const allowed = Math.max(256, Math.ceil(input.wireOverheadTokens ?? 0) + 64);
222815
222822
  if (Math.abs(drift) <= allowed) return;
222816
- if (typeof process !== "undefined" && process.env.NODE_ENV === "production") return;
222823
+ if (typeof process === "undefined" || process.env.PERCH_CONTEXT_METER_DEBUG !== "1") {
222824
+ return;
222825
+ }
222817
222826
  console.warn(
222818
222827
  `[context-meter] Category total drift in ${input.source}: categories=${sum}, headline=${input.headlineTokens}, drift=${drift}`
222819
222828
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perchai-cli",
3
- "version": "2.4.15",
3
+ "version": "2.4.16",
4
4
  "description": "Perch AI command-line interface",
5
5
  "bin": {
6
6
  "perch": "bin/perch"