@oh-my-pi/pi-coding-agent 16.0.5 → 16.0.7
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 +60 -0
- package/dist/cli.js +1945 -1386
- 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 +173 -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 +3 -10
- 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
|
@@ -11,14 +11,51 @@
|
|
|
11
11
|
* bare package root. Subpath imports (`@oh-my-pi/pi-ai/oauth`, etc.)
|
|
12
12
|
* continue to resolve directly against the bundled pi-ai package.
|
|
13
13
|
*
|
|
14
|
-
* The `Type` runtime
|
|
15
|
-
* already serves
|
|
16
|
-
* class, keeping the legacy-compat surface internally consistent.
|
|
14
|
+
* The `Type` runtime and legacy `StringEnum()` helper are borrowed from the
|
|
15
|
+
* Zod-backed TypeBox shim that already serves TypeBox imports for the same
|
|
16
|
+
* extension class, keeping the legacy-compat surface internally consistent.
|
|
17
17
|
*
|
|
18
18
|
* Type-level `Static` and `TSchema` continue to come from pi-ai's own
|
|
19
19
|
* `types.ts` via the `export *` below — pi-ai still exports both as types,
|
|
20
|
-
* only the runtime `Type` builder
|
|
20
|
+
* only the runtime `Type` builder and `StringEnum()` helper were removed.
|
|
21
21
|
*/
|
|
22
|
+
import { type TSchema, Type } from "./typebox";
|
|
23
|
+
|
|
24
|
+
export interface StringEnumOptions<T extends string> {
|
|
25
|
+
description?: string;
|
|
26
|
+
default?: T;
|
|
27
|
+
examples?: T[];
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function stringEnumWireSchema<T extends string>(values: readonly T[], options: StringEnumOptions<T> | undefined) {
|
|
32
|
+
const schema: Record<string, unknown> = {
|
|
33
|
+
type: "string",
|
|
34
|
+
enum: [...values],
|
|
35
|
+
};
|
|
36
|
+
if (!options) return schema;
|
|
37
|
+
for (const key in options) {
|
|
38
|
+
if (options[key] !== undefined) {
|
|
39
|
+
schema[key] = options[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return schema;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function StringEnum<T extends string>(values: readonly T[], options?: StringEnumOptions<T>): TSchema {
|
|
46
|
+
const opts = {
|
|
47
|
+
description: options?.description ?? "Legacy string enum compatibility schema",
|
|
48
|
+
...options,
|
|
49
|
+
};
|
|
50
|
+
const schema: TSchema = values.length === 0 ? Type.Never(opts) : Type.Enum(values, opts);
|
|
51
|
+
Object.defineProperty(schema, "toJSON", {
|
|
52
|
+
value: () => stringEnumWireSchema(values, options),
|
|
53
|
+
enumerable: false,
|
|
54
|
+
writable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
});
|
|
57
|
+
return schema;
|
|
58
|
+
}
|
|
22
59
|
|
|
23
60
|
export * from "@oh-my-pi/pi-ai";
|
|
24
|
-
export { Type }
|
|
61
|
+
export { Type };
|
|
@@ -12,4 +12,117 @@
|
|
|
12
12
|
* the same module identity as a direct `@oh-my-pi/pi-coding-agent` import.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import type { AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
|
|
16
|
+
import type { TSchema } from "@oh-my-pi/pi-ai";
|
|
17
|
+
import { parseFrontmatter as parseOmpFrontmatter } from "@oh-my-pi/pi-utils";
|
|
18
|
+
import { Settings } from "../config/settings";
|
|
19
|
+
import { BUILTIN_TOOLS, type Tool, type ToolSession } from "../tools";
|
|
20
|
+
import type { ToolDefinition } from "./extensions/types";
|
|
21
|
+
import { Type } from "./typebox";
|
|
22
|
+
|
|
23
|
+
const TOOL_DEFINITION_MARKER = "__isToolDefinition";
|
|
24
|
+
const LEGACY_BUILTIN_TOOL_MARKER = "__ompLegacyBuiltinTool";
|
|
25
|
+
const LEGACY_CODING_TOOL_NAMES = ["read", "bash", "edit", "write"] as const;
|
|
26
|
+
|
|
27
|
+
type LegacyCodingToolName = (typeof LEGACY_CODING_TOOL_NAMES)[number];
|
|
28
|
+
type LegacyBuiltinToolDefinition = ToolDefinition & { [LEGACY_BUILTIN_TOOL_MARKER]: true };
|
|
29
|
+
|
|
30
|
+
function markToolDefinition<TParams extends TSchema, TDetails>(
|
|
31
|
+
tool: ToolDefinition<TParams, TDetails>,
|
|
32
|
+
): ToolDefinition<TParams, TDetails> {
|
|
33
|
+
Object.defineProperty(tool, TOOL_DEFINITION_MARKER, {
|
|
34
|
+
value: true,
|
|
35
|
+
enumerable: false,
|
|
36
|
+
writable: false,
|
|
37
|
+
configurable: true,
|
|
38
|
+
});
|
|
39
|
+
return tool;
|
|
40
|
+
}
|
|
41
|
+
function legacyToolSession(cwd: string): ToolSession {
|
|
42
|
+
return {
|
|
43
|
+
cwd,
|
|
44
|
+
hasUI: false,
|
|
45
|
+
getSessionFile: () => null,
|
|
46
|
+
getSessionSpawns: () => null,
|
|
47
|
+
settings: Settings.isolated(),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function createBuiltinTool(cwd: string, name: LegacyCodingToolName): Tool {
|
|
52
|
+
const tool = BUILTIN_TOOLS[name](legacyToolSession(cwd));
|
|
53
|
+
if (tool instanceof Promise) {
|
|
54
|
+
throw new Error(`Built-in ${name} tool factory unexpectedly returned a promise.`);
|
|
55
|
+
}
|
|
56
|
+
if (!tool) {
|
|
57
|
+
throw new Error(`Built-in ${name} tool is unavailable.`);
|
|
58
|
+
}
|
|
59
|
+
return tool;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function executeBuiltinTool(
|
|
63
|
+
cwd: string,
|
|
64
|
+
name: LegacyCodingToolName,
|
|
65
|
+
toolCallId: string,
|
|
66
|
+
params: unknown,
|
|
67
|
+
signal: AbortSignal | undefined,
|
|
68
|
+
onUpdate: AgentToolUpdateCallback | undefined,
|
|
69
|
+
) {
|
|
70
|
+
const tool = createBuiltinTool(cwd, name);
|
|
71
|
+
return tool.execute(toolCallId, params, signal, onUpdate);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function legacyBuiltinTool(cwd: string, name: LegacyCodingToolName): ToolDefinition {
|
|
75
|
+
const tool = createBuiltinTool(cwd, name);
|
|
76
|
+
const definition: LegacyBuiltinToolDefinition = {
|
|
77
|
+
name: tool.name,
|
|
78
|
+
label: tool.label,
|
|
79
|
+
description: tool.description,
|
|
80
|
+
parameters: tool.parameters,
|
|
81
|
+
hidden: tool.hidden,
|
|
82
|
+
deferrable: tool.deferrable,
|
|
83
|
+
approval: tool.approval,
|
|
84
|
+
execute: (toolCallId, params, signal, onUpdate) =>
|
|
85
|
+
executeBuiltinTool(cwd, name, toolCallId, params, signal, onUpdate),
|
|
86
|
+
[LEGACY_BUILTIN_TOOL_MARKER]: true,
|
|
87
|
+
};
|
|
88
|
+
return markToolDefinition(definition);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface ParsedFrontmatter<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
92
|
+
frontmatter: T;
|
|
93
|
+
body: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function parseFrontmatter<T extends Record<string, unknown> = Record<string, unknown>>(
|
|
97
|
+
content: string,
|
|
98
|
+
): ParsedFrontmatter<T> {
|
|
99
|
+
const { frontmatter, body } = parseOmpFrontmatter(content, { level: "fatal" });
|
|
100
|
+
return { frontmatter: frontmatter as T, body };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function stripFrontmatter(content: string): string {
|
|
104
|
+
return parseFrontmatter(content).body;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function defineTool<TParams extends TSchema = TSchema, TDetails = unknown>(
|
|
108
|
+
tool: ToolDefinition<TParams, TDetails>,
|
|
109
|
+
): ToolDefinition<TParams, TDetails> {
|
|
110
|
+
return markToolDefinition(tool);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function createCodingTools(cwd: string): ToolDefinition[] {
|
|
114
|
+
return LEGACY_CODING_TOOL_NAMES.map(name => legacyBuiltinTool(cwd, name));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const SettingsManager = {
|
|
118
|
+
create(cwd: string, agentDir?: string): Promise<Settings> {
|
|
119
|
+
return Settings.init({ cwd, agentDir });
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
inMemory(): Settings {
|
|
123
|
+
return Settings.isolated();
|
|
124
|
+
},
|
|
125
|
+
} as const;
|
|
126
|
+
|
|
15
127
|
export * from "../index";
|
|
128
|
+
export { Type };
|
|
@@ -64,14 +64,14 @@ const packageRootCache = new Map<string, string | null>();
|
|
|
64
64
|
const packageImportsCache = new Map<string, Record<string, unknown> | null>();
|
|
65
65
|
const PACKAGE_IMPORT_EXCLUDED = Symbol("packageImportExcluded");
|
|
66
66
|
|
|
67
|
-
// Extensions that imported
|
|
68
|
-
//
|
|
69
|
-
// shim under `extensibility/typebox.ts`; plugins still importing
|
|
70
|
-
// are redirected to that shim so existing extensions keep
|
|
71
|
-
// changes. Submodules like `@sinclair/typebox/compiler`
|
|
72
|
-
// remapped — those expose TypeBox-only APIs the shim does
|
|
73
|
-
// relying on them must vendor
|
|
74
|
-
const TYPEBOX_SPECIFIER_FILTER =
|
|
67
|
+
// Extensions that imported TypeBox directly used to resolve against a real
|
|
68
|
+
// `@sinclair/typebox` or `typebox` install. The runtime dep was replaced with
|
|
69
|
+
// the Zod-backed shim under `extensibility/typebox.ts`; plugins still importing
|
|
70
|
+
// either public name are redirected to that shim so existing extensions keep
|
|
71
|
+
// working without code changes. Submodules like `@sinclair/typebox/compiler`
|
|
72
|
+
// are intentionally not remapped — those expose TypeBox-only APIs the shim does
|
|
73
|
+
// not provide and plugins relying on them must vendor TypeBox directly.
|
|
74
|
+
const TYPEBOX_SPECIFIER_FILTER = /^(?:@sinclair\/typebox|typebox)$/;
|
|
75
75
|
|
|
76
76
|
// Compat shim and bundled-package paths used in compiled-binary mode. The shim
|
|
77
77
|
// paths must point at files that ship inside the bunfs root; in dev /
|
|
@@ -295,14 +295,14 @@ function rewriteLegacyPiImports(source: string): string {
|
|
|
295
295
|
);
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
// Match the bare
|
|
299
|
-
//
|
|
300
|
-
//
|
|
301
|
-
const TYPEBOX_IMPORT_SPECIFIER_REGEX = /((?:from\s+|import\s+|import\s*\(\s*)["'])(@sinclair\/typebox)(["'])/g;
|
|
298
|
+
// Match the bare TypeBox import specifiers (static + dynamic). Subpath imports
|
|
299
|
+
// like `@sinclair/typebox/compiler` are intentionally excluded — they expose
|
|
300
|
+
// TypeBox-only APIs the Zod-backed shim does not provide.
|
|
301
|
+
const TYPEBOX_IMPORT_SPECIFIER_REGEX = /((?:from\s+|import\s+|import\s*\(\s*)["'])(@sinclair\/typebox|typebox)(["'])/g;
|
|
302
302
|
|
|
303
303
|
/**
|
|
304
304
|
* Rewrite the extension-owned specifiers OMP must host-resolve — legacy
|
|
305
|
-
* `@(scope)/pi-*`, bare
|
|
305
|
+
* `@(scope)/pi-*`, bare TypeBox packages, and package `imports` aliases like
|
|
306
306
|
* `#src/*` — to absolute `file://` URLs. Every other specifier (relative
|
|
307
307
|
* siblings and third-party dependencies) is left untouched so Bun resolves it
|
|
308
308
|
* natively from the extension's real on-disk location.
|
|
@@ -14,7 +14,10 @@ export function applyToolProxy<TTool extends object>(tool: TTool, wrapper: objec
|
|
|
14
14
|
Object.defineProperty(wrapper, key, {
|
|
15
15
|
get() {
|
|
16
16
|
const value = (tool as Record<PropertyKey, unknown>)[key];
|
|
17
|
-
|
|
17
|
+
// Bind real methods so `this` is preserved through the wrapper, but leave
|
|
18
|
+
// callable values that aren't plain functions untouched — notably an ArkType
|
|
19
|
+
// `Type` (the `parameters` schema) is callable yet lacks `Function.prototype.bind`.
|
|
20
|
+
return typeof value === "function" && typeof value.bind === "function" ? value.bind(tool) : value;
|
|
18
21
|
},
|
|
19
22
|
enumerable: true,
|
|
20
23
|
configurable: true,
|