@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
package/src/types.ts CHANGED
@@ -1,15 +1,33 @@
1
- import * as ts from 'typescript'
2
- import { ChannelsMeta } from '@pikku/core/channel'
3
- import { HTTPWiringsMeta } from '@pikku/core/http'
4
- import { ScheduledTasksMeta } from '@pikku/core/scheduler'
5
- import { QueueWorkersMeta } from '@pikku/core/queue'
6
- import { WorkflowsMeta } from '@pikku/core/workflow'
7
- import { MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from '@pikku/core/mcp'
8
- import { CLIMeta } from '@pikku/core/cli'
9
- import { ForgeNodesMeta, ForgeCredentialsMeta } from '@pikku/core/forge-node'
10
- import { TypesMap } from './types-map.js'
11
- import { FunctionsMeta, FunctionServicesMeta } from '@pikku/core'
12
- import { ErrorCode } from './error-codes.js'
1
+ import type * as ts from 'typescript'
2
+ import type { ChannelsMeta } from '@pikku/core/channel'
3
+ import type { HTTPWiringsMeta } from '@pikku/core/http'
4
+ import type { ScheduledTasksMeta } from '@pikku/core/scheduler'
5
+ import type { TriggerMeta, TriggerSourceMeta } from '@pikku/core/trigger'
6
+ import type { QueueWorkersMeta } from '@pikku/core/queue'
7
+ import type { WorkflowsMeta } from '@pikku/core/workflow'
8
+ import type {
9
+ MCPResourceMeta,
10
+ MCPToolMeta,
11
+ MCPPromptMeta,
12
+ } from '@pikku/core/mcp'
13
+ import type { AIAgentMeta } from '@pikku/core/ai-agent'
14
+ import type { CLIMeta } from '@pikku/core/cli'
15
+ import type { NodesMeta } from '@pikku/core/node'
16
+ import type { SecretDefinitions } from '@pikku/core/secret'
17
+ import type { VariableDefinitions } from '@pikku/core/variable'
18
+ import type { TypesMap } from './types-map.js'
19
+ import type {
20
+ FunctionsMeta,
21
+ FunctionServicesMeta,
22
+ FunctionWiresMeta,
23
+ JSONValue,
24
+ } from '@pikku/core'
25
+ import type { OpenAPISpecInfo } from './utils/serialize-openapi-json.js'
26
+ import type { ErrorCode } from './error-codes.js'
27
+ import type {
28
+ VersionManifest,
29
+ VersionValidateError,
30
+ } from './utils/contract-hashes.js'
13
31
  import type { SerializedWorkflowGraphs } from './utils/workflow/graph/workflow-graph.types.js'
14
32
 
15
33
  export type PathToNameAndType = Map<
@@ -31,7 +49,8 @@ export interface MiddlewareGroupMeta {
31
49
  sourceFile: string
32
50
  position: number
33
51
  services: FunctionServicesMeta
34
- middlewareCount: number
52
+ count: number
53
+ instanceIds: string[]
35
54
  isFactory: boolean // true if wrapped in () => add...()
36
55
  }
37
56
 
@@ -40,7 +59,8 @@ export interface PermissionGroupMeta {
40
59
  sourceFile: string
41
60
  position: number
42
61
  services: FunctionServicesMeta
43
- permissionCount: number
62
+ count: number
63
+ instanceIds: string[]
44
64
  isFactory: boolean // true if wrapped in () => add...()
45
65
  }
46
66
 
@@ -59,11 +79,18 @@ export interface InspectorHTTPState {
59
79
  }
60
80
 
61
81
  /**
62
- * Zod schema reference for deferred conversion to JSON Schema at build time
82
+ * Schema vendor types for Standard Schema compliant validators
63
83
  */
64
- export interface ZodSchemaRef {
84
+ export type SchemaVendor = 'zod' | 'valibot' | 'arktype' | 'effect' | 'unknown'
85
+
86
+ /**
87
+ * Schema reference for deferred conversion to JSON Schema at build time.
88
+ * Supports Standard Schema compliant validators (Zod, Valibot, ArkType, Effect Schema).
89
+ */
90
+ export interface SchemaRef {
65
91
  variableName: string
66
92
  sourceFile: string
93
+ vendor?: SchemaVendor
67
94
  }
68
95
 
69
96
  export interface InspectorFunctionState {
@@ -77,41 +104,64 @@ export interface InspectorChannelState {
77
104
  files: Set<string>
78
105
  }
79
106
 
107
+ export interface InspectorMiddlewareDefinition {
108
+ services: FunctionServicesMeta
109
+ wires?: FunctionWiresMeta
110
+ sourceFile: string
111
+ position: number
112
+ exportedName: string | null
113
+ factory?: boolean
114
+ name?: string
115
+ description?: string
116
+ package?: string
117
+ }
118
+
119
+ export interface InspectorMiddlewareInstance {
120
+ definitionId: string
121
+ sourceFile: string
122
+ position: number
123
+ isFactoryCall: boolean
124
+ }
125
+
80
126
  export interface InspectorMiddlewareState {
81
- // Individual middleware function metadata
82
- meta: Record<
83
- string,
84
- {
85
- services: FunctionServicesMeta
86
- sourceFile: string
87
- position: number
88
- exportedName: string | null
89
- factory?: boolean // true if wrapped with pikkuMiddlewareFactory
90
- name?: string // optional name from pikkuMiddleware({ name: '...' })
91
- description?: string // optional description from pikkuMiddleware({ description: '...' })
92
- }
93
- >
94
- // Tag-based middleware calls tracking - tag -> group metadata
95
- // e.g., export const adminMiddleware = () => addMiddleware('admin', [...])
127
+ definitions: Record<string, InspectorMiddlewareDefinition>
128
+ instances: Record<string, InspectorMiddlewareInstance>
129
+ tagMiddleware: Map<string, MiddlewareGroupMeta>
130
+ }
131
+
132
+ export interface InspectorChannelMiddlewareState {
133
+ definitions: Record<string, InspectorMiddlewareDefinition>
134
+ instances: Record<string, InspectorMiddlewareInstance>
96
135
  tagMiddleware: Map<string, MiddlewareGroupMeta>
97
136
  }
98
137
 
138
+ export interface InspectorAIMiddlewareState {
139
+ definitions: Record<string, InspectorMiddlewareDefinition>
140
+ }
141
+
142
+ export interface InspectorPermissionDefinition {
143
+ services: FunctionServicesMeta
144
+ wires?: FunctionWiresMeta
145
+ sourceFile: string
146
+ position: number
147
+ exportedName: string | null
148
+ factory?: boolean
149
+ name?: string
150
+ description?: string
151
+ package?: string
152
+ requiresData?: boolean
153
+ }
154
+
155
+ export interface InspectorPermissionInstance {
156
+ definitionId: string
157
+ sourceFile: string
158
+ position: number
159
+ isFactoryCall: boolean
160
+ }
161
+
99
162
  export interface InspectorPermissionState {
100
- // Individual permission function metadata
101
- meta: Record<
102
- string,
103
- {
104
- services: FunctionServicesMeta
105
- sourceFile: string
106
- position: number
107
- exportedName: string | null
108
- factory?: boolean // true if wrapped with pikkuPermissionFactory
109
- name?: string // optional name from pikkuPermission({ name: '...' })
110
- description?: string // optional description from pikkuPermission({ description: '...' })
111
- }
112
- >
113
- // Tag-based permission calls tracking - tag -> group metadata
114
- // e.g., export const adminPermissions = () => addPermission('admin', [...])
163
+ definitions: Record<string, InspectorPermissionDefinition>
164
+ instances: Record<string, InspectorPermissionInstance>
115
165
  tagPermissions: Map<string, PermissionGroupMeta>
116
166
  }
117
167
 
@@ -124,16 +174,47 @@ export type InspectorFilters = {
124
174
  httpMethods?: string[] // HTTP methods: "GET", "POST", "DELETE", etc.
125
175
  }
126
176
 
177
+ export type AddonConfig = {
178
+ package: string
179
+ rpcEndpoint?: string
180
+ secretOverrides?: Record<string, string>
181
+ forceInclude?: boolean
182
+ }
183
+
184
+ export type ModelConfigEntry =
185
+ | string
186
+ | { model: string; temperature?: number; maxSteps?: number }
187
+
188
+ export type InspectorModelConfig = {
189
+ models?: Record<string, ModelConfigEntry>
190
+ agentDefaults?: { temperature?: number; maxSteps?: number }
191
+ agentOverrides?: Record<
192
+ string,
193
+ { model?: string; temperature?: number; maxSteps?: number }
194
+ >
195
+ }
196
+
127
197
  export type InspectorOptions = Partial<{
128
198
  setupOnly: boolean
129
- /** Project root directory - used to filter out external package files */
130
199
  rootDir: string
200
+ isAddon: boolean
131
201
  types: Partial<{
132
202
  configFileType: string
133
203
  userSessionType: string
134
204
  singletonServicesFactoryType: string
135
205
  wireServicesFactoryType: string
136
206
  }>
207
+ schemaConfig: {
208
+ tsconfig: string
209
+ schemasFromTypes?: string[]
210
+ schema?: { additionalProperties?: boolean }
211
+ }
212
+ openAPI: {
213
+ additionalInfo: OpenAPISpecInfo
214
+ }
215
+ tags: string[]
216
+ manifest: VersionManifest
217
+ modelConfig: InspectorModelConfig
137
218
  }>
138
219
 
139
220
  export interface InspectorLogger {
@@ -197,6 +278,13 @@ export interface InspectorFilesAndMethods {
197
278
  }
198
279
  }
199
280
 
281
+ export interface InspectorDiagnostic {
282
+ code: string
283
+ message: string
284
+ sourceFile: string
285
+ position: number
286
+ }
287
+
200
288
  export interface InspectorState {
201
289
  rootDir: string // Root directory inferred from source files
202
290
  singletonServicesTypeImportMap: PathToNameAndType
@@ -210,10 +298,16 @@ export interface InspectorState {
210
298
  filesAndMethods: InspectorFilesAndMethods
211
299
  filesAndMethodsErrors: Map<string, PathToNameAndType>
212
300
  typesLookup: Map<string, ts.Type[]> // Lookup for types by name (e.g., function input types, Config type)
213
- zodLookup: Map<string, ZodSchemaRef> // Lookup for Zod schemas by name for deferred JSON Schema conversion
301
+ schemaLookup: Map<string, SchemaRef> // Lookup for schemas by name for deferred JSON Schema conversion (supports Standard Schema vendors)
302
+ schemas: Record<string, JSONValue>
214
303
  http: InspectorHTTPState
215
304
  functions: InspectorFunctionState
216
305
  channels: InspectorChannelState
306
+ triggers: {
307
+ meta: TriggerMeta
308
+ sourceMeta: TriggerSourceMeta
309
+ files: Set<string>
310
+ }
217
311
  scheduledTasks: {
218
312
  meta: ScheduledTasksMeta
219
313
  files: Set<string>
@@ -227,6 +321,7 @@ export interface InspectorState {
227
321
  files: Map<string, { path: string; exportedName: string }>
228
322
  graphMeta: SerializedWorkflowGraphs
229
323
  graphFiles: Map<string, { path: string; exportedName: string }>
324
+ invokedWorkflows: Set<string>
230
325
  }
231
326
  rpc: {
232
327
  internalMeta: Record<string, string>
@@ -234,7 +329,17 @@ export interface InspectorState {
234
329
  exposedMeta: Record<string, string>
235
330
  exposedFiles: Map<string, { path: string; exportedName: string }>
236
331
  invokedFunctions: Set<string>
237
- usedExternalPackages: Set<string>
332
+ usedAddons: Set<string>
333
+ wireAddonDeclarations: Map<
334
+ string,
335
+ {
336
+ package: string
337
+ rpcEndpoint?: string
338
+ secretOverrides?: Record<string, string>
339
+ variableOverrides?: Record<string, string>
340
+ }
341
+ >
342
+ wireAddonFiles: Set<string>
238
343
  }
239
344
  mcpEndpoints: {
240
345
  resourcesMeta: MCPResourceMeta
@@ -242,36 +347,61 @@ export interface InspectorState {
242
347
  promptsMeta: MCPPromptMeta
243
348
  files: Set<string>
244
349
  }
350
+ agents: {
351
+ agentsMeta: AIAgentMeta
352
+ files: Map<string, { path: string; exportedName: string }>
353
+ }
245
354
  cli: {
246
355
  meta: CLIMeta
247
356
  files: Set<string>
248
357
  }
249
- forgeNodes: {
250
- meta: ForgeNodesMeta
358
+ nodes: {
359
+ meta: NodesMeta
251
360
  files: Set<string>
252
361
  }
253
- forgeCredentials: {
254
- meta: ForgeCredentialsMeta
362
+ secrets: {
363
+ definitions: SecretDefinitions
255
364
  files: Set<string>
256
365
  }
366
+ variables: {
367
+ definitions: VariableDefinitions
368
+ files: Set<string>
369
+ }
370
+ manifest: {
371
+ initial: VersionManifest | null
372
+ current: VersionManifest | null
373
+ errors: VersionValidateError[]
374
+ }
257
375
  middleware: InspectorMiddlewareState
376
+ channelMiddleware: InspectorChannelMiddlewareState
377
+ aiMiddleware: InspectorAIMiddlewareState
258
378
  permissions: InspectorPermissionState
259
379
  serviceAggregation: {
260
- requiredServices: Set<string> // All services needed across the app
261
- usedFunctions: Set<string> // Function names actually wired/exposed
262
- usedMiddleware: Set<string> // Middleware names used by wired functions
263
- usedPermissions: Set<string> // Permission names used by wired functions
264
- allSingletonServices: string[] // All services available in SingletonServices type
265
- allWireServices: string[] // All services available in Services type (excluding SingletonServices)
380
+ requiredServices: Set<string>
381
+ usedFunctions: Set<string>
382
+ usedMiddleware: Set<string>
383
+ usedPermissions: Set<string>
384
+ allSingletonServices: string[]
385
+ allWireServices: string[]
266
386
  }
267
- serviceMetadata: Array<{
268
- name: string
269
- summary: string
270
- description: string
271
- package: string
272
- path: string
273
- version: string
274
- interface: string
275
- expandedProperties: Record<string, string>
276
- }>
387
+ resolvedIOTypes: Record<string, { inputType: string; outputType: string }>
388
+ middlewareGroupsMeta: {
389
+ definitions: Record<string, InspectorMiddlewareDefinition>
390
+ instances: Record<string, InspectorMiddlewareInstance>
391
+ httpGroups: Record<string, MiddlewareGroupMeta>
392
+ tagGroups: Record<string, MiddlewareGroupMeta>
393
+ channelMiddleware: {
394
+ definitions: Record<string, InspectorMiddlewareDefinition>
395
+ instances: Record<string, InspectorMiddlewareInstance>
396
+ tagGroups: Record<string, MiddlewareGroupMeta>
397
+ }
398
+ }
399
+ permissionsGroupsMeta: {
400
+ definitions: Record<string, InspectorPermissionDefinition>
401
+ httpGroups: Record<string, PermissionGroupMeta>
402
+ tagGroups: Record<string, PermissionGroupMeta>
403
+ }
404
+ requiredSchemas: Set<string>
405
+ openAPISpec: Record<string, any> | null
406
+ diagnostics: InspectorDiagnostic[]
277
407
  }
@@ -0,0 +1,48 @@
1
+ import type { FunctionsMeta } from '@pikku/core'
2
+ import type { TypesMap } from '../types-map.js'
3
+ import type { SchemaRef } from '../types.js'
4
+
5
+ const PRIMITIVE_TYPES = new Set([
6
+ 'boolean',
7
+ 'string',
8
+ 'number',
9
+ 'null',
10
+ 'undefined',
11
+ 'void',
12
+ 'any',
13
+ 'unknown',
14
+ 'never',
15
+ ])
16
+
17
+ export function computeRequiredSchemas(
18
+ functionsMeta: FunctionsMeta,
19
+ typesMap: TypesMap,
20
+ additionalTypes?: string[],
21
+ schemaLookup?: Map<string, SchemaRef>
22
+ ): Set<string> {
23
+ return new Set<string>([
24
+ ...Object.values(functionsMeta)
25
+ .flatMap(({ inputs, outputs }) => {
26
+ const types: (string | undefined)[] = []
27
+ if (inputs?.[0]) {
28
+ try {
29
+ types.push(typesMap.getUniqueName(inputs[0]))
30
+ } catch {
31
+ types.push(inputs[0])
32
+ }
33
+ }
34
+ if (outputs?.[0]) {
35
+ try {
36
+ types.push(typesMap.getUniqueName(outputs[0]))
37
+ } catch {
38
+ types.push(outputs[0])
39
+ }
40
+ }
41
+ return types
42
+ })
43
+ .filter((s): s is string => !!s && !PRIMITIVE_TYPES.has(s)),
44
+ ...typesMap.customTypes.keys(),
45
+ ...(additionalTypes || []),
46
+ ...(schemaLookup ? Array.from(schemaLookup.keys()) : []),
47
+ ])
48
+ }