jangada-ai 1.0.0 → 1.0.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.
- 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-B3YravIz.cjs} +7 -7
- package/dist/{anthropic-BlqXqf9N.js → anthropic-BIf0c9qU.js} +4 -4
- package/dist/{base-bplcDr6J.cjs → base-DCec5kyg.cjs} +1 -1
- package/dist/{base-8WLtVj6O.js → base-DINmmIz8.js} +1 -1
- package/dist/{bedrock-Dxpg5jFC.cjs → bedrock-B0H9pi3_.cjs} +5 -5
- package/dist/{bedrock-infoTG03.js → bedrock-sN_8C9li.js} +3 -3
- package/dist/{client-Y9MDtyQ4.d.cts → client-BcJnFY-A.d.cts} +2 -2
- package/dist/{client-BFoano5Y.js → client-D2b1IWMA.js} +4 -3
- package/dist/{client-C7tNbVHu.cjs → client-DgttfmVI.cjs} +10 -9
- 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-De2Tpc2b.cjs} +8 -8
- package/dist/{gemini-UV1iF24m.js → gemini-DnHVRfsI.js} +4 -4
- package/dist/index.cjs +35 -34
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +17 -16
- 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-NBf2U9m7.js → mistral-Dw4pHREG.js} +3 -3
- package/dist/{mistral-CdX-9oKB.cjs → mistral-TvOcFJiO.cjs} +12 -12
- 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-CURVIQcv.cjs → ollama-DsY6KRGW.cjs} +6 -6
- package/dist/{ollama-CpdaRdg-.js → ollama-DwavghW6.js} +3 -3
- package/dist/{openai-compat-BWdb9UUW.cjs → openai-compat-4pgUQI_o.cjs} +11 -11
- package/dist/{openai-compat-Qlv_JgU5.js → openai-compat-BdWwTQc6.js} +4 -4
- 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-DOnplmbD.js → server-Copv1dWg.js} +3 -3
- package/dist/{server-CKj0B5mk.cjs → server-Crk1KLvG.cjs} +3 -3
- package/dist/server-DVWw6Q6D.d.ts +280 -0
- package/dist/server-zdrObsBn.js +639 -0
- package/dist/{version-CrHu1Pq_.js → version-BR38yiy9.js} +1 -1
- package/dist/{version-Ch4xT-gQ.cjs → version-cxay-WR-.cjs} +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_server = require("../server-C0wyAefS.cjs");
|
|
3
|
+
exports.A2AHandler = require_server.A2AHandler;
|
|
4
|
+
exports.A2aInvalidParamsError = require_server.A2aInvalidParamsError;
|
|
5
|
+
exports.A2aTaskNotCancelableError = require_server.A2aTaskNotCancelableError;
|
|
6
|
+
exports.A2aTaskNotFoundError = require_server.A2aTaskNotFoundError;
|
|
7
|
+
exports.buildA2aHandler = require_server.buildA2aHandler;
|
|
8
|
+
exports.requestContext = require_server.requestContext;
|
|
9
|
+
exports.textFromParts = require_server.textFromParts;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as JsonRpcResponse, S as JsonRpcError, _ as A2aTask, a as requestContext, b as A2aTaskState, c as A2aAgent, d as A2aHistoryStore, f as A2aInvalidParamsError, g as A2aStreamEvent, h as A2aStatusUpdate, i as buildA2aHandler, l as A2aArtifact, m as A2aPart, n as A2aServed, o as A2AHandler, p as A2aMessage, r as A2aServerOptions, s as A2AHandlerOptions, t as A2aRequestContext, u as A2aCallOptions, v as A2aTaskNotCancelableError, w as textFromParts, x as A2aTaskStatus, y as A2aTaskNotFoundError } from "../server-CnO0Uj7X.cjs";
|
|
2
|
+
export { A2AHandler, type A2AHandlerOptions, type A2aAgent, type A2aArtifact, type A2aCallOptions, type A2aHistoryStore, A2aInvalidParamsError, type A2aMessage, type A2aPart, type A2aRequestContext, type A2aServed, type A2aServerOptions, type A2aStatusUpdate, type A2aStreamEvent, type A2aTask, A2aTaskNotCancelableError, A2aTaskNotFoundError, type A2aTaskState, type A2aTaskStatus, type JsonRpcError, type JsonRpcResponse, buildA2aHandler, requestContext, textFromParts };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as JsonRpcResponse, S as JsonRpcError, _ as A2aTask, a as requestContext, b as A2aTaskState, c as A2aAgent, d as A2aHistoryStore, f as A2aInvalidParamsError, g as A2aStreamEvent, h as A2aStatusUpdate, i as buildA2aHandler, l as A2aArtifact, m as A2aPart, n as A2aServed, o as A2AHandler, p as A2aMessage, r as A2aServerOptions, s as A2AHandlerOptions, t as A2aRequestContext, u as A2aCallOptions, v as A2aTaskNotCancelableError, w as textFromParts, x as A2aTaskStatus, y as A2aTaskNotFoundError } from "../server-DVWw6Q6D.js";
|
|
2
|
+
export { A2AHandler, type A2AHandlerOptions, type A2aAgent, type A2aArtifact, type A2aCallOptions, type A2aHistoryStore, A2aInvalidParamsError, type A2aMessage, type A2aPart, type A2aRequestContext, type A2aServed, type A2aServerOptions, type A2aStatusUpdate, type A2aStreamEvent, type A2aTask, A2aTaskNotCancelableError, A2aTaskNotFoundError, type A2aTaskState, type A2aTaskStatus, type JsonRpcError, type JsonRpcResponse, buildA2aHandler, requestContext, textFromParts };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { r as A2AHandler, i as A2aInvalidParamsError, a as A2aTaskNotCancelableError, o as A2aTaskNotFoundError, t as buildA2aHandler, n as requestContext, s as textFromParts } from "../server-zdrObsBn.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_errors = require("./errors-BJIPDLwX.cjs");
|
|
2
|
-
const require_client = require("./client-
|
|
3
|
-
const
|
|
4
|
-
const require_version = require("./version-
|
|
5
|
-
const require_base = require("./base-
|
|
2
|
+
const require_client = require("./client-DgttfmVI.cjs");
|
|
3
|
+
const require_message = require("./message-DCvWw0dF.cjs");
|
|
4
|
+
const require_version = require("./version-cxay-WR-.cjs");
|
|
5
|
+
const require_base = require("./base-DCec5kyg.cjs");
|
|
6
6
|
// src/providers/anthropic.ts
|
|
7
7
|
/**
|
|
8
8
|
* Provider Anthropic (Claude): texto, vision, tools, tools nativas (server tools),
|
|
@@ -103,7 +103,7 @@ var AnthropicProvider = class AnthropicProvider extends require_base.Provider {
|
|
|
103
103
|
source: {
|
|
104
104
|
type: "base64",
|
|
105
105
|
media_type: p.mimeType,
|
|
106
|
-
data:
|
|
106
|
+
data: require_message.imageBase64(p)
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
else if (p.type === "tool_call") {
|
|
@@ -302,7 +302,7 @@ var AnthropicProvider = class AnthropicProvider extends require_base.Provider {
|
|
|
302
302
|
const content = get(resp, "content");
|
|
303
303
|
if (!Array.isArray(content)) throw new require_errors.ServerError(`[${this.name}] resposta sem conteúdo (content=${content}).`, { provider: this.name });
|
|
304
304
|
const text = content.map((b) => get(b, "type") === "text" ? get(b, "text") ?? "" : "").join("");
|
|
305
|
-
const toolCalls = content.filter((b) => get(b, "type") === "tool_use" && get(b, "name")).map((b) => new
|
|
305
|
+
const toolCalls = content.filter((b) => get(b, "type") === "tool_use" && get(b, "name")).map((b) => new require_message.ToolCall(String(get(b, "id") ?? ""), String(get(b, "name")), { ...get(b, "input") ?? {} }));
|
|
306
306
|
const thinking = AnthropicProvider.thinkingBlocks(content);
|
|
307
307
|
if (thinking.length && toolCalls[0]) toolCalls[0].metadata[THINKING_KEY] = thinking;
|
|
308
308
|
const { citations, serverCalls, preservar } = AnthropicProvider.nativeOutputs(content);
|
|
@@ -332,7 +332,7 @@ var AnthropicProvider = class AnthropicProvider extends require_base.Provider {
|
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
334
|
const stop = get(resp, "stop_reason") ?? null;
|
|
335
|
-
return new
|
|
335
|
+
return new require_message.Completion({
|
|
336
336
|
text,
|
|
337
337
|
model: this.model,
|
|
338
338
|
provider: this.name,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { _ as UnsupportedError, d as ProviderError, l as OutputValidationError, m as ServerError, s as LLMError, v as classify } from "./errors-hp-4UePr.js";
|
|
2
|
-
import { s as splitMcp } from "./client-
|
|
3
|
-
import {
|
|
4
|
-
import { c as NativeTool, i as splitTools } from "./version-
|
|
5
|
-
import { n as applyProfile, t as Provider } from "./base-
|
|
2
|
+
import { s as splitMcp } from "./client-D2b1IWMA.js";
|
|
3
|
+
import { a as ToolCall, n as Completion, o as imageBase64 } from "./message-0wKCrEp2.js";
|
|
4
|
+
import { c as NativeTool, i as splitTools } from "./version-BR38yiy9.js";
|
|
5
|
+
import { n as applyProfile, t as Provider } from "./base-DINmmIz8.js";
|
|
6
6
|
// src/providers/anthropic.ts
|
|
7
7
|
/**
|
|
8
8
|
* Provider Anthropic (Claude): texto, vision, tools, tools nativas (server tools),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_errors = require("./errors-BJIPDLwX.cjs");
|
|
2
|
-
const require_version = require("./version-
|
|
2
|
+
const require_version = require("./version-cxay-WR-.cjs");
|
|
3
3
|
const require_env = require("./env-B1ffNsxb.cjs");
|
|
4
4
|
// src/profiles.ts
|
|
5
5
|
const RULES = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as UnsupportedError, g as TruncatedError } from "./errors-hp-4UePr.js";
|
|
2
|
-
import { c as NativeTool } from "./version-
|
|
2
|
+
import { c as NativeTool } from "./version-BR38yiy9.js";
|
|
3
3
|
import { n as getEnv } from "./env-BH4ulZ4_.js";
|
|
4
4
|
// src/profiles.ts
|
|
5
5
|
const RULES = [];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_errors = require("./errors-BJIPDLwX.cjs");
|
|
2
2
|
const require_env = require("./env-B1ffNsxb.cjs");
|
|
3
|
-
const
|
|
4
|
-
const require_base = require("./base-
|
|
5
|
-
const require_version = require("./version-
|
|
3
|
+
const require_message = require("./message-DCvWw0dF.cjs");
|
|
4
|
+
const require_base = require("./base-DCec5kyg.cjs");
|
|
5
|
+
const require_version = require("./version-cxay-WR-.cjs");
|
|
6
6
|
// src/providers/bedrock.ts
|
|
7
7
|
/**
|
|
8
8
|
* Provider AWS Bedrock via Converse API (`@aws-sdk/client-bedrock-runtime`, peer
|
|
@@ -245,7 +245,7 @@ var BedrockProvider = class extends require_base.Provider {
|
|
|
245
245
|
};
|
|
246
246
|
serverCalls.push(sc);
|
|
247
247
|
if (id) porId.set(id, sc);
|
|
248
|
-
} else toolCalls.push(new
|
|
248
|
+
} else toolCalls.push(new require_message.ToolCall(String(id), String(get(tu, "name")), { ...get(tu, "input") ?? {} }));
|
|
249
249
|
}
|
|
250
250
|
const tr = get(b, "toolResult");
|
|
251
251
|
const alvo = porId.get(String(get(tr, "toolUseId")));
|
|
@@ -265,7 +265,7 @@ var BedrockProvider = class extends require_base.Provider {
|
|
|
265
265
|
if (Object.keys(reqs).length) usage.serverToolRequests = reqs;
|
|
266
266
|
}
|
|
267
267
|
const stop = get(resp, "stopReason") ?? null;
|
|
268
|
-
return new
|
|
268
|
+
return new require_message.Completion({
|
|
269
269
|
text: partes.join(""),
|
|
270
270
|
model: this.model,
|
|
271
271
|
provider: this.name,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { _ as UnsupportedError, d as ProviderError, l as OutputValidationError, m as ServerError, s as LLMError, v as classify } from "./errors-hp-4UePr.js";
|
|
2
2
|
import { n as getEnv } from "./env-BH4ulZ4_.js";
|
|
3
|
-
import {
|
|
4
|
-
import { n as applyProfile, t as Provider } from "./base-
|
|
5
|
-
import { i as splitTools } from "./version-
|
|
3
|
+
import { a as ToolCall, n as Completion } from "./message-0wKCrEp2.js";
|
|
4
|
+
import { n as applyProfile, t as Provider } from "./base-DINmmIz8.js";
|
|
5
|
+
import { i as splitTools } from "./version-BR38yiy9.js";
|
|
6
6
|
// src/providers/bedrock.ts
|
|
7
7
|
/**
|
|
8
8
|
* Provider AWS Bedrock via Converse API (`@aws-sdk/client-bedrock-runtime`, peer
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as Params, s as LLM } from "./client-
|
|
2
|
-
import {
|
|
1
|
+
import { _ as Params, s as LLM } from "./client-voHjPm-f.cjs";
|
|
2
|
+
import { S as ToolCall, T as Usage, a as Completion, p as Message, s as Content, w as ToolResultPart } from "./message-D3MSjqww.cjs";
|
|
3
3
|
import { n as ToolAnnotations, t as Tool } from "./tools-DjzQr-Np.cjs";
|
|
4
4
|
type Json = Record<string, unknown>;
|
|
5
5
|
/** `"never"`, `"always"` ou o objeto nativo da OpenAI (`{ never: { tool_names: [...] } }`). */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { s as LLMError, t as APIConnectionError } from "./errors-hp-4UePr.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { o as warn } from "./context-CvNVqdqz.js";
|
|
3
|
+
import { c as textPart, i as Message, r as Image } from "./message-0wKCrEp2.js";
|
|
4
|
+
import { n as Tool } from "./version-BR38yiy9.js";
|
|
4
5
|
// src/mcp/client.ts
|
|
5
6
|
function get(obj, key) {
|
|
6
7
|
return obj !== null && typeof obj === "object" ? obj[key] : void 0;
|
|
@@ -466,7 +467,7 @@ var MCPClient = class {
|
|
|
466
467
|
const sdk = await loadSdk();
|
|
467
468
|
const info = this.#options.clientInfo ?? {
|
|
468
469
|
name: "jangada",
|
|
469
|
-
version: "1.0.
|
|
470
|
+
version: "1.0.1"
|
|
470
471
|
};
|
|
471
472
|
const client = new sdk.Client(info, { capabilities: this.capabilities() });
|
|
472
473
|
this.registerCallbacks(client, sdk);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_errors = require("./errors-BJIPDLwX.cjs");
|
|
2
|
-
const require_context = require("./context-
|
|
3
|
-
const
|
|
2
|
+
const require_context = require("./context-BWyYfOyr.cjs");
|
|
3
|
+
const require_message = require("./message-DCvWw0dF.cjs");
|
|
4
|
+
const require_version = require("./version-cxay-WR-.cjs");
|
|
4
5
|
// src/mcp/client.ts
|
|
5
6
|
function get(obj, key) {
|
|
6
7
|
return obj !== null && typeof obj === "object" ? obj[key] : void 0;
|
|
@@ -255,10 +256,10 @@ function mcpContentToParts(content) {
|
|
|
255
256
|
for (const b of blocos) if (get(b, "type") === "image") {
|
|
256
257
|
const data = get(b, "data");
|
|
257
258
|
const mime = attr(b, "mimeType", "mime_type");
|
|
258
|
-
if (typeof data === "string") partes.push(
|
|
259
|
+
if (typeof data === "string") partes.push(require_message.Image.fromBase64(data, typeof mime === "string" ? mime : "image/png"));
|
|
259
260
|
} else {
|
|
260
261
|
const texto = get(b, "text");
|
|
261
|
-
if (typeof texto === "string" && texto) partes.push(
|
|
262
|
+
if (typeof texto === "string" && texto) partes.push(require_message.textPart(texto));
|
|
262
263
|
}
|
|
263
264
|
const unica = partes[0];
|
|
264
265
|
if (partes.length === 1 && unica?.type === "text") return unica.text;
|
|
@@ -290,7 +291,7 @@ function makeSamplingHandler(llm, options = {}) {
|
|
|
290
291
|
err.code = -1;
|
|
291
292
|
throw err;
|
|
292
293
|
}
|
|
293
|
-
const history = (params.messages ?? []).map((m) =>
|
|
294
|
+
const history = (params.messages ?? []).map((m) => require_message.Message.create(m.role, mcpContentToParts(m.content)));
|
|
294
295
|
const callParams = {};
|
|
295
296
|
const temperatura = attr(params, "temperature");
|
|
296
297
|
if (typeof temperatura === "number") callParams.temperature = temperatura;
|
|
@@ -466,7 +467,7 @@ var MCPClient = class {
|
|
|
466
467
|
const sdk = await loadSdk();
|
|
467
468
|
const info = this.#options.clientInfo ?? {
|
|
468
469
|
name: "jangada",
|
|
469
|
-
version: "1.0.
|
|
470
|
+
version: "1.0.1"
|
|
470
471
|
};
|
|
471
472
|
const client = new sdk.Client(info, { capabilities: this.capabilities() });
|
|
472
473
|
this.registerCallbacks(client, sdk);
|
|
@@ -615,7 +616,7 @@ var MCPClient = class {
|
|
|
615
616
|
}
|
|
616
617
|
/** Pega um prompt do servidor e converte em `Message[]` (pronto para `history`). */
|
|
617
618
|
async promptMessages(name, args, options) {
|
|
618
|
-
return ((await this.getPrompt(name, args, options)).messages ?? []).map((m) =>
|
|
619
|
+
return ((await this.getPrompt(name, args, options)).messages ?? []).map((m) => require_message.Message.create(m.role, mcpContentToParts(m.content)));
|
|
619
620
|
}
|
|
620
621
|
/** Nível de log que o servidor deve mandar (`debug`, `info`, `warning`...). */
|
|
621
622
|
setLoggingLevel(level, options) {
|
|
@@ -726,7 +727,7 @@ async function runAgent(llm, prompt, options) {
|
|
|
726
727
|
} else tools = options.tools;
|
|
727
728
|
const oferecidas = new Set(tools.map((t) => t.name));
|
|
728
729
|
const msgs = [...options.history ?? []];
|
|
729
|
-
if (prompt !== null) msgs.push(
|
|
730
|
+
if (prompt !== null) msgs.push(require_message.Message.create("user", prompt));
|
|
730
731
|
let comp = null;
|
|
731
732
|
const toolTrace = [];
|
|
732
733
|
const usageTotal = {};
|
|
@@ -775,7 +776,7 @@ async function runAgent(llm, prompt, options) {
|
|
|
775
776
|
results.push(result);
|
|
776
777
|
}
|
|
777
778
|
msgs.push(comp.assistantMessage());
|
|
778
|
-
msgs.push(
|
|
779
|
+
msgs.push(require_message.Message.toolResults(...results));
|
|
779
780
|
}
|
|
780
781
|
if (comp === null) return null;
|
|
781
782
|
const stoppedByLimit = comp.toolCalls.length > 0;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { T as Usage, _ as OCRResult, a as Completion, b as StreamEvent, f as ImagePart, l as EmbeddingResult, p as Message, r as AudioPart } from "./message-D3MSjqww.js";
|
|
2
|
+
import { f as FileInput, n as ObservabilitySession } from "./observability-DSlDuE1w.js";
|
|
2
3
|
import { i as SchemaSpec, r as ResolvedSchema, t as InferSchema } from "./schema-BBiyhRZk.js";
|
|
3
4
|
/** O que precisa bater para reusar uma resposta. */
|
|
4
5
|
interface CacheScope {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as Params, s as LLM } from "./client-
|
|
2
|
-
import {
|
|
1
|
+
import { _ as Params, s as LLM } from "./client-G7gJaq6H.js";
|
|
2
|
+
import { S as ToolCall, T as Usage, a as Completion, p as Message, s as Content, w as ToolResultPart } from "./message-D3MSjqww.js";
|
|
3
3
|
import { n as ToolAnnotations, t as Tool } from "./tools-4-yoaMWI.js";
|
|
4
4
|
type Json = Record<string, unknown>;
|
|
5
5
|
/** `"never"`, `"always"` ou o objeto nativo da OpenAI (`{ never: { tool_names: [...] } }`). */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { T as Usage, _ as OCRResult, a as Completion, b as StreamEvent, f as ImagePart, l as EmbeddingResult, p as Message, r as AudioPart } from "./message-D3MSjqww.cjs";
|
|
2
|
+
import { f as FileInput, n as ObservabilitySession } from "./observability-Cy4ewtvC.cjs";
|
|
2
3
|
import { i as SchemaSpec, r as ResolvedSchema, t as InferSchema } from "./schema-BBiyhRZk.cjs";
|
|
3
4
|
/** O que precisa bater para reusar uma resposta. */
|
|
4
5
|
interface CacheScope {
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
// src/mcp/context.ts
|
|
9
|
+
function findStorage() {
|
|
10
|
+
const g = globalThis;
|
|
11
|
+
let Ctor;
|
|
12
|
+
try {
|
|
13
|
+
Ctor = (g.process?.getBuiltinModule?.("node:async_hooks"))?.AsyncLocalStorage;
|
|
14
|
+
} catch {}
|
|
15
|
+
Ctor ??= g.AsyncLocalStorage;
|
|
16
|
+
if (typeof Ctor !== "function") return void 0;
|
|
17
|
+
try {
|
|
18
|
+
return new Ctor();
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const storage = findStorage();
|
|
24
|
+
/** Contexto vazio (stdio, ou chamada fora de uma requisição). */
|
|
25
|
+
const EMPTY_CONTEXT = Object.freeze({ headers: Object.freeze({}) });
|
|
26
|
+
/** Roda `fn` com `ctx` como contexto atual (quando há `AsyncLocalStorage`). */
|
|
27
|
+
function runWithRequestContext(ctx, fn) {
|
|
28
|
+
return storage ? storage.run(ctx, fn) : fn();
|
|
29
|
+
}
|
|
30
|
+
function ambient() {
|
|
31
|
+
return storage?.getStore();
|
|
32
|
+
}
|
|
33
|
+
/** Normaliza headers (Headers, objeto ou pares) em objeto com nomes minúsculos. */
|
|
34
|
+
function normalizeHeaders(headers) {
|
|
35
|
+
const out = {};
|
|
36
|
+
if (!headers || typeof headers !== "object") return out;
|
|
37
|
+
try {
|
|
38
|
+
if (typeof headers.forEach === "function" && !Array.isArray(headers)) {
|
|
39
|
+
headers.forEach((v, k) => {
|
|
40
|
+
out[k.toLowerCase()] = v;
|
|
41
|
+
});
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
const entries = Array.isArray(headers) ? headers : Object.entries(headers);
|
|
45
|
+
for (const [k, v] of entries) {
|
|
46
|
+
if (v === void 0 || v === null) continue;
|
|
47
|
+
out[String(k).toLowerCase()] = Array.isArray(v) ? v.join(", ") : String(v);
|
|
48
|
+
}
|
|
49
|
+
} catch {}
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Headers HTTP da chamada MCP atual (nomes em minúsculas).
|
|
54
|
+
*
|
|
55
|
+
* Vazio fora de uma chamada (ex.: no stdio, que não tem HTTP) e em runtimes sem
|
|
56
|
+
* `AsyncLocalStorage`, a menos que você passe o `ctx` recebido pela tool. Vale
|
|
57
|
+
* dentro das tools, do `toolFilter` e do `toolDescription`.
|
|
58
|
+
*/
|
|
59
|
+
function requestHeaders(ctx) {
|
|
60
|
+
return { ...(ctx ?? ambient())?.headers ?? {} };
|
|
61
|
+
}
|
|
62
|
+
function decodeClaims(raw) {
|
|
63
|
+
if (!raw) return null;
|
|
64
|
+
try {
|
|
65
|
+
const b64 = raw.replace(/-/g, "+").replace(/_/g, "/");
|
|
66
|
+
const padded = b64 + "=".repeat((4 - b64.length % 4) % 4);
|
|
67
|
+
const bin = atob(padded);
|
|
68
|
+
const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));
|
|
69
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
70
|
+
} catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function decodeName(raw) {
|
|
75
|
+
try {
|
|
76
|
+
return decodeURIComponent(raw);
|
|
77
|
+
} catch {
|
|
78
|
+
return raw;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Identidade de quem chamou, lida dos headers `x-jangada-user-*`.
|
|
83
|
+
*
|
|
84
|
+
* `null` quando não há usuário: modo Token do jangada Cloud, servidor fora do
|
|
85
|
+
* jangada Cloud ou transporte stdio. Os headers `x-jangada-*` só são confiáveis
|
|
86
|
+
* atrás do gateway do jangada Cloud (ele remove os que vêm do cliente); num
|
|
87
|
+
* servidor exposto direto, qualquer um poderia mandá-los.
|
|
88
|
+
*/
|
|
89
|
+
function currentUser(ctx) {
|
|
90
|
+
const h = (ctx ?? ambient())?.headers ?? {};
|
|
91
|
+
const id = h["x-jangada-user-id"];
|
|
92
|
+
if (!id) return null;
|
|
93
|
+
const name = h["x-jangada-user-name"];
|
|
94
|
+
return {
|
|
95
|
+
id,
|
|
96
|
+
email: h["x-jangada-user-email"] || null,
|
|
97
|
+
name: name ? decodeName(name) : null,
|
|
98
|
+
claims: decodeClaims(h["x-jangada-claims"])
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
Object.defineProperty(exports, "EMPTY_CONTEXT", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function() {
|
|
104
|
+
return EMPTY_CONTEXT;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, "currentUser", {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function() {
|
|
110
|
+
return currentUser;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, "normalizeHeaders", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function() {
|
|
116
|
+
return normalizeHeaders;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(exports, "requestHeaders", {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
get: function() {
|
|
122
|
+
return requestHeaders;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(exports, "runWithRequestContext", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function() {
|
|
128
|
+
return runWithRequestContext;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
Object.defineProperty(exports, "warn", {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function() {
|
|
134
|
+
return warn;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
// src/mcp/context.ts
|
|
9
|
+
function findStorage() {
|
|
10
|
+
const g = globalThis;
|
|
11
|
+
let Ctor;
|
|
12
|
+
try {
|
|
13
|
+
Ctor = (g.process?.getBuiltinModule?.("node:async_hooks"))?.AsyncLocalStorage;
|
|
14
|
+
} catch {}
|
|
15
|
+
Ctor ??= g.AsyncLocalStorage;
|
|
16
|
+
if (typeof Ctor !== "function") return void 0;
|
|
17
|
+
try {
|
|
18
|
+
return new Ctor();
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const storage = findStorage();
|
|
24
|
+
/** Contexto vazio (stdio, ou chamada fora de uma requisição). */
|
|
25
|
+
const EMPTY_CONTEXT = Object.freeze({ headers: Object.freeze({}) });
|
|
26
|
+
/** Roda `fn` com `ctx` como contexto atual (quando há `AsyncLocalStorage`). */
|
|
27
|
+
function runWithRequestContext(ctx, fn) {
|
|
28
|
+
return storage ? storage.run(ctx, fn) : fn();
|
|
29
|
+
}
|
|
30
|
+
function ambient() {
|
|
31
|
+
return storage?.getStore();
|
|
32
|
+
}
|
|
33
|
+
/** Normaliza headers (Headers, objeto ou pares) em objeto com nomes minúsculos. */
|
|
34
|
+
function normalizeHeaders(headers) {
|
|
35
|
+
const out = {};
|
|
36
|
+
if (!headers || typeof headers !== "object") return out;
|
|
37
|
+
try {
|
|
38
|
+
if (typeof headers.forEach === "function" && !Array.isArray(headers)) {
|
|
39
|
+
headers.forEach((v, k) => {
|
|
40
|
+
out[k.toLowerCase()] = v;
|
|
41
|
+
});
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
const entries = Array.isArray(headers) ? headers : Object.entries(headers);
|
|
45
|
+
for (const [k, v] of entries) {
|
|
46
|
+
if (v === void 0 || v === null) continue;
|
|
47
|
+
out[String(k).toLowerCase()] = Array.isArray(v) ? v.join(", ") : String(v);
|
|
48
|
+
}
|
|
49
|
+
} catch {}
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Headers HTTP da chamada MCP atual (nomes em minúsculas).
|
|
54
|
+
*
|
|
55
|
+
* Vazio fora de uma chamada (ex.: no stdio, que não tem HTTP) e em runtimes sem
|
|
56
|
+
* `AsyncLocalStorage`, a menos que você passe o `ctx` recebido pela tool. Vale
|
|
57
|
+
* dentro das tools, do `toolFilter` e do `toolDescription`.
|
|
58
|
+
*/
|
|
59
|
+
function requestHeaders(ctx) {
|
|
60
|
+
return { ...(ctx ?? ambient())?.headers ?? {} };
|
|
61
|
+
}
|
|
62
|
+
function decodeClaims(raw) {
|
|
63
|
+
if (!raw) return null;
|
|
64
|
+
try {
|
|
65
|
+
const b64 = raw.replace(/-/g, "+").replace(/_/g, "/");
|
|
66
|
+
const padded = b64 + "=".repeat((4 - b64.length % 4) % 4);
|
|
67
|
+
const bin = atob(padded);
|
|
68
|
+
const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));
|
|
69
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
70
|
+
} catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function decodeName(raw) {
|
|
75
|
+
try {
|
|
76
|
+
return decodeURIComponent(raw);
|
|
77
|
+
} catch {
|
|
78
|
+
return raw;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Identidade de quem chamou, lida dos headers `x-jangada-user-*`.
|
|
83
|
+
*
|
|
84
|
+
* `null` quando não há usuário: modo Token do jangada Cloud, servidor fora do
|
|
85
|
+
* jangada Cloud ou transporte stdio. Os headers `x-jangada-*` só são confiáveis
|
|
86
|
+
* atrás do gateway do jangada Cloud (ele remove os que vêm do cliente); num
|
|
87
|
+
* servidor exposto direto, qualquer um poderia mandá-los.
|
|
88
|
+
*/
|
|
89
|
+
function currentUser(ctx) {
|
|
90
|
+
const h = (ctx ?? ambient())?.headers ?? {};
|
|
91
|
+
const id = h["x-jangada-user-id"];
|
|
92
|
+
if (!id) return null;
|
|
93
|
+
const name = h["x-jangada-user-name"];
|
|
94
|
+
return {
|
|
95
|
+
id,
|
|
96
|
+
email: h["x-jangada-user-email"] || null,
|
|
97
|
+
name: name ? decodeName(name) : null,
|
|
98
|
+
claims: decodeClaims(h["x-jangada-claims"])
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export { runWithRequestContext as a, requestHeaders as i, currentUser as n, warn as o, normalizeHeaders as r, EMPTY_CONTEXT as t };
|
package/dist/eval/index.d.cts
CHANGED
package/dist/eval/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_errors = require("./errors-BJIPDLwX.cjs");
|
|
2
|
-
const
|
|
2
|
+
const require_message = require("./message-DCvWw0dF.cjs");
|
|
3
3
|
const require_env = require("./env-B1ffNsxb.cjs");
|
|
4
|
-
const require_client = require("./client-
|
|
5
|
-
const require_base = require("./base-
|
|
4
|
+
const require_client = require("./client-DgttfmVI.cjs");
|
|
5
|
+
const require_base = require("./base-DCec5kyg.cjs");
|
|
6
6
|
const require_schema = require("./schema-qS-xTTIs.cjs");
|
|
7
|
-
const require_version = require("./version-
|
|
7
|
+
const require_version = require("./version-cxay-WR-.cjs");
|
|
8
8
|
const require_gemini_schema = require("./gemini-schema-BwcTPvV1.cjs");
|
|
9
9
|
// src/providers/gemini.ts
|
|
10
10
|
/**
|
|
@@ -110,7 +110,7 @@ var GeminiProvider = class GeminiProvider extends require_base.Provider {
|
|
|
110
110
|
if (typeof m.content === "string") parts.push({ text: m.content });
|
|
111
111
|
else for (const p of m.content) if (p.type === "text") parts.push({ text: p.text });
|
|
112
112
|
else if (p.type === "image") parts.push({ inlineData: {
|
|
113
|
-
data:
|
|
113
|
+
data: require_message.imageBase64(p),
|
|
114
114
|
mimeType: p.mimeType
|
|
115
115
|
} });
|
|
116
116
|
else if (p.type === "tool_call") {
|
|
@@ -317,7 +317,7 @@ var GeminiProvider = class GeminiProvider extends require_base.Provider {
|
|
|
317
317
|
meta.gemini_call_id = real;
|
|
318
318
|
id = real;
|
|
319
319
|
} else id = `${get(fc, "name")}#${calls.length}`;
|
|
320
|
-
calls.push(new
|
|
320
|
+
calls.push(new require_message.ToolCall(id, String(get(fc, "name")), { ...get(fc, "args") ?? {} }, meta));
|
|
321
321
|
};
|
|
322
322
|
const cand = get(resp, "candidates")?.[0];
|
|
323
323
|
for (const part of get(get(cand, "content"), "parts") ?? []) {
|
|
@@ -370,7 +370,7 @@ var GeminiProvider = class GeminiProvider extends require_base.Provider {
|
|
|
370
370
|
const cand = get(resp, "candidates")?.[0];
|
|
371
371
|
const fr = get(cand, "finishReason");
|
|
372
372
|
const finish = typeof fr === "string" ? fr === "MAX_TOKENS" ? "length" : fr : null;
|
|
373
|
-
return new
|
|
373
|
+
return new require_message.Completion({
|
|
374
374
|
text: texto,
|
|
375
375
|
model: this.model,
|
|
376
376
|
provider: this.name,
|
|
@@ -742,7 +742,7 @@ var GeminiProvider = class GeminiProvider extends require_base.Provider {
|
|
|
742
742
|
contents: [{
|
|
743
743
|
role: "user",
|
|
744
744
|
parts: [{ inlineData: {
|
|
745
|
-
data:
|
|
745
|
+
data: require_message.bytesToBase64(audio.data),
|
|
746
746
|
mimeType: audio.mimeType
|
|
747
747
|
} }, { text: instrucao }]
|
|
748
748
|
}]
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { _ as UnsupportedError, i as BadRequestError, m as ServerError, v as classify } from "./errors-hp-4UePr.js";
|
|
2
|
-
import {
|
|
2
|
+
import { a as ToolCall, l as bytesToBase64, n as Completion, o as imageBase64 } from "./message-0wKCrEp2.js";
|
|
3
3
|
import { n as getEnv } from "./env-BH4ulZ4_.js";
|
|
4
|
-
import { a as mcpTools, l as toolResultText, s as splitMcp, t as MCPClient, u as toolSourceFromSession } from "./client-
|
|
5
|
-
import { n as applyProfile, t as Provider } from "./base-
|
|
4
|
+
import { a as mcpTools, l as toolResultText, s as splitMcp, t as MCPClient, u as toolSourceFromSession } from "./client-D2b1IWMA.js";
|
|
5
|
+
import { n as applyProfile, t as Provider } from "./base-DINmmIz8.js";
|
|
6
6
|
import { n as parseJsonText } from "./schema-DCaQOk49.js";
|
|
7
|
-
import { i as splitTools } from "./version-
|
|
7
|
+
import { i as splitTools } from "./version-BR38yiy9.js";
|
|
8
8
|
import { t as cleanGeminiSchema } from "./gemini-schema-BLKtypnG.js";
|
|
9
9
|
// src/providers/gemini.ts
|
|
10
10
|
/**
|