@cubicecho/agent-router-worker 0.11.0 → 0.12.0
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.
|
@@ -42,6 +42,8 @@ The options are agent-core's `AgentLoopOptions`, and the result its `AgentLoopRe
|
|
|
42
42
|
- **Call the model through `options.config.fetch`.** `config.baseUrl` is an address nothing answers, and only that `fetch` reaches the router's models. It refuses every other address. An agent with an endpoint of its own has its own `baseUrl` and no `fetch`.
|
|
43
43
|
- **Run tools through `options.dispatch`,** which knows which tools are the worker's and which the router's. When its answer carries `end`, stop the loop: the call is the app's, handed back.
|
|
44
44
|
- **Report through `options.onEvent`,** agent-core's `RunEventInput`s. They are the run's record on the router.
|
|
45
|
+
- **Report what the run made.** Return it as `artifacts` and say each one as an `artifact` event: agent-core's `ArtifactLedger` keeps the merge rules, and `artifactEvent` builds the event. Put each dispatch answer's `links` and `artifacts` in it, and whatever your loop reads off a write as a `detected` draft.
|
|
46
|
+
- **Tell the model of `options.artifacts.tool`, when set,** the app tool it records what it made with: agent-core's `artifactToolPrompt` is the line. Never call it yourself.
|
|
45
47
|
- **Stop on `options.signal`.** It fires on a cancel and when the worker stops. The run is then finished as failed with the reason, whatever the loop returns.
|
|
46
48
|
- **Return `messages`, `usage`, `loaded` and `turn`.** A throw fails the run with its message.
|
|
47
49
|
- **Offer your models, if you call them yourself.** A loop that calls its model through `options.config.fetch` needs do nothing: the worker offers the router's models, and the router records the model each call asks for. One that calls models of its own passes them to `startWorker` as `models`, each an `OfferedModel` (`{ provider, id }`). The router then sends this worker only runs of agents whose model is one of them, named `<provider>/<id>`, and none other. Run the one `options.config.model` names. Use a provider name every worker serving the same models shares, not the worker's own, so they share the runs.
|
|
@@ -616,6 +616,21 @@ function targetOf(targets, name) {
|
|
|
616
616
|
return Object.hasOwn(targets, name) ? targets[name] : void 0;
|
|
617
617
|
}
|
|
618
618
|
/**
|
|
619
|
+
* The loop's `artifacts` option, naming the app's artifact tool where the model is offered it.
|
|
620
|
+
*
|
|
621
|
+
* @param assignment - The stretch.
|
|
622
|
+
* @returns `{ artifacts: { tool } }`, or nothing when the app names no tool or the model is offered none by its name.
|
|
623
|
+
*
|
|
624
|
+
* @remarks
|
|
625
|
+
* An app tool that one of the agent's own tools answers is offered under the agent tool's name. Pruned across
|
|
626
|
+
* servers, that name differs, and the loop would refuse to start over a tool it can't find.
|
|
627
|
+
*/
|
|
628
|
+
function artifactsOf(assignment) {
|
|
629
|
+
const { artifactTool } = assignment;
|
|
630
|
+
if (artifactTool === void 0) return {};
|
|
631
|
+
return [...assignment.tools, ...assignment.appTools].some((tool) => tool.type === "function" && tool.function.name === artifactTool) ? { artifacts: { tool: artifactTool } } : {};
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
619
634
|
* Runs one stretch of a run's agent loop: to its answer, or until the model calls an app tool.
|
|
620
635
|
*
|
|
621
636
|
* @param assignment - The stretch.
|
|
@@ -671,6 +686,7 @@ async function executeRun(assignment, ports, runtime) {
|
|
|
671
686
|
...isEager ? {} : { catalog: assignment.catalog },
|
|
672
687
|
dispatch,
|
|
673
688
|
dedupeToolCalls: (call) => appNames.has(call.name) === false,
|
|
689
|
+
...artifactsOf(assignment),
|
|
674
690
|
signal: ports.signal,
|
|
675
691
|
session: runId,
|
|
676
692
|
onEvent
|
|
@@ -1135,7 +1151,7 @@ path.resolve(import.meta.dirname, "..", "..");
|
|
|
1135
1151
|
* A bundle can't read the repo's package.json the way `version()` does, because it isn't there.
|
|
1136
1152
|
*/
|
|
1137
1153
|
function workerVersion() {
|
|
1138
|
-
return "0.
|
|
1154
|
+
return "0.12.0";
|
|
1139
1155
|
}
|
|
1140
1156
|
// worker/workdir/git.ts
|
|
1141
1157
|
/** The git program, found on PATH. */
|
package/lib.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { r as TOOL_ORIGIN_LOCAL, i as TOOL_ORIGIN_ROUTER, a as WorkerConfigError, n as executeRun, o as readWorkerConfig, t as startWorker } from "./chunks/worker-
|
|
1
|
+
export { r as TOOL_ORIGIN_LOCAL, i as TOOL_ORIGIN_ROUTER, a as WorkerConfigError, n as executeRun, o as readWorkerConfig, t as startWorker } from "./chunks/worker-CeigVtbh.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cubicecho/agent-router-worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "agent-router's worker program: runs a workspace's agent loops on another machine.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -43,6 +43,6 @@
|
|
|
43
43
|
"zod": "^4.6.7"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@cubicecho/agent-core": "^
|
|
46
|
+
"@cubicecho/agent-core": "^9.0.0"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -51,6 +51,11 @@ export interface RunAssignment {
|
|
|
51
51
|
targets: Record<string, ToolTarget>;
|
|
52
52
|
/** The app's tools this stretch hands back. */
|
|
53
53
|
appTools: AppToolDefinition[];
|
|
54
|
+
/**
|
|
55
|
+
* The app tool the model records what it made with, which the loop tells it of and never calls itself. Absent when
|
|
56
|
+
* the app names none.
|
|
57
|
+
*/
|
|
58
|
+
artifactTool?: string;
|
|
54
59
|
}
|
|
55
60
|
/** How a call to a tool is made, besides its arguments. */
|
|
56
61
|
export interface ToolCallOptions {
|
package/worker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { o as readWorkerConfig, s as errorMessage, t as startWorker } from "./chunks/worker-
|
|
2
|
+
import { o as readWorkerConfig, s as errorMessage, t as startWorker } from "./chunks/worker-CeigVtbh.js";
|
|
3
3
|
// worker/index.ts
|
|
4
4
|
/** Exits with this when the worker can't start, or is stopped twice. */
|
|
5
5
|
const EXIT_FAILED = 1;
|