@mindot/will 0.4.0 → 0.6.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 +32 -12
- package/dist/channels/discord.d.ts +2 -11
- package/dist/channels/discord.js.map +1 -1
- package/dist/channels/whatsapp.d.ts +72 -0
- package/dist/channels/whatsapp.js +252 -0
- package/dist/channels/whatsapp.js.map +1 -0
- package/dist/cli.js +837 -91
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +620 -79
- package/dist/index.js.map +1 -1
- package/dist/mcp/effectors.d.ts +1 -1
- package/dist/mcp/effectors.js.map +1 -1
- package/dist/types-E9-HV-SW.d.ts +11 -0
- package/dist/{will-D-slky1N.d.ts → will-Bikuk4s2.d.ts} +56 -12
- package/package.json +12 -3
- package/src/channels/discord.ts +11 -11
- package/src/channels/roster.ts +1 -1
- package/src/channels/types.ts +1 -1
- package/src/channels/whatsapp.ts +318 -0
- package/src/cli.ts +46 -23
- package/src/cognition/acp.ts +28 -0
- package/src/cognition/agency/consequence.ts +174 -0
- package/src/cognition/agency/engines/action.selector.ts +301 -48
- package/src/cognition/agency/engines/affordance.synthesizer.ts +26 -16
- package/src/cognition/agency/engines/deliberation.engine.ts +28 -14
- package/src/cognition/agency/engines/motor.schema.executor.ts +86 -14
- package/src/cognition/agency/engines/reafference.engine.ts +122 -18
- package/src/cognition/agency/execution.primitives.ts +13 -13
- package/src/cognition/agency/proactive.communicator.ts +1 -1
- package/src/cognition/agency/reconcile.learning.ts +1 -1
- package/src/cognition/agency/revocation.ts +79 -0
- package/src/cognition/agency/schemas/repertoire.ts +2 -2
- package/src/cognition/agency/selection.scoring.ts +25 -9
- package/src/cognition/bus.ts +2 -2
- package/src/cognition/completion.inbox.ts +1 -1
- package/src/cognition/config.mirror.entities.ts +5 -5
- package/src/cognition/event.log.ts +2 -2
- package/src/cognition/event.schemas.ts +67 -67
- package/src/cognition/faculties/aesthetic.evaluator.ts +6 -6
- package/src/cognition/faculties/affective.blender.ts +36 -4
- package/src/cognition/faculties/attachment.evaluator.ts +6 -6
- package/src/cognition/faculties/attention.allocator.ts +63 -8
- package/src/cognition/faculties/autobiographical.narrator.ts +3 -3
- package/src/cognition/faculties/bias.detector.ts +7 -7
- package/src/cognition/faculties/circadian.oscillator.ts +3 -3
- package/src/cognition/faculties/confidence.calibrator.ts +7 -7
- package/src/cognition/faculties/dream.simulator.ts +5 -5
- package/src/cognition/faculties/empathy.simulator.ts +7 -7
- package/src/cognition/faculties/energy.regulator.ts +4 -4
- package/src/cognition/faculties/episodic.consolidator.ts +6 -6
- package/src/cognition/faculties/executive.engine/commands.ts +6 -6
- package/src/cognition/faculties/executive.engine/context.ts +42 -42
- package/src/cognition/faculties/executive.engine/deferred.effects.ts +2 -2
- package/src/cognition/faculties/executive.engine/engine.ts +27 -26
- package/src/cognition/faculties/executive.engine/facet.supervisor.ts +12 -12
- package/src/cognition/faculties/executive.engine/facet.ts +18 -18
- package/src/cognition/faculties/executive.engine/gating.ts +2 -2
- package/src/cognition/faculties/executive.engine/messages.ts +3 -3
- package/src/cognition/faculties/executive.engine/parser.ts +11 -11
- package/src/cognition/faculties/executive.engine/prompt.factory.ts +55 -55
- package/src/cognition/faculties/exteroception.ts +99 -5
- package/src/cognition/faculties/forgetting.curve.ts +3 -3
- package/src/cognition/faculties/frustration.evaluator.ts +6 -6
- package/src/cognition/faculties/goal.manager.ts +15 -15
- package/src/cognition/faculties/inhibition.controller.ts +3 -3
- package/src/cognition/faculties/interoception.ts +3 -3
- package/src/cognition/faculties/introspection.engine.ts +3 -3
- package/src/cognition/faculties/known.entity.tracker.ts +15 -15
- package/src/cognition/faculties/loss.evaluator.ts +2 -2
- package/src/cognition/faculties/moral.evaluator.ts +4 -4
- package/src/cognition/faculties/novelty.detector.ts +4 -4
- package/src/cognition/faculties/persona.consolidator.ts +12 -12
- package/src/cognition/faculties/planning.engine/engine.ts +47 -47
- package/src/cognition/faculties/planning.engine/plan.frontier.ts +5 -5
- package/src/cognition/faculties/planning.engine/plan.store.ts +1 -1
- package/src/cognition/faculties/planning.engine/plan.supervision.ts +20 -20
- package/src/cognition/faculties/reputation.tracker.ts +6 -6
- package/src/cognition/faculties/reward.evaluator.ts +4 -4
- package/src/cognition/faculties/self.model.updater.ts +8 -8
- package/src/cognition/faculties/semantic.engine/integrator.ts +15 -15
- package/src/cognition/faculties/sleep.pressure.regulator.ts +4 -4
- package/src/cognition/faculties/social.perception.ts +3 -3
- package/src/cognition/faculties/spaced.repetition.ts +2 -2
- package/src/cognition/faculties/stress.regulator.ts +27 -4
- package/src/cognition/faculties/task.switcher.ts +11 -6
- package/src/cognition/faculties/theory.of.mind.ts +6 -6
- package/src/cognition/faculties/threat.evaluator.ts +3 -3
- package/src/cognition/faculties/working.memory.ts +8 -8
- package/src/cognition/generative.model.ts +2 -2
- package/src/cognition/memory/vector.adapter.ts +5 -5
- package/src/cognition/memory/vector.content.ts +4 -4
- package/src/cognition/memory/vector.embedder.ts +9 -9
- package/src/cognition/persona.prior.ts +1 -1
- package/src/cognition/schema.registry.ts +2 -2
- package/src/cognition/senses/audition.engine/engine.ts +2 -2
- package/src/cognition/senses/base.sense.engine.ts +1 -1
- package/src/cognition/utilities/token.tracker.ts +11 -5
- package/src/core/abstracts.ts +1 -1
- package/src/core/completion.recorder.ts +2 -2
- package/src/core/serialization.ts +3 -3
- package/src/core/snapshot.manager.ts +1 -1
- package/src/core/state.manager.ts +1 -1
- package/src/core/utils.ts +1 -1
- package/src/host/boot.ts +59 -37
- package/src/host/utterances.ts +1 -1
- package/src/llm/index.ts +84 -34
- package/src/llm/summarizer.ts +4 -4
- package/src/llm/wire.contracts.ts +1 -1
- package/src/mcp/effectors.ts +10 -10
- package/src/mcp/server.ts +11 -11
- package/src/pma/eval.ts +1 -1
- package/src/pma/index.ts +21 -21
- package/src/runners/outreach.runner.ts +3 -3
- package/src/runners/social.runner.ts +1 -1
- package/src/runners/thin-shim.runner.ts +1 -1
- package/src/sdk/will.ts +20 -11
- package/src/serve/server.ts +12 -12
- package/src/stem/assembly.audit.ts +3 -3
- package/src/stem/guards/identity.coherence.ts +13 -12
- package/src/stem/guards/identity.guard.ts +22 -22
- package/src/stem/index.ts +11 -11
- package/src/stem/mind.ts +12 -12
- package/src/stem/tracts/biography.writer.ts +3 -3
- package/src/stem/tracts/effector.controller.ts +4 -4
- package/src/stem/tracts/health.reporter.ts +1 -1
- package/src/stem/tracts/outbox.controller.ts +4 -0
- package/src/stem/tracts/outbox.writer.ts +4 -4
- package/src/stem/tracts/pma.controller.ts +1 -1
- package/src/stem/tracts/replay.controller.ts +10 -10
- package/src/stem/tracts/sensory.controller.ts +2 -2
- package/src/stem/tracts/session.logger.ts +4 -4
- package/src/stem/tracts/transport/socketio.transport.ts +7 -7
- package/src/stem/tracts/transport/stream.transport.ts +2 -2
- package/src/stem/tracts/transport.controller.ts +15 -15
package/dist/mcp/effectors.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
-
import { E as EffectorHandler, W as Will } from '../will-
|
|
2
|
+
import { E as EffectorHandler, W as Will } from '../will-Bikuk4s2.js';
|
|
3
3
|
|
|
4
4
|
/** Where the tools live: spawn a local server, reach a remote one, or bring a connected client. */
|
|
5
5
|
type McpToolsSource = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/effectors.ts"],"names":[],"mappings":";;;;;AAwDA,IAAM,sBAAA,GAAyB,GAAA;AAE/B,IAAM,WAAA,GAAc,GAAA;AAOb,SAAS,gBAAiB,IAAA,EAA4B;AAC3D,EAAA,MAAM,KAAA,GAAW,IAAA,CAAK,WAAA,EAAa,UAAA,IAAc,EAAC;AAClD,EAAA,MAAM,WAAW,IAAI,GAAA,CAAK,KAAK,WAAA,EAAa,QAAA,IAAY,EAAG,CAAA;AAC3D,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,OA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K,UAAU,EAAG,CAAA,EAAI,KAAK,IAAK,CAAA,CAAA;AACjD,IAAA,IAAA,CAAK,SAAU,IAAA,EAAM;AAAA,MACnB,WAAA,EAAa,gBAAiB,IAAK,CAAA;AAAA,MACnC,IAAA,EAAa,KAAK,IAAA,IAAQ,GAAA;AAAA,MAC1B,IAAA,EAAa,CAAE,KAAM,CAAA;AAAA,MACrB,OAAA,EAAa,eAAA,CAAiB,MAAA,EAAQ,IAAK;AAAA,KAC3C,CAAA;AACF,IAAA,KAAA,CAAM,KAAM,IAAK,CAAA;AAAA,EACnB;AAEA,EAAA,OAAO,EAAE,KAAA,EAAO,KAAA,EAAO,YAAY;AAAE,IAAA,IAAI,KAAA,EAAQ,MAAM,MAAA,CAAO,KAAA,EAAM;AAAA,EAAE,CAAA,EAAE;AAC1E","file":"effectors.js","sourcesContent":["// ─────────────────────────────────────────────────────────────\n// src/mcp/effectors.ts — a Will EMPLOYING MCP tools (Seam 1)\n// ─────────────────────────────────────────────────────────────\n//\n// The other direction from server.ts: connect a Will to an external MCP server\n// and register that server's tools as the Will's own ABILITIES. Each tool\n// becomes a learnable affordance — its description (plus a compact hint of the\n// arguments it takes) is the ability's meaning, surfaced to the executive and\n// the deliberator; the WILL decides when to enact one (nothing here dispatches);\n// the tool's result feeds back through reafference, so the Will gets *skilled*\n// at the tools it uses.\n//\n// Arguments come from conscious intent: the executive supplies them via an\n// action's `args`, which ride the ideomotor leg into the invocation (see\n// executive commands.ts). A tool with required arguments enacted habitually\n// (without args) fails informatively — reafference then teaches the Will that\n// this ability wants deliberate articulation.\n//\n// const { names, close } = await connectMcpEffectors( will, {\n// command: 'npx', args: [ '-y', '@modelcontextprotocol/server-filesystem', '/tmp' ],\n// } )\n//\n// Import from '@mindot/will/mcp' — kept off the main entry so non-MCP\n// consumers never load the MCP SDK.\n// ─────────────────────────────────────────────────────────────\n\nimport { Client } from '@modelcontextprotocol/sdk/client/index.js'\nimport { StdioClientTransport, getDefaultEnvironment } from '@modelcontextprotocol/sdk/client/stdio.js'\nimport { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'\nimport type { Will, EffectorHandler, EffectorResult } from '#sdk/will'\n\n/** Where the tools live: spawn a local server, reach a remote one, or bring a connected client. */\nexport type McpToolsSource =\n | { command: string; args?: string[]; env?: Record<string, string> }\n | { url: string }\n | { client: Client }\n\nexport interface McpEffectorsOptions {\n /** Intrinsic effort prior 0..1 seeded on every bridged ability (default 0.2). */\n cost?: number\n /** Prefix for the ability names (e.g. 'fs_') — avoids collisions across servers. */\n prefix?: string\n}\n\n/** Minimal structural view of an MCP tool (the SDK's zod-inferred type, loosened). */\nexport interface McpToolInfo {\n name: string\n description?: string\n inputSchema?: {\n type?: string\n properties?: Record<string, { type?: string; description?: string }>\n required?: string[]\n }\n}\n\n/** Keep tool outcomes bounded — the description feeds reafference + episodic memory. */\nconst RESULT_DESCRIPTION_CAP = 700\n/** Keep ability meanings bounded — they render into the executive prompt. */\nconst MEANING_CAP = 300\n\n/**\n * The ability's *meaning*: the tool's description plus a compact hint of the\n * arguments it takes — so the executive knows what to supply in an action's\n * `args` when it enacts this ability.\n */\nexport function describeMcpTool( tool: McpToolInfo ): string {\n const props = tool.inputSchema?.properties ?? {}\n const required = new Set( tool.inputSchema?.required ?? [] )\n const argHints = Object.entries( props ).map( ( [ key, p ] ) =>\n `${ key }${ required.has( key ) ? '' : '?' }${ p.description ? `: ${ p.description }` : '' }` )\n\n const base = ( tool.description ?? `The ${ tool.name } tool.` ).trim().replace( /\\s+/g, ' ' )\n const hint = argHints.length > 0 ? ` (args — ${ argHints.join( '; ' ) })` : ''\n const full = `${ base }${ hint }`\n return full.length > MEANING_CAP ? `${ full.slice( 0, MEANING_CAP - 1 ) }…` : full\n}\n\n/**\n * The effector handler for one bridged tool: checks required args (an ability\n * enacted without its needed articulation fails informatively — reafference\n * learns from it), calls the tool, and maps the result onto EffectorResult.\n */\nexport function buildMcpHandler( client: Client, tool: McpToolInfo ): EffectorHandler {\n return async ( args ): Promise<EffectorResult> => {\n const props = tool.inputSchema?.properties\n // Only pass keys the tool declares — invocation params can carry situation\n // extras (targetEntityName, learned priors) the tool never asked for.\n const filtered: Record<string, unknown> = {}\n for( const [ k, v ] of Object.entries( args ?? {} ) )\n if( !props || k in props ) filtered[ k ] = v\n\n const missing = ( tool.inputSchema?.required ?? [] ).filter(\n k => filtered[ k ] === undefined || filtered[ k ] === '' )\n if( missing.length > 0 )\n return {\n success: false,\n description: `${ tool.name } needs ${ missing.join( ', ' ) } — enact it deliberately, supplying them in the action's args.`,\n }\n\n try {\n const res = await client.callTool( { name: tool.name, arguments: filtered } ) as\n { content?: Array<{ type: string; text?: string }>; isError?: boolean }\n const text = ( res.content ?? [] )\n .filter( c => c.type === 'text' && typeof c.text === 'string' )\n .map( c => c.text as string )\n .join( '\\n' )\n .trim() || ( res.isError ? 'The tool reported an error.' : 'Done (no output).' )\n const bounded = text.length > RESULT_DESCRIPTION_CAP ? `${ text.slice( 0, RESULT_DESCRIPTION_CAP - 1 ) }…` : text\n return { success: !res.isError, description: bounded }\n }\n catch( err ){\n return { success: false, description: `${ tool.name } failed: ${ err instanceof Error ? err.message : String( err ) }` }\n }\n }\n}\n\nasync function connect( source: McpToolsSource ): Promise<{ client: Client; owned: boolean }> {\n if( 'client' in source ) return { client: source.client, owned: false }\n\n const client = new Client( { name: 'mindot-will', version: '0' } )\n if( 'url' in source )\n await client.connect( new StreamableHTTPClientTransport( new URL( source.url ) ) )\n else\n await client.connect( new StdioClientTransport( {\n command: source.command,\n ...( source.args ? { args: source.args } : {} ),\n // Merge over the SDK's safe default env so PATH etc. survive a custom env.\n env: { ...getDefaultEnvironment(), ...( source.env ?? {} ) },\n } ) )\n return { client, owned: true }\n}\n\n/**\n * Register an MCP server's tools as the Will's abilities. Returns the ability\n * names registered and a `close()` for the connection (call it when the Will\n * stops; a client passed in via `source.client` is left open).\n */\nexport async function connectMcpEffectors(\n will: Will,\n source: McpToolsSource,\n opts: McpEffectorsOptions = {},\n): Promise<{ names: string[]; close: () => Promise<void> }> {\n const { client, owned } = await connect( source )\n const { tools } = await client.listTools() as unknown as { tools: McpToolInfo[] }\n\n const names: string[] = []\n for( const tool of tools ){\n const name = `${ opts.prefix ?? '' }${ tool.name }`\n will.effector( name, {\n description: describeMcpTool( tool ),\n cost: opts.cost ?? 0.2,\n tags: [ 'mcp' ],\n handler: buildMcpHandler( client, tool ),\n } )\n names.push( name )\n }\n\n return { names, close: async () => { if( owned ) await client.close() } }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/effectors.ts"],"names":[],"mappings":";;;;;AAwDA,IAAM,sBAAA,GAAyB,GAAA;AAE/B,IAAM,WAAA,GAAc,GAAA;AAOb,SAAS,gBAAiB,IAAA,EAA4B;AAC3D,EAAA,MAAM,KAAA,GAAW,IAAA,CAAK,WAAA,EAAa,UAAA,IAAc,EAAC;AAClD,EAAA,MAAM,WAAW,IAAI,GAAA,CAAK,KAAK,WAAA,EAAa,QAAA,IAAY,EAAG,CAAA;AAC3D,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,OAAA,CAAS,KAAM,CAAA,CAAE,GAAA,CAAK,CAAE,CAAE,GAAA,EAAK,CAAE,CAAA,KACvD,CAAA,EAAI,GAAI,CAAA,EAAI,QAAA,CAAS,GAAA,CAAK,GAAI,CAAA,GAAI,EAAA,GAAK,GAAI,CAAA,EAAI,CAAA,CAAE,WAAA,GAAc,CAAA,EAAA,EAAM,CAAA,CAAE,WAAY,CAAA,CAAA,GAAK,EAAG,CAAA,CAAE,CAAA;AAE/F,EAAA,MAAM,IAAA,GAAA,CAAS,IAAA,CAAK,WAAA,IAAe,CAAA,IAAA,EAAQ,IAAA,CAAK,IAAK,CAAA,MAAA,CAAA,EAAU,IAAA,EAAK,CAAE,OAAA,CAAS,MAAA,EAAQ,GAAG,CAAA;AAC1F,EAAA,MAAM,IAAA,GAAO,SAAS,MAAA,GAAS,CAAA,GAAI,iBAAa,QAAA,CAAS,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AA,CAAO,OAAA,CAAS,IAAI,oBAAA,CAAsB;AAAA,MAC9C,SAAS,MAAA,CAAO,OAAA;AAAA,MAChB,GAAK,OAAO,IAAA,GAAO,EAAE,MAAM,MAAA,CAAO,IAAA,KAAS,EAAC;AAAA;AAAA,MAE5C,GAAA,EAAK,EAAE,GAAG,qBAAA,IAAyB,GAAK,MAAA,CAAO,GAAA,IAAO,EAAC;AAAI,KAC3D,CAAE,CAAA;AACN,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,IAAA,EAAK;AAC/B;AAOA,eAAsB,mBAAA,CACpB,IAAA,EACA,MAAA,EACA,IAAA,GAA8B,EAAC,EAC2B;AAC1D,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,EAAM,GAAI,MAAM,QAAS,MAAO,CAAA;AAChD,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,MAAM,OAAO,SAAA,EAAU;AAEzC,EAAA,MAAM,QAAkB,EAAC;AACzB,EAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,IAAA,MAAM,OAAO,CAAA,EAAI,IAAA,CAAK,UAAU,EAAG,CAAA,EAAI,KAAK,IAAK,CAAA,CAAA;AACjD,IAAA,IAAA,CAAK,SAAU,IAAA,EAAM;AAAA,MACnB,WAAA,EAAa,gBAAiB,IAAK,CAAA;AAAA,MACnC,IAAA,EAAa,KAAK,IAAA,IAAQ,GAAA;AAAA,MAC1B,IAAA,EAAa,CAAE,KAAM,CAAA;AAAA,MACrB,OAAA,EAAa,eAAA,CAAiB,MAAA,EAAQ,IAAK;AAAA,KAC3C,CAAA;AACF,IAAA,KAAA,CAAM,KAAM,IAAK,CAAA;AAAA,EACnB;AAEA,EAAA,OAAO,EAAE,KAAA,EAAO,KAAA,EAAO,YAAY;AAAE,IAAA,IAAI,KAAA,EAAQ,MAAM,MAAA,CAAO,KAAA,EAAM;AAAA,EAAE,CAAA,EAAE;AAC1E","file":"effectors.js","sourcesContent":["// ─────────────────────────────────────────────────────────────\n// src/mcp/effectors.ts — a Will EMPLOYING MCP tools (Seam 1)\n// ─────────────────────────────────────────────────────────────\n//\n// The other direction from server.ts: connect a Will to an external MCP server\n// and register that server's tools as the Will's own ABILITIES. Each tool\n// becomes a learnable affordance — its description (plus a compact hint of the\n// arguments it takes) is the ability's meaning, surfaced to the executive and\n// the deliberator; the WILL decides when to enact one (nothing here dispatches);\n// the tool's result feeds back through reafference, so the Will gets *skilled*\n// at the tools it uses.\n//\n// Arguments come from conscious intent: the executive supplies them via an\n// action's `args`, which ride the ideomotor leg into the invocation (see\n// executive commands.ts). A tool with required arguments enacted habitually\n// (without args) fails informatively — reafference then teaches the Will that\n// this ability wants deliberate articulation.\n//\n// const { names, close } = await connectMcpEffectors( will, {\n// command: 'npx', args: [ '-y', '@modelcontextprotocol/server-filesystem', '/tmp' ],\n// } )\n//\n// Import from '@mindot/will/mcp' — kept off the main entry so non-MCP\n// consumers never load the MCP SDK.\n// ─────────────────────────────────────────────────────────────\n\nimport { Client } from '@modelcontextprotocol/sdk/client/index.js'\nimport { StdioClientTransport, getDefaultEnvironment } from '@modelcontextprotocol/sdk/client/stdio.js'\nimport { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'\nimport type { Will, EffectorHandler, EffectorResult } from '#sdk/will'\n\n/** Where the tools live: spawn a local server, reach a remote one, or bring a connected client. */\nexport type McpToolsSource =\n | { command: string; args?: string[]; env?: Record<string, string> }\n | { url: string }\n | { client: Client }\n\nexport interface McpEffectorsOptions {\n /** Intrinsic effort prior 0..1 seeded on every bridged ability (default 0.2). */\n cost?: number\n /** Prefix for the ability names (e.g. 'fs_') — avoids collisions across servers. */\n prefix?: string\n}\n\n/** Minimal structural view of an MCP tool (the SDK's zod-inferred type, loosened). */\nexport interface McpToolInfo {\n name: string\n description?: string\n inputSchema?: {\n type?: string\n properties?: Record<string, { type?: string; description?: string }>\n required?: string[]\n }\n}\n\n/** Keep tool outcomes bounded — the description feeds reafference + episodic memory. */\nconst RESULT_DESCRIPTION_CAP = 700\n/** Keep ability meanings bounded — they render into the executive prompt. */\nconst MEANING_CAP = 300\n\n/**\n * The ability's *meaning*: the tool's description plus a compact hint of the\n * arguments it takes — so the executive knows what to supply in an action's\n * `args` when it enacts this ability.\n */\nexport function describeMcpTool( tool: McpToolInfo ): string {\n const props = tool.inputSchema?.properties ?? {}\n const required = new Set( tool.inputSchema?.required ?? [] )\n const argHints = Object.entries( props ).map( ( [ key, p ] ) =>\n `${ key }${ required.has( key ) ? '' : '?' }${ p.description ? `: ${ p.description }` : '' }`)\n\n const base = ( tool.description ?? `The ${ tool.name } tool.`).trim().replace( /\\s+/g, ' ')\n const hint = argHints.length > 0 ? ` (args — ${ argHints.join('; ') })` : ''\n const full = `${ base }${ hint }`\n return full.length > MEANING_CAP ? `${ full.slice( 0, MEANING_CAP - 1 ) }…` : full\n}\n\n/**\n * The effector handler for one bridged tool: checks required args (an ability\n * enacted without its needed articulation fails informatively — reafference\n * learns from it), calls the tool, and maps the result onto EffectorResult.\n */\nexport function buildMcpHandler( client: Client, tool: McpToolInfo ): EffectorHandler {\n return async ( args ): Promise<EffectorResult> => {\n const props = tool.inputSchema?.properties\n // Only pass keys the tool declares — invocation params can carry situation\n // extras (targetEntityName, learned priors) the tool never asked for.\n const filtered: Record<string, unknown> = {}\n for( const [ k, v ] of Object.entries( args ?? {} ) )\n if( !props || k in props ) filtered[ k ] = v\n\n const missing = ( tool.inputSchema?.required ?? [] ).filter(\n k => filtered[ k ] === undefined || filtered[ k ] === '')\n if( missing.length > 0 )\n return {\n success: false,\n description: `${ tool.name } needs ${ missing.join(', ') } — enact it deliberately, supplying them in the action's args.`,\n }\n\n try {\n const res = await client.callTool( { name: tool.name, arguments: filtered } ) as\n { content?: Array<{ type: string; text?: string }>; isError?: boolean }\n const text = ( res.content ?? [] )\n .filter( c => c.type === 'text' && typeof c.text === 'string')\n .map( c => c.text as string )\n .join('\\n')\n .trim() || ( res.isError ? 'The tool reported an error.' : 'Done (no output).')\n const bounded = text.length > RESULT_DESCRIPTION_CAP ? `${ text.slice( 0, RESULT_DESCRIPTION_CAP - 1 ) }…` : text\n return { success: !res.isError, description: bounded }\n }\n catch( err ){\n return { success: false, description: `${ tool.name } failed: ${ err instanceof Error ? err.message : String( err ) }` }\n }\n }\n}\n\nasync function connect( source: McpToolsSource ): Promise<{ client: Client; owned: boolean }> {\n if('client' in source ) return { client: source.client, owned: false }\n\n const client = new Client( { name: 'mindot-will', version: '0' } )\n if('url' in source )\n await client.connect( new StreamableHTTPClientTransport( new URL( source.url ) ) )\n else\n await client.connect( new StdioClientTransport( {\n command: source.command,\n ...( source.args ? { args: source.args } : {} ),\n // Merge over the SDK's safe default env so PATH etc. survive a custom env.\n env: { ...getDefaultEnvironment(), ...( source.env ?? {} ) },\n } ) )\n return { client, owned: true }\n}\n\n/**\n * Register an MCP server's tools as the Will's abilities. Returns the ability\n * names registered and a `close()` for the connection (call it when the Will\n * stops; a client passed in via `source.client` is left open).\n */\nexport async function connectMcpEffectors(\n will: Will,\n source: McpToolsSource,\n opts: McpEffectorsOptions = {},\n): Promise<{ names: string[]; close: () => Promise<void> }> {\n const { client, owned } = await connect( source )\n const { tools } = await client.listTools() as unknown as { tools: McpToolInfo[] }\n\n const names: string[] = []\n for( const tool of tools ){\n const name = `${ opts.prefix ?? '' }${ tool.name }`\n will.effector( name, {\n description: describeMcpTool( tool ),\n cost: opts.cost ?? 0.2,\n tags: [ 'mcp' ],\n handler: buildMcpHandler( client, tool ),\n } )\n names.push( name )\n }\n\n return { names, close: async () => { if( owned ) await client.close() } }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** A running connection between one Will and one platform. */
|
|
2
|
+
interface ChannelBridge {
|
|
3
|
+
/** Platform kind, e.g. 'discord'. */
|
|
4
|
+
readonly kind: string;
|
|
5
|
+
/** Connect and start relaying. Resolves once the bridge is live. */
|
|
6
|
+
start(): Promise<void>;
|
|
7
|
+
/** Disconnect and release resources. Idempotent. */
|
|
8
|
+
close(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type { ChannelBridge as C };
|
|
@@ -2567,7 +2567,7 @@ declare class CompletionInbox {
|
|
|
2567
2567
|
clear(): number;
|
|
2568
2568
|
}
|
|
2569
2569
|
|
|
2570
|
-
type LLMProvider = 'anthropic' | 'deepseek' | 'openai' | 'google';
|
|
2570
|
+
type LLMProvider = 'anthropic' | 'glm' | 'deepseek' | 'openai' | 'google';
|
|
2571
2571
|
interface LLMDirectorConfig {
|
|
2572
2572
|
willId: string;
|
|
2573
2573
|
model: string;
|
|
@@ -3347,6 +3347,8 @@ declare class AttentionAllocator implements SimulationEngine, CognitiveEngine {
|
|
|
3347
3347
|
private _effort;
|
|
3348
3348
|
/** A one-shot focus/rest request from the executive, applied next react(). */
|
|
3349
3349
|
private _effortRequest;
|
|
3350
|
+
/** ACP-P2: a self-caused precision attenuation is armed; react() restores after one observe. */
|
|
3351
|
+
private _acpOneShot;
|
|
3350
3352
|
private _bus;
|
|
3351
3353
|
private readonly _model;
|
|
3352
3354
|
constructor(config?: AttentionAllocatorConfig);
|
|
@@ -3435,6 +3437,8 @@ declare class StressRegulator implements SimulationEngine, CognitiveEngine {
|
|
|
3435
3437
|
subscribes(): string[];
|
|
3436
3438
|
publishes(): CognitiveEventSchema[];
|
|
3437
3439
|
onCognitiveEvent(e: CognitiveEvent): StateCommands | void;
|
|
3440
|
+
/** ACP-P2: self-caused stress attenuation armed; react() restores after one observe. */
|
|
3441
|
+
private _acpOneShot;
|
|
3438
3442
|
snapshot(): Record<string, unknown>;
|
|
3439
3443
|
react(delta: Duration, _tick: Tick, state: ReadonlySimulationState, context: SimulationContext): Promise<EngineResult>;
|
|
3440
3444
|
private _readConfigFromState;
|
|
@@ -3549,6 +3553,28 @@ declare class Exteroception implements SimulationEngine, CognitiveEngine {
|
|
|
3549
3553
|
* Generate a meaningful summary for an entity.
|
|
3550
3554
|
* Instead of "New percept: percept-54-0", produce something useful.
|
|
3551
3555
|
*/
|
|
3556
|
+
/**
|
|
3557
|
+
* The text the corollary-discharge matcher inspects for this entity — its
|
|
3558
|
+
* content (a message body) over its description over its summary. Where our
|
|
3559
|
+
* own delivered words would surface if the world echoes them back.
|
|
3560
|
+
*/
|
|
3561
|
+
/**
|
|
3562
|
+
* The affect→percept valence seam (registry #5). A percept carries how the
|
|
3563
|
+
* mind *feels* about what it is a percept OF, resolved most-specific-first:
|
|
3564
|
+
*
|
|
3565
|
+
* 1. the KnownEntityTracker's dossier for this entity (`ke-<id>.valence`) —
|
|
3566
|
+
* a real per-entity felt valence, the honest signal;
|
|
3567
|
+
* 2. otherwise the ambient `affect.valence` — the felt tone at perception
|
|
3568
|
+
* time. Weaker evidence, so it is tagged `'ambient'` and consumers
|
|
3569
|
+
* weight it down (mood is context, not appraisal of this thing).
|
|
3570
|
+
*
|
|
3571
|
+
* Absent both, no valence is stamped and every consumer keeps its
|
|
3572
|
+
* pre-seam behaviour.
|
|
3573
|
+
*/
|
|
3574
|
+
/** Spread-friendly form of `_valenceFor` for percept construction. */
|
|
3575
|
+
private _valenceOf;
|
|
3576
|
+
private _valenceFor;
|
|
3577
|
+
private _matchText;
|
|
3552
3578
|
private _summarizeEntity;
|
|
3553
3579
|
/**
|
|
3554
3580
|
* Compute salience of a percept based on entity characteristics.
|
|
@@ -4263,6 +4289,8 @@ declare class AffectiveBlender implements SimulationEngine, CognitiveEngine {
|
|
|
4263
4289
|
private _previousPAD;
|
|
4264
4290
|
private _emotionHistory;
|
|
4265
4291
|
private _moodBaseline;
|
|
4292
|
+
/** ACP-P2: self-caused arousal attenuation armed; react() restores after one observe. */
|
|
4293
|
+
private _acpOneShot;
|
|
4266
4294
|
private _energyLevel;
|
|
4267
4295
|
private _comfort;
|
|
4268
4296
|
private _sleepPressure;
|
|
@@ -5451,25 +5479,25 @@ declare class AccessGrants {
|
|
|
5451
5479
|
declare class VisionEngine extends ShellSenseEngine {
|
|
5452
5480
|
readonly name = "vision-engine";
|
|
5453
5481
|
readonly domain: "vision";
|
|
5454
|
-
protected readonly acceptedKinds: Set<"text" | "system" | "
|
|
5482
|
+
protected readonly acceptedKinds: Set<"text" | "system" | "ambient" | "voice" | "image" | "video" | "webhook" | "background" | "self-eval" | "assessment">;
|
|
5455
5483
|
}
|
|
5456
5484
|
|
|
5457
5485
|
declare class SomatosensationEngine extends ShellSenseEngine {
|
|
5458
5486
|
readonly name = "somatosensation-engine";
|
|
5459
5487
|
readonly domain: "somatosensation";
|
|
5460
|
-
protected readonly acceptedKinds: Set<"text" | "system" | "
|
|
5488
|
+
protected readonly acceptedKinds: Set<"text" | "system" | "ambient" | "voice" | "image" | "video" | "webhook" | "background" | "self-eval" | "assessment">;
|
|
5461
5489
|
}
|
|
5462
5490
|
|
|
5463
5491
|
declare class OlfactionEngine extends ShellSenseEngine {
|
|
5464
5492
|
readonly name = "olfaction-engine";
|
|
5465
5493
|
readonly domain: "olfaction";
|
|
5466
|
-
protected readonly acceptedKinds: Set<"text" | "system" | "
|
|
5494
|
+
protected readonly acceptedKinds: Set<"text" | "system" | "ambient" | "voice" | "image" | "video" | "webhook" | "background" | "self-eval" | "assessment">;
|
|
5467
5495
|
}
|
|
5468
5496
|
|
|
5469
5497
|
declare class GustationEngine extends ShellSenseEngine {
|
|
5470
5498
|
readonly name = "gustation-engine";
|
|
5471
5499
|
readonly domain: "gustation";
|
|
5472
|
-
protected readonly acceptedKinds: Set<"text" | "system" | "
|
|
5500
|
+
protected readonly acceptedKinds: Set<"text" | "system" | "ambient" | "voice" | "image" | "video" | "webhook" | "background" | "self-eval" | "assessment">;
|
|
5473
5501
|
}
|
|
5474
5502
|
|
|
5475
5503
|
/**
|
|
@@ -5639,7 +5667,7 @@ declare class AuditionEngine extends BaseSenseEngine {
|
|
|
5639
5667
|
readonly name = "audition-engine";
|
|
5640
5668
|
readonly domain: "audition";
|
|
5641
5669
|
/** Audition consumes language input; the base filters every other kind out. */
|
|
5642
|
-
protected readonly acceptedKinds: Set<"text" | "system" | "
|
|
5670
|
+
protected readonly acceptedKinds: Set<"text" | "system" | "ambient" | "voice" | "image" | "video" | "webhook" | "background" | "self-eval" | "assessment">;
|
|
5643
5671
|
/** Inbound is gated on the 'listen' effector — the base enforces it before _perceive(). */
|
|
5644
5672
|
protected readonly gateEffector = "listen";
|
|
5645
5673
|
private _executiveEngine;
|
|
@@ -6085,11 +6113,25 @@ declare class ActionSelector implements CognitiveEngine {
|
|
|
6085
6113
|
private _bus;
|
|
6086
6114
|
private _lastEntropy;
|
|
6087
6115
|
private _lastDeliberate;
|
|
6116
|
+
private _lastRevoked;
|
|
6117
|
+
private _senseBuffer;
|
|
6088
6118
|
attachBus(bus: CognitiveBus): void;
|
|
6089
6119
|
publishes(): CognitiveEventSchema[];
|
|
6090
6120
|
subscribes(): string[];
|
|
6091
|
-
|
|
6121
|
+
/**
|
|
6122
|
+
* Mostly pull-model — but two afferent classes never become entities and
|
|
6123
|
+
* would leave rupture blind: sense-channel percepts
|
|
6124
|
+
* (ACTION_CONDITIONED_PREDICTION §2b) and the model-error state-change
|
|
6125
|
+
* events (registry #6). Buffer both (cross-tick: bus flush at T, consumed
|
|
6126
|
+
* by react at T+1 — FN9-snapshotted); the echo guard is applied at read
|
|
6127
|
+
* time for texts, and at the SOURCE for model errors (ACP-P2 precision).
|
|
6128
|
+
*/
|
|
6129
|
+
onCognitiveEvent(e: CognitiveEvent): void;
|
|
6092
6130
|
snapshot(): Record<string, unknown>;
|
|
6131
|
+
/** FN9: `_lastRevoked` has behavioral effect (the Channel-B `revokedBy` stamp),
|
|
6132
|
+
* so a restored mind must carry it — a rupture-driven letting-go survives a
|
|
6133
|
+
* snapshot boundary instead of silently losing its narrative thread. */
|
|
6134
|
+
restore(s: Record<string, unknown>): void;
|
|
6093
6135
|
react(_delta: Duration, tick: Tick, state: ReadonlySimulationState, _context: SimulationContext): Promise<EngineResult>;
|
|
6094
6136
|
}
|
|
6095
6137
|
|
|
@@ -7868,11 +7910,13 @@ interface CreateWillOptions {
|
|
|
7868
7910
|
* (Named llmConfig because `llm` is the mock/anthropic MODE switch.) */
|
|
7869
7911
|
llmConfig?: WillLLMConfig;
|
|
7870
7912
|
/**
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7913
|
+
* LLM mode. 'mock' (default when no key is present) runs a deterministic
|
|
7914
|
+
* canned executive — zero keys, zero cost. 'anthropic' calls Claude (needs
|
|
7915
|
+
* ANTHROPIC_API_KEY / WILL_LLM_* env); 'glm' calls Z.ai's GLM over its
|
|
7916
|
+
* Anthropic-compatible endpoint (needs ZAI_API_KEY / WILL_LLM_*). Omit to
|
|
7917
|
+
* auto-detect from whichever key is set.
|
|
7918
|
+
*/
|
|
7919
|
+
llm?: 'mock' | 'anthropic' | 'glm';
|
|
7876
7920
|
/**
|
|
7877
7921
|
* Abilities the Will can choose to enact. `name → handler`, or
|
|
7878
7922
|
* `name → { handler, description?, cost?, valence?, preconditions? }` to seed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindot/will",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"author": "Fabrice <fabrice8@github.com>",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
"zod": "^4.0.0"
|
|
22
22
|
},
|
|
23
23
|
"optionalDependencies": {
|
|
24
|
+
"baileys": "^7.0.0-rc13",
|
|
24
25
|
"discord.js": "^14.16.3",
|
|
26
|
+
"qrcode-terminal": "^0.12.0",
|
|
25
27
|
"socket.io-client": "^4.8.1"
|
|
26
28
|
},
|
|
27
29
|
"exports": {
|
|
@@ -36,16 +38,23 @@
|
|
|
36
38
|
"./discord": {
|
|
37
39
|
"import": "./dist/channels/discord.js",
|
|
38
40
|
"types": "./dist/channels/discord.d.ts"
|
|
41
|
+
},
|
|
42
|
+
"./whatsapp": {
|
|
43
|
+
"import": "./dist/channels/whatsapp.js",
|
|
44
|
+
"types": "./dist/channels/whatsapp.d.ts"
|
|
39
45
|
}
|
|
40
46
|
},
|
|
41
47
|
"bugs": {
|
|
42
48
|
"url": "https://github.com/mindot-ai/will/issues"
|
|
43
49
|
},
|
|
44
|
-
"description": "Will
|
|
50
|
+
"description": "Will \u2014 an engine for persistent machine minds. A Will is a continuously-ticking synthetic mind built from 38 cognitive faculties, a learning agency pipeline, and a dual-process executive \u2014 deterministic, persistent, and portable (PMA).",
|
|
45
51
|
"engines": {
|
|
46
52
|
"bun": ">=1.0.0"
|
|
47
53
|
},
|
|
48
|
-
"files": [
|
|
54
|
+
"files": [
|
|
55
|
+
"dist",
|
|
56
|
+
"src"
|
|
57
|
+
],
|
|
49
58
|
"homepage": "https://github.com/mindot-ai/will#readme",
|
|
50
59
|
"keywords": [
|
|
51
60
|
"ai",
|
package/src/channels/discord.ts
CHANGED
|
@@ -84,8 +84,8 @@ export interface DiscordBridgeOptions {
|
|
|
84
84
|
* itself is not stopped; it simply loses this surface.
|
|
85
85
|
*/
|
|
86
86
|
export async function connectDiscord( will: Will, opts: DiscordBridgeOptions ): Promise<ChannelBridge> {
|
|
87
|
-
const log = opts.log ?? ( ( m: string ) => console.error(
|
|
88
|
-
const roster = new ChannelRoster( opts.rosterPath ?? `.will/${ will.id }.discord.json`
|
|
87
|
+
const log = opts.log ?? ( ( m: string ) => console.error(`[will:discord] ${ m }`) )
|
|
88
|
+
const roster = new ChannelRoster( opts.rosterPath ?? `.will/${ will.id }.discord.json`)
|
|
89
89
|
const allowed = opts.channels?.length ? new Set( opts.channels ) : null
|
|
90
90
|
|
|
91
91
|
const client = opts.client ?? await createDiscordClient()
|
|
@@ -94,7 +94,7 @@ export async function connectDiscord( will: Will, opts: DiscordBridgeOptions ):
|
|
|
94
94
|
let lastActiveChannelId: string | null = opts.homeChannelId ?? null
|
|
95
95
|
|
|
96
96
|
// ── inbound: platform message → stimulus ──────────────────────────────────
|
|
97
|
-
client.on(
|
|
97
|
+
client.on('messageCreate', message => { void onMessage( message ) } )
|
|
98
98
|
|
|
99
99
|
async function onMessage( message: DiscordLikeMessage ): Promise<void> {
|
|
100
100
|
const self = client.user
|
|
@@ -135,7 +135,7 @@ export async function connectDiscord( will: Will, opts: DiscordBridgeOptions ):
|
|
|
135
135
|
// ── outbound: projected utterance → the addressee ─────────────────────────
|
|
136
136
|
// The facade has no off(); the bridge gates its handler on `closed` instead.
|
|
137
137
|
let closed = false
|
|
138
|
-
will.on(
|
|
138
|
+
will.on('message', ( m: WillMessage ) => { if( !closed ) void deliver( m ) } )
|
|
139
139
|
|
|
140
140
|
async function deliver( m: WillMessage ): Promise<void> {
|
|
141
141
|
const peer = m.to ? roster.resolve( m.to ) : undefined
|
|
@@ -161,7 +161,7 @@ export async function connectDiscord( will: Will, opts: DiscordBridgeOptions ):
|
|
|
161
161
|
}
|
|
162
162
|
catch { /* fall through */ }
|
|
163
163
|
}
|
|
164
|
-
log(
|
|
164
|
+
log(`no route for utterance to '${ m.to }' — dropped (${ m.content.length } chars)`)
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
// ── lifecycle ──────────────────────────────────────────────────────────────
|
|
@@ -175,14 +175,14 @@ export async function connectDiscord( will: Will, opts: DiscordBridgeOptions ):
|
|
|
175
175
|
const ready = new Promise<void>( resolve => {
|
|
176
176
|
let poll: ReturnType<typeof setInterval> | null = null
|
|
177
177
|
const done = (): void => { if( poll ) clearInterval( poll ); resolve() }
|
|
178
|
-
client.once(
|
|
178
|
+
client.once('clientReady', done )
|
|
179
179
|
poll = setInterval( () => { if( client.isReady?.() ) done() }, 100 )
|
|
180
180
|
poll.unref?.()
|
|
181
181
|
} )
|
|
182
|
-
await client.login( opts.token ?? ''
|
|
182
|
+
await client.login( opts.token ?? '')
|
|
183
183
|
await ready
|
|
184
184
|
}
|
|
185
|
-
log(
|
|
185
|
+
log(`${ will.name } is present on Discord as user ${ client.user?.id }`)
|
|
186
186
|
},
|
|
187
187
|
async close(): Promise<void> {
|
|
188
188
|
if( closed ) return
|
|
@@ -196,10 +196,10 @@ export async function connectDiscord( will: Will, opts: DiscordBridgeOptions ):
|
|
|
196
196
|
|
|
197
197
|
/** Build a real discord.js client (lazy import keeps it out of non-Discord hosts). */
|
|
198
198
|
async function createDiscordClient(): Promise<DiscordLikeClient> {
|
|
199
|
-
let mod: typeof import(
|
|
200
|
-
try { mod = await import(
|
|
199
|
+
let mod: typeof import('discord.js')
|
|
200
|
+
try { mod = await import('discord.js') }
|
|
201
201
|
catch {
|
|
202
|
-
throw new Error(
|
|
202
|
+
throw new Error('discord.js is not installed (it is an optionalDependency) — run `bun add discord.js` / `npm i discord.js` and retry.')
|
|
203
203
|
}
|
|
204
204
|
const { Client, GatewayIntentBits, Partials } = mod
|
|
205
205
|
return new Client( {
|
package/src/channels/roster.ts
CHANGED
|
@@ -42,7 +42,7 @@ export class ChannelRoster {
|
|
|
42
42
|
constructor( private readonly path: string ) {
|
|
43
43
|
if( existsSync( path ) ){
|
|
44
44
|
try {
|
|
45
|
-
const raw = JSON.parse( readFileSync( path, 'utf8'
|
|
45
|
+
const raw = JSON.parse( readFileSync( path, 'utf8') ) as RosterEntry[]
|
|
46
46
|
for( const e of Array.isArray( raw ) ? raw : [] ) this.entries.set( e.entityId, e )
|
|
47
47
|
}
|
|
48
48
|
catch { /* a corrupt roster is not worth failing a boot over — start fresh */ }
|
package/src/channels/types.ts
CHANGED
|
@@ -36,7 +36,7 @@ export function chunkText( text: string, max: number ): string[] {
|
|
|
36
36
|
while( rest.length > max ){
|
|
37
37
|
// Prefer a paragraph break, then a line break, then a space — else hard-cut.
|
|
38
38
|
const window = rest.slice( 0, max )
|
|
39
|
-
const cut = Math.max( window.lastIndexOf(
|
|
39
|
+
const cut = Math.max( window.lastIndexOf('\n\n'), window.lastIndexOf('\n'), window.lastIndexOf(' ') )
|
|
40
40
|
const at = cut > max * 0.5 ? cut : max
|
|
41
41
|
chunks.push( rest.slice( 0, at ).trimEnd() )
|
|
42
42
|
rest = rest.slice( at ).trimStart()
|