@pikku/inspector 0.11.2 → 0.12.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/CHANGELOG.md +11 -1
- package/OPTIMIZATION-PLAN.md +195 -0
- package/dist/add/add-ai-agent.d.ts +2 -0
- package/dist/add/add-ai-agent.js +314 -0
- package/dist/add/add-channel.js +69 -61
- package/dist/add/add-cli.js +36 -18
- package/dist/add/add-file-with-factory.js +2 -0
- package/dist/add/add-functions.js +250 -75
- package/dist/add/add-http-route.d.ts +19 -10
- package/dist/add/add-http-route.js +152 -66
- package/dist/add/add-http-routes.d.ts +5 -0
- package/dist/add/add-http-routes.js +159 -0
- package/dist/add/add-keyed-wiring.d.ts +12 -0
- package/dist/add/add-keyed-wiring.js +97 -0
- package/dist/add/add-mcp-prompt.js +14 -9
- package/dist/add/add-mcp-resource.js +14 -9
- package/dist/add/add-middleware.d.ts +1 -4
- package/dist/add/add-middleware.js +364 -79
- package/dist/add/add-permission.d.ts +1 -1
- package/dist/add/add-permission.js +152 -40
- package/dist/add/add-queue-worker.js +18 -12
- package/dist/add/add-rpc-invocations.js +14 -0
- package/dist/add/add-schedule.js +11 -5
- package/dist/add/add-secret.d.ts +3 -0
- package/dist/add/add-secret.js +82 -0
- package/dist/add/add-trigger.d.ts +2 -0
- package/dist/add/add-trigger.js +87 -0
- package/dist/add/add-variable.d.ts +1 -0
- package/dist/add/add-variable.js +8 -0
- package/dist/add/add-workflow-graph.d.ts +3 -2
- package/dist/add/add-workflow-graph.js +143 -406
- package/dist/add/add-workflow.js +6 -4
- package/dist/error-codes.d.ts +14 -1
- package/dist/error-codes.js +19 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +5 -4
- package/dist/inspector.d.ts +1 -1
- package/dist/inspector.js +91 -14
- package/dist/schema-generator.d.ts +1 -0
- package/dist/schema-generator.js +1 -0
- package/dist/types-map.js +10 -1
- package/dist/types.d.ts +163 -39
- package/dist/utils/compute-required-schemas.d.ts +4 -0
- package/dist/utils/compute-required-schemas.js +41 -0
- package/dist/utils/contract-hashes.d.ts +35 -0
- package/dist/utils/contract-hashes.js +202 -0
- package/dist/utils/custom-types-generator.d.ts +9 -0
- package/dist/utils/custom-types-generator.js +71 -0
- package/dist/utils/detect-schema-vendor.d.ts +22 -0
- package/dist/utils/detect-schema-vendor.js +76 -0
- package/dist/utils/ensure-function-metadata.d.ts +5 -2
- package/dist/utils/ensure-function-metadata.js +220 -6
- package/dist/utils/extract-function-name.d.ts +5 -16
- package/dist/utils/extract-function-name.js +86 -291
- package/dist/utils/extract-services.d.ts +2 -1
- package/dist/utils/extract-services.js +25 -1
- package/dist/utils/filter-inspector-state.js +107 -23
- package/dist/utils/get-property-value.d.ts +6 -1
- package/dist/utils/get-property-value.js +28 -3
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.js +23 -0
- package/dist/utils/middleware.d.ts +7 -30
- package/dist/utils/middleware.js +80 -66
- package/dist/utils/permissions.d.ts +2 -2
- package/dist/utils/permissions.js +10 -10
- package/dist/utils/post-process.d.ts +9 -10
- package/dist/utils/post-process.js +231 -24
- package/dist/utils/resolve-external-package.d.ts +12 -0
- package/dist/utils/resolve-external-package.js +34 -0
- package/dist/utils/resolve-function-types.d.ts +6 -0
- package/dist/utils/resolve-function-types.js +29 -0
- package/dist/utils/resolve-identifier.d.ts +10 -0
- package/dist/utils/resolve-identifier.js +36 -0
- package/dist/utils/resolve-versions.d.ts +2 -0
- package/dist/utils/resolve-versions.js +78 -0
- package/dist/utils/schema-generator.d.ts +9 -0
- package/dist/utils/schema-generator.js +209 -0
- package/dist/utils/serialize-inspector-state.d.ts +59 -22
- package/dist/utils/serialize-inspector-state.js +92 -20
- package/dist/utils/serialize-mcp-json.d.ts +2 -0
- package/dist/utils/serialize-mcp-json.js +99 -0
- package/dist/utils/serialize-middleware-groups-meta.d.ts +12 -0
- package/dist/utils/serialize-middleware-groups-meta.js +28 -0
- package/dist/utils/serialize-openapi-json.d.ts +85 -0
- package/dist/utils/serialize-openapi-json.js +151 -0
- package/dist/utils/serialize-permissions-groups-meta.d.ts +6 -0
- package/dist/utils/serialize-permissions-groups-meta.js +31 -0
- package/dist/utils/workflow/dsl/deserialize-dsl-workflow.js +34 -102
- package/dist/utils/workflow/dsl/extract-dsl-workflow.js +23 -4
- package/dist/utils/workflow/graph/convert-dsl-to-graph.js +12 -10
- package/dist/utils/workflow/graph/finalize-workflow-wires.d.ts +3 -0
- package/dist/utils/workflow/graph/finalize-workflow-wires.js +276 -0
- package/dist/utils/workflow/graph/finalize-workflows.d.ts +2 -0
- package/dist/utils/workflow/graph/finalize-workflows.js +75 -0
- package/dist/utils/workflow/graph/index.d.ts +2 -0
- package/dist/utils/workflow/graph/index.js +2 -0
- package/dist/utils/workflow/graph/serialize-workflow-graph.d.ts +0 -8
- package/dist/utils/workflow/graph/serialize-workflow-graph.js +1 -3
- package/dist/utils/workflow/graph/workflow-graph.types.d.ts +53 -79
- package/dist/utils/workflow/graph/workflow-graph.types.js +1 -1
- package/dist/visit.js +11 -6
- package/package.json +14 -4
- package/src/add/add-ai-agent.ts +468 -0
- package/src/add/add-channel.ts +82 -79
- package/src/add/add-cli.ts +49 -20
- package/src/add/add-file-with-factory.ts +2 -0
- package/src/add/add-functions.ts +330 -86
- package/src/add/add-http-route.ts +245 -88
- package/src/add/add-http-routes.ts +228 -0
- package/src/add/add-keyed-wiring.ts +151 -0
- package/src/add/add-mcp-prompt.ts +26 -15
- package/src/add/add-mcp-resource.ts +27 -15
- package/src/add/add-middleware.ts +482 -80
- package/src/add/add-permission.ts +199 -40
- package/src/add/add-queue-worker.ts +24 -19
- package/src/add/add-rpc-invocations.ts +17 -0
- package/src/add/add-schedule.ts +16 -11
- package/src/add/add-secret.ts +140 -0
- package/src/add/add-trigger.ts +154 -0
- package/src/add/add-variable.ts +9 -0
- package/src/add/add-workflow-graph.ts +180 -522
- package/src/add/add-workflow.ts +5 -4
- package/src/error-codes.ts +24 -1
- package/src/index.ts +22 -13
- package/src/inspector.ts +129 -17
- package/src/schema-generator.ts +1 -0
- package/src/types-map.ts +12 -1
- package/src/types.ts +175 -58
- package/src/utils/compute-required-schemas.ts +49 -0
- package/src/utils/contract-hashes.test.ts +528 -0
- package/src/utils/contract-hashes.ts +290 -0
- package/src/utils/custom-types-generator.ts +88 -0
- package/src/utils/detect-schema-vendor.ts +90 -0
- package/src/utils/ensure-function-metadata.ts +324 -7
- package/src/utils/extract-function-name.ts +101 -351
- package/src/utils/extract-services.ts +35 -2
- package/src/utils/filter-inspector-state.test.ts +34 -20
- package/src/utils/filter-inspector-state.ts +140 -31
- package/src/utils/get-property-value.ts +42 -4
- package/src/utils/hash.ts +26 -0
- package/src/utils/middleware.test.ts +204 -0
- package/src/utils/middleware.ts +129 -67
- package/src/utils/permissions.test.ts +35 -12
- package/src/utils/permissions.ts +10 -10
- package/src/utils/post-process.ts +283 -43
- package/src/utils/resolve-external-package.ts +42 -0
- package/src/utils/resolve-function-types.ts +42 -0
- package/src/utils/resolve-identifier.ts +46 -0
- package/src/utils/resolve-versions.test.ts +249 -0
- package/src/utils/resolve-versions.ts +105 -0
- package/src/utils/schema-generator.ts +329 -0
- package/src/utils/serialize-inspector-state.ts +163 -40
- package/src/utils/serialize-mcp-json.ts +145 -0
- package/src/utils/serialize-middleware-groups-meta.ts +33 -0
- package/src/utils/serialize-openapi-json.ts +277 -0
- package/src/utils/serialize-permissions-groups-meta.ts +35 -0
- package/src/utils/test-data/inspector-state.json +69 -66
- package/src/utils/workflow/dsl/deserialize-dsl-workflow.ts +43 -119
- package/src/utils/workflow/dsl/extract-dsl-workflow.ts +24 -4
- package/src/utils/workflow/graph/convert-dsl-to-graph.ts +17 -10
- package/src/utils/workflow/graph/finalize-workflow-wires.ts +310 -0
- package/src/utils/workflow/graph/finalize-workflows.ts +100 -0
- package/src/utils/workflow/graph/index.ts +5 -0
- package/src/utils/workflow/graph/serialize-workflow-graph.ts +1 -8
- package/src/utils/workflow/graph/workflow-graph.types.ts +29 -78
- package/src/visit.ts +12 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/add/add-forge-credential.d.ts +0 -8
- package/dist/add/add-forge-credential.js +0 -77
- package/dist/add/add-forge-node.d.ts +0 -7
- package/dist/add/add-forge-node.js +0 -77
- package/dist/add/add-mcp-tool.d.ts +0 -2
- package/dist/add/add-mcp-tool.js +0 -81
- package/dist/utils/extract-service-metadata.d.ts +0 -19
- package/dist/utils/extract-service-metadata.js +0 -244
- package/dist/utils/write-service-metadata.d.ts +0 -13
- package/dist/utils/write-service-metadata.js +0 -37
- package/src/add/add-forge-credential.ts +0 -119
- package/src/add/add-forge-node.ts +0 -132
- package/src/add/add-mcp-tool.ts +0 -141
- package/src/utils/extract-service-metadata.ts +0 -353
- package/src/utils/write-service-metadata.ts +0 -51
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JSONValue } from '@pikku/core'
|
|
2
|
+
import { InspectorDiagnostic, InspectorState } from '../types.js'
|
|
2
3
|
import { TypesMap } from '../types-map.js'
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -62,7 +63,17 @@ export interface SerializableInspectorState {
|
|
|
62
63
|
>,
|
|
63
64
|
]
|
|
64
65
|
>
|
|
65
|
-
|
|
66
|
+
schemaLookup: Array<
|
|
67
|
+
[
|
|
68
|
+
string,
|
|
69
|
+
{
|
|
70
|
+
variableName: string
|
|
71
|
+
sourceFile: string
|
|
72
|
+
vendor?: 'zod' | 'valibot' | 'arktype' | 'effect' | 'unknown'
|
|
73
|
+
},
|
|
74
|
+
]
|
|
75
|
+
>
|
|
76
|
+
schemas: Record<string, JSONValue>
|
|
66
77
|
functions: {
|
|
67
78
|
typesMap: {
|
|
68
79
|
map: Array<[string, { originalName: string; path: string | null }]>
|
|
@@ -105,6 +116,11 @@ export interface SerializableInspectorState {
|
|
|
105
116
|
files: string[]
|
|
106
117
|
meta: InspectorState['channels']['meta']
|
|
107
118
|
}
|
|
119
|
+
triggers: {
|
|
120
|
+
meta: InspectorState['triggers']['meta']
|
|
121
|
+
sourceMeta: InspectorState['triggers']['sourceMeta']
|
|
122
|
+
files: string[]
|
|
123
|
+
}
|
|
108
124
|
scheduledTasks: {
|
|
109
125
|
meta: InspectorState['scheduledTasks']['meta']
|
|
110
126
|
files: string[]
|
|
@@ -118,6 +134,7 @@ export interface SerializableInspectorState {
|
|
|
118
134
|
files: Array<[string, { path: string; exportedName: string }]>
|
|
119
135
|
graphMeta: InspectorState['workflows']['graphMeta']
|
|
120
136
|
graphFiles: Array<[string, { path: string; exportedName: string }]>
|
|
137
|
+
invokedWorkflows: string[]
|
|
121
138
|
}
|
|
122
139
|
rpc: {
|
|
123
140
|
internalMeta: InspectorState['rpc']['internalMeta']
|
|
@@ -133,20 +150,30 @@ export interface SerializableInspectorState {
|
|
|
133
150
|
promptsMeta: InspectorState['mcpEndpoints']['promptsMeta']
|
|
134
151
|
files: string[]
|
|
135
152
|
}
|
|
153
|
+
agents: {
|
|
154
|
+
agentsMeta: InspectorState['agents']['agentsMeta']
|
|
155
|
+
files: [string, { path: string; exportedName: string }][]
|
|
156
|
+
}
|
|
136
157
|
cli: {
|
|
137
158
|
meta: InspectorState['cli']['meta']
|
|
138
159
|
files: string[]
|
|
139
160
|
}
|
|
140
|
-
|
|
141
|
-
meta: InspectorState['
|
|
161
|
+
nodes: {
|
|
162
|
+
meta: InspectorState['nodes']['meta']
|
|
163
|
+
files: string[]
|
|
164
|
+
}
|
|
165
|
+
secrets: {
|
|
166
|
+
definitions: InspectorState['secrets']['definitions']
|
|
142
167
|
files: string[]
|
|
143
168
|
}
|
|
144
|
-
|
|
145
|
-
|
|
169
|
+
variables: {
|
|
170
|
+
definitions: InspectorState['variables']['definitions']
|
|
146
171
|
files: string[]
|
|
147
172
|
}
|
|
173
|
+
manifest: InspectorState['manifest']
|
|
148
174
|
middleware: {
|
|
149
|
-
|
|
175
|
+
definitions: InspectorState['middleware']['definitions']
|
|
176
|
+
instances: InspectorState['middleware']['instances']
|
|
150
177
|
tagMiddleware: Array<
|
|
151
178
|
[
|
|
152
179
|
string,
|
|
@@ -159,8 +186,27 @@ export interface SerializableInspectorState {
|
|
|
159
186
|
]
|
|
160
187
|
>
|
|
161
188
|
}
|
|
189
|
+
channelMiddleware: {
|
|
190
|
+
definitions: InspectorState['channelMiddleware']['definitions']
|
|
191
|
+
instances: InspectorState['channelMiddleware']['instances']
|
|
192
|
+
tagMiddleware: Array<
|
|
193
|
+
[
|
|
194
|
+
string,
|
|
195
|
+
InspectorState['channelMiddleware']['tagMiddleware'] extends Map<
|
|
196
|
+
string,
|
|
197
|
+
infer V
|
|
198
|
+
>
|
|
199
|
+
? V
|
|
200
|
+
: never,
|
|
201
|
+
]
|
|
202
|
+
>
|
|
203
|
+
}
|
|
204
|
+
aiMiddleware: {
|
|
205
|
+
definitions: InspectorState['aiMiddleware']['definitions']
|
|
206
|
+
}
|
|
162
207
|
permissions: {
|
|
163
|
-
|
|
208
|
+
definitions: InspectorState['permissions']['definitions']
|
|
209
|
+
instances: InspectorState['permissions']['instances']
|
|
164
210
|
tagPermissions: Array<
|
|
165
211
|
[
|
|
166
212
|
string,
|
|
@@ -181,16 +227,12 @@ export interface SerializableInspectorState {
|
|
|
181
227
|
allSingletonServices: string[]
|
|
182
228
|
allWireServices: string[]
|
|
183
229
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
version: string
|
|
191
|
-
interface: string
|
|
192
|
-
expandedProperties: Record<string, string>
|
|
193
|
-
}>
|
|
230
|
+
resolvedIOTypes: Record<string, { inputType: string; outputType: string }>
|
|
231
|
+
middlewareGroupsMeta: InspectorState['middlewareGroupsMeta']
|
|
232
|
+
permissionsGroupsMeta: InspectorState['permissionsGroupsMeta']
|
|
233
|
+
requiredSchemas: string[]
|
|
234
|
+
openAPISpec: Record<string, any> | null
|
|
235
|
+
diagnostics: InspectorDiagnostic[]
|
|
194
236
|
}
|
|
195
237
|
|
|
196
238
|
/**
|
|
@@ -243,7 +285,8 @@ export function serializeInspectorState(
|
|
|
243
285
|
filesAndMethodsErrors: Array.from(
|
|
244
286
|
state.filesAndMethodsErrors.entries()
|
|
245
287
|
).map(([key, mapValue]) => [key, Array.from(mapValue.entries())] as const),
|
|
246
|
-
|
|
288
|
+
schemaLookup: Array.from(state.schemaLookup.entries()),
|
|
289
|
+
schemas: state.schemas,
|
|
247
290
|
functions: {
|
|
248
291
|
typesMap: serializeTypesMap(state.functions.typesMap),
|
|
249
292
|
meta: state.functions.meta,
|
|
@@ -260,6 +303,11 @@ export function serializeInspectorState(
|
|
|
260
303
|
files: Array.from(state.channels.files),
|
|
261
304
|
meta: state.channels.meta,
|
|
262
305
|
},
|
|
306
|
+
triggers: {
|
|
307
|
+
meta: state.triggers.meta,
|
|
308
|
+
sourceMeta: state.triggers.sourceMeta,
|
|
309
|
+
files: Array.from(state.triggers.files),
|
|
310
|
+
},
|
|
263
311
|
scheduledTasks: {
|
|
264
312
|
meta: state.scheduledTasks.meta,
|
|
265
313
|
files: Array.from(state.scheduledTasks.files),
|
|
@@ -273,6 +321,7 @@ export function serializeInspectorState(
|
|
|
273
321
|
files: Array.from(state.workflows.files.entries()),
|
|
274
322
|
graphMeta: state.workflows.graphMeta,
|
|
275
323
|
graphFiles: Array.from(state.workflows.graphFiles.entries()),
|
|
324
|
+
invokedWorkflows: Array.from(state.workflows.invokedWorkflows),
|
|
276
325
|
},
|
|
277
326
|
rpc: {
|
|
278
327
|
internalMeta: state.rpc.internalMeta,
|
|
@@ -288,24 +337,45 @@ export function serializeInspectorState(
|
|
|
288
337
|
promptsMeta: state.mcpEndpoints.promptsMeta,
|
|
289
338
|
files: Array.from(state.mcpEndpoints.files),
|
|
290
339
|
},
|
|
340
|
+
agents: {
|
|
341
|
+
agentsMeta: state.agents?.agentsMeta ?? {},
|
|
342
|
+
files: Array.from(state.agents?.files?.entries() ?? []),
|
|
343
|
+
},
|
|
291
344
|
cli: {
|
|
292
345
|
meta: state.cli.meta,
|
|
293
346
|
files: Array.from(state.cli.files),
|
|
294
347
|
},
|
|
295
|
-
|
|
296
|
-
meta: state.
|
|
297
|
-
files: Array.from(state.
|
|
348
|
+
nodes: {
|
|
349
|
+
meta: state.nodes.meta,
|
|
350
|
+
files: Array.from(state.nodes.files),
|
|
298
351
|
},
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
files: Array.from(state.
|
|
352
|
+
secrets: {
|
|
353
|
+
definitions: state.secrets.definitions,
|
|
354
|
+
files: Array.from(state.secrets.files),
|
|
302
355
|
},
|
|
356
|
+
variables: {
|
|
357
|
+
definitions: state.variables.definitions,
|
|
358
|
+
files: Array.from(state.variables.files),
|
|
359
|
+
},
|
|
360
|
+
manifest: state.manifest,
|
|
303
361
|
middleware: {
|
|
304
|
-
|
|
362
|
+
definitions: state.middleware.definitions,
|
|
363
|
+
instances: state.middleware.instances,
|
|
305
364
|
tagMiddleware: Array.from(state.middleware.tagMiddleware.entries()),
|
|
306
365
|
},
|
|
366
|
+
channelMiddleware: {
|
|
367
|
+
definitions: state.channelMiddleware.definitions,
|
|
368
|
+
instances: state.channelMiddleware.instances,
|
|
369
|
+
tagMiddleware: Array.from(
|
|
370
|
+
state.channelMiddleware.tagMiddleware.entries()
|
|
371
|
+
),
|
|
372
|
+
},
|
|
373
|
+
aiMiddleware: {
|
|
374
|
+
definitions: state.aiMiddleware.definitions,
|
|
375
|
+
},
|
|
307
376
|
permissions: {
|
|
308
|
-
|
|
377
|
+
definitions: state.permissions.definitions,
|
|
378
|
+
instances: state.permissions.instances,
|
|
309
379
|
tagPermissions: Array.from(state.permissions.tagPermissions.entries()),
|
|
310
380
|
},
|
|
311
381
|
serviceAggregation: {
|
|
@@ -316,7 +386,12 @@ export function serializeInspectorState(
|
|
|
316
386
|
allSingletonServices: state.serviceAggregation.allSingletonServices,
|
|
317
387
|
allWireServices: state.serviceAggregation.allWireServices,
|
|
318
388
|
},
|
|
319
|
-
|
|
389
|
+
resolvedIOTypes: state.resolvedIOTypes,
|
|
390
|
+
middlewareGroupsMeta: state.middlewareGroupsMeta,
|
|
391
|
+
permissionsGroupsMeta: state.permissionsGroupsMeta,
|
|
392
|
+
requiredSchemas: Array.from(state.requiredSchemas),
|
|
393
|
+
openAPISpec: state.openAPISpec,
|
|
394
|
+
diagnostics: state.diagnostics,
|
|
320
395
|
}
|
|
321
396
|
}
|
|
322
397
|
|
|
@@ -326,8 +401,15 @@ export function serializeInspectorState(
|
|
|
326
401
|
*/
|
|
327
402
|
export function deserializeInspectorState(
|
|
328
403
|
data: SerializableInspectorState
|
|
329
|
-
): Omit<InspectorState, 'typesLookup' | '
|
|
330
|
-
|
|
404
|
+
): Omit<InspectorState, 'typesLookup' | 'schemaLookup'> & {
|
|
405
|
+
schemaLookup: Map<
|
|
406
|
+
string,
|
|
407
|
+
{
|
|
408
|
+
variableName: string
|
|
409
|
+
sourceFile: string
|
|
410
|
+
vendor?: 'zod' | 'valibot' | 'arktype' | 'effect' | 'unknown'
|
|
411
|
+
}
|
|
412
|
+
>
|
|
331
413
|
} {
|
|
332
414
|
// Helper to deserialize TypesMap
|
|
333
415
|
const deserializeTypesMap = (
|
|
@@ -363,7 +445,8 @@ export function deserializeInspectorState(
|
|
|
363
445
|
new Map(entries),
|
|
364
446
|
])
|
|
365
447
|
),
|
|
366
|
-
|
|
448
|
+
schemaLookup: new Map(data.schemaLookup || []),
|
|
449
|
+
schemas: data.schemas || {},
|
|
367
450
|
functions: {
|
|
368
451
|
typesMap: deserializeTypesMap(data.functions.typesMap),
|
|
369
452
|
meta: data.functions.meta,
|
|
@@ -380,6 +463,11 @@ export function deserializeInspectorState(
|
|
|
380
463
|
files: new Set(data.channels.files),
|
|
381
464
|
meta: data.channels.meta,
|
|
382
465
|
},
|
|
466
|
+
triggers: {
|
|
467
|
+
meta: data.triggers?.meta ?? {},
|
|
468
|
+
sourceMeta: data.triggers?.sourceMeta ?? {},
|
|
469
|
+
files: new Set(data.triggers?.files ?? []),
|
|
470
|
+
},
|
|
383
471
|
scheduledTasks: {
|
|
384
472
|
meta: data.scheduledTasks.meta,
|
|
385
473
|
files: new Set(data.scheduledTasks.files),
|
|
@@ -393,6 +481,7 @@ export function deserializeInspectorState(
|
|
|
393
481
|
files: new Map(data.workflows.files),
|
|
394
482
|
graphMeta: data.workflows.graphMeta || {},
|
|
395
483
|
graphFiles: new Map(data.workflows.graphFiles || []),
|
|
484
|
+
invokedWorkflows: new Set(data.workflows.invokedWorkflows || []),
|
|
396
485
|
},
|
|
397
486
|
rpc: {
|
|
398
487
|
internalMeta: data.rpc.internalMeta,
|
|
@@ -408,24 +497,43 @@ export function deserializeInspectorState(
|
|
|
408
497
|
promptsMeta: data.mcpEndpoints.promptsMeta,
|
|
409
498
|
files: new Set(data.mcpEndpoints.files),
|
|
410
499
|
},
|
|
500
|
+
agents: {
|
|
501
|
+
agentsMeta: data.agents?.agentsMeta || {},
|
|
502
|
+
files: new Map(data.agents?.files || []),
|
|
503
|
+
},
|
|
411
504
|
cli: {
|
|
412
505
|
meta: data.cli.meta,
|
|
413
506
|
files: new Set(data.cli.files),
|
|
414
507
|
},
|
|
415
|
-
|
|
416
|
-
meta: data.
|
|
417
|
-
files: new Set(data.
|
|
508
|
+
nodes: {
|
|
509
|
+
meta: data.nodes?.meta || {},
|
|
510
|
+
files: new Set(data.nodes?.files || []),
|
|
511
|
+
},
|
|
512
|
+
secrets: {
|
|
513
|
+
definitions: data.secrets?.definitions || [],
|
|
514
|
+
files: new Set(data.secrets?.files || []),
|
|
418
515
|
},
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
files: new Set(data.
|
|
516
|
+
variables: {
|
|
517
|
+
definitions: data.variables?.definitions || [],
|
|
518
|
+
files: new Set(data.variables?.files || []),
|
|
422
519
|
},
|
|
520
|
+
manifest: data.manifest || { initial: null, current: null, errors: [] },
|
|
423
521
|
middleware: {
|
|
424
|
-
|
|
522
|
+
definitions: data.middleware.definitions,
|
|
523
|
+
instances: data.middleware.instances || {},
|
|
425
524
|
tagMiddleware: new Map(data.middleware.tagMiddleware),
|
|
426
525
|
},
|
|
526
|
+
channelMiddleware: {
|
|
527
|
+
definitions: data.channelMiddleware?.definitions || {},
|
|
528
|
+
instances: data.channelMiddleware?.instances || {},
|
|
529
|
+
tagMiddleware: new Map(data.channelMiddleware?.tagMiddleware || []),
|
|
530
|
+
},
|
|
531
|
+
aiMiddleware: {
|
|
532
|
+
definitions: data.aiMiddleware?.definitions || {},
|
|
533
|
+
},
|
|
427
534
|
permissions: {
|
|
428
|
-
|
|
535
|
+
definitions: data.permissions.definitions,
|
|
536
|
+
instances: data.permissions.instances || {},
|
|
429
537
|
tagPermissions: new Map(data.permissions.tagPermissions),
|
|
430
538
|
},
|
|
431
539
|
serviceAggregation: {
|
|
@@ -436,6 +544,21 @@ export function deserializeInspectorState(
|
|
|
436
544
|
allSingletonServices: data.serviceAggregation.allSingletonServices,
|
|
437
545
|
allWireServices: data.serviceAggregation.allWireServices,
|
|
438
546
|
},
|
|
439
|
-
|
|
547
|
+
resolvedIOTypes: data.resolvedIOTypes || {},
|
|
548
|
+
middlewareGroupsMeta: data.middlewareGroupsMeta || {
|
|
549
|
+
definitions: {},
|
|
550
|
+
instances: {},
|
|
551
|
+
httpGroups: {},
|
|
552
|
+
tagGroups: {},
|
|
553
|
+
channelMiddleware: { definitions: {}, instances: {}, tagGroups: {} },
|
|
554
|
+
},
|
|
555
|
+
permissionsGroupsMeta: data.permissionsGroupsMeta || {
|
|
556
|
+
definitions: {},
|
|
557
|
+
httpGroups: {},
|
|
558
|
+
tagGroups: {},
|
|
559
|
+
},
|
|
560
|
+
requiredSchemas: new Set(data.requiredSchemas || []),
|
|
561
|
+
openAPISpec: data.openAPISpec || null,
|
|
562
|
+
diagnostics: data.diagnostics || [],
|
|
440
563
|
}
|
|
441
564
|
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { InspectorLogger, InspectorState } from '../types.js'
|
|
2
|
+
import type { JSONValue } from '@pikku/core'
|
|
3
|
+
|
|
4
|
+
interface MCPEndpoint {
|
|
5
|
+
uri?: string
|
|
6
|
+
name: string
|
|
7
|
+
description?: string
|
|
8
|
+
parameters?: JSONValue
|
|
9
|
+
returns?: JSONValue
|
|
10
|
+
streaming?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const serializeMCPJson = (
|
|
14
|
+
logger: InspectorLogger,
|
|
15
|
+
state: InspectorState
|
|
16
|
+
): string => {
|
|
17
|
+
const { mcpEndpoints, functions, schemas } = state
|
|
18
|
+
const { meta: functionsMeta, typesMap } = functions
|
|
19
|
+
const { resourcesMeta, toolsMeta, promptsMeta } = mcpEndpoints
|
|
20
|
+
|
|
21
|
+
const tools: MCPEndpoint[] = []
|
|
22
|
+
const resources: MCPEndpoint[] = []
|
|
23
|
+
const prompts: any[] = []
|
|
24
|
+
|
|
25
|
+
const loadSchema = (typeName: string | undefined): JSONValue | undefined => {
|
|
26
|
+
if (
|
|
27
|
+
!typeName ||
|
|
28
|
+
[
|
|
29
|
+
'boolean',
|
|
30
|
+
'string',
|
|
31
|
+
'number',
|
|
32
|
+
'null',
|
|
33
|
+
'undefined',
|
|
34
|
+
'void',
|
|
35
|
+
'unknown',
|
|
36
|
+
'never',
|
|
37
|
+
].includes(typeName)
|
|
38
|
+
) {
|
|
39
|
+
return undefined
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const uniqueName = typesMap.getUniqueName(typeName)
|
|
43
|
+
if (!uniqueName) {
|
|
44
|
+
return undefined
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const schema = schemas[uniqueName]
|
|
48
|
+
if (!schema) {
|
|
49
|
+
logger.warn(
|
|
50
|
+
`Serialize MCP: Could not find schema for type: ${uniqueName}`
|
|
51
|
+
)
|
|
52
|
+
return undefined
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return schema
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
for (const [name, endpointMeta] of Object.entries(resourcesMeta)) {
|
|
59
|
+
const functionMeta = functionsMeta[endpointMeta.pikkuFuncId]
|
|
60
|
+
if (!functionMeta) {
|
|
61
|
+
logger.warn(
|
|
62
|
+
`Function ${endpointMeta.pikkuFuncId} not found in functionsMeta. Skipping resource ${name}.`
|
|
63
|
+
)
|
|
64
|
+
continue
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const inputType = functionMeta.inputs?.[0]
|
|
68
|
+
const outputType = functionMeta.outputs?.[0]
|
|
69
|
+
|
|
70
|
+
const parameters = loadSchema(inputType)
|
|
71
|
+
const returns = loadSchema(outputType)
|
|
72
|
+
|
|
73
|
+
resources.push({
|
|
74
|
+
uri: name,
|
|
75
|
+
name,
|
|
76
|
+
description: endpointMeta.description,
|
|
77
|
+
...(parameters && { parameters }),
|
|
78
|
+
...(returns && { returns }),
|
|
79
|
+
...(endpointMeta.streaming && { streaming: true }),
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
for (const [name, endpointMeta] of Object.entries(toolsMeta)) {
|
|
84
|
+
const functionMeta = functionsMeta[endpointMeta.pikkuFuncId]
|
|
85
|
+
if (!functionMeta) {
|
|
86
|
+
logger.warn(
|
|
87
|
+
`Function ${endpointMeta.pikkuFuncId} not found in functionsMeta. Skipping tool ${name}.`
|
|
88
|
+
)
|
|
89
|
+
continue
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const inputType = functionMeta.inputs?.[0]
|
|
93
|
+
const outputType = functionMeta.outputs?.[0]
|
|
94
|
+
|
|
95
|
+
const parameters = loadSchema(inputType)
|
|
96
|
+
const returns = loadSchema(outputType)
|
|
97
|
+
|
|
98
|
+
tools.push({
|
|
99
|
+
name,
|
|
100
|
+
description: endpointMeta.description,
|
|
101
|
+
...(parameters && { parameters }),
|
|
102
|
+
...(returns && { returns }),
|
|
103
|
+
...(endpointMeta.streaming && { streaming: true }),
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
for (const [name, endpointMeta] of Object.entries(promptsMeta)) {
|
|
108
|
+
const functionMeta = functionsMeta[endpointMeta.pikkuFuncId]
|
|
109
|
+
if (!functionMeta) {
|
|
110
|
+
logger.warn(
|
|
111
|
+
`Function ${endpointMeta.pikkuFuncId} not found in functionsMeta. Skipping prompt ${name}.`
|
|
112
|
+
)
|
|
113
|
+
continue
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const inputType = functionMeta.inputs?.[0]
|
|
117
|
+
const inputSchema = loadSchema(inputType)
|
|
118
|
+
|
|
119
|
+
const argumentsArray: any[] = []
|
|
120
|
+
if (
|
|
121
|
+
inputSchema &&
|
|
122
|
+
typeof inputSchema === 'object' &&
|
|
123
|
+
!(inputSchema instanceof Array)
|
|
124
|
+
) {
|
|
125
|
+
const properties = inputSchema.properties as Record<string, any>
|
|
126
|
+
const required = (inputSchema.required as string[]) || []
|
|
127
|
+
|
|
128
|
+
for (const [propName, propSchema] of Object.entries(properties)) {
|
|
129
|
+
argumentsArray.push({
|
|
130
|
+
name: propName,
|
|
131
|
+
description: propSchema.description || `${propName} parameter`,
|
|
132
|
+
required: required.includes(propName),
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
prompts.push({
|
|
138
|
+
name,
|
|
139
|
+
description: endpointMeta.description,
|
|
140
|
+
arguments: argumentsArray,
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return JSON.stringify({ tools, resources, prompts }, null, 2)
|
|
145
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { InspectorState, MiddlewareGroupMeta } from '../types.js'
|
|
2
|
+
|
|
3
|
+
const serializeGroupMap = (
|
|
4
|
+
groupMap: Map<string, MiddlewareGroupMeta>
|
|
5
|
+
): Record<string, any> => {
|
|
6
|
+
const result: Record<string, any> = {}
|
|
7
|
+
for (const [key, meta] of groupMap.entries()) {
|
|
8
|
+
result[key] = {
|
|
9
|
+
exportName: meta.exportName,
|
|
10
|
+
sourceFile: meta.sourceFile,
|
|
11
|
+
position: meta.position,
|
|
12
|
+
services: meta.services,
|
|
13
|
+
count: meta.count,
|
|
14
|
+
instanceIds: meta.instanceIds,
|
|
15
|
+
isFactory: meta.isFactory,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const serializeMiddlewareGroupsMeta = (state: InspectorState) => {
|
|
22
|
+
return {
|
|
23
|
+
definitions: state.middleware.definitions,
|
|
24
|
+
instances: state.middleware.instances,
|
|
25
|
+
httpGroups: serializeGroupMap(state.http.routeMiddleware),
|
|
26
|
+
tagGroups: serializeGroupMap(state.middleware.tagMiddleware),
|
|
27
|
+
channelMiddleware: {
|
|
28
|
+
definitions: state.channelMiddleware.definitions,
|
|
29
|
+
instances: state.channelMiddleware.instances,
|
|
30
|
+
tagGroups: serializeGroupMap(state.channelMiddleware.tagMiddleware),
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
}
|