nolo-cli 0.202.0-alpha.2 → 0.203.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-IPRTPSW7.js → _executeModel-KOODDFV3.js} +16 -16
- package/{agentDeleteCommand-6HFA37FH.js → agentDeleteCommand-HCZZPPAB.js} +17 -16
- package/{agentEmailCommands-TDBNVIAT.js → agentEmailCommands-5R2ST7IA.js} +19 -18
- package/{agentListCommands-YSQSDQM3.js → agentListCommands-POQKNVWF.js} +3 -3
- package/{agentMachineCommands-5W23BLFR.js → agentMachineCommands-UZ7I4VL3.js} +3 -3
- package/{agentProviderCommands-5ALOQLE5.js → agentProviderCommands-MEFUIECN.js} +30 -12
- package/{agentRecordCommands-SRIMZZFK.js → agentRecordCommands-SSSJLCIP.js} +18 -17
- package/{agentRunCommand-BLYHIN6S.js → agentRunCommand-FXGB7HRK.js} +19 -18
- package/{agentRuntimeLocal-FE66EBRC.js → agentRuntimeLocal-M2RCAORY.js} +2 -2
- package/{agentSlice-BFDKYW6H.js → agentSlice-H47GA3AE.js} +1 -1
- package/{appDeleteCommands-BEVZGCAG.js → appDeleteCommands-JI6AEOJO.js} +4 -4
- package/{appDeployCommands-E7TFCHSP.js → appDeployCommands-W3W4T7BU.js} +4 -4
- package/{appDeployStatusCommands-MYY5Z5G3.js → appDeployStatusCommands-QXPI3XS4.js} +4 -4
- package/{appGetCommands-HNED5JUU.js → appGetCommands-SQV3MNFW.js} +4 -4
- package/{appListCommands-MSBFWPIY.js → appListCommands-DMYRVV7E.js} +4 -4
- package/{authCommand-W34UWJGR.js → authCommand-KPTIANH2.js} +1 -1
- package/{builtinSkillRegistry-NJVHQIKY.js → builtinSkillRegistry-HH75G5J3.js} +2 -2
- package/{chromeOpsCommands-USKE4B4K.js → chromeOpsCommands-JFT4J4LQ.js} +1 -1
- package/{chunk-HKWGI3TM.js → chunk-4HAB2O5R.js} +235 -11
- package/{chunk-OIB4GARE.js → chunk-4JBJG7XB.js} +3 -3
- package/{chunk-WPQGLJHU.js → chunk-76QKMZCM.js} +2 -2
- package/{chunk-SSK4WNJA.js → chunk-7BIC2DPF.js} +1 -1
- package/{chunk-LAYFVGS4.js → chunk-7KWQ3AWS.js} +9 -9
- package/{chunk-HKMPGHFZ.js → chunk-A46X4DUK.js} +4 -4
- package/{chunk-BLFZULEQ.js → chunk-DP7YE3D3.js} +2 -2
- package/{chunk-TWVVTUNG.js → chunk-E4KACSRR.js} +2 -2
- package/{chunk-CLTGWJVT.js → chunk-E4LYPSYM.js} +2 -0
- package/{chunk-5E4FSR4J.js → chunk-EPJFGQYO.js} +1 -1
- package/{chunk-YAGFPXOX.js → chunk-FIFPSUK7.js} +128 -7
- package/{chunk-326HCB6L.js → chunk-G7RADKSA.js} +8 -8
- package/{chunk-DKZJJ2NQ.js → chunk-I5PBXF7O.js} +1 -1
- package/{chunk-KDUYNEJ5.js → chunk-IK6AAUGM.js} +1 -1
- package/{chunk-SUBNV2JH.js → chunk-IT2QLZ7M.js} +2 -2
- package/{chunk-DHJXDGC3.js → chunk-JL3YTCPQ.js} +1 -1
- package/{chunk-BRZTSZBG.js → chunk-L2F7JJZX.js} +21 -121
- package/{chunk-C7PKPHK6.js → chunk-LK46VB57.js} +5 -5
- package/{chunk-Q7GNBUT4.js → chunk-NEZGPBL7.js} +2 -2
- package/{chunk-ETTDZBK5.js → chunk-OBOAMKAA.js} +3 -3
- package/{chunk-3CWF2EUZ.js → chunk-QUJ3IHEK.js} +1 -1
- package/{chunk-E2FC5RMU.js → chunk-S2ZXDWPU.js} +29 -8
- package/{chunk-RS66RJLA.js → chunk-TEI5QWP3.js} +1 -1
- package/{chunk-6OEPWZV7.js → chunk-TPCDYNJK.js} +3 -0
- package/{chunk-D57YYGMD.js → chunk-VF2CQVMR.js} +2 -2
- package/{chunk-YV2RSLM4.js → chunk-W6L3E75W.js} +4 -4
- package/{chunk-ASG7VWPK.js → chunk-WKJCPU4B.js} +3 -3
- package/chunk-WOAZVUSN.js +126 -0
- package/{chunk-RIKSN62L.js → chunk-Y6KUC75Q.js} +3 -3
- package/{chunk-LEX6DEH4.js → chunk-Y6M7KJOA.js} +1 -1
- package/{commandRegistry-ZU3RX7A2.js → commandRegistry-YYGDQ353.js} +59 -59
- package/{contentThunks-I4IHSDTM.js → contentThunks-CUBCGUNV.js} +3 -3
- package/{cooldownCommands-5SJ74DNP.js → cooldownCommands-BLRMLW7Q.js} +1 -1
- package/{createAgentAutomationAction-WQCH5HR2.js → createAgentAutomationAction-QKYRYNB7.js} +3 -3
- package/{createDialogAction-CKMZK5JQ.js → createDialogAction-X6YMBBIP.js} +5 -5
- package/{createPageAction-QAZHQGY7.js → createPageAction-UISPQP64.js} +3 -3
- package/{dialogCommands-NEQ6NW5H.js → dialogCommands-XBAEKJVC.js} +4 -4
- package/{dialogSlice-GEGACCH2.js → dialogSlice-JPKOEWA7.js} +2 -2
- package/{docCreateCommands-EXV267FP.js → docCreateCommands-XBI32MGB.js} +3 -3
- package/{docDeleteCommands-TSBILA2Z.js → docDeleteCommands-7EKY3XJR.js} +3 -3
- package/{docReadCommands-AKVYHITD.js → docReadCommands-LWDKFZKJ.js} +3 -3
- package/{docStore-B4EFT53J.js → docStore-YUQJ22PU.js} +1 -1
- package/{docUpdateCommands-G6GULDGZ.js → docUpdateCommands-VFB53K4G.js} +3 -3
- package/{handleSendMessageAction-4BACQWOG.js → handleSendMessageAction-OBYLLUON.js} +11 -11
- package/index.js +6 -6
- package/{localRuntimeAdapter-MTDULOUZ.js → localRuntimeAdapter-FZ7E66VZ.js} +17 -16
- package/{machineCommands-OGHHBRV3.js → machineCommands-3VBUV3VZ.js} +18 -17
- package/{machineWsRunDispatch-R6DNC3H7.js → machineWsRunDispatch-SJMADAGT.js} +18 -17
- package/package.json +1 -1
- package/{readlineWorkspace-NC2O4DQP.js → readlineWorkspace-SHYYZ7XS.js} +22 -21
- package/{runAgentClientLoop-QKV66PX5.js → runAgentClientLoop-2FDKWHUB.js} +14 -14
- package/{secretCommands-MKU25CDP.js → secretCommands-S2DDPIQ4.js} +1 -1
- package/{settingThunks-4WU7YE62.js → settingThunks-SWYDFUYT.js} +3 -3
- package/{spaceCommands-J7BRTTM3.js → spaceCommands-BFES7F7G.js} +2 -2
- package/{streamAgentChatTurn-GM3UNSLS.js → streamAgentChatTurn-VQGUVTAC.js} +28 -18
- package/{tools-UJLEQBKI.js → tools-JMEDZDIA.js} +10 -10
- package/{updateCommands-RVDAFHBT.js → updateCommands-LEJRRVBB.js} +3 -3
- package/{updateDialogTitleAction-24QO27NT.js → updateDialogTitleAction-QGH4ZL4E.js} +3 -3
- package/{windowsSelfUpdate-N2VH2OBW.js → windowsSelfUpdate-LSSQLXVS.js} +2 -2
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
isAgentSkillDisabled,
|
|
5
5
|
resolveAgentSkillConfig,
|
|
6
6
|
resolveUserEnabledSkills
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-I5PBXF7O.js";
|
|
8
8
|
import {
|
|
9
9
|
resolveBuiltinSkillEntry,
|
|
10
10
|
resolveBuiltinSkillPage,
|
|
11
11
|
resolveSkillGraphFromRoots
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Y6M7KJOA.js";
|
|
13
13
|
import {
|
|
14
14
|
parseSkillDocProtocol
|
|
15
15
|
} from "./chunk-AETZ7AD6.js";
|
|
@@ -458,7 +458,7 @@ var slice = createSliceWithThunks({
|
|
|
458
458
|
const overrides = {};
|
|
459
459
|
if (args.systemPromptOverride !== void 0) overrides.prompt = args.systemPromptOverride;
|
|
460
460
|
if (args.toolsOverride !== void 0) overrides.tools = args.toolsOverride;
|
|
461
|
-
const { _executeModel } = await import("./_executeModel-
|
|
461
|
+
const { _executeModel } = await import("./_executeModel-KOODDFV3.js");
|
|
462
462
|
return _executeModel(
|
|
463
463
|
{
|
|
464
464
|
isStreaming: args.isStreaming ?? false,
|
|
@@ -479,7 +479,7 @@ var slice = createSliceWithThunks({
|
|
|
479
479
|
* - 循环直到无工具调用或触发其他运行时停止条件
|
|
480
480
|
*/
|
|
481
481
|
runAgent: create.asyncThunk(async (args, thunkApi) => {
|
|
482
|
-
const { runAgentClientLoop } = await import("./runAgentClientLoop-
|
|
482
|
+
const { runAgentClientLoop } = await import("./runAgentClientLoop-2FDKWHUB.js");
|
|
483
483
|
const { content: loopContent, toolCallCount } = await runAgentClientLoop(
|
|
484
484
|
{
|
|
485
485
|
agentKey: args.agentKey,
|
|
@@ -495,7 +495,7 @@ var slice = createSliceWithThunks({
|
|
|
495
495
|
* 聊天轮次流式 Agent 调用
|
|
496
496
|
*/
|
|
497
497
|
streamAgentChatTurn: create.asyncThunk(async (args, thunkApi) => {
|
|
498
|
-
const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-
|
|
498
|
+
const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-VQGUVTAC.js");
|
|
499
499
|
return streamAgentChatTurnHandler(args, thunkApi);
|
|
500
500
|
}),
|
|
501
501
|
/**
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildStaticUserPolicyContext,
|
|
3
3
|
resolveSpaceContextPreloadPlan
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NEZGPBL7.js";
|
|
5
5
|
import {
|
|
6
6
|
fetchReferenceContents,
|
|
7
7
|
mergeReferences,
|
|
8
8
|
resolveReferenceAssets,
|
|
9
9
|
resolveToolsFromKeys
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-Y6KUC75Q.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-
|
|
21
|
+
} from "./chunk-LK46VB57.js";
|
|
22
22
|
import {
|
|
23
23
|
resolveAgentRecommendedSkillNames,
|
|
24
24
|
resolveAgentRequiredPackIds
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-I5PBXF7O.js";
|
|
26
26
|
import {
|
|
27
27
|
getDocState
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-VF2CQVMR.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-
|
|
40
|
+
} from "./chunk-7BIC2DPF.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-
|
|
49
|
+
} from "./chunk-G7RADKSA.js";
|
|
50
50
|
import {
|
|
51
51
|
selectPendingFiles
|
|
52
52
|
} from "./chunk-OWYYDMGJ.js";
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
expandEnabledPackPromptPatches,
|
|
69
69
|
expandEnabledPacks,
|
|
70
70
|
resolveEffectiveEnabledPacks
|
|
71
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-TPCDYNJK.js";
|
|
72
72
|
import {
|
|
73
73
|
projectToolMessageContent
|
|
74
74
|
} from "./chunk-2WZXXAQD.js";
|
|
@@ -993,6 +993,27 @@ var buildEditingContextSummary = (state, runtimeOptions) => {
|
|
|
993
993
|
if (targetKind === "canvas_node") {
|
|
994
994
|
return buildCanvasNodeEditingContextSummary(runtimeOptions);
|
|
995
995
|
}
|
|
996
|
+
if (targetKind === "artifact" || targetKind === "html_artifact") {
|
|
997
|
+
const editingTarget = runtimeOptions?.editingTarget;
|
|
998
|
+
const metadata = editingTarget?.metadata;
|
|
999
|
+
const artifactId = typeof editingTarget?.key === "string" && editingTarget.key ? editingTarget.key : typeof metadata?.artifactId === "string" ? metadata.artifactId : typeof editingTarget?.artifactId === "string" ? editingTarget.artifactId : null;
|
|
1000
|
+
const title = editingTarget?.title ?? (typeof metadata?.title === "string" ? metadata.title : "HTML \u7F51\u9875\u6210\u54C1");
|
|
1001
|
+
const dialogKey = typeof metadata?.dialogKey === "string" ? metadata.dialogKey : typeof editingTarget?.dialogKey === "string" ? editingTarget.dialogKey : null;
|
|
1002
|
+
return [
|
|
1003
|
+
"\u5F53\u524D\u7F16\u8F91\u76EE\u6807\uFF1A\u5355\u6587\u4EF6 HTML \u7F51\u9875\u6210\u54C1\uFF08Editing HTML Artifact\uFF09\u3002",
|
|
1004
|
+
...artifactId ? [`- \u6210\u54C1 ID (artifactId): ${artifactId}`] : ["- \u6210\u54C1 ID: (\u65B0\u5EFA\u4E2D\u6216\u672A\u6307\u5B9A)"],
|
|
1005
|
+
`- \u6807\u9898: ${title}`,
|
|
1006
|
+
...dialogKey ? [`- \u6240\u5C5E\u5BF9\u8BDD: ${dialogKey}`] : [],
|
|
1007
|
+
"",
|
|
1008
|
+
"\u3010\u7ED9 AI \u7684\u64CD\u4F5C\u6307\u5357 / \u975E\u7528\u6237\u539F\u8BDD\u3011",
|
|
1009
|
+
artifactId ? `1. \u5F53\u524D\u5BF9\u8BDD\u5DF2\u5B58\u5728\u5E76\u6B63\u5728\u67E5\u770B HTML \u6210\u54C1\uFF08ID: ${artifactId}\uFF09\u3002\u5982\u679C\u7528\u6237\u8981\u6C42\u4FEE\u6539\u3001\u8C03\u6574\u6837\u5F0F\u3001\u5B8C\u5584\u529F\u80FD\u6216\u8FED\u4EE3\u5F53\u524D\u7F51\u9875\uFF0C**\u5FC5\u987B\u5148\u4F7F\u7528 readHtmlArtifact(id: "${artifactId}") \u8BFB\u53D6\u73B0\u6709\u6E90\u7801\uFF08\u5982\u9700\uFF09\uFF0C\u518D\u8C03\u7528 updateHtmlArtifact(id: "${artifactId}", html: "...") \u66F4\u65B0\u540C\u4E00\u4E2A ID**\uFF0C\u4FDD\u6301\u539F\u6210\u54C1 ID \u7A33\u5B9A\u3002` : "1. \u5982\u679C\u7528\u6237\u8981\u6C42\u751F\u6210\u5168\u65B0\u7F51\u9875\uFF0C\u4F7F\u7528 createHtmlArtifact \u521B\u5EFA\u65B0\u6210\u54C1\u3002",
|
|
1010
|
+
...artifactId ? [
|
|
1011
|
+
`2. **\u4E25\u7981\u65E0\u6761\u4EF6\u8C03\u7528 createHtmlArtifact \u521B\u5EFA\u65B0\u526F\u672C**\u6765\u66FF\u4EE3\u5BF9\u73B0\u6709\u6210\u54C1\u7684\u4FEE\u6539\uFF1B\u53EA\u6709\u7528\u6237\u660E\u786E\u8868\u8FBE\u8981\u53E6\u5916'\u65B0\u5EFA\u4E00\u4E2A\u72EC\u7ACB\u7F51\u9875'\u65F6\u624D\u8C03\u7528 createHtmlArtifact\u3002`,
|
|
1012
|
+
"3. \u7CFB\u7EDF\u4E0D\u4F1A\u9759\u9ED8\u628A create \u8F6C\u6362\u4E3A update\uFF0C\u8C03\u7528\u9519\u8BEF\u4F1A\u5BFC\u81F4\u4EA7\u751F\u5206\u53C9\u526F\u672C\u3002"
|
|
1013
|
+
] : [],
|
|
1014
|
+
"4. \u751F\u6210/\u66F4\u65B0\u7F51\u9875\u8BF7\u4F7F\u7528 createHtmlArtifact / updateHtmlArtifact\uFF0C\u4E0D\u8981\u4F7F\u7528 createDoc \u6216\u666E\u901A\u6587\u6863\u5DE5\u5177\uFF1B\u666E\u901A\u6587\u6863\u5DE5\u5177\u4EC5\u7528\u4E8E\u77E5\u8BC6\u5E93\u4E0E\u6587\u7AE0\u3002"
|
|
1015
|
+
].join("\n");
|
|
1016
|
+
}
|
|
996
1017
|
return null;
|
|
997
1018
|
};
|
|
998
1019
|
|
|
@@ -333,7 +333,7 @@ async function saveDocState(arg, { dispatch, getState }) {
|
|
|
333
333
|
).unwrap();
|
|
334
334
|
if (dbSpaceId) {
|
|
335
335
|
try {
|
|
336
|
-
const { updateContentTitle } = await import("./contentThunks-
|
|
336
|
+
const { updateContentTitle } = await import("./contentThunks-CUBCGUNV.js");
|
|
337
337
|
await dispatch(
|
|
338
338
|
updateContentTitle({
|
|
339
339
|
spaceId: dbSpaceId,
|
|
@@ -372,7 +372,7 @@ async function saveDocState(arg, { dispatch, getState }) {
|
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
async function createDocState(args, thunkApi) {
|
|
375
|
-
const { createPageAction } = await import("./createPageAction-
|
|
375
|
+
const { createPageAction } = await import("./createPageAction-UISPQP64.js");
|
|
376
376
|
return createPageAction(args, thunkApi);
|
|
377
377
|
}
|
|
378
378
|
function subscribe(listener) {
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
} from "./chunk-HS7MLR74.js";
|
|
4
4
|
import {
|
|
5
5
|
performServerProxyFetchWithRetry
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-Y6KUC75Q.js";
|
|
7
7
|
import {
|
|
8
8
|
fetchServerSyncedCredential
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OBOAMKAA.js";
|
|
10
10
|
import {
|
|
11
11
|
buildSkillGuidancePromptBlock
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Y6M7KJOA.js";
|
|
13
13
|
import {
|
|
14
14
|
CREDENTIAL_HYGIENE_RULE,
|
|
15
15
|
DELETE_SAFETY_RED_LINE,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
compileContextLayers,
|
|
24
24
|
detectDispatchIntentFromMessages,
|
|
25
25
|
resolveToolGuidedSections
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-IK6AAUGM.js";
|
|
27
27
|
import {
|
|
28
28
|
convertMessagesToResponsesInput,
|
|
29
29
|
getUsageRequestOptions,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addContentToSpace
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7BIC2DPF.js";
|
|
4
4
|
import {
|
|
5
5
|
format,
|
|
6
6
|
prepareAndPersistMessage,
|
|
7
7
|
uiAskChoiceFunc,
|
|
8
8
|
uiAskChoiceFunctionSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-G7RADKSA.js";
|
|
10
10
|
import {
|
|
11
11
|
formatISO
|
|
12
12
|
} from "./chunk-ZRAU6T47.js";
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
} from "./chunk-PXYBUFDB.js";
|
|
26
26
|
import {
|
|
27
27
|
buildBuiltinObjectSkillReference
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-TPCDYNJK.js";
|
|
29
29
|
import {
|
|
30
30
|
extractCustomId
|
|
31
31
|
} from "./chunk-M2EJHDJP.js";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isAbortError
|
|
3
|
+
} from "./chunk-7DPNBQSV.js";
|
|
4
|
+
|
|
5
|
+
// packages/agent-runtime/customNativeWire.ts
|
|
6
|
+
var CHAT_COMPLETIONS_SUFFIX = /\/chat\/completions\/?$/;
|
|
7
|
+
function resolveCustomNativeBase(endpoint) {
|
|
8
|
+
return endpoint.replace(CHAT_COMPLETIONS_SUFFIX, "").replace(/\/+$/, "");
|
|
9
|
+
}
|
|
10
|
+
var NATIVE_PATH_SUFFIX = {
|
|
11
|
+
"openai-responses": "/responses",
|
|
12
|
+
"anthropic-messages": "/messages"
|
|
13
|
+
};
|
|
14
|
+
var ANTHROPIC_MESSAGES_VERSION = "2023-06-01";
|
|
15
|
+
var OPENCODE_HOST = "opencode.ai";
|
|
16
|
+
var OPENCODE_ZEN_GO_PREFIX = "/zen/go";
|
|
17
|
+
var OPENCODE_INFERENCE_GO_PREFIX = "/inference/go";
|
|
18
|
+
function normalizeOpencodeGoGeminiBase(base, wire) {
|
|
19
|
+
if (wire !== "gemini") return base;
|
|
20
|
+
const schemeEnd = base.indexOf("://");
|
|
21
|
+
if (schemeEnd <= 0 || base.slice(0, schemeEnd).toLowerCase() !== "https") return base;
|
|
22
|
+
const authorityStart = schemeEnd + 3;
|
|
23
|
+
const pathStart = base.indexOf("/", authorityStart);
|
|
24
|
+
if (pathStart < 0) return base;
|
|
25
|
+
const host = base.slice(authorityStart, pathStart).toLowerCase();
|
|
26
|
+
if (host !== OPENCODE_HOST) return base;
|
|
27
|
+
const pathAndQuery = base.slice(pathStart);
|
|
28
|
+
const isZenGoPath = pathAndQuery === OPENCODE_ZEN_GO_PREFIX || pathAndQuery.startsWith(`${OPENCODE_ZEN_GO_PREFIX}/`);
|
|
29
|
+
if (!isZenGoPath) return base;
|
|
30
|
+
return `${base.slice(0, authorityStart)}${OPENCODE_HOST}${OPENCODE_INFERENCE_GO_PREFIX}${pathAndQuery.slice(
|
|
31
|
+
OPENCODE_ZEN_GO_PREFIX.length
|
|
32
|
+
)}`;
|
|
33
|
+
}
|
|
34
|
+
function detectDeclaredCustomNativeWire(endpoint) {
|
|
35
|
+
const trimmed = typeof endpoint === "string" ? endpoint.trim().replace(/\/+$/, "") : "";
|
|
36
|
+
if (!trimmed) return null;
|
|
37
|
+
const pathname = trimmed.split(/[?#]/)[0] ?? "";
|
|
38
|
+
if (pathname.endsWith(NATIVE_PATH_SUFFIX["openai-responses"])) return "openai-responses";
|
|
39
|
+
if (pathname.endsWith(NATIVE_PATH_SUFFIX["anthropic-messages"])) return "anthropic-messages";
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
function resolveCustomNativeEndpoint(endpoint, wire, model) {
|
|
43
|
+
const base = normalizeOpencodeGoGeminiBase(resolveCustomNativeBase(endpoint), wire);
|
|
44
|
+
switch (wire) {
|
|
45
|
+
case "gemini":
|
|
46
|
+
return `${base}/models/${model}:streamGenerateContent?alt=sse`;
|
|
47
|
+
case "openai-responses":
|
|
48
|
+
case "anthropic-messages": {
|
|
49
|
+
const suffix = NATIVE_PATH_SUFFIX[wire];
|
|
50
|
+
return detectDeclaredCustomNativeWire(base) === wire ? base : `${base}${suffix}`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
var RESERVED_CUSTOM_NATIVE_AUTH_HEADERS = [
|
|
55
|
+
// 凭据之外、由通道自己决定的头
|
|
56
|
+
"accept",
|
|
57
|
+
"accept-encoding",
|
|
58
|
+
"anthropic-version",
|
|
59
|
+
"content-type",
|
|
60
|
+
"content-length",
|
|
61
|
+
"user-agent",
|
|
62
|
+
"x-opencode-session",
|
|
63
|
+
// 请求走私 / 连接语义(hop-by-hop 与 Host/Cookie 家族)
|
|
64
|
+
"connection",
|
|
65
|
+
"cookie",
|
|
66
|
+
"host",
|
|
67
|
+
"keep-alive",
|
|
68
|
+
"proxy-authenticate",
|
|
69
|
+
"proxy-authorization",
|
|
70
|
+
"proxy-connection",
|
|
71
|
+
"te",
|
|
72
|
+
"trailer",
|
|
73
|
+
"transfer-encoding",
|
|
74
|
+
"upgrade"
|
|
75
|
+
];
|
|
76
|
+
var HTTP_HEADER_TOKEN_RE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
77
|
+
var CustomNativeApiKeyHeaderError = class extends Error {
|
|
78
|
+
code = "INVALID_API_KEY_HEADER";
|
|
79
|
+
constructor(message) {
|
|
80
|
+
super(message);
|
|
81
|
+
this.name = "CustomNativeApiKeyHeaderError";
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
function resolveCustomNativeApiKeyHeader(apiKeyHeader) {
|
|
85
|
+
const headerName = apiKeyHeader?.trim();
|
|
86
|
+
if (!headerName) return void 0;
|
|
87
|
+
if (!HTTP_HEADER_TOKEN_RE.test(headerName)) {
|
|
88
|
+
throw new CustomNativeApiKeyHeaderError(
|
|
89
|
+
`Invalid apiKeyHeader "${headerName}": not a valid HTTP header name (spaces, ":", CR/LF, control characters and other non-token characters are not allowed).`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
if (RESERVED_CUSTOM_NATIVE_AUTH_HEADERS.includes(headerName.toLowerCase())) {
|
|
93
|
+
throw new CustomNativeApiKeyHeaderError(
|
|
94
|
+
`Invalid apiKeyHeader "${headerName}": reserved header, it cannot be used as the API key header.`
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return headerName;
|
|
98
|
+
}
|
|
99
|
+
function customNativeAuthHeaderValue(headerName, apiKey) {
|
|
100
|
+
return headerName.toLowerCase() === "authorization" ? apiKey.startsWith("Bearer ") ? apiKey : `Bearer ${apiKey}` : apiKey;
|
|
101
|
+
}
|
|
102
|
+
function customNativeAuthHeaders(wire, apiKey, apiKeyHeader) {
|
|
103
|
+
const overrideName = resolveCustomNativeApiKeyHeader(apiKeyHeader);
|
|
104
|
+
switch (wire) {
|
|
105
|
+
case "gemini":
|
|
106
|
+
return overrideName ? { [overrideName]: customNativeAuthHeaderValue(overrideName, apiKey) } : { "x-goog-api-key": apiKey };
|
|
107
|
+
case "openai-responses":
|
|
108
|
+
return overrideName ? { [overrideName]: customNativeAuthHeaderValue(overrideName, apiKey) } : { Authorization: `Bearer ${apiKey}` };
|
|
109
|
+
case "anthropic-messages":
|
|
110
|
+
return {
|
|
111
|
+
...overrideName ? { [overrideName]: customNativeAuthHeaderValue(overrideName, apiKey) } : { "x-api-key": apiKey },
|
|
112
|
+
"anthropic-version": ANTHROPIC_MESSAGES_VERSION
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function isCallerCancellation(error, callerSignal) {
|
|
117
|
+
return isAbortError(error) || callerSignal?.aborted === true;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
detectDeclaredCustomNativeWire,
|
|
122
|
+
resolveCustomNativeEndpoint,
|
|
123
|
+
resolveCustomNativeApiKeyHeader,
|
|
124
|
+
customNativeAuthHeaders,
|
|
125
|
+
isCallerCancellation
|
|
126
|
+
};
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
clipMultilineText,
|
|
3
3
|
fetchAndSerializeTable,
|
|
4
4
|
waitForAbortableDelay
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-LK46VB57.js";
|
|
6
6
|
import {
|
|
7
7
|
isGatewayHttpStatus
|
|
8
8
|
} from "./chunk-NF64D32W.js";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "./chunk-AGIM7IMJ.js";
|
|
22
22
|
import {
|
|
23
23
|
fetchAndCacheMessages
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-G7RADKSA.js";
|
|
25
25
|
import {
|
|
26
26
|
createSpaceKey
|
|
27
27
|
} from "./chunk-UAD2WT54.js";
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
extractRuntimePageCapabilities,
|
|
36
36
|
resolveBuiltinSkillPage,
|
|
37
37
|
resolveSkillGraphFromRoots
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-Y6M7KJOA.js";
|
|
39
39
|
import {
|
|
40
40
|
isAbortError
|
|
41
41
|
} from "./chunk-7DPNBQSV.js";
|