pi-openai-toolkit 0.18.0 → 0.20.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 +156 -242
- package/README.zh.md +156 -242
- package/config.schema.json +15 -1
- package/docs/configuration.md +135 -7
- package/package.json +9 -6
- package/src/config/policy.ts +4 -2
- package/src/config/v2.ts +36 -3
- package/src/config.ts +1 -0
- package/src/context-management/codex-provider.ts +18 -8
- package/src/extension-runtime.ts +47 -26
- package/src/image-generation/artifacts.ts +28 -7
- package/src/image-generation/client.ts +5 -3
- package/src/image-generation/eligibility.ts +10 -5
- package/src/image-generation/extension.ts +6 -4
- package/src/image-generation/protocol.ts +175 -38
- package/src/image-generation/render.ts +13 -5
- package/src/image-generation/service.ts +35 -7
- package/src/image-generation/types.ts +23 -3
- package/src/payload-rewrite.ts +16 -1
- package/src/responses-headers.ts +6 -1
- package/src/responses-websocket/extension.ts +32 -0
- package/src/responses-websocket/transport.ts +577 -0
- package/src/runtime.ts +295 -28
- package/src/serializer.ts +214 -0
- package/src/supported-environment.ts +5 -0
- package/src/types.ts +6 -2
- package/src/web-search/extension.ts +4 -3
- package/src/web-search/types.ts +25 -3
- package/tsconfig.check.json +2 -0
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
export {
|
|
2
2
|
buildCompactUrl,
|
|
3
3
|
buildResponsesUrl,
|
|
4
|
+
VIRTUAL_MODEL_API,
|
|
4
5
|
getNativeCompactionRuntime,
|
|
5
6
|
getRuntimeModelDescriptor,
|
|
7
|
+
resolveAzureDeploymentName,
|
|
8
|
+
resolveEffectiveModel,
|
|
9
|
+
registerPhysicalModelObserver,
|
|
6
10
|
isResponsesCompatiblePayload,
|
|
7
11
|
isSupportedApi,
|
|
8
12
|
normalizeBaseUrl,
|
|
9
13
|
parseModelSpec,
|
|
10
14
|
resolveNativeCompactionEnvironment,
|
|
11
15
|
resolveRemoteCompactionExecution,
|
|
16
|
+
type EffectiveModelResolution,
|
|
12
17
|
type NativeCompactionEnvironmentFailure,
|
|
13
18
|
type NativeCompactionEnvironmentResolution,
|
|
14
19
|
type NativeCompactionEnvironmentSuccess,
|
package/src/types.ts
CHANGED
|
@@ -13,7 +13,11 @@ export const REDACTED_VALUE = "[REDACTED]";
|
|
|
13
13
|
* APIs the extension knows how to build a `/responses/compact` URL for.
|
|
14
14
|
* `compaction.responsesApis` in config.json may only narrow this set.
|
|
15
15
|
*/
|
|
16
|
-
export const RESPONSES_COMPACT_CAPABLE_APIS = [
|
|
16
|
+
export const RESPONSES_COMPACT_CAPABLE_APIS = [
|
|
17
|
+
"openai-responses",
|
|
18
|
+
"openai-codex-responses",
|
|
19
|
+
"azure-openai-responses",
|
|
20
|
+
] as const;
|
|
17
21
|
/**
|
|
18
22
|
* Bare model ID used by the independent Astra effort compatibility layer.
|
|
19
23
|
* Remote Context eligibility is API/provider based with an exact gateway opt-in;
|
|
@@ -602,7 +606,7 @@ export const DEFAULT_WEB_SEARCH_CONFIG: WebSearchConfig = {
|
|
|
602
606
|
};
|
|
603
607
|
|
|
604
608
|
/** Single source of truth for the hosted image model used when nothing is configured. */
|
|
605
|
-
export const DEFAULT_IMAGE_GENERATION_MODEL = "
|
|
609
|
+
export const DEFAULT_IMAGE_GENERATION_MODEL = "grok-imagine-image-2.0";
|
|
606
610
|
export const DEFAULT_IMAGE_GENERATION_MODELS: readonly string[] = [DEFAULT_IMAGE_GENERATION_MODEL];
|
|
607
611
|
|
|
608
612
|
export const DEFAULT_IMAGE_GENERATION_CONFIG: ImageGenerationConfig = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExtensionAPI, ExtensionContext, ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { assertConfigValid, loadToolkitConfig, resolveToolkitConfig, type ResolvedToolkitConfig } from "../config";
|
|
3
3
|
import { notifyConfigIssues } from "../config/notifications";
|
|
4
|
-
import { resolveResponsesEnvironment, type ResponsesEnvironmentResolution } from "../runtime";
|
|
4
|
+
import { registerPhysicalModelObserver, resolveResponsesEnvironment, type ResponsesEnvironmentResolution } from "../runtime";
|
|
5
5
|
import {
|
|
6
6
|
requestAlphaSearch,
|
|
7
7
|
normalizeStandaloneWebRunCommands,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
LOCAL_WEB_SEARCH_TOOL_NAME,
|
|
19
19
|
resolveWebSearchRoute,
|
|
20
20
|
WEB_RUN_TOOL_NAME,
|
|
21
|
-
|
|
21
|
+
WEB_SEARCH_STANDALONE_APIS,
|
|
22
22
|
type WebSearchModel,
|
|
23
23
|
type WebSearchRouteResolution,
|
|
24
24
|
} from "./types";
|
|
@@ -245,7 +245,7 @@ export async function executeStandaloneWebRun(args: {
|
|
|
245
245
|
|
|
246
246
|
const runtime = await resolveRuntime(args.ctx, {
|
|
247
247
|
enabled: config.webSearch.enabled,
|
|
248
|
-
responsesApis:
|
|
248
|
+
responsesApis: WEB_SEARCH_STANDALONE_APIS,
|
|
249
249
|
codexGatewayModels: resolved.gatewayModelKeys,
|
|
250
250
|
});
|
|
251
251
|
if (!runtime.ok) throw standaloneRuntimeFailure(runtime);
|
|
@@ -379,6 +379,7 @@ export function registerWebSearchExtension(
|
|
|
379
379
|
): void {
|
|
380
380
|
if (registeredApis.has(pi)) return;
|
|
381
381
|
registeredApis.add(pi);
|
|
382
|
+
registerPhysicalModelObserver(pi);
|
|
382
383
|
|
|
383
384
|
const states = { webSearch: cloneToolState(), webRun: cloneToolState() };
|
|
384
385
|
let standaloneRegistrationSucceeded = false;
|
package/src/web-search/types.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import { VIRTUAL_MODEL_API } from "../runtime";
|
|
1
2
|
import { getExactModelKey, isExactModelAllowed } from "../model-scope";
|
|
2
3
|
import type { WebSearchConfig, WebSearchRoute } from "../types";
|
|
3
4
|
|
|
4
|
-
export const WEB_SEARCH_CAPABLE_APIS = [
|
|
5
|
+
export const WEB_SEARCH_CAPABLE_APIS = [
|
|
6
|
+
"openai-responses",
|
|
7
|
+
"openai-codex-responses",
|
|
8
|
+
"azure-openai-responses",
|
|
9
|
+
] as const;
|
|
10
|
+
/** The provider-relative alpha endpoint is only verified for OpenAI/Codex routes. */
|
|
11
|
+
export const WEB_SEARCH_STANDALONE_APIS = ["openai-responses", "openai-codex-responses"] as const;
|
|
5
12
|
export const WEB_SEARCH_SOURCE_INCLUDE = "web_search_call.action.sources";
|
|
6
13
|
export const WEB_SEARCH_PROMPT_MARKER = "<!-- pi-openai-toolkit:web-search -->";
|
|
7
14
|
export const WEB_RUN_TOOL_NAME = "web_run";
|
|
8
15
|
export const LOCAL_WEB_SEARCH_TOOL_NAME = "web_search";
|
|
9
16
|
|
|
10
17
|
export type WebSearchCapableApi = (typeof WEB_SEARCH_CAPABLE_APIS)[number];
|
|
18
|
+
export type WebSearchStandaloneApi = (typeof WEB_SEARCH_STANDALONE_APIS)[number];
|
|
11
19
|
export type WebSearchRouteSource = "exact" | "default" | "legacy" | "none";
|
|
12
20
|
export type WebSearchRouteUnavailableReason = "missing-model" | "unsupported-api" | "invalid-route";
|
|
13
21
|
|
|
@@ -76,7 +84,13 @@ function selectedRoute(args: {
|
|
|
76
84
|
reason: "missing-model",
|
|
77
85
|
};
|
|
78
86
|
}
|
|
79
|
-
if (
|
|
87
|
+
if (
|
|
88
|
+
args.route !== "local" &&
|
|
89
|
+
args.model?.api !== VIRTUAL_MODEL_API &&
|
|
90
|
+
(args.route === "standalone-alpha"
|
|
91
|
+
? !isWebSearchStandaloneCapableApi(args.model?.api)
|
|
92
|
+
: !isWebSearchCapableApi(args.model?.api))
|
|
93
|
+
) {
|
|
80
94
|
return {
|
|
81
95
|
route: args.route,
|
|
82
96
|
source: args.source,
|
|
@@ -97,6 +111,10 @@ export function isWebSearchCapableApi(api: unknown): api is WebSearchCapableApi
|
|
|
97
111
|
return typeof api === "string" && (WEB_SEARCH_CAPABLE_APIS as readonly string[]).includes(api);
|
|
98
112
|
}
|
|
99
113
|
|
|
114
|
+
export function isWebSearchStandaloneCapableApi(api: unknown): api is WebSearchStandaloneApi {
|
|
115
|
+
return typeof api === "string" && (WEB_SEARCH_STANDALONE_APIS as readonly string[]).includes(api);
|
|
116
|
+
}
|
|
117
|
+
|
|
100
118
|
/**
|
|
101
119
|
* Resolve exactly one configured Web Search route. The legacy model allowlist is
|
|
102
120
|
* deliberately consulted only after explicit route fields so old configs retain
|
|
@@ -127,7 +145,11 @@ export function resolveWebSearchRoute(args: {
|
|
|
127
145
|
return selectedRoute({ route: config.defaultRoute, source: "default", model, modelKey });
|
|
128
146
|
}
|
|
129
147
|
|
|
130
|
-
if (
|
|
148
|
+
if (
|
|
149
|
+
modelKey &&
|
|
150
|
+
isExactModelAllowed(model, config.models) &&
|
|
151
|
+
(model?.api === VIRTUAL_MODEL_API || isWebSearchCapableApi(model?.api))
|
|
152
|
+
) {
|
|
131
153
|
return selectedRoute({ route: "hosted", source: "legacy", model, modelKey });
|
|
132
154
|
}
|
|
133
155
|
|
package/tsconfig.check.json
CHANGED