@runtypelabs/cli 1.1.5 → 1.2.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.js CHANGED
@@ -5983,11 +5983,12 @@ function isRecord(value) {
5983
5983
  function parseSandboxProvider(value) {
5984
5984
  if (!value) return void 0;
5985
5985
  const normalized = value.trim().toLowerCase();
5986
- if (normalized === "quickjs" || normalized === "daytona") return normalized;
5986
+ if (normalized === "quickjs" || normalized === "daytona" || normalized === "cloudflare-worker")
5987
+ return normalized;
5987
5988
  return void 0;
5988
5989
  }
5989
5990
  function parseSandboxLanguage(provider, value) {
5990
- if (provider === "quickjs") return "javascript";
5991
+ if (provider === "quickjs" || provider === "cloudflare-worker") return "javascript";
5991
5992
  if (typeof value === "string") {
5992
5993
  const normalized = value.trim().toLowerCase();
5993
5994
  if (normalized === "javascript" || normalized === "typescript" || normalized === "python") {
@@ -5997,7 +5998,7 @@ function parseSandboxLanguage(provider, value) {
5997
5998
  return "javascript";
5998
5999
  }
5999
6000
  function parseSandboxTimeout(value, provider) {
6000
- const fallback = provider === "quickjs" ? 5e3 : 3e4;
6001
+ const fallback = provider === "quickjs" || provider === "cloudflare-worker" ? 5e3 : 3e4;
6001
6002
  let numericValue;
6002
6003
  if (typeof value === "number" && Number.isFinite(value)) {
6003
6004
  numericValue = value;
@@ -6028,18 +6029,39 @@ function parseDaytonaExecutionResult(value) {
6028
6029
  }
6029
6030
  }
6030
6031
  function createSandboxInstructions(provider) {
6032
+ if (provider === "cloudflare-worker") {
6033
+ return [
6034
+ "--- Sandbox Tooling (Cloudflare Worker) ---",
6035
+ "You can execute JavaScript snippets with the local tool `run_sandbox_code`.",
6036
+ "Call shape:",
6037
+ '{ "code": "...", "parameters": { ... }, "timeoutMs": 5000 }',
6038
+ "Cloudflare Worker rules:",
6039
+ "1. Use JavaScript only (no TypeScript or Python).",
6040
+ "2. async/await and Promises are fully supported.",
6041
+ "3. Inputs are passed in the `parameters` object (for example: `const x = parameters.x`).",
6042
+ "4. The snippet is wrapped in an async function. Use top-level `return ...` to produce the result.",
6043
+ "5. Return JSON-serializable values (object, array, string, number, boolean, null).",
6044
+ "6. Helper functions are available under `helpers.*` namespace (e.g., `helpers.extractEmails(text)`).",
6045
+ "7. No Node/Bun/Deno APIs, imports/require, process, filesystem, or network calls.",
6046
+ "Example:",
6047
+ "const nums = parameters.nums || []",
6048
+ "const sum = nums.reduce((acc, n) => acc + n, 0)",
6049
+ "return { sum, count: nums.length }"
6050
+ ].join("\n");
6051
+ }
6031
6052
  if (provider === "quickjs") {
6032
6053
  return [
6033
- "--- Sandbox Tooling (QuickJS) ---",
6054
+ "--- Sandbox Tooling (QuickJS \u2014 Legacy) ---",
6034
6055
  "You can execute JavaScript snippets with the local tool `run_sandbox_code`.",
6035
6056
  "Call shape:",
6036
6057
  '{ "code": "...", "parameters": { ... }, "timeoutMs": 5000 }',
6037
6058
  "QuickJS rules:",
6038
6059
  "1. Use JavaScript only (no TypeScript or Python).",
6039
- "2. Inputs are passed in the `parameters` object (for example: `const x = parameters.x`).",
6040
- "3. The snippet is wrapped in a function. Use top-level `return ...` to produce the result.",
6041
- "4. Return JSON-serializable values (object, array, string, number, boolean, null).",
6042
- "5. No Node/Bun/Deno APIs, imports/require, process, filesystem, or network calls.",
6060
+ "2. Do NOT use async/await or Promises \u2014 they will fail.",
6061
+ "3. Inputs are passed in the `parameters` object (for example: `const x = parameters.x`).",
6062
+ "4. The snippet is wrapped in a function. Use top-level `return ...` to produce the result.",
6063
+ "5. Return JSON-serializable values (object, array, string, number, boolean, null).",
6064
+ "6. No Node/Bun/Deno APIs, imports/require, process, filesystem, or network calls.",
6043
6065
  "Example:",
6044
6066
  "const nums = parameters.nums || []",
6045
6067
  "const sum = nums.reduce((acc, n) => acc + n, 0)",
@@ -6068,7 +6090,7 @@ function buildResumeCommand(agent, options, parsedSandbox) {
6068
6090
  }
6069
6091
  function createSandboxLocalTool(client, provider, debugMode) {
6070
6092
  return {
6071
- description: provider === "quickjs" ? "Execute JavaScript code in QuickJS sandbox. Inputs are passed via parameters object." : "Execute JavaScript/TypeScript/Python code in Daytona sandbox. Inputs are injected as top-level variables.",
6093
+ description: provider === "cloudflare-worker" ? "Execute JavaScript code in Cloudflare Worker sandbox. Async/await supported. Inputs are passed via parameters object." : provider === "quickjs" ? "Execute JavaScript code in QuickJS sandbox (legacy). Inputs are passed via parameters object." : "Execute JavaScript/TypeScript/Python code in Daytona sandbox. Inputs are injected as top-level variables.",
6072
6094
  parametersSchema: {
6073
6095
  type: "object",
6074
6096
  properties: {
@@ -6079,8 +6101,8 @@ function createSandboxLocalTool(client, provider, debugMode) {
6079
6101
  },
6080
6102
  language: {
6081
6103
  type: "string",
6082
- enum: provider === "quickjs" ? ["javascript"] : ["javascript", "typescript", "python"],
6083
- description: provider === "quickjs" ? "QuickJS only accepts javascript" : "Daytona code language"
6104
+ enum: provider === "quickjs" || provider === "cloudflare-worker" ? ["javascript"] : ["javascript", "typescript", "python"],
6105
+ description: provider === "quickjs" ? "QuickJS only accepts javascript" : provider === "cloudflare-worker" ? "Cloudflare Worker only accepts javascript" : "Daytona code language"
6084
6106
  },
6085
6107
  timeoutMs: { type: "number", description: "Execution timeout in ms (max 30000)" }
6086
6108
  },
@@ -6111,7 +6133,7 @@ function createSandboxLocalTool(client, provider, debugMode) {
6111
6133
  {
6112
6134
  allowedToolTypes: ["custom"],
6113
6135
  allowedSandboxProviders: [provider],
6114
- allowedLanguages: provider === "quickjs" ? ["javascript"] : ["javascript", "typescript", "python"],
6136
+ allowedLanguages: provider === "quickjs" || provider === "cloudflare-worker" ? ["javascript"] : ["javascript", "typescript", "python"],
6115
6137
  maxTimeoutMs: 3e4,
6116
6138
  maxCodeLength: 12e3
6117
6139
  }
@@ -6247,7 +6269,7 @@ async function taskAction(agent, options) {
6247
6269
  });
6248
6270
  let parsedSandbox = parseSandboxProvider(options.sandbox);
6249
6271
  if (options.sandbox && !parsedSandbox) {
6250
- console.error(chalk12.red(`Invalid --sandbox value "${options.sandbox}". Use: quickjs or daytona`));
6272
+ console.error(chalk12.red(`Invalid --sandbox value "${options.sandbox}". Use: cloudflare-worker, quickjs, or daytona`));
6251
6273
  process.exit(1);
6252
6274
  }
6253
6275
  let agentId = agent;
@@ -6648,7 +6670,7 @@ Task failed: ${errMsg}`));
6648
6670
  }
6649
6671
  }
6650
6672
  function applyTaskOptions(cmd) {
6651
- return cmd.argument("<agent>", "Agent ID or name").option("-g, --goal <text>", "Goal message for the agent").option("--max-sessions <n>", "Maximum sessions", "50").option("--max-cost <n>", "Budget in USD").option("--model <modelId>", "Model ID to use (overrides agent config)").option("--name <name>", "Task name (used for state file, defaults to agent name)").option("--session <name>", "Resume a specific session by name").option("--state-dir <path>", "Directory for state files (default: .runtype/marathons/)").option("--resume [message]", "Resume from existing local state, optionally with a new message").option("--compact", "Use compact summary instead of full history on resume").option("--track", "Sync progress to a Runtype record (visible in dashboard)").option("--debug", "Show debug output from each session").option("--json", "Output final result as JSON").option("--sandbox <provider>", "Enable sandbox code execution tool (quickjs or daytona)").option("--no-local-tools", "Disable built-in local tool execution (read_file, write_file, list_directory)").option("--plain-text", "Disable markdown rendering in output").option("--no-steer", "Run all iterations without steering pauses (fully autonomous)").option("--steer-timeout <seconds>", "Auto-continue timeout in seconds (default: 10)", "10").action(taskAction);
6673
+ return cmd.argument("<agent>", "Agent ID or name").option("-g, --goal <text>", "Goal message for the agent").option("--max-sessions <n>", "Maximum sessions", "50").option("--max-cost <n>", "Budget in USD").option("--model <modelId>", "Model ID to use (overrides agent config)").option("--name <name>", "Task name (used for state file, defaults to agent name)").option("--session <name>", "Resume a specific session by name").option("--state-dir <path>", "Directory for state files (default: .runtype/marathons/)").option("--resume [message]", "Resume from existing local state, optionally with a new message").option("--compact", "Use compact summary instead of full history on resume").option("--track", "Sync progress to a Runtype record (visible in dashboard)").option("--debug", "Show debug output from each session").option("--json", "Output final result as JSON").option("--sandbox <provider>", "Enable sandbox code execution tool (cloudflare-worker, quickjs, or daytona)").option("--no-local-tools", "Disable built-in local tool execution (read_file, write_file, list_directory)").option("--plain-text", "Disable markdown rendering in output").option("--no-steer", "Run all iterations without steering pauses (fully autonomous)").option("--steer-timeout <seconds>", "Auto-continue timeout in seconds (default: 10)", "10").action(taskAction);
6652
6674
  }
6653
6675
  var taskCommand = applyTaskOptions(
6654
6676
  new Command11("task").description("Run a multi-session agent task")