@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.
Files changed (50) hide show
  1. package/README.md +14 -14
  2. package/dist/Agent.d.ts +3 -3
  3. package/dist/Agent.d.ts.map +1 -1
  4. package/dist/Agent.js +2 -2
  5. package/dist/Agent.js.map +1 -1
  6. package/dist/AgentPolicy.d.ts +8 -8
  7. package/dist/AgentPolicy.d.ts.map +1 -1
  8. package/dist/AgentPolicy.js +10 -10
  9. package/dist/AgentPolicy.js.map +1 -1
  10. package/dist/Tool.d.ts +1 -1
  11. package/dist/Tool.js +1 -1
  12. package/dist/agent-pool.d.ts +4 -4
  13. package/dist/agent-pool.js +42 -42
  14. package/dist/agent-pool.js.map +1 -1
  15. package/dist/context.d.ts +10 -10
  16. package/dist/context.d.ts.map +1 -1
  17. package/dist/context.js +11 -11
  18. package/dist/context.js.map +1 -1
  19. package/dist/create-agent-pool.d.ts +10 -10
  20. package/dist/create-agent-pool.d.ts.map +1 -1
  21. package/dist/create-agent-pool.js +27 -27
  22. package/dist/create-agent-pool.js.map +1 -1
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +4 -4
  26. package/dist/index.js.map +1 -1
  27. package/dist/orchestrators.d.ts +8 -8
  28. package/dist/orchestrators.d.ts.map +1 -1
  29. package/dist/orchestrators.js +10 -10
  30. package/dist/orchestrators.js.map +1 -1
  31. package/dist/replay.d.ts +19 -19
  32. package/dist/replay.d.ts.map +1 -1
  33. package/dist/replay.js +29 -29
  34. package/dist/replay.js.map +1 -1
  35. package/dist/spine.d.ts +106 -0
  36. package/dist/spine.d.ts.map +1 -0
  37. package/dist/{shared-root.js → spine.js} +40 -37
  38. package/dist/spine.js.map +1 -0
  39. package/dist/trace-types.d.ts +4 -4
  40. package/dist/trace-types.d.ts.map +1 -1
  41. package/dist/types.d.ts +20 -14
  42. package/dist/types.d.ts.map +1 -1
  43. package/dist/use-agent.d.ts +3 -3
  44. package/dist/use-agent.d.ts.map +1 -1
  45. package/dist/use-agent.js +5 -5
  46. package/dist/use-agent.js.map +1 -1
  47. package/package.json +2 -2
  48. package/dist/shared-root.d.ts +0 -96
  49. package/dist/shared-root.d.ts.map +0 -1
  50. package/dist/shared-root.js.map +0 -1
@@ -1,96 +0,0 @@
1
- import type { Operation } from "effection";
2
- import { Branch } from "@lloyal-labs/sdk";
3
- import type { SamplingParams } from "./types";
4
- /**
5
- * Configuration for {@link withSharedRoot}
6
- *
7
- * @category Agents
8
- */
9
- export interface SharedRootOptions {
10
- /** Sampling parameters for the root branch */
11
- params?: SamplingParams;
12
- /**
13
- * Set ScratchpadParent context so tools can fork from the shared root
14
- * for scratchpad extraction (fork-attend-extract-prune pattern).
15
- * @default false
16
- */
17
- enableScratchpad?: boolean;
18
- /**
19
- * Fork root from this branch instead of creating at position 0.
20
- *
21
- * When provided, the root inherits the parent's full KV state —
22
- * every tool call, tool result, and generated token the parent
23
- * accumulated. Sub-agents forking from this root attend over the
24
- * parent's complete attention state (Continuous Context).
25
- *
26
- * When omitted, creates a fresh root at position 0 (cold start).
27
- */
28
- parent?: Branch;
29
- /**
30
- * When set, prefill the chat-format `[system + tools]` header onto the
31
- * root once at setup. Every agent forking from the root inherits these
32
- * tokens via `forkSync`'s metadata-only KV prefix-share — the role and
33
- * tool schemas appear ONCE in physical KV regardless of how many agents
34
- * the pool spawns.
35
- *
36
- * The resulting `FormatConfig` (parser/grammar/format/triggers) is set
37
- * on the {@link RootFmt} context so `setupAgent` can detect shared mode,
38
- * skip its own system+tools formatting, and inherit the dispatch-side
39
- * fmt from the root.
40
- *
41
- * Use this for orchestrators where every agent shares the same role —
42
- * chain-mode research pools, fanout-style same-role pools, etc. Mixed-
43
- * role workflows (research → compare → synthesize) keep using per-spec
44
- * `SpawnSpec.systemPrompt` and don't pass this option.
45
- */
46
- systemPrompt?: string;
47
- /**
48
- * JSON-serialized tool schemas to embed in the chat-format header
49
- * prefilled at setup. Format matches `FormatChatOptions.tools` — output
50
- * of `createToolkit(...).toolsJson`. Only applied when `systemPrompt` is
51
- * also set; ignored otherwise.
52
- */
53
- toolsJson?: string;
54
- /**
55
- * Whether to enable thinking-mode tokens (e.g. `<think>` blocks) when
56
- * formatting the shared root header. Threaded through to the chat-format
57
- * call AND stored on the `RootFmt` FormatConfig so `setupAgent`'s
58
- * shared-mode shortcut copies a parser/grammar/triggers configuration
59
- * consistent with the per-agent suffix formatting.
60
- *
61
- * Should match the `enableThinking` value the caller passes to the agent
62
- * pool — divergent values produce inconsistent grammar between the
63
- * prefilled root and per-agent suffixes.
64
- *
65
- * @default false
66
- */
67
- enableThinking?: boolean;
68
- }
69
- /**
70
- * Scoped shared root branch with guaranteed cleanup
71
- *
72
- * Creates (or forks) a root branch for the pool's agents to fork from.
73
- * The root is pruned via try/finally when the body returns or throws,
74
- * regardless of whether children still exist.
75
- *
76
- * Each agent's chat format (system + user + generation prompt) is rendered
77
- * fresh inside `setupAgent`, so this root carries no chat context itself —
78
- * it exists as the pool's branching point and as the spine that
79
- * `ctx.extendRoot` writes onto between tasks.
80
- *
81
- * **Cold path** (no `parent`): creates a root at position 0 with no prefill.
82
- * Agents fork at position 0; their full chat context lives in their own suffix.
83
- *
84
- * **Warm path** (`parent` provided): forks from parent and prefills a turn
85
- * separator so subsequent agent suffixes land on a clean turn boundary.
86
- * Sub-agents inherit the parent's full KV state via the fork.
87
- *
88
- * @param opts - Sampling parameters and optional parent branch
89
- * @param body - Operation that receives the root branch and prefix length.
90
- * Typically calls {@link useAgentPool} inside.
91
- * @returns The body's return value
92
- *
93
- * @category Agents
94
- */
95
- export declare function withSharedRoot<T>(opts: SharedRootOptions, body: (root: Branch, sharedPrefixLength: number) => Operation<T>): Operation<T>;
96
- //# sourceMappingURL=shared-root.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shared-root.d.ts","sourceRoot":"","sources":["../src/shared-root.ts"],"names":[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