@lssm/lib.ai-agent 0.0.0-canary-20251207012602 → 0.0.0-canary-20251207043720

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/types.d.ts DELETED
@@ -1,194 +0,0 @@
1
- import { LanguageModelUsage, ModelMessage, StepResult, ToolSet } from "ai";
2
-
3
- //#region src/types.d.ts
4
-
5
- /**
6
- * Simplified tool call type for ContractSpec usage.
7
- * Compatible with AI SDK v6 TypedToolCall.
8
- */
9
- interface ToolCallInfo {
10
- type: 'tool-call';
11
- toolCallId: string;
12
- toolName: string;
13
- args: unknown;
14
- }
15
- /**
16
- * Simplified tool result type for ContractSpec usage.
17
- * Compatible with AI SDK v6 TypedToolResult.
18
- */
19
- interface ToolResultInfo {
20
- type: 'tool-result';
21
- toolCallId: string;
22
- toolName: string;
23
- output: unknown;
24
- }
25
- /**
26
- * Extended message type that adds metadata support to ModelMessage.
27
- * Used for session memory tracking.
28
- */
29
- interface AgentMessage {
30
- role: 'user' | 'assistant' | 'system' | 'tool';
31
- content: string | {
32
- type: string;
33
- text?: string;
34
- [key: string]: unknown;
35
- }[];
36
- metadata?: Record<string, string>;
37
- }
38
- type AgentStatus = 'idle' | 'running' | 'waiting' | 'completed' | 'failed' | 'escalated';
39
- type AgentEventName = 'agent.session.created' | 'agent.session.updated' | 'agent.step.started' | 'agent.step.completed' | 'agent.tool.called' | 'agent.tool.completed' | 'agent.tool.failed' | 'agent.tool.approval_requested' | 'agent.escalated' | 'agent.completed' | 'agent.failed';
40
- interface AgentEventPayload {
41
- sessionId: string;
42
- agentId: string;
43
- tenantId?: string;
44
- stepIndex?: number;
45
- toolName?: string;
46
- metadata?: Record<string, unknown>;
47
- }
48
- /**
49
- * Runtime context passed to agent calls via AI SDK v6 callOptionsSchema.
50
- * Maps to ContractSpec's tenant/actor system.
51
- */
52
- interface AgentCallOptions {
53
- /** Tenant scoping for guardrails and data isolation */
54
- tenantId?: string;
55
- /** Unique end-user identifier (for personalization) */
56
- actorId?: string;
57
- /** Session to resume; new session created when omitted */
58
- sessionId?: string;
59
- /** Arbitrary metadata forwarded to events and tool handlers */
60
- metadata?: Record<string, string>;
61
- }
62
- interface AgentSessionState {
63
- sessionId: string;
64
- agentId: string;
65
- tenantId?: string;
66
- actorId?: string;
67
- status: AgentStatus;
68
- messages: ModelMessage[];
69
- steps: StepResult<ToolSet>[];
70
- createdAt: Date;
71
- updatedAt: Date;
72
- metadata?: Record<string, string>;
73
- }
74
- interface AgentGenerateParams {
75
- /** User prompt or message */
76
- prompt: string;
77
- /** System prompt override (appended to agent instructions) */
78
- systemOverride?: string;
79
- /** Runtime context options */
80
- options?: AgentCallOptions;
81
- /** Maximum number of steps/iterations */
82
- maxSteps?: number;
83
- /** Abort signal for cancellation */
84
- signal?: AbortSignal;
85
- }
86
- interface AgentStreamParams extends AgentGenerateParams {
87
- /** Called when a step completes */
88
- onStepFinish?: (step: StepResult<ToolSet>) => void | Promise<void>;
89
- }
90
- interface AgentGenerateResult<TOutput = string> {
91
- /** The final text response */
92
- text: string;
93
- /** Structured output if configured */
94
- output?: TOutput;
95
- /** All steps taken during generation */
96
- steps: StepResult<ToolSet>[];
97
- /** All tool calls made during generation */
98
- toolCalls: ToolCallInfo[];
99
- /** All tool results */
100
- toolResults: ToolResultInfo[];
101
- /** Reason generation finished */
102
- finishReason: 'stop' | 'tool-calls' | 'length' | 'content-filter' | 'error' | 'other' | 'unknown';
103
- /** Token usage statistics */
104
- usage?: LanguageModelUsage;
105
- /** Updated session state */
106
- session?: AgentSessionState;
107
- /** Whether approval is pending for a tool call */
108
- pendingApproval?: {
109
- toolName: string;
110
- toolCallId: string;
111
- args: unknown;
112
- };
113
- }
114
- /**
115
- * Context provided to tool handlers during execution.
116
- */
117
- interface ToolExecutionContext {
118
- agentId: string;
119
- sessionId: string;
120
- tenantId?: string;
121
- actorId?: string;
122
- metadata?: Record<string, string>;
123
- signal?: AbortSignal;
124
- }
125
- /**
126
- * Handler function for a tool.
127
- */
128
- type ToolHandler<TInput = unknown, TOutput = string> = (input: TInput, context: ToolExecutionContext) => Promise<TOutput>;
129
- interface AgentStepMetrics {
130
- agentId: string;
131
- stepIndex: number;
132
- toolCalls: {
133
- toolName: string;
134
- durationMs?: number;
135
- success: boolean;
136
- error?: string;
137
- }[];
138
- finishReason: string;
139
- usage?: LanguageModelUsage;
140
- timestamp: Date;
141
- }
142
- type AgentEventEmitter = (event: AgentEventName, payload: AgentEventPayload) => void | Promise<void>;
143
- /** @deprecated Use AgentGenerateParams instead */
144
- interface AgentRunRequestInput {
145
- agent: string;
146
- version?: number;
147
- input: string;
148
- tenantId?: string;
149
- actorId?: string;
150
- sessionId?: string;
151
- metadata?: Record<string, string>;
152
- instructionsOverride?: string;
153
- }
154
- /** @deprecated Use AgentGenerateResult instead */
155
- interface AgentRunResult {
156
- session: AgentSessionState;
157
- outputText: string;
158
- confidence: number;
159
- iterations: number;
160
- requiresEscalation: boolean;
161
- approvalRequestId?: string;
162
- finishReason: string;
163
- toolInvocations: AgentToolInvocation[];
164
- }
165
- /** @deprecated Use ToolCallInfo instead */
166
- interface AgentToolInvocation {
167
- name: string;
168
- arguments: unknown;
169
- startedAt: Date;
170
- completedAt?: Date;
171
- durationMs?: number;
172
- success: boolean;
173
- error?: string;
174
- }
175
- /** @deprecated Use ToolExecutionContext instead */
176
- interface AgentToolContext {
177
- session: AgentSessionState;
178
- tenantId?: string;
179
- actorId?: string;
180
- metadata?: Record<string, string>;
181
- emit: (event: AgentEventName, payload: AgentEventPayload) => void;
182
- }
183
- /** @deprecated Use ToolHandler instead */
184
- interface AgentToolResult {
185
- content: string;
186
- citations?: {
187
- label: string;
188
- url?: string;
189
- snippet?: string;
190
- }[];
191
- metadata?: Record<string, string>;
192
- }
193
- //#endregion
194
- export { AgentCallOptions, AgentEventEmitter, AgentEventName, AgentEventPayload, AgentGenerateParams, AgentGenerateResult, AgentMessage, AgentRunRequestInput, AgentRunResult, AgentSessionState, AgentStatus, AgentStepMetrics, AgentStreamParams, AgentToolContext, AgentToolInvocation, AgentToolResult, ToolCallInfo, ToolExecutionContext, ToolHandler, ToolResultInfo };