@pikku/inspector 0.12.60 → 0.12.61
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 +301 -0
- package/OPTIMIZATION-PLAN.md +19 -19
- package/dist/add/add-auth.js +1 -1
- package/dist/add/add-channel.d.ts +1 -1
- package/dist/add/add-cli.js +5 -0
- package/dist/add/add-functions.js +10 -1
- package/dist/add/add-http-route.js +18 -18
- package/dist/add/add-keyed-wiring.d.ts +2 -0
- package/dist/add/add-keyed-wiring.js +3 -1
- package/dist/add/add-personas.js +4 -1
- package/dist/add/add-secret.js +1 -0
- package/dist/add/add-variable.js +1 -0
- package/dist/add/add-wire-remote-addon.js +2 -1
- package/dist/add/add-workflow-graph.js +63 -6
- package/dist/add/add-workflow.d.ts +1 -1
- package/dist/error-codes.d.ts +3 -1
- package/dist/error-codes.js +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/inspector.js +12 -2
- package/dist/types.d.ts +25 -21
- package/dist/utils/annotate-http-route-auth.js +2 -1
- package/dist/utils/check-secret-sinks.js +2 -1
- package/dist/utils/compute-required-schemas.d.ts +1 -1
- package/dist/utils/contract-hashes.d.ts +2 -2
- package/dist/utils/contract-hashes.js +1 -1
- package/dist/utils/extract-function-name.js +1 -1
- package/dist/utils/extract-services.d.ts +1 -1
- package/dist/utils/extract-surface-usage.d.ts +29 -0
- package/dist/utils/extract-surface-usage.js +97 -0
- package/dist/utils/filter-inspector-state.js +53 -16
- package/dist/utils/filter-utils.d.ts +1 -1
- package/dist/utils/get-property-value.js +42 -3
- package/dist/utils/load-addon-functions-meta.js +31 -0
- package/dist/utils/middleware.d.ts +1 -1
- package/dist/utils/permissions.d.ts +1 -1
- package/dist/utils/post-process.d.ts +27 -7
- package/dist/utils/post-process.js +79 -14
- package/dist/utils/resolve-deploy-target.d.ts +1 -1
- package/dist/utils/resolve-function-meta.d.ts +1 -1
- package/dist/utils/resolve-function-types.d.ts +1 -1
- package/dist/utils/resolve-versions.js +1 -1
- package/dist/utils/schema-generator.d.ts +1 -1
- package/dist/utils/serialize-inspector-state.d.ts +2 -1
- package/dist/utils/serialize-inspector-state.js +2 -0
- package/dist/utils/serialize-openapi-json.d.ts +2 -2
- package/dist/utils/validate-auth-sessionless.js +2 -1
- package/dist/utils/workflow/derive-workflow-plan.d.ts +1 -1
- package/dist/utils/workflow/dsl/extract-dsl-workflow.d.ts +1 -1
- package/dist/utils/workflow/graph/convert-dsl-to-graph.d.ts +1 -1
- package/dist/utils/workflow/graph/finalize-workflows.js +1 -1
- package/dist/utils/workflow/graph/serialize-workflow-graph.d.ts +6 -1
- package/dist/utils/workflow/graph/serialize-workflow-graph.js +26 -2
- package/dist/utils/workflow/graph/workflow-graph.types.d.ts +11 -2
- package/package.json +10 -10
- package/run-tests.sh +0 -0
- package/src/add/add-agent.ts +2 -4
- package/src/add/add-auth.ts +2 -2
- package/src/add/add-channel.ts +1 -4
- package/src/add/add-cli.ts +7 -1
- package/src/add/add-credential.ts +3 -6
- package/src/add/add-file-with-factory.ts +2 -6
- package/src/add/add-functions.ts +24 -31
- package/src/add/add-gateway.ts +1 -1
- package/src/add/add-http-route-ref.test.ts +149 -0
- package/src/add/add-http-route.ts +26 -29
- package/src/add/add-keyed-wiring.ts +8 -7
- package/src/add/add-permission.ts +1 -1
- package/src/add/add-personas.test.ts +26 -2
- package/src/add/add-personas.ts +4 -3
- package/src/add/add-scenario-step.test.ts +37 -2
- package/src/add/add-scope.test.ts +15 -15
- package/src/add/add-scope.ts +5 -9
- package/src/add/add-secret.ts +1 -0
- package/src/add/add-system-role.test.ts +4 -4
- package/src/add/add-system-role.ts +2 -4
- package/src/add/add-variable.ts +1 -0
- package/src/add/add-wire-remote-addon.ts +4 -1
- package/src/add/add-workflow-graph-foreach.test.ts +174 -0
- package/src/add/add-workflow-graph-input.test.ts +1 -1
- package/src/add/add-workflow-graph.ts +78 -6
- package/src/add/add-workflow-sleep-expression.test.ts +3 -4
- package/src/add/add-workflow.ts +1 -4
- package/src/add/addon-contracts.test.ts +1 -1
- package/src/add/config-value-metadata.test.ts +94 -0
- package/src/add/secret-sink-check.test.ts +4 -1
- package/src/error-codes.ts +3 -1
- package/src/index.ts +3 -4
- package/src/inspector.ts +19 -2
- package/src/types.ts +25 -28
- package/src/utils/annotate-http-route-auth.test.ts +5 -7
- package/src/utils/annotate-http-route-auth.ts +2 -1
- package/src/utils/check-secret-sinks.ts +4 -1
- package/src/utils/compute-required-schemas.ts +1 -1
- package/src/utils/contract-hashes.test.ts +1 -1
- package/src/utils/contract-hashes.ts +3 -3
- package/src/utils/extract-function-name.ts +1 -1
- package/src/utils/extract-services.ts +1 -2
- package/src/utils/extract-surface-usage.test.ts +147 -0
- package/src/utils/extract-surface-usage.ts +121 -0
- package/src/utils/filter-inspector-state.test.ts +138 -12
- package/src/utils/filter-inspector-state.ts +82 -21
- package/src/utils/filter-utils.ts +1 -1
- package/src/utils/get-property-value.ts +43 -5
- package/src/utils/load-addon-functions-meta.ts +40 -0
- package/src/utils/middleware.ts +1 -1
- package/src/utils/permissions.ts +1 -1
- package/src/utils/post-process.test.ts +59 -2
- package/src/utils/post-process.ts +88 -25
- package/src/utils/resolve-deploy-target.ts +1 -1
- package/src/utils/resolve-function-meta.ts +1 -4
- package/src/utils/resolve-function-types.ts +1 -1
- package/src/utils/resolve-versions.ts +2 -5
- package/src/utils/schema-generator.ts +3 -3
- package/src/utils/serialize-inspector-state.ts +4 -1
- package/src/utils/serialize-mcp-json.ts +1 -1
- package/src/utils/serialize-openapi-json.ts +2 -2
- package/src/utils/validate-auth-sessionless.ts +2 -1
- package/src/utils/validate-tags-resolve-to-middleware.test.ts +4 -1
- package/src/utils/workflow/derive-workflow-plan.test.ts +1 -1
- package/src/utils/workflow/derive-workflow-plan.ts +1 -1
- package/src/utils/workflow/dsl/extract-approval-policy.test.ts +1 -1
- package/src/utils/workflow/dsl/extract-dsl-workflow.ts +2 -2
- package/src/utils/workflow/graph/convert-dsl-to-graph-skip.test.ts +1 -1
- package/src/utils/workflow/graph/convert-dsl-to-graph.ts +1 -4
- package/src/utils/workflow/graph/finalize-workflow-wires.ts +1 -1
- package/src/utils/workflow/graph/finalize-workflows.ts +2 -2
- package/src/utils/workflow/graph/serialize-workflow-graph.ts +34 -3
- package/src/utils/workflow/graph/workflow-graph.types.ts +12 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/add/add-ai-agent.d.ts +0 -4
- package/dist/add/add-ai-agent.js +0 -442
- package/dist/add/add-ai-scorer.d.ts +0 -2
- package/dist/add/add-ai-scorer.js +0 -61
- package/dist/utils/secret-brokers.d.ts +0 -2
- package/dist/utils/secret-brokers.js +0 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRef } from '@pikku/core/
|
|
1
|
+
import { isRef, template } from '@pikku/core/workflow'
|
|
2
2
|
import type {
|
|
3
3
|
SerializedWorkflowGraph,
|
|
4
4
|
SerializedGraphNode,
|
|
@@ -36,6 +36,26 @@ function serializeInputMapping(
|
|
|
36
36
|
return result
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Convert a `forEach` source — a bare node id, a ref, or a `(ref) => ref(...)`
|
|
41
|
+
* callback — to the serialized DataRef form
|
|
42
|
+
*/
|
|
43
|
+
function serializeForEach(
|
|
44
|
+
forEach: unknown,
|
|
45
|
+
createRef: (nodeId: string, path?: string) => { nodeId: string; path?: string }
|
|
46
|
+
): DataRef | undefined {
|
|
47
|
+
if (forEach === undefined) return undefined
|
|
48
|
+
if (typeof forEach === 'string') return { $ref: forEach }
|
|
49
|
+
if (typeof forEach === 'function') {
|
|
50
|
+
return serializeForEach(
|
|
51
|
+
(forEach as (ref: unknown) => unknown)(createRef),
|
|
52
|
+
createRef
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
if (isRef(forEach)) return convertRef(forEach)
|
|
56
|
+
return undefined
|
|
57
|
+
}
|
|
58
|
+
|
|
39
59
|
/**
|
|
40
60
|
* Convert next config from runtime format to serialized format
|
|
41
61
|
* Runtime uses Record<string, string | string[]> for branching with graph.branch()
|
|
@@ -73,7 +93,9 @@ export function serializeWorkflowGraph(
|
|
|
73
93
|
string,
|
|
74
94
|
{
|
|
75
95
|
func: { name?: string }
|
|
76
|
-
input?: (ref: any) => Record<string, unknown>
|
|
96
|
+
input?: (ref: any, template?: any, $item?: any) => Record<string, unknown>
|
|
97
|
+
forEach?: string | { nodeId: string; path?: string } | ((ref: any) => unknown)
|
|
98
|
+
mode?: 'parallel' | 'sequential'
|
|
77
99
|
next?: string | string[] | Record<string, string | string[]>
|
|
78
100
|
onError?: string | string[]
|
|
79
101
|
notes?: string
|
|
@@ -96,6 +118,8 @@ export function serializeWorkflowGraph(
|
|
|
96
118
|
path,
|
|
97
119
|
})
|
|
98
120
|
|
|
121
|
+
const createItemRef = (path?: string) => createRef('$item', path)
|
|
122
|
+
|
|
99
123
|
// Track which nodes have incoming edges
|
|
100
124
|
const hasIncomingEdge = new Set<string>()
|
|
101
125
|
|
|
@@ -124,7 +148,7 @@ export function serializeWorkflowGraph(
|
|
|
124
148
|
// Evaluate input callback to get the mapping
|
|
125
149
|
let input: Record<string, unknown | DataRef> = {}
|
|
126
150
|
if (node.input) {
|
|
127
|
-
const rawInput = node.input(createRef)
|
|
151
|
+
const rawInput = node.input(createRef, template, createItemRef)
|
|
128
152
|
input = serializeInputMapping(rawInput)
|
|
129
153
|
}
|
|
130
154
|
|
|
@@ -138,6 +162,13 @@ export function serializeWorkflowGraph(
|
|
|
138
162
|
next: serializeNext(node.next),
|
|
139
163
|
onError: node.onError,
|
|
140
164
|
}
|
|
165
|
+
const forEach = serializeForEach(node.forEach, createRef)
|
|
166
|
+
if (forEach) {
|
|
167
|
+
funcNode.forEach = forEach
|
|
168
|
+
if (node.mode !== undefined) {
|
|
169
|
+
funcNode.mode = node.mode
|
|
170
|
+
}
|
|
171
|
+
}
|
|
141
172
|
if (node.notes !== undefined) {
|
|
142
173
|
funcNode.notes = node.notes
|
|
143
174
|
}
|
|
@@ -115,8 +115,8 @@ import type {
|
|
|
115
115
|
ContextVariable,
|
|
116
116
|
WorkflowContext,
|
|
117
117
|
WorkflowPlannedStep,
|
|
118
|
-
} from '@pikku/core/
|
|
119
|
-
import type { ScenarioStepPhase } from '@pikku/core/
|
|
118
|
+
} from '@pikku/core/workflow'
|
|
119
|
+
import type { ScenarioStepPhase } from '@pikku/core/scenario'
|
|
120
120
|
|
|
121
121
|
export type { ContextVariable, WorkflowContext }
|
|
122
122
|
|
|
@@ -141,11 +141,21 @@ interface BaseNode {
|
|
|
141
141
|
/**
|
|
142
142
|
* Function node - calls an RPC
|
|
143
143
|
*/
|
|
144
|
+
/** How the per-item instances of a `forEach` node run */
|
|
145
|
+
export type ForEachMode = 'parallel' | 'sequential'
|
|
146
|
+
|
|
144
147
|
export interface FunctionNode extends BaseNode {
|
|
145
148
|
/** RPC function name */
|
|
146
149
|
rpcName: string
|
|
147
150
|
/** Input mapping - values can be literals or DataRefs */
|
|
148
151
|
input?: Record<string, unknown | DataRef>
|
|
152
|
+
/**
|
|
153
|
+
* Run this node once per element of the referenced array. The node's own
|
|
154
|
+
* result becomes the ordered array of per-item results.
|
|
155
|
+
*/
|
|
156
|
+
forEach?: DataRef
|
|
157
|
+
/** How the per-item instances run. Defaults to 'parallel'. */
|
|
158
|
+
mode?: ForEachMode
|
|
149
159
|
/** Output variable name for storing result */
|
|
150
160
|
outputVar?: string
|
|
151
161
|
/** Hash of nodeId + RPC input/output schemas for version detection */
|