@polycode-projects/the-mechanical-code-talker 3.0.1 → 3.0.3

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.
@@ -28,6 +28,7 @@ import * as defaultSource from "../adapters/source.mjs";
28
28
  import { resolveExtensions, mergedLexiconExtra } from "./extensions.mjs";
29
29
  import { runTurn, hasSeededVocabulary, vocabExampleHint } from "./chat.mjs";
30
30
  import { resolveGameConfig } from "../domain/game-config.mjs";
31
+ import { emptyRecord, resolveDiscourseConfig } from "../domain/discourse.mjs";
31
32
  import { resolveResearchConfig } from "./research.mjs";
32
33
  import { sessionLogHeaderMarkdown, sessionLogTurnMarkdown, sessionLogEndMarkdown } from "./session-log-format.mjs";
33
34
 
@@ -351,6 +352,9 @@ export async function createSession({
351
352
  let last = null; // the last dispatched answer ({query,answer,detail}) — why/say-more re-renders it
352
353
  let planState = null; // the in-progress plan (goals/moves/cursor) — cleared by completion or a fresh goal, never by an aside
353
354
  let researchState = null; // the in-progress research queue — advanced by "research next", cleared by completion or "research stop"
355
+ // The typed discourse record ([discourse] max_referents caps it) — session-scoped
356
+ // like the focus, threaded turn to turn, never persisted.
357
+ let discourseRecord = emptyRecord(resolveDiscourseConfig(toml));
354
358
  let closed = false;
355
359
 
356
360
  return {
@@ -375,7 +379,7 @@ export async function createSession({
375
379
  async turn(line) {
376
380
  let result;
377
381
  try {
378
- result = await runTurn(line, { config, source, graph, focus, last, memoryDir, sessionId, env, lexicon, narrate: narrateOn, liveReference: liveReferenceOn, vocabHint, tel, biasByBundle, planState, gameConfig, researchState, researchConfig });
382
+ result = await runTurn(line, { config, source, graph, focus, last, memoryDir, sessionId, env, lexicon, narrate: narrateOn, liveReference: liveReferenceOn, vocabHint, tel, biasByBundle, planState, gameConfig, researchState, researchConfig, discourse: discourseRecord });
379
383
  } catch (e) {
380
384
  const ts = new Date().toISOString();
381
385
  const message = e instanceof Error ? e.message : String(e);
@@ -391,6 +395,7 @@ export async function createSession({
391
395
  last = nextLast;
392
396
  if ("planState" in result) planState = result.planState;
393
397
  if ("researchState" in result) researchState = result.researchState;
398
+ if ("discourse" in result) discourseRecord = result.discourse;
394
399
  // /narrate on|off and /wiki on|off (runCommand) ride the turn RESULT the
395
400
  // same way a focus update does — apply them to this handle's
396
401
  // session-scoped state.