jangada-ai 1.0.0 → 1.0.2
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.
- package/dist/a2a/index.cjs +9 -0
- package/dist/a2a/index.d.cts +2 -0
- package/dist/a2a/index.d.ts +2 -0
- package/dist/a2a/index.js +1 -0
- package/dist/{anthropic-CYKRUh9e.cjs → anthropic-6sRl3i7z.cjs} +7 -7
- package/dist/{anthropic-BlqXqf9N.js → anthropic-BIKZUdHL.js} +4 -4
- package/dist/{base-bplcDr6J.cjs → base-8ZFKIzBj.cjs} +1 -1
- package/dist/{base-8WLtVj6O.js → base-B9vWogrC.js} +1 -1
- package/dist/{bedrock-Dxpg5jFC.cjs → bedrock-Cjek46Mw.cjs} +5 -5
- package/dist/{bedrock-infoTG03.js → bedrock-oWZQlwCt.js} +3 -3
- package/dist/{client-BFoano5Y.js → client-BALmyl1D.js} +5 -4
- package/dist/{client-C7tNbVHu.cjs → client-Bb1r1q6G.cjs} +11 -10
- package/dist/{client-Y9MDtyQ4.d.cts → client-BcJnFY-A.d.cts} +2 -2
- package/dist/{client-CoQl5mod.d.ts → client-G7gJaq6H.d.ts} +2 -1
- package/dist/{client-BmJIzbSw.d.ts → client-gwTD3MxV.d.ts} +2 -2
- package/dist/{client-DgU6xftB.d.cts → client-voHjPm-f.d.cts} +2 -1
- package/dist/context-BWyYfOyr.cjs +136 -0
- package/dist/context-CvNVqdqz.js +101 -0
- package/dist/eval/index.d.cts +1 -1
- package/dist/eval/index.d.ts +1 -1
- package/dist/{gemini-Dj5mMQH_.cjs → gemini-CqWTQz_y.cjs} +8 -8
- package/dist/{gemini-UV1iF24m.js → gemini-VIK6GzRx.js} +4 -4
- package/dist/index.cjs +36 -35
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +18 -17
- package/dist/mcp/index.cjs +3 -3
- package/dist/mcp/index.d.cts +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +3 -3
- package/dist/{context-C7qrmHGJ.js → message-0wKCrEp2.js} +1 -101
- package/dist/{observability-DLUNn71i.d.ts → message-D3MSjqww.d.cts} +1 -80
- package/dist/{observability-DLUNn71i.d.cts → message-D3MSjqww.d.ts} +1 -80
- package/dist/{context-JTZvYRrC.cjs → message-DCvWw0dF.cjs} +0 -136
- package/dist/{mistral-CdX-9oKB.cjs → mistral-DD9PTIYO.cjs} +12 -12
- package/dist/{mistral-NBf2U9m7.js → mistral-rbVDtlHt.js} +3 -3
- package/dist/node/index.cjs +8 -644
- package/dist/node/index.d.cts +3 -235
- package/dist/node/index.d.ts +3 -235
- package/dist/node/index.js +3 -639
- package/dist/observability-Cy4ewtvC.d.cts +81 -0
- package/dist/observability-DSlDuE1w.d.ts +81 -0
- package/dist/{ollama-CpdaRdg-.js → ollama-CtOa_75e.js} +3 -3
- package/dist/{ollama-CURVIQcv.cjs → ollama-DvKNKF2I.cjs} +6 -6
- package/dist/{openai-compat-Qlv_JgU5.js → openai-compat-CJRRaqmi.js} +4 -4
- package/dist/{openai-compat-BWdb9UUW.cjs → openai-compat-uVcRxBHu.cjs} +11 -11
- package/dist/prebuilt/index.cjs +1 -1
- package/dist/prebuilt/index.js +1 -1
- package/dist/rag/index.d.cts +3 -2
- package/dist/rag/index.d.ts +3 -2
- package/dist/server-C0wyAefS.cjs +680 -0
- package/dist/server-CnO0Uj7X.d.cts +280 -0
- package/dist/server-DVWw6Q6D.d.ts +280 -0
- package/dist/{server-DOnplmbD.js → server-q2tlgVLB.js} +3 -3
- package/dist/{server-CKj0B5mk.cjs → server-uzd_KbIF.cjs} +3 -3
- package/dist/server-zdrObsBn.js +639 -0
- package/dist/{version-Ch4xT-gQ.cjs → version-3n0cxDMH.cjs} +1 -1
- package/dist/{version-CrHu1Pq_.js → version-DgKb-29E.js} +1 -1
- package/package.json +5 -1
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_client = require("./client-
|
|
3
|
-
const
|
|
4
|
-
const require_version = require("./version-
|
|
2
|
+
const require_client = require("./client-Bb1r1q6G.cjs");
|
|
3
|
+
const require_message = require("./message-DCvWw0dF.cjs");
|
|
4
|
+
const require_version = require("./version-3n0cxDMH.cjs");
|
|
5
5
|
const require_schema = require("./schema-qS-xTTIs.cjs");
|
|
6
6
|
const require_errors = require("./errors-BJIPDLwX.cjs");
|
|
7
7
|
const require_files = require("./files-DhchXoMT.cjs");
|
|
8
8
|
const require_observability = require("./observability-D1Eiz3hh.cjs");
|
|
9
9
|
const require_env = require("./env-B1ffNsxb.cjs");
|
|
10
|
+
const require_context = require("./context-BWyYfOyr.cjs");
|
|
10
11
|
const require_gemini_schema = require("./gemini-schema-BwcTPvV1.cjs");
|
|
11
|
-
const require_base = require("./base-
|
|
12
|
+
const require_base = require("./base-8ZFKIzBj.cjs");
|
|
12
13
|
// src/providers/registry.ts
|
|
13
14
|
const REGISTRY = /* @__PURE__ */ new Map();
|
|
14
15
|
/** Registra (ou sobrescreve) um provider. */
|
|
@@ -33,17 +34,17 @@ function availableProviders() {
|
|
|
33
34
|
* Registro dos providers embutidos. O módulo de cada adapter só é carregado quando
|
|
34
35
|
* o provider é usado; o SDK, só quando o cliente é criado.
|
|
35
36
|
*/
|
|
36
|
-
registerProvider("openai", async () => (await Promise.resolve().then(() => require("./openai-compat-
|
|
37
|
-
registerProvider("azure", async () => (await Promise.resolve().then(() => require("./openai-compat-
|
|
38
|
-
registerProvider("groq", async () => (await Promise.resolve().then(() => require("./openai-compat-
|
|
39
|
-
registerProvider("openrouter", async () => (await Promise.resolve().then(() => require("./openai-compat-
|
|
40
|
-
registerProvider("deepseek", async () => (await Promise.resolve().then(() => require("./openai-compat-
|
|
41
|
-
registerProvider("anthropic", async () => (await Promise.resolve().then(() => require("./anthropic-
|
|
42
|
-
registerProvider("gemini", async () => (await Promise.resolve().then(() => require("./gemini-
|
|
43
|
-
registerProvider("vertex", async () => (await Promise.resolve().then(() => require("./gemini-
|
|
44
|
-
registerProvider("ollama", async () => (await Promise.resolve().then(() => require("./ollama-
|
|
45
|
-
registerProvider("bedrock", async () => (await Promise.resolve().then(() => require("./bedrock-
|
|
46
|
-
registerProvider("mistral", async () => (await Promise.resolve().then(() => require("./mistral-
|
|
37
|
+
registerProvider("openai", async () => (await Promise.resolve().then(() => require("./openai-compat-uVcRxBHu.cjs"))).OpenAIProvider);
|
|
38
|
+
registerProvider("azure", async () => (await Promise.resolve().then(() => require("./openai-compat-uVcRxBHu.cjs"))).AzureOpenAIProvider);
|
|
39
|
+
registerProvider("groq", async () => (await Promise.resolve().then(() => require("./openai-compat-uVcRxBHu.cjs"))).GroqProvider);
|
|
40
|
+
registerProvider("openrouter", async () => (await Promise.resolve().then(() => require("./openai-compat-uVcRxBHu.cjs"))).OpenRouterProvider);
|
|
41
|
+
registerProvider("deepseek", async () => (await Promise.resolve().then(() => require("./openai-compat-uVcRxBHu.cjs"))).DeepSeekProvider);
|
|
42
|
+
registerProvider("anthropic", async () => (await Promise.resolve().then(() => require("./anthropic-6sRl3i7z.cjs"))).AnthropicProvider);
|
|
43
|
+
registerProvider("gemini", async () => (await Promise.resolve().then(() => require("./gemini-CqWTQz_y.cjs"))).GeminiProvider);
|
|
44
|
+
registerProvider("vertex", async () => (await Promise.resolve().then(() => require("./gemini-CqWTQz_y.cjs"))).VertexProvider);
|
|
45
|
+
registerProvider("ollama", async () => (await Promise.resolve().then(() => require("./ollama-DvKNKF2I.cjs"))).OllamaProvider);
|
|
46
|
+
registerProvider("bedrock", async () => (await Promise.resolve().then(() => require("./bedrock-Cjek46Mw.cjs"))).BedrockProvider);
|
|
47
|
+
registerProvider("mistral", async () => (await Promise.resolve().then(() => require("./mistral-DD9PTIYO.cjs"))).MistralProvider);
|
|
47
48
|
// src/agents.ts
|
|
48
49
|
/** Memória de longo prazo sobre um RAG: `recall` busca; `remember` indexa. Best-effort. */
|
|
49
50
|
var RAGMemory = class {
|
|
@@ -264,7 +265,7 @@ var Agent = class Agent {
|
|
|
264
265
|
});
|
|
265
266
|
results.push(r);
|
|
266
267
|
}
|
|
267
|
-
history.push(
|
|
268
|
+
history.push(require_message.Message.toolResults(...results));
|
|
268
269
|
}
|
|
269
270
|
if (i > this.maxIterations) {
|
|
270
271
|
i = this.maxIterations;
|
|
@@ -541,7 +542,7 @@ async function plan(llm, goal, options = {}) {
|
|
|
541
542
|
/** JSON estável: chaves ordenadas, bytes viram base64. */
|
|
542
543
|
function stableStringify(value) {
|
|
543
544
|
return JSON.stringify(value, (_k, v) => {
|
|
544
|
-
if (v instanceof Uint8Array) return { __bytes:
|
|
545
|
+
if (v instanceof Uint8Array) return { __bytes: require_message.bytesToBase64(v) };
|
|
545
546
|
if (v && typeof v === "object" && !Array.isArray(v)) return Object.fromEntries(Object.entries(v).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
546
547
|
return v;
|
|
547
548
|
});
|
|
@@ -568,7 +569,7 @@ function isCacheable(method, hasTools) {
|
|
|
568
569
|
* cache), `cost = 0` (Flow/Graph/Agent não somam custo fantasma) e `cached = true`.
|
|
569
570
|
*/
|
|
570
571
|
function hitCopy(comp) {
|
|
571
|
-
const novo = new
|
|
572
|
+
const novo = new require_message.Completion({
|
|
572
573
|
text: comp.text,
|
|
573
574
|
model: comp.model,
|
|
574
575
|
provider: comp.provider,
|
|
@@ -2562,12 +2563,12 @@ function sleep$1(ms, signal) {
|
|
|
2562
2563
|
}
|
|
2563
2564
|
async function resolveImage(img, signal) {
|
|
2564
2565
|
if (typeof img !== "string") return img;
|
|
2565
|
-
if (img.startsWith("data:")) return
|
|
2566
|
+
if (img.startsWith("data:")) return require_message.Image.fromDataUri(img);
|
|
2566
2567
|
if (/^https?:\/\//i.test(img)) {
|
|
2567
2568
|
const resp = await fetch(img, signal ? { signal } : {});
|
|
2568
2569
|
if (!resp.ok) throw new Error(`não consegui baixar a imagem ${img}: HTTP ${resp.status}`);
|
|
2569
2570
|
const mime = resp.headers.get("content-type")?.split(";")[0]?.trim() || "image/png";
|
|
2570
|
-
return
|
|
2571
|
+
return require_message.Image.fromBytes(new Uint8Array(await resp.arrayBuffer()), mime);
|
|
2571
2572
|
}
|
|
2572
2573
|
throw new TypeError(`imagem '${img}': no núcleo use ImagePart, data URI ou URL http(s). Para ler de arquivo no Node, use readImage() de 'jangada-ai/node'.`);
|
|
2573
2574
|
}
|
|
@@ -2657,14 +2658,14 @@ var LLM = class LLM {
|
|
|
2657
2658
|
for (const f of input.files ?? []) parts.push(...await require_files.toParts(f));
|
|
2658
2659
|
for (const img of input.images ?? []) if (Array.isArray(img)) {
|
|
2659
2660
|
const [label, item] = img;
|
|
2660
|
-
if (label) parts.push(
|
|
2661
|
+
if (label) parts.push(require_message.textPart(String(label)));
|
|
2661
2662
|
parts.push(await resolveImage(item, input.signal));
|
|
2662
2663
|
} else parts.push(await resolveImage(img, input.signal));
|
|
2663
2664
|
if (prompt === null && parts.length === 0) return messages;
|
|
2664
2665
|
const rendered = this.render(prompt ?? "", input.variables) ?? "";
|
|
2665
2666
|
messages.push(parts.length ? {
|
|
2666
2667
|
role: "user",
|
|
2667
|
-
content: [
|
|
2668
|
+
content: [require_message.textPart(rendered), ...parts]
|
|
2668
2669
|
} : {
|
|
2669
2670
|
role: "user",
|
|
2670
2671
|
content: rendered
|
|
@@ -2712,7 +2713,7 @@ var LLM = class LLM {
|
|
|
2712
2713
|
*/
|
|
2713
2714
|
refusal(message, reason, paid) {
|
|
2714
2715
|
this.debug.note(`guardrail bloqueou: ${reason}`);
|
|
2715
|
-
return new
|
|
2716
|
+
return new require_message.Completion({
|
|
2716
2717
|
text: message,
|
|
2717
2718
|
model: this.model,
|
|
2718
2719
|
provider: this.providerName,
|
|
@@ -2918,7 +2919,7 @@ var LLM = class LLM {
|
|
|
2918
2919
|
yield r.value;
|
|
2919
2920
|
}
|
|
2920
2921
|
this.debug.note("stream concluído");
|
|
2921
|
-
if (!LLM.isGuardCall(input)) require_observability.autoReport(new
|
|
2922
|
+
if (!LLM.isGuardCall(input)) require_observability.autoReport(new require_message.Completion({
|
|
2922
2923
|
text: pedacos.join(""),
|
|
2923
2924
|
model: cand.model,
|
|
2924
2925
|
provider: cand.providerName
|
|
@@ -3130,7 +3131,7 @@ var LLM = class LLM {
|
|
|
3130
3131
|
reportEmbed(r, items, t0) {
|
|
3131
3132
|
const dim = r.vectors[0]?.length ?? 0;
|
|
3132
3133
|
const usage = r.usage ?? null;
|
|
3133
|
-
const comp = new
|
|
3134
|
+
const comp = new require_message.Completion({
|
|
3134
3135
|
text: `${r.vectors.length} embedding(s), ${dim} dimensions`,
|
|
3135
3136
|
model: this.model,
|
|
3136
3137
|
provider: this.providerName,
|
|
@@ -4340,7 +4341,7 @@ var GeminiInteractions = class GeminiInteractions {
|
|
|
4340
4341
|
* lib não puxa o adapter para o bundle principal.
|
|
4341
4342
|
*/
|
|
4342
4343
|
provider() {
|
|
4343
|
-
this.providerPromise ??= Promise.resolve().then(() => require("./gemini-
|
|
4344
|
+
this.providerPromise ??= Promise.resolve().then(() => require("./gemini-CqWTQz_y.cjs")).then((m) => {
|
|
4344
4345
|
const Base = this.options.vertexai ? m.VertexProvider : m.GeminiProvider;
|
|
4345
4346
|
class Interactions extends Base {
|
|
4346
4347
|
nativeClient() {
|
|
@@ -4367,7 +4368,7 @@ var GeminiInteractions = class GeminiInteractions {
|
|
|
4367
4368
|
}
|
|
4368
4369
|
async api() {
|
|
4369
4370
|
const api = get(await (await this.provider()).nativeClient(), "interactions");
|
|
4370
|
-
if (!api) throw new require_errors.UnsupportedError("a Interactions API exige
|
|
4371
|
+
if (!api) throw new require_errors.UnsupportedError("a Interactions API exige @google/genai 1.33 ou mais novo (client.interactions): atualize com `npm install @google/genai@latest`.", { provider: PROVIDER$1 });
|
|
4371
4372
|
return api;
|
|
4372
4373
|
}
|
|
4373
4374
|
static err(e, signal, request = false) {
|
|
@@ -4769,10 +4770,10 @@ async function stepBack(llm, query, options = {}) {
|
|
|
4769
4770
|
exports.APIConnectionError = require_errors.APIConnectionError;
|
|
4770
4771
|
exports.APITimeoutError = require_errors.APITimeoutError;
|
|
4771
4772
|
exports.Agent = Agent;
|
|
4772
|
-
exports.Audio =
|
|
4773
|
+
exports.Audio = require_message.Audio;
|
|
4773
4774
|
exports.AuthError = require_errors.AuthError;
|
|
4774
4775
|
exports.BadRequestError = require_errors.BadRequestError;
|
|
4775
|
-
exports.Completion =
|
|
4776
|
+
exports.Completion = require_message.Completion;
|
|
4776
4777
|
exports.DEEP_RESEARCH_AGENT = DEEP_RESEARCH_AGENT;
|
|
4777
4778
|
exports.DEFAULT_FAILOVER = require_errors.DEFAULT_FAILOVER;
|
|
4778
4779
|
exports.DEFAULT_MAX_PDF_PAGES = require_files.DEFAULT_MAX_PDF_PAGES;
|
|
@@ -4789,14 +4790,14 @@ exports.Graph = Graph;
|
|
|
4789
4790
|
exports.GraphResult = GraphResult;
|
|
4790
4791
|
exports.Guardrail = Guardrail;
|
|
4791
4792
|
exports.GuardrailError = require_errors.GuardrailError;
|
|
4792
|
-
exports.Image =
|
|
4793
|
+
exports.Image = require_message.Image;
|
|
4793
4794
|
exports.InteractionFunctionCall = InteractionFunctionCall;
|
|
4794
4795
|
exports.InteractionResult = InteractionResult;
|
|
4795
4796
|
exports.LLM = LLM;
|
|
4796
4797
|
exports.LLMError = require_errors.LLMError;
|
|
4797
4798
|
exports.MCPClient = require_client.MCPClient;
|
|
4798
4799
|
exports.MCPServer = require_client.MCPServer;
|
|
4799
|
-
exports.Message =
|
|
4800
|
+
exports.Message = require_message.Message;
|
|
4800
4801
|
exports.NATIVE_TOOL_KINDS = require_version.NATIVE_TOOL_KINDS;
|
|
4801
4802
|
exports.NativeTool = require_version.NativeTool;
|
|
4802
4803
|
exports.NotFoundError = require_errors.NotFoundError;
|
|
@@ -4819,7 +4820,7 @@ exports.TRANSIENT = require_errors.TRANSIENT;
|
|
|
4819
4820
|
exports.Template = Template;
|
|
4820
4821
|
exports.TemplateError = TemplateError;
|
|
4821
4822
|
exports.Tool = require_version.Tool;
|
|
4822
|
-
exports.ToolCall =
|
|
4823
|
+
exports.ToolCall = require_message.ToolCall;
|
|
4823
4824
|
exports.TruncatedError = require_errors.TruncatedError;
|
|
4824
4825
|
exports.UnsupportedError = require_errors.UnsupportedError;
|
|
4825
4826
|
exports.VERSION = require_version.VERSION;
|
|
@@ -4840,8 +4841,8 @@ exports.fileSearch = require_version.fileSearch;
|
|
|
4840
4841
|
exports.flushObservability = require_observability.flushObservability;
|
|
4841
4842
|
exports.googleMaps = require_version.googleMaps;
|
|
4842
4843
|
exports.hitCopy = hitCopy;
|
|
4843
|
-
exports.imageBase64 =
|
|
4844
|
-
exports.imageDataUri =
|
|
4844
|
+
exports.imageBase64 = require_message.imageBase64;
|
|
4845
|
+
exports.imageDataUri = require_message.imageDataUri;
|
|
4845
4846
|
exports.imageGeneration = require_version.imageGeneration;
|
|
4846
4847
|
exports.imageSize = imageSize;
|
|
4847
4848
|
exports.isInstanceOfAny = require_errors.isInstanceOfAny;
|
|
@@ -4868,7 +4869,7 @@ exports.runAgent = require_client.runAgent;
|
|
|
4868
4869
|
exports.splitMcp = require_client.splitMcp;
|
|
4869
4870
|
exports.splitTools = require_version.splitTools;
|
|
4870
4871
|
exports.stepBack = stepBack;
|
|
4871
|
-
exports.textPart =
|
|
4872
|
+
exports.textPart = require_message.textPart;
|
|
4872
4873
|
exports.toParts = require_files.toParts;
|
|
4873
4874
|
exports.toTool = require_version.toTool;
|
|
4874
4875
|
exports.tool = require_version.tool;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { $ as Embedder, A as BadRequestError, B as ProviderError, C as GuardResult, D as APIConnectionError, E as ScopeGuardOptions, F as LLMErrorClass, G as TruncatedError, H as SchemaValidationError, I as LLMErrorOptions, J as isInstanceOfAny, K as UnsupportedError, L as NotFoundError, M as ErrorCategory, N as GuardrailError, O as APITimeoutError, P as LLMError, Q as CacheScope, R as OutputValidationError, S as registerProfile, T as ScopeGuard, U as ServerError, V as RateLimitError, W as TRANSIENT, X as Debugger, Y as DebugSink, Z as Cache, _ as Params, a as EmbeddingVectors, b as applyProfile, c as LLMOptions, d as TemplateContext, et as ExactCache, f as TemplateError, g as ProviderOptions, h as ProviderClass, i as EmbedOptions, j as DEFAULT_FAILOVER, k as AuthError, l as REMOVE, m as Provider, n as CompleteInput, nt as hitCopy, o as ImageInput, p as CallOptions, q as classify, r as DEFAULT_MAX_TOKENS, s as LLM, t as CallInput, tt as SemanticCache, u as Template, v as Profile, w as Guardrail, x as registerAlias, y as ProfileTransform, z as OverloadedError } from "./client-
|
|
2
|
-
import { C as mcpTools, D as toolResultText, T as splitMcp, a as MCPServerInit, g as McpToolSource, i as MCPServer, n as MCPClient, r as MCPClientOptions, t as AgentCompletion, w as runAgent, y as RunAgentOptions } from "./client-
|
|
3
|
-
import {
|
|
1
|
+
import { $ as Embedder, A as BadRequestError, B as ProviderError, C as GuardResult, D as APIConnectionError, E as ScopeGuardOptions, F as LLMErrorClass, G as TruncatedError, H as SchemaValidationError, I as LLMErrorOptions, J as isInstanceOfAny, K as UnsupportedError, L as NotFoundError, M as ErrorCategory, N as GuardrailError, O as APITimeoutError, P as LLMError, Q as CacheScope, R as OutputValidationError, S as registerProfile, T as ScopeGuard, U as ServerError, V as RateLimitError, W as TRANSIENT, X as Debugger, Y as DebugSink, Z as Cache, _ as Params, a as EmbeddingVectors, b as applyProfile, c as LLMOptions, d as TemplateContext, et as ExactCache, f as TemplateError, g as ProviderOptions, h as ProviderClass, i as EmbedOptions, j as DEFAULT_FAILOVER, k as AuthError, l as REMOVE, m as Provider, n as CompleteInput, nt as hitCopy, o as ImageInput, p as CallOptions, q as classify, r as DEFAULT_MAX_TOKENS, s as LLM, t as CallInput, tt as SemanticCache, u as Template, v as Profile, w as Guardrail, x as registerAlias, y as ProfileTransform, z as OverloadedError } from "./client-voHjPm-f.cjs";
|
|
2
|
+
import { C as mcpTools, D as toolResultText, T as splitMcp, a as MCPServerInit, g as McpToolSource, i as MCPServer, n as MCPClient, r as MCPClientOptions, t as AgentCompletion, w as runAgent, y as RunAgentOptions } from "./client-BcJnFY-A.cjs";
|
|
3
|
+
import { C as ToolCallPart, D as imageDataUri, E as imageBase64, O as textPart, S as ToolCall, T as Usage, _ as OCRResult, a as Completion, b as StreamEvent, c as ContentPart, d as Image, f as ImagePart, g as OCRPage, h as OCRImage, i as Citation, l as EmbeddingResult, m as Metadata, n as AudioOptions, o as CompletionInit, p as Message, r as AudioPart, s as Content, t as Audio, u as FinishReason, v as Role, w as ToolResultPart, x as TextPart, y as ServerToolCall } from "./message-D3MSjqww.cjs";
|
|
4
4
|
import { C as googleMaps, D as urlContext, E as nativeTool, O as webFetch, S as fileSearch, T as isNative, _ as ProviderOverrides, a as ToolSpec, b as codeExecution, c as toTool, d as ComputerUseOptions, f as FileSearchOptions, g as NativeToolKind, h as NativeTool, i as ToolDefinition, k as webSearch, l as tool, m as NATIVE_TOOL_KINDS, n as ToolAnnotations, o as normalizeTools, p as GoogleMapsOptions, r as ToolContext, s as splitTools, t as Tool, u as CodeExecutionOptions, v as WebFetchOptions, w as imageGeneration, x as computerUse, y as WebSearchOptions } from "./tools-DjzQr-Np.cjs";
|
|
5
|
+
import { a as flushObservability, c as Document, d as DocumentOptions, f as FileInput, i as feedback, l as DocumentError, n as ObservabilitySession, o as observabilitySession, p as toParts, r as droppedCount, s as DEFAULT_MAX_PDF_PAGES, t as FeedbackOptions, u as DocumentMode } from "./observability-Cy4ewtvC.cjs";
|
|
5
6
|
import { a as StandardSchemaLike, i as SchemaSpec, n as JsonSchemaSpec, o as jsonSchema, r as ResolvedSchema, s as resolveSchema, t as InferSchema } from "./schema-BBiyhRZk.cjs";
|
|
6
7
|
import { i as requestHeaders, n as McpRequestContext, r as currentUser } from "./context-DN___2Xb.cjs";
|
|
7
8
|
/** O mínimo que a `RAGMemory` usa de um RAG. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { $ as Embedder, A as BadRequestError, B as ProviderError, C as GuardResult, D as APIConnectionError, E as ScopeGuardOptions, F as LLMErrorClass, G as TruncatedError, H as SchemaValidationError, I as LLMErrorOptions, J as isInstanceOfAny, K as UnsupportedError, L as NotFoundError, M as ErrorCategory, N as GuardrailError, O as APITimeoutError, P as LLMError, Q as CacheScope, R as OutputValidationError, S as registerProfile, T as ScopeGuard, U as ServerError, V as RateLimitError, W as TRANSIENT, X as Debugger, Y as DebugSink, Z as Cache, _ as Params, a as EmbeddingVectors, b as applyProfile, c as LLMOptions, d as TemplateContext, et as ExactCache, f as TemplateError, g as ProviderOptions, h as ProviderClass, i as EmbedOptions, j as DEFAULT_FAILOVER, k as AuthError, l as REMOVE, m as Provider, n as CompleteInput, nt as hitCopy, o as ImageInput, p as CallOptions, q as classify, r as DEFAULT_MAX_TOKENS, s as LLM, t as CallInput, tt as SemanticCache, u as Template, v as Profile, w as Guardrail, x as registerAlias, y as ProfileTransform, z as OverloadedError } from "./client-
|
|
2
|
-
import { C as mcpTools, D as toolResultText, T as splitMcp, a as MCPServerInit, g as McpToolSource, i as MCPServer, n as MCPClient, r as MCPClientOptions, t as AgentCompletion, w as runAgent, y as RunAgentOptions } from "./client-
|
|
3
|
-
import {
|
|
1
|
+
import { $ as Embedder, A as BadRequestError, B as ProviderError, C as GuardResult, D as APIConnectionError, E as ScopeGuardOptions, F as LLMErrorClass, G as TruncatedError, H as SchemaValidationError, I as LLMErrorOptions, J as isInstanceOfAny, K as UnsupportedError, L as NotFoundError, M as ErrorCategory, N as GuardrailError, O as APITimeoutError, P as LLMError, Q as CacheScope, R as OutputValidationError, S as registerProfile, T as ScopeGuard, U as ServerError, V as RateLimitError, W as TRANSIENT, X as Debugger, Y as DebugSink, Z as Cache, _ as Params, a as EmbeddingVectors, b as applyProfile, c as LLMOptions, d as TemplateContext, et as ExactCache, f as TemplateError, g as ProviderOptions, h as ProviderClass, i as EmbedOptions, j as DEFAULT_FAILOVER, k as AuthError, l as REMOVE, m as Provider, n as CompleteInput, nt as hitCopy, o as ImageInput, p as CallOptions, q as classify, r as DEFAULT_MAX_TOKENS, s as LLM, t as CallInput, tt as SemanticCache, u as Template, v as Profile, w as Guardrail, x as registerAlias, y as ProfileTransform, z as OverloadedError } from "./client-G7gJaq6H.js";
|
|
2
|
+
import { C as mcpTools, D as toolResultText, T as splitMcp, a as MCPServerInit, g as McpToolSource, i as MCPServer, n as MCPClient, r as MCPClientOptions, t as AgentCompletion, w as runAgent, y as RunAgentOptions } from "./client-gwTD3MxV.js";
|
|
3
|
+
import { C as ToolCallPart, D as imageDataUri, E as imageBase64, O as textPart, S as ToolCall, T as Usage, _ as OCRResult, a as Completion, b as StreamEvent, c as ContentPart, d as Image, f as ImagePart, g as OCRPage, h as OCRImage, i as Citation, l as EmbeddingResult, m as Metadata, n as AudioOptions, o as CompletionInit, p as Message, r as AudioPart, s as Content, t as Audio, u as FinishReason, v as Role, w as ToolResultPart, x as TextPart, y as ServerToolCall } from "./message-D3MSjqww.js";
|
|
4
4
|
import { C as googleMaps, D as urlContext, E as nativeTool, O as webFetch, S as fileSearch, T as isNative, _ as ProviderOverrides, a as ToolSpec, b as codeExecution, c as toTool, d as ComputerUseOptions, f as FileSearchOptions, g as NativeToolKind, h as NativeTool, i as ToolDefinition, k as webSearch, l as tool, m as NATIVE_TOOL_KINDS, n as ToolAnnotations, o as normalizeTools, p as GoogleMapsOptions, r as ToolContext, s as splitTools, t as Tool, u as CodeExecutionOptions, v as WebFetchOptions, w as imageGeneration, x as computerUse, y as WebSearchOptions } from "./tools-4-yoaMWI.js";
|
|
5
|
+
import { a as flushObservability, c as Document, d as DocumentOptions, f as FileInput, i as feedback, l as DocumentError, n as ObservabilitySession, o as observabilitySession, p as toParts, r as droppedCount, s as DEFAULT_MAX_PDF_PAGES, t as FeedbackOptions, u as DocumentMode } from "./observability-DSlDuE1w.js";
|
|
5
6
|
import { a as StandardSchemaLike, i as SchemaSpec, n as JsonSchemaSpec, o as jsonSchema, r as ResolvedSchema, s as resolveSchema, t as InferSchema } from "./schema-BBiyhRZk.js";
|
|
6
7
|
import { i as requestHeaders, n as McpRequestContext, r as currentUser } from "./context-DN___2Xb.js";
|
|
7
8
|
/** O mínimo que a `RAGMemory` usa de um RAG. */
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { a as mcpTools, l as toolResultText, n as MCPServer, o as runAgent, s as splitMcp, t as MCPClient } from "./client-
|
|
2
|
-
import {
|
|
3
|
-
import { _ as webFetch, a as toTool, c as NativeTool, d as fileSearch, f as googleMaps, g as urlContext, h as nativeTool, i as splitTools, l as codeExecution, m as isNative, n as Tool, o as tool, p as imageGeneration, r as normalizeTools, s as NATIVE_TOOL_KINDS, t as VERSION, u as computerUse, v as webSearch } from "./version-
|
|
1
|
+
import { a as mcpTools, l as toolResultText, n as MCPServer, o as runAgent, s as splitMcp, t as MCPClient } from "./client-BALmyl1D.js";
|
|
2
|
+
import { a as ToolCall, c as textPart, i as Message, l as bytesToBase64, n as Completion, o as imageBase64, r as Image, s as imageDataUri, t as Audio } from "./message-0wKCrEp2.js";
|
|
3
|
+
import { _ as webFetch, a as toTool, c as NativeTool, d as fileSearch, f as googleMaps, g as urlContext, h as nativeTool, i as splitTools, l as codeExecution, m as isNative, n as Tool, o as tool, p as imageGeneration, r as normalizeTools, s as NATIVE_TOOL_KINDS, t as VERSION, u as computerUse, v as webSearch } from "./version-DgKb-29E.js";
|
|
4
4
|
import { n as parseJsonText, r as resolveSchema, t as jsonSchema } from "./schema-DCaQOk49.js";
|
|
5
5
|
import { _ as UnsupportedError, a as DEFAULT_FAILOVER, c as NotFoundError, d as ProviderError, f as RateLimitError, g as TruncatedError, h as TRANSIENT, i as BadRequestError, l as OutputValidationError, m as ServerError, n as APITimeoutError, o as GuardrailError, p as SchemaValidationError, r as AuthError, s as LLMError, t as APIConnectionError, u as OverloadedError, v as classify, y as isInstanceOfAny } from "./errors-hp-4UePr.js";
|
|
6
6
|
import { i as toParts, n as Document, r as DocumentError, t as DEFAULT_MAX_PDF_PAGES } from "./files-lcQv3hAq.js";
|
|
7
7
|
import { a as feedback, i as droppedCount, l as summarizeInput, n as autoReportError, o as flushObservability, r as detectCapabilities, s as observabilitySession, t as autoReport } from "./observability-DQW4up31.js";
|
|
8
8
|
import { n as getEnv, t as envFlag } from "./env-BH4ulZ4_.js";
|
|
9
|
+
import { i as requestHeaders, n as currentUser, o as warn } from "./context-CvNVqdqz.js";
|
|
9
10
|
import { t as cleanGeminiSchema } from "./gemini-schema-BLKtypnG.js";
|
|
10
|
-
import { i as registerProfile, n as applyProfile, r as registerAlias, t as Provider } from "./base-
|
|
11
|
+
import { i as registerProfile, n as applyProfile, r as registerAlias, t as Provider } from "./base-B9vWogrC.js";
|
|
11
12
|
// src/providers/registry.ts
|
|
12
13
|
const REGISTRY = /* @__PURE__ */ new Map();
|
|
13
14
|
/** Registra (ou sobrescreve) um provider. */
|
|
@@ -32,17 +33,17 @@ function availableProviders() {
|
|
|
32
33
|
* Registro dos providers embutidos. O módulo de cada adapter só é carregado quando
|
|
33
34
|
* o provider é usado; o SDK, só quando o cliente é criado.
|
|
34
35
|
*/
|
|
35
|
-
registerProvider("openai", async () => (await import("./openai-compat-
|
|
36
|
-
registerProvider("azure", async () => (await import("./openai-compat-
|
|
37
|
-
registerProvider("groq", async () => (await import("./openai-compat-
|
|
38
|
-
registerProvider("openrouter", async () => (await import("./openai-compat-
|
|
39
|
-
registerProvider("deepseek", async () => (await import("./openai-compat-
|
|
40
|
-
registerProvider("anthropic", async () => (await import("./anthropic-
|
|
41
|
-
registerProvider("gemini", async () => (await import("./gemini-
|
|
42
|
-
registerProvider("vertex", async () => (await import("./gemini-
|
|
43
|
-
registerProvider("ollama", async () => (await import("./ollama-
|
|
44
|
-
registerProvider("bedrock", async () => (await import("./bedrock-
|
|
45
|
-
registerProvider("mistral", async () => (await import("./mistral-
|
|
36
|
+
registerProvider("openai", async () => (await import("./openai-compat-CJRRaqmi.js")).OpenAIProvider);
|
|
37
|
+
registerProvider("azure", async () => (await import("./openai-compat-CJRRaqmi.js")).AzureOpenAIProvider);
|
|
38
|
+
registerProvider("groq", async () => (await import("./openai-compat-CJRRaqmi.js")).GroqProvider);
|
|
39
|
+
registerProvider("openrouter", async () => (await import("./openai-compat-CJRRaqmi.js")).OpenRouterProvider);
|
|
40
|
+
registerProvider("deepseek", async () => (await import("./openai-compat-CJRRaqmi.js")).DeepSeekProvider);
|
|
41
|
+
registerProvider("anthropic", async () => (await import("./anthropic-BIKZUdHL.js")).AnthropicProvider);
|
|
42
|
+
registerProvider("gemini", async () => (await import("./gemini-VIK6GzRx.js")).GeminiProvider);
|
|
43
|
+
registerProvider("vertex", async () => (await import("./gemini-VIK6GzRx.js")).VertexProvider);
|
|
44
|
+
registerProvider("ollama", async () => (await import("./ollama-CtOa_75e.js")).OllamaProvider);
|
|
45
|
+
registerProvider("bedrock", async () => (await import("./bedrock-oWZQlwCt.js")).BedrockProvider);
|
|
46
|
+
registerProvider("mistral", async () => (await import("./mistral-rbVDtlHt.js")).MistralProvider);
|
|
46
47
|
// src/agents.ts
|
|
47
48
|
/** Memória de longo prazo sobre um RAG: `recall` busca; `remember` indexa. Best-effort. */
|
|
48
49
|
var RAGMemory = class {
|
|
@@ -4339,7 +4340,7 @@ var GeminiInteractions = class GeminiInteractions {
|
|
|
4339
4340
|
* lib não puxa o adapter para o bundle principal.
|
|
4340
4341
|
*/
|
|
4341
4342
|
provider() {
|
|
4342
|
-
this.providerPromise ??= import("./gemini-
|
|
4343
|
+
this.providerPromise ??= import("./gemini-VIK6GzRx.js").then((m) => {
|
|
4343
4344
|
const Base = this.options.vertexai ? m.VertexProvider : m.GeminiProvider;
|
|
4344
4345
|
class Interactions extends Base {
|
|
4345
4346
|
nativeClient() {
|
|
@@ -4366,7 +4367,7 @@ var GeminiInteractions = class GeminiInteractions {
|
|
|
4366
4367
|
}
|
|
4367
4368
|
async api() {
|
|
4368
4369
|
const api = get(await (await this.provider()).nativeClient(), "interactions");
|
|
4369
|
-
if (!api) throw new UnsupportedError("a Interactions API exige
|
|
4370
|
+
if (!api) throw new UnsupportedError("a Interactions API exige @google/genai 1.33 ou mais novo (client.interactions): atualize com `npm install @google/genai@latest`.", { provider: PROVIDER$1 });
|
|
4370
4371
|
return api;
|
|
4371
4372
|
}
|
|
4372
4373
|
static err(e, signal, request = false) {
|
package/dist/mcp/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_client = require("../client-
|
|
3
|
-
const require_server = require("../server-
|
|
4
|
-
const require_context = require("../context-
|
|
2
|
+
const require_client = require("../client-Bb1r1q6G.cjs");
|
|
3
|
+
const require_server = require("../server-uzd_KbIF.cjs");
|
|
4
|
+
const require_context = require("../context-BWyYfOyr.cjs");
|
|
5
5
|
exports.CodeMode = require_server.CodeMode;
|
|
6
6
|
exports.DEFAULT_LIMITS = require_server.DEFAULT_LIMITS;
|
|
7
7
|
exports.MCPClient = require_client.MCPClient;
|
package/dist/mcp/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as mcpTools, D as toolResultText, E as toRoot, O as toolSourceFromSession, S as mcpContentToParts, T as splitMcp, _ as RequireApproval, a as MCPServerInit, b as ToolTraceEntry, c as McpGetPromptResult, d as McpRequestOptions, f as McpResourceInfo, g as McpToolSource, h as McpToolInfo, i as MCPServer, l as McpPromptInfo, m as McpSamplingParams, n as MCPClient, o as McpCallToolResult, p as McpRoot, r as MCPClientOptions, s as McpContentBlock, t as AgentCompletion, u as McpReadResourceResult, v as RootInput, w as runAgent, x as makeSamplingHandler, y as RunAgentOptions } from "../client-
|
|
1
|
+
import { C as mcpTools, D as toolResultText, E as toRoot, O as toolSourceFromSession, S as mcpContentToParts, T as splitMcp, _ as RequireApproval, a as MCPServerInit, b as ToolTraceEntry, c as McpGetPromptResult, d as McpRequestOptions, f as McpResourceInfo, g as McpToolSource, h as McpToolInfo, i as MCPServer, l as McpPromptInfo, m as McpSamplingParams, n as MCPClient, o as McpCallToolResult, p as McpRoot, r as MCPClientOptions, s as McpContentBlock, t as AgentCompletion, u as McpReadResourceResult, v as RootInput, w as runAgent, x as makeSamplingHandler, y as RunAgentOptions } from "../client-BcJnFY-A.cjs";
|
|
2
2
|
import { a as McpServerOptions, c as CodeMode, d as CodeModeOptions, f as DEFAULT_LIMITS, g as ToolFilter, h as ToolDescription, i as McpServerInstance, l as CodeModeDetail, m as asCodeMode, n as McpHandlerOptions, o as buildMcpHandler, p as QuickJSModuleLike, r as McpIcon, s as buildMcpServer, t as McpHandler, u as CodeModeLimits } from "../server-C8hINWgp.cjs";
|
|
3
3
|
import { i as requestHeaders, n as McpRequestContext, r as currentUser, t as CurrentUser } from "../context-DN___2Xb.cjs";
|
|
4
4
|
export { AgentCompletion, CodeMode, type CodeModeDetail, type CodeModeLimits, type CodeModeOptions, type CurrentUser, DEFAULT_LIMITS, MCPClient, MCPClientOptions, MCPServer, MCPServerInit, McpCallToolResult, McpContentBlock, McpGetPromptResult, type McpHandler, type McpHandlerOptions, type McpIcon, McpPromptInfo, McpReadResourceResult, type McpRequestContext, McpRequestOptions, McpResourceInfo, McpRoot, McpSamplingParams, type McpServerInstance, type McpServerOptions, McpToolInfo, McpToolSource, type QuickJSModuleLike, RequireApproval, RootInput, RunAgentOptions, type ToolDescription, type ToolFilter, ToolTraceEntry, asCodeMode, buildMcpHandler, buildMcpServer, currentUser, makeSamplingHandler, mcpContentToParts, mcpTools, requestHeaders, runAgent, splitMcp, toRoot, toolResultText, toolSourceFromSession };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as mcpTools, D as toolResultText, E as toRoot, O as toolSourceFromSession, S as mcpContentToParts, T as splitMcp, _ as RequireApproval, a as MCPServerInit, b as ToolTraceEntry, c as McpGetPromptResult, d as McpRequestOptions, f as McpResourceInfo, g as McpToolSource, h as McpToolInfo, i as MCPServer, l as McpPromptInfo, m as McpSamplingParams, n as MCPClient, o as McpCallToolResult, p as McpRoot, r as MCPClientOptions, s as McpContentBlock, t as AgentCompletion, u as McpReadResourceResult, v as RootInput, w as runAgent, x as makeSamplingHandler, y as RunAgentOptions } from "../client-
|
|
1
|
+
import { C as mcpTools, D as toolResultText, E as toRoot, O as toolSourceFromSession, S as mcpContentToParts, T as splitMcp, _ as RequireApproval, a as MCPServerInit, b as ToolTraceEntry, c as McpGetPromptResult, d as McpRequestOptions, f as McpResourceInfo, g as McpToolSource, h as McpToolInfo, i as MCPServer, l as McpPromptInfo, m as McpSamplingParams, n as MCPClient, o as McpCallToolResult, p as McpRoot, r as MCPClientOptions, s as McpContentBlock, t as AgentCompletion, u as McpReadResourceResult, v as RootInput, w as runAgent, x as makeSamplingHandler, y as RunAgentOptions } from "../client-gwTD3MxV.js";
|
|
2
2
|
import { a as McpServerOptions, c as CodeMode, d as CodeModeOptions, f as DEFAULT_LIMITS, g as ToolFilter, h as ToolDescription, i as McpServerInstance, l as CodeModeDetail, m as asCodeMode, n as McpHandlerOptions, o as buildMcpHandler, p as QuickJSModuleLike, r as McpIcon, s as buildMcpServer, t as McpHandler, u as CodeModeLimits } from "../server-B_XDzBbl.js";
|
|
3
3
|
import { i as requestHeaders, n as McpRequestContext, r as currentUser, t as CurrentUser } from "../context-DN___2Xb.js";
|
|
4
4
|
export { AgentCompletion, CodeMode, type CodeModeDetail, type CodeModeLimits, type CodeModeOptions, type CurrentUser, DEFAULT_LIMITS, MCPClient, MCPClientOptions, MCPServer, MCPServerInit, McpCallToolResult, McpContentBlock, McpGetPromptResult, type McpHandler, type McpHandlerOptions, type McpIcon, McpPromptInfo, McpReadResourceResult, type McpRequestContext, McpRequestOptions, McpResourceInfo, McpRoot, McpSamplingParams, type McpServerInstance, type McpServerOptions, McpToolInfo, McpToolSource, type QuickJSModuleLike, RequireApproval, RootInput, RunAgentOptions, type ToolDescription, type ToolFilter, ToolTraceEntry, asCodeMode, buildMcpHandler, buildMcpServer, currentUser, makeSamplingHandler, mcpContentToParts, mcpTools, requestHeaders, runAgent, splitMcp, toRoot, toolResultText, toolSourceFromSession };
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as mcpTools, c as toRoot, i as mcpContentToParts, l as toolResultText, n as MCPServer, o as runAgent, r as makeSamplingHandler, s as splitMcp, t as MCPClient, u as toolSourceFromSession } from "../client-
|
|
2
|
-
import { a as asCodeMode, i as DEFAULT_LIMITS, n as buildMcpServer, r as CodeMode, t as buildMcpHandler } from "../server-
|
|
3
|
-
import { i as requestHeaders, n as currentUser } from "../context-
|
|
1
|
+
import { a as mcpTools, c as toRoot, i as mcpContentToParts, l as toolResultText, n as MCPServer, o as runAgent, r as makeSamplingHandler, s as splitMcp, t as MCPClient, u as toolSourceFromSession } from "../client-BALmyl1D.js";
|
|
2
|
+
import { a as asCodeMode, i as DEFAULT_LIMITS, n as buildMcpServer, r as CodeMode, t as buildMcpHandler } from "../server-q2tlgVLB.js";
|
|
3
|
+
import { i as requestHeaders, n as currentUser } from "../context-CvNVqdqz.js";
|
|
4
4
|
export { CodeMode, DEFAULT_LIMITS, MCPClient, MCPServer, asCodeMode, buildMcpHandler, buildMcpServer, currentUser, makeSamplingHandler, mcpContentToParts, mcpTools, requestHeaders, runAgent, splitMcp, toRoot, toolResultText, toolSourceFromSession };
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
// src/internal/warn.ts
|
|
2
|
-
/** Aviso não fatal da lib (equivalente ao `warnings.warn` do Python). */
|
|
3
|
-
function warn(message) {
|
|
4
|
-
const proc = globalThis.process;
|
|
5
|
-
if (typeof proc?.emitWarning === "function") proc.emitWarning(message, "JangadaWarning");
|
|
6
|
-
else console.warn(`JangadaWarning: ${message}`);
|
|
7
|
-
}
|
|
8
1
|
// src/internal/base64.ts
|
|
9
2
|
/**
|
|
10
3
|
* Base64 sem `Buffer`, para rodar igual em Node, Bun, Deno e edge.
|
|
@@ -203,97 +196,4 @@ var Completion = class {
|
|
|
203
196
|
return this.text;
|
|
204
197
|
}
|
|
205
198
|
};
|
|
206
|
-
|
|
207
|
-
function findStorage() {
|
|
208
|
-
const g = globalThis;
|
|
209
|
-
let Ctor;
|
|
210
|
-
try {
|
|
211
|
-
Ctor = (g.process?.getBuiltinModule?.("node:async_hooks"))?.AsyncLocalStorage;
|
|
212
|
-
} catch {}
|
|
213
|
-
Ctor ??= g.AsyncLocalStorage;
|
|
214
|
-
if (typeof Ctor !== "function") return void 0;
|
|
215
|
-
try {
|
|
216
|
-
return new Ctor();
|
|
217
|
-
} catch {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
const storage = findStorage();
|
|
222
|
-
/** Contexto vazio (stdio, ou chamada fora de uma requisição). */
|
|
223
|
-
const EMPTY_CONTEXT = Object.freeze({ headers: Object.freeze({}) });
|
|
224
|
-
/** Roda `fn` com `ctx` como contexto atual (quando há `AsyncLocalStorage`). */
|
|
225
|
-
function runWithRequestContext(ctx, fn) {
|
|
226
|
-
return storage ? storage.run(ctx, fn) : fn();
|
|
227
|
-
}
|
|
228
|
-
function ambient() {
|
|
229
|
-
return storage?.getStore();
|
|
230
|
-
}
|
|
231
|
-
/** Normaliza headers (Headers, objeto ou pares) em objeto com nomes minúsculos. */
|
|
232
|
-
function normalizeHeaders(headers) {
|
|
233
|
-
const out = {};
|
|
234
|
-
if (!headers || typeof headers !== "object") return out;
|
|
235
|
-
try {
|
|
236
|
-
if (typeof headers.forEach === "function" && !Array.isArray(headers)) {
|
|
237
|
-
headers.forEach((v, k) => {
|
|
238
|
-
out[k.toLowerCase()] = v;
|
|
239
|
-
});
|
|
240
|
-
return out;
|
|
241
|
-
}
|
|
242
|
-
const entries = Array.isArray(headers) ? headers : Object.entries(headers);
|
|
243
|
-
for (const [k, v] of entries) {
|
|
244
|
-
if (v === void 0 || v === null) continue;
|
|
245
|
-
out[String(k).toLowerCase()] = Array.isArray(v) ? v.join(", ") : String(v);
|
|
246
|
-
}
|
|
247
|
-
} catch {}
|
|
248
|
-
return out;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Headers HTTP da chamada MCP atual (nomes em minúsculas).
|
|
252
|
-
*
|
|
253
|
-
* Vazio fora de uma chamada (ex.: no stdio, que não tem HTTP) e em runtimes sem
|
|
254
|
-
* `AsyncLocalStorage`, a menos que você passe o `ctx` recebido pela tool. Vale
|
|
255
|
-
* dentro das tools, do `toolFilter` e do `toolDescription`.
|
|
256
|
-
*/
|
|
257
|
-
function requestHeaders(ctx) {
|
|
258
|
-
return { ...(ctx ?? ambient())?.headers ?? {} };
|
|
259
|
-
}
|
|
260
|
-
function decodeClaims(raw) {
|
|
261
|
-
if (!raw) return null;
|
|
262
|
-
try {
|
|
263
|
-
const b64 = raw.replace(/-/g, "+").replace(/_/g, "/");
|
|
264
|
-
const padded = b64 + "=".repeat((4 - b64.length % 4) % 4);
|
|
265
|
-
const bin = atob(padded);
|
|
266
|
-
const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));
|
|
267
|
-
return JSON.parse(new TextDecoder().decode(bytes));
|
|
268
|
-
} catch {
|
|
269
|
-
return null;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
function decodeName(raw) {
|
|
273
|
-
try {
|
|
274
|
-
return decodeURIComponent(raw);
|
|
275
|
-
} catch {
|
|
276
|
-
return raw;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Identidade de quem chamou, lida dos headers `x-jangada-user-*`.
|
|
281
|
-
*
|
|
282
|
-
* `null` quando não há usuário: modo Token do jangada Cloud, servidor fora do
|
|
283
|
-
* jangada Cloud ou transporte stdio. Os headers `x-jangada-*` só são confiáveis
|
|
284
|
-
* atrás do gateway do jangada Cloud (ele remove os que vêm do cliente); num
|
|
285
|
-
* servidor exposto direto, qualquer um poderia mandá-los.
|
|
286
|
-
*/
|
|
287
|
-
function currentUser(ctx) {
|
|
288
|
-
const h = (ctx ?? ambient())?.headers ?? {};
|
|
289
|
-
const id = h["x-jangada-user-id"];
|
|
290
|
-
if (!id) return null;
|
|
291
|
-
const name = h["x-jangada-user-name"];
|
|
292
|
-
return {
|
|
293
|
-
id,
|
|
294
|
-
email: h["x-jangada-user-email"] || null,
|
|
295
|
-
name: name ? decodeName(name) : null,
|
|
296
|
-
claims: decodeClaims(h["x-jangada-claims"])
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
export { runWithRequestContext as a, Image as c, imageBase64 as d, imageDataUri as f, warn as h, requestHeaders as i, Message as l, bytesToBase64 as m, currentUser as n, Audio as o, textPart as p, normalizeHeaders as r, Completion as s, EMPTY_CONTEXT as t, ToolCall as u };
|
|
199
|
+
export { ToolCall as a, textPart as c, Message as i, bytesToBase64 as l, Completion as n, imageBase64 as o, Image as r, imageDataUri as s, Audio as t };
|
|
@@ -224,83 +224,4 @@ interface EmbeddingResult {
|
|
|
224
224
|
usage?: Usage | null;
|
|
225
225
|
raw?: unknown;
|
|
226
226
|
}
|
|
227
|
-
|
|
228
|
-
/** Falha ao extrair um documento (formato, dependência ou conteúdo). */
|
|
229
|
-
declare class DocumentError extends Error {
|
|
230
|
-
constructor(message: string, options?: {
|
|
231
|
-
cause?: unknown;
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
/** Páginas renderizadas por padrão num PDF em `mode: "vision"` (custo de imagem cresce rápido). */
|
|
235
|
-
declare const DEFAULT_MAX_PDF_PAGES = 20;
|
|
236
|
-
interface DocumentOptions {
|
|
237
|
-
/** Nome do arquivo (a extensão define o formato). Sem nome, o formato é deduzido pelo conteúdo. */
|
|
238
|
-
name?: string;
|
|
239
|
-
mimeType?: string;
|
|
240
|
-
mode?: DocumentMode;
|
|
241
|
-
/** Limite de linhas em CSV/XLSX. */
|
|
242
|
-
maxRows?: number;
|
|
243
|
-
/** Limite de páginas renderizadas em PDF com `mode: "vision"`. */
|
|
244
|
-
maxPages?: number;
|
|
245
|
-
}
|
|
246
|
-
/** Um arquivo a anexar à mensagem (`files: [...]`). */
|
|
247
|
-
declare class Document {
|
|
248
|
-
readonly data: Uint8Array;
|
|
249
|
-
readonly name: string | undefined;
|
|
250
|
-
readonly mimeType: string | undefined;
|
|
251
|
-
readonly mode: DocumentMode;
|
|
252
|
-
readonly maxRows: number | undefined;
|
|
253
|
-
readonly maxPages: number | undefined;
|
|
254
|
-
constructor(data: Uint8Array | ArrayBuffer, options?: DocumentOptions);
|
|
255
|
-
get ext(): string;
|
|
256
|
-
get label(): string;
|
|
257
|
-
}
|
|
258
|
-
/** Qualquer coisa aceita em `files: [...]`. */
|
|
259
|
-
type FileInput = Document | TextPart | ImagePart | Uint8Array | ArrayBuffer;
|
|
260
|
-
/**
|
|
261
|
-
* Converte um arquivo em partes da mensagem: texto extraído ou imagem(ns). Um PDF
|
|
262
|
-
* em `mode: "vision"` vira uma imagem por página. É aqui que se decide vision vs.
|
|
263
|
-
* texto; nenhum formato de documento chega aos adapters.
|
|
264
|
-
*/
|
|
265
|
-
declare function toParts(item: FileInput): Promise<ContentPart[]>;
|
|
266
|
-
/** Um lote (trace): as chamadas com a mesma sessão viram observations do mesmo trace. */
|
|
267
|
-
interface ObservabilitySession {
|
|
268
|
-
readonly id: string;
|
|
269
|
-
name?: string;
|
|
270
|
-
userId?: string;
|
|
271
|
-
sessionId?: string;
|
|
272
|
-
metadata?: Record<string, unknown>;
|
|
273
|
-
/** Credenciais só desta sessão (multi-tenant: uma chave por empresa no mesmo processo). */
|
|
274
|
-
apiKey?: string;
|
|
275
|
-
endpoint?: string;
|
|
276
|
-
/** Prompt do registry que gerou as chamadas (preenchido por `PromptVersion`). */
|
|
277
|
-
prompt?: {
|
|
278
|
-
name: string;
|
|
279
|
-
version: number;
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
/** Cria uma sessão (lote). Passe-a em `{ trace: sessao }` nas chamadas. */
|
|
283
|
-
declare function observabilitySession(options?: Omit<ObservabilitySession, "id"> & {
|
|
284
|
-
id?: string;
|
|
285
|
-
}): ObservabilitySession;
|
|
286
|
-
/** Quantos eventos foram descartados por excesso de envios pendentes. */
|
|
287
|
-
declare function droppedCount(): number;
|
|
288
|
-
/**
|
|
289
|
-
* Espera os envios pendentes terminarem (com prazo). Em serverless, chame antes de
|
|
290
|
-
* devolver a resposta, senão o último trace pode se perder. Nunca lança.
|
|
291
|
-
*/
|
|
292
|
-
declare function flushObservability(timeoutMs?: number): Promise<void>;
|
|
293
|
-
interface FeedbackOptions {
|
|
294
|
-
name?: string;
|
|
295
|
-
comment?: string;
|
|
296
|
-
apiKey?: string;
|
|
297
|
-
endpoint?: string;
|
|
298
|
-
timeoutMs?: number;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Feedback de produção para um trace (👍 = 1, 👎 = -1 ou 0). Best-effort: devolve
|
|
302
|
-
* `false` se faltou chave ou a rede falhou; nunca lança. Em multi-tenant, passe a
|
|
303
|
-
* chave do tenant dono do trace.
|
|
304
|
-
*/
|
|
305
|
-
declare function feedback(traceId: string, value: number, options?: FeedbackOptions): Promise<boolean>;
|
|
306
|
-
export { OCRResult as A, imageDataUri as B, FinishReason as C, Metadata as D, Message as E, ToolCall as F, ToolCallPart as I, ToolResultPart as L, ServerToolCall as M, StreamEvent as N, OCRImage as O, TextPart as P, Usage as R, EmbeddingResult as S, ImagePart as T, textPart as V, Citation as _, flushObservability as a, Content as b, Document as c, DocumentOptions as d, FileInput as f, AudioPart as g, AudioOptions as h, feedback as i, Role as j, OCRPage as k, DocumentError as l, Audio as m, ObservabilitySession as n, observabilitySession as o, toParts as p, droppedCount as r, DEFAULT_MAX_PDF_PAGES as s, FeedbackOptions as t, DocumentMode as u, Completion as v, Image as w, ContentPart as x, CompletionInit as y, imageBase64 as z };
|
|
227
|
+
export { ToolCallPart as C, imageDataUri as D, imageBase64 as E, textPart as O, ToolCall as S, Usage as T, OCRResult as _, Completion as a, StreamEvent as b, ContentPart as c, Image as d, ImagePart as f, OCRPage as g, OCRImage as h, Citation as i, EmbeddingResult as l, Metadata as m, AudioOptions as n, CompletionInit as o, Message as p, AudioPart as r, Content as s, Audio as t, FinishReason as u, Role as v, ToolResultPart as w, TextPart as x, ServerToolCall as y };
|