@raindrop-ai/deep-agents 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/dist/index.d.mts +77 -3
- package/dist/index.d.ts +77 -3
- package/dist/index.js +712 -103
- package/dist/index.mjs +716 -103
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -56,6 +56,16 @@ await raindrop.shutdown();
|
|
|
56
56
|
| `projectId` | `string` | - | Route events to a specific project (slug); omit for the default **Production** project |
|
|
57
57
|
| `debug` | `boolean` | `false` | Enable verbose logging |
|
|
58
58
|
| `traceChains` | `boolean` | `true` | Create spans for chain execution |
|
|
59
|
+
| `tools` | `ToolDeclaration[]` | - | Overrides the tool catalog recorded as `ai.prompt.tools` on every model span. Use when the integration cannot see the tools the model was given. |
|
|
60
|
+
|
|
61
|
+
### Tool catalog capture
|
|
62
|
+
|
|
63
|
+
Every model span (`llm`) records the tools the agent's chat model was given for
|
|
64
|
+
that call as `ai.prompt.tools` (one JSON document per tool: `name`, `description`,
|
|
65
|
+
full JSON Schema as `inputSchema`). It is read from the callback's
|
|
66
|
+
`invocation_params.tools` / `functions`, which ChatOpenAI, ChatAnthropic and similar
|
|
67
|
+
models populate from `bindTools()`. Absent when the model reports no list; pass
|
|
68
|
+
`tools` to record a catalog explicitly (`tools: []` records an empty one).
|
|
59
69
|
|
|
60
70
|
## Projects
|
|
61
71
|
|
|
@@ -139,7 +149,7 @@ The `createRaindropDeepAgents()` factory returns:
|
|
|
139
149
|
- **Streaming**: Token-by-token streaming events are not captured individually; only the final aggregated response is tracked.
|
|
140
150
|
- **Subagent isolation**: When using the `task` tool for subagent delegation, each subagent's callbacks fire independently.
|
|
141
151
|
- **Concurrent invocations on a shared handler**: A single handler instance keeps one in-flight span map at a time. Running multiple `agent.invoke(...)` calls **concurrently with the same handler** (e.g. `Promise.all([agent.invoke(...), agent.invoke(...)])` with the same `raindrop.handler`) can scramble the linkage between events and traces. Instantiate one `createRaindropDeepAgents()` per concurrent request; sequential invocations on a shared handler are fully supported.
|
|
142
|
-
- **Long
|
|
152
|
+
- **Long inputs/outputs are truncated at `maxTextFieldChars`**: The root event's `input` is the latest user message and its `output` the final response, each capped at the configured `maxTextFieldChars` (default 1,000,000 chars), the same cap the other JavaScript integrations use; the full conversation history lives on the LLM span (`ai.prompt.messages`). Tool payloads are pruned to the cap _before_ JSON serialization, so a multi-MB tool output costs the cap — not the payload — on your event loop (truncated values carry a `...[truncated by raindrop]` marker).
|
|
143
153
|
|
|
144
154
|
## Testing
|
|
145
155
|
|
package/dist/index.d.mts
CHANGED
|
@@ -509,6 +509,46 @@ declare global {
|
|
|
509
509
|
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => AsyncLocalStorageLike<T>) | undefined;
|
|
510
510
|
}
|
|
511
511
|
|
|
512
|
+
/**
|
|
513
|
+
* `ai.prompt.tools`: the tool catalog a model call was given, one JSON
|
|
514
|
+
* document per tool, in the shape the Vercel AI SDK records on its
|
|
515
|
+
* `doGenerate` / `doStream` spans. Every integration emits this attribute on
|
|
516
|
+
* its model-call spans so downstream consumers (agent replay, world builder)
|
|
517
|
+
* can read what the model could call instead of guessing from the calls it
|
|
518
|
+
* happened to make.
|
|
519
|
+
*
|
|
520
|
+
* An absent attribute means the integration could not observe the tool list;
|
|
521
|
+
* an empty array means the model had no tools. Callers who know better than
|
|
522
|
+
* the integration pass a `tools` override, which replaces the inferred list.
|
|
523
|
+
*/
|
|
524
|
+
declare const PROMPT_TOOLS_ATTRIBUTE = "ai.prompt.tools";
|
|
525
|
+
type JsonSchema = Record<string, unknown>;
|
|
526
|
+
type FunctionToolDeclaration = {
|
|
527
|
+
type: "function";
|
|
528
|
+
name: string;
|
|
529
|
+
description?: string;
|
|
530
|
+
inputSchema?: JsonSchema;
|
|
531
|
+
};
|
|
532
|
+
type ProviderDefinedToolDeclaration = {
|
|
533
|
+
type: "provider-defined";
|
|
534
|
+
id?: string;
|
|
535
|
+
name: string;
|
|
536
|
+
args?: Record<string, unknown>;
|
|
537
|
+
};
|
|
538
|
+
type ToolDeclaration = FunctionToolDeclaration | ProviderDefinedToolDeclaration;
|
|
539
|
+
/**
|
|
540
|
+
* What callers hand to a `tools` override. The canonical `ToolDeclaration`
|
|
541
|
+
* shape is accepted as-is; so is any framework shape `normalizeToolDeclarations`
|
|
542
|
+
* recognizes (OpenAI, Anthropic, Bedrock, LangChain, Pi, Mastra, AI SDK).
|
|
543
|
+
*/
|
|
544
|
+
type ToolDeclarationInput = ToolDeclaration | {
|
|
545
|
+
name: string;
|
|
546
|
+
description?: string;
|
|
547
|
+
inputSchema?: JsonSchema;
|
|
548
|
+
parameters?: JsonSchema;
|
|
549
|
+
};
|
|
550
|
+
type PromptToolsOverride = ReadonlyArray<ToolDeclarationInput | unknown>;
|
|
551
|
+
|
|
512
552
|
interface RaindropDeepAgentsHandlerOptions {
|
|
513
553
|
eventShipper: EventShipper;
|
|
514
554
|
traceShipper: TraceShipper;
|
|
@@ -517,6 +557,21 @@ interface RaindropDeepAgentsHandlerOptions {
|
|
|
517
557
|
eventName?: string;
|
|
518
558
|
eventId?: () => string;
|
|
519
559
|
traceChains?: boolean;
|
|
560
|
+
/**
|
|
561
|
+
* Per-field caps this handler captures against, fixed for its lifetime:
|
|
562
|
+
* `maxTextFieldChars` for span attributes (further reduced by
|
|
563
|
+
* `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` as each span is captured, the
|
|
564
|
+
* way the trace shipper applies it), `eventMaxTextFieldChars` for event
|
|
565
|
+
* `input`/`output`. Default to the module-wide cap at construction.
|
|
566
|
+
*/
|
|
567
|
+
maxTextFieldChars?: number;
|
|
568
|
+
eventMaxTextFieldChars?: number;
|
|
569
|
+
/**
|
|
570
|
+
* Overrides the tool catalog recorded as `ai.prompt.tools` on every model
|
|
571
|
+
* span. Use when the integration cannot see the tools the model was given.
|
|
572
|
+
* Replaces the inferred list entirely; `[]` records an empty catalog.
|
|
573
|
+
*/
|
|
574
|
+
tools?: PromptToolsOverride;
|
|
520
575
|
}
|
|
521
576
|
declare class RaindropDeepAgentsHandler extends BaseCallbackHandler {
|
|
522
577
|
name: string;
|
|
@@ -527,6 +582,9 @@ declare class RaindropDeepAgentsHandler extends BaseCallbackHandler {
|
|
|
527
582
|
private eventName?;
|
|
528
583
|
private eventIdSource?;
|
|
529
584
|
private traceChains;
|
|
585
|
+
private readonly configuredSpanMaxChars;
|
|
586
|
+
private readonly eventMaxChars;
|
|
587
|
+
private readonly promptTools;
|
|
530
588
|
private spans;
|
|
531
589
|
private rootRunIds;
|
|
532
590
|
private eventIds;
|
|
@@ -539,13 +597,15 @@ declare class RaindropDeepAgentsHandler extends BaseCallbackHandler {
|
|
|
539
597
|
*/
|
|
540
598
|
_lastRootEventId: string | undefined;
|
|
541
599
|
constructor(opts: RaindropDeepAgentsHandlerOptions);
|
|
600
|
+
private promptToolsAttribute;
|
|
601
|
+
private get spanMaxChars();
|
|
542
602
|
private getEventId;
|
|
543
603
|
private getParent;
|
|
544
604
|
private cleanup;
|
|
545
605
|
private finalizeEventIfRoot;
|
|
546
606
|
private rootErrorPatch;
|
|
547
|
-
handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string,
|
|
548
|
-
handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string,
|
|
607
|
+
handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
|
|
608
|
+
handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
|
|
549
609
|
handleLLMEnd(output: LLMResult, runId: string, _parentRunId?: string): Promise<void>;
|
|
550
610
|
handleLLMError(err: unknown, runId: string): Promise<void>;
|
|
551
611
|
handleChainStart(chain: Serialized, _inputs: ChainValues, runId: string, parentRunId?: string, _tags?: string[], _metadata?: Record<string, unknown>, _runType?: string, runName?: string): Promise<void>;
|
|
@@ -587,8 +647,22 @@ interface DeepAgentsOptions {
|
|
|
587
647
|
*/
|
|
588
648
|
projectId?: string;
|
|
589
649
|
traceChains?: boolean;
|
|
650
|
+
/**
|
|
651
|
+
* Per-field character cap for captured text and JSON (`ai.prompt.messages`,
|
|
652
|
+
* `ai.toolCall.args` / `ai.toolCall.result`, event `input` / `output`).
|
|
653
|
+
* A history that does not fit is cut at message boundaries, stays valid
|
|
654
|
+
* JSON and is flagged with `ai.prompt.messages.truncated`. Module-wide,
|
|
655
|
+
* shared with the underlying shippers; omitting it leaves the current cap
|
|
656
|
+
* unchanged. Defaults to 1,000,000.
|
|
657
|
+
*/
|
|
658
|
+
maxTextFieldChars?: number;
|
|
590
659
|
/** Application Git identity. Auto-detects commit SHA by default; pass `false` to disable. */
|
|
591
660
|
appGit?: AppGitOptions | false;
|
|
661
|
+
/**
|
|
662
|
+
* Overrides the tool catalog recorded as `ai.prompt.tools` on every model
|
|
663
|
+
* span. Use when the integration cannot see the tools the model was given.
|
|
664
|
+
*/
|
|
665
|
+
tools?: PromptToolsOverride;
|
|
592
666
|
}
|
|
593
667
|
type RaindropDeepAgentsClient = {
|
|
594
668
|
/**
|
|
@@ -676,4 +750,4 @@ type RaindropDeepAgentsClient = {
|
|
|
676
750
|
*/
|
|
677
751
|
declare function createRaindropDeepAgents(opts: DeepAgentsOptions): RaindropDeepAgentsClient;
|
|
678
752
|
|
|
679
|
-
export { type DeepAgentsOptions, type RaindropDeepAgentsClient, RaindropDeepAgentsHandler, createRaindropDeepAgents };
|
|
753
|
+
export { type DeepAgentsOptions, PROMPT_TOOLS_ATTRIBUTE, type PromptToolsOverride, type RaindropDeepAgentsClient, RaindropDeepAgentsHandler, type ToolDeclaration, createRaindropDeepAgents };
|
package/dist/index.d.ts
CHANGED
|
@@ -509,6 +509,46 @@ declare global {
|
|
|
509
509
|
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => AsyncLocalStorageLike<T>) | undefined;
|
|
510
510
|
}
|
|
511
511
|
|
|
512
|
+
/**
|
|
513
|
+
* `ai.prompt.tools`: the tool catalog a model call was given, one JSON
|
|
514
|
+
* document per tool, in the shape the Vercel AI SDK records on its
|
|
515
|
+
* `doGenerate` / `doStream` spans. Every integration emits this attribute on
|
|
516
|
+
* its model-call spans so downstream consumers (agent replay, world builder)
|
|
517
|
+
* can read what the model could call instead of guessing from the calls it
|
|
518
|
+
* happened to make.
|
|
519
|
+
*
|
|
520
|
+
* An absent attribute means the integration could not observe the tool list;
|
|
521
|
+
* an empty array means the model had no tools. Callers who know better than
|
|
522
|
+
* the integration pass a `tools` override, which replaces the inferred list.
|
|
523
|
+
*/
|
|
524
|
+
declare const PROMPT_TOOLS_ATTRIBUTE = "ai.prompt.tools";
|
|
525
|
+
type JsonSchema = Record<string, unknown>;
|
|
526
|
+
type FunctionToolDeclaration = {
|
|
527
|
+
type: "function";
|
|
528
|
+
name: string;
|
|
529
|
+
description?: string;
|
|
530
|
+
inputSchema?: JsonSchema;
|
|
531
|
+
};
|
|
532
|
+
type ProviderDefinedToolDeclaration = {
|
|
533
|
+
type: "provider-defined";
|
|
534
|
+
id?: string;
|
|
535
|
+
name: string;
|
|
536
|
+
args?: Record<string, unknown>;
|
|
537
|
+
};
|
|
538
|
+
type ToolDeclaration = FunctionToolDeclaration | ProviderDefinedToolDeclaration;
|
|
539
|
+
/**
|
|
540
|
+
* What callers hand to a `tools` override. The canonical `ToolDeclaration`
|
|
541
|
+
* shape is accepted as-is; so is any framework shape `normalizeToolDeclarations`
|
|
542
|
+
* recognizes (OpenAI, Anthropic, Bedrock, LangChain, Pi, Mastra, AI SDK).
|
|
543
|
+
*/
|
|
544
|
+
type ToolDeclarationInput = ToolDeclaration | {
|
|
545
|
+
name: string;
|
|
546
|
+
description?: string;
|
|
547
|
+
inputSchema?: JsonSchema;
|
|
548
|
+
parameters?: JsonSchema;
|
|
549
|
+
};
|
|
550
|
+
type PromptToolsOverride = ReadonlyArray<ToolDeclarationInput | unknown>;
|
|
551
|
+
|
|
512
552
|
interface RaindropDeepAgentsHandlerOptions {
|
|
513
553
|
eventShipper: EventShipper;
|
|
514
554
|
traceShipper: TraceShipper;
|
|
@@ -517,6 +557,21 @@ interface RaindropDeepAgentsHandlerOptions {
|
|
|
517
557
|
eventName?: string;
|
|
518
558
|
eventId?: () => string;
|
|
519
559
|
traceChains?: boolean;
|
|
560
|
+
/**
|
|
561
|
+
* Per-field caps this handler captures against, fixed for its lifetime:
|
|
562
|
+
* `maxTextFieldChars` for span attributes (further reduced by
|
|
563
|
+
* `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` as each span is captured, the
|
|
564
|
+
* way the trace shipper applies it), `eventMaxTextFieldChars` for event
|
|
565
|
+
* `input`/`output`. Default to the module-wide cap at construction.
|
|
566
|
+
*/
|
|
567
|
+
maxTextFieldChars?: number;
|
|
568
|
+
eventMaxTextFieldChars?: number;
|
|
569
|
+
/**
|
|
570
|
+
* Overrides the tool catalog recorded as `ai.prompt.tools` on every model
|
|
571
|
+
* span. Use when the integration cannot see the tools the model was given.
|
|
572
|
+
* Replaces the inferred list entirely; `[]` records an empty catalog.
|
|
573
|
+
*/
|
|
574
|
+
tools?: PromptToolsOverride;
|
|
520
575
|
}
|
|
521
576
|
declare class RaindropDeepAgentsHandler extends BaseCallbackHandler {
|
|
522
577
|
name: string;
|
|
@@ -527,6 +582,9 @@ declare class RaindropDeepAgentsHandler extends BaseCallbackHandler {
|
|
|
527
582
|
private eventName?;
|
|
528
583
|
private eventIdSource?;
|
|
529
584
|
private traceChains;
|
|
585
|
+
private readonly configuredSpanMaxChars;
|
|
586
|
+
private readonly eventMaxChars;
|
|
587
|
+
private readonly promptTools;
|
|
530
588
|
private spans;
|
|
531
589
|
private rootRunIds;
|
|
532
590
|
private eventIds;
|
|
@@ -539,13 +597,15 @@ declare class RaindropDeepAgentsHandler extends BaseCallbackHandler {
|
|
|
539
597
|
*/
|
|
540
598
|
_lastRootEventId: string | undefined;
|
|
541
599
|
constructor(opts: RaindropDeepAgentsHandlerOptions);
|
|
600
|
+
private promptToolsAttribute;
|
|
601
|
+
private get spanMaxChars();
|
|
542
602
|
private getEventId;
|
|
543
603
|
private getParent;
|
|
544
604
|
private cleanup;
|
|
545
605
|
private finalizeEventIfRoot;
|
|
546
606
|
private rootErrorPatch;
|
|
547
|
-
handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string,
|
|
548
|
-
handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string,
|
|
607
|
+
handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
|
|
608
|
+
handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
|
|
549
609
|
handleLLMEnd(output: LLMResult, runId: string, _parentRunId?: string): Promise<void>;
|
|
550
610
|
handleLLMError(err: unknown, runId: string): Promise<void>;
|
|
551
611
|
handleChainStart(chain: Serialized, _inputs: ChainValues, runId: string, parentRunId?: string, _tags?: string[], _metadata?: Record<string, unknown>, _runType?: string, runName?: string): Promise<void>;
|
|
@@ -587,8 +647,22 @@ interface DeepAgentsOptions {
|
|
|
587
647
|
*/
|
|
588
648
|
projectId?: string;
|
|
589
649
|
traceChains?: boolean;
|
|
650
|
+
/**
|
|
651
|
+
* Per-field character cap for captured text and JSON (`ai.prompt.messages`,
|
|
652
|
+
* `ai.toolCall.args` / `ai.toolCall.result`, event `input` / `output`).
|
|
653
|
+
* A history that does not fit is cut at message boundaries, stays valid
|
|
654
|
+
* JSON and is flagged with `ai.prompt.messages.truncated`. Module-wide,
|
|
655
|
+
* shared with the underlying shippers; omitting it leaves the current cap
|
|
656
|
+
* unchanged. Defaults to 1,000,000.
|
|
657
|
+
*/
|
|
658
|
+
maxTextFieldChars?: number;
|
|
590
659
|
/** Application Git identity. Auto-detects commit SHA by default; pass `false` to disable. */
|
|
591
660
|
appGit?: AppGitOptions | false;
|
|
661
|
+
/**
|
|
662
|
+
* Overrides the tool catalog recorded as `ai.prompt.tools` on every model
|
|
663
|
+
* span. Use when the integration cannot see the tools the model was given.
|
|
664
|
+
*/
|
|
665
|
+
tools?: PromptToolsOverride;
|
|
592
666
|
}
|
|
593
667
|
type RaindropDeepAgentsClient = {
|
|
594
668
|
/**
|
|
@@ -676,4 +750,4 @@ type RaindropDeepAgentsClient = {
|
|
|
676
750
|
*/
|
|
677
751
|
declare function createRaindropDeepAgents(opts: DeepAgentsOptions): RaindropDeepAgentsClient;
|
|
678
752
|
|
|
679
|
-
export { type DeepAgentsOptions, type RaindropDeepAgentsClient, RaindropDeepAgentsHandler, createRaindropDeepAgents };
|
|
753
|
+
export { type DeepAgentsOptions, PROMPT_TOOLS_ATTRIBUTE, type PromptToolsOverride, type RaindropDeepAgentsClient, RaindropDeepAgentsHandler, type ToolDeclaration, createRaindropDeepAgents };
|