@elevasis/ui 2.9.0 → 2.10.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 (75) hide show
  1. package/dist/app/index.css +137 -0
  2. package/dist/app/index.d.ts +223 -0
  3. package/dist/app/index.js +95 -0
  4. package/dist/charts/index.js +3 -2
  5. package/dist/{chunk-NYMKWGKN.js → chunk-4BF74JVD.js} +110 -7
  6. package/dist/{chunk-YCHZ4U5V.js → chunk-5VBR74ZS.js} +5 -13
  7. package/dist/chunk-ADSSLKKP.js +10 -0
  8. package/dist/{chunk-C2OFFC7J.js → chunk-AL23U6C3.js} +3 -2
  9. package/dist/{chunk-27COZ5AH.js → chunk-CEWTOKE7.js} +3 -50
  10. package/dist/{chunk-AQQYVAFK.js → chunk-CLXMNMIS.js} +8 -7
  11. package/dist/{chunk-4PHPENKX.js → chunk-E3IFHX6A.js} +27 -377
  12. package/dist/{chunk-4JPW5U5I.js → chunk-E4W7LB37.js} +53 -54
  13. package/dist/{chunk-CYXZHBP4.js → chunk-F4TPY6YL.js} +14 -3
  14. package/dist/chunk-G2TDX3W6.js +5 -0
  15. package/dist/chunk-IIMU5YAJ.js +53 -0
  16. package/dist/{chunk-W4VYXIN7.js → chunk-L4XXM55J.js} +3 -142
  17. package/dist/{chunk-KGEYEUR5.js → chunk-MOHVG62K.js} +7 -6
  18. package/dist/{chunk-F5QSLYUB.js → chunk-N47Z6LD4.js} +317 -1060
  19. package/dist/{chunk-47YILFON.js → chunk-OS5GFW2O.js} +156 -141
  20. package/dist/chunk-P5VHGY5P.js +13 -0
  21. package/dist/chunk-R7WLWGPO.js +126 -0
  22. package/dist/{chunk-Y3D3WFJG.js → chunk-SQQGLGHW.js} +2 -11
  23. package/dist/{chunk-KFICYU6S.js → chunk-STZJ7SY5.js} +1 -1
  24. package/dist/chunk-SZHARWKU.js +15 -0
  25. package/dist/{chunk-7PDDPNQS.js → chunk-TSX4I3NW.js} +3 -3
  26. package/dist/{chunk-CTWYIRKW.js → chunk-U23TW6NP.js} +24 -34
  27. package/dist/{chunk-OPT74SGF.js → chunk-USVBMGMP.js} +26 -172
  28. package/dist/chunk-V7XHGJQZ.js +145 -0
  29. package/dist/{chunk-UE5QQDCR.js → chunk-WHQXDETX.js} +5 -5
  30. package/dist/{chunk-ZZ35VSNF.js → chunk-YQLE5HR5.js} +4 -4
  31. package/dist/{chunk-VNUOQQNY.js → chunk-Z3OWD3A4.js} +2 -2
  32. package/dist/components/index.d.ts +6 -253
  33. package/dist/components/index.js +31 -25
  34. package/dist/features/auth/index.d.ts +0 -107
  35. package/dist/features/auth/index.js +0 -1
  36. package/dist/features/crm/index.d.ts +3 -136
  37. package/dist/features/crm/index.js +14 -9
  38. package/dist/features/dashboard/index.js +13 -9
  39. package/dist/features/delivery/index.d.ts +3 -137
  40. package/dist/features/delivery/index.js +15 -9
  41. package/dist/features/lead-gen/index.d.ts +3 -29
  42. package/dist/features/lead-gen/index.js +20 -14
  43. package/dist/features/monitoring/index.d.ts +3 -30
  44. package/dist/features/monitoring/index.js +14 -10
  45. package/dist/features/operations/index.d.ts +18 -1323
  46. package/dist/features/operations/index.js +18 -13
  47. package/dist/features/seo/index.d.ts +3 -30
  48. package/dist/features/seo/index.js +3 -2
  49. package/dist/features/settings/index.d.ts +6 -146
  50. package/dist/features/settings/index.js +13 -9
  51. package/dist/hooks/index.d.ts +10 -1403
  52. package/dist/hooks/index.js +11 -7
  53. package/dist/hooks/published.d.ts +10 -1403
  54. package/dist/hooks/published.js +11 -7
  55. package/dist/index.d.ts +96 -1510
  56. package/dist/index.js +12 -8
  57. package/dist/initialization/index.d.ts +3 -117
  58. package/dist/layout/index.d.ts +12 -2
  59. package/dist/layout/index.js +5 -4
  60. package/dist/organization/index.d.ts +3 -10
  61. package/dist/organization/index.js +2 -1
  62. package/dist/profile/index.d.ts +0 -107
  63. package/dist/provider/index.d.ts +44 -65
  64. package/dist/provider/index.js +10 -6
  65. package/dist/provider/published.d.ts +44 -65
  66. package/dist/provider/published.js +6 -3
  67. package/dist/supabase/index.d.ts +0 -209
  68. package/dist/theme/index.d.ts +1 -1
  69. package/dist/theme/index.js +3 -3
  70. package/dist/typeform/index.js +10 -10
  71. package/dist/types/index.d.ts +68 -1738
  72. package/package.json +20 -4
  73. package/src/app/README.md +24 -0
  74. package/src/provider/README.md +8 -7
  75. package/dist/chunk-IDACMRGQ.js +0 -115
@@ -1554,113 +1554,6 @@ type Database = {
1554
1554
  }
1555
1555
  ];
1556
1556
  };
1557
- calibration_projects: {
1558
- Row: {
1559
- created_at: string | null;
1560
- description: string | null;
1561
- id: string;
1562
- name: string;
1563
- organization_id: string;
1564
- resource_id: string;
1565
- resource_type: string;
1566
- updated_at: string | null;
1567
- };
1568
- Insert: {
1569
- created_at?: string | null;
1570
- description?: string | null;
1571
- id?: string;
1572
- name: string;
1573
- organization_id: string;
1574
- resource_id: string;
1575
- resource_type: string;
1576
- updated_at?: string | null;
1577
- };
1578
- Update: {
1579
- created_at?: string | null;
1580
- description?: string | null;
1581
- id?: string;
1582
- name?: string;
1583
- organization_id?: string;
1584
- resource_id?: string;
1585
- resource_type?: string;
1586
- updated_at?: string | null;
1587
- };
1588
- Relationships: [
1589
- {
1590
- foreignKeyName: "calibration_projects_organization_id_fkey";
1591
- columns: ["organization_id"];
1592
- isOneToOne: false;
1593
- referencedRelation: "organizations";
1594
- referencedColumns: ["id"];
1595
- }
1596
- ];
1597
- };
1598
- calibration_runs: {
1599
- Row: {
1600
- completed_at: string | null;
1601
- config_variants: Json;
1602
- created_at: string | null;
1603
- description: string | null;
1604
- execution_mode: string;
1605
- grader_model: string | null;
1606
- grading_rubric: Json | null;
1607
- id: string;
1608
- name: string;
1609
- organization_id: string;
1610
- project_id: string;
1611
- results: Json;
1612
- status: string;
1613
- test_inputs: Json;
1614
- };
1615
- Insert: {
1616
- completed_at?: string | null;
1617
- config_variants: Json;
1618
- created_at?: string | null;
1619
- description?: string | null;
1620
- execution_mode?: string;
1621
- grader_model?: string | null;
1622
- grading_rubric?: Json | null;
1623
- id?: string;
1624
- name: string;
1625
- organization_id: string;
1626
- project_id: string;
1627
- results?: Json;
1628
- status?: string;
1629
- test_inputs: Json;
1630
- };
1631
- Update: {
1632
- completed_at?: string | null;
1633
- config_variants?: Json;
1634
- created_at?: string | null;
1635
- description?: string | null;
1636
- execution_mode?: string;
1637
- grader_model?: string | null;
1638
- grading_rubric?: Json | null;
1639
- id?: string;
1640
- name?: string;
1641
- organization_id?: string;
1642
- project_id?: string;
1643
- results?: Json;
1644
- status?: string;
1645
- test_inputs?: Json;
1646
- };
1647
- Relationships: [
1648
- {
1649
- foreignKeyName: "calibration_runs_organization_id_fkey";
1650
- columns: ["organization_id"];
1651
- isOneToOne: false;
1652
- referencedRelation: "organizations";
1653
- referencedColumns: ["id"];
1654
- },
1655
- {
1656
- foreignKeyName: "calibration_runs_project_id_fkey";
1657
- columns: ["project_id"];
1658
- isOneToOne: false;
1659
- referencedRelation: "calibration_projects";
1660
- referencedColumns: ["id"];
1661
- }
1662
- ];
1663
- };
1664
1557
  command_queue: {
1665
1558
  Row: {
1666
1559
  action_payload: Json | null;
@@ -3162,7 +3055,7 @@ interface TaskSchedule extends ScheduleOriginTracking {
3162
3055
  updatedAt: Date;
3163
3056
  }
3164
3057
 
3165
- type MessageType = MessageEvent$1['type'];
3058
+ type MessageType = MessageEvent['type'];
3166
3059
  /**
3167
3060
  * Session Data Transfer Object (DTO)
3168
3061
  * Transform type for API responses (snake_case DB → camelCase frontend)
@@ -3187,7 +3080,7 @@ interface ChatMessage {
3187
3080
  role: 'user' | 'assistant';
3188
3081
  messageType: MessageType;
3189
3082
  text: string;
3190
- metadata?: MessageEvent$1;
3083
+ metadata?: MessageEvent;
3191
3084
  turnNumber: number;
3192
3085
  messageIndex?: number;
3193
3086
  createdAt: Date;
@@ -3218,18 +3111,11 @@ interface SessionTokenUsage {
3218
3111
  */
3219
3112
  /**
3220
3113
  * Per-user-per-org config (stored in org_memberships.config)
3221
- * Controls which features a specific member can access within their org
3222
- * Valid feature keys: operations, monitoring, acquisition, delivery, calibration, seo
3114
+ * Controls which features a specific member can access within their org.
3115
+ * Keys are feature IDs from the organization model (e.g. crm, lead-gen, projects, seo).
3223
3116
  */
3224
3117
  interface MembershipFeatureConfig {
3225
- features?: {
3226
- operations?: boolean;
3227
- monitoring?: boolean;
3228
- acquisition?: boolean;
3229
- delivery?: boolean;
3230
- calibration?: boolean;
3231
- seo?: boolean;
3232
- };
3118
+ features?: Record<string, boolean>;
3233
3119
  }
3234
3120
  /**
3235
3121
  * User-global config (stored in users.config)
@@ -3237,7 +3123,7 @@ interface MembershipFeatureConfig {
3237
3123
  */
3238
3124
  interface UserConfig {
3239
3125
  theme?: {
3240
- 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';
3126
+ preset?: 'default' | 'tactical' | 'regal' | 'cyber-volt' | 'aurora' | 'rose-gold' | 'midnight' | 'titanium' | 'obsidian' | 'honey' | 'abyss' | 'canopy' | 'slate' | 'cyber-strike' | 'cyber-chrome' | 'cyber-void' | 'nirvana' | 'wave' | 'synapse' | 'cortex' | 'helios' | 'graphite' | 'quarry' | 'canyon' | 'nord' | 'catppuccin' | 'tokyo-night' | 'gruvbox';
3241
3127
  colorScheme?: 'light' | 'dark' | 'auto';
3242
3128
  };
3243
3129
  onboarding?: {
@@ -3339,7 +3225,7 @@ interface MembershipWithDetails extends OrganizationMembership {
3339
3225
  * Structured action metadata attached to assistant messages.
3340
3226
  * Frontend reads this instead of parsing text prefixes.
3341
3227
  */
3342
- type AssistantAction$1 = {
3228
+ type AssistantAction = {
3343
3229
  kind: 'navigate';
3344
3230
  path: string;
3345
3231
  reason: string;
@@ -3349,13 +3235,13 @@ type AssistantAction$1 = {
3349
3235
  statusFilter: string | null;
3350
3236
  searchQuery: string | null;
3351
3237
  };
3352
- type MessageEvent$1 = {
3238
+ type MessageEvent = {
3353
3239
  type: 'user_message';
3354
3240
  text: string;
3355
3241
  } | {
3356
3242
  type: 'assistant_message';
3357
3243
  text: string;
3358
- _action?: AssistantAction$1;
3244
+ _action?: AssistantAction;
3359
3245
  } | {
3360
3246
  type: 'agent:started';
3361
3247
  } | {
@@ -3746,72 +3632,6 @@ interface AgentToolCallEvent {
3746
3632
  */
3747
3633
  type AgentLogContext = AgentLifecycleEvent | AgentIterationEvent | AgentToolCallEvent
3748
3634
 
3749
- /**
3750
- * Data for lifecycle 'started' events
3751
- */
3752
- interface AgentLifecycleStartedData {
3753
- startTime: number
3754
- iteration?: number
3755
- }
3756
-
3757
- /**
3758
- * Data for lifecycle 'completed' events
3759
- */
3760
- interface AgentLifecycleCompletedData {
3761
- startTime: number
3762
- endTime: number
3763
- duration: number
3764
- iteration?: number
3765
- attempts?: number
3766
- memorySize?: {
3767
- sessionMemoryKeys: number
3768
- historyEntries: number
3769
- }
3770
- }
3771
-
3772
- /**
3773
- * Data for lifecycle 'failed' events
3774
- */
3775
- interface AgentLifecycleFailedData {
3776
- startTime: number
3777
- endTime: number
3778
- duration: number
3779
- error: string
3780
- iteration?: number
3781
- }
3782
-
3783
- /**
3784
- * Scoped logger for agent execution
3785
- * Captures logger and agentId to eliminate repetitive parameter passing
3786
- *
3787
- * Type-safe lifecycle logging with stage-specific required fields
3788
- */
3789
- interface AgentScopedLogger {
3790
- lifecycle(lifecycle: AgentLifecycle, stage: 'started', data: AgentLifecycleStartedData): void
3791
- lifecycle(lifecycle: AgentLifecycle, stage: 'completed', data: AgentLifecycleCompletedData): void
3792
- lifecycle(lifecycle: AgentLifecycle, stage: 'failed', data: AgentLifecycleFailedData): void
3793
- reasoning(output: string, iteration: number, startTime: number, endTime: number, duration: number): void
3794
- action(
3795
- actionType: string,
3796
- message: string,
3797
- iteration: number,
3798
- startTime: number,
3799
- endTime: number,
3800
- duration: number
3801
- ): void
3802
- toolCall(
3803
- toolName: string,
3804
- iteration: number,
3805
- startTime: number,
3806
- endTime: number,
3807
- duration: number,
3808
- success: boolean,
3809
- error?: string,
3810
- input?: unknown,
3811
- output?: unknown
3812
- ): void
3813
- }
3814
-
3815
3635
  /**
3816
3636
  * Base execution logger for Execution Engine
3817
3637
  */
@@ -3829,14 +3649,6 @@ interface ExecutionLogMessage {
3829
3649
  context?: LogContext
3830
3650
  }
3831
3651
 
3832
- // Logger interface - any logger implementation must satisfy this
3833
- interface IExecutionLogger {
3834
- debug(message: string, context?: LogContext): void
3835
- info(message: string, context?: LogContext): void
3836
- warn(message: string, context?: LogContext): void
3837
- error(message: string, context?: LogContext): void
3838
- }
3839
-
3840
3652
  /**
3841
3653
  * Shared form field types for dynamic form generation
3842
3654
  * Used by: Command Queue, Execution Runner UI, future form-based features
@@ -3965,116 +3777,6 @@ interface AgentMemory {
3965
3777
  history: MemoryEntry[]
3966
3778
  }
3967
3779
 
3968
- /**
3969
- * Memory status for agent awareness
3970
- */
3971
- interface MemoryStatus {
3972
- // Session memory
3973
- sessionMemoryKeys: number // Current count
3974
- sessionMemoryLimit: number // Max allowed (default: 10)
3975
- currentKeys: string[] // List of keys currently stored
3976
-
3977
- // History memory (token-based)
3978
- historyPercent: number // 0-100 (percentage of token budget used)
3979
- historyTokens: number // Current token count
3980
- tokenBudget: number // Total token budget for memory
3981
- }
3982
-
3983
- /**
3984
- * Memory constraints (optional limits)
3985
- */
3986
- interface MemoryConstraints {
3987
- maxSessionMemoryKeys?: number // Max session memory keys (default: 10)
3988
- maxMemoryTokens?: number // Total token budget for all memory (default: 14000)
3989
- }
3990
-
3991
- /**
3992
- * Generic LLM Types
3993
- * Universal interfaces for LLM interaction across all resource types
3994
- */
3995
-
3996
- // ============================================================================
3997
- // Message Format (OpenAI-compatible)
3998
- // ============================================================================
3999
-
4000
- /**
4001
- * Standard chat message format
4002
- * Compatible with OpenAI, Anthropic, and other providers
4003
- */
4004
- interface LLMMessage {
4005
- role: 'system' | 'user' | 'assistant'
4006
- content: string
4007
- }
4008
-
4009
- // ============================================================================
4010
- // Generic Request/Response
4011
- // ============================================================================
4012
-
4013
- /**
4014
- * Generic LLM generation request
4015
- * Usable by agents, workflows, tools, etc.
4016
- */
4017
- interface LLMGenerateRequest {
4018
- // Prompt (required)
4019
- messages: LLMMessage[]
4020
-
4021
- // Output structure (required)
4022
- responseSchema: unknown // JSON Schema for structured output
4023
-
4024
- // Constraints (optional)
4025
- /** Maximum output tokens per LLM call. NOT the model's context window — see ModelInfo.maxTokens for that. */
4026
- maxOutputTokens?: number
4027
- temperature?: number
4028
- topP?: number
4029
-
4030
- // Cancellation (optional)
4031
- signal?: AbortSignal // Execution-level abort signal, composed with per-call timeout in base adapters
4032
- }
4033
-
4034
- /**
4035
- * Generic LLM generation response
4036
- * Usage field is internal-only (stripped by UniversalLLMAdapter wrapper)
4037
- */
4038
- interface LLMGenerateResponse<T = unknown> {
4039
- output: T // Parsed structured output (validated against responseSchema)
4040
-
4041
- // Internal use only (for observability tracking)
4042
- // Not exposed in public interface - wrapper extracts this
4043
- usage?: {
4044
- inputTokens: number
4045
- outputTokens: number
4046
- totalTokens: number
4047
- }
4048
-
4049
- // Actual cost from provider in USD (when available)
4050
- // Currently only OpenRouter provides this via usage accounting
4051
- cost?: number
4052
- }
4053
-
4054
- // ============================================================================
4055
- // LLM Adapter Interface
4056
- // ============================================================================
4057
-
4058
- /**
4059
- * LLM Adapter interface
4060
- * Generic primitive for all resource types (agents, workflows, tools)
4061
- *
4062
- * Design principles:
4063
- * - Single method: generate() - the core LLM primitive
4064
- * - Generic return type for type safety
4065
- * - Universal format (not agent-specific)
4066
- * - Standard message-based input (OpenAI-compatible)
4067
- */
4068
- interface LLMAdapter {
4069
- /**
4070
- * Generate structured output from prompt using LLM
4071
- *
4072
- * @param request - Generation request with messages and response schema
4073
- * @returns Generated output (typed) with optional usage metadata
4074
- */
4075
- generate<T = unknown>(request: LLMGenerateRequest): Promise<LLMGenerateResponse<T>>
4076
- }
4077
-
4078
3780
  /**
4079
3781
  * Model Configuration
4080
3782
  * Centralized model information, configuration, options, constraints, and validation
@@ -4185,569 +3887,74 @@ interface ModelConfig {
4185
3887
  modelOptions?: ModelSpecificOptions
4186
3888
  }
4187
3889
 
4188
- /**
4189
- * Memory Manager
4190
- * Encapsulates all memory operations with ultra-simple agent API
4191
- * Agent provides strings, framework handles wrapping and auto-compaction
4192
- */
4193
-
4194
-
4195
-
4196
- /**
4197
- * Memory Manager - Agent memory orchestration
4198
- * Provides ultra-simple API for agents (strings only)
4199
- * Handles automatic compaction and token management
4200
- */
4201
- declare class MemoryManager {
4202
- private cachedSnapshot?: AgentMemory
4203
-
4204
- constructor(
4205
- private memory: AgentMemory,
4206
- private constraints: MemoryConstraints = {},
4207
- private logger?: AgentScopedLogger
4208
- ) {}
3890
+ // ============================================================================
3891
+ // AI Call Tracking Types (SSOT)
3892
+ // ============================================================================
4209
3893
 
4210
- // === Agent Operations (Ultra-Simple) ===
3894
+ interface BaseAICall {
3895
+ callSequence: number // 1, 2, 3... (execution-wide universal counter)
3896
+ callType: 'agent-reasoning' | 'agent-completion' | 'workflow-step' | 'tool' | 'other'
3897
+ model: LLMModel
3898
+ inputTokens: number
3899
+ outputTokens: number
3900
+ costUsd: number // Cost in USD with full decimal precision
3901
+ latencyMs: number
3902
+ context?: AICallContext
3903
+ }
4211
3904
 
4212
- /**
4213
- * Set session memory entry (agent provides string, framework wraps it)
4214
- * @param key - Session memory key
4215
- * @param content - String content from agent
4216
- */
4217
- set(key: string, content: string): void {
4218
- // Check single entry token limit
4219
- const entryTokens = estimateTokens(content)
4220
- if (entryTokens > MAX_SINGLE_ENTRY_TOKENS) {
4221
- const truncateTime = Date.now()
4222
- this.logger?.action(
4223
- 'memory-truncate',
4224
- `Single entry exceeds token limit (${entryTokens}/${MAX_SINGLE_ENTRY_TOKENS}): ${key}`,
4225
- 0,
4226
- truncateTime,
4227
- truncateTime,
4228
- 0
4229
- )
4230
- // Truncate content to fit limit
4231
- const maxChars = MAX_SINGLE_ENTRY_TOKENS * 4
4232
- content = content.slice(0, maxChars) + '... [truncated]'
4233
- }
3905
+ type AICallContext =
3906
+ | AgentReasoningContext
3907
+ | AgentCompletionContext
3908
+ | WorkflowStepContext
3909
+ | ToolCallContext
3910
+ | OtherCallContext
4234
3911
 
4235
- this.memory.sessionMemory[key] = {
4236
- type: 'context',
4237
- content,
4238
- timestamp: Date.now(),
4239
- turnNumber: null, // Session memory entries are not turn-specific
4240
- iterationNumber: null // Session memory entries are not iteration-specific
4241
- }
4242
- }
3912
+ interface AgentReasoningContext {
3913
+ type: 'agent-reasoning'
3914
+ iteration: number
3915
+ actionsPlanned?: string[]
3916
+ sessionId?: string
3917
+ turnNumber?: number
3918
+ }
4243
3919
 
4244
- /**
4245
- * Get session memory entry content
4246
- * @param key - Session memory key
4247
- * @returns String content if exists, undefined otherwise
4248
- */
4249
- get(key: string): string | undefined {
4250
- const entry = this.memory.sessionMemory[key]
4251
- return entry?.content
4252
- }
3920
+ interface AgentCompletionContext {
3921
+ type: 'agent-completion'
3922
+ attempt: 1 | 2
3923
+ validationFailed?: boolean
3924
+ sessionId?: string
3925
+ turnNumber?: number
3926
+ }
4253
3927
 
4254
- /**
4255
- * Delete session memory entry
4256
- * @param key - Key to delete
4257
- * @returns True if key existed and was deleted
4258
- */
4259
- delete(key: string): boolean {
4260
- if (key in this.memory.sessionMemory) {
4261
- delete this.memory.sessionMemory[key]
4262
- return true
4263
- }
4264
- return false
4265
- }
3928
+ interface WorkflowStepContext {
3929
+ type: 'workflow-step'
3930
+ stepId: string
3931
+ stepName?: string
3932
+ stepSequence?: number
3933
+ }
4266
3934
 
4267
- // === Framework Operations (Automatic) ===
3935
+ interface ToolCallContext {
3936
+ type: 'tool'
3937
+ toolName: string
3938
+ parentIteration?: number
3939
+ parentStepId?: string
3940
+ }
4268
3941
 
4269
- /**
4270
- * Add entry to history (called by framework after tool results, reasoning, etc.)
4271
- * Automatically sets timestamp to current time
4272
- * @param entry - Memory entry to add (without timestamp - auto-generated)
4273
- */
4274
- addToHistory(entry: Omit<MemoryEntry, 'timestamp'>): void {
4275
- // Validate turnNumber is provided for history entries (use null for session memory)
4276
- if (entry.turnNumber === undefined && entry.type !== 'context') {
4277
- throw new AgentMemoryValidationError('turnNumber required for history entries (use null for session memory)', {
4278
- entryType: entry.type,
4279
- missingField: 'turnNumber',
4280
- iterationNumber: entry.iterationNumber
4281
- })
4282
- }
3942
+ interface OtherCallContext {
3943
+ type: 'other'
3944
+ description?: string
3945
+ metadata?: Record<string, unknown>
3946
+ }
4283
3947
 
4284
- // Truncate tool-result content if it exceeds the tool result token limit
4285
- let content = entry.content
4286
- if (entry.type === 'tool-result') {
4287
- const before = content
4288
- content = truncateToolResult(content, MAX_TOOL_RESULT_TOKENS)
4289
- if (content !== before) {
4290
- const truncateTime = Date.now()
4291
- this.logger?.action(
4292
- 'memory-tool-result-truncate',
4293
- `Tool result truncated (${estimateTokens(before)} -> ${MAX_TOOL_RESULT_TOKENS} tokens)`,
4294
- entry.iterationNumber ?? 0,
4295
- truncateTime,
4296
- truncateTime,
4297
- 0
4298
- )
4299
- }
4300
- }
3948
+ type AICallRecord = BaseAICall
4301
3949
 
4302
- this.memory.history.push({
4303
- ...entry,
4304
- content,
4305
- timestamp: Date.now()
4306
- })
4307
- // Auto-compact after adding (if needed)
4308
- this.autoCompact()
4309
- }
3950
+ // ============================================================================
3951
+ // API Request/Response Types (Dashboard Observability)
3952
+ // ============================================================================
4310
3953
 
4311
- /**
4312
- * Auto-compact history if approaching token budget
4313
- * Uses preserve-anchors strategy: keep first + recent entries
4314
- */
4315
- autoCompact(): void {
4316
- const status = this.getStatus()
4317
-
4318
- // Auto-compact when at 100% of token budget
4319
- if (status.historyPercent >= 100) {
4320
- const before = this.memory.history.length
4321
-
4322
- // Preserve-anchors strategy: first entry + last 10 entries
4323
- this.memory.history = [
4324
- this.memory.history[0], // First (original input)
4325
- ...this.memory.history.slice(-10) // Last 10
4326
- ]
4327
-
4328
- const compactTime = Date.now()
4329
- this.logger?.action(
4330
- 'memory-auto-compact',
4331
- `Auto-compacted: ${before} -> ${this.memory.history.length} entries`,
4332
- 0,
4333
- compactTime,
4334
- compactTime,
4335
- 0
4336
- )
4337
- }
4338
- }
4339
-
4340
- /**
4341
- * Enforce hard limits (called before LLM request)
4342
- * Emergency fallback if agent exceeds limits
4343
- */
4344
- enforceHardLimits(): void {
4345
- const maxSessionMemoryKeys = this.constraints.maxSessionMemoryKeys || MAX_SESSION_MEMORY_KEYS
4346
-
4347
- // Check session memory count
4348
- const sessionMemoryKeys = Object.keys(this.memory.sessionMemory)
4349
- if (sessionMemoryKeys.length > maxSessionMemoryKeys) {
4350
- const limitTime = Date.now()
4351
- this.logger?.action(
4352
- 'memory-limit-exceeded',
4353
- `Session memory exceeds hard limit (${sessionMemoryKeys.length}/${maxSessionMemoryKeys})`,
4354
- 0,
4355
- limitTime,
4356
- limitTime,
4357
- 0
4358
- )
4359
-
4360
- // Remove oldest entries by timestamp
4361
- const sorted = Object.entries(this.memory.sessionMemory).sort((a, b) => a[1].timestamp - b[1].timestamp)
4362
-
4363
- this.memory.sessionMemory = Object.fromEntries(sorted.slice(-maxSessionMemoryKeys))
4364
- }
4365
-
4366
- // Check total token budget (emergency compaction)
4367
- const status = this.getStatus()
4368
- const maxTokens = this.constraints.maxMemoryTokens || MAX_MEMORY_TOKENS
4369
-
4370
- if (status.historyTokens > maxTokens) {
4371
- const before = this.memory.history.length
4372
- const emergencyStartTime = Date.now()
4373
- this.logger?.action(
4374
- 'memory-emergency',
4375
- `Total memory exceeds token budget (${status.historyTokens}/${maxTokens}), forcing emergency compaction`,
4376
- 0,
4377
- emergencyStartTime,
4378
- emergencyStartTime,
4379
- 0
4380
- )
4381
-
4382
- // Emergency: Aggressively compact history
4383
- this.memory.history = [
4384
- this.memory.history[0],
4385
- ...this.memory.history.slice(-5) // Keep only last 5
4386
- ]
4387
-
4388
- const emergencyEndTime = Date.now()
4389
- this.logger?.action(
4390
- 'memory-emergency-compact',
4391
- `Emergency compaction: ${before} -> ${this.memory.history.length} entries`,
4392
- 0,
4393
- emergencyStartTime,
4394
- emergencyEndTime,
4395
- emergencyEndTime - emergencyStartTime
4396
- )
4397
- }
4398
- }
4399
-
4400
- /**
4401
- * Get history length (for logging and introspection)
4402
- * @returns Number of entries in history
4403
- */
4404
- getHistoryLength(): number {
4405
- return this.memory.history.length
4406
- }
4407
-
4408
- /**
4409
- * Get memory status for agent awareness
4410
- * @returns Memory status with token usage and key counts
4411
- */
4412
- getStatus(): MemoryStatus {
4413
- const sessionMemoryKeys = Object.keys(this.memory.sessionMemory)
4414
-
4415
- // Calculate tokens
4416
- const sessionMemoryContent = Object.values(this.memory.sessionMemory)
4417
- .map((entry) => entry.content)
4418
- .join('')
4419
- const historyContent = this.memory.history.map((entry) => entry.content).join('')
4420
- const sessionMemoryTokens = estimateTokens(sessionMemoryContent)
4421
- const historyTokens = estimateTokens(historyContent)
4422
- const totalTokens = sessionMemoryTokens + historyTokens
4423
-
4424
- // Token budget
4425
- const tokenBudget = this.constraints.maxMemoryTokens || MAX_MEMORY_TOKENS
4426
- const sessionMemoryLimit = this.constraints.maxSessionMemoryKeys || MAX_SESSION_MEMORY_KEYS
4427
-
4428
- return {
4429
- sessionMemoryKeys: sessionMemoryKeys.length,
4430
- sessionMemoryLimit,
4431
- currentKeys: sessionMemoryKeys,
4432
- historyPercent: Math.round((totalTokens / tokenBudget) * 100),
4433
- historyTokens: totalTokens,
4434
- tokenBudget
4435
- }
4436
- }
4437
-
4438
- /**
4439
- * Create memory snapshot for persistence
4440
- * Caches snapshot internally for later retrieval
4441
- * @returns Deep copy of current memory state
4442
- */
4443
- toSnapshot(): AgentMemory {
4444
- this.cachedSnapshot = structuredClone(this.memory)
4445
- return this.cachedSnapshot
4446
- }
4447
-
4448
- /**
4449
- * Get cached memory snapshot
4450
- * Returns snapshot created by toSnapshot()
4451
- * @returns Cached snapshot (undefined if toSnapshot() not called yet)
4452
- */
4453
- getSnapshot(): AgentMemory | undefined {
4454
- return this.cachedSnapshot
4455
- }
4456
-
4457
- /**
4458
- * Build context string for LLM
4459
- * Serializes sessionmemory + history memory with clear sections
4460
- * Shows current iteration entries FIRST (reverse chronological) for LLM attention
4461
- * @param currentIteration - Current iteration number (0 = pre-iteration)
4462
- * @param currentTurn - Current turn number (optional, for session context filtering)
4463
- * @returns Formatted memory context for LLM prompt
4464
- */
4465
- toContext(currentIteration: number, currentTurn?: number): string {
4466
- const status = this.getStatus()
4467
-
4468
- // Split by turn and iteration number
4469
- // DUAL FILTERING: Turn scope first (if provided), then iteration scope
4470
- // null iterations are session memory entries (excluded from history context)
4471
- // undefined/null turnNumbers are treated as legacy entries (pre-migration) or one-off executions
4472
- const currentContext = this.memory.history
4473
- .filter(
4474
- (entry) =>
4475
- (!currentTurn || entry.turnNumber === currentTurn || entry.turnNumber === undefined) &&
4476
- entry.iterationNumber === currentIteration
4477
- )
4478
- .reverse() // Most recent first (LLM positional bias)
4479
-
4480
- const earlierContext = this.memory.history.filter(
4481
- (entry) =>
4482
- (!currentTurn || entry.turnNumber === currentTurn || entry.turnNumber === undefined) &&
4483
- entry.iterationNumber !== null &&
4484
- entry.iterationNumber < currentIteration
4485
- )
4486
- // Earlier entries stay chronological
4487
-
4488
- // Format entry with simple label
4489
- const formatEntry = (entry: MemoryEntry): string => {
4490
- const label = `[${entry.type.toUpperCase()}]`
4491
- return `${label}\n${entry.content}`
4492
- }
4493
-
4494
- // Serialize session memory
4495
- const sessionMemoryContext = Object.entries(this.memory.sessionMemory)
4496
- .map(([key, entry]) => `[SESSION:${key}]\n${entry.content}`)
4497
- .join('\n\n')
4498
-
4499
- const currentSection = currentContext.map(formatEntry).join('\n\n')
4500
- const earlierSection =
4501
- earlierContext.length > 0 ? earlierContext.map(formatEntry).join('\n\n') : '(no earlier context)'
4502
-
4503
- return `
4504
- === MEMORY STATUS ===
4505
- ${status.sessionMemoryKeys}/${status.sessionMemoryLimit} session keys
4506
- ${status.historyPercent}% of token budget
4507
-
4508
- === SESSION MEMORY (Persists for conversation) ===
4509
- ${sessionMemoryContext || '(empty)'}
4510
-
4511
- === ITERATION ${currentIteration} - CURRENT CONTEXT ===
4512
-
4513
- ${currentSection}
4514
-
4515
- === EARLIER CONTEXT ===
4516
-
4517
- ${earlierSection}
4518
- `.trim()
4519
- }
4520
- }
4521
-
4522
- /**
4523
- * AIUsageCollector
4524
- * Centralized token tracking that aggregates usage across all LLM calls in an execution
4525
- */
4526
- declare class AIUsageCollector {
4527
- private model: LLMModel = 'gpt-5' // Default, will be overwritten on first record()
4528
- private calls: AICallRecord[] = []
4529
- private callSequence: number = 0
4530
-
4531
- /**
4532
- * Record a single AI call with usage metrics
4533
- *
4534
- * @param usage - Token usage and latency data from LLM adapter
4535
- * @param callType - Type discriminator (agent-reasoning, tool, etc.)
4536
- * @param context - Optional typed context specific to callType
4537
- */
4538
- record(usage: LLMUsageData, callType: BaseAICall['callType'] = 'other', context?: AICallContext): void {
4539
- this.callSequence++
4540
- this.model = usage.model
4541
-
4542
- // Use actual cost from provider (e.g., OpenRouter) if available, otherwise calculate
4543
- const costUsd = usage.cost ?? calculateCost(usage.model, usage.inputTokens, usage.outputTokens)
4544
-
4545
- this.calls.push({
4546
- callSequence: this.callSequence,
4547
- callType,
4548
- model: usage.model,
4549
- inputTokens: usage.inputTokens,
4550
- outputTokens: usage.outputTokens,
4551
- costUsd,
4552
- latencyMs: usage.latencyMs,
4553
- context
4554
- })
4555
- }
4556
-
4557
- /**
4558
- * Get aggregated summary of all AI calls
4559
- */
4560
- getSummary(): AIUsageSummary {
4561
- const totalInputTokens = this.calls.reduce((sum, c) => sum + c.inputTokens, 0)
4562
- const totalOutputTokens = this.calls.reduce((sum, c) => sum + c.outputTokens, 0)
4563
- const totalCostUsd = this.calls.reduce((sum, c) => sum + c.costUsd, 0)
4564
-
4565
- return {
4566
- model: this.model,
4567
- totalInputTokens,
4568
- totalOutputTokens,
4569
- totalTokens: totalInputTokens + totalOutputTokens,
4570
- totalCostUsd,
4571
- callCount: this.calls.length,
4572
- calls: this.calls
4573
- }
4574
- }
4575
-
4576
- /**
4577
- * Check if any usage has been recorded
4578
- */
4579
- hasUsage(): boolean {
4580
- return this.calls.length > 0
4581
- }
4582
- }
4583
-
4584
- /**
4585
- * MetricsCollector
4586
- * Tracks execution timing and ROI metrics
4587
- */
4588
- declare class MetricsCollector {
4589
- private timings: Map<string, number> = new Map()
4590
- private durationMs?: number
4591
-
4592
- /**
4593
- * Start a timer with a label
4594
- */
4595
- startTimer(label: string): void {
4596
- this.timings.set(label, Date.now())
4597
- }
4598
-
4599
- /**
4600
- * End a timer and calculate duration
4601
- * If label is 'execution', stores duration for metrics summary
4602
- */
4603
- endTimer(label: string): number | null {
4604
- const start = this.timings.get(label)
4605
- if (!start) return null
4606
-
4607
- const duration = Date.now() - start
4608
-
4609
- if (label === 'execution') {
4610
- this.durationMs = duration
4611
- }
4612
-
4613
- this.timings.delete(label)
4614
- return duration
4615
- }
4616
-
4617
- /**
4618
- * Build execution metrics summary with optional ROI calculation
4619
- */
4620
- buildExecutionMetrics(metricsConfig?: ResourceMetricsConfig): ExecutionMetricsSummary {
4621
- const automationSavingsUsd = metricsConfig
4622
- ? (metricsConfig.estimatedManualMinutes / 60) * metricsConfig.hourlyLaborRateUsd
4623
- : undefined
4624
-
4625
- return {
4626
- durationMs: this.durationMs,
4627
- automationSavingsUsd
4628
- }
4629
- }
4630
- }
4631
-
4632
- // ============================================================================
4633
- // AI Call Tracking Types (SSOT)
4634
- // ============================================================================
4635
-
4636
- interface BaseAICall {
4637
- callSequence: number // 1, 2, 3... (execution-wide universal counter)
4638
- callType: 'agent-reasoning' | 'agent-completion' | 'workflow-step' | 'tool' | 'other'
4639
- model: LLMModel
4640
- inputTokens: number
4641
- outputTokens: number
4642
- costUsd: number // Cost in USD with full decimal precision
4643
- latencyMs: number
4644
- context?: AICallContext
4645
- }
4646
-
4647
- type AICallContext =
4648
- | AgentReasoningContext
4649
- | AgentCompletionContext
4650
- | WorkflowStepContext
4651
- | ToolCallContext
4652
- | OtherCallContext
4653
-
4654
- interface AgentReasoningContext {
4655
- type: 'agent-reasoning'
4656
- iteration: number
4657
- actionsPlanned?: string[]
4658
- sessionId?: string
4659
- turnNumber?: number
4660
- }
4661
-
4662
- interface AgentCompletionContext {
4663
- type: 'agent-completion'
4664
- attempt: 1 | 2
4665
- validationFailed?: boolean
4666
- sessionId?: string
4667
- turnNumber?: number
4668
- }
4669
-
4670
- interface WorkflowStepContext {
4671
- type: 'workflow-step'
4672
- stepId: string
4673
- stepName?: string
4674
- stepSequence?: number
4675
- }
4676
-
4677
- interface ToolCallContext {
4678
- type: 'tool'
4679
- toolName: string
4680
- parentIteration?: number
4681
- parentStepId?: string
4682
- }
4683
-
4684
- interface OtherCallContext {
4685
- type: 'other'
4686
- description?: string
4687
- metadata?: Record<string, unknown>
4688
- }
4689
-
4690
- type AICallRecord = BaseAICall
4691
-
4692
- // ============================================================================
4693
- // LLM Usage Data (from adapters)
4694
- // ============================================================================
4695
-
4696
- /**
4697
- * Raw LLM usage data returned by adapters
4698
- * Used as input to AIUsageCollector.record()
4699
- */
4700
- interface LLMUsageData {
4701
- model: LLMModel
4702
- inputTokens: number
4703
- outputTokens: number
4704
- latencyMs: number
4705
- /** Actual cost from provider in USD (when available, e.g., OpenRouter) */
4706
- cost?: number
4707
- }
4708
-
4709
- // ============================================================================
4710
- // AI Usage Summary
4711
- // ============================================================================
4712
-
4713
- interface AIUsageSummary {
4714
- model: LLMModel
4715
- totalInputTokens: number
4716
- totalOutputTokens: number
4717
- totalTokens: number
4718
- totalCostUsd: number // Total cost in USD with full decimal precision
4719
- callCount: number
4720
- calls: AICallRecord[]
4721
- }
4722
-
4723
- // ============================================================================
4724
- // Execution Metrics
4725
- // ============================================================================
4726
-
4727
- interface ExecutionMetricsSummary {
4728
- durationMs?: number
4729
- automationSavingsUsd?: number // Automation savings in USD with full decimal precision
4730
- }
4731
-
4732
- // ============================================================================
4733
- // Resource Metrics Configuration
4734
- // ============================================================================
4735
-
4736
- interface ResourceMetricsConfig {
4737
- estimatedManualMinutes: number
4738
- hourlyLaborRateUsd: number // Hourly rate in USD (e.g., 75.00 for $75/hour)
4739
- confidenceLevel?: 'low' | 'medium' | 'high'
4740
- notes?: string
4741
- }
4742
-
4743
- // ============================================================================
4744
- // API Request/Response Types (Dashboard Observability)
4745
- // ============================================================================
4746
-
4747
- /**
4748
- * Time range selector for dashboard metrics
4749
- */
4750
- type TimeRange = '1h' | '24h' | '7d' | '30d'
3954
+ /**
3955
+ * Time range selector for dashboard metrics
3956
+ */
3957
+ type TimeRange = '1h' | '24h' | '7d' | '30d'
4751
3958
 
4752
3959
  /**
4753
3960
  * Execution health metrics response
@@ -5049,353 +4256,6 @@ interface CostByModelResponse {
5049
4256
  totalCallCount: number
5050
4257
  }
5051
4258
 
5052
- /**
5053
- * Knowledge Map Types
5054
- *
5055
- * Enables agents to navigate organizational knowledge through a lightweight
5056
- * graph that lazy-loads capabilities on-demand.
5057
- *
5058
- * @module agent/knowledge-map
5059
- */
5060
-
5061
-
5062
-
5063
- /**
5064
- * Lightweight knowledge map (passed as agent property)
5065
- *
5066
- * Contains metadata about available knowledge nodes without loading
5067
- * the full content upfront. Total size: ~300-500 tokens.
5068
- *
5069
- * Multi-tenancy is enforced via:
5070
- * - File-scoped maps (organizations/{org-name}/knowledge/)
5071
- * - ExecutionContext.organizationId passed to node.load()
5072
- */
5073
- interface KnowledgeMap {
5074
- /** Available knowledge nodes indexed by ID */
5075
- nodes: Record<string, KnowledgeNode>
5076
- }
5077
-
5078
- /**
5079
- * Single knowledge source
5080
- *
5081
- * Represents a domain knowledge area (CRM, brand guidelines, Excel tools)
5082
- * that can be lazy-loaded to provide instructions and tools to agents.
5083
- */
5084
- interface KnowledgeNode {
5085
- /** Unique identifier for this node (e.g., "crm", "brand-guidelines") */
5086
- id: string
5087
-
5088
- /**
5089
- * Description of when to use this knowledge
5090
- * Used for semantic matching against user intent
5091
- */
5092
- description: string
5093
-
5094
- /**
5095
- * Load knowledge content on-demand
5096
- *
5097
- * @param context - Execution context with organizationId for multi-tenancy
5098
- * @returns Promise resolving to knowledge content (prompt + optional tools)
5099
- */
5100
- load(context: ExecutionContext): Promise<KnowledgeContent>
5101
-
5102
- /**
5103
- * Loaded state flag
5104
- * Set to true after load() is called
5105
- */
5106
- loaded?: boolean
5107
-
5108
- /**
5109
- * Cached prompt (for system prompt serialization)
5110
- * Only the prompt is cached - tools go to toolRegistry, children flattened to nodes
5111
- */
5112
- prompt?: string
5113
- }
5114
-
5115
- /**
5116
- * Content returned by knowledge node
5117
- *
5118
- * Separates instructions (prompt) from capabilities (tools).
5119
- * Tools are optional - some nodes only provide context.
5120
- *
5121
- * Supports recursive navigation - nodes can contain child nodes
5122
- * that are discovered when the parent node is loaded.
5123
- */
5124
- interface KnowledgeContent {
5125
- /** Instructions and context (markdown format) */
5126
- prompt: string
5127
-
5128
- /** Tool implementations (optional) */
5129
- tools?: Tool[]
5130
-
5131
- /**
5132
- * Child knowledge nodes (optional, recursive)
5133
- *
5134
- * Enables hierarchical navigation: base → specialized → deep expertise.
5135
- * Child nodes are flattened into the main knowledge map when parent loads,
5136
- * making them available for subsequent navigate-knowledge actions.
5137
- *
5138
- * Example: CRM base node returns crm-customers and crm-deals as children
5139
- */
5140
- nodes?: Record<string, KnowledgeNode>
5141
- }
5142
-
5143
- /**
5144
- * Execution interface configuration
5145
- * Defines how a resource is executed via the UI (forms, scheduling, webhooks)
5146
- * Applies to both agents and workflows
5147
- */
5148
- interface ExecutionInterface {
5149
- /** Form configuration for execution inputs */
5150
- form: ExecutionFormSchema
5151
-
5152
- /** Optional: Schedule configuration */
5153
- schedule?: ScheduleConfig
5154
-
5155
- /** Optional: Webhook trigger configuration */
5156
- webhook?: WebhookConfig
5157
- }
5158
-
5159
- /**
5160
- * Execution form schema
5161
- * Extends FormSchema with execution-specific fields
5162
- */
5163
- interface ExecutionFormSchema extends FormSchema {
5164
- /**
5165
- * Field mappings to resource input schema
5166
- * Maps form field names to contract input paths
5167
- * If omitted, field names must match contract input keys exactly
5168
- */
5169
- fieldMappings?: Record<string, string>
5170
-
5171
- /**
5172
- * Submit button configuration
5173
- * Default: { label: 'Run', loadingLabel: 'Running...' }
5174
- */
5175
- submitButton?: {
5176
- label?: string
5177
- loadingLabel?: string
5178
- confirmMessage?: string // Optional confirmation dialog
5179
- }
5180
- }
5181
-
5182
- /**
5183
- * Schedule configuration for automated execution
5184
- */
5185
- interface ScheduleConfig {
5186
- /** Whether scheduling is enabled for this resource */
5187
- enabled: boolean
5188
- /** Default schedule (cron expression) */
5189
- defaultSchedule?: string
5190
- /** Allowed schedule patterns (if restricted) */
5191
- allowedPatterns?: string[]
5192
- }
5193
-
5194
- /**
5195
- * Webhook configuration for external triggers
5196
- */
5197
- interface WebhookConfig {
5198
- /** Whether webhook trigger is enabled */
5199
- enabled: boolean
5200
- /** Expected payload schema (for documentation) */
5201
- payloadSchema?: unknown
5202
- }
5203
-
5204
- /**
5205
- * Agent-specific type definitions
5206
- * Types for autonomous agents with tools, memory, and constraints
5207
- */
5208
-
5209
-
5210
-
5211
- /**
5212
- * Factory function for creating LLM adapters.
5213
- * Injected into the Agent class to decouple the engine from server-only provider SDKs.
5214
- * - API process: provides createLLMAdapter (real SDKs + process.env API keys)
5215
- * - SDK worker: provides PostMessageLLMAdapter (proxies via platform.call)
5216
- *
5217
- * Uses `any` for optional params so both the real createLLMAdapter (with typed
5218
- * AIUsageCollector/AICallContext) and the worker proxy (which ignores them) satisfy the type.
5219
- */
5220
- type LLMAdapterFactory = (
5221
- config: ModelConfig,
5222
- ...args: any[]
5223
- ) => LLMAdapter
5224
-
5225
- // Agent configuration
5226
- interface AgentConfig extends ResourceDefinition {
5227
- type: 'agent'
5228
-
5229
- // Agent behavior
5230
- systemPrompt: string // System prompt defining agent behavior
5231
-
5232
- // Execution constraints (simplified for v1)
5233
- constraints?: AgentConstraints
5234
-
5235
- /**
5236
- * Session capability declaration (opt-in)
5237
- * If true, agent is designed for multi-turn session interactions
5238
- * Controls whether agent can use message action and appears in Sessions UI
5239
- *
5240
- * Use for:
5241
- * - Conversational agents with multi-turn interactions
5242
- * - Agents requiring persistent context across turns
5243
- * - Agents that need human-in-the-loop communication
5244
- */
5245
- sessionCapable?: boolean
5246
-
5247
- /**
5248
- * Security level for system prompt hardening (auto-derived if omitted)
5249
- *
5250
- * - 'standard': Lightweight defense (3 rules) - default for non-session agents
5251
- * - 'hardened': Comprehensive defense (6 rules) - default for session-capable agents
5252
- * - 'none': No security prompt - for pure internal agents with no external input
5253
- *
5254
- * If omitted, derived from sessionCapable:
5255
- * sessionCapable: true -> 'hardened'
5256
- * sessionCapable: false -> 'standard'
5257
- */
5258
- securityLevel?: 'standard' | 'hardened' | 'none'
5259
-
5260
- /**
5261
- * Memory management preferences (opt-in)
5262
- * If provided, agent can use memoryOps to manage session memory
5263
- * If omitted, agent has no memory management capabilities
5264
- *
5265
- * Agent-specific guidance on what to preserve, when to persist, and what to clean up.
5266
- * This guidance is injected into the system prompt when memory management is enabled.
5267
- *
5268
- * Use for:
5269
- * - Conversational agents needing cross-turn context
5270
- * - Agents managing complex user preferences
5271
- * - Agents tracking decisions over multiple iterations
5272
- */
5273
- memoryPreferences?: string
5274
-
5275
- // Lifecycle callbacks for observability (optional) - DEFERRED
5276
- }
5277
-
5278
- // Execution constraints to prevent runaway agents
5279
- interface AgentConstraints {
5280
- // Agent execution control
5281
- maxIterations?: number // Prevent infinite loops
5282
- timeout?: number // Execution time limit (ms)
5283
-
5284
- // Memory constraints
5285
- maxSessionMemoryKeys?: number // Max session memory keys (default: 10)
5286
- maxMemoryTokens?: number // Total token budget for all memory (default: 14000)
5287
- }
5288
-
5289
- // Agent definition - pure configuration without instance state
5290
- // Used by registry to define agents that can be instantiated with fresh memory
5291
- interface AgentDefinition {
5292
- config: AgentConfig
5293
- contract: Contract
5294
- tools: Tool[]
5295
-
5296
- /**
5297
- * Model configuration for LLM execution
5298
- * Specifies provider, API key, and model-specific options
5299
- */
5300
- modelConfig: ModelConfig
5301
-
5302
- /**
5303
- * Optional knowledge map for lazy-loading capabilities
5304
- * Enables agents to navigate organizational knowledge on-demand
5305
- */
5306
- knowledgeMap?: KnowledgeMap
5307
-
5308
- /**
5309
- * Preload memory before execution starts
5310
- * Handles BOTH context loading AND session restoration
5311
- *
5312
- * @param context - Execution context (includes sessionId if session turn)
5313
- * @returns Initial AgentMemory state (sessionMemory entries + optionally history)
5314
- */
5315
- preloadMemory?: (context: ExecutionContext) => Promise<AgentMemory> | AgentMemory
5316
-
5317
- /**
5318
- * Metrics configuration for ROI calculations
5319
- * Optional: Only needed if tracking automation savings
5320
- */
5321
- metricsConfig?: ResourceMetricsConfig
5322
-
5323
- /**
5324
- * Execution interface configuration (optional)
5325
- * If provided, agent appears in Execution Runner UI
5326
- */
5327
- interface?: ExecutionInterface
5328
- }
5329
-
5330
- /**
5331
- * Agent execution context
5332
- * Groups all state needed for agent execution phases
5333
- */
5334
- interface IterationContext {
5335
- config: AgentConfig
5336
- contract: Contract
5337
- toolRegistry: Map<string, Tool>
5338
- memoryManager: MemoryManager
5339
- executionContext: ExecutionContext
5340
- iteration: number
5341
- logger: AgentScopedLogger
5342
- modelConfig: ModelConfig
5343
- adapterFactory: LLMAdapterFactory
5344
- knowledgeMap?: KnowledgeMap
5345
- }
5346
-
5347
- /**
5348
- * Tool definitions
5349
- *
5350
- * Tool interface used by agents and workflows.
5351
- * Provides a universal interface for AI systems to interact with tools.
5352
- */
5353
-
5354
-
5355
-
5356
- /**
5357
- * Options for tool execution
5358
- * Provides named parameters for better API clarity and extensibility
5359
- */
5360
- interface ToolExecutionOptions {
5361
- /** Tool input (validated against inputSchema before execution) */
5362
- input: unknown
5363
-
5364
- /** Execution context with multi-tenant isolation and observability (optional for simple tools, required for platform/integration tools) */
5365
- executionContext?: ExecutionContext
5366
-
5367
- /** Full iteration context for advanced tools (provides access to memoryManager, toolRegistry, logger, etc.) */
5368
- iterationContext?: IterationContext
5369
-
5370
- /** Abort signal for timeout/cancellation -- forward to fetch() calls for clean cancellation */
5371
- signal?: AbortSignal
5372
- }
5373
-
5374
- /**
5375
- * Tool interface for AI systems
5376
- *
5377
- * Used by:
5378
- * - Agents: For agentic tool use (reasoning loop selects and executes tools)
5379
- * - Workflows: For workflow step tool invocation (future)
5380
- * - Platform tools: createApprovalTool(), createSchedulerTool()
5381
- * - Integration tools: External API calls (Gmail, Slack, etc.)
5382
- */
5383
- interface Tool {
5384
- // Required fields
5385
- name: string // Unique identifier (e.g., 'web_search', 'calculator')
5386
- description: string // What the tool does (used by LLM for selection)
5387
-
5388
- // I/O validation (both required for complete type safety)
5389
- inputSchema: z.ZodSchema // Input validation schema
5390
- outputSchema: z.ZodSchema // Output validation schema
5391
-
5392
- // Execution
5393
- execute: (options: ToolExecutionOptions) => Promise<unknown>
5394
-
5395
- // Timeout (optional) -- per-tool override in ms, defaults to DEFAULT_TOOL_TIMEOUT (300_000 / 5min) in executor
5396
- timeout?: number
5397
- }
5398
-
5399
4259
  /**
5400
4260
  * Action configuration for HITL tasks
5401
4261
  * Defines available user actions and their behavior
@@ -6329,164 +5189,6 @@ interface SerializedWorkflowDefinition {
6329
5189
  interface?: SerializedExecutionInterface
6330
5190
  }
6331
5191
 
6332
- /**
6333
- * Base Execution Engine type definitions
6334
- * Core types shared across all Execution Engine resources
6335
- */
6336
-
6337
-
6338
-
6339
- /**
6340
- * Immutable execution metadata
6341
- * Represents complete execution identity (who, what, when, where)
6342
- * Shared across ExecutionContext and ExecutionLoggerContext to eliminate field duplication
6343
- */
6344
- interface ExecutionMetadata {
6345
- executionId: string // Unique ID for this execution instance
6346
- organizationId: string // Required for multi-tenant isolation and security
6347
- organizationName: string // Required for resource lookup in registry
6348
- resourceId: string // Required for observability and audit trails
6349
- userId?: string // Optional: user context for audit trails (API keys, system executions may not have userId)
6350
- sessionId?: string // Optional: only for session executions
6351
- sessionTurnNumber?: number // Optional: only for session executions (maps to execution_logs.session_turn_number)
6352
- }
6353
-
6354
- /**
6355
- * Unified message event type - covers all message types in sessions
6356
- * Replaces separate SessionTurnMessages and AgentActivityEvent mechanisms
6357
- */
6358
- /**
6359
- * Structured action metadata attached to assistant messages.
6360
- * Frontend reads this instead of parsing text prefixes.
6361
- */
6362
- type AssistantAction =
6363
- | { kind: 'navigate'; path: string; reason: string }
6364
- | {
6365
- kind: 'update_filters'
6366
- timeRange: string | null
6367
- statusFilter: string | null
6368
- searchQuery: string | null
6369
- }
6370
-
6371
- type MessageEvent =
6372
- // User/Assistant text messages
6373
- | { type: 'user_message'; text: string }
6374
- | { type: 'assistant_message'; text: string; _action?: AssistantAction }
6375
-
6376
- // Agent lifecycle events
6377
- | { type: 'agent:started' }
6378
- | { type: 'agent:completed' }
6379
- | { type: 'agent:error'; error: string }
6380
-
6381
- // Agent activity events (with metadata for UI)
6382
- | { type: 'agent:reasoning'; iteration: number; reasoning: string }
6383
- | { type: 'agent:tool_call'; toolName: string; args: Record<string, unknown> }
6384
- | { type: 'agent:tool_result'; toolName: string; success: boolean; result?: unknown; error?: string }
6385
-
6386
- /**
6387
- * Execution context for all resources
6388
- * Unified callback replaces SessionTurnMessages (removed)
6389
- */
6390
- interface ExecutionContext extends ExecutionMetadata {
6391
- // Inherited: executionId, organizationId, organizationName, resourceId, userId, sessionId, sessionTurnNumber
6392
- logger: IExecutionLogger // Required for observability and debugging
6393
- signal?: AbortSignal // Future: cancellation support for long-running operations
6394
-
6395
- // Unified message event callback (immediate persistence + streaming)
6396
- onMessageEvent?: (event: MessageEvent) => Promise<void>
6397
-
6398
- /** Called per iteration to write heartbeat + check stall status. Non-fatal if it throws. */
6399
- onHeartbeat?: () => Promise<void>
6400
-
6401
- // Observability collectors (optional - injected by coordinators)
6402
- aiUsageCollector?: AIUsageCollector // Tracks AI token usage and costs
6403
- metricsCollector?: MetricsCollector // Tracks execution timing and ROI metrics
6404
-
6405
- // Nested execution tracking (Wave 2c - Agent Resource Invocation)
6406
- parentExecutionId?: string // Parent execution ID for nested invocations
6407
- executionDepth: number // Nesting depth: 0 = top-level, 1+ = nested
6408
-
6409
- // Integration credential tracking (for OAuth token refresh persistence)
6410
- credentialName?: string // Credential name used for current integration call
6411
-
6412
- // Execution-scoped storage for large data (e.g., PDF buffers) that shouldn't be logged
6413
- // Automatically garbage collected when execution context ends
6414
- store: Map<string, unknown>
6415
- }
6416
-
6417
- // Contract definition - validation schemas (Zod)
6418
- interface Contract {
6419
- inputSchema: z.ZodSchema // Required - use z.object({}) for no input
6420
- outputSchema?: z.ZodSchema // Optional - if present, agent generates output
6421
- }
6422
-
6423
- // Workflow configuration
6424
- interface WorkflowConfig extends ResourceDefinition {
6425
- type: 'workflow'
6426
- }
6427
-
6428
- // Workflow step definition
6429
- interface WorkflowStepDefinition {
6430
- id: string
6431
- name: string
6432
- description: string
6433
- }
6434
-
6435
- // Step handler function type
6436
- type StepHandler = (input: unknown, context: ExecutionContext) => Promise<unknown>
6437
-
6438
- // Next step configuration types
6439
- interface LinearNext {
6440
- type: 'linear'
6441
- target: string
6442
- }
6443
-
6444
- interface ConditionalNext {
6445
- type: 'conditional'
6446
- routes: Array<{
6447
- condition: (data: unknown) => boolean
6448
- target: string
6449
- }>
6450
- default: string // Required to avoid ambiguity
6451
- }
6452
-
6453
- type NextConfig =
6454
- | LinearNext // Go to specific step
6455
- | ConditionalNext // Conditional routing
6456
- | null // Explicitly end workflow
6457
-
6458
- // Workflow step with graph-based flow
6459
- interface WorkflowStep extends WorkflowStepDefinition {
6460
- handler: StepHandler
6461
-
6462
- // I/O validation (BOTH REQUIRED for complete type safety)
6463
- inputSchema: z.ZodSchema // Validates input from previous step or workflow
6464
- outputSchema: z.ZodSchema // Validates output before next step
6465
-
6466
- next: NextConfig // Required - explicit flow decision for every step
6467
- }
6468
-
6469
- // Workflow definition - pure configuration without instance state
6470
- // Used by registry to define workflows that can be instantiated
6471
- interface WorkflowDefinition {
6472
- config: WorkflowConfig
6473
- contract: Contract
6474
- steps: Record<string, WorkflowStep>
6475
- entryPoint: string
6476
-
6477
- /**
6478
- * Metrics configuration for ROI calculations
6479
- * Optional: Only needed if tracking automation savings
6480
- */
6481
- metricsConfig?: ResourceMetricsConfig
6482
-
6483
- /**
6484
- * Execution interface configuration (optional)
6485
- * If provided, workflow appears in Execution Runner UI
6486
- */
6487
- interface?: ExecutionInterface
6488
- }
6489
-
6490
5192
  /**
6491
5193
  * Agent timeline and observability types
6492
5194
  * Used for UI timeline visualization and backend processing
@@ -6688,378 +5390,6 @@ declare const ExecutionHistoryResponseSchema = z.object({
6688
5390
  type ExecutionHistoryItem = z.infer<typeof ExecutionHistoryItemSchema>
6689
5391
  type ExecutionHistoryResponse = z.infer<typeof ExecutionHistoryResponseSchema>
6690
5392
 
6691
- /**
6692
- * Calibration Lab Type Definitions
6693
- * Core types for AI model configuration optimization with cost/performance comparison
6694
- */
6695
-
6696
-
6697
-
6698
- // ============================================================================
6699
- // Calibration Project Types
6700
- // ============================================================================
6701
-
6702
- /**
6703
- * Calibration project - groups related optimization runs
6704
- * Provides organizational structure for iterative testing
6705
- */
6706
- interface CalibrationProject {
6707
- id: string
6708
- organizationId: string
6709
- resourceId: string
6710
- resourceType: 'agent' | 'workflow'
6711
- name: string
6712
- description?: string | null
6713
- createdAt: Date
6714
- updatedAt: Date
6715
- }
6716
-
6717
- // ============================================================================
6718
- // Configuration Variant Types
6719
- // ============================================================================
6720
-
6721
- /**
6722
- * Configuration variant for testing
6723
- * Defines what to override in the base agent/workflow definition
6724
- */
6725
- interface ConfigVariant {
6726
- variantName: string
6727
- definitionOverrides?: AgentCalibrationOverrides | WorkflowCalibrationOverrides
6728
- }
6729
-
6730
- /**
6731
- * Agent definition overrides for calibration
6732
- * Excludes identity/metadata fields that should not be modified
6733
- */
6734
- type AgentCalibrationOverrides = Omit<
6735
- Partial<AgentDefinition>,
6736
- 'config' | 'contract' | 'tools' | 'metricsConfig' | 'interface'
6737
- >
6738
-
6739
- /**
6740
- * Workflow definition overrides for calibration
6741
- * Excludes identity/metadata fields that should not be modified
6742
- */
6743
- type WorkflowCalibrationOverrides = Omit<
6744
- Partial<WorkflowDefinition>,
6745
- 'config' | 'contract' | 'steps' | 'entryPoint' | 'metricsConfig' | 'interface'
6746
- >
6747
-
6748
- // ============================================================================
6749
- // Grading System Types
6750
- // ============================================================================
6751
-
6752
- /**
6753
- * Grading rubric for LLM-as-judge evaluation
6754
- * Defines criteria and passing threshold
6755
- */
6756
- interface GradingRubric {
6757
- passingThreshold: number // 0-1, e.g., 0.7 means 70% to pass
6758
- criteria: GradingCriterion[]
6759
- }
6760
-
6761
- /**
6762
- * Individual grading criterion
6763
- * Weight should be 0-1, and all weights should sum to 1
6764
- */
6765
- interface GradingCriterion {
6766
- name: string
6767
- weight: number // 0-1, weights should sum to 1
6768
- description: string
6769
- scoringGuide: string
6770
- }
6771
-
6772
- /**
6773
- * Grading result for a single execution or session
6774
- * Contains overall score and per-criterion breakdown
6775
- */
6776
- interface GradeResult {
6777
- score: number // 0-1
6778
- passed: boolean
6779
- details: Record<string, { score: number; justification: string }>
6780
- }
6781
-
6782
- // ============================================================================
6783
- // Result Types
6784
- // ============================================================================
6785
-
6786
- /**
6787
- * Single-turn calibration result
6788
- * One result per (variant × input) combination
6789
- */
6790
- interface SingleCalibrationResult {
6791
- executionId: string // Reference to execution_logs
6792
- variantName: string
6793
- inputIndex: number // Which input from testInputs array (0-based)
6794
- appliedOverrides?: AgentCalibrationOverrides | WorkflowCalibrationOverrides
6795
- status: 'pending' | 'running' | 'completed' | 'failed'
6796
- errorMessage?: string
6797
- grade?: GradeResult
6798
- gradeError?: string
6799
- }
6800
-
6801
- /**
6802
- * Multi-turn session calibration result
6803
- * Leverages existing sessions infrastructure
6804
- */
6805
- interface SessionCalibrationResult {
6806
- sessionId: string // Reference to sessions table
6807
- variantName: string
6808
- appliedOverrides?: AgentCalibrationOverrides | WorkflowCalibrationOverrides
6809
- status: 'pending' | 'running' | 'completed' | 'failed'
6810
- errorMessage?: string
6811
- turnCount: number
6812
- grade?: GradeResult
6813
- gradeError?: string
6814
- }
6815
-
6816
- // ============================================================================
6817
- // Calibration Run Types
6818
- // ============================================================================
6819
-
6820
- /**
6821
- * Calibration run - individual test execution within a project
6822
- * Contains configuration, results, and grading information
6823
- */
6824
- interface CalibrationRun {
6825
- id: string
6826
- organizationId: string
6827
- projectId: string
6828
- name: string
6829
- description?: string | null
6830
- executionMode: 'single' | 'session'
6831
- testInputs: unknown[]
6832
- configVariants: ConfigVariant[]
6833
- gradingRubric?: GradingRubric | null
6834
- graderModel?: string | null
6835
- results: (SingleCalibrationResult | SessionCalibrationResult)[]
6836
- status: 'pending' | 'running' | 'completed' | 'partial' | 'failed'
6837
- createdAt: Date
6838
- completedAt?: Date | null
6839
- }
6840
-
6841
- // ============================================================================
6842
- // Combined Response Types
6843
- // ============================================================================
6844
-
6845
- /**
6846
- * Execution log subset for comparison view
6847
- * Contains essential data without full execution context
6848
- */
6849
- interface ExecutionLog {
6850
- executionId: string
6851
- status: 'running' | 'completed' | 'failed'
6852
- input: unknown
6853
- output: unknown | null
6854
- error: CalibrationExecutionError | null
6855
- startedAt: string
6856
- completedAt: string | null
6857
- }
6858
-
6859
- /**
6860
- * Execution error information for calibration display
6861
- * Subset of full execution error for UI display purposes
6862
- * Named differently from ExecutionError class to avoid type conflicts
6863
- */
6864
- interface CalibrationExecutionError {
6865
- message: string
6866
- category?: string
6867
- type?: string
6868
- }
6869
-
6870
- /**
6871
- * Combined calibration run data for comparison view
6872
- * Single API call returns run + execution logs + metrics
6873
- */
6874
- interface CalibrationRunWithFullData {
6875
- run: CalibrationRun
6876
- logs: Record<string, ExecutionLog> // keyed by executionId
6877
- metrics: Record<string, ExecutionMetricsDetail> // keyed by executionId
6878
- }
6879
-
6880
- // ============================================================================
6881
- // Calibration Project Schemas
6882
- // ============================================================================
6883
-
6884
- /**
6885
- * Create calibration project schema
6886
- * Validates request body for creating a new calibration project
6887
- */
6888
- declare const CreateCalibrationProjectSchema = z.object({
6889
- resourceId: z.string().min(1),
6890
- resourceType: z.enum(['agent', 'workflow']),
6891
- name: z.string().min(1),
6892
- description: z.string().optional()
6893
- })
6894
-
6895
- /**
6896
- * Update calibration project schema
6897
- * Validates request body for updating an existing calibration project
6898
- */
6899
- declare const UpdateCalibrationProjectSchema = z.object({
6900
- name: z.string().min(1).optional(),
6901
- description: z.string().optional()
6902
- })
6903
-
6904
- // ============================================================================
6905
- // Calibration Run Schemas
6906
- // ============================================================================
6907
-
6908
- /**
6909
- * Create calibration run schema
6910
- * Validates request body for creating a new calibration run
6911
- * Includes refinement for graderModel requirement when gradingRubric is provided
6912
- */
6913
- declare const CreateCalibrationRunSchema = z
6914
- .object({
6915
- projectId: z.string().uuid(),
6916
- name: z.string().min(1),
6917
- description: z.string().optional(),
6918
- executionMode: z.enum(['single', 'session']).default('single'),
6919
- testInputs: z.array(z.unknown()).min(1).max(50), // Min 1, max 50 inputs
6920
- configVariants: z.array(ConfigVariantSchema).min(1).max(10), // Min 1, max 10 variants
6921
- gradingRubric: GradingRubricSchema.optional(),
6922
- graderModel: LLMModelSchema.optional()
6923
- })
6924
- .refine((data) => !data.gradingRubric || data.graderModel, {
6925
- message: 'graderModel is required when gradingRubric is provided'
6926
- })
6927
-
6928
-
6929
- // ============================================================================
6930
- // Inferred Types
6931
- // ============================================================================
6932
-
6933
- type CreateCalibrationProjectInput = z.infer<typeof CreateCalibrationProjectSchema>
6934
- type UpdateCalibrationProjectInput = z.infer<typeof UpdateCalibrationProjectSchema>
6935
- type CreateCalibrationRunInput = z.infer<typeof CreateCalibrationRunSchema>
6936
-
6937
- /**
6938
- * Calibration SSE Event Types
6939
- *
6940
- * Shared event type definitions for calibration real-time streaming.
6941
- * Used by both the API broadcaster and the command-center UI.
6942
- */
6943
-
6944
- // Single-turn events
6945
-
6946
- interface CalibrationExecutionStartedEvent {
6947
- type: 'execution-started'
6948
- variantName: string
6949
- inputIndex: number
6950
- timestamp: number
6951
- }
6952
-
6953
- interface CalibrationExecutionCompletedEvent {
6954
- type: 'execution-completed'
6955
- variantName: string
6956
- inputIndex: number
6957
- executionId: string
6958
- timestamp: number
6959
- }
6960
-
6961
- interface CalibrationExecutionFailedEvent {
6962
- type: 'execution-failed'
6963
- variantName: string
6964
- inputIndex?: number
6965
- error: string
6966
- timestamp: number
6967
- }
6968
-
6969
- // Session events
6970
-
6971
- interface CalibrationSessionStartedEvent {
6972
- type: 'session-started'
6973
- variantName: string
6974
- sessionId: string
6975
- timestamp: number
6976
- }
6977
-
6978
- interface CalibrationTurnStartedEvent {
6979
- type: 'turn-started'
6980
- variantName: string
6981
- turnNumber: number
6982
- timestamp: number
6983
- }
6984
-
6985
- interface CalibrationTurnCompletedEvent {
6986
- type: 'turn-completed'
6987
- variantName: string
6988
- turnNumber: number
6989
- executionId: string
6990
- timestamp: number
6991
- }
6992
-
6993
- interface CalibrationSessionCompletedEvent {
6994
- type: 'session-completed'
6995
- variantName: string
6996
- sessionId: string
6997
- turnCount: number
6998
- timestamp: number
6999
- }
7000
-
7001
- // Grading events
7002
-
7003
- interface CalibrationGradingStartedEvent {
7004
- type: 'grading-started'
7005
- variantName: string
7006
- timestamp: number
7007
- }
7008
-
7009
- interface CalibrationGradingCompletedEvent {
7010
- type: 'grading-completed'
7011
- variantName: string
7012
- score: number
7013
- timestamp: number
7014
- }
7015
-
7016
- interface CalibrationGradingFailedEvent {
7017
- type: 'grading-failed'
7018
- variantName: string
7019
- error: string
7020
- timestamp: number
7021
- }
7022
-
7023
- // Completion events
7024
-
7025
- interface CalibrationCompletedEvent {
7026
- type: 'calibration-completed'
7027
- summary: { total: number; completed: number; failed: number }
7028
- timestamp: number
7029
- }
7030
-
7031
- interface CalibrationFailedEvent {
7032
- type: 'calibration-failed'
7033
- error: string
7034
- timestamp: number
7035
- }
7036
-
7037
- // Connection event
7038
-
7039
- interface CalibrationConnectedEvent {
7040
- type: 'connected'
7041
- timestamp: number
7042
- data?: undefined
7043
- }
7044
-
7045
- /**
7046
- * Union of all calibration SSE events
7047
- */
7048
- type CalibrationSSEEvent =
7049
- | CalibrationExecutionStartedEvent
7050
- | CalibrationExecutionCompletedEvent
7051
- | CalibrationExecutionFailedEvent
7052
- | CalibrationSessionStartedEvent
7053
- | CalibrationTurnStartedEvent
7054
- | CalibrationTurnCompletedEvent
7055
- | CalibrationSessionCompletedEvent
7056
- | CalibrationGradingStartedEvent
7057
- | CalibrationGradingCompletedEvent
7058
- | CalibrationGradingFailedEvent
7059
- | CalibrationCompletedEvent
7060
- | CalibrationFailedEvent
7061
- | CalibrationConnectedEvent
7062
-
7063
5393
  /**
7064
5394
  * Command Queue SSE Event Types
7065
5395
  *
@@ -7402,4 +5732,4 @@ interface CommandViewStatsResponse {
7402
5732
  generatedAt: string
7403
5733
  }
7404
5734
 
7405
- export type { AIResourceDefinition, APIExecutionDetail, APIExecutionListResponse, APIExecutionSummary, AbsoluteScheduleConfig, AbsoluteScheduleItem, ActionConfig, Activity, ActivitySSEEvent, ActivityStatus, ActivityType, AgentIterationData, AgentMemory, ApiKeyListItem, BusinessImpactMetrics, CalibrationProject, CalibrationRun, CalibrationRunWithFullData, CalibrationSSEEvent, ChatMessage, CheckpointListResponse, CommandQueueSSEEvent, CommandViewAgent, CommandViewData, CommandViewNode, CommandViewNodeType, CommandViewStatsResponse, CommandViewWorkflow, ConfigVariant, CostBreakdownMetrics, CostByModelResponse, CostSummaryResponse, CostTrendsResponse, CreateCalibrationProjectInput, CreateCalibrationRunInput, CreateWebhookEndpointRequest, CredentialListItem, DashboardMetrics, DealListItem, DealStage, Deployment, DeploymentStatus, DomainDefinition, ErrorAnalysisMetrics, ErrorDetailFull, ErrorDetailResponse, ErrorTrend, ExecutionHealthMetrics, ExecutionHistoryItem, ExecutionHistoryResponse, ExecutionLog, ExecutionLogMessage, ExecutionMetricsDetail, ExecutionSSEEvent, ExecutionStatus$1 as ExecutionStatus, ExecutionSummary, FailingResource, GradingRubric, HumanCheckpointDefinition, HumanCheckpointStats, KanbanBoardConfig, ListMembershipsParams, MembershipFeatureConfig, MembershipStatus, MembershipWithDetails, MessageEvent$1 as MessageEvent, MessageType, ModelConfig, NotificationDTO, NotificationSSEEvent, PatchTaskParams, RecentExecutionsByResourceResponse, RecurringScheduleConfig, RelativeScheduleConfig, RelativeScheduleItem, ResourceDefinition$1 as ResourceDefinition, ResourceDomain, ResourceErrorsResponse, ResourceExecutionSummary, ResourceExecutionsResponse, ResourceHealth, ResourceIdentifier, ResourceStats, ResourceStatus$1 as ResourceStatus, ResourceType$1 as ResourceType, ResourcesHealthResponse, SerializedAgentDefinition, SerializedExecutionInterface, SerializedWorkflowDefinition, SessionCalibrationResult, SessionDTO, SessionTokenUsage, SingleCalibrationResult, StatsTimeRange, SupabaseUserProfile, Task, TaskSchedule, TaskScheduleConfig, TaskStatus, TimeRange, WorkflowNodeVisualizerData as TimelineData, UpdateCalibrationProjectInput, UpdateWebhookEndpointRequest, UserConfig, WebhookEndpoint, WebhookEndpointResponse };
5735
+ export type { AIResourceDefinition, APIExecutionDetail, APIExecutionListResponse, APIExecutionSummary, AbsoluteScheduleConfig, AbsoluteScheduleItem, ActionConfig, Activity, ActivitySSEEvent, ActivityStatus, ActivityType, AgentIterationData, AgentMemory, ApiKeyListItem, BusinessImpactMetrics, ChatMessage, CheckpointListResponse, CommandQueueSSEEvent, CommandViewAgent, CommandViewData, CommandViewNode, CommandViewNodeType, CommandViewStatsResponse, CommandViewWorkflow, CostBreakdownMetrics, CostByModelResponse, CostSummaryResponse, CostTrendsResponse, CreateWebhookEndpointRequest, CredentialListItem, DashboardMetrics, DealListItem, DealStage, Deployment, DeploymentStatus, DomainDefinition, ErrorAnalysisMetrics, ErrorDetailFull, ErrorDetailResponse, ErrorTrend, ExecutionHealthMetrics, ExecutionHistoryItem, ExecutionHistoryResponse, ExecutionLogMessage, ExecutionMetricsDetail, ExecutionSSEEvent, ExecutionStatus$1 as ExecutionStatus, ExecutionSummary, FailingResource, HumanCheckpointDefinition, HumanCheckpointStats, KanbanBoardConfig, ListMembershipsParams, MembershipFeatureConfig, MembershipStatus, MembershipWithDetails, MessageEvent, MessageType, ModelConfig, NotificationDTO, NotificationSSEEvent, PatchTaskParams, RecentExecutionsByResourceResponse, RecurringScheduleConfig, RelativeScheduleConfig, RelativeScheduleItem, ResourceDefinition$1 as ResourceDefinition, ResourceDomain, ResourceErrorsResponse, ResourceExecutionSummary, ResourceExecutionsResponse, ResourceHealth, ResourceIdentifier, ResourceStats, ResourceStatus$1 as ResourceStatus, ResourceType$1 as ResourceType, ResourcesHealthResponse, SerializedAgentDefinition, SerializedExecutionInterface, SerializedWorkflowDefinition, SessionDTO, SessionTokenUsage, StatsTimeRange, SupabaseUserProfile, Task, TaskSchedule, TaskScheduleConfig, TaskStatus, TimeRange, WorkflowNodeVisualizerData as TimelineData, UpdateWebhookEndpointRequest, UserConfig, WebhookEndpoint, WebhookEndpointResponse };