dsh-context-memory 0.1.0 → 0.1.1
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/CHANGELOG.md +9 -0
- package/lib/memory.web.js +31 -4
- package/lib/memory.web.js.map +7 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
- **Fix the browser half never registering.** The client bundle was emitted as plain ESM
|
|
6
|
+
with `react` external, which prints a top-level `import` — invalid inside the loader's
|
|
7
|
+
concatenated script bundle, so evaluation aborted and every module after it failed with
|
|
8
|
+
"...loaded without registering ... via __ModuleLoader__.load". The bundle is now emitted
|
|
9
|
+
in the loader's lazy-CJS factory form (`window.__ModuleLoader__.load({ id, factory })`).
|
|
10
|
+
- Point the `./client` export's `types` at `lib/client/index.d.ts`.
|
|
11
|
+
|
|
3
12
|
## 0.1.0
|
|
4
13
|
|
|
5
14
|
Initial release.
|
package/lib/memory.web.js
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: "dsh-context-memory", factory: (require) => {
|
|
2
|
+
var module = { exports: {} }; var exports = module.exports;
|
|
3
|
+
"use strict";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/client/index.tsx
|
|
23
|
+
var index_exports = {};
|
|
24
|
+
__export(index_exports, {
|
|
25
|
+
apply: () => apply,
|
|
26
|
+
inject: () => inject
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
1
30
|
// src/client/view.tsx
|
|
2
31
|
function escapeHtml(value) {
|
|
3
32
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
@@ -54,7 +83,5 @@ function apply(ctx) {
|
|
|
54
83
|
});
|
|
55
84
|
});
|
|
56
85
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
inject
|
|
60
|
-
};
|
|
86
|
+
return module.exports; } });
|
|
87
|
+
//# sourceMappingURL=memory.web.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/client/index.tsx", "../src/client/view.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * Browser half of dsh-context-memory \u2014 the registration shell.\n *\n * Declaring `inject` at module scope is required, not stylistic: without it the client\n * loader cannot resolve the settings and connection services, and the half fails to\n * register with an unhelpful error.\n *\n * @module context-memory/client\n */\n\nimport type { PanelPayload } from '../types.js'\nimport { renderPanel } from './view.js'\n\nexport const inject = ['@deepseek-ai/dsh-client-ui-settings', '@deepseek-ai/dsh-client-connection']\n\nexport function apply(ctx: { inject: (deps: string[], fn: (...services: unknown[]) => void) => void }): void {\n ctx.inject(inject, (settings: unknown, connection: unknown) => {\n const s = settings as { section: (id: string, opts: { title: string; render: () => Promise<string> | string }) => void }\n const c = connection as { fetch: (path: string) => Promise<Response> }\n\n s.section('context-memory', {\n title: 'Context memory',\n render: async () => {\n try {\n const res = await c.fetch('/api/context-memory.panel')\n const payload: PanelPayload = await res.json()\n return renderPanel(payload)\n } catch (error) {\n // Say what failed rather than rendering an empty panel, which would read as\n // \"nothing is remembered\" \u2014 a different and wrong answer.\n return `<div class=\"context-memory-panel\"><h2>Context memory</h2><p>Could not load memories: ${String(error)}</p></div>`\n }\n },\n })\n })\n}\n", "/**\n * Browser half of dsh-context-memory \u2014 the view model.\n *\n * Rendering is kept here, separate from the fetch-and-register shell, so it can be\n * statically rendered in Node during tests. The panel is a claim about what the agent\n * remembers, so it is worth asserting on without a browser.\n *\n * @module context-memory/client/view\n */\n\nimport type { MemoryState, PanelPayload } from '../types.js'\n\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n}\n\n/**\n * A memory's verification badge.\n *\n * Four states, not two, because \"no check exists\" and \"the check could not run\" are\n * different answers from \"the check failed\" \u2014 collapsing them would report an\n * unverifiable memory and a false one identically, which is the failure this plugin\n * exists to avoid.\n */\nexport function verificationLabel(memory: MemoryState): string {\n if (!memory.guard) return 'no check'\n switch (memory.verification?.outcome) {\n case 'passed': return 'checked, holds'\n case 'violated': return 'checked, does not hold'\n case 'broken': return 'check unusable'\n default: return 'not yet checked'\n }\n}\n\nfunction rows(memories: MemoryState[]): string {\n return memories\n .map((memory) => {\n const provenance = [\n memory.source,\n memory.sessionId ? `session ${memory.sessionId}` : null,\n memory.step !== undefined ? `step ${memory.step}` : null,\n ].filter(Boolean).join(' \u00B7 ')\n return `<tr><td><code>${escapeHtml(memory.id)}</code></td><td>${escapeHtml(memory.text)}</td><td>${escapeHtml(memory.kind)}</td><td>${escapeHtml(verificationLabel(memory))}</td><td>${escapeHtml(provenance)}</td></tr>`\n })\n .join('')\n}\n\nexport function renderPanel(payload: PanelPayload): string {\n const { totals } = payload\n\n const summary = `<p class=\"memory-summary\">${totals.active} active (${totals.verified} checked and holding, ${totals.unverified} not), ${totals.superseded} superseded, ${totals.withGuard} with a compiled check.</p>`\n\n const conflictBlock = payload.conflicts.length === 0\n ? '<p>No conflicts.</p>'\n : `<div class=\"memory-conflicts\"><h3>Conflicts</h3><ul>${payload.conflicts\n .map((conflict) => `<li><strong>${escapeHtml(conflict.subject)}</strong><ul>${conflict.memories\n .map((memory) => `<li><code>${escapeHtml(memory.id)}</code> ${escapeHtml(memory.text)}</li>`)\n .join('')}</ul></li>`)\n .join('')}</ul></div>`\n\n const activeBlock = payload.active.length === 0\n ? '<p>Nothing is remembered yet.</p>'\n : `<table><thead><tr><th>Id</th><th>Memory</th><th>Kind</th><th>Status</th><th>From</th></tr></thead><tbody>${rows(payload.active)}</tbody></table>`\n\n const supersededBlock = payload.superseded.length === 0\n ? ''\n : `<details><summary>Superseded (${payload.superseded.length})</summary><table><thead><tr><th>Id</th><th>Memory</th><th>Kind</th><th>Status</th><th>From</th></tr></thead><tbody>${rows(payload.superseded)}</tbody></table></details>`\n\n return `<div class=\"context-memory-panel\"><h2>Context memory</h2>${summary}${conflictBlock}<h3>Active</h3>${activeBlock}${supersededBlock}</div>`\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYA,SAAS,WAAW,OAAuB;AACzC,SAAO,MACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ;AAC3B;AAUO,SAAS,kBAAkB,QAA6B;AAC7D,MAAI,CAAC,OAAO,MAAO,QAAO;AAC1B,UAAQ,OAAO,cAAc,SAAS;AAAA,IACpC,KAAK;AAAU,aAAO;AAAA,IACtB,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAU,aAAO;AAAA,IACtB;AAAS,aAAO;AAAA,EAClB;AACF;AAEA,SA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,SAAS,MAAM,KAAuF;AAC3G,MAAI,OAAO,QAAQ,CAAC,UAAmB,eAAwB;AAC7D,UAAM,IAAI;AACV,UAAM,IAAI;AAEV,MAAE,QAAQ,kBAAkB;AAAA,MAC1B,OAAO;AAAA,MACP,QAAQ,YAAY;AAClB,YAAI;AACF,gBAAM,MAAM,MAAM,EAAE,MAAM,2BAA2B;AACrD,gBAAM,UAAwB,MAAM,IAAI,KAAK;AAC7C,iBAAO,YAAY,OAAO;AAAA,QAC5B,SAAS,OAAO;AAGd,iBAAO,wFAAwF,OAAO,KAAK,CAAC;AAAA,QAC9G;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-context-memory",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Cross-session memory for your dsh agent: remembered, recalled, and re-verified instead of assumed.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"bin": { "dsh-context-memory": "lib/bin.js" },
|
|
9
9
|
"exports": {
|
|
10
10
|
".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" },
|
|
11
|
-
"./client": { "types": "./lib/client.d.ts", "default": "./lib/memory.web.js" },
|
|
11
|
+
"./client": { "types": "./lib/client/index.d.ts", "default": "./lib/memory.web.js" },
|
|
12
12
|
"./package.json": "./package.json"
|
|
13
13
|
},
|
|
14
14
|
"files": ["lib", "cordis.patch.yml", "README.md", "CHANGELOG.md"],
|