@anvia/core 0.26.0 → 1.0.0-rc.1

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 (135) hide show
  1. package/README.md +21 -11
  2. package/dist/agent/index.d.ts +26 -68
  3. package/dist/agent/index.js +20 -17
  4. package/dist/agent-DGYY_onS.d.ts +145 -0
  5. package/dist/audio-generation/index.d.ts +12 -14
  6. package/dist/audio-generation/index.js +5 -39
  7. package/dist/audio-generation/index.js.map +1 -1
  8. package/dist/{chunk-MRQLEK2B.js → chunk-5XKDW36Z.js} +30 -7
  9. package/dist/chunk-5XKDW36Z.js.map +1 -0
  10. package/dist/chunk-6WGGTJE6.js +139 -0
  11. package/dist/chunk-6WGGTJE6.js.map +1 -0
  12. package/dist/chunk-A3UBYTJT.js +157 -0
  13. package/dist/chunk-A3UBYTJT.js.map +1 -0
  14. package/dist/{chunk-NCPN4SJR.js → chunk-DMPUP4R3.js} +10 -10
  15. package/dist/chunk-DMPUP4R3.js.map +1 -0
  16. package/dist/{chunk-MNWK2USR.js → chunk-DZ3CKYTH.js} +29 -5
  17. package/dist/chunk-DZ3CKYTH.js.map +1 -0
  18. package/dist/{chunk-CWUJUSOS.js → chunk-FNQB2JEH.js} +1 -1
  19. package/dist/chunk-FNQB2JEH.js.map +1 -0
  20. package/dist/chunk-I6G7BC42.js +41 -0
  21. package/dist/chunk-I6G7BC42.js.map +1 -0
  22. package/dist/{chunk-BALBBVI3.js → chunk-IL3ZSNJI.js} +2720 -1704
  23. package/dist/chunk-IL3ZSNJI.js.map +1 -0
  24. package/dist/chunk-J6GNQART.js +122 -0
  25. package/dist/chunk-J6GNQART.js.map +1 -0
  26. package/dist/{chunk-MC3CCKEB.js → chunk-M3IOWB4Y.js} +124 -65
  27. package/dist/chunk-M3IOWB4Y.js.map +1 -0
  28. package/dist/chunk-QY5GZ7HR.js +39 -0
  29. package/dist/chunk-QY5GZ7HR.js.map +1 -0
  30. package/dist/{chunk-MELYDKWQ.js → chunk-R2LJSQUW.js} +190 -20
  31. package/dist/chunk-R2LJSQUW.js.map +1 -0
  32. package/dist/{chunk-WQKHFADH.js → chunk-RFDVKCIE.js} +3 -3
  33. package/dist/chunk-RFDVKCIE.js.map +1 -0
  34. package/dist/chunk-RMUBRRSK.js +34 -0
  35. package/dist/chunk-RMUBRRSK.js.map +1 -0
  36. package/dist/{chunk-I6XOQ4LK.js → chunk-RXKHOYEH.js} +1 -1
  37. package/dist/chunk-RXKHOYEH.js.map +1 -0
  38. package/dist/chunk-XDRSPSR7.js +38 -0
  39. package/dist/chunk-XDRSPSR7.js.map +1 -0
  40. package/dist/completion/index.d.ts +5 -36
  41. package/dist/completion/index.js +4 -5
  42. package/dist/dynamic-tools-i9woysFa.d.ts +33 -0
  43. package/dist/embeddings/index.d.ts +2 -2
  44. package/dist/embeddings/index.js +1 -2
  45. package/dist/{errors-2moLDuuN.d.ts → errors-CYKUcU89.d.ts} +2 -2
  46. package/dist/evals/index.d.ts +22 -15
  47. package/dist/evals/index.js +57 -35
  48. package/dist/evals/index.js.map +1 -1
  49. package/dist/extractor/index.d.ts +23 -35
  50. package/dist/extractor/index.js +7 -21
  51. package/dist/guardrails/index.d.ts +2 -2
  52. package/dist/guardrails/index.js +1 -1
  53. package/dist/image-generation/index.d.ts +12 -14
  54. package/dist/image-generation/index.js +5 -39
  55. package/dist/image-generation/index.js.map +1 -1
  56. package/dist/index-DxB74ybJ.d.ts +349 -0
  57. package/dist/index.d.ts +20 -17
  58. package/dist/index.js +31 -36
  59. package/dist/internal/agent.d.ts +152 -9
  60. package/dist/internal/agent.js +22 -17
  61. package/dist/{json-BVPssigK.d.ts → json-Zo7K3xmt.d.ts} +12 -11
  62. package/dist/loaders/index.d.ts +5 -10
  63. package/dist/loaders/index.js.map +1 -1
  64. package/dist/mcp/index.d.ts +4 -4
  65. package/dist/mcp/index.js.map +1 -1
  66. package/dist/memory/index.d.ts +4 -4
  67. package/dist/memory/index.js +6 -7
  68. package/dist/middleware-KynLg_RW.d.ts +56 -0
  69. package/dist/observability/index.d.ts +6 -3
  70. package/dist/observability/index.js.map +1 -1
  71. package/dist/pipeline/index.d.ts +40 -47
  72. package/dist/pipeline/index.js +99 -99
  73. package/dist/pipeline/index.js.map +1 -1
  74. package/dist/retry-D3Ruy-ba.d.ts +15 -0
  75. package/dist/skills/index.d.ts +4 -4
  76. package/dist/skills/index.js +5 -6
  77. package/dist/streaming/index.js +37 -3
  78. package/dist/streaming/index.js.map +1 -1
  79. package/dist/{think-tool-DfCMuO8e.d.ts → think-tool-DZqZj2LV.d.ts} +5 -5
  80. package/dist/tool/index.d.ts +8 -6
  81. package/dist/tool/index.js +12 -15
  82. package/dist/tool-C_8GudXn.d.ts +49 -0
  83. package/dist/transcription/index.d.ts +14 -16
  84. package/dist/transcription/index.js +5 -57
  85. package/dist/transcription/index.js.map +1 -1
  86. package/dist/type-utils-CtHVDRn_.d.ts +6 -0
  87. package/dist/{types-G12i56s2.d.ts → types-B3A4YxaA.d.ts} +1 -1
  88. package/dist/{types-BrLbKnEz.d.ts → types-BBEGKB9m.d.ts} +1 -1
  89. package/dist/{types-O-abTIin.d.ts → types-DT3nEemY.d.ts} +3 -3
  90. package/dist/{types-04LqWrmy.d.ts → types-DhQfwiZn.d.ts} +1 -1
  91. package/dist/{types-JJCxRnaZ.d.ts → types-DulRCYdB.d.ts} +2 -2
  92. package/dist/{types-BCTRUGex.d.ts → types-p55Jc-sr.d.ts} +1 -1
  93. package/dist/ui/index.d.ts +1 -1
  94. package/dist/ui/index.js +1 -1
  95. package/dist/vector-store/index.d.ts +5 -5
  96. package/dist/vector-store/index.js +4 -4
  97. package/package.json +2 -10
  98. package/dist/agent-x3YTyv5i.d.ts +0 -222
  99. package/dist/chunk-2ODTMRHP.js +0 -54
  100. package/dist/chunk-2ODTMRHP.js.map +0 -1
  101. package/dist/chunk-BALBBVI3.js.map +0 -1
  102. package/dist/chunk-CWUJUSOS.js.map +0 -1
  103. package/dist/chunk-DALYP4PX.js +0 -225
  104. package/dist/chunk-DALYP4PX.js.map +0 -1
  105. package/dist/chunk-HYUYZEAJ.js +0 -223
  106. package/dist/chunk-HYUYZEAJ.js.map +0 -1
  107. package/dist/chunk-I6XOQ4LK.js.map +0 -1
  108. package/dist/chunk-JI5YZWNT.js +0 -220
  109. package/dist/chunk-JI5YZWNT.js.map +0 -1
  110. package/dist/chunk-MC3CCKEB.js.map +0 -1
  111. package/dist/chunk-MELYDKWQ.js.map +0 -1
  112. package/dist/chunk-MNWK2USR.js.map +0 -1
  113. package/dist/chunk-MRQLEK2B.js.map +0 -1
  114. package/dist/chunk-NCPN4SJR.js.map +0 -1
  115. package/dist/chunk-OIMLU4SF.js +0 -20
  116. package/dist/chunk-OIMLU4SF.js.map +0 -1
  117. package/dist/chunk-Q25IWLBT.js +0 -138
  118. package/dist/chunk-Q25IWLBT.js.map +0 -1
  119. package/dist/chunk-UQX6EXWG.js +0 -33
  120. package/dist/chunk-UQX6EXWG.js.map +0 -1
  121. package/dist/chunk-WQKHFADH.js.map +0 -1
  122. package/dist/chunk-XUUY2L2D.js +0 -42
  123. package/dist/chunk-XUUY2L2D.js.map +0 -1
  124. package/dist/chunk-YLMDBQO4.js +0 -141
  125. package/dist/chunk-YLMDBQO4.js.map +0 -1
  126. package/dist/hooks/index.d.ts +0 -12
  127. package/dist/hooks/index.js +0 -17
  128. package/dist/hooks/index.js.map +0 -1
  129. package/dist/index-BxSbmOMr.d.ts +0 -257
  130. package/dist/middleware-Dp3d_pxi.d.ts +0 -90
  131. package/dist/request/index.d.ts +0 -28
  132. package/dist/request/index.js +0 -25
  133. package/dist/request/index.js.map +0 -1
  134. package/dist/tool-Cohdv5GC.d.ts +0 -65
  135. package/dist/types-D9JpeAPF.d.ts +0 -114
package/dist/index.js CHANGED
@@ -2,54 +2,51 @@ import {
2
2
  SkillValidationError,
3
3
  loadSkills,
4
4
  skill
5
- } from "./chunk-NCPN4SJR.js";
5
+ } from "./chunk-DMPUP4R3.js";
6
+ import {
7
+ transcribe
8
+ } from "./chunk-QY5GZ7HR.js";
6
9
  import {
7
10
  coreMessagesToUIMessages,
8
11
  uiMessagesToCoreMessages
9
- } from "./chunk-I6XOQ4LK.js";
12
+ } from "./chunk-RXKHOYEH.js";
13
+ import {
14
+ generateImage
15
+ } from "./chunk-XDRSPSR7.js";
10
16
  import "./chunk-CQNNSZPG.js";
11
17
  import "./chunk-XWUC7CIT.js";
12
18
  import {
13
- AgentBuilder
14
- } from "./chunk-JI5YZWNT.js";
15
- import "./chunk-DALYP4PX.js";
19
+ generateSpeech
20
+ } from "./chunk-RMUBRRSK.js";
16
21
  import {
22
+ Agent,
23
+ AgentRunCancelledError,
17
24
  MaxTurnsError,
18
- PromptCancelledError,
19
- ToolApprovalRequiredError
20
- } from "./chunk-BALBBVI3.js";
25
+ createContextIndex,
26
+ isContextIndex
27
+ } from "./chunk-IL3ZSNJI.js";
21
28
  import "./chunk-YK4WAAS4.js";
22
- import "./chunk-XUUY2L2D.js";
23
29
  import {
24
30
  createMiddleware,
25
31
  createThinkTool
26
- } from "./chunk-HYUYZEAJ.js";
32
+ } from "./chunk-6WGGTJE6.js";
27
33
  import {
28
34
  createTool
29
- } from "./chunk-MELYDKWQ.js";
30
- import {
31
- cancelPrompt,
32
- createHook,
33
- requestToolApproval,
34
- runControl,
35
- skipTool,
36
- toolCallControl
37
- } from "./chunk-2ODTMRHP.js";
38
- import "./chunk-UQX6EXWG.js";
35
+ } from "./chunk-R2LJSQUW.js";
39
36
  import {
40
37
  MemoryCompactionConflictError,
41
38
  MemoryCompactionError,
42
39
  createSummaryMemoryCompactor,
43
40
  isMemoryCompactionSummary
44
- } from "./chunk-MRQLEK2B.js";
45
- import "./chunk-MNWK2USR.js";
46
- import "./chunk-OIMLU4SF.js";
47
- import "./chunk-Q25IWLBT.js";
41
+ } from "./chunk-5XKDW36Z.js";
42
+ import "./chunk-DZ3CKYTH.js";
43
+ import "./chunk-I6G7BC42.js";
48
44
  import {
49
45
  createCompletion,
50
46
  createCompletionStream,
51
47
  createParsedCompletion
52
- } from "./chunk-MC3CCKEB.js";
48
+ } from "./chunk-M3IOWB4Y.js";
49
+ import "./chunk-RFDVKCIE.js";
53
50
  import {
54
51
  AssistantContent,
55
52
  Message,
@@ -63,7 +60,7 @@ import {
63
60
  resolveCompletionModelInfo,
64
61
  withContextUsage
65
62
  } from "./chunk-ADH7NNCS.js";
66
- import "./chunk-WQKHFADH.js";
63
+ import "./chunk-A3UBYTJT.js";
67
64
  import {
68
65
  allow,
69
66
  block,
@@ -71,28 +68,26 @@ import {
71
68
  defineInputGuardrail,
72
69
  defineOutputGuardrail,
73
70
  guardrails
74
- } from "./chunk-CWUJUSOS.js";
71
+ } from "./chunk-FNQB2JEH.js";
75
72
  export {
76
- AgentBuilder,
73
+ Agent,
74
+ AgentRunCancelledError,
77
75
  AssistantContent,
78
76
  MaxTurnsError,
79
77
  MemoryCompactionConflictError,
80
78
  MemoryCompactionError,
81
79
  Message,
82
- PromptCancelledError,
83
80
  SkillValidationError,
84
- ToolApprovalRequiredError,
85
81
  ToolContent,
86
82
  Usage,
87
83
  UserContent,
88
84
  allow,
89
85
  block,
90
86
  calculateContextUsage,
91
- cancelPrompt,
92
87
  coreMessagesToUIMessages,
93
88
  createCompletion,
94
89
  createCompletionStream,
95
- createHook,
90
+ createContextIndex,
96
91
  createMiddleware,
97
92
  createParsedCompletion,
98
93
  createSummaryMemoryCompactor,
@@ -101,18 +96,18 @@ export {
101
96
  defineGuardrailPolicy,
102
97
  defineInputGuardrail,
103
98
  defineOutputGuardrail,
99
+ generateImage,
100
+ generateSpeech,
104
101
  getAssistantGenerationMetadata,
105
102
  guardrails,
103
+ isContextIndex,
106
104
  isJsonValue,
107
105
  isMemoryCompactionSummary,
108
106
  isProviderTool,
109
107
  loadSkills,
110
- requestToolApproval,
111
108
  resolveCompletionModelInfo,
112
- runControl,
113
109
  skill,
114
- skipTool,
115
- toolCallControl,
110
+ transcribe,
116
111
  uiMessagesToCoreMessages,
117
112
  withContextUsage
118
113
  };
@@ -1,10 +1,153 @@
1
- export { A as Agent, e as AgentEventAppendInput, f as AgentEventRecord, c as AgentEventStore, g as AgentEventStoreInclude, d as AgentEventStoreOptions, j as AgentEventStoreRegistration, k as AgentOptions, h as AgentSession, i as AgentToolOptions, l as DEFAULT_MAX_TURNS, D as DynamicContextOptions, m as DynamicContextRegistration, b as DynamicToolOptions, n as DynamicToolRegistration } from '../agent-x3YTyv5i.js';
2
- import '../types-G12i56s2.js';
1
+ export { A as Agent, R as ResolvedAgentOptions, k as createResolvedAgent, l as getResolvedAgentOptions } from '../agent-DGYY_onS.js';
2
+ import { P as ProviderTool, M as Message, U as Usage, g as CompletionResponse, u as ToolResultContent } from '../types-B3A4YxaA.js';
3
+ import { T as ToolIndex } from '../dynamic-tools-i9woysFa.js';
4
+ import { A as AnyTool, a as ToolApprovalContext } from '../tool-C_8GudXn.js';
5
+ import { v as AgentToolApprovalRequest, n as AgentRunOptions } from '../index-DxB74ybJ.js';
3
6
  import '../guardrails/index.js';
4
- import '../types-D9JpeAPF.js';
5
- import '../types-BrLbKnEz.js';
6
- import '../index-BxSbmOMr.js';
7
- import '../tool-Cohdv5GC.js';
8
- import '../middleware-Dp3d_pxi.js';
9
- import '../types-BCTRUGex.js';
10
- import '../types-O-abTIin.js';
7
+ import '../type-utils-CtHVDRn_.js';
8
+ import '../types-BBEGKB9m.js';
9
+ import '../middleware-KynLg_RW.js';
10
+ import '../zod-schema-C7F4clpm.js';
11
+ import 'zod';
12
+ import '../types-DulRCYdB.js';
13
+ import '@modelcontextprotocol/sdk/client/sse.js';
14
+ import '@modelcontextprotocol/sdk/client/stdio.js';
15
+ import '@modelcontextprotocol/sdk/client/streamableHttp.js';
16
+ import '../types-DhQfwiZn.js';
17
+ import '../types-DT3nEemY.js';
18
+ import '../types-p55Jc-sr.js';
19
+ import '../retry-D3Ruy-ba.js';
20
+
21
+ type AgentToolState = {
22
+ staticTools: readonly AnyTool[];
23
+ providerTools: readonly ProviderTool[];
24
+ toolIndexes: readonly ToolIndex[];
25
+ };
26
+ declare function getAgentToolState(agent: object): AgentToolState;
27
+
28
+ type HookAction = {
29
+ type: "continue";
30
+ } | {
31
+ type: "terminate";
32
+ reason: string;
33
+ };
34
+ type ToolApprovalRequestOptions = {
35
+ reason?: string;
36
+ rejectMessage?: string;
37
+ };
38
+ type ToolCallHookAction = {
39
+ type: "continue";
40
+ } | {
41
+ type: "skip";
42
+ reason: string;
43
+ } | {
44
+ type: "terminate";
45
+ reason: string;
46
+ } | ({
47
+ type: "approval_request";
48
+ } & ToolApprovalRequestOptions);
49
+ type RunControl = {
50
+ continue(): HookAction;
51
+ cancel(reason: string): HookAction;
52
+ };
53
+ type ToolCallControl = {
54
+ run(): ToolCallHookAction;
55
+ skip(reason: string): ToolCallHookAction;
56
+ cancel(reason: string): ToolCallHookAction;
57
+ requestApproval(options?: ToolApprovalRequestOptions): ToolCallHookAction;
58
+ };
59
+ type HookCallback<Args> = (args: Args) => HookAction | Promise<HookAction | undefined> | Promise<void> | void;
60
+ type ToolCallHookCallback<Args> = (args: Args) => ToolCallHookAction | Promise<ToolCallHookAction | undefined> | Promise<void> | void;
61
+ type CompletionCallHookArgs = {
62
+ prompt: Message;
63
+ history: Message[];
64
+ run: RunControl;
65
+ };
66
+ type RunStartHookArgs = {
67
+ prompt: Message;
68
+ history: Message[];
69
+ maxTurns: number;
70
+ run: RunControl;
71
+ };
72
+ type RunEndHookArgs = {
73
+ output: string;
74
+ usage: Usage;
75
+ messages: Message[];
76
+ run: RunControl;
77
+ };
78
+ type RunErrorHookArgs = {
79
+ error: unknown;
80
+ usage: Usage;
81
+ messages: Message[];
82
+ run: RunControl;
83
+ };
84
+ type TurnStartHookArgs = {
85
+ turn: number;
86
+ prompt: Message;
87
+ history: Message[];
88
+ run: RunControl;
89
+ };
90
+ type TurnEndHookArgs<RawResponse = unknown> = {
91
+ turn: number;
92
+ response: CompletionResponse<RawResponse>;
93
+ run: RunControl;
94
+ };
95
+ type CompletionResponseHookArgs<RawResponse = unknown> = {
96
+ prompt: Message;
97
+ response: CompletionResponse<RawResponse>;
98
+ run: RunControl;
99
+ };
100
+ type CompletionErrorHookArgs = {
101
+ prompt: Message;
102
+ error: unknown;
103
+ run: RunControl;
104
+ };
105
+ type ToolHookArgs = {
106
+ toolName: string;
107
+ toolCallId?: string;
108
+ internalCallId: string;
109
+ args: string;
110
+ };
111
+ type ToolCallHookArgs = ToolHookArgs & {
112
+ tool: ToolCallControl;
113
+ };
114
+ type ToolResultHookArgs = ToolHookArgs & {
115
+ result: string;
116
+ structuredResult?: ToolResultContent[] | undefined;
117
+ run: RunControl;
118
+ };
119
+ type ToolErrorHookArgs = ToolHookArgs & {
120
+ error: unknown;
121
+ run: RunControl;
122
+ };
123
+ interface AgentHook<RawResponse = unknown> {
124
+ onRunStart?: HookCallback<RunStartHookArgs>;
125
+ onRunEnd?: HookCallback<RunEndHookArgs>;
126
+ onRunError?: HookCallback<RunErrorHookArgs>;
127
+ onTurnStart?: HookCallback<TurnStartHookArgs>;
128
+ onTurnEnd?: HookCallback<TurnEndHookArgs<RawResponse>>;
129
+ onCompletionCall?: HookCallback<CompletionCallHookArgs>;
130
+ onCompletionResponse?: HookCallback<CompletionResponseHookArgs<RawResponse>>;
131
+ onCompletionError?: HookCallback<CompletionErrorHookArgs>;
132
+ onToolCall?: ToolCallHookCallback<ToolCallHookArgs>;
133
+ onToolResult?: HookCallback<ToolResultHookArgs>;
134
+ onToolError?: HookCallback<ToolErrorHookArgs>;
135
+ }
136
+
137
+ declare function createHook<RawResponse = unknown>(hook: AgentHook<RawResponse>): AgentHook<RawResponse>;
138
+
139
+ type ToolApprovalRequest<Args = unknown> = ToolApprovalContext<Args> & {
140
+ id: string;
141
+ reason?: string | undefined;
142
+ rejectMessage?: string | undefined;
143
+ };
144
+
145
+ declare function getAgentApprovalRequestDetails(approval: AgentToolApprovalRequest): ToolApprovalRequest | undefined;
146
+
147
+ type InternalAgentRunOptions = {
148
+ hook?: AgentHook | undefined;
149
+ runId?: string | undefined;
150
+ };
151
+ declare function withInternalAgentRunOptions<T extends AgentRunOptions>(options: T, internal: InternalAgentRunOptions): T;
152
+
153
+ export { type AgentHook, type InternalAgentRunOptions, createHook, getAgentApprovalRequestDetails, getAgentToolState, withInternalAgentRunOptions };
@@ -1,25 +1,30 @@
1
1
  import {
2
2
  Agent,
3
- AgentSession,
4
- DEFAULT_MAX_TURNS
5
- } from "../chunk-DALYP4PX.js";
6
- import "../chunk-BALBBVI3.js";
3
+ createHook,
4
+ createResolvedAgent,
5
+ getAgentApprovalRequestDetails,
6
+ getAgentToolState,
7
+ getResolvedAgentOptions,
8
+ withInternalAgentRunOptions
9
+ } from "../chunk-IL3ZSNJI.js";
7
10
  import "../chunk-YK4WAAS4.js";
8
- import "../chunk-XUUY2L2D.js";
9
- import "../chunk-HYUYZEAJ.js";
10
- import "../chunk-MELYDKWQ.js";
11
- import "../chunk-2ODTMRHP.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";
11
+ import "../chunk-6WGGTJE6.js";
12
+ import "../chunk-R2LJSQUW.js";
13
+ import "../chunk-5XKDW36Z.js";
14
+ import "../chunk-DZ3CKYTH.js";
15
+ import "../chunk-I6G7BC42.js";
16
+ import "../chunk-M3IOWB4Y.js";
17
+ import "../chunk-RFDVKCIE.js";
17
18
  import "../chunk-ADH7NNCS.js";
18
- import "../chunk-WQKHFADH.js";
19
- import "../chunk-CWUJUSOS.js";
19
+ import "../chunk-A3UBYTJT.js";
20
+ import "../chunk-FNQB2JEH.js";
20
21
  export {
21
22
  Agent,
22
- AgentSession,
23
- DEFAULT_MAX_TURNS
23
+ createHook,
24
+ createResolvedAgent,
25
+ getAgentApprovalRequestDetails,
26
+ getAgentToolState,
27
+ getResolvedAgentOptions,
28
+ withInternalAgentRunOptions
24
29
  };
25
30
  //# sourceMappingURL=agent.js.map
@@ -1,10 +1,10 @@
1
+ import { a as RetryOptions } from './retry-D3Ruy-ba.js';
1
2
  import { Z as ZodSchema } from './zod-schema-C7F4clpm.js';
2
- import { M as Message, D as Document, i as CompletionTool, L as ToolChoice, J as JsonObject, l as JsonValue, A as AssistantContent, U as Usage, g as CompletionResponse, C as CompletionModel, Z as StreamingCompletionModel, Q as CompletionStreamEvent } from './types-G12i56s2.js';
3
+ import { C as CompletionModel, D as Document, i as CompletionTool, Y as ToolChoice, J as JsonObject, l as JsonValue, M as Message, A as AssistantContent, U as Usage, g as CompletionResponse, W as StreamingCompletionModel, L as CompletionStreamEvent } from './types-B3A4YxaA.js';
3
4
 
4
5
  type CreateCompletionInput = string | Message | Message[];
5
- type CreateCompletionBaseOptions = {
6
- input?: CreateCompletionInput | undefined;
7
- messages?: Message[] | undefined;
6
+ type CreateCompletionBaseOptions<Model extends CompletionModel = CompletionModel> = {
7
+ model: Model;
8
8
  instructions?: string | undefined;
9
9
  documents?: Document[] | undefined;
10
10
  tools?: CompletionTool[] | undefined;
@@ -12,11 +12,12 @@ type CreateCompletionBaseOptions = {
12
12
  maxTokens?: number | undefined;
13
13
  toolChoice?: ToolChoice | undefined;
14
14
  outputSchema?: JsonObject | undefined;
15
- params?: JsonValue | undefined;
15
+ additionalParams?: JsonValue | undefined;
16
+ retries?: RetryOptions | undefined;
16
17
  };
17
- type CreateCompletionOptions = CreateCompletionBaseOptions;
18
- type CreateCompletionStreamOptions = CreateCompletionBaseOptions;
19
- type CreateParsedCompletionOptions<T> = Omit<CreateCompletionBaseOptions, "outputSchema"> & {
18
+ type CreateCompletionOptions<Model extends CompletionModel = CompletionModel> = CreateCompletionBaseOptions<Model>;
19
+ type CreateCompletionStreamOptions<Model extends StreamingCompletionModel = StreamingCompletionModel> = CreateCompletionBaseOptions<Model>;
20
+ type CreateParsedCompletionOptions<T, Model extends CompletionModel = CompletionModel> = Omit<CreateCompletionBaseOptions<Model>, "outputSchema"> & {
20
21
  schema: ZodSchema<T>;
21
22
  };
22
23
  type CreateCompletionResult<RawResponse = unknown> = {
@@ -29,9 +30,9 @@ type CreateParsedCompletionResult<T, RawResponse = unknown> = CreateCompletionRe
29
30
  data: T;
30
31
  };
31
32
  type RawResponseOf<Model> = Model extends CompletionModel<infer RawResponse, infer _ModelName> ? RawResponse : unknown;
32
- declare function createCompletion<Model extends CompletionModel>(model: Model, options: CreateCompletionOptions): Promise<CreateCompletionResult<RawResponseOf<Model>>>;
33
- declare function createCompletionStream<Model extends StreamingCompletionModel>(model: Model, options: CreateCompletionStreamOptions): AsyncIterable<CompletionStreamEvent<RawResponseOf<Model>>>;
34
- declare function createParsedCompletion<T, Model extends CompletionModel>(model: Model, options: CreateParsedCompletionOptions<T>): Promise<CreateParsedCompletionResult<T, RawResponseOf<Model>>>;
33
+ declare function createCompletion<Model extends CompletionModel>(input: CreateCompletionInput, options: CreateCompletionOptions<Model>): Promise<CreateCompletionResult<RawResponseOf<Model>>>;
34
+ declare function createCompletionStream<Model extends StreamingCompletionModel>(input: CreateCompletionInput, options: CreateCompletionStreamOptions<Model>): AsyncIterable<CompletionStreamEvent<RawResponseOf<Model>>>;
35
+ declare function createParsedCompletion<T, Model extends CompletionModel>(input: CreateCompletionInput, options: CreateParsedCompletionOptions<T, Model>): Promise<CreateParsedCompletionResult<T, RawResponseOf<Model>>>;
35
36
  declare function isStreamingCompletionModel(model: CompletionModel): model is StreamingCompletionModel;
36
37
 
37
38
  declare function isJsonValue(value: unknown): value is JsonValue;
@@ -1,4 +1,4 @@
1
- import { D as Document } from '../types-G12i56s2.js';
1
+ import { D as Document } from '../types-B3A4YxaA.js';
2
2
 
3
3
  type LoaderResult<T> = {
4
4
  ok: true;
@@ -7,11 +7,11 @@ type LoaderResult<T> = {
7
7
  ok: false;
8
8
  error: unknown;
9
9
  };
10
- type LoaderValue$1<T> = T extends {
10
+ type LoaderValue<T> = T extends {
11
11
  ok: true;
12
12
  value: infer Value;
13
13
  } ? Value : never;
14
- type UnwrapLoaderResult$1<T> = [LoaderValue$1<T>] extends [never] ? T : LoaderValue$1<T>;
14
+ type UnwrapLoaderResult<T> = [LoaderValue<T>] extends [never] ? T : LoaderValue<T>;
15
15
  type FileSource = {
16
16
  path: string;
17
17
  } | {
@@ -61,15 +61,10 @@ declare class FileLoader<T = LoaderResult<FileSource>> implements AsyncIterable<
61
61
  static fromBytesMany(bytes: Array<Uint8Array | ArrayBuffer>): FileLoader<LoaderResult<FileSource>>;
62
62
  read(): FileLoader<LoaderResult<string>>;
63
63
  readWithPath(): FileLoader<LoaderResult<FileReadWithPath>>;
64
- ignoreErrors(): FileLoader<UnwrapLoaderResult$1<T>>;
64
+ ignoreErrors(): FileLoader<UnwrapLoaderResult<T>>;
65
65
  [Symbol.asyncIterator](): AsyncIterator<T>;
66
66
  }
67
67
 
68
- type LoaderValue<T> = T extends {
69
- ok: true;
70
- value: infer Value;
71
- } ? Value : never;
72
- type UnwrapLoaderResult<T> = [LoaderValue<T>] extends [never] ? T : LoaderValue<T>;
73
68
  declare class PdfFileLoader<T = LoaderResult<PdfSource>> implements AsyncIterable<T> {
74
69
  private readonly source;
75
70
  private readonly mode;
@@ -88,4 +83,4 @@ declare class PdfFileLoader<T = LoaderResult<PdfSource>> implements AsyncIterabl
88
83
  [Symbol.asyncIterator](): AsyncIterator<T>;
89
84
  }
90
85
 
91
- export { FileLoader, type FileMode, type FileReadWithPath, type FileSource, type LoaderResult, type LoaderValue$1 as LoaderValue, PdfFileLoader, type PdfPage, type PdfPageWithPath, type PdfReadWithPath, type PdfSource, type UnwrapLoaderResult$1 as UnwrapLoaderResult, fileLoaderToDocuments, fileToDocument, pdfLoaderToDocuments, pdfPageLoaderToDocuments, pdfPageToDocument, pdfToDocument };
86
+ export { FileLoader, type FileMode, type FileReadWithPath, type FileSource, type LoaderResult, type LoaderValue, PdfFileLoader, type PdfPage, type PdfPageWithPath, type PdfReadWithPath, type PdfSource, type UnwrapLoaderResult, fileLoaderToDocuments, fileToDocument, pdfLoaderToDocuments, pdfPageLoaderToDocuments, pdfPageToDocument, pdfToDocument };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/loaders/documents.ts","../../src/loaders/file.ts","../../src/loaders/shared.ts","../../src/loaders/pdf.ts"],"sourcesContent":["import type { Document } from \"../completion\";\nimport type { FileReadWithPath, PdfPageWithPath, PdfReadWithPath } from \"./types\";\n\nexport function fileToDocument(file: FileReadWithPath): Document {\n return {\n id: file.path,\n text: file.text,\n additionalProps: {\n source: file.path,\n mediaType: \"text/plain\",\n },\n };\n}\n\nexport async function fileLoaderToDocuments(\n loader: AsyncIterable<FileReadWithPath>,\n): Promise<Document[]> {\n const documents: Document[] = [];\n for await (const file of loader) {\n documents.push(fileToDocument(file));\n }\n return documents;\n}\n\nexport function pdfToDocument(pdf: PdfReadWithPath): Document {\n return {\n id: pdf.path,\n text: pdf.text,\n additionalProps: {\n source: pdf.path,\n mediaType: \"application/pdf\",\n },\n };\n}\n\nexport async function pdfLoaderToDocuments(\n loader: AsyncIterable<PdfReadWithPath>,\n): Promise<Document[]> {\n const documents: Document[] = [];\n for await (const pdf of loader) {\n documents.push(pdfToDocument(pdf));\n }\n return documents;\n}\n\nexport function pdfPageToDocument(page: PdfPageWithPath): Document {\n return {\n id: `${page.path}#page=${page.pageNumber}`,\n text: page.text,\n additionalProps: {\n source: page.path,\n mediaType: \"application/pdf\",\n pageNumber: String(page.pageNumber),\n },\n };\n}\n\nexport async function pdfPageLoaderToDocuments(\n loader: AsyncIterable<PdfPageWithPath>,\n): Promise<Document[]> {\n const documents: Document[] = [];\n for await (const page of loader) {\n documents.push(pdfPageToDocument(page));\n }\n return documents;\n}\n","import { readdir, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { err, ok, sortedGlob, toUint8Array } from \"./shared\";\nimport type {\n FileMode,\n FileReadWithPath,\n FileSource,\n LoaderResult,\n UnwrapLoaderResult,\n} from \"./types\";\n\nexport class FileLoader<T = LoaderResult<FileSource>> implements AsyncIterable<T> {\n private constructor(\n private readonly source: () => AsyncIterable<LoaderResult<FileSource>>,\n private readonly mode: FileMode,\n private readonly skipErrors: boolean,\n ) {}\n\n static withGlob(pattern: string): FileLoader<LoaderResult<FileSource>> {\n return new FileLoader(\n async function* () {\n for (const path of await sortedGlob(pattern)) {\n yield ok({ path });\n }\n },\n \"source\",\n false,\n );\n }\n\n static withDir(directory: string): FileLoader<LoaderResult<FileSource>> {\n return new FileLoader(\n async function* () {\n const entries = await readdir(directory, { withFileTypes: true });\n const files = entries\n .filter((entry) => entry.isFile())\n .map((entry) => join(directory, entry.name))\n .sort((left, right) => left.localeCompare(right));\n for (const path of files) {\n yield ok({ path });\n }\n },\n \"source\",\n false,\n );\n }\n\n static fromBytes(bytes: Uint8Array | ArrayBuffer): FileLoader<LoaderResult<FileSource>> {\n return FileLoader.fromBytesMany([bytes]);\n }\n\n static fromBytesMany(\n bytes: Array<Uint8Array | ArrayBuffer>,\n ): FileLoader<LoaderResult<FileSource>> {\n return new FileLoader(\n async function* () {\n for (const value of bytes) {\n yield ok({ path: \"<memory>\", bytes: toUint8Array(value) });\n }\n },\n \"source\",\n false,\n );\n }\n\n read(): FileLoader<LoaderResult<string>> {\n return new FileLoader(this.source, \"read\", this.skipErrors);\n }\n\n readWithPath(): FileLoader<LoaderResult<FileReadWithPath>> {\n return new FileLoader(this.source, \"readWithPath\", this.skipErrors);\n }\n\n ignoreErrors(): FileLoader<UnwrapLoaderResult<T>> {\n return new FileLoader(this.source, this.mode, true) as FileLoader<UnwrapLoaderResult<T>>;\n }\n\n async *[Symbol.asyncIterator](): AsyncIterator<T> {\n for await (const item of this.source()) {\n const result = await mapFileResult(item, this.mode);\n if (!result.ok && this.skipErrors) {\n continue;\n }\n yield (this.skipErrors && result.ok ? result.value : result) as T;\n }\n }\n}\n\nasync function mapFileResult(\n item: LoaderResult<FileSource>,\n mode: FileMode,\n): Promise<LoaderResult<FileSource | string | FileReadWithPath>> {\n if (!item.ok) {\n return item;\n }\n if (mode === \"source\") {\n return item;\n }\n try {\n const text = await readFileSource(item.value);\n return mode === \"read\" ? ok(text) : ok({ path: item.value.path, text });\n } catch (error) {\n return err(error);\n }\n}\n\nasync function readFileSource(source: FileSource): Promise<string> {\n if (\"bytes\" in source) {\n return new TextDecoder().decode(source.bytes);\n }\n return readFile(source.path, \"utf8\");\n}\n","import { isAbsolute } from \"node:path\";\nimport { glob } from \"tinyglobby\";\nimport type { LoaderResult } from \"./types\";\n\nexport function ok<T>(value: T): LoaderResult<T> {\n return { ok: true, value };\n}\n\nexport function err(error: unknown): LoaderResult<never> {\n return { ok: false, error };\n}\n\nexport async function sortedGlob(pattern: string): Promise<string[]> {\n return (await glob(pattern, { absolute: isAbsolute(pattern), onlyFiles: true })).sort(\n (left, right) => left.localeCompare(right),\n );\n}\n\nexport function toUint8Array(bytes: Uint8Array | ArrayBuffer): Uint8Array {\n if (bytes instanceof Uint8Array) {\n return new Uint8Array(\n bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength),\n );\n }\n return new Uint8Array(bytes);\n}\n","import { readdir, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { err, ok, sortedGlob, toUint8Array } from \"./shared\";\nimport type { LoaderResult, PdfPage, PdfPageWithPath, PdfReadWithPath, PdfSource } from \"./types\";\n\ntype PdfMode = \"source\" | \"read\" | \"readWithPath\" | \"byPage\" | \"byPageWithPath\";\ntype LoaderValue<T> = T extends { ok: true; value: infer Value } ? Value : never;\ntype UnwrapLoaderResult<T> = [LoaderValue<T>] extends [never] ? T : LoaderValue<T>;\n\nexport class PdfFileLoader<T = LoaderResult<PdfSource>> implements AsyncIterable<T> {\n private constructor(\n private readonly source: () => AsyncIterable<LoaderResult<PdfSource>>,\n private readonly mode: PdfMode,\n private readonly skipErrors: boolean,\n ) {}\n\n static withGlob(pattern: string): PdfFileLoader<LoaderResult<PdfSource>> {\n return new PdfFileLoader(\n async function* () {\n for (const path of await sortedGlob(pattern)) {\n yield ok({ path });\n }\n },\n \"source\",\n false,\n );\n }\n\n static withDir(directory: string): PdfFileLoader<LoaderResult<PdfSource>> {\n return new PdfFileLoader(\n async function* () {\n const entries = await readdir(directory, { withFileTypes: true });\n const files = entries\n .filter((entry) => entry.isFile())\n .map((entry) => join(directory, entry.name))\n .sort((left, right) => left.localeCompare(right));\n for (const path of files) {\n yield ok({ path });\n }\n },\n \"source\",\n false,\n );\n }\n\n static fromBytes(bytes: Uint8Array | ArrayBuffer): PdfFileLoader<LoaderResult<PdfSource>> {\n return PdfFileLoader.fromBytesMany([bytes]);\n }\n\n static fromBytesMany(\n bytes: Array<Uint8Array | ArrayBuffer>,\n ): PdfFileLoader<LoaderResult<PdfSource>> {\n return new PdfFileLoader(\n async function* () {\n for (const value of bytes) {\n yield ok({ path: \"<memory>\", bytes: toUint8Array(value) });\n }\n },\n \"source\",\n false,\n );\n }\n\n read(): PdfFileLoader<LoaderResult<string>> {\n return new PdfFileLoader(this.source, \"read\", this.skipErrors);\n }\n\n readWithPath(): PdfFileLoader<LoaderResult<PdfReadWithPath>> {\n return new PdfFileLoader(this.source, \"readWithPath\", this.skipErrors);\n }\n\n byPage(\n this: PdfFileLoader<LoaderResult<PdfReadWithPath>>,\n ): PdfFileLoader<LoaderResult<PdfPageWithPath>>;\n byPage(this: PdfFileLoader<PdfReadWithPath>): PdfFileLoader<PdfPageWithPath>;\n byPage(): PdfFileLoader<LoaderResult<PdfPage>>;\n byPage(): PdfFileLoader<LoaderResult<PdfPage> | LoaderResult<PdfPageWithPath> | PdfPageWithPath> {\n const mode = this.mode === \"readWithPath\" ? \"byPageWithPath\" : \"byPage\";\n return new PdfFileLoader(this.source, mode, this.skipErrors);\n }\n\n ignoreErrors(): PdfFileLoader<UnwrapLoaderResult<T>> {\n return new PdfFileLoader(this.source, this.mode, true) as PdfFileLoader<UnwrapLoaderResult<T>>;\n }\n\n async *[Symbol.asyncIterator](): AsyncIterator<T> {\n for await (const item of this.source()) {\n const results = await mapPdfResult(item, this.mode);\n for (const result of results) {\n if (!result.ok && this.skipErrors) {\n continue;\n }\n yield (this.skipErrors && result.ok ? result.value : result) as T;\n }\n }\n }\n}\n\nasync function mapPdfResult(\n item: LoaderResult<PdfSource>,\n mode: PdfMode,\n): Promise<Array<LoaderResult<PdfSource | string | PdfReadWithPath | PdfPage | PdfPageWithPath>>> {\n if (!item.ok) {\n return [item];\n }\n if (mode === \"source\") {\n return [item];\n }\n try {\n const pages = await readPdfPages(item.value);\n if (mode === \"read\") {\n return [ok(pages.map((page) => page.text).join(\"\"))];\n }\n if (mode === \"readWithPath\") {\n return [ok({ path: item.value.path, text: pages.map((page) => page.text).join(\"\") })];\n }\n if (mode === \"byPageWithPath\") {\n return pages.map((page) => ok({ path: item.value.path, ...page }));\n }\n return pages.map(ok);\n } catch (error) {\n return [err(error)];\n }\n}\n\nasync function readPdfPages(source: PdfSource): Promise<PdfPage[]> {\n const pdfjs = await import(\"pdfjs-dist/legacy/build/pdf.mjs\");\n const bytes = \"bytes\" in source ? source.bytes : toUint8Array(await readFile(source.path));\n const loadingTask = pdfjs.getDocument({ data: bytes });\n const document = await loadingTask.promise;\n const pages: PdfPage[] = [];\n try {\n for (let index = 1; index <= document.numPages; index += 1) {\n const page = await document.getPage(index);\n const content = await page.getTextContent();\n const text = content.items\n .flatMap((item) =>\n typeof item === \"object\" && item !== null && \"str\" in item ? [String(item.str)] : [],\n )\n .join(\"\\n\");\n pages.push({ pageNumber: index - 1, text: text.length > 0 ? `${text}\\n` : \"\" });\n }\n } finally {\n await loadingTask.destroy();\n }\n return pages;\n}\n"],"mappings":";AAGO,SAAS,eAAe,MAAkC;AAC/D,SAAO;AAAA,IACL,IAAI,KAAK;AAAA,IACT,MAAM,KAAK;AAAA,IACX,iBAAiB;AAAA,MACf,QAAQ,KAAK;AAAA,MACb,WAAW;AAAA,IACb;AAAA,EACF;AACF;AAEA,eAAsB,sBACpB,QACqB;AACrB,QAAM,YAAwB,CAAC;AAC/B,mBAAiB,QAAQ,QA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;AAC5D,QAAM,QAAQ,WAAW,SAAS,OAAO,QAAQ,aAAa,MAAMC,UAAS,OAAO,IAAI,CAAC;AACzF,QAAM,cAAc,MAAM,YAAY,EAAE,MAAM,MAAM,CAAC;AACrD,QAAM,WAAW,MAAM,YAAY;AACnC,QAAM,QAAmB,CAAC;AAC1B,MAAI;AACF,aAAS,QAAQ,GAAG,SAAS,SAAS,UAAU,SAAS,GAAG;AAC1D,YAAM,OAAO,MAAM,SAAS,QAAQ,KAAK;AACzC,YAAM,UAAU,MAAM,KAAK,eAAe;AAC1C,YAAM,OAAO,QAAQ,MAClB;AAAA,QAAQ,CAAC,SACR,OAAO,SAAS,YAAY,SAAS,QAAQ,SAAS,OAAO,CAAC,OAAO,KAAK,GAAG,CAAC,IAAI,CAAC;AAAA,MACrF,EACC,KAAK,IAAI;AACZ,YAAM,KAAK,EAAE,YAAY,QAAQ,GAAG,MAAM,KAAK,SAAS,IAAI,GAAG,IAAI;AAAA,IAAO,GAAG,CAAC;AAAA,IAChF;AAAA,EACF,UAAE;AACA,UAAM,YAAY,QAAQ;AAAA,EAC5B;AACA,SAAO;AACT;","names":["readdir","readFile","join","readdir","join","readFile"]}
1
+ {"version":3,"sources":["../../src/loaders/documents.ts","../../src/loaders/file.ts","../../src/loaders/shared.ts","../../src/loaders/pdf.ts"],"sourcesContent":["import type { Document } from \"../completion\";\nimport type { FileReadWithPath, PdfPageWithPath, PdfReadWithPath } from \"./types\";\n\nexport function fileToDocument(file: FileReadWithPath): Document {\n return {\n id: file.path,\n text: file.text,\n additionalProps: {\n source: file.path,\n mediaType: \"text/plain\",\n },\n };\n}\n\nexport async function fileLoaderToDocuments(\n loader: AsyncIterable<FileReadWithPath>,\n): Promise<Document[]> {\n const documents: Document[] = [];\n for await (const file of loader) {\n documents.push(fileToDocument(file));\n }\n return documents;\n}\n\nexport function pdfToDocument(pdf: PdfReadWithPath): Document {\n return {\n id: pdf.path,\n text: pdf.text,\n additionalProps: {\n source: pdf.path,\n mediaType: \"application/pdf\",\n },\n };\n}\n\nexport async function pdfLoaderToDocuments(\n loader: AsyncIterable<PdfReadWithPath>,\n): Promise<Document[]> {\n const documents: Document[] = [];\n for await (const pdf of loader) {\n documents.push(pdfToDocument(pdf));\n }\n return documents;\n}\n\nexport function pdfPageToDocument(page: PdfPageWithPath): Document {\n return {\n id: `${page.path}#page=${page.pageNumber}`,\n text: page.text,\n additionalProps: {\n source: page.path,\n mediaType: \"application/pdf\",\n pageNumber: String(page.pageNumber),\n },\n };\n}\n\nexport async function pdfPageLoaderToDocuments(\n loader: AsyncIterable<PdfPageWithPath>,\n): Promise<Document[]> {\n const documents: Document[] = [];\n for await (const page of loader) {\n documents.push(pdfPageToDocument(page));\n }\n return documents;\n}\n","import { readdir, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { err, ok, sortedGlob, toUint8Array } from \"./shared\";\nimport type {\n FileMode,\n FileReadWithPath,\n FileSource,\n LoaderResult,\n UnwrapLoaderResult,\n} from \"./types\";\n\nexport class FileLoader<T = LoaderResult<FileSource>> implements AsyncIterable<T> {\n private constructor(\n private readonly source: () => AsyncIterable<LoaderResult<FileSource>>,\n private readonly mode: FileMode,\n private readonly skipErrors: boolean,\n ) {}\n\n static withGlob(pattern: string): FileLoader<LoaderResult<FileSource>> {\n return new FileLoader(\n async function* () {\n for (const path of await sortedGlob(pattern)) {\n yield ok({ path });\n }\n },\n \"source\",\n false,\n );\n }\n\n static withDir(directory: string): FileLoader<LoaderResult<FileSource>> {\n return new FileLoader(\n async function* () {\n const entries = await readdir(directory, { withFileTypes: true });\n const files = entries\n .filter((entry) => entry.isFile())\n .map((entry) => join(directory, entry.name))\n .sort((left, right) => left.localeCompare(right));\n for (const path of files) {\n yield ok({ path });\n }\n },\n \"source\",\n false,\n );\n }\n\n static fromBytes(bytes: Uint8Array | ArrayBuffer): FileLoader<LoaderResult<FileSource>> {\n return FileLoader.fromBytesMany([bytes]);\n }\n\n static fromBytesMany(\n bytes: Array<Uint8Array | ArrayBuffer>,\n ): FileLoader<LoaderResult<FileSource>> {\n return new FileLoader(\n async function* () {\n for (const value of bytes) {\n yield ok({ path: \"<memory>\", bytes: toUint8Array(value) });\n }\n },\n \"source\",\n false,\n );\n }\n\n read(): FileLoader<LoaderResult<string>> {\n return new FileLoader(this.source, \"read\", this.skipErrors);\n }\n\n readWithPath(): FileLoader<LoaderResult<FileReadWithPath>> {\n return new FileLoader(this.source, \"readWithPath\", this.skipErrors);\n }\n\n ignoreErrors(): FileLoader<UnwrapLoaderResult<T>> {\n return new FileLoader(this.source, this.mode, true) as FileLoader<UnwrapLoaderResult<T>>;\n }\n\n async *[Symbol.asyncIterator](): AsyncIterator<T> {\n for await (const item of this.source()) {\n const result = await mapFileResult(item, this.mode);\n if (!result.ok && this.skipErrors) {\n continue;\n }\n yield (this.skipErrors && result.ok ? result.value : result) as T;\n }\n }\n}\n\nasync function mapFileResult(\n item: LoaderResult<FileSource>,\n mode: FileMode,\n): Promise<LoaderResult<FileSource | string | FileReadWithPath>> {\n if (!item.ok) {\n return item;\n }\n if (mode === \"source\") {\n return item;\n }\n try {\n const text = await readFileSource(item.value);\n return mode === \"read\" ? ok(text) : ok({ path: item.value.path, text });\n } catch (error) {\n return err(error);\n }\n}\n\nasync function readFileSource(source: FileSource): Promise<string> {\n if (\"bytes\" in source) {\n return new TextDecoder().decode(source.bytes);\n }\n return readFile(source.path, \"utf8\");\n}\n","import { isAbsolute } from \"node:path\";\nimport { glob } from \"tinyglobby\";\nimport type { LoaderResult } from \"./types\";\n\nexport function ok<T>(value: T): LoaderResult<T> {\n return { ok: true, value };\n}\n\nexport function err(error: unknown): LoaderResult<never> {\n return { ok: false, error };\n}\n\nexport async function sortedGlob(pattern: string): Promise<string[]> {\n return (await glob(pattern, { absolute: isAbsolute(pattern), onlyFiles: true })).sort(\n (left, right) => left.localeCompare(right),\n );\n}\n\nexport function toUint8Array(bytes: Uint8Array | ArrayBuffer): Uint8Array {\n if (bytes instanceof Uint8Array) {\n return new Uint8Array(\n bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength),\n );\n }\n return new Uint8Array(bytes);\n}\n","import { readdir, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { err, ok, sortedGlob, toUint8Array } from \"./shared\";\nimport type {\n LoaderResult,\n PdfPage,\n PdfPageWithPath,\n PdfReadWithPath,\n PdfSource,\n UnwrapLoaderResult,\n} from \"./types\";\n\ntype PdfMode = \"source\" | \"read\" | \"readWithPath\" | \"byPage\" | \"byPageWithPath\";\n\nexport class PdfFileLoader<T = LoaderResult<PdfSource>> implements AsyncIterable<T> {\n private constructor(\n private readonly source: () => AsyncIterable<LoaderResult<PdfSource>>,\n private readonly mode: PdfMode,\n private readonly skipErrors: boolean,\n ) {}\n\n static withGlob(pattern: string): PdfFileLoader<LoaderResult<PdfSource>> {\n return new PdfFileLoader(\n async function* () {\n for (const path of await sortedGlob(pattern)) {\n yield ok({ path });\n }\n },\n \"source\",\n false,\n );\n }\n\n static withDir(directory: string): PdfFileLoader<LoaderResult<PdfSource>> {\n return new PdfFileLoader(\n async function* () {\n const entries = await readdir(directory, { withFileTypes: true });\n const files = entries\n .filter((entry) => entry.isFile())\n .map((entry) => join(directory, entry.name))\n .sort((left, right) => left.localeCompare(right));\n for (const path of files) {\n yield ok({ path });\n }\n },\n \"source\",\n false,\n );\n }\n\n static fromBytes(bytes: Uint8Array | ArrayBuffer): PdfFileLoader<LoaderResult<PdfSource>> {\n return PdfFileLoader.fromBytesMany([bytes]);\n }\n\n static fromBytesMany(\n bytes: Array<Uint8Array | ArrayBuffer>,\n ): PdfFileLoader<LoaderResult<PdfSource>> {\n return new PdfFileLoader(\n async function* () {\n for (const value of bytes) {\n yield ok({ path: \"<memory>\", bytes: toUint8Array(value) });\n }\n },\n \"source\",\n false,\n );\n }\n\n read(): PdfFileLoader<LoaderResult<string>> {\n return new PdfFileLoader(this.source, \"read\", this.skipErrors);\n }\n\n readWithPath(): PdfFileLoader<LoaderResult<PdfReadWithPath>> {\n return new PdfFileLoader(this.source, \"readWithPath\", this.skipErrors);\n }\n\n byPage(\n this: PdfFileLoader<LoaderResult<PdfReadWithPath>>,\n ): PdfFileLoader<LoaderResult<PdfPageWithPath>>;\n byPage(this: PdfFileLoader<PdfReadWithPath>): PdfFileLoader<PdfPageWithPath>;\n byPage(): PdfFileLoader<LoaderResult<PdfPage>>;\n byPage(): PdfFileLoader<LoaderResult<PdfPage> | LoaderResult<PdfPageWithPath> | PdfPageWithPath> {\n const mode = this.mode === \"readWithPath\" ? \"byPageWithPath\" : \"byPage\";\n return new PdfFileLoader(this.source, mode, this.skipErrors);\n }\n\n ignoreErrors(): PdfFileLoader<UnwrapLoaderResult<T>> {\n return new PdfFileLoader(this.source, this.mode, true) as PdfFileLoader<UnwrapLoaderResult<T>>;\n }\n\n async *[Symbol.asyncIterator](): AsyncIterator<T> {\n for await (const item of this.source()) {\n const results = await mapPdfResult(item, this.mode);\n for (const result of results) {\n if (!result.ok && this.skipErrors) {\n continue;\n }\n yield (this.skipErrors && result.ok ? result.value : result) as T;\n }\n }\n }\n}\n\nasync function mapPdfResult(\n item: LoaderResult<PdfSource>,\n mode: PdfMode,\n): Promise<Array<LoaderResult<PdfSource | string | PdfReadWithPath | PdfPage | PdfPageWithPath>>> {\n if (!item.ok) {\n return [item];\n }\n if (mode === \"source\") {\n return [item];\n }\n try {\n const pages = await readPdfPages(item.value);\n if (mode === \"read\") {\n return [ok(pages.map((page) => page.text).join(\"\"))];\n }\n if (mode === \"readWithPath\") {\n return [ok({ path: item.value.path, text: pages.map((page) => page.text).join(\"\") })];\n }\n if (mode === \"byPageWithPath\") {\n return pages.map((page) => ok({ path: item.value.path, ...page }));\n }\n return pages.map(ok);\n } catch (error) {\n return [err(error)];\n }\n}\n\nasync function readPdfPages(source: PdfSource): Promise<PdfPage[]> {\n const pdfjs = await import(\"pdfjs-dist/legacy/build/pdf.mjs\");\n const bytes = \"bytes\" in source ? source.bytes : toUint8Array(await readFile(source.path));\n const loadingTask = pdfjs.getDocument({ data: bytes });\n const document = await loadingTask.promise;\n const pages: PdfPage[] = [];\n try {\n for (let index = 1; index <= document.numPages; index += 1) {\n const page = await document.getPage(index);\n const content = await page.getTextContent();\n const text = content.items\n .flatMap((item) =>\n typeof item === \"object\" && item !== null && \"str\" in item ? [String(item.str)] : [],\n )\n .join(\"\\n\");\n pages.push({ pageNumber: index - 1, text: text.length > 0 ? `${text}\\n` : \"\" });\n }\n } finally {\n await loadingTask.destroy();\n }\n return pages;\n}\n"],"mappings":";AAGO,SAAS,eAAe,MAAkC;AAC/D,SAAO;AAAA,IACL,IAAI,KAAK;AAAA,IACT,MAAM,KAAK;AAAA,IACX,iBAAiB;AAAA,MACf,QAAQ,KAAK;AAAA,MACb,WAAW;AAAA,IACb;AAAA,EACF;AACF;AAEA,eAAsB,sBACpB,QACqB;AACrB,QAAM,YAAwB,CAAC;AAC/B,mBAAiB,QAAQ,QAAQ;AAC/B,cAAU,KAAK,eAAe,IAAI,CAAC;AAAA,EACrC;AACA,SAAO;AACT;AAEO,SAAS,cAAc,KAAgC;AAC5D,SAAO;AAAA,IACL,IAAI,IAAI;AAAA,IACR,MAAM,IAAI;AAAA,IACV,iBAAiB;AAAA,MACf,QAAQ,IAAI;AAAA,MACZ,WAAW;AAAA,IACb;AAAA,EACF;AACF;AAEA,eAAsB,qBACpB,QACqB;AACrB,QAAM,YAAwB,CAAC;AAC/B,mBAAiB,OAAO,QAAQ;AAC9B,cAAU,KAAK,cAAc,GAAG,CAAC;AAAA,EACnC;AACA,SAAO;AACT;AAEO,SAAS,kBAAkB,MAAiC;AACjE,SAAO;AAAA,IACL,IAAI,GAAG,KAAK,IAAI,SAAS,KAAK,UAAU;AAAA,IACxC,MAAM,KAAK;AAAA,IACX,iBAAiB;AAAA,MACf,QAAQ,KAAK;AAAA,MACb,WAAW;AAAA,MACX,YAAY,OAAO,KAAK,UAAU;AAAA,IACpC;AAAA,EACF;AACF;AAEA,eAAsB,yBACpB,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,UAAM,YAAY,QAAQ;AAAA,EAC5B;AACA,SAAO;AACT;","names":["readdir","readFile","join","readdir","join","readFile"]}
@@ -1,10 +1,10 @@
1
- import { M as McpConnection, a as McpServer, b as McpStdioOptions, c as McpHttpOptions, d as McpSseOptions } from '../types-JJCxRnaZ.js';
2
- export { e as McpClient, f as McpToolCallContent, g as McpToolCallResult, h as McpToolDefinition } from '../types-JJCxRnaZ.js';
1
+ import { M as McpConnection, a as McpServer, b as McpStdioOptions, c as McpHttpOptions, d as McpSseOptions } from '../types-DulRCYdB.js';
2
+ export { e as McpClient, f as McpToolCallContent, g as McpToolCallResult, h as McpToolDefinition } from '../types-DulRCYdB.js';
3
3
  import '@modelcontextprotocol/sdk/client/sse.js';
4
4
  import '@modelcontextprotocol/sdk/client/stdio.js';
5
5
  import '@modelcontextprotocol/sdk/client/streamableHttp.js';
6
- import '../types-G12i56s2.js';
7
- import '../tool-Cohdv5GC.js';
6
+ import '../types-B3A4YxaA.js';
7
+ import '../tool-C_8GudXn.js';
8
8
 
9
9
  declare function connectMcp(connection: McpConnection): Promise<McpServer>;
10
10