@elevasis/core 0.15.1 → 0.16.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/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 +305 -201
- 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/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
|
@@ -1,233 +1,234 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool definitions
|
|
3
|
-
*
|
|
4
|
-
* Tool interface used by agents and workflows.
|
|
5
|
-
* Provides a universal interface for AI systems to interact with tools.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { z } from 'zod'
|
|
9
|
-
import { ExecutionError } from '../base/errors'
|
|
10
|
-
import type { ExecutionContext } from '../base/types'
|
|
11
|
-
import type { IterationContext } from '../agent/core/types'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Options for tool execution
|
|
15
|
-
* Provides named parameters for better API clarity and extensibility
|
|
16
|
-
*/
|
|
17
|
-
export interface ToolExecutionOptions {
|
|
18
|
-
/** Tool input (validated against inputSchema before execution) */
|
|
19
|
-
input: unknown
|
|
20
|
-
|
|
21
|
-
/** Execution context with multi-tenant isolation and observability (optional for simple tools, required for platform/integration tools) */
|
|
22
|
-
executionContext?: ExecutionContext
|
|
23
|
-
|
|
24
|
-
/** Full iteration context for advanced tools (provides access to memoryManager, toolRegistry, logger, etc.) */
|
|
25
|
-
iterationContext?: IterationContext
|
|
26
|
-
|
|
27
|
-
/** Abort signal for timeout/cancellation -- forward to fetch() calls for clean cancellation */
|
|
28
|
-
signal?: AbortSignal
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Tool interface for AI systems
|
|
33
|
-
*
|
|
34
|
-
* Used by:
|
|
35
|
-
* - Agents: For agentic tool use (reasoning loop selects and executes tools)
|
|
36
|
-
* - Workflows: For workflow step tool invocation (future)
|
|
37
|
-
* - Platform tools: createApprovalTool(), createSchedulerTool()
|
|
38
|
-
* - Integration tools: External API calls (Gmail, Slack, etc.)
|
|
39
|
-
*/
|
|
40
|
-
export interface Tool {
|
|
41
|
-
// Required fields
|
|
42
|
-
name: string // Unique identifier (e.g., 'web_search', 'calculator')
|
|
43
|
-
description: string // What the tool does (used by LLM for selection)
|
|
44
|
-
|
|
45
|
-
// I/O validation (both required for complete type safety)
|
|
46
|
-
inputSchema: z.ZodSchema // Input validation schema
|
|
47
|
-
outputSchema: z.ZodSchema // Output validation schema
|
|
48
|
-
|
|
49
|
-
// Execution
|
|
50
|
-
execute: (options: ToolExecutionOptions) => Promise<unknown>
|
|
51
|
-
|
|
52
|
-
// Timeout (optional) -- per-tool override in ms, defaults to DEFAULT_TOOL_TIMEOUT (300_000 / 5min) in executor
|
|
53
|
-
timeout?: number
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Tool definition (for LLM communication)
|
|
58
|
-
* Universal format for tool specifications sent to LLMs
|
|
59
|
-
*/
|
|
60
|
-
export interface ToolDefinition {
|
|
61
|
-
name: string // Unique identifier
|
|
62
|
-
description: string // LLM-readable purpose
|
|
63
|
-
inputSchema: unknown // JSON Schema
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Tooling error types
|
|
68
|
-
* Used across platform tools and integration tools
|
|
69
|
-
*/
|
|
70
|
-
export type ToolingErrorType =
|
|
71
|
-
// Platform tool errors
|
|
72
|
-
| 'service_unavailable'
|
|
73
|
-
| 'permission_denied'
|
|
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
|
-
readonly
|
|
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
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Tool definitions
|
|
3
|
+
*
|
|
4
|
+
* Tool interface used by agents and workflows.
|
|
5
|
+
* Provides a universal interface for AI systems to interact with tools.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { z } from 'zod'
|
|
9
|
+
import { ExecutionError } from '../base/errors'
|
|
10
|
+
import type { ExecutionContext } from '../base/types'
|
|
11
|
+
import type { IterationContext } from '../agent/core/types'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Options for tool execution
|
|
15
|
+
* Provides named parameters for better API clarity and extensibility
|
|
16
|
+
*/
|
|
17
|
+
export interface ToolExecutionOptions {
|
|
18
|
+
/** Tool input (validated against inputSchema before execution) */
|
|
19
|
+
input: unknown
|
|
20
|
+
|
|
21
|
+
/** Execution context with multi-tenant isolation and observability (optional for simple tools, required for platform/integration tools) */
|
|
22
|
+
executionContext?: ExecutionContext
|
|
23
|
+
|
|
24
|
+
/** Full iteration context for advanced tools (provides access to memoryManager, toolRegistry, logger, etc.) */
|
|
25
|
+
iterationContext?: IterationContext
|
|
26
|
+
|
|
27
|
+
/** Abort signal for timeout/cancellation -- forward to fetch() calls for clean cancellation */
|
|
28
|
+
signal?: AbortSignal
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Tool interface for AI systems
|
|
33
|
+
*
|
|
34
|
+
* Used by:
|
|
35
|
+
* - Agents: For agentic tool use (reasoning loop selects and executes tools)
|
|
36
|
+
* - Workflows: For workflow step tool invocation (future)
|
|
37
|
+
* - Platform tools: createApprovalTool(), createSchedulerTool()
|
|
38
|
+
* - Integration tools: External API calls (Gmail, Slack, etc.)
|
|
39
|
+
*/
|
|
40
|
+
export interface Tool {
|
|
41
|
+
// Required fields
|
|
42
|
+
name: string // Unique identifier (e.g., 'web_search', 'calculator')
|
|
43
|
+
description: string // What the tool does (used by LLM for selection)
|
|
44
|
+
|
|
45
|
+
// I/O validation (both required for complete type safety)
|
|
46
|
+
inputSchema: z.ZodSchema // Input validation schema
|
|
47
|
+
outputSchema: z.ZodSchema // Output validation schema
|
|
48
|
+
|
|
49
|
+
// Execution
|
|
50
|
+
execute: (options: ToolExecutionOptions) => Promise<unknown>
|
|
51
|
+
|
|
52
|
+
// Timeout (optional) -- per-tool override in ms, defaults to DEFAULT_TOOL_TIMEOUT (300_000 / 5min) in executor
|
|
53
|
+
timeout?: number
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Tool definition (for LLM communication)
|
|
58
|
+
* Universal format for tool specifications sent to LLMs
|
|
59
|
+
*/
|
|
60
|
+
export interface ToolDefinition {
|
|
61
|
+
name: string // Unique identifier
|
|
62
|
+
description: string // LLM-readable purpose
|
|
63
|
+
inputSchema: unknown // JSON Schema
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Tooling error types
|
|
68
|
+
* Used across platform tools and integration tools
|
|
69
|
+
*/
|
|
70
|
+
export type ToolingErrorType =
|
|
71
|
+
// Platform tool errors
|
|
72
|
+
| 'service_unavailable'
|
|
73
|
+
| 'permission_denied'
|
|
74
|
+
| 'platform_internal'
|
|
75
|
+
|
|
76
|
+
// Integration tool errors
|
|
77
|
+
| 'adapter_not_found'
|
|
78
|
+
| 'method_not_found'
|
|
79
|
+
| 'tool_not_found'
|
|
80
|
+
| 'credentials_missing'
|
|
81
|
+
| 'credentials_invalid'
|
|
82
|
+
| 'rate_limit_exceeded'
|
|
83
|
+
| 'server_unavailable'
|
|
84
|
+
| 'auth_error'
|
|
85
|
+
| 'api_error'
|
|
86
|
+
| 'validation_error'
|
|
87
|
+
| 'network_error'
|
|
88
|
+
| 'timeout_error'
|
|
89
|
+
| 'unknown_error'
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Tooling error class
|
|
93
|
+
* Provides structured error information for tool failures across all tool types
|
|
94
|
+
*
|
|
95
|
+
* Severity mapping:
|
|
96
|
+
* - critical: credentials_missing, credentials_invalid, permission_denied, auth_error,
|
|
97
|
+
* adapter_not_found, method_not_found, tool_not_found
|
|
98
|
+
* - info: validation_error
|
|
99
|
+
* - warning: All other types (retryable transient errors)
|
|
100
|
+
*
|
|
101
|
+
* Category: tool (tool execution errors)
|
|
102
|
+
*/
|
|
103
|
+
export class ToolingError extends ExecutionError {
|
|
104
|
+
readonly type = 'tooling_error' as const
|
|
105
|
+
readonly category = 'tool' as const
|
|
106
|
+
|
|
107
|
+
constructor(
|
|
108
|
+
public readonly errorType: ToolingErrorType,
|
|
109
|
+
message: string,
|
|
110
|
+
public readonly details?: unknown
|
|
111
|
+
) {
|
|
112
|
+
super(message, { type: errorType, details })
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Derive severity based on error type
|
|
117
|
+
*/
|
|
118
|
+
get severity(): 'critical' | 'warning' | 'info' {
|
|
119
|
+
// Critical: Authentication, authorization, and configuration errors
|
|
120
|
+
if (
|
|
121
|
+
[
|
|
122
|
+
'credentials_missing',
|
|
123
|
+
'credentials_invalid',
|
|
124
|
+
'permission_denied',
|
|
125
|
+
'auth_error',
|
|
126
|
+
'adapter_not_found',
|
|
127
|
+
'method_not_found',
|
|
128
|
+
'tool_not_found'
|
|
129
|
+
].includes(this.errorType)
|
|
130
|
+
) {
|
|
131
|
+
return 'critical'
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Info: Validation errors (user input errors)
|
|
135
|
+
if (this.errorType === 'validation_error') {
|
|
136
|
+
return 'info'
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Warning: Transient failures (retryable)
|
|
140
|
+
return 'warning'
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Check if error is retryable
|
|
145
|
+
*/
|
|
146
|
+
override isRetryable(): boolean {
|
|
147
|
+
return [
|
|
148
|
+
'service_unavailable',
|
|
149
|
+
'rate_limit_exceeded',
|
|
150
|
+
'api_error',
|
|
151
|
+
'network_error',
|
|
152
|
+
'timeout_error',
|
|
153
|
+
'server_unavailable'
|
|
154
|
+
].includes(this.errorType)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Convert to JSON for logging
|
|
159
|
+
*/
|
|
160
|
+
toJSON() {
|
|
161
|
+
return {
|
|
162
|
+
name: this.name,
|
|
163
|
+
type: this.errorType,
|
|
164
|
+
message: this.message,
|
|
165
|
+
severity: this.severity,
|
|
166
|
+
category: this.category,
|
|
167
|
+
details: this.details
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Factory functions for common error types
|
|
173
|
+
|
|
174
|
+
/** Platform tool errors */
|
|
175
|
+
export function serviceUnavailable(serviceName: string, details?: unknown): ToolingError {
|
|
176
|
+
return new ToolingError('service_unavailable', `${serviceName} is unavailable`, details)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function permissionDenied(operation: string): ToolingError {
|
|
180
|
+
return new ToolingError('permission_denied', `Permission denied: ${operation}`)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Integration tool errors */
|
|
184
|
+
export function adapterNotFound(adapterId: string): ToolingError {
|
|
185
|
+
return new ToolingError('adapter_not_found', `Integration adapter not found: ${adapterId}`)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function methodNotFound(methodName: string): ToolingError {
|
|
189
|
+
return new ToolingError('method_not_found', `Method not found: ${methodName}`)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function toolNotFound(toolName: string): ToolingError {
|
|
193
|
+
return new ToolingError('tool_not_found', `Tool not found: ${toolName}`)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function credentialsMissing(integrationName: string): ToolingError {
|
|
197
|
+
return new ToolingError('credentials_missing', `No credentials found for ${integrationName}`)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function credentialsInvalid(integrationName: string): ToolingError {
|
|
201
|
+
return new ToolingError('credentials_invalid', `Credentials expired or invalid for ${integrationName}`)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function rateLimitExceeded(service: string): ToolingError {
|
|
205
|
+
return new ToolingError('rate_limit_exceeded', `Rate limit exceeded for ${service}`)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function serverUnavailable(serverName: string): ToolingError {
|
|
209
|
+
return new ToolingError('server_unavailable', `${serverName} is unavailable`)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function authError(message: string): ToolingError {
|
|
213
|
+
return new ToolingError('auth_error', message)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function apiError(message: string, details?: unknown): ToolingError {
|
|
217
|
+
return new ToolingError('api_error', message, details)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function validationError(message: string): ToolingError {
|
|
221
|
+
return new ToolingError('validation_error', message)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export function networkError(message: string): ToolingError {
|
|
225
|
+
return new ToolingError('network_error', message)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export function timeoutError(operation: string): ToolingError {
|
|
229
|
+
return new ToolingError('timeout_error', `Operation timed out: ${operation}`)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function unknownError(message: string, details?: unknown): ToolingError {
|
|
233
|
+
return new ToolingError('unknown_error', message, details)
|
|
234
|
+
}
|