@pikku/inspector 0.11.0 → 0.11.2
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 +32 -2
- package/dist/add/add-channel.js +11 -10
- package/dist/add/add-file-with-factory.js +10 -10
- package/dist/add/add-forge-credential.d.ts +8 -0
- package/dist/add/add-forge-credential.js +77 -0
- package/dist/add/add-forge-node.d.ts +7 -0
- package/dist/add/add-forge-node.js +77 -0
- package/dist/add/add-functions.js +158 -51
- package/dist/add/add-http-route.js +28 -4
- package/dist/add/add-mcp-prompt.js +6 -5
- package/dist/add/add-mcp-resource.js +6 -5
- package/dist/add/add-mcp-tool.js +6 -5
- package/dist/add/add-middleware.js +1 -1
- package/dist/add/add-permission.js +1 -1
- package/dist/add/add-queue-worker.js +6 -5
- package/dist/add/add-rpc-invocations.d.ts +3 -0
- package/dist/add/add-rpc-invocations.js +51 -25
- package/dist/add/add-schedule.js +5 -4
- package/dist/add/add-workflow-graph.d.ts +6 -0
- package/dist/add/add-workflow-graph.js +659 -0
- package/dist/add/add-workflow.d.ts +1 -1
- package/dist/add/add-workflow.js +191 -69
- package/dist/error-codes.d.ts +3 -0
- package/dist/error-codes.js +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -0
- package/dist/inspector.js +29 -9
- package/dist/types.d.ts +47 -8
- package/dist/utils/extract-function-name.js +7 -7
- package/dist/utils/extract-function-node.d.ts +10 -0
- package/dist/utils/extract-function-node.js +38 -0
- package/dist/utils/extract-node-value.d.ts +8 -0
- package/dist/utils/extract-node-value.js +24 -0
- package/dist/utils/extract-service-metadata.d.ts +19 -0
- package/dist/utils/extract-service-metadata.js +244 -0
- package/dist/utils/get-files-and-methods.d.ts +3 -3
- package/dist/utils/get-files-and-methods.js +3 -3
- package/dist/utils/get-property-value.d.ts +14 -6
- package/dist/utils/get-property-value.js +55 -43
- package/dist/utils/post-process.d.ts +9 -0
- package/dist/utils/post-process.js +30 -3
- package/dist/utils/serialize-inspector-state.d.ts +42 -6
- package/dist/utils/serialize-inspector-state.js +36 -10
- package/dist/utils/workflow/dsl/deserialize-dsl-workflow.d.ts +24 -0
- package/dist/utils/workflow/dsl/deserialize-dsl-workflow.js +898 -0
- package/dist/utils/workflow/dsl/extract-dsl-workflow.d.ts +17 -0
- package/dist/utils/workflow/dsl/extract-dsl-workflow.js +1284 -0
- package/dist/utils/workflow/dsl/index.d.ts +7 -0
- package/dist/utils/workflow/dsl/index.js +7 -0
- package/dist/utils/workflow/dsl/patterns.d.ts +60 -0
- package/dist/utils/workflow/dsl/patterns.js +218 -0
- package/dist/utils/workflow/dsl/validation.d.ts +30 -0
- package/dist/utils/workflow/dsl/validation.js +142 -0
- package/dist/utils/workflow/graph/convert-dsl-to-graph.d.ts +13 -0
- package/dist/utils/workflow/graph/convert-dsl-to-graph.js +316 -0
- package/dist/utils/workflow/graph/index.d.ts +6 -0
- package/dist/utils/workflow/graph/index.js +6 -0
- package/dist/utils/workflow/graph/serialize-workflow-graph.d.ts +43 -0
- package/dist/utils/workflow/graph/serialize-workflow-graph.js +152 -0
- package/dist/utils/workflow/graph/workflow-graph.types.d.ts +229 -0
- package/dist/utils/workflow/graph/workflow-graph.types.js +38 -0
- package/dist/utils/write-service-metadata.d.ts +13 -0
- package/dist/utils/write-service-metadata.js +37 -0
- package/dist/visit.js +8 -2
- package/package.json +16 -4
- package/src/add/add-channel.ts +37 -17
- package/src/add/add-file-with-factory.ts +10 -10
- package/src/add/add-forge-credential.ts +119 -0
- package/src/add/add-forge-node.ts +132 -0
- package/src/add/add-functions.ts +199 -69
- package/src/add/add-http-route.ts +34 -5
- package/src/add/add-mcp-prompt.ts +11 -7
- package/src/add/add-mcp-resource.ts +11 -7
- package/src/add/add-mcp-tool.ts +11 -7
- package/src/add/add-middleware.ts +1 -1
- package/src/add/add-permission.ts +1 -1
- package/src/add/add-queue-worker.ts +11 -12
- package/src/add/add-rpc-invocations.ts +61 -31
- package/src/add/add-schedule.ts +10 -5
- package/src/add/add-workflow-graph.ts +864 -0
- package/src/add/add-workflow.ts +212 -116
- package/src/error-codes.ts +3 -0
- package/src/index.ts +12 -0
- package/src/inspector.ts +36 -10
- package/src/types.ts +43 -9
- package/src/utils/extract-function-name.ts +7 -7
- package/src/utils/extract-function-node.ts +58 -0
- package/src/utils/extract-node-value.ts +31 -0
- package/src/utils/extract-service-metadata.ts +353 -0
- package/src/utils/filter-inspector-state.test.ts +3 -3
- package/src/utils/filter-utils.test.ts +45 -51
- package/src/utils/get-files-and-methods.ts +11 -11
- package/src/utils/get-property-value.ts +67 -53
- package/src/utils/permissions.test.ts +3 -3
- package/src/utils/post-process.ts +56 -3
- package/src/utils/serialize-inspector-state.ts +67 -19
- package/src/utils/test-data/inspector-state.json +9 -9
- package/src/utils/workflow/dsl/deserialize-dsl-workflow.ts +1180 -0
- package/src/utils/workflow/dsl/extract-dsl-workflow.ts +1608 -0
- package/src/utils/workflow/dsl/index.ts +11 -0
- package/src/utils/workflow/dsl/patterns.ts +279 -0
- package/src/utils/workflow/dsl/validation.ts +180 -0
- package/src/utils/workflow/graph/convert-dsl-to-graph.ts +415 -0
- package/src/utils/workflow/graph/index.ts +6 -0
- package/src/utils/workflow/graph/serialize-workflow-graph.ts +223 -0
- package/src/utils/workflow/graph/workflow-graph.types.ts +280 -0
- package/src/utils/write-service-metadata.ts +51 -0
- package/src/visit.ts +9 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import {
|
|
3
3
|
getPropertyValue,
|
|
4
|
-
|
|
4
|
+
getCommonWireMetaData,
|
|
5
5
|
} from '../utils/get-property-value.js'
|
|
6
6
|
import { extractWireNames } from '../utils/post-process.js'
|
|
7
7
|
import { ensureFunctionMetadata } from '../utils/ensure-function-metadata.js'
|
|
@@ -40,10 +40,12 @@ export const addMCPPrompt: AddWiring = (
|
|
|
40
40
|
const obj = firstArg
|
|
41
41
|
|
|
42
42
|
const nameValue = getPropertyValue(obj, 'name') as string | null
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const { tags, summary, description, errors } = getCommonWireMetaData(
|
|
44
|
+
obj,
|
|
45
|
+
'MCP prompt',
|
|
46
|
+
nameValue,
|
|
47
|
+
logger
|
|
48
|
+
)
|
|
47
49
|
|
|
48
50
|
const funcInitializer = getPropertyAssignmentInitializer(
|
|
49
51
|
obj,
|
|
@@ -76,7 +78,7 @@ export const addMCPPrompt: AddWiring = (
|
|
|
76
78
|
return
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
if (!
|
|
81
|
+
if (!description) {
|
|
80
82
|
logger.critical(
|
|
81
83
|
ErrorCode.MISSING_DESCRIPTION,
|
|
82
84
|
`MCP prompt '${nameValue}' is missing a description.`
|
|
@@ -116,7 +118,9 @@ export const addMCPPrompt: AddWiring = (
|
|
|
116
118
|
state.mcpEndpoints.promptsMeta[nameValue] = {
|
|
117
119
|
pikkuFuncName,
|
|
118
120
|
name: nameValue,
|
|
119
|
-
description
|
|
121
|
+
description,
|
|
122
|
+
summary,
|
|
123
|
+
errors,
|
|
120
124
|
tags,
|
|
121
125
|
inputSchema,
|
|
122
126
|
outputSchema,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import {
|
|
3
3
|
getPropertyValue,
|
|
4
|
-
|
|
4
|
+
getCommonWireMetaData,
|
|
5
5
|
} from '../utils/get-property-value.js'
|
|
6
6
|
import { extractWireNames } from '../utils/post-process.js'
|
|
7
7
|
import { ensureFunctionMetadata } from '../utils/ensure-function-metadata.js'
|
|
@@ -41,11 +41,13 @@ export const addMCPResource: AddWiring = (
|
|
|
41
41
|
|
|
42
42
|
const uriValue = getPropertyValue(obj, 'uri') as string | null
|
|
43
43
|
const titleValue = getPropertyValue(obj, 'title') as string | null
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const { tags, summary, description, errors } = getCommonWireMetaData(
|
|
45
|
+
obj,
|
|
46
|
+
'MCP resource',
|
|
47
|
+
uriValue,
|
|
48
|
+
logger
|
|
49
|
+
)
|
|
47
50
|
const streamingValue = getPropertyValue(obj, 'streaming') as boolean | null
|
|
48
|
-
const tags = getPropertyTags(obj, 'MCP resource', uriValue, logger)
|
|
49
51
|
|
|
50
52
|
if (streamingValue === true) {
|
|
51
53
|
logger.warn(
|
|
@@ -92,7 +94,7 @@ export const addMCPResource: AddWiring = (
|
|
|
92
94
|
return
|
|
93
95
|
}
|
|
94
96
|
|
|
95
|
-
if (!
|
|
97
|
+
if (!description) {
|
|
96
98
|
logger.critical(
|
|
97
99
|
ErrorCode.MISSING_DESCRIPTION,
|
|
98
100
|
`MCP resource '${uriValue}' is missing a description.`
|
|
@@ -133,7 +135,9 @@ export const addMCPResource: AddWiring = (
|
|
|
133
135
|
pikkuFuncName,
|
|
134
136
|
uri: uriValue,
|
|
135
137
|
title: titleValue,
|
|
136
|
-
description
|
|
138
|
+
description,
|
|
139
|
+
summary,
|
|
140
|
+
errors,
|
|
137
141
|
...(streamingValue !== null && { streaming: streamingValue }),
|
|
138
142
|
tags,
|
|
139
143
|
inputSchema,
|
package/src/add/add-mcp-tool.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import {
|
|
3
3
|
getPropertyValue,
|
|
4
|
-
|
|
4
|
+
getCommonWireMetaData,
|
|
5
5
|
} from '../utils/get-property-value.js'
|
|
6
6
|
import { extractWireNames } from '../utils/post-process.js'
|
|
7
7
|
import { ensureFunctionMetadata } from '../utils/ensure-function-metadata.js'
|
|
@@ -41,11 +41,13 @@ export const addMCPTool: AddWiring = (
|
|
|
41
41
|
|
|
42
42
|
const nameValue = getPropertyValue(obj, 'name') as string | null
|
|
43
43
|
const titleValue = getPropertyValue(obj, 'title') as string | null
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const { tags, summary, description, errors } = getCommonWireMetaData(
|
|
45
|
+
obj,
|
|
46
|
+
'MCP tool',
|
|
47
|
+
nameValue,
|
|
48
|
+
logger
|
|
49
|
+
)
|
|
47
50
|
const streamingValue = getPropertyValue(obj, 'streaming') as boolean | null
|
|
48
|
-
const tags = getPropertyTags(obj, 'MCP tool', nameValue, logger)
|
|
49
51
|
|
|
50
52
|
if (streamingValue === true) {
|
|
51
53
|
logger.warn(
|
|
@@ -84,7 +86,7 @@ export const addMCPTool: AddWiring = (
|
|
|
84
86
|
return
|
|
85
87
|
}
|
|
86
88
|
|
|
87
|
-
if (!
|
|
89
|
+
if (!description) {
|
|
88
90
|
logger.critical(
|
|
89
91
|
ErrorCode.MISSING_DESCRIPTION,
|
|
90
92
|
`MCP tool '${nameValue}' is missing a description.`
|
|
@@ -125,7 +127,9 @@ export const addMCPTool: AddWiring = (
|
|
|
125
127
|
pikkuFuncName,
|
|
126
128
|
name: nameValue,
|
|
127
129
|
title: titleValue || undefined,
|
|
128
|
-
description
|
|
130
|
+
description,
|
|
131
|
+
summary,
|
|
132
|
+
errors,
|
|
129
133
|
...(streamingValue !== null && { streaming: streamingValue }),
|
|
130
134
|
tags,
|
|
131
135
|
inputSchema,
|
|
@@ -125,7 +125,7 @@ export const addMiddleware: AddWiring = (logger, node, checker, state) => {
|
|
|
125
125
|
}
|
|
126
126
|
} else {
|
|
127
127
|
// No pikkuMiddleware wrapper found - extract from factory's return value directly
|
|
128
|
-
// Factory pattern: (config) => (services,
|
|
128
|
+
// Factory pattern: (config) => (services, wire, next) => { ... }
|
|
129
129
|
if (
|
|
130
130
|
ts.isArrowFunction(factoryNode) ||
|
|
131
131
|
ts.isFunctionExpression(factoryNode)
|
|
@@ -125,7 +125,7 @@ export const addPermission: AddWiring = (logger, node, checker, state) => {
|
|
|
125
125
|
}
|
|
126
126
|
} else {
|
|
127
127
|
// No pikkuPermission wrapper found - extract from factory's return value directly
|
|
128
|
-
// Factory pattern: (config) => (services, data,
|
|
128
|
+
// Factory pattern: (config) => (services, data, wire) => { ... }
|
|
129
129
|
if (
|
|
130
130
|
ts.isArrowFunction(factoryNode) ||
|
|
131
131
|
ts.isFunctionExpression(factoryNode)
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import {
|
|
3
3
|
getPropertyValue,
|
|
4
|
-
|
|
4
|
+
getCommonWireMetaData,
|
|
5
5
|
} from '../utils/get-property-value.js'
|
|
6
|
-
import { PikkuDocs } from '@pikku/core'
|
|
7
6
|
import { AddWiring } from '../types.js'
|
|
8
7
|
import { extractFunctionName } from '../utils/extract-function-name.js'
|
|
9
8
|
import { getPropertyAssignmentInitializer } from '../utils/type-utils.js'
|
|
@@ -11,13 +10,7 @@ import { resolveMiddleware } from '../utils/middleware.js'
|
|
|
11
10
|
import { extractWireNames } from '../utils/post-process.js'
|
|
12
11
|
import { ErrorCode } from '../error-codes.js'
|
|
13
12
|
|
|
14
|
-
export const addQueueWorker: AddWiring = (
|
|
15
|
-
logger,
|
|
16
|
-
node,
|
|
17
|
-
checker,
|
|
18
|
-
state,
|
|
19
|
-
options
|
|
20
|
-
) => {
|
|
13
|
+
export const addQueueWorker: AddWiring = (logger, node, checker, state) => {
|
|
21
14
|
if (!ts.isCallExpression(node)) {
|
|
22
15
|
return
|
|
23
16
|
}
|
|
@@ -39,8 +32,12 @@ export const addQueueWorker: AddWiring = (
|
|
|
39
32
|
const obj = firstArg
|
|
40
33
|
|
|
41
34
|
const queueName = getPropertyValue(obj, 'queueName') as string | null
|
|
42
|
-
const
|
|
43
|
-
|
|
35
|
+
const { tags, summary, description, errors } = getCommonWireMetaData(
|
|
36
|
+
obj,
|
|
37
|
+
'Queue worker',
|
|
38
|
+
queueName,
|
|
39
|
+
logger
|
|
40
|
+
)
|
|
44
41
|
|
|
45
42
|
// --- find the referenced function ---
|
|
46
43
|
const funcInitializer = getPropertyAssignmentInitializer(
|
|
@@ -84,7 +81,9 @@ export const addQueueWorker: AddWiring = (
|
|
|
84
81
|
state.queueWorkers.meta[queueName] = {
|
|
85
82
|
pikkuFuncName,
|
|
86
83
|
queueName,
|
|
87
|
-
|
|
84
|
+
summary,
|
|
85
|
+
description,
|
|
86
|
+
errors,
|
|
88
87
|
tags,
|
|
89
88
|
middleware,
|
|
90
89
|
}
|
|
@@ -1,48 +1,78 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import { InspectorState, InspectorLogger } from '../types.js'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Helper to extract namespace from a namespaced function reference like 'ext:hello'
|
|
6
|
+
*/
|
|
7
|
+
function extractNamespace(functionRef: string): string | null {
|
|
8
|
+
const colonIndex = functionRef.indexOf(':')
|
|
9
|
+
if (colonIndex !== -1) {
|
|
10
|
+
return functionRef.substring(0, colonIndex)
|
|
11
|
+
}
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
|
|
4
15
|
/**
|
|
5
16
|
* Scan for rpc.invoke() calls to track which functions are actually being invoked
|
|
17
|
+
* Also detects external package usage via:
|
|
18
|
+
* - Namespaced calls: rpc.invoke('namespace:function')
|
|
19
|
+
* - External helper: external('namespace:function')
|
|
6
20
|
*/
|
|
7
21
|
export function addRPCInvocations(
|
|
8
22
|
node: ts.Node,
|
|
9
23
|
state: InspectorState,
|
|
10
24
|
logger: InspectorLogger
|
|
11
25
|
) {
|
|
12
|
-
// Look for
|
|
13
|
-
if (ts.
|
|
14
|
-
const { expression,
|
|
26
|
+
// Look for call expressions: external('ext:hello') or rpc.invoke('...')
|
|
27
|
+
if (ts.isCallExpression(node)) {
|
|
28
|
+
const { expression, arguments: args } = node
|
|
29
|
+
|
|
30
|
+
// Check for external('namespace:function') calls
|
|
31
|
+
if (ts.isIdentifier(expression) && expression.text === 'external') {
|
|
32
|
+
const [firstArg] = args
|
|
33
|
+
if (firstArg && ts.isStringLiteral(firstArg)) {
|
|
34
|
+
const functionRef = firstArg.text
|
|
35
|
+
logger.debug(`• Found external() call: ${functionRef}`)
|
|
36
|
+
state.rpc.invokedFunctions.add(functionRef)
|
|
15
37
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
)
|
|
43
|
-
}
|
|
38
|
+
const namespace = extractNamespace(functionRef)
|
|
39
|
+
if (namespace) {
|
|
40
|
+
logger.debug(` → External package detected: ${namespace}`)
|
|
41
|
+
state.rpc.usedExternalPackages.add(namespace)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Check for rpc.invoke('...') calls
|
|
47
|
+
if (
|
|
48
|
+
ts.isPropertyAccessExpression(expression) &&
|
|
49
|
+
expression.name.text === 'invoke' &&
|
|
50
|
+
ts.isIdentifier(expression.expression) &&
|
|
51
|
+
expression.expression.text === 'rpc'
|
|
52
|
+
) {
|
|
53
|
+
const [firstArg] = args
|
|
54
|
+
if (firstArg) {
|
|
55
|
+
if (ts.isStringLiteral(firstArg)) {
|
|
56
|
+
const functionRef = firstArg.text
|
|
57
|
+
logger.debug(`• Found RPC invocation: ${functionRef}`)
|
|
58
|
+
state.rpc.invokedFunctions.add(functionRef)
|
|
59
|
+
|
|
60
|
+
const namespace = extractNamespace(functionRef)
|
|
61
|
+
if (namespace) {
|
|
62
|
+
logger.debug(` → External package detected: ${namespace}`)
|
|
63
|
+
state.rpc.usedExternalPackages.add(namespace)
|
|
44
64
|
}
|
|
45
65
|
}
|
|
66
|
+
// Handle template literals like `function-${name}`
|
|
67
|
+
else if (
|
|
68
|
+
ts.isTemplateExpression(firstArg) ||
|
|
69
|
+
ts.isNoSubstitutionTemplateLiteral(firstArg)
|
|
70
|
+
) {
|
|
71
|
+
logger.warn(`• Found dynamic RPC invocation: ${firstArg.getText()}`)
|
|
72
|
+
logger.warn(
|
|
73
|
+
`\tYou can only use string literals for RPC function names, with ' or " and not \``
|
|
74
|
+
)
|
|
75
|
+
}
|
|
46
76
|
}
|
|
47
77
|
}
|
|
48
78
|
}
|
package/src/add/add-schedule.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import {
|
|
3
3
|
getPropertyValue,
|
|
4
|
-
|
|
4
|
+
getCommonWireMetaData,
|
|
5
5
|
} from '../utils/get-property-value.js'
|
|
6
|
-
import { PikkuDocs } from '@pikku/core'
|
|
7
6
|
import { AddWiring } from '../types.js'
|
|
8
7
|
import { extractFunctionName } from '../utils/extract-function-name.js'
|
|
9
8
|
import { getPropertyAssignmentInitializer } from '../utils/type-utils.js'
|
|
@@ -40,8 +39,12 @@ export const addSchedule: AddWiring = (
|
|
|
40
39
|
|
|
41
40
|
const nameValue = getPropertyValue(obj, 'name') as string | null
|
|
42
41
|
const scheduleValue = getPropertyValue(obj, 'schedule') as string | null
|
|
43
|
-
const
|
|
44
|
-
|
|
42
|
+
const { tags, summary, description, errors } = getCommonWireMetaData(
|
|
43
|
+
obj,
|
|
44
|
+
'Scheduler',
|
|
45
|
+
nameValue,
|
|
46
|
+
logger
|
|
47
|
+
)
|
|
45
48
|
|
|
46
49
|
const funcInitializer = getPropertyAssignmentInitializer(
|
|
47
50
|
obj,
|
|
@@ -81,7 +84,9 @@ export const addSchedule: AddWiring = (
|
|
|
81
84
|
pikkuFuncName,
|
|
82
85
|
name: nameValue,
|
|
83
86
|
schedule: scheduleValue,
|
|
84
|
-
|
|
87
|
+
summary,
|
|
88
|
+
description,
|
|
89
|
+
errors,
|
|
85
90
|
tags,
|
|
86
91
|
middleware,
|
|
87
92
|
}
|