@lotics/cli 0.176.0 → 0.178.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -43,7 +43,7 @@ workspace, deploys the app, and prints a one-time sign-in link:
43
43
 
44
44
  ```bash
45
45
  curl -fsSL https://lotics.ai/install.sh | bash
46
- lotics start <starter_id> --email you@company.com
46
+ lotics setup <starter_id> --email you@company.com
47
47
  ```
48
48
 
49
49
  The installer downloads one compiled executable — no Node.js, no npm. Copying a starter is the
@@ -51,7 +51,7 @@ one step that needs more: it builds the app locally, and building needs Node 18+
51
51
 
52
52
  Add `--json` for one machine-readable object instead of progress — the organization, the
53
53
  workspace, the app id, what was created, the sign-in link, and any warnings. Already signed in?
54
- Drop `--email` and `lotics start <starter_id>` copies into the account you have.
54
+ Drop `--email` and `lotics setup <starter_id>` copies into the account you have.
55
55
 
56
56
  ## Install
57
57
 
package/dist/src/cli.js CHANGED
@@ -44183,6 +44183,7 @@ function transportErrorMessage(status, parsed) {
44183
44183
  }
44184
44184
 
44185
44185
  // src/client.ts
44186
+ import crypto from "node:crypto";
44186
44187
  import fs2 from "node:fs";
44187
44188
  import path2 from "node:path";
44188
44189
 
@@ -44321,6 +44322,9 @@ async function fetchOfficialStarters() {
44321
44322
  return await response.json();
44322
44323
  }
44323
44324
  var SHELF_FETCH_TIMEOUT_MS = 1e4;
44325
+ function newRequestId() {
44326
+ return crypto.randomUUID().replace(/-/g, "").slice(0, 12);
44327
+ }
44324
44328
  var LoticsClient = class {
44325
44329
  apiKey;
44326
44330
  workspaceId;
@@ -44337,7 +44341,18 @@ var LoticsClient = class {
44337
44341
  this.viewAsMemberId = options.viewAsMemberId;
44338
44342
  this.baseUrl = API_BASE_URL;
44339
44343
  }
44340
- async throwResponseError(response) {
44344
+ /**
44345
+ * The id is appended to the MESSAGE rather than carried on a field, because
44346
+ * the only thing that reliably reaches a person is what got printed: the CLI's
44347
+ * top-level handler writes `error.message` to stderr, and the telemetry tail
44348
+ * captures the same bytes. A field would have to be read by every one of ~60
44349
+ * exit sites to be worth anything.
44350
+ *
44351
+ * `requestId` is optional because one caller legitimately has none — a
44352
+ * presigned CDN download is not a request of ours and appears in none of our
44353
+ * logs. Every call against the API passes the id its own headers carry.
44354
+ */
44355
+ async throwResponseError(response, requestId) {
44341
44356
  const text = await response.text();
44342
44357
  let message2;
44343
44358
  try {
@@ -44346,15 +44361,23 @@ var LoticsClient = class {
44346
44361
  } catch {
44347
44362
  message2 = text;
44348
44363
  }
44349
- throw new Error(`${response.status}: ${message2}`);
44364
+ const trace = requestId === void 0 ? "" : `
44365
+
44366
+ Request id: ${requestId} \u2014 quote this to Lotics support.`;
44367
+ throw new Error(`${response.status}: ${message2}${trace}`);
44350
44368
  }
44351
44369
  /**
44352
- * The backend's `log()` middleware registers `user-agent` and
44353
- * `x-posthog-session-id` onto the per-request Logger, so they ride EVERY log
44354
- * line that request emits — the validation 400, the tool error, the timing.
44355
- * Sending them is therefore the whole of the correlation work: it turns an
44356
- * anonymous API-key request into "`app workflow set`, from cli 0.117.0, the
44357
- * fourth command of this session".
44370
+ * The backend's `log()` middleware registers `user-agent`,
44371
+ * `x-posthog-session-id` and `x-request-id` onto the per-request Logger, so
44372
+ * they ride EVERY log line that request emits — the validation 400, the tool
44373
+ * error, the timing. Sending them is therefore the whole of the correlation
44374
+ * work: it turns an anonymous API-key request into "`app workflow set`, from
44375
+ * cli 0.117.0, the fourth command of this session".
44376
+ *
44377
+ * The request id is minted HERE, with the other headers, so it cannot reach
44378
+ * some paths and not others: several commands build their own transport around
44379
+ * these headers, and an id threaded only through `request` would leave
44380
+ * `app deploy`, `uploadFiles` and every workflow call unfindable.
44358
44381
  */
44359
44382
  buildHeaders() {
44360
44383
  const invocation2 = getInvocation();
@@ -44376,6 +44399,7 @@ var LoticsClient = class {
44376
44399
  headers["x-posthog-session-id"] = invocation2.session;
44377
44400
  }
44378
44401
  }
44402
+ headers["x-request-id"] = newRequestId();
44379
44403
  return headers;
44380
44404
  }
44381
44405
  async request(method, path13, body) {
@@ -44387,7 +44411,7 @@ var LoticsClient = class {
44387
44411
  init.body = JSON.stringify(body);
44388
44412
  }
44389
44413
  const response = await fetch(url2, init);
44390
- if (!response.ok) await this.throwResponseError(response);
44414
+ if (!response.ok) await this.throwResponseError(response, headers["x-request-id"]);
44391
44415
  return response.json();
44392
44416
  }
44393
44417
  async whoami() {
@@ -44438,13 +44462,14 @@ var LoticsClient = class {
44438
44462
  const timeout = setTimeout(() => controller.abort(), options.timeoutMs);
44439
44463
  try {
44440
44464
  const url2 = `${this.baseUrl}/v1/tools/execute`;
44465
+ const headers = { ...this.buildHeaders(), "Content-Type": "application/json" };
44441
44466
  const response = await fetch(url2, {
44442
44467
  method: "POST",
44443
- headers: { ...this.buildHeaders(), "Content-Type": "application/json" },
44468
+ headers,
44444
44469
  body: JSON.stringify(body),
44445
44470
  signal: controller.signal
44446
44471
  });
44447
- if (!response.ok) await this.throwResponseError(response);
44472
+ if (!response.ok) await this.throwResponseError(response, headers["x-request-id"]);
44448
44473
  return response.json();
44449
44474
  } catch (error52) {
44450
44475
  if (error52 instanceof Error && error52.name === "AbortError") {
@@ -44862,16 +44887,12 @@ var LoticsClient = class {
44862
44887
  * iframe. Mirrors POST /v1/apps/{app_id}/agents/{alias}/runs.
44863
44888
  */
44864
44889
  async appAgentRunStream(app_id, alias, body, signal) {
44890
+ const headers = { ...this.buildHeaders(), "Content-Type": "application/json" };
44865
44891
  const res = await fetch(
44866
44892
  `${this.baseUrl}/v1/apps/${encodeURIComponent(app_id)}/agents/${encodeURIComponent(alias)}/runs`,
44867
- {
44868
- method: "POST",
44869
- headers: { ...this.buildHeaders(), "Content-Type": "application/json" },
44870
- body: JSON.stringify(body),
44871
- signal
44872
- }
44893
+ { method: "POST", headers, body: JSON.stringify(body), signal }
44873
44894
  );
44874
- if (!res.ok) await this.throwResponseError(res);
44895
+ if (!res.ok) await this.throwResponseError(res, headers["x-request-id"]);
44875
44896
  return res;
44876
44897
  }
44877
44898
  /**
@@ -44881,16 +44902,12 @@ var LoticsClient = class {
44881
44902
  * POST /v1/apps/{app_id}/agent-runs/{run_id}/continue.
44882
44903
  */
44883
44904
  async appAgentRunContinueStream(app_id, run_id, body, signal) {
44905
+ const headers = { ...this.buildHeaders(), "Content-Type": "application/json" };
44884
44906
  const res = await fetch(
44885
44907
  `${this.baseUrl}/v1/apps/${encodeURIComponent(app_id)}/agent-runs/${encodeURIComponent(run_id)}/continue`,
44886
- {
44887
- method: "POST",
44888
- headers: { ...this.buildHeaders(), "Content-Type": "application/json" },
44889
- body: JSON.stringify(body),
44890
- signal
44891
- }
44908
+ { method: "POST", headers, body: JSON.stringify(body), signal }
44892
44909
  );
44893
- if (!res.ok) await this.throwResponseError(res);
44910
+ if (!res.ok) await this.throwResponseError(res, headers["x-request-id"]);
44894
44911
  return res;
44895
44912
  }
44896
44913
  /**
@@ -45009,12 +45026,8 @@ var LoticsClient = class {
45009
45026
  formData.append("agent_aliases", JSON.stringify(args.agent_aliases ?? []));
45010
45027
  formData.append("query_aliases", JSON.stringify(args.query_aliases ?? []));
45011
45028
  const url2 = `${this.baseUrl}/v1/apps/${encodeURIComponent(args.app_id)}/versions`;
45012
- const response = await fetch(url2, {
45013
- method: "POST",
45014
- headers: this.buildHeaders(),
45015
- // no Content-Type — fetch sets multipart boundary
45016
- body: formData
45017
- });
45029
+ const headers = this.buildHeaders();
45030
+ const response = await fetch(url2, { method: "POST", headers, body: formData });
45018
45031
  if (response.status === 409) {
45019
45032
  const conflict = await response.json();
45020
45033
  const err2 = new Error(conflict.message ?? "Deploy conflict \u2014 pull required");
@@ -45023,7 +45036,7 @@ var LoticsClient = class {
45023
45036
  throw err2;
45024
45037
  }
45025
45038
  if (!response.ok) {
45026
- await this.throwResponseError(response);
45039
+ await this.throwResponseError(response, headers["x-request-id"]);
45027
45040
  }
45028
45041
  return response.json();
45029
45042
  }
@@ -45039,11 +45052,14 @@ var LoticsClient = class {
45039
45052
  return absolutePath;
45040
45053
  }
45041
45054
  async downloadFileById(fileId, outputDir, options) {
45055
+ const signedHeaders = this.buildHeaders();
45042
45056
  const signedUrlRes = await fetch(
45043
45057
  `${this.baseUrl}/v1/files/${encodeURIComponent(fileId)}/signed_url`,
45044
- { headers: this.buildHeaders() }
45058
+ { headers: signedHeaders }
45045
45059
  );
45046
- if (!signedUrlRes.ok) await this.throwResponseError(signedUrlRes);
45060
+ if (!signedUrlRes.ok) {
45061
+ await this.throwResponseError(signedUrlRes, signedHeaders["x-request-id"]);
45062
+ }
45047
45063
  const { url: url2 } = await signedUrlRes.json();
45048
45064
  const response = await fetch(url2);
45049
45065
  if (!response.ok) await this.throwResponseError(response);
@@ -45103,12 +45119,9 @@ var LoticsClient = class {
45103
45119
  formData.append("file", new Blob([item.bytes], { type: mimeType }), item.filename);
45104
45120
  }
45105
45121
  const url2 = `${this.baseUrl}/v1/files`;
45106
- const response = await fetch(url2, {
45107
- method: "POST",
45108
- headers: this.buildHeaders(),
45109
- body: formData
45110
- });
45111
- if (!response.ok) await this.throwResponseError(response);
45122
+ const headers = this.buildHeaders();
45123
+ const response = await fetch(url2, { method: "POST", headers, body: formData });
45124
+ if (!response.ok) await this.throwResponseError(response, headers["x-request-id"]);
45112
45125
  return response.json();
45113
45126
  }
45114
45127
  };
@@ -45200,7 +45213,7 @@ async function resolveUploadSource(sourceFlag, flags) {
45200
45213
  }
45201
45214
 
45202
45215
  // src/telemetry.ts
45203
- import crypto from "node:crypto";
45216
+ import crypto2 from "node:crypto";
45204
45217
  import fs3 from "node:fs";
45205
45218
  import os2 from "node:os";
45206
45219
  import path3 from "node:path";
@@ -45276,7 +45289,7 @@ function buildEvent(exitCode, durationMs, now) {
45276
45289
  if (invocation2 === null || invocation2.session === null) return null;
45277
45290
  const message2 = exitCode === 0 ? "" : stripNarration(stderrTail);
45278
45291
  return {
45279
- event_id: crypto.randomUUID(),
45292
+ event_id: crypto2.randomUUID(),
45280
45293
  ts: now.toISOString(),
45281
45294
  cli_session_id: invocation2.session,
45282
45295
  cli_command: invocation2.command,
@@ -45343,8 +45356,8 @@ function flushSpool(post, minEvents = 5) {
45343
45356
  const batch = events.slice(0, MAX_FLUSH_EVENTS);
45344
45357
  const sent = `${lines.slice(0, batch.length).join("\n")}
45345
45358
  `;
45346
- void post(batch).then(() => {
45347
- clearSpool(sent);
45359
+ void post(batch).then((outcome) => {
45360
+ if (outcome !== "retry") clearSpool(sent);
45348
45361
  }).catch(() => {
45349
45362
  });
45350
45363
  }
@@ -45358,7 +45371,9 @@ async function postEvents(baseUrl, apiKey, events, timeoutMs = 5e3) {
45358
45371
  body: JSON.stringify({ events }),
45359
45372
  signal: controller.signal
45360
45373
  });
45361
- if (!res.ok) throw new Error(`telemetry flush: ${res.status}`);
45374
+ if (res.ok) return "delivered";
45375
+ const permanent = res.status >= 400 && res.status < 500 && res.status !== 408 && res.status !== 429;
45376
+ return permanent ? "rejected" : "retry";
45362
45377
  } finally {
45363
45378
  clearTimeout(timer2);
45364
45379
  }
@@ -45696,7 +45711,7 @@ function resultSideEffects(result) {
45696
45711
  }
45697
45712
 
45698
45713
  // src/version.ts
45699
- var VERSION = "0.176.0";
45714
+ var VERSION = "0.178.0";
45700
45715
 
45701
45716
  // src/timezone.ts
45702
45717
  function machineTimezone() {
@@ -45864,9 +45879,9 @@ function docsCommand(args) {
45864
45879
  // src/commands.ts
45865
45880
  var COMMANDS = [
45866
45881
  {
45867
- verbs: ["start"],
45882
+ verbs: ["setup"],
45868
45883
  help: [
45869
- " lotics start <starter_id> [path] --email <you@co.com>",
45884
+ " lotics setup <starter_id> [path] --email <you@co.com>",
45870
45885
  " First run, one command: create an account if this",
45871
45886
  " machine has none, then copy the starter into its",
45872
45887
  " workspace \u2014 schema, templates, knowledge docs,",
@@ -48192,6 +48207,22 @@ ${inputLines.join("\n")}
48192
48207
  }
48193
48208
  `;
48194
48209
  }
48210
+ var LINK_TSCONFIG_PATH = ".lotics/tsconfig.link.json";
48211
+ function generateLinkTsconfig(paths) {
48212
+ const header = Object.keys(paths).length > 0 ? `// GENERATED by \`lotics app codegen\` \u2014 do not edit.
48213
+ // LOTICS_UI_SRC is set, so @lotics/ui resolves to your working copy for tsc,
48214
+ // vitest, eslint and your editor \u2014 the same copy Vite is bundling. The peer
48215
+ // pins keep ONE react / react-native in the program; without them the kit's
48216
+ // source resolves its own copies and every shared type stops matching.
48217
+ // Unset LOTICS_UI_SRC and re-run to go back to the published kit.
48218
+ ` : `// GENERATED by \`lotics app codegen\` \u2014 do not edit.
48219
+ // @lotics/ui resolves from node_modules as normal, so this is inert. It still
48220
+ // has to exist: tsconfig.json extends it, and a missing extends target fails
48221
+ // the build outright.
48222
+ `;
48223
+ return `${header}${JSON.stringify({ compilerOptions: { paths } }, null, 2)}
48224
+ `;
48225
+ }
48195
48226
  var CAPABILITY_GATED_CALLS = {
48196
48227
  comments: ["useComments", "createComment", "updateComment", "deleteComment"]
48197
48228
  };
@@ -71905,18 +71936,17 @@ function ensureAppTsconfig(projectDir) {
71905
71936
  }
71906
71937
  const existingExtends = parsed.extends;
71907
71938
  if (existingExtends === void 0) {
71908
- parsed.extends = `./${LINK_TSCONFIG}`;
71909
- changes.push(`added "extends": "./${LINK_TSCONFIG}" (so tsc resolves the same @lotics/ui as Vite)`);
71910
- } else if (existingExtends !== `./${LINK_TSCONFIG}`) {
71939
+ parsed.extends = `./${LINK_TSCONFIG_PATH}`;
71940
+ changes.push(`added "extends": "./${LINK_TSCONFIG_PATH}" (so tsc resolves the same @lotics/ui as Vite)`);
71941
+ } else if (existingExtends !== `./${LINK_TSCONFIG_PATH}`) {
71911
71942
  console.error(
71912
- `\u26A0 tsconfig.json already extends ${JSON.stringify(existingExtends)}, so the dev-link config was not added \u2014 \`tsc\` will keep resolving @lotics/ui from node_modules even under LOTICS_UI_SRC. Add "./${LINK_TSCONFIG}" to "extends" (it accepts an array) to fix it.`
71943
+ `\u26A0 tsconfig.json already extends ${JSON.stringify(existingExtends)}, so the dev-link config was not added \u2014 \`tsc\` will keep resolving @lotics/ui from node_modules even under LOTICS_UI_SRC. Add "./${LINK_TSCONFIG_PATH}" to "extends" (it accepts an array) to fix it.`
71913
71944
  );
71914
71945
  }
71915
71946
  if (changes.length === 0) return;
71916
71947
  fs8.writeFileSync(tsconfigPath, JSON.stringify(parsed, null, 2) + "\n");
71917
71948
  console.error(`Patched tsconfig.json: ${changes.join("; ")}.`);
71918
71949
  }
71919
- var LINK_TSCONFIG = ".lotics/tsconfig.link.json";
71920
71950
  function writeDevLinkTsconfig(projectDir) {
71921
71951
  const uiSrc = process.env.LOTICS_UI_SRC;
71922
71952
  const paths = {};
@@ -71931,19 +71961,8 @@ function writeDevLinkTsconfig(projectDir) {
71931
71961
  paths[`${peer}/*`] = [`${target}/*`];
71932
71962
  }
71933
71963
  }
71934
- const file2 = path9.join(projectDir, ".lotics", "tsconfig.link.json");
71935
- const header = uiSrc ? `// GENERATED by \`lotics app codegen\` \u2014 do not edit.
71936
- // LOTICS_UI_SRC is set, so @lotics/ui resolves to your working copy for tsc,
71937
- // vitest, eslint and your editor \u2014 the same copy Vite is bundling. The peer
71938
- // pins keep ONE react / react-native in the program; without them the kit's
71939
- // source resolves its own copies and every shared type stops matching.
71940
- // Unset LOTICS_UI_SRC and re-run to go back to the published kit.
71941
- ` : `// GENERATED by \`lotics app codegen\` \u2014 do not edit.
71942
- // LOTICS_UI_SRC is not set, so this is inert and @lotics/ui resolves from
71943
- // node_modules as normal.
71944
- `;
71945
- fs8.writeFileSync(file2, `${header}${JSON.stringify({ compilerOptions: { paths } }, null, 2)}
71946
- `);
71964
+ const file2 = path9.join(projectDir, LINK_TSCONFIG_PATH);
71965
+ fs8.writeFileSync(file2, generateLinkTsconfig(paths));
71947
71966
  return file2;
71948
71967
  }
71949
71968
  function writeKitTypeAugmentation(projectDir) {
@@ -73984,7 +74003,7 @@ async function starterListPublic() {
73984
74003
  printStarterRows(starters);
73985
74004
  console.error(
73986
74005
  `
73987
- lotics start <starter_id> --email you@company.com Copy one \u2014 creates your account too
74006
+ lotics setup <starter_id> --email you@company.com Copy one \u2014 creates your account too
73988
74007
 
73989
74008
  This machine has no Lotics account yet, so this is the published shelf.
73990
74009
  Signed in, the same command also lists what your own organization published.`
@@ -74128,6 +74147,15 @@ Building ${starter.name} \u2014 this runs its build on your machine (its package
74128
74147
  } else if (serverDeployed === null) {
74129
74148
  note(`Building and deploying\u2026`);
74130
74149
  }
74150
+ if (serverDeployed === null && result.build_error) {
74151
+ warn(
74152
+ `
74153
+ Lotics could not build ${starter.name} \u2014 building here instead.
74154
+ ${result.build_error.split("\n")[0]}
74155
+ The copy is fine: the tables, the records and the app all landed. Do NOT
74156
+ copy again, and do not write a replacement app \u2014 only the build is missing.`
74157
+ );
74158
+ }
74131
74159
  const resumeDir = path10.relative(process.cwd(), targetPath) || ".";
74132
74160
  try {
74133
74161
  if (serverDeployed !== null) {
@@ -103592,10 +103620,10 @@ async function main() {
103592
103620
  console.log(VERSION);
103593
103621
  return;
103594
103622
  }
103595
- if (command === "start") {
103623
+ if (command === "setup") {
103596
103624
  const starterId = subcommand;
103597
103625
  if (!starterId) {
103598
- console.error("Usage: lotics start <starter_id> [path] [--email <you@co.com>] [--json]");
103626
+ console.error("Usage: lotics setup <starter_id> [path] [--email <you@co.com>] [--json]");
103599
103627
  console.error(" Creates an account if this machine has none, then copies the starter");
103600
103628
  console.error(" into its workspace: schema, templates, knowledge docs, sample records");
103601
103629
  console.error(" and a deployed app. Ends with a one-time sign-in link.");
@@ -103608,7 +103636,7 @@ async function main() {
103608
103636
  const email3 = flags.email ?? (process.stdin.isTTY ? await prompt("Email: ") : "");
103609
103637
  if (!email3) {
103610
103638
  console.error(
103611
- "This machine has no Lotics credential yet, so `start` needs an email to create one:\n lotics start " + starterId + " --email you@company.com"
103639
+ "This machine has no Lotics credential yet, so `start` needs an email to create one:\n lotics setup " + starterId + " --email you@company.com"
103612
103640
  );
103613
103641
  process.exit(1);
103614
103642
  }
@@ -103627,7 +103655,7 @@ async function main() {
103627
103655
  } else if (flags.email !== void 0) {
103628
103656
  console.error(
103629
103657
  `Already authenticated (${SOURCE_LABELS[existing.source]}), so --email would create a SECOND account and copy into it.
103630
- Copy into the account you have: lotics start ${starterId}
103658
+ Copy into the account you have: lotics setup ${starterId}
103631
103659
  Or create another one first: lotics auth signup ${flags.email}`
103632
103660
  );
103633
103661
  process.exit(1);
@@ -163,12 +163,17 @@ export declare class LoticsClient {
163
163
  constructor(options: LoticsClientOptions);
164
164
  private throwResponseError;
165
165
  /**
166
- * The backend's `log()` middleware registers `user-agent` and
167
- * `x-posthog-session-id` onto the per-request Logger, so they ride EVERY log
168
- * line that request emits — the validation 400, the tool error, the timing.
169
- * Sending them is therefore the whole of the correlation work: it turns an
170
- * anonymous API-key request into "`app workflow set`, from cli 0.117.0, the
171
- * fourth command of this session".
166
+ * The backend's `log()` middleware registers `user-agent`,
167
+ * `x-posthog-session-id` and `x-request-id` onto the per-request Logger, so
168
+ * they ride EVERY log line that request emits — the validation 400, the tool
169
+ * error, the timing. Sending them is therefore the whole of the correlation
170
+ * work: it turns an anonymous API-key request into "`app workflow set`, from
171
+ * cli 0.117.0, the fourth command of this session".
172
+ *
173
+ * The request id is minted HERE, with the other headers, so it cannot reach
174
+ * some paths and not others: several commands build their own transport around
175
+ * these headers, and an id threaded only through `request` would leave
176
+ * `app deploy`, `uploadFiles` and every workflow call unfindable.
172
177
  */
173
178
  private buildHeaders;
174
179
  private request;
@@ -422,6 +427,11 @@ export declare class LoticsClient {
422
427
  version_id: string;
423
428
  version_number: number;
424
429
  } | null;
430
+ /**
431
+ * Why the server built nothing, when it was asked to and `deployed` is null.
432
+ * Absent from an older server's response for the same reason as `deployed`.
433
+ */
434
+ build_error?: string | null;
425
435
  binding: Record<string, Record<string, string>>;
426
436
  sample_record_ids: Record<string, string[]>;
427
437
  knowledge_warnings: {
@@ -1,4 +1,5 @@
1
1
  import { transportErrorMessage } from "@lotics/shared/transport_error";
2
+ import crypto from "node:crypto";
2
3
  import fs from "node:fs";
3
4
  import path from "node:path";
4
5
  import { getInvocation } from "./invocation.js";
@@ -115,6 +116,18 @@ export async function fetchOfficialStarters() {
115
116
  }
116
117
  /** Long enough for a slow link, short enough that a dead one still says so. */
117
118
  const SHELF_FETCH_TIMEOUT_MS = 10_000;
119
+ /**
120
+ * A short id for one request, short because a person has to read it back to us.
121
+ *
122
+ * Not `generateLocalId` from `@lotics/shared`: this file is the UNBUNDLED
123
+ * library entry, so every bare specifier it imports has to resolve from a
124
+ * package whose `dependencies` are empty. `node:crypto` is a builtin and costs
125
+ * nothing, and the server treats the header as opaque — it logs whatever
126
+ * arrives, so matching its id ALPHABET buys nothing.
127
+ */
128
+ function newRequestId() {
129
+ return crypto.randomUUID().replace(/-/g, "").slice(0, 12);
130
+ }
118
131
  export class LoticsClient {
119
132
  apiKey;
120
133
  workspaceId;
@@ -131,7 +144,18 @@ export class LoticsClient {
131
144
  this.viewAsMemberId = options.viewAsMemberId;
132
145
  this.baseUrl = API_BASE_URL;
133
146
  }
134
- async throwResponseError(response) {
147
+ /**
148
+ * The id is appended to the MESSAGE rather than carried on a field, because
149
+ * the only thing that reliably reaches a person is what got printed: the CLI's
150
+ * top-level handler writes `error.message` to stderr, and the telemetry tail
151
+ * captures the same bytes. A field would have to be read by every one of ~60
152
+ * exit sites to be worth anything.
153
+ *
154
+ * `requestId` is optional because one caller legitimately has none — a
155
+ * presigned CDN download is not a request of ours and appears in none of our
156
+ * logs. Every call against the API passes the id its own headers carry.
157
+ */
158
+ async throwResponseError(response, requestId) {
135
159
  const text = await response.text();
136
160
  let message;
137
161
  try {
@@ -141,15 +165,21 @@ export class LoticsClient {
141
165
  catch {
142
166
  message = text;
143
167
  }
144
- throw new Error(`${response.status}: ${message}`);
168
+ const trace = requestId === undefined ? "" : `\n\n Request id: ${requestId} — quote this to Lotics support.`;
169
+ throw new Error(`${response.status}: ${message}${trace}`);
145
170
  }
146
171
  /**
147
- * The backend's `log()` middleware registers `user-agent` and
148
- * `x-posthog-session-id` onto the per-request Logger, so they ride EVERY log
149
- * line that request emits — the validation 400, the tool error, the timing.
150
- * Sending them is therefore the whole of the correlation work: it turns an
151
- * anonymous API-key request into "`app workflow set`, from cli 0.117.0, the
152
- * fourth command of this session".
172
+ * The backend's `log()` middleware registers `user-agent`,
173
+ * `x-posthog-session-id` and `x-request-id` onto the per-request Logger, so
174
+ * they ride EVERY log line that request emits — the validation 400, the tool
175
+ * error, the timing. Sending them is therefore the whole of the correlation
176
+ * work: it turns an anonymous API-key request into "`app workflow set`, from
177
+ * cli 0.117.0, the fourth command of this session".
178
+ *
179
+ * The request id is minted HERE, with the other headers, so it cannot reach
180
+ * some paths and not others: several commands build their own transport around
181
+ * these headers, and an id threaded only through `request` would leave
182
+ * `app deploy`, `uploadFiles` and every workflow call unfindable.
153
183
  */
154
184
  buildHeaders() {
155
185
  const invocation = getInvocation();
@@ -171,6 +201,9 @@ export class LoticsClient {
171
201
  headers["x-posthog-session-id"] = invocation.session;
172
202
  }
173
203
  }
204
+ // Unconditional, unlike the session header: this describes the request
205
+ // rather than tracking anyone, and it is what makes a failure findable.
206
+ headers["x-request-id"] = newRequestId();
174
207
  return headers;
175
208
  }
176
209
  async request(method, path, body) {
@@ -183,7 +216,7 @@ export class LoticsClient {
183
216
  }
184
217
  const response = await fetch(url, init);
185
218
  if (!response.ok)
186
- await this.throwResponseError(response);
219
+ await this.throwResponseError(response, headers["x-request-id"]);
187
220
  return response.json();
188
221
  }
189
222
  async whoami() {
@@ -234,14 +267,15 @@ export class LoticsClient {
234
267
  const timeout = setTimeout(() => controller.abort(), options.timeoutMs);
235
268
  try {
236
269
  const url = `${this.baseUrl}/v1/tools/execute`;
270
+ const headers = { ...this.buildHeaders(), "Content-Type": "application/json" };
237
271
  const response = await fetch(url, {
238
272
  method: "POST",
239
- headers: { ...this.buildHeaders(), "Content-Type": "application/json" },
273
+ headers,
240
274
  body: JSON.stringify(body),
241
275
  signal: controller.signal,
242
276
  });
243
277
  if (!response.ok)
244
- await this.throwResponseError(response);
278
+ await this.throwResponseError(response, headers["x-request-id"]);
245
279
  return response.json();
246
280
  }
247
281
  catch (error) {
@@ -662,14 +696,10 @@ export class LoticsClient {
662
696
  * iframe. Mirrors POST /v1/apps/{app_id}/agents/{alias}/runs.
663
697
  */
664
698
  async appAgentRunStream(app_id, alias, body, signal) {
665
- const res = await fetch(`${this.baseUrl}/v1/apps/${encodeURIComponent(app_id)}/agents/${encodeURIComponent(alias)}/runs`, {
666
- method: "POST",
667
- headers: { ...this.buildHeaders(), "Content-Type": "application/json" },
668
- body: JSON.stringify(body),
669
- signal,
670
- });
699
+ const headers = { ...this.buildHeaders(), "Content-Type": "application/json" };
700
+ const res = await fetch(`${this.baseUrl}/v1/apps/${encodeURIComponent(app_id)}/agents/${encodeURIComponent(alias)}/runs`, { method: "POST", headers, body: JSON.stringify(body), signal });
671
701
  if (!res.ok)
672
- await this.throwResponseError(res);
702
+ await this.throwResponseError(res, headers["x-request-id"]);
673
703
  return res;
674
704
  }
675
705
  /**
@@ -679,14 +709,10 @@ export class LoticsClient {
679
709
  * POST /v1/apps/{app_id}/agent-runs/{run_id}/continue.
680
710
  */
681
711
  async appAgentRunContinueStream(app_id, run_id, body, signal) {
682
- const res = await fetch(`${this.baseUrl}/v1/apps/${encodeURIComponent(app_id)}/agent-runs/${encodeURIComponent(run_id)}/continue`, {
683
- method: "POST",
684
- headers: { ...this.buildHeaders(), "Content-Type": "application/json" },
685
- body: JSON.stringify(body),
686
- signal,
687
- });
712
+ const headers = { ...this.buildHeaders(), "Content-Type": "application/json" };
713
+ const res = await fetch(`${this.baseUrl}/v1/apps/${encodeURIComponent(app_id)}/agent-runs/${encodeURIComponent(run_id)}/continue`, { method: "POST", headers, body: JSON.stringify(body), signal });
688
714
  if (!res.ok)
689
- await this.throwResponseError(res);
715
+ await this.throwResponseError(res, headers["x-request-id"]);
690
716
  return res;
691
717
  }
692
718
  /**
@@ -775,11 +801,8 @@ export class LoticsClient {
775
801
  formData.append("agent_aliases", JSON.stringify(args.agent_aliases ?? []));
776
802
  formData.append("query_aliases", JSON.stringify(args.query_aliases ?? []));
777
803
  const url = `${this.baseUrl}/v1/apps/${encodeURIComponent(args.app_id)}/versions`;
778
- const response = await fetch(url, {
779
- method: "POST",
780
- headers: this.buildHeaders(), // no Content-Type — fetch sets multipart boundary
781
- body: formData,
782
- });
804
+ const headers = this.buildHeaders(); // no Content-Type — fetch sets multipart boundary
805
+ const response = await fetch(url, { method: "POST", headers, body: formData });
783
806
  if (response.status === 409) {
784
807
  const conflict = (await response.json());
785
808
  const err = new Error(conflict.message ?? "Deploy conflict — pull required");
@@ -789,7 +812,7 @@ export class LoticsClient {
789
812
  throw err;
790
813
  }
791
814
  if (!response.ok) {
792
- await this.throwResponseError(response);
815
+ await this.throwResponseError(response, headers["x-request-id"]);
793
816
  }
794
817
  return response.json();
795
818
  }
@@ -809,9 +832,11 @@ export class LoticsClient {
809
832
  // edge Worker that doesn't accept the API key). The signed_url endpoint
810
833
  // takes the API key and returns a short-lived, directly-fetchable URL
811
834
  // whose Content-Disposition carries the original filename.
812
- const signedUrlRes = await fetch(`${this.baseUrl}/v1/files/${encodeURIComponent(fileId)}/signed_url`, { headers: this.buildHeaders() });
813
- if (!signedUrlRes.ok)
814
- await this.throwResponseError(signedUrlRes);
835
+ const signedHeaders = this.buildHeaders();
836
+ const signedUrlRes = await fetch(`${this.baseUrl}/v1/files/${encodeURIComponent(fileId)}/signed_url`, { headers: signedHeaders });
837
+ if (!signedUrlRes.ok) {
838
+ await this.throwResponseError(signedUrlRes, signedHeaders["x-request-id"]);
839
+ }
815
840
  const { url } = (await signedUrlRes.json());
816
841
  const response = await fetch(url);
817
842
  if (!response.ok)
@@ -890,13 +915,10 @@ export class LoticsClient {
890
915
  formData.append("file", new Blob([item.bytes], { type: mimeType }), item.filename);
891
916
  }
892
917
  const url = `${this.baseUrl}/v1/files`;
893
- const response = await fetch(url, {
894
- method: "POST",
895
- headers: this.buildHeaders(),
896
- body: formData,
897
- });
918
+ const headers = this.buildHeaders();
919
+ const response = await fetch(url, { method: "POST", headers, body: formData });
898
920
  if (!response.ok)
899
- await this.throwResponseError(response);
921
+ await this.throwResponseError(response, headers["x-request-id"]);
900
922
  return response.json();
901
923
  }
902
924
  }
@@ -41,10 +41,10 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
41
41
  | `lotics app deploy [--prune] -m <message>` | `-m` is OPTIONAL — omitted, the deploy derives the version message from what it actually pushed; pass `-m` when you have a reason worth recording. npm run build; tar source + dist; POST /v1/apps/{id}/versions multipart. **One command ships everything**: before the bundle moves, a deploy pushes every binding the project has ahead of the app — an edited workflow body or declaration, edited agent prose, a changed query — through `set_app_query`, then `set_app_workflow`, then `set_app_agent`, and fails the release if any push is refused. That order is required: an agent declares the query and workflow aliases it may call, so pushing it before its own new query is refused. A workflow's `description` is part of that push and is compared against the recorded baseline, not the live app — it lives on the workflow ROW, which `getApp` does not carry. It never AUTHORS a binding itself — those verbs stay the single writers — and each push carries the fingerprint the project last saw live (`lotics.synced`), so a stale checkout is refused rather than overwriting another author's edit. `package.json` means the same thing for both artifacts: editing `lotics.agents.<alias>.inputs`/`outputs` is pushed exactly like the workflow equivalent (only those two fields — `set_app_agent` merges, so everything the manifest does not model is left untouched). It also regenerates `.lotics/app_fields.ts` before building, since the build INLINES it and a stale copy would ship ids that no longer name what the source thinks they do. `lotics app check` reports the same set without pushing; neither has a `--strict`. What the version RECORDS as the aliases it calls — the set `remove_app_workflow` / `remove_app_query` / `remove_app_agent` consult to refuse unbinding one the served version still reaches — is read by the SERVER out of the source archive this deploy uploads, not reported by the deploy. That matters because the deploy is also what unbinds: a client supplying the evidence used to refuse its own removal cannot be checked by it. After a successful deploy it warns about any alias the source CALLS that is NOT bound, and **names the inverse** — bindings the app still serves that this bundle mentions nowhere. It does NOT remove them: **`--prune` does, and only when passed.** A static scan sees the bundle's call sites and an agent's `query_aliases`/`workflow_aliases`; it cannot see `lotics run run_app_workflow`, whose whole contract is that the alias is bound server-side, or chat's call under `app:use`. An operator-driven workflow therefore leaves no call site anywhere in the source and is indistinguishable from a dead one here — so a deploy that pruned by default deleted working tooling and printed it as a ✓. Pruning runs AFTER the version is live, because the removal tools refuse an alias the SERVED version still declares — so doing it first is refused by the guard that makes it safe. `--prune` is skipped ENTIRELY (with a warning, never a failure) when the source computes an alias at run time, since the scan cannot tell which binding that reaches and pruning "the rest" would be guessing with a deletion. **A removal DELETES the local declaration too** — `package.json#lotics.<kind>.<alias>` and its `synced` baseline — because leaving it would undo the prune: the manifest is what the next plain deploy pushes FROM, so the binding came straight back. That makes the act destructive rather than merely reversible, so what it deleted is written to `.lotics/pruned/<kind>/<alias>.json` and the ✓ names that file plus the `set` verb that re-binds it, on the same line. (These trees are never committed, so git is not the fallback; `lotics app pull --from-version <apv_…>` is the only other route back.) After a successful prune the generated companions are regenerated from the narrowed manifest — the `.d.ts` set and, when a query was pruned, `.lotics/app_fields.ts`, whose table set is derived from the surviving query ASTs. A table named ONLY by the pruned query leaves `F`/`OPT`, which is reported: if your source still addresses it, add the table id to `package.json#lotics.codegen.tables`. A local write that fails at any of this reports what could not be written and which aliases were already unbound server-side; it never fails the release, which is already live. A binding that will not unbind is reported and does NOT fail the release: the version is live and correct — and the server refuses to unbind a WORKFLOW this workspace has actually run (a recorded execution means a caller the source cannot name), which surfaces here as `✗ could not unbind …` with the date it last ran. After a successful deploy it also REFRESHES the `.lotics/workflows/<alias>.globals.d.ts` of any alias whose `// lotics:declaration` stamp says this deploy moved its declaration (only those — refreshing every bound alias would cost one round trip each on every deploy to fix something only ever wrong right after a manifest edit), from the manifest declaration, re-wrapping the SAME on-disk body (never re-fetching it, so local edits survive). A deploy is the moment the manifest becomes real, so it is also the moment the local types stop matching it — and the author's next act is usually `workflow set`, whose body would otherwise be typechecked against the declaration as it stood before this deploy. Non-fatal: the release already shipped, and stale types never fail it. |
42
42
  | `lotics app versions [app_id]` | `GET /v1/apps/{id}/versions` — print deploy history newest-first (version number, timestamp, deployer name, build status, the `-m` message; `*` marks the currently-served version). app_id from the local manifest, or pass one to inspect any app without pulling it. Admin-only server-side (mirrors deploy + source download). Answers "what shipped, when, by whom" — e.g. whether a fix was live at an incident's time. Title → stderr, table → stdout (pipeable). |
43
43
  | `lotics app codegen [path]` | Regenerate `.lotics/*` from the manifest + workspace schema **without a deploy**. The three `.d.ts` companions (`app_{workflows,queries,agents}.d.ts`) are always rewritten (synchronous, no network). When credentials resolve, also rewrites the **runtime** `.lotics/app_fields.ts` — a real `.ts` exporting `F` (table→field→`"fld_…"`) + `OPT` (table→select-field→option→`"opt_…"`) keyed by display-name aliases, for the tables the app's queries reference (+ optional `package.json#lotics.codegen.tables` allowlist). **There is one form, and that is what makes a starter's source portable**: the keys are slugified DISPLAY NAMES and a starter carries its labels verbatim, so running codegen in a copy's own workspace emits the same keys pointing at that workspace's ids — no binding fetched at load, no prebuilt bundle to keep in step. Also refreshes each bound workflow's `.lotics/workflows/<alias>.globals.d.ts` + re-wraps its EXISTING `src/workflows/<alias>.ts` body in the current envelope (strips + re-wraps; never re-fetches the body, so local edits survive). **`.lotics/` is reconciled to the manifest, not merely added to** — a `<alias>.globals.d.ts` whose alias the manifest no longer declares is DELETED. Only that exact filename shape is removed; anything else in the directory is left alone. The reconcile runs before the credential branch, so it happens offline too. The authored counterpart is never deleted — a `src/workflows/<alias>.ts` the manifest does not declare is NAMED instead (`check` and `set` both take their alias set from the manifest, so editing an undeclared body is a silent no-op). A getApp / binding / schema / dts-fetch failure is non-fatal (warns, keeps the last-generated files). **Re-silvers `package.json#lotics.agents`** from the live app row whenever its `inputs`/`outputs` disagree, then rewrites the agent `.d.ts` from the refreshed block: that block is a mirror AND the offline seed for `useAgentRun` typings, so a stale copy types the app against an agent that does not exist. The write is surgical and order-preserving, so it changes only the fields that actually differ. A hand edit to that block is therefore reverted — it never changed the agent anyway; to change one, `set_app_agent`. |
44
- | `lotics start <starter_id> [path] [--email <addr>] [--json]` | **The whole first run, in one command.** Creates an account when this machine has no credential (the same call `auth signup` makes — `--name` and `--timezone` apply), then does exactly what `starter init` does, then prints the one-time sign-in link. It exists because the two-command form has a seam where the FIRST command exists only to produce a credential for the second, and a caller pasting a prompt has to get both right. **`--email` is only for creating an account**: with a credential already resolvable it is REFUSED rather than obeyed, because the two can name different organizations and preferring either one silently copies a starter into an org the caller did not name — the message says how to do each thing on purpose. Without it, `start` copies into the account you already have and is a pure alias for `starter init`. **`--json` prints one object on stdout and nothing else** — `organization_id`, `workspace_id`, `app_id`, `project_dir`, `signin_url`, and `created` — which NAMES what landed (`tables`, `templates` and `knowledge_docs` are alias arrays; `sample_records` is a row count, since rows are not named things). Aliases rather than counts because the next question is about a particular artifact: a copied template carries the publisher's wording and a copied knowledge doc describes how they work, so "which of these should be mine?" is the conversation a copy starts, and a count cannot begin it. Plus a `warnings` array carrying everything the prose form would have said out of band — an unbindable knowledge doc, a sign-in link that could not be minted, and the notice naming whose build is about to run on this machine. A warning is never merely silenced: when the command fails with an error before it can emit, the ones it had collected go to stderr alongside it. npm's and vite's own output is captured under `--json` and surfaced only if the build FAILS, where it rides out in the error. Reachable with no install: `npx -y @lotics/cli start …`. |
44
+ | `lotics setup <starter_id> [path] [--email <addr>] [--json]` | **The whole first run, in one command.** Creates an account when this machine has no credential (the same call `auth signup` makes — `--name` and `--timezone` apply), then does exactly what `starter init` does, then prints the one-time sign-in link. It exists because the two-command form has a seam where the FIRST command exists only to produce a credential for the second, and a caller pasting a prompt has to get both right. **`--email` is only for creating an account**: with a credential already resolvable it is REFUSED rather than obeyed, because the two can name different organizations and preferring either one silently copies a starter into an org the caller did not name — the message says how to do each thing on purpose. Without it, `setup` copies into the account you already have and is a pure alias for `starter init`. **`--json` prints one object on stdout and nothing else** — `organization_id`, `workspace_id`, `app_id`, `project_dir`, `signin_url`, and `created` — which NAMES what landed (`tables`, `templates` and `knowledge_docs` are alias arrays; `sample_records` is a row count, since rows are not named things). Aliases rather than counts because the next question is about a particular artifact: a copied template carries the publisher's wording and a copied knowledge doc describes how they work, so "which of these should be mine?" is the conversation a copy starts, and a count cannot begin it. Plus a `warnings` array carrying everything the prose form would have said out of band — an unbindable knowledge doc, a sign-in link that could not be minted, and the notice naming whose build is about to run on this machine. A warning is never merely silenced: when the command fails with an error before it can emit, the ones it had collected go to stderr alongside it. npm's and vite's own output is captured under `--json` and surfaced only if the build FAILS, where it rides out in the error. Reachable with no install: `npx -y @lotics/cli start …`. |
45
45
  | `lotics starter list` | **Works with no account**, and that is the point: whether to copy a starter or build from scratch is decided before one exists, so requiring a key would mean signing up to learn the answer was no. Unauthenticated it lists what Lotics publishes (`GET /v1/starters/official`, public). Authenticated it is the org shelf — The starters this organization can copy — Lotics-reviewed ones plus its own, each with at least one released version. Deliberately NOT a catalogue of everything published: the server returns exactly what a copy would be allowed to take, so the list can never offer something that then refuses. Admin-only. |
46
46
  | `lotics starter show <starter_id>` | One starter's name, description, current version and trust standing (`official` — reviewed by Lotics; `your organization's own`). Read it before copying a starter you did not publish. |
47
- | `lotics starter init <starter_id> [path]` | **Copy a starter into this workspace.** Server-side it scaffolds the tables and fields, creates the document templates and knowledge docs, inserts the sample records, creates a BESPOKE app and materializes its queries, workflows and agents onto it. Then it stops: a starter ships **source only**, with no prebuilt bundle, so the app source is downloaded here, hydrated against the live app (the same steps `app pull` runs), built, and deployed — which is why this needs node and a few minutes, and why the app is not servable until the deploy lands. **What you get is yours outright**: an ordinary app plus ordinary tables, with no link back to the starter, nothing pinned, and nothing to upgrade. Edit any of it. **It builds the publisher's code on your machine** — the copy has to build where your workspace's field ids are, so `npm run build` runs their build script and vite loads their `vite.config.ts` in Node, as you. Dependencies install with `npm ci --ignore-scripts` — the lockfile's exact tree (so a starter published months ago resolves the same packages today), and no lifecycle scripts (the path that fires before you run anything). Neither changes the build itself. That is why provenance is the gate: **copyable only if the starter is Lotics-reviewed or your own organization published it** — copying runs the author's code (its bundle, its workflows, its agents) under YOUR authority, so provenance is the gate, enforced server-side. **Refuses a workspace that already has tables** unless `--adopt`: scaffold matches an entity by DISPLAY NAME, so a starter declaring `Contacts` would bind to yours. `--json` prints one object on stdout instead of progress (the shape is under `lotics start`) and captures npm/vite output unless the build fails. `--no-sample-data` skips the sample records; with them, the created record ids are reported — they are ordinary records, delete them whenever. Resolves and ANNOUNCES its workspace first (`lotics → <org> / <workspace>` on stderr). Admin-only. Authoring the registry (`starter publish/release/unpublish`) stays operator-only. |
47
+ | `lotics starter init <starter_id> [path]` | **Copy a starter into this workspace.** Server-side it scaffolds the tables and fields, creates the document templates and knowledge docs, inserts the sample records, creates a BESPOKE app and materializes its queries, workflows and agents onto it. Then it stops: a starter ships **source only**, with no prebuilt bundle, so the app source is downloaded here, hydrated against the live app (the same steps `app pull` runs), built, and deployed — which is why this needs node and a few minutes, and why the app is not servable until the deploy lands. **What you get is yours outright**: an ordinary app plus ordinary tables, with no link back to the starter, nothing pinned, and nothing to upgrade. Edit any of it. **It builds the publisher's code on your machine** — the copy has to build where your workspace's field ids are, so `npm run build` runs their build script and vite loads their `vite.config.ts` in Node, as you. Dependencies install with `npm ci --ignore-scripts` — the lockfile's exact tree (so a starter published months ago resolves the same packages today), and no lifecycle scripts (the path that fires before you run anything). Neither changes the build itself. That is why provenance is the gate: **copyable only if the starter is Lotics-reviewed or your own organization published it** — copying runs the author's code (its bundle, its workflows, its agents) under YOUR authority, so provenance is the gate, enforced server-side. **Refuses a workspace that already has tables** unless `--adopt`: scaffold matches an entity by DISPLAY NAME, so a starter declaring `Contacts` would bind to yours. `--json` prints one object on stdout instead of progress (the shape is under `lotics setup`) and captures npm/vite output unless the build fails. `--no-sample-data` skips the sample records; with them, the created record ids are reported — they are ordinary records, delete them whenever. Resolves and ANNOUNCES its workspace first (`lotics → <org> / <workspace>` on stderr). Admin-only. Authoring the registry (`starter publish/release/unpublish`) stays operator-only. |
48
48
  | `lotics starter fixtures capture [--entity <alias> ...] [--limit <n>]` | **(authoring)** Write this app's live records into the project as `fixtures/<entity-alias>.json` — the sample data a starter carries, so a copy lands with something in it. Run from an app project; the app id comes from its manifest. The alias-keyed shape is produced server-side, because the aliases are minted when the starter is extracted and exist nowhere a project can read them. `--entity` is repeatable and comma-separated; omitted, every table the app declares is captured. **Capture a linked set in ONE call** — a link between two rows only resolves within a single capture, so taking companies and contacts separately drops the edge between them (it says so when it happens). `--limit` bounds rows per table (default 10, max 200). **READ WHAT IT WROTE before committing**: these rows are created verbatim in every workspace that copies the starter, so a real customer name, price or address captured here is published. Files, formulas, rollups, lookups and autonumbers are never captured — the platform writes those. Admin-only; writes nothing to the workspace. |
49
49
  | `lotics upgrade` | Update this CLI in place. Runs the same installer a person would, chosen by how THIS copy arrived: an npm install upgrades through npm, a script install re-runs the script — the runtime knows which (the executable is compiled, the npm bin runs under node), so nobody has to. It downloads nothing itself; resolving a version, verifying the checksum and replacing a running executable already exist in the installers, and a second copy of that inside the binary would be a second thing to get right. Replacing the binary while it runs is safe — a rename leaves the running image mapped on unix, and on Windows the installer moves the old aside precisely because the file is in use. Already current is a no-op that says so. Needs no auth. |
50
50
  | `lotics docs` \| `lotics docs <area>` | The index of the reference docs, **resolved out of the packages installed beside this project** — never carried by this CLI. **Both levels are discovered by looking**: every `@lotics/*` package carrying an `AGENTS.md` or a `docs/` in any `node_modules/@lotics` from the current directory UPWARD (nearest wins, so a hoisted root copy never shadows the one a project's own imports resolve to), and within each, every area it actually ships. Titles come from each file's own `# heading` and the version from the installed `package.json`, so a doc OR a whole package added upstream appears with no change to this CLI, and a skewed install is visible rather than reassuring. A package's index is named after the package (`lotics docs ui`), never `index`. `@lotics/app-sdk`, `@lotics/ui` and `@lotics/cli` sort first as a reading ORDER, not a filter. Both the index and `<area>` print to **stdout** — the index is the payload of a bare `lotics docs`, so `lotics docs | grep -i excel` works — with only the provenance line on stderr, so `lotics docs ai > ai.md` is the doc alone; a name two packages share is refused with both qualified forms (`lotics docs ui/templates`) rather than resolved silently. Needs no auth. Outside a project only `@lotics/cli`'s own resolve, and it says so. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/cli",
3
- "version": "0.176.0",
3
+ "version": "0.178.0",
4
4
  "description": "Lotics SDK and CLI for AI agents",
5
5
  "type": "module",
6
6
  "bin": {