@mindot/will 0.4.0 → 0.6.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 +32 -12
- package/dist/channels/discord.d.ts +2 -11
- package/dist/channels/discord.js.map +1 -1
- package/dist/channels/whatsapp.d.ts +72 -0
- package/dist/channels/whatsapp.js +252 -0
- package/dist/channels/whatsapp.js.map +1 -0
- package/dist/cli.js +837 -91
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +620 -79
- package/dist/index.js.map +1 -1
- package/dist/mcp/effectors.d.ts +1 -1
- package/dist/mcp/effectors.js.map +1 -1
- package/dist/types-E9-HV-SW.d.ts +11 -0
- package/dist/{will-D-slky1N.d.ts → will-Bikuk4s2.d.ts} +56 -12
- package/package.json +12 -3
- package/src/channels/discord.ts +11 -11
- package/src/channels/roster.ts +1 -1
- package/src/channels/types.ts +1 -1
- package/src/channels/whatsapp.ts +318 -0
- package/src/cli.ts +46 -23
- package/src/cognition/acp.ts +28 -0
- package/src/cognition/agency/consequence.ts +174 -0
- package/src/cognition/agency/engines/action.selector.ts +301 -48
- package/src/cognition/agency/engines/affordance.synthesizer.ts +26 -16
- package/src/cognition/agency/engines/deliberation.engine.ts +28 -14
- package/src/cognition/agency/engines/motor.schema.executor.ts +86 -14
- package/src/cognition/agency/engines/reafference.engine.ts +122 -18
- package/src/cognition/agency/execution.primitives.ts +13 -13
- package/src/cognition/agency/proactive.communicator.ts +1 -1
- package/src/cognition/agency/reconcile.learning.ts +1 -1
- package/src/cognition/agency/revocation.ts +79 -0
- package/src/cognition/agency/schemas/repertoire.ts +2 -2
- package/src/cognition/agency/selection.scoring.ts +25 -9
- package/src/cognition/bus.ts +2 -2
- package/src/cognition/completion.inbox.ts +1 -1
- package/src/cognition/config.mirror.entities.ts +5 -5
- package/src/cognition/event.log.ts +2 -2
- package/src/cognition/event.schemas.ts +67 -67
- package/src/cognition/faculties/aesthetic.evaluator.ts +6 -6
- package/src/cognition/faculties/affective.blender.ts +36 -4
- package/src/cognition/faculties/attachment.evaluator.ts +6 -6
- package/src/cognition/faculties/attention.allocator.ts +63 -8
- package/src/cognition/faculties/autobiographical.narrator.ts +3 -3
- package/src/cognition/faculties/bias.detector.ts +7 -7
- package/src/cognition/faculties/circadian.oscillator.ts +3 -3
- package/src/cognition/faculties/confidence.calibrator.ts +7 -7
- package/src/cognition/faculties/dream.simulator.ts +5 -5
- package/src/cognition/faculties/empathy.simulator.ts +7 -7
- package/src/cognition/faculties/energy.regulator.ts +4 -4
- package/src/cognition/faculties/episodic.consolidator.ts +6 -6
- package/src/cognition/faculties/executive.engine/commands.ts +6 -6
- package/src/cognition/faculties/executive.engine/context.ts +42 -42
- package/src/cognition/faculties/executive.engine/deferred.effects.ts +2 -2
- package/src/cognition/faculties/executive.engine/engine.ts +27 -26
- package/src/cognition/faculties/executive.engine/facet.supervisor.ts +12 -12
- package/src/cognition/faculties/executive.engine/facet.ts +18 -18
- package/src/cognition/faculties/executive.engine/gating.ts +2 -2
- package/src/cognition/faculties/executive.engine/messages.ts +3 -3
- package/src/cognition/faculties/executive.engine/parser.ts +11 -11
- package/src/cognition/faculties/executive.engine/prompt.factory.ts +55 -55
- package/src/cognition/faculties/exteroception.ts +99 -5
- package/src/cognition/faculties/forgetting.curve.ts +3 -3
- package/src/cognition/faculties/frustration.evaluator.ts +6 -6
- package/src/cognition/faculties/goal.manager.ts +15 -15
- package/src/cognition/faculties/inhibition.controller.ts +3 -3
- package/src/cognition/faculties/interoception.ts +3 -3
- package/src/cognition/faculties/introspection.engine.ts +3 -3
- package/src/cognition/faculties/known.entity.tracker.ts +15 -15
- package/src/cognition/faculties/loss.evaluator.ts +2 -2
- package/src/cognition/faculties/moral.evaluator.ts +4 -4
- package/src/cognition/faculties/novelty.detector.ts +4 -4
- package/src/cognition/faculties/persona.consolidator.ts +12 -12
- package/src/cognition/faculties/planning.engine/engine.ts +47 -47
- package/src/cognition/faculties/planning.engine/plan.frontier.ts +5 -5
- package/src/cognition/faculties/planning.engine/plan.store.ts +1 -1
- package/src/cognition/faculties/planning.engine/plan.supervision.ts +20 -20
- package/src/cognition/faculties/reputation.tracker.ts +6 -6
- package/src/cognition/faculties/reward.evaluator.ts +4 -4
- package/src/cognition/faculties/self.model.updater.ts +8 -8
- package/src/cognition/faculties/semantic.engine/integrator.ts +15 -15
- package/src/cognition/faculties/sleep.pressure.regulator.ts +4 -4
- package/src/cognition/faculties/social.perception.ts +3 -3
- package/src/cognition/faculties/spaced.repetition.ts +2 -2
- package/src/cognition/faculties/stress.regulator.ts +27 -4
- package/src/cognition/faculties/task.switcher.ts +11 -6
- package/src/cognition/faculties/theory.of.mind.ts +6 -6
- package/src/cognition/faculties/threat.evaluator.ts +3 -3
- package/src/cognition/faculties/working.memory.ts +8 -8
- package/src/cognition/generative.model.ts +2 -2
- package/src/cognition/memory/vector.adapter.ts +5 -5
- package/src/cognition/memory/vector.content.ts +4 -4
- package/src/cognition/memory/vector.embedder.ts +9 -9
- package/src/cognition/persona.prior.ts +1 -1
- package/src/cognition/schema.registry.ts +2 -2
- package/src/cognition/senses/audition.engine/engine.ts +2 -2
- package/src/cognition/senses/base.sense.engine.ts +1 -1
- package/src/cognition/utilities/token.tracker.ts +11 -5
- package/src/core/abstracts.ts +1 -1
- package/src/core/completion.recorder.ts +2 -2
- package/src/core/serialization.ts +3 -3
- package/src/core/snapshot.manager.ts +1 -1
- package/src/core/state.manager.ts +1 -1
- package/src/core/utils.ts +1 -1
- package/src/host/boot.ts +59 -37
- package/src/host/utterances.ts +1 -1
- package/src/llm/index.ts +84 -34
- package/src/llm/summarizer.ts +4 -4
- package/src/llm/wire.contracts.ts +1 -1
- package/src/mcp/effectors.ts +10 -10
- package/src/mcp/server.ts +11 -11
- package/src/pma/eval.ts +1 -1
- package/src/pma/index.ts +21 -21
- package/src/runners/outreach.runner.ts +3 -3
- package/src/runners/social.runner.ts +1 -1
- package/src/runners/thin-shim.runner.ts +1 -1
- package/src/sdk/will.ts +20 -11
- package/src/serve/server.ts +12 -12
- package/src/stem/assembly.audit.ts +3 -3
- package/src/stem/guards/identity.coherence.ts +13 -12
- package/src/stem/guards/identity.guard.ts +22 -22
- package/src/stem/index.ts +11 -11
- package/src/stem/mind.ts +12 -12
- package/src/stem/tracts/biography.writer.ts +3 -3
- package/src/stem/tracts/effector.controller.ts +4 -4
- package/src/stem/tracts/health.reporter.ts +1 -1
- package/src/stem/tracts/outbox.controller.ts +4 -0
- package/src/stem/tracts/outbox.writer.ts +4 -4
- package/src/stem/tracts/pma.controller.ts +1 -1
- package/src/stem/tracts/replay.controller.ts +10 -10
- package/src/stem/tracts/sensory.controller.ts +2 -2
- package/src/stem/tracts/session.logger.ts +4 -4
- package/src/stem/tracts/transport/socketio.transport.ts +7 -7
- package/src/stem/tracts/transport/stream.transport.ts +2 -2
- package/src/stem/tracts/transport.controller.ts +15 -15
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// ─────────────────────────────────────────────────────────────
|
|
2
|
+
// src/agency/revocation.ts — commitment-revocation tombstones
|
|
3
|
+
// ─────────────────────────────────────────────────────────────
|
|
4
|
+
//
|
|
5
|
+
// EXAFFERENCE P4. When the world ruptures hard enough (rupture ≥
|
|
6
|
+
// RUPTURE_REVOKE_GATE), the ActionSelector doesn't just soften its switch cost
|
|
7
|
+
// (P3) — it *lets go* of a commitment it was still weighing: a `deliberating`
|
|
8
|
+
// intent. But the selector cannot delete that intent directly. Registration
|
|
9
|
+
// order is Selector → Deliberation → Executor, and each engine reads the frozen
|
|
10
|
+
// tick-start snapshot, so a same-tick selector-delete + deliberation-set on the
|
|
11
|
+
// same intent applies set-after-delete → the intent is RESURRECTED as `selected`
|
|
12
|
+
// and enacted despite revocation (the P0 audit's resurrection race).
|
|
13
|
+
//
|
|
14
|
+
// The tombstone breaks that race by construction: the selector writes a SEPARATE
|
|
15
|
+
// `agency.revocation` entity keyed by the intent id (no same-entity write). One
|
|
16
|
+
// tick later both honorers see it from frozen state:
|
|
17
|
+
// • the Deliberation engine skips + deletes tombstoned `deliberating` intents;
|
|
18
|
+
// • the Executor refuses to enact a tombstoned `selected` intent (the half-race
|
|
19
|
+
// where deliberation committed `selected` the same tick the tombstone landed).
|
|
20
|
+
// Revocation commits NO successor — the field re-forms and next tick selects.
|
|
21
|
+
// A short TTL reaps a tombstone whose intent already vanished for another reason.
|
|
22
|
+
// ─────────────────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
import type { EntityInput, Tick } from '#core/types'
|
|
25
|
+
|
|
26
|
+
export const REVOCATION_TYPE = 'agency.revocation'
|
|
27
|
+
|
|
28
|
+
/** Rupture at/above which a still-deliberating commitment is revoked (rarer than
|
|
29
|
+
* P3's recruitment-grade softening — letting go is a bigger step than easing up). */
|
|
30
|
+
export const RUPTURE_REVOKE_GATE = 0.7
|
|
31
|
+
|
|
32
|
+
/** Safety reap: a tombstone whose intent disappeared otherwise dies after this. */
|
|
33
|
+
export const REVOCATION_TTL_TICKS = 5
|
|
34
|
+
|
|
35
|
+
export function revocationId( intentId: string ): string {
|
|
36
|
+
return `agency-revocation-${ intentId }`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Build the tombstone for a revoked intent (keyed by intent id — one per intent). */
|
|
40
|
+
export function revocationEntity(
|
|
41
|
+
intentId: string, schema: string, rupture: number, tick: Tick,
|
|
42
|
+
): EntityInput {
|
|
43
|
+
return {
|
|
44
|
+
id: revocationId( intentId ),
|
|
45
|
+
type: REVOCATION_TYPE,
|
|
46
|
+
metadata: { intentId, schema, rupture, tick, expiresAt: tick + REVOCATION_TTL_TICKS },
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Intent ids under a live (unexpired) revocation tombstone, from frozen state. */
|
|
51
|
+
export function revokedIntentIds(
|
|
52
|
+
entities: ReadonlyMap<string, { type: string; metadata?: ReadonlyMap<string, unknown> | Record<string, unknown> }>,
|
|
53
|
+
tick: Tick,
|
|
54
|
+
): Set<string> {
|
|
55
|
+
const out = new Set<string>()
|
|
56
|
+
for( const [ , e ] of entities ){
|
|
57
|
+
if( e.type !== REVOCATION_TYPE ) continue
|
|
58
|
+
const m = ( e.metadata ?? {} ) as Record<string, unknown>
|
|
59
|
+
const intentId = typeof m['intentId'] === 'string' ? m['intentId'] as string : undefined
|
|
60
|
+
const expiresAt = typeof m['expiresAt'] === 'number' ? m['expiresAt'] as number : 0
|
|
61
|
+
if( intentId && tick < expiresAt ) out.add( intentId )
|
|
62
|
+
}
|
|
63
|
+
return out
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Ids of expired tombstones to sweep (TTL reap for intents that vanished otherwise). */
|
|
67
|
+
export function staleRevocationIds(
|
|
68
|
+
entities: ReadonlyMap<string, { type: string; metadata?: ReadonlyMap<string, unknown> | Record<string, unknown> }>,
|
|
69
|
+
tick: Tick,
|
|
70
|
+
): string[] {
|
|
71
|
+
const stale: string[] = []
|
|
72
|
+
for( const [ id, e ] of entities ){
|
|
73
|
+
if( e.type !== REVOCATION_TYPE ) continue
|
|
74
|
+
const m = ( e.metadata ?? {} ) as Record<string, unknown>
|
|
75
|
+
const expiresAt = typeof m['expiresAt'] === 'number' ? m['expiresAt'] as number : 0
|
|
76
|
+
if( tick >= expiresAt ) stale.push( id )
|
|
77
|
+
}
|
|
78
|
+
return stale
|
|
79
|
+
}
|
|
@@ -167,7 +167,7 @@ export class SchemaRepertoire {
|
|
|
167
167
|
const out: EntityInput[] = []
|
|
168
168
|
for( const id of this._learned ){
|
|
169
169
|
const s = this._templates.get( id )
|
|
170
|
-
if( s && s.kind === 'composite'
|
|
170
|
+
if( s && s.kind === 'composite') out.push( schemaEntity( s ) )
|
|
171
171
|
}
|
|
172
172
|
return out
|
|
173
173
|
}
|
|
@@ -242,7 +242,7 @@ function readSchema( m: Record<string, unknown> | undefined ): MotorSchema | und
|
|
|
242
242
|
const meta = m ?? {}
|
|
243
243
|
const id = typeof meta['id'] === 'string' ? meta['id'] as string : undefined
|
|
244
244
|
const kind = meta['kind']
|
|
245
|
-
if( !id || ( kind !== 'composite' && kind !== 'primitive'
|
|
245
|
+
if( !id || ( kind !== 'composite' && kind !== 'primitive') ) return undefined
|
|
246
246
|
return {
|
|
247
247
|
id,
|
|
248
248
|
kind,
|
|
@@ -7,13 +7,18 @@
|
|
|
7
7
|
// learned, and what it fears. This is the basal-ganglia Go/NoGo arithmetic,
|
|
8
8
|
// kept pure so it is trivially testable and replay-deterministic.
|
|
9
9
|
//
|
|
10
|
-
// activation = goalRelevance
|
|
10
|
+
// activation = goalRelevance
|
|
11
|
+
// + expectedReward
|
|
12
|
+
// + novelty
|
|
13
|
+
// + driveUrgency
|
|
11
14
|
// + habitStrength·W (additive habit bonus)
|
|
12
15
|
// + planBias·W (top-down prior)
|
|
13
|
-
// − cost
|
|
16
|
+
// − cost
|
|
17
|
+
// − inhibition
|
|
18
|
+
// − risk
|
|
14
19
|
//
|
|
15
20
|
// The habit term is additive (per design decision): an overlearned schema wins
|
|
16
|
-
// cheaply AND lowers its own deliberation threshold (see selector.ts), which is
|
|
21
|
+
// cheaply AND lowers its own deliberation threshold (see action.selector.ts), which is
|
|
17
22
|
// how the instrumental→habitual gradient cashes out as falling LLM spend.
|
|
18
23
|
// ─────────────────────────────────────────────────────────────
|
|
19
24
|
|
|
@@ -77,22 +82,29 @@ export const DEFAULT_TEMPERATURE = 0.15
|
|
|
77
82
|
*/
|
|
78
83
|
export function collectGoalTargets( state: ReadonlySimulationState ): Map<string, number> {
|
|
79
84
|
const targets = new Map<string, number>()
|
|
85
|
+
|
|
80
86
|
for( const e of state.entities.values() ){
|
|
81
|
-
if( e.type !== 'goal'
|
|
87
|
+
if( e.type !== 'goal') continue
|
|
88
|
+
|
|
82
89
|
const m = e.metadata as Record<string, unknown> | undefined
|
|
83
90
|
const status = typeof m?.['status'] === 'string' ? m['status'] : undefined
|
|
84
|
-
|
|
91
|
+
|
|
92
|
+
if( status !== 'active' && status !== 'in_progress') continue
|
|
93
|
+
|
|
85
94
|
const priority = typeof m?.['priority'] === 'number' ? m['priority'] as number : 0
|
|
86
95
|
const link = ( id: unknown ): void => {
|
|
87
96
|
if( typeof id !== 'string' || !id ) return
|
|
88
97
|
targets.set( id, Math.max( targets.get( id ) ?? 0, priority ) )
|
|
89
98
|
}
|
|
99
|
+
|
|
90
100
|
link( m?.['targetEntityId'] )
|
|
91
101
|
link( m?.['requestingEntityId'] )
|
|
102
|
+
|
|
92
103
|
if( Array.isArray( m?.['tags'] ) )
|
|
93
104
|
for( const t of m['tags'] as unknown[] )
|
|
94
|
-
if( typeof t === 'string' && t.startsWith(
|
|
105
|
+
if( typeof t === 'string' && t.startsWith('keid:') ) link( t.slice( 5 ) )
|
|
95
106
|
}
|
|
107
|
+
|
|
96
108
|
return targets
|
|
97
109
|
}
|
|
98
110
|
|
|
@@ -100,18 +112,22 @@ export function collectGoalTargets( state: ReadonlySimulationState ): Map<string
|
|
|
100
112
|
export function goalRelevance( a: Affordance, bias: BiasContext ): number {
|
|
101
113
|
if( a.targetEntityId && bias.goalTargets.has( a.targetEntityId ) )
|
|
102
114
|
return bias.maxGoalPriority
|
|
115
|
+
|
|
103
116
|
return 0
|
|
104
117
|
}
|
|
105
118
|
|
|
106
119
|
/** Homeostatic urgency routed to the affordance by its schema tags. */
|
|
107
120
|
export function driveUrgency( a: Affordance, bias: BiasContext ): number {
|
|
108
121
|
const t = a.tags
|
|
109
|
-
if( t.includes(
|
|
122
|
+
if( t.includes('regulatory') || t.includes('self-care') || t.includes('rest') )
|
|
110
123
|
return Math.max( bias.drives.energy, bias.drives.sleep )
|
|
111
|
-
|
|
124
|
+
|
|
125
|
+
if( t.includes('social') )
|
|
112
126
|
return bias.drives.social
|
|
113
|
-
|
|
127
|
+
|
|
128
|
+
if( t.includes('self-protection') )
|
|
114
129
|
return Math.max( bias.drives.stress, bias.threat )
|
|
130
|
+
|
|
115
131
|
return 0
|
|
116
132
|
}
|
|
117
133
|
|
package/src/cognition/bus.ts
CHANGED
|
@@ -73,11 +73,11 @@ interface Subscription {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function topicMatches( pattern: string, topic: string ): boolean {
|
|
76
|
-
if( pattern === '*'
|
|
76
|
+
if( pattern === '*') return true // global workspace subscription
|
|
77
77
|
if( pattern === topic ) return true
|
|
78
78
|
if( pattern.endsWith('.*') ){
|
|
79
79
|
const prefix = pattern.slice( 0, -2 )
|
|
80
|
-
return topic === prefix || topic.startsWith( prefix + '.'
|
|
80
|
+
return topic === prefix || topic.startsWith( prefix + '.')
|
|
81
81
|
}
|
|
82
82
|
return false
|
|
83
83
|
}
|
|
@@ -70,7 +70,7 @@ export class CompletionInbox {
|
|
|
70
70
|
for( const { label, apply } of batch ){
|
|
71
71
|
try { apply() }
|
|
72
72
|
catch( err ){
|
|
73
|
-
logger.error(
|
|
73
|
+
logger.error(`[completion-inbox] "${label}" failed while landing at tick ${tick}:`, err )
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -21,11 +21,11 @@ export interface EngineConfigEntity {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export function buildEngineConfigEntities( config: WillConfig, executiveInterval: number ): EngineConfigEntity[] {
|
|
24
|
-
const selfBelonging = parseFloat( process.env.WILL_SELF_BELONGING ?? '0.35'
|
|
25
|
-
const boredomRate = parseFloat( process.env.WILL_BOREDOM_RATE ?? '0.005'
|
|
26
|
-
const curiosityFloor = parseFloat( process.env.WILL_CURIOSITY_FLOOR ?? '0.08'
|
|
27
|
-
const summaryInterval = parseInt( process.env.WILL_SUMMARY_INTERVAL ?? '10'
|
|
28
|
-
const summaryBufferSize = parseInt( process.env.WILL_SUMMARY_BUFFER_SIZE ?? '12'
|
|
24
|
+
const selfBelonging = parseFloat( process.env.WILL_SELF_BELONGING ?? '0.35')
|
|
25
|
+
const boredomRate = parseFloat( process.env.WILL_BOREDOM_RATE ?? '0.005')
|
|
26
|
+
const curiosityFloor = parseFloat( process.env.WILL_CURIOSITY_FLOOR ?? '0.08')
|
|
27
|
+
const summaryInterval = parseInt( process.env.WILL_SUMMARY_INTERVAL ?? '10')
|
|
28
|
+
const summaryBufferSize = parseInt( process.env.WILL_SUMMARY_BUFFER_SIZE ?? '12')
|
|
29
29
|
|
|
30
30
|
return [
|
|
31
31
|
// ── System metadata ──────────────────────────────────────────
|
|
@@ -84,7 +84,7 @@ export class DefaultEventLog implements EventLog {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
private async _writeBatch( batch: CognitiveEvent[] ): Promise<void> {
|
|
87
|
-
const lines = batch.map( e => JSON.stringify( e ) ).join(
|
|
87
|
+
const lines = batch.map( e => JSON.stringify( e ) ).join('\n') + '\n'
|
|
88
88
|
let existing = ''
|
|
89
89
|
|
|
90
90
|
try {
|
|
@@ -92,7 +92,7 @@ export class DefaultEventLog implements EventLog {
|
|
|
92
92
|
existing = await this._storage.read( this._path )
|
|
93
93
|
} catch { /* file may not exist yet */ }
|
|
94
94
|
|
|
95
|
-
await this._storage.ensureDir?.( this._path.replace( /\/[^/]+$/, ''
|
|
95
|
+
await this._storage.ensureDir?.( this._path.replace( /\/[^/]+$/, '') )
|
|
96
96
|
await this._storage.write( this._path, existing + lines )
|
|
97
97
|
}
|
|
98
98
|
}
|