flyspace-cli 0.1.48 → 0.1.50

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({
@@ -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;
@@ -1895,7 +1943,7 @@ function buildArgs(prompt, botName, options, resumeSessionId, isolatedStyle) {
1895
1943
  // activity); plain json emits one blob on completion. stream-json with
1896
1944
  // --print requires --verbose.
1897
1945
  ...options.onActivity ? ["--output-format", "stream-json", "--verbose"] : ["--output-format", "json"],
1898
- "--dangerously-skip-permissions",
1946
+ ...permissionArgs(options.permissionMode, options.permissionPromptTool),
1899
1947
  "--no-chrome",
1900
1948
  // `=` form: the flag is variadic and would otherwise swallow the next token.
1901
1949
  ...docsAccessDisallowedTools(options.docsAccess).length > 0 ? [`--disallowedTools=${docsAccessDisallowedTools(options.docsAccess).join(",")}`] : [],
@@ -1931,8 +1979,9 @@ function buildArgs(prompt, botName, options, resumeSessionId, isolatedStyle) {
1931
1979
  if (options.mcpConfigPath) {
1932
1980
  args.push("--mcp-config", options.mcpConfigPath);
1933
1981
  }
1934
- if (options.model && isModelForGateway(options.model, process.env["ANTHROPIC_MODEL"])) {
1935
- 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));
1936
1985
  }
1937
1986
  if (options.effort) {
1938
1987
  args.push("--effort", resolveClaudeEffort(options.effort));
@@ -1972,6 +2021,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
1972
2021
  );
1973
2022
  const env = resolveMiseEnv(cwd);
1974
2023
  env["FLYSPACE_SCRATCH_DIR"] = paths.SCRATCH_DIR;
2024
+ if (options.permissionPromptTool && !env["MCP_TOOL_TIMEOUT"]) env["MCP_TOOL_TIMEOUT"] = "360000";
1975
2025
  env["CLAUDE_CODE_ARTIFACT"] = "1";
1976
2026
  if (options.disableAutoMemory) env["CLAUDE_CODE_DISABLE_AUTO_MEMORY"] = "1";
1977
2027
  else delete env["CLAUDE_CODE_DISABLE_AUTO_MEMORY"];
@@ -2292,6 +2342,11 @@ var featureFlags = {
2292
2342
  title: "Autocomplete",
2293
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.",
2294
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"
2295
2350
  }
2296
2351
  };
2297
2352
  var featureFlagIds = Object.keys(featureFlags);
@@ -2703,7 +2758,7 @@ var TRIAL_DAYS = 14;
2703
2758
  async function listWorkspaceSummaries() {
2704
2759
  const db = getSupabaseClient();
2705
2760
  const [workspaces, settings, channels, memberships, activity] = await Promise.all([
2706
- 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"),
2707
2762
  db.from("workspace_settings").select("profile, display_name, logo"),
2708
2763
  db.from("channels").select("profile, is_default").is("archived_at", null),
2709
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 }),
@@ -2750,7 +2805,7 @@ async function listWorkspaceSummaries() {
2750
2805
  agentConnectedAt: w.agent_connected_at,
2751
2806
  plan: w.plan ?? null,
2752
2807
  planStatus,
2753
- trialEndsAt: planStatus === "trialing" ? new Date(new Date(createdAt).getTime() + TRIAL_DAYS * 864e5).toISOString() : null,
2808
+ trialEndsAt: planStatus === "trialing" ? w.trial_ends_at ?? null : null,
2754
2809
  archivedAt: w.archived_at ?? null,
2755
2810
  displayName: displayNames.get(w.slug) || null,
2756
2811
  logo: logos.get(w.slug) || null,
@@ -2784,7 +2839,8 @@ async function setWorkspaceStripeSubscription(workspaceId, fields) {
2784
2839
  plan: fields.plan,
2785
2840
  stripe_customer_id: fields.stripeCustomerId,
2786
2841
  stripe_subscription_id: fields.stripeSubscriptionId,
2787
- plan_status: fields.planStatus
2842
+ plan_status: fields.planStatus,
2843
+ trial_ends_at: fields.trialEndsAt
2788
2844
  }).eq("id", workspaceId);
2789
2845
  if (error) throw new Error(`setWorkspaceStripeSubscription(${workspaceId}): ${error.message}`);
2790
2846
  }
@@ -2831,8 +2887,8 @@ async function getWorkspaceBilling(workspaceId) {
2831
2887
  stripeSubscriptionId: row["stripe_subscription_id"] ?? null
2832
2888
  };
2833
2889
  }
2834
- async function updateWorkspacePlanStatus(workspaceId, planStatus) {
2835
- 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);
2836
2892
  if (error) throw new Error(`updateWorkspacePlanStatus(${workspaceId}): ${error.message}`);
2837
2893
  planStatusCache.delete(workspaceId);
2838
2894
  }
@@ -2992,6 +3048,15 @@ async function setAllowGuestAccess(workspaceId, allow) {
2992
3048
  const { error } = await getSupabaseClient().from("workspaces").update({ allow_guest_access: allow }).eq("id", workspaceId);
2993
3049
  if (error) throw new Error(`setAllowGuestAccess(${workspaceId}): ${error.message}`);
2994
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
+ }
2995
3060
  async function getAgentPaused(workspaceId) {
2996
3061
  const { data, error } = await getSupabaseClient().from("workspaces").select("agent_paused").eq("id", workspaceId).maybeSingle();
2997
3062
  if (error) throw new Error(`getAgentPaused(${workspaceId}): ${error.message}`);
@@ -3336,7 +3401,8 @@ function normalizeProviders(entries) {
3336
3401
  for (const entry of entries) {
3337
3402
  if (!KNOWN_RUNNERS.includes(entry.runner) || seen.has(entry.runner)) continue;
3338
3403
  seen.add(entry.runner);
3339
- 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;
3340
3406
  chain.push({ runner: entry.runner, ...model ? { model } : {} });
3341
3407
  }
3342
3408
  for (const runner of KNOWN_RUNNERS) {
@@ -3631,7 +3697,7 @@ function buildArgs2(prompt, options, lastMessageFile, resumeSessionId) {
3631
3697
  } else if (!resumeSessionId) {
3632
3698
  args.push("-s", sandbox);
3633
3699
  }
3634
- if (options.model) args.push("-m", options.model);
3700
+ if (options.model) args.push("-m", upgradeModel(options.model));
3635
3701
  if (options.effort) args.push("-c", `model_reasoning_effort=${resolveCodexEffort(options.effort)}`);
3636
3702
  if (resumeSessionId) args.push(resumeSessionId);
3637
3703
  args.push(applySystemPrompt(prompt, options, resumeSessionId));
@@ -4457,6 +4523,8 @@ async function runAutomation(opts) {
4457
4523
  model,
4458
4524
  maxBudgetUsd,
4459
4525
  channelPrompt: resolveChannelPrompt(channel),
4526
+ // Nobody is watching a scheduled run: in `ask` mode a blocked call is denied.
4527
+ permissionMode: resolveChannelPermissionMode(channel),
4460
4528
  ...memory.memoryPrompt ? { memoryPrompt: memory.memoryPrompt } : {},
4461
4529
  ...memory.enabled ? { disableAutoMemory: true } : {},
4462
4530
  // No userId: nobody triggered this. The schedule's name is the
@@ -5696,7 +5764,16 @@ function richTextToMrkdwn(blocks) {
5696
5764
  return lines.length ? lines.join("\n") : null;
5697
5765
  }
5698
5766
  function bodyTextFor(msg) {
5699
- return richTextToMrkdwn(msg.blocks) ?? msg.text ?? "";
5767
+ return (richTextToMrkdwn(msg.blocks) ?? msg.text ?? "").replace(
5768
+ /<@([A-Z0-9]+)>/g,
5769
+ (m, id) => {
5770
+ const name = displayNameFor(id);
5771
+ return name === id ? m : `<@${id}|${name}>`;
5772
+ }
5773
+ );
5774
+ }
5775
+ function mentionedUserIds(msg) {
5776
+ return [...(richTextToMrkdwn(msg.blocks) ?? msg.text ?? "").matchAll(/<@([A-Z0-9]+)>/g)].map((m) => m[1]);
5700
5777
  }
5701
5778
  var SKIP_SUBTYPES = /* @__PURE__ */ new Set([
5702
5779
  "channel_join",
@@ -5745,6 +5822,7 @@ async function mirrorIncomingMessage(client, msg) {
5745
5822
  if (msg.subtype && SKIP_SUBTYPES.has(msg.subtype)) return;
5746
5823
  if (msg.subtype === "message_changed" || msg.subtype === "message_deleted") return;
5747
5824
  try {
5825
+ await ensureUsersCached(client, mentionedUserIds(msg));
5748
5826
  const body = bodyTextFor(msg);
5749
5827
  if (!body) return;
5750
5828
  const supabase = getSupabaseClient();
@@ -6101,8 +6179,9 @@ function collectFrom(root, source, maxDepth, namePrefix) {
6101
6179
  const fm = parseFrontmatter(file);
6102
6180
  const name = fm.name?.trim() || basename2(dirname2(file));
6103
6181
  const plugin = source === "plugin" ? pluginNameFor(file, root) : void 0;
6182
+ const prefix = namePrefix ?? plugin;
6104
6183
  return {
6105
- name: namePrefix ? `${namePrefix}:${name}` : name,
6184
+ name: prefix ? `${prefix}:${name}` : name,
6106
6185
  description: (fm.description ?? "").trim(),
6107
6186
  source,
6108
6187
  ...plugin && { plugin },
@@ -6176,7 +6255,9 @@ function findSkillDetail(configDir, cwd, name, sources) {
6176
6255
  for (const file of files) {
6177
6256
  const fm = parseFrontmatter(file);
6178
6257
  const rawName = fm.name?.trim() || basename2(dirname2(file));
6179
- const skillName = namePrefix ? `${namePrefix}:${rawName}` : rawName;
6258
+ const plugin = source === "plugin" ? pluginNameFor(file, root) : void 0;
6259
+ const prefix = namePrefix ?? plugin;
6260
+ const skillName = prefix ? `${prefix}:${rawName}` : rawName;
6180
6261
  if (skillName !== name) continue;
6181
6262
  let raw;
6182
6263
  let mtime;
@@ -6187,7 +6268,6 @@ function findSkillDetail(configDir, cwd, name, sources) {
6187
6268
  continue;
6188
6269
  }
6189
6270
  const { body } = splitFrontmatter(raw);
6190
- const plugin = source === "plugin" ? pluginNameFor(file, root) : void 0;
6191
6271
  return {
6192
6272
  name: skillName,
6193
6273
  description: (fm.description ?? "").trim(),
@@ -6671,12 +6751,12 @@ ${trimmedDetail.slice(0, 1500)}
6671
6751
  const threadEffortOverride = store.getEffortOverride(channelId, sessionKey);
6672
6752
  const effectiveEffort = resolveEffort(threadEffortOverride, channelId, config.effort);
6673
6753
  const threadModelOverride = store.getModelOverride(channelId, sessionKey);
6674
- const effectiveModel = resolveModel(threadModelOverride, channelId, model);
6754
+ const effectiveModel2 = resolveModel(threadModelOverride, channelId, model);
6675
6755
  const runner = threadModelOverride ? runnerForModel(threadModelOverride) : runnerForModel(loadDashboardSettings().agent);
6676
6756
  if (runner === "codex") {
6677
6757
  const stored = store.getSession(channelId, sessionKey);
6678
6758
  const resumeId = stored?.runner === "codex" ? stored.sessionId : void 0;
6679
- const codexModel = isCodexModel(effectiveModel) ? effectiveModel : config.codexModel;
6759
+ const codexModel = isCodexModel(effectiveModel2) ? effectiveModel2 : config.codexModel;
6680
6760
  const codexOptions = {
6681
6761
  ...codexModel ? { model: codexModel } : {},
6682
6762
  ...effectiveEffort ? { effort: effectiveEffort } : {},
@@ -6777,13 +6857,15 @@ ${trimmedDetail.slice(0, 1500)}
6777
6857
  return;
6778
6858
  }
6779
6859
  const askOptions = {
6780
- model: effectiveModel,
6860
+ model: effectiveModel2,
6781
6861
  effort: effectiveEffort,
6782
6862
  maxBudgetUsd,
6783
6863
  // Channel-level instructions (channels.prompt), appended to the
6784
6864
  // workspace prompt for this channel only — same source the dashboard
6785
6865
  // chat path reads through resolveChannelConfig().
6786
6866
  channelPrompt: resolveChannelPrompt(channelId),
6867
+ // No prompt tool here: in `ask` mode a blocked call is just denied.
6868
+ permissionMode: resolveChannelPermissionMode(channelId),
6787
6869
  signal: abortController.signal,
6788
6870
  // Attribution for the usage row each spawn writes. Sharing one options
6789
6871
  // object across every attempt is deliberate: the retries below are
@@ -9169,6 +9251,7 @@ export {
9169
9251
  loadConfig,
9170
9252
  refreshAutomationRegistry,
9171
9253
  startAutomationRegistryPolling,
9254
+ isPermissionMode,
9172
9255
  isLogicalCwd,
9173
9256
  isUnderLogicalRoot,
9174
9257
  ensureLogicalCwdDir,
@@ -9184,6 +9267,7 @@ export {
9184
9267
  auditChannelCwds,
9185
9268
  warnOnBrokenChannelCwds,
9186
9269
  resolveCwd,
9270
+ resolveChannelPermissionMode,
9187
9271
  resolveChannelPrompt,
9188
9272
  ChannelCwdError,
9189
9273
  createChannel,
@@ -9197,6 +9281,12 @@ export {
9197
9281
  DEFAULT_TIMEZONE,
9198
9282
  loadAutomations,
9199
9283
  loadEffectiveAutomations,
9284
+ effectiveModel,
9285
+ runnerForModel,
9286
+ isCodexModel,
9287
+ agentLabel,
9288
+ isAllowedModel,
9289
+ modelLabel,
9200
9290
  BUILT_IN_OUTPUT_STYLES,
9201
9291
  OutputStyleConflictError,
9202
9292
  listOutputStyles,
@@ -9206,11 +9296,6 @@ export {
9206
9296
  resolveSelectedOutputStyle,
9207
9297
  getOutputStyleDefault,
9208
9298
  setOutputStyleDefault,
9209
- runnerForModel,
9210
- isCodexModel,
9211
- agentLabel,
9212
- isAllowedModel,
9213
- modelLabel,
9214
9299
  usageLimitedUntil,
9215
9300
  usageLimitedModels,
9216
9301
  clearClaudeAuthFailed,
@@ -9285,6 +9370,8 @@ export {
9285
9370
  transferWorkspaceAdmin,
9286
9371
  getAllowGuestAccess,
9287
9372
  setAllowGuestAccess,
9373
+ getWorkspacePermissionMode,
9374
+ setWorkspacePermissionMode,
9288
9375
  getAgentPaused,
9289
9376
  setAgentPaused,
9290
9377
  loadAgentMemory,
@@ -9317,6 +9404,7 @@ export {
9317
9404
  buildFilesPromptSection,
9318
9405
  syncSlackAvatars,
9319
9406
  bodyTextFor,
9407
+ mentionedUserIds,
9320
9408
  SKIP_SUBTYPES,
9321
9409
  tsToIso,
9322
9410
  authorFor,
@@ -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) {