pi2dsh 0.5.0 → 0.6.0
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 +37 -14
- package/README.zh.md +32 -14
- package/cordis.patch.yml +3 -0
- package/dist/cli.mjs +1 -1
- package/dist/compat/pi-ai.mjs +1 -1
- package/dist/compat/pi-coding-agent.mjs +1 -1
- package/dist/credentials-oauth.mjs +3 -3
- package/dist/host.mjs +2 -2
- package/dist/index.d.mts +30 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +98 -2
- package/dist/index.mjs.map +1 -0
- package/dist/{mcp-config-ByUc0jmD.mjs → mcp-config-vU1LZ7fC.mjs} +4 -4
- package/dist/{mcp-config-ByUc0jmD.mjs.map → mcp-config-vU1LZ7fC.mjs.map} +1 -1
- package/dist/{oauth-bridge-C6fL1qSv.mjs → oauth-bridge-CfyImWx4.mjs} +2 -2
- package/dist/{oauth-bridge-C6fL1qSv.mjs.map → oauth-bridge-CfyImWx4.mjs.map} +1 -1
- package/dist/{pi-ai-B_88Wb0r.mjs → pi-ai-7HR3ciAs.mjs} +4 -42
- package/dist/{pi-ai-B_88Wb0r.mjs.map → pi-ai-7HR3ciAs.mjs.map} +1 -1
- package/dist/{pi-coding-agent-C9Y9ql5E.mjs → pi-coding-agent-CznNsOnV.mjs} +2 -2
- package/dist/{pi-coding-agent-C9Y9ql5E.mjs.map → pi-coding-agent-CznNsOnV.mjs.map} +1 -1
- package/dist/{runtime-VK4eVnYa.mjs → runtime-xNd10ACP.mjs} +44 -19
- package/dist/runtime-xNd10ACP.mjs.map +1 -0
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +1 -1
- package/package.json +9 -2
- package/dist/all-DSpxKvHa.mjs +0 -28512
- package/dist/all-DSpxKvHa.mjs.map +0 -1
- package/dist/anthropic-messages-BL9N1Idv.mjs +0 -6438
- package/dist/anthropic-messages-BL9N1Idv.mjs.map +0 -1
- package/dist/azure-openai-responses-A67VbaZ1.mjs +0 -209
- package/dist/azure-openai-responses-A67VbaZ1.mjs.map +0 -1
- package/dist/deferred-tools-BD4g5QUx.mjs +0 -32
- package/dist/deferred-tools-BD4g5QUx.mjs.map +0 -1
- package/dist/diagnostics-CJye1UFh.mjs +0 -99
- package/dist/diagnostics-CJye1UFh.mjs.map +0 -1
- package/dist/dist-BYA74yh_.mjs +0 -1246
- package/dist/dist-BYA74yh_.mjs.map +0 -1
- package/dist/dist-DeonWo7m.mjs +0 -1089
- package/dist/dist-DeonWo7m.mjs.map +0 -1
- package/dist/error-body-DKA3lknR.mjs +0 -104
- package/dist/error-body-DKA3lknR.mjs.map +0 -1
- package/dist/github-copilot-headers-CZo2QHrt.mjs +0 -25
- package/dist/github-copilot-headers-CZo2QHrt.mjs.map +0 -1
- package/dist/google-generative-ai-DT5S8D8y.mjs +0 -358
- package/dist/google-generative-ai-DT5S8D8y.mjs.map +0 -1
- package/dist/google-shared-DYP_9cnK.mjs +0 -29042
- package/dist/google-shared-DYP_9cnK.mjs.map +0 -1
- package/dist/google-vertex-Dpq7O7Be.mjs +0 -402
- package/dist/google-vertex-Dpq7O7Be.mjs.map +0 -1
- package/dist/hash-Dbggamac.mjs +0 -19
- package/dist/hash-Dbggamac.mjs.map +0 -1
- package/dist/headers-CPzZhJQn.mjs +0 -17
- package/dist/headers-CPzZhJQn.mjs.map +0 -1
- package/dist/images-models-DJtHo9Rp.mjs +0 -1068
- package/dist/images-models-DJtHo9Rp.mjs.map +0 -1
- package/dist/json-parse-Dz5sKMTv.mjs +0 -384
- package/dist/json-parse-Dz5sKMTv.mjs.map +0 -1
- package/dist/mistral-conversations-BsxbCCWx.mjs +0 -42007
- package/dist/mistral-conversations-BsxbCCWx.mjs.map +0 -1
- package/dist/multipart-parser-woKCuALW.mjs +0 -301
- package/dist/multipart-parser-woKCuALW.mjs.map +0 -1
- package/dist/openai-DkzRh5_G.mjs +0 -6732
- package/dist/openai-DkzRh5_G.mjs.map +0 -1
- package/dist/openai-codex-responses-C7vviVT2.mjs +0 -1169
- package/dist/openai-codex-responses-C7vviVT2.mjs.map +0 -1
- package/dist/openai-completions-By8QNX1P.mjs +0 -947
- package/dist/openai-completions-By8QNX1P.mjs.map +0 -1
- package/dist/openai-prompt-cache-BDWtZRKh.mjs +0 -11
- package/dist/openai-prompt-cache-BDWtZRKh.mjs.map +0 -1
- package/dist/openai-responses-DboJUcFN.mjs +0 -247
- package/dist/openai-responses-DboJUcFN.mjs.map +0 -1
- package/dist/openai-responses-shared-BDzn7nJY.mjs +0 -572
- package/dist/openai-responses-shared-BDzn7nJY.mjs.map +0 -1
- package/dist/openrouter-images-fG3Aj6M4.mjs +0 -127
- package/dist/openrouter-images-fG3Aj6M4.mjs.map +0 -1
- package/dist/otel-PimLMoiV.mjs +0 -24935
- package/dist/otel-PimLMoiV.mjs.map +0 -1
- package/dist/pi-messages-B-7Xo_I0.mjs +0 -306
- package/dist/pi-messages-B-7Xo_I0.mjs.map +0 -1
- package/dist/provider-env-D-cCRWzv.mjs +0 -40
- package/dist/provider-env-D-cCRWzv.mjs.map +0 -1
- package/dist/provider-retry-Cw6YJ4cr.mjs +0 -80
- package/dist/provider-retry-Cw6YJ4cr.mjs.map +0 -1
- package/dist/runtime-VK4eVnYa.mjs.map +0 -1
- package/dist/sanitize-unicode-wLA11KvZ.mjs +0 -29
- package/dist/sanitize-unicode-wLA11KvZ.mjs.map +0 -1
- package/dist/src-BEl3QrGL.mjs +0 -5031
- package/dist/src-BEl3QrGL.mjs.map +0 -1
- package/dist/transform-messages-DGq9mvhA.mjs +0 -379
- package/dist/transform-messages-DGq9mvhA.mjs.map +0 -1
- package/dist/uuid-DtFT7tOE.mjs +0 -65
- package/dist/uuid-DtFT7tOE.mjs.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
import { C as realBuiltinProvider, R as AssistantMessageEventStream, S as openAIResponsesApi, a as builtinProviders, i as anthropicMessagesApi, r as __setPiAiLlmBridge, x as openAICompletionsApi } from "./pi-ai-
|
|
2
|
+
import { C as realBuiltinProvider, R as AssistantMessageEventStream, S as openAIResponsesApi, a as builtinProviders, i as anthropicMessagesApi, r as __setPiAiLlmBridge, x as openAICompletionsApi } from "./pi-ai-7HR3ciAs.mjs";
|
|
3
3
|
import { r as normalizePath, t as getAgentDir } from "./pi-config-shim-CZ1wFzqM.mjs";
|
|
4
|
-
import { E as __setSubagentSessionFactory, S as Theme, f as ExtensionRunner } from "./pi-coding-agent-
|
|
5
|
-
import { a as resolvePiProviderAuth, n as loginPiProvider, r as providerSupportsOAuth, t as FileCredentialStore } from "./oauth-bridge-
|
|
4
|
+
import { E as __setSubagentSessionFactory, S as Theme, f as ExtensionRunner } from "./pi-coding-agent-CznNsOnV.mjs";
|
|
5
|
+
import { a as resolvePiProviderAuth, n as loginPiProvider, r as providerSupportsOAuth, t as FileCredentialStore } from "./oauth-bridge-CfyImWx4.mjs";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
8
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
8
9
|
import { join } from "node:path";
|
|
9
10
|
import { fileURLToPath } from "node:url";
|
|
10
|
-
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
11
11
|
import { tmpdir } from "node:os";
|
|
12
12
|
import { EventEmitter } from "node:events";
|
|
13
13
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -2629,7 +2629,7 @@ function contextFor(ctx, state, agent, signal, command = false) {
|
|
|
2629
2629
|
return provider.length > 0 && providerSupportsOAuth(providerConfig(provider));
|
|
2630
2630
|
},
|
|
2631
2631
|
refresh: async () => {
|
|
2632
|
-
await reloadModelsJson(ctx, state);
|
|
2632
|
+
await reloadModelsJson(ctx, state, true);
|
|
2633
2633
|
await catalog?.refresh();
|
|
2634
2634
|
return {
|
|
2635
2635
|
models: allModels(),
|
|
@@ -3167,11 +3167,30 @@ async function collectPiImages(ctx, messages) {
|
|
|
3167
3167
|
return images;
|
|
3168
3168
|
}
|
|
3169
3169
|
function oauthStoreOf(state) {
|
|
3170
|
-
state.oauthStore ??= new FileCredentialStore(join(getAgentDir(), "auth.json"));
|
|
3171
|
-
return state.oauthStore;
|
|
3170
|
+
state.shared.oauthStore ??= new FileCredentialStore(join(getAgentDir(), "auth.json"));
|
|
3171
|
+
return state.shared.oauthStore;
|
|
3172
3172
|
}
|
|
3173
3173
|
const MODELS_JSON_ROUTE_PREFIX = "models.json/";
|
|
3174
|
-
|
|
3174
|
+
const SHARED_HOST_STATE = /* @__PURE__ */ new WeakMap();
|
|
3175
|
+
function sharedHostStateOf(ctx) {
|
|
3176
|
+
const key = ctx.root ?? ctx;
|
|
3177
|
+
let shared = SHARED_HOST_STATE.get(key);
|
|
3178
|
+
if (shared === void 0) {
|
|
3179
|
+
shared = {
|
|
3180
|
+
modelsJsonProviders: /* @__PURE__ */ new Map(),
|
|
3181
|
+
companionRoutes: /* @__PURE__ */ new Map(),
|
|
3182
|
+
providerRouteDisposers: /* @__PURE__ */ new Map(),
|
|
3183
|
+
providers: /* @__PURE__ */ new Map()
|
|
3184
|
+
};
|
|
3185
|
+
SHARED_HOST_STATE.set(key, shared);
|
|
3186
|
+
}
|
|
3187
|
+
return shared;
|
|
3188
|
+
}
|
|
3189
|
+
async function reloadModelsJson(ctx, state, force = false) {
|
|
3190
|
+
if (!force && state.shared.modelsJson !== void 0) {
|
|
3191
|
+
state.modelsJson = state.shared.modelsJson;
|
|
3192
|
+
return;
|
|
3193
|
+
}
|
|
3175
3194
|
for (const [key, dispose] of state.providerRouteDisposers) {
|
|
3176
3195
|
if (!key.startsWith(MODELS_JSON_ROUTE_PREFIX)) continue;
|
|
3177
3196
|
state.providerRouteDisposers.delete(key);
|
|
@@ -3180,6 +3199,7 @@ async function reloadModelsJson(ctx, state) {
|
|
|
3180
3199
|
state.modelsJsonProviders.clear();
|
|
3181
3200
|
state.companionRoutes.clear();
|
|
3182
3201
|
state.modelsJson = await loadModelsJsonSnapshot(realBuiltinProvider);
|
|
3202
|
+
state.shared.modelsJson = state.modelsJson;
|
|
3183
3203
|
for (const problem of state.modelsJson.errors) logger(ctx).warn(`[pi2dsh] models.json: ${problem}`);
|
|
3184
3204
|
for (const [providerId, providerConfig] of state.modelsJson.providers) {
|
|
3185
3205
|
const models = state.modelsJson.models.filter((model) => model.provider === providerId);
|
|
@@ -3260,8 +3280,8 @@ async function materializeAttachmentImage(ctx, attachment) {
|
|
|
3260
3280
|
}
|
|
3261
3281
|
}
|
|
3262
3282
|
function ensureLoginCommand(ctx, state) {
|
|
3263
|
-
if (state.
|
|
3264
|
-
state.
|
|
3283
|
+
if (state.shared.loginRegistered === true) return;
|
|
3284
|
+
state.shared.loginRegistered = true;
|
|
3265
3285
|
try {
|
|
3266
3286
|
registerLoginCommand(ctx, state);
|
|
3267
3287
|
} catch (error) {
|
|
@@ -3829,7 +3849,9 @@ async function applyPiPackage(ctx, options) {
|
|
|
3829
3849
|
origin: "package"
|
|
3830
3850
|
}
|
|
3831
3851
|
}));
|
|
3852
|
+
const shared = sharedHostStateOf(ctx);
|
|
3832
3853
|
const state = {
|
|
3854
|
+
shared,
|
|
3833
3855
|
handlers: /* @__PURE__ */ new Map(),
|
|
3834
3856
|
tools: runtimeTools,
|
|
3835
3857
|
runner: new ExtensionRunner(piToolRecords),
|
|
@@ -3837,8 +3859,8 @@ async function applyPiPackage(ctx, options) {
|
|
|
3837
3859
|
toolRestrictions: /* @__PURE__ */ new WeakMap(),
|
|
3838
3860
|
commands: /* @__PURE__ */ new Map(),
|
|
3839
3861
|
commandDisposers: /* @__PURE__ */ new Map(),
|
|
3840
|
-
modelsJsonProviders:
|
|
3841
|
-
companionRoutes:
|
|
3862
|
+
modelsJsonProviders: shared.modelsJsonProviders,
|
|
3863
|
+
companionRoutes: shared.companionRoutes,
|
|
3842
3864
|
flags: /* @__PURE__ */ new Map(),
|
|
3843
3865
|
notifications: [],
|
|
3844
3866
|
activeAgents: /* @__PURE__ */ new Set(),
|
|
@@ -3852,7 +3874,7 @@ async function applyPiPackage(ctx, options) {
|
|
|
3852
3874
|
shortcuts: /* @__PURE__ */ new Map(),
|
|
3853
3875
|
messageRenderers: /* @__PURE__ */ new Map(),
|
|
3854
3876
|
entryRenderers: /* @__PURE__ */ new Map(),
|
|
3855
|
-
providers:
|
|
3877
|
+
providers: shared.providers,
|
|
3856
3878
|
autocompleteProviders: [],
|
|
3857
3879
|
editorBuffers: /* @__PURE__ */ new WeakMap(),
|
|
3858
3880
|
toolsExpanded: false,
|
|
@@ -3863,7 +3885,7 @@ async function applyPiPackage(ctx, options) {
|
|
|
3863
3885
|
argMutations: /* @__PURE__ */ new WeakMap(),
|
|
3864
3886
|
streamingTexts: /* @__PURE__ */ new Map(),
|
|
3865
3887
|
lastLoggedModels: /* @__PURE__ */ new WeakMap(),
|
|
3866
|
-
providerRouteDisposers:
|
|
3888
|
+
providerRouteDisposers: shared.providerRouteDisposers
|
|
3867
3889
|
};
|
|
3868
3890
|
subscribeLifecycle(ctx, state);
|
|
3869
3891
|
subscribeInterceptors(ctx, state);
|
|
@@ -3886,12 +3908,15 @@ async function applyPiPackage(ctx, options) {
|
|
|
3886
3908
|
}
|
|
3887
3909
|
}
|
|
3888
3910
|
const llm = llmOf(ctx);
|
|
3889
|
-
state.modelCatalog = new ModelCatalog(llm);
|
|
3911
|
+
state.modelCatalog = shared.modelCatalog ??= new ModelCatalog(llm);
|
|
3890
3912
|
await reloadModelsJson(ctx, state);
|
|
3891
3913
|
if (llm !== void 0) {
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3914
|
+
if (shared.catalogSubscribed !== true) {
|
|
3915
|
+
shared.catalogSubscribed = true;
|
|
3916
|
+
ctx.on("llm/adapters-updated", () => {
|
|
3917
|
+
shared.modelCatalog?.refresh();
|
|
3918
|
+
});
|
|
3919
|
+
}
|
|
3895
3920
|
await state.modelCatalog.refresh();
|
|
3896
3921
|
__setPiAiLlmBridge((model, context, callOptions) => streamViaDshLlm(llm, {
|
|
3897
3922
|
model,
|
|
@@ -3933,4 +3958,4 @@ const runtimeInternals = {
|
|
|
3933
3958
|
//#endregion
|
|
3934
3959
|
export { normalizeToolSchema as n, runtimeInternals as r, applyPiPackage as t };
|
|
3935
3960
|
|
|
3936
|
-
//# sourceMappingURL=runtime-
|
|
3961
|
+
//# sourceMappingURL=runtime-xNd10ACP.mjs.map
|