flyspace-cli 0.1.65 → 0.1.66
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/{chunk-5ISKGSFF.js → chunk-DVHYIWIW.js} +180 -10
- package/dist/{chunk-O7OYNQND.js → chunk-KPZOOR73.js} +14 -8
- package/dist/{chunk-GQ2QZ5WF.js → chunk-ODQS4YBM.js} +1 -1
- package/dist/cli.js +429 -213
- package/dist/index.js +2 -2
- package/dist/{threads-AR6D7V3Y.js → threads-62Y2BIFT.js} +2 -2
- package/package.json +1 -1
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
sweepScratchDir,
|
|
31
31
|
uploadLocalImages,
|
|
32
32
|
useHostDbWithoutCredentials
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-KPZOOR73.js";
|
|
34
34
|
|
|
35
35
|
// ../../node_modules/.pnpm/delayed-stream@1.0.0/node_modules/delayed-stream/lib/delayed_stream.js
|
|
36
36
|
var require_delayed_stream = __commonJS({
|
|
@@ -17878,11 +17878,6 @@ var require_dist = __commonJS({
|
|
|
17878
17878
|
// src/index.ts
|
|
17879
17879
|
import { execFile as execFile2, spawn as spawn6 } from "child_process";
|
|
17880
17880
|
|
|
17881
|
-
// src/companion/index.ts
|
|
17882
|
-
import { mkdtempSync, rmSync as rmSync2 } from "fs";
|
|
17883
|
-
import { tmpdir } from "os";
|
|
17884
|
-
import { join as join5 } from "path";
|
|
17885
|
-
|
|
17886
17881
|
// ../api/src/channels.ts
|
|
17887
17882
|
import { createHash } from "crypto";
|
|
17888
17883
|
import { existsSync, mkdirSync, realpathSync, statSync } from "fs";
|
|
@@ -17924,6 +17919,37 @@ function resolveOwnPersona(channelId) {
|
|
|
17924
17919
|
const channel = channelId ? findChannel(channelId) : void 0;
|
|
17925
17920
|
return workspaceOwnPersona.has(channel?.profile ?? getProfile());
|
|
17926
17921
|
}
|
|
17922
|
+
var workspaceAgentDefaults = /* @__PURE__ */ new Map();
|
|
17923
|
+
async function refreshWorkspaceAgentDefaults() {
|
|
17924
|
+
const { data, error } = await getSupabaseClient().from("workspaces").select("slug, default_model, default_effort");
|
|
17925
|
+
if (error) return;
|
|
17926
|
+
workspaceAgentDefaults = new Map(
|
|
17927
|
+
(data ?? []).map((w) => [
|
|
17928
|
+
w.slug,
|
|
17929
|
+
{
|
|
17930
|
+
model: typeof w.default_model === "string" && w.default_model.trim() ? w.default_model.trim() : void 0,
|
|
17931
|
+
effort: typeof w.default_effort === "string" && isEffort(w.default_effort) ? w.default_effort : void 0
|
|
17932
|
+
}
|
|
17933
|
+
])
|
|
17934
|
+
);
|
|
17935
|
+
}
|
|
17936
|
+
function workspaceAgentDefault(profile = getProfile()) {
|
|
17937
|
+
return workspaceAgentDefaults.get(profile) ?? {};
|
|
17938
|
+
}
|
|
17939
|
+
function displayCwd(cwd, hostHome) {
|
|
17940
|
+
const logical = isLogicalCwd(cwd) ? cwd : toLogicalCwd(cwd);
|
|
17941
|
+
let path = cwd;
|
|
17942
|
+
if (isLogicalCwd(logical)) {
|
|
17943
|
+
const [slug, name] = logical.split("/");
|
|
17944
|
+
const root = workspaceRoots.get(slug);
|
|
17945
|
+
path = root ? `${root.replace(/[/\\]+$/, "")}/${name}` : `~/Flyspace/${logical}`;
|
|
17946
|
+
}
|
|
17947
|
+
const home = hostHome?.replace(/[/\\]+$/, "");
|
|
17948
|
+
if (home && (path === home || path.startsWith(`${home}/`) || path.startsWith(`${home}\\`))) {
|
|
17949
|
+
return `~${path.slice(home.length)}`;
|
|
17950
|
+
}
|
|
17951
|
+
return path.replace(/^\/(Users|home)\/[^/]+/, "~").replace(/^\/root(?=\/|$)/, "~").replace(/^[A-Za-z]:\\Users\\[^\\]+/, "~");
|
|
17952
|
+
}
|
|
17927
17953
|
async function refreshWorkspacePermissionModes() {
|
|
17928
17954
|
const { data, error } = await getSupabaseClient().from("workspaces").select("slug, permission_mode");
|
|
17929
17955
|
if (error) return;
|
|
@@ -18046,7 +18072,8 @@ async function refreshChannelRegistry() {
|
|
|
18046
18072
|
refreshWorkspaceRoots(),
|
|
18047
18073
|
refreshWorkspacePermissionModes(),
|
|
18048
18074
|
refreshWorkspaceOwnPersona(),
|
|
18049
|
-
refreshWorkspaceAutoContinueLimits()
|
|
18075
|
+
refreshWorkspaceAutoContinueLimits(),
|
|
18076
|
+
refreshWorkspaceAgentDefaults()
|
|
18050
18077
|
]);
|
|
18051
18078
|
if (JSON.stringify([...workspaceRoots]) !== rootsBefore) lastSnapshot = void 0;
|
|
18052
18079
|
const { data, error } = await getSupabaseClient().from("channels").select("*").order("position", { ascending: true });
|
|
@@ -18424,6 +18451,28 @@ async function ensureMemberDmChannel(a, b) {
|
|
|
18424
18451
|
}
|
|
18425
18452
|
}
|
|
18426
18453
|
|
|
18454
|
+
// src/dashboard/channel-destroy-sweep.ts
|
|
18455
|
+
function watchDestroyedChannels(store) {
|
|
18456
|
+
let known = new Set(getChannelRegistry().map((c) => c.id));
|
|
18457
|
+
return onChannelRegistryChange(() => {
|
|
18458
|
+
const now = new Set(getChannelRegistry().map((c) => c.id));
|
|
18459
|
+
if (now.size === 0) return;
|
|
18460
|
+
for (const id of known) {
|
|
18461
|
+
if (now.has(id)) continue;
|
|
18462
|
+
const removed = store.forgetChannel(id);
|
|
18463
|
+
console.log(
|
|
18464
|
+
`[channels] channel ${id} destroyed: forgot ${removed} cached row(s), local folder untouched`
|
|
18465
|
+
);
|
|
18466
|
+
}
|
|
18467
|
+
known = now;
|
|
18468
|
+
});
|
|
18469
|
+
}
|
|
18470
|
+
|
|
18471
|
+
// src/companion/index.ts
|
|
18472
|
+
import { mkdtempSync, rmSync as rmSync2 } from "fs";
|
|
18473
|
+
import { tmpdir } from "os";
|
|
18474
|
+
import { join as join5 } from "path";
|
|
18475
|
+
|
|
18427
18476
|
// ../api/src/dashboard/auth-context.ts
|
|
18428
18477
|
import { HTTPException } from "hono/http-exception";
|
|
18429
18478
|
import { isAuthApiError, isAuthRetryableFetchError } from "@supabase/supabase-js";
|
|
@@ -18993,6 +19042,14 @@ async function setWorkspaceOwnPersona(workspaceId, enabled) {
|
|
|
18993
19042
|
const { error } = await getSupabaseClient().from("workspaces").update({ own_persona: enabled }).eq("id", workspaceId);
|
|
18994
19043
|
if (error) throw new Error(`setWorkspaceOwnPersona(${workspaceId}): ${error.message}`);
|
|
18995
19044
|
}
|
|
19045
|
+
async function setWorkspaceAgentDefaults(workspaceId, patch) {
|
|
19046
|
+
const row = {};
|
|
19047
|
+
if (patch.defaultModel !== void 0) row["default_model"] = patch.defaultModel;
|
|
19048
|
+
if (patch.defaultEffort !== void 0) row["default_effort"] = patch.defaultEffort;
|
|
19049
|
+
if (!Object.keys(row).length) return;
|
|
19050
|
+
const { error } = await getSupabaseClient().from("workspaces").update(row).eq("id", workspaceId);
|
|
19051
|
+
if (error) throw new Error(`setWorkspaceAgentDefaults(${workspaceId}): ${error.message}`);
|
|
19052
|
+
}
|
|
18996
19053
|
async function setWorkspacePermissionMode(workspaceId, mode) {
|
|
18997
19054
|
const { error } = await getSupabaseClient().from("workspaces").update({ permission_mode: mode }).eq("id", workspaceId);
|
|
18998
19055
|
if (error) throw new Error(`setWorkspacePermissionMode(${workspaceId}): ${error.message}`);
|
|
@@ -19007,6 +19064,105 @@ async function setAgentPaused(workspaceId, paused) {
|
|
|
19007
19064
|
if (error) throw new Error(`setAgentPaused(${workspaceId}): ${error.message}`);
|
|
19008
19065
|
}
|
|
19009
19066
|
|
|
19067
|
+
// ../api/src/store/support-store.ts
|
|
19068
|
+
var SUPPORT_HANDLE = "flyspace-support";
|
|
19069
|
+
async function logSupportAction(entry) {
|
|
19070
|
+
const { error } = await getSupabaseClient().from("support_access_log").insert({
|
|
19071
|
+
workspace_id: entry.workspaceId,
|
|
19072
|
+
staff_user_id: entry.staffUserId,
|
|
19073
|
+
staff_email: entry.staffEmail,
|
|
19074
|
+
action: entry.action,
|
|
19075
|
+
detail: entry.detail ?? null
|
|
19076
|
+
});
|
|
19077
|
+
if (error) throw new Error(`logSupportAction(${entry.action}): ${error.message}`);
|
|
19078
|
+
}
|
|
19079
|
+
async function listSupportWorkspaceIds(userId) {
|
|
19080
|
+
const { data, error } = await getSupabaseClient().from("memberships").select("workspace_id").eq("user_id", userId).eq("is_support", true);
|
|
19081
|
+
if (error) throw new Error(`listSupportWorkspaceIds: ${error.message}`);
|
|
19082
|
+
return new Set((data ?? []).map((r) => r.workspace_id));
|
|
19083
|
+
}
|
|
19084
|
+
async function grantSupportMembership(params) {
|
|
19085
|
+
const db = getSupabaseClient();
|
|
19086
|
+
const { data: existing, error: readError } = await db.from("memberships").select("is_support").eq("workspace_id", params.workspaceId).eq("user_id", params.userId).maybeSingle();
|
|
19087
|
+
if (readError) throw new Error(`grantSupportMembership: ${readError.message}`);
|
|
19088
|
+
if (existing) {
|
|
19089
|
+
if (existing.is_support === true) return "existing";
|
|
19090
|
+
throw new Error("already a regular member of this workspace");
|
|
19091
|
+
}
|
|
19092
|
+
const { data: taken } = await db.from("memberships").select("id").eq("workspace_id", params.workspaceId).eq("handle", SUPPORT_HANDLE).maybeSingle();
|
|
19093
|
+
const handle = taken ? `${SUPPORT_HANDLE}-${params.userId.slice(0, 8)}` : SUPPORT_HANDLE;
|
|
19094
|
+
const { error } = await db.from("memberships").insert({
|
|
19095
|
+
workspace_id: params.workspaceId,
|
|
19096
|
+
user_id: params.userId,
|
|
19097
|
+
email: params.email,
|
|
19098
|
+
handle,
|
|
19099
|
+
role: "admin",
|
|
19100
|
+
status: "active",
|
|
19101
|
+
is_support: true,
|
|
19102
|
+
accepted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
19103
|
+
});
|
|
19104
|
+
if (error) throw new Error(`grantSupportMembership: ${error.message}`);
|
|
19105
|
+
return "granted";
|
|
19106
|
+
}
|
|
19107
|
+
async function revokeSupportMembership(workspaceId, userId) {
|
|
19108
|
+
const { data, error } = await getSupabaseClient().from("memberships").delete().eq("workspace_id", workspaceId).eq("user_id", userId).eq("is_support", true).select("id");
|
|
19109
|
+
if (error) throw new Error(`revokeSupportMembership: ${error.message}`);
|
|
19110
|
+
return (data ?? []).length > 0;
|
|
19111
|
+
}
|
|
19112
|
+
async function listSupportLog(filter) {
|
|
19113
|
+
let query = getSupabaseClient().from("support_access_log").select("*").order("created_at", { ascending: false }).limit(Math.min(filter.limit ?? 200, 1e3));
|
|
19114
|
+
if (filter.workspaceId) query = query.eq("workspace_id", filter.workspaceId);
|
|
19115
|
+
const { data, error } = await query;
|
|
19116
|
+
if (error) throw new Error(`listSupportLog: ${error.message}`);
|
|
19117
|
+
return (data ?? []).map((r) => ({
|
|
19118
|
+
id: r.id,
|
|
19119
|
+
workspaceId: r.workspace_id,
|
|
19120
|
+
staffUserId: r.staff_user_id,
|
|
19121
|
+
staffEmail: r.staff_email,
|
|
19122
|
+
action: r.action,
|
|
19123
|
+
detail: r.detail ?? null,
|
|
19124
|
+
createdAt: r.created_at
|
|
19125
|
+
}));
|
|
19126
|
+
}
|
|
19127
|
+
var SUPPORT_GRANT_HOURS = [1, 24, 168, 720, 0];
|
|
19128
|
+
var SUPPORT_GRANT_FOREVER = "9999-12-31T00:00:00.000Z";
|
|
19129
|
+
async function getActiveSupportGrant(workspaceId) {
|
|
19130
|
+
const { data, error } = await getSupabaseClient().from("support_access_grants").select("id, granted_by_email, reason, expires_at, created_at").eq("workspace_id", workspaceId).is("revoked_at", null).gt("expires_at", (/* @__PURE__ */ new Date()).toISOString()).order("expires_at", { ascending: false }).limit(1).maybeSingle();
|
|
19131
|
+
if (error) throw new Error(`getActiveSupportGrant: ${error.message}`);
|
|
19132
|
+
if (!data) return null;
|
|
19133
|
+
return {
|
|
19134
|
+
id: data.id,
|
|
19135
|
+
grantedByEmail: data.granted_by_email,
|
|
19136
|
+
reason: data.reason ?? null,
|
|
19137
|
+
expiresAt: data.expires_at,
|
|
19138
|
+
createdAt: data.created_at
|
|
19139
|
+
};
|
|
19140
|
+
}
|
|
19141
|
+
async function createSupportGrant(params) {
|
|
19142
|
+
await revokeSupportGrants(params.workspaceId, params.userId);
|
|
19143
|
+
const expiresAt = params.hours === 0 ? SUPPORT_GRANT_FOREVER : new Date(Date.now() + params.hours * 36e5).toISOString();
|
|
19144
|
+
const { data, error } = await getSupabaseClient().from("support_access_grants").insert({
|
|
19145
|
+
workspace_id: params.workspaceId,
|
|
19146
|
+
granted_by: params.userId,
|
|
19147
|
+
granted_by_email: params.email,
|
|
19148
|
+
reason: params.reason ?? null,
|
|
19149
|
+
expires_at: expiresAt
|
|
19150
|
+
}).select("id, granted_by_email, reason, expires_at, created_at").single();
|
|
19151
|
+
if (error) throw new Error(`createSupportGrant: ${error.message}`);
|
|
19152
|
+
return {
|
|
19153
|
+
id: data.id,
|
|
19154
|
+
grantedByEmail: data.granted_by_email,
|
|
19155
|
+
reason: data.reason ?? null,
|
|
19156
|
+
expiresAt: data.expires_at,
|
|
19157
|
+
createdAt: data.created_at
|
|
19158
|
+
};
|
|
19159
|
+
}
|
|
19160
|
+
async function revokeSupportGrants(workspaceId, userId) {
|
|
19161
|
+
const { data, error } = await getSupabaseClient().from("support_access_grants").update({ revoked_at: (/* @__PURE__ */ new Date()).toISOString(), revoked_by: userId }).eq("workspace_id", workspaceId).is("revoked_at", null).gt("expires_at", (/* @__PURE__ */ new Date()).toISOString()).select("id");
|
|
19162
|
+
if (error) throw new Error(`revokeSupportGrants: ${error.message}`);
|
|
19163
|
+
return (data ?? []).length;
|
|
19164
|
+
}
|
|
19165
|
+
|
|
19010
19166
|
// ../api/src/dashboard/auth-context.ts
|
|
19011
19167
|
function onboardingPending(ctx) {
|
|
19012
19168
|
const pending = [];
|
|
@@ -19087,6 +19243,7 @@ async function resolveAuthContextUncached(c) {
|
|
|
19087
19243
|
if (!workspace) return null;
|
|
19088
19244
|
const membership = await getMembershipByEmail(workspace.id, user.email);
|
|
19089
19245
|
if (!membership) return null;
|
|
19246
|
+
if (membership.isSupport && !await getActiveSupportGrant(workspace.id)) return null;
|
|
19090
19247
|
if (membership.status === "invited") {
|
|
19091
19248
|
await activateMembership(workspace.id, user.email);
|
|
19092
19249
|
}
|
|
@@ -25529,7 +25686,7 @@ async function withMcpConfig(profile, connectionIds, fn, extraServers = {}) {
|
|
|
25529
25686
|
|
|
25530
25687
|
// ../api/src/version.ts
|
|
25531
25688
|
import { readFileSync as readFileSync8 } from "fs";
|
|
25532
|
-
var CLI_VERSION = true ? "0.1.
|
|
25689
|
+
var CLI_VERSION = true ? "0.1.66" : devVersion();
|
|
25533
25690
|
function isOlderVersion(a, b) {
|
|
25534
25691
|
const parse2 = (v) => v.replace(/^v/, "").split("-")[0].split(".").map(Number);
|
|
25535
25692
|
const [pa, pb] = [parse2(a), parse2(b)];
|
|
@@ -26094,9 +26251,11 @@ function defaultClaudeCwd() {
|
|
|
26094
26251
|
return profileEnv("CLAUDE_CWD") ?? process.cwd();
|
|
26095
26252
|
}
|
|
26096
26253
|
function defaultModel() {
|
|
26097
|
-
return cachedProfileConfig()?.agentModel || profileEnv("CUSTIE_MODEL")?.trim() || "sonnet";
|
|
26254
|
+
return cachedProfileConfig()?.agentModel || workspaceAgentDefault().model || profileEnv("CUSTIE_MODEL")?.trim() || "sonnet";
|
|
26098
26255
|
}
|
|
26099
26256
|
function defaultEffort() {
|
|
26257
|
+
const stored = workspaceAgentDefault().effort;
|
|
26258
|
+
if (stored) return stored;
|
|
26100
26259
|
const raw = profileEnv("CUSTIE_EFFORT")?.trim().toLowerCase();
|
|
26101
26260
|
return raw && isEffort(raw) ? raw : void 0;
|
|
26102
26261
|
}
|
|
@@ -31281,7 +31440,6 @@ var SETTINGS_SECTIONS = [
|
|
|
31281
31440
|
"activity",
|
|
31282
31441
|
"channels",
|
|
31283
31442
|
"domain",
|
|
31284
|
-
"workspaces",
|
|
31285
31443
|
"usage",
|
|
31286
31444
|
"sessions",
|
|
31287
31445
|
"mcp-servers",
|
|
@@ -35366,6 +35524,7 @@ async function startServer() {
|
|
|
35366
35524
|
const caffeinate = startCaffeinate();
|
|
35367
35525
|
const config = loadConfig();
|
|
35368
35526
|
const store = new SessionStore(paths.DB_FILE);
|
|
35527
|
+
watchDestroyedChannels(store);
|
|
35369
35528
|
const runStore = new AutomationRunStore(paths.DB_FILE);
|
|
35370
35529
|
installUsageRecording();
|
|
35371
35530
|
const stopRunSync = databaseReachable() ? startAutomationRunSync(runStore, getProfile(), {
|
|
@@ -35433,6 +35592,7 @@ export {
|
|
|
35433
35592
|
useLocalCache,
|
|
35434
35593
|
isPermissionMode,
|
|
35435
35594
|
isLogicalCwd,
|
|
35595
|
+
displayCwd,
|
|
35436
35596
|
isUnderLogicalRoot,
|
|
35437
35597
|
expandPath,
|
|
35438
35598
|
canSeeChannel,
|
|
@@ -35503,9 +35663,19 @@ export {
|
|
|
35503
35663
|
setWorkspaceAutoContinueLimit,
|
|
35504
35664
|
getWorkspaceOwnPersona,
|
|
35505
35665
|
setWorkspaceOwnPersona,
|
|
35666
|
+
setWorkspaceAgentDefaults,
|
|
35506
35667
|
setWorkspacePermissionMode,
|
|
35507
35668
|
getAgentPaused,
|
|
35508
35669
|
setAgentPaused,
|
|
35670
|
+
logSupportAction,
|
|
35671
|
+
listSupportWorkspaceIds,
|
|
35672
|
+
grantSupportMembership,
|
|
35673
|
+
revokeSupportMembership,
|
|
35674
|
+
listSupportLog,
|
|
35675
|
+
SUPPORT_GRANT_HOURS,
|
|
35676
|
+
getActiveSupportGrant,
|
|
35677
|
+
createSupportGrant,
|
|
35678
|
+
revokeSupportGrants,
|
|
35509
35679
|
onboardingPending,
|
|
35510
35680
|
invalidateAuthContextCache,
|
|
35511
35681
|
SUPPORT_AVATAR_URL,
|
|
@@ -221,23 +221,18 @@ import { existsSync as existsSync2 } from "fs";
|
|
|
221
221
|
import { resolve as resolve2 } from "path";
|
|
222
222
|
|
|
223
223
|
// ../api/src/effort.ts
|
|
224
|
-
var EFFORT_LEVELS = ["low", "medium", "high", "max"];
|
|
224
|
+
var EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
|
|
225
225
|
function isEffort(value) {
|
|
226
226
|
return EFFORT_LEVELS.includes(value);
|
|
227
227
|
}
|
|
228
|
-
var CLAUDE_EFFORT = {
|
|
229
|
-
low: "low",
|
|
230
|
-
medium: "medium",
|
|
231
|
-
high: "xhigh",
|
|
232
|
-
max: "max"
|
|
233
|
-
};
|
|
234
228
|
function resolveClaudeEffort(effort) {
|
|
235
|
-
return
|
|
229
|
+
return effort;
|
|
236
230
|
}
|
|
237
231
|
var CODEX_EFFORT = {
|
|
238
232
|
low: "low",
|
|
239
233
|
medium: "medium",
|
|
240
234
|
high: "high",
|
|
235
|
+
xhigh: "high",
|
|
241
236
|
max: "high"
|
|
242
237
|
};
|
|
243
238
|
function resolveCodexEffort(effort) {
|
|
@@ -551,6 +546,17 @@ var SessionStore = class {
|
|
|
551
546
|
const result = this.db.prepare("DELETE FROM sessions WHERE channel_id = ?").run(channelId);
|
|
552
547
|
return result.changes;
|
|
553
548
|
}
|
|
549
|
+
/**
|
|
550
|
+
* Drop every cached row (sessions and `!model`/`!effort` overrides) for a
|
|
551
|
+
* channel that was destroyed in the cloud. Only SQLite rows: the channel's
|
|
552
|
+
* folder and the CLI transcripts on disk are never touched.
|
|
553
|
+
*/
|
|
554
|
+
forgetChannel(channelId) {
|
|
555
|
+
let removed = 0;
|
|
556
|
+
for (const table of ["sessions", "model_overrides", "effort_overrides"])
|
|
557
|
+
removed += this.db.prepare(`DELETE FROM ${table} WHERE channel_id = ?`).run(channelId).changes;
|
|
558
|
+
return removed;
|
|
559
|
+
}
|
|
554
560
|
/**
|
|
555
561
|
* Re-key a single thread's rows onto a different channel. `sessions`,
|
|
556
562
|
* `model_overrides` and `effort_overrides` are all keyed by (channel_id,
|