@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
@@ -508,12 +508,12 @@ export const addMiddleware = (logger, node, checker, state) => {
508
508
  logger.debug(`• Found channel middleware factory with services: ${services.services.join(', ')}`);
509
509
  return;
510
510
  }
511
- if (expression.text === 'pikkuAIMiddleware') {
511
+ if (expression.text === 'pikkuAgentMiddleware') {
512
512
  const arg = args[0];
513
513
  if (!arg)
514
514
  return;
515
515
  if (!ts.isObjectLiteralExpression(arg)) {
516
- logger.error(`• pikkuAIMiddleware() requires an object literal argument.`);
516
+ logger.error(`• pikkuAgentMiddleware() requires an object literal argument.`);
517
517
  return;
518
518
  }
519
519
  const allServices = new Set();
@@ -542,12 +542,12 @@ export const addMiddleware = (logger, node, checker, state) => {
542
542
  pikkuFuncId = node.parent.name.text;
543
543
  }
544
544
  else {
545
- logger.error(`• pikkuAIMiddleware() must be assigned to a variable or object property. ` +
546
- `Extract it to a const: const myMiddleware = pikkuAIMiddleware(...)`);
545
+ logger.error(`• pikkuAgentMiddleware() must be assigned to a variable or object property. ` +
546
+ `Extract it to a const: const myMiddleware = pikkuAgentMiddleware(...)`);
547
547
  return;
548
548
  }
549
549
  }
550
- state.aiMiddleware.definitions[pikkuFuncId] = {
550
+ state.agentMiddleware.definitions[pikkuFuncId] = {
551
551
  services,
552
552
  sourceFile: node.getSourceFile().fileName,
553
553
  position: node.getStart(),
@@ -1,5 +1,5 @@
1
1
  import * as ts from 'typescript';
2
- import { DISPOSITIONS } from '@pikku/core/virtual-user';
2
+ import { DISPOSITIONS } from '@pikku/core/ecosystem/virtual-user';
3
3
  import { isRunnablePersona } from '@pikku/core/persona';
4
4
  import { ErrorCode } from '../error-codes.js';
5
5
  import { claimSingleDeclaration } from '../utils/single-declaration.js';
@@ -53,6 +53,8 @@ export function addWireAddon(node, state, logger) {
53
53
  let secretOverrides;
54
54
  let variableOverrides;
55
55
  let credentialOverrides;
56
+ let secretGrants;
57
+ let credentialGrants;
56
58
  let globalSecrets;
57
59
  let globalCredentials;
58
60
  for (const prop of firstArg.properties) {
@@ -96,6 +98,12 @@ export function addWireAddon(node, state, logger) {
96
98
  ts.isObjectLiteralExpression(prop.initializer)) {
97
99
  credentialOverrides = parseStringRecord(prop.initializer);
98
100
  }
101
+ else if (key === 'secretGrants') {
102
+ secretGrants = parseStringArray(prop.initializer);
103
+ }
104
+ else if (key === 'credentialGrants') {
105
+ credentialGrants = parseStringArray(prop.initializer);
106
+ }
99
107
  else if (key === 'globalSecrets') {
100
108
  // The grant is real at runtime whatever the reason evaluates to, so a
101
109
  // non-literal is recorded as its source text rather than dropped.
@@ -122,6 +130,8 @@ export function addWireAddon(node, state, logger) {
122
130
  secretOverrides,
123
131
  variableOverrides,
124
132
  credentialOverrides,
133
+ secretGrants,
134
+ credentialGrants,
125
135
  globalSecrets,
126
136
  globalCredentials,
127
137
  });
@@ -1,5 +1,5 @@
1
1
  import type { AddWiring } from '../types.js';
2
- import type { WorkflowStepMeta } from '@pikku/core/workflow';
2
+ import type { WorkflowStepMeta } from '@pikku/core/ecosystem/workflow';
3
3
  /**
4
4
  * Recursively collect all RPC names from workflow steps
5
5
  */
@@ -69,6 +69,7 @@ export declare enum ErrorCode {
69
69
  FUNCTION_DYNAMIC_IMPORT = "PKU498",
70
70
  DUPLICATE_CORE_VERSION = "PKU717",
71
71
  CORE_VERSION_SKEW = "PKU718",
72
+ SPLIT_TYPE_IDENTITY = "PKU719",
72
73
  PII_IN_OUTPUT = "PKU910",
73
74
  ADDON_WIRING_NOT_ALLOWED = "PKU920",
74
75
  ADDON_CONTRACT_HANDLERS_NOT_ALLOWED = "PKU921",
@@ -90,6 +90,7 @@ export var ErrorCode;
90
90
  // Dependency integrity errors
91
91
  ErrorCode["DUPLICATE_CORE_VERSION"] = "PKU717";
92
92
  ErrorCode["CORE_VERSION_SKEW"] = "PKU718";
93
+ ErrorCode["SPLIT_TYPE_IDENTITY"] = "PKU719";
93
94
  // Data classification errors
94
95
  ErrorCode["PII_IN_OUTPUT"] = "PKU910";
95
96
  // Addon authoring errors
package/dist/inspector.js CHANGED
@@ -177,7 +177,7 @@ export function getInitialInspectorState(rootDir) {
177
177
  instances: {},
178
178
  tagMiddleware: new Map(),
179
179
  },
180
- aiMiddleware: {
180
+ agentMiddleware: {
181
181
  definitions: {},
182
182
  },
183
183
  permissions: {
package/dist/types.d.ts CHANGED
@@ -1,26 +1,27 @@
1
1
  import type * as ts from 'typescript';
2
2
  import type { SecretUsage } from './utils/extract-secret-usage.js';
3
- import type { ChannelMessageMeta, ChannelsMeta } from '@pikku/core/channel';
4
- import type { GatewaysMeta } from '@pikku/core/gateway';
5
- import type { HTTPWiringsMeta } from '@pikku/core/http';
6
- import type { ScheduledTasksMeta } from '@pikku/core/scheduler';
7
- import type { TriggerMeta, TriggerSourceMeta } from '@pikku/core/trigger';
8
- import type { QueueWorkersMeta } from '@pikku/core/queue';
9
- import type { WorkflowsMeta } from '@pikku/core/workflow';
10
- import type { MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from '@pikku/core/mcp';
11
- import type { AIAgentMeta } from '@pikku/core/ai-agent';
12
- import type { ScorerMeta } from '@pikku/core/ai-scorer';
13
- import type { CLIMeta } from '@pikku/core/cli';
14
- import type { CLICommandMeta } from '@pikku/core/cli';
15
- import type { NodesMeta } from '@pikku/core/node';
16
- import type { SecretDefinitions } from '@pikku/core/secret';
17
- import type { CredentialDefinitions } from '@pikku/core/credential';
18
- import type { ScopeDefinitions } from '@pikku/core/scope';
19
- import type { SystemRoleDefinitions } from '@pikku/core/role';
20
- import type { PersonaDefinitions } from '@pikku/core/persona';
21
- import type { VariableDefinitions } from '@pikku/core/variable';
3
+ import type { ChannelMessageMeta, ChannelsMeta } from '@pikku/core/ecosystem/channel';
4
+ import type { GatewaysMeta } from '@pikku/core/ecosystem/gateway';
5
+ import type { HTTPWiringsMeta } from '@pikku/core/ecosystem/http';
6
+ import type { ScheduledTasksMeta } from '@pikku/core/ecosystem/scheduler';
7
+ import type { TriggerMeta, TriggerSourceMeta } from '@pikku/core/ecosystem/trigger';
8
+ import type { QueueWorkersMeta } from '@pikku/core/ecosystem/queue';
9
+ import type { WorkflowsMeta } from '@pikku/core/ecosystem/workflow';
10
+ import type { MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from '@pikku/core/ecosystem/mcp';
11
+ import type { AgentsMeta } from '@pikku/core/ecosystem/agent';
12
+ import type { ScorerMeta } from '@pikku/core/ecosystem/agent-scorer';
13
+ import type { CLIMeta } from '@pikku/core/ecosystem/cli';
14
+ import type { CLICommandMeta } from '@pikku/core/ecosystem/cli';
15
+ import type { NodesMeta } from '@pikku/core/ecosystem/node';
16
+ import type { SecretDefinitions } from '@pikku/core/ecosystem/secret';
17
+ import type { CredentialDefinitions } from '@pikku/core/ecosystem/credential';
18
+ import type { ScopeDefinitions } from '@pikku/core/ecosystem/scope';
19
+ import type { SystemRoleDefinitions } from '@pikku/core/ecosystem/role';
20
+ import type { PersonaDefinitions } from '@pikku/core/ecosystem/persona';
21
+ import type { VariableDefinitions } from '@pikku/core/ecosystem/variable';
22
22
  import type { TypesMap } from './types-map.js';
23
- import type { FunctionsMeta, FunctionServicesMeta, FunctionWiresMeta, JSONValue } from '@pikku/core';
23
+ import type { FunctionsMeta } from '@pikku/core/ecosystem/services';
24
+ import type { FunctionServicesMeta, FunctionWiresMeta, JSONValue } from '@pikku/core/ecosystem/types';
24
25
  import type { OpenAPISpecInfo } from './utils/serialize-openapi-json.js';
25
26
  import type { ErrorCode, CodedDiagnostic } from './error-codes.js';
26
27
  import type { VersionManifest, VersionValidateError } from './utils/contract-hashes.js';
@@ -521,6 +522,10 @@ export interface InspectorState {
521
522
  secretOverrides?: Record<string, string>;
522
523
  variableOverrides?: Record<string, string>;
523
524
  credentialOverrides?: Record<string, string>;
525
+ /** Secrets the app lends this instance, named as the addon reads them. */
526
+ secretGrants?: string[];
527
+ /** Credentials the app lends this instance, named as the addon reads them. */
528
+ credentialGrants?: string[];
524
529
  /**
525
530
  * The app's stated reason for handing this instance the whole
526
531
  * `SecretService` instead of one scoped to its declared secrets.
@@ -541,7 +546,7 @@ export interface InspectorState {
541
546
  files: Set<string>;
542
547
  };
543
548
  agents: {
544
- agentsMeta: AIAgentMeta;
549
+ agentsMeta: AgentsMeta;
545
550
  files: Map<string, {
546
551
  path: string;
547
552
  exportedName: string;
@@ -615,7 +620,7 @@ export interface InspectorState {
615
620
  };
616
621
  middleware: InspectorMiddlewareState;
617
622
  channelMiddleware: InspectorChannelMiddlewareState;
618
- aiMiddleware: InspectorAIMiddlewareState;
623
+ agentMiddleware: InspectorAIMiddlewareState;
619
624
  permissions: InspectorPermissionState;
620
625
  serviceAggregation: {
621
626
  requiredServices: Set<string>;
@@ -1,4 +1,4 @@
1
- import type { FunctionsMeta } from '@pikku/core';
1
+ import type { FunctionsMeta } from '@pikku/core/ecosystem/services';
2
2
  import type { TypesMap } from '../types-map.js';
3
3
  import type { SchemaRef } from '../types.js';
4
4
  export declare function computeRequiredSchemas(functionsMeta: FunctionsMeta, typesMap: TypesMap, additionalTypes?: string[], schemaLookup?: Map<string, SchemaRef>): Set<string>;
@@ -1,4 +1,5 @@
1
- import type { FunctionsMeta, JSONValue } from '@pikku/core';
1
+ import type { FunctionsMeta } from '@pikku/core/ecosystem/services';
2
+ import type { JSONValue } from '@pikku/core/ecosystem/types';
2
3
  import type { TypesMap } from '../types-map.js';
3
4
  import { ErrorCode } from '../error-codes.js';
4
5
  export type ContractEntry = {
@@ -1,4 +1,4 @@
1
- import { parseVersionedId } from '@pikku/core';
1
+ import { parseVersionedId } from '@pikku/core/ecosystem/types';
2
2
  import { ErrorCode } from '../error-codes.js';
3
3
  import { canonicalJSON, hashString } from './hash.js';
4
4
  function isHashEntry(v) {
@@ -1,7 +1,7 @@
1
1
  import * as ts from 'typescript';
2
2
  import { createHash } from 'crypto';
3
3
  import { relative } from 'path';
4
- import { formatVersionedId } from '@pikku/core';
4
+ import { formatVersionedId } from '@pikku/core/ecosystem/types';
5
5
  /**
6
6
  * Deterministic placeholder id for an anonymous/unnamed pikku function or
7
7
  * permission. Derived from the call expression's source location (relative path
@@ -1,5 +1,5 @@
1
1
  import * as ts from 'typescript';
2
- import type { FunctionServicesMeta, FunctionWiresMeta } from '@pikku/core';
2
+ import type { FunctionServicesMeta, FunctionWiresMeta } from '@pikku/core/ecosystem/types';
3
3
  /**
4
4
  * Extract services from a function's first parameter destructuring pattern
5
5
  */
@@ -1,4 +1,4 @@
1
- import { parseVersionedId } from '@pikku/core';
1
+ import { parseVersionedId } from '@pikku/core/ecosystem/types';
2
2
  import { aggregateRequiredServices } from './post-process.js';
3
3
  import { resolveDeployTarget } from './resolve-deploy-target.js';
4
4
  // Module-level Set to track warned groups across multiple filter calls
@@ -1,5 +1,5 @@
1
1
  import type { InspectorFilters, InspectorLogger } from '../types.js';
2
- import type { PikkuWiringTypes } from '@pikku/core';
2
+ import type { PikkuWiringTypes } from '@pikku/core/ecosystem/types';
3
3
  /**
4
4
  * Match a value against a pattern with wildcard support
5
5
  * Supports "*" at the beginning, end, or both (e.g., "send*", "*Payment", "*process*")
@@ -1,5 +1,5 @@
1
1
  import * as ts from 'typescript';
2
- import type { MiddlewareMetadata } from '@pikku/core';
2
+ import type { MiddlewareMetadata } from '@pikku/core/ecosystem/types';
3
3
  import type { InspectorState } from '../types.js';
4
4
  export interface MiddlewareRef {
5
5
  definitionId: string;
@@ -12,5 +12,5 @@ export declare function routeMatchesPattern(route: string, pattern: string): boo
12
12
  export declare function resolveHTTPMiddleware(state: InspectorState, route: string, tags: string[] | undefined, explicitMiddlewareNode: ts.Expression | undefined, checker: ts.TypeChecker): MiddlewareMetadata[] | undefined;
13
13
  export declare function resolveMiddleware(state: InspectorState, obj: ts.ObjectLiteralExpression, tags: string[] | undefined, checker: ts.TypeChecker): MiddlewareMetadata[] | undefined;
14
14
  export declare function resolveHTTPMiddlewareFromObject(state: InspectorState, route: string, obj: ts.ObjectLiteralExpression, tags: string[] | undefined, checker: ts.TypeChecker): MiddlewareMetadata[] | undefined;
15
- export declare function resolveAIMiddleware(state: InspectorState, obj: ts.ObjectLiteralExpression, checker: ts.TypeChecker): MiddlewareMetadata[] | undefined;
15
+ export declare function resolveAgentMiddleware(state: InspectorState, obj: ts.ObjectLiteralExpression, checker: ts.TypeChecker): MiddlewareMetadata[] | undefined;
16
16
  export declare function resolveChannelMiddleware(state: InspectorState, obj: ts.ObjectLiteralExpression, tags: string[] | undefined, checker: ts.TypeChecker): MiddlewareMetadata[] | undefined;
@@ -116,19 +116,19 @@ export function resolveHTTPMiddlewareFromObject(state, route, obj, tags, checker
116
116
  const explicitMiddlewareNode = getMiddlewareNode(obj);
117
117
  return resolveHTTPMiddleware(state, route, tags, explicitMiddlewareNode, checker);
118
118
  }
119
- function getAIMiddlewareNode(obj) {
119
+ function getAgentMiddlewareNode(obj) {
120
120
  const prop = obj.properties.find((p) => ts.isPropertyAssignment(p) &&
121
121
  ts.isIdentifier(p.name) &&
122
- p.name.text === 'aiMiddleware');
122
+ p.name.text === 'agentMiddleware');
123
123
  return prop?.initializer;
124
124
  }
125
- export function resolveAIMiddleware(state, obj, checker) {
126
- const explicitNode = getAIMiddlewareNode(obj);
125
+ export function resolveAgentMiddleware(state, obj, checker) {
126
+ const explicitNode = getAgentMiddlewareNode(obj);
127
127
  if (!explicitNode)
128
128
  return undefined;
129
129
  const names = extractMiddlewarePikkuNames(explicitNode, checker, state.rootDir);
130
130
  const resolved = names.map((name) => {
131
- const def = state.aiMiddleware.definitions[name];
131
+ const def = state.agentMiddleware.definitions[name];
132
132
  return {
133
133
  type: 'wire',
134
134
  name,
@@ -1,5 +1,5 @@
1
1
  import * as ts from 'typescript';
2
- import type { PermissionMetadata } from '@pikku/core';
2
+ import type { PermissionMetadata } from '@pikku/core/ecosystem/types';
3
3
  import type { InspectorState } from '../types.js';
4
4
  /**
5
5
  * Extract permission pikkuFuncIds from an expression (array or object literal)
@@ -1,5 +1,5 @@
1
1
  import type { InspectorState, InspectorLogger, InspectorOptions } from '../types.js';
2
- import type { MiddlewareMetadata, PermissionMetadata } from '@pikku/core';
2
+ import type { MiddlewareMetadata, PermissionMetadata } from '@pikku/core/ecosystem/types';
3
3
  import type ts from 'typescript';
4
4
  /**
5
5
  * Stamp the inspected authorize/callbacks service set onto the generated auth
@@ -153,7 +153,7 @@ export declare function validateScopeReferences(logger: InspectorLogger, state:
153
153
  *
154
154
  * The description check is separate and opt-in (`--strict-meta`), because the
155
155
  * description is what the model is told the tool does: without one, the tool is
156
- * offered to it under its own name (`ai-agent-prepare.ts`), which is a silent
156
+ * offered to it under its own name (`agent-prepare.ts`), which is a silent
157
157
  * quality loss rather than a failure. A title deliberately does not satisfy it —
158
158
  * a title labels a tool in a UI, it does not tell a model when to reach for it.
159
159
  */
@@ -5,7 +5,7 @@ import { ErrorCode } from '../error-codes.js';
5
5
  import { findSecretAliasServices } from './secret-alias-services.js';
6
6
  import { relative } from 'node:path';
7
7
  import { AUTH_HANDLER_FUNC_ID } from '../add/add-auth.js';
8
- import { flattenScopeDefinitions } from '@pikku/core/scope';
8
+ import { flattenScopeDefinitions } from '@pikku/core/ecosystem/scope';
9
9
  import { DYNAMIC_SCENARIO_STEP_TARGET } from './workflow/dsl/patterns.js';
10
10
  /**
11
11
  * Stamp the inspected authorize/callbacks service set onto the generated auth
@@ -254,12 +254,12 @@ export function aggregateRequiredServices(state) {
254
254
  }
255
255
  }
256
256
  }
257
- // AI agents need aiStorage + aiRunState + agentRunService + aiAgentRunner
257
+ // AI agents need agentStorage + agentRunState + agentRunService + agentRunner
258
258
  if (Object.keys(state.agents.agentsMeta).length > 0) {
259
- requiredServices.add('aiStorage');
260
- requiredServices.add('aiRunState');
259
+ requiredServices.add('agentStorage');
260
+ requiredServices.add('agentRunState');
261
261
  requiredServices.add('agentRunService');
262
- requiredServices.add('aiAgentRunner');
262
+ requiredServices.add('agentRunner');
263
263
  }
264
264
  // Channels need eventHub for pub/sub
265
265
  if (Object.keys(state.channels.meta).length > 0) {
@@ -317,14 +317,21 @@ export function validateSecretOverrides(logger, state) {
317
317
  // older meta without a secretId field.
318
318
  const secretIds = new Set(state.secrets.definitions.map((d) => d.secretId ?? d.name));
319
319
  for (const [namespace, addonDecl] of wireAddonDeclarations.entries()) {
320
- if (!addonDecl.secretOverrides)
321
- continue;
322
- for (const [logicalName, resolvedName] of Object.entries(addonDecl.secretOverrides)) {
320
+ for (const [logicalName, resolvedName] of Object.entries(addonDecl.secretOverrides ?? {})) {
323
321
  if (!secretIds.has(resolvedName)) {
324
322
  const availableSecrets = Array.from(secretIds);
325
323
  logger.critical(ErrorCode.INVALID_VALUE, `Secret override '${logicalName}' -> '${resolvedName}' in addon '${namespace}' (${addonDecl.package}) targets a secret that does not exist. Available secrets: ${availableSecrets.join(', ') || 'none'}`);
326
324
  }
327
325
  }
326
+ // A grant names the secret as the addon reads it, so it resolves through
327
+ // the override map before it can be looked up in the project.
328
+ for (const logicalName of addonDecl.secretGrants ?? []) {
329
+ const resolvedName = addonDecl.secretOverrides?.[logicalName] ?? logicalName;
330
+ if (!secretIds.has(resolvedName)) {
331
+ const availableSecrets = Array.from(secretIds);
332
+ logger.critical(ErrorCode.INVALID_VALUE, `Secret grant '${logicalName}' in addon '${namespace}' (${addonDecl.package}) targets a secret that does not exist. Available secrets: ${availableSecrets.join(', ') || 'none'}`);
333
+ }
334
+ }
328
335
  }
329
336
  }
330
337
  export function validateCredentialOverrides(logger, state) {
@@ -333,14 +340,19 @@ export function validateCredentialOverrides(logger, state) {
333
340
  return;
334
341
  const credentialNames = new Set(state.credentials?.definitions.map((d) => d.name) ?? []);
335
342
  for (const [namespace, addonDecl] of wireAddonDeclarations.entries()) {
336
- if (!addonDecl.credentialOverrides)
337
- continue;
338
- for (const [logicalName, resolvedName] of Object.entries(addonDecl.credentialOverrides)) {
343
+ for (const [logicalName, resolvedName] of Object.entries(addonDecl.credentialOverrides ?? {})) {
339
344
  if (!credentialNames.has(resolvedName)) {
340
345
  const availableCredentials = Array.from(credentialNames);
341
346
  logger.critical(ErrorCode.INVALID_VALUE, `Credential override '${logicalName}' -> '${resolvedName}' in addon '${namespace}' (${addonDecl.package}) targets a credential that does not exist. Available credentials: ${availableCredentials.join(', ') || 'none'}`);
342
347
  }
343
348
  }
349
+ for (const logicalName of addonDecl.credentialGrants ?? []) {
350
+ const resolvedName = addonDecl.credentialOverrides?.[logicalName] ?? logicalName;
351
+ if (!credentialNames.has(resolvedName)) {
352
+ const availableCredentials = Array.from(credentialNames);
353
+ logger.critical(ErrorCode.INVALID_VALUE, `Credential grant '${logicalName}' in addon '${namespace}' (${addonDecl.package}) targets a credential that does not exist. Available credentials: ${availableCredentials.join(', ') || 'none'}`);
354
+ }
355
+ }
344
356
  }
345
357
  }
346
358
  export function validateVariableOverrides(logger, state) {
@@ -983,7 +995,7 @@ export function validateScopeReferences(logger, state) {
983
995
  *
984
996
  * The description check is separate and opt-in (`--strict-meta`), because the
985
997
  * description is what the model is told the tool does: without one, the tool is
986
- * offered to it under its own name (`ai-agent-prepare.ts`), which is a silent
998
+ * offered to it under its own name (`agent-prepare.ts`), which is a silent
987
999
  * quality loss rather than a failure. A title deliberately does not satisfy it —
988
1000
  * a title labels a tool in a UI, it does not tell a model when to reach for it.
989
1001
  */
@@ -1,4 +1,4 @@
1
- import type { FunctionMeta } from '@pikku/core';
1
+ import type { FunctionMeta } from '@pikku/core/ecosystem/services';
2
2
  /**
3
3
  * Thrown when a function's explicit `deploy: 'serverless'` conflicts
4
4
  * with one of its services being declared `serverlessIncompatible`.
@@ -1,4 +1,4 @@
1
- import type { FunctionMeta, FunctionsMeta } from '@pikku/core';
1
+ import type { FunctionMeta, FunctionsMeta } from '@pikku/core/ecosystem/services';
2
2
  /**
3
3
  * Look up function metadata by pikkuFuncId, checking both local functions
4
4
  * and addon functions. Addon functions use namespaced IDs like 'namespace:funcName'.
@@ -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
  export declare function resolveFunctionIOTypes(pikkuFuncId: string, functionsMeta: FunctionsMeta, typesMap: TypesMap, requiredTypes: Set<string>): {
4
4
  inputType: string;
5
5
  outputType: string;
@@ -1,4 +1,4 @@
1
- import { parseVersionedId, formatVersionedId } from '@pikku/core';
1
+ import { parseVersionedId, formatVersionedId, } from '@pikku/core/ecosystem/types';
2
2
  import { ErrorCode } from '../error-codes.js';
3
3
  export function resolveLatestVersions(state, logger) {
4
4
  const functionsMeta = state.functions.meta;
@@ -1,4 +1,4 @@
1
- import type { JSONValue } from '@pikku/core';
1
+ import type { JSONValue } from '@pikku/core/ecosystem/types';
2
2
  import type { InspectorLogger, InspectorState } from '../types.js';
3
3
  /** One file the generated schemas were derived from, as of when they were generated. */
4
4
  export type SchemaDep = {
@@ -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 { InspectorDiagnostic, InspectorFeature, InspectorState } from '../types.js';
4
4
  /**
5
5
  * Serializable version of InspectorState that can be saved to JSON
@@ -195,6 +195,8 @@ export interface SerializableInspectorState {
195
195
  secretOverrides?: Record<string, string>;
196
196
  variableOverrides?: Record<string, string>;
197
197
  credentialOverrides?: Record<string, string>;
198
+ secretGrants?: string[];
199
+ credentialGrants?: string[];
198
200
  globalSecrets?: string;
199
201
  globalCredentials?: string;
200
202
  }
@@ -277,8 +279,8 @@ export interface SerializableInspectorState {
277
279
  InspectorState['channelMiddleware']['tagMiddleware'] extends Map<string, infer V> ? V : never
278
280
  ]>;
279
281
  };
280
- aiMiddleware: {
281
- definitions: InspectorState['aiMiddleware']['definitions'];
282
+ agentMiddleware: {
283
+ definitions: InspectorState['agentMiddleware']['definitions'];
282
284
  };
283
285
  permissions: {
284
286
  definitions: InspectorState['permissions']['definitions'];
@@ -149,8 +149,8 @@ export function serializeInspectorState(state) {
149
149
  instances: state.channelMiddleware.instances,
150
150
  tagMiddleware: Array.from(state.channelMiddleware.tagMiddleware.entries()),
151
151
  },
152
- aiMiddleware: {
153
- definitions: state.aiMiddleware.definitions,
152
+ agentMiddleware: {
153
+ definitions: state.agentMiddleware.definitions,
154
154
  },
155
155
  permissions: {
156
156
  definitions: state.permissions.definitions,
@@ -326,8 +326,8 @@ export function deserializeInspectorState(data) {
326
326
  instances: data.channelMiddleware?.instances || {},
327
327
  tagMiddleware: new Map(data.channelMiddleware?.tagMiddleware || []),
328
328
  },
329
- aiMiddleware: {
330
- definitions: data.aiMiddleware?.definitions || {},
329
+ agentMiddleware: {
330
+ definitions: data.agentMiddleware?.definitions || {},
331
331
  },
332
332
  permissions: {
333
333
  definitions: data.permissions.definitions,
@@ -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
  interface ErrorDetails {
5
5
  status: number;
@@ -1,4 +1,4 @@
1
- import type { WorkflowStepMeta, WorkflowPlannedStep } from '@pikku/core/workflow';
1
+ import type { WorkflowStepMeta, WorkflowPlannedStep } from '@pikku/core/ecosystem/workflow';
2
2
  /**
3
3
  * Derive the static UI plan for a DSL workflow from its extracted step tree.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import * as ts from 'typescript';
2
- import type { WorkflowStepMeta, WorkflowContext } from '@pikku/core/workflow';
2
+ import type { WorkflowStepMeta, WorkflowContext } from '@pikku/core/ecosystem/workflow';
3
3
  /**
4
4
  * Result of DSL workflow extraction
5
5
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Converts DSL (Domain Specific Language) step-based format to graph node format
3
3
  */
4
- import type { WorkflowsMeta } from '@pikku/core/workflow';
4
+ import type { WorkflowsMeta } from '@pikku/core/ecosystem/workflow';
5
5
  import type { SerializedWorkflowGraph } from './workflow-graph.types.js';
6
6
  /**
7
7
  * Convert a DSL workflow to graph format
@@ -1,4 +1,4 @@
1
- import { isVersionedId, formatVersionedId, parseVersionedId } from '@pikku/core';
1
+ import { isVersionedId, formatVersionedId, parseVersionedId, } from '@pikku/core/ecosystem/types';
2
2
  import { canonicalJSON, hashString } from '../../hash.js';
3
3
  import { convertDslToGraph } from './convert-dsl-to-graph.js';
4
4
  import { deriveWorkflowPlan } from '../derive-workflow-plan.js';
@@ -1,4 +1,4 @@
1
- import { isRef } from '@pikku/core/workflow';
1
+ import { isRef } from '@pikku/core/ecosystem/workflow';
2
2
  /**
3
3
  * Convert a RefValue (from runtime) to DataRef (serialized)
4
4
  */
@@ -67,7 +67,8 @@ export interface NodeOptions {
67
67
  * Flow node types for control flow (no RPC call)
68
68
  */
69
69
  export type FlowType = 'sleep' | 'suspend' | 'approval' | 'branch' | 'parallel' | 'fanout' | 'inline' | 'switch' | 'filter' | 'arrayPredicate' | 'return' | 'cancel' | 'set';
70
- import type { ContextVariable, ScenarioStepPhase, WorkflowContext, WorkflowPlannedStep } from '@pikku/core/workflow';
70
+ import type { ContextVariable, WorkflowContext, WorkflowPlannedStep } from '@pikku/core/ecosystem/workflow';
71
+ import type { ScenarioStepPhase } from '@pikku/core/ecosystem/scenario';
71
72
  export type { ContextVariable, WorkflowContext };
72
73
  /**
73
74
  * Base node properties shared by all node types
package/dist/visit.js CHANGED
@@ -28,8 +28,8 @@ import { addPersonas } from './add/add-personas.js';
28
28
  import { addVariable } from './add/add-variable.js';
29
29
  import { addWorkflowGraph } from './add/add-workflow-graph.js';
30
30
  import { addFeature } from './add/add-feature.js';
31
- import { addAIAgent } from './add/add-ai-agent.js';
32
- import { addAIScorer } from './add/add-ai-scorer.js';
31
+ import { addAgent } from './add/add-agent.js';
32
+ import { addAgentScorer } from './add/add-agent-scorer.js';
33
33
  import { addApprovalDescription } from './add/add-approval-description.js';
34
34
  export const visitSetup = (logger, checker, node, state, options) => {
35
35
  addFileExtendsCoreType(node, checker, state.singletonServicesTypeImportMap, 'CoreSingletonServices', state);
@@ -88,7 +88,7 @@ export const visitRoutes = (logger, checker, node, state, options) => {
88
88
  addMCPPrompt(logger, node, checker, state, nextOptions);
89
89
  addWorkflowGraph(logger, node, checker, state, nextOptions);
90
90
  addFeature(logger, node, checker, state, nextOptions);
91
- addAIAgent(logger, node, checker, state, nextOptions);
92
- addAIScorer(logger, node, checker, state, nextOptions);
91
+ addAgent(logger, node, checker, state, nextOptions);
92
+ addAgentScorer(logger, node, checker, state, nextOptions);
93
93
  ts.forEachChild(node, (child) => visitRoutes(logger, checker, child, state, nextOptions));
94
94
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/inspector",
3
- "version": "0.12.58",
3
+ "version": "0.12.60",
4
4
  "description": "TypeScript inspector for Pikku — discovers functions and wirings to drive code generation",
5
5
  "author": "yasser.fadl@gmail.com",
6
6
  "license": "BUSL-1.1",
@@ -45,10 +45,10 @@
45
45
  "zod-to-ts": "^2.1.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "@pikku/core": "^0.12.82"
48
+ "@pikku/core": "^0.12.84"
49
49
  },
50
50
  "devDependencies": {
51
- "@pikku/core": "^0.12.82",
51
+ "@pikku/core": "^0.12.84",
52
52
  "@types/node": "^24.11.0"
53
53
  },
54
54
  "engines": {