gipity 1.1.40 → 1.1.41
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/approval-verify.js +113 -0
- package/dist/commands/approval.js +85 -2
- package/dist/commands/deploy.js +13 -6
- package/dist/commands/notify.js +105 -12
- package/dist/commands/status.js +15 -1
- package/dist/index.js +585 -336
- package/dist/knowledge.js +3 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6993,7 +6993,7 @@ Prefer the cheapest option that works - CLI and sandbox are instant and free, ap
|
|
|
6993
6993
|
|
|
6994
6994
|
1. CLI commands (fast, no agent overhead). The \`gipity\` CLI covers add, deploy, db, fn, logs, page, sync, memory, skill, email, and more. All commands support \`--json\` (except \`gipity build\`, which hands the terminal to your coding agent).
|
|
6995
6995
|
2. Cloud sandbox via \`gipity sandbox run\` - Docker container with pre-installed tools for media (ffmpeg, ImageMagick, sox), documents (pandoc, LibreOffice), and data (pandas, matplotlib, sqlite3). Run \`gipity skill read sandbox-tools\` for the full toolkit. No network from inside the sandbox - fetch what you need before sending it in.
|
|
6996
|
-
3. App services - runtime HTTP endpoints your deployed app calls directly at \`https://a.gipity.ai/api/<PROJECT_GUID>/services/*\`. Available: LLM, TTS, image, sound, music, transcribe, video, file upload, realtime (a function can push into a room with the injected \`realtime.publish()\`, so a page listens instead of polling; see \`app-realtime\`), location, push notifications (Gipity Notify - \`gipity add notify\`, send from a function with the injected \`notify()\`; see \`app-notify\`), embeddings for semantic search / RAG (the injected \`embed()\` in a function plus the pre-installed pgvector in the app DB; see \`app-vector-search\`). Load the matching skill (\`app-llm\`, \`app-tts\`, etc.) before writing service code - they have the schemas, auth pattern, and common-mistake guards. For one-off generation during development, prefer \`gipity generate <image|video|speech|sound|music>\` - direct generation always bills you (the owner), regardless of any service \`billing_mode\` (that setting only governs the deployed app's runtime calls; never flip it just to create assets). Image models named \`gipity-*\` run on Gipity's own GPU at half price but wait in a queue (paid accounts first): \`gipity generate image --model gipity-<model>\` waits and saves, \`--no-wait\` returns at once, and \`gipity generate models\` shows them with prices and the current wait. \`gipity generate\` saves to a generic file in the current directory by default (e.g. \`./generated.png\`) - pass \`-o <path>\` to write it straight into your source tree so it deploys (e.g. \`gipity generate image "hero banner" -o src/assets/images/hero.png\`) instead of generating at cwd and moving it. For a quick model answer while you work - summarize a log, extract fields, describe a screenshot, a second opinion from a different model - use \`gipity ask "<question>"\`: one call, no history or tools, any model (\`--model sonnet\`, \`--model openai\`), text files with \`--file <path>\` (\`--file -\` for stdin), images with \`--image <path>\`, and a JSON answer with \`--schema '<json schema>'\`.
|
|
6996
|
+
3. App services - runtime HTTP endpoints your deployed app calls directly at \`https://a.gipity.ai/api/<PROJECT_GUID>/services/*\`. Available: LLM, TTS, image, sound, music, transcribe, video, file upload, realtime (a function can push into a room with the injected \`realtime.publish()\`, so a page listens instead of polling; see \`app-realtime\`), location, push notifications (Gipity Notify - \`gipity add notify\`, send from a function with the injected \`notify()\`; see \`app-notify\`), embeddings for semantic search / RAG (the injected \`embed()\` in a function plus the pre-installed pgvector in the app DB; see \`app-vector-search\`), passkey approvals (one person signs off on one exact action with Face ID or a passkey, and a device verifies the signed proof offline: the injected \`approval\` in a function; see \`app-approvals\`). Load the matching skill (\`app-llm\`, \`app-tts\`, etc.) before writing service code - they have the schemas, auth pattern, and common-mistake guards. For one-off generation during development, prefer \`gipity generate <image|video|speech|sound|music>\` - direct generation always bills you (the owner), regardless of any service \`billing_mode\` (that setting only governs the deployed app's runtime calls; never flip it just to create assets). Image models named \`gipity-*\` run on Gipity's own GPU at half price but wait in a queue (paid accounts first): \`gipity generate image --model gipity-<model>\` waits and saves, \`--no-wait\` returns at once, and \`gipity generate models\` shows them with prices and the current wait. \`gipity generate\` saves to a generic file in the current directory by default (e.g. \`./generated.png\`) - pass \`-o <path>\` to write it straight into your source tree so it deploys (e.g. \`gipity generate image "hero banner" -o src/assets/images/hero.png\`) instead of generating at cwd and moving it. For a quick model answer while you work - summarize a log, extract fields, describe a screenshot, a second opinion from a different model - use \`gipity ask "<question>"\`: one call, no history or tools, any model (\`--model sonnet\`, \`--model openai\`), text files with \`--file <path>\` (\`--file -\` for stdin), images with \`--image <path>\`, and a JSON answer with \`--schema '<json schema>'\`.
|
|
6997
6997
|
|
|
6998
6998
|
You are the developer. Write files in this directory - Gipity's editor hooks (installed by \`gipity init\` into Claude Code, Codex, Grok, Antigravity, and opencode) auto-sync them to Gipity. Don't run \`npm install\`, \`npm start\`, \`node\`, or \`python\` locally; there is no local runtime. Code runs in the Gipity sandbox.
|
|
6999
6999
|
|
|
@@ -7118,13 +7118,14 @@ Run \`gipity skill list\` to see every skill. Run \`gipity skill read <name>\` t
|
|
|
7118
7118
|
|
|
7119
7119
|
App services skills (load before calling \`/services/*\` endpoints):
|
|
7120
7120
|
- \`app-api-keys\` - project API keys for scripts/devices: gipity key create, scopes (functions, tables, files, ip)
|
|
7121
|
+
- \`app-approvals\` - passkey approvals - one person signs off on one exact action with Face ID / a passkey; signed proof a device verifies offline, single-use consume
|
|
7121
7122
|
- \`app-audio\` - sound effects, music, transcription
|
|
7122
7123
|
- \`app-auth\` - sign in: Gipity accounts or app-owned users (Google, email code), popup vs redirect
|
|
7123
7124
|
- \`app-files\` - uploads, then displaying files and the storage helper (ownership check, delete)
|
|
7124
7125
|
- \`app-image\` - text-to-image AND instruction editing (pass \`images\` to edit an uploaded photo); providers, sizes, aspect ratios
|
|
7125
7126
|
- \`app-llm\` - chat completions, streaming, image input
|
|
7126
7127
|
- \`app-location\` - user location & reverse geocoding for deployed apps (first-party - no third-party geocoder)
|
|
7127
|
-
- \`app-notify\` -
|
|
7128
|
+
- \`app-notify\` - push notifications for deployed apps (web, iOS home-screen web apps, and native iOS apps via APNs) - notify kit + injected notify() service, platform owns delivery
|
|
7128
7129
|
- \`app-payments\` - charge end-users real money - Stripe one-time purchases & subscriptions, via the stripe kit (gipity add stripe)
|
|
7129
7130
|
- \`app-realtime\` - Gipity Realtime rooms, relay vs state
|
|
7130
7131
|
- \`app-tts\` - voices, models, dialogue, languages, word timestamps
|
|
@@ -34369,7 +34370,7 @@ var {
|
|
|
34369
34370
|
init_config();
|
|
34370
34371
|
init_setup();
|
|
34371
34372
|
init_utils();
|
|
34372
|
-
import { readFileSync as
|
|
34373
|
+
import { readFileSync as readFileSync34 } from "fs";
|
|
34373
34374
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
34374
34375
|
import { dirname as dirname17, resolve as resolve20 } from "path";
|
|
34375
34376
|
|
|
@@ -34850,9 +34851,9 @@ var UploadConflictError = class extends Error {
|
|
|
34850
34851
|
path;
|
|
34851
34852
|
};
|
|
34852
34853
|
async function uploadOneFile(projectGuid2, localPath, virtualPath, opts = {}) {
|
|
34853
|
-
const { sha256, size } = await hashFile(localPath);
|
|
34854
|
+
const { sha256: sha2562, size } = await hashFile(localPath);
|
|
34854
34855
|
const mime = opts.mime ?? guessMime(virtualPath);
|
|
34855
|
-
const initBody = { path: virtualPath, size, sha256, mime };
|
|
34856
|
+
const initBody = { path: virtualPath, size, sha256: sha2562, mime };
|
|
34856
34857
|
if (opts.expectedServerVersion !== void 0) {
|
|
34857
34858
|
initBody.expected_server_version = opts.expectedServerVersion;
|
|
34858
34859
|
}
|
|
@@ -35119,8 +35120,8 @@ function walkLocal(root, ignorePatterns, baseline) {
|
|
|
35119
35120
|
const size = stat2.size;
|
|
35120
35121
|
const mtime = stat2.mtime.toISOString();
|
|
35121
35122
|
const prior = baseline[rel2];
|
|
35122
|
-
const
|
|
35123
|
-
result.set(rel2, { size, mtime, sha256 });
|
|
35123
|
+
const sha2562 = prior && prior.size === size && prior.mtime === mtime ? prior.sha256 : void 0;
|
|
35124
|
+
result.set(rel2, { size, mtime, sha256: sha2562 });
|
|
35124
35125
|
} catch {
|
|
35125
35126
|
}
|
|
35126
35127
|
}
|
|
@@ -35162,8 +35163,8 @@ async function ensureLocalHashes(root, local, paths) {
|
|
|
35162
35163
|
const info2 = local.get(path5);
|
|
35163
35164
|
if (!info2 || info2.sha256) continue;
|
|
35164
35165
|
try {
|
|
35165
|
-
const { sha256 } = await hashFile(join10(root, path5));
|
|
35166
|
-
info2.sha256 =
|
|
35166
|
+
const { sha256: sha2562 } = await hashFile(join10(root, path5));
|
|
35167
|
+
info2.sha256 = sha2562;
|
|
35167
35168
|
} catch {
|
|
35168
35169
|
}
|
|
35169
35170
|
}
|
|
@@ -35729,11 +35730,11 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
35729
35730
|
{ expectedServerVersion: null }
|
|
35730
35731
|
);
|
|
35731
35732
|
const stat2 = statSync2(renamedFull);
|
|
35732
|
-
const { sha256 } = await hashFile(renamedFull);
|
|
35733
|
+
const { sha256: sha2562 } = await hashFile(renamedFull);
|
|
35733
35734
|
baseline.files[renamedRel] = {
|
|
35734
35735
|
size: stat2.size,
|
|
35735
35736
|
mtime: stat2.mtime.toISOString(),
|
|
35736
|
-
sha256,
|
|
35737
|
+
sha256: sha2562,
|
|
35737
35738
|
serverVersion: result.serverVersion
|
|
35738
35739
|
};
|
|
35739
35740
|
} catch (e) {
|
|
@@ -35815,11 +35816,11 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
35815
35816
|
expectedServerVersion: null
|
|
35816
35817
|
});
|
|
35817
35818
|
const stat2 = statSync2(renamed);
|
|
35818
|
-
const { sha256 } = await hashFile(renamed);
|
|
35819
|
+
const { sha256: sha2562 } = await hashFile(renamed);
|
|
35819
35820
|
baseline.files[a.renamedLocalTo] = {
|
|
35820
35821
|
size: stat2.size,
|
|
35821
35822
|
mtime: stat2.mtime.toISOString(),
|
|
35822
|
-
sha256,
|
|
35823
|
+
sha256: sha2562,
|
|
35823
35824
|
serverVersion: result.serverVersion
|
|
35824
35825
|
};
|
|
35825
35826
|
} catch (err) {
|
|
@@ -35859,8 +35860,8 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
35859
35860
|
onBytes?.(a.localSize ?? 0);
|
|
35860
35861
|
continue;
|
|
35861
35862
|
}
|
|
35862
|
-
const
|
|
35863
|
-
prepared.push({ a, full, size: stat2.size, mtime: stat2.mtime.toISOString(), sha256 });
|
|
35863
|
+
const sha2562 = local.get(a.path)?.sha256 ?? (await hashFile(full)).sha256;
|
|
35864
|
+
prepared.push({ a, full, size: stat2.size, mtime: stat2.mtime.toISOString(), sha256: sha2562 });
|
|
35864
35865
|
} catch (e) {
|
|
35865
35866
|
errors.push(`Upload failed for ${a.path}: ${e.message}`);
|
|
35866
35867
|
onBytes?.(a.localSize ?? 0);
|
|
@@ -36008,12 +36009,12 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
36008
36009
|
mkdirSync5(dirname6(full), { recursive: true });
|
|
36009
36010
|
writeFileSync6(full, buf);
|
|
36010
36011
|
const stat2 = statSync2(full);
|
|
36011
|
-
const { sha256 } = await hashFile(full);
|
|
36012
|
+
const { sha256: sha2562 } = await hashFile(full);
|
|
36012
36013
|
const current = typeof err.data?.current_server_version === "number" ? err.data.current_server_version : null;
|
|
36013
36014
|
baseline.files[a.path] = {
|
|
36014
36015
|
size: stat2.size,
|
|
36015
36016
|
mtime: stat2.mtime.toISOString(),
|
|
36016
|
-
sha256,
|
|
36017
|
+
sha256: sha2562,
|
|
36017
36018
|
serverVersion: current ?? a.expectedServerVersion ?? 0
|
|
36018
36019
|
};
|
|
36019
36020
|
errors.push(`Could not delete ${a.path}: server has a newer version - restored the server copy locally (delete it again and re-sync to confirm)`);
|
|
@@ -36096,11 +36097,11 @@ async function pushFile(filePath) {
|
|
|
36096
36097
|
expectedServerVersion: baseEntry ? baseEntry.serverVersion : null
|
|
36097
36098
|
});
|
|
36098
36099
|
const stat2 = statSync2(filePath);
|
|
36099
|
-
const { sha256 } = await hashFile(filePath);
|
|
36100
|
+
const { sha256: sha2562 } = await hashFile(filePath);
|
|
36100
36101
|
baseline.files[rel2] = {
|
|
36101
36102
|
size: stat2.size,
|
|
36102
36103
|
mtime: stat2.mtime.toISOString(),
|
|
36103
|
-
sha256,
|
|
36104
|
+
sha256: sha2562,
|
|
36104
36105
|
serverVersion: result.serverVersion
|
|
36105
36106
|
};
|
|
36106
36107
|
writeBaseline(baseline);
|
|
@@ -37750,258 +37751,9 @@ init_api();
|
|
|
37750
37751
|
init_config();
|
|
37751
37752
|
init_colors();
|
|
37752
37753
|
init_setup();
|
|
37753
|
-
import { existsSync as
|
|
37754
|
-
import { join as
|
|
37754
|
+
import { existsSync as existsSync13, readFileSync as readFileSync16 } from "fs";
|
|
37755
|
+
import { join as join18, resolve as resolve10 } from "path";
|
|
37755
37756
|
import { homedir as homedir12 } from "os";
|
|
37756
|
-
function checkGipityPlugin() {
|
|
37757
|
-
const path5 = join16(homedir12(), ".claude", "settings.json");
|
|
37758
|
-
let settings = {};
|
|
37759
|
-
if (existsSync12(path5)) {
|
|
37760
|
-
try {
|
|
37761
|
-
settings = JSON.parse(readFileSync14(path5, "utf-8"));
|
|
37762
|
-
} catch {
|
|
37763
|
-
}
|
|
37764
|
-
}
|
|
37765
|
-
const missing = [];
|
|
37766
|
-
if (!settings?.extraKnownMarketplaces?.[GIPITY_MARKETPLACE_NAME]) missing.push("marketplace");
|
|
37767
|
-
if (settings?.enabledPlugins?.[GIPITY_PLUGIN_ID] !== true) missing.push("plugin");
|
|
37768
|
-
const install = userScopeInstallState();
|
|
37769
|
-
if (!install.current) missing.push("install");
|
|
37770
|
-
const stale = missing.length === 1 && missing[0] === "install" && install.exists;
|
|
37771
|
-
return { missing, ok: missing.length === 0, stale };
|
|
37772
|
-
}
|
|
37773
|
-
async function probeAuth(loggedIn) {
|
|
37774
|
-
if (!loggedIn && !usingEnvToken()) return { state: "none", account: null };
|
|
37775
|
-
if (!usingEnvToken() && sessionExpired()) return { state: "expired", account: null };
|
|
37776
|
-
const timeout = new Promise(
|
|
37777
|
-
(res) => setTimeout(() => res({ state: "unreachable", account: null }), 5e3).unref?.()
|
|
37778
|
-
);
|
|
37779
|
-
const call = get("/users/me").then(
|
|
37780
|
-
(res) => ({ state: "ok", account: res.data?.accountSlug ?? null }),
|
|
37781
|
-
(err) => ({ state: err instanceof ApiError && err.statusCode === 401 ? "rejected" : "unreachable", account: null })
|
|
37782
|
-
);
|
|
37783
|
-
return Promise.race([call, timeout]);
|
|
37784
|
-
}
|
|
37785
|
-
var statusCommand = new Command("status").alias("whoami").description("Show project and login status").option("--json", "Output as JSON").option("--repair-hooks", "Re-enable the Gipity Claude Code plugin (hooks) if missing or disabled").action(async (opts) => {
|
|
37786
|
-
const config = getConfig();
|
|
37787
|
-
const auth = getAuth();
|
|
37788
|
-
const cwd = resolve9(process.cwd());
|
|
37789
|
-
void cwd;
|
|
37790
|
-
const hookCheck = config ? checkGipityPlugin() : null;
|
|
37791
|
-
const queueDelivered = auth && !sessionExpired() ? await flushBugQueue().catch(() => 0) : 0;
|
|
37792
|
-
const probe = await probeAuth(!!auth);
|
|
37793
|
-
const accountMismatch = probe.state === "ok" && !!config && !!probe.account && probe.account !== config.accountSlug;
|
|
37794
|
-
const apiBaseInUse = resolveApiBase();
|
|
37795
|
-
if (opts.json) {
|
|
37796
|
-
console.log(JSON.stringify({
|
|
37797
|
-
project: config ? {
|
|
37798
|
-
guid: config.projectGuid,
|
|
37799
|
-
slug: config.projectSlug,
|
|
37800
|
-
account: config.accountSlug,
|
|
37801
|
-
apiBase: config.apiBase,
|
|
37802
|
-
apiBaseInUse,
|
|
37803
|
-
url: liveUrl(config),
|
|
37804
|
-
...config.env ? { env: config.env.name } : {}
|
|
37805
|
-
} : null,
|
|
37806
|
-
// `valid` reflects the refresh token (the real session) - access
|
|
37807
|
-
// tokens auto-renew, so their expiry must not read as "invalid".
|
|
37808
|
-
// `probe` is what one live call just proved: 'rejected' means every
|
|
37809
|
-
// authenticated command will fail even though `valid` reads true.
|
|
37810
|
-
// 'mismatch' overrides 'ok' when the live account isn't the one that
|
|
37811
|
-
// owns this project - `valid` still reads true (the token IS valid).
|
|
37812
|
-
auth: auth || usingEnvToken() ? {
|
|
37813
|
-
email: auth?.email,
|
|
37814
|
-
account: probe.account,
|
|
37815
|
-
source: usingEnvToken() ? "agent-token" : "session",
|
|
37816
|
-
valid: usingEnvToken() ? probe.state !== "rejected" : !sessionExpired(),
|
|
37817
|
-
probe: accountMismatch ? "mismatch" : probe.state
|
|
37818
|
-
} : null,
|
|
37819
|
-
plugin: hookCheck
|
|
37820
|
-
}, null, 2));
|
|
37821
|
-
return;
|
|
37822
|
-
}
|
|
37823
|
-
if (!config) {
|
|
37824
|
-
console.log(warning("Not a Gipity project. Run: gipity init"));
|
|
37825
|
-
} else {
|
|
37826
|
-
console.log(`${muted("Project:")} ${brand(config.projectSlug)} ${muted(`(${config.projectGuid})`)}`);
|
|
37827
|
-
console.log(`${muted("Account:")} ${config.accountSlug}`);
|
|
37828
|
-
if (config.env) console.log(`${muted("Env:")} ${config.env.name}`);
|
|
37829
|
-
console.log(`${muted("Live:")} ${liveUrl(config)}`);
|
|
37830
|
-
console.log(`${muted("API:")} ${config.apiBase}`);
|
|
37831
|
-
if (apiBaseInUse !== config.apiBase) {
|
|
37832
|
-
console.log(`${muted("API (in use):")} ${warning(apiBaseInUse)} ${muted("(overrides .gipity.json: GIPITY_API_BASE / --api-base / allowlist)")}`);
|
|
37833
|
-
}
|
|
37834
|
-
}
|
|
37835
|
-
if (usingEnvToken()) {
|
|
37836
|
-
console.log(`${muted("Auth:")} ${probe.state === "rejected" ? warning("agent API token (GIPITY_TOKEN) rejected by the server. Mint a new one: gipity skill read agent-deploy") : success("agent API token (GIPITY_TOKEN)")}${probe.state === "unreachable" ? ` ${muted("(unverified: API unreachable)")}` : ""}`);
|
|
37837
|
-
} else if (!auth) {
|
|
37838
|
-
console.log(`${muted("Auth:")} ${warning("not logged in. Run: gipity login")}`);
|
|
37839
|
-
} else if (probe.state === "expired") {
|
|
37840
|
-
console.log(`${muted("Auth:")} ${warning(`session expired for ${auth.email}. Run: gipity login (headless/CI: set GIPITY_TOKEN, see gipity skill read agent-deploy)`)}`);
|
|
37841
|
-
} else if (probe.state === "rejected") {
|
|
37842
|
-
console.log(`${muted("Auth:")} ${warning(`session for ${auth.email} was rejected by the server. Run: gipity login (headless/CI: set GIPITY_TOKEN, see gipity skill read agent-deploy)`)}`);
|
|
37843
|
-
} else {
|
|
37844
|
-
console.log(`${muted("Auth:")} ${success(auth.email)}${probe.state === "unreachable" ? ` ${muted("(unverified: API unreachable)")}` : ""}`);
|
|
37845
|
-
}
|
|
37846
|
-
if (accountMismatch) {
|
|
37847
|
-
console.log(`${muted("Account:")} ${warning(`logged-in account (${probe.account}) differs from this project's account (${config.accountSlug}). If you didn't expect this you may be logged into the wrong account. Run: gipity login`)}`);
|
|
37848
|
-
console.log(muted("(If this project was shared with you via gipity rbac, this is expected.)"));
|
|
37849
|
-
}
|
|
37850
|
-
if (queueDelivered > 0) {
|
|
37851
|
-
console.log(`${muted("Bug queue:")} ${success(`delivered ${queueDelivered} queued bug report${queueDelivered === 1 ? "" : "s"}`)}`);
|
|
37852
|
-
}
|
|
37853
|
-
if (hookCheck) {
|
|
37854
|
-
if (hookCheck.ok) {
|
|
37855
|
-
console.log(`${muted("Hooks:")} ${success(`Gipity plugin enabled (${GIPITY_PLUGIN_ID})`)}`);
|
|
37856
|
-
} else if (opts.repairHooks) {
|
|
37857
|
-
ensureGipityPlugin(true);
|
|
37858
|
-
setupClaudeHooks();
|
|
37859
|
-
ensureGipityPluginInstalled();
|
|
37860
|
-
const after = checkGipityPlugin();
|
|
37861
|
-
if (after.ok) {
|
|
37862
|
-
console.log(`${muted("Hooks:")} ${success("repaired - Gipity plugin enabled")}`);
|
|
37863
|
-
} else {
|
|
37864
|
-
console.log(`${muted("Hooks:")} ${warning(`repair incomplete (still missing: ${after.missing.join(", ")})`)}`);
|
|
37865
|
-
console.log(muted("Ensure `claude` is on PATH, then re-run. Restart Claude Code to load the update."));
|
|
37866
|
-
}
|
|
37867
|
-
} else if (hookCheck.stale) {
|
|
37868
|
-
console.log(`${muted("Hooks:")} ${warning("Gipity plugin out of date (an update is available)")}`);
|
|
37869
|
-
console.log(muted("Hooks still load, but run `gipity status --repair-hooks` to update to the latest."));
|
|
37870
|
-
} else {
|
|
37871
|
-
console.log(`${muted("Hooks:")} ${warning(`Gipity plugin not enabled (missing: ${hookCheck.missing.join(", ")})`)}`);
|
|
37872
|
-
console.log(muted("Run `gipity status --repair-hooks` to enable."));
|
|
37873
|
-
console.log(muted("Without it, files don't auto-sync and web CLI dispatches can't show Claude Code output."));
|
|
37874
|
-
}
|
|
37875
|
-
}
|
|
37876
|
-
});
|
|
37877
|
-
|
|
37878
|
-
// src/commands/sync.ts
|
|
37879
|
-
import { dirname as dirname9 } from "node:path";
|
|
37880
|
-
init_colors();
|
|
37881
|
-
init_utils();
|
|
37882
|
-
init_config();
|
|
37883
|
-
var syncCommand = new Command("sync").description("Sync files").addHelpText("after", "\nAdd a .gipityignore at the project root to exclude paths (gitignore-style).").option("--plan", "Print the plan without applying any changes").option("--force", "Bypass the bulk-deletion guard").option("--prune", "Remove files that exist on Gipity but not locally (applies the bulk deletes the guard defers)").option("--json", "Output as JSON").action(async (opts) => {
|
|
37884
|
-
try {
|
|
37885
|
-
const progress = opts.json ? void 0 : createProgressReporter();
|
|
37886
|
-
const result = await sync({ plan: opts.plan, force: opts.force, prune: opts.prune, confirmMerge: true, progress });
|
|
37887
|
-
if (opts.json) {
|
|
37888
|
-
console.log(JSON.stringify(result));
|
|
37889
|
-
} else {
|
|
37890
|
-
console.log(result.summary);
|
|
37891
|
-
if (!opts.plan && result.applied > 0) {
|
|
37892
|
-
console.log(`
|
|
37893
|
-
${result.applied} action${result.applied > 1 ? "s" : ""} applied.`);
|
|
37894
|
-
}
|
|
37895
|
-
if (isWsl()) {
|
|
37896
|
-
const configPath = getConfigPath();
|
|
37897
|
-
const twin = configPath ? findWindowsTwinProject(dirname9(configPath)) : null;
|
|
37898
|
-
if (twin) {
|
|
37899
|
-
console.log(muted(
|
|
37900
|
-
`
|
|
37901
|
-
Note: a Windows-side copy of this project exists at ${wslPathToWindows(twin)} and is NOT synced. If you added files there, move them into this folder so they sync.`
|
|
37902
|
-
));
|
|
37903
|
-
}
|
|
37904
|
-
}
|
|
37905
|
-
if (result.deferredDeletes > 0) {
|
|
37906
|
-
console.log(muted(
|
|
37907
|
-
`
|
|
37908
|
-
${result.deferredDeletes} file${result.deferredDeletes > 1 ? "s" : ""} on Gipity ${result.deferredDeletes > 1 ? "are" : "is"} not present locally and ${result.deferredDeletes > 1 ? "were" : "was"} left untouched. Run 'gipity sync --prune' to remove ${result.deferredDeletes > 1 ? "them" : "it"}.`
|
|
37909
|
-
));
|
|
37910
|
-
}
|
|
37911
|
-
for (const e of result.errors) console.error(error(e));
|
|
37912
|
-
}
|
|
37913
|
-
if (result.aborted || result.errors.length > 0) process.exit(1);
|
|
37914
|
-
} catch (err) {
|
|
37915
|
-
console.error(error(`Sync failed: ${err.message}`));
|
|
37916
|
-
process.exit(1);
|
|
37917
|
-
}
|
|
37918
|
-
});
|
|
37919
|
-
|
|
37920
|
-
// src/commands/push.ts
|
|
37921
|
-
import { resolve as resolve10 } from "path";
|
|
37922
|
-
init_colors();
|
|
37923
|
-
var pushCommand = new Command("push").description("Push one or more files").argument("<files...>", "File path(s) to push").option("--quiet", "Suppress output").option("--background", "Fork and exit immediately").option("--json", "Output as JSON").action(async (files, opts) => {
|
|
37924
|
-
try {
|
|
37925
|
-
const fullPaths = files.map((f) => resolve10(f));
|
|
37926
|
-
if (opts.background) {
|
|
37927
|
-
const { spawnCommand: spawnCommand2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
|
|
37928
|
-
const child = spawnCommand2(process.execPath, [process.argv[1], "push", ...fullPaths, "--quiet"], {
|
|
37929
|
-
detached: true,
|
|
37930
|
-
stdio: "ignore"
|
|
37931
|
-
});
|
|
37932
|
-
child.unref();
|
|
37933
|
-
if (opts.json) console.log(JSON.stringify({ background: true, files }));
|
|
37934
|
-
return;
|
|
37935
|
-
}
|
|
37936
|
-
const pushed = [];
|
|
37937
|
-
const skipped = [];
|
|
37938
|
-
for (let i = 0; i < fullPaths.length; i++) {
|
|
37939
|
-
(await pushFile(fullPaths[i]) ? pushed : skipped).push(files[i]);
|
|
37940
|
-
}
|
|
37941
|
-
if (opts.json) {
|
|
37942
|
-
console.log(JSON.stringify({ pushed, skipped }));
|
|
37943
|
-
} else if (!opts.quiet) {
|
|
37944
|
-
console.log(success(files.length === 1 ? `Pushed ${files[0]}` : `Pushed ${files.length} files`));
|
|
37945
|
-
}
|
|
37946
|
-
} catch (err) {
|
|
37947
|
-
if (!opts.quiet) {
|
|
37948
|
-
console.error(error(`Push failed: ${err.message}`));
|
|
37949
|
-
}
|
|
37950
|
-
process.exit(1);
|
|
37951
|
-
}
|
|
37952
|
-
});
|
|
37953
|
-
|
|
37954
|
-
// src/commands/upload.ts
|
|
37955
|
-
init_api();
|
|
37956
|
-
init_config();
|
|
37957
|
-
import { statSync as statSync5 } from "fs";
|
|
37958
|
-
import { basename as basename4 } from "path";
|
|
37959
|
-
init_utils();
|
|
37960
|
-
init_colors();
|
|
37961
|
-
var uploadCommand = new Command("upload").description("Upload a file and print a durable public URL (works immediately, no deploy)").argument("<file>", "Local file to upload").option("--private", "Store as a private token-signed serve URL instead of a public CDN url").option("--content-type <mime>", "Override the content type (default: detected from the file extension)").option("--json", "Output as JSON").addHelpText("after", `
|
|
37962
|
-
Public by default (a media.gipity.ai CDN url any job or function can fetch);
|
|
37963
|
-
--private mints a token-signed serve url instead. Example:
|
|
37964
|
-
|
|
37965
|
-
gipity upload song.mp3
|
|
37966
|
-
gipity job submit split-stems --data '{"audio_url":"<printed url>"}'
|
|
37967
|
-
`).action((file, opts) => run("Upload", async () => {
|
|
37968
|
-
const { config } = await resolveProjectContext();
|
|
37969
|
-
let size;
|
|
37970
|
-
try {
|
|
37971
|
-
const st2 = statSync5(file);
|
|
37972
|
-
if (!st2.isFile()) throw new Error("not a regular file");
|
|
37973
|
-
size = st2.size;
|
|
37974
|
-
} catch (err) {
|
|
37975
|
-
throw new Error(`can't read ${file}: ${err.message}`);
|
|
37976
|
-
}
|
|
37977
|
-
if (size === 0) throw new Error(`${file} is empty - nothing to upload.`);
|
|
37978
|
-
const filename = basename4(file);
|
|
37979
|
-
const contentType = opts.contentType || guessMime(file);
|
|
37980
|
-
const doUpload = async () => {
|
|
37981
|
-
const init = await post(`/api/${config.projectGuid}/uploads/init`, {
|
|
37982
|
-
filename,
|
|
37983
|
-
content_type: contentType,
|
|
37984
|
-
size,
|
|
37985
|
-
public: !opts.private
|
|
37986
|
-
});
|
|
37987
|
-
const fields = await transferToS3(file, size, contentType, init.data);
|
|
37988
|
-
const completeBody = {
|
|
37989
|
-
upload_guid: init.data.upload_guid
|
|
37990
|
-
};
|
|
37991
|
-
if ("parts" in fields) completeBody.parts = fields.parts;
|
|
37992
|
-
const comp = await post(`/api/${config.projectGuid}/uploads/complete`, completeBody);
|
|
37993
|
-
return comp.data;
|
|
37994
|
-
};
|
|
37995
|
-
const data = opts.json ? await doUpload() : await withSpinner(`Uploading ${filename} (${formatSize(size)})...`, doUpload, { done: null });
|
|
37996
|
-
if (opts.json) {
|
|
37997
|
-
console.log(JSON.stringify(data));
|
|
37998
|
-
return;
|
|
37999
|
-
}
|
|
38000
|
-
console.log(success(`Uploaded ${data.name} (${formatSize(data.size)})`));
|
|
38001
|
-
console.log(` ${brand(data.url)}`);
|
|
38002
|
-
console.log(muted(` Durable, worker-reachable URL - pass it straight to a job/function as an input URL.`));
|
|
38003
|
-
console.log(muted(` ${data.is_public ? "public (CDN)" : "private (token-signed)"} \xB7 guid: ${data.guid}`));
|
|
38004
|
-
}));
|
|
38005
37757
|
|
|
38006
37758
|
// src/commands/deploy.ts
|
|
38007
37759
|
init_api();
|
|
@@ -38016,7 +37768,7 @@ init_colors();
|
|
|
38016
37768
|
init_auth();
|
|
38017
37769
|
|
|
38018
37770
|
// src/commands/page-eval.ts
|
|
38019
|
-
import { readFileSync as
|
|
37771
|
+
import { readFileSync as readFileSync15 } from "node:fs";
|
|
38020
37772
|
init_api();
|
|
38021
37773
|
init_colors();
|
|
38022
37774
|
init_auth();
|
|
@@ -38049,8 +37801,8 @@ function dropCheckpoint(projectGuid2, database) {
|
|
|
38049
37801
|
// src/page-fixtures.ts
|
|
38050
37802
|
init_api();
|
|
38051
37803
|
init_config();
|
|
38052
|
-
import { readFileSync as
|
|
38053
|
-
import { basename as
|
|
37804
|
+
import { readFileSync as readFileSync14, statSync as statSync5, existsSync as existsSync12, readdirSync as readdirSync7 } from "node:fs";
|
|
37805
|
+
import { basename as basename4, resolve as resolve9, relative as relative3, join as join16 } from "node:path";
|
|
38054
37806
|
var FIND_SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".gipity", "dist", "build", ".next", "coverage"]);
|
|
38055
37807
|
function findByBasename(root, name, limit = 3) {
|
|
38056
37808
|
const hits = [];
|
|
@@ -38067,31 +37819,31 @@ function findByBasename(root, name, limit = 3) {
|
|
|
38067
37819
|
}
|
|
38068
37820
|
for (const e of entries) {
|
|
38069
37821
|
if (e.isDirectory()) {
|
|
38070
|
-
if (!FIND_SKIP.has(e.name)) queue.push(
|
|
37822
|
+
if (!FIND_SKIP.has(e.name)) queue.push(join16(dir, e.name));
|
|
38071
37823
|
} else if (e.name === name && hits.length < limit) {
|
|
38072
|
-
hits.push(
|
|
37824
|
+
hits.push(join16(dir, e.name));
|
|
38073
37825
|
}
|
|
38074
37826
|
}
|
|
38075
37827
|
}
|
|
38076
37828
|
return hits;
|
|
38077
37829
|
}
|
|
38078
37830
|
function assertLocalAsset(flag, localPath) {
|
|
38079
|
-
const abs =
|
|
38080
|
-
if (
|
|
37831
|
+
const abs = resolve9(localPath);
|
|
37832
|
+
if (existsSync12(abs)) return;
|
|
38081
37833
|
const root = getProjectRoot() ?? process.cwd();
|
|
38082
|
-
const elsewhere = findByBasename(root,
|
|
37834
|
+
const elsewhere = findByBasename(root, basename4(localPath)).filter((p) => p !== abs);
|
|
38083
37835
|
const found = elsewhere.length ? `
|
|
38084
37836
|
That file DOES exist here. Pass this path instead:
|
|
38085
37837
|
${elsewhere.map((p) => ` ${flag} ${relative3(process.cwd(), p) || p}`).join("\n")}` : `
|
|
38086
|
-
Nothing named "${
|
|
37838
|
+
Nothing named "${basename4(localPath)}" under ${root} either. Generate a frame with \`gipity generate image "<description>" -o ${localPath}\`, or check the path.`;
|
|
38087
37839
|
throw new Error(
|
|
38088
37840
|
`${flag} ${localPath}: no such file. Looked for ${abs} (relative paths resolve against the current directory, ${process.cwd()}).${found}`
|
|
38089
37841
|
);
|
|
38090
37842
|
}
|
|
38091
37843
|
async function uploadPublicFixture(projectGuid2, localPath, flag = "--fixture") {
|
|
38092
37844
|
assertLocalAsset(flag, localPath);
|
|
38093
|
-
const name =
|
|
38094
|
-
const size =
|
|
37845
|
+
const name = basename4(localPath);
|
|
37846
|
+
const size = statSync5(localPath).size;
|
|
38095
37847
|
const contentType = guessMime(localPath);
|
|
38096
37848
|
const init = await post(
|
|
38097
37849
|
`/api/${projectGuid2}/uploads/init`,
|
|
@@ -38103,7 +37855,7 @@ async function uploadPublicFixture(projectGuid2, localPath, flag = "--fixture")
|
|
|
38103
37855
|
const res = await fetch(init.data.url, {
|
|
38104
37856
|
method: "PUT",
|
|
38105
37857
|
headers: { "Content-Type": contentType },
|
|
38106
|
-
body:
|
|
37858
|
+
body: readFileSync14(localPath)
|
|
38107
37859
|
});
|
|
38108
37860
|
if (!res.ok) {
|
|
38109
37861
|
throw new Error(`upload of fixture "${name}" failed: ${res.status} ${res.statusText}`);
|
|
@@ -38123,7 +37875,7 @@ function assertCameraFile(localPath) {
|
|
|
38123
37875
|
const ext = localPath.slice(localPath.lastIndexOf(".")).toLowerCase();
|
|
38124
37876
|
if (CAMERA_EXTS.includes(ext)) return;
|
|
38125
37877
|
throw new Error(
|
|
38126
|
-
`--camera ${
|
|
37878
|
+
`--camera ${basename4(localPath)}: unsupported file type "${ext || "(none)"}": the camera feed must be an image or video (${CAMERA_EXTS.join(", ")}).
|
|
38127
37879
|
A still image is played as a looping single-frame feed, which is what a gesture/pose/object model needs.
|
|
38128
37880
|
No frame to hand? Generate one: gipity generate image "a hand making a closed fist, palm to camera, plain background"`
|
|
38129
37881
|
);
|
|
@@ -38205,7 +37957,7 @@ function capWaitForTimeoutMs(raw) {
|
|
|
38205
37957
|
return WAIT_FOR_MAX_MS;
|
|
38206
37958
|
}
|
|
38207
37959
|
function readScriptFile(pathArg) {
|
|
38208
|
-
return
|
|
37960
|
+
return readFileSync15(pathArg === "-" ? 0 : pathArg, "utf8");
|
|
38209
37961
|
}
|
|
38210
37962
|
function parsesAsExpression(s) {
|
|
38211
37963
|
try {
|
|
@@ -38710,7 +38462,7 @@ init_auth();
|
|
|
38710
38462
|
init_colors();
|
|
38711
38463
|
init_utils();
|
|
38712
38464
|
import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync10 } from "fs";
|
|
38713
|
-
import { dirname as
|
|
38465
|
+
import { dirname as dirname9, extname as extname4, join as join17, resolve as resolvePath } from "path";
|
|
38714
38466
|
var DEVICE_PRESETS = {
|
|
38715
38467
|
default: { width: 1280, height: 720 },
|
|
38716
38468
|
desktop: { width: 1920, height: 1080 },
|
|
@@ -38774,7 +38526,7 @@ function dimSuffix(vp2) {
|
|
|
38774
38526
|
}
|
|
38775
38527
|
function defaultScreenshotDir() {
|
|
38776
38528
|
const root = getProjectRoot();
|
|
38777
|
-
return
|
|
38529
|
+
return join17(root ?? ".", "tmp", "screenshots");
|
|
38778
38530
|
}
|
|
38779
38531
|
function timestampSlug(d = /* @__PURE__ */ new Date()) {
|
|
38780
38532
|
const p = (n) => String(n).padStart(2, "0");
|
|
@@ -38993,8 +38745,8 @@ var pageScreenshotCommand = new Command("screenshot").description("Screenshot a
|
|
|
38993
38745
|
return stemPath(outputArg, suffix);
|
|
38994
38746
|
};
|
|
38995
38747
|
for (let i = 0; i < pngs.length; i++) {
|
|
38996
|
-
const target = outputArg ? outputPath(i) :
|
|
38997
|
-
mkdirSync9(
|
|
38748
|
+
const target = outputArg ? outputPath(i) : join17(dir, names[i] ?? shotName(meta.screenshots[i].viewport));
|
|
38749
|
+
mkdirSync9(dirname9(target), { recursive: true });
|
|
38998
38750
|
writeFileSync10(target, pngs[i].buffer);
|
|
38999
38751
|
savedFiles.push(resolvePath(target));
|
|
39000
38752
|
}
|
|
@@ -39179,8 +38931,8 @@ async function inspectPage(url, opts = {}) {
|
|
|
39179
38931
|
let transientErrors = [];
|
|
39180
38932
|
if (opts.reprobe !== false && (b7.console || []).some(isErrorLine)) {
|
|
39181
38933
|
try {
|
|
39182
|
-
const
|
|
39183
|
-
const recurring = new Set((
|
|
38934
|
+
const verify3 = await post(`/tools/browser/inspect`, inspectBody);
|
|
38935
|
+
const recurring = new Set((verify3.data.console || []).filter(isErrorLine));
|
|
39184
38936
|
transientErrors = (b7.console || []).filter((l7) => isErrorLine(l7) && !recurring.has(l7));
|
|
39185
38937
|
b7.console = (b7.console || []).filter((l7) => !isErrorLine(l7) || recurring.has(l7));
|
|
39186
38938
|
} catch {
|
|
@@ -39337,7 +39089,7 @@ async function printPlan(appGuid2, env, json) {
|
|
|
39337
39089
|
console.log(warning("A prod deploy stops on the destructive statements above until you pass --yes-destructive."));
|
|
39338
39090
|
}
|
|
39339
39091
|
}
|
|
39340
|
-
var deployCommand = new Command("deploy").description("Deploy the app to prod, or to an environment (created on first deploy)").argument("[env]", "prod, or an environment name (dev, staging, ...). Omitted: prod while the app has no environments; once it has any, name one").option("--yes-destructive", "Allow pending prod migrations that destroy data (DROP TABLE/COLUMN, TRUNCATE, DELETE without WHERE, column type changes)").option("--plan", "Show the pending migrations this deploy would run (and where each already ran), without deploying").option("--source-dir <dir>", "Source directory to deploy from").option("--only <phases>", "Run only specific phases, comma-separated, matched by gipity.yaml phase name or type: files/static, database/sql, functions, workflows, services, jobs, records, realtime, env, auth_branding, auth").option("--force", "Re-run all phases (ignore checksums) and bypass the sync bulk-deletion guard").option("--no-sync", "Skip sync-up before deploy").option("--optimize", 'Bundle and minify the JS/CSS with Vite (off by default: files upload as-is, so prod serves what you verified). Only bundles <script type="module"> references, and page eval import() of an app module then loads a separate copy').option("--json", "Output as JSON").option("--inspect [path]", "After a successful deploy, run `page inspect` on the deployed URL (or URL + path) in the same command - one build-loop step instead of two. With --json, emits two JSON lines: deploy, then inspect.").option("--wait <ms>", "With --inspect: sleep this many ms before capturing (max 30000)").option("--wait-for <selector>", "With --inspect: wait until this CSS selector appears before capturing (deterministic; the app's own ready signal)").option("--wait-timeout <ms>", "With --inspect: max ms to wait for --wait-for before giving up", "5000").action((envArg, opts) => run("Deploy", async () => {
|
|
39092
|
+
var deployCommand = new Command("deploy").description("Deploy the app to prod, or to an environment (created on first deploy)").argument("[env]", "prod, or an environment name (dev, staging, ...). Omitted: prod while the app has no environments; once it has any, name one").option("--yes-destructive", "Allow pending prod migrations that destroy data (DROP TABLE/COLUMN, TRUNCATE, DELETE without WHERE, column type changes)").option("--plan", "Show the pending migrations this deploy would run (and where each already ran), without deploying").option("--source-dir <dir>", "Source directory to deploy from").option("--only <phases>", "Run only specific phases, comma-separated, matched by gipity.yaml phase name or type: files/static, database/sql, functions, workflows, services, jobs, records, realtime, env, auth_branding, auth, access").option("--force", "Re-run all phases (ignore checksums) and bypass the sync bulk-deletion guard").option("--no-sync", "Skip sync-up before deploy").option("--optimize", 'Bundle and minify the JS/CSS with Vite (off by default: files upload as-is, so prod serves what you verified). Only bundles <script type="module"> references, and page eval import() of an app module then loads a separate copy').option("--json", "Output as JSON").option("--inspect [path]", "After a successful deploy, run `page inspect` on the deployed URL (or URL + path) in the same command - one build-loop step instead of two. With --json, emits two JSON lines: deploy, then inspect.").option("--wait <ms>", "With --inspect: sleep this many ms before capturing (max 30000)").option("--wait-for <selector>", "With --inspect: wait until this CSS selector appears before capturing (deterministic; the app's own ready signal)").option("--wait-timeout <ms>", "With --inspect: max ms to wait for --wait-for before giving up", "5000").action((envArg, opts) => run("Deploy", async () => {
|
|
39341
39093
|
const env = envArg ?? getEnvOption();
|
|
39342
39094
|
if (opts.plan) {
|
|
39343
39095
|
await printPlan(requireConfig2().projectGuid, env ?? "prod", !!opts.json);
|
|
@@ -39358,7 +39110,6 @@ var deployCommand = new Command("deploy").description("Deploy the app to prod, o
|
|
|
39358
39110
|
});
|
|
39359
39111
|
const res = opts.json ? await doDeploy() : await withSpinner(env ? `Deploying to ${env}...` : "Deploying...", doDeploy, { done: null });
|
|
39360
39112
|
const d = res.data;
|
|
39361
|
-
const where = d.env ?? d.target;
|
|
39362
39113
|
const inspectAfter = async () => {
|
|
39363
39114
|
if (!opts.inspect) return;
|
|
39364
39115
|
if (!d.url) {
|
|
@@ -39387,7 +39138,7 @@ var deployCommand = new Command("deploy").description("Deploy the app to prod, o
|
|
|
39387
39138
|
return;
|
|
39388
39139
|
}
|
|
39389
39140
|
const batchLabel = d.batch ? muted(` (batch ${d.batch})`) : "";
|
|
39390
|
-
console.log(brand(bold(`Deploy to ${
|
|
39141
|
+
console.log(brand(bold(`Deploy to ${d.env}`)) + batchLabel + (d.created ? muted(" (new environment)") : ""));
|
|
39391
39142
|
console.log(muted("\u2500".repeat(40)));
|
|
39392
39143
|
if (d.phases && d.phases.length > 0) {
|
|
39393
39144
|
for (const phase of d.phases) {
|
|
@@ -39424,17 +39175,285 @@ var deployCommand = new Command("deploy").description("Deploy the app to prod, o
|
|
|
39424
39175
|
console.log(error(`Deploy failed`) + muted(` (${d.elapsedMs}ms)`));
|
|
39425
39176
|
process.exit(1);
|
|
39426
39177
|
} else {
|
|
39427
|
-
console.log(success(`\u2713 Deployed to ${
|
|
39178
|
+
console.log(success(`\u2713 Deployed to ${d.env}`) + muted(` (${d.elapsedMs}ms)`));
|
|
39428
39179
|
if (d.url) console.log(`${muted("Live:")} ${brand(d.url)}`);
|
|
39180
|
+
if (d.pageAccess && d.pageAccess !== "public") console.log(`${muted("Pages:")} ${pageAccessLabel(d.pageAccess)}`);
|
|
39429
39181
|
if (d.phases?.some((p) => p.name === "functions")) {
|
|
39430
|
-
console.log(`${muted("Functions:")} POST ${brand(`${resolveApiBase()}/api/${d.appGuid
|
|
39431
|
-
const envFlag = d.env
|
|
39182
|
+
console.log(`${muted("Functions:")} POST ${brand(`${resolveApiBase()}/api/${d.appGuid}/fn/<name>`)}`);
|
|
39183
|
+
const envFlag = d.env !== "prod" ? ` --env ${d.env}` : "";
|
|
39432
39184
|
console.log(muted(` (names: gipity fn list${envFlag}; verify the public path: gipity fn call <name>${envFlag} --anon)`));
|
|
39433
39185
|
}
|
|
39434
39186
|
for (const hint of d.hints ?? []) console.log(muted(hint));
|
|
39435
39187
|
await inspectAfter();
|
|
39436
39188
|
}
|
|
39437
39189
|
}));
|
|
39190
|
+
function pageAccessLabel(mode) {
|
|
39191
|
+
return mode === "members" ? "private: only you and project members (Gipity sign-in)" : "private: only the app's signed-in users";
|
|
39192
|
+
}
|
|
39193
|
+
|
|
39194
|
+
// src/commands/status.ts
|
|
39195
|
+
async function probePageAccess(projectGuid2) {
|
|
39196
|
+
const timeout = new Promise((res) => setTimeout(() => res(null), 5e3).unref?.());
|
|
39197
|
+
const call = get(`/projects/${projectGuid2}`).then(
|
|
39198
|
+
(res) => res.data?.page_access ?? null,
|
|
39199
|
+
() => null
|
|
39200
|
+
);
|
|
39201
|
+
return Promise.race([call, timeout]);
|
|
39202
|
+
}
|
|
39203
|
+
function checkGipityPlugin() {
|
|
39204
|
+
const path5 = join18(homedir12(), ".claude", "settings.json");
|
|
39205
|
+
let settings = {};
|
|
39206
|
+
if (existsSync13(path5)) {
|
|
39207
|
+
try {
|
|
39208
|
+
settings = JSON.parse(readFileSync16(path5, "utf-8"));
|
|
39209
|
+
} catch {
|
|
39210
|
+
}
|
|
39211
|
+
}
|
|
39212
|
+
const missing = [];
|
|
39213
|
+
if (!settings?.extraKnownMarketplaces?.[GIPITY_MARKETPLACE_NAME]) missing.push("marketplace");
|
|
39214
|
+
if (settings?.enabledPlugins?.[GIPITY_PLUGIN_ID] !== true) missing.push("plugin");
|
|
39215
|
+
const install = userScopeInstallState();
|
|
39216
|
+
if (!install.current) missing.push("install");
|
|
39217
|
+
const stale = missing.length === 1 && missing[0] === "install" && install.exists;
|
|
39218
|
+
return { missing, ok: missing.length === 0, stale };
|
|
39219
|
+
}
|
|
39220
|
+
async function probeAuth(loggedIn) {
|
|
39221
|
+
if (!loggedIn && !usingEnvToken()) return { state: "none", account: null };
|
|
39222
|
+
if (!usingEnvToken() && sessionExpired()) return { state: "expired", account: null };
|
|
39223
|
+
const timeout = new Promise(
|
|
39224
|
+
(res) => setTimeout(() => res({ state: "unreachable", account: null }), 5e3).unref?.()
|
|
39225
|
+
);
|
|
39226
|
+
const call = get("/users/me").then(
|
|
39227
|
+
(res) => ({ state: "ok", account: res.data?.accountSlug ?? null }),
|
|
39228
|
+
(err) => ({ state: err instanceof ApiError && err.statusCode === 401 ? "rejected" : "unreachable", account: null })
|
|
39229
|
+
);
|
|
39230
|
+
return Promise.race([call, timeout]);
|
|
39231
|
+
}
|
|
39232
|
+
var statusCommand = new Command("status").alias("whoami").description("Show project and login status").option("--json", "Output as JSON").option("--repair-hooks", "Re-enable the Gipity Claude Code plugin (hooks) if missing or disabled").action(async (opts) => {
|
|
39233
|
+
const config = getConfig();
|
|
39234
|
+
const auth = getAuth();
|
|
39235
|
+
const cwd = resolve10(process.cwd());
|
|
39236
|
+
void cwd;
|
|
39237
|
+
const hookCheck = config ? checkGipityPlugin() : null;
|
|
39238
|
+
const queueDelivered = auth && !sessionExpired() ? await flushBugQueue().catch(() => 0) : 0;
|
|
39239
|
+
const [probe, pageAccess] = await Promise.all([
|
|
39240
|
+
probeAuth(!!auth),
|
|
39241
|
+
config && (auth || usingEnvToken()) ? probePageAccess(config.projectGuid) : Promise.resolve(null)
|
|
39242
|
+
]);
|
|
39243
|
+
const accountMismatch = probe.state === "ok" && !!config && !!probe.account && probe.account !== config.accountSlug;
|
|
39244
|
+
const apiBaseInUse = resolveApiBase();
|
|
39245
|
+
if (opts.json) {
|
|
39246
|
+
console.log(JSON.stringify({
|
|
39247
|
+
project: config ? {
|
|
39248
|
+
guid: config.projectGuid,
|
|
39249
|
+
slug: config.projectSlug,
|
|
39250
|
+
account: config.accountSlug,
|
|
39251
|
+
apiBase: config.apiBase,
|
|
39252
|
+
apiBaseInUse,
|
|
39253
|
+
url: liveUrl(config),
|
|
39254
|
+
...config.env ? { env: config.env.name } : {},
|
|
39255
|
+
...pageAccess ? { pageAccess } : {}
|
|
39256
|
+
} : null,
|
|
39257
|
+
// `valid` reflects the refresh token (the real session) - access
|
|
39258
|
+
// tokens auto-renew, so their expiry must not read as "invalid".
|
|
39259
|
+
// `probe` is what one live call just proved: 'rejected' means every
|
|
39260
|
+
// authenticated command will fail even though `valid` reads true.
|
|
39261
|
+
// 'mismatch' overrides 'ok' when the live account isn't the one that
|
|
39262
|
+
// owns this project - `valid` still reads true (the token IS valid).
|
|
39263
|
+
auth: auth || usingEnvToken() ? {
|
|
39264
|
+
email: auth?.email,
|
|
39265
|
+
account: probe.account,
|
|
39266
|
+
source: usingEnvToken() ? "agent-token" : "session",
|
|
39267
|
+
valid: usingEnvToken() ? probe.state !== "rejected" : !sessionExpired(),
|
|
39268
|
+
probe: accountMismatch ? "mismatch" : probe.state
|
|
39269
|
+
} : null,
|
|
39270
|
+
plugin: hookCheck
|
|
39271
|
+
}, null, 2));
|
|
39272
|
+
return;
|
|
39273
|
+
}
|
|
39274
|
+
if (!config) {
|
|
39275
|
+
console.log(warning("Not a Gipity project. Run: gipity init"));
|
|
39276
|
+
} else {
|
|
39277
|
+
console.log(`${muted("Project:")} ${brand(config.projectSlug)} ${muted(`(${config.projectGuid})`)}`);
|
|
39278
|
+
console.log(`${muted("Account:")} ${config.accountSlug}`);
|
|
39279
|
+
if (config.env) console.log(`${muted("Env:")} ${config.env.name}`);
|
|
39280
|
+
console.log(`${muted("Live:")} ${liveUrl(config)}`);
|
|
39281
|
+
if (pageAccess && pageAccess !== "public") console.log(`${muted("Pages:")} ${pageAccessLabel(pageAccess)}`);
|
|
39282
|
+
console.log(`${muted("API:")} ${config.apiBase}`);
|
|
39283
|
+
if (apiBaseInUse !== config.apiBase) {
|
|
39284
|
+
console.log(`${muted("API (in use):")} ${warning(apiBaseInUse)} ${muted("(overrides .gipity.json: GIPITY_API_BASE / --api-base / allowlist)")}`);
|
|
39285
|
+
}
|
|
39286
|
+
}
|
|
39287
|
+
if (usingEnvToken()) {
|
|
39288
|
+
console.log(`${muted("Auth:")} ${probe.state === "rejected" ? warning("agent API token (GIPITY_TOKEN) rejected by the server. Mint a new one: gipity skill read agent-deploy") : success("agent API token (GIPITY_TOKEN)")}${probe.state === "unreachable" ? ` ${muted("(unverified: API unreachable)")}` : ""}`);
|
|
39289
|
+
} else if (!auth) {
|
|
39290
|
+
console.log(`${muted("Auth:")} ${warning("not logged in. Run: gipity login")}`);
|
|
39291
|
+
} else if (probe.state === "expired") {
|
|
39292
|
+
console.log(`${muted("Auth:")} ${warning(`session expired for ${auth.email}. Run: gipity login (headless/CI: set GIPITY_TOKEN, see gipity skill read agent-deploy)`)}`);
|
|
39293
|
+
} else if (probe.state === "rejected") {
|
|
39294
|
+
console.log(`${muted("Auth:")} ${warning(`session for ${auth.email} was rejected by the server. Run: gipity login (headless/CI: set GIPITY_TOKEN, see gipity skill read agent-deploy)`)}`);
|
|
39295
|
+
} else {
|
|
39296
|
+
console.log(`${muted("Auth:")} ${success(auth.email)}${probe.state === "unreachable" ? ` ${muted("(unverified: API unreachable)")}` : ""}`);
|
|
39297
|
+
}
|
|
39298
|
+
if (accountMismatch) {
|
|
39299
|
+
console.log(`${muted("Account:")} ${warning(`logged-in account (${probe.account}) differs from this project's account (${config.accountSlug}). If you didn't expect this you may be logged into the wrong account. Run: gipity login`)}`);
|
|
39300
|
+
console.log(muted("(If this project was shared with you via gipity rbac, this is expected.)"));
|
|
39301
|
+
}
|
|
39302
|
+
if (queueDelivered > 0) {
|
|
39303
|
+
console.log(`${muted("Bug queue:")} ${success(`delivered ${queueDelivered} queued bug report${queueDelivered === 1 ? "" : "s"}`)}`);
|
|
39304
|
+
}
|
|
39305
|
+
if (hookCheck) {
|
|
39306
|
+
if (hookCheck.ok) {
|
|
39307
|
+
console.log(`${muted("Hooks:")} ${success(`Gipity plugin enabled (${GIPITY_PLUGIN_ID})`)}`);
|
|
39308
|
+
} else if (opts.repairHooks) {
|
|
39309
|
+
ensureGipityPlugin(true);
|
|
39310
|
+
setupClaudeHooks();
|
|
39311
|
+
ensureGipityPluginInstalled();
|
|
39312
|
+
const after = checkGipityPlugin();
|
|
39313
|
+
if (after.ok) {
|
|
39314
|
+
console.log(`${muted("Hooks:")} ${success("repaired - Gipity plugin enabled")}`);
|
|
39315
|
+
} else {
|
|
39316
|
+
console.log(`${muted("Hooks:")} ${warning(`repair incomplete (still missing: ${after.missing.join(", ")})`)}`);
|
|
39317
|
+
console.log(muted("Ensure `claude` is on PATH, then re-run. Restart Claude Code to load the update."));
|
|
39318
|
+
}
|
|
39319
|
+
} else if (hookCheck.stale) {
|
|
39320
|
+
console.log(`${muted("Hooks:")} ${warning("Gipity plugin out of date (an update is available)")}`);
|
|
39321
|
+
console.log(muted("Hooks still load, but run `gipity status --repair-hooks` to update to the latest."));
|
|
39322
|
+
} else {
|
|
39323
|
+
console.log(`${muted("Hooks:")} ${warning(`Gipity plugin not enabled (missing: ${hookCheck.missing.join(", ")})`)}`);
|
|
39324
|
+
console.log(muted("Run `gipity status --repair-hooks` to enable."));
|
|
39325
|
+
console.log(muted("Without it, files don't auto-sync and web CLI dispatches can't show Claude Code output."));
|
|
39326
|
+
}
|
|
39327
|
+
}
|
|
39328
|
+
});
|
|
39329
|
+
|
|
39330
|
+
// src/commands/sync.ts
|
|
39331
|
+
import { dirname as dirname10 } from "node:path";
|
|
39332
|
+
init_colors();
|
|
39333
|
+
init_utils();
|
|
39334
|
+
init_config();
|
|
39335
|
+
var syncCommand = new Command("sync").description("Sync files").addHelpText("after", "\nAdd a .gipityignore at the project root to exclude paths (gitignore-style).").option("--plan", "Print the plan without applying any changes").option("--force", "Bypass the bulk-deletion guard").option("--prune", "Remove files that exist on Gipity but not locally (applies the bulk deletes the guard defers)").option("--json", "Output as JSON").action(async (opts) => {
|
|
39336
|
+
try {
|
|
39337
|
+
const progress = opts.json ? void 0 : createProgressReporter();
|
|
39338
|
+
const result = await sync({ plan: opts.plan, force: opts.force, prune: opts.prune, confirmMerge: true, progress });
|
|
39339
|
+
if (opts.json) {
|
|
39340
|
+
console.log(JSON.stringify(result));
|
|
39341
|
+
} else {
|
|
39342
|
+
console.log(result.summary);
|
|
39343
|
+
if (!opts.plan && result.applied > 0) {
|
|
39344
|
+
console.log(`
|
|
39345
|
+
${result.applied} action${result.applied > 1 ? "s" : ""} applied.`);
|
|
39346
|
+
}
|
|
39347
|
+
if (isWsl()) {
|
|
39348
|
+
const configPath = getConfigPath();
|
|
39349
|
+
const twin = configPath ? findWindowsTwinProject(dirname10(configPath)) : null;
|
|
39350
|
+
if (twin) {
|
|
39351
|
+
console.log(muted(
|
|
39352
|
+
`
|
|
39353
|
+
Note: a Windows-side copy of this project exists at ${wslPathToWindows(twin)} and is NOT synced. If you added files there, move them into this folder so they sync.`
|
|
39354
|
+
));
|
|
39355
|
+
}
|
|
39356
|
+
}
|
|
39357
|
+
if (result.deferredDeletes > 0) {
|
|
39358
|
+
console.log(muted(
|
|
39359
|
+
`
|
|
39360
|
+
${result.deferredDeletes} file${result.deferredDeletes > 1 ? "s" : ""} on Gipity ${result.deferredDeletes > 1 ? "are" : "is"} not present locally and ${result.deferredDeletes > 1 ? "were" : "was"} left untouched. Run 'gipity sync --prune' to remove ${result.deferredDeletes > 1 ? "them" : "it"}.`
|
|
39361
|
+
));
|
|
39362
|
+
}
|
|
39363
|
+
for (const e of result.errors) console.error(error(e));
|
|
39364
|
+
}
|
|
39365
|
+
if (result.aborted || result.errors.length > 0) process.exit(1);
|
|
39366
|
+
} catch (err) {
|
|
39367
|
+
console.error(error(`Sync failed: ${err.message}`));
|
|
39368
|
+
process.exit(1);
|
|
39369
|
+
}
|
|
39370
|
+
});
|
|
39371
|
+
|
|
39372
|
+
// src/commands/push.ts
|
|
39373
|
+
import { resolve as resolve11 } from "path";
|
|
39374
|
+
init_colors();
|
|
39375
|
+
var pushCommand = new Command("push").description("Push one or more files").argument("<files...>", "File path(s) to push").option("--quiet", "Suppress output").option("--background", "Fork and exit immediately").option("--json", "Output as JSON").action(async (files, opts) => {
|
|
39376
|
+
try {
|
|
39377
|
+
const fullPaths = files.map((f) => resolve11(f));
|
|
39378
|
+
if (opts.background) {
|
|
39379
|
+
const { spawnCommand: spawnCommand2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
|
|
39380
|
+
const child = spawnCommand2(process.execPath, [process.argv[1], "push", ...fullPaths, "--quiet"], {
|
|
39381
|
+
detached: true,
|
|
39382
|
+
stdio: "ignore"
|
|
39383
|
+
});
|
|
39384
|
+
child.unref();
|
|
39385
|
+
if (opts.json) console.log(JSON.stringify({ background: true, files }));
|
|
39386
|
+
return;
|
|
39387
|
+
}
|
|
39388
|
+
const pushed = [];
|
|
39389
|
+
const skipped = [];
|
|
39390
|
+
for (let i = 0; i < fullPaths.length; i++) {
|
|
39391
|
+
(await pushFile(fullPaths[i]) ? pushed : skipped).push(files[i]);
|
|
39392
|
+
}
|
|
39393
|
+
if (opts.json) {
|
|
39394
|
+
console.log(JSON.stringify({ pushed, skipped }));
|
|
39395
|
+
} else if (!opts.quiet) {
|
|
39396
|
+
console.log(success(files.length === 1 ? `Pushed ${files[0]}` : `Pushed ${files.length} files`));
|
|
39397
|
+
}
|
|
39398
|
+
} catch (err) {
|
|
39399
|
+
if (!opts.quiet) {
|
|
39400
|
+
console.error(error(`Push failed: ${err.message}`));
|
|
39401
|
+
}
|
|
39402
|
+
process.exit(1);
|
|
39403
|
+
}
|
|
39404
|
+
});
|
|
39405
|
+
|
|
39406
|
+
// src/commands/upload.ts
|
|
39407
|
+
init_api();
|
|
39408
|
+
init_config();
|
|
39409
|
+
import { statSync as statSync6 } from "fs";
|
|
39410
|
+
import { basename as basename5 } from "path";
|
|
39411
|
+
init_utils();
|
|
39412
|
+
init_colors();
|
|
39413
|
+
var uploadCommand = new Command("upload").description("Upload a file and print a durable public URL (works immediately, no deploy)").argument("<file>", "Local file to upload").option("--private", "Store as a private token-signed serve URL instead of a public CDN url").option("--content-type <mime>", "Override the content type (default: detected from the file extension)").option("--json", "Output as JSON").addHelpText("after", `
|
|
39414
|
+
Public by default (a media.gipity.ai CDN url any job or function can fetch);
|
|
39415
|
+
--private mints a token-signed serve url instead. Example:
|
|
39416
|
+
|
|
39417
|
+
gipity upload song.mp3
|
|
39418
|
+
gipity job submit split-stems --data '{"audio_url":"<printed url>"}'
|
|
39419
|
+
`).action((file, opts) => run("Upload", async () => {
|
|
39420
|
+
const { config } = await resolveProjectContext();
|
|
39421
|
+
let size;
|
|
39422
|
+
try {
|
|
39423
|
+
const st2 = statSync6(file);
|
|
39424
|
+
if (!st2.isFile()) throw new Error("not a regular file");
|
|
39425
|
+
size = st2.size;
|
|
39426
|
+
} catch (err) {
|
|
39427
|
+
throw new Error(`can't read ${file}: ${err.message}`);
|
|
39428
|
+
}
|
|
39429
|
+
if (size === 0) throw new Error(`${file} is empty - nothing to upload.`);
|
|
39430
|
+
const filename = basename5(file);
|
|
39431
|
+
const contentType = opts.contentType || guessMime(file);
|
|
39432
|
+
const doUpload = async () => {
|
|
39433
|
+
const init = await post(`/api/${config.projectGuid}/uploads/init`, {
|
|
39434
|
+
filename,
|
|
39435
|
+
content_type: contentType,
|
|
39436
|
+
size,
|
|
39437
|
+
public: !opts.private
|
|
39438
|
+
});
|
|
39439
|
+
const fields = await transferToS3(file, size, contentType, init.data);
|
|
39440
|
+
const completeBody = {
|
|
39441
|
+
upload_guid: init.data.upload_guid
|
|
39442
|
+
};
|
|
39443
|
+
if ("parts" in fields) completeBody.parts = fields.parts;
|
|
39444
|
+
const comp = await post(`/api/${config.projectGuid}/uploads/complete`, completeBody);
|
|
39445
|
+
return comp.data;
|
|
39446
|
+
};
|
|
39447
|
+
const data = opts.json ? await doUpload() : await withSpinner(`Uploading ${filename} (${formatSize(size)})...`, doUpload, { done: null });
|
|
39448
|
+
if (opts.json) {
|
|
39449
|
+
console.log(JSON.stringify(data));
|
|
39450
|
+
return;
|
|
39451
|
+
}
|
|
39452
|
+
console.log(success(`Uploaded ${data.name} (${formatSize(data.size)})`));
|
|
39453
|
+
console.log(` ${brand(data.url)}`);
|
|
39454
|
+
console.log(muted(` Durable, worker-reachable URL - pass it straight to a job/function as an input URL.`));
|
|
39455
|
+
console.log(muted(` ${data.is_public ? "public (CDN)" : "private (token-signed)"} \xB7 guid: ${data.guid}`));
|
|
39456
|
+
}));
|
|
39438
39457
|
|
|
39439
39458
|
// src/commands/env.ts
|
|
39440
39459
|
init_api();
|
|
@@ -43243,14 +43262,14 @@ var saveCommand = new Command("save").description("Save this app as a portable .
|
|
|
43243
43262
|
}
|
|
43244
43263
|
fs3.mkdirSync(path2.dirname(dest), { recursive: true });
|
|
43245
43264
|
fs3.writeFileSync(dest, buffer);
|
|
43246
|
-
const
|
|
43265
|
+
const sha2562 = createHash4("sha256").update(buffer).digest("hex");
|
|
43247
43266
|
const skipped = Number(headers.get("x-gip-skipped") ?? 0);
|
|
43248
43267
|
const entries = zipEntryCount(buffer);
|
|
43249
43268
|
if (opts.json) {
|
|
43250
43269
|
console.log(JSON.stringify({
|
|
43251
43270
|
path: dest,
|
|
43252
43271
|
bytes: buffer.length,
|
|
43253
|
-
sha256,
|
|
43272
|
+
sha256: sha2562,
|
|
43254
43273
|
...entries !== null ? { entries } : {},
|
|
43255
43274
|
skipped
|
|
43256
43275
|
}));
|
|
@@ -43260,7 +43279,7 @@ var saveCommand = new Command("save").description("Save this app as a portable .
|
|
|
43260
43279
|
console.log(` Path: ${dest}`);
|
|
43261
43280
|
console.log(` Size: ${formatBytes(buffer.length)}`);
|
|
43262
43281
|
if (entries !== null) console.log(` Entries: ${entries} (including the bundle manifest)`);
|
|
43263
|
-
console.log(` SHA-256: ${
|
|
43282
|
+
console.log(` SHA-256: ${sha2562}`);
|
|
43264
43283
|
if (skipped > 0) {
|
|
43265
43284
|
console.log("");
|
|
43266
43285
|
console.warn(warning(`${skipped} file(s) were skipped (unreadable or over 100 MB) - this bundle is partial.`));
|
|
@@ -44531,8 +44550,9 @@ secretsCommand.command("rm <name>").alias("delete").description("Delete a secret
|
|
|
44531
44550
|
init_api();
|
|
44532
44551
|
init_config();
|
|
44533
44552
|
init_colors();
|
|
44534
|
-
|
|
44535
|
-
notifyCommand
|
|
44553
|
+
import { readFileSync as readFileSync22 } from "fs";
|
|
44554
|
+
var notifyCommand = new Command("notify").description("Push notifications (web and native iOS)").addHelpText("after", "\nGipity Notify: send a test notification, inspect subscriptions, or set up iOS push (notify apns).");
|
|
44555
|
+
notifyCommand.command("test").description("Send a test push notification (web and iOS devices) to a user or everyone").option("--to <who>", "Recipient: a user guid, comma-separated guids, or 'all'", "all").option("--title <text>", "Notification title", "Test notification").option("--body <text>", "Notification body", "Hello from Gipity Notify \u{1F44B}").option("--url <url>", "URL to open when the notification is clicked").option("--project <guid-or-slug>", "Target a specific project instead of cwd / Home").option("--json", "Output raw JSON").action((opts) => run("Notify", async () => {
|
|
44536
44556
|
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
44537
44557
|
const to2 = opts.to === "all" ? "all" : opts.to.includes(",") ? opts.to.split(",").map((s) => s.trim()) : opts.to;
|
|
44538
44558
|
const notification = { title: opts.title, body: opts.body };
|
|
@@ -44545,11 +44565,22 @@ notifyCommand.command("test").description("Send a test push notification to your
|
|
|
44545
44565
|
console.log(JSON.stringify(res.data));
|
|
44546
44566
|
return;
|
|
44547
44567
|
}
|
|
44548
|
-
const { sent, failed, pruned } = res.data;
|
|
44549
|
-
if (sent > 0)
|
|
44550
|
-
|
|
44568
|
+
const { sent, failed, pruned, results } = res.data;
|
|
44569
|
+
if (sent > 0) {
|
|
44570
|
+
const ios = results.filter((r) => r.transport === "apns" && r.status === "sent").length;
|
|
44571
|
+
const web = sent - ios;
|
|
44572
|
+
const split = ios > 0 ? ` (${web} web, ${ios} iOS)` : "";
|
|
44573
|
+
console.log(success(`\u2713 Sent to ${sent} device${sent === 1 ? "" : "s"}${split}.`));
|
|
44574
|
+
} else {
|
|
44575
|
+
console.log(warning("No devices received it: has anyone enabled notifications in the app yet? (gipity notify subs)"));
|
|
44576
|
+
}
|
|
44551
44577
|
if (pruned) console.log(muted(` pruned ${pruned} expired subscription${pruned === 1 ? "" : "s"}`));
|
|
44552
|
-
if (failed)
|
|
44578
|
+
if (failed) {
|
|
44579
|
+
console.log(muted(` ${failed} delivery failure${failed === 1 ? "" : "s"}`));
|
|
44580
|
+
for (const r of results) {
|
|
44581
|
+
if (r.status === "failed" && r.transport === "apns") console.log(muted(` iOS device ...${r.device}: ${r.reason ?? "failed"}`));
|
|
44582
|
+
}
|
|
44583
|
+
}
|
|
44553
44584
|
}));
|
|
44554
44585
|
notifyCommand.command("subs").description("Show how many push subscriptions this app has, per user").option("--project <guid-or-slug>", "Target a specific project instead of cwd / Home").option("--json", "Output raw JSON").action((opts) => run("Notify", async () => {
|
|
44555
44586
|
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
@@ -44562,9 +44593,12 @@ notifyCommand.command("subs").description("Show how many push subscriptions this
|
|
|
44562
44593
|
}
|
|
44563
44594
|
const { total, byUser } = res.data;
|
|
44564
44595
|
console.log(bold(`${total} subscription${total === 1 ? "" : "s"} across ${byUser.length} user${byUser.length === 1 ? "" : "s"}`));
|
|
44565
|
-
for (const r of byUser)
|
|
44596
|
+
for (const r of byUser) {
|
|
44597
|
+
const split = r.ios > 0 ? ` (${r.web} web, ${r.ios} iOS)` : "";
|
|
44598
|
+
console.log(` ${r.user_guid} ${muted(`${r.count} device${r.count === 1 ? "" : "s"}${split}`)}`);
|
|
44599
|
+
}
|
|
44566
44600
|
}));
|
|
44567
|
-
notifyCommand.command("rm").description("Remove a user's push subscriptions (e.g. on account deletion)").requiredOption("--user <guid>", "User guid whose subscriptions to remove").option("--project <guid-or-slug>", "Target a specific project instead of cwd / Home").option("--json", "Output raw JSON").action((opts) => run("Notify", async () => {
|
|
44601
|
+
notifyCommand.command("rm").description("Remove a user's push subscriptions and iOS devices (e.g. on account deletion)").requiredOption("--user <guid>", "User guid whose subscriptions to remove").option("--project <guid-or-slug>", "Target a specific project instead of cwd / Home").option("--json", "Output raw JSON").action((opts) => run("Notify", async () => {
|
|
44568
44602
|
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
44569
44603
|
const res = await post(
|
|
44570
44604
|
`/api/${config.projectGuid}/services/notify/remove`,
|
|
@@ -44576,6 +44610,67 @@ notifyCommand.command("rm").description("Remove a user's push subscriptions (e.g
|
|
|
44576
44610
|
}
|
|
44577
44611
|
console.log(success(`Removed ${res.data.removed} subscription${res.data.removed === 1 ? "" : "s"} for ${opts.user}.`));
|
|
44578
44612
|
}));
|
|
44613
|
+
function printApns(c) {
|
|
44614
|
+
if (!c.configured) {
|
|
44615
|
+
console.log(warning("iOS push is not set up. Run: gipity notify apns set --team-id <id> --key-id <id> --p8 <AuthKey.p8> --bundle-id <id>"));
|
|
44616
|
+
return;
|
|
44617
|
+
}
|
|
44618
|
+
console.log(` Team ID: ${c.teamId}`);
|
|
44619
|
+
console.log(` Key ID: ${c.keyId}`);
|
|
44620
|
+
console.log(` Bundle ID: ${c.bundleId}`);
|
|
44621
|
+
console.log(` Default: ${c.defaultEnvironment} ${muted("(for devices that register without an environment)")}`);
|
|
44622
|
+
}
|
|
44623
|
+
var apnsCommand = new Command("apns").description("Set up push notifications for a native iOS app (your own Apple key)").addHelpText("after", `
|
|
44624
|
+
Create an APNs key in your Apple Developer account (Certificates, Identifiers
|
|
44625
|
+
& Profiles > Keys > + > Apple Push Notifications service), download the
|
|
44626
|
+
AuthKey_<KEYID>.p8 file, then:
|
|
44627
|
+
|
|
44628
|
+
gipity notify apns set --team-id ABCDE12345 --key-id KEY1234567 \\
|
|
44629
|
+
--p8 ./AuthKey_KEY1234567.p8 --bundle-id com.example.myapp
|
|
44630
|
+
|
|
44631
|
+
The key is stored encrypted and never shown again. Your app registers each
|
|
44632
|
+
device with POST /api/<app-guid>/notify/devices; notify() then reaches it.`);
|
|
44633
|
+
apnsCommand.command("set").description("Store the APNs key for this app (all environments use it)").requiredOption("--team-id <id>", "Your 10-character Apple Team ID").requiredOption("--key-id <id>", "The 10-character Key ID of the APNs key").requiredOption("--p8 <file>", "Path to the AuthKey_<KEYID>.p8 file").requiredOption("--bundle-id <id>", "Your app bundle id, e.g. com.example.myapp").option("--sandbox", "Devices that register without an environment use the sandbox (development builds)").option("--project <guid-or-slug>", "Target a specific project instead of cwd / Home").option("--json", "Output raw JSON").action((opts) => run("Notify", async () => {
|
|
44634
|
+
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
44635
|
+
let p8;
|
|
44636
|
+
try {
|
|
44637
|
+
p8 = readFileSync22(opts.p8, "utf-8");
|
|
44638
|
+
} catch {
|
|
44639
|
+
throw new Error(`Can't read ${opts.p8}. Pass the path to the AuthKey_<KEYID>.p8 file from Apple.`);
|
|
44640
|
+
}
|
|
44641
|
+
const res = await put(`/api/${config.projectGuid}/services/notify/apns`, {
|
|
44642
|
+
team_id: opts.teamId,
|
|
44643
|
+
key_id: opts.keyId,
|
|
44644
|
+
bundle_id: opts.bundleId,
|
|
44645
|
+
p8,
|
|
44646
|
+
sandbox: !!opts.sandbox
|
|
44647
|
+
});
|
|
44648
|
+
if (opts.json) {
|
|
44649
|
+
console.log(JSON.stringify(res.data));
|
|
44650
|
+
return;
|
|
44651
|
+
}
|
|
44652
|
+
console.log(success("\u2713 iOS push is set up."));
|
|
44653
|
+
printApns(res.data);
|
|
44654
|
+
}));
|
|
44655
|
+
apnsCommand.command("show").description("Show the APNs setup for this app (never the key itself)").option("--project <guid-or-slug>", "Target a specific project instead of cwd / Home").option("--json", "Output raw JSON").action((opts) => run("Notify", async () => {
|
|
44656
|
+
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
44657
|
+
const res = await get(`/api/${config.projectGuid}/services/notify/apns`);
|
|
44658
|
+
if (opts.json) {
|
|
44659
|
+
console.log(JSON.stringify(res.data));
|
|
44660
|
+
return;
|
|
44661
|
+
}
|
|
44662
|
+
printApns(res.data);
|
|
44663
|
+
}));
|
|
44664
|
+
apnsCommand.command("rm").description("Remove the APNs key (iOS devices stop receiving notifications)").option("--project <guid-or-slug>", "Target a specific project instead of cwd / Home").option("--json", "Output raw JSON").action((opts) => run("Notify", async () => {
|
|
44665
|
+
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
44666
|
+
const res = await del(`/api/${config.projectGuid}/services/notify/apns`);
|
|
44667
|
+
if (opts.json) {
|
|
44668
|
+
console.log(JSON.stringify(res.data));
|
|
44669
|
+
return;
|
|
44670
|
+
}
|
|
44671
|
+
console.log(res.data.removed ? success("\u2713 APNs key removed.") : warning("No APNs key was set."));
|
|
44672
|
+
}));
|
|
44673
|
+
notifyCommand.addCommand(apnsCommand);
|
|
44579
44674
|
|
|
44580
44675
|
// src/commands/bug.ts
|
|
44581
44676
|
init_api();
|
|
@@ -45215,7 +45310,7 @@ emailCommand.command("log").description("Recent email() sends and skipped attemp
|
|
|
45215
45310
|
init_api();
|
|
45216
45311
|
init_config();
|
|
45217
45312
|
init_colors();
|
|
45218
|
-
import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync17, readFileSync as
|
|
45313
|
+
import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync17, readFileSync as readFileSync23 } from "fs";
|
|
45219
45314
|
import { resolve as resolvePath2, dirname as dirname13, relative as relative5, isAbsolute as isAbsolute2, basename as basename7 } from "path";
|
|
45220
45315
|
|
|
45221
45316
|
// src/commands/generate-async.ts
|
|
@@ -45588,7 +45683,7 @@ function readInputImages(paths) {
|
|
|
45588
45683
|
return paths.map((p) => {
|
|
45589
45684
|
let buf;
|
|
45590
45685
|
try {
|
|
45591
|
-
buf =
|
|
45686
|
+
buf = readFileSync23(p);
|
|
45592
45687
|
} catch (e) {
|
|
45593
45688
|
throw new Error(`can't read --input image ${p} (${e.code || e.message}).`);
|
|
45594
45689
|
}
|
|
@@ -45863,7 +45958,7 @@ Examples:
|
|
|
45863
45958
|
console.error(error("Pass --lyrics or --lyrics-file, not both."));
|
|
45864
45959
|
process.exit(1);
|
|
45865
45960
|
}
|
|
45866
|
-
const lyrics = opts.lyricsFile ?
|
|
45961
|
+
const lyrics = opts.lyricsFile ? readFileSync23(opts.lyricsFile, "utf8").trim() : opts.lyrics;
|
|
45867
45962
|
const doGenerate = () => post(`/projects/${config.projectGuid}/generate/music`, {
|
|
45868
45963
|
prompt: prompt2,
|
|
45869
45964
|
duration_seconds: opts.duration,
|
|
@@ -45934,7 +46029,7 @@ var generateCommand = addGenerationSubcommands(new Command("generate").descripti
|
|
|
45934
46029
|
// src/commands/ask.ts
|
|
45935
46030
|
init_api();
|
|
45936
46031
|
init_config();
|
|
45937
|
-
import { readFileSync as
|
|
46032
|
+
import { readFileSync as readFileSync24, fstatSync } from "fs";
|
|
45938
46033
|
init_colors();
|
|
45939
46034
|
var IMAGE_TYPES = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/gif", "image/webp"]);
|
|
45940
46035
|
var MAX_WARM_WAIT_S = 90;
|
|
@@ -45959,7 +46054,7 @@ function stdinIsPiped() {
|
|
|
45959
46054
|
}
|
|
45960
46055
|
function readTextFile(path5) {
|
|
45961
46056
|
try {
|
|
45962
|
-
return
|
|
46057
|
+
return readFileSync24(path5 === "-" ? 0 : path5, "utf8");
|
|
45963
46058
|
} catch (e) {
|
|
45964
46059
|
throw new Error(`can't read --file ${path5} (${e.code || e.message}).`);
|
|
45965
46060
|
}
|
|
@@ -45969,7 +46064,7 @@ function readImage(path5) {
|
|
|
45969
46064
|
if (!IMAGE_TYPES.has(mime)) throw new Error(`--image ${path5} is ${mime}; use a png, jpg, gif or webp.`);
|
|
45970
46065
|
let buf;
|
|
45971
46066
|
try {
|
|
45972
|
-
buf =
|
|
46067
|
+
buf = readFileSync24(path5);
|
|
45973
46068
|
} catch (e) {
|
|
45974
46069
|
throw new Error(`can't read --image ${path5} (${e.code || e.message}).`);
|
|
45975
46070
|
}
|
|
@@ -46026,14 +46121,14 @@ Examples:
|
|
|
46026
46121
|
init_api();
|
|
46027
46122
|
init_config();
|
|
46028
46123
|
init_colors();
|
|
46029
|
-
import { existsSync as existsSync19, readFileSync as
|
|
46124
|
+
import { existsSync as existsSync19, readFileSync as readFileSync25 } from "fs";
|
|
46030
46125
|
import { join as join24 } from "path";
|
|
46031
46126
|
function readInstalledKitReadme(name) {
|
|
46032
46127
|
const root = getProjectRoot() ?? process.cwd();
|
|
46033
46128
|
const kitDir = join24(root, "src", "packages", name);
|
|
46034
46129
|
if (!existsSync19(join24(kitDir, "package.json"))) return null;
|
|
46035
46130
|
const readme = join24(kitDir, "README.md");
|
|
46036
|
-
return existsSync19(readme) ?
|
|
46131
|
+
return existsSync19(readme) ? readFileSync25(readme, "utf-8") : null;
|
|
46037
46132
|
}
|
|
46038
46133
|
function slugify2(title) {
|
|
46039
46134
|
return title.toLowerCase().replace(/[`*_]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -46817,12 +46912,12 @@ var locationCommand = new Command("location").description("Show location").argum
|
|
|
46817
46912
|
}));
|
|
46818
46913
|
|
|
46819
46914
|
// src/commands/doctor.ts
|
|
46820
|
-
import { existsSync as existsSync22, readFileSync as
|
|
46915
|
+
import { existsSync as existsSync22, readFileSync as readFileSync27, statSync as statSync9 } from "fs";
|
|
46821
46916
|
import { join as join26, resolve as resolve17 } from "path";
|
|
46822
46917
|
import { homedir as homedir17 } from "os";
|
|
46823
46918
|
|
|
46824
46919
|
// src/updater/state.ts
|
|
46825
|
-
import { readFileSync as
|
|
46920
|
+
import { readFileSync as readFileSync26, writeFileSync as writeFileSync18, mkdirSync as mkdirSync16, existsSync as existsSync21 } from "fs";
|
|
46826
46921
|
import { dirname as dirname15, join as join25, resolve as resolve16 } from "path";
|
|
46827
46922
|
import { homedir as homedir16 } from "os";
|
|
46828
46923
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
@@ -46837,7 +46932,7 @@ function findPkgRoot() {
|
|
|
46837
46932
|
let dir = dirname15(fileURLToPath4(import.meta.url));
|
|
46838
46933
|
for (; ; ) {
|
|
46839
46934
|
try {
|
|
46840
|
-
if (JSON.parse(
|
|
46935
|
+
if (JSON.parse(readFileSync26(join25(dir, "package.json"), "utf-8")).name === "gipity") return dir;
|
|
46841
46936
|
} catch {
|
|
46842
46937
|
}
|
|
46843
46938
|
const up2 = dirname15(dir);
|
|
@@ -46864,7 +46959,7 @@ function ensureDir() {
|
|
|
46864
46959
|
function readState() {
|
|
46865
46960
|
if (!existsSync21(STATE_FILE)) return { ...DEFAULT_STATE };
|
|
46866
46961
|
try {
|
|
46867
|
-
return { ...DEFAULT_STATE, ...JSON.parse(
|
|
46962
|
+
return { ...DEFAULT_STATE, ...JSON.parse(readFileSync26(STATE_FILE, "utf-8")) };
|
|
46868
46963
|
} catch {
|
|
46869
46964
|
return { ...DEFAULT_STATE };
|
|
46870
46965
|
}
|
|
@@ -46876,7 +46971,7 @@ function writeState(state) {
|
|
|
46876
46971
|
function readSettings() {
|
|
46877
46972
|
if (!existsSync21(SETTINGS_FILE)) return { ...DEFAULT_SETTINGS };
|
|
46878
46973
|
try {
|
|
46879
|
-
return { ...DEFAULT_SETTINGS, ...JSON.parse(
|
|
46974
|
+
return { ...DEFAULT_SETTINGS, ...JSON.parse(readFileSync26(SETTINGS_FILE, "utf-8")) };
|
|
46880
46975
|
} catch {
|
|
46881
46976
|
return { ...DEFAULT_SETTINGS };
|
|
46882
46977
|
}
|
|
@@ -46913,7 +47008,7 @@ function localVersion() {
|
|
|
46913
47008
|
const pkgPath = join26(LOCAL_PKG_DIR, "package.json");
|
|
46914
47009
|
if (!existsSync22(pkgPath)) return null;
|
|
46915
47010
|
try {
|
|
46916
|
-
return JSON.parse(
|
|
47011
|
+
return JSON.parse(readFileSync27(pkgPath, "utf-8")).version ?? null;
|
|
46917
47012
|
} catch {
|
|
46918
47013
|
return null;
|
|
46919
47014
|
}
|
|
@@ -46921,7 +47016,7 @@ function localVersion() {
|
|
|
46921
47016
|
function shimVersion() {
|
|
46922
47017
|
try {
|
|
46923
47018
|
const url = new URL("../../package.json", import.meta.url);
|
|
46924
|
-
return JSON.parse(
|
|
47019
|
+
return JSON.parse(readFileSync27(url, "utf-8")).version;
|
|
46925
47020
|
} catch {
|
|
46926
47021
|
return "unknown";
|
|
46927
47022
|
}
|
|
@@ -47251,13 +47346,13 @@ var updateCommand = new Command("update").description("Update the CLI").option("
|
|
|
47251
47346
|
init_api();
|
|
47252
47347
|
init_utils();
|
|
47253
47348
|
init_colors();
|
|
47254
|
-
import { existsSync as existsSync26, readFileSync as
|
|
47349
|
+
import { existsSync as existsSync26, readFileSync as readFileSync30, unlinkSync as unlinkSync9 } from "fs";
|
|
47255
47350
|
import { spawn as spawn2 } from "child_process";
|
|
47256
47351
|
|
|
47257
47352
|
// src/relay/daemon.ts
|
|
47258
47353
|
init_platform();
|
|
47259
47354
|
init_config();
|
|
47260
|
-
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync19, existsSync as existsSync25, readFileSync as
|
|
47355
|
+
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync19, existsSync as existsSync25, readFileSync as readFileSync29, writeFileSync as writeFileSync20, chmodSync as chmodSync4, closeSync as closeSync4, openSync as openSync4, unlinkSync as unlinkSync8 } from "fs";
|
|
47261
47356
|
import { stat, readFile } from "fs/promises";
|
|
47262
47357
|
import { createInterface as createInterface2 } from "readline";
|
|
47263
47358
|
import { homedir as homedir19, hostname as hostname6, platform as osPlatform3, loadavg as loadavg2, freemem as freemem2, totalmem as totalmem2, cpus as cpus2 } from "os";
|
|
@@ -49584,7 +49679,7 @@ async function resolveCwdForProject(d) {
|
|
|
49584
49679
|
const configPath = join30(path5, ".gipity.json");
|
|
49585
49680
|
if (existsSync25(configPath)) {
|
|
49586
49681
|
try {
|
|
49587
|
-
const cfg = JSON.parse(
|
|
49682
|
+
const cfg = JSON.parse(readFileSync29(configPath, "utf-8"));
|
|
49588
49683
|
if (cfg.projectGuid === d.project_guid) return { cwd: path5, bootstrapped: false };
|
|
49589
49684
|
log2("warn", "project dir exists but guid mismatch - using it anyway", {
|
|
49590
49685
|
path: path5,
|
|
@@ -50167,7 +50262,7 @@ relayCommand.command("stop").description("Stop the background service").option("
|
|
|
50167
50262
|
console.log(muted("Background service isn't running."));
|
|
50168
50263
|
return;
|
|
50169
50264
|
}
|
|
50170
|
-
const pid = parseInt(
|
|
50265
|
+
const pid = parseInt(readFileSync30(pidPath, "utf-8").trim(), 10);
|
|
50171
50266
|
if (!pid || isNaN(pid)) {
|
|
50172
50267
|
console.error(error("PID file is empty or malformed."));
|
|
50173
50268
|
process.exit(1);
|
|
@@ -50316,7 +50411,7 @@ relayCommand.command("revoke").description("Revoke and forget this device").acti
|
|
|
50316
50411
|
}
|
|
50317
50412
|
const pidPath = getDaemonPidPath();
|
|
50318
50413
|
if (existsSync26(pidPath)) {
|
|
50319
|
-
const pid = parseInt(
|
|
50414
|
+
const pid = parseInt(readFileSync30(pidPath, "utf-8").trim(), 10);
|
|
50320
50415
|
if (pid && !isNaN(pid)) {
|
|
50321
50416
|
try {
|
|
50322
50417
|
process.kill(pid, "SIGTERM");
|
|
@@ -50335,7 +50430,7 @@ relayCommand.command("log").description("Tail the service log").option("-n, --li
|
|
|
50335
50430
|
}
|
|
50336
50431
|
const lines = parseInt(opts.lines, 10) || 100;
|
|
50337
50432
|
try {
|
|
50338
|
-
const all =
|
|
50433
|
+
const all = readFileSync30(path5, "utf-8").split("\n");
|
|
50339
50434
|
const tail2 = all.slice(-lines - 1).join("\n");
|
|
50340
50435
|
process.stdout.write(tail2);
|
|
50341
50436
|
} catch (err) {
|
|
@@ -50511,7 +50606,7 @@ init_api();
|
|
|
50511
50606
|
init_auth();
|
|
50512
50607
|
init_utils();
|
|
50513
50608
|
init_colors();
|
|
50514
|
-
import { existsSync as existsSync27, rmSync as rmSync4, unlinkSync as unlinkSync10, readFileSync as
|
|
50609
|
+
import { existsSync as existsSync27, rmSync as rmSync4, unlinkSync as unlinkSync10, readFileSync as readFileSync31, writeFileSync as writeFileSync21 } from "fs";
|
|
50515
50610
|
import { homedir as homedir20, platform as osPlatform4 } from "os";
|
|
50516
50611
|
import { join as join31, resolve as resolve19 } from "path";
|
|
50517
50612
|
init_agents();
|
|
@@ -50524,7 +50619,7 @@ function removeInstallerPathLines() {
|
|
|
50524
50619
|
if (!existsSync27(rc2)) continue;
|
|
50525
50620
|
let text;
|
|
50526
50621
|
try {
|
|
50527
|
-
text =
|
|
50622
|
+
text = readFileSync31(rc2, "utf-8");
|
|
50528
50623
|
} catch {
|
|
50529
50624
|
continue;
|
|
50530
50625
|
}
|
|
@@ -50692,8 +50787,100 @@ var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").
|
|
|
50692
50787
|
});
|
|
50693
50788
|
|
|
50694
50789
|
// src/commands/approval.ts
|
|
50790
|
+
import { readFileSync as readFileSync32 } from "node:fs";
|
|
50695
50791
|
init_api();
|
|
50696
50792
|
init_colors();
|
|
50793
|
+
|
|
50794
|
+
// src/approval-verify.ts
|
|
50795
|
+
import { createHash as createHash6, createPublicKey, verify as verify2 } from "node:crypto";
|
|
50796
|
+
var CHALLENGE_PREFIX = "gipity-approval:v1|";
|
|
50797
|
+
function canonicalJson(value) {
|
|
50798
|
+
if (value === null) return "null";
|
|
50799
|
+
switch (typeof value) {
|
|
50800
|
+
case "boolean":
|
|
50801
|
+
case "string":
|
|
50802
|
+
return JSON.stringify(value);
|
|
50803
|
+
case "number":
|
|
50804
|
+
if (!Number.isFinite(value)) throw new Error("payload contains a non-finite number");
|
|
50805
|
+
return JSON.stringify(value);
|
|
50806
|
+
case "object": {
|
|
50807
|
+
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
50808
|
+
const obj = value;
|
|
50809
|
+
return `{${Object.keys(obj).sort().map((k7) => {
|
|
50810
|
+
if (obj[k7] === void 0) throw new Error(`payload field '${k7}' is undefined`);
|
|
50811
|
+
return `${JSON.stringify(k7)}:${canonicalJson(obj[k7])}`;
|
|
50812
|
+
}).join(",")}}`;
|
|
50813
|
+
}
|
|
50814
|
+
default:
|
|
50815
|
+
throw new Error(`payload contains a value JSON can't represent (${typeof value})`);
|
|
50816
|
+
}
|
|
50817
|
+
}
|
|
50818
|
+
var sha256 = (data) => createHash6("sha256").update(data).digest();
|
|
50819
|
+
function payloadHash(payload) {
|
|
50820
|
+
return sha256(canonicalJson(payload)).toString("hex");
|
|
50821
|
+
}
|
|
50822
|
+
function approvalChallenge(id2, hash, expiresAt) {
|
|
50823
|
+
return sha256(`${CHALLENGE_PREFIX}${id2}|${hash}|${expiresAt}`).toString("base64url");
|
|
50824
|
+
}
|
|
50825
|
+
function sameKey(a, b7) {
|
|
50826
|
+
if (a.kty !== b7.kty) return false;
|
|
50827
|
+
if (a.kty === "EC") return a.crv === b7.crv && a.x === b7.x && a.y === b7.y;
|
|
50828
|
+
if (a.kty === "OKP") return a.crv === b7.crv && a.x === b7.x;
|
|
50829
|
+
if (a.kty === "RSA") return a.n === b7.n && a.e === b7.e;
|
|
50830
|
+
return false;
|
|
50831
|
+
}
|
|
50832
|
+
function verifySignature(jwk, data, signature) {
|
|
50833
|
+
const key = createPublicKey({ key: { kty: jwk.kty, crv: jwk.crv, x: jwk.x, y: jwk.y, n: jwk.n, e: jwk.e }, format: "jwk" });
|
|
50834
|
+
return verify2(jwk.kty === "OKP" ? null : "sha256", data, key, signature);
|
|
50835
|
+
}
|
|
50836
|
+
function verifyApproval(approval, opts) {
|
|
50837
|
+
const checks = [];
|
|
50838
|
+
const add = (check, ok, detail) => checks.push(detail ? { check, ok, detail } : { check, ok });
|
|
50839
|
+
const proof = approval.proof;
|
|
50840
|
+
if (!proof) {
|
|
50841
|
+
add("proof present", false, `approval is ${approval.status}; there is no passkey proof`);
|
|
50842
|
+
return { ok: false, pinned: !!opts.pinnedJwk, checks };
|
|
50843
|
+
}
|
|
50844
|
+
const expectedRpId = new URL(opts.expectedOrigin).hostname;
|
|
50845
|
+
const hash = payloadHash(opts.payload);
|
|
50846
|
+
add("payload hash matches", hash === approval.payloadHash, hash === approval.payloadHash ? void 0 : `local ${hash}`);
|
|
50847
|
+
const challenge = approvalChallenge(approval.id, hash, approval.expiresAt);
|
|
50848
|
+
let clientData = {};
|
|
50849
|
+
const clientDataBytes = Buffer.from(proof.clientDataJSON, "base64url");
|
|
50850
|
+
try {
|
|
50851
|
+
clientData = JSON.parse(clientDataBytes.toString("utf8"));
|
|
50852
|
+
} catch {
|
|
50853
|
+
add("clientDataJSON parses", false);
|
|
50854
|
+
}
|
|
50855
|
+
add("clientData type is webauthn.get", clientData.type === "webauthn.get");
|
|
50856
|
+
add("clientData challenge matches", clientData.challenge === challenge);
|
|
50857
|
+
add(
|
|
50858
|
+
"clientData origin matches",
|
|
50859
|
+
clientData.origin === opts.expectedOrigin,
|
|
50860
|
+
clientData.origin === opts.expectedOrigin ? void 0 : `got ${String(clientData.origin)}`
|
|
50861
|
+
);
|
|
50862
|
+
const authData = Buffer.from(proof.authenticatorData, "base64url");
|
|
50863
|
+
const rpIdOk = authData.length >= 37 && authData.subarray(0, 32).equals(sha256(expectedRpId));
|
|
50864
|
+
add("rpIdHash matches", rpIdOk);
|
|
50865
|
+
const flags = authData.length >= 37 ? authData[32] : 0;
|
|
50866
|
+
add("user present (UP)", (flags & 1) !== 0);
|
|
50867
|
+
add("user verified (UV)", (flags & 4) !== 0);
|
|
50868
|
+
const key = opts.pinnedJwk ?? proof.publicKeyJwk;
|
|
50869
|
+
if (opts.pinnedJwk) add("proof key is the pinned key", sameKey(opts.pinnedJwk, proof.publicKeyJwk));
|
|
50870
|
+
let sigOk = false;
|
|
50871
|
+
try {
|
|
50872
|
+
sigOk = verifySignature(key, Buffer.concat([authData, sha256(clientDataBytes)]), Buffer.from(proof.signature, "base64url"));
|
|
50873
|
+
} catch {
|
|
50874
|
+
sigOk = false;
|
|
50875
|
+
}
|
|
50876
|
+
add("signature verifies", sigOk);
|
|
50877
|
+
const expiresMs = Date.parse(approval.expiresAt);
|
|
50878
|
+
const notExpired = Number.isFinite(expiresMs) && expiresMs > (opts.now ?? Date.now());
|
|
50879
|
+
add("not expired", notExpired, notExpired ? void 0 : `expired at ${approval.expiresAt}`);
|
|
50880
|
+
return { ok: checks.every((c) => c.ok), pinned: !!opts.pinnedJwk, checks };
|
|
50881
|
+
}
|
|
50882
|
+
|
|
50883
|
+
// src/commands/approval.ts
|
|
50697
50884
|
function timeAgo(dateStr) {
|
|
50698
50885
|
const diffMs = Date.now() - new Date(dateStr).getTime();
|
|
50699
50886
|
const mins = Math.floor(diffMs / 6e4);
|
|
@@ -50715,7 +50902,7 @@ approvalCommand.command("list").description("List pending approvals").addOption(
|
|
|
50715
50902
|
res.data,
|
|
50716
50903
|
opts,
|
|
50717
50904
|
"No approvals.",
|
|
50718
|
-
(a) => `${a.guid} ${a.title} ${muted(`[${a.status}] ${timeAgo(a.created_at)}`)}`
|
|
50905
|
+
(a) => `${a.guid} ${a.title} ${muted(`[${a.status}${a.kind === "passkey" ? ", passkey" : ""}] ${timeAgo(a.created_at)}`)}`
|
|
50719
50906
|
);
|
|
50720
50907
|
}));
|
|
50721
50908
|
approvalCommand.command("create <title...>").description("Create a pending approval").option("--description <text>", "Detailed context").addOption(new Option("--type <type>", "Approval type").choices(["yes_no", "choice", "text"]).default("yes_no")).option("--choices <a,b,c>", "Comma-separated options (for --type choice)").option("--prompt <text>", "Custom prompt shown to the user").option("--expires-in <minutes>", "Minutes until expiry (default: 10080 = 7d)").option("--json", "Output as JSON").action((titleParts, opts) => run("Create", async () => {
|
|
@@ -50780,6 +50967,68 @@ approvalCommand.command("cancel <guid>").description("Cancel a pending approval
|
|
|
50780
50967
|
await post(`/approvals/${guid}/cancel`, {});
|
|
50781
50968
|
printResult(success(`Cancelled ${guid}.`), opts, { guid, cancelled: true });
|
|
50782
50969
|
}));
|
|
50970
|
+
function requireGuid(guid) {
|
|
50971
|
+
if (!guid.startsWith("ap_")) throw new Error("Expected approval guid like ap_xxxxxxxx");
|
|
50972
|
+
}
|
|
50973
|
+
approvalCommand.command("show <guid>").description("Show one approval (for a passkey approval: status, payload hash, expiry and whether it carries a signed proof)").option("--json", "Output as JSON").action((guid, opts) => run("Show", async () => {
|
|
50974
|
+
requireGuid(guid);
|
|
50975
|
+
const { data } = await get(`/approvals/${guid}`);
|
|
50976
|
+
const lines = [`${data.guid} ${data.title}`];
|
|
50977
|
+
if (data.description) lines.push(muted(data.description));
|
|
50978
|
+
if (data.passkey) {
|
|
50979
|
+
const p = data.passkey;
|
|
50980
|
+
lines.push(
|
|
50981
|
+
`Status: ${p.status} (passkey)`,
|
|
50982
|
+
`Approver: ${p.approver}`,
|
|
50983
|
+
`Payload hash: ${p.payloadHash}`,
|
|
50984
|
+
`Expires: ${p.expiresAt}`,
|
|
50985
|
+
`Resolved: ${p.resolvedAt ?? "-"}`,
|
|
50986
|
+
`Consumed: ${p.consumedAt ?? "-"}`,
|
|
50987
|
+
`Proof: ${p.proof ? `signed by passkey ${p.proof.credentialId}` : "none"}`
|
|
50988
|
+
);
|
|
50989
|
+
} else {
|
|
50990
|
+
lines.push(`Status: ${data.status}`);
|
|
50991
|
+
}
|
|
50992
|
+
printResult(lines.join("\n"), opts, data);
|
|
50993
|
+
}));
|
|
50994
|
+
approvalCommand.command("passkeys").description("List the passkeys you approve with (add them in the browser at the printed link)").option("--remove <id>", "Remove one of your passkeys by id").option("--json", "Output as JSON").action((opts) => run("Passkeys", async () => {
|
|
50995
|
+
if (opts.remove) {
|
|
50996
|
+
await del(`/approvals/passkeys/credentials/${encodeURIComponent(opts.remove)}`);
|
|
50997
|
+
printResult(success(`Removed ${opts.remove}.`), opts, { id: opts.remove, removed: true });
|
|
50998
|
+
return;
|
|
50999
|
+
}
|
|
51000
|
+
const { data } = await get("/approvals/passkeys/credentials");
|
|
51001
|
+
const manageUrl = `${getBaseUrl()}/approvals/passkeys`;
|
|
51002
|
+
if (opts.json) {
|
|
51003
|
+
console.log(JSON.stringify({ passkeys: data, manageUrl }));
|
|
51004
|
+
return;
|
|
51005
|
+
}
|
|
51006
|
+
console.log(data.length ? data.map((k7) => `${k7.id} ${k7.label ?? "Passkey"} ${muted(`added ${k7.createdAt.slice(0, 10)}${k7.lastUsedAt ? `, last used ${k7.lastUsedAt.slice(0, 10)}` : ""}`)}`).join("\n") : "No passkeys yet.");
|
|
51007
|
+
console.log(muted(`Add or remove passkeys in the browser: ${manageUrl}`));
|
|
51008
|
+
}));
|
|
51009
|
+
approvalCommand.command("verify <guid>").description("Verify a passkey approval offline, as a device does: recompute the payload hash and challenge and check the passkey signature").requiredOption("--payload <file>", "JSON file with the exact payload the approval is for").option("--key <file>", "The approver's public key (JWK JSON) pinned at enrollment; without it the proof's own key is used and the result says so").option("--origin <url>", "Relying-party origin the passkey signed for (default: the API base)").option("--json", "Output as JSON").action((guid, opts) => run("Verify", async () => {
|
|
51010
|
+
requireGuid(guid);
|
|
51011
|
+
const payload = JSON.parse(readFileSync32(opts.payload, "utf8"));
|
|
51012
|
+
const pinnedJwk = opts.key ? JSON.parse(readFileSync32(opts.key, "utf8")) : void 0;
|
|
51013
|
+
const { data } = await get(`/approvals/${guid}`);
|
|
51014
|
+
if (!data.passkey) throw new Error(`${guid} is not a passkey approval`);
|
|
51015
|
+
const expectedOrigin = new URL(opts.origin ?? getBaseUrl()).origin;
|
|
51016
|
+
const result = verifyApproval(data.passkey, { payload, pinnedJwk, expectedOrigin });
|
|
51017
|
+
if (opts.json) {
|
|
51018
|
+
console.log(JSON.stringify({ id: guid, status: data.passkey.status, ...result }));
|
|
51019
|
+
} else {
|
|
51020
|
+
for (const c of result.checks) console.log(`${c.ok ? "ok " : "FAIL"} ${c.check}${c.detail ? muted(` (${c.detail})`) : ""}`);
|
|
51021
|
+
if (!result.pinned) console.log(muted("Key not pinned: checked against the key in the proof. Pass --key with the approver key you pinned."));
|
|
51022
|
+
if (result.ok && data.passkey.status !== "approved") console.log(muted(`Signature is valid, but the approval is ${data.passkey.status}.`));
|
|
51023
|
+
}
|
|
51024
|
+
if (!result.ok) {
|
|
51025
|
+
if (opts.json) {
|
|
51026
|
+
process.exitCode = 1;
|
|
51027
|
+
return;
|
|
51028
|
+
}
|
|
51029
|
+
throw new Error("verification failed");
|
|
51030
|
+
}
|
|
51031
|
+
}));
|
|
50783
51032
|
|
|
50784
51033
|
// src/commands/gmail.ts
|
|
50785
51034
|
init_api();
|
|
@@ -50830,7 +51079,7 @@ gmailCommand.command("reply").description("Reply to a Gmail thread. Get thread-i
|
|
|
50830
51079
|
}));
|
|
50831
51080
|
|
|
50832
51081
|
// src/commands/text.ts
|
|
50833
|
-
import { readFileSync as
|
|
51082
|
+
import { readFileSync as readFileSync33 } from "fs";
|
|
50834
51083
|
init_colors();
|
|
50835
51084
|
|
|
50836
51085
|
// src/helpers/text-analysis.ts
|
|
@@ -50985,10 +51234,10 @@ function areAnagrams(a, b7) {
|
|
|
50985
51234
|
|
|
50986
51235
|
// src/commands/text.ts
|
|
50987
51236
|
function resolveInput(args, opts) {
|
|
50988
|
-
if (opts.file) return
|
|
51237
|
+
if (opts.file) return readFileSync33(opts.file, "utf-8");
|
|
50989
51238
|
if (args.length) return args.join(" ");
|
|
50990
51239
|
try {
|
|
50991
|
-
return
|
|
51240
|
+
return readFileSync33(0, "utf-8");
|
|
50992
51241
|
} catch {
|
|
50993
51242
|
return "";
|
|
50994
51243
|
}
|
|
@@ -51284,11 +51533,11 @@ function installOutputTrace(label2) {
|
|
|
51284
51533
|
installOutputTrace("index");
|
|
51285
51534
|
var __dirname = dirname17(fileURLToPath5(import.meta.url));
|
|
51286
51535
|
installNetworking();
|
|
51287
|
-
var pkg = JSON.parse(
|
|
51536
|
+
var pkg = JSON.parse(readFileSync34(resolve20(__dirname, "../package.json"), "utf-8"));
|
|
51288
51537
|
function versionLabel() {
|
|
51289
51538
|
const base = `v${pkg.version}`;
|
|
51290
51539
|
try {
|
|
51291
|
-
const info2 = JSON.parse(
|
|
51540
|
+
const info2 = JSON.parse(readFileSync34(resolve20(__dirname, "build-info.json"), "utf-8"));
|
|
51292
51541
|
if (info2?.sha) return `${base} (dev ${info2.sha}${info2.dirty ? ", modified" : ""})`;
|
|
51293
51542
|
} catch {
|
|
51294
51543
|
}
|