@lloyal-labs/lloyal-agents 2.1.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 +17 -1
- package/dist/Agent.d.ts +13 -2
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +10 -0
- package/dist/Agent.js.map +1 -1
- package/dist/AgentPolicy.d.ts +84 -7
- package/dist/AgentPolicy.d.ts.map +1 -1
- package/dist/AgentPolicy.js +32 -4
- package/dist/AgentPolicy.js.map +1 -1
- package/dist/Tool.d.ts +44 -0
- package/dist/Tool.d.ts.map +1 -1
- package/dist/Tool.js +49 -1
- package/dist/Tool.js.map +1 -1
- package/dist/agent-pool.d.ts.map +1 -1
- package/dist/agent-pool.js +187 -16
- 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 +68 -12
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +64 -12
- package/dist/context.js.map +1 -1
- package/dist/create-agent-pool.d.ts +10 -4
- package/dist/create-agent-pool.d.ts.map +1 -1
- package/dist/create-agent-pool.js +7 -6
- 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 +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/orchestrators.d.ts +7 -0
- package/dist/orchestrators.d.ts.map +1 -1
- package/dist/orchestrators.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 +0 -6
- package/dist/spine.d.ts.map +1 -1
- package/dist/spine.js +18 -2
- package/dist/spine.js.map +1 -1
- 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 +34 -2
- package/dist/trace-types.d.ts.map +1 -1
- package/dist/types.d.ts +27 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/use-agent.d.ts +9 -4
- package/dist/use-agent.d.ts.map +1 -1
- package/dist/use-agent.js +15 -12
- package/dist/use-agent.js.map +1 -1
- package/package.json +7 -5
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
|
@@ -31,6 +31,16 @@ import {
|
|
|
31
31
|
Tool, Source,
|
|
32
32
|
DefaultAgentPolicy,
|
|
33
33
|
Ctx, Store, Events,
|
|
34
|
+
// App protocol primitives — types + contexts the registry + agent pool
|
|
35
|
+
// pick up. Construction lives in `@lloyal-labs/rig` (`defineApp`,
|
|
36
|
+
// `createAppRegistry`).
|
|
37
|
+
AppRegistryCtx, AppConfigStoreCtx, GrantStoreCtx, RerankerCtx,
|
|
38
|
+
} from "@lloyal-labs/lloyal-agents";
|
|
39
|
+
|
|
40
|
+
import type {
|
|
41
|
+
App, AppManifest, AppProtocol, AppFactory, AppState,
|
|
42
|
+
AgentRenderCtx, SkillTemplateFn,
|
|
43
|
+
AppConfigStore, GrantStore,
|
|
34
44
|
} from "@lloyal-labs/lloyal-agents";
|
|
35
45
|
```
|
|
36
46
|
|
|
@@ -233,10 +243,16 @@ The runtime emits structured events for TUI, logging, or telemetry:
|
|
|
233
243
|
| `agent:recovered` | `agentId`, `result` — recovery extracted findings from killed agent |
|
|
234
244
|
| `agent:done` | `agentId` |
|
|
235
245
|
|
|
246
|
+
## App protocol
|
|
247
|
+
|
|
248
|
+
`lloyal-agents` ships the App protocol primitives — types ({@link App}, {@link AppManifest}, {@link AppProtocol}, {@link AppRegistry}), contexts (`AppRegistryCtx`, `AppConfigStoreCtx`, `GrantStoreCtx`, `RerankerCtx`), and the `Tool.protected` flag + authGuard hook in the agent policy. Construction primitives — `defineApp`, `createAppRegistry`, `createInMemoryConfigStore`, `createGrantStore`, `renderSpine`, `renderAgentPreamble` — live in [`@lloyal-labs/rig`](../rig). Reference Apps (`@lloyal-labs/web-app`, `@lloyal-labs/corpus-app`, `@lloyal-labs/wikipedia-app`) consume both.
|
|
249
|
+
|
|
250
|
+
Scaffold an App with `npx harness.dev app <name>`; install one with `npx harness.dev install <publisher>/<name>`.
|
|
251
|
+
|
|
236
252
|
## Documentation
|
|
237
253
|
|
|
238
254
|
Full positioning, mechanics, learn pages, and reference at [docs.lloyal.ai](https://docs.lloyal.ai).
|
|
239
255
|
|
|
240
256
|
## License
|
|
241
257
|
|
|
242
|
-
Apache
|
|
258
|
+
See [LICENSE](./LICENSE) (Functional Source License 1.1 — Apache 2.0 Future License) and the [licensing FAQ](./LICENSE-FAQ.md).
|
package/dist/Agent.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { TraceToken } from './types';
|
|
|
6
6
|
* Agent status — domain language for where the agent is in its lifecycle.
|
|
7
7
|
*
|
|
8
8
|
* - `idle`: created but not yet generating, OR finished but branch still
|
|
9
|
-
* alive (extraction window for
|
|
9
|
+
* alive (extraction window for recovery)
|
|
10
10
|
* - `active`: generating tokens (between PRODUCE start and stop token)
|
|
11
11
|
* - `awaiting_tool`: tool call parsed, waiting for result in SETTLE
|
|
12
12
|
* - `disposed`: branch pruned, agent no longer usable
|
|
@@ -19,7 +19,7 @@ export type AgentStatus = 'idle' | 'active' | 'awaiting_tool' | 'disposed';
|
|
|
19
19
|
*
|
|
20
20
|
* @category Agents
|
|
21
21
|
*/
|
|
22
|
-
export type ResultSource = 'voluntary_return' | 'free_text' | '
|
|
22
|
+
export type ResultSource = 'voluntary_return' | 'free_text' | 'recovery' | 'nudge' | 'tool_error';
|
|
23
23
|
/**
|
|
24
24
|
* Immutable prompt format configuration set at agent creation.
|
|
25
25
|
* Derived from `formatChatSync()` output.
|
|
@@ -91,6 +91,15 @@ export declare class Agent {
|
|
|
91
91
|
readonly fmt: FormatConfig;
|
|
92
92
|
/** The task text this agent was assigned — used by echo detection guard */
|
|
93
93
|
readonly task: string;
|
|
94
|
+
/**
|
|
95
|
+
* Optional non-enforcing label naming the App a spawn nominally belongs
|
|
96
|
+
* to (`SpawnSpec.assignedApp`), or `null` for harness-internal spawns.
|
|
97
|
+
* Purely informational since the authGuard moved the security boundary
|
|
98
|
+
* into the tool: tool access is gated by {@link Tool.protected}
|
|
99
|
+
* + session grants, not by app membership. Carried so trace events
|
|
100
|
+
* (`tool:authReject`) and harness UI can attribute work to an app.
|
|
101
|
+
*/
|
|
102
|
+
readonly assignedApp: string | null;
|
|
94
103
|
private _status;
|
|
95
104
|
private _statusSignal;
|
|
96
105
|
private _startedAt;
|
|
@@ -115,6 +124,8 @@ export declare class Agent {
|
|
|
115
124
|
fmt: FormatConfig;
|
|
116
125
|
parent?: Agent | null;
|
|
117
126
|
task?: string;
|
|
127
|
+
/** Optional non-enforcing app label — see {@link assignedApp}. */
|
|
128
|
+
assignedApp?: string | null;
|
|
118
129
|
});
|
|
119
130
|
get status(): AgentStatus;
|
|
120
131
|
/**
|
package/dist/Agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../src/Agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,GAAG,UAAU,CAAC;AAE3E;;;;GAIG;AACH,MAAM,MAAM,YAAY,GACpB,kBAAkB,GAClB,WAAW,GACX,
|
|
1
|
+
{"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../src/Agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,GAAG,UAAU,CAAC;AAE3E;;;;GAIG;AACH,MAAM,MAAM,YAAY,GACpB,kBAAkB,GAClB,WAAW,GACX,UAAU,GACV,OAAO,GACP,YA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AAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IASvF,oEAAoE;IACpE,OAAO,IAAI,IAAI;CAIhB"}
|
package/dist/Agent.js
CHANGED
|
@@ -32,6 +32,15 @@ class Agent {
|
|
|
32
32
|
fmt;
|
|
33
33
|
/** The task text this agent was assigned — used by echo detection guard */
|
|
34
34
|
task;
|
|
35
|
+
/**
|
|
36
|
+
* Optional non-enforcing label naming the App a spawn nominally belongs
|
|
37
|
+
* to (`SpawnSpec.assignedApp`), or `null` for harness-internal spawns.
|
|
38
|
+
* Purely informational since the authGuard moved the security boundary
|
|
39
|
+
* into the tool: tool access is gated by {@link Tool.protected}
|
|
40
|
+
* + session grants, not by app membership. Carried so trace events
|
|
41
|
+
* (`tool:authReject`) and harness UI can attribute work to an app.
|
|
42
|
+
*/
|
|
43
|
+
assignedApp;
|
|
35
44
|
// ── Mutable state ───────────────────────────────────────
|
|
36
45
|
_status = 'idle';
|
|
37
46
|
_statusSignal = (0, effection_1.createSignal)();
|
|
@@ -58,6 +67,7 @@ class Agent {
|
|
|
58
67
|
this.fmt = opts.fmt;
|
|
59
68
|
this.task = opts.task ?? '';
|
|
60
69
|
this.parent = opts.parent ?? null;
|
|
70
|
+
this.assignedApp = opts.assignedApp ?? null;
|
|
61
71
|
}
|
|
62
72
|
// ── Status ──────────────────────────────────────────────
|
|
63
73
|
get status() { return this._status; }
|
package/dist/Agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Agent.js","sourceRoot":"","sources":["../src/Agent.ts"],"names":[],"mappings":";;;AAEA,yCAAsD;AA+EtD,+DAA+D;AAE/D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,KAAK;IAChB,2DAA2D;IAE3D,+CAA+C;IACtC,EAAE,CAAS;IAEpB,uEAAuE;IAC9D,QAAQ,CAAS;IAE1B,sCAAsC;IAC7B,MAAM,CAAS;IAExB,4CAA4C;IACnC,GAAG,CAAe;I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C,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;CACF;AAzRD,sBAyRC"}
|
package/dist/AgentPolicy.d.ts
CHANGED
|
@@ -1,20 +1,42 @@
|
|
|
1
1
|
import type { Agent, ToolHistoryEntry } from './Agent';
|
|
2
|
+
import type { ToolRetryError } from './Tool';
|
|
2
3
|
import { ContextPressure } from './agent-pool';
|
|
3
4
|
import type { ParsedToolCall } from '@lloyal-labs/sdk';
|
|
4
5
|
import type { PressureThresholds } from './types';
|
|
5
6
|
/**
|
|
6
|
-
* A declarative guard that rejects tool calls based on agent
|
|
7
|
+
* A declarative guard that rejects tool calls based on agent state.
|
|
7
8
|
* Guards are checked in order before any tool is dispatched.
|
|
8
9
|
*
|
|
10
|
+
* `tools` selects which tool calls this guard sees: a `string[]` matches
|
|
11
|
+
* by exact name; the literal `'*'` matches every call (used by the
|
|
12
|
+
* framework-injected authGuard — guards that need to
|
|
13
|
+
* inspect *every* call regardless of tool name).
|
|
14
|
+
*
|
|
15
|
+
* `reject` returns `true` to reject the call with `message`. It receives
|
|
16
|
+
* the parsed args, the full agent lineage's tool history, the agent
|
|
17
|
+
* itself, `toolName` (so `tools: '*'` guards know which tool they're
|
|
18
|
+
* gating), and the pool-level `config` (so guards can consult
|
|
19
|
+
* pool-resolved state such as the protected-tool set and the session's
|
|
20
|
+
* grants — see {@link PolicyConfig}). Guards that don't need `config`
|
|
21
|
+
* simply omit the parameter.
|
|
22
|
+
*
|
|
23
|
+
* `name` is the optional guard identifier surfaced via
|
|
24
|
+
* `ProduceAction.nudge.guard` so the pool can emit per-guard trace
|
|
25
|
+
* events (e.g., `tool:authReject` for `name: 'auth_reject'`). Omit it
|
|
26
|
+
* for guards whose only observable footprint is the resulting
|
|
27
|
+
* `pool:agentNudge` event.
|
|
28
|
+
*
|
|
9
29
|
* @category Agents
|
|
10
30
|
*/
|
|
11
31
|
export interface ToolGuard {
|
|
12
|
-
/** Tool names this guard applies to */
|
|
13
|
-
tools: string[];
|
|
14
|
-
/** Return true to reject the call.
|
|
15
|
-
reject: (args: Record<string, unknown>, lineageHistory: ToolHistoryEntry[], agent: Agent) => boolean;
|
|
16
|
-
/** Error message sent back to the agent as a tool result */
|
|
32
|
+
/** Tool names this guard applies to; `'*'` matches every call. */
|
|
33
|
+
tools: string[] | '*';
|
|
34
|
+
/** Return true to reject the call. */
|
|
35
|
+
reject: (args: Record<string, unknown>, lineageHistory: ToolHistoryEntry[], agent: Agent, toolName: string, config: PolicyConfig) => boolean;
|
|
36
|
+
/** Error message sent back to the agent as a tool result. */
|
|
17
37
|
message: string;
|
|
38
|
+
/** Optional identifier surfaced via `ProduceAction.nudge.guard`. */
|
|
39
|
+
name?: string;
|
|
18
40
|
}
|
|
19
41
|
export declare const defaultToolGuards: ToolGuard[];
|
|
20
42
|
/**
|
|
@@ -32,9 +54,14 @@ export type ProduceAction = {
|
|
|
32
54
|
} | {
|
|
33
55
|
type: 'return';
|
|
34
56
|
result: string;
|
|
35
|
-
}
|
|
57
|
+
}
|
|
58
|
+
/** `guard` carries the identifier of the rejecting `ToolGuard` — used to
|
|
59
|
+
* route `auth_reject` rejections to the `tool:authReject` trace event.
|
|
60
|
+
* Absent for nudges not produced by a guard. */
|
|
61
|
+
| {
|
|
36
62
|
type: 'nudge';
|
|
37
63
|
message: string;
|
|
64
|
+
guard?: string;
|
|
38
65
|
} | {
|
|
39
66
|
type: 'idle';
|
|
40
67
|
reason: IdleReason;
|
|
@@ -67,6 +94,25 @@ export type RecoveryAction = {
|
|
|
67
94
|
} | {
|
|
68
95
|
type: 'skip';
|
|
69
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* Action returned by policy.onToolRetry — what to do when a tool throws
|
|
99
|
+
* {@link ToolRetryError} (transient failure, e.g. provider rate-limited).
|
|
100
|
+
*
|
|
101
|
+
* `retry` parks the agent (`awaiting_tool`, skipped by PRODUCE at zero
|
|
102
|
+
* cost — no turns, no tokens, no KV) and re-executes the same call after
|
|
103
|
+
* `afterMs` (defaults to the error's own `retryAfterMs` estimate).
|
|
104
|
+
* `fail` settles `message` (or the pool's directive default) as the tool
|
|
105
|
+
* result so the model can pivot.
|
|
106
|
+
*
|
|
107
|
+
* @category Agents
|
|
108
|
+
*/
|
|
109
|
+
export type ToolRetryAction = {
|
|
110
|
+
type: 'retry';
|
|
111
|
+
afterMs?: number;
|
|
112
|
+
} | {
|
|
113
|
+
type: 'fail';
|
|
114
|
+
message?: string;
|
|
115
|
+
};
|
|
70
116
|
/**
|
|
71
117
|
* Agent lifecycle policy — injected strategy for pressure, nudge,
|
|
72
118
|
* recursion, report timing, and result quality decisions.
|
|
@@ -154,6 +200,18 @@ export interface AgentPolicy {
|
|
|
154
200
|
* Optional — defaults to skip when absent.
|
|
155
201
|
*/
|
|
156
202
|
onRecovery?(agent: Agent, pressure: ContextPressure): RecoveryAction;
|
|
203
|
+
/**
|
|
204
|
+
* Transient tool failure (the tool threw {@link ToolRetryError}).
|
|
205
|
+
* Decide whether to park-and-retry or settle a failure result. The tool
|
|
206
|
+
* supplies a `retryAfterMs` estimate on the error; the policy may override
|
|
207
|
+
* it (`afterMs`) or refuse to wait at all — e.g. when the time budget
|
|
208
|
+
* can't afford a park.
|
|
209
|
+
*
|
|
210
|
+
* Absent → pool default: one retry at the error's own delay, then fail.
|
|
211
|
+
*
|
|
212
|
+
* @param attempt - 1 on the first failure of a call, 2 after one retry, …
|
|
213
|
+
*/
|
|
214
|
+
onToolRetry?(agent: Agent, tool: string, error: ToolRetryError, attempt: number): ToolRetryAction;
|
|
157
215
|
}
|
|
158
216
|
/**
|
|
159
217
|
* Pool-level configuration passed to policy methods.
|
|
@@ -163,6 +221,20 @@ export interface PolicyConfig {
|
|
|
163
221
|
maxTurns: number;
|
|
164
222
|
terminalToolName?: string;
|
|
165
223
|
hasNonTerminalTools: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Tool names this pool declares `protected` (gathered from each
|
|
226
|
+
* {@link Tool.protected} flag). The authGuard gates only these; every
|
|
227
|
+
* other tool is open. Resolved once at pool setup. Undefined/empty when
|
|
228
|
+
* no tool in the pool is protected (the common case).
|
|
229
|
+
*/
|
|
230
|
+
protectedTools?: ReadonlySet<string>;
|
|
231
|
+
/**
|
|
232
|
+
* Protected tool names the session currently holds a grant for — read
|
|
233
|
+
* from {@link GrantStoreCtx} at pool setup. The authGuard allows a
|
|
234
|
+
* protected tool iff its name is in this set. Undefined/empty = no
|
|
235
|
+
* grants (fail-closed: every protected tool denied).
|
|
236
|
+
*/
|
|
237
|
+
grants?: ReadonlySet<string>;
|
|
166
238
|
}
|
|
167
239
|
/**
|
|
168
240
|
* Default policy replicating the current inline if-logic from agent-pool.ts.
|
|
@@ -232,6 +304,9 @@ export interface DefaultAgentPolicyOpts {
|
|
|
232
304
|
* protected from shouldExit — the hard limit is deferred until the tool
|
|
233
305
|
* call completes naturally or KV pressure forces a kill. */
|
|
234
306
|
terminalToolName?: string;
|
|
307
|
+
/** Max park-and-retry attempts per tool call on {@link ToolRetryError}
|
|
308
|
+
* before failing the call with a directive result. @default 1 */
|
|
309
|
+
maxToolRetries?: number;
|
|
235
310
|
}
|
|
236
311
|
export declare class DefaultAgentPolicy implements AgentPolicy {
|
|
237
312
|
private _minToolCalls;
|
|
@@ -242,8 +317,10 @@ export declare class DefaultAgentPolicy implements AgentPolicy {
|
|
|
242
317
|
private _recovery;
|
|
243
318
|
private _budget;
|
|
244
319
|
private _terminalToolName;
|
|
320
|
+
private _maxToolRetries;
|
|
245
321
|
private _startTime;
|
|
246
322
|
constructor(opts?: DefaultAgentPolicyOpts);
|
|
323
|
+
onToolRetry(_agent: Agent, _tool: string, _error: ToolRetryError, attempt: number): ToolRetryAction;
|
|
247
324
|
/**
|
|
248
325
|
* Elapsed wall time for *this agent* (since its first idle→active transition),
|
|
249
326
|
* falling back to the policy's own construction time when the agent hasn't
|