@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.
- package/CHANGELOG.md +53 -0
- package/dist/cli.js +1927 -1376
- package/dist/types/advisor/advise-tool.d.ts +22 -19
- package/dist/types/autoresearch/tools/init-experiment.d.ts +13 -17
- package/dist/types/autoresearch/tools/log-experiment.d.ts +17 -19
- package/dist/types/autoresearch/tools/run-experiment.d.ts +3 -4
- package/dist/types/autoresearch/tools/update-notes.d.ts +4 -5
- package/dist/types/cli/ttsr-cli.d.ts +39 -0
- package/dist/types/commands/ttsr.d.ts +57 -0
- package/dist/types/commit/agentic/tools/analyze-file.d.ts +4 -5
- package/dist/types/commit/agentic/tools/git-file-diff.d.ts +4 -5
- package/dist/types/commit/agentic/tools/git-hunk.d.ts +5 -6
- package/dist/types/commit/agentic/tools/git-overview.d.ts +4 -5
- package/dist/types/commit/agentic/tools/propose-changelog.d.ts +23 -24
- package/dist/types/commit/agentic/tools/propose-commit.d.ts +11 -32
- package/dist/types/commit/agentic/tools/recent-commits.d.ts +3 -4
- package/dist/types/commit/agentic/tools/schemas.d.ts +6 -27
- package/dist/types/commit/agentic/tools/split-commit.d.ts +28 -49
- package/dist/types/commit/changelog/generate.d.ts +12 -13
- package/dist/types/commit/shared-llm.d.ts +10 -37
- package/dist/types/config/config-file.d.ts +4 -4
- package/dist/types/config/keybindings.d.ts +5 -0
- package/dist/types/config/models-config-schema.d.ts +625 -990
- package/dist/types/config/models-config.d.ts +229 -217
- package/dist/types/config/settings-schema.d.ts +53 -23
- package/dist/types/edit/hashline/params.d.ts +7 -11
- package/dist/types/edit/index.d.ts +2 -1
- package/dist/types/edit/modes/apply-patch.d.ts +4 -5
- package/dist/types/edit/modes/patch.d.ts +15 -24
- package/dist/types/edit/modes/replace.d.ts +16 -17
- package/dist/types/eval/js/index.d.ts +1 -0
- package/dist/types/extensibility/custom-commands/types.d.ts +6 -3
- package/dist/types/extensibility/custom-tools/types.d.ts +8 -5
- package/dist/types/extensibility/extensions/types.d.ts +6 -3
- package/dist/types/extensibility/hooks/types.d.ts +7 -4
- package/dist/types/extensibility/legacy-pi-ai-shim.d.ts +13 -5
- package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +17 -0
- package/dist/types/extensibility/typebox.d.ts +80 -58
- package/dist/types/goals/tools/goal-tool.d.ts +11 -24
- package/dist/types/index.d.ts +2 -0
- package/dist/types/lsp/index.d.ts +11 -26
- package/dist/types/lsp/types.d.ts +12 -28
- package/dist/types/mcp/client.d.ts +8 -0
- package/dist/types/modes/components/btw-panel.d.ts +1 -0
- package/dist/types/modes/components/custom-editor.d.ts +3 -1
- package/dist/types/modes/controllers/btw-controller.d.ts +2 -0
- package/dist/types/modes/controllers/input-controller.d.ts +1 -0
- package/dist/types/modes/interactive-mode.d.ts +3 -0
- package/dist/types/modes/setup-wizard/index.d.ts +1 -0
- package/dist/types/modes/setup-wizard/startup-splash.d.ts +7 -0
- package/dist/types/modes/theme/theme.d.ts +1 -1
- package/dist/types/modes/types.d.ts +3 -0
- package/dist/types/sdk.d.ts +5 -0
- package/dist/types/session/agent-session.d.ts +4 -0
- package/dist/types/startup-splash.d.ts +12 -0
- package/dist/types/task/types.d.ts +47 -48
- package/dist/types/tools/ask.d.ts +26 -27
- package/dist/types/tools/ast-edit.d.ts +17 -17
- package/dist/types/tools/ast-grep.d.ts +12 -13
- package/dist/types/tools/bash.d.ts +20 -17
- package/dist/types/tools/browser.d.ts +46 -71
- package/dist/types/tools/checkpoint.d.ts +14 -15
- package/dist/types/tools/debug.d.ts +82 -145
- package/dist/types/tools/eval.d.ts +30 -40
- package/dist/types/tools/find.d.ts +17 -18
- package/dist/types/tools/gh.d.ts +49 -78
- package/dist/types/tools/image-gen.d.ts +20 -36
- package/dist/types/tools/inspect-image.d.ts +10 -11
- package/dist/types/tools/irc.d.ts +22 -33
- package/dist/types/tools/job.d.ts +11 -12
- package/dist/types/tools/learn.d.ts +21 -28
- package/dist/types/tools/manage-skill.d.ts +13 -22
- package/dist/types/tools/memory-edit.d.ts +15 -24
- package/dist/types/tools/memory-recall.d.ts +7 -8
- package/dist/types/tools/memory-reflect.d.ts +9 -10
- package/dist/types/tools/memory-retain.d.ts +13 -14
- package/dist/types/tools/read.d.ts +7 -8
- package/dist/types/tools/resolve.d.ts +11 -18
- package/dist/types/tools/review.d.ts +9 -15
- package/dist/types/tools/search-tool-bm25.d.ts +9 -10
- package/dist/types/tools/search.d.ts +16 -17
- package/dist/types/tools/ssh.d.ts +14 -15
- package/dist/types/tools/todo.d.ts +27 -43
- package/dist/types/tools/tts.d.ts +8 -9
- package/dist/types/tools/write.d.ts +9 -10
- package/dist/types/tui/index.d.ts +1 -0
- package/dist/types/tui/width-aware-text.d.ts +23 -0
- package/dist/types/utils/markit.d.ts +10 -1
- package/dist/types/web/search/index.d.ts +17 -28
- package/dist/types/web/search/providers/perplexity.d.ts +0 -2
- package/dist/types/web/search/types.d.ts +32 -26
- package/package.json +14 -13
- package/scripts/omp +1 -1
- package/src/advisor/__tests__/advisor.test.ts +44 -1
- package/src/advisor/advise-tool.ts +34 -11
- package/src/autoresearch/tools/init-experiment.ts +13 -16
- package/src/autoresearch/tools/log-experiment.ts +15 -18
- package/src/autoresearch/tools/run-experiment.ts +3 -3
- package/src/autoresearch/tools/update-notes.ts +4 -4
- package/src/cli/ttsr-cli.ts +995 -0
- package/src/cli-commands.ts +1 -0
- package/src/cli.ts +7 -1
- package/src/commands/ttsr.ts +125 -0
- package/src/commit/agentic/tools/analyze-file.ts +4 -4
- package/src/commit/agentic/tools/git-file-diff.ts +4 -4
- package/src/commit/agentic/tools/git-hunk.ts +7 -5
- package/src/commit/agentic/tools/git-overview.ts +4 -4
- package/src/commit/agentic/tools/propose-changelog.ts +18 -15
- package/src/commit/agentic/tools/propose-commit.ts +6 -6
- package/src/commit/agentic/tools/recent-commits.ts +3 -3
- package/src/commit/agentic/tools/schemas.ts +8 -20
- package/src/commit/agentic/tools/split-commit.ts +19 -23
- package/src/commit/analysis/summary.ts +7 -5
- package/src/commit/changelog/generate.ts +15 -11
- package/src/commit/shared-llm.ts +17 -24
- package/src/config/config-file.ts +13 -15
- package/src/config/keybindings.ts +6 -0
- package/src/config/models-config-schema.ts +206 -179
- package/src/config/settings-schema.ts +34 -0
- package/src/discovery/builtin-rules/index.ts +2 -0
- package/src/discovery/builtin-rules/ts-import-type.md +2 -2
- package/src/discovery/builtin-rules/ts-no-any.md +11 -2
- package/src/discovery/builtin-rules/ts-no-inline-cast-access.md +55 -0
- package/src/edit/hashline/params.ts +12 -11
- package/src/edit/index.ts +5 -4
- package/src/edit/modes/apply-patch.ts +4 -4
- package/src/edit/modes/patch.ts +15 -18
- package/src/edit/modes/replace.ts +13 -17
- package/src/edit/renderer.ts +0 -1
- package/src/eval/agent-bridge.ts +11 -13
- package/src/eval/completion-bridge.ts +25 -17
- package/src/eval/js/context-manager.ts +17 -2
- package/src/eval/js/index.ts +1 -1
- package/src/eval/py/executor.ts +2 -2
- package/src/extensibility/custom-commands/loader.ts +5 -3
- package/src/extensibility/custom-commands/types.ts +6 -3
- package/src/extensibility/custom-tools/loader.ts +4 -2
- package/src/extensibility/custom-tools/types.ts +8 -5
- package/src/extensibility/extensions/loader.ts +4 -2
- package/src/extensibility/extensions/types.ts +6 -3
- package/src/extensibility/hooks/loader.ts +5 -2
- package/src/extensibility/hooks/types.ts +7 -4
- package/src/extensibility/legacy-pi-ai-shim.ts +42 -5
- package/src/extensibility/legacy-pi-coding-agent-shim.ts +113 -0
- package/src/extensibility/plugins/legacy-pi-compat.ts +13 -13
- package/src/extensibility/tool-proxy.ts +4 -1
- package/src/extensibility/typebox.ts +778 -251
- package/src/goals/guided-setup.ts +12 -3
- package/src/goals/tools/goal-tool.ts +6 -6
- package/src/index.ts +2 -0
- package/src/internal-urls/docs-index.generated.ts +11 -9
- package/src/lsp/types.ts +13 -27
- package/src/main.ts +19 -18
- package/src/mcp/client.ts +38 -13
- package/src/mcp/render.ts +102 -89
- package/src/modes/components/agent-hub.ts +11 -4
- package/src/modes/components/btw-panel.ts +5 -1
- package/src/modes/components/custom-editor.ts +18 -0
- package/src/modes/components/status-line/component.ts +8 -1
- package/src/modes/components/tool-execution.ts +17 -10
- package/src/modes/controllers/btw-controller.ts +69 -1
- package/src/modes/controllers/input-controller.ts +29 -0
- package/src/modes/interactive-mode.ts +38 -8
- package/src/modes/setup-wizard/index.ts +1 -0
- package/src/modes/setup-wizard/scenes/sign-in.ts +77 -5
- package/src/modes/setup-wizard/startup-splash.ts +107 -0
- package/src/modes/theme/theme.ts +133 -143
- package/src/modes/types.ts +3 -0
- package/src/modes/utils/context-usage.ts +9 -5
- package/src/modes/utils/hotkeys-markdown.ts +1 -0
- package/src/prompts/system/system-prompt.md +1 -0
- package/src/sdk.ts +21 -4
- package/src/session/agent-session.ts +160 -33
- package/src/session/session-history-format.ts +11 -2
- package/src/session/snapcompact-inline.ts +1 -1
- package/src/slash-commands/builtin-registry.ts +4 -11
- package/src/startup-splash.ts +19 -0
- package/src/task/executor.ts +11 -6
- package/src/task/types.ts +44 -41
- package/src/tool-discovery/tool-index.ts +17 -4
- package/src/tools/ask.ts +14 -14
- package/src/tools/ast-edit.ts +17 -14
- package/src/tools/ast-grep.ts +10 -9
- package/src/tools/bash.ts +15 -10
- package/src/tools/browser/launch.ts +13 -0
- package/src/tools/browser.ts +26 -32
- package/src/tools/checkpoint.ts +7 -7
- package/src/tools/debug.ts +72 -69
- package/src/tools/eval.ts +18 -19
- package/src/tools/find.ts +20 -13
- package/src/tools/gh.ts +29 -49
- package/src/tools/image-gen.ts +27 -32
- package/src/tools/inspect-image.ts +8 -9
- package/src/tools/irc.ts +12 -12
- package/src/tools/job.ts +6 -6
- package/src/tools/learn.ts +11 -14
- package/src/tools/manage-skill.ts +19 -23
- package/src/tools/memory-edit.ts +8 -8
- package/src/tools/memory-recall.ts +4 -4
- package/src/tools/memory-reflect.ts +5 -5
- package/src/tools/memory-retain.ts +9 -11
- package/src/tools/puppeteer/02_stealth_hairline.txt +1 -1
- package/src/tools/puppeteer/04_stealth_iframe.txt +4 -4
- package/src/tools/puppeteer/05_stealth_webgl.txt +1 -1
- package/src/tools/puppeteer/10_stealth_plugins.txt +6 -4
- package/src/tools/puppeteer/12_stealth_codecs.txt +2 -2
- package/src/tools/puppeteer/13_stealth_worker.txt +1 -1
- package/src/tools/read.ts +169 -13
- package/src/tools/report-tool-issue.ts +6 -6
- package/src/tools/resolve.ts +6 -6
- package/src/tools/review.ts +10 -12
- package/src/tools/search-tool-bm25.ts +5 -5
- package/src/tools/search.ts +20 -29
- package/src/tools/ssh.ts +8 -8
- package/src/tools/todo.ts +16 -19
- package/src/tools/tts.ts +16 -15
- package/src/tools/write.ts +5 -5
- package/src/tui/index.ts +1 -0
- package/src/tui/width-aware-text.ts +58 -0
- package/src/utils/markit.ts +17 -2
- package/src/web/search/index.ts +9 -9
- package/src/web/search/providers/perplexity.ts +373 -126
- package/src/web/search/types.ts +28 -48
package/src/tools/ast-edit.ts
CHANGED
|
@@ -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 {
|
|
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 =
|
|
39
|
-
pat:
|
|
40
|
-
out:
|
|
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 =
|
|
44
|
-
ops:
|
|
45
|
-
paths:
|
|
46
|
-
.
|
|
47
|
-
.
|
|
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<
|
|
172
|
-
? ((args as Partial<
|
|
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<
|
|
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<
|
|
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:
|
|
254
|
+
params: AstEditSchemaInfer,
|
|
252
255
|
signal?: AbortSignal,
|
|
253
256
|
_onUpdate?: AgentToolUpdateCallback<AstEditToolDetails>,
|
|
254
257
|
_context?: AgentToolContext,
|
package/src/tools/ast-grep.ts
CHANGED
|
@@ -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 {
|
|
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 =
|
|
38
|
-
pat:
|
|
39
|
-
paths:
|
|
40
|
-
.
|
|
41
|
-
.
|
|
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:
|
|
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<
|
|
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:
|
|
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 {
|
|
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 =
|
|
104
|
-
command:
|
|
105
|
-
env:
|
|
106
|
-
timeout:
|
|
107
|
-
cwd:
|
|
108
|
-
pty:
|
|
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 =
|
|
112
|
-
|
|
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<
|
|
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
|
|
package/src/tools/browser.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 { ToolExample } from "@oh-my-pi/pi-ai";
|
|
3
3
|
import { prompt, untilAborted } from "@oh-my-pi/pi-utils";
|
|
4
|
-
import {
|
|
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 =
|
|
27
|
-
path:
|
|
28
|
-
cdp_url:
|
|
29
|
-
args:
|
|
30
|
-
target:
|
|
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 =
|
|
34
|
-
action:
|
|
35
|
-
name:
|
|
36
|
-
url:
|
|
37
|
-
app: appSchema
|
|
38
|
-
viewport:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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 =
|
|
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<
|
|
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" },
|
package/src/tools/checkpoint.ts
CHANGED
|
@@ -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 {
|
|
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 =
|
|
21
|
-
goal:
|
|
20
|
+
const checkpointSchema = type({
|
|
21
|
+
goal: type("string").describe("investigation goal"),
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
type CheckpointParams =
|
|
24
|
+
type CheckpointParams = typeof checkpointSchema.infer;
|
|
25
25
|
|
|
26
|
-
const rewindSchema =
|
|
27
|
-
report:
|
|
26
|
+
const rewindSchema = type({
|
|
27
|
+
report: type("string").describe("investigation findings"),
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
type RewindParams =
|
|
30
|
+
type RewindParams = typeof rewindSchema.infer;
|
|
31
31
|
|
|
32
32
|
export interface CheckpointToolDetails {
|
|
33
33
|
goal: string;
|
package/src/tools/debug.ts
CHANGED
|
@@ -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 {
|
|
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
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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 =
|
|
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<
|
|
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 {
|
|
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 =
|
|
31
|
-
language:
|
|
32
|
-
code:
|
|
33
|
-
title:
|
|
34
|
-
timeout:
|
|
35
|
-
reset:
|
|
36
|
-
.
|
|
37
|
-
|
|
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 =
|
|
39
|
+
export type EvalCellInput = typeof evalCellSchema.infer;
|
|
41
40
|
|
|
42
|
-
export const evalSchema =
|
|
43
|
-
cells:
|
|
44
|
-
.array(
|
|
45
|
-
.
|
|
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 =
|
|
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<
|
|
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<
|
|
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:
|
|
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 {
|
|
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 =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.
|
|
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 =
|
|
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<
|
|
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:
|
|
154
|
+
params: typeof findSchema.infer,
|
|
148
155
|
signal?: AbortSignal,
|
|
149
156
|
onUpdate?: AgentToolUpdateCallback<FindToolDetails>,
|
|
150
157
|
_context?: AgentToolContext,
|