@pikku/inspector 0.12.59 → 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 (97) hide show
  1. package/CHANGELOG.md +72 -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-workflow.d.ts +1 -1
  12. package/dist/inspector.js +1 -1
  13. package/dist/types.d.ts +23 -22
  14. package/dist/utils/compute-required-schemas.d.ts +1 -1
  15. package/dist/utils/contract-hashes.d.ts +2 -1
  16. package/dist/utils/contract-hashes.js +1 -1
  17. package/dist/utils/extract-function-name.js +1 -1
  18. package/dist/utils/extract-services.d.ts +1 -1
  19. package/dist/utils/filter-inspector-state.js +1 -1
  20. package/dist/utils/filter-utils.d.ts +1 -1
  21. package/dist/utils/middleware.d.ts +2 -2
  22. package/dist/utils/middleware.js +5 -5
  23. package/dist/utils/permissions.d.ts +1 -1
  24. package/dist/utils/post-process.d.ts +2 -2
  25. package/dist/utils/post-process.js +6 -6
  26. package/dist/utils/resolve-deploy-target.d.ts +1 -1
  27. package/dist/utils/resolve-function-meta.d.ts +1 -1
  28. package/dist/utils/resolve-function-types.d.ts +1 -1
  29. package/dist/utils/resolve-versions.js +1 -1
  30. package/dist/utils/schema-generator.d.ts +1 -1
  31. package/dist/utils/serialize-inspector-state.d.ts +3 -3
  32. package/dist/utils/serialize-inspector-state.js +4 -4
  33. package/dist/utils/serialize-openapi-json.d.ts +2 -2
  34. package/dist/utils/workflow/derive-workflow-plan.d.ts +1 -1
  35. package/dist/utils/workflow/dsl/extract-dsl-workflow.d.ts +1 -1
  36. package/dist/utils/workflow/graph/convert-dsl-to-graph.d.ts +1 -1
  37. package/dist/utils/workflow/graph/finalize-workflows.js +1 -1
  38. package/dist/utils/workflow/graph/serialize-workflow-graph.js +1 -1
  39. package/dist/utils/workflow/graph/workflow-graph.types.d.ts +2 -2
  40. package/dist/visit.js +4 -4
  41. package/package.json +3 -3
  42. package/src/add/{add-ai-scorer.test.ts → add-agent-scorer.test.ts} +11 -11
  43. package/src/add/{add-ai-scorer.ts → add-agent-scorer.ts} +4 -4
  44. package/src/add/{add-ai-agent.test.ts → add-agent.test.ts} +1 -1
  45. package/src/add/{add-ai-agent.ts → add-agent.ts} +11 -17
  46. package/src/add/add-auth.ts +1 -1
  47. package/src/add/add-channel.ts +4 -1
  48. package/src/add/add-cli.ts +1 -1
  49. package/src/add/add-functions.ts +9 -4
  50. package/src/add/add-gateway.ts +1 -1
  51. package/src/add/add-http-route.ts +1 -1
  52. package/src/add/add-keyed-wiring.ts +1 -1
  53. package/src/add/add-middleware.ts +7 -5
  54. package/src/add/add-permission.ts +1 -1
  55. package/src/add/add-personas.test.ts +2 -2
  56. package/src/add/add-personas.ts +3 -2
  57. package/src/add/add-scenario-step.test.ts +2 -2
  58. package/src/add/add-scope.test.ts +19 -19
  59. package/src/add/add-scope.ts +1 -1
  60. package/src/add/add-system-role.test.ts +12 -12
  61. package/src/add/add-workflow-graph-input.test.ts +1 -1
  62. package/src/add/add-workflow.ts +4 -1
  63. package/src/add/addon-contracts.test.ts +1 -1
  64. package/src/inspector.ts +1 -1
  65. package/src/types.ts +29 -23
  66. package/src/utils/compute-required-schemas.ts +1 -1
  67. package/src/utils/contract-hashes.test.ts +1 -1
  68. package/src/utils/contract-hashes.ts +3 -2
  69. package/src/utils/extract-function-name.ts +1 -1
  70. package/src/utils/extract-services.ts +4 -1
  71. package/src/utils/filter-inspector-state.ts +2 -2
  72. package/src/utils/filter-utils.ts +1 -1
  73. package/src/utils/middleware.test.ts +23 -23
  74. package/src/utils/middleware.ts +6 -6
  75. package/src/utils/permissions.ts +1 -1
  76. package/src/utils/post-process.test.ts +9 -9
  77. package/src/utils/post-process.ts +8 -8
  78. package/src/utils/resolve-deploy-target.ts +1 -1
  79. package/src/utils/resolve-function-meta.ts +4 -1
  80. package/src/utils/resolve-function-types.ts +1 -1
  81. package/src/utils/resolve-versions.ts +5 -2
  82. package/src/utils/schema-generator.ts +3 -2
  83. package/src/utils/serialize-inspector-state.ts +7 -7
  84. package/src/utils/serialize-mcp-json.ts +1 -1
  85. package/src/utils/serialize-openapi-json.ts +2 -2
  86. package/src/utils/workflow/derive-workflow-plan.test.ts +1 -1
  87. package/src/utils/workflow/derive-workflow-plan.ts +1 -1
  88. package/src/utils/workflow/dsl/extract-approval-policy.test.ts +5 -2
  89. package/src/utils/workflow/dsl/extract-dsl-workflow.ts +2 -2
  90. package/src/utils/workflow/graph/convert-dsl-to-graph-skip.test.ts +1 -1
  91. package/src/utils/workflow/graph/convert-dsl-to-graph.ts +4 -1
  92. package/src/utils/workflow/graph/finalize-workflow-wires.ts +1 -1
  93. package/src/utils/workflow/graph/finalize-workflows.ts +6 -2
  94. package/src/utils/workflow/graph/serialize-workflow-graph.ts +1 -1
  95. package/src/utils/workflow/graph/workflow-graph.types.ts +2 -2
  96. package/src/visit.ts +4 -4
  97. package/tsconfig.tsbuildinfo +1 -1
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';
@@ -545,7 +546,7 @@ export interface InspectorState {
545
546
  files: Set<string>;
546
547
  };
547
548
  agents: {
548
- agentsMeta: AIAgentMeta;
549
+ agentsMeta: AgentsMeta;
549
550
  files: Map<string, {
550
551
  path: string;
551
552
  exportedName: string;
@@ -619,7 +620,7 @@ export interface InspectorState {
619
620
  };
620
621
  middleware: InspectorMiddlewareState;
621
622
  channelMiddleware: InspectorChannelMiddlewareState;
622
- aiMiddleware: InspectorAIMiddlewareState;
623
+ agentMiddleware: InspectorAIMiddlewareState;
623
624
  permissions: InspectorPermissionState;
624
625
  serviceAggregation: {
625
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) {
@@ -995,7 +995,7 @@ export function validateScopeReferences(logger, state) {
995
995
  *
996
996
  * The description check is separate and opt-in (`--strict-meta`), because the
997
997
  * description is what the model is told the tool does: without one, the tool is
998
- * 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
999
999
  * quality loss rather than a failure. A title deliberately does not satisfy it —
1000
1000
  * a title labels a tool in a UI, it does not tell a model when to reach for it.
1001
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
@@ -279,8 +279,8 @@ export interface SerializableInspectorState {
279
279
  InspectorState['channelMiddleware']['tagMiddleware'] extends Map<string, infer V> ? V : never
280
280
  ]>;
281
281
  };
282
- aiMiddleware: {
283
- definitions: InspectorState['aiMiddleware']['definitions'];
282
+ agentMiddleware: {
283
+ definitions: InspectorState['agentMiddleware']['definitions'];
284
284
  };
285
285
  permissions: {
286
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,8 +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, WorkflowContext, WorkflowPlannedStep } from '@pikku/core/workflow';
71
- import type { ScenarioStepPhase } from '@pikku/core/scenario';
70
+ import type { ContextVariable, WorkflowContext, WorkflowPlannedStep } from '@pikku/core/ecosystem/workflow';
71
+ import type { ScenarioStepPhase } from '@pikku/core/ecosystem/scenario';
72
72
  export type { ContextVariable, WorkflowContext };
73
73
  /**
74
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.59",
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.83"
48
+ "@pikku/core": "^0.12.84"
49
49
  },
50
50
  "devDependencies": {
51
- "@pikku/core": "^0.12.83",
51
+ "@pikku/core": "^0.12.84",
52
52
  "@types/node": "^24.11.0"
53
53
  },
54
54
  "engines": {
@@ -23,7 +23,7 @@ const makeLogger = (criticals: Array<{ code: ErrorCode; message: string }>) =>
23
23
  }) satisfies InspectorLogger
24
24
 
25
25
  const inspectSources = async (sources: Record<string, string>) => {
26
- const rootDir = await mkdtemp(join(tmpdir(), 'pikku-add-ai-scorer-'))
26
+ const rootDir = await mkdtemp(join(tmpdir(), 'pikku-add-agent-scorer-'))
27
27
  const files: Record<string, string> = {}
28
28
  for (const [name, source] of Object.entries(sources)) {
29
29
  files[name] = join(rootDir, name)
@@ -43,16 +43,16 @@ const inspectSources = async (sources: Record<string, string>) => {
43
43
  const inspectSource = (source: string) =>
44
44
  inspectSources({ 'grading.scorer.ts': source })
45
45
 
46
- describe('addAIScorer', () => {
46
+ describe('addAgentScorer', () => {
47
47
  test('reads the lane off which constructor was called, not off a field', async () => {
48
48
  const { state, criticals } = await inspectSource(
49
49
  [
50
- `export const brevity = pikkuAIScorer({`,
50
+ `export const brevity = pikkuAgentScorer({`,
51
51
  ` name: 'brevity',`,
52
52
  ` description: 'Shorter answers score higher',`,
53
53
  ` score: () => ({ score: 1 }),`,
54
54
  `})`,
55
- `export const helpfulness = pikkuAIJudge({`,
55
+ `export const helpfulness = pikkuAgentJudge({`,
56
56
  ` name: 'helpfulness',`,
57
57
  ` description: 'Does the answer help',`,
58
58
  ` model: 'claude-opus-5',`,
@@ -69,7 +69,7 @@ describe('addAIScorer', () => {
69
69
  test('defaults an unstated sample rate to grading every run', async () => {
70
70
  const { state } = await inspectSource(
71
71
  [
72
- `export const brevity = pikkuAIScorer({`,
72
+ `export const brevity = pikkuAgentScorer({`,
73
73
  ` name: 'brevity',`,
74
74
  ` description: 'Shorter answers score higher',`,
75
75
  ` score: () => ({ score: 1 }),`,
@@ -84,7 +84,7 @@ describe('addAIScorer', () => {
84
84
  test('carries the sample rate and the reference requirement into the meta', async () => {
85
85
  const { state } = await inspectSource(
86
86
  [
87
- `export const correctness = pikkuAIJudge({`,
87
+ `export const correctness = pikkuAgentJudge({`,
88
88
  ` name: 'correctness',`,
89
89
  ` description: 'Is the answer right',`,
90
90
  ` model: 'claude-opus-5',`,
@@ -105,7 +105,7 @@ describe('addAIScorer', () => {
105
105
  test('rejects a sample rate that is not a fraction', async () => {
106
106
  const { state, criticals } = await inspectSource(
107
107
  [
108
- `export const brevity = pikkuAIScorer({`,
108
+ `export const brevity = pikkuAgentScorer({`,
109
109
  ` name: 'brevity',`,
110
110
  ` description: 'Shorter answers score higher',`,
111
111
  ` sampleRate: 50,`,
@@ -122,7 +122,7 @@ describe('addAIScorer', () => {
122
122
  test('a scorer with no description is refused, since the meta is what names it', async () => {
123
123
  const { criticals } = await inspectSource(
124
124
  [
125
- `export const brevity = pikkuAIScorer({`,
125
+ `export const brevity = pikkuAgentScorer({`,
126
126
  ` name: 'brevity',`,
127
127
  ` score: () => ({ score: 1 }),`,
128
128
  `})`,
@@ -135,7 +135,7 @@ describe('addAIScorer', () => {
135
135
  test('records where a scorer was declared, so codegen can import it back', async () => {
136
136
  const { state } = await inspectSource(
137
137
  [
138
- `export const brevity = pikkuAIScorer({`,
138
+ `export const brevity = pikkuAgentScorer({`,
139
139
  ` name: 'brevity',`,
140
140
  ` description: 'Shorter answers score higher',`,
141
141
  ` score: () => ({ score: 1 }),`,
@@ -153,7 +153,7 @@ describe('addAIScorer', () => {
153
153
 
154
154
  describe('an agent asking to be graded', () => {
155
155
  const scorerFile = [
156
- `export const brevity = pikkuAIScorer({`,
156
+ `export const brevity = pikkuAgentScorer({`,
157
157
  ` name: 'brevity',`,
158
158
  ` description: 'Shorter answers score higher',`,
159
159
  ` score: () => ({ score: 1 }),`,
@@ -162,7 +162,7 @@ describe('an agent asking to be graded', () => {
162
162
 
163
163
  const agent = (scorers: string) =>
164
164
  [
165
- `export const assistant = pikkuAIAgent({`,
165
+ `export const assistant = pikkuAgent({`,
166
166
  ` name: 'assistant',`,
167
167
  ` description: 'Answers questions',`,
168
168
  ` goal: 'Answer the question.',`,
@@ -5,16 +5,16 @@ import { extractFunctionName } from '../utils/extract-function-name.js'
5
5
  import { ErrorCode } from '../error-codes.js'
6
6
 
7
7
  /**
8
- * `pikkuAIScorer` grades in code and `pikkuAIJudge` grades with a model, which
8
+ * `pikkuAgentScorer` grades in code and `pikkuAgentJudge` grades with a model, which
9
9
  * is the whole difference between the two lanes — so the lane is read off which
10
10
  * constructor was called rather than from a field an author could contradict.
11
11
  */
12
12
  const LANES: Record<string, 'fast' | 'slow'> = {
13
- pikkuAIScorer: 'fast',
14
- pikkuAIJudge: 'slow',
13
+ pikkuAgentScorer: 'fast',
14
+ pikkuAgentJudge: 'slow',
15
15
  }
16
16
 
17
- export const addAIScorer: AddWiring = (logger, node, checker, state) => {
17
+ export const addAgentScorer: AddWiring = (logger, node, checker, state) => {
18
18
  if (!ts.isCallExpression(node)) return
19
19
 
20
20
  const expression = node.expression
@@ -2,7 +2,7 @@ import { describe, test } from 'node:test'
2
2
  import assert from 'node:assert'
3
3
  import * as ts from 'typescript'
4
4
 
5
- import { resolveWorkflowReferences } from './add-ai-agent.js'
5
+ import { resolveWorkflowReferences } from './add-agent.js'
6
6
  import type { InspectorLogger } from '../types.js'
7
7
 
8
8
  function createSourceFile(code: string): ts.SourceFile {
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  resolveMiddleware,
14
14
  resolveChannelMiddleware,
15
- resolveAIMiddleware,
15
+ resolveAgentMiddleware,
16
16
  } from '../utils/middleware.js'
17
17
  import { resolvePermissions } from '../utils/permissions.js'
18
18
  import { ErrorCode } from '../error-codes.js'
@@ -119,7 +119,7 @@ function resolveAgentReferences(
119
119
  logger.critical(
120
120
  ErrorCode.INVALID_VALUE,
121
121
  `AI agent '${agentName}' agents array contains a string literal '${element.text}'. ` +
122
- `Use an agent reference instead (e.g., import the pikkuAIAgent variable).`
122
+ `Use an agent reference instead (e.g., import the pikkuAgent variable).`
123
123
  )
124
124
  continue
125
125
  }
@@ -134,7 +134,7 @@ function resolveAgentReferences(
134
134
  logger.critical(
135
135
  ErrorCode.INVALID_VALUE,
136
136
  `AI agent '${agentName}' agents array contains identifier '${element.text}' ` +
137
- `that could not be resolved to a pikkuAIAgent.`
137
+ `that could not be resolved to a pikkuAgent.`
138
138
  )
139
139
  }
140
140
  }
@@ -319,7 +319,7 @@ function resolveIdentifierToAgentName(
319
319
  if (
320
320
  ts.isCallExpression(decl.initializer) &&
321
321
  ts.isIdentifier(decl.initializer.expression) &&
322
- decl.initializer.expression.text === 'pikkuAIAgent'
322
+ decl.initializer.expression.text === 'pikkuAgent'
323
323
  ) {
324
324
  if (ts.isIdentifier(decl.name)) {
325
325
  return decl.name.text
@@ -363,13 +363,7 @@ function resolveScorerNames(
363
363
  return names.length > 0 ? names : null
364
364
  }
365
365
 
366
- export const addAIAgent: AddWiring = (
367
- logger,
368
- node,
369
- checker,
370
- state,
371
- options
372
- ) => {
366
+ export const addAgent: AddWiring = (logger, node, checker, state, options) => {
373
367
  if (!ts.isCallExpression(node)) {
374
368
  return
375
369
  }
@@ -378,7 +372,7 @@ export const addAIAgent: AddWiring = (
378
372
  const firstArg = args[0]
379
373
  const expression = node.expression
380
374
 
381
- if (!ts.isIdentifier(expression) || expression.text !== 'pikkuAIAgent') {
375
+ if (!ts.isIdentifier(expression) || expression.text !== 'pikkuAgent') {
382
376
  return
383
377
  }
384
378
 
@@ -579,7 +573,7 @@ export const addAIAgent: AddWiring = (
579
573
  tags,
580
574
  checker
581
575
  )
582
- const aiMiddleware = resolveAIMiddleware(state, obj, checker)
576
+ const agentMiddleware = resolveAgentMiddleware(state, obj, checker)
583
577
  const permissions = resolvePermissions(state, obj, tags, checker)
584
578
 
585
579
  state.serviceAggregation.usedFunctions.add(agentKey)
@@ -623,7 +617,7 @@ export const addAIAgent: AddWiring = (
623
617
  workingMemorySchema,
624
618
  middleware,
625
619
  channelMiddleware,
626
- aiMiddleware,
620
+ agentMiddleware,
627
621
  permissions,
628
622
  }
629
623
 
@@ -632,10 +626,10 @@ export const addAIAgent: AddWiring = (
632
626
  const funcMeta = state.functions.meta[agentKey]
633
627
  if (funcMeta?.services) {
634
628
  for (const svc of [
635
- 'aiStorage',
636
- 'aiRunState',
629
+ 'agentStorage',
630
+ 'agentRunState',
637
631
  'agentRunService',
638
- 'aiAgentRunner',
632
+ 'agentRunner',
639
633
  ]) {
640
634
  if (!funcMeta.services.services.includes(svc)) {
641
635
  funcMeta.services.services.push(svc)
@@ -1,5 +1,5 @@
1
1
  import * as ts from 'typescript'
2
- import type { FunctionServicesMeta } from '@pikku/core'
2
+ import type { FunctionServicesMeta } from '@pikku/core/ecosystem/types'
3
3
  import type { AddWiring } from '../types.js'
4
4
  import { ErrorCode } from '../error-codes.js'
5
5
  import { extractServicesFromFunction } from '../utils/extract-services.js'