@lloyal-labs/sdk 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 ADDED
@@ -0,0 +1,107 @@
1
+ # Functional Source License, Version 1.1, Apache 2.0 Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-Apache-2.0
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 Lloyal Labs
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publish, and distribute the
28
+ Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A "Permitted Purpose" is any purpose other than a Competing Use. A
33
+ "Competing Use" means making the Software available to others in a
34
+ commercial product or service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a Licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives
65
+ of the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND,
74
+ INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE,
75
+ MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO
78
+ THE SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
79
+ DAMAGES, EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software
90
+ under the Apache License, Version 2.0 that is effective on the second
91
+ anniversary of the date we make the Software available. On or after that
92
+ date, you may use the Software under the Apache License, Version 2.0, in
93
+ which case the following will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
96
+ use this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software
103
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
104
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
105
+
106
+ See the License for the specific language governing permissions and
107
+ limitations under the License.
package/LICENSE-FAQ.md ADDED
@@ -0,0 +1,256 @@
1
+ # Licensing FAQ
2
+
3
+ > Canonical version at https://docs.lloyal.ai/licensing/faq.
4
+ > This file is a synced copy. Edit the canonical source and re-run
5
+ > `scripts/sync-license-faq.sh` in lloyal-sdk to update all copies.
6
+
7
+
8
+ **You can build and sell commercial products using HDK.**
9
+
10
+ > HDK is free to build products with; it is not free to become the
11
+ > replacement HDK platform.
12
+
13
+ That single sentence is the entire restriction reduced to one line. The rest
14
+ of this page is illustration.
15
+
16
+ ## The short version
17
+
18
+ HDK 3.0 runtime packages — `liblloyal`, `lloyal-node`, and the lloyal-sdk
19
+ packages (`agents`, `sdk`, `rig`, `apps/corpus`, `apps/web`) — are
20
+ source-available under **FSL-1.1-Apache-2.0** (the Functional Source License,
21
+ Apache 2.0 future grant). FSL is a [Fair Source](https://fair.io) license.
22
+
23
+ Each version converts to Apache 2.0 two years after its release. The
24
+ restriction during those two years is narrow: **you cannot offer a competing
25
+ HDK runtime, a managed HDK service, or an alternative HDK App distribution
26
+ channel.** Everything else — commercial use, redistribution, modification,
27
+ sale, embedding in shipped products — is freely permitted.
28
+
29
+ The reason the channel restriction exists is consumer-protective: every App
30
+ listed on `apps.lloyal.ai` is reviewed by Lloyal Labs for tool-safety,
31
+ manifest conformance, and signature provenance before publication. Pinning
32
+ the App ecosystem to one verified channel keeps the AI-safety review meaningful
33
+ (consumers can rely on a single trust boundary) and prevents protocol
34
+ fragmentation (an App that works on one harness works on every harness).
35
+
36
+ The `harness.dev` CLI and `hdk-create-app` scaffolder are licensed under
37
+ **Apache 2.0** (unrestricted). They're not part of the runtime stack.
38
+
39
+ ## Can I ship a commercial product built on HDK?
40
+
41
+ **Yes.** This is the question everyone has and the answer is straightforward.
42
+ Concretely:
43
+
44
+ - **Shipping a paid intelligent inbox app to consumers** — permitted ✅
45
+ - **Selling an Excel-with-AI desktop app to enterprises** — permitted ✅
46
+ - **Embedding HDK in a medical device sold commercially** — permitted ✅
47
+ - **A consulting firm building a custom intelligent harness for a Fortune
48
+ 500 client, charging $500K for the engagement, deploying on client
49
+ infrastructure** — permitted ✅
50
+ - **An indie dev shipping a paid productivity app on the Mac App Store** —
51
+ permitted ✅
52
+ - **An OEM shipping HDK inside an infotainment system or industrial device**
53
+ — permitted ✅
54
+ - **A startup building an end-user product on top of HDK** — including
55
+ vertical research apps, workflow tools, and agent applications — permitted
56
+ ✅, *as long as the product is not offering HDK itself as a substitute
57
+ runtime, managed HDK service, or competing App distribution channel*.
58
+ - **A research lab using HDK in published academic work** — permitted ✅
59
+ - **Forking HDK on GitHub to learn, modify, demo, or contribute** — permitted ✅
60
+ - **Running HDK internally inside your company for any business use** —
61
+ permitted ✅
62
+
63
+ If you are building something *with* HDK, you are almost certainly fine.
64
+
65
+ ## What is actually restricted?
66
+
67
+ The restriction is narrow and specific: **don't become the replacement
68
+ platform vendor**. Concretely:
69
+
70
+ - **AWS / Google / Microsoft launching "Bedrock Managed HDK" or "Vertex HDK"
71
+ as a hosted runtime service** — restricted ❌
72
+ - **A competitor publishing "OpenHDK" as a forked harness runtime under a
73
+ different name** — restricted ❌
74
+ - **A clean-room reimplementation of the HDK runtime in Python / Rust / Go
75
+ intended as a drop-in replacement** — restricted ❌ (Competing Use doesn't
76
+ require forking source code — a reimplementation that competes is the
77
+ same problem)
78
+ - **Launching `apps.competitor.com` as an alternative HDK App distribution
79
+ channel** — restricted ❌
80
+ - **Offering "managed HDK hosting" or "HDK-as-a-Service" as a competing
81
+ SaaS** — restricted ❌
82
+ - **A hosted orchestration service exposing HDK-compatible APIs as a
83
+ substitute for the HDK runtime** — restricted ❌
84
+
85
+ Notice the pattern: every restricted scenario is "become the platform
86
+ vendor," not "build products with HDK." If your project doesn't compete
87
+ directly with the HDK runtime or its distribution channel, FSL doesn't
88
+ affect you.
89
+
90
+ ## Why does the LICENSE list four narrow Permitted Purposes then?
91
+
92
+ You may read the FSL LICENSE and see this section:
93
+
94
+ > Permitted Purposes specifically include using the Software:
95
+ > 1. for your internal use and access;
96
+ > 2. for non-commercial education;
97
+ > 3. for non-commercial research; and
98
+ > 4. in connection with professional services that you provide to a
99
+ > Licensee using the Software in accordance with these Terms and
100
+ > Conditions.
101
+
102
+ A careful first reading can mistake this list for the *exclusive* set of
103
+ permitted uses — leading to the (incorrect) conclusion that commercial
104
+ product distribution is prohibited.
105
+
106
+ It isn't. **The operative definition is broader.** Earlier in the same
107
+ section, the license states:
108
+
109
+ > A "Permitted Purpose" is any purpose other than a Competing Use.
110
+
111
+ The four enumerated items are **illustrative examples** added because those
112
+ specific cases are ones a careful reader might otherwise hesitate about
113
+ ("is research permitted? is consulting permitted?"). The four items are
114
+ additive clarifications, not a closing of the open-ended definition.
115
+
116
+ Sentry, who authored FSL and uses it on their own software, [confirms this
117
+ explicitly in their FAQ](https://fsl.software):
118
+
119
+ > "You can do anything with FSL software except undermine its producer. You
120
+ > can run it for almost all purposes, study it, modify it, and distribute
121
+ > your changes…"
122
+
123
+ If the license felt restrictive on first read, that's a documented
124
+ [FSL adoption hazard](https://fair.io) — many developers hit the same wall.
125
+ The answer is to read the "any purpose other than a Competing Use" line as
126
+ the operative definition and treat the four enumerated items as examples,
127
+ not as a closed list.
128
+
129
+ ## Will it become Apache 2.0?
130
+
131
+ **Yes — automatically, on a per-version schedule.** Each released version of
132
+ the runtime stack converts to Apache 2.0 exactly two years after its release
133
+ date. The conversion is irrevocable and written into the license text — it's
134
+ not a promise from Lloyal Labs, it's a contractual clause.
135
+
136
+ For example: if `lloyal-sdk @lloyal-labs/lloyal-agents` v3.0.0 is released
137
+ on 2026-06-01, that exact version becomes available under Apache 2.0 on
138
+ 2028-06-01. Any consumer can elect to use that version under Apache 2.0
139
+ from that date forward — Lloyal Labs takes no action; the grant is
140
+ automatic.
141
+
142
+ New versions released after v3.0.0 start their own two-year clock from
143
+ their own release dates. There is no single global Change Date.
144
+
145
+ ## Is this OSI-approved open source?
146
+
147
+ **No, and we want to be honest about that.** FSL is not OSI-approved
148
+ because the OSI definition of open source (clause 6, "No Discrimination
149
+ Against Fields of Endeavor") does not permit restrictions on specific
150
+ use cases. FSL restricts Competing Use. That restriction takes it out of
151
+ strict OSI compliance.
152
+
153
+ FSL falls under the [Fair Source](https://fair.io) classification —
154
+ source-available licenses that are explicitly developer-friendly:
155
+ commercial use permitted, free redistribution, eventual open-source
156
+ conversion. Fair Source is a more developer-friendly framing than the
157
+ generic "source-available" label, which has been tainted by the
158
+ SSPL / Elastic / MongoDB relicensing trauma cycles.
159
+
160
+ What this means practically:
161
+
162
+ - **You can read the source.** ✅
163
+ - **You can modify it.** ✅
164
+ - **You can sell products built with it.** ✅
165
+ - **You can redistribute it (with the same FSL terms).** ✅
166
+ - **It will be Apache 2.0 in two years.** ✅
167
+ - Some enterprise procurement policies that strictly require OSI-approved
168
+ licenses will require an exception for this. We're working on making
169
+ that exception easy to grant.
170
+
171
+ ## Why FSL specifically — why not stay Apache?
172
+
173
+ HDK 3.0 introduces installable HDK Apps. Every App declares against a
174
+ specific App protocol — the bytes-locked intro, catalog format,
175
+ tool-selection rule, and boundary marker that the runtime renders into
176
+ the spine. Your App's reliability depends on every HDK runtime your users
177
+ install agreeing on the same protocol.
178
+
179
+ Under a permissive license alone, the protocol is forkable. A
180
+ well-resourced redistributor could fork the runtime, modify the protocol
181
+ surface, and distribute a variant under a different name with captive
182
+ distribution. App developers then face a fragmented ecosystem: target one
183
+ protocol, target both, or pick the bigger distribution and abandon the
184
+ others. The cost of that split is paid by App developers in testing
185
+ burden, divergent behavior, and reliability degradation across runtimes.
186
+
187
+ FSL's two-year Competing Use restriction is shaped to block that
188
+ fragmentation specifically. After the conversion, anyone can build
189
+ whatever they want — by which time the protocol has had enough time to
190
+ stabilize through ecosystem use and the protection is no longer the load-
191
+ bearing thing keeping it coherent.
192
+
193
+ For the longer treatment of this argument, see
194
+ [Why FSL](./why-fsl).
195
+
196
+ We could have used Apache 2.0 and tried to protect only the channel via
197
+ terms-of-service. We could have written a custom license. We chose
198
+ standard FSL because it's:
199
+
200
+ - **Off-the-shelf** — no bespoke license review at every adopter
201
+ - **Recognizable** — Sentry, PowerSync, and others use it
202
+ - **Documented** — the FAQ, definitions, and edge cases have been
203
+ litigated publicly
204
+ - **Time-bounded** — the protocolual Apache 2.0 conversion is the answer
205
+ to the "is this just source-available forever?" critique
206
+ - **Pre-launch** — relicensing at HDK 3.0 launch is structurally
207
+ different from MongoDB / Elastic / HashiCorp relicensing under an
208
+ existing installed base, which is what causes the backlash cycle
209
+
210
+ ## What about the lloyal stack — what's under FSL and what's not?
211
+
212
+ | Component | License | Why |
213
+ |---|---|---|
214
+ | `liblloyal` (C++ engine) | FSL-1.1-Apache-2.0 | Native primitives the runtime is built on |
215
+ | `lloyal-node` (N-API binding) | FSL-1.1-Apache-2.0 | The binding that lets Effection drive llama.cpp |
216
+ | `@lloyal-labs/lloyal-agents` | FSL-1.1-Apache-2.0 | Runtime framework |
217
+ | `@lloyal-labs/lloyal-sdk` | FSL-1.1-Apache-2.0 | Runtime framework |
218
+ | `@lloyal-labs/rig` | FSL-1.1-Apache-2.0 | Runtime framework — holds the App protocol |
219
+ | `@lloyal-labs/corpus`, `@lloyal-labs/web` | FSL-1.1-Apache-2.0 | Reference Apps shipped in-tree |
220
+ | **`@lloyal-labs/harness-cli` (the `harness.dev` CLI)** | **Apache 2.0** | Scaffolder — unrestricted for scaffolding new harnesses and Apps |
221
+ | **`hdk-create-app`** (when shipped) | **Apache 2.0** | Scaffolder — same as above |
222
+ | `llama.cpp` (vendored dependency) | MIT (unchanged) | External upstream library; we don't relicense their code |
223
+
224
+ ## Can I contribute to HDK?
225
+
226
+ **Yes.** Contributions are welcome under the same FSL license terms. If you
227
+ submit a PR, you're granting Lloyal Labs the right to distribute your
228
+ contribution under FSL-1.1-Apache-2.0 (and automatically under Apache 2.0
229
+ two years after each release that includes it). The CONTRIBUTING file in
230
+ each repo has the details.
231
+
232
+ ## I have a use case that's borderline — who do I ask?
233
+
234
+ Email [legal@lloyal.ai](mailto:legal@lloyal.ai) (or open a discussion in the repo). The runtime
235
+ team will help you confirm whether your use case falls under Permitted
236
+ Purpose or Competing Use. We'd rather give you a quick yes than have you
237
+ worry about it.
238
+
239
+ ## Further reading
240
+
241
+ - [FSL official site](https://fsl.software) — Sentry's canonical FSL
242
+ resources and FAQ
243
+ - [Fair Source](https://fair.io) — the category FSL belongs to
244
+ - [The FSL template, instantiated for each repo](./fsl-template)
245
+ - [Why we chose FSL over BSL, Apache, or a custom license](./why-fsl)
246
+
247
+ ## Is there a safe harbor for building products with the HDK?
248
+
249
+ Yes. The [Lloyal Harness Builder Grant](https://github.com/lloyal-ai/hdk/blob/main/GRANT.md)
250
+ irrevocably guarantees that building, selling, and hosting Harnesses and Apps
251
+ is a Permitted Purpose and never a Competing Use — even products that compete
252
+ head-on with Lloyal's own (including reasoning.run). Only three uses remain
253
+ restricted: offering the HDK itself as a developer framework, hosting the HDK
254
+ as-a-service for third-party developers, and operating a general-purpose App
255
+ distribution channel. Private/internal App distribution and your Harness's
256
+ own plugin system are explicitly permitted.
package/README.md CHANGED
@@ -162,4 +162,4 @@ export type { SessionContext, SamplingParams, Produced, ContextOptions, ... };
162
162
 
163
163
  ## License
164
164
 
165
- Apache-2.0
165
+ See [LICENSE](./LICENSE) (Functional Source License 1.1 — Apache 2.0 Future License) and the [licensing FAQ](./LICENSE-FAQ.md).
package/dist/Branch.d.ts CHANGED
@@ -1,4 +1,31 @@
1
1
  import type { SessionContext, SamplingParams, Produced, GrammarTrigger } from './types';
2
+ /**
3
+ * Options for {@link Branch.fork} / {@link Branch.forkSync}.
4
+ */
5
+ export interface ForkOpts {
6
+ /**
7
+ * When true (default), copy parent's captured logits snapshot to child
8
+ * (~600KB at 150k vocab). When false, skip the snapshot copy — useful for
9
+ * prefill-overwrite consumers (rerank leaves, embedding probes). Child has
10
+ * no logits until prefill()/step() runs; calling sample() before that
11
+ * throws {@link BranchSampleError}.
12
+ */
13
+ cloneLogits?: boolean;
14
+ }
15
+ /**
16
+ * Thrown when {@link Branch.sample} is called on a branch that cannot sample.
17
+ *
18
+ * The native kernel returns -1 as a sentinel value when either:
19
+ * (1) no logits are captured (the branch hasn't been prefilled/stepped); or
20
+ * (2) no sampler chain is configured.
21
+ *
22
+ * Without this guard the -1 would silently flow into consumer code as a token
23
+ * id, producing wrong continuations downstream. This typed error names both
24
+ * root causes so callers can fix at the right layer.
25
+ */
26
+ export declare class BranchSampleError extends Error {
27
+ readonly name = "BranchSampleError";
28
+ }
2
29
  /**
3
30
  * Forkable inference handle for covalent generation
4
31
  *
@@ -70,7 +97,7 @@ export declare class Branch {
70
97
  *
71
98
  * @returns New forked Branch
72
99
  */
73
- fork(): Promise<Branch>;
100
+ fork(opts?: ForkOpts): Promise<Branch>;
74
101
  /**
75
102
  * Fork this branch to a new sequence (sync)
76
103
  *
@@ -81,9 +108,16 @@ export declare class Branch {
81
108
  *
82
109
  * Call reseedSampler() on each child for stochastic diversity.
83
110
  *
111
+ * @param opts.cloneLogits - When true (default), copy parent's captured
112
+ * logits snapshot so the child can sample the same distribution. When
113
+ * false, skip the snapshot copy (~600KB at 150k vocab) — useful for
114
+ * prefill-overwrite consumers (rerank leaves, embedding probes) that
115
+ * fork → prefill → read → prune and never sample the parent's
116
+ * distribution. The child has no logits until prefill()/step() runs,
117
+ * so calling sample() before that throws BranchSampleError.
84
118
  * @returns New forked Branch
85
119
  */
86
- forkSync(): Branch;
120
+ forkSync(opts?: ForkOpts): Branch;
87
121
  /**
88
122
  * Get a copy of this branch's captured logits snapshot.
89
123
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Branch.d.ts","sourceRoot":"","sources":["../src/Branch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGxF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,IAAI,CAAiB;IAC7B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAU;gBAEf,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM;IAM/C;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,MAAM,CACX,GAAG,EAAE,c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C,kBAAkB;CAK3B"}
package/dist/Branch.js CHANGED
@@ -1,7 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Branch = void 0;
3
+ exports.Branch = exports.BranchSampleError = void 0;
4
4
  const types_1 = require("./types");
5
+ /**
6
+ * Thrown when {@link Branch.sample} is called on a branch that cannot sample.
7
+ *
8
+ * The native kernel returns -1 as a sentinel value when either:
9
+ * (1) no logits are captured (the branch hasn't been prefilled/stepped); or
10
+ * (2) no sampler chain is configured.
11
+ *
12
+ * Without this guard the -1 would silently flow into consumer code as a token
13
+ * id, producing wrong continuations downstream. This typed error names both
14
+ * root causes so callers can fix at the right layer.
15
+ */
16
+ class BranchSampleError extends Error {
17
+ name = 'BranchSampleError';
18
+ }
19
+ exports.BranchSampleError = BranchSampleError;
5
20
  /**
6
21
  * Forkable inference handle for covalent generation
7
22
  *
@@ -80,8 +95,8 @@ class Branch {
80
95
  *
81
96
  * @returns New forked Branch
82
97
  */
83
- async fork() {
84
- return this.forkSync();
98
+ async fork(opts) {
99
+ return this.forkSync(opts);
85
100
  }
86
101
  /**
87
102
  * Fork this branch to a new sequence (sync)
@@ -93,11 +108,19 @@ class Branch {
93
108
  *
94
109
  * Call reseedSampler() on each child for stochastic diversity.
95
110
  *
111
+ * @param opts.cloneLogits - When true (default), copy parent's captured
112
+ * logits snapshot so the child can sample the same distribution. When
113
+ * false, skip the snapshot copy (~600KB at 150k vocab) — useful for
114
+ * prefill-overwrite consumers (rerank leaves, embedding probes) that
115
+ * fork → prefill → read → prune and never sample the parent's
116
+ * distribution. The child has no logits until prefill()/step() runs,
117
+ * so calling sample() before that throws BranchSampleError.
96
118
  * @returns New forked Branch
97
119
  */
98
- forkSync() {
120
+ forkSync(opts) {
99
121
  this._ensureNotDisposed();
100
- const newHandle = this._ctx._branchFork(this._handle);
122
+ const cloneLogits = opts?.cloneLogits ?? true;
123
+ const newHandle = this._ctx._branchFork(this._handle, cloneLogits);
101
124
  return new Branch(this._ctx, newHandle);
102
125
  }
103
126
  /**
@@ -166,7 +189,13 @@ class Branch {
166
189
  */
167
190
  sample() {
168
191
  this._ensureNotDisposed();
169
- return this._ctx._branchSample(this._handle);
192
+ const token = this._ctx._branchSample(this._handle);
193
+ if (token === -1) {
194
+ throw new BranchSampleError(`Branch.sample() returned -1 — possible causes: ` +
195
+ `(1) no logits captured (call prefill() or step() first); ` +
196
+ `(2) no sampler chain configured.`);
197
+ }
198
+ return token;
170
199
  }
171
200
  /**
172
201
  * Record token in the sampler's repeat/presence penalty window
@@ -1 +1 @@
1
- {"version":3,"file":"Branch.js","sourceRoot":"","sources":["../src/Branch.ts"],"names":[],"mappings":";;;AACA,mCAA6C;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAa,MAAM;IACT,IAAI,CAAiB;IACrB,OAAO,CAAS;IAChB,SAAS,CAAU;IAE3B,YAAY,GAAmB,EAAE,MAAc;QAC7C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,MAAM,CACX,GAAmB,EACnB,QAAgB,EAChB,MAAuB,EACvB,MAAe,EACf,OAAgB;QAEhB,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACpE,OAAO,IAAI,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,QAAQ;QACN,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,MAAM,SAAS,GAAG,IAAI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