pi2dsh 0.12.4 → 0.13.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 +73 -12
- package/README.zh.md +61 -10
- package/dist/{analyzer-CXNbeBAe.mjs → analyzer-CJFwQlSG.mjs} +2 -2
- package/dist/{analyzer-CXNbeBAe.mjs.map → analyzer-CJFwQlSG.mjs.map} +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/client.js +187 -0
- package/dist/compat/pi-ai.d.mts +2281 -5
- package/dist/compat/pi-ai.d.mts.map +1 -1
- package/dist/compat/pi-ai.mjs +2 -2
- package/dist/compat/pi-coding-agent.mjs +1 -1
- package/dist/{credentials-oauth-BakY-0PA.mjs → credentials-oauth-Txs6oew8.mjs} +13 -6
- package/dist/credentials-oauth-Txs6oew8.mjs.map +1 -0
- package/dist/credentials-oauth.mjs +1 -1
- package/dist/host.mjs +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{mcp-config-CZepacin.mjs → mcp-config-_idn-pzI.mjs} +8 -7
- package/dist/mcp-config-_idn-pzI.mjs.map +1 -0
- package/dist/pi-ai-D7PqVeWs.mjs +11717 -0
- package/dist/pi-ai-D7PqVeWs.mjs.map +1 -0
- package/dist/{pi-coding-agent-D9skobb6.mjs → pi-coding-agent-BVZu0dHG.mjs} +0 -0
- package/dist/{pi-coding-agent-D9skobb6.mjs.map → pi-coding-agent-BVZu0dHG.mjs.map} +1 -1
- package/dist/{runtime-DH0zEUpu.mjs → runtime-DEjs_Qlf.mjs} +176 -23
- package/dist/runtime-DEjs_Qlf.mjs.map +1 -0
- package/dist/runtime.d.mts +6 -0
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +1 -1
- package/package.json +31 -32
- package/dist/credentials-oauth-BakY-0PA.mjs.map +0 -1
- package/dist/mcp-config-CZepacin.mjs.map +0 -1
- package/dist/pi-ai-BA3V_J0V.mjs +0 -3104
- package/dist/pi-ai-BA3V_J0V.mjs.map +0 -1
- package/dist/runtime-DH0zEUpu.mjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import { P as generateBranchSummary, Tn as PiCapabilityError, b as Theme, d as ExtensionRunner, w as __setSubagentSessionFactory, wn as CapabilityLedger } from "./pi-coding-agent-
|
|
2
|
+
import { X as isContextOverflow, Y as AssistantMessageEventStream, c as builtinProviders, i as __setPiAiLlmBridge, x as getSupportedThinkingLevels } from "./pi-ai-D7PqVeWs.mjs";
|
|
3
|
+
import { P as generateBranchSummary, Tn as PiCapabilityError, b as Theme, d as ExtensionRunner, w as __setSubagentSessionFactory, wn as CapabilityLedger } from "./pi-coding-agent-BVZu0dHG.mjs";
|
|
4
4
|
import { t as getAgentDir } from "./pi-config-shim-CZ1wFzqM.mjs";
|
|
5
|
-
import { a as FileCredentialStore, c as providerSupportsOAuth, i as oauthCredentialRef, l as resolvePiProviderAuth, o as joinSignals, s as loginPiProvider, u as storedOAuthCredential } from "./credentials-oauth-
|
|
5
|
+
import { a as FileCredentialStore, c as providerSupportsOAuth, i as oauthCredentialRef, l as resolvePiProviderAuth, o as joinSignals, s as loginPiProvider, u as storedOAuthCredential } from "./credentials-oauth-Txs6oew8.mjs";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
8
8
|
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
@@ -786,6 +786,15 @@ var BrowserSurfaces = class {
|
|
|
786
786
|
#draftRequests = /* @__PURE__ */ new Map();
|
|
787
787
|
#liveDrafts = /* @__PURE__ */ new Map();
|
|
788
788
|
#completionSources = /* @__PURE__ */ new Map();
|
|
789
|
+
#imageToolNames = /* @__PURE__ */ new Set();
|
|
790
|
+
/** Register one known image tool's exact DSH wire name. */
|
|
791
|
+
registerImageTool(name) {
|
|
792
|
+
if (name.length > 0) this.#imageToolNames.add(name);
|
|
793
|
+
}
|
|
794
|
+
/** Exact wire names needing the generic Pi image-result browser view. */
|
|
795
|
+
imageToolNames() {
|
|
796
|
+
return [...this.#imageToolNames];
|
|
797
|
+
}
|
|
789
798
|
/**
|
|
790
799
|
* Track one child session under its parent.
|
|
791
800
|
* @param parentSessionId - the session the panel floats over.
|
|
@@ -1158,6 +1167,14 @@ function registerBrowserSurfaceRoute(ctx, registry) {
|
|
|
1158
1167
|
response.end(JSON.stringify({ items }));
|
|
1159
1168
|
return;
|
|
1160
1169
|
}
|
|
1170
|
+
if (url.pathname === "/pi2dsh/image-tool-names") {
|
|
1171
|
+
response.writeHead(200, {
|
|
1172
|
+
"content-type": "application/json; charset=utf-8",
|
|
1173
|
+
"cache-control": "no-store"
|
|
1174
|
+
});
|
|
1175
|
+
response.end(method === "HEAD" ? void 0 : JSON.stringify({ names: registry.imageToolNames() }));
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1161
1178
|
if (url.pathname !== "/pi2dsh/browser-state") {
|
|
1162
1179
|
response.writeHead(404);
|
|
1163
1180
|
response.end();
|
|
@@ -2277,6 +2294,11 @@ function piProviderDshAdapter(providerId, provider, host) {
|
|
|
2277
2294
|
...typeof options.maxTokens === "number" ? { maxTokens: options.maxTokens } : {},
|
|
2278
2295
|
...typeof options.temperature === "number" ? { temperature: options.temperature } : {},
|
|
2279
2296
|
...typeof options.sessionId === "string" ? { sessionId: options.sessionId } : {},
|
|
2297
|
+
...host.beforeProviderRequest === void 0 ? {} : { onPayload: (payload) => host.beforeProviderRequest(payload, {
|
|
2298
|
+
provider: providerId,
|
|
2299
|
+
model,
|
|
2300
|
+
...options.signal instanceof AbortSignal ? { signal: options.signal } : {}
|
|
2301
|
+
}) },
|
|
2280
2302
|
...effort === void 0 || effort === "off" ? {} : { reasoning: effort }
|
|
2281
2303
|
};
|
|
2282
2304
|
const contextWindow = typeof model.contextWindow === "number" ? model.contextWindow : void 0;
|
|
@@ -2382,9 +2404,98 @@ const DSH_THINKING_FORMATS = /* @__PURE__ */ new Set([
|
|
|
2382
2404
|
"together",
|
|
2383
2405
|
"zai",
|
|
2384
2406
|
"qwen",
|
|
2407
|
+
"chat-template",
|
|
2408
|
+
"qwen-chat-template",
|
|
2385
2409
|
"string-thinking",
|
|
2386
2410
|
"ant-ling"
|
|
2387
2411
|
]);
|
|
2412
|
+
const DSH_MAX_TOKENS_FIELDS = /* @__PURE__ */ new Set(["max_completion_tokens", "max_tokens"]);
|
|
2413
|
+
const DSH_CACHE_CONTROL_FORMATS = /* @__PURE__ */ new Set(["anthropic"]);
|
|
2414
|
+
const DSH_CHAT_TEMPLATE_VARS = /* @__PURE__ */ new Set(["thinking.enabled", "thinking.effort"]);
|
|
2415
|
+
const COMPLETIONS = /* @__PURE__ */ new Set(["openai-completions"]);
|
|
2416
|
+
const ANTHROPIC = /* @__PURE__ */ new Set(["anthropic-messages"]);
|
|
2417
|
+
const COMPLETIONS_AND_RESPONSES = /* @__PURE__ */ new Set(["openai-completions", "openai-responses"]);
|
|
2418
|
+
const DSH_COMPAT_FIELD_PROTOCOLS = {
|
|
2419
|
+
supportsStore: COMPLETIONS,
|
|
2420
|
+
supportsDeveloperRole: COMPLETIONS_AND_RESPONSES,
|
|
2421
|
+
supportsReasoningEffort: COMPLETIONS,
|
|
2422
|
+
supportsUsageInStreaming: COMPLETIONS,
|
|
2423
|
+
maxTokensField: COMPLETIONS,
|
|
2424
|
+
requiresToolResultName: COMPLETIONS,
|
|
2425
|
+
requiresAssistantAfterToolResult: COMPLETIONS,
|
|
2426
|
+
requiresThinkingAsText: COMPLETIONS,
|
|
2427
|
+
requiresReasoningContentOnAssistantMessages: COMPLETIONS,
|
|
2428
|
+
thinkingFormat: COMPLETIONS,
|
|
2429
|
+
chatTemplateKwargs: COMPLETIONS,
|
|
2430
|
+
supportsStrictMode: COMPLETIONS_AND_RESPONSES,
|
|
2431
|
+
cacheControlFormat: COMPLETIONS,
|
|
2432
|
+
supportsLongCacheRetention: new Set(DSH_PROTOCOLS),
|
|
2433
|
+
supportsEagerToolInputStreaming: ANTHROPIC,
|
|
2434
|
+
supportsCacheControlOnTools: ANTHROPIC,
|
|
2435
|
+
supportsTemperature: ANTHROPIC,
|
|
2436
|
+
forceAdaptiveThinking: ANTHROPIC,
|
|
2437
|
+
allowEmptySignature: ANTHROPIC,
|
|
2438
|
+
supportsStrictTools: ANTHROPIC
|
|
2439
|
+
};
|
|
2440
|
+
function recordOf(value) {
|
|
2441
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
2442
|
+
}
|
|
2443
|
+
function chatTemplateKwargsOf(value) {
|
|
2444
|
+
const input = recordOf(value);
|
|
2445
|
+
if (input === void 0) return void 0;
|
|
2446
|
+
const output = {};
|
|
2447
|
+
for (const [key, candidate] of Object.entries(input)) {
|
|
2448
|
+
if (candidate === null || typeof candidate === "string" || typeof candidate === "boolean" || typeof candidate === "number" && Number.isFinite(candidate)) {
|
|
2449
|
+
output[key] = candidate;
|
|
2450
|
+
continue;
|
|
2451
|
+
}
|
|
2452
|
+
const placeholder = recordOf(candidate);
|
|
2453
|
+
if (placeholder === void 0 || typeof placeholder.$var !== "string" || !DSH_CHAT_TEMPLATE_VARS.has(placeholder.$var) || placeholder.omitWhenOff !== void 0 && typeof placeholder.omitWhenOff !== "boolean") continue;
|
|
2454
|
+
output[key] = {
|
|
2455
|
+
$var: placeholder.$var,
|
|
2456
|
+
...typeof placeholder.omitWhenOff === "boolean" ? { omitWhenOff: placeholder.omitWhenOff } : {}
|
|
2457
|
+
};
|
|
2458
|
+
}
|
|
2459
|
+
return Object.keys(output).length === 0 ? void 0 : output;
|
|
2460
|
+
}
|
|
2461
|
+
/**
|
|
2462
|
+
* The part of Pi's model compat that rc.8's official adapter deliberately
|
|
2463
|
+
* offers for this protocol. Vendor-owned catalog switches remain withheld:
|
|
2464
|
+
* forwarding one unknown key rejects the entire settings section, so this is
|
|
2465
|
+
* an explicit field gate rather than a spread.
|
|
2466
|
+
*/
|
|
2467
|
+
function compatProfileOf(value, api) {
|
|
2468
|
+
const compat = recordOf(value);
|
|
2469
|
+
if (compat === void 0 || api === void 0) return {};
|
|
2470
|
+
const output = {};
|
|
2471
|
+
const fields = Object.entries(DSH_COMPAT_FIELD_PROTOCOLS);
|
|
2472
|
+
for (const [field, protocols] of fields) {
|
|
2473
|
+
if (!protocols.has(api)) continue;
|
|
2474
|
+
const candidate = compat[field];
|
|
2475
|
+
if (field === "maxTokensField") {
|
|
2476
|
+
if (typeof candidate === "string" && DSH_MAX_TOKENS_FIELDS.has(candidate)) output[field] = candidate;
|
|
2477
|
+
} else if (field === "thinkingFormat") {
|
|
2478
|
+
if (typeof candidate === "string" && DSH_THINKING_FORMATS.has(candidate)) output[field] = candidate;
|
|
2479
|
+
} else if (field === "chatTemplateKwargs") {
|
|
2480
|
+
const kwargs = chatTemplateKwargsOf(candidate);
|
|
2481
|
+
if (kwargs !== void 0) output[field] = kwargs;
|
|
2482
|
+
} else if (field === "cacheControlFormat") {
|
|
2483
|
+
if (typeof candidate === "string" && DSH_CACHE_CONTROL_FORMATS.has(candidate)) output[field] = candidate;
|
|
2484
|
+
} else if (typeof candidate === "boolean") output[field] = candidate;
|
|
2485
|
+
}
|
|
2486
|
+
return output;
|
|
2487
|
+
}
|
|
2488
|
+
function reasoningEffortsOf(model) {
|
|
2489
|
+
if (model.reasoning === false) return false;
|
|
2490
|
+
if (model.reasoning !== true) return void 0;
|
|
2491
|
+
const levelMap = recordOf(model.thinkingLevelMap);
|
|
2492
|
+
const efforts = {};
|
|
2493
|
+
for (const level of getSupportedThinkingLevels(model)) {
|
|
2494
|
+
const wire = levelMap?.[level];
|
|
2495
|
+
efforts[level] = level === "off" && wire === void 0 ? null : wire ?? level;
|
|
2496
|
+
}
|
|
2497
|
+
return Object.keys(efforts).some((level) => level !== "off") ? efforts : void 0;
|
|
2498
|
+
}
|
|
2388
2499
|
/** A positive whole number, or undefined — the profile schema rejects 0 and fractions. */
|
|
2389
2500
|
function wholeAbove(value) {
|
|
2390
2501
|
return typeof value === "number" && Number.isInteger(value) && value >= 1 ? value : void 0;
|
|
@@ -2394,23 +2505,17 @@ function wholeAbove(value) {
|
|
|
2394
2505
|
*
|
|
2395
2506
|
* Field by field on purpose. The two vocabularies overlap but do not match:
|
|
2396
2507
|
* Pi's `maxTokens` is routinely 0 for "unstated" while DSH requires at least 1,
|
|
2397
|
-
* Pi's `compat` carries gateway dialect flags DSH's profile has no slot for,
|
|
2398
2508
|
* and Pi's `reasoning` is a boolean where DSH's `reasoningEfforts` is a map of
|
|
2399
|
-
* offered levels.
|
|
2400
|
-
*
|
|
2509
|
+
* offered levels. rc.8 gives compat a real profile slot, but only for a gated
|
|
2510
|
+
* protocol-specific subset. Forwarding these objects verbatim still rejects
|
|
2511
|
+
* the whole settings section — one bad key takes down every route in it.
|
|
2401
2512
|
* @param model - the Pi model descriptor as its package declared it.
|
|
2402
|
-
* @param api - the wire protocol this route resolved to, which decides
|
|
2403
|
-
*
|
|
2513
|
+
* @param api - the wire protocol this route resolved to, which decides which
|
|
2514
|
+
* compat fields are legal to state.
|
|
2404
2515
|
*/
|
|
2405
2516
|
function modelProfileOf(model, api) {
|
|
2406
|
-
const
|
|
2407
|
-
const
|
|
2408
|
-
const thinkingFormat = reasoningCompatAllowed && typeof compat?.thinkingFormat === "string" && DSH_THINKING_FORMATS.has(compat.thinkingFormat) ? { thinkingFormat: compat.thinkingFormat } : {};
|
|
2409
|
-
const supportsReasoningEffort = reasoningCompatAllowed && typeof compat?.supportsReasoningEffort === "boolean" ? { supportsReasoningEffort: compat.supportsReasoningEffort } : {};
|
|
2410
|
-
const carriedCompat = {
|
|
2411
|
-
...thinkingFormat,
|
|
2412
|
-
...supportsReasoningEffort
|
|
2413
|
-
};
|
|
2517
|
+
const carriedCompat = compatProfileOf(model.compat, api);
|
|
2518
|
+
const reasoningEfforts = reasoningEffortsOf(model);
|
|
2414
2519
|
const input = Array.isArray(model.input) ? model.input.filter((entry) => typeof entry === "string" && DSH_MODALITIES.has(entry)) : [];
|
|
2415
2520
|
const contextWindow = wholeAbove(model.contextWindow);
|
|
2416
2521
|
const maxTokens = wholeAbove(model.maxTokens);
|
|
@@ -2420,6 +2525,7 @@ function modelProfileOf(model, api) {
|
|
|
2420
2525
|
...contextWindow === void 0 ? {} : { contextWindow },
|
|
2421
2526
|
...maxTokens === void 0 ? {} : { maxTokens },
|
|
2422
2527
|
...input.length === 0 ? {} : { input },
|
|
2528
|
+
...reasoningEfforts === void 0 ? {} : { reasoningEfforts },
|
|
2423
2529
|
...Object.keys(carriedCompat).length === 0 ? {} : { compat: carriedCompat }
|
|
2424
2530
|
};
|
|
2425
2531
|
}
|
|
@@ -2447,12 +2553,14 @@ function registerCatalogOnlyRoute(options) {
|
|
|
2447
2553
|
const apiKeyEnv = envReferenceOf(provider.apiKey);
|
|
2448
2554
|
const api = protocolOf(provider.api) ?? protocolOf(first.api);
|
|
2449
2555
|
const baseURL = typeof provider.baseUrl === "string" ? provider.baseUrl : typeof first.baseUrl === "string" ? first.baseUrl : void 0;
|
|
2556
|
+
const providerCompat = compatProfileOf(provider.compat, api);
|
|
2450
2557
|
return {
|
|
2451
2558
|
displayName: typeof provider.name === "string" ? provider.name : providerId,
|
|
2452
2559
|
...apiKeyEnv === void 0 ? {} : { apiKeyEnv },
|
|
2453
2560
|
...api === void 0 ? {} : { api },
|
|
2454
2561
|
...baseURL === void 0 ? {} : { baseURL },
|
|
2455
|
-
...
|
|
2562
|
+
...Object.keys(providerCompat).length === 0 ? {} : { compat: providerCompat },
|
|
2563
|
+
...models.length === 0 ? {} : { models: models.map((model) => modelProfileOf(model, api ?? protocolOf(model.api))) }
|
|
2456
2564
|
};
|
|
2457
2565
|
}, `[pi2dsh] Pi provider ${JSON.stringify(providerId)} declares a catalog only; DSH's official llm-pi-ai adapter now serves it as a native route`);
|
|
2458
2566
|
}
|
|
@@ -2549,6 +2657,10 @@ function registerPiProviderRoute(options) {
|
|
|
2549
2657
|
//#region src/runtime.ts
|
|
2550
2658
|
/** Fallback thread ids when a child session reports none. */
|
|
2551
2659
|
let sidePanelSerial = 0;
|
|
2660
|
+
const KNOWN_IMAGE_TOOLS_BY_PACKAGE = /* @__PURE__ */ new Map([["@crazygit/pi-codex-image-gen", /* @__PURE__ */ new Set(["codex_generate_image"])]]);
|
|
2661
|
+
function isKnownImageTool(packageName, toolName) {
|
|
2662
|
+
return KNOWN_IMAGE_TOOLS_BY_PACKAGE.get(packageName)?.has(toolName) === true;
|
|
2663
|
+
}
|
|
2552
2664
|
function logger(ctx) {
|
|
2553
2665
|
const candidate = ctx.logger;
|
|
2554
2666
|
return {
|
|
@@ -2916,6 +3028,14 @@ function contextFor(ctx, state, agent, signal, command = false, sessionOverride)
|
|
|
2916
3028
|
question: String(title),
|
|
2917
3029
|
...placeholder === void 0 ? {} : { detail: String(placeholder) }
|
|
2918
3030
|
}),
|
|
3031
|
+
deviceCode: async (title, detail, promptSignal) => {
|
|
3032
|
+
await askOne(ctx, agent, joinSignals(signal, promptSignal), {
|
|
3033
|
+
id: "pi2dsh-device-code",
|
|
3034
|
+
question: String(title),
|
|
3035
|
+
detail: String(detail),
|
|
3036
|
+
options: [{ label: "Cancel login" }]
|
|
3037
|
+
});
|
|
3038
|
+
},
|
|
2919
3039
|
editor: (title, prefill) => askOne(ctx, agent, signal, {
|
|
2920
3040
|
id: "pi2dsh-editor",
|
|
2921
3041
|
question: String(title),
|
|
@@ -3365,6 +3485,31 @@ async function dispatch(state, eventName, event, eventContext) {
|
|
|
3365
3485
|
return results;
|
|
3366
3486
|
}
|
|
3367
3487
|
/**
|
|
3488
|
+
* Pi's request-body event is a waterfall over the body the provider transport
|
|
3489
|
+
* will actually send. Only package-registered Pi transports expose that body
|
|
3490
|
+
* through SimpleStreamOptions.onPayload; native DSH adapters build it behind
|
|
3491
|
+
* their own boundary and never call this function.
|
|
3492
|
+
*/
|
|
3493
|
+
async function dispatchBeforeProviderRequest(ctx, state, payload, request) {
|
|
3494
|
+
let current = payload;
|
|
3495
|
+
const agent = currentAgent(state);
|
|
3496
|
+
const eventContext = contextFor(ctx, state, agent, request.signal);
|
|
3497
|
+
eventContext.model = {
|
|
3498
|
+
...request.model,
|
|
3499
|
+
provider: request.provider
|
|
3500
|
+
};
|
|
3501
|
+
for (const handler of state.handlers.get("before_provider_request") ?? []) try {
|
|
3502
|
+
const result = await state.agentScope.run(agent, () => handler({
|
|
3503
|
+
type: "before_provider_request",
|
|
3504
|
+
payload: current
|
|
3505
|
+
}, eventContext));
|
|
3506
|
+
if (result !== void 0 && typeof result === "object" && result !== null) current = result;
|
|
3507
|
+
} catch (error) {
|
|
3508
|
+
logger(ctx).warn(`[pi2dsh] before_provider_request handler failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
3509
|
+
}
|
|
3510
|
+
return current;
|
|
3511
|
+
}
|
|
3512
|
+
/**
|
|
3368
3513
|
* What triggered a compaction, in Pi's vocabulary.
|
|
3369
3514
|
*
|
|
3370
3515
|
* DSH's durable lifecycle events say two things about the trigger: a manual
|
|
@@ -4204,16 +4349,17 @@ async function supersedeActiveLogin(state) {
|
|
|
4204
4349
|
async function ensureLoggedInProviderRoute(ctx, state, name, config) {
|
|
4205
4350
|
if (!providerSupportsOAuth(config)) return false;
|
|
4206
4351
|
if (providerCarriesTransport(config) || state.providerRouteDisposers.has(name)) return false;
|
|
4207
|
-
|
|
4352
|
+
const alreadyRouted = llmOf(ctx)?.listProviders().some((provider) => provider.id === name) === true;
|
|
4208
4353
|
if (await storedOAuthCredential(oauthStoreOf(state), name).catch(() => void 0) === void 0) return false;
|
|
4354
|
+
const published = await publishOAuthCredential(ctx, state, name, config);
|
|
4355
|
+
if (!published.ok) return false;
|
|
4356
|
+
keepOAuthCredentialFresh(ctx, state);
|
|
4357
|
+
if (alreadyRouted) return false;
|
|
4209
4358
|
const settings = optionalService(ctx, "settings");
|
|
4210
4359
|
if (settings === void 0) {
|
|
4211
4360
|
logger(ctx).warn(`[pi2dsh] logged in to ${JSON.stringify(name)}, but this composition has no settings service to declare its model route in`);
|
|
4212
4361
|
return false;
|
|
4213
4362
|
}
|
|
4214
|
-
const published = await publishOAuthCredential(ctx, state, name, config);
|
|
4215
|
-
if (!published.ok) return false;
|
|
4216
|
-
keepOAuthCredentialFresh(ctx, state);
|
|
4217
4363
|
await settings.update("llm-pi-ai", { providers: { [name]: {
|
|
4218
4364
|
...typeof config.name === "string" ? { displayName: config.name } : {},
|
|
4219
4365
|
...published.baseUrl === void 0 ? {} : { baseURL: published.baseUrl },
|
|
@@ -4460,6 +4606,7 @@ function registerTool(ctx, state, tool) {
|
|
|
4460
4606
|
};
|
|
4461
4607
|
const dispose = ctx.tools.register(definition);
|
|
4462
4608
|
state.toolDisposers.set(tool.name, dispose);
|
|
4609
|
+
if (isKnownImageTool(state.packageName, tool.name)) state.shared.browserSurfaces?.registerImageTool(tool.name);
|
|
4463
4610
|
}
|
|
4464
4611
|
function unregisterTool(state, name) {
|
|
4465
4612
|
const dispose = state.toolDisposers.get(name);
|
|
@@ -4840,6 +4987,7 @@ function createPiApi(ctx, state) {
|
|
|
4840
4987
|
store: oauthStoreOf(state)
|
|
4841
4988
|
}),
|
|
4842
4989
|
warn: (message) => logger(ctx).warn(message),
|
|
4990
|
+
beforeProviderRequest: (payload, request) => dispatchBeforeProviderRequest(ctx, state, payload, request),
|
|
4843
4991
|
resolveAttachments: () => optionalService(ctx, "attachments")
|
|
4844
4992
|
}
|
|
4845
4993
|
});
|
|
@@ -5176,7 +5324,11 @@ async function applyPiPackage(ctx, options) {
|
|
|
5176
5324
|
oauth: provider.auth.oauth
|
|
5177
5325
|
});
|
|
5178
5326
|
ensureLoginCommand(ctx, state);
|
|
5179
|
-
for (const [name, config] of [...state.providers])
|
|
5327
|
+
for (const [name, config] of [...state.providers]) try {
|
|
5328
|
+
await ensureLoggedInProviderRoute(ctx, state, name, config);
|
|
5329
|
+
} catch (error) {
|
|
5330
|
+
logger(ctx).warn(`[pi2dsh] could not restore the route for logged-in provider ${JSON.stringify(name)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
5331
|
+
}
|
|
5180
5332
|
if (options.manifest.skillDirs.length > 0) {
|
|
5181
5333
|
if (ctx.get("skills") === void 0) logger(ctx).warn("[pi2dsh] migrated skills were not mounted because this DSH composition has no ctx.skills");
|
|
5182
5334
|
else {
|
|
@@ -5335,6 +5487,7 @@ const runtimeInternals = {
|
|
|
5335
5487
|
resolveOfferedChoice,
|
|
5336
5488
|
dshToPiContent,
|
|
5337
5489
|
expandPrompt,
|
|
5490
|
+
isKnownImageTool,
|
|
5338
5491
|
isSubagentOrigin,
|
|
5339
5492
|
normalizeToolResult,
|
|
5340
5493
|
splitArguments,
|
|
@@ -5344,4 +5497,4 @@ const runtimeInternals = {
|
|
|
5344
5497
|
//#endregion
|
|
5345
5498
|
export { runtimeInternals as i, normalizeToolSchema as n, registerVisionCompanions as r, applyPiPackage as t };
|
|
5346
5499
|
|
|
5347
|
-
//# sourceMappingURL=runtime-
|
|
5500
|
+
//# sourceMappingURL=runtime-DEjs_Qlf.mjs.map
|