pi-openai-toolkit 0.18.0 → 0.19.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.
@@ -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 = ["openai-responses", "openai-codex-responses"] as const;
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 = "gpt-image-2.5";
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
- WEB_SEARCH_CAPABLE_APIS,
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: WEB_SEARCH_CAPABLE_APIS,
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;
@@ -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 = ["openai-responses", "openai-codex-responses"] as const;
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 (args.route !== "local" && !isWebSearchCapableApi(args.model?.api)) {
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 (modelKey && isExactModelAllowed(model, config.models) && isWebSearchCapableApi(model?.api)) {
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