gipity 1.1.6 → 1.1.9

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.
@@ -87,36 +87,40 @@ emailCommand
87
87
  console.log(success(`✓ Sent to ${sent} recipient${sent === 1 ? '' : 's'}.`));
88
88
  else
89
89
  console.log(warning(`Nothing sent (${skipped} skipped).`));
90
- for (const r of results)
91
- console.log(muted(` ${r.to} — ${r.status}`));
90
+ for (const r of results) {
91
+ console.log(muted(` ${r.to} — ${r.status}${r.reason ? `: ${r.reason}` : ''}`));
92
+ }
92
93
  }));
93
94
  // --- gipity email log ---
94
- // Recent email() sends from the credits ledger (operation = email_send).
95
+ // Recent email() activity from the credits ledger: delivered sends
96
+ // (operation = email_send) plus skipped attempts (email_skip, 0-credit rows
97
+ // recording unsubscribed/blocked/not-configured recipients).
95
98
  emailCommand
96
99
  .command('log')
97
- .description('Recent email() sends from your app')
100
+ .description('Recent email() sends and skipped attempts from your app')
98
101
  .option('--range <range>', 'Time range (24h, 7d, 30d)', '7d')
99
102
  .option('--limit <n>', 'Max rows', '50')
100
103
  .option('--project <guid-or-slug>', 'Target a specific project instead of cwd / Home')
101
104
  .option('--json', 'Output raw JSON')
102
105
  .action((opts) => run('Email', async () => {
103
106
  const { config } = await resolveProjectContext({ projectOverride: opts.project });
104
- const res = await get(`/account/logs/credits?operations=email_send&app_guid=${config.projectGuid}&range=${encodeURIComponent(opts.range)}&limit=${encodeURIComponent(opts.limit)}`);
107
+ const res = await get(`/account/logs/credits?operations=email_send,email_skip&app_guid=${config.projectGuid}&range=${encodeURIComponent(opts.range)}&limit=${encodeURIComponent(opts.limit)}`);
105
108
  if (opts.json) {
106
109
  console.log(JSON.stringify(res.data));
107
110
  return;
108
111
  }
109
112
  const { totals, items } = res.data;
110
113
  if (!items.length) {
111
- console.log(muted('No email() sends in this range.'));
114
+ console.log(muted('No email() activity in this range (sends and skipped attempts both appear here).'));
112
115
  return;
113
116
  }
114
- console.log(bold(`${totals.n} send${totals.n === 1 ? '' : 's'} · ${totals.credits} credit${totals.credits === 1 ? '' : 's'}`));
117
+ console.log(bold(`${totals.n} attempt${totals.n === 1 ? '' : 's'} · ${totals.credits} credit${totals.credits === 1 ? '' : 's'}`));
115
118
  for (const r of items) {
116
119
  const when = new Date(r.created_at).toISOString().replace('T', ' ').slice(0, 16);
117
120
  const to = r.detail?.to ?? '—';
118
121
  const subj = r.detail?.subject ? ` · ${r.detail.subject}` : '';
119
- console.log(` ${muted(when)} ${to}${muted(subj)}`);
122
+ const status = r.detail?.status ? ` [skipped: ${r.detail.status}]` : '';
123
+ console.log(` ${muted(when)} ${to}${status ? warning(status) : ''}${muted(subj)}`);
120
124
  }
121
125
  }));
122
126
  //# sourceMappingURL=email.js.map
@@ -36,9 +36,13 @@ fileCommand
36
36
  }));
37
37
  fileCommand
38
38
  .command('url <path>')
39
- .description('Durable public URL for a project file - no deploy needed. Reachable by browsers, GPU jobs, and external services the moment the file syncs; ideal for throwaway test fixtures (delete the file to revoke the link).')
39
+ .description('Durable public URL for a project file - no deploy needed')
40
40
  .option('--download', 'URL forces a download (Content-Disposition: attachment)')
41
41
  .option('--json', 'Output as JSON')
42
+ .addHelpText('after', `
43
+ Reachable by browsers, GPU jobs, and external services the moment the file
44
+ syncs; ideal for throwaway test fixtures (delete the file to revoke the link).
45
+ `)
42
46
  .action((path, opts) => run('Url', async () => {
43
47
  const { config } = await resolveProjectContext();
44
48
  const qs = new URLSearchParams({ path });
@@ -8,7 +8,7 @@ import { error as clrError, success, muted } from '../colors.js';
8
8
  import { printCommandError } from '../helpers/command.js';
9
9
  import { withSpinner } from '../progress.js';
10
10
  import { guessMime } from '../upload.js';
11
- import { IMAGE_MODELS_DOC, IMAGE_GEMINI_ASPECT_RATIOS, IMAGE_GEMINI_SIZES, VIDEO_MODELS_DOC, TTS_PROVIDER_DESCRIPTIONS } from '../provider-docs.js';
11
+ import { IMAGE_MODELS_DOC, VIDEO_MODELS_DOC, TTS_PROVIDER_DESCRIPTIONS } from '../provider-docs.js';
12
12
  /** Download a URL and save to a local file, then push it up to the project so
13
13
  * the cloud (and anything that mirrors it) immediately matches local disk.
14
14
  * Returns the absolute path written, so callers can report where it landed.
@@ -170,19 +170,14 @@ function readInputImages(paths) {
170
170
  }
171
171
  // ── IMAGE ──────────────────────────────────────────────────────────────
172
172
  const imageCommand = new Command('image')
173
- .description(`Generate an image from a text prompt, or EDIT existing images with --input.
174
-
173
+ .description('Generate an image from a text prompt, or edit existing images with --input')
174
+ .addHelpText('after', `
175
175
  Models: ${IMAGE_MODELS_DOC}
176
176
 
177
177
  Editing (--input): pass one or more source images and the prompt becomes an edit
178
178
  instruction applied to them - "make it night time", "add a hat", "remove the car
179
179
  in the background", or compose several inputs together. Editing routes to Gemini
180
- automatically. This is the first-party way to exercise the image-edit flow from
181
- the CLI; the CLI reads the file bytes itself, so there is no base64/argv fiddling.
182
-
183
- Gemini-specific options:
184
- --aspect-ratio Control output shape: ${IMAGE_GEMINI_ASPECT_RATIOS}
185
- --image-size Control resolution: ${IMAGE_GEMINI_SIZES} (default: 1K)
180
+ automatically; the CLI reads the file bytes itself, so there is no base64/argv fiddling.
186
181
 
187
182
  Examples:
188
183
  gipity generate image "a cat wearing a top hat"
@@ -190,7 +185,8 @@ Examples:
190
185
  gipity generate image "put the person in the first photo into the second scene" --input person.png --input scene.png
191
186
  gipity generate image "landscape sunset" --provider gemini --aspect-ratio 16:9 --image-size 2K
192
187
  gipity generate image "product photo" --provider openai --model gpt-image-2 --size 1536x1024 --quality high
193
- gipity generate image "abstract art" --provider bfl --model flux-2-pro -o art.png`)
188
+ gipity generate image "abstract art" --provider bfl --model flux-2-pro -o art.png
189
+ `)
194
190
  .argument('<prompt>', 'Text description of the image, or (with --input) the edit instruction to apply')
195
191
  .option('--input <file>', 'Source image to edit/compose (repeatable). With --input the prompt is an edit instruction; routes to Gemini.', (v, acc) => (acc || []).concat(v))
196
192
  .option('--provider <provider>', 'Image provider: openai, bfl, or gemini (default: bfl)')
@@ -248,14 +244,10 @@ Examples:
248
244
  });
249
245
  // ── VIDEO ──────────────────────────────────────────────────────────────
250
246
  const videoCommand = new Command('video')
251
- .description(`Generate a short video (up to 8 seconds) from a text prompt using Google Veo.
252
-
247
+ .description('Generate a short video (up to 8 seconds) from a text prompt using Google Veo')
248
+ .addHelpText('after', `
253
249
  Models: ${VIDEO_MODELS_DOC}
254
250
 
255
- Options:
256
- --aspect 16:9 (landscape, default), 9:16 (portrait/vertical), 1:1 (square)
257
- --resolution 720p (default), 1080p, 4k
258
-
259
251
  Tips:
260
252
  - Describe the scene, camera movement, lighting, and any dialogue
261
253
  - Generation takes 30-120 seconds depending on model
@@ -264,7 +256,8 @@ Tips:
264
256
  Examples:
265
257
  gipity generate video "a bird flying over a mountain lake at sunset"
266
258
  gipity generate video "close-up of coffee being poured" --model veo-3.1-fast-generate-preview
267
- gipity generate video "vertical dance video" --aspect 9:16 --resolution 1080p -o dance.mp4`)
259
+ gipity generate video "vertical dance video" --aspect 9:16 --resolution 1080p -o dance.mp4
260
+ `)
268
261
  .argument('<prompt>', 'Description of the video scene, action, camera movement, and dialogue')
269
262
  .option('--model <model>', 'Veo model: veo-3.1-generate-preview (quality), veo-3.1-fast-generate-preview (speed), veo-3.1-lite-generate-preview (budget)')
270
263
  .option('--aspect <ratio>', 'Aspect ratio: 16:9 (landscape), 9:16 (portrait), 1:1 (square)')
@@ -304,20 +297,20 @@ Examples:
304
297
  });
305
298
  // ── SPEECH ─────────────────────────────────────────────────────────────
306
299
  const speechCommand = new Command('speech')
307
- .description(`Generate speech audio from text using text-to-speech.
308
-
300
+ .description('Generate speech audio from text using text-to-speech')
301
+ .addHelpText('after', `
309
302
  Providers: ${Object.entries(TTS_PROVIDER_DESCRIPTIONS).map(([k, v]) => `${k} - ${v}`).join('\n ')}
310
303
 
311
- Gemini-specific options:
312
- --language BCP-47 language code (e.g. ja-JP, es-ES, fr-FR). 60+ languages supported.
313
- --speakers Multi-speaker mode (up to 2). JSON array: [{"name":"Joe","voice":"Kore"},{"name":"Jane","voice":"Puck"}]
314
- When using multi-speaker, format your text as "Name: dialogue" on each line.
304
+ Multi-speaker (--speakers, Gemini only): JSON array like
305
+ [{"name":"Joe","voice":"Kore"},{"name":"Jane","voice":"Puck"}]; format the
306
+ text as "Name: dialogue" on each line.
315
307
 
316
308
  Examples:
317
309
  gipity generate speech "Hello, welcome to Gipity!"
318
310
  gipity generate speech "こんにちは世界" --provider gemini --voice Kore --language ja-JP
319
311
  gipity generate speech "Bonjour le monde" --provider gemini --language fr-FR
320
- gipity generate speech 'Joe: Hey!\\nJane: Hi there!' --provider gemini --speakers '[{"name":"Joe","voice":"Charon"},{"name":"Jane","voice":"Leda"}]'`)
312
+ gipity generate speech 'Joe: Hey!\\nJane: Hi there!' --provider gemini --speakers '[{"name":"Joe","voice":"Charon"},{"name":"Jane","voice":"Leda"}]'
313
+ `)
321
314
  .argument('<text>', 'Text to convert to speech (max 5000 characters)')
322
315
  .option('--provider <provider>', 'TTS provider: elevenlabs (default), openai, or gemini')
323
316
  .option('--voice <voice>', 'Voice ID or name (provider-specific)')
@@ -368,8 +361,8 @@ Examples:
368
361
  });
369
362
  // ── MUSIC ──────────────────────────────────────────────────────────────
370
363
  const musicCommand = new Command('music')
371
- .description(`Generate music from a text prompt using AI.
372
-
364
+ .description('Generate music from a text prompt using AI')
365
+ .addHelpText('after', `
373
366
  The model is chosen from the platform's music catalog. Omit --model to use the
374
367
  default; pass --model <id> only if you want a specific one (see the catalog with
375
368
  \`gipity service call music/models --get\`).
@@ -382,7 +375,8 @@ Tips:
382
375
  Examples:
383
376
  gipity generate music "chill lo-fi beat for studying"
384
377
  gipity generate music "epic orchestral battle theme" --duration 60 -o src/assets/audio/theme.mp3
385
- gipity generate music "indie pop chorus" --vocals --duration 20`)
378
+ gipity generate music "indie pop chorus" --vocals --duration 20
379
+ `)
386
380
  .argument('<prompt>', 'Text description of the music to generate')
387
381
  .option('--duration <seconds>', 'Clip length in seconds (default 30; max depends on the model)', (v) => parseInt(v, 10))
388
382
  .option('--model <model>', 'Music model id (default: platform default)')
@@ -421,8 +415,8 @@ Examples:
421
415
  });
422
416
  // ── SOUND ──────────────────────────────────────────────────────────────
423
417
  const soundCommand = new Command('sound')
424
- .description(`Generate a sound effect from a text description using AI.
425
-
418
+ .description('Generate a sound effect from a text description using AI')
419
+ .addHelpText('after', `
426
420
  Always billed to you (the caller) - the app's service billing_mode does not
427
421
  apply to direct generation, so there is never a reason to flip a service to
428
422
  owner_pays just to create assets.
@@ -435,7 +429,8 @@ Tips:
435
429
  Examples:
436
430
  gipity generate sound "cartoon character saying oof"
437
431
  gipity generate sound "thunder rolling in the distance" --duration 5
438
- gipity generate sound "sci-fi laser blast" -o src/assets/sounds/laser.mp3`)
432
+ gipity generate sound "sci-fi laser blast" -o src/assets/sounds/laser.mp3
433
+ `)
439
434
  .argument('<text>', 'Text description of the sound effect (max 1000 characters)')
440
435
  .option('--duration <seconds>', 'Clip length in seconds (0.5-30; default: automatic)', (v) => parseFloat(v))
441
436
  .option('--influence <n>', 'How closely to follow the prompt, 0.0-1.0 (higher = more literal)', (v) => parseFloat(v))
@@ -5,6 +5,7 @@ import { getAccountSlug } from '../api.js';
5
5
  import { getConfig, getConfigPath, saveConfigAt } from '../config.js';
6
6
  import { getAuth } from '../auth.js';
7
7
  import { slugify, setupProjectTools, SUPPORTED_TOOLS, DEFAULT_TOOLS, DEFAULT_SYNC_IGNORE } from '../setup.js';
8
+ import { AGENT_ADAPTERS } from '../agents/index.js';
8
9
  import { success, error as clrError, info, muted, bold } from '../colors.js';
9
10
  import { confirm } from '../utils.js';
10
11
  import { scanForAdoption, adoptCurrentDir, canAdoptCwd, formatBytes, formatCwdLabel, ADOPT_THRESHOLDS, } from '../adopt-cwd.js';
@@ -23,7 +24,7 @@ function resolveTools(forFlag) {
23
24
  }
24
25
  export const initCommand = new Command('init')
25
26
  .description('Link this directory to a project')
26
- .addHelpText('after', '\nWrites CLAUDE.md/AGENTS.md primer files so your AI coding tool understands Gipity, and installs the Gipity skills + file-sync hooks into the agent CLIs found on this machine (Claude Code, Codex, Grok, Antigravity).')
27
+ .addHelpText('after', `\nWrites CLAUDE.md/AGENTS.md primer files so your AI coding tool understands Gipity, and installs the Gipity skills + file-sync hooks into the agent CLIs found on this machine (${AGENT_ADAPTERS.map(a => a.displayName).join(', ')}).`)
27
28
  .argument('[name]', 'Project name/slug (defaults to current directory name)')
28
29
  .option('--agent <guid>', 'Agent GUID to use')
29
30
  .option('--no-capture', 'Don\'t record Claude Code sessions in this directory to your Gipity project (sets captureHooks: false in .gipity.json)')
@@ -177,7 +178,7 @@ Working with an existing Gipity project:
177
178
  }
178
179
  console.log(success(`Wrote primer files: ${primerSummary}.`));
179
180
  if (wantsClaude) {
180
- console.log(success('Ready! Run your coding agent here (claude, codex, grok, agy), or `gipity build` to launch one with a picker.'));
181
+ console.log(success(`Ready! Run your coding agent here (${AGENT_ADAPTERS.map(a => a.key).join(', ')}), or \`gipity build\` to launch one with a picker.`));
181
182
  // Recording happens by default (however Claude Code is launched), so
182
183
  // say so up front - consent should be explicit, not discovered later.
183
184
  if (opts.capture === false) {
@@ -5,6 +5,7 @@ import { brand, bold, muted, warning, success } from '../colors.js';
5
5
  import { run, parseDuration } from '../helpers/index.js';
6
6
  import { getAuth } from '../auth.js';
7
7
  import { resolveProjectContext } from '../config.js';
8
+ import { createCheckpoint, restoreCheckpoint, resolveDatabase } from '../db-checkpoint.js';
8
9
  import { uploadPublicFixture, uploadCameraFeed, assertCameraFile, deleteFixture } from '../page-fixtures.js';
9
10
  // Shown when an eval runs cleanly but returns nothing serializable. Turns a
10
11
  // bare/opaque `null` into a deterministic, actionable nudge so the agent shapes
@@ -416,8 +417,9 @@ export const pageEvalCommand = new Command('eval')
416
417
  .option('--wait <ms>', 'Sleep this many ms after DOMContentLoaded before evaluating (lets late async work settle; max 30000). With --wait-for, it elapses AFTER the selector appears - gate, then settle.', '500')
417
418
  .option('--wait-for <selector>', `Wait until this CSS selector appears before evaluating, then evaluate (deterministic - beats guessing a --wait). Gate on the state you are ASSERTING, not just a ready flag: '#verdict:not(:empty)' returns the instant the round lands, where a fixed wait snapshots mid-sequence. Same flag on page inspect/screenshot. Max ${WAIT_FOR_MAX_MS}ms (--wait-timeout).`)
418
419
  .option('--wait-timeout <ms>', `Max ms to wait for --wait-for before giving up (max ${WAIT_FOR_MAX_MS})`, '5000')
419
- .option('--timeout <ms>', `How long the script itself may run IN the page. Bare number = MILLISECONDS (so 90s = 90000, NOT 90); or pass an explicit unit that means the same on both this and \`sandbox run --timeout\` — --timeout 90s. Its own await/setTimeout pauses count (default ${EVAL_SCRIPT_BUDGET_MS}, ${EVAL_SCRIPT_BUDGET_CAMERA_MS} with --camera/--fake-media; floor 1000, max ${EVAL_SCRIPT_BUDGET_MAX_MS}). Raise it to trace a sequence that unfolds over time (a game round, an animation). Distinct from --wait, which only sleeps BEFORE the script.`)
420
+ .option('--timeout <ms>', `How long the script itself may run IN the page. Bare number = MILLISECONDS (so 90s = 90000, NOT 90); or pass an explicit unit that means the same on both this and \`sandbox run --timeout\` — --timeout 90s. Its own await/setTimeout pauses count (default ${EVAL_SCRIPT_BUDGET_MS}, ${EVAL_SCRIPT_BUDGET_CAMERA_MS} with --camera/--fake-media; floor 1000 - a bare number under it is rejected as a unit mix-up, a suffixed one just floors; max ${EVAL_SCRIPT_BUDGET_MAX_MS}). Raise it to trace a sequence that unfolds over time (a game round, an animation). Distinct from --wait, which only sleeps BEFORE the script.`)
420
421
  .option('--auth', 'Evaluate signed in as you (your Gipity account), so a page behind a Sign-in-with-Gipity login is reachable. Only works for apps using Sign in with Gipity, hosted on *.gipity.ai. Without this flag the page loads as a genuinely anonymous, signed-out visitor — nothing carries over from earlier --auth runs.')
422
+ .option('--restore-db', "Snapshot the app database before the script runs and roll it back after, so a write-path check (click Approve, submit the form, edit a row) leaves the real data untouched. Use this whenever the eval WRITES - it is the undo for driving the deployed app against real project data. Same snapshot/undo standalone: gipity db checkpoint / gipity db restore.")
421
423
  .option('--json', 'Output as JSON')
422
424
  .action((url, exprArg, opts) => run('Page eval', async () => {
423
425
  // A JS-intent flag guess (captured as a hidden decoy below): redirect to the
@@ -481,10 +483,13 @@ export const pageEvalCommand = new Command('eval')
481
483
  // 90s` means 90 seconds on BOTH commands. A suffixed value is normalized to ms
482
484
  // up front, so the rest of this action (and the bare-number guard below) sees a
483
485
  // plain ms number and the portable form just works.
486
+ let timeoutHadSuffix = false;
484
487
  if (opts.timeout !== undefined) {
485
488
  const dur = parseDuration(opts.timeout, 'ms');
486
- if (dur?.hadSuffix)
489
+ if (dur?.hadSuffix) {
487
490
  opts.timeout = String(Math.round(dur.value));
491
+ timeoutHadSuffix = true;
492
+ }
488
493
  }
489
494
  // A BARE number below the in-page floor is the unit-mixup tell: a real ms
490
495
  // budget that small is useless (it just floors to the minimum), so a sub-floor
@@ -493,7 +498,12 @@ export const pageEvalCommand = new Command('eval')
493
498
  // an opaque "1s budget" error that never reveals the unit mix-up. Reject it up
494
499
  // front, naming the unit AND the portable suffix form, so the fix is one obvious
495
500
  // edit instead of a doomed run.
496
- if (opts.timeout !== undefined) {
501
+ //
502
+ // A SUFFIXED value is exempt: `--timeout 400ms` states the unit, so there is no
503
+ // mix-up left to name. Sent through the guard it drew the one answer that is
504
+ // certainly wrong for that caller - "pass --timeout 400s", a 400x jump they
505
+ // never asked for. Let it floor in capScriptBudgetMs like any other small value.
506
+ if (opts.timeout !== undefined && !timeoutHadSuffix) {
497
507
  const t = parseInt(opts.timeout, 10);
498
508
  if (Number.isFinite(t) && t > 0 && t < EVAL_SCRIPT_BUDGET_MIN_MS) {
499
509
  const overMax = t * 1000 > EVAL_SCRIPT_BUDGET_MAX_MS;
@@ -561,7 +571,24 @@ export const pageEvalCommand = new Command('eval')
561
571
  // instant error, not an upload plus an opaque browser-side failure.
562
572
  if (opts.camera)
563
573
  assertCameraFile(opts.camera);
574
+ // Set when --restore-db took a checkpoint; the finally below rolls the app
575
+ // database back to it, so a write-path smoke test leaves no residue in the
576
+ // real data the user is about to look at.
577
+ let restoreDb;
564
578
  try {
579
+ if (opts.restoreDb) {
580
+ const { config } = await resolveProjectContext({});
581
+ projectGuid = config.projectGuid;
582
+ const database = await resolveDatabase(config.projectGuid);
583
+ if (!database) {
584
+ console.error(muted('--restore-db: this project has no database - nothing to roll back.'));
585
+ }
586
+ else {
587
+ const cp = await createCheckpoint(config.projectGuid, database);
588
+ console.error(muted(`Checkpointed ${cp.tables.length} table(s), ${cp.rows} row(s) in '${database}' - rolled back when this eval finishes.`));
589
+ restoreDb = { projectGuid: config.projectGuid, database };
590
+ }
591
+ }
565
592
  if (fixturePaths.length || opts.camera) {
566
593
  const { config } = await resolveProjectContext({});
567
594
  projectGuid = config.projectGuid;
@@ -715,6 +742,15 @@ export const pageEvalCommand = new Command('eval')
715
742
  }
716
743
  }
717
744
  finally {
745
+ if (restoreDb) {
746
+ try {
747
+ const r = await restoreCheckpoint(restoreDb.projectGuid, restoreDb.database);
748
+ console.error(muted(`Rolled ${r.tables.length} table(s) back to the checkpoint (${r.rows} row(s)) - nothing this eval wrote survives.`));
749
+ }
750
+ catch (err) {
751
+ console.error(warning(`⚠ Could not roll back the database - the checkpoint is still there, retry with: gipity db restore (${err.message})`));
752
+ }
753
+ }
718
754
  for (const h of [...hosted, ...(camera ? [camera] : [])]) {
719
755
  try {
720
756
  await deleteFixture(projectGuid, h.guid);
@@ -1,6 +1,6 @@
1
1
  import { Command, Option } from 'commander';
2
2
  import { mkdirSync, writeFileSync } from 'fs';
3
- import { dirname, join, resolve as resolvePath } from 'path';
3
+ import { dirname, extname, join, resolve as resolvePath } from 'path';
4
4
  import { postForTarEntries } from '../api.js';
5
5
  import { getConfig, getProjectRoot } from '../config.js';
6
6
  import { getAuth } from '../auth.js';
@@ -171,6 +171,19 @@ function resolveDevice(name) {
171
171
  const available = [...Object.keys(DEVICE_PRESETS), ...TOUCH_DEVICES].join(', ');
172
172
  throw new Error(`Unknown --device preset: "${name}" (known: ${available})`);
173
173
  }
174
+ /** Slug used to tell one viewport's `-o` file from another's: the device name the
175
+ * caller typed (`desktop`, `Pixel 9` → `pixel-9`) or the raw dimensions. */
176
+ function viewportSlug(name) {
177
+ return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || 'shot';
178
+ }
179
+ /** Expand an `--output` path into one path per viewport by treating it as a stem:
180
+ * `tmp/shot.png` + `mobile` → `tmp/shot-mobile.png`. Keeps the caller's extension
181
+ * (defaulting to .png) so a multi-device capture writes every file it took. */
182
+ function stemPath(output, suffix) {
183
+ const ext = extname(output) || '.png';
184
+ const base = ext && output.endsWith(ext) ? output.slice(0, -ext.length) : output;
185
+ return `${base}-${suffix}${ext}`;
186
+ }
174
187
  function splitCsv(values) {
175
188
  if (!values || values.length === 0)
176
189
  return [];
@@ -238,7 +251,7 @@ export const pageScreenshotCommand = new Command('screenshot')
238
251
  .option('--action <js>', 'Run JS in the page before capturing - e.g. click a button to enter a state ("document.getElementById(\'play\').click()"). Runs as an async function body, so const/await and app-relative import(\'./...\') work. Runs after the post-load delay, then settles again before the shot. If it throws, the capture still happens and the failure is reported.')
239
252
  .option('--file <path>', 'Read the pre-capture script from a file instead of inline --action (mutually exclusive), or --file - to read it from stdin (pipe a heredoc: --file - <<\'EOF\' ... EOF) with no tmp file. For a multi-step driver - click through a flow, wait for it to render - then capture. Same async-function-body semantics as --action; same --file flag as page eval.')
240
253
  .option('--full', 'Capture the full scrollable page (default: viewport only). Scrolls the page through first so scroll-reveal/fade-in-on-scroll (IntersectionObserver) sections render into the shot instead of capturing blank.')
241
- .option('-o, --output <file>', 'Output path (single viewport only; default .gipity/screenshots/ss-<host>-<timestamp>.png)')
254
+ .option('-o, --output <file>', 'Output path (default .gipity/screenshots/ss-<host>-<timestamp>.png). With several viewports it is a stem: -o tmp/shot.png --device desktop,mobile writes tmp/shot-desktop.png and tmp/shot-mobile.png.')
242
255
  .option('--no-reload-between', 'Skip reload between viewports (faster, lower fidelity - only safe for static pages)')
243
256
  .option('--fake-media', 'Grant a synthetic microphone + camera and auto-accept the getUserMedia prompt, so voice/camera apps render headlessly. The video feed is a built-in test pattern — to capture what the app does with a REAL frame (a hand, a face, an object), use --camera <path> instead.')
244
257
  .option('--camera <path>', 'Play a local image or video (.png/.jpg/.webp/.mp4/.webm/.y4m/.mjpeg) as the browser\'s WEBCAM feed, then capture — so the shot shows the app reacting to a frame you chose (detected gesture, boxes, labels). Implies --fake-media.')
@@ -347,9 +360,12 @@ export const pageScreenshotCommand = new Command('screenshot')
347
360
  ...deviceNames.map(resolveDevice),
348
361
  ...viewportStrs.map(parseViewportString),
349
362
  ];
350
- if (opts.output && customViewports.length > 1) {
351
- throw new Error('--output can only be used with a single viewport');
352
- }
363
+ // Parallel to customViewports: what each capture is called when `--output` has
364
+ // to name more than one file.
365
+ const viewportLabels = [
366
+ ...deviceNames.map(viewportSlug),
367
+ ...viewportStrs.map(viewportSlug),
368
+ ];
353
369
  // Server defaults to 1280×720 when viewports is omitted - don't send it in
354
370
  // the no-flag case so the filename stays unsuffixed (no viewport segment).
355
371
  const userSpecifiedViewports = customViewports.length > 0;
@@ -437,9 +453,21 @@ export const pageScreenshotCommand = new Command('screenshot')
437
453
  }
438
454
  const dir = defaultScreenshotDir();
439
455
  const savedFiles = [];
456
+ // With more than one viewport, `--output` is a stem: every capture gets its own
457
+ // file (shot.png → shot-desktop.png, shot-mobile.png) instead of overwriting.
458
+ const usedStems = new Set();
459
+ const outputPath = (i) => {
460
+ if (pngs.length === 1)
461
+ return opts.output;
462
+ let suffix = viewportLabels[i] ?? dimSuffix(meta.screenshots[i].viewport);
463
+ while (usedStems.has(suffix))
464
+ suffix += `-${i + 1}`;
465
+ usedStems.add(suffix);
466
+ return stemPath(opts.output, suffix);
467
+ };
440
468
  for (let i = 0; i < pngs.length; i++) {
441
469
  const target = opts.output
442
- ? opts.output
470
+ ? outputPath(i)
443
471
  : join(dir, names[i] ?? shotName(meta.screenshots[i].viewport));
444
472
  // Create the target's parent dir so a `-o` path under a not-yet-existing
445
473
  // directory (e.g. .gipity/screenshots/home.png) writes cleanly instead of
@@ -79,25 +79,37 @@ recordsCommand
79
79
  }));
80
80
  recordsCommand
81
81
  .command('query <table>')
82
- .description('List records')
83
- .option('--filter <filter>', 'Filter string (e.g., "status:eq:active")')
82
+ .description('List records (full-text search, filter, sort, recycle bin)')
83
+ .option('-q, --q <text>', 'Full-text search across the table\'s text columns (needs `--searchable true` on the table)')
84
+ .option('--filter <filter>', 'AND filter string (e.g., "status:eq:active")')
85
+ .option('--any <filter>', 'OR filter group, same grammar as --filter (e.g., "owner:eq:me,shared:eq:true")')
84
86
  .option('--sort <sort>', 'Sort string (e.g., "created_at:desc")')
85
87
  .option('--limit <n>', 'Max rows', '20')
86
88
  .option('--offset <n>', 'Offset', '0')
87
89
  .option('--fields <fields>', 'Comma-separated column names')
90
+ .option('--include-deleted', 'Include soft-deleted rows (owner/editor)')
91
+ .option('--only-deleted', 'Only soft-deleted rows - the recycle bin (owner/editor)')
88
92
  .option(ANON_FLAG, ANON_HELP)
89
93
  .option('--json', 'Output as JSON')
90
94
  .action((table, opts) => run('Query', async () => {
91
95
  const api = await recordsHttp(opts);
92
96
  const params = new URLSearchParams();
97
+ if (opts.q)
98
+ params.set('q', opts.q);
93
99
  if (opts.filter)
94
100
  params.set('filter', opts.filter);
101
+ if (opts.any)
102
+ params.set('any', opts.any);
95
103
  if (opts.sort)
96
104
  params.set('sort', opts.sort);
97
105
  params.set('limit', opts.limit);
98
106
  params.set('offset', opts.offset);
99
107
  if (opts.fields)
100
108
  params.set('fields', opts.fields);
109
+ if (opts.includeDeleted)
110
+ params.set('include_deleted', '1');
111
+ if (opts.onlyDeleted)
112
+ params.set('only_deleted', '1');
101
113
  const res = await api.get(`/api/${api.guid}/records/${table}?${params}`);
102
114
  if (opts.json) {
103
115
  console.log(JSON.stringify(res));
@@ -162,18 +174,38 @@ recordsCommand
162
174
  const res = await api.put(`/api/${api.guid}/records/${table}/${id}`, data);
163
175
  printResult(`Updated: ${JSON.stringify(res.data)}`, opts, res.data);
164
176
  }));
177
+ // A table that declares `soft_delete_column` only STAMPS the row on delete - it
178
+ // stays queryable via `query --only-deleted` and keeps its audit history. That's
179
+ // right for user data and wrong for a probe row you just minted to test the
180
+ // wiring, so `--purge` (the server's ?purge=1) is the one call that really
181
+ // removes it. The plain success line says which of the two happened and names
182
+ // the escape hatch, so nobody has to go spelunking through gipity.js to find it.
165
183
  recordsCommand
166
184
  .command('delete <table> <id>')
167
- .description('Delete a record')
185
+ .description('Delete a record (soft-delete when the table declares one; --purge removes it for good)')
186
+ .option('--purge', 'Hard-delete: remove the row AND erase its audit history (owner/editor). Use it to scrub probe rows.')
168
187
  .option(ANON_FLAG, ANON_HELP)
169
188
  .option('--json', 'Output as JSON')
170
189
  .action((table, id, opts) => run('Delete', async () => {
171
- if (!await confirm(`Delete record ${id} from "${table}"?`)) {
190
+ const what = opts.purge ? `Purge record ${id} from "${table}" (also erases its history)?` : `Delete record ${id} from "${table}"?`;
191
+ if (!await confirm(what)) {
172
192
  printResult('Cancelled.', opts, { table, id, deleted: false, cancelled: true });
173
193
  return;
174
194
  }
175
195
  const api = await recordsHttp(opts);
176
- const res = await api.del(`/api/${api.guid}/records/${table}/${id}`);
177
- printResult('Deleted.', opts, res?.data ?? { table, id, deleted: true });
196
+ const res = await api.del(`/api/${api.guid}/records/${table}/${id}${opts.purge ? '?purge=1' : ''}`);
197
+ const data = res?.data ?? { table, id, deleted: true, purged: !!opts.purge };
198
+ printResult(data.purged
199
+ ? 'Purged - the row and its audit history are gone.'
200
+ : `Deleted. If "${table}" declares a soft-delete column the row is only stamped deleted (see it with \`gipity records query ${table} --only-deleted\`, bring it back with \`gipity records restore ${table} ${id}\`, remove it for good with \`--purge\`).`, opts, data);
201
+ }));
202
+ recordsCommand
203
+ .command('restore <table> <id>')
204
+ .description('Un-delete a soft-deleted record (owner/editor)')
205
+ .option('--json', 'Output as JSON')
206
+ .action((table, id, opts) => run('Restore', async () => {
207
+ const api = await recordsHttp(opts);
208
+ const res = await api.post(`/api/${api.guid}/records/${table}/${id}/restore`);
209
+ printResult('Restored.', opts, res?.data ?? { table, id, restored: true });
178
210
  }));
179
211
  //# sourceMappingURL=records.js.map
@@ -1,8 +1,9 @@
1
1
  import { Command } from 'commander';
2
- import { get, post } from '../api.js';
2
+ import { get, post, publicRequest, mintAppToken, ApiError } from '../api.js';
3
+ import { getAuth } from '../auth.js';
3
4
  import { requireConfig } from '../config.js';
4
5
  import { bold, muted } from '../colors.js';
5
- import { run } from '../helpers/index.js';
6
+ import { run, emitField, resolveBody } from '../helpers/index.js';
6
7
  /** Known app-service endpoints, shown by `gipity service list` and used to
7
8
  * give a helpful hint on typos. POST endpoints take a JSON body; GET
8
9
  * endpoints (model/voice listings) are reached with `--get`. */
@@ -35,16 +36,41 @@ serviceCommand
35
36
  const width = SERVICES.reduce((m, s) => Math.max(m, s.name.length), 0);
36
37
  console.log('Call one with `gipity service call <name> \'{"json":"body"}\'`');
37
38
  console.log(muted('(GET endpoints like llm/models, tts/voices take --get and no body)'));
39
+ console.log(muted('Verifying what a signed-out visitor of your deployed app gets? Add --anon.'));
38
40
  console.log('');
39
41
  for (const s of SERVICES) {
40
42
  console.log(`${bold(s.name.padEnd(width))} ${muted(`[${s.method}] ${s.desc}`)}`);
41
43
  }
42
44
  }));
45
+ /** A signed-out visitor's 401 on a service is almost never "the caller needs to
46
+ * log in" — it is the app's service `billing_mode` still on the `user_pays`
47
+ * default, which asks every anonymous visitor of a PUBLIC page to sign in and
48
+ * pay from their own credits. The server's raw body says LOGIN_REQUIRED and
49
+ * nothing about the manifest, so the fix costs a doc hunt across skills. Name
50
+ * the cause and the exact edit here, at the moment it happens. */
51
+ export function anonBillingHint(name, err) {
52
+ if (!(err instanceof ApiError) || err.statusCode !== 401)
53
+ return null;
54
+ // Only the "sign in to use this" refusal is a billing-mode symptom. A missing
55
+ // credential (the visitor token never minted) is a different failure with a
56
+ // different fix, and must not be dressed up as one.
57
+ if (err.code !== 'LOGIN_REQUIRED')
58
+ return null;
59
+ const service = name.split('/')[0];
60
+ return (`An anonymous visitor cannot call '${service}': it is on the user_pays default, so every signed-out ` +
61
+ `visitor to a public page is asked to sign in and pay from their own credits. If this app serves the ` +
62
+ `public (a help bubble, a landing page), switch it to owner-pays in gipity.yaml and redeploy:\n` +
63
+ ` deploy:\n phases:\n - services\n service_definitions:\n - service: ${service}\n billing_mode: owner_pays\n` +
64
+ ` gipity deploy dev --only services`);
65
+ }
43
66
  serviceCommand
44
67
  .command('call <name> [body]')
45
- .description('Call an app service by name (e.g. llm, image, music). Uses your logged-in session - no token wrangling.')
46
- .option('--data <json>', 'JSON request body (alternative to the positional [body])')
68
+ .description('Call an app service by name (e.g. llm, image, music). Uses your logged-in session - no token wrangling; --anon calls it as a signed-out visitor instead.')
69
+ .option('-d, --data <json>', 'JSON request body: inline JSON, @file to read a file, or @- / - for stdin (alternative to the positional [body])')
70
+ .option('--file <field=@path>', 'Attach a file as { data, media_type } under <field> (the vision/media shape these services expect), repeatable, e.g. --file image=@receipt.png', (v, acc) => (acc || []).concat(v))
71
+ .option('--anon', 'Call as an anonymous visitor (the public path a signed-out user of your deployed app hits) instead of as your signed-in account')
47
72
  .option('--get', 'Issue a GET (for listing endpoints like llm/models, tts/voices)')
73
+ .option('--field <path>', 'Print only this field of the result (dot path, e.g. choices.0.message.content)')
48
74
  .option('--json', 'Output compact JSON')
49
75
  .action((name, bodyArg, opts) => run('Call', async () => {
50
76
  const config = requireConfig();
@@ -52,9 +78,47 @@ serviceCommand
52
78
  // like `location/geocode` and `llm/models` resolve correctly.
53
79
  const path = name.split('/').map(encodeURIComponent).join('/');
54
80
  const url = `/api/${config.projectGuid}/services/${path}`;
55
- const res = opts.get
56
- ? await get(url)
57
- : await post(url, JSON.parse(bodyArg || opts.data || '{}'));
81
+ const body = resolveBody(bodyArg || opts.data, opts.file);
82
+ // Name the calling identity (stderr, so stdout stays parseable). An owner
83
+ // call always succeeds regardless of billing mode, so without this line a
84
+ // "the service works" verification silently proves nothing about the
85
+ // visitors the deployed app actually serves.
86
+ if (opts.anon) {
87
+ console.error(muted('Auth: anonymous visitor (the public path a signed-out user of your deployed app hits)'));
88
+ }
89
+ else {
90
+ const who = getAuth()?.email;
91
+ console.error(muted(`Auth: calling as ${who ?? 'your signed-in account'} (the owner persona - always billed to you and never blocked by billing_mode; use --anon for the public visitor path)`));
92
+ }
93
+ let res;
94
+ try {
95
+ if (opts.anon) {
96
+ // The short-lived app token IS the visitor's credential here (unlike a
97
+ // public function, a service is never callable with no token at all).
98
+ // If it can't be minted, say so — otherwise the request comes back as a
99
+ // bare 401 that reads like an app-permissions problem.
100
+ const headers = await mintAppToken(config.projectGuid);
101
+ if (!headers) {
102
+ throw new Error(`Could not mint a visitor token for this project, so there is no anonymous path to call. ` +
103
+ `That means the app is not deployed on this API base yet: run \`gipity deploy dev\` first, ` +
104
+ `then re-run this command.`);
105
+ }
106
+ res = await publicRequest(opts.get ? 'GET' : 'POST', url, opts.get ? undefined : body, headers);
107
+ }
108
+ else {
109
+ res = opts.get ? await get(url) : await post(url, body);
110
+ }
111
+ }
112
+ catch (err) {
113
+ const hint = opts.anon ? anonBillingHint(name, err) : null;
114
+ if (!hint)
115
+ throw err;
116
+ throw new Error(`${err.message}\n${hint}`);
117
+ }
118
+ if (opts.field) {
119
+ emitField(res, opts.field);
120
+ return;
121
+ }
58
122
  console.log(opts.json ? JSON.stringify(res) : JSON.stringify(res, null, 2));
59
123
  }));
60
124
  //# sourceMappingURL=service.js.map