@nylorun/harness 0.19.2-beta → 0.21.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +125 -0
- package/HOST_CONTRACT.md +11 -11
- package/README.md +2 -2
- package/dist/compatibility.d.ts +12 -3
- package/dist/compatibility.js +11 -3
- package/dist/flow/checkpoint.d.ts +2 -2
- package/dist/flow/checkpoint.js +2 -2
- package/dist/flow/context.d.ts +1 -0
- package/dist/flow/context.js +1 -0
- package/dist/flow/engine.d.ts +3 -2
- package/dist/flow/engine.js +8 -4
- package/dist/flow/loop.d.ts +4 -0
- package/dist/flow/loop.js +3 -1
- package/dist/flow/map.js +1 -1
- package/dist/flow/node.js +27 -4
- package/dist/flow/paths.d.ts +6 -1
- package/dist/flow/paths.js +7 -2
- package/dist/flow/types.d.ts +1 -1
- package/dist/flow/types.js +1 -1
- package/dist/flow/v2.d.ts +12 -0
- package/dist/flow/v2.js +370 -0
- package/dist/loop/compaction/index.d.ts +49 -0
- package/dist/loop/compaction/index.js +288 -0
- package/dist/loop/delegation.d.ts +14 -0
- package/dist/loop/delegation.js +39 -15
- package/dist/loop/model/normalize.js +1 -0
- package/dist/loop/model/project.js +34 -5
- package/dist/loop/run.js +58 -0
- package/dist/loop/step/run.js +9 -1
- package/dist/loop/transcript.js +20 -0
- package/dist/run/durable.d.ts +6 -1
- package/dist/run/durable.js +14 -3
- package/dist/types/execution.d.ts +8 -0
- package/package.json +4 -3
package/dist/run/durable.js
CHANGED
|
@@ -150,7 +150,7 @@ export async function runDurable(options) {
|
|
|
150
150
|
name: tool.name,
|
|
151
151
|
})),
|
|
152
152
|
}));
|
|
153
|
-
// All capabilities registered at a hook point share one effect, so one
|
|
153
|
+
// All capabilities registered at a hook point share one effect, so one Action delivery.
|
|
154
154
|
const runHooks = async ({ point, capabilityIds, args, identity }) => {
|
|
155
155
|
const outcome = await effect("hook", args, { info: checkpoint.info }, scoped(ref, identity), {
|
|
156
156
|
hook: { at: point.at, scope: point.scope, capabilityIds },
|
|
@@ -163,12 +163,23 @@ export async function runDurable(options) {
|
|
|
163
163
|
};
|
|
164
164
|
return Object.freeze({ ...definition, runHooks });
|
|
165
165
|
};
|
|
166
|
-
const modelCall = (ref) => async (call, ctx) => (await effect("model", call,
|
|
166
|
+
const modelCall = (ref) => async (call, ctx) => (await effect("model", call,
|
|
167
|
+
// The call already holds the whole prompt; journaling the request would store it twice.
|
|
168
|
+
{
|
|
169
|
+
invocationId: ctx.invocationId,
|
|
170
|
+
...(ctx.compaction ? { compaction: ctx.compaction } : {}),
|
|
171
|
+
}, scoped(ref, ctx.invocationId), ref ? { agent: ref } : {})).value;
|
|
167
172
|
const delegation = {
|
|
168
173
|
child: (delegate, ref) => ({
|
|
169
174
|
definition: hostedDefinition(delegate.manifest, ref),
|
|
170
175
|
onModelCall: modelCall(ref),
|
|
171
176
|
}),
|
|
177
|
+
// A flow agent used as a tool runs in its own linked session, like a flow's agent
|
|
178
|
+
// step: the host starts it, and the effect settles when its turn ends.
|
|
179
|
+
async flow(_delegate, ref, task) {
|
|
180
|
+
const outcome = await effect("agent", { agentId: ref.id, input: task, path: ref.path }, { role: "delegate", delegationId: ref.delegationId }, `${ref.delegationId}:flow`, { agent: ref });
|
|
181
|
+
return outcome.value;
|
|
182
|
+
},
|
|
172
183
|
async announce(phase, ref, payload, ids) {
|
|
173
184
|
await effect("delegation", payload, { ...ids }, `${ref.delegationId}:${phase}`, {
|
|
174
185
|
agent: ref,
|
|
@@ -187,7 +198,7 @@ export async function runDurable(options) {
|
|
|
187
198
|
info: checkpoint.info,
|
|
188
199
|
signal: options.signal,
|
|
189
200
|
onModelCall: modelCall(),
|
|
190
|
-
}, { delegation }));
|
|
201
|
+
}, { delegation, ...(options.yieldAfter ? { yieldAfter: options.yieldAfter } : {}) }));
|
|
191
202
|
return { status: result.status, checkpoint: { ...checkpoint, state: result.state }, result };
|
|
192
203
|
}
|
|
193
204
|
catch (error) {
|
|
@@ -132,4 +132,12 @@ export type RunResult<Output = string> = {
|
|
|
132
132
|
readonly status: "failed";
|
|
133
133
|
readonly state: ExecutionState;
|
|
134
134
|
readonly error: Tripwire;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A durable segment ended at a step boundary so the turn continues in a new segment
|
|
138
|
+
* (Model Calls §10). The state is mid-turn; resume it with `{ kind: "continue" }`.
|
|
139
|
+
*/
|
|
140
|
+
| {
|
|
141
|
+
readonly status: "yielded";
|
|
142
|
+
readonly state: ExecutionState;
|
|
135
143
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nylorun/harness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0-beta",
|
|
4
4
|
"description": "Nylorun's TypeScript agent execution engine. See github.com/nylorun/agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -65,7 +65,8 @@
|
|
|
65
65
|
"format": "prettier --write .",
|
|
66
66
|
"format:check": "prettier --check .",
|
|
67
67
|
"clean": "node -e \"import('node:fs').then(({rmSync})=>rmSync('dist',{recursive:true,force:true}))\"",
|
|
68
|
-
"prepack": "npm run build"
|
|
68
|
+
"prepack": "npm run build",
|
|
69
|
+
"eval:compaction": "vitest run test/compaction-eval.test.ts"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
72
|
"@types/node": "^26.5.0",
|
|
@@ -76,7 +77,7 @@
|
|
|
76
77
|
"zod": "^4.6.5"
|
|
77
78
|
},
|
|
78
79
|
"dependencies": {
|
|
79
|
-
"@nylorun/core": "0.
|
|
80
|
+
"@nylorun/core": "0.9.0-beta"
|
|
80
81
|
},
|
|
81
82
|
"peerDependencies": {
|
|
82
83
|
"zod": "^4.6.5"
|