@oh-my-pi/pi-coding-agent 15.10.7 → 15.10.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 (80) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/types/config/model-registry.d.ts +4 -2
  3. package/dist/types/config/model-resolver.d.ts +2 -0
  4. package/dist/types/config/settings-schema.d.ts +9 -0
  5. package/dist/types/extensibility/custom-tools/loader.d.ts +22 -3
  6. package/dist/types/extensibility/custom-tools/types.d.ts +3 -1
  7. package/dist/types/extensibility/extensions/index.d.ts +1 -1
  8. package/dist/types/extensibility/extensions/loader.d.ts +17 -1
  9. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +8 -0
  10. package/dist/types/mcp/oauth-discovery.d.ts +4 -1
  11. package/dist/types/mcp/oauth-flow.d.ts +6 -1
  12. package/dist/types/mcp/transports/stdio.d.ts +12 -0
  13. package/dist/types/modes/components/custom-editor.d.ts +3 -2
  14. package/dist/types/sdk.d.ts +42 -2
  15. package/dist/types/task/executor.d.ts +16 -0
  16. package/dist/types/tools/fetch.d.ts +2 -1
  17. package/dist/types/tools/index.d.ts +20 -1
  18. package/dist/types/tools/report-tool-issue.d.ts +5 -0
  19. package/dist/types/tui/hyperlink.d.ts +8 -0
  20. package/dist/types/web/kagi.d.ts +2 -1
  21. package/dist/types/web/parallel.d.ts +3 -0
  22. package/dist/types/web/search/providers/anthropic.d.ts +2 -1
  23. package/dist/types/web/search/providers/base.d.ts +2 -1
  24. package/dist/types/web/search/providers/brave.d.ts +2 -1
  25. package/dist/types/web/search/providers/codex.d.ts +2 -1
  26. package/dist/types/web/search/providers/exa.d.ts +2 -1
  27. package/dist/types/web/search/providers/gemini.d.ts +2 -1
  28. package/dist/types/web/search/providers/jina.d.ts +7 -2
  29. package/dist/types/web/search/providers/kagi.d.ts +7 -2
  30. package/dist/types/web/search/providers/kimi.d.ts +7 -2
  31. package/dist/types/web/search/providers/parallel.d.ts +2 -1
  32. package/dist/types/web/search/providers/perplexity.d.ts +2 -1
  33. package/dist/types/web/search/providers/searxng.d.ts +2 -1
  34. package/dist/types/web/search/providers/synthetic.d.ts +7 -3
  35. package/dist/types/web/search/providers/tavily.d.ts +2 -1
  36. package/dist/types/web/search/providers/zai.d.ts +2 -1
  37. package/package.json +9 -9
  38. package/src/config/model-registry.ts +13 -7
  39. package/src/config/model-resolver.ts +57 -2
  40. package/src/config/settings-schema.ts +6 -0
  41. package/src/extensibility/custom-tools/loader.ts +43 -19
  42. package/src/extensibility/custom-tools/types.ts +3 -1
  43. package/src/extensibility/extensions/index.ts +1 -0
  44. package/src/extensibility/extensions/loader.ts +29 -6
  45. package/src/extensibility/plugins/legacy-pi-compat.ts +30 -6
  46. package/src/internal-urls/docs-index.generated.ts +1 -1
  47. package/src/mcp/oauth-discovery.ts +8 -3
  48. package/src/mcp/oauth-flow.ts +12 -5
  49. package/src/mcp/transports/stdio.ts +139 -3
  50. package/src/modes/components/assistant-message.ts +28 -6
  51. package/src/modes/components/custom-editor.ts +69 -9
  52. package/src/modes/components/transcript-container.ts +77 -25
  53. package/src/modes/controllers/input-controller.ts +1 -1
  54. package/src/modes/controllers/mcp-command-controller.ts +2 -2
  55. package/src/sdk.ts +138 -56
  56. package/src/ssh/ssh-executor.ts +60 -4
  57. package/src/task/executor.ts +19 -0
  58. package/src/task/index.ts +4 -0
  59. package/src/tools/fetch.ts +22 -5
  60. package/src/tools/image-gen.ts +33 -11
  61. package/src/tools/index.ts +21 -2
  62. package/src/tools/report-tool-issue.ts +7 -1
  63. package/src/tui/hyperlink.ts +27 -3
  64. package/src/web/kagi.ts +5 -2
  65. package/src/web/parallel.ts +7 -3
  66. package/src/web/search/providers/anthropic.ts +5 -1
  67. package/src/web/search/providers/base.ts +2 -1
  68. package/src/web/search/providers/brave.ts +5 -2
  69. package/src/web/search/providers/codex.ts +6 -2
  70. package/src/web/search/providers/exa.ts +91 -8
  71. package/src/web/search/providers/gemini.ts +6 -0
  72. package/src/web/search/providers/jina.ts +15 -5
  73. package/src/web/search/providers/kagi.ts +9 -2
  74. package/src/web/search/providers/kimi.ts +18 -4
  75. package/src/web/search/providers/parallel.ts +6 -2
  76. package/src/web/search/providers/perplexity.ts +7 -4
  77. package/src/web/search/providers/searxng.ts +6 -2
  78. package/src/web/search/providers/synthetic.ts +9 -5
  79. package/src/web/search/providers/tavily.ts +4 -2
  80. package/src/web/search/providers/zai.ts +15 -4
@@ -4,7 +4,7 @@
4
4
  * Calls Z.AI's remote MCP server (`webSearchPrime`) and adapts results into
5
5
  * the unified SearchResponse shape used by the web search tool.
6
6
  */
7
- import { type ApiKey, type AuthStorage, getEnvApiKey, withAuth } from "@oh-my-pi/pi-ai";
7
+ import { type ApiKey, type AuthStorage, type FetchImpl, getEnvApiKey, withAuth } from "@oh-my-pi/pi-ai";
8
8
  import { asRecord, asString } from "../../../web/scrapers/utils";
9
9
  import type { SearchResponse, SearchSource } from "../../../web/search/types";
10
10
  import { SearchProviderError } from "../../../web/search/types";
@@ -21,6 +21,7 @@ export interface ZaiSearchParams {
21
21
  query: string;
22
22
  num_results?: number;
23
23
  signal?: AbortSignal;
24
+ fetch?: FetchImpl;
24
25
  authStorage: AuthStorage;
25
26
  sessionId?: string;
26
27
  }
@@ -62,8 +63,13 @@ export async function findApiKey(
62
63
  return (await authStorage.getApiKey("zai", sessionId, { signal })) ?? null;
63
64
  }
64
65
 
65
- async function callZaiTool(apiKey: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<unknown> {
66
- const response = await fetch(ZAI_MCP_URL, {
66
+ async function callZaiTool(
67
+ apiKey: string,
68
+ args: Record<string, unknown>,
69
+ signal: AbortSignal | undefined,
70
+ fetchImpl: FetchImpl,
71
+ ): Promise<unknown> {
72
+ const response = await fetchImpl(ZAI_MCP_URL, {
67
73
  method: "POST",
68
74
  headers: {
69
75
  Authorization: `Bearer ${apiKey}`,
@@ -158,6 +164,7 @@ async function callZaiTool(apiKey: string, args: Record<string, unknown>, signal
158
164
 
159
165
  async function callZaiSearch(apiKey: string, params: ZaiSearchParams): Promise<unknown> {
160
166
  const count = params.num_results ?? DEFAULT_NUM_RESULTS;
167
+ const fetchImpl = params.fetch ?? fetch;
161
168
  const attempts: Record<string, unknown>[] = [
162
169
  { query: params.query, count },
163
170
  { search_query: params.query, count },
@@ -167,7 +174,7 @@ async function callZaiSearch(apiKey: string, params: ZaiSearchParams): Promise<u
167
174
  let lastError: unknown;
168
175
  for (let i = 0; i < attempts.length; i++) {
169
176
  try {
170
- return await callZaiTool(apiKey, attempts[i], params.signal);
177
+ return await callZaiTool(apiKey, attempts[i], params.signal, fetchImpl);
171
178
  } catch (error) {
172
179
  lastError = error;
173
180
  const isLastAttempt = i === attempts.length - 1;
@@ -301,6 +308,8 @@ export async function searchZai(params: ZaiSearchParams): Promise<SearchResponse
301
308
  };
302
309
  }
303
310
 
311
+ type ZaiProviderSearchParams = SearchParams & { fetch?: FetchImpl };
312
+
304
313
  /** Search provider for Z.AI web search MCP. */
305
314
  export class ZaiProvider extends SearchProvider {
306
315
  readonly id = "zai";
@@ -311,12 +320,14 @@ export class ZaiProvider extends SearchProvider {
311
320
  }
312
321
 
313
322
  search(params: SearchParams): Promise<SearchResponse> {
323
+ const { fetch: fetchOverride } = params as ZaiProviderSearchParams;
314
324
  return searchZai({
315
325
  query: params.query,
316
326
  num_results: params.numSearchResults ?? params.limit,
317
327
  signal: params.signal,
318
328
  authStorage: params.authStorage,
319
329
  sessionId: params.sessionId,
330
+ fetch: fetchOverride,
320
331
  });
321
332
  }
322
333
  }