@pikku/inspector 0.11.2 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -1
- package/OPTIMIZATION-PLAN.md +195 -0
- package/dist/add/add-ai-agent.d.ts +2 -0
- package/dist/add/add-ai-agent.js +314 -0
- package/dist/add/add-channel.js +81 -61
- package/dist/add/add-cli.d.ts +1 -1
- package/dist/add/add-cli.js +42 -19
- package/dist/add/add-file-extends-core-type.d.ts +1 -1
- package/dist/add/add-file-with-config.d.ts +1 -1
- package/dist/add/add-file-with-factory.d.ts +1 -1
- package/dist/add/add-file-with-factory.js +2 -0
- package/dist/add/add-functions.d.ts +1 -1
- package/dist/add/add-functions.js +256 -82
- package/dist/add/add-http-route.d.ts +20 -10
- package/dist/add/add-http-route.js +156 -66
- package/dist/add/add-http-routes.d.ts +5 -0
- package/dist/add/add-http-routes.js +160 -0
- package/dist/add/add-keyed-wiring.d.ts +12 -0
- package/dist/add/add-keyed-wiring.js +97 -0
- package/dist/add/add-mcp-prompt.d.ts +1 -1
- package/dist/add/add-mcp-prompt.js +14 -9
- package/dist/add/add-mcp-resource.d.ts +1 -1
- package/dist/add/add-mcp-resource.js +14 -9
- package/dist/add/add-middleware.d.ts +1 -4
- package/dist/add/add-middleware.js +364 -79
- package/dist/add/add-permission.d.ts +1 -1
- package/dist/add/add-permission.js +152 -40
- package/dist/add/add-queue-worker.d.ts +1 -1
- package/dist/add/add-queue-worker.js +18 -12
- package/dist/add/add-rpc-invocations.d.ts +3 -3
- package/dist/add/add-rpc-invocations.js +24 -10
- package/dist/add/add-schedule.d.ts +1 -1
- package/dist/add/add-schedule.js +11 -5
- package/dist/add/add-secret.d.ts +3 -0
- package/dist/add/add-secret.js +82 -0
- package/dist/add/add-trigger.d.ts +2 -0
- package/dist/add/add-trigger.js +87 -0
- package/dist/add/add-variable.d.ts +1 -0
- package/dist/add/add-variable.js +8 -0
- package/dist/add/add-wire-addon.d.ts +7 -0
- package/dist/add/add-wire-addon.js +70 -0
- package/dist/add/add-workflow-graph.d.ts +3 -2
- package/dist/add/add-workflow-graph.js +143 -406
- package/dist/add/add-workflow.d.ts +1 -1
- package/dist/add/add-workflow.js +6 -4
- package/dist/error-codes.d.ts +15 -1
- package/dist/error-codes.js +20 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +5 -4
- package/dist/inspector.d.ts +2 -2
- package/dist/inspector.js +95 -15
- package/dist/schema-generator.d.ts +1 -0
- package/dist/schema-generator.js +1 -0
- package/dist/types-map.js +10 -1
- package/dist/types.d.ts +180 -50
- package/dist/utils/compute-required-schemas.d.ts +4 -0
- package/dist/utils/compute-required-schemas.js +40 -0
- package/dist/utils/contract-hashes.d.ts +52 -0
- package/dist/utils/contract-hashes.js +269 -0
- package/dist/utils/custom-types-generator.d.ts +9 -0
- package/dist/utils/custom-types-generator.js +71 -0
- package/dist/utils/detect-schema-vendor.d.ts +22 -0
- package/dist/utils/detect-schema-vendor.js +76 -0
- package/dist/utils/does-type-extend-core-type.d.ts +1 -1
- package/dist/utils/ensure-function-metadata.d.ts +6 -3
- package/dist/utils/ensure-function-metadata.js +220 -6
- package/dist/utils/extract-function-name.d.ts +5 -16
- package/dist/utils/extract-function-name.js +86 -291
- package/dist/utils/extract-services.d.ts +2 -1
- package/dist/utils/extract-services.js +25 -1
- package/dist/utils/filter-inspector-state.d.ts +1 -1
- package/dist/utils/filter-inspector-state.js +107 -23
- package/dist/utils/filter-utils.d.ts +2 -2
- package/dist/utils/get-files-and-methods.d.ts +1 -1
- package/dist/utils/get-property-value.d.ts +6 -1
- package/dist/utils/get-property-value.js +28 -3
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.js +23 -0
- package/dist/utils/middleware.d.ts +9 -32
- package/dist/utils/middleware.js +80 -66
- package/dist/utils/permissions.d.ts +4 -4
- package/dist/utils/permissions.js +10 -10
- package/dist/utils/post-process.d.ts +11 -11
- package/dist/utils/post-process.js +247 -24
- package/dist/utils/resolve-addon-package.d.ts +16 -0
- package/dist/utils/resolve-addon-package.js +34 -0
- package/dist/utils/resolve-function-types.d.ts +6 -0
- package/dist/utils/resolve-function-types.js +29 -0
- package/dist/utils/resolve-identifier.d.ts +10 -0
- package/dist/utils/resolve-identifier.js +36 -0
- package/dist/utils/resolve-versions.d.ts +2 -0
- package/dist/utils/resolve-versions.js +78 -0
- package/dist/utils/schema-generator.d.ts +9 -0
- package/dist/utils/schema-generator.js +209 -0
- package/dist/utils/serialize-inspector-state.d.ts +70 -23
- package/dist/utils/serialize-inspector-state.js +98 -22
- package/dist/utils/serialize-mcp-json.d.ts +2 -0
- package/dist/utils/serialize-mcp-json.js +99 -0
- package/dist/utils/serialize-middleware-groups-meta.d.ts +12 -0
- package/dist/utils/serialize-middleware-groups-meta.js +28 -0
- package/dist/utils/serialize-openapi-json.d.ts +85 -0
- package/dist/utils/serialize-openapi-json.js +151 -0
- package/dist/utils/serialize-permissions-groups-meta.d.ts +6 -0
- package/dist/utils/serialize-permissions-groups-meta.js +31 -0
- package/dist/utils/validate-auth-sessionless.d.ts +3 -0
- package/dist/utils/validate-auth-sessionless.js +14 -0
- package/dist/utils/workflow/dsl/deserialize-dsl-workflow.js +34 -102
- package/dist/utils/workflow/dsl/extract-dsl-workflow.d.ts +1 -1
- package/dist/utils/workflow/dsl/extract-dsl-workflow.js +23 -4
- package/dist/utils/workflow/graph/convert-dsl-to-graph.js +12 -10
- package/dist/utils/workflow/graph/finalize-workflow-wires.d.ts +3 -0
- package/dist/utils/workflow/graph/finalize-workflow-wires.js +276 -0
- package/dist/utils/workflow/graph/finalize-workflows.d.ts +2 -0
- package/dist/utils/workflow/graph/finalize-workflows.js +75 -0
- package/dist/utils/workflow/graph/index.d.ts +2 -0
- package/dist/utils/workflow/graph/index.js +2 -0
- package/dist/utils/workflow/graph/serialize-workflow-graph.d.ts +0 -8
- package/dist/utils/workflow/graph/serialize-workflow-graph.js +1 -3
- package/dist/utils/workflow/graph/workflow-graph.types.d.ts +53 -79
- package/dist/utils/workflow/graph/workflow-graph.types.js +1 -1
- package/dist/visit.d.ts +1 -1
- package/dist/visit.js +13 -6
- package/package.json +14 -4
- package/src/add/add-ai-agent.ts +468 -0
- package/src/add/add-channel.ts +103 -79
- package/src/add/add-cli.ts +68 -24
- package/src/add/add-file-extends-core-type.ts +1 -1
- package/src/add/add-file-with-config.ts +1 -1
- package/src/add/add-file-with-factory.ts +3 -1
- package/src/add/add-functions.ts +349 -103
- package/src/add/add-http-route.ts +263 -89
- package/src/add/add-http-routes.ts +229 -0
- package/src/add/add-keyed-wiring.ts +151 -0
- package/src/add/add-mcp-prompt.ts +27 -16
- package/src/add/add-mcp-resource.ts +28 -16
- package/src/add/add-middleware.ts +482 -80
- package/src/add/add-permission.ts +199 -40
- package/src/add/add-queue-worker.ts +25 -20
- package/src/add/add-rpc-invocations.ts +28 -11
- package/src/add/add-schedule.ts +17 -12
- package/src/add/add-secret.ts +140 -0
- package/src/add/add-trigger.ts +154 -0
- package/src/add/add-variable.ts +9 -0
- package/src/add/add-wire-addon.ts +80 -0
- package/src/add/add-workflow-graph.ts +180 -522
- package/src/add/add-workflow.ts +7 -6
- package/src/error-codes.ts +25 -1
- package/src/index.ts +23 -13
- package/src/inspector.ts +139 -19
- package/src/schema-generator.ts +1 -0
- package/src/types-map.ts +12 -1
- package/src/types.ts +199 -69
- package/src/utils/compute-required-schemas.ts +48 -0
- package/src/utils/contract-hashes.test.ts +553 -0
- package/src/utils/contract-hashes.ts +386 -0
- package/src/utils/custom-types-generator.ts +88 -0
- package/src/utils/detect-schema-vendor.ts +90 -0
- package/src/utils/does-type-extend-core-type.ts +1 -1
- package/src/utils/ensure-function-metadata.ts +325 -8
- package/src/utils/extract-function-name.ts +101 -351
- package/src/utils/extract-services.ts +35 -2
- package/src/utils/filter-inspector-state.test.ts +37 -25
- package/src/utils/filter-inspector-state.ts +146 -32
- package/src/utils/filter-utils.test.ts +1 -1
- package/src/utils/filter-utils.ts +2 -2
- package/src/utils/get-files-and-methods.ts +1 -1
- package/src/utils/get-property-value.ts +42 -4
- package/src/utils/hash.ts +26 -0
- package/src/utils/middleware.test.ts +204 -0
- package/src/utils/middleware.ts +131 -69
- package/src/utils/permissions.test.ts +35 -12
- package/src/utils/permissions.ts +12 -12
- package/src/utils/post-process.ts +306 -44
- package/src/utils/resolve-addon-package.ts +49 -0
- package/src/utils/resolve-function-types.ts +42 -0
- package/src/utils/resolve-identifier.ts +46 -0
- package/src/utils/resolve-versions.test.ts +249 -0
- package/src/utils/resolve-versions.ts +105 -0
- package/src/utils/schema-generator.ts +329 -0
- package/src/utils/serialize-inspector-state.ts +184 -43
- package/src/utils/serialize-mcp-json.ts +145 -0
- package/src/utils/serialize-middleware-groups-meta.ts +33 -0
- package/src/utils/serialize-openapi-json.ts +277 -0
- package/src/utils/serialize-permissions-groups-meta.ts +35 -0
- package/src/utils/test-data/inspector-state.json +69 -66
- package/src/utils/validate-auth-sessionless.ts +29 -0
- package/src/utils/workflow/dsl/deserialize-dsl-workflow.ts +43 -119
- package/src/utils/workflow/dsl/extract-dsl-workflow.ts +26 -6
- package/src/utils/workflow/graph/convert-dsl-to-graph.ts +17 -10
- package/src/utils/workflow/graph/finalize-workflow-wires.ts +310 -0
- package/src/utils/workflow/graph/finalize-workflows.ts +100 -0
- package/src/utils/workflow/graph/index.ts +5 -0
- package/src/utils/workflow/graph/serialize-workflow-graph.ts +1 -8
- package/src/utils/workflow/graph/workflow-graph.types.ts +29 -78
- package/src/visit.ts +19 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/add/add-forge-credential.d.ts +0 -8
- package/dist/add/add-forge-credential.js +0 -77
- package/dist/add/add-forge-node.d.ts +0 -7
- package/dist/add/add-forge-node.js +0 -77
- package/dist/add/add-mcp-tool.d.ts +0 -2
- package/dist/add/add-mcp-tool.js +0 -81
- package/dist/utils/extract-service-metadata.d.ts +0 -19
- package/dist/utils/extract-service-metadata.js +0 -244
- package/dist/utils/write-service-metadata.d.ts +0 -13
- package/dist/utils/write-service-metadata.js +0 -37
- package/src/add/add-forge-credential.ts +0 -119
- package/src/add/add-forge-node.ts +0 -132
- package/src/add/add-mcp-tool.ts +0 -141
- package/src/utils/extract-service-metadata.ts +0 -353
- package/src/utils/write-service-metadata.ts +0 -51
package/src/add/add-workflow.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
|
-
import { AddWiring, InspectorState } from '../types.js'
|
|
2
|
+
import type { AddWiring, InspectorState } from '../types.js'
|
|
3
3
|
import { extractFunctionName } from '../utils/extract-function-name.js'
|
|
4
4
|
import { extractFunctionNode } from '../utils/extract-function-node.js'
|
|
5
5
|
import { ErrorCode } from '../error-codes.js'
|
|
6
|
-
import { WorkflowStepMeta, WorkflowContext } from '@pikku/core/workflow'
|
|
6
|
+
import type { WorkflowStepMeta, WorkflowContext } from '@pikku/core/workflow'
|
|
7
7
|
import {
|
|
8
8
|
extractStringLiteral,
|
|
9
9
|
isStringLike,
|
|
@@ -182,7 +182,7 @@ export const addWorkflow: AddWiring = (logger, node, checker, state) => {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
// Extract workflow name and metadata using same logic as add-functions
|
|
185
|
-
const {
|
|
185
|
+
const { pikkuFuncId, name, exportedName } = extractFunctionName(
|
|
186
186
|
node,
|
|
187
187
|
checker,
|
|
188
188
|
state.rootDir
|
|
@@ -214,6 +214,7 @@ export const addWorkflow: AddWiring = (logger, node, checker, state) => {
|
|
|
214
214
|
workflowName,
|
|
215
215
|
logger
|
|
216
216
|
)
|
|
217
|
+
if (metadata.disabled) return
|
|
217
218
|
tags = metadata.tags
|
|
218
219
|
summary = metadata.summary
|
|
219
220
|
description = metadata.description
|
|
@@ -242,7 +243,7 @@ export const addWorkflow: AddWiring = (logger, node, checker, state) => {
|
|
|
242
243
|
|
|
243
244
|
// Track workflow file for wiring generation
|
|
244
245
|
if (exportedName) {
|
|
245
|
-
state.workflows.files.set(
|
|
246
|
+
state.workflows.files.set(pikkuFuncId, {
|
|
246
247
|
path: node.getSourceFile().fileName,
|
|
247
248
|
exportedName,
|
|
248
249
|
})
|
|
@@ -314,8 +315,8 @@ export const addWorkflow: AddWiring = (logger, node, checker, state) => {
|
|
|
314
315
|
}
|
|
315
316
|
|
|
316
317
|
state.workflows.meta[workflowName] = {
|
|
317
|
-
|
|
318
|
-
workflowName,
|
|
318
|
+
pikkuFuncId,
|
|
319
|
+
name: workflowName,
|
|
319
320
|
steps,
|
|
320
321
|
context,
|
|
321
322
|
dsl,
|
package/src/error-codes.ts
CHANGED
|
@@ -30,12 +30,17 @@ export enum ErrorCode {
|
|
|
30
30
|
SCHEMA_NO_ROOT = 'PKU431',
|
|
31
31
|
SCHEMA_GENERATION_ERROR = 'PKU456',
|
|
32
32
|
SCHEMA_LOAD_ERROR = 'PKU488',
|
|
33
|
-
|
|
33
|
+
INLINE_SCHEMA = 'PKU489',
|
|
34
34
|
|
|
35
35
|
// Function errors
|
|
36
36
|
FUNCTION_METADATA_NOT_FOUND = 'PKU559',
|
|
37
37
|
HANDLER_NOT_RESOLVED = 'PKU568',
|
|
38
38
|
|
|
39
|
+
// HTTP Route errors
|
|
40
|
+
ROUTE_PARAM_MISMATCH = 'PKU571',
|
|
41
|
+
ROUTE_QUERY_MISMATCH = 'PKU572',
|
|
42
|
+
AUTH_DISABLED_REQUIRES_SESSIONLESS = 'PKU573',
|
|
43
|
+
|
|
39
44
|
// Middleware/Permission errors
|
|
40
45
|
MIDDLEWARE_HANDLER_INVALID = 'PKU685',
|
|
41
46
|
MIDDLEWARE_TAG_INVALID = 'PKU715',
|
|
@@ -46,6 +51,25 @@ export enum ErrorCode {
|
|
|
46
51
|
PERMISSION_EMPTY_ARRAY = 'PKU937',
|
|
47
52
|
PERMISSION_PATTERN_INVALID = 'PKU975',
|
|
48
53
|
|
|
54
|
+
// Versioning errors
|
|
55
|
+
DUPLICATE_FUNCTION_VERSION = 'PKU850',
|
|
56
|
+
|
|
57
|
+
// Contract versioning errors
|
|
58
|
+
MANIFEST_MISSING = 'PKU860',
|
|
59
|
+
FUNCTION_VERSION_MODIFIED = 'PKU861',
|
|
60
|
+
CONTRACT_CHANGED_REQUIRES_BUMP = 'PKU862',
|
|
61
|
+
VERSION_REGRESSION_OR_CONFLICT = 'PKU863',
|
|
62
|
+
VERSION_GAP_NOT_ALLOWED = 'PKU864',
|
|
63
|
+
MANIFEST_INTEGRITY_ERROR = 'PKU865',
|
|
64
|
+
|
|
65
|
+
// Model configuration errors
|
|
66
|
+
MISSING_MODEL = 'PKU145',
|
|
67
|
+
INVALID_MODEL = 'PKU146',
|
|
68
|
+
|
|
69
|
+
// Optimization diagnostics
|
|
70
|
+
SERVICES_NOT_DESTRUCTURED = 'PKU410',
|
|
71
|
+
WIRES_NOT_DESTRUCTURED = 'PKU411',
|
|
72
|
+
|
|
49
73
|
// Feature Flag
|
|
50
74
|
WORKFLOW_MULTI_QUEUE_NOT_SUPPORTED = 'PKU901',
|
|
51
75
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
export { inspect, getInitialInspectorState } from './inspector.js'
|
|
2
|
-
export { getFilesAndMethods } from './utils/get-files-and-methods.js'
|
|
3
2
|
export type { TypesMap } from './types-map.js'
|
|
4
3
|
export type * from './types.js'
|
|
5
|
-
export type {
|
|
6
|
-
export type {
|
|
7
|
-
FilesAndMethods,
|
|
8
|
-
FilesAndMethodsErrors,
|
|
9
|
-
} from './utils/get-files-and-methods.js'
|
|
4
|
+
export type { FilesAndMethodsErrors } from './utils/get-files-and-methods.js'
|
|
10
5
|
export { ErrorCode } from './error-codes.js'
|
|
11
6
|
export {
|
|
12
7
|
serializeInspectorState,
|
|
@@ -14,15 +9,30 @@ export {
|
|
|
14
9
|
} from './utils/serialize-inspector-state.js'
|
|
15
10
|
export type { SerializableInspectorState } from './utils/serialize-inspector-state.js'
|
|
16
11
|
export { filterInspectorState } from './utils/filter-inspector-state.js'
|
|
17
|
-
export { writeAllServiceMetadata } from './utils/write-service-metadata.js'
|
|
18
|
-
export type { ServiceMetadata } from './utils/extract-service-metadata.js'
|
|
19
12
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} from './utils/
|
|
13
|
+
generateCustomTypes,
|
|
14
|
+
sanitizeTypeName,
|
|
15
|
+
} from './utils/custom-types-generator.js'
|
|
16
|
+
export {
|
|
17
|
+
createEmptyManifest,
|
|
18
|
+
serializeManifest,
|
|
19
|
+
} from './utils/contract-hashes.js'
|
|
20
|
+
export type {
|
|
21
|
+
ContractEntry,
|
|
22
|
+
VersionHashEntry,
|
|
23
|
+
VersionValidateError,
|
|
24
|
+
VersionManifest,
|
|
25
|
+
VersionManifestEntry,
|
|
26
|
+
} from './utils/contract-hashes.js'
|
|
27
|
+
export { serializeMCPJson } from './utils/serialize-mcp-json.js'
|
|
28
|
+
export type { OpenAPISpecInfo } from './utils/serialize-openapi-json.js'
|
|
23
29
|
export {
|
|
24
30
|
deserializeDslWorkflow,
|
|
25
31
|
deserializeGraphWorkflow,
|
|
26
32
|
deserializeAllDslWorkflows,
|
|
27
|
-
} from './utils/workflow/dsl/
|
|
28
|
-
export
|
|
33
|
+
} from './utils/workflow/dsl/index.js'
|
|
34
|
+
export { getFilesAndMethods } from './utils/get-files-and-methods.js'
|
|
35
|
+
export type {
|
|
36
|
+
SerializedWorkflowGraph,
|
|
37
|
+
SerializedWorkflowGraphs,
|
|
38
|
+
} from './utils/workflow/graph/index.js'
|
package/src/inspector.ts
CHANGED
|
@@ -2,13 +2,41 @@ import * as ts from 'typescript'
|
|
|
2
2
|
import { performance } from 'perf_hooks'
|
|
3
3
|
import { visitSetup, visitRoutes } from './visit.js'
|
|
4
4
|
import { TypesMap } from './types-map.js'
|
|
5
|
-
import {
|
|
5
|
+
import type {
|
|
6
|
+
InspectorState,
|
|
7
|
+
InspectorLogger,
|
|
8
|
+
InspectorOptions,
|
|
9
|
+
} from './types.js'
|
|
6
10
|
import { getFilesAndMethods } from './utils/get-files-and-methods.js'
|
|
7
11
|
import { findCommonAncestor } from './utils/find-root-dir.js'
|
|
8
12
|
import {
|
|
9
13
|
aggregateRequiredServices,
|
|
10
|
-
|
|
14
|
+
validateAgentModels,
|
|
15
|
+
validateAgentOverrides,
|
|
16
|
+
validateSecretOverrides,
|
|
17
|
+
validateVariableOverrides,
|
|
18
|
+
computeResolvedIOTypes,
|
|
19
|
+
computeMiddlewareGroupsMeta,
|
|
20
|
+
computePermissionsGroupsMeta,
|
|
21
|
+
computeRequiredSchemas,
|
|
22
|
+
computeDiagnostics,
|
|
11
23
|
} from './utils/post-process.js'
|
|
24
|
+
import { generateOpenAPISpec } from './utils/serialize-openapi-json.js'
|
|
25
|
+
import { pikkuState } from '@pikku/core/internal'
|
|
26
|
+
import { resolveLatestVersions } from './utils/resolve-versions.js'
|
|
27
|
+
import { finalizeWorkflows } from './utils/workflow/graph/finalize-workflows.js'
|
|
28
|
+
import {
|
|
29
|
+
finalizeWorkflowHelperTypes,
|
|
30
|
+
finalizeWorkflowWires,
|
|
31
|
+
} from './utils/workflow/graph/finalize-workflow-wires.js'
|
|
32
|
+
import { generateAllSchemas } from './utils/schema-generator.js'
|
|
33
|
+
import {
|
|
34
|
+
computeContractHashes,
|
|
35
|
+
extractContractsFromMeta,
|
|
36
|
+
updateManifest,
|
|
37
|
+
createEmptyManifest,
|
|
38
|
+
validateContracts,
|
|
39
|
+
} from './utils/contract-hashes.js'
|
|
12
40
|
|
|
13
41
|
/**
|
|
14
42
|
* Creates an initial/empty inspector state with all required properties initialized
|
|
@@ -29,7 +57,8 @@ export function getInitialInspectorState(rootDir: string): InspectorState {
|
|
|
29
57
|
filesAndMethods: {},
|
|
30
58
|
filesAndMethodsErrors: new Map(),
|
|
31
59
|
typesLookup: new Map(),
|
|
32
|
-
|
|
60
|
+
schemaLookup: new Map(),
|
|
61
|
+
schemas: {},
|
|
33
62
|
functions: {
|
|
34
63
|
typesMap: new TypesMap(),
|
|
35
64
|
meta: {},
|
|
@@ -54,6 +83,11 @@ export function getInitialInspectorState(rootDir: string): InspectorState {
|
|
|
54
83
|
files: new Set(),
|
|
55
84
|
meta: {},
|
|
56
85
|
},
|
|
86
|
+
triggers: {
|
|
87
|
+
meta: {},
|
|
88
|
+
sourceMeta: {},
|
|
89
|
+
files: new Set(),
|
|
90
|
+
},
|
|
57
91
|
scheduledTasks: {
|
|
58
92
|
meta: {},
|
|
59
93
|
files: new Set(),
|
|
@@ -67,6 +101,7 @@ export function getInitialInspectorState(rootDir: string): InspectorState {
|
|
|
67
101
|
files: new Map(),
|
|
68
102
|
graphMeta: {},
|
|
69
103
|
graphFiles: new Map(),
|
|
104
|
+
invokedWorkflows: new Set(),
|
|
70
105
|
},
|
|
71
106
|
rpc: {
|
|
72
107
|
internalMeta: {},
|
|
@@ -74,7 +109,9 @@ export function getInitialInspectorState(rootDir: string): InspectorState {
|
|
|
74
109
|
exposedMeta: {},
|
|
75
110
|
exposedFiles: new Map(),
|
|
76
111
|
invokedFunctions: new Set(),
|
|
77
|
-
|
|
112
|
+
usedAddons: new Set(),
|
|
113
|
+
wireAddonDeclarations: new Map(),
|
|
114
|
+
wireAddonFiles: new Set(),
|
|
78
115
|
},
|
|
79
116
|
mcpEndpoints: {
|
|
80
117
|
resourcesMeta: {},
|
|
@@ -82,6 +119,10 @@ export function getInitialInspectorState(rootDir: string): InspectorState {
|
|
|
82
119
|
promptsMeta: {},
|
|
83
120
|
files: new Set(),
|
|
84
121
|
},
|
|
122
|
+
agents: {
|
|
123
|
+
agentsMeta: {},
|
|
124
|
+
files: new Map(),
|
|
125
|
+
},
|
|
85
126
|
cli: {
|
|
86
127
|
meta: {
|
|
87
128
|
programs: {},
|
|
@@ -89,20 +130,39 @@ export function getInitialInspectorState(rootDir: string): InspectorState {
|
|
|
89
130
|
},
|
|
90
131
|
files: new Set(),
|
|
91
132
|
},
|
|
92
|
-
|
|
133
|
+
nodes: {
|
|
93
134
|
meta: {},
|
|
94
135
|
files: new Set(),
|
|
95
136
|
},
|
|
96
|
-
|
|
97
|
-
|
|
137
|
+
secrets: {
|
|
138
|
+
definitions: [],
|
|
98
139
|
files: new Set(),
|
|
99
140
|
},
|
|
141
|
+
variables: {
|
|
142
|
+
definitions: [],
|
|
143
|
+
files: new Set(),
|
|
144
|
+
},
|
|
145
|
+
manifest: {
|
|
146
|
+
initial: null,
|
|
147
|
+
current: null,
|
|
148
|
+
errors: [],
|
|
149
|
+
},
|
|
100
150
|
middleware: {
|
|
101
|
-
|
|
151
|
+
definitions: {},
|
|
152
|
+
instances: {},
|
|
102
153
|
tagMiddleware: new Map(),
|
|
103
154
|
},
|
|
155
|
+
channelMiddleware: {
|
|
156
|
+
definitions: {},
|
|
157
|
+
instances: {},
|
|
158
|
+
tagMiddleware: new Map(),
|
|
159
|
+
},
|
|
160
|
+
aiMiddleware: {
|
|
161
|
+
definitions: {},
|
|
162
|
+
},
|
|
104
163
|
permissions: {
|
|
105
|
-
|
|
164
|
+
definitions: {},
|
|
165
|
+
instances: {},
|
|
106
166
|
tagPermissions: new Map(),
|
|
107
167
|
},
|
|
108
168
|
serviceAggregation: {
|
|
@@ -113,22 +173,41 @@ export function getInitialInspectorState(rootDir: string): InspectorState {
|
|
|
113
173
|
allSingletonServices: [],
|
|
114
174
|
allWireServices: [],
|
|
115
175
|
},
|
|
116
|
-
|
|
176
|
+
resolvedIOTypes: {},
|
|
177
|
+
middlewareGroupsMeta: {
|
|
178
|
+
definitions: {},
|
|
179
|
+
instances: {},
|
|
180
|
+
httpGroups: {},
|
|
181
|
+
tagGroups: {},
|
|
182
|
+
channelMiddleware: {
|
|
183
|
+
definitions: {},
|
|
184
|
+
instances: {},
|
|
185
|
+
tagGroups: {},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
permissionsGroupsMeta: {
|
|
189
|
+
definitions: {},
|
|
190
|
+
httpGroups: {},
|
|
191
|
+
tagGroups: {},
|
|
192
|
+
},
|
|
193
|
+
requiredSchemas: new Set(),
|
|
194
|
+
openAPISpec: null,
|
|
195
|
+
diagnostics: [],
|
|
117
196
|
}
|
|
118
197
|
}
|
|
119
198
|
|
|
120
|
-
export const inspect = (
|
|
199
|
+
export const inspect = async (
|
|
121
200
|
logger: InspectorLogger,
|
|
122
201
|
routeFiles: string[],
|
|
123
202
|
options: InspectorOptions = {}
|
|
124
|
-
): InspectorState => {
|
|
203
|
+
): Promise<InspectorState> => {
|
|
125
204
|
const startProgram = performance.now()
|
|
126
205
|
const program = ts.createProgram(routeFiles, {
|
|
127
206
|
target: ts.ScriptTarget.ESNext,
|
|
128
|
-
module: ts.ModuleKind.
|
|
207
|
+
module: ts.ModuleKind.Node16,
|
|
129
208
|
skipLibCheck: true,
|
|
130
209
|
skipDefaultLibCheck: true,
|
|
131
|
-
moduleResolution: ts.ModuleResolutionKind.
|
|
210
|
+
moduleResolution: ts.ModuleResolutionKind.Node16,
|
|
132
211
|
types: [],
|
|
133
212
|
allowJs: false,
|
|
134
213
|
checkJs: false,
|
|
@@ -180,6 +259,32 @@ export const inspect = (
|
|
|
180
259
|
logger.debug(
|
|
181
260
|
`Visit routes phase completed in ${(performance.now() - startRoutes).toFixed(2)}ms`
|
|
182
261
|
)
|
|
262
|
+
|
|
263
|
+
resolveLatestVersions(state, logger)
|
|
264
|
+
|
|
265
|
+
if (options.schemaConfig) {
|
|
266
|
+
state.schemas = await generateAllSchemas(
|
|
267
|
+
logger,
|
|
268
|
+
options.schemaConfig,
|
|
269
|
+
state
|
|
270
|
+
)
|
|
271
|
+
computeContractHashes(
|
|
272
|
+
state.schemas,
|
|
273
|
+
state.functions.typesMap,
|
|
274
|
+
state.functions.meta
|
|
275
|
+
)
|
|
276
|
+
computeRequiredSchemas(state, options)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
state.manifest.initial = options.manifest ?? null
|
|
280
|
+
const contracts = extractContractsFromMeta(state.functions.meta)
|
|
281
|
+
const baseManifest = state.manifest.initial ?? createEmptyManifest()
|
|
282
|
+
state.manifest.current = updateManifest(baseManifest, contracts)
|
|
283
|
+
state.manifest.errors = validateContracts(baseManifest, contracts).errors
|
|
284
|
+
|
|
285
|
+
finalizeWorkflows(state)
|
|
286
|
+
finalizeWorkflowHelperTypes(state)
|
|
287
|
+
finalizeWorkflowWires(state)
|
|
183
288
|
}
|
|
184
289
|
|
|
185
290
|
// Populate filesAndMethods
|
|
@@ -198,11 +303,26 @@ export const inspect = (
|
|
|
198
303
|
`Aggregate required services completed in ${(performance.now() - startAggregate).toFixed(2)}ms`
|
|
199
304
|
)
|
|
200
305
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
306
|
+
computeResolvedIOTypes(state)
|
|
307
|
+
computeMiddlewareGroupsMeta(state)
|
|
308
|
+
computePermissionsGroupsMeta(state)
|
|
309
|
+
computeDiagnostics(state)
|
|
310
|
+
|
|
311
|
+
if (options.openAPI) {
|
|
312
|
+
state.openAPISpec = await generateOpenAPISpec(
|
|
313
|
+
logger,
|
|
314
|
+
state.functions.meta,
|
|
315
|
+
state.http.meta,
|
|
316
|
+
state.schemas,
|
|
317
|
+
options.openAPI.additionalInfo,
|
|
318
|
+
pikkuState(null, 'misc', 'errors')
|
|
319
|
+
)
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
validateAgentModels(logger, state, options.modelConfig)
|
|
323
|
+
validateAgentOverrides(logger, state, options.modelConfig)
|
|
324
|
+
validateSecretOverrides(logger, state)
|
|
325
|
+
validateVariableOverrides(logger, state)
|
|
206
326
|
}
|
|
207
327
|
|
|
208
328
|
return state
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateAllSchemas } from './utils/schema-generator.js'
|
package/src/types-map.ts
CHANGED
|
@@ -28,7 +28,18 @@ export class TypesMap {
|
|
|
28
28
|
uniqueName: string
|
|
29
29
|
path: string | null
|
|
30
30
|
} {
|
|
31
|
-
if (
|
|
31
|
+
if (
|
|
32
|
+
[
|
|
33
|
+
'string',
|
|
34
|
+
'number',
|
|
35
|
+
'boolean',
|
|
36
|
+
'null',
|
|
37
|
+
'undefined',
|
|
38
|
+
'void',
|
|
39
|
+
'unknown',
|
|
40
|
+
'never',
|
|
41
|
+
].includes(name)
|
|
42
|
+
) {
|
|
32
43
|
return {
|
|
33
44
|
originalName: name,
|
|
34
45
|
uniqueName: name,
|