@mindot/will 0.8.0 → 0.10.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/README.md +15 -11
- package/dist/index.d.ts +188 -141
- package/dist/index.js +6985 -3337
- package/dist/index.js.map +1 -1
- package/dist/surface/channels/discord.d.ts +177 -0
- package/dist/surface/channels/discord.js +394 -0
- package/dist/surface/channels/discord.js.map +1 -0
- package/dist/{channels → surface/channels}/whatsapp.d.ts +2 -2
- package/dist/{channels → surface/channels}/whatsapp.js +11 -5
- package/dist/surface/channels/whatsapp.js.map +1 -0
- package/dist/{cli.js → surface/cli.js} +5382 -1573
- package/dist/surface/cli.js.map +1 -0
- package/dist/{mcp → surface/mcp}/effectors.d.ts +1 -1
- package/dist/{mcp → surface/mcp}/effectors.js +10 -4
- package/dist/surface/mcp/effectors.js.map +1 -0
- package/dist/{will-cS6k4uiJ.d.ts → will-evj9_vrd.d.ts} +6658 -5078
- package/package.json +11 -12
- package/src/cognition/agency/consequence.ts +356 -1
- package/src/cognition/agency/conversation.aim.ts +292 -0
- package/src/cognition/agency/engines/action.selector.ts +142 -5
- package/src/cognition/agency/engines/affordance.synthesizer.ts +200 -7
- package/src/cognition/agency/engines/deliberation.engine.ts +76 -3
- package/src/cognition/agency/engines/motor.schema.executor.ts +509 -32
- package/src/cognition/agency/engines/reafference.engine.ts +160 -4
- package/src/cognition/agency/execution.primitives.ts +17 -4
- package/src/cognition/agency/proactive.communicator.ts +19 -3
- package/src/cognition/agency/reconcile.learning.ts +5 -4
- package/src/cognition/agency/restart.ts +66 -0
- package/src/cognition/agency/schemas/innate.ts +96 -1
- package/src/cognition/agency/schemas/repertoire.ts +19 -1
- package/src/cognition/agency/selection.scoring.ts +49 -0
- package/src/cognition/agency/settlement.ts +203 -0
- package/src/cognition/agency/types.ts +73 -1
- package/src/cognition/cache/composition.ts +232 -0
- package/src/cognition/cache/deliberation.cache.ts +219 -0
- package/src/cognition/cache/fingerprint.ts +120 -0
- package/src/cognition/cache/types.ts +105 -0
- package/src/cognition/config.mirror.entities.ts +108 -1
- package/src/cognition/event.schemas.ts +22 -8
- package/src/cognition/faculties/affective.blender.ts +21 -4
- package/src/cognition/faculties/autobiographical.narrator.ts +5 -10
- package/src/cognition/faculties/circadian.oscillator.ts +36 -7
- package/src/cognition/faculties/episodic.consolidator.ts +59 -3
- package/src/cognition/faculties/executive.engine/action.record.ts +129 -0
- package/src/cognition/faculties/executive.engine/commands.ts +189 -14
- package/src/cognition/faculties/executive.engine/context.ts +106 -46
- package/src/cognition/faculties/executive.engine/deliberate.reasoning.ts +1 -1
- package/src/cognition/faculties/executive.engine/engine.ts +714 -136
- package/src/cognition/faculties/executive.engine/escalation.buffer.ts +230 -45
- package/src/cognition/faculties/executive.engine/facet.supervisor.ts +320 -65
- package/src/cognition/faculties/executive.engine/facet.ts +81 -26
- package/src/cognition/faculties/executive.engine/gating.ts +14 -14
- package/src/cognition/faculties/executive.engine/parser.ts +120 -38
- package/src/cognition/faculties/executive.engine/prompt.factory.ts +331 -38
- package/src/cognition/faculties/executive.engine/types.ts +84 -12
- package/src/cognition/faculties/exteroception.ts +99 -98
- package/src/cognition/faculties/goal.manager.ts +144 -16
- package/src/cognition/faculties/known.entity.tracker.ts +287 -29
- package/src/cognition/faculties/moral.evaluator.ts +8 -3
- package/src/cognition/faculties/persona.consolidator.ts +141 -0
- package/src/cognition/faculties/planning.engine/engine.ts +4 -4
- package/src/cognition/faculties/planning.engine/plan.frontier.ts +1 -1
- package/src/cognition/faculties/reputation.tracker.ts +66 -2
- package/src/cognition/faculties/self.model.updater.ts +19 -12
- package/src/cognition/faculties/semantic.engine/integrator.ts +1 -1
- package/src/cognition/faculties/social.perception.ts +47 -3
- package/src/cognition/faculties/threat.evaluator.ts +7 -0
- package/src/cognition/faculties/working.memory.ts +16 -21
- package/src/cognition/identity.entity.ts +205 -0
- package/src/cognition/index.ts +7 -0
- package/src/cognition/instruction.handler.ts +1 -1
- package/src/cognition/memory/vector.adapter.ts +12 -3
- package/src/cognition/memory/vector.embedder.ts +45 -4
- package/src/cognition/percept.entity.ts +122 -0
- package/src/cognition/persona.prior.ts +6 -0
- package/src/cognition/sense.boundary.ts +176 -0
- package/src/cognition/senses/audition.engine/engine.ts +492 -53
- package/src/cognition/senses/base.sense.engine.ts +105 -7
- package/src/cognition/senses/index.ts +83 -13
- package/src/cognition/senses/provenance.ts +128 -0
- package/src/cognition/senses/somatosensation.engine.ts +117 -9
- package/src/cognition/social.identity.ts +296 -0
- package/src/cognition/utilities/token.tracker.ts +94 -10
- package/src/core/orchestrator.ts +51 -0
- package/src/index.ts +39 -5
- package/src/llm/gate.ts +48 -0
- package/src/llm/index.ts +127 -33
- package/src/llm/routing.ts +6 -0
- package/src/llm/summarizer.ts +1 -1
- package/src/llm/wire.contracts.ts +57 -0
- package/src/pma/index.ts +68 -54
- package/src/stem/assembly.audit.ts +1 -0
- package/src/stem/guards/identity.coherence.ts +1 -1
- package/src/stem/index.ts +171 -23
- package/src/stem/mind.ts +198 -57
- package/src/stem/policy/arbiter.ts +10 -0
- package/src/stem/profiles/built-in.ts +7 -0
- package/src/{profiles → stem/profiles}/companion.ts +1 -1
- package/src/{profiles → stem/profiles}/company-brain.ts +1 -1
- package/src/{profiles → stem/profiles}/customer-service.ts +1 -1
- package/src/{profiles → stem/profiles}/game-npc.ts +1 -1
- package/src/{profiles → stem/profiles}/index.ts +1 -1
- package/src/{profiles → stem/profiles}/smart-home.ts +1 -1
- package/src/stem/tracts/effector/escalation.lifecycle.ts +239 -0
- package/src/stem/tracts/effector/policy.enforcement.ts +261 -0
- package/src/stem/tracts/effector/types.ts +110 -0
- package/src/stem/tracts/effector.controller.ts +112 -401
- package/src/stem/tracts/outbox.controller.ts +30 -17
- package/src/stem/tracts/outbox.writer.ts +40 -2
- package/src/stem/tracts/sensory.controller.ts +6 -6
- package/src/stem/tracts/session.logger.ts +6 -1
- package/src/stem/tracts/transport/types.ts +20 -1
- package/src/stem/tracts/transport.controller.ts +33 -9
- package/src/surface/channels/discord.ts +609 -0
- package/src/{channels → surface/channels}/roster.ts +1 -1
- package/src/surface/channels/types.ts +136 -0
- package/src/{channels → surface/channels}/whatsapp.ts +22 -10
- package/src/{cli.ts → surface/cli.ts} +14 -9
- package/src/{host → surface/host}/boot.ts +3 -3
- package/src/{host → surface/host}/utterances.ts +2 -2
- package/src/{mcp → surface/mcp}/effectors.ts +19 -6
- package/src/{mcp → surface/mcp}/server.ts +19 -5
- package/src/{sdk → surface/sdk}/will.ts +194 -33
- package/src/{serve → surface/serve}/server.ts +11 -4
- package/src/types.ts +24 -3
- package/dist/channels/discord.d.ts +0 -69
- package/dist/channels/discord.js +0 -193
- package/dist/channels/discord.js.map +0 -1
- package/dist/channels/whatsapp.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/mcp/effectors.js.map +0 -1
- package/src/channels/discord.ts +0 -214
- package/src/channels/types.ts +0 -46
- package/src/cognition/faculties/executive.engine/messages.ts +0 -102
- package/src/extensions/livestream.ext.ts +0 -570
- package/src/extensions/time.ext.ts +0 -339
- package/src/profiles/built-in.ts +0 -7
- package/src/runners/coherence.runner.ts +0 -49
- package/src/runners/outreach.runner.ts +0 -155
- package/src/runners/social.runner.ts +0 -179
- package/src/runners/thin-shim.runner.ts +0 -205
- /package/dist/{cli.d.ts → surface/cli.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ Embed it six ways — [**SDK facade**](#the-will-sdk-facade--recommended) (Node/
|
|
|
36
36
|
| Personality: a prompt string | Five-factor trait model that *develops* — traits self-tune from experience and carry a learned baseline across restarts |
|
|
37
37
|
| No self-improvement | A closing metacognition loop — introspection writes back into the engine apparatus (accommodation), bounded and surprise-gated |
|
|
38
38
|
| Token blowout at tick 600 | Context windowing — rolling summariser + isolated conversation threads |
|
|
39
|
-
| Fire-and-forget actions | Bidirectional effector ack loop — the host confirms execution; the result feeds back
|
|
39
|
+
| Fire-and-forget actions | Bidirectional effector ack loop — the host confirms execution; the result feeds back through reafference |
|
|
40
40
|
| Fixed effector catalog | Learning agency pipeline — actions are *found in the situation*, enacted, and proceduralised into composite skills via reafference |
|
|
41
41
|
| No identity across restarts | A portable, eval-verified mind artifact (PMA) — psychology **and** learned competence, with a measured reconstruction-fidelity score |
|
|
42
42
|
|
|
@@ -141,9 +141,11 @@ WILL_IDENTITY="I am Aria — curious, dry-witted, fond of this server's people."
|
|
|
141
141
|
ANTHROPIC_API_KEY=sk-ant-… npx -y @mindot/will discord
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
-
No command prefix, no forced replies. It perceives the rooms it can see (salience-scored — perceiving costs no LLM call), **decides for itself when to speak** (silence is a valid outcome), learns people's names as *learned* knowledge
|
|
144
|
+
No command prefix, no forced replies. It perceives the rooms it can see (salience-scored — perceiving costs no LLM call), **decides for itself when to speak** (silence is a valid outcome, written as `[NO_MESSAGE]` and recorded rather than sent), learns people's names as *learned* knowledge, keeps each channel as its own conversation thread, and **can message first**. On shutdown it hibernates to its PMA and returns as the same self, still knowing everyone.
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
Someone the Will meets is a **referent**, not an address: `discord:<userId>` becomes an alias onto an anchor, so the same person met in a server, a DM, and on WhatsApp is one entity rather than three. The rooms they are reachable in hang off that anchor as handles carrying the circumstances — private or shared, and when they last *answered* there — so the mind picks where to say something from evidence about where this person actually replies. `WILL_DISCORD_HOME_CHANNEL` and the roster chain (last shared channel → DM → home) remain the bridge's fallback for when it has nothing to go on.
|
|
147
|
+
|
|
148
|
+
Scope it with `WILL_DISCORD_CHANNELS` (id allowlist) and `WILL_DISCORD_MENTION_ONLY` for busy servers. The bridge answers one innate act and grants nothing else: when the Will **inspects** a room it is already in, Discord replies with what that room is for, what it sits under, and how many are in it — a count, never a roster, because people are met rather than listed. The answer arrives as a *percept* it perceives and judges, not as a value written into it. Everything beyond that stays explicit (effectors / MCP). Setup + SDK embedding (`import { connectDiscord } from '@mindot/will/discord'`): [docs/channels/discord.md](docs/channels/discord.md) · runnable: [`examples/discord.ts`](examples/discord.ts).
|
|
147
149
|
|
|
148
150
|
### The MCP server — a persistent mind in Claude Desktop / Claude Code
|
|
149
151
|
|
|
@@ -246,7 +248,7 @@ manager.addTickListener(willId, (snapshot, tick, outbox, invocations) => {
|
|
|
246
248
|
})
|
|
247
249
|
|
|
248
250
|
// Speak to the Will. The reply arrives on a later tick via the listener above.
|
|
249
|
-
await manager.
|
|
251
|
+
await manager.senseText(willId, {
|
|
250
252
|
kind: 'text',
|
|
251
253
|
entityId: 'alice',
|
|
252
254
|
content: 'How are you feeling about the night shift?',
|
|
@@ -254,13 +256,13 @@ await manager.ingestText(willId, {
|
|
|
254
256
|
})
|
|
255
257
|
```
|
|
256
258
|
|
|
257
|
-
There is **no synchronous reply** — `
|
|
259
|
+
There is **no synchronous reply** — `senseText` returns immediately; the Will answers when it has reasoned. Subscribe to the tick listener *before* (or right after) sending, and treat the outbox as the single source of outbound messages and effector calls.
|
|
258
260
|
|
|
259
261
|
---
|
|
260
262
|
|
|
261
263
|
## Architecture
|
|
262
264
|
|
|
263
|
-
> **Visual map:** [`docs/graphs/`](docs/graphs/) holds twenty-
|
|
265
|
+
> **Visual map:** [`docs/graphs/`](docs/graphs/) holds twenty-eight architecture graphs — the cognitive stories (memory, executive & facets, agency, audition, body & affect, meta-cognition, the executive ⇄ agency seam, planning & goals, social cognition, proactive communication, competence, the two persona channels), the loops that close on the world (exafference, policy reafference and its joint RFC, the answered loop, identity vs route, the signal boundary), the machinery (the deterministic tick, the simulation core, the cognitive bus & wiring, one LLM call end-to-end, model routing, transports, the stem's tracts), the edges (host surfaces, the PMA lifecycle), and the [whole composition](docs/graphs/composition.svg). One palette across all of them: violet is always memory, amber executive, green agency. Regenerate with `bun docs/graphs/generate.ts`.
|
|
264
266
|
|
|
265
267
|

|
|
266
268
|
|
|
@@ -329,6 +331,8 @@ A plan does **not** dispatch steps to an executor down a parallel channel. It pr
|
|
|
329
331
|
|
|
330
332
|
A Will does not own a catalog of effectors it looks up. Capability is a **relation between a body-in-a-state and a world-as-perceived**, not a row in a table. So the Will **finds actions in the situation**: perception synthesises a field of *affordances*, a biased competition selects one, the executor enacts it, and the outcome (reafference) updates competence.
|
|
331
333
|
|
|
334
|
+
Which is why there is a **sense boundary**. Cognition and world share one entity map, so the outward senses have to be told where the mind ends — otherwise it perceives its own bookkeeping as world events and the situation it finds actions in is made of itself. The mind's own types are enumerable (it knows its anatomy); the world's are not, so everything undeclared is world by default and a host can introduce anything. An engine that writes about the mind says so with `writes`; see [`src/cognition/sense.boundary.ts`](src/cognition/sense.boundary.ts).
|
|
335
|
+
|
|
332
336
|
```
|
|
333
337
|
senses → percepts
|
|
334
338
|
→ AffordanceSynthesizer affordance field (no LLM · attention-gated)
|
|
@@ -362,14 +366,14 @@ registerProfile({
|
|
|
362
366
|
manager.addTickListener(willId, (snap, tick, outbox, invocations) => {
|
|
363
367
|
for (const inv of invocations) {
|
|
364
368
|
const result = world.execute(inv) // YOUR world runs the action
|
|
365
|
-
manager.confirmEffectorExecution(willId, inv.
|
|
369
|
+
manager.confirmEffectorExecution(willId, inv.intentId, {
|
|
366
370
|
success: result.ok, description: result.summary, metrics: result.metrics,
|
|
367
371
|
})
|
|
368
372
|
}
|
|
369
373
|
})
|
|
370
374
|
```
|
|
371
375
|
|
|
372
|
-
The acked outcome returns as an `
|
|
376
|
+
The acked outcome returns as an `action.outcome` the ReafferenceEngine reconciles against what the Will expected, and feeds the agency learning loop — so the Will gets *better* at your effectors over time, and that learned competence travels in the PMA. (Today external effectors are objectless: the host resolves the target. Per-effector cost/preconditions and entity-targeting are on the roadmap.)
|
|
373
377
|
|
|
374
378
|
### Senses
|
|
375
379
|
|
|
@@ -398,7 +402,7 @@ When a Will decides to communicate or invoke an external effector, the result go
|
|
|
398
402
|
- **`outbox`** — `OutboxMessage[]` — text/speech bubbles to deliver. Each has `deliveryStatus: 'pending' | 'delivered' | 'failed'`.
|
|
399
403
|
- **`pendingEffectorInvocations`** — `EffectorInvocation[]` — structured action requests, each carrying a correlation handle.
|
|
400
404
|
|
|
401
|
-
The host closes the reafference loop by confirming back — which writes an `
|
|
405
|
+
The host closes the reafference loop by confirming back — which writes an `action.outcome` the ReafferenceEngine reconciles, so the Will *learns what happened*:
|
|
402
406
|
|
|
403
407
|
```typescript
|
|
404
408
|
manager.confirmMessageDelivery(willId, messageId, true)
|
|
@@ -641,7 +645,7 @@ await manager.archiveWill(willId) // stops tick loop, persists final snapshot
|
|
|
641
645
|
// Every tick — drain outbox + effector invocations, push to SSE/WS clients
|
|
642
646
|
const unsub = manager.addTickListener(willId, (snapshot, tick, outbox, invocations) => {
|
|
643
647
|
for (const msg of outbox) pushToClient(msg) // .id .content .effectorName .targetEntityId .deliveryStatus
|
|
644
|
-
for (const inv of invocations) dispatchToWorld(inv) // .
|
|
648
|
+
for (const inv of invocations) dispatchToWorld(inv) // .intentId ← correlation handle
|
|
645
649
|
})
|
|
646
650
|
|
|
647
651
|
// Fine-grained simulation events (goal.formed, belief.updated, emotion.spike, …)
|
|
@@ -696,7 +700,7 @@ manager.loadPMA(willId, pma)
|
|
|
696
700
|
const report = await manager.runPMAEval(willId, { behavioral: true })
|
|
697
701
|
|
|
698
702
|
// Senses — route external input through the sense engines
|
|
699
|
-
await manager.
|
|
703
|
+
await manager.senseText(willId, { kind: 'text', entityId, content, speakerName })
|
|
700
704
|
manager.getSenseEngineStatus(willId) // five domains; audition active
|
|
701
705
|
|
|
702
706
|
// Health & recovery
|
package/dist/index.d.ts
CHANGED
|
@@ -1,143 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
/** Decides how emit() resolves an ack for a given envelope. Default: acked via callback. */
|
|
5
|
-
type AckPolicy = (env: OutboundEnvelope) => AckResult;
|
|
6
|
-
declare class LoopbackTransport implements ExternalTransport {
|
|
7
|
-
/** Every envelope passed to emit(), in order — inspect in tests. */
|
|
8
|
-
readonly sent: OutboundEnvelope[];
|
|
9
|
-
private _connected;
|
|
10
|
-
private _ackPolicy;
|
|
11
|
-
private readonly _inboundHandlers;
|
|
12
|
-
private readonly _statusHandlers;
|
|
13
|
-
constructor(ackPolicy?: AckPolicy);
|
|
14
|
-
get connected(): boolean;
|
|
15
|
-
emit(env: OutboundEnvelope): Promise<AckResult>;
|
|
16
|
-
onInbound(handler: (env: InboundEnvelope) => void): () => void;
|
|
17
|
-
onStatus(handler: (s: TransportStatus) => void): () => void;
|
|
18
|
-
close(): void;
|
|
19
|
-
/** Simulate the peer sending an inbound envelope to the Will. */
|
|
20
|
-
injectInbound(env: InboundEnvelope): void;
|
|
21
|
-
/** Flip connection state and notify status handlers. */
|
|
22
|
-
setConnected(connected: boolean): void;
|
|
23
|
-
/** Swap the ack policy mid-test (e.g. to simulate timeouts then recovery). */
|
|
24
|
-
setAckPolicy(policy: AckPolicy): void;
|
|
25
|
-
/** Convenience: only the envelopes on a given channel. */
|
|
26
|
-
sentOn<T extends OutboundEnvelope['channel']>(channel: T): Extract<OutboundEnvelope, {
|
|
27
|
-
channel: T;
|
|
28
|
-
}>[];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Minimal surface of a socket.io client we depend on — keeps us decoupled from the dep's types. */
|
|
32
|
-
interface SocketLike {
|
|
33
|
-
connected: boolean;
|
|
34
|
-
on(event: string, handler: (...args: any[]) => void): void;
|
|
35
|
-
emit(event: string, payload: unknown, ack?: (response: unknown) => void): void;
|
|
36
|
-
disconnect(): void;
|
|
37
|
-
}
|
|
38
|
-
interface SocketIoTransportOptions {
|
|
39
|
-
/** socket.io server URL (e.g. wss://host or http://host:port). */
|
|
40
|
-
url: string;
|
|
41
|
-
/** This Will's id — sent as auth + routing key. */
|
|
42
|
-
willId: string;
|
|
43
|
-
/** Optional auth token sent in the socket.io handshake. */
|
|
44
|
-
token?: string;
|
|
45
|
-
/** Default ack timeout for emit() in ms. Default 5000. */
|
|
46
|
-
ackTimeoutMs?: number;
|
|
47
|
-
/**
|
|
48
|
-
* Override the socket factory — inject a fake in tests, or customize the
|
|
49
|
-
* socket.io connection. When omitted, `socket.io-client` is dynamically
|
|
50
|
-
* imported and `io(url, { auth })` is called.
|
|
51
|
-
*/
|
|
52
|
-
socketFactory?: (url: string, opts: {
|
|
53
|
-
auth: {
|
|
54
|
-
willId: string;
|
|
55
|
-
token?: string;
|
|
56
|
-
};
|
|
57
|
-
}) => SocketLike | Promise<SocketLike>;
|
|
58
|
-
}
|
|
59
|
-
declare class SocketIoTransport implements ExternalTransport {
|
|
60
|
-
private readonly _opts;
|
|
61
|
-
private _socket;
|
|
62
|
-
private _connecting;
|
|
63
|
-
private _seq;
|
|
64
|
-
private readonly _inboundHandlers;
|
|
65
|
-
private readonly _statusHandlers;
|
|
66
|
-
constructor(_opts: SocketIoTransportOptions);
|
|
67
|
-
get connected(): boolean;
|
|
68
|
-
emit(env: OutboundEnvelope, opts?: {
|
|
69
|
-
ackTimeoutMs?: number;
|
|
70
|
-
}): Promise<AckResult>;
|
|
71
|
-
onInbound(handler: (env: InboundEnvelope) => void): () => void;
|
|
72
|
-
onStatus(handler: (s: TransportStatus) => void): () => void;
|
|
73
|
-
close(): void;
|
|
74
|
-
private _ensureSocket;
|
|
75
|
-
private _connect;
|
|
76
|
-
private _defaultFactory;
|
|
77
|
-
/** Attach socket.io event handlers that feed the inbound + status streams. */
|
|
78
|
-
private _wire;
|
|
79
|
-
private _emitInbound;
|
|
80
|
-
private _notifyStatus;
|
|
81
|
-
private _deliveryAck;
|
|
82
|
-
private _resultAck;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** Channels a consumer can filter on (any OutboundEnvelope channel, or '*'). */
|
|
86
|
-
type StreamChannel = OutboundEnvelope['channel'] | '*';
|
|
87
|
-
type OutboundListener = (env: OutboundEnvelope) => void;
|
|
88
|
-
declare class StreamTransport implements ExternalTransport {
|
|
89
|
-
readonly willId: string;
|
|
90
|
-
private _connected;
|
|
91
|
-
private readonly _outbound;
|
|
92
|
-
private readonly _outboundByCh;
|
|
93
|
-
private readonly _inboundHandlers;
|
|
94
|
-
private readonly _statusHandlers;
|
|
95
|
-
constructor(willId?: string);
|
|
96
|
-
get connected(): boolean;
|
|
97
|
-
/**
|
|
98
|
-
* Deliver an outbound envelope to subscribers. In-process and synchronous, so
|
|
99
|
-
* it resolves immediately (`via: 'event'`) — there is no remote peer to ack.
|
|
100
|
-
* A listener that throws is isolated; it can never break the tick loop.
|
|
101
|
-
*/
|
|
102
|
-
emit(env: OutboundEnvelope): Promise<AckResult>;
|
|
103
|
-
/** Subscribe to every outbound envelope. Returns an unsubscribe function. */
|
|
104
|
-
subscribe(listener: OutboundListener): () => void;
|
|
105
|
-
/**
|
|
106
|
-
* Subscribe to a single channel (e.g. `'token_report'`, `'session_log'`,
|
|
107
|
-
* `'reply'`) or `'*'` for all. Returns an unsubscribe function.
|
|
108
|
-
*/
|
|
109
|
-
on(channel: StreamChannel, listener: OutboundListener): () => void;
|
|
110
|
-
/**
|
|
111
|
-
* Inject an inbound envelope (message, percept, ack) into the Will. The stem
|
|
112
|
-
* enqueues it onto the tick-stamped InboundQueue and applies it deterministically
|
|
113
|
-
* on tick — this method itself never touches simulation state.
|
|
114
|
-
*/
|
|
115
|
-
injectInbound(env: InboundEnvelope): void;
|
|
116
|
-
onInbound(handler: (env: InboundEnvelope) => void): () => void;
|
|
117
|
-
onStatus(handler: (s: TransportStatus) => void): () => void;
|
|
118
|
-
/** Notify status subscribers (e.g. flip to 'disconnected' in a test). */
|
|
119
|
-
setStatus(status: TransportStatus): void;
|
|
120
|
-
close(): void;
|
|
121
|
-
/** Total active outbound listeners (diagnostics/tests). */
|
|
122
|
-
get listenerCount(): number;
|
|
123
|
-
private _dispatch;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Whether producers should ALSO write their telemetry to local files.
|
|
127
|
-
*
|
|
128
|
-
* Files are a development convenience only. In production the stream/transport is
|
|
129
|
-
* the single source of truth and the consumer owns persistence.
|
|
130
|
-
*
|
|
131
|
-
* - `WILL_FILE_LOGS=true|1|false|0` — explicit override (wins).
|
|
132
|
-
* - otherwise: on when `NODE_ENV` is neither `production` nor `test`.
|
|
133
|
-
*/
|
|
134
|
-
declare function fileLoggingEnabled(): boolean;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Number of ticks an undelivered outbox message survives before it is
|
|
138
|
-
* expired. Override via WILL_OUTBOX_TTL_TICKS. Default: 100 ticks.
|
|
139
|
-
*/
|
|
140
|
-
declare const OUTBOX_TTL_TICKS: number;
|
|
1
|
+
import { S as SimulationContext, a as SeededPRNG, b as SimulationEntity, T as Timestamp, c as SimulationEvent, d as StateManager, e as Tick, f as SimulationState, R as RestoreOptions, g as StateCommands, h as ReasoningFootprint, i as ReadonlySimulationState, C as ConflictReport, j as ConflictStrategy, k as ConflictResolution, O as OutboundEnvelope, A as AckResult, l as ExternalTransport, I as InboundEnvelope, m as TransportStatus, P as PolicyDecision, D as DenialFinality, n as PolicyArbiter, o as PolicyInvocation, V as Verdict } from './will-evj9_vrd.js';
|
|
2
|
+
export { p as AckEnvelope, q as ActionRequest, r as ActionResult, s as ActionSelector, t as ActivityEnvelope, u as ActivityEvent, v as ActivityEventHandler, w as AestheticEvaluator, x as AestheticEvaluatorConfig, y as AffectiveBlender, z as AffectiveBlenderConfig, B as AffordanceSynthesizer, F as AsyncEngine, G as AsyncEngineConfig, H as AttachmentEvaluator, J as AttachmentEvaluatorConfig, K as AttentionAllocator, L as AttentionAllocatorConfig, M as AuditionEngine, N as AutobiographicalNarrator, Q as AutobiographicalNarratorConfig, U as BACKGROUND_DEMAND, X as BehavioralProbeResult, Y as BiasDetector, Z as BiasDetectorConfig, _ as BunStorageAdapter, $ as ChunkEnvelope, a0 as CircadianConfig, a1 as CircadianOscillator, a2 as ClockConfig, a3 as Cognition, a4 as CognitiveHealth, a5 as ConfidenceCalibrator, a6 as ConfidenceCalibratorConfig, a7 as Coordinates, a8 as CreateWillOptions, a9 as DefaultEventBus, aa as DefaultMetricCollector, ab as DefaultOrchestrator, ac as DefaultReplayRecorder, ad as DefaultReplaySession, ae as DefaultScenario, af as DefaultSerializer, ag as DefaultSimulation, ah as DefaultSimulationClock, ai as DefaultStateManager, aj as DefaultVectorMemoryAdapter, ak as DeliberationEngine, al as DeltaEncoder, am as DeltaSnapshot, an as DreamSimulator, ao as DreamSimulatorConfig, ap as Duration, aq as ESCALATION_DEMAND, ar as EffectorDeclaration, as as EffectorEntry, E as EffectorHandler, at as EffectorResult, au as EffectorSpec, av as EmbeddingProvider, aw as EmpathySimulator, ax as EmpathySimulatorConfig, ay as EnergyRegulator, az as EnergyRegulatorConfig, aA as EngineRegistry, aB as EngineResult, aC as Envelope, aD as EpisodicConsolidator, aE as EpisodicConsolidatorConfig, aF as EventBus, aG as EventBusConfig, aH as EventFilter, aI as EventHandler, aJ as EventPayload, aK as ExecutiveEngine, aL as ExecutiveEngineConfig, aM as Exteroception, aN as ExteroceptionConfig, aO as ForgettingCurve, aP as ForgettingCurveConfig, aQ as FrustrationEvaluator, aR as FrustrationEvaluatorConfig, aS as GoalManager, aT as GoalManagerConfig, aU as GustationEngine, aV as InboundMessageEnvelope, aW as InboundPerceptEnvelope, aX as InhibitionController, aY as InhibitionControllerConfig, aZ as Interoception, a_ as InteroceptionConfig, a$ as IntrospectionEngine, b0 as IntrospectionEngineConfig, b1 as KNOWN_PROVIDERS, b2 as KnownEntityTracker, b3 as KnownEntityTrackerConfig, b4 as KnownProvider, b5 as LLMCallMeta, b6 as LLMCompletionRecord, b7 as LLMCompletionSink, b8 as LLMProvider, b9 as LLMWire, ba as LossEvaluator, bb as LossEvaluatorConfig, bc as MessageEnvelope, bd as MetricCollector, be as MetricPoint, bf as MinimalContext, bg as MockEmbedder, bh as ModelPrice, bi as ModelRoute, bj as ModelRouter, bk as MoralEvaluator, bl as MoralEvaluatorConfig, bm as MotorSchemaExecutor, bn as NULL_ARBITER, bo as NULL_ROUTER, bp as NoveltyDetector, bq as NoveltyDetectorConfig, br as OlfactionEngine, bs as OpenAICompatibleEmbedder, bt as Orchestrator, bu as OrchestratorConfig, bv as OutboxMessage, bw as PMABehavioral, bx as PMABelief, by as PMAEmotionalBaseline, bz as PMAEvalHarness, bA as PMAGoal, bB as PMAIdentity, bC as PMAProbe, bD as PMASnapshot, bE as PerceptEnvelope, bF as PersonaConsolidator, bG as PersonaConsolidatorConfig, bH as PlanningEngine, bI as PlanningEngineConfig, bJ as PolicyCounterfactual, bK as PriceTable, bL as ProviderCredential, bM as ReafferenceEngine, bN as ReconstructionFidelityReport, bO as ReconstructionFidelityScores, bP as RecordUsageInput, bQ as ReplayComparison, bR as ReplayConfig, bS as ReplayDifference, bT as ReplayManager, bU as ReplayMetadata, bV as ReplayRecord, bW as ReplayRecorder, bX as ReplaySession, bY as ReplyEnvelope, bZ as ReputationTracker, b_ as ReputationTrackerConfig, b$ as RewardEvaluator, c0 as RewardEvaluatorConfig, c1 as RoutingRule, c2 as Scenario, c3 as ScenarioConfig, c4 as ScenarioValidationResult, c5 as SchemaPrecondition, c6 as SelfModelUpdater, c7 as SelfModelUpdaterConfig, c8 as SemanticIntegrator, c9 as SemanticIntegratorConfig, ca as SensoryInput, cb as SensorySignal, cc as SerializationConfig, cd as SerializationFormat, ce as SerializedEntity, cf as SerializedState, cg as Serializer, ch as SessionLogEnvelope, ci as SignalProvenance, cj as Simulation, ck as SimulationClock, cl as SimulationConfig, cm as SimulationEngine, cn as SimulationEventBase, co as SimulationEventListener, cp as SleepPressureConfig, cq as SleepPressureRegulator, cr as SocialPerception, cs as SocialPerceptionConfig, ct as SomatosensationEngine, cu as SpacedRepetition, cv as SpacedRepetitionConfig, cw as StateSnapshot, cx as Stimulus, cy as StorageAdapter, cz as StressRegulator, cA as StressRegulatorConfig, cB as TableRouter, cC as TaskSwitcher, cD as TaskSwitcherConfig, cE as TextMessage, cF as TheoryOfMind, cG as TheoryOfMindConfig, cH as ThreatEvaluator, cI as ThreatEvaluatorConfig, cJ as TickListener, cK as TokenLedgerRecord, cL as TokenReportEnvelope, cM as TokenTracker, cN as TokenTrackerConfig, cO as TokenUsage, cP as Transduced, cQ as VectorIndex, cR as VectorMemoryAdapter, cS as VectorMemoryConfig, cT as VectorQueryFilter, cU as VectorQueryResult, cV as VectorRecord, cW as VisionEngine, cX as VoiceChunk, W as Will, cY as WillAffect, cZ as WillConfig, c_ as WillEffectorAct, c$ as WillInstance, d0 as WillMessage, d1 as WillStateSummary, d2 as WillStatus, d3 as WillStem, d4 as WillSummary, d5 as WorkingMemory, d6 as WorkingMemoryConfig, d7 as WorldEntity, d8 as WorldInterface, d9 as asFinality, da as asProvenance, db as assembleMind, dc as chainRouters, dd as clearCompletionRecorder, de as defaultBaseFor, df as effectorInvocation, dg as effectorInvocationEnvelope, dh as finalityOf, di as getCompletionRecorder, dj as isNullArbiter, dk as isNullRouter, dl as knownWireFor, dm as resolvePricing, dn as setCompletionRecorder } from './will-evj9_vrd.js';
|
|
141
3
|
|
|
142
4
|
/**
|
|
143
5
|
* Creates a Mulberry32 PRNG from the given seed.
|
|
@@ -416,6 +278,144 @@ declare class ConflictDetector {
|
|
|
416
278
|
private _merge;
|
|
417
279
|
}
|
|
418
280
|
|
|
281
|
+
/** Decides how emit() resolves an ack for a given envelope. Default: acked via callback. */
|
|
282
|
+
type AckPolicy = (env: OutboundEnvelope) => AckResult;
|
|
283
|
+
declare class LoopbackTransport implements ExternalTransport {
|
|
284
|
+
/** Every envelope passed to emit(), in order — inspect in tests. */
|
|
285
|
+
readonly sent: OutboundEnvelope[];
|
|
286
|
+
private _connected;
|
|
287
|
+
private _ackPolicy;
|
|
288
|
+
private readonly _inboundHandlers;
|
|
289
|
+
private readonly _statusHandlers;
|
|
290
|
+
constructor(ackPolicy?: AckPolicy);
|
|
291
|
+
get connected(): boolean;
|
|
292
|
+
emit(env: OutboundEnvelope): Promise<AckResult>;
|
|
293
|
+
onInbound(handler: (env: InboundEnvelope) => void): () => void;
|
|
294
|
+
onStatus(handler: (s: TransportStatus) => void): () => void;
|
|
295
|
+
close(): void;
|
|
296
|
+
/** Simulate the peer sending an inbound envelope to the Will. */
|
|
297
|
+
injectInbound(env: InboundEnvelope): void;
|
|
298
|
+
/** Flip connection state and notify status handlers. */
|
|
299
|
+
setConnected(connected: boolean): void;
|
|
300
|
+
/** Swap the ack policy mid-test (e.g. to simulate timeouts then recovery). */
|
|
301
|
+
setAckPolicy(policy: AckPolicy): void;
|
|
302
|
+
/** Convenience: only the envelopes on a given channel. */
|
|
303
|
+
sentOn<T extends OutboundEnvelope['channel']>(channel: T): Extract<OutboundEnvelope, {
|
|
304
|
+
channel: T;
|
|
305
|
+
}>[];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** Minimal surface of a socket.io client we depend on — keeps us decoupled from the dep's types. */
|
|
309
|
+
interface SocketLike {
|
|
310
|
+
connected: boolean;
|
|
311
|
+
on(event: string, handler: (...args: any[]) => void): void;
|
|
312
|
+
emit(event: string, payload: unknown, ack?: (response: unknown) => void): void;
|
|
313
|
+
disconnect(): void;
|
|
314
|
+
}
|
|
315
|
+
interface SocketIoTransportOptions {
|
|
316
|
+
/** socket.io server URL (e.g. wss://host or http://host:port). */
|
|
317
|
+
url: string;
|
|
318
|
+
/** This Will's id — sent as auth + routing key. */
|
|
319
|
+
willId: string;
|
|
320
|
+
/** Optional auth token sent in the socket.io handshake. */
|
|
321
|
+
token?: string;
|
|
322
|
+
/** Default ack timeout for emit() in ms. Default 5000. */
|
|
323
|
+
ackTimeoutMs?: number;
|
|
324
|
+
/**
|
|
325
|
+
* Override the socket factory — inject a fake in tests, or customize the
|
|
326
|
+
* socket.io connection. When omitted, `socket.io-client` is dynamically
|
|
327
|
+
* imported and `io(url, { auth })` is called.
|
|
328
|
+
*/
|
|
329
|
+
socketFactory?: (url: string, opts: {
|
|
330
|
+
auth: {
|
|
331
|
+
willId: string;
|
|
332
|
+
token?: string;
|
|
333
|
+
};
|
|
334
|
+
}) => SocketLike | Promise<SocketLike>;
|
|
335
|
+
}
|
|
336
|
+
declare class SocketIoTransport implements ExternalTransport {
|
|
337
|
+
private readonly _opts;
|
|
338
|
+
private _socket;
|
|
339
|
+
private _connecting;
|
|
340
|
+
private _seq;
|
|
341
|
+
private readonly _inboundHandlers;
|
|
342
|
+
private readonly _statusHandlers;
|
|
343
|
+
constructor(_opts: SocketIoTransportOptions);
|
|
344
|
+
get connected(): boolean;
|
|
345
|
+
emit(env: OutboundEnvelope, opts?: {
|
|
346
|
+
ackTimeoutMs?: number;
|
|
347
|
+
}): Promise<AckResult>;
|
|
348
|
+
onInbound(handler: (env: InboundEnvelope) => void): () => void;
|
|
349
|
+
onStatus(handler: (s: TransportStatus) => void): () => void;
|
|
350
|
+
close(): void;
|
|
351
|
+
private _ensureSocket;
|
|
352
|
+
private _connect;
|
|
353
|
+
private _defaultFactory;
|
|
354
|
+
/** Attach socket.io event handlers that feed the inbound + status streams. */
|
|
355
|
+
private _wire;
|
|
356
|
+
private _emitInbound;
|
|
357
|
+
private _notifyStatus;
|
|
358
|
+
private _deliveryAck;
|
|
359
|
+
private _resultAck;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** Channels a consumer can filter on (any OutboundEnvelope channel, or '*'). */
|
|
363
|
+
type StreamChannel = OutboundEnvelope['channel'] | '*';
|
|
364
|
+
type OutboundListener = (env: OutboundEnvelope) => void;
|
|
365
|
+
declare class StreamTransport implements ExternalTransport {
|
|
366
|
+
readonly willId: string;
|
|
367
|
+
private _connected;
|
|
368
|
+
private readonly _outbound;
|
|
369
|
+
private readonly _outboundByCh;
|
|
370
|
+
private readonly _inboundHandlers;
|
|
371
|
+
private readonly _statusHandlers;
|
|
372
|
+
constructor(willId?: string);
|
|
373
|
+
get connected(): boolean;
|
|
374
|
+
/**
|
|
375
|
+
* Deliver an outbound envelope to subscribers. In-process and synchronous, so
|
|
376
|
+
* it resolves immediately (`via: 'event'`) — there is no remote peer to ack.
|
|
377
|
+
* A listener that throws is isolated; it can never break the tick loop.
|
|
378
|
+
*/
|
|
379
|
+
emit(env: OutboundEnvelope): Promise<AckResult>;
|
|
380
|
+
/** Subscribe to every outbound envelope. Returns an unsubscribe function. */
|
|
381
|
+
subscribe(listener: OutboundListener): () => void;
|
|
382
|
+
/**
|
|
383
|
+
* Subscribe to a single channel (e.g. `'token_report'`, `'session_log'`,
|
|
384
|
+
* `'reply'`) or `'*'` for all. Returns an unsubscribe function.
|
|
385
|
+
*/
|
|
386
|
+
on(channel: StreamChannel, listener: OutboundListener): () => void;
|
|
387
|
+
/**
|
|
388
|
+
* Inject an inbound envelope (message, percept, ack) into the Will. The stem
|
|
389
|
+
* enqueues it onto the tick-stamped InboundQueue and applies it deterministically
|
|
390
|
+
* on tick — this method itself never touches simulation state.
|
|
391
|
+
*/
|
|
392
|
+
injectInbound(env: InboundEnvelope): void;
|
|
393
|
+
onInbound(handler: (env: InboundEnvelope) => void): () => void;
|
|
394
|
+
onStatus(handler: (s: TransportStatus) => void): () => void;
|
|
395
|
+
/** Notify status subscribers (e.g. flip to 'disconnected' in a test). */
|
|
396
|
+
setStatus(status: TransportStatus): void;
|
|
397
|
+
close(): void;
|
|
398
|
+
/** Total active outbound listeners (diagnostics/tests). */
|
|
399
|
+
get listenerCount(): number;
|
|
400
|
+
private _dispatch;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Whether producers should ALSO write their telemetry to local files.
|
|
404
|
+
*
|
|
405
|
+
* Files are a development convenience only. In production the stream/transport is
|
|
406
|
+
* the single source of truth and the consumer owns persistence.
|
|
407
|
+
*
|
|
408
|
+
* - `WILL_FILE_LOGS=true|1|false|0` — explicit override (wins).
|
|
409
|
+
* - otherwise: on when `NODE_ENV` is neither `production` nor `test`.
|
|
410
|
+
*/
|
|
411
|
+
declare function fileLoggingEnabled(): boolean;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Number of ticks an undelivered outbox message survives before it is
|
|
415
|
+
* expired. Override via WILL_OUTBOX_TTL_TICKS. Default: 100 ticks.
|
|
416
|
+
*/
|
|
417
|
+
declare const OUTBOX_TTL_TICKS: number;
|
|
418
|
+
|
|
419
419
|
interface WorldProfile {
|
|
420
420
|
id: string;
|
|
421
421
|
name: string;
|
|
@@ -433,4 +433,51 @@ declare function resolveProfile(id: string): WorldProfile | undefined;
|
|
|
433
433
|
/** List all registered profile ids. */
|
|
434
434
|
declare function listProfiles(): string[];
|
|
435
435
|
|
|
436
|
-
|
|
436
|
+
/** A bound on one parameter. Checked in declaration order: max, min, equals, oneOf. */
|
|
437
|
+
interface ParamConstraint {
|
|
438
|
+
max?: number;
|
|
439
|
+
min?: number;
|
|
440
|
+
equals?: unknown;
|
|
441
|
+
oneOf?: readonly unknown[];
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* One rule. `schema`/`target` scope it (omitted ⇒ matches any); the FIRST rule
|
|
445
|
+
* whose scope matches decides, so order is policy.
|
|
446
|
+
*
|
|
447
|
+
* `require` is meaningful with `decision: 'allow'` only: the scope matched, and
|
|
448
|
+
* these constraints must hold for the allow to stand. A violation flips the
|
|
449
|
+
* verdict to deny — carrying the counterfactual — with finality 'parameter',
|
|
450
|
+
* because the ability itself was permitted and only these arguments were not.
|
|
451
|
+
*
|
|
452
|
+
* A rule with `decision: 'deny'` and no `require` is a flat class-level ban;
|
|
453
|
+
* it reports finality 'class' unless told otherwise.
|
|
454
|
+
*/
|
|
455
|
+
interface PolicyRule {
|
|
456
|
+
schema?: string;
|
|
457
|
+
target?: string;
|
|
458
|
+
decision: PolicyDecision;
|
|
459
|
+
require?: Record<string, ParamConstraint>;
|
|
460
|
+
reasonCode?: string;
|
|
461
|
+
finality?: DenialFinality;
|
|
462
|
+
}
|
|
463
|
+
interface RuleTableOptions {
|
|
464
|
+
rules: readonly PolicyRule[];
|
|
465
|
+
/**
|
|
466
|
+
* The verdict when NO rule matches. Required — deliberately not defaulted.
|
|
467
|
+
* A policy component that silently defaults open is a trap; make the posture
|
|
468
|
+
* an explicit decision at the call site. 'deny' is fail-closed and is the
|
|
469
|
+
* right choice once a rule set is complete.
|
|
470
|
+
*/
|
|
471
|
+
fallthrough: PolicyDecision;
|
|
472
|
+
/** Recorded with every verdict for audit. Defaults to 'rule-table'. */
|
|
473
|
+
name?: string;
|
|
474
|
+
}
|
|
475
|
+
declare class RuleTableArbiter implements PolicyArbiter {
|
|
476
|
+
readonly name: string;
|
|
477
|
+
private readonly _rules;
|
|
478
|
+
private readonly _fallthrough;
|
|
479
|
+
constructor(opts: RuleTableOptions);
|
|
480
|
+
evaluate(invocation: PolicyInvocation): Verdict;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
export { type AckPolicy, AckResult, ConflictDetector, ConflictReport, ConflictResolution, ConflictStrategy, ConsistentHashRouter, ConsoleLogger, type CrossShardQuery, type CrossShardResult, type CrossShardTransport, DefaultPartitionRouter, type DeliveryGuarantee, DenialFinality, type DistributedEvent, type DistributedNode, type DistributedNodeConfig, DistributedOrchestrator, DistributedStateManager, ExternalTransport, InboundEnvelope, LocalTransport, type Logger, LoopbackTransport, OUTBOX_TTL_TICKS, OutboundEnvelope, type OutboundListener, type ParamConstraint, type PartitionRouter, PolicyArbiter, PolicyDecision, PolicyInvocation, type PolicyRule, ReasoningFootprint, RestoreOptions, RuleTableArbiter, type RuleTableOptions, type ShardConfig, type ShardStrategy, SilentLogger, SimulationContext, SimulationEntity, SimulationEvent, SimulationState, SocketIoTransport, type SocketIoTransportOptions, type SocketLike, StateManager, type StreamChannel, StreamTransport, Tick, Timestamp, TransportStatus, Verdict, type WorldProfile, createContext, createPRNG, fileLoggingEnabled, getLogger, listProfiles, logger, resetLogger, resolveProfile, setLogger };
|