@polycode-projects/the-mechanical-code-talker 5.0.27 → 5.0.28
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/corpus/worlds/index.json.gz +0 -0
- package/corpus/worlds/manifest.json +27 -17
- package/corpus/worlds/shards/river-crossing.jsonl.gz +0 -0
- package/corpus/worlds/shards/town-square-chapel.jsonl.gz +0 -0
- package/corpus/worlds/shards/town-square-market.jsonl.gz +0 -0
- package/corpus/worlds/shards/town-square.jsonl.gz +0 -0
- package/corpus/worlds/src/river-crossing.jsonl +29 -0
- package/corpus/worlds/src/town-square-chapel.jsonl +12 -8
- package/corpus/worlds/src/town-square-market.jsonl +12 -8
- package/corpus/worlds/src/town-square.jsonl +12 -8
- package/package.json +1 -1
- package/src/adapters/memory/inspect.mjs +37 -0
- package/src/domain/agent-traits.mjs +282 -0
- package/src/domain/choice-question.mjs +135 -6
- package/src/domain/el-classify.mjs +39 -7
- package/src/domain/fact-phrase.mjs +7 -4
- package/src/domain/interpret/normalize.mjs +58 -2
- package/src/domain/town-square-world.mjs +44 -19
- package/src/services/adventure.mjs +5 -16
- package/src/services/agent-editor.mjs +216 -0
- package/src/services/chat-session.mjs +26 -5
- package/src/services/chat.mjs +118 -58
- package/src/services/mudiii-scene.mjs +32 -5
- package/src/services/mudiii-turn.mjs +7 -3
- package/src/services/mudiii-viz.mjs +215 -1
- package/src/services/predator-prey.mjs +157 -24
- package/src/surfaces/web/chat-browser-entry.mjs +69 -3
- package/src/surfaces/web/memory-ask-browser.bundle.js +155 -155
- package/src/surfaces/web/mudiii-browser-entry.mjs +35 -0
- package/src/surfaces/web/turn-session.mjs +13 -9
|
@@ -19,6 +19,10 @@ import {
|
|
|
19
19
|
import { findActionPath } from "../../domain/planning.mjs";
|
|
20
20
|
import { DEFAULT_GAME_CONFIG } from "../../domain/game-config.mjs";
|
|
21
21
|
import { parseMudEditorText, planMudEditorSync, gridWorldEditorState } from "../../services/mud-editor.mjs";
|
|
22
|
+
import {
|
|
23
|
+
parseAgentEditorText, planAgentEditorSync, renderAgentEditorText, renderAgentClassText,
|
|
24
|
+
} from "../../services/agent-editor.mjs";
|
|
25
|
+
import { agentTraitsOf } from "../../domain/agent-traits.mjs";
|
|
22
26
|
import { pillsForMudiii } from "../../services/mudiii-turn.mjs";
|
|
23
27
|
import { relatedForTerm } from "../../domain/skos-view.mjs";
|
|
24
28
|
import { classAncestorChain } from "../../domain/sprite-map.mjs";
|
|
@@ -305,6 +309,29 @@ export async function createMudiiiSession(
|
|
|
305
309
|
return engPlaceFood(memoryDir, { layout, ...opts });
|
|
306
310
|
}
|
|
307
311
|
|
|
312
|
+
/** The actor card's own store sync — agent-editor.mjs's closed table,
|
|
313
|
+
* disjoint from `applyEdit`'s world table. `subject` is whichever id the
|
|
314
|
+
* card is scoped to when this is called: an instance id on the "this
|
|
315
|
+
* goblin" tab, the class name itself on the "all goblins" tab — either
|
|
316
|
+
* way `planAgentEditorSync` only ever reads and writes rows whose own
|
|
317
|
+
* subject is that one id, so an actor edit can reach no instance, no
|
|
318
|
+
* class and no placement it was not asked to touch. Never calls
|
|
319
|
+
* `recast`: a trait is not where anything stands. */
|
|
320
|
+
async function applyAgentEdit(subject, text) {
|
|
321
|
+
const rows = readFactRows(await loadMemory(memoryDir));
|
|
322
|
+
const { triples, unrecognized } = parseAgentEditorText(text);
|
|
323
|
+
const { toAppend, toRemoveIds } = planAgentEditorSync(rows, subject, triples);
|
|
324
|
+
if (toAppend.length) {
|
|
325
|
+
await appendFacts(memoryDir, toAppend.map((f) => ({
|
|
326
|
+
subject: f.subject, predicate: f.predicate, object: f.object, provenance: `actor-edit:${subject}`,
|
|
327
|
+
})));
|
|
328
|
+
}
|
|
329
|
+
const removed = unrecognized.length === 0 && toRemoveIds.length
|
|
330
|
+
? (await removeFacts(memoryDir, toRemoveIds)).removed.length
|
|
331
|
+
: 0;
|
|
332
|
+
return { unrecognized, added: toAppend.length, removed };
|
|
333
|
+
}
|
|
334
|
+
|
|
308
335
|
return {
|
|
309
336
|
memoryDir,
|
|
310
337
|
codeGraph,
|
|
@@ -317,6 +344,7 @@ export async function createMudiiiSession(
|
|
|
317
344
|
board,
|
|
318
345
|
snapshot,
|
|
319
346
|
applyEdit,
|
|
347
|
+
applyAgentEdit,
|
|
320
348
|
placeFood,
|
|
321
349
|
};
|
|
322
350
|
}
|
|
@@ -340,5 +368,12 @@ publishTmctSurface({
|
|
|
340
368
|
// cursor: the lateral SKOS neighbourhood and the vertical is-a chain.
|
|
341
369
|
relatedForTerm, classAncestorChain,
|
|
342
370
|
routeBetweenCells,
|
|
371
|
+
// What the page's scene boot reads to resolve each agent's stated
|
|
372
|
+
// display name and model off the rows, class chain included.
|
|
373
|
+
agentTraitsOf,
|
|
374
|
+
// The actor card's own render half — agent-editor.mjs leans on
|
|
375
|
+
// agent-traits.mjs's class-chain walk, so (like agentTraitsOf) it
|
|
376
|
+
// reaches the page through this bag rather than a `.toString()` splice.
|
|
377
|
+
renderAgentEditorText, renderAgentClassText,
|
|
343
378
|
},
|
|
344
379
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// entry.mjs, ledger-browser-entry.mjs, adventure-browser-entry.mjs, spider-
|
|
4
4
|
// fly-browser-entry.mjs, plan-browser-entry.mjs, research-browser-entry.mjs,
|
|
5
5
|
// mud-browser-entry.mjs, sprites-browser-entry.mjs): a closure over
|
|
6
|
-
// focus/last/planState/researchState, a `try { runTurn(...) } catch` that
|
|
6
|
+
// focus/last/planState/researchState/newsState, a `try { runTurn(...) } catch` that
|
|
7
7
|
// turns a throw into a safe answer instead of ending the session (the page
|
|
8
8
|
// has no other chance to show that turn's reply), the post-call state
|
|
9
9
|
// capture, and a return shape covering every field one caller or another
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// The nine differ in what they hand `runTurn` beyond the common core
|
|
20
20
|
// (`synthesisBudget`, `gameConfig`, `researchConfig`,
|
|
21
21
|
// `actingSubject`, a per-character `sessionId`...) and in what they do with a
|
|
22
|
-
// turn's result besides the standard focus/last/planState/researchState fold
|
|
22
|
+
// turn's result besides the standard focus/last/planState/researchState/newsState fold
|
|
23
23
|
// (sync an externally-held plan holder, grow a visited-rooms set, bump a
|
|
24
24
|
// per-character turn tally). `buildExtraOptions`/`captureExtraState` below
|
|
25
25
|
// are exactly those two seams — everything else is common enough to live
|
|
@@ -40,7 +40,7 @@ function turnErrorFallback(message) {
|
|
|
40
40
|
* `createTurnSession({ memoryDir, graph, lexicon, sessionId, vocabHint,
|
|
41
41
|
* buildExtraOptions, captureExtraState })` — a live turn-dispatch session
|
|
42
42
|
* over the real engine (`runTurn`), threading focus/last/planState/
|
|
43
|
-
* researchState across calls the way every browser chat dock does.
|
|
43
|
+
* researchState/newsState across calls the way every browser chat dock does.
|
|
44
44
|
*
|
|
45
45
|
* `vocabHint` is the session-lifetime hint every caller computes once at
|
|
46
46
|
* creation (a fixed string, or `vocabExampleHint(vocabSeeded)`'s result) —
|
|
@@ -51,19 +51,19 @@ function turnErrorFallback(message) {
|
|
|
51
51
|
* (`synthesisBudget`, `gameConfig`, `researchConfig`,
|
|
52
52
|
* a per-character `actingSubject`/`sessionId`, or a `planState` read from an
|
|
53
53
|
* external holder instead of this closure's own). `state` is
|
|
54
|
-
* `{ focus, last, planState, researchState }` as this turn is about to run;
|
|
54
|
+
* `{ focus, last, planState, researchState, newsState }` as this turn is about to run;
|
|
55
55
|
* `callArgs` is whatever extra argument `turn(line, callArgs)` was given
|
|
56
56
|
* (plan-browser-entry.mjs's own per-call `{ maxDepth }` override, for one).
|
|
57
57
|
*
|
|
58
58
|
* `captureExtraState(result, state, callArgs)` (optional, may be async) runs
|
|
59
59
|
* once after a SUCCESSFUL turn, with `state` already folded forward
|
|
60
|
-
* (focus/last/planState/researchState updated) — the caller's own chance to
|
|
60
|
+
* (focus/last/planState/researchState/newsState updated) — the caller's own chance to
|
|
61
61
|
* do further bookkeeping (sync an external plan holder, reload memory to
|
|
62
62
|
* grow a visited-rooms set, bump a turn tally). Never runs on a throw: none
|
|
63
63
|
* of the nine originals touch their own state when `runTurn` itself failed.
|
|
64
64
|
*
|
|
65
65
|
* Returns `{ memoryDir, sessionId, graph, turn, focus, last, planState,
|
|
66
|
-
* setPlanState, researchState, setResearchState }`. `graph` is the one this
|
|
66
|
+
* setPlanState, researchState, setResearchState, newsState, setNewsState }`. `graph` is the one this
|
|
67
67
|
* session was built over, exposed so a caller can put a question to the same
|
|
68
68
|
* graph its turns run against (engine-surface.mjs's `graphAsk`) without
|
|
69
69
|
* holding a second reference to it. `turn(line, callArgs)`
|
|
@@ -87,15 +87,16 @@ export function createTurnSession({
|
|
|
87
87
|
let last = null;
|
|
88
88
|
let planState = null;
|
|
89
89
|
let researchState = null;
|
|
90
|
+
let newsState = null;
|
|
90
91
|
|
|
91
92
|
async function turn(line, callArgs) {
|
|
92
|
-
const before = { focus, last, planState, researchState };
|
|
93
|
+
const before = { focus, last, planState, researchState, newsState };
|
|
93
94
|
const extra = buildExtraOptions(before, callArgs) || {};
|
|
94
95
|
let result;
|
|
95
96
|
try {
|
|
96
97
|
result = await runTurn(line, {
|
|
97
98
|
config: null, source: null, graph, focus, last, memoryDir, sessionId,
|
|
98
|
-
env: {}, lexicon, vocabHint, planState, researchState, uiContext: "browser",
|
|
99
|
+
env: {}, lexicon, vocabHint, planState, researchState, newsState, uiContext: "browser",
|
|
99
100
|
...extra,
|
|
100
101
|
});
|
|
101
102
|
} catch (e) {
|
|
@@ -106,7 +107,8 @@ export function createTurnSession({
|
|
|
106
107
|
last = result.last;
|
|
107
108
|
if ("planState" in result) planState = result.planState;
|
|
108
109
|
if ("researchState" in result) researchState = result.researchState;
|
|
109
|
-
|
|
110
|
+
if ("newsState" in result) newsState = result.newsState;
|
|
111
|
+
await captureExtraState(result, { focus, last, planState, researchState, newsState }, callArgs);
|
|
110
112
|
return {
|
|
111
113
|
answer: result.answer,
|
|
112
114
|
end: Boolean(result.end),
|
|
@@ -126,6 +128,8 @@ export function createTurnSession({
|
|
|
126
128
|
setPlanState(next) { planState = next; },
|
|
127
129
|
get researchState() { return researchState; },
|
|
128
130
|
setResearchState(next) { researchState = next; },
|
|
131
|
+
get newsState() { return newsState; },
|
|
132
|
+
setNewsState(next) { newsState = next; },
|
|
129
133
|
turn,
|
|
130
134
|
};
|
|
131
135
|
}
|