icex-dsh-memory 0.2.4 → 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 +12 -5
  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
  *
@@ -19,6 +18,7 @@
19
18
  * `memory` tool; when it does not, the policy falls back to editing the file
20
19
  * with the built-in filesystem tools.
21
20
  */
21
+ import { randomUUID } from 'node:crypto'
22
22
  import { existsSync, mkdirSync, readFileSync, writeFileSync, renameSync, rmSync, statSync } from 'node:fs'
23
23
  import { createHash } from 'node:crypto'
24
24
  import { homedir } from 'node:os'
@@ -494,7 +494,7 @@ export function apply(ctx, config) {
494
494
 
495
495
  ctx.on('agent/created', (payload) => {
496
496
  const agent = payload?.agent ?? payload
497
- if (agent === undefined || typeof agent.inject !== 'function') return
497
+ if (agent === undefined || agent.ctx === undefined) return
498
498
  void (async () => {
499
499
  try {
500
500
  const cwd = await workingDirectory(ctx, agent)
@@ -510,7 +510,14 @@ export function apply(ctx, config) {
510
510
  }
511
511
  const text = renderDigest(cwd)
512
512
  if (text === '') return
513
- agent.inject({ content: [{ type: 'text', text }], source: { kind: 'icex-memory' } })
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
+ })
514
521
  } catch (error) {
515
522
  ctx.logger?.warn?.('icex-dsh-memory: digest injection failed: ' + String(error))
516
523
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icex-dsh-memory",
3
- "version": "0.2.4",
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": {