@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.
Files changed (211) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/OPTIMIZATION-PLAN.md +195 -0
  3. package/dist/add/add-ai-agent.d.ts +2 -0
  4. package/dist/add/add-ai-agent.js +314 -0
  5. package/dist/add/add-channel.js +81 -61
  6. package/dist/add/add-cli.d.ts +1 -1
  7. package/dist/add/add-cli.js +42 -19
  8. package/dist/add/add-file-extends-core-type.d.ts +1 -1
  9. package/dist/add/add-file-with-config.d.ts +1 -1
  10. package/dist/add/add-file-with-factory.d.ts +1 -1
  11. package/dist/add/add-file-with-factory.js +2 -0
  12. package/dist/add/add-functions.d.ts +1 -1
  13. package/dist/add/add-functions.js +256 -82
  14. package/dist/add/add-http-route.d.ts +20 -10
  15. package/dist/add/add-http-route.js +156 -66
  16. package/dist/add/add-http-routes.d.ts +5 -0
  17. package/dist/add/add-http-routes.js +160 -0
  18. package/dist/add/add-keyed-wiring.d.ts +12 -0
  19. package/dist/add/add-keyed-wiring.js +97 -0
  20. package/dist/add/add-mcp-prompt.d.ts +1 -1
  21. package/dist/add/add-mcp-prompt.js +14 -9
  22. package/dist/add/add-mcp-resource.d.ts +1 -1
  23. package/dist/add/add-mcp-resource.js +14 -9
  24. package/dist/add/add-middleware.d.ts +1 -4
  25. package/dist/add/add-middleware.js +364 -79
  26. package/dist/add/add-permission.d.ts +1 -1
  27. package/dist/add/add-permission.js +152 -40
  28. package/dist/add/add-queue-worker.d.ts +1 -1
  29. package/dist/add/add-queue-worker.js +18 -12
  30. package/dist/add/add-rpc-invocations.d.ts +3 -3
  31. package/dist/add/add-rpc-invocations.js +24 -10
  32. package/dist/add/add-schedule.d.ts +1 -1
  33. package/dist/add/add-schedule.js +11 -5
  34. package/dist/add/add-secret.d.ts +3 -0
  35. package/dist/add/add-secret.js +82 -0
  36. package/dist/add/add-trigger.d.ts +2 -0
  37. package/dist/add/add-trigger.js +87 -0
  38. package/dist/add/add-variable.d.ts +1 -0
  39. package/dist/add/add-variable.js +8 -0
  40. package/dist/add/add-wire-addon.d.ts +7 -0
  41. package/dist/add/add-wire-addon.js +70 -0
  42. package/dist/add/add-workflow-graph.d.ts +3 -2
  43. package/dist/add/add-workflow-graph.js +143 -406
  44. package/dist/add/add-workflow.d.ts +1 -1
  45. package/dist/add/add-workflow.js +6 -4
  46. package/dist/error-codes.d.ts +15 -1
  47. package/dist/error-codes.js +20 -1
  48. package/dist/index.d.ts +9 -8
  49. package/dist/index.js +5 -4
  50. package/dist/inspector.d.ts +2 -2
  51. package/dist/inspector.js +95 -15
  52. package/dist/schema-generator.d.ts +1 -0
  53. package/dist/schema-generator.js +1 -0
  54. package/dist/types-map.js +10 -1
  55. package/dist/types.d.ts +180 -50
  56. package/dist/utils/compute-required-schemas.d.ts +4 -0
  57. package/dist/utils/compute-required-schemas.js +40 -0
  58. package/dist/utils/contract-hashes.d.ts +52 -0
  59. package/dist/utils/contract-hashes.js +269 -0
  60. package/dist/utils/custom-types-generator.d.ts +9 -0
  61. package/dist/utils/custom-types-generator.js +71 -0
  62. package/dist/utils/detect-schema-vendor.d.ts +22 -0
  63. package/dist/utils/detect-schema-vendor.js +76 -0
  64. package/dist/utils/does-type-extend-core-type.d.ts +1 -1
  65. package/dist/utils/ensure-function-metadata.d.ts +6 -3
  66. package/dist/utils/ensure-function-metadata.js +220 -6
  67. package/dist/utils/extract-function-name.d.ts +5 -16
  68. package/dist/utils/extract-function-name.js +86 -291
  69. package/dist/utils/extract-services.d.ts +2 -1
  70. package/dist/utils/extract-services.js +25 -1
  71. package/dist/utils/filter-inspector-state.d.ts +1 -1
  72. package/dist/utils/filter-inspector-state.js +107 -23
  73. package/dist/utils/filter-utils.d.ts +2 -2
  74. package/dist/utils/get-files-and-methods.d.ts +1 -1
  75. package/dist/utils/get-property-value.d.ts +6 -1
  76. package/dist/utils/get-property-value.js +28 -3
  77. package/dist/utils/hash.d.ts +2 -0
  78. package/dist/utils/hash.js +23 -0
  79. package/dist/utils/middleware.d.ts +9 -32
  80. package/dist/utils/middleware.js +80 -66
  81. package/dist/utils/permissions.d.ts +4 -4
  82. package/dist/utils/permissions.js +10 -10
  83. package/dist/utils/post-process.d.ts +11 -11
  84. package/dist/utils/post-process.js +247 -24
  85. package/dist/utils/resolve-addon-package.d.ts +16 -0
  86. package/dist/utils/resolve-addon-package.js +34 -0
  87. package/dist/utils/resolve-function-types.d.ts +6 -0
  88. package/dist/utils/resolve-function-types.js +29 -0
  89. package/dist/utils/resolve-identifier.d.ts +10 -0
  90. package/dist/utils/resolve-identifier.js +36 -0
  91. package/dist/utils/resolve-versions.d.ts +2 -0
  92. package/dist/utils/resolve-versions.js +78 -0
  93. package/dist/utils/schema-generator.d.ts +9 -0
  94. package/dist/utils/schema-generator.js +209 -0
  95. package/dist/utils/serialize-inspector-state.d.ts +70 -23
  96. package/dist/utils/serialize-inspector-state.js +98 -22
  97. package/dist/utils/serialize-mcp-json.d.ts +2 -0
  98. package/dist/utils/serialize-mcp-json.js +99 -0
  99. package/dist/utils/serialize-middleware-groups-meta.d.ts +12 -0
  100. package/dist/utils/serialize-middleware-groups-meta.js +28 -0
  101. package/dist/utils/serialize-openapi-json.d.ts +85 -0
  102. package/dist/utils/serialize-openapi-json.js +151 -0
  103. package/dist/utils/serialize-permissions-groups-meta.d.ts +6 -0
  104. package/dist/utils/serialize-permissions-groups-meta.js +31 -0
  105. package/dist/utils/validate-auth-sessionless.d.ts +3 -0
  106. package/dist/utils/validate-auth-sessionless.js +14 -0
  107. package/dist/utils/workflow/dsl/deserialize-dsl-workflow.js +34 -102
  108. package/dist/utils/workflow/dsl/extract-dsl-workflow.d.ts +1 -1
  109. package/dist/utils/workflow/dsl/extract-dsl-workflow.js +23 -4
  110. package/dist/utils/workflow/graph/convert-dsl-to-graph.js +12 -10
  111. package/dist/utils/workflow/graph/finalize-workflow-wires.d.ts +3 -0
  112. package/dist/utils/workflow/graph/finalize-workflow-wires.js +276 -0
  113. package/dist/utils/workflow/graph/finalize-workflows.d.ts +2 -0
  114. package/dist/utils/workflow/graph/finalize-workflows.js +75 -0
  115. package/dist/utils/workflow/graph/index.d.ts +2 -0
  116. package/dist/utils/workflow/graph/index.js +2 -0
  117. package/dist/utils/workflow/graph/serialize-workflow-graph.d.ts +0 -8
  118. package/dist/utils/workflow/graph/serialize-workflow-graph.js +1 -3
  119. package/dist/utils/workflow/graph/workflow-graph.types.d.ts +53 -79
  120. package/dist/utils/workflow/graph/workflow-graph.types.js +1 -1
  121. package/dist/visit.d.ts +1 -1
  122. package/dist/visit.js +13 -6
  123. package/package.json +14 -4
  124. package/src/add/add-ai-agent.ts +468 -0
  125. package/src/add/add-channel.ts +103 -79
  126. package/src/add/add-cli.ts +68 -24
  127. package/src/add/add-file-extends-core-type.ts +1 -1
  128. package/src/add/add-file-with-config.ts +1 -1
  129. package/src/add/add-file-with-factory.ts +3 -1
  130. package/src/add/add-functions.ts +349 -103
  131. package/src/add/add-http-route.ts +263 -89
  132. package/src/add/add-http-routes.ts +229 -0
  133. package/src/add/add-keyed-wiring.ts +151 -0
  134. package/src/add/add-mcp-prompt.ts +27 -16
  135. package/src/add/add-mcp-resource.ts +28 -16
  136. package/src/add/add-middleware.ts +482 -80
  137. package/src/add/add-permission.ts +199 -40
  138. package/src/add/add-queue-worker.ts +25 -20
  139. package/src/add/add-rpc-invocations.ts +28 -11
  140. package/src/add/add-schedule.ts +17 -12
  141. package/src/add/add-secret.ts +140 -0
  142. package/src/add/add-trigger.ts +154 -0
  143. package/src/add/add-variable.ts +9 -0
  144. package/src/add/add-wire-addon.ts +80 -0
  145. package/src/add/add-workflow-graph.ts +180 -522
  146. package/src/add/add-workflow.ts +7 -6
  147. package/src/error-codes.ts +25 -1
  148. package/src/index.ts +23 -13
  149. package/src/inspector.ts +139 -19
  150. package/src/schema-generator.ts +1 -0
  151. package/src/types-map.ts +12 -1
  152. package/src/types.ts +199 -69
  153. package/src/utils/compute-required-schemas.ts +48 -0
  154. package/src/utils/contract-hashes.test.ts +553 -0
  155. package/src/utils/contract-hashes.ts +386 -0
  156. package/src/utils/custom-types-generator.ts +88 -0
  157. package/src/utils/detect-schema-vendor.ts +90 -0
  158. package/src/utils/does-type-extend-core-type.ts +1 -1
  159. package/src/utils/ensure-function-metadata.ts +325 -8
  160. package/src/utils/extract-function-name.ts +101 -351
  161. package/src/utils/extract-services.ts +35 -2
  162. package/src/utils/filter-inspector-state.test.ts +37 -25
  163. package/src/utils/filter-inspector-state.ts +146 -32
  164. package/src/utils/filter-utils.test.ts +1 -1
  165. package/src/utils/filter-utils.ts +2 -2
  166. package/src/utils/get-files-and-methods.ts +1 -1
  167. package/src/utils/get-property-value.ts +42 -4
  168. package/src/utils/hash.ts +26 -0
  169. package/src/utils/middleware.test.ts +204 -0
  170. package/src/utils/middleware.ts +131 -69
  171. package/src/utils/permissions.test.ts +35 -12
  172. package/src/utils/permissions.ts +12 -12
  173. package/src/utils/post-process.ts +306 -44
  174. package/src/utils/resolve-addon-package.ts +49 -0
  175. package/src/utils/resolve-function-types.ts +42 -0
  176. package/src/utils/resolve-identifier.ts +46 -0
  177. package/src/utils/resolve-versions.test.ts +249 -0
  178. package/src/utils/resolve-versions.ts +105 -0
  179. package/src/utils/schema-generator.ts +329 -0
  180. package/src/utils/serialize-inspector-state.ts +184 -43
  181. package/src/utils/serialize-mcp-json.ts +145 -0
  182. package/src/utils/serialize-middleware-groups-meta.ts +33 -0
  183. package/src/utils/serialize-openapi-json.ts +277 -0
  184. package/src/utils/serialize-permissions-groups-meta.ts +35 -0
  185. package/src/utils/test-data/inspector-state.json +69 -66
  186. package/src/utils/validate-auth-sessionless.ts +29 -0
  187. package/src/utils/workflow/dsl/deserialize-dsl-workflow.ts +43 -119
  188. package/src/utils/workflow/dsl/extract-dsl-workflow.ts +26 -6
  189. package/src/utils/workflow/graph/convert-dsl-to-graph.ts +17 -10
  190. package/src/utils/workflow/graph/finalize-workflow-wires.ts +310 -0
  191. package/src/utils/workflow/graph/finalize-workflows.ts +100 -0
  192. package/src/utils/workflow/graph/index.ts +5 -0
  193. package/src/utils/workflow/graph/serialize-workflow-graph.ts +1 -8
  194. package/src/utils/workflow/graph/workflow-graph.types.ts +29 -78
  195. package/src/visit.ts +19 -7
  196. package/tsconfig.tsbuildinfo +1 -1
  197. package/dist/add/add-forge-credential.d.ts +0 -8
  198. package/dist/add/add-forge-credential.js +0 -77
  199. package/dist/add/add-forge-node.d.ts +0 -7
  200. package/dist/add/add-forge-node.js +0 -77
  201. package/dist/add/add-mcp-tool.d.ts +0 -2
  202. package/dist/add/add-mcp-tool.js +0 -81
  203. package/dist/utils/extract-service-metadata.d.ts +0 -19
  204. package/dist/utils/extract-service-metadata.js +0 -244
  205. package/dist/utils/write-service-metadata.d.ts +0 -13
  206. package/dist/utils/write-service-metadata.js +0 -37
  207. package/src/add/add-forge-credential.ts +0 -119
  208. package/src/add/add-forge-node.ts +0 -132
  209. package/src/add/add-mcp-tool.ts +0 -141
  210. package/src/utils/extract-service-metadata.ts +0 -353
  211. package/src/utils/write-service-metadata.ts +0 -51
@@ -0,0 +1,209 @@
1
+ import * as ts from 'typescript';
2
+ import { dirname, join, resolve } from 'path';
3
+ import { createGenerator, RootlessError } from 'ts-json-schema-generator';
4
+ import { tsImport } from 'tsx/esm/api';
5
+ import * as z from 'zod';
6
+ import { zodToTs, createAuxiliaryTypeStore } from 'zod-to-ts';
7
+ import { ErrorCode } from '../error-codes.js';
8
+ import { generateCustomTypes } from './custom-types-generator.js';
9
+ const PRIMITIVE_TYPES = new Set([
10
+ 'boolean',
11
+ 'string',
12
+ 'number',
13
+ 'null',
14
+ 'undefined',
15
+ 'void',
16
+ 'any',
17
+ 'unknown',
18
+ 'never',
19
+ ]);
20
+ function primitiveTypeToSchema(typeStr) {
21
+ const normalized = typeStr.trim();
22
+ if (normalized === 'void' ||
23
+ normalized === 'undefined' ||
24
+ normalized === 'never') {
25
+ return null;
26
+ }
27
+ if (normalized === 'boolean' ||
28
+ normalized === 'false | true' ||
29
+ normalized === 'true | false') {
30
+ return { type: 'boolean' };
31
+ }
32
+ if (normalized === 'true') {
33
+ return { const: true };
34
+ }
35
+ if (normalized === 'false') {
36
+ return { const: false };
37
+ }
38
+ if (normalized === 'string') {
39
+ return { type: 'string' };
40
+ }
41
+ if (normalized === 'number') {
42
+ return { type: 'number' };
43
+ }
44
+ if (normalized === 'null') {
45
+ return { type: 'null' };
46
+ }
47
+ return null;
48
+ }
49
+ function createProgramWithVirtualFile(tsconfig, virtualFilePath, virtualFileContent) {
50
+ const configPath = resolve(tsconfig);
51
+ const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
52
+ const basePath = dirname(configPath);
53
+ const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, basePath);
54
+ const resolvedVirtualPath = resolve(virtualFilePath);
55
+ const fileNames = [...parsedConfig.fileNames, resolvedVirtualPath];
56
+ const defaultHost = ts.createCompilerHost(parsedConfig.options);
57
+ const customHost = {
58
+ ...defaultHost,
59
+ getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
60
+ if (resolve(fileName) === resolvedVirtualPath) {
61
+ return ts.createSourceFile(fileName, virtualFileContent, languageVersionOrOptions);
62
+ }
63
+ return defaultHost.getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
64
+ },
65
+ fileExists(fileName) {
66
+ if (resolve(fileName) === resolvedVirtualPath)
67
+ return true;
68
+ return defaultHost.fileExists(fileName);
69
+ },
70
+ readFile(fileName) {
71
+ if (resolve(fileName) === resolvedVirtualPath)
72
+ return virtualFileContent;
73
+ return defaultHost.readFile(fileName);
74
+ },
75
+ };
76
+ return ts.createProgram(fileNames, parsedConfig.options, customHost);
77
+ }
78
+ function generateTSSchemas(logger, tsconfig, customTypesContent, typesMap, functionMeta, httpWiringsMeta, additionalTypes, additionalProperties = false, schemaLookup) {
79
+ const schemasSet = new Set(typesMap.customTypes.keys());
80
+ for (const { inputs, outputs } of Object.values(functionMeta)) {
81
+ const types = [...(inputs || []), ...(outputs || [])];
82
+ for (const type of types) {
83
+ try {
84
+ const uniqueName = typesMap.getUniqueName(type);
85
+ if (uniqueName) {
86
+ schemasSet.add(uniqueName);
87
+ }
88
+ }
89
+ catch {
90
+ // Skip types not in typesMap (e.g., inline types in generated workflow workers)
91
+ }
92
+ }
93
+ }
94
+ for (const wiringRoutes of Object.values(httpWiringsMeta)) {
95
+ for (const { inputTypes } of Object.values(wiringRoutes)) {
96
+ if (inputTypes?.body) {
97
+ schemasSet.add(inputTypes.body);
98
+ }
99
+ if (inputTypes?.query) {
100
+ schemasSet.add(inputTypes.query);
101
+ }
102
+ if (inputTypes?.params) {
103
+ schemasSet.add(inputTypes.params);
104
+ }
105
+ }
106
+ }
107
+ if (additionalTypes) {
108
+ for (const type of additionalTypes) {
109
+ schemasSet.add(type);
110
+ }
111
+ }
112
+ const virtualFilePath = join(dirname(resolve(tsconfig)), '__pikku_virtual_types__.ts');
113
+ const program = createProgramWithVirtualFile(tsconfig, virtualFilePath, customTypesContent);
114
+ const generator = createGenerator({
115
+ tsProgram: program,
116
+ skipTypeCheck: true,
117
+ topRef: false,
118
+ discriminatorType: 'open-api',
119
+ expose: 'export',
120
+ jsDoc: 'extended',
121
+ sortProps: true,
122
+ strictTuples: false,
123
+ encodeRefs: false,
124
+ additionalProperties,
125
+ });
126
+ const schemas = {};
127
+ schemasSet.forEach((schema) => {
128
+ if (PRIMITIVE_TYPES.has(schema)) {
129
+ return;
130
+ }
131
+ if (schemaLookup?.has(schema)) {
132
+ return;
133
+ }
134
+ try {
135
+ schemas[schema] = generator.createSchema(schema);
136
+ }
137
+ catch (e) {
138
+ if (e instanceof RootlessError) {
139
+ const customType = typesMap.customTypes.get(schema);
140
+ if (customType) {
141
+ const primitiveSchema = primitiveTypeToSchema(customType.type);
142
+ if (primitiveSchema) {
143
+ schemas[schema] = primitiveSchema;
144
+ }
145
+ }
146
+ return;
147
+ }
148
+ const customType = typesMap.customTypes.get(schema);
149
+ logger.error(`[${ErrorCode.SCHEMA_GENERATION_ERROR}] Error generating schema: ${schema}. Message: ${e.message}. Type info: ${customType ? `type=${customType.type}` : 'not in typesMap'}`);
150
+ }
151
+ });
152
+ return schemas;
153
+ }
154
+ async function generateZodSchemas(logger, schemaLookup, typesMap) {
155
+ const schemas = {};
156
+ const auxiliaryTypeStore = createAuxiliaryTypeStore();
157
+ const printer = ts.createPrinter();
158
+ const fakeSourceFile = ts.createSourceFile('zod-types.ts', '', ts.ScriptTarget.ESNext, false, ts.ScriptKind.TS);
159
+ for (const [schemaName, ref] of schemaLookup.entries()) {
160
+ if (ref.vendor && ref.vendor !== 'zod') {
161
+ throw new Error(`Schema '${schemaName}' uses ${ref.vendor} which is not yet supported for JSON Schema generation. ` +
162
+ `Currently only Zod schemas can be converted to JSON Schema. ` +
163
+ `Please use Zod or contribute support for ${ref.vendor}.`);
164
+ }
165
+ try {
166
+ const module = await tsImport(ref.sourceFile, import.meta.url);
167
+ const zodSchema = module[ref.variableName];
168
+ if (!zodSchema) {
169
+ logger.warn(`Could not find exported schema '${ref.variableName}' in ${ref.sourceFile} for ${schemaName}. Available exports: ${Object.keys(module).join(', ')}`);
170
+ continue;
171
+ }
172
+ const schema = z.toJSONSchema(zodSchema, {
173
+ unrepresentable: 'any',
174
+ override: ({ zodSchema, jsonSchema }) => {
175
+ if (zodSchema._zod?.def?.type === 'date') {
176
+ ;
177
+ jsonSchema.type = 'string';
178
+ jsonSchema.format = 'date-time';
179
+ }
180
+ },
181
+ });
182
+ if (schema.required && schema.properties) {
183
+ schema.required = schema.required.filter((fieldName) => {
184
+ const prop = schema.properties[fieldName];
185
+ return prop && prop.default === undefined;
186
+ });
187
+ if (schema.required.length === 0) {
188
+ delete schema.required;
189
+ }
190
+ }
191
+ schemas[schemaName] = schema;
192
+ const { node: tsType } = zodToTs(zodSchema, { auxiliaryTypeStore });
193
+ const typeText = printer.printNode(ts.EmitHint.Unspecified, tsType, fakeSourceFile);
194
+ typesMap.addCustomType(schemaName, typeText, []);
195
+ logger.debug(`• Generated schema from Zod: ${schemaName}`);
196
+ }
197
+ catch (e) {
198
+ logger.warn(`Could not convert Zod schema '${schemaName}': ${e instanceof Error ? e.message : e}`);
199
+ }
200
+ }
201
+ return schemas;
202
+ }
203
+ export async function generateAllSchemas(logger, config, state) {
204
+ const zodSchemas = await generateZodSchemas(logger, state.schemaLookup, state.functions.typesMap);
205
+ const requiredTypes = new Set();
206
+ const customTypesContent = generateCustomTypes(state.functions.typesMap, requiredTypes);
207
+ const tsSchemas = generateTSSchemas(logger, config.tsconfig, customTypesContent, state.functions.typesMap, state.functions.meta, state.http.meta, config.schemasFromTypes, config.schema?.additionalProperties, state.schemaLookup);
208
+ return { ...tsSchemas, ...zodSchemas };
209
+ }
@@ -1,4 +1,5 @@
1
- import { InspectorState } from '../types.js';
1
+ import type { JSONValue } from '@pikku/core';
2
+ import type { InspectorDiagnostic, InspectorState } from '../types.js';
2
3
  /**
3
4
  * Serializable version of InspectorState that can be saved to JSON
4
5
  * Omits typesLookup (contains non-serializable ts.Type objects) and converts Maps/Sets to arrays
@@ -74,10 +75,15 @@ export interface SerializableInspectorState {
74
75
  }[]
75
76
  ]>
76
77
  ]>;
77
- zodLookup: Array<[string, {
78
- variableName: string;
79
- sourceFile: string;
80
- }]>;
78
+ schemaLookup: Array<[
79
+ string,
80
+ {
81
+ variableName: string;
82
+ sourceFile: string;
83
+ vendor?: 'zod' | 'valibot' | 'arktype' | 'effect' | 'unknown';
84
+ }
85
+ ]>;
86
+ schemas: Record<string, JSONValue>;
81
87
  functions: {
82
88
  typesMap: {
83
89
  map: Array<[string, {
@@ -119,6 +125,11 @@ export interface SerializableInspectorState {
119
125
  files: string[];
120
126
  meta: InspectorState['channels']['meta'];
121
127
  };
128
+ triggers: {
129
+ meta: InspectorState['triggers']['meta'];
130
+ sourceMeta: InspectorState['triggers']['sourceMeta'];
131
+ files: string[];
132
+ };
122
133
  scheduledTasks: {
123
134
  meta: InspectorState['scheduledTasks']['meta'];
124
135
  files: string[];
@@ -138,6 +149,7 @@ export interface SerializableInspectorState {
138
149
  path: string;
139
150
  exportedName: string;
140
151
  }]>;
152
+ invokedWorkflows: string[];
141
153
  };
142
154
  rpc: {
143
155
  internalMeta: InspectorState['rpc']['internalMeta'];
@@ -151,7 +163,17 @@ export interface SerializableInspectorState {
151
163
  exportedName: string;
152
164
  }]>;
153
165
  invokedFunctions: string[];
154
- usedExternalPackages: string[];
166
+ usedAddons: string[];
167
+ wireAddonDeclarations: Array<[
168
+ string,
169
+ {
170
+ package: string;
171
+ rpcEndpoint?: string;
172
+ secretOverrides?: Record<string, string>;
173
+ variableOverrides?: Record<string, string>;
174
+ }
175
+ ]>;
176
+ wireAddonFiles: string[];
155
177
  };
156
178
  mcpEndpoints: {
157
179
  resourcesMeta: InspectorState['mcpEndpoints']['resourcesMeta'];
@@ -159,27 +181,52 @@ export interface SerializableInspectorState {
159
181
  promptsMeta: InspectorState['mcpEndpoints']['promptsMeta'];
160
182
  files: string[];
161
183
  };
184
+ agents: {
185
+ agentsMeta: InspectorState['agents']['agentsMeta'];
186
+ files: [string, {
187
+ path: string;
188
+ exportedName: string;
189
+ }][];
190
+ };
162
191
  cli: {
163
192
  meta: InspectorState['cli']['meta'];
164
193
  files: string[];
165
194
  };
166
- forgeNodes: {
167
- meta: InspectorState['forgeNodes']['meta'];
195
+ nodes: {
196
+ meta: InspectorState['nodes']['meta'];
197
+ files: string[];
198
+ };
199
+ secrets: {
200
+ definitions: InspectorState['secrets']['definitions'];
168
201
  files: string[];
169
202
  };
170
- forgeCredentials: {
171
- meta: InspectorState['forgeCredentials']['meta'];
203
+ variables: {
204
+ definitions: InspectorState['variables']['definitions'];
172
205
  files: string[];
173
206
  };
207
+ manifest: InspectorState['manifest'];
174
208
  middleware: {
175
- meta: InspectorState['middleware']['meta'];
209
+ definitions: InspectorState['middleware']['definitions'];
210
+ instances: InspectorState['middleware']['instances'];
176
211
  tagMiddleware: Array<[
177
212
  string,
178
213
  InspectorState['middleware']['tagMiddleware'] extends Map<string, infer V> ? V : never
179
214
  ]>;
180
215
  };
216
+ channelMiddleware: {
217
+ definitions: InspectorState['channelMiddleware']['definitions'];
218
+ instances: InspectorState['channelMiddleware']['instances'];
219
+ tagMiddleware: Array<[
220
+ string,
221
+ InspectorState['channelMiddleware']['tagMiddleware'] extends Map<string, infer V> ? V : never
222
+ ]>;
223
+ };
224
+ aiMiddleware: {
225
+ definitions: InspectorState['aiMiddleware']['definitions'];
226
+ };
181
227
  permissions: {
182
- meta: InspectorState['permissions']['meta'];
228
+ definitions: InspectorState['permissions']['definitions'];
229
+ instances: InspectorState['permissions']['instances'];
183
230
  tagPermissions: Array<[
184
231
  string,
185
232
  InspectorState['permissions']['tagPermissions'] extends Map<string, infer V> ? V : never
@@ -193,16 +240,15 @@ export interface SerializableInspectorState {
193
240
  allSingletonServices: string[];
194
241
  allWireServices: string[];
195
242
  };
196
- serviceMetadata: Array<{
197
- name: string;
198
- summary: string;
199
- description: string;
200
- package: string;
201
- path: string;
202
- version: string;
203
- interface: string;
204
- expandedProperties: Record<string, string>;
243
+ resolvedIOTypes: Record<string, {
244
+ inputType: string;
245
+ outputType: string;
205
246
  }>;
247
+ middlewareGroupsMeta: InspectorState['middlewareGroupsMeta'];
248
+ permissionsGroupsMeta: InspectorState['permissionsGroupsMeta'];
249
+ requiredSchemas: string[];
250
+ openAPISpec: Record<string, any> | null;
251
+ diagnostics: InspectorDiagnostic[];
206
252
  }
207
253
  /**
208
254
  * Serializes InspectorState to a JSON-compatible format
@@ -213,9 +259,10 @@ export declare function serializeInspectorState(state: InspectorState): Serializ
213
259
  * Deserializes JSON data back to InspectorState
214
260
  * Creates a partial state suitable for filtering/generation (without typesLookup)
215
261
  */
216
- export declare function deserializeInspectorState(data: SerializableInspectorState): Omit<InspectorState, 'typesLookup' | 'zodLookup'> & {
217
- zodLookup: Map<string, {
262
+ export declare function deserializeInspectorState(data: SerializableInspectorState): Omit<InspectorState, 'typesLookup' | 'schemaLookup'> & {
263
+ schemaLookup: Map<string, {
218
264
  variableName: string;
219
265
  sourceFile: string;
266
+ vendor?: 'zod' | 'valibot' | 'arktype' | 'effect' | 'unknown';
220
267
  }>;
221
268
  };
@@ -26,7 +26,8 @@ export function serializeInspectorState(state) {
26
26
  configFactories: Array.from(state.configFactories.entries()),
27
27
  filesAndMethods: state.filesAndMethods,
28
28
  filesAndMethodsErrors: Array.from(state.filesAndMethodsErrors.entries()).map(([key, mapValue]) => [key, Array.from(mapValue.entries())]),
29
- zodLookup: Array.from(state.zodLookup.entries()),
29
+ schemaLookup: Array.from(state.schemaLookup.entries()),
30
+ schemas: state.schemas,
30
31
  functions: {
31
32
  typesMap: serializeTypesMap(state.functions.typesMap),
32
33
  meta: state.functions.meta,
@@ -43,6 +44,11 @@ export function serializeInspectorState(state) {
43
44
  files: Array.from(state.channels.files),
44
45
  meta: state.channels.meta,
45
46
  },
47
+ triggers: {
48
+ meta: state.triggers.meta,
49
+ sourceMeta: state.triggers.sourceMeta,
50
+ files: Array.from(state.triggers.files),
51
+ },
46
52
  scheduledTasks: {
47
53
  meta: state.scheduledTasks.meta,
48
54
  files: Array.from(state.scheduledTasks.files),
@@ -56,6 +62,7 @@ export function serializeInspectorState(state) {
56
62
  files: Array.from(state.workflows.files.entries()),
57
63
  graphMeta: state.workflows.graphMeta,
58
64
  graphFiles: Array.from(state.workflows.graphFiles.entries()),
65
+ invokedWorkflows: Array.from(state.workflows.invokedWorkflows),
59
66
  },
60
67
  rpc: {
61
68
  internalMeta: state.rpc.internalMeta,
@@ -63,7 +70,9 @@ export function serializeInspectorState(state) {
63
70
  exposedMeta: state.rpc.exposedMeta,
64
71
  exposedFiles: Array.from(state.rpc.exposedFiles.entries()),
65
72
  invokedFunctions: Array.from(state.rpc.invokedFunctions),
66
- usedExternalPackages: Array.from(state.rpc.usedExternalPackages),
73
+ usedAddons: Array.from(state.rpc.usedAddons),
74
+ wireAddonDeclarations: Array.from(state.rpc.wireAddonDeclarations.entries()),
75
+ wireAddonFiles: Array.from(state.rpc.wireAddonFiles),
67
76
  },
68
77
  mcpEndpoints: {
69
78
  resourcesMeta: state.mcpEndpoints.resourcesMeta,
@@ -71,24 +80,43 @@ export function serializeInspectorState(state) {
71
80
  promptsMeta: state.mcpEndpoints.promptsMeta,
72
81
  files: Array.from(state.mcpEndpoints.files),
73
82
  },
83
+ agents: {
84
+ agentsMeta: state.agents?.agentsMeta ?? {},
85
+ files: Array.from(state.agents?.files?.entries() ?? []),
86
+ },
74
87
  cli: {
75
88
  meta: state.cli.meta,
76
89
  files: Array.from(state.cli.files),
77
90
  },
78
- forgeNodes: {
79
- meta: state.forgeNodes.meta,
80
- files: Array.from(state.forgeNodes.files),
91
+ nodes: {
92
+ meta: state.nodes.meta,
93
+ files: Array.from(state.nodes.files),
94
+ },
95
+ secrets: {
96
+ definitions: state.secrets.definitions,
97
+ files: Array.from(state.secrets.files),
81
98
  },
82
- forgeCredentials: {
83
- meta: state.forgeCredentials.meta,
84
- files: Array.from(state.forgeCredentials.files),
99
+ variables: {
100
+ definitions: state.variables.definitions,
101
+ files: Array.from(state.variables.files),
85
102
  },
103
+ manifest: state.manifest,
86
104
  middleware: {
87
- meta: state.middleware.meta,
105
+ definitions: state.middleware.definitions,
106
+ instances: state.middleware.instances,
88
107
  tagMiddleware: Array.from(state.middleware.tagMiddleware.entries()),
89
108
  },
109
+ channelMiddleware: {
110
+ definitions: state.channelMiddleware.definitions,
111
+ instances: state.channelMiddleware.instances,
112
+ tagMiddleware: Array.from(state.channelMiddleware.tagMiddleware.entries()),
113
+ },
114
+ aiMiddleware: {
115
+ definitions: state.aiMiddleware.definitions,
116
+ },
90
117
  permissions: {
91
- meta: state.permissions.meta,
118
+ definitions: state.permissions.definitions,
119
+ instances: state.permissions.instances,
92
120
  tagPermissions: Array.from(state.permissions.tagPermissions.entries()),
93
121
  },
94
122
  serviceAggregation: {
@@ -99,7 +127,12 @@ export function serializeInspectorState(state) {
99
127
  allSingletonServices: state.serviceAggregation.allSingletonServices,
100
128
  allWireServices: state.serviceAggregation.allWireServices,
101
129
  },
102
- serviceMetadata: state.serviceMetadata,
130
+ resolvedIOTypes: state.resolvedIOTypes,
131
+ middlewareGroupsMeta: state.middlewareGroupsMeta,
132
+ permissionsGroupsMeta: state.permissionsGroupsMeta,
133
+ requiredSchemas: Array.from(state.requiredSchemas),
134
+ openAPISpec: state.openAPISpec,
135
+ diagnostics: state.diagnostics,
103
136
  };
104
137
  }
105
138
  /**
@@ -130,7 +163,8 @@ export function deserializeInspectorState(data) {
130
163
  key,
131
164
  new Map(entries),
132
165
  ])),
133
- zodLookup: new Map(data.zodLookup || []),
166
+ schemaLookup: new Map(data.schemaLookup || []),
167
+ schemas: data.schemas || {},
134
168
  functions: {
135
169
  typesMap: deserializeTypesMap(data.functions.typesMap),
136
170
  meta: data.functions.meta,
@@ -147,6 +181,11 @@ export function deserializeInspectorState(data) {
147
181
  files: new Set(data.channels.files),
148
182
  meta: data.channels.meta,
149
183
  },
184
+ triggers: {
185
+ meta: data.triggers?.meta ?? {},
186
+ sourceMeta: data.triggers?.sourceMeta ?? {},
187
+ files: new Set(data.triggers?.files ?? []),
188
+ },
150
189
  scheduledTasks: {
151
190
  meta: data.scheduledTasks.meta,
152
191
  files: new Set(data.scheduledTasks.files),
@@ -160,6 +199,7 @@ export function deserializeInspectorState(data) {
160
199
  files: new Map(data.workflows.files),
161
200
  graphMeta: data.workflows.graphMeta || {},
162
201
  graphFiles: new Map(data.workflows.graphFiles || []),
202
+ invokedWorkflows: new Set(data.workflows.invokedWorkflows || []),
163
203
  },
164
204
  rpc: {
165
205
  internalMeta: data.rpc.internalMeta,
@@ -167,7 +207,9 @@ export function deserializeInspectorState(data) {
167
207
  exposedMeta: data.rpc.exposedMeta,
168
208
  exposedFiles: new Map(data.rpc.exposedFiles),
169
209
  invokedFunctions: new Set(data.rpc.invokedFunctions),
170
- usedExternalPackages: new Set(data.rpc.usedExternalPackages || []),
210
+ usedAddons: new Set(data.rpc.usedAddons || []),
211
+ wireAddonDeclarations: new Map(data.rpc.wireAddonDeclarations || []),
212
+ wireAddonFiles: new Set(data.rpc.wireAddonFiles || []),
171
213
  },
172
214
  mcpEndpoints: {
173
215
  resourcesMeta: data.mcpEndpoints.resourcesMeta,
@@ -175,24 +217,43 @@ export function deserializeInspectorState(data) {
175
217
  promptsMeta: data.mcpEndpoints.promptsMeta,
176
218
  files: new Set(data.mcpEndpoints.files),
177
219
  },
220
+ agents: {
221
+ agentsMeta: data.agents?.agentsMeta || {},
222
+ files: new Map(data.agents?.files || []),
223
+ },
178
224
  cli: {
179
225
  meta: data.cli.meta,
180
226
  files: new Set(data.cli.files),
181
227
  },
182
- forgeNodes: {
183
- meta: data.forgeNodes?.meta || {},
184
- files: new Set(data.forgeNodes?.files || []),
228
+ nodes: {
229
+ meta: data.nodes?.meta || {},
230
+ files: new Set(data.nodes?.files || []),
231
+ },
232
+ secrets: {
233
+ definitions: data.secrets?.definitions || [],
234
+ files: new Set(data.secrets?.files || []),
185
235
  },
186
- forgeCredentials: {
187
- meta: data.forgeCredentials?.meta || {},
188
- files: new Set(data.forgeCredentials?.files || []),
236
+ variables: {
237
+ definitions: data.variables?.definitions || [],
238
+ files: new Set(data.variables?.files || []),
189
239
  },
240
+ manifest: data.manifest || { initial: null, current: null, errors: [] },
190
241
  middleware: {
191
- meta: data.middleware.meta,
242
+ definitions: data.middleware.definitions,
243
+ instances: data.middleware.instances || {},
192
244
  tagMiddleware: new Map(data.middleware.tagMiddleware),
193
245
  },
246
+ channelMiddleware: {
247
+ definitions: data.channelMiddleware?.definitions || {},
248
+ instances: data.channelMiddleware?.instances || {},
249
+ tagMiddleware: new Map(data.channelMiddleware?.tagMiddleware || []),
250
+ },
251
+ aiMiddleware: {
252
+ definitions: data.aiMiddleware?.definitions || {},
253
+ },
194
254
  permissions: {
195
- meta: data.permissions.meta,
255
+ definitions: data.permissions.definitions,
256
+ instances: data.permissions.instances || {},
196
257
  tagPermissions: new Map(data.permissions.tagPermissions),
197
258
  },
198
259
  serviceAggregation: {
@@ -203,6 +264,21 @@ export function deserializeInspectorState(data) {
203
264
  allSingletonServices: data.serviceAggregation.allSingletonServices,
204
265
  allWireServices: data.serviceAggregation.allWireServices,
205
266
  },
206
- serviceMetadata: data.serviceMetadata || [],
267
+ resolvedIOTypes: data.resolvedIOTypes || {},
268
+ middlewareGroupsMeta: data.middlewareGroupsMeta || {
269
+ definitions: {},
270
+ instances: {},
271
+ httpGroups: {},
272
+ tagGroups: {},
273
+ channelMiddleware: { definitions: {}, instances: {}, tagGroups: {} },
274
+ },
275
+ permissionsGroupsMeta: data.permissionsGroupsMeta || {
276
+ definitions: {},
277
+ httpGroups: {},
278
+ tagGroups: {},
279
+ },
280
+ requiredSchemas: new Set(data.requiredSchemas || []),
281
+ openAPISpec: data.openAPISpec || null,
282
+ diagnostics: data.diagnostics || [],
207
283
  };
208
284
  }
@@ -0,0 +1,2 @@
1
+ import type { InspectorLogger, InspectorState } from '../types.js';
2
+ export declare const serializeMCPJson: (logger: InspectorLogger, state: InspectorState) => string;