pi2dsh 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/README.zh.md +16 -1
- package/dist/compat/pi-ai.d.mts +10 -1
- package/dist/compat/pi-ai.d.mts.map +1 -1
- package/dist/compat/pi-ai.mjs +2 -2918
- package/dist/credentials-oauth.d.mts +27 -0
- package/dist/credentials-oauth.d.mts.map +1 -0
- package/dist/credentials-oauth.mjs +91 -0
- package/dist/credentials-oauth.mjs.map +1 -0
- package/dist/host.mjs +3 -1
- package/dist/host.mjs.map +1 -1
- package/dist/oauth-bridge-BpPrppjR.mjs +359 -0
- package/dist/oauth-bridge-BpPrppjR.mjs.map +1 -0
- package/dist/pi-ai-CWFlgigJ.mjs +2947 -0
- package/dist/pi-ai-CWFlgigJ.mjs.map +1 -0
- package/dist/{runtime-oLd2EInK.mjs → runtime-6DefpI6h.mjs} +11 -355
- package/dist/runtime-6DefpI6h.mjs.map +1 -0
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +1 -1
- package/package.json +11 -1
- package/dist/compat/pi-ai.mjs.map +0 -1
- package/dist/runtime-oLd2EInK.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -102,7 +102,22 @@ DSH ships static HTTP headers only; pi2dsh adds the interactive OAuth layer from
|
|
|
102
102
|
# → approve in your browser; the credential lands in auth.json (0600)
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
What you get, end to end: PKCE + `localhost:1455` callback (device-code fallback for headless boxes), credentials persisted in Pi's `auth.json` format — so packages like `@narumitw/pi-accounts` manage the same file they already know — automatic refresh with Pi's double-checked-lock rotation (5-minute expiry window, refreshed token persisted before release), and `getProviderAuth`/`getApiKeyForProvider` on the extension registry returning live keys.
|
|
105
|
+
What you get, end to end: PKCE + `localhost:1455` callback (device-code fallback for headless boxes), credentials persisted in Pi's `auth.json` format — so packages like `@narumitw/pi-accounts` manage the same file they already know — automatic refresh with Pi's double-checked-lock rotation (5-minute expiry window, refreshed token persisted before release), and `getProviderAuth`/`getApiKeyForProvider` on the extension registry returning live keys.
|
|
106
|
+
|
|
107
|
+
**And the token drives real model calls through DSH's native LLM path.** `pi2dsh/credentials-oauth` is a standard `dsh-credentials` provider: any reference shaped `PI2DSH_OAUTH_<PROVIDER>` resolves per request from `auth.json` (running the refresh rotation on the way), everything else falls through to the environment. Point an official `@deepseek-ai/dsh-llm-pi-ai` route at it and `ctx.llm.stream()` runs on your subscription:
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
- id: llm
|
|
111
|
+
name: '@deepseek-ai/dsh-llm-pi-ai'
|
|
112
|
+
config:
|
|
113
|
+
providers:
|
|
114
|
+
openai-codex:
|
|
115
|
+
apiKeyEnv: PI2DSH_OAUTH_OPENAI_CODEX
|
|
116
|
+
models:
|
|
117
|
+
- id: gpt-5.6-luna
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Both layers are verified against a real ChatGPT Pro account: browser authorization → callback → token exchange → store → refreshable key (`scripts/verify-oauth-e2e.mjs`), then credentials provider → official pi-ai route → DSH-native `ctx.llm.stream()` → a real model reply on the subscription (`scripts/verify-oauth-llm-e2e.mjs`). On networks that need a proxy, both scripts honor `HTTPS_PROXY`.
|
|
106
121
|
|
|
107
122
|
## Compatibility boundaries (explicit, never silent)
|
|
108
123
|
|
package/README.zh.md
CHANGED
|
@@ -102,7 +102,22 @@ DSH 原生只有静态 HTTP headers;pi2dsh 把 Pi 生态的交互式 OAuth 层
|
|
|
102
102
|
# → 浏览器里点击授权;凭证落盘 auth.json(0600)
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
端到端你得到的是:PKCE + `localhost:1455` 回调(无头环境有 device-code 备选)、凭证按 Pi 的 `auth.json` 格式持久化——所以 `@narumitw/pi-accounts` 这类包管理的就是它们熟悉的同一份文件——自动刷新走 Pi 的双检锁轮换(5 分钟过期窗口,轮换后的 token 先落盘再放锁)、扩展注册表的 `getProviderAuth`/`getApiKeyForProvider` 返回真实可用的 key
|
|
105
|
+
端到端你得到的是:PKCE + `localhost:1455` 回调(无头环境有 device-code 备选)、凭证按 Pi 的 `auth.json` 格式持久化——所以 `@narumitw/pi-accounts` 这类包管理的就是它们熟悉的同一份文件——自动刷新走 Pi 的双检锁轮换(5 分钟过期窗口,轮换后的 token 先落盘再放锁)、扩展注册表的 `getProviderAuth`/`getApiKeyForProvider` 返回真实可用的 key。
|
|
106
|
+
|
|
107
|
+
**而且 token 直接驱动 DSH 原生链路的真实模型调用。** `pi2dsh/credentials-oauth` 是一个标准 `dsh-credentials` provider:形如 `PI2DSH_OAUTH_<PROVIDER>` 的引用每次请求都从 `auth.json` 解析(途中跑刷新轮换),其余引用回落环境变量。把官方 `@deepseek-ai/dsh-llm-pi-ai` 的 route 指向它,`ctx.llm.stream()` 就跑在你的订阅上:
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
- id: llm
|
|
111
|
+
name: '@deepseek-ai/dsh-llm-pi-ai'
|
|
112
|
+
config:
|
|
113
|
+
providers:
|
|
114
|
+
openai-codex:
|
|
115
|
+
apiKeyEnv: PI2DSH_OAUTH_OPENAI_CODEX
|
|
116
|
+
models:
|
|
117
|
+
- id: gpt-5.6-luna
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
两层都已用真实 ChatGPT Pro 账号验证:浏览器授权 → 回调 → 换 token → 落盘 → 可刷新的 key(`scripts/verify-oauth-e2e.mjs`),然后 credentials provider → 官方 pi-ai route → DSH 原生 `ctx.llm.stream()` → 订阅上的真实模型回复(`scripts/verify-oauth-llm-e2e.mjs`)。需要代理的网络下两个脚本都尊重 `HTTPS_PROXY`。
|
|
106
121
|
|
|
107
122
|
## 兼容边界(显式声明,绝不静默)
|
|
108
123
|
|
package/dist/compat/pi-ai.d.mts
CHANGED
|
@@ -331,6 +331,15 @@ declare const loadOpenAICodexOAuth: () => Promise<unknown>;
|
|
|
331
331
|
declare const loadAnthropicOAuth: () => Promise<unknown>;
|
|
332
332
|
declare const loadGitHubCopilotOAuth: () => Promise<unknown>;
|
|
333
333
|
declare const loadKimiCodingOAuth: () => Promise<unknown>;
|
|
334
|
+
interface CompatApiProvider {
|
|
335
|
+
api: string;
|
|
336
|
+
stream: (...args: unknown[]) => unknown;
|
|
337
|
+
streamSimple: (...args: unknown[]) => unknown;
|
|
338
|
+
}
|
|
339
|
+
declare function registerApiProvider(provider: CompatApiProvider, sourceId?: string): void;
|
|
340
|
+
declare function getApiProvider(api: string): CompatApiProvider | undefined;
|
|
341
|
+
declare function getApiProviders(): CompatApiProvider[];
|
|
342
|
+
declare function unregisterApiProviders(sourceId: string): void;
|
|
334
343
|
declare function complete(..._args: unknown[]): never;
|
|
335
344
|
declare function stream(..._args: unknown[]): never;
|
|
336
345
|
interface StringEnumOptions<T extends readonly string[]> {
|
|
@@ -344,5 +353,5 @@ declare function StringEnum<T extends readonly string[]>(values: T, options?: St
|
|
|
344
353
|
default?: T[number];
|
|
345
354
|
};
|
|
346
355
|
//#endregion
|
|
347
|
-
export { type AgentMessage, Api, type AssistantMessage, AssistantMessageEventStream, type ImageContent, type Message, Model, ModelThinkingLevel, ModelsError, type Static, StringEnum, StringEnumOptions, type TSchema, type TextContent, type ThinkingContent, ThinkingLevel, ThinkingLevelMap, type ToolCallContent, type ToolResultMessage, typebox_d_exports as Type, type Usage, type UserMessage, anthropicMessagesApi, anthropicOAuth, builtinProviders, clampThinkingLevel, complete, contentText, createProvider, generatePKCE, getModel, getModels, getProvider, getProviders, getSupportedThinkingLevels, githubCopilotOAuth, isContextOverflow, isRecoverableLength, isRetryableAssistantError, kimiCodingOAuth, lazyApi, lazyStream, loadAnthropicOAuth, loadGitHubCopilotOAuth, loadKimiCodingOAuth, loadOpenAICodexOAuth, modelsAreEqual, openAICompletionsApi, openAIResponsesApi, openaiCodexOAuth, pollOAuthDeviceCodeFlow, registerProvider, stream, uuidv7 };
|
|
356
|
+
export { type AgentMessage, Api, type AssistantMessage, AssistantMessageEventStream, type ImageContent, type Message, Model, ModelThinkingLevel, ModelsError, type Static, StringEnum, StringEnumOptions, type TSchema, type TextContent, type ThinkingContent, ThinkingLevel, ThinkingLevelMap, type ToolCallContent, type ToolResultMessage, typebox_d_exports as Type, type Usage, type UserMessage, anthropicMessagesApi, anthropicOAuth, builtinProviders, clampThinkingLevel, complete, contentText, createProvider, generatePKCE, getApiProvider, getApiProviders, getModel, getModels, getProvider, getProviders, getSupportedThinkingLevels, githubCopilotOAuth, isContextOverflow, isRecoverableLength, isRetryableAssistantError, kimiCodingOAuth, lazyApi, lazyStream, loadAnthropicOAuth, loadGitHubCopilotOAuth, loadKimiCodingOAuth, loadOpenAICodexOAuth, modelsAreEqual, openAICompletionsApi, openAIResponsesApi, openaiCodexOAuth, pollOAuthDeviceCodeFlow, registerApiProvider, registerProvider, stream, unregisterApiProviders, uuidv7 };
|
|
348
357
|
//# sourceMappingURL=pi-ai.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-ai.d.mts","names":[],"sources":["../../node_modules/.pnpm/typebox@1.3.13/node_modules/typebox/build/type/types/_refine.d.mts","../../node_modules/.pnpm/typebox@1.3.13/node_modules/typebox/build/type/script/script.d.mts","../../node_modules/.pnpm/typebox@1.3.13/node_modules/typebox/build/typebox.d.mts","../../src/compat/vendor/pi-ai-overflow.ts","../../src/compat/vendor/pi-ai-retry.ts","../../src/compat/vendor/pi-uuid.ts","../../src/compat/vendor/pi-ai-provider.ts","../../src/compat/vendor/pi-ai-event-stream.ts","../../src/compat/vendor/pi-ai-lazy.ts","../../src/compat/vendor/pi-oauth-flows/openai-codex.ts","../../src/compat/vendor/pi-oauth-flows/anthropic.ts","../../src/compat/vendor/pi-oauth-flows/github-copilot.ts","../../src/compat/vendor/pi-oauth-flows/kimi-coding.ts","../../src/compat/vendor/pi-oauth-flows/pkce.ts","../../src/compat/vendor/pi-oauth-flows/device-code.ts","../../src/compat/pi-ai.ts"],"x_google_ignoreList":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OxB,KAAK;EAgBL,IAAI;GAWI,OAAO,kBAAc;EAgB7B,UAAM;;cAIG,oCAAoC;EAAA;;;;;;;;;iBC5BjC,WAAW,YAAO,aAAK;iBAWvB,QAAQ,WAAM;sDAAd;4DAAA;;;;cC2XH;;;;;;;;;;;;;;;;;;;;;;;iBC7OE,eAAe,mBAAW;;;;;;cA+G5B;;;;;;;;;;;;;;;;iBCvBE,mBAAmB,mBAAW;;;;;;;;cAoChC;;;;;;;;;;;;;;;;;;;;iBC7EE,gBAAgB,mBAAW;;;;;;cAa7B;;;;;;;;;;;;;;;;;;;;;;;iBCrOS,gBAAY;;;;;;iBCOZ,wBAAwB,eAAO;;;KCDzC;KACA,6BAA6B;KAC7B,mBAAmB,QAAQ,OAAO;KAClC;UAEK,MAAM,aAAa,MAAM;EACxC;EACA;EACA,MAAM;EACN;EACA;EACA;EACA,mBAAmB;EACnB;EACA;EACA;GACC;;iBAKa,2BAA2B,aAAa,KAAK,OAAO,MAAM,QAAQ;iBASlE,mBAAmB,aAAa,KAC9C,OAAO,MAAM,OACb,OAAO,qBACN;iBAgBa,eAAe,aAAa,KAC1C,GAAG,MAAM,0BACT,GAAG,MAAM;UAMD;EACR;EACA;GACC;;iBAGa,YAAY,2BAA2B,kBAAkB;iBAazD,iBAAiB,cAAc;iBAM/B;iBAIA,YAAY;iBAIZ,SAAS,mBAAmB;iBAI5B,UAAU;iBAoBV;iBAIA;iBAIA;iBAwBA,oBAAoB;EAAQ;EAAY;EAAc;EAAa;EAAiB;EAAiB;IAAQ;;;cAYhH,4BAAiC;cACjC,0BAA+B;cAC/B,8BAAmC;cACnC,2BAAgC;
|
|
1
|
+
{"version":3,"file":"pi-ai.d.mts","names":[],"sources":["../../node_modules/.pnpm/typebox@1.3.13/node_modules/typebox/build/type/types/_refine.d.mts","../../node_modules/.pnpm/typebox@1.3.13/node_modules/typebox/build/type/script/script.d.mts","../../node_modules/.pnpm/typebox@1.3.13/node_modules/typebox/build/typebox.d.mts","../../src/compat/vendor/pi-ai-overflow.ts","../../src/compat/vendor/pi-ai-retry.ts","../../src/compat/vendor/pi-uuid.ts","../../src/compat/vendor/pi-ai-provider.ts","../../src/compat/vendor/pi-ai-event-stream.ts","../../src/compat/vendor/pi-ai-lazy.ts","../../src/compat/vendor/pi-oauth-flows/openai-codex.ts","../../src/compat/vendor/pi-oauth-flows/anthropic.ts","../../src/compat/vendor/pi-oauth-flows/github-copilot.ts","../../src/compat/vendor/pi-oauth-flows/kimi-coding.ts","../../src/compat/vendor/pi-oauth-flows/pkce.ts","../../src/compat/vendor/pi-oauth-flows/device-code.ts","../../src/compat/pi-ai.ts"],"x_google_ignoreList":[0,1,2],"mappings":";;;;KAGY,WAAW,aAAa,UAAU,oCAAoC,OAAO,OAAO,QAAQ;;KAI5F,QAAQ,aAAa,UAAU,YAAY;EACnD,WAAW;;KAEH,qBAAqB,oCAAoC,OAAO;KAChE,qBAAqB,oCAAoC,OAAO;UAC3D,YAAY;EACzB,OAAO,qBAAqB;EAC5B,OAAO,qBAAqB;;;iBAGR,OAAO,aAAa,SAAS,QAAQ,OAAO,OAAO,MAAM,MAAM,OAAO,qBAAqB,QAAQ,OAAO,qBAAqB,SAAS,WAAW;;iBAEnJ,OAAO,aAAa,SAAS,QAAQ,OAAO,OAAO,MAAM,MAAM,OAAO,qBAAqB,SAAS,WAAW;;iBAI/G,SAAS,iBAAiB,SAAS;;;KClB/C,iBAAiB,gBAAgB,oBAAoB,iBAAiB,iBAAiB,iBAAiB;;KAExG,QAAQ,gBAAgB,aAAa,yBAAyB,UAAe,sBAAsB,aAAa,mBAAmB,iBAAiB,SAAS,gBAAgB,QAAQ;;iBAEzK,OAAO,uBAAuB,OAAO,SAAS,YAAY;;iBAE1D,OAAO,gBAAgB,aAAa,uBAAuB,SAAS,SAAS,OAAO,SAAS,QAAQ,SAAS;;iBAE9G,OAAO,uBAAuB,OAAO,QAAQ,SAAS,iBAAiB,YAAY;;iBAEnF,OAAO,gBAAgB,aAAa,uBAAuB,S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