@xiaoso/dsh-tool-plus 0.1.0-beta.5 → 0.1.0-beta.7
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/README.en.md +1 -1
- package/README.md +2 -2
- package/THIRD_PARTY_NOTICES.md +42 -42
- package/lib/{abort-dIkZBV7Q.mjs → abort-CsjZitYv.mjs} +1 -1
- package/lib/{amazon-bedrock-WQhvjHYu.mjs → amazon-bedrock-CfNIDi5k.mjs} +7 -7
- package/lib/{anthropic-CJCauvYz.mjs → anthropic-BVfZdnMp.mjs} +12 -12
- package/lib/{anthropic-tTntD8BD.mjs → anthropic-DGXmmg43.mjs} +2 -2
- package/lib/{api-key-login-BzqNdM2y.mjs → api-key-login-BikQAfD-.mjs} +1 -1
- package/lib/{aws-credentials-CXryMobh.mjs → aws-credentials-DrssNMn_.mjs} +4 -4
- package/lib/{azure-openai-responses-DuukbD0F.mjs → azure-openai-responses-C-5q-5K2.mjs} +8 -8
- package/lib/browser-render-z6b8Ljo9.mjs +183 -0
- package/lib/{bundled-references-Cavaffah.mjs → bundled-references-D71z7_T3.mjs} +2 -2
- package/lib/{callback-server-CQ5Jo8F-.mjs → callback-server-Di6C4RqI.mjs} +1 -1
- package/lib/client.js +613 -107
- package/lib/{cursor-B6TUEmgP.mjs → cursor-CQQtygwl.mjs} +1 -1
- package/lib/{cursor-DkSX2h3H.mjs → cursor-DXJxwdcg.mjs} +7 -7
- package/lib/{cursor-aJrXeYCb.mjs → cursor-Hr5Zw1gt.mjs} +3 -3
- package/lib/{device-code-DBo3B5nh.mjs → device-code-wZUbgPdB.mjs} +1 -1
- package/lib/{devin-BHZZyMhO.mjs → devin-CF6UhCFw.mjs} +2 -2
- package/lib/{devin-BK7DHeca.mjs → devin-DXJoDlW2.mjs} +1 -1
- package/lib/{devin-vNZTNUON.mjs → devin-P37gURs_.mjs} +5 -5
- package/lib/{dom-DGdYAVTv.mjs → dom-CawWi8fa.mjs} +14 -1
- package/lib/{error-Dd8DIqs-.mjs → error-DoHuatWw.mjs} +1 -1
- package/lib/{event-stream-BbFZJy-z.mjs → event-stream-C-FmBYUt.mjs} +1 -1
- package/lib/{github-copilot-CYkjeTi3.mjs → github-copilot-C2dTonBX.mjs} +3 -3
- package/lib/{github-copilot-B1yiyVRh.mjs → github-copilot-qETlj_bD.mjs} +1 -1
- package/lib/{gitlab-duo-CM7Ref1H.mjs → gitlab-duo-FQZiFRQe.mjs} +3 -3
- package/lib/{gitlab-duo-workflow-BGAF6JDw.mjs → gitlab-duo-workflow-DLTabzOy.mjs} +2 -2
- package/lib/{google-BS4T25Pn.mjs → google-BilwFSzx.mjs} +3 -3
- package/lib/{google-antigravity-DGmwC2KV.mjs → google-antigravity-BfBiINdu.mjs} +2 -2
- package/lib/{google-auth-B6gjsZvg.mjs → google-auth-CWlKXJ-H.mjs} +3 -3
- package/lib/{google-gemini-cli-Dsztq0N5.mjs → google-gemini-cli-CB89ljNz.mjs} +3 -3
- package/lib/{google-gemini-cli-Cqds_Q5T.mjs → google-gemini-cli-CygFcR6N.mjs} +8 -8
- package/lib/{google-oauth-shared-CuEHaDDj.mjs → google-oauth-shared-Cn82h1o2.mjs} +2 -2
- package/lib/{google-shared-Dr-VG-ap.mjs → google-shared-CF1JrqTM.mjs} +6 -6
- package/lib/{google-vertex-BDN2tLaD.mjs → google-vertex-DgMhhFw8.mjs} +5 -5
- package/lib/{identity-Da1GPU9a.mjs → identity-C0SPVyIZ.mjs} +1 -1
- package/lib/{idle-iterator-DUjKQEGT.mjs → idle-iterator-HzbbfXP4.mjs} +2 -2
- package/lib/index.mjs +310 -29
- package/lib/{kimi-Dh0pv3WZ.mjs → kimi-DHDO6Fde.mjs} +3 -3
- package/lib/launch-DwpE70Pv.mjs +148 -0
- package/lib/{markit-BL3cH47U.mjs → markit-B9exZ0ZV.mjs} +1 -1
- package/lib/{minimax-code-Uq8Qu9LW.mjs → minimax-code-vAhEXhev.mjs} +1 -1
- package/lib/{models-SGASygJ3.mjs → models-Cp3PzU3l.mjs} +1 -1
- package/lib/{ollama-DPzBmq89.mjs → ollama-TrkXTNqE.mjs} +8 -8
- package/lib/{openai-codex-Ch8CkT3p.mjs → openai-codex-CrjHtSH4.mjs} +3 -3
- package/lib/{openai-codex-responses-pejZgdZo.mjs → openai-codex-responses-C4uMpWNy.mjs} +10 -10
- package/lib/{openai-completions-DIf361kF.mjs → openai-completions-1ydXm5vF.mjs} +13 -13
- package/lib/{openai-reasoning-fallback-Nj6yB2rY.mjs → openai-reasoning-fallback-CigKCyzc.mjs} +2 -2
- package/lib/{openai-responses-Db_a-U4-.mjs → openai-responses-CN79gRGQ.mjs} +10 -10
- package/lib/{opencode-Rq_Q2vAO.mjs → opencode-CEGlimzL.mjs} +1 -1
- package/lib/{perplexity-C4iLVMUj.mjs → perplexity-BLJN-8dM.mjs} +2 -2
- package/lib/{proxy-pM_NIv-H.mjs → proxy-XOYi58TM.mjs} +1 -1
- package/lib/readability-Cpm-ocau.mjs +455 -0
- package/lib/{scrapers-1FTlHNQV.mjs → scrapers-DrSYgPyf.mjs} +11 -10
- package/lib/{src-BgpusnsB.mjs → src-D_e1qMwi.mjs} +5 -1
- package/lib/{stream-CRtexYLe.mjs → stream-DveNFWSN.mjs} +56 -56
- package/lib/{stream-markup-healing-KMkiAA00.mjs → stream-markup-healing-C9eC7Gf8.mjs} +3 -3
- package/lib/tool-errors-DoyxivAR.mjs +47 -0
- package/lib/types-BUO0JXO-.mjs +251 -0
- package/lib/{utils-D2YknRk4.mjs → utils-B-mTYQBc.mjs} +1 -1
- package/lib/{utils-C616y7eF.mjs → utils-DSEEKy3G.mjs} +28 -268
- package/lib/{utils-Cp76gCyk.mjs → utils-fnV2zzp3.mjs} +3 -3
- package/lib/{vision-guard-01qSwFpf.mjs → vision-guard-BsvOWmfB.mjs} +2 -2
- package/lib/{wafer-CgtPHerf.mjs → wafer-Dpy7tL3l.mjs} +1 -1
- package/lib/{xai-oauth-Buk8XVvM.mjs → xai-oauth-BkPNQS-q.mjs} +2 -2
- package/lib/{xiaomi-D2qT5cAC.mjs → xiaomi-CG3TsYRz.mjs} +1 -1
- package/lib/{zai-C59YnomG.mjs → zai--cewobzN.mjs} +2 -2
- package/lib/{zip-Cg9ANN_U.mjs → zip-CqKW2-TK.mjs} +3 -46
- package/package.json +3 -1
- package/presets/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
import { c as OAuthError, h as LoginCancelledError } from "./error-
|
|
4
|
-
import "./utils-
|
|
3
|
+
import { c as OAuthError, h as LoginCancelledError } from "./error-DoHuatWw.mjs";
|
|
4
|
+
import "./utils-fnV2zzp3.mjs";
|
|
5
5
|
import { n as isRecord } from "./type-guards-B9VVjRDK.mjs";
|
|
6
|
-
import { t as OAuthCallbackFlow } from "./callback-server-
|
|
6
|
+
import { t as OAuthCallbackFlow } from "./callback-server-Di6C4RqI.mjs";
|
|
7
7
|
import { t as generatePKCE } from "./pkce-BlQikGPu.mjs";
|
|
8
8
|
import { i as OPENAI_HEADER_VALUES } from "./codex-P1dGpX7G.mjs";
|
|
9
9
|
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/openai-codex.ts
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
3
|
import { r as __exportAll } from "./fs-promises-shim-Bx0fpxuk.mjs";
|
|
4
|
-
import { B as USER_AGENT, C as error, I as $flag, P as $env, S as debug, g as parseStreamingJson, o as readSseJson, q as getInstallId, t as structuredCloneJSON, w as time } from "./src-
|
|
5
|
-
import { G as fetchWithRetry, V as ProviderHttpError, g as MissingApiKeyError, l as finalize, v as AbortError } from "./error-
|
|
6
|
-
import { A as NO_STRICT, C as kStreamingPartialJson, L as sanitizeSchemaForOpenAIResponses, a as normalizeSystemPrompts, c as sanitizeOpenAIResponsesAssistantFallbackItemsForReplay, d as stripOpenAIResponsesComputerLinkedReasoningIdsForReplay, h as clearStreamingPartialJson, j as adaptSchemaForStrict, k as toolWireSchema, l as sanitizeOpenAIResponsesAssistantHistoryItemsForReplay, m as transformMessages, n as getOpenAIResponsesHistoryItems, p as redactSensitiveInObject, r as getOpenAIResponsesHistoryPayload, t as createOpenAIResponsesHistoryPayload } from "./utils-
|
|
4
|
+
import { B as USER_AGENT, C as error, I as $flag, P as $env, S as debug, g as parseStreamingJson, o as readSseJson, q as getInstallId, t as structuredCloneJSON, w as time } from "./src-D_e1qMwi.mjs";
|
|
5
|
+
import { G as fetchWithRetry, V as ProviderHttpError, g as MissingApiKeyError, l as finalize, v as AbortError } from "./error-DoHuatWw.mjs";
|
|
6
|
+
import { A as NO_STRICT, C as kStreamingPartialJson, L as sanitizeSchemaForOpenAIResponses, a as normalizeSystemPrompts, c as sanitizeOpenAIResponsesAssistantFallbackItemsForReplay, d as stripOpenAIResponsesComputerLinkedReasoningIdsForReplay, h as clearStreamingPartialJson, j as adaptSchemaForStrict, k as toolWireSchema, l as sanitizeOpenAIResponsesAssistantHistoryItemsForReplay, m as transformMessages, n as getOpenAIResponsesHistoryItems, p as redactSensitiveInObject, r as getOpenAIResponsesHistoryPayload, t as createOpenAIResponsesHistoryPayload } from "./utils-fnV2zzp3.mjs";
|
|
7
7
|
import { t as asRecord } from "./type-guards-B9VVjRDK.mjs";
|
|
8
|
-
import { A as computerCallMetadata, B as finalizeCustomToolCallInputDone, E as buildResponsesDeltaInput, F as createSequentialCutoffSummaryState, H as finalizePendingResponsesToolCalls, K as getOpenAIPromptCacheKey, L as encodeResponsesToolCallId, M as convertResponsesInputContent, Q as isOpenAIResponsesProgressEvent, R as encodeTextSignatureV1, U as finalizeReasoningThinking, V as finalizeMessageText, W as finalizeToolCallArgumentsDone, X as hasExecutableIncompleteResponsesToolCalls, a as accumulateCustomToolCallInputDelta, at as populateResponsesUsageFromResponse, bt as escapeHarmonyControlTokens, c as appendMessageTextDelta, d as appendReasoningSummaryTextDelta, f as appendResponsesImageResult, j as convertResponsesAssistantMessage, l as appendReasoningSummaryPart, n as getEnvApiKey, nt as mapOpenAIResponsesStopReason, o as accumulateToolCallArgumentsDelta, p as appendResponsesToolResultMessages, r as isOfficialCodexApiUrl, rt as normalizeOpenAIPromptCacheKey, s as appendMessageContentPart, st as promoteResponsesToolUseStopReason, tt as mapOpenAIReasoningEffort, u as appendReasoningSummaryPartDone, x as applyReasoningSummaryDone, xt as isHarmonyDialectModel, y as applyOpenAIServiceTier, z as escapeReplayedControlTokens } from "./stream-
|
|
9
|
-
import { r as getProxyForUrl } from "./proxy-
|
|
10
|
-
import { E as supportsCodexReasoningSummary, T as supportsAllTurnsReasoningContext, s as requireSupportedEffort, t as calculateCost } from "./models-
|
|
11
|
-
import { a as toNumber } from "./utils-
|
|
12
|
-
import "./identity-
|
|
13
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
8
|
+
import { A as computerCallMetadata, B as finalizeCustomToolCallInputDone, E as buildResponsesDeltaInput, F as createSequentialCutoffSummaryState, H as finalizePendingResponsesToolCalls, K as getOpenAIPromptCacheKey, L as encodeResponsesToolCallId, M as convertResponsesInputContent, Q as isOpenAIResponsesProgressEvent, R as encodeTextSignatureV1, U as finalizeReasoningThinking, V as finalizeMessageText, W as finalizeToolCallArgumentsDone, X as hasExecutableIncompleteResponsesToolCalls, a as accumulateCustomToolCallInputDelta, at as populateResponsesUsageFromResponse, bt as escapeHarmonyControlTokens, c as appendMessageTextDelta, d as appendReasoningSummaryTextDelta, f as appendResponsesImageResult, j as convertResponsesAssistantMessage, l as appendReasoningSummaryPart, n as getEnvApiKey, nt as mapOpenAIResponsesStopReason, o as accumulateToolCallArgumentsDelta, p as appendResponsesToolResultMessages, r as isOfficialCodexApiUrl, rt as normalizeOpenAIPromptCacheKey, s as appendMessageContentPart, st as promoteResponsesToolUseStopReason, tt as mapOpenAIReasoningEffort, u as appendReasoningSummaryPartDone, x as applyReasoningSummaryDone, xt as isHarmonyDialectModel, y as applyOpenAIServiceTier, z as escapeReplayedControlTokens } from "./stream-DveNFWSN.mjs";
|
|
9
|
+
import { r as getProxyForUrl } from "./proxy-XOYi58TM.mjs";
|
|
10
|
+
import { E as supportsCodexReasoningSummary, T as supportsAllTurnsReasoningContext, s as requireSupportedEffort, t as calculateCost } from "./models-Cp3PzU3l.mjs";
|
|
11
|
+
import { a as toNumber } from "./utils-B-mTYQBc.mjs";
|
|
12
|
+
import "./identity-C0SPVyIZ.mjs";
|
|
13
|
+
import { t as AssistantMessageEventStream } from "./event-stream-C-FmBYUt.mjs";
|
|
14
14
|
import { a as getCodexAccountId, i as OPENAI_HEADER_VALUES, n as CODEX_CLIENT_VERSION, r as OPENAI_HEADERS, t as CODEX_BASE_URL } from "./codex-P1dGpX7G.mjs";
|
|
15
|
-
import { n as getOpenAIStreamFirstEventTimeoutMs, o as iterateWithIdleTimeout, r as getOpenAIStreamIdleTimeoutMs, t as armPreResponseTimeout } from "./idle-iterator-
|
|
15
|
+
import { n as getOpenAIStreamFirstEventTimeoutMs, o as iterateWithIdleTimeout, r as getOpenAIStreamIdleTimeoutMs, t as armPreResponseTimeout } from "./idle-iterator-HzbbfXP4.mjs";
|
|
16
16
|
import { n as isRequestDebugEnabled, t as createRequestDebugSession } from "./request-debug-HJMoJncL.mjs";
|
|
17
17
|
import { t as notifyRawSseEvent } from "./sse-debug-CYdjOC96.mjs";
|
|
18
18
|
import { t as compactGrammarDefinition } from "./grammar-D-NqNUxQ.mjs";
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
3
|
import { r as __exportAll } from "./fs-promises-shim-Bx0fpxuk.mjs";
|
|
4
|
-
import { P as $env, T as warn, _ as parseStreamingJsonThrottled, g as parseStreamingJson } from "./src-
|
|
5
|
-
import { B as OpenAIHttpError, d as callWithCopilotModelRetry, l as finalize, n as StreamTimeoutError, s as ProviderResponseError, t as ConfigurationError, v as AbortError } from "./error-
|
|
6
|
-
import { A as NO_STRICT, F as sanitizeSchemaForGrammar, O as flattenExclusiveRequiredRootUnion, P as normalizeSchemaForMoonshot, S as kStreamingLastParseLen, a as normalizeSystemPrompts, g as isDemotedThinking, j as adaptSchemaForStrict, k as toolWireSchema, m as transformMessages, s as resolveCacheRetention, w as renderDemotedThinking } from "./utils-
|
|
7
|
-
import { $ as isOpenRouterAnthropicModel, Ct as withEmptyCompletionRetry, I as disableStrictToolsForScope, J as getOpenAIStrictToolsScope, K as getOpenAIPromptCacheKey, N as createInitialResponsesAssistantMessage, O as calculateOpenAIUsageAccounting, P as createOpenAIStrictToolsState, St as hasVisibleAssistantContent, T as applyWireModelIdTransform, Z as isCompiledGrammarTooLargeStrictError, _ as applyOpenAIExtraBody, _t as isForcedToolChoice, b as applyOpenRouterReportedCost, ct as resolveOpenAICompatPolicy, dt as resolveOpenAIRequestSetup, et as isStrictToolsDisabledForScope, h as applyChatCompletionsToolStream, it as parseAzureDeploymentNameMap, k as clearOpenAIStrictToolsState, lt as resolveOpenAICompletionsOutputClamp, m as applyChatCompletionsCompatPolicy, n as getEnvApiKey, pt as shouldRetryWithoutStrictTools, ut as resolveOpenAIOutputTokenParam, v as applyOpenAIGatewayRouting, vt as mapToOpenAICompletionsToolChoice, y as applyOpenAIServiceTier } from "./stream-
|
|
8
|
-
import { t as createAbortSourceTracker } from "./abort-
|
|
9
|
-
import { b as isKimiModelId, c as resolveWireModelId, t as calculateCost } from "./models-
|
|
10
|
-
import "./identity-
|
|
11
|
-
import { n as isDashscopeCompatibleModeTextOnlyQwen, r as joinTextWithImagePlaceholder, t as NON_VISION_IMAGE_PLACEHOLDER } from "./vision-guard-
|
|
4
|
+
import { P as $env, T as warn, _ as parseStreamingJsonThrottled, g as parseStreamingJson } from "./src-D_e1qMwi.mjs";
|
|
5
|
+
import { B as OpenAIHttpError, d as callWithCopilotModelRetry, l as finalize, n as StreamTimeoutError, s as ProviderResponseError, t as ConfigurationError, v as AbortError } from "./error-DoHuatWw.mjs";
|
|
6
|
+
import { A as NO_STRICT, F as sanitizeSchemaForGrammar, O as flattenExclusiveRequiredRootUnion, P as normalizeSchemaForMoonshot, S as kStreamingLastParseLen, a as normalizeSystemPrompts, g as isDemotedThinking, j as adaptSchemaForStrict, k as toolWireSchema, m as transformMessages, s as resolveCacheRetention, w as renderDemotedThinking } from "./utils-fnV2zzp3.mjs";
|
|
7
|
+
import { $ as isOpenRouterAnthropicModel, Ct as withEmptyCompletionRetry, I as disableStrictToolsForScope, J as getOpenAIStrictToolsScope, K as getOpenAIPromptCacheKey, N as createInitialResponsesAssistantMessage, O as calculateOpenAIUsageAccounting, P as createOpenAIStrictToolsState, St as hasVisibleAssistantContent, T as applyWireModelIdTransform, Z as isCompiledGrammarTooLargeStrictError, _ as applyOpenAIExtraBody, _t as isForcedToolChoice, b as applyOpenRouterReportedCost, ct as resolveOpenAICompatPolicy, dt as resolveOpenAIRequestSetup, et as isStrictToolsDisabledForScope, h as applyChatCompletionsToolStream, it as parseAzureDeploymentNameMap, k as clearOpenAIStrictToolsState, lt as resolveOpenAICompletionsOutputClamp, m as applyChatCompletionsCompatPolicy, n as getEnvApiKey, pt as shouldRetryWithoutStrictTools, ut as resolveOpenAIOutputTokenParam, v as applyOpenAIGatewayRouting, vt as mapToOpenAICompletionsToolChoice, y as applyOpenAIServiceTier } from "./stream-DveNFWSN.mjs";
|
|
8
|
+
import { t as createAbortSourceTracker } from "./abort-CsjZitYv.mjs";
|
|
9
|
+
import { b as isKimiModelId, c as resolveWireModelId, t as calculateCost } from "./models-Cp3PzU3l.mjs";
|
|
10
|
+
import "./identity-C0SPVyIZ.mjs";
|
|
11
|
+
import { n as isDashscopeCompatibleModeTextOnlyQwen, r as joinTextWithImagePlaceholder, t as NON_VISION_IMAGE_PLACEHOLDER } from "./vision-guard-BsvOWmfB.mjs";
|
|
12
12
|
import { t as findStrictToolSchemaViolation } from "./strict-tool-validation-imVLUcbI.mjs";
|
|
13
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
14
|
-
import { n as getOpenAIStreamFirstEventTimeoutMs, o as iterateWithIdleTimeout, r as getOpenAIStreamIdleTimeoutMs, s as iterateWithTerminalGrace } from "./idle-iterator-
|
|
15
|
-
import { t as getKimiCommonHeaders } from "./kimi-
|
|
13
|
+
import { t as AssistantMessageEventStream } from "./event-stream-C-FmBYUt.mjs";
|
|
14
|
+
import { n as getOpenAIStreamFirstEventTimeoutMs, o as iterateWithIdleTimeout, r as getOpenAIStreamIdleTimeoutMs, s as iterateWithTerminalGrace } from "./idle-iterator-HzbbfXP4.mjs";
|
|
15
|
+
import { t as getKimiCommonHeaders } from "./kimi-DHDO6Fde.mjs";
|
|
16
16
|
import { t as notifyProviderResponse } from "./provider-response-C6vcbQyO.mjs";
|
|
17
|
-
import { t as StreamMarkupHealing } from "./stream-markup-healing-
|
|
18
|
-
import { a as getOpenAIReasoningEffortFallback, c as postOpenAIStream, i as createOpenAIReasoningEffortFallbackState, n as clearOpenAIReasoningEffortFallbackState, o as rememberOpenAIReasoningEffortFallback, r as createOpenAIReasoningEffortFallbackKey, s as resolveOpenAIReasoningEffortFallback, t as applyOpenAIReasoningEffortFallback } from "./openai-reasoning-fallback-
|
|
17
|
+
import { t as StreamMarkupHealing } from "./stream-markup-healing-C9eC7Gf8.mjs";
|
|
18
|
+
import { a as getOpenAIReasoningEffortFallback, c as postOpenAIStream, i as createOpenAIReasoningEffortFallbackState, n as clearOpenAIReasoningEffortFallbackState, o as rememberOpenAIReasoningEffortFallback, r as createOpenAIReasoningEffortFallbackKey, s as resolveOpenAIReasoningEffortFallback, t as applyOpenAIReasoningEffortFallback } from "./openai-reasoning-fallback-CigKCyzc.mjs";
|
|
19
19
|
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/providers/openai-completions.ts
|
|
20
20
|
var openai_completions_exports = /* @__PURE__ */ __exportAll({
|
|
21
21
|
convertMessages: () => convertMessages,
|
package/lib/{openai-reasoning-fallback-Nj6yB2rY.mjs → openai-reasoning-fallback-CigKCyzc.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
import { o as readSseJson } from "./src-
|
|
4
|
-
import { B as OpenAIHttpError, G as fetchWithRetry, W as extractHttpStatusFromError, s as ProviderResponseError } from "./error-
|
|
3
|
+
import { o as readSseJson } from "./src-D_e1qMwi.mjs";
|
|
4
|
+
import { B as OpenAIHttpError, G as fetchWithRetry, W as extractHttpStatusFromError, s as ProviderResponseError } from "./error-DoHuatWw.mjs";
|
|
5
5
|
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/openai-http.ts
|
|
6
6
|
/**
|
|
7
7
|
* JSON-POST → SSE transport for OpenAI-wire streaming endpoints (chat
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
3
|
import { r as __exportAll } from "./fs-promises-shim-Bx0fpxuk.mjs";
|
|
4
|
-
import { I as $flag, S as debug, T as warn, t as structuredCloneJSON } from "./src-
|
|
5
|
-
import { A as isTransientStreamParseError, B as OpenAIHttpError, d as callWithCopilotModelRetry, l as finalize, n as StreamTimeoutError, s as ProviderResponseError, t as ConfigurationError, v as AbortError } from "./error-
|
|
6
|
-
import { A as NO_STRICT, L as sanitizeSchemaForOpenAIResponses, O as flattenExclusiveRequiredRootUnion, P as normalizeSchemaForMoonshot, a as normalizeSystemPrompts, j as adaptSchemaForStrict, k as toolWireSchema, l as sanitizeOpenAIResponsesAssistantHistoryItemsForReplay, s as resolveCacheRetention, t as createOpenAIResponsesHistoryPayload } from "./utils-
|
|
7
|
-
import { $ as isOpenRouterAnthropicModel, Ct as withEmptyCompletionRetry, D as buildResponsesInput, E as buildResponsesDeltaInput, G as getJuiceValue, I as disableStrictToolsForScope, J as getOpenAIStrictToolsScope, K as getOpenAIPromptCacheKey, N as createInitialResponsesAssistantMessage, P as createOpenAIStrictToolsState, Q as isOpenAIResponsesProgressEvent, S as applyResponsesCompatPolicy, T as applyWireModelIdTransform, Y as getOpenRouterResponsesSessionId, Z as isCompiledGrammarTooLargeStrictError, _ as applyOpenAIExtraBody, _t as isForcedToolChoice, ct as resolveOpenAICompatPolicy, dt as resolveOpenAIRequestSetup, et as isStrictToolsDisabledForScope, ft as resolveOpenAIResponsesOutputClamp, g as applyCommonResponsesSamplingParams, k as clearOpenAIStrictToolsState, n as getEnvApiKey, ot as processResponsesStream, pt as shouldRetryWithoutStrictTools, q as getOpenAIResponsesRoutingSessionId, ut as resolveOpenAIOutputTokenParam, v as applyOpenAIGatewayRouting, w as applyVercelResponsesCacheControls, yt as mapToOpenAIResponsesToolChoice } from "./stream-
|
|
8
|
-
import { t as createAbortSourceTracker } from "./abort-
|
|
9
|
-
import { A as semverGte, D as bareModelId, j as hostMatchesUrl, k as parseOpenAIModel } from "./models-
|
|
10
|
-
import "./identity-
|
|
4
|
+
import { I as $flag, S as debug, T as warn, t as structuredCloneJSON } from "./src-D_e1qMwi.mjs";
|
|
5
|
+
import { A as isTransientStreamParseError, B as OpenAIHttpError, d as callWithCopilotModelRetry, l as finalize, n as StreamTimeoutError, s as ProviderResponseError, t as ConfigurationError, v as AbortError } from "./error-DoHuatWw.mjs";
|
|
6
|
+
import { A as NO_STRICT, L as sanitizeSchemaForOpenAIResponses, O as flattenExclusiveRequiredRootUnion, P as normalizeSchemaForMoonshot, a as normalizeSystemPrompts, j as adaptSchemaForStrict, k as toolWireSchema, l as sanitizeOpenAIResponsesAssistantHistoryItemsForReplay, s as resolveCacheRetention, t as createOpenAIResponsesHistoryPayload } from "./utils-fnV2zzp3.mjs";
|
|
7
|
+
import { $ as isOpenRouterAnthropicModel, Ct as withEmptyCompletionRetry, D as buildResponsesInput, E as buildResponsesDeltaInput, G as getJuiceValue, I as disableStrictToolsForScope, J as getOpenAIStrictToolsScope, K as getOpenAIPromptCacheKey, N as createInitialResponsesAssistantMessage, P as createOpenAIStrictToolsState, Q as isOpenAIResponsesProgressEvent, S as applyResponsesCompatPolicy, T as applyWireModelIdTransform, Y as getOpenRouterResponsesSessionId, Z as isCompiledGrammarTooLargeStrictError, _ as applyOpenAIExtraBody, _t as isForcedToolChoice, ct as resolveOpenAICompatPolicy, dt as resolveOpenAIRequestSetup, et as isStrictToolsDisabledForScope, ft as resolveOpenAIResponsesOutputClamp, g as applyCommonResponsesSamplingParams, k as clearOpenAIStrictToolsState, n as getEnvApiKey, ot as processResponsesStream, pt as shouldRetryWithoutStrictTools, q as getOpenAIResponsesRoutingSessionId, ut as resolveOpenAIOutputTokenParam, v as applyOpenAIGatewayRouting, w as applyVercelResponsesCacheControls, yt as mapToOpenAIResponsesToolChoice } from "./stream-DveNFWSN.mjs";
|
|
8
|
+
import { t as createAbortSourceTracker } from "./abort-CsjZitYv.mjs";
|
|
9
|
+
import { A as semverGte, D as bareModelId, j as hostMatchesUrl, k as parseOpenAIModel } from "./models-Cp3PzU3l.mjs";
|
|
10
|
+
import "./identity-C0SPVyIZ.mjs";
|
|
11
11
|
import { t as findStrictToolSchemaViolation } from "./strict-tool-validation-imVLUcbI.mjs";
|
|
12
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
13
|
-
import { n as getOpenAIStreamFirstEventTimeoutMs, o as iterateWithIdleTimeout, r as getOpenAIStreamIdleTimeoutMs } from "./idle-iterator-
|
|
12
|
+
import { t as AssistantMessageEventStream } from "./event-stream-C-FmBYUt.mjs";
|
|
13
|
+
import { n as getOpenAIStreamFirstEventTimeoutMs, o as iterateWithIdleTimeout, r as getOpenAIStreamIdleTimeoutMs } from "./idle-iterator-HzbbfXP4.mjs";
|
|
14
14
|
import { t as notifyProviderResponse } from "./provider-response-C6vcbQyO.mjs";
|
|
15
15
|
import { t as compactGrammarDefinition } from "./grammar-D-NqNUxQ.mjs";
|
|
16
|
-
import { a as getOpenAIReasoningEffortFallback, c as postOpenAIStream, i as createOpenAIReasoningEffortFallbackState, n as clearOpenAIReasoningEffortFallbackState, o as rememberOpenAIReasoningEffortFallback, r as createOpenAIReasoningEffortFallbackKey, s as resolveOpenAIReasoningEffortFallback, t as applyOpenAIReasoningEffortFallback } from "./openai-reasoning-fallback-
|
|
16
|
+
import { a as getOpenAIReasoningEffortFallback, c as postOpenAIStream, i as createOpenAIReasoningEffortFallbackState, n as clearOpenAIReasoningEffortFallbackState, o as rememberOpenAIReasoningEffortFallback, r as createOpenAIReasoningEffortFallbackKey, s as resolveOpenAIReasoningEffortFallback, t as applyOpenAIReasoningEffortFallback } from "./openai-reasoning-fallback-CigKCyzc.mjs";
|
|
17
17
|
import { scheduler } from "node:timers/promises";
|
|
18
18
|
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/providers/openai-responses.ts
|
|
19
19
|
var openai_responses_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
import { _ as OnPromptRequiredError, h as LoginCancelledError, m as ApiKeyRequiredError } from "./error-
|
|
3
|
+
import { _ as OnPromptRequiredError, h as LoginCancelledError, m as ApiKeyRequiredError } from "./error-DoHuatWw.mjs";
|
|
4
4
|
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/opencode.ts
|
|
5
5
|
/**
|
|
6
6
|
* OpenCode Zen login flow.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
import { D as Cookie, E as $, O as CookieMap, P as $env } from "./src-
|
|
4
|
-
import { V as ProviderHttpError, _ as OnPromptRequiredError, c as OAuthError, h as LoginCancelledError } from "./error-
|
|
3
|
+
import { D as Cookie, E as $, O as CookieMap, P as $env } from "./src-D_e1qMwi.mjs";
|
|
4
|
+
import { V as ProviderHttpError, _ as OnPromptRequiredError, c as OAuthError, h as LoginCancelledError } from "./error-DoHuatWw.mjs";
|
|
5
5
|
import * as os from "node:os";
|
|
6
6
|
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/registry/oauth/perplexity.ts
|
|
7
7
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
import { n as StreamTimeoutError, r as ValidationError, v as AbortError } from "./error-
|
|
3
|
+
import { n as StreamTimeoutError, r as ValidationError, v as AbortError } from "./error-DoHuatWw.mjs";
|
|
4
4
|
import * as tls from "node:tls";
|
|
5
5
|
import * as net from "node:net";
|
|
6
6
|
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/proxy.ts
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
+
__installBunShim();
|
|
3
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-utils@17.3.5/node_modules/@oh-my-pi/pi-utils/src/readability/readability.ts
|
|
4
|
+
const UNLIKELY$1 = /-ad-|ai2html|banner|breadcrumbs|comment|community|combx|disqus|extra|footer|gdpr|header|legends|menu|related|remark|replies|rss|shoutbox|sidebar|skyscraper|social|sponsor|supplemental|ad-break|agegate|pagination|pager|popup/i;
|
|
5
|
+
const POSSIBLE$1 = /and|article|body|column|content|main|shadow/i;
|
|
6
|
+
const POSITIVE = /article|body|content|entry|hentry|h-entry|main|page|pagination|post|text|blog|story/i;
|
|
7
|
+
const NEGATIVE = /-ad-|hidden|^hid$| hid$| hid |^hid |banner|comment|com-|contact|footer|gdpr|masthead|media|meta|outbrain|promo|related|scroll|share|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|widget/i;
|
|
8
|
+
const BYLINE = /byline|author|dateline|writtenby|p-author/i;
|
|
9
|
+
const SCORE_TAGS = /* @__PURE__ */ new Set([
|
|
10
|
+
"SECTION",
|
|
11
|
+
"H2",
|
|
12
|
+
"H3",
|
|
13
|
+
"H4",
|
|
14
|
+
"H5",
|
|
15
|
+
"H6",
|
|
16
|
+
"P",
|
|
17
|
+
"TD",
|
|
18
|
+
"PRE"
|
|
19
|
+
]);
|
|
20
|
+
const DROP_TAGS = [
|
|
21
|
+
"form",
|
|
22
|
+
"fieldset",
|
|
23
|
+
"object",
|
|
24
|
+
"embed",
|
|
25
|
+
"footer",
|
|
26
|
+
"link",
|
|
27
|
+
"aside",
|
|
28
|
+
"iframe",
|
|
29
|
+
"input",
|
|
30
|
+
"textarea",
|
|
31
|
+
"select",
|
|
32
|
+
"button"
|
|
33
|
+
];
|
|
34
|
+
const UNLIKELY_ROLES = /* @__PURE__ */ new Set([
|
|
35
|
+
"menu",
|
|
36
|
+
"menubar",
|
|
37
|
+
"complementary",
|
|
38
|
+
"navigation",
|
|
39
|
+
"alert",
|
|
40
|
+
"alertdialog",
|
|
41
|
+
"dialog"
|
|
42
|
+
]);
|
|
43
|
+
const ARTICLE_TYPES = /^(?:Article|AdvertiserContentArticle|NewsArticle|AnalysisNewsArticle|OpinionNewsArticle|ReportageNewsArticle|ReviewNewsArticle|Report|ScholarlyArticle|MedicalScholarlyArticle|SocialMediaPosting|BlogPosting|LiveBlogPosting|DiscussionForumPosting|TechArticle|APIReference)$/;
|
|
44
|
+
const NORMALIZE = /\s{2,}/g;
|
|
45
|
+
function elements(collection) {
|
|
46
|
+
return Array.from(collection);
|
|
47
|
+
}
|
|
48
|
+
function descendants(root) {
|
|
49
|
+
const result = [];
|
|
50
|
+
const pending = elements(root.children).reverse();
|
|
51
|
+
while (pending.length) {
|
|
52
|
+
const node = pending.pop();
|
|
53
|
+
if (!node) continue;
|
|
54
|
+
result.push(node);
|
|
55
|
+
const children = elements(node.children);
|
|
56
|
+
for (let index = children.length - 1; index >= 0; index--) pending.push(children[index]);
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
function text(node) {
|
|
61
|
+
return (node.textContent ?? "").trim().replace(NORMALIZE, " ");
|
|
62
|
+
}
|
|
63
|
+
function matchLabel(node) {
|
|
64
|
+
return `${typeof node.className === "string" ? node.className : ""} ${node.id ?? ""}`;
|
|
65
|
+
}
|
|
66
|
+
function classWeight(node) {
|
|
67
|
+
const label = matchLabel(node);
|
|
68
|
+
return (POSITIVE.test(label) ? 25 : 0) - (NEGATIVE.test(label) ? 25 : 0);
|
|
69
|
+
}
|
|
70
|
+
function initialScore(node) {
|
|
71
|
+
let score = classWeight(node);
|
|
72
|
+
switch (node.tagName) {
|
|
73
|
+
case "DIV":
|
|
74
|
+
score += 5;
|
|
75
|
+
break;
|
|
76
|
+
case "PRE":
|
|
77
|
+
case "TD":
|
|
78
|
+
case "BLOCKQUOTE":
|
|
79
|
+
score += 3;
|
|
80
|
+
break;
|
|
81
|
+
case "ADDRESS":
|
|
82
|
+
case "OL":
|
|
83
|
+
case "UL":
|
|
84
|
+
case "DL":
|
|
85
|
+
case "DD":
|
|
86
|
+
case "DT":
|
|
87
|
+
case "LI":
|
|
88
|
+
case "FORM":
|
|
89
|
+
score -= 3;
|
|
90
|
+
break;
|
|
91
|
+
case "H1":
|
|
92
|
+
case "H2":
|
|
93
|
+
case "H3":
|
|
94
|
+
case "H4":
|
|
95
|
+
case "H5":
|
|
96
|
+
case "H6":
|
|
97
|
+
case "TH": score -= 5;
|
|
98
|
+
}
|
|
99
|
+
return score;
|
|
100
|
+
}
|
|
101
|
+
function linkDensity(node) {
|
|
102
|
+
const total = text(node).length;
|
|
103
|
+
if (!total) return 0;
|
|
104
|
+
let linked = 0;
|
|
105
|
+
for (const link of elements(node.getElementsByTagName("a"))) linked += text(link).length * ((link.getAttribute("href") ?? "").startsWith("#") ? .3 : 1);
|
|
106
|
+
return linked / total;
|
|
107
|
+
}
|
|
108
|
+
function visible(node) {
|
|
109
|
+
const style = node.getAttribute("style")?.toLowerCase() ?? "";
|
|
110
|
+
return !node.hasAttribute("hidden") && node.getAttribute("aria-hidden") !== "true" && !/display\s*:\s*none|visibility\s*:\s*hidden/.test(style);
|
|
111
|
+
}
|
|
112
|
+
function removeAll(root, tags) {
|
|
113
|
+
const container = root;
|
|
114
|
+
for (const tag of tags) for (const node of elements(container.getElementsByTagName(tag))) node.remove();
|
|
115
|
+
}
|
|
116
|
+
function entityDecode(value) {
|
|
117
|
+
if (!value) return value;
|
|
118
|
+
const named = {
|
|
119
|
+
quot: "\"",
|
|
120
|
+
amp: "&",
|
|
121
|
+
apos: "'",
|
|
122
|
+
lt: "<",
|
|
123
|
+
gt: ">"
|
|
124
|
+
};
|
|
125
|
+
return value.replace(/&(quot|amp|apos|lt|gt);/g, (_, name) => named[name] ?? "").replace(/&#(?:x([0-9a-f]+)|(\d+));/gi, (_, hex, decimal) => {
|
|
126
|
+
const value = Number.parseInt(hex ?? decimal ?? "0", hex ? 16 : 10);
|
|
127
|
+
return String.fromCodePoint(value === 0 || value > 1114111 || value >= 55296 && value <= 57343 ? 65533 : value);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function titleFromDocument(document) {
|
|
131
|
+
const titleElement = elements(document.getElementsByTagName("title"))[0];
|
|
132
|
+
const original = typeof document.title === "string" ? document.title.trim() : titleElement ? text(titleElement) : "";
|
|
133
|
+
let title = original;
|
|
134
|
+
const separators = [...original.matchAll(/ [|\\/>»-] /g)];
|
|
135
|
+
if (separators.length) {
|
|
136
|
+
title = original.slice(0, separators.at(-1)?.index);
|
|
137
|
+
if (title.trim().split(/\s+/).length < 3) title = original.replace(/^[^|\\/>»-]*[|\\/>»-]/, "");
|
|
138
|
+
} else if (title.includes(": ")) {
|
|
139
|
+
if (!elements(document.querySelectorAll("h1, h2")).some((node) => text(node) === title)) {
|
|
140
|
+
const suffix = original.slice(original.lastIndexOf(":") + 1);
|
|
141
|
+
title = suffix.trim().split(/\s+/).length < 3 ? original.slice(original.indexOf(":") + 1) : suffix;
|
|
142
|
+
}
|
|
143
|
+
} else if (title.length > 150 || title.length < 15) {
|
|
144
|
+
const headings = elements(document.getElementsByTagName("h1"));
|
|
145
|
+
if (headings.length === 1) title = text(headings[0]);
|
|
146
|
+
}
|
|
147
|
+
title = title.trim().replace(NORMALIZE, " ");
|
|
148
|
+
if (title.split(/\s+/).length <= 4) return original;
|
|
149
|
+
return title;
|
|
150
|
+
}
|
|
151
|
+
function jsonLdMetadata(document) {
|
|
152
|
+
for (const script of elements(document.getElementsByTagName("script"))) {
|
|
153
|
+
if (script.getAttribute("type") !== "application/ld+json") continue;
|
|
154
|
+
try {
|
|
155
|
+
const decoded = JSON.parse((script.textContent ?? "").replace(/^\s*<!\[CDATA\[|\]\]>\s*$/g, ""));
|
|
156
|
+
const records = Array.isArray(decoded) ? decoded : [decoded];
|
|
157
|
+
for (const candidate of records) {
|
|
158
|
+
if (!candidate || typeof candidate !== "object") continue;
|
|
159
|
+
const record = candidate;
|
|
160
|
+
if (typeof record["@type"] !== "string" || !ARTICLE_TYPES.test(record["@type"])) continue;
|
|
161
|
+
const author = record.author;
|
|
162
|
+
let byline;
|
|
163
|
+
if (author && typeof author === "object" && !Array.isArray(author)) {
|
|
164
|
+
const name = author.name;
|
|
165
|
+
if (typeof name === "string") byline = name.trim();
|
|
166
|
+
} else if (Array.isArray(author)) {
|
|
167
|
+
const names = author.flatMap((item) => {
|
|
168
|
+
if (!item || typeof item !== "object") return [];
|
|
169
|
+
const name = item.name;
|
|
170
|
+
return typeof name === "string" ? [name.trim()] : [];
|
|
171
|
+
});
|
|
172
|
+
if (names.length) byline = names.join(", ");
|
|
173
|
+
}
|
|
174
|
+
const publisher = record.publisher;
|
|
175
|
+
const publisherName = publisher && typeof publisher === "object" ? publisher.name : void 0;
|
|
176
|
+
return {
|
|
177
|
+
title: typeof record.name === "string" ? record.name.trim() : typeof record.headline === "string" ? record.headline.trim() : void 0,
|
|
178
|
+
byline,
|
|
179
|
+
excerpt: typeof record.description === "string" ? record.description.trim() : void 0,
|
|
180
|
+
siteName: typeof publisherName === "string" ? publisherName.trim() : void 0,
|
|
181
|
+
publishedTime: typeof record.datePublished === "string" ? record.datePublished.trim() : void 0
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
} catch {}
|
|
185
|
+
}
|
|
186
|
+
return {};
|
|
187
|
+
}
|
|
188
|
+
function metadataFromDocument(document, jsonLd) {
|
|
189
|
+
const values = /* @__PURE__ */ new Map();
|
|
190
|
+
for (const meta of elements(document.getElementsByTagName("meta"))) {
|
|
191
|
+
const content = meta.getAttribute("content")?.trim();
|
|
192
|
+
if (!content) continue;
|
|
193
|
+
const property = meta.getAttribute("property")?.toLowerCase().replace(/\s/g, "");
|
|
194
|
+
const name = meta.getAttribute("name")?.toLowerCase().replace(/\s/g, "").replace(/\./g, ":");
|
|
195
|
+
if (property && /^(?:article|dc|dcterm|og|twitter):(?:author|creator|description|published_time|title|site_name)$/.test(property)) values.set(property, content);
|
|
196
|
+
else if (name && /^(?:(?:dc|dcterm|og|twitter|parsely|weibo:(?:article|webpage))[-:]?)?(?:author|creator|pub-date|description|title|site_name)$/.test(name)) values.set(name, content);
|
|
197
|
+
}
|
|
198
|
+
const articleAuthor = values.get("article:author");
|
|
199
|
+
const result = {
|
|
200
|
+
title: jsonLd.title ?? values.get("dc:title") ?? values.get("dcterm:title") ?? values.get("og:title") ?? values.get("title") ?? values.get("twitter:title") ?? titleFromDocument(document),
|
|
201
|
+
byline: jsonLd.byline ?? values.get("dc:creator") ?? values.get("dcterm:creator") ?? values.get("author") ?? values.get("parsely-author") ?? (articleAuthor && !/^https?:\/\//.test(articleAuthor) ? articleAuthor : void 0),
|
|
202
|
+
excerpt: jsonLd.excerpt ?? values.get("dc:description") ?? values.get("dcterm:description") ?? values.get("og:description") ?? values.get("description") ?? values.get("twitter:description"),
|
|
203
|
+
siteName: jsonLd.siteName ?? values.get("og:site_name"),
|
|
204
|
+
publishedTime: jsonLd.publishedTime ?? values.get("article:published_time") ?? values.get("parsely-pub-date") ?? null
|
|
205
|
+
};
|
|
206
|
+
return {
|
|
207
|
+
title: entityDecode(result.title) ?? void 0,
|
|
208
|
+
byline: entityDecode(result.byline) ?? void 0,
|
|
209
|
+
excerpt: entityDecode(result.excerpt) ?? void 0,
|
|
210
|
+
siteName: entityDecode(result.siteName) ?? void 0,
|
|
211
|
+
publishedTime: entityDecode(result.publishedTime)
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/** Extracts the article body and metadata from a standards-shaped document. */
|
|
215
|
+
var Readability = class {
|
|
216
|
+
#document;
|
|
217
|
+
#options;
|
|
218
|
+
#scores = /* @__PURE__ */ new Map();
|
|
219
|
+
#byline;
|
|
220
|
+
#lang = null;
|
|
221
|
+
constructor(document, options = {}) {
|
|
222
|
+
this.#document = document;
|
|
223
|
+
this.#options = options;
|
|
224
|
+
}
|
|
225
|
+
/** Runs extraction once; the supplied document is consumed and should not be reused. */
|
|
226
|
+
parse() {
|
|
227
|
+
const documentElement = this.#document.documentElement;
|
|
228
|
+
if (!documentElement) return null;
|
|
229
|
+
const max = this.#options.maxElemsToParse ?? 0;
|
|
230
|
+
if (max > 0) {
|
|
231
|
+
const count = descendants(documentElement).length + 1;
|
|
232
|
+
if (count > max) throw new Error(`Aborting parsing document; ${count} elements found`);
|
|
233
|
+
}
|
|
234
|
+
const jsonLd = this.#options.disableJSONLD ? {} : jsonLdMetadata(this.#document);
|
|
235
|
+
const metadata = metadataFromDocument(this.#document, jsonLd);
|
|
236
|
+
removeAll(this.#document, ["script", "style"]);
|
|
237
|
+
const body = this.#document.body;
|
|
238
|
+
if (!body) return null;
|
|
239
|
+
const source = body.innerHTML;
|
|
240
|
+
const attempts = [];
|
|
241
|
+
for (const mode of [
|
|
242
|
+
0,
|
|
243
|
+
1,
|
|
244
|
+
2,
|
|
245
|
+
3
|
|
246
|
+
]) {
|
|
247
|
+
if (mode) body.innerHTML = source;
|
|
248
|
+
this.#scores.clear();
|
|
249
|
+
this.#byline = void 0;
|
|
250
|
+
const attempt = this.#extract(body, documentElement, metadata.title ?? "", mode);
|
|
251
|
+
if (attempt) attempts.push(attempt);
|
|
252
|
+
if (attempt && attempt.length >= (this.#options.charThreshold || 500)) break;
|
|
253
|
+
}
|
|
254
|
+
attempts.sort((left, right) => right.length - left.length);
|
|
255
|
+
const best = attempts[0];
|
|
256
|
+
if (!best?.length) return null;
|
|
257
|
+
if (!metadata.excerpt) {
|
|
258
|
+
const firstParagraph = elements(best.element.getElementsByTagName("p"))[0];
|
|
259
|
+
if (firstParagraph) metadata.excerpt = (firstParagraph.textContent ?? "").trim();
|
|
260
|
+
}
|
|
261
|
+
const contentText = best.element.textContent ?? "";
|
|
262
|
+
const serializer = this.#options.serializer ?? ((node) => node.innerHTML);
|
|
263
|
+
return {
|
|
264
|
+
title: metadata.title,
|
|
265
|
+
byline: metadata.byline ?? this.#byline,
|
|
266
|
+
dir: best.dir,
|
|
267
|
+
lang: this.#lang,
|
|
268
|
+
content: serializer(best.element),
|
|
269
|
+
textContent: contentText,
|
|
270
|
+
length: contentText.length,
|
|
271
|
+
excerpt: metadata.excerpt,
|
|
272
|
+
siteName: metadata.siteName,
|
|
273
|
+
publishedTime: metadata.publishedTime
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
#extract(body, documentElement, articleTitle, mode) {
|
|
277
|
+
this.#lang = documentElement.getAttribute("lang");
|
|
278
|
+
const stripUnlikely = mode === 0;
|
|
279
|
+
const weightClasses = mode < 2;
|
|
280
|
+
const all = [documentElement, ...descendants(documentElement)];
|
|
281
|
+
const scored = [];
|
|
282
|
+
let titleRemoved = false;
|
|
283
|
+
for (const node of all) {
|
|
284
|
+
if (node === documentElement || node.tagName === "BODY") continue;
|
|
285
|
+
const label = matchLabel(node);
|
|
286
|
+
if (!visible(node) || node.getAttribute("aria-modal") === "true" && node.getAttribute("role") === "dialog") {
|
|
287
|
+
node.remove();
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
if (!this.#byline && this.#isByline(node, label)) {
|
|
291
|
+
this.#byline = text(node);
|
|
292
|
+
node.remove();
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (!titleRemoved && /^(?:H1|H2)$/.test(node.tagName) && this.#similar(articleTitle, text(node)) > .75) {
|
|
296
|
+
titleRemoved = true;
|
|
297
|
+
node.remove();
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (stripUnlikely && UNLIKELY$1.test(label) && !POSSIBLE$1.test(label) || UNLIKELY_ROLES.has(node.getAttribute("role") ?? "")) {
|
|
301
|
+
node.remove();
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (SCORE_TAGS.has(node.tagName)) scored.push(node);
|
|
305
|
+
}
|
|
306
|
+
for (const paragraph of scored) this.#scoreParagraph(paragraph, weightClasses);
|
|
307
|
+
let top;
|
|
308
|
+
let topScore = Number.NEGATIVE_INFINITY;
|
|
309
|
+
for (const [candidate, raw] of this.#scores) {
|
|
310
|
+
if (candidate.tagName === "BODY" || candidate.tagName === "HTML") continue;
|
|
311
|
+
const score = raw * (1 - linkDensity(candidate));
|
|
312
|
+
this.#scores.set(candidate, score);
|
|
313
|
+
if (score > topScore) {
|
|
314
|
+
top = candidate;
|
|
315
|
+
topScore = score;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (!top || top.tagName === "BODY") top = body;
|
|
319
|
+
while (top.parentNode && top.parentNode.tagName !== "BODY" && top.parentNode.children.length === 1) top = top.parentNode;
|
|
320
|
+
const parent = top.parentNode;
|
|
321
|
+
const article = this.#document.createElement("DIV");
|
|
322
|
+
const siblings = parent ? elements(parent.children) : [top];
|
|
323
|
+
const threshold = Math.max(10, (this.#scores.get(top) ?? topScore) * .2);
|
|
324
|
+
for (const sibling of siblings) {
|
|
325
|
+
const siblingText = text(sibling);
|
|
326
|
+
const sameClassBonus = sibling.className && sibling.className === top.className ? (this.#scores.get(top) ?? 0) * .2 : 0;
|
|
327
|
+
if (!(sibling === top || (this.#scores.get(sibling) ?? 0) + sameClassBonus >= threshold || sibling.tagName === "P" && (siblingText.length > 80 && linkDensity(sibling) < .25 || siblingText.length > 0 && siblingText.length < 80 && linkDensity(sibling) === 0 && /\.(?: |$)/.test(siblingText)))) continue;
|
|
328
|
+
if ([
|
|
329
|
+
"DIV",
|
|
330
|
+
"ARTICLE",
|
|
331
|
+
"SECTION",
|
|
332
|
+
"P",
|
|
333
|
+
"OL",
|
|
334
|
+
"UL"
|
|
335
|
+
].includes(sibling.tagName)) {
|
|
336
|
+
article.appendChild(sibling);
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
const replacement = this.#document.createElement("DIV");
|
|
340
|
+
for (const attribute of Array.from(sibling.attributes)) replacement.setAttribute(attribute.name, attribute.value);
|
|
341
|
+
while (sibling.firstChild) replacement.appendChild(sibling.firstChild);
|
|
342
|
+
article.appendChild(replacement);
|
|
343
|
+
}
|
|
344
|
+
this.#clean(article, mode < 3);
|
|
345
|
+
const page = this.#document.createElement("DIV");
|
|
346
|
+
page.id = "readability-page-1";
|
|
347
|
+
page.className = "page";
|
|
348
|
+
while (article.firstChild) page.appendChild(article.firstChild);
|
|
349
|
+
article.appendChild(page);
|
|
350
|
+
const content = text(article);
|
|
351
|
+
let dir;
|
|
352
|
+
let ancestor = top;
|
|
353
|
+
while (ancestor) {
|
|
354
|
+
if (ancestor.getAttribute) {
|
|
355
|
+
dir = ancestor.getAttribute("dir");
|
|
356
|
+
if (dir) break;
|
|
357
|
+
}
|
|
358
|
+
ancestor = ancestor.parentNode;
|
|
359
|
+
}
|
|
360
|
+
return {
|
|
361
|
+
element: article,
|
|
362
|
+
length: content.length,
|
|
363
|
+
dir
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
#scoreParagraph(node, weightClasses) {
|
|
367
|
+
const content = text(node);
|
|
368
|
+
if (content.length < 25) return;
|
|
369
|
+
const score = 1 + content.split(/[\u002c\u060c\ufe50\ufe10\ufe11\u2e41\u2e34\u2e32\uff0c]/).length + Math.min(Math.floor(content.length / 100), 3);
|
|
370
|
+
let ancestor = node.parentNode;
|
|
371
|
+
for (let level = 0; ancestor && level < 5; level++, ancestor = ancestor.parentNode) {
|
|
372
|
+
const element = ancestor;
|
|
373
|
+
if (!element.tagName || !element.parentNode || !element.parentNode.tagName) continue;
|
|
374
|
+
const baseline = this.#scores.get(element) ?? initialScore(element) - (weightClasses ? 0 : classWeight(element));
|
|
375
|
+
const divisor = level === 0 ? 1 : level === 1 ? 2 : level * 3;
|
|
376
|
+
this.#scores.set(element, baseline + score / divisor);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
#clean(root, conditional) {
|
|
380
|
+
removeAll(root, DROP_TAGS);
|
|
381
|
+
for (const heading of elements(root.querySelectorAll("h1, h2, h3, h4, h5, h6"))) if (classWeight(heading) < 0 || linkDensity(heading) > .33) heading.remove();
|
|
382
|
+
if (conditional) for (const node of elements(root.querySelectorAll("table, ul, div"))) {
|
|
383
|
+
if (node === root) continue;
|
|
384
|
+
const nodeText = text(node);
|
|
385
|
+
const paragraphs = node.getElementsByTagName("p").length;
|
|
386
|
+
const images = node.getElementsByTagName("img").length;
|
|
387
|
+
const inputs = node.getElementsByTagName("input").length;
|
|
388
|
+
if (classWeight(node) < 0 || !nodeText && !images || nodeText.split(",").length < 10 && (images > paragraphs && paragraphs > 0 || inputs > Math.floor(paragraphs / 3) || linkDensity(node) > .5)) node.remove();
|
|
389
|
+
}
|
|
390
|
+
for (const paragraph of elements(root.getElementsByTagName("p"))) if (!text(paragraph) && !paragraph.querySelector("img, embed, object, iframe")) paragraph.remove();
|
|
391
|
+
for (const node of [root, ...descendants(root)]) {
|
|
392
|
+
if (!this.#options.keepClasses) {
|
|
393
|
+
const preserved = (this.#options.classesToPreserve ?? []).filter((name) => node.className.split(/\s+/).includes(name));
|
|
394
|
+
if (node.id === "readability-page-1") preserved.unshift("page");
|
|
395
|
+
if (preserved.length) node.className = [...new Set(preserved)].join(" ");
|
|
396
|
+
else node.removeAttribute("class");
|
|
397
|
+
}
|
|
398
|
+
for (const attr of [
|
|
399
|
+
"style",
|
|
400
|
+
"align",
|
|
401
|
+
"background",
|
|
402
|
+
"bgcolor",
|
|
403
|
+
"border",
|
|
404
|
+
"cellpadding",
|
|
405
|
+
"cellspacing",
|
|
406
|
+
"frame",
|
|
407
|
+
"hspace",
|
|
408
|
+
"rules",
|
|
409
|
+
"valign",
|
|
410
|
+
"vspace"
|
|
411
|
+
]) node.removeAttribute(attr);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
#isByline(node, label) {
|
|
415
|
+
const value = text(node);
|
|
416
|
+
return value.length > 0 && value.length < 100 && (node.getAttribute("rel") === "author" || (node.getAttribute("itemprop") ?? "").includes("author") || BYLINE.test(label));
|
|
417
|
+
}
|
|
418
|
+
#similar(left, right) {
|
|
419
|
+
const leftTokens = left.toLowerCase().split(/\W+/).filter(Boolean);
|
|
420
|
+
const rightTokens = right.toLowerCase().split(/\W+/).filter(Boolean);
|
|
421
|
+
if (!leftTokens.length || !rightTokens.length) return 0;
|
|
422
|
+
return 1 - rightTokens.filter((token) => !leftTokens.includes(token)).join(" ").length / rightTokens.join(" ").length;
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-utils@17.3.5/node_modules/@oh-my-pi/pi-utils/src/readability/readerable.ts
|
|
427
|
+
const UNLIKELY = /-ad-|ai2html|banner|breadcrumbs|combx|comment|community|cover-wrap|disqus|extra|footer|gdpr|header|legends|menu|related|remark|replies|rss|shoutbox|sidebar|skyscraper|social|sponsor|supplemental|ad-break|agegate|pagination|pager|popup|yom-remote/i;
|
|
428
|
+
const POSSIBLE = /and|article|body|column|content|main|shadow/i;
|
|
429
|
+
/** Estimates whether a document contains enough prose for article extraction. */
|
|
430
|
+
function isProbablyReaderable(document, options = {}) {
|
|
431
|
+
const resolved = typeof options === "function" ? { visibilityChecker: options } : options;
|
|
432
|
+
const minLength = resolved.minContentLength ?? 140;
|
|
433
|
+
const minScore = resolved.minScore ?? 20;
|
|
434
|
+
const visible = resolved.visibilityChecker ?? ((node) => {
|
|
435
|
+
const element = node;
|
|
436
|
+
const style = element.getAttribute("style")?.toLowerCase() ?? "";
|
|
437
|
+
return !element.hasAttribute("hidden") && element.getAttribute("aria-hidden") !== "true" && !/display\s*:\s*none/.test(style);
|
|
438
|
+
});
|
|
439
|
+
const candidates = new Set(Array.from(document.querySelectorAll("p, pre, article")));
|
|
440
|
+
for (const br of Array.from(document.querySelectorAll("div > br"))) if (br.parentNode) candidates.add(br.parentNode);
|
|
441
|
+
let score = 0;
|
|
442
|
+
for (const node of candidates) {
|
|
443
|
+
if (!visible(node)) continue;
|
|
444
|
+
const label = `${node.className} ${node.id}`;
|
|
445
|
+
if (UNLIKELY.test(label) && !POSSIBLE.test(label)) continue;
|
|
446
|
+
if (node.parentNode?.tagName === "LI" && node.tagName === "P") continue;
|
|
447
|
+
const length = (node.textContent ?? "").trim().length;
|
|
448
|
+
if (length < minLength) continue;
|
|
449
|
+
score += Math.sqrt(length - minLength);
|
|
450
|
+
if (score > minScore) return true;
|
|
451
|
+
}
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
//#endregion
|
|
455
|
+
export { Readability, isProbablyReaderable };
|