@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.
Files changed (142) hide show
  1. package/README.md +15 -11
  2. package/dist/index.d.ts +188 -141
  3. package/dist/index.js +6985 -3337
  4. package/dist/index.js.map +1 -1
  5. package/dist/surface/channels/discord.d.ts +177 -0
  6. package/dist/surface/channels/discord.js +394 -0
  7. package/dist/surface/channels/discord.js.map +1 -0
  8. package/dist/{channels → surface/channels}/whatsapp.d.ts +2 -2
  9. package/dist/{channels → surface/channels}/whatsapp.js +11 -5
  10. package/dist/surface/channels/whatsapp.js.map +1 -0
  11. package/dist/{cli.js → surface/cli.js} +5382 -1573
  12. package/dist/surface/cli.js.map +1 -0
  13. package/dist/{mcp → surface/mcp}/effectors.d.ts +1 -1
  14. package/dist/{mcp → surface/mcp}/effectors.js +10 -4
  15. package/dist/surface/mcp/effectors.js.map +1 -0
  16. package/dist/{will-cS6k4uiJ.d.ts → will-evj9_vrd.d.ts} +6658 -5078
  17. package/package.json +11 -12
  18. package/src/cognition/agency/consequence.ts +356 -1
  19. package/src/cognition/agency/conversation.aim.ts +292 -0
  20. package/src/cognition/agency/engines/action.selector.ts +142 -5
  21. package/src/cognition/agency/engines/affordance.synthesizer.ts +200 -7
  22. package/src/cognition/agency/engines/deliberation.engine.ts +76 -3
  23. package/src/cognition/agency/engines/motor.schema.executor.ts +509 -32
  24. package/src/cognition/agency/engines/reafference.engine.ts +160 -4
  25. package/src/cognition/agency/execution.primitives.ts +17 -4
  26. package/src/cognition/agency/proactive.communicator.ts +19 -3
  27. package/src/cognition/agency/reconcile.learning.ts +5 -4
  28. package/src/cognition/agency/restart.ts +66 -0
  29. package/src/cognition/agency/schemas/innate.ts +96 -1
  30. package/src/cognition/agency/schemas/repertoire.ts +19 -1
  31. package/src/cognition/agency/selection.scoring.ts +49 -0
  32. package/src/cognition/agency/settlement.ts +203 -0
  33. package/src/cognition/agency/types.ts +73 -1
  34. package/src/cognition/cache/composition.ts +232 -0
  35. package/src/cognition/cache/deliberation.cache.ts +219 -0
  36. package/src/cognition/cache/fingerprint.ts +120 -0
  37. package/src/cognition/cache/types.ts +105 -0
  38. package/src/cognition/config.mirror.entities.ts +108 -1
  39. package/src/cognition/event.schemas.ts +22 -8
  40. package/src/cognition/faculties/affective.blender.ts +21 -4
  41. package/src/cognition/faculties/autobiographical.narrator.ts +5 -10
  42. package/src/cognition/faculties/circadian.oscillator.ts +36 -7
  43. package/src/cognition/faculties/episodic.consolidator.ts +59 -3
  44. package/src/cognition/faculties/executive.engine/action.record.ts +129 -0
  45. package/src/cognition/faculties/executive.engine/commands.ts +189 -14
  46. package/src/cognition/faculties/executive.engine/context.ts +106 -46
  47. package/src/cognition/faculties/executive.engine/deliberate.reasoning.ts +1 -1
  48. package/src/cognition/faculties/executive.engine/engine.ts +714 -136
  49. package/src/cognition/faculties/executive.engine/escalation.buffer.ts +230 -45
  50. package/src/cognition/faculties/executive.engine/facet.supervisor.ts +320 -65
  51. package/src/cognition/faculties/executive.engine/facet.ts +81 -26
  52. package/src/cognition/faculties/executive.engine/gating.ts +14 -14
  53. package/src/cognition/faculties/executive.engine/parser.ts +120 -38
  54. package/src/cognition/faculties/executive.engine/prompt.factory.ts +331 -38
  55. package/src/cognition/faculties/executive.engine/types.ts +84 -12
  56. package/src/cognition/faculties/exteroception.ts +99 -98
  57. package/src/cognition/faculties/goal.manager.ts +144 -16
  58. package/src/cognition/faculties/known.entity.tracker.ts +287 -29
  59. package/src/cognition/faculties/moral.evaluator.ts +8 -3
  60. package/src/cognition/faculties/persona.consolidator.ts +141 -0
  61. package/src/cognition/faculties/planning.engine/engine.ts +4 -4
  62. package/src/cognition/faculties/planning.engine/plan.frontier.ts +1 -1
  63. package/src/cognition/faculties/reputation.tracker.ts +66 -2
  64. package/src/cognition/faculties/self.model.updater.ts +19 -12
  65. package/src/cognition/faculties/semantic.engine/integrator.ts +1 -1
  66. package/src/cognition/faculties/social.perception.ts +47 -3
  67. package/src/cognition/faculties/threat.evaluator.ts +7 -0
  68. package/src/cognition/faculties/working.memory.ts +16 -21
  69. package/src/cognition/identity.entity.ts +205 -0
  70. package/src/cognition/index.ts +7 -0
  71. package/src/cognition/instruction.handler.ts +1 -1
  72. package/src/cognition/memory/vector.adapter.ts +12 -3
  73. package/src/cognition/memory/vector.embedder.ts +45 -4
  74. package/src/cognition/percept.entity.ts +122 -0
  75. package/src/cognition/persona.prior.ts +6 -0
  76. package/src/cognition/sense.boundary.ts +176 -0
  77. package/src/cognition/senses/audition.engine/engine.ts +492 -53
  78. package/src/cognition/senses/base.sense.engine.ts +105 -7
  79. package/src/cognition/senses/index.ts +83 -13
  80. package/src/cognition/senses/provenance.ts +128 -0
  81. package/src/cognition/senses/somatosensation.engine.ts +117 -9
  82. package/src/cognition/social.identity.ts +296 -0
  83. package/src/cognition/utilities/token.tracker.ts +94 -10
  84. package/src/core/orchestrator.ts +51 -0
  85. package/src/index.ts +39 -5
  86. package/src/llm/gate.ts +48 -0
  87. package/src/llm/index.ts +127 -33
  88. package/src/llm/routing.ts +6 -0
  89. package/src/llm/summarizer.ts +1 -1
  90. package/src/llm/wire.contracts.ts +57 -0
  91. package/src/pma/index.ts +68 -54
  92. package/src/stem/assembly.audit.ts +1 -0
  93. package/src/stem/guards/identity.coherence.ts +1 -1
  94. package/src/stem/index.ts +171 -23
  95. package/src/stem/mind.ts +198 -57
  96. package/src/stem/policy/arbiter.ts +10 -0
  97. package/src/stem/profiles/built-in.ts +7 -0
  98. package/src/{profiles → stem/profiles}/companion.ts +1 -1
  99. package/src/{profiles → stem/profiles}/company-brain.ts +1 -1
  100. package/src/{profiles → stem/profiles}/customer-service.ts +1 -1
  101. package/src/{profiles → stem/profiles}/game-npc.ts +1 -1
  102. package/src/{profiles → stem/profiles}/index.ts +1 -1
  103. package/src/{profiles → stem/profiles}/smart-home.ts +1 -1
  104. package/src/stem/tracts/effector/escalation.lifecycle.ts +239 -0
  105. package/src/stem/tracts/effector/policy.enforcement.ts +261 -0
  106. package/src/stem/tracts/effector/types.ts +110 -0
  107. package/src/stem/tracts/effector.controller.ts +112 -401
  108. package/src/stem/tracts/outbox.controller.ts +30 -17
  109. package/src/stem/tracts/outbox.writer.ts +40 -2
  110. package/src/stem/tracts/sensory.controller.ts +6 -6
  111. package/src/stem/tracts/session.logger.ts +6 -1
  112. package/src/stem/tracts/transport/types.ts +20 -1
  113. package/src/stem/tracts/transport.controller.ts +33 -9
  114. package/src/surface/channels/discord.ts +609 -0
  115. package/src/{channels → surface/channels}/roster.ts +1 -1
  116. package/src/surface/channels/types.ts +136 -0
  117. package/src/{channels → surface/channels}/whatsapp.ts +22 -10
  118. package/src/{cli.ts → surface/cli.ts} +14 -9
  119. package/src/{host → surface/host}/boot.ts +3 -3
  120. package/src/{host → surface/host}/utterances.ts +2 -2
  121. package/src/{mcp → surface/mcp}/effectors.ts +19 -6
  122. package/src/{mcp → surface/mcp}/server.ts +19 -5
  123. package/src/{sdk → surface/sdk}/will.ts +194 -33
  124. package/src/{serve → surface/serve}/server.ts +11 -4
  125. package/src/types.ts +24 -3
  126. package/dist/channels/discord.d.ts +0 -69
  127. package/dist/channels/discord.js +0 -193
  128. package/dist/channels/discord.js.map +0 -1
  129. package/dist/channels/whatsapp.js.map +0 -1
  130. package/dist/cli.js.map +0 -1
  131. package/dist/mcp/effectors.js.map +0 -1
  132. package/src/channels/discord.ts +0 -214
  133. package/src/channels/types.ts +0 -46
  134. package/src/cognition/faculties/executive.engine/messages.ts +0 -102
  135. package/src/extensions/livestream.ext.ts +0 -570
  136. package/src/extensions/time.ext.ts +0 -339
  137. package/src/profiles/built-in.ts +0 -7
  138. package/src/runners/coherence.runner.ts +0 -49
  139. package/src/runners/outreach.runner.ts +0 -155
  140. package/src/runners/social.runner.ts +0 -179
  141. package/src/runners/thin-shim.runner.ts +0 -205
  142. /package/dist/{cli.d.ts → surface/cli.d.ts} +0 -0
@@ -0,0 +1,110 @@
1
+ // ─────────────────────────────────────────────────────────────
2
+ // src/stem/tracts/effector/types.ts — the efference crossing, shared shapes
3
+ // ─────────────────────────────────────────────────────────────
4
+ //
5
+ // SIGNAL_BOUNDARY P1a. `effector.controller.ts` had seven jobs; these are the
6
+ // shapes its three real seams pass between them:
7
+ //
8
+ // policy enforcement arbiter · verdicts · refusals
9
+ // escalation lifecycle hold · resolve · expire
10
+ // agency↔host buffer · drain · ack (the controller itself)
11
+ //
12
+ // The seams were verified before the cut, not assumed: no method touched both
13
+ // the policy fields (`_arbiter`, `_pendingRefusals`) and the escalation fields
14
+ // (`_newEscalations`, `_activeEscalations`, `_pendingResolutions`) except
15
+ // `_applyVerdict`, which is the ROUTER — deny goes one way, escalate the other.
16
+ // A router across a seam is the seam working, not a tangle.
17
+
18
+ import type { DenialFinality, PolicyCounterfactual } from '#stem/policy/arbiter'
19
+ import type { WillInstance } from '#stem/index'
20
+
21
+ /** A denial awaiting application as a refusal ack at the next tick boundary. */
22
+ export interface PendingRefusal {
23
+ intentId: string
24
+ schema: string
25
+ reasonCode: string
26
+ finality: DenialFinality
27
+ /** ENVELOPE_NARROWING P0 — what WOULD have been allowed, carried through to
28
+ * the outcome the mind learns from. Absent on refusals that have no bound to
29
+ * report (a flat ban, a fault, an unanswered escalation). */
30
+ counterfactual?: PolicyCounterfactual
31
+ }
32
+
33
+ /** An escalation the Will has raised: the intent is held, the ask is voiced once,
34
+ * and the original payload is kept so an approval can dispatch it to the world. */
35
+ export interface Escalation {
36
+ intentId: string
37
+ schema: string
38
+ reasonCode: string
39
+ /** The withheld invocation payload — replayed to the host on approval. */
40
+ payload: Record<string, unknown>
41
+ expiresAt: number
42
+ }
43
+
44
+ /** A host's answer to an escalation, applied at the next tick boundary. */
45
+ export interface PendingResolution {
46
+ intentId: string
47
+ approved: boolean
48
+ }
49
+
50
+ /** What a host says came back. */
51
+ export interface EffectorAck {
52
+ success: boolean
53
+ /**
54
+ * How the act WENT. The fate of the attempt — landed, refused, failed — which
55
+ * is what the mind learns competence from. Not what the act revealed.
56
+ */
57
+ description: string
58
+ /**
59
+ * What the act REVEALED: new information about the world, as distinct from how
60
+ * the act went (SIGNAL_BOUNDARY P2).
61
+ *
62
+ * Present ⇒ this ack is ALSO afference. It arrives as a reafferent percept
63
+ * carrying `sourceIntentId`, so the mind perceives it, remembers it and can
64
+ * recall it — rather than only learning from it. `lookup`, `list_warnings`,
65
+ * `snapshot` carry one; `kick`, `warn`, a refusal do not.
66
+ *
67
+ * WHY THE HOST DECIDES, AND WHY THIS IS NOT INFERRED FROM `description`.
68
+ * An ack is not *always* new world information, and nothing inside the mind
69
+ * can tell "the kick landed" from "there are 47 people here" — both are
70
+ * strings that came back from an act. Only the host knows which it wrote.
71
+ * Same contract as `provenance`: asserted at the boundary, never guessed.
72
+ *
73
+ * Forcing every ack through the sense door would be the over-unification this
74
+ * epoch warns about — a mind perceiving "the kick landed" as a fresh event in
75
+ * the world, every time it kicks.
76
+ *
77
+ * ANY SHAPE, AND CARRIED WHOLE. A host with a member record, a channel
78
+ * snapshot, a list of warnings sends the record — not a paragraph about it.
79
+ * Making a host flatten its own data to prose is a quieter kind of cutting:
80
+ * it destroys the structure rather than the tail. Nothing here is truncated
81
+ * at any point on the way in; what the host sent is what the mind gets.
82
+ */
83
+ observation?: unknown
84
+ metrics?: Record<string, number>
85
+ /** POLICY_REAFFERENCE P2 — set when the ack is a policy refusal, so the
86
+ * ReafferenceEngine routes it to availability rather than competence. */
87
+ refused?: boolean
88
+ finality?: DenialFinality
89
+ /** ENVELOPE_NARROWING P0 — the bound that was exceeded, if the arbiter said. */
90
+ counterfactual?: PolicyCounterfactual
91
+ }
92
+
93
+ /**
94
+ * The translation seam, as the other two see it.
95
+ *
96
+ * Both collaborators need to put an invocation on the wire, and policy also
97
+ * needs to reconcile a refusal as an ack. Injected as plain functions rather
98
+ * than a controller reference: it keeps the dependency one-way at the type
99
+ * level, and it is what lets the controller wire a cycle (policy raises an
100
+ * escalation, an escalation queues a refusal) without either class importing
101
+ * the other.
102
+ */
103
+ export interface EffectorOps {
104
+ buffer( instance: WillInstance, payload: Record<string, unknown> ): void
105
+ confirmExecution( instance: WillInstance, invocationId: string, result: EffectorAck ): void
106
+ }
107
+
108
+ /** How long an escalated intent is held awaiting a resolution before it degrades
109
+ * to a refusal — 2× the host-ack timeout, so a human has real time to answer. */
110
+ export const ESCALATION_TTL_TICKS = 30