gipity 1.1.31 → 1.1.33

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.
@@ -12,7 +12,9 @@
12
12
  */
13
13
  import { Command } from 'commander';
14
14
  import { get, post } from '../api.js';
15
- import { resolveProjectContext } from '../config.js';
15
+ import { resolveProjectContext, getConfigPath } from '../config.js';
16
+ import { sync } from '../sync.js';
17
+ import { createProgressReporter } from '../progress.js';
16
18
  import { bold, muted, success } from '../colors.js';
17
19
  import { run } from '../helpers/index.js';
18
20
  const ACCENT_SOURCE_LABEL = {
@@ -92,6 +94,7 @@ brandCommand
92
94
  return;
93
95
  }
94
96
  const res = await post(`/projects/${config.projectGuid}/brand`, body);
97
+ await pullWrittenFiles(res.data.files ?? [], opts);
95
98
  if (opts.json) {
96
99
  console.log(JSON.stringify(res.data));
97
100
  return;
@@ -109,12 +112,21 @@ brandCommand
109
112
  const { config } = await resolveProjectContext({ projectOverride: opts.project });
110
113
  const body = opts.fixHead ? { fix_head: true } : {};
111
114
  const res = await post(`/projects/${config.projectGuid}/brand`, body);
115
+ await pullWrittenFiles(res.data.files ?? [], opts);
112
116
  if (opts.json) {
113
117
  console.log(JSON.stringify(res.data));
114
118
  return;
115
119
  }
116
120
  reportFiles(res.data.files ?? []);
117
121
  }));
122
+ /** The server writes the regenerated assets (icons, manifest, index.html head)
123
+ * into the project. Pull them now: a local copy left stale gets edited, and
124
+ * the next deploy stops on a sync conflict. Only for the linked project in cwd. */
125
+ async function pullWrittenFiles(files, opts) {
126
+ if (!files.length || opts.project || !getConfigPath())
127
+ return;
128
+ await sync({ interactive: false, progress: opts.json ? undefined : createProgressReporter() });
129
+ }
118
130
  function reportFiles(files) {
119
131
  if (!files.length) {
120
132
  console.log(muted('\nStored (assets not regenerated - run gipity brand apply).'));
@@ -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
  }
@@ -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
@@ -405,12 +408,19 @@ GCC/Rust).
405
408
  console.error(clrError('--discard-output requires a non-empty glob (e.g. --discard-output "*.ppm")'));
406
409
  process.exit(1);
407
410
  }
408
- // Args are good - now it's worth resolving (and announcing) the project.
409
- const { config } = await resolveProjectContext();
410
411
  // A bare number is native SECONDS; an explicit suffix (90s / 1500ms / 2m) is
411
412
  // portable with `page eval --timeout` and converted to seconds here.
412
413
  const durOpt = parseDuration(opts.timeout, 's');
413
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();
414
424
  const cwd = resolveRelativeCwd();
415
425
  // A scratch path is never synced, so it can never reach the VFS the sandbox
416
426
  // mirrors from - `--input tmp/frame.png` would fail inside the container with
@@ -481,7 +491,9 @@ GCC/Rust).
481
491
  // make every later sync propose deleting them. (`noSyncOutput` is the
482
492
  // wire name for --discard-output.)
483
493
  noSyncOutput: discardOutput.length ? discardOutput : undefined,
484
- });
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 });
485
497
  const res = opts.json
486
498
  ? await doRun()
487
499
  : await withSpinner('Running in sandbox...', doRun, { done: null });
@@ -317,9 +317,44 @@ async function readStdin() {
317
317
  process.stdin.on('error', () => resolve(buf));
318
318
  });
319
319
  }
320
- async function postEntries(convGuid, entries) {
321
- if (!entries.length)
320
+ // Per-entry byte caps the ingest route enforces (platform routes/remote-sessions.ts),
321
+ // kept a little under. An entry over them 400s its whole batch, and since the
322
+ // watermark only advances on success, every later flush of the session failed
323
+ // on the same entry: one big screenshot stopped capture for the rest of the run.
324
+ const MAX_TOOL_JSON_BYTES = 190_000;
325
+ const MAX_ASSISTANT_CHARS = 480_000;
326
+ const bytesOf = (v) => {
327
+ try {
328
+ return Buffer.byteLength(JSON.stringify(v ?? null), 'utf-8');
329
+ }
330
+ catch {
331
+ return Infinity;
332
+ }
333
+ };
334
+ /** Swap a payload the server would reject for a short note saying what was
335
+ * dropped, so the rest of the transcript still lands. Exported for tests. */
336
+ export function fitEntryToCaps(e) {
337
+ const note = (n) => `[omitted from the capture: ${Math.round(n / 1024)} KB, over the size cap]`;
338
+ if (e.kind === 'tool_result') {
339
+ const n = bytesOf(e.content);
340
+ return n > MAX_TOOL_JSON_BYTES ? { ...e, content: note(n) } : e;
341
+ }
342
+ if (e.kind === 'tool_use') {
343
+ const n = bytesOf(e.tool_input);
344
+ return n > MAX_TOOL_JSON_BYTES ? { ...e, tool_input: { omitted: note(n) } } : e;
345
+ }
346
+ if (e.kind === 'assistant') {
347
+ const n = bytesOf(e.blocks);
348
+ if (e.text.length <= MAX_ASSISTANT_CHARS && n <= MAX_ASSISTANT_CHARS)
349
+ return e;
350
+ return { ...e, text: e.text.slice(0, MAX_ASSISTANT_CHARS), blocks: [{ type: 'text', text: note(n) }] };
351
+ }
352
+ return e;
353
+ }
354
+ async function postEntries(convGuid, rawEntries) {
355
+ if (!rawEntries.length)
322
356
  return true;
357
+ const entries = rawEntries.map(fitEntryToCaps);
323
358
  // Batch into server-cap-safe chunks.
324
359
  for (let i = 0; i < entries.length; i += INGEST_BATCH_MAX) {
325
360
  const slice = entries.slice(i, i + INGEST_BATCH_MAX);
package/dist/index.js CHANGED
@@ -38679,7 +38679,8 @@ function parseViewportString(s) {
38679
38679
  const height = parseInt(m[2], 10);
38680
38680
  const dpr = m[3] ? parseFloat(m[3]) : void 0;
38681
38681
  if (width < 200 || width > 3840 || height < 200 || height > 2160) {
38682
- 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}`);
38683
38684
  }
38684
38685
  return dpr ? { width, height, deviceScaleFactor: dpr } : { width, height };
38685
38686
  }
@@ -39742,6 +39743,7 @@ var CODE_OPENERS = /* @__PURE__ */ new Set([
39742
39743
  "try",
39743
39744
  "with"
39744
39745
  ]);
39746
+ var SANDBOX_MAX_TIMEOUT_S = 280;
39745
39747
  function looksLikeShellCommand(code) {
39746
39748
  if (code.includes("\n")) return false;
39747
39749
  const m = /^([A-Za-z0-9_.~/-]+)(\s|$)/.exec(code.trim());
@@ -39839,7 +39841,7 @@ function resolveRelativeCwd() {
39839
39841
  return rel2.split(/[\\/]/).filter(Boolean).join("/");
39840
39842
  }
39841
39843
  var sandboxCommand = new Command("sandbox").description("Run code in a sandbox");
39842
- 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(
39843
39845
  "--input <path>",
39844
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.",
39845
39847
  (v7, prev) => [...prev ?? [], v7]
@@ -39952,9 +39954,14 @@ GCC/Rust).
39952
39954
  console.error(error('--discard-output requires a non-empty glob (e.g. --discard-output "*.ppm")'));
39953
39955
  process.exit(1);
39954
39956
  }
39955
- const { config } = await resolveProjectContext();
39956
39957
  const durOpt = parseDuration(opts.timeout, "s");
39957
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();
39958
39965
  const cwd = resolveRelativeCwd();
39959
39966
  const scratchInputs = (opts.input ?? []).filter(
39960
39967
  (p) => shouldIgnore(p.replace(/\\/g, "/").replace(/^\.\//, ""), SCRATCH_IGNORE)
@@ -39996,7 +40003,9 @@ GCC/Rust).
39996
40003
  // make every later sync propose deleting them. (`noSyncOutput` is the
39997
40004
  // wire name for --discard-output.)
39998
40005
  noSyncOutput: discardOutput.length ? discardOutput : void 0
39999
- });
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 });
40000
40009
  const res = opts.json ? await doRun() : await withSpinner("Running in sandbox...", doRun, { done: null });
40001
40010
  const pulledLocal = !!(res.data.outputFiles?.length && getConfigPath());
40002
40011
  if (pulledLocal) {
@@ -42967,6 +42976,7 @@ brandCommand.command("set").description("Change brand fields and regenerate all
42967
42976
  return;
42968
42977
  }
42969
42978
  const res = await post(`/projects/${config.projectGuid}/brand`, body);
42979
+ await pullWrittenFiles(res.data.files ?? [], opts);
42970
42980
  if (opts.json) {
42971
42981
  console.log(JSON.stringify(res.data));
42972
42982
  return;
@@ -42978,12 +42988,17 @@ brandCommand.command("apply").description("Re-render all brand assets from the s
42978
42988
  const { config } = await resolveProjectContext({ projectOverride: opts.project });
42979
42989
  const body = opts.fixHead ? { fix_head: true } : {};
42980
42990
  const res = await post(`/projects/${config.projectGuid}/brand`, body);
42991
+ await pullWrittenFiles(res.data.files ?? [], opts);
42981
42992
  if (opts.json) {
42982
42993
  console.log(JSON.stringify(res.data));
42983
42994
  return;
42984
42995
  }
42985
42996
  reportFiles(res.data.files ?? []);
42986
42997
  }));
42998
+ async function pullWrittenFiles(files, opts) {
42999
+ if (!files.length || opts.project || !getConfigPath()) return;
43000
+ await sync({ interactive: false, progress: opts.json ? void 0 : createProgressReporter() });
43001
+ }
42987
43002
  function reportFiles(files) {
42988
43003
  if (!files.length) {
42989
43004
  console.log(muted("\nStored (assets not regenerated - run gipity brand apply)."));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gipity",
3
- "version": "1.1.31",
3
+ "version": "1.1.33",
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",