@nervekit/desktop 0.40.0 → 0.40.2
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/THIRD-PARTY-LICENSES.txt +5087 -485
- package/dist/{chunk-KSZJ3HGD.js → chunk-2BKMOJYJ.js} +1 -1
- package/dist/{chunk-5UT23MT6.js → chunk-3JJN36GV.js} +70 -71
- package/dist/{chunk-2Z5FLMLE.js → chunk-3SSNDIQT.js} +1 -1
- package/dist/{chunk-PUM6UCBT.js → chunk-3VZR3ZUY.js} +55 -8
- package/dist/{chunk-BXVRC3HF.js → chunk-4H3WR7IT.js} +1 -1
- package/dist/{chunk-QVHYARC2.js → chunk-4VPX67B7.js} +3 -1
- package/dist/chunk-5NN7JAJ2.js +258 -0
- package/dist/{chunk-BPOIFVQO.js → chunk-6FSDDGFZ.js} +731 -605
- package/dist/chunk-6PACEIUY.js +183 -0
- package/dist/{chunk-XNYZEQ3U.js → chunk-6TAN6WG6.js} +1 -1
- package/dist/{chunk-RWLLVZ7I.js → chunk-7FLZA2BD.js} +31 -15
- package/dist/{chunk-WTHP3VH6.js → chunk-7JQBECUL.js} +1 -1
- package/dist/{chunk-5Y3NEEOK.js → chunk-AAEIGAGD.js} +9 -9
- package/dist/{chunk-UN3GLM4U.js → chunk-ANI6J75M.js} +68 -65
- package/dist/chunk-B4IE2GAM.js +14 -0
- package/dist/chunk-BNVMNV4O.js +69 -0
- package/dist/{chunk-L3YB2QLN.js → chunk-C6RO4LP3.js} +2 -2
- package/dist/chunk-DTGL5P2V.js +250 -0
- package/dist/{chunk-U4DBQKHO.js → chunk-E4JNHQGT.js} +11 -9
- package/dist/chunk-EJM4HMEL.js +45 -0
- package/dist/chunk-ER2ES2RH.js +64 -0
- package/dist/{chunk-SQ7CWNIT.js → chunk-EX63VKXY.js} +1 -1
- package/dist/{chunk-JDI4D5EM.js → chunk-F3MHINI6.js} +19 -23
- package/dist/chunk-FGZX4Q7W.js +22828 -0
- package/dist/{chunk-LPCHTKEK.js → chunk-FZ5N6WXF.js} +31 -160
- package/dist/chunk-H2G55ZPG.js +783 -0
- package/dist/chunk-HDBDYGJQ.js +40 -0
- package/dist/{chunk-RU6S57LK.js → chunk-HOCODVKL.js} +22 -24
- package/dist/chunk-JCF3ZRP4.js +481 -0
- package/dist/chunk-K2J2VZXO.js +142 -0
- package/dist/chunk-KBNEZR7T.js +135 -0
- package/dist/chunk-KSSM6LUI.js +340 -0
- package/dist/{chunk-HHUSIAK3.js → chunk-KTGSBL6T.js} +14 -17
- package/dist/chunk-L2DHKP5C.js +42 -0
- package/dist/{chunk-DBXMYYPJ.js → chunk-M3ELKCNA.js} +1 -1
- package/dist/chunk-M7WTH5K5.js +822 -0
- package/dist/{chunk-LZRPWVVJ.js → chunk-MWIKZIAI.js} +9 -8
- package/dist/{chunk-AON37AL2.js → chunk-O2652RWY.js} +29 -4
- package/dist/chunk-O6U226AI.js +249 -0
- package/dist/{chunk-5R3UAHXF.js → chunk-OAEV22IW.js} +48 -26
- package/dist/chunk-OANTMDXI.js +29 -0
- package/dist/{chunk-UGDIHDAR.js → chunk-ODS5QROC.js} +1 -1
- package/dist/{chunk-Q7LPOIKN.js → chunk-OQC3F6JA.js} +3 -471
- package/dist/{chunk-YA2WJRUO.js → chunk-PST63OUS.js} +5 -5
- package/dist/{chunk-S2PITDVA.js → chunk-QBAIDKF6.js} +1 -1
- package/dist/chunk-RPLBWENJ.js +224 -0
- package/dist/{chunk-GCSWN326.js → chunk-S62LLS4I.js} +33 -55
- package/dist/chunk-SHEU5KLD.js +32 -0
- package/dist/{chunk-FESN7DND.js → chunk-SU2USXTD.js} +1 -1
- package/dist/chunk-T6NRMNLQ.js +22 -0
- package/dist/{chunk-NSA42OOT.js → chunk-TGKIV3F4.js} +53 -65
- package/dist/{chunk-MN7PZ2PH.js → chunk-TSV3PFU2.js} +2 -2
- package/dist/{chunk-D5WJKB4R.js → chunk-UDC7NPQJ.js} +4 -3
- package/dist/{chunk-CEX2GWGZ.js → chunk-VBM7TD3X.js} +1 -1
- package/dist/chunk-VC6TX2Y2.js +359 -0
- package/dist/{chunk-7FI3LC3O.js → chunk-VTDI5KP7.js} +241 -104
- package/dist/{chunk-P2GSKP6N.js → chunk-WIN7KHMV.js} +15 -18
- package/dist/chunk-WJULIJOU.js +168 -0
- package/dist/{chunk-HKLAYK2Z.js → chunk-WRTA5G57.js} +23 -0
- package/dist/{chunk-4ZNLXHTH.js → chunk-WYPVD3HW.js} +10 -9
- package/dist/{chunk-V7EAFXAX.js → chunk-XE2E2KBP.js} +10 -9
- package/dist/chunk-XY53EFK3.js +39 -0
- package/dist/chunk-XZYFB566.js +153 -0
- package/dist/{chunk-H4CDZRIE.js → chunk-YJT4NXMV.js} +5 -5
- package/dist/{chunk-ET5RYBGZ.js → chunk-YQFENES6.js} +3 -3
- package/dist/chunk-YUO5V75X.js +128 -0
- package/dist/chunk-YYLKI74V.js +8778 -0
- package/dist/daemon.js +15 -10
- package/dist/git-isolated-reader-helper.js +1 -1
- package/dist/main.js +14 -9
- package/dist/web/assets/{AsyncBashCenterHost-HGsdxUJ3.js → AsyncBashCenterHost-BvXKoCVr.js} +1 -1
- package/dist/web/assets/{ConversationsWorkbenchPanel-B6dzWkG1.js → ConversationsWorkbenchPanel-CIfK_e3I.js} +1 -1
- package/dist/web/assets/{DiscoverCenterHost-B186WBRA.js → DiscoverCenterHost-Ep8EN9iJ.js} +1 -1
- package/dist/web/assets/{FileCenterHost-DigJOU5M.js → FileCenterHost-C_7XZAFZ.js} +1 -1
- package/dist/web/assets/{FilesWorkbenchPanel-VPvx3Bmi.js → FilesWorkbenchPanel-CtXo7ywG.js} +1 -1
- package/dist/web/assets/{GitDiffCenterHost-IuZfF3hG.js → GitDiffCenterHost-Cr7lqGI_.js} +1 -1
- package/dist/web/assets/{GitWorkbenchPanel-CScC0CfH.js → GitWorkbenchPanel-BFbwUgIN.js} +1 -1
- package/dist/web/assets/{LaunchConfigurationNotice-5yb4cH27.js → LaunchConfigurationNotice-CJjWkMhv.js} +1 -1
- package/dist/web/assets/{LaunchesWorkbenchPanel-Vy0Gm7gg.js → LaunchesWorkbenchPanel-BqzJvsrj.js} +1 -1
- package/dist/web/assets/{LogsCenterHost-BXBozCYw.js → LogsCenterHost-BI1fSxFW.js} +1 -1
- package/dist/web/assets/{MermaidCenterHost-DDh4ArdK.js → MermaidCenterHost-DVsZB8nB.js} +1 -1
- package/dist/web/assets/{MobileFilesBody-Cda_7gDp.js → MobileFilesBody-BJMoaP9I.js} +1 -1
- package/dist/web/assets/{MobileFilesHost-C1jev2Un.js → MobileFilesHost-D843vkDF.js} +1 -1
- package/dist/web/assets/{MobileLaunchOutputHost-Bsv12o2H.js → MobileLaunchOutputHost-vpltMcar.js} +1 -1
- package/dist/web/assets/{MobileLaunchesHost-C9VH-2bn.js → MobileLaunchesHost-CdDrKASg.js} +1 -1
- package/dist/web/assets/{MobileLogsHost-BMDXc-WC.js → MobileLogsHost-qK7N-C1y.js} +1 -1
- package/dist/web/assets/{MobileNoteEditorHost-BA6WIY1Y.js → MobileNoteEditorHost-Bg1N8o54.js} +1 -1
- package/dist/web/assets/{MobileNotesHost-BZeYpK9H.js → MobileNotesHost-meLV39Yw.js} +1 -1
- package/dist/web/assets/{MobileProjectSettingsHost-U3Mx3EN8.js → MobileProjectSettingsHost-A49Fdn54.js} +1 -1
- package/dist/web/assets/{MobileProjectSettingsPageHost-CMvxbjfs.js → MobileProjectSettingsPageHost-BXpUqS_N.js} +1 -1
- package/dist/web/assets/{MobileSettingsHost-CP8Z_-gH.js → MobileSettingsHost-DPKPajzI.js} +1 -1
- package/dist/web/assets/{MobileSettingsPageHost-BPjXKTMV.js → MobileSettingsPageHost-izNWGN0i.js} +1 -1
- package/dist/web/assets/{MobileSettingsPageScreen-C5rHdrUU.js → MobileSettingsPageScreen-DWMg4fDo.js} +1 -1
- package/dist/web/assets/{ProjectSettingsCenterHost-BVXpBixy.js → ProjectSettingsCenterHost-DHeb274m.js} +1 -1
- package/dist/web/assets/{PullRequestCenterHost-CZhXfCX2.js → PullRequestCenterHost-BYkWxXQe.js} +1 -1
- package/dist/web/assets/{PullRequestsWorkbenchPanel-BBnZJVnI.js → PullRequestsWorkbenchPanel-ZvGbi1Cr.js} +1 -1
- package/dist/web/assets/{SearchWorkbenchPanel-qLgszneN.js → SearchWorkbenchPanel-DaC0smfe.js} +1 -1
- package/dist/web/assets/{SettingsCenter-7BfrBfiy.js → SettingsCenter-C_NLBsi6.js} +1 -1
- package/dist/web/assets/{SettingsCenterHost-Ck5uHILP.js → SettingsCenterHost-jP8MULEj.js} +1 -1
- package/dist/web/assets/{SystemPromptCenterHost-ya5AvXsd.js → SystemPromptCenterHost-B1hfsfAn.js} +1 -1
- package/dist/web/assets/{discover-B3I5g1_G.js → discover-B-aZ504j.js} +1 -1
- package/dist/web/assets/{index-FJEmK_L5.js → index-TZ1KAAsX.js} +34 -34
- package/dist/web/assets/{settings-page-controllers.svelte-CU0i08wo.js → settings-page-controllers.svelte-D_ydJF8u.js} +1 -1
- package/dist/web/assets/{shell-layout.svelte-BT2508sa.js → shell-layout.svelte-OoLFwzzJ.js} +2 -2
- package/dist/web/assets/{views-Z-n-GTYY.js → views-ByPCKDiZ.js} +1 -1
- package/dist/web/index.html +3 -3
- package/dist/web/sw.js +1 -1
- package/dist/worker.js +14 -9
- package/package.json +8 -9
- package/dist/chunk-RUZ2UAYH.js +0 -365
- package/dist/resize-worker.js +0 -168
- /package/dist/{chunk-PUM6UCBT.js.LEGAL.txt → chunk-3VZR3ZUY.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-YA2WJRUO.js.LEGAL.txt → chunk-PST63OUS.js.LEGAL.txt} +0 -0
|
@@ -5,19 +5,20 @@ import {
|
|
|
5
5
|
parseClassifierUsage,
|
|
6
6
|
postClassifierRequest,
|
|
7
7
|
requiredNumber
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YJT4NXMV.js";
|
|
9
|
+
import "./chunk-EX63VKXY.js";
|
|
9
10
|
import {
|
|
10
11
|
formatProviderError,
|
|
11
12
|
normalizeProviderError
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-O2652RWY.js";
|
|
14
|
+
import "./chunk-VBM7TD3X.js";
|
|
15
|
+
import "./chunk-TGKIV3F4.js";
|
|
16
|
+
import "./chunk-TSV3PFU2.js";
|
|
17
|
+
import "./chunk-UDC7NPQJ.js";
|
|
18
|
+
import "./chunk-XY53EFK3.js";
|
|
18
19
|
import "./chunk-CWESUMYQ.js";
|
|
19
20
|
|
|
20
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
21
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.js
|
|
21
22
|
var LABEL = "OpenAI Decisions";
|
|
22
23
|
var MAX_IMAGES = 128;
|
|
23
24
|
function predicateInstructions(question) {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
ownedSlice
|
|
5
|
+
} from "./chunk-XY53EFK3.js";
|
|
3
6
|
|
|
4
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
7
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js
|
|
5
8
|
var MAX_PROVIDER_ERROR_BODY_CHARS = 4e3;
|
|
6
9
|
function normalizeProviderError(error) {
|
|
7
10
|
if (!(error instanceof Error)) {
|
|
@@ -11,13 +14,33 @@ function normalizeProviderError(error) {
|
|
|
11
14
|
const status = extractStatus(sdkError);
|
|
12
15
|
const body = extractBody(sdkError);
|
|
13
16
|
const messageCarriesBody = body === void 0 || error.message.includes(body);
|
|
17
|
+
const message = status === void 0 && body === void 0 ? withCauseDetail(error) : error.message;
|
|
14
18
|
return {
|
|
15
19
|
status,
|
|
16
20
|
body,
|
|
17
|
-
message
|
|
21
|
+
message,
|
|
18
22
|
messageCarriesBody
|
|
19
23
|
};
|
|
20
24
|
}
|
|
25
|
+
var MAX_CAUSE_DEPTH = 5;
|
|
26
|
+
function withCauseDetail(error) {
|
|
27
|
+
let deepest;
|
|
28
|
+
let current = error.cause;
|
|
29
|
+
for (let depth = 0; depth < MAX_CAUSE_DEPTH && current instanceof Error; depth++) {
|
|
30
|
+
deepest = current;
|
|
31
|
+
current = current.cause;
|
|
32
|
+
}
|
|
33
|
+
if (!deepest)
|
|
34
|
+
return error.message;
|
|
35
|
+
let detail = (deepest.message || deepest.name).trim();
|
|
36
|
+
const code = deepest.code;
|
|
37
|
+
if ((typeof code === "string" || typeof code === "number") && !detail.includes(String(code))) {
|
|
38
|
+
detail = detail ? `${detail} (${code})` : String(code);
|
|
39
|
+
}
|
|
40
|
+
if (!detail || error.message.includes(detail))
|
|
41
|
+
return error.message;
|
|
42
|
+
return error.message ? `${error.message}: ${detail}` : detail;
|
|
43
|
+
}
|
|
21
44
|
function extractStatus(error) {
|
|
22
45
|
if (typeof error.statusCode === "number")
|
|
23
46
|
return error.statusCode;
|
|
@@ -72,7 +95,7 @@ function formatProviderError(norm, prefix) {
|
|
|
72
95
|
function truncateErrorText(text, maxChars) {
|
|
73
96
|
if (text.length <= maxChars)
|
|
74
97
|
return text;
|
|
75
|
-
return `${text
|
|
98
|
+
return `${ownedSlice(text, 0, maxChars)}... [truncated ${text.length - maxChars} chars]`;
|
|
76
99
|
}
|
|
77
100
|
function safeJsonStringify(value) {
|
|
78
101
|
try {
|
|
@@ -85,5 +108,7 @@ function safeJsonStringify(value) {
|
|
|
85
108
|
|
|
86
109
|
export {
|
|
87
110
|
normalizeProviderError,
|
|
88
|
-
|
|
111
|
+
withCauseDetail,
|
|
112
|
+
formatProviderError,
|
|
113
|
+
truncateErrorText
|
|
89
114
|
};
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
|
+
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
startOAuthCallbackServer,
|
|
5
|
+
waitForCallbackOrManualInput
|
|
6
|
+
} from "./chunk-K2J2VZXO.js";
|
|
7
|
+
import {
|
|
8
|
+
generatePKCE
|
|
9
|
+
} from "./chunk-YUO5V75X.js";
|
|
10
|
+
import {
|
|
11
|
+
getProviderEnvValue
|
|
12
|
+
} from "./chunk-SU2USXTD.js";
|
|
13
|
+
import "./chunk-CWESUMYQ.js";
|
|
14
|
+
|
|
15
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js
|
|
16
|
+
var decode = (s) => atob(s);
|
|
17
|
+
var CLIENT_ID = decode("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl");
|
|
18
|
+
var AUTHORIZE_URL = "https://claude.ai/oauth/authorize";
|
|
19
|
+
var TOKEN_URL = "https://platform.claude.com/v1/oauth/token";
|
|
20
|
+
var CALLBACK_HOST = getProviderEnvValue("PI_OAUTH_CALLBACK_HOST") || "127.0.0.1";
|
|
21
|
+
var CALLBACK_PORT = 53692;
|
|
22
|
+
var CALLBACK_PATH = "/callback";
|
|
23
|
+
var REDIRECT_URI = `http://localhost:${CALLBACK_PORT}${CALLBACK_PATH}`;
|
|
24
|
+
var COPY_CODE_REDIRECT_URI = "https://platform.claude.com/oauth/code/callback";
|
|
25
|
+
var ANTHROPIC_BROWSER_LOGIN_METHOD = "browser";
|
|
26
|
+
var ANTHROPIC_COPY_CODE_LOGIN_METHOD = "copy_code";
|
|
27
|
+
var SCOPES = "org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload";
|
|
28
|
+
function parseAuthorizationInput(input) {
|
|
29
|
+
const value = input.trim();
|
|
30
|
+
if (!value)
|
|
31
|
+
return {};
|
|
32
|
+
try {
|
|
33
|
+
const url = new URL(value);
|
|
34
|
+
return {
|
|
35
|
+
code: url.searchParams.get("code") ?? void 0,
|
|
36
|
+
state: url.searchParams.get("state") ?? void 0
|
|
37
|
+
};
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
if (value.includes("#")) {
|
|
41
|
+
const [code, state] = value.split("#", 2);
|
|
42
|
+
return { code, state };
|
|
43
|
+
}
|
|
44
|
+
if (value.includes("code=")) {
|
|
45
|
+
const params = new URLSearchParams(value);
|
|
46
|
+
return {
|
|
47
|
+
code: params.get("code") ?? void 0,
|
|
48
|
+
state: params.get("state") ?? void 0
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return { code: value };
|
|
52
|
+
}
|
|
53
|
+
function formatErrorDetails(error) {
|
|
54
|
+
if (error instanceof Error) {
|
|
55
|
+
const details = [`${error.name}: ${error.message}`];
|
|
56
|
+
const errorWithCode = error;
|
|
57
|
+
if (errorWithCode.code)
|
|
58
|
+
details.push(`code=${errorWithCode.code}`);
|
|
59
|
+
if (typeof errorWithCode.errno !== "undefined")
|
|
60
|
+
details.push(`errno=${String(errorWithCode.errno)}`);
|
|
61
|
+
if (typeof error.cause !== "undefined") {
|
|
62
|
+
details.push(`cause=${formatErrorDetails(error.cause)}`);
|
|
63
|
+
}
|
|
64
|
+
if (error.stack) {
|
|
65
|
+
details.push(`stack=${error.stack}`);
|
|
66
|
+
}
|
|
67
|
+
return details.join("; ");
|
|
68
|
+
}
|
|
69
|
+
return String(error);
|
|
70
|
+
}
|
|
71
|
+
async function postJson(url, body, signal) {
|
|
72
|
+
const response = await fetch(url, {
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: {
|
|
75
|
+
"Content-Type": "application/json",
|
|
76
|
+
Accept: "application/json"
|
|
77
|
+
},
|
|
78
|
+
body: JSON.stringify(body),
|
|
79
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(3e4)])
|
|
80
|
+
});
|
|
81
|
+
const responseBody = await response.text();
|
|
82
|
+
if (!response.ok) {
|
|
83
|
+
throw new Error(`HTTP request failed. status=${response.status}; url=${url}; body=${responseBody}`);
|
|
84
|
+
}
|
|
85
|
+
return responseBody;
|
|
86
|
+
}
|
|
87
|
+
async function exchangeAuthorizationCode(code, state, verifier, redirectUri, signal) {
|
|
88
|
+
let responseBody;
|
|
89
|
+
try {
|
|
90
|
+
responseBody = await postJson(TOKEN_URL, {
|
|
91
|
+
grant_type: "authorization_code",
|
|
92
|
+
client_id: CLIENT_ID,
|
|
93
|
+
code,
|
|
94
|
+
state,
|
|
95
|
+
redirect_uri: redirectUri,
|
|
96
|
+
code_verifier: verifier
|
|
97
|
+
}, signal);
|
|
98
|
+
} catch (error) {
|
|
99
|
+
throw new Error(`Token exchange request failed. url=${TOKEN_URL}; redirect_uri=${redirectUri}; response_type=authorization_code; details=${formatErrorDetails(error)}`);
|
|
100
|
+
}
|
|
101
|
+
let tokenData;
|
|
102
|
+
try {
|
|
103
|
+
tokenData = JSON.parse(responseBody);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
throw new Error(`Token exchange returned invalid JSON. url=${TOKEN_URL}; body=${responseBody}; details=${formatErrorDetails(error)}`);
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
type: "oauth",
|
|
109
|
+
refresh: tokenData.refresh_token,
|
|
110
|
+
access: tokenData.access_token,
|
|
111
|
+
expires: Date.now() + tokenData.expires_in * 1e3 - 5 * 60 * 1e3
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async function loginAnthropic(interaction) {
|
|
115
|
+
const { verifier, challenge } = await generatePKCE();
|
|
116
|
+
const startCallbackServer = (port) => startOAuthCallbackServer({
|
|
117
|
+
providerName: "Anthropic",
|
|
118
|
+
host: CALLBACK_HOST,
|
|
119
|
+
port,
|
|
120
|
+
path: CALLBACK_PATH,
|
|
121
|
+
redirectHost: "localhost",
|
|
122
|
+
state: verifier,
|
|
123
|
+
complete: async (code) => code,
|
|
124
|
+
signal: interaction.signal
|
|
125
|
+
});
|
|
126
|
+
const callback = await startCallbackServer(CALLBACK_PORT).catch(() => startCallbackServer(0)).catch(() => void 0);
|
|
127
|
+
const redirectUri = callback?.redirectUri ?? REDIRECT_URI;
|
|
128
|
+
try {
|
|
129
|
+
const authParams = new URLSearchParams({
|
|
130
|
+
code: "true",
|
|
131
|
+
client_id: CLIENT_ID,
|
|
132
|
+
response_type: "code",
|
|
133
|
+
redirect_uri: redirectUri,
|
|
134
|
+
scope: SCOPES,
|
|
135
|
+
code_challenge: challenge,
|
|
136
|
+
code_challenge_method: "S256",
|
|
137
|
+
state: verifier
|
|
138
|
+
});
|
|
139
|
+
interaction.notify({
|
|
140
|
+
type: "auth_url",
|
|
141
|
+
url: `${AUTHORIZE_URL}?${authParams.toString()}`,
|
|
142
|
+
instructions: "Complete login in your browser. If the browser is on another machine, paste the final redirect URL here."
|
|
143
|
+
});
|
|
144
|
+
const result = await waitForCallbackOrManualInput(interaction, callback, {
|
|
145
|
+
message: "Complete login in your browser, or paste the authorization code / redirect URL here:",
|
|
146
|
+
placeholder: redirectUri
|
|
147
|
+
});
|
|
148
|
+
let code;
|
|
149
|
+
let state = verifier;
|
|
150
|
+
if (result.type === "callback") {
|
|
151
|
+
code = result.value;
|
|
152
|
+
} else {
|
|
153
|
+
const parsed = parseAuthorizationInput(result.input);
|
|
154
|
+
if (parsed.state && parsed.state !== verifier)
|
|
155
|
+
throw new Error("OAuth state mismatch");
|
|
156
|
+
code = parsed.code;
|
|
157
|
+
state = parsed.state ?? verifier;
|
|
158
|
+
}
|
|
159
|
+
if (!code)
|
|
160
|
+
throw new Error("Missing authorization code");
|
|
161
|
+
interaction.notify({ type: "progress", message: "Exchanging authorization code for tokens..." });
|
|
162
|
+
return await exchangeAuthorizationCode(code, state, verifier, redirectUri, interaction.signal);
|
|
163
|
+
} finally {
|
|
164
|
+
callback?.close();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async function loginAnthropicCopyCode(interaction) {
|
|
168
|
+
const { verifier, challenge } = await generatePKCE();
|
|
169
|
+
const authParams = new URLSearchParams({
|
|
170
|
+
code: "true",
|
|
171
|
+
client_id: CLIENT_ID,
|
|
172
|
+
response_type: "code",
|
|
173
|
+
redirect_uri: COPY_CODE_REDIRECT_URI,
|
|
174
|
+
scope: SCOPES,
|
|
175
|
+
code_challenge: challenge,
|
|
176
|
+
code_challenge_method: "S256",
|
|
177
|
+
state: verifier
|
|
178
|
+
});
|
|
179
|
+
interaction.notify({
|
|
180
|
+
type: "auth_url",
|
|
181
|
+
url: `${AUTHORIZE_URL}?${authParams.toString()}`,
|
|
182
|
+
instructions: "Complete login in your browser, then copy the code Anthropic shows and paste it here."
|
|
183
|
+
});
|
|
184
|
+
const input = await interaction.prompt({
|
|
185
|
+
type: "manual_code",
|
|
186
|
+
message: "Paste the code Anthropic shows after you sign in:",
|
|
187
|
+
placeholder: "code#state",
|
|
188
|
+
signal: interaction.signal
|
|
189
|
+
});
|
|
190
|
+
const parsed = parseAuthorizationInput(input);
|
|
191
|
+
if (parsed.state && parsed.state !== verifier)
|
|
192
|
+
throw new Error("OAuth state mismatch");
|
|
193
|
+
if (!parsed.code)
|
|
194
|
+
throw new Error("Missing authorization code");
|
|
195
|
+
interaction.notify({ type: "progress", message: "Exchanging authorization code for tokens..." });
|
|
196
|
+
return await exchangeAuthorizationCode(parsed.code, parsed.state ?? verifier, verifier, COPY_CODE_REDIRECT_URI, interaction.signal);
|
|
197
|
+
}
|
|
198
|
+
async function refreshAnthropicToken(refreshToken, signal) {
|
|
199
|
+
let responseBody;
|
|
200
|
+
try {
|
|
201
|
+
responseBody = await postJson(TOKEN_URL, {
|
|
202
|
+
grant_type: "refresh_token",
|
|
203
|
+
client_id: CLIENT_ID,
|
|
204
|
+
refresh_token: refreshToken
|
|
205
|
+
}, signal);
|
|
206
|
+
} catch (error) {
|
|
207
|
+
throw new Error(`Anthropic token refresh request failed. url=${TOKEN_URL}; details=${formatErrorDetails(error)}`);
|
|
208
|
+
}
|
|
209
|
+
let data;
|
|
210
|
+
try {
|
|
211
|
+
data = JSON.parse(responseBody);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
throw new Error(`Anthropic token refresh returned invalid JSON. url=${TOKEN_URL}; body=${responseBody}; details=${formatErrorDetails(error)}`);
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
type: "oauth",
|
|
217
|
+
refresh: data.refresh_token,
|
|
218
|
+
access: data.access_token,
|
|
219
|
+
expires: Date.now() + data.expires_in * 1e3 - 5 * 60 * 1e3
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
var anthropicOAuth = {
|
|
223
|
+
name: "Anthropic (Claude Pro/Max)",
|
|
224
|
+
isSubscription: true,
|
|
225
|
+
async login(interaction) {
|
|
226
|
+
const method = await interaction.prompt({
|
|
227
|
+
type: "select",
|
|
228
|
+
message: "Select Anthropic login method:",
|
|
229
|
+
options: [
|
|
230
|
+
{ id: ANTHROPIC_BROWSER_LOGIN_METHOD, label: "Browser login (default)" },
|
|
231
|
+
{ id: ANTHROPIC_COPY_CODE_LOGIN_METHOD, label: "Copy code login (headless)" }
|
|
232
|
+
]
|
|
233
|
+
});
|
|
234
|
+
if (method === ANTHROPIC_COPY_CODE_LOGIN_METHOD) {
|
|
235
|
+
return loginAnthropicCopyCode(interaction);
|
|
236
|
+
}
|
|
237
|
+
if (method !== ANTHROPIC_BROWSER_LOGIN_METHOD) {
|
|
238
|
+
throw new Error(`Unknown Anthropic login method: ${method}`);
|
|
239
|
+
}
|
|
240
|
+
return loginAnthropic(interaction);
|
|
241
|
+
},
|
|
242
|
+
refresh: (credential, signal) => refreshAnthropicToken(credential.refresh, signal),
|
|
243
|
+
async toAuth(credential) {
|
|
244
|
+
return { apiKey: credential.access };
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
export {
|
|
248
|
+
anthropicOAuth
|
|
249
|
+
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
-
clampThinkingLevel
|
|
4
|
+
clampThinkingLevel
|
|
5
|
+
} from "./chunk-TGKIV3F4.js";
|
|
6
|
+
import {
|
|
5
7
|
getSystemMessageText
|
|
6
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XY53EFK3.js";
|
|
7
9
|
|
|
8
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
10
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js
|
|
9
11
|
var UnsupportedStrictJsonSchemaError = class extends Error {
|
|
10
12
|
};
|
|
11
13
|
var UNSUPPORTED_STRICT_SCHEMA_KEYS = [
|
|
@@ -118,6 +120,10 @@ function makeStrictJsonSchema(schema, isUnsupportedKeyword) {
|
|
|
118
120
|
}
|
|
119
121
|
return cloned;
|
|
120
122
|
}
|
|
123
|
+
function prefersJsonSchemaStrictSampling(tool) {
|
|
124
|
+
const config = tool.constrainedSampling;
|
|
125
|
+
return !!config && config.type === "json_schema" && config.strict === "prefer";
|
|
126
|
+
}
|
|
121
127
|
function getJsonSchemaToolParameters(tool, strict) {
|
|
122
128
|
return strict === true ? makeStrictJsonSchema(tool.parameters) : tool.parameters;
|
|
123
129
|
}
|
|
@@ -128,30 +134,35 @@ function getGrammarToolInput(toolName, arguments_, inputProperty) {
|
|
|
128
134
|
}
|
|
129
135
|
return input;
|
|
130
136
|
}
|
|
131
|
-
function appendGrammarToolInputJsonDelta(buffer, inputProperty,
|
|
137
|
+
function appendGrammarToolInputJsonDelta(buffer, inputProperty, inputDelta) {
|
|
132
138
|
if (buffer.closed) {
|
|
133
|
-
if (close && nextInput === buffer.input)
|
|
134
|
-
return void 0;
|
|
135
139
|
throw new Error(`grammar tool input for property "${inputProperty}" changed after it was closed`);
|
|
136
140
|
}
|
|
137
|
-
if (
|
|
138
|
-
throw new Error(`grammar tool input for property "${inputProperty}" changed non-monotonically`);
|
|
139
|
-
}
|
|
140
|
-
const inputDelta = nextInput.slice(buffer.input.length);
|
|
141
|
-
if (!close && inputDelta.length === 0)
|
|
141
|
+
if (inputDelta.length === 0)
|
|
142
142
|
return void 0;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
buffer.input += inputDelta;
|
|
144
|
+
return grammarToolInputJsonStart(buffer, inputProperty) + JSON.stringify(inputDelta).slice(1, -1);
|
|
145
|
+
}
|
|
146
|
+
function closeGrammarToolInputJson(buffer, inputProperty, finalInput) {
|
|
147
|
+
if (buffer.closed) {
|
|
148
|
+
if (finalInput === void 0 || finalInput === buffer.input)
|
|
149
|
+
return void 0;
|
|
150
|
+
throw new Error(`grammar tool input for property "${inputProperty}" changed after it was closed`);
|
|
147
151
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (close) {
|
|
151
|
-
delta += '"}';
|
|
152
|
-
buffer.closed = true;
|
|
152
|
+
if (finalInput !== void 0 && !finalInput.startsWith(buffer.input)) {
|
|
153
|
+
throw new Error(`grammar tool input for property "${inputProperty}" changed non-monotonically`);
|
|
153
154
|
}
|
|
154
|
-
|
|
155
|
+
const rest = finalInput === void 0 ? "" : finalInput.slice(buffer.input.length);
|
|
156
|
+
if (finalInput !== void 0)
|
|
157
|
+
buffer.input = finalInput;
|
|
158
|
+
buffer.closed = true;
|
|
159
|
+
return `${grammarToolInputJsonStart(buffer, inputProperty)}${JSON.stringify(rest).slice(1, -1)}"}`;
|
|
160
|
+
}
|
|
161
|
+
function grammarToolInputJsonStart(buffer, inputProperty) {
|
|
162
|
+
if (buffer.started)
|
|
163
|
+
return "";
|
|
164
|
+
buffer.started = true;
|
|
165
|
+
return `{${JSON.stringify(inputProperty)}:"`;
|
|
155
166
|
}
|
|
156
167
|
function inferGrammarInputProperty(tool) {
|
|
157
168
|
const schema = tool.parameters;
|
|
@@ -228,7 +239,7 @@ function createGrammarToolInputProperties(tools, supportsOpenAIGrammarTools) {
|
|
|
228
239
|
return properties;
|
|
229
240
|
}
|
|
230
241
|
|
|
231
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
242
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js
|
|
232
243
|
var CHARS_PER_TOKEN = 3.5;
|
|
233
244
|
var ESTIMATED_IMAGE_CHARS = 4800;
|
|
234
245
|
function calculateContextTokens(usage) {
|
|
@@ -313,14 +324,21 @@ function estimateToolsTokens(tools) {
|
|
|
313
324
|
return estimateTextTokens(safeJsonStringify(tools));
|
|
314
325
|
}
|
|
315
326
|
|
|
316
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
327
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js
|
|
317
328
|
var CONTEXT_SAFETY_TOKENS = 4096;
|
|
329
|
+
var CONTEXT_SAFETY_RATIO = 0.15;
|
|
330
|
+
var MIN_OUTPUT_WITH_RATIO_MARGIN = 32768;
|
|
318
331
|
var MIN_MAX_TOKENS = 1;
|
|
319
332
|
function clampMaxTokensToContext(model, context, maxTokens) {
|
|
320
333
|
if (model.contextWindow <= 0)
|
|
321
334
|
return Math.max(MIN_MAX_TOKENS, maxTokens);
|
|
322
|
-
const
|
|
323
|
-
|
|
335
|
+
const input = estimateContextTokens(context).tokens;
|
|
336
|
+
const margin = Math.max(CONTEXT_SAFETY_TOKENS, Math.ceil(input * CONTEXT_SAFETY_RATIO));
|
|
337
|
+
let room = model.contextWindow - input - margin;
|
|
338
|
+
if (room < MIN_OUTPUT_WITH_RATIO_MARGIN) {
|
|
339
|
+
room = Math.min(MIN_OUTPUT_WITH_RATIO_MARGIN, model.contextWindow - input - CONTEXT_SAFETY_TOKENS);
|
|
340
|
+
}
|
|
341
|
+
return Math.min(maxTokens, Math.max(MIN_MAX_TOKENS, room));
|
|
324
342
|
}
|
|
325
343
|
function resolveSamplingParams(model, thinkingLevel, requestParams) {
|
|
326
344
|
const effectiveThinkingLevel = clampThinkingLevel(model, thinkingLevel);
|
|
@@ -340,6 +358,7 @@ function buildBaseOptions(model, context, options, apiKey) {
|
|
|
340
358
|
transport: options?.transport,
|
|
341
359
|
cacheRetention: options?.cacheRetention,
|
|
342
360
|
sessionId: options?.sessionId,
|
|
361
|
+
disableContinuation: options?.disableContinuation,
|
|
343
362
|
headers: options?.headers,
|
|
344
363
|
identity: options?.identity,
|
|
345
364
|
onPayload: options?.onPayload,
|
|
@@ -380,7 +399,7 @@ function adjustMaxTokensForThinking(baseMaxTokens, modelMaxTokens, reasoningLeve
|
|
|
380
399
|
return { maxTokens, thinkingBudget };
|
|
381
400
|
}
|
|
382
401
|
|
|
383
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
402
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js
|
|
384
403
|
var NON_VISION_USER_IMAGE_PLACEHOLDER = "(image omitted: model does not support images)";
|
|
385
404
|
var NON_VISION_TOOL_IMAGE_PLACEHOLDER = "(tool image omitted: model does not support images)";
|
|
386
405
|
var ERROR_TOOL_IMAGE_PLACEHOLDER = "(image attached after the tool results)";
|
|
@@ -552,15 +571,18 @@ function transformMessages(messages, model, normalizeToolCallId) {
|
|
|
552
571
|
}
|
|
553
572
|
|
|
554
573
|
export {
|
|
574
|
+
prefersJsonSchemaStrictSampling,
|
|
555
575
|
getJsonSchemaToolParameters,
|
|
556
576
|
getGrammarToolInput,
|
|
557
577
|
appendGrammarToolInputJsonDelta,
|
|
578
|
+
closeGrammarToolInputJson,
|
|
558
579
|
resolveJsonSchemaStrictSampling,
|
|
559
580
|
resolveGrammarConstrainedSampling,
|
|
560
581
|
createGrammarToolInputProperties,
|
|
561
582
|
clampMaxTokensToContext,
|
|
562
583
|
resolveSamplingParams,
|
|
563
584
|
buildBaseOptions,
|
|
585
|
+
clampReasoning,
|
|
564
586
|
thinkingBudgetForLevel,
|
|
565
587
|
clampThinkingBudgetToAnswerRoom,
|
|
566
588
|
adjustMaxTokensForThinking,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
|
+
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/session-resources.js
|
|
5
|
+
var sessionResourceCleanups = /* @__PURE__ */ new Set();
|
|
6
|
+
function registerSessionResourceCleanup(cleanup) {
|
|
7
|
+
sessionResourceCleanups.add(cleanup);
|
|
8
|
+
return () => {
|
|
9
|
+
sessionResourceCleanups.delete(cleanup);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function cleanupSessionResources(sessionId) {
|
|
13
|
+
const errors = [];
|
|
14
|
+
for (const cleanup of sessionResourceCleanups) {
|
|
15
|
+
try {
|
|
16
|
+
cleanup(sessionId);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
errors.push(error);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (errors.length > 0) {
|
|
22
|
+
throw new AggregateError(errors, "Failed to cleanup session resources");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
registerSessionResourceCleanup,
|
|
28
|
+
cleanupSessionResources
|
|
29
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
3
|
|
|
4
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
4
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/api/openai-prompt-cache.js
|
|
5
5
|
var OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH = 64;
|
|
6
6
|
function clampOpenAIPromptCacheKey(key) {
|
|
7
7
|
if (key === void 0)
|