@pikku/inspector 0.11.1 → 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 +26 -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 +327 -59
- package/dist/add/add-http-route.d.ts +19 -10
- package/dist/add/add-http-route.js +153 -44
- 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.d.ts +3 -0
- package/dist/add/add-rpc-invocations.js +65 -25
- 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 +7 -0
- package/dist/add/add-workflow-graph.js +396 -0
- package/dist/add/add-workflow.js +124 -26
- package/dist/error-codes.d.ts +16 -1
- package/dist/error-codes.js +21 -1
- package/dist/index.d.ts +9 -5
- package/dist/index.js +5 -2
- package/dist/inspector.d.ts +1 -1
- package/dist/inspector.js +106 -13
- 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 +180 -30
- 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 +93 -298
- 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 +8 -2
- package/dist/utils/get-property-value.js +33 -4
- 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 +73 -13
- package/dist/utils/serialize-inspector-state.js +102 -6
- 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.d.ts +24 -0
- package/dist/utils/workflow/dsl/deserialize-dsl-workflow.js +830 -0
- package/dist/{workflow/extract-simple-workflow.d.ts → utils/workflow/dsl/extract-dsl-workflow.d.ts} +4 -2
- package/dist/{workflow/extract-simple-workflow.js → utils/workflow/dsl/extract-dsl-workflow.js} +572 -72
- package/dist/utils/workflow/dsl/index.d.ts +7 -0
- package/dist/utils/workflow/dsl/index.js +7 -0
- package/dist/{workflow → utils/workflow/dsl}/patterns.d.ts +21 -0
- package/dist/{workflow → utils/workflow/dsl}/patterns.js +90 -10
- package/dist/{workflow → utils/workflow/dsl}/validation.d.ts +2 -0
- package/dist/{workflow → utils/workflow/dsl}/validation.js +25 -7
- package/dist/utils/workflow/graph/convert-dsl-to-graph.d.ts +13 -0
- package/dist/utils/workflow/graph/convert-dsl-to-graph.js +318 -0
- 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 +8 -0
- package/dist/utils/workflow/graph/index.js +8 -0
- package/dist/utils/workflow/graph/serialize-workflow-graph.d.ts +35 -0
- package/dist/utils/workflow/graph/serialize-workflow-graph.js +150 -0
- package/dist/utils/workflow/graph/workflow-graph.types.d.ts +203 -0
- package/dist/utils/workflow/graph/workflow-graph.types.js +38 -0
- package/dist/visit.js +13 -2
- package/package.json +26 -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 +429 -71
- package/src/add/add-http-route.ts +246 -65
- 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 +78 -31
- 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 +522 -0
- package/src/add/add-workflow.ts +117 -30
- package/src/error-codes.ts +26 -1
- package/src/index.ts +27 -8
- package/src/inspector.ts +145 -17
- package/src/schema-generator.ts +1 -0
- package/src/types-map.ts +12 -1
- package/src/types.ts +192 -51
- 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 +108 -358
- 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 +50 -5
- 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 +181 -20
- 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 +1104 -0
- package/src/{workflow/extract-simple-workflow.ts → utils/workflow/dsl/extract-dsl-workflow.ts} +678 -85
- package/src/utils/workflow/dsl/index.ts +11 -0
- package/src/{workflow → utils/workflow/dsl}/patterns.ts +108 -11
- package/src/{workflow → utils/workflow/dsl}/validation.ts +34 -7
- package/src/utils/workflow/graph/convert-dsl-to-graph.ts +422 -0
- 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 +11 -0
- package/src/utils/workflow/graph/serialize-workflow-graph.ts +216 -0
- package/src/utils/workflow/graph/workflow-graph.types.ts +231 -0
- package/src/visit.ts +14 -2
- package/tsconfig.tsbuildinfo +1 -1
- 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-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,6 +63,17 @@ export interface SerializableInspectorState {
|
|
|
62
63
|
>,
|
|
63
64
|
]
|
|
64
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>
|
|
65
77
|
functions: {
|
|
66
78
|
typesMap: {
|
|
67
79
|
map: Array<[string, { originalName: string; path: string | null }]>
|
|
@@ -104,6 +116,11 @@ export interface SerializableInspectorState {
|
|
|
104
116
|
files: string[]
|
|
105
117
|
meta: InspectorState['channels']['meta']
|
|
106
118
|
}
|
|
119
|
+
triggers: {
|
|
120
|
+
meta: InspectorState['triggers']['meta']
|
|
121
|
+
sourceMeta: InspectorState['triggers']['sourceMeta']
|
|
122
|
+
files: string[]
|
|
123
|
+
}
|
|
107
124
|
scheduledTasks: {
|
|
108
125
|
meta: InspectorState['scheduledTasks']['meta']
|
|
109
126
|
files: string[]
|
|
@@ -115,6 +132,9 @@ export interface SerializableInspectorState {
|
|
|
115
132
|
workflows: {
|
|
116
133
|
meta: InspectorState['workflows']['meta']
|
|
117
134
|
files: Array<[string, { path: string; exportedName: string }]>
|
|
135
|
+
graphMeta: InspectorState['workflows']['graphMeta']
|
|
136
|
+
graphFiles: Array<[string, { path: string; exportedName: string }]>
|
|
137
|
+
invokedWorkflows: string[]
|
|
118
138
|
}
|
|
119
139
|
rpc: {
|
|
120
140
|
internalMeta: InspectorState['rpc']['internalMeta']
|
|
@@ -122,6 +142,7 @@ export interface SerializableInspectorState {
|
|
|
122
142
|
exposedMeta: InspectorState['rpc']['exposedMeta']
|
|
123
143
|
exposedFiles: Array<[string, { path: string; exportedName: string }]>
|
|
124
144
|
invokedFunctions: string[]
|
|
145
|
+
usedExternalPackages: string[]
|
|
125
146
|
}
|
|
126
147
|
mcpEndpoints: {
|
|
127
148
|
resourcesMeta: InspectorState['mcpEndpoints']['resourcesMeta']
|
|
@@ -129,12 +150,30 @@ export interface SerializableInspectorState {
|
|
|
129
150
|
promptsMeta: InspectorState['mcpEndpoints']['promptsMeta']
|
|
130
151
|
files: string[]
|
|
131
152
|
}
|
|
153
|
+
agents: {
|
|
154
|
+
agentsMeta: InspectorState['agents']['agentsMeta']
|
|
155
|
+
files: [string, { path: string; exportedName: string }][]
|
|
156
|
+
}
|
|
132
157
|
cli: {
|
|
133
158
|
meta: InspectorState['cli']['meta']
|
|
134
159
|
files: string[]
|
|
135
160
|
}
|
|
161
|
+
nodes: {
|
|
162
|
+
meta: InspectorState['nodes']['meta']
|
|
163
|
+
files: string[]
|
|
164
|
+
}
|
|
165
|
+
secrets: {
|
|
166
|
+
definitions: InspectorState['secrets']['definitions']
|
|
167
|
+
files: string[]
|
|
168
|
+
}
|
|
169
|
+
variables: {
|
|
170
|
+
definitions: InspectorState['variables']['definitions']
|
|
171
|
+
files: string[]
|
|
172
|
+
}
|
|
173
|
+
manifest: InspectorState['manifest']
|
|
136
174
|
middleware: {
|
|
137
|
-
|
|
175
|
+
definitions: InspectorState['middleware']['definitions']
|
|
176
|
+
instances: InspectorState['middleware']['instances']
|
|
138
177
|
tagMiddleware: Array<
|
|
139
178
|
[
|
|
140
179
|
string,
|
|
@@ -147,8 +186,27 @@ export interface SerializableInspectorState {
|
|
|
147
186
|
]
|
|
148
187
|
>
|
|
149
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
|
+
}
|
|
150
207
|
permissions: {
|
|
151
|
-
|
|
208
|
+
definitions: InspectorState['permissions']['definitions']
|
|
209
|
+
instances: InspectorState['permissions']['instances']
|
|
152
210
|
tagPermissions: Array<
|
|
153
211
|
[
|
|
154
212
|
string,
|
|
@@ -169,16 +227,12 @@ export interface SerializableInspectorState {
|
|
|
169
227
|
allSingletonServices: string[]
|
|
170
228
|
allWireServices: string[]
|
|
171
229
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
version: string
|
|
179
|
-
interface: string
|
|
180
|
-
expandedProperties: Record<string, string>
|
|
181
|
-
}>
|
|
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[]
|
|
182
236
|
}
|
|
183
237
|
|
|
184
238
|
/**
|
|
@@ -231,6 +285,8 @@ export function serializeInspectorState(
|
|
|
231
285
|
filesAndMethodsErrors: Array.from(
|
|
232
286
|
state.filesAndMethodsErrors.entries()
|
|
233
287
|
).map(([key, mapValue]) => [key, Array.from(mapValue.entries())] as const),
|
|
288
|
+
schemaLookup: Array.from(state.schemaLookup.entries()),
|
|
289
|
+
schemas: state.schemas,
|
|
234
290
|
functions: {
|
|
235
291
|
typesMap: serializeTypesMap(state.functions.typesMap),
|
|
236
292
|
meta: state.functions.meta,
|
|
@@ -247,6 +303,11 @@ export function serializeInspectorState(
|
|
|
247
303
|
files: Array.from(state.channels.files),
|
|
248
304
|
meta: state.channels.meta,
|
|
249
305
|
},
|
|
306
|
+
triggers: {
|
|
307
|
+
meta: state.triggers.meta,
|
|
308
|
+
sourceMeta: state.triggers.sourceMeta,
|
|
309
|
+
files: Array.from(state.triggers.files),
|
|
310
|
+
},
|
|
250
311
|
scheduledTasks: {
|
|
251
312
|
meta: state.scheduledTasks.meta,
|
|
252
313
|
files: Array.from(state.scheduledTasks.files),
|
|
@@ -258,6 +319,9 @@ export function serializeInspectorState(
|
|
|
258
319
|
workflows: {
|
|
259
320
|
meta: state.workflows.meta,
|
|
260
321
|
files: Array.from(state.workflows.files.entries()),
|
|
322
|
+
graphMeta: state.workflows.graphMeta,
|
|
323
|
+
graphFiles: Array.from(state.workflows.graphFiles.entries()),
|
|
324
|
+
invokedWorkflows: Array.from(state.workflows.invokedWorkflows),
|
|
261
325
|
},
|
|
262
326
|
rpc: {
|
|
263
327
|
internalMeta: state.rpc.internalMeta,
|
|
@@ -265,6 +329,7 @@ export function serializeInspectorState(
|
|
|
265
329
|
exposedMeta: state.rpc.exposedMeta,
|
|
266
330
|
exposedFiles: Array.from(state.rpc.exposedFiles.entries()),
|
|
267
331
|
invokedFunctions: Array.from(state.rpc.invokedFunctions),
|
|
332
|
+
usedExternalPackages: Array.from(state.rpc.usedExternalPackages),
|
|
268
333
|
},
|
|
269
334
|
mcpEndpoints: {
|
|
270
335
|
resourcesMeta: state.mcpEndpoints.resourcesMeta,
|
|
@@ -272,16 +337,45 @@ export function serializeInspectorState(
|
|
|
272
337
|
promptsMeta: state.mcpEndpoints.promptsMeta,
|
|
273
338
|
files: Array.from(state.mcpEndpoints.files),
|
|
274
339
|
},
|
|
340
|
+
agents: {
|
|
341
|
+
agentsMeta: state.agents?.agentsMeta ?? {},
|
|
342
|
+
files: Array.from(state.agents?.files?.entries() ?? []),
|
|
343
|
+
},
|
|
275
344
|
cli: {
|
|
276
345
|
meta: state.cli.meta,
|
|
277
346
|
files: Array.from(state.cli.files),
|
|
278
347
|
},
|
|
348
|
+
nodes: {
|
|
349
|
+
meta: state.nodes.meta,
|
|
350
|
+
files: Array.from(state.nodes.files),
|
|
351
|
+
},
|
|
352
|
+
secrets: {
|
|
353
|
+
definitions: state.secrets.definitions,
|
|
354
|
+
files: Array.from(state.secrets.files),
|
|
355
|
+
},
|
|
356
|
+
variables: {
|
|
357
|
+
definitions: state.variables.definitions,
|
|
358
|
+
files: Array.from(state.variables.files),
|
|
359
|
+
},
|
|
360
|
+
manifest: state.manifest,
|
|
279
361
|
middleware: {
|
|
280
|
-
|
|
362
|
+
definitions: state.middleware.definitions,
|
|
363
|
+
instances: state.middleware.instances,
|
|
281
364
|
tagMiddleware: Array.from(state.middleware.tagMiddleware.entries()),
|
|
282
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
|
+
},
|
|
283
376
|
permissions: {
|
|
284
|
-
|
|
377
|
+
definitions: state.permissions.definitions,
|
|
378
|
+
instances: state.permissions.instances,
|
|
285
379
|
tagPermissions: Array.from(state.permissions.tagPermissions.entries()),
|
|
286
380
|
},
|
|
287
381
|
serviceAggregation: {
|
|
@@ -292,7 +386,12 @@ export function serializeInspectorState(
|
|
|
292
386
|
allSingletonServices: state.serviceAggregation.allSingletonServices,
|
|
293
387
|
allWireServices: state.serviceAggregation.allWireServices,
|
|
294
388
|
},
|
|
295
|
-
|
|
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,
|
|
296
395
|
}
|
|
297
396
|
}
|
|
298
397
|
|
|
@@ -302,7 +401,16 @@ export function serializeInspectorState(
|
|
|
302
401
|
*/
|
|
303
402
|
export function deserializeInspectorState(
|
|
304
403
|
data: SerializableInspectorState
|
|
305
|
-
): Omit<InspectorState, 'typesLookup'> {
|
|
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
|
+
>
|
|
413
|
+
} {
|
|
306
414
|
// Helper to deserialize TypesMap
|
|
307
415
|
const deserializeTypesMap = (
|
|
308
416
|
serialized: SerializableInspectorState['functions']['typesMap']
|
|
@@ -337,6 +445,8 @@ export function deserializeInspectorState(
|
|
|
337
445
|
new Map(entries),
|
|
338
446
|
])
|
|
339
447
|
),
|
|
448
|
+
schemaLookup: new Map(data.schemaLookup || []),
|
|
449
|
+
schemas: data.schemas || {},
|
|
340
450
|
functions: {
|
|
341
451
|
typesMap: deserializeTypesMap(data.functions.typesMap),
|
|
342
452
|
meta: data.functions.meta,
|
|
@@ -353,6 +463,11 @@ export function deserializeInspectorState(
|
|
|
353
463
|
files: new Set(data.channels.files),
|
|
354
464
|
meta: data.channels.meta,
|
|
355
465
|
},
|
|
466
|
+
triggers: {
|
|
467
|
+
meta: data.triggers?.meta ?? {},
|
|
468
|
+
sourceMeta: data.triggers?.sourceMeta ?? {},
|
|
469
|
+
files: new Set(data.triggers?.files ?? []),
|
|
470
|
+
},
|
|
356
471
|
scheduledTasks: {
|
|
357
472
|
meta: data.scheduledTasks.meta,
|
|
358
473
|
files: new Set(data.scheduledTasks.files),
|
|
@@ -364,6 +479,9 @@ export function deserializeInspectorState(
|
|
|
364
479
|
workflows: {
|
|
365
480
|
meta: data.workflows.meta,
|
|
366
481
|
files: new Map(data.workflows.files),
|
|
482
|
+
graphMeta: data.workflows.graphMeta || {},
|
|
483
|
+
graphFiles: new Map(data.workflows.graphFiles || []),
|
|
484
|
+
invokedWorkflows: new Set(data.workflows.invokedWorkflows || []),
|
|
367
485
|
},
|
|
368
486
|
rpc: {
|
|
369
487
|
internalMeta: data.rpc.internalMeta,
|
|
@@ -371,6 +489,7 @@ export function deserializeInspectorState(
|
|
|
371
489
|
exposedMeta: data.rpc.exposedMeta,
|
|
372
490
|
exposedFiles: new Map(data.rpc.exposedFiles),
|
|
373
491
|
invokedFunctions: new Set(data.rpc.invokedFunctions),
|
|
492
|
+
usedExternalPackages: new Set(data.rpc.usedExternalPackages || []),
|
|
374
493
|
},
|
|
375
494
|
mcpEndpoints: {
|
|
376
495
|
resourcesMeta: data.mcpEndpoints.resourcesMeta,
|
|
@@ -378,16 +497,43 @@ export function deserializeInspectorState(
|
|
|
378
497
|
promptsMeta: data.mcpEndpoints.promptsMeta,
|
|
379
498
|
files: new Set(data.mcpEndpoints.files),
|
|
380
499
|
},
|
|
500
|
+
agents: {
|
|
501
|
+
agentsMeta: data.agents?.agentsMeta || {},
|
|
502
|
+
files: new Map(data.agents?.files || []),
|
|
503
|
+
},
|
|
381
504
|
cli: {
|
|
382
505
|
meta: data.cli.meta,
|
|
383
506
|
files: new Set(data.cli.files),
|
|
384
507
|
},
|
|
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 || []),
|
|
515
|
+
},
|
|
516
|
+
variables: {
|
|
517
|
+
definitions: data.variables?.definitions || [],
|
|
518
|
+
files: new Set(data.variables?.files || []),
|
|
519
|
+
},
|
|
520
|
+
manifest: data.manifest || { initial: null, current: null, errors: [] },
|
|
385
521
|
middleware: {
|
|
386
|
-
|
|
522
|
+
definitions: data.middleware.definitions,
|
|
523
|
+
instances: data.middleware.instances || {},
|
|
387
524
|
tagMiddleware: new Map(data.middleware.tagMiddleware),
|
|
388
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
|
+
},
|
|
389
534
|
permissions: {
|
|
390
|
-
|
|
535
|
+
definitions: data.permissions.definitions,
|
|
536
|
+
instances: data.permissions.instances || {},
|
|
391
537
|
tagPermissions: new Map(data.permissions.tagPermissions),
|
|
392
538
|
},
|
|
393
539
|
serviceAggregation: {
|
|
@@ -398,6 +544,21 @@ export function deserializeInspectorState(
|
|
|
398
544
|
allSingletonServices: data.serviceAggregation.allSingletonServices,
|
|
399
545
|
allWireServices: data.serviceAggregation.allWireServices,
|
|
400
546
|
},
|
|
401
|
-
|
|
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 || [],
|
|
402
563
|
}
|
|
403
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
|
+
}
|