raindrop-ai 0.0.42 → 0.0.43

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.
@@ -1769,6 +1769,13 @@ var NonLiveInteraction = class {
1769
1769
  return Promise.reject(error);
1770
1770
  }
1771
1771
  }
1772
+ withTool(_params, fn, thisArg, ...args) {
1773
+ try {
1774
+ return Promise.resolve(fn.apply(thisArg, args));
1775
+ } catch (error) {
1776
+ return Promise.reject(error);
1777
+ }
1778
+ }
1772
1779
  startSpan(_params) {
1773
1780
  return NO_OP_SPAN;
1774
1781
  }
@@ -99,6 +99,27 @@ interface SpanParams {
99
99
  properties?: Record<string, string>;
100
100
  inputParameters?: unknown[];
101
101
  }
102
+ /**
103
+ * Configuration for a traced tool.
104
+ *
105
+ * Tools represent external utilities or services that are invoked during an AI interaction,
106
+ * such as search engines, calculators, or other specialized functions.
107
+ *
108
+ * @property name - Name of the tool for identification in traces
109
+ * @property version - Optional version number of the tool
110
+ * @property properties - Optional key-value pairs for additional metadata
111
+ * @property inputParameters - Optional record of input parameters for the tool
112
+ * @property traceContent - Optional flag to control whether content is traced
113
+ * @property suppressTracing - Optional flag to suppress tracing for this tool invocation
114
+ */
115
+ interface ToolParams {
116
+ name: string;
117
+ version?: number;
118
+ properties?: Record<string, string>;
119
+ inputParameters?: Record<string, any>;
120
+ traceContent?: boolean;
121
+ suppressTracing?: boolean;
122
+ }
102
123
  /**
103
124
  * Represents an active tracing interaction for tracking and analyzing AI interactions.
104
125
  *
@@ -151,6 +172,43 @@ type Interaction = {
151
172
  * @returns A span that can be used to record a task
152
173
  */
153
174
  withSpan<T>(params: SpanParams, fn: (...args: any[]) => Promise<T> | T, thisArg?: any, ...args: any[]): Promise<T>;
175
+ /**
176
+ * Creates a traced tool that executes the provided function.
177
+ *
178
+ * Tools represent external utilities or services that are invoked during an AI interaction.
179
+ * This method wraps a function call with tracing to capture the tool's inputs and outputs.
180
+ *
181
+ * @param params ToolParams object with tool configuration
182
+ * @param fn Function to execute within the tool trace
183
+ * @param thisArg Optional 'this' context for the function
184
+ * @param args Optional arguments to pass to the function
185
+ * @returns A promise that resolves with the tool execution result
186
+ *
187
+ * @example
188
+ * // Basic tool usage
189
+ * const result = await interaction.withTool(
190
+ * { name: "search_tool" },
191
+ * async () => {
192
+ * // Call to external API or service
193
+ * return "Search results";
194
+ * }
195
+ * );
196
+ *
197
+ * @example
198
+ * // Basic tool usage
199
+ * const result = await interaction.withTool(
200
+ * {
201
+ * name: "calculator",
202
+ * properties: { operation: "multiply" },
203
+ * inputParameters: { a: 5, b: 10 }
204
+ * },
205
+ * async () => {
206
+ * // Tool implementation
207
+ * return "Result: 50";
208
+ * }
209
+ * );
210
+ */
211
+ withTool<T>(params: ToolParams, fn: (...args: any[]) => Promise<T> | T, thisArg?: any, ...args: any[]): Promise<T>;
154
212
  /**
155
213
  * Creates a task span that can be used to manually record a task.
156
214
  *
@@ -99,6 +99,27 @@ interface SpanParams {
99
99
  properties?: Record<string, string>;
100
100
  inputParameters?: unknown[];
101
101
  }
102
+ /**
103
+ * Configuration for a traced tool.
104
+ *
105
+ * Tools represent external utilities or services that are invoked during an AI interaction,
106
+ * such as search engines, calculators, or other specialized functions.
107
+ *
108
+ * @property name - Name of the tool for identification in traces
109
+ * @property version - Optional version number of the tool
110
+ * @property properties - Optional key-value pairs for additional metadata
111
+ * @property inputParameters - Optional record of input parameters for the tool
112
+ * @property traceContent - Optional flag to control whether content is traced
113
+ * @property suppressTracing - Optional flag to suppress tracing for this tool invocation
114
+ */
115
+ interface ToolParams {
116
+ name: string;
117
+ version?: number;
118
+ properties?: Record<string, string>;
119
+ inputParameters?: Record<string, any>;
120
+ traceContent?: boolean;
121
+ suppressTracing?: boolean;
122
+ }
102
123
  /**
103
124
  * Represents an active tracing interaction for tracking and analyzing AI interactions.
104
125
  *
@@ -151,6 +172,43 @@ type Interaction = {
151
172
  * @returns A span that can be used to record a task
152
173
  */
153
174
  withSpan<T>(params: SpanParams, fn: (...args: any[]) => Promise<T> | T, thisArg?: any, ...args: any[]): Promise<T>;
175
+ /**
176
+ * Creates a traced tool that executes the provided function.
177
+ *
178
+ * Tools represent external utilities or services that are invoked during an AI interaction.
179
+ * This method wraps a function call with tracing to capture the tool's inputs and outputs.
180
+ *
181
+ * @param params ToolParams object with tool configuration
182
+ * @param fn Function to execute within the tool trace
183
+ * @param thisArg Optional 'this' context for the function
184
+ * @param args Optional arguments to pass to the function
185
+ * @returns A promise that resolves with the tool execution result
186
+ *
187
+ * @example
188
+ * // Basic tool usage
189
+ * const result = await interaction.withTool(
190
+ * { name: "search_tool" },
191
+ * async () => {
192
+ * // Call to external API or service
193
+ * return "Search results";
194
+ * }
195
+ * );
196
+ *
197
+ * @example
198
+ * // Basic tool usage
199
+ * const result = await interaction.withTool(
200
+ * {
201
+ * name: "calculator",
202
+ * properties: { operation: "multiply" },
203
+ * inputParameters: { a: 5, b: 10 }
204
+ * },
205
+ * async () => {
206
+ * // Tool implementation
207
+ * return "Result: 50";
208
+ * }
209
+ * );
210
+ */
211
+ withTool<T>(params: ToolParams, fn: (...args: any[]) => Promise<T> | T, thisArg?: any, ...args: any[]): Promise<T>;
154
212
  /**
155
213
  * Creates a task span that can be used to manually record a task.
156
214
  *
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- export { M as MAX_INGEST_SIZE_BYTES, R as Raindrop, R as default } from './index-SHpkmIQb.mjs';
1
+ export { M as MAX_INGEST_SIZE_BYTES, R as Raindrop, R as default } from './index-CPL3oZVf.mjs';
2
2
  import '@dawn/schemas/ingest';
3
3
  import '@opentelemetry/api';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { M as MAX_INGEST_SIZE_BYTES, R as Raindrop, R as default } from './index-SHpkmIQb.js';
1
+ export { M as MAX_INGEST_SIZE_BYTES, R as Raindrop, R as default } from './index-CPL3oZVf.js';
2
2
  import '@dawn/schemas/ingest';
3
3
  import '@opentelemetry/api';
package/dist/index.js CHANGED
@@ -56,7 +56,7 @@ var TrackEventSchema = import_zod.z.object({
56
56
  timestamp: import_zod.z.coerce.date(),
57
57
  received_at: import_zod.z.coerce.date(),
58
58
  user_id: import_zod.z.coerce.string().min(1, "User ID cannot be empty"),
59
- attachments: import_zod.z.array(AttachmentSchema).optional()
59
+ attachments: import_zod.z.array(AttachmentSchema).optional().nullable()
60
60
  }).strict();
61
61
  var AiDataSchema = import_zod.z.object({
62
62
  model: import_zod.z.coerce.string().optional().nullable(),
@@ -107,7 +107,7 @@ var CategorizationRequestSchema = import_zod.z.object({
107
107
  // package.json
108
108
  var package_default = {
109
109
  name: "raindrop-ai",
110
- version: "0.0.42",
110
+ version: "0.0.43",
111
111
  main: "dist/index.js",
112
112
  module: "dist/index.mjs",
113
113
  types: "dist/index.d.ts",
@@ -320,6 +320,13 @@ var NonLiveInteraction = class {
320
320
  return Promise.reject(error);
321
321
  }
322
322
  }
323
+ withTool(_params, fn, thisArg, ...args) {
324
+ try {
325
+ return Promise.resolve(fn.apply(thisArg, args));
326
+ } catch (error) {
327
+ return Promise.reject(error);
328
+ }
329
+ }
323
330
  startSpan(_params) {
324
331
  return NO_OP_SPAN;
325
332
  }
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tracing
3
- } from "./chunk-N5Y5IKFX.mjs";
3
+ } from "./chunk-UQBASHHQ.mjs";
4
4
 
5
5
  // ../schemas/src/ingest/index.ts
6
6
  import { z } from "zod";
@@ -32,7 +32,7 @@ var TrackEventSchema = z.object({
32
32
  timestamp: z.coerce.date(),
33
33
  received_at: z.coerce.date(),
34
34
  user_id: z.coerce.string().min(1, "User ID cannot be empty"),
35
- attachments: z.array(AttachmentSchema).optional()
35
+ attachments: z.array(AttachmentSchema).optional().nullable()
36
36
  }).strict();
37
37
  var AiDataSchema = z.object({
38
38
  model: z.coerce.string().optional().nullable(),
@@ -83,7 +83,7 @@ var CategorizationRequestSchema = z.object({
83
83
  // package.json
84
84
  var package_default = {
85
85
  name: "raindrop-ai",
86
- version: "0.0.42",
86
+ version: "0.0.43",
87
87
  main: "dist/index.js",
88
88
  module: "dist/index.mjs",
89
89
  types: "dist/index.d.ts",
@@ -1,5 +1,5 @@
1
1
  import * as traceloop from '@traceloop/node-server-sdk';
2
- import { R as Raindrop, P as PartialAiTrackEvent, I as Interaction } from '../index-SHpkmIQb.mjs';
2
+ import { R as Raindrop, P as PartialAiTrackEvent, I as Interaction } from '../index-CPL3oZVf.mjs';
3
3
  import '@dawn/schemas/ingest';
4
4
  import '@opentelemetry/api';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import * as traceloop from '@traceloop/node-server-sdk';
2
- import { R as Raindrop, P as PartialAiTrackEvent, I as Interaction } from '../index-SHpkmIQb.js';
2
+ import { R as Raindrop, P as PartialAiTrackEvent, I as Interaction } from '../index-CPL3oZVf.js';
3
3
  import '@dawn/schemas/ingest';
4
4
  import '@opentelemetry/api';
5
5