@rivus/runtime 0.16.2
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 +21 -0
- package/README.md +5 -0
- package/dist/acp.d.ts +179 -0
- package/dist/acp.js +768 -0
- package/dist/chunks/agent-loop.d.ts +481 -0
- package/dist/chunks/agent-loop.js +164 -0
- package/dist/chunks/rivus-runtime-tool.d.ts +386 -0
- package/dist/chunks/tool-input-digest.js +119 -0
- package/dist/index.d.ts +1306 -0
- package/dist/index.js +4164 -0
- package/dist/pi.d.ts +840 -0
- package/dist/pi.js +2143 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PerfectPan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/acp.d.ts
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { C as AgentLoopInput, a as AgentLoopInput$1, b as AgentLoop, t as AgentLoop$1 } from "./chunks/agent-loop.js";
|
|
2
|
+
import * as acp from "@agentclientprotocol/sdk";
|
|
3
|
+
|
|
4
|
+
//#region src/adapters/acp/runtime/acp-agent-loop.d.ts
|
|
5
|
+
type AcpToolCallStatus = "pending" | "in_progress" | "completed" | "failed";
|
|
6
|
+
interface AcpSessionUpdate {
|
|
7
|
+
readonly content?: unknown;
|
|
8
|
+
readonly name?: string | null;
|
|
9
|
+
readonly rawInput?: unknown;
|
|
10
|
+
readonly rawOutput?: unknown;
|
|
11
|
+
readonly sessionUpdate: string;
|
|
12
|
+
readonly status?: AcpToolCallStatus | null;
|
|
13
|
+
readonly title?: string | null;
|
|
14
|
+
readonly toolCallId?: string;
|
|
15
|
+
readonly [key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
interface AcpPromptResult {
|
|
18
|
+
readonly stopReason: string;
|
|
19
|
+
}
|
|
20
|
+
interface AcpAgentSession {
|
|
21
|
+
cancel(options?: {
|
|
22
|
+
readonly preserveSession?: boolean;
|
|
23
|
+
}): Promise<void> | void;
|
|
24
|
+
prompt(text: string, onUpdate: (update: AcpSessionUpdate) => void): Promise<AcpPromptResult>;
|
|
25
|
+
dispose?(): Promise<void> | void;
|
|
26
|
+
invalidate?(): Promise<void> | void;
|
|
27
|
+
}
|
|
28
|
+
interface AcpAgentLoopOptions {
|
|
29
|
+
readonly cancellationSettleTimeoutMs?: number;
|
|
30
|
+
readonly disposeSessionAfterRun?: boolean;
|
|
31
|
+
readonly resolveSession: (input: AgentLoopInput) => Promise<AcpAgentSession> | AcpAgentSession;
|
|
32
|
+
}
|
|
33
|
+
declare function createAcpAgentLoop(options: AcpAgentLoopOptions): AgentLoop;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/adapters/acp/runtime/acp-permission-policy.d.ts
|
|
36
|
+
interface AcpPermissionOption {
|
|
37
|
+
readonly kind: "allow_once" | "allow_always" | "reject_once" | "reject_always";
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly optionId: string;
|
|
40
|
+
}
|
|
41
|
+
interface AcpPermissionToolCall {
|
|
42
|
+
readonly toolCallId: string;
|
|
43
|
+
readonly title?: string;
|
|
44
|
+
readonly rawInput?: unknown;
|
|
45
|
+
}
|
|
46
|
+
interface AcpPermissionRequest {
|
|
47
|
+
readonly options: ReadonlyArray<AcpPermissionOption>;
|
|
48
|
+
readonly sessionId: string;
|
|
49
|
+
readonly toolCall: AcpPermissionToolCall;
|
|
50
|
+
}
|
|
51
|
+
interface AcpPermissionSelection {
|
|
52
|
+
readonly optionId: string;
|
|
53
|
+
}
|
|
54
|
+
type AcpPermissionDecision = {
|
|
55
|
+
readonly outcome: "cancelled";
|
|
56
|
+
} | {
|
|
57
|
+
readonly optionId: string;
|
|
58
|
+
readonly outcome: "selected";
|
|
59
|
+
};
|
|
60
|
+
type AcpPermissionPolicy = (request: AcpPermissionRequest) => Promise<AcpPermissionSelection | undefined> | AcpPermissionSelection | undefined;
|
|
61
|
+
interface AcpSessionPermissionContext {
|
|
62
|
+
readonly sessionKey: string;
|
|
63
|
+
}
|
|
64
|
+
type AcpSessionPermissionPolicy = (request: AcpPermissionRequest, context: AcpSessionPermissionContext) => Promise<AcpPermissionSelection | undefined> | AcpPermissionSelection | undefined;
|
|
65
|
+
declare function decideAcpPermission(request: AcpPermissionRequest, policy?: AcpPermissionPolicy): Promise<AcpPermissionDecision>;
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/adapters/acp/runtime/acp-permission-bridge.d.ts
|
|
68
|
+
interface AcpPermissionBridge {
|
|
69
|
+
readonly policy: AcpSessionPermissionPolicy;
|
|
70
|
+
bind(sessionKey: string, policy: AcpPermissionPolicy): () => void;
|
|
71
|
+
}
|
|
72
|
+
declare function createAcpPermissionBridge(): AcpPermissionBridge;
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/adapters/acp/runtime/acp-agent-server.d.ts
|
|
75
|
+
interface AcpAgentServerOptions {
|
|
76
|
+
readonly agentName?: string;
|
|
77
|
+
readonly loop: AgentLoop;
|
|
78
|
+
readonly permissionBridge?: AcpPermissionBridge;
|
|
79
|
+
readonly workingDirectory: string;
|
|
80
|
+
}
|
|
81
|
+
declare function createAcpAgentServer(options: AcpAgentServerOptions): acp.AgentApp;
|
|
82
|
+
declare function serveAcpAgentOnStdio(app: acp.AgentApp): Promise<void>;
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/adapters/acp/runtime/acp-session-store.d.ts
|
|
85
|
+
interface AcpSessionRecord {
|
|
86
|
+
readonly sessionId: string;
|
|
87
|
+
}
|
|
88
|
+
interface AcpSessionStore {
|
|
89
|
+
delete(sessionKey: string): Promise<void>;
|
|
90
|
+
load(sessionKey: string): Promise<AcpSessionRecord | undefined>;
|
|
91
|
+
save(sessionKey: string, record: AcpSessionRecord): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
interface JsonAcpSessionStoreOptions {
|
|
94
|
+
readonly filePath: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A small deployment-owned store for ACP provider session identities.
|
|
98
|
+
* The file contains no prompts or credentials, only session-key bindings.
|
|
99
|
+
*/
|
|
100
|
+
declare function createJsonAcpSessionStore(options: JsonAcpSessionStoreOptions): AcpSessionStore;
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/adapters/acp/runtime/acp-stdio-agent-loop.d.ts
|
|
103
|
+
interface AcpMcpServerEnvironmentVariable {
|
|
104
|
+
readonly name: string;
|
|
105
|
+
readonly value: string;
|
|
106
|
+
}
|
|
107
|
+
interface AcpMcpServer {
|
|
108
|
+
readonly args: ReadonlyArray<string>;
|
|
109
|
+
readonly command: string;
|
|
110
|
+
readonly env: ReadonlyArray<AcpMcpServerEnvironmentVariable>;
|
|
111
|
+
readonly name: string;
|
|
112
|
+
}
|
|
113
|
+
interface AcpStdioAgentLoopOptions {
|
|
114
|
+
readonly arguments?: ReadonlyArray<string>;
|
|
115
|
+
readonly clientName?: string;
|
|
116
|
+
readonly command: string;
|
|
117
|
+
readonly environment?: Readonly<Record<string, string>>;
|
|
118
|
+
readonly initializationTimeoutMs?: number;
|
|
119
|
+
readonly mcpServers?: (input: AgentLoopInput) => ReadonlyArray<AcpMcpServer>;
|
|
120
|
+
readonly onStderr?: (text: string) => void;
|
|
121
|
+
readonly permissionPolicy?: AcpSessionPermissionPolicy;
|
|
122
|
+
/** Persist provider session IDs so a restarted ACP child can load/resume them. */
|
|
123
|
+
readonly sessionStore?: AcpSessionStore;
|
|
124
|
+
readonly terminationTimeoutMs?: number;
|
|
125
|
+
readonly workingDirectory: string;
|
|
126
|
+
}
|
|
127
|
+
interface AcpStdioAgentLoopHandle {
|
|
128
|
+
readonly loop: AgentLoop;
|
|
129
|
+
dispose(): Promise<void>;
|
|
130
|
+
}
|
|
131
|
+
declare function createAcpStdioAgentLoop(options: AcpStdioAgentLoopOptions): AcpStdioAgentLoopHandle;
|
|
132
|
+
declare class AcpSessionResumeUnavailable extends Error {
|
|
133
|
+
readonly sessionId: string;
|
|
134
|
+
readonly name = "AcpSessionResumeUnavailable";
|
|
135
|
+
constructor(sessionId: string);
|
|
136
|
+
}
|
|
137
|
+
declare class AcpSessionResumeFailed extends Error {
|
|
138
|
+
readonly sessionId: string;
|
|
139
|
+
readonly cause: unknown;
|
|
140
|
+
readonly name = "AcpSessionResumeFailed";
|
|
141
|
+
constructor(sessionId: string, cause: unknown);
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/adapters/compatibility/acp/acp-runtime.d.ts
|
|
145
|
+
interface AcpAgentLoopOptions$1 {
|
|
146
|
+
readonly cancellationSettleTimeoutMs?: number;
|
|
147
|
+
readonly disposeSessionAfterRun?: boolean;
|
|
148
|
+
readonly resolveSession: (input: AgentLoopInput$1) => Promise<AcpAgentSession> | AcpAgentSession;
|
|
149
|
+
}
|
|
150
|
+
interface AcpAgentServerOptions$1 {
|
|
151
|
+
readonly loop: AgentLoop$1;
|
|
152
|
+
readonly workingDirectory: string;
|
|
153
|
+
readonly agentName?: string;
|
|
154
|
+
readonly permissionBridge?: AcpPermissionBridge;
|
|
155
|
+
}
|
|
156
|
+
interface AcpStdioAgentLoopOptions$1 {
|
|
157
|
+
readonly command: string;
|
|
158
|
+
readonly workingDirectory: string;
|
|
159
|
+
readonly mcpServers?: (input: AgentLoopInput$1) => ReadonlyArray<AcpMcpServer>;
|
|
160
|
+
/** Persist provider session IDs so a restarted ACP child can load/resume them. */
|
|
161
|
+
readonly sessionStore?: AcpSessionStore;
|
|
162
|
+
readonly permissionPolicy?: AcpSessionPermissionPolicy;
|
|
163
|
+
readonly environment?: Readonly<Record<string, string>>;
|
|
164
|
+
readonly arguments?: ReadonlyArray<string>;
|
|
165
|
+
readonly clientName?: string;
|
|
166
|
+
readonly initializationTimeoutMs?: number;
|
|
167
|
+
readonly terminationTimeoutMs?: number;
|
|
168
|
+
readonly onStderr?: (text: string) => void;
|
|
169
|
+
}
|
|
170
|
+
interface AcpStdioAgentLoopHandle$1 {
|
|
171
|
+
readonly loop: AgentLoop$1;
|
|
172
|
+
dispose(): Promise<void>;
|
|
173
|
+
}
|
|
174
|
+
declare function createAcpAgentLoop$1(options: AcpAgentLoopOptions$1): AgentLoop$1;
|
|
175
|
+
declare function createAcpAgentServer$1(options: AcpAgentServerOptions$1): acp.AgentApp;
|
|
176
|
+
declare function serveAcpAgentOnStdio$1(app: acp.AgentApp): Promise<void>;
|
|
177
|
+
declare function createAcpStdioAgentLoop$1(options: AcpStdioAgentLoopOptions$1): AcpStdioAgentLoopHandle$1;
|
|
178
|
+
//#endregion
|
|
179
|
+
export { type AcpAgentLoopOptions, type AcpAgentServerOptions, type AcpAgentSession, type AcpMcpServer, type AcpMcpServerEnvironmentVariable, type AcpPermissionBridge, type AcpPermissionDecision, type AcpPermissionOption, type AcpPermissionPolicy, type AcpPermissionRequest, type AcpPermissionSelection, type AcpPermissionToolCall, type AcpPromptResult, type AcpSessionPermissionContext, type AcpSessionPermissionPolicy, type AcpSessionRecord, AcpSessionResumeFailed, AcpSessionResumeUnavailable, type AcpSessionStore, type AcpSessionUpdate, type AcpStdioAgentLoopHandle, type AcpStdioAgentLoopOptions, type AcpToolCallStatus, type JsonAcpSessionStoreOptions, type AcpAgentLoopOptions$1 as LegacyAcpAgentLoopOptions, type AcpAgentServerOptions$1 as LegacyAcpAgentServerOptions, type AcpStdioAgentLoopHandle$1 as LegacyAcpStdioAgentLoopHandle, type AcpStdioAgentLoopOptions$1 as LegacyAcpStdioAgentLoopOptions, createAcpAgentLoop, createAcpAgentServer, createAcpPermissionBridge, createAcpStdioAgentLoop, createJsonAcpSessionStore, createAcpAgentLoop$1 as createLegacyAcpAgentLoop, createAcpAgentServer$1 as createLegacyAcpAgentServer, createAcpStdioAgentLoop$1 as createLegacyAcpStdioAgentLoop, decideAcpPermission, serveAcpAgentOnStdio, serveAcpAgentOnStdio$1 as serveLegacyAcpAgentOnStdio };
|