@pikku/inspector 0.11.2 → 0.12.1
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 +36 -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 +81 -61
- package/dist/add/add-cli.d.ts +1 -1
- package/dist/add/add-cli.js +42 -19
- package/dist/add/add-file-extends-core-type.d.ts +1 -1
- package/dist/add/add-file-with-config.d.ts +1 -1
- package/dist/add/add-file-with-factory.d.ts +1 -1
- package/dist/add/add-file-with-factory.js +2 -0
- package/dist/add/add-functions.d.ts +1 -1
- package/dist/add/add-functions.js +256 -82
- package/dist/add/add-http-route.d.ts +20 -10
- package/dist/add/add-http-route.js +156 -66
- package/dist/add/add-http-routes.d.ts +5 -0
- package/dist/add/add-http-routes.js +160 -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.d.ts +1 -1
- package/dist/add/add-mcp-prompt.js +14 -9
- package/dist/add/add-mcp-resource.d.ts +1 -1
- 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.d.ts +1 -1
- package/dist/add/add-queue-worker.js +18 -12
- package/dist/add/add-rpc-invocations.d.ts +3 -3
- package/dist/add/add-rpc-invocations.js +24 -10
- package/dist/add/add-schedule.d.ts +1 -1
- 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-wire-addon.d.ts +7 -0
- package/dist/add/add-wire-addon.js +70 -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.d.ts +1 -1
- package/dist/add/add-workflow.js +6 -4
- package/dist/error-codes.d.ts +15 -1
- package/dist/error-codes.js +20 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +5 -4
- package/dist/inspector.d.ts +2 -2
- package/dist/inspector.js +95 -15
- 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 -50
- package/dist/utils/compute-required-schemas.d.ts +4 -0
- package/dist/utils/compute-required-schemas.js +40 -0
- package/dist/utils/contract-hashes.d.ts +52 -0
- package/dist/utils/contract-hashes.js +269 -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/does-type-extend-core-type.d.ts +1 -1
- package/dist/utils/ensure-function-metadata.d.ts +6 -3
- 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.d.ts +1 -1
- package/dist/utils/filter-inspector-state.js +107 -23
- package/dist/utils/filter-utils.d.ts +2 -2
- package/dist/utils/get-files-and-methods.d.ts +1 -1
- 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 +9 -32
- package/dist/utils/middleware.js +80 -66
- package/dist/utils/permissions.d.ts +4 -4
- package/dist/utils/permissions.js +10 -10
- package/dist/utils/post-process.d.ts +11 -11
- package/dist/utils/post-process.js +247 -24
- package/dist/utils/resolve-addon-package.d.ts +16 -0
- package/dist/utils/resolve-addon-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 +70 -23
- package/dist/utils/serialize-inspector-state.js +98 -22
- 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/validate-auth-sessionless.d.ts +3 -0
- package/dist/utils/validate-auth-sessionless.js +14 -0
- package/dist/utils/workflow/dsl/deserialize-dsl-workflow.js +34 -102
- package/dist/utils/workflow/dsl/extract-dsl-workflow.d.ts +1 -1
- 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.d.ts +1 -1
- package/dist/visit.js +13 -6
- package/package.json +14 -4
- package/src/add/add-ai-agent.ts +468 -0
- package/src/add/add-channel.ts +103 -79
- package/src/add/add-cli.ts +68 -24
- package/src/add/add-file-extends-core-type.ts +1 -1
- package/src/add/add-file-with-config.ts +1 -1
- package/src/add/add-file-with-factory.ts +3 -1
- package/src/add/add-functions.ts +349 -103
- package/src/add/add-http-route.ts +263 -89
- package/src/add/add-http-routes.ts +229 -0
- package/src/add/add-keyed-wiring.ts +151 -0
- package/src/add/add-mcp-prompt.ts +27 -16
- package/src/add/add-mcp-resource.ts +28 -16
- package/src/add/add-middleware.ts +482 -80
- package/src/add/add-permission.ts +199 -40
- package/src/add/add-queue-worker.ts +25 -20
- package/src/add/add-rpc-invocations.ts +28 -11
- package/src/add/add-schedule.ts +17 -12
- 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-wire-addon.ts +80 -0
- package/src/add/add-workflow-graph.ts +180 -522
- package/src/add/add-workflow.ts +7 -6
- package/src/error-codes.ts +25 -1
- package/src/index.ts +23 -13
- package/src/inspector.ts +139 -19
- package/src/schema-generator.ts +1 -0
- package/src/types-map.ts +12 -1
- package/src/types.ts +199 -69
- package/src/utils/compute-required-schemas.ts +48 -0
- package/src/utils/contract-hashes.test.ts +553 -0
- package/src/utils/contract-hashes.ts +386 -0
- package/src/utils/custom-types-generator.ts +88 -0
- package/src/utils/detect-schema-vendor.ts +90 -0
- package/src/utils/does-type-extend-core-type.ts +1 -1
- package/src/utils/ensure-function-metadata.ts +325 -8
- 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 +37 -25
- package/src/utils/filter-inspector-state.ts +146 -32
- package/src/utils/filter-utils.test.ts +1 -1
- package/src/utils/filter-utils.ts +2 -2
- package/src/utils/get-files-and-methods.ts +1 -1
- 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 +131 -69
- package/src/utils/permissions.test.ts +35 -12
- package/src/utils/permissions.ts +12 -12
- package/src/utils/post-process.ts +306 -44
- package/src/utils/resolve-addon-package.ts +49 -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 +184 -43
- 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/validate-auth-sessionless.ts +29 -0
- package/src/utils/workflow/dsl/deserialize-dsl-workflow.ts +43 -119
- package/src/utils/workflow/dsl/extract-dsl-workflow.ts +26 -6
- 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 +19 -7
- 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 type { JSONValue } from '@pikku/core'
|
|
2
|
+
import type { 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']
|
|
@@ -125,7 +142,19 @@ export interface SerializableInspectorState {
|
|
|
125
142
|
exposedMeta: InspectorState['rpc']['exposedMeta']
|
|
126
143
|
exposedFiles: Array<[string, { path: string; exportedName: string }]>
|
|
127
144
|
invokedFunctions: string[]
|
|
128
|
-
|
|
145
|
+
usedAddons: string[]
|
|
146
|
+
wireAddonDeclarations: Array<
|
|
147
|
+
[
|
|
148
|
+
string,
|
|
149
|
+
{
|
|
150
|
+
package: string
|
|
151
|
+
rpcEndpoint?: string
|
|
152
|
+
secretOverrides?: Record<string, string>
|
|
153
|
+
variableOverrides?: Record<string, string>
|
|
154
|
+
},
|
|
155
|
+
]
|
|
156
|
+
>
|
|
157
|
+
wireAddonFiles: string[]
|
|
129
158
|
}
|
|
130
159
|
mcpEndpoints: {
|
|
131
160
|
resourcesMeta: InspectorState['mcpEndpoints']['resourcesMeta']
|
|
@@ -133,20 +162,30 @@ export interface SerializableInspectorState {
|
|
|
133
162
|
promptsMeta: InspectorState['mcpEndpoints']['promptsMeta']
|
|
134
163
|
files: string[]
|
|
135
164
|
}
|
|
165
|
+
agents: {
|
|
166
|
+
agentsMeta: InspectorState['agents']['agentsMeta']
|
|
167
|
+
files: [string, { path: string; exportedName: string }][]
|
|
168
|
+
}
|
|
136
169
|
cli: {
|
|
137
170
|
meta: InspectorState['cli']['meta']
|
|
138
171
|
files: string[]
|
|
139
172
|
}
|
|
140
|
-
|
|
141
|
-
meta: InspectorState['
|
|
173
|
+
nodes: {
|
|
174
|
+
meta: InspectorState['nodes']['meta']
|
|
142
175
|
files: string[]
|
|
143
176
|
}
|
|
144
|
-
|
|
145
|
-
|
|
177
|
+
secrets: {
|
|
178
|
+
definitions: InspectorState['secrets']['definitions']
|
|
146
179
|
files: string[]
|
|
147
180
|
}
|
|
181
|
+
variables: {
|
|
182
|
+
definitions: InspectorState['variables']['definitions']
|
|
183
|
+
files: string[]
|
|
184
|
+
}
|
|
185
|
+
manifest: InspectorState['manifest']
|
|
148
186
|
middleware: {
|
|
149
|
-
|
|
187
|
+
definitions: InspectorState['middleware']['definitions']
|
|
188
|
+
instances: InspectorState['middleware']['instances']
|
|
150
189
|
tagMiddleware: Array<
|
|
151
190
|
[
|
|
152
191
|
string,
|
|
@@ -159,8 +198,27 @@ export interface SerializableInspectorState {
|
|
|
159
198
|
]
|
|
160
199
|
>
|
|
161
200
|
}
|
|
201
|
+
channelMiddleware: {
|
|
202
|
+
definitions: InspectorState['channelMiddleware']['definitions']
|
|
203
|
+
instances: InspectorState['channelMiddleware']['instances']
|
|
204
|
+
tagMiddleware: Array<
|
|
205
|
+
[
|
|
206
|
+
string,
|
|
207
|
+
InspectorState['channelMiddleware']['tagMiddleware'] extends Map<
|
|
208
|
+
string,
|
|
209
|
+
infer V
|
|
210
|
+
>
|
|
211
|
+
? V
|
|
212
|
+
: never,
|
|
213
|
+
]
|
|
214
|
+
>
|
|
215
|
+
}
|
|
216
|
+
aiMiddleware: {
|
|
217
|
+
definitions: InspectorState['aiMiddleware']['definitions']
|
|
218
|
+
}
|
|
162
219
|
permissions: {
|
|
163
|
-
|
|
220
|
+
definitions: InspectorState['permissions']['definitions']
|
|
221
|
+
instances: InspectorState['permissions']['instances']
|
|
164
222
|
tagPermissions: Array<
|
|
165
223
|
[
|
|
166
224
|
string,
|
|
@@ -181,16 +239,12 @@ export interface SerializableInspectorState {
|
|
|
181
239
|
allSingletonServices: string[]
|
|
182
240
|
allWireServices: string[]
|
|
183
241
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
version: string
|
|
191
|
-
interface: string
|
|
192
|
-
expandedProperties: Record<string, string>
|
|
193
|
-
}>
|
|
242
|
+
resolvedIOTypes: Record<string, { inputType: string; outputType: string }>
|
|
243
|
+
middlewareGroupsMeta: InspectorState['middlewareGroupsMeta']
|
|
244
|
+
permissionsGroupsMeta: InspectorState['permissionsGroupsMeta']
|
|
245
|
+
requiredSchemas: string[]
|
|
246
|
+
openAPISpec: Record<string, any> | null
|
|
247
|
+
diagnostics: InspectorDiagnostic[]
|
|
194
248
|
}
|
|
195
249
|
|
|
196
250
|
/**
|
|
@@ -243,7 +297,8 @@ export function serializeInspectorState(
|
|
|
243
297
|
filesAndMethodsErrors: Array.from(
|
|
244
298
|
state.filesAndMethodsErrors.entries()
|
|
245
299
|
).map(([key, mapValue]) => [key, Array.from(mapValue.entries())] as const),
|
|
246
|
-
|
|
300
|
+
schemaLookup: Array.from(state.schemaLookup.entries()),
|
|
301
|
+
schemas: state.schemas,
|
|
247
302
|
functions: {
|
|
248
303
|
typesMap: serializeTypesMap(state.functions.typesMap),
|
|
249
304
|
meta: state.functions.meta,
|
|
@@ -260,6 +315,11 @@ export function serializeInspectorState(
|
|
|
260
315
|
files: Array.from(state.channels.files),
|
|
261
316
|
meta: state.channels.meta,
|
|
262
317
|
},
|
|
318
|
+
triggers: {
|
|
319
|
+
meta: state.triggers.meta,
|
|
320
|
+
sourceMeta: state.triggers.sourceMeta,
|
|
321
|
+
files: Array.from(state.triggers.files),
|
|
322
|
+
},
|
|
263
323
|
scheduledTasks: {
|
|
264
324
|
meta: state.scheduledTasks.meta,
|
|
265
325
|
files: Array.from(state.scheduledTasks.files),
|
|
@@ -273,6 +333,7 @@ export function serializeInspectorState(
|
|
|
273
333
|
files: Array.from(state.workflows.files.entries()),
|
|
274
334
|
graphMeta: state.workflows.graphMeta,
|
|
275
335
|
graphFiles: Array.from(state.workflows.graphFiles.entries()),
|
|
336
|
+
invokedWorkflows: Array.from(state.workflows.invokedWorkflows),
|
|
276
337
|
},
|
|
277
338
|
rpc: {
|
|
278
339
|
internalMeta: state.rpc.internalMeta,
|
|
@@ -280,7 +341,11 @@ export function serializeInspectorState(
|
|
|
280
341
|
exposedMeta: state.rpc.exposedMeta,
|
|
281
342
|
exposedFiles: Array.from(state.rpc.exposedFiles.entries()),
|
|
282
343
|
invokedFunctions: Array.from(state.rpc.invokedFunctions),
|
|
283
|
-
|
|
344
|
+
usedAddons: Array.from(state.rpc.usedAddons),
|
|
345
|
+
wireAddonDeclarations: Array.from(
|
|
346
|
+
state.rpc.wireAddonDeclarations.entries()
|
|
347
|
+
),
|
|
348
|
+
wireAddonFiles: Array.from(state.rpc.wireAddonFiles),
|
|
284
349
|
},
|
|
285
350
|
mcpEndpoints: {
|
|
286
351
|
resourcesMeta: state.mcpEndpoints.resourcesMeta,
|
|
@@ -288,24 +353,45 @@ export function serializeInspectorState(
|
|
|
288
353
|
promptsMeta: state.mcpEndpoints.promptsMeta,
|
|
289
354
|
files: Array.from(state.mcpEndpoints.files),
|
|
290
355
|
},
|
|
356
|
+
agents: {
|
|
357
|
+
agentsMeta: state.agents?.agentsMeta ?? {},
|
|
358
|
+
files: Array.from(state.agents?.files?.entries() ?? []),
|
|
359
|
+
},
|
|
291
360
|
cli: {
|
|
292
361
|
meta: state.cli.meta,
|
|
293
362
|
files: Array.from(state.cli.files),
|
|
294
363
|
},
|
|
295
|
-
|
|
296
|
-
meta: state.
|
|
297
|
-
files: Array.from(state.
|
|
364
|
+
nodes: {
|
|
365
|
+
meta: state.nodes.meta,
|
|
366
|
+
files: Array.from(state.nodes.files),
|
|
298
367
|
},
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
files: Array.from(state.
|
|
368
|
+
secrets: {
|
|
369
|
+
definitions: state.secrets.definitions,
|
|
370
|
+
files: Array.from(state.secrets.files),
|
|
302
371
|
},
|
|
372
|
+
variables: {
|
|
373
|
+
definitions: state.variables.definitions,
|
|
374
|
+
files: Array.from(state.variables.files),
|
|
375
|
+
},
|
|
376
|
+
manifest: state.manifest,
|
|
303
377
|
middleware: {
|
|
304
|
-
|
|
378
|
+
definitions: state.middleware.definitions,
|
|
379
|
+
instances: state.middleware.instances,
|
|
305
380
|
tagMiddleware: Array.from(state.middleware.tagMiddleware.entries()),
|
|
306
381
|
},
|
|
382
|
+
channelMiddleware: {
|
|
383
|
+
definitions: state.channelMiddleware.definitions,
|
|
384
|
+
instances: state.channelMiddleware.instances,
|
|
385
|
+
tagMiddleware: Array.from(
|
|
386
|
+
state.channelMiddleware.tagMiddleware.entries()
|
|
387
|
+
),
|
|
388
|
+
},
|
|
389
|
+
aiMiddleware: {
|
|
390
|
+
definitions: state.aiMiddleware.definitions,
|
|
391
|
+
},
|
|
307
392
|
permissions: {
|
|
308
|
-
|
|
393
|
+
definitions: state.permissions.definitions,
|
|
394
|
+
instances: state.permissions.instances,
|
|
309
395
|
tagPermissions: Array.from(state.permissions.tagPermissions.entries()),
|
|
310
396
|
},
|
|
311
397
|
serviceAggregation: {
|
|
@@ -316,7 +402,12 @@ export function serializeInspectorState(
|
|
|
316
402
|
allSingletonServices: state.serviceAggregation.allSingletonServices,
|
|
317
403
|
allWireServices: state.serviceAggregation.allWireServices,
|
|
318
404
|
},
|
|
319
|
-
|
|
405
|
+
resolvedIOTypes: state.resolvedIOTypes,
|
|
406
|
+
middlewareGroupsMeta: state.middlewareGroupsMeta,
|
|
407
|
+
permissionsGroupsMeta: state.permissionsGroupsMeta,
|
|
408
|
+
requiredSchemas: Array.from(state.requiredSchemas),
|
|
409
|
+
openAPISpec: state.openAPISpec,
|
|
410
|
+
diagnostics: state.diagnostics,
|
|
320
411
|
}
|
|
321
412
|
}
|
|
322
413
|
|
|
@@ -326,8 +417,15 @@ export function serializeInspectorState(
|
|
|
326
417
|
*/
|
|
327
418
|
export function deserializeInspectorState(
|
|
328
419
|
data: SerializableInspectorState
|
|
329
|
-
): Omit<InspectorState, 'typesLookup' | '
|
|
330
|
-
|
|
420
|
+
): Omit<InspectorState, 'typesLookup' | 'schemaLookup'> & {
|
|
421
|
+
schemaLookup: Map<
|
|
422
|
+
string,
|
|
423
|
+
{
|
|
424
|
+
variableName: string
|
|
425
|
+
sourceFile: string
|
|
426
|
+
vendor?: 'zod' | 'valibot' | 'arktype' | 'effect' | 'unknown'
|
|
427
|
+
}
|
|
428
|
+
>
|
|
331
429
|
} {
|
|
332
430
|
// Helper to deserialize TypesMap
|
|
333
431
|
const deserializeTypesMap = (
|
|
@@ -363,7 +461,8 @@ export function deserializeInspectorState(
|
|
|
363
461
|
new Map(entries),
|
|
364
462
|
])
|
|
365
463
|
),
|
|
366
|
-
|
|
464
|
+
schemaLookup: new Map(data.schemaLookup || []),
|
|
465
|
+
schemas: data.schemas || {},
|
|
367
466
|
functions: {
|
|
368
467
|
typesMap: deserializeTypesMap(data.functions.typesMap),
|
|
369
468
|
meta: data.functions.meta,
|
|
@@ -380,6 +479,11 @@ export function deserializeInspectorState(
|
|
|
380
479
|
files: new Set(data.channels.files),
|
|
381
480
|
meta: data.channels.meta,
|
|
382
481
|
},
|
|
482
|
+
triggers: {
|
|
483
|
+
meta: data.triggers?.meta ?? {},
|
|
484
|
+
sourceMeta: data.triggers?.sourceMeta ?? {},
|
|
485
|
+
files: new Set(data.triggers?.files ?? []),
|
|
486
|
+
},
|
|
383
487
|
scheduledTasks: {
|
|
384
488
|
meta: data.scheduledTasks.meta,
|
|
385
489
|
files: new Set(data.scheduledTasks.files),
|
|
@@ -393,6 +497,7 @@ export function deserializeInspectorState(
|
|
|
393
497
|
files: new Map(data.workflows.files),
|
|
394
498
|
graphMeta: data.workflows.graphMeta || {},
|
|
395
499
|
graphFiles: new Map(data.workflows.graphFiles || []),
|
|
500
|
+
invokedWorkflows: new Set(data.workflows.invokedWorkflows || []),
|
|
396
501
|
},
|
|
397
502
|
rpc: {
|
|
398
503
|
internalMeta: data.rpc.internalMeta,
|
|
@@ -400,7 +505,9 @@ export function deserializeInspectorState(
|
|
|
400
505
|
exposedMeta: data.rpc.exposedMeta,
|
|
401
506
|
exposedFiles: new Map(data.rpc.exposedFiles),
|
|
402
507
|
invokedFunctions: new Set(data.rpc.invokedFunctions),
|
|
403
|
-
|
|
508
|
+
usedAddons: new Set(data.rpc.usedAddons || []),
|
|
509
|
+
wireAddonDeclarations: new Map(data.rpc.wireAddonDeclarations || []),
|
|
510
|
+
wireAddonFiles: new Set(data.rpc.wireAddonFiles || []),
|
|
404
511
|
},
|
|
405
512
|
mcpEndpoints: {
|
|
406
513
|
resourcesMeta: data.mcpEndpoints.resourcesMeta,
|
|
@@ -408,24 +515,43 @@ export function deserializeInspectorState(
|
|
|
408
515
|
promptsMeta: data.mcpEndpoints.promptsMeta,
|
|
409
516
|
files: new Set(data.mcpEndpoints.files),
|
|
410
517
|
},
|
|
518
|
+
agents: {
|
|
519
|
+
agentsMeta: data.agents?.agentsMeta || {},
|
|
520
|
+
files: new Map(data.agents?.files || []),
|
|
521
|
+
},
|
|
411
522
|
cli: {
|
|
412
523
|
meta: data.cli.meta,
|
|
413
524
|
files: new Set(data.cli.files),
|
|
414
525
|
},
|
|
415
|
-
|
|
416
|
-
meta: data.
|
|
417
|
-
files: new Set(data.
|
|
526
|
+
nodes: {
|
|
527
|
+
meta: data.nodes?.meta || {},
|
|
528
|
+
files: new Set(data.nodes?.files || []),
|
|
418
529
|
},
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
files: new Set(data.
|
|
530
|
+
secrets: {
|
|
531
|
+
definitions: data.secrets?.definitions || [],
|
|
532
|
+
files: new Set(data.secrets?.files || []),
|
|
422
533
|
},
|
|
534
|
+
variables: {
|
|
535
|
+
definitions: data.variables?.definitions || [],
|
|
536
|
+
files: new Set(data.variables?.files || []),
|
|
537
|
+
},
|
|
538
|
+
manifest: data.manifest || { initial: null, current: null, errors: [] },
|
|
423
539
|
middleware: {
|
|
424
|
-
|
|
540
|
+
definitions: data.middleware.definitions,
|
|
541
|
+
instances: data.middleware.instances || {},
|
|
425
542
|
tagMiddleware: new Map(data.middleware.tagMiddleware),
|
|
426
543
|
},
|
|
544
|
+
channelMiddleware: {
|
|
545
|
+
definitions: data.channelMiddleware?.definitions || {},
|
|
546
|
+
instances: data.channelMiddleware?.instances || {},
|
|
547
|
+
tagMiddleware: new Map(data.channelMiddleware?.tagMiddleware || []),
|
|
548
|
+
},
|
|
549
|
+
aiMiddleware: {
|
|
550
|
+
definitions: data.aiMiddleware?.definitions || {},
|
|
551
|
+
},
|
|
427
552
|
permissions: {
|
|
428
|
-
|
|
553
|
+
definitions: data.permissions.definitions,
|
|
554
|
+
instances: data.permissions.instances || {},
|
|
429
555
|
tagPermissions: new Map(data.permissions.tagPermissions),
|
|
430
556
|
},
|
|
431
557
|
serviceAggregation: {
|
|
@@ -436,6 +562,21 @@ export function deserializeInspectorState(
|
|
|
436
562
|
allSingletonServices: data.serviceAggregation.allSingletonServices,
|
|
437
563
|
allWireServices: data.serviceAggregation.allWireServices,
|
|
438
564
|
},
|
|
439
|
-
|
|
565
|
+
resolvedIOTypes: data.resolvedIOTypes || {},
|
|
566
|
+
middlewareGroupsMeta: data.middlewareGroupsMeta || {
|
|
567
|
+
definitions: {},
|
|
568
|
+
instances: {},
|
|
569
|
+
httpGroups: {},
|
|
570
|
+
tagGroups: {},
|
|
571
|
+
channelMiddleware: { definitions: {}, instances: {}, tagGroups: {} },
|
|
572
|
+
},
|
|
573
|
+
permissionsGroupsMeta: data.permissionsGroupsMeta || {
|
|
574
|
+
definitions: {},
|
|
575
|
+
httpGroups: {},
|
|
576
|
+
tagGroups: {},
|
|
577
|
+
},
|
|
578
|
+
requiredSchemas: new Set(data.requiredSchemas || []),
|
|
579
|
+
openAPISpec: data.openAPISpec || null,
|
|
580
|
+
diagnostics: data.diagnostics || [],
|
|
440
581
|
}
|
|
441
582
|
}
|
|
@@ -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
|
+
}
|