@elevasis/core 0.15.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/index.d.ts +1662 -23
  2. package/dist/index.js +171 -24
  3. package/dist/knowledge/index.d.ts +1340 -0
  4. package/dist/knowledge/index.js +138 -0
  5. package/dist/organization-model/index.d.ts +1662 -23
  6. package/dist/organization-model/index.js +171 -24
  7. package/dist/test-utils/index.d.ts +711 -10
  8. package/dist/test-utils/index.js +159 -16
  9. package/package.json +7 -3
  10. package/src/__tests__/publish.test.ts +14 -13
  11. package/src/__tests__/template-core-compatibility.test.ts +4 -4
  12. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +1265 -1154
  13. package/src/auth/multi-tenancy/index.ts +3 -0
  14. package/src/auth/multi-tenancy/theme-presets.ts +45 -0
  15. package/src/auth/multi-tenancy/types.ts +57 -83
  16. package/src/auth/multi-tenancy/users/api-schemas.ts +165 -194
  17. package/src/business/acquisition/activity-events.ts +1 -1
  18. package/src/business/acquisition/api-schemas.ts +1196 -1177
  19. package/src/business/acquisition/crm-state-actions.test.ts +139 -139
  20. package/src/business/acquisition/types.ts +381 -390
  21. package/src/business/crm/api-schemas.ts +40 -0
  22. package/src/business/crm/index.ts +1 -0
  23. package/src/business/deals/api-schemas.ts +79 -0
  24. package/src/business/deals/index.ts +1 -0
  25. package/src/business/projects/types.ts +124 -88
  26. package/src/execution/core/runner-types.ts +61 -80
  27. package/src/execution/engine/tools/integration/server/adapters/gmail/gmail-tools.ts +105 -104
  28. package/src/execution/engine/tools/integration/server/adapters/instantly/instantly-tools.ts +1474 -1473
  29. package/src/execution/engine/tools/integration/server/adapters/millionverifier/millionverifier-tools.ts +103 -102
  30. package/src/execution/engine/tools/integration/server/adapters/signature-api/signature-api-tools.ts +182 -179
  31. package/src/execution/engine/tools/integration/server/adapters/stripe/stripe-tools.ts +310 -309
  32. package/src/execution/engine/tools/integration/tool.ts +255 -253
  33. package/src/execution/engine/tools/lead-service-types.ts +895 -894
  34. package/src/execution/engine/tools/messages.ts +43 -0
  35. package/src/execution/engine/tools/platform/acquisition/types.ts +2 -1
  36. package/src/execution/engine/tools/platform/email/types.ts +97 -96
  37. package/src/execution/engine/tools/types.ts +234 -233
  38. package/src/execution/engine/workflow/types.ts +195 -193
  39. package/src/execution/external/api-schemas.ts +40 -0
  40. package/src/execution/external/index.ts +1 -0
  41. package/src/knowledge/README.md +32 -0
  42. package/src/knowledge/__tests__/queries.test.ts +504 -0
  43. package/src/knowledge/format.ts +99 -0
  44. package/src/knowledge/index.ts +5 -0
  45. package/src/knowledge/published.ts +5 -0
  46. package/src/knowledge/queries.ts +256 -0
  47. package/src/organization-model/__tests__/defaults.test.ts +172 -172
  48. package/src/organization-model/__tests__/foundation.test.ts +7 -7
  49. package/src/organization-model/__tests__/icons.test.ts +27 -0
  50. package/src/organization-model/__tests__/knowledge.test.ts +214 -0
  51. package/src/organization-model/contracts.ts +17 -15
  52. package/src/organization-model/defaults.ts +74 -19
  53. package/src/organization-model/domains/knowledge.ts +53 -0
  54. package/src/organization-model/domains/navigation.ts +416 -399
  55. package/src/organization-model/domains/shared.ts +6 -5
  56. package/src/organization-model/foundation.ts +10 -6
  57. package/src/organization-model/graph/build.ts +209 -182
  58. package/src/organization-model/graph/schema.ts +37 -34
  59. package/src/organization-model/graph/types.ts +47 -31
  60. package/src/organization-model/icons.ts +81 -0
  61. package/src/organization-model/index.ts +8 -3
  62. package/src/organization-model/organization-model.mdx +1 -1
  63. package/src/organization-model/published.ts +103 -86
  64. package/src/organization-model/schema.ts +90 -85
  65. package/src/organization-model/types.ts +40 -33
  66. package/src/platform/index.ts +23 -27
  67. package/src/platform/registry/index.ts +0 -4
  68. package/src/platform/registry/resource-registry.ts +0 -77
  69. package/src/platform/registry/serialized-types.ts +148 -219
  70. package/src/platform/registry/stats-types.ts +60 -60
  71. package/src/reference/_generated/contracts.md +1265 -1154
  72. package/src/platform/registry/__tests__/resource-registry.list-executable.test.ts +0 -393
@@ -1,193 +1,195 @@
1
- // Import z for schema types
2
- import type { z } from 'zod'
3
-
4
- /**
5
- * Workflow-specific type definitions
6
- */
7
-
8
- import type { ExecutionContext } from '../base/types'
9
- import type { ResourceDefinition } from '../../../platform/registry/types'
10
- import type { ResourceMetricsConfig } from '../../../operations/observability/types'
11
- import type { ExecutionInterface } from '../interface/types'
12
-
13
- // Workflow configuration
14
- export interface WorkflowConfig extends ResourceDefinition {
15
- type: 'workflow'
16
- }
17
-
18
- // Workflow step definition
19
- export interface WorkflowStepDefinition {
20
- id: string
21
- name: string
22
- description: string
23
- }
24
-
25
- // Step handler function type
26
- export type StepHandler = (input: unknown, context: ExecutionContext) => Promise<unknown>
27
-
28
- // Step type for flow control
29
- export const StepType = {
30
- LINEAR: 'linear',
31
- CONDITIONAL: 'conditional'
32
- } as const
33
- export type StepType = (typeof StepType)[keyof typeof StepType]
34
-
35
- // Next step configuration types
36
- export interface LinearNext {
37
- type: 'linear'
38
- target: string
39
- }
40
-
41
- export interface ConditionalNext {
42
- type: 'conditional'
43
- routes: Array<{
44
- condition: (data: unknown) => boolean
45
- target: string
46
- }>
47
- default: string // Required to avoid ambiguity
48
- }
49
-
50
- export type NextConfig =
51
- | LinearNext // Go to specific step
52
- | ConditionalNext // Conditional routing
53
- | null // Explicitly end workflow
54
-
55
- // Workflow step with graph-based flow
56
- export interface WorkflowStep extends WorkflowStepDefinition {
57
- handler: StepHandler
58
-
59
- // I/O validation (BOTH REQUIRED for complete type safety)
60
- inputSchema: z.ZodSchema // Validates input from previous step or workflow
61
- outputSchema: z.ZodSchema // Validates output before next step
62
-
63
- next: NextConfig // Required - explicit flow decision for every step
64
- }
65
-
66
- // Workflow definition - pure configuration without instance state
67
- // Used by registry to define workflows that can be instantiated
68
- export interface WorkflowDefinition {
69
- config: WorkflowConfig
70
- contract: import('../base/types').Contract
71
- steps: Record<string, WorkflowStep>
72
- entryPoint: string
73
-
74
- /**
75
- * Metrics configuration for ROI calculations
76
- * Optional: Only needed if tracking automation savings
77
- */
78
- metricsConfig?: ResourceMetricsConfig
79
-
80
- /**
81
- * Execution interface configuration (optional)
82
- * If provided, workflow appears in Execution Runner UI
83
- */
84
- interface?: ExecutionInterface
85
-
86
- /**
87
- * Lead-gen processing stage this workflow implements (optional).
88
- * Must match a key in the platform lead-gen stage catalog.
89
- * Used by org-os graph derivation to surface workflow→stage edges and
90
- * by pipeline_config validation to confirm each catalog stage has an
91
- * implementing workflow before a list is activated.
92
- *
93
- * Example: stageImplemented: 'verified' on the email-verification workflow.
94
- */
95
- stageImplemented?: string
96
- }
97
-
98
- /**
99
- * Workflow timeline and observability types
100
- * Used for UI timeline visualization and backend processing
101
- */
102
-
103
- import type { WorkflowLogMessage } from './logging'
104
-
105
- /**
106
- * Workflow step state
107
- * Aggregates step context events with timing and logs
108
- */
109
- export interface StepState {
110
- stepId: string
111
- stepName: string
112
- status: 'pending' | 'running' | 'completed' | 'failed'
113
-
114
- // Timeline visualization timing
115
- startTime?: number // From step-started context
116
- endTime?: number // From step-completed/failed context
117
- duration?: number // From step-completed/failed context
118
-
119
- // Step data
120
- input?: unknown
121
- output?: unknown
122
- error?: unknown
123
- logs: WorkflowLogMessage[]
124
- }
125
-
126
- /**
127
- * Complete workflow execution data for node visualization
128
- * Parsed from execution logs
129
- */
130
- export interface WorkflowNodeVisualizerData {
131
- steps: StepState[]
132
- totalDuration: number
133
- isRunning: boolean
134
- }
135
-
136
- /**
137
- * Step data extracted from execution logs
138
- * Used to provide detailed step information in unified graph nodes
139
- */
140
- export interface StepExecutionData {
141
- /** Final execution status for this step */
142
- status: 'pending' | 'running' | 'completed' | 'failed'
143
-
144
- /** Step execution duration in milliseconds */
145
- duration?: number
146
-
147
- /** Step input data */
148
- input?: unknown
149
-
150
- /** Step output data */
151
- output?: unknown
152
-
153
- /** Error data if step failed */
154
- error?: unknown
155
-
156
- /** Log messages from this step (reserved for future use) */
157
- logs?: unknown[]
158
- }
159
-
160
- /**
161
- * Execution path tracking state
162
- *
163
- * Tracks which steps have been executed and which edges were taken during workflow
164
- * execution. This state is built from SSE execution log events and used to compute
165
- * the visual dimming/highlighting of nodes and edges.
166
- *
167
- * Algorithm:
168
- * - `executedSteps` provides O(1) lookup for "has this step been reached?"
169
- * - `executedStepsOrdered` preserves execution order for edge inference
170
- * - `takenEdges` comes from `conditional-route` SSE events + linear step inference
171
- * - `currentStepId` tracks the actively running step for animation
172
- * - `stepStatusMap` provides final status for each executed step
173
- * - `stepDataMap` provides detailed execution data (duration, input, output, error)
174
- */
175
- export interface ExecutionPathState {
176
- /** Set of step IDs that have been executed (O(1) lookup) */
177
- executedSteps: Set<string>
178
-
179
- /** Step IDs in execution order (for inferring linear edges) */
180
- executedStepsOrdered: string[]
181
-
182
- /** Set of edge IDs that were traversed (format: "edge-{source}-{target}") */
183
- takenEdges: Set<string>
184
-
185
- /** Currently running step ID (undefined if no step is running) */
186
- currentStepId?: string
187
-
188
- /** Map of step IDs to their final execution status */
189
- stepStatusMap?: Map<string, 'pending' | 'running' | 'completed' | 'failed'>
190
-
191
- /** Map of step IDs to their execution data (duration, input, output, error) */
192
- stepDataMap?: Map<string, StepExecutionData>
193
- }
1
+ // Import z for schema types
2
+ import type { z } from 'zod'
3
+
4
+ /**
5
+ * Workflow-specific type definitions
6
+ */
7
+
8
+ import type { ExecutionContext } from '../base/types'
9
+ import type { ResourceDefinition } from '../../../platform/registry/types'
10
+ import type { ResourceMetricsConfig } from '../../../operations/observability/types'
11
+ import type { ExecutionInterface } from '../interface/types'
12
+
13
+ // Workflow configuration
14
+ export interface WorkflowConfig extends ResourceDefinition {
15
+ type: 'workflow'
16
+ /** Lead-gen capability key for registry derivation (e.g. 'lead-gen.company.apollo-import') */
17
+ capabilityKey?: string
18
+ }
19
+
20
+ // Workflow step definition
21
+ export interface WorkflowStepDefinition {
22
+ id: string
23
+ name: string
24
+ description: string
25
+ }
26
+
27
+ // Step handler function type
28
+ export type StepHandler = (input: unknown, context: ExecutionContext) => Promise<unknown>
29
+
30
+ // Step type for flow control
31
+ export const StepType = {
32
+ LINEAR: 'linear',
33
+ CONDITIONAL: 'conditional'
34
+ } as const
35
+ export type StepType = (typeof StepType)[keyof typeof StepType]
36
+
37
+ // Next step configuration types
38
+ export interface LinearNext {
39
+ type: 'linear'
40
+ target: string
41
+ }
42
+
43
+ export interface ConditionalNext {
44
+ type: 'conditional'
45
+ routes: Array<{
46
+ condition: (data: unknown) => boolean
47
+ target: string
48
+ }>
49
+ default: string // Required to avoid ambiguity
50
+ }
51
+
52
+ export type NextConfig =
53
+ | LinearNext // Go to specific step
54
+ | ConditionalNext // Conditional routing
55
+ | null // Explicitly end workflow
56
+
57
+ // Workflow step with graph-based flow
58
+ export interface WorkflowStep extends WorkflowStepDefinition {
59
+ handler: StepHandler
60
+
61
+ // I/O validation (BOTH REQUIRED for complete type safety)
62
+ inputSchema: z.ZodSchema // Validates input from previous step or workflow
63
+ outputSchema: z.ZodSchema // Validates output before next step
64
+
65
+ next: NextConfig // Required - explicit flow decision for every step
66
+ }
67
+
68
+ // Workflow definition - pure configuration without instance state
69
+ // Used by registry to define workflows that can be instantiated
70
+ export interface WorkflowDefinition {
71
+ config: WorkflowConfig
72
+ contract: import('../base/types').Contract
73
+ steps: Record<string, WorkflowStep>
74
+ entryPoint: string
75
+
76
+ /**
77
+ * Metrics configuration for ROI calculations
78
+ * Optional: Only needed if tracking automation savings
79
+ */
80
+ metricsConfig?: ResourceMetricsConfig
81
+
82
+ /**
83
+ * Execution interface configuration (optional)
84
+ * If provided, workflow appears in Execution Runner UI
85
+ */
86
+ interface?: ExecutionInterface
87
+
88
+ /**
89
+ * Lead-gen processing stage this workflow implements (optional).
90
+ * Must match a key in the platform lead-gen stage catalog.
91
+ * Used by org-os graph derivation to surface workflow→stage edges and
92
+ * by pipeline_config validation to confirm each catalog stage has an
93
+ * implementing workflow before a list is activated.
94
+ *
95
+ * Example: stageImplemented: 'verified' on the email-verification workflow.
96
+ */
97
+ stageImplemented?: string
98
+ }
99
+
100
+ /**
101
+ * Workflow timeline and observability types
102
+ * Used for UI timeline visualization and backend processing
103
+ */
104
+
105
+ import type { WorkflowLogMessage } from './logging'
106
+
107
+ /**
108
+ * Workflow step state
109
+ * Aggregates step context events with timing and logs
110
+ */
111
+ export interface StepState {
112
+ stepId: string
113
+ stepName: string
114
+ status: 'pending' | 'running' | 'completed' | 'failed'
115
+
116
+ // Timeline visualization timing
117
+ startTime?: number // From step-started context
118
+ endTime?: number // From step-completed/failed context
119
+ duration?: number // From step-completed/failed context
120
+
121
+ // Step data
122
+ input?: unknown
123
+ output?: unknown
124
+ error?: unknown
125
+ logs: WorkflowLogMessage[]
126
+ }
127
+
128
+ /**
129
+ * Complete workflow execution data for node visualization
130
+ * Parsed from execution logs
131
+ */
132
+ export interface WorkflowNodeVisualizerData {
133
+ steps: StepState[]
134
+ totalDuration: number
135
+ isRunning: boolean
136
+ }
137
+
138
+ /**
139
+ * Step data extracted from execution logs
140
+ * Used to provide detailed step information in unified graph nodes
141
+ */
142
+ export interface StepExecutionData {
143
+ /** Final execution status for this step */
144
+ status: 'pending' | 'running' | 'completed' | 'failed'
145
+
146
+ /** Step execution duration in milliseconds */
147
+ duration?: number
148
+
149
+ /** Step input data */
150
+ input?: unknown
151
+
152
+ /** Step output data */
153
+ output?: unknown
154
+
155
+ /** Error data if step failed */
156
+ error?: unknown
157
+
158
+ /** Log messages from this step (reserved for future use) */
159
+ logs?: unknown[]
160
+ }
161
+
162
+ /**
163
+ * Execution path tracking state
164
+ *
165
+ * Tracks which steps have been executed and which edges were taken during workflow
166
+ * execution. This state is built from SSE execution log events and used to compute
167
+ * the visual dimming/highlighting of nodes and edges.
168
+ *
169
+ * Algorithm:
170
+ * - `executedSteps` provides O(1) lookup for "has this step been reached?"
171
+ * - `executedStepsOrdered` preserves execution order for edge inference
172
+ * - `takenEdges` comes from `conditional-route` SSE events + linear step inference
173
+ * - `currentStepId` tracks the actively running step for animation
174
+ * - `stepStatusMap` provides final status for each executed step
175
+ * - `stepDataMap` provides detailed execution data (duration, input, output, error)
176
+ */
177
+ export interface ExecutionPathState {
178
+ /** Set of step IDs that have been executed (O(1) lookup) */
179
+ executedSteps: Set<string>
180
+
181
+ /** Step IDs in execution order (for inferring linear edges) */
182
+ executedStepsOrdered: string[]
183
+
184
+ /** Set of edge IDs that were traversed (format: "edge-{source}-{target}") */
185
+ takenEdges: Set<string>
186
+
187
+ /** Currently running step ID (undefined if no step is running) */
188
+ currentStepId?: string
189
+
190
+ /** Map of step IDs to their final execution status */
191
+ stepStatusMap?: Map<string, 'pending' | 'running' | 'completed' | 'failed'>
192
+
193
+ /** Map of step IDs to their execution data (duration, input, output, error) */
194
+ stepDataMap?: Map<string, StepExecutionData>
195
+ }
@@ -0,0 +1,40 @@
1
+ import { z } from 'zod'
2
+
3
+ /**
4
+ * Generic API validation schemas for the external execution API surface.
5
+ *
6
+ * These schemas are ENVELOPE-ONLY -- they validate the transport layer
7
+ * shape (resourceId, input, querystring params). They do NOT validate
8
+ * per-workflow input shapes; that remains the responsibility of each
9
+ * workflow's own contract.inputSchema.
10
+ *
11
+ * Multi-Tenant Layering Rule: apps/api stays generic. No per-workflow
12
+ * shapes enter this file.
13
+ */
14
+
15
+ /**
16
+ * POST /execute-async - Request body envelope
17
+ *
18
+ * Validates that resourceId is present and non-empty.
19
+ * `input` is accepted as unknown (opaque JSONB) -- per-workflow validation
20
+ * is the workflow's own responsibility.
21
+ */
22
+ export const ExecuteAsyncEnvelopeSchema = z.object({
23
+ resourceId: z.string().min(1),
24
+ input: z.unknown().optional()
25
+ })
26
+
27
+ export type ExecuteAsyncEnvelope = z.infer<typeof ExecuteAsyncEnvelopeSchema>
28
+
29
+ /**
30
+ * GET /executions/:resourceId - Querystring parameters
31
+ *
32
+ * `limit`: max 100 rows per request to prevent excessive data transfer.
33
+ * `status`: optional filter by execution status string.
34
+ */
35
+ export const GetExecutionsQuerySchema = z.object({
36
+ limit: z.coerce.number().int().min(1).max(100).default(50),
37
+ status: z.string().optional()
38
+ })
39
+
40
+ export type GetExecutionsQuery = z.infer<typeof GetExecutionsQuerySchema>
@@ -0,0 +1 @@
1
+ export * from './api-schemas'
@@ -0,0 +1,32 @@
1
+ # @elevasis/core/knowledge
2
+
3
+ Pure query layer over the organization graph. Browser-safe (no Node APIs); shared by the SDK CLI, platform CLI, and the `@elevasis/ui/knowledge` browser.
4
+
5
+ ## Surface
6
+
7
+ | Export | Purpose |
8
+ | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
9
+ | `byFeature(graph, featureId, knowledgeNodes)` | Knowledge nodes that govern the given feature. |
10
+ | `byKind(graph, kind, knowledgeNodes)` | Filter knowledge nodes by `OrgKnowledgeKind`. |
11
+ | `byOwner(graph, ownerId, knowledgeNodes)` | Knowledge nodes whose `ownerIds` includes the given owner. |
12
+ | `governs(graph, nodeId)` | Outgoing `governs` targets (governed-feature ids) from a knowledge node. |
13
+ | `governedBy(graph, nodeId)` | Incoming `governs` sources (governing knowledge-node ids) into a feature. |
14
+ | `parsePath(pathString)` | Parse `/by-feature/$id`, `/by-kind/$kind`, `/by-owner/$id`, `/graph/$id/{governs,governed-by}`, or `/$id`. Throws on invalid input. |
15
+ | `formatText`, `formatJson`, `formatIdsOnly` | Output formatters used by the `knowledge:*` CLI subcommands. |
16
+
17
+ ## Path syntax
18
+
19
+ ```
20
+ /by-feature/<featureId>
21
+ /by-kind/<playbook|strategy|reference>
22
+ /by-owner/<ownerId>
23
+ /graph/<nodeId>/governs
24
+ /graph/<nodeId>/governed-by
25
+ /<nodeId>
26
+ ```
27
+
28
+ ## JSON envelope
29
+
30
+ `formatJson` returns `{ path, mount, args, results }` — the same wrapped envelope used by `pnpm exec elevasis knowledge:ls --json` and `pnpm exec elevasis-sdk knowledge:ls --json`.
31
+
32
+ `governs` and `governedBy` accept either bare or graph-namespaced ids (`knowledge.foo` or `knowledge:knowledge.foo`).