@polycode-projects/the-mechanical-code-talker 4.1.0 → 4.1.2
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 +31 -18
- package/bin/tmct.mjs +3 -0
- package/data/templates/responses.jsonl +3 -0
- package/package.json +2 -1
- package/src/adapters/memory/core.mjs +1358 -196
- package/src/adapters/memory/inspect.mjs +11 -0
- package/src/adapters/memory/shacl.mjs +38 -0
- package/src/adapters/p2p/webrtc-transport.mjs +28 -5
- package/src/domain/ask-vocab.mjs +39 -0
- package/src/domain/ask.mjs +183 -34
- package/src/domain/grammar/assert.mjs +8 -2
- package/src/domain/hanoi-board.mjs +232 -0
- package/src/domain/ingest-facts.mjs +120 -0
- package/src/domain/interpret/normalize.mjs +49 -0
- package/src/domain/memory/compaction.mjs +284 -0
- package/src/domain/memory/resolution.mjs +171 -0
- package/src/domain/memory/trust.mjs +175 -5
- package/src/domain/memory-facts.mjs +139 -0
- package/src/domain/p2p/facts.mjs +21 -0
- package/src/domain/p2p/peer-id.mjs +15 -0
- package/src/domain/p2p/provenance-relabel.mjs +13 -2
- package/src/domain/p2p/sync-filter.mjs +5 -1
- package/src/domain/p2p/wire.mjs +7 -4
- package/src/domain/scene-compose.mjs +2 -2
- package/src/domain/sprite-facts.mjs +0 -0
- package/src/domain/sprite-request.mjs +1 -1
- package/src/services/adventure-viz.mjs +43 -39
- package/src/services/adventure.mjs +70 -44
- package/src/services/chat-page-viz.mjs +403 -332
- package/src/services/chat.mjs +274 -156
- package/src/services/code-explorer-viz.mjs +142 -55
- package/src/services/index.mjs +1 -1
- package/src/services/ingest-viz.mjs +153 -28
- package/src/services/ledger-viz.mjs +47 -47
- package/src/services/memory-panel-viz.mjs +8 -3
- package/src/services/mud-turn.mjs +11 -8
- package/src/services/mud-viz.mjs +474 -234
- package/src/services/p2p-room.mjs +110 -23
- package/src/services/plan-viz.mjs +72 -13
- package/src/services/research-viz.mjs +35 -24
- package/src/services/share-overlay-viz.mjs +623 -0
- package/src/services/spider-fly-viz.mjs +24 -24
- package/src/services/sprite-catalog-viz.mjs +307 -82
- package/src/surfaces/web/adventure-browser-entry.mjs +46 -25
- package/src/surfaces/web/chat-browser-entry.mjs +55 -9
- package/src/surfaces/web/code-explorer-browser-entry.mjs +30 -16
- package/src/surfaces/web/engine-surface.mjs +82 -0
- package/src/surfaces/web/ingest-browser-entry.mjs +81 -11
- package/src/surfaces/web/ledger-browser-entry.mjs +47 -14
- package/src/surfaces/web/memory-ask-browser-entry.mjs +55 -13
- package/src/surfaces/web/memory-ask-browser.bundle.js +149 -116
- package/src/surfaces/web/mud-browser-entry.mjs +77 -25
- package/src/surfaces/web/p2p-browser-entry.mjs +1 -1
- package/src/surfaces/web/plan-browser-entry.mjs +49 -11
- package/src/surfaces/web/research-browser-entry.mjs +33 -24
- package/src/surfaces/web/spider-fly-browser-entry.mjs +32 -13
- package/src/surfaces/web/sprites-browser-entry.mjs +51 -11
- package/src/surfaces/web/tmct-surface.mjs +159 -0
- package/src/surfaces/web/turn-session.mjs +16 -5
- package/src/tools/server.mjs +13 -6
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
// index.html already uses for chat-browser.bundle.js (both are the FULL
|
|
12
12
|
// turn engine, both generated fresh per build, neither meant to be
|
|
13
13
|
// committed), not memory-ask-browser.bundle.js's inlined-text arrangement
|
|
14
|
-
// (that bundle is small
|
|
15
|
-
//
|
|
14
|
+
// (that bundle is small and inlined specifically so ledger.html stays
|
|
15
|
+
// portable on its own — that reason doesn't apply here).
|
|
16
16
|
//
|
|
17
17
|
// renderSpiderFlyHtml() is pure: no I/O, deterministic output for identical
|
|
18
18
|
// input. scripts/build-demo-site.mjs calls it directly and writes the result
|
|
@@ -83,7 +83,7 @@ function webCellIds() {
|
|
|
83
83
|
* `geometry` is `{ parseCellId, cellId, directionDelta }` — the exact three
|
|
84
84
|
* grid-geometry primitives spider-fly-world.mjs exports, injected rather
|
|
85
85
|
* than imported so this function stays `.toString()`-splice safe (the
|
|
86
|
-
* inlined page calls it with `window.
|
|
86
|
+
* inlined page calls it with `window.tmct`'s own re-exports of the
|
|
87
87
|
* same three). Returns the ordered cell-id array (length > 1) or null.
|
|
88
88
|
*/
|
|
89
89
|
export function threadCellsForSpiderPlan(agents, geometry) {
|
|
@@ -558,7 +558,7 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
558
558
|
// lanes read exactly as much better with wink loaded as they do on every
|
|
559
559
|
// other page. Fired eagerly here so it is likely settled well before a
|
|
560
560
|
// visitor's first ordinary (non-game) question.
|
|
561
|
-
loadWinkVendor({ register: (factory) =>
|
|
561
|
+
loadWinkVendor({ register: (factory) => tmct.page.registerWinkModel(factory) })();
|
|
562
562
|
const el = (id) => document.getElementById(id);
|
|
563
563
|
const boardFrame = el("boardFrame");
|
|
564
564
|
const boardCanvas = el("board");
|
|
@@ -661,12 +661,12 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
661
661
|
// takes, answered by the same pure resolver the tool wraps (sprite-request.mjs,
|
|
662
662
|
// spliced in above) — the page holds the state and nothing else.
|
|
663
663
|
function resolveSpriteFace(spriteRequest) {
|
|
664
|
-
if (!window.
|
|
664
|
+
if (!window.tmct) return "";
|
|
665
665
|
return resolveSpriteRequest(spriteRequest, {
|
|
666
666
|
factRows: (session && session.taxonomyRows) || [],
|
|
667
667
|
templates: SPIDERFLY.spriteTemplates,
|
|
668
|
-
spriteRegistry:
|
|
669
|
-
resolveSpriteAsset:
|
|
668
|
+
spriteRegistry: tmct.page.SPRITE_REGISTRY,
|
|
669
|
+
resolveSpriteAsset: tmct.page.resolveSpriteAsset,
|
|
670
670
|
}).svg || "";
|
|
671
671
|
}
|
|
672
672
|
|
|
@@ -718,7 +718,7 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
718
718
|
for (const [id, a] of Object.entries(agents)) {
|
|
719
719
|
const cls = agentKindOf(id);
|
|
720
720
|
const node = ensureSpriteEl(id, cls, a);
|
|
721
|
-
const parsed =
|
|
721
|
+
const parsed = tmct.page.parseCellId(a.cell);
|
|
722
722
|
if (!parsed) continue;
|
|
723
723
|
const pct = cellCenterPct(parsed.x, parsed.y);
|
|
724
724
|
node.style.left = pct.leftPct + "%";
|
|
@@ -778,7 +778,7 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
778
778
|
spriteLayer.appendChild(node);
|
|
779
779
|
corpseEls[id] = node;
|
|
780
780
|
}
|
|
781
|
-
const deathCell =
|
|
781
|
+
const deathCell = tmct.page.parseCellId(corpse.cell);
|
|
782
782
|
if (!deathCell) continue;
|
|
783
783
|
const pct = cellCenterPct(deathCell.x, SPIDERFLY.gridSize);
|
|
784
784
|
node.style.left = pct.leftPct + "%";
|
|
@@ -863,9 +863,9 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
863
863
|
});
|
|
864
864
|
|
|
865
865
|
const threadGeometry = {
|
|
866
|
-
parseCellId: (id) =>
|
|
867
|
-
cellId: (x, y) =>
|
|
868
|
-
directionDelta:
|
|
866
|
+
parseCellId: (id) => tmct.page.parseCellId(id),
|
|
867
|
+
cellId: (x, y) => tmct.page.cellId(x, y),
|
|
868
|
+
directionDelta: tmct.page.DIRECTION_DELTA,
|
|
869
869
|
};
|
|
870
870
|
|
|
871
871
|
function drawBoard(agents, activeWebs) {
|
|
@@ -873,7 +873,7 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
873
873
|
boardCtx.clearRect(0, 0, w, h);
|
|
874
874
|
boardCtx.fillStyle = cssVar("--taught-soft") || "rgba(46,125,79,.12)";
|
|
875
875
|
for (const wc of SPIDERFLY.webCells) {
|
|
876
|
-
const p =
|
|
876
|
+
const p = tmct.page.parseCellId(wc);
|
|
877
877
|
boardCtx.fillRect((p.x - 1) * cellSize, (p.y - 1) * cellSize, cellSize, cellSize);
|
|
878
878
|
}
|
|
879
879
|
// A spider-built dynamic web is a distinct color from the always-on
|
|
@@ -884,7 +884,7 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
884
884
|
boardCtx.lineWidth = 1;
|
|
885
885
|
boardCtx.setLineDash([3, 2]);
|
|
886
886
|
for (const web of activeWebs || []) {
|
|
887
|
-
const p =
|
|
887
|
+
const p = tmct.page.parseCellId(web.cell);
|
|
888
888
|
if (!p) continue;
|
|
889
889
|
boardCtx.fillRect((p.x - 1) * cellSize, (p.y - 1) * cellSize, cellSize, cellSize);
|
|
890
890
|
boardCtx.strokeRect((p.x - 1) * cellSize + 0.5, (p.y - 1) * cellSize + 0.5, cellSize - 1, cellSize - 1);
|
|
@@ -904,7 +904,7 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
904
904
|
boardCtx.beginPath();
|
|
905
905
|
let prev = null;
|
|
906
906
|
thread.forEach((c, i) => {
|
|
907
|
-
const p =
|
|
907
|
+
const p = tmct.page.parseCellId(c);
|
|
908
908
|
const px = (p.x - 0.5) * cellSize, py = (p.y - 0.5) * cellSize;
|
|
909
909
|
if (i === 0) boardCtx.moveTo(px, py); else boardCtx.lineTo(px, py);
|
|
910
910
|
if (prev) threadHits.push({ x: (prev.x + px) / 2, y: (prev.y + py) / 2, step: i });
|
|
@@ -919,19 +919,19 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
919
919
|
if (!povAgentId) return;
|
|
920
920
|
const agent = lastAgents[povAgentId];
|
|
921
921
|
if (!agent) { povAgentId = null; return; }
|
|
922
|
-
const p =
|
|
922
|
+
const p = tmct.page.parseCellId(agent.cell);
|
|
923
923
|
// The live, slider-adjustable per-class radius (falling back to the
|
|
924
924
|
// engine's own shipped default before the session has finished
|
|
925
925
|
// booting) — a POV toggle always reflects whatever vision range this
|
|
926
926
|
// class currently actually has, not a fixed constant.
|
|
927
927
|
const radius = agentKindOf(povAgentId) === "spider"
|
|
928
|
-
? (liveConfig.spiderVisionRadius ??
|
|
929
|
-
: (liveConfig.flyVisionRadius ??
|
|
930
|
-
const visible = new Set(
|
|
928
|
+
? (liveConfig.spiderVisionRadius ?? tmct.page.DEFAULT_VISION_RADIUS)
|
|
929
|
+
: (liveConfig.flyVisionRadius ?? tmct.page.DEFAULT_VISION_RADIUS);
|
|
930
|
+
const visible = new Set(tmct.page.visibleCells(p.x, p.y, radius));
|
|
931
931
|
povCtx.fillStyle = "rgba(0,0,0,.55)";
|
|
932
932
|
for (let gy = 1; gy <= SPIDERFLY.gridSize; gy += 1) {
|
|
933
933
|
for (let gx = 1; gx <= SPIDERFLY.gridSize; gx += 1) {
|
|
934
|
-
if (visible.has(
|
|
934
|
+
if (visible.has(tmct.page.cellId(gx, gy))) continue;
|
|
935
935
|
povCtx.fillRect((gx - 1) * cellSize, (gy - 1) * cellSize, cellSize, cellSize);
|
|
936
936
|
}
|
|
937
937
|
}
|
|
@@ -983,7 +983,7 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
983
983
|
chatqEl.value = "";
|
|
984
984
|
addChatLine("u", esc(q));
|
|
985
985
|
withLock(async () => {
|
|
986
|
-
const result = await
|
|
986
|
+
const result = await tmct.turn(q);
|
|
987
987
|
addChatLine("a", esc(result.answer).replace(/\\n/g, "<br>"));
|
|
988
988
|
const snap = await session.snapshot();
|
|
989
989
|
redraw(snap.agents, snap.turn, snap.activeWebs);
|
|
@@ -1027,14 +1027,14 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
1027
1027
|
refreshPills();
|
|
1028
1028
|
|
|
1029
1029
|
// ---- deception pills (§A.2.4): a SEPARATE dynamic rail, alongside (never
|
|
1030
|
-
// replacing) the static one above.
|
|
1030
|
+
// replacing) the static one above. tmct.page.pillsForSpiderFly is the
|
|
1031
1031
|
// exact same pure function spider-fly-turn.mjs exports — this page never
|
|
1032
1032
|
// reimplements the true/false claim logic, only renders its output and
|
|
1033
1033
|
// fills #chatq on click, same click-to-fill discipline as every other
|
|
1034
1034
|
// pill on this page (never auto-submits).
|
|
1035
1035
|
function renderDynamicPills() {
|
|
1036
1036
|
if (!session || !Object.keys(lastAgents).length) { dynamicPillsEl.innerHTML = ""; return; }
|
|
1037
|
-
const result =
|
|
1037
|
+
const result = tmct.page.pillsForSpiderFly(lastAgents, selectedAddresseeId, {});
|
|
1038
1038
|
selectedAddresseeId = result.addresseeId;
|
|
1039
1039
|
const addrHtml = result.addressPills.map((p) =>
|
|
1040
1040
|
'<button type="button" class="pill" data-role="dyn-addr" data-id="' + esc(p.id) + '"'
|
|
@@ -1099,7 +1099,7 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
1099
1099
|
|
|
1100
1100
|
let tuningInitialized = false;
|
|
1101
1101
|
async function boot() {
|
|
1102
|
-
session = await
|
|
1102
|
+
session = await tmct.open();
|
|
1103
1103
|
// A reset mints a brand-new session (fresh board, fresh config) — the
|
|
1104
1104
|
// FIRST boot seeds the sliders from the engine's own shipped defaults;
|
|
1105
1105
|
// every boot after that re-applies whatever the visitor already had the
|