@qwen-code/qwen-harness 0.1.12 → 0.1.13
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/README.md +19 -7
- package/dist/entrypoint.js +1104 -699
- package/dist/entrypoint.js.map +4 -4
- package/package.json +1 -1
package/dist/entrypoint.js
CHANGED
|
@@ -4013,6 +4013,7 @@ var init_planning = __esm({
|
|
|
4013
4013
|
"session_notes",
|
|
4014
4014
|
"new_context",
|
|
4015
4015
|
"memory_lookup",
|
|
4016
|
+
"tool_search",
|
|
4016
4017
|
"submit_plan",
|
|
4017
4018
|
"run_code",
|
|
4018
4019
|
"exec",
|
|
@@ -4510,7 +4511,11 @@ function scalingSystemPrompt(config, cwd, interactive = false) {
|
|
|
4510
4511
|
}
|
|
4511
4512
|
function mechanismPrompt(config) {
|
|
4512
4513
|
const pieces = [];
|
|
4513
|
-
if (config.TC
|
|
4514
|
+
if (config.TC === "TC1")
|
|
4515
|
+
pieces.push(
|
|
4516
|
+
"Core tools are available directly. Use tool_search to find additional tools by capability or name. Search loads matching definitions for subsequent named calls. Read the returned schema before calling a discovered tool."
|
|
4517
|
+
);
|
|
4518
|
+
else
|
|
4514
4519
|
pieces.push(
|
|
4515
4520
|
`Use ${config.TC === "TC2" ? "run_code" : "exec"} for every tool operation through tools.<name>(args). Await each operation that matters; emit results with text() or image(). Tool results include content and isError. No Node, filesystem, or network APIs are exposed.`
|
|
4516
4521
|
);
|
|
@@ -4540,7 +4545,7 @@ function mechanismPrompt(config) {
|
|
|
4540
4545
|
);
|
|
4541
4546
|
if (config.W === "W3")
|
|
4542
4547
|
pieces.push(
|
|
4543
|
-
"You may delegate a task using subagent. Each child has an independent context initialized only with your task description, uses the same model and S/TS/TC/O/C, and cannot delegate again. Supply relevant facts and constraints. Children share the project directory; avoid conflicting changes. Integrate their results and finish the user task.
|
|
4548
|
+
"You may delegate a task using subagent, which starts a child and returns its agent_id. Use list_agents to inspect child status, wait_agents to wait for selected children and collect their results, and send_message to give an existing child additional facts or constraints. You may continue independent work while a child runs. At most one child may run at a time. A wait timeout does not cancel the child, and message submission does not mean the task is complete. Each child has an independent context initialized only with your task description, uses the same model and S/TS/TC/O/C, and cannot delegate again. Supply relevant facts and constraints. Children share the project directory; avoid conflicting changes. Integrate their results and finish the user task. All parent/child usage is recorded together."
|
|
4544
4549
|
);
|
|
4545
4550
|
return pieces.length ? rewriteToolReferences(["Task capabilities and runtime rules:", ...pieces].join("\n\n"), config.TS) : "";
|
|
4546
4551
|
}
|
|
@@ -4553,43 +4558,407 @@ var init_prompts = __esm({
|
|
|
4553
4558
|
}
|
|
4554
4559
|
});
|
|
4555
4560
|
|
|
4556
|
-
// src/
|
|
4561
|
+
// src/capabilities/tools/agents/subagent.ts
|
|
4557
4562
|
import { defineTool as defineTool30 } from "@earendil-works/pi-coding-agent";
|
|
4558
4563
|
import { Type as Type29 } from "typebox";
|
|
4559
|
-
function createSubagentTool(
|
|
4560
|
-
let active = false;
|
|
4564
|
+
function createSubagentTool(agents) {
|
|
4561
4565
|
return defineTool30({
|
|
4562
4566
|
name: "subagent",
|
|
4563
4567
|
label: "Subagent",
|
|
4564
4568
|
executionMode: "sequential",
|
|
4565
|
-
description: "
|
|
4569
|
+
description: "Start a child with the same model and S/TS/TC/O/C; return agent_id immediately. Supply relevant facts and user constraints in task. The child has an independent context, shares the workspace and cannot delegate. At most one child runs at once. Continue independent work, inspect list_agents, and collect results with wait_agents. All child and summary usage is included in shared accounting.",
|
|
4566
4570
|
parameters: Type29.Object({ task: Type29.String({ minLength: 1 }) }, { additionalProperties: false }),
|
|
4567
|
-
async execute(_id, args, signal, _update,
|
|
4568
|
-
signal
|
|
4569
|
-
if (active) throw new Error("Only one subagent may run at a time; await the current child");
|
|
4570
|
-
budget.delegate();
|
|
4571
|
-
active = true;
|
|
4572
|
-
const before = budget.snapshot();
|
|
4573
|
-
try {
|
|
4574
|
-
const result = await run(args.task, ctx, signal);
|
|
4575
|
-
const after = budget.snapshot();
|
|
4576
|
-
return { ...textResult({ text: result.text, sessionId: result.sessionId, modelCalls: after.modelCalls - before.modelCalls, toolCalls: after.toolCalls - before.toolCalls, totalTokens: after.totalTokens - before.totalTokens, cost: after.cost - before.cost }), usage: result.usage };
|
|
4577
|
-
} finally {
|
|
4578
|
-
active = false;
|
|
4579
|
-
}
|
|
4571
|
+
async execute(_id, args, signal, _update, context) {
|
|
4572
|
+
return jsonToolResult(await agents.start(args.task, context, signal));
|
|
4580
4573
|
}
|
|
4581
4574
|
});
|
|
4582
4575
|
}
|
|
4583
4576
|
var init_subagent = __esm({
|
|
4584
|
-
"src/
|
|
4577
|
+
"src/capabilities/tools/agents/subagent.ts"() {
|
|
4585
4578
|
"use strict";
|
|
4586
|
-
|
|
4579
|
+
init_workspace();
|
|
4587
4580
|
}
|
|
4588
4581
|
});
|
|
4589
4582
|
|
|
4590
|
-
// src/
|
|
4591
|
-
import {
|
|
4583
|
+
// src/capabilities/tools/agents/list_agents.ts
|
|
4584
|
+
import { defineTool as defineTool31 } from "@earendil-works/pi-coding-agent";
|
|
4585
|
+
import { Type as Type30 } from "typebox";
|
|
4586
|
+
function createListAgentsTool(agents) {
|
|
4587
|
+
return defineTool31({
|
|
4588
|
+
name: "list_agents",
|
|
4589
|
+
label: "List Agents",
|
|
4590
|
+
annotations: { readOnlyHint: true },
|
|
4591
|
+
description: "List this task's child agent ids, short task descriptions, session ids and running/completed/failed/cancelled status. Use wait_agents to collect terminal results.",
|
|
4592
|
+
parameters: Type30.Object({}, { additionalProperties: false }),
|
|
4593
|
+
async execute(_id, _args, signal) {
|
|
4594
|
+
signal?.throwIfAborted();
|
|
4595
|
+
return jsonToolResult({ agents: agents.list() });
|
|
4596
|
+
}
|
|
4597
|
+
});
|
|
4598
|
+
}
|
|
4599
|
+
var init_list_agents = __esm({
|
|
4600
|
+
"src/capabilities/tools/agents/list_agents.ts"() {
|
|
4601
|
+
"use strict";
|
|
4602
|
+
init_workspace();
|
|
4603
|
+
}
|
|
4604
|
+
});
|
|
4605
|
+
|
|
4606
|
+
// src/capabilities/tools/agents/wait_agents.ts
|
|
4607
|
+
import { defineTool as defineTool32 } from "@earendil-works/pi-coding-agent";
|
|
4608
|
+
import { Type as Type31 } from "typebox";
|
|
4609
|
+
function createWaitAgentsTool(agents) {
|
|
4610
|
+
return defineTool32({
|
|
4611
|
+
name: "wait_agents",
|
|
4612
|
+
label: "Wait Agents",
|
|
4613
|
+
annotations: { readOnlyHint: true },
|
|
4614
|
+
description: "Wait for selected child agent ids and collect completed results or errors. A timeout returns current status and does not cancel any child. Further waits can collect remaining results. Message submission alone does not mean a child finished.",
|
|
4615
|
+
parameters: Type31.Object(
|
|
4616
|
+
{
|
|
4617
|
+
agent_ids: Type31.Array(Type31.String({ minLength: 1 }), { minItems: 1 }),
|
|
4618
|
+
timeout_ms: Type31.Optional(Type31.Integer({ minimum: 0, maximum: 6e4 }))
|
|
4619
|
+
},
|
|
4620
|
+
{ additionalProperties: false }
|
|
4621
|
+
),
|
|
4622
|
+
async execute(_id, args, signal) {
|
|
4623
|
+
return jsonToolResult(await agents.wait(args.agent_ids, args.timeout_ms ?? 1e4, signal));
|
|
4624
|
+
}
|
|
4625
|
+
});
|
|
4626
|
+
}
|
|
4627
|
+
var init_wait_agents = __esm({
|
|
4628
|
+
"src/capabilities/tools/agents/wait_agents.ts"() {
|
|
4629
|
+
"use strict";
|
|
4630
|
+
init_workspace();
|
|
4631
|
+
}
|
|
4632
|
+
});
|
|
4633
|
+
|
|
4634
|
+
// src/capabilities/tools/agents/send_message.ts
|
|
4635
|
+
import { defineTool as defineTool33 } from "@earendil-works/pi-coding-agent";
|
|
4636
|
+
import { Type as Type32 } from "typebox";
|
|
4637
|
+
function createSendMessageTool(agents) {
|
|
4638
|
+
return defineTool33({
|
|
4639
|
+
name: "send_message",
|
|
4640
|
+
label: "Send Agent Message",
|
|
4641
|
+
description: "Queue additional facts, constraints or feedback for an existing running child. The child receives messages at safe execution boundaries. Returns message submission status, not task completion. Does not start or restart an agent.",
|
|
4642
|
+
parameters: Type32.Object(
|
|
4643
|
+
{ agent_id: Type32.String({ minLength: 1 }), message: Type32.String({ minLength: 1 }) },
|
|
4644
|
+
{ additionalProperties: false }
|
|
4645
|
+
),
|
|
4646
|
+
async execute(_id, args, signal) {
|
|
4647
|
+
return jsonToolResult(await agents.send(args.agent_id, args.message, signal));
|
|
4648
|
+
}
|
|
4649
|
+
});
|
|
4650
|
+
}
|
|
4651
|
+
var init_send_message = __esm({
|
|
4652
|
+
"src/capabilities/tools/agents/send_message.ts"() {
|
|
4653
|
+
"use strict";
|
|
4654
|
+
init_workspace();
|
|
4655
|
+
}
|
|
4656
|
+
});
|
|
4657
|
+
|
|
4658
|
+
// src/utils/storage/json_store.ts
|
|
4659
|
+
import { mkdir as mkdir8, readFile as readFile7, writeFile as writeFile7, rename as rename2, unlink } from "node:fs/promises";
|
|
4592
4660
|
import path17 from "node:path";
|
|
4661
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
4662
|
+
var JsonStore;
|
|
4663
|
+
var init_json_store = __esm({
|
|
4664
|
+
"src/utils/storage/json_store.ts"() {
|
|
4665
|
+
"use strict";
|
|
4666
|
+
JsonStore = class {
|
|
4667
|
+
file;
|
|
4668
|
+
initial;
|
|
4669
|
+
queue = Promise.resolve();
|
|
4670
|
+
constructor(file, initial) {
|
|
4671
|
+
this.file = file;
|
|
4672
|
+
this.initial = structuredClone(initial);
|
|
4673
|
+
}
|
|
4674
|
+
async read() {
|
|
4675
|
+
await this.queue.catch(() => {
|
|
4676
|
+
});
|
|
4677
|
+
return this.load();
|
|
4678
|
+
}
|
|
4679
|
+
async load() {
|
|
4680
|
+
try {
|
|
4681
|
+
return JSON.parse(await readFile7(this.file, "utf8"));
|
|
4682
|
+
} catch (error) {
|
|
4683
|
+
if (error.code !== "ENOENT") throw error;
|
|
4684
|
+
return structuredClone(this.initial);
|
|
4685
|
+
}
|
|
4686
|
+
}
|
|
4687
|
+
update(change) {
|
|
4688
|
+
const operation = this.queue.catch(() => {
|
|
4689
|
+
}).then(async () => {
|
|
4690
|
+
const state = await this.load();
|
|
4691
|
+
const result = await change(state);
|
|
4692
|
+
await mkdir8(path17.dirname(this.file), { recursive: true });
|
|
4693
|
+
const temporary = this.file + "." + randomUUID4();
|
|
4694
|
+
try {
|
|
4695
|
+
await writeFile7(temporary, JSON.stringify(state, null, 2) + "\n", { mode: 384, flag: "wx" });
|
|
4696
|
+
await rename2(temporary, this.file);
|
|
4697
|
+
} finally {
|
|
4698
|
+
await unlink(temporary).catch((e) => {
|
|
4699
|
+
if (e.code !== "ENOENT") throw e;
|
|
4700
|
+
});
|
|
4701
|
+
}
|
|
4702
|
+
return result;
|
|
4703
|
+
});
|
|
4704
|
+
this.queue = operation;
|
|
4705
|
+
return operation;
|
|
4706
|
+
}
|
|
4707
|
+
};
|
|
4708
|
+
}
|
|
4709
|
+
});
|
|
4710
|
+
|
|
4711
|
+
// src/utils/async/abortable.ts
|
|
4712
|
+
function abortable(promise, signal) {
|
|
4713
|
+
if (!signal) return promise;
|
|
4714
|
+
signal.throwIfAborted();
|
|
4715
|
+
return new Promise((resolve, reject) => {
|
|
4716
|
+
const abort = () => {
|
|
4717
|
+
cleanup();
|
|
4718
|
+
reject(signal.reason ?? new Error("Operation aborted"));
|
|
4719
|
+
};
|
|
4720
|
+
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
4721
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
4722
|
+
promise.then(
|
|
4723
|
+
(value) => {
|
|
4724
|
+
cleanup();
|
|
4725
|
+
resolve(value);
|
|
4726
|
+
},
|
|
4727
|
+
(error) => {
|
|
4728
|
+
cleanup();
|
|
4729
|
+
reject(error);
|
|
4730
|
+
}
|
|
4731
|
+
);
|
|
4732
|
+
});
|
|
4733
|
+
}
|
|
4734
|
+
var init_abortable = __esm({
|
|
4735
|
+
"src/utils/async/abortable.ts"() {
|
|
4736
|
+
"use strict";
|
|
4737
|
+
}
|
|
4738
|
+
});
|
|
4739
|
+
|
|
4740
|
+
// src/utils/agents/agent_manager.ts
|
|
4741
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
4742
|
+
var AgentManager;
|
|
4743
|
+
var init_agent_manager = __esm({
|
|
4744
|
+
"src/utils/agents/agent_manager.ts"() {
|
|
4745
|
+
"use strict";
|
|
4746
|
+
init_json_store();
|
|
4747
|
+
init_abortable();
|
|
4748
|
+
AgentManager = class {
|
|
4749
|
+
store;
|
|
4750
|
+
records = /* @__PURE__ */ new Map();
|
|
4751
|
+
live = /* @__PURE__ */ new Map();
|
|
4752
|
+
run;
|
|
4753
|
+
delegated;
|
|
4754
|
+
recordOperation;
|
|
4755
|
+
closed = false;
|
|
4756
|
+
constructor(run, delegated, recordOperation = () => {
|
|
4757
|
+
}) {
|
|
4758
|
+
this.run = run;
|
|
4759
|
+
this.delegated = delegated;
|
|
4760
|
+
this.recordOperation = recordOperation;
|
|
4761
|
+
}
|
|
4762
|
+
async bind(file) {
|
|
4763
|
+
await this.cancelAll();
|
|
4764
|
+
this.records.clear();
|
|
4765
|
+
this.live.clear();
|
|
4766
|
+
this.closed = false;
|
|
4767
|
+
this.store = new JsonStore(file, { agents: [] });
|
|
4768
|
+
for (const record8 of (await this.store.read()).agents) {
|
|
4769
|
+
if (record8.status === "running") {
|
|
4770
|
+
record8.status = "cancelled";
|
|
4771
|
+
record8.error = "Child execution was interrupted; start a new child to retry";
|
|
4772
|
+
}
|
|
4773
|
+
this.records.set(record8.id, record8);
|
|
4774
|
+
}
|
|
4775
|
+
await this.save();
|
|
4776
|
+
}
|
|
4777
|
+
async save() {
|
|
4778
|
+
if (!this.store) throw new Error("Child agents require a bound session");
|
|
4779
|
+
const agents = structuredClone([...this.records.values()]);
|
|
4780
|
+
await this.store.update((state) => {
|
|
4781
|
+
state.agents = agents;
|
|
4782
|
+
});
|
|
4783
|
+
}
|
|
4784
|
+
get(id) {
|
|
4785
|
+
const record8 = this.records.get(id);
|
|
4786
|
+
if (!record8) throw new Error(`Unknown child agent: ${id}`);
|
|
4787
|
+
return record8;
|
|
4788
|
+
}
|
|
4789
|
+
list() {
|
|
4790
|
+
return [...this.records.values()].map((record8) => ({
|
|
4791
|
+
agent_id: record8.id,
|
|
4792
|
+
task: record8.task.slice(0, 240),
|
|
4793
|
+
status: record8.status,
|
|
4794
|
+
session_id: record8.sessionId,
|
|
4795
|
+
collected: record8.collected
|
|
4796
|
+
}));
|
|
4797
|
+
}
|
|
4798
|
+
async start(task, context, signal) {
|
|
4799
|
+
if (this.closed) throw new Error("Child agent manager is closed");
|
|
4800
|
+
if (!this.store) throw new Error("Child agents require a bound session");
|
|
4801
|
+
signal?.throwIfAborted();
|
|
4802
|
+
if ([...this.records.values()].some((record9) => record9.status === "running"))
|
|
4803
|
+
throw new Error("Only one child agent may run at a time; wait for the current child before starting another");
|
|
4804
|
+
const record8 = {
|
|
4805
|
+
id: randomUUID5(),
|
|
4806
|
+
task,
|
|
4807
|
+
status: "running",
|
|
4808
|
+
createdAt: Date.now(),
|
|
4809
|
+
collected: false,
|
|
4810
|
+
messages: []
|
|
4811
|
+
};
|
|
4812
|
+
const controller = new AbortController();
|
|
4813
|
+
const owner = context.signal ?? signal;
|
|
4814
|
+
const abort = () => controller.abort(owner?.reason);
|
|
4815
|
+
owner?.addEventListener("abort", abort, { once: true });
|
|
4816
|
+
if (owner?.aborted) abort();
|
|
4817
|
+
const live = { record: record8, controller, settled: Promise.resolve(), delivery: Promise.resolve() };
|
|
4818
|
+
let accepted = false;
|
|
4819
|
+
let begin;
|
|
4820
|
+
const committed = new Promise((resolve) => {
|
|
4821
|
+
begin = resolve;
|
|
4822
|
+
});
|
|
4823
|
+
live.settled = committed.then(async () => {
|
|
4824
|
+
if (!accepted) return;
|
|
4825
|
+
try {
|
|
4826
|
+
controller.signal.throwIfAborted();
|
|
4827
|
+
const result = await this.run(task, context, controller.signal, {
|
|
4828
|
+
bind: (mailbox) => {
|
|
4829
|
+
live.mailbox = mailbox;
|
|
4830
|
+
record8.sessionId = mailbox.sessionId;
|
|
4831
|
+
this.flush(live);
|
|
4832
|
+
}
|
|
4833
|
+
});
|
|
4834
|
+
record8.result = result;
|
|
4835
|
+
record8.sessionId = result.sessionId;
|
|
4836
|
+
record8.status = controller.signal.aborted ? "cancelled" : "completed";
|
|
4837
|
+
} catch (error) {
|
|
4838
|
+
record8.status = controller.signal.aborted ? "cancelled" : "failed";
|
|
4839
|
+
record8.error = error instanceof Error ? error.message : String(error);
|
|
4840
|
+
} finally {
|
|
4841
|
+
owner?.removeEventListener("abort", abort);
|
|
4842
|
+
await live.delivery;
|
|
4843
|
+
for (const message of record8.messages)
|
|
4844
|
+
if (message.status === "queued") {
|
|
4845
|
+
message.status = "failed";
|
|
4846
|
+
message.error = "Child ended before accepting the message";
|
|
4847
|
+
}
|
|
4848
|
+
await this.save();
|
|
4849
|
+
}
|
|
4850
|
+
});
|
|
4851
|
+
void live.settled.catch(() => {
|
|
4852
|
+
});
|
|
4853
|
+
this.records.set(record8.id, record8);
|
|
4854
|
+
this.live.set(record8.id, live);
|
|
4855
|
+
try {
|
|
4856
|
+
await this.save();
|
|
4857
|
+
this.delegated();
|
|
4858
|
+
this.recordOperation({ operation: "create", agent_ids: [record8.id] });
|
|
4859
|
+
accepted = true;
|
|
4860
|
+
} catch (error) {
|
|
4861
|
+
owner?.removeEventListener("abort", abort);
|
|
4862
|
+
this.records.delete(record8.id);
|
|
4863
|
+
this.live.delete(record8.id);
|
|
4864
|
+
throw error;
|
|
4865
|
+
} finally {
|
|
4866
|
+
begin();
|
|
4867
|
+
}
|
|
4868
|
+
return { agent_id: record8.id, status: record8.status };
|
|
4869
|
+
}
|
|
4870
|
+
flush(live) {
|
|
4871
|
+
if (!live.mailbox) return;
|
|
4872
|
+
live.delivery = live.delivery.then(async () => {
|
|
4873
|
+
for (const message of live.record.messages) {
|
|
4874
|
+
if (message.status !== "queued") continue;
|
|
4875
|
+
try {
|
|
4876
|
+
live.controller.signal.throwIfAborted();
|
|
4877
|
+
await live.mailbox.send(message.id, message.text);
|
|
4878
|
+
message.status = "submitted";
|
|
4879
|
+
} catch (error) {
|
|
4880
|
+
message.status = "failed";
|
|
4881
|
+
message.error = error instanceof Error ? error.message : String(error);
|
|
4882
|
+
}
|
|
4883
|
+
}
|
|
4884
|
+
await this.save();
|
|
4885
|
+
});
|
|
4886
|
+
void live.delivery.catch(() => {
|
|
4887
|
+
});
|
|
4888
|
+
}
|
|
4889
|
+
async send(id, text2, signal) {
|
|
4890
|
+
signal?.throwIfAborted();
|
|
4891
|
+
const record8 = this.get(id);
|
|
4892
|
+
const live = this.live.get(id);
|
|
4893
|
+
if (record8.status !== "running" || !live)
|
|
4894
|
+
throw new Error("Messages can only be sent to a running child; start a new child for another task");
|
|
4895
|
+
const message = { id: randomUUID5(), text: text2, status: "queued" };
|
|
4896
|
+
record8.messages.push(message);
|
|
4897
|
+
await this.save();
|
|
4898
|
+
this.recordOperation({ operation: "send", agent_ids: [id], message_id: message.id });
|
|
4899
|
+
this.flush(live);
|
|
4900
|
+
await abortable(live.delivery, signal);
|
|
4901
|
+
return {
|
|
4902
|
+
agent_id: id,
|
|
4903
|
+
message_id: message.id,
|
|
4904
|
+
status: message.status,
|
|
4905
|
+
error: message.error,
|
|
4906
|
+
agent_status: record8.status
|
|
4907
|
+
};
|
|
4908
|
+
}
|
|
4909
|
+
async wait(ids, timeoutMs, signal, automatic = false) {
|
|
4910
|
+
signal?.throwIfAborted();
|
|
4911
|
+
const records = [...new Set(ids)].map((id) => this.get(id));
|
|
4912
|
+
this.recordOperation({ operation: "wait", agent_ids: records.map((record8) => record8.id), automatic });
|
|
4913
|
+
const settled = Promise.all(
|
|
4914
|
+
records.filter((record8) => record8.status === "running").map((record8) => this.live.get(record8.id).settled)
|
|
4915
|
+
);
|
|
4916
|
+
let timer;
|
|
4917
|
+
try {
|
|
4918
|
+
await abortable(
|
|
4919
|
+
timeoutMs === void 0 ? settled : Promise.race([
|
|
4920
|
+
settled,
|
|
4921
|
+
new Promise((resolve) => {
|
|
4922
|
+
timer = setTimeout(resolve, timeoutMs);
|
|
4923
|
+
})
|
|
4924
|
+
]),
|
|
4925
|
+
signal
|
|
4926
|
+
);
|
|
4927
|
+
} finally {
|
|
4928
|
+
if (timer) clearTimeout(timer);
|
|
4929
|
+
}
|
|
4930
|
+
for (const record8 of records) if (record8.status !== "running") record8.collected = true;
|
|
4931
|
+
await this.save();
|
|
4932
|
+
return {
|
|
4933
|
+
agents: records.map((record8) => ({
|
|
4934
|
+
agent_id: record8.id,
|
|
4935
|
+
status: record8.status,
|
|
4936
|
+
session_id: record8.sessionId,
|
|
4937
|
+
result: record8.result,
|
|
4938
|
+
error: record8.error
|
|
4939
|
+
})),
|
|
4940
|
+
timed_out: records.some((record8) => record8.status === "running")
|
|
4941
|
+
};
|
|
4942
|
+
}
|
|
4943
|
+
uncollected() {
|
|
4944
|
+
return [...this.records.values()].filter((record8) => !record8.collected).map((record8) => record8.id);
|
|
4945
|
+
}
|
|
4946
|
+
async cancelAll() {
|
|
4947
|
+
for (const live of this.live.values())
|
|
4948
|
+
if (live.record.status === "running") live.controller.abort(new Error("Parent session ended"));
|
|
4949
|
+
await Promise.all([...this.live.values()].map((live) => live.settled));
|
|
4950
|
+
}
|
|
4951
|
+
async dispose() {
|
|
4952
|
+
this.closed = true;
|
|
4953
|
+
await this.cancelAll();
|
|
4954
|
+
}
|
|
4955
|
+
};
|
|
4956
|
+
}
|
|
4957
|
+
});
|
|
4958
|
+
|
|
4959
|
+
// src/utils/filesystem/apply_patch.ts
|
|
4960
|
+
import { mkdir as mkdir9, readFile as readFile8, stat, unlink as unlink2, writeFile as writeFile8 } from "node:fs/promises";
|
|
4961
|
+
import path18 from "node:path";
|
|
4593
4962
|
function patchError(message) {
|
|
4594
4963
|
return new Error(`Invalid patch: ${message}`);
|
|
4595
4964
|
}
|
|
@@ -4932,8 +5301,8 @@ function throwIfAborted(signal) {
|
|
|
4932
5301
|
}
|
|
4933
5302
|
async function writeWithParents(target, contents, signal) {
|
|
4934
5303
|
throwIfAborted(signal);
|
|
4935
|
-
await
|
|
4936
|
-
await
|
|
5304
|
+
await mkdir9(path18.dirname(target), { recursive: true });
|
|
5305
|
+
await writeFile8(target, contents, { encoding: "utf8", signal });
|
|
4937
5306
|
}
|
|
4938
5307
|
function formatApplyPatchSummary(paths) {
|
|
4939
5308
|
const rows = [
|
|
@@ -4960,25 +5329,25 @@ async function applyPatch(cwd, patch, signal) {
|
|
|
4960
5329
|
if (hunk.type === "delete") {
|
|
4961
5330
|
const target2 = await resolveWorkspacePath(cwd, hunk.path);
|
|
4962
5331
|
await requireRegularFile(target2, "Failed to delete file");
|
|
4963
|
-
await
|
|
5332
|
+
await unlink2(target2);
|
|
4964
5333
|
affected.deleted.push(hunk.path);
|
|
4965
5334
|
continue;
|
|
4966
5335
|
}
|
|
4967
5336
|
const target = await resolveWorkspacePath(cwd, hunk.path);
|
|
4968
5337
|
await requireRegularFile(target, "Failed to read file to update");
|
|
4969
|
-
const before = await
|
|
5338
|
+
const before = await readFile8(target, { encoding: "utf8", signal });
|
|
4970
5339
|
const after = applyUpdate(before, target, hunk.chunks);
|
|
4971
5340
|
if (hunk.movePath === void 0) {
|
|
4972
|
-
await
|
|
5341
|
+
await writeFile8(target, after, { encoding: "utf8", signal });
|
|
4973
5342
|
affected.modified.push(hunk.path);
|
|
4974
5343
|
continue;
|
|
4975
5344
|
}
|
|
4976
5345
|
const destination = await resolveWorkspacePath(cwd, hunk.movePath);
|
|
4977
5346
|
if (destination === target) {
|
|
4978
|
-
await
|
|
5347
|
+
await writeFile8(target, after, { encoding: "utf8", signal });
|
|
4979
5348
|
} else {
|
|
4980
5349
|
await writeWithParents(destination, after, signal);
|
|
4981
|
-
await
|
|
5350
|
+
await unlink2(target);
|
|
4982
5351
|
}
|
|
4983
5352
|
affected.modified.push(hunk.movePath);
|
|
4984
5353
|
}
|
|
@@ -5001,11 +5370,11 @@ var init_apply_patch = __esm({
|
|
|
5001
5370
|
|
|
5002
5371
|
// src/capabilities/tools/filesystem/apply_patch.ts
|
|
5003
5372
|
import {
|
|
5004
|
-
defineTool as
|
|
5373
|
+
defineTool as defineTool34
|
|
5005
5374
|
} from "@earendil-works/pi-coding-agent";
|
|
5006
|
-
import { Type as
|
|
5375
|
+
import { Type as Type33 } from "typebox";
|
|
5007
5376
|
function createApplyPatchTool(cwd) {
|
|
5008
|
-
return
|
|
5377
|
+
return defineTool34({
|
|
5009
5378
|
name: APPLY_PATCH_TOOL_NAME,
|
|
5010
5379
|
label: "Apply Patch",
|
|
5011
5380
|
description: DESCRIPTION,
|
|
@@ -5046,8 +5415,8 @@ var init_apply_patch2 = __esm({
|
|
|
5046
5415
|
"Update hunks use @@ sections with lines prefixed by space (context), - (remove), or + (add), and may include '*** Move to: path'.",
|
|
5047
5416
|
"Paths may be relative to the workspace root or absolute paths inside it."
|
|
5048
5417
|
].join(" ");
|
|
5049
|
-
schema16 =
|
|
5050
|
-
patch:
|
|
5418
|
+
schema16 = Type33.Object({
|
|
5419
|
+
patch: Type33.String({
|
|
5051
5420
|
minLength: 1,
|
|
5052
5421
|
description: "Complete Codex patch text from *** Begin Patch through *** End Patch."
|
|
5053
5422
|
})
|
|
@@ -5056,15 +5425,15 @@ var init_apply_patch2 = __esm({
|
|
|
5056
5425
|
});
|
|
5057
5426
|
|
|
5058
5427
|
// src/capabilities/tools/filesystem/list_directory.ts
|
|
5059
|
-
import { defineTool as
|
|
5060
|
-
import { Type as
|
|
5428
|
+
import { defineTool as defineTool35 } from "@earendil-works/pi-coding-agent";
|
|
5429
|
+
import { Type as Type34 } from "typebox";
|
|
5061
5430
|
import { readdir as readdir2 } from "node:fs/promises";
|
|
5062
5431
|
function createListDirectoryTool(cwd) {
|
|
5063
|
-
return
|
|
5432
|
+
return defineTool35({
|
|
5064
5433
|
name: "list_directory",
|
|
5065
5434
|
label: "List Directory",
|
|
5066
5435
|
description: "List direct children of a workspace directory, including entry type.",
|
|
5067
|
-
parameters:
|
|
5436
|
+
parameters: Type34.Object({ path: Type34.Optional(Type34.String()) }),
|
|
5068
5437
|
async execute(_id, args) {
|
|
5069
5438
|
const entries = await readdir2(await resolveWorkspacePath(cwd, args.path ?? "."), { withFileTypes: true });
|
|
5070
5439
|
return jsonToolResult(
|
|
@@ -5086,11 +5455,11 @@ var init_list_directory = __esm({
|
|
|
5086
5455
|
// src/capabilities/tools/filesystem/glob.ts
|
|
5087
5456
|
import {
|
|
5088
5457
|
createFindToolDefinition as createFindToolDefinition3,
|
|
5089
|
-
defineTool as
|
|
5458
|
+
defineTool as defineTool36
|
|
5090
5459
|
} from "@earendil-works/pi-coding-agent";
|
|
5091
5460
|
function createGlobTool(cwd) {
|
|
5092
5461
|
const nativeFind = createFindToolDefinition3(cwd);
|
|
5093
|
-
return
|
|
5462
|
+
return defineTool36({
|
|
5094
5463
|
...nativeFind,
|
|
5095
5464
|
name: GLOB_TOOL_NAME,
|
|
5096
5465
|
label: "Glob"
|
|
@@ -5121,24 +5490,24 @@ var init_grep = __esm({
|
|
|
5121
5490
|
});
|
|
5122
5491
|
|
|
5123
5492
|
// src/utils/filesystem/text_edit.ts
|
|
5124
|
-
import { readFile as
|
|
5125
|
-
import { randomUUID as
|
|
5493
|
+
import { readFile as readFile9, writeFile as writeFile9, rename as rename3, stat as stat2, unlink as unlink3 } from "node:fs/promises";
|
|
5494
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
5126
5495
|
async function updateTextFile(target, edit, signal) {
|
|
5127
5496
|
const previous = locks.get(target) ?? Promise.resolve();
|
|
5128
5497
|
const next = previous.catch(() => {
|
|
5129
5498
|
}).then(async () => {
|
|
5130
5499
|
signal?.throwIfAborted();
|
|
5131
|
-
const [original, metadata] = await Promise.all([
|
|
5500
|
+
const [original, metadata] = await Promise.all([readFile9(target, "utf8"), stat2(target)]);
|
|
5132
5501
|
const modified = edit(original);
|
|
5133
|
-
const temporary = target + ".scaling-" +
|
|
5502
|
+
const temporary = target + ".scaling-" + randomUUID6();
|
|
5134
5503
|
try {
|
|
5135
|
-
await
|
|
5504
|
+
await writeFile9(temporary, modified, { flag: "wx", mode: metadata.mode });
|
|
5136
5505
|
signal?.throwIfAborted();
|
|
5137
|
-
if (await
|
|
5506
|
+
if (await readFile9(target, "utf8") !== original)
|
|
5138
5507
|
throw new Error("File changed during edit; read it again before retrying");
|
|
5139
|
-
await
|
|
5508
|
+
await rename3(temporary, target);
|
|
5140
5509
|
} finally {
|
|
5141
|
-
await
|
|
5510
|
+
await unlink3(temporary).catch((error) => {
|
|
5142
5511
|
if (error.code !== "ENOENT") throw error;
|
|
5143
5512
|
});
|
|
5144
5513
|
}
|
|
@@ -5159,21 +5528,21 @@ var init_text_edit = __esm({
|
|
|
5159
5528
|
});
|
|
5160
5529
|
|
|
5161
5530
|
// src/capabilities/tools/filesystem/notebook_edit.ts
|
|
5162
|
-
import { defineTool as
|
|
5163
|
-
import { Type as
|
|
5164
|
-
import { randomUUID as
|
|
5531
|
+
import { defineTool as defineTool37 } from "@earendil-works/pi-coding-agent";
|
|
5532
|
+
import { Type as Type35 } from "typebox";
|
|
5533
|
+
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
5165
5534
|
function createNotebookEditTool(cwd) {
|
|
5166
|
-
return
|
|
5535
|
+
return defineTool37({
|
|
5167
5536
|
name: "notebook_edit",
|
|
5168
5537
|
label: "Notebook Edit",
|
|
5169
5538
|
description: "Replace, insert, or delete a Jupyter notebook cell by id or zero-based index. Editing code clears stale execution results. Unrelated notebook metadata is preserved.",
|
|
5170
5539
|
executionMode: "sequential",
|
|
5171
|
-
parameters:
|
|
5172
|
-
path:
|
|
5173
|
-
action:
|
|
5174
|
-
cell:
|
|
5175
|
-
source:
|
|
5176
|
-
cell_type:
|
|
5540
|
+
parameters: Type35.Object({
|
|
5541
|
+
path: Type35.String(),
|
|
5542
|
+
action: Type35.Union([Type35.Literal("replace"), Type35.Literal("insert"), Type35.Literal("delete")]),
|
|
5543
|
+
cell: Type35.Union([Type35.String(), Type35.Integer({ minimum: 0 })]),
|
|
5544
|
+
source: Type35.Optional(Type35.String()),
|
|
5545
|
+
cell_type: Type35.Optional(Type35.Union([Type35.Literal("code"), Type35.Literal("markdown"), Type35.Literal("raw")]))
|
|
5177
5546
|
}),
|
|
5178
5547
|
async execute(_id, args, signal) {
|
|
5179
5548
|
await updateTextFile(
|
|
@@ -5188,7 +5557,7 @@ function createNotebookEditTool(cwd) {
|
|
|
5188
5557
|
if (args.action === "delete") notebook.cells.splice(index, 1);
|
|
5189
5558
|
else {
|
|
5190
5559
|
if (args.source === void 0) throw new Error("source is required for replace/insert");
|
|
5191
|
-
const cell = args.action === "insert" ? { id:
|
|
5560
|
+
const cell = args.action === "insert" ? { id: randomUUID7().slice(0, 8), metadata: {} } : notebook.cells[index];
|
|
5192
5561
|
cell.cell_type = args.cell_type ?? cell.cell_type ?? "code";
|
|
5193
5562
|
cell.source = args.source.match(/[^\n]*\n|[^\n]+$/g) ?? [];
|
|
5194
5563
|
if (cell.cell_type === "code") {
|
|
@@ -5217,15 +5586,15 @@ var init_notebook_edit = __esm({
|
|
|
5217
5586
|
});
|
|
5218
5587
|
|
|
5219
5588
|
// src/capabilities/tools/filesystem/enter_worktree.ts
|
|
5220
|
-
import { defineTool as
|
|
5221
|
-
import { Type as
|
|
5589
|
+
import { defineTool as defineTool38 } from "@earendil-works/pi-coding-agent";
|
|
5590
|
+
import { Type as Type36 } from "typebox";
|
|
5222
5591
|
function createEnterWorktreeTool(manager) {
|
|
5223
|
-
return
|
|
5592
|
+
return defineTool38({
|
|
5224
5593
|
name: "enter_worktree",
|
|
5225
5594
|
label: "Enter Worktree",
|
|
5226
5595
|
executionMode: "sequential",
|
|
5227
5596
|
description: "Create an isolated Git worktree on a new branch and return its absolute path and worktree_id. The default working directory stays unchanged; route subsequent operations through the returned path.",
|
|
5228
|
-
parameters:
|
|
5597
|
+
parameters: Type36.Object({ name: Type36.Optional(Type36.String()) }),
|
|
5229
5598
|
async execute(_id, args, signal) {
|
|
5230
5599
|
const result = await manager.enter(args.name, signal);
|
|
5231
5600
|
return jsonToolResult({ ...result, worktree_id: result.id });
|
|
@@ -5240,15 +5609,15 @@ var init_enter_worktree = __esm({
|
|
|
5240
5609
|
});
|
|
5241
5610
|
|
|
5242
5611
|
// src/capabilities/tools/filesystem/exit_worktree.ts
|
|
5243
|
-
import { defineTool as
|
|
5244
|
-
import { Type as
|
|
5612
|
+
import { defineTool as defineTool39 } from "@earendil-works/pi-coding-agent";
|
|
5613
|
+
import { Type as Type37 } from "typebox";
|
|
5245
5614
|
function createExitWorktreeTool(manager) {
|
|
5246
|
-
return
|
|
5615
|
+
return defineTool39({
|
|
5247
5616
|
name: "exit_worktree",
|
|
5248
5617
|
label: "Exit Worktree",
|
|
5249
5618
|
executionMode: "sequential",
|
|
5250
5619
|
description: "Finish a managed worktree. keep defaults to true. keep=false removes only a clean worktree; dirty files are preserved by Git's refusal. The branch is retained.",
|
|
5251
|
-
parameters:
|
|
5620
|
+
parameters: Type37.Object({ worktree_id: Type37.String(), keep: Type37.Optional(Type37.Boolean()) }),
|
|
5252
5621
|
async execute(_id, args, signal) {
|
|
5253
5622
|
return jsonToolResult(await manager.exit(args.worktree_id, args.keep, signal));
|
|
5254
5623
|
}
|
|
@@ -5262,15 +5631,15 @@ var init_exit_worktree = __esm({
|
|
|
5262
5631
|
});
|
|
5263
5632
|
|
|
5264
5633
|
// src/capabilities/tools/execution/list_processes.ts
|
|
5265
|
-
import { defineTool as
|
|
5266
|
-
import { Type as
|
|
5634
|
+
import { defineTool as defineTool40 } from "@earendil-works/pi-coding-agent";
|
|
5635
|
+
import { Type as Type38 } from "typebox";
|
|
5267
5636
|
function createListProcessesTool(manager) {
|
|
5268
|
-
const identifier =
|
|
5269
|
-
return
|
|
5637
|
+
const identifier = Type38.String({ minLength: 1 });
|
|
5638
|
+
return defineTool40({
|
|
5270
5639
|
name: "list_processes",
|
|
5271
5640
|
label: "List Processes",
|
|
5272
5641
|
description: "List shell processes started by this runtime and their exit status.",
|
|
5273
|
-
parameters:
|
|
5642
|
+
parameters: Type38.Object({}),
|
|
5274
5643
|
async execute() {
|
|
5275
5644
|
return jsonToolResult(manager.list());
|
|
5276
5645
|
}
|
|
@@ -5284,19 +5653,19 @@ var init_list_processes = __esm({
|
|
|
5284
5653
|
});
|
|
5285
5654
|
|
|
5286
5655
|
// src/capabilities/tools/execution/read_process_output.ts
|
|
5287
|
-
import { defineTool as
|
|
5288
|
-
import { Type as
|
|
5656
|
+
import { defineTool as defineTool41 } from "@earendil-works/pi-coding-agent";
|
|
5657
|
+
import { Type as Type39 } from "typebox";
|
|
5289
5658
|
function createReadProcessOutputTool(manager) {
|
|
5290
|
-
const identifier =
|
|
5291
|
-
return
|
|
5659
|
+
const identifier = Type39.String({ minLength: 1 });
|
|
5660
|
+
return defineTool41({
|
|
5292
5661
|
name: "read_process_output",
|
|
5293
5662
|
label: "Read Process Output",
|
|
5294
5663
|
description: "Read incremental process output. offset and next_offset are byte offsets; omitted offset continues from the previous read.",
|
|
5295
|
-
parameters:
|
|
5664
|
+
parameters: Type39.Object({
|
|
5296
5665
|
process_id: identifier,
|
|
5297
|
-
offset:
|
|
5298
|
-
max_bytes:
|
|
5299
|
-
wait_ms:
|
|
5666
|
+
offset: Type39.Optional(Type39.Integer({ minimum: 0 })),
|
|
5667
|
+
max_bytes: Type39.Optional(Type39.Integer({ minimum: 1, maximum: 1e6 })),
|
|
5668
|
+
wait_ms: Type39.Optional(Type39.Integer({ minimum: 0, maximum: 3e4 }))
|
|
5300
5669
|
}),
|
|
5301
5670
|
async execute(_id, args, signal) {
|
|
5302
5671
|
await manager.wait(args.process_id, args.wait_ms ?? 0, signal);
|
|
@@ -5312,19 +5681,19 @@ var init_read_process_output = __esm({
|
|
|
5312
5681
|
});
|
|
5313
5682
|
|
|
5314
5683
|
// src/capabilities/tools/execution/write_stdin.ts
|
|
5315
|
-
import { defineTool as
|
|
5316
|
-
import { Type as
|
|
5684
|
+
import { defineTool as defineTool42 } from "@earendil-works/pi-coding-agent";
|
|
5685
|
+
import { Type as Type40 } from "typebox";
|
|
5317
5686
|
function createWriteStdinTool(manager) {
|
|
5318
|
-
const identifier =
|
|
5319
|
-
return
|
|
5687
|
+
const identifier = Type40.String({ minLength: 1 });
|
|
5688
|
+
return defineTool42({
|
|
5320
5689
|
name: "write_stdin",
|
|
5321
5690
|
label: "Write Stdin",
|
|
5322
5691
|
description: "Send input to a live shell process; optionally close stdin and read subsequent output.",
|
|
5323
|
-
parameters:
|
|
5692
|
+
parameters: Type40.Object({
|
|
5324
5693
|
process_id: identifier,
|
|
5325
|
-
chars:
|
|
5326
|
-
close:
|
|
5327
|
-
wait_ms:
|
|
5694
|
+
chars: Type40.String(),
|
|
5695
|
+
close: Type40.Optional(Type40.Boolean()),
|
|
5696
|
+
wait_ms: Type40.Optional(Type40.Integer({ minimum: 0, maximum: 3e4 }))
|
|
5328
5697
|
}),
|
|
5329
5698
|
async execute(_id, args, signal) {
|
|
5330
5699
|
signal?.throwIfAborted();
|
|
@@ -5342,15 +5711,15 @@ var init_write_stdin = __esm({
|
|
|
5342
5711
|
});
|
|
5343
5712
|
|
|
5344
5713
|
// src/capabilities/tools/execution/stop_process.ts
|
|
5345
|
-
import { defineTool as
|
|
5346
|
-
import { Type as
|
|
5714
|
+
import { defineTool as defineTool43 } from "@earendil-works/pi-coding-agent";
|
|
5715
|
+
import { Type as Type41 } from "typebox";
|
|
5347
5716
|
function createStopProcessTool(manager) {
|
|
5348
|
-
const identifier =
|
|
5349
|
-
return
|
|
5717
|
+
const identifier = Type41.String({ minLength: 1 });
|
|
5718
|
+
return defineTool43({
|
|
5350
5719
|
name: "stop_process",
|
|
5351
5720
|
label: "Stop Process",
|
|
5352
5721
|
description: "Terminate a managed process group and wait for its output streams to close.",
|
|
5353
|
-
parameters:
|
|
5722
|
+
parameters: Type41.Object({ process_id: identifier }),
|
|
5354
5723
|
async execute(_id, args) {
|
|
5355
5724
|
await manager.stop(args.process_id);
|
|
5356
5725
|
return jsonToolResult(await manager.read(args.process_id));
|
|
@@ -5365,30 +5734,30 @@ var init_stop_process = __esm({
|
|
|
5365
5734
|
});
|
|
5366
5735
|
|
|
5367
5736
|
// src/capabilities/tools/web/http_request.ts
|
|
5368
|
-
import { defineTool as
|
|
5369
|
-
import { Type as
|
|
5737
|
+
import { defineTool as defineTool44 } from "@earendil-works/pi-coding-agent";
|
|
5738
|
+
import { Type as Type42 } from "typebox";
|
|
5370
5739
|
function createHttpRequestTool(resolveHeader = async (value) => value) {
|
|
5371
|
-
return
|
|
5740
|
+
return defineTool44({
|
|
5372
5741
|
name: "http_request",
|
|
5373
5742
|
label: "HTTP Request",
|
|
5374
5743
|
description: "Make an HTTP(S) request to a web page or API. Returns status, response headers and body; non-success HTTP status is reported as an error with its body preserved. Use response_format=base64 for binary data.",
|
|
5375
|
-
parameters:
|
|
5376
|
-
url:
|
|
5377
|
-
method:
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5744
|
+
parameters: Type42.Object({
|
|
5745
|
+
url: Type42.String({ minLength: 1 }),
|
|
5746
|
+
method: Type42.Optional(
|
|
5747
|
+
Type42.Union([
|
|
5748
|
+
Type42.Literal("GET"),
|
|
5749
|
+
Type42.Literal("HEAD"),
|
|
5750
|
+
Type42.Literal("POST"),
|
|
5751
|
+
Type42.Literal("PUT"),
|
|
5752
|
+
Type42.Literal("PATCH"),
|
|
5753
|
+
Type42.Literal("DELETE"),
|
|
5754
|
+
Type42.Literal("OPTIONS")
|
|
5386
5755
|
])
|
|
5387
5756
|
),
|
|
5388
|
-
headers:
|
|
5389
|
-
body:
|
|
5390
|
-
response_format:
|
|
5391
|
-
timeout_ms:
|
|
5757
|
+
headers: Type42.Optional(Type42.Record(Type42.String(), Type42.String())),
|
|
5758
|
+
body: Type42.Optional(Type42.String()),
|
|
5759
|
+
response_format: Type42.Optional(Type42.Union([Type42.Literal("text"), Type42.Literal("json"), Type42.Literal("base64")])),
|
|
5760
|
+
timeout_ms: Type42.Optional(Type42.Integer({ minimum: 1, maximum: 3e5 }))
|
|
5392
5761
|
}),
|
|
5393
5762
|
async execute(_id, args, signal) {
|
|
5394
5763
|
const url = new URL(args.url);
|
|
@@ -5426,14 +5795,14 @@ var init_http_request = __esm({
|
|
|
5426
5795
|
});
|
|
5427
5796
|
|
|
5428
5797
|
// src/capabilities/tools/skills/skill.ts
|
|
5429
|
-
import { defineTool as
|
|
5430
|
-
import { Type as
|
|
5798
|
+
import { defineTool as defineTool45 } from "@earendil-works/pi-coding-agent";
|
|
5799
|
+
import { Type as Type43 } from "typebox";
|
|
5431
5800
|
function createSkillTool(store) {
|
|
5432
|
-
return
|
|
5801
|
+
return defineTool45({
|
|
5433
5802
|
name: "skill",
|
|
5434
5803
|
label: "Skill",
|
|
5435
5804
|
description: "Load the full instructions for a named skill. Follow its workflow, resolving references against base_directory. Loading a skill does not execute its scripts automatically.",
|
|
5436
|
-
parameters:
|
|
5805
|
+
parameters: Type43.Object({ name: Type43.String({ minLength: 1 }) }),
|
|
5437
5806
|
async execute(_id, args) {
|
|
5438
5807
|
return jsonToolResult(await store.read(args.name));
|
|
5439
5808
|
}
|
|
@@ -5447,16 +5816,16 @@ var init_skill = __esm({
|
|
|
5447
5816
|
});
|
|
5448
5817
|
|
|
5449
5818
|
// src/capabilities/tools/memory/memory_search.ts
|
|
5450
|
-
import { defineTool as
|
|
5451
|
-
import { Type as
|
|
5819
|
+
import { defineTool as defineTool46 } from "@earendil-works/pi-coding-agent";
|
|
5820
|
+
import { Type as Type44 } from "typebox";
|
|
5452
5821
|
function createMemorySearchTool(store) {
|
|
5453
|
-
return
|
|
5822
|
+
return defineTool46({
|
|
5454
5823
|
name: "memory_search",
|
|
5455
5824
|
label: "Memory Search",
|
|
5456
5825
|
description: "Search the run's persistent memory snapshot by words in title, tags and content. This store is independent of session notes and context summaries.",
|
|
5457
|
-
parameters:
|
|
5458
|
-
query:
|
|
5459
|
-
limit:
|
|
5826
|
+
parameters: Type44.Object({
|
|
5827
|
+
query: Type44.String({ minLength: 1 }),
|
|
5828
|
+
limit: Type44.Optional(Type44.Integer({ minimum: 1, maximum: 50 }))
|
|
5460
5829
|
}),
|
|
5461
5830
|
async execute(_id, args) {
|
|
5462
5831
|
return jsonToolResult(await store.search(args.query, args.limit));
|
|
@@ -5471,19 +5840,19 @@ var init_memory_search = __esm({
|
|
|
5471
5840
|
});
|
|
5472
5841
|
|
|
5473
5842
|
// src/capabilities/tools/memory/memory_write.ts
|
|
5474
|
-
import { defineTool as
|
|
5475
|
-
import { Type as
|
|
5843
|
+
import { defineTool as defineTool47 } from "@earendil-works/pi-coding-agent";
|
|
5844
|
+
import { Type as Type45 } from "typebox";
|
|
5476
5845
|
function createMemoryWriteTool(store) {
|
|
5477
|
-
return
|
|
5846
|
+
return defineTool47({
|
|
5478
5847
|
name: "memory_write",
|
|
5479
5848
|
label: "Memory Write",
|
|
5480
5849
|
executionMode: "sequential",
|
|
5481
5850
|
description: "Create a persistent memory entry or replace an existing entry by id. Writes remain in this evaluation run; the next run starts from its initial snapshot.",
|
|
5482
|
-
parameters:
|
|
5483
|
-
id:
|
|
5484
|
-
title:
|
|
5485
|
-
content:
|
|
5486
|
-
tags:
|
|
5851
|
+
parameters: Type45.Object({
|
|
5852
|
+
id: Type45.Optional(Type45.String()),
|
|
5853
|
+
title: Type45.String({ minLength: 1 }),
|
|
5854
|
+
content: Type45.String({ minLength: 1 }),
|
|
5855
|
+
tags: Type45.Optional(Type45.Array(Type45.String()))
|
|
5487
5856
|
}),
|
|
5488
5857
|
async execute(_id, args) {
|
|
5489
5858
|
return jsonToolResult(await store.write(args));
|
|
@@ -5498,14 +5867,14 @@ var init_memory_write = __esm({
|
|
|
5498
5867
|
});
|
|
5499
5868
|
|
|
5500
5869
|
// src/capabilities/tools/mcp/list_mcp_resources.ts
|
|
5501
|
-
import { defineTool as
|
|
5502
|
-
import { Type as
|
|
5870
|
+
import { defineTool as defineTool48 } from "@earendil-works/pi-coding-agent";
|
|
5871
|
+
import { Type as Type46 } from "typebox";
|
|
5503
5872
|
function createListMcpResourcesTool(pool) {
|
|
5504
|
-
return
|
|
5873
|
+
return defineTool48({
|
|
5505
5874
|
name: "list_mcp_resources",
|
|
5506
5875
|
label: "List MCP Resources",
|
|
5507
5876
|
description: "List all paginated resources from one configured MCP server or every configured server. Resources are data, separate from callable MCP tools.",
|
|
5508
|
-
parameters:
|
|
5877
|
+
parameters: Type46.Object({ server: Type46.Optional(Type46.String()) }),
|
|
5509
5878
|
async execute(_id, args, signal) {
|
|
5510
5879
|
return jsonToolResult(
|
|
5511
5880
|
await Promise.all(
|
|
@@ -5526,15 +5895,15 @@ var init_list_mcp_resources = __esm({
|
|
|
5526
5895
|
});
|
|
5527
5896
|
|
|
5528
5897
|
// src/capabilities/tools/mcp/read_mcp_resource.ts
|
|
5529
|
-
import { defineTool as
|
|
5898
|
+
import { defineTool as defineTool49 } from "@earendil-works/pi-coding-agent";
|
|
5530
5899
|
import { toLlmContent } from "@earendil-works/pi-mcp";
|
|
5531
|
-
import { Type as
|
|
5900
|
+
import { Type as Type47 } from "typebox";
|
|
5532
5901
|
function createReadMcpResourceTool(pool) {
|
|
5533
|
-
return
|
|
5902
|
+
return defineTool49({
|
|
5534
5903
|
name: "read_mcp_resource",
|
|
5535
5904
|
label: "Read MCP Resource",
|
|
5536
5905
|
description: "Read a resource URI from its configured MCP server, preserving text and image resources for the model.",
|
|
5537
|
-
parameters:
|
|
5906
|
+
parameters: Type47.Object({ server: Type47.String(), uri: Type47.String({ minLength: 1 }) }),
|
|
5538
5907
|
async execute(_id, args, signal) {
|
|
5539
5908
|
const result = await (await pool.get(args.server, signal)).readResource(args.uri, { signal });
|
|
5540
5909
|
return {
|
|
@@ -5555,8 +5924,8 @@ import { spawn as spawn4 } from "node:child_process";
|
|
|
5555
5924
|
import { closeSync, mkdtempSync, openSync, writeSync } from "node:fs";
|
|
5556
5925
|
import { open as open2, rm as rm4 } from "node:fs/promises";
|
|
5557
5926
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
5558
|
-
import
|
|
5559
|
-
import { randomUUID as
|
|
5927
|
+
import path19 from "node:path";
|
|
5928
|
+
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
5560
5929
|
import { setTimeout as delay4 } from "node:timers/promises";
|
|
5561
5930
|
import { getShellConfig as getShellConfig3 } from "@earendil-works/pi-coding-agent";
|
|
5562
5931
|
var ProcessManager;
|
|
@@ -5575,9 +5944,9 @@ var init_process_manager = __esm({
|
|
|
5575
5944
|
if (this.disposed) throw new Error("Process manager is closed");
|
|
5576
5945
|
if ([...this.processes.values()].filter((p) => p.running).length >= 32)
|
|
5577
5946
|
throw new Error("At most 32 background processes may run at once");
|
|
5578
|
-
this.directory ??= mkdtempSync(
|
|
5579
|
-
const id =
|
|
5580
|
-
const outputPath =
|
|
5947
|
+
this.directory ??= mkdtempSync(path19.join(tmpdir3(), "scaling-processes-"));
|
|
5948
|
+
const id = randomUUID8();
|
|
5949
|
+
const outputPath = path19.join(this.directory, id + ".log");
|
|
5581
5950
|
const fd = openSync(outputPath, "wx", 384);
|
|
5582
5951
|
const shell = getShellConfig3();
|
|
5583
5952
|
let child;
|
|
@@ -5747,35 +6116,6 @@ var init_process_manager = __esm({
|
|
|
5747
6116
|
}
|
|
5748
6117
|
});
|
|
5749
6118
|
|
|
5750
|
-
// src/utils/async/abortable.ts
|
|
5751
|
-
function abortable(promise, signal) {
|
|
5752
|
-
if (!signal) return promise;
|
|
5753
|
-
signal.throwIfAborted();
|
|
5754
|
-
return new Promise((resolve, reject) => {
|
|
5755
|
-
const abort = () => {
|
|
5756
|
-
cleanup();
|
|
5757
|
-
reject(signal.reason ?? new Error("Operation aborted"));
|
|
5758
|
-
};
|
|
5759
|
-
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
5760
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
5761
|
-
promise.then(
|
|
5762
|
-
(value) => {
|
|
5763
|
-
cleanup();
|
|
5764
|
-
resolve(value);
|
|
5765
|
-
},
|
|
5766
|
-
(error) => {
|
|
5767
|
-
cleanup();
|
|
5768
|
-
reject(error);
|
|
5769
|
-
}
|
|
5770
|
-
);
|
|
5771
|
-
});
|
|
5772
|
-
}
|
|
5773
|
-
var init_abortable = __esm({
|
|
5774
|
-
"src/utils/async/abortable.ts"() {
|
|
5775
|
-
"use strict";
|
|
5776
|
-
}
|
|
5777
|
-
});
|
|
5778
|
-
|
|
5779
6119
|
// src/utils/mcp/client_pool.ts
|
|
5780
6120
|
import {
|
|
5781
6121
|
McpClient,
|
|
@@ -5858,61 +6198,8 @@ var init_client_pool = __esm({
|
|
|
5858
6198
|
}
|
|
5859
6199
|
});
|
|
5860
6200
|
|
|
5861
|
-
// src/utils/storage/json_store.ts
|
|
5862
|
-
import { mkdir as mkdir9, readFile as readFile9, writeFile as writeFile9, rename as rename3, unlink as unlink3 } from "node:fs/promises";
|
|
5863
|
-
import path19 from "node:path";
|
|
5864
|
-
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
5865
|
-
var JsonStore;
|
|
5866
|
-
var init_json_store = __esm({
|
|
5867
|
-
"src/utils/storage/json_store.ts"() {
|
|
5868
|
-
"use strict";
|
|
5869
|
-
JsonStore = class {
|
|
5870
|
-
file;
|
|
5871
|
-
initial;
|
|
5872
|
-
queue = Promise.resolve();
|
|
5873
|
-
constructor(file, initial) {
|
|
5874
|
-
this.file = file;
|
|
5875
|
-
this.initial = structuredClone(initial);
|
|
5876
|
-
}
|
|
5877
|
-
async read() {
|
|
5878
|
-
await this.queue.catch(() => {
|
|
5879
|
-
});
|
|
5880
|
-
return this.load();
|
|
5881
|
-
}
|
|
5882
|
-
async load() {
|
|
5883
|
-
try {
|
|
5884
|
-
return JSON.parse(await readFile9(this.file, "utf8"));
|
|
5885
|
-
} catch (error) {
|
|
5886
|
-
if (error.code !== "ENOENT") throw error;
|
|
5887
|
-
return structuredClone(this.initial);
|
|
5888
|
-
}
|
|
5889
|
-
}
|
|
5890
|
-
update(change) {
|
|
5891
|
-
const operation = this.queue.catch(() => {
|
|
5892
|
-
}).then(async () => {
|
|
5893
|
-
const state = await this.load();
|
|
5894
|
-
const result = await change(state);
|
|
5895
|
-
await mkdir9(path19.dirname(this.file), { recursive: true });
|
|
5896
|
-
const temporary = this.file + "." + randomUUID7();
|
|
5897
|
-
try {
|
|
5898
|
-
await writeFile9(temporary, JSON.stringify(state, null, 2) + "\n", { mode: 384, flag: "wx" });
|
|
5899
|
-
await rename3(temporary, this.file);
|
|
5900
|
-
} finally {
|
|
5901
|
-
await unlink3(temporary).catch((e) => {
|
|
5902
|
-
if (e.code !== "ENOENT") throw e;
|
|
5903
|
-
});
|
|
5904
|
-
}
|
|
5905
|
-
return result;
|
|
5906
|
-
});
|
|
5907
|
-
this.queue = operation;
|
|
5908
|
-
return operation;
|
|
5909
|
-
}
|
|
5910
|
-
};
|
|
5911
|
-
}
|
|
5912
|
-
});
|
|
5913
|
-
|
|
5914
6201
|
// src/utils/memory/memory_store.ts
|
|
5915
|
-
import { randomUUID as
|
|
6202
|
+
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
5916
6203
|
var MemoryStore;
|
|
5917
6204
|
var init_memory_store = __esm({
|
|
5918
6205
|
"src/utils/memory/memory_store.ts"() {
|
|
@@ -5943,7 +6230,7 @@ var init_memory_store = __esm({
|
|
|
5943
6230
|
const index = input.id ? state.entries.findIndex((e) => e.id === input.id) : -1;
|
|
5944
6231
|
if (input.id && index < 0) throw new Error(`Unknown memory entry: ${input.id}`);
|
|
5945
6232
|
const entry = {
|
|
5946
|
-
id: input.id ??
|
|
6233
|
+
id: input.id ?? randomUUID9(),
|
|
5947
6234
|
title: input.title,
|
|
5948
6235
|
content: input.content,
|
|
5949
6236
|
tags: input.tags ?? (index < 0 ? [] : state.entries[index].tags),
|
|
@@ -6050,7 +6337,7 @@ var init_skill_store = __esm({
|
|
|
6050
6337
|
import { execFile } from "node:child_process";
|
|
6051
6338
|
import { promisify } from "node:util";
|
|
6052
6339
|
import { mkdir as mkdir11 } from "node:fs/promises";
|
|
6053
|
-
import { randomUUID as
|
|
6340
|
+
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
6054
6341
|
import path21 from "node:path";
|
|
6055
6342
|
var execute, WorktreeManager;
|
|
6056
6343
|
var init_worktree_manager = __esm({
|
|
@@ -6068,7 +6355,7 @@ var init_worktree_manager = __esm({
|
|
|
6068
6355
|
}
|
|
6069
6356
|
async enter(name, signal) {
|
|
6070
6357
|
if (/[\\/]\.pi[\\/]worktrees[\\/]/u.test(this.cwd)) throw new Error("Nested managed worktrees are not supported");
|
|
6071
|
-
const slug = name ?? "task-" +
|
|
6358
|
+
const slug = name ?? "task-" + randomUUID10().slice(0, 8);
|
|
6072
6359
|
if (!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/u.test(slug))
|
|
6073
6360
|
throw new Error("Worktree name must be a slug of at most 64 characters");
|
|
6074
6361
|
const { stdout } = await execute("git", ["rev-parse", "--show-toplevel"], { cwd: this.cwd, signal });
|
|
@@ -6077,7 +6364,7 @@ var init_worktree_manager = __esm({
|
|
|
6077
6364
|
await mkdir11(path21.dirname(directory), { recursive: true });
|
|
6078
6365
|
const branch = "dragon/" + slug;
|
|
6079
6366
|
await execute("git", ["worktree", "add", "-b", branch, directory, "HEAD"], { cwd: root, signal });
|
|
6080
|
-
const worktree = { id:
|
|
6367
|
+
const worktree = { id: randomUUID10(), path: directory, branch, status: "active" };
|
|
6081
6368
|
await this.store.update((state) => {
|
|
6082
6369
|
state.worktrees.push(worktree);
|
|
6083
6370
|
});
|
|
@@ -6382,7 +6669,7 @@ var init_video_jobs = __esm({
|
|
|
6382
6669
|
});
|
|
6383
6670
|
|
|
6384
6671
|
// src/utils/scheduling/scheduler.ts
|
|
6385
|
-
import { randomUUID as
|
|
6672
|
+
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
6386
6673
|
import { Cron } from "croner";
|
|
6387
6674
|
var Scheduler;
|
|
6388
6675
|
var init_scheduler = __esm({
|
|
@@ -6462,7 +6749,7 @@ var init_scheduler = __esm({
|
|
|
6462
6749
|
if (Number(input.cron !== void 0) + Number(input.at !== void 0) !== 1)
|
|
6463
6750
|
throw new Error("Provide exactly one cron expression or future timestamp");
|
|
6464
6751
|
const job = {
|
|
6465
|
-
id:
|
|
6752
|
+
id: randomUUID11(),
|
|
6466
6753
|
prompt: input.prompt,
|
|
6467
6754
|
cron: input.cron,
|
|
6468
6755
|
at: input.at,
|
|
@@ -6739,7 +7026,7 @@ var init_lsp_manager = __esm({
|
|
|
6739
7026
|
});
|
|
6740
7027
|
|
|
6741
7028
|
// src/utils/tasks/task_store.ts
|
|
6742
|
-
import { randomUUID as
|
|
7029
|
+
import { randomUUID as randomUUID12 } from "node:crypto";
|
|
6743
7030
|
var TaskStore;
|
|
6744
7031
|
var init_task_store = __esm({
|
|
6745
7032
|
"src/utils/tasks/task_store.ts"() {
|
|
@@ -6776,7 +7063,7 @@ var init_task_store = __esm({
|
|
|
6776
7063
|
create(input) {
|
|
6777
7064
|
return this.store.update((state) => {
|
|
6778
7065
|
const task = {
|
|
6779
|
-
id:
|
|
7066
|
+
id: randomUUID12(),
|
|
6780
7067
|
subject: input.subject,
|
|
6781
7068
|
description: input.description,
|
|
6782
7069
|
metadata: input.metadata ?? {},
|
|
@@ -6836,7 +7123,7 @@ var init_task_store = __esm({
|
|
|
6836
7123
|
});
|
|
6837
7124
|
|
|
6838
7125
|
// src/utils/goals/goal_store.ts
|
|
6839
|
-
import { randomUUID as
|
|
7126
|
+
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
6840
7127
|
var GoalStore;
|
|
6841
7128
|
var init_goal_store = __esm({
|
|
6842
7129
|
"src/utils/goals/goal_store.ts"() {
|
|
@@ -6874,7 +7161,7 @@ var init_goal_store = __esm({
|
|
|
6874
7161
|
return this.store.update((state) => {
|
|
6875
7162
|
if (state.goal && ["active", "paused", "blocked"].includes(state.goal.status))
|
|
6876
7163
|
throw new Error("Finish the current goal before creating another");
|
|
6877
|
-
state.goal = { id:
|
|
7164
|
+
state.goal = { id: randomUUID13(), objective, status: "active", started: this.usage(), budget: {} };
|
|
6878
7165
|
return this.snapshot(state.goal);
|
|
6879
7166
|
});
|
|
6880
7167
|
}
|
|
@@ -6915,7 +7202,7 @@ var init_goal_store = __esm({
|
|
|
6915
7202
|
|
|
6916
7203
|
// src/utils/artifacts/artifact_store.ts
|
|
6917
7204
|
import { stat as stat3 } from "node:fs/promises";
|
|
6918
|
-
import { randomUUID as
|
|
7205
|
+
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
6919
7206
|
var ArtifactStore;
|
|
6920
7207
|
var init_artifact_store = __esm({
|
|
6921
7208
|
"src/utils/artifacts/artifact_store.ts"() {
|
|
@@ -6933,7 +7220,7 @@ var init_artifact_store = __esm({
|
|
|
6933
7220
|
if (Number(input.path !== void 0) + Number(input.url !== void 0) !== 1)
|
|
6934
7221
|
throw new Error("Provide exactly one file path or URL");
|
|
6935
7222
|
const artifact = {
|
|
6936
|
-
id:
|
|
7223
|
+
id: randomUUID14(),
|
|
6937
7224
|
title: input.title,
|
|
6938
7225
|
description: input.description,
|
|
6939
7226
|
mime_type: input.mime_type
|
|
@@ -7234,7 +7521,7 @@ var init_plugin_manager = __esm({
|
|
|
7234
7521
|
});
|
|
7235
7522
|
|
|
7236
7523
|
// src/utils/events/intent_store.ts
|
|
7237
|
-
import { randomUUID as
|
|
7524
|
+
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
7238
7525
|
var IntentStore;
|
|
7239
7526
|
var init_intent_store = __esm({
|
|
7240
7527
|
"src/utils/events/intent_store.ts"() {
|
|
@@ -7248,7 +7535,7 @@ var init_intent_store = __esm({
|
|
|
7248
7535
|
this.wake = wake;
|
|
7249
7536
|
}
|
|
7250
7537
|
async create(input) {
|
|
7251
|
-
const intent = { ...input, id:
|
|
7538
|
+
const intent = { ...input, id: randomUUID15(), max_fires: input.max_fires ?? 1, fired: 0, cancelled: false };
|
|
7252
7539
|
if (input.event_kind === "intent") throw new Error("Intents cannot trigger other intents");
|
|
7253
7540
|
await this.store.update((state) => {
|
|
7254
7541
|
state.intents.push(intent);
|
|
@@ -7298,7 +7585,7 @@ Trigger (${event.kind}, ${event.id}): ${event.content}`
|
|
|
7298
7585
|
|
|
7299
7586
|
// src/utils/network/portal_manager.ts
|
|
7300
7587
|
import { createServer, request as httpRequest } from "node:http";
|
|
7301
|
-
import { randomUUID as
|
|
7588
|
+
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
7302
7589
|
var PortalManager;
|
|
7303
7590
|
var init_portal_manager = __esm({
|
|
7304
7591
|
"src/utils/network/portal_manager.ts"() {
|
|
@@ -7386,7 +7673,7 @@ Connection: close\r
|
|
|
7386
7673
|
});
|
|
7387
7674
|
});
|
|
7388
7675
|
const portal = {
|
|
7389
|
-
id:
|
|
7676
|
+
id: randomUUID16(),
|
|
7390
7677
|
port,
|
|
7391
7678
|
title,
|
|
7392
7679
|
url: `http://127.0.0.1:${server2.address().port}/`,
|
|
@@ -7419,7 +7706,7 @@ Connection: close\r
|
|
|
7419
7706
|
});
|
|
7420
7707
|
|
|
7421
7708
|
// src/utils/media/transcript_store.ts
|
|
7422
|
-
import { randomUUID as
|
|
7709
|
+
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
7423
7710
|
var TranscriptStore;
|
|
7424
7711
|
var init_transcript_store = __esm({
|
|
7425
7712
|
"src/utils/media/transcript_store.ts"() {
|
|
@@ -7436,7 +7723,7 @@ var init_transcript_store = __esm({
|
|
|
7436
7723
|
}
|
|
7437
7724
|
async start(title, provider = "manual", meetingUrl) {
|
|
7438
7725
|
if (provider !== "manual" && !this.providers[provider]) throw new Error("Unknown transcript capture provider");
|
|
7439
|
-
const session = { id:
|
|
7726
|
+
const session = { id: randomUUID17(), title, status: "recording", provider, manual: [] };
|
|
7440
7727
|
if (provider !== "manual")
|
|
7441
7728
|
session.process_id = this.processes.start(this.providers[provider].command, void 0, void 0, {
|
|
7442
7729
|
TRANSCRIPT_MEETING_URL: meetingUrl ?? ""
|
|
@@ -7459,7 +7746,7 @@ var init_transcript_store = __esm({
|
|
|
7459
7746
|
let session = id ? state.sessions.find((s) => s.id === id) : void 0;
|
|
7460
7747
|
if (id && !session) throw new Error("Unknown transcript session");
|
|
7461
7748
|
if (!session) {
|
|
7462
|
-
session = { id:
|
|
7749
|
+
session = { id: randomUUID17(), title, status: "imported", provider: "manual", manual: [] };
|
|
7463
7750
|
state.sessions.push(session);
|
|
7464
7751
|
}
|
|
7465
7752
|
session.manual.push(text2);
|
|
@@ -7520,18 +7807,18 @@ var init_transcript_store = __esm({
|
|
|
7520
7807
|
});
|
|
7521
7808
|
|
|
7522
7809
|
// src/capabilities/tools/filesystem/read_many_files.ts
|
|
7523
|
-
import { defineTool as
|
|
7524
|
-
import { Type as
|
|
7810
|
+
import { defineTool as defineTool50 } from "@earendil-works/pi-coding-agent";
|
|
7811
|
+
import { Type as Type48 } from "typebox";
|
|
7525
7812
|
function createReadManyFilesTool(cwd) {
|
|
7526
7813
|
const read = createReadFileTool(cwd);
|
|
7527
|
-
return
|
|
7814
|
+
return defineTool50({
|
|
7528
7815
|
name: "read_many_files",
|
|
7529
7816
|
label: "Read Many Files",
|
|
7530
7817
|
description: "Read several explicit file paths with the same text, image and document reader. Results identify each file and preserve successful reads when another fails.",
|
|
7531
|
-
parameters:
|
|
7532
|
-
paths:
|
|
7533
|
-
offset:
|
|
7534
|
-
limit:
|
|
7818
|
+
parameters: Type48.Object({
|
|
7819
|
+
paths: Type48.Array(Type48.String({ minLength: 1 }), { minItems: 1, maxItems: 50 }),
|
|
7820
|
+
offset: Type48.Optional(Type48.Integer({ minimum: 1 })),
|
|
7821
|
+
limit: Type48.Optional(Type48.Integer({ minimum: 1 }))
|
|
7535
7822
|
}),
|
|
7536
7823
|
async execute(id, args, signal, update, ctx) {
|
|
7537
7824
|
const content = [];
|
|
@@ -7566,21 +7853,21 @@ var init_read_many_files = __esm({
|
|
|
7566
7853
|
});
|
|
7567
7854
|
|
|
7568
7855
|
// src/capabilities/tools/filesystem/multi_edit.ts
|
|
7569
|
-
import { defineTool as
|
|
7570
|
-
import { Type as
|
|
7856
|
+
import { defineTool as defineTool51 } from "@earendil-works/pi-coding-agent";
|
|
7857
|
+
import { Type as Type49 } from "typebox";
|
|
7571
7858
|
function createMultiEditTool(cwd) {
|
|
7572
|
-
return
|
|
7859
|
+
return defineTool51({
|
|
7573
7860
|
name: "multi_edit",
|
|
7574
7861
|
label: "Multi Edit",
|
|
7575
7862
|
description: "Atomically apply sequential literal replacements to ONE existing file. Each edit sees previous edits. Unique matches are required unless replace_all=true; any failure leaves the file unchanged.",
|
|
7576
7863
|
executionMode: "sequential",
|
|
7577
|
-
parameters:
|
|
7578
|
-
path:
|
|
7579
|
-
edits:
|
|
7580
|
-
|
|
7581
|
-
old_string:
|
|
7582
|
-
new_string:
|
|
7583
|
-
replace_all:
|
|
7864
|
+
parameters: Type49.Object({
|
|
7865
|
+
path: Type49.String(),
|
|
7866
|
+
edits: Type49.Array(
|
|
7867
|
+
Type49.Object({
|
|
7868
|
+
old_string: Type49.String({ minLength: 1 }),
|
|
7869
|
+
new_string: Type49.String(),
|
|
7870
|
+
replace_all: Type49.Optional(Type49.Boolean())
|
|
7584
7871
|
}),
|
|
7585
7872
|
{ minItems: 1 }
|
|
7586
7873
|
)
|
|
@@ -7616,27 +7903,27 @@ var init_multi_edit = __esm({
|
|
|
7616
7903
|
});
|
|
7617
7904
|
|
|
7618
7905
|
// src/capabilities/tools/code/lsp.ts
|
|
7619
|
-
import { defineTool as
|
|
7620
|
-
import { Type as
|
|
7906
|
+
import { defineTool as defineTool52 } from "@earendil-works/pi-coding-agent";
|
|
7907
|
+
import { Type as Type50 } from "typebox";
|
|
7621
7908
|
function createLspTool(manager) {
|
|
7622
|
-
return
|
|
7909
|
+
return defineTool52({
|
|
7623
7910
|
name: "lsp",
|
|
7624
7911
|
label: "LSP",
|
|
7625
7912
|
description: "Query a configured language server for definitions, references, hover information, document/workspace symbols or diagnostics. Positions use 1-based line and character. Files are synchronized from disk before queries; this tool never applies code edits.",
|
|
7626
|
-
parameters:
|
|
7627
|
-
operation:
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7913
|
+
parameters: Type50.Object({
|
|
7914
|
+
operation: Type50.Union([
|
|
7915
|
+
Type50.Literal("definition"),
|
|
7916
|
+
Type50.Literal("references"),
|
|
7917
|
+
Type50.Literal("hover"),
|
|
7918
|
+
Type50.Literal("document_symbols"),
|
|
7919
|
+
Type50.Literal("workspace_symbols"),
|
|
7920
|
+
Type50.Literal("diagnostics")
|
|
7634
7921
|
]),
|
|
7635
|
-
file_path:
|
|
7636
|
-
line:
|
|
7637
|
-
character:
|
|
7638
|
-
query:
|
|
7639
|
-
server:
|
|
7922
|
+
file_path: Type50.String(),
|
|
7923
|
+
line: Type50.Optional(Type50.Integer({ minimum: 1 })),
|
|
7924
|
+
character: Type50.Optional(Type50.Integer({ minimum: 1 })),
|
|
7925
|
+
query: Type50.Optional(Type50.String()),
|
|
7926
|
+
server: Type50.Optional(Type50.String())
|
|
7640
7927
|
}),
|
|
7641
7928
|
async execute(_id, args, signal) {
|
|
7642
7929
|
return jsonToolResult(await manager.query(args, signal));
|
|
@@ -7651,18 +7938,18 @@ var init_lsp = __esm({
|
|
|
7651
7938
|
});
|
|
7652
7939
|
|
|
7653
7940
|
// src/capabilities/tools/scheduling/cron_create.ts
|
|
7654
|
-
import { defineTool as
|
|
7655
|
-
import { Type as
|
|
7941
|
+
import { defineTool as defineTool53 } from "@earendil-works/pi-coding-agent";
|
|
7942
|
+
import { Type as Type51 } from "typebox";
|
|
7656
7943
|
function createCronCreateTool(scheduler) {
|
|
7657
|
-
return
|
|
7944
|
+
return defineTool53({
|
|
7658
7945
|
name: "cron_create",
|
|
7659
7946
|
label: "Create Cron",
|
|
7660
7947
|
description: "Schedule a prompt on a cron expression during this runtime lifetime. Supports five-field cron and an optional leading seconds field. timezone defaults to UTC; recurring=false runs only the next occurrence. Scheduled model work uses the same host permissions and budget.",
|
|
7661
|
-
parameters:
|
|
7662
|
-
cron:
|
|
7663
|
-
prompt:
|
|
7664
|
-
timezone:
|
|
7665
|
-
recurring:
|
|
7948
|
+
parameters: Type51.Object({
|
|
7949
|
+
cron: Type51.String({ minLength: 1 }),
|
|
7950
|
+
prompt: Type51.String({ minLength: 1 }),
|
|
7951
|
+
timezone: Type51.Optional(Type51.String()),
|
|
7952
|
+
recurring: Type51.Optional(Type51.Boolean())
|
|
7666
7953
|
}),
|
|
7667
7954
|
async execute(_id, args) {
|
|
7668
7955
|
return jsonToolResult(await scheduler.create(args));
|
|
@@ -7677,14 +7964,14 @@ var init_cron_create = __esm({
|
|
|
7677
7964
|
});
|
|
7678
7965
|
|
|
7679
7966
|
// src/capabilities/tools/scheduling/cron_delete.ts
|
|
7680
|
-
import { defineTool as
|
|
7681
|
-
import { Type as
|
|
7967
|
+
import { defineTool as defineTool54 } from "@earendil-works/pi-coding-agent";
|
|
7968
|
+
import { Type as Type52 } from "typebox";
|
|
7682
7969
|
function createCronDeleteTool(scheduler) {
|
|
7683
|
-
return
|
|
7970
|
+
return defineTool54({
|
|
7684
7971
|
name: "cron_delete",
|
|
7685
7972
|
label: "Delete Cron",
|
|
7686
7973
|
description: "Cancel a scheduled cron job or wakeup owned by this runtime.",
|
|
7687
|
-
parameters:
|
|
7974
|
+
parameters: Type52.Object({ id: Type52.String() }),
|
|
7688
7975
|
async execute(_id, args) {
|
|
7689
7976
|
return jsonToolResult(await scheduler.delete(args.id));
|
|
7690
7977
|
}
|
|
@@ -7698,14 +7985,14 @@ var init_cron_delete = __esm({
|
|
|
7698
7985
|
});
|
|
7699
7986
|
|
|
7700
7987
|
// src/capabilities/tools/scheduling/cron_list.ts
|
|
7701
|
-
import { defineTool as
|
|
7702
|
-
import { Type as
|
|
7988
|
+
import { defineTool as defineTool55 } from "@earendil-works/pi-coding-agent";
|
|
7989
|
+
import { Type as Type53 } from "typebox";
|
|
7703
7990
|
function createCronListTool(scheduler) {
|
|
7704
|
-
return
|
|
7991
|
+
return defineTool55({
|
|
7705
7992
|
name: "cron_list",
|
|
7706
7993
|
label: "List Cron",
|
|
7707
7994
|
description: "List runtime-owned schedules, next occurrences, execution status and last delivery errors.",
|
|
7708
|
-
parameters:
|
|
7995
|
+
parameters: Type53.Object({}),
|
|
7709
7996
|
async execute() {
|
|
7710
7997
|
return jsonToolResult(await scheduler.list());
|
|
7711
7998
|
}
|
|
@@ -7719,17 +8006,17 @@ var init_cron_list = __esm({
|
|
|
7719
8006
|
});
|
|
7720
8007
|
|
|
7721
8008
|
// src/capabilities/tools/scheduling/schedule_wakeup.ts
|
|
7722
|
-
import { defineTool as
|
|
7723
|
-
import { Type as
|
|
8009
|
+
import { defineTool as defineTool56 } from "@earendil-works/pi-coding-agent";
|
|
8010
|
+
import { Type as Type54 } from "typebox";
|
|
7724
8011
|
function createScheduleWakeupTool(scheduler) {
|
|
7725
|
-
return
|
|
8012
|
+
return defineTool56({
|
|
7726
8013
|
name: "schedule_wakeup",
|
|
7727
8014
|
label: "Schedule Wakeup",
|
|
7728
8015
|
description: "Schedule a one-time model wakeup in this runtime. Provide exactly one of delay_ms or at (ISO timestamp), up to 24 hours ahead. Returns immediately; the wakeup is cancelled when the runtime ends.",
|
|
7729
|
-
parameters:
|
|
7730
|
-
prompt:
|
|
7731
|
-
delay_ms:
|
|
7732
|
-
at:
|
|
8016
|
+
parameters: Type54.Object({
|
|
8017
|
+
prompt: Type54.String({ minLength: 1 }),
|
|
8018
|
+
delay_ms: Type54.Optional(Type54.Integer({ minimum: 1, maximum: 864e5 })),
|
|
8019
|
+
at: Type54.Optional(Type54.String())
|
|
7733
8020
|
}),
|
|
7734
8021
|
async execute(_id, args) {
|
|
7735
8022
|
if (Number(args.delay_ms !== void 0) + Number(args.at !== void 0) !== 1)
|
|
@@ -7752,18 +8039,18 @@ var init_schedule_wakeup = __esm({
|
|
|
7752
8039
|
|
|
7753
8040
|
// src/capabilities/tools/scheduling/monitor.ts
|
|
7754
8041
|
import { StringDecoder } from "node:string_decoder";
|
|
7755
|
-
import { defineTool as
|
|
7756
|
-
import { Type as
|
|
8042
|
+
import { defineTool as defineTool57 } from "@earendil-works/pi-coding-agent";
|
|
8043
|
+
import { Type as Type55 } from "typebox";
|
|
7757
8044
|
function createMonitorTool(processes, tasks, wake) {
|
|
7758
|
-
return
|
|
8045
|
+
return defineTool57({
|
|
7759
8046
|
name: "monitor",
|
|
7760
8047
|
label: "Monitor",
|
|
7761
8048
|
description: "Run a shell command in the background and deliver complete output lines as runtime notifications. Notifications are batched at a bounded rate; complete raw output stays available through process/task output. Returns task_id and process_id; task_stop cancels the monitor.",
|
|
7762
|
-
parameters:
|
|
7763
|
-
command:
|
|
7764
|
-
description:
|
|
7765
|
-
interval_ms:
|
|
7766
|
-
timeout:
|
|
8049
|
+
parameters: Type55.Object({
|
|
8050
|
+
command: Type55.String({ minLength: 1 }),
|
|
8051
|
+
description: Type55.Optional(Type55.String()),
|
|
8052
|
+
interval_ms: Type55.Optional(Type55.Integer({ minimum: 100, maximum: 3e4 })),
|
|
8053
|
+
timeout: Type55.Optional(Type55.Number({ exclusiveMinimum: 0 }))
|
|
7767
8054
|
}),
|
|
7768
8055
|
async execute(_id, args, signal) {
|
|
7769
8056
|
signal?.throwIfAborted();
|
|
@@ -7845,27 +8132,27 @@ var init_monitor = __esm({
|
|
|
7845
8132
|
});
|
|
7846
8133
|
|
|
7847
8134
|
// src/capabilities/tools/scheduling/heartbeat_respond.ts
|
|
7848
|
-
import { defineTool as
|
|
7849
|
-
import { Type as
|
|
8135
|
+
import { defineTool as defineTool58 } from "@earendil-works/pi-coding-agent";
|
|
8136
|
+
import { Type as Type56 } from "typebox";
|
|
7850
8137
|
function createHeartbeatRespondTool(file, turn, wake) {
|
|
7851
8138
|
const store = new JsonStore(file, { responses: {} });
|
|
7852
|
-
return
|
|
8139
|
+
return defineTool58({
|
|
7853
8140
|
name: "heartbeat_respond",
|
|
7854
8141
|
label: "Heartbeat Response",
|
|
7855
8142
|
description: "Record one heartbeat outcome for the current turn. notify=true requires notification_text. Scratch is stored as private monitor context and excluded from tool output.",
|
|
7856
|
-
parameters:
|
|
7857
|
-
outcome:
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
8143
|
+
parameters: Type56.Object({
|
|
8144
|
+
outcome: Type56.Union([
|
|
8145
|
+
Type56.Literal("no_change"),
|
|
8146
|
+
Type56.Literal("progress"),
|
|
8147
|
+
Type56.Literal("done"),
|
|
8148
|
+
Type56.Literal("blocked"),
|
|
8149
|
+
Type56.Literal("needs_attention")
|
|
7863
8150
|
]),
|
|
7864
|
-
notify:
|
|
7865
|
-
summary:
|
|
7866
|
-
notification_text:
|
|
7867
|
-
scratch:
|
|
7868
|
-
next_check:
|
|
8151
|
+
notify: Type56.Boolean(),
|
|
8152
|
+
summary: Type56.String({ minLength: 1 }),
|
|
8153
|
+
notification_text: Type56.Optional(Type56.String()),
|
|
8154
|
+
scratch: Type56.Optional(Type56.String()),
|
|
8155
|
+
next_check: Type56.Optional(Type56.String())
|
|
7869
8156
|
}),
|
|
7870
8157
|
async execute(_id, args) {
|
|
7871
8158
|
if (args.notify && !args.notification_text?.trim()) throw new Error("notify=true requires notification_text");
|
|
@@ -7889,14 +8176,14 @@ var init_heartbeat_respond = __esm({
|
|
|
7889
8176
|
});
|
|
7890
8177
|
|
|
7891
8178
|
// src/capabilities/tools/skills/skills_list.ts
|
|
7892
|
-
import { defineTool as
|
|
7893
|
-
import { Type as
|
|
8179
|
+
import { defineTool as defineTool59 } from "@earendil-works/pi-coding-agent";
|
|
8180
|
+
import { Type as Type57 } from "typebox";
|
|
7894
8181
|
function createSkillsListTool(store) {
|
|
7895
|
-
return
|
|
8182
|
+
return defineTool59({
|
|
7896
8183
|
name: "skills_list",
|
|
7897
8184
|
label: "List Skills",
|
|
7898
8185
|
description: "Discover skills and their descriptions using Pi's skill loader without loading all skill instructions.",
|
|
7899
|
-
parameters:
|
|
8186
|
+
parameters: Type57.Object({}),
|
|
7900
8187
|
async execute() {
|
|
7901
8188
|
return jsonToolResult(store.list());
|
|
7902
8189
|
}
|
|
@@ -7910,27 +8197,27 @@ var init_skills_list = __esm({
|
|
|
7910
8197
|
});
|
|
7911
8198
|
|
|
7912
8199
|
// src/capabilities/tools/skills/skill_manage.ts
|
|
7913
|
-
import { defineTool as
|
|
7914
|
-
import { Type as
|
|
8200
|
+
import { defineTool as defineTool60 } from "@earendil-works/pi-coding-agent";
|
|
8201
|
+
import { Type as Type58 } from "typebox";
|
|
7915
8202
|
function createSkillManageTool(store) {
|
|
7916
|
-
return
|
|
8203
|
+
return defineTool60({
|
|
7917
8204
|
name: "skill_manage",
|
|
7918
8205
|
label: "Manage Skill",
|
|
7919
8206
|
executionMode: "sequential",
|
|
7920
8207
|
description: "Create, patch or delete a run-owned skill, or write/remove its supporting files. Source skill snapshots are read-only. create requires complete SKILL.md frontmatter; patch requires one unique old_string.",
|
|
7921
|
-
parameters:
|
|
7922
|
-
action:
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
8208
|
+
parameters: Type58.Object({
|
|
8209
|
+
action: Type58.Union([
|
|
8210
|
+
Type58.Literal("create"),
|
|
8211
|
+
Type58.Literal("patch"),
|
|
8212
|
+
Type58.Literal("write_file"),
|
|
8213
|
+
Type58.Literal("remove_file"),
|
|
8214
|
+
Type58.Literal("delete")
|
|
7928
8215
|
]),
|
|
7929
|
-
name:
|
|
7930
|
-
path:
|
|
7931
|
-
content:
|
|
7932
|
-
old_string:
|
|
7933
|
-
new_string:
|
|
8216
|
+
name: Type58.String({ minLength: 1 }),
|
|
8217
|
+
path: Type58.Optional(Type58.String()),
|
|
8218
|
+
content: Type58.Optional(Type58.String()),
|
|
8219
|
+
old_string: Type58.Optional(Type58.String()),
|
|
8220
|
+
new_string: Type58.Optional(Type58.String())
|
|
7934
8221
|
}),
|
|
7935
8222
|
async execute(_id, args) {
|
|
7936
8223
|
return jsonToolResult(await store.manage(args));
|
|
@@ -7945,18 +8232,18 @@ var init_skill_manage = __esm({
|
|
|
7945
8232
|
});
|
|
7946
8233
|
|
|
7947
8234
|
// src/capabilities/tools/media/video_gen.ts
|
|
7948
|
-
import { defineTool as
|
|
7949
|
-
import { Type as
|
|
8235
|
+
import { defineTool as defineTool61 } from "@earendil-works/pi-coding-agent";
|
|
8236
|
+
import { Type as Type59 } from "typebox";
|
|
7950
8237
|
function createVideoGenTool(jobs) {
|
|
7951
|
-
return
|
|
8238
|
+
return defineTool61({
|
|
7952
8239
|
name: "video_gen",
|
|
7953
8240
|
label: "Generate Video",
|
|
7954
8241
|
description: "Submit an asynchronous text-to-video generation job using the configured Wan model. Returns task_id; use video_gen_retrieve to poll its state and obtain or save the completed video.",
|
|
7955
|
-
parameters:
|
|
7956
|
-
prompt:
|
|
7957
|
-
size:
|
|
7958
|
-
duration:
|
|
7959
|
-
seed:
|
|
8242
|
+
parameters: Type59.Object({
|
|
8243
|
+
prompt: Type59.String({ minLength: 1 }),
|
|
8244
|
+
size: Type59.Optional(Type59.String()),
|
|
8245
|
+
duration: Type59.Optional(Type59.Integer({ minimum: 1, maximum: 15 })),
|
|
8246
|
+
seed: Type59.Optional(Type59.Integer({ minimum: 0, maximum: 2147483647 }))
|
|
7960
8247
|
}),
|
|
7961
8248
|
async execute(_id, args, signal) {
|
|
7962
8249
|
return jsonToolResult(await jobs.submit(args, signal));
|
|
@@ -7971,14 +8258,14 @@ var init_video_gen = __esm({
|
|
|
7971
8258
|
});
|
|
7972
8259
|
|
|
7973
8260
|
// src/capabilities/tools/media/video_gen_retrieve.ts
|
|
7974
|
-
import { defineTool as
|
|
7975
|
-
import { Type as
|
|
8261
|
+
import { defineTool as defineTool62 } from "@earendil-works/pi-coding-agent";
|
|
8262
|
+
import { Type as Type60 } from "typebox";
|
|
7976
8263
|
function createVideoGenRetrieveTool(jobs) {
|
|
7977
|
-
return
|
|
8264
|
+
return defineTool62({
|
|
7978
8265
|
name: "video_gen_retrieve",
|
|
7979
8266
|
label: "Retrieve Video",
|
|
7980
8267
|
description: "Check a video task created by this run. Pending jobs stay pending; completed jobs return a video URL and can be downloaded to file_path. Provider failure is returned as an error.",
|
|
7981
|
-
parameters:
|
|
8268
|
+
parameters: Type60.Object({ task_id: Type60.String(), file_path: Type60.Optional(Type60.String()) }),
|
|
7982
8269
|
async execute(_id, args, signal) {
|
|
7983
8270
|
const result = await jobs.retrieve(args.task_id, args.file_path, signal);
|
|
7984
8271
|
return { ...jsonToolResult(result), isError: !!result.error };
|
|
@@ -7993,26 +8280,26 @@ var init_video_gen_retrieve = __esm({
|
|
|
7993
8280
|
});
|
|
7994
8281
|
|
|
7995
8282
|
// src/capabilities/tools/media/transcripts.ts
|
|
7996
|
-
import { defineTool as
|
|
7997
|
-
import { Type as
|
|
8283
|
+
import { defineTool as defineTool63 } from "@earendil-works/pi-coding-agent";
|
|
8284
|
+
import { Type as Type61 } from "typebox";
|
|
7998
8285
|
function createTranscriptsTool(store, summarize) {
|
|
7999
|
-
return
|
|
8286
|
+
return defineTool63({
|
|
8000
8287
|
name: "transcripts",
|
|
8001
8288
|
label: "Transcripts",
|
|
8002
8289
|
description: "Manage transcript sessions: start a manual session or configured live-capture provider, import text chunks, inspect status, stop capture or summarize. Capture providers write transcript text on stdout and receive TRANSCRIPT_MEETING_URL from the host. Summarization uses the host-selected model and shared accounting.",
|
|
8003
|
-
parameters:
|
|
8004
|
-
action:
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8290
|
+
parameters: Type61.Object({
|
|
8291
|
+
action: Type61.Union([
|
|
8292
|
+
Type61.Literal("start"),
|
|
8293
|
+
Type61.Literal("stop"),
|
|
8294
|
+
Type61.Literal("status"),
|
|
8295
|
+
Type61.Literal("import"),
|
|
8296
|
+
Type61.Literal("summarize")
|
|
8010
8297
|
]),
|
|
8011
|
-
session_id:
|
|
8012
|
-
title:
|
|
8013
|
-
provider:
|
|
8014
|
-
meeting_url:
|
|
8015
|
-
transcript:
|
|
8298
|
+
session_id: Type61.Optional(Type61.String()),
|
|
8299
|
+
title: Type61.Optional(Type61.String()),
|
|
8300
|
+
provider: Type61.Optional(Type61.String()),
|
|
8301
|
+
meeting_url: Type61.Optional(Type61.String()),
|
|
8302
|
+
transcript: Type61.Optional(Type61.String())
|
|
8016
8303
|
}),
|
|
8017
8304
|
async execute(_id, args, signal, _update, ctx) {
|
|
8018
8305
|
if (args.action === "start")
|
|
@@ -8043,16 +8330,16 @@ var init_transcripts = __esm({
|
|
|
8043
8330
|
// src/capabilities/tools/media/zoom_image.ts
|
|
8044
8331
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
8045
8332
|
import { PhotonImage as PhotonImage2, crop, resize, SamplingFilter } from "@silvia-odwyer/photon-node";
|
|
8046
|
-
import { defineTool as
|
|
8047
|
-
import { Type as
|
|
8333
|
+
import { defineTool as defineTool64 } from "@earendil-works/pi-coding-agent";
|
|
8334
|
+
import { Type as Type62 } from "typebox";
|
|
8048
8335
|
function createZoomImageTool(cwd) {
|
|
8049
|
-
const coordinate =
|
|
8050
|
-
return
|
|
8336
|
+
const coordinate = Type62.Number({ minimum: 0, maximum: 1e3 });
|
|
8337
|
+
return defineTool64({
|
|
8051
8338
|
name: "zoom_image",
|
|
8052
8339
|
label: "Zoom Image",
|
|
8053
8340
|
description: "Read a high-resolution region from an image using normalized 0\u20131000 coordinates. Returns an enlarged PNG view for inspection and leaves the source file unchanged.",
|
|
8054
|
-
parameters:
|
|
8055
|
-
file_path:
|
|
8341
|
+
parameters: Type62.Object({
|
|
8342
|
+
file_path: Type62.String(),
|
|
8056
8343
|
x1: coordinate,
|
|
8057
8344
|
y1: coordinate,
|
|
8058
8345
|
x2: coordinate,
|
|
@@ -8106,14 +8393,14 @@ var init_zoom_image = __esm({
|
|
|
8106
8393
|
});
|
|
8107
8394
|
|
|
8108
8395
|
// src/capabilities/tools/goals/create_goal.ts
|
|
8109
|
-
import { defineTool as
|
|
8110
|
-
import { Type as
|
|
8396
|
+
import { defineTool as defineTool65 } from "@earendil-works/pi-coding-agent";
|
|
8397
|
+
import { Type as Type63 } from "typebox";
|
|
8111
8398
|
function createCreateGoalTool(store) {
|
|
8112
|
-
return
|
|
8399
|
+
return defineTool65({
|
|
8113
8400
|
name: "create_goal",
|
|
8114
8401
|
label: "Create Goal",
|
|
8115
8402
|
description: "Create a persistent objective when no unfinished goal exists. Records usage from the shared host budget.",
|
|
8116
|
-
parameters:
|
|
8403
|
+
parameters: Type63.Object({ objective: Type63.String({ minLength: 1 }) }),
|
|
8117
8404
|
async execute(_id, args, signal) {
|
|
8118
8405
|
return jsonToolResult(await store.create(args.objective));
|
|
8119
8406
|
}
|
|
@@ -8127,14 +8414,14 @@ var init_create_goal = __esm({
|
|
|
8127
8414
|
});
|
|
8128
8415
|
|
|
8129
8416
|
// src/capabilities/tools/goals/get_goal.ts
|
|
8130
|
-
import { defineTool as
|
|
8131
|
-
import { Type as
|
|
8417
|
+
import { defineTool as defineTool66 } from "@earendil-works/pi-coding-agent";
|
|
8418
|
+
import { Type as Type64 } from "typebox";
|
|
8132
8419
|
function createGetGoalTool(store) {
|
|
8133
|
-
return
|
|
8420
|
+
return defineTool66({
|
|
8134
8421
|
name: "get_goal",
|
|
8135
8422
|
label: "Get Goal",
|
|
8136
8423
|
description: "Read the active goal, status, limits and current token, turn and elapsed-time usage.",
|
|
8137
|
-
parameters:
|
|
8424
|
+
parameters: Type64.Object({}),
|
|
8138
8425
|
async execute(_id, args, signal) {
|
|
8139
8426
|
return jsonToolResult(await store.get());
|
|
8140
8427
|
}
|
|
@@ -8148,20 +8435,20 @@ var init_get_goal = __esm({
|
|
|
8148
8435
|
});
|
|
8149
8436
|
|
|
8150
8437
|
// src/capabilities/tools/goals/update_goal.ts
|
|
8151
|
-
import { defineTool as
|
|
8152
|
-
import { Type as
|
|
8438
|
+
import { defineTool as defineTool67 } from "@earendil-works/pi-coding-agent";
|
|
8439
|
+
import { Type as Type65 } from "typebox";
|
|
8153
8440
|
function createUpdateGoalTool(store) {
|
|
8154
|
-
return
|
|
8441
|
+
return defineTool67({
|
|
8155
8442
|
name: "update_goal",
|
|
8156
8443
|
label: "Update Goal",
|
|
8157
8444
|
description: "Update the current goal status by its exact id. Mark complete only when the objective is achieved.",
|
|
8158
|
-
parameters:
|
|
8159
|
-
goal_id:
|
|
8160
|
-
status:
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8445
|
+
parameters: Type65.Object({
|
|
8446
|
+
goal_id: Type65.String(),
|
|
8447
|
+
status: Type65.Union([
|
|
8448
|
+
Type65.Literal("active"),
|
|
8449
|
+
Type65.Literal("paused"),
|
|
8450
|
+
Type65.Literal("blocked"),
|
|
8451
|
+
Type65.Literal("complete")
|
|
8165
8452
|
])
|
|
8166
8453
|
}),
|
|
8167
8454
|
async execute(_id, args, signal) {
|
|
@@ -8177,23 +8464,23 @@ var init_update_goal = __esm({
|
|
|
8177
8464
|
});
|
|
8178
8465
|
|
|
8179
8466
|
// src/capabilities/tools/goals/set_goal_budget.ts
|
|
8180
|
-
import { defineTool as
|
|
8181
|
-
import { Type as
|
|
8467
|
+
import { defineTool as defineTool68 } from "@earendil-works/pi-coding-agent";
|
|
8468
|
+
import { Type as Type66 } from "typebox";
|
|
8182
8469
|
function createSetGoalBudgetTool(store) {
|
|
8183
|
-
return
|
|
8470
|
+
return defineTool68({
|
|
8184
8471
|
name: "set_goal_budget",
|
|
8185
8472
|
label: "Set Goal Budget",
|
|
8186
8473
|
description: "Set a token, turn or elapsed-time limit on the current goal. An already-reached limit is reported immediately and enforced by the host; it cannot enlarge the host budget.",
|
|
8187
|
-
parameters:
|
|
8188
|
-
goal_id:
|
|
8189
|
-
value:
|
|
8190
|
-
unit:
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8474
|
+
parameters: Type66.Object({
|
|
8475
|
+
goal_id: Type66.String(),
|
|
8476
|
+
value: Type66.Number({ exclusiveMinimum: 0 }),
|
|
8477
|
+
unit: Type66.Union([
|
|
8478
|
+
Type66.Literal("tokens"),
|
|
8479
|
+
Type66.Literal("turns"),
|
|
8480
|
+
Type66.Literal("milliseconds"),
|
|
8481
|
+
Type66.Literal("seconds"),
|
|
8482
|
+
Type66.Literal("minutes"),
|
|
8483
|
+
Type66.Literal("hours")
|
|
8197
8484
|
])
|
|
8198
8485
|
}),
|
|
8199
8486
|
async execute(_id, args, signal) {
|
|
@@ -8209,17 +8496,17 @@ var init_set_goal_budget = __esm({
|
|
|
8209
8496
|
});
|
|
8210
8497
|
|
|
8211
8498
|
// src/capabilities/tools/tasks/task_create.ts
|
|
8212
|
-
import { defineTool as
|
|
8213
|
-
import { Type as
|
|
8499
|
+
import { defineTool as defineTool69 } from "@earendil-works/pi-coding-agent";
|
|
8500
|
+
import { Type as Type67 } from "typebox";
|
|
8214
8501
|
function createTaskCreateTool(store) {
|
|
8215
|
-
return
|
|
8502
|
+
return defineTool69({
|
|
8216
8503
|
name: "task_create",
|
|
8217
8504
|
label: "Task Create",
|
|
8218
8505
|
description: "Create a structured task record with subject and description. Recording a task does not start an executor or spawn a subagent.",
|
|
8219
|
-
parameters:
|
|
8220
|
-
subject:
|
|
8221
|
-
description:
|
|
8222
|
-
metadata:
|
|
8506
|
+
parameters: Type67.Object({
|
|
8507
|
+
subject: Type67.String({ minLength: 1 }),
|
|
8508
|
+
description: Type67.String({ minLength: 1 }),
|
|
8509
|
+
metadata: Type67.Optional(Type67.Record(Type67.String(), Type67.Unknown()))
|
|
8223
8510
|
}),
|
|
8224
8511
|
async execute(_id, args, signal) {
|
|
8225
8512
|
return jsonToolResult(await store.create(args));
|
|
@@ -8234,14 +8521,14 @@ var init_task_create = __esm({
|
|
|
8234
8521
|
});
|
|
8235
8522
|
|
|
8236
8523
|
// src/capabilities/tools/tasks/task_get.ts
|
|
8237
|
-
import { defineTool as
|
|
8238
|
-
import { Type as
|
|
8524
|
+
import { defineTool as defineTool70 } from "@earendil-works/pi-coding-agent";
|
|
8525
|
+
import { Type as Type68 } from "typebox";
|
|
8239
8526
|
function createTaskGetTool(store) {
|
|
8240
|
-
return
|
|
8527
|
+
return defineTool70({
|
|
8241
8528
|
name: "task_get",
|
|
8242
8529
|
label: "Task Get",
|
|
8243
8530
|
description: "Read one task record, including status, owner, dependencies and metadata.",
|
|
8244
|
-
parameters:
|
|
8531
|
+
parameters: Type68.Object({ task_id: Type68.String() }),
|
|
8245
8532
|
async execute(_id, args, signal) {
|
|
8246
8533
|
return jsonToolResult(await store.get(args.task_id));
|
|
8247
8534
|
}
|
|
@@ -8255,14 +8542,14 @@ var init_task_get = __esm({
|
|
|
8255
8542
|
});
|
|
8256
8543
|
|
|
8257
8544
|
// src/capabilities/tools/tasks/task_list.ts
|
|
8258
|
-
import { defineTool as
|
|
8259
|
-
import { Type as
|
|
8545
|
+
import { defineTool as defineTool71 } from "@earendil-works/pi-coding-agent";
|
|
8546
|
+
import { Type as Type69 } from "typebox";
|
|
8260
8547
|
function createTaskListTool(store) {
|
|
8261
|
-
return
|
|
8548
|
+
return defineTool71({
|
|
8262
8549
|
name: "task_list",
|
|
8263
8550
|
label: "Task List",
|
|
8264
8551
|
description: "List all task records owned by this runtime.",
|
|
8265
|
-
parameters:
|
|
8552
|
+
parameters: Type69.Object({}),
|
|
8266
8553
|
async execute(_id, args, signal) {
|
|
8267
8554
|
return jsonToolResult(await store.list());
|
|
8268
8555
|
}
|
|
@@ -8276,28 +8563,28 @@ var init_task_list = __esm({
|
|
|
8276
8563
|
});
|
|
8277
8564
|
|
|
8278
8565
|
// src/capabilities/tools/tasks/task_update.ts
|
|
8279
|
-
import { defineTool as
|
|
8280
|
-
import { Type as
|
|
8566
|
+
import { defineTool as defineTool72 } from "@earendil-works/pi-coding-agent";
|
|
8567
|
+
import { Type as Type70 } from "typebox";
|
|
8281
8568
|
function createTaskUpdateTool(store) {
|
|
8282
|
-
return
|
|
8569
|
+
return defineTool72({
|
|
8283
8570
|
name: "task_update",
|
|
8284
8571
|
label: "Task Update",
|
|
8285
8572
|
description: "Update a task record. Dependencies must exist and remain acyclic; starting a task requires completed dependencies.",
|
|
8286
|
-
parameters:
|
|
8287
|
-
task_id:
|
|
8288
|
-
subject:
|
|
8289
|
-
description:
|
|
8290
|
-
owner:
|
|
8291
|
-
status:
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8573
|
+
parameters: Type70.Object({
|
|
8574
|
+
task_id: Type70.String(),
|
|
8575
|
+
subject: Type70.Optional(Type70.String()),
|
|
8576
|
+
description: Type70.Optional(Type70.String()),
|
|
8577
|
+
owner: Type70.Optional(Type70.String()),
|
|
8578
|
+
status: Type70.Optional(
|
|
8579
|
+
Type70.Union([
|
|
8580
|
+
Type70.Literal("pending"),
|
|
8581
|
+
Type70.Literal("in_progress"),
|
|
8582
|
+
Type70.Literal("completed"),
|
|
8583
|
+
Type70.Literal("cancelled")
|
|
8297
8584
|
])
|
|
8298
8585
|
),
|
|
8299
|
-
blocked_by:
|
|
8300
|
-
metadata:
|
|
8586
|
+
blocked_by: Type70.Optional(Type70.Array(Type70.String())),
|
|
8587
|
+
metadata: Type70.Optional(Type70.Record(Type70.String(), Type70.Unknown()))
|
|
8301
8588
|
}),
|
|
8302
8589
|
async execute(_id, args, signal) {
|
|
8303
8590
|
return jsonToolResult(await store.update(args.task_id, args));
|
|
@@ -8312,14 +8599,14 @@ var init_task_update = __esm({
|
|
|
8312
8599
|
});
|
|
8313
8600
|
|
|
8314
8601
|
// src/capabilities/tools/tasks/task_stop.ts
|
|
8315
|
-
import { defineTool as
|
|
8316
|
-
import { Type as
|
|
8602
|
+
import { defineTool as defineTool73 } from "@earendil-works/pi-coding-agent";
|
|
8603
|
+
import { Type as Type71 } from "typebox";
|
|
8317
8604
|
function createTaskStopTool(store) {
|
|
8318
|
-
return
|
|
8605
|
+
return defineTool73({
|
|
8319
8606
|
name: "task_stop",
|
|
8320
8607
|
label: "Task Stop",
|
|
8321
8608
|
description: "Stop an attached background executor and mark its task cancelled, or cancel a pending task record. Uses only host-authorized handles.",
|
|
8322
|
-
parameters:
|
|
8609
|
+
parameters: Type71.Object({ task_id: Type71.String() }),
|
|
8323
8610
|
async execute(_id, args, signal) {
|
|
8324
8611
|
return jsonToolResult(await store.stop(args.task_id));
|
|
8325
8612
|
}
|
|
@@ -8333,14 +8620,14 @@ var init_task_stop = __esm({
|
|
|
8333
8620
|
});
|
|
8334
8621
|
|
|
8335
8622
|
// src/capabilities/tools/tasks/task_output.ts
|
|
8336
|
-
import { defineTool as
|
|
8337
|
-
import { Type as
|
|
8623
|
+
import { defineTool as defineTool74 } from "@earendil-works/pi-coding-agent";
|
|
8624
|
+
import { Type as Type72 } from "typebox";
|
|
8338
8625
|
function createTaskOutputTool(store) {
|
|
8339
|
-
return
|
|
8626
|
+
return defineTool74({
|
|
8340
8627
|
name: "task_output",
|
|
8341
8628
|
label: "Task Output",
|
|
8342
8629
|
description: "Read the output of a background task handle or the final output saved on a task record.",
|
|
8343
|
-
parameters:
|
|
8630
|
+
parameters: Type72.Object({ task_id: Type72.String() }),
|
|
8344
8631
|
async execute(_id, args, signal) {
|
|
8345
8632
|
return jsonToolResult(await store.output(args.task_id, signal));
|
|
8346
8633
|
}
|
|
@@ -8354,14 +8641,14 @@ var init_task_output = __esm({
|
|
|
8354
8641
|
});
|
|
8355
8642
|
|
|
8356
8643
|
// src/capabilities/tools/mcp/mcp_list.ts
|
|
8357
|
-
import { defineTool as
|
|
8358
|
-
import { Type as
|
|
8644
|
+
import { defineTool as defineTool75 } from "@earendil-works/pi-coding-agent";
|
|
8645
|
+
import { Type as Type73 } from "typebox";
|
|
8359
8646
|
function createMcpListTool(pool) {
|
|
8360
|
-
return
|
|
8647
|
+
return defineTool75({
|
|
8361
8648
|
name: "mcp_list",
|
|
8362
8649
|
label: "List MCP Tools",
|
|
8363
8650
|
description: "Discover tools offered by configured MCP servers; returns names and descriptions. Use mcp_get for a full input schema.",
|
|
8364
|
-
parameters:
|
|
8651
|
+
parameters: Type73.Object({ server: Type73.Optional(Type73.String()), query: Type73.Optional(Type73.String()) }),
|
|
8365
8652
|
async execute(_id, args, signal) {
|
|
8366
8653
|
const tools = (await Promise.all(
|
|
8367
8654
|
pool.names(args.server).map(
|
|
@@ -8388,14 +8675,14 @@ var init_mcp_list = __esm({
|
|
|
8388
8675
|
});
|
|
8389
8676
|
|
|
8390
8677
|
// src/capabilities/tools/mcp/mcp_get.ts
|
|
8391
|
-
import { defineTool as
|
|
8392
|
-
import { Type as
|
|
8678
|
+
import { defineTool as defineTool76 } from "@earendil-works/pi-coding-agent";
|
|
8679
|
+
import { Type as Type74 } from "typebox";
|
|
8393
8680
|
function createMcpGetTool(pool) {
|
|
8394
|
-
return
|
|
8681
|
+
return defineTool76({
|
|
8395
8682
|
name: "mcp_get",
|
|
8396
8683
|
label: "Describe MCP Tool",
|
|
8397
8684
|
description: "Fetch the full description and input schema of a named tool from its configured MCP server.",
|
|
8398
|
-
parameters:
|
|
8685
|
+
parameters: Type74.Object({ server: Type74.String(), tool: Type74.String() }),
|
|
8399
8686
|
async execute(_id, args, signal) {
|
|
8400
8687
|
const tool = (await (await pool.get(args.server, signal)).listTools({ signal })).find(
|
|
8401
8688
|
(t) => t.name === args.tool
|
|
@@ -8413,20 +8700,20 @@ var init_mcp_get = __esm({
|
|
|
8413
8700
|
});
|
|
8414
8701
|
|
|
8415
8702
|
// src/capabilities/tools/mcp/mcp_call.ts
|
|
8416
|
-
import { defineTool as
|
|
8703
|
+
import { defineTool as defineTool77 } from "@earendil-works/pi-coding-agent";
|
|
8417
8704
|
import { toLlmContent as toLlmContent3 } from "@earendil-works/pi-mcp";
|
|
8418
8705
|
import { Ajv } from "ajv";
|
|
8419
|
-
import { Type as
|
|
8706
|
+
import { Type as Type75 } from "typebox";
|
|
8420
8707
|
function createMcpCallTool(pool) {
|
|
8421
8708
|
const ajv = new Ajv({ strict: false, allErrors: true });
|
|
8422
|
-
return
|
|
8709
|
+
return defineTool77({
|
|
8423
8710
|
name: "mcp_call",
|
|
8424
8711
|
label: "Call MCP Tool",
|
|
8425
8712
|
description: "Call a configured MCP tool after validating its arguments against the server's schema. Preserves structured results, image content and MCP isError status. This is a task-tool operation and obeys the host workflow and budget.",
|
|
8426
|
-
parameters:
|
|
8427
|
-
server:
|
|
8428
|
-
tool:
|
|
8429
|
-
arguments:
|
|
8713
|
+
parameters: Type75.Object({
|
|
8714
|
+
server: Type75.String(),
|
|
8715
|
+
tool: Type75.String(),
|
|
8716
|
+
arguments: Type75.Record(Type75.String(), Type75.Unknown())
|
|
8430
8717
|
}),
|
|
8431
8718
|
async execute(_id, args, signal) {
|
|
8432
8719
|
const client = await pool.get(args.server, signal);
|
|
@@ -8446,14 +8733,14 @@ var init_mcp_call = __esm({
|
|
|
8446
8733
|
});
|
|
8447
8734
|
|
|
8448
8735
|
// src/capabilities/tools/mcp/list_mcp_resource_templates.ts
|
|
8449
|
-
import { defineTool as
|
|
8450
|
-
import { Type as
|
|
8736
|
+
import { defineTool as defineTool78 } from "@earendil-works/pi-coding-agent";
|
|
8737
|
+
import { Type as Type76 } from "typebox";
|
|
8451
8738
|
function createListMcpResourceTemplatesTool(pool) {
|
|
8452
|
-
return
|
|
8739
|
+
return defineTool78({
|
|
8453
8740
|
name: "list_mcp_resource_templates",
|
|
8454
8741
|
label: "List MCP Resource Templates",
|
|
8455
8742
|
description: "List paginated URI templates offered by configured MCP servers.",
|
|
8456
|
-
parameters:
|
|
8743
|
+
parameters: Type76.Object({ server: Type76.Optional(Type76.String()) }),
|
|
8457
8744
|
async execute(_id, args, signal) {
|
|
8458
8745
|
return jsonToolResult(
|
|
8459
8746
|
await Promise.all(
|
|
@@ -8474,14 +8761,14 @@ var init_list_mcp_resource_templates = __esm({
|
|
|
8474
8761
|
});
|
|
8475
8762
|
|
|
8476
8763
|
// src/capabilities/tools/sessions/sessions_list.ts
|
|
8477
|
-
import { defineTool as
|
|
8478
|
-
import { Type as
|
|
8764
|
+
import { defineTool as defineTool79 } from "@earendil-works/pi-coding-agent";
|
|
8765
|
+
import { Type as Type77 } from "typebox";
|
|
8479
8766
|
function createSessionsListTool(catalog) {
|
|
8480
|
-
return
|
|
8767
|
+
return defineTool79({
|
|
8481
8768
|
name: "sessions_list",
|
|
8482
8769
|
label: "List Sessions",
|
|
8483
8770
|
description: "List Pi sessions from the explicitly authorized archive directory, with names, timestamps and message counts. Current-task history remains under the selected context policy.",
|
|
8484
|
-
parameters:
|
|
8771
|
+
parameters: Type77.Object({ include_archived: Type77.Optional(Type77.Boolean()) }),
|
|
8485
8772
|
async execute(_id, args, signal) {
|
|
8486
8773
|
return jsonToolResult(await catalog.list(args.include_archived, signal));
|
|
8487
8774
|
}
|
|
@@ -8495,17 +8782,17 @@ var init_sessions_list = __esm({
|
|
|
8495
8782
|
});
|
|
8496
8783
|
|
|
8497
8784
|
// src/capabilities/tools/sessions/sessions_history.ts
|
|
8498
|
-
import { defineTool as
|
|
8499
|
-
import { Type as
|
|
8785
|
+
import { defineTool as defineTool80 } from "@earendil-works/pi-coding-agent";
|
|
8786
|
+
import { Type as Type78 } from "typebox";
|
|
8500
8787
|
function createSessionsHistoryTool(catalog) {
|
|
8501
|
-
return
|
|
8788
|
+
return defineTool80({
|
|
8502
8789
|
name: "sessions_history",
|
|
8503
8790
|
label: "Session History",
|
|
8504
8791
|
description: "Read a bounded range of model-visible messages from an authorized archived session, using Pi context projection. offset is a zero-based message index. Cannot bypass the current task context policy.",
|
|
8505
|
-
parameters:
|
|
8506
|
-
session_id:
|
|
8507
|
-
offset:
|
|
8508
|
-
limit:
|
|
8792
|
+
parameters: Type78.Object({
|
|
8793
|
+
session_id: Type78.String(),
|
|
8794
|
+
offset: Type78.Optional(Type78.Integer({ minimum: 0 })),
|
|
8795
|
+
limit: Type78.Optional(Type78.Integer({ minimum: 1, maximum: 200 }))
|
|
8509
8796
|
}),
|
|
8510
8797
|
async execute(_id, args, signal) {
|
|
8511
8798
|
return jsonToolResult(await catalog.history(args.session_id, args.offset, args.limit, signal));
|
|
@@ -8520,16 +8807,16 @@ var init_sessions_history = __esm({
|
|
|
8520
8807
|
});
|
|
8521
8808
|
|
|
8522
8809
|
// src/capabilities/tools/sessions/sessions_search.ts
|
|
8523
|
-
import { defineTool as
|
|
8524
|
-
import { Type as
|
|
8810
|
+
import { defineTool as defineTool81 } from "@earendil-works/pi-coding-agent";
|
|
8811
|
+
import { Type as Type79 } from "typebox";
|
|
8525
8812
|
function createSessionsSearchTool(catalog) {
|
|
8526
|
-
return
|
|
8813
|
+
return defineTool81({
|
|
8527
8814
|
name: "sessions_search",
|
|
8528
8815
|
label: "Search Sessions",
|
|
8529
8816
|
description: "Search model-visible text in the authorized archived sessions and return session/message references with bounded snippets.",
|
|
8530
|
-
parameters:
|
|
8531
|
-
query:
|
|
8532
|
-
limit:
|
|
8817
|
+
parameters: Type79.Object({
|
|
8818
|
+
query: Type79.String({ minLength: 1 }),
|
|
8819
|
+
limit: Type79.Optional(Type79.Integer({ minimum: 1, maximum: 100 }))
|
|
8533
8820
|
}),
|
|
8534
8821
|
async execute(_id, args, signal) {
|
|
8535
8822
|
return jsonToolResult(await catalog.search(args.query, args.limit, signal));
|
|
@@ -8544,14 +8831,14 @@ var init_sessions_search = __esm({
|
|
|
8544
8831
|
});
|
|
8545
8832
|
|
|
8546
8833
|
// src/capabilities/tools/sessions/session_status.ts
|
|
8547
|
-
import { defineTool as
|
|
8548
|
-
import { Type as
|
|
8834
|
+
import { defineTool as defineTool82 } from "@earendil-works/pi-coding-agent";
|
|
8835
|
+
import { Type as Type80 } from "typebox";
|
|
8549
8836
|
function createSessionStatusTool(catalog) {
|
|
8550
|
-
return
|
|
8837
|
+
return defineTool82({
|
|
8551
8838
|
name: "session_status",
|
|
8552
8839
|
label: "Session Status",
|
|
8553
8840
|
description: "Read host-provided current-session status or metadata of a specified authorized archived session. Does not change the model or context strategy.",
|
|
8554
|
-
parameters:
|
|
8841
|
+
parameters: Type80.Object({ session_id: Type80.Optional(Type80.String()) }),
|
|
8555
8842
|
async execute(_id, args, signal) {
|
|
8556
8843
|
return jsonToolResult(await catalog.status(args.session_id, signal));
|
|
8557
8844
|
}
|
|
@@ -8565,18 +8852,18 @@ var init_session_status = __esm({
|
|
|
8565
8852
|
});
|
|
8566
8853
|
|
|
8567
8854
|
// src/capabilities/tools/sessions/sessions.ts
|
|
8568
|
-
import { defineTool as
|
|
8569
|
-
import { Type as
|
|
8855
|
+
import { defineTool as defineTool83 } from "@earendil-works/pi-coding-agent";
|
|
8856
|
+
import { Type as Type81 } from "typebox";
|
|
8570
8857
|
function createSessionsTool(catalog) {
|
|
8571
|
-
return
|
|
8858
|
+
return defineTool83({
|
|
8572
8859
|
name: "sessions",
|
|
8573
8860
|
label: "Manage Sessions",
|
|
8574
8861
|
description: "Update title, pinned or archived metadata for an authorized archived session. Source session files are preserved. Model selection and current-task context are fixed by the host.",
|
|
8575
|
-
parameters:
|
|
8576
|
-
session_id:
|
|
8577
|
-
title:
|
|
8578
|
-
pinned:
|
|
8579
|
-
archived:
|
|
8862
|
+
parameters: Type81.Object({
|
|
8863
|
+
session_id: Type81.String(),
|
|
8864
|
+
title: Type81.Optional(Type81.String()),
|
|
8865
|
+
pinned: Type81.Optional(Type81.Boolean()),
|
|
8866
|
+
archived: Type81.Optional(Type81.Boolean())
|
|
8580
8867
|
}),
|
|
8581
8868
|
async execute(_id, args) {
|
|
8582
8869
|
return jsonToolResult(await catalog.update(args.session_id, args));
|
|
@@ -8591,21 +8878,21 @@ var init_sessions = __esm({
|
|
|
8591
8878
|
});
|
|
8592
8879
|
|
|
8593
8880
|
// src/capabilities/tools/communication/message.ts
|
|
8594
|
-
import { defineTool as
|
|
8595
|
-
import { Type as
|
|
8881
|
+
import { defineTool as defineTool84 } from "@earendil-works/pi-coding-agent";
|
|
8882
|
+
import { Type as Type82 } from "typebox";
|
|
8596
8883
|
function createMessageTool(gateway) {
|
|
8597
|
-
return
|
|
8884
|
+
return defineTool84({
|
|
8598
8885
|
name: "message",
|
|
8599
8886
|
label: "External Message",
|
|
8600
8887
|
description: "Send or broadcast a message through a configured external OpenClaw channel such as Slack or Telegram. This is external delivery, separate from W3 subagent communication. The gateway applies its channel authorization policy.",
|
|
8601
|
-
parameters:
|
|
8602
|
-
action:
|
|
8603
|
-
channel:
|
|
8604
|
-
target:
|
|
8605
|
-
targets:
|
|
8606
|
-
message:
|
|
8607
|
-
media:
|
|
8608
|
-
account_id:
|
|
8888
|
+
parameters: Type82.Object({
|
|
8889
|
+
action: Type82.Union([Type82.Literal("send"), Type82.Literal("broadcast")]),
|
|
8890
|
+
channel: Type82.String({ minLength: 1 }),
|
|
8891
|
+
target: Type82.Optional(Type82.String()),
|
|
8892
|
+
targets: Type82.Optional(Type82.Array(Type82.String(), { minItems: 1 })),
|
|
8893
|
+
message: Type82.String({ minLength: 1 }),
|
|
8894
|
+
media: Type82.Optional(Type82.String()),
|
|
8895
|
+
account_id: Type82.Optional(Type82.String())
|
|
8609
8896
|
}),
|
|
8610
8897
|
async execute(_id, args, signal) {
|
|
8611
8898
|
if (args.action === "send" && !args.target) throw new Error("send requires target");
|
|
@@ -8622,17 +8909,17 @@ var init_message = __esm({
|
|
|
8622
8909
|
});
|
|
8623
8910
|
|
|
8624
8911
|
// src/capabilities/tools/communication/conversations_list.ts
|
|
8625
|
-
import { defineTool as
|
|
8626
|
-
import { Type as
|
|
8912
|
+
import { defineTool as defineTool85 } from "@earendil-works/pi-coding-agent";
|
|
8913
|
+
import { Type as Type83 } from "typebox";
|
|
8627
8914
|
function createConversationsListTool(gateway) {
|
|
8628
|
-
return
|
|
8915
|
+
return defineTool85({
|
|
8629
8916
|
name: "conversations_list",
|
|
8630
8917
|
label: "List External Conversations",
|
|
8631
8918
|
description: "List authorized external channel conversations via OpenClaw. Returned conversationRef values identify exact delivery destinations, independently of local Pi sessions.",
|
|
8632
|
-
parameters:
|
|
8633
|
-
channel:
|
|
8634
|
-
query:
|
|
8635
|
-
limit:
|
|
8919
|
+
parameters: Type83.Object({
|
|
8920
|
+
channel: Type83.Optional(Type83.String()),
|
|
8921
|
+
query: Type83.Optional(Type83.String()),
|
|
8922
|
+
limit: Type83.Optional(Type83.Integer({ minimum: 1, maximum: 100 }))
|
|
8636
8923
|
}),
|
|
8637
8924
|
async execute(_id, args, signal) {
|
|
8638
8925
|
return gateway.invoke("conversations_list", args, signal);
|
|
@@ -8646,17 +8933,17 @@ var init_conversations_list = __esm({
|
|
|
8646
8933
|
});
|
|
8647
8934
|
|
|
8648
8935
|
// src/capabilities/tools/communication/conversations_turn.ts
|
|
8649
|
-
import { defineTool as
|
|
8650
|
-
import { Type as
|
|
8936
|
+
import { defineTool as defineTool86 } from "@earendil-works/pi-coding-agent";
|
|
8937
|
+
import { Type as Type84 } from "typebox";
|
|
8651
8938
|
function createConversationsTurnTool(gateway) {
|
|
8652
|
-
return
|
|
8939
|
+
return defineTool86({
|
|
8653
8940
|
name: "conversations_turn",
|
|
8654
8941
|
label: "External Conversation Turn",
|
|
8655
8942
|
description: "Send a message to a conversationRef obtained from conversations_list and wait for its correlated inbound reply. Uses the configured external channel adapter; does not invoke another model session.",
|
|
8656
|
-
parameters:
|
|
8657
|
-
conversation_ref:
|
|
8658
|
-
message:
|
|
8659
|
-
timeout_seconds:
|
|
8943
|
+
parameters: Type84.Object({
|
|
8944
|
+
conversation_ref: Type84.String({ pattern: "^conv_[a-f0-9]{32}$" }),
|
|
8945
|
+
message: Type84.String({ minLength: 1 }),
|
|
8946
|
+
timeout_seconds: Type84.Optional(Type84.Integer({ minimum: 1, maximum: 300 }))
|
|
8660
8947
|
}),
|
|
8661
8948
|
async execute(_id, args, signal) {
|
|
8662
8949
|
return gateway.invoke(
|
|
@@ -8687,19 +8974,19 @@ var init_ask_user_question = __esm({
|
|
|
8687
8974
|
});
|
|
8688
8975
|
|
|
8689
8976
|
// src/capabilities/tools/artifacts/record_artifact.ts
|
|
8690
|
-
import { defineTool as
|
|
8691
|
-
import { Type as
|
|
8977
|
+
import { defineTool as defineTool87 } from "@earendil-works/pi-coding-agent";
|
|
8978
|
+
import { Type as Type85 } from "typebox";
|
|
8692
8979
|
function createRecordArtifactTool(store) {
|
|
8693
|
-
return
|
|
8980
|
+
return defineTool87({
|
|
8694
8981
|
name: "record_artifact",
|
|
8695
8982
|
label: "Record Artifact",
|
|
8696
8983
|
description: "Register an existing workspace file or an HTTP(S) URL as a deliverable. Provide exactly one of path or url. Verifies files exist and are regular files before recording; repeated registration updates the same artifact.",
|
|
8697
|
-
parameters:
|
|
8698
|
-
title:
|
|
8699
|
-
description:
|
|
8700
|
-
path:
|
|
8701
|
-
url:
|
|
8702
|
-
mime_type:
|
|
8984
|
+
parameters: Type85.Object({
|
|
8985
|
+
title: Type85.String({ minLength: 1 }),
|
|
8986
|
+
description: Type85.Optional(Type85.String()),
|
|
8987
|
+
path: Type85.Optional(Type85.String()),
|
|
8988
|
+
url: Type85.Optional(Type85.String()),
|
|
8989
|
+
mime_type: Type85.Optional(Type85.String())
|
|
8703
8990
|
}),
|
|
8704
8991
|
async execute(_id, args) {
|
|
8705
8992
|
return jsonToolResult(await store.record(args));
|
|
@@ -8714,16 +9001,16 @@ var init_record_artifact = __esm({
|
|
|
8714
9001
|
});
|
|
8715
9002
|
|
|
8716
9003
|
// src/capabilities/tools/artifacts/report_findings.ts
|
|
8717
|
-
import { defineTool as
|
|
8718
|
-
import { Type as
|
|
9004
|
+
import { defineTool as defineTool88 } from "@earendil-works/pi-coding-agent";
|
|
9005
|
+
import { Type as Type86 } from "typebox";
|
|
8719
9006
|
function createReportFindingsTool(file) {
|
|
8720
9007
|
const store = new JsonStore(file, { findings: [] });
|
|
8721
|
-
return
|
|
9008
|
+
return defineTool88({
|
|
8722
9009
|
name: "report_findings",
|
|
8723
9010
|
label: "Report Findings",
|
|
8724
9011
|
executionMode: "sequential",
|
|
8725
9012
|
description: "Submit a complete structured review report; replaces the previous report. Findings need unique stable ids. A later outcomes report must cover exactly the previous ids and supply an outcome on every finding.",
|
|
8726
|
-
parameters:
|
|
9013
|
+
parameters: Type86.Object({ findings: Type86.Array(findingSchema) }),
|
|
8727
9014
|
async execute(_id, args) {
|
|
8728
9015
|
return jsonToolResult(
|
|
8729
9016
|
await store.update((state) => {
|
|
@@ -8748,43 +9035,43 @@ var init_report_findings = __esm({
|
|
|
8748
9035
|
"use strict";
|
|
8749
9036
|
init_json_store();
|
|
8750
9037
|
init_workspace();
|
|
8751
|
-
findingSchema =
|
|
8752
|
-
id:
|
|
8753
|
-
severity:
|
|
8754
|
-
file:
|
|
8755
|
-
line:
|
|
8756
|
-
summary:
|
|
8757
|
-
failure_scenario:
|
|
8758
|
-
confidence:
|
|
8759
|
-
outcome:
|
|
8760
|
-
|
|
9038
|
+
findingSchema = Type86.Object({
|
|
9039
|
+
id: Type86.String({ minLength: 1 }),
|
|
9040
|
+
severity: Type86.Union([Type86.Literal("Critical"), Type86.Literal("Suggestion"), Type86.Literal("Nice to have")]),
|
|
9041
|
+
file: Type86.String(),
|
|
9042
|
+
line: Type86.Optional(Type86.Integer({ minimum: 1 })),
|
|
9043
|
+
summary: Type86.String({ minLength: 1 }),
|
|
9044
|
+
failure_scenario: Type86.String({ minLength: 1 }),
|
|
9045
|
+
confidence: Type86.Optional(Type86.Union([Type86.Literal("high"), Type86.Literal("low")])),
|
|
9046
|
+
outcome: Type86.Optional(
|
|
9047
|
+
Type86.Union([Type86.Literal("fixed"), Type86.Literal("skipped"), Type86.Literal("no_change_needed")])
|
|
8761
9048
|
),
|
|
8762
|
-
outcome_note:
|
|
9049
|
+
outcome_note: Type86.Optional(Type86.String())
|
|
8763
9050
|
});
|
|
8764
9051
|
}
|
|
8765
9052
|
});
|
|
8766
9053
|
|
|
8767
9054
|
// src/capabilities/tools/extensions/plugins.ts
|
|
8768
|
-
import { defineTool as
|
|
8769
|
-
import { Type as
|
|
9055
|
+
import { defineTool as defineTool89 } from "@earendil-works/pi-coding-agent";
|
|
9056
|
+
import { Type as Type87 } from "typebox";
|
|
8770
9057
|
function createPluginsTool(manager) {
|
|
8771
|
-
return
|
|
9058
|
+
return defineTool89({
|
|
8772
9059
|
name: "plugins",
|
|
8773
9060
|
label: "Manage Plugins",
|
|
8774
9061
|
description: "Manage run-owned Pi packages using Pi package management: list, inspect, search npm, install, uninstall, enable, disable or reload the package resource catalog. Install with a version-pinned npm source, git revision, or local package path. Changes target this run configuration; the active model and selected harness strategy remain fixed.",
|
|
8775
|
-
parameters:
|
|
8776
|
-
action:
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
9062
|
+
parameters: Type87.Object({
|
|
9063
|
+
action: Type87.Union([
|
|
9064
|
+
Type87.Literal("list"),
|
|
9065
|
+
Type87.Literal("inspect"),
|
|
9066
|
+
Type87.Literal("search"),
|
|
9067
|
+
Type87.Literal("install"),
|
|
9068
|
+
Type87.Literal("uninstall"),
|
|
9069
|
+
Type87.Literal("enable"),
|
|
9070
|
+
Type87.Literal("disable"),
|
|
9071
|
+
Type87.Literal("reload")
|
|
8785
9072
|
]),
|
|
8786
|
-
source:
|
|
8787
|
-
query:
|
|
9073
|
+
source: Type87.Optional(Type87.String()),
|
|
9074
|
+
query: Type87.Optional(Type87.String())
|
|
8788
9075
|
}),
|
|
8789
9076
|
async execute(_id, args, signal) {
|
|
8790
9077
|
if (args.action === "list") return jsonToolResult(await manager.list());
|
|
@@ -8809,23 +9096,23 @@ var init_plugins = __esm({
|
|
|
8809
9096
|
});
|
|
8810
9097
|
|
|
8811
9098
|
// src/capabilities/tools/extensions/manage_connections.ts
|
|
8812
|
-
import { defineTool as
|
|
8813
|
-
import { Type as
|
|
9099
|
+
import { defineTool as defineTool90 } from "@earendil-works/pi-coding-agent";
|
|
9100
|
+
import { Type as Type88 } from "typebox";
|
|
8814
9101
|
function createManageConnectionsTool(manager) {
|
|
8815
|
-
return
|
|
9102
|
+
return defineTool90({
|
|
8816
9103
|
name: "manage_connections",
|
|
8817
9104
|
label: "Manage Connections",
|
|
8818
9105
|
description: "List, add, remove or connect run-owned MCP services. Supports Pi stdio and Streamable HTTP transports. Configuration is persisted for resuming this run; listed metadata omits environment values and authorization headers. MCP tools discovered through a connection are tracked separately from the fixed task-tool catalog.",
|
|
8819
|
-
parameters:
|
|
8820
|
-
action:
|
|
8821
|
-
name:
|
|
8822
|
-
transport:
|
|
8823
|
-
command:
|
|
8824
|
-
args:
|
|
8825
|
-
cwd:
|
|
8826
|
-
env:
|
|
8827
|
-
url:
|
|
8828
|
-
headers:
|
|
9106
|
+
parameters: Type88.Object({
|
|
9107
|
+
action: Type88.Union([Type88.Literal("list"), Type88.Literal("add"), Type88.Literal("remove"), Type88.Literal("connect")]),
|
|
9108
|
+
name: Type88.Optional(Type88.String()),
|
|
9109
|
+
transport: Type88.Optional(Type88.Union([Type88.Literal("stdio"), Type88.Literal("http")])),
|
|
9110
|
+
command: Type88.Optional(Type88.String()),
|
|
9111
|
+
args: Type88.Optional(Type88.Array(Type88.String())),
|
|
9112
|
+
cwd: Type88.Optional(Type88.String()),
|
|
9113
|
+
env: Type88.Optional(Type88.Record(Type88.String(), Type88.String())),
|
|
9114
|
+
url: Type88.Optional(Type88.String()),
|
|
9115
|
+
headers: Type88.Optional(Type88.Record(Type88.String(), Type88.String()))
|
|
8829
9116
|
}),
|
|
8830
9117
|
async execute(_id, args, signal) {
|
|
8831
9118
|
if (args.action === "list") return jsonToolResult(manager.list());
|
|
@@ -8861,20 +9148,20 @@ var init_manage_connections = __esm({
|
|
|
8861
9148
|
});
|
|
8862
9149
|
|
|
8863
9150
|
// src/capabilities/tools/extensions/intent.ts
|
|
8864
|
-
import { defineTool as
|
|
8865
|
-
import { Type as
|
|
9151
|
+
import { defineTool as defineTool91 } from "@earendil-works/pi-coding-agent";
|
|
9152
|
+
import { Type as Type89 } from "typebox";
|
|
8866
9153
|
function createIntentTool(store) {
|
|
8867
|
-
return
|
|
9154
|
+
return defineTool91({
|
|
8868
9155
|
name: "intent",
|
|
8869
9156
|
label: "Event Intent",
|
|
8870
9157
|
description: "Create, list or cancel an event-triggered follow-up prompt in this runtime. Match a host event kind (or *) and optional literal contains text. Fires once by default; all triggered model work uses the current host model, context policy and budget.",
|
|
8871
|
-
parameters:
|
|
8872
|
-
action:
|
|
8873
|
-
id:
|
|
8874
|
-
event_kind:
|
|
8875
|
-
contains:
|
|
8876
|
-
prompt:
|
|
8877
|
-
max_fires:
|
|
9158
|
+
parameters: Type89.Object({
|
|
9159
|
+
action: Type89.Union([Type89.Literal("create"), Type89.Literal("list"), Type89.Literal("cancel")]),
|
|
9160
|
+
id: Type89.Optional(Type89.String()),
|
|
9161
|
+
event_kind: Type89.Optional(Type89.String()),
|
|
9162
|
+
contains: Type89.Optional(Type89.String()),
|
|
9163
|
+
prompt: Type89.Optional(Type89.String()),
|
|
9164
|
+
max_fires: Type89.Optional(Type89.Integer({ minimum: 1, maximum: 100 }))
|
|
8878
9165
|
}),
|
|
8879
9166
|
async execute(_id, args) {
|
|
8880
9167
|
if (args.action === "list") return jsonToolResult(await store.list());
|
|
@@ -8948,17 +9235,17 @@ var init_prompt_secret = __esm({
|
|
|
8948
9235
|
});
|
|
8949
9236
|
|
|
8950
9237
|
// src/capabilities/tools/extensions/secrets.ts
|
|
8951
|
-
import { defineTool as
|
|
8952
|
-
import { Type as
|
|
9238
|
+
import { defineTool as defineTool92 } from "@earendil-works/pi-coding-agent";
|
|
9239
|
+
import { Type as Type90 } from "typebox";
|
|
8953
9240
|
function createSecretsTool(vault) {
|
|
8954
|
-
return
|
|
9241
|
+
return defineTool92({
|
|
8955
9242
|
name: "secrets",
|
|
8956
9243
|
label: "Secrets",
|
|
8957
9244
|
description: "List credential metadata, request a credential through protected masked human input, or delete a credential. Returns secret:// references rather than values. The host can resolve these references for service authorization; there is no plaintext read operation.",
|
|
8958
|
-
parameters:
|
|
8959
|
-
action:
|
|
8960
|
-
name:
|
|
8961
|
-
reason:
|
|
9245
|
+
parameters: Type90.Object({
|
|
9246
|
+
action: Type90.Union([Type90.Literal("list"), Type90.Literal("request"), Type90.Literal("delete")]),
|
|
9247
|
+
name: Type90.Optional(Type90.String()),
|
|
9248
|
+
reason: Type90.Optional(Type90.String())
|
|
8962
9249
|
}),
|
|
8963
9250
|
async execute(_id, args, signal, _update, ctx) {
|
|
8964
9251
|
if (args.action === "list") return jsonToolResult(await vault.list());
|
|
@@ -8980,18 +9267,18 @@ var init_secrets = __esm({
|
|
|
8980
9267
|
});
|
|
8981
9268
|
|
|
8982
9269
|
// src/capabilities/tools/extensions/portal.ts
|
|
8983
|
-
import { defineTool as
|
|
8984
|
-
import { Type as
|
|
9270
|
+
import { defineTool as defineTool93 } from "@earendil-works/pi-coding-agent";
|
|
9271
|
+
import { Type as Type91 } from "typebox";
|
|
8985
9272
|
function createPortalTool(manager) {
|
|
8986
|
-
return
|
|
9273
|
+
return defineTool93({
|
|
8987
9274
|
name: "portal",
|
|
8988
9275
|
label: "Portal",
|
|
8989
9276
|
description: "Open, list or close a local HTTP/WebSocket forwarding address. Open a port first to get its URL, then start the service; requests show a retry page until it listens. Addresses bind to loopback and end with this runtime. Does not automate a browser.",
|
|
8990
|
-
parameters:
|
|
8991
|
-
action:
|
|
8992
|
-
port:
|
|
8993
|
-
title:
|
|
8994
|
-
id:
|
|
9277
|
+
parameters: Type91.Object({
|
|
9278
|
+
action: Type91.Union([Type91.Literal("open"), Type91.Literal("list"), Type91.Literal("close")]),
|
|
9279
|
+
port: Type91.Optional(Type91.Integer({ minimum: 1, maximum: 65535 })),
|
|
9280
|
+
title: Type91.Optional(Type91.String()),
|
|
9281
|
+
id: Type91.Optional(Type91.String())
|
|
8995
9282
|
}),
|
|
8996
9283
|
async execute(_id, args) {
|
|
8997
9284
|
if (args.action === "list") return jsonToolResult(manager.list());
|
|
@@ -9012,17 +9299,17 @@ var init_portal = __esm({
|
|
|
9012
9299
|
});
|
|
9013
9300
|
|
|
9014
9301
|
// src/capabilities/tools/orchestration/workflow.ts
|
|
9015
|
-
import { defineTool as
|
|
9016
|
-
import { Type as
|
|
9302
|
+
import { defineTool as defineTool94 } from "@earendil-works/pi-coding-agent";
|
|
9303
|
+
import { Type as Type92 } from "typebox";
|
|
9017
9304
|
function createWorkflowTool(tasks, resolveTools, wake) {
|
|
9018
|
-
return
|
|
9305
|
+
return defineTool94({
|
|
9019
9306
|
name: "workflow",
|
|
9020
9307
|
label: "Workflow",
|
|
9021
9308
|
description: "Start a background JavaScript workflow over the host-authorized tool bindings. Await tool calls and emit results with text() or image(). Returns task_id immediately; task_output reads progress and task_stop cancels execution. Subagents are available only when W3 permits them; no recursive workflow entry is provided.",
|
|
9022
|
-
parameters:
|
|
9023
|
-
name:
|
|
9024
|
-
code:
|
|
9025
|
-
timeout_ms:
|
|
9309
|
+
parameters: Type92.Object({
|
|
9310
|
+
name: Type92.String({ minLength: 1 }),
|
|
9311
|
+
code: Type92.String({ minLength: 1 }),
|
|
9312
|
+
timeout_ms: Type92.Optional(Type92.Integer({ minimum: 1, maximum: 6e5 }))
|
|
9026
9313
|
}),
|
|
9027
9314
|
async execute(id, args, signal, _update, ctx) {
|
|
9028
9315
|
signal?.throwIfAborted();
|
|
@@ -9302,7 +9589,7 @@ import {
|
|
|
9302
9589
|
SessionManager as SessionManager2,
|
|
9303
9590
|
SettingsManager as SettingsManager6
|
|
9304
9591
|
} from "@earendil-works/pi-coding-agent";
|
|
9305
|
-
async function runScalingChild(task, parent, signal, config, limits, budget, parentSettings, nativeCompactionSettings, toolServices, assertParentBudget, parentSecrets) {
|
|
9592
|
+
async function runScalingChild(task, parent, signal, config, limits, budget, parentSettings, nativeCompactionSettings, toolServices, assertParentBudget, parentSecrets, channel) {
|
|
9306
9593
|
if (!parent.model) throw new Error("Subagent requires the parent's selected model");
|
|
9307
9594
|
signal?.throwIfAborted();
|
|
9308
9595
|
const runtime = createScalingRuntime(config, {
|
|
@@ -9380,7 +9667,23 @@ async function runScalingChild(task, parent, signal, config, limits, budget, par
|
|
|
9380
9667
|
try {
|
|
9381
9668
|
await session.bindExtensions({});
|
|
9382
9669
|
signal?.throwIfAborted();
|
|
9383
|
-
|
|
9670
|
+
let accepting = true;
|
|
9671
|
+
channel?.bind({
|
|
9672
|
+
sessionId: manager.getSessionId(),
|
|
9673
|
+
async send(id, text2) {
|
|
9674
|
+
signal?.throwIfAborted();
|
|
9675
|
+
if (!accepting) throw new Error("Child is no longer accepting messages");
|
|
9676
|
+
await session.sendCustomMessage(
|
|
9677
|
+
{ customType: "scaling-parent-message", content: text2, display: false, details: { message_id: id } },
|
|
9678
|
+
{ deliverAs: "steer", triggerTurn: false }
|
|
9679
|
+
);
|
|
9680
|
+
}
|
|
9681
|
+
});
|
|
9682
|
+
try {
|
|
9683
|
+
await session.prompt(task);
|
|
9684
|
+
} finally {
|
|
9685
|
+
accepting = false;
|
|
9686
|
+
}
|
|
9384
9687
|
signal?.throwIfAborted();
|
|
9385
9688
|
runtime.assertSuccessful();
|
|
9386
9689
|
const last = session.messages.findLast((message) => message.role === "assistant");
|
|
@@ -9397,8 +9700,11 @@ async function runScalingChild(task, parent, signal, config, limits, budget, par
|
|
|
9397
9700
|
return { text: visibleText(last), sessionId: manager.getSessionId(), usage };
|
|
9398
9701
|
} finally {
|
|
9399
9702
|
signal?.removeEventListener("abort", abort);
|
|
9400
|
-
|
|
9401
|
-
|
|
9703
|
+
try {
|
|
9704
|
+
await runtime.dispose();
|
|
9705
|
+
} finally {
|
|
9706
|
+
session.dispose();
|
|
9707
|
+
}
|
|
9402
9708
|
}
|
|
9403
9709
|
}
|
|
9404
9710
|
var init_child = __esm({
|
|
@@ -9413,9 +9719,10 @@ var init_child = __esm({
|
|
|
9413
9719
|
// src/harnesses/scaling/runtime.ts
|
|
9414
9720
|
import path30 from "node:path";
|
|
9415
9721
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
9416
|
-
import { randomUUID as
|
|
9722
|
+
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
9417
9723
|
import {
|
|
9418
|
-
SettingsManager as SettingsManager7
|
|
9724
|
+
SettingsManager as SettingsManager7,
|
|
9725
|
+
createToolSearchExtension
|
|
9419
9726
|
} from "@earendil-works/pi-coding-agent";
|
|
9420
9727
|
function createScalingRuntime(input, options = {}) {
|
|
9421
9728
|
const config = parseScalingConfig(input);
|
|
@@ -9441,7 +9748,7 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9441
9748
|
let turn = 0;
|
|
9442
9749
|
let disposing;
|
|
9443
9750
|
let initialized = false;
|
|
9444
|
-
let stateDirectory = path30.join(tmpdir4(), "scaling-pending-" +
|
|
9751
|
+
let stateDirectory = path30.join(tmpdir4(), "scaling-pending-" + randomUUID18());
|
|
9445
9752
|
const toolName = (name) => visibleToolName(config.TS, name);
|
|
9446
9753
|
const makeToolSpace = (directory) => {
|
|
9447
9754
|
const common = { ...options.toolServices, cwd, stateDirectory: directory, parentSecrets: options.parentSecrets };
|
|
@@ -9466,6 +9773,28 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9466
9773
|
});
|
|
9467
9774
|
};
|
|
9468
9775
|
let toolSpace = makeToolSpace(stateDirectory);
|
|
9776
|
+
const agents = config.W === "W3" && depth === 0 ? new AgentManager(
|
|
9777
|
+
options.runChild ?? (async (task, ctx, signal, channel) => {
|
|
9778
|
+
const { runScalingChild: runScalingChild2 } = await Promise.resolve().then(() => (init_child(), child_exports));
|
|
9779
|
+
if (!inheritedSettings) throw new Error("Missing the parent's Pi settings");
|
|
9780
|
+
return runScalingChild2(
|
|
9781
|
+
task,
|
|
9782
|
+
ctx,
|
|
9783
|
+
signal,
|
|
9784
|
+
config,
|
|
9785
|
+
limits,
|
|
9786
|
+
budget,
|
|
9787
|
+
inheritedSettings,
|
|
9788
|
+
nativeCompactionSettings,
|
|
9789
|
+
{ ...options.toolServices, settings: toolSpace.settings },
|
|
9790
|
+
assertTaskBudget,
|
|
9791
|
+
toolSpace.secrets,
|
|
9792
|
+
channel
|
|
9793
|
+
);
|
|
9794
|
+
}),
|
|
9795
|
+
() => budget.delegate(),
|
|
9796
|
+
(event) => host?.appendEntry("scaling-agent-operation", event)
|
|
9797
|
+
) : void 0;
|
|
9469
9798
|
async function deliverEvent(event) {
|
|
9470
9799
|
if (disposing || boundContext?.signal?.aborted) return;
|
|
9471
9800
|
if (!host || !boundContext) throw new Error("Task notifications require a bound Pi session");
|
|
@@ -9484,7 +9813,13 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9484
9813
|
}
|
|
9485
9814
|
const dispose = () => {
|
|
9486
9815
|
code?.dispose();
|
|
9487
|
-
return disposing ??=
|
|
9816
|
+
return disposing ??= (async () => {
|
|
9817
|
+
try {
|
|
9818
|
+
await agents?.dispose();
|
|
9819
|
+
} finally {
|
|
9820
|
+
await toolSpace.dispose();
|
|
9821
|
+
}
|
|
9822
|
+
})();
|
|
9488
9823
|
};
|
|
9489
9824
|
const chargeModelCall = () => {
|
|
9490
9825
|
if (fatal) throw fatal;
|
|
@@ -9513,13 +9848,16 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9513
9848
|
};
|
|
9514
9849
|
function guarded(tool, outer = false) {
|
|
9515
9850
|
const delivered = outer || config.TC === "TC1";
|
|
9851
|
+
let exposure = "codemode";
|
|
9852
|
+
if (outer || tool.name === "tool_search") exposure = "model-only";
|
|
9853
|
+
else if (config.TC === "TC1") exposure = TC1_CORE_TOOLS.has(tool.name) ? "direct" : "deferred";
|
|
9516
9854
|
return renameTool(
|
|
9517
9855
|
{
|
|
9518
9856
|
...tool,
|
|
9519
9857
|
// Only model delivery uses O's shared result shape. Programs retain
|
|
9520
9858
|
// native content, structured results, and their schema.
|
|
9521
9859
|
outputSchema: delivered ? void 0 : tool.outputSchema,
|
|
9522
|
-
exposure
|
|
9860
|
+
exposure,
|
|
9523
9861
|
async execute(id, args, signal, _update, ctx) {
|
|
9524
9862
|
if (fatal) throw fatal;
|
|
9525
9863
|
assertTaskBudget();
|
|
@@ -9545,9 +9883,14 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9545
9883
|
result = { ...textResult(error instanceof Error ? error.message : String(error)), isError: true };
|
|
9546
9884
|
}
|
|
9547
9885
|
const observed = delivered ? await observation.apply(tool.name, result, ctx, id, outputLimit) : result;
|
|
9548
|
-
if (config.C === "C2" && !outer && ![
|
|
9549
|
-
|
|
9550
|
-
|
|
9886
|
+
if (config.C === "C2" && !outer && ![
|
|
9887
|
+
"session_notes",
|
|
9888
|
+
"new_context",
|
|
9889
|
+
"session_history",
|
|
9890
|
+
"get_context_remaining",
|
|
9891
|
+
"memory_lookup",
|
|
9892
|
+
"tool_search"
|
|
9893
|
+
].includes(tool.name))
|
|
9551
9894
|
context.notes.workChanged();
|
|
9552
9895
|
return observed;
|
|
9553
9896
|
}
|
|
@@ -9566,35 +9909,23 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9566
9909
|
})),
|
|
9567
9910
|
...context.tools(),
|
|
9568
9911
|
...planning ? [planning.tool()] : [],
|
|
9569
|
-
...
|
|
9570
|
-
createSubagentTool(
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
if (!inheritedSettings) throw new Error("Missing the parent's Pi settings");
|
|
9575
|
-
return runScalingChild2(
|
|
9576
|
-
task,
|
|
9577
|
-
ctx,
|
|
9578
|
-
signal,
|
|
9579
|
-
config,
|
|
9580
|
-
limits,
|
|
9581
|
-
budget,
|
|
9582
|
-
inheritedSettings,
|
|
9583
|
-
nativeCompactionSettings,
|
|
9584
|
-
{ ...options.toolServices, settings: toolSpace.settings },
|
|
9585
|
-
assertTaskBudget,
|
|
9586
|
-
toolSpace.secrets
|
|
9587
|
-
);
|
|
9588
|
-
})
|
|
9589
|
-
)
|
|
9912
|
+
...agents ? [
|
|
9913
|
+
createSubagentTool(agents),
|
|
9914
|
+
createListAgentsTool(agents),
|
|
9915
|
+
createWaitAgentsTool(agents),
|
|
9916
|
+
createSendMessageTool(agents)
|
|
9590
9917
|
] : []
|
|
9591
9918
|
];
|
|
9592
9919
|
const names = definitions.map((tool) => tool.name);
|
|
9593
9920
|
if (new Set(names).size !== names.length) throw new Error("Duplicate tool capability in scaling composition");
|
|
9594
9921
|
const registered = definitions.map((tool) => guarded(tool));
|
|
9595
9922
|
let exposed;
|
|
9596
|
-
|
|
9597
|
-
|
|
9923
|
+
const deferred = registered.filter((tool) => tool.exposure === "deferred");
|
|
9924
|
+
const deferredNames = new Set(deferred.map((tool) => tool.name));
|
|
9925
|
+
if (config.TC === "TC1") {
|
|
9926
|
+
exposed = registered.filter((tool) => tool.exposure === "direct").map((tool) => tool.name);
|
|
9927
|
+
exposed.push(toolName("tool_search"));
|
|
9928
|
+
} else if (config.TC === "TC2") {
|
|
9598
9929
|
const tool = createScalingCodemodeTool([...registered]);
|
|
9599
9930
|
const entry = guarded(tool, true);
|
|
9600
9931
|
registered.push(entry);
|
|
@@ -9607,11 +9938,42 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9607
9938
|
}
|
|
9608
9939
|
const extension = {
|
|
9609
9940
|
name: "harness-scaling",
|
|
9610
|
-
factory(pi) {
|
|
9941
|
+
async factory(pi) {
|
|
9611
9942
|
host = pi;
|
|
9612
9943
|
context.bind(pi);
|
|
9613
9944
|
observation.bind(pi);
|
|
9614
9945
|
for (const tool of registered) pi.registerTool(tool);
|
|
9946
|
+
let active = exposed;
|
|
9947
|
+
if (config.TC === "TC1") {
|
|
9948
|
+
await createToolSearchExtension()({
|
|
9949
|
+
...pi,
|
|
9950
|
+
getAllTools: () => pi.getAllTools().filter((tool) => deferredNames.has(tool.name)),
|
|
9951
|
+
getActiveTools: () => active,
|
|
9952
|
+
setActiveTools(names2) {
|
|
9953
|
+
active = names2;
|
|
9954
|
+
pi.setActiveTools(active);
|
|
9955
|
+
pi.appendEntry(
|
|
9956
|
+
"scaling-discovered",
|
|
9957
|
+
active.filter((name) => deferredNames.has(name))
|
|
9958
|
+
);
|
|
9959
|
+
},
|
|
9960
|
+
registerTool(definition) {
|
|
9961
|
+
const search = definition;
|
|
9962
|
+
pi.registerTool(
|
|
9963
|
+
guarded({
|
|
9964
|
+
...search,
|
|
9965
|
+
async execute(...args) {
|
|
9966
|
+
const result = await search.execute(...args);
|
|
9967
|
+
const loaded = new Set(result.details.loaded);
|
|
9968
|
+
const schemas = deferred.filter((tool) => loaded.has(tool.name)).map(({ name, description, parameters }) => ({ name, description, parameters }));
|
|
9969
|
+
if (!schemas.length) return result;
|
|
9970
|
+
return { ...result, content: [...result.content, { type: "text", text: JSON.stringify(schemas) }] };
|
|
9971
|
+
}
|
|
9972
|
+
})
|
|
9973
|
+
);
|
|
9974
|
+
}
|
|
9975
|
+
});
|
|
9976
|
+
}
|
|
9615
9977
|
const recordNativeSettings = (ctx) => {
|
|
9616
9978
|
inheritedSettings = pi.getSettings();
|
|
9617
9979
|
if (config.C !== "C1") return;
|
|
@@ -9625,6 +9987,7 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9625
9987
|
});
|
|
9626
9988
|
};
|
|
9627
9989
|
const restore = async (ctx) => {
|
|
9990
|
+
await agents?.cancelAll();
|
|
9628
9991
|
code?.dispose();
|
|
9629
9992
|
fatal = void 0;
|
|
9630
9993
|
nativeCompaction = void 0;
|
|
@@ -9643,7 +10006,7 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9643
10006
|
new Error("This session used different scaling limits; start a new session for the new experiment"),
|
|
9644
10007
|
ctx
|
|
9645
10008
|
);
|
|
9646
|
-
if (savedConfig && (savedConfig.version !==
|
|
10009
|
+
if (savedConfig && (savedConfig.version !== SCALING_RUNTIME_VERSION || savedConfig.catalogVersion !== TOOL_CATALOG_VERSION || savedConfig.mappingVersion !== TOOL_MAPPING_VERSION))
|
|
9647
10010
|
fail(new Error("This session used a different tool catalog or naming version; start a new session"), ctx);
|
|
9648
10011
|
if (!previous && branch.some((entry) => entry.type === "message" && ["user", "assistant"].includes(entry.message.role)))
|
|
9649
10012
|
fail(new Error("An existing non-scaling session cannot be reused as a scaling configuration"), ctx);
|
|
@@ -9675,9 +10038,10 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9675
10038
|
if ("initialize" in toolSpace) await toolSpace.initialize();
|
|
9676
10039
|
initialized = true;
|
|
9677
10040
|
}
|
|
10041
|
+
await agents?.bind(path30.join(stateDirectory, "agents.json"));
|
|
9678
10042
|
if (!previous)
|
|
9679
10043
|
pi.appendEntry("scaling-config", {
|
|
9680
|
-
version:
|
|
10044
|
+
version: SCALING_RUNTIME_VERSION,
|
|
9681
10045
|
catalogVersion: TOOL_CATALOG_VERSION,
|
|
9682
10046
|
mappingVersion: TOOL_MAPPING_VERSION,
|
|
9683
10047
|
toolStateDirectory: stateDirectory,
|
|
@@ -9686,8 +10050,12 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9686
10050
|
limits,
|
|
9687
10051
|
depth
|
|
9688
10052
|
});
|
|
10053
|
+
const discovery = branch.findLast(
|
|
10054
|
+
(entry) => entry.type === "custom" && entry.customType === "scaling-discovered"
|
|
10055
|
+
);
|
|
10056
|
+
active = discovery?.type === "custom" && Array.isArray(discovery.data) ? [...exposed, ...discovery.data.filter((name) => deferredNames.has(name))] : exposed;
|
|
9689
10057
|
recordNativeSettings(ctx);
|
|
9690
|
-
pi.setActiveTools(
|
|
10058
|
+
pi.setActiveTools(active);
|
|
9691
10059
|
};
|
|
9692
10060
|
pi.on("session_start", (_event, ctx) => restore(ctx));
|
|
9693
10061
|
pi.on("session_tree", (_event, ctx) => restore(ctx));
|
|
@@ -9695,7 +10063,7 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9695
10063
|
pi.on("session_shutdown", () => dispose());
|
|
9696
10064
|
pi.on("before_agent_start", (_event, ctx) => {
|
|
9697
10065
|
systemPrompt = composePrompt(depth === 0 && ctx.hasUI);
|
|
9698
|
-
pi.setActiveTools(
|
|
10066
|
+
pi.setActiveTools(active);
|
|
9699
10067
|
return { systemPrompt };
|
|
9700
10068
|
});
|
|
9701
10069
|
pi.on("turn_start", () => {
|
|
@@ -9746,11 +10114,35 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9746
10114
|
fail(error, ctx);
|
|
9747
10115
|
}
|
|
9748
10116
|
});
|
|
9749
|
-
pi.on("agent_before_settle", (_event, ctx) => {
|
|
10117
|
+
pi.on("agent_before_settle", async (_event, ctx) => {
|
|
9750
10118
|
if (ctx.signal?.aborted || fatal) return;
|
|
9751
10119
|
try {
|
|
10120
|
+
const remaining = agents?.uncollected();
|
|
10121
|
+
if (remaining?.length) {
|
|
10122
|
+
const result = await agents.wait(remaining, void 0, ctx.signal, true);
|
|
10123
|
+
const observed = await observation.apply("wait_agents", textResult(result), ctx, "settle-" + randomUUID18());
|
|
10124
|
+
if (config.C === "C2") context.notes.workChanged();
|
|
10125
|
+
return {
|
|
10126
|
+
entries: [
|
|
10127
|
+
{
|
|
10128
|
+
type: "custom_message",
|
|
10129
|
+
customType: "scaling-child-results",
|
|
10130
|
+
content: [
|
|
10131
|
+
{
|
|
10132
|
+
type: "text",
|
|
10133
|
+
text: "Delegated work has returned. Integrate these results before completing the user task."
|
|
10134
|
+
},
|
|
10135
|
+
...observed.content
|
|
10136
|
+
],
|
|
10137
|
+
display: false
|
|
10138
|
+
}
|
|
10139
|
+
],
|
|
10140
|
+
continue: true
|
|
10141
|
+
};
|
|
10142
|
+
}
|
|
9752
10143
|
return planning?.beforeSettle();
|
|
9753
10144
|
} catch (error) {
|
|
10145
|
+
if (ctx.signal?.aborted) return;
|
|
9754
10146
|
fail(error, ctx);
|
|
9755
10147
|
}
|
|
9756
10148
|
});
|
|
@@ -9799,16 +10191,19 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9799
10191
|
pi.on("session_compact_failed", () => {
|
|
9800
10192
|
nativeCompaction = void 0;
|
|
9801
10193
|
});
|
|
9802
|
-
pi.on("agent_settled", (event) => {
|
|
9803
|
-
if (event.aborted)
|
|
10194
|
+
pi.on("agent_settled", async (event) => {
|
|
10195
|
+
if (event.aborted) {
|
|
10196
|
+
code?.dispose();
|
|
10197
|
+
await agents?.cancelAll();
|
|
10198
|
+
}
|
|
9804
10199
|
});
|
|
9805
10200
|
}
|
|
9806
10201
|
};
|
|
9807
|
-
const registeredToolNames = registered.map((tool) => tool.name);
|
|
10202
|
+
const registeredToolNames = [.../* @__PURE__ */ new Set([...exposed, ...registered.map((tool) => tool.name)])];
|
|
9808
10203
|
const capability = {
|
|
9809
10204
|
name: "harness-scaling",
|
|
9810
10205
|
tools: exposed,
|
|
9811
|
-
callableTools: config.TC === "TC1" ? [] : names.map(toolName),
|
|
10206
|
+
callableTools: config.TC === "TC1" ? [...deferredNames] : names.map(toolName),
|
|
9812
10207
|
extensionFactories: [extension]
|
|
9813
10208
|
};
|
|
9814
10209
|
return {
|
|
@@ -9825,9 +10220,11 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9825
10220
|
extension,
|
|
9826
10221
|
tools: registered,
|
|
9827
10222
|
exposedTools: exposed,
|
|
10223
|
+
deferredTools: [...deferredNames],
|
|
9828
10224
|
registeredToolNames,
|
|
9829
10225
|
beforeNativeSummaryRequest,
|
|
9830
10226
|
toolName,
|
|
10227
|
+
agents,
|
|
9831
10228
|
taskToolNames: toolSpace.tools.map((tool) => toolName(tool.name)),
|
|
9832
10229
|
get toolSpace() {
|
|
9833
10230
|
return toolSpace;
|
|
@@ -9839,6 +10236,7 @@ function createScalingRuntime(input, options = {}) {
|
|
|
9839
10236
|
}
|
|
9840
10237
|
};
|
|
9841
10238
|
}
|
|
10239
|
+
var TC1_CORE_TOOLS, SCALING_RUNTIME_VERSION;
|
|
9842
10240
|
var init_runtime = __esm({
|
|
9843
10241
|
"src/harnesses/scaling/runtime.ts"() {
|
|
9844
10242
|
"use strict";
|
|
@@ -9851,10 +10249,16 @@ var init_runtime = __esm({
|
|
|
9851
10249
|
init_planning();
|
|
9852
10250
|
init_prompts();
|
|
9853
10251
|
init_subagent();
|
|
10252
|
+
init_list_agents();
|
|
10253
|
+
init_wait_agents();
|
|
10254
|
+
init_send_message();
|
|
10255
|
+
init_agent_manager();
|
|
9854
10256
|
init_tools();
|
|
9855
10257
|
init_task_tool_space();
|
|
9856
10258
|
init_expanded_task_tool_space();
|
|
9857
10259
|
init_naming();
|
|
10260
|
+
TC1_CORE_TOOLS = /* @__PURE__ */ new Set(["bash", "read_file", "apply_patch", "subagent"]);
|
|
10261
|
+
SCALING_RUNTIME_VERSION = 3;
|
|
9858
10262
|
}
|
|
9859
10263
|
});
|
|
9860
10264
|
|
|
@@ -11787,68 +12191,68 @@ init_config();
|
|
|
11787
12191
|
init_runtime();
|
|
11788
12192
|
|
|
11789
12193
|
// src/capabilities/tool-service-settings.ts
|
|
11790
|
-
import { Type as
|
|
12194
|
+
import { Type as Type93 } from "typebox";
|
|
11791
12195
|
import { Value as Value2 } from "typebox/value";
|
|
11792
|
-
var text = () =>
|
|
11793
|
-
var strings = () =>
|
|
11794
|
-
var server =
|
|
11795
|
-
|
|
12196
|
+
var text = () => Type93.String({ minLength: 1 });
|
|
12197
|
+
var strings = () => Type93.Record(Type93.String(), Type93.String());
|
|
12198
|
+
var server = Type93.Union([
|
|
12199
|
+
Type93.Object(
|
|
11796
12200
|
{
|
|
11797
|
-
type:
|
|
12201
|
+
type: Type93.Optional(Type93.Literal("stdio")),
|
|
11798
12202
|
command: text(),
|
|
11799
|
-
args:
|
|
11800
|
-
cwd:
|
|
11801
|
-
env:
|
|
11802
|
-
enabled:
|
|
12203
|
+
args: Type93.Optional(Type93.Array(Type93.String())),
|
|
12204
|
+
cwd: Type93.Optional(text()),
|
|
12205
|
+
env: Type93.Optional(strings()),
|
|
12206
|
+
enabled: Type93.Optional(Type93.Boolean())
|
|
11803
12207
|
},
|
|
11804
12208
|
{ additionalProperties: false }
|
|
11805
12209
|
),
|
|
11806
|
-
|
|
12210
|
+
Type93.Object(
|
|
11807
12211
|
{
|
|
11808
|
-
type:
|
|
12212
|
+
type: Type93.Optional(Type93.Literal("http")),
|
|
11809
12213
|
url: text(),
|
|
11810
|
-
headers:
|
|
11811
|
-
enabled:
|
|
12214
|
+
headers: Type93.Optional(strings()),
|
|
12215
|
+
enabled: Type93.Optional(Type93.Boolean())
|
|
11812
12216
|
},
|
|
11813
12217
|
{ additionalProperties: false }
|
|
11814
12218
|
)
|
|
11815
12219
|
]);
|
|
11816
|
-
var schema17 =
|
|
12220
|
+
var schema17 = Type93.Object(
|
|
11817
12221
|
{
|
|
11818
|
-
stateRoot:
|
|
11819
|
-
sessionDirectory:
|
|
11820
|
-
skillPaths:
|
|
11821
|
-
videoModel:
|
|
11822
|
-
initialMemory:
|
|
11823
|
-
|
|
11824
|
-
|
|
11825
|
-
{ id: text(), title: text(), content:
|
|
12222
|
+
stateRoot: Type93.Optional(text()),
|
|
12223
|
+
sessionDirectory: Type93.Optional(text()),
|
|
12224
|
+
skillPaths: Type93.Optional(Type93.Array(text())),
|
|
12225
|
+
videoModel: Type93.Optional(text()),
|
|
12226
|
+
initialMemory: Type93.Optional(
|
|
12227
|
+
Type93.Array(
|
|
12228
|
+
Type93.Object(
|
|
12229
|
+
{ id: text(), title: text(), content: Type93.String(), tags: Type93.Array(Type93.String()), updated_at: text() },
|
|
11826
12230
|
{ additionalProperties: false }
|
|
11827
12231
|
)
|
|
11828
12232
|
)
|
|
11829
12233
|
),
|
|
11830
|
-
mcpServers:
|
|
11831
|
-
lspServers:
|
|
11832
|
-
|
|
11833
|
-
|
|
11834
|
-
|
|
12234
|
+
mcpServers: Type93.Optional(Type93.Record(Type93.String({ pattern: "^[A-Za-z0-9_-]+$" }), server)),
|
|
12235
|
+
lspServers: Type93.Optional(
|
|
12236
|
+
Type93.Record(
|
|
12237
|
+
Type93.String(),
|
|
12238
|
+
Type93.Object(
|
|
11835
12239
|
{
|
|
11836
12240
|
command: text(),
|
|
11837
|
-
args:
|
|
11838
|
-
extensions:
|
|
12241
|
+
args: Type93.Optional(Type93.Array(Type93.String())),
|
|
12242
|
+
extensions: Type93.Array(text(), { minItems: 1 }),
|
|
11839
12243
|
language_id: text(),
|
|
11840
|
-
env:
|
|
11841
|
-
initialization_options:
|
|
12244
|
+
env: Type93.Optional(strings()),
|
|
12245
|
+
initialization_options: Type93.Optional(Type93.Unknown())
|
|
11842
12246
|
},
|
|
11843
12247
|
{ additionalProperties: false }
|
|
11844
12248
|
)
|
|
11845
12249
|
)
|
|
11846
12250
|
),
|
|
11847
|
-
gateway:
|
|
11848
|
-
|
|
12251
|
+
gateway: Type93.Optional(
|
|
12252
|
+
Type93.Object({ url: text(), token: Type93.Optional(text()), session_key: text() }, { additionalProperties: false })
|
|
11849
12253
|
),
|
|
11850
|
-
transcriptProviders:
|
|
11851
|
-
|
|
12254
|
+
transcriptProviders: Type93.Optional(
|
|
12255
|
+
Type93.Record(Type93.String(), Type93.Object({ command: text() }, { additionalProperties: false }))
|
|
11852
12256
|
)
|
|
11853
12257
|
},
|
|
11854
12258
|
{ additionalProperties: false }
|
|
@@ -11958,6 +12362,7 @@ async function runScalingHarness(args) {
|
|
|
11958
12362
|
limits: runtime.limits,
|
|
11959
12363
|
taskTools: runtime.taskToolNames,
|
|
11960
12364
|
exposedTools: runtime.exposedTools,
|
|
12365
|
+
...runtime.config.TC === "TC1" ? { deferredTools: runtime.deferredTools } : {},
|
|
11961
12366
|
callableTools: runtime.tools.filter((tool) => tool.exposure === "codemode").map((tool) => tool.name),
|
|
11962
12367
|
systemPrompt: runtime.systemPrompt
|
|
11963
12368
|
},
|
|
@@ -11984,9 +12389,9 @@ init_glob();
|
|
|
11984
12389
|
|
|
11985
12390
|
// src/capabilities/tools/filesystem/str_replace_editor.ts
|
|
11986
12391
|
import {
|
|
11987
|
-
defineTool as
|
|
12392
|
+
defineTool as defineTool95
|
|
11988
12393
|
} from "@earendil-works/pi-coding-agent";
|
|
11989
|
-
import { Type as
|
|
12394
|
+
import { Type as Type94 } from "typebox";
|
|
11990
12395
|
|
|
11991
12396
|
// src/utils/filesystem/str_replace_editor.ts
|
|
11992
12397
|
init_workspace();
|
|
@@ -12239,29 +12644,29 @@ var DEFAULT_DESCRIPTION = [
|
|
|
12239
12644
|
"The create command refuses to overwrite an existing path.",
|
|
12240
12645
|
"For str_replace, old_str must match exactly once; include enough surrounding text to make it unique."
|
|
12241
12646
|
].join(" ");
|
|
12242
|
-
var schema18 =
|
|
12243
|
-
command:
|
|
12244
|
-
|
|
12245
|
-
|
|
12246
|
-
|
|
12247
|
-
|
|
12647
|
+
var schema18 = Type94.Object({
|
|
12648
|
+
command: Type94.Union([
|
|
12649
|
+
Type94.Literal("view"),
|
|
12650
|
+
Type94.Literal("create"),
|
|
12651
|
+
Type94.Literal("str_replace"),
|
|
12652
|
+
Type94.Literal("insert")
|
|
12248
12653
|
], { description: "Command to run." }),
|
|
12249
|
-
path:
|
|
12654
|
+
path: Type94.String({
|
|
12250
12655
|
description: "Absolute path to a file or directory inside the workspace."
|
|
12251
12656
|
}),
|
|
12252
|
-
file_text:
|
|
12657
|
+
file_text: Type94.Optional(Type94.String({
|
|
12253
12658
|
description: "Required by create: complete content of the new file."
|
|
12254
12659
|
})),
|
|
12255
|
-
insert_line:
|
|
12660
|
+
insert_line: Type94.Optional(Type94.Integer({
|
|
12256
12661
|
description: "Required by insert: insert new_str after this 0-based line boundary."
|
|
12257
12662
|
})),
|
|
12258
|
-
new_str:
|
|
12663
|
+
new_str: Type94.Optional(Type94.String({
|
|
12259
12664
|
description: "Replacement text for str_replace, or required insertion text for insert."
|
|
12260
12665
|
})),
|
|
12261
|
-
old_str:
|
|
12666
|
+
old_str: Type94.Optional(Type94.String({
|
|
12262
12667
|
description: "Required by str_replace: the unique literal text to replace."
|
|
12263
12668
|
})),
|
|
12264
|
-
view_range:
|
|
12669
|
+
view_range: Type94.Optional(Type94.Array(Type94.Integer(), {
|
|
12265
12670
|
description: "For file views, [start_line, end_line] using 1-based inclusive lines; use -1 as the end to read through EOF."
|
|
12266
12671
|
}))
|
|
12267
12672
|
}, { additionalProperties: false });
|
|
@@ -12273,7 +12678,7 @@ function resolveDescription(description) {
|
|
|
12273
12678
|
function createStrReplaceEditorTool(cwd, options = {}) {
|
|
12274
12679
|
const runtimeOptions = resolveStrReplaceEditorOptions(options);
|
|
12275
12680
|
const description = resolveDescription(options.description);
|
|
12276
|
-
return
|
|
12681
|
+
return defineTool95({
|
|
12277
12682
|
name: STR_REPLACE_EDITOR_TOOL_NAME,
|
|
12278
12683
|
label: "String Replace Editor",
|
|
12279
12684
|
description,
|