@elevasis/sdk 1.48.0 → 1.50.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 (56) hide show
  1. package/dist/chunk-MGZZ4HL4.js +4399 -0
  2. package/dist/chunk-VYWGWJRW.js +130 -0
  3. package/dist/chunk-YJDXRHNP.js +7901 -0
  4. package/dist/cli.cjs +949 -281
  5. package/dist/index.d.ts +1031 -48
  6. package/dist/index.js +2 -7597
  7. package/dist/node/index.d.ts +3 -3675
  8. package/dist/node/index.js +2 -124
  9. package/dist/test-utils/index.d.ts +2 -12051
  10. package/dist/test-utils/index.js +113 -27891
  11. package/dist/worker/index.d.ts +548 -12264
  12. package/dist/worker/index.js +3 -7400
  13. package/package.json +12 -4
  14. package/reference/_navigation.md +4 -4
  15. package/reference/_reference-manifest.json +1 -1
  16. package/reference/core/index.mdx +6 -4
  17. package/reference/index.mdx +11 -5
  18. package/reference/packages/core/src/README.md +46 -44
  19. package/reference/packages/core/src/content/README.md +16 -12
  20. package/reference/rules/agent-start-here.md +1 -1
  21. package/reference/rules/frontend.md +3 -1
  22. package/reference/rules/package-taxonomy.md +7 -5
  23. package/reference/rules/ui.md +31 -5
  24. package/reference/rules/vibe-intents.md +2 -2
  25. package/reference/rules/vibe.md +30 -10
  26. package/reference/scaffold/recipes/extend-content.md +82 -3
  27. package/reference/scaffold/recipes/gate-by-feature-or-admin.md +8 -6
  28. package/reference/scaffold/ui/feature-flags-and-gating.md +11 -1
  29. package/reference/sdk/cli-management.mdx +284 -139
  30. package/reference/sdk/cli.mdx +136 -88
  31. package/reference/sdk/define-builders.mdx +1 -1
  32. package/reference/sdk/deployment/command-center.mdx +2 -2
  33. package/reference/sdk/deployment/index.mdx +24 -7
  34. package/reference/sdk/exports.mdx +4 -4
  35. package/reference/sdk/framework/agent.mdx +4 -3
  36. package/reference/sdk/framework/index.mdx +1 -1
  37. package/reference/sdk/framework/project-structure.mdx +34 -23
  38. package/reference/sdk/framework/tutorial-system.mdx +1 -1
  39. package/reference/sdk/getting-started.mdx +25 -52
  40. package/reference/sdk/index.mdx +3 -3
  41. package/reference/sdk/platform-tools/adapters-integration.mdx +1 -1
  42. package/reference/sdk/platform-tools/adapters-platform.mdx +1 -1
  43. package/reference/sdk/platform-tools/type-safety.mdx +1 -1
  44. package/reference/sdk/resources/patterns.mdx +10 -11
  45. package/reference/sdk/resources/types.mdx +15 -9
  46. package/reference/sdk/templates/data-enrichment.mdx +1 -1
  47. package/reference/sdk/templates/email-sender.mdx +1 -1
  48. package/reference/sdk/templates/index.mdx +47 -47
  49. package/reference/sdk/templates/lead-scorer.mdx +1 -1
  50. package/reference/sdk/templates/pdf-generator.mdx +42 -24
  51. package/reference/sdk/templates/recurring-job.mdx +20 -15
  52. package/reference/sdk/templates/text-classifier.mdx +1 -1
  53. package/reference/sdk/templates/web-scraper.mdx +9 -5
  54. package/reference/sdk/troubleshooting.mdx +72 -1
  55. package/reference/ui/exports.mdx +1 -1
  56. package/reference/ui/index.mdx +2 -2
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ export { AgentResourceDescriptorResolver, DeploymentSpec, IntegrationDefinition, IntegrationResourceDescriptorResolver, ProjectDeploymentSpecOptions, ResourceOntologyBindingResolver, ResourceRelationships, WorkflowDefinition, WorkflowResourceDescriptorResolver, projectDeploymentSpec, projectTopologyRelationships, toSdkResourceDescriptor, withPlatformAgentResourceDescriptor, withPlatformAgentResourceDescriptors, withPlatformIntegrationResourceDescriptor, withPlatformIntegrationResourceDescriptors, withPlatformResourceDescriptor, withPlatformResourceDescriptors } from '@elevasis/sdk';
2
2
 
3
3
  type KnowledgeKind = 'playbook' | 'strategy' | 'reference';
4
4
  interface KnowledgeCodegenNode {
@@ -37,3645 +37,6 @@ declare function generateKnowledgeNodesTs(options: {
37
37
  }): string;
38
38
  declare function generateKnowledgeNodes(options: GenerateKnowledgeNodesOptions): GenerateKnowledgeNodesResult;
39
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
- /**
267
- * Time a unit of work and emit the single `action` event it produces.
268
- *
269
- * Captures `Date.now()` immediately before and after `work()`, then emits the same event
270
- * `action()` would -- collapsing the repeated `startTime = Date.now(); ...work...; endTime =
271
- * Date.now(); action(actionType, message, iteration, startTime, endTime, endTime - startTime)`
272
- * boilerplate found at memory-write and tool-result call sites into a single call.
273
- *
274
- * `actionType` may be a function of the work's result for the rare call site where the emitted
275
- * type itself depends on the outcome (e.g. "deleted" vs "delete of a missing key") -- most
276
- * callers just pass a fixed string.
277
- *
278
- * **Throw behavior:** if `work` throws synchronously or its promise rejects, the error propagates
279
- * to the caller UNCHANGED and NO `action` event is emitted -- there is no completed unit of work
280
- * to describe, so this deliberately does not swallow the error or log a synthetic failure action.
281
- * A call site that needs an error-path log keeps calling `action()` manually from its own
282
- * `catch` block.
283
- *
284
- * @param actionType - Action type string, or a function deriving it from the result
285
- * @param iteration - Current iteration number
286
- * @param work - The unit of work to time (sync or async)
287
- * @param message - Builds the human-readable message from the work's result
288
- * @returns The value returned by `work`
289
- */
290
- timed<T>(actionType: string | ((result: T) => string), iteration: number, work: () => Promise<T> | T, message: (result: T) => string): Promise<T>;
291
- toolCall(toolName: string, iteration: number, startTime: number, endTime: number, duration: number, success: boolean, error?: string, input?: unknown, output?: unknown): void;
292
- }
293
-
294
- type LogContext = WorkflowLogContext | AgentLogContext;
295
- interface IExecutionLogger {
296
- debug(message: string, context?: LogContext): void;
297
- info(message: string, context?: LogContext): void;
298
- warn(message: string, context?: LogContext): void;
299
- error(message: string, context?: LogContext): void;
300
- }
301
-
302
- declare const ResourceGovernanceStatusSchema: z.ZodEnum<{
303
- active: "active";
304
- deprecated: "deprecated";
305
- archived: "archived";
306
- }>;
307
- declare const ResourceOntologyBindingSchema: z.ZodObject<{
308
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
309
- primaryAction: z.ZodOptional<z.ZodString>;
310
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
311
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
312
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
313
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
314
- contract: z.ZodOptional<z.ZodObject<{
315
- input: z.ZodOptional<z.ZodString>;
316
- output: z.ZodOptional<z.ZodString>;
317
- }, z.core.$strip>>;
318
- }, z.core.$strip>;
319
- declare const WorkflowResourceEntrySchema: z.ZodObject<{
320
- id: z.ZodString;
321
- order: z.ZodDefault<z.ZodNumber>;
322
- systemPath: z.ZodString;
323
- title: z.ZodOptional<z.ZodString>;
324
- description: z.ZodOptional<z.ZodString>;
325
- ownerRoleId: z.ZodOptional<z.ZodString>;
326
- status: z.ZodEnum<{
327
- active: "active";
328
- deprecated: "deprecated";
329
- archived: "archived";
330
- }>;
331
- ontology: z.ZodOptional<z.ZodObject<{
332
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
333
- primaryAction: z.ZodOptional<z.ZodString>;
334
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
335
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
336
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
337
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
338
- contract: z.ZodOptional<z.ZodObject<{
339
- input: z.ZodOptional<z.ZodString>;
340
- output: z.ZodOptional<z.ZodString>;
341
- }, z.core.$strip>>;
342
- }, z.core.$strip>>;
343
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
344
- path: z.ZodString;
345
- role: z.ZodEnum<{
346
- entrypoint: "entrypoint";
347
- handler: "handler";
348
- schema: "schema";
349
- test: "test";
350
- docs: "docs";
351
- config: "config";
352
- }>;
353
- symbol: z.ZodOptional<z.ZodString>;
354
- description: z.ZodOptional<z.ZodString>;
355
- }, z.core.$strip>>>;
356
- kind: z.ZodLiteral<"workflow">;
357
- emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
358
- eventKey: z.ZodString;
359
- label: z.ZodString;
360
- payloadSchema: z.ZodOptional<z.ZodString>;
361
- lifecycle: z.ZodOptional<z.ZodEnum<{
362
- active: "active";
363
- deprecated: "deprecated";
364
- draft: "draft";
365
- beta: "beta";
366
- archived: "archived";
367
- }>>;
368
- }, z.core.$strip>>>;
369
- }, z.core.$strip>;
370
- declare const AgentResourceEntrySchema: z.ZodObject<{
371
- id: z.ZodString;
372
- order: z.ZodDefault<z.ZodNumber>;
373
- systemPath: z.ZodString;
374
- title: z.ZodOptional<z.ZodString>;
375
- description: z.ZodOptional<z.ZodString>;
376
- ownerRoleId: z.ZodOptional<z.ZodString>;
377
- status: z.ZodEnum<{
378
- active: "active";
379
- deprecated: "deprecated";
380
- archived: "archived";
381
- }>;
382
- ontology: z.ZodOptional<z.ZodObject<{
383
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
384
- primaryAction: z.ZodOptional<z.ZodString>;
385
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
386
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
387
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
388
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
389
- contract: z.ZodOptional<z.ZodObject<{
390
- input: z.ZodOptional<z.ZodString>;
391
- output: z.ZodOptional<z.ZodString>;
392
- }, z.core.$strip>>;
393
- }, z.core.$strip>>;
394
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
395
- path: z.ZodString;
396
- role: z.ZodEnum<{
397
- entrypoint: "entrypoint";
398
- handler: "handler";
399
- schema: "schema";
400
- test: "test";
401
- docs: "docs";
402
- config: "config";
403
- }>;
404
- symbol: z.ZodOptional<z.ZodString>;
405
- description: z.ZodOptional<z.ZodString>;
406
- }, z.core.$strip>>>;
407
- kind: z.ZodLiteral<"agent">;
408
- agentKind: z.ZodEnum<{
409
- platform: "platform";
410
- orchestrator: "orchestrator";
411
- specialist: "specialist";
412
- utility: "utility";
413
- }>;
414
- actsAsRoleId: z.ZodOptional<z.ZodString>;
415
- sessionCapable: z.ZodBoolean;
416
- invocations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
417
- kind: z.ZodLiteral<"slash-command">;
418
- command: z.ZodString;
419
- toolFactory: z.ZodOptional<z.ZodString>;
420
- }, z.core.$strip>, z.ZodObject<{
421
- kind: z.ZodLiteral<"mcp-tool">;
422
- server: z.ZodString;
423
- name: z.ZodString;
424
- }, z.core.$strip>, z.ZodObject<{
425
- kind: z.ZodLiteral<"api-endpoint">;
426
- method: z.ZodEnum<{
427
- GET: "GET";
428
- POST: "POST";
429
- PATCH: "PATCH";
430
- DELETE: "DELETE";
431
- }>;
432
- path: z.ZodString;
433
- requestSchema: z.ZodOptional<z.ZodString>;
434
- responseSchema: z.ZodOptional<z.ZodString>;
435
- }, z.core.$strip>, z.ZodObject<{
436
- kind: z.ZodLiteral<"script-execution">;
437
- resourceId: z.ZodString;
438
- }, z.core.$strip>], "kind">>>;
439
- emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
440
- eventKey: z.ZodString;
441
- label: z.ZodString;
442
- payloadSchema: z.ZodOptional<z.ZodString>;
443
- lifecycle: z.ZodOptional<z.ZodEnum<{
444
- active: "active";
445
- deprecated: "deprecated";
446
- draft: "draft";
447
- beta: "beta";
448
- archived: "archived";
449
- }>>;
450
- }, z.core.$strip>>>;
451
- }, z.core.$strip>;
452
- declare const IntegrationResourceEntrySchema: z.ZodObject<{
453
- id: z.ZodString;
454
- order: z.ZodDefault<z.ZodNumber>;
455
- systemPath: z.ZodString;
456
- title: z.ZodOptional<z.ZodString>;
457
- description: z.ZodOptional<z.ZodString>;
458
- ownerRoleId: z.ZodOptional<z.ZodString>;
459
- status: z.ZodEnum<{
460
- active: "active";
461
- deprecated: "deprecated";
462
- archived: "archived";
463
- }>;
464
- ontology: z.ZodOptional<z.ZodObject<{
465
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
466
- primaryAction: z.ZodOptional<z.ZodString>;
467
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
468
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
469
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
470
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
471
- contract: z.ZodOptional<z.ZodObject<{
472
- input: z.ZodOptional<z.ZodString>;
473
- output: z.ZodOptional<z.ZodString>;
474
- }, z.core.$strip>>;
475
- }, z.core.$strip>>;
476
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
477
- path: z.ZodString;
478
- role: z.ZodEnum<{
479
- entrypoint: "entrypoint";
480
- handler: "handler";
481
- schema: "schema";
482
- test: "test";
483
- docs: "docs";
484
- config: "config";
485
- }>;
486
- symbol: z.ZodOptional<z.ZodString>;
487
- description: z.ZodOptional<z.ZodString>;
488
- }, z.core.$strip>>>;
489
- kind: z.ZodLiteral<"integration">;
490
- provider: z.ZodString;
491
- }, z.core.$strip>;
492
- declare const ResourceEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
493
- id: z.ZodString;
494
- order: z.ZodDefault<z.ZodNumber>;
495
- systemPath: z.ZodString;
496
- title: z.ZodOptional<z.ZodString>;
497
- description: z.ZodOptional<z.ZodString>;
498
- ownerRoleId: z.ZodOptional<z.ZodString>;
499
- status: z.ZodEnum<{
500
- active: "active";
501
- deprecated: "deprecated";
502
- archived: "archived";
503
- }>;
504
- ontology: z.ZodOptional<z.ZodObject<{
505
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
506
- primaryAction: z.ZodOptional<z.ZodString>;
507
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
508
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
509
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
510
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
511
- contract: z.ZodOptional<z.ZodObject<{
512
- input: z.ZodOptional<z.ZodString>;
513
- output: z.ZodOptional<z.ZodString>;
514
- }, z.core.$strip>>;
515
- }, z.core.$strip>>;
516
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
517
- path: z.ZodString;
518
- role: z.ZodEnum<{
519
- entrypoint: "entrypoint";
520
- handler: "handler";
521
- schema: "schema";
522
- test: "test";
523
- docs: "docs";
524
- config: "config";
525
- }>;
526
- symbol: z.ZodOptional<z.ZodString>;
527
- description: z.ZodOptional<z.ZodString>;
528
- }, z.core.$strip>>>;
529
- kind: z.ZodLiteral<"workflow">;
530
- emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
531
- eventKey: z.ZodString;
532
- label: z.ZodString;
533
- payloadSchema: z.ZodOptional<z.ZodString>;
534
- lifecycle: z.ZodOptional<z.ZodEnum<{
535
- active: "active";
536
- deprecated: "deprecated";
537
- draft: "draft";
538
- beta: "beta";
539
- archived: "archived";
540
- }>>;
541
- }, z.core.$strip>>>;
542
- }, z.core.$strip>, z.ZodObject<{
543
- id: z.ZodString;
544
- order: z.ZodDefault<z.ZodNumber>;
545
- systemPath: z.ZodString;
546
- title: z.ZodOptional<z.ZodString>;
547
- description: z.ZodOptional<z.ZodString>;
548
- ownerRoleId: z.ZodOptional<z.ZodString>;
549
- status: z.ZodEnum<{
550
- active: "active";
551
- deprecated: "deprecated";
552
- archived: "archived";
553
- }>;
554
- ontology: z.ZodOptional<z.ZodObject<{
555
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
556
- primaryAction: z.ZodOptional<z.ZodString>;
557
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
558
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
559
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
560
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
561
- contract: z.ZodOptional<z.ZodObject<{
562
- input: z.ZodOptional<z.ZodString>;
563
- output: z.ZodOptional<z.ZodString>;
564
- }, z.core.$strip>>;
565
- }, z.core.$strip>>;
566
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
567
- path: z.ZodString;
568
- role: z.ZodEnum<{
569
- entrypoint: "entrypoint";
570
- handler: "handler";
571
- schema: "schema";
572
- test: "test";
573
- docs: "docs";
574
- config: "config";
575
- }>;
576
- symbol: z.ZodOptional<z.ZodString>;
577
- description: z.ZodOptional<z.ZodString>;
578
- }, z.core.$strip>>>;
579
- kind: z.ZodLiteral<"agent">;
580
- agentKind: z.ZodEnum<{
581
- platform: "platform";
582
- orchestrator: "orchestrator";
583
- specialist: "specialist";
584
- utility: "utility";
585
- }>;
586
- actsAsRoleId: z.ZodOptional<z.ZodString>;
587
- sessionCapable: z.ZodBoolean;
588
- invocations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
589
- kind: z.ZodLiteral<"slash-command">;
590
- command: z.ZodString;
591
- toolFactory: z.ZodOptional<z.ZodString>;
592
- }, z.core.$strip>, z.ZodObject<{
593
- kind: z.ZodLiteral<"mcp-tool">;
594
- server: z.ZodString;
595
- name: z.ZodString;
596
- }, z.core.$strip>, z.ZodObject<{
597
- kind: z.ZodLiteral<"api-endpoint">;
598
- method: z.ZodEnum<{
599
- GET: "GET";
600
- POST: "POST";
601
- PATCH: "PATCH";
602
- DELETE: "DELETE";
603
- }>;
604
- path: z.ZodString;
605
- requestSchema: z.ZodOptional<z.ZodString>;
606
- responseSchema: z.ZodOptional<z.ZodString>;
607
- }, z.core.$strip>, z.ZodObject<{
608
- kind: z.ZodLiteral<"script-execution">;
609
- resourceId: z.ZodString;
610
- }, z.core.$strip>], "kind">>>;
611
- emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
612
- eventKey: z.ZodString;
613
- label: z.ZodString;
614
- payloadSchema: z.ZodOptional<z.ZodString>;
615
- lifecycle: z.ZodOptional<z.ZodEnum<{
616
- active: "active";
617
- deprecated: "deprecated";
618
- draft: "draft";
619
- beta: "beta";
620
- archived: "archived";
621
- }>>;
622
- }, z.core.$strip>>>;
623
- }, z.core.$strip>, z.ZodObject<{
624
- id: z.ZodString;
625
- order: z.ZodDefault<z.ZodNumber>;
626
- systemPath: z.ZodString;
627
- title: z.ZodOptional<z.ZodString>;
628
- description: z.ZodOptional<z.ZodString>;
629
- ownerRoleId: z.ZodOptional<z.ZodString>;
630
- status: z.ZodEnum<{
631
- active: "active";
632
- deprecated: "deprecated";
633
- archived: "archived";
634
- }>;
635
- ontology: z.ZodOptional<z.ZodObject<{
636
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
637
- primaryAction: z.ZodOptional<z.ZodString>;
638
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
639
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
640
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
641
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
642
- contract: z.ZodOptional<z.ZodObject<{
643
- input: z.ZodOptional<z.ZodString>;
644
- output: z.ZodOptional<z.ZodString>;
645
- }, z.core.$strip>>;
646
- }, z.core.$strip>>;
647
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
648
- path: z.ZodString;
649
- role: z.ZodEnum<{
650
- entrypoint: "entrypoint";
651
- handler: "handler";
652
- schema: "schema";
653
- test: "test";
654
- docs: "docs";
655
- config: "config";
656
- }>;
657
- symbol: z.ZodOptional<z.ZodString>;
658
- description: z.ZodOptional<z.ZodString>;
659
- }, z.core.$strip>>>;
660
- kind: z.ZodLiteral<"integration">;
661
- provider: z.ZodString;
662
- }, z.core.$strip>, z.ZodObject<{
663
- id: z.ZodString;
664
- order: z.ZodDefault<z.ZodNumber>;
665
- systemPath: z.ZodString;
666
- title: z.ZodOptional<z.ZodString>;
667
- description: z.ZodOptional<z.ZodString>;
668
- ownerRoleId: z.ZodOptional<z.ZodString>;
669
- status: z.ZodEnum<{
670
- active: "active";
671
- deprecated: "deprecated";
672
- archived: "archived";
673
- }>;
674
- ontology: z.ZodOptional<z.ZodObject<{
675
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
676
- primaryAction: z.ZodOptional<z.ZodString>;
677
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
678
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
679
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
680
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
681
- contract: z.ZodOptional<z.ZodObject<{
682
- input: z.ZodOptional<z.ZodString>;
683
- output: z.ZodOptional<z.ZodString>;
684
- }, z.core.$strip>>;
685
- }, z.core.$strip>>;
686
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
687
- path: z.ZodString;
688
- role: z.ZodEnum<{
689
- entrypoint: "entrypoint";
690
- handler: "handler";
691
- schema: "schema";
692
- test: "test";
693
- docs: "docs";
694
- config: "config";
695
- }>;
696
- symbol: z.ZodOptional<z.ZodString>;
697
- description: z.ZodOptional<z.ZodString>;
698
- }, z.core.$strip>>>;
699
- kind: z.ZodLiteral<"script">;
700
- language: z.ZodEnum<{
701
- shell: "shell";
702
- sql: "sql";
703
- typescript: "typescript";
704
- python: "python";
705
- }>;
706
- source: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
707
- file: z.ZodString;
708
- }, z.core.$strip>]>;
709
- }, z.core.$strip>], "kind">;
710
- type ResourceGovernanceStatus = z.infer<typeof ResourceGovernanceStatusSchema>;
711
- type WorkflowResourceEntry = z.infer<typeof WorkflowResourceEntrySchema>;
712
- type AgentResourceEntry = z.infer<typeof AgentResourceEntrySchema>;
713
- type ResourceEntry = z.infer<typeof ResourceEntrySchema>;
714
-
715
- /**
716
- * Memory type definitions
717
- * Types for agent memory management with semantic entry types
718
- */
719
- /**
720
- * Semantic memory entry types
721
- * Use-case agnostic types that describe the purpose of each entry
722
- * Memory types mirror action types for clarity and filtering
723
- */
724
- type MemoryEntryType = 'context' | 'input' | 'reasoning' | 'tool-result' | 'error';
725
- /**
726
- * Who authored an entry's content.
727
- *
728
- * This is what lets the assembled prompt tell framework-authored text apart from text that
729
- * originated outside the trust boundary. `'framework'` content is ours; the other three are not
730
- * and are rendered inside the JSON data envelope (see `MemoryManager.toContextParts`).
731
- */
732
- type MemoryEntrySource = 'framework' | 'user' | 'tool' | 'model';
733
- /**
734
- * Memory entry - represents a single entry in agent memory
735
- * Stored in agent memory, translated by adapters to vendor-specific formats
736
- */
737
- interface MemoryEntry {
738
- type: MemoryEntryType;
739
- content: string;
740
- timestamp: number;
741
- turnNumber: number | null;
742
- iterationNumber: number | null;
743
- /**
744
- * Provenance. **Optional on purpose** — `undefined` means unknown, which is what every
745
- * pre-existing snapshot and every not-yet-redeployed tenant bundle produces. Read sites MUST
746
- * test `== null`, never `=== undefined`: the `inTurnScope` predicate in `manager.ts` is the
747
- * cautionary precedent, where a `=== undefined` check silently dropped every `null`-stamped
748
- * entry. `isMemoryEntry` is deliberately NOT tightened to require this field; doing so would
749
- * make every stored snapshot fail validation, and `restoreSessionMemory` fails open by
750
- * starting the agent with empty memory rather than throwing.
751
- */
752
- source?: MemoryEntrySource;
753
- /**
754
- * Which tool produced this entry. Set on `tool-result` entries so the model can tell N parallel
755
- * results apart -- the framework instructs batching independent tool calls in one iteration, and
756
- * an anonymous result is unattributable the moment two land in the same iteration. `addToolError`
757
- * already carries this (folded into its `content` JSON); this is the same fact for the success
758
- * path, carried as a real field instead of prose the caller has to parse back out.
759
- */
760
- toolName?: string;
761
- /**
762
- * Present when `truncateContent` cut this entry's `content` to fit its token budget. A sibling
763
- * field, never text appended into `content` -- the notice used to be spliced into the string
764
- * itself, which could (and did) land inside a JSON string literal `truncateContent` had just cut
765
- * open, breaking `JSON.parse` on the far end. Absent means never truncated.
766
- */
767
- truncated?: {
768
- omittedTokens: number;
769
- };
770
- /**
771
- * Prompt-injection warning types found in `content`, screened once here -- when the entry is
772
- * written -- instead of by re-scanning the whole accumulated envelope on every iteration it gets
773
- * re-sent for (`screenRequest`'s `data-envelope` slot used to do exactly that). Empty array means
774
- * screened and clean; `undefined` means never screened (entries that bypass `addToHistory`/`set`,
775
- * or pre-existing snapshots from before this field existed).
776
- */
777
- warnings?: string[];
778
- }
779
- /**
780
- * Agent memory - Self-orchestrated memory with session + working storage
781
- * Agent has full control over what persists, framework handles auto-compaction
782
- */
783
- interface AgentMemory {
784
- /**
785
- * Session memory - Persists for session/conversation duration
786
- * Never auto-trimmed by framework
787
- * Agent-managed key-value store for critical information
788
- * Agent provides strings, framework wraps in MemoryEntry
789
- */
790
- sessionMemory: Record<string, MemoryEntry>;
791
- /**
792
- * Working memory - Execution history
793
- * Automatically compacted by framework when needed
794
- * Agent doesn't control compaction
795
- */
796
- history: MemoryEntry[];
797
- }
798
- /**
799
- * Memory status for agent awareness
800
- */
801
- interface MemoryStatus {
802
- sessionMemoryKeys: number;
803
- sessionMemoryLimit: number;
804
- sessionMemoryTokens: number;
805
- sessionMemoryTokenLimit: number;
806
- /**
807
- * History tokens as a percentage of `historyBudget` — history ALONE, not history plus session
808
- * memory. It previously reported the combined total under this name, so session memory growth
809
- * read as history pressure and triggered history compaction that could not relieve it.
810
- */
811
- historyPercent: number;
812
- /**
813
- * Tokens the history entries **in scope for the requested turn** occupy — the same set
814
- * `toContextParts` puts in the envelope. Equal to `storedHistoryTokens` when `getStatus` is
815
- * called without a turn.
816
- *
817
- * This is the number the model is shown, and it is scoped because the model is handed a scoped
818
- * set. Counting the whole cross-turn array here meant the framing quoted the size of a store
819
- * while the envelope beside it carried one turn's worth of it.
820
- */
821
- historyTokens: number;
822
- /**
823
- * Tokens the **entire** history array occupies, across every turn the session snapshot restored.
824
- *
825
- * This is what compaction measures, because compaction trims that array. Scoping it to a turn
826
- * would let the store grow without bound whenever the current turn happened to be small.
827
- */
828
- storedHistoryTokens: number;
829
- /** `storedHistoryTokens` as a percentage of `historyBudget`. The auto-compaction trigger. */
830
- storedHistoryPercent: number;
831
- historyBudget: number;
832
- }
833
-
834
- /**
835
- * Types for the schema compiler. `compile.ts` walks a `JsonSchema` once, driven entirely by a
836
- * `ProviderDialect`, and every server adapter compiles through it.
837
- */
838
- /**
839
- * What happened to `strict` on a request, recorded per call rather than inferred.
840
- *
841
- * `applied` and `notAttempted` are the two states that a refusal-only field cannot tell apart --
842
- * both leave `strictRefusalReasons` empty. Recording the verdict positively is what makes "was
843
- * this agent's output actually enforced?" answerable from an `ai_calls` row.
844
- */
845
- type StrictStatus = 'applied' | 'refused' | 'compileRejected' | 'notAttempted';
846
- /**
847
- * A JSON Schema node, typed enough to be useful without pretending to validate the spec.
848
- *
849
- * The compiler has to accept schemas that arrive OUTSIDE the strict subset (that is the whole
850
- * point of a dialect that can refuse or rewrite them) as well as the `$ref`/`$defs`/`const`/
851
- * `$schema` shapes the strict subset has no vocabulary for at all. The index signature exists
852
- * because tenant schemas carry keywords (`minLength`, `pattern`, `minimum`, ...) this compiler
853
- * drops or refuses on, and they still need somewhere to type-check while they pass through
854
- * `Object.entries`.
855
- */
856
- interface JsonSchema {
857
- type?: string | string[];
858
- /**
859
- * The value is `JsonSchema | undefined`, not `JsonSchema`, because a property really can be
860
- * declared with nothing describing it. `buildIterationResponseSchema` emits one per tool as
861
- * `input: tool.inputSchema`, and `ToolDefinition.inputSchema` is typed `unknown` -- a tool
862
- * deployed without one puts `undefined` under a key that exists.
863
- *
864
- * Both readers already handle it: `compileSchema` passes each value through `convertNode`, which
865
- * takes `unknown`, and `collectErrors` opens with `if (!schema || typeof schema !== 'object')`
866
- * above a comment naming this exact case. Declaring the value non-optional only hid that they
867
- * were right to.
868
- */
869
- properties?: Record<string, JsonSchema | undefined>;
870
- items?: JsonSchema;
871
- anyOf?: JsonSchema[];
872
- oneOf?: JsonSchema[];
873
- allOf?: JsonSchema[];
874
- required?: string[];
875
- additionalProperties?: boolean | JsonSchema;
876
- minItems?: number;
877
- maxItems?: number;
878
- format?: string;
879
- enum?: unknown[];
880
- const?: unknown;
881
- description?: string;
882
- default?: unknown;
883
- $ref?: string;
884
- $defs?: Record<string, JsonSchema>;
885
- definitions?: Record<string, JsonSchema>;
886
- $schema?: string;
887
- $id?: string;
888
- $anchor?: string;
889
- /**
890
- * OpenAPI's nullability spelling, which is not JSON Schema's. It is declared because
891
- * `response-schema-validator.ts` READS it (`schemaPermitsNull`) -- Google's schema dialect is
892
- * OpenAPI-derived, so a schema that reaches the validator can carry it. No dialect in `compile.ts`
893
- * writes or rewrites it; the canonical spelling this compiler emits is `type: ['x', 'null']`.
894
- */
895
- nullable?: boolean;
896
- [key: string]: unknown;
897
- }
898
-
899
- /**
900
- * Generic LLM Types
901
- * Universal interfaces for LLM interaction across all resource types
902
- */
903
-
904
- /**
905
- * Standard chat message format
906
- * Compatible with OpenAI, Anthropic, and other providers
907
- */
908
- interface LLMMessage {
909
- role: 'system' | 'user' | 'assistant';
910
- content: string;
911
- /**
912
- * Marks this message as the end of a byte-stable prefix worth an Anthropic cache breakpoint,
913
- * beyond the one the system prompt already gets. Anthropic's rule is "everything up to and
914
- * including the marked block is cached", so this only ever needs to sit on ONE message -- the
915
- * last one before content that changes.
916
- *
917
- * `buildAgentMessages` sets it on the last replayed prior-turn message: conversation history is
918
- * fixed for the whole turn (only the framing/envelope after it grow per iteration), so it is the
919
- * only part of a session agent's messages, besides the system prompt, that is ever byte-identical
920
- * call to call. A hint rather than a mechanism deliberately -- an adapter that does not read it
921
- * (OpenAI, OpenRouter, any test stub) just ignores the extra property; only the Anthropic adapter
922
- * turns it into a wire `cache_control` block.
923
- */
924
- cacheBreakpoint?: boolean;
925
- /**
926
- * Prompt-injection warning types already found in this message's content, when the caller has
927
- * already screened it and wants `screenRequest` to use that verdict instead of re-scanning.
928
- *
929
- * Set only on the data-envelope message by `buildAgentMessages`, sourced from
930
- * `MemoryContextParts.envelopeWarnings` -- itself an aggregate of `MemoryEntry.warnings` stamped
931
- * once per fragment when it entered memory. `undefined` means "not pre-screened"; `screenRequest`
932
- * falls back to scanning the content directly, which is what every other message role/slot still
933
- * does and what a hand-built message (tests, other callers) gets by default.
934
- */
935
- envelopeWarnings?: string[];
936
- }
937
- /**
938
- * Generic LLM generation request
939
- * Usable by agents, workflows, tools, etc.
940
- */
941
- interface LLMGenerateRequest {
942
- messages: LLMMessage[];
943
- /**
944
- * JSON Schema for structured output. Omit it for an unstructured call.
945
- *
946
- * Absence is what turns validation off: `runGeneratePipeline` skips `validateResponseSchema`
947
- * entirely when this is missing, whatever `validationSchema` holds.
948
- *
949
- * This was declared `responseSchema: unknown` -- required, and typed as nothing. `unknown` admits
950
- * `undefined`, so "required" only ever forced the KEY to be written, and `createLLMCallTool`
951
- * writes it as `undefined` on every call where the model supplies no usable schema. There was no
952
- * type error available for that, and three separate layers re-derived the same nullability at
953
- * runtime under three different rules -- truthiness in the pipeline, an object check in the
954
- * validator, and a `'type'`-key check in the tool. Because the pipeline's was truthiness, `null`,
955
- * `0` and `''` all quietly meant "no structured output" while the type insisted a schema was
956
- * mandatory. Optional-and-typed is what those three were compensating for.
957
- */
958
- responseSchema?: JsonSchema;
959
- /** Maximum output tokens per LLM call. NOT the model's context window — see ModelInfo.maxTokens for that. */
960
- maxOutputTokens?: number;
961
- temperature?: number;
962
- topP?: number;
963
- signal?: AbortSignal;
964
- /**
965
- * Caller-supplied acceptance step (Wave D2b / decision A15). A pipeline-aware adapter
966
- * (`UniversalLLMAdapter`, via `runGeneratePipeline`) runs this once per retry attempt, right
967
- * after the response has passed `responseSchema` validation. Throw to reject the attempt --
968
- * rejection is classified exactly like a thrown `LLMResponseParseError` from
969
- * `validateResponseSchema`: retryable, no circuit-breaker verdict, and the attempt is recorded as
970
- * a failure (`ai_calls` validation-failure row) rather than a clean success. Returning normally
971
- * (including `undefined`) accepts the response.
972
- *
973
- * Optional, and a HINT rather than a dependency -- an adapter that does not read this field
974
- * simply ignores it, so a caller must not assume it ran:
975
- * - A bare test-stub `LLMAdapter` (many exist in this codebase) does not invoke it.
976
- * - `PostMessageLLMAdapter` (`packages/sdk/src/worker/llm-adapter.ts`) cannot forward it at all --
977
- * functions cannot be structured-cloned across the worker `postMessage` boundary, so its
978
- * `params` object is built from an explicit allowlist that omits `accept`. The field is dropped
979
- * before `postMessage` is ever called (no `DataCloneError`), and the parent-side handler that
980
- * fulfils the call (`tool-dispatcher.ts`'s `case 'llm'`) rebuilds its own `LLMGenerateRequest`
981
- * from that allowlisted payload, so there is nothing to forward even in principle. This is the
982
- * path every deployed org-bundle agent and the `command-center-assistant` static module run
983
- * through today -- `accept` does not reach their retry loop.
984
- *
985
- * This is not a validation mechanism on its own: it does not decide whether output is acceptable,
986
- * the caller's function does, by throwing or not. `callLLMForAgentIteration`
987
- * (`execution/engine/agent/reasoning/adapters/agent-adapter-helpers.ts`) passes its Zod parse of
988
- * the iteration response as this field, so a malformed-but-schema-valid iteration is re-sampled
989
- * inside the retry loop instead of losing the turn -- for the in-process callers that can see it.
990
- */
991
- accept?: (output: unknown) => void;
992
- /**
993
- * The schema the RESPONSE is validated against, when that must differ from the schema the
994
- * provider was asked to sample against. Defaults to `responseSchema` when omitted.
995
- *
996
- * **This does not affect what is sent to the provider.** `responseSchema` remains the only schema
997
- * an adapter puts on the wire; this one is read solely by `runGeneratePipeline`'s validation step.
998
- * Whether validation happens at all is still decided by `responseSchema` -- a request with no
999
- * `responseSchema` is unstructured and stays unvalidated, whatever this field holds.
1000
- *
1001
- * A caller may legitimately ACCEPT A SUPERSET of what it ASKS FOR -- a document that validates a
1002
- * response more leniently than the one the provider was asked to sample against. No caller in this
1003
- * codebase supplies one today (agent iterations validate with a single Zod parse instead, see
1004
- * `agent-adapter-helpers.ts`), but the mechanism stays: `validateResponseSchema` does not descend
1005
- * into `anyOf`/`oneOf` regardless of which document is supplied here, so this field only ever
1006
- * changes which top-level/required/type keywords are checked, never which acceptance contract a
1007
- * union is read as.
1008
- *
1009
- * Unlike `accept` above, this is DATA. It is structured-cloneable, so it survives the worker
1010
- * `postMessage` boundary that drops `accept`: `PostMessageLLMAdapter` forwards it in its params
1011
- * allowlist and `tool-dispatcher.ts`'s `case 'llm'` puts it back on the `LLMGenerateRequest` it
1012
- * rebuilds parent-side. That is why a divergence expressible as a schema belongs here rather than
1013
- * in a callback -- deployed org-bundle agents run on the far side of that boundary.
1014
- */
1015
- validationSchema?: JsonSchema;
1016
- }
1017
- /**
1018
- * Generic LLM generation response
1019
- * `usage`, `cost`, `strictStatus` and `strictRefusalReasons` are observability fields. They are
1020
- * **read** by `UniversalLLMAdapter` and lifted onto the `ai_calls` row; they are **not removed**.
1021
- * The wrapper returns the base adapter's response object as-is, so a caller can observe all four.
1022
- * Earlier revisions of this file claimed they were stripped — they never were.
1023
- */
1024
- interface LLMGenerateResponse<T = unknown> {
1025
- output: T;
1026
- usage?: {
1027
- inputTokens: number;
1028
- outputTokens: number;
1029
- totalTokens: number;
1030
- /**
1031
- * Anthropic-only: input tokens served from the prompt cache (`cache_read_input_tokens`), billed
1032
- * at 0.1x the base input rate. Optional so OpenAI/OpenRouter usage objects, which never report
1033
- * this, stay valid -- absent means "this provider doesn't report it," not "zero were read."
1034
- */
1035
- cacheReadInputTokens?: number;
1036
- /**
1037
- * Anthropic-only: input tokens written to the prompt cache this call
1038
- * (`cache_creation_input_tokens`), billed at 1.25x the base input rate. Same optionality
1039
- * rationale as `cacheReadInputTokens`.
1040
- */
1041
- cacheCreationInputTokens?: number;
1042
- };
1043
- cost?: number;
1044
- /**
1045
- * What actually happened to `strict` on the request that produced this response.
1046
- *
1047
- * - `applied` — the request carried `strict: true` and the grammar was in effect
1048
- * - `refused` — `compileSchema` could not express the schema, so the request went out unstrict
1049
- * - `compileRejected` — the schema passed `compileSchema` but the provider's grammar compiler
1050
- * rejected it at request time, and the call was retried unstrict
1051
- * - `notAttempted` — the adapter did not send `strict` on this call
1052
- *
1053
- * This exists because `strictRefusalReasons` alone cannot answer the question. Its absence means
1054
- * "strict held" OR "nothing ever tried", and a prod run that recorded zero refusals while
1055
- * returning an array-typed field as a string is exactly the case where the difference matters.
1056
- *
1057
- * **Do not read this as "provider X never sends strict."** It describes one call, not an adapter.
1058
- * A previous revision of this comment enumerated OpenAI, Google and OpenRouter as adapters that
1059
- * never send `strict`, which was false for OpenRouter — it sends `strict: true` whenever the
1060
- * schema compiles, and separately reports `notAttempted`. That producer bug is still live; the
1061
- * fix is to make the value a return of schema compilation rather than a per-adapter literal.
1062
- * `MockAdapter` sets no value at all, so absence does not imply `notAttempted` either.
1063
- *
1064
- * Observability only — `UniversalLLMAdapter` lifts it onto the `ai_calls` row. It is not removed
1065
- * from the response.
1066
- */
1067
- strictStatus?: StrictStatus;
1068
- /**
1069
- * Why this call went out WITHOUT `strict`, on an adapter that tried to send it with one.
1070
- *
1071
- * The detail behind a `refused` / `compileRejected` `strictStatus` — the short, stable reason
1072
- * strings `compileSchema` computes. Read `strictStatus` to answer "was it enforced"; read this
1073
- * to answer "why not".
1074
- *
1075
- * Observability only — `UniversalLLMAdapter` lifts it onto the `ai_calls` row. It is not removed
1076
- * from the response.
1077
- */
1078
- strictRefusalReasons?: string[];
1079
- }
1080
- /**
1081
- * LLM Adapter interface
1082
- * Generic primitive for all resource types (agents, workflows, tools)
1083
- *
1084
- * Design principles:
1085
- * - Single method: generate() - the core LLM primitive
1086
- * - Generic return type for type safety
1087
- * - Universal format (not agent-specific)
1088
- * - Standard message-based input (OpenAI-compatible)
1089
- */
1090
- interface LLMAdapter {
1091
- /**
1092
- * Generate structured output from prompt using LLM
1093
- *
1094
- * @param request - Generation request with messages and response schema
1095
- * @returns Generated output (typed) with optional usage metadata
1096
- */
1097
- generate<T = unknown>(request: LLMGenerateRequest): Promise<LLMGenerateResponse<T>>;
1098
- }
1099
-
1100
- /**
1101
- * Model Configuration
1102
- * Centralized model information, configuration, options, constraints, and validation
1103
- * Single source of truth for all model-related definitions
1104
- * Update manually when pricing changes or new models are added
1105
- */
1106
-
1107
- /**
1108
- * Supported Open AI models (direct SDK access)
1109
- */
1110
- type OpenAIModel = 'gpt-5' | 'gpt-5.4-mini' | 'gpt-5.4-nano';
1111
- /**
1112
- * Supported OpenRouter models (explicit union for type safety)
1113
- */
1114
- type OpenRouterModel = 'openrouter/z-ai/glm-5';
1115
- /**
1116
- * Supported Anthropic models (direct SDK access via @anthropic-ai/sdk)
1117
- */
1118
- type AnthropicModel = 'claude-opus-5' | 'claude-sonnet-5' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5';
1119
- /** Supported LLM models */
1120
- type LLMModel = OpenAIModel | OpenRouterModel | AnthropicModel | 'mock';
1121
- /**
1122
- * GPT-5 model options schema
1123
- */
1124
- declare const GPT5OptionsSchema: z.ZodObject<{
1125
- reasoning_effort: z.ZodOptional<z.ZodEnum<{
1126
- minimal: "minimal";
1127
- low: "low";
1128
- medium: "medium";
1129
- high: "high";
1130
- }>>;
1131
- verbosity: z.ZodOptional<z.ZodEnum<{
1132
- low: "low";
1133
- medium: "medium";
1134
- high: "high";
1135
- }>>;
1136
- }, z.core.$strip>;
1137
- /**
1138
- * OpenRouter model options schema
1139
- * OpenRouter-specific options for routing and transforms
1140
- */
1141
- declare const OpenRouterOptionsSchema: z.ZodObject<{
1142
- transforms: z.ZodOptional<z.ZodArray<z.ZodString>>;
1143
- route: z.ZodOptional<z.ZodEnum<{
1144
- fallback: "fallback";
1145
- }>>;
1146
- }, z.core.$strip>;
1147
- /**
1148
- * Anthropic model options schema
1149
- * Currently empty - future options must be added per supported model family
1150
- */
1151
- declare const AnthropicOptionsSchema: z.ZodObject<{}, z.core.$strict>;
1152
- /**
1153
- * Infer TypeScript types from schemas
1154
- */
1155
- type GPT5Options = z.infer<typeof GPT5OptionsSchema>;
1156
- type MockOptions = Record<string, never>;
1157
- type OpenRouterOptions = z.infer<typeof OpenRouterOptionsSchema>;
1158
- type AnthropicOptions = z.infer<typeof AnthropicOptionsSchema>;
1159
- type ModelSpecificOptions = GPT5Options | MockOptions | OpenRouterOptions | AnthropicOptions;
1160
- /**
1161
- * Model configuration for LLM execution
1162
- * Belongs in resource definition (AgentDefinition, WorkflowDefinition, etc.)
1163
- */
1164
- interface ModelConfig {
1165
- model: LLMModel;
1166
- provider: 'openai' | 'anthropic' | 'openrouter' | 'mock';
1167
- apiKey: string;
1168
- temperature?: number;
1169
- /** Maximum output tokens per LLM call. NOT the model's context window — see ModelInfo.maxTokens for that. */
1170
- maxOutputTokens?: number;
1171
- topP?: number;
1172
- /**
1173
- * Model-specific options (flat structure)
1174
- * Options are model-specific, not vendor-specific
1175
- * Available options defined in MODEL_INFO per model
1176
- * Validated at build time via validateModelOptions()
1177
- */
1178
- modelOptions?: ModelSpecificOptions;
1179
- }
1180
-
1181
- /**
1182
- * Memory Manager
1183
- * Encapsulates all memory operations with ultra-simple agent API
1184
- * Agent provides strings, framework handles wrapping and auto-compaction
1185
- */
1186
-
1187
- /**
1188
- * The framework's own framing message and the untrusted data envelope, as separate strings.
1189
- *
1190
- * They are separate because the model must be able to tell them apart, and so must the input
1191
- * sanitizer: the framing is framework-authored and trusted, the envelope is not. Concatenating
1192
- * them — which is what this replaced — made that distinction undecidable at the adapter and left
1193
- * the framework's own section headers inside the region scanned for delimiter injection.
1194
- */
1195
- interface MemoryContextParts {
1196
- /** Framework-authored. Memory status and a description of the envelope. Carries NO stored content. */
1197
- framing: string;
1198
- /** Every stored fragment, JSON-encoded. Untrusted. */
1199
- dataEnvelope: string;
1200
- /**
1201
- * Union of prompt-injection warning types already found across every fragment `dataEnvelope`
1202
- * actually carries this call, aggregated from verdicts stamped once when each fragment entered
1203
- * memory (see `MemoryEntry.warnings`) rather than by re-scanning `dataEnvelope`'s text on every
1204
- * iteration it gets rebuilt for. Elided fragments (see `ENVELOPE_FULL_RESULT_WINDOW`) contribute
1205
- * nothing here — their original content isn't what gets sent once they're stubbed.
1206
- *
1207
- * This is metadata about the envelope, not part of it: folding a detector's own finding into the
1208
- * model-visible JSON would hand a would-be attacker — plausibly the same person on the other end
1209
- * of a session conversation — direct feedback on which pattern tripped. A caller wiring this up
1210
- * (`screenRequest`'s `data-envelope` slot is the one that currently re-scans instead of reading
1211
- * this) should treat it exactly the way `screenRequest` already treats cross-turn history: it
1212
- * warns, but whether it blocks is that caller's decision to make, not this one's.
1213
- *
1214
- * Optional (not just possibly-empty): the fixture literals in `agent/reasoning/**` tests build
1215
- * `MemoryContextParts` by hand without it, and requiring it would make this signature's landing
1216
- * a forced edit across files this change does not otherwise touch.
1217
- */
1218
- envelopeWarnings?: string[];
1219
- }
1220
- /**
1221
- * Memory Manager - Agent memory orchestration
1222
- * Provides ultra-simple API for agents (strings only)
1223
- * Handles automatic compaction and token management
1224
- */
1225
- declare class MemoryManager {
1226
- private memory;
1227
- private constraints;
1228
- private logger?;
1229
- /**
1230
- * Rolling correction for `estimateTokens`'s bias, learned from real provider usage.
1231
- * `undefined` until the first `recordActualUsage` call -- the cold-start state, where
1232
- * `estimate()` returns the raw `estimateTokens` output unscaled. See `recordActualUsage`.
1233
- */
1234
- private tokenCorrectionFactor?;
1235
- constructor(memory: AgentMemory, constraints?: AgentConstraints, logger?: AgentScopedLogger | undefined);
1236
- /**
1237
- * Record how far `estimateTokens` was from reality on a real provider call, and roll it into a
1238
- * correction applied to every estimate this instance makes from here on -- `getStatus`'s three
1239
- * token fields and `enforceSessionMemoryTokenLimit`'s eviction check, which is what
1240
- * `autoCompact`/`enforceHardLimits` actually decide compaction from (C3 / Wave M3).
1241
- *
1242
- * `estimateTokens` is `chars / 3.5` -- a constant-ratio guess with no knowledge of JSON escaping,
1243
- * key overhead, or real tokenizer behaviour. Every provider call already returns an EXACT count
1244
- * (`usage.inputTokens`) that reaches `ai_calls` and is then dropped; this is where it stops being
1245
- * dropped, without replacing the estimator outright -- a cold session still needs SOME number
1246
- * before its first real call completes, so the estimator stays the prior and this only corrects
1247
- * it once real data exists.
1248
- *
1249
- * `estimatedRequestTokens` must be `estimateTokens` applied to the SAME text `actualInputTokens`
1250
- * was billed for -- the whole assembled request (system prompt, tools, conversation history, the
1251
- * envelope, everything), not just what this class itself emits. `estimateTokens`'s bias is a
1252
- * property of the heuristic, not of which slice of the request it is pointed at, so measuring it
1253
- * against the full request (visible to the caller, not to this class) and applying the result to
1254
- * this class's own estimates (which can only ever see its own slice) is a fair trade -- one ratio,
1255
- * calibrated on real data, standing in for a per-segment breakdown nothing needs.
1256
- *
1257
- * Exponential moving average, not a straight replace: a single call's ratio is noisy, and a
1258
- * straight replace lets one outlier swing every compaction decision made afterward. Each new
1259
- * observation gets 30% weight, converging within a handful of calls without chasing one spike.
1260
- */
1261
- recordActualUsage(estimatedRequestTokens: number, actualInputTokens: number): void;
1262
- /** `estimateTokens`, scaled by the learned correction once one exists. See `recordActualUsage`. */
1263
- private estimate;
1264
- /**
1265
- * Set session memory entry (agent provides string, framework wraps it)
1266
- * @param key - Session memory key
1267
- * @param content - String content from agent
1268
- */
1269
- set(key: string, content: string, source?: MemoryEntrySource): void;
1270
- /**
1271
- * Get session memory entry content
1272
- * @param key - Session memory key
1273
- * @returns String content if exists, undefined otherwise
1274
- */
1275
- get(key: string): string | undefined;
1276
- /**
1277
- * Delete session memory entry
1278
- * @param key - Key to delete
1279
- * @returns True if key existed and was deleted
1280
- */
1281
- delete(key: string): boolean;
1282
- /**
1283
- * Add entry to history (called by framework after tool results, reasoning, etc.)
1284
- * Automatically sets timestamp to current time
1285
- * @param entry - Memory entry to add (without timestamp - auto-generated)
1286
- */
1287
- addToHistory(entry: Omit<MemoryEntry, 'timestamp'>): void;
1288
- /**
1289
- * Auto-compact history if approaching token budget
1290
- * Uses preserve-anchors strategy: keep first + recent entries
1291
- */
1292
- autoCompact(): void;
1293
- /**
1294
- * Enforce hard limits (called before LLM request)
1295
- * Emergency fallback if agent exceeds limits
1296
- */
1297
- enforceHardLimits(): void;
1298
- /**
1299
- * Evict oldest session memory entries until the pool fits its token limit.
1300
- *
1301
- * Key count and token count are different constraints: 25 short keys are fine, 25 large ones
1302
- * are not. Eviction is oldest-first by timestamp, matching the key-count path, and always
1303
- * leaves at least one entry so a single oversized key degrades to "one key" rather than to
1304
- * "memory silently emptied".
1305
- *
1306
- * The running total is **recomputed** from the survivors rather than decremented per entry.
1307
- * `getStatus` estimates the pool as a ceiling of the joined sum, and a per-entry decrement is a
1308
- * sum of ceilings — the larger of the two by up to one token per key. The running total therefore
1309
- * fell faster than the pool did, and the loop could exit reporting a fit while the very next
1310
- * `getStatus` still read over the limit. Recomputing makes the loop's exit condition and the
1311
- * number it is judged by the same expression. The pool is capped at `MAX_SESSION_MEMORY_KEYS`
1312
- * entries, so the extra passes are bounded and cheap.
1313
- */
1314
- private enforceSessionMemoryTokenLimit;
1315
- /**
1316
- * Get history length (for logging and introspection)
1317
- * @returns Number of entries in history
1318
- */
1319
- getHistoryLength(): number;
1320
- /**
1321
- * Get memory status for agent awareness
1322
- *
1323
- * @param currentTurn - Turn to scope `historyTokens` / `historyPercent` to. Omit to measure the
1324
- * whole store, which is what the compaction paths want. Callers building something the model
1325
- * reads should pass it, so the count describes the set the model is actually handed.
1326
- * @returns Memory status with token usage and key counts
1327
- */
1328
- getStatus(currentTurn?: number): MemoryStatus;
1329
- /**
1330
- * Create a memory snapshot for persistence.
1331
- *
1332
- * Stateless: every call returns a fresh `structuredClone` of the current memory, so the caller
1333
- * owns caching if it needs to hold onto the result across calls (see `Agent.memorySnapshot`).
1334
- *
1335
- * @returns Deep copy of current memory state
1336
- */
1337
- snapshot(): AgentMemory;
1338
- /**
1339
- * Build the framework framing and the untrusted data envelope for an LLM call.
1340
- *
1341
- * These are two separate strings because they are two different trust levels, and they used to
1342
- * be one. Concatenated, the framework's own `=== ... ===` section headers sat in the same string
1343
- * as stored tool output and user text, so the input sanitizer matched its own scaffolding on
1344
- * every call and nothing downstream could tell which half a match came from. Splitting them
1345
- * makes that distinction structural: the framing is ours, the envelope is not.
1346
- *
1347
- * The envelope is JSON, which additionally neutralizes the anchored-delimiter attack class —
1348
- * `JSON.stringify` escapes newlines, so a stored fragment cannot produce a line that starts
1349
- * with `===` no matter what it contains.
1350
- *
1351
- * The current turn's own input is deliberately NOT in either string. It travels as its own
1352
- * `role:'user'` message (see `buildAgentMessages`), which is the whole point: a model asked to
1353
- * treat "everything in this block" as data was also being handed the live question inside that
1354
- * block.
1355
- *
1356
- * History entries stay chronological. They used to be split into a "current iteration" slot
1357
- * (reverse chronological, for LLM positional bias) and an "earlier" slot -- but the LLM call
1358
- * always happens BEFORE `addToHistory` writes that iteration's own entries, so the
1359
- * current-iteration slot held nothing on any call that mattered. One chronological list replaces
1360
- * both.
1361
- *
1362
- * Tool results (and tool errors) older than `ENVELOPE_FULL_RESULT_WINDOW` iterations are carried
1363
- * as a short stub instead of their full content -- see `ENVELOPE_FULL_RESULT_WINDOW`. The STORE
1364
- * (`this.memory.history`) is untouched; only what this call carries is capped.
1365
- *
1366
- * @param currentIteration - Current iteration number (0 = pre-iteration)
1367
- * @param currentTurn - Current turn number (optional, for session context filtering)
1368
- */
1369
- toContextParts(currentIteration: number, currentTurn?: number): MemoryContextParts;
1370
- }
1371
-
1372
- /**
1373
- * Shared form field types for dynamic form generation
1374
- * Used by: Command Queue, Execution Runner UI, future form-based features
1375
- */
1376
- /**
1377
- * Supported form field types for action payloads
1378
- * Maps to Mantine form components
1379
- */
1380
- type FormFieldType = 'text' | 'textarea' | 'number' | 'select' | 'checkbox' | 'radio' | 'richtext';
1381
- /**
1382
- * Form field definition
1383
- */
1384
- interface FormField {
1385
- /** Field key in payload object */
1386
- name: string;
1387
- /** Field label for UI */
1388
- label: string;
1389
- /** Field type (determines UI component) */
1390
- type: FormFieldType;
1391
- /** Default value */
1392
- defaultValue?: unknown;
1393
- /** Required field */
1394
- required?: boolean;
1395
- /** Placeholder text */
1396
- placeholder?: string;
1397
- /** Help text */
1398
- description?: string;
1399
- /** Options for select/radio */
1400
- options?: Array<{
1401
- label: string;
1402
- value: string | number;
1403
- }>;
1404
- /** Min/max for number */
1405
- min?: number;
1406
- max?: number;
1407
- /** Path to context value for pre-filling (dot notation, e.g., 'proposal.summary') */
1408
- defaultValueFromContext?: string;
1409
- }
1410
- /**
1411
- * Form schema for action payload collection
1412
- */
1413
- interface FormSchema {
1414
- /** Form title */
1415
- title?: string;
1416
- /** Form description */
1417
- description?: string;
1418
- /** Form fields */
1419
- fields: FormField[];
1420
- }
1421
-
1422
- /**
1423
- * Execution interface configuration
1424
- * Defines how a resource is executed via the UI (forms, scheduling, webhooks)
1425
- * Applies to both agents and workflows
1426
- */
1427
- interface ExecutionInterface {
1428
- /** Form configuration for execution inputs */
1429
- form: ExecutionFormSchema;
1430
- /** Optional: Schedule configuration */
1431
- schedule?: ScheduleConfig;
1432
- /** Optional: Webhook trigger configuration */
1433
- webhook?: WebhookConfig;
1434
- }
1435
- /**
1436
- * Execution form schema
1437
- * Extends FormSchema with execution-specific fields
1438
- */
1439
- interface ExecutionFormSchema extends FormSchema {
1440
- /**
1441
- * Field mappings to resource input schema
1442
- * Maps form field names to contract input paths
1443
- * If omitted, field names must match contract input keys exactly
1444
- */
1445
- fieldMappings?: Record<string, string>;
1446
- /**
1447
- * Submit button configuration
1448
- * Default: { label: 'Run', loadingLabel: 'Running...' }
1449
- */
1450
- submitButton?: {
1451
- label?: string;
1452
- loadingLabel?: string;
1453
- confirmMessage?: string;
1454
- };
1455
- }
1456
- /**
1457
- * Schedule configuration for automated execution
1458
- */
1459
- interface ScheduleConfig {
1460
- /** Whether scheduling is enabled for this resource */
1461
- enabled: boolean;
1462
- /** Default schedule (cron expression) */
1463
- defaultSchedule?: string;
1464
- /** Allowed schedule patterns (if restricted) */
1465
- allowedPatterns?: string[];
1466
- }
1467
- /**
1468
- * Webhook configuration for external triggers
1469
- */
1470
- interface WebhookConfig {
1471
- /** Whether webhook trigger is enabled */
1472
- enabled: boolean;
1473
- /** Expected payload schema (for documentation) */
1474
- payloadSchema?: unknown;
1475
- }
1476
-
1477
- interface WorkflowConfig extends ResourceDefinition {
1478
- type: 'workflow';
1479
- /** OM descriptor backing canonical identity and governance metadata. */
1480
- resource?: WorkflowResourceEntry;
1481
- }
1482
- interface WorkflowStepDefinition {
1483
- id: string;
1484
- name: string;
1485
- description: string;
1486
- }
1487
- type StepHandler = (input: unknown, context: ExecutionContext) => Promise<unknown>;
1488
- interface LinearNext {
1489
- type: 'linear';
1490
- target: string;
1491
- }
1492
- interface ConditionalNext {
1493
- type: 'conditional';
1494
- routes: Array<{
1495
- condition: (data: unknown) => boolean;
1496
- target: string;
1497
- }>;
1498
- default: string;
1499
- }
1500
- type NextConfig = LinearNext | ConditionalNext | null;
1501
- interface WorkflowStep extends WorkflowStepDefinition {
1502
- handler: StepHandler;
1503
- inputSchema: z.ZodSchema;
1504
- outputSchema: z.ZodSchema;
1505
- next: NextConfig;
1506
- }
1507
- interface WorkflowDefinition {
1508
- config: WorkflowConfig;
1509
- contract: Contract;
1510
- steps: Record<string, WorkflowStep>;
1511
- entryPoint: string;
1512
- /**
1513
- * Metrics configuration for ROI calculations
1514
- * Optional: Only needed if tracking automation savings
1515
- */
1516
- metricsConfig?: ResourceMetricsConfig;
1517
- /**
1518
- * Execution interface configuration (optional)
1519
- * If provided, workflow appears in Execution Runner UI
1520
- */
1521
- interface?: ExecutionInterface;
1522
- /**
1523
- * Lead-gen processing stage this workflow implements (optional).
1524
- * Must match a key in the platform lead-gen stage catalog.
1525
- * Used by org-os graph derivation to surface workflow→stage edges and
1526
- * by pipeline_config validation to confirm each catalog stage has an
1527
- * implementing workflow before a list is activated.
1528
- *
1529
- * Example: stageImplemented: 'verified' on the email-verification workflow.
1530
- */
1531
- stageImplemented?: string;
1532
- }
1533
-
1534
- declare const OntologyScopeSchema: z.ZodDefault<z.ZodObject<{
1535
- objectTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1536
- id: z.ZodString;
1537
- label: z.ZodOptional<z.ZodString>;
1538
- description: z.ZodOptional<z.ZodString>;
1539
- ownerSystemId: z.ZodOptional<z.ZodString>;
1540
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1541
- properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1542
- storage: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1543
- }, z.core.$loose>>>>;
1544
- linkTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1545
- id: z.ZodString;
1546
- label: z.ZodOptional<z.ZodString>;
1547
- description: z.ZodOptional<z.ZodString>;
1548
- ownerSystemId: z.ZodOptional<z.ZodString>;
1549
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1550
- from: z.ZodString;
1551
- to: z.ZodString;
1552
- cardinality: z.ZodOptional<z.ZodString>;
1553
- via: z.ZodOptional<z.ZodString>;
1554
- }, z.core.$loose>>>>;
1555
- actionTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1556
- id: z.ZodString;
1557
- label: z.ZodOptional<z.ZodString>;
1558
- description: z.ZodOptional<z.ZodString>;
1559
- ownerSystemId: z.ZodOptional<z.ZodString>;
1560
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1561
- actsOn: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
1562
- input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1563
- effects: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1564
- }, z.core.$loose>>>>;
1565
- catalogTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1566
- id: z.ZodString;
1567
- label: z.ZodOptional<z.ZodString>;
1568
- description: z.ZodOptional<z.ZodString>;
1569
- ownerSystemId: z.ZodOptional<z.ZodString>;
1570
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1571
- kind: z.ZodOptional<z.ZodString>;
1572
- appliesTo: z.ZodOptional<z.ZodString>;
1573
- entries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1574
- }, z.core.$loose>>>>;
1575
- eventTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1576
- id: z.ZodString;
1577
- label: z.ZodOptional<z.ZodString>;
1578
- description: z.ZodOptional<z.ZodString>;
1579
- ownerSystemId: z.ZodOptional<z.ZodString>;
1580
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1581
- payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1582
- }, z.core.$loose>>>>;
1583
- interfaceTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1584
- id: z.ZodString;
1585
- label: z.ZodOptional<z.ZodString>;
1586
- description: z.ZodOptional<z.ZodString>;
1587
- ownerSystemId: z.ZodOptional<z.ZodString>;
1588
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1589
- properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1590
- }, z.core.$loose>>>>;
1591
- valueTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1592
- id: z.ZodString;
1593
- label: z.ZodOptional<z.ZodString>;
1594
- description: z.ZodOptional<z.ZodString>;
1595
- ownerSystemId: z.ZodOptional<z.ZodString>;
1596
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1597
- primitive: z.ZodOptional<z.ZodString>;
1598
- }, z.core.$loose>>>>;
1599
- sharedProperties: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1600
- id: z.ZodString;
1601
- label: z.ZodOptional<z.ZodString>;
1602
- description: z.ZodOptional<z.ZodString>;
1603
- ownerSystemId: z.ZodOptional<z.ZodString>;
1604
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1605
- valueType: z.ZodOptional<z.ZodString>;
1606
- searchable: z.ZodOptional<z.ZodBoolean>;
1607
- pii: z.ZodOptional<z.ZodBoolean>;
1608
- }, z.core.$loose>>>>;
1609
- groups: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1610
- id: z.ZodString;
1611
- label: z.ZodOptional<z.ZodString>;
1612
- description: z.ZodOptional<z.ZodString>;
1613
- ownerSystemId: z.ZodOptional<z.ZodString>;
1614
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1615
- members: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
1616
- }, z.core.$loose>>>>;
1617
- endpoints: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1618
- id: z.ZodString;
1619
- label: z.ZodOptional<z.ZodString>;
1620
- description: z.ZodOptional<z.ZodString>;
1621
- ownerSystemId: z.ZodOptional<z.ZodString>;
1622
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
1623
- route: z.ZodOptional<z.ZodString>;
1624
- }, z.core.$loose>>>>;
1625
- }, z.core.$strict>>;
1626
- type OntologyScope = z.infer<typeof OntologyScopeSchema>;
1627
-
1628
- declare const SystemApiInterfaceSchema: z.ZodObject<{
1629
- lifecycle: z.ZodDefault<z.ZodEnum<{
1630
- active: "active";
1631
- deprecated: "deprecated";
1632
- draft: "draft";
1633
- archived: "archived";
1634
- disabled: "disabled";
1635
- }>>;
1636
- readinessProfile: z.ZodOptional<z.ZodString>;
1637
- resourceIds: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
1638
- readinessContract: z.ZodOptional<z.ZodObject<{
1639
- requiredObjects: z.ZodDefault<z.ZodArray<z.ZodString>>;
1640
- requiredCatalogs: z.ZodArray<z.ZodString>;
1641
- }, z.core.$strict>>;
1642
- }, z.core.$strict>;
1643
- type JsonPrimitive = string | number | boolean | null;
1644
- type JsonValue = JsonPrimitive | JsonValue[] | {
1645
- [key: string]: JsonValue;
1646
- };
1647
- /** Explicit interface needed to annotate the recursive SystemEntrySchema. */
1648
- interface SystemEntry {
1649
- id: string;
1650
- label?: string;
1651
- title?: string;
1652
- description?: string;
1653
- kind?: 'product' | 'operational' | 'platform' | 'diagnostic';
1654
- parentSystemId?: string;
1655
- ui?: {
1656
- path: string;
1657
- surfaces: string[];
1658
- icon?: string;
1659
- };
1660
- lifecycle?: 'draft' | 'beta' | 'active' | 'deprecated' | 'archived';
1661
- responsibleRoleId?: string;
1662
- governedByKnowledge?: string[];
1663
- actions?: {
1664
- actionId: string;
1665
- intent: 'exposes' | 'consumes';
1666
- invocation?: unknown;
1667
- }[];
1668
- drivesGoals?: string[];
1669
- apiInterface?: z.infer<typeof SystemApiInterfaceSchema>;
1670
- path?: string;
1671
- icon?: string;
1672
- uiPosition?: 'sidebar-primary' | 'sidebar-bottom';
1673
- enabled?: boolean;
1674
- order: number;
1675
- config?: Record<string, JsonValue>;
1676
- ontology?: OntologyScope;
1677
- systems?: Record<string, SystemEntry>;
1678
- subsystems?: Record<string, SystemEntry>;
1679
- }
1680
-
1681
- declare const SurfaceTypeSchema: z.ZodEnum<{
1682
- dashboard: "dashboard";
1683
- settings: "settings";
1684
- graph: "graph";
1685
- page: "page";
1686
- detail: "detail";
1687
- list: "list";
1688
- }>;
1689
- interface SidebarSurfaceNode {
1690
- type: 'surface';
1691
- label: string;
1692
- path: string;
1693
- surfaceType: z.infer<typeof SurfaceTypeSchema>;
1694
- description?: string;
1695
- icon?: string;
1696
- order?: number;
1697
- targets?: {
1698
- systems?: string[];
1699
- entities?: string[];
1700
- resources?: string[];
1701
- actions?: string[];
1702
- };
1703
- devOnly?: boolean;
1704
- requiresAdmin?: boolean;
1705
- }
1706
- interface SidebarGroupNode {
1707
- type: 'group';
1708
- label: string;
1709
- description?: string;
1710
- icon?: string;
1711
- order?: number;
1712
- children: Record<string, SidebarNode>;
1713
- }
1714
- type SidebarNode = SidebarSurfaceNode | SidebarGroupNode;
1715
-
1716
- declare const LinkSchema: z.ZodObject<{
1717
- nodeId: z.ZodString;
1718
- kind: z.ZodEnum<{
1719
- affects: "affects";
1720
- actions: "actions";
1721
- effects: "effects";
1722
- links: "links";
1723
- reads: "reads";
1724
- writes: "writes";
1725
- emits: "emits";
1726
- triggers: "triggers";
1727
- uses: "uses";
1728
- approval: "approval";
1729
- contains: "contains";
1730
- references: "references";
1731
- maps_to: "maps_to";
1732
- governs: "governs";
1733
- originates_from: "originates_from";
1734
- applies_to: "applies_to";
1735
- uses_catalog: "uses_catalog";
1736
- }>;
1737
- }, z.core.$strip>;
1738
- type Link = z.infer<typeof LinkSchema>;
1739
-
1740
- declare const OrganizationModelSchema: z.ZodObject<{
1741
- version: z.ZodDefault<z.ZodLiteral<1>>;
1742
- snapshotHash: z.ZodOptional<z.ZodString>;
1743
- domainMetadata: z.ZodPipe<z.ZodDefault<z.ZodObject<{
1744
- branding: z.ZodOptional<z.ZodObject<{
1745
- version: z.ZodDefault<z.ZodLiteral<1>>;
1746
- lastModified: z.ZodString;
1747
- }, z.core.$strip>>;
1748
- identity: z.ZodOptional<z.ZodObject<{
1749
- version: z.ZodDefault<z.ZodLiteral<1>>;
1750
- lastModified: z.ZodString;
1751
- }, z.core.$strip>>;
1752
- clients: z.ZodOptional<z.ZodObject<{
1753
- version: z.ZodDefault<z.ZodLiteral<1>>;
1754
- lastModified: z.ZodString;
1755
- }, z.core.$strip>>;
1756
- customers: z.ZodOptional<z.ZodObject<{
1757
- version: z.ZodDefault<z.ZodLiteral<1>>;
1758
- lastModified: z.ZodString;
1759
- }, z.core.$strip>>;
1760
- offerings: z.ZodOptional<z.ZodObject<{
1761
- version: z.ZodDefault<z.ZodLiteral<1>>;
1762
- lastModified: z.ZodString;
1763
- }, z.core.$strip>>;
1764
- roles: z.ZodOptional<z.ZodObject<{
1765
- version: z.ZodDefault<z.ZodLiteral<1>>;
1766
- lastModified: z.ZodString;
1767
- }, z.core.$strip>>;
1768
- goals: z.ZodOptional<z.ZodObject<{
1769
- version: z.ZodDefault<z.ZodLiteral<1>>;
1770
- lastModified: z.ZodString;
1771
- }, z.core.$strip>>;
1772
- systems: z.ZodOptional<z.ZodObject<{
1773
- version: z.ZodDefault<z.ZodLiteral<1>>;
1774
- lastModified: z.ZodString;
1775
- }, z.core.$strip>>;
1776
- ontology: z.ZodOptional<z.ZodObject<{
1777
- version: z.ZodDefault<z.ZodLiteral<1>>;
1778
- lastModified: z.ZodString;
1779
- }, z.core.$strip>>;
1780
- resources: z.ZodOptional<z.ZodObject<{
1781
- version: z.ZodDefault<z.ZodLiteral<1>>;
1782
- lastModified: z.ZodString;
1783
- }, z.core.$strip>>;
1784
- topology: z.ZodOptional<z.ZodObject<{
1785
- version: z.ZodDefault<z.ZodLiteral<1>>;
1786
- lastModified: z.ZodString;
1787
- }, z.core.$strip>>;
1788
- actions: z.ZodOptional<z.ZodObject<{
1789
- version: z.ZodDefault<z.ZodLiteral<1>>;
1790
- lastModified: z.ZodString;
1791
- }, z.core.$strip>>;
1792
- entities: z.ZodOptional<z.ZodObject<{
1793
- version: z.ZodDefault<z.ZodLiteral<1>>;
1794
- lastModified: z.ZodString;
1795
- }, z.core.$strip>>;
1796
- knowledge: z.ZodOptional<z.ZodObject<{
1797
- version: z.ZodDefault<z.ZodLiteral<1>>;
1798
- lastModified: z.ZodString;
1799
- }, z.core.$strip>>;
1800
- }, z.core.$strip>>, z.ZodTransform<{
1801
- branding: {
1802
- version: 1;
1803
- lastModified: string;
1804
- };
1805
- identity: {
1806
- version: 1;
1807
- lastModified: string;
1808
- };
1809
- clients: {
1810
- version: 1;
1811
- lastModified: string;
1812
- };
1813
- customers: {
1814
- version: 1;
1815
- lastModified: string;
1816
- };
1817
- offerings: {
1818
- version: 1;
1819
- lastModified: string;
1820
- };
1821
- roles: {
1822
- version: 1;
1823
- lastModified: string;
1824
- };
1825
- goals: {
1826
- version: 1;
1827
- lastModified: string;
1828
- };
1829
- systems: {
1830
- version: 1;
1831
- lastModified: string;
1832
- };
1833
- ontology: {
1834
- version: 1;
1835
- lastModified: string;
1836
- };
1837
- resources: {
1838
- version: 1;
1839
- lastModified: string;
1840
- };
1841
- topology: {
1842
- version: 1;
1843
- lastModified: string;
1844
- };
1845
- actions: {
1846
- version: 1;
1847
- lastModified: string;
1848
- };
1849
- entities: {
1850
- version: 1;
1851
- lastModified: string;
1852
- };
1853
- knowledge: {
1854
- version: 1;
1855
- lastModified: string;
1856
- };
1857
- }, {
1858
- branding?: {
1859
- version: 1;
1860
- lastModified: string;
1861
- } | undefined;
1862
- identity?: {
1863
- version: 1;
1864
- lastModified: string;
1865
- } | undefined;
1866
- clients?: {
1867
- version: 1;
1868
- lastModified: string;
1869
- } | undefined;
1870
- customers?: {
1871
- version: 1;
1872
- lastModified: string;
1873
- } | undefined;
1874
- offerings?: {
1875
- version: 1;
1876
- lastModified: string;
1877
- } | undefined;
1878
- roles?: {
1879
- version: 1;
1880
- lastModified: string;
1881
- } | undefined;
1882
- goals?: {
1883
- version: 1;
1884
- lastModified: string;
1885
- } | undefined;
1886
- systems?: {
1887
- version: 1;
1888
- lastModified: string;
1889
- } | undefined;
1890
- ontology?: {
1891
- version: 1;
1892
- lastModified: string;
1893
- } | undefined;
1894
- resources?: {
1895
- version: 1;
1896
- lastModified: string;
1897
- } | undefined;
1898
- topology?: {
1899
- version: 1;
1900
- lastModified: string;
1901
- } | undefined;
1902
- actions?: {
1903
- version: 1;
1904
- lastModified: string;
1905
- } | undefined;
1906
- entities?: {
1907
- version: 1;
1908
- lastModified: string;
1909
- } | undefined;
1910
- knowledge?: {
1911
- version: 1;
1912
- lastModified: string;
1913
- } | undefined;
1914
- }>>;
1915
- branding: z.ZodDefault<z.ZodObject<{
1916
- organizationName: z.ZodString;
1917
- productName: z.ZodString;
1918
- shortName: z.ZodString;
1919
- description: z.ZodOptional<z.ZodString>;
1920
- logos: z.ZodDefault<z.ZodObject<{
1921
- light: z.ZodOptional<z.ZodString>;
1922
- dark: z.ZodOptional<z.ZodString>;
1923
- }, z.core.$strip>>;
1924
- voice: z.ZodOptional<z.ZodString>;
1925
- tagline: z.ZodOptional<z.ZodString>;
1926
- values: z.ZodOptional<z.ZodArray<z.ZodString>>;
1927
- themePresetId: z.ZodOptional<z.ZodString>;
1928
- }, z.core.$loose>>;
1929
- navigation: z.ZodDefault<z.ZodObject<{
1930
- sidebar: z.ZodDefault<z.ZodObject<{
1931
- primary: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<SidebarNode, unknown, z.core.$ZodTypeInternals<SidebarNode, unknown>>>>;
1932
- bottom: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<SidebarNode, unknown, z.core.$ZodTypeInternals<SidebarNode, unknown>>>>;
1933
- }, z.core.$strip>>;
1934
- topbar: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1935
- id: z.ZodString;
1936
- label: z.ZodString;
1937
- tooltip: z.ZodOptional<z.ZodString>;
1938
- icon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
1939
- message: "message";
1940
- error: "error";
1941
- agent: "agent";
1942
- workflow: "workflow";
1943
- "google-sheets": "google-sheets";
1944
- dashboard: "dashboard";
1945
- calendar: "calendar";
1946
- sales: "sales";
1947
- crm: "crm";
1948
- "lead-gen": "lead-gen";
1949
- projects: "projects";
1950
- clients: "clients";
1951
- operations: "operations";
1952
- monitoring: "monitoring";
1953
- knowledge: "knowledge";
1954
- settings: "settings";
1955
- admin: "admin";
1956
- archive: "archive";
1957
- business: "business";
1958
- finance: "finance";
1959
- platform: "platform";
1960
- seo: "seo";
1961
- playbook: "playbook";
1962
- strategy: "strategy";
1963
- reference: "reference";
1964
- integration: "integration";
1965
- database: "database";
1966
- user: "user";
1967
- team: "team";
1968
- gmail: "gmail";
1969
- attio: "attio";
1970
- overview: "overview";
1971
- "command-view": "command-view";
1972
- "command-queue": "command-queue";
1973
- pipeline: "pipeline";
1974
- lists: "lists";
1975
- resources: "resources";
1976
- approve: "approve";
1977
- reject: "reject";
1978
- retry: "retry";
1979
- edit: "edit";
1980
- view: "view";
1981
- launch: "launch";
1982
- "message-plus": "message-plus";
1983
- escalate: "escalate";
1984
- promote: "promote";
1985
- submit: "submit";
1986
- email: "email";
1987
- success: "success";
1988
- warning: "warning";
1989
- info: "info";
1990
- pending: "pending";
1991
- bolt: "bolt";
1992
- building: "building";
1993
- briefcase: "briefcase";
1994
- apps: "apps";
1995
- graph: "graph";
1996
- shield: "shield";
1997
- users: "users";
1998
- "chart-bar": "chart-bar";
1999
- search: "search";
2000
- }>, z.ZodString]>>;
2001
- order: z.ZodOptional<z.ZodNumber>;
2002
- enabled: z.ZodDefault<z.ZodBoolean>;
2003
- devOnly: z.ZodOptional<z.ZodBoolean>;
2004
- requiresAdmin: z.ZodOptional<z.ZodBoolean>;
2005
- targets: z.ZodOptional<z.ZodDefault<z.ZodObject<{
2006
- systems: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
2007
- entities: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
2008
- resources: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
2009
- actions: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
2010
- }, z.core.$strip>>>;
2011
- }, z.core.$strip>>>;
2012
- }, z.core.$strip>>;
2013
- identity: z.ZodDefault<z.ZodObject<{
2014
- mission: z.ZodDefault<z.ZodString>;
2015
- vision: z.ZodDefault<z.ZodString>;
2016
- legalName: z.ZodDefault<z.ZodString>;
2017
- entityType: z.ZodDefault<z.ZodString>;
2018
- jurisdiction: z.ZodDefault<z.ZodString>;
2019
- industryCategory: z.ZodDefault<z.ZodString>;
2020
- geographicFocus: z.ZodDefault<z.ZodString>;
2021
- timeZone: z.ZodDefault<z.ZodString>;
2022
- businessHours: z.ZodDefault<z.ZodObject<{
2023
- monday: z.ZodOptional<z.ZodObject<{
2024
- open: z.ZodString;
2025
- close: z.ZodString;
2026
- }, z.core.$strip>>;
2027
- tuesday: z.ZodOptional<z.ZodObject<{
2028
- open: z.ZodString;
2029
- close: z.ZodString;
2030
- }, z.core.$strip>>;
2031
- wednesday: z.ZodOptional<z.ZodObject<{
2032
- open: z.ZodString;
2033
- close: z.ZodString;
2034
- }, z.core.$strip>>;
2035
- thursday: z.ZodOptional<z.ZodObject<{
2036
- open: z.ZodString;
2037
- close: z.ZodString;
2038
- }, z.core.$strip>>;
2039
- friday: z.ZodOptional<z.ZodObject<{
2040
- open: z.ZodString;
2041
- close: z.ZodString;
2042
- }, z.core.$strip>>;
2043
- saturday: z.ZodOptional<z.ZodObject<{
2044
- open: z.ZodString;
2045
- close: z.ZodString;
2046
- }, z.core.$strip>>;
2047
- sunday: z.ZodOptional<z.ZodObject<{
2048
- open: z.ZodString;
2049
- close: z.ZodString;
2050
- }, z.core.$strip>>;
2051
- }, z.core.$strip>>;
2052
- clientBrief: z.ZodDefault<z.ZodString>;
2053
- organizationName: z.ZodOptional<z.ZodString>;
2054
- productName: z.ZodOptional<z.ZodString>;
2055
- shortName: z.ZodOptional<z.ZodString>;
2056
- description: z.ZodOptional<z.ZodString>;
2057
- }, z.core.$loose>>;
2058
- clients: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2059
- id: z.ZodString;
2060
- slug: z.ZodString;
2061
- name: z.ZodString;
2062
- status: z.ZodDefault<z.ZodEnum<{
2063
- active: "active";
2064
- onboarding: "onboarding";
2065
- paused: "paused";
2066
- completed: "completed";
2067
- churned: "churned";
2068
- }>>;
2069
- source: z.ZodOptional<z.ZodString>;
2070
- identity: z.ZodDefault<z.ZodObject<{
2071
- organizationName: z.ZodOptional<z.ZodString>;
2072
- shortName: z.ZodOptional<z.ZodString>;
2073
- clientBrief: z.ZodDefault<z.ZodString>;
2074
- geographicFocus: z.ZodDefault<z.ZodArray<z.ZodString>>;
2075
- timeZone: z.ZodDefault<z.ZodString>;
2076
- }, z.core.$loose>>;
2077
- branding: z.ZodDefault<z.ZodObject<{
2078
- voice: z.ZodOptional<z.ZodString>;
2079
- tagline: z.ZodOptional<z.ZodString>;
2080
- values: z.ZodDefault<z.ZodArray<z.ZodString>>;
2081
- }, z.core.$loose>>;
2082
- workspace: z.ZodDefault<z.ZodObject<{
2083
- kind: z.ZodOptional<z.ZodEnum<{
2084
- "external-project": "external-project";
2085
- "internal-project": "internal-project";
2086
- none: "none";
2087
- }>>;
2088
- owner: z.ZodOptional<z.ZodEnum<{
2089
- platform: "platform";
2090
- client: "client";
2091
- developer: "developer";
2092
- }>>;
2093
- projectId: z.ZodOptional<z.ZodString>;
2094
- workspacePath: z.ZodOptional<z.ZodString>;
2095
- }, z.core.$loose>>;
2096
- links: z.ZodDefault<z.ZodObject<{
2097
- projectIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
2098
- primaryCompanyId: z.ZodOptional<z.ZodString>;
2099
- primaryContactId: z.ZodOptional<z.ZodString>;
2100
- sourceDealId: z.ZodOptional<z.ZodString>;
2101
- }, z.core.$strip>>;
2102
- prompts: z.ZodDefault<z.ZodObject<{
2103
- defaultContext: z.ZodDefault<z.ZodString>;
2104
- }, z.core.$loose>>;
2105
- config: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
2106
- customValues: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
2107
- }, z.core.$strict>>>>;
2108
- customers: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2109
- id: z.ZodString;
2110
- order: z.ZodNumber;
2111
- name: z.ZodDefault<z.ZodString>;
2112
- description: z.ZodDefault<z.ZodString>;
2113
- jobsToBeDone: z.ZodDefault<z.ZodString>;
2114
- pains: z.ZodDefault<z.ZodArray<z.ZodString>>;
2115
- gains: z.ZodDefault<z.ZodArray<z.ZodString>>;
2116
- firmographics: z.ZodDefault<z.ZodObject<{
2117
- industry: z.ZodOptional<z.ZodString>;
2118
- companySize: z.ZodOptional<z.ZodString>;
2119
- region: z.ZodOptional<z.ZodString>;
2120
- }, z.core.$strip>>;
2121
- valueProp: z.ZodDefault<z.ZodString>;
2122
- }, z.core.$strip>>>>;
2123
- offerings: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2124
- id: z.ZodString;
2125
- order: z.ZodNumber;
2126
- name: z.ZodDefault<z.ZodString>;
2127
- description: z.ZodDefault<z.ZodString>;
2128
- pricingModel: z.ZodDefault<z.ZodEnum<{
2129
- custom: "custom";
2130
- "one-time": "one-time";
2131
- subscription: "subscription";
2132
- "usage-based": "usage-based";
2133
- }>>;
2134
- price: z.ZodDefault<z.ZodNumber>;
2135
- currency: z.ZodDefault<z.ZodString>;
2136
- targetSegmentIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
2137
- deliveryFeatureId: z.ZodOptional<z.ZodString>;
2138
- }, z.core.$strip>>>>;
2139
- roles: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2140
- id: z.ZodString;
2141
- order: z.ZodNumber;
2142
- title: z.ZodString;
2143
- responsibilities: z.ZodDefault<z.ZodArray<z.ZodString>>;
2144
- reportsToId: z.ZodOptional<z.ZodString>;
2145
- heldBy: z.ZodOptional<z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
2146
- kind: z.ZodLiteral<"human">;
2147
- userId: z.ZodString;
2148
- }, z.core.$strip>, z.ZodObject<{
2149
- kind: z.ZodLiteral<"agent">;
2150
- agentId: z.ZodString;
2151
- }, z.core.$strip>, z.ZodObject<{
2152
- kind: z.ZodLiteral<"team">;
2153
- memberIds: z.ZodArray<z.ZodString>;
2154
- }, z.core.$strip>], "kind">, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2155
- kind: z.ZodLiteral<"human">;
2156
- userId: z.ZodString;
2157
- }, z.core.$strip>, z.ZodObject<{
2158
- kind: z.ZodLiteral<"agent">;
2159
- agentId: z.ZodString;
2160
- }, z.core.$strip>, z.ZodObject<{
2161
- kind: z.ZodLiteral<"team">;
2162
- memberIds: z.ZodArray<z.ZodString>;
2163
- }, z.core.$strip>], "kind">>]>>;
2164
- responsibleFor: z.ZodOptional<z.ZodArray<z.ZodString>>;
2165
- }, z.core.$strip>>>>;
2166
- goals: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2167
- id: z.ZodString;
2168
- order: z.ZodNumber;
2169
- description: z.ZodString;
2170
- periodStart: z.ZodString;
2171
- periodEnd: z.ZodString;
2172
- keyResults: z.ZodDefault<z.ZodArray<z.ZodObject<{
2173
- id: z.ZodString;
2174
- description: z.ZodString;
2175
- targetMetric: z.ZodString;
2176
- currentValue: z.ZodDefault<z.ZodNumber>;
2177
- targetValue: z.ZodOptional<z.ZodNumber>;
2178
- }, z.core.$strip>>>;
2179
- }, z.core.$strip>>>>;
2180
- systems: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<SystemEntry, unknown, z.core.$ZodTypeInternals<SystemEntry, unknown>>>>>;
2181
- ontology: z.ZodDefault<z.ZodDefault<z.ZodObject<{
2182
- objectTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2183
- id: z.ZodString;
2184
- label: z.ZodOptional<z.ZodString>;
2185
- description: z.ZodOptional<z.ZodString>;
2186
- ownerSystemId: z.ZodOptional<z.ZodString>;
2187
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
2188
- properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2189
- storage: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2190
- }, z.core.$loose>>>>;
2191
- linkTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2192
- id: z.ZodString;
2193
- label: z.ZodOptional<z.ZodString>;
2194
- description: z.ZodOptional<z.ZodString>;
2195
- ownerSystemId: z.ZodOptional<z.ZodString>;
2196
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
2197
- from: z.ZodString;
2198
- to: z.ZodString;
2199
- cardinality: z.ZodOptional<z.ZodString>;
2200
- via: z.ZodOptional<z.ZodString>;
2201
- }, z.core.$loose>>>>;
2202
- actionTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2203
- id: z.ZodString;
2204
- label: z.ZodOptional<z.ZodString>;
2205
- description: z.ZodOptional<z.ZodString>;
2206
- ownerSystemId: z.ZodOptional<z.ZodString>;
2207
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
2208
- actsOn: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
2209
- input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2210
- effects: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
2211
- }, z.core.$loose>>>>;
2212
- catalogTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2213
- id: z.ZodString;
2214
- label: z.ZodOptional<z.ZodString>;
2215
- description: z.ZodOptional<z.ZodString>;
2216
- ownerSystemId: z.ZodOptional<z.ZodString>;
2217
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
2218
- kind: z.ZodOptional<z.ZodString>;
2219
- appliesTo: z.ZodOptional<z.ZodString>;
2220
- entries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2221
- }, z.core.$loose>>>>;
2222
- eventTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2223
- id: z.ZodString;
2224
- label: z.ZodOptional<z.ZodString>;
2225
- description: z.ZodOptional<z.ZodString>;
2226
- ownerSystemId: z.ZodOptional<z.ZodString>;
2227
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
2228
- payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2229
- }, z.core.$loose>>>>;
2230
- interfaceTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2231
- id: z.ZodString;
2232
- label: z.ZodOptional<z.ZodString>;
2233
- description: z.ZodOptional<z.ZodString>;
2234
- ownerSystemId: z.ZodOptional<z.ZodString>;
2235
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
2236
- properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2237
- }, z.core.$loose>>>>;
2238
- valueTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2239
- id: z.ZodString;
2240
- label: z.ZodOptional<z.ZodString>;
2241
- description: z.ZodOptional<z.ZodString>;
2242
- ownerSystemId: z.ZodOptional<z.ZodString>;
2243
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
2244
- primitive: z.ZodOptional<z.ZodString>;
2245
- }, z.core.$loose>>>>;
2246
- sharedProperties: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2247
- id: z.ZodString;
2248
- label: z.ZodOptional<z.ZodString>;
2249
- description: z.ZodOptional<z.ZodString>;
2250
- ownerSystemId: z.ZodOptional<z.ZodString>;
2251
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
2252
- valueType: z.ZodOptional<z.ZodString>;
2253
- searchable: z.ZodOptional<z.ZodBoolean>;
2254
- pii: z.ZodOptional<z.ZodBoolean>;
2255
- }, z.core.$loose>>>>;
2256
- groups: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2257
- id: z.ZodString;
2258
- label: z.ZodOptional<z.ZodString>;
2259
- description: z.ZodOptional<z.ZodString>;
2260
- ownerSystemId: z.ZodOptional<z.ZodString>;
2261
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
2262
- members: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
2263
- }, z.core.$loose>>>>;
2264
- endpoints: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2265
- id: z.ZodString;
2266
- label: z.ZodOptional<z.ZodString>;
2267
- description: z.ZodOptional<z.ZodString>;
2268
- ownerSystemId: z.ZodOptional<z.ZodString>;
2269
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
2270
- route: z.ZodOptional<z.ZodString>;
2271
- }, z.core.$loose>>>>;
2272
- }, z.core.$strict>>>;
2273
- resources: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
2274
- id: z.ZodString;
2275
- order: z.ZodDefault<z.ZodNumber>;
2276
- systemPath: z.ZodString;
2277
- title: z.ZodOptional<z.ZodString>;
2278
- description: z.ZodOptional<z.ZodString>;
2279
- ownerRoleId: z.ZodOptional<z.ZodString>;
2280
- status: z.ZodEnum<{
2281
- active: "active";
2282
- deprecated: "deprecated";
2283
- archived: "archived";
2284
- }>;
2285
- ontology: z.ZodOptional<z.ZodObject<{
2286
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
2287
- primaryAction: z.ZodOptional<z.ZodString>;
2288
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
2289
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
2290
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
2291
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
2292
- contract: z.ZodOptional<z.ZodObject<{
2293
- input: z.ZodOptional<z.ZodString>;
2294
- output: z.ZodOptional<z.ZodString>;
2295
- }, z.core.$strip>>;
2296
- }, z.core.$strip>>;
2297
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
2298
- path: z.ZodString;
2299
- role: z.ZodEnum<{
2300
- entrypoint: "entrypoint";
2301
- handler: "handler";
2302
- schema: "schema";
2303
- test: "test";
2304
- docs: "docs";
2305
- config: "config";
2306
- }>;
2307
- symbol: z.ZodOptional<z.ZodString>;
2308
- description: z.ZodOptional<z.ZodString>;
2309
- }, z.core.$strip>>>;
2310
- kind: z.ZodLiteral<"workflow">;
2311
- emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
2312
- eventKey: z.ZodString;
2313
- label: z.ZodString;
2314
- payloadSchema: z.ZodOptional<z.ZodString>;
2315
- lifecycle: z.ZodOptional<z.ZodEnum<{
2316
- active: "active";
2317
- deprecated: "deprecated";
2318
- draft: "draft";
2319
- beta: "beta";
2320
- archived: "archived";
2321
- }>>;
2322
- }, z.core.$strip>>>;
2323
- }, z.core.$strip>, z.ZodObject<{
2324
- id: z.ZodString;
2325
- order: z.ZodDefault<z.ZodNumber>;
2326
- systemPath: z.ZodString;
2327
- title: z.ZodOptional<z.ZodString>;
2328
- description: z.ZodOptional<z.ZodString>;
2329
- ownerRoleId: z.ZodOptional<z.ZodString>;
2330
- status: z.ZodEnum<{
2331
- active: "active";
2332
- deprecated: "deprecated";
2333
- archived: "archived";
2334
- }>;
2335
- ontology: z.ZodOptional<z.ZodObject<{
2336
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
2337
- primaryAction: z.ZodOptional<z.ZodString>;
2338
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
2339
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
2340
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
2341
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
2342
- contract: z.ZodOptional<z.ZodObject<{
2343
- input: z.ZodOptional<z.ZodString>;
2344
- output: z.ZodOptional<z.ZodString>;
2345
- }, z.core.$strip>>;
2346
- }, z.core.$strip>>;
2347
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
2348
- path: z.ZodString;
2349
- role: z.ZodEnum<{
2350
- entrypoint: "entrypoint";
2351
- handler: "handler";
2352
- schema: "schema";
2353
- test: "test";
2354
- docs: "docs";
2355
- config: "config";
2356
- }>;
2357
- symbol: z.ZodOptional<z.ZodString>;
2358
- description: z.ZodOptional<z.ZodString>;
2359
- }, z.core.$strip>>>;
2360
- kind: z.ZodLiteral<"agent">;
2361
- agentKind: z.ZodEnum<{
2362
- platform: "platform";
2363
- orchestrator: "orchestrator";
2364
- specialist: "specialist";
2365
- utility: "utility";
2366
- }>;
2367
- actsAsRoleId: z.ZodOptional<z.ZodString>;
2368
- sessionCapable: z.ZodBoolean;
2369
- invocations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2370
- kind: z.ZodLiteral<"slash-command">;
2371
- command: z.ZodString;
2372
- toolFactory: z.ZodOptional<z.ZodString>;
2373
- }, z.core.$strip>, z.ZodObject<{
2374
- kind: z.ZodLiteral<"mcp-tool">;
2375
- server: z.ZodString;
2376
- name: z.ZodString;
2377
- }, z.core.$strip>, z.ZodObject<{
2378
- kind: z.ZodLiteral<"api-endpoint">;
2379
- method: z.ZodEnum<{
2380
- GET: "GET";
2381
- POST: "POST";
2382
- PATCH: "PATCH";
2383
- DELETE: "DELETE";
2384
- }>;
2385
- path: z.ZodString;
2386
- requestSchema: z.ZodOptional<z.ZodString>;
2387
- responseSchema: z.ZodOptional<z.ZodString>;
2388
- }, z.core.$strip>, z.ZodObject<{
2389
- kind: z.ZodLiteral<"script-execution">;
2390
- resourceId: z.ZodString;
2391
- }, z.core.$strip>], "kind">>>;
2392
- emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
2393
- eventKey: z.ZodString;
2394
- label: z.ZodString;
2395
- payloadSchema: z.ZodOptional<z.ZodString>;
2396
- lifecycle: z.ZodOptional<z.ZodEnum<{
2397
- active: "active";
2398
- deprecated: "deprecated";
2399
- draft: "draft";
2400
- beta: "beta";
2401
- archived: "archived";
2402
- }>>;
2403
- }, z.core.$strip>>>;
2404
- }, z.core.$strip>, z.ZodObject<{
2405
- id: z.ZodString;
2406
- order: z.ZodDefault<z.ZodNumber>;
2407
- systemPath: z.ZodString;
2408
- title: z.ZodOptional<z.ZodString>;
2409
- description: z.ZodOptional<z.ZodString>;
2410
- ownerRoleId: z.ZodOptional<z.ZodString>;
2411
- status: z.ZodEnum<{
2412
- active: "active";
2413
- deprecated: "deprecated";
2414
- archived: "archived";
2415
- }>;
2416
- ontology: z.ZodOptional<z.ZodObject<{
2417
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
2418
- primaryAction: z.ZodOptional<z.ZodString>;
2419
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
2420
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
2421
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
2422
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
2423
- contract: z.ZodOptional<z.ZodObject<{
2424
- input: z.ZodOptional<z.ZodString>;
2425
- output: z.ZodOptional<z.ZodString>;
2426
- }, z.core.$strip>>;
2427
- }, z.core.$strip>>;
2428
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
2429
- path: z.ZodString;
2430
- role: z.ZodEnum<{
2431
- entrypoint: "entrypoint";
2432
- handler: "handler";
2433
- schema: "schema";
2434
- test: "test";
2435
- docs: "docs";
2436
- config: "config";
2437
- }>;
2438
- symbol: z.ZodOptional<z.ZodString>;
2439
- description: z.ZodOptional<z.ZodString>;
2440
- }, z.core.$strip>>>;
2441
- kind: z.ZodLiteral<"integration">;
2442
- provider: z.ZodString;
2443
- }, z.core.$strip>, z.ZodObject<{
2444
- id: z.ZodString;
2445
- order: z.ZodDefault<z.ZodNumber>;
2446
- systemPath: z.ZodString;
2447
- title: z.ZodOptional<z.ZodString>;
2448
- description: z.ZodOptional<z.ZodString>;
2449
- ownerRoleId: z.ZodOptional<z.ZodString>;
2450
- status: z.ZodEnum<{
2451
- active: "active";
2452
- deprecated: "deprecated";
2453
- archived: "archived";
2454
- }>;
2455
- ontology: z.ZodOptional<z.ZodObject<{
2456
- actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
2457
- primaryAction: z.ZodOptional<z.ZodString>;
2458
- reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
2459
- writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
2460
- usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
2461
- emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
2462
- contract: z.ZodOptional<z.ZodObject<{
2463
- input: z.ZodOptional<z.ZodString>;
2464
- output: z.ZodOptional<z.ZodString>;
2465
- }, z.core.$strip>>;
2466
- }, z.core.$strip>>;
2467
- codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
2468
- path: z.ZodString;
2469
- role: z.ZodEnum<{
2470
- entrypoint: "entrypoint";
2471
- handler: "handler";
2472
- schema: "schema";
2473
- test: "test";
2474
- docs: "docs";
2475
- config: "config";
2476
- }>;
2477
- symbol: z.ZodOptional<z.ZodString>;
2478
- description: z.ZodOptional<z.ZodString>;
2479
- }, z.core.$strip>>>;
2480
- kind: z.ZodLiteral<"script">;
2481
- language: z.ZodEnum<{
2482
- shell: "shell";
2483
- sql: "sql";
2484
- typescript: "typescript";
2485
- python: "python";
2486
- }>;
2487
- source: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
2488
- file: z.ZodString;
2489
- }, z.core.$strip>]>;
2490
- }, z.core.$strip>], "kind">>>>;
2491
- topology: z.ZodDefault<z.ZodDefault<z.ZodObject<{
2492
- version: z.ZodDefault<z.ZodLiteral<1>>;
2493
- relationships: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2494
- from: z.ZodDiscriminatedUnion<[z.ZodObject<{
2495
- kind: z.ZodLiteral<"system">;
2496
- id: z.ZodString;
2497
- }, z.core.$strip>, z.ZodObject<{
2498
- kind: z.ZodLiteral<"resource">;
2499
- id: z.ZodString;
2500
- }, z.core.$strip>, z.ZodObject<{
2501
- kind: z.ZodLiteral<"ontology">;
2502
- id: z.ZodString;
2503
- }, z.core.$strip>, z.ZodObject<{
2504
- kind: z.ZodLiteral<"role">;
2505
- id: z.ZodString;
2506
- }, z.core.$strip>, z.ZodObject<{
2507
- kind: z.ZodLiteral<"trigger">;
2508
- id: z.ZodString;
2509
- }, z.core.$strip>, z.ZodObject<{
2510
- kind: z.ZodLiteral<"humanCheckpoint">;
2511
- id: z.ZodString;
2512
- }, z.core.$strip>, z.ZodObject<{
2513
- kind: z.ZodLiteral<"externalResource">;
2514
- id: z.ZodString;
2515
- }, z.core.$strip>], "kind">;
2516
- kind: z.ZodEnum<{
2517
- triggers: "triggers";
2518
- uses: "uses";
2519
- approval: "approval";
2520
- }>;
2521
- to: z.ZodDiscriminatedUnion<[z.ZodObject<{
2522
- kind: z.ZodLiteral<"system">;
2523
- id: z.ZodString;
2524
- }, z.core.$strip>, z.ZodObject<{
2525
- kind: z.ZodLiteral<"resource">;
2526
- id: z.ZodString;
2527
- }, z.core.$strip>, z.ZodObject<{
2528
- kind: z.ZodLiteral<"ontology">;
2529
- id: z.ZodString;
2530
- }, z.core.$strip>, z.ZodObject<{
2531
- kind: z.ZodLiteral<"role">;
2532
- id: z.ZodString;
2533
- }, z.core.$strip>, z.ZodObject<{
2534
- kind: z.ZodLiteral<"trigger">;
2535
- id: z.ZodString;
2536
- }, z.core.$strip>, z.ZodObject<{
2537
- kind: z.ZodLiteral<"humanCheckpoint">;
2538
- id: z.ZodString;
2539
- }, z.core.$strip>, z.ZodObject<{
2540
- kind: z.ZodLiteral<"externalResource">;
2541
- id: z.ZodString;
2542
- }, z.core.$strip>], "kind">;
2543
- systemPath: z.ZodOptional<z.ZodString>;
2544
- required: z.ZodOptional<z.ZodBoolean>;
2545
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
2546
- }, z.core.$strip>>>;
2547
- }, z.core.$strip>>>;
2548
- actions: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2549
- id: z.ZodString;
2550
- order: z.ZodNumber;
2551
- label: z.ZodString;
2552
- description: z.ZodOptional<z.ZodString>;
2553
- scope: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"global">, z.ZodObject<{
2554
- domain: z.ZodString;
2555
- }, z.core.$strip>]>>;
2556
- resourceId: z.ZodOptional<z.ZodString>;
2557
- affects: z.ZodOptional<z.ZodArray<z.ZodString>>;
2558
- invocations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2559
- kind: z.ZodLiteral<"slash-command">;
2560
- command: z.ZodString;
2561
- toolFactory: z.ZodOptional<z.ZodString>;
2562
- }, z.core.$strip>, z.ZodObject<{
2563
- kind: z.ZodLiteral<"mcp-tool">;
2564
- server: z.ZodString;
2565
- name: z.ZodString;
2566
- }, z.core.$strip>, z.ZodObject<{
2567
- kind: z.ZodLiteral<"api-endpoint">;
2568
- method: z.ZodEnum<{
2569
- GET: "GET";
2570
- POST: "POST";
2571
- PATCH: "PATCH";
2572
- DELETE: "DELETE";
2573
- }>;
2574
- path: z.ZodString;
2575
- requestSchema: z.ZodOptional<z.ZodString>;
2576
- responseSchema: z.ZodOptional<z.ZodString>;
2577
- }, z.core.$strip>, z.ZodObject<{
2578
- kind: z.ZodLiteral<"script-execution">;
2579
- resourceId: z.ZodString;
2580
- }, z.core.$strip>], "kind">>>;
2581
- knowledge: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
2582
- lifecycle: z.ZodDefault<z.ZodEnum<{
2583
- active: "active";
2584
- deprecated: "deprecated";
2585
- draft: "draft";
2586
- beta: "beta";
2587
- archived: "archived";
2588
- }>>;
2589
- }, z.core.$strip>>>>;
2590
- entities: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2591
- id: z.ZodString;
2592
- order: z.ZodNumber;
2593
- label: z.ZodString;
2594
- description: z.ZodOptional<z.ZodString>;
2595
- ownedBySystemId: z.ZodString;
2596
- table: z.ZodOptional<z.ZodString>;
2597
- rowSchema: z.ZodOptional<z.ZodString>;
2598
- stateCatalogId: z.ZodOptional<z.ZodString>;
2599
- links: z.ZodOptional<z.ZodArray<z.ZodObject<{
2600
- toEntity: z.ZodString;
2601
- kind: z.ZodEnum<{
2602
- "belongs-to": "belongs-to";
2603
- "has-many": "has-many";
2604
- "has-one": "has-one";
2605
- "many-to-many": "many-to-many";
2606
- }>;
2607
- via: z.ZodOptional<z.ZodString>;
2608
- label: z.ZodOptional<z.ZodString>;
2609
- }, z.core.$strip>>>;
2610
- }, z.core.$strip>>>>;
2611
- knowledge: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2612
- id: z.ZodString;
2613
- kind: z.ZodEnum<{
2614
- playbook: "playbook";
2615
- strategy: "strategy";
2616
- reference: "reference";
2617
- }>;
2618
- title: z.ZodString;
2619
- summary: z.ZodString;
2620
- icon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
2621
- message: "message";
2622
- error: "error";
2623
- agent: "agent";
2624
- workflow: "workflow";
2625
- "google-sheets": "google-sheets";
2626
- dashboard: "dashboard";
2627
- calendar: "calendar";
2628
- sales: "sales";
2629
- crm: "crm";
2630
- "lead-gen": "lead-gen";
2631
- projects: "projects";
2632
- clients: "clients";
2633
- operations: "operations";
2634
- monitoring: "monitoring";
2635
- knowledge: "knowledge";
2636
- settings: "settings";
2637
- admin: "admin";
2638
- archive: "archive";
2639
- business: "business";
2640
- finance: "finance";
2641
- platform: "platform";
2642
- seo: "seo";
2643
- playbook: "playbook";
2644
- strategy: "strategy";
2645
- reference: "reference";
2646
- integration: "integration";
2647
- database: "database";
2648
- user: "user";
2649
- team: "team";
2650
- gmail: "gmail";
2651
- attio: "attio";
2652
- overview: "overview";
2653
- "command-view": "command-view";
2654
- "command-queue": "command-queue";
2655
- pipeline: "pipeline";
2656
- lists: "lists";
2657
- resources: "resources";
2658
- approve: "approve";
2659
- reject: "reject";
2660
- retry: "retry";
2661
- edit: "edit";
2662
- view: "view";
2663
- launch: "launch";
2664
- "message-plus": "message-plus";
2665
- escalate: "escalate";
2666
- promote: "promote";
2667
- submit: "submit";
2668
- email: "email";
2669
- success: "success";
2670
- warning: "warning";
2671
- info: "info";
2672
- pending: "pending";
2673
- bolt: "bolt";
2674
- building: "building";
2675
- briefcase: "briefcase";
2676
- apps: "apps";
2677
- graph: "graph";
2678
- shield: "shield";
2679
- users: "users";
2680
- "chart-bar": "chart-bar";
2681
- search: "search";
2682
- }>, z.ZodString]>>;
2683
- externalUrl: z.ZodOptional<z.ZodString>;
2684
- sourceFilePath: z.ZodOptional<z.ZodString>;
2685
- body: z.ZodString;
2686
- links: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodUnion<readonly [z.ZodObject<{
2687
- target: z.ZodObject<{
2688
- kind: z.ZodEnum<{
2689
- knowledge: "knowledge";
2690
- system: "system";
2691
- resource: "resource";
2692
- action: "action";
2693
- ontology: "ontology";
2694
- role: "role";
2695
- client: "client";
2696
- stage: "stage";
2697
- goal: "goal";
2698
- "customer-segment": "customer-segment";
2699
- offering: "offering";
2700
- }>;
2701
- id: z.ZodString;
2702
- }, z.core.$strip>;
2703
- }, z.core.$strip>, z.ZodObject<{
2704
- nodeId: z.ZodUnion<readonly [z.ZodString, z.ZodTemplateLiteral<`ontology:${string}`>]>;
2705
- }, z.core.$strip>]>, z.ZodTransform<{
2706
- target: {
2707
- kind: "knowledge" | "system" | "resource" | "action" | "ontology" | "role" | "client" | "stage" | "goal" | "customer-segment" | "offering";
2708
- id: string;
2709
- };
2710
- nodeId: string;
2711
- }, {
2712
- nodeId: string;
2713
- } | {
2714
- target: {
2715
- kind: "knowledge" | "system" | "resource" | "action" | "ontology" | "role" | "client" | "stage" | "goal" | "customer-segment" | "offering";
2716
- id: string;
2717
- };
2718
- }>>>>;
2719
- ownerIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
2720
- updatedAt: z.ZodString;
2721
- }, z.core.$strip>>>>;
2722
- }, z.core.$strip>;
2723
-
2724
- type OrganizationModel = z.infer<typeof OrganizationModelSchema>;
2725
- type OrganizationModelResourceOntologyBinding = z.infer<typeof ResourceOntologyBindingSchema>;
2726
- type OrganizationModelWorkflowResourceEntry = z.infer<typeof WorkflowResourceEntrySchema>;
2727
- type OrganizationModelAgentResourceEntry = z.infer<typeof AgentResourceEntrySchema>;
2728
- type OrganizationModelIntegrationResourceEntry = z.infer<typeof IntegrationResourceEntrySchema>;
2729
-
2730
- /**
2731
- * AIUsageCollector
2732
- * Centralized token tracking that aggregates usage across all LLM calls in an execution
2733
- */
2734
- declare class AIUsageCollector {
2735
- private model;
2736
- private calls;
2737
- private callSequence;
2738
- /**
2739
- * Record a single AI call with usage metrics
2740
- *
2741
- * @param usage - Token usage and latency data from LLM adapter
2742
- * @param callType - Type discriminator (agent-reasoning, tool, etc.)
2743
- * @param context - Optional typed context specific to callType
2744
- */
2745
- record(usage: LLMUsageData, callType?: BaseAICall['callType'], context?: AICallContext): void;
2746
- /**
2747
- * Get aggregated summary of all AI calls
2748
- */
2749
- getSummary(): AIUsageSummary;
2750
- /**
2751
- * Check if any usage has been recorded
2752
- */
2753
- hasUsage(): boolean;
2754
- }
2755
-
2756
- /**
2757
- * MetricsCollector
2758
- * Tracks execution timing and ROI metrics
2759
- */
2760
- declare class MetricsCollector {
2761
- private timings;
2762
- private durationMs?;
2763
- /**
2764
- * Start a timer with a label
2765
- */
2766
- startTimer(label: string): void;
2767
- /**
2768
- * End a timer and calculate duration
2769
- * If label is 'execution', stores duration for metrics summary
2770
- */
2771
- endTimer(label: string): number | null;
2772
- /**
2773
- * Build execution metrics summary with optional ROI calculation
2774
- */
2775
- buildExecutionMetrics(metricsConfig?: ResourceMetricsConfig): ExecutionMetricsSummary;
2776
- }
2777
-
2778
- /**
2779
- * Which `role:'user'` message slot a sanitizer warning came from, derived from the request's
2780
- * message array (no new plumbing from callers):
2781
- * - `'memory-context'` — the framework's framing message, identified by the `=== MEMORY STATUS ===`
2782
- * banner. Framework-authored and trusted; it is no longer scanned at all, so this source should
2783
- * not appear for agent calls. Retained because stale tenant bundles still emit the old combined
2784
- * block, and their rows must stay readable.
2785
- * - `'data-envelope'` — the JSON envelope carrying every stored fragment. Untrusted, and the slot
2786
- * where a match is genuine signal.
2787
- * - `'input'` — the turn's own input, on its own message. Also untrusted.
2788
- * - `'history'` — replayed prior turns. Untrusted, but already screened at their own front door,
2789
- * so warnings here are recorded and never block (see `screenInput`).
2790
- */
2791
- type InputWarningSource = 'memory-context' | 'data-envelope' | 'history' | 'input';
2792
- /** Per-source breakdown of sanitizer warnings, so a memory-context echo is distinguishable from a genuine hit. */
2793
- interface SourcedInputWarnings {
2794
- source: InputWarningSource;
2795
- warnings: string[];
2796
- }
2797
- interface BaseAICall {
2798
- callSequence: number;
2799
- callType: 'agent-reasoning' | 'agent-completion' | 'workflow-step' | 'tool' | 'other';
2800
- model: LLMModel;
2801
- inputTokens: number;
2802
- outputTokens: number;
2803
- costUsd: number;
2804
- latencyMs: number;
2805
- context?: AICallContext;
2806
- /**
2807
- * Anthropic-only: input tokens served from the prompt cache this call (`cache_read_input_tokens`),
2808
- * billed at 0.1x the base input rate. Already folded into `inputTokens`/`totalInputTokens` so
2809
- * aggregate totals reflect real usage -- present here as the raw breakdown, not additive on top.
2810
- */
2811
- cacheReadInputTokens?: number;
2812
- /**
2813
- * Anthropic-only: input tokens written to the prompt cache this call (`cache_creation_input_tokens`),
2814
- * billed at 1.25x the base input rate. Same folding rationale as `cacheReadInputTokens`.
2815
- */
2816
- cacheCreationInputTokens?: number;
2817
- /**
2818
- * Distinct prompt-injection pattern types detected in the request's user-role messages.
2819
- * Present only when the input sanitizer matched something. Non-blocking matches ride along on
2820
- * the successful call's row; a blocked call records a row of its own (see `inputBlocked`).
2821
- *
2822
- * Flat union across all `role:'user'` messages — unchanged shape, kept for existing readers.
2823
- * See `inputWarningsBySource` for the per-slot breakdown.
2824
- */
2825
- inputWarnings?: string[];
2826
- /**
2827
- * Additive breakdown of `inputWarnings` by message slot (see `InputWarningSource`). Present only
2828
- * when at least one source produced a warning. Existing readers that only look at the flat
2829
- * `inputWarnings` array are unaffected.
2830
- */
2831
- inputWarningsBySource?: SourcedInputWarnings[];
2832
- /**
2833
- * True when the sanitizer blocked the request and no provider call was made.
2834
- * Such a row carries zero tokens, zero cost, and zero latency — it exists so a hard,
2835
- * user-visible failure is observable at all. Before this, a blocked call produced no row.
2836
- */
2837
- inputBlocked?: boolean;
2838
- /**
2839
- * The validator's message when the provider responded but its output failed `responseSchema`
2840
- * validation (e.g. `missing required field 'nextActions'`). Present only on such a row.
2841
- *
2842
- * This is NOT the blocked-input case: the provider DID respond and tokens WERE spent, so the row
2843
- * carries real `inputTokens`, `outputTokens`, cost and latency. It is a paid call that produced
2844
- * nothing usable, and before this it produced no row at all.
2845
- *
2846
- * One row per failed attempt — the adapter retries a validation failure up to `LLM_MAX_ATTEMPTS`,
2847
- * so a turn that exhausts its retries records three. Reading `inputTokens` across these rows is
2848
- * what measures malformed-output rate against context size rather than inferring it.
2849
- *
2850
- * Existing readers that only look at the fields above are unaffected.
2851
- */
2852
- outputValidationError?: string;
2853
- /**
2854
- * The raw model output that failed validation, JSON-stringified and truncated to a bounded
2855
- * length. Truncation is visible in the value itself (a trailing `…[truncated: N chars total]`),
2856
- * never silent. Present only alongside `outputValidationError`.
2857
- */
2858
- unvalidatedOutput?: string;
2859
- /**
2860
- * What happened to `strict` structured output on this call — `applied`, `refused`,
2861
- * `compileRejected`, or `notAttempted`. Every server adapter sets it, so this is the field that
2862
- * answers "is this agent's output actually being enforced?" without reading source.
2863
- *
2864
- * It replaces an inference that turned out to be unsound. `strictRefusalReasons` alone records
2865
- * only refusals, so an empty row meant "strict held" OR "this adapter never tries" — and a prod
2866
- * run recorded zero refusals while a call returned an array-typed field as a string, which a
2867
- * grammar makes impossible. The absence proved nothing, because the deployed API had no way to
2868
- * write the field at all.
2869
- *
2870
- * Absent on rows written before this field existed; that absence is itself diagnostic (the API
2871
- * predates the change). Existing readers that only look at the fields above are unaffected.
2872
- */
2873
- strictStatus?: StrictStatus;
2874
- /**
2875
- * Why this call went out without `strict`, when a strict-capable adapter refused the schema. The
2876
- * detail behind `strictStatus: 'refused' | 'compileRejected'` — read `strictStatus` for whether
2877
- * it was enforced, this for why not.
2878
- *
2879
- * Existing readers that only look at the fields above are unaffected.
2880
- */
2881
- strictRefusalReasons?: string[];
2882
- /**
2883
- * Time spent in the base adapter's `generate()` call alone, excluding `responseSchema`
2884
- * validation. On a success or validation-failure row, `providerMs + validateMs === latencyMs`
2885
- * (modulo rounding) -- `latencyMs` keeps its existing meaning unchanged; this and `validateMs`
2886
- * are the same window split into its two components.
2887
- *
2888
- * Present on success and validation-failure rows. Absent on a blocked row (no provider call was
2889
- * made) and on rows written before this field existed.
2890
- */
2891
- providerMs?: number;
2892
- /**
2893
- * Time spent in `validateResponseSchema` alone. Omitted when the call carried no `responseSchema`
2894
- * (nothing to validate); `0` is a legitimate value meaning a schema was supplied and validation
2895
- * was effectively instant. See `providerMs` for how the two relate to `latencyMs`.
2896
- *
2897
- * Present on success and validation-failure rows that supplied a `responseSchema`. Absent on a
2898
- * blocked row and on rows written before this field existed.
2899
- */
2900
- validateMs?: number;
2901
- /**
2902
- * Total elapsed time for the WHOLE `generate()` call -- every retry attempt plus every backoff
2903
- * sleep between them. Unlike `latencyMs` (which is per-attempt and never includes backoff, by
2904
- * design -- see `runWithRetry`), this is the one number that answers "how long did the caller
2905
- * actually wait". On a call that never retried, `wallClockMs === latencyMs`. On a retried call,
2906
- * `wallClockMs` is strictly greater than any individual row's `latencyMs` from that same call, by
2907
- * at least the backoff time actually slept.
2908
- *
2909
- * The same value is attached to every row produced by one `generate()` call (a validation-failure
2910
- * row from an earlier attempt included), because it describes the call, not the attempt.
2911
- *
2912
- * Present on success and validation-failure rows. Absent on a blocked row -- a blocked call never
2913
- * reaches the retry loop, so `wallClockMs` would just restate `latencyMs` (0). Absent on rows
2914
- * written before this field existed.
2915
- */
2916
- wallClockMs?: number;
2917
- }
2918
- type AICallContext = AgentReasoningContext | AgentCompletionContext | WorkflowStepContext | ToolCallContext | OtherCallContext;
2919
- interface AgentReasoningContext {
2920
- type: 'agent-reasoning';
2921
- iteration: number;
2922
- actionsPlanned?: string[];
2923
- sessionId?: string;
2924
- turnNumber?: number;
2925
- }
2926
- interface AgentCompletionContext {
2927
- type: 'agent-completion';
2928
- attempt: 1 | 2;
2929
- validationFailed?: boolean;
2930
- sessionId?: string;
2931
- turnNumber?: number;
2932
- }
2933
- interface WorkflowStepContext {
2934
- type: 'workflow-step';
2935
- stepId: string;
2936
- stepName?: string;
2937
- stepSequence?: number;
2938
- }
2939
- interface ToolCallContext {
2940
- type: 'tool';
2941
- toolName: string;
2942
- parentIteration?: number;
2943
- parentStepId?: string;
2944
- }
2945
- interface OtherCallContext {
2946
- type: 'other';
2947
- description?: string;
2948
- metadata?: Record<string, unknown>;
2949
- }
2950
- type AICallRecord = BaseAICall;
2951
- /**
2952
- * Raw LLM usage data returned by adapters
2953
- * Used as input to AIUsageCollector.record()
2954
- */
2955
- interface LLMUsageData {
2956
- model: LLMModel;
2957
- inputTokens: number;
2958
- outputTokens: number;
2959
- latencyMs: number;
2960
- /** Actual cost from provider in USD (when available, e.g., OpenRouter) */
2961
- cost?: number;
2962
- /**
2963
- * Anthropic-only: input tokens served from the prompt cache (`cache_read_input_tokens`), billed at
2964
- * 0.1x the base input rate. Absent for providers that never report it (OpenAI, OpenRouter).
2965
- */
2966
- cacheReadInputTokens?: number;
2967
- /**
2968
- * Anthropic-only: input tokens written to the prompt cache this call
2969
- * (`cache_creation_input_tokens`), billed at 1.25x the base input rate. Same absence rationale.
2970
- */
2971
- cacheCreationInputTokens?: number;
2972
- /** Distinct prompt-injection pattern types detected in the request's user-role messages */
2973
- inputWarnings?: string[];
2974
- /** Additive per-source breakdown of `inputWarnings` — see `SourcedInputWarnings` */
2975
- inputWarningsBySource?: SourcedInputWarnings[];
2976
- /** True when the sanitizer blocked the request and no provider call was made */
2977
- inputBlocked?: boolean;
2978
- /** Validator message when the provider responded but the output failed `responseSchema` validation */
2979
- outputValidationError?: string;
2980
- /** Raw model output that failed validation — JSON-stringified, truncated, truncation marked inline */
2981
- unvalidatedOutput?: string;
2982
- /** What happened to `strict` on this call — set by every server adapter, refusal or not */
2983
- strictStatus?: StrictStatus;
2984
- /** Why the call went out unstrict, when a strict-capable adapter refused the schema */
2985
- strictRefusalReasons?: string[];
2986
- /** Time in the base adapter's `generate()` alone, excluding `responseSchema` validation. See `BaseAICall.providerMs`. */
2987
- providerMs?: number;
2988
- /** Time in `validateResponseSchema` alone. Omitted when no `responseSchema` was supplied. See `BaseAICall.validateMs`. */
2989
- validateMs?: number;
2990
- /** Total elapsed for the whole `generate()` call, including every retry and every backoff sleep. See `BaseAICall.wallClockMs`. */
2991
- wallClockMs?: number;
2992
- }
2993
- interface AIUsageSummary {
2994
- model: LLMModel;
2995
- totalInputTokens: number;
2996
- totalOutputTokens: number;
2997
- totalTokens: number;
2998
- totalCostUsd: number;
2999
- callCount: number;
3000
- calls: AICallRecord[];
3001
- }
3002
- interface ExecutionMetricsSummary {
3003
- durationMs?: number;
3004
- automationSavingsUsd?: number;
3005
- }
3006
- interface ResourceMetricsConfig {
3007
- estimatedManualMinutes: number;
3008
- hourlyLaborRateUsd: number;
3009
- confidenceLevel?: 'low' | 'medium' | 'high';
3010
- notes?: string;
3011
- }
3012
-
3013
- /**
3014
- * Agent-specific type definitions
3015
- * Types for autonomous agents with tools, memory, and constraints
3016
- */
3017
-
3018
- /**
3019
- * Factory function for creating LLM adapters.
3020
- * Injected into the Agent class to decouple the engine from server-only provider SDKs.
3021
- * - API process: provides createLLMAdapter (real SDKs + process.env API keys)
3022
- * - SDK worker: provides PostMessageLLMAdapter (proxies via platform.call)
3023
- *
3024
- * Signature mirrors `createLLMAdapter`'s real parameter list. `context` is narrowed to the two
3025
- * shapes an agent ever actually builds (`processReasoning` passes `AgentReasoningContext`,
3026
- * `Agent.callLLMForOutput` passes `AgentCompletionContext`) rather than the full `AICallContext`
3027
- * union `createLLMAdapter` accepts -- a narrower optional param here is still assignable to the
3028
- * wider one there. `createPostMessageAdapterFactory()`'s worker proxy ignores every param past
3029
- * `config`; a shorter-arity function remains assignable to a longer optional-param function type,
3030
- * so it still satisfies this type unchanged.
3031
- */
3032
- type LLMAdapterFactory = (config: ModelConfig, aiUsageCollector?: AIUsageCollector, callType?: BaseAICall['callType'], context?: AgentReasoningContext | AgentCompletionContext, organizationId?: string) => LLMAdapter;
3033
- type AgentKind = 'orchestrator' | 'specialist' | 'utility' | 'platform';
3034
- interface AgentConfig extends ResourceDefinition {
3035
- type: 'agent';
3036
- /** OM descriptor backing canonical identity and governance metadata. */
3037
- resource?: AgentResourceEntry;
3038
- kind: AgentKind;
3039
- systemPrompt: string;
3040
- constraints?: AgentConstraints;
3041
- /**
3042
- * Session capability declaration (opt-in)
3043
- * If true, agent is designed for multi-turn session interactions
3044
- * Controls whether agent can use message action and appears in Sessions UI
3045
- *
3046
- * Use for:
3047
- * - Conversational agents with multi-turn interactions
3048
- * - Agents requiring persistent context across turns
3049
- * - Agents that need human-in-the-loop communication
3050
- */
3051
- sessionCapable?: boolean;
3052
- /**
3053
- * Overrides the default `message` requiredness for a session-capable agent (ignored for
3054
- * non-session agents, which always get `AgentCapabilities.message: 'off'`). Defaults to
3055
- * `'required'` -- see `AgentCapabilities.message`'s doc comment for why. Set `'optional'` only
3056
- * when the agent legitimately needs tool-only turns with no reply, and the deploy target can
3057
- * tolerate the blind-retry risk `validateResponseSchema` carries on any path where the schema is
3058
- * not compiled into a sampling grammar.
3059
- */
3060
- messagePolicy?: 'optional' | 'required';
3061
- /**
3062
- * Explicit opt-in to skip the iteration loop and produce `contract.outputSchema`-shaped output in
3063
- * a single LLM call (round 3 decision B6: explicit opt-in, never inferred from `kind`,
3064
- * `sessionCapable`, or tool count -- so no existing agent changes shape by default). Structurally
3065
- * the normal path pays two calls minimum: `iterate()` always runs at least one, and `complete()`
3066
- * runs a second whose prompt re-derives the answer from history rather than reading what the
3067
- * iteration already decided. A single-shot classifier -- one input in, one structured output out,
3068
- * no multi-step reasoning needed -- does not need that second derivation; `complete()` already
3069
- * makes exactly the one call it needs, from `currentInput` directly.
3070
- *
3071
- * Requires `sessionCapable` to be falsy and `contract.outputSchema` to be present. `Agent`
3072
- * validates both during initialization and throws `AgentInitializationError` if either is missing,
3073
- * rather than silently falling back to the normal two-call path on a misconfigured opt-in. Tools
3074
- * registered on the agent are never invoked in this path -- there is no iteration loop to call
3075
- * them from, so an agent that needs tool calls before it can answer is not eligible regardless of
3076
- * this flag.
3077
- */
3078
- singleShot?: boolean;
3079
- /**
3080
- * Security level for system prompt hardening (auto-derived if omitted)
3081
- *
3082
- * - 'standard': Lightweight defense (3 rules) - default for non-session agents
3083
- * - 'hardened': Comprehensive defense (5 rules) - default for session-capable agents
3084
- * - 'none': No security prompt - for pure internal agents with no external input
3085
- *
3086
- * If omitted, derived from sessionCapable:
3087
- * sessionCapable: true -> 'hardened'
3088
- * sessionCapable: false -> 'standard'
3089
- */
3090
- securityLevel?: 'standard' | 'hardened' | 'none';
3091
- /**
3092
- * Memory management preferences (opt-in)
3093
- * If provided, agent can use memoryOps to manage session memory
3094
- * If omitted, agent has no memory management capabilities
3095
- *
3096
- * Agent-specific guidance on what to preserve, when to persist, and what to clean up.
3097
- * This guidance is injected into the system prompt when memory management is enabled.
3098
- *
3099
- * Use for:
3100
- * - Conversational agents needing cross-turn context
3101
- * - Agents managing complex user preferences
3102
- * - Agents tracking decisions over multiple iterations
3103
- */
3104
- memoryPreferences?: string;
3105
- }
3106
- interface AgentConstraints {
3107
- maxIterations?: number;
3108
- timeout?: number;
3109
- maxSessionMemoryKeys?: number;
3110
- maxMemoryTokens?: number;
3111
- }
3112
- interface AgentDefinition {
3113
- config: AgentConfig;
3114
- contract: Contract;
3115
- tools: Tool[];
3116
- /**
3117
- * Model configuration for LLM execution
3118
- * Specifies provider, API key, and model-specific options
3119
- */
3120
- modelConfig: ModelConfig;
3121
- /**
3122
- * Preload memory before execution starts
3123
- * Handles BOTH context loading AND session restoration
3124
- *
3125
- * @param context - Execution context (includes sessionId if session turn)
3126
- * @returns Initial AgentMemory state (sessionMemory entries + optionally history)
3127
- */
3128
- preloadMemory?: (context: ExecutionContext) => Promise<AgentMemory> | AgentMemory;
3129
- /**
3130
- * Metrics configuration for ROI calculations
3131
- * Optional: Only needed if tracking automation savings
3132
- */
3133
- metricsConfig?: ResourceMetricsConfig;
3134
- /**
3135
- * Execution interface configuration (optional)
3136
- * If provided, agent appears in Execution Runner UI
3137
- */
3138
- interface?: ExecutionInterface;
3139
- }
3140
- /**
3141
- * Agent execution context
3142
- * Groups all state needed for agent execution phases
3143
- */
3144
- interface IterationContext {
3145
- config: AgentConfig;
3146
- contract: Contract;
3147
- toolRegistry: Map<string, Tool>;
3148
- memoryManager: MemoryManager;
3149
- executionContext: ExecutionContext;
3150
- iteration: number;
3151
- logger: AgentScopedLogger;
3152
- modelConfig: ModelConfig;
3153
- adapterFactory: LLMAdapterFactory;
3154
- /**
3155
- * The validated input for this execution, serialized. It travels here because the model gets
3156
- * it as its own `role:'user'` message; nothing else in this context carried it, so the input
3157
- * had to be read back out of memory history and shipped inside the memory block.
3158
- */
3159
- currentInput: string;
3160
- }
3161
-
3162
- /**
3163
- * Base Execution Engine type definitions
3164
- * Core types shared across all Execution Engine resources
3165
- */
3166
-
3167
- /**
3168
- * Immutable execution metadata
3169
- * Represents complete execution identity (who, what, when, where)
3170
- * Shared across ExecutionContext and ExecutionLoggerContext to eliminate field duplication
3171
- */
3172
- interface ExecutionMetadata {
3173
- executionId: string;
3174
- organizationId: string;
3175
- organizationName: string;
3176
- resourceId: string;
3177
- userId?: string;
3178
- sessionId?: string;
3179
- sessionTurnNumber?: number;
3180
- }
3181
- /**
3182
- * Unified message event type - covers all message types in sessions
3183
- * Replaces separate SessionTurnMessages and AgentActivityEvent mechanisms
3184
- */
3185
- /**
3186
- * Structured action metadata attached to assistant messages.
3187
- * Frontend reads this instead of parsing text prefixes.
3188
- */
3189
- type AssistantAction = {
3190
- kind: 'navigate';
3191
- path: string;
3192
- reason: string;
3193
- } | {
3194
- kind: 'update_filters';
3195
- timeRange: string | null;
3196
- statusFilter: string | null;
3197
- searchQuery: string | null;
3198
- };
3199
- type MessageEvent = {
3200
- type: 'user_message';
3201
- text: string;
3202
- } | {
3203
- type: 'assistant_message';
3204
- text: string;
3205
- _action?: AssistantAction;
3206
- } | {
3207
- type: 'agent:started';
3208
- } | {
3209
- type: 'agent:completed';
3210
- } | {
3211
- type: 'agent:error';
3212
- error: string;
3213
- } | {
3214
- type: 'agent:reasoning';
3215
- iteration: number;
3216
- reasoning: string;
3217
- } | {
3218
- type: 'agent:tool_call';
3219
- toolName: string;
3220
- args: Record<string, unknown>;
3221
- } | {
3222
- type: 'agent:tool_result';
3223
- toolName: string;
3224
- success: boolean;
3225
- result?: unknown;
3226
- error?: string;
3227
- };
3228
- /**
3229
- * A message from an earlier turn of this session.
3230
- *
3231
- * Deliberately lean (no ids, timestamps, or event metadata): this crosses the
3232
- * parent -> worker payload boundary and is replayed verbatim into the model's message
3233
- * array, so it carries only what the model needs to read the conversation.
3234
- */
3235
- interface ConversationMessage {
3236
- role: 'user' | 'assistant';
3237
- content: string;
3238
- }
3239
- /**
3240
- * Execution context for all resources
3241
- * Unified callback replaces SessionTurnMessages (removed)
3242
- */
3243
- interface ExecutionContext extends ExecutionMetadata {
3244
- logger: IExecutionLogger;
3245
- signal?: AbortSignal;
3246
- /**
3247
- * This session's earlier turns, oldest first, as actually said.
3248
- *
3249
- * A session agent is handed its own conversation: these are replayed into the model's
3250
- * message array as real user/assistant turns. Absent for one-off (non-session)
3251
- * executions. The session layer bounds this before it is sent -- see
3252
- * `selectConversationHistory`.
3253
- */
3254
- conversationHistory?: ConversationMessage[];
3255
- onMessageEvent?: (event: MessageEvent) => Promise<void>;
3256
- /** Called per iteration to write heartbeat + check stall status. Non-fatal if it throws. */
3257
- onHeartbeat?: () => Promise<void>;
3258
- aiUsageCollector?: AIUsageCollector;
3259
- metricsCollector?: MetricsCollector;
3260
- parentExecutionId?: string;
3261
- executionDepth: number;
3262
- credentialName?: string;
3263
- store: Map<string, unknown>;
3264
- }
3265
- interface Contract {
3266
- inputSchema: z.ZodSchema;
3267
- outputSchema?: z.ZodSchema;
3268
- }
3269
-
3270
- /**
3271
- * Tool definitions
3272
- *
3273
- * Tool interface used by agents and workflows.
3274
- * Provides a universal interface for AI systems to interact with tools.
3275
- */
3276
-
3277
- /**
3278
- * Options for tool execution
3279
- * Provides named parameters for better API clarity and extensibility
3280
- */
3281
- interface ToolExecutionOptions {
3282
- /** Tool input (validated against inputSchema before execution) */
3283
- input: unknown;
3284
- /** Execution context with multi-tenant isolation and observability (optional for simple tools, required for platform/integration tools) */
3285
- executionContext?: ExecutionContext;
3286
- /** Full iteration context for advanced tools (provides access to memoryManager, toolRegistry, logger, etc.) */
3287
- iterationContext?: IterationContext;
3288
- /** Abort signal for timeout/cancellation -- forward to fetch() calls for clean cancellation */
3289
- signal?: AbortSignal;
3290
- }
3291
- /**
3292
- * Tool interface for AI systems
3293
- *
3294
- * Used by:
3295
- * - Agents: For agentic tool use (reasoning loop selects and executes tools)
3296
- * - Workflows: For workflow step tool invocation (future)
3297
- * - Platform tools: createApprovalTool(), createSchedulerTool()
3298
- * - Integration tools: External API calls (Gmail, Slack, etc.)
3299
- */
3300
- interface Tool {
3301
- name: string;
3302
- description: string;
3303
- inputSchema: z.ZodSchema;
3304
- outputSchema: z.ZodSchema;
3305
- execute: (options: ToolExecutionOptions) => Promise<unknown>;
3306
- timeout?: number;
3307
- /**
3308
- * Optional per-tool output size bound, in approximate tokens. Today the ONLY size bound on tool
3309
- * output is a 4,000-token truncation applied post-hoc at memory insert -- after the payload is
3310
- * already fully materialized, validated against `outputSchema`, emitted as a session message, and
3311
- * logged. This field exists so a tool can declare its own bound up front instead.
3312
- *
3313
- * Enforcement is NOT here. `executor.ts:executeToolCall` is the single call site that produces the
3314
- * value handed to all four sinks (memory, the `agent:tool_result` event, the session message, and
3315
- * the log line) -- enforcing there, before that value is emitted, is what makes the four sinks agree
3316
- * instead of three of them seeing the untruncated payload. See that file's own comment for the
3317
- * exact insertion point.
3318
- */
3319
- maxOutputTokens?: number;
3320
- }
3321
-
3322
- /**
3323
- * Supported integration types
3324
- *
3325
- * These represent the available integration adapters that can be used with tools.
3326
- * Each integration type corresponds to an adapter implementation.
3327
- *
3328
- * Note: Concrete adapter implementations are deferred until needed.
3329
- * This type provides compile-time safety and auto-completion for tool definitions.
3330
- */
3331
- 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';
3332
-
3333
- /**
3334
- * Resource Registry type definitions
3335
- */
3336
-
3337
- /**
3338
- * Environment/deployment status for resources
3339
- */
3340
- type ResourceStatus = 'dev' | 'prod';
3341
- /**
3342
- * All resource types in the platform
3343
- * Used as the discriminator field in ResourceDefinition
3344
- */
3345
- type ResourceType = 'agent' | 'workflow' | 'trigger' | 'integration' | 'external' | 'human';
3346
- type ResourceSystemSummary = Pick<SystemEntry, 'id' | 'title' | 'description' | 'kind' | 'lifecycle'>;
3347
- /**
3348
- * Base interface for ALL platform resources
3349
- * Shared by both executable (agents, workflows) and non-executable (triggers, integrations, etc.) resources
3350
- */
3351
- interface ResourceDefinition {
3352
- /** Unique resource identifier */
3353
- resourceId: string;
3354
- /** Display name */
3355
- name: string;
3356
- /** Purpose and functionality description */
3357
- description: string;
3358
- /** Version for change tracking and evolution */
3359
- version: string;
3360
- /** Resource type discriminator */
3361
- type: ResourceType;
3362
- /** Environment/deployment status */
3363
- status: ResourceStatus;
3364
- /** Graph links to Organization Model nodes */
3365
- links?: ResourceLink[];
3366
- /** Infrastructure category for filtering */
3367
- category?: ResourceCategory;
3368
- /** Whether the agent supports multi-turn sessions (agents only) */
3369
- sessionCapable?: boolean;
3370
- /** Whether the resource is local (monorepo) or remote (externally deployed) */
3371
- origin?: 'local' | 'remote';
3372
- /** OM System membership — dot-separated system path (e.g. "sys.lead-gen"), when backed by a Resource descriptor */
3373
- systemPath?: string;
3374
- /** Display metadata for the owning OM System */
3375
- system?: ResourceSystemSummary;
3376
- /** Governance lifecycle status from the OM Resource descriptor */
3377
- governanceStatus?: ResourceGovernanceStatus;
3378
- /** Whether this resource is archived and should be excluded from registration and deployment */
3379
- archived?: boolean;
3380
- }
3381
- /** Webhook provider identifiers */
3382
- type WebhookProviderType = 'cal-com' | 'stripe' | 'signature-api' | 'instantly' | 'apify' | 'test';
3383
- /** Webhook trigger configuration */
3384
- interface WebhookTriggerConfig {
3385
- /** Provider identifier */
3386
- provider: WebhookProviderType;
3387
- /** Event type for documentation (not used for matching - workflow handles routing) */
3388
- event?: string;
3389
- /** Optional filtering (e.g., specific form ID for Fillout) */
3390
- filter?: Record<string, string>;
3391
- /** References credential in credentials table for per-org webhook secrets */
3392
- credentialName?: string;
3393
- }
3394
- /** Schedule trigger configuration */
3395
- interface ScheduleTriggerConfig {
3396
- /** Cron expression (e.g., '0 6 * * *') */
3397
- cron: string;
3398
- /** Optional timezone (default: UTC) */
3399
- timezone?: string;
3400
- }
3401
- /** Event trigger configuration */
3402
- interface EventTriggerConfig {
3403
- /** Internal event type */
3404
- eventType: string;
3405
- /** Event source */
3406
- source?: string;
3407
- }
3408
- /** Union of all trigger configs */
3409
- type TriggerConfig = WebhookTriggerConfig | ScheduleTriggerConfig | EventTriggerConfig;
3410
- /**
3411
- * Trigger metadata - entry points that initiate resource execution
3412
- *
3413
- * Triggers represent how executions start: webhooks from external services,
3414
- * scheduled cron jobs, platform events, or manual user actions.
3415
- *
3416
- * BREAKING CHANGES (2025-11-30):
3417
- * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
3418
- * - Field renames: `id` -> `resourceId` (inherited), `type` -> `triggerType`
3419
- * - Relationship rename: `invokes` -> `triggers` (unified vocabulary)
3420
- * - New required fields: `version` (inherited), `type: 'trigger'` (inherited)
3421
- * - triggers object now includes `externalResources` option
3422
- *
3423
- * @example
3424
- * // TriggerDefinition - metadata only
3425
- * {
3426
- * resourceId: 'trigger-new-order',
3427
- * type: 'trigger',
3428
- * triggerType: 'webhook',
3429
- * name: 'New Order',
3430
- * description: 'Webhook from Shopify on new orders',
3431
- * version: '1.0.0',
3432
- * status: 'prod',
3433
- * webhookPath: '/webhooks/shopify/orders'
3434
- * }
3435
- *
3436
- * // Relationships declared in ResourceRelationships (not on TriggerDefinition):
3437
- * // relationships: {
3438
- * // 'trigger-new-order': { triggers: { workflows: ['order-fulfillment-workflow'] } }
3439
- * // }
3440
- */
3441
- interface TriggerDefinition extends ResourceDefinition {
3442
- /** Resource type discriminator (narrowed from base union) */
3443
- type: 'trigger';
3444
- /** Trigger mechanism type (renamed from 'type' to avoid collision with base type discriminator) */
3445
- triggerType: 'webhook' | 'schedule' | 'manual' | 'event';
3446
- /** Type-specific configuration */
3447
- config?: TriggerConfig;
3448
- /** For webhook triggers: path like '/webhooks/shopify/orders' */
3449
- webhookPath?: string;
3450
- /** For schedule triggers: cron expression like '0 6 * * *' */
3451
- schedule?: string;
3452
- /** For event triggers: event type like 'low-stock-alert' */
3453
- eventType?: string;
3454
- }
3455
- /**
3456
- * Integration metadata - external service connections
3457
- *
3458
- * References credentials table for actual connection. No connection status
3459
- * stored here (queried at runtime from credentials table).
3460
- *
3461
- * BREAKING CHANGES (2025-11-30):
3462
- * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
3463
- * - Field renames: `id` -> `resourceId` (inherited)
3464
- * - New required field: `status` (inherited) - organizations must add status to all integrations
3465
- * - New required field: `version` (inherited) - organizations must add version to all integrations
3466
- * - New required field: `type: 'integration'` (inherited) - resource type discriminator
3467
- *
3468
- * @example
3469
- * {
3470
- * resourceId: 'integration-shopify-prod',
3471
- * type: 'integration',
3472
- * provider: 'shopify',
3473
- * credentialName: 'shopify-prod',
3474
- * name: 'Shopify Production',
3475
- * description: 'E-commerce platform',
3476
- * version: '1.0.0',
3477
- * status: 'prod'
3478
- * }
3479
- */
3480
- interface IntegrationDefinition extends ResourceDefinition {
3481
- /** Resource type discriminator (narrowed from base union) */
3482
- type: 'integration';
3483
- /** OM descriptor that owns canonical identity and governance metadata. */
3484
- resource?: Extract<ResourceEntry, {
3485
- kind: 'integration';
3486
- }>;
3487
- /** Integration provider type */
3488
- provider: IntegrationType;
3489
- /** References credentials table (e.g., 'shopify-prod', 'zendesk-api') */
3490
- credentialName: string;
3491
- }
3492
- /**
3493
- * Explicit resource relationship declaration
3494
- *
3495
- * Single-direction only - Command View derives reverse relationships.
3496
- * Agents/workflows declare what they trigger and use.
3497
- *
3498
- * @example
3499
- * {
3500
- * triggers: { workflows: ['order-fulfillment-workflow'] },
3501
- * uses: { integrations: ['integration-shopify-prod', 'integration-postgres'] }
3502
- * }
3503
- */
3504
- interface RelationshipDeclaration {
3505
- /** Resources this resource triggers */
3506
- triggers?: {
3507
- /** Agent resourceIds this resource triggers */
3508
- agents?: string[];
3509
- /** Workflow resourceIds this resource triggers */
3510
- workflows?: string[];
3511
- };
3512
- /** Integrations this resource uses */
3513
- uses?: {
3514
- /** Integration IDs this resource uses */
3515
- integrations?: string[];
3516
- };
3517
- }
3518
- /**
3519
- * Resource relationships map
3520
- * Maps resourceId to its relationship declarations
3521
- *
3522
- * @example
3523
- * {
3524
- * 'order-processor-agent': {
3525
- * triggers: { workflows: ['order-fulfillment-workflow'] },
3526
- * uses: { integrations: ['integration-shopify-prod'] }
3527
- * }
3528
- * }
3529
- */
3530
- type ResourceRelationships = Record<string, RelationshipDeclaration>;
3531
- /**
3532
- * External platform type
3533
- * Supported third-party automation platforms
3534
- */
3535
- type ExternalPlatform = 'n8n' | 'make' | 'zapier' | 'other';
3536
- /**
3537
- * External automation resource metadata
3538
- *
3539
- * Represents workflows/automations running on third-party platforms
3540
- * (n8n, Make, Zapier, etc.) for visualization in Command View.
3541
- *
3542
- * NOTE: This is metadata ONLY for visualization. No execution logic,
3543
- * no API integration with external platforms, no status syncing.
3544
- *
3545
- * BREAKING CHANGES (2025-11-30):
3546
- * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
3547
- * - Field renames: `id` -> `resourceId` (inherited)
3548
- * - New required field: `version` (inherited) - organizations must add version to all external resources
3549
- * - New required field: `type: 'external'` (inherited) - resource type discriminator
3550
- * - REMOVED FIELD: `triggeredBy` - per relationship-consolidation design, all relationships are forward-only declarations
3551
- *
3552
- * @example
3553
- * {
3554
- * resourceId: 'external-n8n-order-sync',
3555
- * type: 'external',
3556
- * version: '1.0.0',
3557
- * platform: 'n8n',
3558
- * name: 'Shopify Order Sync',
3559
- * description: 'Legacy n8n workflow for syncing Shopify orders',
3560
- * status: 'prod',
3561
- * platformUrl: 'https://n8n.client.com/workflow/123',
3562
- * triggers: { workflows: ['order-fulfillment-workflow'] },
3563
- * uses: { integrations: ['integration-shopify-prod'] }
3564
- * }
3565
- */
3566
- interface ExternalResourceDefinition extends ResourceDefinition {
3567
- /** Resource type discriminator (narrowed from base union) */
3568
- type: 'external';
3569
- /** Platform type */
3570
- platform: ExternalPlatform;
3571
- /** Link to external platform (e.g., n8n workflow editor URL) */
3572
- platformUrl?: string;
3573
- /** Platform's internal ID/reference */
3574
- externalId?: string;
3575
- /** What this external resource triggers (external -> internal) */
3576
- triggers?: {
3577
- /** Elevasis workflow resourceIds this external automation triggers */
3578
- workflows?: string[];
3579
- /** Elevasis agent resourceIds this external automation triggers */
3580
- agents?: string[];
3581
- };
3582
- /** Integrations this external resource uses (shared credentials) */
3583
- uses?: {
3584
- /** Integration IDs this external automation uses */
3585
- integrations?: string[];
3586
- };
3587
- }
3588
- /**
3589
- * Human Checkpoint definition - human decision points in automation
3590
- *
3591
- * Represents where human judgment is deployed in the automation landscape.
3592
- * Tasks with matching command_queue_group are routed to this checkpoint.
3593
- *
3594
- * BREAKING CHANGES (2025-11-30):
3595
- * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
3596
- * - Field renames: `id` -> `resourceId` (inherited)
3597
- * - description is now REQUIRED (was optional) - organizations must add description to all human checkpoints
3598
- * - New required field: `version` (inherited) - organizations must add version to all human checkpoints
3599
- * - New required field: `type: 'human'` (inherited) - resource type discriminator
3600
- *
3601
- * @example
3602
- * {
3603
- * resourceId: 'sales-approval',
3604
- * type: 'human',
3605
- * name: 'Sales Approval Queue',
3606
- * description: 'High-value order approvals for sales team',
3607
- * version: '1.0.0',
3608
- * status: 'prod',
3609
- * requestedBy: { agents: ['order-processor-agent'] },
3610
- * routesTo: { agents: ['order-fulfillment-agent'] }
3611
- * }
3612
- */
3613
- interface HumanCheckpointDefinition extends ResourceDefinition {
3614
- /** Resource type discriminator (narrowed from base union) */
3615
- type: 'human';
3616
- /** Resources that create tasks for this checkpoint */
3617
- requestedBy?: {
3618
- /** Agent resourceIds that request approval here */
3619
- agents?: string[];
3620
- /** Workflow resourceIds that request approval here */
3621
- workflows?: string[];
3622
- };
3623
- /** Resources that receive approved decisions */
3624
- routesTo?: {
3625
- /** Agent resourceIds that handle approved tasks */
3626
- agents?: string[];
3627
- /** Workflow resourceIds that handle approved tasks */
3628
- workflows?: string[];
3629
- };
3630
- }
3631
-
3632
- declare const ResourceCategorySchema: z.ZodEnum<{
3633
- diagnostic: "diagnostic";
3634
- production: "production";
3635
- internal: "internal";
3636
- testing: "testing";
3637
- }>;
3638
- type ResourceCategory = z.infer<typeof ResourceCategorySchema>;
3639
- type ResourceLink = Link;
3640
-
3641
- /**
3642
- * ResourceRegistry - Resource discovery and lookup
3643
- * Handles resource definitions from OrganizationRegistry
3644
- *
3645
- * Features:
3646
- * - Resource discovery by organization
3647
- * - Startup validation (duplicate IDs, model configs, relationships, interface-schema alignment)
3648
- * - Pre-serialization cache for instant API responses
3649
- * - Command View data generation
3650
- */
3651
-
3652
- /**
3653
- * Organization-specific resource collection
3654
- *
3655
- * Complete manifest of all automation resources for an organization.
3656
- * Used by ResourceRegistry for discovery and Command View for visualization.
3657
- */
3658
- interface DeploymentSpec {
3659
- /** Deployment version (semver) */
3660
- version: string;
3661
- /** Optional full Organization Model snapshot used for OM-code validation and deployment persistence */
3662
- organizationModel?: OrganizationModel;
3663
- /** Workflow definitions */
3664
- workflows?: WorkflowDefinition[];
3665
- /** Agent definitions */
3666
- agents?: AgentDefinition[];
3667
- /** Trigger definitions - entry points that initiate executions */
3668
- triggers?: TriggerDefinition[];
3669
- /** Integration definitions - external service connections */
3670
- integrations?: IntegrationDefinition[];
3671
- /** Explicit relationship declarations between resources */
3672
- relationships?: ResourceRelationships;
3673
- /** External automation resources (n8n, Make, Zapier, etc.) */
3674
- externalResources?: ExternalResourceDefinition[];
3675
- /** Human checkpoint definitions - human decision points in automation */
3676
- humanCheckpoints?: HumanCheckpointDefinition[];
3677
- }
3678
-
3679
40
  interface KnowledgeNodeInput {
3680
41
  id: string;
3681
42
  kind: string;
@@ -3709,38 +70,5 @@ interface ResolvedKnowledgeLayout {
3709
70
  }
3710
71
  declare function runKnowledgeCodegen(layout: ResolvedKnowledgeLayout): Promise<void>;
3711
72
 
3712
- type ResourceOntologyBindingResolver = (resourceId: string) => OrganizationModelResourceOntologyBinding | undefined;
3713
- type WorkflowResourceDescriptorResolver = (resourceId: string) => OrganizationModelWorkflowResourceEntry;
3714
- type AgentResourceDescriptorResolver = (resourceId: string) => OrganizationModelAgentResourceEntry;
3715
- type IntegrationResourceDescriptorResolver = (resourceId: string) => OrganizationModelIntegrationResourceEntry;
3716
- interface ProjectDeploymentSpecOptions {
3717
- version: string;
3718
- organizationModel: OrganizationModel;
3719
- workflows: WorkflowDefinition[];
3720
- integrations?: IntegrationDefinition[];
3721
- agents?: DeploymentSpec['agents'];
3722
- triggers?: DeploymentSpec['triggers'];
3723
- externalResources?: DeploymentSpec['externalResources'];
3724
- humanCheckpoints?: DeploymentSpec['humanCheckpoints'];
3725
- getWorkflowResourceDescriptor: WorkflowResourceDescriptorResolver;
3726
- getAgentResourceDescriptor?: AgentResourceDescriptorResolver;
3727
- getIntegrationResourceDescriptor: IntegrationResourceDescriptorResolver;
3728
- getResourceOntologyBinding?: ResourceOntologyBindingResolver;
3729
- }
3730
- declare function toSdkResourceDescriptor<TResource extends {
3731
- id: string;
3732
- systemPath: string;
3733
- }>(resource: TResource, getResourceOntologyBinding?: ResourceOntologyBindingResolver): TResource & Partial<OrganizationModelResourceOntologyBinding> & {
3734
- systemId: string;
3735
- };
3736
- declare function withPlatformResourceDescriptor(workflow: WorkflowDefinition, getWorkflowResourceDescriptor: WorkflowResourceDescriptorResolver, getResourceOntologyBinding?: ResourceOntologyBindingResolver): WorkflowDefinition;
3737
- declare function withPlatformResourceDescriptors(workflows: WorkflowDefinition[], getWorkflowResourceDescriptor: WorkflowResourceDescriptorResolver, getResourceOntologyBinding?: ResourceOntologyBindingResolver): WorkflowDefinition[];
3738
- declare function withPlatformAgentResourceDescriptor(agent: AgentDefinition, getAgentResourceDescriptor: AgentResourceDescriptorResolver, getResourceOntologyBinding?: ResourceOntologyBindingResolver): AgentDefinition;
3739
- declare function withPlatformAgentResourceDescriptors(agents: AgentDefinition[], getAgentResourceDescriptor: AgentResourceDescriptorResolver, getResourceOntologyBinding?: ResourceOntologyBindingResolver): AgentDefinition[];
3740
- declare function withPlatformIntegrationResourceDescriptor(integration: IntegrationDefinition, getIntegrationResourceDescriptor: IntegrationResourceDescriptorResolver, getResourceOntologyBinding?: ResourceOntologyBindingResolver): IntegrationDefinition;
3741
- declare function withPlatformIntegrationResourceDescriptors(integrations: IntegrationDefinition[], getIntegrationResourceDescriptor: IntegrationResourceDescriptorResolver, getResourceOntologyBinding?: ResourceOntologyBindingResolver): IntegrationDefinition[];
3742
- declare function projectTopologyRelationships(model: Pick<OrganizationModel, 'resources' | 'topology'>): ResourceRelationships;
3743
- declare function projectDeploymentSpec(options: ProjectDeploymentSpecOptions): DeploymentSpec;
3744
-
3745
- export { generateKnowledgeBodies, generateKnowledgeNodes, generateKnowledgeNodesTs, projectDeploymentSpec, projectTopologyRelationships, readKnowledgeNodeMdx, runKnowledgeCodegen, toSdkResourceDescriptor, withPlatformAgentResourceDescriptor, withPlatformAgentResourceDescriptors, withPlatformIntegrationResourceDescriptor, withPlatformIntegrationResourceDescriptors, withPlatformResourceDescriptor, withPlatformResourceDescriptors };
3746
- export type { AgentResourceDescriptorResolver, CodegenResult, DeploymentSpec, GenerateKnowledgeNodesOptions, GenerateKnowledgeNodesResult, IntegrationDefinition, IntegrationResourceDescriptorResolver, KnowledgeCodegenNode, KnowledgeKind, KnowledgeNodeInput, KnowledgeSearchEntry, ProjectDeploymentSpecOptions, ResolvedKnowledgeLayout, ResourceOntologyBindingResolver, ResourceRelationships, WorkflowDefinition, WorkflowResourceDescriptorResolver };
73
+ export { generateKnowledgeBodies, generateKnowledgeNodes, generateKnowledgeNodesTs, readKnowledgeNodeMdx, runKnowledgeCodegen };
74
+ export type { CodegenResult, GenerateKnowledgeNodesOptions, GenerateKnowledgeNodesResult, KnowledgeCodegenNode, KnowledgeKind, KnowledgeNodeInput, KnowledgeSearchEntry, ResolvedKnowledgeLayout };