@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,92 @@
1
+ /**
2
+ * Custom event name for citation events.
3
+ * Used with AG-UI CustomEvent to transmit citation data.
4
+ */
5
+ export declare const CITATION_EVENT_NAME = "citation";
6
+ /**
7
+ * Unicode Private Use Area delimiters for citation markers.
8
+ * Using PUA characters as delimiters prevents collision with natural text.
9
+ *
10
+ * Format: START + "cite" + SEP + number + END
11
+ * Example: '\ue200cite\ue2021\ue201' for citation 1
12
+ *
13
+ * This format follows the ChatGPT citation style where:
14
+ * - \ue200 marks the start of a citation reference
15
+ * - \ue201 marks the end of a citation reference
16
+ * - \ue202 separates the type from the reference identifier
17
+ * - "cite" and the number are visible text the AI can output
18
+ */
19
+ export declare const CITATION_MARKER_START = "\uE200";
20
+ export declare const CITATION_MARKER_END = "\uE201";
21
+ export declare const CITATION_MARKER_SEP = "\uE202";
22
+ /**
23
+ * Pattern to match legacy [n] citation markers in text.
24
+ * Used for backwards compatibility.
25
+ */
26
+ export declare const LEGACY_CITATION_PATTERN: RegExp;
27
+ /**
28
+ * Pattern to match citation markers in text.
29
+ * Uses Markdown footnote syntax [^n] which Claude outputs naturally and rarely appears in code.
30
+ * Examples: [^1], [^2], [^1,2]
31
+ */
32
+ export declare const CITATION_PATTERN: RegExp;
33
+ /**
34
+ * Creates a citation marker for a given number.
35
+ * @param num The citation number (1, 2, 3, etc.)
36
+ * @returns The marker string (e.g., '[^1]')
37
+ */
38
+ export declare function createCitationMarker(num: number): string;
39
+ /**
40
+ * Transforms legacy [n] citation markers to footnote format.
41
+ * @param text Text containing [1], [2], etc. markers
42
+ * @returns Text with footnote markers ([^1], [^2], etc.)
43
+ */
44
+ export declare function transformLegacyCitations(text: string): string;
45
+ /**
46
+ * System prompt instruction for AI models to use citation markers.
47
+ * Uses Markdown footnote syntax [^n] which Claude outputs naturally.
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * new AISDKAgent({
52
+ * model: anthropic('claude-sonnet-4-20250514'),
53
+ * providerTools: { web_search: webSearch },
54
+ * // Citation instruction is auto-appended when citations: true (default)
55
+ * });
56
+ * ```
57
+ */
58
+ export declare const CITATION_SYSTEM_INSTRUCTION = "**CITATION FORMAT (REQUIRED)**\nWhen referencing information from sources, cite using Markdown footnote markers.\n\nFormat: [^N] where N is the source number (1-indexed position in results).\nMultiple sources: [^1,2]\n\nEXAMPLES:\n- \"TypeScript 5.7 was released in November 2024[^1].\"\n- \"React 19 introduced new features[^2] and performance improvements[^1,3].\"\n\nRULES:\n1. Place [^N] IMMEDIATELY after the cited claim.\n2. Every fact from sources MUST have a citation marker.";
59
+ /**
60
+ * A citation reference that can be displayed inline as [n] linking to a source.
61
+ */
62
+ export interface Citation {
63
+ /** Unique identifier for this citation */
64
+ id: string;
65
+ /** Sequential number for display [1], [2], etc. */
66
+ number: number;
67
+ /** Type of citation source */
68
+ type: 'url' | 'document' | 'tool-result';
69
+ /** URL for web sources (opens in new tab when clicked) */
70
+ url?: string;
71
+ /** Title of the source (used for tooltip) */
72
+ title?: string;
73
+ /** Document ID for RAG sources */
74
+ documentId?: string;
75
+ /** Snippet/excerpt from the source */
76
+ snippet?: string;
77
+ /** Tool name that provided this citation */
78
+ toolName?: string;
79
+ /** Provider-specific metadata */
80
+ metadata?: Record<string, unknown>;
81
+ }
82
+ /**
83
+ * Event payload for citation custom events.
84
+ * Sent via CustomEvent with name='citation'.
85
+ */
86
+ export interface CitationEvent {
87
+ /** The message ID these citations belong to */
88
+ messageId: string;
89
+ /** Array of citations collected so far */
90
+ citations: Citation[];
91
+ }
92
+ //# sourceMappingURL=citations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"citations.d.ts","sourceRoot":"","sources":["../src/citations.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAC5C,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,uBAAuB,QAAe,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAA0B,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,2BAA2B,weAYgB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,0CAA0C;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,aAAa,CAAC;IACzC,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,SAAS,EAAE,QAAQ,EAAE,CAAC;CACvB"}
@@ -0,0 +1,3 @@
1
+ export type { ToolDefinition, ClientMessage, RunAgentMessage, ToolResultMessage, AbortRunMessage, 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, AGUIEvent, WorkflowStatus, UseAIClientMessage, RunWorkflowMessage, McpHeadersConfig, McpHeadersMap, AgentInfo, UseAIForwardedProps, TextContent, ImageContent, FileContent, MultimodalContent, UserMessageContent, } from './types';
2
+ export { EventType, ErrorCode } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAEV,cAAc,EAEd,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,EAEf,IAAI,EACJ,OAAO,EACP,OAAO,EACP,aAAa,EACb,KAAK,EAEL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,QAAQ,EACR,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,SAAS,EAET,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,mBAAmB,EAEnB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}