risicare 0.5.0 → 0.6.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.
Files changed (72) hide show
  1. package/README.md +44 -6
  2. package/dist/frameworks/instructor.cjs +9 -0
  3. package/dist/frameworks/instructor.cjs.map +1 -1
  4. package/dist/frameworks/instructor.js +9 -0
  5. package/dist/frameworks/instructor.js.map +1 -1
  6. package/dist/frameworks/langchain.cjs +9 -0
  7. package/dist/frameworks/langchain.cjs.map +1 -1
  8. package/dist/frameworks/langchain.js +9 -0
  9. package/dist/frameworks/langchain.js.map +1 -1
  10. package/dist/frameworks/langgraph.cjs +9 -0
  11. package/dist/frameworks/langgraph.cjs.map +1 -1
  12. package/dist/frameworks/langgraph.js +9 -0
  13. package/dist/frameworks/langgraph.js.map +1 -1
  14. package/dist/frameworks/llamaindex.cjs +9 -0
  15. package/dist/frameworks/llamaindex.cjs.map +1 -1
  16. package/dist/frameworks/llamaindex.js +9 -0
  17. package/dist/frameworks/llamaindex.js.map +1 -1
  18. package/dist/index.cjs +685 -313
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +38 -2
  21. package/dist/index.d.ts +38 -2
  22. package/dist/index.js +685 -313
  23. package/dist/index.js.map +1 -1
  24. package/dist/providers/anthropic/index.cjs +9 -0
  25. package/dist/providers/anthropic/index.cjs.map +1 -1
  26. package/dist/providers/anthropic/index.js +9 -0
  27. package/dist/providers/anthropic/index.js.map +1 -1
  28. package/dist/providers/bedrock/index.cjs +9 -0
  29. package/dist/providers/bedrock/index.cjs.map +1 -1
  30. package/dist/providers/bedrock/index.js +9 -0
  31. package/dist/providers/bedrock/index.js.map +1 -1
  32. package/dist/providers/cerebras/index.cjs +9 -0
  33. package/dist/providers/cerebras/index.cjs.map +1 -1
  34. package/dist/providers/cerebras/index.js +9 -0
  35. package/dist/providers/cerebras/index.js.map +1 -1
  36. package/dist/providers/cohere/index.cjs +9 -0
  37. package/dist/providers/cohere/index.cjs.map +1 -1
  38. package/dist/providers/cohere/index.js +9 -0
  39. package/dist/providers/cohere/index.js.map +1 -1
  40. package/dist/providers/google/index.cjs +9 -0
  41. package/dist/providers/google/index.cjs.map +1 -1
  42. package/dist/providers/google/index.js +9 -0
  43. package/dist/providers/google/index.js.map +1 -1
  44. package/dist/providers/groq/index.cjs +9 -0
  45. package/dist/providers/groq/index.cjs.map +1 -1
  46. package/dist/providers/groq/index.js +9 -0
  47. package/dist/providers/groq/index.js.map +1 -1
  48. package/dist/providers/huggingface/index.cjs +9 -0
  49. package/dist/providers/huggingface/index.cjs.map +1 -1
  50. package/dist/providers/huggingface/index.js +9 -0
  51. package/dist/providers/huggingface/index.js.map +1 -1
  52. package/dist/providers/mistral/index.cjs +9 -0
  53. package/dist/providers/mistral/index.cjs.map +1 -1
  54. package/dist/providers/mistral/index.js +9 -0
  55. package/dist/providers/mistral/index.js.map +1 -1
  56. package/dist/providers/ollama/index.cjs +9 -0
  57. package/dist/providers/ollama/index.cjs.map +1 -1
  58. package/dist/providers/ollama/index.js +9 -0
  59. package/dist/providers/ollama/index.js.map +1 -1
  60. package/dist/providers/openai/index.cjs +9 -0
  61. package/dist/providers/openai/index.cjs.map +1 -1
  62. package/dist/providers/openai/index.js +9 -0
  63. package/dist/providers/openai/index.js.map +1 -1
  64. package/dist/providers/together/index.cjs +9 -0
  65. package/dist/providers/together/index.cjs.map +1 -1
  66. package/dist/providers/together/index.js +9 -0
  67. package/dist/providers/together/index.js.map +1 -1
  68. package/dist/providers/vercel-ai/index.cjs +9 -0
  69. package/dist/providers/vercel-ai/index.cjs.map +1 -1
  70. package/dist/providers/vercel-ai/index.js +9 -0
  71. package/dist/providers/vercel-ai/index.js.map +1 -1
  72. package/package.json +2 -2
package/README.md CHANGED
@@ -45,6 +45,39 @@ await shutdown();
45
45
 
46
46
  **That's it.** Your agent's LLM calls, latency, token usage, and costs now appear in the [Risicare dashboard](https://app.risicare.ai).
47
47
 
48
+ ## Prompt content is NOT captured by default
49
+
50
+ **Since 0.5.1, `traceContent` defaults to `false`.** Your prompts and completions
51
+ stay in your process. Everything else — model, token counts, latency, cost,
52
+ message roles, errors, and any attributes you set — is captured as normal, so the
53
+ dashboard, cost tracking and error diagnosis all work unchanged.
54
+
55
+ To send prompt and completion text as well, opt in:
56
+
57
+ ```typescript
58
+ init({ apiKey: 'rsk-...', traceContent: true });
59
+ // or set RISICARE_TRACE_CONTENT=true
60
+ ```
61
+
62
+ **Upgrading from 0.5.0 or earlier?** This is a behaviour change: content that
63
+ used to be sent is no longer sent unless you opt in. In those versions the flag
64
+ also did not work for content you set by hand — `traceContent: false` did not
65
+ stop a `span.setAttribute('gen_ai.prompt.0.content', ...)` from reaching us.
66
+ Both are fixed together.
67
+
68
+ When capture is off, content-bearing attributes are **replaced** with
69
+ `<risicare:content-omitted>` rather than removed, so "no prompt was sent" stays
70
+ distinguishable from "capture is off".
71
+
72
+ If you want content captured but redacted first, use the `mask` hook — it is
73
+ independent of this switch and runs on every content-bearing field before
74
+ export:
75
+
76
+ ```typescript
77
+ init({ apiKey: 'rsk-...', traceContent: true, mask: (key, value) => value });
78
+ ```
79
+
80
+
48
81
  ## Features
49
82
 
50
83
  - **12 LLM providers** — OpenAI, Anthropic, Google, Mistral, Groq, Cohere, Together, Ollama, HuggingFace, Cerebras, Bedrock, Vercel AI
@@ -109,9 +142,10 @@ import {
109
142
  init({ apiKey, endpoint }) // Initialize SDK
110
143
  agent({ name }, fn) // Wrap function with agent identity
111
144
  session({ sessionId, userId }, fn) // Group traces into user sessions
112
- traceThink('analyze', async () => {...}) // Tag reasoning phase
113
- traceDecide('choose', async () => {...}) // Tag decision phase
114
- traceAct('execute', async () => {...}) // Tag action phase
145
+ // These are WRAPPER FACTORIES: they return a function you then call.
146
+ await traceThink('analyze', async () => {...})() // note the trailing ()
147
+ await traceDecide('choose', async () => {...})()
148
+ await traceAct('execute', async () => {...})()
115
149
  reportError(error) // Report caught errors for diagnosis
116
150
  score(traceId, 'quality', 0.92) // Record evaluation score [0.0-1.0]
117
151
  tracedStream(asyncIterable, 'stream') // Trace async iterators
@@ -146,18 +180,22 @@ try {
146
180
  Structure your traces to see how your agent thinks, decides, and acts:
147
181
 
148
182
  ```typescript
183
+ // traceThink / traceDecide / traceAct RETURN A WRAPPED FUNCTION — they do not
184
+ // run your callback themselves. Call the result (the trailing `()` below).
185
+ // Omitting it is silent: you get a function back, your callback never runs,
186
+ // and no span is emitted.
149
187
  const myAgent = agent({ name: 'planner', role: 'coordinator' }, async (input) => {
150
188
  const analysis = await traceThink('analyze', async () => {
151
189
  return await openai.chat.completions.create({ /* ... */ });
152
- });
190
+ })();
153
191
 
154
192
  const decision = await traceDecide('choose-action', async () => {
155
193
  return pickBestAction(analysis);
156
- });
194
+ })();
157
195
 
158
196
  return await traceAct('execute', async () => {
159
197
  return executeAction(decision);
160
- });
198
+ })();
161
199
  });
162
200
  ```
163
201
 
@@ -123,6 +123,15 @@ var NOOP_SPAN = Object.freeze({
123
123
  }
124
124
  });
125
125
 
126
+ // src/runtime/taxonomy.generated.ts
127
+ var SUPPLEMENTAL_RULES = [
128
+ { re: new RegExp("timeout|timedout|aborted", "i"), code: "TOOL.EXECUTION.TIMEOUT" },
129
+ { re: new RegExp("rate.?limit|\\b429\\b|too many requests", "i"), code: "TOOL.EXECUTION.RATE_LIMITED" },
130
+ { re: new RegExp("connection|econnrefused|econnreset|enotfound|fetch failed|unreachable|broken pipe", "i"), code: "TOOL.EXECUTION.DEPENDENCY_FAILED" },
131
+ { re: new RegExp("\\bauth|unauthorized|forbidden|permission|\\b401\\b|\\b403\\b", "i"), code: "TOOL.INVOCATION.PERMISSION_DENIED" },
132
+ { re: new RegExp("json|syntaxerror|unexpected token|decodeerror", "i"), code: "PERCEPTION.PARSING.JSON_INVALID" }
133
+ ];
134
+
126
135
  // src/runtime/applier.ts
127
136
  var import_node_crypto2 = require("crypto");
128
137