@anvia/core 1.0.0-rc.1 → 1.0.0-rc.3

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 (151) hide show
  1. package/README.md +344 -85
  2. package/dist/agent/index.d.ts +33 -18
  3. package/dist/agent/index.js +42 -17
  4. package/dist/agent-CXScUOpX.d.ts +150 -0
  5. package/dist/{chunk-R2LJSQUW.js → chunk-3CMWKK32.js} +260 -104
  6. package/dist/chunk-3CMWKK32.js.map +1 -0
  7. package/dist/chunk-3RM57ZT2.js +31 -0
  8. package/dist/chunk-3RM57ZT2.js.map +1 -0
  9. package/dist/chunk-5MK3BISB.js +704 -0
  10. package/dist/chunk-5MK3BISB.js.map +1 -0
  11. package/dist/chunk-AI5JMUW7.js +45 -0
  12. package/dist/chunk-AI5JMUW7.js.map +1 -0
  13. package/dist/{chunk-FNQB2JEH.js → chunk-AZB6N7P4.js} +94 -65
  14. package/dist/chunk-AZB6N7P4.js.map +1 -0
  15. package/dist/chunk-BEYBU7VJ.js +53 -0
  16. package/dist/chunk-BEYBU7VJ.js.map +1 -0
  17. package/dist/chunk-BY4OMNIU.js +4699 -0
  18. package/dist/chunk-BY4OMNIU.js.map +1 -0
  19. package/dist/chunk-D2ECOWN5.js +515 -0
  20. package/dist/chunk-D2ECOWN5.js.map +1 -0
  21. package/dist/{chunk-A3UBYTJT.js → chunk-FN7HLLAZ.js} +60 -6
  22. package/dist/chunk-FN7HLLAZ.js.map +1 -0
  23. package/dist/chunk-GKDERULJ.js +50 -0
  24. package/dist/chunk-GKDERULJ.js.map +1 -0
  25. package/dist/chunk-GQL5KRAH.js +331 -0
  26. package/dist/chunk-GQL5KRAH.js.map +1 -0
  27. package/dist/{chunk-5XKDW36Z.js → chunk-KFR4CDGK.js} +70 -75
  28. package/dist/chunk-KFR4CDGK.js.map +1 -0
  29. package/dist/chunk-KV6QCRQ4.js +171 -0
  30. package/dist/chunk-KV6QCRQ4.js.map +1 -0
  31. package/dist/{chunk-DMPUP4R3.js → chunk-LXMAFD23.js} +5 -5
  32. package/dist/{chunk-I6G7BC42.js → chunk-MGNTXGTX.js} +2 -6
  33. package/dist/chunk-MGNTXGTX.js.map +1 -0
  34. package/dist/chunk-PK5LKOFL.js +239 -0
  35. package/dist/chunk-PK5LKOFL.js.map +1 -0
  36. package/dist/chunk-QOUPWOGW.js +29 -0
  37. package/dist/chunk-QOUPWOGW.js.map +1 -0
  38. package/dist/chunk-TRQ3XRFD.js +54 -0
  39. package/dist/chunk-TRQ3XRFD.js.map +1 -0
  40. package/dist/chunk-VKYZZXP5.js +323 -0
  41. package/dist/chunk-VKYZZXP5.js.map +1 -0
  42. package/dist/chunk-ZCPOIDAQ.js +127 -0
  43. package/dist/chunk-ZCPOIDAQ.js.map +1 -0
  44. package/dist/client-DvUatElp.d.ts +84 -0
  45. package/dist/completion/index.d.ts +5 -4
  46. package/dist/completion/index.js +25 -28
  47. package/dist/documents/index.d.ts +34 -0
  48. package/dist/documents/index.js +315 -0
  49. package/dist/documents/index.js.map +1 -0
  50. package/dist/{dynamic-tools-i9woysFa.d.ts → dynamic-tools-AEBOTgu1.d.ts} +21 -9
  51. package/dist/embeddings/index.d.ts +11 -9
  52. package/dist/embeddings/index.js +3 -3
  53. package/dist/evals/index.d.ts +53 -25
  54. package/dist/evals/index.js +153 -103
  55. package/dist/evals/index.js.map +1 -1
  56. package/dist/extractor/index.d.ts +23 -26
  57. package/dist/extractor/index.js +7 -8
  58. package/dist/guardrails/index.d.ts +7 -129
  59. package/dist/guardrails/index.js +1 -1
  60. package/dist/image-generation/index.d.ts +18 -16
  61. package/dist/image-generation/index.js +2 -2
  62. package/dist/index.d.ts +26 -23
  63. package/dist/index.js +71 -48
  64. package/dist/interactions-csssHYcN.d.ts +174 -0
  65. package/dist/internal/agent.d.ts +36 -29
  66. package/dist/internal/agent.js +48 -15
  67. package/dist/internal/agent.js.map +1 -1
  68. package/dist/mcp/index.d.ts +19 -13
  69. package/dist/mcp/index.js +14 -348
  70. package/dist/mcp/index.js.map +1 -1
  71. package/dist/memory/index.d.ts +20 -6
  72. package/dist/memory/index.js +10 -10
  73. package/dist/message-schema-B2M7AYzR.d.ts +52 -0
  74. package/dist/model-call-options-CZkSw_xN.d.ts +6 -0
  75. package/dist/model-listing/index.d.ts +3 -1
  76. package/dist/observability/index.d.ts +21 -6
  77. package/dist/observability/index.js +8 -5
  78. package/dist/observability/index.js.map +1 -1
  79. package/dist/pipeline/index.d.ts +106 -57
  80. package/dist/pipeline/index.js +419 -236
  81. package/dist/pipeline/index.js.map +1 -1
  82. package/dist/{retry-D3Ruy-ba.d.ts → retry-CjvSlKGW.d.ts} +2 -1
  83. package/dist/skills/index.d.ts +5 -4
  84. package/dist/skills/index.js +8 -7
  85. package/dist/speech-generation/index.d.ts +37 -0
  86. package/dist/speech-generation/index.js +8 -0
  87. package/dist/text-C_6eKrbC.d.ts +32 -0
  88. package/dist/{think-tool-DZqZj2LV.d.ts → think-tool-D8frXxwV.d.ts} +16 -2
  89. package/dist/tool/index.d.ts +9 -7
  90. package/dist/tool/index.js +12 -10
  91. package/dist/{tool-C_8GudXn.d.ts → tool-r62gf3QY.d.ts} +17 -8
  92. package/dist/transcription/index.d.ts +23 -14
  93. package/dist/transcription/index.js +2 -2
  94. package/dist/types-C3gv9EX6.d.ts +130 -0
  95. package/dist/{index-DxB74ybJ.d.ts → types-CElwurHZ.d.ts} +139 -88
  96. package/dist/types-CIPaIbZo.d.ts +105 -0
  97. package/dist/types-Cr4uiYo5.d.ts +99 -0
  98. package/dist/types-D9rKQ_as.d.ts +341 -0
  99. package/dist/types-DbolvLtZ.d.ts +155 -0
  100. package/dist/{types-DhQfwiZn.d.ts → types-RT3cuyRk.d.ts} +1 -1
  101. package/dist/vector-store/index.d.ts +33 -34
  102. package/dist/vector-store/index.js +7 -6
  103. package/package.json +10 -14
  104. package/dist/agent-DGYY_onS.d.ts +0 -145
  105. package/dist/audio-generation/index.d.ts +0 -31
  106. package/dist/audio-generation/index.js +0 -8
  107. package/dist/chunk-5XKDW36Z.js.map +0 -1
  108. package/dist/chunk-6WGGTJE6.js +0 -139
  109. package/dist/chunk-6WGGTJE6.js.map +0 -1
  110. package/dist/chunk-A3UBYTJT.js.map +0 -1
  111. package/dist/chunk-ADH7NNCS.js +0 -512
  112. package/dist/chunk-ADH7NNCS.js.map +0 -1
  113. package/dist/chunk-DZ3CKYTH.js +0 -267
  114. package/dist/chunk-DZ3CKYTH.js.map +0 -1
  115. package/dist/chunk-FNQB2JEH.js.map +0 -1
  116. package/dist/chunk-I6G7BC42.js.map +0 -1
  117. package/dist/chunk-IL3ZSNJI.js +0 -3748
  118. package/dist/chunk-IL3ZSNJI.js.map +0 -1
  119. package/dist/chunk-J6GNQART.js +0 -122
  120. package/dist/chunk-J6GNQART.js.map +0 -1
  121. package/dist/chunk-M3IOWB4Y.js +0 -280
  122. package/dist/chunk-M3IOWB4Y.js.map +0 -1
  123. package/dist/chunk-QY5GZ7HR.js +0 -39
  124. package/dist/chunk-QY5GZ7HR.js.map +0 -1
  125. package/dist/chunk-R2LJSQUW.js.map +0 -1
  126. package/dist/chunk-RFDVKCIE.js +0 -12
  127. package/dist/chunk-RFDVKCIE.js.map +0 -1
  128. package/dist/chunk-RMUBRRSK.js +0 -34
  129. package/dist/chunk-RMUBRRSK.js.map +0 -1
  130. package/dist/chunk-RXKHOYEH.js +0 -466
  131. package/dist/chunk-RXKHOYEH.js.map +0 -1
  132. package/dist/chunk-XDRSPSR7.js +0 -38
  133. package/dist/chunk-XDRSPSR7.js.map +0 -1
  134. package/dist/chunk-XWUC7CIT.js +0 -1
  135. package/dist/chunk-XWUC7CIT.js.map +0 -1
  136. package/dist/errors-CYKUcU89.d.ts +0 -17
  137. package/dist/json-Zo7K3xmt.d.ts +0 -40
  138. package/dist/loaders/index.d.ts +0 -86
  139. package/dist/loaders/index.js +0 -299
  140. package/dist/loaders/index.js.map +0 -1
  141. package/dist/middleware-KynLg_RW.d.ts +0 -56
  142. package/dist/types-B3A4YxaA.d.ts +0 -354
  143. package/dist/types-BBEGKB9m.d.ts +0 -119
  144. package/dist/types-DT3nEemY.d.ts +0 -79
  145. package/dist/types-DulRCYdB.d.ts +0 -70
  146. package/dist/types-p55Jc-sr.d.ts +0 -47
  147. package/dist/ui/index.d.ts +0 -107
  148. package/dist/ui/index.js +0 -10
  149. package/dist/ui/index.js.map +0 -1
  150. /package/dist/{chunk-DMPUP4R3.js.map → chunk-LXMAFD23.js.map} +0 -0
  151. /package/dist/{audio-generation → speech-generation}/index.js.map +0 -0
@@ -0,0 +1,130 @@
1
+ import { b as RetrySetting } from './retry-CjvSlKGW.js';
2
+ import { J as JsonObject } from './types-D9rKQ_as.js';
3
+ import { b as VectorMetadataValue, V as VectorMetadata, a as EmbeddedDocument, S as SparseVector, E as EmbeddingModel, c as SparseEmbeddingModel } from './types-Cr4uiYo5.js';
4
+
5
+ type VectorFilter = {
6
+ type: "eq";
7
+ key: string;
8
+ value: VectorMetadataValue;
9
+ } | {
10
+ type: "gt";
11
+ key: string;
12
+ value: VectorMetadataValue;
13
+ } | {
14
+ type: "lt";
15
+ key: string;
16
+ value: VectorMetadataValue;
17
+ } | {
18
+ type: "and";
19
+ filters: [VectorFilter, VectorFilter];
20
+ } | {
21
+ type: "or";
22
+ filters: [VectorFilter, VectorFilter];
23
+ };
24
+ type VectorMetric = "cosine" | "euclidean" | "dotProduct";
25
+ type VectorFusion = "rrf" | "dbsf";
26
+ type LshOptions = {
27
+ type: "lsh";
28
+ numTables: number;
29
+ numHyperplanes: number;
30
+ seed?: number | undefined;
31
+ };
32
+ type IndexStrategy = {
33
+ type: "bruteForce";
34
+ } | LshOptions;
35
+ type VectorStoreUpsertOptions<T, Metadata extends VectorMetadata = VectorMetadata> = {
36
+ documents: Array<EmbeddedDocument<T, Metadata>>;
37
+ providerOptions?: JsonObject | undefined;
38
+ };
39
+ type VectorSearchRequest = {
40
+ vector: number[];
41
+ topK: number;
42
+ minScore?: number | undefined;
43
+ filter?: VectorFilter | undefined;
44
+ providerOptions?: JsonObject | undefined;
45
+ abortSignal?: AbortSignal | undefined;
46
+ };
47
+ type HybridVectorSearchRequest = VectorSearchRequest & {
48
+ sparseVector: SparseVector;
49
+ fusion?: VectorFusion | undefined;
50
+ };
51
+ type VectorSearchResult<T = unknown, Metadata extends VectorMetadata = VectorMetadata> = {
52
+ score: number;
53
+ id: string;
54
+ document: T;
55
+ metadata?: Metadata | undefined;
56
+ };
57
+ type VectorInspectRequest = {
58
+ limit: number;
59
+ cursor?: string | undefined;
60
+ filter?: VectorFilter | undefined;
61
+ providerOptions?: JsonObject | undefined;
62
+ abortSignal?: AbortSignal | undefined;
63
+ };
64
+ type VectorInspectItem<T = unknown, Metadata extends VectorMetadata = VectorMetadata> = {
65
+ id: string;
66
+ document: T;
67
+ metadata?: Metadata | undefined;
68
+ };
69
+ type VectorInspectPage<T = unknown, Metadata extends VectorMetadata = VectorMetadata> = {
70
+ items: Array<VectorInspectItem<T, Metadata>>;
71
+ nextCursor?: string | undefined;
72
+ totalCount?: number | undefined;
73
+ };
74
+ interface VectorStore<T = unknown, Metadata extends VectorMetadata = VectorMetadata> {
75
+ ensure(): Promise<void>;
76
+ validate(): Promise<void>;
77
+ upsert(options: VectorStoreUpsertOptions<T, Metadata>): Promise<void>;
78
+ search(request: VectorSearchRequest): Promise<Array<VectorSearchResult<T, Metadata>>>;
79
+ inspect?(request: VectorInspectRequest): Promise<VectorInspectPage<T, Metadata>>;
80
+ }
81
+ interface HybridVectorStore<T = unknown, Metadata extends VectorMetadata = VectorMetadata> extends VectorStore<T, Metadata> {
82
+ searchHybrid(request: HybridVectorSearchRequest): Promise<Array<VectorSearchResult<T, Metadata>>>;
83
+ }
84
+ type RetrieveDocumentsBaseOptions = {
85
+ query: string;
86
+ topK: number;
87
+ minScore?: number | undefined;
88
+ filter?: VectorFilter | undefined;
89
+ retries?: RetrySetting | undefined;
90
+ abortSignal?: AbortSignal | undefined;
91
+ };
92
+ type RetrieveDocumentsOptions<T, Metadata extends VectorMetadata = VectorMetadata> = RetrieveDocumentsBaseOptions & {
93
+ store: VectorStore<T, Metadata>;
94
+ model: EmbeddingModel;
95
+ models?: never;
96
+ };
97
+ type RetrieveHybridDocumentsOptions<T, Metadata extends VectorMetadata = VectorMetadata> = RetrieveDocumentsBaseOptions & {
98
+ store: HybridVectorStore<T, Metadata>;
99
+ model?: never;
100
+ models: {
101
+ dense: EmbeddingModel;
102
+ sparse: SparseEmbeddingModel;
103
+ };
104
+ fusion?: VectorFusion | undefined;
105
+ };
106
+ type VectorSearchToolBaseOptions = {
107
+ name: string;
108
+ description?: string | undefined;
109
+ topK?: number | undefined;
110
+ minScore?: number | undefined;
111
+ filter?: VectorFilter | undefined;
112
+ retries?: RetrySetting | undefined;
113
+ };
114
+ type DenseVectorSearchToolOptions<T, Metadata extends VectorMetadata = VectorMetadata> = VectorSearchToolBaseOptions & {
115
+ store: VectorStore<T, Metadata>;
116
+ model: EmbeddingModel;
117
+ models?: never;
118
+ };
119
+ type HybridVectorSearchToolOptions<T, Metadata extends VectorMetadata = VectorMetadata> = VectorSearchToolBaseOptions & {
120
+ store: HybridVectorStore<T, Metadata>;
121
+ model?: never;
122
+ models: {
123
+ dense: EmbeddingModel;
124
+ sparse: SparseEmbeddingModel;
125
+ };
126
+ fusion?: VectorFusion | undefined;
127
+ };
128
+ type VectorSearchToolOptions<T = unknown, Metadata extends VectorMetadata = VectorMetadata> = DenseVectorSearchToolOptions<T, Metadata> | HybridVectorSearchToolOptions<T, Metadata>;
129
+
130
+ export type { DenseVectorSearchToolOptions as D, HybridVectorStore as H, IndexStrategy as I, LshOptions as L, RetrieveDocumentsOptions as R, VectorFilter as V, VectorSearchResult as a, VectorInspectRequest as b, VectorInspectPage as c, VectorStore as d, VectorFusion as e, RetrieveHybridDocumentsOptions as f, VectorStoreUpsertOptions as g, VectorSearchRequest as h, VectorSearchToolOptions as i, HybridVectorSearchRequest as j, HybridVectorSearchToolOptions as k, RetrieveDocumentsBaseOptions as l, VectorInspectItem as m, VectorMetric as n, VectorSearchToolBaseOptions as o };
@@ -1,9 +1,10 @@
1
- import { a as RetryOptions } from './retry-D3Ruy-ba.js';
2
- import { M as Message, g as CompletionResponse, U as Usage, V as ReasoningContentType, p as ToolCall, h as CompletionSource, o as ProviderToolCall, j as ContextUsage, f as CompletionRequest, u as ToolResultContent, X as ToolCallArgumentsMode, J as JsonObject, K as CompletionModelCapabilities, r as ToolDefinition, l as JsonValue } from './types-B3A4YxaA.js';
3
- import { GuardrailPolicyInput, GuardrailDecisionRecord } from './guardrails/index.js';
4
- import { A as AgentMiddleware } from './middleware-KynLg_RW.js';
1
+ import { a as AgentInteractionRequest, A as AgentContinuation, b as AgentInteractionResponse, c as AgentMiddleware } from './interactions-csssHYcN.js';
2
+ import { b as RetrySetting } from './retry-CjvSlKGW.js';
3
+ import { M as Message, f as CompletionResponse, U as Usage, R as ReasoningContentType, t as ToolCallPart, h as CompletionSource, q as ProviderToolCall, E as UserMessage, k as ContextUsage, e as CompletionRequest, y as ToolResultOutput, x as ToolResultContentPart, Z as ToolInteractionResponsePart, Y as ToolCallArgumentsMode, J as JsonObject, Q as CompletionModelCapabilities, v as ToolDefinition } from './types-D9rKQ_as.js';
4
+ import { d as GuardrailPolicyInput, a as GuardrailDecisionRecord } from './types-CIPaIbZo.js';
5
+ import { e as MemoryCompactionInfo, z as MemoryScope } from './types-DbolvLtZ.js';
5
6
  import { D as DeepReadonly, M as MaybePromise } from './type-utils-CtHVDRn_.js';
6
- import { d as ToolCallStreamEvent } from './tool-C_8GudXn.js';
7
+ import { d as ToolCallStreamEvent } from './tool-r62gf3QY.js';
7
8
 
8
9
  type AgentLifecycleRunEvent = {
9
10
  runId: string;
@@ -34,39 +35,81 @@ type AgentToolFinishEvent = (AgentToolFinishEventBase & {
34
35
  success: false;
35
36
  error: unknown;
36
37
  });
37
- type AgentFinishEvent = AgentLifecycleRunEvent & {
38
- output: string;
38
+ type AgentFinishEventBase = AgentLifecycleRunEvent & {
39
+ text: string;
39
40
  usage: DeepReadonly<Usage>;
40
41
  messages: DeepReadonly<Message[]>;
42
+ memoryCompaction?: DeepReadonly<MemoryCompactionInfo> | undefined;
41
43
  };
44
+ type AgentFinishEvent<Output = string> = (AgentFinishEventBase & {
45
+ status: "completed";
46
+ output: DeepReadonly<Output>;
47
+ }) | (AgentFinishEventBase & {
48
+ status: "blocked";
49
+ stage: "input" | "output";
50
+ }) | (AgentFinishEventBase & {
51
+ status: "suspended";
52
+ interaction: DeepReadonly<AgentInteractionRequest>;
53
+ });
42
54
  type AgentErrorEvent = AgentLifecycleRunEvent & {
43
55
  error: unknown;
44
56
  usage: DeepReadonly<Usage>;
45
57
  messages: DeepReadonly<Message[]>;
46
58
  };
47
- type AgentLifecycle<RawResponse = unknown> = {
59
+ type AgentLifecycle<Output = string, RawResponse = unknown> = {
48
60
  onStart?(event: AgentStartEvent): MaybePromise<void>;
49
61
  onStepFinish?(event: AgentStepFinishEvent<RawResponse>): MaybePromise<void>;
50
62
  onToolStart?(event: AgentToolStartEvent): MaybePromise<void>;
51
63
  onToolFinish?(event: AgentToolFinishEvent): MaybePromise<void>;
52
- onFinish?(event: AgentFinishEvent): MaybePromise<void>;
64
+ onFinish?(event: AgentFinishEvent<Output>): MaybePromise<void>;
53
65
  onError?(event: AgentErrorEvent): MaybePromise<void>;
54
66
  };
55
67
 
56
- type AgentInput = string | Message | Message[];
57
- type AgentRunOptions = {
68
+ type AgentPrompt = string | UserMessage;
69
+ type AgentInput = {
70
+ prompt: AgentPrompt;
71
+ messages?: never;
72
+ session?: MemoryScope | undefined;
73
+ continuation?: never;
74
+ response?: never;
75
+ } | {
76
+ messages: readonly Message[];
77
+ prompt?: never;
78
+ session?: never;
79
+ continuation?: never;
80
+ response?: never;
81
+ } | {
82
+ continuation: AgentContinuation;
83
+ response: AgentInteractionResponse;
84
+ prompt?: never;
85
+ messages?: never;
86
+ session?: never;
87
+ };
88
+ type AgentSteerInput = {
89
+ prompt: AgentPrompt;
90
+ messages?: never;
91
+ } | {
92
+ messages: readonly UserMessage[];
93
+ prompt?: never;
94
+ };
95
+ type AgentRunSettings<Output = string, RawResponse = unknown> = {
58
96
  maxTurns?: number | undefined;
59
- retries?: RetryOptions | undefined;
60
- lifecycle?: AgentLifecycle | undefined;
97
+ retries?: RetrySetting | undefined;
98
+ abortSignal?: AbortSignal | undefined;
99
+ lifecycle?: AgentLifecycle<Output, RawResponse> | undefined;
61
100
  guardrails?: GuardrailPolicyInput | undefined;
62
101
  toolConcurrency?: number | undefined;
63
102
  middlewares?: readonly AgentMiddleware[] | undefined;
64
103
  trace?: AgentTraceOptions | undefined;
65
104
  };
66
- type AgentResponse = {
67
- status: "completed";
105
+ type AgentRunOptions<Output = string, RawResponse = unknown> = AgentInput & AgentRunSettings<Output, RawResponse>;
106
+ type AgentRunLink = Readonly<{
107
+ runId: string;
108
+ interactionId: string;
109
+ }>;
110
+ type AgentResultBase = {
68
111
  runId: string;
69
- output: string;
112
+ text: string;
70
113
  usage: Usage;
71
114
  contextUsage?: ContextUsage | undefined;
72
115
  messages: Message[];
@@ -74,32 +117,23 @@ type AgentResponse = {
74
117
  guardrails?: GuardrailDecisionRecord[] | undefined;
75
118
  sources?: CompletionSource[] | undefined;
76
119
  providerToolCalls?: ProviderToolCall[] | undefined;
120
+ memoryCompaction?: MemoryCompactionInfo | undefined;
121
+ resumedFrom?: AgentRunLink | undefined;
77
122
  };
78
- type AgentApprovalRequiredResult = {
79
- status: "approval_required";
80
- runId: string;
81
- approval: AgentToolApprovalRequest;
82
- usage: Usage;
83
- messages: Message[];
84
- };
85
- type AgentResult = AgentResponse | AgentApprovalRequiredResult;
86
- type AgentToolApprovalRequest = {
87
- id: string;
88
- toolName: string;
89
- toolCallId?: string | undefined;
90
- reason?: string | undefined;
91
- input: unknown;
123
+ type AgentResponse<Output = string> = AgentResultBase & {
124
+ status: "completed";
125
+ output: Output;
92
126
  };
93
- type AgentApprovalRequiredEvent = Omit<AgentApprovalRequiredResult, "status"> & {
94
- type: "approval_required";
127
+ type AgentBlockedResult = AgentResultBase & {
128
+ status: "blocked";
129
+ stage: "input" | "output";
95
130
  };
96
- type AgentApprovalDecision = {
97
- approved: true;
98
- reason?: string;
99
- } | {
100
- approved: false;
101
- reason?: string;
131
+ type AgentSuspendedResult = AgentResultBase & {
132
+ status: "suspended";
133
+ interaction: AgentInteractionRequest;
134
+ continuation: AgentContinuation;
102
135
  };
136
+ type AgentResult<Output = string> = AgentResponse<Output> | AgentBlockedResult | AgentSuspendedResult;
103
137
  type AgentDeltaEvent = {
104
138
  type: "text_delta";
105
139
  delta: string;
@@ -111,7 +145,7 @@ type AgentDeltaEvent = {
111
145
  signature?: string;
112
146
  } | {
113
147
  type: "tool_call";
114
- toolCall: ToolCall;
148
+ toolCall: ToolCallPart;
115
149
  } | {
116
150
  type: "source";
117
151
  source: CompletionSource;
@@ -124,10 +158,6 @@ type AgentErrorStreamEvent = {
124
158
  error: unknown;
125
159
  usage: Usage;
126
160
  };
127
- type AgentStreamOptions = AgentRunOptions & {
128
- /** @default true */
129
- includeToolCallDeltas?: boolean;
130
- };
131
161
  type AgentToolCallDeltaEvent = {
132
162
  type: "tool_call_delta";
133
163
  turn: number;
@@ -138,7 +168,24 @@ type AgentToolCallDeltaEvent = {
138
168
  argumentsMode?: ToolCallArgumentsMode;
139
169
  signature?: string;
140
170
  };
141
- type AgentChildStreamEventBase<RawResponse = unknown> = {
171
+ type AgentMemoryCompactionEvent = MemoryCompactionInfo & {
172
+ type: "memory_compaction";
173
+ };
174
+ type AgentInteractionResponseEvent = {
175
+ type: "interaction_response";
176
+ response: ToolInteractionResponsePart;
177
+ sourceRunId: string;
178
+ };
179
+ type AgentSteerReceipt = Readonly<{
180
+ id: string;
181
+ status: "queued";
182
+ }>;
183
+ type AgentSteeringAppliedEvent = {
184
+ type: "steering_applied";
185
+ id: string;
186
+ turn: number;
187
+ };
188
+ type AgentChildStreamEventBase<Output = string, RawResponse = unknown> = {
142
189
  type: "turn_start";
143
190
  turn: number;
144
191
  prompt: Message;
@@ -162,7 +209,7 @@ type AgentChildStreamEventBase<RawResponse = unknown> = {
162
209
  } | {
163
210
  type: "tool_call";
164
211
  turn: number;
165
- toolCall: ToolCall;
212
+ toolCall: ToolCallPart;
166
213
  } | {
167
214
  type: "source";
168
215
  turn: number;
@@ -175,11 +222,13 @@ type AgentChildStreamEventBase<RawResponse = unknown> = {
175
222
  type: "tool_result";
176
223
  turn: number;
177
224
  toolName: string;
178
- toolCallId?: string;
225
+ toolCallId: string;
226
+ callId?: string;
179
227
  internalCallId: string;
180
228
  args: string;
229
+ output: ToolResultOutput;
181
230
  result: string;
182
- structuredResult?: ToolResultContent[] | undefined;
231
+ structuredResult?: readonly ToolResultContentPart[] | undefined;
183
232
  } | {
184
233
  type: "turn_end";
185
234
  turn: number;
@@ -189,22 +238,12 @@ type AgentChildStreamEventBase<RawResponse = unknown> = {
189
238
  type: "guardrail_decision";
190
239
  turn?: number | undefined;
191
240
  decision: GuardrailDecisionRecord;
192
- } | {
241
+ } | AgentMemoryCompactionEvent | AgentInteractionResponseEvent | AgentSteeringAppliedEvent | {
193
242
  type: "final";
194
- runId: string;
195
- output: string;
196
- usage: Usage;
197
- contextUsage?: ContextUsage | undefined;
198
- messages: Message[];
199
- trace?: AgentTraceInfo | undefined;
200
- guardrails?: GuardrailDecisionRecord[] | undefined;
201
- sources?: CompletionSource[] | undefined;
202
- providerToolCalls?: ProviderToolCall[] | undefined;
203
- } | AgentApprovalRequiredEvent | AgentErrorStreamEvent;
204
- type AgentChildStreamEventWithoutToolCallDeltas<RawResponse = unknown> = AgentChildStreamEventBase<RawResponse>;
205
- type AgentChildStreamEvent<RawResponse = unknown> = AgentChildStreamEventBase<RawResponse> | AgentToolCallDeltaEvent;
206
- type AgentChildStreamEventWithToolCallDeltas<RawResponse = unknown> = AgentChildStreamEvent<RawResponse>;
207
- type AgentToolStreamEvent<ChildEvent> = {
243
+ result: AgentResult<Output>;
244
+ } | AgentErrorStreamEvent;
245
+ type AgentChildStreamEvent<Output = string, RawResponse = unknown> = AgentChildStreamEventBase<Output, RawResponse> | AgentToolCallDeltaEvent;
246
+ type AgentToolStreamEvent = {
208
247
  type: "agent_tool_event";
209
248
  turn: number;
210
249
  toolName: string;
@@ -212,28 +251,27 @@ type AgentToolStreamEvent<ChildEvent> = {
212
251
  internalCallId: string;
213
252
  agentId: string;
214
253
  agentName?: string;
215
- event: ChildEvent;
254
+ event: AgentChildStreamEvent<unknown, unknown>;
216
255
  };
217
- type AgentStreamEventWithoutToolCallDeltas<RawResponse = unknown> = AgentChildStreamEventWithoutToolCallDeltas<RawResponse> | AgentToolStreamEvent<AgentChildStreamEventWithoutToolCallDeltas<RawResponse>>;
218
- type AgentStreamEvent<RawResponse = unknown> = AgentChildStreamEvent<RawResponse> | AgentToolStreamEvent<AgentChildStreamEvent<RawResponse>>;
219
- type AgentStreamEventWithToolCallDeltas<RawResponse = unknown> = AgentStreamEvent<RawResponse>;
256
+ type AgentStreamEvent<Output = string, RawResponse = unknown> = AgentChildStreamEvent<Output, RawResponse> | AgentToolStreamEvent;
220
257
  interface AgentStream<Event = AgentStreamEvent> extends AsyncIterable<Event> {
221
- steer(input: AgentInput): boolean;
258
+ steer(input: AgentSteerInput): AgentSteerReceipt;
222
259
  }
223
260
 
224
261
  type AgentTraceInfo = {
262
+ readonly observer: string;
225
263
  readonly traceId?: string | undefined;
226
264
  readonly observationId?: string | undefined;
227
265
  };
266
+ type AgentObserverTraceInfo = Omit<AgentTraceInfo, "observer">;
228
267
  type AgentTraceOptions = {
229
268
  readonly name?: string | undefined;
230
269
  readonly userId?: string | undefined;
231
270
  readonly sessionId?: string | undefined;
232
- readonly metadata?: Readonly<Record<string, unknown>> | undefined;
271
+ readonly metadata?: DeepReadonly<JsonObject> | undefined;
233
272
  readonly tags?: readonly string[] | undefined;
234
273
  readonly version?: string | undefined;
235
274
  readonly traceId?: string | undefined;
236
- readonly failOnObserverError?: boolean | undefined;
237
275
  readonly promptRef?: AgentRunPromptRef | undefined;
238
276
  };
239
277
  type AgentRunPromptRef = {
@@ -251,13 +289,25 @@ type AgentRunStartArgs = {
251
289
  readonly history: readonly DeepReadonly<Message>[];
252
290
  readonly maxTurns: number;
253
291
  };
254
- type AgentRunEndArgs = {
255
- readonly output: string;
292
+ type AgentRunEndArgsBase = {
293
+ readonly runId: string;
294
+ readonly text: string;
256
295
  readonly usage: DeepReadonly<Usage>;
257
296
  readonly messages: readonly DeepReadonly<Message>[];
258
297
  readonly sources?: readonly DeepReadonly<CompletionSource>[] | undefined;
259
298
  readonly providerToolCalls?: readonly DeepReadonly<ProviderToolCall>[] | undefined;
260
- };
299
+ readonly resumedFrom?: DeepReadonly<AgentRunLink> | undefined;
300
+ };
301
+ type AgentRunEndArgs = (AgentRunEndArgsBase & {
302
+ readonly status: "completed";
303
+ readonly output: unknown;
304
+ }) | (AgentRunEndArgsBase & {
305
+ readonly status: "blocked";
306
+ readonly stage: "input" | "output";
307
+ }) | (AgentRunEndArgsBase & {
308
+ readonly status: "suspended";
309
+ readonly interaction: DeepReadonly<AgentInteractionRequest>;
310
+ });
261
311
  type AgentRunErrorArgs = {
262
312
  readonly error: unknown;
263
313
  readonly usage: DeepReadonly<Usage>;
@@ -265,7 +315,7 @@ type AgentRunErrorArgs = {
265
315
  };
266
316
  type AgentGenerationModelInfo = {
267
317
  readonly provider: string;
268
- readonly defaultModel: string;
318
+ readonly modelId: string;
269
319
  readonly capabilities?: DeepReadonly<CompletionModelCapabilities> | undefined;
270
320
  };
271
321
  type AgentGenerationStartArgs = {
@@ -289,13 +339,13 @@ type AgentGenerationUpdateArgs = {
289
339
  };
290
340
  type AgentRunEventArgs = {
291
341
  readonly name: string;
292
- readonly attributes?: Readonly<Record<string, DeepReadonly<JsonValue> | undefined>> | undefined;
342
+ readonly attributes?: DeepReadonly<JsonObject> | undefined;
293
343
  readonly level?: "DEFAULT" | "WARNING" | "ERROR" | undefined;
294
- readonly timestamp?: Date | string | undefined;
344
+ readonly timestamp?: string | undefined;
295
345
  };
296
346
  type AgentToolStartArgs = {
297
347
  readonly turn: number;
298
- readonly toolCall: DeepReadonly<ToolCall>;
348
+ readonly toolCall: DeepReadonly<ToolCallPart>;
299
349
  readonly toolName: string;
300
350
  readonly args: string;
301
351
  readonly internalCallId: string;
@@ -305,12 +355,15 @@ type AgentToolStartArgs = {
305
355
  };
306
356
  type AgentToolEndArgs = AgentToolStartArgs & {
307
357
  readonly result: string;
308
- readonly structuredResult?: readonly DeepReadonly<ToolResultContent>[] | undefined;
358
+ readonly structuredResult?: readonly DeepReadonly<ToolResultContentPart>[] | undefined;
309
359
  readonly skipped: boolean;
310
360
  };
311
361
  type AgentToolErrorArgs = AgentToolStartArgs & {
312
362
  readonly error: unknown;
313
363
  };
364
+ type AgentToolSuspendedArgs = AgentToolStartArgs & {
365
+ readonly interaction: DeepReadonly<AgentInteractionRequest>;
366
+ };
314
367
  type AgentToolStreamEventArgs = AgentToolStartArgs & {
315
368
  readonly event: DeepReadonly<ToolCallStreamEvent>;
316
369
  };
@@ -322,10 +375,11 @@ interface AgentGenerationObserver {
322
375
  interface AgentToolObserver {
323
376
  streamEvent?(args: AgentToolStreamEventArgs): void | Promise<void>;
324
377
  end(args: AgentToolEndArgs): void | Promise<void>;
378
+ suspend?(args: AgentToolSuspendedArgs): void | Promise<void>;
325
379
  error?(args: AgentToolErrorArgs): void | Promise<void>;
326
380
  }
327
381
  interface AgentRunObserver {
328
- readonly trace?: AgentTraceInfo | undefined;
382
+ readonly trace?: AgentObserverTraceInfo | undefined;
329
383
  startGeneration?(args: AgentGenerationStartArgs): AgentGenerationObserver | undefined | Promise<AgentGenerationObserver | undefined>;
330
384
  startTool?(args: AgentToolStartArgs): AgentToolObserver | undefined | Promise<AgentToolObserver | undefined>;
331
385
  end(args: AgentRunEndArgs): void | Promise<void>;
@@ -334,16 +388,13 @@ interface AgentRunObserver {
334
388
  }
335
389
  interface AgentObserver {
336
390
  startRun(args: AgentRunStartArgs): AgentRunObserver | undefined | Promise<AgentRunObserver | undefined>;
337
- flush?(): void | Promise<void>;
338
- shutdown?(): void | Promise<void>;
339
391
  }
340
- type AgentObserverRegistration = {
341
- readonly observer: AgentObserver;
342
- readonly failOnObserverError?: boolean | undefined;
343
- };
344
- type ObserveOptions = {
345
- readonly failOnObserverError?: boolean | undefined;
392
+ type AgentObserverMap = Readonly<Record<string, AgentObserver>>;
393
+ type AgentObserverErrorPolicy = "ignore" | "throw";
394
+ type AgentObservabilityOptions<Observers extends AgentObserverMap = AgentObserverMap> = {
395
+ readonly observers: Observers;
396
+ readonly primaryTrace?: Extract<keyof Observers, string> | undefined;
397
+ readonly errorPolicy?: AgentObserverErrorPolicy | undefined;
346
398
  };
347
- declare function createObserver(observer: AgentObserver): AgentObserver;
348
399
 
349
- export { type AgentApprovalDecision as A, type AgentObserverRegistration as B, type AgentGenerationEndArgs as C, type AgentGenerationErrorArgs as D, type AgentGenerationModelInfo as E, type AgentGenerationObserver as F, type AgentGenerationStartArgs as G, type AgentGenerationUpdateArgs as H, type AgentRunEndArgs as I, type AgentRunErrorArgs as J, type AgentRunEventArgs as K, type AgentRunObserver as L, type AgentRunPromptRef as M, type AgentRunStartArgs as N, type ObserveOptions as O, type AgentToolEndArgs as P, type AgentToolErrorArgs as Q, type AgentToolObserver as R, type AgentToolStartArgs as S, type AgentToolStreamEventArgs as T, type AgentTraceInfo as U, type AgentTraceOptions as V, createObserver as W, type AgentApprovalRequiredEvent as a, type AgentApprovalRequiredResult as b, type AgentChildStreamEvent as c, type AgentChildStreamEventWithToolCallDeltas as d, type AgentChildStreamEventWithoutToolCallDeltas as e, type AgentDeltaEvent as f, type AgentErrorEvent as g, type AgentErrorStreamEvent as h, type AgentFinishEvent as i, type AgentInput as j, type AgentLifecycle as k, type AgentResponse as l, type AgentResult as m, type AgentRunOptions as n, type AgentStartEvent as o, type AgentStepFinishEvent as p, type AgentStream as q, type AgentStreamEvent as r, type AgentStreamEventWithToolCallDeltas as s, type AgentStreamEventWithoutToolCallDeltas as t, type AgentStreamOptions as u, type AgentToolApprovalRequest as v, type AgentToolCallDeltaEvent as w, type AgentToolFinishEvent as x, type AgentToolStartEvent as y, type AgentObserver as z };
400
+ export type { AgentBlockedResult as A, AgentGenerationObserver as B, AgentGenerationStartArgs as C, AgentGenerationUpdateArgs as D, AgentObservabilityOptions as E, AgentObserver as F, AgentObserverErrorPolicy as G, AgentObserverMap as H, AgentObserverTraceInfo as I, AgentRunEndArgs as J, AgentRunErrorArgs as K, AgentRunEventArgs as L, AgentRunObserver as M, AgentRunPromptRef as N, AgentRunStartArgs as O, AgentToolEndArgs as P, AgentToolErrorArgs as Q, AgentToolObserver as R, AgentToolStartArgs as S, AgentToolStreamEventArgs as T, AgentToolSuspendedArgs as U, AgentTraceInfo as V, AgentTraceOptions as W, AgentChildStreamEvent as a, AgentDeltaEvent as b, AgentErrorEvent as c, AgentErrorStreamEvent as d, AgentFinishEvent as e, AgentInput as f, AgentLifecycle as g, AgentMemoryCompactionEvent as h, AgentPrompt as i, AgentResponse as j, AgentResult as k, AgentRunOptions as l, AgentRunSettings as m, AgentStartEvent as n, AgentSteerInput as o, AgentSteerReceipt as p, AgentStepFinishEvent as q, AgentStream as r, AgentStreamEvent as s, AgentSuspendedResult as t, AgentToolCallDeltaEvent as u, AgentToolFinishEvent as v, AgentToolStartEvent as w, AgentGenerationEndArgs as x, AgentGenerationErrorArgs as y, AgentGenerationModelInfo as z };
@@ -0,0 +1,105 @@
1
+ import { M as Message, J as JsonObject, U as Usage } from './types-D9rKQ_as.js';
2
+ import { M as MaybePromise } from './type-utils-CtHVDRn_.js';
3
+
4
+ type GuardrailMode = "enforce" | "observe";
5
+ type GuardrailBoundary = "input" | "output";
6
+ type GuardrailRunContext = {
7
+ agentId: string;
8
+ runId: string;
9
+ sessionId?: string | undefined;
10
+ metadata?: JsonObject | undefined;
11
+ };
12
+ type GuardrailDecisionRecord = {
13
+ policyId: string;
14
+ guardrailId: string;
15
+ boundary: GuardrailBoundary;
16
+ mode: GuardrailMode;
17
+ action: GuardrailActionName;
18
+ applied: boolean;
19
+ reason?: string | undefined;
20
+ message?: string | undefined;
21
+ metadata?: JsonObject | undefined;
22
+ latencyMs: number;
23
+ };
24
+ type GuardrailActionName = "allow" | "block" | "rewrite" | "error";
25
+ type GuardrailActionBase = {
26
+ reason?: string | undefined;
27
+ metadata?: JsonObject | undefined;
28
+ };
29
+ type GuardrailAllow = GuardrailActionBase & {
30
+ action: "allow";
31
+ };
32
+ type GuardrailBlock = GuardrailActionBase & {
33
+ action: "block";
34
+ reason: string;
35
+ message?: string | undefined;
36
+ };
37
+ type InputGuardrailRewrite = GuardrailActionBase & {
38
+ action: "rewrite";
39
+ prompt?: Message | undefined;
40
+ inputText?: string | undefined;
41
+ };
42
+ type OutputGuardrailRewrite = GuardrailActionBase & {
43
+ action: "rewrite";
44
+ outputText: string;
45
+ };
46
+ type InputGuardrailResult = GuardrailAllow | GuardrailBlock | InputGuardrailRewrite;
47
+ type OutputGuardrailResult = GuardrailAllow | GuardrailBlock | OutputGuardrailRewrite;
48
+ type GuardrailCommonActions = {
49
+ allow(options?: GuardrailActionBase): GuardrailAllow;
50
+ block(options: Omit<GuardrailBlock, "action">): GuardrailBlock;
51
+ };
52
+ type InputGuardrailActions = GuardrailCommonActions & {
53
+ rewrite(options: Omit<InputGuardrailRewrite, "action">): InputGuardrailRewrite;
54
+ };
55
+ type OutputGuardrailActions = GuardrailCommonActions & {
56
+ rewrite(options: Omit<OutputGuardrailRewrite, "action">): OutputGuardrailRewrite;
57
+ };
58
+ type InputGuardrailContext = {
59
+ prompt: Message;
60
+ history: Message[];
61
+ inputText: string;
62
+ run: GuardrailRunContext;
63
+ };
64
+ type OutputGuardrailContext = {
65
+ outputText: string;
66
+ messages: Message[];
67
+ usage: Usage;
68
+ run: GuardrailRunContext;
69
+ };
70
+ type InputGuardrail = {
71
+ id: string;
72
+ check(context: InputGuardrailContext, actions: InputGuardrailActions): MaybePromise<InputGuardrailResult | undefined>;
73
+ };
74
+ type OutputGuardrail = {
75
+ id: string;
76
+ check(context: OutputGuardrailContext, actions: OutputGuardrailActions): MaybePromise<OutputGuardrailResult | undefined>;
77
+ };
78
+ type GuardrailPolicy = {
79
+ id: string;
80
+ mode: GuardrailMode;
81
+ input: InputGuardrail[];
82
+ output: OutputGuardrail[];
83
+ };
84
+ type GuardrailPolicyOptions = {
85
+ id: string;
86
+ mode?: GuardrailMode | undefined;
87
+ input?: InputGuardrail[] | undefined;
88
+ output?: OutputGuardrail[] | undefined;
89
+ };
90
+ type GuardrailPolicyInput = GuardrailPolicy | GuardrailPolicy[];
91
+ type InputGuardrailRunResult = {
92
+ prompt: Message;
93
+ inputText: string;
94
+ blocked: boolean;
95
+ message?: string | undefined;
96
+ decisions: GuardrailDecisionRecord[];
97
+ };
98
+ type OutputGuardrailRunResult = {
99
+ outputText: string;
100
+ blocked: boolean;
101
+ message?: string | undefined;
102
+ decisions: GuardrailDecisionRecord[];
103
+ };
104
+
105
+ export type { GuardrailBoundary as G, InputGuardrail as I, OutputGuardrail as O, GuardrailDecisionRecord as a, GuardrailMode as b, GuardrailPolicy as c, GuardrailPolicyInput as d, GuardrailPolicyOptions as e, InputGuardrailActions as f, InputGuardrailContext as g, OutputGuardrailActions as h, OutputGuardrailContext as i, InputGuardrailRunResult as j, OutputGuardrailRunResult as k, GuardrailActionBase as l, GuardrailActionName as m, GuardrailAllow as n, GuardrailBlock as o, GuardrailCommonActions as p, GuardrailRunContext as q, InputGuardrailResult as r, InputGuardrailRewrite as s, OutputGuardrailResult as t, OutputGuardrailRewrite as u };