@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.
- package/dist/index.d.ts +1662 -23
- package/dist/index.js +171 -24
- package/dist/knowledge/index.d.ts +1340 -0
- package/dist/knowledge/index.js +138 -0
- package/dist/organization-model/index.d.ts +1662 -23
- package/dist/organization-model/index.js +171 -24
- package/dist/test-utils/index.d.ts +711 -10
- package/dist/test-utils/index.js +159 -16
- package/package.json +7 -3
- package/src/__tests__/publish.test.ts +14 -13
- package/src/__tests__/template-core-compatibility.test.ts +4 -4
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +1265 -1154
- package/src/auth/multi-tenancy/index.ts +3 -0
- package/src/auth/multi-tenancy/theme-presets.ts +45 -0
- package/src/auth/multi-tenancy/types.ts +57 -83
- package/src/auth/multi-tenancy/users/api-schemas.ts +165 -194
- package/src/business/acquisition/activity-events.ts +1 -1
- package/src/business/acquisition/api-schemas.ts +1196 -1177
- package/src/business/acquisition/crm-state-actions.test.ts +139 -139
- package/src/business/acquisition/types.ts +381 -390
- package/src/business/crm/api-schemas.ts +40 -0
- package/src/business/crm/index.ts +1 -0
- package/src/business/deals/api-schemas.ts +79 -0
- package/src/business/deals/index.ts +1 -0
- package/src/business/projects/types.ts +124 -88
- package/src/execution/core/runner-types.ts +61 -80
- package/src/execution/engine/tools/integration/server/adapters/gmail/gmail-tools.ts +105 -104
- package/src/execution/engine/tools/integration/server/adapters/instantly/instantly-tools.ts +1474 -1473
- package/src/execution/engine/tools/integration/server/adapters/millionverifier/millionverifier-tools.ts +103 -102
- package/src/execution/engine/tools/integration/server/adapters/signature-api/signature-api-tools.ts +182 -179
- package/src/execution/engine/tools/integration/server/adapters/stripe/stripe-tools.ts +310 -309
- package/src/execution/engine/tools/integration/tool.ts +255 -253
- package/src/execution/engine/tools/lead-service-types.ts +895 -894
- package/src/execution/engine/tools/messages.ts +43 -0
- package/src/execution/engine/tools/platform/acquisition/types.ts +2 -1
- package/src/execution/engine/tools/platform/email/types.ts +97 -96
- package/src/execution/engine/tools/types.ts +234 -233
- package/src/execution/engine/workflow/types.ts +195 -193
- package/src/execution/external/api-schemas.ts +40 -0
- package/src/execution/external/index.ts +1 -0
- package/src/knowledge/README.md +32 -0
- package/src/knowledge/__tests__/queries.test.ts +504 -0
- package/src/knowledge/format.ts +99 -0
- package/src/knowledge/index.ts +5 -0
- package/src/knowledge/published.ts +5 -0
- package/src/knowledge/queries.ts +256 -0
- package/src/organization-model/__tests__/defaults.test.ts +172 -172
- package/src/organization-model/__tests__/foundation.test.ts +7 -7
- package/src/organization-model/__tests__/icons.test.ts +27 -0
- package/src/organization-model/__tests__/knowledge.test.ts +214 -0
- package/src/organization-model/contracts.ts +17 -15
- package/src/organization-model/defaults.ts +74 -19
- package/src/organization-model/domains/knowledge.ts +53 -0
- package/src/organization-model/domains/navigation.ts +416 -399
- package/src/organization-model/domains/shared.ts +6 -5
- package/src/organization-model/foundation.ts +10 -6
- package/src/organization-model/graph/build.ts +209 -182
- package/src/organization-model/graph/schema.ts +37 -34
- package/src/organization-model/graph/types.ts +47 -31
- package/src/organization-model/icons.ts +81 -0
- package/src/organization-model/index.ts +8 -3
- package/src/organization-model/organization-model.mdx +1 -1
- package/src/organization-model/published.ts +103 -86
- package/src/organization-model/schema.ts +90 -85
- package/src/organization-model/types.ts +40 -33
- package/src/platform/index.ts +23 -27
- package/src/platform/registry/index.ts +0 -4
- package/src/platform/registry/resource-registry.ts +0 -77
- package/src/platform/registry/serialized-types.ts +148 -219
- package/src/platform/registry/stats-types.ts +60 -60
- package/src/reference/_generated/contracts.md +1265 -1154
- 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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* - `
|
|
171
|
-
* - `
|
|
172
|
-
* - `
|
|
173
|
-
* - `
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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`).
|