@nylorun/harness 0.33.0-beta → 0.34.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 +19 -0
- package/dist/api/run.js +2 -0
- package/dist/loop/delegation.d.ts +6 -0
- package/dist/loop/run.js +26 -0
- package/dist/run/durable.d.ts +9 -1
- package/dist/run/durable.js +25 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.34.0-beta
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c649f33: A message can steer a running turn (D85). `delivery: "steer"` on a `message` command, behind the
|
|
8
|
+
optional Host feature `steer`: to a busy agent session it waits in the session queue marked
|
|
9
|
+
`steer`, and our engine takes it into the running turn before its next step, after the tool
|
|
10
|
+
results, through a new effect kind, `inputs`, which core answers in the transaction that journals
|
|
11
|
+
it (Harness API 5, `harness-api/v5.4.json`). Each taken message's `command.message` is written
|
|
12
|
+
under the running turn, then `queue.taken` with the `step`. The queued answer and
|
|
13
|
+
`message.queued` say which delivery applied; a workflow session queues. A steer the turn doesn't
|
|
14
|
+
take starts the next turn like any queued message, and D76's defaults never choose steer.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Pin core to the tested release.
|
|
19
|
+
- Updated dependencies [c649f33]
|
|
20
|
+
- @nylorun/core@0.37.0-beta
|
|
21
|
+
|
|
3
22
|
## 0.33.0-beta
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/dist/api/run.js
CHANGED
|
@@ -125,6 +125,8 @@ export async function runTurn(ctx, run) {
|
|
|
125
125
|
// Another session wrote the memory since this one's last turn: its index again.
|
|
126
126
|
...(memory?.refresh ? { refreshPinned: true } : {}),
|
|
127
127
|
...(start.options.yieldAfter ? { yieldAfter: start.options.yieldAfter } : {}),
|
|
128
|
+
// Core answers the `inputs` effect (D85): messages steered into the turn.
|
|
129
|
+
takeInputs: true,
|
|
128
130
|
...(start.model ? { model: start.model } : {}),
|
|
129
131
|
files: filesOf(ctx, run, start, start.manifest.engine),
|
|
130
132
|
loop: ctx.engine.loop,
|
|
@@ -40,6 +40,12 @@ export interface ExecuteInternals {
|
|
|
40
40
|
};
|
|
41
41
|
/** The loop's settings (compaction, a failed child's partial output). Default `DEFAULT_LOOP_CONFIG`. */
|
|
42
42
|
readonly loop?: LoopConfig;
|
|
43
|
+
/**
|
|
44
|
+
* The messages steered into the running turn (D85), asked before every step but the turn's
|
|
45
|
+
* first: each one's input as its message gave it, which the loop reads as a user message. Set
|
|
46
|
+
* for the root invocation only; an agent used as a tool never takes them.
|
|
47
|
+
*/
|
|
48
|
+
readonly takeInputs?: (turnId: string, stepNumber: number) => Promise<readonly unknown[]>;
|
|
43
49
|
}
|
|
44
50
|
/** Codes are curated: a child's provider error bodies never reach the parent's context. */
|
|
45
51
|
export declare const INTERACTION_UNSUPPORTED = "Agents used as tools can't ask for input, approval or a wait yet; do this work on the parent agent.";
|
package/dist/loop/run.js
CHANGED
|
@@ -2,6 +2,7 @@ import { HostSuspension } from "./host-suspension.js";
|
|
|
2
2
|
import { HarnessError, isHarnessError } from "@nylorun/core/define";
|
|
3
3
|
import { runStep } from "./step/run.js";
|
|
4
4
|
import { compact, contextBudget, estimateTokens } from "./compaction/index.js";
|
|
5
|
+
import { normalizeInput } from "./state.js";
|
|
5
6
|
import { createId } from "../utils/ids.js";
|
|
6
7
|
import { dispatchPlan } from "./dispatch.js";
|
|
7
8
|
import { createInvocation } from "./invocation.js";
|
|
@@ -114,6 +115,31 @@ export async function execute(agent, options, internals = {}) {
|
|
|
114
115
|
invocation.state = { ...invocation.state, turn: { turnId } };
|
|
115
116
|
return finish({ status: "yielded" });
|
|
116
117
|
}
|
|
118
|
+
// Messages steered into the running turn (D85): every step but the turn's first may take
|
|
119
|
+
// them, after the tool results the model sees next, and never while a plan dispatches.
|
|
120
|
+
if (internals.takeInputs && stepNumber > 1 && !invocation.state.plan) {
|
|
121
|
+
// Each is a message's input as sent (text, or a user message with parts), as at turn start.
|
|
122
|
+
const steered = (await internals.takeInputs(turnId, stepNumber)).flatMap((value) => {
|
|
123
|
+
try {
|
|
124
|
+
const event = normalizeInput(value);
|
|
125
|
+
return event.kind === "user-message" ? [event] : [];
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
if (steered.length > 0) {
|
|
132
|
+
invocation.state = {
|
|
133
|
+
...invocation.state,
|
|
134
|
+
transcript: [
|
|
135
|
+
...invocation.state.transcript,
|
|
136
|
+
...steered.map((event) => ({ kind: "input", turnId, event })),
|
|
137
|
+
],
|
|
138
|
+
};
|
|
139
|
+
await record();
|
|
140
|
+
arrivals = steered;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
117
143
|
stepsRun++;
|
|
118
144
|
const stepId = createId("step");
|
|
119
145
|
// Keep the next prompt inside the model's window, before it is sent.
|
package/dist/run/durable.d.ts
CHANGED
|
@@ -32,8 +32,10 @@ export interface HostEffect {
|
|
|
32
32
|
/**
|
|
33
33
|
* `delegation` journals when an agent used as a tool starts and settles; hosts record it and resolve it at once.
|
|
34
34
|
* Flow effects: `agent` and `tool` (node) — each carries `path`, `key`, and `iterations`.
|
|
35
|
+
* `inputs` (D85) takes the messages steered into the running turn before a step; hosts answer it
|
|
36
|
+
* at once with `{events}`.
|
|
35
37
|
*/
|
|
36
|
-
readonly kind: "model" | "tool" | "delegation" | "agent";
|
|
38
|
+
readonly kind: "model" | "tool" | "delegation" | "agent" | "inputs";
|
|
37
39
|
/** Set on work for an agent used as a tool; `agentId` stays the session's root agent. */
|
|
38
40
|
readonly agent?: AgentRef;
|
|
39
41
|
/** The name the model called a tool by, for display; the record routes by `target`. */
|
|
@@ -141,6 +143,12 @@ export declare function runDurable(options: {
|
|
|
141
143
|
readonly steps?: number;
|
|
142
144
|
readonly ms?: number;
|
|
143
145
|
};
|
|
146
|
+
/**
|
|
147
|
+
* Ask the host for the messages steered into the turn (D85) before every step but its first:
|
|
148
|
+
* an `inputs` effect, which a host that serves it answers at once with `{events}`. Off unless
|
|
149
|
+
* set; the Harness API run sets it, since core serves it. Not hashed.
|
|
150
|
+
*/
|
|
151
|
+
takeInputs?: boolean;
|
|
144
152
|
/** The model the turn's calls use (`turn.start.model`), for the root and every child. */
|
|
145
153
|
model?: ModelDescriptor;
|
|
146
154
|
/** How the turn's files reach the model (`representFiles`), for the root and every child. */
|
package/dist/run/durable.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HarnessError } from "@nylorun/core/define";
|
|
2
|
-
import { effectIdOf } from "@nylorun/core/harness-api";
|
|
2
|
+
import { effectIdOf, HarnessApiError, } from "@nylorun/core/harness-api";
|
|
3
3
|
import { engineFeaturesOf } from "@nylorun/core/engine";
|
|
4
4
|
import { AgentManifestSchema, checkMemoryCall } from "@nylorun/core/contracts";
|
|
5
5
|
import { agentFrom, withHttpTarget } from "@nylorun/core/define";
|
|
@@ -201,6 +201,29 @@ export async function runDurable(options) {
|
|
|
201
201
|
});
|
|
202
202
|
},
|
|
203
203
|
};
|
|
204
|
+
/**
|
|
205
|
+
* The messages steered into the root's turn (D85), before step `stepNumber`: an `inputs`
|
|
206
|
+
* effect, journaled by core even when empty, so a replay takes the same at the same step. A
|
|
207
|
+
* core that doesn't know the kind (`invalid`) turns taking off for this run: its steers start
|
|
208
|
+
* the next turn instead.
|
|
209
|
+
*/
|
|
210
|
+
let takesInputs = true;
|
|
211
|
+
const takeInputs = async (turnId, stepNumber) => {
|
|
212
|
+
if (!takesInputs)
|
|
213
|
+
return [];
|
|
214
|
+
try {
|
|
215
|
+
const outcome = await effect("inputs", { step: stepNumber }, { turnId, stepNumber }, `step:${stepNumber}`);
|
|
216
|
+
const events = outcome.value?.events;
|
|
217
|
+
return Array.isArray(events) ? events : [];
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
if (error instanceof HarnessApiError && error.code === "invalid") {
|
|
221
|
+
takesInputs = false;
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
throw error;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
204
227
|
const hosted = hostedDefinition(manifest);
|
|
205
228
|
// Manifest reconstruction must retain definition identity, including schemas and instructions.
|
|
206
229
|
if (hosted.hash !== checkpoint.manifestHash)
|
|
@@ -217,6 +240,7 @@ export async function runDurable(options) {
|
|
|
217
240
|
...(options.files === undefined ? {} : { files: options.files }),
|
|
218
241
|
}, {
|
|
219
242
|
delegation,
|
|
243
|
+
...(options.takeInputs ? { takeInputs } : {}),
|
|
220
244
|
...(options.yieldAfter ? { yieldAfter: options.yieldAfter } : {}),
|
|
221
245
|
...(options.loop ? { loop: options.loop } : {}),
|
|
222
246
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nylorun/harness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.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",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"zod": "^4.6.7"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@nylorun/core": "0.
|
|
80
|
+
"@nylorun/core": "0.37.0-beta"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"zod": "^4.6.7"
|