@polycode-projects/the-mechanical-code-talker 5.0.26 → 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 +2 -1
- package/src/adapters/memory/inspect.mjs +37 -0
- package/src/domain/agent-traits.mjs +282 -0
- package/src/domain/ask.mjs +19 -6
- package/src/domain/choice-question.mjs +135 -6
- package/src/domain/codegraph.mjs +8 -1
- 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 +221 -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/news-viz.mjs +489 -0
- 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/news-browser-entry.mjs +384 -0
- package/src/surfaces/web/turn-session.mjs +13 -9
|
@@ -717,6 +717,16 @@ ${RING_POINTS.map((point) => ` <span class="dir-slot dir-${point}"><button
|
|
|
717
717
|
</section>
|
|
718
718
|
</aside>
|
|
719
719
|
</div>
|
|
720
|
+
<section class="actor-card" id="mudiiiActorCard" aria-label="the followed actor's own facts">
|
|
721
|
+
<div class="actor-tabs" role="tablist" aria-label="edit this actor alone, or its whole class">
|
|
722
|
+
<button type="button" id="actorTabInstance" class="actor-tab" role="tab" aria-selected="true">this actor</button>
|
|
723
|
+
<button type="button" id="actorTabClass" class="actor-tab" role="tab" aria-selected="false">its whole class</button>
|
|
724
|
+
</div>
|
|
725
|
+
<p class="edit-lede" id="actorCardLede">Follow an agent to edit what it wants — the class tab changes every one that has not been edited on its own, and the next one spawned; this tab changes only the one selected above.</p>
|
|
726
|
+
<textarea id="actorEditorText" spellcheck="false" aria-label="the followed actor's own facts as plain sentences, one per line"></textarea>
|
|
727
|
+
<div class="chatpills" id="actorEditorPills" aria-label="related words for the term before the cursor"></div>
|
|
728
|
+
<p class="edit-status" id="actorEditorStatus" role="status"></p>
|
|
729
|
+
</section>
|
|
720
730
|
<section class="mudiii-chat" aria-label="talk to the square">
|
|
721
731
|
<div class="chatlog" id="chatLog" aria-live="polite"></div>
|
|
722
732
|
<div class="log-popup" id="chatLogPopup" role="dialog" aria-label="the whole reply" hidden>
|
|
@@ -964,6 +974,23 @@ const MUDIII_STYLE = `
|
|
|
964
974
|
.edit-placement-row { display: flex; gap: .4rem; }
|
|
965
975
|
.edit-empty { font-size: .74rem; font-style: italic; color: var(--square-stone-dark); }
|
|
966
976
|
|
|
977
|
+
.actor-card {
|
|
978
|
+
display: none; flex-direction: column; gap: .45rem; margin-bottom: 1rem;
|
|
979
|
+
background: var(--parchment); border: 1px solid var(--square-stone-dark); border-radius: 4px;
|
|
980
|
+
box-shadow: 0 2px 0 rgba(0,0,0,.18); padding: .7rem .8rem; min-width: 0;
|
|
981
|
+
}
|
|
982
|
+
body.editing .actor-card { display: flex; }
|
|
983
|
+
.actor-tabs { display: flex; gap: .35rem; }
|
|
984
|
+
.actor-tab { font-family: ${MONO_STACK}; font-size: .68rem; padding: .22rem .6rem; border: 1px solid var(--square-stone-dark); border-radius: 3px; background: rgba(255,255,255,.5); }
|
|
985
|
+
.actor-tab[aria-selected="true"] { background: var(--square-accent); border-color: var(--square-accent); }
|
|
986
|
+
#actorEditorText {
|
|
987
|
+
width: 100%; box-sizing: border-box; min-height: 12rem; resize: vertical;
|
|
988
|
+
font-family: ${MONO_STACK}; font-size: .74rem; line-height: 1.6;
|
|
989
|
+
color: var(--square-ink); background: rgba(255,255,255,.6);
|
|
990
|
+
border: 1px solid var(--square-stone-dark); border-radius: 3px; padding: .55rem .6rem;
|
|
991
|
+
}
|
|
992
|
+
#actorEditorText:disabled { opacity: .55; }
|
|
993
|
+
|
|
967
994
|
.mudiii-chat { background: var(--parchment); border: 1px solid var(--square-stone-dark); border-radius: 4px; box-shadow: 0 2px 0 rgba(0,0,0,.18); padding: .7rem .8rem; display: flex; flex-direction: column; gap: .5rem; }
|
|
968
995
|
.chatlog { min-height: 8rem; max-height: 16rem; overflow-y: auto; }
|
|
969
996
|
.chatlog > * { margin: 0 0 .32rem; }
|
|
@@ -1575,6 +1602,7 @@ function pageScript() {
|
|
|
1575
1602
|
camera = { mode: mode, selectedId: id, status: null };
|
|
1576
1603
|
renderCameraButtons();
|
|
1577
1604
|
renderDriveRing();
|
|
1605
|
+
if (editing) renderActorEditor();
|
|
1578
1606
|
sendCameraToScene(camera);
|
|
1579
1607
|
});
|
|
1580
1608
|
|
|
@@ -1669,6 +1697,42 @@ function pageScript() {
|
|
|
1669
1697
|
// mud.html's burrow-survey SVG, since a town square is a grid, not a room
|
|
1670
1698
|
// graph.
|
|
1671
1699
|
function worldOnlyRows(rows) { return rowsForWorld(rows, scenario().worldPayload.name); }
|
|
1700
|
+
|
|
1701
|
+
// What the rows say each agent is called (mgx:display-name) and drawn as
|
|
1702
|
+
// (mgx:model), resolved through the class chain so a class row covers every
|
|
1703
|
+
// instance, a mid-play arrival included. Null when the rows state neither
|
|
1704
|
+
// for anything — the scene then keeps ids and prefix meshes, the honest
|
|
1705
|
+
// fallback for a world that names nobody.
|
|
1706
|
+
function agentPresentationFrom(rows) {
|
|
1707
|
+
var traitsOf = window.tmct && window.tmct.page && window.tmct.page.agentTraitsOf;
|
|
1708
|
+
if (!traitsOf) return null;
|
|
1709
|
+
var kinds = {};
|
|
1710
|
+
var instanceIds = {};
|
|
1711
|
+
var presentedPredicates = { "mgx:display-name": true, "mgx:model": true };
|
|
1712
|
+
(rows || []).forEach(function (row) {
|
|
1713
|
+
if (!row || !row.subject || row.subject.indexOf("@") !== -1) return;
|
|
1714
|
+
if (row.predicate === "rdf:type" && /-\d+$/.test(row.subject)) {
|
|
1715
|
+
kinds[row.object] = true;
|
|
1716
|
+
instanceIds[row.subject] = true;
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
if (!presentedPredicates[row.predicate]) return;
|
|
1720
|
+
if (/-\d+$/.test(row.subject)) instanceIds[row.subject] = true;
|
|
1721
|
+
else kinds[row.subject] = true;
|
|
1722
|
+
});
|
|
1723
|
+
var byKind = {};
|
|
1724
|
+
var byId = {};
|
|
1725
|
+
var any = false;
|
|
1726
|
+
var take = function (bag, key) {
|
|
1727
|
+
var traits = traitsOf(rows, key);
|
|
1728
|
+
if (!traits.displayName && !traits.model) return;
|
|
1729
|
+
bag[key] = { label: traits.displayName, model: traits.model };
|
|
1730
|
+
any = true;
|
|
1731
|
+
};
|
|
1732
|
+
Object.keys(kinds).forEach(function (kind) { take(byKind, kind); });
|
|
1733
|
+
Object.keys(instanceIds).forEach(function (id) { take(byId, id); });
|
|
1734
|
+
return any ? { byId: byId, byKind: byKind } : null;
|
|
1735
|
+
}
|
|
1672
1736
|
let editRows = [];
|
|
1673
1737
|
// The FULL store, not the world's own rows: a term's synonyms and its is-a
|
|
1674
1738
|
// chain mostly live in the background corpus, not in the square's vocabulary.
|
|
@@ -1699,6 +1763,7 @@ function pageScript() {
|
|
|
1699
1763
|
el("editorStatus").textContent = "";
|
|
1700
1764
|
renderSuggestionPills();
|
|
1701
1765
|
renderEditPlacements();
|
|
1766
|
+
renderActorEditor();
|
|
1702
1767
|
}
|
|
1703
1768
|
|
|
1704
1769
|
function exitEditMode() {
|
|
@@ -1772,6 +1837,7 @@ function pageScript() {
|
|
|
1772
1837
|
}
|
|
1773
1838
|
await callScene("boot", {
|
|
1774
1839
|
propPlacements: props, assetManifest: DATA.assetManifest, gridSize: gridSizeOf(), cellSize: 1,
|
|
1840
|
+
agentPresentation: agentPresentationFrom(allStoreRows.length ? allStoreRows : editRows),
|
|
1775
1841
|
});
|
|
1776
1842
|
sendCameraToScene(camera);
|
|
1777
1843
|
callScene("applyTick", { agents: agentsById, items: itemsById, ecology: [] });
|
|
@@ -1800,6 +1866,151 @@ function pageScript() {
|
|
|
1800
1866
|
renderEditPlacements();
|
|
1801
1867
|
}
|
|
1802
1868
|
|
|
1869
|
+
// ---- actor card (per-instance edit) -------------------------------------
|
|
1870
|
+
// A second, disjoint sentence table beside the world editor's own: this
|
|
1871
|
+
// card edits whichever agent #agentSelect currently follows, alone,
|
|
1872
|
+
// through agent-editor.mjs's AGENT_TRAIT_PREDICATES rather than
|
|
1873
|
+
// mud-editor.mjs's placement/class/exit/dig vocabulary. "this <kind>"
|
|
1874
|
+
// writes to the instance id; "every <kind>" writes to the class name,
|
|
1875
|
+
// which changes the NEXT spawn (R2's copy-on-spawn), never an instance
|
|
1876
|
+
// already standing — the lede says so, naming which instances already
|
|
1877
|
+
// carry their own copies.
|
|
1878
|
+
let actorTab = "instance";
|
|
1879
|
+
|
|
1880
|
+
function actorPluralOf(word) {
|
|
1881
|
+
return /(?:[sxz]|ch|sh)$/i.test(word) ? word + "es" : word + "s";
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
function actorEditSubject() {
|
|
1885
|
+
const id = el("agentSelect").value;
|
|
1886
|
+
if (!id) return null;
|
|
1887
|
+
return actorTab === "class" ? roleOfAgentId(id) : id;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
function renderActorEditor() {
|
|
1891
|
+
const id = el("agentSelect").value;
|
|
1892
|
+
const area = el("actorEditorText");
|
|
1893
|
+
const status = el("actorEditorStatus");
|
|
1894
|
+
status.className = "edit-status";
|
|
1895
|
+
status.textContent = "";
|
|
1896
|
+
if (!id || !window.tmct || !window.tmct.page.renderAgentEditorText) {
|
|
1897
|
+
area.value = "";
|
|
1898
|
+
area.disabled = true;
|
|
1899
|
+
el("actorTabInstance").textContent = "this actor";
|
|
1900
|
+
el("actorTabClass").textContent = "its whole class";
|
|
1901
|
+
el("actorCardLede").textContent = "Follow an agent above to edit what it wants.";
|
|
1902
|
+
return;
|
|
1903
|
+
}
|
|
1904
|
+
const kind = roleOfAgentId(id);
|
|
1905
|
+
area.disabled = false;
|
|
1906
|
+
el("actorTabInstance").textContent = "this " + kind;
|
|
1907
|
+
el("actorTabInstance").setAttribute("aria-selected", actorTab === "instance" ? "true" : "false");
|
|
1908
|
+
el("actorTabClass").textContent = "every " + actorPluralOf(kind);
|
|
1909
|
+
el("actorTabClass").setAttribute("aria-selected", actorTab === "class" ? "true" : "false");
|
|
1910
|
+
if (actorTab === "class") {
|
|
1911
|
+
const siblings = Object.keys(agentsById).filter(function (aid) { return roleOfAgentId(aid) === kind; }).sort();
|
|
1912
|
+
area.value = window.tmct.page.renderAgentClassText(allStoreRows, kind);
|
|
1913
|
+
el("actorCardLede").textContent = (siblings.length ? siblings.join(", ") + " already carry their own copies. " : "")
|
|
1914
|
+
+ "This changes the next " + kind + " to arrive.";
|
|
1915
|
+
} else {
|
|
1916
|
+
area.value = window.tmct.page.renderAgentEditorText(allStoreRows, id);
|
|
1917
|
+
el("actorCardLede").textContent = "This changes " + id + " alone.";
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
el("actorTabInstance").addEventListener("click", function () {
|
|
1922
|
+
if (actorTab === "instance") return;
|
|
1923
|
+
actorTab = "instance";
|
|
1924
|
+
renderActorEditor();
|
|
1925
|
+
});
|
|
1926
|
+
el("actorTabClass").addEventListener("click", function () {
|
|
1927
|
+
if (actorTab === "class") return;
|
|
1928
|
+
actorTab = "class";
|
|
1929
|
+
renderActorEditor();
|
|
1930
|
+
});
|
|
1931
|
+
|
|
1932
|
+
function renderActorSuggestionPills() {
|
|
1933
|
+
const box = el("actorEditorPills");
|
|
1934
|
+
const area = el("actorEditorText");
|
|
1935
|
+
const term = wordBeforeCursor(area.value, area.selectionStart);
|
|
1936
|
+
if (!term || !window.tmct) { box.innerHTML = ""; return; }
|
|
1937
|
+
const related = window.tmct.page.relatedForTerm ? window.tmct.page.relatedForTerm(allStoreRows, term) : null;
|
|
1938
|
+
const chain = window.tmct.page.classAncestorChain ? window.tmct.page.classAncestorChain(term, allStoreRows) : [];
|
|
1939
|
+
const seen = {};
|
|
1940
|
+
seen[term] = true;
|
|
1941
|
+
const out = [];
|
|
1942
|
+
const push = function (label) { if (label && !seen[label]) { seen[label] = true; out.push(label); } };
|
|
1943
|
+
if (related) {
|
|
1944
|
+
related.synonyms.forEach(push);
|
|
1945
|
+
related.related.forEach(function (r) { push(r.prefLabel); });
|
|
1946
|
+
}
|
|
1947
|
+
chain.slice(1).forEach(push);
|
|
1948
|
+
box.innerHTML = out.slice(0, 8).map(function (s) {
|
|
1949
|
+
return '<button type="button" class="pill" data-insert="' + esc(s) + '">' + esc(s) + "</button>";
|
|
1950
|
+
}).join("");
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
el("actorEditorPills").addEventListener("click", function (e) {
|
|
1954
|
+
const btn = e.target.closest(".pill");
|
|
1955
|
+
if (!btn) return;
|
|
1956
|
+
const area = el("actorEditorText");
|
|
1957
|
+
const pos = area.selectionStart;
|
|
1958
|
+
const word = wordBeforeCursor(area.value, pos);
|
|
1959
|
+
const insert = btn.getAttribute("data-insert");
|
|
1960
|
+
area.value = area.value.slice(0, pos - word.length) + insert + area.value.slice(pos);
|
|
1961
|
+
const next = pos - word.length + insert.length;
|
|
1962
|
+
area.setSelectionRange(next, next);
|
|
1963
|
+
area.focus();
|
|
1964
|
+
onActorEditorChanged();
|
|
1965
|
+
});
|
|
1966
|
+
|
|
1967
|
+
let actorSuggestTimer = null;
|
|
1968
|
+
let actorSyncTimer = null;
|
|
1969
|
+
function scheduleActorSuggestions() { clearTimeout(actorSuggestTimer); actorSuggestTimer = setTimeout(renderActorSuggestionPills, 180); }
|
|
1970
|
+
function scheduleActorSync() { clearTimeout(actorSyncTimer); actorSyncTimer = setTimeout(applyActorEditorText, 450); }
|
|
1971
|
+
function onActorEditorChanged() { scheduleActorSuggestions(); scheduleActorSync(); }
|
|
1972
|
+
el("actorEditorText").addEventListener("input", onActorEditorChanged);
|
|
1973
|
+
el("actorEditorText").addEventListener("click", scheduleActorSuggestions);
|
|
1974
|
+
el("actorEditorText").addEventListener("keyup", function (e) {
|
|
1975
|
+
if (["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End"].indexOf(e.key) !== -1) scheduleActorSuggestions();
|
|
1976
|
+
});
|
|
1977
|
+
|
|
1978
|
+
// Redraws the label/mesh presentation and replays the CURRENT tick
|
|
1979
|
+
// payload — never calls session.recast, unlike rebuildSceneFromEdit's own
|
|
1980
|
+
// add/remove branch. A trait is not where anything stands, so a trait
|
|
1981
|
+
// edit must never move a single placement on the board.
|
|
1982
|
+
async function redrawAgentPresentation() {
|
|
1983
|
+
await callScene("boot", {
|
|
1984
|
+
propPlacements: props, assetManifest: DATA.assetManifest, gridSize: gridSizeOf(), cellSize: 1,
|
|
1985
|
+
agentPresentation: agentPresentationFrom(allStoreRows),
|
|
1986
|
+
});
|
|
1987
|
+
sendCameraToScene(camera);
|
|
1988
|
+
callScene("applyTick", { agents: agentsById, items: itemsById, ecology: [] });
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
async function applyActorEditorText() {
|
|
1992
|
+
if (!session) return;
|
|
1993
|
+
const subject = actorEditSubject();
|
|
1994
|
+
if (!subject) return;
|
|
1995
|
+
const status = el("actorEditorStatus");
|
|
1996
|
+
status.className = "edit-status pending";
|
|
1997
|
+
status.textContent = "reading the square\\u2026";
|
|
1998
|
+
const result = await serializeTick(function () { return session.applyAgentEdit(subject, el("actorEditorText").value); });
|
|
1999
|
+
const snap = await session.snapshot();
|
|
2000
|
+
allStoreRows = snap.rows;
|
|
2001
|
+
await redrawAgentPresentation();
|
|
2002
|
+
if (result && result.unrecognized && result.unrecognized.length) {
|
|
2003
|
+
status.className = "edit-status pending";
|
|
2004
|
+
status.textContent = result.unrecognized.length + " line" + (result.unrecognized.length === 1 ? "" : "s")
|
|
2005
|
+
+ " not understood yet \\u2014 nothing is retracted until they are.";
|
|
2006
|
+
} else {
|
|
2007
|
+
status.className = "edit-status ok";
|
|
2008
|
+
status.textContent = (result && (result.added || result.removed))
|
|
2009
|
+
? "synced \\u2014 " + result.added + " fact(s) written, " + result.removed + " retracted."
|
|
2010
|
+
: "synced \\u2014 no change.";
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
|
|
1803
2014
|
// ---- booting ---------------------------------------------------------
|
|
1804
2015
|
// The board opens playing: a square standing still reads as broken, and the
|
|
1805
2016
|
// first thing anyone does is press play anyway. A visitor who asked for
|
|
@@ -1860,7 +2071,10 @@ function pageScript() {
|
|
|
1860
2071
|
agentsById = {};
|
|
1861
2072
|
itemsById = {};
|
|
1862
2073
|
el("chatInput").disabled = false;
|
|
1863
|
-
await callScene("boot", {
|
|
2074
|
+
await callScene("boot", {
|
|
2075
|
+
propPlacements: props, assetManifest: DATA.assetManifest, gridSize: gridSizeOf(), cellSize: 1,
|
|
2076
|
+
agentPresentation: agentPresentationFrom((s.worldPayload && s.worldPayload.facts) || []),
|
|
2077
|
+
});
|
|
1864
2078
|
|
|
1865
2079
|
// The opening board, drawn through the very path a tick takes. Without
|
|
1866
2080
|
// this the page's first sight of where anything stands is the first tick,
|