@oh-my-pi/pi-coding-agent 14.5.12 → 14.5.13

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 (85) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/package.json +18 -10
  3. package/src/cli/jupyter-cli.ts +1 -1
  4. package/src/config/model-equivalence.ts +49 -16
  5. package/src/config/model-registry.ts +100 -25
  6. package/src/config/model-resolver.ts +29 -15
  7. package/src/config/settings-schema.ts +20 -6
  8. package/src/config/settings.ts +9 -8
  9. package/src/config.ts +9 -0
  10. package/src/eval/backend.ts +43 -0
  11. package/src/eval/eval.lark +43 -0
  12. package/src/eval/index.ts +5 -0
  13. package/src/eval/js/context-manager.ts +717 -0
  14. package/src/eval/js/executor.ts +131 -0
  15. package/src/eval/js/index.ts +46 -0
  16. package/src/eval/js/prelude.ts +2 -0
  17. package/src/eval/js/prelude.txt +84 -0
  18. package/src/eval/js/tool-bridge.ts +124 -0
  19. package/src/eval/parse.ts +337 -0
  20. package/src/{ipy → eval/py}/executor.ts +2 -180
  21. package/src/{ipy → eval/py}/gateway-coordinator.ts +2 -2
  22. package/src/eval/py/index.ts +58 -0
  23. package/src/{ipy → eval/py}/kernel.ts +5 -41
  24. package/src/{ipy → eval/py}/prelude.py +39 -227
  25. package/src/eval/types.ts +48 -0
  26. package/src/export/html/template.generated.ts +1 -1
  27. package/src/export/html/template.js +8 -10
  28. package/src/extensibility/extensions/types.ts +2 -3
  29. package/src/internal-urls/docs-index.generated.ts +5 -5
  30. package/src/lsp/client.ts +9 -0
  31. package/src/lsp/index.ts +395 -0
  32. package/src/lsp/types.ts +15 -4
  33. package/src/main.ts +25 -14
  34. package/src/mcp/oauth-flow.ts +1 -1
  35. package/src/memories/index.ts +1 -1
  36. package/src/modes/acp/acp-event-mapper.ts +1 -1
  37. package/src/modes/components/{python-execution.ts → eval-execution.ts} +11 -4
  38. package/src/modes/components/login-dialog.ts +1 -1
  39. package/src/modes/components/oauth-selector.ts +2 -1
  40. package/src/modes/components/tool-execution.ts +3 -4
  41. package/src/modes/controllers/command-controller.ts +28 -8
  42. package/src/modes/controllers/input-controller.ts +4 -4
  43. package/src/modes/controllers/selector-controller.ts +2 -1
  44. package/src/modes/interactive-mode.ts +4 -5
  45. package/src/modes/types.ts +3 -3
  46. package/src/modes/utils/ui-helpers.ts +2 -2
  47. package/src/prompts/system/system-prompt.md +3 -3
  48. package/src/prompts/tools/eval.md +92 -0
  49. package/src/prompts/tools/lsp.md +7 -3
  50. package/src/sdk.ts +45 -31
  51. package/src/session/agent-session.ts +42 -42
  52. package/src/session/messages.ts +1 -1
  53. package/src/slash-commands/builtin-registry.ts +1 -1
  54. package/src/system-prompt.ts +34 -66
  55. package/src/task/executor.ts +5 -9
  56. package/src/tools/browser/launch.ts +22 -0
  57. package/src/tools/browser/registry.ts +25 -244
  58. package/src/tools/browser/render.ts +1 -1
  59. package/src/tools/browser/tab-protocol.ts +101 -0
  60. package/src/tools/browser/tab-supervisor.ts +429 -0
  61. package/src/tools/browser/tab-worker-entry.ts +21 -0
  62. package/src/tools/browser/tab-worker.ts +1006 -0
  63. package/src/tools/browser.ts +12 -29
  64. package/src/tools/checkpoint.ts +2 -2
  65. package/src/tools/{python.ts → eval.ts} +324 -315
  66. package/src/tools/exit-plan-mode.ts +1 -1
  67. package/src/tools/index.ts +62 -100
  68. package/src/tools/read.ts +0 -6
  69. package/src/tools/recipe/runners/pkg.ts +34 -32
  70. package/src/tools/renderers.ts +2 -2
  71. package/src/tools/resolve.ts +7 -2
  72. package/src/tools/todo-write.ts +0 -1
  73. package/src/tools/tool-timeouts.ts +2 -2
  74. package/src/utils/markit.ts +15 -7
  75. package/src/utils/tools-manager.ts +5 -5
  76. package/src/web/search/index.ts +5 -5
  77. package/src/web/search/provider.ts +121 -39
  78. package/src/web/search/providers/gemini.ts +2 -2
  79. package/src/web/search/render.ts +2 -2
  80. package/src/ipy/modules.ts +0 -144
  81. package/src/prompts/tools/python.md +0 -57
  82. package/src/tools/browser/vm.ts +0 -792
  83. /package/src/{ipy → eval/py}/cancellation.ts +0 -0
  84. /package/src/{ipy → eval/py}/prelude.ts +0 -0
  85. /package/src/{ipy → eval/py}/runtime.ts +0 -0
@@ -4,18 +4,9 @@ import { prompt, untilAborted } from "@oh-my-pi/pi-utils";
4
4
  import { type Static, Type } from "@sinclair/typebox";
5
5
  import browserDescription from "../prompts/tools/browser.md" with { type: "text" };
6
6
  import type { ToolSession } from "../sdk";
7
- import {
8
- acquireBrowser,
9
- acquireTab,
10
- type BrowserHandle,
11
- type BrowserKind,
12
- type BrowserKindTag,
13
- dropHeadlessBrowsers,
14
- getTab,
15
- releaseAllTabs,
16
- releaseTab,
17
- } from "./browser/registry";
18
- import { collectObservation, formatObservation, type Observation, runInTab, type ScreenshotResult } from "./browser/vm";
7
+ import { acquireBrowser, type BrowserHandle, type BrowserKind, type BrowserKindTag } from "./browser/registry";
8
+ import type { Observation, ScreenshotResult } from "./browser/tab-protocol";
9
+ import { acquireTab, dropHeadlessTabs, getTab, releaseAllTabs, releaseTab, runInTab } from "./browser/tab-supervisor";
19
10
  import type { OutputMeta } from "./output-meta";
20
11
  import { resolveToCwd } from "./path-utils";
21
12
  import { ToolAbortError, ToolError, throwIfAborted } from "./tool-errors";
@@ -23,7 +14,7 @@ import { toolResult } from "./tool-result";
23
14
  import { clampTimeout } from "./tool-timeouts";
24
15
 
25
16
  export { extractReadableFromHtml, type ReadableFormat, type ReadableResult } from "./browser/readable";
26
- export type { Observation, ObservationEntry } from "./browser/vm";
17
+ export type { Observation, ObservationEntry } from "./browser/tab-protocol";
27
18
 
28
19
  const DEFAULT_TAB_NAME = "main";
29
20
 
@@ -129,7 +120,7 @@ export class BrowserTool implements AgentTool<typeof browserSchema, BrowserToolD
129
120
 
130
121
  /** Restart browser to apply mode changes (e.g. headless toggle). Drops only headless browsers. */
131
122
  async restartForModeChange(): Promise<void> {
132
- await dropHeadlessBrowsers();
123
+ await dropHeadlessTabs();
133
124
  }
134
125
 
135
126
  async execute(
@@ -216,10 +207,10 @@ export class BrowserTool implements AgentTool<typeof browserSchema, BrowserToolD
216
207
  }),
217
208
  );
218
209
  const tab = result.tab;
219
- const url = tab.page.url();
220
- const title = (await untilAborted(signal, () => tab.page.title())) as string;
210
+ const url = tab.info.url;
211
+ const title = tab.info.title ?? "";
221
212
  details.url = url;
222
- details.viewport = tab.page.viewport() ?? undefined;
213
+ details.viewport = tab.info.viewport;
223
214
  const verb = result.created ? "Opened" : "Reused";
224
215
  const lines = [
225
216
  `${verb} tab ${JSON.stringify(name)} on ${describeBrowser(browser)}`,
@@ -258,16 +249,12 @@ export class BrowserTool implements AgentTool<typeof browserSchema, BrowserToolD
258
249
  throw new ToolError("Missing required parameter 'code' for action 'run'.");
259
250
  }
260
251
  const tab = getTab(name);
261
- if (!tab) {
262
- throw new ToolError(
263
- `No tab named ${JSON.stringify(name)}. Call open first (e.g. action: 'open', name: '${name}').`,
264
- );
252
+ if (tab) {
253
+ details.browser = tab.browser.kind.kind;
254
+ details.url = tab.info.url;
265
255
  }
266
- details.browser = tab.browser.kind.kind;
267
- details.url = tab.page.url();
268
256
 
269
- const { displays, returnValue, screenshots } = await runInTab({
270
- tab,
257
+ const { displays, returnValue, screenshots } = await runInTab(name, {
271
258
  code: params.code,
272
259
  timeoutMs,
273
260
  signal,
@@ -330,7 +317,3 @@ function stringifyReturnValue(value: unknown): string {
330
317
  return String(value);
331
318
  }
332
319
  }
333
-
334
- // Re-export collectObservation so external callers (e.g. tests) can use it without
335
- // reaching into the browser/ subdirectory.
336
- export { collectObservation, formatObservation };
@@ -52,7 +52,7 @@ export class CheckpointTool implements AgentTool<typeof checkpointSchema, Checkp
52
52
  readonly description: string;
53
53
  readonly parameters = checkpointSchema;
54
54
  readonly strict = true;
55
- readonly intent = (args: Partial<CheckpointParams>) => args.goal;
55
+ readonly intent = (args: Partial<CheckpointParams>) => (args.goal ? `checkpointing: ${args.goal}` : "checkpointing");
56
56
 
57
57
  constructor(private readonly session: ToolSession) {
58
58
  this.description = prompt.render(checkpointDescription);
@@ -95,7 +95,7 @@ export class RewindTool implements AgentTool<typeof rewindSchema, RewindToolDeta
95
95
  readonly description: string;
96
96
  readonly parameters = rewindSchema;
97
97
  readonly strict = true;
98
- readonly intent = (): string => "Rewinding to checkpoint";
98
+ readonly intent = (): string => "rewinding";
99
99
 
100
100
  constructor(private readonly session: ToolSession) {
101
101
  this.description = prompt.render(rewindDescription);