@anvia/core 0.26.0 → 1.0.0-rc.10

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 (184) hide show
  1. package/README.md +400 -94
  2. package/dist/agent/index.d.ts +67 -71
  3. package/dist/agent/index.js +36 -18
  4. package/dist/agent/interactions/index.d.ts +122 -0
  5. package/dist/agent/interactions/index.js +20 -0
  6. package/dist/agent-DWzW9SoH.d.ts +150 -0
  7. package/dist/chunk-3RM57ZT2.js +31 -0
  8. package/dist/chunk-3RM57ZT2.js.map +1 -0
  9. package/dist/chunk-3RWESPUG.js +331 -0
  10. package/dist/chunk-3RWESPUG.js.map +1 -0
  11. package/dist/{chunk-NCPN4SJR.js → chunk-3SKZ2BKP.js} +15 -13
  12. package/dist/chunk-3SKZ2BKP.js.map +1 -0
  13. package/dist/chunk-3XQGVDU5.js +69 -0
  14. package/dist/chunk-3XQGVDU5.js.map +1 -0
  15. package/dist/{chunk-MRQLEK2B.js → chunk-5C6B6ZRH.js} +69 -51
  16. package/dist/chunk-5C6B6ZRH.js.map +1 -0
  17. package/dist/chunk-6BBOCFHV.js +323 -0
  18. package/dist/chunk-6BBOCFHV.js.map +1 -0
  19. package/dist/chunk-7JLAIN6E.js +15 -0
  20. package/dist/chunk-7JLAIN6E.js.map +1 -0
  21. package/dist/chunk-7PHMK7W4.js +1516 -0
  22. package/dist/chunk-7PHMK7W4.js.map +1 -0
  23. package/dist/{chunk-CWUJUSOS.js → chunk-AZB6N7P4.js} +94 -65
  24. package/dist/chunk-AZB6N7P4.js.map +1 -0
  25. package/dist/chunk-D4PACGPA.js +37 -0
  26. package/dist/chunk-D4PACGPA.js.map +1 -0
  27. package/dist/chunk-EFLT7XZD.js +51 -0
  28. package/dist/chunk-EFLT7XZD.js.map +1 -0
  29. package/dist/chunk-EMZKPRE6.js +667 -0
  30. package/dist/chunk-EMZKPRE6.js.map +1 -0
  31. package/dist/chunk-I3Q7XSBB.js +59 -0
  32. package/dist/chunk-I3Q7XSBB.js.map +1 -0
  33. package/dist/chunk-J6LVLV6P.js +13 -0
  34. package/dist/chunk-J6LVLV6P.js.map +1 -0
  35. package/dist/chunk-LTXABCOO.js +127 -0
  36. package/dist/chunk-LTXABCOO.js.map +1 -0
  37. package/dist/chunk-OJBFDBLG.js +164 -0
  38. package/dist/chunk-OJBFDBLG.js.map +1 -0
  39. package/dist/chunk-QGX73TSQ.js +177 -0
  40. package/dist/chunk-QGX73TSQ.js.map +1 -0
  41. package/dist/chunk-QOUPWOGW.js +29 -0
  42. package/dist/chunk-QOUPWOGW.js.map +1 -0
  43. package/dist/chunk-SJMSS5SI.js +171 -0
  44. package/dist/chunk-SJMSS5SI.js.map +1 -0
  45. package/dist/chunk-T2C3CGDQ.js +56 -0
  46. package/dist/chunk-T2C3CGDQ.js.map +1 -0
  47. package/dist/chunk-VX3HS6PE.js +4569 -0
  48. package/dist/chunk-VX3HS6PE.js.map +1 -0
  49. package/dist/chunk-X4LK4ODN.js +86 -0
  50. package/dist/chunk-X4LK4ODN.js.map +1 -0
  51. package/dist/chunk-ZA564323.js +331 -0
  52. package/dist/chunk-ZA564323.js.map +1 -0
  53. package/dist/completion/index.d.ts +6 -36
  54. package/dist/completion/index.js +34 -29
  55. package/dist/documents/index.d.ts +34 -0
  56. package/dist/documents/index.js +340 -0
  57. package/dist/documents/index.js.map +1 -0
  58. package/dist/dynamic-tools-aIZlg5x1.d.ts +45 -0
  59. package/dist/embeddings/index.d.ts +11 -9
  60. package/dist/embeddings/index.js +3 -4
  61. package/dist/evals/index.d.ts +57 -21
  62. package/dist/evals/index.js +209 -104
  63. package/dist/evals/index.js.map +1 -1
  64. package/dist/extractor/index.d.ts +27 -42
  65. package/dist/extractor/index.js +9 -22
  66. package/dist/guardrails/index.d.ts +7 -129
  67. package/dist/guardrails/index.js +1 -1
  68. package/dist/image-generation/index.d.ts +23 -23
  69. package/dist/image-generation/index.js +7 -39
  70. package/dist/image-generation/index.js.map +1 -1
  71. package/dist/index.d.ts +24 -22
  72. package/dist/index.js +85 -68
  73. package/dist/internal/agent.d.ts +156 -10
  74. package/dist/internal/agent.js +58 -18
  75. package/dist/internal/agent.js.map +1 -1
  76. package/dist/mcp/index.d.ts +7 -15
  77. package/dist/mcp/index.js +3 -348
  78. package/dist/mcp/index.js.map +1 -1
  79. package/dist/memory/index.d.ts +20 -6
  80. package/dist/memory/index.js +11 -10
  81. package/dist/middleware-kcF8AusP.d.ts +59 -0
  82. package/dist/model-call-options-CZkSw_xN.d.ts +6 -0
  83. package/dist/model-listing/index.d.ts +3 -1
  84. package/dist/observability/index.d.ts +23 -4
  85. package/dist/observability/index.js +10 -5
  86. package/dist/observability/index.js.map +1 -1
  87. package/dist/pipeline/index.d.ts +111 -73
  88. package/dist/pipeline/index.js +471 -286
  89. package/dist/pipeline/index.js.map +1 -1
  90. package/dist/provider-output-error-BEwDgVv3.d.ts +99 -0
  91. package/dist/retry-CjvSlKGW.d.ts +16 -0
  92. package/dist/skills/index.d.ts +5 -4
  93. package/dist/skills/index.js +8 -8
  94. package/dist/speech-generation/index.d.ts +37 -0
  95. package/dist/speech-generation/index.js +10 -0
  96. package/dist/streaming/index.js +37 -3
  97. package/dist/streaming/index.js.map +1 -1
  98. package/dist/text-ZLECpQE7.d.ts +32 -0
  99. package/dist/think-tool-BwCsJ365.d.ts +40 -0
  100. package/dist/tool/index.d.ts +11 -6
  101. package/dist/tool/index.js +21 -21
  102. package/dist/tool-BpqpoRSE.d.ts +58 -0
  103. package/dist/transcription/index.d.ts +29 -22
  104. package/dist/transcription/index.js +7 -57
  105. package/dist/transcription/index.js.map +1 -1
  106. package/dist/type-utils-CtHVDRn_.d.ts +6 -0
  107. package/dist/types-CXNE592e.d.ts +130 -0
  108. package/dist/types-Cr4uiYo5.d.ts +99 -0
  109. package/dist/{types-04LqWrmy.d.ts → types-DC1U1XwW.d.ts} +1 -1
  110. package/dist/types-DKOXVTcq.d.ts +155 -0
  111. package/dist/types-DgvozfPc.d.ts +349 -0
  112. package/dist/types-DhkodEft.d.ts +105 -0
  113. package/dist/types-DjqRHeAi.d.ts +31 -0
  114. package/dist/types-Sue2hb_L.d.ts +403 -0
  115. package/dist/vector-store/index.d.ts +34 -34
  116. package/dist/vector-store/index.js +10 -6
  117. package/package.json +22 -24
  118. package/dist/agent-x3YTyv5i.d.ts +0 -222
  119. package/dist/audio-generation/index.d.ts +0 -33
  120. package/dist/audio-generation/index.js +0 -42
  121. package/dist/audio-generation/index.js.map +0 -1
  122. package/dist/chunk-2ODTMRHP.js +0 -54
  123. package/dist/chunk-2ODTMRHP.js.map +0 -1
  124. package/dist/chunk-ADH7NNCS.js +0 -512
  125. package/dist/chunk-ADH7NNCS.js.map +0 -1
  126. package/dist/chunk-BALBBVI3.js +0 -2732
  127. package/dist/chunk-BALBBVI3.js.map +0 -1
  128. package/dist/chunk-CQNNSZPG.js +0 -9
  129. package/dist/chunk-CQNNSZPG.js.map +0 -1
  130. package/dist/chunk-CWUJUSOS.js.map +0 -1
  131. package/dist/chunk-DALYP4PX.js +0 -225
  132. package/dist/chunk-DALYP4PX.js.map +0 -1
  133. package/dist/chunk-HYUYZEAJ.js +0 -223
  134. package/dist/chunk-HYUYZEAJ.js.map +0 -1
  135. package/dist/chunk-I6XOQ4LK.js +0 -466
  136. package/dist/chunk-I6XOQ4LK.js.map +0 -1
  137. package/dist/chunk-JI5YZWNT.js +0 -220
  138. package/dist/chunk-JI5YZWNT.js.map +0 -1
  139. package/dist/chunk-MC3CCKEB.js +0 -221
  140. package/dist/chunk-MC3CCKEB.js.map +0 -1
  141. package/dist/chunk-MELYDKWQ.js +0 -337
  142. package/dist/chunk-MELYDKWQ.js.map +0 -1
  143. package/dist/chunk-MNWK2USR.js +0 -243
  144. package/dist/chunk-MNWK2USR.js.map +0 -1
  145. package/dist/chunk-MRQLEK2B.js.map +0 -1
  146. package/dist/chunk-NCPN4SJR.js.map +0 -1
  147. package/dist/chunk-OIMLU4SF.js +0 -20
  148. package/dist/chunk-OIMLU4SF.js.map +0 -1
  149. package/dist/chunk-Q25IWLBT.js +0 -138
  150. package/dist/chunk-Q25IWLBT.js.map +0 -1
  151. package/dist/chunk-UQX6EXWG.js +0 -33
  152. package/dist/chunk-UQX6EXWG.js.map +0 -1
  153. package/dist/chunk-WQKHFADH.js +0 -12
  154. package/dist/chunk-WQKHFADH.js.map +0 -1
  155. package/dist/chunk-XUUY2L2D.js +0 -42
  156. package/dist/chunk-XUUY2L2D.js.map +0 -1
  157. package/dist/chunk-XWUC7CIT.js +0 -1
  158. package/dist/chunk-XWUC7CIT.js.map +0 -1
  159. package/dist/chunk-YLMDBQO4.js +0 -141
  160. package/dist/chunk-YLMDBQO4.js.map +0 -1
  161. package/dist/errors-2moLDuuN.d.ts +0 -17
  162. package/dist/hooks/index.d.ts +0 -12
  163. package/dist/hooks/index.js +0 -17
  164. package/dist/index-BxSbmOMr.d.ts +0 -257
  165. package/dist/json-BVPssigK.d.ts +0 -39
  166. package/dist/loaders/index.d.ts +0 -91
  167. package/dist/loaders/index.js +0 -299
  168. package/dist/loaders/index.js.map +0 -1
  169. package/dist/middleware-Dp3d_pxi.d.ts +0 -90
  170. package/dist/request/index.d.ts +0 -28
  171. package/dist/request/index.js +0 -25
  172. package/dist/think-tool-DfCMuO8e.d.ts +0 -26
  173. package/dist/tool-Cohdv5GC.d.ts +0 -65
  174. package/dist/types-BCTRUGex.d.ts +0 -47
  175. package/dist/types-BrLbKnEz.d.ts +0 -119
  176. package/dist/types-D9JpeAPF.d.ts +0 -114
  177. package/dist/types-G12i56s2.d.ts +0 -354
  178. package/dist/types-JJCxRnaZ.d.ts +0 -70
  179. package/dist/types-O-abTIin.d.ts +0 -79
  180. package/dist/ui/index.d.ts +0 -107
  181. package/dist/ui/index.js +0 -10
  182. package/dist/ui/index.js.map +0 -1
  183. /package/dist/{hooks → agent/interactions}/index.js.map +0 -0
  184. /package/dist/{request → speech-generation}/index.js.map +0 -0
@@ -1,75 +1,71 @@
1
- import { D as DynamicContextOptions, b as DynamicToolOptions, c as AgentEventStore, d as AgentEventStoreOptions, A as Agent } from '../agent-x3YTyv5i.js';
2
- export { e as AgentEventAppendInput, f as AgentEventRecord, g as AgentEventStoreInclude, h as AgentSession, i as AgentToolOptions } from '../agent-x3YTyv5i.js';
3
- import { Z as ZodSchema } from '../zod-schema-C7F4clpm.js';
4
- import { C as CompletionModel, P as ProviderTool, l as JsonValue, L as ToolChoice } from '../types-G12i56s2.js';
5
- import { GuardrailPolicyInput } from '../guardrails/index.js';
6
- import { P as PromptHook } from '../types-D9JpeAPF.js';
7
- import { a as McpServer } from '../types-JJCxRnaZ.js';
8
- import { m as MemoryStore, n as MemoryOptions } from '../types-BrLbKnEz.js';
9
- import { i as AgentObserver, O as ObserveOptions } from '../index-BxSbmOMr.js';
10
- import { a as SkillSet } from '../types-04LqWrmy.js';
11
- import { i as ToolSearchDocument, j as ToolSet, A as AgentMiddleware } from '../middleware-Dp3d_pxi.js';
12
- import { A as AnyTool, e as ToolApprovalsOptions } from '../tool-Cohdv5GC.js';
13
- import { a as VectorSearchIndex } from '../types-O-abTIin.js';
1
+ export { M as ModelCallOptions } from '../model-call-options-CZkSw_xN.js';
2
+ export { R as RetryContext, a as RetryOptions, b as RetrySetting } from '../retry-CjvSlKGW.js';
3
+ export { A as Agent, a as AgentContextInput, b as AgentMemory, c as AgentMemoryOptions, d as AgentOptions, e as AgentToolInput, f as AgentToolOptions, C as CreateHybridVectorContextOptions, g as CreateVectorContextOptions, V as VectorContext, h as VectorContextBaseOptions, i as createVectorContext, j as isVectorContext } from '../agent-DWzW9SoH.js';
4
+ import { M as Message, U as Usage, C as CompletionFinishReason } from '../types-DgvozfPc.js';
5
+ import { A as AgentBlockedResult, t as AgentSuspendedResult } from '../types-Sue2hb_L.js';
6
+ export { a as AgentChildStreamEvent, b as AgentDeltaEvent, c as AgentErrorEvent, d as AgentErrorStreamEvent, e as AgentFinishEvent, f as AgentInput, g as AgentLifecycle, h as AgentMemoryCompactionEvent, i as AgentPrompt, j as AgentResponse, k as AgentResult, l as AgentRunOptions, m as AgentRunSettings, n as AgentStartEvent, o as AgentSteerInput, p as AgentSteerReceipt, q as AgentStepFinishEvent, r as AgentStream, s as AgentStreamEvent, u as AgentToolCallDeltaEvent, v as AgentToolFinishEvent, w as AgentToolStartEvent } from '../types-Sue2hb_L.js';
7
+ import '../zod-schema-C7F4clpm.js';
14
8
  import 'zod';
15
- import '@modelcontextprotocol/sdk/client/sse.js';
16
- import '@modelcontextprotocol/sdk/client/stdio.js';
17
- import '@modelcontextprotocol/sdk/client/streamableHttp.js';
18
- import '../types-BCTRUGex.js';
9
+ import '../types-DhkodEft.js';
10
+ import '../type-utils-CtHVDRn_.js';
11
+ import '../types-DjqRHeAi.js';
12
+ import '../tool-BpqpoRSE.js';
13
+ import '../middleware-kcF8AusP.js';
14
+ import '../types-DKOXVTcq.js';
15
+ import '../types-DC1U1XwW.js';
16
+ import '../dynamic-tools-aIZlg5x1.js';
17
+ import '../types-Cr4uiYo5.js';
18
+ import '../types-CXNE592e.js';
19
+ import './interactions/index.js';
19
20
 
20
- declare class AgentBuilder<M extends CompletionModel = CompletionModel> {
21
- private readonly completionModel;
22
- private readonly agentId;
23
- private agentName;
24
- private agentDescription;
25
- private instructionBlocks;
26
- private contextDocs;
27
- private temp;
28
- private maxTokenCount;
29
- private params;
30
- private choice;
31
- private turns;
32
- private requestHook;
33
- private schema;
34
- private approvalOptions;
35
- private guardrailPolicies;
36
- private skillInstructionBlocks;
37
- private observerRegistrations;
38
- private dynamicContextRegistrations;
39
- private dynamicToolRegistrations;
40
- private middlewareRegistrations;
41
- private memoryRegistration;
42
- private eventStoreRegistration;
43
- private activeToolSet;
44
- private providerToolDefs;
45
- constructor(agentId: string, completionModel: M);
46
- name(name: string): this;
47
- description(description: string): this;
48
- instructions(instructions: string): this;
49
- context(text: string, id?: string): this;
50
- dynamicContext<T>(index: VectorSearchIndex<T>, options: DynamicContextOptions<T>): this;
51
- dynamicTools(index: VectorSearchIndex<ToolSearchDocument>, options: DynamicToolOptions): this;
52
- tool(tool: AnyTool | ProviderTool): this;
53
- tools(tools: Array<AnyTool | ProviderTool>): this;
54
- mcp(servers: McpServer[]): this;
55
- skills(skillSet: SkillSet): this;
56
- useToolSet(toolSet: ToolSet): this;
57
- temperature(temperature: number): this;
58
- maxTokens(maxTokens: number): this;
59
- additionalParams(params: JsonValue): this;
60
- toolChoice(toolChoice: ToolChoice): this;
61
- defaultMaxTurns(defaultMaxTurns: number): this;
62
- hook(hook: PromptHook): this;
63
- middleware(middleware: AgentMiddleware): this;
64
- middlewares(middlewares: AgentMiddleware[]): this;
65
- observe(observer: AgentObserver, options?: ObserveOptions): this;
66
- approvals(options: ToolApprovalsOptions): this;
67
- guardrails(policies: GuardrailPolicyInput): this;
68
- memory(store: MemoryStore, options?: MemoryOptions): this;
69
- eventStore(store: AgentEventStore, options?: AgentEventStoreOptions): this;
70
- outputSchema(schema: ZodSchema): this;
71
- build(): Agent<M>;
72
- private buildInstructions;
21
+ type AgentStructuredOutputPhase = "truncated" | "content-filter" | "parse" | "schema";
22
+ type AgentStructuredOutputFormat = "raw" | "json-fence" | "unlabeled-fence";
23
+ declare class AgentStructuredOutputError extends Error {
24
+ readonly phase: AgentStructuredOutputPhase;
25
+ readonly attempt: number;
26
+ readonly maxAttempts: number;
27
+ readonly outputLength: number;
28
+ readonly normalizedLength: number;
29
+ readonly outputFormat: AgentStructuredOutputFormat;
30
+ readonly attemptUsage: Usage;
31
+ readonly usage: Usage;
32
+ readonly finishReason: CompletionFinishReason | undefined;
33
+ readonly providerFinishReason: string | undefined;
34
+ constructor(options: {
35
+ phase: AgentStructuredOutputPhase;
36
+ attempt: number;
37
+ maxAttempts: number;
38
+ outputLength: number;
39
+ normalizedLength: number;
40
+ outputFormat: AgentStructuredOutputFormat;
41
+ attemptUsage: Usage;
42
+ usage: Usage;
43
+ finishReason?: CompletionFinishReason | undefined;
44
+ providerFinishReason?: string | undefined;
45
+ cause?: unknown;
46
+ });
47
+ }
48
+ declare class MaxTurnsError extends Error {
49
+ readonly maxTurns: number;
50
+ readonly chatHistory: Message[];
51
+ readonly prompt: Message;
52
+ constructor(maxTurns: number, chatHistory: Message[], prompt: Message);
53
+ }
54
+ declare class AgentRunCancelledError extends Error {
55
+ readonly chatHistory: Message[];
56
+ readonly reason: string;
57
+ constructor(chatHistory: Message[], reason: string, options?: ErrorOptions);
58
+ }
59
+ declare class AgentRunBlockedError extends Error {
60
+ readonly result: AgentBlockedResult;
61
+ constructor(result: AgentBlockedResult);
62
+ }
63
+ declare class AgentStreamClosedError extends Error {
64
+ constructor();
65
+ }
66
+ declare class AgentToolSuspensionError extends Error {
67
+ readonly result: AgentSuspendedResult;
68
+ constructor(result: AgentSuspendedResult);
73
69
  }
74
70
 
75
- export { Agent, AgentBuilder, AgentEventStore, AgentEventStoreOptions, DynamicContextOptions, DynamicToolOptions };
71
+ export { AgentBlockedResult, AgentRunBlockedError, AgentRunCancelledError, AgentStreamClosedError, AgentStructuredOutputError, type AgentStructuredOutputFormat, type AgentStructuredOutputPhase, AgentSuspendedResult, AgentToolSuspensionError, MaxTurnsError };
@@ -1,23 +1,41 @@
1
1
  import {
2
- AgentBuilder
3
- } from "../chunk-JI5YZWNT.js";
4
- import "../chunk-DALYP4PX.js";
5
- import "../chunk-BALBBVI3.js";
2
+ Agent,
3
+ createVectorContext,
4
+ isVectorContext
5
+ } from "../chunk-VX3HS6PE.js";
6
+ import "../chunk-OJBFDBLG.js";
7
+ import "../chunk-J6LVLV6P.js";
8
+ import "../chunk-5C6B6ZRH.js";
9
+ import "../chunk-6BBOCFHV.js";
6
10
  import "../chunk-YK4WAAS4.js";
7
- import "../chunk-XUUY2L2D.js";
8
- import "../chunk-HYUYZEAJ.js";
9
- import "../chunk-MELYDKWQ.js";
10
- import "../chunk-2ODTMRHP.js";
11
- import "../chunk-UQX6EXWG.js";
12
- import "../chunk-MRQLEK2B.js";
13
- import "../chunk-MNWK2USR.js";
14
- import "../chunk-OIMLU4SF.js";
15
- import "../chunk-Q25IWLBT.js";
16
- import "../chunk-MC3CCKEB.js";
17
- import "../chunk-ADH7NNCS.js";
18
- import "../chunk-WQKHFADH.js";
19
- import "../chunk-CWUJUSOS.js";
11
+ import "../chunk-SJMSS5SI.js";
12
+ import "../chunk-EMZKPRE6.js";
13
+ import {
14
+ AgentRunBlockedError,
15
+ AgentRunCancelledError,
16
+ AgentStreamClosedError,
17
+ AgentStructuredOutputError,
18
+ AgentToolSuspensionError,
19
+ MaxTurnsError
20
+ } from "../chunk-X4LK4ODN.js";
21
+ import "../chunk-ZA564323.js";
22
+ import "../chunk-3RM57ZT2.js";
23
+ import "../chunk-D4PACGPA.js";
24
+ import "../chunk-7PHMK7W4.js";
25
+ import "../chunk-7JLAIN6E.js";
26
+ import "../chunk-QGX73TSQ.js";
27
+ import "../chunk-3XQGVDU5.js";
28
+ import "../chunk-3RWESPUG.js";
29
+ import "../chunk-AZB6N7P4.js";
20
30
  export {
21
- AgentBuilder
31
+ Agent,
32
+ AgentRunBlockedError,
33
+ AgentRunCancelledError,
34
+ AgentStreamClosedError,
35
+ AgentStructuredOutputError,
36
+ AgentToolSuspensionError,
37
+ MaxTurnsError,
38
+ createVectorContext,
39
+ isVectorContext
22
40
  };
23
41
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,122 @@
1
+ import { z } from 'zod';
2
+ import { p as JsonValue, J as JsonObject, $ as ToolQuestionAnswer } from '../../types-DgvozfPc.js';
3
+ import '../../model-call-options-CZkSw_xN.js';
4
+
5
+ type AgentQuestionChoice = Readonly<{
6
+ label: string;
7
+ value: string;
8
+ }>;
9
+ type AgentQuestionPrompt = Readonly<{
10
+ id: string;
11
+ text: string;
12
+ choices?: readonly AgentQuestionChoice[];
13
+ allowCustom?: boolean;
14
+ }>;
15
+ type AgentQuestionAnswer = ToolQuestionAnswer;
16
+ type AgentInteractionRequestBase = Readonly<{
17
+ id: string;
18
+ toolName: string;
19
+ toolCallId: string;
20
+ callId?: string;
21
+ internalCallId: string;
22
+ }>;
23
+ type AgentToolApprovalRequest = AgentInteractionRequestBase & Readonly<{
24
+ type: "tool-approval";
25
+ input: JsonValue;
26
+ reason?: string;
27
+ }>;
28
+ type AgentToolQuestionRequest = AgentInteractionRequestBase & Readonly<{
29
+ type: "tool-question";
30
+ questions: readonly AgentQuestionPrompt[];
31
+ }>;
32
+ type AgentInteractionRequest = AgentToolApprovalRequest | AgentToolQuestionRequest;
33
+ type AgentInteractionResponse = Readonly<{
34
+ type: "tool-approval";
35
+ approved: boolean;
36
+ reason?: string;
37
+ }> | Readonly<{
38
+ type: "tool-question";
39
+ answers: readonly AgentQuestionAnswer[];
40
+ }>;
41
+ type AgentContinuation = Readonly<{
42
+ version: 1;
43
+ agentId: string;
44
+ sourceRunId: string;
45
+ interaction: AgentInteractionRequest;
46
+ state: JsonObject;
47
+ }>;
48
+ declare const agentInteractionRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
49
+ input: z.ZodCustom<JsonValue, JsonValue>;
50
+ reason: z.ZodOptional<z.ZodString>;
51
+ id: z.ZodString;
52
+ toolName: z.ZodString;
53
+ toolCallId: z.ZodString;
54
+ callId: z.ZodOptional<z.ZodString>;
55
+ internalCallId: z.ZodString;
56
+ type: z.ZodLiteral<"tool-approval">;
57
+ }, z.core.$strict>, z.ZodObject<{
58
+ questions: z.ZodArray<z.ZodObject<{
59
+ id: z.ZodString;
60
+ text: z.ZodString;
61
+ choices: z.ZodOptional<z.ZodArray<z.ZodObject<{
62
+ label: z.ZodString;
63
+ value: z.ZodString;
64
+ }, z.core.$strict>>>;
65
+ allowCustom: z.ZodOptional<z.ZodBoolean>;
66
+ }, z.core.$strict>>;
67
+ id: z.ZodString;
68
+ toolName: z.ZodString;
69
+ toolCallId: z.ZodString;
70
+ callId: z.ZodOptional<z.ZodString>;
71
+ internalCallId: z.ZodString;
72
+ type: z.ZodLiteral<"tool-question">;
73
+ }, z.core.$strict>], "type">;
74
+ declare const agentInteractionResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
75
+ type: z.ZodLiteral<"tool-approval">;
76
+ approved: z.ZodBoolean;
77
+ reason: z.ZodOptional<z.ZodString>;
78
+ }, z.core.$strict>, z.ZodObject<{
79
+ type: z.ZodLiteral<"tool-question">;
80
+ answers: z.ZodArray<z.ZodObject<{
81
+ questionId: z.ZodString;
82
+ value: z.ZodString;
83
+ }, z.core.$strict>>;
84
+ }, z.core.$strict>], "type">;
85
+ declare const agentContinuationSchema: z.ZodObject<{
86
+ version: z.ZodLiteral<1>;
87
+ agentId: z.ZodString;
88
+ sourceRunId: z.ZodString;
89
+ interaction: z.ZodDiscriminatedUnion<[z.ZodObject<{
90
+ input: z.ZodCustom<JsonValue, JsonValue>;
91
+ reason: z.ZodOptional<z.ZodString>;
92
+ id: z.ZodString;
93
+ toolName: z.ZodString;
94
+ toolCallId: z.ZodString;
95
+ callId: z.ZodOptional<z.ZodString>;
96
+ internalCallId: z.ZodString;
97
+ type: z.ZodLiteral<"tool-approval">;
98
+ }, z.core.$strict>, z.ZodObject<{
99
+ questions: z.ZodArray<z.ZodObject<{
100
+ id: z.ZodString;
101
+ text: z.ZodString;
102
+ choices: z.ZodOptional<z.ZodArray<z.ZodObject<{
103
+ label: z.ZodString;
104
+ value: z.ZodString;
105
+ }, z.core.$strict>>>;
106
+ allowCustom: z.ZodOptional<z.ZodBoolean>;
107
+ }, z.core.$strict>>;
108
+ id: z.ZodString;
109
+ toolName: z.ZodString;
110
+ toolCallId: z.ZodString;
111
+ callId: z.ZodOptional<z.ZodString>;
112
+ internalCallId: z.ZodString;
113
+ type: z.ZodLiteral<"tool-question">;
114
+ }, z.core.$strict>], "type">;
115
+ state: z.ZodCustom<JsonObject, JsonObject>;
116
+ }, z.core.$strict>;
117
+ declare function parseAgentInteractionRequest(value: unknown): AgentInteractionRequest;
118
+ declare function parseAgentInteractionResponse(value: unknown): AgentInteractionResponse;
119
+ declare function parseAgentContinuation(value: unknown): AgentContinuation;
120
+ declare function assertAgentInteractionResponse(request: AgentInteractionRequest, response: AgentInteractionResponse): void;
121
+
122
+ export { type AgentContinuation, type AgentInteractionRequest, type AgentInteractionResponse, type AgentQuestionAnswer, type AgentQuestionChoice, type AgentQuestionPrompt, type AgentToolApprovalRequest, type AgentToolQuestionRequest, agentContinuationSchema, agentInteractionRequestSchema, agentInteractionResponseSchema, assertAgentInteractionResponse, parseAgentContinuation, parseAgentInteractionRequest, parseAgentInteractionResponse };
@@ -0,0 +1,20 @@
1
+ import {
2
+ agentContinuationSchema,
3
+ agentInteractionRequestSchema,
4
+ agentInteractionResponseSchema,
5
+ assertAgentInteractionResponse,
6
+ parseAgentContinuation,
7
+ parseAgentInteractionRequest,
8
+ parseAgentInteractionResponse
9
+ } from "../../chunk-OJBFDBLG.js";
10
+ import "../../chunk-3XQGVDU5.js";
11
+ export {
12
+ agentContinuationSchema,
13
+ agentInteractionRequestSchema,
14
+ agentInteractionResponseSchema,
15
+ assertAgentInteractionResponse,
16
+ parseAgentContinuation,
17
+ parseAgentInteractionRequest,
18
+ parseAgentInteractionResponse
19
+ };
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,150 @@
1
+ import { b as RetrySetting } from './retry-CjvSlKGW.js';
2
+ import { D as Document, c as CompletionModel, P as ProviderTool, J as JsonObject, v as ToolChoice } from './types-DgvozfPc.js';
3
+ import { Z as ZodSchema } from './zod-schema-C7F4clpm.js';
4
+ import { d as GuardrailPolicyInput, c as GuardrailPolicy } from './types-DhkodEft.js';
5
+ import { a as McpServer } from './types-DjqRHeAi.js';
6
+ import { g as AgentLifecycle, E as AgentObservabilityOptions, l as AgentRunOptions, k as AgentResult, r as AgentStream, s as AgentStreamEvent } from './types-Sue2hb_L.js';
7
+ import { A as AgentMiddleware } from './middleware-kcF8AusP.js';
8
+ import { A as AnyTool, T as Tool, c as ToolCallContext, N as NormalizedToolOutput } from './tool-BpqpoRSE.js';
9
+ import { D as MemoryStore, y as MemorySavePolicy, m as MemoryCompactor, d as MemoryCompactionConflictRetryOptions, x as MemoryOptions } from './types-DKOXVTcq.js';
10
+ import { a as SkillSet } from './types-DC1U1XwW.js';
11
+ import { T as ToolIndex } from './dynamic-tools-aIZlg5x1.js';
12
+ import { E as EmbeddingModel, c as SparseEmbeddingModel } from './types-Cr4uiYo5.js';
13
+ import { V as VectorFilter, a as VectorSearchResult, d as VectorStore, H as HybridVectorStore, e as VectorFusion } from './types-CXNE592e.js';
14
+
15
+ type VectorContextBaseOptions<T = unknown> = {
16
+ topK: number;
17
+ minScore?: number | undefined;
18
+ filter?: VectorFilter | undefined;
19
+ retries?: RetrySetting | undefined;
20
+ format?(result: VectorSearchResult<T>): Document;
21
+ };
22
+ type CreateVectorContextOptions<T = unknown> = VectorContextBaseOptions<T> & {
23
+ store: VectorStore<T>;
24
+ model: EmbeddingModel;
25
+ models?: never;
26
+ };
27
+ type CreateHybridVectorContextOptions<T = unknown> = VectorContextBaseOptions<T> & {
28
+ store: HybridVectorStore<T>;
29
+ model?: never;
30
+ models: {
31
+ dense: EmbeddingModel;
32
+ sparse: SparseEmbeddingModel;
33
+ };
34
+ fusion?: VectorFusion | undefined;
35
+ };
36
+ type VectorContext<T = unknown> = (CreateVectorContextOptions<T> | CreateHybridVectorContextOptions<T>) & {
37
+ readonly kind: "vector-context";
38
+ };
39
+ declare function createVectorContext<T>(options: CreateVectorContextOptions<T>): VectorContext<T>;
40
+ declare function createVectorContext<T>(options: CreateHybridVectorContextOptions<T>): VectorContext<T>;
41
+ declare function isVectorContext(value: unknown): value is VectorContext;
42
+
43
+ type AgentToolInput = AnyTool | ProviderTool | ToolIndex;
44
+ type AgentContextInput<T = unknown> = Document | VectorContext<T>;
45
+ type RawResponseOf$1<Model> = Model extends CompletionModel<infer RawResponse> ? RawResponse : unknown;
46
+ type AgentOptions<Output = string, M extends CompletionModel = CompletionModel, ContextDocument = unknown> = {
47
+ id: string;
48
+ name?: string | undefined;
49
+ description?: string | undefined;
50
+ model: M;
51
+ instructions?: string | undefined;
52
+ context?: readonly AgentContextInput<ContextDocument>[] | undefined;
53
+ tools?: readonly AgentToolInput[] | undefined;
54
+ mcpServers?: readonly McpServer[] | undefined;
55
+ skills?: SkillSet | undefined;
56
+ temperature?: number | undefined;
57
+ maxTokens?: number | undefined;
58
+ providerOptions?: JsonObject | undefined;
59
+ retries?: RetrySetting | undefined;
60
+ toolChoice?: ToolChoice | undefined;
61
+ maxTurns?: number | undefined;
62
+ lifecycle?: AgentLifecycle<Output, RawResponseOf$1<M>> | undefined;
63
+ outputSchema?: ZodSchema<Output> | undefined;
64
+ observability?: AgentObservabilityOptions | undefined;
65
+ guardrails?: GuardrailPolicyInput | undefined;
66
+ middlewares?: readonly AgentMiddleware[] | undefined;
67
+ memory?: AgentMemoryOptions | undefined;
68
+ };
69
+ type AgentMemoryOptions = MemoryOptions & {
70
+ store: MemoryStore;
71
+ };
72
+ type AgentMemory = {
73
+ store: MemoryStore;
74
+ savePolicy: MemorySavePolicy;
75
+ compaction?: {
76
+ trigger: {
77
+ afterMessages: number;
78
+ };
79
+ retention: {
80
+ recentUserTurns: number;
81
+ };
82
+ compactor: MemoryCompactor;
83
+ conflictRetries: false | MemoryCompactionConflictRetryOptions;
84
+ } | undefined;
85
+ };
86
+ type ResolvedAgentOptions<Output = string, M extends CompletionModel = CompletionModel, ContextDocument = unknown> = {
87
+ id: string;
88
+ name?: string | undefined;
89
+ description?: string | undefined;
90
+ model: M;
91
+ instructions?: string | undefined;
92
+ context?: readonly AgentContextInput<ContextDocument>[] | undefined;
93
+ temperature?: number | undefined;
94
+ maxTokens?: number | undefined;
95
+ providerOptions?: JsonObject | undefined;
96
+ retries?: RetrySetting | undefined;
97
+ tools?: readonly AnyTool[] | undefined;
98
+ mcpServers?: readonly McpServer[] | undefined;
99
+ providerTools?: readonly ProviderTool[] | undefined;
100
+ toolIndexes?: readonly ToolIndex[] | undefined;
101
+ toolChoice?: ToolChoice | undefined;
102
+ defaultMaxTurns?: number | undefined;
103
+ lifecycle?: AgentLifecycle<Output, RawResponseOf$1<M>> | undefined;
104
+ outputSchema?: ZodSchema<Output> | undefined;
105
+ observability?: AgentObservabilityOptions | undefined;
106
+ guardrails?: readonly GuardrailPolicy[] | undefined;
107
+ middlewares?: readonly AgentMiddleware[] | undefined;
108
+ memory?: AgentMemory | undefined;
109
+ };
110
+ type AgentToolOptions = {
111
+ name: string;
112
+ suspension: "reject";
113
+ description?: string | undefined;
114
+ maxTurns?: number | undefined;
115
+ stream?: boolean | undefined;
116
+ };
117
+
118
+ type RawResponseOf<Model> = Model extends CompletionModel<infer RawResponse> ? RawResponse : unknown;
119
+ declare class Agent<Output = string, M extends CompletionModel = CompletionModel, ContextDocument = unknown> {
120
+ readonly id: string;
121
+ readonly name: string | undefined;
122
+ readonly description: string | undefined;
123
+ readonly model: M;
124
+ readonly instructions: string | undefined;
125
+ readonly context: readonly AgentContextInput<ContextDocument>[];
126
+ readonly temperature: number | undefined;
127
+ readonly maxTokens: number | undefined;
128
+ readonly providerOptions: JsonObject | undefined;
129
+ readonly retries: RetrySetting | undefined;
130
+ readonly mcpServers: readonly McpServer[];
131
+ readonly tools: readonly AnyTool[];
132
+ readonly toolChoice: ToolChoice | undefined;
133
+ readonly defaultMaxTurns: number | undefined;
134
+ readonly lifecycle: AgentLifecycle<Output, RawResponseOf<M>> | undefined;
135
+ readonly outputSchema: ZodSchema<Output> | undefined;
136
+ readonly observability: AgentObservabilityOptions | undefined;
137
+ readonly guardrails: readonly GuardrailPolicy[];
138
+ readonly middlewares: readonly AgentMiddleware[];
139
+ readonly memory: AgentMemory | undefined;
140
+ constructor(options: AgentOptions<Output, M, ContextDocument>);
141
+ generate(options: AgentRunOptions<Output, RawResponseOf<M>>): Promise<AgentResult<Output>>;
142
+ stream(options: AgentRunOptions<Output, RawResponseOf<M>>): AgentStream<AgentStreamEvent<Output, RawResponseOf<M>>>;
143
+ asTool(options: AgentToolOptions): Tool<{
144
+ prompt: string;
145
+ }, Output>;
146
+ getTool(toolName: string): AnyTool | undefined;
147
+ callTool(toolName: string, args: string, context?: ToolCallContext): Promise<NormalizedToolOutput>;
148
+ }
149
+
150
+ export { Agent as A, type CreateHybridVectorContextOptions as C, type ResolvedAgentOptions as R, type VectorContext as V, type AgentContextInput as a, type AgentMemory as b, type AgentMemoryOptions as c, type AgentOptions as d, type AgentToolInput as e, type AgentToolOptions as f, type CreateVectorContextOptions as g, type VectorContextBaseOptions as h, createVectorContext as i, isVectorContext as j };
@@ -0,0 +1,31 @@
1
+ // src/internal/concurrency.ts
2
+ async function mapWithConcurrency(inputs, concurrency, mapper) {
3
+ if (!Number.isSafeInteger(concurrency) || concurrency <= 0) {
4
+ throw new RangeError("concurrency must be a positive safe integer.");
5
+ }
6
+ const limit = concurrency;
7
+ const results = new Array(inputs.length);
8
+ let nextIndex = 0;
9
+ let firstFailure;
10
+ async function worker() {
11
+ while (firstFailure === void 0 && nextIndex < inputs.length) {
12
+ const index = nextIndex;
13
+ nextIndex += 1;
14
+ try {
15
+ results[index] = await mapper(inputs[index]);
16
+ } catch (error) {
17
+ firstFailure ??= { error };
18
+ }
19
+ }
20
+ }
21
+ await Promise.all(Array.from({ length: Math.min(limit, inputs.length) }, () => worker()));
22
+ if (firstFailure !== void 0) {
23
+ throw firstFailure.error;
24
+ }
25
+ return results;
26
+ }
27
+
28
+ export {
29
+ mapWithConcurrency
30
+ };
31
+ //# sourceMappingURL=chunk-3RM57ZT2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal/concurrency.ts"],"sourcesContent":["export async function mapWithConcurrency<Input, Output>(\n inputs: readonly Input[],\n concurrency: number,\n mapper: (input: Input) => Promise<Output>,\n): Promise<Output[]> {\n if (!Number.isSafeInteger(concurrency) || concurrency <= 0) {\n throw new RangeError(\"concurrency must be a positive safe integer.\");\n }\n const limit = concurrency;\n const results = new Array<Output>(inputs.length);\n let nextIndex = 0;\n let firstFailure: { error: unknown } | undefined;\n\n async function worker(): Promise<void> {\n while (firstFailure === undefined && nextIndex < inputs.length) {\n const index = nextIndex;\n nextIndex += 1;\n try {\n results[index] = await mapper(inputs[index] as Input);\n } catch (error) {\n firstFailure ??= { error };\n }\n }\n }\n\n await Promise.all(Array.from({ length: Math.min(limit, inputs.length) }, () => worker()));\n if (firstFailure !== undefined) {\n throw firstFailure.error;\n }\n return results;\n}\n"],"mappings":";AAAA,eAAsB,mBACpB,QACA,aACA,QACmB;AACnB,MAAI,CAAC,OAAO,cAAc,WAAW,KAAK,eAAe,GAAG;AAC1D,UAAM,IAAI,WAAW,8CAA8C;AAAA,EACrE;AACA,QAAM,QAAQ;AACd,QAAM,UAAU,IAAI,MAAc,OAAO,MAAM;AAC/C,MAAI,YAAY;AAChB,MAAI;AAEJ,iBAAe,SAAwB;AACrC,WAAO,iBAAiB,UAAa,YAAY,OAAO,QAAQ;AAC9D,YAAM,QAAQ;AACd,mBAAa;AACb,UAAI;AACF,gBAAQ,KAAK,IAAI,MAAM,OAAO,OAAO,KAAK,CAAU;AAAA,MACtD,SAAS,OAAO;AACd,yBAAiB,EAAE,MAAM;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AAEA,QAAM,QAAQ,IAAI,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,OAAO,OAAO,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,CAAC;AACxF,MAAI,iBAAiB,QAAW;AAC9B,UAAM,aAAa;AAAA,EACrB;AACA,SAAO;AACT;","names":[]}