@elevasis/ui 1.20.1 → 1.22.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.
Files changed (66) hide show
  1. package/dist/charts/index.js +3 -2
  2. package/dist/chunk-3KMDHCAR.js +52 -0
  3. package/dist/{chunk-4SY4EQSK.js → chunk-5266RV46.js} +3 -3
  4. package/dist/{chunk-UMFPUM7Q.js → chunk-7TLPKXC2.js} +12 -12
  5. package/dist/{chunk-OFAXUZPZ.js → chunk-AJPFSMEH.js} +528 -336
  6. package/dist/chunk-AWT255UH.js +255 -0
  7. package/dist/{chunk-EMN755L5.js → chunk-CTF6FS2M.js} +10 -216
  8. package/dist/{chunk-C7AD6N23.js → chunk-DLI3F5IV.js} +364 -364
  9. package/dist/{chunk-AQ5MQDSS.js → chunk-EDAYKRPJ.js} +404 -2
  10. package/dist/{chunk-XOTN3X3Z.js → chunk-FATKFO7X.js} +3 -54
  11. package/dist/{chunk-JZEXFQ6N.js → chunk-HOYZWSNV.js} +91 -80
  12. package/dist/{chunk-AWMZCYKH.js → chunk-IAZT3VO6.js} +158 -82
  13. package/dist/{chunk-ERVB3QJQ.js → chunk-N5SDJP44.js} +1 -1
  14. package/dist/{chunk-3DIU726S.js → chunk-NVSKJG3L.js} +25 -4
  15. package/dist/{chunk-VLTVZXP6.js → chunk-QZS5FOIR.js} +2 -2
  16. package/dist/chunk-ROSMICXG.js +668 -0
  17. package/dist/{chunk-JIABC3AE.js → chunk-WAEKXBP3.js} +516 -266
  18. package/dist/{chunk-COTI2QPO.js → chunk-ZHJGTOXP.js} +4 -3
  19. package/dist/components/chat/index.d.ts +202 -0
  20. package/dist/components/chat/index.js +2 -0
  21. package/dist/components/index.css +0 -3
  22. package/dist/components/index.d.ts +37 -37
  23. package/dist/components/index.js +2652 -2902
  24. package/dist/features/auth/index.css +0 -3
  25. package/dist/features/dashboard/index.css +0 -3
  26. package/dist/features/dashboard/index.js +9 -9
  27. package/dist/features/monitoring/index.css +0 -3
  28. package/dist/features/monitoring/index.js +10 -10
  29. package/dist/features/operations/index.css +0 -3
  30. package/dist/features/operations/index.d.ts +245 -10
  31. package/dist/features/operations/index.js +1115 -170
  32. package/dist/features/settings/index.css +0 -3
  33. package/dist/features/settings/index.js +9 -9
  34. package/dist/hooks/index.css +68 -3
  35. package/dist/hooks/index.d.ts +1165 -4
  36. package/dist/hooks/index.js +5 -6
  37. package/dist/hooks/published.css +68 -3
  38. package/dist/hooks/published.d.ts +1165 -4
  39. package/dist/hooks/published.js +4 -5
  40. package/dist/index.css +68 -3
  41. package/dist/index.d.ts +1166 -5
  42. package/dist/index.js +6 -7
  43. package/dist/layout/index.d.ts +4 -4
  44. package/dist/layout/index.js +3 -4
  45. package/dist/provider/index.css +0 -3
  46. package/dist/provider/index.d.ts +1 -1
  47. package/dist/provider/index.js +3 -4
  48. package/dist/provider/published.d.ts +1 -1
  49. package/dist/theme/index.d.ts +1 -1
  50. package/dist/theme/index.js +3 -3
  51. package/dist/types/index.d.ts +1 -1
  52. package/package.json +7 -2
  53. package/dist/chunk-JFRG2JJE.js +0 -47
  54. package/dist/chunk-R3R367QY.js +0 -14
  55. package/dist/theme/presets/__tests__/getPreset.test.d.ts +0 -2
  56. package/dist/theme/presets/__tests__/getPreset.test.d.ts.map +0 -1
  57. package/dist/theme/presets/__tests__/getPreset.test.js +0 -92
  58. package/dist/theme/presets/cyber-volt.d.ts +0 -12
  59. package/dist/theme/presets/cyber-volt.d.ts.map +0 -1
  60. package/dist/theme/presets/cyber-volt.js +0 -70
  61. package/dist/theme/presets/regal.d.ts +0 -8
  62. package/dist/theme/presets/regal.d.ts.map +0 -1
  63. package/dist/theme/presets/regal.js +0 -69
  64. package/dist/theme/presets/rose-gold.d.ts +0 -12
  65. package/dist/theme/presets/rose-gold.d.ts.map +0 -1
  66. package/dist/theme/presets/rose-gold.js +0 -76
@@ -1,9 +1,9 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
+ import { z } from 'zod';
2
3
  import * as react from 'react';
3
4
  import * as zustand_middleware from 'zustand/middleware';
4
5
  import * as zustand from 'zustand';
5
6
  import { Edge } from '@xyflow/react';
6
- import { z } from 'zod';
7
7
 
8
8
  /**
9
9
  * Query key factory for executions TanStack Query hooks.
@@ -626,6 +626,51 @@ interface AgentToolCallEvent {
626
626
  * 3 event types total (lifecycle, iteration, tool-call)
627
627
  */
628
628
  type AgentLogContext = AgentLifecycleEvent | AgentIterationEvent | AgentToolCallEvent;
629
+ /**
630
+ * Data for lifecycle 'started' events
631
+ */
632
+ interface AgentLifecycleStartedData {
633
+ startTime: number;
634
+ iteration?: number;
635
+ }
636
+ /**
637
+ * Data for lifecycle 'completed' events
638
+ */
639
+ interface AgentLifecycleCompletedData {
640
+ startTime: number;
641
+ endTime: number;
642
+ duration: number;
643
+ iteration?: number;
644
+ attempts?: number;
645
+ memorySize?: {
646
+ sessionMemoryKeys: number;
647
+ historyEntries: number;
648
+ };
649
+ }
650
+ /**
651
+ * Data for lifecycle 'failed' events
652
+ */
653
+ interface AgentLifecycleFailedData {
654
+ startTime: number;
655
+ endTime: number;
656
+ duration: number;
657
+ error: string;
658
+ iteration?: number;
659
+ }
660
+ /**
661
+ * Scoped logger for agent execution
662
+ * Captures logger and agentId to eliminate repetitive parameter passing
663
+ *
664
+ * Type-safe lifecycle logging with stage-specific required fields
665
+ */
666
+ interface AgentScopedLogger {
667
+ lifecycle(lifecycle: AgentLifecycle, stage: 'started', data: AgentLifecycleStartedData): void;
668
+ lifecycle(lifecycle: AgentLifecycle, stage: 'completed', data: AgentLifecycleCompletedData): void;
669
+ lifecycle(lifecycle: AgentLifecycle, stage: 'failed', data: AgentLifecycleFailedData): void;
670
+ reasoning(output: string, iteration: number, startTime: number, endTime: number, duration: number): void;
671
+ action(actionType: string, message: string, iteration: number, startTime: number, endTime: number, duration: number): void;
672
+ toolCall(toolName: string, iteration: number, startTime: number, endTime: number, duration: number, success: boolean, error?: string, input?: unknown, output?: unknown): void;
673
+ }
629
674
 
630
675
  /**
631
676
  * Base execution logger for Execution Engine
@@ -639,6 +684,12 @@ interface ExecutionLogMessage {
639
684
  timestamp: number;
640
685
  context?: LogContext;
641
686
  }
687
+ interface IExecutionLogger {
688
+ debug(message: string, context?: LogContext): void;
689
+ info(message: string, context?: LogContext): void;
690
+ warn(message: string, context?: LogContext): void;
691
+ error(message: string, context?: LogContext): void;
692
+ }
642
693
 
643
694
  /**
644
695
  * Shared form field types for dynamic form generation
@@ -920,6 +971,262 @@ interface SerializedWorkflowDefinition {
920
971
  interface?: SerializedExecutionInterface;
921
972
  }
922
973
 
974
+ /**
975
+ * Model Configuration
976
+ * Centralized model information, configuration, options, constraints, and validation
977
+ * Single source of truth for all model-related definitions
978
+ * Update manually when pricing changes or new models are added
979
+ */
980
+
981
+ /**
982
+ * Supported Open AI models (direct SDK access)
983
+ */
984
+ type OpenAIModel = 'gpt-5' | 'gpt-5.4-mini' | 'gpt-5.4-nano';
985
+ /**
986
+ * Supported OpenRouter models (explicit union for type safety)
987
+ */
988
+ type OpenRouterModel = 'openrouter/z-ai/glm-5';
989
+ /**
990
+ * Supported Google models (direct SDK access)
991
+ */
992
+ type GoogleModel = 'gemini-3-flash-preview' | 'gemini-3.1-flash-lite-preview';
993
+ /**
994
+ * Supported Anthropic models (direct SDK access via @anthropic-ai/sdk)
995
+ */
996
+ type AnthropicModel = 'claude-sonnet-4-5';
997
+ /** Supported LLM models */
998
+ type LLMModel = OpenAIModel | OpenRouterModel | GoogleModel | AnthropicModel | 'mock';
999
+ /**
1000
+ * GPT-5 model options schema
1001
+ */
1002
+ declare const GPT5OptionsSchema: z.ZodObject<{
1003
+ reasoning_effort: z.ZodOptional<z.ZodEnum<{
1004
+ minimal: "minimal";
1005
+ low: "low";
1006
+ medium: "medium";
1007
+ high: "high";
1008
+ }>>;
1009
+ verbosity: z.ZodOptional<z.ZodEnum<{
1010
+ low: "low";
1011
+ medium: "medium";
1012
+ high: "high";
1013
+ }>>;
1014
+ }, z.core.$strip>;
1015
+ /**
1016
+ * OpenRouter model options schema
1017
+ * OpenRouter-specific options for routing and transforms
1018
+ */
1019
+ declare const OpenRouterOptionsSchema: z.ZodObject<{
1020
+ transforms: z.ZodOptional<z.ZodArray<z.ZodString>>;
1021
+ route: z.ZodOptional<z.ZodEnum<{
1022
+ fallback: "fallback";
1023
+ }>>;
1024
+ }, z.core.$strip>;
1025
+ /**
1026
+ * Google model options schema
1027
+ * Gemini 3 specific options for thinking depth control
1028
+ */
1029
+ declare const GoogleOptionsSchema: z.ZodObject<{
1030
+ thinkingLevel: z.ZodOptional<z.ZodEnum<{
1031
+ minimal: "minimal";
1032
+ low: "low";
1033
+ medium: "medium";
1034
+ high: "high";
1035
+ }>>;
1036
+ }, z.core.$strip>;
1037
+ /**
1038
+ * Anthropic model options schema
1039
+ * Currently empty - future options: budget_tokens for extended thinking
1040
+ */
1041
+ declare const AnthropicOptionsSchema: z.ZodObject<{}, z.core.$strip>;
1042
+ /**
1043
+ * Infer TypeScript types from schemas
1044
+ */
1045
+ type GPT5Options = z.infer<typeof GPT5OptionsSchema>;
1046
+ type MockOptions = Record<string, never>;
1047
+ type OpenRouterOptions = z.infer<typeof OpenRouterOptionsSchema>;
1048
+ type GoogleOptions = z.infer<typeof GoogleOptionsSchema>;
1049
+ type AnthropicOptions = z.infer<typeof AnthropicOptionsSchema>;
1050
+ type ModelSpecificOptions = GPT5Options | MockOptions | OpenRouterOptions | GoogleOptions | AnthropicOptions;
1051
+ /**
1052
+ * Model configuration for LLM execution
1053
+ * Belongs in resource definition (AgentDefinition, WorkflowDefinition, etc.)
1054
+ */
1055
+ interface ModelConfig {
1056
+ model: LLMModel;
1057
+ provider: 'openai' | 'anthropic' | 'openrouter' | 'google' | 'mock';
1058
+ apiKey: string;
1059
+ temperature?: number;
1060
+ /** Maximum output tokens per LLM call. NOT the model's context window — see ModelInfo.maxTokens for that. */
1061
+ maxOutputTokens?: number;
1062
+ topP?: number;
1063
+ /**
1064
+ * Model-specific options (flat structure)
1065
+ * Options are model-specific, not vendor-specific
1066
+ * Available options defined in MODEL_INFO per model
1067
+ * Validated at build time via validateModelOptions()
1068
+ */
1069
+ modelOptions?: ModelSpecificOptions;
1070
+ }
1071
+
1072
+ /**
1073
+ * Execution interface configuration
1074
+ * Defines how a resource is executed via the UI (forms, scheduling, webhooks)
1075
+ * Applies to both agents and workflows
1076
+ */
1077
+ interface ExecutionInterface {
1078
+ /** Form configuration for execution inputs */
1079
+ form: ExecutionFormSchema;
1080
+ /** Optional: Schedule configuration */
1081
+ schedule?: ScheduleConfig;
1082
+ /** Optional: Webhook trigger configuration */
1083
+ webhook?: WebhookConfig;
1084
+ }
1085
+ /**
1086
+ * Execution form schema
1087
+ * Extends FormSchema with execution-specific fields
1088
+ */
1089
+ interface ExecutionFormSchema extends FormSchema {
1090
+ /**
1091
+ * Field mappings to resource input schema
1092
+ * Maps form field names to contract input paths
1093
+ * If omitted, field names must match contract input keys exactly
1094
+ */
1095
+ fieldMappings?: Record<string, string>;
1096
+ /**
1097
+ * Submit button configuration
1098
+ * Default: { label: 'Run', loadingLabel: 'Running...' }
1099
+ */
1100
+ submitButton?: {
1101
+ label?: string;
1102
+ loadingLabel?: string;
1103
+ confirmMessage?: string;
1104
+ };
1105
+ }
1106
+ /**
1107
+ * Schedule configuration for automated execution
1108
+ */
1109
+ interface ScheduleConfig {
1110
+ /** Whether scheduling is enabled for this resource */
1111
+ enabled: boolean;
1112
+ /** Default schedule (cron expression) */
1113
+ defaultSchedule?: string;
1114
+ /** Allowed schedule patterns (if restricted) */
1115
+ allowedPatterns?: string[];
1116
+ }
1117
+ /**
1118
+ * Webhook configuration for external triggers
1119
+ */
1120
+ interface WebhookConfig {
1121
+ /** Whether webhook trigger is enabled */
1122
+ enabled: boolean;
1123
+ /** Expected payload schema (for documentation) */
1124
+ payloadSchema?: unknown;
1125
+ }
1126
+
1127
+ interface WorkflowConfig extends ResourceDefinition {
1128
+ type: 'workflow';
1129
+ }
1130
+ interface WorkflowStepDefinition {
1131
+ id: string;
1132
+ name: string;
1133
+ description: string;
1134
+ }
1135
+ type StepHandler = (input: unknown, context: ExecutionContext) => Promise<unknown>;
1136
+ interface LinearNext {
1137
+ type: 'linear';
1138
+ target: string;
1139
+ }
1140
+ interface ConditionalNext {
1141
+ type: 'conditional';
1142
+ routes: Array<{
1143
+ condition: (data: unknown) => boolean;
1144
+ target: string;
1145
+ }>;
1146
+ default: string;
1147
+ }
1148
+ type NextConfig = LinearNext | ConditionalNext | null;
1149
+ interface WorkflowStep extends WorkflowStepDefinition {
1150
+ handler: StepHandler;
1151
+ inputSchema: z.ZodSchema;
1152
+ outputSchema: z.ZodSchema;
1153
+ next: NextConfig;
1154
+ }
1155
+ interface WorkflowDefinition {
1156
+ config: WorkflowConfig;
1157
+ contract: Contract;
1158
+ steps: Record<string, WorkflowStep>;
1159
+ entryPoint: string;
1160
+ /**
1161
+ * Metrics configuration for ROI calculations
1162
+ * Optional: Only needed if tracking automation savings
1163
+ */
1164
+ metricsConfig?: ResourceMetricsConfig;
1165
+ /**
1166
+ * Execution interface configuration (optional)
1167
+ * If provided, workflow appears in Execution Runner UI
1168
+ */
1169
+ interface?: ExecutionInterface;
1170
+ }
1171
+
1172
+ /**
1173
+ * Generic LLM Types
1174
+ * Universal interfaces for LLM interaction across all resource types
1175
+ */
1176
+ /**
1177
+ * Standard chat message format
1178
+ * Compatible with OpenAI, Anthropic, and other providers
1179
+ */
1180
+ interface LLMMessage {
1181
+ role: 'system' | 'user' | 'assistant';
1182
+ content: string;
1183
+ }
1184
+ /**
1185
+ * Generic LLM generation request
1186
+ * Usable by agents, workflows, tools, etc.
1187
+ */
1188
+ interface LLMGenerateRequest {
1189
+ messages: LLMMessage[];
1190
+ responseSchema: unknown;
1191
+ /** Maximum output tokens per LLM call. NOT the model's context window — see ModelInfo.maxTokens for that. */
1192
+ maxOutputTokens?: number;
1193
+ temperature?: number;
1194
+ topP?: number;
1195
+ signal?: AbortSignal;
1196
+ }
1197
+ /**
1198
+ * Generic LLM generation response
1199
+ * Usage field is internal-only (stripped by UniversalLLMAdapter wrapper)
1200
+ */
1201
+ interface LLMGenerateResponse<T = unknown> {
1202
+ output: T;
1203
+ usage?: {
1204
+ inputTokens: number;
1205
+ outputTokens: number;
1206
+ totalTokens: number;
1207
+ };
1208
+ cost?: number;
1209
+ }
1210
+ /**
1211
+ * LLM Adapter interface
1212
+ * Generic primitive for all resource types (agents, workflows, tools)
1213
+ *
1214
+ * Design principles:
1215
+ * - Single method: generate() - the core LLM primitive
1216
+ * - Generic return type for type safety
1217
+ * - Universal format (not agent-specific)
1218
+ * - Standard message-based input (OpenAI-compatible)
1219
+ */
1220
+ interface LLMAdapter {
1221
+ /**
1222
+ * Generate structured output from prompt using LLM
1223
+ *
1224
+ * @param request - Generation request with messages and response schema
1225
+ * @returns Generated output (typed) with optional usage metadata
1226
+ */
1227
+ generate<T = unknown>(request: LLMGenerateRequest): Promise<LLMGenerateResponse<T>>;
1228
+ }
1229
+
923
1230
  /**
924
1231
  * Memory type definitions
925
1232
  * Types for agent memory management with semantic entry types
@@ -960,6 +1267,302 @@ interface AgentMemory {
960
1267
  */
961
1268
  history: MemoryEntry[];
962
1269
  }
1270
+ /**
1271
+ * Memory status for agent awareness
1272
+ */
1273
+ interface MemoryStatus {
1274
+ sessionMemoryKeys: number;
1275
+ sessionMemoryLimit: number;
1276
+ currentKeys: string[];
1277
+ historyPercent: number;
1278
+ historyTokens: number;
1279
+ tokenBudget: number;
1280
+ }
1281
+ /**
1282
+ * Memory constraints (optional limits)
1283
+ */
1284
+ interface MemoryConstraints {
1285
+ maxSessionMemoryKeys?: number;
1286
+ maxMemoryTokens?: number;
1287
+ }
1288
+
1289
+ /**
1290
+ * Memory Manager
1291
+ * Encapsulates all memory operations with ultra-simple agent API
1292
+ * Agent provides strings, framework handles wrapping and auto-compaction
1293
+ */
1294
+
1295
+ /**
1296
+ * Memory Manager - Agent memory orchestration
1297
+ * Provides ultra-simple API for agents (strings only)
1298
+ * Handles automatic compaction and token management
1299
+ */
1300
+ declare class MemoryManager {
1301
+ private memory;
1302
+ private constraints;
1303
+ private logger?;
1304
+ private cachedSnapshot?;
1305
+ constructor(memory: AgentMemory, constraints?: MemoryConstraints, logger?: AgentScopedLogger | undefined);
1306
+ /**
1307
+ * Set session memory entry (agent provides string, framework wraps it)
1308
+ * @param key - Session memory key
1309
+ * @param content - String content from agent
1310
+ */
1311
+ set(key: string, content: string): void;
1312
+ /**
1313
+ * Get session memory entry content
1314
+ * @param key - Session memory key
1315
+ * @returns String content if exists, undefined otherwise
1316
+ */
1317
+ get(key: string): string | undefined;
1318
+ /**
1319
+ * Delete session memory entry
1320
+ * @param key - Key to delete
1321
+ * @returns True if key existed and was deleted
1322
+ */
1323
+ delete(key: string): boolean;
1324
+ /**
1325
+ * Add entry to history (called by framework after tool results, reasoning, etc.)
1326
+ * Automatically sets timestamp to current time
1327
+ * @param entry - Memory entry to add (without timestamp - auto-generated)
1328
+ */
1329
+ addToHistory(entry: Omit<MemoryEntry, 'timestamp'>): void;
1330
+ /**
1331
+ * Auto-compact history if approaching token budget
1332
+ * Uses preserve-anchors strategy: keep first + recent entries
1333
+ */
1334
+ autoCompact(): void;
1335
+ /**
1336
+ * Enforce hard limits (called before LLM request)
1337
+ * Emergency fallback if agent exceeds limits
1338
+ */
1339
+ enforceHardLimits(): void;
1340
+ /**
1341
+ * Get history length (for logging and introspection)
1342
+ * @returns Number of entries in history
1343
+ */
1344
+ getHistoryLength(): number;
1345
+ /**
1346
+ * Get memory status for agent awareness
1347
+ * @returns Memory status with token usage and key counts
1348
+ */
1349
+ getStatus(): MemoryStatus;
1350
+ /**
1351
+ * Create memory snapshot for persistence
1352
+ * Caches snapshot internally for later retrieval
1353
+ * @returns Deep copy of current memory state
1354
+ */
1355
+ toSnapshot(): AgentMemory;
1356
+ /**
1357
+ * Get cached memory snapshot
1358
+ * Returns snapshot created by toSnapshot()
1359
+ * @returns Cached snapshot (undefined if toSnapshot() not called yet)
1360
+ */
1361
+ getSnapshot(): AgentMemory | undefined;
1362
+ /**
1363
+ * Build context string for LLM
1364
+ * Serializes sessionmemory + history memory with clear sections
1365
+ * Shows current iteration entries FIRST (reverse chronological) for LLM attention
1366
+ * @param currentIteration - Current iteration number (0 = pre-iteration)
1367
+ * @param currentTurn - Current turn number (optional, for session context filtering)
1368
+ * @returns Formatted memory context for LLM prompt
1369
+ */
1370
+ toContext(currentIteration: number, currentTurn?: number): string;
1371
+ }
1372
+
1373
+ /**
1374
+ * Knowledge Map Types
1375
+ *
1376
+ * Enables agents to navigate organizational knowledge through a lightweight
1377
+ * graph that lazy-loads capabilities on-demand.
1378
+ *
1379
+ * @module agent/knowledge-map
1380
+ */
1381
+
1382
+ /**
1383
+ * Lightweight knowledge map (passed as agent property)
1384
+ *
1385
+ * Contains metadata about available knowledge nodes without loading
1386
+ * the full content upfront. Total size: ~300-500 tokens.
1387
+ *
1388
+ * Multi-tenancy is enforced via:
1389
+ * - File-scoped maps (organizations/{org-name}/knowledge/)
1390
+ * - ExecutionContext.organizationId passed to node.load()
1391
+ */
1392
+ interface KnowledgeMap {
1393
+ /** Available knowledge nodes indexed by ID */
1394
+ nodes: Record<string, KnowledgeNode>;
1395
+ }
1396
+ /**
1397
+ * Single knowledge source
1398
+ *
1399
+ * Represents a domain knowledge area (CRM, brand guidelines, Excel tools)
1400
+ * that can be lazy-loaded to provide instructions and tools to agents.
1401
+ */
1402
+ interface KnowledgeNode {
1403
+ /** Unique identifier for this node (e.g., "crm", "brand-guidelines") */
1404
+ id: string;
1405
+ /**
1406
+ * Description of when to use this knowledge
1407
+ * Used for semantic matching against user intent
1408
+ */
1409
+ description: string;
1410
+ /**
1411
+ * Load knowledge content on-demand
1412
+ *
1413
+ * @param context - Execution context with organizationId for multi-tenancy
1414
+ * @returns Promise resolving to knowledge content (prompt + optional tools)
1415
+ */
1416
+ load(context: ExecutionContext): Promise<KnowledgeContent>;
1417
+ /**
1418
+ * Loaded state flag
1419
+ * Set to true after load() is called
1420
+ */
1421
+ loaded?: boolean;
1422
+ /**
1423
+ * Cached prompt (for system prompt serialization)
1424
+ * Only the prompt is cached - tools go to toolRegistry, children flattened to nodes
1425
+ */
1426
+ prompt?: string;
1427
+ }
1428
+ /**
1429
+ * Content returned by knowledge node
1430
+ *
1431
+ * Separates instructions (prompt) from capabilities (tools).
1432
+ * Tools are optional - some nodes only provide context.
1433
+ *
1434
+ * Supports recursive navigation - nodes can contain child nodes
1435
+ * that are discovered when the parent node is loaded.
1436
+ */
1437
+ interface KnowledgeContent {
1438
+ /** Instructions and context (markdown format) */
1439
+ prompt: string;
1440
+ /** Tool implementations (optional) */
1441
+ tools?: Tool[];
1442
+ /**
1443
+ * Child knowledge nodes (optional, recursive)
1444
+ *
1445
+ * Enables hierarchical navigation: base → specialized → deep expertise.
1446
+ * Child nodes are flattened into the main knowledge map when parent loads,
1447
+ * making them available for subsequent navigate-knowledge actions.
1448
+ *
1449
+ * Example: CRM base node returns crm-customers and crm-deals as children
1450
+ */
1451
+ nodes?: Record<string, KnowledgeNode>;
1452
+ }
1453
+
1454
+ /**
1455
+ * Agent-specific type definitions
1456
+ * Types for autonomous agents with tools, memory, and constraints
1457
+ */
1458
+
1459
+ /**
1460
+ * Factory function for creating LLM adapters.
1461
+ * Injected into the Agent class to decouple the engine from server-only provider SDKs.
1462
+ * - API process: provides createLLMAdapter (real SDKs + process.env API keys)
1463
+ * - SDK worker: provides PostMessageLLMAdapter (proxies via platform.call)
1464
+ *
1465
+ * Uses `any` for optional params so both the real createLLMAdapter (with typed
1466
+ * AIUsageCollector/AICallContext) and the worker proxy (which ignores them) satisfy the type.
1467
+ */
1468
+ type LLMAdapterFactory = (config: ModelConfig, ...args: any[]) => LLMAdapter;
1469
+ interface AgentConfig extends ResourceDefinition {
1470
+ type: 'agent';
1471
+ systemPrompt: string;
1472
+ constraints?: AgentConstraints;
1473
+ /**
1474
+ * Session capability declaration (opt-in)
1475
+ * If true, agent is designed for multi-turn session interactions
1476
+ * Controls whether agent can use message action and appears in Sessions UI
1477
+ *
1478
+ * Use for:
1479
+ * - Conversational agents with multi-turn interactions
1480
+ * - Agents requiring persistent context across turns
1481
+ * - Agents that need human-in-the-loop communication
1482
+ */
1483
+ sessionCapable?: boolean;
1484
+ /**
1485
+ * Security level for system prompt hardening (auto-derived if omitted)
1486
+ *
1487
+ * - 'standard': Lightweight defense (3 rules) - default for non-session agents
1488
+ * - 'hardened': Comprehensive defense (6 rules) - default for session-capable agents
1489
+ * - 'none': No security prompt - for pure internal agents with no external input
1490
+ *
1491
+ * If omitted, derived from sessionCapable:
1492
+ * sessionCapable: true -> 'hardened'
1493
+ * sessionCapable: false -> 'standard'
1494
+ */
1495
+ securityLevel?: 'standard' | 'hardened' | 'none';
1496
+ /**
1497
+ * Memory management preferences (opt-in)
1498
+ * If provided, agent can use memoryOps to manage session memory
1499
+ * If omitted, agent has no memory management capabilities
1500
+ *
1501
+ * Agent-specific guidance on what to preserve, when to persist, and what to clean up.
1502
+ * This guidance is injected into the system prompt when memory management is enabled.
1503
+ *
1504
+ * Use for:
1505
+ * - Conversational agents needing cross-turn context
1506
+ * - Agents managing complex user preferences
1507
+ * - Agents tracking decisions over multiple iterations
1508
+ */
1509
+ memoryPreferences?: string;
1510
+ }
1511
+ interface AgentConstraints {
1512
+ maxIterations?: number;
1513
+ timeout?: number;
1514
+ maxSessionMemoryKeys?: number;
1515
+ maxMemoryTokens?: number;
1516
+ }
1517
+ interface AgentDefinition {
1518
+ config: AgentConfig;
1519
+ contract: Contract;
1520
+ tools: Tool[];
1521
+ /**
1522
+ * Model configuration for LLM execution
1523
+ * Specifies provider, API key, and model-specific options
1524
+ */
1525
+ modelConfig: ModelConfig;
1526
+ /**
1527
+ * Optional knowledge map for lazy-loading capabilities
1528
+ * Enables agents to navigate organizational knowledge on-demand
1529
+ */
1530
+ knowledgeMap?: KnowledgeMap;
1531
+ /**
1532
+ * Preload memory before execution starts
1533
+ * Handles BOTH context loading AND session restoration
1534
+ *
1535
+ * @param context - Execution context (includes sessionId if session turn)
1536
+ * @returns Initial AgentMemory state (sessionMemory entries + optionally history)
1537
+ */
1538
+ preloadMemory?: (context: ExecutionContext) => Promise<AgentMemory> | AgentMemory;
1539
+ /**
1540
+ * Metrics configuration for ROI calculations
1541
+ * Optional: Only needed if tracking automation savings
1542
+ */
1543
+ metricsConfig?: ResourceMetricsConfig;
1544
+ /**
1545
+ * Execution interface configuration (optional)
1546
+ * If provided, agent appears in Execution Runner UI
1547
+ */
1548
+ interface?: ExecutionInterface;
1549
+ }
1550
+ /**
1551
+ * Agent execution context
1552
+ * Groups all state needed for agent execution phases
1553
+ */
1554
+ interface IterationContext {
1555
+ config: AgentConfig;
1556
+ contract: Contract;
1557
+ toolRegistry: Map<string, Tool>;
1558
+ memoryManager: MemoryManager;
1559
+ executionContext: ExecutionContext;
1560
+ iteration: number;
1561
+ logger: AgentScopedLogger;
1562
+ modelConfig: ModelConfig;
1563
+ adapterFactory: LLMAdapterFactory;
1564
+ knowledgeMap?: KnowledgeMap;
1565
+ }
963
1566
 
964
1567
  type Json = string | number | boolean | null | {
965
1568
  [key: string]: Json | undefined;
@@ -3663,7 +4266,7 @@ interface MembershipFeatureConfig {
3663
4266
  */
3664
4267
  interface UserConfig {
3665
4268
  theme?: {
3666
- preset?: 'default' | 'tactical' | 'regal' | 'cyber-volt' | 'aurora' | 'rose-gold' | 'midnight' | 'ember' | 'obsidian' | 'honey' | 'abyss' | 'canopy' | 'slate' | 'cyber-strike' | 'cyber-punk' | 'cyber-void' | 'nirvana' | 'wave' | 'synapse' | 'cortex' | 'helios' | 'graphite' | 'canyon' | 'nord' | 'catppuccin' | 'tokyo-night' | 'gruvbox';
4269
+ preset?: 'default' | 'tactical' | 'regal' | 'cyber-volt' | 'aurora' | 'rose-gold' | 'midnight' | 'ember' | 'obsidian' | 'honey' | 'abyss' | 'canopy' | 'slate' | 'cyber-strike' | 'cyber-chrome' | 'cyber-void' | 'nirvana' | 'wave' | 'synapse' | 'cortex' | 'helios' | 'graphite' | 'quarry' | 'canyon' | 'nord' | 'catppuccin' | 'tokyo-night' | 'gruvbox';
3667
4270
  colorScheme?: 'light' | 'dark' | 'auto';
3668
4271
  };
3669
4272
  onboarding?: {
@@ -3720,6 +4323,102 @@ interface MembershipWithDetails extends OrganizationMembership {
3720
4323
  config?: MembershipFeatureConfig;
3721
4324
  }
3722
4325
 
4326
+ /**
4327
+ * MetricsCollector
4328
+ * Tracks execution timing and ROI metrics
4329
+ */
4330
+ declare class MetricsCollector {
4331
+ private timings;
4332
+ private durationMs?;
4333
+ /**
4334
+ * Start a timer with a label
4335
+ */
4336
+ startTimer(label: string): void;
4337
+ /**
4338
+ * End a timer and calculate duration
4339
+ * If label is 'execution', stores duration for metrics summary
4340
+ */
4341
+ endTimer(label: string): number | null;
4342
+ /**
4343
+ * Build execution metrics summary with optional ROI calculation
4344
+ */
4345
+ buildExecutionMetrics(metricsConfig?: ResourceMetricsConfig): ExecutionMetricsSummary;
4346
+ }
4347
+
4348
+ interface BaseAICall {
4349
+ callSequence: number;
4350
+ callType: 'agent-reasoning' | 'agent-completion' | 'workflow-step' | 'tool' | 'other';
4351
+ model: LLMModel;
4352
+ inputTokens: number;
4353
+ outputTokens: number;
4354
+ costUsd: number;
4355
+ latencyMs: number;
4356
+ context?: AICallContext;
4357
+ }
4358
+ type AICallContext = AgentReasoningContext | AgentCompletionContext | WorkflowStepContext | ToolCallContext | OtherCallContext;
4359
+ interface AgentReasoningContext {
4360
+ type: 'agent-reasoning';
4361
+ iteration: number;
4362
+ actionsPlanned?: string[];
4363
+ sessionId?: string;
4364
+ turnNumber?: number;
4365
+ }
4366
+ interface AgentCompletionContext {
4367
+ type: 'agent-completion';
4368
+ attempt: 1 | 2;
4369
+ validationFailed?: boolean;
4370
+ sessionId?: string;
4371
+ turnNumber?: number;
4372
+ }
4373
+ interface WorkflowStepContext {
4374
+ type: 'workflow-step';
4375
+ stepId: string;
4376
+ stepName?: string;
4377
+ stepSequence?: number;
4378
+ }
4379
+ interface ToolCallContext {
4380
+ type: 'tool';
4381
+ toolName: string;
4382
+ parentIteration?: number;
4383
+ parentStepId?: string;
4384
+ }
4385
+ interface OtherCallContext {
4386
+ type: 'other';
4387
+ description?: string;
4388
+ metadata?: Record<string, unknown>;
4389
+ }
4390
+ type AICallRecord = BaseAICall;
4391
+ /**
4392
+ * Raw LLM usage data returned by adapters
4393
+ * Used as input to AIUsageCollector.record()
4394
+ */
4395
+ interface LLMUsageData {
4396
+ model: LLMModel;
4397
+ inputTokens: number;
4398
+ outputTokens: number;
4399
+ latencyMs: number;
4400
+ /** Actual cost from provider in USD (when available, e.g., OpenRouter) */
4401
+ cost?: number;
4402
+ }
4403
+ interface AIUsageSummary {
4404
+ model: LLMModel;
4405
+ totalInputTokens: number;
4406
+ totalOutputTokens: number;
4407
+ totalTokens: number;
4408
+ totalCostUsd: number;
4409
+ callCount: number;
4410
+ calls: AICallRecord[];
4411
+ }
4412
+ interface ExecutionMetricsSummary {
4413
+ durationMs?: number;
4414
+ automationSavingsUsd?: number;
4415
+ }
4416
+ interface ResourceMetricsConfig {
4417
+ estimatedManualMinutes: number;
4418
+ hourlyLaborRateUsd: number;
4419
+ confidenceLevel?: 'low' | 'medium' | 'high';
4420
+ notes?: string;
4421
+ }
3723
4422
  /**
3724
4423
  * Time range selector for dashboard metrics
3725
4424
  */
@@ -3790,6 +4489,23 @@ interface CostBreakdownMetrics {
3790
4489
  avgCostUsd: number;
3791
4490
  }>;
3792
4491
  }
4492
+ /**
4493
+ * Detailed execution metrics response
4494
+ * Full execution metrics with AI call breakdown
4495
+ */
4496
+ interface ExecutionMetricsDetail {
4497
+ executionId: string;
4498
+ organizationId: string;
4499
+ resourceId: string;
4500
+ totalInputTokens: number;
4501
+ totalOutputTokens: number;
4502
+ totalCostUsd: number;
4503
+ aiCallCount: number;
4504
+ aiCalls: AICallRecord[];
4505
+ durationMs?: number;
4506
+ automationSavingsUsd?: number;
4507
+ createdAt: string;
4508
+ }
3793
4509
  /**
3794
4510
  * Dashboard metrics response
3795
4511
  * Aggregates core observability metrics in a single response
@@ -3964,11 +4680,51 @@ interface CostByModelResponse {
3964
4680
  totalCallCount: number;
3965
4681
  }
3966
4682
 
4683
+ /**
4684
+ * AIUsageCollector
4685
+ * Centralized token tracking that aggregates usage across all LLM calls in an execution
4686
+ */
4687
+ declare class AIUsageCollector {
4688
+ private model;
4689
+ private calls;
4690
+ private callSequence;
4691
+ /**
4692
+ * Record a single AI call with usage metrics
4693
+ *
4694
+ * @param usage - Token usage and latency data from LLM adapter
4695
+ * @param callType - Type discriminator (agent-reasoning, tool, etc.)
4696
+ * @param context - Optional typed context specific to callType
4697
+ */
4698
+ record(usage: LLMUsageData, callType?: BaseAICall['callType'], context?: AICallContext): void;
4699
+ /**
4700
+ * Get aggregated summary of all AI calls
4701
+ */
4702
+ getSummary(): AIUsageSummary;
4703
+ /**
4704
+ * Check if any usage has been recorded
4705
+ */
4706
+ hasUsage(): boolean;
4707
+ }
4708
+
3967
4709
  /**
3968
4710
  * Base Execution Engine type definitions
3969
4711
  * Core types shared across all Execution Engine resources
3970
4712
  */
3971
4713
 
4714
+ /**
4715
+ * Immutable execution metadata
4716
+ * Represents complete execution identity (who, what, when, where)
4717
+ * Shared across ExecutionContext and ExecutionLoggerContext to eliminate field duplication
4718
+ */
4719
+ interface ExecutionMetadata {
4720
+ executionId: string;
4721
+ organizationId: string;
4722
+ organizationName: string;
4723
+ resourceId: string;
4724
+ userId?: string;
4725
+ sessionId?: string;
4726
+ sessionTurnNumber?: number;
4727
+ }
3972
4728
  /**
3973
4729
  * Unified message event type - covers all message types in sessions
3974
4730
  * Replaces separate SessionTurnMessages and AgentActivityEvent mechanisms
@@ -4016,6 +4772,27 @@ type MessageEvent = {
4016
4772
  result?: unknown;
4017
4773
  error?: string;
4018
4774
  };
4775
+ /**
4776
+ * Execution context for all resources
4777
+ * Unified callback replaces SessionTurnMessages (removed)
4778
+ */
4779
+ interface ExecutionContext extends ExecutionMetadata {
4780
+ logger: IExecutionLogger;
4781
+ signal?: AbortSignal;
4782
+ onMessageEvent?: (event: MessageEvent) => Promise<void>;
4783
+ /** Called per iteration to write heartbeat + check stall status. Non-fatal if it throws. */
4784
+ onHeartbeat?: () => Promise<void>;
4785
+ aiUsageCollector?: AIUsageCollector;
4786
+ metricsCollector?: MetricsCollector;
4787
+ parentExecutionId?: string;
4788
+ executionDepth: number;
4789
+ credentialName?: string;
4790
+ store: Map<string, unknown>;
4791
+ }
4792
+ interface Contract {
4793
+ inputSchema: z.ZodSchema;
4794
+ outputSchema?: z.ZodSchema;
4795
+ }
4019
4796
  /**
4020
4797
  * NOTE: AIResource interface has been removed and replaced with ResourceDefinition
4021
4798
  * from registry/types.ts. All resources (executable and non-executable) now extend
@@ -4026,6 +4803,45 @@ type MessageEvent = {
4026
4803
  */
4027
4804
  type AIResourceDefinition = SerializedWorkflowDefinition | SerializedAgentDefinition;
4028
4805
 
4806
+ /**
4807
+ * Tool definitions
4808
+ *
4809
+ * Tool interface used by agents and workflows.
4810
+ * Provides a universal interface for AI systems to interact with tools.
4811
+ */
4812
+
4813
+ /**
4814
+ * Options for tool execution
4815
+ * Provides named parameters for better API clarity and extensibility
4816
+ */
4817
+ interface ToolExecutionOptions {
4818
+ /** Tool input (validated against inputSchema before execution) */
4819
+ input: unknown;
4820
+ /** Execution context with multi-tenant isolation and observability (optional for simple tools, required for platform/integration tools) */
4821
+ executionContext?: ExecutionContext;
4822
+ /** Full iteration context for advanced tools (provides access to memoryManager, toolRegistry, logger, etc.) */
4823
+ iterationContext?: IterationContext;
4824
+ /** Abort signal for timeout/cancellation -- forward to fetch() calls for clean cancellation */
4825
+ signal?: AbortSignal;
4826
+ }
4827
+ /**
4828
+ * Tool interface for AI systems
4829
+ *
4830
+ * Used by:
4831
+ * - Agents: For agentic tool use (reasoning loop selects and executes tools)
4832
+ * - Workflows: For workflow step tool invocation (future)
4833
+ * - Platform tools: createApprovalTool(), createSchedulerTool()
4834
+ * - Integration tools: External API calls (Gmail, Slack, etc.)
4835
+ */
4836
+ interface Tool {
4837
+ name: string;
4838
+ description: string;
4839
+ inputSchema: z.ZodSchema;
4840
+ outputSchema: z.ZodSchema;
4841
+ execute: (options: ToolExecutionOptions) => Promise<unknown>;
4842
+ timeout?: number;
4843
+ }
4844
+
4029
4845
  /**
4030
4846
  * Supported integration types
4031
4847
  *
@@ -4434,6 +5250,99 @@ interface Activity {
4434
5250
  createdAt: Date;
4435
5251
  }
4436
5252
 
5253
+ /**
5254
+ * Calibration SSE Event Types
5255
+ *
5256
+ * Shared event type definitions for calibration real-time streaming.
5257
+ * Used by both the API broadcaster and the command-center UI.
5258
+ */
5259
+ interface CalibrationExecutionStartedEvent {
5260
+ type: 'execution-started';
5261
+ variantName: string;
5262
+ inputIndex: number;
5263
+ timestamp: number;
5264
+ }
5265
+ interface CalibrationExecutionCompletedEvent {
5266
+ type: 'execution-completed';
5267
+ variantName: string;
5268
+ inputIndex: number;
5269
+ executionId: string;
5270
+ timestamp: number;
5271
+ }
5272
+ interface CalibrationExecutionFailedEvent {
5273
+ type: 'execution-failed';
5274
+ variantName: string;
5275
+ inputIndex?: number;
5276
+ error: string;
5277
+ timestamp: number;
5278
+ }
5279
+ interface CalibrationSessionStartedEvent {
5280
+ type: 'session-started';
5281
+ variantName: string;
5282
+ sessionId: string;
5283
+ timestamp: number;
5284
+ }
5285
+ interface CalibrationTurnStartedEvent {
5286
+ type: 'turn-started';
5287
+ variantName: string;
5288
+ turnNumber: number;
5289
+ timestamp: number;
5290
+ }
5291
+ interface CalibrationTurnCompletedEvent {
5292
+ type: 'turn-completed';
5293
+ variantName: string;
5294
+ turnNumber: number;
5295
+ executionId: string;
5296
+ timestamp: number;
5297
+ }
5298
+ interface CalibrationSessionCompletedEvent {
5299
+ type: 'session-completed';
5300
+ variantName: string;
5301
+ sessionId: string;
5302
+ turnCount: number;
5303
+ timestamp: number;
5304
+ }
5305
+ interface CalibrationGradingStartedEvent {
5306
+ type: 'grading-started';
5307
+ variantName: string;
5308
+ timestamp: number;
5309
+ }
5310
+ interface CalibrationGradingCompletedEvent {
5311
+ type: 'grading-completed';
5312
+ variantName: string;
5313
+ score: number;
5314
+ timestamp: number;
5315
+ }
5316
+ interface CalibrationGradingFailedEvent {
5317
+ type: 'grading-failed';
5318
+ variantName: string;
5319
+ error: string;
5320
+ timestamp: number;
5321
+ }
5322
+ interface CalibrationCompletedEvent {
5323
+ type: 'calibration-completed';
5324
+ summary: {
5325
+ total: number;
5326
+ completed: number;
5327
+ failed: number;
5328
+ };
5329
+ timestamp: number;
5330
+ }
5331
+ interface CalibrationFailedEvent {
5332
+ type: 'calibration-failed';
5333
+ error: string;
5334
+ timestamp: number;
5335
+ }
5336
+ interface CalibrationConnectedEvent {
5337
+ type: 'connected';
5338
+ timestamp: number;
5339
+ data?: undefined;
5340
+ }
5341
+ /**
5342
+ * Union of all calibration SSE events
5343
+ */
5344
+ type CalibrationSSEEvent = CalibrationExecutionStartedEvent | CalibrationExecutionCompletedEvent | CalibrationExecutionFailedEvent | CalibrationSessionStartedEvent | CalibrationTurnStartedEvent | CalibrationTurnCompletedEvent | CalibrationSessionCompletedEvent | CalibrationGradingStartedEvent | CalibrationGradingCompletedEvent | CalibrationGradingFailedEvent | CalibrationCompletedEvent | CalibrationFailedEvent | CalibrationConnectedEvent;
5345
+
4437
5346
  /**
4438
5347
  * Execution history item.
4439
5348
  * Represents a single execution triggered by a schedule.
@@ -4478,6 +5387,154 @@ declare const ExecutionHistoryResponseSchema: z.ZodObject<{
4478
5387
  type ExecutionHistoryItem = z.infer<typeof ExecutionHistoryItemSchema>;
4479
5388
  type ExecutionHistoryResponse = z.infer<typeof ExecutionHistoryResponseSchema>;
4480
5389
 
5390
+ /**
5391
+ * Calibration Lab Type Definitions
5392
+ * Core types for AI model configuration optimization with cost/performance comparison
5393
+ */
5394
+
5395
+ /**
5396
+ * Calibration project - groups related optimization runs
5397
+ * Provides organizational structure for iterative testing
5398
+ */
5399
+ interface CalibrationProject {
5400
+ id: string;
5401
+ organizationId: string;
5402
+ resourceId: string;
5403
+ resourceType: 'agent' | 'workflow';
5404
+ name: string;
5405
+ description?: string | null;
5406
+ createdAt: Date;
5407
+ updatedAt: Date;
5408
+ }
5409
+ /**
5410
+ * Configuration variant for testing
5411
+ * Defines what to override in the base agent/workflow definition
5412
+ */
5413
+ interface ConfigVariant {
5414
+ variantName: string;
5415
+ definitionOverrides?: AgentCalibrationOverrides | WorkflowCalibrationOverrides;
5416
+ }
5417
+ /**
5418
+ * Agent definition overrides for calibration
5419
+ * Excludes identity/metadata fields that should not be modified
5420
+ */
5421
+ type AgentCalibrationOverrides = Omit<Partial<AgentDefinition>, 'config' | 'contract' | 'tools' | 'metricsConfig' | 'interface'>;
5422
+ /**
5423
+ * Workflow definition overrides for calibration
5424
+ * Excludes identity/metadata fields that should not be modified
5425
+ */
5426
+ type WorkflowCalibrationOverrides = Omit<Partial<WorkflowDefinition>, 'config' | 'contract' | 'steps' | 'entryPoint' | 'metricsConfig' | 'interface'>;
5427
+ /**
5428
+ * Grading rubric for LLM-as-judge evaluation
5429
+ * Defines criteria and passing threshold
5430
+ */
5431
+ interface GradingRubric {
5432
+ passingThreshold: number;
5433
+ criteria: GradingCriterion[];
5434
+ }
5435
+ /**
5436
+ * Individual grading criterion
5437
+ * Weight should be 0-1, and all weights should sum to 1
5438
+ */
5439
+ interface GradingCriterion {
5440
+ name: string;
5441
+ weight: number;
5442
+ description: string;
5443
+ scoringGuide: string;
5444
+ }
5445
+ /**
5446
+ * Grading result for a single execution or session
5447
+ * Contains overall score and per-criterion breakdown
5448
+ */
5449
+ interface GradeResult {
5450
+ score: number;
5451
+ passed: boolean;
5452
+ details: Record<string, {
5453
+ score: number;
5454
+ justification: string;
5455
+ }>;
5456
+ }
5457
+ /**
5458
+ * Single-turn calibration result
5459
+ * One result per (variant × input) combination
5460
+ */
5461
+ interface SingleCalibrationResult {
5462
+ executionId: string;
5463
+ variantName: string;
5464
+ inputIndex: number;
5465
+ appliedOverrides?: AgentCalibrationOverrides | WorkflowCalibrationOverrides;
5466
+ status: 'pending' | 'running' | 'completed' | 'failed';
5467
+ errorMessage?: string;
5468
+ grade?: GradeResult;
5469
+ gradeError?: string;
5470
+ }
5471
+ /**
5472
+ * Multi-turn session calibration result
5473
+ * Leverages existing sessions infrastructure
5474
+ */
5475
+ interface SessionCalibrationResult {
5476
+ sessionId: string;
5477
+ variantName: string;
5478
+ appliedOverrides?: AgentCalibrationOverrides | WorkflowCalibrationOverrides;
5479
+ status: 'pending' | 'running' | 'completed' | 'failed';
5480
+ errorMessage?: string;
5481
+ turnCount: number;
5482
+ grade?: GradeResult;
5483
+ gradeError?: string;
5484
+ }
5485
+ /**
5486
+ * Calibration run - individual test execution within a project
5487
+ * Contains configuration, results, and grading information
5488
+ */
5489
+ interface CalibrationRun {
5490
+ id: string;
5491
+ organizationId: string;
5492
+ projectId: string;
5493
+ name: string;
5494
+ description?: string | null;
5495
+ executionMode: 'single' | 'session';
5496
+ testInputs: unknown[];
5497
+ configVariants: ConfigVariant[];
5498
+ gradingRubric?: GradingRubric | null;
5499
+ graderModel?: string | null;
5500
+ results: (SingleCalibrationResult | SessionCalibrationResult)[];
5501
+ status: 'pending' | 'running' | 'completed' | 'partial' | 'failed';
5502
+ createdAt: Date;
5503
+ completedAt?: Date | null;
5504
+ }
5505
+ /**
5506
+ * Execution log subset for comparison view
5507
+ * Contains essential data without full execution context
5508
+ */
5509
+ interface ExecutionLog {
5510
+ executionId: string;
5511
+ status: 'running' | 'completed' | 'failed';
5512
+ input: unknown;
5513
+ output: unknown | null;
5514
+ error: CalibrationExecutionError | null;
5515
+ startedAt: string;
5516
+ completedAt: string | null;
5517
+ }
5518
+ /**
5519
+ * Execution error information for calibration display
5520
+ * Subset of full execution error for UI display purposes
5521
+ * Named differently from ExecutionError class to avoid type conflicts
5522
+ */
5523
+ interface CalibrationExecutionError {
5524
+ message: string;
5525
+ category?: string;
5526
+ type?: string;
5527
+ }
5528
+ /**
5529
+ * Combined calibration run data for comparison view
5530
+ * Single API call returns run + execution logs + metrics
5531
+ */
5532
+ interface CalibrationRunWithFullData {
5533
+ run: CalibrationRun;
5534
+ logs: Record<string, ExecutionLog>;
5535
+ metrics: Record<string, ExecutionMetricsDetail>;
5536
+ }
5537
+
4481
5538
  /**
4482
5539
  * Deployment types — browser-safe
4483
5540
  *
@@ -5993,6 +7050,110 @@ interface UseResourceExecutionsOptions {
5993
7050
  */
5994
7051
  declare function useResourceExecutions({ resourceId, timeRange, enabled }: UseResourceExecutionsOptions): _tanstack_react_query.UseQueryResult<ResourceExecutionsResponse, Error>;
5995
7052
 
7053
+ /**
7054
+ * Query key factory for calibration hooks.
7055
+ * Ensures consistent, organization-scoped cache isolation.
7056
+ */
7057
+ declare const calibrationKeys: {
7058
+ all: readonly ["calibration"];
7059
+ projects: (org: string) => readonly ["calibration", "projects", string];
7060
+ projectsByResource: (org: string, resourceId: string, resourceType: string) => readonly ["calibration", "projects", string, string, string];
7061
+ project: (org: string, projectId: string) => readonly ["calibration", "project", string, string];
7062
+ runs: (org: string, projectId: string) => readonly ["calibration", "runs", string, string];
7063
+ run: (org: string, runId: string) => readonly ["calibration", "run", string, string];
7064
+ runFull: (org: string, runId: string) => readonly ["calibration", "run-full", string, string];
7065
+ };
7066
+
7067
+ /**
7068
+ * Fetch all calibration projects for the organization (unified view)
7069
+ */
7070
+ declare function useAllCalibrationProjects(): _tanstack_react_query.UseQueryResult<CalibrationProject[], Error>;
7071
+ /**
7072
+ * Fetch calibration projects for a specific resource
7073
+ */
7074
+ declare function useCalibrationProjects(resourceId: string, resourceType: 'agent' | 'workflow'): _tanstack_react_query.UseQueryResult<CalibrationProject[], Error>;
7075
+ declare function useCalibrationProject(projectId: string): _tanstack_react_query.UseQueryResult<CalibrationProject, Error>;
7076
+ declare function useCreateProject(): _tanstack_react_query.UseMutationResult<CalibrationProject, Error, {
7077
+ resourceId: string;
7078
+ resourceType: "agent" | "workflow";
7079
+ name: string;
7080
+ description?: string | undefined;
7081
+ }, unknown>;
7082
+ declare function useUpdateProject(): _tanstack_react_query.UseMutationResult<CalibrationProject, Error, {
7083
+ name?: string | undefined;
7084
+ description?: string | undefined;
7085
+ } & {
7086
+ id: string;
7087
+ }, unknown>;
7088
+ declare function useDeleteProject(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
7089
+
7090
+ declare function useCalibrationRuns(projectId: string): _tanstack_react_query.UseQueryResult<CalibrationRun[], Error>;
7091
+ declare function useCalibrationRun(runId: string): _tanstack_react_query.UseQueryResult<CalibrationRun, Error>;
7092
+ declare function useCreateRun(): _tanstack_react_query.UseMutationResult<CalibrationRun, Error, {
7093
+ projectId: string;
7094
+ name: string;
7095
+ executionMode: "single" | "session";
7096
+ testInputs: unknown[];
7097
+ configVariants: {
7098
+ variantName: string;
7099
+ definitionOverrides?: Record<string, unknown> | undefined;
7100
+ }[];
7101
+ description?: string | undefined;
7102
+ gradingRubric?: {
7103
+ passingThreshold: number;
7104
+ criteria: {
7105
+ name: string;
7106
+ weight: number;
7107
+ description: string;
7108
+ scoringGuide: string;
7109
+ }[];
7110
+ } | undefined;
7111
+ graderModel?: "gpt-5" | "gpt-5.4-mini" | "gpt-5.4-nano" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite-preview" | "openrouter/z-ai/glm-5" | "mock" | undefined;
7112
+ }, unknown>;
7113
+ declare function useExecuteRun(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
7114
+ declare function useDeleteRun(): _tanstack_react_query.UseMutationResult<void, Error, {
7115
+ runId: string;
7116
+ projectId: string;
7117
+ }, unknown>;
7118
+ declare function useGradeRun(): _tanstack_react_query.UseMutationResult<void, Error, {
7119
+ runId: string;
7120
+ rubric?: unknown;
7121
+ graderModel?: string;
7122
+ }, unknown>;
7123
+
7124
+ declare function useCalibrationRunFull(runId: string): _tanstack_react_query.UseQueryResult<CalibrationRunWithFullData, Error>;
7125
+
7126
+ interface CalibrationProgress {
7127
+ connected: boolean;
7128
+ events: CalibrationSSEEvent[];
7129
+ summary?: {
7130
+ total: number;
7131
+ completed: number;
7132
+ failed: number;
7133
+ };
7134
+ isComplete: boolean;
7135
+ error?: string;
7136
+ }
7137
+ interface UseCalibrationSSEOptions {
7138
+ runId: string;
7139
+ manager: SSEConnectionManager;
7140
+ apiUrl: string;
7141
+ enabled?: boolean;
7142
+ }
7143
+ declare function useCalibrationSSE({ runId, manager, apiUrl, enabled }: UseCalibrationSSEOptions): {
7144
+ disconnect: () => void;
7145
+ reset: () => void;
7146
+ connected: boolean;
7147
+ events: CalibrationSSEEvent[];
7148
+ summary?: {
7149
+ total: number;
7150
+ completed: number;
7151
+ failed: number;
7152
+ };
7153
+ isComplete: boolean;
7154
+ error?: string;
7155
+ };
7156
+
5996
7157
  /**
5997
7158
  * Hook to fetch sessions list with optional filtering.
5998
7159
  */
@@ -6052,5 +7213,5 @@ declare function useSessionWebSocket(sessionId: string, apiUrl: string): {
6052
7213
  lastTokenUsage: SessionTokenUsage | null;
6053
7214
  };
6054
7215
 
6055
- export { OperationsService, REFETCH_INTERVAL_RUNNING, WS_MAX_RETRIES_BEFORE_ERROR, WS_RECONNECT_BASE_DELAY, WS_RECONNECT_MAX_DELAY, createUseFeatureAccess, executionsKeys, isSessionCapable, observabilityKeys, operationsKeys, scheduleKeys, sessionsKeys, sortData, useActivities, useActivityTrend, useArchiveSession, useArchivedLogs, useBatchDelete, useBatchedResourcesHealth, useBulkDeleteExecutions, useBusinessImpact, useCancelExecution, useCancelSchedule, useCheckpointTasks, useCommandQueue, useCommandQueueTotals, useCommandViewData, useCommandViewLayout, useCommandViewStats, useCommandViewStore, useCostBreakdown, useCostByModel, useCostSummary, useCostTrends, useCreateSchedule, useCreateSession, useDashboardMetrics, useDeleteExecution, useDeleteSchedule, useDeleteSession, useDeleteTask, useDeploymentDocs, useErrorAnalysis, useErrorDetail, useErrorDetails, useErrorDistribution, useErrorNotification, useErrorTrends, useExecuteAsync, useExecution, useExecutionHealth, useExecutionLogSSE, useExecutionLogs, useExecutionPanelState, useExecutions, useGetExecutionHistory, useGetSchedule, useGraphStats, useListSchedules, useMarkAllAsRead, useMarkAsRead, useNotificationCount as useNotificationCountSSE, useNotifications, usePaginationState, usePatchTask, usePauseSchedule, useRecentExecutionsByResource, useResolveAllErrors, useResolveError, useResolveErrorsByExecution, useResourceDefinition, useResourceErrors, useResourceExecutions, useResources, useResourcesHealth, useResumeSchedule, useRetryExecution, useSSEConnection, useScheduledTasks, useSession, useSessionExecution, useSessionExecutions, useSessionMessages, useSessionWebSocket, useSessions, useSortedData, useSubmitAction, useSuccessNotification, useTableSelection, useTableSort, useTestNotification, useTopFailingResources, useUnresolveError, useUnresolvedErrors, useUpdateAnchor, useUpdateSchedule, useWarningNotification };
6056
- export type { ActivityTrendResponse, BulkDeleteExecutionsParams, BulkDeleteExecutionsResult, BusinessImpactMetrics, CancelExecutionParams, CancelExecutionResult, ChatMessage, CostBreakdownItem, CreateScheduleInput, CreateSessionResponse, DeleteExecutionParams, DocFile, ErrorDistributionItem, ErrorDistributionParams, ErrorFilters, ErrorTrendsParams, ExecuteAsyncParams, ExecuteAsyncResult, ExecutionErrorDetails, ExecutionHistoryItem, ExecutionHistoryResponse, ExecutionLogsPageResponse, FailingResource, GetMessagesResponse, ListActivitiesResponse, ListSchedulesFilters, ListSchedulesResponse, MessageEvent, MessageType, ResourcesResponse, RetryExecutionParams, SessionDTO, SessionExecution, SessionExecutionsResponse, SessionListItem, SessionTokenUsage, SortDirection, SortState, SubmitActionRequest, SubmitActionResponse, TaskSchedule, TopFailingResourcesParams, UpdateScheduleInput, UseActivitiesParams, UseActivityTrendParams, UseBatchedResourcesHealthParams, UseExecutionHealthParams, UseExecutionLogsParams, UseExecutionPanelStateOptions, UseExecutionPanelStateReturn, UseNotificationCountArgs, UseResourcesHealthParams, UseSSEConnectionOptions, UseScheduledTasksOptions, WebSocketState };
7216
+ export { OperationsService, REFETCH_INTERVAL_RUNNING, WS_MAX_RETRIES_BEFORE_ERROR, WS_RECONNECT_BASE_DELAY, WS_RECONNECT_MAX_DELAY, calibrationKeys, createUseFeatureAccess, executionsKeys, isSessionCapable, observabilityKeys, operationsKeys, scheduleKeys, sessionsKeys, sortData, useActivities, useActivityTrend, useAllCalibrationProjects, useArchiveSession, useArchivedLogs, useBatchDelete, useBatchedResourcesHealth, useBulkDeleteExecutions, useBusinessImpact, useCalibrationProject, useCalibrationProjects, useCalibrationRun, useCalibrationRunFull, useCalibrationRuns, useCalibrationSSE, useCancelExecution, useCancelSchedule, useCheckpointTasks, useCommandQueue, useCommandQueueTotals, useCommandViewData, useCommandViewLayout, useCommandViewStats, useCommandViewStore, useCostBreakdown, useCostByModel, useCostSummary, useCostTrends, useCreateProject, useCreateRun, useCreateSchedule, useCreateSession, useDashboardMetrics, useDeleteExecution, useDeleteProject, useDeleteRun, useDeleteSchedule, useDeleteSession, useDeleteTask, useDeploymentDocs, useErrorAnalysis, useErrorDetail, useErrorDetails, useErrorDistribution, useErrorNotification, useErrorTrends, useExecuteAsync, useExecuteRun, useExecution, useExecutionHealth, useExecutionLogSSE, useExecutionLogs, useExecutionPanelState, useExecutions, useGetExecutionHistory, useGetSchedule, useGradeRun, useGraphStats, useListSchedules, useMarkAllAsRead, useMarkAsRead, useNotificationCount as useNotificationCountSSE, useNotifications, usePaginationState, usePatchTask, usePauseSchedule, useRecentExecutionsByResource, useResolveAllErrors, useResolveError, useResolveErrorsByExecution, useResourceDefinition, useResourceErrors, useResourceExecutions, useResources, useResourcesHealth, useResumeSchedule, useRetryExecution, useSSEConnection, useScheduledTasks, useSession, useSessionExecution, useSessionExecutions, useSessionMessages, useSessionWebSocket, useSessions, useSortedData, useSubmitAction, useSuccessNotification, useTableSelection, useTableSort, useTestNotification, useTopFailingResources, useUnresolveError, useUnresolvedErrors, useUpdateAnchor, useUpdateProject, useUpdateSchedule, useWarningNotification };
7217
+ export type { ActivityTrendResponse, BulkDeleteExecutionsParams, BulkDeleteExecutionsResult, BusinessImpactMetrics, CalibrationProgress, CancelExecutionParams, CancelExecutionResult, ChatMessage, CostBreakdownItem, CreateScheduleInput, CreateSessionResponse, DeleteExecutionParams, DocFile, ErrorDistributionItem, ErrorDistributionParams, ErrorFilters, ErrorTrendsParams, ExecuteAsyncParams, ExecuteAsyncResult, ExecutionErrorDetails, ExecutionHistoryItem, ExecutionHistoryResponse, ExecutionLogsPageResponse, FailingResource, GetMessagesResponse, ListActivitiesResponse, ListSchedulesFilters, ListSchedulesResponse, MessageEvent, MessageType, ResourcesResponse, RetryExecutionParams, SessionDTO, SessionExecution, SessionExecutionsResponse, SessionListItem, SessionTokenUsage, SortDirection, SortState, SubmitActionRequest, SubmitActionResponse, TaskSchedule, TopFailingResourcesParams, UpdateScheduleInput, UseActivitiesParams, UseActivityTrendParams, UseBatchedResourcesHealthParams, UseCalibrationSSEOptions, UseExecutionHealthParams, UseExecutionLogsParams, UseExecutionPanelStateOptions, UseExecutionPanelStateReturn, UseNotificationCountArgs, UseResourcesHealthParams, UseSSEConnectionOptions, UseScheduledTasksOptions, WebSocketState };