@meetsmore-oss/use-ai-core 1.2.1

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.
@@ -0,0 +1,248 @@
1
+ import type { Tool, Message, Context, RunAgentInput, State, RunStartedEvent, RunFinishedEvent, RunErrorEvent, StepStartedEvent, StepFinishedEvent, TextMessageStartEvent, TextMessageContentEvent, TextMessageEndEvent, TextMessageChunkEvent, ToolCallStartEvent, ToolCallArgsEvent, ToolCallEndEvent, ToolCallChunkEvent, ToolCallResultEvent, StateSnapshotEvent, StateDeltaEvent, MessagesSnapshotEvent, RawEvent, CustomEvent, ActivitySnapshotEvent, ActivityDeltaEvent } from '@ag-ui/core';
2
+ /**
3
+ * Error codes sent from server to client.
4
+ * Used to identify specific error types for proper handling and messaging.
5
+ */
6
+ export declare enum ErrorCode {
7
+ /** Error when AI API is experiencing high load (HTTP 529) */
8
+ API_OVERLOADED = "API_OVERLOADED",
9
+ /** Error when rate limit is exceeded (HTTP 429) */
10
+ RATE_LIMITED = "RATE_LIMITED",
11
+ /** Generic error for unknown or unexpected errors */
12
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
13
+ }
14
+ export type { Tool, Message, Context, RunAgentInput, State, RunStartedEvent, RunFinishedEvent, RunErrorEvent, StepStartedEvent, StepFinishedEvent, TextMessageStartEvent, TextMessageContentEvent, TextMessageEndEvent, TextMessageChunkEvent, ToolCallStartEvent, ToolCallArgsEvent, ToolCallEndEvent, ToolCallChunkEvent, ToolCallResultEvent, StateSnapshotEvent, StateDeltaEvent, MessagesSnapshotEvent, RawEvent, CustomEvent, ActivitySnapshotEvent, ActivityDeltaEvent, };
15
+ /**
16
+ * Extended tool definition with use-ai specific features.
17
+ * Extends AG-UI Tool type with confirmationRequired flag.
18
+ */
19
+ export interface ToolDefinition {
20
+ /** The unique name of the tool */
21
+ name: string;
22
+ /** Human-readable description of what the tool does */
23
+ description: string;
24
+ /** JSON Schema describing the tool's input parameters */
25
+ parameters: {
26
+ type: 'object';
27
+ properties: Record<string, unknown>;
28
+ required?: string[];
29
+ };
30
+ /** Whether the tool requires explicit user confirmation before execution */
31
+ confirmationRequired?: boolean;
32
+ }
33
+ /**
34
+ * Base interface for all messages sent from client to server over WebSocket.
35
+ * Uses AG-UI RunAgentInput format for agent execution.
36
+ */
37
+ export interface ClientMessage {
38
+ /** The type of message being sent */
39
+ type: 'run_agent' | 'tool_result' | 'abort_run';
40
+ /** The message payload */
41
+ data: unknown;
42
+ }
43
+ /**
44
+ * Message sent from client to server to run the agent.
45
+ * Includes tools, messages, and state using AG-UI RunAgentInput format.
46
+ */
47
+ export interface RunAgentMessage {
48
+ type: 'run_agent';
49
+ data: RunAgentInput;
50
+ }
51
+ /**
52
+ * Message sent from client to server with the result of a tool execution.
53
+ * This maps to AG-UI ToolCallResultEvent.
54
+ */
55
+ export interface ToolResultMessage {
56
+ type: 'tool_result';
57
+ data: {
58
+ /** Message ID for the tool result */
59
+ messageId: string;
60
+ /** The unique ID of the tool call being responded to */
61
+ toolCallId: string;
62
+ /** The result content (stringified) */
63
+ content: string;
64
+ /** Role is always 'tool' for tool results */
65
+ role: 'tool';
66
+ };
67
+ }
68
+ /**
69
+ * Message sent from client to server to abort a running agent execution.
70
+ */
71
+ export interface AbortRunMessage {
72
+ type: 'abort_run';
73
+ data: {
74
+ /** Run ID to abort */
75
+ runId: string;
76
+ };
77
+ }
78
+ /**
79
+ * AG-UI event type - all events from server to client.
80
+ * Server emits AG-UI standard events.
81
+ */
82
+ export type AGUIEvent = RunStartedEvent | RunFinishedEvent | RunErrorEvent | StepStartedEvent | StepFinishedEvent | TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | TextMessageChunkEvent | ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent | ToolCallChunkEvent | ToolCallResultEvent | StateSnapshotEvent | StateDeltaEvent | MessagesSnapshotEvent | ActivitySnapshotEvent | ActivityDeltaEvent | RawEvent | CustomEvent;
83
+ export { EventType } from '@ag-ui/core';
84
+ /**
85
+ * HTTP headers configuration for a single MCP endpoint.
86
+ * Can be used for authentication, custom headers, or any HTTP header needs.
87
+ */
88
+ export interface McpHeadersConfig {
89
+ /** HTTP headers to send to the MCP endpoint */
90
+ headers: Record<string, string>;
91
+ }
92
+ /**
93
+ * Information about an available agent on the server.
94
+ */
95
+ export interface AgentInfo {
96
+ /** The unique identifier/key for this agent */
97
+ id: string;
98
+ /** Human-readable name of the agent */
99
+ name: string;
100
+ /** Annotation/description shown in the agent selector UI */
101
+ annotation?: string;
102
+ }
103
+ /**
104
+ * Extended forwardedProps type for use-ai protocol.
105
+ * Uses AG-UI's forwardedProps extension point for use-ai specific features.
106
+ */
107
+ export interface UseAIForwardedProps {
108
+ /** MCP headers configuration for MCP endpoint authentication */
109
+ mcpHeaders?: McpHeadersMap;
110
+ /** Agent ID to use for this request (falls back to server default if not specified) */
111
+ agent?: string;
112
+ }
113
+ /**
114
+ * Mapping of MCP endpoint patterns to HTTP headers configurations.
115
+ * Patterns can be:
116
+ * - Constant strings: `'https://api.example.com'` - Exact match
117
+ * - Glob patterns: `'https://*.meetsmore.com'` - Wildcard matching using picomatch
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * {
122
+ * // Exact match
123
+ * 'https://api.example.com': {
124
+ * headers: { 'Authorization': 'Bearer token123' }
125
+ * },
126
+ * // Wildcard subdomain
127
+ * 'https://*.meetsmore.com': {
128
+ * headers: { 'X-API-Key': 'key456' }
129
+ * },
130
+ * // Multiple wildcards
131
+ * '*://*.example.com': {
132
+ * headers: { 'X-Custom': 'value' }
133
+ * }
134
+ * }
135
+ * ```
136
+ */
137
+ export type McpHeadersMap = Record<string, McpHeadersConfig>;
138
+ /**
139
+ * Status of a workflow execution.
140
+ */
141
+ export type WorkflowStatus = 'idle' | 'running' | 'completed' | 'error';
142
+ /**
143
+ * Extended message type for use-ai.
144
+ * Includes AG-UI protocol messages ('run_agent', 'tool_result', 'abort_run')
145
+ * plus use-ai-specific extensions ('run_workflow').
146
+ *
147
+ * Note: This extends beyond AG-UI protocol to support headless workflow triggers.
148
+ * For AG-UI compliance, use ClientMessage instead.
149
+ */
150
+ export interface UseAIClientMessage {
151
+ type: 'run_agent' | 'tool_result' | 'abort_run' | 'run_workflow';
152
+ data: unknown;
153
+ }
154
+ /**
155
+ * Message sent from client to server to run a workflow (headless execution).
156
+ *
157
+ * This is a use-ai-specific extension, NOT part of AG-UI protocol.
158
+ * Used for triggering workflows without chat UI (e.g., button click, file upload).
159
+ *
160
+ * Workflows differ from agents:
161
+ * - No conversation history (stateless)
162
+ * - No chat UI involvement
163
+ * - Can use external platforms (Dify, Flowise, etc.)
164
+ * - Still supports tool calls to frontend
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * socket.emit('message', {
169
+ * type: 'run_workflow',
170
+ * data: {
171
+ * runner: 'dify',
172
+ * workflowId: 'pdf-processor',
173
+ * inputs: { file: pdfData },
174
+ * tools: [insertTextTool],
175
+ * runId: uuidv4(),
176
+ * threadId: uuidv4(),
177
+ * }
178
+ * });
179
+ * ```
180
+ */
181
+ export interface RunWorkflowMessage {
182
+ type: 'run_workflow';
183
+ data: {
184
+ /** The runner to use (e.g., 'dify', 'flowise') */
185
+ runner: string;
186
+ /** The workflow identifier (depends on which platform you are using) */
187
+ workflowId: string;
188
+ /** Input data for the workflow */
189
+ inputs: Record<string, any>;
190
+ /** Available tools that the workflow can call */
191
+ tools?: ToolDefinition[];
192
+ /** Run ID for tracking */
193
+ runId: string;
194
+ /** Thread ID for conversation tracking */
195
+ threadId: string;
196
+ /**
197
+ * AG-UI extension point for additional fields in messages.
198
+ * We use it to send `mcpHeaders`.
199
+ * @see RunAgentInput['forwardedProps']
200
+ */
201
+ forwardedProps?: {
202
+ /**
203
+ * A map of current McpHeaders that should be applied to MCP tool calls (e.g. auth headers)
204
+ */
205
+ mcpHeaders?: McpHeadersMap;
206
+ };
207
+ };
208
+ }
209
+ /**
210
+ * Text content part for multimodal messages.
211
+ */
212
+ export interface TextContent {
213
+ type: 'text';
214
+ text: string;
215
+ }
216
+ /**
217
+ * Image content part for multimodal messages.
218
+ * URL can be a data URL (base64) or a remote URL.
219
+ */
220
+ export interface ImageContent {
221
+ type: 'image';
222
+ /** Image URL (data URL or remote URL) */
223
+ url: string;
224
+ }
225
+ /**
226
+ * File content part for multimodal messages.
227
+ * Used for non-image files like PDFs, documents, etc.
228
+ */
229
+ export interface FileContent {
230
+ type: 'file';
231
+ /** File URL (data URL or remote URL) */
232
+ url: string;
233
+ /** MIME type of the file */
234
+ mimeType: string;
235
+ /** Original file name */
236
+ name: string;
237
+ }
238
+ /**
239
+ * Content part for multimodal messages.
240
+ * A message can contain multiple content parts of different types.
241
+ */
242
+ export type MultimodalContent = TextContent | ImageContent | FileContent;
243
+ /**
244
+ * User message content - can be a simple string or multimodal content array.
245
+ * When multimodal, the array can contain text, images, and files.
246
+ */
247
+ export type UserMessageContent = string | MultimodalContent[];
248
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EACJ,OAAO,EACP,OAAO,EACP,aAAa,EACb,KAAK,EAEL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EAEjB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EAErB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EAEnB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EAErB,QAAQ,EACR,WAAW,EAEX,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,oBAAY,SAAS;IACnB,6DAA6D;IAC7D,cAAc,mBAAmB;IACjC,mDAAmD;IACnD,YAAY,iBAAiB;IAC7B,qDAAqD;IACrD,aAAa,kBAAkB;CAChC;AAED,YAAY,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,CAAC"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@meetsmore-oss/use-ai-core",
3
+ "version": "1.2.1",
4
+ "license": "BUSL-1.1",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "author": {
9
+ "name": "Zachary Davison",
10
+ "url": "https://github.com/mm-zacharydavison"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/meetsmore/use-ai.git",
15
+ "directory": "packages/core"
16
+ },
17
+ "type": "module",
18
+ "main": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "import": "./dist/index.js",
23
+ "types": "./dist/index.d.ts"
24
+ }
25
+ },
26
+ "scripts": {
27
+ "clean": "rm -rf dist *.tsbuildinfo",
28
+ "build": "bun build ./src/index.ts --outdir ./dist --target node --format esm && tsc --emitDeclarationOnly --declaration --declarationMap"
29
+ },
30
+ "dependencies": {
31
+ "@ag-ui/core": "^0.0.41"
32
+ },
33
+ "devDependencies": {
34
+ "@types/bun": "latest",
35
+ "typescript": "^5.9.3"
36
+ }
37
+ }