@kodycodes/cli 3.12.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 (71) 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-NN3I7FJQ.js → chunk-2ATDBLEX.js} +104 -158
  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-TVDOUKXV.js → chunk-DINK4SRI.js} +3 -3
  12. package/dist/{chunk-LD6ND6Z3.js → chunk-EGN6A45D.js} +3 -3
  13. package/dist/{chunk-VZ5Q5FIR.js → chunk-PQBZATM7.js} +3 -3
  14. package/dist/{chunk-T2UI7XR3.js → chunk-R62L6MWH.js} +6 -4
  15. package/dist/chunk-R62L6MWH.js.map +6 -0
  16. package/dist/{chunk-AZ6UXLP6.js → chunk-SUR4SJXS.js} +31 -125
  17. package/dist/chunk-SUR4SJXS.js.map +6 -0
  18. package/dist/{chunk-HTMEGJAJ.js → chunk-TJRNKHE6.js} +21 -7
  19. package/dist/chunk-TJRNKHE6.js.map +6 -0
  20. package/dist/chunk-UHBPB4VH.js +255 -0
  21. package/dist/chunk-UHBPB4VH.js.map +6 -0
  22. package/dist/{chunk-PMHSFJLB.js → chunk-VUUVCVAG.js} +2 -2
  23. package/dist/cli-credential.d.ts +86 -0
  24. package/dist/cli.d.ts +3 -23
  25. package/dist/cli.js +9 -8
  26. package/dist/{commands-LSLLUXHL.js → commands-PVXABMWK.js} +5 -4
  27. package/dist/commands-PVXABMWK.js.map +6 -0
  28. package/dist/{dev-command-W4EXL7SE.js → dev-command-BTJ4WJEQ.js} +8 -7
  29. package/dist/dev-command-BTJ4WJEQ.js.map +6 -0
  30. package/dist/{git-credential-M4RC3D5E.js → git-credential-AGHABRZZ.js} +6 -5
  31. package/dist/git-credential-AGHABRZZ.js.map +6 -0
  32. package/dist/{local-execute-ALYHHP6M.js → local-execute-NLJGGADH.js} +6 -5
  33. package/dist/{local-package-graph-GREJNPV5.js → local-package-graph-M7U7DQ2N.js} +4 -3
  34. package/dist/{local-package-run-LMJ5XYA5.js → local-package-run-Z2ITZ6KO.js} +8 -7
  35. package/dist/{mock-dep-resolve-ZSTZP6F7.js → mock-dep-resolve-DANXDGZU.js} +6 -5
  36. package/dist/mock-dep-resolve-DANXDGZU.js.map +6 -0
  37. package/dist/{mock-local-deps-WZDGHV7Z.js → mock-local-deps-CNFLGJSA.js} +5 -4
  38. package/dist/{open-api-client-CFFUM66I.js → open-api-client-ZK5T7PIZ.js} +4 -3
  39. package/dist/{remote-execute-3VJIHSVF.js → remote-execute-7KZCU5FK.js} +4 -3
  40. package/dist/remote-execute-7KZCU5FK.js.map +6 -0
  41. package/dist/{run-executor-7CL5RXNG.js → run-executor-RHSAGN2Z.js} +7 -6
  42. package/dist/run-executor-RHSAGN2Z.js.map +6 -0
  43. package/dist/{setup-git-RAWSZAB2.js → setup-git-67N7Q2BR.js} +5 -4
  44. package/dist/whoami-SMZ4U5QQ.js +114 -0
  45. package/dist/whoami-SMZ4U5QQ.js.map +6 -0
  46. package/dist/whoami.d.ts +22 -0
  47. package/package.json +1 -1
  48. package/dist/chunk-AZ6UXLP6.js.map +0 -6
  49. package/dist/chunk-HTMEGJAJ.js.map +0 -6
  50. package/dist/chunk-NN3I7FJQ.js.map +0 -6
  51. package/dist/chunk-T2UI7XR3.js.map +0 -6
  52. package/dist/commands-LSLLUXHL.js.map +0 -6
  53. package/dist/dev-command-W4EXL7SE.js.map +0 -6
  54. package/dist/git-credential-M4RC3D5E.js.map +0 -6
  55. package/dist/mock-dep-resolve-ZSTZP6F7.js.map +0 -6
  56. package/dist/remote-execute-3VJIHSVF.js.map +0 -6
  57. package/dist/run-executor-7CL5RXNG.js.map +0 -6
  58. /package/dist/{auth-YYGBFLBJ.js.map → auth-2ZIZDLPY.js.map} +0 -0
  59. /package/dist/{chunk-7YASVU4K.js.map → chunk-3KNFRULE.js.map} +0 -0
  60. /package/dist/{chunk-6XTF3YD5.js.map → chunk-3NV6G54V.js.map} +0 -0
  61. /package/dist/{chunk-GY3OE2RC.js.map → chunk-6N43NCYD.js.map} +0 -0
  62. /package/dist/{chunk-TVDOUKXV.js.map → chunk-DINK4SRI.js.map} +0 -0
  63. /package/dist/{chunk-LD6ND6Z3.js.map → chunk-EGN6A45D.js.map} +0 -0
  64. /package/dist/{chunk-VZ5Q5FIR.js.map → chunk-PQBZATM7.js.map} +0 -0
  65. /package/dist/{chunk-PMHSFJLB.js.map → chunk-VUUVCVAG.js.map} +0 -0
  66. /package/dist/{local-execute-ALYHHP6M.js.map → local-execute-NLJGGADH.js.map} +0 -0
  67. /package/dist/{local-package-graph-GREJNPV5.js.map → local-package-graph-M7U7DQ2N.js.map} +0 -0
  68. /package/dist/{local-package-run-LMJ5XYA5.js.map → local-package-run-Z2ITZ6KO.js.map} +0 -0
  69. /package/dist/{mock-local-deps-WZDGHV7Z.js.map → mock-local-deps-CNFLGJSA.js.map} +0 -0
  70. /package/dist/{open-api-client-CFFUM66I.js.map → open-api-client-ZK5T7PIZ.js.map} +0 -0
  71. /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,
@@ -300,12 +304,15 @@ ${orgBlock}
300
304
  with \`--json\`.
301
305
 
302
306
  --token / ${apiTokenEnvVar}
303
- Scoped API token (preferred via env). With no \`kody login\`
304
- session, search / whoami / api / execute use the Open API and
305
- CapabilityProxy \u2014 including cloud execute without --local.
306
- Auth priority matches \`execute --local\`: \`--token\` /
307
- ${apiTokenEnvVar}; stored bootstrap/API token from
308
- \`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\`.
309
316
  Prefer \`cliCredentialBootstrap\` then \`auth bootstrap\`
310
317
  (\`--lifetime short|long\`). CI/headless: \`tokenCreate\` with
311
318
  \`org:execute\` plus the capability scopes you need.
@@ -901,6 +908,7 @@ async function runCli(argv = process.argv.slice(2), io = {}) {
901
908
  });
902
909
  }
903
910
  const jsonFlag = argvIncludesJsonFlag(argv);
911
+ resetActiveCliCredential();
904
912
  try {
905
913
  const parsed = resolveCommand(argv);
906
914
  const helpMcpUrl = mcpUrlFrom({
@@ -1010,7 +1018,7 @@ async function dispatch(parsed, write, writeErr) {
1010
1018
  const apiUrl = apiUrlFrom({
1011
1019
  apiUrl: typeof parsed.values["api-url"] === "string" ? parsed.values["api-url"] : void 0
1012
1020
  });
1013
- const { runExecutionContextCommand } = await import("./commands-LSLLUXHL.js");
1021
+ const { runExecutionContextCommand } = await import("./commands-PVXABMWK.js");
1014
1022
  return await runExecutionContextCommand({
1015
1023
  command: parsed.command,
1016
1024
  positionals: parsed.positionals,
@@ -1040,7 +1048,7 @@ async function dispatch(parsed, write, writeErr) {
1040
1048
  });
1041
1049
  }
1042
1050
  case "login": {
1043
- const { login, loginWithDevice } = await import("./auth-YYGBFLBJ.js");
1051
+ const { login, loginWithDevice } = await import("./auth-2ZIZDLPY.js");
1044
1052
  const openBrowser = parsed.values["no-browser"] !== true;
1045
1053
  const lifetimeOption = typeof parsed.values.lifetime === "string" ? {
1046
1054
  lifetime: parsed.values.lifetime === "short" ? "short" : "long"
@@ -1057,6 +1065,7 @@ async function dispatch(parsed, write, writeErr) {
1057
1065
  onDeviceCode: (prompt) => write(formatDeviceLoginNotice(prompt))
1058
1066
  });
1059
1067
  write(formatLoginSuccess(result2));
1068
+ write(storedApiTokenAfterLoginNotice(loginApiUrl));
1060
1069
  return 0;
1061
1070
  }
1062
1071
  const headlessReason = openBrowser ? detectHeadlessLoginReason() : null;
@@ -1075,6 +1084,7 @@ async function dispatch(parsed, write, writeErr) {
1075
1084
  }
1076
1085
  });
1077
1086
  write(formatLoginSuccess(result));
1087
+ write(storedApiTokenAfterLoginNotice(loginApiUrl));
1078
1088
  return 0;
1079
1089
  }
1080
1090
  case "logout": {
@@ -1176,6 +1186,12 @@ async function dispatch(parsed, write, writeErr) {
1176
1186
  } else {
1177
1187
  lines.push(`api: ${apiUrl}`, `stored API token: no`);
1178
1188
  }
1189
+ const inUse = resolveCliCredential({ mcpUrl, apiUrl });
1190
+ if (inUse) {
1191
+ lines.push(
1192
+ `credential in use (api, whoami, package): ${describeCliCredential(inUse)}`
1193
+ );
1194
+ }
1179
1195
  lines.push("");
1180
1196
  write(lines.join("\n"));
1181
1197
  return 0;
@@ -1270,7 +1286,7 @@ async function dispatch(parsed, write, writeErr) {
1270
1286
  parseGitCredentialAction,
1271
1287
  parseGitCredentialInput,
1272
1288
  readGitCredentialStdin
1273
- } = await import("./git-credential-M4RC3D5E.js");
1289
+ } = await import("./git-credential-AGHABRZZ.js");
1274
1290
  const action = parseGitCredentialAction(parsed.positionals);
1275
1291
  const raw = await readGitCredentialStdin(process.stdin);
1276
1292
  const output = await handleGitCredential({
@@ -1330,79 +1346,15 @@ async function dispatch(parsed, write, writeErr) {
1330
1346
  if (mock.started) await mock.server.close();
1331
1347
  }
1332
1348
  }
1333
- if (shouldUseApiToken({
1349
+ const { runWhoami } = await import("./whoami-SMZ4U5QQ.js");
1350
+ return await runWhoami({
1334
1351
  tokenValues,
1335
1352
  mcpUrl,
1336
1353
  apiUrl,
1337
- allowEnvWithoutLogin: true,
1338
- ...org ? { org } : {}
1339
- })) {
1340
- const { whoamiWithApiToken: whoamiWithApiToken2 } = await import("./open-api-client-CFFUM66I.js");
1341
- const identity2 = await whoamiWithApiToken2({
1342
- token: requireApiToken(tokenValues, process.env, "whoami", {
1343
- apiUrl
1344
- }),
1345
- apiUrl,
1346
- ...org ? { org } : {}
1347
- });
1348
- if (json) {
1349
- write(`${JSON.stringify(identity2, null, 2)}
1350
- `);
1351
- return 0;
1352
- }
1353
- const scopeLine = identity2.token.scopes.join(", ") || "(none)";
1354
- const userLine2 = identity2.user ? `${identity2.user.displayName} <${identity2.user.email}>` : "(account:read not on this token)";
1355
- write(
1356
- [
1357
- `api: ${identity2.apiUrl}`,
1358
- `auth: API token (${identity2.token.id})`,
1359
- `user: ${userLine2}`,
1360
- `scopes: ${scopeLine}`,
1361
- `expires: ${identity2.token.expiresAt ?? "unknown"}`,
1362
- ""
1363
- ].join("\n")
1364
- );
1365
- return 0;
1366
- }
1367
- const { ensureOpenApiCredentials } = await import("./auth-YYGBFLBJ.js");
1368
- const credentials = await ensureOpenApiCredentials({
1369
- mcpUrl,
1370
- org,
1371
- apiUrl
1372
- });
1373
- const { whoamiWithApiToken } = await import("./open-api-client-CFFUM66I.js");
1374
- const identity = await whoamiWithApiToken({
1375
- token: credentials.accessToken,
1376
- apiUrl,
1354
+ json,
1355
+ write,
1377
1356
  ...org ? { org } : {}
1378
1357
  });
1379
- if (json) {
1380
- write(
1381
- `${JSON.stringify(
1382
- {
1383
- apiUrl: identity.apiUrl,
1384
- org: credentials.org ?? null,
1385
- scope: identity.token.scopes,
1386
- token: identity.token,
1387
- user: identity.user
1388
- },
1389
- null,
1390
- 2
1391
- )}
1392
- `
1393
- );
1394
- return 0;
1395
- }
1396
- const orgLine = credentials.org ? `
1397
- org: ${credentials.org}` : "";
1398
- const userLine = identity.user ? `${identity.user.displayName} <${identity.user.email}>` : "(no profile)";
1399
- write(
1400
- `Logged in at ${identity.apiUrl}${orgLine}
1401
- user: ${userLine}
1402
- scopes: ${identity.token.scopes.join(", ") || "(none)"}
1403
- `
1404
- );
1405
- return 0;
1406
1358
  }
1407
1359
  case "search": {
1408
1360
  const { resolveTarget } = await import("./target-UQBEV64U.js");
@@ -1424,7 +1376,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1424
1376
  });
1425
1377
  apiUrl = mock.apiUrl;
1426
1378
  closeMock = mock.started ? () => mock.server.close() : void 0;
1427
- const { searchWithApiToken: searchWithApiToken2 } = await import("./open-api-client-CFFUM66I.js");
1379
+ const { searchWithApiToken: searchWithApiToken2 } = await import("./open-api-client-ZK5T7PIZ.js");
1428
1380
  const result2 = await searchWithApiToken2({
1429
1381
  token: mock.token,
1430
1382
  apiUrl,
@@ -1436,18 +1388,17 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1436
1388
  write(formatToolResult(result2, json));
1437
1389
  return result2.isError ? 1 : 0;
1438
1390
  }
1439
- if (shouldUseApiToken({
1391
+ const searchCredential = resolveCliCredential({
1440
1392
  tokenValues,
1441
1393
  mcpUrl,
1442
1394
  apiUrl,
1443
- allowEnvWithoutLogin: true,
1395
+ purpose: "session",
1444
1396
  ...org ? { org } : {}
1445
- })) {
1446
- 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");
1447
1400
  const result2 = await searchWithApiToken2({
1448
- token: requireApiToken(tokenValues, process.env, "search", {
1449
- apiUrl
1450
- }),
1401
+ token: searchCredential.token,
1451
1402
  apiUrl,
1452
1403
  ...org ? { org } : {},
1453
1404
  query: query || void 0,
@@ -1458,13 +1409,14 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1458
1409
  write(formatToolResult(result2, json));
1459
1410
  return result2.isError ? 1 : 0;
1460
1411
  }
1461
- const { ensureOpenApiCredentials } = await import("./auth-YYGBFLBJ.js");
1412
+ const { ensureOpenApiCredentials } = await import("./auth-2ZIZDLPY.js");
1462
1413
  const credentials = await ensureOpenApiCredentials({
1463
1414
  mcpUrl,
1464
1415
  org,
1465
1416
  apiUrl
1466
1417
  });
1467
- 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");
1468
1420
  const result = await searchWithApiToken({
1469
1421
  token: credentials.accessToken,
1470
1422
  apiUrl,
@@ -1522,7 +1474,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1522
1474
  (value) => typeof value === "string"
1523
1475
  ) : typeof parsed.values.credential === "string" ? [parsed.values.credential] : void 0
1524
1476
  );
1525
- const executeRouting = (await import("./remote-execute-3VJIHSVF.js")).executeRoutingFromFlags(parsed.values);
1477
+ const executeRouting = (await import("./remote-execute-7KZCU5FK.js")).executeRoutingFromFlags(parsed.values);
1526
1478
  if (executeRouting && local) {
1527
1479
  writeErr(
1528
1480
  "--context, --fallback, --requires, and --chain route cloud execute; drop --local.\n"
@@ -1578,7 +1530,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1578
1530
  apiUrl = mock.apiUrl;
1579
1531
  mockToken = mock.token;
1580
1532
  closeMock = mock.started ? () => mock.server.close() : void 0;
1581
- const { tryResolveMockDepResolve } = await import("./mock-dep-resolve-ZSTZP6F7.js");
1533
+ const { tryResolveMockDepResolve } = await import("./mock-dep-resolve-DANXDGZU.js");
1582
1534
  mockDepResolve = await tryResolveMockDepResolve({
1583
1535
  tokenValues,
1584
1536
  apiUrl: prodApiUrl,
@@ -1587,7 +1539,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1587
1539
  });
1588
1540
  }
1589
1541
  if (localPackageRun) {
1590
- const { buildLocalPackageContext, runLocalPackageModule } = await import("./local-package-run-LMJ5XYA5.js");
1542
+ const { buildLocalPackageContext, runLocalPackageModule } = await import("./local-package-run-Z2ITZ6KO.js");
1591
1543
  const result2 = await runLocalPackageModule({
1592
1544
  modulePath: localPackageRun.modulePath,
1593
1545
  params: args.params,
@@ -1615,13 +1567,14 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1615
1567
  write(formatToolResult(result2, json));
1616
1568
  return result2.isError ? 1 : 0;
1617
1569
  }
1618
- const useToken = local || shouldUseApiToken({
1570
+ const cloudCredential = local ? null : resolveCliCredential({
1619
1571
  tokenValues,
1620
1572
  mcpUrl,
1621
1573
  apiUrl,
1622
- allowEnvWithoutLogin: true,
1574
+ purpose: "session",
1623
1575
  ...org ? { org } : {}
1624
1576
  });
1577
+ const cloudToken = cloudCredential?.token ?? null;
1625
1578
  let packageRootForMocks;
1626
1579
  if (target === "mock") {
1627
1580
  try {
@@ -1631,7 +1584,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1631
1584
  packageRootForMocks = void 0;
1632
1585
  }
1633
1586
  }
1634
- const result = local ? await (await import("./local-execute-ALYHHP6M.js")).runLocalExecute({
1587
+ const result = local ? await (await import("./local-execute-NLJGGADH.js")).runLocalExecute({
1635
1588
  code: args.code,
1636
1589
  ...modulePath !== void 0 ? { modulePath } : {},
1637
1590
  params: args.params,
@@ -1653,28 +1606,27 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1653
1606
  allowPrivateNetwork: parsed.values["allow-private-network"] === true,
1654
1607
  onStatus: (message) => writeErr(`${message}
1655
1608
  `)
1656
- }) : useToken ? await (await import("./remote-execute-3VJIHSVF.js")).runRemoteExecuteWithToken({
1609
+ }) : cloudToken ? await (await import("./remote-execute-7KZCU5FK.js")).runRemoteExecuteWithToken({
1657
1610
  code: typeof args.code === "string" ? args.code : void 0,
1658
1611
  params: args.params,
1659
1612
  conversationId: args.conversationId,
1660
1613
  ...credentials !== void 0 ? { credentials } : {},
1661
1614
  ...executeRouting ? { routing: executeRouting } : {},
1662
- token: requireApiToken(
1663
- tokenValues,
1664
- process.env,
1665
- "execute with an API token",
1666
- { apiUrl }
1667
- ),
1615
+ token: cloudToken,
1668
1616
  apiUrl,
1669
1617
  ...org ? { org } : {}
1670
1618
  }) : await (async () => {
1671
- const { ensureOpenApiCredentials } = await import("./auth-YYGBFLBJ.js");
1619
+ const { ensureOpenApiCredentials } = await import("./auth-2ZIZDLPY.js");
1672
1620
  const session = await ensureOpenApiCredentials({
1673
1621
  mcpUrl,
1674
1622
  org,
1675
1623
  apiUrl
1676
1624
  });
1677
- 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({
1678
1630
  code: typeof args.code === "string" ? args.code : void 0,
1679
1631
  params: args.params,
1680
1632
  conversationId: args.conversationId,
@@ -1689,7 +1641,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1689
1641
  return result.isError ? 1 : 0;
1690
1642
  } catch (error) {
1691
1643
  if (json && local) {
1692
- const { LocalPackageGraphError, packageGraphErrorToolResult } = await import("./local-package-graph-GREJNPV5.js");
1644
+ const { LocalPackageGraphError, packageGraphErrorToolResult } = await import("./local-package-graph-M7U7DQ2N.js");
1693
1645
  if (error instanceof LocalPackageGraphError) {
1694
1646
  const redacted = redactError(error).message;
1695
1647
  const result = packageGraphErrorToolResult(error);
@@ -1719,7 +1671,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1719
1671
  runDevServe,
1720
1672
  runDevWebhook,
1721
1673
  tryAttachedDevFetch
1722
- } = await import("./dev-command-W4EXL7SE.js");
1674
+ } = await import("./dev-command-BTJ4WJEQ.js");
1723
1675
  const target = resolveTarget({
1724
1676
  command: "dev",
1725
1677
  flag: typeof parsed.values.target === "string" ? parsed.values.target : void 0
@@ -1745,8 +1697,8 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1745
1697
  { callOpenApiOperation, formatOpenApiHttpDebugLine },
1746
1698
  { parsePackageCheckResult, PublishChecksAuthError }
1747
1699
  ] = await Promise.all([
1748
- import("./open-api-client-CFFUM66I.js"),
1749
- import("./dev-command-W4EXL7SE.js")
1700
+ import("./open-api-client-ZK5T7PIZ.js"),
1701
+ import("./dev-command-BTJ4WJEQ.js")
1750
1702
  ]);
1751
1703
  let token2;
1752
1704
  try {
@@ -1860,7 +1812,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
1860
1812
  purpose: "kody dev",
1861
1813
  ...org ? { org } : {}
1862
1814
  }) : "mock";
1863
- 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({
1864
1816
  tokenValues,
1865
1817
  apiUrl: prodApiUrl,
1866
1818
  mcpUrl,
@@ -2001,7 +1953,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
2001
1953
  const params = parseApiParamsJson(
2002
1954
  typeof parsed.values.params === "string" ? parsed.values.params : void 0
2003
1955
  );
2004
- const { callOpenApiOperation } = await import("./open-api-client-CFFUM66I.js");
1956
+ const { callOpenApiOperation } = await import("./open-api-client-ZK5T7PIZ.js");
2005
1957
  const result = await callOpenApiOperation({
2006
1958
  operationId,
2007
1959
  params,
@@ -2036,7 +1988,7 @@ scopes: ${identity.token.scopes.join(", ") || "(none)"}
2036
1988
  mcpUrl,
2037
1989
  org
2038
1990
  });
2039
- const { callOpenApiOperation: callOpenApiOperation2 } = await import("./open-api-client-CFFUM66I.js");
1991
+ const { callOpenApiOperation: callOpenApiOperation2 } = await import("./open-api-client-ZK5T7PIZ.js");
2040
1992
  write(
2041
1993
  await runPackageCollaboratorPlan({
2042
1994
  plan,
@@ -2062,7 +2014,7 @@ ${packageCollaboratorUsage}`
2062
2014
  positional: parsed.positionals[1],
2063
2015
  paramsJson: typeof parsed.values.params === "string" ? parsed.values.params : void 0
2064
2016
  });
2065
- const { callOpenApiOperation } = await import("./open-api-client-CFFUM66I.js");
2017
+ const { callOpenApiOperation } = await import("./open-api-client-ZK5T7PIZ.js");
2066
2018
  const publishToken = await accessTokenForOpenApi({
2067
2019
  tokenValues,
2068
2020
  apiUrl,
@@ -2203,7 +2155,7 @@ function attachExecuteCommonArgs(args, input) {
2203
2155
  return args;
2204
2156
  }
2205
2157
  async function runAuthSetupGit(input) {
2206
- const { authSetupGit, setupGitDefaultScopes } = await import("./setup-git-RAWSZAB2.js");
2158
+ const { authSetupGit, setupGitDefaultScopes } = await import("./setup-git-67N7Q2BR.js");
2207
2159
  const apiUrl = apiUrlFrom({
2208
2160
  apiUrl: typeof input.values["api-url"] === "string" ? input.values["api-url"] : void 0
2209
2161
  });
@@ -2260,7 +2212,7 @@ async function runAuthSetupGit(input) {
2260
2212
  return 0;
2261
2213
  }
2262
2214
  async function runAuthRemoveGit(input) {
2263
- const { authRemoveGit, formatAuthRemoveGitReport } = await import("./setup-git-RAWSZAB2.js");
2215
+ const { authRemoveGit, formatAuthRemoveGitReport } = await import("./setup-git-67N7Q2BR.js");
2264
2216
  const apiUrl = apiUrlFrom({
2265
2217
  apiUrl: typeof input.values["api-url"] === "string" ? input.values["api-url"] : void 0
2266
2218
  });
@@ -2273,22 +2225,16 @@ async function runAuthRemoveGit(input) {
2273
2225
  }
2274
2226
  function bootstrapMinter(input) {
2275
2227
  return async (params) => {
2276
- if (shouldUseApiToken({
2228
+ const minter = resolveCliCredential({
2277
2229
  tokenValues: input.tokenValues,
2278
2230
  mcpUrl: input.mcpUrl,
2279
2231
  apiUrl: input.apiUrl,
2280
- allowEnvWithoutLogin: true,
2232
+ purpose: "mint",
2281
2233
  ...input.org ? { org: input.org } : {}
2282
- })) {
2283
- const token = requireApiToken(
2284
- input.tokenValues,
2285
- process.env,
2286
- "auth bootstrap --scopes",
2287
- {
2288
- apiUrl: input.apiUrl
2289
- }
2290
- );
2291
- 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");
2292
2238
  try {
2293
2239
  return await callOpenApiOperation({
2294
2240
  token,
@@ -2306,16 +2252,14 @@ function bootstrapMinter(input) {
2306
2252
  throw error;
2307
2253
  }
2308
2254
  }
2309
- if (loadCredentials(input.mcpUrl, void 0, void 0, {
2310
- org: input.org
2311
- })) {
2312
- const { ensureOpenApiCredentials } = await import("./auth-YYGBFLBJ.js");
2255
+ if (minter) {
2256
+ const { ensureOpenApiCredentials } = await import("./auth-2ZIZDLPY.js");
2313
2257
  const session = await ensureOpenApiCredentials({
2314
2258
  mcpUrl: input.mcpUrl,
2315
2259
  apiUrl: input.apiUrl,
2316
2260
  ...input.org ? { org: input.org } : {}
2317
2261
  });
2318
- const { callOpenApiOperation } = await import("./open-api-client-CFFUM66I.js");
2262
+ const { callOpenApiOperation } = await import("./open-api-client-ZK5T7PIZ.js");
2319
2263
  return callOpenApiOperation({
2320
2264
  operationId: cliCredentialBootstrapOperationId,
2321
2265
  params,
@@ -2335,18 +2279,20 @@ function tokenFlagValues(values) {
2335
2279
  };
2336
2280
  }
2337
2281
  async function accessTokenForOpenApi(input) {
2338
- const explicit = resolveScopedApiToken({
2282
+ const credential = resolveCliCredential({
2339
2283
  tokenValues: input.tokenValues,
2340
- env: process.env,
2341
- apiUrl: input.apiUrl
2284
+ apiUrl: input.apiUrl,
2285
+ mcpUrl: input.mcpUrl,
2286
+ ...input.org ? { org: input.org } : {}
2342
2287
  });
2343
- if (explicit) return explicit;
2344
- const { ensureOpenApiCredentials } = await import("./auth-YYGBFLBJ.js");
2288
+ if (credential?.token) return credential.token;
2289
+ const { ensureOpenApiCredentials } = await import("./auth-2ZIZDLPY.js");
2345
2290
  const session = await ensureOpenApiCredentials({
2346
2291
  mcpUrl: input.mcpUrl,
2347
2292
  apiUrl: input.apiUrl,
2348
2293
  ...input.org ? { org: input.org } : {}
2349
2294
  });
2295
+ noteActiveLoginCredential({ login: session });
2350
2296
  return session.accessToken;
2351
2297
  }
2352
2298
  function parseApiParamsJson(paramsJson) {
@@ -2394,21 +2340,21 @@ async function resolvePackagePublishTarget(params, call) {
2394
2340
  const { kody_id: _name, ...rest } = params;
2395
2341
  return { ...rest, package_id: matches[0].package_id };
2396
2342
  }
2397
- function shouldUseApiToken(input) {
2398
- if (hasExplicitTokenFlag(input.tokenValues)) return true;
2399
- if (!input.allowEnvWithoutLogin) return false;
2400
- if (!resolveScopedApiToken({
2401
- tokenValues: input.tokenValues,
2402
- env: input.env,
2403
- apiUrl: input.apiUrl,
2404
- loadApiToken: input.loadApiToken
2405
- })) {
2406
- return false;
2343
+ function storedApiTokenAfterLoginNotice(apiUrl, loadApiToken = loadStoredApiToken) {
2344
+ let stored;
2345
+ try {
2346
+ stored = loadApiToken(apiUrl);
2347
+ } catch {
2348
+ return "";
2407
2349
  }
2408
- const loggedIn = input.hasSession ?? loadCredentials(input.mcpUrl, void 0, void 0, {
2409
- org: input.org
2410
- }) != null;
2411
- 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
+ `;
2412
2358
  }
2413
2359
 
2414
2360
  export {
@@ -2424,6 +2370,6 @@ export {
2424
2370
  parseApiParamsJson,
2425
2371
  packagePublishParams,
2426
2372
  resolvePackagePublishTarget,
2427
- shouldUseApiToken
2373
+ storedApiTokenAfterLoginNotice
2428
2374
  };
2429
- //# sourceMappingURL=chunk-NN3I7FJQ.js.map
2375
+ //# sourceMappingURL=chunk-2ATDBLEX.js.map