@mindot/will 0.7.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/README.md +87 -22
- 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 +13733 -11057
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3729 -1199
- package/dist/index.js.map +1 -1
- package/dist/mcp/effectors.d.ts +1 -1
- package/dist/{will-DAW0l-lY.d.ts → will-DbDj_TEH.d.ts} +1214 -93
- 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 +85 -3
- 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 +129 -2
- package/src/cognition/agency/proactive.communicator.ts +19 -3
- package/src/cognition/agency/reconcile.learning.ts +16 -2
- package/src/cognition/agency/restart.ts +66 -0
- package/src/cognition/agency/schemas/repertoire.ts +12 -5
- 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 +109 -1
- 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 +686 -187
- 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 +89 -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 +169 -20
- 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 +11 -0
- package/src/cognition/memory/vector.adapter.ts +12 -3
- package/src/cognition/memory/vector.embedder.ts +54 -7
- 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 +246 -98
- package/src/core/orchestrator.ts +38 -0
- package/src/host/boot.ts +78 -22
- package/src/index.ts +35 -0
- package/src/llm/index.ts +415 -97
- package/src/llm/routing.ts +204 -0
- package/src/llm/summarizer.ts +5 -1
- package/src/llm/wire.contracts.ts +19 -0
- package/src/pma/index.ts +67 -53
- package/src/runners/thin-shim.runner.ts +18 -6
- package/src/sdk/will.ts +121 -22
- package/src/stem/assembly.audit.ts +1 -0
- package/src/stem/guards/identity.coherence.ts +17 -6
- package/src/stem/index.ts +82 -5
- package/src/stem/mind.ts +327 -79
- package/src/stem/policy/arbiter.ts +49 -14
- package/src/stem/policy/rule.table.ts +2 -2
- package/src/stem/tracts/effector.controller.ts +56 -9
- package/src/stem/tracts/outbox.writer.ts +40 -2
- package/src/cognition/faculties/executive.engine/messages.ts +0 -102
package/src/host/boot.ts
CHANGED
|
@@ -12,9 +12,11 @@
|
|
|
12
12
|
// WILL_NAME display name (default "Will")
|
|
13
13
|
// WILL_IDENTITY persona prompt (default a minimal self)
|
|
14
14
|
// WILL_TIER basic | standard | full (default standard)
|
|
15
|
-
// WILL_LLM mock |
|
|
16
|
-
//
|
|
17
|
-
//
|
|
15
|
+
// WILL_LLM mock | any provider name (default: auto — whichever
|
|
16
|
+
// provider's own key is set,
|
|
17
|
+
// else the zero-key mock)
|
|
18
|
+
// WILL_LLM_MODEL concrete model id (REQUIRED for a live mind —
|
|
19
|
+
// the engine has no default)
|
|
18
20
|
// WILL_TICK_MS ms per tick (default 1000)
|
|
19
21
|
// WILL_SEED deterministic seed (testing) (default unseeded/wall-time)
|
|
20
22
|
// WILL_PMA_PATH PMA artifact path (default ./.will/<name>.pma.json)
|
|
@@ -25,10 +27,10 @@
|
|
|
25
27
|
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs'
|
|
26
28
|
import { dirname, resolve } from 'node:path'
|
|
27
29
|
import { setLogger } from '#core/logger'
|
|
28
|
-
import { Will, type CreateWillOptions } from '#sdk/will'
|
|
30
|
+
import { Will, detectProvider, type CreateWillOptions } from '#sdk/will'
|
|
29
31
|
import type { PMASnapshot } from '#pma/index'
|
|
30
32
|
import { connectMcpEffectors, type McpToolsSource } from '#root/mcp/effectors'
|
|
31
|
-
import { anthropicWireHeaders, defaultBaseFor,
|
|
33
|
+
import { anthropicWireHeaders, defaultBaseFor, knownWireFor, providerKeyFromEnv, PROVIDER_KEY_ENV, type LLMProvider, type LLMWire } from '#llm/index'
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* Route every engine log line to stderr. For `will mcp`, stdout is the MCP
|
|
@@ -47,19 +49,51 @@ function slug( s: string ): string {
|
|
|
47
49
|
|
|
48
50
|
/** The LLM mode the hosts will boot with: an explicit WILL_LLM, else whichever
|
|
49
51
|
* provider's key is present, else the zero-key mock. */
|
|
50
|
-
export function resolveLlmMode(): 'mock' |
|
|
51
|
-
const explicit = process.env.WILL_LLM
|
|
52
|
-
if( explicit ) return explicit
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
export function resolveLlmMode(): 'mock' | LLMProvider {
|
|
53
|
+
const explicit = process.env.WILL_LLM
|
|
54
|
+
if( explicit ) return explicit as 'mock' | LLMProvider
|
|
55
|
+
// The SDK's own detection, not a copy of it. Boot used to know only
|
|
56
|
+
// anthropic/glm, so once the provider set widened, a Will booting live on
|
|
57
|
+
// (say) Kimi had its preflight silently skipped — the one check that exists
|
|
58
|
+
// to stop a mind that boots, perceives, and never speaks.
|
|
59
|
+
return detectProvider()
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
/** The key for a live mode — the provider-agnostic override first, then the
|
|
59
63
|
* provider's own env. */
|
|
60
|
-
function resolveLlmKey( mode:
|
|
61
|
-
return process.env.WILL_LLM_API_KEY
|
|
62
|
-
|
|
64
|
+
function resolveLlmKey( mode: LLMProvider ): string | undefined {
|
|
65
|
+
return process.env.WILL_LLM_API_KEY ?? providerKeyFromEnv( mode )
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The smallest real completion request, in a given wire's dialect.
|
|
70
|
+
*
|
|
71
|
+
* `null` means "this wire has no cheap ping here" — the caller raises the mind
|
|
72
|
+
* unchecked rather than inventing a request shape and reading its rejection as
|
|
73
|
+
* a broken provider.
|
|
74
|
+
*/
|
|
75
|
+
export function pingRequest(
|
|
76
|
+
wire: LLMWire, base: string, model: string, key: string, provider: LLMProvider,
|
|
77
|
+
): { url: string; headers: Record<string, string>; body: unknown } | null {
|
|
78
|
+
const messages = [ { role: 'user', content: 'ping' } ]
|
|
79
|
+
switch( wire ){
|
|
80
|
+
case 'anthropic':
|
|
81
|
+
return {
|
|
82
|
+
url: `${ base }/messages`,
|
|
83
|
+
headers: anthropicWireHeaders( provider, key ),
|
|
84
|
+
body: { model, max_tokens: 1, messages },
|
|
85
|
+
}
|
|
86
|
+
case 'openai':
|
|
87
|
+
return {
|
|
88
|
+
url: `${ base }/chat/completions`,
|
|
89
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${ key }` },
|
|
90
|
+
body: { model, max_tokens: 1, messages },
|
|
91
|
+
}
|
|
92
|
+
// Gemini authenticates in the query string and nests its payload
|
|
93
|
+
// differently enough that a hand-rolled ping here would drift from the
|
|
94
|
+
// client that actually makes the calls. Better unchecked than wrong.
|
|
95
|
+
case 'google': return null
|
|
96
|
+
}
|
|
63
97
|
}
|
|
64
98
|
|
|
65
99
|
/**
|
|
@@ -83,7 +117,7 @@ async function preflightLLM( anatomy: string ): Promise<void> {
|
|
|
83
117
|
|
|
84
118
|
const key = resolveLlmKey( mode )
|
|
85
119
|
if( !key ){
|
|
86
|
-
const expected = mode
|
|
120
|
+
const expected = PROVIDER_KEY_ENV[ mode ] ?? 'WILL_LLM_API_KEY'
|
|
87
121
|
console.error(`[will] WILL_LLM=${ mode } but no ${ expected } / WILL_LLM_API_KEY is set.`)
|
|
88
122
|
console.error('[will] The Will would boot, perceive, and never speak. Set a key, or run keyless with WILL_LLM=mock.')
|
|
89
123
|
process.exit( 2 )
|
|
@@ -91,16 +125,38 @@ async function preflightLLM( anatomy: string ): Promise<void> {
|
|
|
91
125
|
|
|
92
126
|
// The ping validates key + balance + reachability, which is the failure class
|
|
93
127
|
// that strands an operator. It uses the pinned model when there is one, so a
|
|
94
|
-
// bad model id is caught too
|
|
95
|
-
|
|
96
|
-
|
|
128
|
+
// bad model id is caught too.
|
|
129
|
+
const base = process.env.WILL_LLM_BASE_URL ?? defaultBaseFor( mode )
|
|
130
|
+
if( !base ){
|
|
131
|
+
console.error(`[will] WILL_LLM=${ mode } has no known base URL — set WILL_LLM_BASE_URL.`)
|
|
132
|
+
process.exit( 2 )
|
|
133
|
+
}
|
|
134
|
+
// The ping needs *a* model id. WILL_LLM_MODEL is the one the Will will
|
|
135
|
+
// actually use, so preferring it means a bad id is caught here rather than at
|
|
136
|
+
// the first tick. Without it there is nothing honest to send: the engine no
|
|
137
|
+
// longer carries a default model, so say so plainly instead of guessing.
|
|
97
138
|
const model = process.env.WILL_LLM_MODEL
|
|
98
|
-
|
|
139
|
+
if( !model ){
|
|
140
|
+
console.error(`[will] WILL_LLM_MODEL is not set. The engine has no default model —`)
|
|
141
|
+
console.error('[will] pick one for your provider (e.g. WILL_LLM_MODEL=claude-sonnet-4-5-20250929).')
|
|
142
|
+
process.exit( 2 )
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Ping in the provider's OWN dialect. This used to be hardcoded to the
|
|
146
|
+
// Anthropic wire, which was fine when boot knew only anthropic and glm. With
|
|
147
|
+
// the provider set widened it became a false negative: an OpenAI-wire
|
|
148
|
+
// provider answers 404 to `/messages`, preflight read that as "the LLM
|
|
149
|
+
// refused", and a perfectly working Will never got raised.
|
|
150
|
+
const ping = pingRequest( knownWireFor( mode ) ?? 'openai', base, model, key, mode )
|
|
151
|
+
if( !ping ){
|
|
152
|
+
console.error(`[will] no preflight ping for the ${ mode } wire — raising the mind unchecked.`)
|
|
153
|
+
return
|
|
154
|
+
}
|
|
99
155
|
try {
|
|
100
|
-
const res = await fetch(
|
|
156
|
+
const res = await fetch( ping.url, {
|
|
101
157
|
method: 'POST',
|
|
102
|
-
headers:
|
|
103
|
-
body: JSON.stringify(
|
|
158
|
+
headers: ping.headers,
|
|
159
|
+
body: JSON.stringify( ping.body ),
|
|
104
160
|
signal: AbortSignal.timeout( 20_000 ),
|
|
105
161
|
} )
|
|
106
162
|
if( res.ok ) return
|
package/src/index.ts
CHANGED
|
@@ -26,6 +26,41 @@ export {
|
|
|
26
26
|
|
|
27
27
|
export { assembleMind, type WillConfig } from '#stem/mind'
|
|
28
28
|
|
|
29
|
+
// Model routing — which model serves which call.
|
|
30
|
+
//
|
|
31
|
+
// These were reachable only through `WillConfig.llm.router`'s structural type,
|
|
32
|
+
// which meant the reference implementation this ships *for* hosts to use could
|
|
33
|
+
// not be imported by one. A seam nobody can import is not a seam.
|
|
34
|
+
//
|
|
35
|
+
// The engine carries mechanism only: a router sees what kind of work a call is
|
|
36
|
+
// and how much the moment demands, never who is paying or what anything costs.
|
|
37
|
+
// The table itself is the host's.
|
|
38
|
+
export {
|
|
39
|
+
NULL_ROUTER,
|
|
40
|
+
TableRouter,
|
|
41
|
+
chainRouters,
|
|
42
|
+
isNullRouter,
|
|
43
|
+
type ModelRouter,
|
|
44
|
+
type ModelRoute,
|
|
45
|
+
type RoutingRule,
|
|
46
|
+
} from '#llm/routing'
|
|
47
|
+
|
|
48
|
+
// Provider vocabulary — the wire each known provider speaks and where it lives.
|
|
49
|
+
// A provider outside this table works identically once the host declares its
|
|
50
|
+
// `wire` and `baseUrl` on the `llm.providers` entry.
|
|
51
|
+
export {
|
|
52
|
+
KNOWN_PROVIDERS,
|
|
53
|
+
knownWireFor,
|
|
54
|
+
defaultBaseFor,
|
|
55
|
+
BACKGROUND_DEMAND,
|
|
56
|
+
ESCALATION_DEMAND,
|
|
57
|
+
type LLMProvider,
|
|
58
|
+
type KnownProvider,
|
|
59
|
+
type LLMWire,
|
|
60
|
+
type LLMCallMeta,
|
|
61
|
+
type ProviderCredential,
|
|
62
|
+
} from '#llm/index'
|
|
63
|
+
|
|
29
64
|
// External transport — the unified bidirectional envelope channel between a Will
|
|
30
65
|
// and its host peer (backend). Exposes the transport interface, every envelope
|
|
31
66
|
// type, and the three implementations:
|