@rivus/runtime 0.16.6 → 0.18.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/LICENSE +674 -21
- package/README.md +21 -0
- package/dist/acp.d.ts +7 -92
- package/dist/acp.js +298 -249
- package/dist/chunks/agent-loop.d.ts +143 -95
- package/dist/chunks/agent-user-input.js +109 -0
- package/dist/chunks/rivus-runtime-tool.d.ts +104 -4
- package/dist/chunks/{tool-input-digest.js → tool-risk-policy.js} +7 -14
- package/dist/chunks/user-input-xml.js +224 -0
- package/dist/index.d.ts +107 -823
- package/dist/index.js +242 -705
- package/dist/pi.d.ts +62 -332
- package/dist/pi.js +547 -546
- package/package.json +12 -11
- package/dist/chunks/agent-loop.js +0 -164
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivus/runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Execution core, Pi/ACP adapters, memory, and tool brokerage for Rivus.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "GPL-3.0-only",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": "^24.11.0"
|
|
9
9
|
},
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"LICENSE"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"@rivus/platform": "0.18.0",
|
|
43
44
|
"@earendil-works/pi-coding-agent": "0.84.4",
|
|
44
|
-
"effect": "^
|
|
45
|
-
"typebox": "^1.
|
|
45
|
+
"effect": "^4.0.0",
|
|
46
|
+
"typebox": "^1.3.34",
|
|
46
47
|
"@opentelemetry/api": "^1.9.1",
|
|
47
48
|
"@opentelemetry/exporter-trace-otlp-proto": "^0.222.0",
|
|
48
49
|
"@opentelemetry/resources": "^2.11.0",
|
|
49
50
|
"@opentelemetry/sdk-trace-base": "^2.11.0",
|
|
50
|
-
"@opentelemetry/sdk-trace-node": "^2.11.0"
|
|
51
|
-
"@rivus/platform": "0.16.6"
|
|
51
|
+
"@opentelemetry/sdk-trace-node": "^2.11.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@agentclientprotocol/sdk": "^1.3.0"
|
|
@@ -62,15 +62,16 @@
|
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"vite-plus": "0.
|
|
66
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@0.
|
|
65
|
+
"vite-plus": "1.0.0",
|
|
66
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.0.0",
|
|
67
67
|
"typescript": "6.0.3",
|
|
68
|
-
"@
|
|
69
|
-
"@
|
|
68
|
+
"@typescript/native": "npm:typescript@7.0.2",
|
|
69
|
+
"@types/node": "24.19.0",
|
|
70
|
+
"@vitest/coverage-v8": "5.0.1"
|
|
70
71
|
},
|
|
71
72
|
"scripts": {
|
|
72
73
|
"build": "vp pack",
|
|
73
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
74
|
+
"typecheck": "node node_modules/@typescript/native/bin/tsc -p tsconfig.json --noEmit",
|
|
74
75
|
"test": "vp test --run"
|
|
75
76
|
}
|
|
76
77
|
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { Effect, Stream } from "effect";
|
|
2
|
-
//#region src/core/application/agent-execution/loop/agent-loop.ts
|
|
3
|
-
function createAgentLoopTextDelta(delta) {
|
|
4
|
-
return {
|
|
5
|
-
delta,
|
|
6
|
-
type: "assistant_text_delta"
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
function createAgentLoopTurnStart() {
|
|
10
|
-
return { type: "turn_start" };
|
|
11
|
-
}
|
|
12
|
-
function normalizeAgentLoopEvent(event) {
|
|
13
|
-
return typeof event === "string" ? createAgentLoopTextDelta(event) : event;
|
|
14
|
-
}
|
|
15
|
-
function createAgentLoopThinkingDelta(delta) {
|
|
16
|
-
return {
|
|
17
|
-
delta,
|
|
18
|
-
type: "assistant_thinking_delta"
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function createAgentLoopModelExecutionStart(options) {
|
|
22
|
-
return {
|
|
23
|
-
...options,
|
|
24
|
-
type: "model_execution_start"
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function createAgentLoopModelExecutionEnd(options) {
|
|
28
|
-
return {
|
|
29
|
-
...options,
|
|
30
|
-
type: "model_execution_end"
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function createAgentLoopSkillExecutionStart(options) {
|
|
34
|
-
return {
|
|
35
|
-
...options,
|
|
36
|
-
type: "skill_execution_start"
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function createAgentLoopSkillExecutionEnd(options) {
|
|
40
|
-
return {
|
|
41
|
-
...options,
|
|
42
|
-
type: "skill_execution_end"
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function createAgentLoopToolExecutionStart(options) {
|
|
46
|
-
return {
|
|
47
|
-
input: options.input,
|
|
48
|
-
toolCallId: options.toolCallId,
|
|
49
|
-
toolName: options.toolName,
|
|
50
|
-
type: "tool_execution_start"
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function createAgentLoopToolExecutionUpdate(options) {
|
|
54
|
-
return {
|
|
55
|
-
input: options.input,
|
|
56
|
-
partialResult: options.partialResult,
|
|
57
|
-
toolCallId: options.toolCallId,
|
|
58
|
-
toolName: options.toolName,
|
|
59
|
-
type: "tool_execution_update"
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function createAgentLoopToolExecutionEnd(options) {
|
|
63
|
-
return {
|
|
64
|
-
isError: options.isError,
|
|
65
|
-
result: options.result,
|
|
66
|
-
toolCallId: options.toolCallId,
|
|
67
|
-
toolName: options.toolName,
|
|
68
|
-
type: "tool_execution_end"
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function isPromiseLike$1(value) {
|
|
72
|
-
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
73
|
-
}
|
|
74
|
-
function createEventAgentLoop$1(options) {
|
|
75
|
-
return { run: (input) => {
|
|
76
|
-
const events = typeof options.events === "function" ? options.events(input) : options.events;
|
|
77
|
-
if (isPromiseLike$1(events)) return Stream.fromEffect(Effect.tryPromise({
|
|
78
|
-
try: () => events,
|
|
79
|
-
catch: (cause) => cause
|
|
80
|
-
})).pipe(Stream.flatMap((resolvedEvents) => Stream.fromIterable(resolvedEvents)), Stream.map(normalizeAgentLoopEvent));
|
|
81
|
-
return Stream.fromIterable(events).pipe(Stream.map(normalizeAgentLoopEvent));
|
|
82
|
-
} };
|
|
83
|
-
}
|
|
84
|
-
function createTextAgentLoop$1(options) {
|
|
85
|
-
return { run: (input) => Stream.fromEffect(options.generate(input)).pipe(Stream.map((delta) => createAgentLoopTextDelta(delta))) };
|
|
86
|
-
}
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/adapters/compatibility/agent-execution/loop/agent-loop.ts
|
|
89
|
-
function createEventAgentLoop(options) {
|
|
90
|
-
return fromEffectAgentLoop(createEventAgentLoop$1({ events: (input) => typeof options.events === "function" ? options.events(toCompatibilityAgentLoopInput(input)) : options.events }));
|
|
91
|
-
}
|
|
92
|
-
function createAsyncIterableAgentLoop(options) {
|
|
93
|
-
return { run: (input) => Stream.fromAsyncIterable(options.run(input), (error) => error).pipe(Stream.map(normalizeAgentLoopEvent)) };
|
|
94
|
-
}
|
|
95
|
-
function createAgentLoopFromCallback(run) {
|
|
96
|
-
return { run: (input) => Stream.fromEffect(Effect.try({
|
|
97
|
-
try: () => run(input),
|
|
98
|
-
catch: (cause) => cause
|
|
99
|
-
})).pipe(Stream.flatMap(streamFromAgentLoopCallbackResult)) };
|
|
100
|
-
}
|
|
101
|
-
function createTextAgentLoop(options) {
|
|
102
|
-
return fromEffectAgentLoop(createTextAgentLoop$1({ generate: (input) => options.generate(toCompatibilityAgentLoopInput(input)) }));
|
|
103
|
-
}
|
|
104
|
-
function createTextAgentLoopFromCallback(generate) {
|
|
105
|
-
return createTextAgentLoop({ generate: (input) => Effect.tryPromise({
|
|
106
|
-
try: async () => generate(input),
|
|
107
|
-
catch: (cause) => cause
|
|
108
|
-
}) });
|
|
109
|
-
}
|
|
110
|
-
function toEffectAgentLoop(loop) {
|
|
111
|
-
return {
|
|
112
|
-
run: (input) => loop.run(toCompatibilityAgentLoopInput(input)),
|
|
113
|
-
...loop.supportsSteering ? { supportsSteering: true } : {}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
function fromEffectAgentLoop(loop) {
|
|
117
|
-
return {
|
|
118
|
-
run: (input) => loop.run(toEffectAgentLoopInput(input)),
|
|
119
|
-
...loop.supportsSteering ? { supportsSteering: true } : {}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
function toEffectAgentLoopInput(input) {
|
|
123
|
-
const { steering, ...rest } = input;
|
|
124
|
-
return {
|
|
125
|
-
...rest,
|
|
126
|
-
...steering ? { steering: {
|
|
127
|
-
...steering.close ? { close: () => Effect.promise(() => steering.close()) } : {},
|
|
128
|
-
next: () => Effect.promise((signal) => steering.next(signal))
|
|
129
|
-
} } : {}
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
function toCompatibilityAgentLoopInput(input) {
|
|
133
|
-
const { steering, ...rest } = input;
|
|
134
|
-
return {
|
|
135
|
-
...rest,
|
|
136
|
-
...steering ? { steering: {
|
|
137
|
-
...steering.close ? { close: () => Effect.runPromise(steering.close()) } : {},
|
|
138
|
-
next: (signal) => Effect.runPromise(steering.next(), { signal })
|
|
139
|
-
} } : {}
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function isPromiseLike(value) {
|
|
143
|
-
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
144
|
-
}
|
|
145
|
-
function streamFromAgentLoopCallbackResult(result) {
|
|
146
|
-
if (Effect.isEffect(result)) return Stream.fromEffect(result).pipe(Stream.flatMap(streamFromAgentLoopCallbackOutput));
|
|
147
|
-
if (isPromiseLike(result)) return Stream.fromEffect(Effect.tryPromise({
|
|
148
|
-
try: () => Promise.resolve(result),
|
|
149
|
-
catch: (cause) => cause
|
|
150
|
-
})).pipe(Stream.flatMap(streamFromAgentLoopCallbackOutput));
|
|
151
|
-
return streamFromAgentLoopCallbackOutput(result);
|
|
152
|
-
}
|
|
153
|
-
function streamFromAgentLoopCallbackOutput(output) {
|
|
154
|
-
if (isEffectStream(output)) return output.pipe(Stream.map(normalizeAgentLoopEvent));
|
|
155
|
-
return (isAsyncIterable(output) ? Stream.fromAsyncIterable(output, (error) => error) : Stream.fromIterable(output)).pipe(Stream.map(normalizeAgentLoopEvent));
|
|
156
|
-
}
|
|
157
|
-
function isAsyncIterable(value) {
|
|
158
|
-
return Symbol.asyncIterator in value && typeof value[Symbol.asyncIterator] === "function";
|
|
159
|
-
}
|
|
160
|
-
function isEffectStream(value) {
|
|
161
|
-
return typeof value === "object" && value !== null && Stream.StreamTypeId in value;
|
|
162
|
-
}
|
|
163
|
-
//#endregion
|
|
164
|
-
export { normalizeAgentLoopEvent as S, createAgentLoopToolExecutionStart as _, createTextAgentLoopFromCallback as a, createEventAgentLoop$1 as b, toEffectAgentLoop as c, createAgentLoopModelExecutionStart as d, createAgentLoopSkillExecutionEnd as f, createAgentLoopToolExecutionEnd as g, createAgentLoopThinkingDelta as h, createTextAgentLoop as i, toEffectAgentLoopInput as l, createAgentLoopTextDelta as m, createAsyncIterableAgentLoop as n, fromEffectAgentLoop as o, createAgentLoopSkillExecutionStart as p, createEventAgentLoop as r, toCompatibilityAgentLoopInput as s, createAgentLoopFromCallback as t, createAgentLoopModelExecutionEnd as u, createAgentLoopToolExecutionUpdate as v, createTextAgentLoop$1 as x, createAgentLoopTurnStart as y };
|