@pikku/inspector 0.12.75 → 0.12.81

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.
Files changed (219) hide show
  1. package/CHANGELOG.md +330 -0
  2. package/dist/add/add-analytics.d.ts +9 -0
  3. package/dist/add/add-analytics.js +178 -0
  4. package/dist/add/add-auth.js +0 -54
  5. package/dist/add/add-feature-flag.d.ts +2 -0
  6. package/dist/add/add-feature-flag.js +162 -0
  7. package/dist/add/add-wire-addon.js +1 -0
  8. package/dist/add/add-wire-remote-addon.js +1 -0
  9. package/dist/index.d.ts +3 -1
  10. package/dist/index.js +3 -1
  11. package/dist/inspector.js +4 -0
  12. package/dist/surface/collect-surface.d.ts +58 -0
  13. package/dist/surface/collect-surface.js +613 -0
  14. package/dist/types.d.ts +20 -11
  15. package/dist/utils/filter-inspector-state.js +14 -0
  16. package/dist/utils/post-process.js +15 -0
  17. package/dist/utils/read-module-specifiers.d.ts +8 -0
  18. package/dist/utils/read-module-specifiers.js +23 -0
  19. package/dist/utils/read-tsconfig-out-dir.d.ts +5 -0
  20. package/dist/utils/read-tsconfig-out-dir.js +12 -0
  21. package/dist/utils/resolve-deploy-target.d.ts +7 -0
  22. package/dist/utils/resolve-deploy-target.js +15 -7
  23. package/dist/utils/serialize-inspector-state.d.ts +5 -0
  24. package/dist/utils/serialize-inspector-state.js +8 -0
  25. package/dist/visit.js +4 -0
  26. package/package.json +16 -6
  27. package/run-tests.sh +21 -6
  28. package/src/add/add-addon-bans.ts +0 -85
  29. package/src/add/add-agent-scorer.test.ts +0 -197
  30. package/src/add/add-agent-scorer.ts +0 -83
  31. package/src/add/add-agent.test.ts +0 -87
  32. package/src/add/add-agent.ts +0 -638
  33. package/src/add/add-approval-description.ts +0 -76
  34. package/src/add/add-auth.test.ts +0 -791
  35. package/src/add/add-auth.ts +0 -424
  36. package/src/add/add-channel.ts +0 -778
  37. package/src/add/add-cli-renderers.test.ts +0 -74
  38. package/src/add/add-cli.ts +0 -1006
  39. package/src/add/add-credential.ts +0 -186
  40. package/src/add/add-feature.test.ts +0 -306
  41. package/src/add/add-feature.ts +0 -253
  42. package/src/add/add-file-extends-core-type.ts +0 -66
  43. package/src/add/add-file-with-config.ts +0 -45
  44. package/src/add/add-file-with-factory.test.ts +0 -134
  45. package/src/add/add-file-with-factory.ts +0 -288
  46. package/src/add/add-functions.test.ts +0 -743
  47. package/src/add/add-functions.ts +0 -1548
  48. package/src/add/add-gateway.ts +0 -143
  49. package/src/add/add-http-route-ref.test.ts +0 -149
  50. package/src/add/add-http-route.ts +0 -530
  51. package/src/add/add-http-routes.ts +0 -471
  52. package/src/add/add-keyed-wiring.ts +0 -180
  53. package/src/add/add-mcp-prompt.ts +0 -157
  54. package/src/add/add-mcp-resource.ts +0 -175
  55. package/src/add/add-middleware.test.ts +0 -196
  56. package/src/add/add-middleware.ts +0 -879
  57. package/src/add/add-permission-auth.test.ts +0 -59
  58. package/src/add/add-permission.ts +0 -311
  59. package/src/add/add-personas.test.ts +0 -406
  60. package/src/add/add-personas.ts +0 -287
  61. package/src/add/add-queue-worker.ts +0 -117
  62. package/src/add/add-rpc-invocations.test.ts +0 -287
  63. package/src/add/add-rpc-invocations.ts +0 -221
  64. package/src/add/add-scenario-step.test.ts +0 -509
  65. package/src/add/add-schedule.ts +0 -120
  66. package/src/add/add-scope.test.ts +0 -419
  67. package/src/add/add-scope.ts +0 -221
  68. package/src/add/add-secret.ts +0 -10
  69. package/src/add/add-subject-scenario-steps.test.ts +0 -161
  70. package/src/add/add-system-role.test.ts +0 -297
  71. package/src/add/add-system-role.ts +0 -162
  72. package/src/add/add-trigger.ts +0 -165
  73. package/src/add/add-variable.ts +0 -10
  74. package/src/add/add-wire-addon.test.ts +0 -185
  75. package/src/add/add-wire-addon.ts +0 -146
  76. package/src/add/add-wire-remote-addon.ts +0 -80
  77. package/src/add/add-workflow-edge-cases.test.ts +0 -201
  78. package/src/add/add-workflow-fanout.test.ts +0 -166
  79. package/src/add/add-workflow-graph-foreach.test.ts +0 -174
  80. package/src/add/add-workflow-graph-input.test.ts +0 -94
  81. package/src/add/add-workflow-graph-notes.test.ts +0 -74
  82. package/src/add/add-workflow-graph.ts +0 -644
  83. package/src/add/add-workflow-on-error.test.ts +0 -118
  84. package/src/add/add-workflow-return-switch.test.ts +0 -121
  85. package/src/add/add-workflow-silent-drops.test.ts +0 -261
  86. package/src/add/add-workflow-sleep-expression.test.ts +0 -96
  87. package/src/add/add-workflow.test.ts +0 -155
  88. package/src/add/add-workflow.ts +0 -482
  89. package/src/add/addon-bans.test.ts +0 -121
  90. package/src/add/addon-contracts.test.ts +0 -221
  91. package/src/add/allow-escape-hatches.test.ts +0 -144
  92. package/src/add/audit-meta.test.ts +0 -75
  93. package/src/add/classified-sink-check.test.ts +0 -347
  94. package/src/add/config-value-metadata.test.ts +0 -263
  95. package/src/add/dynamic-import-check.test.ts +0 -119
  96. package/src/add/expect-eventually-scenario-only.test.ts +0 -108
  97. package/src/add/function-body-span.test.ts +0 -96
  98. package/src/add/inline-wiring-function.test.ts +0 -104
  99. package/src/add/pii-check.test.ts +0 -258
  100. package/src/add/rpc-type-cast.test.ts +0 -123
  101. package/src/add/scenario-instrumentation.test.ts +0 -89
  102. package/src/add/scenario-instrumentation.ts +0 -42
  103. package/src/add/scenario-marker.test.ts +0 -89
  104. package/src/add/scenario-not-extractable.test.ts +0 -159
  105. package/src/add/scenario-services.test.ts +0 -103
  106. package/src/add/scenario-skip.test.ts +0 -83
  107. package/src/add/validate-workflow-graph-addons.test.ts +0 -102
  108. package/src/add/wire-name-literal.test.ts +0 -117
  109. package/src/error-codes-emitted.test.ts +0 -76
  110. package/src/error-codes.ts +0 -145
  111. package/src/index.ts +0 -66
  112. package/src/inspector.ts +0 -575
  113. package/src/schema-generator.ts +0 -1
  114. package/src/source-file-cache.ts +0 -73
  115. package/src/tsconfig-paths.test.ts +0 -90
  116. package/src/types-map.ts +0 -141
  117. package/src/types.ts +0 -775
  118. package/src/utils/annotate-http-route-auth.test.ts +0 -161
  119. package/src/utils/annotate-http-route-auth.ts +0 -53
  120. package/src/utils/check-classified-sinks.ts +0 -215
  121. package/src/utils/check-pii-output.ts +0 -120
  122. package/src/utils/compute-diagnostics.test.ts +0 -106
  123. package/src/utils/compute-required-schemas.ts +0 -48
  124. package/src/utils/contract-hashes.test.ts +0 -553
  125. package/src/utils/contract-hashes.ts +0 -387
  126. package/src/utils/custom-types-generator.test.ts +0 -124
  127. package/src/utils/custom-types-generator.ts +0 -150
  128. package/src/utils/detect-schema-vendor.test.ts +0 -123
  129. package/src/utils/detect-schema-vendor.ts +0 -120
  130. package/src/utils/does-type-extend-core-type.ts +0 -53
  131. package/src/utils/ensure-function-metadata.ts +0 -385
  132. package/src/utils/extract-function-name.ts +0 -612
  133. package/src/utils/extract-function-node.ts +0 -70
  134. package/src/utils/extract-node-value.test.ts +0 -117
  135. package/src/utils/extract-node-value.ts +0 -172
  136. package/src/utils/extract-secret-usage.test.ts +0 -81
  137. package/src/utils/extract-secret-usage.ts +0 -73
  138. package/src/utils/extract-services.ts +0 -70
  139. package/src/utils/extract-surface-usage.test.ts +0 -147
  140. package/src/utils/extract-surface-usage.ts +0 -121
  141. package/src/utils/filter-inspector-state.test.ts +0 -2232
  142. package/src/utils/filter-inspector-state.ts +0 -1298
  143. package/src/utils/filter-utils.test.ts +0 -843
  144. package/src/utils/filter-utils.ts +0 -161
  145. package/src/utils/find-root-dir.ts +0 -68
  146. package/src/utils/find-zod-transform.test.ts +0 -70
  147. package/src/utils/find-zod-transform.ts +0 -103
  148. package/src/utils/get-exported-variable-name.ts +0 -48
  149. package/src/utils/get-files-and-methods.ts +0 -157
  150. package/src/utils/get-property-value.test.ts +0 -141
  151. package/src/utils/get-property-value.ts +0 -331
  152. package/src/utils/hash.ts +0 -26
  153. package/src/utils/literal-properties.ts +0 -97
  154. package/src/utils/load-addon-functions-meta.test.ts +0 -157
  155. package/src/utils/load-addon-functions-meta.ts +0 -508
  156. package/src/utils/load-addon-scopes.test.ts +0 -138
  157. package/src/utils/middleware.test.ts +0 -204
  158. package/src/utils/middleware.ts +0 -303
  159. package/src/utils/nested-project-filter.test.ts +0 -53
  160. package/src/utils/nested-project-filter.ts +0 -28
  161. package/src/utils/permissions-shorthand.test.ts +0 -79
  162. package/src/utils/permissions.test.ts +0 -125
  163. package/src/utils/permissions.ts +0 -129
  164. package/src/utils/post-process.test.ts +0 -1094
  165. package/src/utils/post-process.ts +0 -1604
  166. package/src/utils/resolve-addon-package.ts +0 -106
  167. package/src/utils/resolve-core-type.test.ts +0 -142
  168. package/src/utils/resolve-core-type.ts +0 -35
  169. package/src/utils/resolve-deploy-target.test.ts +0 -135
  170. package/src/utils/resolve-deploy-target.ts +0 -65
  171. package/src/utils/resolve-function-meta.ts +0 -25
  172. package/src/utils/resolve-function-types.ts +0 -42
  173. package/src/utils/resolve-identifier.ts +0 -46
  174. package/src/utils/resolve-ref-contract.ts +0 -71
  175. package/src/utils/resolve-versions.test.ts +0 -499
  176. package/src/utils/resolve-versions.ts +0 -228
  177. package/src/utils/schema-cache.test.ts +0 -124
  178. package/src/utils/schema-generator.test.ts +0 -272
  179. package/src/utils/schema-generator.ts +0 -780
  180. package/src/utils/secret-alias-services.test.ts +0 -146
  181. package/src/utils/secret-alias-services.ts +0 -58
  182. package/src/utils/serialize-inspector-state.ts +0 -742
  183. package/src/utils/serialize-mcp-json.ts +0 -150
  184. package/src/utils/serialize-middleware-groups-meta.ts +0 -36
  185. package/src/utils/serialize-openapi-json.ts +0 -277
  186. package/src/utils/serialize-permissions-groups-meta.ts +0 -7
  187. package/src/utils/single-declaration.ts +0 -57
  188. package/src/utils/type-utils.ts +0 -145
  189. package/src/utils/validate-auth-sessionless.ts +0 -30
  190. package/src/utils/validate-exposed-functions-gated.test.ts +0 -230
  191. package/src/utils/validate-exposed-functions-gated.ts +0 -103
  192. package/src/utils/validate-tags-resolve-to-middleware.test.ts +0 -108
  193. package/src/utils/validate-tags-resolve-to-middleware.ts +0 -48
  194. package/src/utils/workflow/derive-workflow-plan.test.ts +0 -178
  195. package/src/utils/workflow/derive-workflow-plan.ts +0 -117
  196. package/src/utils/workflow/dsl/deserialize-dsl-workflow.ts +0 -1465
  197. package/src/utils/workflow/dsl/deserialize-fanout-body.test.ts +0 -71
  198. package/src/utils/workflow/dsl/deserialize-fanout-fidelity.test.ts +0 -99
  199. package/src/utils/workflow/dsl/deserialize-graph-next.test.ts +0 -161
  200. package/src/utils/workflow/dsl/deserialize-roundtrip-bindings.test.ts +0 -121
  201. package/src/utils/workflow/dsl/deserialize-roundtrip-values.test.ts +0 -116
  202. package/src/utils/workflow/dsl/deserialize-roundtrip.test.ts +0 -145
  203. package/src/utils/workflow/dsl/extract-approval-policy.test.ts +0 -71
  204. package/src/utils/workflow/dsl/extract-dsl-workflow.ts +0 -2254
  205. package/src/utils/workflow/dsl/index.ts +0 -11
  206. package/src/utils/workflow/dsl/patterns.ts +0 -440
  207. package/src/utils/workflow/dsl/validation.ts +0 -203
  208. package/src/utils/workflow/graph/convert-dsl-to-graph-skip.test.ts +0 -35
  209. package/src/utils/workflow/graph/convert-dsl-to-graph.ts +0 -543
  210. package/src/utils/workflow/graph/fanout-node-identity.test.ts +0 -105
  211. package/src/utils/workflow/graph/finalize-workflow-wires.ts +0 -310
  212. package/src/utils/workflow/graph/finalize-workflows.test.ts +0 -50
  213. package/src/utils/workflow/graph/finalize-workflows.ts +0 -130
  214. package/src/utils/workflow/graph/index.ts +0 -28
  215. package/src/utils/workflow/graph/serialize-workflow-graph.ts +0 -240
  216. package/src/utils/workflow/graph/workflow-graph.types.ts +0 -281
  217. package/src/visit.ts +0 -181
  218. package/tsconfig.json +0 -19
  219. package/tsconfig.tsbuildinfo +0 -1
@@ -1,742 +0,0 @@
1
- import type { SecretUsage } from './extract-secret-usage.js'
2
- import type { JSONValue } from '@pikku/core/utils'
3
- import type {
4
- InspectorDiagnostic,
5
- InspectorFeature,
6
- InspectorState,
7
- } from '../types.js'
8
- import { TypesMap } from '../types-map.js'
9
-
10
- /**
11
- * Serializable version of InspectorState that can be saved to JSON
12
- * Omits typesLookup (contains non-serializable ts.Type objects) and converts Maps/Sets to arrays
13
- */
14
- export interface SerializableInspectorState {
15
- rootDir: string
16
- singletonServicesTypeImportMap: Array<
17
- [
18
- string,
19
- { variable: string; type: string | null; typePath: string | null }[],
20
- ]
21
- >
22
- wireServicesTypeImportMap: Array<
23
- [
24
- string,
25
- { variable: string; type: string | null; typePath: string | null }[],
26
- ]
27
- >
28
- userSessionTypeImportMap: Array<
29
- [
30
- string,
31
- { variable: string; type: string | null; typePath: string | null }[],
32
- ]
33
- >
34
- configTypeImportMap: Array<
35
- [
36
- string,
37
- { variable: string; type: string | null; typePath: string | null }[],
38
- ]
39
- >
40
- singletonServicesFactories: Array<
41
- [
42
- string,
43
- { variable: string; type: string | null; typePath: string | null }[],
44
- ]
45
- >
46
- wireServicesFactories: Array<
47
- [
48
- string,
49
- { variable: string; type: string | null; typePath: string | null }[],
50
- ]
51
- >
52
- wireServicesMeta: Array<[string, string[]]>
53
- addonRequiredParentServices: string[]
54
- addonCreatedServices: string[]
55
- addonServicesFactorySeen: boolean
56
- addonServerlessIncompatible: Array<[string, string[]]>
57
- configFactories: Array<
58
- [
59
- string,
60
- { variable: string; type: string | null; typePath: string | null }[],
61
- ]
62
- >
63
- serverLifecycleFactories: Array<
64
- [
65
- string,
66
- { variable: string; type: string | null; typePath: string | null }[],
67
- ]
68
- >
69
- filesAndMethods: InspectorState['filesAndMethods']
70
- filesAndMethodsErrors: Array<
71
- [
72
- string,
73
- Array<
74
- [
75
- string,
76
- { variable: string; type: string | null; typePath: string | null }[],
77
- ]
78
- >,
79
- ]
80
- >
81
- schemaLookup: Array<
82
- [
83
- string,
84
- {
85
- variableName: string
86
- sourceFile: string
87
- vendor?: 'zod' | 'valibot' | 'arktype' | 'effect' | 'unknown'
88
- },
89
- ]
90
- >
91
- schemas: Record<string, JSONValue>
92
- functions: {
93
- typesMap: {
94
- map: Array<[string, { originalName: string; path: string | null }]>
95
- customTypes: Array<[string, { type: string; references: string[] }]>
96
- }
97
- meta: InspectorState['functions']['meta']
98
- files: Array<[string, { path: string; exportedName: string }]>
99
- approvalDescriptions: InspectorState['functions']['approvalDescriptions']
100
- }
101
- http: {
102
- metaInputTypes: Array<
103
- [
104
- string,
105
- {
106
- query: string[] | undefined
107
- params: string[] | undefined
108
- body: string[] | undefined
109
- },
110
- ]
111
- >
112
- meta: InspectorState['http']['meta']
113
- files: string[]
114
- routeMiddleware: Array<
115
- [
116
- string,
117
- InspectorState['http']['routeMiddleware'] extends Map<string, infer V>
118
- ? V
119
- : never,
120
- ]
121
- >
122
- }
123
- channels: {
124
- files: string[]
125
- meta: InspectorState['channels']['meta']
126
- }
127
- gateways: {
128
- meta: InspectorState['gateways']['meta']
129
- files: string[]
130
- }
131
- triggers: {
132
- meta: InspectorState['triggers']['meta']
133
- sourceMeta: InspectorState['triggers']['sourceMeta']
134
- files: string[]
135
- }
136
- scheduledTasks: {
137
- meta: InspectorState['scheduledTasks']['meta']
138
- files: string[]
139
- }
140
- queueWorkers: {
141
- meta: InspectorState['queueWorkers']['meta']
142
- files: string[]
143
- }
144
- workflows: {
145
- meta: InspectorState['workflows']['meta']
146
- files: Array<[string, { path: string; exportedName: string }]>
147
- graphMeta: InspectorState['workflows']['graphMeta']
148
- graphFiles: Array<[string, { path: string; exportedName: string }]>
149
- featureFiles: Array<[string, InspectorFeature]>
150
- invokedWorkflows: string[]
151
- }
152
- rpc: {
153
- internalMeta: InspectorState['rpc']['internalMeta']
154
- internalFiles: Array<[string, { path: string; exportedName: string }]>
155
- exposedMeta: InspectorState['rpc']['exposedMeta']
156
- exposedFiles: Array<[string, { path: string; exportedName: string }]>
157
- remoteMeta: InspectorState['rpc']['remoteMeta']
158
- remoteFiles: Array<[string, { path: string; exportedName: string }]>
159
- invokedFunctions: string[]
160
- invokedFunctionsByFile?: Array<[string, string[]]>
161
- usedAddons: string[]
162
- wireAddonDeclarations: Array<
163
- [
164
- string,
165
- {
166
- package: string
167
- rpcEndpoint?: string
168
- remote?: boolean
169
- hasAuth?: boolean
170
- authCredentialId?: string
171
- authSecretId?: string
172
- secretOverrides?: Record<string, string>
173
- variableOverrides?: Record<string, string>
174
- credentialOverrides?: Record<string, string>
175
- secretGrants?: string[]
176
- credentialGrants?: string[]
177
- globalSecrets?: string
178
- globalCredentials?: string
179
- },
180
- ]
181
- >
182
- wireAddonFiles: string[]
183
- }
184
- mcpEndpoints: {
185
- resourcesMeta: InspectorState['mcpEndpoints']['resourcesMeta']
186
- toolsMeta: InspectorState['mcpEndpoints']['toolsMeta']
187
- promptsMeta: InspectorState['mcpEndpoints']['promptsMeta']
188
- files: string[]
189
- }
190
- agents: {
191
- invokedAgentsByFile?: Array<[string, string[]]>
192
- agentsMeta: InspectorState['agents']['agentsMeta']
193
- files: [string, { path: string; exportedName: string }][]
194
- }
195
- scorers: {
196
- scorersMeta: InspectorState['scorers']['scorersMeta']
197
- files: [string, { path: string; exportedName: string }][]
198
- }
199
- cli: {
200
- meta: InspectorState['cli']['meta']
201
- files: string[]
202
- }
203
- nodes: {
204
- meta: InspectorState['nodes']['meta']
205
- files: string[]
206
- }
207
- auth: {
208
- providers: string[]
209
- plugins: string[]
210
- files: string[]
211
- definition: InspectorState['auth']['definition']
212
- }
213
- secrets: {
214
- definitions: InspectorState['secrets']['definitions']
215
- files: string[]
216
- usage: Record<string, SecretUsage>
217
- }
218
- surfaceUsage: InspectorState['surfaceUsage']
219
- credentials: {
220
- definitions: InspectorState['credentials']['definitions']
221
- files: string[]
222
- }
223
- scopes: {
224
- definitions: InspectorState['scopes']['definitions']
225
- files: string[]
226
- }
227
- systemRoles: {
228
- definitions: InspectorState['systemRoles']['definitions']
229
- files: string[]
230
- }
231
- personas: {
232
- definitions: InspectorState['personas']['definitions']
233
- files: string[]
234
- }
235
- variables: {
236
- definitions: InspectorState['variables']['definitions']
237
- files: string[]
238
- }
239
- manifest: InspectorState['manifest']
240
- middleware: {
241
- definitions: InspectorState['middleware']['definitions']
242
- instances: InspectorState['middleware']['instances']
243
- tagMiddleware: Array<
244
- [
245
- string,
246
- InspectorState['middleware']['tagMiddleware'] extends Map<
247
- string,
248
- infer V
249
- >
250
- ? V
251
- : never,
252
- ]
253
- >
254
- }
255
- channelMiddleware: {
256
- definitions: InspectorState['channelMiddleware']['definitions']
257
- instances: InspectorState['channelMiddleware']['instances']
258
- tagMiddleware: Array<
259
- [
260
- string,
261
- InspectorState['channelMiddleware']['tagMiddleware'] extends Map<
262
- string,
263
- infer V
264
- >
265
- ? V
266
- : never,
267
- ]
268
- >
269
- }
270
- agentMiddleware: {
271
- definitions: InspectorState['agentMiddleware']['definitions']
272
- }
273
- permissions: {
274
- definitions: InspectorState['permissions']['definitions']
275
- instances: InspectorState['permissions']['instances']
276
- }
277
- serviceAggregation: {
278
- requiredServices: string[]
279
- usedFunctions: string[]
280
- usedMiddleware: string[]
281
- usedPermissions: string[]
282
- allSingletonServices: string[]
283
- allWireServices: string[]
284
- }
285
- resolvedIOTypes: Record<string, { inputType: string; outputType: string }>
286
- middlewareGroupsMeta: InspectorState['middlewareGroupsMeta']
287
- permissionsGroupsMeta: InspectorState['permissionsGroupsMeta']
288
- requiredSchemas: string[]
289
- openAPISpec: Record<string, any> | null
290
- diagnostics: InspectorDiagnostic[]
291
- addonFunctions: InspectorState['addonFunctions']
292
- exportedContracts: InspectorState['exportedContracts']
293
- }
294
-
295
- /**
296
- * Serializes InspectorState to a JSON-compatible format
297
- * Omits typesLookup (not needed for filtering/generation) and converts Maps/Sets to arrays
298
- */
299
- export function serializeInspectorState(
300
- state: InspectorState
301
- ): SerializableInspectorState {
302
- // Helper to serialize TypesMap
303
- const serializeTypesMap = (
304
- typesMap: TypesMap
305
- ): {
306
- map: Array<[string, { originalName: string; path: string | null }]>
307
- customTypes: Array<[string, { type: string; references: string[] }]>
308
- } => {
309
- // Access private map via type assertion
310
- const mapEntries: Array<
311
- [string, { originalName: string; path: string | null }]
312
- > = Array.from((typesMap as any).map.entries())
313
- const customTypesEntries: Array<
314
- [string, { type: string; references: string[] }]
315
- > = Array.from(typesMap.customTypes.entries())
316
-
317
- return {
318
- map: mapEntries,
319
- customTypes: customTypesEntries,
320
- }
321
- }
322
-
323
- return {
324
- rootDir: state.rootDir,
325
- singletonServicesTypeImportMap: Array.from(
326
- state.singletonServicesTypeImportMap.entries()
327
- ),
328
- wireServicesTypeImportMap: Array.from(
329
- state.wireServicesTypeImportMap.entries()
330
- ),
331
- userSessionTypeImportMap: Array.from(
332
- state.userSessionTypeImportMap.entries()
333
- ),
334
- configTypeImportMap: Array.from(state.configTypeImportMap.entries()),
335
- singletonServicesFactories: Array.from(
336
- state.singletonServicesFactories.entries()
337
- ),
338
- wireServicesFactories: Array.from(state.wireServicesFactories.entries()),
339
- wireServicesMeta: Array.from(state.wireServicesMeta.entries()),
340
- addonRequiredParentServices: state.addonRequiredParentServices,
341
- addonCreatedServices: state.addonCreatedServices,
342
- addonServicesFactorySeen: state.addonServicesFactorySeen,
343
- addonServerlessIncompatible: Array.from(
344
- state.addonServerlessIncompatible.entries()
345
- ),
346
- configFactories: Array.from(state.configFactories.entries()),
347
- serverLifecycleFactories: Array.from(
348
- state.serverLifecycleFactories.entries()
349
- ),
350
- filesAndMethods: state.filesAndMethods,
351
- filesAndMethodsErrors: Array.from(
352
- state.filesAndMethodsErrors.entries()
353
- ).map(([key, mapValue]) => [key, Array.from(mapValue.entries())] as const),
354
- schemaLookup: Array.from(state.schemaLookup.entries()),
355
- schemas: state.schemas,
356
- functions: {
357
- typesMap: serializeTypesMap(state.functions.typesMap),
358
- meta: state.functions.meta,
359
- files: Array.from(state.functions.files.entries()),
360
- approvalDescriptions: state.functions.approvalDescriptions,
361
- },
362
- http: {
363
- metaInputTypes: Array.from(state.http.metaInputTypes.entries()),
364
- meta: state.http.meta,
365
- files: Array.from(state.http.files),
366
- routeMiddleware: Array.from(state.http.routeMiddleware.entries()),
367
- },
368
- channels: {
369
- files: Array.from(state.channels.files),
370
- meta: state.channels.meta,
371
- },
372
- gateways: {
373
- meta: state.gateways.meta,
374
- files: Array.from(state.gateways.files),
375
- },
376
- triggers: {
377
- meta: state.triggers.meta,
378
- sourceMeta: state.triggers.sourceMeta,
379
- files: Array.from(state.triggers.files),
380
- },
381
- scheduledTasks: {
382
- meta: state.scheduledTasks.meta,
383
- files: Array.from(state.scheduledTasks.files),
384
- },
385
- queueWorkers: {
386
- meta: state.queueWorkers.meta,
387
- files: Array.from(state.queueWorkers.files),
388
- },
389
- workflows: {
390
- meta: state.workflows.meta,
391
- files: Array.from(state.workflows.files.entries()),
392
- graphMeta: state.workflows.graphMeta,
393
- graphFiles: Array.from(state.workflows.graphFiles.entries()),
394
- featureFiles: Array.from(state.workflows.featureFiles.entries()),
395
- invokedWorkflows: Array.from(state.workflows.invokedWorkflows),
396
- },
397
- rpc: {
398
- internalMeta: state.rpc.internalMeta,
399
- internalFiles: Array.from(state.rpc.internalFiles.entries()),
400
- exposedMeta: state.rpc.exposedMeta,
401
- exposedFiles: Array.from(state.rpc.exposedFiles.entries()),
402
- remoteMeta: state.rpc.remoteMeta,
403
- remoteFiles: Array.from(state.rpc.remoteFiles.entries()),
404
- invokedFunctions: Array.from(state.rpc.invokedFunctions),
405
- invokedFunctionsByFile: Array.from(
406
- (
407
- state.rpc.invokedFunctionsByFile ?? new Map<string, Set<string>>()
408
- ).entries()
409
- ).map(([file, fns]): [string, string[]] => [file, Array.from(fns)]),
410
- usedAddons: Array.from(state.rpc.usedAddons),
411
- wireAddonDeclarations: Array.from(
412
- state.rpc.wireAddonDeclarations.entries()
413
- ),
414
- wireAddonFiles: Array.from(state.rpc.wireAddonFiles),
415
- },
416
- mcpEndpoints: {
417
- resourcesMeta: state.mcpEndpoints.resourcesMeta,
418
- toolsMeta: state.mcpEndpoints.toolsMeta,
419
- promptsMeta: state.mcpEndpoints.promptsMeta,
420
- files: Array.from(state.mcpEndpoints.files),
421
- },
422
- agents: {
423
- agentsMeta: state.agents?.agentsMeta ?? {},
424
- files: Array.from(state.agents?.files?.entries() ?? []),
425
- invokedAgentsByFile: Array.from(
426
- (
427
- state.agents?.invokedAgentsByFile ?? new Map<string, Set<string>>()
428
- ).entries()
429
- ).map(([file, agents]): [string, string[]] => [file, Array.from(agents)]),
430
- },
431
- scorers: {
432
- scorersMeta: state.scorers?.scorersMeta ?? {},
433
- files: Array.from(state.scorers?.files?.entries() ?? []),
434
- },
435
- cli: {
436
- meta: state.cli.meta,
437
- files: Array.from(state.cli.files),
438
- },
439
- nodes: {
440
- meta: state.nodes.meta,
441
- files: Array.from(state.nodes.files),
442
- },
443
- auth: {
444
- providers: state.auth.providers,
445
- plugins: state.auth.plugins,
446
- files: Array.from(state.auth.files),
447
- definition: state.auth.definition,
448
- },
449
- secrets: {
450
- definitions: state.secrets.definitions,
451
- files: Array.from(state.secrets.files),
452
- usage: Object.fromEntries(state.secrets.usage),
453
- },
454
- surfaceUsage: state.surfaceUsage,
455
- credentials: {
456
- definitions: state.credentials.definitions,
457
- files: Array.from(state.credentials.files),
458
- },
459
- scopes: {
460
- definitions: state.scopes.definitions,
461
- files: Array.from(state.scopes.files),
462
- },
463
- systemRoles: {
464
- definitions: state.systemRoles.definitions,
465
- files: Array.from(state.systemRoles.files),
466
- },
467
- personas: {
468
- definitions: state.personas.definitions,
469
- files: Array.from(state.personas.files),
470
- },
471
- variables: {
472
- definitions: state.variables.definitions,
473
- files: Array.from(state.variables.files),
474
- },
475
- manifest: state.manifest,
476
- middleware: {
477
- definitions: state.middleware.definitions,
478
- instances: state.middleware.instances,
479
- tagMiddleware: Array.from(state.middleware.tagMiddleware.entries()),
480
- },
481
- channelMiddleware: {
482
- definitions: state.channelMiddleware.definitions,
483
- instances: state.channelMiddleware.instances,
484
- tagMiddleware: Array.from(
485
- state.channelMiddleware.tagMiddleware.entries()
486
- ),
487
- },
488
- agentMiddleware: {
489
- definitions: state.agentMiddleware.definitions,
490
- },
491
- permissions: {
492
- definitions: state.permissions.definitions,
493
- instances: state.permissions.instances,
494
- },
495
- serviceAggregation: {
496
- requiredServices: Array.from(state.serviceAggregation.requiredServices),
497
- usedFunctions: Array.from(state.serviceAggregation.usedFunctions),
498
- usedMiddleware: Array.from(state.serviceAggregation.usedMiddleware),
499
- usedPermissions: Array.from(state.serviceAggregation.usedPermissions),
500
- allSingletonServices: state.serviceAggregation.allSingletonServices,
501
- allWireServices: state.serviceAggregation.allWireServices,
502
- },
503
- resolvedIOTypes: state.resolvedIOTypes,
504
- middlewareGroupsMeta: state.middlewareGroupsMeta,
505
- permissionsGroupsMeta: state.permissionsGroupsMeta,
506
- requiredSchemas: Array.from(state.requiredSchemas),
507
- openAPISpec: state.openAPISpec,
508
- diagnostics: state.diagnostics,
509
- addonFunctions: state.addonFunctions,
510
- exportedContracts: state.exportedContracts,
511
- }
512
- }
513
-
514
- /**
515
- * Deserializes JSON data back to InspectorState
516
- * Creates a partial state suitable for filtering/generation (without typesLookup)
517
- */
518
- export function deserializeInspectorState(
519
- data: SerializableInspectorState
520
- ): Omit<InspectorState, 'typesLookup' | 'schemaLookup'> & {
521
- schemaLookup: Map<
522
- string,
523
- {
524
- variableName: string
525
- sourceFile: string
526
- vendor?: 'zod' | 'valibot' | 'arktype' | 'effect' | 'unknown'
527
- }
528
- >
529
- } {
530
- // Helper to deserialize TypesMap
531
- const deserializeTypesMap = (
532
- serialized: SerializableInspectorState['functions']['typesMap']
533
- ): TypesMap => {
534
- const typesMap = new TypesMap()
535
-
536
- // Restore private map
537
- ;(typesMap as any).map = new Map(serialized.map)
538
-
539
- // Restore public customTypes
540
- typesMap.customTypes = new Map(serialized.customTypes)
541
-
542
- return typesMap
543
- }
544
-
545
- return {
546
- rootDir: data.rootDir,
547
- singletonServicesTypeImportMap: new Map(
548
- data.singletonServicesTypeImportMap
549
- ),
550
- wireServicesTypeImportMap: new Map(data.wireServicesTypeImportMap),
551
- userSessionTypeImportMap: new Map(data.userSessionTypeImportMap),
552
- configTypeImportMap: new Map(data.configTypeImportMap),
553
- singletonServicesFactories: new Map(data.singletonServicesFactories),
554
- wireServicesFactories: new Map(data.wireServicesFactories),
555
- wireServicesMeta: new Map(data.wireServicesMeta),
556
- addonRequiredParentServices: data.addonRequiredParentServices || [],
557
- addonCreatedServices: data.addonCreatedServices || [],
558
- addonServicesFactorySeen: data.addonServicesFactorySeen ?? false,
559
- addonServerlessIncompatible: new Map(
560
- data.addonServerlessIncompatible || []
561
- ),
562
- configFactories: new Map(data.configFactories),
563
- serverLifecycleFactories: new Map(data.serverLifecycleFactories),
564
- filesAndMethods: data.filesAndMethods,
565
- filesAndMethodsErrors: new Map(
566
- data.filesAndMethodsErrors.map(([key, entries]) => [
567
- key,
568
- new Map(entries),
569
- ])
570
- ),
571
- schemaLookup: new Map(data.schemaLookup || []),
572
- schemas: data.schemas || {},
573
- functions: {
574
- typesMap: deserializeTypesMap(data.functions.typesMap),
575
- meta: data.functions.meta,
576
- files: new Map(data.functions.files),
577
- approvalDescriptions: (data.functions as any).approvalDescriptions || {},
578
- dynamicImportIds: new Set(),
579
- },
580
- http: {
581
- metaInputTypes: new Map(data.http.metaInputTypes),
582
- meta: data.http.meta,
583
- files: new Set(data.http.files),
584
- routeMiddleware: new Map(data.http.routeMiddleware),
585
- },
586
- channels: {
587
- files: new Set(data.channels.files),
588
- meta: data.channels.meta,
589
- },
590
- gateways: {
591
- meta: data.gateways?.meta ?? {},
592
- files: new Set(data.gateways?.files ?? []),
593
- },
594
- triggers: {
595
- meta: data.triggers?.meta ?? {},
596
- sourceMeta: data.triggers?.sourceMeta ?? {},
597
- files: new Set(data.triggers?.files ?? []),
598
- },
599
- scheduledTasks: {
600
- meta: data.scheduledTasks.meta,
601
- files: new Set(data.scheduledTasks.files),
602
- },
603
- queueWorkers: {
604
- meta: data.queueWorkers.meta,
605
- files: new Set(data.queueWorkers.files),
606
- },
607
- workflows: {
608
- meta: data.workflows.meta,
609
- files: new Map(data.workflows.files),
610
- graphMeta: data.workflows.graphMeta || {},
611
- graphFiles: new Map(data.workflows.graphFiles || []),
612
- featureFiles: new Map(data.workflows.featureFiles || []),
613
- invokedWorkflows: new Set(data.workflows.invokedWorkflows || []),
614
- },
615
- rpc: {
616
- internalMeta: data.rpc.internalMeta,
617
- internalFiles: new Map(data.rpc.internalFiles),
618
- exposedMeta: data.rpc.exposedMeta,
619
- exposedFiles: new Map(data.rpc.exposedFiles),
620
- remoteMeta: data.rpc.remoteMeta ?? {},
621
- remoteFiles: new Map(data.rpc.remoteFiles ?? []),
622
- invokedFunctions: new Set(data.rpc.invokedFunctions),
623
- invokedFunctionsByFile: new Map(
624
- (data.rpc.invokedFunctionsByFile || []).map(
625
- ([file, fns]): [string, Set<string>] => [file, new Set(fns)]
626
- )
627
- ),
628
- usedAddons: new Set(data.rpc.usedAddons || []),
629
- wireAddonDeclarations: new Map(data.rpc.wireAddonDeclarations || []),
630
- wireAddonFiles: new Set(data.rpc.wireAddonFiles || []),
631
- },
632
- mcpEndpoints: {
633
- resourcesMeta: data.mcpEndpoints.resourcesMeta,
634
- toolsMeta: data.mcpEndpoints.toolsMeta,
635
- promptsMeta: data.mcpEndpoints.promptsMeta,
636
- files: new Set(data.mcpEndpoints.files),
637
- },
638
- agents: {
639
- agentsMeta: data.agents?.agentsMeta || {},
640
- files: new Map(data.agents?.files || []),
641
- invokedAgentsByFile: new Map(
642
- (data.agents?.invokedAgentsByFile || []).map(
643
- ([file, agents]): [string, Set<string>] => [file, new Set(agents)]
644
- )
645
- ),
646
- },
647
- scorers: {
648
- scorersMeta: data.scorers?.scorersMeta || {},
649
- files: new Map(data.scorers?.files || []),
650
- },
651
- cli: {
652
- meta: data.cli.meta,
653
- files: new Set(data.cli.files),
654
- },
655
- nodes: {
656
- meta: data.nodes?.meta || {},
657
- files: new Set(data.nodes?.files || []),
658
- },
659
- auth: {
660
- providers: data.auth?.providers || [],
661
- plugins: data.auth?.plugins || [],
662
- files: new Set(data.auth?.files || []),
663
- definition: data.auth?.definition || null,
664
- },
665
- secrets: {
666
- definitions: data.secrets?.definitions || [],
667
- files: new Set(data.secrets?.files || []),
668
- usage: new Map(Object.entries(data.secrets?.usage || {})),
669
- },
670
- surfaceUsage: data.surfaceUsage || {},
671
- credentials: {
672
- definitions: data.credentials?.definitions || [],
673
- files: new Set(data.credentials?.files || []),
674
- },
675
- scopes: {
676
- definitions: data.scopes?.definitions || [],
677
- files: new Set(data.scopes?.files || []),
678
- },
679
- systemRoles: {
680
- definitions: data.systemRoles?.definitions || [],
681
- files: new Set(data.systemRoles?.files || []),
682
- },
683
- personas: {
684
- definitions: data.personas?.definitions || [],
685
- files: new Set(data.personas?.files || []),
686
- },
687
- variables: {
688
- definitions: data.variables?.definitions || [],
689
- files: new Set(data.variables?.files || []),
690
- },
691
- manifest: data.manifest || { initial: null, current: null, errors: [] },
692
- middleware: {
693
- definitions: data.middleware.definitions,
694
- instances: data.middleware.instances || {},
695
- tagMiddleware: new Map(data.middleware.tagMiddleware),
696
- },
697
- channelMiddleware: {
698
- definitions: data.channelMiddleware?.definitions || {},
699
- instances: data.channelMiddleware?.instances || {},
700
- tagMiddleware: new Map(data.channelMiddleware?.tagMiddleware || []),
701
- },
702
- agentMiddleware: {
703
- definitions: data.agentMiddleware?.definitions || {},
704
- },
705
- permissions: {
706
- definitions: data.permissions.definitions,
707
- instances: data.permissions.instances || {},
708
- },
709
- serviceAggregation: {
710
- requiredServices: new Set(data.serviceAggregation.requiredServices),
711
- usedFunctions: new Set(data.serviceAggregation.usedFunctions),
712
- usedMiddleware: new Set(data.serviceAggregation.usedMiddleware),
713
- usedPermissions: new Set(data.serviceAggregation.usedPermissions),
714
- allSingletonServices: data.serviceAggregation.allSingletonServices,
715
- allWireServices: data.serviceAggregation.allWireServices,
716
- },
717
- resolvedIOTypes: data.resolvedIOTypes || {},
718
- middlewareGroupsMeta: data.middlewareGroupsMeta || {
719
- definitions: {},
720
- instances: {},
721
- httpGroups: {},
722
- tagGroups: {},
723
- channelMiddleware: { definitions: {}, instances: {}, tagGroups: {} },
724
- },
725
- permissionsGroupsMeta: data.permissionsGroupsMeta || {
726
- definitions: {},
727
- },
728
- requiredSchemas: new Set(data.requiredSchemas || []),
729
- openAPISpec: data.openAPISpec || null,
730
- diagnostics: data.diagnostics || [],
731
- addonFunctions: data.addonFunctions || {},
732
- exportedContracts: data.exportedContracts || {
733
- http: {},
734
- cli: {},
735
- channel: {},
736
- addonHttp: {},
737
- addonCli: {},
738
- addonChannel: {},
739
- },
740
- program: null,
741
- }
742
- }