@guidekit/core 0.1.0-beta.2 → 0.1.0-beta.3

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/index.d.cts CHANGED
@@ -1177,130 +1177,6 @@ declare class ContextManager {
1177
1177
  private log;
1178
1178
  }
1179
1179
 
1180
- interface TokenUsage$1 {
1181
- prompt: number;
1182
- completion: number;
1183
- total: number;
1184
- }
1185
- /** Configuration for the OpenAI adapter (custom adapter pattern). */
1186
- interface OpenAIAdapterConfig {
1187
- apiKey: string;
1188
- model?: 'gpt-4o' | 'gpt-4o-mini' | (string & {});
1189
- }
1190
- /**
1191
- * Adapter that translates between GuideKit's internal types and the
1192
- * OpenAI Chat Completions API wire format. Handles streaming via SSE,
1193
- * tool formatting, and response parsing.
1194
- *
1195
- * Usage as a custom adapter:
1196
- * ```ts
1197
- * import { OpenAIAdapter } from '@guidekit/core';
1198
- * const llmConfig = { adapter: new OpenAIAdapter({ apiKey: '...', model: 'gpt-4o' }) };
1199
- * ```
1200
- */
1201
- declare class OpenAIAdapter implements LLMProviderAdapter {
1202
- private readonly apiKey;
1203
- private readonly model;
1204
- /** Tracks whether the last extractChunks call emitted a done chunk. */
1205
- private lastExtractEmittedDone;
1206
- /**
1207
- * Token usage extracted from the most recent `parseResponse` call.
1208
- * Updated as each SSE chunk is parsed.
1209
- */
1210
- private _lastUsage;
1211
- constructor(config: OpenAIAdapterConfig);
1212
- /** Token usage from the most recent parseResponse call. */
1213
- get lastUsage(): TokenUsage$1;
1214
- /**
1215
- * Convert GuideKit tool definitions into OpenAI's `tools` format.
1216
- * Each tool is wrapped as `{ type: 'function', function: { name, description, parameters } }`.
1217
- */
1218
- formatTools(tools: ToolDefinition[]): unknown;
1219
- /**
1220
- * Convert an array of `ConversationTurn` objects into OpenAI's messages
1221
- * format with `role: 'user' | 'assistant'`.
1222
- */
1223
- formatConversation(history: ConversationTurn[]): Array<{
1224
- role: 'user' | 'assistant';
1225
- content: string;
1226
- }>;
1227
- /**
1228
- * Parse an OpenAI SSE streaming response into an async iterable of
1229
- * `TextChunk` and `ToolCall` objects.
1230
- *
1231
- * The OpenAI streaming endpoint sends each chunk as a JSON object
1232
- * prefixed by `data: `. The final line is `data: [DONE]`.
1233
- * Text content arrives in `choices[0].delta.content` and tool calls
1234
- * arrive in `choices[0].delta.tool_calls`.
1235
- *
1236
- * This method also:
1237
- * - Detects content filtering and throws `ContentFilterError`.
1238
- * - Tracks token usage (accessible via `lastUsage` after iteration).
1239
- */
1240
- parseResponse(stream: ReadableStream<Uint8Array>): AsyncIterable<TextChunk | ToolCall>;
1241
- /**
1242
- * Format a tool result so it can be sent back to OpenAI as a
1243
- * `tool` role message with the `tool_call_id`.
1244
- */
1245
- formatToolResult(callId: string, result: unknown): {
1246
- role: 'tool';
1247
- tool_call_id: string;
1248
- content: string;
1249
- };
1250
- /**
1251
- * Build and execute a streaming request to the OpenAI Chat Completions API.
1252
- * Returns the raw `ReadableStream` for the response body together with
1253
- * the raw Response object.
1254
- */
1255
- streamRequest(params: {
1256
- systemPrompt: string;
1257
- contents: unknown;
1258
- userMessage?: string;
1259
- tools?: unknown;
1260
- signal?: AbortSignal;
1261
- timeoutMs?: number;
1262
- }): Promise<{
1263
- stream: ReadableStream<Uint8Array>;
1264
- response: Response;
1265
- }>;
1266
- /**
1267
- * Extract `TextChunk` and accumulate `ToolCall` data from a single parsed
1268
- * OpenAI SSE JSON object.
1269
- *
1270
- * OpenAI tool calls arrive incrementally: the first chunk for a tool call
1271
- * carries the `id` and `function.name`, while subsequent chunks append to
1272
- * `function.arguments`. We accumulate these in `pendingToolCalls` and only
1273
- * yield complete `ToolCall` objects when the finish_reason is 'tool_calls'
1274
- * or when flushed.
1275
- */
1276
- private extractChunks;
1277
- /**
1278
- * Flush all accumulated pending tool calls as complete `ToolCall` objects.
1279
- */
1280
- private flushPendingToolCalls;
1281
- /**
1282
- * Extract token usage from a parsed OpenAI response chunk.
1283
- * Usage data typically appears in the final chunk when `stream_options`
1284
- * includes `include_usage`, or in the non-streaming response.
1285
- * Returns `null` if no usage data is present.
1286
- */
1287
- extractUsage(parsed: Record<string, unknown>): TokenUsage$1 | null;
1288
- /**
1289
- * Check whether a parsed OpenAI chunk indicates the response was
1290
- * blocked by a content filter.
1291
- *
1292
- * OpenAI signals content filtering through:
1293
- * - `choices[].finish_reason === 'content_filter'`
1294
- * - `choices[].content_filter_results` with `filtered: true`
1295
- */
1296
- isContentFiltered(parsed: Record<string, unknown>): boolean;
1297
- /**
1298
- * Translate an HTTP error response from OpenAI into the appropriate
1299
- * GuideKit error class.
1300
- */
1301
- private handleHttpError;
1302
- }
1303
-
1304
1180
  interface TokenUsage {
1305
1181
  prompt: number;
1306
1182
  completion: number;
@@ -1478,7 +1354,7 @@ declare class LLMOrchestrator {
1478
1354
  *
1479
1355
  * Custom adapters:
1480
1356
  * - Pass `{ adapter: myAdapter }` to use any `LLMProviderAdapter`.
1481
- * Example: `llm: { adapter: new OpenAIAdapter({ ... }) }`
1357
+ * Example: `llm: { adapter: myCustomAdapter }`
1482
1358
  */
1483
1359
  private createAdapter;
1484
1360
  /** Convenience accessor for the current provider name. */
@@ -2724,4 +2600,4 @@ declare class VoicePipeline {
2724
2600
  private _log;
2725
2601
  }
2726
2602
 
2727
- export { type AgentConfig, type AgentState, type AggregatedUsage, AuthenticationError, type AwarenessOptions, type AwarenessState, AwarenessSystem, type BeforeLLMCallContext, BrowserSupportError, ConfigurationError, ConnectionManager, type ConnectionManagerOptions, type ConnectionState, ContentFilterError, type ContentMap, type ContentMapEntry, type ContentMapFunction, type ContentMapInput, ContextManager, type ContextManagerOptions, type ConversationTurn, type CreateSessionTokenOptions, DOMScanner, type DOMScannerOptions, type ErrorCode, ErrorCodes, EventBus, type EventMap, type FormField, type FormSummary, GeminiAdapter, GuideKitCore, type GuideKitCoreOptions, GuideKitError, type GuideKitErrorOptions, type GuideKitErrorType, type GuideKitEvent, type GuideKitOptions, type GuideKitProviderProps, type GuideKitStore, type GuideKitTheme, type HealthCheckResult, type HealthCheckStatus, I18n, type I18nOptions, type I18nStrings, InitializationError, type InteractiveElement, type LLMConfig, LLMOrchestrator, type LLMProviderAdapter, type LocaleInput, type NavItem, NavigationController, type NavigationControllerOptions, NetworkError, OpenAIAdapter, type OpenAIAdapterConfig, type OverlayElement, type PageModel, type PageSection, PermissionError, type ProactiveOptions, type ProactiveTrigger, ProactiveTriggerEngine, type ProactiveTriggerType, type Provider, type QueuedMessage, RateLimitError, RateLimiter, type RateLimiterOptions, type RateLimiterState, type RateLimits, type Resource, ResourceExhaustedError, ResourceManager, type ResourceManagerState, type STTConfig, type ScanMetadata, type SessionState, SingletonGuard, type SpotlightState, type SupportedLocale, type TTSConfig, type TextChunk, TimeoutError, type TokenData, TokenManager, type TokenManagerOptions, type TokenPayload, type TokenResponse, type ToolCall, type ToolCallRecord, type ToolDefinition, type ToolExecutionResult, ToolExecutor, type ToolExecutorOptions, type ToolHandler, type TooltipOptions, VisualGuidance, type VisualGuidanceOptions, VoicePipeline, type VoicePipelineOptions, type VoiceState, WebSpeechSTT, type WebSpeechSTTOptions, WebSpeechTTS, type WebSpeechTTSAudioEvent, type WebSpeechTTSOptions, createEventBus, isGuideKitError };
2603
+ export { type AgentConfig, type AgentState, type AggregatedUsage, AuthenticationError, type AwarenessOptions, type AwarenessState, AwarenessSystem, type BeforeLLMCallContext, BrowserSupportError, ConfigurationError, ConnectionManager, type ConnectionManagerOptions, type ConnectionState, ContentFilterError, type ContentMap, type ContentMapEntry, type ContentMapFunction, type ContentMapInput, ContextManager, type ContextManagerOptions, type ConversationTurn, type CreateSessionTokenOptions, DOMScanner, type DOMScannerOptions, type ErrorCode, ErrorCodes, EventBus, type EventMap, type FormField, type FormSummary, GeminiAdapter, GuideKitCore, type GuideKitCoreOptions, GuideKitError, type GuideKitErrorOptions, type GuideKitErrorType, type GuideKitEvent, type GuideKitOptions, type GuideKitProviderProps, type GuideKitStore, type GuideKitTheme, type HealthCheckResult, type HealthCheckStatus, I18n, type I18nOptions, type I18nStrings, InitializationError, type InteractiveElement, type LLMConfig, LLMOrchestrator, type LLMProviderAdapter, type LocaleInput, type NavItem, NavigationController, type NavigationControllerOptions, NetworkError, type OverlayElement, type PageModel, type PageSection, PermissionError, type ProactiveOptions, type ProactiveTrigger, ProactiveTriggerEngine, type ProactiveTriggerType, type Provider, type QueuedMessage, RateLimitError, RateLimiter, type RateLimiterOptions, type RateLimiterState, type RateLimits, type Resource, ResourceExhaustedError, ResourceManager, type ResourceManagerState, type STTConfig, type ScanMetadata, type SessionState, SingletonGuard, type SpotlightState, type SupportedLocale, type TTSConfig, type TextChunk, TimeoutError, type TokenData, TokenManager, type TokenManagerOptions, type TokenPayload, type TokenResponse, type ToolCall, type ToolCallRecord, type ToolDefinition, type ToolExecutionResult, ToolExecutor, type ToolExecutorOptions, type ToolHandler, type TooltipOptions, VisualGuidance, type VisualGuidanceOptions, VoicePipeline, type VoicePipelineOptions, type VoiceState, WebSpeechSTT, type WebSpeechSTTOptions, WebSpeechTTS, type WebSpeechTTSAudioEvent, type WebSpeechTTSOptions, createEventBus, isGuideKitError };
package/dist/index.d.ts CHANGED
@@ -1177,130 +1177,6 @@ declare class ContextManager {
1177
1177
  private log;
1178
1178
  }
1179
1179
 
1180
- interface TokenUsage$1 {
1181
- prompt: number;
1182
- completion: number;
1183
- total: number;
1184
- }
1185
- /** Configuration for the OpenAI adapter (custom adapter pattern). */
1186
- interface OpenAIAdapterConfig {
1187
- apiKey: string;
1188
- model?: 'gpt-4o' | 'gpt-4o-mini' | (string & {});
1189
- }
1190
- /**
1191
- * Adapter that translates between GuideKit's internal types and the
1192
- * OpenAI Chat Completions API wire format. Handles streaming via SSE,
1193
- * tool formatting, and response parsing.
1194
- *
1195
- * Usage as a custom adapter:
1196
- * ```ts
1197
- * import { OpenAIAdapter } from '@guidekit/core';
1198
- * const llmConfig = { adapter: new OpenAIAdapter({ apiKey: '...', model: 'gpt-4o' }) };
1199
- * ```
1200
- */
1201
- declare class OpenAIAdapter implements LLMProviderAdapter {
1202
- private readonly apiKey;
1203
- private readonly model;
1204
- /** Tracks whether the last extractChunks call emitted a done chunk. */
1205
- private lastExtractEmittedDone;
1206
- /**
1207
- * Token usage extracted from the most recent `parseResponse` call.
1208
- * Updated as each SSE chunk is parsed.
1209
- */
1210
- private _lastUsage;
1211
- constructor(config: OpenAIAdapterConfig);
1212
- /** Token usage from the most recent parseResponse call. */
1213
- get lastUsage(): TokenUsage$1;
1214
- /**
1215
- * Convert GuideKit tool definitions into OpenAI's `tools` format.
1216
- * Each tool is wrapped as `{ type: 'function', function: { name, description, parameters } }`.
1217
- */
1218
- formatTools(tools: ToolDefinition[]): unknown;
1219
- /**
1220
- * Convert an array of `ConversationTurn` objects into OpenAI's messages
1221
- * format with `role: 'user' | 'assistant'`.
1222
- */
1223
- formatConversation(history: ConversationTurn[]): Array<{
1224
- role: 'user' | 'assistant';
1225
- content: string;
1226
- }>;
1227
- /**
1228
- * Parse an OpenAI SSE streaming response into an async iterable of
1229
- * `TextChunk` and `ToolCall` objects.
1230
- *
1231
- * The OpenAI streaming endpoint sends each chunk as a JSON object
1232
- * prefixed by `data: `. The final line is `data: [DONE]`.
1233
- * Text content arrives in `choices[0].delta.content` and tool calls
1234
- * arrive in `choices[0].delta.tool_calls`.
1235
- *
1236
- * This method also:
1237
- * - Detects content filtering and throws `ContentFilterError`.
1238
- * - Tracks token usage (accessible via `lastUsage` after iteration).
1239
- */
1240
- parseResponse(stream: ReadableStream<Uint8Array>): AsyncIterable<TextChunk | ToolCall>;
1241
- /**
1242
- * Format a tool result so it can be sent back to OpenAI as a
1243
- * `tool` role message with the `tool_call_id`.
1244
- */
1245
- formatToolResult(callId: string, result: unknown): {
1246
- role: 'tool';
1247
- tool_call_id: string;
1248
- content: string;
1249
- };
1250
- /**
1251
- * Build and execute a streaming request to the OpenAI Chat Completions API.
1252
- * Returns the raw `ReadableStream` for the response body together with
1253
- * the raw Response object.
1254
- */
1255
- streamRequest(params: {
1256
- systemPrompt: string;
1257
- contents: unknown;
1258
- userMessage?: string;
1259
- tools?: unknown;
1260
- signal?: AbortSignal;
1261
- timeoutMs?: number;
1262
- }): Promise<{
1263
- stream: ReadableStream<Uint8Array>;
1264
- response: Response;
1265
- }>;
1266
- /**
1267
- * Extract `TextChunk` and accumulate `ToolCall` data from a single parsed
1268
- * OpenAI SSE JSON object.
1269
- *
1270
- * OpenAI tool calls arrive incrementally: the first chunk for a tool call
1271
- * carries the `id` and `function.name`, while subsequent chunks append to
1272
- * `function.arguments`. We accumulate these in `pendingToolCalls` and only
1273
- * yield complete `ToolCall` objects when the finish_reason is 'tool_calls'
1274
- * or when flushed.
1275
- */
1276
- private extractChunks;
1277
- /**
1278
- * Flush all accumulated pending tool calls as complete `ToolCall` objects.
1279
- */
1280
- private flushPendingToolCalls;
1281
- /**
1282
- * Extract token usage from a parsed OpenAI response chunk.
1283
- * Usage data typically appears in the final chunk when `stream_options`
1284
- * includes `include_usage`, or in the non-streaming response.
1285
- * Returns `null` if no usage data is present.
1286
- */
1287
- extractUsage(parsed: Record<string, unknown>): TokenUsage$1 | null;
1288
- /**
1289
- * Check whether a parsed OpenAI chunk indicates the response was
1290
- * blocked by a content filter.
1291
- *
1292
- * OpenAI signals content filtering through:
1293
- * - `choices[].finish_reason === 'content_filter'`
1294
- * - `choices[].content_filter_results` with `filtered: true`
1295
- */
1296
- isContentFiltered(parsed: Record<string, unknown>): boolean;
1297
- /**
1298
- * Translate an HTTP error response from OpenAI into the appropriate
1299
- * GuideKit error class.
1300
- */
1301
- private handleHttpError;
1302
- }
1303
-
1304
1180
  interface TokenUsage {
1305
1181
  prompt: number;
1306
1182
  completion: number;
@@ -1478,7 +1354,7 @@ declare class LLMOrchestrator {
1478
1354
  *
1479
1355
  * Custom adapters:
1480
1356
  * - Pass `{ adapter: myAdapter }` to use any `LLMProviderAdapter`.
1481
- * Example: `llm: { adapter: new OpenAIAdapter({ ... }) }`
1357
+ * Example: `llm: { adapter: myCustomAdapter }`
1482
1358
  */
1483
1359
  private createAdapter;
1484
1360
  /** Convenience accessor for the current provider name. */
@@ -2724,4 +2600,4 @@ declare class VoicePipeline {
2724
2600
  private _log;
2725
2601
  }
2726
2602
 
2727
- export { type AgentConfig, type AgentState, type AggregatedUsage, AuthenticationError, type AwarenessOptions, type AwarenessState, AwarenessSystem, type BeforeLLMCallContext, BrowserSupportError, ConfigurationError, ConnectionManager, type ConnectionManagerOptions, type ConnectionState, ContentFilterError, type ContentMap, type ContentMapEntry, type ContentMapFunction, type ContentMapInput, ContextManager, type ContextManagerOptions, type ConversationTurn, type CreateSessionTokenOptions, DOMScanner, type DOMScannerOptions, type ErrorCode, ErrorCodes, EventBus, type EventMap, type FormField, type FormSummary, GeminiAdapter, GuideKitCore, type GuideKitCoreOptions, GuideKitError, type GuideKitErrorOptions, type GuideKitErrorType, type GuideKitEvent, type GuideKitOptions, type GuideKitProviderProps, type GuideKitStore, type GuideKitTheme, type HealthCheckResult, type HealthCheckStatus, I18n, type I18nOptions, type I18nStrings, InitializationError, type InteractiveElement, type LLMConfig, LLMOrchestrator, type LLMProviderAdapter, type LocaleInput, type NavItem, NavigationController, type NavigationControllerOptions, NetworkError, OpenAIAdapter, type OpenAIAdapterConfig, type OverlayElement, type PageModel, type PageSection, PermissionError, type ProactiveOptions, type ProactiveTrigger, ProactiveTriggerEngine, type ProactiveTriggerType, type Provider, type QueuedMessage, RateLimitError, RateLimiter, type RateLimiterOptions, type RateLimiterState, type RateLimits, type Resource, ResourceExhaustedError, ResourceManager, type ResourceManagerState, type STTConfig, type ScanMetadata, type SessionState, SingletonGuard, type SpotlightState, type SupportedLocale, type TTSConfig, type TextChunk, TimeoutError, type TokenData, TokenManager, type TokenManagerOptions, type TokenPayload, type TokenResponse, type ToolCall, type ToolCallRecord, type ToolDefinition, type ToolExecutionResult, ToolExecutor, type ToolExecutorOptions, type ToolHandler, type TooltipOptions, VisualGuidance, type VisualGuidanceOptions, VoicePipeline, type VoicePipelineOptions, type VoiceState, WebSpeechSTT, type WebSpeechSTTOptions, WebSpeechTTS, type WebSpeechTTSAudioEvent, type WebSpeechTTSOptions, createEventBus, isGuideKitError };
2603
+ export { type AgentConfig, type AgentState, type AggregatedUsage, AuthenticationError, type AwarenessOptions, type AwarenessState, AwarenessSystem, type BeforeLLMCallContext, BrowserSupportError, ConfigurationError, ConnectionManager, type ConnectionManagerOptions, type ConnectionState, ContentFilterError, type ContentMap, type ContentMapEntry, type ContentMapFunction, type ContentMapInput, ContextManager, type ContextManagerOptions, type ConversationTurn, type CreateSessionTokenOptions, DOMScanner, type DOMScannerOptions, type ErrorCode, ErrorCodes, EventBus, type EventMap, type FormField, type FormSummary, GeminiAdapter, GuideKitCore, type GuideKitCoreOptions, GuideKitError, type GuideKitErrorOptions, type GuideKitErrorType, type GuideKitEvent, type GuideKitOptions, type GuideKitProviderProps, type GuideKitStore, type GuideKitTheme, type HealthCheckResult, type HealthCheckStatus, I18n, type I18nOptions, type I18nStrings, InitializationError, type InteractiveElement, type LLMConfig, LLMOrchestrator, type LLMProviderAdapter, type LocaleInput, type NavItem, NavigationController, type NavigationControllerOptions, NetworkError, type OverlayElement, type PageModel, type PageSection, PermissionError, type ProactiveOptions, type ProactiveTrigger, ProactiveTriggerEngine, type ProactiveTriggerType, type Provider, type QueuedMessage, RateLimitError, RateLimiter, type RateLimiterOptions, type RateLimiterState, type RateLimits, type Resource, ResourceExhaustedError, ResourceManager, type ResourceManagerState, type STTConfig, type ScanMetadata, type SessionState, SingletonGuard, type SpotlightState, type SupportedLocale, type TTSConfig, type TextChunk, TimeoutError, type TokenData, TokenManager, type TokenManagerOptions, type TokenPayload, type TokenResponse, type ToolCall, type ToolCallRecord, type ToolDefinition, type ToolExecutionResult, ToolExecutor, type ToolExecutorOptions, type ToolHandler, type TooltipOptions, VisualGuidance, type VisualGuidanceOptions, VoicePipeline, type VoicePipelineOptions, type VoiceState, WebSpeechSTT, type WebSpeechSTTOptions, WebSpeechTTS, type WebSpeechTTSAudioEvent, type WebSpeechTTSOptions, createEventBus, isGuideKitError };