@rivus/agent 0.13.2 → 0.14.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.
Files changed (46) hide show
  1. package/README.md +20 -15
  2. package/dist/acp.d.ts +40 -40
  3. package/dist/acp.js +71 -31
  4. package/dist/bootstrap/pi-feishu.d.ts +20 -0
  5. package/dist/bootstrap/pi-feishu.js +594 -0
  6. package/dist/{agent-loop.d.ts → chunks/agent-loop.d.ts} +293 -44
  7. package/dist/chunks/agent-loop.js +1272 -0
  8. package/dist/chunks/api.d.ts +70 -0
  9. package/dist/chunks/api.js +471 -0
  10. package/dist/{rivus-plugin.d.ts → chunks/api2.d.ts} +271 -120
  11. package/dist/chunks/api2.js +1331 -0
  12. package/dist/chunks/api3.d.ts +402 -0
  13. package/dist/chunks/index.d.ts +3662 -0
  14. package/dist/chunks/module.js +267 -0
  15. package/dist/chunks/pi-skill-tool.js +460 -0
  16. package/dist/chunks/pi-tool-proxy.d.ts +188 -0
  17. package/dist/chunks/pi.js +329 -0
  18. package/dist/{rivus-daemon-cli.js → chunks/rivus-daemon-cli.js} +2197 -1526
  19. package/dist/{rivus-plugin-testkit.d.ts → chunks/rivus-plugin-testkit.d.ts} +1 -1
  20. package/dist/{rivus-plugin-testkit.js → chunks/rivus-plugin-testkit.js} +11 -3
  21. package/dist/chunks/sha256-digest.js +12 -0
  22. package/dist/chunks/spi.d.ts +1 -0
  23. package/dist/chunks/spi.js +2 -0
  24. package/dist/chunks/src.js +9897 -0
  25. package/dist/cli.js +602 -93
  26. package/dist/index.d.ts +8 -3645
  27. package/dist/index.js +9 -10483
  28. package/dist/mcp.d.ts +3 -38
  29. package/dist/mcp.js +4 -114
  30. package/dist/pi.d.ts +95 -9
  31. package/dist/pi.js +3 -146
  32. package/dist/testing/index.d.ts +1 -1
  33. package/dist/testing/index.js +1 -1
  34. package/examples/pi-feishu-deployment.bootstrap.ts +35 -46
  35. package/examples/pi-feishu.bootstrap.ts +35 -20
  36. package/examples/rivus-starter.plugin.mjs +3 -1
  37. package/package.json +8 -2
  38. package/dist/agent-loop.js +0 -121
  39. package/dist/agent-memory.d.ts +0 -100
  40. package/dist/agent-memory.js +0 -114
  41. package/dist/background-session-authority.js +0 -224
  42. package/dist/background-session-input.js +0 -45
  43. package/dist/background-session-service.d.ts +0 -291
  44. package/dist/pi-tool-proxy.d.ts +0 -197
  45. package/dist/rivus-plugin-registry.js +0 -215
  46. package/dist/tool-input-digest.js +0 -128
@@ -1,7 +1,7 @@
1
- import { n as AgentMemoryIdentity } from "./agent-memory.js";
1
+ import { s as AgentMemoryIdentity } from "./api.js";
2
2
  import { Effect, Stream } from "effect";
3
3
 
4
- //#region src/domain/agent-events.d.ts
4
+ //#region src/modules/agent-execution/domain/run/agent-events.d.ts
5
5
  type AgentRunId = string;
6
6
  type SessionKey = string;
7
7
  interface AgentRunAccepted {
@@ -132,22 +132,22 @@ interface AgentRunFailed {
132
132
  readonly errorMessage: string;
133
133
  readonly occurredAt: Date;
134
134
  }
135
- interface AgentRunCancelled {
135
+ interface AgentRunCancelled$1 {
136
136
  readonly type: "agent_run_cancelled";
137
137
  readonly runId: AgentRunId;
138
138
  readonly reason?: string;
139
139
  readonly occurredAt: Date;
140
140
  }
141
- type AgentDomainEvent = AgentRunAccepted | AgentTurnStarted | AssistantTextDelta | AssistantThinkingDelta | AgentModelExecutionStarted | AgentModelExecutionEnded | AgentSkillExecutionStarted | AgentSkillExecutionEnded | AgentToolExecutionStarted | AgentToolExecutionUpdated | AgentToolExecutionEnded | AgentTurnCompleted | AgentRunCompleted | AgentRunFailed | AgentRunCancelled;
141
+ type AgentDomainEvent = AgentRunAccepted | AgentTurnStarted | AssistantTextDelta | AssistantThinkingDelta | AgentModelExecutionStarted | AgentModelExecutionEnded | AgentSkillExecutionStarted | AgentSkillExecutionEnded | AgentToolExecutionStarted | AgentToolExecutionUpdated | AgentToolExecutionEnded | AgentTurnCompleted | AgentRunCompleted | AgentRunFailed | AgentRunCancelled$1;
142
142
  type AgentToolExecutionEvent = AgentToolExecutionStarted | AgentToolExecutionUpdated | AgentToolExecutionEnded;
143
143
  type AgentModelExecutionEvent = AgentModelExecutionStarted | AgentModelExecutionEnded;
144
- type TerminalAgentDomainEvent = AgentRunCompleted | AgentRunFailed | AgentRunCancelled;
144
+ type TerminalAgentDomainEvent = AgentRunCompleted | AgentRunFailed | AgentRunCancelled$1;
145
145
  declare function isAssistantTextDeltaEvent(event: AgentDomainEvent): event is AssistantTextDelta;
146
146
  declare function isAssistantThinkingDeltaEvent(event: AgentDomainEvent): event is AssistantThinkingDelta;
147
147
  declare function isAgentToolExecutionEvent(event: AgentDomainEvent): event is AgentToolExecutionEvent;
148
148
  declare function isTerminalAgentDomainEvent(event: AgentDomainEvent): event is TerminalAgentDomainEvent;
149
149
  //#endregion
150
- //#region src/domain/agent-run-state.d.ts
150
+ //#region src/modules/agent-execution/domain/run/agent-run-state.d.ts
151
151
  type AgentRunPhase = "idle" | "accepted" | "running" | "completed" | "failed" | "cancelled";
152
152
  interface AgentRunState {
153
153
  readonly phase: AgentRunPhase;
@@ -184,7 +184,7 @@ declare const initialAgentRunState: AgentRunState;
184
184
  declare function isTerminalAgentRunPhase(phase: AgentRunPhase): boolean;
185
185
  declare function evolveAgentRun(state: AgentRunState, event: AgentDomainEvent): AgentRunState;
186
186
  //#endregion
187
- //#region src/domain/agent-history.d.ts
187
+ //#region src/modules/agent-execution/domain/history/agent-history.d.ts
188
188
  interface AgentRunSummary {
189
189
  readonly acceptedAt?: Date;
190
190
  readonly cancellationReason?: string;
@@ -228,7 +228,7 @@ interface AgentHistory {
228
228
  }
229
229
  declare function replayAgentHistory(events: ReadonlyArray<AgentDomainEvent>): AgentHistory;
230
230
  //#endregion
231
- //#region src/domain/agent-transcript.d.ts
231
+ //#region src/modules/agent-execution/domain/transcript/agent-transcript.d.ts
232
232
  interface AgentTranscript {
233
233
  readonly latestTurn?: AgentTranscriptTurn;
234
234
  readonly sessionKey: SessionKey;
@@ -268,7 +268,7 @@ declare function createAgentTranscriptTurn(summary: AgentRunSummary & {
268
268
  declare function createAgentTranscriptMessages(transcript: AgentTranscript): ReadonlyArray<AgentTranscriptMessage>;
269
269
  declare function createAgentConversationMessages(options: AgentConversationMessagesOptions): ReadonlyArray<AgentTranscriptMessage>;
270
270
  //#endregion
271
- //#region src/domain/agent-invocation.d.ts
271
+ //#region src/modules/agent-execution/domain/invocation/agent-invocation.d.ts
272
272
  type AgentMemoryInvocationIdentity = AgentMemoryIdentity;
273
273
  interface FeishuAgentInvocationOrigin {
274
274
  readonly allowedActorOpenIds: ReadonlyArray<string>;
@@ -308,22 +308,7 @@ interface BackgroundSessionAgentInvocationOrigin {
308
308
  }
309
309
  type AgentInvocationOrigin = FeishuAgentInvocationOrigin | LocalCliAgentInvocationOrigin | AutomationAgentInvocationOrigin | BackgroundSessionAgentInvocationOrigin;
310
310
  //#endregion
311
- //#region src/application/agent/agent-loop.d.ts
312
- interface AgentLoopInput {
313
- readonly abortSignal: AbortSignal;
314
- readonly invocation?: AgentInvocationOrigin;
315
- readonly messages?: ReadonlyArray<AgentTranscriptMessage>;
316
- readonly runId: AgentRunId;
317
- readonly sessionKey: SessionKey;
318
- /** Optional mailbox for user steering while the run is active. */
319
- readonly steering?: AgentSteeringChannel;
320
- readonly text: string;
321
- readonly previousSessionState?: AgentRunState;
322
- readonly previousSessionTranscript?: AgentTranscript;
323
- }
324
- interface AgentSteeringChannel {
325
- next(): Promise<string>;
326
- }
311
+ //#region src/modules/agent-execution/application/loop/agent-loop.d.ts
327
312
  type AgentLoopEvent = AgentLoopTurnStart | AgentLoopTextDelta | AgentLoopThinkingDelta | AgentLoopModelExecutionStart | AgentLoopModelExecutionEnd | AgentLoopSkillExecutionStart | AgentLoopSkillExecutionEnd | AgentLoopToolExecutionStart | AgentLoopToolExecutionUpdate | AgentLoopToolExecutionEnd;
328
313
  type AgentLoopEventLike = AgentLoopEvent | string;
329
314
  interface AgentLoopTextDelta {
@@ -397,24 +382,6 @@ interface AgentLoopToolExecutionEnd {
397
382
  readonly result: unknown;
398
383
  readonly isError: boolean;
399
384
  }
400
- interface AgentLoop {
401
- run(input: AgentLoopInput): Stream.Stream<AgentLoopEvent, unknown>;
402
- /** Provider adapters opt in only when they can consume steering safely. */
403
- readonly supportsSteering?: boolean;
404
- }
405
- type AgentLoopCallbackOutput = Iterable<AgentLoopEventLike> | AsyncIterable<AgentLoopEventLike> | Stream.Stream<AgentLoopEventLike, unknown>;
406
- type AgentLoopCallbackResult = AgentLoopCallbackOutput | PromiseLike<AgentLoopCallbackOutput> | Effect.Effect<AgentLoopCallbackOutput, unknown>;
407
- type AgentLoopCallback = (input: AgentLoopInput) => AgentLoopCallbackResult;
408
- interface AsyncIterableAgentLoopOptions {
409
- readonly run: (input: AgentLoopInput) => AsyncIterable<AgentLoopEventLike>;
410
- }
411
- interface EventAgentLoopOptions {
412
- readonly events: ReadonlyArray<AgentLoopEventLike> | ((input: AgentLoopInput) => ReadonlyArray<AgentLoopEventLike> | Promise<ReadonlyArray<AgentLoopEventLike>>);
413
- }
414
- interface TextAgentLoopOptions {
415
- readonly generate: (input: AgentLoopInput) => Effect.Effect<string, unknown>;
416
- }
417
- type TextAgentLoopCallback = (input: AgentLoopInput) => string | Promise<string>;
418
385
  type AgentLoopToolExecutionStartOptions = Omit<AgentLoopToolExecutionStart, "type">;
419
386
  type AgentLoopToolExecutionUpdateOptions = Omit<AgentLoopToolExecutionUpdate, "type">;
420
387
  type AgentLoopToolExecutionEndOptions = Omit<AgentLoopToolExecutionEnd, "type">;
@@ -432,10 +399,292 @@ declare function createAgentLoopSkillExecutionEnd(options: AgentLoopSkillExecuti
432
399
  declare function createAgentLoopToolExecutionStart(options: AgentLoopToolExecutionStartOptions): AgentLoopToolExecutionStart;
433
400
  declare function createAgentLoopToolExecutionUpdate(options: AgentLoopToolExecutionUpdateOptions): AgentLoopToolExecutionUpdate;
434
401
  declare function createAgentLoopToolExecutionEnd(options: AgentLoopToolExecutionEndOptions): AgentLoopToolExecutionEnd;
402
+ //#endregion
403
+ //#region src/modules/agent-execution/application/contracts/agent-execution-contracts.d.ts
404
+ interface AgentClock {
405
+ readonly now: Effect.Effect<Date>;
406
+ }
407
+ interface RunIdGenerator {
408
+ readonly next: Effect.Effect<AgentRunId>;
409
+ }
410
+ interface PromptCommand {
411
+ readonly invocation?: AgentInvocationOrigin;
412
+ readonly sessionKey: SessionKey;
413
+ readonly text: string;
414
+ }
415
+ interface AgentPromptResult {
416
+ readonly runId: AgentRunId;
417
+ readonly events: ReadonlyArray<AgentDomainEvent>;
418
+ readonly finalText: string;
419
+ readonly runSnapshot: AgentRunSnapshot;
420
+ readonly snapshot: AgentSessionSnapshot;
421
+ readonly state: AgentRunState;
422
+ readonly turn: AgentTranscriptTurn;
423
+ readonly updates: ReadonlyArray<AgentRunUpdate>;
424
+ }
425
+ interface AgentRunUpdate {
426
+ readonly event: AgentDomainEvent;
427
+ readonly previousState?: AgentRunState;
428
+ readonly state: AgentRunState;
429
+ }
430
+ interface AgentRunSnapshot {
431
+ readonly events: ReadonlyArray<AgentDomainEvent>;
432
+ readonly runId: AgentRunId;
433
+ readonly state?: AgentRunState;
434
+ readonly summary: AgentRunSummary;
435
+ readonly updates: ReadonlyArray<AgentRunUpdate>;
436
+ }
437
+ interface ActiveAgentRun {
438
+ readonly runId: AgentRunId;
439
+ readonly sessionKey: SessionKey;
440
+ }
441
+ type AgentHarnessAvailability = AgentHarnessIdleAvailability | AgentHarnessBusyAvailability;
442
+ type AgentSessionAvailability = AgentHarnessIdleAvailability | AgentSessionBusyAvailability;
443
+ interface AgentHarnessIdleAvailability {
444
+ readonly busy: false;
445
+ }
446
+ interface AgentHarnessBusyAvailability {
447
+ readonly activeRun: ActiveAgentRun;
448
+ readonly activeRunId: AgentRunId;
449
+ readonly activeSessionKey: SessionKey;
450
+ readonly activeState?: AgentRunState;
451
+ readonly busy: true;
452
+ }
453
+ type AgentSessionBusyAvailability = AgentSessionOwnedBusyAvailability | AgentSessionOtherBusyAvailability;
454
+ interface AgentSessionOwnedBusyAvailability {
455
+ readonly activeInSession: true;
456
+ readonly activeRun: ActiveAgentRun;
457
+ readonly activeRunId: AgentRunId;
458
+ readonly activeState?: AgentRunState;
459
+ readonly busy: true;
460
+ }
461
+ interface AgentSessionOtherBusyAvailability {
462
+ readonly activeInSession: false;
463
+ readonly busy: true;
464
+ }
465
+ interface AgentSessionSnapshot {
466
+ readonly availability: AgentSessionAvailability;
467
+ readonly latestRunSummary?: AgentRunSummary;
468
+ readonly runs: ReadonlyArray<AgentRunSummary>;
469
+ readonly sessionKey: SessionKey;
470
+ readonly state?: AgentRunState;
471
+ readonly summary?: AgentSessionSummary;
472
+ readonly transcript: AgentTranscript;
473
+ }
474
+ type AgentHarnessError = AgentHarnessBusy | AgentLoopFailed | AgentEventSinkFailed | AgentEventHandlerFailed | AgentRunCancelled;
475
+ interface AgentRunSubscriptionCapabilities {
476
+ subscribe(listener: AgentDomainEventListener): () => void;
477
+ subscribeRun(runId: AgentRunId, listener: AgentDomainEventListener): () => void;
478
+ subscribeRunUpdates(runId: AgentRunId, listener: AgentRunUpdateListener): () => void;
479
+ subscribeUpdates(listener: AgentRunUpdateListener): () => void;
480
+ }
481
+ interface AgentHarness extends AgentRunSubscriptionCapabilities {
482
+ cancelActiveRun(reason?: string): Effect.Effect<boolean>;
483
+ cancelRun(runId: AgentRunId, reason?: string): Effect.Effect<boolean>;
484
+ steerRun(runId: AgentRunId, text: string): Effect.Effect<boolean>;
485
+ forSession(sessionKey: SessionKey): AgentSessionHandle;
486
+ getActiveRun(): ActiveAgentRun | undefined;
487
+ getActiveRunId(): AgentRunId | undefined;
488
+ getActiveRunState(): AgentRunState | undefined;
489
+ getAvailability(): AgentHarnessAvailability;
490
+ getHistory(): AgentHistory;
491
+ getRunEvents(runId: AgentRunId): ReadonlyArray<AgentDomainEvent> | undefined;
492
+ getRunSnapshot(runId: AgentRunId): AgentRunSnapshot | undefined;
493
+ getRunSummary(runId: AgentRunId): AgentRunSummary | undefined;
494
+ getRunState(runId: AgentRunId): AgentRunState | undefined;
495
+ getRunUpdates(runId: AgentRunId): ReadonlyArray<AgentRunUpdate> | undefined;
496
+ getSessionHistory(sessionKey: SessionKey): AgentHistory;
497
+ getSessionLatestRunSnapshot(sessionKey: SessionKey): AgentRunSnapshot | undefined;
498
+ getSessionLatestRunSummary(sessionKey: SessionKey): AgentRunSummary | undefined;
499
+ getSessionRuns(sessionKey: SessionKey): ReadonlyArray<AgentRunSummary>;
500
+ getSessionSnapshot(sessionKey: SessionKey): AgentSessionSnapshot;
501
+ getSessionSummary(sessionKey: SessionKey): AgentSessionSummary | undefined;
502
+ getSessionTranscript(sessionKey: SessionKey): AgentTranscript;
503
+ getSessionState(sessionKey: SessionKey): AgentRunState | undefined;
504
+ getState(): AgentRunState;
505
+ prompt(command: PromptCommand): Effect.Effect<AgentPromptResult, AgentHarnessError>;
506
+ promptRunSnapshot(command: PromptCommand): Effect.Effect<AgentRunSnapshot, AgentHarnessError>;
507
+ promptSnapshot(command: PromptCommand): Effect.Effect<AgentSessionSnapshot, AgentHarnessError>;
508
+ promptText(command: PromptCommand): Effect.Effect<string, AgentHarnessError>;
509
+ promptTurn(command: PromptCommand): Effect.Effect<AgentTranscriptTurn, AgentHarnessError>;
510
+ promptWithEvents<R>(command: PromptCommand, onEvent: AgentDomainEventHandler<R>): Effect.Effect<AgentPromptResult, AgentHarnessError, R>;
511
+ promptWithUpdates<R>(command: PromptCommand, onUpdate: AgentRunUpdateHandler<R>): Effect.Effect<AgentPromptResult, AgentHarnessError, R>;
512
+ stream(command: PromptCommand): Stream.Stream<AgentDomainEvent, AgentHarnessError>;
513
+ streamText(command: PromptCommand): Stream.Stream<string, AgentHarnessError>;
514
+ streamUpdates(command: PromptCommand): Stream.Stream<AgentRunUpdate, AgentHarnessError>;
515
+ }
516
+ interface AgentSessionHandle extends AgentRunSubscriptionCapabilities {
517
+ readonly sessionKey: SessionKey;
518
+ cancelActiveRun(reason?: string): Effect.Effect<boolean>;
519
+ cancelRun(runId: AgentRunId, reason?: string): Effect.Effect<boolean>;
520
+ steerRun(runId: AgentRunId, text: string): Effect.Effect<boolean>;
521
+ getActiveRun(): ActiveAgentRun | undefined;
522
+ getActiveRunState(): AgentRunState | undefined;
523
+ getAvailability(): AgentSessionAvailability;
524
+ getHistory(): AgentHistory;
525
+ getLatestRunSnapshot(): AgentRunSnapshot | undefined;
526
+ getLatestRunSummary(): AgentRunSummary | undefined;
527
+ getRunEvents(runId: AgentRunId): ReadonlyArray<AgentDomainEvent> | undefined;
528
+ getRunSnapshot(runId: AgentRunId): AgentRunSnapshot | undefined;
529
+ getRunSummary(runId: AgentRunId): AgentRunSummary | undefined;
530
+ getRuns(): ReadonlyArray<AgentRunSummary>;
531
+ getSnapshot(): AgentSessionSnapshot;
532
+ getSummary(): AgentSessionSummary | undefined;
533
+ getTranscript(): AgentTranscript;
534
+ getRunState(runId: AgentRunId): AgentRunState | undefined;
535
+ getRunUpdates(runId: AgentRunId): ReadonlyArray<AgentRunUpdate> | undefined;
536
+ getState(): AgentRunState | undefined;
537
+ prompt(text: string): Effect.Effect<AgentPromptResult, AgentHarnessError>;
538
+ promptRunSnapshot(text: string): Effect.Effect<AgentRunSnapshot, AgentHarnessError>;
539
+ promptSnapshot(text: string): Effect.Effect<AgentSessionSnapshot, AgentHarnessError>;
540
+ promptText(text: string): Effect.Effect<string, AgentHarnessError>;
541
+ promptTurn(text: string): Effect.Effect<AgentTranscriptTurn, AgentHarnessError>;
542
+ promptWithEvents<R>(text: string, onEvent: AgentDomainEventHandler<R>): Effect.Effect<AgentPromptResult, AgentHarnessError, R>;
543
+ promptWithUpdates<R>(text: string, onUpdate: AgentRunUpdateHandler<R>): Effect.Effect<AgentPromptResult, AgentHarnessError, R>;
544
+ stream(text: string): Stream.Stream<AgentDomainEvent, AgentHarnessError>;
545
+ streamText(text: string): Stream.Stream<string, AgentHarnessError>;
546
+ streamUpdates(text: string): Stream.Stream<AgentRunUpdate, AgentHarnessError>;
547
+ }
548
+ type AgentDomainEventListener = (event: AgentDomainEvent) => void;
549
+ type AgentRunUpdateListener = (update: AgentRunUpdate) => void;
550
+ type AgentDomainEventHandler<R = never> = (event: AgentDomainEvent) => Effect.Effect<void, unknown, R>;
551
+ type AgentRunUpdateHandler<R = never> = (update: AgentRunUpdate) => Effect.Effect<void, unknown, R>;
552
+ interface AgentDomainEventSink {
553
+ append(event: AgentDomainEvent): Effect.Effect<void, unknown>;
554
+ }
555
+ //#endregion
556
+ //#region src/modules/agent-execution/application/contracts/agent-execution-errors.d.ts
557
+ declare class AgentHarnessBusy {
558
+ readonly activeRun: ActiveAgentRun;
559
+ readonly activeState?: AgentRunState | undefined;
560
+ readonly _tag = "AgentHarnessBusy";
561
+ readonly activeRunId: AgentRunId;
562
+ readonly activeSessionKey: SessionKey;
563
+ constructor(activeRun: ActiveAgentRun, activeState?: AgentRunState | undefined);
564
+ }
565
+ declare class AgentLoopFailed {
566
+ readonly runId: AgentRunId;
567
+ readonly errorMessage: string;
568
+ readonly cause: unknown;
569
+ readonly state?: AgentRunState | undefined;
570
+ readonly _tag = "AgentLoopFailed";
571
+ constructor(runId: AgentRunId, errorMessage: string, cause: unknown, state?: AgentRunState | undefined);
572
+ }
573
+ declare class AgentEventSinkFailed {
574
+ readonly runId: AgentRunId;
575
+ readonly eventType: AgentDomainEvent["type"];
576
+ readonly cause: unknown;
577
+ readonly _tag = "AgentEventSinkFailed";
578
+ constructor(runId: AgentRunId, eventType: AgentDomainEvent["type"], cause: unknown);
579
+ }
580
+ declare class AgentEventHandlerFailed {
581
+ readonly runId: AgentRunId;
582
+ readonly eventType: AgentDomainEvent["type"];
583
+ readonly cause: unknown;
584
+ readonly state?: AgentRunState | undefined;
585
+ readonly _tag = "AgentEventHandlerFailed";
586
+ constructor(runId: AgentRunId, eventType: AgentDomainEvent["type"], cause: unknown, state?: AgentRunState | undefined);
587
+ }
588
+ declare class AgentRunCancelled {
589
+ readonly runId: AgentRunId;
590
+ readonly reason: string | undefined;
591
+ readonly state: AgentRunState;
592
+ readonly _tag = "AgentRunCancelled";
593
+ constructor(runId: AgentRunId, reason: string | undefined, state: AgentRunState);
594
+ }
595
+ //#endregion
596
+ //#region src/modules/agent-execution/application/execution/agent-event-sink.d.ts
597
+ declare function createAgentDomainEventSink(append: (event: AgentDomainEvent) => Effect.Effect<void, unknown>): AgentDomainEventSink;
598
+ //#endregion
599
+ //#region src/modules/agent-execution/application/history/agent-history.d.ts
600
+ interface AgentHistoryEventLog {
601
+ readAll(): Effect.Effect<ReadonlyArray<AgentDomainEvent>, unknown>;
602
+ }
603
+ declare function restoreAgentHistory(eventLog: AgentHistoryEventLog): Effect.Effect<AgentHistory, unknown>;
604
+ //#endregion
605
+ //#region src/modules/agent-execution/application/context/agent-context-assembler.d.ts
606
+ type AgentContextLayerKind = "host-safety" | "system-prompt" | "managed-instructions" | "workspace-instructions" | "tool-schema" | "skill" | "memory" | "compaction" | "transcript" | "current-input";
607
+ interface AgentContextLayer {
608
+ readonly kind: AgentContextLayerKind;
609
+ readonly content: string;
610
+ }
611
+ interface AgentContextInput {
612
+ readonly hostSafety: string;
613
+ readonly systemPrompt: string;
614
+ readonly managedInstructions?: string;
615
+ readonly workspaceInstructions?: ReadonlyArray<string>;
616
+ readonly toolSchemas: ReadonlyArray<string>;
617
+ readonly skills?: ReadonlyArray<string>;
618
+ readonly memory?: ReadonlyArray<string>;
619
+ readonly compaction?: string;
620
+ readonly transcript?: ReadonlyArray<string>;
621
+ readonly currentInput: string;
622
+ readonly maxBytes: number;
623
+ }
624
+ interface AssembledAgentContext {
625
+ readonly layers: ReadonlyArray<AgentContextLayer>;
626
+ readonly omittedKinds: ReadonlyArray<AgentContextLayerKind>;
627
+ readonly bytes: number;
628
+ }
629
+ declare class AgentContextBudgetExceeded extends Error {
630
+ readonly name = "AgentContextBudgetExceeded";
631
+ }
632
+ declare function assembleAgentContext(input: AgentContextInput): AssembledAgentContext;
633
+ //#endregion
634
+ //#region src/modules/agent-execution/application/observation/agent-model-content-observer.d.ts
635
+ interface AgentModelInputObservation {
636
+ readonly input: unknown;
637
+ readonly modelCallId: string;
638
+ readonly runId: AgentRunId;
639
+ }
640
+ interface AgentModelOutputObservation {
641
+ readonly modelCallId: string;
642
+ readonly output: unknown;
643
+ readonly runId: AgentRunId;
644
+ }
645
+ interface AgentModelContentObserver {
646
+ observeInput(observation: AgentModelInputObservation): void;
647
+ observeOutput(observation: AgentModelOutputObservation): void;
648
+ }
649
+ //#endregion
650
+ //#region src/adapters/compatibility/agent-execution/loop/agent-loop.d.ts
651
+ interface AgentLoopInput {
652
+ readonly runId: AgentRunId;
653
+ readonly sessionKey: SessionKey;
654
+ readonly text: string;
655
+ readonly abortSignal: AbortSignal;
656
+ readonly previousSessionState?: AgentRunState;
657
+ readonly previousSessionTranscript?: AgentTranscript;
658
+ readonly messages?: ReadonlyArray<AgentTranscriptMessage>;
659
+ readonly invocation?: AgentInvocationOrigin;
660
+ /** Optional mailbox for user steering while the run is active. */
661
+ readonly steering?: AgentSteeringChannel;
662
+ }
663
+ interface AgentSteeringChannel {
664
+ next(): Promise<string>;
665
+ }
666
+ interface AgentLoop {
667
+ run(input: AgentLoopInput): Stream.Stream<AgentLoopEvent, unknown>;
668
+ /** Provider adapters opt in only when they can consume steering safely. */
669
+ readonly supportsSteering?: boolean;
670
+ }
671
+ type AgentLoopCallbackOutput = Iterable<AgentLoopEventLike> | AsyncIterable<AgentLoopEventLike> | Stream.Stream<AgentLoopEventLike, unknown>;
672
+ type AgentLoopCallbackResult = AgentLoopCallbackOutput | PromiseLike<AgentLoopCallbackOutput> | Effect.Effect<AgentLoopCallbackOutput, unknown>;
673
+ type AgentLoopCallback = (input: AgentLoopInput) => AgentLoopCallbackResult;
674
+ interface AsyncIterableAgentLoopOptions {
675
+ readonly run: (input: AgentLoopInput) => AsyncIterable<AgentLoopEventLike>;
676
+ }
677
+ interface EventAgentLoopOptions {
678
+ readonly events: ReadonlyArray<AgentLoopEventLike> | ((input: AgentLoopInput) => ReadonlyArray<AgentLoopEventLike> | Promise<ReadonlyArray<AgentLoopEventLike>>);
679
+ }
680
+ type TextAgentLoopCallback = (input: AgentLoopInput) => string | Promise<string>;
681
+ interface TextAgentLoopOptions {
682
+ readonly generate: (input: AgentLoopInput) => Effect.Effect<string, unknown>;
683
+ }
435
684
  declare function createEventAgentLoop(options: EventAgentLoopOptions): AgentLoop;
436
685
  declare function createAsyncIterableAgentLoop(options: AsyncIterableAgentLoopOptions): AgentLoop;
437
686
  declare function createAgentLoopFromCallback(run: AgentLoopCallback): AgentLoop;
438
687
  declare function createTextAgentLoop(options: TextAgentLoopOptions): AgentLoop;
439
688
  declare function createTextAgentLoopFromCallback(generate: TextAgentLoopCallback): AgentLoop;
440
689
  //#endregion
441
- export { AgentTranscriptTurn as $, createAgentLoopFromCallback as A, AgentTurnCompleted as At, createAgentLoopTurnStart as B, AgentLoopToolExecutionUpdateOptions as C, AgentRunId as Ct, EventAgentLoopOptions as D, AgentToolExecutionEvent as Dt, AsyncIterableAgentLoopOptions as E, AgentToolExecutionEnded as Et, createAgentLoopTextDelta as F, TerminalAgentDomainEvent as Ft, AgentInvocationOrigin as G, createEventAgentLoop as H, createAgentLoopThinkingDelta as I, isAgentToolExecutionEvent as It, LocalCliAgentInvocationOrigin as J, AutomationAgentInvocationOrigin as K, createAgentLoopToolExecutionEnd as L, isAssistantTextDeltaEvent as Lt, createAgentLoopModelExecutionStart as M, AssistantTextDelta as Mt, createAgentLoopSkillExecutionEnd as N, AssistantThinkingDelta as Nt, TextAgentLoopCallback as O, AgentToolExecutionStarted as Ot, createAgentLoopSkillExecutionStart as P, SessionKey as Pt, AgentTranscriptMessageRole as Q, createAgentLoopToolExecutionStart as R, isAssistantThinkingDeltaEvent as Rt, AgentLoopToolExecutionUpdate as S, AgentRunFailed as St, AgentSteeringChannel as T, AgentSkillExecutionStarted as Tt, createTextAgentLoop as U, createAsyncIterableAgentLoop as V, createTextAgentLoopFromCallback as W, AgentTranscript as X, AgentConversationMessagesOptions as Y, AgentTranscriptMessage as Z, AgentLoopThinkingDelta as _, AgentModelExecutionStarted as _t, AgentLoopEvent as a, AgentRunSummary as at, AgentLoopToolExecutionStart as b, AgentRunCancelled as bt, AgentLoopModelExecutionEnd as c, AgentRunPhase as ct, AgentLoopModelExecutionStartOptions as d, evolveAgentRun as dt, createAgentConversationMessages as et, AgentLoopSkillExecutionEnd as f, initialAgentRunState as ft, AgentLoopTextDelta as g, AgentModelExecutionEvent as gt, AgentLoopSkillExecutionStartOptions as h, AgentModelExecutionEnded as ht, AgentLoopCallbackResult as i, AgentHistory as it, createAgentLoopModelExecutionEnd as j, AgentTurnStarted as jt, TextAgentLoopOptions as k, AgentToolExecutionUpdated as kt, AgentLoopModelExecutionEndOptions as l, AgentRunState as lt, AgentLoopSkillExecutionStart as m, AgentDomainEvent as mt, AgentLoopCallback as n, createAgentTranscriptTurn as nt, AgentLoopEventLike as o, AgentSessionSummary as ot, AgentLoopSkillExecutionEndOptions as p, isTerminalAgentRunPhase as pt, FeishuAgentInvocationOrigin as q, AgentLoopCallbackOutput as r, replayAgentTranscript as rt, AgentLoopInput as s, replayAgentHistory as st, AgentLoop as t, createAgentTranscriptMessages as tt, AgentLoopModelExecutionStart as u, AgentSkillExecutionState as ut, AgentLoopToolExecutionEnd as v, AgentModelUsage as vt, AgentLoopTurnStart as w, AgentSkillExecutionEnded as wt, AgentLoopToolExecutionStartOptions as x, AgentRunCompleted as xt, AgentLoopToolExecutionEndOptions as y, AgentRunAccepted as yt, createAgentLoopToolExecutionUpdate as z, isTerminalAgentDomainEvent as zt };
690
+ export { AgentSessionSnapshot as $, isTerminalAgentRunPhase as $t, AgentHarnessBusy as A, createAgentLoopTurnStart as At, AgentHarnessBusyAvailability as B, createAgentConversationMessages as Bt, AssembledAgentContext as C, isAssistantThinkingDeltaEvent as Cn, createAgentLoopSkillExecutionEnd as Ct, createAgentDomainEventSink as D, createAgentLoopToolExecutionEnd as Dt, restoreAgentHistory as E, createAgentLoopThinkingDelta as Et, AgentDomainEventHandler as F, AgentConversationMessagesOptions as Ft, AgentRunUpdate as G, AgentRunSummary as Gt, AgentHarnessIdleAvailability as H, createAgentTranscriptTurn as Ht, AgentDomainEventListener as I, AgentTranscript as It, AgentSessionAvailability as J, AgentRunPhase as Jt, AgentRunUpdateHandler as K, AgentSessionSummary as Kt, AgentDomainEventSink as L, AgentTranscriptMessage as Lt, AgentRunCancelled as M, AutomationAgentInvocationOrigin as Mt, ActiveAgentRun as N, FeishuAgentInvocationOrigin as Nt, AgentEventHandlerFailed as O, createAgentLoopToolExecutionStart as Ot, AgentClock as P, LocalCliAgentInvocationOrigin as Pt, AgentSessionOwnedBusyAvailability as Q, initialAgentRunState as Qt, AgentHarness as R, AgentTranscriptMessageRole as Rt, AgentContextLayerKind as S, isAssistantTextDeltaEvent as Sn, createAgentLoopModelExecutionStart as St, AgentHistoryEventLog as T, createAgentLoopTextDelta as Tt, AgentPromptResult as U, replayAgentTranscript as Ut, AgentHarnessError as V, createAgentTranscriptMessages as Vt, AgentRunSnapshot as W, AgentHistory as Wt, AgentSessionHandle as X, AgentSkillExecutionState as Xt, AgentSessionBusyAvailability as Y, AgentRunState as Yt, AgentSessionOtherBusyAvailability as Z, evolveAgentRun as Zt, AgentModelInputObservation as _, AssistantTextDelta as _n, AgentLoopToolExecutionStartOptions as _t, AgentLoopInput as a, AgentRunAccepted as an, AgentLoopModelExecutionEndOptions as at, AgentContextInput as b, TerminalAgentDomainEvent as bn, AgentLoopTurnStart as bt, EventAgentLoopOptions as c, AgentRunId as cn, AgentLoopSkillExecutionEnd as ct, createAgentLoopFromCallback as d, AgentToolExecutionEnded as dn, AgentLoopSkillExecutionStartOptions as dt, AgentDomainEvent as en, PromptCommand as et, createAsyncIterableAgentLoop as f, AgentToolExecutionEvent as fn, AgentLoopTextDelta as ft, AgentModelContentObserver as g, AgentTurnStarted as gn, AgentLoopToolExecutionStart as gt, createTextAgentLoopFromCallback as h, AgentTurnCompleted as hn, AgentLoopToolExecutionEndOptions as ht, AgentLoopCallbackResult as i, AgentModelUsage as in, AgentLoopModelExecutionEnd as it, AgentLoopFailed as j, AgentInvocationOrigin as jt, AgentEventSinkFailed as k, createAgentLoopToolExecutionUpdate as kt, TextAgentLoopCallback as l, AgentSkillExecutionEnded as ln, AgentLoopSkillExecutionEndOptions as lt, createTextAgentLoop as m, AgentToolExecutionUpdated as mn, AgentLoopToolExecutionEnd as mt, AgentLoopCallback as n, AgentModelExecutionEvent as nn, AgentLoopEvent as nt, AgentSteeringChannel as o, AgentRunCompleted as on, AgentLoopModelExecutionStart as ot, createEventAgentLoop as p, AgentToolExecutionStarted as pn, AgentLoopThinkingDelta as pt, AgentRunUpdateListener as q, replayAgentHistory as qt, AgentLoopCallbackOutput as r, AgentModelExecutionStarted as rn, AgentLoopEventLike as rt, AsyncIterableAgentLoopOptions as s, AgentRunFailed as sn, AgentLoopModelExecutionStartOptions as st, AgentLoop as t, AgentModelExecutionEnded as tn, RunIdGenerator as tt, TextAgentLoopOptions as u, AgentSkillExecutionStarted as un, AgentLoopSkillExecutionStart as ut, AgentModelOutputObservation as v, AssistantThinkingDelta as vn, AgentLoopToolExecutionUpdate as vt, assembleAgentContext as w, isTerminalAgentDomainEvent as wn, createAgentLoopSkillExecutionStart as wt, AgentContextLayer as x, isAgentToolExecutionEvent as xn, createAgentLoopModelExecutionEnd as xt, AgentContextBudgetExceeded as y, SessionKey as yn, AgentLoopToolExecutionUpdateOptions as yt, AgentHarnessAvailability as z, AgentTranscriptTurn as zt };