icex-dsh-memory 0.2.5 → 0.2.6

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.
Files changed (2) hide show
  1. package/index.js +11 -15
  2. 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 is injected once per agent as an inbox
6
- * message (`agent.inject`), so it never disturbs the system-prompt prefix and
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 {
@@ -505,7 +494,7 @@ export function apply(ctx, config) {
505
494
 
506
495
  ctx.on('agent/created', (payload) => {
507
496
  const agent = payload?.agent ?? payload
508
- if (agent === undefined || typeof agent.inject !== 'function') return
497
+ if (agent === undefined || agent.ctx === undefined) return
509
498
  void (async () => {
510
499
  try {
511
500
  const cwd = await workingDirectory(ctx, agent)
@@ -521,7 +510,14 @@ export function apply(ctx, config) {
521
510
  }
522
511
  const text = renderDigest(cwd)
523
512
  if (text === '') return
524
- agent.inject(memoryMessage(text))
513
+ const agentCtx = agent.ctx
514
+ if (agentCtx === undefined || agentCtx.systemPrompt === undefined || typeof agentCtx.systemPrompt.section !== 'function') return
515
+ agentCtx.systemPrompt.section({
516
+ name: 'icex-memory:digest',
517
+ order: 950,
518
+ text: text,
519
+ interpolate: false,
520
+ })
525
521
  } catch (error) {
526
522
  ctx.logger?.warn?.('icex-dsh-memory: digest injection failed: ' + String(error))
527
523
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icex-dsh-memory",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
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": {