@meetsmore-oss/use-ai-server 1.2.4 → 1.3.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/dist/agents/AISDKAgent.d.ts +6 -0
- package/dist/agents/AISDKAgent.d.ts.map +1 -1
- package/dist/index.js +32 -18
- package/dist/server.d.ts.map +1 -1
- package/dist/src/agents/AISDKAgent.d.ts +6 -0
- package/dist/src/agents/AISDKAgent.d.ts.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/agents/plugins/__tests__/runner.test.d.ts +0 -2
- package/dist/agents/plugins/__tests__/runner.test.d.ts.map +0 -1
- package/dist/agents/plugins/citations/citationPlugin.d.ts +0 -72
- package/dist/agents/plugins/citations/citationPlugin.d.ts.map +0 -1
- package/dist/agents/plugins/citations/citationPlugin.test.d.ts +0 -2
- package/dist/agents/plugins/citations/citationPlugin.test.d.ts.map +0 -1
- package/dist/agents/plugins/citations/index.d.ts +0 -7
- package/dist/agents/plugins/citations/index.d.ts.map +0 -1
- package/dist/agents/plugins/index.d.ts +0 -34
- package/dist/agents/plugins/index.d.ts.map +0 -1
- package/dist/agents/plugins/runner.d.ts +0 -76
- package/dist/agents/plugins/runner.d.ts.map +0 -1
- package/dist/agents/plugins/types.d.ts +0 -280
- package/dist/agents/plugins/types.d.ts.map +0 -1
- package/dist/src/agents/plugins/__tests__/runner.test.d.ts +0 -2
- package/dist/src/agents/plugins/__tests__/runner.test.d.ts.map +0 -1
- package/dist/src/agents/plugins/citations/citationPlugin.d.ts +0 -72
- package/dist/src/agents/plugins/citations/citationPlugin.d.ts.map +0 -1
- package/dist/src/agents/plugins/citations/citationPlugin.test.d.ts +0 -2
- package/dist/src/agents/plugins/citations/citationPlugin.test.d.ts.map +0 -1
- package/dist/src/agents/plugins/citations/index.d.ts +0 -7
- package/dist/src/agents/plugins/citations/index.d.ts.map +0 -1
- package/dist/src/agents/plugins/index.d.ts +0 -34
- package/dist/src/agents/plugins/index.d.ts.map +0 -1
- package/dist/src/agents/plugins/runner.d.ts +0 -76
- package/dist/src/agents/plugins/runner.d.ts.map +0 -1
- package/dist/src/agents/plugins/types.d.ts +0 -280
- package/dist/src/agents/plugins/types.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meetsmore-oss/use-ai-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"license": "BUSL-1.1",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@ai-sdk/anthropic": "3.0.0-beta.59",
|
|
34
34
|
"@ai-sdk/openai": "3.0.0-beta.66",
|
|
35
|
-
"@meetsmore-oss/use-ai-core": "1.
|
|
35
|
+
"@meetsmore-oss/use-ai-core": "1.3.0",
|
|
36
36
|
"ai": "6.0.0-beta.116",
|
|
37
37
|
"picomatch": "^4.0.3",
|
|
38
38
|
"socket.io": "^4.8.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runner.test.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/__tests__/runner.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { AgentPlugin } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Citation source that can be included in tool results.
|
|
4
|
-
* Tools (like RAG) can return citations in their results using this format.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* // In your RAG tool implementation:
|
|
9
|
-
* return {
|
|
10
|
-
* answer: "Based on the documentation...",
|
|
11
|
-
* _citations: [
|
|
12
|
-
* { url: "https://docs.example.com/api", title: "API Reference" },
|
|
13
|
-
* { url: "https://docs.example.com/guide", title: "Getting Started Guide" },
|
|
14
|
-
* ]
|
|
15
|
-
* };
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export interface ToolCitationSource {
|
|
19
|
-
/** URL of the source document */
|
|
20
|
-
url: string;
|
|
21
|
-
/** Title of the source (optional) */
|
|
22
|
-
title?: string;
|
|
23
|
-
/** Additional metadata (optional) */
|
|
24
|
-
metadata?: Record<string, unknown>;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Available citation types.
|
|
28
|
-
*
|
|
29
|
-
* - `anthropic`: Extracts from Anthropic web search source chunks (streaming) and result.sources
|
|
30
|
-
* - `openai`: Extracts from OpenAI url_citation annotations in response messages
|
|
31
|
-
* - `rag`: Extracts from tool results with `_citations`, `citations`, or `sources` fields
|
|
32
|
-
*/
|
|
33
|
-
export type CitationType = 'rag';
|
|
34
|
-
/**
|
|
35
|
-
* Plugin that handles citation collection and emission.
|
|
36
|
-
*
|
|
37
|
-
* Supports multiple citation sources:
|
|
38
|
-
* - **rag**: Citations in tool results via `_citations`, `citations`, or `sources` fields
|
|
39
|
-
* - **anthropic**: Source chunks during streaming + result.sources (for future use)
|
|
40
|
-
* - **openai**: url_citation annotations in response (for future use)
|
|
41
|
-
*
|
|
42
|
-
* @param enabledTypes - Which extractors to enable. If not provided, all extractors are enabled.
|
|
43
|
-
* Extractors run in the order specified.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* // With custom RAG tool - return citations in the tool result
|
|
48
|
-
* import { AISDKAgent, citationPlugin } from '@meetsmore-oss/use-ai-server';
|
|
49
|
-
*
|
|
50
|
-
* const ragTool = defineTool(
|
|
51
|
-
* 'Search internal documentation',
|
|
52
|
-
* z.object({ query: z.string() }),
|
|
53
|
-
* async ({ query }) => {
|
|
54
|
-
* const results = await vectorDb.search(query);
|
|
55
|
-
* return {
|
|
56
|
-
* answer: results.map(r => r.content).join('\n'),
|
|
57
|
-
* _citations: results.map(r => ({
|
|
58
|
-
* url: r.sourceUrl,
|
|
59
|
-
* title: r.title,
|
|
60
|
-
* })),
|
|
61
|
-
* };
|
|
62
|
-
* }
|
|
63
|
-
* );
|
|
64
|
-
*
|
|
65
|
-
* const agent = new AISDKAgent({
|
|
66
|
-
* model: anthropic('claude-sonnet-4-20250514'),
|
|
67
|
-
* plugins: [citationPlugin(['rag'])],
|
|
68
|
-
* });
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export declare function citationPlugin(enabledTypes?: CitationType[]): AgentPlugin;
|
|
72
|
-
//# sourceMappingURL=citationPlugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"citationPlugin.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/citations/citationPlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAgF,MAAM,UAAU,CAAC;AAI1H;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,kBAAkB;IACjC,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC;AAoPjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,cAAc,CAAC,YAAY,CAAC,EAAE,YAAY,EAAE,GAAG,WAAW,CA4CzE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"citationPlugin.test.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/citations/citationPlugin.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Citation plugin for AISDKAgent.
|
|
3
|
-
* Collects sources from AI responses and emits citation events.
|
|
4
|
-
*/
|
|
5
|
-
export { citationPlugin } from './citationPlugin';
|
|
6
|
-
export type { ToolCitationSource, CitationType } from './citationPlugin';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/citations/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent plugin system for extending AISDKAgent functionality.
|
|
3
|
-
*
|
|
4
|
-
* Plugins can hook into the agent lifecycle to:
|
|
5
|
-
* - Modify inputs before sending to AI
|
|
6
|
-
* - Transform streaming chunks
|
|
7
|
-
* - Intercept or modify tool calls
|
|
8
|
-
* - Process and transform responses
|
|
9
|
-
* - Handle errors
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import { AISDKAgent } from '@meetsmore-oss/use-ai-server';
|
|
14
|
-
* import type { AgentPlugin } from '@meetsmore-oss/use-ai-server';
|
|
15
|
-
*
|
|
16
|
-
* const loggingPlugin: AgentPlugin = {
|
|
17
|
-
* id: 'logging',
|
|
18
|
-
* onUserMessage(input, ctx) {
|
|
19
|
-
* ctx.logger.info('Message received');
|
|
20
|
-
* return input;
|
|
21
|
-
* },
|
|
22
|
-
* };
|
|
23
|
-
*
|
|
24
|
-
* const agent = new AISDKAgent({
|
|
25
|
-
* model: anthropic('claude-3-5-sonnet-20241022'),
|
|
26
|
-
* plugins: [loggingPlugin],
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export type { AgentPlugin, AgentPluginContext, AgentRunInput, AgentRunResult, ToolCallInfo, ToolResultInfo, StreamChunk, TextDeltaChunk, ReasoningDeltaChunk, SourceChunk, ToolInputStartChunk, ToolInputDeltaChunk, ToolCallChunk, ToolResultChunk, StartStepChunk, FinishStepChunk, ErrorChunk, UnknownChunk, } from './types';
|
|
31
|
-
export { AgentPluginRunner } from './runner';
|
|
32
|
-
export { citationPlugin } from './citations';
|
|
33
|
-
export type { ToolCitationSource, CitationType } from './citations';
|
|
34
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAc,EAEd,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,cAAc,EACd,eAAe,EACf,UAAU,EACV,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { AgentPlugin, AgentPluginContext, AgentRunInput, AgentRunResult, ToolCallInfo, ToolResultInfo, StreamChunk } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Orchestrates plugin execution for AISDKAgent.
|
|
4
|
-
*
|
|
5
|
-
* Plugins are executed in the order they were registered.
|
|
6
|
-
* Each hook is called sequentially, with the output of one plugin
|
|
7
|
-
* becoming the input of the next.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const runner = new AgentPluginRunner([
|
|
12
|
-
* loggingPlugin,
|
|
13
|
-
* metricsPlugin,
|
|
14
|
-
* ]);
|
|
15
|
-
*
|
|
16
|
-
* // Initialize plugins
|
|
17
|
-
* await runner.initialize({ provider: 'anthropic' });
|
|
18
|
-
*
|
|
19
|
-
* // Use in agent run
|
|
20
|
-
* const processedInput = await runner.onUserMessage(input, context);
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare class AgentPluginRunner {
|
|
24
|
-
private plugins;
|
|
25
|
-
constructor(plugins?: AgentPlugin[]);
|
|
26
|
-
/**
|
|
27
|
-
* Initialize all plugins.
|
|
28
|
-
* Called once when the agent is created.
|
|
29
|
-
*/
|
|
30
|
-
initialize(context: {
|
|
31
|
-
provider: string;
|
|
32
|
-
}): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* Run onUserMessage hook for all plugins.
|
|
35
|
-
* Each plugin receives the output of the previous plugin.
|
|
36
|
-
*/
|
|
37
|
-
onUserMessage(input: AgentRunInput, context: AgentPluginContext): Promise<AgentRunInput>;
|
|
38
|
-
/**
|
|
39
|
-
* Run onAgentResponse hook for all plugins.
|
|
40
|
-
* Each plugin receives the output of the previous plugin.
|
|
41
|
-
*/
|
|
42
|
-
onAgentResponse(result: AgentRunResult, context: AgentPluginContext): Promise<AgentRunResult>;
|
|
43
|
-
/**
|
|
44
|
-
* Run onTextChunk hook for all plugins.
|
|
45
|
-
* Returns the transformed chunk (or original if no transform).
|
|
46
|
-
*/
|
|
47
|
-
onTextChunk(chunk: string, context: AgentPluginContext): Promise<string>;
|
|
48
|
-
/**
|
|
49
|
-
* Run onBeforeToolCall hook for all plugins.
|
|
50
|
-
* Returns null if any plugin returns null (tool call should be skipped).
|
|
51
|
-
*/
|
|
52
|
-
onBeforeToolCall(toolCall: ToolCallInfo, context: AgentPluginContext): Promise<ToolCallInfo | null>;
|
|
53
|
-
/**
|
|
54
|
-
* Run onAfterToolCall hook for all plugins.
|
|
55
|
-
* Returns the final transformed result.
|
|
56
|
-
*/
|
|
57
|
-
onAfterToolCall(toolResult: ToolResultInfo, context: AgentPluginContext): Promise<unknown>;
|
|
58
|
-
/**
|
|
59
|
-
* Run onChunk hook for all plugins.
|
|
60
|
-
* Called for each chunk from the AI SDK stream.
|
|
61
|
-
*/
|
|
62
|
-
onChunk(chunk: StreamChunk, context: AgentPluginContext): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Destroy all plugins and release resources.
|
|
65
|
-
*/
|
|
66
|
-
destroy(): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Check if any plugins are registered.
|
|
69
|
-
*/
|
|
70
|
-
hasPlugins(): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Get the number of registered plugins.
|
|
73
|
-
*/
|
|
74
|
-
get pluginCount(): number;
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAc,EACd,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAAqB;gBAExB,OAAO,GAAE,WAAW,EAAO;IAIvC;;;OAGG;IACG,UAAU,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAM9D;;;OAGG;IACG,aAAa,CACjB,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,aAAa,CAAC;IAUzB;;;OAGG;IACG,eAAe,CACnB,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,cAAc,CAAC;IAU1B;;;OAGG;IACG,WAAW,CACf,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC;IAalB;;;OAGG;IACG,gBAAgB,CACpB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAW/B;;;OAGG;IACG,eAAe,CACnB,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,OAAO,CAAC;IAUnB;;;OAGG;IACG,OAAO,CACX,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC;IAQhB;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;CACF"}
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import type { ModelMessage, SystemModelMessage } from 'ai';
|
|
2
|
-
import type { EventEmitter, ClientSession } from '../types';
|
|
3
|
-
import type { ToolDefinition } from '../../types';
|
|
4
|
-
import type { Logger } from '../../logger';
|
|
5
|
-
/**
|
|
6
|
-
* Context available to plugins during a run.
|
|
7
|
-
* Contains session info, event emitter, and shared state.
|
|
8
|
-
*/
|
|
9
|
-
export interface AgentPluginContext {
|
|
10
|
-
/** Unique identifier for this run */
|
|
11
|
-
runId: string;
|
|
12
|
-
/** Client identifier from the session */
|
|
13
|
-
clientId: string;
|
|
14
|
-
/** Thread identifier for the conversation */
|
|
15
|
-
threadId?: string;
|
|
16
|
-
/** AI provider name (e.g., 'openai', 'anthropic') */
|
|
17
|
-
provider: string;
|
|
18
|
-
/** Event emitter for sending AG-UI events */
|
|
19
|
-
events: EventEmitter;
|
|
20
|
-
/** Shared state between plugins within a single run */
|
|
21
|
-
state: Map<string, unknown>;
|
|
22
|
-
/** Logger instance */
|
|
23
|
-
logger: Logger;
|
|
24
|
-
/** The client session */
|
|
25
|
-
session: ClientSession;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Input data passed to onUserMessage hook.
|
|
29
|
-
* Plugins can modify these values before they're sent to the AI SDK.
|
|
30
|
-
*/
|
|
31
|
-
export interface AgentRunInput {
|
|
32
|
-
/** Conversation messages in AI SDK format */
|
|
33
|
-
messages: ModelMessage[];
|
|
34
|
-
/** System messages (if any). Passed directly to AI SDK. */
|
|
35
|
-
systemMessages?: SystemModelMessage[];
|
|
36
|
-
/** Available tools for this run */
|
|
37
|
-
tools: ToolDefinition[];
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Result data passed to onAgentResponse hook.
|
|
41
|
-
* Plugins can process or transform the response.
|
|
42
|
-
*/
|
|
43
|
-
export interface AgentRunResult {
|
|
44
|
-
/** The generated text response */
|
|
45
|
-
text: string;
|
|
46
|
-
/** Sources/citations from the AI response */
|
|
47
|
-
sources?: unknown[];
|
|
48
|
-
/** Raw response object from AI SDK */
|
|
49
|
-
response?: {
|
|
50
|
-
messages: unknown[];
|
|
51
|
-
};
|
|
52
|
-
/** Provider-specific metadata */
|
|
53
|
-
providerMetadata?: Record<string, unknown>;
|
|
54
|
-
/** Tool calls made during the run */
|
|
55
|
-
toolCalls?: unknown[];
|
|
56
|
-
/** Results from tool executions */
|
|
57
|
-
toolResults?: unknown[];
|
|
58
|
-
/** Token usage information */
|
|
59
|
-
usage?: {
|
|
60
|
-
promptTokens: number;
|
|
61
|
-
completionTokens: number;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Information about a tool call (before execution).
|
|
66
|
-
*/
|
|
67
|
-
export interface ToolCallInfo {
|
|
68
|
-
/** Unique identifier for this tool call */
|
|
69
|
-
id: string;
|
|
70
|
-
/** Name of the tool being called */
|
|
71
|
-
name: string;
|
|
72
|
-
/** Arguments passed to the tool */
|
|
73
|
-
args: unknown;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Information about a tool result (after execution).
|
|
77
|
-
*/
|
|
78
|
-
export interface ToolResultInfo extends ToolCallInfo {
|
|
79
|
-
/** Result returned from the tool */
|
|
80
|
-
result: unknown;
|
|
81
|
-
/** Error if the tool execution failed */
|
|
82
|
-
error?: Error;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Known AI SDK stream chunk types.
|
|
86
|
-
* These are the chunk types commonly emitted by the AI SDK fullStream.
|
|
87
|
-
*/
|
|
88
|
-
/** Text content being streamed */
|
|
89
|
-
export interface TextDeltaChunk {
|
|
90
|
-
type: 'text-delta';
|
|
91
|
-
text: string;
|
|
92
|
-
}
|
|
93
|
-
/** Extended thinking/reasoning content (Claude) */
|
|
94
|
-
export interface ReasoningDeltaChunk {
|
|
95
|
-
type: 'reasoning-delta';
|
|
96
|
-
text: string;
|
|
97
|
-
}
|
|
98
|
-
/** Source/citation from web search or RAG */
|
|
99
|
-
export interface SourceChunk {
|
|
100
|
-
type: 'source';
|
|
101
|
-
id: string;
|
|
102
|
-
sourceType: string;
|
|
103
|
-
url?: string;
|
|
104
|
-
title?: string;
|
|
105
|
-
providerMetadata?: Record<string, unknown>;
|
|
106
|
-
}
|
|
107
|
-
/** Tool call starting to stream */
|
|
108
|
-
export interface ToolInputStartChunk {
|
|
109
|
-
type: 'tool-input-start';
|
|
110
|
-
id: string;
|
|
111
|
-
toolName: string;
|
|
112
|
-
}
|
|
113
|
-
/** Tool arguments being streamed */
|
|
114
|
-
export interface ToolInputDeltaChunk {
|
|
115
|
-
type: 'tool-input-delta';
|
|
116
|
-
id: string;
|
|
117
|
-
delta: string;
|
|
118
|
-
}
|
|
119
|
-
/** Tool call complete with parsed input */
|
|
120
|
-
export interface ToolCallChunk {
|
|
121
|
-
type: 'tool-call';
|
|
122
|
-
toolCallId: string;
|
|
123
|
-
toolName: string;
|
|
124
|
-
input: unknown;
|
|
125
|
-
}
|
|
126
|
-
/** Tool execution result */
|
|
127
|
-
export interface ToolResultChunk {
|
|
128
|
-
type: 'tool-result';
|
|
129
|
-
toolCallId: string;
|
|
130
|
-
toolName: string;
|
|
131
|
-
output: unknown;
|
|
132
|
-
}
|
|
133
|
-
/** Step started in multi-step execution */
|
|
134
|
-
export interface StartStepChunk {
|
|
135
|
-
type: 'start-step';
|
|
136
|
-
}
|
|
137
|
-
/** Step finished in multi-step execution */
|
|
138
|
-
export interface FinishStepChunk {
|
|
139
|
-
type: 'finish-step';
|
|
140
|
-
usage?: {
|
|
141
|
-
promptTokens: number;
|
|
142
|
-
completionTokens: number;
|
|
143
|
-
};
|
|
144
|
-
finishReason?: string;
|
|
145
|
-
}
|
|
146
|
-
/** Stream error */
|
|
147
|
-
export interface ErrorChunk {
|
|
148
|
-
type: 'error';
|
|
149
|
-
error: Error;
|
|
150
|
-
}
|
|
151
|
-
/** Unknown chunk type (fallback for future AI SDK chunk types) */
|
|
152
|
-
export interface UnknownChunk {
|
|
153
|
-
type: string;
|
|
154
|
-
[key: string]: unknown;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Union of all known AI SDK stream chunk types.
|
|
158
|
-
* Plugins can use type narrowing with `chunk.type` to handle specific chunk types.
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* ```typescript
|
|
162
|
-
* onChunk(chunk, context) {
|
|
163
|
-
* if (chunk.type === 'source') {
|
|
164
|
-
* // TypeScript knows chunk is SourceChunk here
|
|
165
|
-
* console.log(chunk.url);
|
|
166
|
-
* }
|
|
167
|
-
* }
|
|
168
|
-
* ```
|
|
169
|
-
*/
|
|
170
|
-
export type StreamChunk = TextDeltaChunk | ReasoningDeltaChunk | SourceChunk | ToolInputStartChunk | ToolInputDeltaChunk | ToolCallChunk | ToolResultChunk | StartStepChunk | FinishStepChunk | ErrorChunk | UnknownChunk;
|
|
171
|
-
/**
|
|
172
|
-
* Plugin interface for extending AISDKAgent functionality.
|
|
173
|
-
*
|
|
174
|
-
* Plugins can hook into various points of the agent lifecycle to:
|
|
175
|
-
* - Modify inputs before sending to AI
|
|
176
|
-
* - Transform streaming chunks
|
|
177
|
-
* - Intercept or modify tool calls
|
|
178
|
-
* - Process and transform responses
|
|
179
|
-
* - Handle errors
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```typescript
|
|
183
|
-
* const loggingPlugin: AgentPlugin = {
|
|
184
|
-
* id: 'logging',
|
|
185
|
-
*
|
|
186
|
-
* onUserMessage(input, context) {
|
|
187
|
-
* context.logger.info('User message received', {
|
|
188
|
-
* messageCount: input.messages.length,
|
|
189
|
-
* });
|
|
190
|
-
* return input;
|
|
191
|
-
* },
|
|
192
|
-
*
|
|
193
|
-
* onAgentResponse(result, context) {
|
|
194
|
-
* context.logger.info('Agent response', {
|
|
195
|
-
* textLength: result.text.length,
|
|
196
|
-
* });
|
|
197
|
-
* return result;
|
|
198
|
-
* },
|
|
199
|
-
* };
|
|
200
|
-
* ```
|
|
201
|
-
*/
|
|
202
|
-
export interface AgentPlugin {
|
|
203
|
-
/** Unique plugin identifier */
|
|
204
|
-
id: string;
|
|
205
|
-
/**
|
|
206
|
-
* Initialize plugin (called once when agent is created).
|
|
207
|
-
* Use this to set up any resources the plugin needs.
|
|
208
|
-
*
|
|
209
|
-
* @param context - Initialization context with provider info
|
|
210
|
-
*/
|
|
211
|
-
initialize?(context: {
|
|
212
|
-
provider: string;
|
|
213
|
-
}): void | Promise<void>;
|
|
214
|
-
/**
|
|
215
|
-
* Called before the user message is sent to AI SDK.
|
|
216
|
-
* Can modify messages, system prompt, or tools.
|
|
217
|
-
*
|
|
218
|
-
* @param input - The input data (messages, system prompt, tools)
|
|
219
|
-
* @param context - Plugin context with run info and shared state
|
|
220
|
-
* @returns Modified input or unchanged input
|
|
221
|
-
*/
|
|
222
|
-
onUserMessage?(input: AgentRunInput, context: AgentPluginContext): AgentRunInput | Promise<AgentRunInput>;
|
|
223
|
-
/**
|
|
224
|
-
* Called after AI SDK completes processing (including all tool calls).
|
|
225
|
-
* Can process results, emit events, or transform the final text.
|
|
226
|
-
*
|
|
227
|
-
* @param result - The agent's response data
|
|
228
|
-
* @param context - Plugin context with run info and shared state
|
|
229
|
-
* @returns Modified result or unchanged result
|
|
230
|
-
*/
|
|
231
|
-
onAgentResponse?(result: AgentRunResult, context: AgentPluginContext): AgentRunResult | Promise<AgentRunResult>;
|
|
232
|
-
/**
|
|
233
|
-
* Called for each streaming text chunk.
|
|
234
|
-
* Can transform chunks. Return undefined/void to keep chunk unchanged.
|
|
235
|
-
*
|
|
236
|
-
* @param chunk - The text chunk being streamed
|
|
237
|
-
* @param context - Plugin context with run info and shared state
|
|
238
|
-
* @returns Transformed chunk, or undefined to keep original
|
|
239
|
-
*/
|
|
240
|
-
onTextChunk?(chunk: string, context: AgentPluginContext): string | void | Promise<string | void>;
|
|
241
|
-
/**
|
|
242
|
-
* Called before a tool is executed.
|
|
243
|
-
* Can modify the tool call or return null to skip execution.
|
|
244
|
-
*
|
|
245
|
-
* @param toolCall - Information about the tool being called
|
|
246
|
-
* @param context - Plugin context with run info and shared state
|
|
247
|
-
* @returns Modified tool call, null to skip, or unchanged
|
|
248
|
-
*/
|
|
249
|
-
onBeforeToolCall?(toolCall: ToolCallInfo, context: AgentPluginContext): ToolCallInfo | null | Promise<ToolCallInfo | null>;
|
|
250
|
-
/**
|
|
251
|
-
* Called after a tool is executed.
|
|
252
|
-
* Can modify the tool result before it's sent back to the AI.
|
|
253
|
-
*
|
|
254
|
-
* @param toolResult - Information about the completed tool call
|
|
255
|
-
* @param context - Plugin context with run info and shared state
|
|
256
|
-
* @returns Modified result or unchanged result
|
|
257
|
-
*/
|
|
258
|
-
onAfterToolCall?(toolResult: ToolResultInfo, context: AgentPluginContext): unknown | Promise<unknown>;
|
|
259
|
-
/**
|
|
260
|
-
* Called for each chunk from the AI SDK stream.
|
|
261
|
-
* Plugins can filter by chunk.type to handle specific chunk types.
|
|
262
|
-
*
|
|
263
|
-
* Common chunk types:
|
|
264
|
-
* - 'text-delta': Text content being streamed
|
|
265
|
-
* - 'source': Citation/source from web search or RAG
|
|
266
|
-
* - 'tool-call': Tool invocation
|
|
267
|
-
* - 'tool-result': Tool execution result
|
|
268
|
-
* - 'start-step', 'finish-step': Multi-step execution markers
|
|
269
|
-
*
|
|
270
|
-
* @param chunk - The stream chunk with type and type-specific properties
|
|
271
|
-
* @param context - Plugin context with run info and shared state
|
|
272
|
-
*/
|
|
273
|
-
onChunk?(chunk: StreamChunk, context: AgentPluginContext): void | Promise<void>;
|
|
274
|
-
/**
|
|
275
|
-
* Cleanup (called when agent is destroyed).
|
|
276
|
-
* Use to release any resources the plugin acquired.
|
|
277
|
-
*/
|
|
278
|
-
destroy?(): void | Promise<void>;
|
|
279
|
-
}
|
|
280
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,MAAM,EAAE,YAAY,CAAC;IACrB,uDAAuD;IACvD,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5B,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,OAAO,EAAE,aAAa,CAAC;CACxB;A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C,YAAY,GAAG,IAAI,CAAC,CAAC;IAEtD;;;;;;;OAOG;IACH,eAAe,CAAC,CACd,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE9B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,CACN,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,kBAAkB,GAC1B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExB;;;OAGG;IACH,OAAO,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runner.test.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/__tests__/runner.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { AgentPlugin } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Citation source that can be included in tool results.
|
|
4
|
-
* Tools (like RAG) can return citations in their results using this format.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* // In your RAG tool implementation:
|
|
9
|
-
* return {
|
|
10
|
-
* answer: "Based on the documentation...",
|
|
11
|
-
* _citations: [
|
|
12
|
-
* { url: "https://docs.example.com/api", title: "API Reference" },
|
|
13
|
-
* { url: "https://docs.example.com/guide", title: "Getting Started Guide" },
|
|
14
|
-
* ]
|
|
15
|
-
* };
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export interface ToolCitationSource {
|
|
19
|
-
/** URL of the source document */
|
|
20
|
-
url: string;
|
|
21
|
-
/** Title of the source (optional) */
|
|
22
|
-
title?: string;
|
|
23
|
-
/** Additional metadata (optional) */
|
|
24
|
-
metadata?: Record<string, unknown>;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Available citation types.
|
|
28
|
-
*
|
|
29
|
-
* - `anthropic`: Extracts from Anthropic web search source chunks (streaming) and result.sources
|
|
30
|
-
* - `openai`: Extracts from OpenAI url_citation annotations in response messages
|
|
31
|
-
* - `rag`: Extracts from tool results with `_citations`, `citations`, or `sources` fields
|
|
32
|
-
*/
|
|
33
|
-
export type CitationType = 'rag';
|
|
34
|
-
/**
|
|
35
|
-
* Plugin that handles citation collection and emission.
|
|
36
|
-
*
|
|
37
|
-
* Supports multiple citation sources:
|
|
38
|
-
* - **rag**: Citations in tool results via `_citations`, `citations`, or `sources` fields
|
|
39
|
-
* - **anthropic**: Source chunks during streaming + result.sources (for future use)
|
|
40
|
-
* - **openai**: url_citation annotations in response (for future use)
|
|
41
|
-
*
|
|
42
|
-
* @param enabledTypes - Which extractors to enable. If not provided, all extractors are enabled.
|
|
43
|
-
* Extractors run in the order specified.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* // With custom RAG tool - return citations in the tool result
|
|
48
|
-
* import { AISDKAgent, citationPlugin } from '@meetsmore-oss/use-ai-server';
|
|
49
|
-
*
|
|
50
|
-
* const ragTool = defineTool(
|
|
51
|
-
* 'Search internal documentation',
|
|
52
|
-
* z.object({ query: z.string() }),
|
|
53
|
-
* async ({ query }) => {
|
|
54
|
-
* const results = await vectorDb.search(query);
|
|
55
|
-
* return {
|
|
56
|
-
* answer: results.map(r => r.content).join('\n'),
|
|
57
|
-
* _citations: results.map(r => ({
|
|
58
|
-
* url: r.sourceUrl,
|
|
59
|
-
* title: r.title,
|
|
60
|
-
* })),
|
|
61
|
-
* };
|
|
62
|
-
* }
|
|
63
|
-
* );
|
|
64
|
-
*
|
|
65
|
-
* const agent = new AISDKAgent({
|
|
66
|
-
* model: anthropic('claude-sonnet-4-20250514'),
|
|
67
|
-
* plugins: [citationPlugin(['rag'])],
|
|
68
|
-
* });
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export declare function citationPlugin(enabledTypes?: CitationType[]): AgentPlugin;
|
|
72
|
-
//# sourceMappingURL=citationPlugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"citationPlugin.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/citations/citationPlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAgF,MAAM,UAAU,CAAC;AAI1H;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,kBAAkB;IACjC,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC;AAoPjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,cAAc,CAAC,YAAY,CAAC,EAAE,YAAY,EAAE,GAAG,WAAW,CA4CzE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"citationPlugin.test.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/citations/citationPlugin.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Citation plugin for AISDKAgent.
|
|
3
|
-
* Collects sources from AI responses and emits citation events.
|
|
4
|
-
*/
|
|
5
|
-
export { citationPlugin } from './citationPlugin';
|
|
6
|
-
export type { ToolCitationSource, CitationType } from './citationPlugin';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/citations/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent plugin system for extending AISDKAgent functionality.
|
|
3
|
-
*
|
|
4
|
-
* Plugins can hook into the agent lifecycle to:
|
|
5
|
-
* - Modify inputs before sending to AI
|
|
6
|
-
* - Transform streaming chunks
|
|
7
|
-
* - Intercept or modify tool calls
|
|
8
|
-
* - Process and transform responses
|
|
9
|
-
* - Handle errors
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import { AISDKAgent } from '@meetsmore-oss/use-ai-server';
|
|
14
|
-
* import type { AgentPlugin } from '@meetsmore-oss/use-ai-server';
|
|
15
|
-
*
|
|
16
|
-
* const loggingPlugin: AgentPlugin = {
|
|
17
|
-
* id: 'logging',
|
|
18
|
-
* onUserMessage(input, ctx) {
|
|
19
|
-
* ctx.logger.info('Message received');
|
|
20
|
-
* return input;
|
|
21
|
-
* },
|
|
22
|
-
* };
|
|
23
|
-
*
|
|
24
|
-
* const agent = new AISDKAgent({
|
|
25
|
-
* model: anthropic('claude-3-5-sonnet-20241022'),
|
|
26
|
-
* plugins: [loggingPlugin],
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export type { AgentPlugin, AgentPluginContext, AgentRunInput, AgentRunResult, ToolCallInfo, ToolResultInfo, StreamChunk, TextDeltaChunk, ReasoningDeltaChunk, SourceChunk, ToolInputStartChunk, ToolInputDeltaChunk, ToolCallChunk, ToolResultChunk, StartStepChunk, FinishStepChunk, ErrorChunk, UnknownChunk, } from './types';
|
|
31
|
-
export { AgentPluginRunner } from './runner';
|
|
32
|
-
export { citationPlugin } from './citations';
|
|
33
|
-
export type { ToolCitationSource, CitationType } from './citations';
|
|
34
|
-
//# sourceMappingURL=index.d.ts.map
|