@byollm/protocol 0.1.0-alpha.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 +21 -0
- package/README.md +68 -0
- package/dist/index.d.ts +930 -0
- package/dist/index.js +663 -0
- package/dist/index.js.map +1 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Of Tomorrow, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# `@byollm/protocol`
|
|
2
|
+
|
|
3
|
+
The BYOLLM wire contract: TypeScript types, zod schemas, and the pure rules
|
|
4
|
+
that the daemon and the server **both** enforce.
|
|
5
|
+
|
|
6
|
+
Nothing in this package does I/O. That is the point — the daemon refuses
|
|
7
|
+
misbehaviour, and the server refuses it too, and both run the identical
|
|
8
|
+
function rather than two implementations that drift.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @byollm/protocol
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## What's in here
|
|
15
|
+
|
|
16
|
+
| Export | What it is |
|
|
17
|
+
| ----------------------------------- | -------------------------------------------------------------------------------------- |
|
|
18
|
+
| `matchAudience` | The nine-way audience × offer-scope decision, as a pure total function. |
|
|
19
|
+
| `effectiveOfferScope` | The subscription self-lock, applied at one place so no code path sees a widened scope. |
|
|
20
|
+
| `MUSTS` | Every normative MUST as data. The conformance kit fails if one has no test. |
|
|
21
|
+
| `BACKENDS` | The backend registry — class (`http`/`process`) and account (`open`/`subscription`). |
|
|
22
|
+
| `ClaimedJob`, `HeartbeatRequest`, … | Schemas for the five endpoints. |
|
|
23
|
+
| `canTransition`, `isTerminal` | The job lifecycle, as data. |
|
|
24
|
+
| `provenanceFor` | Builds a result's provenance; `untrusted` is derived, never supplied. |
|
|
25
|
+
|
|
26
|
+
## The two rules worth knowing
|
|
27
|
+
|
|
28
|
+
**A payload is data handed to a model, never configuration.** There is no
|
|
29
|
+
field on the wire for a model, a base URL, a flag, a path, or an environment
|
|
30
|
+
variable, and payload objects are `strict()` — an unknown key is a parse
|
|
31
|
+
failure, not something quietly ignored deeper in.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { GeneratePayload } from "@byollm/protocol";
|
|
35
|
+
|
|
36
|
+
GeneratePayload.safeParse({ prompt: "hi", model: "gpt-4" }).success; // false
|
|
37
|
+
GeneratePayload.parse({ prompt: "$(rm -rf /)" }).prompt; // "$(rm -rf /)" — just characters
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Both sides must admit the other.** A job runs on a daemon only if the job's
|
|
41
|
+
audience admits the daemon's owner _and_ the backend's offer scope admits the
|
|
42
|
+
job's owner.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { matchAudience } from "@byollm/protocol";
|
|
46
|
+
|
|
47
|
+
matchAudience(
|
|
48
|
+
{ owner: "alice", audience: "named" },
|
|
49
|
+
{
|
|
50
|
+
owner: "bob",
|
|
51
|
+
offerScope: "named",
|
|
52
|
+
account: "open",
|
|
53
|
+
// The daemon's OWN allowlist decides — never the server's assertion.
|
|
54
|
+
locallyAllows: (owner) => owner === "alice",
|
|
55
|
+
},
|
|
56
|
+
); // { ok: true }
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Refusals are typed and distinct (`not-locally-allowed` is not the same event
|
|
60
|
+
as `offer-scope-too-narrow`), because a volunteer debugging their setup needs
|
|
61
|
+
to know which one happened.
|
|
62
|
+
|
|
63
|
+
## Normative spec
|
|
64
|
+
|
|
65
|
+
[`docs/protocol.md`](../../docs/protocol.md). Every MUST there carries a
|
|
66
|
+
conformance id that appears in this package's `MUSTS` registry.
|
|
67
|
+
|
|
68
|
+
MIT
|