@lloyal-labs/lloyal-agents 2.0.0 → 2.1.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.
- package/README.md +14 -14
- package/dist/Agent.d.ts +3 -3
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +2 -2
- package/dist/Agent.js.map +1 -1
- package/dist/AgentPolicy.d.ts +8 -8
- package/dist/AgentPolicy.d.ts.map +1 -1
- package/dist/AgentPolicy.js +10 -10
- package/dist/AgentPolicy.js.map +1 -1
- package/dist/Tool.d.ts +1 -1
- package/dist/Tool.js +1 -1
- package/dist/agent-pool.d.ts +4 -4
- package/dist/agent-pool.js +42 -42
- package/dist/agent-pool.js.map +1 -1
- package/dist/context.d.ts +10 -10
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +11 -11
- package/dist/context.js.map +1 -1
- package/dist/create-agent-pool.d.ts +10 -10
- package/dist/create-agent-pool.d.ts.map +1 -1
- package/dist/create-agent-pool.js +27 -27
- package/dist/create-agent-pool.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/orchestrators.d.ts +8 -8
- package/dist/orchestrators.d.ts.map +1 -1
- package/dist/orchestrators.js +10 -10
- package/dist/orchestrators.js.map +1 -1
- package/dist/replay.d.ts +19 -19
- package/dist/replay.d.ts.map +1 -1
- package/dist/replay.js +29 -29
- package/dist/replay.js.map +1 -1
- package/dist/spine.d.ts +106 -0
- package/dist/spine.d.ts.map +1 -0
- package/dist/{shared-root.js → spine.js} +40 -37
- package/dist/spine.js.map +1 -0
- package/dist/trace-types.d.ts +4 -4
- package/dist/trace-types.d.ts.map +1 -1
- package/dist/types.d.ts +20 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/use-agent.d.ts +3 -3
- package/dist/use-agent.d.ts.map +1 -1
- package/dist/use-agent.js +5 -5
- package/dist/use-agent.js.map +1 -1
- package/package.json +2 -2
- package/dist/shared-root.d.ts +0 -96
- package/dist/shared-root.d.ts.map +0 -1
- package/dist/shared-root.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-agent-pool.d.ts","sourceRoot":"","sources":["../src/create-agent-pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQpD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,WAAW,EAAE,YAAY,CAAC;IAC1B,qHAAqH;IACrH,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,iGAAiG;IACjG,
|
|
1
|
+
{"version":3,"file":"create-agent-pool.d.ts","sourceRoot":"","sources":["../src/create-agent-pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQpD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,WAAW,EAAE,YAAY,CAAC;IAC1B,qHAAqH;IACrH,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,iGAAiG;IACjG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uDAAuD;IACvD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,sCAAsC;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wEAAwE;IACxE,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,6CAA6C;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAiB,SAAS,CAAC,IAAI,EAAE,mBAAmB,GAAG,SAAS,CAAC,eAAe,CAAC,CA+DhF"}
|
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.agentPool = agentPool;
|
|
4
4
|
const context_1 = require("./context");
|
|
5
5
|
const toolkit_1 = require("./toolkit");
|
|
6
|
-
const
|
|
6
|
+
const spine_1 = require("./spine");
|
|
7
7
|
const agent_pool_1 = require("./agent-pool");
|
|
8
8
|
// ── agentPool ───────────────────────────────────────────────
|
|
9
9
|
/**
|
|
10
10
|
* Run a parallel agent pool with tools.
|
|
11
11
|
*
|
|
12
|
-
* Composes `
|
|
13
|
-
* Drains the Subscription inside `
|
|
12
|
+
* Composes `withSpine` + `createToolkit` + `useAgentPool` internally.
|
|
13
|
+
* Drains the Subscription inside `withSpine`'s body and forwards
|
|
14
14
|
* events to the broadcast Channel. Returns `AgentPoolResult` with
|
|
15
15
|
* branches pruned.
|
|
16
16
|
*
|
|
@@ -19,7 +19,7 @@ const agent_pool_1 = require("./agent-pool");
|
|
|
19
19
|
* const pool = yield* agentPool({
|
|
20
20
|
* tools: [delegateTool, ...source.tools, reportTool],
|
|
21
21
|
* orchestrate: parallel(questions.map(q => ({ content: q, systemPrompt: RESEARCH_PROMPT }))),
|
|
22
|
-
*
|
|
22
|
+
* terminalToolName: 'report',
|
|
23
23
|
* });
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
@@ -31,48 +31,48 @@ function* agentPool(opts) {
|
|
|
31
31
|
// Warm path priority: explicit parent > session trunk > cold
|
|
32
32
|
const warmParent = opts.parent ?? opts.session?.trunk ?? undefined;
|
|
33
33
|
const sharedMode = opts.systemPrompt !== undefined;
|
|
34
|
-
return yield* (0,
|
|
34
|
+
return yield* (0, spine_1.withSpine)({
|
|
35
35
|
parent: warmParent,
|
|
36
36
|
systemPrompt: opts.systemPrompt,
|
|
37
|
-
// Only emit
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
//
|
|
37
|
+
// Only emit tool schemas into the spine header in shared mode; the
|
|
38
|
+
// dispatcher (toolkit.toolMap) is registered on the useAgentPool
|
|
39
|
+
// below regardless.
|
|
40
|
+
tools: sharedMode ? opts.tools : undefined,
|
|
41
|
+
// Thread enableThinking so the spine header chat-format and the
|
|
42
|
+
// SpineFmt FormatConfig (parser/grammar/triggers) match what the
|
|
42
43
|
// per-agent suffixes get further down. Otherwise a caller passing
|
|
43
|
-
// enableThinking:true gets divergent grammar between
|
|
44
|
+
// enableThinking:true gets divergent grammar between spine + suffix.
|
|
44
45
|
enableThinking: opts.enableThinking,
|
|
45
|
-
}, function* (
|
|
46
|
-
// SHARED mode (systemPrompt set): the inner
|
|
47
|
-
// [system + tools] header
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
// not via root mutation.
|
|
46
|
+
}, function* (innerSpine) {
|
|
47
|
+
// SHARED mode (systemPrompt set): the inner spine carries the
|
|
48
|
+
// [system + tools] header. extendSpine writes onto it, agents fork
|
|
49
|
+
// from it, nested useAgent calls fork from it. Inner spine is pruned
|
|
50
|
+
// at withSpine exit; that's fine because pool findings flow to the
|
|
51
|
+
// session via session.commitTurn (post-pool), not via spine mutation.
|
|
52
52
|
//
|
|
53
53
|
// NON-SHARED mode (existing behavior): on warm path, use the caller-
|
|
54
|
-
// provided parent AS the logical spine so `ctx.
|
|
54
|
+
// provided parent AS the logical spine so `ctx.extendSpine` mutations
|
|
55
55
|
// persist across the pool's lifetime and are visible to sibling pools
|
|
56
|
-
// that fork from the same parent. The inner
|
|
56
|
+
// that fork from the same parent. The inner spine is just a
|
|
57
57
|
// separator-prefilled fork of parent — its extensions would be
|
|
58
58
|
// discarded at pool close, breaking the multi-task spine pattern
|
|
59
|
-
// (research → synth over shared
|
|
60
|
-
//
|
|
61
|
-
const
|
|
59
|
+
// (research → synth over shared spine). On cold path, the inner
|
|
60
|
+
// spine IS the persistent spine.
|
|
61
|
+
const spine = sharedMode ? innerSpine : (warmParent ?? innerSpine);
|
|
62
62
|
const sub = yield* (0, agent_pool_1.useAgentPool)({
|
|
63
|
-
|
|
63
|
+
spine,
|
|
64
64
|
orchestrate: opts.orchestrate,
|
|
65
65
|
toolsJson: toolkit.toolsJson,
|
|
66
66
|
tools: toolkit.toolMap,
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
terminalToolName: opts.terminalToolName,
|
|
68
|
+
pruneOnReturn: opts.pruneOnReturn,
|
|
69
69
|
maxTurns: opts.maxTurns,
|
|
70
70
|
trace: opts.trace,
|
|
71
71
|
policy: opts.policy,
|
|
72
72
|
scorer: opts.scorer,
|
|
73
73
|
enableThinking: opts.enableThinking,
|
|
74
74
|
});
|
|
75
|
-
// Drain Subscription inside body — before
|
|
75
|
+
// Drain Subscription inside body — before withSpine's finally fires
|
|
76
76
|
let next = yield* sub.next();
|
|
77
77
|
while (!next.done) {
|
|
78
78
|
yield* broadcast.send(next.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-agent-pool.js","sourceRoot":"","sources":["../src/create-agent-pool.ts"],"names":[],"mappings":";;AAwGA,8BA+DC;AA/JD,uCAAmC;AACnC,uCAA0C;AAC1C
|
|
1
|
+
{"version":3,"file":"create-agent-pool.js","sourceRoot":"","sources":["../src/create-agent-pool.ts"],"names":[],"mappings":";;AAwGA,8BA+DC;AA/JD,uCAAmC;AACnC,uCAA0C;AAC1C,mCAAoC;AACpC,6CAA4C;AAwE5C,+DAA+D;AAE/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAe,CAAC,CAAC,SAAS,CAAC,IAAyB;IAClD,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,gBAAM,CAAC,MAAM,EAAE,CAAC;IAEzC,MAAM,OAAO,GAAG,IAAA,uBAAa,EAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAEhD,6DAA6D;IAC7D,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,IAAI,SAAS,CAAC;IAEnE,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,KAAK,SAAS,CAAC;IAEnD,OAAO,KAAK,CAAC,CAAC,IAAA,iBAAS,EACrB;QACE,MAAM,EAAE,UAAU;QAClB,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,mEAAmE;QACnE,iEAAiE;QACjE,oBAAoB;QACpB,KAAK,EAAE,UAAU,CAAC,CAA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C;QAC3B,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { diverge } from './diverge';
|
|
|
17
17
|
export { useAgentPool, ContextPressure } from './agent-pool';
|
|
18
18
|
export { createToolkit } from './toolkit';
|
|
19
19
|
export { initAgents } from './init';
|
|
20
|
-
export {
|
|
20
|
+
export { withSpine } from './spine';
|
|
21
21
|
export { NullTraceWriter, JsonlTraceWriter } from './trace-writer';
|
|
22
22
|
export { traceScope } from './trace-scope';
|
|
23
23
|
export { composePrompt, renderPrompt, renderTemplate } from './prompt';
|
|
@@ -25,12 +25,12 @@ export type { PromptState, PromptSection, PromptStep } from './prompt';
|
|
|
25
25
|
export { reduce } from './combinators';
|
|
26
26
|
export { parallel, chain, fanout, dag } from './orchestrators';
|
|
27
27
|
export type { SpawnSpec, ChainStep, DAGNode, Orchestrator, PoolContext } from './orchestrators';
|
|
28
|
-
export {
|
|
28
|
+
export { extractSpineSeed, extractSpineCheckpoint, reconstructBranch } from './replay';
|
|
29
29
|
export type { BranchCheckpoint } from './replay';
|
|
30
30
|
export type { Toolkit } from './toolkit';
|
|
31
31
|
export type { TraceWriter } from './trace-writer';
|
|
32
32
|
export type { TraceEvent, TraceId } from './trace-types';
|
|
33
33
|
export type { AgentHandle } from './init';
|
|
34
|
-
export type {
|
|
34
|
+
export type { SpineOptions } from './spine';
|
|
35
35
|
export type { TraceToken, JsonSchema, ToolSchema, ToolContext, PressureThresholds, AgentTaskSpec, AgentPoolOptions, AgentResult, AgentPoolResult, DivergeOptions, DivergeAttempt, DivergeResult, AgentEvent, } from './types';
|
|
36
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,E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Branch = exports.extractSpineCheckpoint = exports.
|
|
3
|
+
exports.reconstructBranch = exports.extractSpineCheckpoint = exports.extractSpineSeed = exports.dag = exports.fanout = exports.chain = exports.parallel = exports.reduce = exports.renderTemplate = exports.renderPrompt = exports.composePrompt = exports.traceScope = exports.JsonlTraceWriter = exports.NullTraceWriter = exports.withSpine = exports.initAgents = exports.createToolkit = exports.ContextPressure = exports.useAgentPool = exports.diverge = exports.agentPool = exports.agent = exports.useAgent = exports.buildToolResultDelta = exports.buildUserDelta = exports.NULL_SCORER = exports.Source = exports.CallingAgent = exports.defaultToolGuards = exports.DefaultAgentPolicy = exports.Agent = exports.Tool = exports.ScratchpadParent = exports.TraceParent = exports.Trace = exports.Events = exports.Store = exports.Ctx = void 0;
|
|
4
4
|
var context_1 = require("./context");
|
|
5
5
|
Object.defineProperty(exports, "Ctx", { enumerable: true, get: function () { return context_1.Ctx; } });
|
|
6
6
|
Object.defineProperty(exports, "Store", { enumerable: true, get: function () { return context_1.Store; } });
|
|
@@ -38,8 +38,8 @@ var toolkit_1 = require("./toolkit");
|
|
|
38
38
|
Object.defineProperty(exports, "createToolkit", { enumerable: true, get: function () { return toolkit_1.createToolkit; } });
|
|
39
39
|
var init_1 = require("./init");
|
|
40
40
|
Object.defineProperty(exports, "initAgents", { enumerable: true, get: function () { return init_1.initAgents; } });
|
|
41
|
-
var
|
|
42
|
-
Object.defineProperty(exports, "
|
|
41
|
+
var spine_1 = require("./spine");
|
|
42
|
+
Object.defineProperty(exports, "withSpine", { enumerable: true, get: function () { return spine_1.withSpine; } });
|
|
43
43
|
var trace_writer_1 = require("./trace-writer");
|
|
44
44
|
Object.defineProperty(exports, "NullTraceWriter", { enumerable: true, get: function () { return trace_writer_1.NullTraceWriter; } });
|
|
45
45
|
Object.defineProperty(exports, "JsonlTraceWriter", { enumerable: true, get: function () { return trace_writer_1.JsonlTraceWriter; } });
|
|
@@ -57,7 +57,7 @@ Object.defineProperty(exports, "chain", { enumerable: true, get: function () { r
|
|
|
57
57
|
Object.defineProperty(exports, "fanout", { enumerable: true, get: function () { return orchestrators_1.fanout; } });
|
|
58
58
|
Object.defineProperty(exports, "dag", { enumerable: true, get: function () { return orchestrators_1.dag; } });
|
|
59
59
|
var replay_1 = require("./replay");
|
|
60
|
-
Object.defineProperty(exports, "
|
|
60
|
+
Object.defineProperty(exports, "extractSpineSeed", { enumerable: true, get: function () { return replay_1.extractSpineSeed; } });
|
|
61
61
|
Object.defineProperty(exports, "extractSpineCheckpoint", { enumerable: true, get: function () { return replay_1.extractSpineCheckpoint; } });
|
|
62
62
|
Object.defineProperty(exports, "reconstructBranch", { enumerable: true, get: function () { return replay_1.reconstructBranch; } });
|
|
63
63
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAAqF;AAA5E,8FAAA,GAAG,OAAA;AAAE,gGAAA,KAAK,OAAA;AAAE,iGAAA,MAAM,OAAA;AAAE,gGAAA,KAAK,OAAA;AAAE,sGAAA,WAAW,OAAA;AAAE,2GAAA,gBAAgB,OAAA;AACjE,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AAEd,6CAAmD;AAA1C,iHAAA,kBAAkB,OAAA;AAE3B,6CAAkD;AAAzC,gHAAA,iBAAiB,OAAA;AAC1B,qCAAyC;AAAhC,uGAAA,YAAY,OAAA;AACrB,mCAA+C;AAAtC,gGAAA,MAAM,OAAA;AAAE,qGAAA,WAAW,OAAA;AAE5B,wCAAwE;AAA/D,qGAAA,cAAc,OAAA;AAAE,2GAAA,oBAAoB,OAAA;AAC7C,yCAA8C;AAArC,qGAAA,QAAQ,OAAA;AAAE,kGAAA,KAAK,OAAA;AAExB,yDAAgD;AAAvC,8GAAA,SAAS,OAAA;AAElB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AA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sGAAA,YAAY,OAAA;AAAE,wGAAA,cAAc,OAAA;AAEpD,6CAAuC;AAA9B,qGAAA,MAAM,OAAA;AACf,iDAA+D;AAAtD,yGAAA,QAAQ,OAAA;AAAE,sGAAA,KAAK,OAAA;AAAE,uGAAA,MAAM,OAAA;AAAE,oGAAA,GAAG,OAAA;AAErC,mCAAuF;AAA9E,0GAAA,gBAAgB,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAAE,2GAAA,iBAAiB,OAAA"}
|
package/dist/orchestrators.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Branch } from '@lloyal-labs/sdk';
|
|
|
3
3
|
import type { Agent } from './Agent';
|
|
4
4
|
/**
|
|
5
5
|
* Spec for spawning a single agent under a {@link PoolContext}.
|
|
6
|
-
* `parent` defaults to `ctx.
|
|
6
|
+
* `parent` defaults to `ctx.spine`.
|
|
7
7
|
*
|
|
8
8
|
* @category Agents
|
|
9
9
|
*/
|
|
@@ -14,7 +14,7 @@ export interface SpawnSpec {
|
|
|
14
14
|
systemPrompt: string;
|
|
15
15
|
/** PRNG seed for sampler diversity. */
|
|
16
16
|
seed?: number;
|
|
17
|
-
/** Parent branch to fork from. Falls back to ctx.
|
|
17
|
+
/** Parent branch to fork from. Falls back to ctx.spine. */
|
|
18
18
|
parent?: Branch;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
@@ -27,17 +27,17 @@ export interface SpawnSpec {
|
|
|
27
27
|
* @category Agents
|
|
28
28
|
*/
|
|
29
29
|
export interface PoolContext {
|
|
30
|
-
/**
|
|
31
|
-
readonly
|
|
30
|
+
/** The pool's spine branch. Orchestrator-provided spawns fork from here by default. */
|
|
31
|
+
readonly spine: Branch;
|
|
32
32
|
/** Fork an agent branch, prefill its suffix, transition to active. Tick loop picks it up. */
|
|
33
33
|
spawn(spec: SpawnSpec): Operation<Agent>;
|
|
34
34
|
/** Suspend until agent.status becomes 'idle' | 'disposed'. Returns agent for chaining. */
|
|
35
35
|
waitFor(agent: Agent): Operation<Agent>;
|
|
36
36
|
/**
|
|
37
|
-
* Serialize a user+assistant turn and prefill it into
|
|
37
|
+
* Serialize a user+assistant turn and prefill it into the spine, advancing spine.position.
|
|
38
38
|
* No-op (returns 0) when assistantContent is empty.
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
extendSpine(userContent: string, assistantContent: string): Operation<number>;
|
|
41
41
|
/** Whether another spawn with this suffix size would fit under current pressure. */
|
|
42
42
|
canFit(estimatedSuffixTokens: number): boolean;
|
|
43
43
|
}
|
|
@@ -82,7 +82,7 @@ export interface ChainStep {
|
|
|
82
82
|
/** Fires BEFORE `ctx.spawn` for this step. Use for "task starting" events. */
|
|
83
83
|
beforeSpawn?: () => Operation<void>;
|
|
84
84
|
/**
|
|
85
|
-
* Fires AFTER `ctx.
|
|
85
|
+
* Fires AFTER `ctx.extendSpine` for this step (or immediately after waitFor
|
|
86
86
|
* if no extension happened). Receives the number of tokens added to the
|
|
87
87
|
* spine (0 when no extension) and the root's position after any extension.
|
|
88
88
|
* Use for "task done" events with spine telemetry.
|
|
@@ -101,7 +101,7 @@ export interface ChainStep {
|
|
|
101
101
|
* ```ts
|
|
102
102
|
* yield* agentPool({
|
|
103
103
|
* tools: [...],
|
|
104
|
-
* parent:
|
|
104
|
+
* parent: querySpine,
|
|
105
105
|
* orchestrate: chain(researchTasks, (task, i) => ({
|
|
106
106
|
* task: { content: taskToContent(task), systemPrompt: renderWorker({ taskIndex: i }) },
|
|
107
107
|
* userContent: `Research task: ${task.description}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrators.d.ts","sourceRoot":"","sources":["../src/orchestrators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAQ,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;GAKG;AACH,MA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;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,SAAS,EAAE,KAAG,YAI3C,CAAC;AAEJ;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,SAAS,CAAC;IAChB,+FAA+F;IAC/F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;IACpC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC;CACpE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,EACrB,OAAO,CAAC,EAAE,EACV,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,KAC5C,YAaA,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,MAAM,GAAI,WAAW,SAAS,EAAE,SAAS,SAAS,EAAE,KAAG,YAajE,CAAC;AAEJ;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,uFAAuF;IACvF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,GAAG,GAAI,OAAO,OAAO,EAAE,KAAG,YA0CtC,CAAC"}
|
package/dist/orchestrators.js
CHANGED
|
@@ -18,7 +18,7 @@ const effection_1 = require("effection");
|
|
|
18
18
|
* @category Agents
|
|
19
19
|
*/
|
|
20
20
|
const parallel = (tasks) => function* (ctx) {
|
|
21
|
-
const agents = yield* (0, effection_1.all)(tasks.map(t => ctx.spawn({ ...t, parent: t.parent ?? ctx.
|
|
21
|
+
const agents = yield* (0, effection_1.all)(tasks.map(t => ctx.spawn({ ...t, parent: t.parent ?? ctx.spine })));
|
|
22
22
|
yield* (0, effection_1.all)(agents.map(a => ctx.waitFor(a)));
|
|
23
23
|
};
|
|
24
24
|
exports.parallel = parallel;
|
|
@@ -34,7 +34,7 @@ exports.parallel = parallel;
|
|
|
34
34
|
* ```ts
|
|
35
35
|
* yield* agentPool({
|
|
36
36
|
* tools: [...],
|
|
37
|
-
* parent:
|
|
37
|
+
* parent: querySpine,
|
|
38
38
|
* orchestrate: chain(researchTasks, (task, i) => ({
|
|
39
39
|
* task: { content: taskToContent(task), systemPrompt: renderWorker({ taskIndex: i }) },
|
|
40
40
|
* userContent: `Research task: ${task.description}`,
|
|
@@ -49,12 +49,12 @@ const chain = (items, toStep) => function* (ctx) {
|
|
|
49
49
|
const step = toStep(item, i);
|
|
50
50
|
if (step.beforeSpawn)
|
|
51
51
|
yield* step.beforeSpawn();
|
|
52
|
-
const agent = yield* ctx.waitFor(yield* ctx.spawn({ ...step.task, parent: step.task.parent ?? ctx.
|
|
52
|
+
const agent = yield* ctx.waitFor(yield* ctx.spawn({ ...step.task, parent: step.task.parent ?? ctx.spine }));
|
|
53
53
|
const delta = agent.result && step.userContent
|
|
54
|
-
? yield* ctx.
|
|
54
|
+
? yield* ctx.extendSpine(step.userContent, agent.result)
|
|
55
55
|
: 0;
|
|
56
56
|
if (step.afterExtend)
|
|
57
|
-
yield* step.afterExtend(delta, ctx.
|
|
57
|
+
yield* step.afterExtend(delta, ctx.spine.position);
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
exports.chain = chain;
|
|
@@ -79,11 +79,11 @@ exports.chain = chain;
|
|
|
79
79
|
* @category Agents
|
|
80
80
|
*/
|
|
81
81
|
const fanout = (landscape, domains) => function* (ctx) {
|
|
82
|
-
const l = yield* ctx.waitFor(yield* ctx.spawn({ ...landscape.task, parent: landscape.task.parent ?? ctx.
|
|
82
|
+
const l = yield* ctx.waitFor(yield* ctx.spawn({ ...landscape.task, parent: landscape.task.parent ?? ctx.spine }));
|
|
83
83
|
if (l.result && landscape.userContent) {
|
|
84
|
-
yield* ctx.
|
|
84
|
+
yield* ctx.extendSpine(landscape.userContent, l.result);
|
|
85
85
|
}
|
|
86
|
-
const agents = yield* (0, effection_1.all)(domains.map(d => ctx.spawn({ ...d, parent: d.parent ?? ctx.
|
|
86
|
+
const agents = yield* (0, effection_1.all)(domains.map(d => ctx.spawn({ ...d, parent: d.parent ?? ctx.spine })));
|
|
87
87
|
yield* (0, effection_1.all)(agents.map(a => ctx.waitFor(a)));
|
|
88
88
|
};
|
|
89
89
|
exports.fanout = fanout;
|
|
@@ -123,9 +123,9 @@ const dag = (nodes) => {
|
|
|
123
123
|
for (const depId of n.dependsOn ?? []) {
|
|
124
124
|
yield* tasks.get(depId);
|
|
125
125
|
}
|
|
126
|
-
const agent = yield* ctx.waitFor(yield* ctx.spawn({ ...n.task, parent: n.task.parent ?? ctx.
|
|
126
|
+
const agent = yield* ctx.waitFor(yield* ctx.spawn({ ...n.task, parent: n.task.parent ?? ctx.spine }));
|
|
127
127
|
if (agent.result && n.userContent) {
|
|
128
|
-
yield* ctx.
|
|
128
|
+
yield* ctx.extendSpine(n.userContent, agent.result);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
for (const n of nodes) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrators.js","sourceRoot":"","sources":["../src/orchestrators.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AA2DvC,kEAAkE;AAElE;;;;;;;;;;;;;GAaG;AACI,MAAM,QAAQ,GAAG,CAAC,KAAkB,EAAgB,EAAE,CAC3D,QAAQ,CAAC,EAAE,GAAG;IACZ,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,IAAA,eAAG,EAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,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5
|
* Serialized state needed to reconstruct a Branch deterministically.
|
|
6
6
|
*
|
|
7
|
-
* `
|
|
7
|
+
* `seedPrompt` is the tokenized prompt that initialized a spine — the
|
|
8
8
|
* full formatted chat template including system prompt and any tool schemas.
|
|
9
|
-
* Captured from `prompt:format` events with `role: '
|
|
9
|
+
* Captured from `prompt:format` events with `role: 'spine'`.
|
|
10
10
|
*
|
|
11
11
|
* `turns` is an ordered list of user/assistant turn pairs that were prefilled
|
|
12
|
-
* on top of the
|
|
12
|
+
* on top of the spine via {@link extendSpine}. Empty for pool-start replay
|
|
13
13
|
* (any orchestration shape that doesn't extend the spine — e.g. `parallel`);
|
|
14
14
|
* populated for spine-extending orchestrations (`chain`, `fanout`, `dag`).
|
|
15
15
|
*
|
|
16
16
|
* @category Agents
|
|
17
17
|
*/
|
|
18
18
|
export interface BranchCheckpoint {
|
|
19
|
-
|
|
19
|
+
seedPrompt: string;
|
|
20
20
|
turns: Array<{
|
|
21
21
|
userContent: string;
|
|
22
22
|
assistantContent: string;
|
|
23
23
|
}>;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Extract the
|
|
26
|
+
* Extract the spine seed prompt from a trace, with no spine extensions.
|
|
27
27
|
*
|
|
28
28
|
* Useful for replaying parallel orchestrations, or for forking a fresh
|
|
29
29
|
* agent off the same pool-start state for A/B experiments.
|
|
30
30
|
*
|
|
31
31
|
* @param events - parsed JSONL trace events, in emission order
|
|
32
|
-
* @throws If no `prompt:format` event with `role: '
|
|
32
|
+
* @throws If no `prompt:format` event with `role: 'spine'` is found.
|
|
33
33
|
*
|
|
34
34
|
* @category Agents
|
|
35
35
|
*/
|
|
36
|
-
export declare function
|
|
36
|
+
export declare function extractSpineSeed(events: TraceEvent[]): BranchCheckpoint;
|
|
37
37
|
/**
|
|
38
|
-
* Extract a full spine checkpoint —
|
|
39
|
-
* event in emission order.
|
|
38
|
+
* Extract a full spine checkpoint — spine seed prompt plus every
|
|
39
|
+
* `spine:extend` event in emission order.
|
|
40
40
|
*
|
|
41
41
|
* When `opts.poolTraceId` is set, only spine extensions under that pool's
|
|
42
42
|
* scope are included (useful when a trace contains multiple nested or
|
|
43
43
|
* sequential pools with independent spines — typically the research pool
|
|
44
|
-
* vs. a later synthesis pool, both extending their own
|
|
44
|
+
* vs. a later synthesis pool, both extending their own spines).
|
|
45
45
|
*
|
|
46
46
|
* @param events - parsed JSONL trace events, in emission order
|
|
47
47
|
* @param opts.poolTraceId - filter extensions to this pool's scope
|
|
48
|
-
* @throws If no
|
|
48
|
+
* @throws If no spine seed prompt is found.
|
|
49
49
|
*
|
|
50
50
|
* @category Agents
|
|
51
51
|
*/
|
|
@@ -55,11 +55,11 @@ export declare function extractSpineCheckpoint(events: TraceEvent[], opts?: {
|
|
|
55
55
|
/**
|
|
56
56
|
* Materialize a Branch reflecting the checkpointed state.
|
|
57
57
|
*
|
|
58
|
-
* Creates a fresh
|
|
59
|
-
* the tokenized
|
|
58
|
+
* Creates a fresh spine at position 0 in the active `SessionContext`, prefills
|
|
59
|
+
* the tokenized seed prompt, then applies each turn delta via `buildTurnDelta`
|
|
60
60
|
* + `store.prefill`. Registers an `ensure()` so the subtree is pruned when
|
|
61
61
|
* the caller's scope exits — lifetime follows the enclosing `scoped()` or
|
|
62
|
-
* `resource()`, matching how `
|
|
62
|
+
* `resource()`, matching how `withSpine` manages its own spine.
|
|
63
63
|
*
|
|
64
64
|
* Pass the returned branch as `parent` to `agentPool` to run a replacement
|
|
65
65
|
* stage (synth re-run, single-agent replay with modified prompt, etc.) against
|
|
@@ -68,10 +68,10 @@ export declare function extractSpineCheckpoint(events: TraceEvent[], opts?: {
|
|
|
68
68
|
* @example Replay a pool-start (parallel orchestration) with a modified task
|
|
69
69
|
* ```ts
|
|
70
70
|
* const events = parseTrace(tracePath);
|
|
71
|
-
* const checkpoint =
|
|
72
|
-
* const
|
|
71
|
+
* const checkpoint = extractSpineSeed(events);
|
|
72
|
+
* const spine = yield* reconstructBranch(checkpoint);
|
|
73
73
|
* yield* agentPool({
|
|
74
|
-
* parent:
|
|
74
|
+
* parent: spine,
|
|
75
75
|
* orchestrate: parallel([{ content: modifiedTask, systemPrompt: modifiedSys }]),
|
|
76
76
|
* ...
|
|
77
77
|
* });
|
|
@@ -81,9 +81,9 @@ export declare function extractSpineCheckpoint(events: TraceEvent[], opts?: {
|
|
|
81
81
|
* ```ts
|
|
82
82
|
* const events = parseTrace(tracePath);
|
|
83
83
|
* const checkpoint = extractSpineCheckpoint(events);
|
|
84
|
-
* const
|
|
84
|
+
* const spine = yield* reconstructBranch(checkpoint);
|
|
85
85
|
* yield* agentPool({
|
|
86
|
-
* parent:
|
|
86
|
+
* parent: spine,
|
|
87
87
|
* orchestrate: parallel([{ content: SYNTHESIZE.user }]),
|
|
88
88
|
* systemPrompt: SYNTHESIZE.system,
|
|
89
89
|
* ...
|
package/dist/replay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAkB,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAkB,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,gBAAgB,CAWvE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,UAAU,EAAE,EACpB,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GAClC,gBAAgB,CASlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAiB,iBAAiB,CAAC,UAAU,EAAE,gBAAgB,GAAG,SAAS,CAAC,MAAM,CAAC,CAgBlF"}
|
package/dist/replay.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.extractSpineSeed = extractSpineSeed;
|
|
4
4
|
exports.extractSpineCheckpoint = extractSpineCheckpoint;
|
|
5
5
|
exports.reconstructBranch = reconstructBranch;
|
|
6
6
|
const effection_1 = require("effection");
|
|
7
7
|
const sdk_1 = require("@lloyal-labs/sdk");
|
|
8
8
|
const context_1 = require("./context");
|
|
9
9
|
/**
|
|
10
|
-
* Extract the
|
|
10
|
+
* Extract the spine seed prompt from a trace, with no spine extensions.
|
|
11
11
|
*
|
|
12
12
|
* Useful for replaying parallel orchestrations, or for forking a fresh
|
|
13
13
|
* agent off the same pool-start state for A/B experiments.
|
|
14
14
|
*
|
|
15
15
|
* @param events - parsed JSONL trace events, in emission order
|
|
16
|
-
* @throws If no `prompt:format` event with `role: '
|
|
16
|
+
* @throws If no `prompt:format` event with `role: 'spine'` is found.
|
|
17
17
|
*
|
|
18
18
|
* @category Agents
|
|
19
19
|
*/
|
|
20
|
-
function
|
|
21
|
-
const
|
|
22
|
-
if (!
|
|
23
|
-
throw new Error('
|
|
20
|
+
function extractSpineSeed(events) {
|
|
21
|
+
const seed = events.find((e) => e.type === 'prompt:format' && e.role === 'spine');
|
|
22
|
+
if (!seed) {
|
|
23
|
+
throw new Error('extractSpineSeed: no prompt:format event with role=spine found in trace');
|
|
24
24
|
}
|
|
25
|
-
return {
|
|
25
|
+
return { seedPrompt: seed.promptText, turns: [] };
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Extract a full spine checkpoint —
|
|
29
|
-
* event in emission order.
|
|
28
|
+
* Extract a full spine checkpoint — spine seed prompt plus every
|
|
29
|
+
* `spine:extend` event in emission order.
|
|
30
30
|
*
|
|
31
31
|
* When `opts.poolTraceId` is set, only spine extensions under that pool's
|
|
32
32
|
* scope are included (useful when a trace contains multiple nested or
|
|
33
33
|
* sequential pools with independent spines — typically the research pool
|
|
34
|
-
* vs. a later synthesis pool, both extending their own
|
|
34
|
+
* vs. a later synthesis pool, both extending their own spines).
|
|
35
35
|
*
|
|
36
36
|
* @param events - parsed JSONL trace events, in emission order
|
|
37
37
|
* @param opts.poolTraceId - filter extensions to this pool's scope
|
|
38
|
-
* @throws If no
|
|
38
|
+
* @throws If no spine seed prompt is found.
|
|
39
39
|
*
|
|
40
40
|
* @category Agents
|
|
41
41
|
*/
|
|
42
42
|
function extractSpineCheckpoint(events, opts = {}) {
|
|
43
|
-
const
|
|
43
|
+
const seed = extractSpineSeed(events);
|
|
44
44
|
const turns = [];
|
|
45
45
|
for (const e of events) {
|
|
46
46
|
if (e.type !== 'spine:extend')
|
|
@@ -49,16 +49,16 @@ function extractSpineCheckpoint(events, opts = {}) {
|
|
|
49
49
|
continue;
|
|
50
50
|
turns.push({ userContent: e.userContent, assistantContent: e.assistantContent });
|
|
51
51
|
}
|
|
52
|
-
return {
|
|
52
|
+
return { seedPrompt: seed.seedPrompt, turns };
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Materialize a Branch reflecting the checkpointed state.
|
|
56
56
|
*
|
|
57
|
-
* Creates a fresh
|
|
58
|
-
* the tokenized
|
|
57
|
+
* Creates a fresh spine at position 0 in the active `SessionContext`, prefills
|
|
58
|
+
* the tokenized seed prompt, then applies each turn delta via `buildTurnDelta`
|
|
59
59
|
* + `store.prefill`. Registers an `ensure()` so the subtree is pruned when
|
|
60
60
|
* the caller's scope exits — lifetime follows the enclosing `scoped()` or
|
|
61
|
-
* `resource()`, matching how `
|
|
61
|
+
* `resource()`, matching how `withSpine` manages its own spine.
|
|
62
62
|
*
|
|
63
63
|
* Pass the returned branch as `parent` to `agentPool` to run a replacement
|
|
64
64
|
* stage (synth re-run, single-agent replay with modified prompt, etc.) against
|
|
@@ -67,10 +67,10 @@ function extractSpineCheckpoint(events, opts = {}) {
|
|
|
67
67
|
* @example Replay a pool-start (parallel orchestration) with a modified task
|
|
68
68
|
* ```ts
|
|
69
69
|
* const events = parseTrace(tracePath);
|
|
70
|
-
* const checkpoint =
|
|
71
|
-
* const
|
|
70
|
+
* const checkpoint = extractSpineSeed(events);
|
|
71
|
+
* const spine = yield* reconstructBranch(checkpoint);
|
|
72
72
|
* yield* agentPool({
|
|
73
|
-
* parent:
|
|
73
|
+
* parent: spine,
|
|
74
74
|
* orchestrate: parallel([{ content: modifiedTask, systemPrompt: modifiedSys }]),
|
|
75
75
|
* ...
|
|
76
76
|
* });
|
|
@@ -80,9 +80,9 @@ function extractSpineCheckpoint(events, opts = {}) {
|
|
|
80
80
|
* ```ts
|
|
81
81
|
* const events = parseTrace(tracePath);
|
|
82
82
|
* const checkpoint = extractSpineCheckpoint(events);
|
|
83
|
-
* const
|
|
83
|
+
* const spine = yield* reconstructBranch(checkpoint);
|
|
84
84
|
* yield* agentPool({
|
|
85
|
-
* parent:
|
|
85
|
+
* parent: spine,
|
|
86
86
|
* orchestrate: parallel([{ content: SYNTHESIZE.user }]),
|
|
87
87
|
* systemPrompt: SYNTHESIZE.system,
|
|
88
88
|
* ...
|
|
@@ -94,15 +94,15 @@ function extractSpineCheckpoint(events, opts = {}) {
|
|
|
94
94
|
function* reconstructBranch(checkpoint) {
|
|
95
95
|
const ctx = yield* context_1.Ctx.expect();
|
|
96
96
|
const store = yield* context_1.Store.expect();
|
|
97
|
-
const
|
|
98
|
-
yield* (0, effection_1.ensure)(() => { if (!
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
yield* (0, effection_1.call)(() =>
|
|
97
|
+
const spine = sdk_1.Branch.create(ctx, 0, {});
|
|
98
|
+
yield* (0, effection_1.ensure)(() => { if (!spine.disposed)
|
|
99
|
+
spine.pruneSubtreeSync(); });
|
|
100
|
+
const seedTokens = ctx.tokenizeSync(checkpoint.seedPrompt, false);
|
|
101
|
+
yield* (0, effection_1.call)(() => spine.prefill(seedTokens));
|
|
102
102
|
for (const turn of checkpoint.turns) {
|
|
103
103
|
const delta = (0, sdk_1.buildTurnDelta)(ctx, turn.userContent, turn.assistantContent);
|
|
104
|
-
yield* (0, effection_1.call)(() => store.prefill([[
|
|
104
|
+
yield* (0, effection_1.call)(() => store.prefill([[spine, delta]]));
|
|
105
105
|
}
|
|
106
|
-
return
|
|
106
|
+
return spine;
|
|
107
107
|
}
|
|
108
108
|
//# sourceMappingURL=replay.js.map
|
package/dist/replay.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":";;AAoCA,
|
|
1
|
+
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":";;AAoCA,4CAWC;AAiBD,wDAYC;AA0CD,8CAgBC;AAtID,yCAAyC;AAEzC,0CAA0D;AAC1D,uCAAuC;AAsBvC;;;;;;;;;;GAUG;AACH,SAAgB,g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