apcore-js 0.15.0 → 0.16.0

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 (59) hide show
  1. package/README.md +5 -5
  2. package/dist/acl-handlers.d.ts +42 -0
  3. package/dist/acl-handlers.d.ts.map +1 -0
  4. package/dist/acl-handlers.js +128 -0
  5. package/dist/acl-handlers.js.map +1 -0
  6. package/dist/acl.d.ts +11 -0
  7. package/dist/acl.d.ts.map +1 -1
  8. package/dist/acl.js +148 -37
  9. package/dist/acl.js.map +1 -1
  10. package/dist/builtin-steps.d.ts +144 -0
  11. package/dist/builtin-steps.d.ts.map +1 -0
  12. package/dist/builtin-steps.js +582 -0
  13. package/dist/builtin-steps.js.map +1 -0
  14. package/dist/config.d.ts +40 -2
  15. package/dist/config.d.ts.map +1 -1
  16. package/dist/config.js +177 -29
  17. package/dist/config.js.map +1 -1
  18. package/dist/context-key.d.ts +25 -0
  19. package/dist/context-key.d.ts.map +1 -0
  20. package/dist/context-key.js +37 -0
  21. package/dist/context-key.js.map +1 -0
  22. package/dist/context-keys.d.ts +11 -0
  23. package/dist/context-keys.d.ts.map +1 -0
  24. package/dist/context-keys.js +13 -0
  25. package/dist/context-keys.js.map +1 -0
  26. package/dist/context.d.ts +28 -3
  27. package/dist/context.d.ts.map +1 -1
  28. package/dist/context.js +60 -21
  29. package/dist/context.js.map +1 -1
  30. package/dist/errors.d.ts +4 -0
  31. package/dist/errors.d.ts.map +1 -1
  32. package/dist/errors.js +7 -0
  33. package/dist/errors.js.map +1 -1
  34. package/dist/executor.d.ts +24 -0
  35. package/dist/executor.d.ts.map +1 -1
  36. package/dist/executor.js +100 -0
  37. package/dist/executor.js.map +1 -1
  38. package/dist/generated/version.d.ts +1 -1
  39. package/dist/generated/version.js +1 -1
  40. package/dist/index.d.ts +8 -2
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +8 -2
  43. package/dist/index.js.map +1 -1
  44. package/dist/module.d.ts +22 -6
  45. package/dist/module.d.ts.map +1 -1
  46. package/dist/module.js +73 -0
  47. package/dist/module.js.map +1 -1
  48. package/dist/pipeline.d.ts +118 -0
  49. package/dist/pipeline.d.ts.map +1 -0
  50. package/dist/pipeline.js +222 -0
  51. package/dist/pipeline.js.map +1 -0
  52. package/dist/schema/annotations.d.ts.map +1 -1
  53. package/dist/schema/annotations.js +1 -0
  54. package/dist/schema/annotations.js.map +1 -1
  55. package/dist/sys-modules/toggle.d.ts +5 -0
  56. package/dist/sys-modules/toggle.d.ts.map +1 -1
  57. package/dist/sys-modules/toggle.js +5 -0
  58. package/dist/sys-modules/toggle.js.map +1 -1
  59. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.15.0";
1
+ export declare const VERSION = "0.16.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Auto-generated by scripts/generate-version.js — do not edit manually.
2
- export const VERSION = "0.15.0";
2
+ export const VERSION = "0.16.0";
3
3
  //# sourceMappingURL=version.js.map
package/dist/index.d.ts CHANGED
@@ -5,18 +5,20 @@ export { APCore } from './client.js';
5
5
  export type { APCoreOptions, ModuleOptions } from './client.js';
6
6
  export { CancelToken, ExecutionCancelledError } from './cancel.js';
7
7
  export { Context, createIdentity } from './context.js';
8
+ export { ContextKey } from './context-key.js';
9
+ export { TRACING_SPANS, TRACING_SAMPLED, METRICS_STARTS, LOGGING_START, REDACTED_OUTPUT, RETRY_COUNT_BASE, } from './context-keys.js';
8
10
  export type { Identity, ContextFactory } from './context.js';
9
11
  export { Registry, REGISTRY_EVENTS, MODULE_ID_PATTERN, MAX_MODULE_ID_LENGTH, RESERVED_WORDS } from './registry/registry.js';
10
12
  export type { Discoverer, ModuleValidator } from './registry/registry.js';
11
13
  export { Executor, redactSensitive, REDACTED_VALUE, CTX_GLOBAL_DEADLINE, CTX_TRACING_SPANS } from './executor.js';
12
- export { DEFAULT_ANNOTATIONS, createPreflightResult } from './module.js';
14
+ export { DEFAULT_ANNOTATIONS, createAnnotations, annotationsToJSON, annotationsFromJSON, createPreflightResult } from './module.js';
13
15
  export type { ModuleAnnotations, ModuleExample, ModuleDescription, ValidationResult, PreflightCheckResult, PreflightResult, Module } from './module.js';
14
16
  export { Config, discoverConfigFile } from './config.js';
15
17
  export { ErrorFormatterRegistry } from './error-formatter.js';
16
18
  export type { ErrorFormatter } from './error-formatter.js';
17
19
  export { createApprovalRequest, createApprovalResult, AlwaysDenyHandler, AutoApproveHandler, CallbackApprovalHandler, } from './approval.js';
18
20
  export type { ApprovalRequest, ApprovalResult, ApprovalHandler } from './approval.js';
19
- export { ModuleError, ConfigNotFoundError, ConfigError, ACLRuleError, ACLDeniedError, ApprovalError, ApprovalDeniedError, ApprovalTimeoutError, ApprovalPendingError, ModuleNotFoundError, ModuleDisabledError, ModuleTimeoutError, SchemaValidationError, SchemaNotFoundError, SchemaParseError, SchemaCircularRefError, CallDepthExceededError, CircularCallError, CallFrequencyExceededError, InvalidInputError, FuncMissingTypeHintError, FuncMissingReturnTypeError, BindingInvalidTargetError, BindingModuleNotFoundError, BindingCallableNotFoundError, BindingNotCallableError, BindingSchemaMissingError, BindingFileInvalidError, CircularDependencyError, DependencyNotFoundError, FeatureNotImplementedError, ModuleLoadError, ReloadFailedError, ModuleExecuteError, InternalError, ConfigNamespaceDuplicateError, ConfigNamespaceReservedError, ConfigEnvPrefixConflictError, ConfigMountError, ConfigBindError, ErrorFormatterDuplicateError, ErrorCodes, } from './errors.js';
21
+ export { ModuleError, ConfigNotFoundError, ConfigError, ACLRuleError, ACLDeniedError, ApprovalError, ApprovalDeniedError, ApprovalTimeoutError, ApprovalPendingError, ModuleNotFoundError, ModuleDisabledError, ModuleTimeoutError, SchemaValidationError, SchemaNotFoundError, SchemaParseError, SchemaCircularRefError, CallDepthExceededError, CircularCallError, CallFrequencyExceededError, InvalidInputError, FuncMissingTypeHintError, FuncMissingReturnTypeError, BindingInvalidTargetError, BindingModuleNotFoundError, BindingCallableNotFoundError, BindingNotCallableError, BindingSchemaMissingError, BindingFileInvalidError, CircularDependencyError, DependencyNotFoundError, FeatureNotImplementedError, ModuleLoadError, ReloadFailedError, ModuleExecuteError, InternalError, ConfigNamespaceDuplicateError, ConfigNamespaceReservedError, ConfigEnvPrefixConflictError, ConfigEnvMapConflictError, ConfigMountError, ConfigBindError, ErrorFormatterDuplicateError, ErrorCodes, } from './errors.js';
20
22
  export type { ErrorCode, ErrorOptions } from './errors.js';
21
23
  export { ACL } from './acl.js';
22
24
  export type { ACLRule, AuditEntry, AuditLogger } from './acl.js';
@@ -57,5 +59,9 @@ export { computeModuleErrorRate, estimateP99FromHistogram, matchesModuleId, METR
57
59
  export type { UsageRecord, CallerUsageSummary, HourlyBucket, ModuleUsageSummary, ModuleUsageDetail } from './observability/usage.js';
58
60
  export { TraceContext } from './trace-context.js';
59
61
  export type { TraceParent } from './trace-context.js';
62
+ export { ExecutionStrategy, PipelineEngine, PipelineAbortError, StepNotFoundError, StepNotRemovableError, StepNotReplaceableError, StepNameDuplicateError, StrategyNotFoundError } from './pipeline.js';
63
+ export type { Step, StepResult, PipelineContext, StepTrace, PipelineTrace, StrategyInfo } from './pipeline.js';
64
+ export { BuiltinContextCreation, BuiltinSafetyCheck, BuiltinModuleLookup, BuiltinACLCheck, BuiltinApprovalGate, BuiltinInputValidation, BuiltinMiddlewareBefore, BuiltinExecute, BuiltinOutputValidation, BuiltinMiddlewareAfter, BuiltinReturnResult, buildStandardStrategy, buildInternalStrategy, buildTestingStrategy, buildPerformanceStrategy, } from './builtin-steps.js';
65
+ export type { StandardStrategyDeps } from './builtin-steps.js';
60
66
  export { VERSION } from './generated/version.js';
61
67
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,a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E,uBAAuB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACxM,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG/G,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -6,10 +6,12 @@ export { APCore } from './client.js';
6
6
  // Core
7
7
  export { CancelToken, ExecutionCancelledError } from './cancel.js';
8
8
  export { Context, createIdentity } from './context.js';
9
+ export { ContextKey } from './context-key.js';
10
+ export { TRACING_SPANS, TRACING_SAMPLED, METRICS_STARTS, LOGGING_START, REDACTED_OUTPUT, RETRY_COUNT_BASE, } from './context-keys.js';
9
11
  export { Registry, REGISTRY_EVENTS, MODULE_ID_PATTERN, MAX_MODULE_ID_LENGTH, RESERVED_WORDS } from './registry/registry.js';
10
12
  export { Executor, redactSensitive, REDACTED_VALUE, CTX_GLOBAL_DEADLINE, CTX_TRACING_SPANS } from './executor.js';
11
13
  // Module types
12
- export { DEFAULT_ANNOTATIONS, createPreflightResult } from './module.js';
14
+ export { DEFAULT_ANNOTATIONS, createAnnotations, annotationsToJSON, annotationsFromJSON, createPreflightResult } from './module.js';
13
15
  // Config
14
16
  export { Config, discoverConfigFile } from './config.js';
15
17
  // Error Formatter
@@ -17,7 +19,7 @@ export { ErrorFormatterRegistry } from './error-formatter.js';
17
19
  // Approval
18
20
  export { createApprovalRequest, createApprovalResult, AlwaysDenyHandler, AutoApproveHandler, CallbackApprovalHandler, } from './approval.js';
19
21
  // Errors
20
- export { ModuleError, ConfigNotFoundError, ConfigError, ACLRuleError, ACLDeniedError, ApprovalError, ApprovalDeniedError, ApprovalTimeoutError, ApprovalPendingError, ModuleNotFoundError, ModuleDisabledError, ModuleTimeoutError, SchemaValidationError, SchemaNotFoundError, SchemaParseError, SchemaCircularRefError, CallDepthExceededError, CircularCallError, CallFrequencyExceededError, InvalidInputError, FuncMissingTypeHintError, FuncMissingReturnTypeError, BindingInvalidTargetError, BindingModuleNotFoundError, BindingCallableNotFoundError, BindingNotCallableError, BindingSchemaMissingError, BindingFileInvalidError, CircularDependencyError, DependencyNotFoundError, FeatureNotImplementedError, ModuleLoadError, ReloadFailedError, ModuleExecuteError, InternalError, ConfigNamespaceDuplicateError, ConfigNamespaceReservedError, ConfigEnvPrefixConflictError, ConfigMountError, ConfigBindError, ErrorFormatterDuplicateError, ErrorCodes, } from './errors.js';
22
+ export { ModuleError, ConfigNotFoundError, ConfigError, ACLRuleError, ACLDeniedError, ApprovalError, ApprovalDeniedError, ApprovalTimeoutError, ApprovalPendingError, ModuleNotFoundError, ModuleDisabledError, ModuleTimeoutError, SchemaValidationError, SchemaNotFoundError, SchemaParseError, SchemaCircularRefError, CallDepthExceededError, CircularCallError, CallFrequencyExceededError, InvalidInputError, FuncMissingTypeHintError, FuncMissingReturnTypeError, BindingInvalidTargetError, BindingModuleNotFoundError, BindingCallableNotFoundError, BindingNotCallableError, BindingSchemaMissingError, BindingFileInvalidError, CircularDependencyError, DependencyNotFoundError, FeatureNotImplementedError, ModuleLoadError, ReloadFailedError, ModuleExecuteError, InternalError, ConfigNamespaceDuplicateError, ConfigNamespaceReservedError, ConfigEnvPrefixConflictError, ConfigEnvMapConflictError, ConfigMountError, ConfigBindError, ErrorFormatterDuplicateError, ErrorCodes, } from './errors.js';
21
23
  // ACL
22
24
  export { ACL } from './acl.js';
23
25
  // Middleware
@@ -59,5 +61,9 @@ export { UsageCollector, UsageMiddleware, bucketKey } from './observability/usag
59
61
  export { computeModuleErrorRate, estimateP99FromHistogram, matchesModuleId, METRIC_CALLS_TOTAL, METRIC_DURATION_SECONDS } from './observability/metrics-utils.js';
60
62
  // Trace Context
61
63
  export { TraceContext } from './trace-context.js';
64
+ // Pipeline
65
+ export { ExecutionStrategy, PipelineEngine, PipelineAbortError, StepNotFoundError, StepNotRemovableError, StepNotReplaceableError, StepNameDuplicateError, StrategyNotFoundError } from './pipeline.js';
66
+ // Built-in Steps
67
+ export { BuiltinContextCreation, BuiltinSafetyCheck, BuiltinModuleLookup, BuiltinACLCheck, BuiltinApprovalGate, BuiltinInputValidation, BuiltinMiddlewareBefore, BuiltinExecute, BuiltinOutputValidation, BuiltinMiddlewareAfter, BuiltinReturnResult, buildStandardStrategy, buildInternalStrategy, buildTestingStrategy, buildPerformanceStrategy, } from './builtin-steps.js';
62
68
  export { VERSION } from './generated/version.js';
63
69
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,SAAS;AACT,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO;AACP,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE5H,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElH,eAAe;AACf,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzE,SAAS;AACT,OAAO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,EAAE,MAAM,eAAe,CAAC;AAGxM,iBAAiB;AACjB,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/module.d.ts CHANGED
@@ -11,17 +11,33 @@ export interface ModuleAnnotations {
11
11
  readonly openWorld: boolean;
12
12
  readonly streaming: boolean;
13
13
  /** Whether the module's results can be cached. */
14
- readonly cacheable?: boolean;
14
+ readonly cacheable: boolean;
15
15
  /** Cache time-to-live in seconds (0 means no expiry). */
16
- readonly cacheTtl?: number;
16
+ readonly cacheTtl: number;
17
17
  /** Input fields used to compute the cache key (null = all fields). */
18
- readonly cacheKeyFields?: string[] | null;
18
+ readonly cacheKeyFields: readonly string[] | null;
19
19
  /** Whether the module supports paginated results. */
20
- readonly paginated?: boolean;
21
- /** Pagination strategy. */
22
- readonly paginationStyle?: 'cursor' | 'offset' | 'page';
20
+ readonly paginated: boolean;
21
+ /** Pagination strategy. Accepts any string. */
22
+ readonly paginationStyle: string;
23
+ /** Extension dictionary for ecosystem package metadata. */
24
+ readonly extra: Readonly<Record<string, unknown>>;
23
25
  }
24
26
  export declare const DEFAULT_ANNOTATIONS: ModuleAnnotations;
27
+ /**
28
+ * Factory to create a frozen ModuleAnnotations with defaults for unspecified fields.
29
+ * Negative cacheTtl is clamped to 0 with a console warning.
30
+ */
31
+ export declare function createAnnotations(overrides?: Partial<ModuleAnnotations>): ModuleAnnotations;
32
+ /**
33
+ * Serialize ModuleAnnotations to a snake_case JSON-compatible record.
34
+ */
35
+ export declare function annotationsToJSON(a: ModuleAnnotations): Record<string, unknown>;
36
+ /**
37
+ * Deserialize ModuleAnnotations from a snake_case JSON record.
38
+ * Unknown keys are captured into extra.
39
+ */
40
+ export declare function annotationsFromJSON(data: Record<string, unknown>): ModuleAnnotations;
25
41
  export interface ModuleExample {
26
42
  title: string;
27
43
  inputs: Record<string, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC1C,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,2BAA2B;IAC3B,QAAQ,CAAC,eAAe,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;CACzD;AAED,eAAO,MAAM,mBAAmB,EAAE,iBAYhC,CAAC;AAEH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC,MA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C;IAC/C,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,aAAa,EAAE,CAAC;CACpC"}
package/dist/module.js CHANGED
@@ -13,7 +13,80 @@ export const DEFAULT_ANNOTATIONS = Object.freeze({
13
13
  cacheKeyFields: null,
14
14
  paginated: false,
15
15
  paginationStyle: 'cursor',
16
+ extra: Object.freeze({}),
16
17
  });
18
+ /**
19
+ * Factory to create a frozen ModuleAnnotations with defaults for unspecified fields.
20
+ * Negative cacheTtl is clamped to 0 with a console warning.
21
+ */
22
+ export function createAnnotations(overrides) {
23
+ let cacheTtl = overrides?.cacheTtl ?? DEFAULT_ANNOTATIONS.cacheTtl;
24
+ if (cacheTtl < 0) {
25
+ console.warn(`[apcore:annotations] cacheTtl ${cacheTtl} is negative, clamping to 0`);
26
+ cacheTtl = 0;
27
+ }
28
+ return Object.freeze({
29
+ ...DEFAULT_ANNOTATIONS,
30
+ ...overrides,
31
+ cacheTtl,
32
+ extra: Object.freeze({ ...(overrides?.extra ?? {}) }),
33
+ });
34
+ }
35
+ const KNOWN_WIRE_KEYS = new Set([
36
+ 'readonly', 'destructive', 'idempotent', 'requires_approval',
37
+ 'open_world', 'streaming', 'cacheable', 'cache_ttl',
38
+ 'cache_key_fields', 'paginated', 'pagination_style', 'extra',
39
+ ]);
40
+ /**
41
+ * Serialize ModuleAnnotations to a snake_case JSON-compatible record.
42
+ */
43
+ export function annotationsToJSON(a) {
44
+ return {
45
+ readonly: a.readonly,
46
+ destructive: a.destructive,
47
+ idempotent: a.idempotent,
48
+ requires_approval: a.requiresApproval,
49
+ open_world: a.openWorld,
50
+ streaming: a.streaming,
51
+ cacheable: a.cacheable,
52
+ cache_ttl: a.cacheTtl,
53
+ cache_key_fields: a.cacheKeyFields,
54
+ paginated: a.paginated,
55
+ pagination_style: a.paginationStyle,
56
+ extra: a.extra,
57
+ };
58
+ }
59
+ /**
60
+ * Deserialize ModuleAnnotations from a snake_case JSON record.
61
+ * Unknown keys are captured into extra.
62
+ */
63
+ export function annotationsFromJSON(data) {
64
+ const explicitExtra = data['extra'] ?? {};
65
+ const overflow = {};
66
+ for (const [k, v] of Object.entries(data)) {
67
+ if (!KNOWN_WIRE_KEYS.has(k))
68
+ overflow[k] = v;
69
+ }
70
+ let cacheTtl = data['cache_ttl'] ?? 0;
71
+ if (cacheTtl < 0) {
72
+ console.warn(`[apcore:annotations] cache_ttl ${cacheTtl} is negative, clamping to 0`);
73
+ cacheTtl = 0;
74
+ }
75
+ return Object.freeze({
76
+ readonly: data['readonly'] ?? false,
77
+ destructive: data['destructive'] ?? false,
78
+ idempotent: data['idempotent'] ?? false,
79
+ requiresApproval: data['requires_approval'] ?? false,
80
+ openWorld: data['open_world'] ?? true,
81
+ streaming: data['streaming'] ?? false,
82
+ cacheable: data['cacheable'] ?? false,
83
+ cacheTtl,
84
+ cacheKeyFields: data['cache_key_fields'] ?? null,
85
+ paginated: data['paginated'] ?? false,
86
+ paginationStyle: data['pagination_style'] ?? 'cursor',
87
+ extra: Object.freeze({ ...explicitExtra, ...overflow }),
88
+ });
89
+ }
17
90
  export function createPreflightResult(checks, requiresApproval = false) {
18
91
  const valid = checks.every(c => c.passed);
19
92
  const errors = checks
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;GAEG;AAwBH,MAAM,CAAC,MAAM,mBAAmB,GAAsB,MAAM,CAAC,MAAM,CAAC;IAClE,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,KAAK;IACvB,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,CAAC;IACX,cAAc,EAAE,IAAI;IACpB,SAAS,EAAE,KAAK;IAChB,eAAe,EAAE,QAAiB;CACnC,CAAC,CAAC;AA4BH,MAAM,UAAU,qBAAqB,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MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC;SACzC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAM,CAAC,CAAC;IACtB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Execution pipeline types for configurable step-based module invocation.
3
+ */
4
+ import type { Context } from './context.js';
5
+ import { ModuleError } from './errors.js';
6
+ import type { ErrorOptions } from './errors.js';
7
+ /** A single unit of work in the execution pipeline. */
8
+ export interface Step {
9
+ readonly name: string;
10
+ readonly description: string;
11
+ readonly removable: boolean;
12
+ readonly replaceable: boolean;
13
+ execute(ctx: PipelineContext): Promise<StepResult>;
14
+ }
15
+ /** Result returned by a pipeline step execution. */
16
+ export interface StepResult {
17
+ action: 'continue' | 'skip_to' | 'abort';
18
+ skipTo?: string | null;
19
+ explanation?: string | null;
20
+ confidence?: number | null;
21
+ alternatives?: string[] | null;
22
+ }
23
+ /** Holds all state flowing through the pipeline. */
24
+ export interface PipelineContext {
25
+ moduleId: string;
26
+ inputs: Record<string, unknown>;
27
+ context: Context;
28
+ module?: unknown | null;
29
+ validatedInputs?: Record<string, unknown> | null;
30
+ output?: Record<string, unknown> | null;
31
+ validatedOutput?: Record<string, unknown> | null;
32
+ stream?: boolean;
33
+ outputStream?: AsyncGenerator | null;
34
+ strategy?: ExecutionStrategy | null;
35
+ trace?: PipelineTrace | null;
36
+ }
37
+ /** Records execution details for a single step. */
38
+ export interface StepTrace {
39
+ name: string;
40
+ durationMs: number;
41
+ result: StepResult;
42
+ skipped: boolean;
43
+ decisionPoint: boolean;
44
+ }
45
+ /** Records execution details for the entire pipeline run. */
46
+ export interface PipelineTrace {
47
+ moduleId: string;
48
+ strategyName: string;
49
+ steps: StepTrace[];
50
+ totalDurationMs: number;
51
+ success: boolean;
52
+ }
53
+ /** AI-introspectable description of an execution strategy. */
54
+ export interface StrategyInfo {
55
+ name: string;
56
+ stepCount: number;
57
+ stepNames: string[];
58
+ description: string;
59
+ }
60
+ /** An ordered sequence of steps that defines how a module is executed. */
61
+ export declare class ExecutionStrategy {
62
+ readonly name: string;
63
+ private _steps;
64
+ constructor(name: string, steps: Step[]);
65
+ get steps(): readonly Step[];
66
+ /** Insert a step after the named anchor step. */
67
+ insertAfter(anchor: string, step: Step): void;
68
+ /** Insert a step before the named anchor step. */
69
+ insertBefore(anchor: string, step: Step): void;
70
+ /** Remove a step by name. Raises if the step is not removable. */
71
+ remove(stepName: string): void;
72
+ /** Replace a step by name. Raises if the step is not replaceable. */
73
+ replace(stepName: string, newStep: Step): void;
74
+ /** Return the ordered list of step names. */
75
+ stepNames(): string[];
76
+ /** Return an AI-introspectable description of this strategy. */
77
+ info(): StrategyInfo;
78
+ }
79
+ /** Raised when a pipeline is aborted at a step. */
80
+ export declare class PipelineAbortError extends ModuleError {
81
+ static readonly DEFAULT_RETRYABLE: boolean | null;
82
+ readonly step: string;
83
+ readonly explanation: string | null;
84
+ readonly alternatives: string[] | null;
85
+ readonly pipelineTrace: PipelineTrace | null;
86
+ constructor(step: string, explanation?: string | null, alternatives?: string[] | null, trace?: PipelineTrace | null, options?: ErrorOptions);
87
+ }
88
+ /** Raised when a referenced step does not exist. */
89
+ export declare class StepNotFoundError extends ModuleError {
90
+ static readonly DEFAULT_RETRYABLE: boolean | null;
91
+ constructor(message?: string, options?: ErrorOptions);
92
+ }
93
+ /** Raised when attempting to remove a non-removable step. */
94
+ export declare class StepNotRemovableError extends ModuleError {
95
+ static readonly DEFAULT_RETRYABLE: boolean | null;
96
+ constructor(message?: string, options?: ErrorOptions);
97
+ }
98
+ /** Raised when attempting to replace a non-replaceable step. */
99
+ export declare class StepNotReplaceableError extends ModuleError {
100
+ static readonly DEFAULT_RETRYABLE: boolean | null;
101
+ constructor(message?: string, options?: ErrorOptions);
102
+ }
103
+ /** Raised when a step name already exists in the strategy. */
104
+ export declare class StepNameDuplicateError extends ModuleError {
105
+ static readonly DEFAULT_RETRYABLE: boolean | null;
106
+ constructor(message?: string, options?: ErrorOptions);
107
+ }
108
+ /** Executes an ExecutionStrategy against a PipelineContext, returning the final output and a complete execution trace. */
109
+ export declare class PipelineEngine {
110
+ /** Run every step in the strategy against ctx, respecting flow-control actions (continue, skip_to, abort). */
111
+ run(strategy: ExecutionStrategy, ctx: PipelineContext): Promise<[unknown, PipelineTrace]>;
112
+ }
113
+ /** Raised when a referenced strategy does not exist. */
114
+ export declare class StrategyNotFoundError extends ModuleError {
115
+ static readonly DEFAULT_RETRYABLE: boolean | null;
116
+ constructor(message?: string, options?: ErrorOptions);
117
+ }
118
+ //# sourceMappingURL=pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAMhD,uDAAuD;AACvD,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAE9B,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACpD;AAMD,oDAAoD;AACpD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,G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O,CAAC,EAAE,YAAY;CAmBzB;AAED,oDAAoD;AACpD,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,gBAAyB,iBAAiB,EAAE,OAAO,GAAG,IAAI,CAAS;gBAEvD,OAAO,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,YAAY;CAczD;AAED,6DAA6D;AAC7D,qBAAa,qBAAsB,SAAQ,WAAW;IACpD,gBAAyB,iBAAiB,EAAE,OAAO,GAAG,IAAI,CAAS;gBAEvD,OAAO,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,YAAY;CAczD;AAED,gEAAgE;AAChE,qBAAa,uBAAwB,SAAQ,WAAW;IACtD,gBAAyB,iBAAiB,EAAE,OAAO,GAAG,IAAI,CAAS;gBAEvD,OAAO,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,YAAY;CAczD;AAED,8DAA8D;AAC9D,qBAAa,sBAAuB,SAAQ,WAAW;IACrD,gBAAyB,iBAAiB,EAAE,OAAO,GAAG,IAAI,CAAS;gBAEvD,OAAO,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,YAAY;CAczD;AAMD,0HAA0H;AAC1H,qBAAa,cAAc;IACzB,8GAA8G;IACxG,GAAG,CACP,QAAQ,EAAE,iBAAiB,EAC3B,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;CAsErC;AAED,wDAAwD;AACxD,qBAAa,qBAAsB,SAAQ,WAAW;IACpD,gBAAyB,iBAAiB,EAAE,OAAO,GAAG,IAAI,CAAS;gBAEvD,OAAO,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,YAAY;CAczD"}
@@ -0,0 +1,222 @@
1
+ /**
2
+ * Execution pipeline types for configurable step-based module invocation.
3
+ */
4
+ import { ModuleError } from './errors.js';
5
+ // ---------------------------------------------------------------------------
6
+ // ExecutionStrategy
7
+ // ---------------------------------------------------------------------------
8
+ /** An ordered sequence of steps that defines how a module is executed. */
9
+ export class ExecutionStrategy {
10
+ name;
11
+ _steps;
12
+ constructor(name, steps) {
13
+ this.name = name;
14
+ this._steps = [...steps];
15
+ // Validate unique step names
16
+ const names = this._steps.map((s) => s.name);
17
+ const seen = new Set();
18
+ const dupes = new Set();
19
+ for (const n of names) {
20
+ if (seen.has(n)) {
21
+ dupes.add(n);
22
+ }
23
+ seen.add(n);
24
+ }
25
+ if (dupes.size > 0) {
26
+ throw new StepNameDuplicateError(`Duplicate step names: ${[...dupes].join(', ')}`);
27
+ }
28
+ }
29
+ get steps() {
30
+ return this._steps;
31
+ }
32
+ /** Insert a step after the named anchor step. */
33
+ insertAfter(anchor, step) {
34
+ if (this._steps.some((s) => s.name === step.name)) {
35
+ throw new StepNameDuplicateError(`Step '${step.name}' already exists`);
36
+ }
37
+ for (let i = 0; i < this._steps.length; i++) {
38
+ if (this._steps[i].name === anchor) {
39
+ this._steps.splice(i + 1, 0, step);
40
+ return;
41
+ }
42
+ }
43
+ throw new StepNotFoundError(`Anchor step '${anchor}' not found`);
44
+ }
45
+ /** Insert a step before the named anchor step. */
46
+ insertBefore(anchor, step) {
47
+ if (this._steps.some((s) => s.name === step.name)) {
48
+ throw new StepNameDuplicateError(`Step '${step.name}' already exists`);
49
+ }
50
+ for (let i = 0; i < this._steps.length; i++) {
51
+ if (this._steps[i].name === anchor) {
52
+ this._steps.splice(i, 0, step);
53
+ return;
54
+ }
55
+ }
56
+ throw new StepNotFoundError(`Anchor step '${anchor}' not found`);
57
+ }
58
+ /** Remove a step by name. Raises if the step is not removable. */
59
+ remove(stepName) {
60
+ for (let i = 0; i < this._steps.length; i++) {
61
+ if (this._steps[i].name === stepName) {
62
+ if (!this._steps[i].removable) {
63
+ throw new StepNotRemovableError(`Step '${stepName}' is not removable`);
64
+ }
65
+ this._steps.splice(i, 1);
66
+ return;
67
+ }
68
+ }
69
+ throw new StepNotFoundError(`Step '${stepName}' not found`);
70
+ }
71
+ /** Replace a step by name. Raises if the step is not replaceable. */
72
+ replace(stepName, newStep) {
73
+ for (let i = 0; i < this._steps.length; i++) {
74
+ if (this._steps[i].name === stepName) {
75
+ if (!this._steps[i].replaceable) {
76
+ throw new StepNotReplaceableError(`Step '${stepName}' is not replaceable`);
77
+ }
78
+ this._steps[i] = newStep;
79
+ return;
80
+ }
81
+ }
82
+ throw new StepNotFoundError(`Step '${stepName}' not found`);
83
+ }
84
+ /** Return the ordered list of step names. */
85
+ stepNames() {
86
+ return this._steps.map((s) => s.name);
87
+ }
88
+ /** Return an AI-introspectable description of this strategy. */
89
+ info() {
90
+ return {
91
+ name: this.name,
92
+ stepCount: this._steps.length,
93
+ stepNames: this.stepNames(),
94
+ description: this.stepNames().join(' \u2192 '),
95
+ };
96
+ }
97
+ }
98
+ // ---------------------------------------------------------------------------
99
+ // Error types
100
+ // ---------------------------------------------------------------------------
101
+ /** Raised when a pipeline is aborted at a step. */
102
+ export class PipelineAbortError extends ModuleError {
103
+ static DEFAULT_RETRYABLE = false;
104
+ step;
105
+ explanation;
106
+ alternatives;
107
+ pipelineTrace;
108
+ constructor(step, explanation, alternatives, trace, options) {
109
+ super('PIPELINE_ABORT', `Pipeline aborted at step '${step}': ${explanation ?? 'no explanation'}`, { step }, options?.cause, options?.traceId, options?.retryable, options?.aiGuidance, options?.userFixable, options?.suggestion);
110
+ this.name = 'PipelineAbortError';
111
+ this.step = step;
112
+ this.explanation = explanation ?? null;
113
+ this.alternatives = alternatives ?? null;
114
+ this.pipelineTrace = trace ?? null;
115
+ }
116
+ }
117
+ /** Raised when a referenced step does not exist. */
118
+ export class StepNotFoundError extends ModuleError {
119
+ static DEFAULT_RETRYABLE = false;
120
+ constructor(message = '', options) {
121
+ super('STEP_NOT_FOUND', message, {}, options?.cause, options?.traceId, options?.retryable, options?.aiGuidance, options?.userFixable, options?.suggestion);
122
+ this.name = 'StepNotFoundError';
123
+ }
124
+ }
125
+ /** Raised when attempting to remove a non-removable step. */
126
+ export class StepNotRemovableError extends ModuleError {
127
+ static DEFAULT_RETRYABLE = false;
128
+ constructor(message = '', options) {
129
+ super('STEP_NOT_REMOVABLE', message, {}, options?.cause, options?.traceId, options?.retryable, options?.aiGuidance, options?.userFixable, options?.suggestion);
130
+ this.name = 'StepNotRemovableError';
131
+ }
132
+ }
133
+ /** Raised when attempting to replace a non-replaceable step. */
134
+ export class StepNotReplaceableError extends ModuleError {
135
+ static DEFAULT_RETRYABLE = false;
136
+ constructor(message = '', options) {
137
+ super('STEP_NOT_REPLACEABLE', message, {}, options?.cause, options?.traceId, options?.retryable, options?.aiGuidance, options?.userFixable, options?.suggestion);
138
+ this.name = 'StepNotReplaceableError';
139
+ }
140
+ }
141
+ /** Raised when a step name already exists in the strategy. */
142
+ export class StepNameDuplicateError extends ModuleError {
143
+ static DEFAULT_RETRYABLE = false;
144
+ constructor(message = '', options) {
145
+ super('STEP_NAME_DUPLICATE', message, {}, options?.cause, options?.traceId, options?.retryable, options?.aiGuidance, options?.userFixable, options?.suggestion);
146
+ this.name = 'StepNameDuplicateError';
147
+ }
148
+ }
149
+ // ---------------------------------------------------------------------------
150
+ // PipelineEngine
151
+ // ---------------------------------------------------------------------------
152
+ /** Executes an ExecutionStrategy against a PipelineContext, returning the final output and a complete execution trace. */
153
+ export class PipelineEngine {
154
+ /** Run every step in the strategy against ctx, respecting flow-control actions (continue, skip_to, abort). */
155
+ async run(strategy, ctx) {
156
+ const pipelineStart = performance.now();
157
+ const steps = strategy.steps;
158
+ const trace = {
159
+ moduleId: ctx.moduleId,
160
+ strategyName: strategy.name,
161
+ steps: [],
162
+ totalDurationMs: 0,
163
+ success: false,
164
+ };
165
+ ctx.trace = trace;
166
+ let idx = 0;
167
+ while (idx < steps.length) {
168
+ const step = steps[idx];
169
+ const stepStart = performance.now();
170
+ const result = await step.execute(ctx);
171
+ const durationMs = performance.now() - stepStart;
172
+ trace.steps.push({
173
+ name: step.name,
174
+ durationMs,
175
+ result,
176
+ skipped: false,
177
+ decisionPoint: false,
178
+ });
179
+ if (result.action === 'continue') {
180
+ idx += 1;
181
+ }
182
+ else if (result.action === 'abort') {
183
+ trace.totalDurationMs = performance.now() - pipelineStart;
184
+ trace.success = false;
185
+ throw new PipelineAbortError(step.name, result.explanation ?? null, result.alternatives ?? null, trace);
186
+ }
187
+ else if (result.action === 'skip_to') {
188
+ const target = result.skipTo ?? '';
189
+ const targetIdx = steps.findIndex((s, i) => i > idx && s.name === target);
190
+ if (targetIdx === -1) {
191
+ throw new StepNotFoundError(`skip_to target '${target}' not found after step '${step.name}'`);
192
+ }
193
+ // Mark skipped steps in trace
194
+ for (let skipIdx = idx + 1; skipIdx < targetIdx; skipIdx++) {
195
+ trace.steps.push({
196
+ name: steps[skipIdx].name,
197
+ durationMs: 0,
198
+ result: { action: 'continue' },
199
+ skipped: true,
200
+ decisionPoint: false,
201
+ });
202
+ }
203
+ idx = targetIdx;
204
+ }
205
+ else {
206
+ throw new StepNotFoundError(`Unknown step action: '${result.action}'`);
207
+ }
208
+ }
209
+ trace.totalDurationMs = performance.now() - pipelineStart;
210
+ trace.success = true;
211
+ return [ctx.output ?? null, trace];
212
+ }
213
+ }
214
+ /** Raised when a referenced strategy does not exist. */
215
+ export class StrategyNotFoundError extends ModuleError {
216
+ static DEFAULT_RETRYABLE = false;
217
+ constructor(message = '', options) {
218
+ super('STRATEGY_NOT_FOUND', message, {}, options?.cause, options?.traceId, options?.retryable, options?.aiGuidance, options?.userFixable, options?.suggestion);
219
+ this.name = 'StrategyNotFoundError';
220
+ }
221
+ }
222
+ //# sourceMappingURL=pipeline.js.map