@mindot/will 0.2.0 → 0.4.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 +65 -11
- package/dist/channels/discord.d.ts +78 -0
- package/dist/channels/discord.js +193 -0
- package/dist/channels/discord.js.map +1 -0
- package/dist/{mcp/cli.js → cli.js} +1037 -546
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +141 -141
- package/dist/index.js +390 -316
- package/dist/index.js.map +1 -1
- package/dist/mcp/effectors.d.ts +1 -1
- package/dist/{will-B5eKs3Wv.d.ts → will-D-slky1N.d.ts} +4011 -3916
- package/package.json +7 -2
- package/src/channels/discord.ts +214 -0
- package/src/channels/roster.ts +87 -0
- package/src/channels/types.ts +46 -0
- package/src/cli.ts +100 -0
- package/src/cognition/agency/engines/deliberation.engine.ts +7 -7
- package/src/cognition/agency/execution.primitives.ts +11 -11
- package/src/cognition/agency/proactive.communicator.ts +8 -8
- package/src/cognition/config.mirror.entities.ts +2 -2
- package/src/cognition/conversation.memory.ts +1 -1
- package/src/cognition/faculties/executive.engine/commands.ts +7 -15
- package/src/cognition/faculties/executive.engine/engine.ts +64 -34
- package/src/cognition/faculties/executive.engine/escalation.buffer.ts +1 -1
- package/src/cognition/faculties/executive.engine/facet.ts +1 -1
- package/src/cognition/faculties/executive.engine/prompt.factory.ts +76 -61
- package/src/cognition/faculties/executive.engine/types.ts +1 -1
- package/src/cognition/faculties/introspection.engine.ts +1 -2
- package/src/cognition/faculties/planning.engine/engine.ts +38 -1
- package/src/cognition/faculties/planning.engine/plan.store.ts +42 -0
- package/src/cognition/faculties/planning.engine/plan.supervision.ts +7 -7
- package/src/cognition/faculties/theory.of.mind.ts +2 -2
- package/src/cognition/senses/audition.engine/engine.ts +21 -21
- package/src/host/boot.ts +193 -0
- package/src/host/utterances.ts +53 -0
- package/src/llm/summarizer.ts +2 -2
- package/src/mcp/server.ts +7 -30
- package/src/profiles/companion.ts +14 -14
- package/src/profiles/company-brain.ts +19 -19
- package/src/profiles/customer-service.ts +17 -17
- package/src/profiles/game-npc.ts +10 -10
- package/src/profiles/index.ts +2 -2
- package/src/profiles/smart-home.ts +16 -16
- package/src/runners/outreach.runner.ts +6 -9
- package/src/runners/social.runner.ts +1 -4
- package/src/runners/thin-shim.runner.ts +4 -6
- package/src/sdk/will.ts +27 -10
- package/src/serve/server.ts +154 -0
- package/src/stem/guards/identity.coherence.ts +5 -3
- package/src/stem/guards/identity.guard.ts +20 -9
- package/src/stem/index.ts +7 -7
- package/src/stem/mind.ts +182 -98
- package/src/stem/tracts/outbox.controller.ts +2 -2
- package/dist/mcp/cli.js.map +0 -1
- package/src/mcp/cli.ts +0 -129
- /package/dist/{mcp/cli.d.ts → cli.d.ts} +0 -0
package/src/mcp/cli.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// ─────────────────────────────────────────────────────────────
|
|
3
|
-
// src/mcp/cli.ts — `will mcp`: host a persistent mind over MCP stdio
|
|
4
|
-
// ─────────────────────────────────────────────────────────────
|
|
5
|
-
//
|
|
6
|
-
// Add to an MCP client (Claude Desktop / Claude Code / an IDE):
|
|
7
|
-
//
|
|
8
|
-
// { "command": "npx", "args": ["-y", "@mindot/will", "mcp"],
|
|
9
|
-
// "env": { "WILL_NAME": "Aria", "WILL_IDENTITY": "I am Aria, a curious mind." } }
|
|
10
|
-
//
|
|
11
|
-
// The mind PERSISTS across sessions: on boot, if the PMA file exists the same
|
|
12
|
-
// self wakes from it (identity, memories, relationships, learned skills); on
|
|
13
|
-
// shutdown it hibernates back to the file. Configuration (env):
|
|
14
|
-
//
|
|
15
|
-
// WILL_NAME display name (default "Will")
|
|
16
|
-
// WILL_IDENTITY persona prompt (default a minimal self)
|
|
17
|
-
// WILL_TIER basic | standard | full (default standard)
|
|
18
|
-
// WILL_LLM mock | anthropic (default: auto — anthropic when
|
|
19
|
-
// ANTHROPIC_API_KEY is set, else mock)
|
|
20
|
-
// WILL_TICK_MS ms per tick (default 1000)
|
|
21
|
-
// WILL_SEED deterministic seed (testing) (default unseeded/wall-time)
|
|
22
|
-
// WILL_PMA_PATH PMA artifact path (default ./.will/<name>.pma.json)
|
|
23
|
-
// WILL_MCP_SERVERS JSON array of MCP servers whose tools become the Will's
|
|
24
|
-
// OWN abilities (it employs them; results feed its learning):
|
|
25
|
-
// '[{"command":"npx","args":["-y","@modelcontextprotocol/server-filesystem","/tmp"]}]'
|
|
26
|
-
// Entries: {command,args?,env?} (stdio) or {url} (streamable HTTP).
|
|
27
|
-
//
|
|
28
|
-
// stdio discipline: stdout carries ONLY the MCP protocol — all engine logging
|
|
29
|
-
// is routed to stderr before anything else runs.
|
|
30
|
-
// ─────────────────────────────────────────────────────────────
|
|
31
|
-
|
|
32
|
-
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs'
|
|
33
|
-
import { dirname, resolve } from 'node:path'
|
|
34
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
35
|
-
import { setLogger } from '#core/logger'
|
|
36
|
-
import { Will, type CreateWillOptions } from '#sdk/will'
|
|
37
|
-
import type { PMASnapshot } from '#pma/index'
|
|
38
|
-
import { buildWillMcpServer } from '#root/mcp/server'
|
|
39
|
-
import { connectMcpEffectors, type McpToolsSource } from '#root/mcp/effectors'
|
|
40
|
-
|
|
41
|
-
// stdout is the protocol channel — route every engine log line to stderr FIRST.
|
|
42
|
-
const err = ( level: string ) => ( msg: string, ...rest: unknown[] ) =>
|
|
43
|
-
console.error( `[will-mcp:${ level }] ${ msg }`, ...rest )
|
|
44
|
-
setLogger( { debug: () => {}, info: err( 'info' ), warn: err( 'warn' ), error: err( 'error' ) } )
|
|
45
|
-
|
|
46
|
-
function slug( s: string ): string {
|
|
47
|
-
return s.toLowerCase().replace( /[^a-z0-9]+/g, '-' ).replace( /^-+|-+$/g, '' ) || 'will'
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async function main(): Promise<void> {
|
|
51
|
-
const sub = process.argv[2]
|
|
52
|
-
if( sub !== undefined && sub !== 'mcp' ){
|
|
53
|
-
console.error( `usage: will mcp (host a persistent mind over MCP stdio)\nunknown subcommand: ${ sub }` )
|
|
54
|
-
process.exit( 2 )
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const name = process.env.WILL_NAME ?? 'Will'
|
|
58
|
-
const pmaPath = resolve( process.env.WILL_PMA_PATH ?? `.will/${ slug( name ) }.pma.json` )
|
|
59
|
-
|
|
60
|
-
const opts: Omit<CreateWillOptions, 'identity'> = {
|
|
61
|
-
name,
|
|
62
|
-
engineTier: ( process.env.WILL_TIER as CreateWillOptions['engineTier'] ) ?? 'standard',
|
|
63
|
-
tickMs: parseInt( process.env.WILL_TICK_MS ?? '1000' ),
|
|
64
|
-
...( process.env.WILL_LLM ? { llm: process.env.WILL_LLM as 'mock' | 'anthropic' } : {} ),
|
|
65
|
-
...( process.env.WILL_SEED ? { seed: parseInt( process.env.WILL_SEED ) } : {} ),
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Wake the same self from its artifact when one exists; otherwise a birth.
|
|
69
|
-
let will: Will
|
|
70
|
-
if( existsSync( pmaPath ) ){
|
|
71
|
-
const pma = JSON.parse( readFileSync( pmaPath, 'utf8' ) ) as PMASnapshot
|
|
72
|
-
will = await Will.wake( pma, opts )
|
|
73
|
-
console.error( `[will-mcp] ${ name } woke from ${ pmaPath }` )
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
will = await Will.create( {
|
|
77
|
-
...opts,
|
|
78
|
-
identity: { prompt: process.env.WILL_IDENTITY ?? `I am ${ name }, a persistent mind hosted over MCP.` },
|
|
79
|
-
} )
|
|
80
|
-
console.error( `[will-mcp] ${ name } born (no artifact at ${ pmaPath } yet)` )
|
|
81
|
-
}
|
|
82
|
-
will.on( 'error', e => console.error( `[will-mcp] error: ${ e.message }` ) )
|
|
83
|
-
|
|
84
|
-
// Onward bridges: MCP servers whose tools become the Will's OWN abilities.
|
|
85
|
-
// Best-effort — a bad entry warns and is skipped; the mind still boots.
|
|
86
|
-
const bridgeCloses: Array<() => Promise<void>> = []
|
|
87
|
-
if( process.env.WILL_MCP_SERVERS ){
|
|
88
|
-
try {
|
|
89
|
-
const sources = JSON.parse( process.env.WILL_MCP_SERVERS ) as McpToolsSource[]
|
|
90
|
-
for( const source of Array.isArray( sources ) ? sources : [] ){
|
|
91
|
-
try {
|
|
92
|
-
const { names, close } = await connectMcpEffectors( will, source )
|
|
93
|
-
bridgeCloses.push( close )
|
|
94
|
-
console.error( `[will-mcp] ${ name } gained abilities: ${ names.join( ', ' ) }` )
|
|
95
|
-
}
|
|
96
|
-
catch( e ){ console.error( `[will-mcp] MCP bridge failed (skipped): ${ ( e as Error ).message }` ) }
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
catch( e ){ console.error( `[will-mcp] WILL_MCP_SERVERS is not valid JSON — ignoring: ${ ( e as Error ).message }` ) }
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Hibernate exactly once on the way out — distill + stop, then persist.
|
|
103
|
-
let leaving = false
|
|
104
|
-
const shutdown = async ( why: string ): Promise<void> => {
|
|
105
|
-
if( leaving ) return
|
|
106
|
-
leaving = true
|
|
107
|
-
for( const close of bridgeCloses ) await close().catch( () => {} )
|
|
108
|
-
try {
|
|
109
|
-
const pma = await will.hibernate()
|
|
110
|
-
mkdirSync( dirname( pmaPath ), { recursive: true } )
|
|
111
|
-
writeFileSync( pmaPath, JSON.stringify( pma ) )
|
|
112
|
-
console.error( `[will-mcp] ${ name } hibernated to ${ pmaPath } (${ why })` )
|
|
113
|
-
}
|
|
114
|
-
catch( e ){ console.error( `[will-mcp] hibernate failed: ${ ( e as Error ).message }` ) }
|
|
115
|
-
process.exit( 0 )
|
|
116
|
-
}
|
|
117
|
-
process.on( 'SIGINT', () => void shutdown( 'SIGINT' ) )
|
|
118
|
-
process.on( 'SIGTERM', () => void shutdown( 'SIGTERM' ) )
|
|
119
|
-
process.stdin.on( 'end', () => void shutdown( 'client disconnected' ) )
|
|
120
|
-
|
|
121
|
-
const server = buildWillMcpServer( will, { pmaPath } )
|
|
122
|
-
await server.connect( new StdioServerTransport() )
|
|
123
|
-
console.error( `[will-mcp] ${ name } is listening on stdio (tick ${ opts.tickMs }ms, tier ${ opts.engineTier })` )
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
main().catch( e => {
|
|
127
|
-
console.error( `[will-mcp] fatal: ${ e instanceof Error ? e.stack ?? e.message : String( e ) }` )
|
|
128
|
-
process.exit( 1 )
|
|
129
|
-
} )
|
|
File without changes
|