gipity 1.1.30 → 1.1.32

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.
@@ -53,8 +53,7 @@ export const deployCommand = new Command('deploy')
53
53
  .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')
54
54
  .option('--force', 'Re-run all phases (ignore checksums) and bypass the sync bulk-deletion guard')
55
55
  .option('--no-sync', 'Skip sync-up before deploy')
56
- .option('--optimize', 'Force Vite build optimization on (default for prod; use this to optimize a dev deploy too)')
57
- .option('--no-optimize', 'Skip build optimization and upload files as-is - the escape hatch for plain-HTML apps whose <script src> tags are not type="module"')
56
+ .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')
58
57
  .option('--json', 'Output as JSON')
59
58
  .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.')
60
59
  // The settle knobs `page inspect` already has. An app whose first paint is behind
@@ -71,6 +71,8 @@ emailCommand
71
71
  const subj = r.detail?.subject ? ` · ${r.detail.subject}` : '';
72
72
  const status = r.detail?.status ? ` [skipped: ${r.detail.status}]` : '';
73
73
  console.log(` ${muted(when)} ${to}${status ? warning(status) : ''}${muted(subj)}`);
74
+ if (r.detail?.reason)
75
+ console.log(` ${muted(r.detail.reason)}`);
74
76
  }
75
77
  }));
76
78
  //# sourceMappingURL=email.js.map
@@ -325,6 +325,22 @@ export function slowRenderMessage(fps, o) {
325
325
  + `Step the app's own loop deterministically instead (3D templates: ${bold('core.advance(seconds)')}; `
326
326
  + `2D/Phaser template: ${bold("(await import('./js/config.js')).advance(seconds)")}).`;
327
327
  }
328
+ /** A slow eval should say which leg was slow, instead of leaving the caller to
329
+ * guess a longer --wait. Silent under SLOW_EVAL_MS. Exported for tests. */
330
+ const SLOW_EVAL_MS = 20_000;
331
+ export function evalTimingLine(t) {
332
+ const total = t.hostMs + t.submitMs + t.pollMs;
333
+ if (total < SLOW_EVAL_MS)
334
+ return null;
335
+ const s = (ms) => `${(ms / 1000).toFixed(1)}s`;
336
+ const parts = [
337
+ t.hostMs >= 500 ? `hosting files ${s(t.hostMs)}` : null,
338
+ t.submitMs >= 500 ? `camera/feed setup ${s(t.submitMs)}` : null,
339
+ t.browserMs !== undefined ? `browser ${s(t.browserMs)} (launch, page load, waits, script)` : `browser ${s(t.pollMs)}`,
340
+ t.browserMs !== undefined && t.pollMs - t.browserMs >= 2000 ? `queue + cleanup ${s(t.pollMs - t.browserMs)}` : null,
341
+ ].filter(Boolean);
342
+ return `timing: ${s(total)} = ${parts.join(' + ')}`;
343
+ }
328
344
  /** Poll the async eval job until it finishes. Eval runs server-side as a
329
345
  * short-lived job (so a long --wait can't trip the gateway idle timeout);
330
346
  * we submit, then poll the result out of the job store. `expectedWorkMs` is
@@ -600,6 +616,7 @@ export const pageEvalCommand = new Command('eval')
600
616
  const { config } = await resolveProjectContext({});
601
617
  projectGuid = config.projectGuid;
602
618
  }
619
+ const hostStart = Date.now();
603
620
  if (opts.camera) {
604
621
  console.log(muted(`Hosting camera feed ${opts.camera}...`));
605
622
  camera = await uploadCameraFeed(projectGuid, opts.camera);
@@ -621,6 +638,7 @@ export const pageEvalCommand = new Command('eval')
621
638
  if (settleAfterGateMs > 0) {
622
639
  sentExpr = withPrelude(sentExpr, `await new Promise((r) => setTimeout(r, ${settleAfterGateMs}));`);
623
640
  }
641
+ const submitStart = Date.now();
624
642
  const kickoff = await post('/tools/browser/eval', {
625
643
  url, expr: sentExpr, waitMs: sentWaitMs,
626
644
  steps: sentSteps.length ? sentSteps : undefined,
@@ -634,6 +652,7 @@ export const pageEvalCommand = new Command('eval')
634
652
  fakeMedia: opts.fakeMedia || !!camera || undefined,
635
653
  cameraUrl: camera?.url,
636
654
  });
655
+ const pollStart = Date.now();
637
656
  let d;
638
657
  try {
639
658
  d = await pollEvalResult(kickoff.data.evalJobId, evalWorkBudgetMs({
@@ -658,6 +677,12 @@ export const pageEvalCommand = new Command('eval')
658
677
  throw err;
659
678
  throw new Error(`${msg}\n${hint}`);
660
679
  }
680
+ const timing = evalTimingLine({
681
+ hostMs: submitStart - hostStart, submitMs: pollStart - submitStart,
682
+ pollMs: Date.now() - pollStart, browserMs: d.browserMs,
683
+ });
684
+ if (timing)
685
+ console.error(muted(timing));
661
686
  const { result, noValue } = normalizeEvalResult(d.result);
662
687
  const reload = d.reloadResult !== undefined ? normalizeEvalResult(d.reloadResult) : undefined;
663
688
  const execTimeout = evalExecTimeoutMessage(d.result, scriptBudgetMs);
@@ -130,7 +130,9 @@ function parseViewportString(s) {
130
130
  const height = parseInt(m[2], 10);
131
131
  const dpr = m[3] ? parseFloat(m[3]) : undefined;
132
132
  if (width < 200 || width > 3840 || height < 200 || height > 2160) {
133
- throw new Error(`Viewport out of range: ${s} (200-3840 x 200-2160)`);
133
+ // A tall viewport is nearly always "show me the whole page": name the flag for that.
134
+ const tall = height > 2160 ? ` To capture a page taller than the window, keep a normal viewport and add --full (e.g. --viewport ${Math.min(Math.max(width, 200), 3840)}x900 --full).` : '';
135
+ throw new Error(`Viewport out of range: ${s} (200-3840 x 200-2160).${tall}`);
134
136
  }
135
137
  return dpr ? { width, height, deviceScaleFactor: dpr } : { width, height };
136
138
  }
@@ -18,6 +18,12 @@ async function inspectClient(url, waitMs, i) {
18
18
  }
19
19
  const MAX_HOLD_MS = 15_000; // keep each in-page await under the ~20s browser action timeout
20
20
  const MIN_HOLD_MS = 1_000;
21
+ // Clients start on separate browser containers, and a cold one can take longer
22
+ // to load than a whole --hold, so "each client holds from its own load" left a
23
+ // late client sampling after the early one had closed its page (a false
24
+ // "did NOT overlap" even with --stagger 0). Every client instead waits, page
25
+ // open, until a shared start time this far after its launch, then holds.
26
+ export const JOIN_ALLOWANCE_MS = 12_000;
21
27
  // ── lifecycle actions (--at) ───────────────────────────────────────────────
22
28
  // Freeze, hide, or take one client offline partway through the hold window, so
23
29
  // an app can test what its peers do when a phone locks (host handoff) instead
@@ -146,13 +152,15 @@ function warnUnknownTokens(unknown) {
146
152
  /** Build the statement-body script one client runs: do the one-time action,
147
153
  * then sample `observe` `samples` times across `holdMs`, stamping in-page
148
154
  * start/end so the caller can confirm the clients overlapped. */
149
- export function buildHarness(action, observe, label, holdMs, samples) {
155
+ export function buildHarness(action, observe, label, holdMs, samples, startAt) {
150
156
  const n = Math.max(2, samples);
151
157
  const interval = Math.max(0, Math.floor(holdMs / (n - 1)));
152
- const lines = [
153
- `const __label=${JSON.stringify(label)};`,
154
- `const __t0=Date.now();`,
155
- ];
158
+ const lines = [`const __label=${JSON.stringify(label)};`];
159
+ // Shared start (see JOIN_ALLOWANCE_MS). Capped so a skewed clock can't eat the budget.
160
+ if (startAt !== undefined) {
161
+ lines.push(`{ const __bw=Math.min(${startAt}-Date.now(),${JOIN_ALLOWANCE_MS}); if(__bw>0) await new Promise(function(r){setTimeout(r,__bw);}); }`);
162
+ }
163
+ lines.push(`const __t0=Date.now();`);
156
164
  if (action && action.trim()) {
157
165
  lines.push(`try{ ${action} }catch(__e){ return {label:__label,startedAt:__t0,endedAt:Date.now(),samples:[],actionError:String((__e&&__e.message)||__e)}; }`);
158
166
  }
@@ -166,7 +174,7 @@ export function buildHarness(action, observe, label, holdMs, samples) {
166
174
  return lines.join('\n');
167
175
  }
168
176
  /** Kick off and poll one client's eval job, then parse the harness payload. */
169
- async function observeClient(url, expr, i, label, settleMs, holdMs, waitForSelector, lifecycle) {
177
+ async function observeClient(url, expr, i, label, settleMs, holdMs, waitForSelector, lifecycle, barrier = false) {
170
178
  const base = { i, label, samples: [], startedAt: 0, endedAt: 0 };
171
179
  try {
172
180
  const kickoff = await post('/tools/browser/eval', {
@@ -175,12 +183,14 @@ async function observeClient(url, expr, i, label, settleMs, holdMs, waitForSelec
175
183
  waitMs: settleMs,
176
184
  waitForSelector: waitForSelector || undefined,
177
185
  waitForTimeoutMs: waitForSelector ? 5000 : undefined,
186
+ // The shared-start wait runs inside the script, so the script needs room for it.
187
+ timeoutMs: barrier ? JOIN_ALLOWANCE_MS + holdMs + 10_000 : undefined,
178
188
  // Timed from the start of the observe window; the server restores
179
189
  // anything still applied at the end of the hold so the harness finishes.
180
190
  lifecycle: lifecycle?.length ? { steps: lifecycle, untilMs: holdMs } : undefined,
181
191
  });
182
192
  // Server work ≈ nav + settle + the in-page hold; pollEvalResult adds 60s headroom.
183
- const d = await pollEvalResult(kickoff.data.evalJobId, settleMs + holdMs);
193
+ const d = await pollEvalResult(kickoff.data.evalJobId, settleMs + holdMs + (barrier ? JOIN_ALLOWANCE_MS : 0));
184
194
  const raw = d.result?.trim() ?? '';
185
195
  if (raw.startsWith('EvalError:') || raw.startsWith('ObserveError:')) {
186
196
  return { ...base, error: raw };
@@ -287,6 +297,10 @@ async function runInteractive(url, observe, opts) {
287
297
  if (atSpecs.length)
288
298
  console.log(muted(`lifecycle (ms into each client's hold): ${atSpecs.map((s) => s.trim()).join(', ')}`));
289
299
  }
300
+ // Shared start for multi-client runs. Not with --at: its steps are timed from
301
+ // the script's start on the server, and a variable wait would shift them.
302
+ const barrier = clients > 1 && atSpecs.length === 0;
303
+ const t0 = Date.now();
290
304
  const runs = [];
291
305
  for (let i = 0; i < clients; i++) {
292
306
  runs.push((async () => {
@@ -297,8 +311,8 @@ async function runInteractive(url, observe, opts) {
297
311
  // asymmetric roles concurrently (e.g. ?role={{label}} with --labels host,join)
298
312
  // and the overlap check still confirms they coexisted.
299
313
  const clientUrl = subst(url, labelFor(i), i);
300
- const expr = buildHarness(opts.action ? subst(opts.action, labelFor(i), i) : undefined, subst(observe, labelFor(i), i), labelFor(i), hold, samples);
301
- return observeClient(clientUrl, expr, i, labelFor(i), settle, hold, opts.waitFor, lifecycle[i]);
314
+ const expr = buildHarness(opts.action ? subst(opts.action, labelFor(i), i) : undefined, subst(observe, labelFor(i), i), labelFor(i), hold, samples, barrier ? t0 + i * stagger * 1000 + JOIN_ALLOWANCE_MS : undefined);
315
+ return observeClient(clientUrl, expr, i, labelFor(i), settle, hold, opts.waitFor, lifecycle[i], barrier);
302
316
  })());
303
317
  }
304
318
  const results = (await Promise.all(runs)).sort((a, b) => a.i - b.i);
@@ -340,7 +354,7 @@ async function runInteractive(url, observe, opts) {
340
354
  }
341
355
  else {
342
356
  console.log(clrError('⚠ clients did NOT overlap in time: each ran in isolation, so any shared-state reading here is a FALSE NEGATIVE, not proof the app is broken.'));
343
- console.log(muted(' Likely causes: --stagger ≥ --hold, or more --clients than free browser slots (they queued). Lower --stagger / raise --hold / fewer --clients and retry.'));
357
+ console.log(muted(` Each client waits up to ${JOIN_ALLOWANCE_MS / 1000}s after launch for the others to load, then holds. Likely causes: --stagger ≥ --hold, or a client queued for a browser (more --clients than free slots). Lower --stagger / raise --hold / fewer --clients and retry.`));
344
358
  }
345
359
  if (errored.length > 0 || (clients > 1 && !overlapped))
346
360
  process.exitCode = 1;
@@ -52,6 +52,9 @@ const CODE_OPENERS = new Set([
52
52
  * not an assignment (`x = 1` is Python-or-bash-ambiguous). Anything that
53
53
  * fails these checks still goes through the explicit-pin error below.
54
54
  */
55
+ /** Longest --timeout one sandbox run accepts: the request has to finish
56
+ * inside the load balancer's 300s idle limit, output upload included. */
57
+ export const SANDBOX_MAX_TIMEOUT_S = 280;
55
58
  export function looksLikeShellCommand(code) {
56
59
  if (code.includes('\n'))
57
60
  return false;
@@ -253,7 +256,7 @@ sandboxCommand
253
256
  // `node` token still pins the language (so `python -c '...'` runs as python).
254
257
  .addOption(new Option('-c, --cmd <code>', 'Inline code (bash idiom: `sandbox run bash -c "<code>"`)').hideHelp())
255
258
  .addOption(new Option('-e, --eval <code>', 'Inline code (node idiom: `sandbox run node -e "<code>"`)').hideHelp())
256
- .option('--timeout <seconds>', 'Execution timeout. Bare number = seconds; or pass an explicit unit that means the same on both this and `page eval --timeout`, e.g. --timeout 90s.', '30')
259
+ .option('--timeout <seconds>', 'Execution timeout, max 280s (longer work: a Gipity Job). Bare number = seconds; or pass an explicit unit that means the same on both this and `page eval --timeout`, e.g. --timeout 90s.', '30')
257
260
  .option('--input <path>', 'Narrow to specific project files instead of auto-mirroring the whole tree (repeatable). Use this only for >1 GB projects or when you want surgical control.', (v, prev) => [...(prev ?? []), v])
258
261
  // Named "discard", not "no-sync": in Gipity vocabulary "sync" means the
259
262
  // local<->cloud file sync, so a no-sync spelling reads as "give me the file
@@ -383,6 +386,15 @@ GCC/Rust).
383
386
  process.exit(1);
384
387
  }
385
388
  }
389
+ // Empty code is never what the caller meant: usually `"$(cat missing.py)"`
390
+ // expanded to nothing, or an empty file. Say so here, before the server
391
+ // rejects it with a bare schema message.
392
+ if (!source?.trim()) {
393
+ console.error(clrError(filePath
394
+ ? `${filePath} is empty: nothing to run.`
395
+ : 'The inline code is empty: nothing to run. If it came from "$(cat <file>)", that file is missing or empty; pass --file <path> instead.'));
396
+ process.exit(1);
397
+ }
386
398
  // Language precedence: interpreter token > --language > file extension >
387
399
  // unambiguous-command-line heuristic (bash). resolveLanguage() exits when
388
400
  // nothing pins one and the input isn't command-shaped, rather than guessing.
@@ -396,12 +408,19 @@ GCC/Rust).
396
408
  console.error(clrError('--discard-output requires a non-empty glob (e.g. --discard-output "*.ppm")'));
397
409
  process.exit(1);
398
410
  }
399
- // Args are good - now it's worth resolving (and announcing) the project.
400
- const { config } = await resolveProjectContext();
401
411
  // A bare number is native SECONDS; an explicit suffix (90s / 1500ms / 2m) is
402
412
  // portable with `page eval --timeout` and converted to seconds here.
403
413
  const durOpt = parseDuration(opts.timeout, 's');
404
414
  const timeout = durOpt ? Math.max(1, Math.round(durOpt.value)) : parseInt(opts.timeout, 10);
415
+ // The run is one HTTP request, and the connection is cut at the load
416
+ // balancer's 300s idle limit however long --timeout is: refuse what can't work.
417
+ if (timeout > SANDBOX_MAX_TIMEOUT_S) {
418
+ console.error(clrError(`--timeout ${timeout}s is over the ${SANDBOX_MAX_TIMEOUT_S}s limit for one sandbox run (it is a single HTTP call).`));
419
+ console.error(dim(' Split the work into shorter runs, or run it as a Gipity Job (`gipity skill read jobs`), which has no such limit.'));
420
+ process.exit(1);
421
+ }
422
+ // Args are good - now it's worth resolving (and announcing) the project.
423
+ const { config } = await resolveProjectContext();
405
424
  const cwd = resolveRelativeCwd();
406
425
  // A scratch path is never synced, so it can never reach the VFS the sandbox
407
426
  // mirrors from - `--input tmp/frame.png` would fail inside the container with
@@ -472,7 +491,9 @@ GCC/Rust).
472
491
  // make every later sync propose deleting them. (`noSyncOutput` is the
473
492
  // wire name for --discard-output.)
474
493
  noSyncOutput: discardOutput.length ? discardOutput : undefined,
475
- });
494
+ // Wait as long as the run may take, plus room for the mirror and output
495
+ // upload. The 60s default cut off any run asking for more than that.
496
+ }, { timeoutMs: (isNaN(timeout) ? 30 : timeout) * 1000 + 30_000 });
476
497
  const res = opts.json
477
498
  ? await doRun()
478
499
  : await withSpinner('Running in sandbox...', doRun, { done: null });
package/dist/index.js CHANGED
@@ -38185,6 +38185,19 @@ function slowRenderMessage(fps, o) {
38185
38185
  }
38186
38186
  return `${warning("\u26A0 Slow render:")} page painted at ${fps} fps. Waiting on real time (setTimeout) advances animation/physics time far slower than it looks: assertions after a wall-clock wait can report a false negative. Step the app's own loop deterministically instead (3D templates: ${bold("core.advance(seconds)")}; 2D/Phaser template: ${bold("(await import('./js/config.js')).advance(seconds)")}).`;
38187
38187
  }
38188
+ var SLOW_EVAL_MS = 2e4;
38189
+ function evalTimingLine(t) {
38190
+ const total = t.hostMs + t.submitMs + t.pollMs;
38191
+ if (total < SLOW_EVAL_MS) return null;
38192
+ const s = (ms2) => `${(ms2 / 1e3).toFixed(1)}s`;
38193
+ const parts = [
38194
+ t.hostMs >= 500 ? `hosting files ${s(t.hostMs)}` : null,
38195
+ t.submitMs >= 500 ? `camera/feed setup ${s(t.submitMs)}` : null,
38196
+ t.browserMs !== void 0 ? `browser ${s(t.browserMs)} (launch, page load, waits, script)` : `browser ${s(t.pollMs)}`,
38197
+ t.browserMs !== void 0 && t.pollMs - t.browserMs >= 2e3 ? `queue + cleanup ${s(t.pollMs - t.browserMs)}` : null
38198
+ ].filter(Boolean);
38199
+ return `timing: ${s(total)} = ${parts.join(" + ")}`;
38200
+ }
38188
38201
  async function pollEvalResult(evalJobId, expectedWorkMs) {
38189
38202
  const deadline = Date.now() + expectedWorkMs + 6e4;
38190
38203
  let missCount = 0;
@@ -38346,6 +38359,7 @@ var pageEvalCommand = new Command("eval").description("Evaluate JS in a real bro
38346
38359
  const { config } = await resolveProjectContext({});
38347
38360
  projectGuid2 = config.projectGuid;
38348
38361
  }
38362
+ const hostStart = Date.now();
38349
38363
  if (opts.camera) {
38350
38364
  console.log(muted(`Hosting camera feed ${opts.camera}...`));
38351
38365
  camera = await uploadCameraFeed(projectGuid2, opts.camera);
@@ -38364,6 +38378,7 @@ var pageEvalCommand = new Command("eval").description("Evaluate JS in a real bro
38364
38378
  if (settleAfterGateMs > 0) {
38365
38379
  sentExpr = withPrelude(sentExpr, `await new Promise((r) => setTimeout(r, ${settleAfterGateMs}));`);
38366
38380
  }
38381
+ const submitStart = Date.now();
38367
38382
  const kickoff = await post("/tools/browser/eval", {
38368
38383
  url,
38369
38384
  expr: sentExpr,
@@ -38379,6 +38394,7 @@ var pageEvalCommand = new Command("eval").description("Evaluate JS in a real bro
38379
38394
  fakeMedia: opts.fakeMedia || !!camera || void 0,
38380
38395
  cameraUrl: camera?.url
38381
38396
  });
38397
+ const pollStart = Date.now();
38382
38398
  let d;
38383
38399
  try {
38384
38400
  d = await pollEvalResult(kickoff.data.evalJobId, evalWorkBudgetMs({
@@ -38396,6 +38412,13 @@ var pageEvalCommand = new Command("eval").description("Evaluate JS in a real bro
38396
38412
  throw new Error(`${msg}
38397
38413
  ${hint}`);
38398
38414
  }
38415
+ const timing = evalTimingLine({
38416
+ hostMs: submitStart - hostStart,
38417
+ submitMs: pollStart - submitStart,
38418
+ pollMs: Date.now() - pollStart,
38419
+ browserMs: d.browserMs
38420
+ });
38421
+ if (timing) console.error(muted(timing));
38399
38422
  const { result, noValue } = normalizeEvalResult(d.result);
38400
38423
  const reload = d.reloadResult !== void 0 ? normalizeEvalResult(d.reloadResult) : void 0;
38401
38424
  const execTimeout = evalExecTimeoutMessage(d.result, scriptBudgetMs);
@@ -38656,7 +38679,8 @@ function parseViewportString(s) {
38656
38679
  const height = parseInt(m[2], 10);
38657
38680
  const dpr = m[3] ? parseFloat(m[3]) : void 0;
38658
38681
  if (width < 200 || width > 3840 || height < 200 || height > 2160) {
38659
- throw new Error(`Viewport out of range: ${s} (200-3840 x 200-2160)`);
38682
+ const tall = height > 2160 ? ` To capture a page taller than the window, keep a normal viewport and add --full (e.g. --viewport ${Math.min(Math.max(width, 200), 3840)}x900 --full).` : "";
38683
+ throw new Error(`Viewport out of range: ${s} (200-3840 x 200-2160).${tall}`);
38660
38684
  }
38661
38685
  return dpr ? { width, height, deviceScaleFactor: dpr } : { width, height };
38662
38686
  }
@@ -39202,7 +39226,7 @@ async function printPlan(appGuid2, env, json) {
39202
39226
  console.log(warning("A prod deploy stops on the destructive statements above until you pass --yes-destructive."));
39203
39227
  }
39204
39228
  }
39205
- 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").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", "Force Vite build optimization on (default for prod; use this to optimize a dev deploy too)").option("--no-optimize", 'Skip build optimization and upload files as-is - the escape hatch for plain-HTML apps whose <script src> tags are not type="module"').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 () => {
39229
+ 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").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 () => {
39206
39230
  const env = envArg ?? getEnvOption();
39207
39231
  if (opts.plan) {
39208
39232
  await printPlan(requireConfig2().projectGuid, env ?? "prod", !!opts.json);
@@ -39719,6 +39743,7 @@ var CODE_OPENERS = /* @__PURE__ */ new Set([
39719
39743
  "try",
39720
39744
  "with"
39721
39745
  ]);
39746
+ var SANDBOX_MAX_TIMEOUT_S = 280;
39722
39747
  function looksLikeShellCommand(code) {
39723
39748
  if (code.includes("\n")) return false;
39724
39749
  const m = /^([A-Za-z0-9_.~/-]+)(\s|$)/.exec(code.trim());
@@ -39816,7 +39841,7 @@ function resolveRelativeCwd() {
39816
39841
  return rel2.split(/[\\/]/).filter(Boolean).join("/");
39817
39842
  }
39818
39843
  var sandboxCommand = new Command("sandbox").description("Run code in a sandbox");
39819
- sandboxCommand.command("run [args...]").description("Run code").option("--language <language>", "Language: js, py, or bash (required unless pinned by an interpreter token or --file extension)").option("--file <path>", "Read the code body from a file instead of the inline <code> arg; --language is inferred from the extension when not given").addOption(new Option("--code <code>", "Alias for the positional inline <code> arg").hideHelp()).addOption(new Option("-c, --cmd <code>", 'Inline code (bash idiom: `sandbox run bash -c "<code>"`)').hideHelp()).addOption(new Option("-e, --eval <code>", 'Inline code (node idiom: `sandbox run node -e "<code>"`)').hideHelp()).option("--timeout <seconds>", "Execution timeout. Bare number = seconds; or pass an explicit unit that means the same on both this and `page eval --timeout`, e.g. --timeout 90s.", "30").option(
39844
+ sandboxCommand.command("run [args...]").description("Run code").option("--language <language>", "Language: js, py, or bash (required unless pinned by an interpreter token or --file extension)").option("--file <path>", "Read the code body from a file instead of the inline <code> arg; --language is inferred from the extension when not given").addOption(new Option("--code <code>", "Alias for the positional inline <code> arg").hideHelp()).addOption(new Option("-c, --cmd <code>", 'Inline code (bash idiom: `sandbox run bash -c "<code>"`)').hideHelp()).addOption(new Option("-e, --eval <code>", 'Inline code (node idiom: `sandbox run node -e "<code>"`)').hideHelp()).option("--timeout <seconds>", "Execution timeout, max 280s (longer work: a Gipity Job). Bare number = seconds; or pass an explicit unit that means the same on both this and `page eval --timeout`, e.g. --timeout 90s.", "30").option(
39820
39845
  "--input <path>",
39821
39846
  "Narrow to specific project files instead of auto-mirroring the whole tree (repeatable). Use this only for >1 GB projects or when you want surgical control.",
39822
39847
  (v7, prev) => [...prev ?? [], v7]
@@ -39919,15 +39944,24 @@ GCC/Rust).
39919
39944
  process.exit(1);
39920
39945
  }
39921
39946
  }
39947
+ if (!source?.trim()) {
39948
+ console.error(error(filePath ? `${filePath} is empty: nothing to run.` : 'The inline code is empty: nothing to run. If it came from "$(cat <file>)", that file is missing or empty; pass --file <path> instead.'));
39949
+ process.exit(1);
39950
+ }
39922
39951
  const language = resolveLanguage({ langFromInterp, langOpt: opts.language, filePath, inlineCode });
39923
39952
  const discardOutput = opts.discardOutput ?? [];
39924
39953
  if (discardOutput.some((g) => !g.trim())) {
39925
39954
  console.error(error('--discard-output requires a non-empty glob (e.g. --discard-output "*.ppm")'));
39926
39955
  process.exit(1);
39927
39956
  }
39928
- const { config } = await resolveProjectContext();
39929
39957
  const durOpt = parseDuration(opts.timeout, "s");
39930
39958
  const timeout = durOpt ? Math.max(1, Math.round(durOpt.value)) : parseInt(opts.timeout, 10);
39959
+ if (timeout > SANDBOX_MAX_TIMEOUT_S) {
39960
+ console.error(error(`--timeout ${timeout}s is over the ${SANDBOX_MAX_TIMEOUT_S}s limit for one sandbox run (it is a single HTTP call).`));
39961
+ console.error(dim(" Split the work into shorter runs, or run it as a Gipity Job (`gipity skill read jobs`), which has no such limit."));
39962
+ process.exit(1);
39963
+ }
39964
+ const { config } = await resolveProjectContext();
39931
39965
  const cwd = resolveRelativeCwd();
39932
39966
  const scratchInputs = (opts.input ?? []).filter(
39933
39967
  (p) => shouldIgnore(p.replace(/\\/g, "/").replace(/^\.\//, ""), SCRATCH_IGNORE)
@@ -39969,7 +40003,9 @@ GCC/Rust).
39969
40003
  // make every later sync propose deleting them. (`noSyncOutput` is the
39970
40004
  // wire name for --discard-output.)
39971
40005
  noSyncOutput: discardOutput.length ? discardOutput : void 0
39972
- });
40006
+ // Wait as long as the run may take, plus room for the mirror and output
40007
+ // upload. The 60s default cut off any run asking for more than that.
40008
+ }, { timeoutMs: (isNaN(timeout) ? 30 : timeout) * 1e3 + 3e4 });
39973
40009
  const res = opts.json ? await doRun() : await withSpinner("Running in sandbox...", doRun, { done: null });
39974
40010
  const pulledLocal = !!(res.data.outputFiles?.length && getConfigPath());
39975
40011
  if (pulledLocal) {
@@ -43358,6 +43394,7 @@ async function inspectClient(url, waitMs, i) {
43358
43394
  }
43359
43395
  var MAX_HOLD_MS = 15e3;
43360
43396
  var MIN_HOLD_MS = 1e3;
43397
+ var JOIN_ALLOWANCE_MS = 12e3;
43361
43398
  var LIFECYCLE_ACTIONS = ["freeze", "wake", "hide", "show", "offline", "online"];
43362
43399
  var PAUSED_SAMPLE = "(paused)";
43363
43400
  var PAUSE_SLACK_MS = 1500;
@@ -43442,13 +43479,14 @@ function warnUnknownTokens(unknown) {
43442
43479
  `\u26A0 Unrecognized placeholder ${unknown.join(", ")} left as-is: only {{i}} (0-based client index) and {{label}} are substituted per client. Set per-client values with --labels and reference them as {{label}}.`
43443
43480
  ));
43444
43481
  }
43445
- function buildHarness(action, observe, label2, holdMs, samples) {
43482
+ function buildHarness(action, observe, label2, holdMs, samples, startAt) {
43446
43483
  const n = Math.max(2, samples);
43447
43484
  const interval = Math.max(0, Math.floor(holdMs / (n - 1)));
43448
- const lines = [
43449
- `const __label=${JSON.stringify(label2)};`,
43450
- `const __t0=Date.now();`
43451
- ];
43485
+ const lines = [`const __label=${JSON.stringify(label2)};`];
43486
+ if (startAt !== void 0) {
43487
+ lines.push(`{ const __bw=Math.min(${startAt}-Date.now(),${JOIN_ALLOWANCE_MS}); if(__bw>0) await new Promise(function(r){setTimeout(r,__bw);}); }`);
43488
+ }
43489
+ lines.push(`const __t0=Date.now();`);
43452
43490
  if (action && action.trim()) {
43453
43491
  lines.push(
43454
43492
  `try{ ${action} }catch(__e){ return {label:__label,startedAt:__t0,endedAt:Date.now(),samples:[],actionError:String((__e&&__e.message)||__e)}; }`
@@ -43467,7 +43505,7 @@ function buildHarness(action, observe, label2, holdMs, samples) {
43467
43505
  );
43468
43506
  return lines.join("\n");
43469
43507
  }
43470
- async function observeClient(url, expr, i, label2, settleMs, holdMs, waitForSelector, lifecycle) {
43508
+ async function observeClient(url, expr, i, label2, settleMs, holdMs, waitForSelector, lifecycle, barrier = false) {
43471
43509
  const base = { i, label: label2, samples: [], startedAt: 0, endedAt: 0 };
43472
43510
  try {
43473
43511
  const kickoff = await post("/tools/browser/eval", {
@@ -43476,11 +43514,13 @@ async function observeClient(url, expr, i, label2, settleMs, holdMs, waitForSele
43476
43514
  waitMs: settleMs,
43477
43515
  waitForSelector: waitForSelector || void 0,
43478
43516
  waitForTimeoutMs: waitForSelector ? 5e3 : void 0,
43517
+ // The shared-start wait runs inside the script, so the script needs room for it.
43518
+ timeoutMs: barrier ? JOIN_ALLOWANCE_MS + holdMs + 1e4 : void 0,
43479
43519
  // Timed from the start of the observe window; the server restores
43480
43520
  // anything still applied at the end of the hold so the harness finishes.
43481
43521
  lifecycle: lifecycle?.length ? { steps: lifecycle, untilMs: holdMs } : void 0
43482
43522
  });
43483
- const d = await pollEvalResult(kickoff.data.evalJobId, settleMs + holdMs);
43523
+ const d = await pollEvalResult(kickoff.data.evalJobId, settleMs + holdMs + (barrier ? JOIN_ALLOWANCE_MS : 0));
43484
43524
  const raw = d.result?.trim() ?? "";
43485
43525
  if (raw.startsWith("EvalError:") || raw.startsWith("ObserveError:")) {
43486
43526
  return { ...base, error: raw };
@@ -43560,6 +43600,8 @@ async function runInteractive(url, observe, opts) {
43560
43600
  console.log(muted(`${clients} client(s), stagger ${stagger}s, hold ${hold}ms, ${samples} samples each`));
43561
43601
  if (atSpecs.length) console.log(muted(`lifecycle (ms into each client's hold): ${atSpecs.map((s) => s.trim()).join(", ")}`));
43562
43602
  }
43603
+ const barrier = clients > 1 && atSpecs.length === 0;
43604
+ const t0 = Date.now();
43563
43605
  const runs = [];
43564
43606
  for (let i = 0; i < clients; i++) {
43565
43607
  runs.push((async () => {
@@ -43571,9 +43613,10 @@ async function runInteractive(url, observe, opts) {
43571
43613
  subst(observe, labelFor2(i), i),
43572
43614
  labelFor2(i),
43573
43615
  hold,
43574
- samples
43616
+ samples,
43617
+ barrier ? t0 + i * stagger * 1e3 + JOIN_ALLOWANCE_MS : void 0
43575
43618
  );
43576
- return observeClient(clientUrl, expr, i, labelFor2(i), settle, hold, opts.waitFor, lifecycle[i]);
43619
+ return observeClient(clientUrl, expr, i, labelFor2(i), settle, hold, opts.waitFor, lifecycle[i], barrier);
43577
43620
  })());
43578
43621
  }
43579
43622
  const results = (await Promise.all(runs)).sort((a, b7) => a.i - b7.i);
@@ -43622,7 +43665,7 @@ ${warning(observeHint)}`);
43622
43665
  "\u26A0 clients did NOT overlap in time: each ran in isolation, so any shared-state reading here is a FALSE NEGATIVE, not proof the app is broken."
43623
43666
  ));
43624
43667
  console.log(muted(
43625
- " Likely causes: --stagger \u2265 --hold, or more --clients than free browser slots (they queued). Lower --stagger / raise --hold / fewer --clients and retry."
43668
+ ` Each client waits up to ${JOIN_ALLOWANCE_MS / 1e3}s after launch for the others to load, then holds. Likely causes: --stagger \u2265 --hold, or a client queued for a browser (more --clients than free slots). Lower --stagger / raise --hold / fewer --clients and retry.`
43626
43669
  ));
43627
43670
  }
43628
43671
  if (errored.length > 0 || clients > 1 && !overlapped) process.exitCode = 1;
@@ -44890,6 +44933,7 @@ emailCommand.command("log").description("Recent email() sends and skipped attemp
44890
44933
  const subj = r.detail?.subject ? ` \xB7 ${r.detail.subject}` : "";
44891
44934
  const status = r.detail?.status ? ` [skipped: ${r.detail.status}]` : "";
44892
44935
  console.log(` ${muted(when)} ${to2}${status ? warning(status) : ""}${muted(subj)}`);
44936
+ if (r.detail?.reason) console.log(` ${muted(r.detail.reason)}`);
44893
44937
  }
44894
44938
  }));
44895
44939
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gipity",
3
- "version": "1.1.30",
3
+ "version": "1.1.32",
4
4
  "description": "The full-stack platform tuned for AI agents. Database, storage, auth, functions, deploy, and drop-in kits - all agent-tuned. Pair with Claude Code or use standalone.",
5
5
  "bin": {
6
6
  "gipity": "dist/updater/shim.js",