flyspace-cli 0.1.47 → 0.1.49

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.
@@ -437,13 +437,11 @@ async function postToDashboardChannel(opts) {
437
437
  }
438
438
  const parentId = threadId ?? await createThread(supabase, channelId, text, title);
439
439
  const body = await uploadLocalImages(text);
440
- const { error } = await supabase.from("thread_replies").insert({
441
- thread_id: parentId,
442
- author: AGENT_AUTHOR,
443
- body
444
- });
445
- if (error) throw new Error(`failed to write dashboard reply: ${error.message}`);
446
- return parentId;
440
+ const { data, error } = await supabase.from("thread_replies").insert({ thread_id: parentId, author: AGENT_AUTHOR, body }).select("id").single();
441
+ if (error || !data) {
442
+ throw new Error(`failed to write dashboard reply: ${error?.message ?? "no row returned"}`);
443
+ }
444
+ return { threadId: parentId, replyId: data["id"] };
447
445
  }
448
446
  async function createThread(supabase, channelId, text, title) {
449
447
  const { data, error } = await supabase.from("threads").insert({
@@ -3,7 +3,7 @@ import { createRequire as __flyspaceCreateRequire } from 'node:module';
3
3
  const require = __flyspaceCreateRequire(import.meta.url);
4
4
  import {
5
5
  getSupabaseClient
6
- } from "./chunk-F5CXKDZV.js";
6
+ } from "./chunk-HTFQL66T.js";
7
7
 
8
8
  // src/store/chat-admin-store.ts
9
9
  async function listChannels(profile) {
@@ -16,7 +16,7 @@ import {
16
16
  setSupabaseClientFactory,
17
17
  sweepScratchDir,
18
18
  syncPostToDashboard
19
- } from "./chunk-F5CXKDZV.js";
19
+ } from "./chunk-HTFQL66T.js";
20
20
 
21
21
  // src/index.ts
22
22
  import { execFile, spawn as spawn4 } from "child_process";
@@ -275,6 +275,9 @@ function stopAutomationRegistryPolling() {
275
275
  import { existsSync as existsSync2, mkdirSync, realpathSync, statSync } from "fs";
276
276
  import { homedir } from "os";
277
277
  import { isAbsolute, relative, resolve as resolve2, sep } from "path";
278
+ function isPermissionMode(value) {
279
+ return value === "bypass" || value === "ask";
280
+ }
278
281
  function isLogicalCwd(p) {
279
282
  return /^[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9-]*$/.test(p);
280
283
  }
@@ -282,6 +285,14 @@ function logicalRoot() {
282
285
  return process.env["FLYSPACE_ROOT"] || resolve2(homedir(), "Flyspace");
283
286
  }
284
287
  var workspaceRoots = /* @__PURE__ */ new Map();
288
+ var workspacePermissionModes = /* @__PURE__ */ new Map();
289
+ async function refreshWorkspacePermissionModes() {
290
+ const { data, error } = await getSupabaseClient().from("workspaces").select("slug, permission_mode");
291
+ if (error) return;
292
+ workspacePermissionModes = new Map(
293
+ (data ?? []).filter((w) => isPermissionMode(w.permission_mode)).map((w) => [w.slug, w.permission_mode])
294
+ );
295
+ }
285
296
  async function refreshWorkspaceRoots() {
286
297
  const { data, error } = await getSupabaseClient().from("workspaces").select("slug, root_path");
287
298
  if (error) return;
@@ -366,6 +377,7 @@ function rowToChannel(row) {
366
377
  // isn't a clean string array reads as "no mounts", which exposes less
367
378
  // rather than more.
368
379
  mounts: Array.isArray(row.mounts) ? row.mounts.filter((p) => typeof p === "string").map(expandPath) : [],
380
+ permissionMode: isPermissionMode(row.permission_mode) ? row.permission_mode : null,
369
381
  position: row.position,
370
382
  automations: row.automations ?? void 0,
371
383
  agentName: row.agent_name,
@@ -392,7 +404,7 @@ function indexRegistry(list) {
392
404
  }
393
405
  async function refreshChannelRegistry() {
394
406
  const rootsBefore = JSON.stringify([...workspaceRoots]);
395
- await refreshWorkspaceRoots();
407
+ await Promise.all([refreshWorkspaceRoots(), refreshWorkspacePermissionModes()]);
396
408
  if (JSON.stringify([...workspaceRoots]) !== rootsBefore) lastSnapshot2 = void 0;
397
409
  const { data, error } = await getSupabaseClient().from("channels").select("*").order("position", { ascending: true });
398
410
  if (error) {
@@ -519,6 +531,10 @@ function resolveChannelEffort(channelId) {
519
531
  if (!channelId) return void 0;
520
532
  return findChannel(channelId)?.effort ?? void 0;
521
533
  }
534
+ function resolveChannelPermissionMode(channelId) {
535
+ const channel = channelId ? findChannel(channelId) : void 0;
536
+ return channel?.permissionMode ?? workspacePermissionModes.get(channel?.profile ?? getProfile()) ?? "bypass";
537
+ }
522
538
  function resolveChannelPrompt(channelId) {
523
539
  if (!channelId) return void 0;
524
540
  return findChannel(channelId)?.prompt?.trim() || void 0;
@@ -562,6 +578,7 @@ function toRow(input) {
562
578
  if (input.mounts !== void 0) {
563
579
  row["mounts"] = input.mounts.map((p) => p.trim()).filter(Boolean).map(expandPath);
564
580
  }
581
+ if (input.permissionMode !== void 0) row["permission_mode"] = input.permissionMode;
565
582
  if (input.position !== void 0) row["position"] = input.position;
566
583
  if (input.automations !== void 0) row["automations"] = input.automations;
567
584
  if (input.agentName !== void 0) row["agent_name"] = input.agentName;
@@ -851,6 +868,105 @@ import { resolve as resolve4, resolve as resolvePath } from "path";
851
868
  import { homedir as homedir3 } from "os";
852
869
  import { randomUUID } from "crypto";
853
870
 
871
+ // ../api/src/claude/models.ts
872
+ var GATEWAY_MODEL_OPTIONS = [
873
+ { value: "deepseek-chat", label: "DeepSeek Flash \xB7 cheapest", provider: "claude", gateway: "deepseek" },
874
+ { value: "deepseek-v4-pro", label: "DeepSeek Pro \xB7 smarter", provider: "claude", gateway: "deepseek" }
875
+ ];
876
+ function gatewayForModel(value) {
877
+ if (!value) return void 0;
878
+ return value.toLowerCase().startsWith("deepseek") ? "deepseek" : void 0;
879
+ }
880
+ function effectiveModel(model, pinnedModel) {
881
+ if (!pinnedModel) return model ?? "";
882
+ return model && gatewayForModel(model) === gatewayForModel(pinnedModel) ? model : pinnedModel;
883
+ }
884
+ var MODEL_OPTIONS = [
885
+ { value: "opus", label: "Opus", provider: "claude" },
886
+ { value: "sonnet", label: "Sonnet", provider: "claude" },
887
+ { value: "haiku", label: "Haiku", provider: "claude" },
888
+ { value: "fable", label: "Fable", provider: "claude" }
889
+ ];
890
+ var CODEX_MODEL_OPTIONS = [
891
+ { value: "gpt-5.6-sol", label: "Sol \xB7 frontier", provider: "codex" },
892
+ { value: "gpt-5.6-terra", label: "Terra \xB7 everyday", provider: "codex" },
893
+ { value: "gpt-5.6-luna", label: "Luna \xB7 fast", provider: "codex" },
894
+ { value: "gpt-5.5", label: "GPT-5.5", provider: "codex" },
895
+ { value: "gpt-5.4", label: "GPT-5.4", provider: "codex" },
896
+ { value: "gpt-5.4-mini", label: "GPT-5.4 Mini", provider: "codex" }
897
+ ];
898
+ var RETIRED_MODELS = {};
899
+ function upgradeModel(value) {
900
+ let current = value;
901
+ for (let hops = 0; current && RETIRED_MODELS[current] && hops < 10; hops++) {
902
+ current = RETIRED_MODELS[current];
903
+ }
904
+ return current;
905
+ }
906
+ var BY_VALUE = new Map(
907
+ [...MODEL_OPTIONS, ...CODEX_MODEL_OPTIONS, ...GATEWAY_MODEL_OPTIONS].map((m) => [m.value, m])
908
+ );
909
+ var CLAUDE_FAMILY_LABELS = {
910
+ opus: "Opus",
911
+ sonnet: "Sonnet",
912
+ haiku: "Haiku",
913
+ // Mythos is the same model at the same price behind a different id — see
914
+ // the `matches` comment on the fable rate card in `store/rate-cards.ts`.
915
+ fable: "Fable",
916
+ mythos: "Fable"
917
+ };
918
+ var LONG_CONTEXT_SUFFIX = "[1m]";
919
+ function parseClaudeModelId(id) {
920
+ const undated = id.replace(/-\d{8}$/, "");
921
+ const match = /^claude-(opus|sonnet|haiku|fable|mythos)-([\d-]+)$/.exec(undated);
922
+ if (!match) return void 0;
923
+ const [, family, versionParts] = match;
924
+ return { family, version: versionParts.replace(/-/g, ".") };
925
+ }
926
+ function runnerForModel(value) {
927
+ if (!value) return "claude";
928
+ value = upgradeModel(value);
929
+ const known = BY_VALUE.get(value);
930
+ if (known) return known.provider;
931
+ return value.startsWith("gpt-") ? "codex" : "claude";
932
+ }
933
+ function isCodexModel(value) {
934
+ return !!value && runnerForModel(value) === "codex";
935
+ }
936
+ function agentLabel(agent) {
937
+ return agent === "codex" ? "Codex" : "Claude";
938
+ }
939
+ function modelOptionsFor(agent) {
940
+ return agent === "codex" ? CODEX_MODEL_OPTIONS : MODEL_OPTIONS;
941
+ }
942
+ var ALL_MODEL_OPTIONS = [
943
+ ...MODEL_OPTIONS,
944
+ ...CODEX_MODEL_OPTIONS,
945
+ ...GATEWAY_MODEL_OPTIONS
946
+ ];
947
+ function isAllowedModel(value) {
948
+ return BY_VALUE.has(upgradeModel(value));
949
+ }
950
+ function modelQuotaKey(value) {
951
+ const known = BY_VALUE.get(value);
952
+ if (known) return known.value;
953
+ const bare = value.endsWith(LONG_CONTEXT_SUFFIX) ? value.slice(0, -LONG_CONTEXT_SUFFIX.length) : value;
954
+ const parsed = parseClaudeModelId(bare);
955
+ if (!parsed) return value;
956
+ return parsed.family === "mythos" ? "fable" : parsed.family;
957
+ }
958
+ function modelLabel(value) {
959
+ if (!value) return "Default";
960
+ const known = BY_VALUE.get(value);
961
+ if (known) return known.label;
962
+ const longContext = value.endsWith(LONG_CONTEXT_SUFFIX);
963
+ const bare = longContext ? value.slice(0, -LONG_CONTEXT_SUFFIX.length) : value;
964
+ const parsed = parseClaudeModelId(bare);
965
+ if (!parsed) return value;
966
+ const label = `${CLAUDE_FAMILY_LABELS[parsed.family]} ${parsed.version}`;
967
+ return longContext ? `${label} \xB7 1M context` : label;
968
+ }
969
+
854
970
  // src/claude/container.ts
855
971
  import { execFileSync } from "child_process";
856
972
  import { createHash } from "crypto";
@@ -1343,78 +1459,6 @@ function setOutputStyleDefault(claudeConfigDir, id) {
1343
1459
  return true;
1344
1460
  }
1345
1461
 
1346
- // ../api/src/claude/models.ts
1347
- var MODEL_OPTIONS = [
1348
- { value: "opus", label: "Opus", provider: "claude" },
1349
- { value: "sonnet", label: "Sonnet", provider: "claude" },
1350
- { value: "haiku", label: "Haiku", provider: "claude" },
1351
- { value: "fable", label: "Fable", provider: "claude" }
1352
- ];
1353
- var CODEX_MODEL_OPTIONS = [
1354
- { value: "gpt-5.6-sol", label: "Sol \xB7 frontier", provider: "codex" },
1355
- { value: "gpt-5.6-terra", label: "Terra \xB7 everyday", provider: "codex" },
1356
- { value: "gpt-5.6-luna", label: "Luna \xB7 fast", provider: "codex" },
1357
- { value: "gpt-5.5", label: "GPT-5.5", provider: "codex" },
1358
- { value: "gpt-5.4", label: "GPT-5.4", provider: "codex" },
1359
- { value: "gpt-5.4-mini", label: "GPT-5.4 Mini", provider: "codex" }
1360
- ];
1361
- var BY_VALUE = new Map([...MODEL_OPTIONS, ...CODEX_MODEL_OPTIONS].map((m) => [m.value, m]));
1362
- var CLAUDE_FAMILY_LABELS = {
1363
- opus: "Opus",
1364
- sonnet: "Sonnet",
1365
- haiku: "Haiku",
1366
- // Mythos is the same model at the same price behind a different id — see
1367
- // the `matches` comment on the fable rate card in `store/rate-cards.ts`.
1368
- fable: "Fable",
1369
- mythos: "Fable"
1370
- };
1371
- var LONG_CONTEXT_SUFFIX = "[1m]";
1372
- function parseClaudeModelId(id) {
1373
- const undated = id.replace(/-\d{8}$/, "");
1374
- const match = /^claude-(opus|sonnet|haiku|fable|mythos)-([\d-]+)$/.exec(undated);
1375
- if (!match) return void 0;
1376
- const [, family, versionParts] = match;
1377
- return { family, version: versionParts.replace(/-/g, ".") };
1378
- }
1379
- function runnerForModel(value) {
1380
- if (!value) return "claude";
1381
- const known = BY_VALUE.get(value);
1382
- if (known) return known.provider;
1383
- return value.startsWith("gpt-") ? "codex" : "claude";
1384
- }
1385
- function isCodexModel(value) {
1386
- return !!value && runnerForModel(value) === "codex";
1387
- }
1388
- function agentLabel(agent) {
1389
- return agent === "codex" ? "Codex" : "Claude";
1390
- }
1391
- function modelOptionsFor(agent) {
1392
- return agent === "codex" ? CODEX_MODEL_OPTIONS : MODEL_OPTIONS;
1393
- }
1394
- var ALL_MODEL_OPTIONS = [...MODEL_OPTIONS, ...CODEX_MODEL_OPTIONS];
1395
- function isAllowedModel(value) {
1396
- return BY_VALUE.has(value);
1397
- }
1398
- function modelQuotaKey(value) {
1399
- const known = BY_VALUE.get(value);
1400
- if (known) return known.value;
1401
- const bare = value.endsWith(LONG_CONTEXT_SUFFIX) ? value.slice(0, -LONG_CONTEXT_SUFFIX.length) : value;
1402
- const parsed = parseClaudeModelId(bare);
1403
- if (!parsed) return value;
1404
- return parsed.family === "mythos" ? "fable" : parsed.family;
1405
- }
1406
- function modelLabel(value) {
1407
- if (!value) return "Default";
1408
- const known = BY_VALUE.get(value);
1409
- if (known) return known.label;
1410
- const longContext = value.endsWith(LONG_CONTEXT_SUFFIX);
1411
- const bare = longContext ? value.slice(0, -LONG_CONTEXT_SUFFIX.length) : value;
1412
- const parsed = parseClaudeModelId(bare);
1413
- if (!parsed) return value;
1414
- const label = `${CLAUDE_FAMILY_LABELS[parsed.family]} ${parsed.version}`;
1415
- return longContext ? `${label} \xB7 1M context` : label;
1416
- }
1417
-
1418
1462
  // ../api/src/agents/usage-limit.ts
1419
1463
  var USAGE_LIMIT_PATTERNS = [
1420
1464
  /usage limit reached/i,
@@ -1845,6 +1889,10 @@ The instructions above are your primary identity for this entire conversation \u
1845
1889
 
1846
1890
  ${base}`;
1847
1891
  }
1892
+ function permissionArgs(mode, promptTool) {
1893
+ if (mode !== "ask") return ["--dangerously-skip-permissions"];
1894
+ return promptTool ? ["--permission-mode", "auto", "--permission-prompt-tool", promptTool] : ["--permission-mode", "auto", "--permission-prompts", "none"];
1895
+ }
1848
1896
  function docsAccessDisallowedTools(access) {
1849
1897
  const writers = ["Write", "Edit", "MultiEdit", "NotebookEdit"];
1850
1898
  if (access === "read") return writers;
@@ -1884,6 +1932,10 @@ function buildHookSettings(runtime, builtInStyleName) {
1884
1932
  }
1885
1933
  });
1886
1934
  }
1935
+ function isModelForGateway(model, pinned) {
1936
+ if (!pinned) return true;
1937
+ return model.split("-")[0].toLowerCase() === pinned.split("-")[0].toLowerCase();
1938
+ }
1887
1939
  function buildArgs(prompt, botName, options, resumeSessionId, isolatedStyle) {
1888
1940
  const args = [
1889
1941
  "--print",
@@ -1891,7 +1943,7 @@ function buildArgs(prompt, botName, options, resumeSessionId, isolatedStyle) {
1891
1943
  // activity); plain json emits one blob on completion. stream-json with
1892
1944
  // --print requires --verbose.
1893
1945
  ...options.onActivity ? ["--output-format", "stream-json", "--verbose"] : ["--output-format", "json"],
1894
- "--dangerously-skip-permissions",
1946
+ ...permissionArgs(options.permissionMode, options.permissionPromptTool),
1895
1947
  "--no-chrome",
1896
1948
  // `=` form: the flag is variadic and would otherwise swallow the next token.
1897
1949
  ...docsAccessDisallowedTools(options.docsAccess).length > 0 ? [`--disallowedTools=${docsAccessDisallowedTools(options.docsAccess).join(",")}`] : [],
@@ -1927,8 +1979,9 @@ function buildArgs(prompt, botName, options, resumeSessionId, isolatedStyle) {
1927
1979
  if (options.mcpConfigPath) {
1928
1980
  args.push("--mcp-config", options.mcpConfigPath);
1929
1981
  }
1930
- if (options.model && !process.env["ANTHROPIC_MODEL"]) {
1931
- args.push("--model", resolveModelAlias(options.model));
1982
+ const model = upgradeModel(options.model);
1983
+ if (model && isModelForGateway(model, process.env["ANTHROPIC_MODEL"])) {
1984
+ args.push("--model", resolveModelAlias(model));
1932
1985
  }
1933
1986
  if (options.effort) {
1934
1987
  args.push("--effort", resolveClaudeEffort(options.effort));
@@ -1968,6 +2021,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
1968
2021
  );
1969
2022
  const env = resolveMiseEnv(cwd);
1970
2023
  env["FLYSPACE_SCRATCH_DIR"] = paths.SCRATCH_DIR;
2024
+ if (options.permissionPromptTool && !env["MCP_TOOL_TIMEOUT"]) env["MCP_TOOL_TIMEOUT"] = "360000";
1971
2025
  env["CLAUDE_CODE_ARTIFACT"] = "1";
1972
2026
  if (options.disableAutoMemory) env["CLAUDE_CODE_DISABLE_AUTO_MEMORY"] = "1";
1973
2027
  else delete env["CLAUDE_CODE_DISABLE_AUTO_MEMORY"];
@@ -2288,6 +2342,11 @@ var featureFlags = {
2288
2342
  title: "Autocomplete",
2289
2343
  description: "Gray inline suggestions in the message composer that continue what you are typing, based on the channel. Press Tab to accept, Esc to dismiss. Your draft is sent to an AI model.",
2290
2344
  stage: "beta"
2345
+ },
2346
+ languages: {
2347
+ title: "Languages",
2348
+ description: "Pick the interface language in your user settings (13 languages, machine translated). Off: the interface is always English.",
2349
+ stage: "beta"
2291
2350
  }
2292
2351
  };
2293
2352
  var featureFlagIds = Object.keys(featureFlags);
@@ -2699,7 +2758,7 @@ var TRIAL_DAYS = 14;
2699
2758
  async function listWorkspaceSummaries() {
2700
2759
  const db = getSupabaseClient();
2701
2760
  const [workspaces, settings, channels, memberships, activity] = await Promise.all([
2702
- db.from("workspaces").select("id, slug, created_at, agent_connected_at, plan, plan_status, archived_at"),
2761
+ db.from("workspaces").select("id, slug, created_at, agent_connected_at, plan, plan_status, trial_ends_at, archived_at"),
2703
2762
  db.from("workspace_settings").select("profile, display_name, logo"),
2704
2763
  db.from("channels").select("profile, is_default").is("archived_at", null),
2705
2764
  db.from("memberships").select("workspace_id, user_id, email, handle, role, accepted_at").eq("status", "active").eq("is_support", false).order("invited_at", { ascending: true }),
@@ -2746,7 +2805,7 @@ async function listWorkspaceSummaries() {
2746
2805
  agentConnectedAt: w.agent_connected_at,
2747
2806
  plan: w.plan ?? null,
2748
2807
  planStatus,
2749
- trialEndsAt: planStatus === "trialing" ? new Date(new Date(createdAt).getTime() + TRIAL_DAYS * 864e5).toISOString() : null,
2808
+ trialEndsAt: planStatus === "trialing" ? w.trial_ends_at ?? null : null,
2750
2809
  archivedAt: w.archived_at ?? null,
2751
2810
  displayName: displayNames.get(w.slug) || null,
2752
2811
  logo: logos.get(w.slug) || null,
@@ -2780,7 +2839,8 @@ async function setWorkspaceStripeSubscription(workspaceId, fields) {
2780
2839
  plan: fields.plan,
2781
2840
  stripe_customer_id: fields.stripeCustomerId,
2782
2841
  stripe_subscription_id: fields.stripeSubscriptionId,
2783
- plan_status: fields.planStatus
2842
+ plan_status: fields.planStatus,
2843
+ trial_ends_at: fields.trialEndsAt
2784
2844
  }).eq("id", workspaceId);
2785
2845
  if (error) throw new Error(`setWorkspaceStripeSubscription(${workspaceId}): ${error.message}`);
2786
2846
  }
@@ -2827,8 +2887,8 @@ async function getWorkspaceBilling(workspaceId) {
2827
2887
  stripeSubscriptionId: row["stripe_subscription_id"] ?? null
2828
2888
  };
2829
2889
  }
2830
- async function updateWorkspacePlanStatus(workspaceId, planStatus) {
2831
- const { error } = await getSupabaseClient().from("workspaces").update({ plan_status: planStatus }).eq("id", workspaceId);
2890
+ async function updateWorkspacePlanStatus(workspaceId, planStatus, trialEndsAt) {
2891
+ const { error } = await getSupabaseClient().from("workspaces").update({ plan_status: planStatus, trial_ends_at: trialEndsAt }).eq("id", workspaceId);
2832
2892
  if (error) throw new Error(`updateWorkspacePlanStatus(${workspaceId}): ${error.message}`);
2833
2893
  planStatusCache.delete(workspaceId);
2834
2894
  }
@@ -2988,6 +3048,15 @@ async function setAllowGuestAccess(workspaceId, allow) {
2988
3048
  const { error } = await getSupabaseClient().from("workspaces").update({ allow_guest_access: allow }).eq("id", workspaceId);
2989
3049
  if (error) throw new Error(`setAllowGuestAccess(${workspaceId}): ${error.message}`);
2990
3050
  }
3051
+ async function getWorkspacePermissionMode(workspaceId) {
3052
+ const { data, error } = await getSupabaseClient().from("workspaces").select("permission_mode").eq("id", workspaceId).maybeSingle();
3053
+ if (error) throw new Error(`getWorkspacePermissionMode(${workspaceId}): ${error.message}`);
3054
+ return isPermissionMode(data?.["permission_mode"]) ? data["permission_mode"] : "bypass";
3055
+ }
3056
+ async function setWorkspacePermissionMode(workspaceId, mode) {
3057
+ const { error } = await getSupabaseClient().from("workspaces").update({ permission_mode: mode }).eq("id", workspaceId);
3058
+ if (error) throw new Error(`setWorkspacePermissionMode(${workspaceId}): ${error.message}`);
3059
+ }
2991
3060
  async function getAgentPaused(workspaceId) {
2992
3061
  const { data, error } = await getSupabaseClient().from("workspaces").select("agent_paused").eq("id", workspaceId).maybeSingle();
2993
3062
  if (error) throw new Error(`getAgentPaused(${workspaceId}): ${error.message}`);
@@ -3332,7 +3401,8 @@ function normalizeProviders(entries) {
3332
3401
  for (const entry of entries) {
3333
3402
  if (!KNOWN_RUNNERS.includes(entry.runner) || seen.has(entry.runner)) continue;
3334
3403
  seen.add(entry.runner);
3335
- const model = entry.model && isAllowedModel(entry.model) && runnerForModel(entry.model) === entry.runner ? entry.model : void 0;
3404
+ const upgraded = upgradeModel(entry.model);
3405
+ const model = upgraded && isAllowedModel(upgraded) && runnerForModel(upgraded) === entry.runner ? upgraded : void 0;
3336
3406
  chain.push({ runner: entry.runner, ...model ? { model } : {} });
3337
3407
  }
3338
3408
  for (const runner of KNOWN_RUNNERS) {
@@ -3627,7 +3697,7 @@ function buildArgs2(prompt, options, lastMessageFile, resumeSessionId) {
3627
3697
  } else if (!resumeSessionId) {
3628
3698
  args.push("-s", sandbox);
3629
3699
  }
3630
- if (options.model) args.push("-m", options.model);
3700
+ if (options.model) args.push("-m", upgradeModel(options.model));
3631
3701
  if (options.effort) args.push("-c", `model_reasoning_effort=${resolveCodexEffort(options.effort)}`);
3632
3702
  if (resumeSessionId) args.push(resumeSessionId);
3633
3703
  args.push(applySystemPrompt(prompt, options, resumeSessionId));
@@ -4453,6 +4523,8 @@ async function runAutomation(opts) {
4453
4523
  model,
4454
4524
  maxBudgetUsd,
4455
4525
  channelPrompt: resolveChannelPrompt(channel),
4526
+ // Nobody is watching a scheduled run: in `ask` mode a blocked call is denied.
4527
+ permissionMode: resolveChannelPermissionMode(channel),
4456
4528
  ...memory.memoryPrompt ? { memoryPrompt: memory.memoryPrompt } : {},
4457
4529
  ...memory.enabled ? { disableAutoMemory: true } : {},
4458
4530
  // No userId: nobody triggered this. The schedule's name is the
@@ -6097,8 +6169,9 @@ function collectFrom(root, source, maxDepth, namePrefix) {
6097
6169
  const fm = parseFrontmatter(file);
6098
6170
  const name = fm.name?.trim() || basename2(dirname2(file));
6099
6171
  const plugin = source === "plugin" ? pluginNameFor(file, root) : void 0;
6172
+ const prefix = namePrefix ?? plugin;
6100
6173
  return {
6101
- name: namePrefix ? `${namePrefix}:${name}` : name,
6174
+ name: prefix ? `${prefix}:${name}` : name,
6102
6175
  description: (fm.description ?? "").trim(),
6103
6176
  source,
6104
6177
  ...plugin && { plugin },
@@ -6172,7 +6245,9 @@ function findSkillDetail(configDir, cwd, name, sources) {
6172
6245
  for (const file of files) {
6173
6246
  const fm = parseFrontmatter(file);
6174
6247
  const rawName = fm.name?.trim() || basename2(dirname2(file));
6175
- const skillName = namePrefix ? `${namePrefix}:${rawName}` : rawName;
6248
+ const plugin = source === "plugin" ? pluginNameFor(file, root) : void 0;
6249
+ const prefix = namePrefix ?? plugin;
6250
+ const skillName = prefix ? `${prefix}:${rawName}` : rawName;
6176
6251
  if (skillName !== name) continue;
6177
6252
  let raw;
6178
6253
  let mtime;
@@ -6183,7 +6258,6 @@ function findSkillDetail(configDir, cwd, name, sources) {
6183
6258
  continue;
6184
6259
  }
6185
6260
  const { body } = splitFrontmatter(raw);
6186
- const plugin = source === "plugin" ? pluginNameFor(file, root) : void 0;
6187
6261
  return {
6188
6262
  name: skillName,
6189
6263
  description: (fm.description ?? "").trim(),
@@ -6667,12 +6741,12 @@ ${trimmedDetail.slice(0, 1500)}
6667
6741
  const threadEffortOverride = store.getEffortOverride(channelId, sessionKey);
6668
6742
  const effectiveEffort = resolveEffort(threadEffortOverride, channelId, config.effort);
6669
6743
  const threadModelOverride = store.getModelOverride(channelId, sessionKey);
6670
- const effectiveModel = resolveModel(threadModelOverride, channelId, model);
6744
+ const effectiveModel2 = resolveModel(threadModelOverride, channelId, model);
6671
6745
  const runner = threadModelOverride ? runnerForModel(threadModelOverride) : runnerForModel(loadDashboardSettings().agent);
6672
6746
  if (runner === "codex") {
6673
6747
  const stored = store.getSession(channelId, sessionKey);
6674
6748
  const resumeId = stored?.runner === "codex" ? stored.sessionId : void 0;
6675
- const codexModel = isCodexModel(effectiveModel) ? effectiveModel : config.codexModel;
6749
+ const codexModel = isCodexModel(effectiveModel2) ? effectiveModel2 : config.codexModel;
6676
6750
  const codexOptions = {
6677
6751
  ...codexModel ? { model: codexModel } : {},
6678
6752
  ...effectiveEffort ? { effort: effectiveEffort } : {},
@@ -6773,13 +6847,15 @@ ${trimmedDetail.slice(0, 1500)}
6773
6847
  return;
6774
6848
  }
6775
6849
  const askOptions = {
6776
- model: effectiveModel,
6850
+ model: effectiveModel2,
6777
6851
  effort: effectiveEffort,
6778
6852
  maxBudgetUsd,
6779
6853
  // Channel-level instructions (channels.prompt), appended to the
6780
6854
  // workspace prompt for this channel only — same source the dashboard
6781
6855
  // chat path reads through resolveChannelConfig().
6782
6856
  channelPrompt: resolveChannelPrompt(channelId),
6857
+ // No prompt tool here: in `ask` mode a blocked call is just denied.
6858
+ permissionMode: resolveChannelPermissionMode(channelId),
6783
6859
  signal: abortController.signal,
6784
6860
  // Attribution for the usage row each spawn writes. Sharing one options
6785
6861
  // object across every attempt is deliberate: the retries below are
@@ -9165,6 +9241,7 @@ export {
9165
9241
  loadConfig,
9166
9242
  refreshAutomationRegistry,
9167
9243
  startAutomationRegistryPolling,
9244
+ isPermissionMode,
9168
9245
  isLogicalCwd,
9169
9246
  isUnderLogicalRoot,
9170
9247
  ensureLogicalCwdDir,
@@ -9180,6 +9257,7 @@ export {
9180
9257
  auditChannelCwds,
9181
9258
  warnOnBrokenChannelCwds,
9182
9259
  resolveCwd,
9260
+ resolveChannelPermissionMode,
9183
9261
  resolveChannelPrompt,
9184
9262
  ChannelCwdError,
9185
9263
  createChannel,
@@ -9193,6 +9271,12 @@ export {
9193
9271
  DEFAULT_TIMEZONE,
9194
9272
  loadAutomations,
9195
9273
  loadEffectiveAutomations,
9274
+ effectiveModel,
9275
+ runnerForModel,
9276
+ isCodexModel,
9277
+ agentLabel,
9278
+ isAllowedModel,
9279
+ modelLabel,
9196
9280
  BUILT_IN_OUTPUT_STYLES,
9197
9281
  OutputStyleConflictError,
9198
9282
  listOutputStyles,
@@ -9202,11 +9286,6 @@ export {
9202
9286
  resolveSelectedOutputStyle,
9203
9287
  getOutputStyleDefault,
9204
9288
  setOutputStyleDefault,
9205
- runnerForModel,
9206
- isCodexModel,
9207
- agentLabel,
9208
- isAllowedModel,
9209
- modelLabel,
9210
9289
  usageLimitedUntil,
9211
9290
  usageLimitedModels,
9212
9291
  clearClaudeAuthFailed,
@@ -9281,6 +9360,8 @@ export {
9281
9360
  transferWorkspaceAdmin,
9282
9361
  getAllowGuestAccess,
9283
9362
  setAllowGuestAccess,
9363
+ getWorkspacePermissionMode,
9364
+ setWorkspacePermissionMode,
9284
9365
  getAgentPaused,
9285
9366
  setAgentPaused,
9286
9367
  loadAgentMemory,