@elevasis/sdk 1.23.0 → 1.25.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 (55) hide show
  1. package/dist/cli.cjs +5927 -6985
  2. package/dist/index.d.ts +4893 -4759
  3. package/dist/index.js +1444 -3870
  4. package/dist/node/index.d.ts +3059 -2
  5. package/dist/node/index.js +163 -1
  6. package/dist/test-utils/index.d.ts +4413 -4439
  7. package/dist/test-utils/index.js +1766 -4753
  8. package/dist/types/worker/index.d.ts +5 -2
  9. package/dist/types/worker/platform.d.ts +2 -2
  10. package/dist/types/worker/utils.d.ts +9 -0
  11. package/dist/worker/index.js +427 -3708
  12. package/package.json +5 -4
  13. package/reference/_navigation.md +1 -0
  14. package/reference/claude-config/rules/active-change-index.md +11 -80
  15. package/reference/claude-config/rules/agent-start-here.md +11 -277
  16. package/reference/claude-config/rules/deployment.md +11 -57
  17. package/reference/claude-config/rules/error-handling.md +11 -56
  18. package/reference/claude-config/rules/execution.md +11 -40
  19. package/reference/claude-config/rules/frontend.md +11 -43
  20. package/reference/claude-config/rules/observability.md +11 -31
  21. package/reference/claude-config/rules/operations.md +11 -80
  22. package/reference/claude-config/rules/organization-model.md +5 -110
  23. package/reference/claude-config/rules/organization-os.md +7 -111
  24. package/reference/claude-config/rules/package-taxonomy.md +11 -33
  25. package/reference/claude-config/rules/platform.md +11 -42
  26. package/reference/claude-config/rules/shared-types.md +10 -48
  27. package/reference/claude-config/rules/task-tracking.md +11 -47
  28. package/reference/claude-config/rules/ui.md +11 -200
  29. package/reference/claude-config/rules/vibe.md +5 -229
  30. package/reference/claude-config/sync-notes/2026-05-04-knowledge-bundle.md +83 -83
  31. package/reference/claude-config/sync-notes/2026-05-15-om-skill-rename-and-write-family.md +2 -2
  32. package/reference/claude-config/sync-notes/2026-05-17-sdk-boundary-consolidation.md +33 -0
  33. package/reference/cli.mdx +1107 -808
  34. package/reference/rules/active-change-index.md +83 -0
  35. package/reference/rules/agent-start-here.md +280 -0
  36. package/reference/rules/deployment.md +60 -0
  37. package/reference/rules/error-handling.md +59 -0
  38. package/reference/rules/execution.md +43 -0
  39. package/reference/rules/frontend.md +46 -0
  40. package/reference/rules/observability.md +34 -0
  41. package/reference/rules/operations.md +85 -0
  42. package/reference/rules/organization-model.md +119 -0
  43. package/reference/rules/organization-os.md +118 -0
  44. package/reference/rules/package-taxonomy.md +36 -0
  45. package/reference/rules/platform.md +45 -0
  46. package/reference/rules/shared-types.md +52 -0
  47. package/reference/rules/task-tracking.md +50 -0
  48. package/reference/rules/ui.md +203 -0
  49. package/reference/rules/vibe.md +238 -0
  50. package/reference/scaffold/core/organization-graph.mdx +4 -5
  51. package/reference/scaffold/core/organization-model.mdx +1 -1
  52. package/reference/scaffold/recipes/customize-crm-actions.md +45 -46
  53. package/reference/scaffold/recipes/extend-crm.md +253 -255
  54. package/reference/scaffold/recipes/index.md +43 -44
  55. package/reference/scaffold/reference/contracts.md +990 -1065
@@ -1,3 +1,5 @@
1
+ import { z } from 'zod';
2
+
1
3
  type KnowledgeKind = 'playbook' | 'strategy' | 'reference';
2
4
  interface KnowledgeCodegenNode {
3
5
  id: string;
@@ -35,6 +37,2980 @@ declare function generateKnowledgeNodesTs(options: {
35
37
  }): string;
36
38
  declare function generateKnowledgeNodes(options: GenerateKnowledgeNodesOptions): GenerateKnowledgeNodesResult;
37
39
 
40
+ /**
41
+ * Workflow-specific logging types and utilities
42
+ */
43
+
44
+ interface WorkflowExecutionContext {
45
+ type: 'workflow';
46
+ contextType: 'workflow-execution';
47
+ executionId: string;
48
+ workflowId: string;
49
+ workflowName?: string;
50
+ organizationId: string;
51
+ executionPath?: string[];
52
+ }
53
+ interface WorkflowFailureContext {
54
+ type: 'workflow';
55
+ contextType: 'workflow-failure';
56
+ executionId: string;
57
+ workflowId: string;
58
+ error: string;
59
+ }
60
+ interface StepStartedContext {
61
+ type: 'workflow';
62
+ contextType: 'step-started';
63
+ stepId: string;
64
+ stepStatus: 'started';
65
+ input: unknown;
66
+ startTime: number;
67
+ }
68
+ interface StepCompletedContext {
69
+ type: 'workflow';
70
+ contextType: 'step-completed';
71
+ stepId: string;
72
+ stepStatus: 'completed';
73
+ output: unknown;
74
+ duration: number;
75
+ isTerminal: boolean;
76
+ startTime: number;
77
+ endTime: number;
78
+ }
79
+ interface StepFailedContext {
80
+ type: 'workflow';
81
+ contextType: 'step-failed';
82
+ stepId: string;
83
+ stepStatus: 'failed';
84
+ error: string;
85
+ duration: number;
86
+ startTime: number;
87
+ endTime: number;
88
+ }
89
+ interface ConditionalRouteContext {
90
+ type: 'workflow';
91
+ contextType: 'conditional-route';
92
+ stepId: string;
93
+ target: string;
94
+ error?: string;
95
+ }
96
+ interface ExecutionPathContext {
97
+ type: 'workflow';
98
+ contextType: 'execution-path';
99
+ executionPath: string[];
100
+ }
101
+ type WorkflowLogContext = WorkflowExecutionContext | WorkflowFailureContext | StepStartedContext | StepCompletedContext | StepFailedContext | ConditionalRouteContext | ExecutionPathContext;
102
+
103
+ /**
104
+ * Agent-specific logging types
105
+ * Simplified 2-event model: lifecycle, iteration
106
+ *
107
+ * Design Philosophy:
108
+ * - LIFECYCLE EVENTS: Structural checkpoints (initialization, iteration, completion)
109
+ * - ITERATION EVENTS: Execution activities (reasoning, actions during iterations)
110
+ */
111
+
112
+ /**
113
+ * Agent lifecycle stages
114
+ * Universal checkpoints that apply to all agent executions
115
+ */
116
+ type AgentLifecycle = 'initialization' | 'iteration' | 'completion';
117
+ /**
118
+ * Iteration event types
119
+ * Activities that occur during agent iterations
120
+ */
121
+ type IterationEventType = 'reasoning' | 'action' | 'tool-call';
122
+ /**
123
+ * Base fields shared by all lifecycle events
124
+ */
125
+ interface AgentLifecycleEventBase {
126
+ type: 'agent';
127
+ agentId: string;
128
+ lifecycle: AgentLifecycle;
129
+ sessionId?: string;
130
+ }
131
+ /**
132
+ * Lifecycle started event - emitted when a phase begins
133
+ * REQUIRED: startTime (phase has started, no end yet)
134
+ */
135
+ interface AgentLifecycleStartedEvent extends AgentLifecycleEventBase {
136
+ stage: 'started';
137
+ startTime: number;
138
+ iteration?: number;
139
+ }
140
+ /**
141
+ * Lifecycle completed event - emitted when a phase succeeds
142
+ * REQUIRED: startTime, endTime, duration (phase has finished successfully)
143
+ */
144
+ interface AgentLifecycleCompletedEvent extends AgentLifecycleEventBase {
145
+ stage: 'completed';
146
+ startTime: number;
147
+ endTime: number;
148
+ duration: number;
149
+ iteration?: number;
150
+ attempts?: number;
151
+ memorySize?: {
152
+ sessionMemoryKeys: number;
153
+ historyEntries: number;
154
+ };
155
+ }
156
+ /**
157
+ * Lifecycle failed event - emitted when a phase fails
158
+ * REQUIRED: startTime, endTime, duration, error (phase has finished with error)
159
+ */
160
+ interface AgentLifecycleFailedEvent extends AgentLifecycleEventBase {
161
+ stage: 'failed';
162
+ startTime: number;
163
+ endTime: number;
164
+ duration: number;
165
+ error: string;
166
+ iteration?: number;
167
+ }
168
+ /**
169
+ * Union type for all lifecycle events
170
+ * Discriminated by 'stage' field for type narrowing
171
+ */
172
+ type AgentLifecycleEvent = AgentLifecycleStartedEvent | AgentLifecycleCompletedEvent | AgentLifecycleFailedEvent;
173
+ /**
174
+ * Placeholder data for MVP
175
+ * Will be typed per actionType in future
176
+ */
177
+ interface ActionPlaceholderData {
178
+ message: string;
179
+ }
180
+ /**
181
+ * Iteration event - captures activities during agent iterations
182
+ * Consolidates reasoning (LLM thought process) and actions (tool use, memory ops, etc.)
183
+ */
184
+ interface AgentIterationEvent {
185
+ type: 'agent';
186
+ agentId: string;
187
+ lifecycle: 'iteration';
188
+ eventType: IterationEventType;
189
+ iteration: number;
190
+ sessionId?: string;
191
+ startTime: number;
192
+ endTime: number;
193
+ duration: number;
194
+ output?: string;
195
+ actionType?: string;
196
+ data?: ActionPlaceholderData;
197
+ }
198
+ /**
199
+ * Tool call event - captures individual tool executions during iterations
200
+ * Provides granular timing for each tool invocation
201
+ */
202
+ interface AgentToolCallEvent {
203
+ type: 'agent';
204
+ agentId: string;
205
+ lifecycle: 'iteration';
206
+ eventType: 'tool-call';
207
+ iteration: number;
208
+ sessionId?: string;
209
+ toolName: string;
210
+ startTime: number;
211
+ endTime: number;
212
+ duration: number;
213
+ success: boolean;
214
+ error?: string;
215
+ input?: Record<string, unknown>;
216
+ output?: unknown;
217
+ }
218
+ /**
219
+ * Union type for all agent log contexts
220
+ * 3 event types total (lifecycle, iteration, tool-call)
221
+ */
222
+ type AgentLogContext = AgentLifecycleEvent | AgentIterationEvent | AgentToolCallEvent;
223
+ /**
224
+ * Data for lifecycle 'started' events
225
+ */
226
+ interface AgentLifecycleStartedData {
227
+ startTime: number;
228
+ iteration?: number;
229
+ }
230
+ /**
231
+ * Data for lifecycle 'completed' events
232
+ */
233
+ interface AgentLifecycleCompletedData {
234
+ startTime: number;
235
+ endTime: number;
236
+ duration: number;
237
+ iteration?: number;
238
+ attempts?: number;
239
+ memorySize?: {
240
+ sessionMemoryKeys: number;
241
+ historyEntries: number;
242
+ };
243
+ }
244
+ /**
245
+ * Data for lifecycle 'failed' events
246
+ */
247
+ interface AgentLifecycleFailedData {
248
+ startTime: number;
249
+ endTime: number;
250
+ duration: number;
251
+ error: string;
252
+ iteration?: number;
253
+ }
254
+ /**
255
+ * Scoped logger for agent execution
256
+ * Captures logger and agentId to eliminate repetitive parameter passing
257
+ *
258
+ * Type-safe lifecycle logging with stage-specific required fields
259
+ */
260
+ interface AgentScopedLogger {
261
+ lifecycle(lifecycle: AgentLifecycle, stage: 'started', data: AgentLifecycleStartedData): void;
262
+ lifecycle(lifecycle: AgentLifecycle, stage: 'completed', data: AgentLifecycleCompletedData): void;
263
+ lifecycle(lifecycle: AgentLifecycle, stage: 'failed', data: AgentLifecycleFailedData): void;
264
+ reasoning(output: string, iteration: number, startTime: number, endTime: number, duration: number): void;
265
+ action(actionType: string, message: string, iteration: number, startTime: number, endTime: number, duration: number): void;
266
+ toolCall(toolName: string, iteration: number, startTime: number, endTime: number, duration: number, success: boolean, error?: string, input?: unknown, output?: unknown): void;
267
+ }
268
+
269
+ type LogContext = WorkflowLogContext | AgentLogContext;
270
+ interface IExecutionLogger {
271
+ debug(message: string, context?: LogContext): void;
272
+ info(message: string, context?: LogContext): void;
273
+ warn(message: string, context?: LogContext): void;
274
+ error(message: string, context?: LogContext): void;
275
+ }
276
+
277
+ /**
278
+ * Model Configuration
279
+ * Centralized model information, configuration, options, constraints, and validation
280
+ * Single source of truth for all model-related definitions
281
+ * Update manually when pricing changes or new models are added
282
+ */
283
+
284
+ /**
285
+ * Supported Open AI models (direct SDK access)
286
+ */
287
+ type OpenAIModel = 'gpt-5' | 'gpt-5.4-mini' | 'gpt-5.4-nano';
288
+ /**
289
+ * Supported OpenRouter models (explicit union for type safety)
290
+ */
291
+ type OpenRouterModel = 'openrouter/z-ai/glm-5';
292
+ /**
293
+ * Supported Google models (direct SDK access)
294
+ */
295
+ type GoogleModel = 'gemini-3-flash-preview' | 'gemini-3.1-flash-lite-preview';
296
+ /**
297
+ * Supported Anthropic models (direct SDK access via @anthropic-ai/sdk)
298
+ */
299
+ type AnthropicModel = 'claude-sonnet-4-5';
300
+ /** Supported LLM models */
301
+ type LLMModel = OpenAIModel | OpenRouterModel | GoogleModel | AnthropicModel | 'mock';
302
+ /**
303
+ * GPT-5 model options schema
304
+ */
305
+ declare const GPT5OptionsSchema: z.ZodObject<{
306
+ reasoning_effort: z.ZodOptional<z.ZodEnum<{
307
+ minimal: "minimal";
308
+ low: "low";
309
+ medium: "medium";
310
+ high: "high";
311
+ }>>;
312
+ verbosity: z.ZodOptional<z.ZodEnum<{
313
+ low: "low";
314
+ medium: "medium";
315
+ high: "high";
316
+ }>>;
317
+ }, z.core.$strip>;
318
+ /**
319
+ * OpenRouter model options schema
320
+ * OpenRouter-specific options for routing and transforms
321
+ */
322
+ declare const OpenRouterOptionsSchema: z.ZodObject<{
323
+ transforms: z.ZodOptional<z.ZodArray<z.ZodString>>;
324
+ route: z.ZodOptional<z.ZodEnum<{
325
+ fallback: "fallback";
326
+ }>>;
327
+ }, z.core.$strip>;
328
+ /**
329
+ * Google model options schema
330
+ * Gemini 3 specific options for thinking depth control
331
+ */
332
+ declare const GoogleOptionsSchema: z.ZodObject<{
333
+ thinkingLevel: z.ZodOptional<z.ZodEnum<{
334
+ minimal: "minimal";
335
+ low: "low";
336
+ medium: "medium";
337
+ high: "high";
338
+ }>>;
339
+ }, z.core.$strip>;
340
+ /**
341
+ * Anthropic model options schema
342
+ * Currently empty - future options: budget_tokens for extended thinking
343
+ */
344
+ declare const AnthropicOptionsSchema: z.ZodObject<{}, z.core.$strip>;
345
+ /**
346
+ * Infer TypeScript types from schemas
347
+ */
348
+ type GPT5Options = z.infer<typeof GPT5OptionsSchema>;
349
+ type MockOptions = Record<string, never>;
350
+ type OpenRouterOptions = z.infer<typeof OpenRouterOptionsSchema>;
351
+ type GoogleOptions = z.infer<typeof GoogleOptionsSchema>;
352
+ type AnthropicOptions = z.infer<typeof AnthropicOptionsSchema>;
353
+ type ModelSpecificOptions = GPT5Options | MockOptions | OpenRouterOptions | GoogleOptions | AnthropicOptions;
354
+ /**
355
+ * Model configuration for LLM execution
356
+ * Belongs in resource definition (AgentDefinition, WorkflowDefinition, etc.)
357
+ */
358
+ interface ModelConfig {
359
+ model: LLMModel;
360
+ provider: 'openai' | 'anthropic' | 'openrouter' | 'google' | 'mock';
361
+ apiKey: string;
362
+ temperature?: number;
363
+ /** Maximum output tokens per LLM call. NOT the model's context window — see ModelInfo.maxTokens for that. */
364
+ maxOutputTokens?: number;
365
+ topP?: number;
366
+ /**
367
+ * Model-specific options (flat structure)
368
+ * Options are model-specific, not vendor-specific
369
+ * Available options defined in MODEL_INFO per model
370
+ * Validated at build time via validateModelOptions()
371
+ */
372
+ modelOptions?: ModelSpecificOptions;
373
+ }
374
+
375
+ declare const ResourceGovernanceStatusSchema: z.ZodEnum<{
376
+ deprecated: "deprecated";
377
+ active: "active";
378
+ archived: "archived";
379
+ }>;
380
+ declare const WorkflowResourceEntrySchema$1: z.ZodObject<{
381
+ id: z.ZodString;
382
+ order: z.ZodDefault<z.ZodNumber>;
383
+ systemPath: z.ZodString;
384
+ title: z.ZodOptional<z.ZodString>;
385
+ description: z.ZodOptional<z.ZodString>;
386
+ ownerRoleId: z.ZodOptional<z.ZodString>;
387
+ status: z.ZodEnum<{
388
+ deprecated: "deprecated";
389
+ active: "active";
390
+ archived: "archived";
391
+ }>;
392
+ ontology: z.ZodOptional<z.ZodObject<{
393
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
394
+ primaryAction: z.ZodOptional<z.ZodString>;
395
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
396
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
397
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
398
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
399
+ contract: z.ZodOptional<z.ZodObject<{
400
+ input: z.ZodOptional<z.ZodString>;
401
+ output: z.ZodOptional<z.ZodString>;
402
+ }, z.core.$strip>>;
403
+ }, z.core.$strip>>;
404
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
405
+ path: z.ZodString;
406
+ role: z.ZodEnum<{
407
+ config: "config";
408
+ entrypoint: "entrypoint";
409
+ handler: "handler";
410
+ schema: "schema";
411
+ test: "test";
412
+ docs: "docs";
413
+ }>;
414
+ symbol: z.ZodOptional<z.ZodString>;
415
+ description: z.ZodOptional<z.ZodString>;
416
+ }, z.core.$strip>>>;
417
+ kind: z.ZodLiteral<"workflow">;
418
+ emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
419
+ eventKey: z.ZodString;
420
+ label: z.ZodString;
421
+ payloadSchema: z.ZodOptional<z.ZodString>;
422
+ lifecycle: z.ZodOptional<z.ZodEnum<{
423
+ deprecated: "deprecated";
424
+ draft: "draft";
425
+ beta: "beta";
426
+ active: "active";
427
+ archived: "archived";
428
+ }>>;
429
+ }, z.core.$strip>>>;
430
+ }, z.core.$strip>;
431
+ declare const AgentResourceEntrySchema: z.ZodObject<{
432
+ id: z.ZodString;
433
+ order: z.ZodDefault<z.ZodNumber>;
434
+ systemPath: z.ZodString;
435
+ title: z.ZodOptional<z.ZodString>;
436
+ description: z.ZodOptional<z.ZodString>;
437
+ ownerRoleId: z.ZodOptional<z.ZodString>;
438
+ status: z.ZodEnum<{
439
+ deprecated: "deprecated";
440
+ active: "active";
441
+ archived: "archived";
442
+ }>;
443
+ ontology: z.ZodOptional<z.ZodObject<{
444
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
445
+ primaryAction: z.ZodOptional<z.ZodString>;
446
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
447
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
448
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
449
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
450
+ contract: z.ZodOptional<z.ZodObject<{
451
+ input: z.ZodOptional<z.ZodString>;
452
+ output: z.ZodOptional<z.ZodString>;
453
+ }, z.core.$strip>>;
454
+ }, z.core.$strip>>;
455
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
456
+ path: z.ZodString;
457
+ role: z.ZodEnum<{
458
+ config: "config";
459
+ entrypoint: "entrypoint";
460
+ handler: "handler";
461
+ schema: "schema";
462
+ test: "test";
463
+ docs: "docs";
464
+ }>;
465
+ symbol: z.ZodOptional<z.ZodString>;
466
+ description: z.ZodOptional<z.ZodString>;
467
+ }, z.core.$strip>>>;
468
+ kind: z.ZodLiteral<"agent">;
469
+ agentKind: z.ZodEnum<{
470
+ platform: "platform";
471
+ orchestrator: "orchestrator";
472
+ specialist: "specialist";
473
+ utility: "utility";
474
+ }>;
475
+ actsAsRoleId: z.ZodOptional<z.ZodString>;
476
+ sessionCapable: z.ZodBoolean;
477
+ invocations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
478
+ kind: z.ZodLiteral<"slash-command">;
479
+ command: z.ZodString;
480
+ toolFactory: z.ZodOptional<z.ZodString>;
481
+ }, z.core.$strip>, z.ZodObject<{
482
+ kind: z.ZodLiteral<"mcp-tool">;
483
+ server: z.ZodString;
484
+ name: z.ZodString;
485
+ }, z.core.$strip>, z.ZodObject<{
486
+ kind: z.ZodLiteral<"api-endpoint">;
487
+ method: z.ZodEnum<{
488
+ GET: "GET";
489
+ POST: "POST";
490
+ PATCH: "PATCH";
491
+ DELETE: "DELETE";
492
+ }>;
493
+ path: z.ZodString;
494
+ requestSchema: z.ZodOptional<z.ZodString>;
495
+ responseSchema: z.ZodOptional<z.ZodString>;
496
+ }, z.core.$strip>, z.ZodObject<{
497
+ kind: z.ZodLiteral<"script-execution">;
498
+ resourceId: z.ZodString;
499
+ }, z.core.$strip>], "kind">>>;
500
+ emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
501
+ eventKey: z.ZodString;
502
+ label: z.ZodString;
503
+ payloadSchema: z.ZodOptional<z.ZodString>;
504
+ lifecycle: z.ZodOptional<z.ZodEnum<{
505
+ deprecated: "deprecated";
506
+ draft: "draft";
507
+ beta: "beta";
508
+ active: "active";
509
+ archived: "archived";
510
+ }>>;
511
+ }, z.core.$strip>>>;
512
+ }, z.core.$strip>;
513
+ declare const ResourceEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
514
+ id: z.ZodString;
515
+ order: z.ZodDefault<z.ZodNumber>;
516
+ systemPath: z.ZodString;
517
+ title: z.ZodOptional<z.ZodString>;
518
+ description: z.ZodOptional<z.ZodString>;
519
+ ownerRoleId: z.ZodOptional<z.ZodString>;
520
+ status: z.ZodEnum<{
521
+ deprecated: "deprecated";
522
+ active: "active";
523
+ archived: "archived";
524
+ }>;
525
+ ontology: z.ZodOptional<z.ZodObject<{
526
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
527
+ primaryAction: z.ZodOptional<z.ZodString>;
528
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
529
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
530
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
531
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
532
+ contract: z.ZodOptional<z.ZodObject<{
533
+ input: z.ZodOptional<z.ZodString>;
534
+ output: z.ZodOptional<z.ZodString>;
535
+ }, z.core.$strip>>;
536
+ }, z.core.$strip>>;
537
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
538
+ path: z.ZodString;
539
+ role: z.ZodEnum<{
540
+ config: "config";
541
+ entrypoint: "entrypoint";
542
+ handler: "handler";
543
+ schema: "schema";
544
+ test: "test";
545
+ docs: "docs";
546
+ }>;
547
+ symbol: z.ZodOptional<z.ZodString>;
548
+ description: z.ZodOptional<z.ZodString>;
549
+ }, z.core.$strip>>>;
550
+ kind: z.ZodLiteral<"workflow">;
551
+ emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
552
+ eventKey: z.ZodString;
553
+ label: z.ZodString;
554
+ payloadSchema: z.ZodOptional<z.ZodString>;
555
+ lifecycle: z.ZodOptional<z.ZodEnum<{
556
+ deprecated: "deprecated";
557
+ draft: "draft";
558
+ beta: "beta";
559
+ active: "active";
560
+ archived: "archived";
561
+ }>>;
562
+ }, z.core.$strip>>>;
563
+ }, z.core.$strip>, z.ZodObject<{
564
+ id: z.ZodString;
565
+ order: z.ZodDefault<z.ZodNumber>;
566
+ systemPath: z.ZodString;
567
+ title: z.ZodOptional<z.ZodString>;
568
+ description: z.ZodOptional<z.ZodString>;
569
+ ownerRoleId: z.ZodOptional<z.ZodString>;
570
+ status: z.ZodEnum<{
571
+ deprecated: "deprecated";
572
+ active: "active";
573
+ archived: "archived";
574
+ }>;
575
+ ontology: z.ZodOptional<z.ZodObject<{
576
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
577
+ primaryAction: z.ZodOptional<z.ZodString>;
578
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
579
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
580
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
581
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
582
+ contract: z.ZodOptional<z.ZodObject<{
583
+ input: z.ZodOptional<z.ZodString>;
584
+ output: z.ZodOptional<z.ZodString>;
585
+ }, z.core.$strip>>;
586
+ }, z.core.$strip>>;
587
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
588
+ path: z.ZodString;
589
+ role: z.ZodEnum<{
590
+ config: "config";
591
+ entrypoint: "entrypoint";
592
+ handler: "handler";
593
+ schema: "schema";
594
+ test: "test";
595
+ docs: "docs";
596
+ }>;
597
+ symbol: z.ZodOptional<z.ZodString>;
598
+ description: z.ZodOptional<z.ZodString>;
599
+ }, z.core.$strip>>>;
600
+ kind: z.ZodLiteral<"agent">;
601
+ agentKind: z.ZodEnum<{
602
+ platform: "platform";
603
+ orchestrator: "orchestrator";
604
+ specialist: "specialist";
605
+ utility: "utility";
606
+ }>;
607
+ actsAsRoleId: z.ZodOptional<z.ZodString>;
608
+ sessionCapable: z.ZodBoolean;
609
+ invocations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
610
+ kind: z.ZodLiteral<"slash-command">;
611
+ command: z.ZodString;
612
+ toolFactory: z.ZodOptional<z.ZodString>;
613
+ }, z.core.$strip>, z.ZodObject<{
614
+ kind: z.ZodLiteral<"mcp-tool">;
615
+ server: z.ZodString;
616
+ name: z.ZodString;
617
+ }, z.core.$strip>, z.ZodObject<{
618
+ kind: z.ZodLiteral<"api-endpoint">;
619
+ method: z.ZodEnum<{
620
+ GET: "GET";
621
+ POST: "POST";
622
+ PATCH: "PATCH";
623
+ DELETE: "DELETE";
624
+ }>;
625
+ path: z.ZodString;
626
+ requestSchema: z.ZodOptional<z.ZodString>;
627
+ responseSchema: z.ZodOptional<z.ZodString>;
628
+ }, z.core.$strip>, z.ZodObject<{
629
+ kind: z.ZodLiteral<"script-execution">;
630
+ resourceId: z.ZodString;
631
+ }, z.core.$strip>], "kind">>>;
632
+ emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
633
+ eventKey: z.ZodString;
634
+ label: z.ZodString;
635
+ payloadSchema: z.ZodOptional<z.ZodString>;
636
+ lifecycle: z.ZodOptional<z.ZodEnum<{
637
+ deprecated: "deprecated";
638
+ draft: "draft";
639
+ beta: "beta";
640
+ active: "active";
641
+ archived: "archived";
642
+ }>>;
643
+ }, z.core.$strip>>>;
644
+ }, z.core.$strip>, z.ZodObject<{
645
+ id: z.ZodString;
646
+ order: z.ZodDefault<z.ZodNumber>;
647
+ systemPath: z.ZodString;
648
+ title: z.ZodOptional<z.ZodString>;
649
+ description: z.ZodOptional<z.ZodString>;
650
+ ownerRoleId: z.ZodOptional<z.ZodString>;
651
+ status: z.ZodEnum<{
652
+ deprecated: "deprecated";
653
+ active: "active";
654
+ archived: "archived";
655
+ }>;
656
+ ontology: z.ZodOptional<z.ZodObject<{
657
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
658
+ primaryAction: z.ZodOptional<z.ZodString>;
659
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
660
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
661
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
662
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
663
+ contract: z.ZodOptional<z.ZodObject<{
664
+ input: z.ZodOptional<z.ZodString>;
665
+ output: z.ZodOptional<z.ZodString>;
666
+ }, z.core.$strip>>;
667
+ }, z.core.$strip>>;
668
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
669
+ path: z.ZodString;
670
+ role: z.ZodEnum<{
671
+ config: "config";
672
+ entrypoint: "entrypoint";
673
+ handler: "handler";
674
+ schema: "schema";
675
+ test: "test";
676
+ docs: "docs";
677
+ }>;
678
+ symbol: z.ZodOptional<z.ZodString>;
679
+ description: z.ZodOptional<z.ZodString>;
680
+ }, z.core.$strip>>>;
681
+ kind: z.ZodLiteral<"integration">;
682
+ provider: z.ZodString;
683
+ }, z.core.$strip>, z.ZodObject<{
684
+ id: z.ZodString;
685
+ order: z.ZodDefault<z.ZodNumber>;
686
+ systemPath: z.ZodString;
687
+ title: z.ZodOptional<z.ZodString>;
688
+ description: z.ZodOptional<z.ZodString>;
689
+ ownerRoleId: z.ZodOptional<z.ZodString>;
690
+ status: z.ZodEnum<{
691
+ deprecated: "deprecated";
692
+ active: "active";
693
+ archived: "archived";
694
+ }>;
695
+ ontology: z.ZodOptional<z.ZodObject<{
696
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
697
+ primaryAction: z.ZodOptional<z.ZodString>;
698
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
699
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
700
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
701
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
702
+ contract: z.ZodOptional<z.ZodObject<{
703
+ input: z.ZodOptional<z.ZodString>;
704
+ output: z.ZodOptional<z.ZodString>;
705
+ }, z.core.$strip>>;
706
+ }, z.core.$strip>>;
707
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
708
+ path: z.ZodString;
709
+ role: z.ZodEnum<{
710
+ config: "config";
711
+ entrypoint: "entrypoint";
712
+ handler: "handler";
713
+ schema: "schema";
714
+ test: "test";
715
+ docs: "docs";
716
+ }>;
717
+ symbol: z.ZodOptional<z.ZodString>;
718
+ description: z.ZodOptional<z.ZodString>;
719
+ }, z.core.$strip>>>;
720
+ kind: z.ZodLiteral<"script">;
721
+ language: z.ZodEnum<{
722
+ shell: "shell";
723
+ sql: "sql";
724
+ typescript: "typescript";
725
+ python: "python";
726
+ }>;
727
+ source: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
728
+ file: z.ZodString;
729
+ }, z.core.$strip>]>;
730
+ }, z.core.$strip>], "kind">;
731
+ type ResourceGovernanceStatus = z.infer<typeof ResourceGovernanceStatusSchema>;
732
+ type WorkflowResourceEntry = z.infer<typeof WorkflowResourceEntrySchema$1>;
733
+ type AgentResourceEntry = z.infer<typeof AgentResourceEntrySchema>;
734
+ type ResourceEntry = z.infer<typeof ResourceEntrySchema>;
735
+
736
+ /**
737
+ * Shared form field types for dynamic form generation
738
+ * Used by: Command Queue, Execution Runner UI, future form-based features
739
+ */
740
+ /**
741
+ * Supported form field types for action payloads
742
+ * Maps to Mantine form components
743
+ */
744
+ type FormFieldType = 'text' | 'textarea' | 'number' | 'select' | 'checkbox' | 'radio' | 'richtext';
745
+ /**
746
+ * Form field definition
747
+ */
748
+ interface FormField {
749
+ /** Field key in payload object */
750
+ name: string;
751
+ /** Field label for UI */
752
+ label: string;
753
+ /** Field type (determines UI component) */
754
+ type: FormFieldType;
755
+ /** Default value */
756
+ defaultValue?: unknown;
757
+ /** Required field */
758
+ required?: boolean;
759
+ /** Placeholder text */
760
+ placeholder?: string;
761
+ /** Help text */
762
+ description?: string;
763
+ /** Options for select/radio */
764
+ options?: Array<{
765
+ label: string;
766
+ value: string | number;
767
+ }>;
768
+ /** Min/max for number */
769
+ min?: number;
770
+ max?: number;
771
+ /** Path to context value for pre-filling (dot notation, e.g., 'proposal.summary') */
772
+ defaultValueFromContext?: string;
773
+ }
774
+ /**
775
+ * Form schema for action payload collection
776
+ */
777
+ interface FormSchema {
778
+ /** Form title */
779
+ title?: string;
780
+ /** Form description */
781
+ description?: string;
782
+ /** Form fields */
783
+ fields: FormField[];
784
+ }
785
+
786
+ /**
787
+ * Execution interface configuration
788
+ * Defines how a resource is executed via the UI (forms, scheduling, webhooks)
789
+ * Applies to both agents and workflows
790
+ */
791
+ interface ExecutionInterface {
792
+ /** Form configuration for execution inputs */
793
+ form: ExecutionFormSchema;
794
+ /** Optional: Schedule configuration */
795
+ schedule?: ScheduleConfig;
796
+ /** Optional: Webhook trigger configuration */
797
+ webhook?: WebhookConfig;
798
+ }
799
+ /**
800
+ * Execution form schema
801
+ * Extends FormSchema with execution-specific fields
802
+ */
803
+ interface ExecutionFormSchema extends FormSchema {
804
+ /**
805
+ * Field mappings to resource input schema
806
+ * Maps form field names to contract input paths
807
+ * If omitted, field names must match contract input keys exactly
808
+ */
809
+ fieldMappings?: Record<string, string>;
810
+ /**
811
+ * Submit button configuration
812
+ * Default: { label: 'Run', loadingLabel: 'Running...' }
813
+ */
814
+ submitButton?: {
815
+ label?: string;
816
+ loadingLabel?: string;
817
+ confirmMessage?: string;
818
+ };
819
+ }
820
+ /**
821
+ * Schedule configuration for automated execution
822
+ */
823
+ interface ScheduleConfig {
824
+ /** Whether scheduling is enabled for this resource */
825
+ enabled: boolean;
826
+ /** Default schedule (cron expression) */
827
+ defaultSchedule?: string;
828
+ /** Allowed schedule patterns (if restricted) */
829
+ allowedPatterns?: string[];
830
+ }
831
+ /**
832
+ * Webhook configuration for external triggers
833
+ */
834
+ interface WebhookConfig {
835
+ /** Whether webhook trigger is enabled */
836
+ enabled: boolean;
837
+ /** Expected payload schema (for documentation) */
838
+ payloadSchema?: unknown;
839
+ }
840
+
841
+ interface WorkflowConfig extends ResourceDefinition {
842
+ type: 'workflow';
843
+ /** OM descriptor backing canonical identity and governance metadata. */
844
+ resource?: WorkflowResourceEntry;
845
+ }
846
+ interface WorkflowStepDefinition {
847
+ id: string;
848
+ name: string;
849
+ description: string;
850
+ }
851
+ type StepHandler = (input: unknown, context: ExecutionContext) => Promise<unknown>;
852
+ interface LinearNext {
853
+ type: 'linear';
854
+ target: string;
855
+ }
856
+ interface ConditionalNext {
857
+ type: 'conditional';
858
+ routes: Array<{
859
+ condition: (data: unknown) => boolean;
860
+ target: string;
861
+ }>;
862
+ default: string;
863
+ }
864
+ type NextConfig = LinearNext | ConditionalNext | null;
865
+ interface WorkflowStep extends WorkflowStepDefinition {
866
+ handler: StepHandler;
867
+ inputSchema: z.ZodSchema;
868
+ outputSchema: z.ZodSchema;
869
+ next: NextConfig;
870
+ }
871
+ interface WorkflowDefinition {
872
+ config: WorkflowConfig;
873
+ contract: Contract;
874
+ steps: Record<string, WorkflowStep>;
875
+ entryPoint: string;
876
+ /**
877
+ * Metrics configuration for ROI calculations
878
+ * Optional: Only needed if tracking automation savings
879
+ */
880
+ metricsConfig?: ResourceMetricsConfig;
881
+ /**
882
+ * Execution interface configuration (optional)
883
+ * If provided, workflow appears in Execution Runner UI
884
+ */
885
+ interface?: ExecutionInterface;
886
+ /**
887
+ * Lead-gen processing stage this workflow implements (optional).
888
+ * Must match a key in the platform lead-gen stage catalog.
889
+ * Used by org-os graph derivation to surface workflow→stage edges and
890
+ * by pipeline_config validation to confirm each catalog stage has an
891
+ * implementing workflow before a list is activated.
892
+ *
893
+ * Example: stageImplemented: 'verified' on the email-verification workflow.
894
+ */
895
+ stageImplemented?: string;
896
+ }
897
+
898
+ /**
899
+ * Generic LLM Types
900
+ * Universal interfaces for LLM interaction across all resource types
901
+ */
902
+ /**
903
+ * Standard chat message format
904
+ * Compatible with OpenAI, Anthropic, and other providers
905
+ */
906
+ interface LLMMessage {
907
+ role: 'system' | 'user' | 'assistant';
908
+ content: string;
909
+ }
910
+ /**
911
+ * Generic LLM generation request
912
+ * Usable by agents, workflows, tools, etc.
913
+ */
914
+ interface LLMGenerateRequest {
915
+ messages: LLMMessage[];
916
+ responseSchema: unknown;
917
+ /** Maximum output tokens per LLM call. NOT the model's context window — see ModelInfo.maxTokens for that. */
918
+ maxOutputTokens?: number;
919
+ temperature?: number;
920
+ topP?: number;
921
+ signal?: AbortSignal;
922
+ }
923
+ /**
924
+ * Generic LLM generation response
925
+ * Usage field is internal-only (stripped by UniversalLLMAdapter wrapper)
926
+ */
927
+ interface LLMGenerateResponse<T = unknown> {
928
+ output: T;
929
+ usage?: {
930
+ inputTokens: number;
931
+ outputTokens: number;
932
+ totalTokens: number;
933
+ };
934
+ cost?: number;
935
+ }
936
+ /**
937
+ * LLM Adapter interface
938
+ * Generic primitive for all resource types (agents, workflows, tools)
939
+ *
940
+ * Design principles:
941
+ * - Single method: generate() - the core LLM primitive
942
+ * - Generic return type for type safety
943
+ * - Universal format (not agent-specific)
944
+ * - Standard message-based input (OpenAI-compatible)
945
+ */
946
+ interface LLMAdapter {
947
+ /**
948
+ * Generate structured output from prompt using LLM
949
+ *
950
+ * @param request - Generation request with messages and response schema
951
+ * @returns Generated output (typed) with optional usage metadata
952
+ */
953
+ generate<T = unknown>(request: LLMGenerateRequest): Promise<LLMGenerateResponse<T>>;
954
+ }
955
+
956
+ /**
957
+ * Memory type definitions
958
+ * Types for agent memory management with semantic entry types
959
+ */
960
+ /**
961
+ * Semantic memory entry types
962
+ * Use-case agnostic types that describe the purpose of each entry
963
+ * Memory types mirror action types for clarity and filtering
964
+ */
965
+ type MemoryEntryType = 'context' | 'input' | 'reasoning' | 'tool-result' | 'delegation-result' | 'error';
966
+ /**
967
+ * Memory entry - represents a single entry in agent memory
968
+ * Stored in agent memory, translated by adapters to vendor-specific formats
969
+ */
970
+ interface MemoryEntry {
971
+ type: MemoryEntryType;
972
+ content: string;
973
+ timestamp: number;
974
+ turnNumber: number | null;
975
+ iterationNumber: number | null;
976
+ }
977
+ /**
978
+ * Agent memory - Self-orchestrated memory with session + working storage
979
+ * Agent has full control over what persists, framework handles auto-compaction
980
+ */
981
+ interface AgentMemory {
982
+ /**
983
+ * Session memory - Persists for session/conversation duration
984
+ * Never auto-trimmed by framework
985
+ * Agent-managed key-value store for critical information
986
+ * Agent provides strings, framework wraps in MemoryEntry
987
+ */
988
+ sessionMemory: Record<string, MemoryEntry>;
989
+ /**
990
+ * Working memory - Execution history
991
+ * Automatically compacted by framework when needed
992
+ * Agent doesn't control compaction
993
+ */
994
+ history: MemoryEntry[];
995
+ }
996
+ /**
997
+ * Memory status for agent awareness
998
+ */
999
+ interface MemoryStatus {
1000
+ sessionMemoryKeys: number;
1001
+ sessionMemoryLimit: number;
1002
+ currentKeys: string[];
1003
+ historyPercent: number;
1004
+ historyTokens: number;
1005
+ tokenBudget: number;
1006
+ }
1007
+ /**
1008
+ * Memory constraints (optional limits)
1009
+ */
1010
+ interface MemoryConstraints {
1011
+ maxSessionMemoryKeys?: number;
1012
+ maxMemoryTokens?: number;
1013
+ }
1014
+
1015
+ /**
1016
+ * Memory Manager
1017
+ * Encapsulates all memory operations with ultra-simple agent API
1018
+ * Agent provides strings, framework handles wrapping and auto-compaction
1019
+ */
1020
+
1021
+ /**
1022
+ * Memory Manager - Agent memory orchestration
1023
+ * Provides ultra-simple API for agents (strings only)
1024
+ * Handles automatic compaction and token management
1025
+ */
1026
+ declare class MemoryManager {
1027
+ private memory;
1028
+ private constraints;
1029
+ private logger?;
1030
+ private cachedSnapshot?;
1031
+ constructor(memory: AgentMemory, constraints?: MemoryConstraints, logger?: AgentScopedLogger | undefined);
1032
+ /**
1033
+ * Set session memory entry (agent provides string, framework wraps it)
1034
+ * @param key - Session memory key
1035
+ * @param content - String content from agent
1036
+ */
1037
+ set(key: string, content: string): void;
1038
+ /**
1039
+ * Get session memory entry content
1040
+ * @param key - Session memory key
1041
+ * @returns String content if exists, undefined otherwise
1042
+ */
1043
+ get(key: string): string | undefined;
1044
+ /**
1045
+ * Delete session memory entry
1046
+ * @param key - Key to delete
1047
+ * @returns True if key existed and was deleted
1048
+ */
1049
+ delete(key: string): boolean;
1050
+ /**
1051
+ * Add entry to history (called by framework after tool results, reasoning, etc.)
1052
+ * Automatically sets timestamp to current time
1053
+ * @param entry - Memory entry to add (without timestamp - auto-generated)
1054
+ */
1055
+ addToHistory(entry: Omit<MemoryEntry, 'timestamp'>): void;
1056
+ /**
1057
+ * Auto-compact history if approaching token budget
1058
+ * Uses preserve-anchors strategy: keep first + recent entries
1059
+ */
1060
+ autoCompact(): void;
1061
+ /**
1062
+ * Enforce hard limits (called before LLM request)
1063
+ * Emergency fallback if agent exceeds limits
1064
+ */
1065
+ enforceHardLimits(): void;
1066
+ /**
1067
+ * Get history length (for logging and introspection)
1068
+ * @returns Number of entries in history
1069
+ */
1070
+ getHistoryLength(): number;
1071
+ /**
1072
+ * Get memory status for agent awareness
1073
+ * @returns Memory status with token usage and key counts
1074
+ */
1075
+ getStatus(): MemoryStatus;
1076
+ /**
1077
+ * Create memory snapshot for persistence
1078
+ * Caches snapshot internally for later retrieval
1079
+ * @returns Deep copy of current memory state
1080
+ */
1081
+ toSnapshot(): AgentMemory;
1082
+ /**
1083
+ * Get cached memory snapshot
1084
+ * Returns snapshot created by toSnapshot()
1085
+ * @returns Cached snapshot (undefined if toSnapshot() not called yet)
1086
+ */
1087
+ getSnapshot(): AgentMemory | undefined;
1088
+ /**
1089
+ * Build context string for LLM
1090
+ * Serializes sessionmemory + history memory with clear sections
1091
+ * Shows current iteration entries FIRST (reverse chronological) for LLM attention
1092
+ * @param currentIteration - Current iteration number (0 = pre-iteration)
1093
+ * @param currentTurn - Current turn number (optional, for session context filtering)
1094
+ * @returns Formatted memory context for LLM prompt
1095
+ */
1096
+ toContext(currentIteration: number, currentTurn?: number): string;
1097
+ }
1098
+
1099
+ /**
1100
+ * Knowledge Map Types
1101
+ *
1102
+ * Enables agents to navigate organizational knowledge through a lightweight
1103
+ * graph that lazy-loads capabilities on-demand.
1104
+ *
1105
+ * @module agent/knowledge-map
1106
+ */
1107
+
1108
+ /**
1109
+ * Lightweight knowledge map (passed as agent property)
1110
+ *
1111
+ * Contains metadata about available knowledge nodes without loading
1112
+ * the full content upfront. Total size: ~300-500 tokens.
1113
+ *
1114
+ * Multi-tenancy is enforced via:
1115
+ * - File-scoped maps (organizations/{org-name}/knowledge/)
1116
+ * - ExecutionContext.organizationId passed to node.load()
1117
+ */
1118
+ interface KnowledgeMap {
1119
+ /** Available knowledge nodes indexed by ID */
1120
+ nodes: Record<string, KnowledgeNode>;
1121
+ }
1122
+ /**
1123
+ * Single knowledge source
1124
+ *
1125
+ * Represents a domain knowledge area (CRM, brand guidelines, Excel tools)
1126
+ * that can be lazy-loaded to provide instructions and tools to agents.
1127
+ */
1128
+ interface KnowledgeNode {
1129
+ /** Unique identifier for this node (e.g., "crm", "brand-guidelines") */
1130
+ id: string;
1131
+ /**
1132
+ * Description of when to use this knowledge
1133
+ * Used for semantic matching against user intent
1134
+ */
1135
+ description: string;
1136
+ /**
1137
+ * Load knowledge content on-demand
1138
+ *
1139
+ * @param context - Execution context with organizationId for multi-tenancy
1140
+ * @returns Promise resolving to knowledge content (prompt + optional tools)
1141
+ */
1142
+ load(context: ExecutionContext): Promise<KnowledgeContent>;
1143
+ /**
1144
+ * Loaded state flag
1145
+ * Set to true after load() is called
1146
+ */
1147
+ loaded?: boolean;
1148
+ /**
1149
+ * Cached prompt (for system prompt serialization)
1150
+ * Only the prompt is cached - tools go to toolRegistry, children flattened to nodes
1151
+ */
1152
+ prompt?: string;
1153
+ }
1154
+ /**
1155
+ * Content returned by knowledge node
1156
+ *
1157
+ * Separates instructions (prompt) from capabilities (tools).
1158
+ * Tools are optional - some nodes only provide context.
1159
+ *
1160
+ * Supports recursive navigation - nodes can contain child nodes
1161
+ * that are discovered when the parent node is loaded.
1162
+ */
1163
+ interface KnowledgeContent {
1164
+ /** Instructions and context (markdown format) */
1165
+ prompt: string;
1166
+ /** Tool implementations (optional) */
1167
+ tools?: Tool[];
1168
+ /**
1169
+ * Child knowledge nodes (optional, recursive)
1170
+ *
1171
+ * Enables hierarchical navigation: base → specialized → deep expertise.
1172
+ * Child nodes are flattened into the main knowledge map when parent loads,
1173
+ * making them available for subsequent navigate-knowledge actions.
1174
+ *
1175
+ * Example: CRM base node returns crm-customers and crm-deals as children
1176
+ */
1177
+ nodes?: Record<string, KnowledgeNode>;
1178
+ }
1179
+
1180
+ /**
1181
+ * Agent-specific type definitions
1182
+ * Types for autonomous agents with tools, memory, and constraints
1183
+ */
1184
+
1185
+ /**
1186
+ * Factory function for creating LLM adapters.
1187
+ * Injected into the Agent class to decouple the engine from server-only provider SDKs.
1188
+ * - API process: provides createLLMAdapter (real SDKs + process.env API keys)
1189
+ * - SDK worker: provides PostMessageLLMAdapter (proxies via platform.call)
1190
+ *
1191
+ * Uses `any` for optional params so both the real createLLMAdapter (with typed
1192
+ * AIUsageCollector/AICallContext) and the worker proxy (which ignores them) satisfy the type.
1193
+ */
1194
+ type LLMAdapterFactory = (config: ModelConfig, ...args: any[]) => LLMAdapter;
1195
+ type AgentKind = 'orchestrator' | 'specialist' | 'utility' | 'platform';
1196
+ interface AgentConfig extends ResourceDefinition {
1197
+ type: 'agent';
1198
+ /** OM descriptor backing canonical identity and governance metadata. */
1199
+ resource?: AgentResourceEntry;
1200
+ kind: AgentKind;
1201
+ systemPrompt: string;
1202
+ constraints?: AgentConstraints;
1203
+ /**
1204
+ * Session capability declaration (opt-in)
1205
+ * If true, agent is designed for multi-turn session interactions
1206
+ * Controls whether agent can use message action and appears in Sessions UI
1207
+ *
1208
+ * Use for:
1209
+ * - Conversational agents with multi-turn interactions
1210
+ * - Agents requiring persistent context across turns
1211
+ * - Agents that need human-in-the-loop communication
1212
+ */
1213
+ sessionCapable?: boolean;
1214
+ /**
1215
+ * Security level for system prompt hardening (auto-derived if omitted)
1216
+ *
1217
+ * - 'standard': Lightweight defense (3 rules) - default for non-session agents
1218
+ * - 'hardened': Comprehensive defense (6 rules) - default for session-capable agents
1219
+ * - 'none': No security prompt - for pure internal agents with no external input
1220
+ *
1221
+ * If omitted, derived from sessionCapable:
1222
+ * sessionCapable: true -> 'hardened'
1223
+ * sessionCapable: false -> 'standard'
1224
+ */
1225
+ securityLevel?: 'standard' | 'hardened' | 'none';
1226
+ /**
1227
+ * Memory management preferences (opt-in)
1228
+ * If provided, agent can use memoryOps to manage session memory
1229
+ * If omitted, agent has no memory management capabilities
1230
+ *
1231
+ * Agent-specific guidance on what to preserve, when to persist, and what to clean up.
1232
+ * This guidance is injected into the system prompt when memory management is enabled.
1233
+ *
1234
+ * Use for:
1235
+ * - Conversational agents needing cross-turn context
1236
+ * - Agents managing complex user preferences
1237
+ * - Agents tracking decisions over multiple iterations
1238
+ */
1239
+ memoryPreferences?: string;
1240
+ }
1241
+ interface AgentConstraints {
1242
+ maxIterations?: number;
1243
+ timeout?: number;
1244
+ maxSessionMemoryKeys?: number;
1245
+ maxMemoryTokens?: number;
1246
+ }
1247
+ interface AgentDefinition {
1248
+ config: AgentConfig;
1249
+ contract: Contract;
1250
+ tools: Tool[];
1251
+ /**
1252
+ * Model configuration for LLM execution
1253
+ * Specifies provider, API key, and model-specific options
1254
+ */
1255
+ modelConfig: ModelConfig;
1256
+ /**
1257
+ * Optional knowledge map for lazy-loading capabilities
1258
+ * Enables agents to navigate organizational knowledge on-demand
1259
+ */
1260
+ knowledgeMap?: KnowledgeMap;
1261
+ /**
1262
+ * Preload memory before execution starts
1263
+ * Handles BOTH context loading AND session restoration
1264
+ *
1265
+ * @param context - Execution context (includes sessionId if session turn)
1266
+ * @returns Initial AgentMemory state (sessionMemory entries + optionally history)
1267
+ */
1268
+ preloadMemory?: (context: ExecutionContext) => Promise<AgentMemory> | AgentMemory;
1269
+ /**
1270
+ * Metrics configuration for ROI calculations
1271
+ * Optional: Only needed if tracking automation savings
1272
+ */
1273
+ metricsConfig?: ResourceMetricsConfig;
1274
+ /**
1275
+ * Execution interface configuration (optional)
1276
+ * If provided, agent appears in Execution Runner UI
1277
+ */
1278
+ interface?: ExecutionInterface;
1279
+ }
1280
+ /**
1281
+ * Agent execution context
1282
+ * Groups all state needed for agent execution phases
1283
+ */
1284
+ interface IterationContext {
1285
+ config: AgentConfig;
1286
+ contract: Contract;
1287
+ toolRegistry: Map<string, Tool>;
1288
+ memoryManager: MemoryManager;
1289
+ executionContext: ExecutionContext;
1290
+ iteration: number;
1291
+ logger: AgentScopedLogger;
1292
+ modelConfig: ModelConfig;
1293
+ adapterFactory: LLMAdapterFactory;
1294
+ knowledgeMap?: KnowledgeMap;
1295
+ }
1296
+
1297
+ declare const OntologyScopeSchema: z.ZodDefault<z.ZodObject<{
1298
+ objectTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1299
+ id: z.ZodString;
1300
+ label: z.ZodOptional<z.ZodString>;
1301
+ description: z.ZodOptional<z.ZodString>;
1302
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1303
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1304
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1305
+ storage: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1306
+ }, z.core.$loose>>>>;
1307
+ linkTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1308
+ id: z.ZodString;
1309
+ label: z.ZodOptional<z.ZodString>;
1310
+ description: z.ZodOptional<z.ZodString>;
1311
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1312
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1313
+ from: z.ZodString;
1314
+ to: z.ZodString;
1315
+ cardinality: z.ZodOptional<z.ZodString>;
1316
+ via: z.ZodOptional<z.ZodString>;
1317
+ }, z.core.$loose>>>>;
1318
+ actionTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1319
+ id: z.ZodString;
1320
+ label: z.ZodOptional<z.ZodString>;
1321
+ description: z.ZodOptional<z.ZodString>;
1322
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1323
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1324
+ actsOn: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
1325
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1326
+ effects: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1327
+ }, z.core.$loose>>>>;
1328
+ catalogTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1329
+ id: z.ZodString;
1330
+ label: z.ZodOptional<z.ZodString>;
1331
+ description: z.ZodOptional<z.ZodString>;
1332
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1333
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1334
+ kind: z.ZodOptional<z.ZodString>;
1335
+ appliesTo: z.ZodOptional<z.ZodString>;
1336
+ entries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1337
+ }, z.core.$loose>>>>;
1338
+ eventTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1339
+ id: z.ZodString;
1340
+ label: z.ZodOptional<z.ZodString>;
1341
+ description: z.ZodOptional<z.ZodString>;
1342
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1343
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1344
+ payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1345
+ }, z.core.$loose>>>>;
1346
+ interfaceTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1347
+ id: z.ZodString;
1348
+ label: z.ZodOptional<z.ZodString>;
1349
+ description: z.ZodOptional<z.ZodString>;
1350
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1351
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1352
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1353
+ }, z.core.$loose>>>>;
1354
+ valueTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1355
+ id: z.ZodString;
1356
+ label: z.ZodOptional<z.ZodString>;
1357
+ description: z.ZodOptional<z.ZodString>;
1358
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1359
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1360
+ primitive: z.ZodOptional<z.ZodString>;
1361
+ }, z.core.$loose>>>>;
1362
+ sharedProperties: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1363
+ id: z.ZodString;
1364
+ label: z.ZodOptional<z.ZodString>;
1365
+ description: z.ZodOptional<z.ZodString>;
1366
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1367
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1368
+ valueType: z.ZodOptional<z.ZodString>;
1369
+ searchable: z.ZodOptional<z.ZodBoolean>;
1370
+ pii: z.ZodOptional<z.ZodBoolean>;
1371
+ }, z.core.$loose>>>>;
1372
+ groups: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1373
+ id: z.ZodString;
1374
+ label: z.ZodOptional<z.ZodString>;
1375
+ description: z.ZodOptional<z.ZodString>;
1376
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1377
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1378
+ members: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
1379
+ }, z.core.$loose>>>>;
1380
+ surfaces: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1381
+ id: z.ZodString;
1382
+ label: z.ZodOptional<z.ZodString>;
1383
+ description: z.ZodOptional<z.ZodString>;
1384
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1385
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1386
+ route: z.ZodOptional<z.ZodString>;
1387
+ }, z.core.$loose>>>>;
1388
+ }, z.core.$strip>>;
1389
+ type OntologyScope = z.infer<typeof OntologyScopeSchema>;
1390
+
1391
+ type JsonPrimitive = string | number | boolean | null;
1392
+ type JsonValue = JsonPrimitive | JsonValue[] | {
1393
+ [key: string]: JsonValue;
1394
+ };
1395
+ /** Explicit interface needed to annotate the recursive SystemEntrySchema. */
1396
+ interface SystemEntry {
1397
+ id: string;
1398
+ label?: string;
1399
+ title?: string;
1400
+ description?: string;
1401
+ kind?: 'product' | 'operational' | 'platform' | 'diagnostic';
1402
+ parentSystemId?: string;
1403
+ ui?: {
1404
+ path: string;
1405
+ surfaces: string[];
1406
+ icon?: string;
1407
+ order?: number;
1408
+ };
1409
+ lifecycle?: 'draft' | 'beta' | 'active' | 'deprecated' | 'archived';
1410
+ responsibleRoleId?: string;
1411
+ governedByKnowledge?: string[];
1412
+ actions?: {
1413
+ actionId: string;
1414
+ intent: 'exposes' | 'consumes';
1415
+ invocation?: unknown;
1416
+ }[];
1417
+ policies?: string[];
1418
+ drivesGoals?: string[];
1419
+ /** @deprecated Use lifecycle. Accepted for one publish cycle. */
1420
+ status?: 'active' | 'deprecated' | 'archived';
1421
+ path?: string;
1422
+ icon?: string;
1423
+ color?: string;
1424
+ uiPosition?: 'sidebar-primary' | 'sidebar-bottom';
1425
+ enabled?: boolean;
1426
+ devOnly?: boolean;
1427
+ requiresAdmin?: boolean;
1428
+ order: number;
1429
+ config?: Record<string, JsonValue>;
1430
+ ontology?: OntologyScope;
1431
+ systems?: Record<string, SystemEntry>;
1432
+ subsystems?: Record<string, SystemEntry>;
1433
+ }
1434
+
1435
+ declare const SurfaceTypeSchema: z.ZodEnum<{
1436
+ dashboard: "dashboard";
1437
+ settings: "settings";
1438
+ graph: "graph";
1439
+ list: "list";
1440
+ page: "page";
1441
+ detail: "detail";
1442
+ }>;
1443
+ interface SidebarSurfaceNode {
1444
+ type: 'surface';
1445
+ label: string;
1446
+ path: string;
1447
+ surfaceType: z.infer<typeof SurfaceTypeSchema>;
1448
+ description?: string;
1449
+ icon?: string;
1450
+ order?: number;
1451
+ targets?: {
1452
+ systems?: string[];
1453
+ entities?: string[];
1454
+ resources?: string[];
1455
+ actions?: string[];
1456
+ };
1457
+ devOnly?: boolean;
1458
+ requiresAdmin?: boolean;
1459
+ }
1460
+ interface SidebarGroupNode {
1461
+ type: 'group';
1462
+ label: string;
1463
+ description?: string;
1464
+ icon?: string;
1465
+ order?: number;
1466
+ children: Record<string, SidebarNode>;
1467
+ }
1468
+ type SidebarNode = SidebarSurfaceNode | SidebarGroupNode;
1469
+
1470
+ declare const LinkSchema: z.ZodObject<{
1471
+ nodeId: z.ZodString;
1472
+ kind: z.ZodEnum<{
1473
+ links: "links";
1474
+ affects: "affects";
1475
+ effects: "effects";
1476
+ actions: "actions";
1477
+ reads: "reads";
1478
+ writes: "writes";
1479
+ emits: "emits";
1480
+ triggers: "triggers";
1481
+ uses: "uses";
1482
+ approval: "approval";
1483
+ contains: "contains";
1484
+ references: "references";
1485
+ maps_to: "maps_to";
1486
+ governs: "governs";
1487
+ originates_from: "originates_from";
1488
+ applies_to: "applies_to";
1489
+ uses_catalog: "uses_catalog";
1490
+ }>;
1491
+ }, z.core.$strip>;
1492
+ type Link = z.infer<typeof LinkSchema>;
1493
+
1494
+ declare const OrganizationModelSchema$1: z.ZodObject<{
1495
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1496
+ domainMetadata: z.ZodPipe<z.ZodDefault<z.ZodObject<{
1497
+ branding: z.ZodOptional<z.ZodObject<{
1498
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1499
+ lastModified: z.ZodString;
1500
+ }, z.core.$strip>>;
1501
+ identity: z.ZodOptional<z.ZodObject<{
1502
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1503
+ lastModified: z.ZodString;
1504
+ }, z.core.$strip>>;
1505
+ customers: z.ZodOptional<z.ZodObject<{
1506
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1507
+ lastModified: z.ZodString;
1508
+ }, z.core.$strip>>;
1509
+ offerings: z.ZodOptional<z.ZodObject<{
1510
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1511
+ lastModified: z.ZodString;
1512
+ }, z.core.$strip>>;
1513
+ roles: z.ZodOptional<z.ZodObject<{
1514
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1515
+ lastModified: z.ZodString;
1516
+ }, z.core.$strip>>;
1517
+ goals: z.ZodOptional<z.ZodObject<{
1518
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1519
+ lastModified: z.ZodString;
1520
+ }, z.core.$strip>>;
1521
+ systems: z.ZodOptional<z.ZodObject<{
1522
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1523
+ lastModified: z.ZodString;
1524
+ }, z.core.$strip>>;
1525
+ ontology: z.ZodOptional<z.ZodObject<{
1526
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1527
+ lastModified: z.ZodString;
1528
+ }, z.core.$strip>>;
1529
+ resources: z.ZodOptional<z.ZodObject<{
1530
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1531
+ lastModified: z.ZodString;
1532
+ }, z.core.$strip>>;
1533
+ topology: z.ZodOptional<z.ZodObject<{
1534
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1535
+ lastModified: z.ZodString;
1536
+ }, z.core.$strip>>;
1537
+ actions: z.ZodOptional<z.ZodObject<{
1538
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1539
+ lastModified: z.ZodString;
1540
+ }, z.core.$strip>>;
1541
+ entities: z.ZodOptional<z.ZodObject<{
1542
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1543
+ lastModified: z.ZodString;
1544
+ }, z.core.$strip>>;
1545
+ policies: z.ZodOptional<z.ZodObject<{
1546
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1547
+ lastModified: z.ZodString;
1548
+ }, z.core.$strip>>;
1549
+ knowledge: z.ZodOptional<z.ZodObject<{
1550
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1551
+ lastModified: z.ZodString;
1552
+ }, z.core.$strip>>;
1553
+ }, z.core.$strip>>, z.ZodTransform<{
1554
+ branding: {
1555
+ version: 1;
1556
+ lastModified: string;
1557
+ };
1558
+ identity: {
1559
+ version: 1;
1560
+ lastModified: string;
1561
+ };
1562
+ customers: {
1563
+ version: 1;
1564
+ lastModified: string;
1565
+ };
1566
+ offerings: {
1567
+ version: 1;
1568
+ lastModified: string;
1569
+ };
1570
+ roles: {
1571
+ version: 1;
1572
+ lastModified: string;
1573
+ };
1574
+ goals: {
1575
+ version: 1;
1576
+ lastModified: string;
1577
+ };
1578
+ systems: {
1579
+ version: 1;
1580
+ lastModified: string;
1581
+ };
1582
+ ontology: {
1583
+ version: 1;
1584
+ lastModified: string;
1585
+ };
1586
+ resources: {
1587
+ version: 1;
1588
+ lastModified: string;
1589
+ };
1590
+ topology: {
1591
+ version: 1;
1592
+ lastModified: string;
1593
+ };
1594
+ actions: {
1595
+ version: 1;
1596
+ lastModified: string;
1597
+ };
1598
+ entities: {
1599
+ version: 1;
1600
+ lastModified: string;
1601
+ };
1602
+ policies: {
1603
+ version: 1;
1604
+ lastModified: string;
1605
+ };
1606
+ knowledge: {
1607
+ version: 1;
1608
+ lastModified: string;
1609
+ };
1610
+ }, {
1611
+ branding?: {
1612
+ version: 1;
1613
+ lastModified: string;
1614
+ } | undefined;
1615
+ identity?: {
1616
+ version: 1;
1617
+ lastModified: string;
1618
+ } | undefined;
1619
+ customers?: {
1620
+ version: 1;
1621
+ lastModified: string;
1622
+ } | undefined;
1623
+ offerings?: {
1624
+ version: 1;
1625
+ lastModified: string;
1626
+ } | undefined;
1627
+ roles?: {
1628
+ version: 1;
1629
+ lastModified: string;
1630
+ } | undefined;
1631
+ goals?: {
1632
+ version: 1;
1633
+ lastModified: string;
1634
+ } | undefined;
1635
+ systems?: {
1636
+ version: 1;
1637
+ lastModified: string;
1638
+ } | undefined;
1639
+ ontology?: {
1640
+ version: 1;
1641
+ lastModified: string;
1642
+ } | undefined;
1643
+ resources?: {
1644
+ version: 1;
1645
+ lastModified: string;
1646
+ } | undefined;
1647
+ topology?: {
1648
+ version: 1;
1649
+ lastModified: string;
1650
+ } | undefined;
1651
+ actions?: {
1652
+ version: 1;
1653
+ lastModified: string;
1654
+ } | undefined;
1655
+ entities?: {
1656
+ version: 1;
1657
+ lastModified: string;
1658
+ } | undefined;
1659
+ policies?: {
1660
+ version: 1;
1661
+ lastModified: string;
1662
+ } | undefined;
1663
+ knowledge?: {
1664
+ version: 1;
1665
+ lastModified: string;
1666
+ } | undefined;
1667
+ }>>;
1668
+ branding: z.ZodDefault<z.ZodObject<{
1669
+ organizationName: z.ZodString;
1670
+ productName: z.ZodString;
1671
+ shortName: z.ZodString;
1672
+ description: z.ZodOptional<z.ZodString>;
1673
+ logos: z.ZodDefault<z.ZodObject<{
1674
+ light: z.ZodOptional<z.ZodString>;
1675
+ dark: z.ZodOptional<z.ZodString>;
1676
+ }, z.core.$strip>>;
1677
+ }, z.core.$strip>>;
1678
+ navigation: z.ZodDefault<z.ZodObject<{
1679
+ sidebar: z.ZodDefault<z.ZodObject<{
1680
+ primary: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<SidebarNode, unknown, z.core.$ZodTypeInternals<SidebarNode, unknown>>>>;
1681
+ bottom: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<SidebarNode, unknown, z.core.$ZodTypeInternals<SidebarNode, unknown>>>>;
1682
+ }, z.core.$strip>>;
1683
+ }, z.core.$strip>>;
1684
+ identity: z.ZodDefault<z.ZodObject<{
1685
+ mission: z.ZodDefault<z.ZodString>;
1686
+ vision: z.ZodDefault<z.ZodString>;
1687
+ legalName: z.ZodDefault<z.ZodString>;
1688
+ entityType: z.ZodDefault<z.ZodString>;
1689
+ jurisdiction: z.ZodDefault<z.ZodString>;
1690
+ industryCategory: z.ZodDefault<z.ZodString>;
1691
+ geographicFocus: z.ZodDefault<z.ZodString>;
1692
+ timeZone: z.ZodDefault<z.ZodString>;
1693
+ businessHours: z.ZodDefault<z.ZodObject<{
1694
+ monday: z.ZodOptional<z.ZodObject<{
1695
+ open: z.ZodString;
1696
+ close: z.ZodString;
1697
+ }, z.core.$strip>>;
1698
+ tuesday: z.ZodOptional<z.ZodObject<{
1699
+ open: z.ZodString;
1700
+ close: z.ZodString;
1701
+ }, z.core.$strip>>;
1702
+ wednesday: z.ZodOptional<z.ZodObject<{
1703
+ open: z.ZodString;
1704
+ close: z.ZodString;
1705
+ }, z.core.$strip>>;
1706
+ thursday: z.ZodOptional<z.ZodObject<{
1707
+ open: z.ZodString;
1708
+ close: z.ZodString;
1709
+ }, z.core.$strip>>;
1710
+ friday: z.ZodOptional<z.ZodObject<{
1711
+ open: z.ZodString;
1712
+ close: z.ZodString;
1713
+ }, z.core.$strip>>;
1714
+ saturday: z.ZodOptional<z.ZodObject<{
1715
+ open: z.ZodString;
1716
+ close: z.ZodString;
1717
+ }, z.core.$strip>>;
1718
+ sunday: z.ZodOptional<z.ZodObject<{
1719
+ open: z.ZodString;
1720
+ close: z.ZodString;
1721
+ }, z.core.$strip>>;
1722
+ }, z.core.$strip>>;
1723
+ clientBrief: z.ZodDefault<z.ZodString>;
1724
+ }, z.core.$strip>>;
1725
+ customers: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1726
+ id: z.ZodString;
1727
+ order: z.ZodNumber;
1728
+ name: z.ZodDefault<z.ZodString>;
1729
+ description: z.ZodDefault<z.ZodString>;
1730
+ jobsToBeDone: z.ZodDefault<z.ZodString>;
1731
+ pains: z.ZodDefault<z.ZodArray<z.ZodString>>;
1732
+ gains: z.ZodDefault<z.ZodArray<z.ZodString>>;
1733
+ firmographics: z.ZodDefault<z.ZodObject<{
1734
+ industry: z.ZodOptional<z.ZodString>;
1735
+ companySize: z.ZodOptional<z.ZodString>;
1736
+ region: z.ZodOptional<z.ZodString>;
1737
+ }, z.core.$strip>>;
1738
+ valueProp: z.ZodDefault<z.ZodString>;
1739
+ }, z.core.$strip>>>>;
1740
+ offerings: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1741
+ id: z.ZodString;
1742
+ order: z.ZodNumber;
1743
+ name: z.ZodDefault<z.ZodString>;
1744
+ description: z.ZodDefault<z.ZodString>;
1745
+ pricingModel: z.ZodDefault<z.ZodEnum<{
1746
+ custom: "custom";
1747
+ "one-time": "one-time";
1748
+ subscription: "subscription";
1749
+ "usage-based": "usage-based";
1750
+ }>>;
1751
+ price: z.ZodDefault<z.ZodNumber>;
1752
+ currency: z.ZodDefault<z.ZodString>;
1753
+ targetSegmentIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
1754
+ deliveryFeatureId: z.ZodOptional<z.ZodString>;
1755
+ }, z.core.$strip>>>>;
1756
+ roles: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1757
+ id: z.ZodString;
1758
+ order: z.ZodNumber;
1759
+ title: z.ZodString;
1760
+ responsibilities: z.ZodDefault<z.ZodArray<z.ZodString>>;
1761
+ reportsToId: z.ZodOptional<z.ZodString>;
1762
+ heldBy: z.ZodOptional<z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
1763
+ kind: z.ZodLiteral<"human">;
1764
+ userId: z.ZodString;
1765
+ }, z.core.$strip>, z.ZodObject<{
1766
+ kind: z.ZodLiteral<"agent">;
1767
+ agentId: z.ZodString;
1768
+ }, z.core.$strip>, z.ZodObject<{
1769
+ kind: z.ZodLiteral<"team">;
1770
+ memberIds: z.ZodArray<z.ZodString>;
1771
+ }, z.core.$strip>], "kind">, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1772
+ kind: z.ZodLiteral<"human">;
1773
+ userId: z.ZodString;
1774
+ }, z.core.$strip>, z.ZodObject<{
1775
+ kind: z.ZodLiteral<"agent">;
1776
+ agentId: z.ZodString;
1777
+ }, z.core.$strip>, z.ZodObject<{
1778
+ kind: z.ZodLiteral<"team">;
1779
+ memberIds: z.ZodArray<z.ZodString>;
1780
+ }, z.core.$strip>], "kind">>]>>;
1781
+ responsibleFor: z.ZodOptional<z.ZodArray<z.ZodString>>;
1782
+ }, z.core.$strip>>>>;
1783
+ goals: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1784
+ id: z.ZodString;
1785
+ order: z.ZodNumber;
1786
+ description: z.ZodString;
1787
+ periodStart: z.ZodString;
1788
+ periodEnd: z.ZodString;
1789
+ keyResults: z.ZodDefault<z.ZodArray<z.ZodObject<{
1790
+ id: z.ZodString;
1791
+ description: z.ZodString;
1792
+ targetMetric: z.ZodString;
1793
+ currentValue: z.ZodDefault<z.ZodNumber>;
1794
+ targetValue: z.ZodOptional<z.ZodNumber>;
1795
+ }, z.core.$strip>>>;
1796
+ }, z.core.$strip>>>>;
1797
+ systems: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<SystemEntry, unknown, z.core.$ZodTypeInternals<SystemEntry, unknown>>>>>;
1798
+ ontology: z.ZodDefault<z.ZodDefault<z.ZodObject<{
1799
+ objectTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1800
+ id: z.ZodString;
1801
+ label: z.ZodOptional<z.ZodString>;
1802
+ description: z.ZodOptional<z.ZodString>;
1803
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1804
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1805
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1806
+ storage: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1807
+ }, z.core.$loose>>>>;
1808
+ linkTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1809
+ id: z.ZodString;
1810
+ label: z.ZodOptional<z.ZodString>;
1811
+ description: z.ZodOptional<z.ZodString>;
1812
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1813
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1814
+ from: z.ZodString;
1815
+ to: z.ZodString;
1816
+ cardinality: z.ZodOptional<z.ZodString>;
1817
+ via: z.ZodOptional<z.ZodString>;
1818
+ }, z.core.$loose>>>>;
1819
+ actionTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1820
+ id: z.ZodString;
1821
+ label: z.ZodOptional<z.ZodString>;
1822
+ description: z.ZodOptional<z.ZodString>;
1823
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1824
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1825
+ actsOn: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
1826
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1827
+ effects: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1828
+ }, z.core.$loose>>>>;
1829
+ catalogTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1830
+ id: z.ZodString;
1831
+ label: z.ZodOptional<z.ZodString>;
1832
+ description: z.ZodOptional<z.ZodString>;
1833
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1834
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1835
+ kind: z.ZodOptional<z.ZodString>;
1836
+ appliesTo: z.ZodOptional<z.ZodString>;
1837
+ entries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1838
+ }, z.core.$loose>>>>;
1839
+ eventTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1840
+ id: z.ZodString;
1841
+ label: z.ZodOptional<z.ZodString>;
1842
+ description: z.ZodOptional<z.ZodString>;
1843
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1844
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1845
+ payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1846
+ }, z.core.$loose>>>>;
1847
+ interfaceTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1848
+ id: z.ZodString;
1849
+ label: z.ZodOptional<z.ZodString>;
1850
+ description: z.ZodOptional<z.ZodString>;
1851
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1852
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1853
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1854
+ }, z.core.$loose>>>>;
1855
+ valueTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1856
+ id: z.ZodString;
1857
+ label: z.ZodOptional<z.ZodString>;
1858
+ description: z.ZodOptional<z.ZodString>;
1859
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1860
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1861
+ primitive: z.ZodOptional<z.ZodString>;
1862
+ }, z.core.$loose>>>>;
1863
+ sharedProperties: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1864
+ id: z.ZodString;
1865
+ label: z.ZodOptional<z.ZodString>;
1866
+ description: z.ZodOptional<z.ZodString>;
1867
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1868
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1869
+ valueType: z.ZodOptional<z.ZodString>;
1870
+ searchable: z.ZodOptional<z.ZodBoolean>;
1871
+ pii: z.ZodOptional<z.ZodBoolean>;
1872
+ }, z.core.$loose>>>>;
1873
+ groups: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1874
+ id: z.ZodString;
1875
+ label: z.ZodOptional<z.ZodString>;
1876
+ description: z.ZodOptional<z.ZodString>;
1877
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1878
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1879
+ members: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
1880
+ }, z.core.$loose>>>>;
1881
+ surfaces: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1882
+ id: z.ZodString;
1883
+ label: z.ZodOptional<z.ZodString>;
1884
+ description: z.ZodOptional<z.ZodString>;
1885
+ ownerSystemId: z.ZodOptional<z.ZodString>;
1886
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1887
+ route: z.ZodOptional<z.ZodString>;
1888
+ }, z.core.$loose>>>>;
1889
+ }, z.core.$strip>>>;
1890
+ resources: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
1891
+ id: z.ZodString;
1892
+ order: z.ZodDefault<z.ZodNumber>;
1893
+ systemPath: z.ZodString;
1894
+ title: z.ZodOptional<z.ZodString>;
1895
+ description: z.ZodOptional<z.ZodString>;
1896
+ ownerRoleId: z.ZodOptional<z.ZodString>;
1897
+ status: z.ZodEnum<{
1898
+ deprecated: "deprecated";
1899
+ active: "active";
1900
+ archived: "archived";
1901
+ }>;
1902
+ ontology: z.ZodOptional<z.ZodObject<{
1903
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
1904
+ primaryAction: z.ZodOptional<z.ZodString>;
1905
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
1906
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
1907
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
1908
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
1909
+ contract: z.ZodOptional<z.ZodObject<{
1910
+ input: z.ZodOptional<z.ZodString>;
1911
+ output: z.ZodOptional<z.ZodString>;
1912
+ }, z.core.$strip>>;
1913
+ }, z.core.$strip>>;
1914
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
1915
+ path: z.ZodString;
1916
+ role: z.ZodEnum<{
1917
+ config: "config";
1918
+ entrypoint: "entrypoint";
1919
+ handler: "handler";
1920
+ schema: "schema";
1921
+ test: "test";
1922
+ docs: "docs";
1923
+ }>;
1924
+ symbol: z.ZodOptional<z.ZodString>;
1925
+ description: z.ZodOptional<z.ZodString>;
1926
+ }, z.core.$strip>>>;
1927
+ kind: z.ZodLiteral<"workflow">;
1928
+ emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
1929
+ eventKey: z.ZodString;
1930
+ label: z.ZodString;
1931
+ payloadSchema: z.ZodOptional<z.ZodString>;
1932
+ lifecycle: z.ZodOptional<z.ZodEnum<{
1933
+ deprecated: "deprecated";
1934
+ draft: "draft";
1935
+ beta: "beta";
1936
+ active: "active";
1937
+ archived: "archived";
1938
+ }>>;
1939
+ }, z.core.$strip>>>;
1940
+ }, z.core.$strip>, z.ZodObject<{
1941
+ id: z.ZodString;
1942
+ order: z.ZodDefault<z.ZodNumber>;
1943
+ systemPath: z.ZodString;
1944
+ title: z.ZodOptional<z.ZodString>;
1945
+ description: z.ZodOptional<z.ZodString>;
1946
+ ownerRoleId: z.ZodOptional<z.ZodString>;
1947
+ status: z.ZodEnum<{
1948
+ deprecated: "deprecated";
1949
+ active: "active";
1950
+ archived: "archived";
1951
+ }>;
1952
+ ontology: z.ZodOptional<z.ZodObject<{
1953
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
1954
+ primaryAction: z.ZodOptional<z.ZodString>;
1955
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
1956
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
1957
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
1958
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
1959
+ contract: z.ZodOptional<z.ZodObject<{
1960
+ input: z.ZodOptional<z.ZodString>;
1961
+ output: z.ZodOptional<z.ZodString>;
1962
+ }, z.core.$strip>>;
1963
+ }, z.core.$strip>>;
1964
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
1965
+ path: z.ZodString;
1966
+ role: z.ZodEnum<{
1967
+ config: "config";
1968
+ entrypoint: "entrypoint";
1969
+ handler: "handler";
1970
+ schema: "schema";
1971
+ test: "test";
1972
+ docs: "docs";
1973
+ }>;
1974
+ symbol: z.ZodOptional<z.ZodString>;
1975
+ description: z.ZodOptional<z.ZodString>;
1976
+ }, z.core.$strip>>>;
1977
+ kind: z.ZodLiteral<"agent">;
1978
+ agentKind: z.ZodEnum<{
1979
+ platform: "platform";
1980
+ orchestrator: "orchestrator";
1981
+ specialist: "specialist";
1982
+ utility: "utility";
1983
+ }>;
1984
+ actsAsRoleId: z.ZodOptional<z.ZodString>;
1985
+ sessionCapable: z.ZodBoolean;
1986
+ invocations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1987
+ kind: z.ZodLiteral<"slash-command">;
1988
+ command: z.ZodString;
1989
+ toolFactory: z.ZodOptional<z.ZodString>;
1990
+ }, z.core.$strip>, z.ZodObject<{
1991
+ kind: z.ZodLiteral<"mcp-tool">;
1992
+ server: z.ZodString;
1993
+ name: z.ZodString;
1994
+ }, z.core.$strip>, z.ZodObject<{
1995
+ kind: z.ZodLiteral<"api-endpoint">;
1996
+ method: z.ZodEnum<{
1997
+ GET: "GET";
1998
+ POST: "POST";
1999
+ PATCH: "PATCH";
2000
+ DELETE: "DELETE";
2001
+ }>;
2002
+ path: z.ZodString;
2003
+ requestSchema: z.ZodOptional<z.ZodString>;
2004
+ responseSchema: z.ZodOptional<z.ZodString>;
2005
+ }, z.core.$strip>, z.ZodObject<{
2006
+ kind: z.ZodLiteral<"script-execution">;
2007
+ resourceId: z.ZodString;
2008
+ }, z.core.$strip>], "kind">>>;
2009
+ emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
2010
+ eventKey: z.ZodString;
2011
+ label: z.ZodString;
2012
+ payloadSchema: z.ZodOptional<z.ZodString>;
2013
+ lifecycle: z.ZodOptional<z.ZodEnum<{
2014
+ deprecated: "deprecated";
2015
+ draft: "draft";
2016
+ beta: "beta";
2017
+ active: "active";
2018
+ archived: "archived";
2019
+ }>>;
2020
+ }, z.core.$strip>>>;
2021
+ }, z.core.$strip>, z.ZodObject<{
2022
+ id: z.ZodString;
2023
+ order: z.ZodDefault<z.ZodNumber>;
2024
+ systemPath: z.ZodString;
2025
+ title: z.ZodOptional<z.ZodString>;
2026
+ description: z.ZodOptional<z.ZodString>;
2027
+ ownerRoleId: z.ZodOptional<z.ZodString>;
2028
+ status: z.ZodEnum<{
2029
+ deprecated: "deprecated";
2030
+ active: "active";
2031
+ archived: "archived";
2032
+ }>;
2033
+ ontology: z.ZodOptional<z.ZodObject<{
2034
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
2035
+ primaryAction: z.ZodOptional<z.ZodString>;
2036
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
2037
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
2038
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
2039
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
2040
+ contract: z.ZodOptional<z.ZodObject<{
2041
+ input: z.ZodOptional<z.ZodString>;
2042
+ output: z.ZodOptional<z.ZodString>;
2043
+ }, z.core.$strip>>;
2044
+ }, z.core.$strip>>;
2045
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
2046
+ path: z.ZodString;
2047
+ role: z.ZodEnum<{
2048
+ config: "config";
2049
+ entrypoint: "entrypoint";
2050
+ handler: "handler";
2051
+ schema: "schema";
2052
+ test: "test";
2053
+ docs: "docs";
2054
+ }>;
2055
+ symbol: z.ZodOptional<z.ZodString>;
2056
+ description: z.ZodOptional<z.ZodString>;
2057
+ }, z.core.$strip>>>;
2058
+ kind: z.ZodLiteral<"integration">;
2059
+ provider: z.ZodString;
2060
+ }, z.core.$strip>, z.ZodObject<{
2061
+ id: z.ZodString;
2062
+ order: z.ZodDefault<z.ZodNumber>;
2063
+ systemPath: z.ZodString;
2064
+ title: z.ZodOptional<z.ZodString>;
2065
+ description: z.ZodOptional<z.ZodString>;
2066
+ ownerRoleId: z.ZodOptional<z.ZodString>;
2067
+ status: z.ZodEnum<{
2068
+ deprecated: "deprecated";
2069
+ active: "active";
2070
+ archived: "archived";
2071
+ }>;
2072
+ ontology: z.ZodOptional<z.ZodObject<{
2073
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
2074
+ primaryAction: z.ZodOptional<z.ZodString>;
2075
+ reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
2076
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
2077
+ usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
2078
+ emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
2079
+ contract: z.ZodOptional<z.ZodObject<{
2080
+ input: z.ZodOptional<z.ZodString>;
2081
+ output: z.ZodOptional<z.ZodString>;
2082
+ }, z.core.$strip>>;
2083
+ }, z.core.$strip>>;
2084
+ codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
2085
+ path: z.ZodString;
2086
+ role: z.ZodEnum<{
2087
+ config: "config";
2088
+ entrypoint: "entrypoint";
2089
+ handler: "handler";
2090
+ schema: "schema";
2091
+ test: "test";
2092
+ docs: "docs";
2093
+ }>;
2094
+ symbol: z.ZodOptional<z.ZodString>;
2095
+ description: z.ZodOptional<z.ZodString>;
2096
+ }, z.core.$strip>>>;
2097
+ kind: z.ZodLiteral<"script">;
2098
+ language: z.ZodEnum<{
2099
+ shell: "shell";
2100
+ sql: "sql";
2101
+ typescript: "typescript";
2102
+ python: "python";
2103
+ }>;
2104
+ source: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
2105
+ file: z.ZodString;
2106
+ }, z.core.$strip>]>;
2107
+ }, z.core.$strip>], "kind">>>>;
2108
+ topology: z.ZodDefault<z.ZodDefault<z.ZodObject<{
2109
+ version: z.ZodDefault<z.ZodLiteral<1>>;
2110
+ relationships: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2111
+ from: z.ZodDiscriminatedUnion<[z.ZodObject<{
2112
+ kind: z.ZodLiteral<"system">;
2113
+ id: z.ZodString;
2114
+ }, z.core.$strip>, z.ZodObject<{
2115
+ kind: z.ZodLiteral<"resource">;
2116
+ id: z.ZodString;
2117
+ }, z.core.$strip>, z.ZodObject<{
2118
+ kind: z.ZodLiteral<"ontology">;
2119
+ id: z.ZodString;
2120
+ }, z.core.$strip>, z.ZodObject<{
2121
+ kind: z.ZodLiteral<"policy">;
2122
+ id: z.ZodString;
2123
+ }, z.core.$strip>, z.ZodObject<{
2124
+ kind: z.ZodLiteral<"role">;
2125
+ id: z.ZodString;
2126
+ }, z.core.$strip>, z.ZodObject<{
2127
+ kind: z.ZodLiteral<"trigger">;
2128
+ id: z.ZodString;
2129
+ }, z.core.$strip>, z.ZodObject<{
2130
+ kind: z.ZodLiteral<"humanCheckpoint">;
2131
+ id: z.ZodString;
2132
+ }, z.core.$strip>, z.ZodObject<{
2133
+ kind: z.ZodLiteral<"externalResource">;
2134
+ id: z.ZodString;
2135
+ }, z.core.$strip>], "kind">;
2136
+ kind: z.ZodEnum<{
2137
+ triggers: "triggers";
2138
+ uses: "uses";
2139
+ approval: "approval";
2140
+ }>;
2141
+ to: z.ZodDiscriminatedUnion<[z.ZodObject<{
2142
+ kind: z.ZodLiteral<"system">;
2143
+ id: z.ZodString;
2144
+ }, z.core.$strip>, z.ZodObject<{
2145
+ kind: z.ZodLiteral<"resource">;
2146
+ id: z.ZodString;
2147
+ }, z.core.$strip>, z.ZodObject<{
2148
+ kind: z.ZodLiteral<"ontology">;
2149
+ id: z.ZodString;
2150
+ }, z.core.$strip>, z.ZodObject<{
2151
+ kind: z.ZodLiteral<"policy">;
2152
+ id: z.ZodString;
2153
+ }, z.core.$strip>, z.ZodObject<{
2154
+ kind: z.ZodLiteral<"role">;
2155
+ id: z.ZodString;
2156
+ }, z.core.$strip>, z.ZodObject<{
2157
+ kind: z.ZodLiteral<"trigger">;
2158
+ id: z.ZodString;
2159
+ }, z.core.$strip>, z.ZodObject<{
2160
+ kind: z.ZodLiteral<"humanCheckpoint">;
2161
+ id: z.ZodString;
2162
+ }, z.core.$strip>, z.ZodObject<{
2163
+ kind: z.ZodLiteral<"externalResource">;
2164
+ id: z.ZodString;
2165
+ }, z.core.$strip>], "kind">;
2166
+ systemPath: z.ZodOptional<z.ZodString>;
2167
+ required: z.ZodOptional<z.ZodBoolean>;
2168
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
2169
+ }, z.core.$strip>>>;
2170
+ }, z.core.$strip>>>;
2171
+ actions: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2172
+ id: z.ZodString;
2173
+ order: z.ZodNumber;
2174
+ label: z.ZodString;
2175
+ description: z.ZodOptional<z.ZodString>;
2176
+ scope: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"global">, z.ZodObject<{
2177
+ domain: z.ZodString;
2178
+ }, z.core.$strip>]>>;
2179
+ resourceId: z.ZodOptional<z.ZodString>;
2180
+ affects: z.ZodOptional<z.ZodArray<z.ZodString>>;
2181
+ invocations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2182
+ kind: z.ZodLiteral<"slash-command">;
2183
+ command: z.ZodString;
2184
+ toolFactory: z.ZodOptional<z.ZodString>;
2185
+ }, z.core.$strip>, z.ZodObject<{
2186
+ kind: z.ZodLiteral<"mcp-tool">;
2187
+ server: z.ZodString;
2188
+ name: z.ZodString;
2189
+ }, z.core.$strip>, z.ZodObject<{
2190
+ kind: z.ZodLiteral<"api-endpoint">;
2191
+ method: z.ZodEnum<{
2192
+ GET: "GET";
2193
+ POST: "POST";
2194
+ PATCH: "PATCH";
2195
+ DELETE: "DELETE";
2196
+ }>;
2197
+ path: z.ZodString;
2198
+ requestSchema: z.ZodOptional<z.ZodString>;
2199
+ responseSchema: z.ZodOptional<z.ZodString>;
2200
+ }, z.core.$strip>, z.ZodObject<{
2201
+ kind: z.ZodLiteral<"script-execution">;
2202
+ resourceId: z.ZodString;
2203
+ }, z.core.$strip>], "kind">>>;
2204
+ knowledge: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
2205
+ lifecycle: z.ZodDefault<z.ZodEnum<{
2206
+ deprecated: "deprecated";
2207
+ draft: "draft";
2208
+ beta: "beta";
2209
+ active: "active";
2210
+ archived: "archived";
2211
+ }>>;
2212
+ }, z.core.$strip>>>>;
2213
+ entities: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2214
+ id: z.ZodString;
2215
+ order: z.ZodNumber;
2216
+ label: z.ZodString;
2217
+ description: z.ZodOptional<z.ZodString>;
2218
+ ownedBySystemId: z.ZodString;
2219
+ table: z.ZodOptional<z.ZodString>;
2220
+ rowSchema: z.ZodOptional<z.ZodString>;
2221
+ stateCatalogId: z.ZodOptional<z.ZodString>;
2222
+ links: z.ZodOptional<z.ZodArray<z.ZodObject<{
2223
+ toEntity: z.ZodString;
2224
+ kind: z.ZodEnum<{
2225
+ "belongs-to": "belongs-to";
2226
+ "has-many": "has-many";
2227
+ "has-one": "has-one";
2228
+ "many-to-many": "many-to-many";
2229
+ }>;
2230
+ via: z.ZodOptional<z.ZodString>;
2231
+ label: z.ZodOptional<z.ZodString>;
2232
+ }, z.core.$strip>>>;
2233
+ }, z.core.$strip>>>>;
2234
+ policies: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2235
+ id: z.ZodString;
2236
+ order: z.ZodNumber;
2237
+ label: z.ZodString;
2238
+ description: z.ZodOptional<z.ZodString>;
2239
+ trigger: z.ZodDiscriminatedUnion<[z.ZodObject<{
2240
+ kind: z.ZodLiteral<"event">;
2241
+ eventId: z.ZodString;
2242
+ }, z.core.$strip>, z.ZodObject<{
2243
+ kind: z.ZodLiteral<"action-invocation">;
2244
+ actionId: z.ZodString;
2245
+ }, z.core.$strip>, z.ZodObject<{
2246
+ kind: z.ZodLiteral<"schedule">;
2247
+ cron: z.ZodString;
2248
+ }, z.core.$strip>, z.ZodObject<{
2249
+ kind: z.ZodLiteral<"manual">;
2250
+ }, z.core.$strip>], "kind">;
2251
+ predicate: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
2252
+ kind: z.ZodLiteral<"always">;
2253
+ }, z.core.$strip>, z.ZodObject<{
2254
+ kind: z.ZodLiteral<"expression">;
2255
+ expression: z.ZodString;
2256
+ }, z.core.$strip>, z.ZodObject<{
2257
+ kind: z.ZodLiteral<"threshold">;
2258
+ metric: z.ZodString;
2259
+ operator: z.ZodEnum<{
2260
+ lt: "lt";
2261
+ lte: "lte";
2262
+ eq: "eq";
2263
+ gte: "gte";
2264
+ gt: "gt";
2265
+ }>;
2266
+ value: z.ZodNumber;
2267
+ }, z.core.$strip>], "kind">>;
2268
+ actions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2269
+ kind: z.ZodLiteral<"require-approval">;
2270
+ roleId: z.ZodOptional<z.ZodString>;
2271
+ }, z.core.$strip>, z.ZodObject<{
2272
+ kind: z.ZodLiteral<"invoke-action">;
2273
+ actionId: z.ZodString;
2274
+ }, z.core.$strip>, z.ZodObject<{
2275
+ kind: z.ZodLiteral<"notify-role">;
2276
+ roleId: z.ZodString;
2277
+ }, z.core.$strip>, z.ZodObject<{
2278
+ kind: z.ZodLiteral<"block">;
2279
+ }, z.core.$strip>], "kind">>;
2280
+ appliesTo: z.ZodDefault<z.ZodObject<{
2281
+ systemIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
2282
+ actionIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
2283
+ resourceIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
2284
+ roleIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
2285
+ }, z.core.$strip>>;
2286
+ lifecycle: z.ZodDefault<z.ZodEnum<{
2287
+ deprecated: "deprecated";
2288
+ draft: "draft";
2289
+ beta: "beta";
2290
+ active: "active";
2291
+ archived: "archived";
2292
+ }>>;
2293
+ }, z.core.$strip>>>>;
2294
+ knowledge: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2295
+ id: z.ZodString;
2296
+ kind: z.ZodEnum<{
2297
+ playbook: "playbook";
2298
+ strategy: "strategy";
2299
+ reference: "reference";
2300
+ }>;
2301
+ title: z.ZodString;
2302
+ summary: z.ZodString;
2303
+ icon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
2304
+ message: "message";
2305
+ error: "error";
2306
+ agent: "agent";
2307
+ workflow: "workflow";
2308
+ "google-sheets": "google-sheets";
2309
+ dashboard: "dashboard";
2310
+ calendar: "calendar";
2311
+ sales: "sales";
2312
+ crm: "crm";
2313
+ "lead-gen": "lead-gen";
2314
+ projects: "projects";
2315
+ clients: "clients";
2316
+ operations: "operations";
2317
+ monitoring: "monitoring";
2318
+ knowledge: "knowledge";
2319
+ settings: "settings";
2320
+ admin: "admin";
2321
+ archive: "archive";
2322
+ business: "business";
2323
+ finance: "finance";
2324
+ platform: "platform";
2325
+ seo: "seo";
2326
+ playbook: "playbook";
2327
+ strategy: "strategy";
2328
+ reference: "reference";
2329
+ integration: "integration";
2330
+ database: "database";
2331
+ user: "user";
2332
+ team: "team";
2333
+ gmail: "gmail";
2334
+ attio: "attio";
2335
+ overview: "overview";
2336
+ "command-view": "command-view";
2337
+ "command-queue": "command-queue";
2338
+ pipeline: "pipeline";
2339
+ lists: "lists";
2340
+ resources: "resources";
2341
+ approve: "approve";
2342
+ reject: "reject";
2343
+ retry: "retry";
2344
+ edit: "edit";
2345
+ view: "view";
2346
+ launch: "launch";
2347
+ escalate: "escalate";
2348
+ promote: "promote";
2349
+ submit: "submit";
2350
+ email: "email";
2351
+ success: "success";
2352
+ warning: "warning";
2353
+ info: "info";
2354
+ pending: "pending";
2355
+ bolt: "bolt";
2356
+ building: "building";
2357
+ briefcase: "briefcase";
2358
+ apps: "apps";
2359
+ graph: "graph";
2360
+ shield: "shield";
2361
+ users: "users";
2362
+ "chart-bar": "chart-bar";
2363
+ search: "search";
2364
+ }>, z.ZodString]>>;
2365
+ externalUrl: z.ZodOptional<z.ZodString>;
2366
+ sourceFilePath: z.ZodOptional<z.ZodString>;
2367
+ body: z.ZodString;
2368
+ links: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodUnion<readonly [z.ZodObject<{
2369
+ target: z.ZodObject<{
2370
+ kind: z.ZodEnum<{
2371
+ knowledge: "knowledge";
2372
+ system: "system";
2373
+ action: "action";
2374
+ ontology: "ontology";
2375
+ role: "role";
2376
+ goal: "goal";
2377
+ resource: "resource";
2378
+ stage: "stage";
2379
+ "customer-segment": "customer-segment";
2380
+ offering: "offering";
2381
+ }>;
2382
+ id: z.ZodString;
2383
+ }, z.core.$strip>;
2384
+ }, z.core.$strip>, z.ZodObject<{
2385
+ nodeId: z.ZodUnion<readonly [z.ZodString, z.ZodTemplateLiteral<`ontology:${string}`>]>;
2386
+ }, z.core.$strip>]>, z.ZodTransform<{
2387
+ target: {
2388
+ kind: "knowledge" | "system" | "action" | "ontology" | "role" | "goal" | "resource" | "stage" | "customer-segment" | "offering";
2389
+ id: string;
2390
+ };
2391
+ nodeId: string;
2392
+ }, {
2393
+ nodeId: string;
2394
+ } | {
2395
+ target: {
2396
+ kind: "knowledge" | "system" | "action" | "ontology" | "role" | "goal" | "resource" | "stage" | "customer-segment" | "offering";
2397
+ id: string;
2398
+ };
2399
+ }>>>>;
2400
+ ownerIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
2401
+ updatedAt: z.ZodString;
2402
+ }, z.core.$strip>>>>;
2403
+ }, z.core.$strip>;
2404
+
2405
+ type OrganizationModel$1 = z.infer<typeof OrganizationModelSchema$1>;
2406
+
2407
+ /**
2408
+ * MetricsCollector
2409
+ * Tracks execution timing and ROI metrics
2410
+ */
2411
+ declare class MetricsCollector {
2412
+ private timings;
2413
+ private durationMs?;
2414
+ /**
2415
+ * Start a timer with a label
2416
+ */
2417
+ startTimer(label: string): void;
2418
+ /**
2419
+ * End a timer and calculate duration
2420
+ * If label is 'execution', stores duration for metrics summary
2421
+ */
2422
+ endTimer(label: string): number | null;
2423
+ /**
2424
+ * Build execution metrics summary with optional ROI calculation
2425
+ */
2426
+ buildExecutionMetrics(metricsConfig?: ResourceMetricsConfig): ExecutionMetricsSummary;
2427
+ }
2428
+
2429
+ interface BaseAICall {
2430
+ callSequence: number;
2431
+ callType: 'agent-reasoning' | 'agent-completion' | 'workflow-step' | 'tool' | 'other';
2432
+ model: LLMModel;
2433
+ inputTokens: number;
2434
+ outputTokens: number;
2435
+ costUsd: number;
2436
+ latencyMs: number;
2437
+ context?: AICallContext;
2438
+ }
2439
+ type AICallContext = AgentReasoningContext | AgentCompletionContext | WorkflowStepContext | ToolCallContext | OtherCallContext;
2440
+ interface AgentReasoningContext {
2441
+ type: 'agent-reasoning';
2442
+ iteration: number;
2443
+ actionsPlanned?: string[];
2444
+ sessionId?: string;
2445
+ turnNumber?: number;
2446
+ }
2447
+ interface AgentCompletionContext {
2448
+ type: 'agent-completion';
2449
+ attempt: 1 | 2;
2450
+ validationFailed?: boolean;
2451
+ sessionId?: string;
2452
+ turnNumber?: number;
2453
+ }
2454
+ interface WorkflowStepContext {
2455
+ type: 'workflow-step';
2456
+ stepId: string;
2457
+ stepName?: string;
2458
+ stepSequence?: number;
2459
+ }
2460
+ interface ToolCallContext {
2461
+ type: 'tool';
2462
+ toolName: string;
2463
+ parentIteration?: number;
2464
+ parentStepId?: string;
2465
+ }
2466
+ interface OtherCallContext {
2467
+ type: 'other';
2468
+ description?: string;
2469
+ metadata?: Record<string, unknown>;
2470
+ }
2471
+ type AICallRecord = BaseAICall;
2472
+ /**
2473
+ * Raw LLM usage data returned by adapters
2474
+ * Used as input to AIUsageCollector.record()
2475
+ */
2476
+ interface LLMUsageData {
2477
+ model: LLMModel;
2478
+ inputTokens: number;
2479
+ outputTokens: number;
2480
+ latencyMs: number;
2481
+ /** Actual cost from provider in USD (when available, e.g., OpenRouter) */
2482
+ cost?: number;
2483
+ }
2484
+ interface AIUsageSummary {
2485
+ model: LLMModel;
2486
+ totalInputTokens: number;
2487
+ totalOutputTokens: number;
2488
+ totalTokens: number;
2489
+ totalCostUsd: number;
2490
+ callCount: number;
2491
+ calls: AICallRecord[];
2492
+ }
2493
+ interface ExecutionMetricsSummary {
2494
+ durationMs?: number;
2495
+ automationSavingsUsd?: number;
2496
+ }
2497
+ interface ResourceMetricsConfig {
2498
+ estimatedManualMinutes: number;
2499
+ hourlyLaborRateUsd: number;
2500
+ confidenceLevel?: 'low' | 'medium' | 'high';
2501
+ notes?: string;
2502
+ }
2503
+
2504
+ /**
2505
+ * AIUsageCollector
2506
+ * Centralized token tracking that aggregates usage across all LLM calls in an execution
2507
+ */
2508
+ declare class AIUsageCollector {
2509
+ private model;
2510
+ private calls;
2511
+ private callSequence;
2512
+ /**
2513
+ * Record a single AI call with usage metrics
2514
+ *
2515
+ * @param usage - Token usage and latency data from LLM adapter
2516
+ * @param callType - Type discriminator (agent-reasoning, tool, etc.)
2517
+ * @param context - Optional typed context specific to callType
2518
+ */
2519
+ record(usage: LLMUsageData, callType?: BaseAICall['callType'], context?: AICallContext): void;
2520
+ /**
2521
+ * Get aggregated summary of all AI calls
2522
+ */
2523
+ getSummary(): AIUsageSummary;
2524
+ /**
2525
+ * Check if any usage has been recorded
2526
+ */
2527
+ hasUsage(): boolean;
2528
+ }
2529
+
2530
+ /**
2531
+ * Base Execution Engine type definitions
2532
+ * Core types shared across all Execution Engine resources
2533
+ */
2534
+
2535
+ /**
2536
+ * Immutable execution metadata
2537
+ * Represents complete execution identity (who, what, when, where)
2538
+ * Shared across ExecutionContext and ExecutionLoggerContext to eliminate field duplication
2539
+ */
2540
+ interface ExecutionMetadata {
2541
+ executionId: string;
2542
+ organizationId: string;
2543
+ organizationName: string;
2544
+ resourceId: string;
2545
+ userId?: string;
2546
+ sessionId?: string;
2547
+ sessionTurnNumber?: number;
2548
+ }
2549
+ /**
2550
+ * Unified message event type - covers all message types in sessions
2551
+ * Replaces separate SessionTurnMessages and AgentActivityEvent mechanisms
2552
+ */
2553
+ /**
2554
+ * Structured action metadata attached to assistant messages.
2555
+ * Frontend reads this instead of parsing text prefixes.
2556
+ */
2557
+ type AssistantAction = {
2558
+ kind: 'navigate';
2559
+ path: string;
2560
+ reason: string;
2561
+ } | {
2562
+ kind: 'update_filters';
2563
+ timeRange: string | null;
2564
+ statusFilter: string | null;
2565
+ searchQuery: string | null;
2566
+ };
2567
+ type MessageEvent = {
2568
+ type: 'user_message';
2569
+ text: string;
2570
+ } | {
2571
+ type: 'assistant_message';
2572
+ text: string;
2573
+ _action?: AssistantAction;
2574
+ } | {
2575
+ type: 'agent:started';
2576
+ } | {
2577
+ type: 'agent:completed';
2578
+ } | {
2579
+ type: 'agent:error';
2580
+ error: string;
2581
+ } | {
2582
+ type: 'agent:reasoning';
2583
+ iteration: number;
2584
+ reasoning: string;
2585
+ } | {
2586
+ type: 'agent:tool_call';
2587
+ toolName: string;
2588
+ args: Record<string, unknown>;
2589
+ } | {
2590
+ type: 'agent:tool_result';
2591
+ toolName: string;
2592
+ success: boolean;
2593
+ result?: unknown;
2594
+ error?: string;
2595
+ };
2596
+ /**
2597
+ * Execution context for all resources
2598
+ * Unified callback replaces SessionTurnMessages (removed)
2599
+ */
2600
+ interface ExecutionContext extends ExecutionMetadata {
2601
+ logger: IExecutionLogger;
2602
+ signal?: AbortSignal;
2603
+ onMessageEvent?: (event: MessageEvent) => Promise<void>;
2604
+ /** Called per iteration to write heartbeat + check stall status. Non-fatal if it throws. */
2605
+ onHeartbeat?: () => Promise<void>;
2606
+ aiUsageCollector?: AIUsageCollector;
2607
+ metricsCollector?: MetricsCollector;
2608
+ parentExecutionId?: string;
2609
+ executionDepth: number;
2610
+ credentialName?: string;
2611
+ store: Map<string, unknown>;
2612
+ }
2613
+ interface Contract {
2614
+ inputSchema: z.ZodSchema;
2615
+ outputSchema?: z.ZodSchema;
2616
+ }
2617
+
2618
+ /**
2619
+ * Tool definitions
2620
+ *
2621
+ * Tool interface used by agents and workflows.
2622
+ * Provides a universal interface for AI systems to interact with tools.
2623
+ */
2624
+
2625
+ /**
2626
+ * Options for tool execution
2627
+ * Provides named parameters for better API clarity and extensibility
2628
+ */
2629
+ interface ToolExecutionOptions {
2630
+ /** Tool input (validated against inputSchema before execution) */
2631
+ input: unknown;
2632
+ /** Execution context with multi-tenant isolation and observability (optional for simple tools, required for platform/integration tools) */
2633
+ executionContext?: ExecutionContext;
2634
+ /** Full iteration context for advanced tools (provides access to memoryManager, toolRegistry, logger, etc.) */
2635
+ iterationContext?: IterationContext;
2636
+ /** Abort signal for timeout/cancellation -- forward to fetch() calls for clean cancellation */
2637
+ signal?: AbortSignal;
2638
+ }
2639
+ /**
2640
+ * Tool interface for AI systems
2641
+ *
2642
+ * Used by:
2643
+ * - Agents: For agentic tool use (reasoning loop selects and executes tools)
2644
+ * - Workflows: For workflow step tool invocation (future)
2645
+ * - Platform tools: createApprovalTool(), createSchedulerTool()
2646
+ * - Integration tools: External API calls (Gmail, Slack, etc.)
2647
+ */
2648
+ interface Tool {
2649
+ name: string;
2650
+ description: string;
2651
+ inputSchema: z.ZodSchema;
2652
+ outputSchema: z.ZodSchema;
2653
+ execute: (options: ToolExecutionOptions) => Promise<unknown>;
2654
+ timeout?: number;
2655
+ }
2656
+
2657
+ /**
2658
+ * Supported integration types
2659
+ *
2660
+ * These represent the available integration adapters that can be used with tools.
2661
+ * Each integration type corresponds to an adapter implementation.
2662
+ *
2663
+ * Note: Concrete adapter implementations are deferred until needed.
2664
+ * This type provides compile-time safety and auto-completion for tool definitions.
2665
+ */
2666
+ type IntegrationType = 'gmail' | 'google-sheets' | 'slack' | 'github' | 'linear' | 'attio' | 'airtable' | 'salesforce' | 'hubspot' | 'stripe' | 'twilio' | 'sendgrid' | 'mailgun' | 'zapier' | 'webhook' | 'apify' | 'instantly' | 'resend' | 'signature-api' | 'dropbox' | 'anymailfinder' | 'tomba' | 'millionverifier';
2667
+
2668
+ /**
2669
+ * Resource Registry type definitions
2670
+ */
2671
+
2672
+ /**
2673
+ * Environment/deployment status for resources
2674
+ */
2675
+ type ResourceStatus = 'dev' | 'prod';
2676
+ /**
2677
+ * All resource types in the platform
2678
+ * Used as the discriminator field in ResourceDefinition
2679
+ */
2680
+ type ResourceType = 'agent' | 'workflow' | 'trigger' | 'integration' | 'external' | 'human';
2681
+ type ResourceSystemSummary = Pick<SystemEntry, 'id' | 'title' | 'description' | 'kind' | 'lifecycle'>;
2682
+ /**
2683
+ * Base interface for ALL platform resources
2684
+ * Shared by both executable (agents, workflows) and non-executable (triggers, integrations, etc.) resources
2685
+ */
2686
+ interface ResourceDefinition {
2687
+ /** Unique resource identifier */
2688
+ resourceId: string;
2689
+ /** Display name */
2690
+ name: string;
2691
+ /** Purpose and functionality description */
2692
+ description: string;
2693
+ /** Version for change tracking and evolution */
2694
+ version: string;
2695
+ /** Resource type discriminator */
2696
+ type: ResourceType;
2697
+ /** Environment/deployment status */
2698
+ status: ResourceStatus;
2699
+ /** Graph links to Organization Model nodes */
2700
+ links?: ResourceLink[];
2701
+ /** Infrastructure category for filtering */
2702
+ category?: ResourceCategory;
2703
+ /** Whether the agent supports multi-turn sessions (agents only) */
2704
+ sessionCapable?: boolean;
2705
+ /** Whether the resource is local (monorepo) or remote (externally deployed) */
2706
+ origin?: 'local' | 'remote';
2707
+ /** OM System membership — dot-separated system path (e.g. "sys.lead-gen"), when backed by a Resource descriptor */
2708
+ systemPath?: string;
2709
+ /** Display metadata for the owning OM System */
2710
+ system?: ResourceSystemSummary;
2711
+ /** Governance lifecycle status from the OM Resource descriptor */
2712
+ governanceStatus?: ResourceGovernanceStatus;
2713
+ /** Whether this resource is archived and should be excluded from registration and deployment */
2714
+ archived?: boolean;
2715
+ }
2716
+ /** Webhook provider identifiers */
2717
+ type WebhookProviderType = 'cal-com' | 'stripe' | 'signature-api' | 'instantly' | 'apify' | 'test';
2718
+ /** Webhook trigger configuration */
2719
+ interface WebhookTriggerConfig {
2720
+ /** Provider identifier */
2721
+ provider: WebhookProviderType;
2722
+ /** Event type for documentation (not used for matching - workflow handles routing) */
2723
+ event?: string;
2724
+ /** Optional filtering (e.g., specific form ID for Fillout) */
2725
+ filter?: Record<string, string>;
2726
+ /** References credential in credentials table for per-org webhook secrets */
2727
+ credentialName?: string;
2728
+ }
2729
+ /** Schedule trigger configuration */
2730
+ interface ScheduleTriggerConfig {
2731
+ /** Cron expression (e.g., '0 6 * * *') */
2732
+ cron: string;
2733
+ /** Optional timezone (default: UTC) */
2734
+ timezone?: string;
2735
+ }
2736
+ /** Event trigger configuration */
2737
+ interface EventTriggerConfig {
2738
+ /** Internal event type */
2739
+ eventType: string;
2740
+ /** Event source */
2741
+ source?: string;
2742
+ }
2743
+ /** Union of all trigger configs */
2744
+ type TriggerConfig = WebhookTriggerConfig | ScheduleTriggerConfig | EventTriggerConfig;
2745
+ /**
2746
+ * Trigger metadata - entry points that initiate resource execution
2747
+ *
2748
+ * Triggers represent how executions start: webhooks from external services,
2749
+ * scheduled cron jobs, platform events, or manual user actions.
2750
+ *
2751
+ * BREAKING CHANGES (2025-11-30):
2752
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
2753
+ * - Field renames: `id` -> `resourceId` (inherited), `type` -> `triggerType`
2754
+ * - Relationship rename: `invokes` -> `triggers` (unified vocabulary)
2755
+ * - New required fields: `version` (inherited), `type: 'trigger'` (inherited)
2756
+ * - triggers object now includes `externalResources` option
2757
+ *
2758
+ * @example
2759
+ * // TriggerDefinition - metadata only
2760
+ * {
2761
+ * resourceId: 'trigger-new-order',
2762
+ * type: 'trigger',
2763
+ * triggerType: 'webhook',
2764
+ * name: 'New Order',
2765
+ * description: 'Webhook from Shopify on new orders',
2766
+ * version: '1.0.0',
2767
+ * status: 'prod',
2768
+ * webhookPath: '/webhooks/shopify/orders'
2769
+ * }
2770
+ *
2771
+ * // Relationships declared in ResourceRelationships (not on TriggerDefinition):
2772
+ * // relationships: {
2773
+ * // 'trigger-new-order': { triggers: { workflows: ['order-fulfillment-workflow'] } }
2774
+ * // }
2775
+ */
2776
+ interface TriggerDefinition extends ResourceDefinition {
2777
+ /** Resource type discriminator (narrowed from base union) */
2778
+ type: 'trigger';
2779
+ /** Trigger mechanism type (renamed from 'type' to avoid collision with base type discriminator) */
2780
+ triggerType: 'webhook' | 'schedule' | 'manual' | 'event';
2781
+ /** Type-specific configuration */
2782
+ config?: TriggerConfig;
2783
+ /** For webhook triggers: path like '/webhooks/shopify/orders' */
2784
+ webhookPath?: string;
2785
+ /** For schedule triggers: cron expression like '0 6 * * *' */
2786
+ schedule?: string;
2787
+ /** For event triggers: event type like 'low-stock-alert' */
2788
+ eventType?: string;
2789
+ }
2790
+ /**
2791
+ * Integration metadata - external service connections
2792
+ *
2793
+ * References credentials table for actual connection. No connection status
2794
+ * stored here (queried at runtime from credentials table).
2795
+ *
2796
+ * BREAKING CHANGES (2025-11-30):
2797
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
2798
+ * - Field renames: `id` -> `resourceId` (inherited)
2799
+ * - New required field: `status` (inherited) - organizations must add status to all integrations
2800
+ * - New required field: `version` (inherited) - organizations must add version to all integrations
2801
+ * - New required field: `type: 'integration'` (inherited) - resource type discriminator
2802
+ *
2803
+ * @example
2804
+ * {
2805
+ * resourceId: 'integration-shopify-prod',
2806
+ * type: 'integration',
2807
+ * provider: 'shopify',
2808
+ * credentialName: 'shopify-prod',
2809
+ * name: 'Shopify Production',
2810
+ * description: 'E-commerce platform',
2811
+ * version: '1.0.0',
2812
+ * status: 'prod'
2813
+ * }
2814
+ */
2815
+ interface IntegrationDefinition extends ResourceDefinition {
2816
+ /** Resource type discriminator (narrowed from base union) */
2817
+ type: 'integration';
2818
+ /** OM descriptor that owns canonical identity and governance metadata. */
2819
+ resource?: Extract<ResourceEntry, {
2820
+ kind: 'integration';
2821
+ }>;
2822
+ /** Integration provider type */
2823
+ provider: IntegrationType;
2824
+ /** References credentials table (e.g., 'shopify-prod', 'zendesk-api') */
2825
+ credentialName: string;
2826
+ }
2827
+ /**
2828
+ * Explicit resource relationship declaration
2829
+ *
2830
+ * Single-direction only - Command View derives reverse relationships.
2831
+ * Agents/workflows declare what they trigger and use.
2832
+ *
2833
+ * @example
2834
+ * {
2835
+ * triggers: { workflows: ['order-fulfillment-workflow'] },
2836
+ * uses: { integrations: ['integration-shopify-prod', 'integration-postgres'] }
2837
+ * }
2838
+ */
2839
+ interface RelationshipDeclaration {
2840
+ /** Resources this resource triggers */
2841
+ triggers?: {
2842
+ /** Agent resourceIds this resource triggers */
2843
+ agents?: string[];
2844
+ /** Workflow resourceIds this resource triggers */
2845
+ workflows?: string[];
2846
+ };
2847
+ /** Integrations this resource uses */
2848
+ uses?: {
2849
+ /** Integration IDs this resource uses */
2850
+ integrations?: string[];
2851
+ };
2852
+ }
2853
+ /**
2854
+ * Resource relationships map
2855
+ * Maps resourceId to its relationship declarations
2856
+ *
2857
+ * @example
2858
+ * {
2859
+ * 'order-processor-agent': {
2860
+ * triggers: { workflows: ['order-fulfillment-workflow'] },
2861
+ * uses: { integrations: ['integration-shopify-prod'] }
2862
+ * }
2863
+ * }
2864
+ */
2865
+ type ResourceRelationships = Record<string, RelationshipDeclaration>;
2866
+ /**
2867
+ * External platform type
2868
+ * Supported third-party automation platforms
2869
+ */
2870
+ type ExternalPlatform = 'n8n' | 'make' | 'zapier' | 'other';
2871
+ /**
2872
+ * External automation resource metadata
2873
+ *
2874
+ * Represents workflows/automations running on third-party platforms
2875
+ * (n8n, Make, Zapier, etc.) for visualization in Command View.
2876
+ *
2877
+ * NOTE: This is metadata ONLY for visualization. No execution logic,
2878
+ * no API integration with external platforms, no status syncing.
2879
+ *
2880
+ * BREAKING CHANGES (2025-11-30):
2881
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
2882
+ * - Field renames: `id` -> `resourceId` (inherited)
2883
+ * - New required field: `version` (inherited) - organizations must add version to all external resources
2884
+ * - New required field: `type: 'external'` (inherited) - resource type discriminator
2885
+ * - REMOVED FIELD: `triggeredBy` - per relationship-consolidation design, all relationships are forward-only declarations
2886
+ *
2887
+ * @example
2888
+ * {
2889
+ * resourceId: 'external-n8n-order-sync',
2890
+ * type: 'external',
2891
+ * version: '1.0.0',
2892
+ * platform: 'n8n',
2893
+ * name: 'Shopify Order Sync',
2894
+ * description: 'Legacy n8n workflow for syncing Shopify orders',
2895
+ * status: 'prod',
2896
+ * platformUrl: 'https://n8n.client.com/workflow/123',
2897
+ * triggers: { workflows: ['order-fulfillment-workflow'] },
2898
+ * uses: { integrations: ['integration-shopify-prod'] }
2899
+ * }
2900
+ */
2901
+ interface ExternalResourceDefinition extends ResourceDefinition {
2902
+ /** Resource type discriminator (narrowed from base union) */
2903
+ type: 'external';
2904
+ /** Platform type */
2905
+ platform: ExternalPlatform;
2906
+ /** Link to external platform (e.g., n8n workflow editor URL) */
2907
+ platformUrl?: string;
2908
+ /** Platform's internal ID/reference */
2909
+ externalId?: string;
2910
+ /** What this external resource triggers (external -> internal) */
2911
+ triggers?: {
2912
+ /** Elevasis workflow resourceIds this external automation triggers */
2913
+ workflows?: string[];
2914
+ /** Elevasis agent resourceIds this external automation triggers */
2915
+ agents?: string[];
2916
+ };
2917
+ /** Integrations this external resource uses (shared credentials) */
2918
+ uses?: {
2919
+ /** Integration IDs this external automation uses */
2920
+ integrations?: string[];
2921
+ };
2922
+ }
2923
+ /**
2924
+ * Human Checkpoint definition - human decision points in automation
2925
+ *
2926
+ * Represents where human judgment is deployed in the automation landscape.
2927
+ * Tasks with matching command_queue_group are routed to this checkpoint.
2928
+ *
2929
+ * BREAKING CHANGES (2025-11-30):
2930
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
2931
+ * - Field renames: `id` -> `resourceId` (inherited)
2932
+ * - description is now REQUIRED (was optional) - organizations must add description to all human checkpoints
2933
+ * - New required field: `version` (inherited) - organizations must add version to all human checkpoints
2934
+ * - New required field: `type: 'human'` (inherited) - resource type discriminator
2935
+ *
2936
+ * @example
2937
+ * {
2938
+ * resourceId: 'sales-approval',
2939
+ * type: 'human',
2940
+ * name: 'Sales Approval Queue',
2941
+ * description: 'High-value order approvals for sales team',
2942
+ * version: '1.0.0',
2943
+ * status: 'prod',
2944
+ * requestedBy: { agents: ['order-processor-agent'] },
2945
+ * routesTo: { agents: ['order-fulfillment-agent'] }
2946
+ * }
2947
+ */
2948
+ interface HumanCheckpointDefinition extends ResourceDefinition {
2949
+ /** Resource type discriminator (narrowed from base union) */
2950
+ type: 'human';
2951
+ /** Resources that create tasks for this checkpoint */
2952
+ requestedBy?: {
2953
+ /** Agent resourceIds that request approval here */
2954
+ agents?: string[];
2955
+ /** Workflow resourceIds that request approval here */
2956
+ workflows?: string[];
2957
+ };
2958
+ /** Resources that receive approved decisions */
2959
+ routesTo?: {
2960
+ /** Agent resourceIds that handle approved tasks */
2961
+ agents?: string[];
2962
+ /** Workflow resourceIds that handle approved tasks */
2963
+ workflows?: string[];
2964
+ };
2965
+ }
2966
+
2967
+ declare const ResourceCategorySchema: z.ZodEnum<{
2968
+ diagnostic: "diagnostic";
2969
+ production: "production";
2970
+ internal: "internal";
2971
+ testing: "testing";
2972
+ }>;
2973
+ type ResourceCategory = z.infer<typeof ResourceCategorySchema>;
2974
+ type ResourceLink = Link;
2975
+
2976
+ /**
2977
+ * ResourceRegistry - Resource discovery and lookup
2978
+ * Handles resource definitions from OrganizationRegistry
2979
+ *
2980
+ * Features:
2981
+ * - Resource discovery by organization
2982
+ * - Startup validation (duplicate IDs, model configs, relationships, interface-schema alignment)
2983
+ * - Pre-serialization cache for instant API responses
2984
+ * - Command View data generation
2985
+ */
2986
+
2987
+ /**
2988
+ * Organization-specific resource collection
2989
+ *
2990
+ * Complete manifest of all automation resources for an organization.
2991
+ * Used by ResourceRegistry for discovery and Command View for visualization.
2992
+ */
2993
+ interface DeploymentSpec {
2994
+ /** Deployment version (semver) */
2995
+ version: string;
2996
+ /** Optional Organization Model governance catalog used for OM-code validation */
2997
+ organizationModel?: Partial<Pick<OrganizationModel$1, 'systems' | 'resources' | 'ontology' | 'topology' | 'roles' | 'policies' | 'entities' | 'actions'>>;
2998
+ /** Workflow definitions */
2999
+ workflows?: WorkflowDefinition[];
3000
+ /** Agent definitions */
3001
+ agents?: AgentDefinition[];
3002
+ /** Trigger definitions - entry points that initiate executions */
3003
+ triggers?: TriggerDefinition[];
3004
+ /** Integration definitions - external service connections */
3005
+ integrations?: IntegrationDefinition[];
3006
+ /** Explicit relationship declarations between resources */
3007
+ relationships?: ResourceRelationships;
3008
+ /** External automation resources (n8n, Make, Zapier, etc.) */
3009
+ externalResources?: ExternalResourceDefinition[];
3010
+ /** Human checkpoint definitions - human decision points in automation */
3011
+ humanCheckpoints?: HumanCheckpointDefinition[];
3012
+ }
3013
+
38
3014
  interface KnowledgeNodeInput {
39
3015
  id: string;
40
3016
  kind: string;
@@ -68,5 +3044,86 @@ interface ResolvedKnowledgeLayout {
68
3044
  }
69
3045
  declare function runKnowledgeCodegen(layout: ResolvedKnowledgeLayout): Promise<void>;
70
3046
 
71
- export { generateKnowledgeBodies, generateKnowledgeNodes, generateKnowledgeNodesTs, readKnowledgeNodeMdx, runKnowledgeCodegen };
72
- export type { CodegenResult, GenerateKnowledgeNodesOptions, GenerateKnowledgeNodesResult, KnowledgeCodegenNode, KnowledgeKind, KnowledgeNodeInput, KnowledgeSearchEntry, ResolvedKnowledgeLayout };
3047
+ declare const ResourceOntologyBindingSchema = z
3048
+ .object({
3049
+ actions: z.array(OntologyIdSchema).optional(),
3050
+ primaryAction: OntologyIdSchema.optional(),
3051
+ reads: z.array(OntologyIdSchema).optional(),
3052
+ writes: z.array(OntologyIdSchema).optional(),
3053
+ usesCatalogs: z.array(OntologyIdSchema).optional(),
3054
+ emits: z.array(OntologyIdSchema).optional(),
3055
+ /**
3056
+ * Optional typed contract binding for this resource's workflow I/O.
3057
+ * Each ref is a `package/subpath#ExportName` string that resolves to a
3058
+ * Zod schema in `@repo/elevasis-core` (or the consumer's equivalent package).
3059
+ *
3060
+ * Absence of this field preserves all existing behavior — it is additive + optional.
3061
+ * Tier-1 validation (schema.ts): ref-string shape only (browser-safe, no imports).
3062
+ * Tier-2 validation (om:verify): intra-package typed-map resolution asserts ZodType.
3063
+ */
3064
+ contract: z
3065
+ .object({
3066
+ input: ContractRefSchema.optional(),
3067
+ output: ContractRefSchema.optional()
3068
+ })
3069
+ .optional()
3070
+ })
3071
+ .superRefine((binding, ctx) => {
3072
+ if (binding.primaryAction === undefined) return
3073
+ if (binding.actions?.includes(binding.primaryAction)) return
3074
+
3075
+ ctx.addIssue({
3076
+ code: z.ZodIssueCode.custom,
3077
+ path: ['primaryAction'],
3078
+ message: 'Resource ontology primaryAction must be included in actions'
3079
+ })
3080
+ })
3081
+
3082
+ declare const WorkflowResourceEntrySchema = ResourceEntryBaseSchema.extend({
3083
+ kind: z.literal('workflow'),
3084
+ emits: z.array(EventEmissionDescriptorSchema).optional()
3085
+ })
3086
+
3087
+ declare const IntegrationResourceEntrySchema = ResourceEntryBaseSchema.extend({
3088
+ kind: z.literal('integration'),
3089
+ provider: z.string().trim().min(1).max(100)
3090
+ })
3091
+
3092
+ declare const OrganizationModelSchema = OrganizationModelSchemaBase.superRefine(refineOrganizationModel)
3093
+
3094
+ type OrganizationModel = z.infer<typeof OrganizationModelSchema>
3095
+ type OrganizationModelResourceOntologyBinding = z.infer<typeof ResourceOntologyBindingSchema>
3096
+ type OrganizationModelWorkflowResourceEntry = z.infer<typeof WorkflowResourceEntrySchema>
3097
+ type OrganizationModelIntegrationResourceEntry = z.infer<typeof IntegrationResourceEntrySchema>
3098
+
3099
+ type ResourceOntologyBindingResolver = (resourceId: string) => OrganizationModelResourceOntologyBinding | undefined;
3100
+ type WorkflowResourceDescriptorResolver = (resourceId: string) => OrganizationModelWorkflowResourceEntry;
3101
+ type IntegrationResourceDescriptorResolver = (resourceId: string) => OrganizationModelIntegrationResourceEntry;
3102
+ interface ProjectDeploymentSpecOptions {
3103
+ version: string;
3104
+ organizationModel: OrganizationModel;
3105
+ workflows: WorkflowDefinition[];
3106
+ integrations?: IntegrationDefinition[];
3107
+ agents?: DeploymentSpec['agents'];
3108
+ triggers?: DeploymentSpec['triggers'];
3109
+ externalResources?: DeploymentSpec['externalResources'];
3110
+ humanCheckpoints?: DeploymentSpec['humanCheckpoints'];
3111
+ getWorkflowResourceDescriptor: WorkflowResourceDescriptorResolver;
3112
+ getIntegrationResourceDescriptor: IntegrationResourceDescriptorResolver;
3113
+ getResourceOntologyBinding?: ResourceOntologyBindingResolver;
3114
+ }
3115
+ declare function toSdkResourceDescriptor<TResource extends {
3116
+ id: string;
3117
+ systemPath: string;
3118
+ }>(resource: TResource, getResourceOntologyBinding?: ResourceOntologyBindingResolver): TResource & Partial<OrganizationModelResourceOntologyBinding> & {
3119
+ systemId: string;
3120
+ };
3121
+ declare function withPlatformResourceDescriptor(workflow: WorkflowDefinition, getWorkflowResourceDescriptor: WorkflowResourceDescriptorResolver, getResourceOntologyBinding?: ResourceOntologyBindingResolver): WorkflowDefinition;
3122
+ declare function withPlatformResourceDescriptors(workflows: WorkflowDefinition[], getWorkflowResourceDescriptor: WorkflowResourceDescriptorResolver, getResourceOntologyBinding?: ResourceOntologyBindingResolver): WorkflowDefinition[];
3123
+ declare function withPlatformIntegrationResourceDescriptor(integration: IntegrationDefinition, getIntegrationResourceDescriptor: IntegrationResourceDescriptorResolver, getResourceOntologyBinding?: ResourceOntologyBindingResolver): IntegrationDefinition;
3124
+ declare function withPlatformIntegrationResourceDescriptors(integrations: IntegrationDefinition[], getIntegrationResourceDescriptor: IntegrationResourceDescriptorResolver, getResourceOntologyBinding?: ResourceOntologyBindingResolver): IntegrationDefinition[];
3125
+ declare function projectTopologyRelationships(model: Pick<OrganizationModel, 'resources' | 'topology'>): ResourceRelationships;
3126
+ declare function projectDeploymentSpec(options: ProjectDeploymentSpecOptions): DeploymentSpec;
3127
+
3128
+ export { generateKnowledgeBodies, generateKnowledgeNodes, generateKnowledgeNodesTs, projectDeploymentSpec, projectTopologyRelationships, readKnowledgeNodeMdx, runKnowledgeCodegen, toSdkResourceDescriptor, withPlatformIntegrationResourceDescriptor, withPlatformIntegrationResourceDescriptors, withPlatformResourceDescriptor, withPlatformResourceDescriptors };
3129
+ export type { CodegenResult, DeploymentSpec, GenerateKnowledgeNodesOptions, GenerateKnowledgeNodesResult, IntegrationDefinition, IntegrationResourceDescriptorResolver, KnowledgeCodegenNode, KnowledgeKind, KnowledgeNodeInput, KnowledgeSearchEntry, ProjectDeploymentSpecOptions, ResolvedKnowledgeLayout, ResourceOntologyBindingResolver, ResourceRelationships, WorkflowDefinition, WorkflowResourceDescriptorResolver };