@pikku/inspector 0.12.58 → 0.12.60

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 (103) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/dist/add/add-agent-scorer.d.ts +2 -0
  3. package/dist/add/add-agent-scorer.js +61 -0
  4. package/dist/add/add-agent.d.ts +4 -0
  5. package/dist/add/add-agent.js +442 -0
  6. package/dist/add/add-channel.d.ts +1 -1
  7. package/dist/add/add-functions.js +1 -1
  8. package/dist/add/add-keyed-wiring.js +1 -1
  9. package/dist/add/add-middleware.js +5 -5
  10. package/dist/add/add-personas.js +1 -1
  11. package/dist/add/add-wire-addon.js +10 -0
  12. package/dist/add/add-workflow.d.ts +1 -1
  13. package/dist/error-codes.d.ts +1 -0
  14. package/dist/error-codes.js +1 -0
  15. package/dist/inspector.js +1 -1
  16. package/dist/types.d.ts +27 -22
  17. package/dist/utils/compute-required-schemas.d.ts +1 -1
  18. package/dist/utils/contract-hashes.d.ts +2 -1
  19. package/dist/utils/contract-hashes.js +1 -1
  20. package/dist/utils/extract-function-name.js +1 -1
  21. package/dist/utils/extract-services.d.ts +1 -1
  22. package/dist/utils/filter-inspector-state.js +1 -1
  23. package/dist/utils/filter-utils.d.ts +1 -1
  24. package/dist/utils/middleware.d.ts +2 -2
  25. package/dist/utils/middleware.js +5 -5
  26. package/dist/utils/permissions.d.ts +1 -1
  27. package/dist/utils/post-process.d.ts +2 -2
  28. package/dist/utils/post-process.js +24 -12
  29. package/dist/utils/resolve-deploy-target.d.ts +1 -1
  30. package/dist/utils/resolve-function-meta.d.ts +1 -1
  31. package/dist/utils/resolve-function-types.d.ts +1 -1
  32. package/dist/utils/resolve-versions.js +1 -1
  33. package/dist/utils/schema-generator.d.ts +1 -1
  34. package/dist/utils/serialize-inspector-state.d.ts +5 -3
  35. package/dist/utils/serialize-inspector-state.js +4 -4
  36. package/dist/utils/serialize-openapi-json.d.ts +2 -2
  37. package/dist/utils/workflow/derive-workflow-plan.d.ts +1 -1
  38. package/dist/utils/workflow/dsl/extract-dsl-workflow.d.ts +1 -1
  39. package/dist/utils/workflow/graph/convert-dsl-to-graph.d.ts +1 -1
  40. package/dist/utils/workflow/graph/finalize-workflows.js +1 -1
  41. package/dist/utils/workflow/graph/serialize-workflow-graph.js +1 -1
  42. package/dist/utils/workflow/graph/workflow-graph.types.d.ts +2 -1
  43. package/dist/visit.js +4 -4
  44. package/package.json +3 -3
  45. package/src/add/{add-ai-scorer.test.ts → add-agent-scorer.test.ts} +11 -11
  46. package/src/add/{add-ai-scorer.ts → add-agent-scorer.ts} +4 -4
  47. package/src/add/{add-ai-agent.test.ts → add-agent.test.ts} +1 -1
  48. package/src/add/{add-ai-agent.ts → add-agent.ts} +11 -17
  49. package/src/add/add-auth.ts +1 -1
  50. package/src/add/add-channel.ts +4 -1
  51. package/src/add/add-cli.ts +1 -1
  52. package/src/add/add-functions.ts +9 -4
  53. package/src/add/add-gateway.ts +1 -1
  54. package/src/add/add-http-route.ts +1 -1
  55. package/src/add/add-keyed-wiring.ts +1 -1
  56. package/src/add/add-middleware.ts +7 -5
  57. package/src/add/add-permission.ts +1 -1
  58. package/src/add/add-personas.test.ts +2 -2
  59. package/src/add/add-personas.ts +3 -2
  60. package/src/add/add-scenario-step.test.ts +2 -1
  61. package/src/add/add-scope.test.ts +19 -19
  62. package/src/add/add-scope.ts +1 -1
  63. package/src/add/add-system-role.test.ts +12 -12
  64. package/src/add/add-wire-addon.test.ts +31 -0
  65. package/src/add/add-wire-addon.ts +8 -0
  66. package/src/add/add-workflow-graph-input.test.ts +1 -1
  67. package/src/add/add-workflow.ts +4 -1
  68. package/src/add/addon-contracts.test.ts +1 -1
  69. package/src/error-codes.ts +1 -0
  70. package/src/inspector.ts +1 -1
  71. package/src/types.ts +33 -23
  72. package/src/utils/compute-required-schemas.ts +1 -1
  73. package/src/utils/contract-hashes.test.ts +1 -1
  74. package/src/utils/contract-hashes.ts +3 -2
  75. package/src/utils/extract-function-name.ts +1 -1
  76. package/src/utils/extract-services.ts +4 -1
  77. package/src/utils/filter-inspector-state.ts +2 -2
  78. package/src/utils/filter-utils.ts +1 -1
  79. package/src/utils/middleware.test.ts +23 -23
  80. package/src/utils/middleware.ts +6 -6
  81. package/src/utils/permissions.ts +1 -1
  82. package/src/utils/post-process.test.ts +76 -9
  83. package/src/utils/post-process.ts +36 -14
  84. package/src/utils/resolve-deploy-target.ts +1 -1
  85. package/src/utils/resolve-function-meta.ts +4 -1
  86. package/src/utils/resolve-function-types.ts +1 -1
  87. package/src/utils/resolve-versions.ts +5 -2
  88. package/src/utils/schema-generator.ts +3 -2
  89. package/src/utils/serialize-inspector-state.ts +9 -7
  90. package/src/utils/serialize-mcp-json.ts +1 -1
  91. package/src/utils/serialize-openapi-json.ts +2 -2
  92. package/src/utils/workflow/derive-workflow-plan.test.ts +1 -1
  93. package/src/utils/workflow/derive-workflow-plan.ts +1 -1
  94. package/src/utils/workflow/dsl/extract-approval-policy.test.ts +5 -2
  95. package/src/utils/workflow/dsl/extract-dsl-workflow.ts +2 -2
  96. package/src/utils/workflow/graph/convert-dsl-to-graph-skip.test.ts +1 -1
  97. package/src/utils/workflow/graph/convert-dsl-to-graph.ts +4 -1
  98. package/src/utils/workflow/graph/finalize-workflow-wires.ts +1 -1
  99. package/src/utils/workflow/graph/finalize-workflows.ts +6 -2
  100. package/src/utils/workflow/graph/serialize-workflow-graph.ts +1 -1
  101. package/src/utils/workflow/graph/workflow-graph.types.ts +2 -2
  102. package/src/visit.ts +4 -4
  103. package/tsconfig.tsbuildinfo +1 -1
@@ -9,7 +9,7 @@ import type {
9
9
  FunctionServicesMeta,
10
10
  MiddlewareMetadata,
11
11
  PermissionMetadata,
12
- } from '@pikku/core'
12
+ } from '@pikku/core/ecosystem/types'
13
13
  import type ts from 'typescript'
14
14
  import { existsSync, readFileSync } from 'node:fs'
15
15
  import { join } from 'node:path'
@@ -18,8 +18,8 @@ import { ErrorCode } from '../error-codes.js'
18
18
  import { findSecretAliasServices } from './secret-alias-services.js'
19
19
  import { relative } from 'node:path'
20
20
  import { AUTH_HANDLER_FUNC_ID } from '../add/add-auth.js'
21
- import { flattenScopeDefinitions } from '@pikku/core/scope'
22
- import type { WorkflowStepMeta } from '@pikku/core/workflow'
21
+ import { flattenScopeDefinitions } from '@pikku/core/ecosystem/scope'
22
+ import type { WorkflowStepMeta } from '@pikku/core/ecosystem/workflow'
23
23
  import { DYNAMIC_SCENARIO_STEP_TARGET } from './workflow/dsl/patterns.js'
24
24
 
25
25
  /**
@@ -308,12 +308,12 @@ export function aggregateRequiredServices(
308
308
  }
309
309
  }
310
310
 
311
- // AI agents need aiStorage + aiRunState + agentRunService + aiAgentRunner
311
+ // AI agents need agentStorage + agentRunState + agentRunService + agentRunner
312
312
  if (Object.keys(state.agents.agentsMeta).length > 0) {
313
- requiredServices.add('aiStorage')
314
- requiredServices.add('aiRunState')
313
+ requiredServices.add('agentStorage')
314
+ requiredServices.add('agentRunState')
315
315
  requiredServices.add('agentRunService')
316
- requiredServices.add('aiAgentRunner')
316
+ requiredServices.add('agentRunner')
317
317
  }
318
318
 
319
319
  // Channels need eventHub for pub/sub
@@ -383,10 +383,8 @@ export function validateSecretOverrides(
383
383
  )
384
384
 
385
385
  for (const [namespace, addonDecl] of wireAddonDeclarations.entries()) {
386
- if (!addonDecl.secretOverrides) continue
387
-
388
386
  for (const [logicalName, resolvedName] of Object.entries(
389
- addonDecl.secretOverrides
387
+ addonDecl.secretOverrides ?? {}
390
388
  )) {
391
389
  if (!secretIds.has(resolvedName)) {
392
390
  const availableSecrets = Array.from(secretIds)
@@ -396,6 +394,20 @@ export function validateSecretOverrides(
396
394
  )
397
395
  }
398
396
  }
397
+
398
+ // A grant names the secret as the addon reads it, so it resolves through
399
+ // the override map before it can be looked up in the project.
400
+ for (const logicalName of addonDecl.secretGrants ?? []) {
401
+ const resolvedName =
402
+ addonDecl.secretOverrides?.[logicalName] ?? logicalName
403
+ if (!secretIds.has(resolvedName)) {
404
+ const availableSecrets = Array.from(secretIds)
405
+ logger.critical(
406
+ ErrorCode.INVALID_VALUE,
407
+ `Secret grant '${logicalName}' in addon '${namespace}' (${addonDecl.package}) targets a secret that does not exist. Available secrets: ${availableSecrets.join(', ') || 'none'}`
408
+ )
409
+ }
410
+ }
399
411
  }
400
412
  }
401
413
 
@@ -411,10 +423,8 @@ export function validateCredentialOverrides(
411
423
  )
412
424
 
413
425
  for (const [namespace, addonDecl] of wireAddonDeclarations.entries()) {
414
- if (!addonDecl.credentialOverrides) continue
415
-
416
426
  for (const [logicalName, resolvedName] of Object.entries(
417
- addonDecl.credentialOverrides
427
+ addonDecl.credentialOverrides ?? {}
418
428
  )) {
419
429
  if (!credentialNames.has(resolvedName)) {
420
430
  const availableCredentials = Array.from(credentialNames)
@@ -424,6 +434,18 @@ export function validateCredentialOverrides(
424
434
  )
425
435
  }
426
436
  }
437
+
438
+ for (const logicalName of addonDecl.credentialGrants ?? []) {
439
+ const resolvedName =
440
+ addonDecl.credentialOverrides?.[logicalName] ?? logicalName
441
+ if (!credentialNames.has(resolvedName)) {
442
+ const availableCredentials = Array.from(credentialNames)
443
+ logger.critical(
444
+ ErrorCode.INVALID_VALUE,
445
+ `Credential grant '${logicalName}' in addon '${namespace}' (${addonDecl.package}) targets a credential that does not exist. Available credentials: ${availableCredentials.join(', ') || 'none'}`
446
+ )
447
+ }
448
+ }
427
449
  }
428
450
  }
429
451
 
@@ -1208,7 +1230,7 @@ export function validateScopeReferences(
1208
1230
  *
1209
1231
  * The description check is separate and opt-in (`--strict-meta`), because the
1210
1232
  * description is what the model is told the tool does: without one, the tool is
1211
- * offered to it under its own name (`ai-agent-prepare.ts`), which is a silent
1233
+ * offered to it under its own name (`agent-prepare.ts`), which is a silent
1212
1234
  * quality loss rather than a failure. A title deliberately does not satisfy it —
1213
1235
  * a title labels a tool in a UI, it does not tell a model when to reach for it.
1214
1236
  */
@@ -1,4 +1,4 @@
1
- import type { FunctionMeta } from '@pikku/core'
1
+ import type { FunctionMeta } from '@pikku/core/ecosystem/services'
2
2
 
3
3
  /**
4
4
  * Thrown when a function's explicit `deploy: 'serverless'` conflicts
@@ -1,4 +1,7 @@
1
- import type { FunctionMeta, FunctionsMeta } from '@pikku/core'
1
+ import type {
2
+ FunctionMeta,
3
+ FunctionsMeta,
4
+ } from '@pikku/core/ecosystem/services'
2
5
 
3
6
  /**
4
7
  * Look up function metadata by pikkuFuncId, checking both local functions
@@ -1,5 +1,5 @@
1
1
  import type { TypesMap } from '../types-map.js'
2
- import type { FunctionsMeta } from '@pikku/core'
2
+ import type { FunctionsMeta } from '@pikku/core/ecosystem/services'
3
3
 
4
4
  export function resolveFunctionIOTypes(
5
5
  pikkuFuncId: string,
@@ -1,5 +1,8 @@
1
- import { parseVersionedId, formatVersionedId } from '@pikku/core'
2
- import type { CLICommandMeta } from '@pikku/core/cli'
1
+ import {
2
+ parseVersionedId,
3
+ formatVersionedId,
4
+ } from '@pikku/core/ecosystem/types'
5
+ import type { CLICommandMeta } from '@pikku/core/ecosystem/cli'
3
6
  import type { InspectorState, InspectorLogger } from '../types.js'
4
7
  import { ErrorCode } from '../error-codes.js'
5
8
 
@@ -12,8 +12,9 @@ import { createGenerator, RootlessError } from 'ts-json-schema-generator'
12
12
  import { register } from 'tsx/esm/api'
13
13
  import * as z from 'zod'
14
14
  import { zodToTs, createAuxiliaryTypeStore } from 'zod-to-ts'
15
- import type { FunctionsMeta, JSONValue } from '@pikku/core'
16
- import type { HTTPWiringsMeta } from '@pikku/core/http'
15
+ import type { FunctionsMeta } from '@pikku/core/ecosystem/services'
16
+ import type { JSONValue } from '@pikku/core/ecosystem/types'
17
+ import type { HTTPWiringsMeta } from '@pikku/core/ecosystem/http'
17
18
  import type { TypesMap } from '../types-map.js'
18
19
  import { ErrorCode } from '../error-codes.js'
19
20
  import type { InspectorLogger, InspectorState, SchemaRef } from '../types.js'
@@ -1,5 +1,5 @@
1
1
  import type { SecretUsage } from './extract-secret-usage.js'
2
- import type { JSONValue } from '@pikku/core'
2
+ import type { JSONValue } from '@pikku/core/ecosystem/types'
3
3
  import type {
4
4
  InspectorDiagnostic,
5
5
  InspectorFeature,
@@ -170,6 +170,8 @@ export interface SerializableInspectorState {
170
170
  secretOverrides?: Record<string, string>
171
171
  variableOverrides?: Record<string, string>
172
172
  credentialOverrides?: Record<string, string>
173
+ secretGrants?: string[]
174
+ credentialGrants?: string[]
173
175
  globalSecrets?: string
174
176
  globalCredentials?: string
175
177
  },
@@ -261,8 +263,8 @@ export interface SerializableInspectorState {
261
263
  ]
262
264
  >
263
265
  }
264
- aiMiddleware: {
265
- definitions: InspectorState['aiMiddleware']['definitions']
266
+ agentMiddleware: {
267
+ definitions: InspectorState['agentMiddleware']['definitions']
266
268
  }
267
269
  permissions: {
268
270
  definitions: InspectorState['permissions']['definitions']
@@ -471,8 +473,8 @@ export function serializeInspectorState(
471
473
  state.channelMiddleware.tagMiddleware.entries()
472
474
  ),
473
475
  },
474
- aiMiddleware: {
475
- definitions: state.aiMiddleware.definitions,
476
+ agentMiddleware: {
477
+ definitions: state.agentMiddleware.definitions,
476
478
  },
477
479
  permissions: {
478
480
  definitions: state.permissions.definitions,
@@ -677,8 +679,8 @@ export function deserializeInspectorState(
677
679
  instances: data.channelMiddleware?.instances || {},
678
680
  tagMiddleware: new Map(data.channelMiddleware?.tagMiddleware || []),
679
681
  },
680
- aiMiddleware: {
681
- definitions: data.aiMiddleware?.definitions || {},
682
+ agentMiddleware: {
683
+ definitions: data.agentMiddleware?.definitions || {},
682
684
  },
683
685
  permissions: {
684
686
  definitions: data.permissions.definitions,
@@ -1,5 +1,5 @@
1
1
  import type { InspectorLogger, InspectorState } from '../types.js'
2
- import type { JSONValue } from '@pikku/core'
2
+ import type { JSONValue } from '@pikku/core/ecosystem/types'
3
3
  import { resolveFunctionMeta } from './resolve-function-meta.js'
4
4
 
5
5
  interface MCPEndpoint {
@@ -1,5 +1,5 @@
1
- import type { FunctionsMeta } from '@pikku/core'
2
- import type { HTTPWiringsMeta } from '@pikku/core/http'
1
+ import type { FunctionsMeta } from '@pikku/core/ecosystem/services'
2
+ import type { HTTPWiringsMeta } from '@pikku/core/ecosystem/http'
3
3
  import type { InspectorLogger } from '../types.js'
4
4
  import _convertSchema from '@openapi-contrib/json-schema-to-openapi-schema'
5
5
  const convertSchema =
@@ -1,6 +1,6 @@
1
1
  import { strict as assert } from 'assert'
2
2
  import { describe, test } from 'node:test'
3
- import type { WorkflowStepMeta } from '@pikku/core/workflow'
3
+ import type { WorkflowStepMeta } from '@pikku/core/ecosystem/workflow'
4
4
  import { deriveWorkflowPlan } from './derive-workflow-plan.js'
5
5
 
6
6
  const rpc = (stepName: string, rpcName = 'rpc.fn'): WorkflowStepMeta =>
@@ -1,7 +1,7 @@
1
1
  import type {
2
2
  WorkflowStepMeta,
3
3
  WorkflowPlannedStep,
4
- } from '@pikku/core/workflow'
4
+ } from '@pikku/core/ecosystem/workflow'
5
5
 
6
6
  /**
7
7
  * Derive the static UI plan for a DSL workflow from its extracted step tree.
@@ -2,7 +2,7 @@ import { describe, test } from 'node:test'
2
2
  import assert from 'node:assert/strict'
3
3
  import * as ts from 'typescript'
4
4
  import { extractDSLWorkflow } from './extract-dsl-workflow.js'
5
- import type { ApprovalStepMeta } from '@pikku/core/workflow'
5
+ import type { ApprovalStepMeta } from '@pikku/core/ecosystem/workflow'
6
6
 
7
7
  const checker = {
8
8
  getSymbolAtLocation: () => undefined,
@@ -26,7 +26,10 @@ const approvalStepFor = (options: string): ApprovalStepMeta => {
26
26
 
27
27
  let node: ts.Node | undefined
28
28
  const visit = (n: ts.Node) => {
29
- if (ts.isCallExpression(n) && n.expression.getText() === 'pikkuWorkflowFunc') {
29
+ if (
30
+ ts.isCallExpression(n) &&
31
+ n.expression.getText() === 'pikkuWorkflowFunc'
32
+ ) {
30
33
  node = n
31
34
  }
32
35
  ts.forEachChild(n, visit)
@@ -15,13 +15,13 @@ import type {
15
15
  SwitchCaseMeta,
16
16
  FilterStepMeta,
17
17
  ArrayPredicateStepMeta,
18
- ScenarioStepMeta,
19
18
  InputSource,
20
19
  OutputBinding,
21
20
  Condition,
22
21
  WorkflowContext,
23
22
  ContextVariable,
24
- } from '@pikku/core/workflow'
23
+ } from '@pikku/core/ecosystem/workflow'
24
+ import type { ScenarioStepMeta } from '@pikku/core/ecosystem/scenario'
25
25
  import {
26
26
  isWorkflowDoCall,
27
27
  isWorkflowExpectEventuallyCall,
@@ -1,7 +1,7 @@
1
1
  import { test } from 'node:test'
2
2
  import assert from 'node:assert'
3
3
  import { convertDslToGraph } from './convert-dsl-to-graph.js'
4
- import type { WorkflowsMeta } from '@pikku/core'
4
+ import type { WorkflowsMeta } from '@pikku/core/ecosystem/workflow'
5
5
 
6
6
  const scenarioMeta = (
7
7
  overrides: Partial<WorkflowsMeta[string]> = {}
@@ -1,7 +1,10 @@
1
1
  /**
2
2
  * Converts DSL (Domain Specific Language) step-based format to graph node format
3
3
  */
4
- import type { WorkflowStepMeta, WorkflowsMeta } from '@pikku/core/workflow'
4
+ import type {
5
+ WorkflowStepMeta,
6
+ WorkflowsMeta,
7
+ } from '@pikku/core/ecosystem/workflow'
5
8
  import type {
6
9
  SerializedGraphNode,
7
10
  SerializedWorkflowGraph,
@@ -3,7 +3,7 @@ import type {
3
3
  SerializedWorkflowGraph,
4
4
  WorkflowWires,
5
5
  } from './workflow-graph.types.js'
6
- import type { CLICommandMeta } from '@pikku/core/cli'
6
+ import type { CLICommandMeta } from '@pikku/core/ecosystem/cli'
7
7
 
8
8
  function parseWorkflowFuncId(
9
9
  pikkuFuncId: string
@@ -1,5 +1,9 @@
1
- import type { FunctionsMeta } from '@pikku/core'
2
- import { isVersionedId, formatVersionedId, parseVersionedId } from '@pikku/core'
1
+ import type { FunctionsMeta } from '@pikku/core/ecosystem/services'
2
+ import {
3
+ isVersionedId,
4
+ formatVersionedId,
5
+ parseVersionedId,
6
+ } from '@pikku/core/ecosystem/types'
3
7
  import type { SerializedWorkflowGraph } from './workflow-graph.types.js'
4
8
  import { canonicalJSON, hashString } from '../../hash.js'
5
9
  import { convertDslToGraph } from './convert-dsl-to-graph.js'
@@ -1,4 +1,4 @@
1
- import { isRef } from '@pikku/core/workflow'
1
+ import { isRef } from '@pikku/core/ecosystem/workflow'
2
2
  import type {
3
3
  SerializedWorkflowGraph,
4
4
  SerializedGraphNode,
@@ -113,10 +113,10 @@ export type FlowType =
113
113
  // Import and re-export context types from core
114
114
  import type {
115
115
  ContextVariable,
116
- ScenarioStepPhase,
117
116
  WorkflowContext,
118
117
  WorkflowPlannedStep,
119
- } from '@pikku/core/workflow'
118
+ } from '@pikku/core/ecosystem/workflow'
119
+ import type { ScenarioStepPhase } from '@pikku/core/ecosystem/scenario'
120
120
 
121
121
  export type { ContextVariable, WorkflowContext }
122
122
 
package/src/visit.ts CHANGED
@@ -33,8 +33,8 @@ import { addPersonas } from './add/add-personas.js'
33
33
  import { addVariable } from './add/add-variable.js'
34
34
  import { addWorkflowGraph } from './add/add-workflow-graph.js'
35
35
  import { addFeature } from './add/add-feature.js'
36
- import { addAIAgent } from './add/add-ai-agent.js'
37
- import { addAIScorer } from './add/add-ai-scorer.js'
36
+ import { addAgent } from './add/add-agent.js'
37
+ import { addAgentScorer } from './add/add-agent-scorer.js'
38
38
  import { addApprovalDescription } from './add/add-approval-description.js'
39
39
 
40
40
  export const visitSetup = (
@@ -172,8 +172,8 @@ export const visitRoutes = (
172
172
  addMCPPrompt(logger, node, checker, state, nextOptions)
173
173
  addWorkflowGraph(logger, node, checker, state, nextOptions)
174
174
  addFeature(logger, node, checker, state, nextOptions)
175
- addAIAgent(logger, node, checker, state, nextOptions)
176
- addAIScorer(logger, node, checker, state, nextOptions)
175
+ addAgent(logger, node, checker, state, nextOptions)
176
+ addAgentScorer(logger, node, checker, state, nextOptions)
177
177
 
178
178
  ts.forEachChild(node, (child) =>
179
179
  visitRoutes(logger, checker, child, state, nextOptions)