@withone/cli 1.47.1 → 1.47.3

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.
@@ -1279,7 +1279,7 @@ async function executeSubflowStep(step, context, api, permissions, allowedAction
1279
1279
  if (flowStack.includes(resolvedKey)) {
1280
1280
  throw new Error(`Circular flow detected: ${[...flowStack, resolvedKey].join(" \u2192 ")}`);
1281
1281
  }
1282
- const { loadFlowWithMeta: loadFlowWithMeta2 } = await import("./flow-runner-7YOPMXWO.js");
1282
+ const { loadFlowWithMeta: loadFlowWithMeta2 } = await import("./flow-runner-V5FALC6N.js");
1283
1283
  const { flow: subFlow, rootDir: subRootDir } = loadFlowWithMeta2(resolvedKey);
1284
1284
  const subContext = await executeFlow(
1285
1285
  subFlow,
@@ -2563,6 +2563,9 @@ function ensureDir(dir) {
2563
2563
  function generateRunId() {
2564
2564
  return crypto.randomBytes(6).toString("hex");
2565
2565
  }
2566
+ function stripStepsAlias(key, value) {
2567
+ return key === "_steps" ? void 0 : value;
2568
+ }
2566
2569
  var FlowRunner = class _FlowRunner {
2567
2570
  runId;
2568
2571
  flowKey;
@@ -2620,7 +2623,7 @@ var FlowRunner = class _FlowRunner {
2620
2623
  fs3.appendFileSync(this.logPath, JSON.stringify(entry) + "\n");
2621
2624
  }
2622
2625
  saveState() {
2623
- fs3.writeFileSync(this.statePath, JSON.stringify(this.state, null, 2));
2626
+ fs3.writeFileSync(this.statePath, JSON.stringify(this.state, stripStepsAlias, 2));
2624
2627
  }
2625
2628
  createEventHandler(externalHandler) {
2626
2629
  return (event) => {
@@ -2946,6 +2949,7 @@ export {
2946
2949
  getStepTypeDescriptor,
2947
2950
  getNestedStepsKeys,
2948
2951
  generateFlowGuide,
2952
+ stripStepsAlias,
2949
2953
  FlowRunner,
2950
2954
  resolveFlowPath,
2951
2955
  getFlowRootDir,
@@ -9,9 +9,10 @@ import {
9
9
  loadFlowWithMeta,
10
10
  resolveFlowPath,
11
11
  saveFlow,
12
+ stripStepsAlias,
12
13
  summarizeFlowInputs,
13
14
  walkSteps
14
- } from "./chunk-IFTHWFLL.js";
15
+ } from "./chunk-DMLYQFMV.js";
15
16
  import "./chunk-44CV5IMX.js";
16
17
  import "./chunk-K6MWE2ZH.js";
17
18
  export {
@@ -25,6 +26,7 @@ export {
25
26
  loadFlowWithMeta,
26
27
  resolveFlowPath,
27
28
  saveFlow,
29
+ stripStepsAlias,
28
30
  summarizeFlowInputs,
29
31
  walkSteps
30
32
  };
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ import {
30
30
  searchCachePath,
31
31
  validateActionInput,
32
32
  writeCache
33
- } from "./chunk-IFTHWFLL.js";
33
+ } from "./chunk-DMLYQFMV.js";
34
34
  import {
35
35
  memSqlCommand
36
36
  } from "./chunk-QV3Y5N5G.js";
@@ -3323,7 +3323,7 @@ function validateStepIds(flow2) {
3323
3323
  collectIds(flow2.steps, "steps");
3324
3324
  return errors;
3325
3325
  }
3326
- function validateSelectorReferences(flow2) {
3326
+ function validateSelectorReferences(flow2, rootDir) {
3327
3327
  const errors = [];
3328
3328
  const inputNames = new Set(Object.keys(flow2.inputs));
3329
3329
  const nestedKeys = getNestedStepsKeys();
@@ -3441,6 +3441,17 @@ function validateSelectorReferences(flow2) {
3441
3441
  const fieldName = step.type === "code" ? "source" : "expression";
3442
3442
  checkSelectors(extractSelectors(text5), `${pathPrefix}.${descriptor.configKey}.${fieldName}`, preceding2);
3443
3443
  }
3444
+ const modulePath = step.type === "code" ? c.module : void 0;
3445
+ if (rootDir && typeof modulePath === "string" && modulePath.length > 0) {
3446
+ const abs = path4.resolve(rootDir, modulePath);
3447
+ if (fs4.existsSync(abs)) {
3448
+ try {
3449
+ const moduleText = fs4.readFileSync(abs, "utf-8");
3450
+ checkSelectors(extractSelectors(moduleText), `${pathPrefix}.${descriptor.configKey}.module`, preceding2);
3451
+ } catch {
3452
+ }
3453
+ }
3454
+ }
3444
3455
  }
3445
3456
  }
3446
3457
  for (const { configKey, fieldName } of nestedKeys) {
@@ -3608,7 +3619,7 @@ function validateFlow(flow2, rootDir) {
3608
3619
  const f = flow2;
3609
3620
  return [
3610
3621
  ...validateStepIds(f),
3611
- ...validateSelectorReferences(f),
3622
+ ...validateSelectorReferences(f, rootDir),
3612
3623
  ...validateOutputSchemas(f),
3613
3624
  ...rootDir ? validateCodeModules(f, rootDir) : []
3614
3625
  ];
@@ -8961,40 +8972,45 @@ ${pc10.dim(line)}`);
8961
8972
 
8962
8973
  // src/commands/mem/export.ts
8963
8974
  import fs11 from "fs";
8975
+ import { once } from "events";
8976
+ async function writeLine(stream, line) {
8977
+ if (!stream.write(line)) {
8978
+ await once(stream, "drain");
8979
+ }
8980
+ }
8964
8981
  async function memExportCommand(outfile) {
8965
8982
  requireMemoryInit();
8966
8983
  const backend = await getBackend();
8967
8984
  const stats = await backend.stats();
8985
+ const toFile = !!outfile && outfile !== "-";
8986
+ const stream = toFile ? fs11.createWriteStream(outfile, "utf-8") : process.stdout;
8968
8987
  const all = await listAllTypes(backend);
8969
- const records = [];
8988
+ const pageSize = 500;
8989
+ let written = 0;
8970
8990
  for (const type of all) {
8971
- let offset = 0;
8972
- const pageSize = 500;
8973
- while (true) {
8974
- const page = await backend.list(type, { limit: pageSize, offset, status: "active" });
8975
- records.push(...page);
8976
- if (page.length < pageSize) break;
8977
- offset += pageSize;
8978
- }
8979
- offset = 0;
8980
- while (true) {
8981
- const page = await backend.list(type, { limit: pageSize, offset, status: "archived" });
8982
- records.push(...page);
8983
- if (page.length < pageSize) break;
8984
- offset += pageSize;
8985
- }
8986
- }
8987
- const lines = records.map((r) => JSON.stringify(r)).join("\n") + "\n";
8988
- if (!outfile || outfile === "-") {
8989
- process.stdout.write(lines);
8990
- if (!isAgentMode()) {
8991
- process.stderr.write(`Exported ${records.length} records (${stats.recordCount} total in store).
8992
- `);
8991
+ for (const status of ["active", "archived"]) {
8992
+ let offset = 0;
8993
+ while (true) {
8994
+ const page = await backend.list(type, { limit: pageSize, offset, status });
8995
+ for (const r of page) {
8996
+ await writeLine(stream, JSON.stringify(r) + "\n");
8997
+ written++;
8998
+ }
8999
+ if (page.length < pageSize) break;
9000
+ offset += pageSize;
9001
+ }
8993
9002
  }
9003
+ }
9004
+ if (toFile) {
9005
+ stream.end();
9006
+ await once(stream, "finish");
9007
+ okJson({ status: "ok", file: outfile, recordsWritten: written, storeTotal: stats.recordCount });
8994
9008
  return;
8995
9009
  }
8996
- fs11.writeFileSync(outfile, lines, "utf-8");
8997
- okJson({ status: "ok", file: outfile, recordsWritten: records.length, storeTotal: stats.recordCount });
9010
+ if (!isAgentMode()) {
9011
+ process.stderr.write(`Exported ${written} records (${stats.recordCount} total in store).
9012
+ `);
9013
+ }
8998
9014
  }
8999
9015
  async function memImportCommand(file) {
9000
9016
  requireMemoryInit();
@@ -9873,7 +9889,8 @@ one --agent mem reindex # re-embed records under current model
9873
9889
  ## Admin
9874
9890
 
9875
9891
  \`\`\`bash
9876
- one --agent mem export records.jsonl
9892
+ one --agent mem export records.jsonl # streamed JSONL \u2014 memory-safe on large stores
9893
+ one --agent mem export - # stream to stdout
9877
9894
  one --agent mem import records.jsonl # idempotent via keys[]
9878
9895
  one --agent mem migrate --dry-run # preview legacy .db \u2192 memory
9879
9896
  one --agent mem migrate --cleanup -y # migrate + delete .db files
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withone/cli",
3
- "version": "1.47.1",
3
+ "version": "1.47.3",
4
4
  "description": "CLI for managing One",
5
5
  "type": "module",
6
6
  "files": [
@@ -145,7 +145,7 @@ Two rules: (1) prepend the stdin-read line, (2) replace `return X` with `process
145
145
  one --agent flow validate <key>
146
146
  ```
147
147
 
148
- `flow validate` parses every inline `code.source` and runs `node --check` on every `code.module` file, so syntax errors (brace/paren mismatches, duplicate `let`, etc.) surface here instead of after upstream steps have already run. It also extracts `$.steps.X` and `$.input.X` references from inside `code.source` and `transform.expression` and reports any reference to an undefined step/input or to a step declared **after** the current one (forward references resolve to `undefined` at runtime — silent data loss). The same checks run automatically at the start of `flow execute` so a broken step in position 15 fails the run immediately rather than 15 minutes in.
148
+ `flow validate` parses every inline `code.source` and runs `node --check` on every `code.module` file, so syntax errors (brace/paren mismatches, duplicate `let`, etc.) surface here instead of after upstream steps have already run. It also extracts `$.steps.X` and `$.input.X` references from inside `code.source`, `transform.expression`, **and external `code.module` `.mjs` files**, and reports any reference to an undefined step/input or to a step declared **after** the current one (forward references resolve to `undefined` at runtime — silent data loss). The same checks run automatically at the start of `flow execute` so a broken step in position 15 fails the run immediately rather than 15 minutes in.
149
149
 
150
150
  ### Step 6: Execute
151
151