icex-dsh-memory 0.2.5 → 0.2.7
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/index.js +21 -23
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* icex-dsh-memory — cross-session memory for DeepSeek Harness.
|
|
3
3
|
*
|
|
4
4
|
* Two halves, both host-side:
|
|
5
|
-
* 1. A budgeted digest of durable facts
|
|
6
|
-
*
|
|
7
|
-
* stays visible in the session log.
|
|
5
|
+
* 1. A budgeted digest of durable facts enters the system prompt as a
|
|
6
|
+
* session-scoped section, computed once when the agent is created.
|
|
8
7
|
* 2. A `memory` tool reads and writes those facts, one line per fact, with a
|
|
9
8
|
* provenance pointer back to the session that produced it.
|
|
10
9
|
*
|
|
@@ -358,16 +357,6 @@ function policy(storePaths) {
|
|
|
358
357
|
].join('\n')
|
|
359
358
|
}
|
|
360
359
|
|
|
361
|
-
/** Build a complete user message: the inbox accepts UserMessage, not a partial literal. */
|
|
362
|
-
export function memoryMessage(text) {
|
|
363
|
-
return {
|
|
364
|
-
id: randomUUID(),
|
|
365
|
-
role: 'user',
|
|
366
|
-
content: [{ type: 'text', text }],
|
|
367
|
-
source: { kind: 'user' },
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
360
|
/** Resolve the session working directory, falling back to the process cwd. */
|
|
372
361
|
async function workingDirectory(ctx, agent, signal) {
|
|
373
362
|
try {
|
|
@@ -480,14 +469,16 @@ export async function handleEditorRequest(request) {
|
|
|
480
469
|
|
|
481
470
|
/** Claim the settings-editor route when this host carries a browser connection. */
|
|
482
471
|
function registerEditorRoute(ctx) {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
472
|
+
ctx.inject(['connection'], (scope) => {
|
|
473
|
+
const connection = scope.connection
|
|
474
|
+
if (connection === undefined || connection.fetch === undefined || typeof connection.fetch.register !== 'function') return
|
|
475
|
+
scope.effect(() => connection.fetch.register({
|
|
476
|
+
path: '/api/icex-memory',
|
|
477
|
+
methods: ['GET', 'POST'],
|
|
478
|
+
requestBody: 'buffered',
|
|
479
|
+
fetch: handleEditorRequest,
|
|
480
|
+
}), 'icex-dsh-memory: settings editor route')
|
|
481
|
+
})
|
|
491
482
|
}
|
|
492
483
|
|
|
493
484
|
/** Apply the plugin: one prompt section, one injection, optionally one tool. */
|
|
@@ -505,7 +496,7 @@ export function apply(ctx, config) {
|
|
|
505
496
|
|
|
506
497
|
ctx.on('agent/created', (payload) => {
|
|
507
498
|
const agent = payload?.agent ?? payload
|
|
508
|
-
if (agent === undefined ||
|
|
499
|
+
if (agent === undefined || agent.ctx === undefined) return
|
|
509
500
|
void (async () => {
|
|
510
501
|
try {
|
|
511
502
|
const cwd = await workingDirectory(ctx, agent)
|
|
@@ -521,7 +512,14 @@ export function apply(ctx, config) {
|
|
|
521
512
|
}
|
|
522
513
|
const text = renderDigest(cwd)
|
|
523
514
|
if (text === '') return
|
|
524
|
-
agent.
|
|
515
|
+
const agentCtx = agent.ctx
|
|
516
|
+
if (agentCtx === undefined || agentCtx.systemPrompt === undefined || typeof agentCtx.systemPrompt.section !== 'function') return
|
|
517
|
+
agentCtx.systemPrompt.section({
|
|
518
|
+
name: 'icex-memory:digest',
|
|
519
|
+
order: 950,
|
|
520
|
+
text: text,
|
|
521
|
+
interpolate: false,
|
|
522
|
+
})
|
|
525
523
|
} catch (error) {
|
|
526
524
|
ctx.logger?.warn?.('icex-dsh-memory: digest injection failed: ' + String(error))
|
|
527
525
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "icex-dsh-memory",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Cross-session memory for DeepSeek Harness: a budgeted MEMORY.md digest injected once per session, plus one memory tool with provenance back to the producing session.",
|
|
6
6
|
"exports": {
|