@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,6 +1,6 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
- import * as react from 'react';
3
2
  import { z } from 'zod';
3
+ import * as react from 'react';
4
4
  import * as zustand from 'zustand';
5
5
  import * as zustand_middleware from 'zustand/middleware';
6
6
  import { Edge } from '@xyflow/react';
@@ -194,6 +194,51 @@ interface AgentToolCallEvent$1 {
194
194
  * 3 event types total (lifecycle, iteration, tool-call)
195
195
  */
196
196
  type AgentLogContext$1 = AgentLifecycleEvent$1 | AgentIterationEvent$1 | AgentToolCallEvent$1;
197
+ /**
198
+ * Data for lifecycle 'started' events
199
+ */
200
+ interface AgentLifecycleStartedData {
201
+ startTime: number;
202
+ iteration?: number;
203
+ }
204
+ /**
205
+ * Data for lifecycle 'completed' events
206
+ */
207
+ interface AgentLifecycleCompletedData {
208
+ startTime: number;
209
+ endTime: number;
210
+ duration: number;
211
+ iteration?: number;
212
+ attempts?: number;
213
+ memorySize?: {
214
+ sessionMemoryKeys: number;
215
+ historyEntries: number;
216
+ };
217
+ }
218
+ /**
219
+ * Data for lifecycle 'failed' events
220
+ */
221
+ interface AgentLifecycleFailedData {
222
+ startTime: number;
223
+ endTime: number;
224
+ duration: number;
225
+ error: string;
226
+ iteration?: number;
227
+ }
228
+ /**
229
+ * Scoped logger for agent execution
230
+ * Captures logger and agentId to eliminate repetitive parameter passing
231
+ *
232
+ * Type-safe lifecycle logging with stage-specific required fields
233
+ */
234
+ interface AgentScopedLogger {
235
+ lifecycle(lifecycle: AgentLifecycle$1, stage: 'started', data: AgentLifecycleStartedData): void;
236
+ lifecycle(lifecycle: AgentLifecycle$1, stage: 'completed', data: AgentLifecycleCompletedData): void;
237
+ lifecycle(lifecycle: AgentLifecycle$1, stage: 'failed', data: AgentLifecycleFailedData): void;
238
+ reasoning(output: string, iteration: number, startTime: number, endTime: number, duration: number): void;
239
+ action(actionType: string, message: string, iteration: number, startTime: number, endTime: number, duration: number): void;
240
+ toolCall(toolName: string, iteration: number, startTime: number, endTime: number, duration: number, success: boolean, error?: string, input?: unknown, output?: unknown): void;
241
+ }
197
242
 
198
243
  /**
199
244
  * Base execution logger for Execution Engine
@@ -207,6 +252,12 @@ interface ExecutionLogMessage$1 {
207
252
  timestamp: number;
208
253
  context?: LogContext$1;
209
254
  }
255
+ interface IExecutionLogger {
256
+ debug(message: string, context?: LogContext$1): void;
257
+ info(message: string, context?: LogContext$1): void;
258
+ warn(message: string, context?: LogContext$1): void;
259
+ error(message: string, context?: LogContext$1): void;
260
+ }
210
261
 
211
262
  /**
212
263
  * Shared form field types for dynamic form generation
@@ -488,6 +539,262 @@ interface SerializedWorkflowDefinition {
488
539
  interface?: SerializedExecutionInterface;
489
540
  }
490
541
 
542
+ /**
543
+ * Model Configuration
544
+ * Centralized model information, configuration, options, constraints, and validation
545
+ * Single source of truth for all model-related definitions
546
+ * Update manually when pricing changes or new models are added
547
+ */
548
+
549
+ /**
550
+ * Supported Open AI models (direct SDK access)
551
+ */
552
+ type OpenAIModel = 'gpt-5' | 'gpt-5.4-mini' | 'gpt-5.4-nano';
553
+ /**
554
+ * Supported OpenRouter models (explicit union for type safety)
555
+ */
556
+ type OpenRouterModel = 'openrouter/z-ai/glm-5';
557
+ /**
558
+ * Supported Google models (direct SDK access)
559
+ */
560
+ type GoogleModel = 'gemini-3-flash-preview' | 'gemini-3.1-flash-lite-preview';
561
+ /**
562
+ * Supported Anthropic models (direct SDK access via @anthropic-ai/sdk)
563
+ */
564
+ type AnthropicModel = 'claude-sonnet-4-5';
565
+ /** Supported LLM models */
566
+ type LLMModel = OpenAIModel | OpenRouterModel | GoogleModel | AnthropicModel | 'mock';
567
+ /**
568
+ * GPT-5 model options schema
569
+ */
570
+ declare const GPT5OptionsSchema: z.ZodObject<{
571
+ reasoning_effort: z.ZodOptional<z.ZodEnum<{
572
+ minimal: "minimal";
573
+ low: "low";
574
+ medium: "medium";
575
+ high: "high";
576
+ }>>;
577
+ verbosity: z.ZodOptional<z.ZodEnum<{
578
+ low: "low";
579
+ medium: "medium";
580
+ high: "high";
581
+ }>>;
582
+ }, z.core.$strip>;
583
+ /**
584
+ * OpenRouter model options schema
585
+ * OpenRouter-specific options for routing and transforms
586
+ */
587
+ declare const OpenRouterOptionsSchema: z.ZodObject<{
588
+ transforms: z.ZodOptional<z.ZodArray<z.ZodString>>;
589
+ route: z.ZodOptional<z.ZodEnum<{
590
+ fallback: "fallback";
591
+ }>>;
592
+ }, z.core.$strip>;
593
+ /**
594
+ * Google model options schema
595
+ * Gemini 3 specific options for thinking depth control
596
+ */
597
+ declare const GoogleOptionsSchema: z.ZodObject<{
598
+ thinkingLevel: z.ZodOptional<z.ZodEnum<{
599
+ minimal: "minimal";
600
+ low: "low";
601
+ medium: "medium";
602
+ high: "high";
603
+ }>>;
604
+ }, z.core.$strip>;
605
+ /**
606
+ * Anthropic model options schema
607
+ * Currently empty - future options: budget_tokens for extended thinking
608
+ */
609
+ declare const AnthropicOptionsSchema: z.ZodObject<{}, z.core.$strip>;
610
+ /**
611
+ * Infer TypeScript types from schemas
612
+ */
613
+ type GPT5Options = z.infer<typeof GPT5OptionsSchema>;
614
+ type MockOptions = Record<string, never>;
615
+ type OpenRouterOptions = z.infer<typeof OpenRouterOptionsSchema>;
616
+ type GoogleOptions = z.infer<typeof GoogleOptionsSchema>;
617
+ type AnthropicOptions = z.infer<typeof AnthropicOptionsSchema>;
618
+ type ModelSpecificOptions = GPT5Options | MockOptions | OpenRouterOptions | GoogleOptions | AnthropicOptions;
619
+ /**
620
+ * Model configuration for LLM execution
621
+ * Belongs in resource definition (AgentDefinition, WorkflowDefinition, etc.)
622
+ */
623
+ interface ModelConfig {
624
+ model: LLMModel;
625
+ provider: 'openai' | 'anthropic' | 'openrouter' | 'google' | 'mock';
626
+ apiKey: string;
627
+ temperature?: number;
628
+ /** Maximum output tokens per LLM call. NOT the model's context window — see ModelInfo.maxTokens for that. */
629
+ maxOutputTokens?: number;
630
+ topP?: number;
631
+ /**
632
+ * Model-specific options (flat structure)
633
+ * Options are model-specific, not vendor-specific
634
+ * Available options defined in MODEL_INFO per model
635
+ * Validated at build time via validateModelOptions()
636
+ */
637
+ modelOptions?: ModelSpecificOptions;
638
+ }
639
+
640
+ /**
641
+ * Execution interface configuration
642
+ * Defines how a resource is executed via the UI (forms, scheduling, webhooks)
643
+ * Applies to both agents and workflows
644
+ */
645
+ interface ExecutionInterface {
646
+ /** Form configuration for execution inputs */
647
+ form: ExecutionFormSchema;
648
+ /** Optional: Schedule configuration */
649
+ schedule?: ScheduleConfig;
650
+ /** Optional: Webhook trigger configuration */
651
+ webhook?: WebhookConfig;
652
+ }
653
+ /**
654
+ * Execution form schema
655
+ * Extends FormSchema with execution-specific fields
656
+ */
657
+ interface ExecutionFormSchema extends FormSchema {
658
+ /**
659
+ * Field mappings to resource input schema
660
+ * Maps form field names to contract input paths
661
+ * If omitted, field names must match contract input keys exactly
662
+ */
663
+ fieldMappings?: Record<string, string>;
664
+ /**
665
+ * Submit button configuration
666
+ * Default: { label: 'Run', loadingLabel: 'Running...' }
667
+ */
668
+ submitButton?: {
669
+ label?: string;
670
+ loadingLabel?: string;
671
+ confirmMessage?: string;
672
+ };
673
+ }
674
+ /**
675
+ * Schedule configuration for automated execution
676
+ */
677
+ interface ScheduleConfig {
678
+ /** Whether scheduling is enabled for this resource */
679
+ enabled: boolean;
680
+ /** Default schedule (cron expression) */
681
+ defaultSchedule?: string;
682
+ /** Allowed schedule patterns (if restricted) */
683
+ allowedPatterns?: string[];
684
+ }
685
+ /**
686
+ * Webhook configuration for external triggers
687
+ */
688
+ interface WebhookConfig {
689
+ /** Whether webhook trigger is enabled */
690
+ enabled: boolean;
691
+ /** Expected payload schema (for documentation) */
692
+ payloadSchema?: unknown;
693
+ }
694
+
695
+ interface WorkflowConfig extends ResourceDefinition {
696
+ type: 'workflow';
697
+ }
698
+ interface WorkflowStepDefinition {
699
+ id: string;
700
+ name: string;
701
+ description: string;
702
+ }
703
+ type StepHandler = (input: unknown, context: ExecutionContext) => Promise<unknown>;
704
+ interface LinearNext {
705
+ type: 'linear';
706
+ target: string;
707
+ }
708
+ interface ConditionalNext {
709
+ type: 'conditional';
710
+ routes: Array<{
711
+ condition: (data: unknown) => boolean;
712
+ target: string;
713
+ }>;
714
+ default: string;
715
+ }
716
+ type NextConfig = LinearNext | ConditionalNext | null;
717
+ interface WorkflowStep extends WorkflowStepDefinition {
718
+ handler: StepHandler;
719
+ inputSchema: z.ZodSchema;
720
+ outputSchema: z.ZodSchema;
721
+ next: NextConfig;
722
+ }
723
+ interface WorkflowDefinition {
724
+ config: WorkflowConfig;
725
+ contract: Contract;
726
+ steps: Record<string, WorkflowStep>;
727
+ entryPoint: string;
728
+ /**
729
+ * Metrics configuration for ROI calculations
730
+ * Optional: Only needed if tracking automation savings
731
+ */
732
+ metricsConfig?: ResourceMetricsConfig;
733
+ /**
734
+ * Execution interface configuration (optional)
735
+ * If provided, workflow appears in Execution Runner UI
736
+ */
737
+ interface?: ExecutionInterface;
738
+ }
739
+
740
+ /**
741
+ * Generic LLM Types
742
+ * Universal interfaces for LLM interaction across all resource types
743
+ */
744
+ /**
745
+ * Standard chat message format
746
+ * Compatible with OpenAI, Anthropic, and other providers
747
+ */
748
+ interface LLMMessage {
749
+ role: 'system' | 'user' | 'assistant';
750
+ content: string;
751
+ }
752
+ /**
753
+ * Generic LLM generation request
754
+ * Usable by agents, workflows, tools, etc.
755
+ */
756
+ interface LLMGenerateRequest {
757
+ messages: LLMMessage[];
758
+ responseSchema: unknown;
759
+ /** Maximum output tokens per LLM call. NOT the model's context window — see ModelInfo.maxTokens for that. */
760
+ maxOutputTokens?: number;
761
+ temperature?: number;
762
+ topP?: number;
763
+ signal?: AbortSignal;
764
+ }
765
+ /**
766
+ * Generic LLM generation response
767
+ * Usage field is internal-only (stripped by UniversalLLMAdapter wrapper)
768
+ */
769
+ interface LLMGenerateResponse<T = unknown> {
770
+ output: T;
771
+ usage?: {
772
+ inputTokens: number;
773
+ outputTokens: number;
774
+ totalTokens: number;
775
+ };
776
+ cost?: number;
777
+ }
778
+ /**
779
+ * LLM Adapter interface
780
+ * Generic primitive for all resource types (agents, workflows, tools)
781
+ *
782
+ * Design principles:
783
+ * - Single method: generate() - the core LLM primitive
784
+ * - Generic return type for type safety
785
+ * - Universal format (not agent-specific)
786
+ * - Standard message-based input (OpenAI-compatible)
787
+ */
788
+ interface LLMAdapter {
789
+ /**
790
+ * Generate structured output from prompt using LLM
791
+ *
792
+ * @param request - Generation request with messages and response schema
793
+ * @returns Generated output (typed) with optional usage metadata
794
+ */
795
+ generate<T = unknown>(request: LLMGenerateRequest): Promise<LLMGenerateResponse<T>>;
796
+ }
797
+
491
798
  /**
492
799
  * Memory type definitions
493
800
  * Types for agent memory management with semantic entry types
@@ -528,6 +835,302 @@ interface AgentMemory {
528
835
  */
529
836
  history: MemoryEntry[];
530
837
  }
838
+ /**
839
+ * Memory status for agent awareness
840
+ */
841
+ interface MemoryStatus {
842
+ sessionMemoryKeys: number;
843
+ sessionMemoryLimit: number;
844
+ currentKeys: string[];
845
+ historyPercent: number;
846
+ historyTokens: number;
847
+ tokenBudget: number;
848
+ }
849
+ /**
850
+ * Memory constraints (optional limits)
851
+ */
852
+ interface MemoryConstraints {
853
+ maxSessionMemoryKeys?: number;
854
+ maxMemoryTokens?: number;
855
+ }
856
+
857
+ /**
858
+ * Memory Manager
859
+ * Encapsulates all memory operations with ultra-simple agent API
860
+ * Agent provides strings, framework handles wrapping and auto-compaction
861
+ */
862
+
863
+ /**
864
+ * Memory Manager - Agent memory orchestration
865
+ * Provides ultra-simple API for agents (strings only)
866
+ * Handles automatic compaction and token management
867
+ */
868
+ declare class MemoryManager {
869
+ private memory;
870
+ private constraints;
871
+ private logger?;
872
+ private cachedSnapshot?;
873
+ constructor(memory: AgentMemory, constraints?: MemoryConstraints, logger?: AgentScopedLogger | undefined);
874
+ /**
875
+ * Set session memory entry (agent provides string, framework wraps it)
876
+ * @param key - Session memory key
877
+ * @param content - String content from agent
878
+ */
879
+ set(key: string, content: string): void;
880
+ /**
881
+ * Get session memory entry content
882
+ * @param key - Session memory key
883
+ * @returns String content if exists, undefined otherwise
884
+ */
885
+ get(key: string): string | undefined;
886
+ /**
887
+ * Delete session memory entry
888
+ * @param key - Key to delete
889
+ * @returns True if key existed and was deleted
890
+ */
891
+ delete(key: string): boolean;
892
+ /**
893
+ * Add entry to history (called by framework after tool results, reasoning, etc.)
894
+ * Automatically sets timestamp to current time
895
+ * @param entry - Memory entry to add (without timestamp - auto-generated)
896
+ */
897
+ addToHistory(entry: Omit<MemoryEntry, 'timestamp'>): void;
898
+ /**
899
+ * Auto-compact history if approaching token budget
900
+ * Uses preserve-anchors strategy: keep first + recent entries
901
+ */
902
+ autoCompact(): void;
903
+ /**
904
+ * Enforce hard limits (called before LLM request)
905
+ * Emergency fallback if agent exceeds limits
906
+ */
907
+ enforceHardLimits(): void;
908
+ /**
909
+ * Get history length (for logging and introspection)
910
+ * @returns Number of entries in history
911
+ */
912
+ getHistoryLength(): number;
913
+ /**
914
+ * Get memory status for agent awareness
915
+ * @returns Memory status with token usage and key counts
916
+ */
917
+ getStatus(): MemoryStatus;
918
+ /**
919
+ * Create memory snapshot for persistence
920
+ * Caches snapshot internally for later retrieval
921
+ * @returns Deep copy of current memory state
922
+ */
923
+ toSnapshot(): AgentMemory;
924
+ /**
925
+ * Get cached memory snapshot
926
+ * Returns snapshot created by toSnapshot()
927
+ * @returns Cached snapshot (undefined if toSnapshot() not called yet)
928
+ */
929
+ getSnapshot(): AgentMemory | undefined;
930
+ /**
931
+ * Build context string for LLM
932
+ * Serializes sessionmemory + history memory with clear sections
933
+ * Shows current iteration entries FIRST (reverse chronological) for LLM attention
934
+ * @param currentIteration - Current iteration number (0 = pre-iteration)
935
+ * @param currentTurn - Current turn number (optional, for session context filtering)
936
+ * @returns Formatted memory context for LLM prompt
937
+ */
938
+ toContext(currentIteration: number, currentTurn?: number): string;
939
+ }
940
+
941
+ /**
942
+ * Knowledge Map Types
943
+ *
944
+ * Enables agents to navigate organizational knowledge through a lightweight
945
+ * graph that lazy-loads capabilities on-demand.
946
+ *
947
+ * @module agent/knowledge-map
948
+ */
949
+
950
+ /**
951
+ * Lightweight knowledge map (passed as agent property)
952
+ *
953
+ * Contains metadata about available knowledge nodes without loading
954
+ * the full content upfront. Total size: ~300-500 tokens.
955
+ *
956
+ * Multi-tenancy is enforced via:
957
+ * - File-scoped maps (organizations/{org-name}/knowledge/)
958
+ * - ExecutionContext.organizationId passed to node.load()
959
+ */
960
+ interface KnowledgeMap {
961
+ /** Available knowledge nodes indexed by ID */
962
+ nodes: Record<string, KnowledgeNode>;
963
+ }
964
+ /**
965
+ * Single knowledge source
966
+ *
967
+ * Represents a domain knowledge area (CRM, brand guidelines, Excel tools)
968
+ * that can be lazy-loaded to provide instructions and tools to agents.
969
+ */
970
+ interface KnowledgeNode {
971
+ /** Unique identifier for this node (e.g., "crm", "brand-guidelines") */
972
+ id: string;
973
+ /**
974
+ * Description of when to use this knowledge
975
+ * Used for semantic matching against user intent
976
+ */
977
+ description: string;
978
+ /**
979
+ * Load knowledge content on-demand
980
+ *
981
+ * @param context - Execution context with organizationId for multi-tenancy
982
+ * @returns Promise resolving to knowledge content (prompt + optional tools)
983
+ */
984
+ load(context: ExecutionContext): Promise<KnowledgeContent>;
985
+ /**
986
+ * Loaded state flag
987
+ * Set to true after load() is called
988
+ */
989
+ loaded?: boolean;
990
+ /**
991
+ * Cached prompt (for system prompt serialization)
992
+ * Only the prompt is cached - tools go to toolRegistry, children flattened to nodes
993
+ */
994
+ prompt?: string;
995
+ }
996
+ /**
997
+ * Content returned by knowledge node
998
+ *
999
+ * Separates instructions (prompt) from capabilities (tools).
1000
+ * Tools are optional - some nodes only provide context.
1001
+ *
1002
+ * Supports recursive navigation - nodes can contain child nodes
1003
+ * that are discovered when the parent node is loaded.
1004
+ */
1005
+ interface KnowledgeContent {
1006
+ /** Instructions and context (markdown format) */
1007
+ prompt: string;
1008
+ /** Tool implementations (optional) */
1009
+ tools?: Tool[];
1010
+ /**
1011
+ * Child knowledge nodes (optional, recursive)
1012
+ *
1013
+ * Enables hierarchical navigation: base → specialized → deep expertise.
1014
+ * Child nodes are flattened into the main knowledge map when parent loads,
1015
+ * making them available for subsequent navigate-knowledge actions.
1016
+ *
1017
+ * Example: CRM base node returns crm-customers and crm-deals as children
1018
+ */
1019
+ nodes?: Record<string, KnowledgeNode>;
1020
+ }
1021
+
1022
+ /**
1023
+ * Agent-specific type definitions
1024
+ * Types for autonomous agents with tools, memory, and constraints
1025
+ */
1026
+
1027
+ /**
1028
+ * Factory function for creating LLM adapters.
1029
+ * Injected into the Agent class to decouple the engine from server-only provider SDKs.
1030
+ * - API process: provides createLLMAdapter (real SDKs + process.env API keys)
1031
+ * - SDK worker: provides PostMessageLLMAdapter (proxies via platform.call)
1032
+ *
1033
+ * Uses `any` for optional params so both the real createLLMAdapter (with typed
1034
+ * AIUsageCollector/AICallContext) and the worker proxy (which ignores them) satisfy the type.
1035
+ */
1036
+ type LLMAdapterFactory = (config: ModelConfig, ...args: any[]) => LLMAdapter;
1037
+ interface AgentConfig extends ResourceDefinition {
1038
+ type: 'agent';
1039
+ systemPrompt: string;
1040
+ constraints?: AgentConstraints;
1041
+ /**
1042
+ * Session capability declaration (opt-in)
1043
+ * If true, agent is designed for multi-turn session interactions
1044
+ * Controls whether agent can use message action and appears in Sessions UI
1045
+ *
1046
+ * Use for:
1047
+ * - Conversational agents with multi-turn interactions
1048
+ * - Agents requiring persistent context across turns
1049
+ * - Agents that need human-in-the-loop communication
1050
+ */
1051
+ sessionCapable?: boolean;
1052
+ /**
1053
+ * Security level for system prompt hardening (auto-derived if omitted)
1054
+ *
1055
+ * - 'standard': Lightweight defense (3 rules) - default for non-session agents
1056
+ * - 'hardened': Comprehensive defense (6 rules) - default for session-capable agents
1057
+ * - 'none': No security prompt - for pure internal agents with no external input
1058
+ *
1059
+ * If omitted, derived from sessionCapable:
1060
+ * sessionCapable: true -> 'hardened'
1061
+ * sessionCapable: false -> 'standard'
1062
+ */
1063
+ securityLevel?: 'standard' | 'hardened' | 'none';
1064
+ /**
1065
+ * Memory management preferences (opt-in)
1066
+ * If provided, agent can use memoryOps to manage session memory
1067
+ * If omitted, agent has no memory management capabilities
1068
+ *
1069
+ * Agent-specific guidance on what to preserve, when to persist, and what to clean up.
1070
+ * This guidance is injected into the system prompt when memory management is enabled.
1071
+ *
1072
+ * Use for:
1073
+ * - Conversational agents needing cross-turn context
1074
+ * - Agents managing complex user preferences
1075
+ * - Agents tracking decisions over multiple iterations
1076
+ */
1077
+ memoryPreferences?: string;
1078
+ }
1079
+ interface AgentConstraints {
1080
+ maxIterations?: number;
1081
+ timeout?: number;
1082
+ maxSessionMemoryKeys?: number;
1083
+ maxMemoryTokens?: number;
1084
+ }
1085
+ interface AgentDefinition {
1086
+ config: AgentConfig;
1087
+ contract: Contract;
1088
+ tools: Tool[];
1089
+ /**
1090
+ * Model configuration for LLM execution
1091
+ * Specifies provider, API key, and model-specific options
1092
+ */
1093
+ modelConfig: ModelConfig;
1094
+ /**
1095
+ * Optional knowledge map for lazy-loading capabilities
1096
+ * Enables agents to navigate organizational knowledge on-demand
1097
+ */
1098
+ knowledgeMap?: KnowledgeMap;
1099
+ /**
1100
+ * Preload memory before execution starts
1101
+ * Handles BOTH context loading AND session restoration
1102
+ *
1103
+ * @param context - Execution context (includes sessionId if session turn)
1104
+ * @returns Initial AgentMemory state (sessionMemory entries + optionally history)
1105
+ */
1106
+ preloadMemory?: (context: ExecutionContext) => Promise<AgentMemory> | AgentMemory;
1107
+ /**
1108
+ * Metrics configuration for ROI calculations
1109
+ * Optional: Only needed if tracking automation savings
1110
+ */
1111
+ metricsConfig?: ResourceMetricsConfig;
1112
+ /**
1113
+ * Execution interface configuration (optional)
1114
+ * If provided, agent appears in Execution Runner UI
1115
+ */
1116
+ interface?: ExecutionInterface;
1117
+ }
1118
+ /**
1119
+ * Agent execution context
1120
+ * Groups all state needed for agent execution phases
1121
+ */
1122
+ interface IterationContext {
1123
+ config: AgentConfig;
1124
+ contract: Contract;
1125
+ toolRegistry: Map<string, Tool>;
1126
+ memoryManager: MemoryManager;
1127
+ executionContext: ExecutionContext;
1128
+ iteration: number;
1129
+ logger: AgentScopedLogger;
1130
+ modelConfig: ModelConfig;
1131
+ adapterFactory: LLMAdapterFactory;
1132
+ knowledgeMap?: KnowledgeMap;
1133
+ }
531
1134
 
532
1135
  type Json = string | number | boolean | null | {
533
1136
  [key: string]: Json | undefined;
@@ -3234,7 +3837,7 @@ interface MembershipFeatureConfig {
3234
3837
  */
3235
3838
  interface UserConfig {
3236
3839
  theme?: {
3237
- 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';
3840
+ 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';
3238
3841
  colorScheme?: 'light' | 'dark' | 'auto';
3239
3842
  };
3240
3843
  onboarding?: {
@@ -3344,6 +3947,102 @@ interface MembershipWithDetails extends OrganizationMembership {
3344
3947
  config?: MembershipFeatureConfig;
3345
3948
  }
3346
3949
 
3950
+ /**
3951
+ * MetricsCollector
3952
+ * Tracks execution timing and ROI metrics
3953
+ */
3954
+ declare class MetricsCollector {
3955
+ private timings;
3956
+ private durationMs?;
3957
+ /**
3958
+ * Start a timer with a label
3959
+ */
3960
+ startTimer(label: string): void;
3961
+ /**
3962
+ * End a timer and calculate duration
3963
+ * If label is 'execution', stores duration for metrics summary
3964
+ */
3965
+ endTimer(label: string): number | null;
3966
+ /**
3967
+ * Build execution metrics summary with optional ROI calculation
3968
+ */
3969
+ buildExecutionMetrics(metricsConfig?: ResourceMetricsConfig): ExecutionMetricsSummary;
3970
+ }
3971
+
3972
+ interface BaseAICall {
3973
+ callSequence: number;
3974
+ callType: 'agent-reasoning' | 'agent-completion' | 'workflow-step' | 'tool' | 'other';
3975
+ model: LLMModel;
3976
+ inputTokens: number;
3977
+ outputTokens: number;
3978
+ costUsd: number;
3979
+ latencyMs: number;
3980
+ context?: AICallContext;
3981
+ }
3982
+ type AICallContext = AgentReasoningContext | AgentCompletionContext | WorkflowStepContext | ToolCallContext | OtherCallContext;
3983
+ interface AgentReasoningContext {
3984
+ type: 'agent-reasoning';
3985
+ iteration: number;
3986
+ actionsPlanned?: string[];
3987
+ sessionId?: string;
3988
+ turnNumber?: number;
3989
+ }
3990
+ interface AgentCompletionContext {
3991
+ type: 'agent-completion';
3992
+ attempt: 1 | 2;
3993
+ validationFailed?: boolean;
3994
+ sessionId?: string;
3995
+ turnNumber?: number;
3996
+ }
3997
+ interface WorkflowStepContext {
3998
+ type: 'workflow-step';
3999
+ stepId: string;
4000
+ stepName?: string;
4001
+ stepSequence?: number;
4002
+ }
4003
+ interface ToolCallContext {
4004
+ type: 'tool';
4005
+ toolName: string;
4006
+ parentIteration?: number;
4007
+ parentStepId?: string;
4008
+ }
4009
+ interface OtherCallContext {
4010
+ type: 'other';
4011
+ description?: string;
4012
+ metadata?: Record<string, unknown>;
4013
+ }
4014
+ type AICallRecord = BaseAICall;
4015
+ /**
4016
+ * Raw LLM usage data returned by adapters
4017
+ * Used as input to AIUsageCollector.record()
4018
+ */
4019
+ interface LLMUsageData {
4020
+ model: LLMModel;
4021
+ inputTokens: number;
4022
+ outputTokens: number;
4023
+ latencyMs: number;
4024
+ /** Actual cost from provider in USD (when available, e.g., OpenRouter) */
4025
+ cost?: number;
4026
+ }
4027
+ interface AIUsageSummary {
4028
+ model: LLMModel;
4029
+ totalInputTokens: number;
4030
+ totalOutputTokens: number;
4031
+ totalTokens: number;
4032
+ totalCostUsd: number;
4033
+ callCount: number;
4034
+ calls: AICallRecord[];
4035
+ }
4036
+ interface ExecutionMetricsSummary {
4037
+ durationMs?: number;
4038
+ automationSavingsUsd?: number;
4039
+ }
4040
+ interface ResourceMetricsConfig {
4041
+ estimatedManualMinutes: number;
4042
+ hourlyLaborRateUsd: number;
4043
+ confidenceLevel?: 'low' | 'medium' | 'high';
4044
+ notes?: string;
4045
+ }
3347
4046
  /**
3348
4047
  * Time range selector for dashboard metrics
3349
4048
  */
@@ -3414,6 +4113,23 @@ interface CostBreakdownMetrics {
3414
4113
  avgCostUsd: number;
3415
4114
  }>;
3416
4115
  }
4116
+ /**
4117
+ * Detailed execution metrics response
4118
+ * Full execution metrics with AI call breakdown
4119
+ */
4120
+ interface ExecutionMetricsDetail {
4121
+ executionId: string;
4122
+ organizationId: string;
4123
+ resourceId: string;
4124
+ totalInputTokens: number;
4125
+ totalOutputTokens: number;
4126
+ totalCostUsd: number;
4127
+ aiCallCount: number;
4128
+ aiCalls: AICallRecord[];
4129
+ durationMs?: number;
4130
+ automationSavingsUsd?: number;
4131
+ createdAt: string;
4132
+ }
3417
4133
  /**
3418
4134
  * Dashboard metrics response
3419
4135
  * Aggregates core observability metrics in a single response
@@ -3588,11 +4304,51 @@ interface CostByModelResponse {
3588
4304
  totalCallCount: number;
3589
4305
  }
3590
4306
 
4307
+ /**
4308
+ * AIUsageCollector
4309
+ * Centralized token tracking that aggregates usage across all LLM calls in an execution
4310
+ */
4311
+ declare class AIUsageCollector {
4312
+ private model;
4313
+ private calls;
4314
+ private callSequence;
4315
+ /**
4316
+ * Record a single AI call with usage metrics
4317
+ *
4318
+ * @param usage - Token usage and latency data from LLM adapter
4319
+ * @param callType - Type discriminator (agent-reasoning, tool, etc.)
4320
+ * @param context - Optional typed context specific to callType
4321
+ */
4322
+ record(usage: LLMUsageData, callType?: BaseAICall['callType'], context?: AICallContext): void;
4323
+ /**
4324
+ * Get aggregated summary of all AI calls
4325
+ */
4326
+ getSummary(): AIUsageSummary;
4327
+ /**
4328
+ * Check if any usage has been recorded
4329
+ */
4330
+ hasUsage(): boolean;
4331
+ }
4332
+
3591
4333
  /**
3592
4334
  * Base Execution Engine type definitions
3593
4335
  * Core types shared across all Execution Engine resources
3594
4336
  */
3595
4337
 
4338
+ /**
4339
+ * Immutable execution metadata
4340
+ * Represents complete execution identity (who, what, when, where)
4341
+ * Shared across ExecutionContext and ExecutionLoggerContext to eliminate field duplication
4342
+ */
4343
+ interface ExecutionMetadata {
4344
+ executionId: string;
4345
+ organizationId: string;
4346
+ organizationName: string;
4347
+ resourceId: string;
4348
+ userId?: string;
4349
+ sessionId?: string;
4350
+ sessionTurnNumber?: number;
4351
+ }
3596
4352
  /**
3597
4353
  * Unified message event type - covers all message types in sessions
3598
4354
  * Replaces separate SessionTurnMessages and AgentActivityEvent mechanisms
@@ -3640,6 +4396,27 @@ type MessageEvent = {
3640
4396
  result?: unknown;
3641
4397
  error?: string;
3642
4398
  };
4399
+ /**
4400
+ * Execution context for all resources
4401
+ * Unified callback replaces SessionTurnMessages (removed)
4402
+ */
4403
+ interface ExecutionContext extends ExecutionMetadata {
4404
+ logger: IExecutionLogger;
4405
+ signal?: AbortSignal;
4406
+ onMessageEvent?: (event: MessageEvent) => Promise<void>;
4407
+ /** Called per iteration to write heartbeat + check stall status. Non-fatal if it throws. */
4408
+ onHeartbeat?: () => Promise<void>;
4409
+ aiUsageCollector?: AIUsageCollector;
4410
+ metricsCollector?: MetricsCollector;
4411
+ parentExecutionId?: string;
4412
+ executionDepth: number;
4413
+ credentialName?: string;
4414
+ store: Map<string, unknown>;
4415
+ }
4416
+ interface Contract {
4417
+ inputSchema: z.ZodSchema;
4418
+ outputSchema?: z.ZodSchema;
4419
+ }
3643
4420
  /**
3644
4421
  * NOTE: AIResource interface has been removed and replaced with ResourceDefinition
3645
4422
  * from registry/types.ts. All resources (executable and non-executable) now extend
@@ -3650,6 +4427,45 @@ type MessageEvent = {
3650
4427
  */
3651
4428
  type AIResourceDefinition = SerializedWorkflowDefinition | SerializedAgentDefinition;
3652
4429
 
4430
+ /**
4431
+ * Tool definitions
4432
+ *
4433
+ * Tool interface used by agents and workflows.
4434
+ * Provides a universal interface for AI systems to interact with tools.
4435
+ */
4436
+
4437
+ /**
4438
+ * Options for tool execution
4439
+ * Provides named parameters for better API clarity and extensibility
4440
+ */
4441
+ interface ToolExecutionOptions {
4442
+ /** Tool input (validated against inputSchema before execution) */
4443
+ input: unknown;
4444
+ /** Execution context with multi-tenant isolation and observability (optional for simple tools, required for platform/integration tools) */
4445
+ executionContext?: ExecutionContext;
4446
+ /** Full iteration context for advanced tools (provides access to memoryManager, toolRegistry, logger, etc.) */
4447
+ iterationContext?: IterationContext;
4448
+ /** Abort signal for timeout/cancellation -- forward to fetch() calls for clean cancellation */
4449
+ signal?: AbortSignal;
4450
+ }
4451
+ /**
4452
+ * Tool interface for AI systems
4453
+ *
4454
+ * Used by:
4455
+ * - Agents: For agentic tool use (reasoning loop selects and executes tools)
4456
+ * - Workflows: For workflow step tool invocation (future)
4457
+ * - Platform tools: createApprovalTool(), createSchedulerTool()
4458
+ * - Integration tools: External API calls (Gmail, Slack, etc.)
4459
+ */
4460
+ interface Tool {
4461
+ name: string;
4462
+ description: string;
4463
+ inputSchema: z.ZodSchema;
4464
+ outputSchema: z.ZodSchema;
4465
+ execute: (options: ToolExecutionOptions) => Promise<unknown>;
4466
+ timeout?: number;
4467
+ }
4468
+
3653
4469
  /**
3654
4470
  * Supported integration types
3655
4471
  *
@@ -4058,6 +4874,99 @@ interface Activity {
4058
4874
  createdAt: Date;
4059
4875
  }
4060
4876
 
4877
+ /**
4878
+ * Calibration SSE Event Types
4879
+ *
4880
+ * Shared event type definitions for calibration real-time streaming.
4881
+ * Used by both the API broadcaster and the command-center UI.
4882
+ */
4883
+ interface CalibrationExecutionStartedEvent {
4884
+ type: 'execution-started';
4885
+ variantName: string;
4886
+ inputIndex: number;
4887
+ timestamp: number;
4888
+ }
4889
+ interface CalibrationExecutionCompletedEvent {
4890
+ type: 'execution-completed';
4891
+ variantName: string;
4892
+ inputIndex: number;
4893
+ executionId: string;
4894
+ timestamp: number;
4895
+ }
4896
+ interface CalibrationExecutionFailedEvent {
4897
+ type: 'execution-failed';
4898
+ variantName: string;
4899
+ inputIndex?: number;
4900
+ error: string;
4901
+ timestamp: number;
4902
+ }
4903
+ interface CalibrationSessionStartedEvent {
4904
+ type: 'session-started';
4905
+ variantName: string;
4906
+ sessionId: string;
4907
+ timestamp: number;
4908
+ }
4909
+ interface CalibrationTurnStartedEvent {
4910
+ type: 'turn-started';
4911
+ variantName: string;
4912
+ turnNumber: number;
4913
+ timestamp: number;
4914
+ }
4915
+ interface CalibrationTurnCompletedEvent {
4916
+ type: 'turn-completed';
4917
+ variantName: string;
4918
+ turnNumber: number;
4919
+ executionId: string;
4920
+ timestamp: number;
4921
+ }
4922
+ interface CalibrationSessionCompletedEvent {
4923
+ type: 'session-completed';
4924
+ variantName: string;
4925
+ sessionId: string;
4926
+ turnCount: number;
4927
+ timestamp: number;
4928
+ }
4929
+ interface CalibrationGradingStartedEvent {
4930
+ type: 'grading-started';
4931
+ variantName: string;
4932
+ timestamp: number;
4933
+ }
4934
+ interface CalibrationGradingCompletedEvent {
4935
+ type: 'grading-completed';
4936
+ variantName: string;
4937
+ score: number;
4938
+ timestamp: number;
4939
+ }
4940
+ interface CalibrationGradingFailedEvent {
4941
+ type: 'grading-failed';
4942
+ variantName: string;
4943
+ error: string;
4944
+ timestamp: number;
4945
+ }
4946
+ interface CalibrationCompletedEvent {
4947
+ type: 'calibration-completed';
4948
+ summary: {
4949
+ total: number;
4950
+ completed: number;
4951
+ failed: number;
4952
+ };
4953
+ timestamp: number;
4954
+ }
4955
+ interface CalibrationFailedEvent {
4956
+ type: 'calibration-failed';
4957
+ error: string;
4958
+ timestamp: number;
4959
+ }
4960
+ interface CalibrationConnectedEvent {
4961
+ type: 'connected';
4962
+ timestamp: number;
4963
+ data?: undefined;
4964
+ }
4965
+ /**
4966
+ * Union of all calibration SSE events
4967
+ */
4968
+ type CalibrationSSEEvent = CalibrationExecutionStartedEvent | CalibrationExecutionCompletedEvent | CalibrationExecutionFailedEvent | CalibrationSessionStartedEvent | CalibrationTurnStartedEvent | CalibrationTurnCompletedEvent | CalibrationSessionCompletedEvent | CalibrationGradingStartedEvent | CalibrationGradingCompletedEvent | CalibrationGradingFailedEvent | CalibrationCompletedEvent | CalibrationFailedEvent | CalibrationConnectedEvent;
4969
+
4061
4970
  /**
4062
4971
  * Execution history item.
4063
4972
  * Represents a single execution triggered by a schedule.
@@ -4102,6 +5011,154 @@ declare const ExecutionHistoryResponseSchema: z.ZodObject<{
4102
5011
  type ExecutionHistoryItem = z.infer<typeof ExecutionHistoryItemSchema>;
4103
5012
  type ExecutionHistoryResponse = z.infer<typeof ExecutionHistoryResponseSchema>;
4104
5013
 
5014
+ /**
5015
+ * Calibration Lab Type Definitions
5016
+ * Core types for AI model configuration optimization with cost/performance comparison
5017
+ */
5018
+
5019
+ /**
5020
+ * Calibration project - groups related optimization runs
5021
+ * Provides organizational structure for iterative testing
5022
+ */
5023
+ interface CalibrationProject {
5024
+ id: string;
5025
+ organizationId: string;
5026
+ resourceId: string;
5027
+ resourceType: 'agent' | 'workflow';
5028
+ name: string;
5029
+ description?: string | null;
5030
+ createdAt: Date;
5031
+ updatedAt: Date;
5032
+ }
5033
+ /**
5034
+ * Configuration variant for testing
5035
+ * Defines what to override in the base agent/workflow definition
5036
+ */
5037
+ interface ConfigVariant {
5038
+ variantName: string;
5039
+ definitionOverrides?: AgentCalibrationOverrides | WorkflowCalibrationOverrides;
5040
+ }
5041
+ /**
5042
+ * Agent definition overrides for calibration
5043
+ * Excludes identity/metadata fields that should not be modified
5044
+ */
5045
+ type AgentCalibrationOverrides = Omit<Partial<AgentDefinition>, 'config' | 'contract' | 'tools' | 'metricsConfig' | 'interface'>;
5046
+ /**
5047
+ * Workflow definition overrides for calibration
5048
+ * Excludes identity/metadata fields that should not be modified
5049
+ */
5050
+ type WorkflowCalibrationOverrides = Omit<Partial<WorkflowDefinition>, 'config' | 'contract' | 'steps' | 'entryPoint' | 'metricsConfig' | 'interface'>;
5051
+ /**
5052
+ * Grading rubric for LLM-as-judge evaluation
5053
+ * Defines criteria and passing threshold
5054
+ */
5055
+ interface GradingRubric {
5056
+ passingThreshold: number;
5057
+ criteria: GradingCriterion[];
5058
+ }
5059
+ /**
5060
+ * Individual grading criterion
5061
+ * Weight should be 0-1, and all weights should sum to 1
5062
+ */
5063
+ interface GradingCriterion {
5064
+ name: string;
5065
+ weight: number;
5066
+ description: string;
5067
+ scoringGuide: string;
5068
+ }
5069
+ /**
5070
+ * Grading result for a single execution or session
5071
+ * Contains overall score and per-criterion breakdown
5072
+ */
5073
+ interface GradeResult {
5074
+ score: number;
5075
+ passed: boolean;
5076
+ details: Record<string, {
5077
+ score: number;
5078
+ justification: string;
5079
+ }>;
5080
+ }
5081
+ /**
5082
+ * Single-turn calibration result
5083
+ * One result per (variant × input) combination
5084
+ */
5085
+ interface SingleCalibrationResult {
5086
+ executionId: string;
5087
+ variantName: string;
5088
+ inputIndex: number;
5089
+ appliedOverrides?: AgentCalibrationOverrides | WorkflowCalibrationOverrides;
5090
+ status: 'pending' | 'running' | 'completed' | 'failed';
5091
+ errorMessage?: string;
5092
+ grade?: GradeResult;
5093
+ gradeError?: string;
5094
+ }
5095
+ /**
5096
+ * Multi-turn session calibration result
5097
+ * Leverages existing sessions infrastructure
5098
+ */
5099
+ interface SessionCalibrationResult {
5100
+ sessionId: string;
5101
+ variantName: string;
5102
+ appliedOverrides?: AgentCalibrationOverrides | WorkflowCalibrationOverrides;
5103
+ status: 'pending' | 'running' | 'completed' | 'failed';
5104
+ errorMessage?: string;
5105
+ turnCount: number;
5106
+ grade?: GradeResult;
5107
+ gradeError?: string;
5108
+ }
5109
+ /**
5110
+ * Calibration run - individual test execution within a project
5111
+ * Contains configuration, results, and grading information
5112
+ */
5113
+ interface CalibrationRun {
5114
+ id: string;
5115
+ organizationId: string;
5116
+ projectId: string;
5117
+ name: string;
5118
+ description?: string | null;
5119
+ executionMode: 'single' | 'session';
5120
+ testInputs: unknown[];
5121
+ configVariants: ConfigVariant[];
5122
+ gradingRubric?: GradingRubric | null;
5123
+ graderModel?: string | null;
5124
+ results: (SingleCalibrationResult | SessionCalibrationResult)[];
5125
+ status: 'pending' | 'running' | 'completed' | 'partial' | 'failed';
5126
+ createdAt: Date;
5127
+ completedAt?: Date | null;
5128
+ }
5129
+ /**
5130
+ * Execution log subset for comparison view
5131
+ * Contains essential data without full execution context
5132
+ */
5133
+ interface ExecutionLog {
5134
+ executionId: string;
5135
+ status: 'running' | 'completed' | 'failed';
5136
+ input: unknown;
5137
+ output: unknown | null;
5138
+ error: CalibrationExecutionError | null;
5139
+ startedAt: string;
5140
+ completedAt: string | null;
5141
+ }
5142
+ /**
5143
+ * Execution error information for calibration display
5144
+ * Subset of full execution error for UI display purposes
5145
+ * Named differently from ExecutionError class to avoid type conflicts
5146
+ */
5147
+ interface CalibrationExecutionError {
5148
+ message: string;
5149
+ category?: string;
5150
+ type?: string;
5151
+ }
5152
+ /**
5153
+ * Combined calibration run data for comparison view
5154
+ * Single API call returns run + execution logs + metrics
5155
+ */
5156
+ interface CalibrationRunWithFullData {
5157
+ run: CalibrationRun;
5158
+ logs: Record<string, ExecutionLog>;
5159
+ metrics: Record<string, ExecutionMetricsDetail>;
5160
+ }
5161
+
4105
5162
  /**
4106
5163
  * Deployment types — browser-safe
4107
5164
  *
@@ -6607,5 +7664,109 @@ interface UseResourceExecutionsOptions {
6607
7664
  */
6608
7665
  declare function useResourceExecutions({ resourceId, timeRange, enabled }: UseResourceExecutionsOptions): _tanstack_react_query.UseQueryResult<ResourceExecutionsResponse, Error>;
6609
7666
 
6610
- export { ApiKeyService, CredentialService, DeploymentService, OperationsService, OrganizationMembershipService, REFETCH_INTERVAL_RUNNING, WS_MAX_RETRIES_BEFORE_ERROR, WS_RECONNECT_BASE_DELAY, WS_RECONNECT_MAX_DELAY, WebhookEndpointService, createUseFeatureAccess, executionsKeys, filterByDomainFilters, isSessionCapable, observabilityKeys, operationsKeys, scheduleKeys, sessionsKeys, sortData, useActivateDeployment, useActivities, useActivityFilters, useActivityTrend, useArchiveSession, useArchivedLogs, useBatchDelete, useBatchedResourcesHealth, useBulkDeleteExecutions, useBusinessImpact, useCancelExecution, useCancelSchedule, useCheckpointTasks, useCommandQueue, useCommandQueueTotals, useCommandViewData, useCommandViewDomainFilters, useCommandViewLayout, useCommandViewStats, useCommandViewStore, useCostBreakdown, useCostByModel, useCostSummary, useCostTrends, useCreateApiKey, useCreateCredential, useCreateSchedule, useCreateSession, useCreateWebhookEndpoint, useCredentials, useDashboardMetrics, useDeactivateDeployment, useDeactivateMembership, useDeleteApiKey, useDeleteCredential, useDeleteDeployment, useDeleteExecution, useDeleteSchedule, useDeleteSession, useDeleteTask, useDeleteWebhookEndpoint, useDeploymentDocs, useErrorAnalysis, useErrorDetail, useErrorDetails, useErrorDistribution, useErrorNotification, useErrorTrends, useExecuteAsync, useExecution, useExecutionHealth, useExecutionLogSSE, useExecutionLogs, useExecutionLogsFilters, useExecutionPanelState, useExecutions, useGetExecutionHistory, useGetSchedule, useGraphStats, useListApiKeys, useListDeployments, useListSchedules, useListWebhookEndpoints, useMarkAllAsRead, useMarkAsRead, useNotificationCount as useNotificationCountSSE, useNotifications, useOrganizationMembers, usePaginationState, usePatchTask, usePauseSchedule, useReactivateMembership, useRecentExecutionsByResource, useResolveAllErrors, useResolveError, useResolveErrorsByExecution, useResourceDefinition, useResourceErrors, useResourceExecutions, useResourceSearch, useResources, useResourcesDomainFilters, useResourcesHealth, useResumeSchedule, useRetryExecution, useSSEConnection, useScheduledTasks, useSession, useSessionExecution, useSessionExecutions, useSessionMessages, useSessionWebSocket, useSessions, useSortedData, useStatusFilter, useSubmitAction, useSuccessNotification, useTableSelection, useTableSort, useTestNotification, useTimeRangeDates, useTopFailingResources, useUnresolveError, useUnresolvedErrors, useUpdateAnchor, useUpdateApiKey, useUpdateCredential, useUpdateMemberConfig, useUpdateSchedule, useUpdateWebhookEndpoint, useUserMemberships, useVisibleResources, useWarningNotification };
6611
- export type { ActivityFilters, ActivityTrendResponse, BulkDeleteExecutionsParams, BulkDeleteExecutionsResult, BusinessImpactMetrics, CancelExecutionParams, CancelExecutionResult, ChatMessage, CostBreakdownItem, CreateApiKeyRequest, CreateApiKeyResponse, CreateCredentialRequest, CreateCredentialResponse, CreateScheduleInput, CreateSessionResponse, CredentialListItem, DeleteExecutionParams, Deployment, DocFile, ErrorDistributionItem, ErrorDistributionParams, ErrorFilters, ErrorTrendsParams, ExecuteAsyncParams, ExecuteAsyncResult, ExecutionErrorDetails, ExecutionHistoryItem, ExecutionHistoryResponse, ExecutionLogsFilters, ExecutionLogsPageResponse, FailingResource, GetMessagesResponse, ListActivitiesResponse, ListApiKeysResponse, ListCredentialsResponse, ListSchedulesFilters, ListSchedulesResponse, ListWebhookEndpointsResponse, MessageEvent, MessageType, ResourcesResponse, RetryExecutionParams, SessionDTO, SessionExecution, SessionExecutionsResponse, SessionListItem, SessionTokenUsage, SortDirection, SortState, StatusFilter$1 as StatusFilter, SubmitActionRequest, SubmitActionResponse, TaskSchedule, TopFailingResourcesParams, UpdateScheduleInput, UseActivitiesParams, UseActivityTrendParams, UseBatchedResourcesHealthParams, UseExecutionHealthParams, UseExecutionLogsParams, UseExecutionPanelStateOptions, UseExecutionPanelStateReturn, UseNotificationCountArgs, UseResourcesHealthParams, UseSSEConnectionOptions, UseScheduledTasksOptions, WebSocketState };
7667
+ /**
7668
+ * Query key factory for calibration hooks.
7669
+ * Ensures consistent, organization-scoped cache isolation.
7670
+ */
7671
+ declare const calibrationKeys: {
7672
+ all: readonly ["calibration"];
7673
+ projects: (org: string) => readonly ["calibration", "projects", string];
7674
+ projectsByResource: (org: string, resourceId: string, resourceType: string) => readonly ["calibration", "projects", string, string, string];
7675
+ project: (org: string, projectId: string) => readonly ["calibration", "project", string, string];
7676
+ runs: (org: string, projectId: string) => readonly ["calibration", "runs", string, string];
7677
+ run: (org: string, runId: string) => readonly ["calibration", "run", string, string];
7678
+ runFull: (org: string, runId: string) => readonly ["calibration", "run-full", string, string];
7679
+ };
7680
+
7681
+ /**
7682
+ * Fetch all calibration projects for the organization (unified view)
7683
+ */
7684
+ declare function useAllCalibrationProjects(): _tanstack_react_query.UseQueryResult<CalibrationProject[], Error>;
7685
+ /**
7686
+ * Fetch calibration projects for a specific resource
7687
+ */
7688
+ declare function useCalibrationProjects(resourceId: string, resourceType: 'agent' | 'workflow'): _tanstack_react_query.UseQueryResult<CalibrationProject[], Error>;
7689
+ declare function useCalibrationProject(projectId: string): _tanstack_react_query.UseQueryResult<CalibrationProject, Error>;
7690
+ declare function useCreateProject(): _tanstack_react_query.UseMutationResult<CalibrationProject, Error, {
7691
+ resourceId: string;
7692
+ resourceType: "agent" | "workflow";
7693
+ name: string;
7694
+ description?: string | undefined;
7695
+ }, unknown>;
7696
+ declare function useUpdateProject(): _tanstack_react_query.UseMutationResult<CalibrationProject, Error, {
7697
+ name?: string | undefined;
7698
+ description?: string | undefined;
7699
+ } & {
7700
+ id: string;
7701
+ }, unknown>;
7702
+ declare function useDeleteProject(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
7703
+
7704
+ declare function useCalibrationRuns(projectId: string): _tanstack_react_query.UseQueryResult<CalibrationRun[], Error>;
7705
+ declare function useCalibrationRun(runId: string): _tanstack_react_query.UseQueryResult<CalibrationRun, Error>;
7706
+ declare function useCreateRun(): _tanstack_react_query.UseMutationResult<CalibrationRun, Error, {
7707
+ projectId: string;
7708
+ name: string;
7709
+ executionMode: "single" | "session";
7710
+ testInputs: unknown[];
7711
+ configVariants: {
7712
+ variantName: string;
7713
+ definitionOverrides?: Record<string, unknown> | undefined;
7714
+ }[];
7715
+ description?: string | undefined;
7716
+ gradingRubric?: {
7717
+ passingThreshold: number;
7718
+ criteria: {
7719
+ name: string;
7720
+ weight: number;
7721
+ description: string;
7722
+ scoringGuide: string;
7723
+ }[];
7724
+ } | undefined;
7725
+ 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;
7726
+ }, unknown>;
7727
+ declare function useExecuteRun(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
7728
+ declare function useDeleteRun(): _tanstack_react_query.UseMutationResult<void, Error, {
7729
+ runId: string;
7730
+ projectId: string;
7731
+ }, unknown>;
7732
+ declare function useGradeRun(): _tanstack_react_query.UseMutationResult<void, Error, {
7733
+ runId: string;
7734
+ rubric?: unknown;
7735
+ graderModel?: string;
7736
+ }, unknown>;
7737
+
7738
+ declare function useCalibrationRunFull(runId: string): _tanstack_react_query.UseQueryResult<CalibrationRunWithFullData, Error>;
7739
+
7740
+ interface CalibrationProgress {
7741
+ connected: boolean;
7742
+ events: CalibrationSSEEvent[];
7743
+ summary?: {
7744
+ total: number;
7745
+ completed: number;
7746
+ failed: number;
7747
+ };
7748
+ isComplete: boolean;
7749
+ error?: string;
7750
+ }
7751
+ interface UseCalibrationSSEOptions {
7752
+ runId: string;
7753
+ manager: SSEConnectionManager;
7754
+ apiUrl: string;
7755
+ enabled?: boolean;
7756
+ }
7757
+ declare function useCalibrationSSE({ runId, manager, apiUrl, enabled }: UseCalibrationSSEOptions): {
7758
+ disconnect: () => void;
7759
+ reset: () => void;
7760
+ connected: boolean;
7761
+ events: CalibrationSSEEvent[];
7762
+ summary?: {
7763
+ total: number;
7764
+ completed: number;
7765
+ failed: number;
7766
+ };
7767
+ isComplete: boolean;
7768
+ error?: string;
7769
+ };
7770
+
7771
+ export { ApiKeyService, CredentialService, DeploymentService, OperationsService, OrganizationMembershipService, REFETCH_INTERVAL_RUNNING, WS_MAX_RETRIES_BEFORE_ERROR, WS_RECONNECT_BASE_DELAY, WS_RECONNECT_MAX_DELAY, WebhookEndpointService, calibrationKeys, createUseFeatureAccess, executionsKeys, filterByDomainFilters, isSessionCapable, observabilityKeys, operationsKeys, scheduleKeys, sessionsKeys, sortData, useActivateDeployment, useActivities, useActivityFilters, useActivityTrend, useAllCalibrationProjects, useArchiveSession, useArchivedLogs, useBatchDelete, useBatchedResourcesHealth, useBulkDeleteExecutions, useBusinessImpact, useCalibrationProject, useCalibrationProjects, useCalibrationRun, useCalibrationRunFull, useCalibrationRuns, useCalibrationSSE, useCancelExecution, useCancelSchedule, useCheckpointTasks, useCommandQueue, useCommandQueueTotals, useCommandViewData, useCommandViewDomainFilters, useCommandViewLayout, useCommandViewStats, useCommandViewStore, useCostBreakdown, useCostByModel, useCostSummary, useCostTrends, useCreateApiKey, useCreateCredential, useCreateProject, useCreateRun, useCreateSchedule, useCreateSession, useCreateWebhookEndpoint, useCredentials, useDashboardMetrics, useDeactivateDeployment, useDeactivateMembership, useDeleteApiKey, useDeleteCredential, useDeleteDeployment, useDeleteExecution, useDeleteProject, useDeleteRun, useDeleteSchedule, useDeleteSession, useDeleteTask, useDeleteWebhookEndpoint, useDeploymentDocs, useErrorAnalysis, useErrorDetail, useErrorDetails, useErrorDistribution, useErrorNotification, useErrorTrends, useExecuteAsync, useExecuteRun, useExecution, useExecutionHealth, useExecutionLogSSE, useExecutionLogs, useExecutionLogsFilters, useExecutionPanelState, useExecutions, useGetExecutionHistory, useGetSchedule, useGradeRun, useGraphStats, useListApiKeys, useListDeployments, useListSchedules, useListWebhookEndpoints, useMarkAllAsRead, useMarkAsRead, useNotificationCount as useNotificationCountSSE, useNotifications, useOrganizationMembers, usePaginationState, usePatchTask, usePauseSchedule, useReactivateMembership, useRecentExecutionsByResource, useResolveAllErrors, useResolveError, useResolveErrorsByExecution, useResourceDefinition, useResourceErrors, useResourceExecutions, useResourceSearch, useResources, useResourcesDomainFilters, useResourcesHealth, useResumeSchedule, useRetryExecution, useSSEConnection, useScheduledTasks, useSession, useSessionExecution, useSessionExecutions, useSessionMessages, useSessionWebSocket, useSessions, useSortedData, useStatusFilter, useSubmitAction, useSuccessNotification, useTableSelection, useTableSort, useTestNotification, useTimeRangeDates, useTopFailingResources, useUnresolveError, useUnresolvedErrors, useUpdateAnchor, useUpdateApiKey, useUpdateCredential, useUpdateMemberConfig, useUpdateProject, useUpdateSchedule, useUpdateWebhookEndpoint, useUserMemberships, useVisibleResources, useWarningNotification };
7772
+ export type { ActivityFilters, ActivityTrendResponse, BulkDeleteExecutionsParams, BulkDeleteExecutionsResult, BusinessImpactMetrics, CalibrationProgress, CancelExecutionParams, CancelExecutionResult, ChatMessage, CostBreakdownItem, CreateApiKeyRequest, CreateApiKeyResponse, CreateCredentialRequest, CreateCredentialResponse, CreateScheduleInput, CreateSessionResponse, CredentialListItem, DeleteExecutionParams, Deployment, DocFile, ErrorDistributionItem, ErrorDistributionParams, ErrorFilters, ErrorTrendsParams, ExecuteAsyncParams, ExecuteAsyncResult, ExecutionErrorDetails, ExecutionHistoryItem, ExecutionHistoryResponse, ExecutionLogsFilters, ExecutionLogsPageResponse, FailingResource, GetMessagesResponse, ListActivitiesResponse, ListApiKeysResponse, ListCredentialsResponse, ListSchedulesFilters, ListSchedulesResponse, ListWebhookEndpointsResponse, MessageEvent, MessageType, ResourcesResponse, RetryExecutionParams, SessionDTO, SessionExecution, SessionExecutionsResponse, SessionListItem, SessionTokenUsage, SortDirection, SortState, StatusFilter$1 as StatusFilter, SubmitActionRequest, SubmitActionResponse, TaskSchedule, TopFailingResourcesParams, UpdateScheduleInput, UseActivitiesParams, UseActivityTrendParams, UseBatchedResourcesHealthParams, UseCalibrationSSEOptions, UseExecutionHealthParams, UseExecutionLogsParams, UseExecutionPanelStateOptions, UseExecutionPanelStateReturn, UseNotificationCountArgs, UseResourcesHealthParams, UseSSEConnectionOptions, UseScheduledTasksOptions, WebSocketState };