@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
|
@@ -71,6 +71,21 @@ const DRIVE_TAGS = new Set([ 'energy', 'sleep', 'stress', 'survival', 'wellbeing
|
|
|
71
71
|
// conscientiousness-developable baseSwitchCost, #28). Recomputed fresh each tick from
|
|
72
72
|
// basePriority — never accumulates. This is what makes the focus mechanically "stick":
|
|
73
73
|
// the focused goal stays top for goal selection, the executive, and planning.
|
|
74
|
+
/**
|
|
75
|
+
* Schema ids and effector names that mean "the mind said something to someone".
|
|
76
|
+
*
|
|
77
|
+
* `reach-out` is the innate schema; `text`/`talk`/`gesture`/`broadcast` are the
|
|
78
|
+
* effectors it resolves to. Both spellings appear as an `action.outcome`'s
|
|
79
|
+
* `actionType` depending on which path emitted it, and only the second set was
|
|
80
|
+
* ever recognised here. Mirrors `COMM_SCHEMAS` in agency/execution.primitives.
|
|
81
|
+
*/
|
|
82
|
+
const COMMUNICATIVE_SCHEMAS = new Set([
|
|
83
|
+
'reach-out', 'reach_out', 'communicate', 'talk', 'text', 'broadcast', 'gesture',
|
|
84
|
+
])
|
|
85
|
+
|
|
86
|
+
/** Progress an action goal gains when the person it concerns actually answers. */
|
|
87
|
+
const ANSWER_PROGRESS_STEP = 0.12
|
|
88
|
+
|
|
74
89
|
const FOCUS_COMMITMENT_RAMP = 30 // ticks of focus to reach full commitment weight
|
|
75
90
|
const COMMITMENT_GAIN = 0.3 // scales switchCost × commitment × plan-sunk-cost
|
|
76
91
|
const MAX_COMMITMENT_BOOST = 0.2 // cap — a clearly higher-priority goal still wins
|
|
@@ -88,6 +103,10 @@ export interface GoalState {
|
|
|
88
103
|
activatedAt: Tick
|
|
89
104
|
deadline?: Tick
|
|
90
105
|
tags: string[]
|
|
106
|
+
/** Why this goal was abandoned, when it was. Set only on status 'abandoned'.
|
|
107
|
+
* The reason used to be pushed onto `tags`, which threw once the goal had
|
|
108
|
+
* been rehydrated from a deep-frozen state entity. */
|
|
109
|
+
abandonedReason?: string
|
|
91
110
|
/** Snapshot of memory.beliefs_total when this goal was activated.
|
|
92
111
|
* Used to compute epistemic progress: (currentBeliefs - baseline) / threshold. */
|
|
93
112
|
beliefsAtActivation: number
|
|
@@ -199,6 +218,7 @@ export class GoalManager implements SimulationEngine, CognitiveEngine {
|
|
|
199
218
|
'executive.facet.progress',
|
|
200
219
|
'plan.completed',
|
|
201
220
|
'action.outcome', // 4.1: advance action-type goals when matching outcomes fire
|
|
221
|
+
'social.responsiveness', // somebody answered — the only progress a message can make
|
|
202
222
|
]
|
|
203
223
|
}
|
|
204
224
|
publishes(): CognitiveEventSchema[] {
|
|
@@ -298,6 +318,13 @@ export class GoalManager implements SimulationEngine, CognitiveEngine {
|
|
|
298
318
|
this._nudgeActionGoals( p.domain, p.actionType, p.outcomeQuality )
|
|
299
319
|
break
|
|
300
320
|
}
|
|
321
|
+
// A communicative act only advances a goal once somebody answers it. The
|
|
322
|
+
// send itself is not progress — see _nudgeActionGoals.
|
|
323
|
+
case 'social.responsiveness': {
|
|
324
|
+
const p = e.payload as { keid: string; answered: boolean }
|
|
325
|
+
if( p.answered === true && p.keid ) this._nudgeAnsweredGoals( p.keid )
|
|
326
|
+
break
|
|
327
|
+
}
|
|
301
328
|
}
|
|
302
329
|
}
|
|
303
330
|
|
|
@@ -565,8 +592,11 @@ export class GoalManager implements SimulationEngine, CognitiveEngine {
|
|
|
565
592
|
const goal = this._goals.get( goalId )
|
|
566
593
|
if( goal && goal.status === 'active'){
|
|
567
594
|
goal.status = 'abandoned'
|
|
568
|
-
//
|
|
569
|
-
|
|
595
|
+
// On its own field, not pushed onto `tags`. A goal rehydrated from a state
|
|
596
|
+
// entity holds that entity's deep-frozen arrays by reference, so the push
|
|
597
|
+
// threw and the goal stayed active forever — still competing for salience,
|
|
598
|
+
// with the rest of the deferred-effects flush for that tick lost with it.
|
|
599
|
+
if( reason ) goal.abandonedReason = reason.slice( 0, 200 )
|
|
570
600
|
|
|
571
601
|
this._sessionLogger?.write({
|
|
572
602
|
type: 'goal.abandoned',
|
|
@@ -618,13 +648,18 @@ export class GoalManager implements SimulationEngine, CognitiveEngine {
|
|
|
618
648
|
progress: ( meta.progress as number ) ?? 0,
|
|
619
649
|
status,
|
|
620
650
|
parentGoalId: meta.parentGoalId as string | undefined,
|
|
621
|
-
|
|
651
|
+
// COPY, never adopt. `meta` belongs to a state entity, and the state
|
|
652
|
+
// manager deep-freezes those — adopting the array by reference gives the
|
|
653
|
+
// goal a frozen `tags`/`subGoals`, and the next push (abandonGoal, or
|
|
654
|
+
// addGoal appending to a parent) throws TypeError mid-tick.
|
|
655
|
+
subGoals: [ ...( ( meta.subGoals as string[] ) ?? [] ) ],
|
|
622
656
|
activatedAt: ( meta.activatedAt as Tick ) ?? tick,
|
|
623
657
|
deadline: meta.deadline as Tick | undefined,
|
|
624
|
-
tags: ( meta.tags
|
|
658
|
+
tags: [ ...( ( meta.tags as string[] ) ?? [] ) ],
|
|
625
659
|
beliefsAtActivation: ( meta.beliefsAtActivation as number ) ?? this._currentBeliefCount,
|
|
626
660
|
completionType: ( meta.completionType as GoalState['completionType'] ) ?? 'epistemic',
|
|
627
661
|
completionCondition: meta.completionCondition as string | undefined,
|
|
662
|
+
abandonedReason: meta.abandonedReason as string | undefined,
|
|
628
663
|
})
|
|
629
664
|
}
|
|
630
665
|
}
|
|
@@ -658,7 +693,12 @@ export class GoalManager implements SimulationEngine, CognitiveEngine {
|
|
|
658
693
|
.find( g => {
|
|
659
694
|
return g.tags.includes( mapping.tags[0]! )
|
|
660
695
|
&& g.tags.includes( mapping.tags[1]! )
|
|
661
|
-
|
|
696
|
+
// `pending` counts as existing. It did not, and a
|
|
697
|
+
// goal demoted for capacity therefore stopped
|
|
698
|
+
// blocking its own respawn — the drive minted a
|
|
699
|
+
// fresh copy every time its threshold was crossed.
|
|
700
|
+
// Measured: 92 identical copies of one goal.
|
|
701
|
+
&& ( g.status === 'active' || g.status === 'pending')
|
|
662
702
|
})
|
|
663
703
|
|
|
664
704
|
// Never spawn a goal that is *already satisfied* — it would complete on its
|
|
@@ -685,7 +725,9 @@ export class GoalManager implements SimulationEngine, CognitiveEngine {
|
|
|
685
725
|
// Dedup by the referent (keid: tag) when present, else by description.
|
|
686
726
|
const keidTag = tags.find( t => t.startsWith('keid:') )
|
|
687
727
|
const existing = Array.from( this._goals.values() ).find( g =>
|
|
688
|
-
|
|
728
|
+
// Same rule as the drive path: a waiting goal still exists.
|
|
729
|
+
( g.status === 'active' || g.status === 'pending')
|
|
730
|
+
&& ( keidTag ? g.tags.includes( keidTag ) : g.description === desc ) )
|
|
689
731
|
|
|
690
732
|
// Don't spawn a goal that's already satisfied (born-done guard — see _activateFromDrives).
|
|
691
733
|
if( !existing && !this._isConditionMet( cCond, state ) )
|
|
@@ -770,6 +812,32 @@ export class GoalManager implements SimulationEngine, CognitiveEngine {
|
|
|
770
812
|
return 0
|
|
771
813
|
}
|
|
772
814
|
|
|
815
|
+
/**
|
|
816
|
+
* Reconcile the active set to capacity — in BOTH directions.
|
|
817
|
+
*
|
|
818
|
+
* Demotion alone made `pending` a one-way door, and a mind fell through it.
|
|
819
|
+
* Nothing in this file promoted a goal back (the only other write of `'active'`
|
|
820
|
+
* is `pending_verification`'s, a different status), so a goal demoted for
|
|
821
|
+
* capacity was demoted for good. Worse, `pending` is excluded from every other
|
|
822
|
+
* mechanism that could have retired it: it is not in `getActiveGoals()`, not
|
|
823
|
+
* progress-updated, not reachable by the patience/grit sweep (which skips any
|
|
824
|
+
* status but `'active'`) — yet it IS re-persisted every tick and rehydrated on
|
|
825
|
+
* every restore. Inert and immortal at once.
|
|
826
|
+
*
|
|
827
|
+
* Measured on a live COO: 96 goal entities, of which **83 pending, 0 active**,
|
|
828
|
+
* and 92 of the 96 the same drive-spawned goal. `activeGoalCount` sat at 0, so
|
|
829
|
+
* `goalless_crisis` fired every 20 ticks forever while she carried 83 goals —
|
|
830
|
+
* and the `goal` term, the joint-largest weight in the affordance competition,
|
|
831
|
+
* contributed nothing to any choice she made.
|
|
832
|
+
*
|
|
833
|
+
* Promotion also restores GC reachability, which is the quieter half of the
|
|
834
|
+
* fix: an over-patient stale goal can only be abandoned while it is active.
|
|
835
|
+
*
|
|
836
|
+
* `activatedAt` is deliberately NOT refreshed on promotion. Refreshing it would
|
|
837
|
+
* let a goal cycle demote→promote and reset its own patience each time, making
|
|
838
|
+
* it unretirable — the immortality this fix exists to end, reintroduced by the
|
|
839
|
+
* back door. A goal's age is when it was taken up, not when it last got a slot.
|
|
840
|
+
*/
|
|
773
841
|
private _resolveConflicts(): void {
|
|
774
842
|
const active = this.getActiveGoals()
|
|
775
843
|
|
|
@@ -778,6 +846,21 @@ export class GoalManager implements SimulationEngine, CognitiveEngine {
|
|
|
778
846
|
const lowest = active.pop()
|
|
779
847
|
if( lowest ) lowest.status = 'pending'
|
|
780
848
|
}
|
|
849
|
+
|
|
850
|
+
// ...and take the best waiting goals back up when there is room. Only ever
|
|
851
|
+
// reached when UNDER capacity, so this cannot undo the demotion above:
|
|
852
|
+
// the loop leaves the set at exactly capacity, and this one starts below it.
|
|
853
|
+
if( active.length >= this._maxActiveGoals ) return
|
|
854
|
+
|
|
855
|
+
const waiting = Array.from( this._goals.values() )
|
|
856
|
+
.filter( g => g.status === 'pending')
|
|
857
|
+
.sort( ( a, b ) => b.priority - a.priority )
|
|
858
|
+
|
|
859
|
+
for( const goal of waiting ){
|
|
860
|
+
if( active.length >= this._maxActiveGoals ) break
|
|
861
|
+
goal.status = 'active'
|
|
862
|
+
active.push( goal )
|
|
863
|
+
}
|
|
781
864
|
}
|
|
782
865
|
|
|
783
866
|
// ── Internal: progress ───────────────────────────────────
|
|
@@ -852,11 +935,26 @@ export class GoalManager implements SimulationEngine, CognitiveEngine {
|
|
|
852
935
|
const dLow = domain.toLowerCase()
|
|
853
936
|
const aLow = actionType.toLowerCase()
|
|
854
937
|
|
|
855
|
-
//
|
|
856
|
-
//
|
|
857
|
-
//
|
|
858
|
-
|
|
859
|
-
|
|
938
|
+
// A communicative act makes NO progress by being sent.
|
|
939
|
+
//
|
|
940
|
+
// This is the whole shape of the repetition failure, seen from the goal side.
|
|
941
|
+
// `action.outcome` for a message fires the moment the outbox accepts it, with
|
|
942
|
+
// `outcomeQuality` describing the delivery — so crediting it here would have a
|
|
943
|
+
// goal like "get a clear answer to one operational question" complete itself
|
|
944
|
+
// after nine unanswered messages, and the mind would be right to keep sending
|
|
945
|
+
// because sending was visibly working.
|
|
946
|
+
//
|
|
947
|
+
// The answer is progress. It arrives later, through `social.responsiveness`,
|
|
948
|
+
// and lands in _nudgeAnsweredGoals.
|
|
949
|
+
//
|
|
950
|
+
// (Before this the question was moot in the worst way: `actionType` for an
|
|
951
|
+
// outreach is the SCHEMA id, `reach-out`, and the old test looked only for
|
|
952
|
+
// 'talk'/'text', so no communicative act ever reached a goal at all. Measured
|
|
953
|
+
// on a live Will: 8 goals, 28 reach-outs, and `lastActionAttemptTick` unset on
|
|
954
|
+
// every single goal. The bridge was not miscalibrated, it was disconnected —
|
|
955
|
+
// which is why fixing the match alone would have turned a silent failure into
|
|
956
|
+
// a loud one.)
|
|
957
|
+
if( COMMUNICATIVE_SCHEMAS.has( aLow ) || dLow === 'communication') return
|
|
860
958
|
|
|
861
959
|
for( const goal of this._goals.values() ){
|
|
862
960
|
if( goal.status !== 'active' && goal.status !== 'blocked') continue
|
|
@@ -868,9 +966,7 @@ export class GoalManager implements SimulationEngine, CognitiveEngine {
|
|
|
868
966
|
|| t === aLow
|
|
869
967
|
|| dLow.includes( t ) || t.includes( dLow )
|
|
870
968
|
|| aLow.includes( t ) || t.includes( aLow )
|
|
871
|
-
})
|
|
872
|
-
t === 'communication' || t === 'reply' || t === 'conversation'
|
|
873
|
-
) )
|
|
969
|
+
})
|
|
874
970
|
|
|
875
971
|
if( hasMatch ){
|
|
876
972
|
goal.progress = Math.min( 1, goal.progress + outcomeQuality * 0.12 )
|
|
@@ -880,6 +976,33 @@ export class GoalManager implements SimulationEngine, CognitiveEngine {
|
|
|
880
976
|
}
|
|
881
977
|
}
|
|
882
978
|
|
|
979
|
+
/**
|
|
980
|
+
* Somebody answered. Advance the action goals that were about reaching them.
|
|
981
|
+
*
|
|
982
|
+
* Linked the way every other goal→person link in the system is linked: the
|
|
983
|
+
* `keid:<id>` tag (selection.scoring's `collectGoalTargets` reads the same one
|
|
984
|
+
* to lift a reach-out's goal relevance) or `requestingEntityId`, set when a
|
|
985
|
+
* conversation escalation created the goal. Nothing here guesses from wording.
|
|
986
|
+
*
|
|
987
|
+
* Unmatched by design: a goal with no link to this person gets nothing, even if
|
|
988
|
+
* it is tagged 'communication'. Being answered by one person is not progress on
|
|
989
|
+
* wanting to talk to another.
|
|
990
|
+
*/
|
|
991
|
+
private _nudgeAnsweredGoals( keid: string ): void {
|
|
992
|
+
const tag = `keid:${ keid }`.toLowerCase()
|
|
993
|
+
|
|
994
|
+
for( const goal of this._goals.values() ){
|
|
995
|
+
if( goal.status !== 'active' && goal.status !== 'blocked') continue
|
|
996
|
+
if( goal.completionType !== 'action') continue
|
|
997
|
+
if( goal.requestingEntityId !== keid
|
|
998
|
+
&& !goal.tags.some( t => t.toLowerCase() === tag ) ) continue
|
|
999
|
+
|
|
1000
|
+
goal.progress = Math.min( 1, goal.progress + ANSWER_PROGRESS_STEP )
|
|
1001
|
+
goal.lastActionAttemptTick = this._currentTick
|
|
1002
|
+
goal.lastActionType = 'answered'
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
|
|
883
1006
|
/** True when a metric completionCondition (e.g. "emotion.boredom < 40") is already met. */
|
|
884
1007
|
private _isConditionMet( condition: string | undefined, state: ReadonlySimulationState ): boolean {
|
|
885
1008
|
if( !condition ) return false
|
|
@@ -994,9 +1117,14 @@ export class GoalManager implements SimulationEngine, CognitiveEngine {
|
|
|
994
1117
|
progress: goal.progress,
|
|
995
1118
|
status: goal.status,
|
|
996
1119
|
parentGoalId: goal.parentGoalId,
|
|
997
|
-
|
|
1120
|
+
// COPY on the way out too. The state manager deep-freezes what it
|
|
1121
|
+
// stores, so handing it these arrays by reference freezes the
|
|
1122
|
+
// manager's OWN copies — a goal created this session, never
|
|
1123
|
+
// rehydrated, still ends up with an unpushable `tags`.
|
|
1124
|
+
subGoals: [ ...goal.subGoals ],
|
|
998
1125
|
deadline: goal.deadline,
|
|
999
|
-
tags: goal.tags,
|
|
1126
|
+
tags: [ ...goal.tags ],
|
|
1127
|
+
abandonedReason: goal.abandonedReason,
|
|
1000
1128
|
beliefsAtActivation: goal.beliefsAtActivation,
|
|
1001
1129
|
completionType: goal.completionType,
|
|
1002
1130
|
completionCondition: goal.completionCondition,
|