risicare 0.9.2 → 0.10.0
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/CHANGELOG.md +183 -0
- package/README.md +37 -19
- package/dist/frameworks/instructor.cjs +46 -1
- package/dist/frameworks/instructor.cjs.map +1 -1
- package/dist/frameworks/instructor.js +46 -1
- package/dist/frameworks/instructor.js.map +1 -1
- package/dist/frameworks/langchain.cjs +46 -1
- package/dist/frameworks/langchain.cjs.map +1 -1
- package/dist/frameworks/langchain.js +46 -1
- package/dist/frameworks/langchain.js.map +1 -1
- package/dist/frameworks/langgraph.cjs +46 -1
- package/dist/frameworks/langgraph.cjs.map +1 -1
- package/dist/frameworks/langgraph.js +46 -1
- package/dist/frameworks/langgraph.js.map +1 -1
- package/dist/frameworks/llamaindex.cjs +46 -1
- package/dist/frameworks/llamaindex.cjs.map +1 -1
- package/dist/frameworks/llamaindex.js +46 -1
- package/dist/frameworks/llamaindex.js.map +1 -1
- package/dist/index.cjs +329 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +329 -15
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic/index.cjs +117 -8
- package/dist/providers/anthropic/index.cjs.map +1 -1
- package/dist/providers/anthropic/index.js +117 -8
- package/dist/providers/anthropic/index.js.map +1 -1
- package/dist/providers/bedrock/index.cjs +64 -4
- package/dist/providers/bedrock/index.cjs.map +1 -1
- package/dist/providers/bedrock/index.js +64 -4
- package/dist/providers/bedrock/index.js.map +1 -1
- package/dist/providers/cerebras/index.cjs +64 -4
- package/dist/providers/cerebras/index.cjs.map +1 -1
- package/dist/providers/cerebras/index.js +64 -4
- package/dist/providers/cerebras/index.js.map +1 -1
- package/dist/providers/cohere/index.cjs +64 -4
- package/dist/providers/cohere/index.cjs.map +1 -1
- package/dist/providers/cohere/index.js +64 -4
- package/dist/providers/cohere/index.js.map +1 -1
- package/dist/providers/google/index.cjs +64 -4
- package/dist/providers/google/index.cjs.map +1 -1
- package/dist/providers/google/index.js +64 -4
- package/dist/providers/google/index.js.map +1 -1
- package/dist/providers/groq/index.cjs +64 -4
- package/dist/providers/groq/index.cjs.map +1 -1
- package/dist/providers/groq/index.js +64 -4
- package/dist/providers/groq/index.js.map +1 -1
- package/dist/providers/huggingface/index.cjs +64 -4
- package/dist/providers/huggingface/index.cjs.map +1 -1
- package/dist/providers/huggingface/index.js +64 -4
- package/dist/providers/huggingface/index.js.map +1 -1
- package/dist/providers/mistral/index.cjs +64 -4
- package/dist/providers/mistral/index.cjs.map +1 -1
- package/dist/providers/mistral/index.js +64 -4
- package/dist/providers/mistral/index.js.map +1 -1
- package/dist/providers/ollama/index.cjs +64 -4
- package/dist/providers/ollama/index.cjs.map +1 -1
- package/dist/providers/ollama/index.js +64 -4
- package/dist/providers/ollama/index.js.map +1 -1
- package/dist/providers/openai/index.cjs +102 -6
- package/dist/providers/openai/index.cjs.map +1 -1
- package/dist/providers/openai/index.js +102 -6
- package/dist/providers/openai/index.js.map +1 -1
- package/dist/providers/together/index.cjs +64 -4
- package/dist/providers/together/index.cjs.map +1 -1
- package/dist/providers/together/index.js +64 -4
- package/dist/providers/together/index.js.map +1 -1
- package/dist/providers/vercel-ai/index.cjs +48 -3
- package/dist/providers/vercel-ai/index.cjs.map +1 -1
- package/dist/providers/vercel-ai/index.js +48 -3
- package/dist/providers/vercel-ai/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -367,7 +367,49 @@ var CONTENT_KEYS_EXACT = /* @__PURE__ */ new Set([
|
|
|
367
367
|
"audio.transcript",
|
|
368
368
|
"traceloop.entity.input",
|
|
369
369
|
// OpenLLMetry
|
|
370
|
-
"traceloop.entity.output"
|
|
370
|
+
"traceloop.entity.output",
|
|
371
|
+
// Gateway corpus v2 (R41): the content keys of more frameworks. The same 75
|
|
372
|
+
// keys as `CONTENT_KEYS_EXACT` in the gateway's `content_control.rs`.
|
|
373
|
+
"agent.backstory",
|
|
374
|
+
// OpenInference
|
|
375
|
+
"agent.goal",
|
|
376
|
+
"llm.available_functions",
|
|
377
|
+
"llm.tools",
|
|
378
|
+
"ai.prompt",
|
|
379
|
+
// Vercel AI SDK
|
|
380
|
+
"ai.prompt.messages",
|
|
381
|
+
"ai.prompt.tools",
|
|
382
|
+
"ai.response.files",
|
|
383
|
+
"ai.response.object",
|
|
384
|
+
"ai.response.reasoning",
|
|
385
|
+
"ai.response.text",
|
|
386
|
+
"ai.response.toolCalls",
|
|
387
|
+
"ai.result.object",
|
|
388
|
+
// the older Vercel names
|
|
389
|
+
"ai.result.text",
|
|
390
|
+
"ai.result.toolCalls",
|
|
391
|
+
"ai.toolCall.args",
|
|
392
|
+
"ai.toolCall.result",
|
|
393
|
+
"ai.value",
|
|
394
|
+
// the text of an embedding call
|
|
395
|
+
"ai.values",
|
|
396
|
+
"final_result",
|
|
397
|
+
// Pydantic AI
|
|
398
|
+
"model_request_parameters",
|
|
399
|
+
"pydantic_ai.all_messages",
|
|
400
|
+
"tool_arguments",
|
|
401
|
+
"tool_response",
|
|
402
|
+
"gcp.vertex.agent.data",
|
|
403
|
+
// Google ADK
|
|
404
|
+
"gcp.vertex.agent.llm_request",
|
|
405
|
+
"gcp.vertex.agent.llm_response",
|
|
406
|
+
"gcp.vertex.agent.tool_call_args",
|
|
407
|
+
"gcp.vertex.agent.tool_response",
|
|
408
|
+
"gen_ai.task.input",
|
|
409
|
+
// OpenLLMetry
|
|
410
|
+
"gen_ai.task.output",
|
|
411
|
+
"sk.available_functions"
|
|
412
|
+
// Semantic Kernel
|
|
371
413
|
]);
|
|
372
414
|
var CONTENT_LAST_SEGMENT_IN_CONTEXT = /* @__PURE__ */ new Map([
|
|
373
415
|
["function_call_arguments_json", /* @__PURE__ */ new Set()],
|
|
@@ -375,7 +417,15 @@ var CONTENT_LAST_SEGMENT_IN_CONTEXT = /* @__PURE__ */ new Map([
|
|
|
375
417
|
["data", /* @__PURE__ */ new Set(["message_content"])],
|
|
376
418
|
["url", /* @__PURE__ */ new Set(["image"])],
|
|
377
419
|
// `image.url` can hold base64 data
|
|
378
|
-
["metadata", /* @__PURE__ */ new Set(["document", "documents"])]
|
|
420
|
+
["metadata", /* @__PURE__ */ new Set(["document", "documents"])],
|
|
421
|
+
// Gateway corpus v2: a list of tool definitions. The `description` of one tool
|
|
422
|
+
// on a tool span (`tool.description`) is not content; the descriptions in a list are.
|
|
423
|
+
["description", /* @__PURE__ */ new Set(["definitions", "functions", "tools"])],
|
|
424
|
+
["json_schema", /* @__PURE__ */ new Set(["tool", "tools"])],
|
|
425
|
+
["parameters", /* @__PURE__ */ new Set(["definitions", "functions", "tool", "tools"])],
|
|
426
|
+
// Gateway corpus v2: the Mastra span I/O, `mastra.<span type>.input|output`.
|
|
427
|
+
["input", /* @__PURE__ */ new Set(["mastra"])],
|
|
428
|
+
["output", /* @__PURE__ */ new Set(["mastra"])]
|
|
379
429
|
]);
|
|
380
430
|
var CONTENT_CONTAINER_SEGMENTS = /* @__PURE__ */ new Set([
|
|
381
431
|
"message",
|
|
@@ -388,8 +438,23 @@ var CONTENT_CONTAINER_SEGMENTS = /* @__PURE__ */ new Set([
|
|
|
388
438
|
"documents",
|
|
389
439
|
"tool_call",
|
|
390
440
|
"tool_calls",
|
|
391
|
-
"function"
|
|
441
|
+
"function",
|
|
442
|
+
// Gateway corpus v2: LiteLLM `gen_ai.completion.{i}.function_call.arguments` and
|
|
443
|
+
// OpenInference `llm.prompts.{i}.prompt.text`.
|
|
444
|
+
"function_call",
|
|
445
|
+
"prompt",
|
|
446
|
+
"prompts"
|
|
447
|
+
]);
|
|
448
|
+
var CONTENT_FIRST_SEGMENTS = /* @__PURE__ */ new Set(["crewai"]);
|
|
449
|
+
var CONTENT_EVENT_NAMES = /* @__PURE__ */ new Set([
|
|
450
|
+
"gen_ai.assistant.message",
|
|
451
|
+
"gen_ai.choice",
|
|
452
|
+
"gen_ai.system.message",
|
|
453
|
+
"gen_ai.tool.message",
|
|
454
|
+
"gen_ai.user.message"
|
|
392
455
|
]);
|
|
456
|
+
var CONTENT_EVENT_PREFIX = "gen_ai.content.";
|
|
457
|
+
var CONTENT_EVENT_KEEP_KEYS = /* @__PURE__ */ new Set(["gen_ai.provider.name", "gen_ai.system"]);
|
|
393
458
|
var CONTENT_KEYS_KEEP_EXACT = /* @__PURE__ */ new Set([
|
|
394
459
|
"gen_ai.response.content_type",
|
|
395
460
|
"gen_ai.response.content_blocks",
|
|
@@ -407,10 +472,60 @@ var KEEP_LAST_SEGMENTS = /* @__PURE__ */ new Set([
|
|
|
407
472
|
"index",
|
|
408
473
|
"model",
|
|
409
474
|
"finish_reason",
|
|
410
|
-
"mime_type"
|
|
475
|
+
"mime_type",
|
|
476
|
+
// Gateway v2 at risicare-ingestion main (PR 94): a model name
|
|
477
|
+
// (`crewai.agent.llm`) and the crew process type are not content.
|
|
478
|
+
"llm",
|
|
479
|
+
"process"
|
|
411
480
|
]);
|
|
412
481
|
var KEEP_LAST_SUFFIXES = ["_length", "_tokens", "_count"];
|
|
482
|
+
var CONTENT_IN_JSON_OBJECT = /* @__PURE__ */ new Map([
|
|
483
|
+
[
|
|
484
|
+
"llm.invocation_parameters",
|
|
485
|
+
/* @__PURE__ */ new Set([
|
|
486
|
+
"additionalinstructions",
|
|
487
|
+
// OpenAI assistants run
|
|
488
|
+
"chathistory",
|
|
489
|
+
// Cohere
|
|
490
|
+
"contents",
|
|
491
|
+
// Gemini
|
|
492
|
+
"documents",
|
|
493
|
+
// Cohere RAG
|
|
494
|
+
"functions",
|
|
495
|
+
"input",
|
|
496
|
+
"inputtext",
|
|
497
|
+
// Bedrock Titan
|
|
498
|
+
"instructions",
|
|
499
|
+
"message",
|
|
500
|
+
// Cohere
|
|
501
|
+
"messages",
|
|
502
|
+
"preamble",
|
|
503
|
+
// Cohere
|
|
504
|
+
"prediction",
|
|
505
|
+
// OpenAI predicted output
|
|
506
|
+
"prompt",
|
|
507
|
+
"system",
|
|
508
|
+
// Anthropic
|
|
509
|
+
"systeminstruction",
|
|
510
|
+
// Gemini
|
|
511
|
+
"texts",
|
|
512
|
+
// Cohere embed
|
|
513
|
+
"toolconfig",
|
|
514
|
+
// Gemini
|
|
515
|
+
"tools"
|
|
516
|
+
])
|
|
517
|
+
]
|
|
518
|
+
]);
|
|
519
|
+
var VALUE_RULE_PREFIXES = new Set(
|
|
520
|
+
[...CONTENT_IN_JSON_OBJECT.keys()].flatMap((key) => {
|
|
521
|
+
const segments = key.split(".");
|
|
522
|
+
return segments.slice(1).map((_, i) => segments.slice(0, i + 1).join("."));
|
|
523
|
+
})
|
|
524
|
+
);
|
|
413
525
|
var CONTENT_OMITTED_MARKER = "<risicare:content-omitted>";
|
|
526
|
+
function hasKeepLastSegment(last) {
|
|
527
|
+
return KEEP_LAST_SEGMENTS.has(last) || KEEP_LAST_SUFFIXES.some((x) => last.endsWith(x));
|
|
528
|
+
}
|
|
414
529
|
function isContentKey(key) {
|
|
415
530
|
if (CONTENT_KEYS_KEEP_EXACT.has(key)) return false;
|
|
416
531
|
if (CONTENT_KEYS_EXACT.has(key) || key.endsWith("_content")) return true;
|
|
@@ -420,25 +535,220 @@ function isContentKey(key) {
|
|
|
420
535
|
if (context && (context.size === 0 || segments.slice(0, -1).some((s) => context.has(s)))) {
|
|
421
536
|
return true;
|
|
422
537
|
}
|
|
423
|
-
if (
|
|
538
|
+
if (hasKeepLastSegment(last)) {
|
|
424
539
|
return false;
|
|
425
540
|
}
|
|
541
|
+
if (segments.length > 1 && CONTENT_FIRST_SEGMENTS.has(segments[0])) return true;
|
|
426
542
|
if (last === "content") return true;
|
|
427
543
|
if (last === "text" || last === "arguments") {
|
|
428
544
|
return segments.slice(0, -1).some((s) => CONTENT_CONTAINER_SEGMENTS.has(s));
|
|
429
545
|
}
|
|
430
546
|
return false;
|
|
431
547
|
}
|
|
432
|
-
function
|
|
548
|
+
function isContentEvent(name) {
|
|
549
|
+
return CONTENT_EVENT_NAMES.has(name) || name.startsWith(CONTENT_EVENT_PREFIX);
|
|
550
|
+
}
|
|
551
|
+
function isContentEventAttribute(key) {
|
|
552
|
+
if (isContentKey(key)) return true;
|
|
553
|
+
const last = key.slice(key.lastIndexOf(".") + 1);
|
|
554
|
+
return !(CONTENT_KEYS_KEEP_EXACT.has(key) || CONTENT_EVENT_KEEP_KEYS.has(key) || hasKeepLastSegment(last));
|
|
555
|
+
}
|
|
556
|
+
function jsonObjectContentKeys(keyPath, key) {
|
|
557
|
+
for (const [ruleKey, keys] of CONTENT_IN_JSON_OBJECT) {
|
|
558
|
+
if (ruleKey === keyPath || ruleKey === key) return keys;
|
|
559
|
+
}
|
|
560
|
+
return void 0;
|
|
561
|
+
}
|
|
562
|
+
function isJsonObject(value) {
|
|
563
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
564
|
+
}
|
|
565
|
+
function flatValueRule(keyPath, key) {
|
|
566
|
+
for (const [ruleKey, keys] of CONTENT_IN_JSON_OBJECT) {
|
|
567
|
+
for (const k of [keyPath, key]) {
|
|
568
|
+
if (k.startsWith(`${ruleKey}.`)) return [k.slice(ruleKey.length + 1), keys];
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
return void 0;
|
|
572
|
+
}
|
|
573
|
+
function normalisedKey(key) {
|
|
574
|
+
return key.replace(/_/g, "").replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
575
|
+
}
|
|
576
|
+
function namesListedKey(key, keys) {
|
|
577
|
+
return key.split(".").some((part) => keys.has(normalisedKey(part)));
|
|
578
|
+
}
|
|
579
|
+
function isKeyRuleText(keyPath, key) {
|
|
580
|
+
return isContentKey(keyPath) || isContentKey(key);
|
|
581
|
+
}
|
|
582
|
+
function startsAsJson(text) {
|
|
583
|
+
return /^[ \t\n\r]*[{[]/.test(text);
|
|
584
|
+
}
|
|
585
|
+
function parseJson(text) {
|
|
586
|
+
return JSON.parse(text, (_key, value) => {
|
|
587
|
+
if (typeof value === "number" && !Number.isFinite(value)) {
|
|
588
|
+
throw new RangeError("not JSON: a number out of range");
|
|
589
|
+
}
|
|
590
|
+
return value;
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
function jsonCopy(value) {
|
|
594
|
+
return parseJson(
|
|
595
|
+
JSON.stringify(value, (_key, v) => {
|
|
596
|
+
if (typeof v === "number" && !Number.isFinite(v)) throw new RangeError("not JSON: a non-finite number");
|
|
597
|
+
return v;
|
|
598
|
+
})
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
function omitInJsonObject(value, keyPath, keys) {
|
|
602
|
+
try {
|
|
603
|
+
let parsed;
|
|
604
|
+
if (typeof value === "string") parsed = parseJson(value);
|
|
605
|
+
else if (typeof value === "object" && value !== null) parsed = jsonCopy(value);
|
|
606
|
+
if (!isJsonObject(parsed)) return [CONTENT_OMITTED_MARKER, 1];
|
|
607
|
+
let n = 0;
|
|
608
|
+
for (const k of Object.keys(parsed)) {
|
|
609
|
+
const [entry, count] = omitInParameterEntry(parsed[k], `${keyPath}.${k}`, k, keys);
|
|
610
|
+
parsed[k] = entry;
|
|
611
|
+
n += count;
|
|
612
|
+
}
|
|
613
|
+
return [typeof value === "string" ? JSON.stringify(parsed) : parsed, n];
|
|
614
|
+
} catch {
|
|
615
|
+
return [CONTENT_OMITTED_MARKER, 1];
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
function omitInParameterEntry(value, keyPath, key, keys) {
|
|
619
|
+
if (namesListedKey(key, keys) || isKeyRuleText(keyPath, key)) return [CONTENT_OMITTED_MARKER, 1];
|
|
620
|
+
return omitInParameter(value, keyPath, keys);
|
|
621
|
+
}
|
|
622
|
+
function omitInParameter(value, path, keys) {
|
|
433
623
|
let n = 0;
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
624
|
+
if (Array.isArray(value)) {
|
|
625
|
+
value.forEach((item, i) => {
|
|
626
|
+
const [entry, count] = omitInParameter(item, `${path}.${i}`, keys);
|
|
627
|
+
value[i] = entry;
|
|
628
|
+
n += count;
|
|
629
|
+
});
|
|
630
|
+
} else if (isJsonObject(value)) {
|
|
631
|
+
for (const k of Object.keys(value)) {
|
|
632
|
+
const [entry, count] = omitInParameterEntry(value[k], `${path}.${k}`, k, keys);
|
|
633
|
+
value[k] = entry;
|
|
634
|
+
n += count;
|
|
635
|
+
}
|
|
636
|
+
} else if (typeof value === "string" && startsAsJson(value)) {
|
|
637
|
+
try {
|
|
638
|
+
const [tree, count] = omitInParameter(parseJson(value), path, keys);
|
|
639
|
+
return [count ? JSON.stringify(tree) : value, count];
|
|
640
|
+
} catch {
|
|
641
|
+
return [CONTENT_OMITTED_MARKER, 1];
|
|
438
642
|
}
|
|
439
643
|
}
|
|
644
|
+
return [value, n];
|
|
645
|
+
}
|
|
646
|
+
function omitFlat(value, keyPath, key, rest, keys) {
|
|
647
|
+
if (namesListedKey(rest, keys) || isKeyRuleText(keyPath, key)) return [CONTENT_OMITTED_MARKER, 1];
|
|
648
|
+
try {
|
|
649
|
+
if (typeof value === "object" && value !== null) {
|
|
650
|
+
const [tree, n] = omitInParameter(jsonCopy(value), keyPath, keys);
|
|
651
|
+
return n ? [tree, n] : [value, 0];
|
|
652
|
+
}
|
|
653
|
+
return omitInParameter(value, keyPath, keys);
|
|
654
|
+
} catch {
|
|
655
|
+
return [CONTENT_OMITTED_MARKER, 1];
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
function omitBelow(value, path) {
|
|
659
|
+
const text = typeof value === "string" ? value : value instanceof String ? value.valueOf() : void 0;
|
|
660
|
+
if (text !== void 0) {
|
|
661
|
+
let tree;
|
|
662
|
+
try {
|
|
663
|
+
tree = parseJson(text);
|
|
664
|
+
} catch {
|
|
665
|
+
return startsAsJson(text) ? [CONTENT_OMITTED_MARKER, 1] : [value, 0];
|
|
666
|
+
}
|
|
667
|
+
if (typeof tree !== "object" || tree === null) return [value, 0];
|
|
668
|
+
try {
|
|
669
|
+
const [n, found] = omitBelowParsed(tree, path);
|
|
670
|
+
return found ? [JSON.stringify(tree), n] : [value, 0];
|
|
671
|
+
} catch {
|
|
672
|
+
return [CONTENT_OMITTED_MARKER, 1];
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
if (typeof value !== "object" || value === null) return [value, 0];
|
|
676
|
+
try {
|
|
677
|
+
const tree = jsonCopy(value);
|
|
678
|
+
const [n, found] = omitBelowParsed(tree, path);
|
|
679
|
+
return found ? [tree, n] : [value, 0];
|
|
680
|
+
} catch {
|
|
681
|
+
return [CONTENT_OMITTED_MARKER, 1];
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
function omitBelowParsed(tree, path) {
|
|
685
|
+
let n = 0;
|
|
686
|
+
let found = false;
|
|
687
|
+
if (Array.isArray(tree)) {
|
|
688
|
+
tree.forEach((item, i) => {
|
|
689
|
+
const child = `${path}.${i}`;
|
|
690
|
+
if (!VALUE_RULE_PREFIXES.has(child)) return;
|
|
691
|
+
const [count, below] = omitBelowParsed(item, child);
|
|
692
|
+
n += count;
|
|
693
|
+
found ||= below;
|
|
694
|
+
});
|
|
695
|
+
} else if (isJsonObject(tree)) {
|
|
696
|
+
for (const k of Object.keys(tree)) {
|
|
697
|
+
const child = `${path}.${k}`;
|
|
698
|
+
const keys = jsonObjectContentKeys(child, k);
|
|
699
|
+
const flat = keys ? void 0 : flatValueRule(child, k);
|
|
700
|
+
if (keys) {
|
|
701
|
+
const [entry, count] = omitInJsonObject(tree[k], child, keys);
|
|
702
|
+
tree[k] = entry;
|
|
703
|
+
n += count;
|
|
704
|
+
found = true;
|
|
705
|
+
} else if (flat) {
|
|
706
|
+
const [entry, count] = omitFlat(tree[k], child, k, flat[0], flat[1]);
|
|
707
|
+
tree[k] = entry;
|
|
708
|
+
n += count;
|
|
709
|
+
found = true;
|
|
710
|
+
} else if (VALUE_RULE_PREFIXES.has(child)) {
|
|
711
|
+
const [count, below] = omitBelowParsed(tree[k], child);
|
|
712
|
+
n += count;
|
|
713
|
+
found ||= below;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
return [n, found];
|
|
718
|
+
}
|
|
719
|
+
function reachesValueRule(key) {
|
|
720
|
+
return CONTENT_IN_JSON_OBJECT.has(key) || VALUE_RULE_PREFIXES.has(key) || flatValueRule(key, key) !== void 0;
|
|
721
|
+
}
|
|
722
|
+
function stripAttributes(attrs, rule = isContentKey) {
|
|
723
|
+
let n = 0;
|
|
724
|
+
for (const k of Object.keys(attrs)) {
|
|
725
|
+
const keys = rule === isContentKey ? jsonObjectContentKeys(k, k) : void 0;
|
|
726
|
+
const flat = rule === isContentKey && !keys ? flatValueRule(k, k) : void 0;
|
|
727
|
+
let result;
|
|
728
|
+
if (keys) result = omitInJsonObject(attrs[k], k, keys);
|
|
729
|
+
else if (flat) result = omitFlat(attrs[k], k, k, flat[0], flat[1]);
|
|
730
|
+
else if (rule(k)) result = [CONTENT_OMITTED_MARKER, 1];
|
|
731
|
+
else if (VALUE_RULE_PREFIXES.has(k)) result = omitBelow(attrs[k], k);
|
|
732
|
+
else continue;
|
|
733
|
+
attrs[k] = result[0];
|
|
734
|
+
n += result[1];
|
|
735
|
+
}
|
|
440
736
|
return n;
|
|
441
737
|
}
|
|
738
|
+
function stripOwned(holder, rule = isContentKey) {
|
|
739
|
+
const attrs = holder.attributes;
|
|
740
|
+
if (!attrs || typeof attrs !== "object" || !Object.keys(attrs).some((k) => rule(k) || reachesValueRule(k))) {
|
|
741
|
+
return 0;
|
|
742
|
+
}
|
|
743
|
+
const copy = { ...attrs };
|
|
744
|
+
try {
|
|
745
|
+
holder.attributes = copy;
|
|
746
|
+
} catch {
|
|
747
|
+
return stripAttributes(attrs, rule);
|
|
748
|
+
}
|
|
749
|
+
if (holder.attributes !== copy) return stripAttributes(attrs, rule);
|
|
750
|
+
return stripAttributes(copy, rule);
|
|
751
|
+
}
|
|
442
752
|
function stripContent(span) {
|
|
443
753
|
let stripped = 0;
|
|
444
754
|
if (span.attributes && typeof span.attributes === "object") {
|
|
@@ -447,14 +757,15 @@ function stripContent(span) {
|
|
|
447
757
|
if (Array.isArray(span.events)) {
|
|
448
758
|
for (const event of span.events) {
|
|
449
759
|
if (event?.attributes && typeof event.attributes === "object") {
|
|
450
|
-
|
|
760
|
+
const messageEvent = typeof event.name === "string" && isContentEvent(event.name);
|
|
761
|
+
stripped += stripOwned(event, messageEvent ? isContentEventAttribute : isContentKey);
|
|
451
762
|
}
|
|
452
763
|
}
|
|
453
764
|
}
|
|
454
765
|
if (Array.isArray(span.links)) {
|
|
455
766
|
for (const link of span.links) {
|
|
456
767
|
if (link?.attributes && typeof link.attributes === "object") {
|
|
457
|
-
stripped +=
|
|
768
|
+
stripped += stripOwned(link);
|
|
458
769
|
}
|
|
459
770
|
}
|
|
460
771
|
}
|
|
@@ -1286,7 +1597,7 @@ function resolveConfig(config) {
|
|
|
1286
1597
|
const environment = config?.environment || env.RISICARE_ENVIRONMENT || "development";
|
|
1287
1598
|
const serviceName = config?.serviceName ?? env.RISICARE_SERVICE_NAME;
|
|
1288
1599
|
const serviceVersion = config?.serviceVersion ?? env.RISICARE_SERVICE_VERSION;
|
|
1289
|
-
const traceContent = config?.traceContent ?? parseBool(env.RISICARE_TRACE_CONTENT,
|
|
1600
|
+
const traceContent = config?.traceContent ?? parseBool(env.RISICARE_TRACE_CONTENT, true);
|
|
1290
1601
|
const sampleRateRaw = config?.sampleRate ?? parseFloat(env.RISICARE_SAMPLE_RATE ?? "1.0");
|
|
1291
1602
|
const debug2 = config?.debug ?? parseBool(env.RISICARE_DEBUG, false);
|
|
1292
1603
|
const compress = config?.compress ?? parseBool(env.RISICARE_COMPRESS, false);
|
|
@@ -2491,7 +2802,7 @@ function markCancel(span, error) {
|
|
|
2491
2802
|
}
|
|
2492
2803
|
|
|
2493
2804
|
// src/version.ts
|
|
2494
|
-
var SDK_VERSION = "0.
|
|
2805
|
+
var SDK_VERSION = "0.10.0";
|
|
2495
2806
|
|
|
2496
2807
|
// src/exporters/quota.ts
|
|
2497
2808
|
var QUOTA_REASON = "monthly_quota_exceeded";
|
|
@@ -4587,7 +4898,10 @@ function init(config) {
|
|
|
4587
4898
|
"environment",
|
|
4588
4899
|
"serviceName",
|
|
4589
4900
|
"serviceVersion",
|
|
4590
|
-
"sampleRate"
|
|
4901
|
+
"sampleRate",
|
|
4902
|
+
// Capture is on by default (R9): a library's early init() must not
|
|
4903
|
+
// make the program's traceContent: false void in silence.
|
|
4904
|
+
"traceContent"
|
|
4591
4905
|
];
|
|
4592
4906
|
for (const k of checkedKeys) {
|
|
4593
4907
|
if (incoming[k] !== existing.config[k]) {
|