@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.
@@ -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 executor round trip.
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, { request: ctx.request, invocationId: ctx.invocationId }, scoped(ref, ctx.invocationId), ref ? { agent: ref } : {})).value;
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.19.2-beta",
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.7.0-beta"
80
+ "@nylorun/core": "0.9.0-beta"
80
81
  },
81
82
  "peerDependencies": {
82
83
  "zod": "^4.6.5"