@schlenkr/ragents 0.1.6 → 0.1.8

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 (150) hide show
  1. package/apps/server/src/chat-handler.ts +2 -0
  2. package/apps/server/src/config.ts +6 -0
  3. package/apps/server/src/host-api.json +1 -0
  4. package/apps/server/src/layout.ts +0 -15
  5. package/apps/server/src/plugin-support/agent-tool.ts +2 -3
  6. package/apps/server/src/plugin-support/plugin-folder.ts +2 -1
  7. package/apps/server/src/provider.ts +34 -11
  8. package/apps/server/src/ragents/actor-chat-history.ts +1 -0
  9. package/apps/server/src/ragents/engine.ts +23 -24
  10. package/apps/server/src/ragents/journal-chat-events.ts +2 -0
  11. package/apps/server/src/ragents/run-owner.ts +3 -2
  12. package/apps/server/src/ragents/session.ts +3 -3
  13. package/apps/server/src/run-preparation.ts +14 -18
  14. package/apps/server/src/run-transfer.ts +65 -4
  15. package/apps/server/src/settings.ts +2 -4
  16. package/apps/web/dist/assets/{highlighted-body-KPVGNVTW-B9qYBARS.js → highlighted-body-KPVGNVTW-xXXhTDbh.js} +1 -1
  17. package/apps/web/dist/assets/{main-BCjvD2Hh.js → main-C7JeZFjs.js} +1 -1
  18. package/apps/web/dist/assets/{mermaid-HWGCJPDP-CvYYFK_n.js → mermaid-HWGCJPDP-DfsU5ofC.js} +69 -69
  19. package/apps/web/dist/assets/{runPanel-CG7kRMJh.js → runPanel-ZT6TPDLM.js} +1 -1
  20. package/apps/web/dist/help/guide-clients.html +13 -4
  21. package/apps/web/dist/help/guide-clients.md +14 -4
  22. package/apps/web/dist/help/guide-distributed.html +8 -3
  23. package/apps/web/dist/help/guide-distributed.md +8 -3
  24. package/apps/web/dist/help/guide-runtime.html +18 -12
  25. package/apps/web/dist/help/guide-runtime.md +19 -12
  26. package/apps/web/dist/help/mini-app.css +23 -3
  27. package/apps/web/dist/host-web.json +4 -4
  28. package/apps/web/dist/index.html +2 -2
  29. package/apps/web/dist/run-panel.html +2 -2
  30. package/apps/web/src/SessionList.tsx +16 -8
  31. package/apps/web/src/StartTiles.tsx +1 -1
  32. package/apps/web/src/api.ts +2 -0
  33. package/apps/web/src/panel/PanelPage.tsx +1 -1
  34. package/apps/web/src/panel/RunLine.tsx +4 -2
  35. package/apps/web/src/panel/contract.ts +2 -0
  36. package/bundles/ragents.activity/ragents-bundle.json +1 -1
  37. package/bundles/ragents.actor-programs/ragents-bundle.json +1 -1
  38. package/bundles/ragents.ask/ragents-bundle.json +1 -1
  39. package/bundles/ragents.browser/ragents-bundle.json +1 -1
  40. package/bundles/ragents.documents/ragents-bundle.json +1 -1
  41. package/bundles/ragents.lsp-fsharp/ragents-bundle.json +1 -1
  42. package/bundles/ragents.lsp-roslyn/ragents-bundle.json +1 -1
  43. package/bundles/ragents.lsp-typescript/ragents-bundle.json +1 -1
  44. package/bundles/ragents.model-relay/ragents-bundle.json +1 -1
  45. package/bundles/ragents.orchestration/ragents-bundle.json +1 -1
  46. package/bundles/ragents.overseer/ragents-bundle.json +1 -1
  47. package/bundles/ragents.processes/ragents-bundle.json +1 -1
  48. package/bundles/ragents.product/ragents-bundle.json +1 -1
  49. package/bundles/ragents.profile-distribution/ragents-bundle.json +1 -1
  50. package/bundles/ragents.reference/ragents-bundle.json +2 -2
  51. package/bundles/ragents.reference/run-scripts/learning-afternoon/tests/program.test.ts +1 -1
  52. package/bundles/ragents.reference/run-scripts/word-game/tests/program.test.ts +3 -3
  53. package/bundles/ragents.todo/ragents-bundle.json +1 -1
  54. package/bundles/ragents.transcript/ragents-bundle.json +1 -1
  55. package/bundles/ragents.watch/ragents-bundle.json +1 -1
  56. package/bundles/ragents.workspace/ragents-bundle.json +1 -1
  57. package/package.json +2 -2
  58. package/packages/agent/dist/core/agent-settings.d.ts +2 -2
  59. package/packages/agent/dist/core/compaction/compaction.d.ts +16 -50
  60. package/packages/agent/dist/core/context-log.d.ts +25 -0
  61. package/packages/agent/dist/core/messages.d.ts +3 -10
  62. package/packages/agent/dist/core/tool-definition.d.ts +17 -0
  63. package/packages/agent/dist/core/tools/bash.d.ts +2 -7
  64. package/packages/agent/dist/core/tools/edit.d.ts +1 -1
  65. package/packages/agent/dist/core/tools/read.d.ts +1 -1
  66. package/packages/agent/dist/core/tools/write.d.ts +1 -1
  67. package/packages/agent/dist/index.d.ts +7 -8
  68. package/packages/agent/dist/loop/agent.d.ts +2 -6
  69. package/packages/agent/package.json +1 -1
  70. package/packages/agent/src/core/agent-settings.ts +2 -2
  71. package/packages/agent/src/core/compaction/compaction.ts +49 -175
  72. package/packages/agent/src/core/context-log.ts +49 -0
  73. package/packages/agent/src/core/messages.ts +5 -11
  74. package/packages/agent/src/core/tool-definition.ts +29 -0
  75. package/packages/agent/src/core/tools/bash.ts +2 -9
  76. package/packages/agent/src/core/tools/edit.ts +2 -11
  77. package/packages/agent/src/core/tools/read.ts +3 -18
  78. package/packages/agent/src/core/tools/write.ts +1 -5
  79. package/packages/agent/src/index.ts +28 -14
  80. package/packages/agent/src/loop/agent-loop.ts +1 -2
  81. package/packages/agent/src/loop/agent.ts +8 -2
  82. package/packages/ai/dist/api/ai-sdk.d.ts +2 -0
  83. package/packages/ai/dist/types.d.ts +2 -0
  84. package/packages/ai/src/api/ai-sdk-messages.ts +15 -10
  85. package/packages/ai/src/api/ai-sdk.ts +11 -0
  86. package/packages/ai/src/api/transform-messages.ts +1 -1
  87. package/packages/ai/src/types.ts +2 -0
  88. package/packages/ai/src/utils/retry.ts +14 -0
  89. package/packages/ragents/src/agents/actor-input.ts +15 -0
  90. package/packages/ragents/src/agents/model-context.ts +360 -0
  91. package/packages/ragents/src/agents/plugins.ts +5 -0
  92. package/packages/ragents/src/agents/scheduler.ts +3 -7
  93. package/packages/ragents/src/agents/tools.ts +2 -2
  94. package/packages/ragents/src/agents/toolset.ts +47 -20
  95. package/packages/ragents/src/agents/workspaces.ts +0 -6
  96. package/packages/ragents/src/domain/event-semantics.ts +51 -0
  97. package/packages/ragents/src/domain/event-validation.ts +166 -0
  98. package/packages/ragents/src/domain/events.ts +72 -0
  99. package/packages/ragents/src/domain/model.ts +4 -2
  100. package/packages/ragents/src/domain/projection.ts +9 -0
  101. package/packages/ragents/src/domain/tool-result-text.ts +9 -0
  102. package/packages/ragents/src/drivers/agent-hooks.ts +25 -38
  103. package/packages/ragents/src/drivers/agent-runtime.ts +118 -933
  104. package/packages/ragents/src/drivers/agent-turn.ts +735 -0
  105. package/packages/ragents/src/drivers/agent.ts +9 -7
  106. package/packages/ragents/src/drivers/skill-preload.ts +53 -63
  107. package/packages/ragents/src/drivers/types.ts +21 -5
  108. package/packages/ragents/src/index.ts +8 -6
  109. package/packages/ragents/src/plugin-host.ts +60 -13
  110. package/packages/ragents/src/plugin-types.ts +7 -2
  111. package/packages/ragents/src/runtime/decisions/actors.ts +10 -0
  112. package/packages/ragents/src/runtime/decisions/turns.ts +66 -7
  113. package/packages/ragents/src/runtime/journal-storage.ts +7 -4
  114. package/packages/ragents/src/runtime/journal.ts +35 -0
  115. package/packages/ragents/src/runtime/orchestration.ts +140 -9
  116. package/packages/workspace-executor/src/sandbox-tools.ts +10 -11
  117. package/plugins/ragents.reference/run-scripts/learning-afternoon/tests/program.test.ts +1 -1
  118. package/plugins/ragents.reference/run-scripts/word-game/tests/program.test.ts +3 -3
  119. package/scripts/agent/journal.ts +5 -3
  120. package/scripts/package/publish-package.ts +4 -3
  121. package/packages/agent/dist/core/agent-session-runtime.d.ts +0 -33
  122. package/packages/agent/dist/core/agent-session-services.d.ts +0 -35
  123. package/packages/agent/dist/core/agent-session.d.ts +0 -234
  124. package/packages/agent/dist/core/auth-guidance.d.ts +0 -4
  125. package/packages/agent/dist/core/defaults.d.ts +0 -3
  126. package/packages/agent/dist/core/extensions/index.d.ts +0 -11
  127. package/packages/agent/dist/core/extensions/loader.d.ts +0 -12
  128. package/packages/agent/dist/core/extensions/runner.d.ts +0 -39
  129. package/packages/agent/dist/core/extensions/types.d.ts +0 -156
  130. package/packages/agent/dist/core/extensions/wrapper.d.ts +0 -12
  131. package/packages/agent/dist/core/resource-loader.d.ts +0 -39
  132. package/packages/agent/dist/core/sdk.d.ts +0 -38
  133. package/packages/agent/dist/core/session-manager.d.ts +0 -189
  134. package/packages/agent/dist/core/source-info.d.ts +0 -16
  135. package/packages/agent/dist/core/system-prompt.d.ts +0 -21
  136. package/packages/agent/src/core/agent-session-runtime.ts +0 -94
  137. package/packages/agent/src/core/agent-session-services.ts +0 -74
  138. package/packages/agent/src/core/agent-session.ts +0 -1108
  139. package/packages/agent/src/core/auth-guidance.ts +0 -14
  140. package/packages/agent/src/core/defaults.ts +0 -3
  141. package/packages/agent/src/core/extensions/index.ts +0 -38
  142. package/packages/agent/src/core/extensions/loader.ts +0 -125
  143. package/packages/agent/src/core/extensions/runner.ts +0 -211
  144. package/packages/agent/src/core/extensions/types.ts +0 -197
  145. package/packages/agent/src/core/extensions/wrapper.ts +0 -24
  146. package/packages/agent/src/core/resource-loader.ts +0 -142
  147. package/packages/agent/src/core/sdk.ts +0 -123
  148. package/packages/agent/src/core/session-manager.ts +0 -743
  149. package/packages/agent/src/core/source-info.ts +0 -28
  150. package/packages/agent/src/core/system-prompt.ts +0 -108
@@ -172,7 +172,7 @@
172
172
  }
173
173
  },
174
174
  "stand": "04d3cd3b2394dc698c36386e4e24a5f551d75207db44ceb6295e6b0aa688656d",
175
- "sourceStand": "5a6693e08ee33318be87be978178ea0676191bc1ff8a60e0a26ff951ebc1ff11",
175
+ "sourceStand": "00d1dfef1200d3b1c4f51a12dbf126c9f0ae06da62a6ed691638c92a22d0c12d",
176
176
  "server": "server/index.js",
177
177
  "web": {
178
178
  "entry": "web/index.js",
@@ -129,7 +129,7 @@
129
129
  }
130
130
  },
131
131
  "stand": "09df34aa3b7215537058517cd34d9b0065706507daa918b9122eb50dadbfa897",
132
- "sourceStand": "ede033b21ba5ec27edbbc1fc94417d640e6ad81c6594a85532cc40a2c8b1fb54",
132
+ "sourceStand": "a9f28ead727f065d2241e1fc0b49f31c1e9a6f8e4bdad26393c2f1d7c080dbc4",
133
133
  "server": "server/index.js",
134
134
  "web": {
135
135
  "entry": "web/index.js",
@@ -78,7 +78,7 @@
78
78
  }
79
79
  },
80
80
  "stand": "987603befb33bb6cbdf130bf48c606f09549cfcce8811ffcef62a235640d79f5",
81
- "sourceStand": "c53ca466e231c776b26f8a82620cbe18b992fc8698272bdc30468a7b2965454a",
81
+ "sourceStand": "8c4a54ab7237c74d3fc000b6e0fcc400a7a9b2f9b53219a3b78587f37f978abe",
82
82
  "server": "server/index.js",
83
83
  "web": {
84
84
  "entry": "web/index.js",
@@ -76,7 +76,7 @@
76
76
  }
77
77
  },
78
78
  "stand": "83bcb0d455b8559983cc7811b8c3ba4a9ec5d2d595c7489c322d8a7e193a2f0c",
79
- "sourceStand": "5ff99fc7488a7f23083d596ffa4eb0bf8d01431856fec65d33295379439346a8",
79
+ "sourceStand": "5a31a5884bbdecb161987cea6fb768a81fdb6bf774a3d6687ad725f2667bd53e",
80
80
  "server": "server/index.js",
81
81
  "web": {
82
82
  "entry": "web/index.js",
@@ -53,7 +53,7 @@
53
53
  "web": {}
54
54
  },
55
55
  "stand": "bfbd7567f9d0fe8aa6b6600c5e9750caab844053d93fbce389e02a169d151b18",
56
- "sourceStand": "0ae80be7482ac722feed6a2c715d5c5c9ecaf617d806839d9e9c68f8605a2777",
56
+ "sourceStand": "31d397812908e9f38efe5ba5923ba6f6f53624607453b41ffd7d62e688685cbb",
57
57
  "server": "server/index.js",
58
58
  "exports": {
59
59
  "server": {},
@@ -20,8 +20,8 @@
20
20
  ]
21
21
  }
22
22
  },
23
- "stand": "c158c80b63caca976d55e47cdc8d9718075cbc4a50ad916aecd32f3c449d1be3",
24
- "sourceStand": "d7eef6dbb6060fab2555a85ef5bc28cf4f43558660d79d48fc5cfb9260103b18",
23
+ "stand": "b3fa5275dc209c315f26ec832458603d442d2a56974471ee83292e7d26079a12",
24
+ "sourceStand": "6db28f060bf31d72dc73f716a86c7122ce25d67e6b9c81ceba034e96fe735fd9",
25
25
  "server": "server/index.js",
26
26
  "web": {
27
27
  "entry": "web/index.js",
@@ -214,5 +214,5 @@ test("der gemeinsame Ablauf liefert Helferaufträge, Prompt und parallele Graphz
214
214
  await program.onInput(eventOf("experiment", "actor.stopped", {}), context);
215
215
  const failed = workflowGraph(learningWorkflow, learningWorkflowState(context.state.read().board!));
216
216
  assert.deepEqual(failed.nodes.map((node) => [node.id, node.status]), [["experiment", "blocked"], ["quiz", "done"], ["collect", "blocked"]]);
217
- assert.match(failed.nodes.find((node) => node.id === "collect")!.detail!, /1 von 2/);
217
+ assert.match(failed.nodes.find((node) => node.id === "collect")!.detail!, /1 of 2/);
218
218
  });
@@ -96,7 +96,7 @@ test("wartet auf spätere Ereignisse, zählt zwölf Beiträge und beendet die We
96
96
  assert.deepEqual(inputs.map((call) => (call.input as { actor: string }).actor), words.map((_word, index) => `actor-${participants[index % 4]!.handle}`));
97
97
  assert.equal(context.state.read().status, "completed");
98
98
  assert.equal(context.state.read().entries?.length, 12);
99
- assert.match(context.state.read().document!, /12\. Grün: Blume/);
99
+ assert.match(context.state.read().document!, /12\. Green: Blume/);
100
100
  assert.equal(context.state.read().pendingInputId, undefined);
101
101
  assert.deepEqual(await program.functions.start({}, context), { accepted: false });
102
102
  });
@@ -122,7 +122,7 @@ for (const scenario of [
122
122
  { name: "Modellfehler", word: "Strand", options: { outcome: "failed" } },
123
123
  { name: "Unterbrechung", word: "Strand", options: { type: "turn.interrupted" } },
124
124
  { name: "Mehrwortantwort", word: "Schöner Strand", options: {} },
125
- { name: "wiederholtes Ausgangswort", word: "sonne", options: {} },
125
+ { name: "wiederholtes Ausgangswort", word: "sun", options: {} },
126
126
  ]) {
127
127
  test(`${scenario.name} bleibt als Fehler sichtbar und startet nicht erneut`, async () => {
128
128
  const { context, calls, response, start } = fixture();
@@ -247,6 +247,6 @@ test("ein gestoppter aktueller Teilnehmer hält das Spiel an", async () => {
247
247
  await start();
248
248
  await program.onInput(response("Strand", { type: "actor.stopped" }), context);
249
249
  assert.equal(context.state.read().status, "error");
250
- assert.match(context.state.read().error!, /Rot wurde gestoppt/);
250
+ assert.match(context.state.read().error!, /Red wurde gestoppt/);
251
251
  assert.equal(context.state.read().entries?.length, 0);
252
252
  });
@@ -33,7 +33,7 @@
33
33
  }
34
34
  },
35
35
  "stand": "3dd3347780b8ddbe369e9024096d5da94ba34cf37b1003b55e03e3cbc8cd4779",
36
- "sourceStand": "645e499eed8fb1fb1848f82407f093c05acf7d0f217819910d53db047c1b19e0",
36
+ "sourceStand": "dfb507ba9b2a9f99023f75cdb676872db58dcd0f33fab1d1e468c3f09bdebebe",
37
37
  "server": "server/index.js",
38
38
  "web": {
39
39
  "entry": "web/index.js",
@@ -23,7 +23,7 @@
23
23
  "web": {}
24
24
  },
25
25
  "stand": "98d8ba054df383ac3d2d13e25de7f1930a7e4301654e188847cfc1fcf135490b",
26
- "sourceStand": "fe1837e356cd3f36fe94c4e7105800289032929ed9f9bd9ef2aa13b4654fe674",
26
+ "sourceStand": "047848b91abec440121b9d392fd4c268799e674198b9497cd9ad842d32522025",
27
27
  "server": "server/index.js",
28
28
  "exports": {
29
29
  "server": {},
@@ -25,7 +25,7 @@
25
25
  "web": {}
26
26
  },
27
27
  "stand": "f5cade80192041cee54457035b293425a10f1de42b49f1d804117ad7951c1b00",
28
- "sourceStand": "1137b9394272596b02d57f2257b2da60503cc1f0ca9a92745f999f6ad7f32512",
28
+ "sourceStand": "9b701a2a9708f14452ca7548677c735f70b6d013e1e0438bbd7a19c38bc96545",
29
29
  "server": "server/index.js",
30
30
  "exports": {
31
31
  "server": {
@@ -131,7 +131,7 @@
131
131
  }
132
132
  },
133
133
  "stand": "014f6c3e925196716315c4827b73e71a9b98579e620f0cc1beeb3bec763520a8",
134
- "sourceStand": "86fdc3445cc414067d94d110f8c5f351a9285949aa1244a286ae49cbd9db0652",
134
+ "sourceStand": "dabaf431c288a40f14c521ca52da35a66e80e1a5352b5486d464b91a7cbecd5e",
135
135
  "server": "server/index.js",
136
136
  "web": {
137
137
  "entry": "web/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schlenkr/ragents",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "RAgents-Host: Server, Engine, Plugins und Werkzeuge ohne Quell-Checkout",
5
5
  "keywords": [
6
6
  "agents",
@@ -70,6 +70,6 @@
70
70
  "yaml": "2.9.0"
71
71
  },
72
72
  "ragents": {
73
- "hostVersion": "b3d22f501459de3458397f4384273ec283dba6fc"
73
+ "hostVersion": "3634c32d41f5905b3880737716052b3c28f90ced"
74
74
  }
75
75
  }
@@ -1,11 +1,11 @@
1
- /** The few knobs of an agent session; everything else is fixed. */
1
+ /** The few knobs of an agent's runtime; everything else is fixed. */
2
2
  export interface AgentSettings {
3
3
  compaction: {
4
4
  enabled: boolean;
5
5
  reserveTokens: number;
6
6
  keepRecentTokens: number;
7
7
  };
8
- /** Retries of the session after a retryable model error, with exponential backoff. */
8
+ /** Retries after a retryable model error, with exponential backoff. */
9
9
  retry: {
10
10
  enabled: boolean;
11
11
  maxRetries: number;
@@ -1,26 +1,16 @@
1
- /**
2
- * Context compaction for long sessions.
3
- *
4
- * Pure functions for compaction logic. The session manager handles I/O,
5
- * and after compaction the session is reloaded.
6
- */
1
+ /** Context compaction over the context log of one agent; pure functions, the caller persists the result. */
7
2
  import type { AgentMessage, StreamFn, ThinkingLevel } from "../../loop/index.ts";
8
3
  import type { Model, Usage } from "@ragents/ai";
9
- import { type SessionEntry } from "../session-manager.ts";
4
+ import { type ContextLogEntry } from "../context-log.ts";
10
5
  import { type FileOperations } from "./utils.ts";
11
- /** Details stored in CompactionEntry.details for file tracking */
12
- export interface CompactionDetails {
13
- readFiles: string[];
14
- modifiedFiles: string[];
15
- }
16
- /** Result from compact() - SessionManager adds uuid/parentUuid when saving */
17
- export interface CompactionResult<T = unknown> {
6
+ /** Result of compact(); the caller records it as a compaction entry. */
7
+ export interface CompactionResult {
18
8
  summary: string;
19
- firstKeptEntryId: string;
9
+ firstKeptId: string;
20
10
  tokensBefore: number;
21
11
  estimatedTokensAfter?: number;
22
- /** Extension-specific data (e.g., ArtifactIndex, version markers for structured compaction) */
23
- details?: T;
12
+ readFiles: string[];
13
+ modifiedFiles: string[];
24
14
  }
25
15
  export interface CompactionSettings {
26
16
  enabled: boolean;
@@ -52,11 +42,8 @@ export declare function shouldCompact(contextTokens: number, contextWindow: numb
52
42
  * This is conservative (overestimates tokens).
53
43
  */
54
44
  export declare function estimateTokens(message: AgentMessage): number;
55
- /**
56
- * Find the context-visible user-role message that starts the turn containing the given entry index.
57
- * Returns -1 if no turn start found before the index.
58
- */
59
- export declare function findTurnStartIndex(entries: SessionEntry[], entryIndex: number, startIndex: number): number;
45
+ /** The user-like message that starts the turn containing the given index, or -1. */
46
+ export declare function findTurnStartIndex(entries: ContextLogEntry[], entryIndex: number, startIndex: number): number;
60
47
  export interface CutPointResult {
61
48
  /** Index of first entry to keep */
62
49
  firstKeptEntryIndex: number;
@@ -65,31 +52,16 @@ export interface CutPointResult {
65
52
  /** Whether this cut splits a turn (cut point is not a user message) */
66
53
  isSplitTurn: boolean;
67
54
  }
68
- /**
69
- * Find the cut point in session entries that keeps approximately `keepRecentTokens`.
70
- *
71
- * Algorithm: Walk backwards from newest, accumulating estimated message sizes.
72
- * Stop when we've accumulated >= keepRecentTokens. Cut at that point.
73
- *
74
- * Can cut at user OR assistant messages (never tool results). When cutting at an
75
- * assistant message with tool calls, its tool results come after and will be kept.
76
- *
77
- * Returns CutPointResult with:
78
- * - firstKeptEntryIndex: the entry index to start keeping from
79
- * - turnStartIndex: if cutting mid-turn, the user message that started that turn
80
- * - isSplitTurn: whether we're cutting in the middle of a turn
81
- *
82
- * Only considers entries between `startIndex` and `endIndex` (exclusive).
83
- */
84
- export declare function findCutPoint(entries: SessionEntry[], startIndex: number, endIndex: number, keepRecentTokens: number): CutPointResult;
55
+ /** The valid cut point that keeps about `keepRecentTokens` of the entries between `startIndex` and `endIndex`, counted from the newest. */
56
+ export declare function findCutPoint(entries: ContextLogEntry[], startIndex: number, endIndex: number, keepRecentTokens: number): CutPointResult;
85
57
  /**
86
58
  * Generate a summary of the conversation using the LLM.
87
59
  * If previousSummary is provided, uses the update prompt to merge.
88
60
  */
89
61
  export declare function generateSummary(currentMessages: AgentMessage[], model: Model<any>, reserveTokens: number, apiKey: string | undefined, headers?: Record<string, string>, signal?: AbortSignal, customInstructions?: string, previousSummary?: string, thinkingLevel?: ThinkingLevel, streamFn?: StreamFn, env?: Record<string, string>): Promise<string>;
90
62
  export interface CompactionPreparation {
91
- /** UUID of first entry to keep */
92
- firstKeptEntryId: string;
63
+ /** Id of the first entry to keep */
64
+ firstKeptId: string;
93
65
  /** Messages that will be summarized and discarded */
94
66
  messagesToSummarize: AgentMessage[];
95
67
  /** Messages that will be turned into turn prefix summary (if splitting) */
@@ -101,16 +73,10 @@ export interface CompactionPreparation {
101
73
  previousSummary?: string;
102
74
  /** File operations extracted from messagesToSummarize */
103
75
  fileOps: FileOperations;
104
- /** Compaction settions from settings.jsonl */
105
76
  settings: CompactionSettings;
106
77
  }
107
- export declare function prepareCompaction(pathEntries: SessionEntry[], settings: CompactionSettings): CompactionPreparation | undefined;
108
- /**
109
- * Generate summaries for compaction using prepared data.
110
- * Returns CompactionResult - SessionManager adds uuid/parentUuid when saving.
111
- *
112
- * @param preparation - Pre-calculated preparation from prepareCompaction()
113
- * @param customInstructions - Optional custom focus for the summary
114
- */
78
+ /** Prepares a compaction of the whole context log; undefined when there is nothing to summarize. */
79
+ export declare function prepareCompaction(entries: ContextLogEntry[], settings: CompactionSettings): CompactionPreparation | undefined;
80
+ /** Summarizes a prepared compaction; the caller records the result. */
115
81
  export declare function compact(preparation: CompactionPreparation, model: Model<any>, apiKey: string | undefined, headers?: Record<string, string>, customInstructions?: string, signal?: AbortSignal, thinkingLevel?: ThinkingLevel, streamFn?: StreamFn, env?: Record<string, string>): Promise<CompactionResult>;
116
82
  //# sourceMappingURL=compaction.d.ts.map
@@ -0,0 +1,25 @@
1
+ import type { AgentMessage } from "../loop/index.ts";
2
+ /** A compaction replaces every entry before its first kept entry with its summary. */
3
+ export interface ContextCompaction {
4
+ kind: "compaction";
5
+ id: string;
6
+ summary: string;
7
+ firstKeptId: string;
8
+ tokensBefore: number;
9
+ timestamp: number;
10
+ readFiles: string[];
11
+ modifiedFiles: string[];
12
+ }
13
+ /** One entry of an agent's model context in the order the conversation produced it. */
14
+ export type ContextLogEntry = {
15
+ kind: "message";
16
+ id: string;
17
+ message: AgentMessage;
18
+ } | ContextCompaction;
19
+ export declare function latestCompaction(entries: readonly ContextLogEntry[]): ContextCompaction | undefined;
20
+ /** The entries the model sees: the latest compaction, the entries it keeps, and everything after it. */
21
+ export declare function activeContextEntries(entries: readonly ContextLogEntry[]): ContextLogEntry[];
22
+ export declare function contextEntryMessages(entry: ContextLogEntry): AgentMessage[];
23
+ /** The messages of the model context, compaction-aware; the order is the order of the log. */
24
+ export declare function contextMessages(entries: readonly ContextLogEntry[]): AgentMessage[];
25
+ //# sourceMappingURL=context-log.d.ts.map
@@ -3,7 +3,7 @@ import type { AgentMessage } from "../loop/index.ts";
3
3
  import type { Message, UserContent } from "@ragents/ai";
4
4
  export declare const COMPACTION_SUMMARY_PREFIX = "The conversation history before this point was compacted into the following summary:\n\n<summary>\n";
5
5
  export declare const COMPACTION_SUMMARY_SUFFIX = "\n</summary>";
6
- /** Message that an extension injects into the context of a model call. */
6
+ /** A hidden note that a hook adds to one model call; it is not part of the context. */
7
7
  export interface CustomMessage<T = unknown> {
8
8
  role: "custom";
9
9
  customType: string;
@@ -24,14 +24,7 @@ declare module "../loop/types.ts" {
24
24
  compactionSummary: CompactionSummaryMessage;
25
25
  }
26
26
  }
27
- export declare function createCompactionSummaryMessage(summary: string, tokensBefore: number, timestamp: string): CompactionSummaryMessage;
28
- /**
29
- * Transform AgentMessages (including custom types) to LLM-compatible Messages.
30
- *
31
- * This is used by:
32
- * - Agent's transormToLlm option (for prompt calls and queued messages)
33
- * - Compaction's generateSummary (for summarization)
34
- * - Custom extensions and tools
35
- */
27
+ export declare function createCompactionSummaryMessage(summary: string, tokensBefore: number, timestamp: number): CompactionSummaryMessage;
28
+ /** Transform AgentMessages, including hook notes and compaction summaries, to LLM messages. */
36
29
  export declare function convertToLlm(messages: AgentMessage[]): Message[];
37
30
  //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1,17 @@
1
+ /** The form of the read, write, edit and bash tools; the host runs them in its workspace executor. */
2
+ import type { AgentToolResult, AgentToolUpdateCallback, ToolExecutionMode } from "../loop/index.ts";
3
+ import type { Static, TSchema } from "typebox";
4
+ export type { AgentToolResult, AgentToolUpdateCallback, ToolExecutionMode };
5
+ export interface ToolDefinition<TParams extends TSchema = TSchema, TDetails = unknown> {
6
+ name: string;
7
+ label: string;
8
+ description: string;
9
+ parameters: TParams;
10
+ /** Optional compatibility shim to prepare raw tool call arguments before schema validation. */
11
+ prepareArguments?: (args: unknown) => Static<TParams>;
12
+ executionMode?: ToolExecutionMode;
13
+ execute(toolCallId: string, params: Static<TParams>, signal: AbortSignal | undefined, onUpdate: AgentToolUpdateCallback<TDetails> | undefined): Promise<AgentToolResult<TDetails>>;
14
+ }
15
+ /** Preserve parameter inference for standalone tool definitions. */
16
+ export declare function defineTool<TParams extends TSchema, TDetails = unknown>(tool: ToolDefinition<TParams, TDetails>): ToolDefinition<TParams, TDetails>;
17
+ //# sourceMappingURL=tool-definition.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { Type } from "typebox";
2
- import type { ToolDefinition } from "../extensions/types.ts";
2
+ import type { ToolDefinition } from "../tool-definition.ts";
3
3
  import { type TruncationResult } from "./truncate.ts";
4
4
  export declare const BASH_MAX_BYTES: number;
5
5
  export declare const BASH_MAX_LINE_CHARS = 1000;
@@ -33,12 +33,7 @@ export interface BashOperations {
33
33
  exitCode: number | null;
34
34
  }>;
35
35
  }
36
- /**
37
- * Create bash operations using the built-in local shell execution backend.
38
- *
39
- * This is useful for extensions that intercept user_bash and still want the
40
- * standard local shell behavior while wrapping or rewriting commands.
41
- */
36
+ /** Bash operations on the built-in local shell. */
42
37
  export declare function createLocalBashOperations(options?: {
43
38
  shellPath?: string;
44
39
  }): BashOperations;
@@ -1,5 +1,5 @@
1
1
  import { type Static, Type } from "typebox";
2
- import type { ToolDefinition } from "../extensions/types.ts";
2
+ import type { ToolDefinition } from "../tool-definition.ts";
3
3
  declare const editSchema: Type.TObject<{
4
4
  path: Type.TString;
5
5
  edits: Type.TArray<Type.TObject<{
@@ -1,5 +1,5 @@
1
1
  import { Type } from "typebox";
2
- import type { ToolDefinition } from "../extensions/types.ts";
2
+ import type { ToolDefinition } from "../tool-definition.ts";
3
3
  import { type TruncationResult } from "./truncate.ts";
4
4
  declare const readSchema: Type.TObject<{
5
5
  path: Type.TString;
@@ -1,5 +1,5 @@
1
1
  import { Type } from "typebox";
2
- import type { ToolDefinition } from "../extensions/types.ts";
2
+ import type { ToolDefinition } from "../tool-definition.ts";
3
3
  declare const writeSchema: Type.TObject<{
4
4
  path: Type.TString;
5
5
  content: Type.TString;
@@ -1,13 +1,12 @@
1
- export type { AgentSession } from "./core/agent-session.ts";
2
- export type { ExtensionAPI, ExtensionContext, ExtensionError, InlineExtension, ToolDefinition } from "./core/extensions/index.ts";
3
- export { defineTool } from "./core/extensions/index.ts";
4
1
  export { aliasedModel, type ModelAlias, ModelRuntime } from "./core/model-runtime.ts";
5
- export { DefaultResourceLoader } from "./core/resource-loader.ts";
6
- export { type AgentSessionRuntime, type CreateAgentSessionRuntimeFactory, createAgentSession, createAgentSessionFromServices, createAgentSessionRuntime, createAgentSessionServices, } from "./core/sdk.ts";
7
- export { CURRENT_SESSION_VERSION, type SessionEntry, SessionManager } from "./core/session-manager.ts";
8
- export type { AgentSettingsInput } from "./core/agent-settings.ts";
9
- export type { Skill } from "./core/skills.ts";
2
+ export { type AgentSettings, type AgentSettingsInput, agentSettings } from "./core/agent-settings.ts";
3
+ export { activeContextEntries, type ContextCompaction, type ContextLogEntry, contextMessages, latestCompaction, } from "./core/context-log.ts";
4
+ export { calculateContextTokens, compact, estimateContextTokens, prepareCompaction, shouldCompact, } from "./core/compaction/index.ts";
5
+ export { convertToLlm } from "./core/messages.ts";
6
+ export { formatSkillsForPrompt, type Skill } from "./core/skills.ts";
7
+ export { defineTool, type ToolDefinition } from "./core/tool-definition.ts";
10
8
  export { type BashOperations, createBashToolDefinition, createEditToolDefinition, createReadToolDefinition, createWriteToolDefinition, } from "./core/tools/index.ts";
9
+ export { Agent, type AgentEvent, type AgentLoopTurnUpdate, type AgentMessage, type AgentTool, type AgentToolResult, EMPTY_RESPONSE_NUDGE, isRunFailure, type ThinkingLevel, } from "./loop/index.ts";
11
10
  export { parseFrontmatter, stripFrontmatter } from "./utils/frontmatter.ts";
12
11
  export { getShellConfig, killProcessTree, type ShellConfig } from "./utils/shell.ts";
13
12
  //# sourceMappingURL=index.d.ts.map
@@ -18,12 +18,8 @@ export interface AgentOptions {
18
18
  maxRetryDelayMs?: number;
19
19
  toolExecution?: ToolExecutionMode;
20
20
  }
21
- /**
22
- * Stateful wrapper around the low-level agent loop.
23
- *
24
- * `Agent` owns the current transcript, emits lifecycle events, executes tools,
25
- * and polls its steering source before each model request.
26
- */
21
+ /** Whether a message is the stand-in the agent reports for a failed run; no model produced it. */
22
+ export declare const isRunFailure: (message: AgentMessage) => boolean;
27
23
  export declare class Agent {
28
24
  private _state;
29
25
  private readonly listeners;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ragents/agent",
3
3
  "version": "0.80.10",
4
- "description": "The agent runtime of RAgents: agent loop, sessions, compaction, extension hooks and the read, write, edit and bash tools",
4
+ "description": "The agent runtime of RAgents: agent loop, compaction, model runtime and the read, write, edit and bash tools",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
7
7
  "types": "./dist/index.d.ts",
@@ -1,7 +1,7 @@
1
- /** The few knobs of an agent session; everything else is fixed. */
1
+ /** The few knobs of an agent's runtime; everything else is fixed. */
2
2
  export interface AgentSettings {
3
3
  compaction: { enabled: boolean; reserveTokens: number; keepRecentTokens: number };
4
- /** Retries of the session after a retryable model error, with exponential backoff. */
4
+ /** Retries after a retryable model error, with exponential backoff. */
5
5
  retry: { enabled: boolean; maxRetries: number; baseDelayMs: number };
6
6
  /** Timeout and retries of a single provider request; unset values leave the SDK defaults. */
7
7
  providerRequest: { timeoutMs: number; maxRetries?: number; maxRetryDelayMs: number };