@elevasis/ui 2.64.1 → 2.66.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 (72) hide show
  1. package/dist/api/index.js +2 -2
  2. package/dist/app/index.d.ts +26 -0
  3. package/dist/app/index.js +8 -8
  4. package/dist/auth/index.d.ts +12 -5
  5. package/dist/auth/index.js +8 -8
  6. package/dist/charts/index.js +8 -8
  7. package/dist/{chunk-DRQPEMJI.js → chunk-4DV4ECMG.js} +3 -0
  8. package/dist/{chunk-KRWALB24.js → chunk-6SSQGWK7.js} +1 -1
  9. package/dist/{chunk-ZTWA5H77.js → chunk-6ZAP3FOA.js} +0 -1
  10. package/dist/{chunk-PGAA4G3T.js → chunk-ANNM5R7S.js} +275 -382
  11. package/dist/{chunk-I3CFGE3N.js → chunk-BLXJEIQS.js} +1 -1
  12. package/dist/chunk-L7BZZ4SI.js +56 -0
  13. package/dist/chunk-P45GQ3ZW.js +104 -0
  14. package/dist/{chunk-EIXSQONC.js → chunk-RT4KRGZT.js} +37 -59
  15. package/dist/{chunk-FVOMKZ7S.js → chunk-Y6I3IC45.js} +3 -6
  16. package/dist/components/index.d.ts +274 -191
  17. package/dist/components/index.js +8 -8
  18. package/dist/components/navigation/index.js +8 -8
  19. package/dist/execution/index.d.ts +115 -104
  20. package/dist/execution/index.js +2 -2
  21. package/dist/features/auth/index.d.ts +125 -9
  22. package/dist/features/auth/index.js +154 -14
  23. package/dist/features/clients/index.js +8 -8
  24. package/dist/features/crm/index.d.ts +20 -0
  25. package/dist/features/crm/index.js +8 -8
  26. package/dist/features/dashboard/index.js +8 -8
  27. package/dist/features/delivery/index.d.ts +20 -0
  28. package/dist/features/delivery/index.js +8 -8
  29. package/dist/features/knowledge/index.js +8 -8
  30. package/dist/features/lead-gen/index.js +8 -8
  31. package/dist/features/monitoring/index.js +8 -8
  32. package/dist/features/monitoring/requests/index.js +9 -9
  33. package/dist/features/notes/index.js +2 -2
  34. package/dist/features/operations/index.d.ts +177 -106
  35. package/dist/features/operations/index.js +8 -8
  36. package/dist/features/public-agent-chat/index.js +1 -1
  37. package/dist/features/settings/index.d.ts +21 -0
  38. package/dist/features/settings/index.js +8 -8
  39. package/dist/hooks/access/index.js +8 -8
  40. package/dist/hooks/delivery/index.d.ts +20 -0
  41. package/dist/hooks/delivery/index.js +8 -8
  42. package/dist/hooks/index.d.ts +319 -145
  43. package/dist/hooks/index.js +8 -8
  44. package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +0 -2
  45. package/dist/hooks/operations/command-view/utils/transformCommandViewData.js +1 -1
  46. package/dist/hooks/published.d.ts +319 -145
  47. package/dist/hooks/published.js +8 -8
  48. package/dist/index.d.ts +409 -219
  49. package/dist/index.js +8 -8
  50. package/dist/initialization/index.d.ts +95 -28
  51. package/dist/initialization/index.js +3 -3
  52. package/dist/knowledge/index.js +12 -12
  53. package/dist/{knowledge-search-index-JOPRYZN6.js → knowledge-search-index-6EZNBNSR.js} +4 -4
  54. package/dist/layout/index.js +8 -8
  55. package/dist/organization/index.d.ts +63 -4
  56. package/dist/organization/index.js +8 -8
  57. package/dist/profile/index.d.ts +43 -2
  58. package/dist/profile/index.js +1 -1
  59. package/dist/provider/index.d.ts +20 -0
  60. package/dist/provider/index.js +8 -8
  61. package/dist/provider/published.d.ts +20 -0
  62. package/dist/provider/published.js +8 -8
  63. package/dist/supabase/index.d.ts +40 -0
  64. package/dist/test-utils/index.d.ts +5 -0
  65. package/dist/test-utils/index.js +4 -4
  66. package/dist/test-utils/setup-integration.js +1 -1
  67. package/dist/test-utils/setup.js +1 -1
  68. package/dist/types/index.d.ts +483 -244
  69. package/dist/utils/index.js +2 -2
  70. package/package.json +6 -4
  71. package/dist/chunk-LO7GWG24.js +0 -75
  72. package/dist/chunk-T4LA4RY2.js +0 -56
@@ -209,208 +209,6 @@ interface ExecutionLogMessage {
209
209
  context?: LogContext;
210
210
  }
211
211
 
212
- /**
213
- * Serialized Registry Types
214
- *
215
- * Pre-computed JSON-safe types for API responses and Command View.
216
- * Serialization happens once at API startup, enabling instant response times.
217
- */
218
-
219
- /**
220
- * Serialized agent definition (JSON-safe)
221
- * Result of serializeDefinition(AgentDefinition)
222
- */
223
- interface SerializedAgentDefinition {
224
- config: {
225
- resourceId: string;
226
- name: string;
227
- description: string;
228
- version: string;
229
- type: 'agent';
230
- kind: 'orchestrator' | 'specialist' | 'utility' | 'system';
231
- status: 'dev' | 'prod';
232
- links?: ResourceLink[];
233
- category?: ResourceCategory;
234
- /** Whether this resource is archived and should be excluded from registration and deployment */
235
- archived?: boolean;
236
- systemPrompt: string;
237
- constraints?: {
238
- maxIterations?: number;
239
- timeout?: number;
240
- maxSessionMemoryKeys?: number;
241
- maxMemoryTokens?: number;
242
- };
243
- sessionCapable?: boolean;
244
- memoryPreferences?: string;
245
- };
246
- modelConfig: {
247
- provider: string;
248
- model: string;
249
- apiKey: string;
250
- temperature: number;
251
- maxOutputTokens: number;
252
- topP?: number;
253
- modelOptions?: Record<string, unknown>;
254
- };
255
- contract: {
256
- inputSchema: object;
257
- outputSchema?: object;
258
- };
259
- tools: Array<{
260
- name: string;
261
- description: string;
262
- inputSchema?: object;
263
- outputSchema?: object;
264
- }>;
265
- knowledgeMap?: {
266
- nodeCount: number;
267
- nodes: Array<{
268
- id: string;
269
- description: string;
270
- loaded: boolean;
271
- hasPrompt: boolean;
272
- }>;
273
- };
274
- metricsConfig?: object;
275
- }
276
- /**
277
- * Serialized workflow definition (JSON-safe)
278
- * Result of serializeDefinition(WorkflowDefinition)
279
- */
280
- interface SerializedWorkflowDefinition {
281
- config: {
282
- resourceId: string;
283
- name: string;
284
- description: string;
285
- version: string;
286
- type: 'workflow';
287
- status: 'dev' | 'prod';
288
- links?: ResourceLink[];
289
- category?: ResourceCategory;
290
- /** Whether this resource is archived and should be excluded from registration and deployment */
291
- archived?: boolean;
292
- };
293
- entryPoint: string;
294
- steps: Array<{
295
- id: string;
296
- name: string;
297
- description: string;
298
- inputSchema?: object;
299
- outputSchema?: object;
300
- next: {
301
- type: 'linear' | 'conditional';
302
- target?: string;
303
- routes?: Array<{
304
- target: string;
305
- }>;
306
- default?: string;
307
- } | null;
308
- }>;
309
- contract: {
310
- inputSchema: object;
311
- outputSchema?: object;
312
- };
313
- metricsConfig?: object;
314
- }
315
-
316
- /**
317
- * Model Configuration
318
- * Centralized model information, configuration, options, constraints, and validation
319
- * Single source of truth for all model-related definitions
320
- * Update manually when pricing changes or new models are added
321
- */
322
-
323
- /**
324
- * Supported Open AI models (direct SDK access)
325
- */
326
- type OpenAIModel = 'gpt-5' | 'gpt-5.4-mini' | 'gpt-5.4-nano';
327
- /**
328
- * Supported OpenRouter models (explicit union for type safety)
329
- */
330
- type OpenRouterModel = 'openrouter/z-ai/glm-5';
331
- /**
332
- * Supported Google models (direct SDK access)
333
- */
334
- type GoogleModel = 'gemini-3-flash-preview' | 'gemini-3.1-flash-lite-preview';
335
- /**
336
- * Supported Anthropic models (direct SDK access via @anthropic-ai/sdk)
337
- */
338
- type AnthropicModel = 'claude-opus-5' | 'claude-sonnet-5' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5';
339
- /** Supported LLM models */
340
- type LLMModel = OpenAIModel | OpenRouterModel | GoogleModel | AnthropicModel | 'mock';
341
- /**
342
- * GPT-5 model options schema
343
- */
344
- declare const GPT5OptionsSchema: z.ZodObject<{
345
- reasoning_effort: z.ZodOptional<z.ZodEnum<{
346
- minimal: "minimal";
347
- low: "low";
348
- medium: "medium";
349
- high: "high";
350
- }>>;
351
- verbosity: z.ZodOptional<z.ZodEnum<{
352
- low: "low";
353
- medium: "medium";
354
- high: "high";
355
- }>>;
356
- }, z.core.$strip>;
357
- /**
358
- * OpenRouter model options schema
359
- * OpenRouter-specific options for routing and transforms
360
- */
361
- declare const OpenRouterOptionsSchema: z.ZodObject<{
362
- transforms: z.ZodOptional<z.ZodArray<z.ZodString>>;
363
- route: z.ZodOptional<z.ZodEnum<{
364
- fallback: "fallback";
365
- }>>;
366
- }, z.core.$strip>;
367
- /**
368
- * Google model options schema
369
- * Gemini 3 specific options for thinking depth control
370
- */
371
- declare const GoogleOptionsSchema: z.ZodObject<{
372
- thinkingLevel: z.ZodOptional<z.ZodEnum<{
373
- minimal: "minimal";
374
- low: "low";
375
- medium: "medium";
376
- high: "high";
377
- }>>;
378
- }, z.core.$strip>;
379
- /**
380
- * Anthropic model options schema
381
- * Currently empty - future options must be added per supported model family
382
- */
383
- declare const AnthropicOptionsSchema: z.ZodObject<{}, z.core.$strict>;
384
- /**
385
- * Infer TypeScript types from schemas
386
- */
387
- type GPT5Options = z.infer<typeof GPT5OptionsSchema>;
388
- type MockOptions = Record<string, never>;
389
- type OpenRouterOptions = z.infer<typeof OpenRouterOptionsSchema>;
390
- type GoogleOptions = z.infer<typeof GoogleOptionsSchema>;
391
- type AnthropicOptions = z.infer<typeof AnthropicOptionsSchema>;
392
- type ModelSpecificOptions = GPT5Options | MockOptions | OpenRouterOptions | GoogleOptions | AnthropicOptions;
393
- /**
394
- * Model configuration for LLM execution
395
- * Belongs in resource definition (AgentDefinition, WorkflowDefinition, etc.)
396
- */
397
- interface ModelConfig {
398
- model: LLMModel;
399
- provider: 'openai' | 'anthropic' | 'openrouter' | 'google' | 'mock';
400
- apiKey: string;
401
- temperature?: number;
402
- /** Maximum output tokens per LLM call. NOT the model's context window — see ModelInfo.maxTokens for that. */
403
- maxOutputTokens?: number;
404
- topP?: number;
405
- /**
406
- * Model-specific options (flat structure)
407
- * Options are model-specific, not vendor-specific
408
- * Available options defined in MODEL_INFO per model
409
- * Validated at build time via validateModelOptions()
410
- */
411
- modelOptions?: ModelSpecificOptions;
412
- }
413
-
414
212
  declare const ResourceGovernanceStatusSchema: z.ZodEnum<{
415
213
  active: "active";
416
214
  deprecated: "deprecated";
@@ -637,6 +435,184 @@ declare const ResourceEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
637
435
  type ResourceGovernanceStatus = z.infer<typeof ResourceGovernanceStatusSchema>;
638
436
  type ResourceEntry = z.infer<typeof ResourceEntrySchema>;
639
437
 
438
+ /**
439
+ * Memory type definitions
440
+ * Types for agent memory management with semantic entry types
441
+ */
442
+ /**
443
+ * Semantic memory entry types
444
+ * Use-case agnostic types that describe the purpose of each entry
445
+ * Memory types mirror action types for clarity and filtering
446
+ */
447
+ type MemoryEntryType = 'context' | 'input' | 'reasoning' | 'tool-result' | 'error';
448
+ /**
449
+ * Who authored an entry's content.
450
+ *
451
+ * This is what lets the assembled prompt tell framework-authored text apart from text that
452
+ * originated outside the trust boundary. `'framework'` content is ours; the other three are not
453
+ * and are rendered inside the JSON data envelope (see `MemoryManager.toContextParts`).
454
+ */
455
+ type MemoryEntrySource = 'framework' | 'user' | 'tool' | 'model';
456
+ /**
457
+ * Memory entry - represents a single entry in agent memory
458
+ * Stored in agent memory, translated by adapters to vendor-specific formats
459
+ */
460
+ interface MemoryEntry {
461
+ type: MemoryEntryType;
462
+ content: string;
463
+ timestamp: number;
464
+ turnNumber: number | null;
465
+ iterationNumber: number | null;
466
+ /**
467
+ * Provenance. **Optional on purpose** — `undefined` means unknown, which is what every
468
+ * pre-existing snapshot and every not-yet-redeployed tenant bundle produces. Read sites MUST
469
+ * test `== null`, never `=== undefined`: the `inTurnScope` predicate in `manager.ts` is the
470
+ * cautionary precedent, where a `=== undefined` check silently dropped every `null`-stamped
471
+ * entry. `isMemoryEntry` is deliberately NOT tightened to require this field; doing so would
472
+ * make every stored snapshot fail validation, and `restoreSessionMemory` fails open by
473
+ * starting the agent with empty memory rather than throwing.
474
+ */
475
+ source?: MemoryEntrySource;
476
+ /**
477
+ * Which tool produced this entry. Set on `tool-result` entries so the model can tell N parallel
478
+ * results apart -- the framework instructs batching independent tool calls in one iteration, and
479
+ * an anonymous result is unattributable the moment two land in the same iteration. `addToolError`
480
+ * already carries this (folded into its `content` JSON); this is the same fact for the success
481
+ * path, carried as a real field instead of prose the caller has to parse back out.
482
+ */
483
+ toolName?: string;
484
+ /**
485
+ * Present when `truncateContent` cut this entry's `content` to fit its token budget. A sibling
486
+ * field, never text appended into `content` -- the notice used to be spliced into the string
487
+ * itself, which could (and did) land inside a JSON string literal `truncateContent` had just cut
488
+ * open, breaking `JSON.parse` on the far end. Absent means never truncated.
489
+ */
490
+ truncated?: {
491
+ omittedTokens: number;
492
+ };
493
+ /**
494
+ * Prompt-injection warning types found in `content`, screened once here -- when the entry is
495
+ * written -- instead of by re-scanning the whole accumulated envelope on every iteration it gets
496
+ * re-sent for (`screenRequest`'s `data-envelope` slot used to do exactly that). Empty array means
497
+ * screened and clean; `undefined` means never screened (entries that bypass `addToHistory`/`set`,
498
+ * or pre-existing snapshots from before this field existed).
499
+ */
500
+ warnings?: string[];
501
+ }
502
+ /**
503
+ * Agent memory - Self-orchestrated memory with session + working storage
504
+ * Agent has full control over what persists, framework handles auto-compaction
505
+ */
506
+ interface AgentMemory {
507
+ /**
508
+ * Session memory - Persists for session/conversation duration
509
+ * Never auto-trimmed by framework
510
+ * Agent-managed key-value store for critical information
511
+ * Agent provides strings, framework wraps in MemoryEntry
512
+ */
513
+ sessionMemory: Record<string, MemoryEntry>;
514
+ /**
515
+ * Working memory - Execution history
516
+ * Automatically compacted by framework when needed
517
+ * Agent doesn't control compaction
518
+ */
519
+ history: MemoryEntry[];
520
+ }
521
+
522
+ /**
523
+ * Types for the schema compiler. `compile.ts` walks a `JsonSchema` once, driven entirely by a
524
+ * `ProviderDialect`, and every server adapter compiles through it.
525
+ */
526
+ /**
527
+ * What happened to `strict` on a request, recorded per call rather than inferred.
528
+ *
529
+ * `applied` and `notAttempted` are the two states that a refusal-only field cannot tell apart --
530
+ * both leave `strictRefusalReasons` empty. Recording the verdict positively is what makes "was
531
+ * this agent's output actually enforced?" answerable from an `ai_calls` row.
532
+ */
533
+ type StrictStatus = 'applied' | 'refused' | 'compileRejected' | 'notAttempted';
534
+
535
+ /**
536
+ * Model Configuration
537
+ * Centralized model information, configuration, options, constraints, and validation
538
+ * Single source of truth for all model-related definitions
539
+ * Update manually when pricing changes or new models are added
540
+ */
541
+
542
+ /**
543
+ * Supported Open AI models (direct SDK access)
544
+ */
545
+ type OpenAIModel = 'gpt-5' | 'gpt-5.4-mini' | 'gpt-5.4-nano';
546
+ /**
547
+ * Supported OpenRouter models (explicit union for type safety)
548
+ */
549
+ type OpenRouterModel = 'openrouter/z-ai/glm-5';
550
+ /**
551
+ * Supported Anthropic models (direct SDK access via @anthropic-ai/sdk)
552
+ */
553
+ type AnthropicModel = 'claude-opus-5' | 'claude-sonnet-5' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5';
554
+ /** Supported LLM models */
555
+ type LLMModel = OpenAIModel | OpenRouterModel | AnthropicModel | 'mock';
556
+ /**
557
+ * GPT-5 model options schema
558
+ */
559
+ declare const GPT5OptionsSchema: z.ZodObject<{
560
+ reasoning_effort: z.ZodOptional<z.ZodEnum<{
561
+ minimal: "minimal";
562
+ low: "low";
563
+ medium: "medium";
564
+ high: "high";
565
+ }>>;
566
+ verbosity: z.ZodOptional<z.ZodEnum<{
567
+ low: "low";
568
+ medium: "medium";
569
+ high: "high";
570
+ }>>;
571
+ }, z.core.$strip>;
572
+ /**
573
+ * OpenRouter model options schema
574
+ * OpenRouter-specific options for routing and transforms
575
+ */
576
+ declare const OpenRouterOptionsSchema: z.ZodObject<{
577
+ transforms: z.ZodOptional<z.ZodArray<z.ZodString>>;
578
+ route: z.ZodOptional<z.ZodEnum<{
579
+ fallback: "fallback";
580
+ }>>;
581
+ }, z.core.$strip>;
582
+ /**
583
+ * Anthropic model options schema
584
+ * Currently empty - future options must be added per supported model family
585
+ */
586
+ declare const AnthropicOptionsSchema: z.ZodObject<{}, z.core.$strict>;
587
+ /**
588
+ * Infer TypeScript types from schemas
589
+ */
590
+ type GPT5Options = z.infer<typeof GPT5OptionsSchema>;
591
+ type MockOptions = Record<string, never>;
592
+ type OpenRouterOptions = z.infer<typeof OpenRouterOptionsSchema>;
593
+ type AnthropicOptions = z.infer<typeof AnthropicOptionsSchema>;
594
+ type ModelSpecificOptions = GPT5Options | MockOptions | OpenRouterOptions | AnthropicOptions;
595
+ /**
596
+ * Model configuration for LLM execution
597
+ * Belongs in resource definition (AgentDefinition, WorkflowDefinition, etc.)
598
+ */
599
+ interface ModelConfig {
600
+ model: LLMModel;
601
+ provider: 'openai' | 'anthropic' | 'openrouter' | 'mock';
602
+ apiKey: string;
603
+ temperature?: number;
604
+ /** Maximum output tokens per LLM call. NOT the model's context window — see ModelInfo.maxTokens for that. */
605
+ maxOutputTokens?: number;
606
+ topP?: number;
607
+ /**
608
+ * Model-specific options (flat structure)
609
+ * Options are model-specific, not vendor-specific
610
+ * Available options defined in MODEL_INFO per model
611
+ * Validated at build time via validateModelOptions()
612
+ */
613
+ modelOptions?: ModelSpecificOptions;
614
+ }
615
+
640
616
  /**
641
617
  * Shared form field types for dynamic form generation
642
618
  * Used by: Command Queue, Execution Runner UI, future form-based features
@@ -713,47 +689,6 @@ interface WorkflowNodeVisualizerData {
713
689
  isRunning: boolean;
714
690
  }
715
691
 
716
- /**
717
- * Memory type definitions
718
- * Types for agent memory management with semantic entry types
719
- */
720
- /**
721
- * Semantic memory entry types
722
- * Use-case agnostic types that describe the purpose of each entry
723
- * Memory types mirror action types for clarity and filtering
724
- */
725
- type MemoryEntryType = 'context' | 'input' | 'reasoning' | 'tool-result' | 'delegation-result' | 'error';
726
- /**
727
- * Memory entry - represents a single entry in agent memory
728
- * Stored in agent memory, translated by adapters to vendor-specific formats
729
- */
730
- interface MemoryEntry {
731
- type: MemoryEntryType;
732
- content: string;
733
- timestamp: number;
734
- turnNumber: number | null;
735
- iterationNumber: number | null;
736
- }
737
- /**
738
- * Agent memory - Self-orchestrated memory with session + working storage
739
- * Agent has full control over what persists, framework handles auto-compaction
740
- */
741
- interface AgentMemory {
742
- /**
743
- * Session memory - Persists for session/conversation duration
744
- * Never auto-trimmed by framework
745
- * Agent-managed key-value store for critical information
746
- * Agent provides strings, framework wraps in MemoryEntry
747
- */
748
- sessionMemory: Record<string, MemoryEntry>;
749
- /**
750
- * Working memory - Execution history
751
- * Automatically compacted by framework when needed
752
- * Agent doesn't control compaction
753
- */
754
- history: MemoryEntry[];
755
- }
756
-
757
692
  /**
758
693
  * Agent timeline and observability types
759
694
  * Used for UI timeline visualization and backend processing
@@ -3554,6 +3489,7 @@ type Database = {
3554
3489
  deleted_at: string | null;
3555
3490
  ended_at: string | null;
3556
3491
  memory_snapshot: Json;
3492
+ memory_version: number;
3557
3493
  metadata: Json | null;
3558
3494
  organization_id: string;
3559
3495
  resource_id: string;
@@ -3570,6 +3506,7 @@ type Database = {
3570
3506
  deleted_at?: string | null;
3571
3507
  ended_at?: string | null;
3572
3508
  memory_snapshot: Json;
3509
+ memory_version?: number;
3573
3510
  metadata?: Json | null;
3574
3511
  organization_id: string;
3575
3512
  resource_id: string;
@@ -3586,6 +3523,7 @@ type Database = {
3586
3523
  deleted_at?: string | null;
3587
3524
  ended_at?: string | null;
3588
3525
  memory_snapshot?: Json;
3526
+ memory_version?: number;
3589
3527
  metadata?: Json | null;
3590
3528
  organization_id?: string;
3591
3529
  resource_id?: string;
@@ -3923,9 +3861,14 @@ type Database = {
3923
3861
  p_session_id: string;
3924
3862
  };
3925
3863
  Returns: {
3864
+ context_window_size: number;
3926
3865
  created_at: string;
3866
+ cumulative_input_tokens: number;
3867
+ cumulative_output_tokens: number;
3868
+ deleted_at: string;
3927
3869
  ended_at: string;
3928
3870
  memory_snapshot: Json;
3871
+ memory_version: number;
3929
3872
  metadata: Json;
3930
3873
  organization_id: string;
3931
3874
  resource_id: string;
@@ -3967,6 +3910,18 @@ type Database = {
3967
3910
  };
3968
3911
  Returns: boolean;
3969
3912
  };
3913
+ increment_session_tokens: {
3914
+ Args: {
3915
+ p_input_tokens: number;
3916
+ p_output_tokens: number;
3917
+ p_session_id: string;
3918
+ };
3919
+ Returns: {
3920
+ context_window_size: number;
3921
+ cumulative_input_tokens: number;
3922
+ cumulative_output_tokens: number;
3923
+ }[];
3924
+ };
3970
3925
  is_org_member: {
3971
3926
  Args: {
3972
3927
  org_id: string;
@@ -4627,10 +4582,50 @@ interface ListMembershipsParams {
4627
4582
  after?: string;
4628
4583
  order?: 'asc' | 'desc';
4629
4584
  }
4585
+ /**
4586
+ * How a membership row relates to the two systems that describe it.
4587
+ *
4588
+ * - `linked` — an `org_memberships` row that carries a `workos_membership_id`
4589
+ * - `pre_provisioned` — an `org_memberships` row with no `workos_membership_id`;
4590
+ * the invitee was provisioned but has not completed signup
4591
+ * - `workos_only` — a WorkOS membership with no `org_memberships` row (a sync gap)
4592
+ */
4593
+ type MembershipProvisioningState = 'linked' | 'pre_provisioned' | 'workos_only';
4630
4594
  /**
4631
4595
  * Extended membership with user and organization details for UI
4596
+ *
4597
+ * **ID convention (step 17 of the auth/invitations architecture refactor):**
4598
+ * `id`, `userId`, and `organizationId` are the canonical Supabase UUIDs
4599
+ * (`org_memberships.id` / `users.id` / `organizations.id`) on every producer
4600
+ * of this type. `workosMembershipId` / `workosUserId` /
4601
+ * `organization.workos_org_id` carry the WorkOS-side forms explicitly instead
4602
+ * -- the contract does not overload the canonical fields with either form.
4603
+ *
4604
+ * The one exception: a `workos_only` row (a WorkOS membership with no
4605
+ * `org_memberships` row -- a sync gap) has no canonical membership UUID to
4606
+ * report, because no such row exists. `id` stays the WorkOS `om_...` form for
4607
+ * that `provisioningState` alone; `userId` / `organizationId` are still
4608
+ * resolved to their Supabase forms where the user/organization themselves
4609
+ * exist.
4632
4610
  */
4633
4611
  interface MembershipWithDetails extends OrganizationMembership {
4612
+ /**
4613
+ * Set by `GET /memberships`. Optional so existing consumers are unaffected;
4614
+ * treat `undefined` as "not reported by this endpoint".
4615
+ */
4616
+ provisioningState?: MembershipProvisioningState;
4617
+ /**
4618
+ * WorkOS `om_...` form of `id`. `null` when the membership is
4619
+ * pre-provisioned (invited, signup not completed -- no WorkOS record yet).
4620
+ * Explicit companion to the canonical `id`; see the type-level doc comment.
4621
+ */
4622
+ workosMembershipId?: string | null;
4623
+ /**
4624
+ * WorkOS `user_...` form of `userId`. `null` when the member has not
4625
+ * completed WorkOS signup yet. Explicit companion to the canonical
4626
+ * `userId`; see the type-level doc comment.
4627
+ */
4628
+ workosUserId?: string | null;
4634
4629
  user?: {
4635
4630
  id: string;
4636
4631
  email: string;
@@ -4678,6 +4673,25 @@ interface OAuthState {
4678
4673
  provider: string;
4679
4674
  }
4680
4675
 
4676
+ /**
4677
+ * Which `role:'user'` message slot a sanitizer warning came from, derived from the request's
4678
+ * message array (no new plumbing from callers):
4679
+ * - `'memory-context'` — the framework's framing message, identified by the `=== MEMORY STATUS ===`
4680
+ * banner. Framework-authored and trusted; it is no longer scanned at all, so this source should
4681
+ * not appear for agent calls. Retained because stale tenant bundles still emit the old combined
4682
+ * block, and their rows must stay readable.
4683
+ * - `'data-envelope'` — the JSON envelope carrying every stored fragment. Untrusted, and the slot
4684
+ * where a match is genuine signal.
4685
+ * - `'input'` — the turn's own input, on its own message. Also untrusted.
4686
+ * - `'history'` — replayed prior turns. Untrusted, but already screened at their own front door,
4687
+ * so warnings here are recorded and never block (see `screenInput`).
4688
+ */
4689
+ type InputWarningSource = 'memory-context' | 'data-envelope' | 'history' | 'input';
4690
+ /** Per-source breakdown of sanitizer warnings, so a memory-context echo is distinguishable from a genuine hit. */
4691
+ interface SourcedInputWarnings {
4692
+ source: InputWarningSource;
4693
+ warnings: string[];
4694
+ }
4681
4695
  interface BaseAICall {
4682
4696
  callSequence: number;
4683
4697
  callType: 'agent-reasoning' | 'agent-completion' | 'workflow-step' | 'tool' | 'other';
@@ -4687,6 +4701,117 @@ interface BaseAICall {
4687
4701
  costUsd: number;
4688
4702
  latencyMs: number;
4689
4703
  context?: AICallContext;
4704
+ /**
4705
+ * Anthropic-only: input tokens served from the prompt cache this call (`cache_read_input_tokens`),
4706
+ * billed at 0.1x the base input rate. Already folded into `inputTokens`/`totalInputTokens` so
4707
+ * aggregate totals reflect real usage -- present here as the raw breakdown, not additive on top.
4708
+ */
4709
+ cacheReadInputTokens?: number;
4710
+ /**
4711
+ * Anthropic-only: input tokens written to the prompt cache this call (`cache_creation_input_tokens`),
4712
+ * billed at 1.25x the base input rate. Same folding rationale as `cacheReadInputTokens`.
4713
+ */
4714
+ cacheCreationInputTokens?: number;
4715
+ /**
4716
+ * Distinct prompt-injection pattern types detected in the request's user-role messages.
4717
+ * Present only when the input sanitizer matched something. Non-blocking matches ride along on
4718
+ * the successful call's row; a blocked call records a row of its own (see `inputBlocked`).
4719
+ *
4720
+ * Flat union across all `role:'user'` messages — unchanged shape, kept for existing readers.
4721
+ * See `inputWarningsBySource` for the per-slot breakdown.
4722
+ */
4723
+ inputWarnings?: string[];
4724
+ /**
4725
+ * Additive breakdown of `inputWarnings` by message slot (see `InputWarningSource`). Present only
4726
+ * when at least one source produced a warning. Existing readers that only look at the flat
4727
+ * `inputWarnings` array are unaffected.
4728
+ */
4729
+ inputWarningsBySource?: SourcedInputWarnings[];
4730
+ /**
4731
+ * True when the sanitizer blocked the request and no provider call was made.
4732
+ * Such a row carries zero tokens, zero cost, and zero latency — it exists so a hard,
4733
+ * user-visible failure is observable at all. Before this, a blocked call produced no row.
4734
+ */
4735
+ inputBlocked?: boolean;
4736
+ /**
4737
+ * The validator's message when the provider responded but its output failed `responseSchema`
4738
+ * validation (e.g. `missing required field 'nextActions'`). Present only on such a row.
4739
+ *
4740
+ * This is NOT the blocked-input case: the provider DID respond and tokens WERE spent, so the row
4741
+ * carries real `inputTokens`, `outputTokens`, cost and latency. It is a paid call that produced
4742
+ * nothing usable, and before this it produced no row at all.
4743
+ *
4744
+ * One row per failed attempt — the adapter retries a validation failure up to `LLM_MAX_ATTEMPTS`,
4745
+ * so a turn that exhausts its retries records three. Reading `inputTokens` across these rows is
4746
+ * what measures malformed-output rate against context size rather than inferring it.
4747
+ *
4748
+ * Existing readers that only look at the fields above are unaffected.
4749
+ */
4750
+ outputValidationError?: string;
4751
+ /**
4752
+ * The raw model output that failed validation, JSON-stringified and truncated to a bounded
4753
+ * length. Truncation is visible in the value itself (a trailing `…[truncated: N chars total]`),
4754
+ * never silent. Present only alongside `outputValidationError`.
4755
+ */
4756
+ unvalidatedOutput?: string;
4757
+ /**
4758
+ * What happened to `strict` structured output on this call — `applied`, `refused`,
4759
+ * `compileRejected`, or `notAttempted`. Every server adapter sets it, so this is the field that
4760
+ * answers "is this agent's output actually being enforced?" without reading source.
4761
+ *
4762
+ * It replaces an inference that turned out to be unsound. `strictRefusalReasons` alone records
4763
+ * only refusals, so an empty row meant "strict held" OR "this adapter never tries" — and a prod
4764
+ * run recorded zero refusals while a call returned an array-typed field as a string, which a
4765
+ * grammar makes impossible. The absence proved nothing, because the deployed API had no way to
4766
+ * write the field at all.
4767
+ *
4768
+ * Absent on rows written before this field existed; that absence is itself diagnostic (the API
4769
+ * predates the change). Existing readers that only look at the fields above are unaffected.
4770
+ */
4771
+ strictStatus?: StrictStatus;
4772
+ /**
4773
+ * Why this call went out without `strict`, when a strict-capable adapter refused the schema. The
4774
+ * detail behind `strictStatus: 'refused' | 'compileRejected'` — read `strictStatus` for whether
4775
+ * it was enforced, this for why not.
4776
+ *
4777
+ * Existing readers that only look at the fields above are unaffected.
4778
+ */
4779
+ strictRefusalReasons?: string[];
4780
+ /**
4781
+ * Time spent in the base adapter's `generate()` call alone, excluding `responseSchema`
4782
+ * validation. On a success or validation-failure row, `providerMs + validateMs === latencyMs`
4783
+ * (modulo rounding) -- `latencyMs` keeps its existing meaning unchanged; this and `validateMs`
4784
+ * are the same window split into its two components.
4785
+ *
4786
+ * Present on success and validation-failure rows. Absent on a blocked row (no provider call was
4787
+ * made) and on rows written before this field existed.
4788
+ */
4789
+ providerMs?: number;
4790
+ /**
4791
+ * Time spent in `validateResponseSchema` alone. Omitted when the call carried no `responseSchema`
4792
+ * (nothing to validate); `0` is a legitimate value meaning a schema was supplied and validation
4793
+ * was effectively instant. See `providerMs` for how the two relate to `latencyMs`.
4794
+ *
4795
+ * Present on success and validation-failure rows that supplied a `responseSchema`. Absent on a
4796
+ * blocked row and on rows written before this field existed.
4797
+ */
4798
+ validateMs?: number;
4799
+ /**
4800
+ * Total elapsed time for the WHOLE `generate()` call -- every retry attempt plus every backoff
4801
+ * sleep between them. Unlike `latencyMs` (which is per-attempt and never includes backoff, by
4802
+ * design -- see `runWithRetry`), this is the one number that answers "how long did the caller
4803
+ * actually wait". On a call that never retried, `wallClockMs === latencyMs`. On a retried call,
4804
+ * `wallClockMs` is strictly greater than any individual row's `latencyMs` from that same call, by
4805
+ * at least the backoff time actually slept.
4806
+ *
4807
+ * The same value is attached to every row produced by one `generate()` call (a validation-failure
4808
+ * row from an earlier attempt included), because it describes the call, not the attempt.
4809
+ *
4810
+ * Present on success and validation-failure rows. Absent on a blocked row -- a blocked call never
4811
+ * reaches the retry loop, so `wallClockMs` would just restate `latencyMs` (0). Absent on rows
4812
+ * written before this field existed.
4813
+ */
4814
+ wallClockMs?: number;
4690
4815
  }
4691
4816
  type AICallContext = AgentReasoningContext | AgentCompletionContext | WorkflowStepContext | ToolCallContext | OtherCallContext;
4692
4817
  interface AgentReasoningContext {
@@ -4993,6 +5118,121 @@ interface CostByModelResponse {
4993
5118
  totalCallCount: number;
4994
5119
  }
4995
5120
 
5121
+ /**
5122
+ * Agent-specific type definitions
5123
+ * Types for autonomous agents with tools, memory, and constraints
5124
+ */
5125
+
5126
+ type AgentKind = 'orchestrator' | 'specialist' | 'utility' | 'platform';
5127
+
5128
+ /**
5129
+ * Serialized Registry Types
5130
+ *
5131
+ * Pre-computed JSON-safe types for API responses and Command View.
5132
+ * Serialization happens once at API startup, enabling instant response times.
5133
+ */
5134
+
5135
+ /**
5136
+ * Serialized agent definition (JSON-safe)
5137
+ * Result of serializeDefinition(AgentDefinition)
5138
+ */
5139
+ interface SerializedAgentDefinition {
5140
+ config: {
5141
+ resourceId: string;
5142
+ name: string;
5143
+ description: string;
5144
+ version: string;
5145
+ type: 'agent';
5146
+ /**
5147
+ * Imported from the runtime type instead of hand-copied. It used to be a hand-written literal
5148
+ * union that said `'system'` where `AgentKind`'s fourth member is `'platform'` -- undetected
5149
+ * because `serializeDefinition` returns `any` and every call site casts the result to this
5150
+ * interface, so the literal union was never actually checked against real data. Deriving from
5151
+ * the source of truth makes that class of drift a type error instead of a silent typo.
5152
+ */
5153
+ kind: AgentKind;
5154
+ status: 'dev' | 'prod';
5155
+ links?: ResourceLink[];
5156
+ category?: ResourceCategory;
5157
+ /** Whether this resource is archived and should be excluded from registration and deployment */
5158
+ archived?: boolean;
5159
+ systemPrompt: string;
5160
+ constraints?: {
5161
+ maxIterations?: number;
5162
+ timeout?: number;
5163
+ maxSessionMemoryKeys?: number;
5164
+ maxMemoryTokens?: number;
5165
+ };
5166
+ sessionCapable?: boolean;
5167
+ memoryPreferences?: string;
5168
+ };
5169
+ modelConfig: {
5170
+ provider: string;
5171
+ model: string;
5172
+ apiKey: string;
5173
+ /**
5174
+ * Optional here, matching `ModelConfig` -- this used to be required even though neither real
5175
+ * agent literal in the monorepo (`local-test-agent`, the `createPlatformToolAgent` test fixture)
5176
+ * sets it, and nothing caught the mismatch for the same `serializeDefinition`-returns-`any`
5177
+ * reason `kind` drifted above.
5178
+ */
5179
+ temperature?: number;
5180
+ maxOutputTokens?: number;
5181
+ topP?: number;
5182
+ modelOptions?: Record<string, unknown>;
5183
+ };
5184
+ contract: {
5185
+ inputSchema: object;
5186
+ outputSchema?: object;
5187
+ };
5188
+ tools: Array<{
5189
+ name: string;
5190
+ description: string;
5191
+ inputSchema?: object;
5192
+ outputSchema?: object;
5193
+ }>;
5194
+ metricsConfig?: object;
5195
+ }
5196
+ /**
5197
+ * Serialized workflow definition (JSON-safe)
5198
+ * Result of serializeDefinition(WorkflowDefinition)
5199
+ */
5200
+ interface SerializedWorkflowDefinition {
5201
+ config: {
5202
+ resourceId: string;
5203
+ name: string;
5204
+ description: string;
5205
+ version: string;
5206
+ type: 'workflow';
5207
+ status: 'dev' | 'prod';
5208
+ links?: ResourceLink[];
5209
+ category?: ResourceCategory;
5210
+ /** Whether this resource is archived and should be excluded from registration and deployment */
5211
+ archived?: boolean;
5212
+ };
5213
+ entryPoint: string;
5214
+ steps: Array<{
5215
+ id: string;
5216
+ name: string;
5217
+ description: string;
5218
+ inputSchema?: object;
5219
+ outputSchema?: object;
5220
+ next: {
5221
+ type: 'linear' | 'conditional';
5222
+ target?: string;
5223
+ routes?: Array<{
5224
+ target: string;
5225
+ }>;
5226
+ default?: string;
5227
+ } | null;
5228
+ }>;
5229
+ contract: {
5230
+ inputSchema: object;
5231
+ outputSchema?: object;
5232
+ };
5233
+ metricsConfig?: object;
5234
+ }
5235
+
4996
5236
  /**
4997
5237
  * Base Execution Engine type definitions
4998
5238
  * Core types shared across all Execution Engine resources
@@ -5345,7 +5585,6 @@ interface CommandViewAgent extends ResourceDefinition {
5345
5585
  modelProvider: string;
5346
5586
  modelId: string;
5347
5587
  toolCount: number;
5348
- hasKnowledgeMap: boolean;
5349
5588
  hasMemory: boolean;
5350
5589
  sessionCapable: boolean;
5351
5590
  }