@lloyal-labs/lloyal-agents 2.0.0 → 3.0.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/LICENSE +107 -0
- package/LICENSE-FAQ.md +256 -0
- package/README.md +31 -15
- package/dist/Agent.d.ts +15 -4
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +12 -2
- package/dist/Agent.js.map +1 -1
- package/dist/AgentPolicy.d.ts +92 -15
- package/dist/AgentPolicy.d.ts.map +1 -1
- package/dist/AgentPolicy.js +42 -14
- package/dist/AgentPolicy.js.map +1 -1
- package/dist/Tool.d.ts +45 -1
- package/dist/Tool.d.ts.map +1 -1
- package/dist/Tool.js +50 -2
- package/dist/Tool.js.map +1 -1
- package/dist/agent-pool.d.ts +4 -4
- package/dist/agent-pool.d.ts.map +1 -1
- package/dist/agent-pool.js +224 -53
- package/dist/agent-pool.js.map +1 -1
- package/dist/app-config.d.ts +50 -0
- package/dist/app-config.d.ts.map +1 -0
- package/dist/app-config.js +27 -0
- package/dist/app-config.js.map +1 -0
- package/dist/app-types.d.ts +309 -0
- package/dist/app-types.d.ts.map +1 -0
- package/dist/app-types.js +28 -0
- package/dist/app-types.js.map +1 -0
- package/dist/chunk.d.ts +118 -0
- package/dist/chunk.d.ts.map +1 -0
- package/dist/chunk.js +19 -0
- package/dist/chunk.js.map +1 -0
- package/dist/context.d.ts +76 -20
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +72 -20
- package/dist/context.js.map +1 -1
- package/dist/create-agent-pool.d.ts +18 -12
- package/dist/create-agent-pool.d.ts.map +1 -1
- package/dist/create-agent-pool.js +30 -29
- package/dist/create-agent-pool.js.map +1 -1
- package/dist/grant-store.d.ts +49 -0
- package/dist/grant-store.d.ts.map +1 -0
- package/dist/grant-store.js +33 -0
- package/dist/grant-store.js.map +1 -0
- package/dist/index.d.ts +10 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/orchestrators.d.ts +15 -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/source.d.ts +31 -1
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +32 -2
- package/dist/source.js.map +1 -1
- package/dist/spine.d.ts +100 -0
- package/dist/spine.d.ts.map +1 -0
- package/dist/{shared-root.js → spine.js} +57 -38
- package/dist/spine.js.map +1 -0
- package/dist/toolkit.d.ts +44 -17
- package/dist/toolkit.d.ts.map +1 -1
- package/dist/toolkit.js +24 -14
- package/dist/toolkit.js.map +1 -1
- package/dist/trace-types.d.ts +36 -4
- package/dist/trace-types.d.ts.map +1 -1
- package/dist/types.d.ts +46 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/use-agent.d.ts +10 -5
- package/dist/use-agent.d.ts.map +1 -1
- package/dist/use-agent.js +18 -15
- package/dist/use-agent.js.map +1 -1
- package/package.json +7 -5
- 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
package/dist/chunk.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chunk / Reranker abstraction types.
|
|
3
|
+
*
|
|
4
|
+
* These interfaces live in `@lloyal-labs/lloyal-agents` (not rig) so that
|
|
5
|
+
* agent-pool code, app factories, and harness contexts can refer to a
|
|
6
|
+
* common Reranker shape without depending on rig's concrete chunking
|
|
7
|
+
* implementation. Concrete chunking utilities (`chunkResources`,
|
|
8
|
+
* `chunkHtml`, `chunkFetchedPages`) and the cross-encoder-backed
|
|
9
|
+
* `createReranker(...)` factory live in `@lloyal-labs/rig`.
|
|
10
|
+
*
|
|
11
|
+
* The pattern mirrors `Source` and `Tool`: abstract type in agents,
|
|
12
|
+
* concrete subclasses/factories in rig.
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
* @category Contract
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* A loaded document available for search, read, and grep operations.
|
|
19
|
+
*
|
|
20
|
+
* Represents a single file (typically Markdown) loaded into memory.
|
|
21
|
+
* Resources are chunked into {@link Chunk} instances for reranking.
|
|
22
|
+
*/
|
|
23
|
+
export interface Resource {
|
|
24
|
+
/** File name (basename, not full path) used as the resource identifier. */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Full text content of the file. */
|
|
27
|
+
content: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A scored passage within a {@link Resource}, used for reranking and retrieval.
|
|
31
|
+
*
|
|
32
|
+
* The `tokens` array is populated lazily by {@link Reranker.tokenizeChunks}
|
|
33
|
+
* before scoring. Once tokenized, a chunk is bound to that reranker's
|
|
34
|
+
* cross-encoder vocabulary — re-binding requires re-tokenization.
|
|
35
|
+
*/
|
|
36
|
+
export interface Chunk {
|
|
37
|
+
/** Resource identifier (file name or URL) this chunk belongs to. */
|
|
38
|
+
resource: string;
|
|
39
|
+
/** Leaf section heading (e.g. "Recovery loop"). */
|
|
40
|
+
heading: string;
|
|
41
|
+
/** Hierarchical section path (e.g. "Agents > Lifecycle > Recovery loop"). Empty for web chunks. */
|
|
42
|
+
section: string;
|
|
43
|
+
/** Raw text content of the chunk. */
|
|
44
|
+
text: string;
|
|
45
|
+
/** Pre-tokenized representation for the reranker — empty until {@link Reranker.tokenizeChunks} runs. */
|
|
46
|
+
tokens: number[];
|
|
47
|
+
/** First line number (1-based) in the source resource. */
|
|
48
|
+
startLine: number;
|
|
49
|
+
/** Last line number (1-based) in the source resource. */
|
|
50
|
+
endLine: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A single chunk scored by the {@link Reranker} against a query.
|
|
54
|
+
*/
|
|
55
|
+
export interface ScoredChunk {
|
|
56
|
+
/** Source filename containing the chunk. */
|
|
57
|
+
file: string;
|
|
58
|
+
/** Leaf section heading (e.g. "Recovery loop"). */
|
|
59
|
+
heading: string;
|
|
60
|
+
/** Hierarchical section path (e.g. "Agents > Lifecycle > Recovery loop"). Empty for web chunks. */
|
|
61
|
+
section: string;
|
|
62
|
+
/** First ~200 chars of chunk text — gives agents content at search time. */
|
|
63
|
+
snippet: string;
|
|
64
|
+
/** Relevance score (higher = more relevant). */
|
|
65
|
+
score: number;
|
|
66
|
+
/** Start line in the source file (1-indexed). */
|
|
67
|
+
startLine: number;
|
|
68
|
+
/** End line in the source file (1-indexed). */
|
|
69
|
+
endLine: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Progressive reranker output emitted during scoring.
|
|
73
|
+
*
|
|
74
|
+
* Streamed from {@link Reranker.score} as an async iterable, allowing
|
|
75
|
+
* callers to report progress while scoring is in flight.
|
|
76
|
+
*/
|
|
77
|
+
export interface ScoredResult {
|
|
78
|
+
/** Scored chunks accumulated so far, ordered by relevance. */
|
|
79
|
+
results: ScoredChunk[];
|
|
80
|
+
/** Number of chunks scored so far. */
|
|
81
|
+
filled: number;
|
|
82
|
+
/** Total number of chunks to score. */
|
|
83
|
+
total: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Cross-encoder reranker for scoring corpus chunks against a query.
|
|
87
|
+
*
|
|
88
|
+
* Apps obtain the harness-wide reranker via `RerankerCtx.expect()` at
|
|
89
|
+
* factory time — `source.bind({reranker})` is no longer the mechanism.
|
|
90
|
+
* Implementations tokenize chunks up front via {@link tokenizeChunks},
|
|
91
|
+
* then stream progressive results from {@link score}.
|
|
92
|
+
*/
|
|
93
|
+
export interface Reranker {
|
|
94
|
+
/** Score chunks against a query, streaming progressive results. */
|
|
95
|
+
score(query: string, chunks: Chunk[]): AsyncIterable<ScoredResult>;
|
|
96
|
+
/**
|
|
97
|
+
* Score raw text strings against a query in one batch.
|
|
98
|
+
*
|
|
99
|
+
* Returns logit-diff scores (`logit("yes") - logit("no")`, unbounded) in
|
|
100
|
+
* input order. This is the log-odds of the reranker's ABSOLUTE yes/no
|
|
101
|
+
* relevance judgment — `P(yes) = sigmoid(score)`, so 0 ≡ P 0.5 — the
|
|
102
|
+
* monotone equivalent of the official Qwen3-Reranker two-token softmax.
|
|
103
|
+
* Scores are thresholdable and comparable across queries to the extent of
|
|
104
|
+
* the model's calibration (quantization adds noise at the extremes).
|
|
105
|
+
*/
|
|
106
|
+
scoreBatch(query: string, texts: string[]): Promise<number[]>;
|
|
107
|
+
/** Pre-tokenize chunks for subsequent scoring calls. */
|
|
108
|
+
tokenizeChunks(chunks: Chunk[]): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Tokenize an arbitrary text string through the reranker's tokenizer.
|
|
111
|
+
* Use when consumers need to operate on tokens from the same vocabulary
|
|
112
|
+
* as the chunks (e.g. BM25 first-stage scoring at query time).
|
|
113
|
+
*/
|
|
114
|
+
tokenize(text: string): Promise<number[]>;
|
|
115
|
+
/** Release reranker resources. */
|
|
116
|
+
dispose(): void;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=chunk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../src/chunk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,KAAK;IACpB,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,mGAAmG;IACnG,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,wGAAwG;IACxG,MAAM,EAAE,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
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Chunk / Reranker abstraction types.
|
|
4
|
+
*
|
|
5
|
+
* These interfaces live in `@lloyal-labs/lloyal-agents` (not rig) so that
|
|
6
|
+
* agent-pool code, app factories, and harness contexts can refer to a
|
|
7
|
+
* common Reranker shape without depending on rig's concrete chunking
|
|
8
|
+
* implementation. Concrete chunking utilities (`chunkResources`,
|
|
9
|
+
* `chunkHtml`, `chunkFetchedPages`) and the cross-encoder-backed
|
|
10
|
+
* `createReranker(...)` factory live in `@lloyal-labs/rig`.
|
|
11
|
+
*
|
|
12
|
+
* The pattern mirrors `Source` and `Tool`: abstract type in agents,
|
|
13
|
+
* concrete subclasses/factories in rig.
|
|
14
|
+
*
|
|
15
|
+
* @packageDocumentation
|
|
16
|
+
* @category Contract
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
//# sourceMappingURL=chunk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk.js","sourceRoot":"","sources":["../src/chunk.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG"}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import type { SessionContext } from '@lloyal-labs/sdk';
|
|
2
|
-
import type { BranchStore
|
|
2
|
+
import type { BranchStore } from '@lloyal-labs/sdk';
|
|
3
3
|
import type { Channel } from 'effection';
|
|
4
4
|
import type { AgentEvent } from './types';
|
|
5
5
|
import type { TraceWriter } from './trace-writer';
|
|
6
6
|
import type { Agent, FormatConfig } from './Agent';
|
|
7
|
+
import type { Reranker } from './chunk';
|
|
8
|
+
import type { AppRegistry } from './app-types';
|
|
9
|
+
import type { AppConfigStore } from './app-config';
|
|
10
|
+
import type { GrantStore } from './grant-store';
|
|
7
11
|
/**
|
|
8
12
|
* Effection context holding the active {@link SessionContext}
|
|
9
13
|
*
|
|
10
14
|
* Set by {@link initAgents} in the caller's scope. All agent operations
|
|
11
|
-
* (`
|
|
15
|
+
* (`useAgent`, `agentPool`, `useAgentPool`, `withSpine`, `diverge`) read from this
|
|
12
16
|
* context via `yield* Ctx.expect()`.
|
|
13
17
|
*
|
|
14
18
|
* @category Agents
|
|
@@ -51,22 +55,11 @@ export declare const Trace: import("effection").Context<TraceWriter>;
|
|
|
51
55
|
* @category Agents
|
|
52
56
|
*/
|
|
53
57
|
export declare const TraceParent: import("effection").Context<number>;
|
|
54
|
-
/**
|
|
55
|
-
* Effection context holding the scratchpad fork parent branch
|
|
56
|
-
*
|
|
57
|
-
* Set by {@link withSharedRoot} to the current root branch. Tools that
|
|
58
|
-
* need scratchpad extraction (e.g. BufferingFetchPage, BufferingWebSearch)
|
|
59
|
-
* read this via `yield* ScratchpadParent.expect()` to fork from the
|
|
60
|
-
* innermost active root — never a stale reference from a prior scope.
|
|
61
|
-
*
|
|
62
|
-
* @category Agents
|
|
63
|
-
*/
|
|
64
|
-
export declare const ScratchpadParent: import("effection").Context<Branch>;
|
|
65
58
|
/**
|
|
66
59
|
* Effection context holding the calling agent during DISPATCH
|
|
67
60
|
*
|
|
68
61
|
* Set by the pool before each tool execution in `scoped()`. Tools and
|
|
69
|
-
* recursive `
|
|
62
|
+
* recursive `withSpine` calls read this to access the calling
|
|
70
63
|
* agent's branch (for Continuous Context forking) and tool history
|
|
71
64
|
* (for deduplication guards).
|
|
72
65
|
*
|
|
@@ -77,20 +70,83 @@ export declare const ScratchpadParent: import("effection").Context<Branch>;
|
|
|
77
70
|
*/
|
|
78
71
|
export declare const CallingAgent: import("effection").Context<Agent>;
|
|
79
72
|
/**
|
|
80
|
-
* Effection context holding the
|
|
73
|
+
* Effection context holding the spine's pre-computed {@link FormatConfig}
|
|
81
74
|
* when shared system+tools mode is active.
|
|
82
75
|
*
|
|
83
|
-
* Set by {@link
|
|
84
|
-
* The chat-format header (system + tools) is prefilled onto the
|
|
85
|
-
* setup; agents forking from the
|
|
76
|
+
* Set by {@link withSpine} when its `systemPrompt` option is provided.
|
|
77
|
+
* The chat-format header (system + tools) is prefilled onto the spine once at
|
|
78
|
+
* setup; agents forking from the spine inherit those tokens via prefix-share
|
|
86
79
|
* and need the matching parser/grammar/format/triggers to dispatch tool calls
|
|
87
80
|
* correctly. Storing it here lets `setupAgent` detect shared mode and copy
|
|
88
81
|
* the fmt without re-emitting tool schemas in each agent's suffix.
|
|
89
82
|
*
|
|
90
|
-
* Defaults to `null` so non-shared `
|
|
83
|
+
* Defaults to `null` so non-shared `withSpine` scopes leave it unset and
|
|
91
84
|
* `setupAgent` falls back to formatting per-agent system+tools+user as today.
|
|
92
85
|
*
|
|
93
86
|
* @category Agents
|
|
94
87
|
*/
|
|
95
|
-
export declare const
|
|
88
|
+
export declare const SpineFmt: import("effection").Context<FormatConfig | null>;
|
|
89
|
+
/**
|
|
90
|
+
* Effection context holding the harness-wide {@link Reranker}.
|
|
91
|
+
*
|
|
92
|
+
* Set by the harness once via `RerankerCtx.set(reranker)` after
|
|
93
|
+
* `createReranker(...)`. App factories (`createWebApp`, `createCorpusApp`,
|
|
94
|
+
* third-party apps) read this via `yield* RerankerCtx.expect()` at
|
|
95
|
+
* construction time and pass it to their `Source` / search tools.
|
|
96
|
+
*
|
|
97
|
+
* Replaces the per-source `source.bind({reranker})` pattern — chunks
|
|
98
|
+
* tokenized by one reranker can't be re-bound to another without
|
|
99
|
+
* re-tokenization, so one cross-encoder per harness
|
|
100
|
+
* is the invariant.
|
|
101
|
+
*
|
|
102
|
+
* @category Contract
|
|
103
|
+
*/
|
|
104
|
+
export declare const RerankerCtx: import("effection").Context<Reranker>;
|
|
105
|
+
/**
|
|
106
|
+
* Effection context holding the {@link AppRegistry}.
|
|
107
|
+
*
|
|
108
|
+
* Set by `createAppRegistry(...)` (lives in `@lloyal-labs/rig`). The
|
|
109
|
+
* scope-guard reads this at tool-dispatch time to resolve
|
|
110
|
+
* the allowed-tools set for an App-assigned spawn — looking up
|
|
111
|
+
* `registry.byName(spawn.assignedApp)` and matching the dispatched
|
|
112
|
+
* `toolName` against `manifest.protocol.tools`.
|
|
113
|
+
*
|
|
114
|
+
* The spine renderer also reads this to compose the catalog in
|
|
115
|
+
* registration order.
|
|
116
|
+
*
|
|
117
|
+
* @category Contract
|
|
118
|
+
*/
|
|
119
|
+
export declare const AppRegistryCtx: import("effection").Context<AppRegistry>;
|
|
120
|
+
/**
|
|
121
|
+
* Effection context holding the harness's {@link AppConfigStore}.
|
|
122
|
+
*
|
|
123
|
+
* Set by `createAppRegistry({ configStore })` from its `configStore`
|
|
124
|
+
* option, and seeded into each app's detached scope so factories can
|
|
125
|
+
* read it. App factories read their own config via
|
|
126
|
+
* `(yield* AppConfigStoreCtx.expect()).get(manifest.name)` at
|
|
127
|
+
* construction time. The framework validates the stored config against
|
|
128
|
+
* `app.manifest.configSchema` when the app is enabled.
|
|
129
|
+
*
|
|
130
|
+
* Whole-replace semantics on `set`; last-write-wins on concurrent
|
|
131
|
+
* writes.
|
|
132
|
+
*
|
|
133
|
+
* @category Contract
|
|
134
|
+
*/
|
|
135
|
+
export declare const AppConfigStoreCtx: import("effection").Context<AppConfigStore>;
|
|
136
|
+
/**
|
|
137
|
+
* Effection context holding the session's {@link GrantStore}.
|
|
138
|
+
*
|
|
139
|
+
* Seeded by `createAppRegistry({ grantStore })` (lives in `@lloyal-labs/rig`)
|
|
140
|
+
* alongside {@link AppConfigStoreCtx}. The authGuard
|
|
141
|
+
* reads it once per pool to resolve which `protected` tools the session is
|
|
142
|
+
* authorized to call — `protected` tools without a grant reject at dispatch
|
|
143
|
+
* time (`tool:authReject`). The store holds the consent decision; the
|
|
144
|
+
* **credential never enters the model's context**.
|
|
145
|
+
*
|
|
146
|
+
* Absent context = fail-closed: no grants, every protected tool denied.
|
|
147
|
+
* Open (non-protected) tools never consult it.
|
|
148
|
+
*
|
|
149
|
+
* @category Contract
|
|
150
|
+
*/
|
|
151
|
+
export declare const GrantStoreCtx: import("effection").Context<GrantStore>;
|
|
96
152
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAU,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD;;;;;;;;GAQG;AACH,eAAO,MAAM,GAAG,6CAA8C,CAAC;AAE/D;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,0CAA6C,CAAC;AAEhE;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,wDAA4D,CAAC;AAEhF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,0CAA6C,CAAC;AAEhE;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,qCAA+C,CAAC;AAExE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,oCAA8C,CAAC;AAExE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,kDAA8D,CAAC;AAEpF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,uCAA6C,CAAC;AAEtE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,0CAAmD,CAAC;AAE/E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,6CAAyD,CAAC;AAExF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,yCAAiD,CAAC"}
|
package/dist/context.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.GrantStoreCtx = exports.AppConfigStoreCtx = exports.AppRegistryCtx = exports.RerankerCtx = exports.SpineFmt = exports.CallingAgent = exports.TraceParent = exports.Trace = exports.Events = exports.Store = exports.Ctx = void 0;
|
|
4
4
|
const effection_1 = require("effection");
|
|
5
5
|
/**
|
|
6
6
|
* Effection context holding the active {@link SessionContext}
|
|
7
7
|
*
|
|
8
8
|
* Set by {@link initAgents} in the caller's scope. All agent operations
|
|
9
|
-
* (`
|
|
9
|
+
* (`useAgent`, `agentPool`, `useAgentPool`, `withSpine`, `diverge`) read from this
|
|
10
10
|
* context via `yield* Ctx.expect()`.
|
|
11
11
|
*
|
|
12
12
|
* @category Agents
|
|
@@ -49,22 +49,11 @@ exports.Trace = (0, effection_1.createContext)('lloyal.trace');
|
|
|
49
49
|
* @category Agents
|
|
50
50
|
*/
|
|
51
51
|
exports.TraceParent = (0, effection_1.createContext)('lloyal.traceParent');
|
|
52
|
-
/**
|
|
53
|
-
* Effection context holding the scratchpad fork parent branch
|
|
54
|
-
*
|
|
55
|
-
* Set by {@link withSharedRoot} to the current root branch. Tools that
|
|
56
|
-
* need scratchpad extraction (e.g. BufferingFetchPage, BufferingWebSearch)
|
|
57
|
-
* read this via `yield* ScratchpadParent.expect()` to fork from the
|
|
58
|
-
* innermost active root — never a stale reference from a prior scope.
|
|
59
|
-
*
|
|
60
|
-
* @category Agents
|
|
61
|
-
*/
|
|
62
|
-
exports.ScratchpadParent = (0, effection_1.createContext)('lloyal.scratchpadParent');
|
|
63
52
|
/**
|
|
64
53
|
* Effection context holding the calling agent during DISPATCH
|
|
65
54
|
*
|
|
66
55
|
* Set by the pool before each tool execution in `scoped()`. Tools and
|
|
67
|
-
* recursive `
|
|
56
|
+
* recursive `withSpine` calls read this to access the calling
|
|
68
57
|
* agent's branch (for Continuous Context forking) and tool history
|
|
69
58
|
* (for deduplication guards).
|
|
70
59
|
*
|
|
@@ -75,20 +64,83 @@ exports.ScratchpadParent = (0, effection_1.createContext)('lloyal.scratchpadPare
|
|
|
75
64
|
*/
|
|
76
65
|
exports.CallingAgent = (0, effection_1.createContext)('lloyal.callingAgent');
|
|
77
66
|
/**
|
|
78
|
-
* Effection context holding the
|
|
67
|
+
* Effection context holding the spine's pre-computed {@link FormatConfig}
|
|
79
68
|
* when shared system+tools mode is active.
|
|
80
69
|
*
|
|
81
|
-
* Set by {@link
|
|
82
|
-
* The chat-format header (system + tools) is prefilled onto the
|
|
83
|
-
* setup; agents forking from the
|
|
70
|
+
* Set by {@link withSpine} when its `systemPrompt` option is provided.
|
|
71
|
+
* The chat-format header (system + tools) is prefilled onto the spine once at
|
|
72
|
+
* setup; agents forking from the spine inherit those tokens via prefix-share
|
|
84
73
|
* and need the matching parser/grammar/format/triggers to dispatch tool calls
|
|
85
74
|
* correctly. Storing it here lets `setupAgent` detect shared mode and copy
|
|
86
75
|
* the fmt without re-emitting tool schemas in each agent's suffix.
|
|
87
76
|
*
|
|
88
|
-
* Defaults to `null` so non-shared `
|
|
77
|
+
* Defaults to `null` so non-shared `withSpine` scopes leave it unset and
|
|
89
78
|
* `setupAgent` falls back to formatting per-agent system+tools+user as today.
|
|
90
79
|
*
|
|
91
80
|
* @category Agents
|
|
92
81
|
*/
|
|
93
|
-
exports.
|
|
82
|
+
exports.SpineFmt = (0, effection_1.createContext)('lloyal.spineFmt', null);
|
|
83
|
+
/**
|
|
84
|
+
* Effection context holding the harness-wide {@link Reranker}.
|
|
85
|
+
*
|
|
86
|
+
* Set by the harness once via `RerankerCtx.set(reranker)` after
|
|
87
|
+
* `createReranker(...)`. App factories (`createWebApp`, `createCorpusApp`,
|
|
88
|
+
* third-party apps) read this via `yield* RerankerCtx.expect()` at
|
|
89
|
+
* construction time and pass it to their `Source` / search tools.
|
|
90
|
+
*
|
|
91
|
+
* Replaces the per-source `source.bind({reranker})` pattern — chunks
|
|
92
|
+
* tokenized by one reranker can't be re-bound to another without
|
|
93
|
+
* re-tokenization, so one cross-encoder per harness
|
|
94
|
+
* is the invariant.
|
|
95
|
+
*
|
|
96
|
+
* @category Contract
|
|
97
|
+
*/
|
|
98
|
+
exports.RerankerCtx = (0, effection_1.createContext)('lloyal.reranker');
|
|
99
|
+
/**
|
|
100
|
+
* Effection context holding the {@link AppRegistry}.
|
|
101
|
+
*
|
|
102
|
+
* Set by `createAppRegistry(...)` (lives in `@lloyal-labs/rig`). The
|
|
103
|
+
* scope-guard reads this at tool-dispatch time to resolve
|
|
104
|
+
* the allowed-tools set for an App-assigned spawn — looking up
|
|
105
|
+
* `registry.byName(spawn.assignedApp)` and matching the dispatched
|
|
106
|
+
* `toolName` against `manifest.protocol.tools`.
|
|
107
|
+
*
|
|
108
|
+
* The spine renderer also reads this to compose the catalog in
|
|
109
|
+
* registration order.
|
|
110
|
+
*
|
|
111
|
+
* @category Contract
|
|
112
|
+
*/
|
|
113
|
+
exports.AppRegistryCtx = (0, effection_1.createContext)('lloyal.appRegistry');
|
|
114
|
+
/**
|
|
115
|
+
* Effection context holding the harness's {@link AppConfigStore}.
|
|
116
|
+
*
|
|
117
|
+
* Set by `createAppRegistry({ configStore })` from its `configStore`
|
|
118
|
+
* option, and seeded into each app's detached scope so factories can
|
|
119
|
+
* read it. App factories read their own config via
|
|
120
|
+
* `(yield* AppConfigStoreCtx.expect()).get(manifest.name)` at
|
|
121
|
+
* construction time. The framework validates the stored config against
|
|
122
|
+
* `app.manifest.configSchema` when the app is enabled.
|
|
123
|
+
*
|
|
124
|
+
* Whole-replace semantics on `set`; last-write-wins on concurrent
|
|
125
|
+
* writes.
|
|
126
|
+
*
|
|
127
|
+
* @category Contract
|
|
128
|
+
*/
|
|
129
|
+
exports.AppConfigStoreCtx = (0, effection_1.createContext)('lloyal.appConfigStore');
|
|
130
|
+
/**
|
|
131
|
+
* Effection context holding the session's {@link GrantStore}.
|
|
132
|
+
*
|
|
133
|
+
* Seeded by `createAppRegistry({ grantStore })` (lives in `@lloyal-labs/rig`)
|
|
134
|
+
* alongside {@link AppConfigStoreCtx}. The authGuard
|
|
135
|
+
* reads it once per pool to resolve which `protected` tools the session is
|
|
136
|
+
* authorized to call — `protected` tools without a grant reject at dispatch
|
|
137
|
+
* time (`tool:authReject`). The store holds the consent decision; the
|
|
138
|
+
* **credential never enters the model's context**.
|
|
139
|
+
*
|
|
140
|
+
* Absent context = fail-closed: no grants, every protected tool denied.
|
|
141
|
+
* Open (non-protected) tools never consult it.
|
|
142
|
+
*
|
|
143
|
+
* @category Contract
|
|
144
|
+
*/
|
|
145
|
+
exports.GrantStoreCtx = (0, effection_1.createContext)('lloyal.grantStore');
|
|
94
146
|
//# sourceMappingURL=context.js.map
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;AAAA,yCAA0C;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;AAAA,yCAA0C;AAa1C;;;;;;;;GAQG;AACU,QAAA,GAAG,GAAG,IAAA,yBAAa,EAAiB,YAAY,CAAC,CAAC;AAE/D;;;;;;;GAOG;AACU,QAAA,KAAK,GAAG,IAAA,yBAAa,EAAc,cAAc,CAAC,CAAC;AAEhE;;;;;;;GAOG;AACU,QAAA,MAAM,GAAG,IAAA,yBAAa,EAA4B,eAAe,CAAC,CAAC;AAEhF;;;;;;;GAOG;AACU,QAAA,KAAK,GAAG,IAAA,yBAAa,EAAc,cAAc,CAAC,CAAC;AAEhE;;;;;;;;GAQG;AACU,QAAA,WAAW,GAAG,IAAA,yBAAa,EAAU,oBAAoB,CAAC,CAAC;AAExE;;;;;;;;;;;;GAYG;AACU,QAAA,YAAY,GAAG,IAAA,yBAAa,EAAQ,qBAAqB,CAAC,CAAC;AAExE;;;;;;;;;;;;;;;GAeG;AACU,QAAA,QAAQ,GAAG,IAAA,yBAAa,EAAsB,iBAAiB,EAAE,IAAI,CAAC,CAAC;AAEpF;;;;;;;;;;;;;;GAcG;AACU,QAAA,WAAW,GAAG,IAAA,yBAAa,EAAW,iBAAiB,CAAC,CAAC;AAEtE;;;;;;;;;;;;;GAaG;AACU,QAAA,cAAc,GAAG,IAAA,yBAAa,EAAc,oBAAoB,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;GAcG;AACU,QAAA,iBAAiB,GAAG,IAAA,yBAAa,EAAiB,uBAAuB,CAAC,CAAC;AAExF;;;;;;;;;;;;;;GAcG;AACU,QAAA,aAAa,GAAG,IAAA,yBAAa,EAAa,mBAAmB,CAAC,CAAC"}
|
|
@@ -20,12 +20,18 @@ export interface CreateAgentPoolOpts {
|
|
|
20
20
|
orchestrate: Orchestrator;
|
|
21
21
|
/** Data access tools (array, createToolkit called internally). Optional — pool degenerates cleanly without tools. */
|
|
22
22
|
tools?: Tool[];
|
|
23
|
-
/**
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The tool that ends an agent's turn — `report`, `email`, whatever the
|
|
25
|
+
* harness designates. Passed by reference; the framework merges it into
|
|
26
|
+
* the tool set (so its schema reaches the model) and intercepts its
|
|
27
|
+
* call at the policy layer to extract the `result` arg as the agent's
|
|
28
|
+
* return value. Omit for pools that end on free-text/stop.
|
|
29
|
+
*/
|
|
30
|
+
terminal?: Tool;
|
|
25
31
|
/** Max tool-use turns per agent before hard cut. @default 100 */
|
|
26
32
|
maxTurns?: number;
|
|
27
|
-
/** Prune agent branches immediately
|
|
28
|
-
|
|
33
|
+
/** Prune agent branches immediately when they voluntarily return, freeing KV mid-pool. */
|
|
34
|
+
pruneOnReturn?: boolean;
|
|
29
35
|
/** Custom agent policy. @default DefaultAgentPolicy */
|
|
30
36
|
policy?: AgentPolicy;
|
|
31
37
|
/** Enable structured trace events. */
|
|
@@ -55,8 +61,8 @@ export interface CreateAgentPoolOpts {
|
|
|
55
61
|
enableThinking?: boolean;
|
|
56
62
|
/**
|
|
57
63
|
* Pool-shared system prompt. When set, the chat-format `[system + tools]`
|
|
58
|
-
* header is prefilled onto the inner
|
|
59
|
-
* forking from
|
|
64
|
+
* header is prefilled onto the inner spine once at setup; every agent
|
|
65
|
+
* forking from the spine inherits the role+tools header via fork prefix-
|
|
60
66
|
* sharing instead of re-emitting them in its own suffix. Use when every
|
|
61
67
|
* spawn in the pool shares the same role (chain mode, single-role parallel/
|
|
62
68
|
* fanout pools); leave unset for mixed-role workflows.
|
|
@@ -66,9 +72,9 @@ export interface CreateAgentPoolOpts {
|
|
|
66
72
|
* layers as a second system message in the agent's KV (multi-system in
|
|
67
73
|
* lineage — Qwen3 handles this; recovery has shipped on the same pattern).
|
|
68
74
|
*
|
|
69
|
-
* In shared mode, `
|
|
75
|
+
* In shared mode, `extendSpine` writes onto the inner spine rather than
|
|
70
76
|
* the warm parent. Findings are visible to subsequent agents in the pool
|
|
71
|
-
* and to nested `useAgent` calls within the same `
|
|
77
|
+
* and to nested `useAgent` calls within the same `withSpine` scope,
|
|
72
78
|
* but do NOT persist on the session trunk after the pool closes.
|
|
73
79
|
*/
|
|
74
80
|
systemPrompt?: string;
|
|
@@ -76,17 +82,17 @@ export interface CreateAgentPoolOpts {
|
|
|
76
82
|
/**
|
|
77
83
|
* Run a parallel agent pool with tools.
|
|
78
84
|
*
|
|
79
|
-
* Composes `
|
|
80
|
-
* Drains the Subscription inside `
|
|
85
|
+
* Composes `withSpine` + `createToolkit` + `useAgentPool` internally.
|
|
86
|
+
* Drains the Subscription inside `withSpine`'s body and forwards
|
|
81
87
|
* events to the broadcast Channel. Returns `AgentPoolResult` with
|
|
82
88
|
* branches pruned.
|
|
83
89
|
*
|
|
84
90
|
* @example Research harness
|
|
85
91
|
* ```typescript
|
|
86
92
|
* const pool = yield* agentPool({
|
|
87
|
-
* tools: [delegateTool, ...source.tools
|
|
93
|
+
* tools: [delegateTool, ...source.tools],
|
|
88
94
|
* orchestrate: parallel(questions.map(q => ({ content: q, systemPrompt: RESEARCH_PROMPT }))),
|
|
89
|
-
*
|
|
95
|
+
* terminal: reportTool,
|
|
90
96
|
* });
|
|
91
97
|
* ```
|
|
92
98
|
*
|
|
@@ -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
|
|
1
|
+
{"version":3,"file":"create-agent-pool.d.ts","sourceRoot":"","sources":["../src/create-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AE,MAAM,CAAC;CACvB;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAiB,SAAS,CAAC,IAAI,EAAE,mBAAmB,GAAG,SAAS,CAAC,eAAe,CAAC,CAgEhF"}
|
|
@@ -3,23 +3,23 @@ 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
|
*
|
|
17
17
|
* @example Research harness
|
|
18
18
|
* ```typescript
|
|
19
19
|
* const pool = yield* agentPool({
|
|
20
|
-
* tools: [delegateTool, ...source.tools
|
|
20
|
+
* tools: [delegateTool, ...source.tools],
|
|
21
21
|
* orchestrate: parallel(questions.map(q => ({ content: q, systemPrompt: RESEARCH_PROMPT }))),
|
|
22
|
-
*
|
|
22
|
+
* terminal: reportTool,
|
|
23
23
|
* });
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
@@ -27,52 +27,53 @@ const agent_pool_1 = require("./agent-pool");
|
|
|
27
27
|
*/
|
|
28
28
|
function* agentPool(opts) {
|
|
29
29
|
const broadcast = yield* context_1.Events.expect();
|
|
30
|
-
const toolkit = (0, toolkit_1.createToolkit)(opts.tools ?? []);
|
|
30
|
+
const toolkit = (0, toolkit_1.createToolkit)(opts.tools ?? [], opts.terminal);
|
|
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. Use the toolkit's merged set so the terminal's
|
|
40
|
+
// schema rides the spine prefill alongside the capability tools.
|
|
41
|
+
tools: sharedMode ? toolkit.tools : undefined,
|
|
42
|
+
// Thread enableThinking so the spine header chat-format and the
|
|
43
|
+
// SpineFmt FormatConfig (parser/grammar/triggers) match what the
|
|
42
44
|
// per-agent suffixes get further down. Otherwise a caller passing
|
|
43
|
-
// enableThinking:true gets divergent grammar between
|
|
45
|
+
// enableThinking:true gets divergent grammar between spine + suffix.
|
|
44
46
|
enableThinking: opts.enableThinking,
|
|
45
|
-
}, function* (
|
|
46
|
-
// SHARED mode (systemPrompt set): the inner
|
|
47
|
-
// [system + tools] header
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
// not via root mutation.
|
|
47
|
+
}, function* (innerSpine) {
|
|
48
|
+
// SHARED mode (systemPrompt set): the inner spine carries the
|
|
49
|
+
// [system + tools] header. extendSpine writes onto it, agents fork
|
|
50
|
+
// from it, nested useAgent calls fork from it. Inner spine is pruned
|
|
51
|
+
// at withSpine exit; that's fine because pool findings flow to the
|
|
52
|
+
// session via session.commitTurn (post-pool), not via spine mutation.
|
|
52
53
|
//
|
|
53
54
|
// NON-SHARED mode (existing behavior): on warm path, use the caller-
|
|
54
|
-
// provided parent AS the logical spine so `ctx.
|
|
55
|
+
// provided parent AS the logical spine so `ctx.extendSpine` mutations
|
|
55
56
|
// persist across the pool's lifetime and are visible to sibling pools
|
|
56
|
-
// that fork from the same parent. The inner
|
|
57
|
+
// that fork from the same parent. The inner spine is just a
|
|
57
58
|
// separator-prefilled fork of parent — its extensions would be
|
|
58
59
|
// discarded at pool close, breaking the multi-task spine pattern
|
|
59
|
-
// (research → synth over shared
|
|
60
|
-
//
|
|
61
|
-
const
|
|
60
|
+
// (research → synth over shared spine). On cold path, the inner
|
|
61
|
+
// spine IS the persistent spine.
|
|
62
|
+
const spine = sharedMode ? innerSpine : (warmParent ?? innerSpine);
|
|
62
63
|
const sub = yield* (0, agent_pool_1.useAgentPool)({
|
|
63
|
-
|
|
64
|
+
spine,
|
|
64
65
|
orchestrate: opts.orchestrate,
|
|
65
66
|
toolsJson: toolkit.toolsJson,
|
|
66
67
|
tools: toolkit.toolMap,
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
terminalToolName: toolkit.terminalName,
|
|
69
|
+
pruneOnReturn: opts.pruneOnReturn,
|
|
69
70
|
maxTurns: opts.maxTurns,
|
|
70
71
|
trace: opts.trace,
|
|
71
72
|
policy: opts.policy,
|
|
72
73
|
scorer: opts.scorer,
|
|
73
74
|
enableThinking: opts.enableThinking,
|
|
74
75
|
});
|
|
75
|
-
// Drain Subscription inside body — before
|
|
76
|
+
// Drain Subscription inside body — before withSpine's finally fires
|
|
76
77
|
let next = yield* sub.next();
|
|
77
78
|
while (!next.done) {
|
|
78
79
|
yield* broadcast.send(next.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-agent-pool.js","sourceRoot":"","sources":["../src/create-agent-pool.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"create-agent-pool.js","sourceRoot":"","sources":["../src/create-agent-pool.ts"],"names":[],"mappings":";;AA8GA,8BAgEC;AAtKD,uCAAmC;AACnC,uCAA0C;AAC1C,mCAAoC;AACpC,6CAA4C;AA8E5C,+DAA+D;AAE/D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