@kodycodes/cli 3.11.0 → 3.12.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.
Files changed (80) hide show
  1. package/README.md +34 -8
  2. package/dist/api-token.d.ts +3 -0
  3. package/dist/{auth-YYGBFLBJ.js → auth-2ZIZDLPY.js} +5 -4
  4. package/dist/bin.js +7 -6
  5. package/dist/bin.js.map +1 -1
  6. package/dist/{chunk-CASZNLFR.js → chunk-2ATDBLEX.js} +136 -159
  7. package/dist/chunk-2ATDBLEX.js.map +6 -0
  8. package/dist/{chunk-7YASVU4K.js → chunk-3KNFRULE.js} +2 -2
  9. package/dist/{chunk-6XTF3YD5.js → chunk-3NV6G54V.js} +6 -6
  10. package/dist/{chunk-GY3OE2RC.js → chunk-6N43NCYD.js} +4 -4
  11. package/dist/{chunk-L225BIT7.js → chunk-CDFCKKEC.js} +1 -1
  12. package/dist/{chunk-L225BIT7.js.map → chunk-CDFCKKEC.js.map} +1 -1
  13. package/dist/{chunk-TVDOUKXV.js → chunk-DINK4SRI.js} +3 -3
  14. package/dist/{chunk-LD6ND6Z3.js → chunk-EGN6A45D.js} +3 -3
  15. package/dist/{chunk-VZ5Q5FIR.js → chunk-PQBZATM7.js} +3 -3
  16. package/dist/{chunk-T2UI7XR3.js → chunk-R62L6MWH.js} +6 -4
  17. package/dist/chunk-R62L6MWH.js.map +6 -0
  18. package/dist/{chunk-AZ6UXLP6.js → chunk-SUR4SJXS.js} +31 -125
  19. package/dist/chunk-SUR4SJXS.js.map +6 -0
  20. package/dist/{chunk-HTMEGJAJ.js → chunk-TJRNKHE6.js} +21 -7
  21. package/dist/chunk-TJRNKHE6.js.map +6 -0
  22. package/dist/chunk-UHBPB4VH.js +255 -0
  23. package/dist/chunk-UHBPB4VH.js.map +6 -0
  24. package/dist/{chunk-PMHSFJLB.js → chunk-VUUVCVAG.js} +2 -2
  25. package/dist/cli-credential.d.ts +86 -0
  26. package/dist/cli.d.ts +11 -24
  27. package/dist/cli.js +9 -8
  28. package/dist/commands-PVXABMWK.js +2524 -0
  29. package/dist/commands-PVXABMWK.js.map +6 -0
  30. package/dist/{dev-command-W4EXL7SE.js → dev-command-BTJ4WJEQ.js} +8 -7
  31. package/dist/dev-command-BTJ4WJEQ.js.map +6 -0
  32. package/dist/execution-context/client.d.ts +4 -1
  33. package/dist/execution-context/commands.d.ts +11 -1
  34. package/dist/execution-context/daemon.d.ts +12 -2
  35. package/dist/execution-context/keystore.d.ts +32 -2
  36. package/dist/execution-context/service-commands.d.ts +75 -0
  37. package/dist/execution-context/service.d.ts +157 -0
  38. package/dist/{git-credential-M4RC3D5E.js → git-credential-AGHABRZZ.js} +6 -5
  39. package/dist/git-credential-AGHABRZZ.js.map +6 -0
  40. package/dist/{local-execute-ALYHHP6M.js → local-execute-NLJGGADH.js} +6 -5
  41. package/dist/{local-package-graph-GREJNPV5.js → local-package-graph-M7U7DQ2N.js} +4 -3
  42. package/dist/{local-package-run-LMJ5XYA5.js → local-package-run-Z2ITZ6KO.js} +8 -7
  43. package/dist/{mock-dep-resolve-ZSTZP6F7.js → mock-dep-resolve-DANXDGZU.js} +6 -5
  44. package/dist/mock-dep-resolve-DANXDGZU.js.map +6 -0
  45. package/dist/{mock-local-deps-WZDGHV7Z.js → mock-local-deps-CNFLGJSA.js} +5 -4
  46. package/dist/{open-api-client-CFFUM66I.js → open-api-client-ZK5T7PIZ.js} +4 -3
  47. package/dist/{remote-execute-3VJIHSVF.js → remote-execute-7KZCU5FK.js} +4 -3
  48. package/dist/remote-execute-7KZCU5FK.js.map +6 -0
  49. package/dist/{run-executor-NNH65ODC.js → run-executor-RHSAGN2Z.js} +8 -7
  50. package/dist/run-executor-RHSAGN2Z.js.map +6 -0
  51. package/dist/{setup-git-RAWSZAB2.js → setup-git-67N7Q2BR.js} +5 -4
  52. package/dist/whoami-SMZ4U5QQ.js +114 -0
  53. package/dist/whoami-SMZ4U5QQ.js.map +6 -0
  54. package/dist/whoami.d.ts +22 -0
  55. package/package.json +1 -1
  56. package/dist/chunk-AZ6UXLP6.js.map +0 -6
  57. package/dist/chunk-CASZNLFR.js.map +0 -6
  58. package/dist/chunk-HTMEGJAJ.js.map +0 -6
  59. package/dist/chunk-T2UI7XR3.js.map +0 -6
  60. package/dist/commands-DOND3A3A.js +0 -1217
  61. package/dist/commands-DOND3A3A.js.map +0 -6
  62. package/dist/dev-command-W4EXL7SE.js.map +0 -6
  63. package/dist/git-credential-M4RC3D5E.js.map +0 -6
  64. package/dist/mock-dep-resolve-ZSTZP6F7.js.map +0 -6
  65. package/dist/remote-execute-3VJIHSVF.js.map +0 -6
  66. package/dist/run-executor-NNH65ODC.js.map +0 -6
  67. /package/dist/{auth-YYGBFLBJ.js.map → auth-2ZIZDLPY.js.map} +0 -0
  68. /package/dist/{chunk-7YASVU4K.js.map → chunk-3KNFRULE.js.map} +0 -0
  69. /package/dist/{chunk-6XTF3YD5.js.map → chunk-3NV6G54V.js.map} +0 -0
  70. /package/dist/{chunk-GY3OE2RC.js.map → chunk-6N43NCYD.js.map} +0 -0
  71. /package/dist/{chunk-TVDOUKXV.js.map → chunk-DINK4SRI.js.map} +0 -0
  72. /package/dist/{chunk-LD6ND6Z3.js.map → chunk-EGN6A45D.js.map} +0 -0
  73. /package/dist/{chunk-VZ5Q5FIR.js.map → chunk-PQBZATM7.js.map} +0 -0
  74. /package/dist/{chunk-PMHSFJLB.js.map → chunk-VUUVCVAG.js.map} +0 -0
  75. /package/dist/{local-execute-ALYHHP6M.js.map → local-execute-NLJGGADH.js.map} +0 -0
  76. /package/dist/{local-package-graph-GREJNPV5.js.map → local-package-graph-M7U7DQ2N.js.map} +0 -0
  77. /package/dist/{local-package-run-LMJ5XYA5.js.map → local-package-run-Z2ITZ6KO.js.map} +0 -0
  78. /package/dist/{mock-local-deps-WZDGHV7Z.js.map → mock-local-deps-CNFLGJSA.js.map} +0 -0
  79. /package/dist/{open-api-client-CFFUM66I.js.map → open-api-client-ZK5T7PIZ.js.map} +0 -0
  80. /package/dist/{setup-git-RAWSZAB2.js.map → setup-git-67N7Q2BR.js.map} +0 -0
@@ -17,7 +17,7 @@ import {
17
17
  } from "./chunk-SLNAWWQK.js";
18
18
  import {
19
19
  resolveLocalExecuteBearer
20
- } from "./chunk-HTMEGJAJ.js";
20
+ } from "./chunk-TJRNKHE6.js";
21
21
  import {
22
22
  assertLocalExecuteNodeEngine
23
23
  } from "./chunk-2XPH7L2P.js";
@@ -30,7 +30,7 @@ import {
30
30
  parseCliScopesFlag,
31
31
  refreshGitCredentialHelperPinIfNeeded,
32
32
  resolveCliTokenLifetime
33
- } from "./chunk-T2UI7XR3.js";
33
+ } from "./chunk-R62L6MWH.js";
34
34
  import {
35
35
  orgEnvVar,
36
36
  orgSlugFromFlag
@@ -43,14 +43,18 @@ import {
43
43
  } from "./chunk-46IJPEID.js";
44
44
  import {
45
45
  cliBootstrapMintCall,
46
+ parseCredentialFlags,
47
+ readPackageVersion
48
+ } from "./chunk-SUR4SJXS.js";
49
+ import {
46
50
  deleteStoredApiToken,
47
- hasExplicitTokenFlag,
51
+ describeCliCredential,
48
52
  loadStoredApiToken,
49
- parseCredentialFlags,
50
- readPackageVersion,
51
- requireApiToken,
52
- resolveScopedApiToken
53
- } from "./chunk-AZ6UXLP6.js";
53
+ noteActiveLoginCredential,
54
+ replaceStoredTokenCommand,
55
+ resetActiveCliCredential,
56
+ resolveCliCredential
57
+ } from "./chunk-UHBPB4VH.js";
54
58
  import {
55
59
  deleteCredentials,
56
60
  listStoredOrgs,
@@ -123,7 +127,12 @@ Usage:
123
127
  kody context revoke <name|ec id> | kody context delete <name|ec id> [--org <slug>] [--json]
124
128
  kody context policy [show] | allow <path> [--mode ro|rw] | remove <path> [--json]
125
129
  kody chain show | add <name> | remove <name> [--org <slug>] [--json]
130
+ kody connect --name <name> [--org <slug>] [--no-install] [--key-storage keyring|file] [--yes]
126
131
  kody daemon [--context <ec id>] [--max-concurrent <n>]
132
+ kody daemon install [--context <ec id>] [--max-concurrent <n>] [--key-storage keyring|file] [--yes]
133
+ kody daemon status [--context <ec id>] [--json] | logs [--lines <n>] [--follow] | restart
134
+ kody daemon uninstall [--context <ec id>] [--unregister | --no-unregister]
135
+ kody update
127
136
  [--credential <key=name>]\u2026 [--context <id|name>] [--fallback chain] [--requires fs,lan] [--chain <a,b,cloud>] [--target prod|mock] [--token <token>] [--api-url <url>] [--local] [--allow-private-network]
128
137
  kody dev [serve] [--org <slug>] [--target prod|mock] [--reset-storage] [--port <n>] [--app-base-path <path>] [--allow-private-network] [--no-live-reload] [--json] [--ready-file <path>]
129
138
  kody dev fetch <path> [--method <verb>] [--body <file>] [--target prod|mock] [--json] [--no-attach]
@@ -134,6 +143,14 @@ Usage:
134
143
  kody install [--mcp-url <url>] [--clients <ids>] [--yes] [--project] [--json]
135
144
  kody skill install [--project]
136
145
 
146
+ kody connect registers this machine as an execution context and installs
147
+ \`kody daemon\` as a per-user background service (systemd --user on Linux,
148
+ a LaunchAgent on macOS) so it starts at boot and restarts after crashes.
149
+ \`kody daemon status\` names each problem with the command that fixes it;
150
+ re-running \`kody daemon install\` repairs the service. Windows is not
151
+ supported yet: keep \`kody daemon\` running in a terminal. \`kody update\`
152
+ installs the latest CLI and restarts services after runs in flight finish.
153
+
137
154
  kody context, chain, and daemon need execution contexts, an experiment.
138
155
  Turn it on at https://kody.codes/account/experiments (guide:
139
156
  https://kody.codes/docs/execution-contexts).
@@ -287,12 +304,15 @@ ${orgBlock}
287
304
  with \`--json\`.
288
305
 
289
306
  --token / ${apiTokenEnvVar}
290
- Scoped API token (preferred via env). With no \`kody login\`
291
- session, search / whoami / api / execute use the Open API and
292
- CapabilityProxy \u2014 including cloud execute without --local.
293
- Auth priority matches \`execute --local\`: \`--token\` /
294
- ${apiTokenEnvVar}; stored bootstrap/API token from
295
- \`auth bootstrap\`; then \`kody login\` where applicable.
307
+ Scoped API token (preferred via env). One resolver picks the
308
+ credential, and \`kody whoami\` reports that pick:
309
+ whoami, api, package, execute --local, context, daemon, dev:
310
+ --token, ${apiTokenEnvVar}, stored API token, kody login.
311
+ search and cloud execute: --token, kody login (MCP),
312
+ ${apiTokenEnvVar}, stored API token.
313
+ \`kody login\` does not replace a stored API token; replace it
314
+ with \`kody auth bootstrap --lifetime short --scopes <list>\`
315
+ or clear it with \`kody logout\`.
296
316
  Prefer \`cliCredentialBootstrap\` then \`auth bootstrap\`
297
317
  (\`--lifetime short|long\`). CI/headless: \`tokenCreate\` with
298
318
  \`org:execute\` plus the capability scopes you need.
@@ -735,6 +755,7 @@ async function runPackageCollaboratorPlan(input) {
735
755
  // src/cli.ts
736
756
  var orgScopedCommands = /* @__PURE__ */ new Set([
737
757
  "context",
758
+ "connect",
738
759
  "chain",
739
760
  "login",
740
761
  "logout",
@@ -782,6 +803,13 @@ var cliFlagOptions = {
782
803
  context: { type: "string" },
783
804
  mode: { type: "string" },
784
805
  "max-concurrent": { type: "string" },
806
+ install: { type: "boolean" },
807
+ "no-install": { type: "boolean" },
808
+ "key-storage": { type: "string" },
809
+ lines: { type: "string" },
810
+ follow: { type: "boolean", short: "f" },
811
+ unregister: { type: "boolean" },
812
+ "no-unregister": { type: "boolean" },
785
813
  fallback: { type: "string" },
786
814
  requires: { type: "string" },
787
815
  chain: { type: "string" },
@@ -847,6 +875,8 @@ function resolveCommand(argv) {
847
875
  case "context":
848
876
  case "chain":
849
877
  case "daemon":
878
+ case "connect":
879
+ case "update":
850
880
  return { command: raw, positionals: positionals.slice(1), values };
851
881
  default:
852
882
  throw new Error(
@@ -878,6 +908,7 @@ async function runCli(argv = process.argv.slice(2), io = {}) {
878
908
  });
879
909
  }
880
910
  const jsonFlag = argvIncludesJsonFlag(argv);
911
+ resetActiveCliCredential();
881
912
  try {
882
913
  const parsed = resolveCommand(argv);
883
914
  const helpMcpUrl = mcpUrlFrom({
@@ -981,11 +1012,13 @@ async function dispatch(parsed, write, writeErr) {
981
1012
  return 0;
982
1013
  case "context":
983
1014
  case "chain":
984
- case "daemon": {
1015
+ case "daemon":
1016
+ case "connect":
1017
+ case "update": {
985
1018
  const apiUrl = apiUrlFrom({
986
1019
  apiUrl: typeof parsed.values["api-url"] === "string" ? parsed.values["api-url"] : void 0
987
1020
  });
988
- const { runExecutionContextCommand } = await import("./commands-DOND3A3A.js");
1021
+ const { runExecutionContextCommand } = await import("./commands-PVXABMWK.js");
989
1022
  return await runExecutionContextCommand({
990
1023
  command: parsed.command,
991
1024
  positionals: parsed.positionals,
@@ -994,6 +1027,12 @@ async function dispatch(parsed, write, writeErr) {
994
1027
  ...typeof parsed.values.context === "string" ? { context: parsed.values.context } : {},
995
1028
  ...typeof parsed.values.mode === "string" ? { mode: parsed.values.mode } : {},
996
1029
  ...parsed.values["max-concurrent"] !== void 0 ? { maxConcurrent: String(parsed.values["max-concurrent"]) } : {},
1030
+ ...parsed.values.yes === true ? { yes: true } : {},
1031
+ ...parsed.values["no-install"] === true ? { install: false } : parsed.values.install === true ? { install: true } : {},
1032
+ ...typeof parsed.values["key-storage"] === "string" ? { keyStorage: parsed.values["key-storage"] } : {},
1033
+ ...typeof parsed.values.lines === "string" ? { lines: parsed.values.lines } : {},
1034
+ ...parsed.values.follow === true ? { follow: true } : {},
1035
+ ...parsed.values["no-unregister"] === true ? { unregister: false } : parsed.values.unregister === true ? { unregister: true } : {},
997
1036
  json
998
1037
  },
999
1038
  apiUrl,
@@ -1009,7 +1048,7 @@ async function dispatch(parsed, write, writeErr) {
1009
1048
  });
1010
1049
  }
1011
1050
  case "login": {
1012
- const { login, loginWithDevice } = await import("./auth-YYGBFLBJ.js");
1051
+ const { login, loginWithDevice } = await import("./auth-2ZIZDLPY.js");
1013
1052
  const openBrowser = parsed.values["no-browser"] !== true;
1014
1053
  const lifetimeOption = typeof parsed.values.lifetime === "string" ? {
1015
1054
  lifetime: parsed.values.lifetime === "short" ? "short" : "long"
@@ -1026,6 +1065,7 @@ async function dispatch(parsed, write, writeErr) {
1026
1065
  onDeviceCode: (prompt) => write(formatDeviceLoginNotice(prompt))
1027
1066
  });
1028
1067
  write(formatLoginSuccess(result2));
1068
+ write(storedApiTokenAfterLoginNotice(loginApiUrl));
1029
1069
  return 0;
1030
1070
  }
1031
1071
  const headlessReason = openBrowser ? detectHeadlessLoginReason() : null;
@@ -1044,6 +1084,7 @@ async function dispatch(parsed, write, writeErr) {
1044
1084
  }
1045
1085
  });
1046
1086
  write(formatLoginSuccess(result));
1087
+ write(storedApiTokenAfterLoginNotice(loginApiUrl));
1047
1088
  return 0;
1048
1089
  }
1049
1090
  case "logout": {
@@ -1145,6 +1186,12 @@ async function dispatch(parsed, write, writeErr) {
1145
1186
  } else {
1146
1187
  lines.push(`api: ${apiUrl}`, `stored API token: no`);
1147
1188
  }
1189
+ const inUse = resolveCliCredential({ mcpUrl, apiUrl });
1190
+ if (inUse) {
1191
+ lines.push(
1192
+ `credential in use (api, whoami, package): ${describeCliCredential(inUse)}`
1193
+ );
1194
+ }
1148
1195
  lines.push("");
1149
1196
  write(lines.join("\n"));
1150
1197
  return 0;
@@ -1239,7 +1286,7 @@ async function dispatch(parsed, write, writeErr) {
1239
1286
  parseGitCredentialAction,
1240
1287
  parseGitCredentialInput,
1241
1288
  readGitCredentialStdin
1242
- } = await import("./git-credential-M4RC3D5E.js");
1289
+ } = await import("./git-credential-AGHABRZZ.js");
1243
1290
  const action = parseGitCredentialAction(parsed.positionals);
1244
1291
  const raw = await readGitCredentialStdin(process.stdin);
1245
1292
  const output = await handleGitCredential({
@@ -1299,79 +1346,15 @@ async function dispatch(parsed, write, writeErr) {
1299
1346
  if (mock.started) await mock.server.close();
1300
1347
  }
1301
1348
  }
1302
- if (shouldUseApiToken({
1349
+ const { runWhoami } = await import("./whoami-SMZ4U5QQ.js");
1350
+ return await runWhoami({
1303
1351
  tokenValues,
1304
1352
  mcpUrl,
1305
1353
  apiUrl,
1306
- allowEnvWithoutLogin: true,
1307
- ...org ? { org } : {}
1308
- })) {
1309
- const { whoamiWithApiToken: whoamiWithApiToken2 } = await import("./open-api-client-CFFUM66I.js");
1310
- const identity2 = await whoamiWithApiToken2({
1311
- token: requireApiToken(tokenValues, process.env, "whoami", {
1312
- apiUrl
1313
- }),
1314
- apiUrl,
1315
- ...org ? { org } : {}
1316
- });
1317
- if (json) {
1318
- write(`${JSON.stringify(identity2, null, 2)}
1319
- `);
1320
- return 0;
1321
- }
1322
- const scopeLine = identity2.token.scopes.join(", ") || "(none)";
1323
- const userLine2 = identity2.user ? `${identity2.user.displayName} <${identity2.user.email}>` : "(account:read not on this token)";
1324
- write(
1325
- [
1326
- `api: ${identity2.apiUrl}`,
1327
- `auth: API token (${identity2.token.id})`,
1328
- `user: ${userLine2}`,
1329
- `scopes: ${scopeLine}`,
1330
- `expires: ${identity2.token.expiresAt ?? "unknown"}`,
1331
- ""
1332
- ].join("\n")
1333
- );
1334
- return 0;
1335
- }
1336
- const { ensureOpenApiCredentials } = await import("./auth-YYGBFLBJ.js");
1337
- const credentials = await ensureOpenApiCredentials({
1338
- mcpUrl,
1339
- org,
1340
- apiUrl
1341
- });
1342
- const { whoamiWithApiToken } = await import("./open-api-client-CFFUM66I.js");
1343
- const identity = await whoamiWithApiToken({
1344
- token: credentials.accessToken,
1345
- apiUrl,
1354
+ json,
1355
+ write,
1346
1356
  ...org ? { org } : {}
1347
1357
  });
1348
- if (json) {
1349
- write(
1350
- `${JSON.stringify(
1351
- {
1352
- apiUrl: identity.apiUrl,
1353
- org: credentials.org ?? null,
1354
- scope: identity.token.scopes,
1355
- token: identity.token,
1356
- user: identity.user
1357
- },
1358
- null,
1359
- 2
1360
- )}
1361
- `
1362
- );
1363
- return 0;
1364
- }
1365
- const orgLine = credentials.org ? `
1366
- org: ${credentials.org}` : "";
1367
- const userLine = identity.user ? `${identity.user.displayName} <${identity.user.email}>` : "(no profile)";
1368
- write(
1369
- `Logged in at ${identity.apiUrl}${orgLine}
1370
- user: ${userLine}
1371
- scopes: ${identity.token.scopes.join(", ") || "(none)"}
1372
- `
1373
- );
1374
- return 0;
1375
1358
  }
1376
1359
  case "search": {
1377
1360
  const { resolveTarget } = await import("./target-UQBEV64U.js");
@@ -1393,7 +1376,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1393
1376
  });
1394
1377
  apiUrl = mock.apiUrl;
1395
1378
  closeMock = mock.started ? () => mock.server.close() : void 0;
1396
- const { searchWithApiToken: searchWithApiToken2 } = await import("./open-api-client-CFFUM66I.js");
1379
+ const { searchWithApiToken: searchWithApiToken2 } = await import("./open-api-client-ZK5T7PIZ.js");
1397
1380
  const result2 = await searchWithApiToken2({
1398
1381
  token: mock.token,
1399
1382
  apiUrl,
@@ -1405,18 +1388,17 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1405
1388
  write(formatToolResult(result2, json));
1406
1389
  return result2.isError ? 1 : 0;
1407
1390
  }
1408
- if (shouldUseApiToken({
1391
+ const searchCredential = resolveCliCredential({
1409
1392
  tokenValues,
1410
1393
  mcpUrl,
1411
1394
  apiUrl,
1412
- allowEnvWithoutLogin: true,
1395
+ purpose: "session",
1413
1396
  ...org ? { org } : {}
1414
- })) {
1415
- const { searchWithApiToken: searchWithApiToken2 } = await import("./open-api-client-CFFUM66I.js");
1397
+ });
1398
+ if (searchCredential?.token) {
1399
+ const { searchWithApiToken: searchWithApiToken2 } = await import("./open-api-client-ZK5T7PIZ.js");
1416
1400
  const result2 = await searchWithApiToken2({
1417
- token: requireApiToken(tokenValues, process.env, "search", {
1418
- apiUrl
1419
- }),
1401
+ token: searchCredential.token,
1420
1402
  apiUrl,
1421
1403
  ...org ? { org } : {},
1422
1404
  query: query || void 0,
@@ -1427,13 +1409,14 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1427
1409
  write(formatToolResult(result2, json));
1428
1410
  return result2.isError ? 1 : 0;
1429
1411
  }
1430
- const { ensureOpenApiCredentials } = await import("./auth-YYGBFLBJ.js");
1412
+ const { ensureOpenApiCredentials } = await import("./auth-2ZIZDLPY.js");
1431
1413
  const credentials = await ensureOpenApiCredentials({
1432
1414
  mcpUrl,
1433
1415
  org,
1434
1416
  apiUrl
1435
1417
  });
1436
- const { searchWithApiToken } = await import("./open-api-client-CFFUM66I.js");
1418
+ noteActiveLoginCredential({ login: credentials, purpose: "session" });
1419
+ const { searchWithApiToken } = await import("./open-api-client-ZK5T7PIZ.js");
1437
1420
  const result = await searchWithApiToken({
1438
1421
  token: credentials.accessToken,
1439
1422
  apiUrl,
@@ -1491,7 +1474,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1491
1474
  (value) => typeof value === "string"
1492
1475
  ) : typeof parsed.values.credential === "string" ? [parsed.values.credential] : void 0
1493
1476
  );
1494
- const executeRouting = (await import("./remote-execute-3VJIHSVF.js")).executeRoutingFromFlags(parsed.values);
1477
+ const executeRouting = (await import("./remote-execute-7KZCU5FK.js")).executeRoutingFromFlags(parsed.values);
1495
1478
  if (executeRouting && local) {
1496
1479
  writeErr(
1497
1480
  "--context, --fallback, --requires, and --chain route cloud execute; drop --local.\n"
@@ -1547,7 +1530,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1547
1530
  apiUrl = mock.apiUrl;
1548
1531
  mockToken = mock.token;
1549
1532
  closeMock = mock.started ? () => mock.server.close() : void 0;
1550
- const { tryResolveMockDepResolve } = await import("./mock-dep-resolve-ZSTZP6F7.js");
1533
+ const { tryResolveMockDepResolve } = await import("./mock-dep-resolve-DANXDGZU.js");
1551
1534
  mockDepResolve = await tryResolveMockDepResolve({
1552
1535
  tokenValues,
1553
1536
  apiUrl: prodApiUrl,
@@ -1556,7 +1539,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1556
1539
  });
1557
1540
  }
1558
1541
  if (localPackageRun) {
1559
- const { buildLocalPackageContext, runLocalPackageModule } = await import("./local-package-run-LMJ5XYA5.js");
1542
+ const { buildLocalPackageContext, runLocalPackageModule } = await import("./local-package-run-Z2ITZ6KO.js");
1560
1543
  const result2 = await runLocalPackageModule({
1561
1544
  modulePath: localPackageRun.modulePath,
1562
1545
  params: args.params,
@@ -1584,13 +1567,14 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1584
1567
  write(formatToolResult(result2, json));
1585
1568
  return result2.isError ? 1 : 0;
1586
1569
  }
1587
- const useToken = local || shouldUseApiToken({
1570
+ const cloudCredential = local ? null : resolveCliCredential({
1588
1571
  tokenValues,
1589
1572
  mcpUrl,
1590
1573
  apiUrl,
1591
- allowEnvWithoutLogin: true,
1574
+ purpose: "session",
1592
1575
  ...org ? { org } : {}
1593
1576
  });
1577
+ const cloudToken = cloudCredential?.token ?? null;
1594
1578
  let packageRootForMocks;
1595
1579
  if (target === "mock") {
1596
1580
  try {
@@ -1600,7 +1584,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1600
1584
  packageRootForMocks = void 0;
1601
1585
  }
1602
1586
  }
1603
- const result = local ? await (await import("./local-execute-ALYHHP6M.js")).runLocalExecute({
1587
+ const result = local ? await (await import("./local-execute-NLJGGADH.js")).runLocalExecute({
1604
1588
  code: args.code,
1605
1589
  ...modulePath !== void 0 ? { modulePath } : {},
1606
1590
  params: args.params,
@@ -1622,28 +1606,27 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1622
1606
  allowPrivateNetwork: parsed.values["allow-private-network"] === true,
1623
1607
  onStatus: (message) => writeErr(`${message}
1624
1608
  `)
1625
- }) : useToken ? await (await import("./remote-execute-3VJIHSVF.js")).runRemoteExecuteWithToken({
1609
+ }) : cloudToken ? await (await import("./remote-execute-7KZCU5FK.js")).runRemoteExecuteWithToken({
1626
1610
  code: typeof args.code === "string" ? args.code : void 0,
1627
1611
  params: args.params,
1628
1612
  conversationId: args.conversationId,
1629
1613
  ...credentials !== void 0 ? { credentials } : {},
1630
1614
  ...executeRouting ? { routing: executeRouting } : {},
1631
- token: requireApiToken(
1632
- tokenValues,
1633
- process.env,
1634
- "execute with an API token",
1635
- { apiUrl }
1636
- ),
1615
+ token: cloudToken,
1637
1616
  apiUrl,
1638
1617
  ...org ? { org } : {}
1639
1618
  }) : await (async () => {
1640
- const { ensureOpenApiCredentials } = await import("./auth-YYGBFLBJ.js");
1619
+ const { ensureOpenApiCredentials } = await import("./auth-2ZIZDLPY.js");
1641
1620
  const session = await ensureOpenApiCredentials({
1642
1621
  mcpUrl,
1643
1622
  org,
1644
1623
  apiUrl
1645
1624
  });
1646
- return (await import("./remote-execute-3VJIHSVF.js")).runRemoteExecuteWithToken({
1625
+ noteActiveLoginCredential({
1626
+ login: session,
1627
+ purpose: "session"
1628
+ });
1629
+ return (await import("./remote-execute-7KZCU5FK.js")).runRemoteExecuteWithToken({
1647
1630
  code: typeof args.code === "string" ? args.code : void 0,
1648
1631
  params: args.params,
1649
1632
  conversationId: args.conversationId,
@@ -1658,7 +1641,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1658
1641
  return result.isError ? 1 : 0;
1659
1642
  } catch (error) {
1660
1643
  if (json && local) {
1661
- const { LocalPackageGraphError, packageGraphErrorToolResult } = await import("./local-package-graph-GREJNPV5.js");
1644
+ const { LocalPackageGraphError, packageGraphErrorToolResult } = await import("./local-package-graph-M7U7DQ2N.js");
1662
1645
  if (error instanceof LocalPackageGraphError) {
1663
1646
  const redacted = redactError(error).message;
1664
1647
  const result = packageGraphErrorToolResult(error);
@@ -1688,7 +1671,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1688
1671
  runDevServe,
1689
1672
  runDevWebhook,
1690
1673
  tryAttachedDevFetch
1691
- } = await import("./dev-command-W4EXL7SE.js");
1674
+ } = await import("./dev-command-BTJ4WJEQ.js");
1692
1675
  const target = resolveTarget({
1693
1676
  command: "dev",
1694
1677
  flag: typeof parsed.values.target === "string" ? parsed.values.target : void 0
@@ -1714,8 +1697,8 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1714
1697
  { callOpenApiOperation, formatOpenApiHttpDebugLine },
1715
1698
  { parsePackageCheckResult, PublishChecksAuthError }
1716
1699
  ] = await Promise.all([
1717
- import("./open-api-client-CFFUM66I.js"),
1718
- import("./dev-command-W4EXL7SE.js")
1700
+ import("./open-api-client-ZK5T7PIZ.js"),
1701
+ import("./dev-command-BTJ4WJEQ.js")
1719
1702
  ]);
1720
1703
  let token2;
1721
1704
  try {
@@ -1829,7 +1812,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1829
1812
  purpose: "kody dev",
1830
1813
  ...org ? { org } : {}
1831
1814
  }) : "mock";
1832
- const mockDepResolve = target === "mock" ? await (await import("./mock-dep-resolve-ZSTZP6F7.js")).tryResolveMockDepResolve({
1815
+ const mockDepResolve = target === "mock" ? await (await import("./mock-dep-resolve-DANXDGZU.js")).tryResolveMockDepResolve({
1833
1816
  tokenValues,
1834
1817
  apiUrl: prodApiUrl,
1835
1818
  mcpUrl,
@@ -1970,7 +1953,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1970
1953
  const params = parseApiParamsJson(
1971
1954
  typeof parsed.values.params === "string" ? parsed.values.params : void 0
1972
1955
  );
1973
- const { callOpenApiOperation } = await import("./open-api-client-CFFUM66I.js");
1956
+ const { callOpenApiOperation } = await import("./open-api-client-ZK5T7PIZ.js");
1974
1957
  const result = await callOpenApiOperation({
1975
1958
  operationId,
1976
1959
  params,
@@ -2005,7 +1988,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
2005
1988
  mcpUrl,
2006
1989
  org
2007
1990
  });
2008
- const { callOpenApiOperation: callOpenApiOperation2 } = await import("./open-api-client-CFFUM66I.js");
1991
+ const { callOpenApiOperation: callOpenApiOperation2 } = await import("./open-api-client-ZK5T7PIZ.js");
2009
1992
  write(
2010
1993
  await runPackageCollaboratorPlan({
2011
1994
  plan,
@@ -2031,7 +2014,7 @@ ${packageCollaboratorUsage}`
2031
2014
  positional: parsed.positionals[1],
2032
2015
  paramsJson: typeof parsed.values.params === "string" ? parsed.values.params : void 0
2033
2016
  });
2034
- const { callOpenApiOperation } = await import("./open-api-client-CFFUM66I.js");
2017
+ const { callOpenApiOperation } = await import("./open-api-client-ZK5T7PIZ.js");
2035
2018
  const publishToken = await accessTokenForOpenApi({
2036
2019
  tokenValues,
2037
2020
  apiUrl,
@@ -2172,7 +2155,7 @@ function attachExecuteCommonArgs(args, input) {
2172
2155
  return args;
2173
2156
  }
2174
2157
  async function runAuthSetupGit(input) {
2175
- const { authSetupGit, setupGitDefaultScopes } = await import("./setup-git-RAWSZAB2.js");
2158
+ const { authSetupGit, setupGitDefaultScopes } = await import("./setup-git-67N7Q2BR.js");
2176
2159
  const apiUrl = apiUrlFrom({
2177
2160
  apiUrl: typeof input.values["api-url"] === "string" ? input.values["api-url"] : void 0
2178
2161
  });
@@ -2229,7 +2212,7 @@ async function runAuthSetupGit(input) {
2229
2212
  return 0;
2230
2213
  }
2231
2214
  async function runAuthRemoveGit(input) {
2232
- const { authRemoveGit, formatAuthRemoveGitReport } = await import("./setup-git-RAWSZAB2.js");
2215
+ const { authRemoveGit, formatAuthRemoveGitReport } = await import("./setup-git-67N7Q2BR.js");
2233
2216
  const apiUrl = apiUrlFrom({
2234
2217
  apiUrl: typeof input.values["api-url"] === "string" ? input.values["api-url"] : void 0
2235
2218
  });
@@ -2242,22 +2225,16 @@ async function runAuthRemoveGit(input) {
2242
2225
  }
2243
2226
  function bootstrapMinter(input) {
2244
2227
  return async (params) => {
2245
- if (shouldUseApiToken({
2228
+ const minter = resolveCliCredential({
2246
2229
  tokenValues: input.tokenValues,
2247
2230
  mcpUrl: input.mcpUrl,
2248
2231
  apiUrl: input.apiUrl,
2249
- allowEnvWithoutLogin: true,
2232
+ purpose: "mint",
2250
2233
  ...input.org ? { org: input.org } : {}
2251
- })) {
2252
- const token = requireApiToken(
2253
- input.tokenValues,
2254
- process.env,
2255
- "auth bootstrap --scopes",
2256
- {
2257
- apiUrl: input.apiUrl
2258
- }
2259
- );
2260
- const { callOpenApiOperation } = await import("./open-api-client-CFFUM66I.js");
2234
+ });
2235
+ if (minter?.token) {
2236
+ const token = minter.token;
2237
+ const { callOpenApiOperation } = await import("./open-api-client-ZK5T7PIZ.js");
2261
2238
  try {
2262
2239
  return await callOpenApiOperation({
2263
2240
  token,
@@ -2275,16 +2252,14 @@ function bootstrapMinter(input) {
2275
2252
  throw error;
2276
2253
  }
2277
2254
  }
2278
- if (loadCredentials(input.mcpUrl, void 0, void 0, {
2279
- org: input.org
2280
- })) {
2281
- const { ensureOpenApiCredentials } = await import("./auth-YYGBFLBJ.js");
2255
+ if (minter) {
2256
+ const { ensureOpenApiCredentials } = await import("./auth-2ZIZDLPY.js");
2282
2257
  const session = await ensureOpenApiCredentials({
2283
2258
  mcpUrl: input.mcpUrl,
2284
2259
  apiUrl: input.apiUrl,
2285
2260
  ...input.org ? { org: input.org } : {}
2286
2261
  });
2287
- const { callOpenApiOperation } = await import("./open-api-client-CFFUM66I.js");
2262
+ const { callOpenApiOperation } = await import("./open-api-client-ZK5T7PIZ.js");
2288
2263
  return callOpenApiOperation({
2289
2264
  operationId: cliCredentialBootstrapOperationId,
2290
2265
  params,
@@ -2304,18 +2279,20 @@ function tokenFlagValues(values) {
2304
2279
  };
2305
2280
  }
2306
2281
  async function accessTokenForOpenApi(input) {
2307
- const explicit = resolveScopedApiToken({
2282
+ const credential = resolveCliCredential({
2308
2283
  tokenValues: input.tokenValues,
2309
- env: process.env,
2310
- apiUrl: input.apiUrl
2284
+ apiUrl: input.apiUrl,
2285
+ mcpUrl: input.mcpUrl,
2286
+ ...input.org ? { org: input.org } : {}
2311
2287
  });
2312
- if (explicit) return explicit;
2313
- const { ensureOpenApiCredentials } = await import("./auth-YYGBFLBJ.js");
2288
+ if (credential?.token) return credential.token;
2289
+ const { ensureOpenApiCredentials } = await import("./auth-2ZIZDLPY.js");
2314
2290
  const session = await ensureOpenApiCredentials({
2315
2291
  mcpUrl: input.mcpUrl,
2316
2292
  apiUrl: input.apiUrl,
2317
2293
  ...input.org ? { org: input.org } : {}
2318
2294
  });
2295
+ noteActiveLoginCredential({ login: session });
2319
2296
  return session.accessToken;
2320
2297
  }
2321
2298
  function parseApiParamsJson(paramsJson) {
@@ -2363,21 +2340,21 @@ async function resolvePackagePublishTarget(params, call) {
2363
2340
  const { kody_id: _name, ...rest } = params;
2364
2341
  return { ...rest, package_id: matches[0].package_id };
2365
2342
  }
2366
- function shouldUseApiToken(input) {
2367
- if (hasExplicitTokenFlag(input.tokenValues)) return true;
2368
- if (!input.allowEnvWithoutLogin) return false;
2369
- if (!resolveScopedApiToken({
2370
- tokenValues: input.tokenValues,
2371
- env: input.env,
2372
- apiUrl: input.apiUrl,
2373
- loadApiToken: input.loadApiToken
2374
- })) {
2375
- return false;
2343
+ function storedApiTokenAfterLoginNotice(apiUrl, loadApiToken = loadStoredApiToken) {
2344
+ let stored;
2345
+ try {
2346
+ stored = loadApiToken(apiUrl);
2347
+ } catch {
2348
+ return "";
2376
2349
  }
2377
- const loggedIn = input.hasSession ?? loadCredentials(input.mcpUrl, void 0, void 0, {
2378
- org: input.org
2379
- }) != null;
2380
- return !loggedIn;
2350
+ if (!stored) return "";
2351
+ const label = describeCliCredential({
2352
+ source: "stored-api-token",
2353
+ token: stored.token,
2354
+ stored
2355
+ });
2356
+ return `Note: a ${label} is still stored and \`kody login\` does not replace it. api, package, execute --local, context, daemon, and dev keep using it (scopes: ${stored.scopes?.join(", ") || "unknown"}). To change its scopes run \`${replaceStoredTokenCommand(stored.scopes)}\`, or \`kody logout\` to clear it. Check with \`kody whoami\`.
2357
+ `;
2381
2358
  }
2382
2359
 
2383
2360
  export {
@@ -2393,6 +2370,6 @@ export {
2393
2370
  parseApiParamsJson,
2394
2371
  packagePublishParams,
2395
2372
  resolvePackagePublishTarget,
2396
- shouldUseApiToken
2373
+ storedApiTokenAfterLoginNotice
2397
2374
  };
2398
- //# sourceMappingURL=chunk-CASZNLFR.js.map
2375
+ //# sourceMappingURL=chunk-2ATDBLEX.js.map