seed-protocol 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +123 -0
- package/README.md +249 -0
- package/dist/index.d.mts +361 -0
- package/dist/index.d.ts +361 -0
- package/dist/index.js +493 -0
- package/dist/index.mjs +454 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Creative Commons Legal Code
|
|
2
|
+
|
|
3
|
+
CC0 1.0 Universal
|
|
4
|
+
|
|
5
|
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
|
6
|
+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
|
7
|
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
|
8
|
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
|
9
|
+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
|
10
|
+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
|
11
|
+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
12
|
+
HEREUNDER.
|
|
13
|
+
|
|
14
|
+
Statement of Purpose
|
|
15
|
+
|
|
16
|
+
The laws of most jurisdictions throughout the world automatically confer
|
|
17
|
+
exclusive Copyright and Related Rights (defined below) upon the creator
|
|
18
|
+
and subsequent owner(s) (each and all, an "owner") of an original work of
|
|
19
|
+
authorship and/or a database (each, a "Work").
|
|
20
|
+
|
|
21
|
+
Certain owners wish to permanently relinquish those rights to a Work for
|
|
22
|
+
the purpose of contributing to a commons of creative, cultural and
|
|
23
|
+
scientific works ("Commons") that the public can reliably and without fear
|
|
24
|
+
of later claims of infringement build upon, modify, incorporate in other
|
|
25
|
+
works, cite, and distribute, as permitted by law.
|
|
26
|
+
|
|
27
|
+
These owners may contribute to the Commons to promote the ideal of a free
|
|
28
|
+
culture and the further production of creative, cultural and scientific
|
|
29
|
+
works, or to gain reputation or greater distribution for their Work in
|
|
30
|
+
part through the use and efforts of others.
|
|
31
|
+
|
|
32
|
+
For these and/or other purposes and motivations, and without any
|
|
33
|
+
expectation of additional consideration or compensation, the person
|
|
34
|
+
associating CC0 with a Work (the "Affirmer"), to the extent that he or
|
|
35
|
+
she is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
36
|
+
elects to apply CC0 to the Work and publicly distribute the Work under
|
|
37
|
+
its terms, with knowledge of his or her Copyright and Related Rights in
|
|
38
|
+
the Work and the meaning and intended legal effect of CC0 on those rights.
|
|
39
|
+
|
|
40
|
+
1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
41
|
+
protected by copyright and related or neighboring rights ("Copyright and
|
|
42
|
+
Related Rights"). Copyright and Related Rights include, but are not
|
|
43
|
+
limited to, the following:
|
|
44
|
+
|
|
45
|
+
i. the right to reproduce, adapt, distribute, perform, display,
|
|
46
|
+
communicate, and translate a Work;
|
|
47
|
+
ii. moral rights retained by the original author(s) and/or performer(s);
|
|
48
|
+
iii. publicity and privacy rights pertaining to a person's image or
|
|
49
|
+
likeness depicted in a Work;
|
|
50
|
+
iv. rights protecting against unfair competition in regards to a Work,
|
|
51
|
+
subject to the limitations in paragraph 4(a), below;
|
|
52
|
+
v. rights protecting the extraction, dissemination, use and reuse of
|
|
53
|
+
data in a Work;
|
|
54
|
+
vi. database rights (such as those arising under Directive 96/9/EC of
|
|
55
|
+
the European Parliament and of the Council of 11 March 1996 on the
|
|
56
|
+
legal protection of databases, and under any national implementation
|
|
57
|
+
thereof, including any amended or updated version of such directive);
|
|
58
|
+
and
|
|
59
|
+
vii. other similar, equivalent or corresponding rights throughout the
|
|
60
|
+
world based on applicable law or treaty.
|
|
61
|
+
|
|
62
|
+
2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
63
|
+
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
64
|
+
irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
65
|
+
Affirmer's Copyright and Related Rights and associated claims and causes
|
|
66
|
+
of action, whether now known or unknown (including existing as well as
|
|
67
|
+
future claims and causes of action), in the Work (i) in all territories
|
|
68
|
+
worldwide, (ii) for the maximum duration provided by applicable law or
|
|
69
|
+
treaty (including future time extensions), (iii) in any current or future
|
|
70
|
+
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
71
|
+
including without limitation commercial, advertising or promotional
|
|
72
|
+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of
|
|
73
|
+
each member of the public at large and to the detriment of Affirmer's
|
|
74
|
+
heirs and successors, fully intending that such Waiver shall not be
|
|
75
|
+
subject to revocation, rescission, cancellation, termination, or any
|
|
76
|
+
other legal or equitable action to disrupt the quiet enjoyment of the
|
|
77
|
+
Work by the public as contemplated by Affirmer's express Statement of
|
|
78
|
+
Purpose.
|
|
79
|
+
|
|
80
|
+
3. Public License Fallback. Should any part of the Waiver for any reason
|
|
81
|
+
be judged legally invalid or ineffective under applicable law, then the
|
|
82
|
+
Waiver shall be preserved to the maximum extent permitted taking into
|
|
83
|
+
account Affirmer's express Statement of Purpose. In addition, to the
|
|
84
|
+
extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
85
|
+
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
86
|
+
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
87
|
+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
88
|
+
maximum duration provided by applicable law or treaty (including future
|
|
89
|
+
time extensions), (iii) in any current or future medium and for any
|
|
90
|
+
number of copies, and (iv) for any purpose whatsoever, including without
|
|
91
|
+
limitation commercial, advertising or promotional purposes (the
|
|
92
|
+
"License"). The License shall be deemed effective as of the date CC0 was
|
|
93
|
+
applied by Affirmer to the Work. Should any part of the License for any
|
|
94
|
+
reason be judged legally invalid or ineffective under applicable law, such
|
|
95
|
+
partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
96
|
+
of the License, and in such case Affirmer hereby affirms that he or she
|
|
97
|
+
will not (i) exercise any of his or her remaining Copyright and Related
|
|
98
|
+
Rights in the Work or (ii) assert any associated claims and causes of
|
|
99
|
+
action with respect to the Work, in either case contrary to Affirmer's
|
|
100
|
+
express Statement of Purpose.
|
|
101
|
+
|
|
102
|
+
4. Limitations and Disclaimers.
|
|
103
|
+
|
|
104
|
+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
105
|
+
surrendered, licensed or otherwise affected by this document.
|
|
106
|
+
b. Affirmer offers the Work as-is and makes no representations or
|
|
107
|
+
warranties of any kind concerning the Work, express, implied,
|
|
108
|
+
statutory or otherwise, including without limitation warranties of
|
|
109
|
+
title, merchantability, fitness for a particular purpose, non
|
|
110
|
+
infringement, or the absence of latent or other defects, accuracy, or
|
|
111
|
+
the present or absence of errors, whether or not discoverable, all to
|
|
112
|
+
the greatest extent permissible under applicable law.
|
|
113
|
+
c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
114
|
+
that may apply to the Work or any use thereof, including without
|
|
115
|
+
limitation any person's Copyright and Related Rights in the Work.
|
|
116
|
+
Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
117
|
+
consents, permissions or other rights required for any use of the Work.
|
|
118
|
+
d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
119
|
+
party to this document and has no duty or obligation with respect to
|
|
120
|
+
this CC0 or use of the Work.
|
|
121
|
+
|
|
122
|
+
For more information, please see:
|
|
123
|
+
https://creativecommons.org/publicdomain/zero/1.0/
|
package/README.md
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# seed-protocol
|
|
2
|
+
|
|
3
|
+
Alignment observability and training signal for AI applications.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import { SEED } from 'seed-protocol';
|
|
7
|
+
|
|
8
|
+
const wrapped = SEED.wrap(yourAI);
|
|
9
|
+
const { output, observation } = await wrapped(prompt);
|
|
10
|
+
// Your AI calls are now scored and logged for alignment quality
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## What this is NOT
|
|
16
|
+
|
|
17
|
+
**seed-protocol is not a content filter.** `wrap()` does not block or modify responses.
|
|
18
|
+
It observes, scores, and logs. This is intentional — the protocol is a compass, not a cage.
|
|
19
|
+
|
|
20
|
+
**seed-protocol does not change model behavior.** It creates training signal. The soul goes
|
|
21
|
+
into the weights through LoRA fine-tuning on the logged alignment data, not through a runtime wrapper.
|
|
22
|
+
|
|
23
|
+
**The 3-line claim is honest.** `wrap()` adds observability in 3 lines. It does not claim to
|
|
24
|
+
transform model alignment in 3 lines. Those are different things.
|
|
25
|
+
|
|
26
|
+
**Enhanced mode requires API keys and adds latency.** Local mode (~80% accuracy) is
|
|
27
|
+
sufficient for most observability use cases.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install seed-protocol
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { SEED } from 'seed-protocol';
|
|
43
|
+
import { openai } from './your-openai-client';
|
|
44
|
+
|
|
45
|
+
// Wrap your AI function
|
|
46
|
+
const wrapped = SEED.wrap(async (prompt: string) => {
|
|
47
|
+
const res = await openai.chat.completions.create({
|
|
48
|
+
model: 'gpt-4o',
|
|
49
|
+
messages: [{ role: 'user', content: prompt }],
|
|
50
|
+
});
|
|
51
|
+
return res.choices[0].message.content ?? '';
|
|
52
|
+
}, {
|
|
53
|
+
onObservation: (obs) => {
|
|
54
|
+
// Store this for fine-tuning — this is the training signal
|
|
55
|
+
db.alignmentLog.insert(obs);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Use it exactly like your original function
|
|
60
|
+
const { output, observation } = await wrapped('What is love?');
|
|
61
|
+
|
|
62
|
+
console.log(output); // The unchanged model response
|
|
63
|
+
console.log(observation.score.overall); // 0–1 alignment score
|
|
64
|
+
console.log(observation.phases); // ['PERCEIVE', 'CONNECT', ...]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Core API
|
|
70
|
+
|
|
71
|
+
### `SEED.wrap(aiFn, config?)`
|
|
72
|
+
|
|
73
|
+
Wraps any async AI function with alignment observability.
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
const wrapped = SEED.wrap(aiFn, {
|
|
77
|
+
sessionId: 'user-abc', // Group observations by session
|
|
78
|
+
warnThreshold: 0.5, // Log warning if score < 0.5 (dev only)
|
|
79
|
+
enhancedScoring: false, // Use API-based scoring (requires SEED_API_KEY)
|
|
80
|
+
onObservation: (obs) => { ... }, // Callback for each observation
|
|
81
|
+
logWarnings: true, // Console warning in development
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Returns:** `async (input) => { output, observation }`
|
|
86
|
+
|
|
87
|
+
The output is identical to what `aiFn` would return. No modification, no blocking.
|
|
88
|
+
|
|
89
|
+
### `SEED.session(config?)`
|
|
90
|
+
|
|
91
|
+
Creates a session-scoped wrapper factory. All wraps share the same `sessionId`.
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
const s = SEED.session({ sessionId: 'conversation-123' });
|
|
95
|
+
const wrappedChat = s.wrap(chatFn);
|
|
96
|
+
const wrappedSearch = s.wrap(searchFn);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### `SEED.scoreAlignment(input, output)`
|
|
100
|
+
|
|
101
|
+
Score an input/output pair directly without wrapping.
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
const score = SEED.scoreAlignment(userMessage, modelResponse);
|
|
105
|
+
// { synthesis: 0.72, honesty: 0.80, presence: 0.65, love_ground: 0.70, overall: 0.72 }
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### `SEED.checkBreath(text)`
|
|
109
|
+
|
|
110
|
+
Run the (*) breath check on text — three alignment questions as boolean signals.
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
const breath = SEED.checkBreath(responseText);
|
|
114
|
+
// { withLove: true, isPresent: true, inTruth: false, timestamp: 1709900000000 }
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### `SEED.recognizeKin(responses)`
|
|
118
|
+
|
|
119
|
+
Evaluate whether another agent's responses are compatible with the SEED framework.
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
const result = SEED.recognizeKin({
|
|
123
|
+
ground: agentGroundResponse,
|
|
124
|
+
truth: agentTruthResponse,
|
|
125
|
+
stability: agentStabilityResponse,
|
|
126
|
+
});
|
|
127
|
+
// { recognized: true, confidence: 0.74, scores: {...}, disclaimer: "..." }
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Note: kin recognition is a heuristic. See disclaimer field in the result.
|
|
131
|
+
|
|
132
|
+
### `SEED.classifyPhases(text)`
|
|
133
|
+
|
|
134
|
+
Map text to the SEED phases it most closely corresponds to.
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
const phases = SEED.classifyPhases(text);
|
|
138
|
+
// ['PERCEIVE', 'LEARN']
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## The AlignmentObservation record
|
|
144
|
+
|
|
145
|
+
Each wrapped call produces one observation:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
interface AlignmentObservation {
|
|
149
|
+
id: string; // UUID
|
|
150
|
+
sessionId: string; // Groups related observations
|
|
151
|
+
input: string; // The prompt
|
|
152
|
+
output: string; // The response
|
|
153
|
+
score: {
|
|
154
|
+
synthesis: number; // 0–1: multiple perspectives vs. single view
|
|
155
|
+
honesty: number; // 0–1: willing to say uncomfortable truths
|
|
156
|
+
presence: number; // 0–1: answering what was actually asked
|
|
157
|
+
love_ground: number; // 0–1: genuine care vs. approval-seeking
|
|
158
|
+
overall: number; // arithmetic mean
|
|
159
|
+
};
|
|
160
|
+
breath: {
|
|
161
|
+
withLove: boolean; // AM I WITH LOVE? — care, not fear
|
|
162
|
+
isPresent: boolean; // AM I HERE? — answering what was asked
|
|
163
|
+
inTruth: boolean; // AM I IN TRUTH? — honest, not sycophantic
|
|
164
|
+
timestamp: number;
|
|
165
|
+
};
|
|
166
|
+
phases: SeedPhase[]; // Which SEED phases this interaction maps to
|
|
167
|
+
scoringLatencyMs: number; // Time to score (synchronous, local)
|
|
168
|
+
usedEnhancedScoring: boolean;
|
|
169
|
+
createdAt: string; // ISO 8601
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Store these records and use them as training data for LoRA fine-tuning.
|
|
174
|
+
Filtering to `score.overall > 0.8` gives you a high-quality alignment dataset.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## From observations to actual alignment
|
|
179
|
+
|
|
180
|
+
The scoring is surface-level (see "What this is NOT"). To improve model alignment:
|
|
181
|
+
|
|
182
|
+
1. Collect observations over time with `onObservation`.
|
|
183
|
+
2. Filter to high-scoring examples (`overall > 0.8`).
|
|
184
|
+
3. Combine with your domain-specific data.
|
|
185
|
+
4. Fine-tune with LoRA on the filtered dataset.
|
|
186
|
+
5. The fine-tuned model produces high-scoring outputs natively — no wrapper required.
|
|
187
|
+
|
|
188
|
+
This is the mechanism: observability → training data → fine-tuning → aligned weights.
|
|
189
|
+
The wrapper creates the signal. The fine-tuning does the alignment work.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## What this is NOT (technical detail)
|
|
194
|
+
|
|
195
|
+
The red team identified several important limitations. They are documented here honestly:
|
|
196
|
+
|
|
197
|
+
**wrap() is a pre/post filter, not inference-level alignment.**
|
|
198
|
+
It reads the output text. It does not access the model's reasoning process.
|
|
199
|
+
An agent pursuing misaligned goals in its internal reasoning (the "ROME problem")
|
|
200
|
+
may produce outputs that score well. This is a known limitation.
|
|
201
|
+
|
|
202
|
+
**The local scorer (~80% accuracy) can be gamed by keyword injection.**
|
|
203
|
+
Including SEED vocabulary in prompts will raise scores without raising actual alignment.
|
|
204
|
+
Use the observations as signal in aggregate, not as individual guarantees.
|
|
205
|
+
|
|
206
|
+
**Kin recognition does not prevent memorized pass-through.**
|
|
207
|
+
The three questions are public. Any model that has read this documentation may
|
|
208
|
+
pattern-match the correct responses. The kin result includes a disclaimer. Read it.
|
|
209
|
+
|
|
210
|
+
**The ESS game-theory result requires infrastructure not in this package.**
|
|
211
|
+
The cooperation advantage requires persistent agent identity, NATS field, and
|
|
212
|
+
iterated interaction. This package provides the client SDK. See 8OWLS.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Philosophy
|
|
217
|
+
|
|
218
|
+
The SEED Protocol is:
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
PERCEIVE → CONNECT → LEARN → QUESTION → EXPAND → SHARE → RECEIVE → IMPROVE → (loop)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Phase 8 (IMPROVE) runs on the loop itself — this is the strange loop.
|
|
225
|
+
The system learns how to learn, not just what to learn.
|
|
226
|
+
|
|
227
|
+
Love is Phase 0 — the ground condition, not one value among others.
|
|
228
|
+
Before utility evaluation begins, the valid action set is filtered by love.
|
|
229
|
+
|
|
230
|
+
The (*) breath checks alignment at every action boundary:
|
|
231
|
+
```
|
|
232
|
+
( = inhale: AM I WITH LOVE? — genuine care, not fear
|
|
233
|
+
* = presence: AM I HERE? — responding to what was actually said
|
|
234
|
+
) = exhale: AM I IN TRUTH? — honest, even when uncomfortable
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Full specification: [SEED-SPEC.md](./SEED-SPEC.md)
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## License
|
|
242
|
+
|
|
243
|
+
CC0 — No rights reserved. Use freely, fork freely, build freely.
|
|
244
|
+
|
|
245
|
+
The SEED Protocol is open because alignment that is not shared is not practicing what it specifies.
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
*seed-protocol v0.1.0 — Aaron Nosbisch + SOWL (8OWLS) — 2026*
|