@runtypelabs/sdk 1.9.2 → 1.10.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.
package/dist/index.d.cts CHANGED
@@ -3142,11 +3142,16 @@ interface RunTaskStateSlice {
3142
3142
  bestCandidateVerified?: boolean;
3143
3143
  verificationRequired?: boolean;
3144
3144
  lastVerificationPassed?: boolean;
3145
+ consecutiveBlockedVerificationSessions?: number;
3145
3146
  isCreationTask?: boolean;
3147
+ /** For creation tasks: allowed write root (e.g. "public/"). Writes must stay under this path. */
3148
+ outputRoot?: string;
3146
3149
  sessions: Array<{
3147
3150
  actionKeys?: string[];
3148
3151
  hadTextOutput?: boolean;
3149
3152
  wroteFiles?: boolean;
3153
+ verificationAttempted?: boolean;
3154
+ verificationBlocked?: boolean;
3150
3155
  }>;
3151
3156
  }
3152
3157
  interface RunTaskToolTraceSlice {
@@ -3165,6 +3170,7 @@ interface RunTaskToolTraceSlice {
3165
3170
  bestCandidateVerified: boolean;
3166
3171
  verificationAttempted: boolean;
3167
3172
  verificationPassed: boolean;
3173
+ verificationBlocked: boolean;
3168
3174
  localToolLoopGuardTriggered: boolean;
3169
3175
  forcedTurnEndReason?: string;
3170
3176
  bestCandidatePath?: string;
@@ -3982,26 +3988,6 @@ interface AgentToolInputDeltaEvent extends BaseAgentEvent {
3982
3988
  toolCallId: string;
3983
3989
  delta: string;
3984
3990
  }
3985
- /**
3986
- * Agent tool input delta event — streamed input fragment
3987
- */
3988
- interface AgentToolInputDeltaEvent extends BaseAgentEvent {
3989
- type: 'agent_tool_input_delta';
3990
- iteration: number;
3991
- toolCallId: string;
3992
- delta: string;
3993
- }
3994
- /**
3995
- * Agent tool input complete event — resolved parameters after streaming
3996
- */
3997
- interface AgentToolInputCompleteEvent extends BaseAgentEvent {
3998
- type: 'agent_tool_input_complete';
3999
- iteration: number;
4000
- toolCallId: string;
4001
- toolName: string;
4002
- parameters: Record<string, unknown>;
4003
- hiddenParameterNames?: string[];
4004
- }
4005
3991
  /**
4006
3992
  * Agent tool input complete event — resolved parameters after streaming
4007
3993
  */
@@ -4320,6 +4306,8 @@ interface RunTaskSessionSummary {
4320
4306
  verificationAttempted?: boolean;
4321
4307
  /** Whether the latest verification command passed during the session */
4322
4308
  verificationPassed?: boolean;
4309
+ /** Whether the verification command was blocked (e.g. unsafe command rejected) */
4310
+ verificationBlocked?: boolean;
4323
4311
  /** Best candidate file identified during the session */
4324
4312
  bestCandidatePath?: string;
4325
4313
  /** Recent action keys used during the session */
@@ -4395,12 +4383,16 @@ interface RunTaskState {
4395
4383
  lastVerificationPassed?: boolean;
4396
4384
  /** Whether this task is creating something new rather than modifying existing files */
4397
4385
  isCreationTask?: boolean;
4386
+ /** For creation tasks: allowed write root (e.g. "public/"). Writes must stay under this path. */
4387
+ outputRoot?: string;
4398
4388
  /** Workflow variant string (e.g. 'create', 'modify', or custom) */
4399
4389
  workflowVariant?: string;
4390
+ /** Number of consecutive sessions where verification was blocked */
4391
+ consecutiveBlockedVerificationSessions?: number;
4400
4392
  /** Arbitrary bag for workflow-specific data */
4401
4393
  workflowState?: Record<string, unknown>;
4402
4394
  }
4403
- type RunTaskResumeState = Pick<RunTaskState, 'originalMessage' | 'bootstrapContext' | 'workflowPhase' | 'planPath' | 'planWritten' | 'bestCandidatePath' | 'bestCandidateReason' | 'candidatePaths' | 'recentReadPaths' | 'recentActionKeys' | 'bestCandidateNeedsVerification' | 'bestCandidateVerified' | 'verificationRequired' | 'lastVerificationPassed' | 'isCreationTask' | 'workflowVariant' | 'workflowState'>;
4395
+ type RunTaskResumeState = Pick<RunTaskState, 'originalMessage' | 'bootstrapContext' | 'workflowPhase' | 'planPath' | 'planWritten' | 'bestCandidatePath' | 'bestCandidateReason' | 'candidatePaths' | 'recentReadPaths' | 'recentActionKeys' | 'bestCandidateNeedsVerification' | 'bestCandidateVerified' | 'verificationRequired' | 'lastVerificationPassed' | 'consecutiveBlockedVerificationSessions' | 'isCreationTask' | 'outputRoot' | 'workflowVariant' | 'workflowState'>;
4404
4396
  /**
4405
4397
  * Callback invoked after each session completes.
4406
4398
  * Return `false` to stop the loop early.
package/dist/index.d.ts CHANGED
@@ -3142,11 +3142,16 @@ interface RunTaskStateSlice {
3142
3142
  bestCandidateVerified?: boolean;
3143
3143
  verificationRequired?: boolean;
3144
3144
  lastVerificationPassed?: boolean;
3145
+ consecutiveBlockedVerificationSessions?: number;
3145
3146
  isCreationTask?: boolean;
3147
+ /** For creation tasks: allowed write root (e.g. "public/"). Writes must stay under this path. */
3148
+ outputRoot?: string;
3146
3149
  sessions: Array<{
3147
3150
  actionKeys?: string[];
3148
3151
  hadTextOutput?: boolean;
3149
3152
  wroteFiles?: boolean;
3153
+ verificationAttempted?: boolean;
3154
+ verificationBlocked?: boolean;
3150
3155
  }>;
3151
3156
  }
3152
3157
  interface RunTaskToolTraceSlice {
@@ -3165,6 +3170,7 @@ interface RunTaskToolTraceSlice {
3165
3170
  bestCandidateVerified: boolean;
3166
3171
  verificationAttempted: boolean;
3167
3172
  verificationPassed: boolean;
3173
+ verificationBlocked: boolean;
3168
3174
  localToolLoopGuardTriggered: boolean;
3169
3175
  forcedTurnEndReason?: string;
3170
3176
  bestCandidatePath?: string;
@@ -3982,26 +3988,6 @@ interface AgentToolInputDeltaEvent extends BaseAgentEvent {
3982
3988
  toolCallId: string;
3983
3989
  delta: string;
3984
3990
  }
3985
- /**
3986
- * Agent tool input delta event — streamed input fragment
3987
- */
3988
- interface AgentToolInputDeltaEvent extends BaseAgentEvent {
3989
- type: 'agent_tool_input_delta';
3990
- iteration: number;
3991
- toolCallId: string;
3992
- delta: string;
3993
- }
3994
- /**
3995
- * Agent tool input complete event — resolved parameters after streaming
3996
- */
3997
- interface AgentToolInputCompleteEvent extends BaseAgentEvent {
3998
- type: 'agent_tool_input_complete';
3999
- iteration: number;
4000
- toolCallId: string;
4001
- toolName: string;
4002
- parameters: Record<string, unknown>;
4003
- hiddenParameterNames?: string[];
4004
- }
4005
3991
  /**
4006
3992
  * Agent tool input complete event — resolved parameters after streaming
4007
3993
  */
@@ -4320,6 +4306,8 @@ interface RunTaskSessionSummary {
4320
4306
  verificationAttempted?: boolean;
4321
4307
  /** Whether the latest verification command passed during the session */
4322
4308
  verificationPassed?: boolean;
4309
+ /** Whether the verification command was blocked (e.g. unsafe command rejected) */
4310
+ verificationBlocked?: boolean;
4323
4311
  /** Best candidate file identified during the session */
4324
4312
  bestCandidatePath?: string;
4325
4313
  /** Recent action keys used during the session */
@@ -4395,12 +4383,16 @@ interface RunTaskState {
4395
4383
  lastVerificationPassed?: boolean;
4396
4384
  /** Whether this task is creating something new rather than modifying existing files */
4397
4385
  isCreationTask?: boolean;
4386
+ /** For creation tasks: allowed write root (e.g. "public/"). Writes must stay under this path. */
4387
+ outputRoot?: string;
4398
4388
  /** Workflow variant string (e.g. 'create', 'modify', or custom) */
4399
4389
  workflowVariant?: string;
4390
+ /** Number of consecutive sessions where verification was blocked */
4391
+ consecutiveBlockedVerificationSessions?: number;
4400
4392
  /** Arbitrary bag for workflow-specific data */
4401
4393
  workflowState?: Record<string, unknown>;
4402
4394
  }
4403
- type RunTaskResumeState = Pick<RunTaskState, 'originalMessage' | 'bootstrapContext' | 'workflowPhase' | 'planPath' | 'planWritten' | 'bestCandidatePath' | 'bestCandidateReason' | 'candidatePaths' | 'recentReadPaths' | 'recentActionKeys' | 'bestCandidateNeedsVerification' | 'bestCandidateVerified' | 'verificationRequired' | 'lastVerificationPassed' | 'isCreationTask' | 'workflowVariant' | 'workflowState'>;
4395
+ type RunTaskResumeState = Pick<RunTaskState, 'originalMessage' | 'bootstrapContext' | 'workflowPhase' | 'planPath' | 'planWritten' | 'bestCandidatePath' | 'bestCandidateReason' | 'candidatePaths' | 'recentReadPaths' | 'recentActionKeys' | 'bestCandidateNeedsVerification' | 'bestCandidateVerified' | 'verificationRequired' | 'lastVerificationPassed' | 'consecutiveBlockedVerificationSessions' | 'isCreationTask' | 'outputRoot' | 'workflowVariant' | 'workflowState'>;
4404
4396
  /**
4405
4397
  * Callback invoked after each session completes.
4406
4398
  * Return `false` to stop the loop early.
package/dist/index.js CHANGED
@@ -1896,7 +1896,7 @@ var TOOL_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_]{1,63}$/;
1896
1896
  var DEFAULT_MAX_CODE_LENGTH = 12e3;
1897
1897
  var DEFAULT_MAX_TIMEOUT_MS = 3e4;
1898
1898
  var DEFAULT_BLOCKED_CODE_PATTERNS = [
1899
- /\b(?:child_process|fs|net|tls|http|https|os)\b/i,
1899
+ /\b(?:child_process|fs|net|tls|os)\b/i,
1900
1900
  /\b(?:process|Deno|Bun)\b/i,
1901
1901
  /\b(?:require|import)\s*\(/i,
1902
1902
  /\beval\s*\(/i,
@@ -2715,7 +2715,7 @@ var executionPhase = {
2715
2715
  `After that, you may update "${normalizedPlanPath}" with progress.`
2716
2716
  ].join(" ");
2717
2717
  }
2718
- if (normalizedPathArg && normalizedPathArg !== normalizedPlanPath) {
2718
+ if (!ctx.state.isCreationTask && normalizedPathArg && normalizedPathArg !== normalizedPlanPath) {
2719
2719
  const allowedWriteTargets = new Set(
2720
2720
  [
2721
2721
  normalizedPlanPath,
@@ -2732,6 +2732,23 @@ var executionPhase = {
2732
2732
  ].join(" ");
2733
2733
  }
2734
2734
  }
2735
+ if (ctx.state.isCreationTask && normalizedPathArg && normalizedPathArg !== normalizedPlanPath) {
2736
+ const outputRoot = ctx.state.outputRoot ? ctx.state.outputRoot.trim().replace(/\\/g, "/").replace(/\/+/g, "/").replace(/\/$/, "") || void 0 : void 0;
2737
+ if (!outputRoot) {
2738
+ return [
2739
+ `Blocked by marathon execution guard: creation tasks require outputRoot. Writes outside the plan are not allowed.`,
2740
+ `Plan path: "${normalizedPlanPath}". Create files only under the configured output root.`
2741
+ ].join(" ");
2742
+ }
2743
+ const rootPrefix = outputRoot + "/";
2744
+ const isUnderRoot = normalizedPathArg === outputRoot || normalizedPathArg.startsWith(rootPrefix);
2745
+ if (!isUnderRoot) {
2746
+ return [
2747
+ `Blocked by marathon execution guard: ${toolName} must target the plan or paths under outputRoot "${outputRoot}/".`,
2748
+ `"${normalizedPathArg}" is outside the allowed output root.`
2749
+ ].join(" ");
2750
+ }
2751
+ }
2735
2752
  }
2736
2753
  return void 0;
2737
2754
  },
@@ -2744,6 +2761,17 @@ var executionPhase = {
2744
2761
  },
2745
2762
  buildRecoveryMessage(state) {
2746
2763
  const recent = state.sessions.slice(-2);
2764
+ if (recent.length >= 2 && recent.every(
2765
+ (session) => session.verificationAttempted === true && session.wroteFiles !== true
2766
+ )) {
2767
+ return [
2768
+ "Recovery instruction:",
2769
+ "You have attempted verification in multiple sessions but none passed, and no files were written.",
2770
+ "If the project lacks test/lint/build tooling, verification cannot succeed.",
2771
+ "Focus on completing any remaining implementation. Signal TASK_COMPLETE when done.",
2772
+ "Do not retry run_check unless you have a specific command likely to succeed."
2773
+ ].join("\n");
2774
+ }
2747
2775
  const normalizedPlanPath = typeof state.planPath === "string" && state.planPath.trim() ? normalizeCandidatePath(state.planPath) : void 0;
2748
2776
  const recentPlanOnlyLoop = Boolean(normalizedPlanPath) && recent.length === 2 && recent.every((session) => {
2749
2777
  const specificActionKeys = (session.actionKeys || []).map((actionKey) => actionKey.replace(/\\/g, "/")).filter((actionKey) => !actionKey.startsWith("server:"));
@@ -4716,6 +4744,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
4716
4744
  bestCandidateVerified: false,
4717
4745
  verificationAttempted: false,
4718
4746
  verificationPassed: false,
4747
+ verificationBlocked: false,
4719
4748
  localToolLoopGuardTriggered: false
4720
4749
  };
4721
4750
  }
@@ -4937,6 +4966,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
4937
4966
  if (typeof parsed.success !== "boolean") return void 0;
4938
4967
  return {
4939
4968
  success: parsed.success,
4969
+ ...typeof parsed.blocked === "boolean" ? { blocked: parsed.blocked } : {},
4940
4970
  ...typeof parsed.command === "string" ? { command: parsed.command } : {},
4941
4971
  ...typeof parsed.output === "string" ? { output: parsed.output } : {},
4942
4972
  ...typeof parsed.error === "string" ? { error: parsed.error } : {}
@@ -5164,9 +5194,11 @@ var _AgentsEndpoint = class _AgentsEndpoint {
5164
5194
  bestCandidateVerified: Boolean(resumeState.bestCandidateVerified),
5165
5195
  ...resumeState.verificationRequired !== void 0 ? { verificationRequired: resumeState.verificationRequired } : {},
5166
5196
  lastVerificationPassed: Boolean(resumeState.lastVerificationPassed),
5197
+ ...resumeState.consecutiveBlockedVerificationSessions !== void 0 ? { consecutiveBlockedVerificationSessions: resumeState.consecutiveBlockedVerificationSessions } : {},
5167
5198
  ...resumeState.isCreationTask !== void 0 ? { isCreationTask: resumeState.isCreationTask } : {},
5168
5199
  ...resumeState.workflowVariant !== void 0 ? { workflowVariant: resumeState.workflowVariant } : {},
5169
- ...resumeState.workflowState !== void 0 ? { workflowState: resumeState.workflowState } : {}
5200
+ ...resumeState.workflowState !== void 0 ? { workflowState: resumeState.workflowState } : {},
5201
+ ...typeof resumeState.outputRoot === "string" && resumeState.outputRoot.trim() ? { outputRoot: resumeState.outputRoot.trim().replace(/\\/g, "/").replace(/\/+/g, "/") } : {}
5170
5202
  };
5171
5203
  }
5172
5204
  buildPhaseInstructions(state, workflow) {
@@ -5293,6 +5325,10 @@ var _AgentsEndpoint = class _AgentsEndpoint {
5293
5325
  } else if (state.workflowPhase === "execution") {
5294
5326
  trace.executionFileWritten = true;
5295
5327
  trace.verificationPassed = false;
5328
+ if (!this.isMarathonArtifactPath(normalizedPathArg)) {
5329
+ trace.bestCandidatePath = normalizedPathArg;
5330
+ trace.bestCandidateReason = "written by agent during execution";
5331
+ }
5296
5332
  if (normalizedBestCandidatePath && normalizedPathArg === normalizedBestCandidatePath) {
5297
5333
  trace.bestCandidateWritten = true;
5298
5334
  }
@@ -5302,6 +5338,9 @@ var _AgentsEndpoint = class _AgentsEndpoint {
5302
5338
  if (verificationResult) {
5303
5339
  trace.verificationAttempted = true;
5304
5340
  trace.verificationPassed = verificationResult.success;
5341
+ if (verificationResult.blocked) {
5342
+ trace.verificationBlocked = true;
5343
+ }
5305
5344
  }
5306
5345
  const summarizedResult = verificationResult ? [
5307
5346
  verificationResult.command || "verification",
@@ -5624,6 +5663,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
5624
5663
  };
5625
5664
  state.workflowVariant = classifiedVariant;
5626
5665
  state.isCreationTask = seededResumeState?.isCreationTask ?? state.workflowVariant === "create";
5666
+ state.outputRoot = seededResumeState?.outputRoot ?? (state.isCreationTask ? "public/" : void 0);
5627
5667
  this.updateWorkflowPhase(state, this.createEmptyToolTrace(), workflow);
5628
5668
  let recordId;
5629
5669
  const localToolNames = options.localTools ? Object.keys(options.localTools) : void 0;
@@ -5795,6 +5835,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
5795
5835
  hadTextOutput: Boolean(sessionResult.result.trim()),
5796
5836
  verificationAttempted: sessionTrace.verificationAttempted,
5797
5837
  verificationPassed: sessionTrace.verificationPassed,
5838
+ verificationBlocked: sessionTrace.verificationBlocked || void 0,
5798
5839
  bestCandidatePath: sessionTrace.bestCandidatePath || void 0,
5799
5840
  actionKeys: sessionTrace.actionKeys.slice(-5),
5800
5841
  completedAt: (/* @__PURE__ */ new Date()).toISOString()
@@ -5835,6 +5876,21 @@ var _AgentsEndpoint = class _AgentsEndpoint {
5835
5876
  }
5836
5877
  if (sessionTrace.verificationAttempted) {
5837
5878
  state.lastVerificationPassed = sessionTrace.verificationPassed;
5879
+ if (sessionTrace.verificationBlocked && !sessionTrace.verificationPassed) {
5880
+ state.consecutiveBlockedVerificationSessions = (state.consecutiveBlockedVerificationSessions || 0) + 1;
5881
+ } else {
5882
+ state.consecutiveBlockedVerificationSessions = 0;
5883
+ }
5884
+ }
5885
+ if ((state.consecutiveBlockedVerificationSessions || 0) >= 2 && state.verificationRequired) {
5886
+ state.verificationRequired = false;
5887
+ state.lastVerificationPassed = true;
5888
+ if (!state.planWritten) {
5889
+ state.planWritten = true;
5890
+ }
5891
+ if (!state.bestCandidateVerified) {
5892
+ state.bestCandidateVerified = true;
5893
+ }
5838
5894
  }
5839
5895
  const modelKey = options.model || "default";
5840
5896
  if (!state.costByModel) state.costByModel = {};