@oh-my-pi/pi-coding-agent 16.0.5 → 16.0.6

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 (223) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/cli.js +1927 -1376
  3. package/dist/types/advisor/advise-tool.d.ts +22 -19
  4. package/dist/types/autoresearch/tools/init-experiment.d.ts +13 -17
  5. package/dist/types/autoresearch/tools/log-experiment.d.ts +17 -19
  6. package/dist/types/autoresearch/tools/run-experiment.d.ts +3 -4
  7. package/dist/types/autoresearch/tools/update-notes.d.ts +4 -5
  8. package/dist/types/cli/ttsr-cli.d.ts +39 -0
  9. package/dist/types/commands/ttsr.d.ts +57 -0
  10. package/dist/types/commit/agentic/tools/analyze-file.d.ts +4 -5
  11. package/dist/types/commit/agentic/tools/git-file-diff.d.ts +4 -5
  12. package/dist/types/commit/agentic/tools/git-hunk.d.ts +5 -6
  13. package/dist/types/commit/agentic/tools/git-overview.d.ts +4 -5
  14. package/dist/types/commit/agentic/tools/propose-changelog.d.ts +23 -24
  15. package/dist/types/commit/agentic/tools/propose-commit.d.ts +11 -32
  16. package/dist/types/commit/agentic/tools/recent-commits.d.ts +3 -4
  17. package/dist/types/commit/agentic/tools/schemas.d.ts +6 -27
  18. package/dist/types/commit/agentic/tools/split-commit.d.ts +28 -49
  19. package/dist/types/commit/changelog/generate.d.ts +12 -13
  20. package/dist/types/commit/shared-llm.d.ts +10 -37
  21. package/dist/types/config/config-file.d.ts +4 -4
  22. package/dist/types/config/keybindings.d.ts +5 -0
  23. package/dist/types/config/models-config-schema.d.ts +625 -990
  24. package/dist/types/config/models-config.d.ts +229 -217
  25. package/dist/types/config/settings-schema.d.ts +53 -23
  26. package/dist/types/edit/hashline/params.d.ts +7 -11
  27. package/dist/types/edit/index.d.ts +2 -1
  28. package/dist/types/edit/modes/apply-patch.d.ts +4 -5
  29. package/dist/types/edit/modes/patch.d.ts +15 -24
  30. package/dist/types/edit/modes/replace.d.ts +16 -17
  31. package/dist/types/eval/js/index.d.ts +1 -0
  32. package/dist/types/extensibility/custom-commands/types.d.ts +6 -3
  33. package/dist/types/extensibility/custom-tools/types.d.ts +8 -5
  34. package/dist/types/extensibility/extensions/types.d.ts +6 -3
  35. package/dist/types/extensibility/hooks/types.d.ts +7 -4
  36. package/dist/types/extensibility/legacy-pi-ai-shim.d.ts +13 -5
  37. package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +17 -0
  38. package/dist/types/extensibility/typebox.d.ts +80 -58
  39. package/dist/types/goals/tools/goal-tool.d.ts +11 -24
  40. package/dist/types/index.d.ts +2 -0
  41. package/dist/types/lsp/index.d.ts +11 -26
  42. package/dist/types/lsp/types.d.ts +12 -28
  43. package/dist/types/mcp/client.d.ts +8 -0
  44. package/dist/types/modes/components/btw-panel.d.ts +1 -0
  45. package/dist/types/modes/components/custom-editor.d.ts +3 -1
  46. package/dist/types/modes/controllers/btw-controller.d.ts +2 -0
  47. package/dist/types/modes/controllers/input-controller.d.ts +1 -0
  48. package/dist/types/modes/interactive-mode.d.ts +3 -0
  49. package/dist/types/modes/setup-wizard/index.d.ts +1 -0
  50. package/dist/types/modes/setup-wizard/startup-splash.d.ts +7 -0
  51. package/dist/types/modes/theme/theme.d.ts +1 -1
  52. package/dist/types/modes/types.d.ts +3 -0
  53. package/dist/types/sdk.d.ts +5 -0
  54. package/dist/types/session/agent-session.d.ts +4 -0
  55. package/dist/types/startup-splash.d.ts +12 -0
  56. package/dist/types/task/types.d.ts +47 -48
  57. package/dist/types/tools/ask.d.ts +26 -27
  58. package/dist/types/tools/ast-edit.d.ts +17 -17
  59. package/dist/types/tools/ast-grep.d.ts +12 -13
  60. package/dist/types/tools/bash.d.ts +20 -17
  61. package/dist/types/tools/browser.d.ts +46 -71
  62. package/dist/types/tools/checkpoint.d.ts +14 -15
  63. package/dist/types/tools/debug.d.ts +82 -145
  64. package/dist/types/tools/eval.d.ts +30 -40
  65. package/dist/types/tools/find.d.ts +17 -18
  66. package/dist/types/tools/gh.d.ts +49 -78
  67. package/dist/types/tools/image-gen.d.ts +20 -36
  68. package/dist/types/tools/inspect-image.d.ts +10 -11
  69. package/dist/types/tools/irc.d.ts +22 -33
  70. package/dist/types/tools/job.d.ts +11 -12
  71. package/dist/types/tools/learn.d.ts +21 -28
  72. package/dist/types/tools/manage-skill.d.ts +13 -22
  73. package/dist/types/tools/memory-edit.d.ts +15 -24
  74. package/dist/types/tools/memory-recall.d.ts +7 -8
  75. package/dist/types/tools/memory-reflect.d.ts +9 -10
  76. package/dist/types/tools/memory-retain.d.ts +13 -14
  77. package/dist/types/tools/read.d.ts +7 -8
  78. package/dist/types/tools/resolve.d.ts +11 -18
  79. package/dist/types/tools/review.d.ts +9 -15
  80. package/dist/types/tools/search-tool-bm25.d.ts +9 -10
  81. package/dist/types/tools/search.d.ts +16 -17
  82. package/dist/types/tools/ssh.d.ts +14 -15
  83. package/dist/types/tools/todo.d.ts +27 -43
  84. package/dist/types/tools/tts.d.ts +8 -9
  85. package/dist/types/tools/write.d.ts +9 -10
  86. package/dist/types/tui/index.d.ts +1 -0
  87. package/dist/types/tui/width-aware-text.d.ts +23 -0
  88. package/dist/types/utils/markit.d.ts +10 -1
  89. package/dist/types/web/search/index.d.ts +17 -28
  90. package/dist/types/web/search/providers/perplexity.d.ts +0 -2
  91. package/dist/types/web/search/types.d.ts +32 -26
  92. package/package.json +14 -13
  93. package/scripts/omp +1 -1
  94. package/src/advisor/__tests__/advisor.test.ts +44 -1
  95. package/src/advisor/advise-tool.ts +34 -11
  96. package/src/autoresearch/tools/init-experiment.ts +13 -16
  97. package/src/autoresearch/tools/log-experiment.ts +15 -18
  98. package/src/autoresearch/tools/run-experiment.ts +3 -3
  99. package/src/autoresearch/tools/update-notes.ts +4 -4
  100. package/src/cli/ttsr-cli.ts +995 -0
  101. package/src/cli-commands.ts +1 -0
  102. package/src/cli.ts +7 -1
  103. package/src/commands/ttsr.ts +125 -0
  104. package/src/commit/agentic/tools/analyze-file.ts +4 -4
  105. package/src/commit/agentic/tools/git-file-diff.ts +4 -4
  106. package/src/commit/agentic/tools/git-hunk.ts +7 -5
  107. package/src/commit/agentic/tools/git-overview.ts +4 -4
  108. package/src/commit/agentic/tools/propose-changelog.ts +18 -15
  109. package/src/commit/agentic/tools/propose-commit.ts +6 -6
  110. package/src/commit/agentic/tools/recent-commits.ts +3 -3
  111. package/src/commit/agentic/tools/schemas.ts +8 -20
  112. package/src/commit/agentic/tools/split-commit.ts +19 -23
  113. package/src/commit/analysis/summary.ts +7 -5
  114. package/src/commit/changelog/generate.ts +15 -11
  115. package/src/commit/shared-llm.ts +17 -24
  116. package/src/config/config-file.ts +13 -15
  117. package/src/config/keybindings.ts +6 -0
  118. package/src/config/models-config-schema.ts +206 -179
  119. package/src/config/settings-schema.ts +34 -0
  120. package/src/discovery/builtin-rules/index.ts +2 -0
  121. package/src/discovery/builtin-rules/ts-import-type.md +2 -2
  122. package/src/discovery/builtin-rules/ts-no-any.md +11 -2
  123. package/src/discovery/builtin-rules/ts-no-inline-cast-access.md +55 -0
  124. package/src/edit/hashline/params.ts +12 -11
  125. package/src/edit/index.ts +5 -4
  126. package/src/edit/modes/apply-patch.ts +4 -4
  127. package/src/edit/modes/patch.ts +15 -18
  128. package/src/edit/modes/replace.ts +13 -17
  129. package/src/edit/renderer.ts +0 -1
  130. package/src/eval/agent-bridge.ts +11 -13
  131. package/src/eval/completion-bridge.ts +25 -17
  132. package/src/eval/js/context-manager.ts +17 -2
  133. package/src/eval/js/index.ts +1 -1
  134. package/src/eval/py/executor.ts +2 -2
  135. package/src/extensibility/custom-commands/loader.ts +5 -3
  136. package/src/extensibility/custom-commands/types.ts +6 -3
  137. package/src/extensibility/custom-tools/loader.ts +4 -2
  138. package/src/extensibility/custom-tools/types.ts +8 -5
  139. package/src/extensibility/extensions/loader.ts +4 -2
  140. package/src/extensibility/extensions/types.ts +6 -3
  141. package/src/extensibility/hooks/loader.ts +5 -2
  142. package/src/extensibility/hooks/types.ts +7 -4
  143. package/src/extensibility/legacy-pi-ai-shim.ts +42 -5
  144. package/src/extensibility/legacy-pi-coding-agent-shim.ts +113 -0
  145. package/src/extensibility/plugins/legacy-pi-compat.ts +13 -13
  146. package/src/extensibility/tool-proxy.ts +4 -1
  147. package/src/extensibility/typebox.ts +778 -251
  148. package/src/goals/guided-setup.ts +12 -3
  149. package/src/goals/tools/goal-tool.ts +6 -6
  150. package/src/index.ts +2 -0
  151. package/src/internal-urls/docs-index.generated.ts +11 -9
  152. package/src/lsp/types.ts +13 -27
  153. package/src/main.ts +19 -18
  154. package/src/mcp/client.ts +38 -13
  155. package/src/mcp/render.ts +102 -89
  156. package/src/modes/components/agent-hub.ts +11 -4
  157. package/src/modes/components/btw-panel.ts +5 -1
  158. package/src/modes/components/custom-editor.ts +18 -0
  159. package/src/modes/components/status-line/component.ts +8 -1
  160. package/src/modes/components/tool-execution.ts +17 -10
  161. package/src/modes/controllers/btw-controller.ts +69 -1
  162. package/src/modes/controllers/input-controller.ts +29 -0
  163. package/src/modes/interactive-mode.ts +38 -8
  164. package/src/modes/setup-wizard/index.ts +1 -0
  165. package/src/modes/setup-wizard/scenes/sign-in.ts +77 -5
  166. package/src/modes/setup-wizard/startup-splash.ts +107 -0
  167. package/src/modes/theme/theme.ts +133 -143
  168. package/src/modes/types.ts +3 -0
  169. package/src/modes/utils/context-usage.ts +9 -5
  170. package/src/modes/utils/hotkeys-markdown.ts +1 -0
  171. package/src/prompts/system/system-prompt.md +1 -0
  172. package/src/sdk.ts +21 -4
  173. package/src/session/agent-session.ts +160 -33
  174. package/src/session/session-history-format.ts +11 -2
  175. package/src/session/snapcompact-inline.ts +1 -1
  176. package/src/slash-commands/builtin-registry.ts +4 -11
  177. package/src/startup-splash.ts +19 -0
  178. package/src/task/executor.ts +11 -6
  179. package/src/task/types.ts +44 -41
  180. package/src/tool-discovery/tool-index.ts +17 -4
  181. package/src/tools/ask.ts +14 -14
  182. package/src/tools/ast-edit.ts +17 -14
  183. package/src/tools/ast-grep.ts +10 -9
  184. package/src/tools/bash.ts +15 -10
  185. package/src/tools/browser/launch.ts +13 -0
  186. package/src/tools/browser.ts +26 -32
  187. package/src/tools/checkpoint.ts +7 -7
  188. package/src/tools/debug.ts +72 -69
  189. package/src/tools/eval.ts +18 -19
  190. package/src/tools/find.ts +20 -13
  191. package/src/tools/gh.ts +29 -49
  192. package/src/tools/image-gen.ts +27 -32
  193. package/src/tools/inspect-image.ts +8 -9
  194. package/src/tools/irc.ts +12 -12
  195. package/src/tools/job.ts +6 -6
  196. package/src/tools/learn.ts +11 -14
  197. package/src/tools/manage-skill.ts +19 -23
  198. package/src/tools/memory-edit.ts +8 -8
  199. package/src/tools/memory-recall.ts +4 -4
  200. package/src/tools/memory-reflect.ts +5 -5
  201. package/src/tools/memory-retain.ts +9 -11
  202. package/src/tools/puppeteer/02_stealth_hairline.txt +1 -1
  203. package/src/tools/puppeteer/04_stealth_iframe.txt +4 -4
  204. package/src/tools/puppeteer/05_stealth_webgl.txt +1 -1
  205. package/src/tools/puppeteer/10_stealth_plugins.txt +6 -4
  206. package/src/tools/puppeteer/12_stealth_codecs.txt +2 -2
  207. package/src/tools/puppeteer/13_stealth_worker.txt +1 -1
  208. package/src/tools/read.ts +169 -13
  209. package/src/tools/report-tool-issue.ts +6 -6
  210. package/src/tools/resolve.ts +6 -6
  211. package/src/tools/review.ts +10 -12
  212. package/src/tools/search-tool-bm25.ts +5 -5
  213. package/src/tools/search.ts +20 -29
  214. package/src/tools/ssh.ts +8 -8
  215. package/src/tools/todo.ts +16 -19
  216. package/src/tools/tts.ts +16 -15
  217. package/src/tools/write.ts +5 -5
  218. package/src/tui/index.ts +1 -0
  219. package/src/tui/width-aware-text.ts +58 -0
  220. package/src/utils/markit.ts +17 -2
  221. package/src/web/search/index.ts +9 -9
  222. package/src/web/search/providers/perplexity.ts +373 -126
  223. package/src/web/search/types.ts +28 -48
@@ -6,7 +6,7 @@ import { type AstReplaceChange, type AstReplaceFileChange, astEdit } from "@oh-m
6
6
  import type { Component } from "@oh-my-pi/pi-tui";
7
7
  import { replaceTabs, Text } from "@oh-my-pi/pi-tui";
8
8
  import { $envpos, prompt, untilAborted } from "@oh-my-pi/pi-utils";
9
- import { z } from "zod/v4";
9
+ import { type } from "arktype";
10
10
  import { canonicalSnapshotKey, getFileSnapshotStore } from "../edit/file-snapshot-store";
11
11
  import { normalizeToLF } from "../edit/normalize";
12
12
  import type { RenderResultOptions } from "../extensibility/custom-tools/types";
@@ -35,16 +35,17 @@ import { queueResolveHandler } from "./resolve";
35
35
  import { ToolError } from "./tool-errors";
36
36
  import { toolResult } from "./tool-result";
37
37
 
38
- const astEditOpSchema = z.object({
39
- pat: z.string().describe("ast pattern"),
40
- out: z.string().describe("replacement template"),
38
+ const astEditOpSchema = type({
39
+ pat: type("string").describe("ast pattern"),
40
+ out: type("string").describe("replacement template"),
41
41
  });
42
42
 
43
- const astEditSchema = z.object({
44
- ops: z.array(astEditOpSchema).min(1).describe("rewrite ops"),
45
- paths: z
46
- .array(z.string().describe("file, directory, glob, or internal URL to rewrite"))
47
- .min(1)
43
+ const astEditSchema = type({
44
+ ops: astEditOpSchema.array().atLeastLength(1).describe("rewrite ops"),
45
+ paths: type("string")
46
+ .describe("file, directory, glob, or internal URL to rewrite")
47
+ .array()
48
+ .atLeastLength(1)
48
49
  .describe("files, directories, globs, or internal URLs to rewrite"),
49
50
  });
50
51
 
@@ -165,16 +166,18 @@ export interface AstEditToolDetails {
165
166
  cwd?: string;
166
167
  }
167
168
 
169
+ type AstEditSchemaInfer = typeof astEditSchema.infer;
170
+
168
171
  export class AstEditTool implements AgentTool<typeof astEditSchema, AstEditToolDetails> {
169
172
  readonly name = "ast_edit";
170
173
  readonly approval = (args: unknown) => {
171
- const paths = Array.isArray((args as Partial<z.infer<typeof astEditSchema>>).paths)
172
- ? ((args as Partial<z.infer<typeof astEditSchema>>).paths as string[])
174
+ const paths = Array.isArray((args as Partial<AstEditSchemaInfer>).paths)
175
+ ? ((args as Partial<AstEditSchemaInfer>).paths as string[])
173
176
  : [];
174
177
  return paths.length > 0 && paths.every(path => isInternalUrlPath(path)) ? "read" : "write";
175
178
  };
176
179
  readonly formatApprovalDetails = (args: unknown): string[] => {
177
- const params = args as Partial<z.infer<typeof astEditSchema>>;
180
+ const params = args as Partial<AstEditSchemaInfer>;
178
181
  const lines: string[] = [];
179
182
  const ops = Array.isArray(params.ops) ? params.ops : [];
180
183
  const firstOp = ops[0];
@@ -196,7 +199,7 @@ export class AstEditTool implements AgentTool<typeof astEditSchema, AstEditToolD
196
199
  readonly parameters = astEditSchema;
197
200
  readonly strict = true;
198
201
 
199
- readonly examples: readonly ToolExample<z.input<typeof astEditSchema>>[] = [
202
+ readonly examples: readonly ToolExample<AstEditSchemaInfer>[] = [
200
203
  {
201
204
  caption: "Rename a call site across TypeScript files",
202
205
  call: {
@@ -248,7 +251,7 @@ export class AstEditTool implements AgentTool<typeof astEditSchema, AstEditToolD
248
251
 
249
252
  async execute(
250
253
  _toolCallId: string,
251
- params: z.infer<typeof astEditSchema>,
254
+ params: AstEditSchemaInfer,
252
255
  signal?: AbortSignal,
253
256
  _onUpdate?: AgentToolUpdateCallback<AstEditToolDetails>,
254
257
  _context?: AgentToolContext,
@@ -6,7 +6,7 @@ import { type AstFindMatch, astGrep } from "@oh-my-pi/pi-natives";
6
6
  import type { Component } from "@oh-my-pi/pi-tui";
7
7
  import { Text } from "@oh-my-pi/pi-tui";
8
8
  import { prompt, untilAborted } from "@oh-my-pi/pi-utils";
9
- import { z } from "zod/v4";
9
+ import { type } from "arktype";
10
10
  import { recordFileSnapshot, recordSeenLinesFromBody } from "../edit/file-snapshot-store";
11
11
  import type { RenderResultOptions } from "../extensibility/custom-tools/types";
12
12
  import type { Theme } from "../modes/theme/theme";
@@ -34,13 +34,14 @@ import {
34
34
  import { ToolError } from "./tool-errors";
35
35
  import { toolResult } from "./tool-result";
36
36
 
37
- const astGrepSchema = z.object({
38
- pat: z.string().describe("ast pattern"),
39
- paths: z
40
- .array(z.string().describe("file, directory, glob, or internal URL to search"))
41
- .min(1)
37
+ const astGrepSchema = type({
38
+ pat: type("string").describe("ast pattern"),
39
+ paths: type("string")
40
+ .describe("file, directory, glob, or internal URL to search")
41
+ .array()
42
+ .atLeastLength(1)
42
43
  .describe("files, directories, globs, or internal URLs to search"),
43
- skip: z.number().default(0).describe("matches to skip").optional(),
44
+ "skip?": type("number").describe("matches to skip"),
44
45
  });
45
46
 
46
47
  async function runMultiTargetAstGrep(
@@ -132,7 +133,7 @@ export class AstGrepTool implements AgentTool<typeof astGrepSchema, AstGrepToolD
132
133
  readonly parameters = astGrepSchema;
133
134
  readonly strict = true;
134
135
 
135
- readonly examples: readonly ToolExample<z.input<typeof astGrepSchema>>[] = [
136
+ readonly examples: readonly ToolExample<typeof astGrepSchema.inferIn>[] = [
136
137
  {
137
138
  caption: "Search TypeScript files under src",
138
139
  call: { pat: "console.log($$$)", paths: ["src/**/*.ts"] },
@@ -162,7 +163,7 @@ export class AstGrepTool implements AgentTool<typeof astGrepSchema, AstGrepToolD
162
163
 
163
164
  async execute(
164
165
  _toolCallId: string,
165
- params: z.infer<typeof astGrepSchema>,
166
+ params: typeof astGrepSchema.infer,
166
167
  signal?: AbortSignal,
167
168
  _onUpdate?: AgentToolUpdateCallback<AstGrepToolDetails>,
168
169
  _context?: AgentToolContext,
package/src/tools/bash.ts CHANGED
@@ -9,7 +9,7 @@ import type {
9
9
  import type { Component } from "@oh-my-pi/pi-tui";
10
10
  import { ImageProtocol, TERMINAL } from "@oh-my-pi/pi-tui";
11
11
  import { getProjectDir, isEnoent, logger, prompt } from "@oh-my-pi/pi-utils";
12
- import { z } from "zod/v4";
12
+ import { type } from "arktype";
13
13
  import { type BashResult, executeBash } from "../exec/bash-executor";
14
14
  import type { RenderResultOptions } from "../extensibility/custom-tools/types";
15
15
  import { InternalUrlRouter } from "../internal-urls";
@@ -100,16 +100,21 @@ async function saveBashOriginalArtifact(session: ToolSession, originalText: stri
100
100
  }
101
101
  }
102
102
 
103
- const bashSchemaBase = z.object({
104
- command: z.string().describe("command to execute"),
105
- env: z.record(z.string().regex(BASH_ENV_NAME_PATTERN), z.string()).optional().describe("extra env vars"),
106
- timeout: z.number().default(300).describe("timeout in seconds").optional(),
107
- cwd: z.string().describe("working directory").optional(),
108
- pty: z.boolean().describe("run in pty mode").optional(),
103
+ const bashSchemaBase = type({
104
+ command: type("string").describe("command to execute"),
105
+ "env?": type({ "[string]": "string" }).describe("extra env vars"),
106
+ "timeout?": type("number").describe("timeout in seconds"),
107
+ "cwd?": type("string").describe("working directory"),
108
+ "pty?": type("boolean").describe("run in pty mode"),
109
109
  });
110
110
 
111
- const bashSchemaWithAsync = bashSchemaBase.extend({
112
- async: z.boolean().describe("run in background").optional(),
111
+ const bashSchemaWithAsync = type({
112
+ command: "string",
113
+ "env?": { "[string]": "string" },
114
+ "timeout?": "number",
115
+ "cwd?": "string",
116
+ "pty?": "boolean",
117
+ "async?": type("boolean").describe("run in background"),
113
118
  });
114
119
 
115
120
  type BashToolSchema = typeof bashSchemaBase | typeof bashSchemaWithAsync;
@@ -349,7 +354,7 @@ function stripExitCodeNotice(text: string, exitCode: number | undefined): string
349
354
  *
350
355
  * Executes bash commands with optional timeout and working directory.
351
356
  */
352
- export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
357
+ export class BashTool implements AgentTool<typeof bashSchemaBase | typeof bashSchemaWithAsync, BashToolDetails> {
353
358
  readonly name = "bash";
354
359
  readonly approval = (args: unknown): ToolApprovalDecision => {
355
360
  const rawCommand = (args as Partial<BashToolInput>).command;
@@ -610,6 +610,19 @@ function buildStealthInjectionScript(scripts: readonly string[] = STEALTH_PATCH_
610
610
  const Promise_resolve = nativeWindow.Promise.resolve.bind(nativeWindow.Promise);
611
611
  const Window_Blob = nativeWindow.Blob;
612
612
  const Window_Proxy = nativeWindow.Proxy;
613
+ const Reflect_get = nativeWindow.Reflect.get;
614
+ const Reflect_set = nativeWindow.Reflect.set;
615
+ const Reflect_apply = nativeWindow.Reflect.apply;
616
+ const Reflect_construct = nativeWindow.Reflect.construct;
617
+ const Reflect_defineProperty = nativeWindow.Reflect.defineProperty;
618
+ const Reflect_deleteProperty = nativeWindow.Reflect.deleteProperty;
619
+ const Reflect_getOwnPropertyDescriptor = nativeWindow.Reflect.getOwnPropertyDescriptor;
620
+ const Reflect_getPrototypeOf = nativeWindow.Reflect.getPrototypeOf;
621
+ const Reflect_has = nativeWindow.Reflect.has;
622
+ const Reflect_isExtensible = nativeWindow.Reflect.isExtensible;
623
+ const Reflect_ownKeys = nativeWindow.Reflect.ownKeys;
624
+ const Reflect_preventExtensions = nativeWindow.Reflect.preventExtensions;
625
+ const Reflect_setPrototypeOf = nativeWindow.Reflect.setPrototypeOf;
613
626
  const Intl_DateTimeFormat = nativeWindow.Intl.DateTimeFormat;
614
627
  const Date_constructor = nativeWindow.Date;
615
628
 
@@ -1,7 +1,7 @@
1
1
  import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
2
2
  import type { ToolExample } from "@oh-my-pi/pi-ai";
3
3
  import { prompt, untilAborted } from "@oh-my-pi/pi-utils";
4
- import { z } from "zod/v4";
4
+ import { type } from "arktype";
5
5
  import browserDescription from "../prompts/tools/browser.md" with { type: "text" };
6
6
  import type { ToolSession } from "../sdk";
7
7
  import { enforceInlineByteCap } from "../session/streaming-output";
@@ -23,41 +23,35 @@ export type { Observation, ObservationEntry } from "./browser/tab-protocol";
23
23
 
24
24
  const DEFAULT_TAB_NAME = "main";
25
25
 
26
- const appSchema = z.object({
27
- path: z.string().describe("binary path to spawn").optional(),
28
- cdp_url: z.string().describe("existing cdp endpoint").optional(),
29
- args: z.array(z.string()).describe("extra cli args").optional(),
30
- target: z.string().describe("substring to pick a window").optional(),
26
+ const appSchema = type({
27
+ "path?": type("string").describe("binary path to spawn"),
28
+ "cdp_url?": type("string").describe("existing cdp endpoint"),
29
+ "args?": type("string[]").describe("extra cli args"),
30
+ "target?": type("string").describe("substring to pick a window"),
31
31
  });
32
32
 
33
- const browserSchema = z.object({
34
- action: z.enum(["open", "close", "run"] as const).describe("operation"),
35
- name: z.string().describe("tab id (default 'main')").optional(),
36
- url: z.string().describe("url to open").optional(),
37
- app: appSchema.optional(),
38
- viewport: z
39
- .object({
40
- width: z.number(),
41
- height: z.number(),
42
- scale: z.number().optional(),
43
- })
44
- .optional(),
45
- wait_until: z
46
- .enum(["load", "domcontentloaded", "networkidle0", "networkidle2"] as const)
47
- .describe("navigation wait condition")
48
- .optional(),
49
- dialogs: z
50
- .enum(["accept", "dismiss"] as const)
51
- .describe("auto-handle dialogs")
52
- .optional(),
53
- code: z.string().describe("js body to run in tab").optional(),
54
- timeout: z.number().default(30).describe("timeout in seconds (default 30, max 300)").optional(),
55
- all: z.boolean().describe("close every tab").optional(),
56
- kill: z.boolean().describe("also kill spawned-app browsers").optional(),
33
+ const browserSchema = type({
34
+ action: type("'open' | 'close' | 'run'").describe("operation"),
35
+ "name?": type("string").describe("tab id (default 'main')"),
36
+ "url?": type("string").describe("url to open"),
37
+ "app?": appSchema,
38
+ "viewport?": {
39
+ width: "number",
40
+ height: "number",
41
+ "scale?": "number",
42
+ },
43
+ "wait_until?": type("'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2'").describe(
44
+ "navigation wait condition",
45
+ ),
46
+ "dialogs?": type("'accept' | 'dismiss'").describe("auto-handle dialogs"),
47
+ "code?": type("string").describe("js body to run in tab"),
48
+ "timeout?": type("number").describe("timeout in seconds (default 30, max 300)"),
49
+ "all?": type("boolean").describe("close every tab"),
50
+ "kill?": type("boolean").describe("also kill spawned-app browsers"),
57
51
  });
58
52
 
59
53
  /** Input schema for the browser tool. */
60
- export type BrowserParams = z.infer<typeof browserSchema>;
54
+ export type BrowserParams = typeof browserSchema.infer;
61
55
 
62
56
  /** Details describing a browser tool execution result (for renderers + transcript). */
63
57
  export interface BrowserToolDetails {
@@ -119,7 +113,7 @@ export class BrowserTool implements AgentTool<typeof browserSchema, BrowserToolD
119
113
  readonly parameters = browserSchema;
120
114
  readonly strict = true;
121
115
 
122
- readonly examples: readonly ToolExample<z.input<typeof browserSchema>>[] = [
116
+ readonly examples: readonly ToolExample<typeof browserSchema.infer>[] = [
123
117
  {
124
118
  caption: "Open a tab",
125
119
  call: { action: "open", name: "docs", url: "https://example.com" },
@@ -1,6 +1,6 @@
1
1
  import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
2
2
  import { prompt } from "@oh-my-pi/pi-utils";
3
- import { z } from "zod/v4";
3
+ import { type } from "arktype";
4
4
  import checkpointDescription from "../prompts/tools/checkpoint.md" with { type: "text" };
5
5
  import rewindDescription from "../prompts/tools/rewind.md" with { type: "text" };
6
6
  import type { ToolSession } from ".";
@@ -17,17 +17,17 @@ export interface CheckpointState {
17
17
  startedAt: string;
18
18
  }
19
19
 
20
- const checkpointSchema = z.object({
21
- goal: z.string().describe("investigation goal"),
20
+ const checkpointSchema = type({
21
+ goal: type("string").describe("investigation goal"),
22
22
  });
23
23
 
24
- type CheckpointParams = z.infer<typeof checkpointSchema>;
24
+ type CheckpointParams = typeof checkpointSchema.infer;
25
25
 
26
- const rewindSchema = z.object({
27
- report: z.string().describe("investigation findings"),
26
+ const rewindSchema = type({
27
+ report: type("string").describe("investigation findings"),
28
28
  });
29
29
 
30
- type RewindParams = z.infer<typeof rewindSchema>;
30
+ type RewindParams = typeof rewindSchema.infer;
31
31
 
32
32
  export interface CheckpointToolDetails {
33
33
  goal: string;
@@ -10,7 +10,7 @@ import type {
10
10
  import type { ToolExample } from "@oh-my-pi/pi-ai";
11
11
  import { type Component, Text } from "@oh-my-pi/pi-tui";
12
12
  import { isEnoent, prompt } from "@oh-my-pi/pi-utils";
13
- import { z } from "zod/v4";
13
+ import { type } from "arktype";
14
14
  import {
15
15
  type DapBreakpointRecord,
16
16
  type DapCapabilities,
@@ -74,75 +74,78 @@ export const DEBUG_READONLY_ACTIONS: ReadonlySet<string> = new Set([
74
74
  "modules",
75
75
  "sessions",
76
76
  ]);
77
- const debugSchema = z.object({
78
- action: z.enum([
79
- "launch",
80
- "attach",
81
- "set_breakpoint",
82
- "remove_breakpoint",
83
- "set_instruction_breakpoint",
84
- "remove_instruction_breakpoint",
85
- "data_breakpoint_info",
86
- "set_data_breakpoint",
87
- "remove_data_breakpoint",
88
- "continue",
89
- "step_over",
90
- "step_in",
91
- "step_out",
92
- "pause",
93
- "evaluate",
94
- "stack_trace",
95
- "threads",
96
- "scopes",
97
- "variables",
98
- "disassemble",
99
- "read_memory",
100
- "write_memory",
101
- "modules",
102
- "loaded_sources",
103
- "custom_request",
104
- "output",
105
- "terminate",
106
- "sessions",
107
- ] as const),
108
- program: z.string().describe("program path").optional(),
109
- args: z.array(z.string()).describe("program arguments").optional(),
110
- adapter: z.string().describe("debugger adapter (gdb, lldb-dap, debugpy, dlv)").optional(),
111
- cwd: z.string().optional(),
112
- file: z.string().describe("source file").optional(),
113
- line: z.number().describe("source line").optional(),
114
- function: z.string().describe("function name").optional(),
115
- name: z.string().describe("variable or data name").optional(),
116
- condition: z.string().describe("breakpoint condition").optional(),
117
- hit_condition: z.string().optional(),
118
- expression: z.string().describe("expression to evaluate").optional(),
119
- context: z.string().describe("evaluate context: watch | repl | hover | variables | clipboard").optional(),
120
- frame_id: z.number().optional(),
121
- scope_id: z.number().describe("scope variables reference").optional(),
122
- variable_ref: z.number().describe("variable reference").optional(),
123
- pid: z.number().describe("process id for attach").optional(),
124
- port: z.number().describe("remote attach port").optional(),
125
- host: z.string().describe("remote attach host").optional(),
126
- levels: z.number().describe("max stack frames").optional(),
127
- memory_reference: z.string().describe("memory reference or address").optional(),
128
- instruction_reference: z.string().optional(),
129
- instruction_count: z.number().optional(),
130
- instruction_offset: z.number().optional(),
131
- count: z.number().describe("bytes to read").optional(),
132
- data: z.string().describe("base64 memory payload").optional(),
133
- data_id: z.string().describe("data breakpoint id").optional(),
134
- access_type: z.enum(["read", "write", "readWrite"] as const).optional(),
135
- command: z.string().describe("custom dap request command").optional(),
136
- arguments: z.record(z.string(), z.any()).describe("custom request arguments").optional(),
137
- offset: z.number().optional(),
138
- resolve_symbols: z.boolean().optional(),
139
- allow_partial: z.boolean().optional(),
140
- start_module: z.number().optional(),
141
- module_count: z.number().optional(),
142
- timeout: z.number().describe("per-request timeout seconds").optional(),
77
+ const debugActionSchema = type.enumerated(
78
+ "launch",
79
+ "attach",
80
+ "set_breakpoint",
81
+ "remove_breakpoint",
82
+ "set_instruction_breakpoint",
83
+ "remove_instruction_breakpoint",
84
+ "data_breakpoint_info",
85
+ "set_data_breakpoint",
86
+ "remove_data_breakpoint",
87
+ "continue",
88
+ "step_over",
89
+ "step_in",
90
+ "step_out",
91
+ "pause",
92
+ "evaluate",
93
+ "stack_trace",
94
+ "threads",
95
+ "scopes",
96
+ "variables",
97
+ "disassemble",
98
+ "read_memory",
99
+ "write_memory",
100
+ "modules",
101
+ "loaded_sources",
102
+ "custom_request",
103
+ "output",
104
+ "terminate",
105
+ "sessions",
106
+ );
107
+ const debugSchema = type({
108
+ action: debugActionSchema,
109
+ "program?": type("string").describe("program path"),
110
+ "args?": type("string[]").describe("program arguments"),
111
+ "adapter?": type("string").describe("debugger adapter (gdb, lldb-dap, debugpy, dlv)"),
112
+ cwd: "string?",
113
+ "file?": type("string").describe("source file"),
114
+ "line?": type("number").describe("source line"),
115
+ "function?": type("string").describe("function name"),
116
+ "name?": type("string").describe("variable or data name"),
117
+ "condition?": type("string").describe("breakpoint condition"),
118
+ hit_condition: "string?",
119
+ "expression?": type("string").describe("expression to evaluate"),
120
+ "context?": type("string").describe("evaluate context: watch | repl | hover | variables | clipboard"),
121
+ frame_id: "number?",
122
+ "scope_id?": type("number").describe("scope variables reference"),
123
+ "variable_ref?": type("number").describe("variable reference"),
124
+ "pid?": type("number").describe("process id for attach"),
125
+ "port?": type("number").describe("remote attach port"),
126
+ "host?": type("string").describe("remote attach host"),
127
+ "levels?": type("number").describe("max stack frames"),
128
+ "memory_reference?": type("string").describe("memory reference or address"),
129
+ instruction_reference: "string?",
130
+ instruction_count: "number?",
131
+ instruction_offset: "number?",
132
+ "count?": type("number").describe("bytes to read"),
133
+ "data?": type("string").describe("base64 memory payload"),
134
+ "data_id?": type("string").describe("data breakpoint id"),
135
+ "access_type?": "'read' | 'write' | 'readWrite'",
136
+ "command?": type("string").describe("custom dap request command"),
137
+ "arguments?": type({
138
+ "[string]": "unknown",
139
+ }).describe("custom request arguments"),
140
+ offset: "number?",
141
+ resolve_symbols: "boolean?",
142
+ allow_partial: "boolean?",
143
+ start_module: "number?",
144
+ module_count: "number?",
145
+ "timeout?": type("number").describe("per-request timeout seconds"),
143
146
  });
144
147
 
145
- export type DebugParams = z.infer<typeof debugSchema>;
148
+ export type DebugParams = typeof debugSchema.infer;
146
149
  export type DebugAction = DebugParams["action"];
147
150
 
148
151
  interface DebugToolDetails {
@@ -661,7 +664,7 @@ export class DebugTool implements AgentTool<typeof debugSchema, DebugToolDetails
661
664
  readonly parameters = debugSchema;
662
665
  readonly strict = true;
663
666
 
664
- readonly examples: readonly ToolExample<z.input<typeof debugSchema>>[] = [
667
+ readonly examples: readonly ToolExample<typeof debugSchema.infer>[] = [
665
668
  {
666
669
  caption: "Launch and inspect hang",
667
670
  note: '1. debug(action: "launch", program: "./my_app")\n2. debug(action: "set_breakpoint", file: "src/main.c", line: 42)\n3. debug(action: "continue")\n4. If the program appears hung: debug(action: "pause")\n5. Inspect state with `threads`, `stack_trace`, `scopes`, and `variables`',
package/src/tools/eval.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
2
2
  import type { ImageContent, ToolExample } from "@oh-my-pi/pi-ai";
3
3
  import { prompt } from "@oh-my-pi/pi-utils";
4
- import { z } from "zod/v4";
4
+ import { type } from "arktype";
5
5
  import { jsBackend, pythonBackend } from "../eval";
6
6
  import type { ExecutorBackend, ExecutorBackendResult } from "../eval/backend";
7
7
  import { EVAL_TIMEOUT_PAUSE_OP, EVAL_TIMEOUT_RESUME_OP } from "../eval/bridge-timeout";
@@ -27,25 +27,24 @@ export { EVAL_DEFAULT_PREVIEW_LINES, evalToolRenderer } from "./eval-render";
27
27
  * Per-cell input. Each cell runs in order; state persists within a language
28
28
  * across cells and across tool calls.
29
29
  */
30
- const evalCellSchema = z.object({
31
- language: z.enum(["py", "js"]).describe('runtime: "py" for the IPython kernel, "js" for the persistent JS VM'),
32
- code: z.string().describe("cell body, verbatim. Use top-level await freely."),
33
- title: z.string().optional().describe('short label shown in transcript (e.g. "imports", "load config")'),
34
- timeout: z.number().int().min(1).max(3600).optional().describe("per-cell timeout in seconds (1-3600, default 30)"),
35
- reset: z
36
- .boolean()
37
- .optional()
38
- .describe("wipe this cell's language kernel before running. Other languages are untouched."),
30
+ const evalCellSchema = type({
31
+ language: type("'py' | 'js'").describe('runtime: "py" for the IPython kernel, "js" for the persistent JS VM'),
32
+ code: type("string").describe("cell body, verbatim. Use top-level await freely."),
33
+ "title?": type("string").describe('short label shown in transcript (e.g. "imports", "load config")'),
34
+ "timeout?": type("number").describe("per-cell timeout in seconds (1-3600, default 30)"),
35
+ "reset?": type("boolean").describe(
36
+ "wipe this cell's language kernel before running. Other languages are untouched.",
37
+ ),
39
38
  });
40
- export type EvalCellInput = z.infer<typeof evalCellSchema>;
39
+ export type EvalCellInput = typeof evalCellSchema.infer;
41
40
 
42
- export const evalSchema = z.object({
43
- cells: z
44
- .array(evalCellSchema)
45
- .min(1)
41
+ export const evalSchema = type({
42
+ cells: evalCellSchema
43
+ .array()
44
+ .atLeastLength(1)
46
45
  .describe("cells executed in order. State persists within each language across cells and tool calls."),
47
46
  });
48
- export type EvalToolParams = z.infer<typeof evalSchema>;
47
+ export type EvalToolParams = typeof evalSchema.infer;
49
48
 
50
49
  export type EvalToolResult = {
51
50
  content: Array<{ type: "text"; text: string }>;
@@ -183,7 +182,7 @@ export class EvalTool implements AgentTool<typeof evalSchema> {
183
182
  const spawnsAllowed = sessionSpawns !== "" && sessionSpawns !== null;
184
183
  return getEvalToolDescription({ py: backends.python, js: backends.js, spawns: spawnsAllowed });
185
184
  }
186
- readonly examples: readonly ToolExample<z.input<typeof evalSchema>>[] = [
185
+ readonly examples: readonly ToolExample<typeof evalSchema.infer>[] = [
187
186
  {
188
187
  call: {
189
188
  cells: [
@@ -205,7 +204,7 @@ export class EvalTool implements AgentTool<typeof evalSchema> {
205
204
  readonly parameters = evalSchema;
206
205
  readonly concurrency = "exclusive";
207
206
  readonly strict = true;
208
- readonly intent = (args: Partial<z.infer<typeof evalSchema>>): string | undefined => {
207
+ readonly intent = (args: Partial<typeof evalSchema.infer>): string | undefined => {
209
208
  const cells = Array.isArray(args.cells) ? args.cells : [];
210
209
  const first = cells.find(c => c && typeof c === "object");
211
210
  if (!first) return "evaluating";
@@ -226,7 +225,7 @@ export class EvalTool implements AgentTool<typeof evalSchema> {
226
225
 
227
226
  async execute(
228
227
  _toolCallId: string,
229
- params: z.infer<typeof evalSchema>,
228
+ params: typeof evalSchema.infer,
230
229
  signal?: AbortSignal,
231
230
  onUpdate?: AgentToolUpdateCallback,
232
231
  _ctx?: AgentToolContext,
package/src/tools/find.ts CHANGED
@@ -6,7 +6,7 @@ import * as natives from "@oh-my-pi/pi-natives";
6
6
  import type { Component } from "@oh-my-pi/pi-tui";
7
7
  import { Text } from "@oh-my-pi/pi-tui";
8
8
  import { formatGroupedPaths, isEnoent, prompt, untilAborted } from "@oh-my-pi/pi-utils";
9
- import { z } from "zod/v4";
9
+ import { type } from "arktype";
10
10
  import type { RenderResultOptions } from "../extensibility/custom-tools/types";
11
11
  import { InternalUrlRouter } from "../internal-urls";
12
12
  import type { Theme } from "../modes/theme/theme";
@@ -36,17 +36,24 @@ import {
36
36
  import { ToolAbortError, ToolError, throwIfAborted } from "./tool-errors";
37
37
  import { toolResult } from "./tool-result";
38
38
 
39
- const findSchema = z
40
- .object({
41
- paths: z.array(z.string().describe("glob including search path")).min(1).describe("globs including search paths"),
42
- hidden: z.boolean().default(true).describe("include hidden files").optional(),
43
- gitignore: z.boolean().default(true).describe("respect gitignore").optional(),
44
- limit: z.number().default(200).describe("max results (clamped to 1-200)").optional(),
45
- timeout: z.number().min(0.5).max(60).default(5).describe("timeout in seconds (0.5–60)").optional(),
46
- })
47
- .strict();
39
+ const findSchema = type({
40
+ paths: type("string")
41
+ .describe("glob including search path")
42
+ .array()
43
+ .atLeastLength(1)
44
+ .describe("globs including search paths"),
45
+ "hidden?": type("boolean").describe("include hidden files"),
46
+ "gitignore?": type("boolean").describe("respect gitignore"),
47
+ "limit?": type("number").describe("max results (clamped to 1-200)"),
48
+ "timeout?": type("number").describe("timeout in seconds (0.5–60)"),
49
+ }).narrow((o, ctx) => {
50
+ if (o.timeout !== undefined && (o.timeout < 0.5 || o.timeout > 60)) {
51
+ return ctx.mustBe("a timeout between 0.5 and 60 seconds");
52
+ }
53
+ return true;
54
+ });
48
55
 
49
- export type FindToolInput = z.infer<typeof findSchema>;
56
+ export type FindToolInput = typeof findSchema.infer;
50
57
 
51
58
  const DEFAULT_LIMIT = 200;
52
59
  const MAX_LIMIT = 200;
@@ -108,7 +115,7 @@ export class FindTool implements AgentTool<typeof findSchema, FindToolDetails> {
108
115
  readonly description: string;
109
116
  readonly parameters = findSchema;
110
117
 
111
- readonly examples: readonly ToolExample<z.input<typeof findSchema>>[] = [
118
+ readonly examples: readonly ToolExample<typeof findSchema.infer>[] = [
112
119
  {
113
120
  caption: "Find files",
114
121
  call: { paths: ["src/**/*.ts"] },
@@ -144,7 +151,7 @@ export class FindTool implements AgentTool<typeof findSchema, FindToolDetails> {
144
151
 
145
152
  async execute(
146
153
  _toolCallId: string,
147
- params: z.infer<typeof findSchema>,
154
+ params: typeof findSchema.infer,
148
155
  signal?: AbortSignal,
149
156
  onUpdate?: AgentToolUpdateCallback<FindToolDetails>,
150
157
  _context?: AgentToolContext,