@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/dist/pi.d.ts
ADDED
|
@@ -0,0 +1,840 @@
|
|
|
1
|
+
import { C as AgentLoopInput, Gt as SessionKey, a as AgentLoopInput$1, b as AgentLoop, t as AgentLoop$1 } from "./chunks/agent-loop.js";
|
|
2
|
+
import { $ as RegisteredRivusSkill, A as AgentModelContentObserver, I as RivusMemoryScope, L as RivusResolvedToolDescriptor, O as NormalizedAgentInvocation, U as RivusToolGrantSet, X as RunAdmission, dt as ModelReference, it as ModelChangeBudgetReservation, lt as ModelChangeRuntimePort, nt as ModelBinding, ot as ModelChangePaidCallKind, p as ToolExecutionRequest, q as RivusToolRisk, r as RivusRuntimeToolId } from "./chunks/rivus-runtime-tool.js";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { TSchema } from "typebox";
|
|
5
|
+
|
|
6
|
+
//#region src/adapters/pi/config/pi-model-overrides.d.ts
|
|
7
|
+
interface PiModelDefinitionBase {
|
|
8
|
+
readonly api: string;
|
|
9
|
+
readonly baseUrl: string;
|
|
10
|
+
readonly compat?: object;
|
|
11
|
+
readonly contextWindow: number;
|
|
12
|
+
readonly cost: Readonly<{
|
|
13
|
+
readonly cacheRead: number;
|
|
14
|
+
readonly cacheWrite: number;
|
|
15
|
+
readonly input: number;
|
|
16
|
+
readonly output: number;
|
|
17
|
+
}>;
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly maxTokens: number;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly reasoning: boolean;
|
|
22
|
+
readonly samplingParams?: Readonly<Record<string, unknown>>;
|
|
23
|
+
readonly thinkingLevelMap?: Readonly<Partial<Record<string, string | null>>>;
|
|
24
|
+
}
|
|
25
|
+
interface PiDeclarativeModelDefinition extends PiModelDefinitionBase {
|
|
26
|
+
readonly input: ReadonlyArray<"image" | "text">;
|
|
27
|
+
}
|
|
28
|
+
interface MergePiProviderBaseUrlOverrideOptions {
|
|
29
|
+
readonly baseUrl: string;
|
|
30
|
+
readonly filePath: string;
|
|
31
|
+
readonly provider: string;
|
|
32
|
+
}
|
|
33
|
+
declare function mergePiProviderBaseUrlOverride(options: MergePiProviderBaseUrlOverrideOptions): Promise<void>;
|
|
34
|
+
interface MergePiProviderModelDeclarationOptions {
|
|
35
|
+
readonly filePath: string;
|
|
36
|
+
readonly model: PiDeclarativeModelDefinition;
|
|
37
|
+
readonly provider: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Persist one complete custom model definition in models.json.
|
|
41
|
+
*
|
|
42
|
+
* Pi composes these definitions with its built-in provider metadata. Keeping the
|
|
43
|
+
* complete definition here is deliberate: a missing SDK catalog entry must be
|
|
44
|
+
* represented by its exact server id, never by a fuzzy or legacy alias.
|
|
45
|
+
*/
|
|
46
|
+
declare function mergePiProviderModelDeclaration(options: MergePiProviderModelDeclarationOptions): Promise<void>;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/adapters/pi/execution/pi-agent-loop.d.ts
|
|
49
|
+
type PiAgentSessionEvent = PiMessageStartEvent | PiMessageUpdateEvent | PiMessageEndEvent | PiToolExecutionStartEvent | PiToolExecutionUpdateEvent | PiToolExecutionEndEvent | {
|
|
50
|
+
readonly type: string;
|
|
51
|
+
readonly [key: string]: unknown;
|
|
52
|
+
};
|
|
53
|
+
interface PiMessageUpdateEvent {
|
|
54
|
+
readonly type: "message_update";
|
|
55
|
+
readonly message: unknown;
|
|
56
|
+
readonly assistantMessageEvent: {
|
|
57
|
+
readonly type: "text_delta";
|
|
58
|
+
readonly contentIndex: number;
|
|
59
|
+
readonly delta: string;
|
|
60
|
+
readonly partial: unknown;
|
|
61
|
+
} | {
|
|
62
|
+
readonly type: "thinking_delta";
|
|
63
|
+
readonly contentIndex: number;
|
|
64
|
+
readonly delta: string;
|
|
65
|
+
readonly partial: unknown;
|
|
66
|
+
} | {
|
|
67
|
+
readonly type: string;
|
|
68
|
+
readonly [key: string]: unknown;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
interface PiMessageStartEvent {
|
|
72
|
+
readonly type: "message_start";
|
|
73
|
+
readonly message: unknown;
|
|
74
|
+
}
|
|
75
|
+
interface PiMessageEndEvent {
|
|
76
|
+
readonly type: "message_end";
|
|
77
|
+
readonly message: unknown;
|
|
78
|
+
}
|
|
79
|
+
interface PiToolExecutionStartEvent {
|
|
80
|
+
readonly type: "tool_execution_start";
|
|
81
|
+
readonly toolCallId: string;
|
|
82
|
+
readonly toolName: string;
|
|
83
|
+
readonly args?: unknown;
|
|
84
|
+
readonly input?: unknown;
|
|
85
|
+
}
|
|
86
|
+
interface PiToolExecutionUpdateEvent {
|
|
87
|
+
readonly type: "tool_execution_update";
|
|
88
|
+
readonly toolCallId: string;
|
|
89
|
+
readonly toolName: string;
|
|
90
|
+
readonly args?: unknown;
|
|
91
|
+
readonly input?: unknown;
|
|
92
|
+
readonly partialResult: unknown;
|
|
93
|
+
}
|
|
94
|
+
interface PiToolExecutionEndEvent {
|
|
95
|
+
readonly type: "tool_execution_end";
|
|
96
|
+
readonly toolCallId: string;
|
|
97
|
+
readonly toolName: string;
|
|
98
|
+
readonly result: unknown;
|
|
99
|
+
readonly isError: boolean;
|
|
100
|
+
}
|
|
101
|
+
/** Public session context shape needed by model management and history checks. */
|
|
102
|
+
interface PiSessionContext {
|
|
103
|
+
readonly messages: readonly unknown[];
|
|
104
|
+
}
|
|
105
|
+
/** Minimal session-manager capability exposed by the Pi adapter boundary. */
|
|
106
|
+
interface PiSessionManager {
|
|
107
|
+
readonly buildSessionContext: () => PiSessionContext;
|
|
108
|
+
}
|
|
109
|
+
interface PiAgentSession {
|
|
110
|
+
abort?: () => Promise<void> | void;
|
|
111
|
+
/** Native queue operations required when the loop opts into steering. */
|
|
112
|
+
steer?(text: string): Promise<void> | void;
|
|
113
|
+
readonly isStreaming?: boolean;
|
|
114
|
+
clearQueue?(): unknown;
|
|
115
|
+
setModel?(model: unknown): Promise<void> | void;
|
|
116
|
+
setThinkingLevel?(level: string): void;
|
|
117
|
+
waitForIdle?(): Promise<void>;
|
|
118
|
+
reload?(): Promise<void> | void;
|
|
119
|
+
readonly sessionManager?: PiSessionManager;
|
|
120
|
+
prompt(text: string): Promise<void>;
|
|
121
|
+
readonly state?: unknown;
|
|
122
|
+
subscribe(listener: (event: PiAgentSessionEvent) => void): () => void;
|
|
123
|
+
dispose?: () => Promise<void> | void;
|
|
124
|
+
}
|
|
125
|
+
interface PiAgentSessionHandle$1 {
|
|
126
|
+
readonly activate?: (input: AgentLoopInput) => Promise<void> | void;
|
|
127
|
+
/** Revoke per-Run authority after the SDK prompt and cancellation have settled. */
|
|
128
|
+
readonly deactivate?: () => Promise<void> | void;
|
|
129
|
+
readonly dispose?: () => Promise<void> | void;
|
|
130
|
+
readonly preparePrompt?: (input: AgentLoopInput) => Promise<string> | string;
|
|
131
|
+
readonly refreshResources?: () => Promise<void> | void;
|
|
132
|
+
readonly resolveToolName?: (toolName: string) => string;
|
|
133
|
+
readonly session: PiAgentSession;
|
|
134
|
+
}
|
|
135
|
+
interface PiAgentLoopOptions$1 {
|
|
136
|
+
/** Enable only for sessions providing native steer, isStreaming and clearQueue. */
|
|
137
|
+
readonly supportsSteering?: boolean;
|
|
138
|
+
readonly disposeSessionAfterRun?: boolean;
|
|
139
|
+
readonly modelContentObserver?: AgentModelContentObserver;
|
|
140
|
+
/** Home-wide admission fence acquired before a session/model is resolved. */
|
|
141
|
+
readonly runBoundary?: Pick<RunAdmission, "acquireRun">;
|
|
142
|
+
readonly resolveSession: (input: AgentLoopInput) => Promise<PiAgentSessionHandle$1> | PiAgentSessionHandle$1;
|
|
143
|
+
}
|
|
144
|
+
interface PiCreateAgentSessionResult {
|
|
145
|
+
readonly session: PiAgentSession;
|
|
146
|
+
}
|
|
147
|
+
interface PiSdkAgentLoopOptions<TSessionOptions = unknown> {
|
|
148
|
+
readonly supportsSteering?: boolean;
|
|
149
|
+
readonly createAgentSession: (options: TSessionOptions | undefined) => Promise<PiCreateAgentSessionResult> | PiCreateAgentSessionResult;
|
|
150
|
+
readonly sessionOptions?: TSessionOptions;
|
|
151
|
+
}
|
|
152
|
+
declare function createPiAgentLoop$1(options: PiAgentLoopOptions$1): AgentLoop;
|
|
153
|
+
declare function createPiSdkAgentLoop$1<TSessionOptions = unknown>(options: PiSdkAgentLoopOptions<TSessionOptions>): AgentLoop;
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/adapters/pi/execution/pi-session-prompts.d.ts
|
|
156
|
+
interface PiSessionPromptOptions {
|
|
157
|
+
readonly input: AgentLoopInput;
|
|
158
|
+
readonly handle: PiAgentSessionHandle$1;
|
|
159
|
+
readonly supportsSteering: boolean;
|
|
160
|
+
readonly abort: () => Promise<void>;
|
|
161
|
+
}
|
|
162
|
+
/** One ordinary prompt writer, with ordered native steering while that prompt is streaming. */
|
|
163
|
+
declare function runPiSessionPrompts(options: PiSessionPromptOptions): Promise<void>;
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/adapters/pi/execution/pi-session-registry.d.ts
|
|
166
|
+
interface PiSessionRegistryOptions$1 {
|
|
167
|
+
readonly createSession: (input: AgentLoopInput) => Promise<PiAgentSessionHandle$1> | PiAgentSessionHandle$1;
|
|
168
|
+
}
|
|
169
|
+
interface PiSessionRegistry$1 {
|
|
170
|
+
list(): Promise<ReadonlyArray<PiAgentSessionHandle$1>>;
|
|
171
|
+
resolve(input: AgentLoopInput): Promise<PiAgentSessionHandle$1>;
|
|
172
|
+
size(): number;
|
|
173
|
+
dispose(sessionKey: SessionKey): Promise<void>;
|
|
174
|
+
disposeAll(): Promise<void>;
|
|
175
|
+
}
|
|
176
|
+
declare function createPiSessionRegistry$1(options: PiSessionRegistryOptions$1): PiSessionRegistry$1;
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/adapters/pi/model-management/pi-model-resolution.d.ts
|
|
179
|
+
/**
|
|
180
|
+
* Model metadata needed at the Runtime boundary. The provider SDK model is
|
|
181
|
+
* represented structurally so this public entrypoint does not expose its
|
|
182
|
+
* transitive provider declaration graph.
|
|
183
|
+
*/
|
|
184
|
+
interface PiModel extends PiModelDefinitionBase {
|
|
185
|
+
readonly input: Array<"image" | "text">;
|
|
186
|
+
readonly provider: string;
|
|
187
|
+
}
|
|
188
|
+
type PiModelTextContent = {
|
|
189
|
+
readonly type: "text";
|
|
190
|
+
readonly text: string;
|
|
191
|
+
readonly textSignature?: string;
|
|
192
|
+
};
|
|
193
|
+
type PiModelImageContent = {
|
|
194
|
+
readonly type: "image";
|
|
195
|
+
readonly data: string;
|
|
196
|
+
readonly mimeType: string;
|
|
197
|
+
};
|
|
198
|
+
type PiModelThinkingContent = {
|
|
199
|
+
readonly type: "thinking";
|
|
200
|
+
readonly thinking: string;
|
|
201
|
+
readonly thinkingSignature?: string;
|
|
202
|
+
readonly redacted?: boolean;
|
|
203
|
+
};
|
|
204
|
+
type PiModelToolCall = {
|
|
205
|
+
readonly type: "toolCall";
|
|
206
|
+
readonly id: string;
|
|
207
|
+
readonly name: string;
|
|
208
|
+
readonly arguments: Record<string, unknown>;
|
|
209
|
+
readonly thoughtSignature?: string;
|
|
210
|
+
readonly namespace?: string;
|
|
211
|
+
};
|
|
212
|
+
type PiModelUsage = {
|
|
213
|
+
readonly input: number;
|
|
214
|
+
readonly output: number;
|
|
215
|
+
readonly cacheRead: number;
|
|
216
|
+
readonly cacheWrite: number;
|
|
217
|
+
readonly totalTokens: number;
|
|
218
|
+
readonly cost: Readonly<{
|
|
219
|
+
readonly input: number;
|
|
220
|
+
readonly output: number;
|
|
221
|
+
readonly cacheRead: number;
|
|
222
|
+
readonly cacheWrite: number;
|
|
223
|
+
readonly total: number;
|
|
224
|
+
}>;
|
|
225
|
+
};
|
|
226
|
+
type PiModelUserMessage = {
|
|
227
|
+
readonly role: "user";
|
|
228
|
+
readonly content: string | Array<PiModelTextContent | PiModelImageContent>;
|
|
229
|
+
readonly timestamp: number;
|
|
230
|
+
};
|
|
231
|
+
type PiModelAssistantMessage = {
|
|
232
|
+
readonly role: "assistant";
|
|
233
|
+
readonly content: Array<PiModelTextContent | PiModelThinkingContent | PiModelToolCall>;
|
|
234
|
+
readonly api: string;
|
|
235
|
+
readonly provider: string;
|
|
236
|
+
readonly model: string;
|
|
237
|
+
readonly responseModel?: string;
|
|
238
|
+
readonly responseId?: string;
|
|
239
|
+
readonly usage: PiModelUsage;
|
|
240
|
+
readonly stopReason: "pending" | "stop" | "length" | "toolUse" | "error" | "aborted" | "deferred";
|
|
241
|
+
readonly errorMessage?: string;
|
|
242
|
+
readonly timestamp: number;
|
|
243
|
+
};
|
|
244
|
+
type PiModelToolResultMessage = {
|
|
245
|
+
readonly role: "toolResult";
|
|
246
|
+
readonly toolCallId: string;
|
|
247
|
+
readonly toolName: string;
|
|
248
|
+
readonly content: Array<PiModelTextContent | PiModelImageContent>;
|
|
249
|
+
readonly details?: unknown;
|
|
250
|
+
readonly usage?: PiModelUsage;
|
|
251
|
+
readonly addedToolNames?: string[];
|
|
252
|
+
readonly isError: boolean;
|
|
253
|
+
readonly timestamp: number;
|
|
254
|
+
};
|
|
255
|
+
type PiModelMessage = PiModelUserMessage | PiModelAssistantMessage | PiModelToolResultMessage;
|
|
256
|
+
type PiModelTool = {
|
|
257
|
+
readonly name: string;
|
|
258
|
+
readonly description: string;
|
|
259
|
+
readonly parameters: TSchema;
|
|
260
|
+
};
|
|
261
|
+
/** Provider-neutral context accepted by the Runtime's bounded Pi model calls. */
|
|
262
|
+
interface PiModelContext {
|
|
263
|
+
readonly systemPrompt?: string;
|
|
264
|
+
readonly messages: PiModelMessage[];
|
|
265
|
+
readonly tools?: PiModelTool[];
|
|
266
|
+
}
|
|
267
|
+
type PiModelReasoningLevel = "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
268
|
+
/** Only stream controls used by Runtime model probes are accepted at this boundary. */
|
|
269
|
+
interface PiModelStreamOptions {
|
|
270
|
+
readonly signal?: AbortSignal;
|
|
271
|
+
readonly maxTokens?: number;
|
|
272
|
+
readonly maxRetries?: number;
|
|
273
|
+
readonly maxRetryDelayMs?: number;
|
|
274
|
+
readonly reasoning?: PiModelReasoningLevel;
|
|
275
|
+
}
|
|
276
|
+
interface PiModelRuntimePort {
|
|
277
|
+
getModels(providerId?: string): ReadonlyArray<PiModel>;
|
|
278
|
+
getProvider(providerId: string): unknown;
|
|
279
|
+
getModel(providerId: string, modelId: string): PiModel | undefined;
|
|
280
|
+
getRegisteredProviderIds(): ReadonlyArray<string>;
|
|
281
|
+
refresh(options?: {
|
|
282
|
+
readonly allowNetwork?: boolean;
|
|
283
|
+
readonly providers?: ReadonlyArray<string>;
|
|
284
|
+
readonly signal?: AbortSignal;
|
|
285
|
+
}): Promise<{
|
|
286
|
+
readonly errors: ReadonlyMap<string, Error>;
|
|
287
|
+
}>;
|
|
288
|
+
setRuntimeApiKey(providerId: string, apiKey: string): Promise<void>;
|
|
289
|
+
streamSimple(model: PiModel, context: PiModelContext, options?: PiModelStreamOptions): PiModelStream;
|
|
290
|
+
}
|
|
291
|
+
interface PiModelStream extends AsyncIterable<unknown> {
|
|
292
|
+
result(): Promise<unknown>;
|
|
293
|
+
}
|
|
294
|
+
interface ResolvePiModelOptions {
|
|
295
|
+
readonly modelRuntime: PiModelRuntimePort;
|
|
296
|
+
readonly target: ModelReference;
|
|
297
|
+
}
|
|
298
|
+
interface EnsurePiModelOptions extends ResolvePiModelOptions {
|
|
299
|
+
/** models.json path configured on the ModelRuntime. */
|
|
300
|
+
readonly modelsPath: string;
|
|
301
|
+
readonly signal?: AbortSignal;
|
|
302
|
+
}
|
|
303
|
+
interface ResolvedPiModel {
|
|
304
|
+
readonly binding: ModelBinding;
|
|
305
|
+
readonly model: PiModel;
|
|
306
|
+
}
|
|
307
|
+
declare class PiModelResolutionError extends Error {
|
|
308
|
+
readonly name = "PiModelResolutionError";
|
|
309
|
+
readonly code: "model_change_provider_unsupported" | "model_change_target_unsupported";
|
|
310
|
+
readonly resolutionCode: "invalid-reference" | "provider-unknown" | "model-unknown";
|
|
311
|
+
constructor(resolutionCode: PiModelResolutionError["resolutionCode"], message: string);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Resolve one exact provider/model pair from the installed Pi model runtime.
|
|
315
|
+
*
|
|
316
|
+
* Model aliases and fuzzy matches are intentionally excluded here. Natural-language
|
|
317
|
+
* interpretation belongs to the application/Agent; the activation boundary must bind
|
|
318
|
+
* to the exact model that the SDK can actually construct.
|
|
319
|
+
*/
|
|
320
|
+
declare function resolvePiModel(options: ResolvePiModelOptions): PiModel;
|
|
321
|
+
/**
|
|
322
|
+
* Ensure metadata for an exact model id that is absent from the installed SDK
|
|
323
|
+
* catalog, then recompose the provider from models.json. Phase 1 only ships the
|
|
324
|
+
* verified DeepSeek declaration required by the management contract; all other
|
|
325
|
+
* unknown ids fail closed and must be supplied by a future explicit catalog path.
|
|
326
|
+
*/
|
|
327
|
+
declare function ensurePiModel(options: EnsurePiModelOptions): Promise<PiModel>;
|
|
328
|
+
declare function resolvePiModelBinding(options: {
|
|
329
|
+
readonly bindingRevision: string;
|
|
330
|
+
readonly modelRuntime: PiModelRuntimePort;
|
|
331
|
+
readonly target: ModelReference;
|
|
332
|
+
}): ResolvedPiModel;
|
|
333
|
+
interface RefreshPiModelCatalogOptions {
|
|
334
|
+
readonly allowNetwork?: boolean;
|
|
335
|
+
readonly provider?: string;
|
|
336
|
+
readonly signal?: AbortSignal;
|
|
337
|
+
}
|
|
338
|
+
interface RefreshPiModelCatalogResult {
|
|
339
|
+
readonly errors: ReadonlyMap<string, Error>;
|
|
340
|
+
readonly refreshedProviders: ReadonlyArray<string>;
|
|
341
|
+
}
|
|
342
|
+
/** Refresh installed SDK metadata, retaining the SDK's persisted declarative catalog. */
|
|
343
|
+
declare function refreshPiModelCatalog(modelRuntime: PiModelRuntimePort, options?: RefreshPiModelCatalogOptions): Promise<RefreshPiModelCatalogResult>;
|
|
344
|
+
declare function samePiProvider(left: ModelReference, right: ModelReference): boolean;
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/adapters/pi/model-management/pi-model-probe.d.ts
|
|
347
|
+
declare const PI_MODEL_PROBE_TOOL_NAME = "rivus_model_management_probe";
|
|
348
|
+
declare const PI_MODEL_PROBE_TOOL_RESULT = "RIVUS_MODEL_PROBE_TOOL_OK";
|
|
349
|
+
declare const PI_MODEL_PROBE_FOLLOWUP_RESULT = "RIVUS_MODEL_PROBE_FOLLOWUP_OK";
|
|
350
|
+
interface PiModelProbeBudget {
|
|
351
|
+
readonly deadlineAt: string;
|
|
352
|
+
readonly reservePaidCall: (input: {
|
|
353
|
+
readonly kind: ModelChangePaidCallKind;
|
|
354
|
+
readonly maxOutputTokens?: number;
|
|
355
|
+
}) => Effect.Effect<ModelChangeBudgetReservation, unknown>;
|
|
356
|
+
readonly settlePaidCall: (input: {
|
|
357
|
+
readonly outcome: "known" | "unknown";
|
|
358
|
+
readonly outputTokens: number;
|
|
359
|
+
readonly reservation: ModelChangeBudgetReservation;
|
|
360
|
+
}) => Effect.Effect<void, unknown>;
|
|
361
|
+
}
|
|
362
|
+
interface PiModelProbeOptions {
|
|
363
|
+
readonly budget: PiModelProbeBudget;
|
|
364
|
+
readonly model: PiModel;
|
|
365
|
+
readonly modelRuntime: PiModelRuntimePort;
|
|
366
|
+
readonly signal?: AbortSignal;
|
|
367
|
+
readonly thinkingLevel: PiThinkingLevel;
|
|
368
|
+
}
|
|
369
|
+
type PiThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
370
|
+
interface PiModelProbeTurn {
|
|
371
|
+
readonly assistant: {
|
|
372
|
+
readonly content: ReadonlyArray<unknown>;
|
|
373
|
+
readonly model: string;
|
|
374
|
+
readonly provider: string;
|
|
375
|
+
readonly stopReason: string;
|
|
376
|
+
readonly usage: Readonly<Record<string, unknown>>;
|
|
377
|
+
};
|
|
378
|
+
readonly kind: "initial" | "tool-result" | "follow-up";
|
|
379
|
+
readonly reservationId: string;
|
|
380
|
+
readonly toolResult?: {
|
|
381
|
+
readonly content: string;
|
|
382
|
+
readonly toolCallId: string;
|
|
383
|
+
readonly toolName: string;
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
interface PiModelProbeResult {
|
|
387
|
+
readonly assistantThinkingBlocks: number;
|
|
388
|
+
readonly followupText: string;
|
|
389
|
+
readonly model: {
|
|
390
|
+
readonly id: string;
|
|
391
|
+
readonly provider: string;
|
|
392
|
+
};
|
|
393
|
+
readonly outputTokens: number;
|
|
394
|
+
readonly passed: true;
|
|
395
|
+
readonly thinkingLevel: PiThinkingLevel;
|
|
396
|
+
readonly toolResultText: string;
|
|
397
|
+
readonly toolCallId: string;
|
|
398
|
+
readonly toolName: typeof PI_MODEL_PROBE_TOOL_NAME;
|
|
399
|
+
readonly transcript: ReadonlyArray<PiModelProbeTurn>;
|
|
400
|
+
}
|
|
401
|
+
interface PiModelCanaryOptions {
|
|
402
|
+
readonly budget: PiModelProbeBudget;
|
|
403
|
+
readonly kind: Extract<ModelChangePaidCallKind, "activation" | "restore">;
|
|
404
|
+
readonly model: PiModel;
|
|
405
|
+
readonly modelRuntime: PiModelRuntimePort;
|
|
406
|
+
readonly signal?: AbortSignal;
|
|
407
|
+
readonly thinkingLevel: PiThinkingLevel;
|
|
408
|
+
}
|
|
409
|
+
interface PiModelCanaryResult {
|
|
410
|
+
readonly assistant: PiModelProbeTurn["assistant"];
|
|
411
|
+
readonly outputTokens: number;
|
|
412
|
+
}
|
|
413
|
+
declare class PiModelProbeError extends Error {
|
|
414
|
+
readonly name = "PiModelProbeError";
|
|
415
|
+
readonly code: "model_change_deadline_exceeded" | "model_change_probe_failed";
|
|
416
|
+
readonly outcome: "known" | "unknown";
|
|
417
|
+
constructor(message: string, outcome: "known" | "unknown", options?: ErrorOptions, code?: PiModelProbeError["code"]);
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Exercise a candidate through the same Pi model runtime used by business runs.
|
|
421
|
+
* The probe builds an in-memory synthetic context, performs an actual streamed
|
|
422
|
+
* tool call, feeds the real fixed tool result into a second streamed request, and
|
|
423
|
+
* then sends a separate follow-up request. It never loads a persisted transcript
|
|
424
|
+
* or exposes business tools.
|
|
425
|
+
*/
|
|
426
|
+
declare function probePiModel(options: PiModelProbeOptions): Effect.Effect<PiModelProbeResult, unknown>;
|
|
427
|
+
/** Run one bounded, synthetic request for activation/recovery canaries. */
|
|
428
|
+
declare function runPiModelCanary(options: PiModelCanaryOptions): Effect.Effect<PiModelCanaryResult, unknown>;
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region src/adapters/pi/model-management/pi-model-runtime.d.ts
|
|
431
|
+
/** Minimal session collection needed by model changes; compatibility registries can implement it directly. */
|
|
432
|
+
interface PiModelSessionRegistry {
|
|
433
|
+
readonly list: () => Promise<ReadonlyArray<Pick<PiAgentSessionHandle$1, "refreshResources" | "session">>>;
|
|
434
|
+
}
|
|
435
|
+
interface CreatePiModelRuntimeOptions {
|
|
436
|
+
readonly initial?: {
|
|
437
|
+
readonly binding: ModelBinding;
|
|
438
|
+
readonly model: PiModel;
|
|
439
|
+
readonly thinkingLevel: PiThinkingLevel;
|
|
440
|
+
};
|
|
441
|
+
readonly modelCatalogPath?: string;
|
|
442
|
+
readonly modelRuntime: PiModelRuntimePort;
|
|
443
|
+
readonly sessionRegistries?: ReadonlyArray<PiModelSessionRegistry>;
|
|
444
|
+
}
|
|
445
|
+
interface PiModelRuntime extends ModelChangeRuntimePort {
|
|
446
|
+
/**
|
|
447
|
+
* Set the committed startup selection after Home state has been opened.
|
|
448
|
+
* This path resolves metadata only; paid probes belong to managed changes.
|
|
449
|
+
*/
|
|
450
|
+
readonly initializeSelection: (input: {
|
|
451
|
+
readonly binding: ModelBinding;
|
|
452
|
+
readonly thinkingLevel: PiThinkingLevel;
|
|
453
|
+
}) => Effect.Effect<void, unknown>;
|
|
454
|
+
/** Read current authoritative Pi session options at creation time. */
|
|
455
|
+
readonly getSessionOptions: () => {
|
|
456
|
+
readonly model?: PiModel;
|
|
457
|
+
readonly thinkingLevel?: PiThinkingLevel;
|
|
458
|
+
};
|
|
459
|
+
readonly registerSessionRegistry: (registry: PiModelSessionRegistry) => () => void;
|
|
460
|
+
readonly refreshModelCatalog: (input?: {
|
|
461
|
+
readonly allowNetwork?: boolean;
|
|
462
|
+
readonly deadlineAt?: string;
|
|
463
|
+
readonly provider?: string;
|
|
464
|
+
readonly signal?: AbortSignal;
|
|
465
|
+
}) => Effect.Effect<void, unknown>;
|
|
466
|
+
}
|
|
467
|
+
declare class PiModelRuntimeMutationUnknownError extends Error {
|
|
468
|
+
readonly name = "PiModelRuntimeMutationUnknownError";
|
|
469
|
+
readonly outcome: "unknown";
|
|
470
|
+
constructor(message: string, options?: ErrorOptions);
|
|
471
|
+
}
|
|
472
|
+
declare class PiModelTargetCompatibilityError extends Error {
|
|
473
|
+
readonly name = "PiModelTargetCompatibilityError";
|
|
474
|
+
readonly code: "model_change_target_unsupported";
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Adapter around Pi's live AgentSession instances.
|
|
478
|
+
*
|
|
479
|
+
* The application owns the safe Run boundary. Once that boundary is held, this
|
|
480
|
+
* adapter waits for every cached session, validates its persisted context, and
|
|
481
|
+
* calls AgentSession.setModel so the session manager and conversation history
|
|
482
|
+
* survive the switch. Disposing cached sessions would silently create a new
|
|
483
|
+
* transcript on the next Run and is therefore intentionally unsupported here.
|
|
484
|
+
*/
|
|
485
|
+
declare function createPiModelRuntime(options: CreatePiModelRuntimeOptions): PiModelRuntime;
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/adapters/pi/model-management/pi-history-compatibility.d.ts
|
|
488
|
+
interface PiHistoryCompatibility {
|
|
489
|
+
readonly assistantThinkingBlocks: number;
|
|
490
|
+
readonly assistantToolCalls: number;
|
|
491
|
+
readonly compatible: true;
|
|
492
|
+
readonly imageBlocks: number;
|
|
493
|
+
readonly messageCount: number;
|
|
494
|
+
readonly toolResults: number;
|
|
495
|
+
}
|
|
496
|
+
declare class PiHistoryCompatibilityError extends Error {
|
|
497
|
+
readonly name = "PiHistoryCompatibilityError";
|
|
498
|
+
readonly code: "model_change_history_incompatible";
|
|
499
|
+
readonly messageIndex: number;
|
|
500
|
+
constructor(message: string, messageIndex: number);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Check the structural parts of a persisted Pi transcript that providers need for
|
|
504
|
+
* the next request. The transcript is never returned or copied; only counts are
|
|
505
|
+
* exposed for diagnostics. This deliberately rejects orphaned tool calls/results
|
|
506
|
+
* instead of deleting or rewriting history during a model change.
|
|
507
|
+
*/
|
|
508
|
+
declare function inspectPiSessionHistory(sessionManager: PiSessionManager): PiHistoryCompatibility;
|
|
509
|
+
declare function assertPiSessionHistoryCompatible(sessionManager: PiSessionManager): PiHistoryCompatibility;
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region src/adapters/pi/runtime/pi-session-resources.d.ts
|
|
512
|
+
interface CreatePiSessionResourcesOptions {
|
|
513
|
+
readonly agentDir: string;
|
|
514
|
+
readonly appendSystemPromptOverride?: (base: string[]) => string[];
|
|
515
|
+
readonly cwd: string;
|
|
516
|
+
readonly homeDirectory: string;
|
|
517
|
+
readonly projectSkillPaths?: ReadonlyArray<string>;
|
|
518
|
+
readonly settingsOverrides?: Readonly<Record<string, unknown>>;
|
|
519
|
+
readonly systemPromptOverride?: (base: string | undefined) => string | undefined;
|
|
520
|
+
}
|
|
521
|
+
interface PiSessionResources {
|
|
522
|
+
readonly bashToolOptions?: {
|
|
523
|
+
readonly commandPrefix?: string;
|
|
524
|
+
readonly shellPath?: string;
|
|
525
|
+
};
|
|
526
|
+
readonly skillNames: ReadonlySet<string>;
|
|
527
|
+
readonly skillPaths: ReadonlyArray<string>;
|
|
528
|
+
readonly refresh: () => Promise<void>;
|
|
529
|
+
readonly withSessionOptions: <Options extends object>(options: Options) => BoundPiSessionOptions<Options>;
|
|
530
|
+
}
|
|
531
|
+
type BoundPiSessionOptions<Options extends object> = Omit<Options, "agentDir" | "cwd" | "resourceLoader" | "settingsManager"> & {
|
|
532
|
+
readonly agentDir: string;
|
|
533
|
+
readonly cwd: string;
|
|
534
|
+
};
|
|
535
|
+
declare function createPiSessionResources(options: CreatePiSessionResourcesOptions): Promise<PiSessionResources>;
|
|
536
|
+
//#endregion
|
|
537
|
+
//#region src/adapters/pi/tool-execution/pi-tool-definition.d.ts
|
|
538
|
+
type PiToolContent = {
|
|
539
|
+
readonly text: string;
|
|
540
|
+
readonly textSignature?: string;
|
|
541
|
+
readonly type: "text";
|
|
542
|
+
} | {
|
|
543
|
+
readonly data: string;
|
|
544
|
+
readonly mimeType: string;
|
|
545
|
+
readonly type: "image";
|
|
546
|
+
};
|
|
547
|
+
interface PiToolResult<TDetails = unknown> {
|
|
548
|
+
readonly content: PiToolContent[];
|
|
549
|
+
readonly details: TDetails;
|
|
550
|
+
readonly terminate?: boolean;
|
|
551
|
+
}
|
|
552
|
+
interface PiToolDefinition<TDetails = unknown> {
|
|
553
|
+
readonly description: string;
|
|
554
|
+
readonly execute: (toolCallId: string, params: unknown, signal?: AbortSignal, onUpdate?: (result: PiToolResult<TDetails>) => void, context?: unknown) => Promise<PiToolResult<TDetails>>;
|
|
555
|
+
readonly executionMode?: "parallel" | "sequential";
|
|
556
|
+
readonly label: string;
|
|
557
|
+
readonly name: string;
|
|
558
|
+
readonly parameters: TSchema;
|
|
559
|
+
readonly promptGuidelines?: string[];
|
|
560
|
+
readonly promptSnippet?: string;
|
|
561
|
+
}
|
|
562
|
+
//#endregion
|
|
563
|
+
//#region src/adapters/pi/runtime/pi-assembly.d.ts
|
|
564
|
+
type PiAssemblySession = PiAgentSession & {
|
|
565
|
+
readonly dispose: () => void;
|
|
566
|
+
};
|
|
567
|
+
interface PiAssemblyOptions {
|
|
568
|
+
readonly cwd: string;
|
|
569
|
+
readonly agentDir: string;
|
|
570
|
+
readonly homeDirectory: string;
|
|
571
|
+
readonly authPath?: string;
|
|
572
|
+
readonly modelsPath?: string | null;
|
|
573
|
+
readonly allowModelNetwork?: boolean;
|
|
574
|
+
readonly defaultThinkingLevel?: PiThinkingLevel;
|
|
575
|
+
readonly settingsOverrides?: Readonly<Record<string, unknown>>;
|
|
576
|
+
readonly resourceOptions?: Omit<CreatePiSessionResourcesOptions, "cwd" | "agentDir" | "homeDirectory">;
|
|
577
|
+
}
|
|
578
|
+
interface PiAssemblySessionOptions {
|
|
579
|
+
readonly scopedModels?: ReadonlyArray<{
|
|
580
|
+
readonly model: PiModel;
|
|
581
|
+
readonly thinkingLevel?: PiThinkingLevel;
|
|
582
|
+
}>;
|
|
583
|
+
readonly noTools?: "all" | "builtin";
|
|
584
|
+
readonly tools?: ReadonlyArray<string>;
|
|
585
|
+
readonly excludeTools?: ReadonlyArray<string>;
|
|
586
|
+
readonly customTools?: ReadonlyArray<PiToolDefinition>;
|
|
587
|
+
readonly model?: PiModel;
|
|
588
|
+
/** Persist the session under this deployment-owned directory. */
|
|
589
|
+
readonly sessionDirectory?: string;
|
|
590
|
+
/** Keep the session header tied to the project workspace that owns the run. */
|
|
591
|
+
readonly sessionCwd?: string;
|
|
592
|
+
readonly thinkingLevel?: PiThinkingLevel;
|
|
593
|
+
readonly resources?: PiSessionResources;
|
|
594
|
+
}
|
|
595
|
+
interface PiAssemblySessionResult {
|
|
596
|
+
readonly session: PiAssemblySession;
|
|
597
|
+
readonly extensionsResult?: unknown;
|
|
598
|
+
readonly modelFallbackMessage?: string;
|
|
599
|
+
readonly dispose: () => void;
|
|
600
|
+
readonly refreshResources: () => Promise<void>;
|
|
601
|
+
}
|
|
602
|
+
interface PiAssembly {
|
|
603
|
+
readonly modelRuntime: PiModelRuntimePort;
|
|
604
|
+
readonly createSessionResources: () => Promise<PiSessionResources>;
|
|
605
|
+
readonly createSession: (options?: PiAssemblySessionOptions) => Promise<PiAssemblySessionResult>;
|
|
606
|
+
readonly resolveThinkingLevel: (provider?: string, modelId?: string) => PiThinkingLevel | undefined;
|
|
607
|
+
readonly dispose: () => Promise<void>;
|
|
608
|
+
}
|
|
609
|
+
declare function createPiAssembly(options: PiAssemblyOptions): Promise<PiAssembly>;
|
|
610
|
+
//#endregion
|
|
611
|
+
//#region src/adapters/pi/skills/pi-skill-catalog.d.ts
|
|
612
|
+
interface PiSkillCatalogEntry {
|
|
613
|
+
readonly name: string;
|
|
614
|
+
}
|
|
615
|
+
interface PiSkillCatalogDiagnostic {
|
|
616
|
+
readonly message: string;
|
|
617
|
+
readonly path?: string;
|
|
618
|
+
readonly type: "warning" | "error" | "collision";
|
|
619
|
+
}
|
|
620
|
+
declare class InvalidPiSkillCatalog extends Error {
|
|
621
|
+
readonly name = "InvalidPiSkillCatalog";
|
|
622
|
+
}
|
|
623
|
+
declare function validatePiSkillCatalog(input: {
|
|
624
|
+
readonly diagnostics: ReadonlyArray<PiSkillCatalogDiagnostic>;
|
|
625
|
+
readonly skills: ReadonlyArray<PiSkillCatalogEntry>;
|
|
626
|
+
}): ReadonlySet<string>;
|
|
627
|
+
declare function validatePiSkillCommand(text: string, skillNames: ReadonlySet<string>): void;
|
|
628
|
+
//#endregion
|
|
629
|
+
//#region src/adapters/pi/skills/pi-skill-sources.d.ts
|
|
630
|
+
declare class InvalidPiSkillSource extends Error {
|
|
631
|
+
readonly name = "InvalidPiSkillSource";
|
|
632
|
+
}
|
|
633
|
+
interface ResolvePiSkillSourcesOptions {
|
|
634
|
+
readonly agentDir: string;
|
|
635
|
+
readonly homeDirectory: string;
|
|
636
|
+
readonly projectSkillPaths?: ReadonlyArray<string>;
|
|
637
|
+
}
|
|
638
|
+
declare function resolvePiSkillSources(options: ResolvePiSkillSourcesOptions): Promise<ReadonlyArray<string>>;
|
|
639
|
+
//#endregion
|
|
640
|
+
//#region src/adapters/pi/skills/pi-skill-tool.d.ts
|
|
641
|
+
declare const PI_SKILL_READER_TOOL_NAME = "rivus_read_skill";
|
|
642
|
+
interface PiSkillReadDetails {
|
|
643
|
+
readonly contentLength: number;
|
|
644
|
+
readonly digest: string;
|
|
645
|
+
readonly skillId: string;
|
|
646
|
+
readonly title: string;
|
|
647
|
+
readonly version: string;
|
|
648
|
+
}
|
|
649
|
+
interface PiSkillRuntime {
|
|
650
|
+
readonly prompt: string;
|
|
651
|
+
readonly tool?: PiToolDefinition<PiSkillReadDetails>;
|
|
652
|
+
}
|
|
653
|
+
declare function createPiSkillRuntime(skills: ReadonlyArray<RegisteredRivusSkill>): PiSkillRuntime;
|
|
654
|
+
//#endregion
|
|
655
|
+
//#region src/adapters/pi/skills/pi-skill-read-tool.d.ts
|
|
656
|
+
declare class ProjectSkillReadDenied extends Error {
|
|
657
|
+
readonly name = "ProjectSkillReadDenied";
|
|
658
|
+
}
|
|
659
|
+
declare function createPiSkillReadTool(options: {
|
|
660
|
+
readonly cwd: string;
|
|
661
|
+
readonly skillPaths: ReadonlyArray<string>;
|
|
662
|
+
}): PiToolDefinition;
|
|
663
|
+
declare const createPiProjectSkillReadTool: typeof createPiSkillReadTool;
|
|
664
|
+
declare function createPiSkillReadTools(options: {
|
|
665
|
+
readonly cwd: string;
|
|
666
|
+
readonly runtimeToolIds: ReadonlyArray<RivusRuntimeToolId>;
|
|
667
|
+
readonly skillPaths: ReadonlyArray<string>;
|
|
668
|
+
}): PiToolDefinition[];
|
|
669
|
+
//#endregion
|
|
670
|
+
//#region src/adapters/pi/skills/project-skill-catalog.d.ts
|
|
671
|
+
interface ProjectSkillCatalogEntry {
|
|
672
|
+
readonly name: string;
|
|
673
|
+
}
|
|
674
|
+
interface ProjectSkillCatalogDiagnostic {
|
|
675
|
+
readonly message: string;
|
|
676
|
+
readonly path?: string;
|
|
677
|
+
readonly type: "warning" | "error" | "collision";
|
|
678
|
+
}
|
|
679
|
+
declare class InvalidProjectSkillCatalog extends Error {
|
|
680
|
+
readonly name = "InvalidProjectSkillCatalog";
|
|
681
|
+
}
|
|
682
|
+
declare function validateProjectSkillCatalog(input: {
|
|
683
|
+
readonly diagnostics: ReadonlyArray<ProjectSkillCatalogDiagnostic>;
|
|
684
|
+
readonly skills: ReadonlyArray<ProjectSkillCatalogEntry>;
|
|
685
|
+
}): ReadonlySet<string>;
|
|
686
|
+
declare function validateProjectSkillCommand(text: string, skillNames: ReadonlySet<string>): void;
|
|
687
|
+
//#endregion
|
|
688
|
+
//#region src/adapters/pi/tool-execution/pi-bash-tool-options.d.ts
|
|
689
|
+
interface PiBashSpawnContext {
|
|
690
|
+
command: string;
|
|
691
|
+
cwd: string;
|
|
692
|
+
env: Record<string, string | undefined>;
|
|
693
|
+
}
|
|
694
|
+
/** Rivus's Bash configuration boundary, independent of provider UI/model types. */
|
|
695
|
+
interface PiBashToolOptions {
|
|
696
|
+
commandPrefix?: string;
|
|
697
|
+
shellPath?: string;
|
|
698
|
+
spawnHook?: (context: PiBashSpawnContext) => PiBashSpawnContext;
|
|
699
|
+
}
|
|
700
|
+
//#endregion
|
|
701
|
+
//#region src/adapters/pi/tool-execution/pi-bash-tool.d.ts
|
|
702
|
+
/** Keep Pi's native execution, rendering and abort cleanup with a bounded default. */
|
|
703
|
+
declare function createPiBashTool(cwd: string, options?: PiBashToolOptions): PiToolDefinition;
|
|
704
|
+
//#endregion
|
|
705
|
+
//#region src/adapters/pi/tool-execution/pi-tool-proxy.d.ts
|
|
706
|
+
interface ToolBroker$1 {
|
|
707
|
+
execute(request: ToolExecutionRequest): Promise<unknown>;
|
|
708
|
+
}
|
|
709
|
+
interface PiToolApprovalRequest {
|
|
710
|
+
readonly agentId: string;
|
|
711
|
+
readonly allowedActorOpenIds: ReadonlyArray<string>;
|
|
712
|
+
readonly approvalId: string;
|
|
713
|
+
readonly callId: string;
|
|
714
|
+
readonly endpointId: string;
|
|
715
|
+
readonly inputDigest: string;
|
|
716
|
+
readonly instanceId: string;
|
|
717
|
+
readonly operationId: string;
|
|
718
|
+
readonly risk: RivusToolRisk;
|
|
719
|
+
readonly runId: string;
|
|
720
|
+
readonly sessionKey: string;
|
|
721
|
+
readonly signal?: AbortSignal;
|
|
722
|
+
readonly sourceMessageId: string;
|
|
723
|
+
readonly tenantKey: string;
|
|
724
|
+
readonly toolId: string;
|
|
725
|
+
readonly toolVersion: string;
|
|
726
|
+
}
|
|
727
|
+
interface PiToolApprovalGateway {
|
|
728
|
+
requestApproval(request: PiToolApprovalRequest): Promise<void>;
|
|
729
|
+
}
|
|
730
|
+
interface PiToolProxyOptions$1 {
|
|
731
|
+
readonly agentId: string;
|
|
732
|
+
readonly approvals: PiToolApprovalGateway;
|
|
733
|
+
readonly broker: ToolBroker$1;
|
|
734
|
+
readonly getActiveInput: () => AgentLoopInput | undefined;
|
|
735
|
+
readonly instanceId: string;
|
|
736
|
+
readonly memoryScopes?: ReadonlyArray<RivusMemoryScope>;
|
|
737
|
+
readonly toolGrantSet: RivusToolGrantSet;
|
|
738
|
+
readonly tools: ReadonlyArray<RivusResolvedToolDescriptor>;
|
|
739
|
+
}
|
|
740
|
+
declare function createPiToolProxyDefinitions$1(options: PiToolProxyOptions$1): PiToolDefinition[];
|
|
741
|
+
declare function createPiToolNameResolver$1(tools: ReadonlyArray<Pick<RivusResolvedToolDescriptor, "id">>): (toolName: string) => string;
|
|
742
|
+
//#endregion
|
|
743
|
+
//#region src/adapters/pi/tool-execution/pi-session-tools.d.ts
|
|
744
|
+
interface PiNamedTool {
|
|
745
|
+
readonly name: string;
|
|
746
|
+
}
|
|
747
|
+
declare function resolvePiSessionToolNames(runtimeToolIds: ReadonlyArray<RivusRuntimeToolId>, customTools: ReadonlyArray<PiNamedTool>): ReadonlyArray<string>;
|
|
748
|
+
//#endregion
|
|
749
|
+
//#region src/adapters/pi/tool-execution/pi-managed-run-binding.d.ts
|
|
750
|
+
/**
|
|
751
|
+
* Policy-free Runtime binding for the per-Run managed Bash tool.
|
|
752
|
+
*
|
|
753
|
+
* The binding owns the single Bash tool cached per Pi Session and the mutable
|
|
754
|
+
* slot that holds the active Run's spawn hook and cleanup. It does not interpret
|
|
755
|
+
* invocation provenance, hold management references, or decide authorization;
|
|
756
|
+
* the injected Gateway provider supplies the active Run's hook.
|
|
757
|
+
*/
|
|
758
|
+
interface PiManagedRunInput {
|
|
759
|
+
readonly runId: string;
|
|
760
|
+
readonly sessionKey: string;
|
|
761
|
+
readonly abortSignal: AbortSignal;
|
|
762
|
+
/** Normalized invocation identity carried with the Run; provenance is decided by the Gateway provider. */
|
|
763
|
+
readonly invocation?: NormalizedAgentInvocation;
|
|
764
|
+
}
|
|
765
|
+
interface PiManagedRunProviderResult {
|
|
766
|
+
readonly spawnHook: NonNullable<PiBashToolOptions["spawnHook"]>;
|
|
767
|
+
readonly cleanup: () => void;
|
|
768
|
+
}
|
|
769
|
+
type PiManagedRunProvider = (run: PiManagedRunInput) => PiManagedRunProviderResult;
|
|
770
|
+
interface PiManagedRunBindingOptions {
|
|
771
|
+
readonly bashToolOptions?: PiBashToolOptions;
|
|
772
|
+
readonly cwd: string;
|
|
773
|
+
readonly provider: PiManagedRunProvider;
|
|
774
|
+
}
|
|
775
|
+
declare function createPiManagedRunBinding(options: PiManagedRunBindingOptions): {
|
|
776
|
+
readonly activate: (run: PiManagedRunInput) => void;
|
|
777
|
+
readonly deactivate: () => void;
|
|
778
|
+
readonly tool: PiToolDefinition;
|
|
779
|
+
};
|
|
780
|
+
//#endregion
|
|
781
|
+
//#region src/adapters/compatibility/agent-execution/pi/pi-agent-loop.d.ts
|
|
782
|
+
interface PiAgentSessionHandle {
|
|
783
|
+
readonly session: PiAgentSession;
|
|
784
|
+
readonly resolveToolName?: (toolName: string) => string;
|
|
785
|
+
readonly preparePrompt?: (input: AgentLoopInput$1) => Promise<string> | string;
|
|
786
|
+
readonly dispose?: () => Promise<void> | void;
|
|
787
|
+
readonly activate?: (input: AgentLoopInput$1) => Promise<void> | void;
|
|
788
|
+
readonly deactivate?: () => Promise<void> | void;
|
|
789
|
+
readonly refreshResources?: () => Promise<void> | void;
|
|
790
|
+
}
|
|
791
|
+
interface PiAgentLoopOptions {
|
|
792
|
+
readonly supportsSteering?: boolean;
|
|
793
|
+
readonly resolveSession: (input: AgentLoopInput$1) => Promise<PiAgentSessionHandle> | PiAgentSessionHandle;
|
|
794
|
+
readonly modelContentObserver?: AgentModelContentObserver;
|
|
795
|
+
readonly disposeSessionAfterRun?: boolean;
|
|
796
|
+
readonly runBoundary?: {
|
|
797
|
+
readonly acquireRun: (input?: {
|
|
798
|
+
readonly deadlineAt?: string;
|
|
799
|
+
readonly signal?: AbortSignal;
|
|
800
|
+
}) => Effect.Effect<{
|
|
801
|
+
readonly release: () => void;
|
|
802
|
+
}, unknown>;
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
declare function createPiAgentLoop(options: PiAgentLoopOptions): AgentLoop$1;
|
|
806
|
+
declare function createPiSdkAgentLoop<TSessionOptions = unknown>(options: PiSdkAgentLoopOptions<TSessionOptions>): AgentLoop$1;
|
|
807
|
+
declare function toEffectPiAgentSessionHandle(handle: PiAgentSessionHandle): PiAgentSessionHandle$1;
|
|
808
|
+
declare function fromEffectPiAgentSessionHandle(handle: PiAgentSessionHandle$1): PiAgentSessionHandle;
|
|
809
|
+
//#endregion
|
|
810
|
+
//#region src/adapters/compatibility/agent-execution/pi/pi-session-registry.d.ts
|
|
811
|
+
interface PiSessionRegistryOptions {
|
|
812
|
+
readonly createSession: (input: AgentLoopInput$1) => Promise<PiAgentSessionHandle> | PiAgentSessionHandle;
|
|
813
|
+
}
|
|
814
|
+
interface PiSessionRegistry {
|
|
815
|
+
disposeAll(): Promise<void>;
|
|
816
|
+
dispose(sessionKey: SessionKey): Promise<void>;
|
|
817
|
+
list(): Promise<ReadonlyArray<PiAgentSessionHandle>>;
|
|
818
|
+
size(): number;
|
|
819
|
+
resolve(input: AgentLoopInput$1): Promise<PiAgentSessionHandle>;
|
|
820
|
+
}
|
|
821
|
+
declare function createPiSessionRegistry(options: PiSessionRegistryOptions): PiSessionRegistry;
|
|
822
|
+
//#endregion
|
|
823
|
+
//#region src/adapters/compatibility/agent-execution/pi/pi-tool-proxy.d.ts
|
|
824
|
+
interface ToolBroker {
|
|
825
|
+
execute(request: ToolExecutionRequest): Promise<unknown>;
|
|
826
|
+
}
|
|
827
|
+
interface PiToolProxyOptions {
|
|
828
|
+
readonly agentId: string;
|
|
829
|
+
readonly instanceId: string;
|
|
830
|
+
readonly tools: ReadonlyArray<RivusResolvedToolDescriptor>;
|
|
831
|
+
readonly toolGrantSet: RivusToolGrantSet;
|
|
832
|
+
readonly broker: ToolBroker;
|
|
833
|
+
readonly approvals: PiToolApprovalGateway;
|
|
834
|
+
readonly getActiveInput: () => AgentLoopInput$1 | undefined;
|
|
835
|
+
readonly memoryScopes?: ReadonlyArray<RivusMemoryScope>;
|
|
836
|
+
}
|
|
837
|
+
declare function createPiToolProxyDefinitions(options: PiToolProxyOptions): PiToolDefinition[];
|
|
838
|
+
declare function createPiToolNameResolver(tools: ReadonlyArray<Pick<RivusResolvedToolDescriptor, "id">>): (toolName: string) => string;
|
|
839
|
+
//#endregion
|
|
840
|
+
export { type CreatePiModelRuntimeOptions, type CreatePiSessionResourcesOptions, type EnsurePiModelOptions, InvalidPiSkillCatalog, InvalidPiSkillSource, InvalidProjectSkillCatalog, type PiAgentLoopOptions as LegacyPiAgentLoopOptions, type PiAgentSessionHandle as LegacyPiAgentSessionHandle, type PiSdkAgentLoopOptions as LegacyPiSdkAgentLoopOptions, type PiSdkAgentLoopOptions, type PiSessionRegistry as LegacyPiSessionRegistry, type PiSessionRegistryOptions as LegacyPiSessionRegistryOptions, type PiToolApprovalGateway as LegacyPiToolApprovalGateway, type PiToolApprovalGateway, type PiToolApprovalRequest as LegacyPiToolApprovalRequest, type PiToolApprovalRequest, type PiToolProxyOptions as LegacyPiToolProxyOptions, type MergePiProviderBaseUrlOverrideOptions, type MergePiProviderModelDeclarationOptions, PI_MODEL_PROBE_FOLLOWUP_RESULT, PI_MODEL_PROBE_TOOL_NAME, PI_MODEL_PROBE_TOOL_RESULT, PI_SKILL_READER_TOOL_NAME, type PiAgentLoopOptions$1 as PiAgentLoopOptions, type PiAgentSession, type PiAgentSessionEvent, type PiAgentSessionHandle$1 as PiAgentSessionHandle, type PiAssembly, type PiAssemblyOptions, type PiAssemblySessionOptions, type PiAssemblySessionResult, type PiBashToolOptions, type PiCreateAgentSessionResult, type PiDeclarativeModelDefinition, type PiHistoryCompatibility, PiHistoryCompatibilityError, type PiManagedRunBindingOptions, type PiManagedRunInput, type PiManagedRunProvider, type PiManagedRunProviderResult, type PiMessageEndEvent, type PiMessageStartEvent, type PiMessageUpdateEvent, type PiModel, type PiModelCanaryOptions, type PiModelCanaryResult, type PiModelContext, type PiModelProbeBudget, PiModelProbeError, type PiModelProbeOptions, type PiModelProbeResult, type PiModelProbeTurn, PiModelResolutionError, type PiModelRuntime, PiModelRuntimeMutationUnknownError, type PiModelRuntimePort, type PiModelSessionRegistry, type PiModelStream, type PiModelStreamOptions, PiModelTargetCompatibilityError, type PiNamedTool, type PiSessionContext, type PiSessionManager, type PiSessionRegistry$1 as PiSessionRegistry, type PiSessionRegistryOptions$1 as PiSessionRegistryOptions, type PiSessionResources, type PiSkillCatalogDiagnostic, type PiSkillCatalogEntry, type PiSkillReadDetails, type PiSkillRuntime, type PiThinkingLevel, type PiToolContent, type PiToolDefinition, type PiToolExecutionEndEvent, type PiToolExecutionStartEvent, type PiToolExecutionUpdateEvent, type PiToolProxyOptions$1 as PiToolProxyOptions, type PiToolResult, type ProjectSkillCatalogDiagnostic, type ProjectSkillCatalogEntry, ProjectSkillReadDenied, type RefreshPiModelCatalogOptions, type RefreshPiModelCatalogResult, type ResolvePiModelOptions, type ResolvePiSkillSourcesOptions, type ResolvedPiModel, assertPiSessionHistoryCompatible, createPiAgentLoop as createLegacyPiAgentLoop, createPiSdkAgentLoop as createLegacyPiSdkAgentLoop, createPiSessionRegistry as createLegacyPiSessionRegistry, createPiToolNameResolver as createLegacyPiToolNameResolver, createPiToolProxyDefinitions as createLegacyPiToolProxyDefinitions, createPiAgentLoop$1 as createPiAgentLoop, createPiAssembly, createPiBashTool, createPiManagedRunBinding, createPiModelRuntime, createPiProjectSkillReadTool, createPiSdkAgentLoop$1 as createPiSdkAgentLoop, createPiSessionRegistry$1 as createPiSessionRegistry, createPiSessionResources, createPiSkillReadTool, createPiSkillReadTools, createPiSkillRuntime, createPiToolNameResolver$1 as createPiToolNameResolver, createPiToolProxyDefinitions$1 as createPiToolProxyDefinitions, ensurePiModel, fromEffectPiAgentSessionHandle as fromEffectLegacyPiAgentSessionHandle, inspectPiSessionHistory, mergePiProviderBaseUrlOverride, mergePiProviderModelDeclaration, probePiModel, refreshPiModelCatalog, resolvePiModel, resolvePiModelBinding, resolvePiSessionToolNames, resolvePiSkillSources, runPiModelCanary, runPiSessionPrompts, samePiProvider, toEffectPiAgentSessionHandle as toEffectLegacyPiAgentSessionHandle, validatePiSkillCatalog, validatePiSkillCommand, validateProjectSkillCatalog, validateProjectSkillCommand };
|