@runtypelabs/sdk 1.9.2 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1966,7 +1966,7 @@ var TOOL_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_]{1,63}$/;
1966
1966
  var DEFAULT_MAX_CODE_LENGTH = 12e3;
1967
1967
  var DEFAULT_MAX_TIMEOUT_MS = 3e4;
1968
1968
  var DEFAULT_BLOCKED_CODE_PATTERNS = [
1969
- /\b(?:child_process|fs|net|tls|http|https|os)\b/i,
1969
+ /\b(?:child_process|fs|net|tls|os)\b/i,
1970
1970
  /\b(?:process|Deno|Bun)\b/i,
1971
1971
  /\b(?:require|import)\s*\(/i,
1972
1972
  /\beval\s*\(/i,
@@ -2785,7 +2785,7 @@ var executionPhase = {
2785
2785
  `After that, you may update "${normalizedPlanPath}" with progress.`
2786
2786
  ].join(" ");
2787
2787
  }
2788
- if (normalizedPathArg && normalizedPathArg !== normalizedPlanPath) {
2788
+ if (!ctx.state.isCreationTask && normalizedPathArg && normalizedPathArg !== normalizedPlanPath) {
2789
2789
  const allowedWriteTargets = new Set(
2790
2790
  [
2791
2791
  normalizedPlanPath,
@@ -2802,6 +2802,23 @@ var executionPhase = {
2802
2802
  ].join(" ");
2803
2803
  }
2804
2804
  }
2805
+ if (ctx.state.isCreationTask && normalizedPathArg && normalizedPathArg !== normalizedPlanPath) {
2806
+ const outputRoot = ctx.state.outputRoot ? ctx.state.outputRoot.trim().replace(/\\/g, "/").replace(/\/+/g, "/").replace(/\/$/, "") || void 0 : void 0;
2807
+ if (!outputRoot) {
2808
+ return [
2809
+ `Blocked by marathon execution guard: creation tasks require outputRoot. Writes outside the plan are not allowed.`,
2810
+ `Plan path: "${normalizedPlanPath}". Create files only under the configured output root.`
2811
+ ].join(" ");
2812
+ }
2813
+ const rootPrefix = outputRoot + "/";
2814
+ const isUnderRoot = normalizedPathArg === outputRoot || normalizedPathArg.startsWith(rootPrefix);
2815
+ if (!isUnderRoot) {
2816
+ return [
2817
+ `Blocked by marathon execution guard: ${toolName} must target the plan or paths under outputRoot "${outputRoot}/".`,
2818
+ `"${normalizedPathArg}" is outside the allowed output root.`
2819
+ ].join(" ");
2820
+ }
2821
+ }
2805
2822
  }
2806
2823
  return void 0;
2807
2824
  },
@@ -2814,6 +2831,17 @@ var executionPhase = {
2814
2831
  },
2815
2832
  buildRecoveryMessage(state) {
2816
2833
  const recent = state.sessions.slice(-2);
2834
+ if (recent.length >= 2 && recent.every(
2835
+ (session) => session.verificationAttempted === true && session.wroteFiles !== true
2836
+ )) {
2837
+ return [
2838
+ "Recovery instruction:",
2839
+ "You have attempted verification in multiple sessions but none passed, and no files were written.",
2840
+ "If the project lacks test/lint/build tooling, verification cannot succeed.",
2841
+ "Focus on completing any remaining implementation. Signal TASK_COMPLETE when done.",
2842
+ "Do not retry run_check unless you have a specific command likely to succeed."
2843
+ ].join("\n");
2844
+ }
2817
2845
  const normalizedPlanPath = typeof state.planPath === "string" && state.planPath.trim() ? normalizeCandidatePath(state.planPath) : void 0;
2818
2846
  const recentPlanOnlyLoop = Boolean(normalizedPlanPath) && recent.length === 2 && recent.every((session) => {
2819
2847
  const specificActionKeys = (session.actionKeys || []).map((actionKey) => actionKey.replace(/\\/g, "/")).filter((actionKey) => !actionKey.startsWith("server:"));
@@ -4786,6 +4814,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
4786
4814
  bestCandidateVerified: false,
4787
4815
  verificationAttempted: false,
4788
4816
  verificationPassed: false,
4817
+ verificationBlocked: false,
4789
4818
  localToolLoopGuardTriggered: false
4790
4819
  };
4791
4820
  }
@@ -5007,6 +5036,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
5007
5036
  if (typeof parsed.success !== "boolean") return void 0;
5008
5037
  return {
5009
5038
  success: parsed.success,
5039
+ ...typeof parsed.blocked === "boolean" ? { blocked: parsed.blocked } : {},
5010
5040
  ...typeof parsed.command === "string" ? { command: parsed.command } : {},
5011
5041
  ...typeof parsed.output === "string" ? { output: parsed.output } : {},
5012
5042
  ...typeof parsed.error === "string" ? { error: parsed.error } : {}
@@ -5234,9 +5264,11 @@ var _AgentsEndpoint = class _AgentsEndpoint {
5234
5264
  bestCandidateVerified: Boolean(resumeState.bestCandidateVerified),
5235
5265
  ...resumeState.verificationRequired !== void 0 ? { verificationRequired: resumeState.verificationRequired } : {},
5236
5266
  lastVerificationPassed: Boolean(resumeState.lastVerificationPassed),
5267
+ ...resumeState.consecutiveBlockedVerificationSessions !== void 0 ? { consecutiveBlockedVerificationSessions: resumeState.consecutiveBlockedVerificationSessions } : {},
5237
5268
  ...resumeState.isCreationTask !== void 0 ? { isCreationTask: resumeState.isCreationTask } : {},
5238
5269
  ...resumeState.workflowVariant !== void 0 ? { workflowVariant: resumeState.workflowVariant } : {},
5239
- ...resumeState.workflowState !== void 0 ? { workflowState: resumeState.workflowState } : {}
5270
+ ...resumeState.workflowState !== void 0 ? { workflowState: resumeState.workflowState } : {},
5271
+ ...typeof resumeState.outputRoot === "string" && resumeState.outputRoot.trim() ? { outputRoot: resumeState.outputRoot.trim().replace(/\\/g, "/").replace(/\/+/g, "/") } : {}
5240
5272
  };
5241
5273
  }
5242
5274
  buildPhaseInstructions(state, workflow) {
@@ -5363,6 +5395,10 @@ var _AgentsEndpoint = class _AgentsEndpoint {
5363
5395
  } else if (state.workflowPhase === "execution") {
5364
5396
  trace.executionFileWritten = true;
5365
5397
  trace.verificationPassed = false;
5398
+ if (!this.isMarathonArtifactPath(normalizedPathArg)) {
5399
+ trace.bestCandidatePath = normalizedPathArg;
5400
+ trace.bestCandidateReason = "written by agent during execution";
5401
+ }
5366
5402
  if (normalizedBestCandidatePath && normalizedPathArg === normalizedBestCandidatePath) {
5367
5403
  trace.bestCandidateWritten = true;
5368
5404
  }
@@ -5372,6 +5408,9 @@ var _AgentsEndpoint = class _AgentsEndpoint {
5372
5408
  if (verificationResult) {
5373
5409
  trace.verificationAttempted = true;
5374
5410
  trace.verificationPassed = verificationResult.success;
5411
+ if (verificationResult.blocked) {
5412
+ trace.verificationBlocked = true;
5413
+ }
5375
5414
  }
5376
5415
  const summarizedResult = verificationResult ? [
5377
5416
  verificationResult.command || "verification",
@@ -5694,6 +5733,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
5694
5733
  };
5695
5734
  state.workflowVariant = classifiedVariant;
5696
5735
  state.isCreationTask = seededResumeState?.isCreationTask ?? state.workflowVariant === "create";
5736
+ state.outputRoot = seededResumeState?.outputRoot ?? (state.isCreationTask ? "public/" : void 0);
5697
5737
  this.updateWorkflowPhase(state, this.createEmptyToolTrace(), workflow);
5698
5738
  let recordId;
5699
5739
  const localToolNames = options.localTools ? Object.keys(options.localTools) : void 0;
@@ -5865,6 +5905,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
5865
5905
  hadTextOutput: Boolean(sessionResult.result.trim()),
5866
5906
  verificationAttempted: sessionTrace.verificationAttempted,
5867
5907
  verificationPassed: sessionTrace.verificationPassed,
5908
+ verificationBlocked: sessionTrace.verificationBlocked || void 0,
5868
5909
  bestCandidatePath: sessionTrace.bestCandidatePath || void 0,
5869
5910
  actionKeys: sessionTrace.actionKeys.slice(-5),
5870
5911
  completedAt: (/* @__PURE__ */ new Date()).toISOString()
@@ -5905,6 +5946,21 @@ var _AgentsEndpoint = class _AgentsEndpoint {
5905
5946
  }
5906
5947
  if (sessionTrace.verificationAttempted) {
5907
5948
  state.lastVerificationPassed = sessionTrace.verificationPassed;
5949
+ if (sessionTrace.verificationBlocked && !sessionTrace.verificationPassed) {
5950
+ state.consecutiveBlockedVerificationSessions = (state.consecutiveBlockedVerificationSessions || 0) + 1;
5951
+ } else {
5952
+ state.consecutiveBlockedVerificationSessions = 0;
5953
+ }
5954
+ }
5955
+ if ((state.consecutiveBlockedVerificationSessions || 0) >= 2 && state.verificationRequired) {
5956
+ state.verificationRequired = false;
5957
+ state.lastVerificationPassed = true;
5958
+ if (!state.planWritten) {
5959
+ state.planWritten = true;
5960
+ }
5961
+ if (!state.bestCandidateVerified) {
5962
+ state.bestCandidateVerified = true;
5963
+ }
5908
5964
  }
5909
5965
  const modelKey = options.model || "default";
5910
5966
  if (!state.costByModel) state.costByModel = {};