pi-dent-agent 0.2.4 → 0.2.5
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/lib/engine.ts +2 -0
- package/lib/script-runner.ts +13 -1
- package/lib/script-tool-types.ts +5 -5
- package/lib/script-worker.ts +1 -1
- package/package.json +1 -1
package/lib/engine.ts
CHANGED
|
@@ -82,6 +82,7 @@ import {
|
|
|
82
82
|
CohortTracker,
|
|
83
83
|
} from "./tools.ts";
|
|
84
84
|
import { makeScriptTool } from "./script-tool.ts";
|
|
85
|
+
import { DEFAULT_TOOLS_ALLOW } from "./script-tool-types.ts";
|
|
85
86
|
import { registerReadErrorHint } from "./output-file.ts";
|
|
86
87
|
import { makeBashTool, type BashSettings } from "./bash-tool.ts";
|
|
87
88
|
import { makeSearchTool, searchRuntime } from "./search-tool.ts";
|
|
@@ -2224,6 +2225,7 @@ export class DispatchEngine {
|
|
|
2224
2225
|
cohortFor: (toolCallId) => childCohorts.cohortFor(toolCallId),
|
|
2225
2226
|
agentDir: () => childDir,
|
|
2226
2227
|
extraEnv: () => ({ PI_DENT_SESSION_DIR: childDir }),
|
|
2228
|
+
toolsAllow: () => parseScript(this.boot.config).toolsAllow ?? DEFAULT_TOOLS_ALLOW,
|
|
2227
2229
|
}),
|
|
2228
2230
|
// A child session binds `Search` when the tool cap includes it
|
|
2229
2231
|
// (agent-tool.md Section 3.1); its own session file is the invoking one.
|
package/lib/script-runner.ts
CHANGED
|
@@ -382,7 +382,19 @@ export function runScript(req: ScriptRunRequest): ScriptRunHandle {
|
|
|
382
382
|
.then((reply) => {
|
|
383
383
|
nestedCalls.delete(controller);
|
|
384
384
|
if (settled) return;
|
|
385
|
-
|
|
385
|
+
try {
|
|
386
|
+
worker?.postMessage({ type: "tool-result", id, reply });
|
|
387
|
+
} catch (error) {
|
|
388
|
+
try {
|
|
389
|
+
worker?.postMessage({
|
|
390
|
+
type: "tool-result",
|
|
391
|
+
id,
|
|
392
|
+
reply: { ok: false, error: { name: "Error", message: errorMessage(error) } },
|
|
393
|
+
});
|
|
394
|
+
} catch {
|
|
395
|
+
// Port closed.
|
|
396
|
+
}
|
|
397
|
+
}
|
|
386
398
|
});
|
|
387
399
|
}
|
|
388
400
|
|
package/lib/script-tool-types.ts
CHANGED
|
@@ -106,7 +106,7 @@ function union(members: readonly Typed[]): Typed {
|
|
|
106
106
|
function unsupportedSuffix(schema: Record<string, unknown>): string {
|
|
107
107
|
const found = UNSUPPORTED_KEYWORDS.filter((key) => Object.hasOwn(schema, key));
|
|
108
108
|
if (
|
|
109
|
-
|
|
109
|
+
isObject(schema.properties) &&
|
|
110
110
|
Object.hasOwn(schema, "additionalProperties") &&
|
|
111
111
|
schema.additionalProperties !== false
|
|
112
112
|
) {
|
|
@@ -161,11 +161,11 @@ function baseType(schema: Record<string, unknown>, ctx: TypingContext): Typed {
|
|
|
161
161
|
}
|
|
162
162
|
if (Object.hasOwn(schema, "allOf")) {
|
|
163
163
|
const members = (arrayOf(schema, "allOf") ?? []).map((member) => typeOf(member, ctx));
|
|
164
|
-
|
|
164
|
+
const [only] = members;
|
|
165
|
+
if (only === undefined) return atom("Json");
|
|
166
|
+
if (members.length === 1) return only;
|
|
165
167
|
const texts = members.map((m) => (m.kind === "union" ? `(${m.text})` : m.text));
|
|
166
|
-
return texts.
|
|
167
|
-
? atom(texts.join(""))
|
|
168
|
-
: { text: texts.join(" & "), kind: "intersection" };
|
|
168
|
+
return { text: texts.join(" & "), kind: "intersection" };
|
|
169
169
|
}
|
|
170
170
|
const type = schema.type;
|
|
171
171
|
if (Array.isArray(type)) {
|
package/lib/script-worker.ts
CHANGED
|
@@ -196,13 +196,13 @@ const toolFunction =
|
|
|
196
196
|
}
|
|
197
197
|
return new Promise((resolveCall, rejectCall) => {
|
|
198
198
|
const id = nextCallId++;
|
|
199
|
+
port.postMessage({ type: "tool-call", id, name, args });
|
|
199
200
|
pendingCalls.set(id, { resolve: resolveCall, reject: rejectCall });
|
|
200
201
|
if (!listening) {
|
|
201
202
|
listening = true;
|
|
202
203
|
port.on("message", onToolResult);
|
|
203
204
|
}
|
|
204
205
|
port.ref();
|
|
205
|
-
port.postMessage({ type: "tool-call", id, name, args });
|
|
206
206
|
});
|
|
207
207
|
};
|
|
208
208
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dent-agent",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "A generic coding agent as a pi extension: Bash, Task, Agent, Fleet, Script, Search, Markdown and more tools, with billing and terms extensions bundled",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"coding-agent",
|