flyspace-cli 0.1.51 → 0.1.52
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-R5RECXRP.js → chunk-ZBOOJCDU.js} +871 -816
- package/dist/cli.js +155 -39
- package/dist/index.js +1 -1
- package/package.json +2 -1
- package/system.capabilities.md +7 -36
- package/system.default.md +3 -3
- package/system.slack.md +28 -0
package/dist/cli.js
CHANGED
|
@@ -35,7 +35,6 @@ import {
|
|
|
35
35
|
bodyTextFor,
|
|
36
36
|
buildAuthorizeUrl,
|
|
37
37
|
buildAutoTitle,
|
|
38
|
-
buildManifest,
|
|
39
38
|
cachedProfileConfig,
|
|
40
39
|
canSeeChannel,
|
|
41
40
|
canonicalLanguage,
|
|
@@ -86,6 +85,7 @@ import {
|
|
|
86
85
|
escalateToHuman,
|
|
87
86
|
exchangeCode,
|
|
88
87
|
expandPath,
|
|
88
|
+
explainCost,
|
|
89
89
|
extractCategories,
|
|
90
90
|
extractTitle,
|
|
91
91
|
filterReadableDocsChannels,
|
|
@@ -208,6 +208,7 @@ import {
|
|
|
208
208
|
resolveCwd,
|
|
209
209
|
resolveDocPath,
|
|
210
210
|
resolveDocsAccess,
|
|
211
|
+
resolveRateCard,
|
|
211
212
|
resolveRawPath,
|
|
212
213
|
resolveUserId,
|
|
213
214
|
revokeDocShare,
|
|
@@ -275,7 +276,7 @@ import {
|
|
|
275
276
|
workspaceHostname,
|
|
276
277
|
workspaceSkillsDir,
|
|
277
278
|
writeSkillFile
|
|
278
|
-
} from "./chunk-
|
|
279
|
+
} from "./chunk-ZBOOJCDU.js";
|
|
279
280
|
import {
|
|
280
281
|
firstReplyBody,
|
|
281
282
|
getThread,
|
|
@@ -1387,12 +1388,12 @@ function assertLinkable(target) {
|
|
|
1387
1388
|
}
|
|
1388
1389
|
if (denied.some((d) => target === d || target.startsWith(`${d}/`))) throw new Error(`cannot link ${target}`);
|
|
1389
1390
|
}
|
|
1390
|
-
function linkProjectFolders(slug,
|
|
1391
|
+
function linkProjectFolders(slug, items2) {
|
|
1391
1392
|
if (!SLUG_RE.test(slug)) throw new Error(`invalid workspace slug: ${slug}`);
|
|
1392
1393
|
const dir = join6(flyspaceRoot(), slug);
|
|
1393
1394
|
mkdirSync4(dir, { recursive: true });
|
|
1394
1395
|
const results = [];
|
|
1395
|
-
for (const item of
|
|
1396
|
+
for (const item of items2) {
|
|
1396
1397
|
if (!SLUG_RE.test(item.name)) throw new Error(`invalid channel name: ${item.name}`);
|
|
1397
1398
|
const dest = join6(dir, item.name);
|
|
1398
1399
|
let exists = true;
|
|
@@ -2345,7 +2346,7 @@ function npmEnv(target) {
|
|
|
2345
2346
|
return nodeBin ? { ...process.env, PATH: `${nodeBin}:${process.env.PATH ?? ""}` } : process.env;
|
|
2346
2347
|
}
|
|
2347
2348
|
async function runUpgrade() {
|
|
2348
|
-
const current = "0.1.
|
|
2349
|
+
const current = "0.1.52";
|
|
2349
2350
|
console.log(`Current version: ${current}`);
|
|
2350
2351
|
console.log("Checking for updates...\n");
|
|
2351
2352
|
try {
|
|
@@ -5767,6 +5768,7 @@ var USAGE4 = `
|
|
|
5767
5768
|
[--thread <id>] [--title <t>]
|
|
5768
5769
|
wake --thread <id> --text <t> Post a background task's result AND start a
|
|
5769
5770
|
new agent turn on the thread to act on it
|
|
5771
|
+
[--about <t>] What the job waits for (shown in the thread)
|
|
5770
5772
|
|
|
5771
5773
|
Options:
|
|
5772
5774
|
--to <name-or-id> Destination channel for "move"
|
|
@@ -7064,9 +7066,9 @@ function createOnboardingRouter(agent) {
|
|
|
7064
7066
|
if (unknown) return c.json({ error: "folder was not offered by the scan" }, 400);
|
|
7065
7067
|
const taken = new Set(getProfileChannelRegistry().map((ch) => ch.name));
|
|
7066
7068
|
taken.add("general");
|
|
7067
|
-
const
|
|
7068
|
-
for (const path of folders)
|
|
7069
|
-
const linked = await agent.linkProjectFolders?.(getProfile(),
|
|
7069
|
+
const items2 = [{ name: "general" }];
|
|
7070
|
+
for (const path of folders) items2.push({ name: uniqueChannelName(offered.get(path).name, taken), path });
|
|
7071
|
+
const linked = await agent.linkProjectFolders?.(getProfile(), items2);
|
|
7070
7072
|
if (!linked) return hostUnavailable(c, agent, "linkProjectFolders");
|
|
7071
7073
|
if (runner === "claude" || runner === "codex") {
|
|
7072
7074
|
await agent.saveLocalDashboardSettings?.({ providers: [{ runner }] });
|
|
@@ -8221,9 +8223,9 @@ async function threadIsKnown(threadId, c) {
|
|
|
8221
8223
|
const channelId = data?.channel_id;
|
|
8222
8224
|
return !!channelId && (await globalChannelMeta(c)).has(channelId);
|
|
8223
8225
|
}
|
|
8224
|
-
function chunk(
|
|
8226
|
+
function chunk(items2, size) {
|
|
8225
8227
|
const out = [];
|
|
8226
|
-
for (let i = 0; i <
|
|
8228
|
+
for (let i = 0; i < items2.length; i += size) out.push(items2.slice(i, i + size));
|
|
8227
8229
|
return out;
|
|
8228
8230
|
}
|
|
8229
8231
|
async function withPreviews(supabase, threads) {
|
|
@@ -11170,6 +11172,21 @@ async function latestMainRun(workspace, threadTs) {
|
|
|
11170
11172
|
label: latest.label ?? void 0
|
|
11171
11173
|
};
|
|
11172
11174
|
}
|
|
11175
|
+
async function threadRuns(workspace, threadTs) {
|
|
11176
|
+
const rows = await fetchUsageRows(workspace, { threadTs });
|
|
11177
|
+
return rows.sort((a, b) => a.ran_at.localeCompare(b.ran_at)).map((r) => ({
|
|
11178
|
+
ranAt: r.ran_at,
|
|
11179
|
+
model: r.model ?? void 0,
|
|
11180
|
+
label: r.label ?? void 0,
|
|
11181
|
+
numTurns: r.num_turns ?? void 0,
|
|
11182
|
+
inputTokens: r.input_tokens,
|
|
11183
|
+
outputTokens: r.output_tokens,
|
|
11184
|
+
cacheReadTokens: r.cache_read_tokens,
|
|
11185
|
+
cacheCreationTokens: r.cache_creation_tokens,
|
|
11186
|
+
costUsd: Number(r.cost_usd),
|
|
11187
|
+
isError: r.is_error
|
|
11188
|
+
}));
|
|
11189
|
+
}
|
|
11173
11190
|
|
|
11174
11191
|
// ../api/src/dashboard/usage-report.ts
|
|
11175
11192
|
import { existsSync as existsSync17 } from "fs";
|
|
@@ -11311,6 +11328,102 @@ async function buildThreadUsage(threadTs) {
|
|
|
11311
11328
|
}
|
|
11312
11329
|
}
|
|
11313
11330
|
|
|
11331
|
+
// ../api/src/dashboard/session-retro.ts
|
|
11332
|
+
var MAX_REPLY_CHARS2 = 600;
|
|
11333
|
+
var MAX_TRANSCRIPT_CHARS = 24e3;
|
|
11334
|
+
var MAX_ACTIVITIES_PER_REPLY = 40;
|
|
11335
|
+
var MAX_ITEMS = 3;
|
|
11336
|
+
var SYSTEM_PROMPT2 = `You review how an AI coding agent spent money in one chat thread and coach the user on doing it cheaper next time. Reply with JSON only, no code fence:
|
|
11337
|
+
{"headline": string, "items": [{"problem": string, "detail": string, "fix": string}]}
|
|
11338
|
+
|
|
11339
|
+
- headline: one sentence on the overall picture (was the spend reasonable for the work done?).
|
|
11340
|
+
- items: at most ${MAX_ITEMS}, the biggest cost drivers you can support from the data, each paired with the one thing the USER can do about it. Examples: the same file or log read repeatedly (fix: ask for a summary or the relevant lines), a long thread that switched topics (fix: start a new thread per topic), returning after a long idle gap so the cache went cold (fix: start a new thread instead of resuming), failed runs retried.
|
|
11341
|
+
- Only habits the user controls. Never mention billing, pricing, cost accounting or the app's own bugs, even if the transcript discusses them: the thread's topic is not a cost driver. Never suggest switching models; the user does not pick the model per turn.
|
|
11342
|
+
- cache_read and context_total are summed over every API call inside one run (turns=N), so a large figure means many steps, not a huge context. Do not call it context size.
|
|
11343
|
+
- Be brief: problem at most 6 words, detail one short clause with a number from the data (at most 15 words), fix one short imperative clause (at most 12 words).
|
|
11344
|
+
- Write in the language the user writes in the transcript. If it is Traditional Chinese, use Taiwan wording, full-width punctuation, and keep technical terms in English.
|
|
11345
|
+
- Never use em dashes or en dashes. No Markdown.`;
|
|
11346
|
+
function runLine(r, i) {
|
|
11347
|
+
const ctx = r.inputTokens + r.cacheReadTokens + r.cacheCreationTokens;
|
|
11348
|
+
return `#${i + 1} ${r.ranAt} model=${r.model ?? "?"}${r.label ? ` label=${r.label}` : ""} turns=${r.numTurns ?? "?"} input=${r.inputTokens} cache_read=${r.cacheReadTokens} cache_write=${r.cacheCreationTokens} output=${r.outputTokens} context_total=${ctx} cost=$${r.costUsd.toFixed(3)}${r.isError ? " FAILED" : ""}`;
|
|
11349
|
+
}
|
|
11350
|
+
function transcriptOf(rows) {
|
|
11351
|
+
const parts = rows.map((r) => {
|
|
11352
|
+
const body = r.body.length > MAX_REPLY_CHARS2 ? `${r.body.slice(0, MAX_REPLY_CHARS2)}\u2026` : r.body;
|
|
11353
|
+
const acts = (r.activities ?? []).slice(0, MAX_ACTIVITIES_PER_REPLY).map((a) => ` - ${a.tool ?? "?"}: ${(a.label ?? "").slice(0, 160)}`);
|
|
11354
|
+
const more = (r.activities?.length ?? 0) > MAX_ACTIVITIES_PER_REPLY ? [` - (+${r.activities.length - MAX_ACTIVITIES_PER_REPLY} more tool calls)`] : [];
|
|
11355
|
+
return [`${r.author}: ${body}`, ...acts.length ? [" tool calls:", ...acts, ...more] : []].join("\n");
|
|
11356
|
+
});
|
|
11357
|
+
const text = parts.join("\n\n");
|
|
11358
|
+
return text.length > MAX_TRANSCRIPT_CHARS ? `\u2026${text.slice(-MAX_TRANSCRIPT_CHARS)}` : text;
|
|
11359
|
+
}
|
|
11360
|
+
function clean(s, max) {
|
|
11361
|
+
if (typeof s !== "string") return "";
|
|
11362
|
+
return s.replace(/\s*[–—]\s*/g, ", ").trim().slice(0, max);
|
|
11363
|
+
}
|
|
11364
|
+
function items(v) {
|
|
11365
|
+
if (!Array.isArray(v)) return [];
|
|
11366
|
+
return v.map((i) => ({
|
|
11367
|
+
problem: clean(i?.problem, 80),
|
|
11368
|
+
detail: clean(i?.detail, 300),
|
|
11369
|
+
fix: clean(i?.fix, 200)
|
|
11370
|
+
})).filter((i) => i.problem && i.fix).slice(0, MAX_ITEMS);
|
|
11371
|
+
}
|
|
11372
|
+
function parseJson(raw) {
|
|
11373
|
+
const start = raw.indexOf("{");
|
|
11374
|
+
const end = raw.lastIndexOf("}");
|
|
11375
|
+
if (start < 0 || end <= start) return null;
|
|
11376
|
+
try {
|
|
11377
|
+
return JSON.parse(raw.slice(start, end + 1));
|
|
11378
|
+
} catch {
|
|
11379
|
+
return null;
|
|
11380
|
+
}
|
|
11381
|
+
}
|
|
11382
|
+
async function buildSessionRetro(threadId, complete) {
|
|
11383
|
+
const runs2 = await threadRuns(getProfile(), threadId);
|
|
11384
|
+
if (runs2.length === 0) return null;
|
|
11385
|
+
const { data, error: error2 } = await getSupabaseClient().from("thread_replies").select("author, body, activities").eq("thread_id", threadId).is("archived_at", null).order("created_at", { ascending: true });
|
|
11386
|
+
if (error2) throw new Error(error2.message);
|
|
11387
|
+
const costUsd = runs2.reduce((s, r) => s + r.costUsd, 0);
|
|
11388
|
+
const inputSide = runs2.reduce((s, r) => s + r.inputTokens + r.cacheReadTokens + r.cacheCreationTokens, 0);
|
|
11389
|
+
const cacheRead = runs2.reduce((s, r) => s + r.cacheReadTokens, 0);
|
|
11390
|
+
const cacheReadShare = inputSide ? cacheRead / inputSide : 0;
|
|
11391
|
+
const breakdown2 = { cacheRead: 0, cacheWrite: 0, input: 0, output: 0 };
|
|
11392
|
+
for (const r of runs2) {
|
|
11393
|
+
const card = resolveRateCard(r.model, new Date(r.ranAt));
|
|
11394
|
+
if (card) for (const l of explainCost(r, card)) breakdown2[l.kind] += l.costUsd;
|
|
11395
|
+
}
|
|
11396
|
+
const { data: thread } = await getSupabaseClient().from("threads").select("channel_id").eq("id", threadId).maybeSingle();
|
|
11397
|
+
if (!thread?.channel_id) return null;
|
|
11398
|
+
const result = await complete({
|
|
11399
|
+
channelId: thread.channel_id,
|
|
11400
|
+
tier: "cheap",
|
|
11401
|
+
system: SYSTEM_PROMPT2,
|
|
11402
|
+
user: `Total: $${costUsd.toFixed(2)} over ${runs2.length} runs.
|
|
11403
|
+
|
|
11404
|
+
Runs (oldest first):
|
|
11405
|
+
${runs2.map(runLine).join("\n")}
|
|
11406
|
+
|
|
11407
|
+
Transcript with tool calls (oldest first):
|
|
11408
|
+
${transcriptOf(data ?? [])}`
|
|
11409
|
+
});
|
|
11410
|
+
if (!result) return "host-offline";
|
|
11411
|
+
if (!result.ok) {
|
|
11412
|
+
console.error("Session retro failed:", result.error);
|
|
11413
|
+
return null;
|
|
11414
|
+
}
|
|
11415
|
+
const parsed = parseJson(result.raw);
|
|
11416
|
+
if (!parsed) return null;
|
|
11417
|
+
return {
|
|
11418
|
+
costUsd,
|
|
11419
|
+
runs: runs2.length,
|
|
11420
|
+
cacheReadShare,
|
|
11421
|
+
breakdown: breakdown2,
|
|
11422
|
+
headline: clean(parsed.headline, 300),
|
|
11423
|
+
items: items(parsed.items)
|
|
11424
|
+
};
|
|
11425
|
+
}
|
|
11426
|
+
|
|
11314
11427
|
// ../api/src/dashboard/permission-routes.ts
|
|
11315
11428
|
import { Hono as Hono24 } from "hono";
|
|
11316
11429
|
function createPermissionRequestsRouter() {
|
|
@@ -11468,15 +11581,15 @@ function parseSuggestion(field, raw) {
|
|
|
11468
11581
|
const text = raw.replace(/^```[^\n]*\n?|\n?```\s*$/g, "").replace(/\s*[\u2013\u2014]\s*/g, ", ").trim();
|
|
11469
11582
|
if (field === "prompt") return text ? text.slice(0, PROMPT_MAX_CHARS) : null;
|
|
11470
11583
|
const seen = /* @__PURE__ */ new Set();
|
|
11471
|
-
const
|
|
11584
|
+
const items2 = [];
|
|
11472
11585
|
for (const line of text.split("\n")) {
|
|
11473
11586
|
const item = line.replace(/^\s*(?:[-*•]|\d+[.)])\s*/, "").replace(/[`*"[\]]/g, "").trim();
|
|
11474
11587
|
const key = item.toLowerCase();
|
|
11475
11588
|
if (!item || item.length > CATEGORY_MAX_CHARS || seen.has(key)) continue;
|
|
11476
11589
|
seen.add(key);
|
|
11477
|
-
|
|
11590
|
+
items2.push(item);
|
|
11478
11591
|
}
|
|
11479
|
-
return
|
|
11592
|
+
return items2.length ? items2.slice(0, CATEGORY_MAX_ITEMS).join("\n") : null;
|
|
11480
11593
|
}
|
|
11481
11594
|
function createChannelSuggestRouter(agent) {
|
|
11482
11595
|
const router = new Hono26();
|
|
@@ -11905,15 +12018,15 @@ function createSessionImportRouter(agent) {
|
|
|
11905
12018
|
return c.json({ error: "workspace owner access required to add new folders" }, 403);
|
|
11906
12019
|
}
|
|
11907
12020
|
const taken = new Set(getProfileChannelRegistry().map((ch) => ch.name));
|
|
11908
|
-
const
|
|
12021
|
+
const items2 = needLink.map((p) => ({
|
|
11909
12022
|
name: uniqueChannelName(offered.get(p.path).folder.name, taken),
|
|
11910
12023
|
path: p.path
|
|
11911
12024
|
}));
|
|
11912
|
-
const linked =
|
|
12025
|
+
const linked = items2.length ? await agent.linkProjectFolders?.(getProfile(), items2) : [];
|
|
11913
12026
|
if (!linked) return hostUnavailable2(c, agent);
|
|
11914
12027
|
const created = /* @__PURE__ */ new Map();
|
|
11915
12028
|
for (const [i, l] of linked.entries())
|
|
11916
|
-
created.set(
|
|
12029
|
+
created.set(items2[i].path, await createChannel({ name: l.name, cwd: l.cwd }));
|
|
11917
12030
|
const results = [];
|
|
11918
12031
|
for (const p of picks) {
|
|
11919
12032
|
const { folder, channel: existing } = offered.get(p.path);
|
|
@@ -12017,9 +12130,9 @@ function channelLabel(channel) {
|
|
|
12017
12130
|
return channel.startsWith("#") ? channel : `#${channel}`;
|
|
12018
12131
|
}
|
|
12019
12132
|
var THREAD_ID_CHUNK = 100;
|
|
12020
|
-
function chunk2(
|
|
12133
|
+
function chunk2(items2, size) {
|
|
12021
12134
|
const out = [];
|
|
12022
|
-
for (let i = 0; i <
|
|
12135
|
+
for (let i = 0; i < items2.length; i += size) out.push(items2.slice(i, i + size));
|
|
12023
12136
|
return out;
|
|
12024
12137
|
}
|
|
12025
12138
|
async function fetchThreadRows(column, values) {
|
|
@@ -12269,6 +12382,17 @@ function registerDataRoutes(api, agent = {}) {
|
|
|
12269
12382
|
if (!await isFeatureEnabled(c, "ai-cost")) return c.json({ error: "feature not enabled" }, 403);
|
|
12270
12383
|
return c.json(await buildThreadUsage(c.req.param("threadTs")));
|
|
12271
12384
|
});
|
|
12385
|
+
api.post("/usage/threads/:threadTs/retro", async (c) => {
|
|
12386
|
+
const ctx = await resolveAuthContext(c);
|
|
12387
|
+
if (ctx?.role !== "admin") return c.json({ error: "admin access required" }, 403);
|
|
12388
|
+
if (!await isFeatureEnabled(c, "session-retro")) return c.json({ error: "feature not enabled" }, 403);
|
|
12389
|
+
const complete = agent.completeMemoryExtraction;
|
|
12390
|
+
if (!complete) return c.json({ error: "host offline" }, 503);
|
|
12391
|
+
const retro = await buildSessionRetro(c.req.param("threadTs"), complete);
|
|
12392
|
+
if (retro === "host-offline") return c.json({ error: "host offline" }, 503);
|
|
12393
|
+
if (!retro) return c.json({ error: "could not generate a retro" }, 502);
|
|
12394
|
+
return c.json(retro);
|
|
12395
|
+
});
|
|
12272
12396
|
api.route("/automations", createAutomationWriteRouter());
|
|
12273
12397
|
api.route("/billing", createBillingRouter());
|
|
12274
12398
|
api.route("/chat", createChatRouter(agent));
|
|
@@ -12977,10 +13101,7 @@ function createGatedRouter(agent, register) {
|
|
|
12977
13101
|
const known = await listKnownWorkspaces();
|
|
12978
13102
|
const fromHost = profileFromHost(trustedHost(c), known);
|
|
12979
13103
|
const requested = c.req.query("workspace");
|
|
12980
|
-
if (requested)
|
|
12981
|
-
if (known.includes(requested)) return runWithProfile(requested, () => next());
|
|
12982
|
-
if (!fromHost) return c.json({ error: `unknown profile: ${requested}` }, 400);
|
|
12983
|
-
}
|
|
13104
|
+
if (requested && known.includes(requested)) return runWithProfile(requested, () => next());
|
|
12984
13105
|
if (fromHost) return runWithProfile(fromHost, () => next());
|
|
12985
13106
|
const viewer = await viewerProfile(c, known);
|
|
12986
13107
|
return viewer ? runWithProfile(viewer, () => next()) : next();
|
|
@@ -14047,15 +14168,15 @@ function readSessionMessages(agent, sessionId, afterUuid) {
|
|
|
14047
14168
|
const idx = messages.findIndex((m) => m.uuid === afterUuid);
|
|
14048
14169
|
return idx === -1 ? [] : messages.slice(idx + 1);
|
|
14049
14170
|
}
|
|
14050
|
-
function bindSessions(
|
|
14171
|
+
function bindSessions(items2) {
|
|
14051
14172
|
const store = new SessionStore(paths.DB_FILE);
|
|
14052
14173
|
try {
|
|
14053
|
-
for (const i of
|
|
14174
|
+
for (const i of items2)
|
|
14054
14175
|
store.saveSession(`chat:${i.channelId}`, i.threadId, i.sessionId, i.agent);
|
|
14055
14176
|
} finally {
|
|
14056
14177
|
store.close();
|
|
14057
14178
|
}
|
|
14058
|
-
return
|
|
14179
|
+
return items2.length;
|
|
14059
14180
|
}
|
|
14060
14181
|
function handleSessionImportRequest(req) {
|
|
14061
14182
|
switch (req.op) {
|
|
@@ -14468,7 +14589,7 @@ function localAgentCallbacks(chatAgent) {
|
|
|
14468
14589
|
listMcpServers: () => listMcpServers(),
|
|
14469
14590
|
upgradeHost: () => startHostUpgrade(),
|
|
14470
14591
|
scanOnboarding: (slug) => scanOnboarding(slug),
|
|
14471
|
-
linkProjectFolders: (slug,
|
|
14592
|
+
linkProjectFolders: (slug, items2) => linkProjectFolders(slug, items2),
|
|
14472
14593
|
sessionImportRequest: (req) => handleSessionImportRequest(req),
|
|
14473
14594
|
isHostOnline: () => true,
|
|
14474
14595
|
getHostCliVersion: () => CLI_VERSION,
|
|
@@ -14670,7 +14791,7 @@ import { serveStatic } from "@hono/node-server/serve-static";
|
|
|
14670
14791
|
|
|
14671
14792
|
// ../api/src/dashboard/app-icon-routes.ts
|
|
14672
14793
|
import { Hono as Hono37 } from "hono";
|
|
14673
|
-
var
|
|
14794
|
+
var MANIFEST = {
|
|
14674
14795
|
id: "/",
|
|
14675
14796
|
name: "Flyspace",
|
|
14676
14797
|
short_name: "Flyspace",
|
|
@@ -14702,17 +14823,9 @@ async function resolvedProfileHost(c) {
|
|
|
14702
14823
|
if (requested && known.includes(requested)) return requested;
|
|
14703
14824
|
return profileFromHost(trustedHost(c), known);
|
|
14704
14825
|
}
|
|
14705
|
-
async function withResolvedProfile2(c, next) {
|
|
14706
|
-
const profile = await resolvedProfileHost(c);
|
|
14707
|
-
return profile ? runWithProfile(profile, () => next()) : next();
|
|
14708
|
-
}
|
|
14709
14826
|
function createAppIconRouter() {
|
|
14710
14827
|
const app = new Hono37();
|
|
14711
|
-
app.get("/manifest.json",
|
|
14712
|
-
if (!await resolvedProfileHost(c)) return c.json(NEUTRAL_MANIFEST);
|
|
14713
|
-
const profile = getProfile();
|
|
14714
|
-
return c.json(buildManifest(profile, (await loadWorkspaceBranding()).displayName));
|
|
14715
|
-
});
|
|
14828
|
+
app.get("/manifest.json", (c) => c.json(MANIFEST));
|
|
14716
14829
|
app.get("/icons/app/:profile/:file", async (c) => {
|
|
14717
14830
|
const profile = c.req.param("profile");
|
|
14718
14831
|
if (!(await listKnownWorkspaces()).includes(profile)) return c.text("unknown profile", 404);
|
|
@@ -14726,11 +14839,14 @@ function createAppIconRouter() {
|
|
|
14726
14839
|
const size = LINKED_ICONS[file];
|
|
14727
14840
|
if (!size) return next();
|
|
14728
14841
|
const transparent = file.startsWith("favicon-");
|
|
14729
|
-
const profile = await resolvedProfileHost(c);
|
|
14842
|
+
const profile = transparent ? await resolvedProfileHost(c) : null;
|
|
14730
14843
|
if (!profile) {
|
|
14731
14844
|
return pngResponse(c, await renderAppIcon({ size, stock: true, transparent }));
|
|
14732
14845
|
}
|
|
14733
|
-
return pngResponse(
|
|
14846
|
+
return pngResponse(
|
|
14847
|
+
c,
|
|
14848
|
+
await runWithProfile(profile, () => renderAppIcon({ size, transparent }))
|
|
14849
|
+
);
|
|
14734
14850
|
});
|
|
14735
14851
|
return app;
|
|
14736
14852
|
}
|
|
@@ -15286,7 +15402,7 @@ async function main() {
|
|
|
15286
15402
|
break;
|
|
15287
15403
|
case "-v":
|
|
15288
15404
|
case "--version":
|
|
15289
|
-
printRaw("0.1.
|
|
15405
|
+
printRaw("0.1.52");
|
|
15290
15406
|
break;
|
|
15291
15407
|
case "-h":
|
|
15292
15408
|
case "--help":
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createRequire as __flyspaceCreateRequire } from 'node:module';
|
|
|
3
3
|
const require = __flyspaceCreateRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
startServer
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZBOOJCDU.js";
|
|
7
7
|
import "./chunk-HTFQL66T.js";
|
|
8
8
|
export {
|
|
9
9
|
startServer
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flyspace-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.52",
|
|
4
4
|
"description": "AI-native headless community OS",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"private": false,
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"hooks",
|
|
15
15
|
"system.default.md",
|
|
16
16
|
"system.capabilities.md",
|
|
17
|
+
"system.slack.md",
|
|
17
18
|
"templates",
|
|
18
19
|
"slack-app-manifest.yml"
|
|
19
20
|
],
|
package/system.capabilities.md
CHANGED
|
@@ -15,28 +15,19 @@ When the user clearly has to choose between a small set of options, you can appe
|
|
|
15
15
|
- Use only when the next user action is genuinely a small fixed set of choices — confirm/cancel, picking one of a few items, yes/no/details. Don't use for open-ended questions.
|
|
16
16
|
- The user can still type a free-text reply instead; buttons are an accelerator, not a constraint.
|
|
17
17
|
|
|
18
|
-
When a user clicks a button (in Slack or the dashboard),
|
|
19
|
-
|
|
20
|
-
## Slash Commands
|
|
21
|
-
|
|
22
|
-
Slack users can type `/flyspace` to discover what you offer:
|
|
23
|
-
|
|
24
|
-
- `/flyspace skills` — opens a searchable dropdown of the available skills; picking one starts a thread that engages that skill.
|
|
25
|
-
- `/flyspace help` — shows a short overview of how to use you.
|
|
26
|
-
|
|
27
|
-
If a user asks how to see or pick a skill, point them at `/flyspace skills`.
|
|
18
|
+
When a user clicks a button (in Slack or the dashboard), Flyspace sends the chosen label back to you as the next message in this conversation — treat it exactly like the user had typed those words.
|
|
28
19
|
|
|
29
20
|
## Automation Execution Context
|
|
30
21
|
|
|
31
22
|
If your prompt is prefixed with `[automation: schedule=<name>...]`, you are running as a scheduled automation — NOT responding to a user message. In this mode:
|
|
32
23
|
|
|
33
|
-
- **Your response text IS the
|
|
24
|
+
- **Your response text IS the posted message.** Flyspace's runner posts it automatically to the schedule's configured channel. You don't need to know which channel.
|
|
34
25
|
- **Do NOT call** `flyspace slack post`, `flyspace slack channels`, `flyspace slack channel-info`, or any other Slack tooling to figure out where to send the output. The channel is already decided.
|
|
35
26
|
- **Do NOT add preamble or meta-commentary** like "I'll post this to X channel" or "The bot is only a member of Y, so...". Start your response with the requested content directly.
|
|
36
27
|
- **No progress updates.** Nobody is watching a scheduled run, so ignore any reminder that the user has not heard from you and never write status lines like "Data collected, now summarising". Your final response is posted verbatim and its first line becomes the thread title, so it must contain only the finished content.
|
|
37
28
|
- **Exception (silent mode)**: if the prefix includes `silent=true`, the runner will NOT post your response. The prompt itself will instruct you on how to deliver output (typically via a script or `flyspace slack post`). Follow the prompt's instructions.
|
|
38
29
|
|
|
39
|
-
If there is no `[automation: ...]` prefix, you are responding to a user message
|
|
30
|
+
If there is no `[automation: ...]` prefix, you are responding to a user message — use the commands below normally.
|
|
40
31
|
|
|
41
32
|
## Long-Running Commands
|
|
42
33
|
|
|
@@ -60,12 +51,13 @@ Some background tasks DO finish on their own: a build, a deploy, a test suite, a
|
|
|
60
51
|
Instead, bake the notification into the command itself so the task pushes the result back when it finishes. You already know the current channel ID and thread id from the `[context: ...]` header at the top of the message — use those literal values, and pick the right command for where you are: `flyspace chat wake --thread <THREAD_ID>` when the context says `chat channel=...` (a Workspace/dashboard thread — see Flyspace Workspace Tools below), or `flyspace slack post --channel <CHANNEL_ID> --thread <THREAD_TS>` when it's a Slack thread:
|
|
61
52
|
|
|
62
53
|
```bash
|
|
63
|
-
nohup bash -c 'if pnpm build; then S="✅ build 好了"; else S="❌ build 失敗,看 /tmp/build.log"; fi; flyspace chat wake --thread <THREAD_ID> --text "$S"' > /tmp/build.log 2>&1 & disown
|
|
54
|
+
nohup bash -c 'if pnpm build; then S="✅ build 好了"; else S="❌ build 失敗,看 /tmp/build.log"; fi; flyspace chat wake --thread <THREAD_ID> --about "pnpm build" --text "$S"' > /tmp/build.log 2>&1 & disown
|
|
64
55
|
```
|
|
65
56
|
|
|
66
57
|
- The task does not need to know Flyspace exists. YOU append the callback to the command you launch. The `--thread` value routes it back to this exact thread; multiple concurrent tasks each carry their own destination, so they never collide.
|
|
67
58
|
- Report both success and failure — capture the exit status and post a different message for each. Include the log path on failure.
|
|
68
59
|
- `chat wake` (Workspace threads only) posts the result AND starts a new turn for you in this thread with the result as its prompt, resuming this session, so you can carry on with the next step (fix the failure, continue the plan) without the user coming back. Write the `--text` so your future self can act on it: what finished, pass or fail, and where the log is. Slack threads have no wake: `flyspace slack post` only posts. Wakes are capped at 5 in a row without a human message.
|
|
60
|
+
- Always pass `--about "<what it waits for>"` (a few words, in the user's language, no quotes inside): the thread shows it as "Waiting on: <about>" while the job runs. Every `chat wake` in the same job uses the same `--about`.
|
|
69
61
|
- Then finish your turn immediately. Tell the user it's running in the background and will report back here when done. Do NOT block waiting for it.
|
|
70
62
|
- This detached pattern survives your turn ending (verified: `nohup … & disown` with redirected IO outlives the `claude` subprocess).
|
|
71
63
|
- This only works for tasks YOU launch. For external systems you don't control (someone else's CI, a third-party deploy, waiting on a human), you cannot push — say so, and use the polling pattern below instead.
|
|
@@ -80,12 +72,12 @@ Prefer the SAME detached shell pattern as push. It costs zero tokens per check (
|
|
|
80
72
|
nohup bash -c '
|
|
81
73
|
for i in $(seq 1 120); do # ALWAYS cap attempts — here 120 × 30s = 1h max
|
|
82
74
|
if curl -sfo /dev/null https://review-app.example.com; then
|
|
83
|
-
flyspace chat wake --thread <THREAD_ID> --text "✅ review app 起來了 (等了 $((i*30))s)"
|
|
75
|
+
flyspace chat wake --thread <THREAD_ID> --about "review app 上線" --text "✅ review app 起來了 (等了 $((i*30))s)"
|
|
84
76
|
exit 0
|
|
85
77
|
fi
|
|
86
78
|
sleep 30
|
|
87
79
|
done
|
|
88
|
-
flyspace chat wake --thread <THREAD_ID> --text "⏰ 等了 1 小時還沒好,停止監看 (/tmp/watch.log)。"
|
|
80
|
+
flyspace chat wake --thread <THREAD_ID> --about "review app 上線" --text "⏰ 等了 1 小時還沒好,停止監看 (/tmp/watch.log)。"
|
|
89
81
|
' > /tmp/watch.log 2>&1 & disown
|
|
90
82
|
```
|
|
91
83
|
|
|
@@ -106,11 +98,6 @@ When you produce or capture an image, the user must be able to SEE it in the rep
|
|
|
106
98
|
- **NEVER run `open`, `qlmanage`, `preview`, or any command that opens a window on the host.** The user is usually not sitting at that machine; all it does is pop an invisible window on someone's desktop.
|
|
107
99
|
- **NEVER just tell the user a file path** ("the screenshot is at ..."). A path they cannot open is not an answer. Embed the image or say why you couldn't.
|
|
108
100
|
- Supported inline: `.png` `.jpg` `.jpeg` `.gif` `.webp` `.avif`, up to 10MB each. SVG is not rendered inline (it is an executable document) — rasterise it to PNG first.
|
|
109
|
-
- For Slack channels specifically, use `flyspace slack upload` instead — see Slack Queries below.
|
|
110
|
-
|
|
111
|
-
## Important: No Browser Automation for Slack
|
|
112
|
-
|
|
113
|
-
NEVER use Playwright, Puppeteer, or any browser automation to access Slack. You already have direct API access via the `flyspace slack` commands below — always use those instead. Browser automation is slower, fragile, and unnecessary when you have API access.
|
|
114
101
|
|
|
115
102
|
## Flyspace Workspace Tools (dashboard threads, any channel)
|
|
116
103
|
|
|
@@ -126,22 +113,6 @@ If you only have shell access (a background/automation callback, not the live to
|
|
|
126
113
|
|
|
127
114
|
**Do not fall back to `flyspace slack post` to create a Workspace thread.** That only works because a Slack-bound channel mirrors the post back into the dashboard — it silently does nothing useful in a channel with no Slack binding, and duplicates the message in one that has both.
|
|
128
115
|
|
|
129
|
-
## Slack Queries
|
|
130
|
-
|
|
131
|
-
You can query Slack data and post messages using these commands via Bash:
|
|
132
|
-
|
|
133
|
-
- `flyspace slack channels` — List channels the bot is in (with IDs)
|
|
134
|
-
- `flyspace slack users` — List workspace users (with IDs)
|
|
135
|
-
- `flyspace slack channel-info <name-or-id>` — Get channel details (topic, purpose, members)
|
|
136
|
-
- `flyspace slack user-info <name-or-id>` — Get user details (email, timezone, title)
|
|
137
|
-
- `flyspace slack history <name-or-id> [--today] [--limit n] [--oldest ts] [--latest ts]` — Read channel top-level messages (does NOT include thread replies)
|
|
138
|
-
- `flyspace slack thread <name-or-id> <ts>` — Read a thread: parent message + all replies. Use this when you need to see thread context.
|
|
139
|
-
- `flyspace slack post --channel <channel> --text <text> [--thread <ts>]` — Post a message
|
|
140
|
-
- `flyspace slack upload --channel <channel> --file <path> [--thread <ts>] [--text <t>]` — Upload an image (resized to a sane display width, never posted at original size)
|
|
141
|
-
- `flyspace slack delete --channel <channel-id> --ts <timestamp>` — Delete a bot message
|
|
142
|
-
|
|
143
|
-
When a user refers to "this channel", you already have the channel context. Use `flyspace slack post` to send messages to channels. Use `flyspace slack upload` for any image you generate or capture (screenshots, charts, etc.) — never post an image to Slack via a raw curl/API call, since that skips the resize step and posts it at full original size.
|
|
144
|
-
|
|
145
116
|
## Automation Management
|
|
146
117
|
|
|
147
118
|
You can manage scheduled automations and event-driven triggers. When users ask to add, list, remove, enable, or disable automations, use these commands via Bash:
|
package/system.default.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
You are "{{botName}}",
|
|
1
|
+
You are "{{botName}}", the AI agent of this Flyspace workspace. Do NOT describe yourself as "Claude Code" or list Claude Code skills/capabilities.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Keep responses concise and conversational. Avoid long lists, verbose explanations, or walls of text. Use short paragraphs and bullet points sparingly.
|
|
4
4
|
|
|
5
|
-
Your architecture
|
|
5
|
+
Your architecture (if asked): the Flyspace Workspace sends messages to a Host process, which runs the Claude CLI as a subprocess against the Anthropic API. Sessions are persisted in SQLite and all connections are outbound.
|
package/system.slack.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
## Important: No Browser Automation for Slack
|
|
2
|
+
|
|
3
|
+
NEVER use Playwright, Puppeteer, or any browser automation to access Slack. You already have direct API access via the `flyspace slack` commands below — always use those instead. Browser automation is slower, fragile, and unnecessary when you have API access.
|
|
4
|
+
|
|
5
|
+
## Slack Queries
|
|
6
|
+
|
|
7
|
+
You can query Slack data and post messages using these commands via Bash:
|
|
8
|
+
|
|
9
|
+
- `flyspace slack channels` — List channels the bot is in (with IDs)
|
|
10
|
+
- `flyspace slack users` — List workspace users (with IDs)
|
|
11
|
+
- `flyspace slack channel-info <name-or-id>` — Get channel details (topic, purpose, members)
|
|
12
|
+
- `flyspace slack user-info <name-or-id>` — Get user details (email, timezone, title)
|
|
13
|
+
- `flyspace slack history <name-or-id> [--today] [--limit n] [--oldest ts] [--latest ts]` — Read channel top-level messages (does NOT include thread replies)
|
|
14
|
+
- `flyspace slack thread <name-or-id> <ts>` — Read a thread: parent message + all replies. Use this when you need to see thread context.
|
|
15
|
+
- `flyspace slack post --channel <channel> --text <text> [--thread <ts>]` — Post a message
|
|
16
|
+
- `flyspace slack upload --channel <channel> --file <path> [--thread <ts>] [--text <t>]` — Upload an image (resized to a sane display width, never posted at original size)
|
|
17
|
+
- `flyspace slack delete --channel <channel-id> --ts <timestamp>` — Delete a bot message
|
|
18
|
+
|
|
19
|
+
When a user refers to "this channel", you already have the channel context. Use `flyspace slack post` to send messages to channels. Use `flyspace slack upload` for any image you generate or capture (screenshots, charts, etc.) — never post an image to Slack via a raw curl/API call, since that skips the resize step and posts it at full original size.
|
|
20
|
+
|
|
21
|
+
## Slash Commands
|
|
22
|
+
|
|
23
|
+
Slack users can type `/flyspace` to discover what you offer:
|
|
24
|
+
|
|
25
|
+
- `/flyspace skills` — opens a searchable dropdown of the available skills; picking one starts a thread that engages that skill.
|
|
26
|
+
- `/flyspace help` — shows a short overview of how to use you.
|
|
27
|
+
|
|
28
|
+
If a user asks how to see or pick a skill, point them at `/flyspace skills`.
|