nolo-cli 0.204.0-alpha.2 → 0.205.0-alpha.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 (86) hide show
  1. package/{_executeModel-ZUESBV6T.js → _executeModel-Y4Y6NSF2.js} +16 -16
  2. package/{agentDeleteCommand-INOBZ3HP.js → agentDeleteCommand-QDQJ3HRU.js} +22 -22
  3. package/{agentEmailCommands-J6UTZBJC.js → agentEmailCommands-CMMDVTMB.js} +24 -24
  4. package/{agentListCommands-6344UIVZ.js → agentListCommands-YVUCTMRI.js} +13 -13
  5. package/{agentMachineCommands-TE6IRTIB.js → agentMachineCommands-AHMFIF7U.js} +10 -10
  6. package/{agentProviderCommands-MEFUIECN.js → agentProviderCommands-SKW4L6NN.js} +2 -2
  7. package/{agentRecordCommands-34MHHVFX.js → agentRecordCommands-G6RARTFX.js} +22 -22
  8. package/{agentRunCommand-7OMDQBRA.js → agentRunCommand-G7IJ23OW.js} +23 -23
  9. package/{agentRuntimeLocal-EO6WCTF2.js → agentRuntimeLocal-7Q72MXKN.js} +8 -8
  10. package/{agentSlice-HUFGX25R.js → agentSlice-ZRGNTU3K.js} +1 -1
  11. package/{appDeleteCommands-3DCLKVYC.js → appDeleteCommands-ZUKOQOIM.js} +12 -12
  12. package/{appDeployCommands-X3MUBDOP.js → appDeployCommands-G5YC3DKA.js} +12 -12
  13. package/{appDeployStatusCommands-PXC3EHHS.js → appDeployStatusCommands-EMOTU2NU.js} +12 -12
  14. package/{appGetCommands-ETPPE6H7.js → appGetCommands-N3D2EBDM.js} +12 -12
  15. package/{appListCommands-OFIDLALN.js → appListCommands-DGSGMKJL.js} +12 -12
  16. package/{authCommand-KPTIANH2.js → authCommand-NZC3H2EN.js} +62 -8
  17. package/{chromeOpsCommands-O4J346EQ.js → chromeOpsCommands-ECVS6CAO.js} +1 -1
  18. package/{chunk-VXZ4YYNK.js → chunk-2U2DMUGG.js} +52 -37
  19. package/{chunk-266E37EL.js → chunk-354R5A62.js} +3 -3
  20. package/{chunk-33W4IFUU.js → chunk-5MXA4LWL.js} +1 -1
  21. package/{chunk-E4KACSRR.js → chunk-5OV4MVQK.js} +2 -2
  22. package/{chunk-IK6AAUGM.js → chunk-6AMR3AE6.js} +2 -2
  23. package/{chunk-QUJ3IHEK.js → chunk-767YOSGT.js} +2 -2
  24. package/{chunk-CJ37ZMCQ.js → chunk-7C45ONOU.js} +1 -1
  25. package/{chunk-BC4UX4EZ.js → chunk-7COVU5SP.js} +2 -2
  26. package/{chunk-CQHMBWZH.js → chunk-7NMNKOW5.js} +1 -1
  27. package/{chunk-EPJFGQYO.js → chunk-7T5TLIY4.js} +1 -1
  28. package/{chunk-SEEXRWNB.js → chunk-ACMRWLRR.js} +26 -20
  29. package/{chunk-BER2RSTL.js → chunk-DTLSKEXN.js} +2 -2
  30. package/{chunk-G7RFM5QA.js → chunk-EDSRC2JN.js} +2 -2
  31. package/{chunk-YR4MRACW.js → chunk-F6MQO3YY.js} +3 -3
  32. package/{chunk-IZLXIV5L.js → chunk-HSZ2YEPR.js} +1 -1
  33. package/{chunk-VCFU3BO5.js → chunk-JASKVAYJ.js} +2 -2
  34. package/{chunk-6I7ZP7KJ.js → chunk-JBWLZ3CB.js} +2 -2
  35. package/{chunk-UMIQZ7PX.js → chunk-JTLREMIA.js} +3 -3
  36. package/{chunk-M43VXSMX.js → chunk-JX2QFYIA.js} +2 -2
  37. package/{chunk-HNO2SEYI.js → chunk-KJCSY4TW.js} +8 -8
  38. package/{chunk-4KPB3KWX.js → chunk-LTI5T3A6.js} +309 -82
  39. package/{chunk-3MXJWFLO.js → chunk-MFUGGMIS.js} +1 -1
  40. package/{chunk-MZXWSY4E.js → chunk-MNWKNN6V.js} +1 -1
  41. package/{chunk-H7HWWNJB.js → chunk-PJILX6KS.js} +1 -1
  42. package/{chunk-E4LYPSYM.js → chunk-PPCUXO3E.js} +12 -0
  43. package/{chunk-NGJWYWCF.js → chunk-QEHXPNCZ.js} +5 -5
  44. package/{chunk-SXMTSDFS.js → chunk-RMLFNM3J.js} +2 -2
  45. package/{chunk-JH7KMNGT.js → chunk-RQDGDKFL.js} +1 -1
  46. package/{chunk-YPYNRTWB.js → chunk-SH52SBSW.js} +4 -4
  47. package/{chunk-DQ7PCRZ6.js → chunk-T6CHEJ27.js} +4 -4
  48. package/{chunk-6KWPMJ5C.js → chunk-TYKUYQDP.js} +6 -6
  49. package/{chunk-77GDSGRM.js → chunk-UETRBTZ2.js} +29 -12
  50. package/{chunk-SZXJVQ7L.js → chunk-VT3MVIIU.js} +7 -7
  51. package/{chunk-P4YLK2OD.js → chunk-XNOILBHV.js} +1 -1
  52. package/{chunk-VEUSD6OF.js → chunk-YF4ZRVP3.js} +5 -1
  53. package/{chunk-JL3YTCPQ.js → chunk-YHT3ZONH.js} +2 -2
  54. package/{chunk-NTLJGRAT.js → chunk-YT65GYRP.js} +1 -1
  55. package/{chunk-KCYY5F2P.js → chunk-ZIEPLFWS.js} +2 -2
  56. package/{commandRegistry-XBZJWVTJ.js → commandRegistry-HTURFH3S.js} +59 -59
  57. package/{contentThunks-V5NBNTC5.js → contentThunks-DYUKG2UT.js} +3 -3
  58. package/{cooldownCommands-BLRMLW7Q.js → cooldownCommands-WGVSKMU4.js} +1 -1
  59. package/{createAgentAutomationAction-4TXJ366P.js → createAgentAutomationAction-Y4BMH7SM.js} +3 -3
  60. package/{createDialogAction-4SPT75DB.js → createDialogAction-RY47EJA7.js} +4 -4
  61. package/{createPageAction-D4GMHUPC.js → createPageAction-RLV5IWBB.js} +3 -3
  62. package/{dialogCommands-6RRP5KUH.js → dialogCommands-UR3JECOS.js} +12 -12
  63. package/{dialogSlice-IGPTWSPB.js → dialogSlice-X23NSXGM.js} +2 -2
  64. package/{docCreateCommands-7ODYDGRL.js → docCreateCommands-AM3RDP6K.js} +11 -11
  65. package/{docDeleteCommands-OEIRM3CC.js → docDeleteCommands-KCRF23RY.js} +12 -12
  66. package/{docReadCommands-W56GNAWP.js → docReadCommands-M4SZAVQR.js} +11 -11
  67. package/{docStore-HEAGW26W.js → docStore-OCOEV524.js} +1 -1
  68. package/{docUpdateCommands-33Q3SEG7.js → docUpdateCommands-XU6NSHXX.js} +11 -11
  69. package/{handleSendMessageAction-R2E7VYHQ.js → handleSendMessageAction-JYLG2PGY.js} +10 -10
  70. package/index.js +7 -7
  71. package/{localRuntimeAdapter-J5GD66XZ.js → localRuntimeAdapter-GQCC7EJL.js} +20 -20
  72. package/{machineCommands-AT7B4LFO.js → machineCommands-SYG2QENB.js} +21 -21
  73. package/{machineWsRunDispatch-CRDELH46.js → machineWsRunDispatch-HJWCU2XA.js} +21 -21
  74. package/package.json +1 -1
  75. package/{providerPresetApply-HBBUUVJD.js → providerPresetApply-EQESXT6X.js} +1 -1
  76. package/{providerRegistry-5LK2NXYE.js → providerRegistry-PZ56P43E.js} +1 -1
  77. package/{readlineWorkspace-FPHZGNZP.js → readlineWorkspace-457FDLML.js} +28 -28
  78. package/{runAgentClientLoop-6AAA5HNQ.js → runAgentClientLoop-O6XYZPOG.js} +14 -14
  79. package/{secretCommands-S2DDPIQ4.js → secretCommands-RLIO3QK5.js} +1 -1
  80. package/{spaceCommands-LPKHBCPU.js → spaceCommands-SVGAP4C2.js} +10 -10
  81. package/{streamAgentChatTurn-WNNXYOLC.js → streamAgentChatTurn-VWPG52FR.js} +18 -18
  82. package/{tools-QLURHFLS.js → tools-WFCFBL74.js} +9 -9
  83. package/{tuiSummaryLlmCaller-73QO3HAD.js → tuiSummaryLlmCaller-CEIZAKUV.js} +4 -4
  84. package/{updateCommands-LEJRRVBB.js → updateCommands-N7K7TEU4.js} +3 -3
  85. package/{updateDialogTitleAction-5UVS3ADT.js → updateDialogTitleAction-ZBQOKKO4.js} +3 -3
  86. package/{windowsSelfUpdate-LSSQLXVS.js → windowsSelfUpdate-SVJKL6VH.js} +2 -2
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-523DITKR.js";
12
12
  import {
13
13
  runLlm
14
- } from "./chunk-YR4MRACW.js";
14
+ } from "./chunk-F6MQO3YY.js";
15
15
  import {
16
16
  isMediaToolConfirmation
17
17
  } from "./chunk-QYPE3TS3.js";
@@ -11077,7 +11077,7 @@ var messageSlice = createSliceWithThunks({
11077
11077
  runtimeOptions: args.runtimeOptions
11078
11078
  });
11079
11079
  if (agentKeyToUse) {
11080
- const { streamAgentChatTurn } = await import("./agentSlice-HUFGX25R.js");
11080
+ const { streamAgentChatTurn } = await import("./agentSlice-ZRGNTU3K.js");
11081
11081
  await dispatch(
11082
11082
  streamAgentChatTurn({
11083
11083
  agentKey: agentKeyToUse,
@@ -13891,7 +13891,7 @@ var deleteDialogThunk = async (payload, thunkApi) => {
13891
13891
  }
13892
13892
  if (isCurrentDialog) {
13893
13893
  await thunkApi.dispatch(resetMsgs());
13894
- const { clearPendingAttachments: clearPendingAttachments2 } = await import("./dialogSlice-IGPTWSPB.js");
13894
+ const { clearPendingAttachments: clearPendingAttachments2 } = await import("./dialogSlice-X23NSXGM.js");
13895
13895
  dispatch(clearPendingAttachments2());
13896
13896
  }
13897
13897
  return { dialogKey, isCurrentDialog, attachmentPlan };
@@ -13899,15 +13899,15 @@ var deleteDialogThunk = async (payload, thunkApi) => {
13899
13899
 
13900
13900
  // packages/chat/dialog/dialogSlice.ts
13901
13901
  var runCreateDialogAction = async (args, thunkApi) => {
13902
- const { createDialogAction } = await import("./createDialogAction-4SPT75DB.js");
13902
+ const { createDialogAction } = await import("./createDialogAction-RY47EJA7.js");
13903
13903
  return createDialogAction(args, thunkApi);
13904
13904
  };
13905
13905
  var runCreateAgentAutomationAction = async (args, thunkApi) => {
13906
- const { createAgentAutomationAction } = await import("./createAgentAutomationAction-4TXJ366P.js");
13906
+ const { createAgentAutomationAction } = await import("./createAgentAutomationAction-Y4BMH7SM.js");
13907
13907
  return createAgentAutomationAction(args, thunkApi);
13908
13908
  };
13909
13909
  var runUpdateDialogTitleAction = async (args, thunkApi) => {
13910
- const { updateDialogTitleAction } = await import("./updateDialogTitleAction-5UVS3ADT.js");
13910
+ const { updateDialogTitleAction } = await import("./updateDialogTitleAction-ZBQOKKO4.js");
13911
13911
  return updateDialogTitleAction(args, thunkApi);
13912
13912
  };
13913
13913
  var runAddDialogAgentAction = async (args, thunkApi) => {
@@ -13931,7 +13931,7 @@ var runSetDialogExtraReferencesAction = async (args, thunkApi) => {
13931
13931
  return setDialogExtraReferencesAction(args, thunkApi);
13932
13932
  };
13933
13933
  var runHandleSendMessageAction = async (args, thunkApi) => {
13934
- const { handleSendMessageAction } = await import("./handleSendMessageAction-R2E7VYHQ.js");
13934
+ const { handleSendMessageAction } = await import("./handleSendMessageAction-JYLG2PGY.js");
13935
13935
  return handleSendMessageAction(args, thunkApi);
13936
13936
  };
13937
13937
  function clearDialogState() {
@@ -13944,7 +13944,7 @@ var createPageAndAddReference = createAsyncThunk(
13944
13944
  async (payload, { dispatch, getState, rejectWithValue }) => {
13945
13945
  const { slateData, jsonData, title, type, fileId, groupId, dialogKey } = payload;
13946
13946
  try {
13947
- const { createDocState } = await import("./docStore-HEAGW26W.js");
13947
+ const { createDocState } = await import("./docStore-OCOEV524.js");
13948
13948
  const pageKey = await createDocState(
13949
13949
  { slateData, title },
13950
13950
  { dispatch, getState }
@@ -14,7 +14,7 @@ import {
14
14
  getAntigravityUserAgent,
15
15
  normalizeAntigravityTokenPayload,
16
16
  refreshAntigravityToken
17
- } from "./chunk-VEUSD6OF.js";
17
+ } from "./chunk-YF4ZRVP3.js";
18
18
  import {
19
19
  toErrorMessage
20
20
  } from "./chunk-HNMXYYJR.js";
@@ -844,6 +844,309 @@ var refreshOpenAiCodexToken2 = async (credential, deps = {}) => {
844
844
  });
845
845
  };
846
846
 
847
+ // packages/agent-runtime/anthropicClaudeCodeFingerprint.ts
848
+ var DEFAULT_CLAUDE_CODE_VERSION = "2.1.294";
849
+ var SEMVER_REGEX = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
850
+ var adoptedClaudeCodeVersion = null;
851
+ function parseSemver(v) {
852
+ const match = v.trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/);
853
+ if (!match) return null;
854
+ return {
855
+ major: Number(match[1]),
856
+ minor: Number(match[2]),
857
+ patch: Number(match[3]),
858
+ prerelease: match[4]
859
+ };
860
+ }
861
+ function compareSemver(a, b) {
862
+ const parsedA = parseSemver(a);
863
+ const parsedB = parseSemver(b);
864
+ if (!parsedA || !parsedB) {
865
+ return a.localeCompare(b);
866
+ }
867
+ if (parsedA.major !== parsedB.major) return parsedA.major - parsedB.major;
868
+ if (parsedA.minor !== parsedB.minor) return parsedA.minor - parsedB.minor;
869
+ if (parsedA.patch !== parsedB.patch) return parsedA.patch - parsedB.patch;
870
+ if (!parsedA.prerelease && parsedB.prerelease) return 1;
871
+ if (parsedA.prerelease && !parsedB.prerelease) return -1;
872
+ if (!parsedA.prerelease && !parsedB.prerelease) return 0;
873
+ const partsA = parsedA.prerelease.split(".");
874
+ const partsB = parsedB.prerelease.split(".");
875
+ const maxLen = Math.max(partsA.length, partsB.length);
876
+ for (let i = 0; i < maxLen; i++) {
877
+ const pA = partsA[i];
878
+ const pB = partsB[i];
879
+ if (pA === void 0) return -1;
880
+ if (pB === void 0) return 1;
881
+ if (pA === pB) continue;
882
+ const numA = Number(pA);
883
+ const numB = Number(pB);
884
+ const aIsNum = Number.isInteger(numA) && String(numA) === pA;
885
+ const bIsNum = Number.isInteger(numB) && String(numB) === pB;
886
+ if (aIsNum && bIsNum) return numA - numB;
887
+ if (aIsNum && !bIsNum) return -1;
888
+ if (!aIsNum && bIsNum) return 1;
889
+ return pA.localeCompare(pB);
890
+ }
891
+ return 0;
892
+ }
893
+ function getEnvPinnedVersion(rawEnv) {
894
+ const envVal = rawEnv !== void 0 ? rawEnv : process.env.NOLO_CLAUDE_CODE_VERSION ?? process.env.CLAUDE_CODE_VERSION;
895
+ if (envVal === void 0) return void 0;
896
+ const trimmed = envVal.trim();
897
+ if (!trimmed) return void 0;
898
+ return SEMVER_REGEX.test(trimmed) ? trimmed : void 0;
899
+ }
900
+ function isClaudeCodeVersionEnvPinned() {
901
+ return getEnvPinnedVersion() !== void 0;
902
+ }
903
+ function resolveClaudeCodeVersion(rawEnv) {
904
+ const envPinned = getEnvPinnedVersion(rawEnv);
905
+ if (envPinned !== void 0) {
906
+ return envPinned;
907
+ }
908
+ return adoptedClaudeCodeVersion ?? DEFAULT_CLAUDE_CODE_VERSION;
909
+ }
910
+ function getClaudeCodeUserAgent() {
911
+ const version = resolveClaudeCodeVersion();
912
+ return `claude-cli/${version} (external, local-agent, agent-sdk/0.1.0)`;
913
+ }
914
+ function extractErrorText(error) {
915
+ if (typeof error === "string") return error;
916
+ if (!error) return "";
917
+ if (error instanceof Error) {
918
+ let s = `${error.name}: ${error.message}`;
919
+ const extra = error;
920
+ if (typeof extra.body === "string") s += " " + extra.body;
921
+ else if (extra.body && typeof extra.body === "object") {
922
+ try {
923
+ s += " " + JSON.stringify(extra.body);
924
+ } catch {
925
+ }
926
+ }
927
+ return s;
928
+ }
929
+ if (typeof error === "object") {
930
+ try {
931
+ return JSON.stringify(error);
932
+ } catch {
933
+ return String(error);
934
+ }
935
+ }
936
+ return String(error);
937
+ }
938
+ function adoptRequiredClaudeCodeVersion(error) {
939
+ if (isClaudeCodeVersionEnvPinned()) {
940
+ return false;
941
+ }
942
+ const text = extractErrorText(error);
943
+ if (!text) return false;
944
+ let requiredVersion = null;
945
+ if (typeof error === "object" && error !== null) {
946
+ const errObj = error;
947
+ const nested = errObj.error && typeof errObj.error === "object" ? errObj.error : errObj;
948
+ const hasTooOldCode = /claude_code_version_too_old/i.test(text);
949
+ const direct = nested.required_version ?? nested.requiredVersion ?? nested.minimum_version ?? nested.minVersion ?? (hasTooOldCode ? nested.version : void 0);
950
+ if (typeof direct === "string" && SEMVER_REGEX.test(direct.trim())) {
951
+ requiredVersion = direct.trim();
952
+ }
953
+ }
954
+ if (!requiredVersion) {
955
+ const phrase = text.match(/version\s+(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)\s+or\s+(?:newer|above|higher)\s+is\s+required/i) ?? text.match(/(?:minimum|required)\s+version\s+(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)/i);
956
+ if (phrase) requiredVersion = phrase[1];
957
+ }
958
+ if (!requiredVersion) return false;
959
+ const currentVersion = resolveClaudeCodeVersion();
960
+ if (compareSemver(requiredVersion, currentVersion) > 0) {
961
+ adoptedClaudeCodeVersion = requiredVersion;
962
+ return true;
963
+ }
964
+ return false;
965
+ }
966
+
967
+ // packages/agent-runtime/anthropicOAuth.ts
968
+ var ANTHROPIC_OAUTH_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
969
+ var ANTHROPIC_OAUTH_AUTHORIZE_URL = "https://claude.ai/oauth/authorize";
970
+ var ANTHROPIC_OAUTH_TOKEN_URL = "https://api.anthropic.com/v1/oauth/token";
971
+ var ANTHROPIC_OAUTH_CALLBACK_PORT = 54545;
972
+ var ANTHROPIC_OAUTH_REDIRECT_URI = `http://localhost:${ANTHROPIC_OAUTH_CALLBACK_PORT}/callback`;
973
+ var ANTHROPIC_OAUTH_SCOPES = [
974
+ "org:create_api_key",
975
+ "user:profile",
976
+ "user:inference",
977
+ "user:sessions:claude_code",
978
+ "user:mcp_servers",
979
+ "user:file_upload"
980
+ ];
981
+ var ANTHROPIC_ACCESS_TOKEN_CLIENT_SKEW_MS = 5 * 60 * 1e3;
982
+ var ANTHROPIC_OAUTH_BETA = "oauth-2025-04-20";
983
+ var ANTHROPIC_BOOTSTRAP_URL = "https://api.anthropic.com/api/claude_cli/bootstrap";
984
+ var ANTHROPIC_OAUTH_GRANT_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
985
+ var ANTHROPIC_IDENTITY_RECHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
986
+ function anthropicGrantRemainingMs(credential, now = Date.now()) {
987
+ const rawGrantedAt = credential?.metadata?.grantedAt;
988
+ if (typeof rawGrantedAt !== "number" || !Number.isFinite(rawGrantedAt)) {
989
+ return void 0;
990
+ }
991
+ return rawGrantedAt + ANTHROPIC_OAUTH_GRANT_TTL_MS - now;
992
+ }
993
+ async function fetchAnthropicBootstrapIdentity(accessToken, fetchImpl = fetch, debugLog) {
994
+ if (!accessToken || typeof accessToken !== "string") {
995
+ return {};
996
+ }
997
+ try {
998
+ const response = await fetchImpl(ANTHROPIC_BOOTSTRAP_URL, {
999
+ method: "GET",
1000
+ headers: {
1001
+ Authorization: `Bearer ${accessToken.trim()}`,
1002
+ // UA 版本必须走 fingerprint 单一真源:400 自愈 adopt 新版本后,
1003
+ // 这里若自带一份 pin,就会继续发旧版本,上游抬门槛时身份回填会静默失效。
1004
+ "User-Agent": getClaudeCodeUserAgent(),
1005
+ Accept: "application/json"
1006
+ },
1007
+ signal: AbortSignal.timeout(1e4)
1008
+ });
1009
+ if (!response.ok) {
1010
+ debugLog?.(`Claude bootstrap identity returned HTTP ${response.status}`);
1011
+ return {};
1012
+ }
1013
+ const data = await response.json().catch(() => ({}));
1014
+ const account = data?.oauth_account;
1015
+ const identity = {};
1016
+ if (typeof account?.account_uuid === "string" && account.account_uuid.trim()) {
1017
+ identity.accountId = account.account_uuid.trim();
1018
+ }
1019
+ if (typeof account?.account_email === "string" && account.account_email.trim()) {
1020
+ identity.email = account.account_email.trim();
1021
+ }
1022
+ if (typeof account?.organization_uuid === "string" && account.organization_uuid.trim()) {
1023
+ identity.orgId = account.organization_uuid.trim();
1024
+ }
1025
+ if (typeof account?.organization_name === "string" && account.organization_name.trim()) {
1026
+ identity.orgName = account.organization_name.trim();
1027
+ }
1028
+ return identity;
1029
+ } catch (err) {
1030
+ debugLog?.("Claude bootstrap identity fetch failed", err);
1031
+ return {};
1032
+ }
1033
+ }
1034
+ function normalizeAnthropicTokenPayload(args) {
1035
+ const { payload, baseCredential, now = Date.now() } = args;
1036
+ if (typeof payload.access_token !== "string" || !payload.access_token.trim()) {
1037
+ throw new Error("Claude OAuth token response missing access_token");
1038
+ }
1039
+ const expiresIn = asOptionalFiniteNumber(payload.expires_in);
1040
+ const accountId = typeof payload.account?.uuid === "string" && payload.account.uuid ? payload.account.uuid : baseCredential?.accountId;
1041
+ const email = typeof payload.account?.email_address === "string" && payload.account.email_address ? payload.account.email_address : baseCredential?.metadata?.email;
1042
+ const organizationId = typeof payload.organization?.uuid === "string" && payload.organization.uuid ? payload.organization.uuid : baseCredential?.metadata?.organizationId;
1043
+ const organizationName = typeof payload.organization?.name === "string" && payload.organization.name ? payload.organization.name : baseCredential?.metadata?.organizationName;
1044
+ const refreshToken = typeof payload.refresh_token === "string" && payload.refresh_token.trim() ? payload.refresh_token.trim() : baseCredential?.refreshToken;
1045
+ const scope = typeof payload.scope === "string" && payload.scope ? payload.scope : baseCredential?.scope;
1046
+ const isInteractiveLogin = args.isInitialLogin ?? baseCredential === void 0;
1047
+ const grantedAt = isInteractiveLogin ? now : typeof baseCredential?.metadata?.grantedAt === "number" && Number.isFinite(baseCredential.metadata.grantedAt) ? baseCredential.metadata.grantedAt : void 0;
1048
+ const metadata = {
1049
+ ...baseCredential?.metadata ?? {},
1050
+ ...email ? { email } : {},
1051
+ ...organizationId ? { organizationId } : {},
1052
+ ...organizationName ? { organizationName } : {},
1053
+ ...grantedAt !== void 0 ? { grantedAt } : {}
1054
+ };
1055
+ return {
1056
+ ...baseCredential,
1057
+ provider: "claude",
1058
+ accessToken: payload.access_token.trim(),
1059
+ ...refreshToken ? { refreshToken } : {},
1060
+ ...expiresIn !== void 0 ? { expiresAt: now + expiresIn * 1e3 - ANTHROPIC_ACCESS_TOKEN_CLIENT_SKEW_MS } : baseCredential?.expiresAt !== void 0 ? { expiresAt: baseCredential.expiresAt } : {},
1061
+ ...scope ? { scope } : {},
1062
+ ...accountId ? { accountId } : {},
1063
+ ...Object.keys(metadata).length > 0 ? { metadata } : {},
1064
+ obtainedAt: now
1065
+ };
1066
+ }
1067
+ async function refreshAnthropicToken(credential, deps = {}) {
1068
+ if (!credential.refreshToken) {
1069
+ throw new Error("Claude credential has no refresh_token");
1070
+ }
1071
+ const fetchImpl = deps.fetchImpl ?? fetch;
1072
+ const now = deps.now?.() ?? Date.now();
1073
+ const warn = deps.warn ?? console.warn;
1074
+ const response = await fetchImpl(ANTHROPIC_OAUTH_TOKEN_URL, {
1075
+ method: "POST",
1076
+ headers: {
1077
+ "Content-Type": "application/json",
1078
+ "anthropic-beta": ANTHROPIC_OAUTH_BETA,
1079
+ "User-Agent": "nolo-cli userOAuthProvider"
1080
+ },
1081
+ body: JSON.stringify({
1082
+ grant_type: "refresh_token",
1083
+ client_id: ANTHROPIC_OAUTH_CLIENT_ID,
1084
+ refresh_token: credential.refreshToken
1085
+ }),
1086
+ signal: AbortSignal.timeout(3e4)
1087
+ });
1088
+ const payload = await response.json().catch(() => ({}));
1089
+ if (!response.ok) {
1090
+ throw classifyOAuthRefreshHttpFailure(response.status, payload, response.headers);
1091
+ }
1092
+ if (typeof payload.access_token !== "string" || !payload.access_token.trim()) {
1093
+ throw new OAuthRefreshError("bad_response");
1094
+ }
1095
+ const identityCheckedAt = asOptionalFiniteNumber(credential.metadata?.identityCheckedAt);
1096
+ const identityIncomplete = !credential.accountId || !credential.metadata?.email || !credential.metadata?.organizationId;
1097
+ const orgNameMissing = !credential.metadata?.organizationName;
1098
+ const identityStale = identityCheckedAt === void 0 || now - identityCheckedAt >= ANTHROPIC_IDENTITY_RECHECK_INTERVAL_MS;
1099
+ const shouldCheck = identityIncomplete || identityStale || orgNameMissing && identityStale;
1100
+ const bootstrap = shouldCheck ? await fetchAnthropicBootstrapIdentity(payload.access_token, fetchImpl) : {};
1101
+ const updatedMetadata = {
1102
+ ...credential.metadata ?? {}
1103
+ };
1104
+ if (shouldCheck) {
1105
+ updatedMetadata.identityCheckedAt = now;
1106
+ }
1107
+ if (bootstrap.accountId && bootstrap.accountId !== credential.accountId) {
1108
+ payload.account = { ...payload.account, uuid: bootstrap.accountId };
1109
+ }
1110
+ if (bootstrap.email && bootstrap.email !== credential.metadata?.email) {
1111
+ payload.account = { ...payload.account, email_address: bootstrap.email };
1112
+ updatedMetadata.email = bootstrap.email;
1113
+ }
1114
+ const existingOrgId = credential.metadata?.organizationId;
1115
+ if (!bootstrap.orgId) {
1116
+ delete payload.organization;
1117
+ }
1118
+ if (bootstrap.orgId) {
1119
+ if (existingOrgId && existingOrgId !== bootstrap.orgId) {
1120
+ updatedMetadata.previousOrgId = existingOrgId;
1121
+ updatedMetadata.orgChangedAt = now;
1122
+ warn(
1123
+ `[anthropicOAuth] \u7EC4\u7EC7\u5F52\u5C5E\u5DF2\u968F\u4E0A\u6E38 bootstrap \u53D8\u66F4: ${existingOrgId} -> ${bootstrap.orgId}`
1124
+ );
1125
+ }
1126
+ payload.organization = {
1127
+ ...payload.organization,
1128
+ uuid: bootstrap.orgId,
1129
+ ...bootstrap.orgName ? { name: bootstrap.orgName } : {}
1130
+ };
1131
+ updatedMetadata.organizationId = bootstrap.orgId;
1132
+ if (bootstrap.orgName) {
1133
+ updatedMetadata.organizationName = bootstrap.orgName;
1134
+ }
1135
+ }
1136
+ return normalizeAnthropicTokenPayload({
1137
+ payload,
1138
+ baseCredential: {
1139
+ ...credential,
1140
+ ...Object.keys(updatedMetadata).length > 0 ? { metadata: updatedMetadata } : { metadata: void 0 }
1141
+ },
1142
+ now,
1143
+ // 显式声明是刷新:grantedAt 必须沿用已存值,绝不因为「这次拿到了新 token」
1144
+ // 就把 30 天寿命重新起算——refresh 轮换不延长 grant 家族寿命。
1145
+ isInitialLogin: false
1146
+ });
1147
+ }
1148
+ var anthropicRefresh = refreshAnthropicToken;
1149
+
847
1150
  // packages/cli/oauth/serverSyncConfig.ts
848
1151
  function resolveServerSyncConfig() {
849
1152
  const envServer = process.env.NOLO_SERVER?.trim() || process.env.NOLO_SERVER_URL?.trim() || process.env.BASE_URL?.trim() || "";
@@ -1076,87 +1379,6 @@ async function refreshXaiToken(credential, deps = {}) {
1076
1379
  }
1077
1380
  var xaiRefresh = refreshXaiToken;
1078
1381
 
1079
- // packages/agent-runtime/anthropicOAuth.ts
1080
- var ANTHROPIC_OAUTH_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
1081
- var ANTHROPIC_OAUTH_AUTHORIZE_URL = "https://claude.ai/oauth/authorize";
1082
- var ANTHROPIC_OAUTH_TOKEN_URL = "https://api.anthropic.com/v1/oauth/token";
1083
- var ANTHROPIC_OAUTH_CALLBACK_PORT = 54545;
1084
- var ANTHROPIC_OAUTH_REDIRECT_URI = `http://localhost:${ANTHROPIC_OAUTH_CALLBACK_PORT}/callback`;
1085
- var ANTHROPIC_OAUTH_SCOPES = [
1086
- "org:create_api_key",
1087
- "user:profile",
1088
- "user:inference",
1089
- "user:sessions:claude_code",
1090
- "user:mcp_servers",
1091
- "user:file_upload"
1092
- ];
1093
- var ANTHROPIC_ACCESS_TOKEN_CLIENT_SKEW_MS = 5 * 60 * 1e3;
1094
- var ANTHROPIC_OAUTH_BETA = "oauth-2025-04-20";
1095
- function normalizeAnthropicTokenPayload(args) {
1096
- const { payload, baseCredential, now = Date.now() } = args;
1097
- if (typeof payload.access_token !== "string" || !payload.access_token.trim()) {
1098
- throw new Error("Claude OAuth token response missing access_token");
1099
- }
1100
- const expiresIn = asOptionalFiniteNumber(payload.expires_in);
1101
- const accountId = typeof payload.account?.uuid === "string" && payload.account.uuid ? payload.account.uuid : baseCredential?.accountId;
1102
- const email = typeof payload.account?.email_address === "string" && payload.account.email_address ? payload.account.email_address : baseCredential?.metadata?.email;
1103
- const organizationId = typeof payload.organization?.uuid === "string" && payload.organization.uuid ? payload.organization.uuid : baseCredential?.metadata?.organizationId;
1104
- const organizationName = typeof payload.organization?.name === "string" && payload.organization.name ? payload.organization.name : baseCredential?.metadata?.organizationName;
1105
- const refreshToken = typeof payload.refresh_token === "string" && payload.refresh_token.trim() ? payload.refresh_token.trim() : baseCredential?.refreshToken;
1106
- const scope = typeof payload.scope === "string" && payload.scope ? payload.scope : baseCredential?.scope;
1107
- const metadata = {
1108
- ...baseCredential?.metadata ?? {},
1109
- ...email ? { email } : {},
1110
- ...organizationId ? { organizationId } : {},
1111
- ...organizationName ? { organizationName } : {}
1112
- };
1113
- return {
1114
- ...baseCredential,
1115
- provider: "claude",
1116
- accessToken: payload.access_token.trim(),
1117
- ...refreshToken ? { refreshToken } : {},
1118
- ...expiresIn !== void 0 ? { expiresAt: now + expiresIn * 1e3 - ANTHROPIC_ACCESS_TOKEN_CLIENT_SKEW_MS } : baseCredential?.expiresAt !== void 0 ? { expiresAt: baseCredential.expiresAt } : {},
1119
- ...scope ? { scope } : {},
1120
- ...accountId ? { accountId } : {},
1121
- ...Object.keys(metadata).length > 0 ? { metadata } : {},
1122
- obtainedAt: now
1123
- };
1124
- }
1125
- async function refreshAnthropicToken(credential, deps = {}) {
1126
- if (!credential.refreshToken) {
1127
- throw new Error("Claude credential has no refresh_token");
1128
- }
1129
- const fetchImpl = deps.fetchImpl ?? fetch;
1130
- const response = await fetchImpl(ANTHROPIC_OAUTH_TOKEN_URL, {
1131
- method: "POST",
1132
- headers: {
1133
- "Content-Type": "application/json",
1134
- "anthropic-beta": ANTHROPIC_OAUTH_BETA,
1135
- "User-Agent": "nolo-cli userOAuthProvider"
1136
- },
1137
- body: JSON.stringify({
1138
- grant_type: "refresh_token",
1139
- client_id: ANTHROPIC_OAUTH_CLIENT_ID,
1140
- refresh_token: credential.refreshToken
1141
- }),
1142
- signal: AbortSignal.timeout(3e4)
1143
- });
1144
- const payload = await response.json().catch(() => ({}));
1145
- if (!response.ok) {
1146
- throw classifyOAuthRefreshHttpFailure(response.status, payload, response.headers);
1147
- }
1148
- if (typeof payload.access_token !== "string" || !payload.access_token.trim()) {
1149
- throw new OAuthRefreshError("bad_response");
1150
- }
1151
- const now = deps.now?.() ?? Date.now();
1152
- return normalizeAnthropicTokenPayload({
1153
- payload,
1154
- baseCredential: credential,
1155
- now
1156
- });
1157
- }
1158
- var anthropicRefresh = refreshAnthropicToken;
1159
-
1160
1382
  // packages/agent-runtime/cursorOAuth.ts
1161
1383
  var CURSOR_LOGIN_URL = "https://cursor.com/loginDeepControl";
1162
1384
  var CURSOR_POLL_URL = "https://api2.cursor.sh/auth/poll";
@@ -1246,6 +1468,9 @@ async function refreshCursorToken(credential, deps = {}) {
1246
1468
  var cursorRefresh = refreshCursorToken;
1247
1469
 
1248
1470
  export {
1471
+ resolveClaudeCodeVersion,
1472
+ getClaudeCodeUserAgent,
1473
+ adoptRequiredClaudeCodeVersion,
1249
1474
  startCallbackServer,
1250
1475
  runAntigravityOAuthLogin,
1251
1476
  refreshAntigravityOAuthToken,
@@ -1277,6 +1502,8 @@ export {
1277
1502
  ANTHROPIC_OAUTH_CALLBACK_PORT,
1278
1503
  ANTHROPIC_OAUTH_REDIRECT_URI,
1279
1504
  ANTHROPIC_OAUTH_SCOPES,
1505
+ anthropicGrantRemainingMs,
1506
+ fetchAnthropicBootstrapIdentity,
1280
1507
  normalizeAnthropicTokenPayload,
1281
1508
  anthropicRefresh,
1282
1509
  CURSOR_LOGIN_URL,
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-NBTY7YJF.js";
6
6
  import {
7
7
  resolveCliLocalRuntimeKeyCapability
8
- } from "./chunk-SEEXRWNB.js";
8
+ } from "./chunk-ACMRWLRR.js";
9
9
  import {
10
10
  HIGH_RISK_MUTATION_TOOL_NAMES
11
11
  } from "./chunk-2Q3LOAFE.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveAgentImageInputSupport
3
- } from "./chunk-6I7ZP7KJ.js";
3
+ } from "./chunk-JBWLZ3CB.js";
4
4
  import {
5
5
  TOOL_HAD_IMAGES,
6
6
  hadToolImages
@@ -2,7 +2,7 @@ import {
2
2
  deleteDbRecord,
3
3
  queryUserRecords,
4
4
  readDbRecord
5
- } from "./chunk-CJ37ZMCQ.js";
5
+ } from "./chunk-7C45ONOU.js";
6
6
  import {
7
7
  mergeAndDedupUserData
8
8
  } from "./chunk-OXME3PEE.js";
@@ -913,6 +913,18 @@ var authStrings = {
913
913
  "auth.envUpdated": {
914
914
  en: "[nolo] Updated {0} with CLOUDFLARE_EMAIL_ROUTING_API_TOKEN.",
915
915
  zh: "[nolo] \u5DF2\u66F4\u65B0 {0} \u91CC\u7684 CLOUDFLARE_EMAIL_ROUTING_API_TOKEN\u3002"
916
+ },
917
+ "auth.claudeGrantExpired": {
918
+ en: "[nolo] Claude OAuth grant has expired. Interactive login is required (run: nolo auth claude).",
919
+ zh: "[nolo] Claude OAuth grant \u5DF2\u8FC7\u671F\uFF0C\u5FC5\u987B\u91CD\u65B0\u4EA4\u4E92\u5F0F\u767B\u5F55\uFF08\u8FD0\u884C\uFF1Anolo auth claude\uFF09\u3002"
920
+ },
921
+ "auth.claudeGrantExpiringSoon": {
922
+ en: "[nolo] Claude OAuth grant expires in {0} day(s). Re-authenticate soon with: nolo auth claude.",
923
+ zh: "[nolo] Claude OAuth grant \u5C06\u5728 {0} \u5929\u5185\u8FC7\u671F\uFF0C\u8BF7\u5C3D\u5FEB\u91CD\u65B0\u767B\u5F55\uFF1Anolo auth claude\u3002"
924
+ },
925
+ "auth.claudeGrantValidDays": {
926
+ en: "[nolo] Claude OAuth grant valid for about {0} day(s).",
927
+ zh: "[nolo] Claude OAuth grant \u9884\u8BA1\u8FD8\u5269\u7EA6 {0} \u5929\u6709\u6548\u3002"
916
928
  }
917
929
  };
918
930
 
@@ -7,7 +7,7 @@ import {
7
7
  mergeReferences,
8
8
  resolveReferenceAssets,
9
9
  resolveToolsFromKeys
10
- } from "./chunk-BER2RSTL.js";
10
+ } from "./chunk-DTLSKEXN.js";
11
11
  import {
12
12
  UI_CARD_ENVELOPE_MAX_BYTES,
13
13
  getAllToolRuns,
@@ -18,14 +18,14 @@ import {
18
18
  selectSpaceContextLevel,
19
19
  selectUserTonePreset,
20
20
  uiCardFallback
21
- } from "./chunk-KCYY5F2P.js";
21
+ } from "./chunk-ZIEPLFWS.js";
22
22
  import {
23
23
  resolveAgentRecommendedSkillNames,
24
24
  resolveAgentRequiredPackIds
25
25
  } from "./chunk-I5PBXF7O.js";
26
26
  import {
27
27
  getDocState
28
- } from "./chunk-M43VXSMX.js";
28
+ } from "./chunk-JX2QFYIA.js";
29
29
  import {
30
30
  resolveToolBaseUrl
31
31
  } from "./chunk-MYOH447Z.js";
@@ -37,7 +37,7 @@ import {
37
37
  } from "./chunk-A2ZMIRLN.js";
38
38
  import {
39
39
  getTableState
40
- } from "./chunk-IZLXIV5L.js";
40
+ } from "./chunk-HSZ2YEPR.js";
41
41
  import {
42
42
  getCurrentSpaceIdRaw,
43
43
  getViewMode
@@ -46,7 +46,7 @@ import {
46
46
  PERSONALIZATION_DIALOG_CATEGORY,
47
47
  buildPersonalizationDialogPolicyContext,
48
48
  selectAllMsgs
49
- } from "./chunk-HNO2SEYI.js";
49
+ } from "./chunk-KJCSY4TW.js";
50
50
  import {
51
51
  selectPendingFiles
52
52
  } from "./chunk-OWYYDMGJ.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  fetchReferenceContents,
3
3
  resolveReferenceAssets
4
- } from "./chunk-BER2RSTL.js";
4
+ } from "./chunk-DTLSKEXN.js";
5
5
  import {
6
6
  updateTokensAction
7
- } from "./chunk-HNO2SEYI.js";
7
+ } from "./chunk-KJCSY4TW.js";
8
8
  import {
9
9
  applyUpdateTokensFulfilled
10
10
  } from "./chunk-OWYYDMGJ.js";
@@ -21,7 +21,7 @@ import {
21
21
  isAntigravityOAuthAgent,
22
22
  isSubscriptionEndpoint,
23
23
  isSubscriptionOAuthCredential
24
- } from "./chunk-VEUSD6OF.js";
24
+ } from "./chunk-YF4ZRVP3.js";
25
25
  import {
26
26
  getModelAbility
27
27
  } from "./chunk-T43B7LB2.js";
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-HS7MLR74.js";
4
4
  import {
5
5
  performServerProxyFetchWithRetry
6
- } from "./chunk-BER2RSTL.js";
6
+ } from "./chunk-DTLSKEXN.js";
7
7
  import {
8
8
  fetchServerSyncedCredential
9
- } from "./chunk-YR4MRACW.js";
9
+ } from "./chunk-F6MQO3YY.js";
10
10
  import {
11
11
  buildSkillGuidancePromptBlock
12
12
  } from "./chunk-Y6M7KJOA.js";
@@ -23,7 +23,7 @@ import {
23
23
  compileContextLayers,
24
24
  detectDispatchIntentFromMessages,
25
25
  resolveToolGuidedSections
26
- } from "./chunk-IK6AAUGM.js";
26
+ } from "./chunk-6AMR3AE6.js";
27
27
  import {
28
28
  convertMessagesToResponsesInput,
29
29
  getUsageRequestOptions,
@@ -36,7 +36,7 @@ import {
36
36
  import {
37
37
  resolveAgentCallPlan,
38
38
  resolveClientWire
39
- } from "./chunk-P4YLK2OD.js";
39
+ } from "./chunk-XNOILBHV.js";
40
40
  import {
41
41
  createFileCredentialBroker
42
42
  } from "./chunk-UIOEHFF6.js";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createCliLocalRuntimeAdapter,
3
3
  summarizeEndpoint
4
- } from "./chunk-VXZ4YYNK.js";
4
+ } from "./chunk-2U2DMUGG.js";
5
5
  import {
6
6
  clipMultilineText
7
- } from "./chunk-KCYY5F2P.js";
7
+ } from "./chunk-ZIEPLFWS.js";
8
8
  import {
9
9
  runLocalAgentTurn
10
- } from "./chunk-6KWPMJ5C.js";
10
+ } from "./chunk-TYKUYQDP.js";
11
11
  import {
12
12
  applyToolSurfaceConstraints
13
13
  } from "./chunk-2Q3LOAFE.js";
@@ -38,7 +38,7 @@ import {
38
38
  } from "./chunk-Y6ROFCZO.js";
39
39
  import {
40
40
  t
41
- } from "./chunk-E4LYPSYM.js";
41
+ } from "./chunk-PPCUXO3E.js";
42
42
  import {
43
43
  asTrimmedNonEmptyStringArray
44
44
  } from "./chunk-I42VC5KR.js";