@xandreed/plugin-memory-summary 0.12.0 → 0.14.0

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  # @xandreed/plugin-memory-summary
2
2
 
3
- Efferent composable agent framework, 0.12.0. Node 24 or Bun.
3
+ Efferent composable agent framework, 0.14.0. Node 24 or Bun.
4
4
 
5
5
  Documentation: https://github.com/xandreeddev/efferent
@@ -12,8 +12,19 @@ export declare const MemorySummaryConfig: Schema.Struct<{
12
12
  readonly replies: Schema.Boolean;
13
13
  /** Show recorded tool digests in place of the results they digest. */
14
14
  readonly digests: Schema.Boolean;
15
+ /**
16
+ * How images reach the model (a user's attachments, the images tool
17
+ * results return): the current turn's are sent as images first, within
18
+ * `maxImages` and `maxMediaChars` (with the defaults a message's own images
19
+ * always fit); `inline` (the default) sends earlier turns' images too,
20
+ * newest turn first, while they fit, `none` shows them as label lines.
21
+ * Text only: `maxMediaChars: 0`.
22
+ */
15
23
  readonly media: Schema.Literals<readonly ["none", "inline"]>;
24
+ /** Images one request sends as images, never more than `MEDIA_LIMITS.requestImages` (and artifact reference lines one result shows). */
16
25
  readonly maxImages: Schema.Int;
26
+ /** Base64 characters of the images one request sends, at most `MEDIA_LIMITS.requestChars`; 0 sends none (text only). */
27
+ readonly maxMediaChars: Schema.Int;
17
28
  /** Instructions for the summarizer; the transcript and any earlier summary follow. */
18
29
  readonly instructions: Schema.String;
19
30
  }>;
@@ -39,6 +50,7 @@ export declare const memorySummaryPlugin: import("@xandreed/core").TypedPlugin<{
39
50
  readonly digests: boolean;
40
51
  readonly media: "none" | "inline";
41
52
  readonly maxImages: number;
53
+ readonly maxMediaChars: number;
42
54
  readonly instructions: string;
43
55
  }, {
44
56
  readonly triggerRatio: number;
@@ -49,6 +61,7 @@ export declare const memorySummaryPlugin: import("@xandreed/core").TypedPlugin<{
49
61
  readonly digests: boolean;
50
62
  readonly media: "none" | "inline";
51
63
  readonly maxImages: number;
64
+ readonly maxMediaChars: number;
52
65
  readonly instructions: string;
53
66
  }, ConversationMemory, never, never>;
54
67
  /** Summarizing memory as a typed layer: provides ConversationMemory (and needs a UtilityLlm per turn). */
@@ -61,6 +74,7 @@ export declare const MemorySummaryLive: (options?: Partial<{
61
74
  readonly digests: boolean;
62
75
  readonly media: "none" | "inline";
63
76
  readonly maxImages: number;
77
+ readonly maxMediaChars: number;
64
78
  readonly instructions: string;
65
79
  }> | undefined) => Layer.Layer<ConversationMemory, HarnessError, never>;
66
80
  export default memorySummaryPlugin;
@@ -5,6 +5,7 @@ import {
5
5
  digestTranscript,
6
6
  estimateMessageTokens,
7
7
  HarnessError,
8
+ MEDIA_LIMITS,
8
9
  openLogSession,
9
10
  UtilityLlm
10
11
  } from "@xandreed/core";
@@ -17,6 +18,7 @@ export const MemorySummaryConfig = Schema.Struct({
17
18
  digests: Schema.Boolean,
18
19
  media: Schema.Literals(["none", "inline"]),
19
20
  maxImages: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0))),
21
+ maxMediaChars: Schema.Int.pipe(Schema.check(Schema.isBetween({ minimum: 0, maximum: MEDIA_LIMITS.requestChars }))),
20
22
  instructions: Schema.String
21
23
  }), memorySummaryDefaults = {
22
24
  triggerRatio: 0.8,
@@ -25,8 +27,9 @@ export const MemorySummaryConfig = Schema.Struct({
25
27
  turnContext: "current",
26
28
  replies: !0,
27
29
  digests: !0,
28
- media: "none",
29
- maxImages: 8,
30
+ media: "inline",
31
+ maxImages: MEDIA_LIMITS.requestImages,
32
+ maxMediaChars: MEDIA_LIMITS.requestChars,
30
33
  instructions: "Summarize the earlier part of this conversation for the same assistant, which will continue from your summary plus the newest turns. Preserve, in order: the user's goals and constraints; facts and records established (with their identifiers); answers already given; open questions and pending work. Dense prose and lists; never invent anything not in the transcript."
31
34
  }, SUMMARY_STRATEGY = { id: "summary", version: "1" };
32
35
  const latestSummary = (entries) => Option.fromNullishOr(entries.flatMap((entry) => entry.body._tag === "Compaction" && entry.body.strategy === SUMMARY_STRATEGY.id && entry.body.action._tag === "Summarize" ? [{ turn: entry.turn, keepFromTurn: entry.body.action.keepFromTurn, summary: entry.body.action.summary }] : []).at(-1)), keepFrom = (entries, turn, keepTokens, render) => Array.from({ length: turn }, (_, index) => turn - index).reduce((kept, candidate) => {
@@ -35,7 +38,7 @@ const latestSummary = (entries) => Option.fromNullishOr(entries.flatMap((entry)
35
38
  }, turn);
36
39
  export const summaryPolicy = (config, summarize) => ({
37
40
  strategy: SUMMARY_STRATEGY,
38
- render: { turnContext: config.turnContext, replies: config.replies, digests: config.digests, media: { mode: config.media, maxImages: config.maxImages } },
41
+ render: { turnContext: config.turnContext, replies: config.replies, digests: config.digests, media: { mode: config.media, maxImages: config.maxImages, maxChars: config.maxMediaChars } },
39
42
  digestOnWrite: Option.none(),
40
43
  maintain: (input) => decide(config, summarize, input).pipe(Effect.map((actions) => ({ actions, digest: [] })))
41
44
  });
@@ -60,7 +63,7 @@ ${transcript}`)).trim(), action = { _tag: "Summarize", keepFromTurn: from, summa
60
63
  }), missingUtility = new HarnessError({ code: "memory.summary", message: "The summary strategy needs a UtilityLlm in the turn's services" });
61
64
  export const memorySummaryPlugin = definePlugin({
62
65
  id: "@xandreed/plugin-memory-summary",
63
- version: "0.12.0",
66
+ version: "0.14.0",
64
67
  scope: "runtime",
65
68
  config: MemorySummaryConfig,
66
69
  defaults: memorySummaryDefaults,
package/package.json CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "name": "@xandreed/plugin-memory-summary",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
+ "engines": {
5
+ "node": ">=24",
6
+ "bun": ">=1.3.0"
7
+ },
4
8
  "type": "module",
5
9
  "main": "./dist/index.js",
6
10
  "exports": {
@@ -10,8 +14,8 @@
10
14
  }
11
15
  },
12
16
  "dependencies": {
13
- "@xandreed/core": "0.12.0",
14
- "effect": "4.0.0-rc.118"
17
+ "@xandreed/core": "0.14.0",
18
+ "effect": "4.0.7"
15
19
  },
16
20
  "private": false,
17
21
  "types": "./dist/index.d.ts",
@@ -22,9 +26,5 @@
22
26
  "README.md",
23
27
  "LICENSE"
24
28
  ],
25
- "engines": {
26
- "node": ">=24",
27
- "bun": ">=1.3.0"
28
- },
29
29
  "license": "MIT"
30
30
  }