@oh-my-pi/pi-coding-agent 15.10.1 → 15.10.3
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 +113 -1
- package/dist/types/cli/gallery-fixtures/types.d.ts +7 -1
- package/dist/types/cli/startup-cwd.d.ts +2 -0
- package/dist/types/commands/launch.d.ts +3 -0
- package/dist/types/config/keybindings.d.ts +2 -2
- package/dist/types/config/model-provider-priority.d.ts +1 -0
- package/dist/types/config/model-resolver.d.ts +4 -1
- package/dist/types/config/settings.d.ts +7 -2
- package/dist/types/debug/report-bundle.d.ts +3 -0
- package/dist/types/edit/file-snapshot-store.d.ts +18 -10
- package/dist/types/edit/index.d.ts +0 -1
- package/dist/types/eval/py/__tests__/prelude.test.d.ts +1 -0
- package/dist/types/extensibility/extensions/types.d.ts +4 -1
- package/dist/types/lsp/client.d.ts +10 -0
- package/dist/types/lsp/index.d.ts +0 -5
- package/dist/types/main.d.ts +14 -9
- package/dist/types/mcp/tool-bridge.d.ts +2 -0
- package/dist/types/modes/components/assistant-message.d.ts +0 -9
- package/dist/types/modes/components/custom-editor.d.ts +1 -1
- package/dist/types/modes/components/late-diagnostics-message.d.ts +20 -0
- package/dist/types/modes/components/read-tool-group.d.ts +6 -0
- package/dist/types/modes/components/session-selector.d.ts +16 -7
- package/dist/types/modes/components/status-line.d.ts +2 -0
- package/dist/types/modes/components/tool-execution.d.ts +0 -18
- package/dist/types/modes/controllers/event-controller.d.ts +17 -0
- package/dist/types/modes/interactive-mode.d.ts +1 -0
- package/dist/types/modes/magic-keywords.d.ts +1 -1
- package/dist/types/modes/markdown-prose.d.ts +1 -1
- package/dist/types/modes/types.d.ts +7 -0
- package/dist/types/modes/workflow.d.ts +3 -3
- package/dist/types/session/auth-storage.d.ts +1 -1
- package/dist/types/session/messages.d.ts +11 -8
- package/dist/types/session/session-manager.d.ts +5 -2
- package/dist/types/session/yield-queue.d.ts +10 -1
- package/dist/types/task/executor.d.ts +10 -0
- package/dist/types/tools/eval-render.d.ts +0 -1
- package/dist/types/tools/eval.d.ts +8 -0
- package/dist/types/tools/gh-cache-invalidation.d.ts +6 -0
- package/dist/types/tools/github-cache.d.ts +12 -0
- package/dist/types/tools/index.d.ts +31 -0
- package/dist/types/tools/path-utils.d.ts +13 -1
- package/dist/types/tools/read.d.ts +2 -1
- package/dist/types/tools/render-utils.d.ts +3 -1
- package/dist/types/tools/renderers.d.ts +0 -15
- package/dist/types/tools/search.d.ts +2 -2
- package/dist/types/tools/write.d.ts +0 -2
- package/dist/types/tools/yield.d.ts +8 -0
- package/dist/types/tui/code-cell.d.ts +0 -2
- package/dist/types/tui/hyperlink.d.ts +5 -7
- package/dist/types/tui/output-block.d.ts +0 -18
- package/package.json +9 -9
- package/src/cli/args.ts +3 -1
- package/src/cli/dry-balance-cli.ts +2 -4
- package/src/cli/gallery-cli.ts +4 -0
- package/src/cli/gallery-fixtures/codeintel.ts +0 -1
- package/src/cli/gallery-fixtures/fs.ts +68 -1
- package/src/cli/gallery-fixtures/types.ts +8 -1
- package/src/cli/startup-cwd.ts +68 -0
- package/src/commands/launch.ts +3 -0
- package/src/commit/agentic/agent.ts +1 -0
- package/src/commit/model-selection.ts +3 -2
- package/src/config/model-provider-priority.ts +55 -0
- package/src/config/model-registry.ts +4 -22
- package/src/config/model-resolver.ts +39 -7
- package/src/config/settings.ts +86 -41
- package/src/debug/index.ts +8 -0
- package/src/debug/raw-sse-buffer.ts +7 -4
- package/src/debug/report-bundle.ts +9 -0
- package/src/edit/file-snapshot-store.ts +33 -1
- package/src/edit/hashline/diff.ts +86 -0
- package/src/edit/hashline/execute.ts +14 -1
- package/src/edit/hashline/filesystem.ts +2 -1
- package/src/edit/index.ts +31 -17
- package/src/edit/renderer.ts +116 -31
- package/src/eval/__tests__/llm-bridge.test.ts +20 -0
- package/src/eval/js/context-manager.ts +32 -15
- package/src/eval/js/shared/prelude.txt +26 -10
- package/src/eval/llm-bridge.ts +14 -3
- package/src/eval/py/__tests__/prelude.test.ts +19 -0
- package/src/eval/py/executor.ts +23 -11
- package/src/eval/py/prelude.py +1 -1
- package/src/extensibility/extensions/types.ts +10 -1
- package/src/internal-urls/docs-index.generated.ts +7 -7
- package/src/lsp/client.ts +23 -11
- package/src/lsp/config.ts +11 -1
- package/src/lsp/index.ts +189 -61
- package/src/main.ts +144 -78
- package/src/mcp/tool-bridge.ts +2 -0
- package/src/memories/index.ts +2 -2
- package/src/modes/components/assistant-message.ts +3 -15
- package/src/modes/components/custom-editor.ts +143 -111
- package/src/modes/components/late-diagnostics-message.ts +60 -0
- package/src/modes/components/model-selector.ts +59 -13
- package/src/modes/components/oauth-selector.ts +33 -7
- package/src/modes/components/plan-review-overlay.ts +26 -5
- package/src/modes/components/read-tool-group.ts +415 -35
- package/src/modes/components/session-selector.ts +89 -35
- package/src/modes/components/status-line.ts +19 -4
- package/src/modes/components/tips.txt +1 -1
- package/src/modes/components/tool-execution.ts +7 -49
- package/src/modes/components/transcript-container.ts +108 -32
- package/src/modes/components/user-message.ts +1 -1
- package/src/modes/controllers/event-controller.ts +32 -1
- package/src/modes/controllers/input-controller.ts +56 -9
- package/src/modes/interactive-mode.ts +107 -20
- package/src/modes/magic-keywords.ts +1 -1
- package/src/modes/markdown-prose.ts +1 -1
- package/src/modes/theme/shimmer.ts +20 -9
- package/src/modes/types.ts +7 -0
- package/src/modes/utils/ui-helpers.ts +26 -5
- package/src/modes/workflow.ts +10 -10
- package/src/prompts/system/manual-continue.md +7 -0
- package/src/prompts/system/plan-mode-active.md +56 -72
- package/src/prompts/system/workflow-notice.md +1 -1
- package/src/prompts/tools/bash.md +9 -0
- package/src/prompts/tools/browser.md +1 -1
- package/src/prompts/tools/eval.md +5 -2
- package/src/prompts/tools/lsp-late-diagnostic.md +8 -0
- package/src/prompts/tools/read.md +2 -2
- package/src/sdk.ts +85 -10
- package/src/session/agent-session.ts +42 -15
- package/src/session/auth-storage.ts +2 -0
- package/src/session/messages.ts +21 -14
- package/src/session/session-manager.ts +98 -25
- package/src/session/yield-queue.ts +20 -2
- package/src/task/executor.ts +72 -36
- package/src/task/render.ts +3 -4
- package/src/tiny/title-client.ts +6 -1
- package/src/tools/bash.ts +7 -7
- package/src/tools/browser/tab-supervisor.ts +13 -1
- package/src/tools/browser/tab-worker.ts +33 -4
- package/src/tools/eval-render.ts +4 -23
- package/src/tools/eval.ts +13 -2
- package/src/tools/find.ts +148 -99
- package/src/tools/gh-cache-invalidation.ts +200 -0
- package/src/tools/github-cache.ts +25 -0
- package/src/tools/index.ts +32 -0
- package/src/tools/inspect-image.ts +2 -2
- package/src/tools/path-utils.ts +47 -24
- package/src/tools/plan-mode-guard.ts +52 -7
- package/src/tools/read.ts +41 -20
- package/src/tools/render-utils.ts +3 -1
- package/src/tools/renderers.ts +0 -15
- package/src/tools/search.ts +38 -3
- package/src/tools/ssh.ts +0 -1
- package/src/tools/todo.ts +1 -0
- package/src/tools/write.ts +5 -14
- package/src/tools/yield.ts +10 -1
- package/src/tui/code-cell.ts +1 -6
- package/src/tui/hyperlink.ts +13 -23
- package/src/tui/output-block.ts +2 -97
- package/src/utils/commit-message-generator.ts +2 -2
- package/src/utils/enhanced-paste.ts +30 -2
- package/src/web/search/providers/codex.ts +37 -8
|
@@ -52,8 +52,14 @@ interface JsSession {
|
|
|
52
52
|
|
|
53
53
|
const sessions = new Map<string, JsSession>();
|
|
54
54
|
const startingSessions = new Map<string, Promise<JsSession>>();
|
|
55
|
-
const resettingSessions = new
|
|
56
|
-
|
|
55
|
+
const resettingSessions = new Map<string, Promise<void>>();
|
|
56
|
+
// Worker startup (module-graph import + WorkerCore construction) is infrastructure
|
|
57
|
+
// cost, not user compute. Floor it independently of Bun's 5s default per-test timeout
|
|
58
|
+
// so a slow cold-start under load isn't aborted mid-init — terminating a still-
|
|
59
|
+
// initializing Bun worker triggers the same kind of terminate-race that motivates
|
|
60
|
+
// avoiding `vm.runInContext` (see shared/indirect-eval.ts), here surfacing as a
|
|
61
|
+
// SIGILL/SIGSEGV. Callers that pass a larger per-cell budget still dominate.
|
|
62
|
+
const WORKER_INIT_TIMEOUT_MS = 15_000;
|
|
57
63
|
|
|
58
64
|
export async function executeInVmContext(options: {
|
|
59
65
|
sessionKey: string;
|
|
@@ -67,17 +73,28 @@ export async function executeInVmContext(options: {
|
|
|
67
73
|
runState: VmRunState;
|
|
68
74
|
}): Promise<{ value: unknown }> {
|
|
69
75
|
if (options.reset) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
resettingSessions.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
resettingSessions.
|
|
76
|
+
// Coalesce concurrent resets: an existing in-flight reset already
|
|
77
|
+
// produces a fresh context, so a follow-up `reset: true` cell should
|
|
78
|
+
// just wait for it rather than failing the user-visible call.
|
|
79
|
+
const inFlight = resettingSessions.get(options.sessionKey);
|
|
80
|
+
if (inFlight) await inFlight.catch(() => undefined);
|
|
81
|
+
else {
|
|
82
|
+
const resetPromise = resetVmContext(options.sessionKey);
|
|
83
|
+
resettingSessions.set(
|
|
84
|
+
options.sessionKey,
|
|
85
|
+
resetPromise.then(() => undefined),
|
|
86
|
+
);
|
|
87
|
+
try {
|
|
88
|
+
await resetPromise;
|
|
89
|
+
} finally {
|
|
90
|
+
resettingSessions.delete(options.sessionKey);
|
|
91
|
+
}
|
|
78
92
|
}
|
|
79
|
-
} else
|
|
80
|
-
|
|
93
|
+
} else {
|
|
94
|
+
// Internal coordination: wait for any in-flight reset to settle and
|
|
95
|
+
// then run on the freshly-rebuilt context.
|
|
96
|
+
const inFlight = resettingSessions.get(options.sessionKey);
|
|
97
|
+
if (inFlight) await inFlight.catch(() => undefined);
|
|
81
98
|
}
|
|
82
99
|
const session = await acquireSession(
|
|
83
100
|
options.sessionKey,
|
|
@@ -191,9 +208,9 @@ async function acquireSession(sessionKey: string, snapshot: SessionSnapshot, tim
|
|
|
191
208
|
handleSessionMessage(session, msg);
|
|
192
209
|
});
|
|
193
210
|
try {
|
|
194
|
-
//
|
|
195
|
-
// users can grant more
|
|
196
|
-
const readyTimeoutMs = Math.max(
|
|
211
|
+
// Init headroom is the fixed infrastructure floor; the caller's per-cell timeout
|
|
212
|
+
// dominates when larger so users can grant more by raising `timeout` on a cell.
|
|
213
|
+
const readyTimeoutMs = Math.max(WORKER_INIT_TIMEOUT_MS, timeoutMs ?? 0);
|
|
197
214
|
await raceWithTimeout(readyPromise, readyTimeoutMs, "Timed out initializing JS eval worker");
|
|
198
215
|
worker.send({ type: "init", snapshot });
|
|
199
216
|
sessions.set(sessionKey, session);
|
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
if (!globalThis.__omp_js_prelude_loaded__) {
|
|
2
2
|
globalThis.__omp_js_prelude_loaded__ = true;
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const isPlainObject = value => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5
|
+
const optionsArg = (name, value, rest, example) => {
|
|
6
|
+
if (rest.length > 0) {
|
|
7
|
+
throw new TypeError(
|
|
8
|
+
`${name}() takes options as a single trailing object literal, not positional arguments (got ${rest.length + 1} extra args). Pass them as ${name}(..., ${example}).`,
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
if (value === undefined || value === null) return {};
|
|
12
|
+
if (!isPlainObject(value)) {
|
|
13
|
+
const kind = Array.isArray(value) ? "an array" : typeof value;
|
|
14
|
+
throw new TypeError(
|
|
15
|
+
`${name}() options must be a trailing object literal like ${example}, not ${kind}. JS helpers never take positional options.`,
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
5
20
|
const callHelper = (name, ...args) => globalThis.__omp_helpers__[name](...args);
|
|
6
21
|
|
|
7
|
-
const read = (path, opts
|
|
22
|
+
const read = (path, opts, ...rest) => callHelper("read", path, optionsArg("read", opts, rest, "{ offset, limit }"));
|
|
8
23
|
const write = async (path, data) => callHelper("writeFile", path, data);
|
|
9
24
|
const append = (path, content) => callHelper("append", path, content);
|
|
10
|
-
const sort = (text, opts
|
|
11
|
-
const uniq = (text, opts
|
|
12
|
-
const counter = (items, opts
|
|
25
|
+
const sort = (text, opts, ...rest) => callHelper("sortText", text, optionsArg("sort", opts, rest, "{ reverse, unique }"));
|
|
26
|
+
const uniq = (text, opts, ...rest) => callHelper("uniqText", text, optionsArg("uniq", opts, rest, "{ count }"));
|
|
27
|
+
const counter = (items, opts, ...rest) =>
|
|
28
|
+
callHelper("counter", items, optionsArg("counter", opts, rest, "{ limit, reverse }"));
|
|
13
29
|
const diff = (a, b) => callHelper("diff", a, b);
|
|
14
|
-
const tree = (path = ".", opts
|
|
30
|
+
const tree = (path = ".", opts, ...rest) => callHelper("tree", path, optionsArg("tree", opts, rest, "{ maxDepth, showHidden }"));
|
|
15
31
|
const env = (key, value) => callHelper("env", key, value);
|
|
16
32
|
|
|
17
33
|
const tool = new Proxy(
|
|
@@ -41,15 +57,15 @@ if (!globalThis.__omp_js_prelude_loaded__) {
|
|
|
41
57
|
|
|
42
58
|
const hasOwn = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
|
|
43
59
|
|
|
44
|
-
const llm = async (prompt, opts
|
|
45
|
-
const o =
|
|
60
|
+
const llm = async (prompt, opts, ...rest) => {
|
|
61
|
+
const o = optionsArg("llm", opts, rest, "{ model, system, schema }");
|
|
46
62
|
const res = await globalThis.__omp_call_tool__("__llm__", { prompt, ...o });
|
|
47
63
|
const text = res && typeof res === "object" ? res.text : res;
|
|
48
64
|
return hasOwn(o, "schema") ? JSON.parse(text) : text;
|
|
49
65
|
};
|
|
50
66
|
|
|
51
|
-
const agent = async (prompt, opts
|
|
52
|
-
const o =
|
|
67
|
+
const agent = async (prompt, opts, ...rest) => {
|
|
68
|
+
const o = optionsArg("agent", opts, rest, "{ agentType, model, context, label, schema }");
|
|
53
69
|
const res = await globalThis.__omp_call_tool__("__agent__", { prompt, ...o });
|
|
54
70
|
const text = res && typeof res === "object" ? res.text : res;
|
|
55
71
|
return hasOwn(o, "schema") ? JSON.parse(text) : text;
|
package/src/eval/llm-bridge.ts
CHANGED
|
@@ -16,7 +16,12 @@ import { type Api, Effort, getSupportedEfforts, type Model, type Tool } from "@o
|
|
|
16
16
|
import * as z from "zod/v4";
|
|
17
17
|
import { extractTextContent, extractToolCall, parseJsonPayload } from "../commit/utils";
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
expandRoleAlias,
|
|
21
|
+
formatModelString,
|
|
22
|
+
getModelMatchPreferences,
|
|
23
|
+
resolveModelFromString,
|
|
24
|
+
} from "../config/model-resolver";
|
|
20
25
|
import type { ToolSession } from "../tools";
|
|
21
26
|
import { ToolError } from "../tools/tool-errors";
|
|
22
27
|
import { withBridgeTimeoutPause } from "./bridge-timeout";
|
|
@@ -65,7 +70,7 @@ function resolveTierModel(tier: LlmTier, session: ToolSession): Model<Api> | und
|
|
|
65
70
|
const available = modelRegistry.getAvailable();
|
|
66
71
|
if (available.length === 0) return undefined;
|
|
67
72
|
|
|
68
|
-
const matchPreferences =
|
|
73
|
+
const matchPreferences = getModelMatchPreferences(session.settings);
|
|
69
74
|
const resolve = (pattern: string | undefined): Model<Api> | undefined => {
|
|
70
75
|
if (!pattern) return undefined;
|
|
71
76
|
const expanded = expandRoleAlias(pattern, session.settings);
|
|
@@ -134,13 +139,19 @@ export async function runEvalLlm(args: unknown, options: EvalLlmBridgeOptions):
|
|
|
134
139
|
|
|
135
140
|
const telemetry = resolveTelemetry(options.session.getTelemetry?.(), options.session.getSessionId?.() ?? undefined);
|
|
136
141
|
|
|
142
|
+
// Some providers (notably openai-codex) require a non-empty `instructions`
|
|
143
|
+
// field on every Responses request and 400 with "Instructions are required"
|
|
144
|
+
// when it is missing. Fall back to a minimal default so `llm(prompt)` works
|
|
145
|
+
// without forcing every caller to pass a `system` prompt.
|
|
146
|
+
const systemPrompt = system ? [system] : ["You are a helpful assistant."];
|
|
147
|
+
|
|
137
148
|
// Suspend eval timeout accounting while the model request owns control. The
|
|
138
149
|
// timeout clock restarts once the bridge returns to the cell runtime.
|
|
139
150
|
const response = await withBridgeTimeoutPause(options.emitStatus, () =>
|
|
140
151
|
instrumentedCompleteSimple(
|
|
141
152
|
model,
|
|
142
153
|
{
|
|
143
|
-
systemPrompt
|
|
154
|
+
systemPrompt,
|
|
144
155
|
messages: [{ role: "user", content: [{ type: "text", text: prompt }], timestamp: Date.now() }],
|
|
145
156
|
tools,
|
|
146
157
|
},
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import { PYTHON_PRELUDE } from "../prelude";
|
|
3
|
+
|
|
4
|
+
describe("python prelude", () => {
|
|
5
|
+
it("exposes read(path, offset?, limit?) with positional optional args", () => {
|
|
6
|
+
// The eval docs advertise `read(path, offset?=1, limit?=None)`. A
|
|
7
|
+
// keyword-only signature (`def read(path, *, offset=1, limit=None)`)
|
|
8
|
+
// makes `read("file", 10)` raise `TypeError: read() takes 1 positional
|
|
9
|
+
// argument but 2 were given`, which agents in the wild repeatedly hit.
|
|
10
|
+
// Lock the contract so the helper accepts both positional and keyword
|
|
11
|
+
// forms.
|
|
12
|
+
const match = PYTHON_PRELUDE.match(/def\s+read\(([^)]+)\)/);
|
|
13
|
+
expect(match).not.toBeNull();
|
|
14
|
+
const signature = match?.[1] ?? "";
|
|
15
|
+
expect(signature).not.toContain("*,");
|
|
16
|
+
expect(signature).toContain("offset");
|
|
17
|
+
expect(signature).toContain("limit");
|
|
18
|
+
});
|
|
19
|
+
});
|
package/src/eval/py/executor.ts
CHANGED
|
@@ -126,7 +126,7 @@ interface PythonSession {
|
|
|
126
126
|
|
|
127
127
|
const sessions = new Map<string, PythonSession>();
|
|
128
128
|
const startingSessions = new Map<string, Promise<PythonSession>>();
|
|
129
|
-
const resettingSessions = new
|
|
129
|
+
const resettingSessions = new Map<string, Promise<void>>();
|
|
130
130
|
|
|
131
131
|
function normalizeSessionCwd(cwd: string): string {
|
|
132
132
|
return path.resolve(cwd);
|
|
@@ -611,17 +611,29 @@ async function executeOnSession(code: string, cwd: string, options: PythonExecut
|
|
|
611
611
|
options.bridgeSessionId = sessionId;
|
|
612
612
|
}
|
|
613
613
|
if (options.reset) {
|
|
614
|
-
if
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
resettingSessions.
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
resettingSessions.
|
|
614
|
+
// Coalesce concurrent resets: if another reset is in flight for this
|
|
615
|
+
// session, await it instead of throwing — the caller's intent ("start
|
|
616
|
+
// from a clean kernel") is satisfied once that reset settles.
|
|
617
|
+
const inFlight = resettingSessions.get(sessionKey);
|
|
618
|
+
if (inFlight) await inFlight.catch(() => undefined);
|
|
619
|
+
else {
|
|
620
|
+
const resetPromise = resetSession(sessionKey);
|
|
621
|
+
resettingSessions.set(
|
|
622
|
+
sessionKey,
|
|
623
|
+
resetPromise.then(() => undefined),
|
|
624
|
+
);
|
|
625
|
+
try {
|
|
626
|
+
await resetPromise;
|
|
627
|
+
} finally {
|
|
628
|
+
resettingSessions.delete(sessionKey);
|
|
629
|
+
}
|
|
622
630
|
}
|
|
623
|
-
} else
|
|
624
|
-
|
|
631
|
+
} else {
|
|
632
|
+
// A reset already in progress is an internal coordination state, not a
|
|
633
|
+
// user-visible failure. Wait for it to clear, then proceed with the
|
|
634
|
+
// requested execution on the freshly-restarted kernel.
|
|
635
|
+
const inFlight = resettingSessions.get(sessionKey);
|
|
636
|
+
if (inFlight) await inFlight.catch(() => undefined);
|
|
625
637
|
}
|
|
626
638
|
const session = await acquireSession(sessionKey, sessionId, cwd, options);
|
|
627
639
|
if (options.signal?.aborted) {
|
package/src/eval/py/prelude.py
CHANGED
|
@@ -53,7 +53,7 @@ if "__omp_prelude_loaded__" not in globals():
|
|
|
53
53
|
_emit_status("env", key=key, value=val, action="get")
|
|
54
54
|
return val
|
|
55
55
|
|
|
56
|
-
def read(path: str | Path,
|
|
56
|
+
def read(path: str | Path, offset: int = 1, limit: int | None = None) -> str:
|
|
57
57
|
"""Read file contents. offset/limit are 1-indexed line numbers."""
|
|
58
58
|
p = Path(path)
|
|
59
59
|
data = p.read_text(encoding="utf-8")
|
|
@@ -7,7 +7,13 @@
|
|
|
7
7
|
* - Register commands, keyboard shortcuts, and CLI flags
|
|
8
8
|
* - Interact with the user via UI primitives
|
|
9
9
|
*/
|
|
10
|
-
import type {
|
|
10
|
+
import type {
|
|
11
|
+
AgentMessage,
|
|
12
|
+
AgentToolResult,
|
|
13
|
+
AgentToolUpdateCallback,
|
|
14
|
+
ThinkingLevel,
|
|
15
|
+
ToolApproval,
|
|
16
|
+
} from "@oh-my-pi/pi-agent-core";
|
|
11
17
|
import type { CompactionResult } from "@oh-my-pi/pi-agent-core/compaction";
|
|
12
18
|
import type {
|
|
13
19
|
Api,
|
|
@@ -392,6 +398,9 @@ export interface ToolDefinition<TParams extends TSchema = TSchema, TDetails = un
|
|
|
392
398
|
defaultInactive?: boolean;
|
|
393
399
|
/** If true, tool may stage deferred changes that require explicit resolve/discard. */
|
|
394
400
|
deferrable?: boolean;
|
|
401
|
+
/** Tool approval tier. Defaults to `"exec"` when omitted.
|
|
402
|
+
* `"read"`: read-only operations. `"write"`: mutations. `"exec"`: code execution. */
|
|
403
|
+
approval?: ToolApproval;
|
|
395
404
|
/** MCP server name for discovery/search metadata when this tool fronts an MCP server. */
|
|
396
405
|
mcpServerName?: string;
|
|
397
406
|
/** Original MCP tool name for discovery/search metadata. */
|