wednesdayai 0.5.1-dev.25 → 0.5.1-dev.27
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/dist/{agent-scope-BKsGMXqc.js → agent-scope-DCgndASv.js} +3 -3
- package/dist/{agent-turn-runner-LKV3FMwQ.js → agent-turn-runner-CX7rX8by.js} +6 -6
- package/dist/{api-key-rotation-DZNFm4xG.js → api-key-rotation-dv2YbGr8.js} +2 -2
- package/dist/{audio-preflight-DQous9JR.js → audio-preflight-Qwb3oAbc.js} +29 -29
- package/dist/{audio-transcription-runner-BK3cV_ad.js → audio-transcription-runner-C4eHWIy0.js} +26 -26
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +60 -60
- package/dist/bundled/bootstrap-extra-files/handler.js +6 -6
- package/dist/bundled/command-logger/handler.js +2 -2
- package/dist/bundled/session-journal/handler.js +60 -60
- package/dist/bundled/session-memory/handler.js +60 -60
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/{channel-activity-BAxUpg5h.js → channel-activity-Kn1_ykXE.js} +3 -3
- package/dist/{chat-content-BWkiC3u3.js → chat-content-CX7Bfpgy.js} +34 -34
- package/dist/{chrome-Dzgbe0zH.js → chrome-Bukcguhv.js} +31 -31
- package/dist/{chunk-Bvf22vTh.js → chunk-CEygNI3g.js} +3 -3
- package/dist/{command-queue-BOMFLCHM.js → command-queue-DOzYI9q4.js} +1 -1
- package/dist/{commands-registry-Da3c0MbL.js → commands-registry-Cof4HjvY.js} +2 -2
- package/dist/config.js +9 -9
- package/dist/{deliver-CJjQbaJE.js → deliver-BaTG7V5x.js} +29 -29
- package/dist/{diagnostic-Dn_o8RGN.js → diagnostic-DMrDenZI.js} +5 -5
- package/dist/{errors-1FTZDNVR.js → errors-COs_vQr3.js} +1 -1
- package/dist/{fetch-CnDdghbc.js → fetch-B1ohBh6A.js} +8 -8
- package/dist/{fetch-guard-B6BYdjiQ.js → fetch-guard-BXzVwvnJ.js} +3 -3
- package/dist/{frontmatter-DvbDhvt1.js → frontmatter-Cw_6jMAR.js} +3 -3
- package/dist/{fs-safe-IYMDplSg.js → fs-safe-BK5ALzKD.js} +26 -26
- package/dist/github-copilot-token-DYYKoDuV.js +106 -0
- package/dist/{image-ops-BuzZGoUm.js → image-ops-C-5VgbLB.js} +1 -1
- package/dist/{ir-CBsM7qoP.js → ir-DioI2VyB.js} +5 -5
- package/dist/{legacy-names-Ckds5WWe.js → legacy-names-CghFcfry.js} +1 -1
- package/dist/llm-slug-generator.js +60 -60
- package/dist/{logger-BeXVb5cn.js → logger-J4xjy-6D.js} +1 -1
- package/dist/{manager-BujYLKny.js → manager-D728Thsn.js} +18 -18
- package/dist/{markdown-tables-WuCFdPlC.js → markdown-tables-DfLMw9ti.js} +2 -2
- package/dist/{model-selection-CHi8o17y.js → model-selection-BHGpQSa9.js} +83 -83
- package/dist/{models-config-CAlyknIh.js → models-config-CJUMccZW.js} +2 -2
- package/dist/{outbound-attachment-C6mfyze2.js → outbound-attachment-DtVXUXnX.js} +2 -2
- package/dist/{outbound-message-hooks-jUzcd2OQ.js → outbound-message-hooks-7ErHCBLv.js} +5 -5
- package/dist/{path-alias-guards-BgOxr6f8.js → path-alias-guards-E9ntDORB.js} +1 -1
- package/dist/paths-BIDPYPVC.js +233 -0
- package/dist/{pi-embedded-aOKwlbog.js → pi-embedded-DpTacVAX.js} +277 -277
- package/dist/{pi-embedded-utils-BGvDJMAA.js → pi-embedded-utils-BAaHvb5G.js} +3 -3
- package/dist/{pi-model-discovery-CYfRyzsD.js → pi-model-discovery-BaH_6win.js} +7 -7
- package/dist/plugin-sdk/{agent-turn-execute-C6g1y27e.js → agent-turn-execute-Dg4sVJSk.js} +12 -12
- package/dist/plugin-sdk/{agent-turn-runner-BkP71ySA.js → agent-turn-runner-CD9Y0Gsf.js} +4 -4
- package/dist/plugin-sdk/{audio-preflight-CsMLbzm_.js → audio-preflight-GgmY1Zte.js} +5 -5
- package/dist/plugin-sdk/{audio-transcription-runner-2bpzZm3F.js → audio-transcription-runner-0gef4Ef0.js} +1 -1
- package/dist/plugin-sdk/{chat-content-CCOQCwrz.js → chat-content-Dpzf2nbZ.js} +3 -3
- package/dist/plugin-sdk/{chrome-C2bUQR0d.js → chrome-D9DwZOSC.js} +8 -8
- package/dist/plugin-sdk/{command-queue-J0ZpvnYU.js → command-queue-Cm8QKC0F.js} +1 -1
- package/dist/plugin-sdk/{deliver-CT3Lk2kq.js → deliver-CZVPDUrt.js} +1 -1
- package/dist/plugin-sdk/{deliver-dkNTCb3Z.js → deliver-D6hs0zDt.js} +3 -3
- package/dist/plugin-sdk/{diagnostic-C-Clqb63.js → diagnostic-Bi52EuT5.js} +1 -1
- package/dist/plugin-sdk/{monitor-BHeL2-is.js → monitor-BrUwRgsT.js} +32 -32
- package/dist/plugin-sdk/{pi-embedded-utils-BmeLQMRx.js → pi-embedded-utils-CeNVVYT3.js} +1 -1
- package/dist/plugin-sdk/{provider-dispatcher-BkEWKVLB.js → provider-dispatcher-Bx_RMlu-.js} +12 -12
- package/dist/plugin-sdk/{provider-image-QDVfXKph.js → provider-image-CBXOs7yQ.js} +4 -4
- package/dist/plugin-sdk/{provider-image-BSV8WjkR.js → provider-image-DH8Jro3J.js} +1 -1
- package/dist/plugin-sdk/{pw-ai-QlS2E2LB.js → pw-ai-BP4Kwaqc.js} +1 -1
- package/dist/plugin-sdk/{runs-8iACp6xv.js → runs-C1Lvxfri.js} +3 -3
- package/dist/plugin-sdk/{runs-D0UdtKVI.js → runs-DG49eFuR.js} +5 -5
- package/dist/plugin-sdk/{send-BP8o2l4w.js → send-BguPpGBL.js} +2 -2
- package/dist/plugin-sdk/{send-CYZi6dwK.js → send-CcEF6VcP.js} +1 -1
- package/dist/plugin-sdk/{subagent-registry-DA50ITkO.js → subagent-registry-B4EmS6cu.js} +12 -12
- package/dist/plugin-sdk/testing.js +12 -12
- package/dist/{provider-image-CNBkTbhu.js → provider-image-BSkZoSBN.js} +6 -6
- package/dist/{proxy-Ds4gxPy8.js → proxy-CrSpy5Aw.js} +1 -1
- package/dist/{proxy-env-DAf-b2bM.js → proxy-env-BxR4m86L.js} +1 -1
- package/dist/{proxy-fetch-M3YAp_Kv.js → proxy-fetch-g109vqdt.js} +1 -1
- package/dist/{pw-ai-BcibeG9a.js → pw-ai-CNTt9O_x.js} +14 -14
- package/dist/{qmd-manager-C3UBJiCk.js → qmd-manager-CU9iEql0.js} +12 -12
- package/dist/{query-expansion-BT5lS0um.js → query-expansion-B_2rETEo.js} +13 -13
- package/dist/{recorder-B08vNxya.js → recorder-Clg9Kbqu.js} +2 -2
- package/dist/{redact-CKI6SufO.js → redact-DpE5Tg36.js} +1 -1
- package/dist/{replies-BHkXhmOj.js → replies-Cty02S3t.js} +5 -5
- package/dist/{reply-directives-DkfwzHl4.js → reply-directives-BIh2AkNd.js} +2 -2
- package/dist/{reply-prefix-DS2s69iC.js → reply-prefix-C-DjHvQK.js} +1 -1
- package/dist/{resolve-route-DxuZn3_M.js → resolve-route-DKZiteo6.js} +5 -5
- package/dist/{runs-DFvW_PVw.js → runs-6Q7RU60m.js} +9 -9
- package/dist/{send-D2WSE41A.js → send-Bf4geLyV.js} +8 -8
- package/dist/{send-mILKKt54.js → send-CsDSBjFo.js} +6 -6
- package/dist/{send-yIxOvEiz.js → send-DQvfLvpJ.js} +6 -6
- package/dist/{send-2aTk7PU-.js → send-VDe5tGbO.js} +28 -28
- package/dist/{send-odd2G3DX.js → send-bwKTbNlJ.js} +7 -7
- package/dist/{session-meta-B8B6RwSE.js → session-meta-5XI6vLtM.js} +1 -1
- package/dist/{sessions-DC7A0bw-.js → sessions-DF9biCmh.js} +5 -5
- package/dist/{skill-commands-DdVSQNce.js → skill-commands-CAOvM2sb.js} +8 -8
- package/dist/{skills-BXMjgvRl.js → skills-VN1CJK6W.js} +21 -21
- package/dist/{store-BVdeIl7N.js → store-HgGweM4u.js} +7 -7
- package/dist/subsystem-BZy3aWdW.js +2761 -0
- package/dist/{tables-yHwb0GsI.js → tables-DkwNUhx1.js} +1 -1
- package/dist/{tokens-CXBau-U0.js → tokens-PMai9bNL.js} +1 -1
- package/dist/{tool-loop-detection-Bw8B0hV3.js → tool-loop-detection-BqyMjpvr.js} +2 -2
- package/dist/{user-run-recording-8MZq1Us4.js → user-run-recording-B1HujJiT.js} +2 -2
- package/dist/{workspace-DK2ZEkpT.js → workspace-Bj1Jegt-.js} +27 -27
- package/extensions/acpx/package.json +1 -1
- package/extensions/anthropic/package.json +1 -1
- package/extensions/bifrost/package.json +1 -1
- package/extensions/bluebubbles/package.json +1 -1
- package/extensions/copilot-proxy/package.json +1 -1
- package/extensions/deepgram/package.json +1 -1
- package/extensions/deepinfra/package.json +1 -1
- package/extensions/diagnostics-otel/package.json +1 -1
- package/extensions/diffs/package.json +1 -1
- package/extensions/discord/package.json +1 -1
- package/extensions/dream-cycle/package.json +1 -1
- package/extensions/elevenlabs/package.json +1 -1
- package/extensions/feishu/package.json +1 -1
- package/extensions/gemini-search/package.json +1 -1
- package/extensions/google/package.json +1 -1
- package/extensions/google-gemini-cli-auth/package.json +1 -1
- package/extensions/googlechat/package.json +1 -1
- package/extensions/grok-search/package.json +1 -1
- package/extensions/groq/package.json +1 -1
- package/extensions/imessage/package.json +1 -1
- package/extensions/irc/package.json +1 -1
- package/extensions/kimi-search/package.json +1 -1
- package/extensions/learning-core/package.json +1 -1
- package/extensions/line/package.json +1 -1
- package/extensions/llm-task/package.json +1 -1
- package/extensions/lobster/package.json +1 -1
- package/extensions/matrix/CHANGELOG.md +1 -1
- package/extensions/matrix/package.json +1 -1
- package/extensions/mattermost/package.json +1 -1
- package/extensions/memory-core/package.json +1 -1
- package/extensions/memory-lancedb/package.json +1 -1
- package/extensions/minimax/package.json +1 -1
- package/extensions/minimax-portal-auth/package.json +1 -1
- package/extensions/mistral/package.json +1 -1
- package/extensions/moonshot/package.json +1 -1
- package/extensions/msteams/CHANGELOG.md +1 -1
- package/extensions/msteams/package.json +1 -1
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nostr/CHANGELOG.md +1 -1
- package/extensions/nostr/package.json +1 -1
- package/extensions/open-prose/package.json +1 -1
- package/extensions/openai/package.json +1 -1
- package/extensions/openai-realtime/package.json +1 -1
- package/extensions/openrouter/package.json +1 -1
- package/extensions/perplexity-search/package.json +1 -1
- package/extensions/searxng-search/package.json +1 -1
- package/extensions/signal/package.json +1 -1
- package/extensions/slack/package.json +1 -1
- package/extensions/synology-chat/package.json +1 -1
- package/extensions/telegram/package.json +1 -1
- package/extensions/tlon/package.json +1 -1
- package/extensions/twitch/CHANGELOG.md +1 -1
- package/extensions/twitch/package.json +1 -1
- package/extensions/ui-surfaces/package.json +1 -1
- package/extensions/voice-call/CHANGELOG.md +1 -1
- package/extensions/voice-call/package.json +1 -1
- package/extensions/whatsapp/package.json +1 -1
- package/extensions/zai/package.json +1 -1
- package/extensions/zalo/CHANGELOG.md +1 -1
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalouser/CHANGELOG.md +1 -1
- package/extensions/zalouser/package.json +1 -1
- package/package.json +6 -3
- package/scripts/install.ps1 +329 -0
- package/scripts/install.sh +2479 -0
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
|
|
2
|
-
import { l as resolveDefaultAgentId } from "./agent-scope-
|
|
3
|
-
import { l as resolveStateDir } from "./paths-
|
|
4
|
-
import { t as createSubsystemLogger } from "./subsystem-
|
|
5
|
-
import { H as normalizeOptionalAccountId, M as normalizeMainKey, Q as parseAgentSessionKey, V as normalizeAccountId, j as normalizeAgentId } from "./workspace-
|
|
6
|
-
import { Gt as getActivePluginRegistry, Jn as normalizeChannelId, Kn as getChannelPlugin, Tn as updateSessionStoreEntry, U as loadConfig, Un as resolveStorePath, Yn as getChannelDock, _n as loadSessionStore, ga as resolveOpenClawAgentDir, gn as listConfiguredSessionStorageAgentIds, ln as getConversationReadQuery, qt as getActivePluginRegistryVersion, sn as StorageReadAccessError } from "./model-selection-
|
|
7
|
-
import { L as resolveMainSessionKey, Mt as hasInterSessionUserProvenance, P as canonicalizeMainSessionAlias, Pt as getGlobalHookRunner, a as resolveMirroredTranscriptText, i as appendAssistantMessageToSessionTranscript, o as parseInlineDirectives, ot as eventOrder } from "./sessions-
|
|
2
|
+
import { l as resolveDefaultAgentId } from "./agent-scope-DCgndASv.js";
|
|
3
|
+
import { l as resolveStateDir } from "./paths-BIDPYPVC.js";
|
|
4
|
+
import { t as createSubsystemLogger } from "./subsystem-BZy3aWdW.js";
|
|
5
|
+
import { H as normalizeOptionalAccountId, M as normalizeMainKey, Q as parseAgentSessionKey, V as normalizeAccountId, j as normalizeAgentId } from "./workspace-Bj1Jegt-.js";
|
|
6
|
+
import { Gt as getActivePluginRegistry, Jn as normalizeChannelId, Kn as getChannelPlugin, Tn as updateSessionStoreEntry, U as loadConfig, Un as resolveStorePath, Yn as getChannelDock, _n as loadSessionStore, ga as resolveOpenClawAgentDir, gn as listConfiguredSessionStorageAgentIds, ln as getConversationReadQuery, qt as getActivePluginRegistryVersion, sn as StorageReadAccessError } from "./model-selection-BHGpQSa9.js";
|
|
7
|
+
import { L as resolveMainSessionKey, Mt as hasInterSessionUserProvenance, P as canonicalizeMainSessionAlias, Pt as getGlobalHookRunner, a as resolveMirroredTranscriptText, i as appendAssistantMessageToSessionTranscript, o as parseInlineDirectives, ot as eventOrder } from "./sessions-DF9biCmh.js";
|
|
8
8
|
import { n as generateSecureUuid } from "./secure-random-BEYczWtd.js";
|
|
9
|
-
import { a as isMessagingToolDuplicate, t as extractTextFromChatContent } from "./chat-content-
|
|
10
|
-
import { o as hasErrnoCode } from "./errors-
|
|
11
|
-
import { t as ensureOpenClawModelsJson } from "./models-config-
|
|
12
|
-
import { i as getAgentScopedMediaLocalRoots } from "./fetch-
|
|
13
|
-
import { c as resolveChunkDelivery, d as resolveTextChunkLimit, i as chunkMarkdownTextWithMode, n as chunkByParagraph } from "./chunk-
|
|
14
|
-
import { n as resolveMarkdownTableMode } from "./markdown-tables-
|
|
15
|
-
import { d as resolveOutboundSessionId, n as createMessageSentEmitter, t as applyMessageSendingHook } from "./outbound-message-hooks-
|
|
16
|
-
import { t as parseReplyDirectives } from "./reply-directives-
|
|
17
|
-
import { l as markdownToSignalTextChunks, t as sendMessageSignal } from "./send-
|
|
9
|
+
import { a as isMessagingToolDuplicate, t as extractTextFromChatContent } from "./chat-content-CX7Bfpgy.js";
|
|
10
|
+
import { o as hasErrnoCode } from "./errors-COs_vQr3.js";
|
|
11
|
+
import { t as ensureOpenClawModelsJson } from "./models-config-CJUMccZW.js";
|
|
12
|
+
import { i as getAgentScopedMediaLocalRoots } from "./fetch-B1ohBh6A.js";
|
|
13
|
+
import { c as resolveChunkDelivery, d as resolveTextChunkLimit, i as chunkMarkdownTextWithMode, n as chunkByParagraph } from "./chunk-CEygNI3g.js";
|
|
14
|
+
import { n as resolveMarkdownTableMode } from "./markdown-tables-DfLMw9ti.js";
|
|
15
|
+
import { d as resolveOutboundSessionId, n as createMessageSentEmitter, t as applyMessageSendingHook } from "./outbound-message-hooks-7ErHCBLv.js";
|
|
16
|
+
import { t as parseReplyDirectives } from "./reply-directives-BIh2AkNd.js";
|
|
17
|
+
import { l as markdownToSignalTextChunks, t as sendMessageSignal } from "./send-CsDSBjFo.js";
|
|
18
18
|
import path from "node:path";
|
|
19
|
-
import
|
|
19
|
+
import fs from "node:fs";
|
|
20
20
|
import { createHash } from "node:crypto";
|
|
21
21
|
import { setTimeout } from "node:timers/promises";
|
|
22
22
|
|
|
@@ -372,7 +372,7 @@ function ensureContextWindowCacheLoaded() {
|
|
|
372
372
|
await ensureOpenClawModelsJson(cfg);
|
|
373
373
|
} catch {}
|
|
374
374
|
try {
|
|
375
|
-
const { discoverAuthStorage, discoverModels } = await import("./pi-model-discovery-
|
|
375
|
+
const { discoverAuthStorage, discoverModels } = await import("./pi-model-discovery-BaH_6win.js").then((n) => n.r);
|
|
376
376
|
const agentDir = resolveOpenClawAgentDir();
|
|
377
377
|
const modelRegistry = discoverModels(discoverAuthStorage(agentDir), agentDir);
|
|
378
378
|
applyDiscoveredContextWindows({
|
|
@@ -688,7 +688,7 @@ function listExistingAgentIdsFromDisk() {
|
|
|
688
688
|
const root = resolveStateDir();
|
|
689
689
|
const agentsDir = path.join(root, "agents");
|
|
690
690
|
try {
|
|
691
|
-
return
|
|
691
|
+
return fs.readdirSync(agentsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => normalizeAgentId(entry.name)).filter(Boolean);
|
|
692
692
|
} catch {
|
|
693
693
|
return [];
|
|
694
694
|
}
|
|
@@ -889,11 +889,11 @@ function resolveFailedDir(stateDir) {
|
|
|
889
889
|
/** Ensure the queue directory (and failed/ subdirectory) exist. */
|
|
890
890
|
async function ensureQueueDir(stateDir) {
|
|
891
891
|
const queueDir = resolveQueueDir(stateDir);
|
|
892
|
-
await
|
|
892
|
+
await fs.promises.mkdir(queueDir, {
|
|
893
893
|
recursive: true,
|
|
894
894
|
mode: 448
|
|
895
895
|
});
|
|
896
|
-
await
|
|
896
|
+
await fs.promises.mkdir(resolveFailedDir(stateDir), {
|
|
897
897
|
recursive: true,
|
|
898
898
|
mode: 448
|
|
899
899
|
});
|
|
@@ -923,18 +923,18 @@ async function enqueueDelivery(params, stateDir) {
|
|
|
923
923
|
const filePath = path.join(queueDir, `${id}.json`);
|
|
924
924
|
const tmp = `${filePath}.${process.pid}.tmp`;
|
|
925
925
|
const json = JSON.stringify(entry, null, 2);
|
|
926
|
-
await
|
|
926
|
+
await fs.promises.writeFile(tmp, json, {
|
|
927
927
|
encoding: "utf-8",
|
|
928
928
|
mode: 384
|
|
929
929
|
});
|
|
930
|
-
await
|
|
930
|
+
await fs.promises.rename(tmp, filePath);
|
|
931
931
|
return id;
|
|
932
932
|
}
|
|
933
933
|
/** Remove a successfully delivered entry from the queue. */
|
|
934
934
|
async function ackDelivery(id, stateDir) {
|
|
935
935
|
const filePath = path.join(resolveQueueDir(stateDir), `${id}.json`);
|
|
936
936
|
try {
|
|
937
|
-
await
|
|
937
|
+
await fs.promises.unlink(filePath);
|
|
938
938
|
} catch (err) {
|
|
939
939
|
if ((err && typeof err === "object" && "code" in err ? String(err.code) : null) !== "ENOENT") throw err;
|
|
940
940
|
}
|
|
@@ -961,22 +961,22 @@ async function failDelivery(id, error, stateDir) {
|
|
|
961
961
|
return serializeByKey(filePath, () => failDeliveryWrite(filePath, error));
|
|
962
962
|
}
|
|
963
963
|
async function failDeliveryWrite(filePath, error) {
|
|
964
|
-
const raw = await
|
|
964
|
+
const raw = await fs.promises.readFile(filePath, "utf-8");
|
|
965
965
|
const entry = JSON.parse(raw);
|
|
966
966
|
entry.retryCount += 1;
|
|
967
967
|
entry.lastAttemptAt = Date.now();
|
|
968
968
|
entry.lastError = error;
|
|
969
969
|
const tmp = `${filePath}.${process.pid}.tmp`;
|
|
970
|
-
await
|
|
970
|
+
await fs.promises.writeFile(tmp, JSON.stringify(entry, null, 2), {
|
|
971
971
|
encoding: "utf-8",
|
|
972
972
|
mode: 384
|
|
973
973
|
});
|
|
974
|
-
await
|
|
974
|
+
await fs.promises.rename(tmp, filePath);
|
|
975
975
|
}
|
|
976
976
|
/** Read a queue entry raw; null when the file is missing. */
|
|
977
977
|
async function readEntryFile(filePath) {
|
|
978
978
|
try {
|
|
979
|
-
const raw = await
|
|
979
|
+
const raw = await fs.promises.readFile(filePath, "utf-8");
|
|
980
980
|
return JSON.parse(raw);
|
|
981
981
|
} catch (err) {
|
|
982
982
|
if (hasErrnoCode(err, "ENOENT")) return null;
|
|
@@ -998,11 +998,11 @@ function markDeliveryPhase(filePath, transition) {
|
|
|
998
998
|
const next = transition(entry);
|
|
999
999
|
if (!next.advanced) return next;
|
|
1000
1000
|
const tmp = `${filePath}.${process.pid}.tmp`;
|
|
1001
|
-
await
|
|
1001
|
+
await fs.promises.writeFile(tmp, JSON.stringify(next.entry, null, 2), {
|
|
1002
1002
|
encoding: "utf-8",
|
|
1003
1003
|
mode: 384
|
|
1004
1004
|
});
|
|
1005
|
-
await
|
|
1005
|
+
await fs.promises.rename(tmp, filePath);
|
|
1006
1006
|
return next;
|
|
1007
1007
|
});
|
|
1008
1008
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
|
|
2
|
-
import { t as createSubsystemLogger } from "./subsystem-
|
|
3
|
-
import { N as resolveAgentIdFromSessionKey } from "./workspace-
|
|
4
|
-
import { U as loadConfig } from "./model-selection-
|
|
2
|
+
import { t as createSubsystemLogger } from "./subsystem-BZy3aWdW.js";
|
|
3
|
+
import { N as resolveAgentIdFromSessionKey } from "./workspace-Bj1Jegt-.js";
|
|
4
|
+
import { U as loadConfig } from "./model-selection-BHGpQSa9.js";
|
|
5
5
|
import { t as emitDiagnosticEvent } from "./diagnostic-events-DGRcTqIH.js";
|
|
6
6
|
import { a as recordSessionChannelCorrelation, i as pruneDiagnosticSessionStates, o as recordTurnDuration, r as getDiagnosticSessionState, s as redactChannelCorrelation, t as diagnosticSessionStates } from "./diagnostic-session-state-Bnyx-w0F.js";
|
|
7
7
|
import { t as redactIdentifier } from "./redact-identifier-WYElxwAZ.js";
|
|
8
|
-
import { t as redactSensitiveText } from "./redact-
|
|
8
|
+
import { t as redactSensitiveText } from "./redact-DpE5Tg36.js";
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
|
|
11
11
|
//#region src/agents/command-poll-backoff.ts
|
|
@@ -837,7 +837,7 @@ function startDiagnosticHeartbeat(config) {
|
|
|
837
837
|
if (ageMs > stuckSessionAbortMs && state.queueDepth > 0 && !state.capturedEnd && !state.abortDispatched && state.sessionId) {
|
|
838
838
|
state.abortDispatched = true;
|
|
839
839
|
diag.warn(`stuck-session abort: sessionId=${state.sessionId} progressAge=${Math.round(ageMs / 1e3)}s threshold=${Math.round(stuckSessionAbortMs / 1e3)}s queueDepth=${state.queueDepth}`);
|
|
840
|
-
import("./runs-
|
|
840
|
+
import("./runs-6Q7RU60m.js").then((n) => n.c).then(({ abortEmbeddedPiRun }) => {
|
|
841
841
|
if (state.sessionId && state.abortDispatched) abortEmbeddedPiRun(state.sessionId);
|
|
842
842
|
}).catch((err) => {
|
|
843
843
|
diag.warn(`stuck-session abort import failed: ${String(err)}`);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { c as resolveAgentWorkspaceDir } from "./agent-scope-
|
|
2
|
-
import { l as resolveStateDir } from "./paths-
|
|
3
|
-
import { mt as resolvePreferredOpenClawTmpDir } from "./subsystem-
|
|
4
|
-
import { U as loadConfig } from "./model-selection-
|
|
5
|
-
import { t as redactSensitiveText } from "./redact-
|
|
6
|
-
import { c as detectMime, l as extensionForMime } from "./image-ops-
|
|
7
|
-
import { r as formatErrorChainMessage } from "./errors-
|
|
1
|
+
import { c as resolveAgentWorkspaceDir } from "./agent-scope-DCgndASv.js";
|
|
2
|
+
import { l as resolveStateDir } from "./paths-BIDPYPVC.js";
|
|
3
|
+
import { mt as resolvePreferredOpenClawTmpDir } from "./subsystem-BZy3aWdW.js";
|
|
4
|
+
import { U as loadConfig } from "./model-selection-BHGpQSa9.js";
|
|
5
|
+
import { t as redactSensitiveText } from "./redact-DpE5Tg36.js";
|
|
6
|
+
import { c as detectMime, l as extensionForMime } from "./image-ops-C-5VgbLB.js";
|
|
7
|
+
import { r as formatErrorChainMessage } from "./errors-COs_vQr3.js";
|
|
8
8
|
import { t as resolveNetworkSsrFPolicy } from "./ssrf-config-Cj-XaaTu.js";
|
|
9
|
-
import { n as withStrictGuardedFetchMode, t as fetchWithSsrFGuard } from "./fetch-guard-
|
|
9
|
+
import { n as withStrictGuardedFetchMode, t as fetchWithSsrFGuard } from "./fetch-guard-BXzVwvnJ.js";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
|
|
12
12
|
//#region src/media/local-roots.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as logWarn, r as logInfo } from "./logger-
|
|
2
|
-
import { c as resolvePinnedHostnameWithPolicy, i as createPinnedDispatcher, n as SsrFBlockedError, o as isPrivateIpAddress, r as closeDispatcher, t as hasProxyEnvConfigured } from "./proxy-env-
|
|
1
|
+
import { i as logWarn, r as logInfo } from "./logger-J4xjy-6D.js";
|
|
2
|
+
import { c as resolvePinnedHostnameWithPolicy, i as createPinnedDispatcher, n as SsrFBlockedError, o as isPrivateIpAddress, r as closeDispatcher, t as hasProxyEnvConfigured } from "./proxy-env-BxR4m86L.js";
|
|
3
3
|
import { t as bindAbortRelay } from "./fetch-timeout-Dyj5Y_Ss.js";
|
|
4
|
-
import { t as isNpmUndiciDispatchingFetch } from "./proxy-fetch-
|
|
4
|
+
import { t as isNpmUndiciDispatchingFetch } from "./proxy-fetch-g109vqdt.js";
|
|
5
5
|
import { EnvHttpProxyAgent, FormData, fetch } from "undici";
|
|
6
6
|
|
|
7
7
|
//#region src/infra/net/form-data.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as parseBooleanValue, t as readManifestNamespace } from "./legacy-names-
|
|
1
|
+
import { s as parseBooleanValue, t as readManifestNamespace } from "./legacy-names-CghFcfry.js";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
import JSON5 from "json5";
|
|
5
5
|
import YAML from "yaml";
|
|
6
6
|
|
|
@@ -92,7 +92,7 @@ function hasBinary(bin) {
|
|
|
92
92
|
for (const part of parts) for (const ext of extensions) {
|
|
93
93
|
const candidate = path.join(part, bin + ext);
|
|
94
94
|
try {
|
|
95
|
-
|
|
95
|
+
fs.accessSync(candidate, fs.constants.X_OK);
|
|
96
96
|
hasBinaryCache.set(bin, true);
|
|
97
97
|
return true;
|
|
98
98
|
} catch {}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { u as expandHomePrefix } from "./paths-
|
|
2
|
-
import { B as hasNodeErrorCode, H as isPathInside, I as sameFileIdentity, U as isSymlinkOpenError, V as isNotFoundPathError } from "./subsystem-
|
|
3
|
-
import { i as logWarn } from "./logger-
|
|
4
|
-
import { n as assertNoPathAliasEscape } from "./path-alias-guards-
|
|
1
|
+
import { u as expandHomePrefix } from "./paths-BIDPYPVC.js";
|
|
2
|
+
import { B as hasNodeErrorCode, H as isPathInside, I as sameFileIdentity, U as isSymlinkOpenError, V as isNotFoundPathError } from "./subsystem-BZy3aWdW.js";
|
|
3
|
+
import { i as logWarn } from "./logger-J4xjy-6D.js";
|
|
4
|
+
import { n as assertNoPathAliasEscape } from "./path-alias-guards-E9ntDORB.js";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { constants } from "node:fs";
|
|
7
7
|
import os from "node:os";
|
|
8
|
-
import fs from "node:fs/promises";
|
|
8
|
+
import fs$1 from "node:fs/promises";
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
10
|
import { pipeline } from "node:stream/promises";
|
|
11
11
|
|
|
@@ -25,19 +25,19 @@ const ensureTrailingSep = (value) => value.endsWith(path.sep) ? value : value +
|
|
|
25
25
|
async function expandRelativePathWithHome(relativePath) {
|
|
26
26
|
let home = process.env.HOME || process.env.USERPROFILE || os.homedir();
|
|
27
27
|
try {
|
|
28
|
-
home = await fs.realpath(home);
|
|
28
|
+
home = await fs$1.realpath(home);
|
|
29
29
|
} catch {}
|
|
30
30
|
return expandHomePrefix(relativePath, { home });
|
|
31
31
|
}
|
|
32
32
|
async function openVerifiedLocalFile(filePath, options) {
|
|
33
33
|
try {
|
|
34
|
-
if ((await fs.lstat(filePath)).isDirectory()) throw new SafeOpenError("not-file", "not a file");
|
|
34
|
+
if ((await fs$1.lstat(filePath)).isDirectory()) throw new SafeOpenError("not-file", "not a file");
|
|
35
35
|
} catch (err) {
|
|
36
36
|
if (err instanceof SafeOpenError) throw err;
|
|
37
37
|
}
|
|
38
38
|
let handle;
|
|
39
39
|
try {
|
|
40
|
-
handle = await fs.open(filePath, OPEN_READ_FLAGS);
|
|
40
|
+
handle = await fs$1.open(filePath, OPEN_READ_FLAGS);
|
|
41
41
|
} catch (err) {
|
|
42
42
|
if (isNotFoundPathError(err)) throw new SafeOpenError("not-found", "file not found");
|
|
43
43
|
if (isSymlinkOpenError(err)) throw new SafeOpenError("symlink", "symlink open blocked", { cause: err });
|
|
@@ -45,13 +45,13 @@ async function openVerifiedLocalFile(filePath, options) {
|
|
|
45
45
|
throw err;
|
|
46
46
|
}
|
|
47
47
|
try {
|
|
48
|
-
const [stat, lstat] = await Promise.all([handle.stat(), fs.lstat(filePath)]);
|
|
48
|
+
const [stat, lstat] = await Promise.all([handle.stat(), fs$1.lstat(filePath)]);
|
|
49
49
|
if (lstat.isSymbolicLink()) throw new SafeOpenError("symlink", "symlink not allowed");
|
|
50
50
|
if (!stat.isFile()) throw new SafeOpenError("not-file", "not a file");
|
|
51
51
|
if (options?.rejectHardlinks && stat.nlink > 1) throw new SafeOpenError("invalid-path", "hardlinked path not allowed");
|
|
52
52
|
if (!sameFileIdentity(stat, lstat)) throw new SafeOpenError("path-mismatch", "path changed during read");
|
|
53
|
-
const realPath = await fs.realpath(filePath);
|
|
54
|
-
const realStat = await fs.stat(realPath);
|
|
53
|
+
const realPath = await fs$1.realpath(filePath);
|
|
54
|
+
const realStat = await fs$1.stat(realPath);
|
|
55
55
|
if (options?.rejectHardlinks && realStat.nlink > 1) throw new SafeOpenError("invalid-path", "hardlinked path not allowed");
|
|
56
56
|
if (!sameFileIdentity(stat, realStat)) throw new SafeOpenError("path-mismatch", "path mismatch");
|
|
57
57
|
return {
|
|
@@ -69,7 +69,7 @@ async function openVerifiedLocalFile(filePath, options) {
|
|
|
69
69
|
async function resolvePathWithinRoot(params) {
|
|
70
70
|
let rootReal;
|
|
71
71
|
try {
|
|
72
|
-
rootReal = await fs.realpath(params.rootDir);
|
|
72
|
+
rootReal = await fs$1.realpath(params.rootDir);
|
|
73
73
|
} catch (err) {
|
|
74
74
|
if (isNotFoundPathError(err)) throw new SafeOpenError("not-found", "root dir not found");
|
|
75
75
|
throw err;
|
|
@@ -170,7 +170,7 @@ function buildAtomicWriteTempPath(targetPath) {
|
|
|
170
170
|
return path.join(dir, `.${base}.${process.pid}.${randomUUID()}.tmp`);
|
|
171
171
|
}
|
|
172
172
|
async function writeTempFileForAtomicReplace(params) {
|
|
173
|
-
const tempHandle = await fs.open(params.tempPath, OPEN_WRITE_CREATE_FLAGS, params.mode);
|
|
173
|
+
const tempHandle = await fs$1.open(params.tempPath, OPEN_WRITE_CREATE_FLAGS, params.mode);
|
|
174
174
|
try {
|
|
175
175
|
if (typeof params.data === "string") await tempHandle.writeFile(params.data, params.encoding ?? "utf8");
|
|
176
176
|
else await tempHandle.writeFile(params.data);
|
|
@@ -180,7 +180,7 @@ async function writeTempFileForAtomicReplace(params) {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
async function verifyAtomicWriteResult(params) {
|
|
183
|
-
const rootWithSep = ensureTrailingSep(await fs.realpath(params.rootDir));
|
|
183
|
+
const rootWithSep = ensureTrailingSep(await fs$1.realpath(params.rootDir));
|
|
184
184
|
const opened = await openVerifiedLocalFile(params.targetPath, { rejectHardlinks: true });
|
|
185
185
|
try {
|
|
186
186
|
if (!sameFileIdentity(opened.stat, params.expectedStat)) throw new SafeOpenError("path-mismatch", "path changed during write");
|
|
@@ -191,13 +191,13 @@ async function verifyAtomicWriteResult(params) {
|
|
|
191
191
|
}
|
|
192
192
|
async function resolveOpenedFileRealPathForHandle(handle, ioPath) {
|
|
193
193
|
try {
|
|
194
|
-
return await fs.realpath(ioPath);
|
|
194
|
+
return await fs$1.realpath(ioPath);
|
|
195
195
|
} catch (err) {
|
|
196
196
|
if (!isNotFoundPathError(err)) throw err;
|
|
197
197
|
}
|
|
198
198
|
const fdCandidates = process.platform === "linux" ? [`/proc/self/fd/${handle.fd}`, `/dev/fd/${handle.fd}`] : process.platform === "win32" ? [] : [`/dev/fd/${handle.fd}`];
|
|
199
199
|
for (const fdPath of fdCandidates) try {
|
|
200
|
-
return await fs.realpath(fdPath);
|
|
200
|
+
return await fs$1.realpath(fdPath);
|
|
201
201
|
} catch {}
|
|
202
202
|
throw new SafeOpenError("path-mismatch", "unable to resolve opened file path");
|
|
203
203
|
}
|
|
@@ -212,10 +212,10 @@ async function openWritableFileWithinRoot(params) {
|
|
|
212
212
|
} catch (err) {
|
|
213
213
|
throw new SafeOpenError("invalid-path", "path alias escape blocked", { cause: err });
|
|
214
214
|
}
|
|
215
|
-
if (params.mkdir !== false) await fs.mkdir(path.dirname(resolved), { recursive: true });
|
|
215
|
+
if (params.mkdir !== false) await fs$1.mkdir(path.dirname(resolved), { recursive: true });
|
|
216
216
|
let ioPath = resolved;
|
|
217
217
|
try {
|
|
218
|
-
const resolvedRealPath = await fs.realpath(resolved);
|
|
218
|
+
const resolvedRealPath = await fs$1.realpath(resolved);
|
|
219
219
|
if (!isPathInside(rootWithSep, resolvedRealPath)) throw new SafeOpenError("outside-workspace", "file is outside workspace root");
|
|
220
220
|
ioPath = resolvedRealPath;
|
|
221
221
|
} catch (err) {
|
|
@@ -227,10 +227,10 @@ async function openWritableFileWithinRoot(params) {
|
|
|
227
227
|
let createdForWrite = false;
|
|
228
228
|
try {
|
|
229
229
|
try {
|
|
230
|
-
handle = await fs.open(ioPath, OPEN_WRITE_EXISTING_FLAGS, fileMode);
|
|
230
|
+
handle = await fs$1.open(ioPath, OPEN_WRITE_EXISTING_FLAGS, fileMode);
|
|
231
231
|
} catch (err) {
|
|
232
232
|
if (!isNotFoundPathError(err)) throw err;
|
|
233
|
-
handle = await fs.open(ioPath, OPEN_WRITE_CREATE_FLAGS, fileMode);
|
|
233
|
+
handle = await fs$1.open(ioPath, OPEN_WRITE_CREATE_FLAGS, fileMode);
|
|
234
234
|
createdForWrite = true;
|
|
235
235
|
}
|
|
236
236
|
} catch (err) {
|
|
@@ -244,7 +244,7 @@ async function openWritableFileWithinRoot(params) {
|
|
|
244
244
|
if (!stat.isFile()) throw new SafeOpenError("invalid-path", "path is not a regular file under root");
|
|
245
245
|
if (stat.nlink > 1) throw new SafeOpenError("invalid-path", "hardlinked path not allowed");
|
|
246
246
|
try {
|
|
247
|
-
const lstat = await fs.lstat(ioPath);
|
|
247
|
+
const lstat = await fs$1.lstat(ioPath);
|
|
248
248
|
if (lstat.isSymbolicLink() || !lstat.isFile()) throw new SafeOpenError("invalid-path", "path is not a regular file under root");
|
|
249
249
|
if (!sameFileIdentity(stat, lstat)) throw new SafeOpenError("path-mismatch", "path changed during write");
|
|
250
250
|
} catch (err) {
|
|
@@ -252,7 +252,7 @@ async function openWritableFileWithinRoot(params) {
|
|
|
252
252
|
}
|
|
253
253
|
const realPath = await resolveOpenedFileRealPathForHandle(handle, ioPath);
|
|
254
254
|
openedRealPath = realPath;
|
|
255
|
-
const realStat = await fs.stat(realPath);
|
|
255
|
+
const realStat = await fs$1.stat(realPath);
|
|
256
256
|
if (!sameFileIdentity(stat, realStat)) throw new SafeOpenError("path-mismatch", "path mismatch");
|
|
257
257
|
if (realStat.nlink > 1) throw new SafeOpenError("invalid-path", "hardlinked path not allowed");
|
|
258
258
|
if (!isPathInside(rootWithSep, realPath)) throw new SafeOpenError("outside-workspace", "file is outside workspace root");
|
|
@@ -267,7 +267,7 @@ async function openWritableFileWithinRoot(params) {
|
|
|
267
267
|
const cleanupCreatedPath = createdForWrite && err instanceof SafeOpenError;
|
|
268
268
|
const cleanupPath = openedRealPath ?? ioPath;
|
|
269
269
|
await handle.close().catch(() => {});
|
|
270
|
-
if (cleanupCreatedPath) await fs.rm(cleanupPath, { force: true }).catch(() => {});
|
|
270
|
+
if (cleanupCreatedPath) await fs$1.rm(cleanupPath, { force: true }).catch(() => {});
|
|
271
271
|
throw err;
|
|
272
272
|
}
|
|
273
273
|
}
|
|
@@ -290,7 +290,7 @@ async function writeFileWithinRoot(params) {
|
|
|
290
290
|
encoding: params.encoding,
|
|
291
291
|
mode: targetMode || 384
|
|
292
292
|
});
|
|
293
|
-
await fs.rename(tempPath, destinationPath);
|
|
293
|
+
await fs$1.rename(tempPath, destinationPath);
|
|
294
294
|
tempPath = null;
|
|
295
295
|
try {
|
|
296
296
|
await verifyAtomicWriteResult({
|
|
@@ -303,7 +303,7 @@ async function writeFileWithinRoot(params) {
|
|
|
303
303
|
throw err;
|
|
304
304
|
}
|
|
305
305
|
} finally {
|
|
306
|
-
if (tempPath) await fs.rm(tempPath, { force: true }).catch(() => {});
|
|
306
|
+
if (tempPath) await fs$1.rm(tempPath, { force: true }).catch(() => {});
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
async function copyFileWithinRoot(params) {
|
|
@@ -331,7 +331,7 @@ async function copyFileWithinRoot(params) {
|
|
|
331
331
|
});
|
|
332
332
|
await pipeline(sourceStream, targetStream);
|
|
333
333
|
} catch (err) {
|
|
334
|
-
if (target?.createdForWrite) await fs.rm(target.openedRealPath, { force: true }).catch(() => {});
|
|
334
|
+
if (target?.createdForWrite) await fs$1.rm(target.openedRealPath, { force: true }).catch(() => {});
|
|
335
335
|
throw err;
|
|
336
336
|
} finally {
|
|
337
337
|
if (!sourceClosedByStream) await source.handle.close().catch(() => {});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
|
|
2
|
+
import { l as resolveStateDir } from "./paths-BIDPYPVC.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
|
|
6
|
+
//#region src/infra/json-file.ts
|
|
7
|
+
function loadJsonFile(pathname) {
|
|
8
|
+
try {
|
|
9
|
+
if (!fs.existsSync(pathname)) return;
|
|
10
|
+
const raw = fs.readFileSync(pathname, "utf8");
|
|
11
|
+
return JSON.parse(raw);
|
|
12
|
+
} catch {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function saveJsonFile(pathname, data) {
|
|
17
|
+
const dir = path.dirname(pathname);
|
|
18
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, {
|
|
19
|
+
recursive: true,
|
|
20
|
+
mode: 448
|
|
21
|
+
});
|
|
22
|
+
fs.writeFileSync(pathname, `${JSON.stringify(data, null, 2)}\n`, "utf8");
|
|
23
|
+
fs.chmodSync(pathname, 384);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/providers/github-copilot-token.ts
|
|
28
|
+
var github_copilot_token_exports = /* @__PURE__ */ __exportAll({
|
|
29
|
+
DEFAULT_COPILOT_API_BASE_URL: () => DEFAULT_COPILOT_API_BASE_URL,
|
|
30
|
+
deriveCopilotApiBaseUrlFromToken: () => deriveCopilotApiBaseUrlFromToken,
|
|
31
|
+
resolveCopilotApiToken: () => resolveCopilotApiToken
|
|
32
|
+
});
|
|
33
|
+
const COPILOT_TOKEN_URL = "https://api.github.com/copilot_internal/v2/token";
|
|
34
|
+
function resolveCopilotTokenCachePath(env = process.env) {
|
|
35
|
+
return path.join(resolveStateDir(env), "credentials", "github-copilot.token.json");
|
|
36
|
+
}
|
|
37
|
+
function isTokenUsable(cache, now = Date.now()) {
|
|
38
|
+
return cache.expiresAt - now > 300 * 1e3;
|
|
39
|
+
}
|
|
40
|
+
function parseCopilotTokenResponse(value) {
|
|
41
|
+
if (!value || typeof value !== "object") throw new Error("Unexpected response from GitHub Copilot token endpoint");
|
|
42
|
+
const asRecord = value;
|
|
43
|
+
const token = asRecord.token;
|
|
44
|
+
const expiresAt = asRecord.expires_at;
|
|
45
|
+
if (typeof token !== "string" || token.trim().length === 0) throw new Error("Copilot token response missing token");
|
|
46
|
+
let expiresAtMs;
|
|
47
|
+
if (typeof expiresAt === "number" && Number.isFinite(expiresAt)) expiresAtMs = expiresAt > 1e10 ? expiresAt : expiresAt * 1e3;
|
|
48
|
+
else if (typeof expiresAt === "string" && expiresAt.trim().length > 0) {
|
|
49
|
+
const parsed = Number.parseInt(expiresAt, 10);
|
|
50
|
+
if (!Number.isFinite(parsed)) throw new Error("Copilot token response has invalid expires_at");
|
|
51
|
+
expiresAtMs = parsed > 1e10 ? parsed : parsed * 1e3;
|
|
52
|
+
} else throw new Error("Copilot token response missing expires_at");
|
|
53
|
+
return {
|
|
54
|
+
token,
|
|
55
|
+
expiresAt: expiresAtMs
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const DEFAULT_COPILOT_API_BASE_URL = "https://api.individual.githubcopilot.com";
|
|
59
|
+
function deriveCopilotApiBaseUrlFromToken(token) {
|
|
60
|
+
const trimmed = token.trim();
|
|
61
|
+
if (!trimmed) return null;
|
|
62
|
+
const proxyEp = trimmed.match(/(?:^|;)\s*proxy-ep=([^;\s]+)/i)?.[1]?.trim();
|
|
63
|
+
if (!proxyEp) return null;
|
|
64
|
+
const host = proxyEp.replace(/^https?:\/\//, "").replace(/^proxy\./i, "api.");
|
|
65
|
+
if (!host) return null;
|
|
66
|
+
return `https://${host}`;
|
|
67
|
+
}
|
|
68
|
+
async function resolveCopilotApiToken(params) {
|
|
69
|
+
const env = params.env ?? process.env;
|
|
70
|
+
const cachePath = params.cachePath?.trim() || resolveCopilotTokenCachePath(env);
|
|
71
|
+
const loadJsonFileFn = params.loadJsonFileImpl ?? loadJsonFile;
|
|
72
|
+
const saveJsonFileFn = params.saveJsonFileImpl ?? saveJsonFile;
|
|
73
|
+
const cached = loadJsonFileFn(cachePath);
|
|
74
|
+
if (cached && typeof cached.token === "string" && typeof cached.expiresAt === "number") {
|
|
75
|
+
if (isTokenUsable(cached)) return {
|
|
76
|
+
token: cached.token,
|
|
77
|
+
expiresAt: cached.expiresAt,
|
|
78
|
+
source: `cache:${cachePath}`,
|
|
79
|
+
baseUrl: deriveCopilotApiBaseUrlFromToken(cached.token) ?? DEFAULT_COPILOT_API_BASE_URL
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const res = await (params.fetchImpl ?? fetch)(COPILOT_TOKEN_URL, {
|
|
83
|
+
method: "GET",
|
|
84
|
+
headers: {
|
|
85
|
+
Accept: "application/json",
|
|
86
|
+
Authorization: `Bearer ${params.githubToken}`
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
if (!res.ok) throw new Error(`Copilot token exchange failed: HTTP ${res.status}`);
|
|
90
|
+
const json = parseCopilotTokenResponse(await res.json());
|
|
91
|
+
const payload = {
|
|
92
|
+
token: json.token,
|
|
93
|
+
expiresAt: json.expiresAt,
|
|
94
|
+
updatedAt: Date.now()
|
|
95
|
+
};
|
|
96
|
+
saveJsonFileFn(cachePath, payload);
|
|
97
|
+
return {
|
|
98
|
+
token: payload.token,
|
|
99
|
+
expiresAt: payload.expiresAt,
|
|
100
|
+
source: `fetched:${COPILOT_TOKEN_URL}`,
|
|
101
|
+
baseUrl: deriveCopilotApiBaseUrlFromToken(payload.token) ?? DEFAULT_COPILOT_API_BASE_URL
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
export { saveJsonFile as a, loadJsonFile as i, github_copilot_token_exports as n, resolveCopilotApiToken as r, DEFAULT_COPILOT_API_BASE_URL as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { f as logVerbose, h as shouldLogVerbose, st as resolveUserPath } from "./subsystem-
|
|
2
|
-
import { _ as maxBytesForKind, a as hasAlphaChannel, c as detectMime, l as extensionForMime, m as kindFromMime, o as optimizeImageToPng, r as convertHeicToJpeg, s as resizeToJpeg } from "./image-ops-
|
|
3
|
-
import { o as readLocalFileSafely, t as SafeOpenError } from "./fs-safe-
|
|
4
|
-
import { a as getDefaultMediaLocalRoots, n as fetchRemoteMedia } from "./fetch-
|
|
5
|
-
import { a as chunkText } from "./chunk-
|
|
1
|
+
import { f as logVerbose, h as shouldLogVerbose, st as resolveUserPath } from "./subsystem-BZy3aWdW.js";
|
|
2
|
+
import { _ as maxBytesForKind, a as hasAlphaChannel, c as detectMime, l as extensionForMime, m as kindFromMime, o as optimizeImageToPng, r as convertHeicToJpeg, s as resizeToJpeg } from "./image-ops-C-5VgbLB.js";
|
|
3
|
+
import { o as readLocalFileSafely, t as SafeOpenError } from "./fs-safe-BK5ALzKD.js";
|
|
4
|
+
import { a as getDefaultMediaLocalRoots, n as fetchRemoteMedia } from "./fetch-B1ohBh6A.js";
|
|
5
|
+
import { a as chunkText } from "./chunk-CEygNI3g.js";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import fs from "node:fs/promises";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|