@polycode-projects/the-mechanical-code-talker 2.7.11 → 2.7.13
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/manifest.json +6 -6
- package/corpus/worlds/shards/ashcombe-hall.jsonl.gz +0 -0
- package/corpus/worlds/src/ashcombe-hall.jsonl +6 -0
- package/package.json +1 -1
- package/src/adapters/memory/core.mjs +42 -6
- package/src/adapters/memory/shacl.mjs +8 -6
- package/src/domain/domain.mjs +51 -6
- package/src/domain/spider-fly-world.mjs +13 -0
- package/src/domain/sprite-map.mjs +49 -1
- package/src/services/adventure-autoplay.mjs +192 -0
- package/src/services/adventure-viz.mjs +262 -0
- package/src/services/adventure.mjs +103 -35
- package/src/services/chat.mjs +19 -1
- package/src/services/spider-fly-viz.mjs +39 -9
- package/src/services/spider-fly.mjs +236 -68
- package/src/surfaces/web/adventure-browser-entry.mjs +88 -0
- package/src/surfaces/web/memory-ask-browser.bundle.js +41 -11
- package/src/surfaces/web/spider-fly-browser-entry.mjs +10 -8
|
@@ -9131,11 +9131,7 @@ ${bodyText}` : graphText, tier });
|
|
|
9131
9131
|
"mgx:ruleActionPrecondRole",
|
|
9132
9132
|
"mgx:ruleActionPrecondScope"
|
|
9133
9133
|
],
|
|
9134
|
-
"action-effect": [
|
|
9135
|
-
"mgx:ruleActionEffectPredicate",
|
|
9136
|
-
"mgx:ruleActionEffectSubject",
|
|
9137
|
-
"mgx:ruleActionEffectObject"
|
|
9138
|
-
],
|
|
9134
|
+
"action-effect": ["mgx:ruleActionEffectPredicate", "mgx:ruleActionEffectSubject"],
|
|
9139
9135
|
"action-constraint": [
|
|
9140
9136
|
"mgx:ruleActionConstraintLeft",
|
|
9141
9137
|
"mgx:ruleActionConstraintRight",
|
|
@@ -10088,9 +10084,16 @@ ${bodyText}` : graphText, tier });
|
|
|
10088
10084
|
if (!spec) throw new Error(`a rule kind must be one of ${RULE_KINDS2.join(", ")}, got ${JSON.stringify(kind)}`);
|
|
10089
10085
|
const n = normFactTerm(name);
|
|
10090
10086
|
if (!n) throw new Error("a rule needs a name");
|
|
10087
|
+
const optional = RULE_SLOT_OPTIONAL[kind] || /* @__PURE__ */ new Set();
|
|
10091
10088
|
const slotValues = spec.map(([slotKey]) => normFactTerm(slots?.[slotKey]));
|
|
10092
|
-
|
|
10093
|
-
|
|
10089
|
+
const missing = spec.filter(([slotKey], i) => !optional.has(slotKey) && !slotValues[i]);
|
|
10090
|
+
if (missing.length) {
|
|
10091
|
+
throw new Error(`a ${kind} rule needs ${missing.map(([slotKey]) => slotKey).join(" + ")}`);
|
|
10092
|
+
}
|
|
10093
|
+
if (kind === RULE_KIND_ACTION_EFFECT) {
|
|
10094
|
+
const objectRole = slotValues[spec.findIndex(([k]) => k === "objectRole")];
|
|
10095
|
+
const value = slotValues[spec.findIndex(([k]) => k === "value")];
|
|
10096
|
+
if (!objectRole && !value) throw new Error(`a ${kind} rule needs an objectRole or a value`);
|
|
10094
10097
|
}
|
|
10095
10098
|
const id = ruleIdFor(kind, n, slotValues);
|
|
10096
10099
|
const label = labelOf(`${n} = ${kind}(${slotValues.join(", ")})`);
|
|
@@ -10109,7 +10112,10 @@ ${bodyText}` : graphText, tier });
|
|
|
10109
10112
|
{ prop: "rdf:type", key: "type", value: "owl:NamedIndividual" },
|
|
10110
10113
|
{ prop: RULE_NAME_PROP, key: "ruleName", value: n },
|
|
10111
10114
|
{ prop: RULE_KIND_PROP, key: "ruleKind", value: kind },
|
|
10112
|
-
|
|
10115
|
+
// An optional slot left empty stores no attribute at all — the same
|
|
10116
|
+
// "never supplied" shape a pre-extension Rule individual already has,
|
|
10117
|
+
// rather than a wasted always-"" one.
|
|
10118
|
+
...spec.map(([slotKey, prop], i) => ({ prop, key: slotKey, value: slotValues[i], skip: !slotValues[i] && optional.has(slotKey) })).filter((attr) => !attr.skip).map(({ skip, ...attr }) => attr),
|
|
10113
10119
|
{ prop: CREATED_AT_PROP, key: "createdAt", value: createdAtVal },
|
|
10114
10120
|
...provs.length ? [{ prop: "mgx:factProvenance", key: "provenance", value: provs.join(" | ") }] : []
|
|
10115
10121
|
]
|
|
@@ -10376,7 +10382,7 @@ ${bodyText}` : graphText, tier });
|
|
|
10376
10382
|
}
|
|
10377
10383
|
return out.sort((a, b) => `${a[0].subject} ${a[0].predicate}`.localeCompare(`${b[0].subject} ${b[0].predicate}`));
|
|
10378
10384
|
}
|
|
10379
|
-
var MEMORY_DIR_REL, MEMORY_GRAPH_REL, UTTERANCE_CLASS, FACT_CLASS, MEMORY_SESSION_CLASS, SOURCE_CLASS, RULE_CLASS, SAID_IN_SESSION_PROP, IN_REPLY_TO_PROP, DERIVED_FROM_PROP, STATED_BY_PROP, CANONICALISED_FROM_PROP, SOURCE_RELIABILITY_PROP, OPERATOR_SOURCE_ID, TEACH_SOURCE_ID, ROLES, LABEL_CAP, MEMORY_VOCABULARY, memoryGraphFile, BACKEND_MEMORY, BACKEND_SQLITE, SQLITE_DDL, STD_EDGE_KEYS, cloneJson, MEMORY_MANIFEST_REL, DEFAULT_RETENTION, resolveManifestFile, LEGACY_FACT_ID_RE, SYLLOGISE_STATE_REL, SQLITE_SYLLOGISE_STATE_KEY, MEMORY_INDEX, memoryIndexOf, labelOf, nowIso, sourceLabel, PROV_CLASS_BY_SOURCE_TYPE, isSessionScopedSourceId, RULE_KIND_COMPOSE2, RULE_KIND_FILTER, RULE_KIND_RECURSIVE, RULE_KIND_ACTION_SIGNATURE, RULE_KIND_ACTION_PRECOND, RULE_KIND_ACTION_EFFECT, RULE_KIND_ACTION_CONSTRAINT, RULE_KINDS2, RULE_NAME_PROP, RULE_KIND_PROP, RULE_SLOT_SPEC, ruleIdFor, CONTRADICTION_TRUST_FLOOR, HAS_A_PREDICATE, CAPABLE_OF_PREDICATE2, MULTI_VALUED_PREDICATES;
|
|
10385
|
+
var MEMORY_DIR_REL, MEMORY_GRAPH_REL, UTTERANCE_CLASS, FACT_CLASS, MEMORY_SESSION_CLASS, SOURCE_CLASS, RULE_CLASS, SAID_IN_SESSION_PROP, IN_REPLY_TO_PROP, DERIVED_FROM_PROP, STATED_BY_PROP, CANONICALISED_FROM_PROP, SOURCE_RELIABILITY_PROP, OPERATOR_SOURCE_ID, TEACH_SOURCE_ID, ROLES, LABEL_CAP, MEMORY_VOCABULARY, memoryGraphFile, BACKEND_MEMORY, BACKEND_SQLITE, SQLITE_DDL, STD_EDGE_KEYS, cloneJson, MEMORY_MANIFEST_REL, DEFAULT_RETENTION, resolveManifestFile, LEGACY_FACT_ID_RE, SYLLOGISE_STATE_REL, SQLITE_SYLLOGISE_STATE_KEY, MEMORY_INDEX, memoryIndexOf, labelOf, nowIso, sourceLabel, PROV_CLASS_BY_SOURCE_TYPE, isSessionScopedSourceId, RULE_KIND_COMPOSE2, RULE_KIND_FILTER, RULE_KIND_RECURSIVE, RULE_KIND_ACTION_SIGNATURE, RULE_KIND_ACTION_PRECOND, RULE_KIND_ACTION_EFFECT, RULE_KIND_ACTION_CONSTRAINT, RULE_KINDS2, RULE_NAME_PROP, RULE_KIND_PROP, RULE_SLOT_SPEC, RULE_SLOT_OPTIONAL, ruleIdFor, CONTRADICTION_TRUST_FLOOR, HAS_A_PREDICATE, CAPABLE_OF_PREDICATE2, MULTI_VALUED_PREDICATES;
|
|
10380
10386
|
var init_core = __esm({
|
|
10381
10387
|
"src/adapters/memory/core.mjs"() {
|
|
10382
10388
|
init_promises();
|
|
@@ -10506,12 +10512,22 @@ CREATE INDEX IF NOT EXISTS edges_by_prop ON edges(prop);
|
|
|
10506
10512
|
["shape", "mgx:ruleActionPrecondShape"],
|
|
10507
10513
|
["predicate", "mgx:ruleActionPrecondPredicate"],
|
|
10508
10514
|
["role", "mgx:ruleActionPrecondRole"],
|
|
10509
|
-
["scope", "mgx:ruleActionPrecondScope"]
|
|
10515
|
+
["scope", "mgx:ruleActionPrecondScope"],
|
|
10516
|
+
// value/negate: the "fact-value" shape's literal-match and negation
|
|
10517
|
+
// slots. Optional (RULE_SLOT_OPTIONAL below) — no-incoming/comparator
|
|
10518
|
+
// preconds never set them.
|
|
10519
|
+
["value", "mgx:ruleActionPrecondValue"],
|
|
10520
|
+
["negate", "mgx:ruleActionPrecondNegate"]
|
|
10510
10521
|
],
|
|
10511
10522
|
[RULE_KIND_ACTION_EFFECT]: [
|
|
10512
10523
|
["predicate", "mgx:ruleActionEffectPredicate"],
|
|
10513
10524
|
["subjectRole", "mgx:ruleActionEffectSubject"],
|
|
10514
|
-
|
|
10525
|
+
// objectRole/value: exactly one of these two must be set (enforced
|
|
10526
|
+
// below, not by this per-slot spec) — a role-bound effect (Hanoi's
|
|
10527
|
+
// "rest-on") supplies objectRole, a literal datatype effect (Ashcombe's
|
|
10528
|
+
// is-open = "true") supplies value instead.
|
|
10529
|
+
["objectRole", "mgx:ruleActionEffectObject"],
|
|
10530
|
+
["value", "mgx:ruleActionEffectValue"]
|
|
10515
10531
|
],
|
|
10516
10532
|
// "the <left> may not be with the <right> without the <guard>" — each slot
|
|
10517
10533
|
// names a class whose sole member src/domain/domain.mjs resolves at compile time.
|
|
@@ -10521,6 +10537,10 @@ CREATE INDEX IF NOT EXISTS edges_by_prop ON edges(prop);
|
|
|
10521
10537
|
["guard", "mgx:ruleActionConstraintGuard"]
|
|
10522
10538
|
]
|
|
10523
10539
|
};
|
|
10540
|
+
RULE_SLOT_OPTIONAL = {
|
|
10541
|
+
[RULE_KIND_ACTION_PRECOND]: /* @__PURE__ */ new Set(["value", "negate"]),
|
|
10542
|
+
[RULE_KIND_ACTION_EFFECT]: /* @__PURE__ */ new Set(["objectRole", "value"])
|
|
10543
|
+
};
|
|
10524
10544
|
ruleIdFor = (kind, name, slotValues) => `rule:${fnv1aHex([kind, name, ...slotValues].join("\0"))}`;
|
|
10525
10545
|
CONTRADICTION_TRUST_FLOOR = 0.5;
|
|
10526
10546
|
HAS_A_PREDICATE = "mgx:hasA";
|
|
@@ -22011,6 +22031,14 @@ ${codeblock}`, options);
|
|
|
22011
22031
|
}
|
|
22012
22032
|
});
|
|
22013
22033
|
|
|
22034
|
+
// src/domain/domain.mjs
|
|
22035
|
+
var SEP2;
|
|
22036
|
+
var init_domain = __esm({
|
|
22037
|
+
"src/domain/domain.mjs"() {
|
|
22038
|
+
SEP2 = String.fromCharCode(0);
|
|
22039
|
+
}
|
|
22040
|
+
});
|
|
22041
|
+
|
|
22014
22042
|
// src/adapters/memory/blocks.mjs
|
|
22015
22043
|
var BLOCKS_DIR_REL;
|
|
22016
22044
|
var init_blocks = __esm({
|
|
@@ -23449,6 +23477,7 @@ ${JSON.stringify(envelope, null, 2)}`;
|
|
|
23449
23477
|
init_ace2();
|
|
23450
23478
|
init_graph_adapter();
|
|
23451
23479
|
init_taught();
|
|
23480
|
+
init_domain();
|
|
23452
23481
|
|
|
23453
23482
|
// src/adapters/corpus/worlds-pack.mjs
|
|
23454
23483
|
init_node_fs();
|
|
@@ -23545,6 +23574,7 @@ ${JSON.stringify(envelope, null, 2)}`;
|
|
|
23545
23574
|
// src/services/spider-fly.mjs
|
|
23546
23575
|
init_planning();
|
|
23547
23576
|
init_core();
|
|
23577
|
+
init_hash();
|
|
23548
23578
|
|
|
23549
23579
|
// src/services/spider-fly-turn.mjs
|
|
23550
23580
|
init_core();
|
|
@@ -52,7 +52,7 @@ import { loadLexicon } from "../../domain/grammar/lexicon.mjs";
|
|
|
52
52
|
import {
|
|
53
53
|
worldFactRows, WORLD_NAME, WORLD_OPENING, cellId, parseCellId, DIRECTION_DELTA, visibleCells,
|
|
54
54
|
} from "../../domain/spider-fly-world.mjs";
|
|
55
|
-
import { foldSpiderFlyState, runSpiderFlyTick, startSpiderFlyGame, DEFAULT_VISION_RADIUS } from "../../services/spider-fly.mjs";
|
|
55
|
+
import { foldSpiderFlyState, runSpiderFlyTick, startSpiderFlyGame, liveWebs, DEFAULT_VISION_RADIUS } from "../../services/spider-fly.mjs";
|
|
56
56
|
import { resolveSpriteForClass, SPRITE_REGISTRY } from "../../domain/sprite-map.mjs";
|
|
57
57
|
|
|
58
58
|
/** A live in-memory game the page's ticker and chat dock can both drive.
|
|
@@ -77,8 +77,8 @@ export async function createSpiderFlySession({ flyCount = 1 } = {}) {
|
|
|
77
77
|
const { facts: startFacts } = await startSpiderFlyGame(memoryDir, { flyCount });
|
|
78
78
|
const initialAgents = {};
|
|
79
79
|
for (const f of startFacts) {
|
|
80
|
-
if (f.predicate
|
|
81
|
-
initialAgents[f.subject] = {
|
|
80
|
+
if (f.predicate === "mgx:currently-in") initialAgents[f.subject] = { ...initialAgents[f.subject], cell: f.object };
|
|
81
|
+
else if (f.predicate === "mgx:mass") initialAgents[f.subject] = { ...initialAgents[f.subject], mass: Number(f.object) };
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
const graph = parseEntities({ individuals: [], objectProperties: [] });
|
|
@@ -93,7 +93,7 @@ export async function createSpiderFlySession({ flyCount = 1 } = {}) {
|
|
|
93
93
|
memoryDir,
|
|
94
94
|
sessionId,
|
|
95
95
|
opening: WORLD_OPENING,
|
|
96
|
-
initial: { turn: 0, agents: initialAgents },
|
|
96
|
+
initial: { turn: 0, agents: initialAgents, activeWebs: [] },
|
|
97
97
|
taxonomyRows,
|
|
98
98
|
|
|
99
99
|
/** Run one real engine turn directly. Returns spider-fly.mjs's own
|
|
@@ -127,16 +127,18 @@ export async function createSpiderFlySession({ flyCount = 1 } = {}) {
|
|
|
127
127
|
|
|
128
128
|
/** A read-only fold of the CURRENT board — no engine advance, no goal
|
|
129
129
|
* lines (see the header comment: only a raw tick() recomputes those).
|
|
130
|
-
* Lets the page resync positions/turn count after a
|
|
130
|
+
* Lets the page resync positions/turn count/mass/active webs after a
|
|
131
|
+
* chat-driven tick. Web individuals are never listed as agents (that's
|
|
132
|
+
* spider-1/fly-1/... only) — they surface only through activeWebs. */
|
|
131
133
|
async snapshot() {
|
|
132
134
|
const rows = readFactRows(await loadMemory(memoryDir));
|
|
133
135
|
const state = foldSpiderFlyState(rows);
|
|
134
136
|
const agents = {};
|
|
135
137
|
for (const [id, place] of state.placements) {
|
|
136
|
-
if (state.removed.has(id)) continue;
|
|
137
|
-
agents[id] = { cell: place.cell };
|
|
138
|
+
if (state.removed.has(id) || /^web-\d+$/.test(id)) continue;
|
|
139
|
+
agents[id] = { cell: place.cell, mass: state.mass.get(id)?.value ?? null };
|
|
138
140
|
}
|
|
139
|
-
return { turn: state.turnCount, agents };
|
|
141
|
+
return { turn: state.turnCount, agents, activeWebs: liveWebs(state.webs, state.turnCount) };
|
|
140
142
|
},
|
|
141
143
|
};
|
|
142
144
|
}
|