@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
|
@@ -1,20 +1,62 @@
|
|
|
1
1
|
// memory-ask-browser-entry.mjs — the esbuild entry for the ledger page's
|
|
2
2
|
// chat dock (`tmct viz`, src/services/ledger-viz.mjs).
|
|
3
3
|
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
4
|
+
// The one COMMITTED browser bundle: `tmct viz` is a real CLI command run
|
|
5
|
+
// against a user's own local .tmct store, so this ships with the package. It
|
|
6
|
+
// deliberately carries the question lanes only (factAnswer/factReadBack) and
|
|
7
|
+
// not the full turn engine — see ledger-browser-entry.mjs's header for the
|
|
8
|
+
// contrast with the demo site's own 1.5MB dock.
|
|
9
|
+
//
|
|
10
|
+
// It publishes the SAME `globalThis.tmct` every other page does, through
|
|
11
|
+
// tmct-surface.mjs, which imports nothing — so this bundle gets the shared
|
|
12
|
+
// contract without the tool layer or the capability router coming with it.
|
|
13
|
+
// `tmct.turn` and `tmct.plan` are unwired here and say so: this dock asks
|
|
14
|
+
// questions, it does not hold a conversation or plan anything.
|
|
9
15
|
import { factAnswer, factReadBack } from "../../services/chat.mjs";
|
|
10
16
|
import { createInMemoryStore, normFactTerm } from "../../adapters/memory/core.mjs";
|
|
11
17
|
import { digestTermFromPayloadBrowser } from "./digest-client.mjs";
|
|
18
|
+
import { publishTmctSurface } from "./tmct-surface.mjs";
|
|
19
|
+
|
|
20
|
+
/** A question-only session over a payload the page already embeds — no fs I/O,
|
|
21
|
+
* no turn engine. Returns `{ memoryDir }`. */
|
|
22
|
+
export function createMemoryAskSession({ payload = null } = {}) {
|
|
23
|
+
const memoryDir = createInMemoryStore();
|
|
24
|
+
if (payload) memoryDir.payload = payload;
|
|
25
|
+
return { memoryDir };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* One question, answered from the page's own embedded store. Runs the same
|
|
30
|
+
* cascade `runAsk` runs — factAnswer first, then factReadBack, which is where
|
|
31
|
+
* the taught-relation chases live ("who is the grandfather of ishmael") that
|
|
32
|
+
* factAnswer's own lanes don't reach.
|
|
33
|
+
*
|
|
34
|
+
* Both are called with `envelope: null, miss: true`, which arms factAnswer's
|
|
35
|
+
* bare-question fallbacks directly and skips the structural-graph parse
|
|
36
|
+
* pipeline this dock has no use for.
|
|
37
|
+
*
|
|
38
|
+
* Returns `{ answer, data, miss }`. `data` is the reader's own result, so a
|
|
39
|
+
* caller still sees the inferred `goal` line it computed on the way.
|
|
40
|
+
*/
|
|
41
|
+
export async function askMemory(request, options, session) {
|
|
42
|
+
let fact = null;
|
|
43
|
+
try { fact = await factAnswer(session.memoryDir, request, null, true, {}); } catch { fact = null; }
|
|
44
|
+
if (!(fact && fact.text)) {
|
|
45
|
+
try { fact = await factReadBack(session.memoryDir, request, null, true, null); } catch { fact = null; }
|
|
46
|
+
}
|
|
47
|
+
if (!(fact && fact.text)) return { answer: null, data: null, miss: true };
|
|
48
|
+
return { answer: fact.text, data: fact, miss: false };
|
|
49
|
+
}
|
|
12
50
|
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
// the
|
|
19
|
-
|
|
20
|
-
|
|
51
|
+
// `tmct.page` keeps the term normalizer the dock refocuses the ledger with,
|
|
52
|
+
// and the client-side digest reader — the narrative the demo ledger's live
|
|
53
|
+
// bundle produces, over the static structure table this page embeds.
|
|
54
|
+
// `fallback`, because the demo ledger page carries this bundle AND the full
|
|
55
|
+
// turn engine at once: this one answers where it is alone, and steps aside
|
|
56
|
+
// wherever the live dock is loaded, whichever order the two arrive in.
|
|
57
|
+
publishTmctSurface({
|
|
58
|
+
open: createMemoryAskSession,
|
|
59
|
+
ask: askMemory,
|
|
60
|
+
page: { normFactTerm, digestTermFromPayloadBrowser },
|
|
61
|
+
fallback: true,
|
|
62
|
+
});
|