@rivus/agent 0.16.2 → 0.16.6

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.
@@ -1,382 +0,0 @@
1
- //#region src/core/domain/background-session/value-objects/background-session-id.d.ts
2
- type BackgroundSessionId = string;
3
- //#endregion
4
- //#region src/core/domain/background-session/events/background-session-events.d.ts
5
- type AggregateTransition<TState, TEvent> = Readonly<{
6
- events: ReadonlyArray<TEvent>;
7
- state: TState;
8
- }>;
9
- type BackgroundSessionCompleted = Readonly<{
10
- displayName: string;
11
- revision: number;
12
- sessionId: BackgroundSessionId;
13
- text: string;
14
- type: "BackgroundSessionCompleted";
15
- }>;
16
- type BackgroundSessionFailed = Readonly<{
17
- displayName: string;
18
- errorMessage: string;
19
- revision: number;
20
- sessionId: BackgroundSessionId;
21
- type: "BackgroundSessionFailed";
22
- }>;
23
- type BackgroundSessionStopped = Readonly<{
24
- displayName: string;
25
- reason?: string;
26
- revision: number;
27
- sessionId: BackgroundSessionId;
28
- type: "BackgroundSessionStopped";
29
- }>;
30
- type BackgroundSessionReconciliationRequired = Readonly<{
31
- displayName: string;
32
- note: string;
33
- revision: number;
34
- sessionId: BackgroundSessionId;
35
- type: "BackgroundSessionReconciliationRequired";
36
- }>;
37
- type BackgroundSessionEvent = BackgroundSessionCompleted | BackgroundSessionFailed | BackgroundSessionStopped | BackgroundSessionReconciliationRequired;
38
- //#endregion
39
- //#region src/core/domain/background-session/value-objects/memory.d.ts
40
- declare const BACKGROUND_SESSION_MEMORY_SCOPES: readonly ["conversation", "agent-private", "project", "shared-user-profile"];
41
- type BackgroundSessionMemoryScope = (typeof BACKGROUND_SESSION_MEMORY_SCOPES)[number];
42
- declare const BACKGROUND_SESSION_MEMORY_AUDIENCES: readonly ["group", "private"];
43
- type BackgroundSessionMemoryAudience = (typeof BACKGROUND_SESSION_MEMORY_AUDIENCES)[number];
44
- interface BackgroundSessionMemoryIdentity {
45
- readonly audience: BackgroundSessionMemoryAudience;
46
- readonly conversationId?: string;
47
- readonly projectId?: string;
48
- readonly subjectId: string;
49
- readonly tenantId: string;
50
- }
51
- //#endregion
52
- //#region src/core/domain/background-session/value-objects/authority.d.ts
53
- type BackgroundSessionAuthority = Readonly<{
54
- agentId: string;
55
- profileRevision: string;
56
- toolGrantRevision: string;
57
- policyEpoch: number;
58
- memoryScopes: ReadonlyArray<BackgroundSessionMemoryScope>;
59
- projectSpaceId?: string;
60
- sessionKey: string;
61
- }>;
62
- //#endregion
63
- //#region src/core/domain/background-session/value-objects/cancellation.d.ts
64
- type BackgroundSessionCancellation = Readonly<{
65
- reason: string;
66
- requestedAt: string;
67
- }>;
68
- //#endregion
69
- //#region src/core/domain/background-session/value-objects/lease.d.ts
70
- type BackgroundSessionLease = Readonly<{
71
- owner: string;
72
- epoch: number;
73
- expiresAt: string;
74
- }>;
75
- //#endregion
76
- //#region src/core/domain/background-session/value-objects/origin.d.ts
77
- type BackgroundSessionOrigin = Readonly<{
78
- endpointId: string;
79
- tenantKey: string;
80
- conversationId?: string;
81
- allowedActorOpenIds: ReadonlyArray<string>;
82
- memory?: BackgroundSessionMemoryIdentity;
83
- }>;
84
- //#endregion
85
- //#region src/core/domain/background-session/value-objects/phase.d.ts
86
- type BackgroundSessionPhase = "queued" | "running" | "waiting" | "input-required" | "stopping" | "stopped" | "completed" | "failed" | "reconciliation-required";
87
- //#endregion
88
- //#region src/core/domain/background-session/value-objects/terminal-result.d.ts
89
- type BackgroundSessionTerminalResult = Readonly<{
90
- text: string;
91
- stepRunId: string;
92
- completedAt: string;
93
- }>;
94
- //#endregion
95
- //#region src/core/domain/background-session/aggregate/snapshot.d.ts
96
- type BackgroundSessionSnapshot = Readonly<{
97
- sessionId: BackgroundSessionId;
98
- displayName: string;
99
- phase: BackgroundSessionPhase;
100
- revision: number;
101
- parentRunId: string;
102
- sourceMessageId: string;
103
- origin: BackgroundSessionOrigin;
104
- authority: BackgroundSessionAuthority;
105
- prompt: string;
106
- stepCount: number;
107
- wakeCount: number;
108
- currentStepRunId?: string;
109
- lastWakeText?: string;
110
- pendingInput: ReadonlyArray<string>;
111
- wakeAt?: string;
112
- lease?: BackgroundSessionLease;
113
- cancellation?: BackgroundSessionCancellation;
114
- consecutiveFailures: number;
115
- result?: BackgroundSessionTerminalResult;
116
- errorMessage?: string;
117
- reconciliationNote?: string;
118
- createdAt: string;
119
- updatedAt: string;
120
- }>;
121
- //#endregion
122
- //#region src/core/domain/background-session/aggregate/background-session.d.ts
123
- type BackgroundSessionTransition = AggregateTransition<BackgroundSession, BackgroundSessionEvent>;
124
- interface CreateBackgroundSessionInput {
125
- readonly sessionId: BackgroundSessionId;
126
- readonly displayName: string;
127
- readonly prompt: string;
128
- readonly parentRunId: string;
129
- readonly sourceMessageId: string;
130
- readonly origin: BackgroundSessionOrigin;
131
- readonly authority: BackgroundSessionAuthority;
132
- readonly now: string;
133
- }
134
- interface ClaimBackgroundSessionInput {
135
- readonly lease: BackgroundSessionLease;
136
- readonly stepRunId: string;
137
- readonly wakeText: string;
138
- readonly now: string;
139
- }
140
- interface SuspendBackgroundSessionInput {
141
- readonly wakeAt?: string;
142
- readonly reason?: string;
143
- readonly now: string;
144
- }
145
- declare class BackgroundSession implements BackgroundSessionSnapshot {
146
- readonly sessionId: BackgroundSessionId;
147
- readonly displayName: string;
148
- readonly phase: BackgroundSessionPhase;
149
- readonly revision: number;
150
- readonly parentRunId: string;
151
- readonly sourceMessageId: string;
152
- readonly origin: BackgroundSessionOrigin;
153
- readonly authority: BackgroundSessionAuthority;
154
- readonly prompt: string;
155
- readonly stepCount: number;
156
- readonly wakeCount: number;
157
- readonly currentStepRunId?: string;
158
- readonly lastWakeText?: string;
159
- readonly pendingInput: ReadonlyArray<string>;
160
- readonly wakeAt?: string;
161
- readonly lease?: BackgroundSessionLease;
162
- readonly cancellation?: BackgroundSessionCancellation;
163
- readonly consecutiveFailures: number;
164
- readonly result?: BackgroundSessionTerminalResult;
165
- readonly errorMessage?: string;
166
- readonly reconciliationNote?: string;
167
- readonly createdAt: string;
168
- readonly updatedAt: string;
169
- private constructor();
170
- static create(input: CreateBackgroundSessionInput): BackgroundSession;
171
- static restore(snapshot: unknown): BackgroundSession;
172
- claim(input: ClaimBackgroundSessionInput): BackgroundSessionTransition;
173
- renewLease(lease: BackgroundSessionLease): BackgroundSessionTransition;
174
- releaseLease(): BackgroundSessionTransition;
175
- suspend(input: SuspendBackgroundSessionInput): BackgroundSessionTransition;
176
- completeStep(input: {
177
- readonly text: string;
178
- readonly stepRunId: string;
179
- readonly now: string;
180
- }): BackgroundSessionTransition;
181
- failStep(input: {
182
- readonly errorMessage: string;
183
- readonly now: string;
184
- readonly retryable: boolean;
185
- readonly wakeAt?: string;
186
- }): BackgroundSessionTransition;
187
- requestStop(input: {
188
- readonly reason: string;
189
- readonly now: string;
190
- }): BackgroundSessionTransition;
191
- completeStop(input: {
192
- readonly now: string;
193
- }): BackgroundSessionTransition;
194
- parkForReconciliation(input: {
195
- readonly reason: string;
196
- readonly now: string;
197
- }): BackgroundSessionTransition;
198
- resolveReconciliation(input: {
199
- readonly outcome: "continue" | "stop";
200
- readonly now: string;
201
- }): BackgroundSessionTransition;
202
- appendInput(input: {
203
- readonly message: string;
204
- readonly now: string;
205
- }): BackgroundSessionTransition;
206
- requeueInterruptedStep(input: {
207
- readonly wakeText: string;
208
- readonly now: string;
209
- }): BackgroundSessionTransition;
210
- isLeaseExpired(now: string): boolean;
211
- isDue(now: string): boolean;
212
- isTerminal(): boolean;
213
- toSnapshot(): BackgroundSessionSnapshot;
214
- validateTransitionTo(next: BackgroundSession): string | undefined;
215
- private snapshotFields;
216
- private next;
217
- private unchanged;
218
- private stopped;
219
- }
220
- //#endregion
221
- //#region src/core/application/background-session/ports/background-session-delivery-store.d.ts
222
- type BackgroundSessionDeliveryKind = "progress" | "final" | "stopped" | "failed" | "reconciliation";
223
- interface BackgroundSessionDeliveryRecord {
224
- readonly deliveryId: string;
225
- readonly sessionId: string;
226
- readonly kind: BackgroundSessionDeliveryKind;
227
- readonly text: string;
228
- readonly state: "pending" | "delivered";
229
- readonly revision: number;
230
- readonly providerMessageId?: string;
231
- readonly createdAt: string;
232
- }
233
- interface BackgroundSessionDeliveryStore {
234
- enqueue(input: {
235
- readonly deliveryId: string;
236
- readonly sessionId: string;
237
- readonly kind: BackgroundSessionDeliveryKind;
238
- readonly text: string;
239
- readonly createdAt: string;
240
- }): Promise<BackgroundSessionDeliveryRecord>;
241
- pending(): Promise<ReadonlyArray<BackgroundSessionDeliveryRecord>>;
242
- markDelivered(deliveryId: string, providerMessageId: string): Promise<BackgroundSessionDeliveryRecord | undefined>;
243
- }
244
- declare class BackgroundSessionDeliveryConflict extends Error {
245
- readonly name = "BackgroundSessionDeliveryConflict";
246
- constructor(deliveryId: string, message: string);
247
- }
248
- //#endregion
249
- //#region src/core/application/background-session/ports/background-session-repository.d.ts
250
- interface BackgroundSessionLeasePrecondition {
251
- readonly kind: "absent";
252
- }
253
- interface BackgroundSessionLeaseRequirement {
254
- readonly kind: "held";
255
- readonly owner: string;
256
- readonly epoch: number;
257
- }
258
- interface BackgroundSessionLeaseStaleOrAbsent {
259
- readonly kind: "absent-or-stale";
260
- }
261
- interface BackgroundSessionRepository {
262
- create(session: BackgroundSession): Promise<BackgroundSession>;
263
- get(sessionId: string): Promise<BackgroundSession | undefined>;
264
- list(options?: {
265
- readonly phase?: BackgroundSessionPhase;
266
- readonly limit?: number;
267
- }): Promise<ReadonlyArray<BackgroundSession>>;
268
- update(input: {
269
- readonly sessionId: string;
270
- readonly expectedRevision: number;
271
- readonly expectedLease?: BackgroundSessionLeasePrecondition | BackgroundSessionLeaseRequirement | BackgroundSessionLeaseStaleOrAbsent;
272
- readonly now?: string;
273
- readonly build: (session: BackgroundSession) => BackgroundSession;
274
- }): Promise<BackgroundSession | undefined>;
275
- }
276
- declare class BackgroundSessionRepositoryConflict extends Error {
277
- readonly name = "BackgroundSessionRepositoryConflict";
278
- constructor(sessionId: string, message: string);
279
- }
280
- declare class BackgroundSessionRepositoryCorrupted extends Error {
281
- readonly name = "BackgroundSessionRepositoryCorrupted";
282
- }
283
- //#endregion
284
- //#region src/core/application/background-session/authority/background-session-identity.d.ts
285
- declare const BACKGROUND_SESSION_SESSION_KEY_PREFIX = "background";
286
- declare function createBackgroundSessionKey(sessionId: string): string;
287
- declare function createBackgroundSessionStepSourceMessageId(sessionId: string, stepCount: number): string;
288
- //#endregion
289
- //#region src/core/application/background-session/commands/background-session-ids.d.ts
290
- declare function sessionIdFromSessionKey(sessionKey: string): string | undefined;
291
- declare function terminalDeliveryId(sessionId: string, kind: BackgroundSessionDeliveryKind): string;
292
- declare function progressDeliveryId(sessionId: string, stepCount: number): string;
293
- //#endregion
294
- //#region src/core/application/background-session/commands/background-session-service.d.ts
295
- interface BackgroundSessionExecutionOrigin {
296
- readonly allowedActorOpenIds: ReadonlyArray<string>;
297
- readonly conversationId?: string;
298
- readonly endpointId: string;
299
- readonly tenantKey: string;
300
- }
301
- interface BackgroundSessionExecutionContext {
302
- readonly agentId: string;
303
- readonly callId: string;
304
- readonly instanceId: string;
305
- readonly memory?: BackgroundSessionMemoryIdentity & {
306
- readonly scopes: ReadonlyArray<BackgroundSessionMemoryScope>;
307
- };
308
- readonly operationId?: string;
309
- readonly origin?: BackgroundSessionExecutionOrigin;
310
- readonly policyEpoch: number;
311
- readonly runId: string;
312
- readonly sessionKey: string;
313
- readonly sourceMessageId?: string;
314
- readonly toolId: string;
315
- readonly toolVersion: string;
316
- }
317
- interface BackgroundSessionSummary {
318
- readonly sessionId: string;
319
- readonly displayName: string;
320
- readonly phase: BackgroundSessionPhase;
321
- readonly stepCount: number;
322
- readonly wakeAt?: string;
323
- readonly createdAt: string;
324
- readonly updatedAt: string;
325
- }
326
- interface BackgroundSessionDetailResult {
327
- readonly completedAt: string;
328
- readonly stepRunId: string;
329
- readonly text: string;
330
- }
331
- interface BackgroundSessionDetail extends BackgroundSessionSummary {
332
- readonly parentRunId: string;
333
- readonly pendingInput: ReadonlyArray<string>;
334
- readonly result?: BackgroundSessionDetailResult;
335
- readonly errorMessage?: string;
336
- readonly cancellationReason?: string;
337
- readonly reconciliationNote?: string;
338
- }
339
- declare class BackgroundSessionCallerDenied extends Error {
340
- readonly name = "BackgroundSessionCallerDenied";
341
- constructor(message: string);
342
- }
343
- interface BackgroundSessionService {
344
- list(input: {
345
- readonly context: BackgroundSessionExecutionContext;
346
- readonly limit?: number;
347
- readonly phase?: BackgroundSessionPhase;
348
- }): Promise<ReadonlyArray<BackgroundSessionSummary>>;
349
- resolveReconciliation(input: {
350
- readonly outcome: "continue" | "stop";
351
- readonly sessionId: string;
352
- }): Promise<BackgroundSessionSummary>;
353
- send(input: {
354
- readonly context: BackgroundSessionExecutionContext;
355
- readonly message: string;
356
- readonly sessionId: string;
357
- }): Promise<BackgroundSessionSummary>;
358
- start(input: {
359
- readonly authority: BackgroundSessionAuthority;
360
- readonly context: BackgroundSessionExecutionContext;
361
- readonly displayName?: string;
362
- readonly prompt: string;
363
- readonly sessionId: string;
364
- }): Promise<BackgroundSessionSummary>;
365
- status(input: {
366
- readonly context: BackgroundSessionExecutionContext;
367
- readonly sessionId: string;
368
- }): Promise<BackgroundSessionDetail>;
369
- stop(input: {
370
- readonly context: BackgroundSessionExecutionContext;
371
- readonly reason?: string;
372
- readonly sessionId: string;
373
- }): Promise<BackgroundSessionSummary>;
374
- wait(input: {
375
- readonly context: BackgroundSessionExecutionContext;
376
- readonly delayMs?: number;
377
- readonly reason?: string;
378
- readonly until?: string;
379
- }): Promise<BackgroundSessionSummary>;
380
- }
381
- //#endregion
382
- export { BackgroundSessionAuthority as A, SuspendBackgroundSessionInput as C, BackgroundSessionOrigin as D, BackgroundSessionPhase as E, BackgroundSessionId as M, BackgroundSessionLease as O, CreateBackgroundSessionInput as S, BackgroundSessionTerminalResult as T, BackgroundSessionDeliveryConflict as _, progressDeliveryId as a, BackgroundSession as b, BACKGROUND_SESSION_SESSION_KEY_PREFIX as c, BackgroundSessionLeasePrecondition as d, BackgroundSessionLeaseRequirement as f, BackgroundSessionRepositoryCorrupted as g, BackgroundSessionRepositoryConflict as h, BackgroundSessionSummary as i, BackgroundSessionMemoryScope as j, BackgroundSessionCancellation as k, createBackgroundSessionKey as l, BackgroundSessionRepository as m, BackgroundSessionDetail as n, sessionIdFromSessionKey as o, BackgroundSessionLeaseStaleOrAbsent as p, BackgroundSessionService as r, terminalDeliveryId as s, BackgroundSessionCallerDenied as t, createBackgroundSessionStepSourceMessageId as u, BackgroundSessionDeliveryRecord as v, BackgroundSessionSnapshot as w, ClaimBackgroundSessionInput as x, BackgroundSessionDeliveryStore as y };