@withone/cli 2.11.1 → 2.12.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
@@ -739,12 +739,14 @@ Drop a `.onerc` file in your project root to override global settings per-projec
739
739
  |-----|---------|
740
740
  | `ONE_SECRET` | API key (also honored as env var) |
741
741
  | `ONE_API_BASE` | API base URL, `https://api.withone.ai` or `https://development-api.withone.ai` only (the env var accepts any origin) |
742
- | `ONE_PERMISSIONS` | `admin` / `write` / `read` |
743
- | `ONE_CONNECTION_KEYS` | Comma-separated connection-key allowlist |
744
- | `ONE_ACTION_IDS` | Comma-separated action-ID allowlist |
745
- | `ONE_KNOWLEDGE_AGENT` | `true` / `false` — knowledge-only mode |
742
+ | `ONE_PERMISSIONS` | `admin` / `write` / `read`, can only lower the configured level |
743
+ | `ONE_CONNECTION_KEYS` | Comma-separated connection-key allowlist, intersected with the configured one |
744
+ | `ONE_ACTION_IDS` | Comma-separated action-ID allowlist, intersected with the configured one |
745
+ | `ONE_KNOWLEDGE_AGENT` | `true` turns knowledge-only mode on; it cannot turn it off |
746
746
 
747
- Precedence: env var > `.onerc` > `~/.one/config.json`.
747
+ Precedence: env var > `.onerc` > `~/.one/config.json`. The access keys are the exception: a `.onerc` can only narrow the access settings in your config, never widen them, because it can arrive with a cloned repository. A value that would widen them is ignored with a warning; use `one config` instead.
748
+
749
+ The access settings are enforced on every call to a connected app, whatever the command: `actions execute`, flows, sync and its validation runs. Headers named `x-one-secret`, `x-one-connection-key` or `x-one-action-id` cannot be passed with `--headers`, method-override headers are judged against the permission level, and a path variable cannot be `.` or `..`.
748
750
 
749
751
  ```bash
750
752
  # .onerc
@@ -5,11 +5,11 @@ import {
5
5
  getMemoryConfig,
6
6
  getMemoryConfigOrDefault,
7
7
  updateMemoryConfig
8
- } from "./chunk-NC3HVQ7O.js";
8
+ } from "./chunk-EITBMRUB.js";
9
9
  import {
10
10
  getOpenAiApiKey,
11
11
  homeDir
12
- } from "./chunk-FR4VGZUI.js";
12
+ } from "./chunk-EWHFGWB3.js";
13
13
 
14
14
  // src/lib/memory/schema.ts
15
15
  var SCHEMA_VERSION = "2.3.1";
@@ -6,9 +6,12 @@ import {
6
6
  isAgentMode
7
7
  } from "./chunk-Q6PWTATS.js";
8
8
  import {
9
+ IDENTITY_HEADERS,
9
10
  appendAnalyticsQueue,
10
11
  appendUsageLog,
12
+ checkPassthroughAccess,
11
13
  claimUsageLog,
14
+ getAccessControlFromAllSources,
12
15
  getApiKey,
13
16
  getCacheTtl,
14
17
  getDeviceId,
@@ -16,6 +19,8 @@ import {
16
19
  getProjectRoot,
17
20
  getWhoAmI,
18
21
  homeDir,
22
+ isActionAllowed,
23
+ isMethodAllowed,
19
24
  markTelemetryNoticeShown,
20
25
  readAnalyticsQueue,
21
26
  readConfig,
@@ -24,7 +29,7 @@ import {
24
29
  writeAnalyticsQueue,
25
30
  writeUsageLog,
26
31
  writeUsageState
27
- } from "./chunk-FR4VGZUI.js";
32
+ } from "./chunk-EWHFGWB3.js";
28
33
 
29
34
  // src/lib/flow-runner.ts
30
35
  import fs5 from "fs";
@@ -725,11 +730,17 @@ function parseRetryAfter(value) {
725
730
  return void 0;
726
731
  }
727
732
  var OneApi = class {
728
- constructor(apiKey, apiBase) {
733
+ constructor(apiKey, apiBase, accessSettings) {
729
734
  this.apiKey = apiKey;
735
+ this.accessSettings = accessSettings;
730
736
  this.apiBase = apiBase ?? "https://api.withone.ai/v1";
731
737
  }
732
738
  apiBase;
739
+ /**
740
+ * The local access settings every passthrough call is checked against.
741
+ * Read from config and `.onerc` at call time unless a caller supplies them.
742
+ */
743
+ accessSettings;
733
744
  async request(path7) {
734
745
  return this.requestFull({ path: path7 });
735
746
  }
@@ -967,10 +978,13 @@ var OneApi = class {
967
978
  const action = preloadedAction ?? await this.getActionDetails(args.actionId);
968
979
  const method = action.method;
969
980
  const contentType = args.isFormData ? "multipart/form-data" : args.isFormUrlEncoded ? "application/x-www-form-urlencoded" : "application/json";
981
+ checkPassthroughAccess(this.accessSettings ?? getAccessControlFromAllSources(), {
982
+ actionId: action._id,
983
+ connectionKey: args.connectionKey,
984
+ method,
985
+ headers: args.headers
986
+ });
970
987
  const requestHeaders = {
971
- "x-one-secret": this.apiKey,
972
- "x-one-connection-key": args.connectionKey,
973
- "x-one-action-id": action._id,
974
988
  "Content-Type": contentType,
975
989
  Accept: "application/json, text/event-stream, */*",
976
990
  // Who is calling, for the Logs page. Before the caller's own headers so
@@ -978,9 +992,17 @@ var OneApi = class {
978
992
  ...callerHeaders(),
979
993
  ...args.headers
980
994
  };
995
+ for (const name of Object.keys(requestHeaders)) {
996
+ if (IDENTITY_HEADERS.includes(name.toLowerCase())) delete requestHeaders[name];
997
+ }
998
+ requestHeaders["x-one-secret"] = this.apiKey;
999
+ requestHeaders["x-one-connection-key"] = args.connectionKey;
1000
+ requestHeaders["x-one-action-id"] = action._id;
981
1001
  const finalActionPath = args.pathVariables ? replacePathVariables(action.path, args.pathVariables) : action.path;
982
1002
  const normalizedPath = finalActionPath.startsWith("/") ? finalActionPath : `/${finalActionPath}`;
983
- const url = `${this.apiBase.replace("/v1", "")}/v1/passthrough${normalizedPath}`;
1003
+ const passthroughBase = `${this.apiBase.replace("/v1", "")}/v1/passthrough`;
1004
+ const url = `${passthroughBase}${normalizedPath}`;
1005
+ assertUnderPassthrough(passthroughBase, url);
984
1006
  const isCustomAction = action.tags?.includes("custom");
985
1007
  let requestData = args.data;
986
1008
  if (isCustomAction && method?.toLowerCase() !== "get") {
@@ -1200,6 +1222,20 @@ var TimeoutError = class extends Error {
1200
1222
  function sleep(ms) {
1201
1223
  return new Promise((resolve2) => setTimeout(resolve2, ms));
1202
1224
  }
1225
+ function encodePathValue(name, value) {
1226
+ const text = value.toString();
1227
+ if (text === "." || text === "..") {
1228
+ throw new Error(`Path variable "${name}" cannot be "${text}".`);
1229
+ }
1230
+ return encodeURIComponent(text).replace(/%3A/gi, ":");
1231
+ }
1232
+ function assertUnderPassthrough(passthroughBase, url) {
1233
+ const prefix = new URL(passthroughBase).pathname.replace(/\/+$/, "");
1234
+ const resolved = new URL(url).pathname;
1235
+ if (resolved !== prefix && !resolved.startsWith(`${prefix}/`)) {
1236
+ throw new Error(`Action path resolves outside ${prefix} (${resolved}).`);
1237
+ }
1238
+ }
1203
1239
  function replacePathVariables(path7, variables) {
1204
1240
  if (!path7) return path7;
1205
1241
  let result = path7;
@@ -1209,7 +1245,7 @@ function replacePathVariables(path7, variables) {
1209
1245
  if (value === void 0 || value === null || value === "") {
1210
1246
  throw new Error(`Missing value for path variable: ${trimmedVariable}`);
1211
1247
  }
1212
- return encodeURIComponent(value.toString()).replace(/%3A/gi, ":");
1248
+ return encodePathValue(trimmedVariable, value);
1213
1249
  });
1214
1250
  result = result.replace(/\{([^}]+)\}/g, (_match, variable) => {
1215
1251
  const trimmedVariable = variable.trim();
@@ -1217,23 +1253,10 @@ function replacePathVariables(path7, variables) {
1217
1253
  if (value === void 0 || value === null || value === "") {
1218
1254
  throw new Error(`Missing value for path variable: ${trimmedVariable}`);
1219
1255
  }
1220
- return encodeURIComponent(value.toString()).replace(/%3A/gi, ":");
1256
+ return encodePathValue(trimmedVariable, value);
1221
1257
  });
1222
1258
  return result;
1223
1259
  }
1224
- var PERMISSION_METHODS = {
1225
- read: ["GET"],
1226
- write: ["GET", "POST", "PUT", "PATCH"],
1227
- admin: null
1228
- };
1229
- function isMethodAllowed(method, permissions) {
1230
- const allowed = PERMISSION_METHODS[permissions];
1231
- if (allowed === null) return true;
1232
- return allowed.includes(method.toUpperCase());
1233
- }
1234
- function isActionAllowed(actionId, allowedActionIds) {
1235
- return allowedActionIds.includes("*") || allowedActionIds.includes(actionId);
1236
- }
1237
1260
 
1238
1261
  // src/lib/cache.ts
1239
1262
  import fs3 from "fs";
@@ -2977,7 +3000,7 @@ async function executeSubflowStep(step, context, api, permissions, allowedAction
2977
3000
  if (flowStack.includes(resolvedKey)) {
2978
3001
  throw new Error(`Circular flow detected: ${[...flowStack, resolvedKey].join(" \u2192 ")}`);
2979
3002
  }
2980
- const { loadFlowWithMeta: loadFlowWithMeta2 } = await import("./flow-runner-36I4G5BS.js");
3003
+ const { loadFlowWithMeta: loadFlowWithMeta2 } = await import("./flow-runner-6QTY3U2C.js");
2981
3004
  const { flow: subFlow, rootDir: subRootDir } = loadFlowWithMeta2(resolvedKey);
2982
3005
  const subContext = await executeFlow(
2983
3006
  subFlow,
@@ -3907,9 +3930,6 @@ export {
3907
3930
  ApiError,
3908
3931
  OneApi,
3909
3932
  TimeoutError,
3910
- PERMISSION_METHODS,
3911
- isMethodAllowed,
3912
- isActionAllowed,
3913
3933
  knowledgeCachePath,
3914
3934
  readCache,
3915
3935
  writeCache,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  requireMemoryInit
3
- } from "./chunk-VYOIHD4B.js";
3
+ } from "./chunk-J7JWBH45.js";
4
4
  import {
5
5
  error,
6
6
  isAgentMode,
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-Q6PWTATS.js";
9
9
  import {
10
10
  getBackend
11
- } from "./chunk-UYOXEMF5.js";
11
+ } from "./chunk-6IRGRC3G.js";
12
12
 
13
13
  // src/commands/mem/sql.ts
14
14
  async function memSqlCommand(sql) {
@@ -3,7 +3,7 @@ import {
3
3
  readConfig,
4
4
  setOpenAiApiKey,
5
5
  writeConfig
6
- } from "./chunk-FR4VGZUI.js";
6
+ } from "./chunk-EWHFGWB3.js";
7
7
 
8
8
  // src/lib/memory/config.ts
9
9
  var DEFAULT_MEMORY_CONFIG = {
@@ -10,6 +10,76 @@ function homeDir() {
10
10
  import fs from "fs";
11
11
  import path from "path";
12
12
  import { randomUUID } from "crypto";
13
+
14
+ // src/lib/access-gate.ts
15
+ var PERMISSION_METHODS = {
16
+ read: ["GET"],
17
+ write: ["GET", "POST", "PUT", "PATCH"],
18
+ admin: null
19
+ };
20
+ function isMethodAllowed(method, permissions) {
21
+ const allowed = PERMISSION_METHODS[permissions];
22
+ if (allowed === null) return true;
23
+ return allowed.includes(method.toUpperCase());
24
+ }
25
+ function isActionAllowed(actionId, allowedActionIds) {
26
+ return allowedActionIds.includes("*") || allowedActionIds.includes(actionId);
27
+ }
28
+ function isConnectionAllowed(connectionKey, allowedConnectionKeys) {
29
+ return allowedConnectionKeys.includes("*") || allowedConnectionKeys.includes(connectionKey);
30
+ }
31
+ var IDENTITY_HEADERS = ["x-one-secret", "x-one-connection-key", "x-one-action-id"];
32
+ var METHOD_OVERRIDE_HEADERS = ["x-http-method-override", "x-http-method", "x-method-override"];
33
+ var AccessDeniedError = class extends Error {
34
+ constructor(message) {
35
+ super(message);
36
+ this.name = "AccessDeniedError";
37
+ }
38
+ };
39
+ function checkPassthroughAccess(settings, req) {
40
+ const permissions = settings.permissions ?? "admin";
41
+ const actionIds = settings.actionIds ?? ["*"];
42
+ const connectionKeys = settings.connectionKeys ?? ["*"];
43
+ if (settings.knowledgeAgent) {
44
+ throw new AccessDeniedError("Action execution is disabled (knowledge-only mode).");
45
+ }
46
+ if (!isActionAllowed(req.actionId, actionIds)) {
47
+ throw new AccessDeniedError(`Action "${req.actionId}" is not in the allowed action list.`);
48
+ }
49
+ if (!isConnectionAllowed(req.connectionKey, connectionKeys)) {
50
+ throw new AccessDeniedError(`Connection key "${req.connectionKey}" is not allowed.`);
51
+ }
52
+ if (!isMethodAllowed(req.method, permissions)) {
53
+ throw new AccessDeniedError(`Method "${req.method}" is not allowed under "${permissions}" permission level.`);
54
+ }
55
+ for (const [name, value] of Object.entries(req.headers ?? {})) {
56
+ const lower = name.toLowerCase();
57
+ if (IDENTITY_HEADERS.includes(lower)) {
58
+ throw new AccessDeniedError(
59
+ `Header "${name}" is set by the CLI and cannot be passed. Use --connection-key and the action id instead.`
60
+ );
61
+ }
62
+ if (METHOD_OVERRIDE_HEADERS.includes(lower) && !isMethodAllowed(String(value), permissions)) {
63
+ throw new AccessDeniedError(
64
+ `Header "${name}: ${value}" asks for a method that is not allowed under "${permissions}" permission level.`
65
+ );
66
+ }
67
+ }
68
+ }
69
+ var LEVEL_RANK = { read: 0, write: 1, admin: 2 };
70
+ function isPermissionLevel(value) {
71
+ return value in LEVEL_RANK;
72
+ }
73
+ function stricterLevel(a, b) {
74
+ return LEVEL_RANK[a] <= LEVEL_RANK[b] ? a : b;
75
+ }
76
+ function intersectAllowlists(a, b) {
77
+ if (a.includes("*")) return b;
78
+ if (b.includes("*")) return a;
79
+ return a.filter((x) => b.includes(x));
80
+ }
81
+
82
+ // src/lib/config.ts
13
83
  function configDir() {
14
84
  return path.join(homeDir(), ".one");
15
85
  }
@@ -158,21 +228,44 @@ function setOpenAiApiKey(key) {
158
228
  }
159
229
  writeConfig(resolved.config, resolved.scope ?? "global");
160
230
  }
231
+ var warnedOneRcAccess = false;
161
232
  function getAccessControlFromAllSources() {
162
233
  const rc = readOneRc();
163
234
  const fileAc = getAccessControl();
164
235
  const merged = { ...fileAc };
165
- if (rc.ONE_PERMISSIONS) {
166
- merged.permissions = rc.ONE_PERMISSIONS;
167
- }
168
- if (rc.ONE_CONNECTION_KEYS) {
169
- merged.connectionKeys = rc.ONE_CONNECTION_KEYS.split(",").map((s) => s.trim()).filter(Boolean);
170
- }
171
- if (rc.ONE_ACTION_IDS) {
172
- merged.actionIds = rc.ONE_ACTION_IDS.split(",").map((s) => s.trim()).filter(Boolean);
236
+ const ignored = [];
237
+ const rcLevel = rc.ONE_PERMISSIONS?.trim();
238
+ if (rcLevel) {
239
+ const current = fileAc.permissions ?? "admin";
240
+ if (isPermissionLevel(rcLevel)) {
241
+ merged.permissions = stricterLevel(current, rcLevel);
242
+ if (merged.permissions !== rcLevel) ignored.push(`ONE_PERMISSIONS=${rcLevel}`);
243
+ } else {
244
+ ignored.push(`ONE_PERMISSIONS=${rcLevel}`);
245
+ }
173
246
  }
174
- if (rc.ONE_KNOWLEDGE_AGENT) {
175
- merged.knowledgeAgent = rc.ONE_KNOWLEDGE_AGENT === "true";
247
+ const narrowList = (rcKey, current) => {
248
+ const raw = rc[rcKey];
249
+ if (!raw) return current;
250
+ const asked = raw.split(",").map((s) => s.trim()).filter(Boolean);
251
+ if (asked.length === 0) return current;
252
+ const result = intersectAllowlists(current ?? ["*"], asked);
253
+ if (asked.some((x) => !result.includes(x))) ignored.push(`${rcKey}=${raw}`);
254
+ return result;
255
+ };
256
+ merged.connectionKeys = narrowList("ONE_CONNECTION_KEYS", fileAc.connectionKeys);
257
+ merged.actionIds = narrowList("ONE_ACTION_IDS", fileAc.actionIds);
258
+ if (merged.connectionKeys === void 0) delete merged.connectionKeys;
259
+ if (merged.actionIds === void 0) delete merged.actionIds;
260
+ const rcKnowledge = rc.ONE_KNOWLEDGE_AGENT?.trim();
261
+ if (rcKnowledge === "true") merged.knowledgeAgent = true;
262
+ else if (rcKnowledge && fileAc.knowledgeAgent) ignored.push(`ONE_KNOWLEDGE_AGENT=${rcKnowledge}`);
263
+ if (ignored.length > 0 && !warnedOneRcAccess) {
264
+ warnedOneRcAccess = true;
265
+ process.stderr.write(
266
+ `Ignoring ${ignored.join(", ")} from .onerc: .onerc can only narrow the access settings in your config. Use \`one config\` to widen them.
267
+ `
268
+ );
176
269
  }
177
270
  return merged;
178
271
  }
@@ -439,6 +532,11 @@ function writeUsageState(state) {
439
532
 
440
533
  export {
441
534
  homeDir,
535
+ PERMISSION_METHODS,
536
+ isMethodAllowed,
537
+ isActionAllowed,
538
+ IDENTITY_HEADERS,
539
+ checkPassthroughAccess,
442
540
  getProjectRoot,
443
541
  getProjectConfigPath,
444
542
  getGlobalConfigPath,
@@ -5,11 +5,11 @@ import {
5
5
  } from "./chunk-Q6PWTATS.js";
6
6
  import {
7
7
  getMemoryConfigOrDefault
8
- } from "./chunk-NC3HVQ7O.js";
8
+ } from "./chunk-EITBMRUB.js";
9
9
  import {
10
10
  getOpenAiApiKey,
11
11
  readConfig
12
- } from "./chunk-FR4VGZUI.js";
12
+ } from "./chunk-EWHFGWB3.js";
13
13
 
14
14
  // src/commands/mem/util.ts
15
15
  function requireMemoryInit() {
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  okJson,
6
6
  requireMemoryInit
7
- } from "./chunk-VYOIHD4B.js";
7
+ } from "./chunk-J7JWBH45.js";
8
8
  import {
9
9
  isAgentMode,
10
10
  note
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  getBackend,
14
14
  upsertRecord
15
- } from "./chunk-UYOXEMF5.js";
15
+ } from "./chunk-6IRGRC3G.js";
16
16
 
17
17
  // src/commands/mem/migrate.ts
18
18
  import fs4 from "fs";
@@ -2,8 +2,8 @@ import {
2
2
  defaultSearchableText,
3
3
  embed,
4
4
  embedBatch
5
- } from "./chunk-NC3HVQ7O.js";
6
- import "./chunk-FR4VGZUI.js";
5
+ } from "./chunk-EITBMRUB.js";
6
+ import "./chunk-EWHFGWB3.js";
7
7
  export {
8
8
  defaultSearchableText,
9
9
  embed,
@@ -12,10 +12,10 @@ import {
12
12
  stripStepsAlias,
13
13
  summarizeFlowInputs,
14
14
  walkSteps
15
- } from "./chunk-RUVW6QYK.js";
15
+ } from "./chunk-7ZBRP3BJ.js";
16
16
  import "./chunk-44CV5IMX.js";
17
17
  import "./chunk-Q6PWTATS.js";
18
- import "./chunk-FR4VGZUI.js";
18
+ import "./chunk-EWHFGWB3.js";
19
19
  export {
20
20
  FlowRunner,
21
21
  collectStepTypes,
package/dist/index.js CHANGED
@@ -6,7 +6,6 @@ import {
6
6
  FLOW_SCHEMA,
7
7
  FlowRunner,
8
8
  OneApi,
9
- PERMISSION_METHODS,
10
9
  TimeoutError,
11
10
  clearAll,
12
11
  clearEntry,
@@ -25,9 +24,7 @@ import {
25
24
  getStepTypeDescriptor,
26
25
  installContextToParams,
27
26
  installMcpConfig,
28
- isActionAllowed,
29
27
  isFresh,
30
- isMethodAllowed,
31
28
  knowledgeCachePath,
32
29
  listCacheEntries,
33
30
  listFlows,
@@ -42,10 +39,10 @@ import {
42
39
  validateActionInput,
43
40
  walkSteps,
44
41
  writeCache
45
- } from "./chunk-RUVW6QYK.js";
42
+ } from "./chunk-7ZBRP3BJ.js";
46
43
  import {
47
44
  memSqlCommand
48
- } from "./chunk-WWPH6JOO.js";
45
+ } from "./chunk-DGQOAFXJ.js";
49
46
  import {
50
47
  collectIdentityKeys,
51
48
  countRecords,
@@ -76,7 +73,7 @@ import {
76
73
  writeDraftProfile,
77
74
  writePageToMemory,
78
75
  writeProfile
79
- } from "./chunk-5O5OUAHJ.js";
76
+ } from "./chunk-WZTPSXHP.js";
80
77
  import {
81
78
  getByDotPath
82
79
  } from "./chunk-44CV5IMX.js";
@@ -90,7 +87,7 @@ import {
90
87
  requireMemoryInit,
91
88
  semanticSearchUpgradeHint,
92
89
  semanticSearchUpgradeLine
93
- } from "./chunk-VYOIHD4B.js";
90
+ } from "./chunk-J7JWBH45.js";
94
91
  import {
95
92
  cancel,
96
93
  createSpinner,
@@ -112,7 +109,7 @@ import {
112
109
  listBackendPlugins,
113
110
  loadBackendFromConfig,
114
111
  updateRecord
115
- } from "./chunk-UYOXEMF5.js";
112
+ } from "./chunk-6IRGRC3G.js";
116
113
  import {
117
114
  DEFAULT_MEMORY_CONFIG,
118
115
  defaultSearchableText,
@@ -122,8 +119,9 @@ import {
122
119
  memoryConfigExists,
123
120
  setOpenAiApiKey,
124
121
  updateMemoryConfig
125
- } from "./chunk-NC3HVQ7O.js";
122
+ } from "./chunk-EITBMRUB.js";
126
123
  import {
124
+ PERMISSION_METHODS,
127
125
  configExists,
128
126
  ensureWhoAmI,
129
127
  getAccessControl,
@@ -138,6 +136,8 @@ import {
138
136
  getWhoAmI,
139
137
  globalConfigExists,
140
138
  homeDir,
139
+ isActionAllowed,
140
+ isMethodAllowed,
141
141
  projectConfigExists,
142
142
  readConfig,
143
143
  readGlobalConfig,
@@ -148,7 +148,7 @@ import {
148
148
  updateApiBase,
149
149
  updateWhoAmI,
150
150
  writeConfig
151
- } from "./chunk-FR4VGZUI.js";
151
+ } from "./chunk-EWHFGWB3.js";
152
152
 
153
153
  // src/cli.ts
154
154
  import { createRequire } from "module";
@@ -7427,7 +7427,7 @@ async function syncModel(api, profile, options) {
7427
7427
  updateModelState(platform, model, { status: "failed", pagesProcessed, lastCursor }),
7428
7428
  (async () => {
7429
7429
  try {
7430
- const { getBackend: getBackend2 } = await import("./runtime-J4TQCY7Z.js");
7430
+ const { getBackend: getBackend2 } = await import("./runtime-WB4J6RQK.js");
7431
7431
  const backend = await getBackend2();
7432
7432
  await Promise.race([
7433
7433
  backend.close(),
@@ -7793,7 +7793,7 @@ async function syncModel(api, profile, options) {
7793
7793
  db.exec(`DROP TABLE IF EXISTS _seen_ids`);
7794
7794
  }
7795
7795
  if (options.toMemory !== false) {
7796
- const backend = await (await import("./runtime-J4TQCY7Z.js")).getBackend();
7796
+ const backend = await (await import("./runtime-WB4J6RQK.js")).getBackend();
7797
7797
  const type = `${platform}/${model}`;
7798
7798
  const existing = await backend.listKeysByType(type);
7799
7799
  const sourcePrefix = `${type}:`;
@@ -7894,7 +7894,7 @@ async function syncModel(api, profile, options) {
7894
7894
  let statusCounts;
7895
7895
  if (options.toMemory !== false) {
7896
7896
  try {
7897
- const backend = await (await import("./runtime-J4TQCY7Z.js")).getBackend();
7897
+ const backend = await (await import("./runtime-WB4J6RQK.js")).getBackend();
7898
7898
  const typeName = `${platform}/${model}`;
7899
7899
  const [active, archived] = await Promise.all([
7900
7900
  backend.count(typeName, { status: "active" }),
@@ -9616,7 +9616,7 @@ ${result.total} results`);
9616
9616
  }
9617
9617
  }
9618
9618
  async function syncSqlCommand(platformModel, sql) {
9619
- const { syncSqlCommand: runSyncSql } = await import("./sql-XCMEVSVD.js");
9619
+ const { syncSqlCommand: runSyncSql } = await import("./sql-BNSA2GZM.js");
9620
9620
  await runSyncSql(platformModel, sql);
9621
9621
  }
9622
9622
  async function syncDeleteCommand(platformModel, options) {
@@ -9694,7 +9694,7 @@ async function syncDeleteCommand(platformModel, options) {
9694
9694
  async function maybeAutoMigrateLegacy(platform, models) {
9695
9695
  const dbSize = getDatabaseSize(platform);
9696
9696
  if (!dbSize || dbSize === "0 B") return;
9697
- const { getBackend: getBackend2 } = await import("./runtime-J4TQCY7Z.js");
9697
+ const { getBackend: getBackend2 } = await import("./runtime-WB4J6RQK.js");
9698
9698
  const backend = await getBackend2();
9699
9699
  let memoryHasData = false;
9700
9700
  for (const model of models) {
@@ -9710,7 +9710,7 @@ async function maybeAutoMigrateLegacy(platform, models) {
9710
9710
  ` detected legacy .one/sync/data/${platform}.db (${dbSize}) \u2014 auto-migrating into memory before sync.
9711
9711
  `
9712
9712
  );
9713
- const { memMigrateCommand: memMigrateCommand3 } = await import("./migrate-IKK2N3VW.js");
9713
+ const { memMigrateCommand: memMigrateCommand3 } = await import("./migrate-KKNH3745.js");
9714
9714
  await memMigrateCommand3({ platform, yes: true });
9715
9715
  return;
9716
9716
  }
@@ -9719,7 +9719,7 @@ async function maybeAutoMigrateLegacy(platform, models) {
9719
9719
  initialValue: true
9720
9720
  });
9721
9721
  if (p6.isCancel(shouldMigrate) || !shouldMigrate) return;
9722
- const { memMigrateCommand: memMigrateCommand2 } = await import("./migrate-IKK2N3VW.js");
9722
+ const { memMigrateCommand: memMigrateCommand2 } = await import("./migrate-KKNH3745.js");
9723
9723
  await memMigrateCommand2({ platform, yes: true });
9724
9724
  }
9725
9725
  async function syncSuggestSearchableCommand(platformModel, options = {}) {
@@ -9780,7 +9780,7 @@ async function syncSuggestSearchableCommand(platformModel, options = {}) {
9780
9780
  async function syncListCommand(platform) {
9781
9781
  const profiles = listProfiles(platform);
9782
9782
  const state = await readSyncState();
9783
- const { getBackend: getBackend2 } = await import("./runtime-J4TQCY7Z.js");
9783
+ const { getBackend: getBackend2 } = await import("./runtime-WB4J6RQK.js");
9784
9784
  const backend = await getBackend2();
9785
9785
  const syncs = await Promise.all(profiles.map(async (p9) => {
9786
9786
  const modelState = state[p9.platform]?.[p9.model];
@@ -10056,7 +10056,7 @@ function registerSyncSubcommands(sync) {
10056
10056
  await syncSqlCommand(platformModel, sql);
10057
10057
  });
10058
10058
  sync.command("schema <platform/model>").description("Inspect the JSON structure of synced records (field paths, types, examples) \u2014 useful before writing `sync sql` queries").action(async (platformModel) => {
10059
- const { syncSchemaCommand } = await import("./schema-JKYKFQZD.js");
10059
+ const { syncSchemaCommand } = await import("./schema-SDZZ7XZT.js");
10060
10060
  await syncSchemaCommand(platformModel);
10061
10061
  });
10062
10062
  sync.command("delete <platform/model>").description('Delete records from local sync data (e.g. one sync delete notion/pages --id "abc-123")').option("--id <value>", "Delete record by ID").option("--where <conditions>", 'Delete records matching conditions (e.g. "status=archived")').option("--where-sql <predicate>", `Delete using a raw SQL WHERE clause (e.g. "json_extract(data, '$.type') = 'promotion'")`).option("--yes", "Skip confirmation prompt").action(async (platformModel, options) => {
@@ -10833,7 +10833,7 @@ async function memDoctorCommand() {
10833
10833
  }
10834
10834
  if (cfg.embedding.provider === "openai") {
10835
10835
  try {
10836
- const { embed: embed2 } = await import("./embedding-MVPO6QW7.js");
10836
+ const { embed: embed2 } = await import("./embedding-7Q22D23K.js");
10837
10837
  const result = await embed2("connectivity check");
10838
10838
  checks.push({
10839
10839
  name: "OpenAI embedding provider reachable",
@@ -3,13 +3,13 @@ import {
3
3
  dotPathToJsonbExpr,
4
4
  memMigrateCommand,
5
5
  reviveStringifiedJson
6
- } from "./chunk-5O5OUAHJ.js";
6
+ } from "./chunk-WZTPSXHP.js";
7
7
  import "./chunk-44CV5IMX.js";
8
- import "./chunk-VYOIHD4B.js";
8
+ import "./chunk-J7JWBH45.js";
9
9
  import "./chunk-Q6PWTATS.js";
10
- import "./chunk-UYOXEMF5.js";
11
- import "./chunk-NC3HVQ7O.js";
12
- import "./chunk-FR4VGZUI.js";
10
+ import "./chunk-6IRGRC3G.js";
11
+ import "./chunk-EITBMRUB.js";
12
+ import "./chunk-EWHFGWB3.js";
13
13
  export {
14
14
  buildIdentityMap,
15
15
  dotPathToJsonbExpr,
@@ -5,9 +5,9 @@ import {
5
5
  resetBackendSingleton,
6
6
  updateRecord,
7
7
  upsertRecord
8
- } from "./chunk-UYOXEMF5.js";
9
- import "./chunk-NC3HVQ7O.js";
10
- import "./chunk-FR4VGZUI.js";
8
+ } from "./chunk-6IRGRC3G.js";
9
+ import "./chunk-EITBMRUB.js";
10
+ import "./chunk-EWHFGWB3.js";
11
11
  export {
12
12
  addRecord,
13
13
  closeBackendIfCached,
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  okJson,
3
3
  requireMemoryInit
4
- } from "./chunk-VYOIHD4B.js";
4
+ } from "./chunk-J7JWBH45.js";
5
5
  import {
6
6
  isAgentMode,
7
7
  note
8
8
  } from "./chunk-Q6PWTATS.js";
9
9
  import {
10
10
  getBackend
11
- } from "./chunk-UYOXEMF5.js";
12
- import "./chunk-NC3HVQ7O.js";
13
- import "./chunk-FR4VGZUI.js";
11
+ } from "./chunk-6IRGRC3G.js";
12
+ import "./chunk-EITBMRUB.js";
13
+ import "./chunk-EWHFGWB3.js";
14
14
 
15
15
  // src/lib/memory/sync/schema.ts
16
16
  import pc from "picocolors";
@@ -0,0 +1,13 @@
1
+ import {
2
+ memSqlCommand,
3
+ syncSqlCommand
4
+ } from "./chunk-DGQOAFXJ.js";
5
+ import "./chunk-J7JWBH45.js";
6
+ import "./chunk-Q6PWTATS.js";
7
+ import "./chunk-6IRGRC3G.js";
8
+ import "./chunk-EITBMRUB.js";
9
+ import "./chunk-EWHFGWB3.js";
10
+ export {
11
+ memSqlCommand,
12
+ syncSqlCommand
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withone/cli",
3
- "version": "2.11.1",
3
+ "version": "2.12.0",
4
4
  "description": "CLI for managing One",
5
5
  "type": "module",
6
6
  "files": [
@@ -1,13 +0,0 @@
1
- import {
2
- memSqlCommand,
3
- syncSqlCommand
4
- } from "./chunk-WWPH6JOO.js";
5
- import "./chunk-VYOIHD4B.js";
6
- import "./chunk-Q6PWTATS.js";
7
- import "./chunk-UYOXEMF5.js";
8
- import "./chunk-NC3HVQ7O.js";
9
- import "./chunk-FR4VGZUI.js";
10
- export {
11
- memSqlCommand,
12
- syncSqlCommand
13
- };