@mindot/will 0.8.0 → 0.9.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/dist/channels/discord.d.ts +67 -6
- package/dist/channels/discord.js +112 -6
- package/dist/channels/discord.js.map +1 -1
- package/dist/channels/whatsapp.d.ts +1 -1
- package/dist/channels/whatsapp.js +4 -1
- package/dist/channels/whatsapp.js.map +1 -1
- package/dist/cli.js +3174 -867
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3236 -1042
- package/dist/index.js.map +1 -1
- package/dist/mcp/effectors.d.ts +1 -1
- package/dist/{will-cS6k4uiJ.d.ts → will-DbDj_TEH.d.ts} +752 -17
- package/package.json +1 -1
- package/src/channels/discord.ts +189 -11
- package/src/channels/types.ts +90 -0
- package/src/channels/whatsapp.ts +13 -4
- package/src/cli.ts +9 -4
- package/src/cognition/agency/consequence.ts +122 -1
- package/src/cognition/agency/conversation.aim.ts +260 -0
- package/src/cognition/agency/engines/action.selector.ts +83 -2
- package/src/cognition/agency/engines/affordance.synthesizer.ts +90 -1
- package/src/cognition/agency/engines/motor.schema.executor.ts +152 -10
- package/src/cognition/agency/engines/reafference.engine.ts +117 -0
- package/src/cognition/agency/proactive.communicator.ts +19 -3
- package/src/cognition/agency/restart.ts +66 -0
- package/src/cognition/agency/selection.scoring.ts +33 -0
- package/src/cognition/agency/types.ts +35 -0
- 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 -0
- package/src/cognition/event.schemas.ts +22 -0
- package/src/cognition/faculties/autobiographical.narrator.ts +5 -10
- package/src/cognition/faculties/episodic.consolidator.ts +59 -3
- package/src/cognition/faculties/executive.engine/commands.ts +189 -14
- package/src/cognition/faculties/executive.engine/context.ts +67 -13
- package/src/cognition/faculties/executive.engine/deliberate.reasoning.ts +1 -1
- package/src/cognition/faculties/executive.engine/engine.ts +552 -131
- package/src/cognition/faculties/executive.engine/escalation.buffer.ts +162 -44
- package/src/cognition/faculties/executive.engine/facet.supervisor.ts +310 -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 +21 -1
- package/src/cognition/faculties/executive.engine/prompt.factory.ts +167 -19
- package/src/cognition/faculties/executive.engine/types.ts +69 -0
- package/src/cognition/faculties/goal.manager.ts +94 -14
- package/src/cognition/faculties/known.entity.tracker.ts +267 -28
- package/src/cognition/faculties/moral.evaluator.ts +8 -3
- package/src/cognition/faculties/persona.consolidator.ts +141 -0
- package/src/cognition/faculties/reputation.tracker.ts +66 -2
- package/src/cognition/faculties/self.model.updater.ts +19 -12
- 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 +10 -20
- package/src/cognition/identity.entity.ts +205 -0
- package/src/cognition/index.ts +7 -0
- package/src/cognition/memory/vector.adapter.ts +12 -3
- package/src/cognition/memory/vector.embedder.ts +45 -2
- package/src/cognition/persona.prior.ts +6 -0
- package/src/cognition/senses/audition.engine/engine.ts +404 -46
- package/src/cognition/senses/base.sense.engine.ts +1 -1
- package/src/cognition/senses/index.ts +12 -0
- package/src/cognition/social.identity.ts +273 -0
- package/src/cognition/utilities/token.tracker.ts +58 -5
- package/src/core/orchestrator.ts +38 -0
- package/src/llm/index.ts +25 -8
- package/src/llm/routing.ts +6 -0
- package/src/llm/summarizer.ts +1 -1
- package/src/llm/wire.contracts.ts +19 -0
- package/src/pma/index.ts +67 -53
- package/src/sdk/will.ts +39 -6
- package/src/stem/assembly.audit.ts +1 -0
- package/src/stem/guards/identity.coherence.ts +1 -1
- package/src/stem/index.ts +79 -2
- package/src/stem/mind.ts +172 -55
- package/src/stem/tracts/outbox.writer.ts +40 -2
- package/src/cognition/faculties/executive.engine/messages.ts +0 -102
|
@@ -9,6 +9,13 @@ import type { ExecutiveContext } from '#faculties/executive.engine/types'
|
|
|
9
9
|
import type { EpisodicConsolidator } from '#faculties/episodic.consolidator'
|
|
10
10
|
import type { SemanticIntegrator } from '#faculties/semantic.engine/integrator'
|
|
11
11
|
import { readEffectiveParams, summarizePersonaPrior } from '#cognition/persona.prior'
|
|
12
|
+
import { readIdentityName } from '#cognition/identity.entity'
|
|
13
|
+
import { readSpokenTurns } from '#agency/conversation.aim'
|
|
14
|
+
import { nameOf as referentName } from '#cognition/social.identity'
|
|
15
|
+
|
|
16
|
+
/** How many of the mind's own recent utterances it is shown. Enough to notice a
|
|
17
|
+
* repetition, few enough not to crowd out what is happening now. */
|
|
18
|
+
const SPOKEN_TURNS_SHOWN = 6
|
|
12
19
|
|
|
13
20
|
export interface ContextDependencies {
|
|
14
21
|
workingMemory: WorkingMemory | null
|
|
@@ -32,8 +39,10 @@ export async function buildExecutiveContext(
|
|
|
32
39
|
// Identity — read directly from the identity-self entity.
|
|
33
40
|
const identityEntity = state.entities.get('identity-self')
|
|
34
41
|
// name is the canonical persona name from WillConfig.name (e.g. "Aria", "Guard-1").
|
|
35
|
-
//
|
|
36
|
-
|
|
42
|
+
// '' when unknown — NEVER a default. This read used to end in `?? 'Will'`, which
|
|
43
|
+
// is how the container's name reached a tenant's own prompt. See
|
|
44
|
+
// cognition/identity.entity for what that cost.
|
|
45
|
+
const identityName = readIdentityName( state )
|
|
37
46
|
const identityPrompt = (identityEntity?.metadata?.prompt as string) ?? 'I am a self-aware mind.'
|
|
38
47
|
const identityValues = (identityEntity?.metadata?.values as string[]) ?? []
|
|
39
48
|
const identityTraits = (identityEntity?.metadata?.traits as Record<string, number>) ?? {}
|
|
@@ -275,6 +284,37 @@ export async function buildExecutiveContext(
|
|
|
275
284
|
recentActions.sort( ( a, b ) => b.tick - a.tick )
|
|
276
285
|
const recentActionsCapped = recentActions.slice( 0, 5 )
|
|
277
286
|
|
|
287
|
+
// Current best name for a person, from the known-entity roster.
|
|
288
|
+
const nameOf = ( keid: string ): string | undefined => {
|
|
289
|
+
for( const e of state.entities.values() ){
|
|
290
|
+
if( e.type !== 'known-entity') continue
|
|
291
|
+
const m = e.metadata ?? {}
|
|
292
|
+
if( m['keid'] !== keid ) continue
|
|
293
|
+
const n = m['name']
|
|
294
|
+
return typeof n === 'string' && n.trim() ? n : undefined
|
|
295
|
+
}
|
|
296
|
+
return undefined
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// What the mind has said to people lately, and who answered. Newest first,
|
|
300
|
+
// capped — this is a reminder, not a transcript; the conversation itself lives
|
|
301
|
+
// in memory and in "## In Conversation Now".
|
|
302
|
+
const spokenTurns: ExecutiveContext['spokenTurns'] = readSpokenTurns( state.entities )
|
|
303
|
+
.filter( t => !t.isAck )
|
|
304
|
+
.reverse()
|
|
305
|
+
.slice( 0, SPOKEN_TURNS_SHOWN )
|
|
306
|
+
.map( t => ({
|
|
307
|
+
// Roster first, the record's stored name second. A name is learned over
|
|
308
|
+
// time, so records written before the mind knew it keep the raw id — and
|
|
309
|
+
// the same person rendered as both `FKEM` and `discord:15255…` in one list,
|
|
310
|
+
// which reads as two people. The roster holds the current best name.
|
|
311
|
+
target: nameOf( t.targetEntityId ) ?? t.targetEntityName ?? t.targetEntityId,
|
|
312
|
+
preview: t.preview,
|
|
313
|
+
age: Math.max( 0, state.tick - t.tick ),
|
|
314
|
+
answered: t.answeredAt !== undefined,
|
|
315
|
+
...( t.answeredWith ? { answeredWith: t.answeredWith } : {} ),
|
|
316
|
+
}) )
|
|
317
|
+
|
|
278
318
|
// Active/known plans — read persisted `plan` entities so the executive has
|
|
279
319
|
// execution awareness: which plans exist per goal, their status + step
|
|
280
320
|
// progress, enabling it to target a specific plan by id when managing several. (P4)
|
|
@@ -328,6 +368,7 @@ export async function buildExecutiveContext(
|
|
|
328
368
|
beliefs,
|
|
329
369
|
beliefsOmitted,
|
|
330
370
|
recentActions: recentActionsCapped,
|
|
371
|
+
spokenTurns,
|
|
331
372
|
behavioralDisposition,
|
|
332
373
|
selfTuning,
|
|
333
374
|
knownEntities: extractKnownEntities( state ),
|
|
@@ -436,6 +477,25 @@ export function extractKnownEntities( state: ReadonlySimulationState ): Executiv
|
|
|
436
477
|
if( typeof m.name === 'string') a.name = m.name
|
|
437
478
|
if( m.kind === 'thing' || m.kind === 'sentient') a.kind = m.kind as 'thing' | 'sentient'
|
|
438
479
|
if( typeof m.reliability === 'number') a.reliability = m.reliability as number
|
|
480
|
+
|
|
481
|
+
// The routes, so choosing where to say something is a decision the mind
|
|
482
|
+
// makes rather than a fallback the plumbing makes for it.
|
|
483
|
+
if( Array.isArray( m.handles ) )
|
|
484
|
+
a.handles = ( m.handles as Array<{ keid?: string; kind?: string; lastAnsweredTick?: number }> )
|
|
485
|
+
.filter( h => typeof h?.keid === 'string')
|
|
486
|
+
.map( h => ({
|
|
487
|
+
keid: h.keid!,
|
|
488
|
+
kind: h.kind ?? 'unknown',
|
|
489
|
+
...( typeof h.lastAnsweredTick === 'number'
|
|
490
|
+
? { answeredAgo: Math.max( 0, state.tick - h.lastAnsweredTick ) } : {} ),
|
|
491
|
+
}) )
|
|
492
|
+
|
|
493
|
+
// An identity the mind has not settled. Carried as NAMES where it knows
|
|
494
|
+
// them, because a raw keid in a prompt is noise it cannot act on.
|
|
495
|
+
if( Array.isArray( m.suspectedSameAs ) )
|
|
496
|
+
a.mayBeSameAs = ( m.suspectedSameAs as string[] )
|
|
497
|
+
.map( k => referentName( state.entities, k ) )
|
|
498
|
+
.filter( ( n ): n is string => !!n )
|
|
439
499
|
a._recency = Math.max( a._recency, ( m.lastSeenTick as number ) ?? 0 )
|
|
440
500
|
}
|
|
441
501
|
else if( e.type === 'attachment.bond'){
|
|
@@ -473,17 +533,11 @@ function buildSemanticQuery(
|
|
|
473
533
|
const dominantEmotion = valence > 0.3 ? 'positive' : valence < -0.3 ? 'negative' : 'neutral'
|
|
474
534
|
if( dominantEmotion !== 'neutral') parts.push(`Feeling ${dominantEmotion}`)
|
|
475
535
|
|
|
476
|
-
//
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
if( state.tick - msgTick > 30 ) continue
|
|
482
|
-
if( entity.metadata?.processedByExecutive ) continue
|
|
483
|
-
const name = entity.metadata?.agentName as string | undefined
|
|
484
|
-
if( name && name !== 'unknown') senderNames.add( name )
|
|
485
|
-
}
|
|
486
|
-
if( senderNames.size > 0 ) parts.push(`Talking with: ${[ ...senderNames ].join(', ')}`)
|
|
536
|
+
// A "Talking with: …" hint used to be built here from `communication` entities.
|
|
537
|
+
// Nothing has ever written that type (#114), so the clause never fired. Removed
|
|
538
|
+
// rather than repointed: the inbound entity that now exists (`conversation.received`)
|
|
539
|
+
// is consumed within one tick, so it is not a dependable source for a recall hint —
|
|
540
|
+
// restoring this wants a durable interlocutor signal, which is its own decision.
|
|
487
541
|
|
|
488
542
|
// Recent percepts (top 3 by salience)
|
|
489
543
|
const percepts = extractPercepts( state ).slice( 0, 3 )
|
|
@@ -49,7 +49,7 @@ export async function proposeCandidates( params: ProposeParams ): Promise<Ideati
|
|
|
49
49
|
try {
|
|
50
50
|
const result = await params.director.call(
|
|
51
51
|
params.systemPrompt, params.ideationUserMessage, params.tick, params.proposeTemperature,
|
|
52
|
-
params.meta ?? { category: 'executive', attribute: 'master',
|
|
52
|
+
params.meta ?? { category: 'executive', attribute: 'master', process: 'ideation', function: '-' }
|
|
53
53
|
)
|
|
54
54
|
const candidates = parseIdeation( result.text ).candidates
|
|
55
55
|
return candidates.length > 0 ? candidates : undefined
|