@schlenkr/ragents 0.1.6 → 0.1.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/apps/server/src/chat-handler.ts +2 -0
- package/apps/server/src/config.ts +6 -0
- package/apps/server/src/host-api.json +1 -0
- package/apps/server/src/layout.ts +0 -15
- package/apps/server/src/plugin-support/agent-tool.ts +2 -3
- package/apps/server/src/provider.ts +34 -11
- package/apps/server/src/ragents/actor-chat-history.ts +1 -0
- package/apps/server/src/ragents/engine.ts +5 -13
- package/apps/server/src/ragents/journal-chat-events.ts +2 -0
- package/apps/server/src/ragents/run-owner.ts +3 -2
- package/apps/server/src/ragents/session.ts +3 -3
- package/apps/server/src/run-preparation.ts +14 -18
- package/apps/server/src/run-transfer.ts +65 -4
- package/apps/server/src/settings.ts +2 -4
- package/apps/web/dist/assets/{highlighted-body-KPVGNVTW-B9qYBARS.js → highlighted-body-KPVGNVTW-CFhTJEmH.js} +1 -1
- package/apps/web/dist/assets/{main-BCjvD2Hh.js → main-DlzW4t4c.js} +1 -1
- package/apps/web/dist/assets/{mermaid-HWGCJPDP-CvYYFK_n.js → mermaid-HWGCJPDP-kxkB991i.js} +69 -69
- package/apps/web/dist/assets/{runPanel-CG7kRMJh.js → runPanel-BJEFQ__w.js} +1 -1
- package/apps/web/dist/help/guide-clients.html +13 -4
- package/apps/web/dist/help/guide-clients.md +14 -4
- package/apps/web/dist/help/guide-distributed.html +8 -3
- package/apps/web/dist/help/guide-distributed.md +8 -3
- package/apps/web/dist/help/guide-runtime.html +18 -12
- package/apps/web/dist/help/guide-runtime.md +19 -12
- package/apps/web/dist/help/mini-app.css +23 -3
- package/apps/web/dist/host-web.json +3 -3
- package/apps/web/dist/index.html +2 -2
- package/apps/web/dist/run-panel.html +2 -2
- package/apps/web/src/SessionList.tsx +16 -8
- package/apps/web/src/api.ts +2 -0
- package/apps/web/src/panel/PanelPage.tsx +1 -1
- package/apps/web/src/panel/RunLine.tsx +4 -2
- package/apps/web/src/panel/contract.ts +2 -0
- package/bundles/ragents.activity/ragents-bundle.json +1 -1
- package/bundles/ragents.actor-programs/ragents-bundle.json +1 -1
- package/bundles/ragents.ask/ragents-bundle.json +1 -1
- package/bundles/ragents.browser/ragents-bundle.json +1 -1
- package/bundles/ragents.documents/ragents-bundle.json +1 -1
- package/bundles/ragents.lsp-fsharp/ragents-bundle.json +1 -1
- package/bundles/ragents.lsp-roslyn/ragents-bundle.json +1 -1
- package/bundles/ragents.lsp-typescript/ragents-bundle.json +1 -1
- package/bundles/ragents.model-relay/ragents-bundle.json +1 -1
- package/bundles/ragents.orchestration/ragents-bundle.json +1 -1
- package/bundles/ragents.overseer/ragents-bundle.json +1 -1
- package/bundles/ragents.processes/ragents-bundle.json +1 -1
- package/bundles/ragents.product/ragents-bundle.json +1 -1
- package/bundles/ragents.profile-distribution/ragents-bundle.json +1 -1
- package/bundles/ragents.reference/ragents-bundle.json +2 -2
- package/bundles/ragents.reference/run-scripts/learning-afternoon/tests/program.test.ts +1 -1
- package/bundles/ragents.reference/run-scripts/word-game/tests/program.test.ts +3 -3
- package/bundles/ragents.todo/ragents-bundle.json +1 -1
- package/bundles/ragents.transcript/ragents-bundle.json +1 -1
- package/bundles/ragents.watch/ragents-bundle.json +1 -1
- package/bundles/ragents.workspace/ragents-bundle.json +1 -1
- package/package.json +2 -2
- package/packages/agent/dist/core/agent-settings.d.ts +2 -2
- package/packages/agent/dist/core/compaction/compaction.d.ts +16 -50
- package/packages/agent/dist/core/context-log.d.ts +25 -0
- package/packages/agent/dist/core/messages.d.ts +3 -10
- package/packages/agent/dist/core/tool-definition.d.ts +17 -0
- package/packages/agent/dist/core/tools/bash.d.ts +2 -7
- package/packages/agent/dist/core/tools/edit.d.ts +1 -1
- package/packages/agent/dist/core/tools/read.d.ts +1 -1
- package/packages/agent/dist/core/tools/write.d.ts +1 -1
- package/packages/agent/dist/index.d.ts +7 -8
- package/packages/agent/dist/loop/agent.d.ts +2 -6
- package/packages/agent/package.json +1 -1
- package/packages/agent/src/core/agent-settings.ts +2 -2
- package/packages/agent/src/core/compaction/compaction.ts +49 -175
- package/packages/agent/src/core/context-log.ts +49 -0
- package/packages/agent/src/core/messages.ts +5 -11
- package/packages/agent/src/core/tool-definition.ts +29 -0
- package/packages/agent/src/core/tools/bash.ts +2 -9
- package/packages/agent/src/core/tools/edit.ts +2 -11
- package/packages/agent/src/core/tools/read.ts +3 -18
- package/packages/agent/src/core/tools/write.ts +1 -5
- package/packages/agent/src/index.ts +28 -14
- package/packages/agent/src/loop/agent-loop.ts +1 -2
- package/packages/agent/src/loop/agent.ts +8 -2
- package/packages/ai/dist/api/ai-sdk.d.ts +2 -0
- package/packages/ai/dist/types.d.ts +2 -0
- package/packages/ai/src/api/ai-sdk-messages.ts +15 -10
- package/packages/ai/src/api/ai-sdk.ts +11 -0
- package/packages/ai/src/api/transform-messages.ts +1 -1
- package/packages/ai/src/types.ts +2 -0
- package/packages/ai/src/utils/retry.ts +14 -0
- package/packages/ragents/src/agents/actor-input.ts +15 -0
- package/packages/ragents/src/agents/model-context.ts +360 -0
- package/packages/ragents/src/agents/scheduler.ts +3 -7
- package/packages/ragents/src/agents/tools.ts +2 -2
- package/packages/ragents/src/agents/toolset.ts +47 -20
- package/packages/ragents/src/agents/workspaces.ts +0 -6
- package/packages/ragents/src/domain/event-semantics.ts +51 -0
- package/packages/ragents/src/domain/event-validation.ts +166 -0
- package/packages/ragents/src/domain/events.ts +72 -0
- package/packages/ragents/src/domain/model.ts +4 -2
- package/packages/ragents/src/domain/projection.ts +9 -0
- package/packages/ragents/src/domain/tool-result-text.ts +9 -0
- package/packages/ragents/src/drivers/agent-hooks.ts +25 -38
- package/packages/ragents/src/drivers/agent-runtime.ts +118 -933
- package/packages/ragents/src/drivers/agent-turn.ts +735 -0
- package/packages/ragents/src/drivers/agent.ts +9 -7
- package/packages/ragents/src/drivers/skill-preload.ts +53 -63
- package/packages/ragents/src/drivers/types.ts +21 -5
- package/packages/ragents/src/index.ts +7 -6
- package/packages/ragents/src/plugin-host.ts +3 -4
- package/packages/ragents/src/runtime/decisions/actors.ts +10 -0
- package/packages/ragents/src/runtime/decisions/turns.ts +66 -7
- package/packages/ragents/src/runtime/journal-storage.ts +7 -4
- package/packages/ragents/src/runtime/journal.ts +35 -0
- package/packages/ragents/src/runtime/orchestration.ts +140 -9
- package/packages/workspace-executor/src/sandbox-tools.ts +10 -11
- package/plugins/ragents.reference/run-scripts/learning-afternoon/tests/program.test.ts +1 -1
- package/plugins/ragents.reference/run-scripts/word-game/tests/program.test.ts +3 -3
- package/scripts/agent/journal.ts +5 -3
- package/packages/agent/dist/core/agent-session-runtime.d.ts +0 -33
- package/packages/agent/dist/core/agent-session-services.d.ts +0 -35
- package/packages/agent/dist/core/agent-session.d.ts +0 -234
- package/packages/agent/dist/core/auth-guidance.d.ts +0 -4
- package/packages/agent/dist/core/defaults.d.ts +0 -3
- package/packages/agent/dist/core/extensions/index.d.ts +0 -11
- package/packages/agent/dist/core/extensions/loader.d.ts +0 -12
- package/packages/agent/dist/core/extensions/runner.d.ts +0 -39
- package/packages/agent/dist/core/extensions/types.d.ts +0 -156
- package/packages/agent/dist/core/extensions/wrapper.d.ts +0 -12
- package/packages/agent/dist/core/resource-loader.d.ts +0 -39
- package/packages/agent/dist/core/sdk.d.ts +0 -38
- package/packages/agent/dist/core/session-manager.d.ts +0 -189
- package/packages/agent/dist/core/source-info.d.ts +0 -16
- package/packages/agent/dist/core/system-prompt.d.ts +0 -21
- package/packages/agent/src/core/agent-session-runtime.ts +0 -94
- package/packages/agent/src/core/agent-session-services.ts +0 -74
- package/packages/agent/src/core/agent-session.ts +0 -1108
- package/packages/agent/src/core/auth-guidance.ts +0 -14
- package/packages/agent/src/core/defaults.ts +0 -3
- package/packages/agent/src/core/extensions/index.ts +0 -38
- package/packages/agent/src/core/extensions/loader.ts +0 -125
- package/packages/agent/src/core/extensions/runner.ts +0 -211
- package/packages/agent/src/core/extensions/types.ts +0 -197
- package/packages/agent/src/core/extensions/wrapper.ts +0 -24
- package/packages/agent/src/core/resource-loader.ts +0 -142
- package/packages/agent/src/core/sdk.ts +0 -123
- package/packages/agent/src/core/session-manager.ts +0 -743
- package/packages/agent/src/core/source-info.ts +0 -28
- package/packages/agent/src/core/system-prompt.ts +0 -108
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
"stand": "987603befb33bb6cbdf130bf48c606f09549cfcce8811ffcef62a235640d79f5",
|
|
81
|
-
"sourceStand": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
24
|
-
"sourceStand": "
|
|
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
|
|
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\.
|
|
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: "
|
|
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!, /
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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.
|
|
3
|
+
"version": "0.1.7",
|
|
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": "
|
|
73
|
+
"hostVersion": "765802e9cb0252b2a312b2b1b09a557ef8bf13cc"
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/** The few knobs of an agent
|
|
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
|
|
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
|
|
4
|
+
import { type ContextLogEntry } from "../context-log.ts";
|
|
10
5
|
import { type FileOperations } from "./utils.ts";
|
|
11
|
-
/**
|
|
12
|
-
export interface
|
|
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
|
-
|
|
9
|
+
firstKeptId: string;
|
|
20
10
|
tokensBefore: number;
|
|
21
11
|
estimatedTokensAfter?: number;
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
/**
|
|
92
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
/**
|
|
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:
|
|
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 "../
|
|
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 "../
|
|
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 "../
|
|
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,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 {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export
|
|
9
|
-
export type
|
|
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
|
-
|
|
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,
|
|
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
|
|
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
|
|
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 };
|