@mindot/will 0.4.0 → 0.5.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as OutboundEnvelope, A as AckResult, a as ExternalTransport, I as InboundEnvelope, T as TransportStatus, S as SimulationContext, b as SeededPRNG, c as SimulationEntity, d as Timestamp, e as SimulationEvent, f as StateManager, g as Tick, h as SimulationState, R as RestoreOptions, i as StateCommands, j as ReasoningFootprint, k as ReadonlySimulationState, C as ConflictReport, l as ConflictStrategy, m as ConflictResolution } from './will-D-slky1N.js';
2
- export { n as AckEnvelope, o as ActionRequest, p as ActionResult, q as ActionSelector, r as ActivityEnvelope, s as ActivityEvent, t as ActivityEventHandler, u as AestheticEvaluator, v as AestheticEvaluatorConfig, w as AffectiveBlender, x as AffectiveBlenderConfig, y as AffordanceSynthesizer, z as AsyncEngine, B as AsyncEngineConfig, D as AttachmentEvaluator, F as AttachmentEvaluatorConfig, G as AttentionAllocator, H as AttentionAllocatorConfig, J as AuditionEngine, K as AutobiographicalNarrator, L as AutobiographicalNarratorConfig, M as BehavioralProbeResult, N as BiasDetector, P as BiasDetectorConfig, Q as BunStorageAdapter, U as ChunkEnvelope, V as CircadianConfig, X as CircadianOscillator, Y as ClockConfig, Z as Cognition, _ as CognitiveHealth, $ as ConfidenceCalibrator, a0 as ConfidenceCalibratorConfig, a1 as Coordinates, a2 as CreateWillOptions, a3 as DefaultEventBus, a4 as DefaultMetricCollector, a5 as DefaultOrchestrator, a6 as DefaultReplayRecorder, a7 as DefaultReplaySession, a8 as DefaultScenario, a9 as DefaultSerializer, aa as DefaultSimulation, ab as DefaultSimulationClock, ac as DefaultStateManager, ad as DefaultVectorMemoryAdapter, ae as DeliberationEngine, af as DeltaEncoder, ag as DeltaSnapshot, ah as DreamSimulator, ai as DreamSimulatorConfig, aj as Duration, ak as EffectorDeclaration, al as EffectorEntry, E as EffectorHandler, am as EffectorResult, an as EffectorSpec, ao as EmbeddingProvider, ap as EmpathySimulator, aq as EmpathySimulatorConfig, ar as EnergyRegulator, as as EnergyRegulatorConfig, at as EngineRegistry, au as EngineResult, av as Envelope, aw as EpisodicConsolidator, ax as EpisodicConsolidatorConfig, ay as EventBus, az as EventBusConfig, aA as EventFilter, aB as EventHandler, aC as EventPayload, aD as ExecutiveEngine, aE as ExecutiveEngineConfig, aF as Exteroception, aG as ExteroceptionConfig, aH as ForgettingCurve, aI as ForgettingCurveConfig, aJ as FrustrationEvaluator, aK as FrustrationEvaluatorConfig, aL as GoalManager, aM as GoalManagerConfig, aN as GustationEngine, aO as InboundMessageEnvelope, aP as InboundPerceptEnvelope, aQ as InhibitionController, aR as InhibitionControllerConfig, aS as Interoception, aT as InteroceptionConfig, aU as IntrospectionEngine, aV as IntrospectionEngineConfig, aW as KnownEntityTracker, aX as KnownEntityTrackerConfig, aY as LLMCompletionRecord, aZ as LLMCompletionSink, a_ as LossEvaluator, a$ as LossEvaluatorConfig, b0 as MessageEnvelope, b1 as MetricCollector, b2 as MetricPoint, b3 as MinimalContext, b4 as MockEmbedder, b5 as MoralEvaluator, b6 as MoralEvaluatorConfig, b7 as MotorSchemaExecutor, b8 as NoveltyDetector, b9 as NoveltyDetectorConfig, ba as OlfactionEngine, bb as OpenAICompatibleEmbedder, bc as Orchestrator, bd as OrchestratorConfig, be as OutboxMessage, bf as PMABehavioral, bg as PMABelief, bh as PMAEmotionalBaseline, bi as PMAEvalHarness, bj as PMAGoal, bk as PMAIdentity, bl as PMAProbe, bm as PMASnapshot, bn as PerceptEnvelope, bo as PersonaConsolidator, bp as PersonaConsolidatorConfig, bq as PlanningEngine, br as PlanningEngineConfig, bs as ReafferenceEngine, bt as ReconstructionFidelityReport, bu as ReconstructionFidelityScores, bv as RecordUsageInput, bw as ReplayComparison, bx as ReplayConfig, by as ReplayDifference, bz as ReplayManager, bA as ReplayMetadata, bB as ReplayRecord, bC as ReplayRecorder, bD as ReplaySession, bE as ReplyEnvelope, bF as ReputationTracker, bG as ReputationTrackerConfig, bH as RewardEvaluator, bI as RewardEvaluatorConfig, bJ as Scenario, bK as ScenarioConfig, bL as ScenarioValidationResult, bM as SchemaPrecondition, bN as SelfModelUpdater, bO as SelfModelUpdaterConfig, bP as SemanticIntegrator, bQ as SemanticIntegratorConfig, bR as SensoryInput, bS as SerializationConfig, bT as SerializationFormat, bU as SerializedEntity, bV as SerializedState, bW as Serializer, bX as SessionLogEnvelope, bY as Simulation, bZ as SimulationClock, b_ as SimulationConfig, b$ as SimulationEngine, c0 as SimulationEventBase, c1 as SimulationEventListener, c2 as SleepPressureConfig, c3 as SleepPressureRegulator, c4 as SocialPerception, c5 as SocialPerceptionConfig, c6 as SomatosensationEngine, c7 as SpacedRepetition, c8 as SpacedRepetitionConfig, c9 as StateSnapshot, ca as Stimulus, cb as StorageAdapter, cc as StressRegulator, cd as StressRegulatorConfig, ce as TaskSwitcher, cf as TaskSwitcherConfig, cg as TextMessage, ch as TheoryOfMind, ci as TheoryOfMindConfig, cj as ThreatEvaluator, ck as ThreatEvaluatorConfig, cl as TickListener, cm as TokenLedgerRecord, cn as TokenReportEnvelope, co as TokenTracker, cp as TokenTrackerConfig, cq as TokenUsage, cr as VectorIndex, cs as VectorMemoryAdapter, ct as VectorMemoryConfig, cu as VectorQueryFilter, cv as VectorQueryResult, cw as VectorRecord, cx as VisionEngine, cy as VoiceChunk, W as Will, cz as WillAffect, cA as WillConfig, cB as WillEffectorAct, cC as WillInstance, cD as WillMessage, cE as WillStateSummary, cF as WillStatus, cG as WillStem, cH as WillSummary, cI as WorkingMemory, cJ as WorkingMemoryConfig, cK as WorldEntity, cL as WorldInterface, cM as assembleMind, cN as clearCompletionRecorder, cO as effectorInvocation, cP as effectorInvocationEnvelope, cQ as getCompletionRecorder, cR as resolvePricing, cS as setCompletionRecorder } from './will-D-slky1N.js';
1
+ import { O as OutboundEnvelope, A as AckResult, a as ExternalTransport, I as InboundEnvelope, T as TransportStatus, S as SimulationContext, b as SeededPRNG, c as SimulationEntity, d as Timestamp, e as SimulationEvent, f as StateManager, g as Tick, h as SimulationState, R as RestoreOptions, i as StateCommands, j as ReasoningFootprint, k as ReadonlySimulationState, C as ConflictReport, l as ConflictStrategy, m as ConflictResolution } from './will-BDq-TMQr.js';
2
+ export { n as AckEnvelope, o as ActionRequest, p as ActionResult, q as ActionSelector, r as ActivityEnvelope, s as ActivityEvent, t as ActivityEventHandler, u as AestheticEvaluator, v as AestheticEvaluatorConfig, w as AffectiveBlender, x as AffectiveBlenderConfig, y as AffordanceSynthesizer, z as AsyncEngine, B as AsyncEngineConfig, D as AttachmentEvaluator, F as AttachmentEvaluatorConfig, G as AttentionAllocator, H as AttentionAllocatorConfig, J as AuditionEngine, K as AutobiographicalNarrator, L as AutobiographicalNarratorConfig, M as BehavioralProbeResult, N as BiasDetector, P as BiasDetectorConfig, Q as BunStorageAdapter, U as ChunkEnvelope, V as CircadianConfig, X as CircadianOscillator, Y as ClockConfig, Z as Cognition, _ as CognitiveHealth, $ as ConfidenceCalibrator, a0 as ConfidenceCalibratorConfig, a1 as Coordinates, a2 as CreateWillOptions, a3 as DefaultEventBus, a4 as DefaultMetricCollector, a5 as DefaultOrchestrator, a6 as DefaultReplayRecorder, a7 as DefaultReplaySession, a8 as DefaultScenario, a9 as DefaultSerializer, aa as DefaultSimulation, ab as DefaultSimulationClock, ac as DefaultStateManager, ad as DefaultVectorMemoryAdapter, ae as DeliberationEngine, af as DeltaEncoder, ag as DeltaSnapshot, ah as DreamSimulator, ai as DreamSimulatorConfig, aj as Duration, ak as EffectorDeclaration, al as EffectorEntry, E as EffectorHandler, am as EffectorResult, an as EffectorSpec, ao as EmbeddingProvider, ap as EmpathySimulator, aq as EmpathySimulatorConfig, ar as EnergyRegulator, as as EnergyRegulatorConfig, at as EngineRegistry, au as EngineResult, av as Envelope, aw as EpisodicConsolidator, ax as EpisodicConsolidatorConfig, ay as EventBus, az as EventBusConfig, aA as EventFilter, aB as EventHandler, aC as EventPayload, aD as ExecutiveEngine, aE as ExecutiveEngineConfig, aF as Exteroception, aG as ExteroceptionConfig, aH as ForgettingCurve, aI as ForgettingCurveConfig, aJ as FrustrationEvaluator, aK as FrustrationEvaluatorConfig, aL as GoalManager, aM as GoalManagerConfig, aN as GustationEngine, aO as InboundMessageEnvelope, aP as InboundPerceptEnvelope, aQ as InhibitionController, aR as InhibitionControllerConfig, aS as Interoception, aT as InteroceptionConfig, aU as IntrospectionEngine, aV as IntrospectionEngineConfig, aW as KnownEntityTracker, aX as KnownEntityTrackerConfig, aY as LLMCompletionRecord, aZ as LLMCompletionSink, a_ as LossEvaluator, a$ as LossEvaluatorConfig, b0 as MessageEnvelope, b1 as MetricCollector, b2 as MetricPoint, b3 as MinimalContext, b4 as MockEmbedder, b5 as MoralEvaluator, b6 as MoralEvaluatorConfig, b7 as MotorSchemaExecutor, b8 as NoveltyDetector, b9 as NoveltyDetectorConfig, ba as OlfactionEngine, bb as OpenAICompatibleEmbedder, bc as Orchestrator, bd as OrchestratorConfig, be as OutboxMessage, bf as PMABehavioral, bg as PMABelief, bh as PMAEmotionalBaseline, bi as PMAEvalHarness, bj as PMAGoal, bk as PMAIdentity, bl as PMAProbe, bm as PMASnapshot, bn as PerceptEnvelope, bo as PersonaConsolidator, bp as PersonaConsolidatorConfig, bq as PlanningEngine, br as PlanningEngineConfig, bs as ReafferenceEngine, bt as ReconstructionFidelityReport, bu as ReconstructionFidelityScores, bv as RecordUsageInput, bw as ReplayComparison, bx as ReplayConfig, by as ReplayDifference, bz as ReplayManager, bA as ReplayMetadata, bB as ReplayRecord, bC as ReplayRecorder, bD as ReplaySession, bE as ReplyEnvelope, bF as ReputationTracker, bG as ReputationTrackerConfig, bH as RewardEvaluator, bI as RewardEvaluatorConfig, bJ as Scenario, bK as ScenarioConfig, bL as ScenarioValidationResult, bM as SchemaPrecondition, bN as SelfModelUpdater, bO as SelfModelUpdaterConfig, bP as SemanticIntegrator, bQ as SemanticIntegratorConfig, bR as SensoryInput, bS as SerializationConfig, bT as SerializationFormat, bU as SerializedEntity, bV as SerializedState, bW as Serializer, bX as SessionLogEnvelope, bY as Simulation, bZ as SimulationClock, b_ as SimulationConfig, b$ as SimulationEngine, c0 as SimulationEventBase, c1 as SimulationEventListener, c2 as SleepPressureConfig, c3 as SleepPressureRegulator, c4 as SocialPerception, c5 as SocialPerceptionConfig, c6 as SomatosensationEngine, c7 as SpacedRepetition, c8 as SpacedRepetitionConfig, c9 as StateSnapshot, ca as Stimulus, cb as StorageAdapter, cc as StressRegulator, cd as StressRegulatorConfig, ce as TaskSwitcher, cf as TaskSwitcherConfig, cg as TextMessage, ch as TheoryOfMind, ci as TheoryOfMindConfig, cj as ThreatEvaluator, ck as ThreatEvaluatorConfig, cl as TickListener, cm as TokenLedgerRecord, cn as TokenReportEnvelope, co as TokenTracker, cp as TokenTrackerConfig, cq as TokenUsage, cr as VectorIndex, cs as VectorMemoryAdapter, ct as VectorMemoryConfig, cu as VectorQueryFilter, cv as VectorQueryResult, cw as VectorRecord, cx as VisionEngine, cy as VoiceChunk, W as Will, cz as WillAffect, cA as WillConfig, cB as WillEffectorAct, cC as WillInstance, cD as WillMessage, cE as WillStateSummary, cF as WillStatus, cG as WillStem, cH as WillSummary, cI as WorkingMemory, cJ as WorkingMemoryConfig, cK as WorldEntity, cL as WorldInterface, cM as assembleMind, cN as clearCompletionRecorder, cO as effectorInvocation, cP as effectorInvocationEnvelope, cQ as getCompletionRecorder, cR as resolvePricing, cS as setCompletionRecorder } from './will-BDq-TMQr.js';
3
3
 
4
4
  /** Decides how emit() resolves an ack for a given envelope. Default: acked via callback. */
5
5
  type AckPolicy = (env: OutboundEnvelope) => AckResult;
package/dist/index.js CHANGED
@@ -2814,6 +2814,11 @@ var MODEL_PRICING = {
2814
2814
  // Legacy aliases kept for backward compat
2815
2815
  "anthropic/claude-haiku-4": { input: 1, output: 5 },
2816
2816
  "anthropic/claude-opus-4": { input: 5, output: 25 },
2817
+ // Z.ai (GLM-5 family). `glm-5.2[1m]` is the same model asking for its 1M
2818
+ // context window — same rate, so it gets its own row rather than relying on
2819
+ // the normalizer (a future long-context tier would price differently).
2820
+ "glm/glm-5.2": { input: 1.4, output: 4.4 },
2821
+ "glm/glm-5.2[1m]": { input: 1.4, output: 4.4 },
2817
2822
  // Google
2818
2823
  "google/gemini-2.0-flash": { input: 0.1, output: 0.4 },
2819
2824
  "google/gemini-2.0-pro": { input: 1.25, output: 5 },
@@ -11699,6 +11704,38 @@ async function withGate(fn, label, gate = llmGate) {
11699
11704
  }
11700
11705
 
11701
11706
  // src/llm/index.ts
11707
+ var ANTHROPIC_WIRE = /* @__PURE__ */ new Set(["anthropic", "glm"]);
11708
+ function speaksAnthropicWire(provider) {
11709
+ return ANTHROPIC_WIRE.has(provider);
11710
+ }
11711
+ function defaultBaseFor(provider) {
11712
+ switch (provider) {
11713
+ case "anthropic":
11714
+ return "https://api.anthropic.com/v1";
11715
+ // Z.ai documents the base as `…/api/anthropic` because the Anthropic SDK
11716
+ // appends `/v1/messages`; this client appends `/messages`, so the version
11717
+ // segment belongs here — verified against the live endpoint.
11718
+ case "glm":
11719
+ return "https://api.z.ai/api/anthropic/v1";
11720
+ case "openai":
11721
+ return "https://api.openai.com/v1";
11722
+ case "deepseek":
11723
+ return "https://api.deepseek.com/v1";
11724
+ case "google":
11725
+ return "https://generativelanguage.googleapis.com/v1beta";
11726
+ }
11727
+ }
11728
+ function defaultModelFor(provider) {
11729
+ return provider === "glm" ? "glm-5.2" : "claude-sonnet-4-5-20250929";
11730
+ }
11731
+ function anthropicWireHeaders(provider, apiKey) {
11732
+ return {
11733
+ "Content-Type": "application/json",
11734
+ "anthropic-version": "2023-06-01",
11735
+ "x-api-key": apiKey,
11736
+ ...provider === "glm" ? { Authorization: `Bearer ${apiKey}` } : {}
11737
+ };
11738
+ }
11702
11739
  var DEFAULT_CALL_META = { category: "executive", attribute: "master", function: "decision" };
11703
11740
  var LLMDirector = class {
11704
11741
  _willId;
@@ -11801,7 +11838,7 @@ var LLMDirector = class {
11801
11838
  this._recordCompletion(systemPrompt, userMessage, tick, result2, Date.now() - start, true);
11802
11839
  return result2;
11803
11840
  }
11804
- const result = this._provider === "anthropic" ? await this._callAnthropicStream(systemPrompt, userMessage, onChunk, temperature) : await (async () => {
11841
+ const result = speaksAnthropicWire(this._provider) ? await this._callAnthropicStream(systemPrompt, userMessage, onChunk, temperature) : await (async () => {
11805
11842
  const r = await this._callProvider(systemPrompt, userMessage, temperature);
11806
11843
  onChunk(r.text);
11807
11844
  return r;
@@ -11881,11 +11918,7 @@ var LLMDirector = class {
11881
11918
  try {
11882
11919
  res = await fetch(`${this._resolvedBase()}/messages`, {
11883
11920
  method: "POST",
11884
- headers: {
11885
- "Content-Type": "application/json",
11886
- "anthropic-version": "2023-06-01",
11887
- "x-api-key": this._apiKey
11888
- },
11921
+ headers: anthropicWireHeaders(this._provider, this._apiKey),
11889
11922
  body: JSON.stringify({
11890
11923
  model: this._model,
11891
11924
  max_tokens: this._maxOutputTokens,
@@ -11960,7 +11993,7 @@ var LLMDirector = class {
11960
11993
  return result2;
11961
11994
  }
11962
11995
  const result = await withGate(
11963
- () => this._provider === "anthropic" ? this._callAnthropicStream(systemPrompt, userMessage, () => {
11996
+ () => speaksAnthropicWire(this._provider) ? this._callAnthropicStream(systemPrompt, userMessage, () => {
11964
11997
  }, temperature) : this._callProvider(systemPrompt, userMessage, temperature),
11965
11998
  "executive/direct"
11966
11999
  );
@@ -11972,6 +12005,8 @@ var LLMDirector = class {
11972
12005
  switch (this._provider) {
11973
12006
  case "anthropic":
11974
12007
  return this._callAnthropic(systemPrompt, userMessage, temperature);
12008
+ case "glm":
12009
+ return this._callAnthropic(systemPrompt, userMessage, temperature);
11975
12010
  case "deepseek":
11976
12011
  return this._callOpenAI(systemPrompt, userMessage, temperature);
11977
12012
  case "openai":
@@ -11984,16 +12019,7 @@ var LLMDirector = class {
11984
12019
  }
11985
12020
  /** Default API base URL (including version segment) for a provider. */
11986
12021
  _baseFor(provider) {
11987
- switch (provider) {
11988
- case "anthropic":
11989
- return "https://api.anthropic.com/v1";
11990
- case "openai":
11991
- return "https://api.openai.com/v1";
11992
- case "deepseek":
11993
- return "https://api.deepseek.com/v1";
11994
- case "google":
11995
- return "https://generativelanguage.googleapis.com/v1beta";
11996
- }
12022
+ return defaultBaseFor(provider);
11997
12023
  }
11998
12024
  /** Resolved API base: explicit override wins, else the provider default. */
11999
12025
  _resolvedBase() {
@@ -12033,15 +12059,11 @@ var LLMDirector = class {
12033
12059
  };
12034
12060
  const res = await this._fetchWithTimeout(`${this._resolvedBase()}/messages`, {
12035
12061
  method: "POST",
12036
- headers: {
12037
- "Content-Type": "application/json",
12038
- "anthropic-version": "2023-06-01",
12039
- "x-api-key": this._apiKey
12040
- },
12062
+ headers: anthropicWireHeaders(this._provider, this._apiKey),
12041
12063
  body: JSON.stringify(body)
12042
12064
  });
12043
12065
  if (!res.ok)
12044
- throw new Error(`Anthropic API ${res.status}: ${(await res.text()).slice(0, 300)}`);
12066
+ throw new Error(`${this._provider} API ${res.status}: ${(await res.text()).slice(0, 300)}`);
12045
12067
  const data = await res.json(), text = data.content.find((b) => b.type === "text")?.text ?? "";
12046
12068
  return {
12047
12069
  text,
@@ -12821,7 +12843,7 @@ var ExecutiveEngine = class extends AsyncEngine {
12821
12843
  this._gatingState.executiveInterval = rtConfig.executiveInterval;
12822
12844
  this._gatingState.cooldownTicks = rtConfig.cooldownTicks;
12823
12845
  if (!this._llmDirector && this._willId) {
12824
- const execModel = this._models.executive ?? process.env.WILL_LLM_MODEL ?? "claude-sonnet-4-5-20250929";
12846
+ const execModel = this._models.executive ?? process.env.WILL_LLM_MODEL ?? defaultModelFor(this._llm?.provider ?? process.env.WILL_LLM_PROVIDER ?? "anthropic");
12825
12847
  this._llmDirector = this._directorFor(execModel);
12826
12848
  this._summarizer?.attachLLMDirector(this._directorFor(this._models.summarizer ?? execModel));
12827
12849
  }
@@ -23151,12 +23173,13 @@ async function checkIdentityCoherence(input, reviewer) {
23151
23173
  return { ok: !issues.some((i) => i.severity === "error"), ran: true, issues, raw: text };
23152
23174
  }
23153
23175
  async function reviewIdentityCoherence(input, opts = {}) {
23176
+ const provider = process.env.WILL_LLM_PROVIDER ?? "anthropic";
23154
23177
  const director = new LLMDirector({
23155
23178
  willId: opts.willId ?? "identity-coherence",
23156
- model: process.env.WILL_LLM_MODEL ?? "claude-sonnet-4-5-20250929",
23179
+ model: process.env.WILL_LLM_MODEL ?? defaultModelFor(provider),
23157
23180
  maxOutputTokens: 512,
23158
23181
  apiKey: process.env.WILL_LLM_API_KEY ?? process.env.ANTHROPIC_API_KEY ?? "",
23159
- provider: process.env.WILL_LLM_PROVIDER ?? "anthropic",
23182
+ provider,
23160
23183
  sessionLogger: null,
23161
23184
  baseUrl: process.env.WILL_LLM_BASE_URL ?? process.env.OPENAI_BASE_URL,
23162
23185
  // When a per-Will tracker is supplied, the creation-time review records under
@@ -26469,7 +26492,9 @@ var Will = class _Will {
26469
26492
  }
26470
26493
  // ── Internals ──────────────────────────────────────────────
26471
26494
  _buildConfig(id, opts) {
26472
- const useMock = (opts.llm ?? (process.env.ANTHROPIC_API_KEY ? "anthropic" : "mock")) === "mock";
26495
+ const mode = opts.llm ?? (process.env.ANTHROPIC_API_KEY ? "anthropic" : process.env.ZAI_API_KEY ? "glm" : "mock");
26496
+ const useMock = mode === "mock";
26497
+ const llmConfig = mode === "glm" ? { provider: "glm", ...opts.llmConfig } : opts.llmConfig;
26473
26498
  return {
26474
26499
  id,
26475
26500
  name: opts.name,
@@ -26481,7 +26506,7 @@ var Will = class _Will {
26481
26506
  },
26482
26507
  anatomy: opts.anatomy ?? "mind",
26483
26508
  model: opts.model,
26484
- llm: opts.llmConfig,
26509
+ llm: llmConfig,
26485
26510
  testMode: useMock,
26486
26511
  persistentMemory: opts.persist ?? false,
26487
26512
  snapshotInterval: 100,