pi-openai-toolkit 0.14.8 → 0.14.9

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.
Files changed (39) hide show
  1. package/README.md +1 -1
  2. package/README.zh.md +1 -1
  3. package/docs/internals.md +18 -0
  4. package/extensions/auto-mode.ts +1 -1
  5. package/extensions/codex-astra.ts +1 -1
  6. package/extensions/compaction.ts +1 -1
  7. package/extensions/image-generation.ts +1 -1
  8. package/extensions/web-search.ts +1 -1
  9. package/package.json +2 -1
  10. package/src/auto-mode/classifier.ts +165 -165
  11. package/src/auto-mode/extension.ts +129 -20
  12. package/src/auto-mode/policy.ts +146 -146
  13. package/src/auto-mode/prompt.ts +279 -279
  14. package/src/auto-mode/reviewer.ts +325 -325
  15. package/src/auto-mode/tool-review-tui.ts +211 -0
  16. package/src/auto-mode/transcript.ts +133 -133
  17. package/src/auto-mode/types.ts +137 -137
  18. package/src/codex-astra/effort-planner.ts +175 -175
  19. package/src/codex-astra/extension.ts +122 -122
  20. package/src/compaction-projection.ts +31 -31
  21. package/src/context-management/messages.ts +112 -112
  22. package/src/context-management/namespace-tools.ts +426 -426
  23. package/src/context-management/tool-contract.ts +23 -23
  24. package/src/context-management/tools.ts +291 -291
  25. package/src/context-management/window-budget.ts +83 -83
  26. package/src/context-management/window-request.ts +125 -125
  27. package/src/image-generation/artifacts.ts +237 -237
  28. package/src/image-generation/client.ts +248 -248
  29. package/src/image-generation/eligibility.ts +18 -18
  30. package/src/image-generation/references.ts +194 -194
  31. package/src/image-generation/render.ts +252 -252
  32. package/src/model-scope.ts +17 -17
  33. package/src/pi-context-hook.ts +116 -116
  34. package/src/provider-headers.ts +23 -23
  35. package/src/web-search/alpha-client.ts +875 -875
  36. package/src/web-search/extension.ts +523 -523
  37. package/src/web-search/payload.ts +295 -295
  38. package/src/web-search/prompt.ts +59 -59
  39. package/src/web-search/types.ts +144 -144
@@ -1,295 +1,295 @@
1
- import type { WebSearchConfig } from "../types";
2
- import {
3
- LOCAL_WEB_SEARCH_TOOL_NAME,
4
- resolveWebSearchRoute,
5
- WEB_RUN_TOOL_NAME,
6
- WEB_SEARCH_SOURCE_INCLUDE,
7
- isWebSearchRoute,
8
- type WebSearchModel,
9
- type WebSearchPayloadTransform,
10
- } from "./types";
11
-
12
- type JsonObject = Record<string, unknown>;
13
-
14
- function isRecord(value: unknown): value is JsonObject {
15
- return !!value && typeof value === "object" && !Array.isArray(value);
16
- }
17
-
18
- function isLocalWebSearchFunction(tool: unknown): boolean {
19
- return isRecord(tool) && tool.type === "function" && tool.name === LOCAL_WEB_SEARCH_TOOL_NAME;
20
- }
21
-
22
- function isStandaloneWebRunFunction(tool: unknown): boolean {
23
- return isRecord(tool) && tool.type === "function" && tool.name === WEB_RUN_TOOL_NAME;
24
- }
25
-
26
- function isNativeWebSearchTool(tool: unknown): boolean {
27
- return isRecord(tool) && (tool.type === "web_search" || tool.type === "web_search_preview");
28
- }
29
-
30
- function explicitRouteFailure(resolution: ReturnType<typeof resolveWebSearchRoute>): WebSearchPayloadTransform {
31
- const reason = resolution.route === "none" ? resolution.reason : resolution.reason;
32
- return {
33
- payload: undefined,
34
- outcome: "unavailable-route",
35
- changed: false,
36
- fatal: true,
37
- errorMessage: `Web Search route is unavailable${reason ? ` (${reason})` : ""}; request aborted without fallback.`,
38
- };
39
- }
40
-
41
- function unavailableRouteTransform(
42
- payload: unknown,
43
- resolution: ReturnType<typeof resolveWebSearchRoute>,
44
- ): WebSearchPayloadTransform {
45
- const base = explicitRouteFailure(resolution);
46
- return { ...base, payload };
47
- }
48
-
49
- function transformStandalonePayload(args: {
50
- payload: JsonObject;
51
- resolution: ReturnType<typeof resolveWebSearchRoute>;
52
- }): WebSearchPayloadTransform {
53
- const { payload, resolution } = args;
54
- const toolsValue = payload.tools;
55
- if (toolsValue !== undefined && !Array.isArray(toolsValue)) {
56
- return {
57
- payload,
58
- outcome: "invalid-tools",
59
- changed: false,
60
- fatal: resolution.source !== "legacy",
61
- errorMessage: "Standalone Web Search requires a provider payload tools array.",
62
- };
63
- }
64
- const includeValue = payload.include;
65
- if (includeValue !== undefined && !Array.isArray(includeValue)) {
66
- return {
67
- payload,
68
- outcome: "invalid-include",
69
- changed: false,
70
- fatal: resolution.source !== "legacy",
71
- errorMessage: "Standalone Web Search requires a provider payload include array.",
72
- };
73
- }
74
-
75
- const tools = toolsValue ?? [];
76
- let standaloneToolCount = 0;
77
- const normalizedTools = tools.filter((tool) => {
78
- if (isLocalWebSearchFunction(tool) || isNativeWebSearchTool(tool)) return false;
79
- if (!isStandaloneWebRunFunction(tool)) return true;
80
- standaloneToolCount += 1;
81
- return standaloneToolCount === 1;
82
- });
83
- const include = includeValue ?? [];
84
- const normalizedInclude = include.filter((item) => item !== WEB_SEARCH_SOURCE_INCLUDE);
85
- const toolsChanged = normalizedTools.length !== tools.length;
86
- const includeChanged = normalizedInclude.length !== include.length;
87
- if (toolsValue !== undefined && !normalizedTools.some(isStandaloneWebRunFunction)) {
88
- return {
89
- payload,
90
- outcome: "unavailable-route",
91
- changed: false,
92
- fatal: resolution.source !== "legacy",
93
- errorMessage: "Standalone Web Search requires the registered web.run tool in the provider payload.",
94
- };
95
- }
96
- if (!toolsChanged && !includeChanged) {
97
- return { payload, outcome: "standalone-route", changed: false };
98
- }
99
-
100
- return {
101
- payload: {
102
- ...payload,
103
- ...(toolsChanged ? { tools: normalizedTools } : {}),
104
- ...(includeChanged ? { include: normalizedInclude } : {}),
105
- },
106
- outcome: "removed-conflicting-tools",
107
- changed: true,
108
- };
109
- }
110
-
111
- function transformLocalPayload(args: {
112
- payload: JsonObject;
113
- resolution: ReturnType<typeof resolveWebSearchRoute>;
114
- }): WebSearchPayloadTransform {
115
- const { payload, resolution } = args;
116
- const toolsValue = payload.tools;
117
- if (toolsValue !== undefined && !Array.isArray(toolsValue)) {
118
- return {
119
- payload,
120
- outcome: "invalid-tools",
121
- changed: false,
122
- fatal: resolution.source !== "legacy",
123
- errorMessage: "Local Web Search requires a provider payload tools array.",
124
- };
125
- }
126
- const includeValue = payload.include;
127
- if (includeValue !== undefined && !Array.isArray(includeValue)) {
128
- return {
129
- payload,
130
- outcome: "invalid-include",
131
- changed: false,
132
- fatal: resolution.source !== "legacy",
133
- errorMessage: "Local Web Search requires a provider payload include array.",
134
- };
135
- }
136
-
137
- const tools = toolsValue ?? [];
138
- const normalizedTools = tools.filter(
139
- (tool) => !isStandaloneWebRunFunction(tool) && !isNativeWebSearchTool(tool),
140
- );
141
- const include = includeValue ?? [];
142
- const normalizedInclude = include.filter((item) => item !== WEB_SEARCH_SOURCE_INCLUDE);
143
- const toolsChanged = normalizedTools.length !== tools.length;
144
- const includeChanged = normalizedInclude.length !== include.length;
145
- if (!toolsChanged && !includeChanged) return { payload, outcome: "local-route", changed: false };
146
-
147
- return {
148
- payload: {
149
- ...payload,
150
- ...(toolsChanged ? { tools: normalizedTools } : {}),
151
- ...(includeChanged ? { include: normalizedInclude } : {}),
152
- },
153
- outcome: "removed-conflicting-tools",
154
- changed: true,
155
- };
156
- }
157
-
158
- export function transformWebSearchPayload(args: {
159
- model: WebSearchModel | undefined;
160
- config: WebSearchConfig;
161
- payload: unknown;
162
- }): WebSearchPayloadTransform {
163
- const { model, config, payload } = args;
164
- const resolution = resolveWebSearchRoute({ model, config });
165
-
166
- if (resolution.route === "none") {
167
- return {
168
- payload,
169
- outcome: resolution.reason === "disabled" ? "disabled" : "unsupported-model",
170
- changed: false,
171
- };
172
- }
173
- if (!resolution.available) {
174
- return unavailableRouteTransform(payload, resolution);
175
- }
176
- if (resolution.route === "local") {
177
- if (!isRecord(payload)) {
178
- return {
179
- payload,
180
- outcome: "non-object-payload",
181
- changed: false,
182
- fatal: resolution.source !== "legacy",
183
- errorMessage: "Local Web Search requires an object provider payload.",
184
- };
185
- }
186
- return transformLocalPayload({ payload, resolution });
187
- }
188
- if (resolution.route === "standalone-alpha") {
189
- if (!isRecord(payload)) {
190
- return {
191
- payload,
192
- outcome: "non-object-payload",
193
- changed: false,
194
- fatal: resolution.source !== "legacy",
195
- errorMessage: "Standalone Web Search requires an object provider payload.",
196
- };
197
- }
198
- return transformStandalonePayload({ payload, resolution });
199
- }
200
-
201
- if (!isRecord(payload)) {
202
- return {
203
- payload,
204
- outcome: "non-object-payload",
205
- changed: false,
206
- ...(resolution.source !== "legacy"
207
- ? { fatal: true, errorMessage: "Hosted Web Search requires an object provider payload." }
208
- : {}),
209
- };
210
- }
211
-
212
- const toolsValue = payload.tools;
213
- if (toolsValue !== undefined && !Array.isArray(toolsValue)) {
214
- return {
215
- payload,
216
- outcome: "invalid-tools",
217
- changed: false,
218
- ...(resolution.source !== "legacy"
219
- ? { fatal: true, errorMessage: "Hosted Web Search requires a provider payload tools array." }
220
- : {}),
221
- };
222
- }
223
- const tools = toolsValue ?? [];
224
- const includeValue = payload.include;
225
- if (includeValue !== undefined && !Array.isArray(includeValue)) {
226
- return {
227
- payload,
228
- outcome: "invalid-include",
229
- changed: false,
230
- ...(resolution.source !== "legacy"
231
- ? { fatal: true, errorMessage: "Hosted Web Search requires a provider payload include array." }
232
- : {}),
233
- };
234
- }
235
- const include = includeValue ?? [];
236
- const normalizedTools: unknown[] = [];
237
- let nativeToolCount = 0;
238
- let localToolRemoved = false;
239
- let standaloneToolRemoved = false;
240
- for (const tool of tools) {
241
- if (isLocalWebSearchFunction(tool)) {
242
- localToolRemoved = true;
243
- continue;
244
- }
245
- if (isStandaloneWebRunFunction(tool)) {
246
- standaloneToolRemoved = true;
247
- continue;
248
- }
249
- if (isNativeWebSearchTool(tool)) {
250
- nativeToolCount += 1;
251
- if (nativeToolCount > 1) continue;
252
- }
253
- normalizedTools.push(tool);
254
- }
255
- const hasNativeTool = nativeToolCount > 0;
256
- if (!hasNativeTool) {
257
- normalizedTools.push({ type: "web_search" });
258
- }
259
-
260
- const normalizedInclude: unknown[] = [];
261
- let sourceIncludeCount = 0;
262
- for (const item of include) {
263
- if (item === WEB_SEARCH_SOURCE_INCLUDE) {
264
- sourceIncludeCount += 1;
265
- if (sourceIncludeCount > 1) continue;
266
- }
267
- normalizedInclude.push(item);
268
- }
269
- if (sourceIncludeCount === 0) {
270
- normalizedInclude.push(WEB_SEARCH_SOURCE_INCLUDE);
271
- }
272
-
273
- const toolsChanged = localToolRemoved || standaloneToolRemoved || !hasNativeTool || nativeToolCount > 1;
274
- const includeChanged = sourceIncludeCount !== 1;
275
- if (!toolsChanged && !includeChanged) {
276
- return { payload, outcome: "existing-native-tool", changed: false };
277
- }
278
-
279
- return {
280
- payload: {
281
- ...payload,
282
- ...(toolsChanged ? { tools: normalizedTools } : {}),
283
- ...(includeChanged ? { include: normalizedInclude } : {}),
284
- },
285
- outcome: hasNativeTool ? "existing-native-tool" : "injected-native-tool",
286
- changed: true,
287
- };
288
- }
289
-
290
- export const _payloadTest = {
291
- isLocalWebSearchFunction,
292
- isNativeWebSearchTool,
293
- isStandaloneWebRunFunction,
294
- isWebSearchRoute,
295
- };
1
+ import type { WebSearchConfig } from "../types";
2
+ import {
3
+ LOCAL_WEB_SEARCH_TOOL_NAME,
4
+ resolveWebSearchRoute,
5
+ WEB_RUN_TOOL_NAME,
6
+ WEB_SEARCH_SOURCE_INCLUDE,
7
+ isWebSearchRoute,
8
+ type WebSearchModel,
9
+ type WebSearchPayloadTransform,
10
+ } from "./types";
11
+
12
+ type JsonObject = Record<string, unknown>;
13
+
14
+ function isRecord(value: unknown): value is JsonObject {
15
+ return !!value && typeof value === "object" && !Array.isArray(value);
16
+ }
17
+
18
+ function isLocalWebSearchFunction(tool: unknown): boolean {
19
+ return isRecord(tool) && tool.type === "function" && tool.name === LOCAL_WEB_SEARCH_TOOL_NAME;
20
+ }
21
+
22
+ function isStandaloneWebRunFunction(tool: unknown): boolean {
23
+ return isRecord(tool) && tool.type === "function" && tool.name === WEB_RUN_TOOL_NAME;
24
+ }
25
+
26
+ function isNativeWebSearchTool(tool: unknown): boolean {
27
+ return isRecord(tool) && (tool.type === "web_search" || tool.type === "web_search_preview");
28
+ }
29
+
30
+ function explicitRouteFailure(resolution: ReturnType<typeof resolveWebSearchRoute>): WebSearchPayloadTransform {
31
+ const reason = resolution.route === "none" ? resolution.reason : resolution.reason;
32
+ return {
33
+ payload: undefined,
34
+ outcome: "unavailable-route",
35
+ changed: false,
36
+ fatal: true,
37
+ errorMessage: `Web Search route is unavailable${reason ? ` (${reason})` : ""}; request aborted without fallback.`,
38
+ };
39
+ }
40
+
41
+ function unavailableRouteTransform(
42
+ payload: unknown,
43
+ resolution: ReturnType<typeof resolveWebSearchRoute>,
44
+ ): WebSearchPayloadTransform {
45
+ const base = explicitRouteFailure(resolution);
46
+ return { ...base, payload };
47
+ }
48
+
49
+ function transformStandalonePayload(args: {
50
+ payload: JsonObject;
51
+ resolution: ReturnType<typeof resolveWebSearchRoute>;
52
+ }): WebSearchPayloadTransform {
53
+ const { payload, resolution } = args;
54
+ const toolsValue = payload.tools;
55
+ if (toolsValue !== undefined && !Array.isArray(toolsValue)) {
56
+ return {
57
+ payload,
58
+ outcome: "invalid-tools",
59
+ changed: false,
60
+ fatal: resolution.source !== "legacy",
61
+ errorMessage: "Standalone Web Search requires a provider payload tools array.",
62
+ };
63
+ }
64
+ const includeValue = payload.include;
65
+ if (includeValue !== undefined && !Array.isArray(includeValue)) {
66
+ return {
67
+ payload,
68
+ outcome: "invalid-include",
69
+ changed: false,
70
+ fatal: resolution.source !== "legacy",
71
+ errorMessage: "Standalone Web Search requires a provider payload include array.",
72
+ };
73
+ }
74
+
75
+ const tools = toolsValue ?? [];
76
+ let standaloneToolCount = 0;
77
+ const normalizedTools = tools.filter((tool) => {
78
+ if (isLocalWebSearchFunction(tool) || isNativeWebSearchTool(tool)) return false;
79
+ if (!isStandaloneWebRunFunction(tool)) return true;
80
+ standaloneToolCount += 1;
81
+ return standaloneToolCount === 1;
82
+ });
83
+ const include = includeValue ?? [];
84
+ const normalizedInclude = include.filter((item) => item !== WEB_SEARCH_SOURCE_INCLUDE);
85
+ const toolsChanged = normalizedTools.length !== tools.length;
86
+ const includeChanged = normalizedInclude.length !== include.length;
87
+ if (toolsValue !== undefined && !normalizedTools.some(isStandaloneWebRunFunction)) {
88
+ return {
89
+ payload,
90
+ outcome: "unavailable-route",
91
+ changed: false,
92
+ fatal: resolution.source !== "legacy",
93
+ errorMessage: "Standalone Web Search requires the registered web.run tool in the provider payload.",
94
+ };
95
+ }
96
+ if (!toolsChanged && !includeChanged) {
97
+ return { payload, outcome: "standalone-route", changed: false };
98
+ }
99
+
100
+ return {
101
+ payload: {
102
+ ...payload,
103
+ ...(toolsChanged ? { tools: normalizedTools } : {}),
104
+ ...(includeChanged ? { include: normalizedInclude } : {}),
105
+ },
106
+ outcome: "removed-conflicting-tools",
107
+ changed: true,
108
+ };
109
+ }
110
+
111
+ function transformLocalPayload(args: {
112
+ payload: JsonObject;
113
+ resolution: ReturnType<typeof resolveWebSearchRoute>;
114
+ }): WebSearchPayloadTransform {
115
+ const { payload, resolution } = args;
116
+ const toolsValue = payload.tools;
117
+ if (toolsValue !== undefined && !Array.isArray(toolsValue)) {
118
+ return {
119
+ payload,
120
+ outcome: "invalid-tools",
121
+ changed: false,
122
+ fatal: resolution.source !== "legacy",
123
+ errorMessage: "Local Web Search requires a provider payload tools array.",
124
+ };
125
+ }
126
+ const includeValue = payload.include;
127
+ if (includeValue !== undefined && !Array.isArray(includeValue)) {
128
+ return {
129
+ payload,
130
+ outcome: "invalid-include",
131
+ changed: false,
132
+ fatal: resolution.source !== "legacy",
133
+ errorMessage: "Local Web Search requires a provider payload include array.",
134
+ };
135
+ }
136
+
137
+ const tools = toolsValue ?? [];
138
+ const normalizedTools = tools.filter(
139
+ (tool) => !isStandaloneWebRunFunction(tool) && !isNativeWebSearchTool(tool),
140
+ );
141
+ const include = includeValue ?? [];
142
+ const normalizedInclude = include.filter((item) => item !== WEB_SEARCH_SOURCE_INCLUDE);
143
+ const toolsChanged = normalizedTools.length !== tools.length;
144
+ const includeChanged = normalizedInclude.length !== include.length;
145
+ if (!toolsChanged && !includeChanged) return { payload, outcome: "local-route", changed: false };
146
+
147
+ return {
148
+ payload: {
149
+ ...payload,
150
+ ...(toolsChanged ? { tools: normalizedTools } : {}),
151
+ ...(includeChanged ? { include: normalizedInclude } : {}),
152
+ },
153
+ outcome: "removed-conflicting-tools",
154
+ changed: true,
155
+ };
156
+ }
157
+
158
+ export function transformWebSearchPayload(args: {
159
+ model: WebSearchModel | undefined;
160
+ config: WebSearchConfig;
161
+ payload: unknown;
162
+ }): WebSearchPayloadTransform {
163
+ const { model, config, payload } = args;
164
+ const resolution = resolveWebSearchRoute({ model, config });
165
+
166
+ if (resolution.route === "none") {
167
+ return {
168
+ payload,
169
+ outcome: resolution.reason === "disabled" ? "disabled" : "unsupported-model",
170
+ changed: false,
171
+ };
172
+ }
173
+ if (!resolution.available) {
174
+ return unavailableRouteTransform(payload, resolution);
175
+ }
176
+ if (resolution.route === "local") {
177
+ if (!isRecord(payload)) {
178
+ return {
179
+ payload,
180
+ outcome: "non-object-payload",
181
+ changed: false,
182
+ fatal: resolution.source !== "legacy",
183
+ errorMessage: "Local Web Search requires an object provider payload.",
184
+ };
185
+ }
186
+ return transformLocalPayload({ payload, resolution });
187
+ }
188
+ if (resolution.route === "standalone-alpha") {
189
+ if (!isRecord(payload)) {
190
+ return {
191
+ payload,
192
+ outcome: "non-object-payload",
193
+ changed: false,
194
+ fatal: resolution.source !== "legacy",
195
+ errorMessage: "Standalone Web Search requires an object provider payload.",
196
+ };
197
+ }
198
+ return transformStandalonePayload({ payload, resolution });
199
+ }
200
+
201
+ if (!isRecord(payload)) {
202
+ return {
203
+ payload,
204
+ outcome: "non-object-payload",
205
+ changed: false,
206
+ ...(resolution.source !== "legacy"
207
+ ? { fatal: true, errorMessage: "Hosted Web Search requires an object provider payload." }
208
+ : {}),
209
+ };
210
+ }
211
+
212
+ const toolsValue = payload.tools;
213
+ if (toolsValue !== undefined && !Array.isArray(toolsValue)) {
214
+ return {
215
+ payload,
216
+ outcome: "invalid-tools",
217
+ changed: false,
218
+ ...(resolution.source !== "legacy"
219
+ ? { fatal: true, errorMessage: "Hosted Web Search requires a provider payload tools array." }
220
+ : {}),
221
+ };
222
+ }
223
+ const tools = toolsValue ?? [];
224
+ const includeValue = payload.include;
225
+ if (includeValue !== undefined && !Array.isArray(includeValue)) {
226
+ return {
227
+ payload,
228
+ outcome: "invalid-include",
229
+ changed: false,
230
+ ...(resolution.source !== "legacy"
231
+ ? { fatal: true, errorMessage: "Hosted Web Search requires a provider payload include array." }
232
+ : {}),
233
+ };
234
+ }
235
+ const include = includeValue ?? [];
236
+ const normalizedTools: unknown[] = [];
237
+ let nativeToolCount = 0;
238
+ let localToolRemoved = false;
239
+ let standaloneToolRemoved = false;
240
+ for (const tool of tools) {
241
+ if (isLocalWebSearchFunction(tool)) {
242
+ localToolRemoved = true;
243
+ continue;
244
+ }
245
+ if (isStandaloneWebRunFunction(tool)) {
246
+ standaloneToolRemoved = true;
247
+ continue;
248
+ }
249
+ if (isNativeWebSearchTool(tool)) {
250
+ nativeToolCount += 1;
251
+ if (nativeToolCount > 1) continue;
252
+ }
253
+ normalizedTools.push(tool);
254
+ }
255
+ const hasNativeTool = nativeToolCount > 0;
256
+ if (!hasNativeTool) {
257
+ normalizedTools.push({ type: "web_search" });
258
+ }
259
+
260
+ const normalizedInclude: unknown[] = [];
261
+ let sourceIncludeCount = 0;
262
+ for (const item of include) {
263
+ if (item === WEB_SEARCH_SOURCE_INCLUDE) {
264
+ sourceIncludeCount += 1;
265
+ if (sourceIncludeCount > 1) continue;
266
+ }
267
+ normalizedInclude.push(item);
268
+ }
269
+ if (sourceIncludeCount === 0) {
270
+ normalizedInclude.push(WEB_SEARCH_SOURCE_INCLUDE);
271
+ }
272
+
273
+ const toolsChanged = localToolRemoved || standaloneToolRemoved || !hasNativeTool || nativeToolCount > 1;
274
+ const includeChanged = sourceIncludeCount !== 1;
275
+ if (!toolsChanged && !includeChanged) {
276
+ return { payload, outcome: "existing-native-tool", changed: false };
277
+ }
278
+
279
+ return {
280
+ payload: {
281
+ ...payload,
282
+ ...(toolsChanged ? { tools: normalizedTools } : {}),
283
+ ...(includeChanged ? { include: normalizedInclude } : {}),
284
+ },
285
+ outcome: hasNativeTool ? "existing-native-tool" : "injected-native-tool",
286
+ changed: true,
287
+ };
288
+ }
289
+
290
+ export const _payloadTest = {
291
+ isLocalWebSearchFunction,
292
+ isNativeWebSearchTool,
293
+ isStandaloneWebRunFunction,
294
+ isWebSearchRoute,
295
+ };