nolo-cli 0.140.0-alpha.2 → 0.141.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.
- package/{_executeModel-SOYFJXV6.js → _executeModel-PHFKA2OL.js} +11 -11
- package/{agentEmailCommands-FMB2MKEQ.js → agentEmailCommands-XCFMV73Q.js} +14 -13
- package/{agentListCommands-FKMX7KWB.js → agentListCommands-MWAR7A4K.js} +19 -0
- package/{agentMachineCommands-XMVB676S.js → agentMachineCommands-VDT575S6.js} +1 -1
- package/{agentRecordCommands-KGBQJLVJ.js → agentRecordCommands-PBAKB3YI.js} +13 -12
- package/{agentRunCommand-SEDWFYXO.js → agentRunCommand-3JJVJWKN.js} +12 -12
- package/{agentRunControl-AVJR4JW4.js → agentRunControl-MD72KLQA.js} +2 -2
- package/{agentSlice-CFXREBVL.js → agentSlice-EYRJX2J6.js} +1 -1
- package/{authCommand-K62FH4X2.js → authCommand-VLT5WAYD.js} +2 -2
- package/{chatQueueReduxAdapter-PUEMG7YZ.js → chatQueueReduxAdapter-YNI7ALFW.js} +2 -2
- package/{chunk-PP6FTGA6.js → chunk-5VI55RD6.js} +15 -12
- package/{chunk-VPNHD2TS.js → chunk-63ZFMDDF.js} +1 -1
- package/{chunk-37GBLNHI.js → chunk-6YT7I7KF.js} +5 -5
- package/{chunk-F5IMTLHP.js → chunk-A3JENOEB.js} +2 -2
- package/{chunk-Q6QLBANW.js → chunk-AYLMRAUA.js} +6 -6
- package/{chunk-XWVHWH35.js → chunk-CRGSU5DB.js} +1 -1
- package/{chunk-3EFEN43K.js → chunk-DLT3R4CA.js} +1 -1
- package/{chunk-OMI6BKIS.js → chunk-DT7WS4NV.js} +3 -3
- package/{chunk-X6KARM5G.js → chunk-GYB5AS4J.js} +2 -2
- package/{chunk-ZW4TU76B.js → chunk-K7ASQNHP.js} +16 -1
- package/{chunk-3VNWWVKB.js → chunk-L4KXQ6QP.js} +11 -0
- package/{chunk-K3NOJJUS.js → chunk-MPRDXX4T.js} +17 -9
- package/{chunk-I3TQJXQ7.js → chunk-QFPJEU36.js} +5 -2
- package/{chunk-LLVHGBUH.js → chunk-RDIYKQKZ.js} +63 -9
- package/{chunk-OXY64W6K.js → chunk-SUFNELDG.js} +2 -2
- package/{chunk-2VMY5RLA.js → chunk-TS5BDIPV.js} +8 -8
- package/{chunk-XFEBG6NU.js → chunk-TUETDBTI.js} +2 -2
- package/{chunk-SNVNLFVK.js → chunk-TV5ODOAF.js} +3 -3
- package/chunk-U4STABYN.js +81 -0
- package/{commandRegistry-I7INNYGB.js → commandRegistry-RF5DRRAH.js} +27 -27
- package/{contentThunks-BHQXUKKG.js → contentThunks-2PJ4QDAV.js} +3 -3
- package/{createAgentAutomationAction-QS5HQOP5.js → createAgentAutomationAction-SWO62RE2.js} +3 -3
- package/{createDialogAction-ZTC23O42.js → createDialogAction-2BMDM4X3.js} +4 -4
- package/{createPageAction-RFAUZO6Y.js → createPageAction-HLSLX4R4.js} +3 -3
- package/{dialogSlice-OU5IGCJ5.js → dialogSlice-7IGCUDZE.js} +2 -2
- package/{docStore-UQF3EY2X.js → docStore-OD3NRNBN.js} +1 -1
- package/{handleSendMessageAction-NFT57BBK.js → handleSendMessageAction-PRF7JNOH.js} +2 -2
- package/index.js +2 -2
- package/{machineCommands-2WI4ISEU.js → machineCommands-DXVYZM4A.js} +12 -12
- package/{machineWsRunDispatch-XQDTKFVP.js → machineWsRunDispatch-VI2S5AUR.js} +12 -12
- package/package.json +1 -1
- package/{readlineWorkspace-XDHXGQ4Z.js → readlineWorkspace-YSDOBOSD.js} +51 -107
- package/{runAgentClientLoop-ZHN7EVIF.js → runAgentClientLoop-66UNGCTW.js} +9 -9
- package/{streamAgentChatTurn-KV7NADH2.js → streamAgentChatTurn-6F3M4KUY.js} +10 -10
- package/{tools-ZX3DP5DJ.js → tools-VSECJ5T7.js} +7 -7
- package/{updateDialogTitleAction-6ZCZK2I7.js → updateDialogTitleAction-WE5KY3SM.js} +3 -3
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
refreshSubscriptionQuotas
|
|
3
|
+
} from "./chunk-U4STABYN.js";
|
|
1
4
|
import {
|
|
2
5
|
clearCliLocalRuntimePreparedAgentCache
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5VI55RD6.js";
|
|
4
7
|
import {
|
|
5
8
|
getReadableCliDb
|
|
6
9
|
} from "./chunk-CTUQJVQM.js";
|
|
@@ -67,8 +70,20 @@ async function runAgentReadCommand(args, deps = {}) {
|
|
|
67
70
|
if (!result) {
|
|
68
71
|
throw new Error(`agent not found: ${agentKey}`);
|
|
69
72
|
}
|
|
73
|
+
const rawRecord = result.record;
|
|
74
|
+
const recordQuota = rawRecord?.quota;
|
|
75
|
+
const hasSubscriptionCredential = typeof rawRecord?.apiKeyRef === "string" && rawRecord.apiKeyRef.trim() !== "";
|
|
76
|
+
const fresh = hasSubscriptionCredential ? await refreshSubscriptionQuotas({
|
|
77
|
+
entries: [{ key: result.agentKey, ...recordQuota ? { quota: recordQuota } : {} }],
|
|
78
|
+
onlyKeys: [result.agentKey],
|
|
79
|
+
env,
|
|
80
|
+
cliArgs: args,
|
|
81
|
+
fetchImpl
|
|
82
|
+
}) : {};
|
|
83
|
+
const quota = fresh[result.agentKey] ?? recordQuota;
|
|
70
84
|
output.write(JSON.stringify({
|
|
71
85
|
...normalizeAgentRecordForOutput(result.agentKey, authToken, result.record),
|
|
86
|
+
...quota ? { quota } : {},
|
|
72
87
|
source: result.source
|
|
73
88
|
}, null, 2));
|
|
74
89
|
output.write("\n");
|
|
@@ -2,6 +2,15 @@ import {
|
|
|
2
2
|
estimateTokenCount
|
|
3
3
|
} from "./chunk-PSCNXBYA.js";
|
|
4
4
|
|
|
5
|
+
// packages/ai/tools/agent/runTitle.ts
|
|
6
|
+
var RUN_TITLE_MAX = 60;
|
|
7
|
+
function normalizeRunTitle(value) {
|
|
8
|
+
if (typeof value !== "string") return void 0;
|
|
9
|
+
const cleaned = value.replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ").replace(/\s+/g, " ").trim();
|
|
10
|
+
if (!cleaned) return void 0;
|
|
11
|
+
return cleaned.length > RUN_TITLE_MAX ? `${cleaned.slice(0, RUN_TITLE_MAX - 1)}\u2026` : cleaned;
|
|
12
|
+
}
|
|
13
|
+
|
|
5
14
|
// packages/ai/tools/agent/agentRunDisplayHelpers.ts
|
|
6
15
|
function buildDelegatedTaskContent(task, input) {
|
|
7
16
|
if (input === void 0 || input === null) {
|
|
@@ -278,6 +287,8 @@ function isAgentRunTerminalStatus(status) {
|
|
|
278
287
|
}
|
|
279
288
|
|
|
280
289
|
export {
|
|
290
|
+
RUN_TITLE_MAX,
|
|
291
|
+
normalizeRunTitle,
|
|
281
292
|
buildDelegatedTaskContent,
|
|
282
293
|
calculateDelegatedPayloadMetrics,
|
|
283
294
|
getAgentRunStatusIcon,
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
parseRetryAfterHeaderMs
|
|
25
25
|
} from "./chunk-3L2WKC3W.js";
|
|
26
26
|
import {
|
|
27
|
+
RUN_TITLE_MAX,
|
|
27
28
|
TASK_PREVIEW_MAX,
|
|
28
29
|
buildDelegatedTaskContent,
|
|
29
30
|
calculateDelegatedPayloadMetrics,
|
|
@@ -32,11 +33,12 @@ import {
|
|
|
32
33
|
formatStartRunCard,
|
|
33
34
|
formatStatusRunCard,
|
|
34
35
|
formatStopRunCard,
|
|
36
|
+
normalizeRunTitle,
|
|
35
37
|
resolveRunLabel
|
|
36
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-L4KXQ6QP.js";
|
|
37
39
|
import {
|
|
38
40
|
createDialogAction
|
|
39
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-A3JENOEB.js";
|
|
40
42
|
import {
|
|
41
43
|
addMemberSpace,
|
|
42
44
|
fetchAuthoritativeRemoteSpace,
|
|
@@ -60,7 +62,7 @@ import {
|
|
|
60
62
|
} from "./chunk-VF4K2QE6.js";
|
|
61
63
|
import {
|
|
62
64
|
createDocState
|
|
63
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-TUETDBTI.js";
|
|
64
66
|
import {
|
|
65
67
|
setDialogExtraReferencesAction
|
|
66
68
|
} from "./chunk-Z7IZQF56.js";
|
|
@@ -99,7 +101,7 @@ import {
|
|
|
99
101
|
updateContentCategory,
|
|
100
102
|
updateContentTitle,
|
|
101
103
|
writeStoredCollapsedCategories
|
|
102
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-CRGSU5DB.js";
|
|
103
105
|
import {
|
|
104
106
|
getCurrentSpaceId,
|
|
105
107
|
getCurrentSpaceIdRaw,
|
|
@@ -121,14 +123,14 @@ import {
|
|
|
121
123
|
selectMsgById,
|
|
122
124
|
uiAskChoiceFunc,
|
|
123
125
|
uiAskChoiceFunctionSchema
|
|
124
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-TS5BDIPV.js";
|
|
125
127
|
import {
|
|
126
128
|
createAgent,
|
|
127
129
|
deleteServerSyncedCredential,
|
|
128
130
|
runLlm,
|
|
129
131
|
streamAgentChatTurn,
|
|
130
132
|
updateAgent
|
|
131
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-TV5ODOAF.js";
|
|
132
134
|
import {
|
|
133
135
|
getActiveDialogKey,
|
|
134
136
|
selectCurrentDialogKey,
|
|
@@ -3976,7 +3978,7 @@ async function deleteDialogsFunc(args, thunkApi) {
|
|
|
3976
3978
|
const deletedDialogIds = [];
|
|
3977
3979
|
const deletedDialogKeys = [];
|
|
3978
3980
|
const failures = [];
|
|
3979
|
-
const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-
|
|
3981
|
+
const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-7IGCUDZE.js");
|
|
3980
3982
|
for (const target of targets) {
|
|
3981
3983
|
try {
|
|
3982
3984
|
await thunkApi.dispatch(deleteDialog2(target.dbKey)).unwrap();
|
|
@@ -13223,6 +13225,10 @@ function buildStartAgentRunFunctionSchema(opts) {
|
|
|
13223
13225
|
type: "string",
|
|
13224
13226
|
description: "\u53EF\u9009\u3002\u7531 listAgents/readAgent \u5F97\u5230\u7684\u53EF\u8BFB Agent \u540D\u79F0\uFF0C\u7528\u4E8E TUI \u8FD0\u884C\u5361\u7247\u5C55\u793A\u3002"
|
|
13225
13227
|
},
|
|
13228
|
+
title: {
|
|
13229
|
+
type: "string",
|
|
13230
|
+
description: `\u53EF\u9009\u3002\u8FD9\u6B21\u5B50\u4EFB\u52A1\u7684\u77ED\u6807\u9898\uFF08\u2264${RUN_TITLE_MAX} \u5B57\uFF0C\u4E00\u884C\uFF0C\u5982\u300C\u590D\u5BA1\u989D\u5EA6 diff\u300D\u300COpus \u672C\u5730\u62C9\u53D6\u8BBE\u8BA1\u300D\uFF09\u3002\u672C\u5730 TUI \u7684\u8FD0\u884C\u533A\u7528\u5B83\u6807\u8BC6\u8FD9\u4E2A run\uFF08\u670D\u52A1\u7AEF Web \u8DEF\u5F84\u53EA\u5728\u8FD4\u56DE\u503C\u91CC\u56DE\u663E\uFF0C\u4E0D\u6301\u4E45\u5316\uFF09\u3002\u540C\u4E00\u4E2A agent \u5E76\u53D1\u591A\u4E2A run \u65F6\u540D\u5B57\u5B8C\u5168\u76F8\u540C\u3001brief \u5F00\u5934\u53C8\u5E38\u662F\u540C\u6837\u7684\u5957\u8BDD\uFF0C\u5F3A\u70C8\u5EFA\u8BAE\u586B\u5199\uFF1B\u4E0D\u586B\u5219\u4E0D\u663E\u793A\u6807\u9898\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u4ECE\u4EFB\u52A1\u6B63\u6587\u751F\u6210\u3002`
|
|
13231
|
+
},
|
|
13226
13232
|
// 刻意不向模型暴露 ephemeral:AI 不需要知道这个选项,不提供即默认持久化。
|
|
13227
13233
|
// 非持久化 run 在失败/stall/输出被截断时不会留下任何可找回的结论,而
|
|
13228
13234
|
// review findings 与子任务产出都必须可回读——把选项藏起来比写一条
|
|
@@ -13346,6 +13352,7 @@ async function startAgentRunFunc(args, thunkApi, _context) {
|
|
|
13346
13352
|
const resolvedName = agentName?.trim() || bgResult.agentName || bgResult.name;
|
|
13347
13353
|
const identity = { agentName: resolvedName, agentKey, runId };
|
|
13348
13354
|
const taskPreview = task.replace(/\s+/g, " ").trim().slice(0, TASK_PREVIEW_MAX);
|
|
13355
|
+
const title = normalizeRunTitle(args.title);
|
|
13349
13356
|
return {
|
|
13350
13357
|
rawData: {
|
|
13351
13358
|
runId,
|
|
@@ -13358,6 +13365,7 @@ async function startAgentRunFunc(args, thunkApi, _context) {
|
|
|
13358
13365
|
batchId: effectiveBatchId,
|
|
13359
13366
|
...resolvedName ? { agentName: resolvedName } : {},
|
|
13360
13367
|
...taskPreview ? { taskPreview } : {},
|
|
13368
|
+
...title ? { title } : {},
|
|
13361
13369
|
payloadMetrics
|
|
13362
13370
|
},
|
|
13363
13371
|
displayData: formatStartRunCard(resolveRunLabel(identity), status, {
|
|
@@ -15035,7 +15043,7 @@ var executeToolRun = createAsyncThunk(
|
|
|
15035
15043
|
if (!executionInput) {
|
|
15036
15044
|
throw new Error(`ToolRun ${id} has no input to execute with.`);
|
|
15037
15045
|
}
|
|
15038
|
-
const { findToolExecutor: findToolExecutor2 } = await import("./tools-
|
|
15046
|
+
const { findToolExecutor: findToolExecutor2 } = await import("./tools-VSECJ5T7.js");
|
|
15039
15047
|
const { executor } = findToolExecutor2(run.toolName);
|
|
15040
15048
|
toolRunStarted({
|
|
15041
15049
|
id: run.id,
|
|
@@ -17542,7 +17550,7 @@ async function updateDocFunc(args, thunkApi) {
|
|
|
17542
17550
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
17543
17551
|
};
|
|
17544
17552
|
await dispatch(write({ data: updatedPageData, customKey: id })).unwrap();
|
|
17545
|
-
const { getDocState, applyExternalDocUpdate } = await import("./docStore-
|
|
17553
|
+
const { getDocState, applyExternalDocUpdate } = await import("./docStore-OD3NRNBN.js");
|
|
17546
17554
|
if (getDocState().pageKey === id) {
|
|
17547
17555
|
applyExternalDocUpdate({
|
|
17548
17556
|
slateData: finalSlateData,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isAgentRunTerminalStatus
|
|
3
|
-
|
|
2
|
+
isAgentRunTerminalStatus,
|
|
3
|
+
normalizeRunTitle
|
|
4
|
+
} from "./chunk-L4KXQ6QP.js";
|
|
4
5
|
import {
|
|
5
6
|
isCompiledBinary,
|
|
6
7
|
resolveCliEntrypointPath
|
|
@@ -836,10 +837,12 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
836
837
|
}
|
|
837
838
|
} catch {
|
|
838
839
|
}
|
|
840
|
+
const title = normalizeRunTitle(input.title);
|
|
839
841
|
const record = {
|
|
840
842
|
runId,
|
|
841
843
|
agentKey: input.agentKey,
|
|
842
844
|
...typeof input.agentName === "string" && input.agentName.trim() ? { agentName: input.agentName.trim() } : {},
|
|
845
|
+
...title ? { title } : {},
|
|
843
846
|
cwd: input.cwd,
|
|
844
847
|
...messagePath ? { msgFile: messagePath } : input.msgFile ? { msgFile: input.msgFile } : {},
|
|
845
848
|
startedAt: now().toISOString(),
|
|
@@ -367,6 +367,64 @@ async function refreshAntigravityOAuthToken(credential, deps = {}) {
|
|
|
367
367
|
// packages/cli/oauth/flows/openai-codex.ts
|
|
368
368
|
import { createHash as createHash2 } from "node:crypto";
|
|
369
369
|
|
|
370
|
+
// packages/agent-runtime/oauthRefreshError.ts
|
|
371
|
+
var PERMANENT_REFRESH_CODES = /* @__PURE__ */ new Set(["invalid_grant", "refresh_token_reused", "invalid_client"]);
|
|
372
|
+
var SAFE_MESSAGES = {
|
|
373
|
+
invalid_grant: "refresh token \u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u6388\u6743",
|
|
374
|
+
refresh_token_reused: "refresh token \u5DF2\u88AB\u5176\u4ED6\u526F\u672C\u4F7F\u7528\uFF0C\u8BF7\u91CD\u65B0\u6388\u6743",
|
|
375
|
+
invalid_client: "OAuth \u5BA2\u6237\u7AEF\u88AB\u62D2\u7EDD\uFF0C\u8BF7\u91CD\u65B0\u6388\u6743",
|
|
376
|
+
unauthorized: "\u4E0A\u6E38\u62D2\u7EDD\u4E86\u5237\u65B0\u8BF7\u6C42\uFF08401/403\uFF09",
|
|
377
|
+
rate_limited: "\u4E0A\u6E38\u9650\u6D41\uFF0C\u7A0D\u540E\u91CD\u8BD5",
|
|
378
|
+
http_5xx: "\u4E0A\u6E38\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528",
|
|
379
|
+
network: "\u65E0\u6CD5\u8FDE\u63A5\u4E0A\u6E38",
|
|
380
|
+
bad_response: "\u4E0A\u6E38\u8FD4\u56DE\u4E86\u65E0\u6CD5\u8BC6\u522B\u7684\u54CD\u5E94",
|
|
381
|
+
unknown: "\u5237\u65B0\u5931\u8D25"
|
|
382
|
+
};
|
|
383
|
+
var OAuthRefreshError = class extends Error {
|
|
384
|
+
code;
|
|
385
|
+
status;
|
|
386
|
+
retryAfterMs;
|
|
387
|
+
constructor(code, opts = {}) {
|
|
388
|
+
super(SAFE_MESSAGES[code]);
|
|
389
|
+
this.name = "OAuthRefreshError";
|
|
390
|
+
this.code = code;
|
|
391
|
+
if (opts.status !== void 0) this.status = opts.status;
|
|
392
|
+
if (opts.retryAfterMs !== void 0) this.retryAfterMs = opts.retryAfterMs;
|
|
393
|
+
}
|
|
394
|
+
get permanent() {
|
|
395
|
+
return PERMANENT_REFRESH_CODES.has(this.code);
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
function readErrorCode(payload) {
|
|
399
|
+
if (!payload || typeof payload !== "object") return void 0;
|
|
400
|
+
const err = payload.error;
|
|
401
|
+
if (typeof err === "string") return err;
|
|
402
|
+
if (err && typeof err === "object") {
|
|
403
|
+
const code = err.code;
|
|
404
|
+
if (typeof code === "string") return code;
|
|
405
|
+
}
|
|
406
|
+
return void 0;
|
|
407
|
+
}
|
|
408
|
+
function classifyOAuthRefreshHttpFailure(status, payload, headers) {
|
|
409
|
+
const raw = readErrorCode(payload)?.toLowerCase();
|
|
410
|
+
if (raw === "invalid_grant") return new OAuthRefreshError("invalid_grant", { status });
|
|
411
|
+
if (raw === "refresh_token_reused") {
|
|
412
|
+
return new OAuthRefreshError("refresh_token_reused", { status });
|
|
413
|
+
}
|
|
414
|
+
if (raw === "invalid_client") return new OAuthRefreshError("invalid_client", { status });
|
|
415
|
+
if (status === 429) {
|
|
416
|
+
const seconds = Number(headers?.get("retry-after"));
|
|
417
|
+
return new OAuthRefreshError("rate_limited", {
|
|
418
|
+
status,
|
|
419
|
+
...Number.isFinite(seconds) && seconds > 0 ? { retryAfterMs: seconds * 1e3 } : {}
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
if (status === 401 || status === 403) return new OAuthRefreshError("unauthorized", { status });
|
|
423
|
+
if (status >= 500) return new OAuthRefreshError("http_5xx", { status });
|
|
424
|
+
return new OAuthRefreshError("unknown", { status });
|
|
425
|
+
}
|
|
426
|
+
var TRANSIENT_MAX_MS = 15 * 6e4;
|
|
427
|
+
|
|
370
428
|
// packages/agent-runtime/openaiCodexOAuth.ts
|
|
371
429
|
var OPENAI_CODEX_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
372
430
|
var OPENAI_CODEX_SCOPES = [
|
|
@@ -463,17 +521,14 @@ async function refreshOpenAiCodexToken(credential, deps = {}) {
|
|
|
463
521
|
signal: AbortSignal.timeout(OPENAI_CODEX_TOKEN_REQUEST_TIMEOUT_MS)
|
|
464
522
|
});
|
|
465
523
|
} catch (error) {
|
|
466
|
-
throw new
|
|
467
|
-
`OpenAI Codex token refresh failed: ${toErrorMessage(error)}`
|
|
468
|
-
);
|
|
524
|
+
throw new OAuthRefreshError("network");
|
|
469
525
|
}
|
|
470
526
|
const payload = await response.json().catch(() => ({}));
|
|
471
527
|
if (!response.ok) {
|
|
472
|
-
|
|
473
|
-
throw new Error(`OpenAI Codex token refresh failed: ${detail}`);
|
|
528
|
+
throw classifyOAuthRefreshHttpFailure(response.status, payload, response.headers);
|
|
474
529
|
}
|
|
475
530
|
if (typeof payload.access_token !== "string" || !payload.access_token.trim()) {
|
|
476
|
-
throw new
|
|
531
|
+
throw new OAuthRefreshError("bad_response");
|
|
477
532
|
}
|
|
478
533
|
const now = deps.now?.() ?? Date.now();
|
|
479
534
|
return normalizeOpenAiCodexTokenPayload({
|
|
@@ -1047,11 +1102,10 @@ async function refreshAnthropicToken(credential, deps = {}) {
|
|
|
1047
1102
|
});
|
|
1048
1103
|
const payload = await response.json().catch(() => ({}));
|
|
1049
1104
|
if (!response.ok) {
|
|
1050
|
-
|
|
1051
|
-
throw new Error(`Claude token refresh failed: ${detail}`);
|
|
1105
|
+
throw classifyOAuthRefreshHttpFailure(response.status, payload, response.headers);
|
|
1052
1106
|
}
|
|
1053
1107
|
if (typeof payload.access_token !== "string" || !payload.access_token.trim()) {
|
|
1054
|
-
throw new
|
|
1108
|
+
throw new OAuthRefreshError("bad_response");
|
|
1055
1109
|
}
|
|
1056
1110
|
const now = deps.now?.() ?? Date.now();
|
|
1057
1111
|
return normalizeAnthropicTokenPayload({
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./chunk-6O4IK4V2.js";
|
|
12
12
|
import {
|
|
13
13
|
runLlm
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-TV5ODOAF.js";
|
|
15
15
|
import {
|
|
16
16
|
cleanupCliSessionForDialog
|
|
17
17
|
} from "./chunk-D76D3RTR.js";
|
|
@@ -23937,7 +23937,7 @@ var messageSlice = createSliceWithThunks({
|
|
|
23937
23937
|
runtimeOptions: args.runtimeOptions
|
|
23938
23938
|
});
|
|
23939
23939
|
if (agentKeyToUse) {
|
|
23940
|
-
const { streamAgentChatTurn } = await import("./agentSlice-
|
|
23940
|
+
const { streamAgentChatTurn } = await import("./agentSlice-EYRJX2J6.js");
|
|
23941
23941
|
await dispatch(
|
|
23942
23942
|
streamAgentChatTurn({
|
|
23943
23943
|
agentKey: agentKeyToUse,
|
|
@@ -25073,7 +25073,7 @@ var deleteDialogThunk = async (payload, thunkApi) => {
|
|
|
25073
25073
|
}
|
|
25074
25074
|
if (isCurrentDialog) {
|
|
25075
25075
|
await thunkApi.dispatch(resetMsgs());
|
|
25076
|
-
const { clearPendingAttachments: clearPendingAttachments2 } = await import("./dialogSlice-
|
|
25076
|
+
const { clearPendingAttachments: clearPendingAttachments2 } = await import("./dialogSlice-7IGCUDZE.js");
|
|
25077
25077
|
dispatch(clearPendingAttachments2());
|
|
25078
25078
|
}
|
|
25079
25079
|
return { dialogKey, isCurrentDialog, attachmentPlan };
|
|
@@ -25081,15 +25081,15 @@ var deleteDialogThunk = async (payload, thunkApi) => {
|
|
|
25081
25081
|
|
|
25082
25082
|
// packages/chat/dialog/dialogSlice.ts
|
|
25083
25083
|
var runCreateDialogAction = async (args, thunkApi) => {
|
|
25084
|
-
const { createDialogAction } = await import("./createDialogAction-
|
|
25084
|
+
const { createDialogAction } = await import("./createDialogAction-2BMDM4X3.js");
|
|
25085
25085
|
return createDialogAction(args, thunkApi);
|
|
25086
25086
|
};
|
|
25087
25087
|
var runCreateAgentAutomationAction = async (args, thunkApi) => {
|
|
25088
|
-
const { createAgentAutomationAction } = await import("./createAgentAutomationAction-
|
|
25088
|
+
const { createAgentAutomationAction } = await import("./createAgentAutomationAction-SWO62RE2.js");
|
|
25089
25089
|
return createAgentAutomationAction(args, thunkApi);
|
|
25090
25090
|
};
|
|
25091
25091
|
var runUpdateDialogTitleAction = async (args, thunkApi) => {
|
|
25092
|
-
const { updateDialogTitleAction } = await import("./updateDialogTitleAction-
|
|
25092
|
+
const { updateDialogTitleAction } = await import("./updateDialogTitleAction-WE5KY3SM.js");
|
|
25093
25093
|
return updateDialogTitleAction(args, thunkApi);
|
|
25094
25094
|
};
|
|
25095
25095
|
var runAddDialogAgentAction = async (args, thunkApi) => {
|
|
@@ -25113,7 +25113,7 @@ var runSetDialogExtraReferencesAction = async (args, thunkApi) => {
|
|
|
25113
25113
|
return setDialogExtraReferencesAction(args, thunkApi);
|
|
25114
25114
|
};
|
|
25115
25115
|
var runHandleSendMessageAction = async (args, thunkApi) => {
|
|
25116
|
-
const { handleSendMessageAction } = await import("./handleSendMessageAction-
|
|
25116
|
+
const { handleSendMessageAction } = await import("./handleSendMessageAction-PRF7JNOH.js");
|
|
25117
25117
|
return handleSendMessageAction(args, thunkApi);
|
|
25118
25118
|
};
|
|
25119
25119
|
function clearDialogState() {
|
|
@@ -25126,7 +25126,7 @@ var createPageAndAddReference = createAsyncThunk(
|
|
|
25126
25126
|
async (payload, { dispatch, getState, rejectWithValue }) => {
|
|
25127
25127
|
const { slateData, jsonData, title, type, fileId, groupId, dialogKey } = payload;
|
|
25128
25128
|
try {
|
|
25129
|
-
const { createDocState } = await import("./docStore-
|
|
25129
|
+
const { createDocState } = await import("./docStore-OD3NRNBN.js");
|
|
25130
25130
|
const pageKey = await createDocState(
|
|
25131
25131
|
{ slateData, title },
|
|
25132
25132
|
{ dispatch, getState }
|
|
@@ -326,7 +326,7 @@ async function saveDocState(arg, { dispatch, getState }) {
|
|
|
326
326
|
).unwrap();
|
|
327
327
|
if (dbSpaceId) {
|
|
328
328
|
try {
|
|
329
|
-
const { updateContentTitle } = await import("./contentThunks-
|
|
329
|
+
const { updateContentTitle } = await import("./contentThunks-2PJ4QDAV.js");
|
|
330
330
|
await dispatch(
|
|
331
331
|
updateContentTitle({
|
|
332
332
|
spaceId: dbSpaceId,
|
|
@@ -365,7 +365,7 @@ async function saveDocState(arg, { dispatch, getState }) {
|
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
async function createDocState(args, thunkApi) {
|
|
368
|
-
const { createPageAction } = await import("./createPageAction-
|
|
368
|
+
const { createPageAction } = await import("./createPageAction-HLSLX4R4.js");
|
|
369
369
|
return createPageAction(args, thunkApi);
|
|
370
370
|
}
|
|
371
371
|
function subscribe(listener) {
|
|
@@ -304,7 +304,7 @@ var slice = createSliceWithThunks({
|
|
|
304
304
|
const overrides = {};
|
|
305
305
|
if (args.systemPromptOverride !== void 0) overrides.prompt = args.systemPromptOverride;
|
|
306
306
|
if (args.toolsOverride !== void 0) overrides.tools = args.toolsOverride;
|
|
307
|
-
const { _executeModel } = await import("./_executeModel-
|
|
307
|
+
const { _executeModel } = await import("./_executeModel-PHFKA2OL.js");
|
|
308
308
|
return _executeModel(
|
|
309
309
|
{
|
|
310
310
|
isStreaming: args.isStreaming ?? false,
|
|
@@ -325,7 +325,7 @@ var slice = createSliceWithThunks({
|
|
|
325
325
|
* - 循环直到无工具调用或触发其他运行时停止条件
|
|
326
326
|
*/
|
|
327
327
|
runAgent: create.asyncThunk(async (args, thunkApi) => {
|
|
328
|
-
const { runAgentClientLoop } = await import("./runAgentClientLoop-
|
|
328
|
+
const { runAgentClientLoop } = await import("./runAgentClientLoop-66UNGCTW.js");
|
|
329
329
|
const { content: loopContent, toolCallCount } = await runAgentClientLoop(
|
|
330
330
|
{
|
|
331
331
|
agentKey: args.agentKey,
|
|
@@ -341,7 +341,7 @@ var slice = createSliceWithThunks({
|
|
|
341
341
|
* 聊天轮次流式 Agent 调用
|
|
342
342
|
*/
|
|
343
343
|
streamAgentChatTurn: create.asyncThunk(async (args, thunkApi) => {
|
|
344
|
-
const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-
|
|
344
|
+
const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-6F3M4KUY.js");
|
|
345
345
|
return streamAgentChatTurnHandler(args, thunkApi);
|
|
346
346
|
}),
|
|
347
347
|
/**
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveAuthToken,
|
|
3
|
+
resolveServerUrl
|
|
4
|
+
} from "./chunk-A7GB5UGH.js";
|
|
5
|
+
|
|
6
|
+
// packages/cli/subscriptionQuotaRefresh.ts
|
|
7
|
+
var CATALOG_QUOTA_REFRESH_TIMEOUT_MS = 2e3;
|
|
8
|
+
var CATALOG_QUOTA_STALE_MS = 6e4;
|
|
9
|
+
var EMPTY_REFRESH_BACKOFF_MS = 5 * 6e4;
|
|
10
|
+
var lastRefreshEmptyAt = 0;
|
|
11
|
+
function quotaIsFresh(entry, now) {
|
|
12
|
+
const observedAt = entry.quota?.observedAt;
|
|
13
|
+
return typeof observedAt === "number" && Number.isFinite(observedAt) && now - observedAt < CATALOG_QUOTA_STALE_MS;
|
|
14
|
+
}
|
|
15
|
+
async function refreshSubscriptionQuotas(args) {
|
|
16
|
+
const fresh = {};
|
|
17
|
+
try {
|
|
18
|
+
const now = Date.now();
|
|
19
|
+
const needsRefresh = args.entries.some(
|
|
20
|
+
(entry) => entry.probeable !== false && (!args.onlyKeys || args.onlyKeys.includes(entry.key)) && !quotaIsFresh(entry, now)
|
|
21
|
+
);
|
|
22
|
+
if (!needsRefresh) return fresh;
|
|
23
|
+
const wholeBatch = !args.onlyKeys || args.onlyKeys.length === 0;
|
|
24
|
+
if (wholeBatch && lastRefreshEmptyAt && now - lastRefreshEmptyAt < EMPTY_REFRESH_BACKOFF_MS) {
|
|
25
|
+
return fresh;
|
|
26
|
+
}
|
|
27
|
+
const env = args.env ?? process.env;
|
|
28
|
+
const authToken = resolveAuthToken(args.cliArgs ?? [], env);
|
|
29
|
+
if (!authToken) return fresh;
|
|
30
|
+
const fetchImpl = args.fetchImpl ?? fetch;
|
|
31
|
+
const refreshPromise = (async () => {
|
|
32
|
+
const res = await fetchImpl(
|
|
33
|
+
`${resolveServerUrl(args.cliArgs ?? [], env)}/api/agents/quota/refresh`,
|
|
34
|
+
{
|
|
35
|
+
method: "POST",
|
|
36
|
+
headers: {
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
Authorization: `Bearer ${authToken}`
|
|
39
|
+
},
|
|
40
|
+
body: JSON.stringify(
|
|
41
|
+
args.onlyKeys && args.onlyKeys.length > 0 ? { agentKeys: args.onlyKeys } : {}
|
|
42
|
+
),
|
|
43
|
+
signal: AbortSignal.timeout(CATALOG_QUOTA_REFRESH_TIMEOUT_MS)
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
if (!res.ok) return;
|
|
47
|
+
const payload = await res.json().catch(() => null);
|
|
48
|
+
const quotas = payload?.quotas;
|
|
49
|
+
if (!quotas || typeof quotas !== "object") return;
|
|
50
|
+
const probed = typeof payload?.probed === "number" ? payload.probed : 0;
|
|
51
|
+
if (probed === 0 && Object.keys(quotas).length === 0) {
|
|
52
|
+
if (wholeBatch) lastRefreshEmptyAt = Date.now();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (wholeBatch) lastRefreshEmptyAt = 0;
|
|
56
|
+
for (const entry of args.entries) {
|
|
57
|
+
const quota = quotas[entry.key];
|
|
58
|
+
if (quota && Array.isArray(quota.windows)) {
|
|
59
|
+
fresh[entry.key] = quota;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
})();
|
|
63
|
+
let timer;
|
|
64
|
+
await Promise.race([
|
|
65
|
+
refreshPromise,
|
|
66
|
+
new Promise((resolve) => {
|
|
67
|
+
timer = setTimeout(resolve, CATALOG_QUOTA_REFRESH_TIMEOUT_MS);
|
|
68
|
+
})
|
|
69
|
+
]).catch(() => {
|
|
70
|
+
});
|
|
71
|
+
if (timer) clearTimeout(timer);
|
|
72
|
+
refreshPromise.catch(() => {
|
|
73
|
+
});
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
return fresh;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
refreshSubscriptionQuotas
|
|
81
|
+
};
|