@anvia/core 1.0.0-rc.2 → 1.0.0-rc.4

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 (96) hide show
  1. package/README.md +77 -10
  2. package/dist/agent/index.d.ts +20 -13
  3. package/dist/agent/index.js +36 -15
  4. package/dist/{agent-yBG8e9Jj.d.ts → agent-CXScUOpX.d.ts} +12 -15
  5. package/dist/chunk-3RM57ZT2.js +31 -0
  6. package/dist/chunk-3RM57ZT2.js.map +1 -0
  7. package/dist/{chunk-DBSCKTUL.js → chunk-5GXSQYQT.js} +1744 -838
  8. package/dist/chunk-5GXSQYQT.js.map +1 -0
  9. package/dist/{chunk-KIDGIJM7.js → chunk-AZB6N7P4.js} +94 -86
  10. package/dist/chunk-AZB6N7P4.js.map +1 -0
  11. package/dist/{chunk-KR3RCCHJ.js → chunk-D2ECOWN5.js} +26 -11
  12. package/dist/chunk-D2ECOWN5.js.map +1 -0
  13. package/dist/{chunk-EINTGEGY.js → chunk-FXAIYTRE.js} +101 -26
  14. package/dist/chunk-FXAIYTRE.js.map +1 -0
  15. package/dist/{chunk-FMHLROPQ.js → chunk-GQL5KRAH.js} +13 -33
  16. package/dist/chunk-GQL5KRAH.js.map +1 -0
  17. package/dist/{chunk-D37WMSP6.js → chunk-J2W63PJI.js} +50 -10
  18. package/dist/chunk-J2W63PJI.js.map +1 -0
  19. package/dist/{chunk-OJH6HWHX.js → chunk-KFR4CDGK.js} +8 -2
  20. package/dist/chunk-KFR4CDGK.js.map +1 -0
  21. package/dist/{chunk-TIZYTPJO.js → chunk-PK5LKOFL.js} +33 -2
  22. package/dist/chunk-PK5LKOFL.js.map +1 -0
  23. package/dist/{chunk-XKYYBABH.js → chunk-RFHQY2IO.js} +2 -2
  24. package/dist/chunk-TRQ3XRFD.js +54 -0
  25. package/dist/chunk-TRQ3XRFD.js.map +1 -0
  26. package/dist/{chunk-CWM7B2OO.js → chunk-VKYZZXP5.js} +10 -2
  27. package/dist/chunk-VKYZZXP5.js.map +1 -0
  28. package/dist/{chunk-77AIYARB.js → chunk-XYTPYUGB.js} +29 -19
  29. package/dist/chunk-XYTPYUGB.js.map +1 -0
  30. package/dist/{chunk-4WI3VGZK.js → chunk-ZCPOIDAQ.js} +3 -3
  31. package/dist/{client-B8DT1vUG.d.ts → client-DvUatElp.d.ts} +4 -3
  32. package/dist/completion/index.d.ts +3 -3
  33. package/dist/completion/index.js +2 -2
  34. package/dist/documents/index.d.ts +34 -0
  35. package/dist/documents/index.js +315 -0
  36. package/dist/documents/index.js.map +1 -0
  37. package/dist/{dynamic-tools-KwEGRbHp.d.ts → dynamic-tools-AEBOTgu1.d.ts} +3 -3
  38. package/dist/embeddings/index.js +2 -1
  39. package/dist/evals/index.d.ts +19 -11
  40. package/dist/evals/index.js +88 -55
  41. package/dist/evals/index.js.map +1 -1
  42. package/dist/extractor/index.d.ts +1 -1
  43. package/dist/extractor/index.js +3 -3
  44. package/dist/guardrails/index.d.ts +6 -129
  45. package/dist/guardrails/index.js +1 -1
  46. package/dist/image-generation/index.d.ts +1 -1
  47. package/dist/index.d.ts +15 -14
  48. package/dist/index.js +49 -28
  49. package/dist/interactions-csssHYcN.d.ts +174 -0
  50. package/dist/internal/agent.d.ts +18 -22
  51. package/dist/internal/agent.js +45 -14
  52. package/dist/internal/agent.js.map +1 -1
  53. package/dist/mcp/index.d.ts +4 -4
  54. package/dist/mcp/index.js +6 -5
  55. package/dist/memory/index.d.ts +3 -3
  56. package/dist/memory/index.js +3 -3
  57. package/dist/{message-schema-Cn7ezRfJ.d.ts → message-schema-B2M7AYzR.d.ts} +1 -1
  58. package/dist/observability/index.d.ts +8 -7
  59. package/dist/observability/index.js +3 -3
  60. package/dist/pipeline/index.d.ts +18 -18
  61. package/dist/pipeline/index.js +20 -29
  62. package/dist/pipeline/index.js.map +1 -1
  63. package/dist/skills/index.d.ts +4 -4
  64. package/dist/skills/index.js +6 -5
  65. package/dist/speech-generation/index.d.ts +1 -1
  66. package/dist/text-C_6eKrbC.d.ts +32 -0
  67. package/dist/{think-tool-6H2QNQzQ.d.ts → think-tool-D8frXxwV.d.ts} +16 -2
  68. package/dist/tool/index.d.ts +6 -6
  69. package/dist/tool/index.js +9 -4
  70. package/dist/{tool--Mz4v1eL.d.ts → tool-r62gf3QY.d.ts} +3 -2
  71. package/dist/transcription/index.d.ts +1 -1
  72. package/dist/{types-Dld1TpWj.d.ts → types-C3gv9EX6.d.ts} +1 -1
  73. package/dist/{types-3x3mOLHU.d.ts → types-CElwurHZ.d.ts} +56 -35
  74. package/dist/types-CIPaIbZo.d.ts +105 -0
  75. package/dist/{types-CQ_ioXWK.d.ts → types-D9rKQ_as.d.ts} +24 -2
  76. package/dist/{types-BVzM4RsC.d.ts → types-DbolvLtZ.d.ts} +1 -1
  77. package/dist/{types-DiJqJejp.d.ts → types-RT3cuyRk.d.ts} +1 -1
  78. package/dist/vector-store/index.d.ts +7 -6
  79. package/dist/vector-store/index.js +6 -3
  80. package/package.json +6 -6
  81. package/dist/chunk-77AIYARB.js.map +0 -1
  82. package/dist/chunk-CWM7B2OO.js.map +0 -1
  83. package/dist/chunk-D37WMSP6.js.map +0 -1
  84. package/dist/chunk-DBSCKTUL.js.map +0 -1
  85. package/dist/chunk-EINTGEGY.js.map +0 -1
  86. package/dist/chunk-FMHLROPQ.js.map +0 -1
  87. package/dist/chunk-KIDGIJM7.js.map +0 -1
  88. package/dist/chunk-KR3RCCHJ.js.map +0 -1
  89. package/dist/chunk-OJH6HWHX.js.map +0 -1
  90. package/dist/chunk-TIZYTPJO.js.map +0 -1
  91. package/dist/loaders/index.d.ts +0 -87
  92. package/dist/loaders/index.js +0 -299
  93. package/dist/loaders/index.js.map +0 -1
  94. package/dist/middleware-C7PdmKF7.d.ts +0 -56
  95. /package/dist/{chunk-XKYYBABH.js.map → chunk-RFHQY2IO.js.map} +0 -0
  96. /package/dist/{chunk-4WI3VGZK.js.map → chunk-ZCPOIDAQ.js.map} +0 -0
package/README.md CHANGED
@@ -12,10 +12,17 @@ The package is dependency-injection oriented: create provider models, typed tool
12
12
 
13
13
  ## Installation
14
14
 
15
+ Anvia 1.0 is currently published on npm under the `rc` tag. The unqualified `latest` tag remains
16
+ on the maintenance-only v0 line until 1.0 reaches general availability. Keep Core and every Anvia
17
+ adapter on the same release channel.
18
+
15
19
  ```sh
16
- pnpm add @anvia/core
20
+ pnpm add @anvia/core@rc
17
21
  ```
18
22
 
23
+ See the repository's [1.0 release policy](../../docs/releases/v1.md) for channel and support
24
+ details.
25
+
19
26
  In this monorepo, the package is available through the workspace:
20
27
 
21
28
  ```sh
@@ -202,16 +209,37 @@ await agent.generate({
202
209
  ```
203
210
 
204
211
  Agent results are discriminated by `status`. Completed results include typed `output` and `text`;
205
- guardrail blocks return `status: "blocked"`, `stage`, and `text`; tool approval can return
206
- `status: "approval_required"`.
212
+ guardrail blocks return `status: "blocked"`, `stage`, and `text`; tool approvals and first-class
213
+ questions return a JSON-safe `status: "suspended"` result.
207
214
 
208
215
  ```ts
209
216
  const result = await agent.generate({ prompt: "Help with this request." });
210
217
 
211
218
  if (result.status === "completed") console.log(result.output);
212
219
  if (result.status === "blocked") console.log(result.stage, result.text);
220
+ if (result.status === "suspended") {
221
+ const resumed = await agent.generate({
222
+ continuation: result.continuation,
223
+ response:
224
+ result.interaction.type === "tool-approval"
225
+ ? { type: "tool-approval", approved: true }
226
+ : {
227
+ type: "tool-question",
228
+ answers: result.interaction.questions.map((question) => ({
229
+ questionId: question.id,
230
+ value: "application-provided answer",
231
+ })),
232
+ },
233
+ });
234
+ console.log(resumed.status, resumed.resumedFrom);
235
+ }
213
236
  ```
214
237
 
238
+ Keep continuations server-side. A resumed phase receives a new `runId`; Core validates the
239
+ continuation and current Agent/tool registration but does not provide a durable continuation store
240
+ or exactly-once execution. Use `createQuestionTool({ name, description })` when a model must ask for
241
+ structured free-text or choice answers.
242
+
215
243
  An Agent with `outputSchema` carries that output type through `generate`, `stream`, `asTool`, and
216
244
  Pipeline Agent stages. Agent stream finals use the same result shape:
217
245
 
@@ -344,7 +372,7 @@ const pipeline = new Pipeline({ id: "support-flow", inputSchema: z.string() })
344
372
  .agent({
345
373
  id: "draft",
346
374
  agent,
347
- approval: "reject",
375
+ suspension: "reject",
348
376
  request: ({ input }) => ({ prompt: `Draft a reply for this ticket:\n\n${input}` }),
349
377
  })
350
378
  .extract({
@@ -359,6 +387,37 @@ const { runId, output } = await pipeline.run({
359
387
  });
360
388
  ```
361
389
 
390
+ ## Documents
391
+
392
+ Applications own file discovery, file reads, source metadata, and per-file error policy. Core only
393
+ provides deterministic in-memory chunking and scoped PDF text extraction:
394
+
395
+ ```ts
396
+ import { readFile } from "node:fs/promises";
397
+ import { chunkText, extractPdfText } from "@anvia/core/documents";
398
+
399
+ const text = await readFile("guide.txt", "utf8");
400
+ const chunks = chunkText({
401
+ text,
402
+ strategy: "recursive",
403
+ maxSize: 1_000,
404
+ overlap: 100,
405
+ separators: ["\n\n", "\n", " "],
406
+ });
407
+
408
+ const { pages } = await extractPdfText({
409
+ data: new Uint8Array(await readFile("guide.pdf")),
410
+ abortSignal,
411
+ });
412
+ ```
413
+
414
+ Use `strategy: "fixed"` for deterministic sliding windows. Recursive chunking requires an explicit
415
+ separator order and falls back to fixed-size splitting when none of those separators can divide an
416
+ oversized section. Chunk offsets use JavaScript string indices and always identify the exact source
417
+ slice. PDF pages are one-based, and the parser task is disposed before extraction settles.
418
+ If parsing or abort handling fails together with parser cleanup, extraction rejects with an
419
+ `AggregateError` containing the operation failure first and the cleanup failure second.
420
+
362
421
  ## Media
363
422
 
364
423
  Media helpers follow the same one-object API and share `providerOptions`, `retries`, and
@@ -414,7 +473,7 @@ const github = new McpClient({
414
473
  transport: {
415
474
  type: "streamableHttp",
416
475
  url: "https://mcp.example.com/mcp",
417
- requestInit: { headers: { authorization: `Bearer ${process.env.MCP_TOKEN}` } },
476
+ headers: { authorization: `Bearer ${process.env.MCP_TOKEN}` },
418
477
  },
419
478
  tools: { prefix: "github_" },
420
479
  });
@@ -431,13 +490,21 @@ try {
431
490
 
432
491
  Construction performs no I/O. `connect()` discovers every tool page once and returns a frozen
433
492
  registration snapshot. Reconnect and rebuild the Agent to adopt changed remote tools. Built-in
434
- Streamable HTTP connections enforce Anvia URL safety and do not accept a custom `fetch`; use the
435
- explicit caller-owned `custom` transport only when you intentionally own that security boundary.
436
- MCP server instructions remain inspectable metadata and are not added to Agent instructions.
493
+ Streamable HTTP connections enforce Anvia URL safety by default and do not accept a custom `fetch`.
494
+ Static request headers are explicit transport configuration; arbitrary Fetch `RequestInit` fields
495
+ are not exposed because the MCP transport owns its HTTP method, body, abort signal, session, and
496
+ protocol headers. Configured headers are sent only to the exact MCP endpoint, are not attached to
497
+ OAuth requests, and cause endpoint redirects to fail instead of forwarding credentials. A static
498
+ `authorization` header cannot be combined with `authProvider`.
499
+ For an intentionally local or private-network server, set `ssrfProtection: "disabled"` on that
500
+ transport. This disables hostname and DNS restrictions for the complete transport, including
501
+ redirects and OAuth discovery, while still requiring HTTP(S). Use it only when the application owns
502
+ and trusts that network boundary. MCP server instructions remain inspectable metadata and are not
503
+ added to Agent instructions.
437
504
 
438
505
  ## Public Areas
439
506
 
440
- - `agent`: typed Agent runtime, run results, approvals, retries, and stream events
507
+ - `agent`: typed Agent runtime, continuations, interactions, retries, and stream events
441
508
  - `tool`: typed tool creation and tool sets
442
509
  - `completion`: direct completion helpers and provider-neutral model contracts
443
510
  - `memory`: durable session memory interfaces and in-memory store
@@ -450,7 +517,7 @@ MCP server instructions remain inspectable metadata and are not added to Agent i
450
517
  - `skills`: local skill loading
451
518
  - `observability`: observer interfaces for runs, generations, and tool calls
452
519
  - `evals`: evaluation helpers and reporters
453
- - `loaders`: document loading utilities
520
+ - `documents`: in-memory text chunking and PDF text extraction
454
521
  - `speech-generation`, `image-generation`, `transcription`: provider-neutral media interfaces
455
522
 
456
523
  ## Development
@@ -1,26 +1,26 @@
1
1
  export { M as ModelCallOptions } from '../model-call-options-CZkSw_xN.js';
2
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-yBG8e9Jj.js';
4
- import { M as Message } from '../types-CQ_ioXWK.js';
5
- import { c as AgentBlockedResult } from '../types-3x3mOLHU.js';
6
- export { A as AgentApprovalDecision, a as AgentApprovalRequiredEvent, b as AgentApprovalRequiredResult, d as AgentChildStreamEvent, e as AgentDeltaEvent, f as AgentErrorEvent, g as AgentErrorStreamEvent, h as AgentFinishEvent, i as AgentInput, j as AgentLifecycle, k as AgentMemoryCompactionEvent, l as AgentPrompt, m as AgentResponse, n as AgentResult, o as AgentRunOptions, p as AgentRunSettings, q as AgentStartEvent, r as AgentSteerInput, s as AgentStepFinishEvent, t as AgentStream, u as AgentStreamEvent, v as AgentToolApprovalRequest, w as AgentToolCallDeltaEvent, x as AgentToolFinishEvent, y as AgentToolStartEvent } from '../types-3x3mOLHU.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-CXScUOpX.js';
4
+ import { M as Message } from '../types-D9rKQ_as.js';
5
+ import { A as AgentBlockedResult, t as AgentSuspendedResult } from '../types-CElwurHZ.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-CElwurHZ.js';
7
+ export { A as AgentContinuation, a as AgentInteractionRequest, b as AgentInteractionResponse, d as AgentQuestionAnswer, e as AgentQuestionChoice, f as AgentQuestionPrompt, g as AgentToolApprovalRequest, h as AgentToolQuestionRequest, p as agentContinuationSchema, q as agentInteractionRequestSchema, r as agentInteractionResponseSchema, w as assertAgentInteractionResponse, t as parseAgentContinuation, u as parseAgentInteractionRequest, v as parseAgentInteractionResponse } from '../interactions-csssHYcN.js';
7
8
  import '../zod-schema-C7F4clpm.js';
8
9
  import 'zod';
9
- import '../guardrails/index.js';
10
+ import '../types-CIPaIbZo.js';
10
11
  import '../type-utils-CtHVDRn_.js';
11
- import '../client-B8DT1vUG.js';
12
+ import '../client-DvUatElp.js';
12
13
  import 'node:child_process';
13
14
  import 'node:stream';
14
15
  import '@modelcontextprotocol/sdk/client/auth.js';
15
16
  import '@modelcontextprotocol/sdk/client/streamableHttp.js';
16
17
  import '@modelcontextprotocol/sdk/shared/transport.js';
17
- import '../tool--Mz4v1eL.js';
18
- import '../middleware-C7PdmKF7.js';
19
- import '../types-BVzM4RsC.js';
20
- import '../types-DiJqJejp.js';
21
- import '../dynamic-tools-KwEGRbHp.js';
18
+ import '../tool-r62gf3QY.js';
19
+ import '../types-DbolvLtZ.js';
20
+ import '../types-RT3cuyRk.js';
21
+ import '../dynamic-tools-AEBOTgu1.js';
22
22
  import '../types-Cr4uiYo5.js';
23
- import '../types-Dld1TpWj.js';
23
+ import '../types-C3gv9EX6.js';
24
24
 
25
25
  declare class MaxTurnsError extends Error {
26
26
  readonly maxTurns: number;
@@ -37,5 +37,12 @@ declare class AgentRunBlockedError extends Error {
37
37
  readonly result: AgentBlockedResult;
38
38
  constructor(result: AgentBlockedResult);
39
39
  }
40
+ declare class AgentStreamClosedError extends Error {
41
+ constructor();
42
+ }
43
+ declare class AgentToolSuspensionError extends Error {
44
+ readonly result: AgentSuspendedResult;
45
+ constructor(result: AgentSuspendedResult);
46
+ }
40
47
 
41
- export { AgentBlockedResult, AgentRunBlockedError, AgentRunCancelledError, MaxTurnsError };
48
+ export { AgentBlockedResult, AgentRunBlockedError, AgentRunCancelledError, AgentStreamClosedError, AgentSuspendedResult, AgentToolSuspensionError, MaxTurnsError };
@@ -1,30 +1,51 @@
1
1
  import {
2
2
  Agent,
3
- AgentRunBlockedError,
4
- AgentRunCancelledError,
5
- MaxTurnsError,
3
+ agentContinuationSchema,
4
+ agentInteractionRequestSchema,
5
+ agentInteractionResponseSchema,
6
+ assertAgentInteractionResponse,
6
7
  createVectorContext,
7
- isVectorContext
8
- } from "../chunk-DBSCKTUL.js";
8
+ isVectorContext,
9
+ parseAgentContinuation,
10
+ parseAgentInteractionRequest,
11
+ parseAgentInteractionResponse
12
+ } from "../chunk-5GXSQYQT.js";
13
+ import "../chunk-FXAIYTRE.js";
14
+ import "../chunk-KFR4CDGK.js";
15
+ import "../chunk-VKYZZXP5.js";
9
16
  import "../chunk-YK4WAAS4.js";
10
- import "../chunk-EINTGEGY.js";
11
17
  import "../chunk-CQNNSZPG.js";
12
- import "../chunk-D37WMSP6.js";
13
- import "../chunk-77AIYARB.js";
14
- import "../chunk-OJH6HWHX.js";
15
- import "../chunk-CWM7B2OO.js";
16
- import "../chunk-FMHLROPQ.js";
18
+ import "../chunk-J2W63PJI.js";
19
+ import "../chunk-XYTPYUGB.js";
20
+ import {
21
+ AgentRunBlockedError,
22
+ AgentRunCancelledError,
23
+ AgentStreamClosedError,
24
+ AgentToolSuspensionError,
25
+ MaxTurnsError
26
+ } from "../chunk-TRQ3XRFD.js";
27
+ import "../chunk-GQL5KRAH.js";
28
+ import "../chunk-3RM57ZT2.js";
17
29
  import "../chunk-MGNTXGTX.js";
18
- import "../chunk-KR3RCCHJ.js";
19
- import "../chunk-TIZYTPJO.js";
20
- import "../chunk-KIDGIJM7.js";
30
+ import "../chunk-D2ECOWN5.js";
31
+ import "../chunk-PK5LKOFL.js";
21
32
  import "../chunk-FN7HLLAZ.js";
33
+ import "../chunk-AZB6N7P4.js";
22
34
  export {
23
35
  Agent,
24
36
  AgentRunBlockedError,
25
37
  AgentRunCancelledError,
38
+ AgentStreamClosedError,
39
+ AgentToolSuspensionError,
26
40
  MaxTurnsError,
41
+ agentContinuationSchema,
42
+ agentInteractionRequestSchema,
43
+ agentInteractionResponseSchema,
44
+ assertAgentInteractionResponse,
27
45
  createVectorContext,
28
- isVectorContext
46
+ isVectorContext,
47
+ parseAgentContinuation,
48
+ parseAgentInteractionRequest,
49
+ parseAgentInteractionResponse
29
50
  };
30
51
  //# sourceMappingURL=index.js.map
@@ -1,16 +1,16 @@
1
1
  import { b as RetrySetting } from './retry-CjvSlKGW.js';
2
- import { D as Document, C as CompletionModel, P as ProviderTool, J as JsonObject, u as ToolChoice } from './types-CQ_ioXWK.js';
2
+ import { D as Document, C as CompletionModel, P as ProviderTool, J as JsonObject, u as ToolChoice } from './types-D9rKQ_as.js';
3
3
  import { Z as ZodSchema } from './zod-schema-C7F4clpm.js';
4
- import { GuardrailPolicyInput, GuardrailPolicy } from './guardrails/index.js';
5
- import { a as McpServer } from './client-B8DT1vUG.js';
6
- import { j as AgentLifecycle, G as AgentObservabilityOptions, o as AgentRunOptions, n as AgentResult, t as AgentStream, u as AgentStreamEvent, b as AgentApprovalRequiredResult, A as AgentApprovalDecision, a as AgentApprovalRequiredEvent } from './types-3x3mOLHU.js';
7
- import { A as AgentMiddleware } from './middleware-C7PdmKF7.js';
8
- import { A as AnyTool, T as Tool, c as ToolCallContext, N as NormalizedToolOutput } from './tool--Mz4v1eL.js';
9
- import { D as MemoryStore, y as MemorySavePolicy, m as MemoryCompactor, d as MemoryCompactionConflictRetryOptions, x as MemoryOptions } from './types-BVzM4RsC.js';
10
- import { a as SkillSet } from './types-DiJqJejp.js';
11
- import { T as ToolIndex } from './dynamic-tools-KwEGRbHp.js';
4
+ import { d as GuardrailPolicyInput, c as GuardrailPolicy } from './types-CIPaIbZo.js';
5
+ import { a as McpServer } from './client-DvUatElp.js';
6
+ import { g as AgentLifecycle, E as AgentObservabilityOptions, l as AgentRunOptions, k as AgentResult, r as AgentStream, s as AgentStreamEvent } from './types-CElwurHZ.js';
7
+ import { c as AgentMiddleware } from './interactions-csssHYcN.js';
8
+ import { A as AnyTool, T as Tool, c as ToolCallContext, N as NormalizedToolOutput } from './tool-r62gf3QY.js';
9
+ import { D as MemoryStore, y as MemorySavePolicy, m as MemoryCompactor, d as MemoryCompactionConflictRetryOptions, x as MemoryOptions } from './types-DbolvLtZ.js';
10
+ import { a as SkillSet } from './types-RT3cuyRk.js';
11
+ import { T as ToolIndex } from './dynamic-tools-AEBOTgu1.js';
12
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-Dld1TpWj.js';
13
+ import { V as VectorFilter, a as VectorSearchResult, d as VectorStore, H as HybridVectorStore, e as VectorFusion } from './types-C3gv9EX6.js';
14
14
 
15
15
  type VectorContextBaseOptions<T = unknown> = {
16
16
  topK: number;
@@ -109,6 +109,7 @@ type ResolvedAgentOptions<Output = string, M extends CompletionModel = Completio
109
109
  };
110
110
  type AgentToolOptions = {
111
111
  name: string;
112
+ suspension: "reject";
112
113
  description?: string | undefined;
113
114
  maxTurns?: number | undefined;
114
115
  stream?: boolean | undefined;
@@ -139,15 +140,11 @@ declare class Agent<Output = string, M extends CompletionModel = CompletionModel
139
140
  constructor(options: AgentOptions<Output, M, ContextDocument>);
140
141
  generate(options: AgentRunOptions<Output, RawResponseOf<M>>): Promise<AgentResult<Output>>;
141
142
  stream(options: AgentRunOptions<Output, RawResponseOf<M>>): AgentStream<AgentStreamEvent<Output, RawResponseOf<M>>>;
142
- resume(pending: AgentApprovalRequiredResult, decision: AgentApprovalDecision): Promise<AgentResult<Output>>;
143
- resume(pending: AgentApprovalRequiredEvent, decision: AgentApprovalDecision): AgentStream<AgentStreamEvent<Output, RawResponseOf<M>>>;
144
143
  asTool(options: AgentToolOptions): Tool<{
145
144
  prompt: string;
146
145
  }, Output>;
147
146
  getTool(toolName: string): AnyTool | undefined;
148
147
  callTool(toolName: string, args: string, context?: ToolCallContext): Promise<NormalizedToolOutput>;
149
148
  }
150
- declare function createResolvedAgent<Output = string, M extends CompletionModel = CompletionModel, ContextDocument = unknown>(options: ResolvedAgentOptions<Output, M, ContextDocument>): Agent<Output, M, ContextDocument>;
151
- declare function getResolvedAgentOptions<Output, M extends CompletionModel, ContextDocument>(agent: Agent<Output, M, ContextDocument>): ResolvedAgentOptions<Output, M, ContextDocument>;
152
149
 
153
- 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, createResolvedAgent as k, getResolvedAgentOptions as l };
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":[]}