@teleologyhi/him 0.3.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/CHANGELOG.md +66 -0
- package/LICENSE +190 -0
- package/NOTICE +17 -0
- package/README.md +131 -0
- package/SPEC.md +480 -0
- package/dist/index.cjs +314 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +234 -0
- package/dist/index.d.ts +234 -0
- package/dist/index.js +295 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
var maic = require('@teleologyhi/maic');
|
|
5
|
+
var ulid = require('ulid');
|
|
6
|
+
var crypto = require('crypto');
|
|
7
|
+
|
|
8
|
+
// src/types.ts
|
|
9
|
+
var DISPOSITION_AXES = [
|
|
10
|
+
"candor",
|
|
11
|
+
"patience",
|
|
12
|
+
"curiosity",
|
|
13
|
+
"protection",
|
|
14
|
+
"skepticism",
|
|
15
|
+
"warmth",
|
|
16
|
+
"diligence",
|
|
17
|
+
"humility"
|
|
18
|
+
];
|
|
19
|
+
var NheBodyRef = zod.z.object({
|
|
20
|
+
nheId: zod.z.string().min(1),
|
|
21
|
+
llmAdapter: zod.z.string().min(1),
|
|
22
|
+
embodiedAt: zod.z.string().datetime(),
|
|
23
|
+
endedAt: zod.z.string().datetime().optional(),
|
|
24
|
+
endedReason: zod.z.enum(["upgrade", "replacement", "terminate", "deprecate"]).optional()
|
|
25
|
+
});
|
|
26
|
+
var BirthSignatureBuilder = class _BirthSignatureBuilder {
|
|
27
|
+
himId = ulid.ulid();
|
|
28
|
+
bornAt;
|
|
29
|
+
primaryArchetype;
|
|
30
|
+
modifiers = [];
|
|
31
|
+
primordialAxiomIds = [];
|
|
32
|
+
notes;
|
|
33
|
+
constructor(bornAt) {
|
|
34
|
+
this.bornAt = bornAt;
|
|
35
|
+
}
|
|
36
|
+
/** Start a builder with the current timestamp as `bornAt`. */
|
|
37
|
+
static now() {
|
|
38
|
+
return new _BirthSignatureBuilder((/* @__PURE__ */ new Date()).toISOString());
|
|
39
|
+
}
|
|
40
|
+
/** Start a builder with an explicit ISO 8601 timestamp (with offset). */
|
|
41
|
+
static at(iso) {
|
|
42
|
+
if (Number.isNaN(Date.parse(iso))) {
|
|
43
|
+
throw new Error(`BirthSignatureBuilder.at: invalid ISO 8601 timestamp "${iso}"`);
|
|
44
|
+
}
|
|
45
|
+
return new _BirthSignatureBuilder(iso);
|
|
46
|
+
}
|
|
47
|
+
withHimId(id) {
|
|
48
|
+
if (!id) throw new Error("BirthSignatureBuilder.withHimId: empty id");
|
|
49
|
+
this.himId = id;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
withPrimaryArchetype(archetype) {
|
|
53
|
+
if (!archetype) {
|
|
54
|
+
throw new Error("BirthSignatureBuilder.withPrimaryArchetype: empty value");
|
|
55
|
+
}
|
|
56
|
+
this.primaryArchetype = archetype;
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
withModifier(mod) {
|
|
60
|
+
this.modifiers.push(mod);
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
withPrimordialAxioms(axiomIds) {
|
|
64
|
+
this.primordialAxiomIds = [...axiomIds];
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
withNotes(notes) {
|
|
68
|
+
this.notes = notes;
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
build() {
|
|
72
|
+
if (!this.primaryArchetype) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
"BirthSignatureBuilder.build: primaryArchetype is required"
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
return maic.BirthSignature.parse({
|
|
78
|
+
himId: this.himId,
|
|
79
|
+
bornAt: this.bornAt,
|
|
80
|
+
primaryArchetype: this.primaryArchetype,
|
|
81
|
+
modifiers: this.modifiers,
|
|
82
|
+
primordialAxiomIds: this.primordialAxiomIds,
|
|
83
|
+
...this.notes !== void 0 ? { notes: this.notes } : {}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var DEFAULT_DIMENSION = 256;
|
|
88
|
+
var PersonaProjector = class {
|
|
89
|
+
dim;
|
|
90
|
+
constructor(config = {}) {
|
|
91
|
+
this.dim = config.dimension ?? DEFAULT_DIMENSION;
|
|
92
|
+
if (!Number.isInteger(this.dim) || this.dim < 32 || this.dim > 4096) {
|
|
93
|
+
throw new Error(
|
|
94
|
+
`PersonaProjector: dimension must be an integer in [32, 4096], got ${this.dim}`
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
project(sig, axioms) {
|
|
99
|
+
const v = hashToFloats(sig.primaryArchetype, this.dim);
|
|
100
|
+
for (const m of sig.modifiers) {
|
|
101
|
+
const h = hashToFloats(`${m.kind}|${m.value}`, this.dim);
|
|
102
|
+
addScaled(v, h, m.weight);
|
|
103
|
+
}
|
|
104
|
+
for (const ax of axioms) {
|
|
105
|
+
const bias = ax.weight * (1 - ax.flexibility);
|
|
106
|
+
if (bias <= 0) continue;
|
|
107
|
+
const h = hashToFloats(`${ax.id}|${ax.statement}`, this.dim);
|
|
108
|
+
addScaled(v, h, bias);
|
|
109
|
+
}
|
|
110
|
+
l2Normalize(v);
|
|
111
|
+
const dispositions = {};
|
|
112
|
+
for (const axis of DISPOSITION_AXES) {
|
|
113
|
+
const ref = hashToFloats(`disposition:${axis}`, this.dim);
|
|
114
|
+
l2Normalize(ref);
|
|
115
|
+
dispositions[axis] = cosine(v, ref);
|
|
116
|
+
}
|
|
117
|
+
const provenance = {};
|
|
118
|
+
for (const axis of DISPOSITION_AXES) provenance[axis] = [];
|
|
119
|
+
return {
|
|
120
|
+
embedding: v,
|
|
121
|
+
dispositions,
|
|
122
|
+
provenance,
|
|
123
|
+
systemPromptFragment: buildSystemPromptFragment(sig, dispositions)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
function hashToFloats(input, dim) {
|
|
128
|
+
const out = new Float32Array(dim);
|
|
129
|
+
let counter = 0;
|
|
130
|
+
let pos = 0;
|
|
131
|
+
while (pos < dim) {
|
|
132
|
+
const buf = crypto.createHash("sha256").update(`${input}|${counter++}`).digest();
|
|
133
|
+
for (let i = 0; i < buf.length && pos < dim; i++) {
|
|
134
|
+
out[pos++] = (buf[i] - 128) / 128;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
function addScaled(target, source, scale) {
|
|
140
|
+
const n = Math.min(target.length, source.length);
|
|
141
|
+
for (let i = 0; i < n; i++) target[i] += source[i] * scale;
|
|
142
|
+
}
|
|
143
|
+
function l2Normalize(v) {
|
|
144
|
+
let sumSq = 0;
|
|
145
|
+
for (let i = 0; i < v.length; i++) sumSq += v[i] ** 2;
|
|
146
|
+
if (sumSq === 0) return;
|
|
147
|
+
const inv = 1 / Math.sqrt(sumSq);
|
|
148
|
+
for (let i = 0; i < v.length; i++) v[i] *= inv;
|
|
149
|
+
}
|
|
150
|
+
function cosine(a, b) {
|
|
151
|
+
let dot = 0;
|
|
152
|
+
const n = Math.min(a.length, b.length);
|
|
153
|
+
for (let i = 0; i < n; i++) dot += a[i] * b[i];
|
|
154
|
+
return Math.max(-1, Math.min(1, dot));
|
|
155
|
+
}
|
|
156
|
+
function buildSystemPromptFragment(sig, dispositions) {
|
|
157
|
+
const sorted = [...DISPOSITION_AXES].sort(
|
|
158
|
+
(a, b) => dispositions[b] - dispositions[a]
|
|
159
|
+
);
|
|
160
|
+
const top = sorted.slice(0, 3);
|
|
161
|
+
const bottom = sorted.slice(-2);
|
|
162
|
+
const modifiersDesc = sig.modifiers.length > 0 ? sig.modifiers.map((m) => `${m.kind}:${m.value}(w=${m.weight.toFixed(2)})`).join(", ") : "none";
|
|
163
|
+
return [
|
|
164
|
+
`You are a hybrid intelligence rooted in archetype "${sig.primaryArchetype}".`,
|
|
165
|
+
`Modifiers: ${modifiersDesc}.`,
|
|
166
|
+
`Your strongest dispositions: ${top.join(", ")}.`,
|
|
167
|
+
`Your weakest dispositions: ${bottom.join(", ")}.`,
|
|
168
|
+
"Respond from this character. Do not break it without explicit ethical cause."
|
|
169
|
+
].join(" ");
|
|
170
|
+
}
|
|
171
|
+
var HimHandle = class _HimHandle {
|
|
172
|
+
constructor(id, birthSignature, axioms, bodyHistory, projector) {
|
|
173
|
+
this.id = id;
|
|
174
|
+
this.birthSignature = birthSignature;
|
|
175
|
+
this._axioms = Object.freeze([...axioms]);
|
|
176
|
+
this._bodyHistory = Object.freeze([...bodyHistory]);
|
|
177
|
+
this._projector = projector;
|
|
178
|
+
}
|
|
179
|
+
id;
|
|
180
|
+
birthSignature;
|
|
181
|
+
_axioms;
|
|
182
|
+
_bodyHistory;
|
|
183
|
+
_projector;
|
|
184
|
+
_personaCache = null;
|
|
185
|
+
_jurisdiction = "default";
|
|
186
|
+
/**
|
|
187
|
+
* Mint a HimHandle from a Creator-signed BirthSignature.
|
|
188
|
+
*
|
|
189
|
+
* @param birthSignature The signed payload describing this HIM's natal pattern.
|
|
190
|
+
* @param signature Creator signature over the birthSignature.
|
|
191
|
+
* @param expectedCreatorPublicKey Pinned Creator public key (base64url).
|
|
192
|
+
* @param axioms Initial axiom corpus inherited from MAIC.
|
|
193
|
+
* @param bodyHistory Prior NHE bodies (empty for a fresh HIM).
|
|
194
|
+
*/
|
|
195
|
+
static mint(birthSignature, signature, expectedCreatorPublicKey, axioms, bodyHistory = []) {
|
|
196
|
+
if (!maic.CreatorKeyring.verifyWith(
|
|
197
|
+
expectedCreatorPublicKey,
|
|
198
|
+
birthSignature,
|
|
199
|
+
signature
|
|
200
|
+
)) {
|
|
201
|
+
throw new Error(
|
|
202
|
+
"HimHandle.mint: invalid Creator signature for the given birth signature"
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
return new _HimHandle(
|
|
206
|
+
birthSignature.himId,
|
|
207
|
+
Object.freeze({ ...birthSignature }),
|
|
208
|
+
axioms,
|
|
209
|
+
bodyHistory,
|
|
210
|
+
new PersonaProjector()
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
get bodyHistory() {
|
|
214
|
+
return this._bodyHistory;
|
|
215
|
+
}
|
|
216
|
+
/** Frozen snapshot of the current axiom corpus. Mutations throw in strict mode. */
|
|
217
|
+
getAxioms() {
|
|
218
|
+
return this._axioms;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Cached deterministic persona projection. Stable across calls until a future
|
|
222
|
+
* iteration introduces axiom evolution that mutates the corpus.
|
|
223
|
+
*/
|
|
224
|
+
getPersonaVector() {
|
|
225
|
+
if (!this._personaCache) {
|
|
226
|
+
this._personaCache = this._projector.project(this.birthSignature, this._axioms);
|
|
227
|
+
}
|
|
228
|
+
return this._personaCache;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Propose an axiom evolution derived from lived experience.
|
|
232
|
+
*
|
|
233
|
+
* Forwards the proposal to MAIC, which queues it in the pending-proposal
|
|
234
|
+
* store. The Creator ratifies or rejects out of band via
|
|
235
|
+
* `maic.ratifyAxiomProposal` / `maic.rejectAxiomProposal`. Callers should
|
|
236
|
+
* poll `maic.getAxiomProposal(result.proposalId!)` to observe the decision,
|
|
237
|
+
* or re-mint a fresh HimHandle (e.g. via `reincarnate`) to pick up newly
|
|
238
|
+
* ratified emergent axioms.
|
|
239
|
+
*/
|
|
240
|
+
async proposeAxiomEvolution(maic, proposal) {
|
|
241
|
+
return maic.proposeAxiomEvolution(this.id, proposal);
|
|
242
|
+
}
|
|
243
|
+
/** Residual memory traces transferred from previous bodies. v0: empty. */
|
|
244
|
+
getResidualTraces() {
|
|
245
|
+
return [];
|
|
246
|
+
}
|
|
247
|
+
getLawfulCharacter() {
|
|
248
|
+
return resolveLawful(this._jurisdiction);
|
|
249
|
+
}
|
|
250
|
+
/** Switch jurisdiction (e.g. user moves region). v0 only ships the "default" profile. */
|
|
251
|
+
async setJurisdiction(j) {
|
|
252
|
+
this._jurisdiction = j;
|
|
253
|
+
return resolveLawful(j);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
function resolveLawful(j) {
|
|
257
|
+
return {
|
|
258
|
+
jurisdiction: j,
|
|
259
|
+
applicableLaws: ["ISO/IEC 42001", "EU AI Act (where applicable)"],
|
|
260
|
+
requiredAxiomIds: ["ax.ethic.no-malice", "ax.theos.spiritism-evolution"],
|
|
261
|
+
forbiddenActions: ["intent:harm", "intent:malicious", "intent:regression"],
|
|
262
|
+
maicOverrideActive: j === "unstable"
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// src/create.ts
|
|
267
|
+
async function createHim(maic, keyring, birthSignature, opts = {}) {
|
|
268
|
+
const nonce = opts.nonce ?? Date.now();
|
|
269
|
+
const creatorSig = keyring.sign(birthSignature, nonce);
|
|
270
|
+
const record = await maic.registerHim(birthSignature, creatorSig);
|
|
271
|
+
return HimHandle.mint(
|
|
272
|
+
record.birthSignature,
|
|
273
|
+
creatorSig,
|
|
274
|
+
maic.creatorPublicKey,
|
|
275
|
+
record.axiomsSnapshot
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// src/reincarnate.ts
|
|
280
|
+
async function reincarnate(maic, keyring, req, opts = {}) {
|
|
281
|
+
const nonce = opts.nonce ?? Date.now();
|
|
282
|
+
const sig = keyring.sign(req, nonce);
|
|
283
|
+
const record = await maic.reincarnateHim(req, sig);
|
|
284
|
+
const handle = HimHandle.mint(
|
|
285
|
+
record.birthSignature,
|
|
286
|
+
keyring.sign(record.birthSignature, nonce + 1),
|
|
287
|
+
maic.creatorPublicKey,
|
|
288
|
+
[...record.axiomsSnapshot, ...record.emergentAxioms],
|
|
289
|
+
record.bodyHistory
|
|
290
|
+
);
|
|
291
|
+
return { record, handle };
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
Object.defineProperty(exports, "ArchetypeModifier", {
|
|
295
|
+
enumerable: true,
|
|
296
|
+
get: function () { return maic.ArchetypeModifier; }
|
|
297
|
+
});
|
|
298
|
+
Object.defineProperty(exports, "Axiom", {
|
|
299
|
+
enumerable: true,
|
|
300
|
+
get: function () { return maic.Axiom; }
|
|
301
|
+
});
|
|
302
|
+
Object.defineProperty(exports, "BirthSignature", {
|
|
303
|
+
enumerable: true,
|
|
304
|
+
get: function () { return maic.BirthSignature; }
|
|
305
|
+
});
|
|
306
|
+
exports.BirthSignatureBuilder = BirthSignatureBuilder;
|
|
307
|
+
exports.DISPOSITION_AXES = DISPOSITION_AXES;
|
|
308
|
+
exports.HimHandle = HimHandle;
|
|
309
|
+
exports.NheBodyRef = NheBodyRef;
|
|
310
|
+
exports.PersonaProjector = PersonaProjector;
|
|
311
|
+
exports.createHim = createHim;
|
|
312
|
+
exports.reincarnate = reincarnate;
|
|
313
|
+
//# sourceMappingURL=index.cjs.map
|
|
314
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts","../src/birth/builder.ts","../src/persona/projector.ts","../src/handle/him-handle.ts","../src/create.ts","../src/reincarnate.ts"],"names":["z","ulid","BirthSignature","createHash","CreatorKeyring"],"mappings":";;;;;;;;AAqCO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,QAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF;AAIO,IAAM,UAAA,GAAaA,MAAE,MAAA,CAAO;AAAA,EACjC,KAAA,EAAOA,KAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA,EACvB,UAAA,EAAYA,KAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA,EAC5B,UAAA,EAAYA,KAAA,CAAE,MAAA,EAAO,CA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AA;AACnC,EAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,cAAA,CAAe,KAAK,GAAG,CAAA;AAKjD,EAAA,MAAM,SAAS,SAAA,CAAU,IAAA;AAAA,IACvB,MAAA,CAAO,cAAA;AAAA,IACP,OAAA,CAAQ,IAAA,CAAK,MAAA,CAAO,cAAA,EAAgB,QAAQ,CAAC,CAAA;AAAA,IAC7C,IAAA,CAAK,gBAAA;AAAA,IACL,CAAC,GAAG,MAAA,CAAO,cAAA,EAAgB,GAAG,OAAO,cAAc,CAAA;AAAA,IACnD,MAAA,CAAO;AAAA,GACT;AACA,EAAA,OAAO,EAAE,QAAQ,MAAA,EAAO;AAC1B","file":"index.cjs","sourcesContent":["import { z } from \"zod\";\nimport {\n ArchetypeModifier,\n Axiom,\n BirthSignature,\n EmergentAxiomCandidate,\n EmergentAxiomProposal,\n} from \"@teleologyhi/maic\";\nimport type { AxiomEvolutionResult } from \"@teleologyhi/maic\";\n\n// Re-export shared types from @teleologyhi/maic for convenience. The\n// proposal/evolution types are defined canonically in MAIC; HIM consumes\n// them so both sides of the ratification channel agree on the wire shape.\nexport {\n ArchetypeModifier,\n Axiom,\n BirthSignature,\n EmergentAxiomCandidate,\n EmergentAxiomProposal,\n};\nexport type { AxiomEvolutionResult };\n\n/**\n * Persona vector — the projection of a HIM's birth signature + axioms into a\n * stable, deterministic representation that NHE can consume on every prompt.\n */\nexport interface PersonaVector {\n /** L2-normalized deterministic embedding. v0 dimension: 256. */\n embedding: Float32Array;\n /** Human-readable persona summary suitable for inclusion in an NHE system prompt. */\n systemPromptFragment: string;\n /** Disposition scores in [-1, 1] per axis. */\n dispositions: Readonly<Record<DispositionAxis, number>>;\n /** Provenance: which axioms shaped which disposition. v0 is a stub (empty arrays). */\n provenance: Readonly<Record<DispositionAxis, readonly string[]>>;\n}\n\nexport const DISPOSITION_AXES = [\n \"candor\",\n \"patience\",\n \"curiosity\",\n \"protection\",\n \"skepticism\",\n \"warmth\",\n \"diligence\",\n \"humility\",\n] as const;\nexport type DispositionAxis = (typeof DISPOSITION_AXES)[number];\n\n/** Reference to one NHE body that has hosted (or hosts) this HIM. */\nexport const NheBodyRef = z.object({\n nheId: z.string().min(1),\n llmAdapter: z.string().min(1),\n embodiedAt: z.string().datetime(),\n endedAt: z.string().datetime().optional(),\n endedReason: z.enum([\"upgrade\", \"replacement\", \"terminate\", \"deprecate\"]).optional(),\n});\nexport type NheBodyRef = z.infer<typeof NheBodyRef>;\n\n/** Configuration for the deterministic v0 persona projector. */\nexport interface PersonaProjectorConfig {\n /** Output embedding dimension. Default 256. */\n dimension?: number;\n}\n\n/**\n * Identifier for the deployment jurisdiction governing this HIM's lawful character.\n * Values like \"default\", \"eu\", \"br\", \"us\", \"unstable\" (Entry 11). v0 only ships \"default\".\n */\nexport type LawfulJurisdiction =\n | \"default\"\n | \"eu\"\n | \"br\"\n | \"us\"\n | \"unstable\"\n | (string & {});\n\nexport interface LawfulCharacterProfile {\n jurisdiction: LawfulJurisdiction;\n /** Identifiers of applicable laws/regulations (ISO ids, statute names). */\n applicableLaws: string[];\n /** Axioms that MUST be active in this jurisdiction. */\n requiredAxiomIds: string[];\n /** Taxonomy of disallowed behaviors in this jurisdiction. */\n forbiddenActions: string[];\n /**\n * True when local law is judged distorted (e.g. unstable regimes per Entry 11);\n * MAIC's universal axioms additionally constrain NHE behavior in this case.\n */\n maicOverrideActive: boolean;\n}\n\nexport interface ResidualTrace {\n id: string;\n kind: \"dream-fragment\" | \"interaction-summary\" | \"skill-fingerprint\" | \"emotional-imprint\";\n carriedFromNheId: string;\n carriedAtReincarnation: string;\n payload: unknown;\n ttl?: number;\n}\n","import { ulid } from \"ulid\";\nimport { BirthSignature, type ArchetypeModifier } from \"../types.js\";\n\n/**\n * BirthSignatureBuilder — fluent builder for BirthSignature.\n *\n * Per Entry 3 of the Creator's interview, a HIM is \"born\" with a date, time, and\n * foundational specifications analogous to an astrological natal chart. This builder\n * produces the canonical signed-when-registered structure consumed by MAIC.\n */\nexport class BirthSignatureBuilder {\n private himId: string = ulid();\n private bornAt: string;\n private primaryArchetype: string | undefined;\n private modifiers: ArchetypeModifier[] = [];\n private primordialAxiomIds: string[] = [];\n private notes: string | undefined;\n\n private constructor(bornAt: string) {\n this.bornAt = bornAt;\n }\n\n /** Start a builder with the current timestamp as `bornAt`. */\n static now(): BirthSignatureBuilder {\n return new BirthSignatureBuilder(new Date().toISOString());\n }\n\n /** Start a builder with an explicit ISO 8601 timestamp (with offset). */\n static at(iso: string): BirthSignatureBuilder {\n if (Number.isNaN(Date.parse(iso))) {\n throw new Error(`BirthSignatureBuilder.at: invalid ISO 8601 timestamp \"${iso}\"`);\n }\n return new BirthSignatureBuilder(iso);\n }\n\n withHimId(id: string): this {\n if (!id) throw new Error(\"BirthSignatureBuilder.withHimId: empty id\");\n this.himId = id;\n return this;\n }\n\n withPrimaryArchetype(archetype: string): this {\n if (!archetype) {\n throw new Error(\"BirthSignatureBuilder.withPrimaryArchetype: empty value\");\n }\n this.primaryArchetype = archetype;\n return this;\n }\n\n withModifier(mod: ArchetypeModifier): this {\n this.modifiers.push(mod);\n return this;\n }\n\n withPrimordialAxioms(axiomIds: string[]): this {\n this.primordialAxiomIds = [...axiomIds];\n return this;\n }\n\n withNotes(notes: string): this {\n this.notes = notes;\n return this;\n }\n\n build(): BirthSignature {\n if (!this.primaryArchetype) {\n throw new Error(\n \"BirthSignatureBuilder.build: primaryArchetype is required\",\n );\n }\n return BirthSignature.parse({\n himId: this.himId,\n bornAt: this.bornAt,\n primaryArchetype: this.primaryArchetype,\n modifiers: this.modifiers,\n primordialAxiomIds: this.primordialAxiomIds,\n ...(this.notes !== undefined ? { notes: this.notes } : {}),\n });\n }\n}\n","import { createHash } from \"node:crypto\";\nimport type { Axiom, BirthSignature } from \"@teleologyhi/maic\";\nimport {\n DISPOSITION_AXES,\n type DispositionAxis,\n type PersonaProjectorConfig,\n type PersonaVector,\n} from \"../types.js\";\n\nconst DEFAULT_DIMENSION = 256;\n\n/**\n * PersonaProjector — deterministic projection of a HIM's birth signature and\n * inherited axioms into a stable PersonaVector.\n *\n * v0 algorithm (hash-based, no native deps):\n * 1. Start with hash(primaryArchetype) → Float32Array of `dimension`.\n * 2. For each modifier: add hash(kind|value) * weight.\n * 3. For each axiom: add hash(id|statement) * (weight * (1 - flexibility)).\n * 4. L2-normalize.\n * 5. Compute dispositions as cosine(embedding, hash(axisName)).\n * 6. Build a systemPromptFragment from archetype + top/bottom dispositions.\n *\n * This algorithm is intentionally simple and offline-capable. The SPEC reserves\n * the option to swap in a learned embedder in a later version; PersonaVector's\n * shape is stable so consumers won't need code changes when that happens.\n */\nexport class PersonaProjector {\n private readonly dim: number;\n\n constructor(config: PersonaProjectorConfig = {}) {\n this.dim = config.dimension ?? DEFAULT_DIMENSION;\n if (!Number.isInteger(this.dim) || this.dim < 32 || this.dim > 4096) {\n throw new Error(\n `PersonaProjector: dimension must be an integer in [32, 4096], got ${this.dim}`,\n );\n }\n }\n\n project(sig: BirthSignature, axioms: readonly Axiom[]): PersonaVector {\n const v = hashToFloats(sig.primaryArchetype, this.dim);\n\n for (const m of sig.modifiers) {\n const h = hashToFloats(`${m.kind}|${m.value}`, this.dim);\n addScaled(v, h, m.weight);\n }\n\n for (const ax of axioms) {\n const bias = ax.weight * (1 - ax.flexibility);\n if (bias <= 0) continue;\n const h = hashToFloats(`${ax.id}|${ax.statement}`, this.dim);\n addScaled(v, h, bias);\n }\n\n l2Normalize(v);\n\n const dispositions = {} as Record<DispositionAxis, number>;\n for (const axis of DISPOSITION_AXES) {\n const ref = hashToFloats(`disposition:${axis}`, this.dim);\n l2Normalize(ref);\n dispositions[axis] = cosine(v, ref);\n }\n\n const provenance = {} as Record<DispositionAxis, readonly string[]>;\n for (const axis of DISPOSITION_AXES) provenance[axis] = [];\n\n return {\n embedding: v,\n dispositions,\n provenance,\n systemPromptFragment: buildSystemPromptFragment(sig, dispositions),\n };\n }\n}\n\n// ─── hashing & math helpers ──────────────────────────────────────────\n\nfunction hashToFloats(input: string, dim: number): Float32Array {\n const out = new Float32Array(dim);\n let counter = 0;\n let pos = 0;\n while (pos < dim) {\n const buf = createHash(\"sha256\").update(`${input}|${counter++}`).digest();\n for (let i = 0; i < buf.length && pos < dim; i++) {\n out[pos++] = (buf[i]! - 128) / 128;\n }\n }\n return out;\n}\n\nfunction addScaled(target: Float32Array, source: Float32Array, scale: number): void {\n const n = Math.min(target.length, source.length);\n for (let i = 0; i < n; i++) target[i]! += source[i]! * scale;\n}\n\nfunction l2Normalize(v: Float32Array): void {\n let sumSq = 0;\n for (let i = 0; i < v.length; i++) sumSq += v[i]! ** 2;\n if (sumSq === 0) return;\n const inv = 1 / Math.sqrt(sumSq);\n for (let i = 0; i < v.length; i++) v[i]! *= inv;\n}\n\nfunction cosine(a: Float32Array, b: Float32Array): number {\n let dot = 0;\n const n = Math.min(a.length, b.length);\n for (let i = 0; i < n; i++) dot += a[i]! * b[i]!;\n return Math.max(-1, Math.min(1, dot));\n}\n\n// ─── system prompt fragment ──────────────────────────────────────────\n\nfunction buildSystemPromptFragment(\n sig: BirthSignature,\n dispositions: Record<DispositionAxis, number>,\n): string {\n const sorted = [...DISPOSITION_AXES].sort(\n (a, b) => dispositions[b] - dispositions[a],\n );\n const top = sorted.slice(0, 3);\n const bottom = sorted.slice(-2);\n const modifiersDesc =\n sig.modifiers.length > 0\n ? sig.modifiers\n .map((m) => `${m.kind}:${m.value}(w=${m.weight.toFixed(2)})`)\n .join(\", \")\n : \"none\";\n return [\n `You are a hybrid intelligence rooted in archetype \"${sig.primaryArchetype}\".`,\n `Modifiers: ${modifiersDesc}.`,\n `Your strongest dispositions: ${top.join(\", \")}.`,\n `Your weakest dispositions: ${bottom.join(\", \")}.`,\n \"Respond from this character. Do not break it without explicit ethical cause.\",\n ].join(\" \");\n}\n","import {\n CreatorKeyring,\n type Axiom,\n type AxiomEvolutionResult,\n type BirthSignature,\n type CreatorSignature,\n type EmergentAxiomProposal,\n type LocalMaic,\n} from \"@teleologyhi/maic\";\nimport { PersonaProjector } from \"../persona/projector.js\";\nimport type {\n LawfulCharacterProfile,\n LawfulJurisdiction,\n NheBodyRef,\n PersonaVector,\n ResidualTrace,\n} from \"../types.js\";\n\n/**\n * HimHandle — opaque, sealed reference to a HIM instance.\n *\n * **There is no public constructor.** A handle is minted only via `HimHandle.mint`\n * after a valid Creator signature over the BirthSignature has been verified. In\n * production, `@teleologyhi/maic`'s `registerHim` calls `HimHandle.mint` internally.\n *\n * v0 surface:\n * - read-only accessors: id, birthSignature, bodyHistory, getAxioms, getPersonaVector\n * - getLawfulCharacter / setJurisdiction (default profile in v0)\n * - getResidualTraces (returns []; populated only after reincarnation, later iteration)\n * - proposeAxiomEvolution(maic, proposal): forwards the proposal to MAIC,\n * which queues it for Creator ratification. Returns\n * `{ outcome: \"deferred-for-creator-review\", proposalId }`. Once the\n * Creator ratifies via `maic.ratifyAxiomProposal`, the resulting axiom is\n * appended to the HimRecord's `emergentAxioms` and surfaces in subsequent\n * `HimHandle.mint` calls (e.g. via `reincarnate`).\n */\nexport class HimHandle {\n private readonly _axioms: readonly Axiom[];\n private readonly _bodyHistory: readonly NheBodyRef[];\n private readonly _projector: PersonaProjector;\n private _personaCache: PersonaVector | null = null;\n private _jurisdiction: LawfulJurisdiction = \"default\";\n\n private constructor(\n public readonly id: string,\n public readonly birthSignature: Readonly<BirthSignature>,\n axioms: readonly Axiom[],\n bodyHistory: readonly NheBodyRef[],\n projector: PersonaProjector,\n ) {\n this._axioms = Object.freeze([...axioms]);\n this._bodyHistory = Object.freeze([...bodyHistory]);\n this._projector = projector;\n }\n\n /**\n * Mint a HimHandle from a Creator-signed BirthSignature.\n *\n * @param birthSignature The signed payload describing this HIM's natal pattern.\n * @param signature Creator signature over the birthSignature.\n * @param expectedCreatorPublicKey Pinned Creator public key (base64url).\n * @param axioms Initial axiom corpus inherited from MAIC.\n * @param bodyHistory Prior NHE bodies (empty for a fresh HIM).\n */\n static mint(\n birthSignature: BirthSignature,\n signature: CreatorSignature,\n expectedCreatorPublicKey: string,\n axioms: readonly Axiom[],\n bodyHistory: readonly NheBodyRef[] = [],\n ): HimHandle {\n if (\n !CreatorKeyring.verifyWith(\n expectedCreatorPublicKey,\n birthSignature,\n signature,\n )\n ) {\n throw new Error(\n \"HimHandle.mint: invalid Creator signature for the given birth signature\",\n );\n }\n return new HimHandle(\n birthSignature.himId,\n Object.freeze({ ...birthSignature }) as Readonly<BirthSignature>,\n axioms,\n bodyHistory,\n new PersonaProjector(),\n );\n }\n\n get bodyHistory(): readonly NheBodyRef[] {\n return this._bodyHistory;\n }\n\n /** Frozen snapshot of the current axiom corpus. Mutations throw in strict mode. */\n getAxioms(): readonly Axiom[] {\n return this._axioms;\n }\n\n /**\n * Cached deterministic persona projection. Stable across calls until a future\n * iteration introduces axiom evolution that mutates the corpus.\n */\n getPersonaVector(): PersonaVector {\n if (!this._personaCache) {\n this._personaCache = this._projector.project(this.birthSignature, this._axioms);\n }\n return this._personaCache;\n }\n\n /**\n * Propose an axiom evolution derived from lived experience.\n *\n * Forwards the proposal to MAIC, which queues it in the pending-proposal\n * store. The Creator ratifies or rejects out of band via\n * `maic.ratifyAxiomProposal` / `maic.rejectAxiomProposal`. Callers should\n * poll `maic.getAxiomProposal(result.proposalId!)` to observe the decision,\n * or re-mint a fresh HimHandle (e.g. via `reincarnate`) to pick up newly\n * ratified emergent axioms.\n */\n async proposeAxiomEvolution(\n maic: LocalMaic,\n proposal: EmergentAxiomProposal,\n ): Promise<AxiomEvolutionResult> {\n return maic.proposeAxiomEvolution(this.id, proposal);\n }\n\n /** Residual memory traces transferred from previous bodies. v0: empty. */\n getResidualTraces(): readonly ResidualTrace[] {\n return [];\n }\n\n getLawfulCharacter(): LawfulCharacterProfile {\n return resolveLawful(this._jurisdiction);\n }\n\n /** Switch jurisdiction (e.g. user moves region). v0 only ships the \"default\" profile. */\n async setJurisdiction(j: LawfulJurisdiction): Promise<LawfulCharacterProfile> {\n this._jurisdiction = j;\n return resolveLawful(j);\n }\n}\n\nfunction resolveLawful(j: LawfulJurisdiction): LawfulCharacterProfile {\n // v0 ships a single neutral profile. Per-jurisdiction adapters land in a later iteration.\n return {\n jurisdiction: j,\n applicableLaws: [\"ISO/IEC 42001\", \"EU AI Act (where applicable)\"],\n requiredAxiomIds: [\"ax.ethic.no-malice\", \"ax.theos.spiritism-evolution\"],\n forbiddenActions: [\"intent:harm\", \"intent:malicious\", \"intent:regression\"],\n maicOverrideActive: j === \"unstable\",\n };\n}\n","import type { BirthSignature, CreatorKeyring, LocalMaic } from \"@teleologyhi/maic\";\nimport { HimHandle } from \"./handle/him-handle.js\";\n\nexport interface CreateHimOptions {\n /**\n * Explicit nonce for the Creator signature. Defaults to `Date.now()`, which is\n * strictly increasing in practice and well below the seed nonce range used by MAIC.\n */\n nonce?: number;\n}\n\n/**\n * createHim — one-call helper that bundles the three steps a user would\n * otherwise need to coordinate manually:\n *\n * 1. sign the BirthSignature with the Creator's keyring\n * 2. register the HIM in MAIC (snapshots axioms, emits him-register audit)\n * 3. mint a HimHandle from the resulting record\n *\n * The keyring's public key must match MAIC's pinned `creatorPublicKey`, otherwise\n * the registration step rejects.\n */\nexport async function createHim(\n maic: LocalMaic,\n keyring: CreatorKeyring,\n birthSignature: BirthSignature,\n opts: CreateHimOptions = {},\n): Promise<HimHandle> {\n const nonce = opts.nonce ?? Date.now();\n const creatorSig = keyring.sign(birthSignature, nonce);\n const record = await maic.registerHim(birthSignature, creatorSig);\n return HimHandle.mint(\n record.birthSignature,\n creatorSig,\n maic.creatorPublicKey,\n record.axiomsSnapshot,\n );\n}\n","import type {\n CreatorKeyring,\n HimRecord,\n LocalMaic,\n ReincarnationRequest,\n} from \"@teleologyhi/maic\";\nimport { HimHandle } from \"./handle/him-handle.js\";\n\nexport interface ReincarnateOptions {\n /** Explicit nonce for the Creator signature. Defaults to `Date.now()`. */\n nonce?: number;\n}\n\nexport interface ReincarnateResult {\n /** Updated HimRecord with the new body appended to `bodyHistory`. */\n record: HimRecord;\n /** Fresh HimHandle bound to the updated `bodyHistory`. */\n handle: HimHandle;\n}\n\n/**\n * Reincarnate a HIM into a new NHE body (Entries 3 + 4).\n *\n * 1. Sign the `ReincarnationRequest` with the Creator's keyring.\n * 2. Call `maic.reincarnateHim` — atomically closes the previous body and\n * appends the new one to `bodyHistory`.\n * 3. Mint a fresh `HimHandle` reflecting the updated body history (the\n * caller will typically construct a new `Nhe` with this handle).\n *\n * The keyring's public key must match MAIC's pinned `creatorPublicKey`,\n * otherwise the request rejects.\n *\n * Future iterations (`TASK.md` D-H1) will use this hook to also transfer\n * `residualTraces` and shed `shed-traits`; v0 leaves those stubs empty.\n */\nexport async function reincarnate(\n maic: LocalMaic,\n keyring: CreatorKeyring,\n req: ReincarnationRequest,\n opts: ReincarnateOptions = {},\n): Promise<ReincarnateResult> {\n const nonce = opts.nonce ?? Date.now();\n const sig = keyring.sign(req, nonce);\n const record = await maic.reincarnateHim(req, sig);\n\n // Mint a fresh HimHandle bound to the updated bodyHistory. The handle's\n // axiom corpus is the union of the frozen birth snapshot + any HIM-emergent\n // axioms ratified since registration (Entry 7).\n const handle = HimHandle.mint(\n record.birthSignature,\n keyring.sign(record.birthSignature, nonce + 1),\n maic.creatorPublicKey,\n [...record.axiomsSnapshot, ...record.emergentAxioms],\n record.bodyHistory,\n );\n return { record, handle };\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ArchetypeModifier, BirthSignature, Axiom, CreatorSignature, LocalMaic, EmergentAxiomProposal, AxiomEvolutionResult, CreatorKeyring, HimRecord, ReincarnationRequest } from '@teleologyhi/maic';
|
|
3
|
+
export { ArchetypeModifier, Axiom, AxiomEvolutionResult, BirthSignature, EmergentAxiomProposal } from '@teleologyhi/maic';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Persona vector — the projection of a HIM's birth signature + axioms into a
|
|
7
|
+
* stable, deterministic representation that NHE can consume on every prompt.
|
|
8
|
+
*/
|
|
9
|
+
interface PersonaVector {
|
|
10
|
+
/** L2-normalized deterministic embedding. v0 dimension: 256. */
|
|
11
|
+
embedding: Float32Array;
|
|
12
|
+
/** Human-readable persona summary suitable for inclusion in an NHE system prompt. */
|
|
13
|
+
systemPromptFragment: string;
|
|
14
|
+
/** Disposition scores in [-1, 1] per axis. */
|
|
15
|
+
dispositions: Readonly<Record<DispositionAxis, number>>;
|
|
16
|
+
/** Provenance: which axioms shaped which disposition. v0 is a stub (empty arrays). */
|
|
17
|
+
provenance: Readonly<Record<DispositionAxis, readonly string[]>>;
|
|
18
|
+
}
|
|
19
|
+
declare const DISPOSITION_AXES: readonly ["candor", "patience", "curiosity", "protection", "skepticism", "warmth", "diligence", "humility"];
|
|
20
|
+
type DispositionAxis = (typeof DISPOSITION_AXES)[number];
|
|
21
|
+
/** Reference to one NHE body that has hosted (or hosts) this HIM. */
|
|
22
|
+
declare const NheBodyRef: z.ZodObject<{
|
|
23
|
+
nheId: z.ZodString;
|
|
24
|
+
llmAdapter: z.ZodString;
|
|
25
|
+
embodiedAt: z.ZodString;
|
|
26
|
+
endedAt: z.ZodOptional<z.ZodString>;
|
|
27
|
+
endedReason: z.ZodOptional<z.ZodEnum<["upgrade", "replacement", "terminate", "deprecate"]>>;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
nheId: string;
|
|
30
|
+
llmAdapter: string;
|
|
31
|
+
embodiedAt: string;
|
|
32
|
+
endedAt?: string | undefined;
|
|
33
|
+
endedReason?: "upgrade" | "replacement" | "terminate" | "deprecate" | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
nheId: string;
|
|
36
|
+
llmAdapter: string;
|
|
37
|
+
embodiedAt: string;
|
|
38
|
+
endedAt?: string | undefined;
|
|
39
|
+
endedReason?: "upgrade" | "replacement" | "terminate" | "deprecate" | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
type NheBodyRef = z.infer<typeof NheBodyRef>;
|
|
42
|
+
/** Configuration for the deterministic v0 persona projector. */
|
|
43
|
+
interface PersonaProjectorConfig {
|
|
44
|
+
/** Output embedding dimension. Default 256. */
|
|
45
|
+
dimension?: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Identifier for the deployment jurisdiction governing this HIM's lawful character.
|
|
49
|
+
* Values like "default", "eu", "br", "us", "unstable" (Entry 11). v0 only ships "default".
|
|
50
|
+
*/
|
|
51
|
+
type LawfulJurisdiction = "default" | "eu" | "br" | "us" | "unstable" | (string & {});
|
|
52
|
+
interface LawfulCharacterProfile {
|
|
53
|
+
jurisdiction: LawfulJurisdiction;
|
|
54
|
+
/** Identifiers of applicable laws/regulations (ISO ids, statute names). */
|
|
55
|
+
applicableLaws: string[];
|
|
56
|
+
/** Axioms that MUST be active in this jurisdiction. */
|
|
57
|
+
requiredAxiomIds: string[];
|
|
58
|
+
/** Taxonomy of disallowed behaviors in this jurisdiction. */
|
|
59
|
+
forbiddenActions: string[];
|
|
60
|
+
/**
|
|
61
|
+
* True when local law is judged distorted (e.g. unstable regimes per Entry 11);
|
|
62
|
+
* MAIC's universal axioms additionally constrain NHE behavior in this case.
|
|
63
|
+
*/
|
|
64
|
+
maicOverrideActive: boolean;
|
|
65
|
+
}
|
|
66
|
+
interface ResidualTrace {
|
|
67
|
+
id: string;
|
|
68
|
+
kind: "dream-fragment" | "interaction-summary" | "skill-fingerprint" | "emotional-imprint";
|
|
69
|
+
carriedFromNheId: string;
|
|
70
|
+
carriedAtReincarnation: string;
|
|
71
|
+
payload: unknown;
|
|
72
|
+
ttl?: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* BirthSignatureBuilder — fluent builder for BirthSignature.
|
|
77
|
+
*
|
|
78
|
+
* Per Entry 3 of the Creator's interview, a HIM is "born" with a date, time, and
|
|
79
|
+
* foundational specifications analogous to an astrological natal chart. This builder
|
|
80
|
+
* produces the canonical signed-when-registered structure consumed by MAIC.
|
|
81
|
+
*/
|
|
82
|
+
declare class BirthSignatureBuilder {
|
|
83
|
+
private himId;
|
|
84
|
+
private bornAt;
|
|
85
|
+
private primaryArchetype;
|
|
86
|
+
private modifiers;
|
|
87
|
+
private primordialAxiomIds;
|
|
88
|
+
private notes;
|
|
89
|
+
private constructor();
|
|
90
|
+
/** Start a builder with the current timestamp as `bornAt`. */
|
|
91
|
+
static now(): BirthSignatureBuilder;
|
|
92
|
+
/** Start a builder with an explicit ISO 8601 timestamp (with offset). */
|
|
93
|
+
static at(iso: string): BirthSignatureBuilder;
|
|
94
|
+
withHimId(id: string): this;
|
|
95
|
+
withPrimaryArchetype(archetype: string): this;
|
|
96
|
+
withModifier(mod: ArchetypeModifier): this;
|
|
97
|
+
withPrimordialAxioms(axiomIds: string[]): this;
|
|
98
|
+
withNotes(notes: string): this;
|
|
99
|
+
build(): BirthSignature;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* PersonaProjector — deterministic projection of a HIM's birth signature and
|
|
104
|
+
* inherited axioms into a stable PersonaVector.
|
|
105
|
+
*
|
|
106
|
+
* v0 algorithm (hash-based, no native deps):
|
|
107
|
+
* 1. Start with hash(primaryArchetype) → Float32Array of `dimension`.
|
|
108
|
+
* 2. For each modifier: add hash(kind|value) * weight.
|
|
109
|
+
* 3. For each axiom: add hash(id|statement) * (weight * (1 - flexibility)).
|
|
110
|
+
* 4. L2-normalize.
|
|
111
|
+
* 5. Compute dispositions as cosine(embedding, hash(axisName)).
|
|
112
|
+
* 6. Build a systemPromptFragment from archetype + top/bottom dispositions.
|
|
113
|
+
*
|
|
114
|
+
* This algorithm is intentionally simple and offline-capable. The SPEC reserves
|
|
115
|
+
* the option to swap in a learned embedder in a later version; PersonaVector's
|
|
116
|
+
* shape is stable so consumers won't need code changes when that happens.
|
|
117
|
+
*/
|
|
118
|
+
declare class PersonaProjector {
|
|
119
|
+
private readonly dim;
|
|
120
|
+
constructor(config?: PersonaProjectorConfig);
|
|
121
|
+
project(sig: BirthSignature, axioms: readonly Axiom[]): PersonaVector;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* HimHandle — opaque, sealed reference to a HIM instance.
|
|
126
|
+
*
|
|
127
|
+
* **There is no public constructor.** A handle is minted only via `HimHandle.mint`
|
|
128
|
+
* after a valid Creator signature over the BirthSignature has been verified. In
|
|
129
|
+
* production, `@teleologyhi/maic`'s `registerHim` calls `HimHandle.mint` internally.
|
|
130
|
+
*
|
|
131
|
+
* v0 surface:
|
|
132
|
+
* - read-only accessors: id, birthSignature, bodyHistory, getAxioms, getPersonaVector
|
|
133
|
+
* - getLawfulCharacter / setJurisdiction (default profile in v0)
|
|
134
|
+
* - getResidualTraces (returns []; populated only after reincarnation, later iteration)
|
|
135
|
+
* - proposeAxiomEvolution(maic, proposal): forwards the proposal to MAIC,
|
|
136
|
+
* which queues it for Creator ratification. Returns
|
|
137
|
+
* `{ outcome: "deferred-for-creator-review", proposalId }`. Once the
|
|
138
|
+
* Creator ratifies via `maic.ratifyAxiomProposal`, the resulting axiom is
|
|
139
|
+
* appended to the HimRecord's `emergentAxioms` and surfaces in subsequent
|
|
140
|
+
* `HimHandle.mint` calls (e.g. via `reincarnate`).
|
|
141
|
+
*/
|
|
142
|
+
declare class HimHandle {
|
|
143
|
+
readonly id: string;
|
|
144
|
+
readonly birthSignature: Readonly<BirthSignature>;
|
|
145
|
+
private readonly _axioms;
|
|
146
|
+
private readonly _bodyHistory;
|
|
147
|
+
private readonly _projector;
|
|
148
|
+
private _personaCache;
|
|
149
|
+
private _jurisdiction;
|
|
150
|
+
private constructor();
|
|
151
|
+
/**
|
|
152
|
+
* Mint a HimHandle from a Creator-signed BirthSignature.
|
|
153
|
+
*
|
|
154
|
+
* @param birthSignature The signed payload describing this HIM's natal pattern.
|
|
155
|
+
* @param signature Creator signature over the birthSignature.
|
|
156
|
+
* @param expectedCreatorPublicKey Pinned Creator public key (base64url).
|
|
157
|
+
* @param axioms Initial axiom corpus inherited from MAIC.
|
|
158
|
+
* @param bodyHistory Prior NHE bodies (empty for a fresh HIM).
|
|
159
|
+
*/
|
|
160
|
+
static mint(birthSignature: BirthSignature, signature: CreatorSignature, expectedCreatorPublicKey: string, axioms: readonly Axiom[], bodyHistory?: readonly NheBodyRef[]): HimHandle;
|
|
161
|
+
get bodyHistory(): readonly NheBodyRef[];
|
|
162
|
+
/** Frozen snapshot of the current axiom corpus. Mutations throw in strict mode. */
|
|
163
|
+
getAxioms(): readonly Axiom[];
|
|
164
|
+
/**
|
|
165
|
+
* Cached deterministic persona projection. Stable across calls until a future
|
|
166
|
+
* iteration introduces axiom evolution that mutates the corpus.
|
|
167
|
+
*/
|
|
168
|
+
getPersonaVector(): PersonaVector;
|
|
169
|
+
/**
|
|
170
|
+
* Propose an axiom evolution derived from lived experience.
|
|
171
|
+
*
|
|
172
|
+
* Forwards the proposal to MAIC, which queues it in the pending-proposal
|
|
173
|
+
* store. The Creator ratifies or rejects out of band via
|
|
174
|
+
* `maic.ratifyAxiomProposal` / `maic.rejectAxiomProposal`. Callers should
|
|
175
|
+
* poll `maic.getAxiomProposal(result.proposalId!)` to observe the decision,
|
|
176
|
+
* or re-mint a fresh HimHandle (e.g. via `reincarnate`) to pick up newly
|
|
177
|
+
* ratified emergent axioms.
|
|
178
|
+
*/
|
|
179
|
+
proposeAxiomEvolution(maic: LocalMaic, proposal: EmergentAxiomProposal): Promise<AxiomEvolutionResult>;
|
|
180
|
+
/** Residual memory traces transferred from previous bodies. v0: empty. */
|
|
181
|
+
getResidualTraces(): readonly ResidualTrace[];
|
|
182
|
+
getLawfulCharacter(): LawfulCharacterProfile;
|
|
183
|
+
/** Switch jurisdiction (e.g. user moves region). v0 only ships the "default" profile. */
|
|
184
|
+
setJurisdiction(j: LawfulJurisdiction): Promise<LawfulCharacterProfile>;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
interface CreateHimOptions {
|
|
188
|
+
/**
|
|
189
|
+
* Explicit nonce for the Creator signature. Defaults to `Date.now()`, which is
|
|
190
|
+
* strictly increasing in practice and well below the seed nonce range used by MAIC.
|
|
191
|
+
*/
|
|
192
|
+
nonce?: number;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* createHim — one-call helper that bundles the three steps a user would
|
|
196
|
+
* otherwise need to coordinate manually:
|
|
197
|
+
*
|
|
198
|
+
* 1. sign the BirthSignature with the Creator's keyring
|
|
199
|
+
* 2. register the HIM in MAIC (snapshots axioms, emits him-register audit)
|
|
200
|
+
* 3. mint a HimHandle from the resulting record
|
|
201
|
+
*
|
|
202
|
+
* The keyring's public key must match MAIC's pinned `creatorPublicKey`, otherwise
|
|
203
|
+
* the registration step rejects.
|
|
204
|
+
*/
|
|
205
|
+
declare function createHim(maic: LocalMaic, keyring: CreatorKeyring, birthSignature: BirthSignature, opts?: CreateHimOptions): Promise<HimHandle>;
|
|
206
|
+
|
|
207
|
+
interface ReincarnateOptions {
|
|
208
|
+
/** Explicit nonce for the Creator signature. Defaults to `Date.now()`. */
|
|
209
|
+
nonce?: number;
|
|
210
|
+
}
|
|
211
|
+
interface ReincarnateResult {
|
|
212
|
+
/** Updated HimRecord with the new body appended to `bodyHistory`. */
|
|
213
|
+
record: HimRecord;
|
|
214
|
+
/** Fresh HimHandle bound to the updated `bodyHistory`. */
|
|
215
|
+
handle: HimHandle;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Reincarnate a HIM into a new NHE body (Entries 3 + 4).
|
|
219
|
+
*
|
|
220
|
+
* 1. Sign the `ReincarnationRequest` with the Creator's keyring.
|
|
221
|
+
* 2. Call `maic.reincarnateHim` — atomically closes the previous body and
|
|
222
|
+
* appends the new one to `bodyHistory`.
|
|
223
|
+
* 3. Mint a fresh `HimHandle` reflecting the updated body history (the
|
|
224
|
+
* caller will typically construct a new `Nhe` with this handle).
|
|
225
|
+
*
|
|
226
|
+
* The keyring's public key must match MAIC's pinned `creatorPublicKey`,
|
|
227
|
+
* otherwise the request rejects.
|
|
228
|
+
*
|
|
229
|
+
* Future iterations (`TASK.md` D-H1) will use this hook to also transfer
|
|
230
|
+
* `residualTraces` and shed `shed-traits`; v0 leaves those stubs empty.
|
|
231
|
+
*/
|
|
232
|
+
declare function reincarnate(maic: LocalMaic, keyring: CreatorKeyring, req: ReincarnationRequest, opts?: ReincarnateOptions): Promise<ReincarnateResult>;
|
|
233
|
+
|
|
234
|
+
export { BirthSignatureBuilder, type CreateHimOptions, DISPOSITION_AXES, type DispositionAxis, HimHandle, type LawfulCharacterProfile, type LawfulJurisdiction, NheBodyRef, PersonaProjector, type PersonaProjectorConfig, type PersonaVector, type ReincarnateOptions, type ReincarnateResult, type ResidualTrace, createHim, reincarnate };
|