@elevasis/ui 2.36.0 → 2.37.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 (92) hide show
  1. package/dist/api/index.js +4 -3
  2. package/dist/app/index.css +0 -384
  3. package/dist/app/index.d.ts +20 -0
  4. package/dist/app/index.js +21 -21
  5. package/dist/auth/index.d.ts +91 -28
  6. package/dist/auth/index.js +5 -1
  7. package/dist/charts/index.js +9 -3
  8. package/dist/chunk-5CTJ7TW2.js +111 -0
  9. package/dist/chunk-5EYJ2GIN.js +122 -0
  10. package/dist/{chunk-K4UZU3TU.js → chunk-6NREL3KL.js} +1 -1
  11. package/dist/chunk-6ROXVZ3L.js +9 -0
  12. package/dist/{chunk-YYX7OPZQ.js → chunk-73EWE2EW.js} +1 -1
  13. package/dist/{chunk-SIQ3P4OR.js → chunk-7GQFIWP4.js} +8 -756
  14. package/dist/chunk-A7IG36LB.js +215 -0
  15. package/dist/chunk-CLDCYJQT.js +1 -0
  16. package/dist/{chunk-AKW7KISS.js → chunk-CWYQRM5T.js} +2 -38
  17. package/dist/{chunk-LUYVRATI.js → chunk-DA6I5VEY.js} +5 -213
  18. package/dist/chunk-I53EX4VU.js +734 -0
  19. package/dist/chunk-IIMU5YAJ.js +53 -0
  20. package/dist/{chunk-VKIZUUPM.js → chunk-JPVZRZ3X.js} +31 -14
  21. package/dist/chunk-JXVNHVK7.js +79 -0
  22. package/dist/chunk-JZ2WID2G.js +337 -0
  23. package/dist/chunk-LCJQ6OWC.js +348 -0
  24. package/dist/chunk-LNC6PZAE.js +85 -0
  25. package/dist/{chunk-O2Q4VMRN.js → chunk-NWMPBG4U.js} +1 -1
  26. package/dist/chunk-NYNOMAAS.js +422 -0
  27. package/dist/chunk-S3KBYQTI.js +39 -0
  28. package/dist/chunk-S3XR4II4.js +30 -0
  29. package/dist/chunk-SHZT7ULK.js +425 -0
  30. package/dist/{chunk-F6EFC2MJ.js → chunk-T3NI7DOA.js} +291 -2044
  31. package/dist/{chunk-GX6XBRRF.js → chunk-TYRUKGGD.js} +2 -1
  32. package/dist/{chunk-R3VCBZDC.js → chunk-X4WBGKJQ.js} +3 -50
  33. package/dist/{chunk-GEFWMU26.js → chunk-X66MVMZT.js} +1 -9
  34. package/dist/{chunk-57OZ3AEG.js → chunk-Y3JQBSKQ.js} +1 -1
  35. package/dist/components/index.d.ts +29 -42
  36. package/dist/components/index.js +33 -19
  37. package/dist/components/navigation/index.js +3 -31
  38. package/dist/features/auth/index.d.ts +52 -99
  39. package/dist/features/auth/index.js +36 -99
  40. package/dist/features/clients/index.js +33 -19
  41. package/dist/features/crm/index.d.ts +20 -0
  42. package/dist/features/crm/index.js +33 -19
  43. package/dist/features/dashboard/index.js +33 -19
  44. package/dist/features/delivery/index.d.ts +20 -0
  45. package/dist/features/delivery/index.js +33 -19
  46. package/dist/features/knowledge/index.js +6 -30
  47. package/dist/features/lead-gen/index.d.ts +1088 -1
  48. package/dist/features/lead-gen/index.js +33 -19
  49. package/dist/features/monitoring/index.js +33 -19
  50. package/dist/features/monitoring/requests/index.js +33 -19
  51. package/dist/features/notes/index.d.ts +72 -0
  52. package/dist/features/notes/index.js +621 -0
  53. package/dist/features/operations/index.js +33 -19
  54. package/dist/features/right-panel-host/index.d.ts +214 -0
  55. package/dist/features/right-panel-host/index.js +640 -0
  56. package/dist/features/seo/index.js +3 -2
  57. package/dist/features/settings/index.d.ts +23 -35
  58. package/dist/features/settings/index.js +33 -19
  59. package/dist/hooks/access/index.d.ts +90 -0
  60. package/dist/hooks/access/index.js +10 -0
  61. package/dist/hooks/delivery/index.d.ts +20 -0
  62. package/dist/hooks/delivery/index.js +33 -19
  63. package/dist/hooks/index.d.ts +1599 -1651
  64. package/dist/hooks/index.js +33 -19
  65. package/dist/hooks/published.d.ts +1599 -1651
  66. package/dist/hooks/published.js +33 -19
  67. package/dist/hooks/user-notes/index.d.ts +57 -0
  68. package/dist/hooks/user-notes/index.js +3 -0
  69. package/dist/index.d.ts +239 -275
  70. package/dist/index.js +34 -20
  71. package/dist/initialization/index.d.ts +20 -19
  72. package/dist/knowledge/index.js +10 -7
  73. package/dist/layout/index.js +5 -3
  74. package/dist/organization/index.d.ts +0 -19
  75. package/dist/organization/index.js +33 -19
  76. package/dist/profile/index.d.ts +20 -0
  77. package/dist/provider/index.css +0 -384
  78. package/dist/provider/index.d.ts +20 -0
  79. package/dist/provider/index.js +15 -21
  80. package/dist/provider/published.css +0 -523
  81. package/dist/provider/published.d.ts +20 -0
  82. package/dist/provider/published.js +11 -21
  83. package/dist/supabase/index.d.ts +40 -0
  84. package/dist/test-utils/index.d.ts +2 -21
  85. package/dist/test-utils/index.js +5 -18
  86. package/dist/theme/index.js +2 -1
  87. package/dist/types/index.d.ts +70 -59
  88. package/dist/utils/index.js +2 -1
  89. package/package.json +19 -3
  90. package/src/auth/README.md +6 -6
  91. package/dist/components/navigation/index.css +0 -649
  92. package/dist/features/knowledge/index.css +0 -649
@@ -1,640 +1,159 @@
1
- import * as _tanstack_react_query from '@tanstack/react-query';
2
1
  import { z } from 'zod';
2
+ import * as _tanstack_react_query from '@tanstack/react-query';
3
3
  import { EventSourceMessage } from '@microsoft/fetch-event-source';
4
4
  import * as react from 'react';
5
5
  import * as zustand_middleware from 'zustand/middleware';
6
6
  import * as zustand from 'zustand';
7
7
 
8
8
  /**
9
- * Error categories for observability grouping and classification.
10
- * Used to categorize errors in the execution_errors table metadata.
9
+ * Canonical permission catalog.
10
+ *
11
+ * Source of truth for the permission keys used by:
12
+ * - RLS policies in Supabase (via has_org_permission(org_id, key))
13
+ * - API middleware (via requireOrganizationPermission(key))
14
+ * - UI access checks (via useAccess() permission-backed AccessKeys)
15
+ *
16
+ * The DB table `org_rol_permissions` mirrors this constant. There is no
17
+ * runtime reconciler; parity is enforced two ways:
18
+ * 1. Each migration that adds/removes/modifies a permission must INSERT
19
+ * (or UPDATE / DELETE) the corresponding `org_rol_permissions` row in
20
+ * the same transaction.
21
+ * 2. `apps/api/src/auth/multi-tenancy/__tests__/permissions-catalog-sync.integration.test.ts`
22
+ * asserts the TS catalog and the DB rows agree; CI fails on drift.
23
+ *
24
+ * Adding a permission:
25
+ * 1. Add an entry below.
26
+ * 2. Add a row to the migration (INSERT INTO org_rol_permissions ...) in
27
+ * the same transaction as any policies/grants that reference the key.
28
+ * 3. Reference it in RLS / middleware as needed.
29
+ * 4. Optionally grant it to one or more system roles in org_rol_grants.
30
+ *
31
+ * Removing a permission: follow the deletion runbook — never just delete
32
+ * the entry. Existing role grants and policy references must be cleared first.
11
33
  */
12
- type ExecutionErrorCategory = 'llm' | 'tool' | 'workflow' | 'agent' | 'validation' | 'system';
13
-
34
+ declare const PERMISSIONS: {
35
+ readonly ORG_READ: "org.read";
36
+ readonly ORG_MANAGE: "org.manage";
37
+ readonly ORG_DELETE: "org.delete";
38
+ readonly MEMBERS_MANAGE: "members.manage";
39
+ readonly ROLES_MANAGE: "roles.manage";
40
+ readonly SECRETS_MANAGE: "secrets.manage";
41
+ readonly OPERATIONS_READ: "operations.read";
42
+ readonly OPERATIONS_MANAGE: "operations.manage";
43
+ readonly ACQUISITION_MANAGE: "acquisition.manage";
44
+ readonly PROJECTS_MANAGE: "projects.manage";
45
+ readonly CLIENTS_MANAGE: "clients.manage";
46
+ };
47
+ type PermissionKey = (typeof PERMISSIONS)[keyof typeof PERMISSIONS];
14
48
  /**
15
- * Workflow-specific logging types and utilities
49
+ * Static metadata for each permission. Mirrored into org_rol_permissions by
50
+ * a migration `INSERT` in the same transaction as any change to this catalog.
51
+ * is_org_grantable=false means the permission is reserved to system roles
52
+ * only — custom roles cannot include it (privilege-escalation guard).
16
53
  */
17
-
18
- interface WorkflowExecutionContext {
19
- type: 'workflow';
20
- contextType: 'workflow-execution';
21
- executionId: string;
22
- workflowId: string;
23
- workflowName?: string;
24
- organizationId: string;
25
- executionPath?: string[];
26
- }
27
- interface WorkflowFailureContext {
28
- type: 'workflow';
29
- contextType: 'workflow-failure';
30
- executionId: string;
31
- workflowId: string;
32
- error: string;
33
- }
34
- interface StepStartedContext {
35
- type: 'workflow';
36
- contextType: 'step-started';
37
- stepId: string;
38
- stepStatus: 'started';
39
- input: unknown;
40
- startTime: number;
41
- }
42
- interface StepCompletedContext {
43
- type: 'workflow';
44
- contextType: 'step-completed';
45
- stepId: string;
46
- stepStatus: 'completed';
47
- output: unknown;
48
- duration: number;
49
- isTerminal: boolean;
50
- startTime: number;
51
- endTime: number;
52
- }
53
- interface StepFailedContext {
54
- type: 'workflow';
55
- contextType: 'step-failed';
56
- stepId: string;
57
- stepStatus: 'failed';
58
- error: string;
59
- duration: number;
60
- startTime: number;
61
- endTime: number;
62
- }
63
- interface ConditionalRouteContext {
64
- type: 'workflow';
65
- contextType: 'conditional-route';
66
- stepId: string;
67
- target: string;
68
- error?: string;
69
- }
70
- interface ExecutionPathContext {
71
- type: 'workflow';
72
- contextType: 'execution-path';
73
- executionPath: string[];
54
+ interface PermissionDescriptor {
55
+ key: PermissionKey;
56
+ description: string;
57
+ isOrgGrantable: boolean;
74
58
  }
75
- type WorkflowLogContext = WorkflowExecutionContext | WorkflowFailureContext | StepStartedContext | StepCompletedContext | StepFailedContext | ConditionalRouteContext | ExecutionPathContext;
76
59
 
77
60
  /**
78
- * Agent-specific logging types
79
- * Simplified 2-event model: lifecycle, iteration
61
+ * Memberships Domain - Zod Validation Schemas
80
62
  *
81
- * Design Philosophy:
82
- * - LIFECYCLE EVENTS: Structural checkpoints (initialization, iteration, completion)
83
- * - ITERATION EVENTS: Execution activities (reasoning, actions during iterations)
63
+ * Validation schemas for membership management endpoints.
64
+ * Includes request bodies, query params, and path params.
65
+ *
66
+ * Security:
67
+ * - All schemas use .strict() to prevent mass assignment attacks
68
+ * - UUID validation prevents invalid references
69
+ * - Role enum validation prevents privilege escalation
70
+ * - organizationId never accepted in body (from JWT when needed)
84
71
  */
85
72
 
86
73
  /**
87
- * Agent lifecycle stages
88
- * Universal checkpoints that apply to all agent executions
89
- */
90
- type AgentLifecycle = 'initialization' | 'iteration' | 'completion';
91
- /**
92
- * Iteration event types
93
- * Activities that occur during agent iterations
74
+ * Membership status validation
75
+ * Note: Database constraint only allows 'active' | 'inactive'
94
76
  */
95
- type IterationEventType = 'reasoning' | 'action' | 'tool-call';
77
+ declare const MembershipStatusSchema: z.ZodEnum<{
78
+ active: "active";
79
+ inactive: "inactive";
80
+ }>;
81
+ type MembershipStatus = z.infer<typeof MembershipStatusSchema>;
82
+
96
83
  /**
97
- * Base fields shared by all lifecycle events
84
+ * Organization Membership types based on WorkOS API
98
85
  */
99
- interface AgentLifecycleEventBase {
100
- type: 'agent';
101
- agentId: string;
102
- lifecycle: AgentLifecycle;
103
- sessionId?: string;
86
+ interface OrganizationMembership {
87
+ object: 'organization_membership';
88
+ id: string;
89
+ userId: string;
90
+ organizationId: string;
91
+ role: {
92
+ slug: string;
93
+ };
94
+ status: 'active' | 'inactive';
95
+ createdAt: string;
96
+ updatedAt: string;
104
97
  }
105
98
  /**
106
- * Lifecycle started event - emitted when a phase begins
107
- * REQUIRED: startTime (phase has started, no end yet)
99
+ * Request interfaces for membership operations
108
100
  */
109
- interface AgentLifecycleStartedEvent extends AgentLifecycleEventBase {
110
- stage: 'started';
111
- startTime: number;
112
- iteration?: number;
101
+ interface CreateMembershipRequest {
102
+ userId: string;
103
+ organizationId: string;
104
+ roleSlug?: string;
113
105
  }
114
- /**
115
- * Lifecycle completed event - emitted when a phase succeeds
116
- * REQUIRED: startTime, endTime, duration (phase has finished successfully)
117
- */
118
- interface AgentLifecycleCompletedEvent extends AgentLifecycleEventBase {
119
- stage: 'completed';
120
- startTime: number;
121
- endTime: number;
122
- duration: number;
123
- iteration?: number;
124
- attempts?: number;
125
- memorySize?: {
126
- sessionMemoryKeys: number;
127
- historyEntries: number;
128
- };
106
+ interface UpdateMembershipRequest {
107
+ roleSlug: string;
129
108
  }
130
- /**
131
- * Lifecycle failed event - emitted when a phase fails
132
- * REQUIRED: startTime, endTime, duration, error (phase has finished with error)
133
- */
134
- interface AgentLifecycleFailedEvent extends AgentLifecycleEventBase {
135
- stage: 'failed';
136
- startTime: number;
137
- endTime: number;
138
- duration: number;
139
- error: string;
140
- iteration?: number;
109
+ interface ListMembershipsParams {
110
+ userId?: string;
111
+ organizationId?: string;
112
+ statuses?: MembershipStatus[];
113
+ limit?: number;
114
+ before?: string;
115
+ after?: string;
116
+ order?: 'asc' | 'desc';
141
117
  }
142
118
  /**
143
- * Union type for all lifecycle events
144
- * Discriminated by 'stage' field for type narrowing
145
- */
146
- type AgentLifecycleEvent = AgentLifecycleStartedEvent | AgentLifecycleCompletedEvent | AgentLifecycleFailedEvent;
147
- /**
148
- * Placeholder data for MVP
149
- * Will be typed per actionType in future
119
+ * Response interfaces
150
120
  */
151
- interface ActionPlaceholderData {
152
- message: string;
121
+ interface ListMembershipsResponse {
122
+ data: OrganizationMembership[];
123
+ listMetadata?: {
124
+ before?: string | null;
125
+ after?: string | null;
126
+ };
153
127
  }
154
128
  /**
155
- * Iteration event - captures activities during agent iterations
156
- * Consolidates reasoning (LLM thought process) and actions (tool use, memory ops, etc.)
129
+ * Extended membership with user and organization details for UI
157
130
  */
158
- interface AgentIterationEvent {
159
- type: 'agent';
160
- agentId: string;
161
- lifecycle: 'iteration';
162
- eventType: IterationEventType;
163
- iteration: number;
164
- sessionId?: string;
165
- startTime: number;
166
- endTime: number;
167
- duration: number;
168
- output?: string;
169
- actionType?: string;
170
- data?: ActionPlaceholderData;
131
+ interface MembershipWithDetails extends OrganizationMembership {
132
+ user?: {
133
+ id: string;
134
+ email: string;
135
+ firstName?: string;
136
+ lastName?: string;
137
+ profilePictureUrl?: string;
138
+ };
139
+ organization?: {
140
+ id: string;
141
+ name: string;
142
+ workos_org_id: string;
143
+ primaryDomain?: string;
144
+ is_test?: boolean;
145
+ status?: string;
146
+ metadata?: Record<string, unknown>;
147
+ config?: Record<string, unknown>;
148
+ };
171
149
  }
172
- /**
173
- * Tool call event - captures individual tool executions during iterations
174
- * Provides granular timing for each tool invocation
175
- */
176
- interface AgentToolCallEvent {
177
- type: 'agent';
178
- agentId: string;
179
- lifecycle: 'iteration';
180
- eventType: 'tool-call';
181
- iteration: number;
182
- sessionId?: string;
183
- toolName: string;
184
- startTime: number;
185
- endTime: number;
186
- duration: number;
187
- success: boolean;
188
- error?: string;
189
- input?: Record<string, unknown>;
190
- output?: unknown;
191
- }
192
- /**
193
- * Union type for all agent log contexts
194
- * 3 event types total (lifecycle, iteration, tool-call)
195
- */
196
- type AgentLogContext = AgentLifecycleEvent | AgentIterationEvent | AgentToolCallEvent;
197
-
198
- /**
199
- * Base execution logger for Execution Engine
200
- */
201
- type ExecutionLogLevel = 'debug' | 'info' | 'warn' | 'error';
202
-
203
- type LogContext = WorkflowLogContext | AgentLogContext;
204
- interface ExecutionLogMessage {
205
- level: ExecutionLogLevel;
206
- message: string;
207
- timestamp: number;
208
- context?: LogContext;
209
- }
210
-
211
- /**
212
- * Serialized Registry Types
213
- *
214
- * Pre-computed JSON-safe types for API responses and Command View.
215
- * Serialization happens once at API startup, enabling instant response times.
216
- */
217
150
 
218
- /**
219
- * Serialized agent definition (JSON-safe)
220
- * Result of serializeDefinition(AgentDefinition)
221
- */
222
- interface SerializedAgentDefinition {
223
- config: {
224
- resourceId: string;
225
- name: string;
226
- description: string;
227
- version: string;
228
- type: 'agent';
229
- kind: 'orchestrator' | 'specialist' | 'utility' | 'system';
230
- status: 'dev' | 'prod';
231
- links?: ResourceLink[];
232
- category?: ResourceCategory;
233
- /** Whether this resource is archived and should be excluded from registration and deployment */
234
- archived?: boolean;
235
- systemPrompt: string;
236
- constraints?: {
237
- maxIterations?: number;
238
- timeout?: number;
239
- maxSessionMemoryKeys?: number;
240
- maxMemoryTokens?: number;
241
- };
242
- sessionCapable?: boolean;
243
- memoryPreferences?: string;
244
- };
245
- modelConfig: {
246
- provider: string;
247
- model: string;
248
- apiKey: string;
249
- temperature: number;
250
- maxOutputTokens: number;
251
- topP?: number;
252
- modelOptions?: Record<string, unknown>;
253
- };
254
- contract: {
255
- inputSchema: object;
256
- outputSchema?: object;
257
- };
258
- tools: Array<{
259
- name: string;
260
- description: string;
261
- inputSchema?: object;
262
- outputSchema?: object;
263
- }>;
264
- knowledgeMap?: {
265
- nodeCount: number;
266
- nodes: Array<{
267
- id: string;
268
- description: string;
269
- loaded: boolean;
270
- hasPrompt: boolean;
271
- }>;
272
- };
273
- metricsConfig?: object;
274
- }
275
- /**
276
- * Serialized workflow definition (JSON-safe)
277
- * Result of serializeDefinition(WorkflowDefinition)
278
- */
279
- interface SerializedWorkflowDefinition {
280
- config: {
281
- resourceId: string;
282
- name: string;
283
- description: string;
284
- version: string;
285
- type: 'workflow';
286
- status: 'dev' | 'prod';
287
- links?: ResourceLink[];
288
- category?: ResourceCategory;
289
- /** Whether this resource is archived and should be excluded from registration and deployment */
290
- archived?: boolean;
291
- };
292
- entryPoint: string;
293
- steps: Array<{
294
- id: string;
295
- name: string;
296
- description: string;
297
- inputSchema?: object;
298
- outputSchema?: object;
299
- next: {
300
- type: 'linear' | 'conditional';
301
- target?: string;
302
- routes?: Array<{
303
- target: string;
304
- }>;
305
- default?: string;
306
- } | null;
307
- }>;
308
- contract: {
309
- inputSchema: object;
310
- outputSchema?: object;
311
- };
312
- metricsConfig?: object;
313
- }
314
-
315
- declare const ResourceGovernanceStatusSchema: z.ZodEnum<{
316
- active: "active";
317
- deprecated: "deprecated";
318
- archived: "archived";
319
- }>;
320
- declare const ResourceEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
321
- id: z.ZodString;
322
- order: z.ZodDefault<z.ZodNumber>;
323
- systemPath: z.ZodString;
324
- title: z.ZodOptional<z.ZodString>;
325
- description: z.ZodOptional<z.ZodString>;
326
- ownerRoleId: z.ZodOptional<z.ZodString>;
327
- status: z.ZodEnum<{
328
- active: "active";
329
- deprecated: "deprecated";
330
- archived: "archived";
331
- }>;
332
- ontology: z.ZodOptional<z.ZodObject<{
333
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
334
- primaryAction: z.ZodOptional<z.ZodString>;
335
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
336
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
337
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
338
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
339
- contract: z.ZodOptional<z.ZodObject<{
340
- input: z.ZodOptional<z.ZodString>;
341
- output: z.ZodOptional<z.ZodString>;
342
- }, z.core.$strip>>;
343
- }, z.core.$strip>>;
344
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
345
- path: z.ZodString;
346
- role: z.ZodEnum<{
347
- entrypoint: "entrypoint";
348
- handler: "handler";
349
- schema: "schema";
350
- test: "test";
351
- docs: "docs";
352
- config: "config";
353
- }>;
354
- symbol: z.ZodOptional<z.ZodString>;
355
- description: z.ZodOptional<z.ZodString>;
356
- }, z.core.$strip>>>;
357
- kind: z.ZodLiteral<"workflow">;
358
- emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
359
- eventKey: z.ZodString;
360
- label: z.ZodString;
361
- payloadSchema: z.ZodOptional<z.ZodString>;
362
- lifecycle: z.ZodOptional<z.ZodEnum<{
363
- active: "active";
364
- deprecated: "deprecated";
365
- draft: "draft";
366
- beta: "beta";
367
- archived: "archived";
368
- }>>;
369
- }, z.core.$strip>>>;
370
- }, z.core.$strip>, z.ZodObject<{
371
- id: z.ZodString;
372
- order: z.ZodDefault<z.ZodNumber>;
373
- systemPath: z.ZodString;
374
- title: z.ZodOptional<z.ZodString>;
375
- description: z.ZodOptional<z.ZodString>;
376
- ownerRoleId: z.ZodOptional<z.ZodString>;
377
- status: z.ZodEnum<{
378
- active: "active";
379
- deprecated: "deprecated";
380
- archived: "archived";
381
- }>;
382
- ontology: z.ZodOptional<z.ZodObject<{
383
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
384
- primaryAction: z.ZodOptional<z.ZodString>;
385
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
386
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
387
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
388
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
389
- contract: z.ZodOptional<z.ZodObject<{
390
- input: z.ZodOptional<z.ZodString>;
391
- output: z.ZodOptional<z.ZodString>;
392
- }, z.core.$strip>>;
393
- }, z.core.$strip>>;
394
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
395
- path: z.ZodString;
396
- role: z.ZodEnum<{
397
- entrypoint: "entrypoint";
398
- handler: "handler";
399
- schema: "schema";
400
- test: "test";
401
- docs: "docs";
402
- config: "config";
403
- }>;
404
- symbol: z.ZodOptional<z.ZodString>;
405
- description: z.ZodOptional<z.ZodString>;
406
- }, z.core.$strip>>>;
407
- kind: z.ZodLiteral<"agent">;
408
- agentKind: z.ZodEnum<{
409
- platform: "platform";
410
- orchestrator: "orchestrator";
411
- specialist: "specialist";
412
- utility: "utility";
413
- }>;
414
- actsAsRoleId: z.ZodOptional<z.ZodString>;
415
- sessionCapable: z.ZodBoolean;
416
- invocations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
417
- kind: z.ZodLiteral<"slash-command">;
418
- command: z.ZodString;
419
- toolFactory: z.ZodOptional<z.ZodString>;
420
- }, z.core.$strip>, z.ZodObject<{
421
- kind: z.ZodLiteral<"mcp-tool">;
422
- server: z.ZodString;
423
- name: z.ZodString;
424
- }, z.core.$strip>, z.ZodObject<{
425
- kind: z.ZodLiteral<"api-endpoint">;
426
- method: z.ZodEnum<{
427
- GET: "GET";
428
- POST: "POST";
429
- PATCH: "PATCH";
430
- DELETE: "DELETE";
431
- }>;
432
- path: z.ZodString;
433
- requestSchema: z.ZodOptional<z.ZodString>;
434
- responseSchema: z.ZodOptional<z.ZodString>;
435
- }, z.core.$strip>, z.ZodObject<{
436
- kind: z.ZodLiteral<"script-execution">;
437
- resourceId: z.ZodString;
438
- }, z.core.$strip>], "kind">>>;
439
- emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
440
- eventKey: z.ZodString;
441
- label: z.ZodString;
442
- payloadSchema: z.ZodOptional<z.ZodString>;
443
- lifecycle: z.ZodOptional<z.ZodEnum<{
444
- active: "active";
445
- deprecated: "deprecated";
446
- draft: "draft";
447
- beta: "beta";
448
- archived: "archived";
449
- }>>;
450
- }, z.core.$strip>>>;
451
- }, z.core.$strip>, z.ZodObject<{
452
- id: z.ZodString;
453
- order: z.ZodDefault<z.ZodNumber>;
454
- systemPath: z.ZodString;
455
- title: z.ZodOptional<z.ZodString>;
456
- description: z.ZodOptional<z.ZodString>;
457
- ownerRoleId: z.ZodOptional<z.ZodString>;
458
- status: z.ZodEnum<{
459
- active: "active";
460
- deprecated: "deprecated";
461
- archived: "archived";
462
- }>;
463
- ontology: z.ZodOptional<z.ZodObject<{
464
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
465
- primaryAction: z.ZodOptional<z.ZodString>;
466
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
467
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
468
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
469
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
470
- contract: z.ZodOptional<z.ZodObject<{
471
- input: z.ZodOptional<z.ZodString>;
472
- output: z.ZodOptional<z.ZodString>;
473
- }, z.core.$strip>>;
474
- }, z.core.$strip>>;
475
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
476
- path: z.ZodString;
477
- role: z.ZodEnum<{
478
- entrypoint: "entrypoint";
479
- handler: "handler";
480
- schema: "schema";
481
- test: "test";
482
- docs: "docs";
483
- config: "config";
484
- }>;
485
- symbol: z.ZodOptional<z.ZodString>;
486
- description: z.ZodOptional<z.ZodString>;
487
- }, z.core.$strip>>>;
488
- kind: z.ZodLiteral<"integration">;
489
- provider: z.ZodString;
490
- }, z.core.$strip>, z.ZodObject<{
491
- id: z.ZodString;
492
- order: z.ZodDefault<z.ZodNumber>;
493
- systemPath: z.ZodString;
494
- title: z.ZodOptional<z.ZodString>;
495
- description: z.ZodOptional<z.ZodString>;
496
- ownerRoleId: z.ZodOptional<z.ZodString>;
497
- status: z.ZodEnum<{
498
- active: "active";
499
- deprecated: "deprecated";
500
- archived: "archived";
501
- }>;
502
- ontology: z.ZodOptional<z.ZodObject<{
503
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
504
- primaryAction: z.ZodOptional<z.ZodString>;
505
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
506
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
507
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
508
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
509
- contract: z.ZodOptional<z.ZodObject<{
510
- input: z.ZodOptional<z.ZodString>;
511
- output: z.ZodOptional<z.ZodString>;
512
- }, z.core.$strip>>;
513
- }, z.core.$strip>>;
514
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
515
- path: z.ZodString;
516
- role: z.ZodEnum<{
517
- entrypoint: "entrypoint";
518
- handler: "handler";
519
- schema: "schema";
520
- test: "test";
521
- docs: "docs";
522
- config: "config";
523
- }>;
524
- symbol: z.ZodOptional<z.ZodString>;
525
- description: z.ZodOptional<z.ZodString>;
526
- }, z.core.$strip>>>;
527
- kind: z.ZodLiteral<"script">;
528
- language: z.ZodEnum<{
529
- shell: "shell";
530
- sql: "sql";
531
- typescript: "typescript";
532
- python: "python";
533
- }>;
534
- source: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
535
- file: z.ZodString;
536
- }, z.core.$strip>]>;
537
- }, z.core.$strip>], "kind">;
538
- type ResourceGovernanceStatus = z.infer<typeof ResourceGovernanceStatusSchema>;
539
- type ResourceEntry = z.infer<typeof ResourceEntrySchema>;
540
-
541
- /**
542
- * Shared form field types for dynamic form generation
543
- * Used by: Command Queue, Execution Runner UI, future form-based features
544
- */
545
- /**
546
- * Supported form field types for action payloads
547
- * Maps to Mantine form components
548
- */
549
- type FormFieldType = 'text' | 'textarea' | 'number' | 'select' | 'checkbox' | 'radio' | 'richtext';
550
- /**
551
- * Form field definition
552
- */
553
- interface FormField {
554
- /** Field key in payload object */
555
- name: string;
556
- /** Field label for UI */
557
- label: string;
558
- /** Field type (determines UI component) */
559
- type: FormFieldType;
560
- /** Default value */
561
- defaultValue?: unknown;
562
- /** Required field */
563
- required?: boolean;
564
- /** Placeholder text */
565
- placeholder?: string;
566
- /** Help text */
567
- description?: string;
568
- /** Options for select/radio */
569
- options?: Array<{
570
- label: string;
571
- value: string | number;
572
- }>;
573
- /** Min/max for number */
574
- min?: number;
575
- max?: number;
576
- /** Path to context value for pre-filling (dot notation, e.g., 'proposal.summary') */
577
- defaultValueFromContext?: string;
578
- }
579
- /**
580
- * Form schema for action payload collection
581
- */
582
- interface FormSchema {
583
- /** Form title */
584
- title?: string;
585
- /** Form description */
586
- description?: string;
587
- /** Form fields */
588
- fields: FormField[];
589
- }
590
-
591
- /**
592
- * Memory type definitions
593
- * Types for agent memory management with semantic entry types
594
- */
595
- /**
596
- * Semantic memory entry types
597
- * Use-case agnostic types that describe the purpose of each entry
598
- * Memory types mirror action types for clarity and filtering
599
- */
600
- type MemoryEntryType = 'context' | 'input' | 'reasoning' | 'tool-result' | 'delegation-result' | 'error';
601
- /**
602
- * Memory entry - represents a single entry in agent memory
603
- * Stored in agent memory, translated by adapters to vendor-specific formats
604
- */
605
- interface MemoryEntry {
606
- type: MemoryEntryType;
607
- content: string;
608
- timestamp: number;
609
- turnNumber: number | null;
610
- iterationNumber: number | null;
611
- }
612
- /**
613
- * Agent memory - Self-orchestrated memory with session + working storage
614
- * Agent has full control over what persists, framework handles auto-compaction
615
- */
616
- interface AgentMemory {
617
- /**
618
- * Session memory - Persists for session/conversation duration
619
- * Never auto-trimmed by framework
620
- * Agent-managed key-value store for critical information
621
- * Agent provides strings, framework wraps in MemoryEntry
622
- */
623
- sessionMemory: Record<string, MemoryEntry>;
624
- /**
625
- * Working memory - Execution history
626
- * Automatically compacted by framework when needed
627
- * Agent doesn't control compaction
628
- */
629
- history: MemoryEntry[];
630
- }
631
-
632
- type Json = string | number | boolean | null | {
633
- [key: string]: Json | undefined;
634
- } | Json[];
635
- type Database = {
636
- __InternalSupabase: {
637
- PostgrestVersion: "12.2.3 (519615d)";
151
+ type Json = string | number | boolean | null | {
152
+ [key: string]: Json | undefined;
153
+ } | Json[];
154
+ type Database = {
155
+ __InternalSupabase: {
156
+ PostgrestVersion: "12.2.3 (519615d)";
638
157
  };
639
158
  public: {
640
159
  Tables: {
@@ -3610,6 +3129,12 @@ type Database = {
3610
3129
  Args: never;
3611
3130
  Returns: boolean;
3612
3131
  };
3132
+ current_user_shares_org_with: {
3133
+ Args: {
3134
+ other_user_id: string;
3135
+ };
3136
+ Returns: boolean;
3137
+ };
3613
3138
  current_user_supabase_id: {
3614
3139
  Args: never;
3615
3140
  Returns: string;
@@ -3649,6 +3174,20 @@ type Database = {
3649
3174
  Args: never;
3650
3175
  Returns: string;
3651
3176
  };
3177
+ has_org_access: {
3178
+ Args: {
3179
+ action?: string;
3180
+ org_id: string;
3181
+ system_path: string;
3182
+ };
3183
+ Returns: boolean;
3184
+ } | {
3185
+ Args: {
3186
+ action?: string;
3187
+ system_path: string;
3188
+ };
3189
+ Returns: boolean;
3190
+ };
3652
3191
  has_org_permission: {
3653
3192
  Args: {
3654
3193
  org_id: string;
@@ -3715,25 +3254,819 @@ type Database = {
3715
3254
  [_ in never]: never;
3716
3255
  };
3717
3256
  };
3718
- };
3719
- type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">;
3720
- type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">];
3721
- type Tables<DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) | {
3722
- schema: keyof DatabaseWithoutInternals;
3723
- }, TableName extends DefaultSchemaTableNameOrOptions extends {
3724
- schema: keyof DatabaseWithoutInternals;
3725
- } ? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"]) : never = never> = DefaultSchemaTableNameOrOptions extends {
3726
- schema: keyof DatabaseWithoutInternals;
3727
- } ? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
3728
- Row: infer R;
3729
- } ? R : never : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) ? (DefaultSchema["Tables"] & DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
3730
- Row: infer R;
3731
- } ? R : never : never;
3257
+ };
3258
+ type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">;
3259
+ type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">];
3260
+ type Tables<DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) | {
3261
+ schema: keyof DatabaseWithoutInternals;
3262
+ }, TableName extends DefaultSchemaTableNameOrOptions extends {
3263
+ schema: keyof DatabaseWithoutInternals;
3264
+ } ? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"]) : never = never> = DefaultSchemaTableNameOrOptions extends {
3265
+ schema: keyof DatabaseWithoutInternals;
3266
+ } ? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
3267
+ Row: infer R;
3268
+ } ? R : never : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) ? (DefaultSchema["Tables"] & DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
3269
+ Row: infer R;
3270
+ } ? R : never : never;
3271
+
3272
+ type SupabaseApiKey = Tables<'api_keys'>;
3273
+ /** API response type for API key list items (omits sensitive key_hash) */
3274
+ type ApiKeyListItem = Omit<SupabaseApiKey, 'key_hash'>;
3275
+
3276
+ declare const OntologyScopeSchema: z.ZodDefault<z.ZodObject<{
3277
+ objectTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
3278
+ id: z.ZodString;
3279
+ label: z.ZodOptional<z.ZodString>;
3280
+ description: z.ZodOptional<z.ZodString>;
3281
+ ownerSystemId: z.ZodOptional<z.ZodString>;
3282
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
3283
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3284
+ storage: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3285
+ }, z.core.$loose>>>>;
3286
+ linkTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
3287
+ id: z.ZodString;
3288
+ label: z.ZodOptional<z.ZodString>;
3289
+ description: z.ZodOptional<z.ZodString>;
3290
+ ownerSystemId: z.ZodOptional<z.ZodString>;
3291
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
3292
+ from: z.ZodString;
3293
+ to: z.ZodString;
3294
+ cardinality: z.ZodOptional<z.ZodString>;
3295
+ via: z.ZodOptional<z.ZodString>;
3296
+ }, z.core.$loose>>>>;
3297
+ actionTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
3298
+ id: z.ZodString;
3299
+ label: z.ZodOptional<z.ZodString>;
3300
+ description: z.ZodOptional<z.ZodString>;
3301
+ ownerSystemId: z.ZodOptional<z.ZodString>;
3302
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
3303
+ actsOn: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
3304
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3305
+ effects: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
3306
+ }, z.core.$loose>>>>;
3307
+ catalogTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
3308
+ id: z.ZodString;
3309
+ label: z.ZodOptional<z.ZodString>;
3310
+ description: z.ZodOptional<z.ZodString>;
3311
+ ownerSystemId: z.ZodOptional<z.ZodString>;
3312
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
3313
+ kind: z.ZodOptional<z.ZodString>;
3314
+ appliesTo: z.ZodOptional<z.ZodString>;
3315
+ entries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3316
+ }, z.core.$loose>>>>;
3317
+ eventTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
3318
+ id: z.ZodString;
3319
+ label: z.ZodOptional<z.ZodString>;
3320
+ description: z.ZodOptional<z.ZodString>;
3321
+ ownerSystemId: z.ZodOptional<z.ZodString>;
3322
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
3323
+ payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3324
+ }, z.core.$loose>>>>;
3325
+ interfaceTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
3326
+ id: z.ZodString;
3327
+ label: z.ZodOptional<z.ZodString>;
3328
+ description: z.ZodOptional<z.ZodString>;
3329
+ ownerSystemId: z.ZodOptional<z.ZodString>;
3330
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
3331
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3332
+ }, z.core.$loose>>>>;
3333
+ valueTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
3334
+ id: z.ZodString;
3335
+ label: z.ZodOptional<z.ZodString>;
3336
+ description: z.ZodOptional<z.ZodString>;
3337
+ ownerSystemId: z.ZodOptional<z.ZodString>;
3338
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
3339
+ primitive: z.ZodOptional<z.ZodString>;
3340
+ }, z.core.$loose>>>>;
3341
+ sharedProperties: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
3342
+ id: z.ZodString;
3343
+ label: z.ZodOptional<z.ZodString>;
3344
+ description: z.ZodOptional<z.ZodString>;
3345
+ ownerSystemId: z.ZodOptional<z.ZodString>;
3346
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
3347
+ valueType: z.ZodOptional<z.ZodString>;
3348
+ searchable: z.ZodOptional<z.ZodBoolean>;
3349
+ pii: z.ZodOptional<z.ZodBoolean>;
3350
+ }, z.core.$loose>>>>;
3351
+ groups: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
3352
+ id: z.ZodString;
3353
+ label: z.ZodOptional<z.ZodString>;
3354
+ description: z.ZodOptional<z.ZodString>;
3355
+ ownerSystemId: z.ZodOptional<z.ZodString>;
3356
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
3357
+ members: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
3358
+ }, z.core.$loose>>>>;
3359
+ surfaces: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
3360
+ id: z.ZodString;
3361
+ label: z.ZodOptional<z.ZodString>;
3362
+ description: z.ZodOptional<z.ZodString>;
3363
+ ownerSystemId: z.ZodOptional<z.ZodString>;
3364
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
3365
+ route: z.ZodOptional<z.ZodString>;
3366
+ }, z.core.$loose>>>>;
3367
+ }, z.core.$strip>>;
3368
+ type OntologyScope = z.infer<typeof OntologyScopeSchema>;
3369
+
3370
+ type JsonPrimitive = string | number | boolean | null;
3371
+ type JsonValue = JsonPrimitive | JsonValue[] | {
3372
+ [key: string]: JsonValue;
3373
+ };
3374
+ /** Explicit interface needed to annotate the recursive SystemEntrySchema. */
3375
+ interface SystemEntry {
3376
+ id: string;
3377
+ label?: string;
3378
+ title?: string;
3379
+ description?: string;
3380
+ kind?: 'product' | 'operational' | 'platform' | 'diagnostic';
3381
+ parentSystemId?: string;
3382
+ ui?: {
3383
+ path: string;
3384
+ surfaces: string[];
3385
+ icon?: string;
3386
+ order?: number;
3387
+ };
3388
+ lifecycle?: 'draft' | 'beta' | 'active' | 'deprecated' | 'archived';
3389
+ responsibleRoleId?: string;
3390
+ governedByKnowledge?: string[];
3391
+ actions?: {
3392
+ actionId: string;
3393
+ intent: 'exposes' | 'consumes';
3394
+ invocation?: unknown;
3395
+ }[];
3396
+ policies?: string[];
3397
+ drivesGoals?: string[];
3398
+ /** @deprecated Use lifecycle. Accepted for one publish cycle. */
3399
+ status?: 'active' | 'deprecated' | 'archived';
3400
+ path?: string;
3401
+ icon?: string;
3402
+ color?: string;
3403
+ uiPosition?: 'sidebar-primary' | 'sidebar-bottom';
3404
+ enabled?: boolean;
3405
+ devOnly?: boolean;
3406
+ requiresAdmin?: boolean;
3407
+ order: number;
3408
+ config?: Record<string, JsonValue>;
3409
+ ontology?: OntologyScope;
3410
+ systems?: Record<string, SystemEntry>;
3411
+ subsystems?: Record<string, SystemEntry>;
3412
+ }
3413
+
3414
+ declare const ResourceGovernanceStatusSchema: z.ZodEnum<{
3415
+ active: "active";
3416
+ deprecated: "deprecated";
3417
+ archived: "archived";
3418
+ }>;
3419
+ declare const ResourceEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3420
+ id: z.ZodString;
3421
+ order: z.ZodDefault<z.ZodNumber>;
3422
+ systemPath: z.ZodString;
3423
+ title: z.ZodOptional<z.ZodString>;
3424
+ description: z.ZodOptional<z.ZodString>;
3425
+ ownerRoleId: z.ZodOptional<z.ZodString>;
3426
+ status: z.ZodEnum<{
3427
+ active: "active";
3428
+ deprecated: "deprecated";
3429
+ archived: "archived";
3430
+ }>;
3431
+ ontology: z.ZodOptional<z.ZodObject<{
3432
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
3433
+ primaryAction: z.ZodOptional<z.ZodString>;
3434
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
3435
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
3436
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
3437
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
3438
+ contract: z.ZodOptional<z.ZodObject<{
3439
+ input: z.ZodOptional<z.ZodString>;
3440
+ output: z.ZodOptional<z.ZodString>;
3441
+ }, z.core.$strip>>;
3442
+ }, z.core.$strip>>;
3443
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
3444
+ path: z.ZodString;
3445
+ role: z.ZodEnum<{
3446
+ entrypoint: "entrypoint";
3447
+ handler: "handler";
3448
+ schema: "schema";
3449
+ test: "test";
3450
+ docs: "docs";
3451
+ config: "config";
3452
+ }>;
3453
+ symbol: z.ZodOptional<z.ZodString>;
3454
+ description: z.ZodOptional<z.ZodString>;
3455
+ }, z.core.$strip>>>;
3456
+ kind: z.ZodLiteral<"workflow">;
3457
+ emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
3458
+ eventKey: z.ZodString;
3459
+ label: z.ZodString;
3460
+ payloadSchema: z.ZodOptional<z.ZodString>;
3461
+ lifecycle: z.ZodOptional<z.ZodEnum<{
3462
+ active: "active";
3463
+ deprecated: "deprecated";
3464
+ draft: "draft";
3465
+ beta: "beta";
3466
+ archived: "archived";
3467
+ }>>;
3468
+ }, z.core.$strip>>>;
3469
+ }, z.core.$strip>, z.ZodObject<{
3470
+ id: z.ZodString;
3471
+ order: z.ZodDefault<z.ZodNumber>;
3472
+ systemPath: z.ZodString;
3473
+ title: z.ZodOptional<z.ZodString>;
3474
+ description: z.ZodOptional<z.ZodString>;
3475
+ ownerRoleId: z.ZodOptional<z.ZodString>;
3476
+ status: z.ZodEnum<{
3477
+ active: "active";
3478
+ deprecated: "deprecated";
3479
+ archived: "archived";
3480
+ }>;
3481
+ ontology: z.ZodOptional<z.ZodObject<{
3482
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
3483
+ primaryAction: z.ZodOptional<z.ZodString>;
3484
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
3485
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
3486
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
3487
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
3488
+ contract: z.ZodOptional<z.ZodObject<{
3489
+ input: z.ZodOptional<z.ZodString>;
3490
+ output: z.ZodOptional<z.ZodString>;
3491
+ }, z.core.$strip>>;
3492
+ }, z.core.$strip>>;
3493
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
3494
+ path: z.ZodString;
3495
+ role: z.ZodEnum<{
3496
+ entrypoint: "entrypoint";
3497
+ handler: "handler";
3498
+ schema: "schema";
3499
+ test: "test";
3500
+ docs: "docs";
3501
+ config: "config";
3502
+ }>;
3503
+ symbol: z.ZodOptional<z.ZodString>;
3504
+ description: z.ZodOptional<z.ZodString>;
3505
+ }, z.core.$strip>>>;
3506
+ kind: z.ZodLiteral<"agent">;
3507
+ agentKind: z.ZodEnum<{
3508
+ platform: "platform";
3509
+ orchestrator: "orchestrator";
3510
+ specialist: "specialist";
3511
+ utility: "utility";
3512
+ }>;
3513
+ actsAsRoleId: z.ZodOptional<z.ZodString>;
3514
+ sessionCapable: z.ZodBoolean;
3515
+ invocations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
3516
+ kind: z.ZodLiteral<"slash-command">;
3517
+ command: z.ZodString;
3518
+ toolFactory: z.ZodOptional<z.ZodString>;
3519
+ }, z.core.$strip>, z.ZodObject<{
3520
+ kind: z.ZodLiteral<"mcp-tool">;
3521
+ server: z.ZodString;
3522
+ name: z.ZodString;
3523
+ }, z.core.$strip>, z.ZodObject<{
3524
+ kind: z.ZodLiteral<"api-endpoint">;
3525
+ method: z.ZodEnum<{
3526
+ GET: "GET";
3527
+ POST: "POST";
3528
+ PATCH: "PATCH";
3529
+ DELETE: "DELETE";
3530
+ }>;
3531
+ path: z.ZodString;
3532
+ requestSchema: z.ZodOptional<z.ZodString>;
3533
+ responseSchema: z.ZodOptional<z.ZodString>;
3534
+ }, z.core.$strip>, z.ZodObject<{
3535
+ kind: z.ZodLiteral<"script-execution">;
3536
+ resourceId: z.ZodString;
3537
+ }, z.core.$strip>], "kind">>>;
3538
+ emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
3539
+ eventKey: z.ZodString;
3540
+ label: z.ZodString;
3541
+ payloadSchema: z.ZodOptional<z.ZodString>;
3542
+ lifecycle: z.ZodOptional<z.ZodEnum<{
3543
+ active: "active";
3544
+ deprecated: "deprecated";
3545
+ draft: "draft";
3546
+ beta: "beta";
3547
+ archived: "archived";
3548
+ }>>;
3549
+ }, z.core.$strip>>>;
3550
+ }, z.core.$strip>, z.ZodObject<{
3551
+ id: z.ZodString;
3552
+ order: z.ZodDefault<z.ZodNumber>;
3553
+ systemPath: z.ZodString;
3554
+ title: z.ZodOptional<z.ZodString>;
3555
+ description: z.ZodOptional<z.ZodString>;
3556
+ ownerRoleId: z.ZodOptional<z.ZodString>;
3557
+ status: z.ZodEnum<{
3558
+ active: "active";
3559
+ deprecated: "deprecated";
3560
+ archived: "archived";
3561
+ }>;
3562
+ ontology: z.ZodOptional<z.ZodObject<{
3563
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
3564
+ primaryAction: z.ZodOptional<z.ZodString>;
3565
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
3566
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
3567
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
3568
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
3569
+ contract: z.ZodOptional<z.ZodObject<{
3570
+ input: z.ZodOptional<z.ZodString>;
3571
+ output: z.ZodOptional<z.ZodString>;
3572
+ }, z.core.$strip>>;
3573
+ }, z.core.$strip>>;
3574
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
3575
+ path: z.ZodString;
3576
+ role: z.ZodEnum<{
3577
+ entrypoint: "entrypoint";
3578
+ handler: "handler";
3579
+ schema: "schema";
3580
+ test: "test";
3581
+ docs: "docs";
3582
+ config: "config";
3583
+ }>;
3584
+ symbol: z.ZodOptional<z.ZodString>;
3585
+ description: z.ZodOptional<z.ZodString>;
3586
+ }, z.core.$strip>>>;
3587
+ kind: z.ZodLiteral<"integration">;
3588
+ provider: z.ZodString;
3589
+ }, z.core.$strip>, z.ZodObject<{
3590
+ id: z.ZodString;
3591
+ order: z.ZodDefault<z.ZodNumber>;
3592
+ systemPath: z.ZodString;
3593
+ title: z.ZodOptional<z.ZodString>;
3594
+ description: z.ZodOptional<z.ZodString>;
3595
+ ownerRoleId: z.ZodOptional<z.ZodString>;
3596
+ status: z.ZodEnum<{
3597
+ active: "active";
3598
+ deprecated: "deprecated";
3599
+ archived: "archived";
3600
+ }>;
3601
+ ontology: z.ZodOptional<z.ZodObject<{
3602
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
3603
+ primaryAction: z.ZodOptional<z.ZodString>;
3604
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
3605
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
3606
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
3607
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
3608
+ contract: z.ZodOptional<z.ZodObject<{
3609
+ input: z.ZodOptional<z.ZodString>;
3610
+ output: z.ZodOptional<z.ZodString>;
3611
+ }, z.core.$strip>>;
3612
+ }, z.core.$strip>>;
3613
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
3614
+ path: z.ZodString;
3615
+ role: z.ZodEnum<{
3616
+ entrypoint: "entrypoint";
3617
+ handler: "handler";
3618
+ schema: "schema";
3619
+ test: "test";
3620
+ docs: "docs";
3621
+ config: "config";
3622
+ }>;
3623
+ symbol: z.ZodOptional<z.ZodString>;
3624
+ description: z.ZodOptional<z.ZodString>;
3625
+ }, z.core.$strip>>>;
3626
+ kind: z.ZodLiteral<"script">;
3627
+ language: z.ZodEnum<{
3628
+ shell: "shell";
3629
+ sql: "sql";
3630
+ typescript: "typescript";
3631
+ python: "python";
3632
+ }>;
3633
+ source: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
3634
+ file: z.ZodString;
3635
+ }, z.core.$strip>]>;
3636
+ }, z.core.$strip>], "kind">;
3637
+ type ResourceGovernanceStatus = z.infer<typeof ResourceGovernanceStatusSchema>;
3638
+ type ResourceEntry = z.infer<typeof ResourceEntrySchema>;
3639
+
3640
+ /**
3641
+ * Error categories for observability grouping and classification.
3642
+ * Used to categorize errors in the execution_errors table metadata.
3643
+ */
3644
+ type ExecutionErrorCategory = 'llm' | 'tool' | 'workflow' | 'agent' | 'validation' | 'system';
3645
+
3646
+ /**
3647
+ * Workflow-specific logging types and utilities
3648
+ */
3649
+
3650
+ interface WorkflowExecutionContext {
3651
+ type: 'workflow';
3652
+ contextType: 'workflow-execution';
3653
+ executionId: string;
3654
+ workflowId: string;
3655
+ workflowName?: string;
3656
+ organizationId: string;
3657
+ executionPath?: string[];
3658
+ }
3659
+ interface WorkflowFailureContext {
3660
+ type: 'workflow';
3661
+ contextType: 'workflow-failure';
3662
+ executionId: string;
3663
+ workflowId: string;
3664
+ error: string;
3665
+ }
3666
+ interface StepStartedContext {
3667
+ type: 'workflow';
3668
+ contextType: 'step-started';
3669
+ stepId: string;
3670
+ stepStatus: 'started';
3671
+ input: unknown;
3672
+ startTime: number;
3673
+ }
3674
+ interface StepCompletedContext {
3675
+ type: 'workflow';
3676
+ contextType: 'step-completed';
3677
+ stepId: string;
3678
+ stepStatus: 'completed';
3679
+ output: unknown;
3680
+ duration: number;
3681
+ isTerminal: boolean;
3682
+ startTime: number;
3683
+ endTime: number;
3684
+ }
3685
+ interface StepFailedContext {
3686
+ type: 'workflow';
3687
+ contextType: 'step-failed';
3688
+ stepId: string;
3689
+ stepStatus: 'failed';
3690
+ error: string;
3691
+ duration: number;
3692
+ startTime: number;
3693
+ endTime: number;
3694
+ }
3695
+ interface ConditionalRouteContext {
3696
+ type: 'workflow';
3697
+ contextType: 'conditional-route';
3698
+ stepId: string;
3699
+ target: string;
3700
+ error?: string;
3701
+ }
3702
+ interface ExecutionPathContext {
3703
+ type: 'workflow';
3704
+ contextType: 'execution-path';
3705
+ executionPath: string[];
3706
+ }
3707
+ type WorkflowLogContext = WorkflowExecutionContext | WorkflowFailureContext | StepStartedContext | StepCompletedContext | StepFailedContext | ConditionalRouteContext | ExecutionPathContext;
3708
+
3709
+ /**
3710
+ * Agent-specific logging types
3711
+ * Simplified 2-event model: lifecycle, iteration
3712
+ *
3713
+ * Design Philosophy:
3714
+ * - LIFECYCLE EVENTS: Structural checkpoints (initialization, iteration, completion)
3715
+ * - ITERATION EVENTS: Execution activities (reasoning, actions during iterations)
3716
+ */
3717
+
3718
+ /**
3719
+ * Agent lifecycle stages
3720
+ * Universal checkpoints that apply to all agent executions
3721
+ */
3722
+ type AgentLifecycle = 'initialization' | 'iteration' | 'completion';
3723
+ /**
3724
+ * Iteration event types
3725
+ * Activities that occur during agent iterations
3726
+ */
3727
+ type IterationEventType = 'reasoning' | 'action' | 'tool-call';
3728
+ /**
3729
+ * Base fields shared by all lifecycle events
3730
+ */
3731
+ interface AgentLifecycleEventBase {
3732
+ type: 'agent';
3733
+ agentId: string;
3734
+ lifecycle: AgentLifecycle;
3735
+ sessionId?: string;
3736
+ }
3737
+ /**
3738
+ * Lifecycle started event - emitted when a phase begins
3739
+ * REQUIRED: startTime (phase has started, no end yet)
3740
+ */
3741
+ interface AgentLifecycleStartedEvent extends AgentLifecycleEventBase {
3742
+ stage: 'started';
3743
+ startTime: number;
3744
+ iteration?: number;
3745
+ }
3746
+ /**
3747
+ * Lifecycle completed event - emitted when a phase succeeds
3748
+ * REQUIRED: startTime, endTime, duration (phase has finished successfully)
3749
+ */
3750
+ interface AgentLifecycleCompletedEvent extends AgentLifecycleEventBase {
3751
+ stage: 'completed';
3752
+ startTime: number;
3753
+ endTime: number;
3754
+ duration: number;
3755
+ iteration?: number;
3756
+ attempts?: number;
3757
+ memorySize?: {
3758
+ sessionMemoryKeys: number;
3759
+ historyEntries: number;
3760
+ };
3761
+ }
3762
+ /**
3763
+ * Lifecycle failed event - emitted when a phase fails
3764
+ * REQUIRED: startTime, endTime, duration, error (phase has finished with error)
3765
+ */
3766
+ interface AgentLifecycleFailedEvent extends AgentLifecycleEventBase {
3767
+ stage: 'failed';
3768
+ startTime: number;
3769
+ endTime: number;
3770
+ duration: number;
3771
+ error: string;
3772
+ iteration?: number;
3773
+ }
3774
+ /**
3775
+ * Union type for all lifecycle events
3776
+ * Discriminated by 'stage' field for type narrowing
3777
+ */
3778
+ type AgentLifecycleEvent = AgentLifecycleStartedEvent | AgentLifecycleCompletedEvent | AgentLifecycleFailedEvent;
3779
+ /**
3780
+ * Placeholder data for MVP
3781
+ * Will be typed per actionType in future
3782
+ */
3783
+ interface ActionPlaceholderData {
3784
+ message: string;
3785
+ }
3786
+ /**
3787
+ * Iteration event - captures activities during agent iterations
3788
+ * Consolidates reasoning (LLM thought process) and actions (tool use, memory ops, etc.)
3789
+ */
3790
+ interface AgentIterationEvent {
3791
+ type: 'agent';
3792
+ agentId: string;
3793
+ lifecycle: 'iteration';
3794
+ eventType: IterationEventType;
3795
+ iteration: number;
3796
+ sessionId?: string;
3797
+ startTime: number;
3798
+ endTime: number;
3799
+ duration: number;
3800
+ output?: string;
3801
+ actionType?: string;
3802
+ data?: ActionPlaceholderData;
3803
+ }
3804
+ /**
3805
+ * Tool call event - captures individual tool executions during iterations
3806
+ * Provides granular timing for each tool invocation
3807
+ */
3808
+ interface AgentToolCallEvent {
3809
+ type: 'agent';
3810
+ agentId: string;
3811
+ lifecycle: 'iteration';
3812
+ eventType: 'tool-call';
3813
+ iteration: number;
3814
+ sessionId?: string;
3815
+ toolName: string;
3816
+ startTime: number;
3817
+ endTime: number;
3818
+ duration: number;
3819
+ success: boolean;
3820
+ error?: string;
3821
+ input?: Record<string, unknown>;
3822
+ output?: unknown;
3823
+ }
3824
+ /**
3825
+ * Union type for all agent log contexts
3826
+ * 3 event types total (lifecycle, iteration, tool-call)
3827
+ */
3828
+ type AgentLogContext = AgentLifecycleEvent | AgentIterationEvent | AgentToolCallEvent;
3829
+
3830
+ /**
3831
+ * Base execution logger for Execution Engine
3832
+ */
3833
+ type ExecutionLogLevel = 'debug' | 'info' | 'warn' | 'error';
3834
+
3835
+ type LogContext = WorkflowLogContext | AgentLogContext;
3836
+ interface ExecutionLogMessage {
3837
+ level: ExecutionLogLevel;
3838
+ message: string;
3839
+ timestamp: number;
3840
+ context?: LogContext;
3841
+ }
3842
+
3843
+ declare const LinkSchema: z.ZodObject<{
3844
+ nodeId: z.ZodString;
3845
+ kind: z.ZodEnum<{
3846
+ affects: "affects";
3847
+ actions: "actions";
3848
+ effects: "effects";
3849
+ links: "links";
3850
+ reads: "reads";
3851
+ writes: "writes";
3852
+ emits: "emits";
3853
+ triggers: "triggers";
3854
+ uses: "uses";
3855
+ approval: "approval";
3856
+ contains: "contains";
3857
+ references: "references";
3858
+ maps_to: "maps_to";
3859
+ governs: "governs";
3860
+ originates_from: "originates_from";
3861
+ applies_to: "applies_to";
3862
+ uses_catalog: "uses_catalog";
3863
+ }>;
3864
+ }, z.core.$strip>;
3865
+ type Link = z.infer<typeof LinkSchema>;
3866
+
3867
+ declare const ResourceCategorySchema: z.ZodEnum<{
3868
+ diagnostic: "diagnostic";
3869
+ production: "production";
3870
+ internal: "internal";
3871
+ testing: "testing";
3872
+ }>;
3873
+ type ResourceCategory = z.infer<typeof ResourceCategorySchema>;
3874
+ type ResourceLink = Link;
3875
+
3876
+ /**
3877
+ * Serialized Registry Types
3878
+ *
3879
+ * Pre-computed JSON-safe types for API responses and Command View.
3880
+ * Serialization happens once at API startup, enabling instant response times.
3881
+ */
3882
+
3883
+ /**
3884
+ * Serialized agent definition (JSON-safe)
3885
+ * Result of serializeDefinition(AgentDefinition)
3886
+ */
3887
+ interface SerializedAgentDefinition {
3888
+ config: {
3889
+ resourceId: string;
3890
+ name: string;
3891
+ description: string;
3892
+ version: string;
3893
+ type: 'agent';
3894
+ kind: 'orchestrator' | 'specialist' | 'utility' | 'system';
3895
+ status: 'dev' | 'prod';
3896
+ links?: ResourceLink[];
3897
+ category?: ResourceCategory;
3898
+ /** Whether this resource is archived and should be excluded from registration and deployment */
3899
+ archived?: boolean;
3900
+ systemPrompt: string;
3901
+ constraints?: {
3902
+ maxIterations?: number;
3903
+ timeout?: number;
3904
+ maxSessionMemoryKeys?: number;
3905
+ maxMemoryTokens?: number;
3906
+ };
3907
+ sessionCapable?: boolean;
3908
+ memoryPreferences?: string;
3909
+ };
3910
+ modelConfig: {
3911
+ provider: string;
3912
+ model: string;
3913
+ apiKey: string;
3914
+ temperature: number;
3915
+ maxOutputTokens: number;
3916
+ topP?: number;
3917
+ modelOptions?: Record<string, unknown>;
3918
+ };
3919
+ contract: {
3920
+ inputSchema: object;
3921
+ outputSchema?: object;
3922
+ };
3923
+ tools: Array<{
3924
+ name: string;
3925
+ description: string;
3926
+ inputSchema?: object;
3927
+ outputSchema?: object;
3928
+ }>;
3929
+ knowledgeMap?: {
3930
+ nodeCount: number;
3931
+ nodes: Array<{
3932
+ id: string;
3933
+ description: string;
3934
+ loaded: boolean;
3935
+ hasPrompt: boolean;
3936
+ }>;
3937
+ };
3938
+ metricsConfig?: object;
3939
+ }
3940
+ /**
3941
+ * Serialized workflow definition (JSON-safe)
3942
+ * Result of serializeDefinition(WorkflowDefinition)
3943
+ */
3944
+ interface SerializedWorkflowDefinition {
3945
+ config: {
3946
+ resourceId: string;
3947
+ name: string;
3948
+ description: string;
3949
+ version: string;
3950
+ type: 'workflow';
3951
+ status: 'dev' | 'prod';
3952
+ links?: ResourceLink[];
3953
+ category?: ResourceCategory;
3954
+ /** Whether this resource is archived and should be excluded from registration and deployment */
3955
+ archived?: boolean;
3956
+ };
3957
+ entryPoint: string;
3958
+ steps: Array<{
3959
+ id: string;
3960
+ name: string;
3961
+ description: string;
3962
+ inputSchema?: object;
3963
+ outputSchema?: object;
3964
+ next: {
3965
+ type: 'linear' | 'conditional';
3966
+ target?: string;
3967
+ routes?: Array<{
3968
+ target: string;
3969
+ }>;
3970
+ default?: string;
3971
+ } | null;
3972
+ }>;
3973
+ contract: {
3974
+ inputSchema: object;
3975
+ outputSchema?: object;
3976
+ };
3977
+ metricsConfig?: object;
3978
+ }
3732
3979
 
3733
- type SupabaseUserProfile = Tables<'users'>;
3734
- type SupabaseApiKey = Tables<'api_keys'>;
3735
- /** API response type for API key list items (omits sensitive key_hash) */
3736
- type ApiKeyListItem = Omit<SupabaseApiKey, 'key_hash'>;
3980
+ /**
3981
+ * Shared form field types for dynamic form generation
3982
+ * Used by: Command Queue, Execution Runner UI, future form-based features
3983
+ */
3984
+ /**
3985
+ * Supported form field types for action payloads
3986
+ * Maps to Mantine form components
3987
+ */
3988
+ type FormFieldType = 'text' | 'textarea' | 'number' | 'select' | 'checkbox' | 'radio' | 'richtext';
3989
+ /**
3990
+ * Form field definition
3991
+ */
3992
+ interface FormField {
3993
+ /** Field key in payload object */
3994
+ name: string;
3995
+ /** Field label for UI */
3996
+ label: string;
3997
+ /** Field type (determines UI component) */
3998
+ type: FormFieldType;
3999
+ /** Default value */
4000
+ defaultValue?: unknown;
4001
+ /** Required field */
4002
+ required?: boolean;
4003
+ /** Placeholder text */
4004
+ placeholder?: string;
4005
+ /** Help text */
4006
+ description?: string;
4007
+ /** Options for select/radio */
4008
+ options?: Array<{
4009
+ label: string;
4010
+ value: string | number;
4011
+ }>;
4012
+ /** Min/max for number */
4013
+ min?: number;
4014
+ max?: number;
4015
+ /** Path to context value for pre-filling (dot notation, e.g., 'proposal.summary') */
4016
+ defaultValueFromContext?: string;
4017
+ }
4018
+ /**
4019
+ * Form schema for action payload collection
4020
+ */
4021
+ interface FormSchema {
4022
+ /** Form title */
4023
+ title?: string;
4024
+ /** Form description */
4025
+ description?: string;
4026
+ /** Form fields */
4027
+ fields: FormField[];
4028
+ }
4029
+
4030
+ /**
4031
+ * Memory type definitions
4032
+ * Types for agent memory management with semantic entry types
4033
+ */
4034
+ /**
4035
+ * Semantic memory entry types
4036
+ * Use-case agnostic types that describe the purpose of each entry
4037
+ * Memory types mirror action types for clarity and filtering
4038
+ */
4039
+ type MemoryEntryType = 'context' | 'input' | 'reasoning' | 'tool-result' | 'delegation-result' | 'error';
4040
+ /**
4041
+ * Memory entry - represents a single entry in agent memory
4042
+ * Stored in agent memory, translated by adapters to vendor-specific formats
4043
+ */
4044
+ interface MemoryEntry {
4045
+ type: MemoryEntryType;
4046
+ content: string;
4047
+ timestamp: number;
4048
+ turnNumber: number | null;
4049
+ iterationNumber: number | null;
4050
+ }
4051
+ /**
4052
+ * Agent memory - Self-orchestrated memory with session + working storage
4053
+ * Agent has full control over what persists, framework handles auto-compaction
4054
+ */
4055
+ interface AgentMemory {
4056
+ /**
4057
+ * Session memory - Persists for session/conversation duration
4058
+ * Never auto-trimmed by framework
4059
+ * Agent-managed key-value store for critical information
4060
+ * Agent provides strings, framework wraps in MemoryEntry
4061
+ */
4062
+ sessionMemory: Record<string, MemoryEntry>;
4063
+ /**
4064
+ * Working memory - Execution history
4065
+ * Automatically compacted by framework when needed
4066
+ * Agent doesn't control compaction
4067
+ */
4068
+ history: MemoryEntry[];
4069
+ }
3737
4070
 
3738
4071
  declare const TransitionItemRequestSchema: z.ZodObject<{
3739
4072
  pipelineKey: z.ZodString;
@@ -4016,785 +4349,474 @@ interface DealPriority {
4016
4349
  label: string;
4017
4350
  color: string;
4018
4351
  reason: string;
4019
- latestActivityAt: string | null;
4020
- nextActionAt: string | null;
4021
- }
4022
- interface DealContact {
4023
- id: string;
4024
- first_name: string | null;
4025
- last_name: string | null;
4026
- email: string;
4027
- title: string | null;
4028
- headline: string | null;
4029
- linkedin_url: string | null;
4030
- processing_state: Record<string, unknown> | null;
4031
- enrichment_data: Record<string, unknown> | null;
4032
- company: {
4033
- id: string;
4034
- name: string;
4035
- domain: string | null;
4036
- website: string | null;
4037
- linkedin_url: string | null;
4038
- segment: string | null;
4039
- category: string | null;
4040
- num_employees: number | null;
4041
- } | null;
4042
- }
4043
- interface DealFilters {
4044
- stage?: DealStage;
4045
- search?: string;
4046
- limit?: number;
4047
- offset?: number;
4048
- }
4049
- /** Deal list item with joined contact and company data */
4050
- interface DealListItem extends AcqDealRow {
4051
- priority: DealPriority;
4052
- ownership: 'us' | 'them' | null;
4053
- nextAction: string | null;
4054
- contact: DealContact | null;
4055
- }
4056
- type DealDetail$1 = DealListItem;
4057
- /** Task kind options for a deal task (human follow-up action type) */
4058
- type AcqDealTaskKind = 'call' | 'email' | 'meeting' | 'other';
4059
- /**
4060
- * A CRM to-do item attached to a deal representing a human follow-up action.
4061
- * Transformed from AcqDealTaskRow with camelCase properties.
4062
- */
4063
- interface AcqDealTask {
4064
- id: string;
4065
- organizationId: string;
4066
- dealId: string;
4067
- title: string;
4068
- description: string | null;
4069
- kind: AcqDealTaskKind;
4070
- dueAt: string | null;
4071
- assigneeUserId: string | null;
4072
- completedAt: string | null;
4073
- completedByUserId: string | null;
4074
- createdAt: string;
4075
- updatedAt: string;
4076
- createdByUserId: string | null;
4077
- }
4078
- /**
4079
- * Live-scan aggregate telemetry for a single list, computed on demand from
4080
- * the list junction tables and current contact deliverability state.
4081
- * `stageCounts` are attempted counts from list-row processing_state.
4082
- */
4083
- interface ListTelemetry {
4084
- listId: string;
4085
- totalCompanies: number;
4086
- totalContacts: number;
4087
- stageCounts: {
4088
- populated: number;
4089
- extracted: number;
4090
- qualified: number;
4091
- discovered: number;
4092
- verified: number;
4093
- personalized: number;
4094
- uploaded: number;
4095
- };
4096
- deliverability: {
4097
- valid: number;
4098
- risky: number;
4099
- invalid: number;
4100
- unknown: number;
4101
- bounced: number;
4102
- };
4103
- /** Reserved -- active workflow IDs associated with this list. */
4104
- activeWorkflows?: string[];
4105
- }
4106
-
4107
- /**
4108
- * Lead Service Types
4109
- * CRUD operation types for the acquisition platform (lists, companies, contacts, deals)
4110
- *
4111
- * Implementation: apps/api/src/acquisition/lead-service.ts (LeadService class)
4112
- */
4113
-
4114
- interface AcqDealNote {
4115
- id: string;
4116
- dealId: string;
4117
- organizationId: string;
4118
- authorUserId: string | null;
4119
- body: string;
4120
- createdAt: string;
4121
- updatedAt: string;
4122
- }
4123
-
4124
- /**
4125
- * Action configuration for HITL tasks
4126
- * Defines available user actions and their behavior
4127
- */
4128
- interface ActionConfig {
4129
- /** Unique action identifier (e.g., 'approve', 'retry', 'escalate') */
4130
- id: string;
4131
- /** Display label for UI button */
4132
- label: string;
4133
- /** Button variant/style */
4134
- type: 'primary' | 'secondary' | 'danger' | 'outline';
4135
- /** Tabler icon name (e.g., 'IconCheck', 'IconRefresh') */
4136
- icon?: string;
4137
- /** Button color (Mantine theme colors) */
4138
- color?: string;
4139
- /** Button variant (Mantine button variant, e.g., 'light', 'filled', 'outline') */
4140
- variant?: string;
4141
- /** Execution target (agent/workflow to invoke) */
4142
- target?: {
4143
- resourceType: 'agent' | 'workflow';
4144
- resourceId: string;
4145
- /**
4146
- * Optional session ID for agent continuation.
4147
- * If provided, invokes a new turn on the existing session instead of standalone execution.
4148
- * Only valid when resourceType is 'agent'.
4149
- */
4150
- sessionId?: string;
4151
- };
4152
- /** Form schema for collecting action-specific data */
4153
- form?: FormSchema;
4154
- /** Payload template for pre-filling forms */
4155
- payloadTemplate?: unknown;
4156
- /** Requires confirmation dialog */
4157
- requiresConfirmation?: boolean;
4158
- /** Confirmation message */
4159
- confirmationMessage?: string;
4160
- /** Help text / tooltip */
4161
- description?: string;
4162
- }
4163
-
4164
- /**
4165
- * Origin resource type - where an execution/task originated from.
4166
- * Used for audit trails and tracking execution lineage.
4167
- */
4168
- type OriginResourceType = 'agent' | 'workflow' | 'scheduler' | 'api';
4169
- /**
4170
- * Origin tracking metadata - who/what created this execution/task.
4171
- * Used by both TaskScheduler and CommandQueue for complete audit trails.
4172
- */
4173
- interface OriginTracking {
4174
- originExecutionId: string;
4175
- originResourceType: OriginResourceType;
4176
- originResourceId: string;
4177
- }
4178
-
4179
- /**
4180
- * Command queue task with flexible action system
4181
- */
4182
- interface Task extends OriginTracking {
4183
- id: string;
4184
- organizationId: string;
4185
- actions: ActionConfig[];
4186
- context: unknown;
4187
- selectedAction?: string;
4188
- actionPayload?: unknown;
4189
- description?: string;
4190
- priority: number;
4191
- /** Optional checkpoint identifier for grouping related human approval tasks */
4192
- humanCheckpoint?: string;
4193
- status: QueueTaskStatus;
4194
- /**
4195
- * Target resource tracking — mirrors origin columns.
4196
- * Set when task is created; patchable to redirect execution to a different resource.
4197
- */
4198
- targetResourceId?: string;
4199
- targetResourceType?: 'agent' | 'workflow';
4200
- /**
4201
- * Execution ID for the action that runs AFTER user approval.
4202
- * NULL until execution starts.
4203
- *
4204
- * Naming distinction:
4205
- * - originExecutionId = Parent execution that CREATED the HITL task
4206
- * - targetExecutionId = Child execution that RUNS AFTER user approval
4207
- */
4208
- targetExecutionId?: string;
4209
- createdAt: Date;
4210
- completedAt?: Date;
4211
- completedBy?: string;
4212
- expiresAt?: Date;
4213
- idempotencyKey?: string | null;
4214
- }
4215
- /**
4216
- * Task status values
4217
- * - pending: awaiting action
4218
- * - processing: execution in progress after user approval
4219
- * - completed: action was taken and execution succeeded
4220
- * - failed: execution failed, task can be retried
4221
- * - expired: timed out before action
4222
- */
4223
- type QueueTaskStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'expired';
4224
- /**
4225
- * Parameters for patching mutable metadata on a task
4226
- */
4227
- interface PatchTaskParams {
4228
- humanCheckpoint?: string | null;
4229
- description?: string;
4230
- priority?: number;
4231
- context?: Record<string, unknown>;
4232
- actions?: unknown[];
4233
- targetResourceId?: string | null;
4234
- targetResourceType?: 'agent' | 'workflow' | null;
4235
- targetExecutionId?: string;
4236
- status?: 'pending' | 'failed' | 'completed';
4237
- }
4238
- interface CommandQueueListResponse {
4239
- tasks: Task[];
4240
- total: number;
4352
+ latestActivityAt: string | null;
4353
+ nextActionAt: string | null;
4241
4354
  }
4242
-
4243
- /**
4244
- * Checkpoint list item for sidebar grouping
4245
- * The id field contains the resourceId of the human checkpoint
4246
- */
4247
- interface CheckpointListItem {
4248
- /** Human checkpoint resourceId (or 'ungrouped' for tasks without checkpoint) */
4355
+ interface DealContact {
4249
4356
  id: string;
4250
- /** Display name (same as id, or "Ungrouped" for null) */
4251
- name: string;
4252
- /** Task count for this checkpoint */
4253
- count: number;
4254
- }
4255
- /**
4256
- * Status counts for pie chart display
4257
- */
4258
- interface StatusCounts {
4259
- pending: number;
4260
- completed: number;
4261
- expired: number;
4357
+ first_name: string | null;
4358
+ last_name: string | null;
4359
+ email: string;
4360
+ title: string | null;
4361
+ headline: string | null;
4362
+ linkedin_url: string | null;
4363
+ processing_state: Record<string, unknown> | null;
4364
+ enrichment_data: Record<string, unknown> | null;
4365
+ company: {
4366
+ id: string;
4367
+ name: string;
4368
+ domain: string | null;
4369
+ website: string | null;
4370
+ linkedin_url: string | null;
4371
+ segment: string | null;
4372
+ category: string | null;
4373
+ num_employees: number | null;
4374
+ } | null;
4262
4375
  }
4263
- /**
4264
- * Priority counts for donut chart display
4265
- */
4266
- interface PriorityCounts {
4267
- critical: number;
4268
- high: number;
4269
- medium: number;
4270
- low: number;
4376
+ interface DealFilters {
4377
+ stage?: DealStage;
4378
+ search?: string;
4379
+ limit?: number;
4380
+ offset?: number;
4271
4381
  }
4272
- /**
4273
- * Response from GET /command-queue/checkpoints endpoint
4274
- */
4275
- interface CheckpointListResponse {
4276
- checkpoints: CheckpointListItem[];
4277
- /** Total tasks across all checkpoints */
4278
- total: number;
4279
- /** Breakdown by status for donut chart */
4280
- statusCounts: StatusCounts;
4281
- /** Breakdown by priority for donut chart */
4282
- priorityCounts: PriorityCounts;
4382
+ /** Deal list item with joined contact and company data */
4383
+ interface DealListItem extends AcqDealRow {
4384
+ priority: DealPriority;
4385
+ ownership: 'us' | 'them' | null;
4386
+ nextAction: string | null;
4387
+ contact: DealContact | null;
4283
4388
  }
4284
-
4389
+ type DealDetail$1 = DealListItem;
4390
+ /** Task kind options for a deal task (human follow-up action type) */
4391
+ type AcqDealTaskKind = 'call' | 'email' | 'meeting' | 'other';
4285
4392
  /**
4286
- * Target for schedule execution - identifies what resource to execute.
4287
- * Unlike ExecutionTarget, payload is NOT included here because schedules
4288
- * store payload in the scheduleConfig (varies per step/item).
4393
+ * A CRM to-do item attached to a deal representing a human follow-up action.
4394
+ * Transformed from AcqDealTaskRow with camelCase properties.
4289
4395
  */
4290
- interface ScheduleTarget {
4291
- resourceType: 'agent' | 'workflow';
4292
- resourceId: string;
4396
+ interface AcqDealTask {
4397
+ id: string;
4398
+ organizationId: string;
4399
+ dealId: string;
4400
+ title: string;
4401
+ description: string | null;
4402
+ kind: AcqDealTaskKind;
4403
+ dueAt: string | null;
4404
+ assigneeUserId: string | null;
4405
+ completedAt: string | null;
4406
+ completedByUserId: string | null;
4407
+ createdAt: string;
4408
+ updatedAt: string;
4409
+ createdByUserId: string | null;
4293
4410
  }
4294
4411
  /**
4295
- * Optional origin tracking for schedules.
4296
- * Unlike OriginTracking (which is required), these fields are all optional
4297
- * for schedules created directly via API (not triggered by another resource).
4412
+ * Live-scan aggregate telemetry for a single list, computed on demand from
4413
+ * the list junction tables and current contact deliverability state.
4414
+ * `stageCounts` are attempted counts from list-row processing_state.
4298
4415
  */
4299
- interface ScheduleOriginTracking {
4300
- originExecutionId?: string;
4301
- originResourceType?: OriginResourceType;
4302
- originResourceId?: string;
4303
- }
4304
- type TaskScheduleConfig = RecurringScheduleConfig | RelativeScheduleConfig | AbsoluteScheduleConfig;
4305
- interface RecurringScheduleConfig {
4306
- type: 'recurring';
4307
- cron?: string;
4308
- interval?: 'daily' | 'weekly' | 'monthly';
4309
- time?: string;
4310
- timezone: string;
4311
- payload: Record<string, unknown>;
4312
- endAt?: string | null;
4313
- overduePolicy?: 'skip' | 'execute';
4314
- }
4315
- interface RelativeScheduleConfig {
4316
- type: 'relative';
4317
- anchorAt: string;
4318
- anchorLabel?: string;
4319
- items: RelativeScheduleItem[];
4320
- overduePolicy?: 'skip' | 'execute';
4321
- }
4322
- interface RelativeScheduleItem {
4323
- offset: string;
4324
- payload: Record<string, unknown>;
4325
- label?: string;
4326
- }
4327
- interface AbsoluteScheduleConfig {
4328
- type: 'absolute';
4329
- items: AbsoluteScheduleItem[];
4330
- overduePolicy?: 'skip' | 'execute';
4331
- }
4332
- interface AbsoluteScheduleItem {
4333
- runAt: string;
4334
- payload: Record<string, unknown>;
4335
- label?: string;
4336
- }
4337
- interface TaskSchedule extends ScheduleOriginTracking {
4338
- id: string;
4339
- organizationId: string;
4340
- name: string;
4341
- description?: string;
4342
- target: ScheduleTarget;
4343
- scheduleConfig: TaskScheduleConfig;
4344
- nextRunAt?: Date;
4345
- currentStep: number;
4346
- status: 'active' | 'paused' | 'completed' | 'cancelled';
4347
- lastRunAt?: Date;
4348
- lastExecutionId?: string;
4349
- maxRetries: number;
4350
- idempotencyKey?: string;
4351
- createdAt: Date;
4352
- updatedAt: Date;
4416
+ interface ListTelemetry {
4417
+ listId: string;
4418
+ totalCompanies: number;
4419
+ totalContacts: number;
4420
+ stageCounts: {
4421
+ populated: number;
4422
+ extracted: number;
4423
+ qualified: number;
4424
+ discovered: number;
4425
+ verified: number;
4426
+ personalized: number;
4427
+ uploaded: number;
4428
+ };
4429
+ deliverability: {
4430
+ valid: number;
4431
+ risky: number;
4432
+ invalid: number;
4433
+ unknown: number;
4434
+ bounced: number;
4435
+ };
4436
+ /** Reserved -- active workflow IDs associated with this list. */
4437
+ activeWorkflows?: string[];
4353
4438
  }
4354
4439
 
4355
4440
  /**
4356
- * Wire-format DTO for notification API responses.
4357
- * Dates are ISO 8601 strings (not Date objects like the domain Notification type).
4358
- * Used by frontend hooks that consume /api/notifications.
4441
+ * Lead Service Types
4442
+ * CRUD operation types for the acquisition platform (lists, companies, contacts, deals)
4443
+ *
4444
+ * Implementation: apps/api/src/acquisition/lead-service.ts (LeadService class)
4359
4445
  */
4360
- interface NotificationDTO {
4446
+
4447
+ interface AcqDealNote {
4361
4448
  id: string;
4362
- userId: string;
4449
+ dealId: string;
4363
4450
  organizationId: string;
4364
- category: string;
4365
- title: string;
4366
- message: string;
4367
- actionUrl: string | null;
4368
- read: boolean;
4369
- readAt: string | null;
4451
+ authorUserId: string | null;
4452
+ body: string;
4370
4453
  createdAt: string;
4371
- }
4372
-
4373
- type ProjectRow = Database['public']['Tables']['prj_projects']['Row'];
4374
- type ProjectUpdate = Database['public']['Tables']['prj_projects']['Update'];
4375
- type MilestoneRow = Database['public']['Tables']['prj_milestones']['Row'];
4376
- type MilestoneUpdate = Database['public']['Tables']['prj_milestones']['Update'];
4377
- type TaskRow = Database['public']['Tables']['prj_tasks']['Row'];
4378
- type TaskUpdate = Database['public']['Tables']['prj_tasks']['Update'];
4379
- type ProjectStatus = 'active' | 'on_track' | 'at_risk' | 'blocked' | 'completed' | 'paused';
4380
- type ProjectKind = 'client_engagement' | 'internal' | 'research' | 'other';
4381
- type MilestoneStatus = 'upcoming' | 'in_progress' | 'completed' | 'overdue' | 'blocked';
4382
- type TaskStatus = 'planned' | 'in_progress' | 'blocked' | 'completed' | 'cancelled' | 'submitted' | 'approved' | 'rejected' | 'revision_requested';
4383
- type TaskType = 'documentation' | 'code' | 'report' | 'design' | 'other';
4384
- type NoteType = 'call_note' | 'status_update' | 'issue' | 'blocker' | 'agent_learning';
4385
- interface ProjectFilters {
4386
- status?: ProjectStatus;
4387
- kind?: ProjectKind;
4388
- companyId?: string;
4389
- search?: string;
4390
- }
4391
- interface MilestoneFilters {
4392
- status?: MilestoneStatus;
4393
- projectId?: string;
4394
- }
4395
- interface TaskFilters {
4396
- status?: TaskStatus;
4397
- type?: TaskType;
4398
- milestoneId?: string;
4399
- projectId?: string;
4400
- }
4401
- interface NoteFilters {
4402
- type?: NoteType;
4403
- projectId?: string;
4404
- }
4405
- interface ProjectWithCounts extends ProjectRow {
4406
- milestoneCount: number;
4407
- taskCount: number;
4408
- completedMilestones?: number;
4409
- completedTasks?: number;
4410
- }
4411
- interface ProjectDetail extends ProjectRow {
4412
- milestones: MilestoneRow[];
4413
- tasks: TaskRow[];
4414
- company: {
4415
- id: string;
4416
- name: string;
4417
- domain: string | null;
4418
- } | null;
4419
- deal: ProjectSourceDealRef | null;
4420
- client: ProjectClientRef | null;
4421
- }
4422
- interface ProjectSourceDealRef {
4423
- id: string;
4424
- clientId?: string | null;
4425
- contactEmail: string;
4426
- stageKey: string | null;
4427
- stateKey: string | null;
4428
- sourceListId: string | null;
4429
4454
  updatedAt: string;
4430
4455
  }
4431
- interface ProjectClientRef {
4432
- id: string;
4433
- name: string;
4434
- status: string;
4435
- }
4436
-
4437
- interface Action {
4438
- key: string;
4439
- label: string;
4440
- payloadSchema?: z.ZodTypeAny;
4441
- }
4442
-
4443
- declare const OntologyScopeSchema: z.ZodDefault<z.ZodObject<{
4444
- objectTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4445
- id: z.ZodString;
4446
- label: z.ZodOptional<z.ZodString>;
4447
- description: z.ZodOptional<z.ZodString>;
4448
- ownerSystemId: z.ZodOptional<z.ZodString>;
4449
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
4450
- properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
4451
- storage: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
4452
- }, z.core.$loose>>>>;
4453
- linkTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4454
- id: z.ZodString;
4455
- label: z.ZodOptional<z.ZodString>;
4456
- description: z.ZodOptional<z.ZodString>;
4457
- ownerSystemId: z.ZodOptional<z.ZodString>;
4458
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
4459
- from: z.ZodString;
4460
- to: z.ZodString;
4461
- cardinality: z.ZodOptional<z.ZodString>;
4462
- via: z.ZodOptional<z.ZodString>;
4463
- }, z.core.$loose>>>>;
4464
- actionTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4465
- id: z.ZodString;
4466
- label: z.ZodOptional<z.ZodString>;
4467
- description: z.ZodOptional<z.ZodString>;
4468
- ownerSystemId: z.ZodOptional<z.ZodString>;
4469
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
4470
- actsOn: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
4471
- input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
4472
- effects: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
4473
- }, z.core.$loose>>>>;
4474
- catalogTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4475
- id: z.ZodString;
4476
- label: z.ZodOptional<z.ZodString>;
4477
- description: z.ZodOptional<z.ZodString>;
4478
- ownerSystemId: z.ZodOptional<z.ZodString>;
4479
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
4480
- kind: z.ZodOptional<z.ZodString>;
4481
- appliesTo: z.ZodOptional<z.ZodString>;
4482
- entries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
4483
- }, z.core.$loose>>>>;
4484
- eventTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4485
- id: z.ZodString;
4486
- label: z.ZodOptional<z.ZodString>;
4487
- description: z.ZodOptional<z.ZodString>;
4488
- ownerSystemId: z.ZodOptional<z.ZodString>;
4489
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
4490
- payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
4491
- }, z.core.$loose>>>>;
4492
- interfaceTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4493
- id: z.ZodString;
4494
- label: z.ZodOptional<z.ZodString>;
4495
- description: z.ZodOptional<z.ZodString>;
4496
- ownerSystemId: z.ZodOptional<z.ZodString>;
4497
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
4498
- properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
4499
- }, z.core.$loose>>>>;
4500
- valueTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4501
- id: z.ZodString;
4502
- label: z.ZodOptional<z.ZodString>;
4503
- description: z.ZodOptional<z.ZodString>;
4504
- ownerSystemId: z.ZodOptional<z.ZodString>;
4505
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
4506
- primitive: z.ZodOptional<z.ZodString>;
4507
- }, z.core.$loose>>>>;
4508
- sharedProperties: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4509
- id: z.ZodString;
4510
- label: z.ZodOptional<z.ZodString>;
4511
- description: z.ZodOptional<z.ZodString>;
4512
- ownerSystemId: z.ZodOptional<z.ZodString>;
4513
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
4514
- valueType: z.ZodOptional<z.ZodString>;
4515
- searchable: z.ZodOptional<z.ZodBoolean>;
4516
- pii: z.ZodOptional<z.ZodBoolean>;
4517
- }, z.core.$loose>>>>;
4518
- groups: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4519
- id: z.ZodString;
4520
- label: z.ZodOptional<z.ZodString>;
4521
- description: z.ZodOptional<z.ZodString>;
4522
- ownerSystemId: z.ZodOptional<z.ZodString>;
4523
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
4524
- members: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
4525
- }, z.core.$loose>>>>;
4526
- surfaces: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4527
- id: z.ZodString;
4528
- label: z.ZodOptional<z.ZodString>;
4529
- description: z.ZodOptional<z.ZodString>;
4530
- ownerSystemId: z.ZodOptional<z.ZodString>;
4531
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
4532
- route: z.ZodOptional<z.ZodString>;
4533
- }, z.core.$loose>>>>;
4534
- }, z.core.$strip>>;
4535
- type OntologyScope = z.infer<typeof OntologyScopeSchema>;
4536
4456
 
4537
- type JsonPrimitive = string | number | boolean | null;
4538
- type JsonValue = JsonPrimitive | JsonValue[] | {
4539
- [key: string]: JsonValue;
4540
- };
4541
- /** Explicit interface needed to annotate the recursive SystemEntrySchema. */
4542
- interface SystemEntry {
4457
+ /**
4458
+ * Action configuration for HITL tasks
4459
+ * Defines available user actions and their behavior
4460
+ */
4461
+ interface ActionConfig {
4462
+ /** Unique action identifier (e.g., 'approve', 'retry', 'escalate') */
4543
4463
  id: string;
4544
- label?: string;
4545
- title?: string;
4546
- description?: string;
4547
- kind?: 'product' | 'operational' | 'platform' | 'diagnostic';
4548
- parentSystemId?: string;
4549
- ui?: {
4550
- path: string;
4551
- surfaces: string[];
4552
- icon?: string;
4553
- order?: number;
4554
- };
4555
- lifecycle?: 'draft' | 'beta' | 'active' | 'deprecated' | 'archived';
4556
- responsibleRoleId?: string;
4557
- governedByKnowledge?: string[];
4558
- actions?: {
4559
- actionId: string;
4560
- intent: 'exposes' | 'consumes';
4561
- invocation?: unknown;
4562
- }[];
4563
- policies?: string[];
4564
- drivesGoals?: string[];
4565
- /** @deprecated Use lifecycle. Accepted for one publish cycle. */
4566
- status?: 'active' | 'deprecated' | 'archived';
4567
- path?: string;
4464
+ /** Display label for UI button */
4465
+ label: string;
4466
+ /** Button variant/style */
4467
+ type: 'primary' | 'secondary' | 'danger' | 'outline';
4468
+ /** Tabler icon name (e.g., 'IconCheck', 'IconRefresh') */
4568
4469
  icon?: string;
4470
+ /** Button color (Mantine theme colors) */
4569
4471
  color?: string;
4570
- uiPosition?: 'sidebar-primary' | 'sidebar-bottom';
4571
- enabled?: boolean;
4572
- devOnly?: boolean;
4573
- requiresAdmin?: boolean;
4574
- order: number;
4575
- config?: Record<string, JsonValue>;
4576
- ontology?: OntologyScope;
4577
- systems?: Record<string, SystemEntry>;
4578
- subsystems?: Record<string, SystemEntry>;
4472
+ /** Button variant (Mantine button variant, e.g., 'light', 'filled', 'outline') */
4473
+ variant?: string;
4474
+ /** Execution target (agent/workflow to invoke) */
4475
+ target?: {
4476
+ resourceType: 'agent' | 'workflow';
4477
+ resourceId: string;
4478
+ /**
4479
+ * Optional session ID for agent continuation.
4480
+ * If provided, invokes a new turn on the existing session instead of standalone execution.
4481
+ * Only valid when resourceType is 'agent'.
4482
+ */
4483
+ sessionId?: string;
4484
+ };
4485
+ /** Form schema for collecting action-specific data */
4486
+ form?: FormSchema;
4487
+ /** Payload template for pre-filling forms */
4488
+ payloadTemplate?: unknown;
4489
+ /** Requires confirmation dialog */
4490
+ requiresConfirmation?: boolean;
4491
+ /** Confirmation message */
4492
+ confirmationMessage?: string;
4493
+ /** Help text / tooltip */
4494
+ description?: string;
4579
4495
  }
4580
4496
 
4581
- declare const LinkSchema: z.ZodObject<{
4582
- nodeId: z.ZodString;
4583
- kind: z.ZodEnum<{
4584
- affects: "affects";
4585
- actions: "actions";
4586
- effects: "effects";
4587
- links: "links";
4588
- reads: "reads";
4589
- writes: "writes";
4590
- emits: "emits";
4591
- triggers: "triggers";
4592
- uses: "uses";
4593
- approval: "approval";
4594
- contains: "contains";
4595
- references: "references";
4596
- maps_to: "maps_to";
4597
- governs: "governs";
4598
- originates_from: "originates_from";
4599
- applies_to: "applies_to";
4600
- uses_catalog: "uses_catalog";
4601
- }>;
4602
- }, z.core.$strip>;
4603
- type Link = z.infer<typeof LinkSchema>;
4497
+ /**
4498
+ * Origin resource type - where an execution/task originated from.
4499
+ * Used for audit trails and tracking execution lineage.
4500
+ */
4501
+ type OriginResourceType = 'agent' | 'workflow' | 'scheduler' | 'api';
4502
+ /**
4503
+ * Origin tracking metadata - who/what created this execution/task.
4504
+ * Used by both TaskScheduler and CommandQueue for complete audit trails.
4505
+ */
4506
+ interface OriginTracking {
4507
+ originExecutionId: string;
4508
+ originResourceType: OriginResourceType;
4509
+ originResourceId: string;
4510
+ }
4604
4511
 
4605
- type MessageType = MessageEvent['type'];
4606
4512
  /**
4607
- * Session Data Transfer Object (DTO)
4608
- * Transform type for API responses (snake_case DB → camelCase frontend)
4609
- * Used by frontend apps to display session data
4513
+ * Command queue task with flexible action system
4610
4514
  */
4611
- interface SessionDTO {
4612
- sessionId: string;
4613
- resourceId: string;
4515
+ interface Task extends OriginTracking {
4516
+ id: string;
4614
4517
  organizationId: string;
4615
- userId?: string | null;
4616
- turnCount: number;
4617
- isEnded: boolean;
4618
- title?: string | null;
4619
- memorySnapshot?: AgentMemory;
4620
- metadata?: Record<string, unknown> | null;
4518
+ actions: ActionConfig[];
4519
+ context: unknown;
4520
+ selectedAction?: string;
4521
+ actionPayload?: unknown;
4522
+ description?: string;
4523
+ priority: number;
4524
+ /** Optional checkpoint identifier for grouping related human approval tasks */
4525
+ humanCheckpoint?: string;
4526
+ status: QueueTaskStatus;
4527
+ /**
4528
+ * Target resource tracking — mirrors origin columns.
4529
+ * Set when task is created; patchable to redirect execution to a different resource.
4530
+ */
4531
+ targetResourceId?: string;
4532
+ targetResourceType?: 'agent' | 'workflow';
4533
+ /**
4534
+ * Execution ID for the action that runs AFTER user approval.
4535
+ * NULL until execution starts.
4536
+ *
4537
+ * Naming distinction:
4538
+ * - originExecutionId = Parent execution that CREATED the HITL task
4539
+ * - targetExecutionId = Child execution that RUNS AFTER user approval
4540
+ */
4541
+ targetExecutionId?: string;
4621
4542
  createdAt: Date;
4622
- updatedAt: Date;
4623
- endedAt?: Date | null;
4543
+ completedAt?: Date;
4544
+ completedBy?: string;
4545
+ expiresAt?: Date;
4546
+ idempotencyKey?: string | null;
4624
4547
  }
4625
- interface ChatMessage {
4626
- id: string;
4627
- role: 'user' | 'assistant';
4628
- messageType: MessageType;
4629
- text: string;
4630
- metadata?: MessageEvent;
4631
- turnNumber: number;
4632
- messageIndex?: number;
4633
- createdAt: Date;
4548
+ /**
4549
+ * Task status values
4550
+ * - pending: awaiting action
4551
+ * - processing: execution in progress after user approval
4552
+ * - completed: action was taken and execution succeeded
4553
+ * - failed: execution failed, task can be retried
4554
+ * - expired: timed out before action
4555
+ */
4556
+ type QueueTaskStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'expired';
4557
+ /**
4558
+ * Parameters for patching mutable metadata on a task
4559
+ */
4560
+ interface PatchTaskParams {
4561
+ humanCheckpoint?: string | null;
4562
+ description?: string;
4563
+ priority?: number;
4564
+ context?: Record<string, unknown>;
4565
+ actions?: unknown[];
4566
+ targetResourceId?: string | null;
4567
+ targetResourceType?: 'agent' | 'workflow' | null;
4568
+ targetExecutionId?: string;
4569
+ status?: 'pending' | 'failed' | 'completed';
4634
4570
  }
4635
- /** Token usage data sent with turn:complete WebSocket events */
4636
- interface SessionTokenUsage {
4637
- /** Tokens consumed by this turn's input */
4638
- turnInputTokens: number;
4639
- /** Tokens generated by this turn's output */
4640
- turnOutputTokens: number;
4641
- /** Total tokens for this turn (turnInputTokens + turnOutputTokens) */
4642
- turnTotalTokens: number;
4643
- /** Cumulative input tokens across all turns in this session */
4644
- cumulativeInputTokens: number;
4645
- /** Cumulative output tokens across all turns in this session */
4646
- cumulativeOutputTokens: number;
4647
- /** The model's context window size for this session (e.g., 200K) */
4648
- contextWindowSize: number;
4571
+ interface CommandQueueListResponse {
4572
+ tasks: Task[];
4573
+ total: number;
4649
4574
  }
4650
4575
 
4651
4576
  /**
4652
- * Single source of truth for all active theme preset names.
4653
- *
4654
- * This is the canonical list. To add a preset:
4655
- * 1. Add the name here.
4656
- * 2. Create `packages/ui/src/theme/presets/{name}.ts` exporting `{name}Preset: ThemePreset`.
4657
- * 3. Add to `PRESETS` record in `packages/ui/src/theme/presets/index.ts`.
4658
- * 4. Add to `PresetName` union in `packages/ui/src/theme/presets/types.ts`.
4659
- * 5. Add a card in `apps/command-center/src/features/settings/appearance/components/AppearanceSettings.tsx`.
4660
- *
4661
- * The union type (`ThemePresetName`) and Zod enum (`ThemePresetEnum`) are derived
4662
- * automatically — no other files need updating.
4577
+ * Checkpoint list item for sidebar grouping
4578
+ * The id field contains the resourceId of the human checkpoint
4663
4579
  */
4664
- declare const THEME_PRESETS: readonly ["default", "tactical", "regal", "cyber-volt", "aurora", "rose-gold", "midnight", "titanium", "canopy", "slate", "cyber-strike", "cyber-chrome", "cyber-void", "nirvana", "wave", "synapse", "cortex", "helios", "graphite", "quarry"];
4665
- type ThemePresetName = (typeof THEME_PRESETS)[number];
4666
-
4580
+ interface CheckpointListItem {
4581
+ /** Human checkpoint resourceId (or 'ungrouped' for tasks without checkpoint) */
4582
+ id: string;
4583
+ /** Display name (same as id, or "Ungrouped" for null) */
4584
+ name: string;
4585
+ /** Task count for this checkpoint */
4586
+ count: number;
4587
+ }
4667
4588
  /**
4668
- * Multi-tenancy configuration types
4669
- *
4670
- * Config is stored in dedicated `config` columns (NOT nested in metadata):
4671
- * - organizations.config: Org-level config (no feature toggles -- all features available by default)
4672
- * - org_memberships.config: Per-user-per-org feature overrides
4673
- * - users.config: User-global config
4589
+ * Status counts for pie chart display
4674
4590
  */
4675
-
4591
+ interface StatusCounts {
4592
+ pending: number;
4593
+ completed: number;
4594
+ expired: number;
4595
+ }
4676
4596
  /**
4677
- * Per-user-per-org config (stored in org_memberships.config)
4678
- * Controls which features a specific member can access within their org.
4679
- * Keys are feature IDs from the organization model (e.g. crm, lead-gen, projects, seo).
4597
+ * Priority counts for donut chart display
4680
4598
  */
4681
- interface MembershipFeatureConfig {
4682
- features?: Record<string, boolean>;
4599
+ interface PriorityCounts {
4600
+ critical: number;
4601
+ high: number;
4602
+ medium: number;
4603
+ low: number;
4683
4604
  }
4684
4605
  /**
4685
- * User-global config (stored in users.config)
4686
- * Theme and onboarding are user-specific, NOT org-specific
4606
+ * Response from GET /command-queue/checkpoints endpoint
4687
4607
  */
4688
- interface UserConfig {
4689
- theme?: {
4690
- preset?: ThemePresetName;
4691
- colorScheme?: 'light' | 'dark' | 'auto';
4692
- };
4693
- onboarding?: {
4694
- completed?: boolean;
4695
- completedAt?: string;
4696
- role?: string;
4697
- primaryUseCase?: string[];
4698
- experienceLevel?: string;
4699
- /** Onboarding guide system state (set by checklist/tour system) */
4700
- guides?: {
4701
- completedIds?: string[];
4702
- dismissed?: boolean;
4703
- completedAt?: string;
4704
- };
4705
- };
4608
+ interface CheckpointListResponse {
4609
+ checkpoints: CheckpointListItem[];
4610
+ /** Total tasks across all checkpoints */
4611
+ total: number;
4612
+ /** Breakdown by status for donut chart */
4613
+ statusCounts: StatusCounts;
4614
+ /** Breakdown by priority for donut chart */
4615
+ priorityCounts: PriorityCounts;
4706
4616
  }
4707
4617
 
4708
4618
  /**
4709
- * Memberships Domain - Zod Validation Schemas
4710
- *
4711
- * Validation schemas for membership management endpoints.
4712
- * Includes request bodies, query params, and path params.
4713
- *
4714
- * Security:
4715
- * - All schemas use .strict() to prevent mass assignment attacks
4716
- * - UUID validation prevents invalid references
4717
- * - Role enum validation prevents privilege escalation
4718
- * - organizationId never accepted in body (from JWT when needed)
4619
+ * Target for schedule execution - identifies what resource to execute.
4620
+ * Unlike ExecutionTarget, payload is NOT included here because schedules
4621
+ * store payload in the scheduleConfig (varies per step/item).
4719
4622
  */
4720
-
4623
+ interface ScheduleTarget {
4624
+ resourceType: 'agent' | 'workflow';
4625
+ resourceId: string;
4626
+ }
4721
4627
  /**
4722
- * Membership status validation
4723
- * Note: Database constraint only allows 'active' | 'inactive'
4628
+ * Optional origin tracking for schedules.
4629
+ * Unlike OriginTracking (which is required), these fields are all optional
4630
+ * for schedules created directly via API (not triggered by another resource).
4724
4631
  */
4725
- declare const MembershipStatusSchema: z.ZodEnum<{
4726
- active: "active";
4727
- inactive: "inactive";
4728
- }>;
4729
- type MembershipStatus = z.infer<typeof MembershipStatusSchema>;
4632
+ interface ScheduleOriginTracking {
4633
+ originExecutionId?: string;
4634
+ originResourceType?: OriginResourceType;
4635
+ originResourceId?: string;
4636
+ }
4637
+ type TaskScheduleConfig = RecurringScheduleConfig | RelativeScheduleConfig | AbsoluteScheduleConfig;
4638
+ interface RecurringScheduleConfig {
4639
+ type: 'recurring';
4640
+ cron?: string;
4641
+ interval?: 'daily' | 'weekly' | 'monthly';
4642
+ time?: string;
4643
+ timezone: string;
4644
+ payload: Record<string, unknown>;
4645
+ endAt?: string | null;
4646
+ overduePolicy?: 'skip' | 'execute';
4647
+ }
4648
+ interface RelativeScheduleConfig {
4649
+ type: 'relative';
4650
+ anchorAt: string;
4651
+ anchorLabel?: string;
4652
+ items: RelativeScheduleItem[];
4653
+ overduePolicy?: 'skip' | 'execute';
4654
+ }
4655
+ interface RelativeScheduleItem {
4656
+ offset: string;
4657
+ payload: Record<string, unknown>;
4658
+ label?: string;
4659
+ }
4660
+ interface AbsoluteScheduleConfig {
4661
+ type: 'absolute';
4662
+ items: AbsoluteScheduleItem[];
4663
+ overduePolicy?: 'skip' | 'execute';
4664
+ }
4665
+ interface AbsoluteScheduleItem {
4666
+ runAt: string;
4667
+ payload: Record<string, unknown>;
4668
+ label?: string;
4669
+ }
4670
+ interface TaskSchedule extends ScheduleOriginTracking {
4671
+ id: string;
4672
+ organizationId: string;
4673
+ name: string;
4674
+ description?: string;
4675
+ target: ScheduleTarget;
4676
+ scheduleConfig: TaskScheduleConfig;
4677
+ nextRunAt?: Date;
4678
+ currentStep: number;
4679
+ status: 'active' | 'paused' | 'completed' | 'cancelled';
4680
+ lastRunAt?: Date;
4681
+ lastExecutionId?: string;
4682
+ maxRetries: number;
4683
+ idempotencyKey?: string;
4684
+ createdAt: Date;
4685
+ updatedAt: Date;
4686
+ }
4730
4687
 
4731
4688
  /**
4732
- * Organization Membership types based on WorkOS API
4689
+ * Wire-format DTO for notification API responses.
4690
+ * Dates are ISO 8601 strings (not Date objects like the domain Notification type).
4691
+ * Used by frontend hooks that consume /api/notifications.
4733
4692
  */
4734
- interface OrganizationMembership {
4735
- object: 'organization_membership';
4693
+ interface NotificationDTO {
4736
4694
  id: string;
4737
4695
  userId: string;
4738
4696
  organizationId: string;
4739
- role: {
4740
- slug: string;
4741
- };
4742
- status: 'active' | 'inactive';
4697
+ category: string;
4698
+ title: string;
4699
+ message: string;
4700
+ actionUrl: string | null;
4701
+ read: boolean;
4702
+ readAt: string | null;
4743
4703
  createdAt: string;
4744
- updatedAt: string;
4745
4704
  }
4746
- /**
4747
- * Request interfaces for membership operations
4748
- */
4749
- interface CreateMembershipRequest {
4750
- userId: string;
4751
- organizationId: string;
4752
- roleSlug?: string;
4705
+
4706
+ type ProjectRow = Database['public']['Tables']['prj_projects']['Row'];
4707
+ type ProjectUpdate = Database['public']['Tables']['prj_projects']['Update'];
4708
+ type MilestoneRow = Database['public']['Tables']['prj_milestones']['Row'];
4709
+ type MilestoneUpdate = Database['public']['Tables']['prj_milestones']['Update'];
4710
+ type TaskRow = Database['public']['Tables']['prj_tasks']['Row'];
4711
+ type TaskUpdate = Database['public']['Tables']['prj_tasks']['Update'];
4712
+ type ProjectStatus = 'active' | 'on_track' | 'at_risk' | 'blocked' | 'completed' | 'paused';
4713
+ type ProjectKind = 'client_engagement' | 'internal' | 'research' | 'other';
4714
+ type MilestoneStatus = 'upcoming' | 'in_progress' | 'completed' | 'overdue' | 'blocked';
4715
+ type TaskStatus = 'planned' | 'in_progress' | 'blocked' | 'completed' | 'cancelled' | 'submitted' | 'approved' | 'rejected' | 'revision_requested';
4716
+ type TaskType = 'documentation' | 'code' | 'report' | 'design' | 'other';
4717
+ type NoteType = 'call_note' | 'status_update' | 'issue' | 'blocker' | 'agent_learning';
4718
+ interface ProjectFilters {
4719
+ status?: ProjectStatus;
4720
+ kind?: ProjectKind;
4721
+ companyId?: string;
4722
+ search?: string;
4723
+ }
4724
+ interface MilestoneFilters {
4725
+ status?: MilestoneStatus;
4726
+ projectId?: string;
4727
+ }
4728
+ interface TaskFilters {
4729
+ status?: TaskStatus;
4730
+ type?: TaskType;
4731
+ milestoneId?: string;
4732
+ projectId?: string;
4733
+ }
4734
+ interface NoteFilters {
4735
+ type?: NoteType;
4736
+ projectId?: string;
4737
+ }
4738
+ interface ProjectWithCounts extends ProjectRow {
4739
+ milestoneCount: number;
4740
+ taskCount: number;
4741
+ completedMilestones?: number;
4742
+ completedTasks?: number;
4743
+ }
4744
+ interface ProjectDetail extends ProjectRow {
4745
+ milestones: MilestoneRow[];
4746
+ tasks: TaskRow[];
4747
+ company: {
4748
+ id: string;
4749
+ name: string;
4750
+ domain: string | null;
4751
+ } | null;
4752
+ deal: ProjectSourceDealRef | null;
4753
+ client: ProjectClientRef | null;
4754
+ }
4755
+ interface ProjectSourceDealRef {
4756
+ id: string;
4757
+ clientId?: string | null;
4758
+ contactEmail: string;
4759
+ stageKey: string | null;
4760
+ stateKey: string | null;
4761
+ sourceListId: string | null;
4762
+ updatedAt: string;
4753
4763
  }
4754
- interface UpdateMembershipRequest {
4755
- roleSlug: string;
4764
+ interface ProjectClientRef {
4765
+ id: string;
4766
+ name: string;
4767
+ status: string;
4756
4768
  }
4757
- interface ListMembershipsParams {
4758
- userId?: string;
4759
- organizationId?: string;
4760
- statuses?: MembershipStatus[];
4761
- limit?: number;
4762
- before?: string;
4763
- after?: string;
4764
- order?: 'asc' | 'desc';
4769
+
4770
+ interface Action {
4771
+ key: string;
4772
+ label: string;
4773
+ payloadSchema?: z.ZodTypeAny;
4765
4774
  }
4775
+
4776
+ type MessageType = MessageEvent['type'];
4766
4777
  /**
4767
- * Response interfaces
4778
+ * Session Data Transfer Object (DTO)
4779
+ * Transform type for API responses (snake_case DB → camelCase frontend)
4780
+ * Used by frontend apps to display session data
4768
4781
  */
4769
- interface ListMembershipsResponse {
4770
- data: OrganizationMembership[];
4771
- listMetadata?: {
4772
- before?: string | null;
4773
- after?: string | null;
4774
- };
4782
+ interface SessionDTO {
4783
+ sessionId: string;
4784
+ resourceId: string;
4785
+ organizationId: string;
4786
+ userId?: string | null;
4787
+ turnCount: number;
4788
+ isEnded: boolean;
4789
+ title?: string | null;
4790
+ memorySnapshot?: AgentMemory;
4791
+ metadata?: Record<string, unknown> | null;
4792
+ createdAt: Date;
4793
+ updatedAt: Date;
4794
+ endedAt?: Date | null;
4775
4795
  }
4776
- /**
4777
- * Extended membership with user and organization details for UI
4778
- */
4779
- interface MembershipWithDetails extends OrganizationMembership {
4780
- user?: {
4781
- id: string;
4782
- email: string;
4783
- firstName?: string;
4784
- lastName?: string;
4785
- profilePictureUrl?: string;
4786
- };
4787
- organization?: {
4788
- id: string;
4789
- name: string;
4790
- workos_org_id: string;
4791
- primaryDomain?: string;
4792
- is_test?: boolean;
4793
- status?: string;
4794
- metadata?: Record<string, unknown>;
4795
- config?: Record<string, unknown>;
4796
- };
4797
- config?: MembershipFeatureConfig;
4796
+ interface ChatMessage {
4797
+ id: string;
4798
+ role: 'user' | 'assistant';
4799
+ messageType: MessageType;
4800
+ text: string;
4801
+ metadata?: MessageEvent;
4802
+ turnNumber: number;
4803
+ messageIndex?: number;
4804
+ createdAt: Date;
4805
+ }
4806
+ /** Token usage data sent with turn:complete WebSocket events */
4807
+ interface SessionTokenUsage {
4808
+ /** Tokens consumed by this turn's input */
4809
+ turnInputTokens: number;
4810
+ /** Tokens generated by this turn's output */
4811
+ turnOutputTokens: number;
4812
+ /** Total tokens for this turn (turnInputTokens + turnOutputTokens) */
4813
+ turnTotalTokens: number;
4814
+ /** Cumulative input tokens across all turns in this session */
4815
+ cumulativeInputTokens: number;
4816
+ /** Cumulative output tokens across all turns in this session */
4817
+ cumulativeOutputTokens: number;
4818
+ /** The model's context window size for this session (e.g., 200K) */
4819
+ contextWindowSize: number;
4798
4820
  }
4799
4821
 
4800
4822
  /**
@@ -5441,14 +5463,104 @@ interface CommandViewData {
5441
5463
  edges: CommandViewEdge[];
5442
5464
  }
5443
5465
 
5444
- declare const ResourceCategorySchema: z.ZodEnum<{
5445
- diagnostic: "diagnostic";
5446
- production: "production";
5447
- internal: "internal";
5448
- testing: "testing";
5449
- }>;
5450
- type ResourceCategory = z.infer<typeof ResourceCategorySchema>;
5451
- type ResourceLink = Link;
5466
+ declare const AccessKeyInputSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
5467
+ systemPath: z.ZodString;
5468
+ action: z.ZodDefault<z.ZodEnum<{
5469
+ view: "view";
5470
+ manage: "manage";
5471
+ }>>;
5472
+ }, z.core.$strict>]>;
5473
+ type AccessKeyInput = z.input<typeof AccessKeyInputSchema>;
5474
+ declare const AccessKeys: {
5475
+ readonly platformAdmin: {
5476
+ readonly systemPath: "platform.admin";
5477
+ readonly action: "view";
5478
+ };
5479
+ readonly organizationManage: {
5480
+ readonly systemPath: "permission.org";
5481
+ readonly action: "manage";
5482
+ };
5483
+ readonly membersManage: {
5484
+ readonly systemPath: "permission.members";
5485
+ readonly action: "manage";
5486
+ };
5487
+ readonly rolesManage: {
5488
+ readonly systemPath: "permission.roles";
5489
+ readonly action: "manage";
5490
+ };
5491
+ readonly secretsManage: {
5492
+ readonly systemPath: "permission.secrets";
5493
+ readonly action: "manage";
5494
+ };
5495
+ readonly operationsRead: {
5496
+ readonly systemPath: "permission.operations";
5497
+ readonly action: "view";
5498
+ };
5499
+ readonly operationsManage: {
5500
+ readonly systemPath: "permission.operations";
5501
+ readonly action: "manage";
5502
+ };
5503
+ readonly acquisitionManage: {
5504
+ readonly systemPath: "permission.acquisition";
5505
+ readonly action: "manage";
5506
+ };
5507
+ readonly projectsManage: {
5508
+ readonly systemPath: "permission.projects";
5509
+ readonly action: "manage";
5510
+ };
5511
+ readonly clientsManage: {
5512
+ readonly systemPath: "permission.clients";
5513
+ readonly action: "manage";
5514
+ };
5515
+ readonly operationsOverview: {
5516
+ readonly systemPath: "diagnostic.operations.overview";
5517
+ readonly action: "view";
5518
+ };
5519
+ readonly operationsRecentExecutions: {
5520
+ readonly systemPath: "diagnostic.operations.recent-executions";
5521
+ readonly action: "view";
5522
+ };
5523
+ readonly monitoringExecutionLogs: {
5524
+ readonly systemPath: "diagnostic.monitoring.execution-logs";
5525
+ readonly action: "view";
5526
+ };
5527
+ readonly monitoringNotifications: {
5528
+ readonly systemPath: "diagnostic.monitoring.notifications";
5529
+ readonly action: "view";
5530
+ };
5531
+ };
5532
+
5533
+ type AccessRestrictedBy = 'catalog' | 'membership' | 'system-lifecycle' | 'role-permission' | 'diagnostic-allowlist' | null;
5534
+ type AccessReason = 'allowed' | 'platform-admin-bypass' | 'invalid-access-key' | 'unknown-access-key' | 'organization-mismatch' | 'missing-membership' | 'system-not-active' | 'role-permission-denied' | 'diagnostic-key-not-allowed';
5535
+ interface AccessAnswer {
5536
+ allowed: boolean;
5537
+ restrictedBy: AccessRestrictedBy;
5538
+ reason: AccessReason;
5539
+ }
5540
+
5541
+ interface UseAccessResult extends AccessAnswer {
5542
+ isReady: boolean;
5543
+ isPlatformAdmin: boolean;
5544
+ permissions: readonly string[];
5545
+ }
5546
+ /**
5547
+ * Unified access hook for Organization Model system lifecycle, diagnostic keys,
5548
+ * role permissions, organization membership, and platform-admin bypass.
5549
+ */
5550
+ declare function useAccess(key: AccessKeyInput): UseAccessResult;
5551
+
5552
+ /**
5553
+ * Query key factory for executions TanStack Query hooks.
5554
+ * Uses organization UUID (not name) for cache isolation.
5555
+ */
5556
+ declare const executionsKeys: {
5557
+ all: readonly ["executions"];
5558
+ resources: (orgId: string | null) => readonly ["executions", "resources", string | null];
5559
+ resourceDefinition: (orgId: string | null, resourceId: string) => readonly ["executions", "definition", string | null, string];
5560
+ executionsListBase: (orgId: string | null, resourceId: string) => readonly ["executions", "list", string | null, string];
5561
+ executions: (orgId: string | null, resourceId: string, resourceStatus?: string, limit?: number, offset?: number) => readonly ["executions", "list", string | null, string, string, number | null, number];
5562
+ execution: (orgId: string | null, resourceId: string, executionId: string) => readonly ["executions", "execution", string | null, string, string];
5563
+ };
5452
5564
 
5453
5565
  type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'warning';
5454
5566
  /**
@@ -5509,25 +5621,147 @@ interface APIExecutionSummary {
5509
5621
  endTime?: number;
5510
5622
  resourceStatus?: ResourceStatus;
5511
5623
  }
5512
- interface APIExecutionDetail extends APIExecutionSummary {
5513
- executionLogs: ExecutionLogMessage[];
5514
- input?: unknown;
5515
- result?: unknown;
5516
- error?: string;
5517
- resourceStatus: ResourceStatus;
5518
- apiVersion?: string | null;
5519
- resourceVersion?: string | null;
5520
- sdkVersion?: string | null;
5521
- isArchived?: boolean;
5522
- archivedLogCount?: number;
5624
+ interface APIExecutionDetail extends APIExecutionSummary {
5625
+ executionLogs: ExecutionLogMessage[];
5626
+ input?: unknown;
5627
+ result?: unknown;
5628
+ error?: string;
5629
+ resourceStatus: ResourceStatus;
5630
+ apiVersion?: string | null;
5631
+ resourceVersion?: string | null;
5632
+ sdkVersion?: string | null;
5633
+ isArchived?: boolean;
5634
+ archivedLogCount?: number;
5635
+ }
5636
+ interface APIExecutionListResponse {
5637
+ executions: APIExecutionSummary[];
5638
+ total?: number;
5639
+ limit?: number;
5640
+ offset?: number;
5641
+ hasMore?: boolean;
5642
+ }
5643
+
5644
+ /**
5645
+ * Execution history item.
5646
+ * Represents a single execution triggered by a schedule.
5647
+ */
5648
+ declare const ExecutionHistoryItemSchema: z.ZodObject<{
5649
+ id: z.ZodString;
5650
+ createdAt: z.ZodString;
5651
+ status: z.ZodEnum<{
5652
+ completed: "completed";
5653
+ failed: "failed";
5654
+ running: "running";
5655
+ cancelled: "cancelled";
5656
+ }>;
5657
+ step: z.ZodNullable<z.ZodNumber>;
5658
+ itemLabel: z.ZodNullable<z.ZodString>;
5659
+ duration: z.ZodNullable<z.ZodNumber>;
5660
+ error: z.ZodNullable<z.ZodString>;
5661
+ }, z.core.$strip>;
5662
+ /**
5663
+ * Execution history response.
5664
+ * Returned by GET /schedules/:id/executions with pagination.
5665
+ */
5666
+ declare const ExecutionHistoryResponseSchema: z.ZodObject<{
5667
+ executions: z.ZodArray<z.ZodObject<{
5668
+ id: z.ZodString;
5669
+ createdAt: z.ZodString;
5670
+ status: z.ZodEnum<{
5671
+ completed: "completed";
5672
+ failed: "failed";
5673
+ running: "running";
5674
+ cancelled: "cancelled";
5675
+ }>;
5676
+ step: z.ZodNullable<z.ZodNumber>;
5677
+ itemLabel: z.ZodNullable<z.ZodString>;
5678
+ duration: z.ZodNullable<z.ZodNumber>;
5679
+ error: z.ZodNullable<z.ZodString>;
5680
+ }, z.core.$strip>>;
5681
+ total: z.ZodNumber;
5682
+ limit: z.ZodNumber;
5683
+ offset: z.ZodNumber;
5684
+ }, z.core.$strip>;
5685
+ type ExecutionHistoryItem = z.infer<typeof ExecutionHistoryItemSchema>;
5686
+ type ExecutionHistoryResponse = z.infer<typeof ExecutionHistoryResponseSchema>;
5687
+
5688
+ /**
5689
+ * Fetch the execution list for a given resource.
5690
+ *
5691
+ * @example
5692
+ * const { data, isLoading } = useExecutions(resourceId)
5693
+ *
5694
+ * @example
5695
+ * // With status filter and limit
5696
+ * const { data } = useExecutions(resourceId, 'running', 20)
5697
+ */
5698
+ declare function useExecutions(resourceId: string, resourceStatus?: ResourceStatus | 'all', limit?: number, offset?: number): _tanstack_react_query.UseQueryResult<APIExecutionListResponse, Error>;
5699
+
5700
+ interface UseInFlightExecutionsOptions {
5701
+ enabled?: boolean;
5702
+ refetchInterval?: number | false;
5703
+ limit?: number;
5704
+ offset?: number;
5705
+ listId?: string;
5706
+ }
5707
+ declare function useInFlightExecutions(resourceId: string, options?: UseInFlightExecutionsOptions): _tanstack_react_query.UseQueryResult<APIExecutionListResponse, Error>;
5708
+
5709
+ /**
5710
+ * Fetch a single execution detail.
5711
+ * Automatically polls every 2 seconds while the execution status is 'running'.
5712
+ *
5713
+ * @example
5714
+ * const { data: execution, isLoading } = useExecution(resourceId, executionId)
5715
+ */
5716
+ declare function useExecution(resourceId: string, executionId: string): _tanstack_react_query.UseQueryResult<APIExecutionDetail, Error>;
5717
+
5718
+ interface ExecuteAsyncParams {
5719
+ resourceId: string;
5720
+ resourceType: ResourceType;
5721
+ input: unknown;
5722
+ listId?: string;
5723
+ }
5724
+ interface ExecuteAsyncResult {
5725
+ executionId: string;
5726
+ status: string;
5727
+ resourceId: string;
5728
+ }
5729
+ /**
5730
+ * Trigger an async execution for a workflow or agent.
5731
+ * Invalidates the executions list on success so the new execution appears immediately.
5732
+ *
5733
+ * @example
5734
+ * const { mutate: execute, isPending } = useExecuteAsync()
5735
+ * execute({ resourceId, resourceType: 'workflow', input: { ... } })
5736
+ */
5737
+ declare function useExecuteAsync(): _tanstack_react_query.UseMutationResult<ExecuteAsyncResult, Error, ExecuteAsyncParams, unknown>;
5738
+
5739
+ interface UseWorkflowExecutionOptions {
5740
+ workflowId: string;
5741
+ listId?: string;
5742
+ }
5743
+ interface WorkflowExecutionTriggerParams {
5744
+ input: unknown;
5523
5745
  }
5524
- interface APIExecutionListResponse {
5525
- executions: APIExecutionSummary[];
5526
- total?: number;
5527
- limit?: number;
5528
- offset?: number;
5529
- hasMore?: boolean;
5746
+ interface UseWorkflowExecutionResult {
5747
+ execute: (params: WorkflowExecutionTriggerParams) => Promise<ExecuteAsyncResult>;
5748
+ executionId: string | null;
5749
+ status: string | null;
5750
+ isIdle: boolean;
5751
+ isPending: boolean;
5752
+ isSuccess: boolean;
5753
+ isError: boolean;
5754
+ error: Error | null;
5755
+ data: ExecuteAsyncResult | undefined;
5756
+ reset: () => void;
5530
5757
  }
5758
+ /**
5759
+ * List-builder-friendly wrapper around async workflow execution.
5760
+ *
5761
+ * Binds a workflow ID once, exposes a small trigger API, and refreshes both
5762
+ * platform execution lists and list execution history when a list ID is known.
5763
+ */
5764
+ declare function useWorkflowExecution({ workflowId, listId }: UseWorkflowExecutionOptions): UseWorkflowExecutionResult;
5531
5765
 
5532
5766
  /**
5533
5767
  * @deprecated Use TimeRange from '@elevasis/core' directly. Kept as alias for backward compatibility.
@@ -5606,102 +5840,6 @@ interface Activity {
5606
5840
  createdAt: Date;
5607
5841
  }
5608
5842
 
5609
- /**
5610
- * Canonical permission catalog.
5611
- *
5612
- * Source of truth for the permission keys used by:
5613
- * - RLS policies in Supabase (via has_org_permission(org_id, key))
5614
- * - API middleware (via requireOrganizationPermission(key))
5615
- * - UI hooks (via useOrganizationPermissions().hasPermission(key))
5616
- *
5617
- * The DB table `org_rol_permissions` mirrors this constant. There is no
5618
- * runtime reconciler; parity is enforced two ways:
5619
- * 1. Each migration that adds/removes/modifies a permission must INSERT
5620
- * (or UPDATE / DELETE) the corresponding `org_rol_permissions` row in
5621
- * the same transaction.
5622
- * 2. `apps/api/src/auth/multi-tenancy/__tests__/permissions-catalog-sync.integration.test.ts`
5623
- * asserts the TS catalog and the DB rows agree; CI fails on drift.
5624
- *
5625
- * Adding a permission:
5626
- * 1. Add an entry below.
5627
- * 2. Add a row to the migration (INSERT INTO org_rol_permissions ...) in
5628
- * the same transaction as any policies/grants that reference the key.
5629
- * 3. Reference it in RLS / middleware as needed.
5630
- * 4. Optionally grant it to one or more system roles in org_rol_grants.
5631
- *
5632
- * Removing a permission: follow the deletion runbook — never just delete
5633
- * the entry. Existing role grants and policy references must be cleared first.
5634
- */
5635
- declare const PERMISSIONS: {
5636
- readonly ORG_READ: "org.read";
5637
- readonly ORG_MANAGE: "org.manage";
5638
- readonly ORG_DELETE: "org.delete";
5639
- readonly MEMBERS_MANAGE: "members.manage";
5640
- readonly ROLES_MANAGE: "roles.manage";
5641
- readonly SECRETS_MANAGE: "secrets.manage";
5642
- readonly OPERATIONS_READ: "operations.read";
5643
- readonly OPERATIONS_MANAGE: "operations.manage";
5644
- readonly ACQUISITION_MANAGE: "acquisition.manage";
5645
- readonly PROJECTS_MANAGE: "projects.manage";
5646
- readonly CLIENTS_MANAGE: "clients.manage";
5647
- };
5648
- type PermissionKey = (typeof PERMISSIONS)[keyof typeof PERMISSIONS];
5649
- /**
5650
- * Static metadata for each permission. Mirrored into org_rol_permissions by
5651
- * a migration `INSERT` in the same transaction as any change to this catalog.
5652
- * is_org_grantable=false means the permission is reserved to system roles
5653
- * only — custom roles cannot include it (privilege-escalation guard).
5654
- */
5655
- interface PermissionDescriptor {
5656
- key: PermissionKey;
5657
- description: string;
5658
- isOrgGrantable: boolean;
5659
- }
5660
-
5661
- /**
5662
- * Execution history item.
5663
- * Represents a single execution triggered by a schedule.
5664
- */
5665
- declare const ExecutionHistoryItemSchema: z.ZodObject<{
5666
- id: z.ZodString;
5667
- createdAt: z.ZodString;
5668
- status: z.ZodEnum<{
5669
- completed: "completed";
5670
- failed: "failed";
5671
- running: "running";
5672
- cancelled: "cancelled";
5673
- }>;
5674
- step: z.ZodNullable<z.ZodNumber>;
5675
- itemLabel: z.ZodNullable<z.ZodString>;
5676
- duration: z.ZodNullable<z.ZodNumber>;
5677
- error: z.ZodNullable<z.ZodString>;
5678
- }, z.core.$strip>;
5679
- /**
5680
- * Execution history response.
5681
- * Returned by GET /schedules/:id/executions with pagination.
5682
- */
5683
- declare const ExecutionHistoryResponseSchema: z.ZodObject<{
5684
- executions: z.ZodArray<z.ZodObject<{
5685
- id: z.ZodString;
5686
- createdAt: z.ZodString;
5687
- status: z.ZodEnum<{
5688
- completed: "completed";
5689
- failed: "failed";
5690
- running: "running";
5691
- cancelled: "cancelled";
5692
- }>;
5693
- step: z.ZodNullable<z.ZodNumber>;
5694
- itemLabel: z.ZodNullable<z.ZodString>;
5695
- duration: z.ZodNullable<z.ZodNumber>;
5696
- error: z.ZodNullable<z.ZodString>;
5697
- }, z.core.$strip>>;
5698
- total: z.ZodNumber;
5699
- limit: z.ZodNumber;
5700
- offset: z.ZodNumber;
5701
- }, z.core.$strip>;
5702
- type ExecutionHistoryItem = z.infer<typeof ExecutionHistoryItemSchema>;
5703
- type ExecutionHistoryResponse = z.infer<typeof ExecutionHistoryResponseSchema>;
5704
-
5705
5843
  /**
5706
5844
  * Deployment types — browser-safe
5707
5845
  *
@@ -5863,105 +6001,6 @@ declare const ListCredentialsResponseSchema: z.ZodObject<{
5863
6001
  /** API response type for a single credential list item */
5864
6002
  type CredentialListItem = z.infer<typeof ListCredentialsResponseSchema>['credentials'][number];
5865
6003
 
5866
- declare function useOrganizationPermissions(): {
5867
- hasPermission: (key: PermissionKey | string) => boolean;
5868
- permissions: string[];
5869
- isPlatformAdmin: boolean;
5870
- isReady: boolean;
5871
- };
5872
- declare function useHasPermission(key: PermissionKey | string): boolean;
5873
-
5874
- /**
5875
- * Query key factory for executions TanStack Query hooks.
5876
- * Uses organization UUID (not name) for cache isolation.
5877
- */
5878
- declare const executionsKeys: {
5879
- all: readonly ["executions"];
5880
- resources: (orgId: string | null) => readonly ["executions", "resources", string | null];
5881
- resourceDefinition: (orgId: string | null, resourceId: string) => readonly ["executions", "definition", string | null, string];
5882
- executionsListBase: (orgId: string | null, resourceId: string) => readonly ["executions", "list", string | null, string];
5883
- executions: (orgId: string | null, resourceId: string, resourceStatus?: string, limit?: number, offset?: number) => readonly ["executions", "list", string | null, string, string, number | null, number];
5884
- execution: (orgId: string | null, resourceId: string, executionId: string) => readonly ["executions", "execution", string | null, string, string];
5885
- };
5886
-
5887
- /**
5888
- * Fetch the execution list for a given resource.
5889
- *
5890
- * @example
5891
- * const { data, isLoading } = useExecutions(resourceId)
5892
- *
5893
- * @example
5894
- * // With status filter and limit
5895
- * const { data } = useExecutions(resourceId, 'running', 20)
5896
- */
5897
- declare function useExecutions(resourceId: string, resourceStatus?: ResourceStatus | 'all', limit?: number, offset?: number): _tanstack_react_query.UseQueryResult<APIExecutionListResponse, Error>;
5898
-
5899
- interface UseInFlightExecutionsOptions {
5900
- enabled?: boolean;
5901
- refetchInterval?: number | false;
5902
- limit?: number;
5903
- offset?: number;
5904
- listId?: string;
5905
- }
5906
- declare function useInFlightExecutions(resourceId: string, options?: UseInFlightExecutionsOptions): _tanstack_react_query.UseQueryResult<APIExecutionListResponse, Error>;
5907
-
5908
- /**
5909
- * Fetch a single execution detail.
5910
- * Automatically polls every 2 seconds while the execution status is 'running'.
5911
- *
5912
- * @example
5913
- * const { data: execution, isLoading } = useExecution(resourceId, executionId)
5914
- */
5915
- declare function useExecution(resourceId: string, executionId: string): _tanstack_react_query.UseQueryResult<APIExecutionDetail, Error>;
5916
-
5917
- interface ExecuteAsyncParams {
5918
- resourceId: string;
5919
- resourceType: ResourceType;
5920
- input: unknown;
5921
- listId?: string;
5922
- }
5923
- interface ExecuteAsyncResult {
5924
- executionId: string;
5925
- status: string;
5926
- resourceId: string;
5927
- }
5928
- /**
5929
- * Trigger an async execution for a workflow or agent.
5930
- * Invalidates the executions list on success so the new execution appears immediately.
5931
- *
5932
- * @example
5933
- * const { mutate: execute, isPending } = useExecuteAsync()
5934
- * execute({ resourceId, resourceType: 'workflow', input: { ... } })
5935
- */
5936
- declare function useExecuteAsync(): _tanstack_react_query.UseMutationResult<ExecuteAsyncResult, Error, ExecuteAsyncParams, unknown>;
5937
-
5938
- interface UseWorkflowExecutionOptions {
5939
- workflowId: string;
5940
- listId?: string;
5941
- }
5942
- interface WorkflowExecutionTriggerParams {
5943
- input: unknown;
5944
- }
5945
- interface UseWorkflowExecutionResult {
5946
- execute: (params: WorkflowExecutionTriggerParams) => Promise<ExecuteAsyncResult>;
5947
- executionId: string | null;
5948
- status: string | null;
5949
- isIdle: boolean;
5950
- isPending: boolean;
5951
- isSuccess: boolean;
5952
- isError: boolean;
5953
- error: Error | null;
5954
- data: ExecuteAsyncResult | undefined;
5955
- reset: () => void;
5956
- }
5957
- /**
5958
- * List-builder-friendly wrapper around async workflow execution.
5959
- *
5960
- * Binds a workflow ID once, exposes a small trigger API, and refreshes both
5961
- * platform execution lists and list execution history when a list ID is known.
5962
- */
5963
- declare function useWorkflowExecution({ workflowId, listId }: UseWorkflowExecutionOptions): UseWorkflowExecutionResult;
5964
-
5965
6004
  interface FetchEventSourceWithTokenRefreshOptions {
5966
6005
  url: string;
5967
6006
  getToken: () => Promise<string | undefined>;
@@ -6963,91 +7002,6 @@ declare function useSortedData<T>(data: T[], defaultColumn: string, accessors: R
6963
7002
  toggleSort: (column: string) => void;
6964
7003
  };
6965
7004
 
6966
- interface InitializationError {
6967
- layer: 'auth' | 'profile' | 'organization';
6968
- message: string;
6969
- originalError?: Error;
6970
- }
6971
- interface AppInitializationState {
6972
- userReady: boolean;
6973
- organizationReady: boolean;
6974
- allReady: boolean;
6975
- isInitializing: boolean;
6976
- error: InitializationError | null;
6977
- retry: () => void;
6978
- profile: SupabaseUserProfile | null;
6979
- }
6980
-
6981
- /**
6982
- * The value exposed by OrganizationProvider to all consumers.
6983
- */
6984
- interface OrganizationContextValue {
6985
- /** WorkOS organization ID of the currently selected organization. */
6986
- currentWorkOSOrganizationId: string | null;
6987
- /** Supabase (UUID) organization ID of the currently selected organization. */
6988
- currentSupabaseOrganizationId: string | null;
6989
- /** Full membership record for the currently selected organization. */
6990
- currentMembership: MembershipWithDetails | null;
6991
- /** All memberships for the authenticated user. */
6992
- memberships: MembershipWithDetails[];
6993
- /** True while the initial membership list is being fetched. */
6994
- isInitializing: boolean;
6995
- /** True while a subsequent org switch / refresh is in flight. */
6996
- isOrgRefreshing: boolean;
6997
- /** Error message if the membership fetch or org switch failed. */
6998
- error: string | null;
6999
- /**
7000
- * Switch the active organization.
7001
- *
7002
- * Persists the selection to `last_visited_org` on the user profile and
7003
- * invalidates all org-scoped TanStack Query cache entries.
7004
- *
7005
- * @param workosOrgId - WorkOS organization ID to switch to.
7006
- */
7007
- switchOrganization: (workosOrgId: string) => void;
7008
- /**
7009
- * Re-fetch memberships and retry org selection after an error.
7010
- */
7011
- retry: () => Promise<void>;
7012
- }
7013
-
7014
- type RestrictionSource = 'membership' | null;
7015
- interface FeatureAccessResult {
7016
- allowed: boolean;
7017
- restrictedBy: RestrictionSource;
7018
- }
7019
- /**
7020
- * Factory that creates a `useFeatureAccess` hook scoped to the consumer's
7021
- * feature configuration.
7022
- *
7023
- * @param useInitialization - Initialization hook providing `profile` and `organizationReady`
7024
- * @param useOrganization - Organization hook providing `currentMembership`
7025
- *
7026
- * @example
7027
- * ```typescript
7028
- * // In your app's feature-access module
7029
- * import { createFeatureAccessHook } from '@repo/ui/hooks'
7030
- * import { useInitialization } from '@repo/ui/initialization'
7031
- * import { useOrganization } from '@repo/ui/organization'
7032
- *
7033
- * export const useFeatureAccess = createFeatureAccessHook({
7034
- * useInitialization,
7035
- * useOrganization,
7036
- * })
7037
- * ```
7038
- */
7039
- declare function createFeatureAccessHook({ useInitialization, useOrganization }: {
7040
- useInitialization: () => Pick<AppInitializationState, 'profile' | 'organizationReady'>;
7041
- useOrganization: () => Pick<OrganizationContextValue, 'currentMembership'>;
7042
- }): () => {
7043
- orgConfig: Record<string, unknown> | undefined;
7044
- membershipConfig: MembershipFeatureConfig | undefined;
7045
- userConfig: UserConfig | undefined;
7046
- hasFeature: (featureKey: string) => boolean;
7047
- checkFeature: (featureKey: string) => FeatureAccessResult;
7048
- isReady: boolean;
7049
- };
7050
-
7051
7005
  interface UseSSEConnectionOptions {
7052
7006
  manager: SSEConnectionManagerLike;
7053
7007
  /** Shared connection key — all subscribers with the same key share ONE connection. */
@@ -9537,12 +9491,6 @@ declare class OrganizationMembershipService {
9537
9491
 
9538
9492
  declare function useUserMemberships(userId: string, params?: Omit<ListMembershipsParams, 'userId'>): _tanstack_react_query.UseQueryResult<MembershipWithDetails[], Error>;
9539
9493
 
9540
- interface UpdateMemberConfigParams {
9541
- membershipId: string;
9542
- config: MembershipFeatureConfig;
9543
- }
9544
- declare function useUpdateMemberConfig(): _tanstack_react_query.UseMutationResult<unknown, Error, UpdateMemberConfigParams, unknown>;
9545
-
9546
9494
  interface DeactivateMembershipMutationData {
9547
9495
  membershipId: string;
9548
9496
  userId?: string;
@@ -10279,5 +10227,5 @@ declare function useCreateNote(): _tanstack_react_query.UseMutationResult<{
10279
10227
  type?: string;
10280
10228
  }, "organization_id">, unknown>;
10281
10229
 
10282
- export { ApiKeyService, CredentialService, DeploymentService, OperationsService, OrganizationMembershipService, REFETCH_INTERVAL_RUNNING, WS_MAX_RETRIES_BEFORE_ERROR, WS_RECONNECT_BASE_DELAY, WS_RECONNECT_MAX_DELAY, WebhookEndpointService, acquisitionListKeys, clientsKeys, collectResourceFilterFacets, companyKeys, contactKeys, createFeatureAccessHook, dealKeys, dealNoteKeys, dealTaskKeys, executionsKeys, filterByDomainFilters, getResourceFilterFacetIds, isSessionCapable, labelResourceFilterFacet, leadGenArtifactKeys, leadGenListCompanyKeys, leadGenListMemberKeys, milestoneKeys, noteKeys, observabilityKeys, operationsKeys, projectActivityKeys, projectKeys, requestsKeys, scheduleKeys, sessionsKeys, sortData, taskKeys, useActivateDeployment, useActivities, useActivitiesRealtime, useActivityFilters, useActivityTrend, useAddCompaniesToList, useAddContactsToList, useArchiveSession, useArchivedLogs, useArtifacts, useAssignRole, useBatchDelete, useBatchTelemetry, useBatchedResourcesHealth, useBulkDeleteExecutions, useBusinessImpact, useCancelExecution, useCancelSchedule, useCheckpointTasks, useClient, useClientStatus, useClients, useCommandQueue, useCommandQueueTotals, useCommandViewData, useCommandViewDomainFilters, useCommandViewStats, useCommandViewStore, useCompanies, useCompany, useCompanyFacets, useCompleteDealTask, useContact, useContacts, useCostBreakdown, useCostByModel, useCostSummary, useCostTrends, useCreateApiKey, useCreateArtifact, useCreateClient, useCreateCompany, useCreateContact, useCreateCredential, useCreateDealNote, useCreateDealTask, useCreateProject as useCreateDeliveryProject, useCreateList, useCreateMilestone, useCreateNote, useCreateOrgRole, useCreateSchedule, useCreateSession, useCreateTask, useCreateWebhookEndpoint, useCredentials, useDashboardMetrics, useDeactivateDeployment, useDeactivateMembership, useDealDetail, useDealNotes, useDealTasks, useDealTasksDue, useDeals, useDealsLookup, useDealsSummary, useDeleteApiKey, useDeleteClient, useDeleteCompanies, useDeleteContacts, useDeleteCredential, useDeleteDeal, useDeleteProject as useDeleteDeliveryProject, useDeleteTask as useDeleteDeliveryTask, useDeleteDeployment, useDeleteExecution, useDeleteList, useDeleteMilestone, useDeleteOrgRole, useDeleteRequest, useDeleteSchedule, useDeleteSession, useDeleteTask$1 as useDeleteTask, useDeleteWebhookEndpoint, useDeriveActions, useEffectivePermissions, useErrorAnalysis, useErrorDetail, useErrorDetails, useErrorDistribution, useErrorNotification, useErrorTrends, useExecuteAction, useExecuteAsync, useExecuteResource, useExecution, useExecutionHealth, useExecutionLogSSE, useExecutionLogs, useExecutionLogsFilters, useExecutionPanelState, useExecutionSSE, useExecutions, useGetExecutionHistory, useGetSchedule, useHasPermission, useInFlightExecutions, useList, useListApiKeys, useListDeployments, useListExecutions, useListMember, useListMembers, useListProgress, useListRecords, useListSchedules, useListWebhookEndpoints, useLists, useListsTelemetry, useMarkAllAsRead, useMarkAsRead, useMergedExecution, useMilestones, useNotificationCount as useNotificationCountSSE, useNotifications, useOrgRoles, useOrganizationMembers, useOrganizationPermissions, usePaginationState, usePatchTask, usePauseSchedule, usePermissionCatalog, useProject, useProjectActivities, useProjectMilestones, useProjectNotes, useProjectRealtime, useProjectTasks, useProjects, useReactivateMembership, useRecentExecutionsByResource, useRemoveCompaniesFromList, useRequest, useRequestsList, useResolveAllErrors, useResolveError, useResolveErrorsByExecution, useResourceDefinition, useResourceErrors, useResourceExecutions, useResourceSearch, useResources, useResourcesDomainFilters, useResourcesHealth, useResumeSchedule, useRetryExecution, useRevokeRole, useSSEConnection, useScheduledTasks, useSession, useSessionExecution, useSessionExecutions, useSessionMessages, useSessionWebSocket, useSessions, useSortedData, useStatusFilter, useSubmitAction, useSuccessNotification, useSystemHealth, useTableSelection, useTableSort, useTasks, useTestNotification, useTimeRangeDates, useTopFailingResources, useTransitionItem, useTransitionListCompany, useTransitionListMember, useTransitionState, useUnresolveError, useUnresolvedErrors, useUpdateAnchor, useUpdateApiKey, useUpdateClient, useUpdateCompany, useUpdateContact, useUpdateCredential, useUpdateProject as useUpdateDeliveryProject, useUpdateList, useUpdateListConfig, useUpdateListStatus, useUpdateMemberConfig, useUpdateMilestone, useUpdateOrgRole, useUpdateRequestStatus, useUpdateSchedule, useUpdateTask, useUpdateWebhookEndpoint, useUserMemberships, useVerifyCredential, useVisibleResources, useWarningNotification, useWorkflowExecution };
10283
- export type { AcqCompanyWithCount, AcqContactWithCompany, AcqDealNote, AcqDealTask, AcqDealTaskKind, ActivityFilters, ActivityTrendResponse, AddCompaniesToListResult, AddContactsToListResult, AssignRoleInput, BulkDeleteExecutionsParams, BulkDeleteExecutionsResult, BusinessImpactMetrics, CancelExecutionParams, CancelExecutionResult, ChatMessage, ClientDetailResponse, ClientResponse, ClientStatus, ClientStatusResponse, ClientsListFilters, CreateApiKeyRequest, CreateApiKeyResponse, CreateClientRequest, CreateCredentialRequest, CreateCredentialResponse, CreateOrgRoleInput, CreateScheduleInput, CreateSessionResponse, CredentialListItem, DealDetail, DealLookupFilters, DealLookupItem, DealSummaryStageItem, DealsSummaryResponse, DeleteExecutionParams, Deployment, ErrorDistributionItem, ErrorDistributionParams, ErrorFilters, ErrorTrendsParams, ExecuteActionInput, ExecuteAsyncParams, ExecuteAsyncResult, ExecutionErrorDetails, ExecutionHistoryItem, ExecutionHistoryResponse, ExecutionLogsFilters, ExecutionLogsPageResponse, FailingResource, FeatureAccessResult, GetMessagesResponse, ListActivitiesResponse, ListApiKeysResponse, ListCredentialsResponse, ListExecutionsFilters, ListRecordsFilters, ListSchedulesFilters, ListSchedulesResponse, ListWebhookEndpointsResponse, MessageEvent, MessageType, OrgRole, RemoveCompaniesFromListResult, RequestRow, RequestsListFilters, ResourceFilterFacet, ResourcesResponse, RetryExecutionParams, RevokeRoleInput, SessionDTO, SessionExecution, SessionExecutionsResponse, SessionListItem, SessionTokenUsage, SortDirection, SortState, StaleDealSummaryItem, StatefulItem, StatusFilter, SubmitActionRequest, SubmitActionResponse, SystemHealthExecutionSummary, SystemHealthResponse, TaskSchedule, TopFailingResourcesParams, TransitionItemInput, TransitionListCompanyInput, TransitionListMemberInput, TransitionStateInput, UpdateClientRequest, UpdateListStatusInput, UpdateOrgRoleInput, UpdateScheduleInput, UseActivitiesParams, UseActivityTrendParams, UseArtifactsParams, UseBatchedResourcesHealthParams, UseExecuteResourceOptions, UseExecutionHealthParams, UseExecutionLogsParams, UseExecutionPanelStateOptions, UseExecutionPanelStateReturn, UseExecutionSSEOptions, UseExecutionSSEResult, UseInFlightExecutionsOptions, UseListProgressOptions, UseNotificationCountArgs, UseResourcesHealthParams, UseSSEConnectionOptions, UseScheduledTasksOptions, UseSystemHealthParams, UseWorkflowExecutionOptions, UseWorkflowExecutionResult, VerifyCredentialResponse, WebSocketState, WorkflowExecutionTriggerParams };
10230
+ export { AccessKeys, ApiKeyService, CredentialService, DeploymentService, OperationsService, OrganizationMembershipService, REFETCH_INTERVAL_RUNNING, WS_MAX_RETRIES_BEFORE_ERROR, WS_RECONNECT_BASE_DELAY, WS_RECONNECT_MAX_DELAY, WebhookEndpointService, acquisitionListKeys, clientsKeys, collectResourceFilterFacets, companyKeys, contactKeys, dealKeys, dealNoteKeys, dealTaskKeys, executionsKeys, filterByDomainFilters, getResourceFilterFacetIds, isSessionCapable, labelResourceFilterFacet, leadGenArtifactKeys, leadGenListCompanyKeys, leadGenListMemberKeys, milestoneKeys, noteKeys, observabilityKeys, operationsKeys, projectActivityKeys, projectKeys, requestsKeys, scheduleKeys, sessionsKeys, sortData, taskKeys, useAccess, useActivateDeployment, useActivities, useActivitiesRealtime, useActivityFilters, useActivityTrend, useAddCompaniesToList, useAddContactsToList, useArchiveSession, useArchivedLogs, useArtifacts, useAssignRole, useBatchDelete, useBatchTelemetry, useBatchedResourcesHealth, useBulkDeleteExecutions, useBusinessImpact, useCancelExecution, useCancelSchedule, useCheckpointTasks, useClient, useClientStatus, useClients, useCommandQueue, useCommandQueueTotals, useCommandViewData, useCommandViewDomainFilters, useCommandViewStats, useCommandViewStore, useCompanies, useCompany, useCompanyFacets, useCompleteDealTask, useContact, useContacts, useCostBreakdown, useCostByModel, useCostSummary, useCostTrends, useCreateApiKey, useCreateArtifact, useCreateClient, useCreateCompany, useCreateContact, useCreateCredential, useCreateDealNote, useCreateDealTask, useCreateProject as useCreateDeliveryProject, useCreateList, useCreateMilestone, useCreateNote, useCreateOrgRole, useCreateSchedule, useCreateSession, useCreateTask, useCreateWebhookEndpoint, useCredentials, useDashboardMetrics, useDeactivateDeployment, useDeactivateMembership, useDealDetail, useDealNotes, useDealTasks, useDealTasksDue, useDeals, useDealsLookup, useDealsSummary, useDeleteApiKey, useDeleteClient, useDeleteCompanies, useDeleteContacts, useDeleteCredential, useDeleteDeal, useDeleteProject as useDeleteDeliveryProject, useDeleteTask as useDeleteDeliveryTask, useDeleteDeployment, useDeleteExecution, useDeleteList, useDeleteMilestone, useDeleteOrgRole, useDeleteRequest, useDeleteSchedule, useDeleteSession, useDeleteTask$1 as useDeleteTask, useDeleteWebhookEndpoint, useDeriveActions, useEffectivePermissions, useErrorAnalysis, useErrorDetail, useErrorDetails, useErrorDistribution, useErrorNotification, useErrorTrends, useExecuteAction, useExecuteAsync, useExecuteResource, useExecution, useExecutionHealth, useExecutionLogSSE, useExecutionLogs, useExecutionLogsFilters, useExecutionPanelState, useExecutionSSE, useExecutions, useGetExecutionHistory, useGetSchedule, useInFlightExecutions, useList, useListApiKeys, useListDeployments, useListExecutions, useListMember, useListMembers, useListProgress, useListRecords, useListSchedules, useListWebhookEndpoints, useLists, useListsTelemetry, useMarkAllAsRead, useMarkAsRead, useMergedExecution, useMilestones, useNotificationCount as useNotificationCountSSE, useNotifications, useOrgRoles, useOrganizationMembers, usePaginationState, usePatchTask, usePauseSchedule, usePermissionCatalog, useProject, useProjectActivities, useProjectMilestones, useProjectNotes, useProjectRealtime, useProjectTasks, useProjects, useReactivateMembership, useRecentExecutionsByResource, useRemoveCompaniesFromList, useRequest, useRequestsList, useResolveAllErrors, useResolveError, useResolveErrorsByExecution, useResourceDefinition, useResourceErrors, useResourceExecutions, useResourceSearch, useResources, useResourcesDomainFilters, useResourcesHealth, useResumeSchedule, useRetryExecution, useRevokeRole, useSSEConnection, useScheduledTasks, useSession, useSessionExecution, useSessionExecutions, useSessionMessages, useSessionWebSocket, useSessions, useSortedData, useStatusFilter, useSubmitAction, useSuccessNotification, useSystemHealth, useTableSelection, useTableSort, useTasks, useTestNotification, useTimeRangeDates, useTopFailingResources, useTransitionItem, useTransitionListCompany, useTransitionListMember, useTransitionState, useUnresolveError, useUnresolvedErrors, useUpdateAnchor, useUpdateApiKey, useUpdateClient, useUpdateCompany, useUpdateContact, useUpdateCredential, useUpdateProject as useUpdateDeliveryProject, useUpdateList, useUpdateListConfig, useUpdateListStatus, useUpdateMilestone, useUpdateOrgRole, useUpdateRequestStatus, useUpdateSchedule, useUpdateTask, useUpdateWebhookEndpoint, useUserMemberships, useVerifyCredential, useVisibleResources, useWarningNotification, useWorkflowExecution };
10231
+ export type { AccessKeyInput, AcqCompanyWithCount, AcqContactWithCompany, AcqDealNote, AcqDealTask, AcqDealTaskKind, ActivityFilters, ActivityTrendResponse, AddCompaniesToListResult, AddContactsToListResult, AssignRoleInput, BulkDeleteExecutionsParams, BulkDeleteExecutionsResult, BusinessImpactMetrics, CancelExecutionParams, CancelExecutionResult, ChatMessage, ClientDetailResponse, ClientResponse, ClientStatus, ClientStatusResponse, ClientsListFilters, CreateApiKeyRequest, CreateApiKeyResponse, CreateClientRequest, CreateCredentialRequest, CreateCredentialResponse, CreateOrgRoleInput, CreateScheduleInput, CreateSessionResponse, CredentialListItem, DealDetail, DealLookupFilters, DealLookupItem, DealSummaryStageItem, DealsSummaryResponse, DeleteExecutionParams, Deployment, ErrorDistributionItem, ErrorDistributionParams, ErrorFilters, ErrorTrendsParams, ExecuteActionInput, ExecuteAsyncParams, ExecuteAsyncResult, ExecutionErrorDetails, ExecutionHistoryItem, ExecutionHistoryResponse, ExecutionLogsFilters, ExecutionLogsPageResponse, FailingResource, GetMessagesResponse, ListActivitiesResponse, ListApiKeysResponse, ListCredentialsResponse, ListExecutionsFilters, ListRecordsFilters, ListSchedulesFilters, ListSchedulesResponse, ListWebhookEndpointsResponse, MessageEvent, MessageType, OrgRole, RemoveCompaniesFromListResult, RequestRow, RequestsListFilters, ResourceFilterFacet, ResourcesResponse, RetryExecutionParams, RevokeRoleInput, SessionDTO, SessionExecution, SessionExecutionsResponse, SessionListItem, SessionTokenUsage, SortDirection, SortState, StaleDealSummaryItem, StatefulItem, StatusFilter, SubmitActionRequest, SubmitActionResponse, SystemHealthExecutionSummary, SystemHealthResponse, TaskSchedule, TopFailingResourcesParams, TransitionItemInput, TransitionListCompanyInput, TransitionListMemberInput, TransitionStateInput, UpdateClientRequest, UpdateListStatusInput, UpdateOrgRoleInput, UpdateScheduleInput, UseAccessResult, UseActivitiesParams, UseActivityTrendParams, UseArtifactsParams, UseBatchedResourcesHealthParams, UseExecuteResourceOptions, UseExecutionHealthParams, UseExecutionLogsParams, UseExecutionPanelStateOptions, UseExecutionPanelStateReturn, UseExecutionSSEOptions, UseExecutionSSEResult, UseInFlightExecutionsOptions, UseListProgressOptions, UseNotificationCountArgs, UseResourcesHealthParams, UseSSEConnectionOptions, UseScheduledTasksOptions, UseSystemHealthParams, UseWorkflowExecutionOptions, UseWorkflowExecutionResult, VerifyCredentialResponse, WebSocketState, WorkflowExecutionTriggerParams };