@withone/cli 2.2.0 → 2.3.1

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.
@@ -3,7 +3,7 @@ import {
3
3
  readConfig,
4
4
  setOpenAiApiKey,
5
5
  writeConfig
6
- } from "./chunk-6UB623BG.js";
6
+ } from "./chunk-HTXZZQ6U.js";
7
7
 
8
8
  // src/lib/memory/config.ts
9
9
  var DEFAULT_MEMORY_CONFIG = {
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  getCacheTtl,
7
7
  homeDir
8
- } from "./chunk-6UB623BG.js";
8
+ } from "./chunk-HTXZZQ6U.js";
9
9
 
10
10
  // src/lib/flow-runner.ts
11
11
  import fs3 from "fs";
@@ -2285,7 +2285,7 @@ async function executeSubflowStep(step, context, api, permissions, allowedAction
2285
2285
  if (flowStack.includes(resolvedKey)) {
2286
2286
  throw new Error(`Circular flow detected: ${[...flowStack, resolvedKey].join(" \u2192 ")}`);
2287
2287
  }
2288
- const { loadFlowWithMeta: loadFlowWithMeta2 } = await import("./flow-runner-L3JG2WCY.js");
2288
+ const { loadFlowWithMeta: loadFlowWithMeta2 } = await import("./flow-runner-SFECNAO2.js");
2289
2289
  const { flow: subFlow, rootDir: subRootDir } = loadFlowWithMeta2(resolvedKey);
2290
2290
  const subContext = await executeFlow(
2291
2291
  subFlow,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  getMemoryConfigOrDefault
3
- } from "./chunk-YMUY55U2.js";
3
+ } from "./chunk-3HRC3IPE.js";
4
4
  import {
5
5
  getOpenAiApiKey,
6
6
  readConfig
7
- } from "./chunk-6UB623BG.js";
7
+ } from "./chunk-HTXZZQ6U.js";
8
8
 
9
9
  // src/lib/output.ts
10
10
  import * as p from "@clack/prompts";
@@ -205,6 +205,12 @@ function updateApiBase(url) {
205
205
  delete config.whoamiApiBase;
206
206
  writeConfig(config);
207
207
  }
208
+ function withKnowledgeAgent(accessControl, on) {
209
+ const next = { ...accessControl };
210
+ if (on) next.knowledgeAgent = true;
211
+ else delete next.knowledgeAgent;
212
+ return Object.keys(next).length ? next : void 0;
213
+ }
208
214
  function saveCredentials(apiKey, scope, opts) {
209
215
  const existing = scope === "project" ? readProjectConfig() : readGlobalConfig();
210
216
  const next = {
@@ -217,6 +223,14 @@ function saveCredentials(apiKey, scope, opts) {
217
223
  };
218
224
  if (opts.keyName) next.apiKeyName = opts.keyName;
219
225
  else delete next.apiKeyName;
226
+ const userSetKnowledge = !!existing?.accessControl?.knowledgeAgent && !existing.knowledgeAgentFromGrant;
227
+ if (opts.knowledgeOnly !== void 0 && !userSetKnowledge) {
228
+ const accessControl = withKnowledgeAgent(existing?.accessControl, opts.knowledgeOnly);
229
+ if (accessControl) next.accessControl = accessControl;
230
+ else delete next.accessControl;
231
+ if (opts.knowledgeOnly) next.knowledgeAgentFromGrant = true;
232
+ else delete next.knowledgeAgentFromGrant;
233
+ }
220
234
  writeConfig(next, scope);
221
235
  }
222
236
  function getCacheTtl() {
@@ -249,6 +263,7 @@ function updateAccessControl(settings) {
249
263
  } else {
250
264
  config.accessControl = cleaned;
251
265
  }
266
+ delete config.knowledgeAgentFromGrant;
252
267
  writeConfig(config);
253
268
  }
254
269
  function getWhoAmI() {
@@ -3,10 +3,10 @@ import {
3
3
  isAgentMode,
4
4
  json,
5
5
  requireMemoryInit
6
- } from "./chunk-OLQ55K6B.js";
6
+ } from "./chunk-FUCAK5RA.js";
7
7
  import {
8
8
  getBackend
9
- } from "./chunk-IMU2X3ZV.js";
9
+ } from "./chunk-NOPTG4GC.js";
10
10
 
11
11
  // src/commands/mem/sql.ts
12
12
  async function memSqlCommand(sql) {
@@ -5,11 +5,11 @@ import {
5
5
  getMemoryConfig,
6
6
  getMemoryConfigOrDefault,
7
7
  updateMemoryConfig
8
- } from "./chunk-YMUY55U2.js";
8
+ } from "./chunk-3HRC3IPE.js";
9
9
  import {
10
10
  getOpenAiApiKey,
11
11
  homeDir
12
- } from "./chunk-6UB623BG.js";
12
+ } from "./chunk-HTXZZQ6U.js";
13
13
 
14
14
  // src/lib/memory/schema.ts
15
15
  var SCHEMA_VERSION = "2.3.1";
@@ -6,11 +6,11 @@ import {
6
6
  note,
7
7
  okJson,
8
8
  requireMemoryInit
9
- } from "./chunk-OLQ55K6B.js";
9
+ } from "./chunk-FUCAK5RA.js";
10
10
  import {
11
11
  getBackend,
12
12
  upsertRecord
13
- } from "./chunk-IMU2X3ZV.js";
13
+ } from "./chunk-NOPTG4GC.js";
14
14
 
15
15
  // src/commands/mem/migrate.ts
16
16
  import fs4 from "fs";
@@ -2,8 +2,8 @@ import {
2
2
  defaultSearchableText,
3
3
  embed,
4
4
  embedBatch
5
- } from "./chunk-YMUY55U2.js";
6
- import "./chunk-6UB623BG.js";
5
+ } from "./chunk-3HRC3IPE.js";
6
+ import "./chunk-HTXZZQ6U.js";
7
7
  export {
8
8
  defaultSearchableText,
9
9
  embed,
@@ -12,9 +12,9 @@ import {
12
12
  stripStepsAlias,
13
13
  summarizeFlowInputs,
14
14
  walkSteps
15
- } from "./chunk-6EQDEYVD.js";
15
+ } from "./chunk-6FA7KUNQ.js";
16
16
  import "./chunk-44CV5IMX.js";
17
- import "./chunk-6UB623BG.js";
17
+ import "./chunk-HTXZZQ6U.js";
18
18
  export {
19
19
  FlowRunner,
20
20
  collectStepTypes,
package/dist/index.js CHANGED
@@ -28,10 +28,10 @@ import {
28
28
  validateActionInput,
29
29
  walkSteps,
30
30
  writeCache
31
- } from "./chunk-6EQDEYVD.js";
31
+ } from "./chunk-6FA7KUNQ.js";
32
32
  import {
33
33
  memSqlCommand
34
- } from "./chunk-GKAIRI4Y.js";
34
+ } from "./chunk-IPAVHPRZ.js";
35
35
  import {
36
36
  collectIdentityKeys,
37
37
  countRecords,
@@ -62,7 +62,7 @@ import {
62
62
  writeDraftProfile,
63
63
  writePageToMemory,
64
64
  writeProfile
65
- } from "./chunk-YTM6HJKA.js";
65
+ } from "./chunk-SN6WYDOE.js";
66
66
  import {
67
67
  getByDotPath
68
68
  } from "./chunk-44CV5IMX.js";
@@ -86,7 +86,7 @@ import {
86
86
  semanticSearchUpgradeLine,
87
87
  setAgentMode,
88
88
  silenceWarningsInAgentMode
89
- } from "./chunk-OLQ55K6B.js";
89
+ } from "./chunk-FUCAK5RA.js";
90
90
  import {
91
91
  SCHEMA_VERSION,
92
92
  addRecord,
@@ -96,7 +96,7 @@ import {
96
96
  listBackendPlugins,
97
97
  loadBackendFromConfig,
98
98
  updateRecord
99
- } from "./chunk-IMU2X3ZV.js";
99
+ } from "./chunk-NOPTG4GC.js";
100
100
  import {
101
101
  DEFAULT_MEMORY_CONFIG,
102
102
  defaultSearchableText,
@@ -106,7 +106,7 @@ import {
106
106
  memoryConfigExists,
107
107
  setOpenAiApiKey,
108
108
  updateMemoryConfig
109
- } from "./chunk-YMUY55U2.js";
109
+ } from "./chunk-3HRC3IPE.js";
110
110
  import {
111
111
  appendAnalyticsQueue,
112
112
  appendUsageLog,
@@ -143,7 +143,7 @@ import {
143
143
  writeConfig,
144
144
  writeUsageLog,
145
145
  writeUsageState
146
- } from "./chunk-6UB623BG.js";
146
+ } from "./chunk-HTXZZQ6U.js";
147
147
 
148
148
  // src/cli.ts
149
149
  import { createRequire as createRequire3 } from "module";
@@ -1543,7 +1543,8 @@ function startCallbackServer(expectedState) {
1543
1543
  const grant = cleanParam(url.searchParams.get("grant"), MAX_GRANT_LENGTH);
1544
1544
  res.writeHead(200, { "Content-Type": "text/html" });
1545
1545
  res.end(SUCCESS_HTML);
1546
- resolveResult({ kind: "key", apiKey, keyName, grant });
1546
+ const knowledgeOnly = url.searchParams.get("knowledge") === "1";
1547
+ resolveResult({ kind: "key", apiKey, keyName, grant, knowledgeOnly });
1547
1548
  return;
1548
1549
  }
1549
1550
  const error2 = cleanParam(url.searchParams.get("error"), MAX_ERROR_LENGTH);
@@ -1655,7 +1656,13 @@ ${describeInstallContext(context)}`
1655
1656
  const apiBase = getApiBase();
1656
1657
  const api = new OneApi(outcome.apiKey, apiBase);
1657
1658
  const whoami = await api.whoami();
1658
- return { apiKey: outcome.apiKey, whoami, keyName: outcome.keyName, grant: outcome.grant };
1659
+ return {
1660
+ apiKey: outcome.apiKey,
1661
+ whoami,
1662
+ keyName: outcome.keyName,
1663
+ grant: outcome.grant,
1664
+ knowledgeOnly: outcome.knowledgeOnly
1665
+ };
1659
1666
  } catch (err) {
1660
1667
  spin.stop("Authentication failed.");
1661
1668
  if (err instanceof Error && err.message === "timeout") {
@@ -1714,8 +1721,8 @@ async function loginCommand() {
1714
1721
  }
1715
1722
  const result = await browserLogin({ scope: targetScope });
1716
1723
  if (!result) return;
1717
- const { apiKey, whoami, keyName, grant } = result;
1718
- saveCredentials(apiKey, targetScope, { keyName, whoami });
1724
+ const { apiKey, whoami, keyName, grant, knowledgeOnly } = result;
1725
+ saveCredentials(apiKey, targetScope, { keyName, whoami, knowledgeOnly });
1719
1726
  const pc16 = (await import("picocolors")).default;
1720
1727
  const env = getEnvFromApiKey(apiKey);
1721
1728
  const contextParts = [];
@@ -1787,6 +1794,7 @@ async function nonInteractiveInit(options) {
1787
1794
  let apiKey;
1788
1795
  let keyName;
1789
1796
  let grant;
1797
+ let knowledgeOnly;
1790
1798
  let whoami;
1791
1799
  if (auth === "browser") {
1792
1800
  const result = await browserLogin({ scope });
@@ -1796,6 +1804,7 @@ async function nonInteractiveInit(options) {
1796
1804
  apiKey = result.apiKey;
1797
1805
  keyName = result.keyName;
1798
1806
  grant = result.grant;
1807
+ knowledgeOnly = result.knowledgeOnly;
1799
1808
  whoami = result.whoami;
1800
1809
  } else {
1801
1810
  const key = options.apiKey?.trim();
@@ -1819,7 +1828,7 @@ async function nonInteractiveInit(options) {
1819
1828
  apiKey = key;
1820
1829
  whoami = validated;
1821
1830
  }
1822
- saveCredentials(apiKey, scope, { keyName, whoami });
1831
+ saveCredentials(apiKey, scope, { keyName, whoami, knowledgeOnly });
1823
1832
  if (options.openaiKey?.trim()) {
1824
1833
  try {
1825
1834
  setOpenAiApiKey(options.openaiKey.trim());
@@ -2057,6 +2066,7 @@ async function handleUpdateKey(statuses, scope) {
2057
2066
  let newKey;
2058
2067
  let keyName;
2059
2068
  let grant;
2069
+ let knowledgeOnly;
2060
2070
  let whoamiResult;
2061
2071
  if (authMethod === "browser") {
2062
2072
  const result = await browserLogin({ scope });
@@ -2067,6 +2077,7 @@ async function handleUpdateKey(statuses, scope) {
2067
2077
  newKey = result.apiKey;
2068
2078
  keyName = result.keyName;
2069
2079
  grant = result.grant;
2080
+ knowledgeOnly = result.knowledgeOnly;
2070
2081
  whoamiResult = result.whoami;
2071
2082
  } else {
2072
2083
  p3.note(`Get your API key at:
@@ -2125,7 +2136,8 @@ ${pc4.cyan(getApiKeyUrl())}`, `API Key ${scopeLabel(scope)}`);
2125
2136
  ].join("\n"),
2126
2137
  "Account"
2127
2138
  );
2128
- const ac = getAccessControl();
2139
+ saveCredentials(newKey, scope, { keyName, whoami: whoamiResult, knowledgeOnly });
2140
+ const ac = (scope === "project" ? readProjectConfig() : readGlobalConfig())?.accessControl ?? {};
2129
2141
  const reinstalled = [];
2130
2142
  for (const s of statuses) {
2131
2143
  if (s.globalMcp) {
@@ -2137,7 +2149,6 @@ ${pc4.cyan(getApiKeyUrl())}`, `API Key ${scopeLabel(scope)}`);
2137
2149
  reinstalled.push(`${s.agent.name} (project)`);
2138
2150
  }
2139
2151
  }
2140
- saveCredentials(newKey, scope, { keyName, whoami: whoamiResult });
2141
2152
  if (reinstalled.length > 0) {
2142
2153
  p3.log.success(`Updated MCP configs: ${reinstalled.join(", ")}`);
2143
2154
  }
@@ -2388,7 +2399,11 @@ async function freshSetup(scope, options) {
2388
2399
  ].join("\n"),
2389
2400
  "Account"
2390
2401
  );
2391
- saveCredentials(apiKey, scope, { keyName: result.keyName, whoami: result.whoami });
2402
+ saveCredentials(apiKey, scope, {
2403
+ keyName: result.keyName,
2404
+ whoami: result.whoami,
2405
+ knowledgeOnly: result.knowledgeOnly
2406
+ });
2392
2407
  } else {
2393
2408
  p3.note(`Get your API key at:
2394
2409
  ${pc4.cyan(getApiKeyUrl())}`, `API Key ${scopeLabel(scope)}`);
@@ -7398,7 +7413,7 @@ async function syncModel(api, profile, options) {
7398
7413
  updateModelState(platform, model, { status: "failed", pagesProcessed, lastCursor }),
7399
7414
  (async () => {
7400
7415
  try {
7401
- const { getBackend: getBackend2 } = await import("./runtime-SX36HGBA.js");
7416
+ const { getBackend: getBackend2 } = await import("./runtime-HLW365HP.js");
7402
7417
  const backend = await getBackend2();
7403
7418
  await Promise.race([
7404
7419
  backend.close(),
@@ -7764,7 +7779,7 @@ async function syncModel(api, profile, options) {
7764
7779
  db.exec(`DROP TABLE IF EXISTS _seen_ids`);
7765
7780
  }
7766
7781
  if (options.toMemory !== false) {
7767
- const backend = await (await import("./runtime-SX36HGBA.js")).getBackend();
7782
+ const backend = await (await import("./runtime-HLW365HP.js")).getBackend();
7768
7783
  const type = `${platform}/${model}`;
7769
7784
  const existing = await backend.listKeysByType(type);
7770
7785
  const sourcePrefix = `${type}:`;
@@ -7865,7 +7880,7 @@ async function syncModel(api, profile, options) {
7865
7880
  let statusCounts;
7866
7881
  if (options.toMemory !== false) {
7867
7882
  try {
7868
- const backend = await (await import("./runtime-SX36HGBA.js")).getBackend();
7883
+ const backend = await (await import("./runtime-HLW365HP.js")).getBackend();
7869
7884
  const typeName = `${platform}/${model}`;
7870
7885
  const [active, archived] = await Promise.all([
7871
7886
  backend.count(typeName, { status: "active" }),
@@ -9587,7 +9602,7 @@ ${result.total} results`);
9587
9602
  }
9588
9603
  }
9589
9604
  async function syncSqlCommand(platformModel, sql) {
9590
- const { syncSqlCommand: runSyncSql } = await import("./sql-SYCWUPNP.js");
9605
+ const { syncSqlCommand: runSyncSql } = await import("./sql-6I4LWPZF.js");
9591
9606
  await runSyncSql(platformModel, sql);
9592
9607
  }
9593
9608
  async function syncDeleteCommand(platformModel, options) {
@@ -9665,7 +9680,7 @@ async function syncDeleteCommand(platformModel, options) {
9665
9680
  async function maybeAutoMigrateLegacy(platform, models) {
9666
9681
  const dbSize = getDatabaseSize(platform);
9667
9682
  if (!dbSize || dbSize === "0 B") return;
9668
- const { getBackend: getBackend2 } = await import("./runtime-SX36HGBA.js");
9683
+ const { getBackend: getBackend2 } = await import("./runtime-HLW365HP.js");
9669
9684
  const backend = await getBackend2();
9670
9685
  let memoryHasData = false;
9671
9686
  for (const model of models) {
@@ -9681,7 +9696,7 @@ async function maybeAutoMigrateLegacy(platform, models) {
9681
9696
  ` detected legacy .one/sync/data/${platform}.db (${dbSize}) \u2014 auto-migrating into memory before sync.
9682
9697
  `
9683
9698
  );
9684
- const { memMigrateCommand: memMigrateCommand3 } = await import("./migrate-TACDLGPD.js");
9699
+ const { memMigrateCommand: memMigrateCommand3 } = await import("./migrate-GN3I6EZM.js");
9685
9700
  await memMigrateCommand3({ platform, yes: true });
9686
9701
  return;
9687
9702
  }
@@ -9690,7 +9705,7 @@ async function maybeAutoMigrateLegacy(platform, models) {
9690
9705
  initialValue: true
9691
9706
  });
9692
9707
  if (p6.isCancel(shouldMigrate) || !shouldMigrate) return;
9693
- const { memMigrateCommand: memMigrateCommand2 } = await import("./migrate-TACDLGPD.js");
9708
+ const { memMigrateCommand: memMigrateCommand2 } = await import("./migrate-GN3I6EZM.js");
9694
9709
  await memMigrateCommand2({ platform, yes: true });
9695
9710
  }
9696
9711
  async function syncSuggestSearchableCommand(platformModel, options = {}) {
@@ -9751,7 +9766,7 @@ async function syncSuggestSearchableCommand(platformModel, options = {}) {
9751
9766
  async function syncListCommand(platform) {
9752
9767
  const profiles = listProfiles(platform);
9753
9768
  const state = await readSyncState();
9754
- const { getBackend: getBackend2 } = await import("./runtime-SX36HGBA.js");
9769
+ const { getBackend: getBackend2 } = await import("./runtime-HLW365HP.js");
9755
9770
  const backend = await getBackend2();
9756
9771
  const syncs = await Promise.all(profiles.map(async (p9) => {
9757
9772
  const modelState = state[p9.platform]?.[p9.model];
@@ -10027,7 +10042,7 @@ function registerSyncSubcommands(sync) {
10027
10042
  await syncSqlCommand(platformModel, sql);
10028
10043
  });
10029
10044
  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) => {
10030
- const { syncSchemaCommand } = await import("./schema-RJC2WQQ6.js");
10045
+ const { syncSchemaCommand } = await import("./schema-G7XYVIZG.js");
10031
10046
  await syncSchemaCommand(platformModel);
10032
10047
  });
10033
10048
  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) => {
@@ -10804,7 +10819,7 @@ async function memDoctorCommand() {
10804
10819
  }
10805
10820
  if (cfg.embedding.provider === "openai") {
10806
10821
  try {
10807
- const { embed: embed2 } = await import("./embedding-OXX4OF65.js");
10822
+ const { embed: embed2 } = await import("./embedding-C7FIKORV.js");
10808
10823
  const result = await embed2("connectivity check");
10809
10824
  checks.push({
10810
10825
  name: "OpenAI embedding provider reachable",
@@ -3,12 +3,12 @@ import {
3
3
  dotPathToJsonbExpr,
4
4
  memMigrateCommand,
5
5
  reviveStringifiedJson
6
- } from "./chunk-YTM6HJKA.js";
6
+ } from "./chunk-SN6WYDOE.js";
7
7
  import "./chunk-44CV5IMX.js";
8
- import "./chunk-OLQ55K6B.js";
9
- import "./chunk-IMU2X3ZV.js";
10
- import "./chunk-YMUY55U2.js";
11
- import "./chunk-6UB623BG.js";
8
+ import "./chunk-FUCAK5RA.js";
9
+ import "./chunk-NOPTG4GC.js";
10
+ import "./chunk-3HRC3IPE.js";
11
+ import "./chunk-HTXZZQ6U.js";
12
12
  export {
13
13
  buildIdentityMap,
14
14
  dotPathToJsonbExpr,
@@ -5,9 +5,9 @@ import {
5
5
  resetBackendSingleton,
6
6
  updateRecord,
7
7
  upsertRecord
8
- } from "./chunk-IMU2X3ZV.js";
9
- import "./chunk-YMUY55U2.js";
10
- import "./chunk-6UB623BG.js";
8
+ } from "./chunk-NOPTG4GC.js";
9
+ import "./chunk-3HRC3IPE.js";
10
+ import "./chunk-HTXZZQ6U.js";
11
11
  export {
12
12
  addRecord,
13
13
  closeBackendIfCached,
@@ -3,12 +3,12 @@ import {
3
3
  note,
4
4
  okJson,
5
5
  requireMemoryInit
6
- } from "./chunk-OLQ55K6B.js";
6
+ } from "./chunk-FUCAK5RA.js";
7
7
  import {
8
8
  getBackend
9
- } from "./chunk-IMU2X3ZV.js";
10
- import "./chunk-YMUY55U2.js";
11
- import "./chunk-6UB623BG.js";
9
+ } from "./chunk-NOPTG4GC.js";
10
+ import "./chunk-3HRC3IPE.js";
11
+ import "./chunk-HTXZZQ6U.js";
12
12
 
13
13
  // src/lib/memory/sync/schema.ts
14
14
  import pc from "picocolors";
@@ -0,0 +1,12 @@
1
+ import {
2
+ memSqlCommand,
3
+ syncSqlCommand
4
+ } from "./chunk-IPAVHPRZ.js";
5
+ import "./chunk-FUCAK5RA.js";
6
+ import "./chunk-NOPTG4GC.js";
7
+ import "./chunk-3HRC3IPE.js";
8
+ import "./chunk-HTXZZQ6U.js";
9
+ export {
10
+ memSqlCommand,
11
+ syncSqlCommand
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withone/cli",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "description": "CLI for managing One",
5
5
  "type": "module",
6
6
  "files": [
@@ -1,12 +0,0 @@
1
- import {
2
- memSqlCommand,
3
- syncSqlCommand
4
- } from "./chunk-GKAIRI4Y.js";
5
- import "./chunk-OLQ55K6B.js";
6
- import "./chunk-IMU2X3ZV.js";
7
- import "./chunk-YMUY55U2.js";
8
- import "./chunk-6UB623BG.js";
9
- export {
10
- memSqlCommand,
11
- syncSqlCommand
12
- };