@elevasis/core 0.16.0 → 0.18.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/knowledge/index.d.ts +1340 -0
- package/dist/knowledge/index.js +138 -0
- package/package.json +1 -1
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +969 -962
- package/src/knowledge/published.ts +5 -0
- package/src/platform/registry/__tests__/resource-registry.list-executable.test.ts +0 -393
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { byFeature, byKind, byOwner, governs, governedBy, parsePath } from './queries'
|
|
2
|
+
export type { KnowledgeMount, ParsedKnowledgePath } from './queries'
|
|
3
|
+
|
|
4
|
+
export { formatText, formatJson, formatIdsOnly } from './format'
|
|
5
|
+
export type { KnowledgeJsonEnvelope } from './format'
|
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test: ResourceRegistry.listExecutable()
|
|
3
|
-
* Verifies registry serialization includes interface config
|
|
4
|
-
* and listExecutable() filters resources with interfaces
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { describe, it, expect } from 'vitest'
|
|
8
|
-
import { z } from 'zod'
|
|
9
|
-
import { ResourceRegistry } from '../resource-registry'
|
|
10
|
-
import type { WorkflowDefinition } from '../../../execution/engine/workflow/types'
|
|
11
|
-
import type { AgentDefinition } from '../../../execution/engine/agent/core/types'
|
|
12
|
-
import type { OrganizationRegistry } from '../resource-registry'
|
|
13
|
-
|
|
14
|
-
describe('ResourceRegistry - listExecutable()', () => {
|
|
15
|
-
it('should return empty array when organization has no resources', () => {
|
|
16
|
-
const registry: OrganizationRegistry = {
|
|
17
|
-
'test-org': {}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const resourceRegistry = new ResourceRegistry(registry)
|
|
21
|
-
const executable = resourceRegistry.listExecutable('test-org')
|
|
22
|
-
|
|
23
|
-
expect(executable).toEqual([])
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('should return empty array when no resources have interfaces', () => {
|
|
27
|
-
const workflowWithoutInterface: WorkflowDefinition = {
|
|
28
|
-
config: {
|
|
29
|
-
resourceId: 'workflow-no-interface',
|
|
30
|
-
name: 'Workflow Without Interface',
|
|
31
|
-
description: 'Test workflow',
|
|
32
|
-
version: '1.0.0',
|
|
33
|
-
type: 'workflow',
|
|
34
|
-
status: 'prod'
|
|
35
|
-
},
|
|
36
|
-
contract: {
|
|
37
|
-
inputSchema: z.object({}),
|
|
38
|
-
outputSchema: z.object({})
|
|
39
|
-
},
|
|
40
|
-
steps: {},
|
|
41
|
-
entryPoint: 'start'
|
|
42
|
-
// No interface field
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const registry: OrganizationRegistry = {
|
|
46
|
-
'test-org': {
|
|
47
|
-
workflows: [workflowWithoutInterface]
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const resourceRegistry = new ResourceRegistry(registry)
|
|
52
|
-
const executable = resourceRegistry.listExecutable('test-org')
|
|
53
|
-
|
|
54
|
-
expect(executable).toEqual([])
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
it('should return workflow with interface', () => {
|
|
58
|
-
const workflowWithInterface: WorkflowDefinition = {
|
|
59
|
-
config: {
|
|
60
|
-
resourceId: 'workflow-with-interface',
|
|
61
|
-
name: 'Executable Workflow',
|
|
62
|
-
description: 'Test workflow with UI',
|
|
63
|
-
version: '1.0.0',
|
|
64
|
-
type: 'workflow',
|
|
65
|
-
status: 'prod'
|
|
66
|
-
},
|
|
67
|
-
contract: {
|
|
68
|
-
inputSchema: z.object({ input: z.string() }),
|
|
69
|
-
outputSchema: z.object({ output: z.string() })
|
|
70
|
-
},
|
|
71
|
-
steps: {},
|
|
72
|
-
entryPoint: 'start',
|
|
73
|
-
interface: {
|
|
74
|
-
form: {
|
|
75
|
-
title: 'Run Workflow',
|
|
76
|
-
description: 'Execute this workflow',
|
|
77
|
-
fields: [
|
|
78
|
-
{
|
|
79
|
-
name: 'input',
|
|
80
|
-
label: 'Input Text',
|
|
81
|
-
type: 'text',
|
|
82
|
-
required: true
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const registry: OrganizationRegistry = {
|
|
90
|
-
'test-org': {
|
|
91
|
-
workflows: [workflowWithInterface]
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const resourceRegistry = new ResourceRegistry(registry)
|
|
96
|
-
const executable = resourceRegistry.listExecutable('test-org')
|
|
97
|
-
|
|
98
|
-
expect(executable).toHaveLength(1)
|
|
99
|
-
expect(executable[0]).toMatchObject({
|
|
100
|
-
resourceId: 'workflow-with-interface',
|
|
101
|
-
resourceName: 'Executable Workflow',
|
|
102
|
-
resourceType: 'workflow',
|
|
103
|
-
description: 'Test workflow with UI'
|
|
104
|
-
})
|
|
105
|
-
expect(executable[0].interface).toBeDefined()
|
|
106
|
-
expect(executable[0].interface.form.title).toBe('Run Workflow')
|
|
107
|
-
expect(executable[0].interface.form.fields).toHaveLength(1)
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
it('should return agent with interface', () => {
|
|
111
|
-
const agentWithInterface: AgentDefinition = {
|
|
112
|
-
config: {
|
|
113
|
-
resourceId: 'agent-with-interface',
|
|
114
|
-
name: 'Executable Agent',
|
|
115
|
-
description: 'Test agent with UI',
|
|
116
|
-
version: '1.0.0',
|
|
117
|
-
type: 'agent',
|
|
118
|
-
status: 'prod',
|
|
119
|
-
systemPrompt: 'You are a test agent'
|
|
120
|
-
},
|
|
121
|
-
contract: {
|
|
122
|
-
inputSchema: z.object({ task: z.string() }),
|
|
123
|
-
outputSchema: z.object({ result: z.string() })
|
|
124
|
-
},
|
|
125
|
-
tools: [],
|
|
126
|
-
modelConfig: {
|
|
127
|
-
provider: 'openai',
|
|
128
|
-
model: 'gpt-5.4-mini',
|
|
129
|
-
apiKey: 'sk-test123',
|
|
130
|
-
temperature: 1,
|
|
131
|
-
maxOutputTokens: 4000
|
|
132
|
-
},
|
|
133
|
-
interface: {
|
|
134
|
-
form: {
|
|
135
|
-
title: 'Run Agent',
|
|
136
|
-
description: 'Execute this agent',
|
|
137
|
-
fields: [
|
|
138
|
-
{
|
|
139
|
-
name: 'task',
|
|
140
|
-
label: 'Task Description',
|
|
141
|
-
type: 'textarea',
|
|
142
|
-
required: true
|
|
143
|
-
}
|
|
144
|
-
]
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const registry: OrganizationRegistry = {
|
|
150
|
-
'test-org': {
|
|
151
|
-
agents: [agentWithInterface]
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const resourceRegistry = new ResourceRegistry(registry)
|
|
156
|
-
const executable = resourceRegistry.listExecutable('test-org')
|
|
157
|
-
|
|
158
|
-
expect(executable).toHaveLength(1)
|
|
159
|
-
expect(executable[0]).toMatchObject({
|
|
160
|
-
resourceId: 'agent-with-interface',
|
|
161
|
-
resourceName: 'Executable Agent',
|
|
162
|
-
resourceType: 'agent',
|
|
163
|
-
description: 'Test agent with UI'
|
|
164
|
-
})
|
|
165
|
-
expect(executable[0].interface).toBeDefined()
|
|
166
|
-
expect(executable[0].interface.form.title).toBe('Run Agent')
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
it('should filter by environment (prod only)', () => {
|
|
170
|
-
const devWorkflow: WorkflowDefinition = {
|
|
171
|
-
config: {
|
|
172
|
-
resourceId: 'dev-workflow',
|
|
173
|
-
name: 'Dev Workflow',
|
|
174
|
-
description: 'Development workflow',
|
|
175
|
-
version: '1.0.0',
|
|
176
|
-
type: 'workflow',
|
|
177
|
-
status: 'dev'
|
|
178
|
-
},
|
|
179
|
-
contract: {
|
|
180
|
-
inputSchema: z.object({ test: z.string().optional() }),
|
|
181
|
-
outputSchema: z.object({})
|
|
182
|
-
},
|
|
183
|
-
steps: {},
|
|
184
|
-
entryPoint: 'start',
|
|
185
|
-
interface: {
|
|
186
|
-
form: {
|
|
187
|
-
fields: [{ name: 'test', label: 'Test', type: 'text' }]
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const prodWorkflow: WorkflowDefinition = {
|
|
193
|
-
config: {
|
|
194
|
-
resourceId: 'prod-workflow',
|
|
195
|
-
name: 'Prod Workflow',
|
|
196
|
-
description: 'Production workflow',
|
|
197
|
-
version: '1.0.0',
|
|
198
|
-
type: 'workflow',
|
|
199
|
-
status: 'prod'
|
|
200
|
-
},
|
|
201
|
-
contract: {
|
|
202
|
-
inputSchema: z.object({ test: z.string().optional() }),
|
|
203
|
-
outputSchema: z.object({})
|
|
204
|
-
},
|
|
205
|
-
steps: {},
|
|
206
|
-
entryPoint: 'start',
|
|
207
|
-
interface: {
|
|
208
|
-
form: {
|
|
209
|
-
fields: [{ name: 'test', label: 'Test', type: 'text' }]
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const registry: OrganizationRegistry = {
|
|
215
|
-
'test-org': {
|
|
216
|
-
workflows: [devWorkflow, prodWorkflow]
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const resourceRegistry = new ResourceRegistry(registry)
|
|
221
|
-
const executable = resourceRegistry.listExecutable('test-org', 'prod')
|
|
222
|
-
|
|
223
|
-
expect(executable).toHaveLength(1)
|
|
224
|
-
expect(executable[0].resourceId).toBe('prod-workflow')
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
it('should return both workflows and agents with interfaces', () => {
|
|
228
|
-
const workflow: WorkflowDefinition = {
|
|
229
|
-
config: {
|
|
230
|
-
resourceId: 'workflow-1',
|
|
231
|
-
name: 'Workflow 1',
|
|
232
|
-
description: 'Test',
|
|
233
|
-
version: '1.0.0',
|
|
234
|
-
type: 'workflow',
|
|
235
|
-
status: 'prod'
|
|
236
|
-
},
|
|
237
|
-
contract: {
|
|
238
|
-
inputSchema: z.object({ test: z.string().optional() }),
|
|
239
|
-
outputSchema: z.object({})
|
|
240
|
-
},
|
|
241
|
-
steps: {},
|
|
242
|
-
entryPoint: 'start',
|
|
243
|
-
interface: {
|
|
244
|
-
form: {
|
|
245
|
-
fields: [{ name: 'test', label: 'Test', type: 'text' }]
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const agent: AgentDefinition = {
|
|
251
|
-
config: {
|
|
252
|
-
resourceId: 'agent-1',
|
|
253
|
-
name: 'Agent 1',
|
|
254
|
-
description: 'Test',
|
|
255
|
-
version: '1.0.0',
|
|
256
|
-
type: 'agent',
|
|
257
|
-
status: 'prod',
|
|
258
|
-
systemPrompt: 'Test'
|
|
259
|
-
},
|
|
260
|
-
contract: {
|
|
261
|
-
inputSchema: z.object({ test: z.string().optional() }),
|
|
262
|
-
outputSchema: z.object({})
|
|
263
|
-
},
|
|
264
|
-
tools: [],
|
|
265
|
-
modelConfig: {
|
|
266
|
-
provider: 'openai',
|
|
267
|
-
model: 'gpt-5.4-mini',
|
|
268
|
-
apiKey: 'sk-test',
|
|
269
|
-
temperature: 1,
|
|
270
|
-
maxOutputTokens: 4000
|
|
271
|
-
},
|
|
272
|
-
interface: {
|
|
273
|
-
form: {
|
|
274
|
-
fields: [{ name: 'test', label: 'Test', type: 'text' }]
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const registry: OrganizationRegistry = {
|
|
280
|
-
'test-org': {
|
|
281
|
-
workflows: [workflow],
|
|
282
|
-
agents: [agent]
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const resourceRegistry = new ResourceRegistry(registry)
|
|
287
|
-
const executable = resourceRegistry.listExecutable('test-org')
|
|
288
|
-
|
|
289
|
-
expect(executable).toHaveLength(2)
|
|
290
|
-
expect(executable.map((r) => r.resourceType)).toContain('workflow')
|
|
291
|
-
expect(executable.map((r) => r.resourceType)).toContain('agent')
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
it('should serialize interface fields correctly', () => {
|
|
295
|
-
const workflow: WorkflowDefinition = {
|
|
296
|
-
config: {
|
|
297
|
-
resourceId: 'workflow-full-interface',
|
|
298
|
-
name: 'Full Interface Workflow',
|
|
299
|
-
description: 'Test',
|
|
300
|
-
version: '1.0.0',
|
|
301
|
-
type: 'workflow',
|
|
302
|
-
status: 'prod'
|
|
303
|
-
},
|
|
304
|
-
contract: {
|
|
305
|
-
inputSchema: z.object({
|
|
306
|
-
inputText: z.string(),
|
|
307
|
-
inputSelect: z.string().optional()
|
|
308
|
-
}),
|
|
309
|
-
outputSchema: z.object({})
|
|
310
|
-
},
|
|
311
|
-
steps: {},
|
|
312
|
-
entryPoint: 'start',
|
|
313
|
-
interface: {
|
|
314
|
-
form: {
|
|
315
|
-
title: 'Test Form',
|
|
316
|
-
description: 'Test Description',
|
|
317
|
-
fields: [
|
|
318
|
-
{
|
|
319
|
-
name: 'text-field',
|
|
320
|
-
label: 'Text Field',
|
|
321
|
-
type: 'text',
|
|
322
|
-
required: true,
|
|
323
|
-
placeholder: 'Enter text'
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
name: 'select-field',
|
|
327
|
-
label: 'Select Field',
|
|
328
|
-
type: 'select',
|
|
329
|
-
options: [
|
|
330
|
-
{ label: 'Option 1', value: 'opt1' },
|
|
331
|
-
{ label: 'Option 2', value: 'opt2' }
|
|
332
|
-
]
|
|
333
|
-
}
|
|
334
|
-
],
|
|
335
|
-
fieldMappings: {
|
|
336
|
-
'text-field': 'inputText',
|
|
337
|
-
'select-field': 'inputSelect'
|
|
338
|
-
},
|
|
339
|
-
submitButton: {
|
|
340
|
-
label: 'Execute',
|
|
341
|
-
loadingLabel: 'Executing...',
|
|
342
|
-
confirmMessage: 'Are you sure?'
|
|
343
|
-
}
|
|
344
|
-
},
|
|
345
|
-
schedule: {
|
|
346
|
-
enabled: true,
|
|
347
|
-
defaultSchedule: '0 0 * * *',
|
|
348
|
-
allowedPatterns: ['0 0 * * *', '0 12 * * *']
|
|
349
|
-
},
|
|
350
|
-
webhook: {
|
|
351
|
-
enabled: true,
|
|
352
|
-
payloadSchema: { type: 'object' }
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
const registry: OrganizationRegistry = {
|
|
358
|
-
'test-org': {
|
|
359
|
-
workflows: [workflow]
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
const resourceRegistry = new ResourceRegistry(registry)
|
|
364
|
-
const executable = resourceRegistry.listExecutable('test-org')
|
|
365
|
-
|
|
366
|
-
expect(executable).toHaveLength(1)
|
|
367
|
-
|
|
368
|
-
const serializedInterface = executable[0].interface
|
|
369
|
-
|
|
370
|
-
// Verify form serialization
|
|
371
|
-
expect(serializedInterface.form.title).toBe('Test Form')
|
|
372
|
-
expect(serializedInterface.form.description).toBe('Test Description')
|
|
373
|
-
expect(serializedInterface.form.fields).toHaveLength(2)
|
|
374
|
-
expect(serializedInterface.form.fieldMappings).toEqual({
|
|
375
|
-
'text-field': 'inputText',
|
|
376
|
-
'select-field': 'inputSelect'
|
|
377
|
-
})
|
|
378
|
-
expect(serializedInterface.form.submitButton).toEqual({
|
|
379
|
-
label: 'Execute',
|
|
380
|
-
loadingLabel: 'Executing...',
|
|
381
|
-
confirmMessage: 'Are you sure?'
|
|
382
|
-
})
|
|
383
|
-
|
|
384
|
-
// Verify schedule serialization
|
|
385
|
-
expect(serializedInterface.schedule).toBeDefined()
|
|
386
|
-
expect(serializedInterface.schedule!.enabled).toBe(true)
|
|
387
|
-
expect(serializedInterface.schedule!.defaultSchedule).toBe('0 0 * * *')
|
|
388
|
-
|
|
389
|
-
// Verify webhook serialization
|
|
390
|
-
expect(serializedInterface.webhook).toBeDefined()
|
|
391
|
-
expect(serializedInterface.webhook!.enabled).toBe(true)
|
|
392
|
-
})
|
|
393
|
-
})
|