@smthrs/plugin 0.0.0-stage → 1.0.0-rc.4

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 (118) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/LICENSE +21 -0
  3. package/README.md +86 -2
  4. package/dist/cjs/Config.d.ts +129 -0
  5. package/dist/cjs/Config.d.ts.map +1 -0
  6. package/dist/cjs/Config.js +115 -0
  7. package/dist/cjs/Config.js.map +7 -0
  8. package/dist/cjs/Hooks.d.ts +176 -0
  9. package/dist/cjs/Hooks.d.ts.map +1 -0
  10. package/dist/cjs/Hooks.js +34 -0
  11. package/dist/cjs/Hooks.js.map +7 -0
  12. package/dist/cjs/Kernel.d.ts +81 -0
  13. package/dist/cjs/Kernel.d.ts.map +1 -0
  14. package/dist/cjs/Kernel.js +57 -0
  15. package/dist/cjs/Kernel.js.map +7 -0
  16. package/dist/cjs/Plugin.d.ts +71 -0
  17. package/dist/cjs/Plugin.d.ts.map +1 -0
  18. package/dist/cjs/Plugin.js +25 -0
  19. package/dist/cjs/Plugin.js.map +7 -0
  20. package/dist/cjs/PluginError.d.ts +50 -0
  21. package/dist/cjs/PluginError.d.ts.map +1 -0
  22. package/dist/cjs/PluginError.js +58 -0
  23. package/dist/cjs/PluginError.js.map +7 -0
  24. package/dist/cjs/Plugins.d.ts +97 -0
  25. package/dist/cjs/Plugins.d.ts.map +1 -0
  26. package/dist/cjs/Plugins.js +160 -0
  27. package/dist/cjs/Plugins.js.map +7 -0
  28. package/dist/cjs/Resolve.d.ts +128 -0
  29. package/dist/cjs/Resolve.d.ts.map +1 -0
  30. package/dist/cjs/Resolve.js +343 -0
  31. package/dist/cjs/Resolve.js.map +7 -0
  32. package/dist/cjs/index.d.ts +83 -0
  33. package/dist/cjs/index.d.ts.map +1 -0
  34. package/dist/cjs/index.js +45 -0
  35. package/dist/cjs/index.js.map +7 -0
  36. package/dist/cjs/internal/Boundary.d.ts +96 -0
  37. package/dist/cjs/internal/Boundary.d.ts.map +1 -0
  38. package/dist/cjs/internal/Boundary.js +129 -0
  39. package/dist/cjs/internal/Boundary.js.map +7 -0
  40. package/dist/cjs/internal/mergePluginLayers.d.ts +21 -0
  41. package/dist/cjs/internal/mergePluginLayers.d.ts.map +1 -0
  42. package/dist/cjs/internal/mergePluginLayers.js +57 -0
  43. package/dist/cjs/internal/mergePluginLayers.js.map +7 -0
  44. package/dist/cjs/internal/snapshotCacheEnvironment.d.ts +19 -0
  45. package/dist/cjs/internal/snapshotCacheEnvironment.d.ts.map +1 -0
  46. package/dist/cjs/internal/snapshotCacheEnvironment.js +92 -0
  47. package/dist/cjs/internal/snapshotCacheEnvironment.js.map +7 -0
  48. package/dist/cjs/package.json +1 -0
  49. package/dist/esm/Config.d.ts +129 -0
  50. package/dist/esm/Config.d.ts.map +1 -0
  51. package/dist/esm/Config.js +160 -0
  52. package/dist/esm/Config.js.map +1 -0
  53. package/dist/esm/Hooks.d.ts +176 -0
  54. package/dist/esm/Hooks.d.ts.map +1 -0
  55. package/dist/esm/Hooks.js +56 -0
  56. package/dist/esm/Hooks.js.map +1 -0
  57. package/dist/esm/Kernel.d.ts +81 -0
  58. package/dist/esm/Kernel.d.ts.map +1 -0
  59. package/dist/esm/Kernel.js +58 -0
  60. package/dist/esm/Kernel.js.map +1 -0
  61. package/dist/esm/Plugin.d.ts +71 -0
  62. package/dist/esm/Plugin.d.ts.map +1 -0
  63. package/dist/esm/Plugin.js +20 -0
  64. package/dist/esm/Plugin.js.map +1 -0
  65. package/dist/esm/PluginError.d.ts +50 -0
  66. package/dist/esm/PluginError.d.ts.map +1 -0
  67. package/dist/esm/PluginError.js +53 -0
  68. package/dist/esm/PluginError.js.map +1 -0
  69. package/dist/esm/Plugins.d.ts +97 -0
  70. package/dist/esm/Plugins.d.ts.map +1 -0
  71. package/dist/esm/Plugins.js +178 -0
  72. package/dist/esm/Plugins.js.map +1 -0
  73. package/dist/esm/Resolve.d.ts +128 -0
  74. package/dist/esm/Resolve.d.ts.map +1 -0
  75. package/dist/esm/Resolve.js +367 -0
  76. package/dist/esm/Resolve.js.map +1 -0
  77. package/dist/esm/index.d.ts +83 -0
  78. package/dist/esm/index.d.ts.map +1 -0
  79. package/dist/esm/index.js +48 -0
  80. package/dist/esm/index.js.map +1 -0
  81. package/dist/esm/internal/Boundary.d.ts +96 -0
  82. package/dist/esm/internal/Boundary.d.ts.map +1 -0
  83. package/dist/esm/internal/Boundary.js +162 -0
  84. package/dist/esm/internal/Boundary.js.map +1 -0
  85. package/dist/esm/internal/mergePluginLayers.d.ts +21 -0
  86. package/dist/esm/internal/mergePluginLayers.d.ts.map +1 -0
  87. package/dist/esm/internal/mergePluginLayers.js +41 -0
  88. package/dist/esm/internal/mergePluginLayers.js.map +1 -0
  89. package/dist/esm/internal/snapshotCacheEnvironment.d.ts +19 -0
  90. package/dist/esm/internal/snapshotCacheEnvironment.d.ts.map +1 -0
  91. package/dist/esm/internal/snapshotCacheEnvironment.js +63 -0
  92. package/dist/esm/internal/snapshotCacheEnvironment.js.map +1 -0
  93. package/docs/README.md +131 -0
  94. package/docs/api.md +522 -0
  95. package/docs/concepts/configuration.md +111 -0
  96. package/docs/concepts/hook-kinds.md +107 -0
  97. package/docs/concepts/resolution.md +132 -0
  98. package/docs/guides/cache-identity.md +106 -0
  99. package/docs/guides/contribute-services.md +84 -0
  100. package/docs/guides/host-your-own-hooks.md +129 -0
  101. package/docs/guides/order-handlers.md +76 -0
  102. package/docs/guides/select-plugins.md +72 -0
  103. package/docs/guides/testing.md +149 -0
  104. package/docs/installation.md +71 -0
  105. package/docs/quickstart.md +151 -0
  106. package/docs/troubleshooting.md +179 -0
  107. package/package.json +179 -3
  108. package/src/Config.ts +207 -0
  109. package/src/Hooks.ts +212 -0
  110. package/src/Kernel.ts +119 -0
  111. package/src/Plugin.ts +80 -0
  112. package/src/PluginError.ts +62 -0
  113. package/src/Plugins.ts +254 -0
  114. package/src/Resolve.ts +535 -0
  115. package/src/index.ts +91 -0
  116. package/src/internal/Boundary.ts +252 -0
  117. package/src/internal/mergePluginLayers.ts +57 -0
  118. package/src/internal/snapshotCacheEnvironment.ts +77 -0
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Hooks_exports = {};
20
+ __export(Hooks_exports, {
21
+ engineHooks: () => engineHooks,
22
+ handlerOf: () => handlerOf,
23
+ orderOf: () => orderOf
24
+ });
25
+ module.exports = __toCommonJS(Hooks_exports);
26
+ const sharedHooks = /* @__PURE__ */ Object.create(null);
27
+ Object.defineProperties(sharedHooks, {
28
+ config: { value: "waterfall", enumerable: true },
29
+ configResolved: { value: "parallel", enumerable: true }
30
+ });
31
+ const engineHooks = Object.freeze(sharedHooks);
32
+ const handlerOf = (entry) => typeof entry === "function" ? entry : entry.handler;
33
+ const orderOf = (entry) => typeof entry === "function" ? void 0 : entry.order;
34
+ //# sourceMappingURL=Hooks.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Hooks.ts"],
4
+ "sourcesContent": ["/**\n * The typed hook surface: hook kinds, the hook entry shape, and the shared\n * kernel's base hook catalog.\n *\n * The public package contract is documented at\n * {@link https://smithers.sh/docs/reference/api/plugin}. The shared catalog is limited to\n * `config` and `configResolved`;\n * `@smthrs/agent` adds only `cellRegistry`, `cellFlows`, and\n * `cellModelRequest`. Durable-core lifecycle policy is not a hook catalog.\n *\n * `FlowsHooks` is **open for augmentation, closed for dispatch**: a host\n * declares its hooks with `declare module \"@smthrs/plugin\"`, supplies the\n * matching runtime catalog, and dispatches only that bounded set.\n *\n * @since 1.0.0-rc.0\n */\n\nimport type * as Effect from \"effect/Effect\"\n\n/**\n * Dispatch semantics of a hook, fixed by the core.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type HookKind = \"sequential\" | \"parallel\" | \"first\" | \"waterfall\"\n\ndeclare const HookTypeId: unique symbol\n\n/**\n * Phantom carrier that records a hook's kind and handler type in the type\n * system without adding anything at runtime.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface HookMeta<K extends HookKind, F> {\n readonly [HookTypeId]?: { readonly kind: K; readonly handler: F }\n}\n\n/**\n * The object form of a hook entry: Vite's per-hook ordering object, verbatim.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface HookObject<F> {\n readonly order?: \"pre\" | \"post\" | undefined\n readonly handler: F\n}\n\n/**\n * A hook entry is either the bare handler or `{ order?, handler }`.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type HookEntry<K extends HookKind, F> = (F | HookObject<F>) & HookMeta<K, F>\n\n/**\n * Every handler runs, in resolved order, one at a time.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type SequentialHook<F> = HookEntry<\"sequential\", F>\n\n/**\n * Every handler runs concurrently; results are ignored and failures are\n * returned to the caller rather than failing it.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type ParallelHook<F> = HookEntry<\"parallel\", F>\n\n/**\n * Handlers run in order until one returns `Option.some`.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type FirstHook<F> = HookEntry<\"first\", F>\n\n/**\n * Each handler receives the previous handler's output.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type WaterfallHook<F> = HookEntry<\"waterfall\", F>\n\n/**\n * Extracts the declared kind of a hook entry type.\n *\n * @category type-level\n * @since 1.0.0-rc.0\n */\nexport type KindOf<T> = T extends HookMeta<infer K, any> ? K : never\n\n/**\n * The runtime catalog a host supplies for a hook interface: each hook name\n * mapped to its kind. A name declared in `H` must carry the kind its type\n * declares. Names outside `H` are admitted with any kind, because the type\n * system cannot enumerate an augmentable interface; resolution checks them\n * at runtime and dispatch refuses a kind that disagrees with the catalog.\n *\n * @category type-level\n * @since 1.0.0-rc.0\n */\nexport type HookCatalog<H> =\n & { readonly [K in keyof H & string]?: KindOf<H[K]> }\n & { readonly [name: string]: HookKind | undefined }\n\n/**\n * Extracts the handler type of a hook entry type.\n *\n * @category type-level\n * @since 1.0.0-rc.0\n */\nexport type HandlerOf<T> = T extends HookMeta<any, infer F> ? F : never\n\n/**\n * Selects the hook names of a given kind from a hook interface.\n *\n * @category type-level\n * @since 1.0.0-rc.0\n */\nexport type KeysOfKind<H, K extends HookKind> =\n & {\n [P in keyof H]: KindOf<H[P]> extends K ? P : never\n }[keyof H]\n & string\n\n/**\n * Extracts the positional argument tuple accepted by a hook entry.\n *\n * @category type-level\n * @since 1.0.0-rc.0\n */\nexport type ArgsOf<T> = HandlerOf<T> extends (...args: infer A) => any ? A : never\n\n/**\n * Extracts the Effect returned by a hook entry.\n *\n * @category type-level\n * @since 1.0.0-rc.0\n */\nexport type ReturnOf<T> = HandlerOf<T> extends (...args: any) => infer R ? R : never\n\n/**\n * Extracts the success value returned by a hook entry's Effect.\n *\n * @category type-level\n * @since 1.0.0-rc.0\n */\nexport type SuccessOf<T> = ReturnOf<T> extends Effect.Effect<infer A, any, any> ? A : never\n\n/**\n * Extracts the context required by a hook entry's Effect.\n *\n * @category type-level\n * @since 1.0.0-rc.0\n */\nexport type ContextOf<T> = ReturnOf<T> extends Effect.Effect<any, any, infer R> ? R : never\n\n/**\n * Runtime catalog of the shared kernel's hook names and kinds.\n *\n * The type system cannot enumerate an augmentable interface, so this constant\n * is what the `unknown_hook` guard checks against. A host passes its own\n * superset to {@link resolve}. The cell harness adds only the hooks it\n * dispatches; lifecycle and engine-policy hooks do not belong here.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nconst sharedHooks: { config: \"waterfall\"; configResolved: \"parallel\" } = Object.create(null)\nObject.defineProperties(sharedHooks, {\n config: { value: \"waterfall\", enumerable: true },\n configResolved: { value: \"parallel\", enumerable: true }\n})\n/**\n * Frozen runtime catalog for the shared configuration hooks.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport const engineHooks: Readonly<{\n readonly config: \"waterfall\"\n readonly configResolved: \"parallel\"\n}> = Object.freeze(sharedHooks)\n\n/**\n * Normalizes a hook entry to its handler.\n *\n * @category utils\n * @since 1.0.0-rc.0\n */\nexport const handlerOf = (entry: unknown): (...args: Array<any>) => unknown =>\n typeof entry === \"function\"\n ? entry as (...args: Array<any>) => unknown\n : (entry as HookObject<(...args: Array<any>) => unknown>).handler\n\n/**\n * Reads the per-hook `order` of a hook entry.\n *\n * @category utils\n * @since 1.0.0-rc.0\n */\nexport const orderOf = (entry: unknown): \"pre\" | \"post\" | undefined =>\n typeof entry === \"function\" ? undefined : (entry as HookObject<unknown>).order\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiLA,MAAM,cAAmE,uBAAO,OAAO,IAAI;AAC3F,OAAO,iBAAiB,aAAa;AAAA,EACnC,QAAQ,EAAE,OAAO,aAAa,YAAY,KAAK;AAAA,EAC/C,gBAAgB,EAAE,OAAO,YAAY,YAAY,KAAK;AACxD,CAAC;AAOM,MAAM,cAGR,OAAO,OAAO,WAAW;AAQvB,MAAM,YAAY,CAAC,UACxB,OAAO,UAAU,aACb,QACC,MAAuD;AAQvD,MAAM,UAAU,CAAC,UACtB,OAAO,UAAU,aAAa,SAAa,MAA8B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Startup: resolve the plugin list, run the config pipeline, hand back a
3
+ * dispatcher, a frozen config, and the merged layer.
4
+ *
5
+ * The public package contract is documented at
6
+ * {@link https://smithers.sh/docs/reference/api/plugin}, with the shipped host catalog in
7
+ * `packages/smithers/agent/src/CellPlugin.ts`. D14 in
8
+ * `docs/pages/design-decisions.md` keeps durable policy outside these hooks.
9
+ *
10
+ * Order of operations, per the spec:
11
+ *
12
+ * 1. flatten / filter / validate / order the plugin list;
13
+ * 2. `config` waterfall: each plugin may return a partial to deep-merge;
14
+ * 3. decode and freeze into a `ResolvedConfig` (`config_invalid` on failure);
15
+ * 4. `configResolved` parallel: observers capture the final config;
16
+ * 5. plugin `layer`s merge left-to-right.
17
+ *
18
+ * @since 1.0.0-rc.0
19
+ */
20
+ import * as Effect from "effect/Effect";
21
+ import type * as Layer from "effect/Layer";
22
+ import type { FlowsConfig, ResolvedConfig } from "./Config.ts";
23
+ import type { ContextOf } from "./Hooks.ts";
24
+ import type { FlowsHooks } from "./index.ts";
25
+ import type { PluginInput } from "./Plugin.ts";
26
+ import type { PluginError } from "./PluginError.ts";
27
+ import * as Plugins from "./Plugins.ts";
28
+ import * as Resolve from "./Resolve.ts";
29
+ /**
30
+ * Everything startup produces from a plugin list and a raw config.
31
+ *
32
+ * `observerErrors` carries `configResolved` failures: parallel observers are
33
+ * lossy by contract, so they are reported rather than fatal.
34
+ *
35
+ * @category models
36
+ * @since 1.0.0-rc.0
37
+ */
38
+ export interface Kernel<H = FlowsHooks> {
39
+ readonly plugins: Plugins.Service<H>;
40
+ readonly config: ResolvedConfig;
41
+ readonly layer: Layer.Layer<any, PluginError, any>;
42
+ readonly observerErrors: ReadonlyArray<PluginError>;
43
+ }
44
+ type HookAt<H, K extends string> = K extends keyof H ? H[K] : never;
45
+ /**
46
+ * The services a hook interface's `config` hook requires at startup. `never`
47
+ * for the shared `FlowsHooks`, whose startup hooks are context-free.
48
+ *
49
+ * @category type-level
50
+ * @since 1.0.0-rc.0
51
+ */
52
+ export type ConfigContext<H> = ContextOf<HookAt<H, "config">>;
53
+ /**
54
+ * The services a hook interface's startup hooks require: the union of the
55
+ * `config` and `configResolved` requirements. `Kernel.make` cannot supply
56
+ * them itself, so they surface in its Effect and the caller provides them.
57
+ *
58
+ * @category type-level
59
+ * @since 1.0.0-rc.0
60
+ */
61
+ export type StartupContext<H> = ConfigContext<H> | ContextOf<HookAt<H, "configResolved">>;
62
+ /**
63
+ * Snapshots the config before dispatching the `config` waterfall, then
64
+ * admits the result as a frozen `ResolvedConfig`.
65
+ *
66
+ * @category constructors
67
+ * @since 1.0.0-rc.0
68
+ */
69
+ export declare const runConfig: <H = FlowsHooks>(plugins: Plugins.Service<H>, config: FlowsConfig) => Effect.Effect<ResolvedConfig, PluginError, ConfigContext<H>>;
70
+ /**
71
+ * Resolves plugins, executes the config pipeline, and merges plugin layers.
72
+ * The positional `config` is the kernel's only pre-resolution configuration;
73
+ * the options object cannot declare a second source, and a `config` key
74
+ * supplied anyway fails with `invalid_plugin` at `$options.config`.
75
+ *
76
+ * @category constructors
77
+ * @since 1.0.0-rc.0
78
+ */
79
+ export declare const make: <H = FlowsHooks>(input: PluginInput<NoInfer<H>>, config?: FlowsConfig, options?: Omit<Resolve.Options<NoInfer<H>>, "config">) => Effect.Effect<Kernel<H>, PluginError, StartupContext<H>>;
80
+ export {};
81
+ //# sourceMappingURL=Kernel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Kernel.d.ts","sourceRoot":"","sources":["../../src/Kernel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,KAAK,EAAE,UA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ACH,eAAO,MAAM,IAAI,GAAI,CAAC,GAAG,UAAU,EACjC,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAC9B,SAAQ,WAAgB,EACxB,UAAS,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAM,KACxD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC,CAgBtD,CAAA"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var Kernel_exports = {};
30
+ __export(Kernel_exports, {
31
+ make: () => make,
32
+ runConfig: () => runConfig
33
+ });
34
+ module.exports = __toCommonJS(Kernel_exports);
35
+ var Effect = __toESM(require("effect/Effect"), 1);
36
+ var Config = __toESM(require("./Config.js"), 1);
37
+ var Plugins = __toESM(require("./Plugins.js"), 1);
38
+ var Resolve = __toESM(require("./Resolve.js"), 1);
39
+ const runConfig = (plugins, config) => Effect.gen(function* () {
40
+ const initial = yield* Config.snapshot(config);
41
+ const merged = yield* plugins.waterfall("config", initial, Config.merge);
42
+ return yield* Config.resolve(merged);
43
+ });
44
+ const make = (input, config = {}, options = {}) => Effect.gen(function* () {
45
+ const initial = yield* Config.snapshot(config);
46
+ const resolved = yield* Resolve.resolve(input, options, initial);
47
+ const dispatcher = Plugins.make(resolved);
48
+ const frozen = yield* runConfig(dispatcher, initial);
49
+ const observerErrors = yield* dispatcher.parallel("configResolved", frozen);
50
+ return Object.freeze({
51
+ plugins: dispatcher,
52
+ config: frozen,
53
+ layer: Resolve.layer(resolved),
54
+ observerErrors
55
+ });
56
+ });
57
+ //# sourceMappingURL=Kernel.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Kernel.ts"],
4
+ "sourcesContent": ["/**\n * Startup: resolve the plugin list, run the config pipeline, hand back a\n * dispatcher, a frozen config, and the merged layer.\n *\n * The public package contract is documented at\n * {@link https://smithers.sh/docs/reference/api/plugin}, with the shipped host catalog in\n * `packages/smithers/agent/src/CellPlugin.ts`. D14 in\n * `docs/pages/design-decisions.md` keeps durable policy outside these hooks.\n *\n * Order of operations, per the spec:\n *\n * 1. flatten / filter / validate / order the plugin list;\n * 2. `config` waterfall: each plugin may return a partial to deep-merge;\n * 3. decode and freeze into a `ResolvedConfig` (`config_invalid` on failure);\n * 4. `configResolved` parallel: observers capture the final config;\n * 5. plugin `layer`s merge left-to-right.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport type * as Layer from \"effect/Layer\"\nimport type { FlowsConfig, ResolvedConfig } from \"./Config.ts\"\nimport * as Config from \"./Config.ts\"\nimport type { ContextOf } from \"./Hooks.ts\"\nimport type { FlowsHooks } from \"./index.ts\"\nimport type { PluginInput } from \"./Plugin.ts\"\nimport type { PluginError } from \"./PluginError.ts\"\nimport * as Plugins from \"./Plugins.ts\"\nimport * as Resolve from \"./Resolve.ts\"\n\n/**\n * Everything startup produces from a plugin list and a raw config.\n *\n * `observerErrors` carries `configResolved` failures: parallel observers are\n * lossy by contract, so they are reported rather than fatal.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Kernel<H = FlowsHooks> {\n readonly plugins: Plugins.Service<H>\n readonly config: ResolvedConfig\n readonly layer: Layer.Layer<any, PluginError, any>\n readonly observerErrors: ReadonlyArray<PluginError>\n}\n\ntype HookAt<H, K extends string> = K extends keyof H ? H[K] : never\n\n/**\n * The services a hook interface's `config` hook requires at startup. `never`\n * for the shared `FlowsHooks`, whose startup hooks are context-free.\n *\n * @category type-level\n * @since 1.0.0-rc.0\n */\nexport type ConfigContext<H> = ContextOf<HookAt<H, \"config\">>\n\n/**\n * The services a hook interface's startup hooks require: the union of the\n * `config` and `configResolved` requirements. `Kernel.make` cannot supply\n * them itself, so they surface in its Effect and the caller provides them.\n *\n * @category type-level\n * @since 1.0.0-rc.0\n */\nexport type StartupContext<H> = ConfigContext<H> | ContextOf<HookAt<H, \"configResolved\">>\n\n/**\n * Snapshots the config before dispatching the `config` waterfall, then\n * admits the result as a frozen `ResolvedConfig`.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const runConfig = <H = FlowsHooks>(\n plugins: Plugins.Service<H>,\n config: FlowsConfig\n): Effect.Effect<ResolvedConfig, PluginError, ConfigContext<H>> =>\n Effect.gen(function*() {\n const initial = yield* Config.snapshot(config)\n const merged = yield* (plugins.waterfall as unknown as (\n hook: string,\n initial: FlowsConfig,\n merge: (previous: FlowsConfig, patch: unknown) => FlowsConfig\n ) => Effect.Effect<FlowsConfig, PluginError, ConfigContext<H>>)(\"config\", initial, Config.merge)\n return yield* Config.resolve(merged)\n })\n\n/**\n * Resolves plugins, executes the config pipeline, and merges plugin layers.\n * The positional `config` is the kernel's only pre-resolution configuration;\n * the options object cannot declare a second source, and a `config` key\n * supplied anyway fails with `invalid_plugin` at `$options.config`.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const make = <H = FlowsHooks>(\n input: PluginInput<NoInfer<H>>,\n config: FlowsConfig = {},\n options: Omit<Resolve.Options<NoInfer<H>>, \"config\"> = {}\n): Effect.Effect<Kernel<H>, PluginError, StartupContext<H>> =>\n Effect.gen(function*() {\n const initial = yield* Config.snapshot(config)\n const resolved = yield* Resolve.resolve<H>(input, options, initial)\n const dispatcher = Plugins.make<H>(resolved)\n const frozen = yield* runConfig(dispatcher, initial)\n const observerErrors = yield* (dispatcher.parallel as unknown as (\n hook: string,\n value: ResolvedConfig\n ) => Effect.Effect<ReadonlyArray<PluginError>, never, StartupContext<H>>)(\"configResolved\", frozen)\n return Object.freeze({\n plugins: dispatcher,\n config: frozen,\n layer: Resolve.layer(resolved),\n observerErrors\n })\n })\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBA,aAAwB;AAGxB,aAAwB;AAKxB,cAAyB;AACzB,cAAyB;AA8ClB,MAAM,YAAY,CACvB,SACA,WAEA,OAAO,IAAI,aAAY;AACrB,QAAM,UAAU,OAAO,OAAO,SAAS,MAAM;AAC7C,QAAM,SAAS,OAAQ,QAAQ,UAIiC,UAAU,SAAS,OAAO,KAAK;AAC/F,SAAO,OAAO,OAAO,QAAQ,MAAM;AACrC,CAAC;AAWI,MAAM,OAAO,CAClB,OACA,SAAsB,CAAC,GACvB,UAAuD,CAAC,MAExD,OAAO,IAAI,aAAY;AACrB,QAAM,UAAU,OAAO,OAAO,SAAS,MAAM;AAC7C,QAAM,WAAW,OAAO,QAAQ,QAAW,OAAO,SAAS,OAAO;AAClE,QAAM,aAAa,QAAQ,KAAQ,QAAQ;AAC3C,QAAM,SAAS,OAAO,UAAU,YAAY,OAAO;AACnD,QAAM,iBAAiB,OAAQ,WAAW,SAGgC,kBAAkB,MAAM;AAClG,SAAO,OAAO,OAAO;AAAA,IACnB,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,OAAO,QAAQ,MAAM,QAAQ;AAAA,IAC7B;AAAA,EACF,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The plugin object: a plain record produced by a factory function.
3
+ *
4
+ * The public package contract is documented at
5
+ * {@link https://smithers.sh/docs/reference/api/plugin}. The shipped consumer is the
6
+ * assembled cell host in `@smthrs/agent`;
7
+ * durable-core policy continues to use Effect services and constructor
8
+ * options rather than plugin lifecycle hooks.
9
+ *
10
+ * @since 1.0.0-rc.0
11
+ */
12
+ import type * as Layer from "effect/Layer";
13
+ import type { FlowsConfig } from "./Config.ts";
14
+ import type { FlowsHooks } from "./index.ts";
15
+ /**
16
+ * Conditional-inclusion predicate, mirroring Vite's `apply`.
17
+ *
18
+ * `"engine"` and `"harness"` select the matching plugin-kernel host. The
19
+ * assembled cell host resolves as `"harness"`; this does not make `"engine"` an
20
+ * engine-lifecycle hook registration.
21
+ *
22
+ * @category models
23
+ * @since 1.0.0-rc.0
24
+ */
25
+ export type Apply = "engine" | "harness" | ((config: FlowsConfig) => boolean);
26
+ /**
27
+ * A flows plugin.
28
+ *
29
+ * Generic over the hook interface so a harness can hold plugins typed against
30
+ * its augmented `FlowsHooks` without any inheritance machinery.
31
+ *
32
+ * @category models
33
+ * @since 1.0.0-rc.0
34
+ */
35
+ export interface FlowsPlugin<H = FlowsHooks> {
36
+ /** Required, unique. Convention: `flows-plugin-<thing>`. */
37
+ readonly name: string;
38
+ /**
39
+ * Semantic identity folded into sealed cache keys. Required when the host
40
+ * declares a cache environment. `Action.CacheEnvironment` is complete by
41
+ * contract, so a versionless composition is refused instead of claiming an
42
+ * ambiguous cross-run identity.
43
+ */
44
+ readonly version?: string | undefined;
45
+ /** Ordering group; omitted means `"normal"`. */
46
+ readonly enforce?: "pre" | "post" | undefined;
47
+ /** Conditional inclusion. */
48
+ readonly apply?: Apply | undefined;
49
+ /** Services this plugin contributes to the engine environment. */
50
+ readonly layer?: Layer.Layer<never, any, any> | undefined;
51
+ /** Typed hooks; only keys declared in the hook interface compile. */
52
+ readonly hooks?: Partial<H> | undefined;
53
+ }
54
+ /**
55
+ * What a `plugins` array may contain: plugins, falsy entries, and arrays nested
56
+ * up to `Resolve.maximumPluginDepth`: so a preset is just a function returning
57
+ * plugins.
58
+ *
59
+ * @category models
60
+ * @since 1.0.0-rc.0
61
+ */
62
+ export type PluginInput<H = FlowsHooks> = FlowsPlugin<H> | false | null | undefined | ReadonlyArray<PluginInput<H>>;
63
+ /**
64
+ * Identity constructor that pins a plugin literal to `FlowsPlugin` so excess
65
+ * hook keys are rejected at the definition site.
66
+ *
67
+ * @category constructors
68
+ * @since 1.0.0-rc.0
69
+ */
70
+ export declare const make: <H = FlowsHooks>(plugin: FlowsPlugin<H>) => FlowsPlugin<H>;
71
+ //# sourceMappingURL=Plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C;;;;;;;;;GASG;AACH,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAA;AAE7E;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,UAAU;IACzC,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,gDAAgD;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAAA;IAC7C,6BAA6B;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;IAClC,kEAAkE;IAClE,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,CAAA;IACzD,qEAAqE;IACrE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;CACxC;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,UAAU,IAClC,WAAW,CAAC,CAAC,CAAC,GACd,KAAK,GACL,IAAI,GACJ,SAAS,GACT,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;AAEjC;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,GAAG,UAAU,EAAE,QAAQ,WAAW,CAAC,CAAC,CAAC,KAAG,WAAW,CAAC,CAAC,CAAW,CAAA"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Plugin_exports = {};
20
+ __export(Plugin_exports, {
21
+ make: () => make
22
+ });
23
+ module.exports = __toCommonJS(Plugin_exports);
24
+ const make = (plugin) => plugin;
25
+ //# sourceMappingURL=Plugin.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Plugin.ts"],
4
+ "sourcesContent": ["/**\n * The plugin object: a plain record produced by a factory function.\n *\n * The public package contract is documented at\n * {@link https://smithers.sh/docs/reference/api/plugin}. The shipped consumer is the\n * assembled cell host in `@smthrs/agent`;\n * durable-core policy continues to use Effect services and constructor\n * options rather than plugin lifecycle hooks.\n *\n * @since 1.0.0-rc.0\n */\n\nimport type * as Layer from \"effect/Layer\"\nimport type { FlowsConfig } from \"./Config.ts\"\nimport type { FlowsHooks } from \"./index.ts\"\n\n/**\n * Conditional-inclusion predicate, mirroring Vite's `apply`.\n *\n * `\"engine\"` and `\"harness\"` select the matching plugin-kernel host. The\n * assembled cell host resolves as `\"harness\"`; this does not make `\"engine\"` an\n * engine-lifecycle hook registration.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Apply = \"engine\" | \"harness\" | ((config: FlowsConfig) => boolean)\n\n/**\n * A flows plugin.\n *\n * Generic over the hook interface so a harness can hold plugins typed against\n * its augmented `FlowsHooks` without any inheritance machinery.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface FlowsPlugin<H = FlowsHooks> {\n /** Required, unique. Convention: `flows-plugin-<thing>`. */\n readonly name: string\n /**\n * Semantic identity folded into sealed cache keys. Required when the host\n * declares a cache environment. `Action.CacheEnvironment` is complete by\n * contract, so a versionless composition is refused instead of claiming an\n * ambiguous cross-run identity.\n */\n readonly version?: string | undefined\n /** Ordering group; omitted means `\"normal\"`. */\n readonly enforce?: \"pre\" | \"post\" | undefined\n /** Conditional inclusion. */\n readonly apply?: Apply | undefined\n /** Services this plugin contributes to the engine environment. */\n readonly layer?: Layer.Layer<never, any, any> | undefined\n /** Typed hooks; only keys declared in the hook interface compile. */\n readonly hooks?: Partial<H> | undefined\n}\n\n/**\n * What a `plugins` array may contain: plugins, falsy entries, and arrays nested\n * up to `Resolve.maximumPluginDepth`: so a preset is just a function returning\n * plugins.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type PluginInput<H = FlowsHooks> =\n | FlowsPlugin<H>\n | false\n | null\n | undefined\n | ReadonlyArray<PluginInput<H>>\n\n/**\n * Identity constructor that pins a plugin literal to `FlowsPlugin` so excess\n * hook keys are rejected at the definition site.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const make = <H = FlowsHooks>(plugin: FlowsPlugin<H>): FlowsPlugin<H> => plugin\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+EO,MAAM,OAAO,CAAiB,WAA2C;",
6
+ "names": []
7
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The single typed failure of the plugin kernel.
3
+ *
4
+ * The public package contract is documented at
5
+ * {@link https://smithers.sh/docs/reference/api/plugin}; D14 in
6
+ * `docs/pages/design-decisions.md` bounds it to host-owned cell hooks.
7
+ *
8
+ * @since 1.0.0-rc.0
9
+ */
10
+ import * as Schema from "effect/Schema";
11
+ /**
12
+ * Closed set of plugin-system failure codes.
13
+ *
14
+ * @category models
15
+ * @since 1.0.0-rc.0
16
+ */
17
+ export declare const PluginErrorCode: Schema.Literals<readonly ["duplicate_name", "unknown_hook", "hook_kind_mismatch", "invalid_plugin", "apply_failed", "config_invalid", "cache_environment_invalid", "invalid_hook_result", "resource_limit", "hook_failed", "layer_failed"]>;
18
+ /**
19
+ * Closed set of plugin-system failure codes.
20
+ *
21
+ * @category models
22
+ * @since 1.0.0-rc.0
23
+ */
24
+ export type PluginErrorCode = typeof PluginErrorCode.Type;
25
+ declare const PluginError_base: Schema.Class<PluginError, Schema.TaggedStruct<"flows/plugin/PluginError", {
26
+ readonly code: Schema.Literals<readonly ["duplicate_name", "unknown_hook", "hook_kind_mismatch", "invalid_plugin", "apply_failed", "config_invalid", "cache_environment_invalid", "invalid_hook_result", "resource_limit", "hook_failed", "layer_failed"]>;
27
+ readonly message: Schema.String;
28
+ readonly plugin: Schema.optional<Schema.String>;
29
+ readonly hook: Schema.optional<Schema.String>;
30
+ readonly path: Schema.optional<Schema.String>;
31
+ readonly cause: Schema.optional<Schema.Unknown>;
32
+ }>, import("effect/Cause").YieldableError>;
33
+ /**
34
+ * Failure raised by plugin resolution, hook dispatch, config execution, or
35
+ * layer construction.
36
+ *
37
+ * Parallel observer failures never fail the caller; they are returned from
38
+ * `Plugins.parallel` with this same shape so they can be journalled on the
39
+ * lossy telemetry channel.
40
+ *
41
+ * `cause` is the plugin's unredacted failure and may hold secrets; hosts
42
+ * redact it before logging, persisting, or transmitting the error.
43
+ *
44
+ * @category errors
45
+ * @since 1.0.0-rc.0
46
+ */
47
+ export declare class PluginError extends PluginError_base {
48
+ }
49
+ export {};
50
+ //# sourceMappingURL=PluginError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginError.d.ts","sourceRoot":"","sources":["../../src/PluginError.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,eAAe,6OAY1B,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAA;;;;;;;;;AAEzD;;;;;;;;;;;;;GAaG;AACH,qBAAa,WAAY,SAAQ,gBAO/B;CAAG"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var PluginError_exports = {};
30
+ __export(PluginError_exports, {
31
+ PluginError: () => PluginError,
32
+ PluginErrorCode: () => PluginErrorCode
33
+ });
34
+ module.exports = __toCommonJS(PluginError_exports);
35
+ var Schema = __toESM(require("effect/Schema"), 1);
36
+ const PluginErrorCode = Schema.Literals([
37
+ "duplicate_name",
38
+ "unknown_hook",
39
+ "hook_kind_mismatch",
40
+ "invalid_plugin",
41
+ "apply_failed",
42
+ "config_invalid",
43
+ "cache_environment_invalid",
44
+ "invalid_hook_result",
45
+ "resource_limit",
46
+ "hook_failed",
47
+ "layer_failed"
48
+ ]);
49
+ class PluginError extends Schema.TaggedError()("flows/plugin/PluginError", {
50
+ code: PluginErrorCode,
51
+ message: Schema.String,
52
+ plugin: Schema.optional(Schema.String),
53
+ hook: Schema.optional(Schema.String),
54
+ path: Schema.optional(Schema.String),
55
+ cause: Schema.optional(Schema.Unknown)
56
+ }) {
57
+ }
58
+ //# sourceMappingURL=PluginError.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/PluginError.ts"],
4
+ "sourcesContent": ["/**\n * The single typed failure of the plugin kernel.\n *\n * The public package contract is documented at\n * {@link https://smithers.sh/docs/reference/api/plugin}; D14 in\n * `docs/pages/design-decisions.md` bounds it to host-owned cell hooks.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as Schema from \"effect/Schema\"\n\n/**\n * Closed set of plugin-system failure codes.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport const PluginErrorCode = Schema.Literals([\n \"duplicate_name\",\n \"unknown_hook\",\n \"hook_kind_mismatch\",\n \"invalid_plugin\",\n \"apply_failed\",\n \"config_invalid\",\n \"cache_environment_invalid\",\n \"invalid_hook_result\",\n \"resource_limit\",\n \"hook_failed\",\n \"layer_failed\"\n])\n\n/**\n * Closed set of plugin-system failure codes.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type PluginErrorCode = typeof PluginErrorCode.Type\n\n/**\n * Failure raised by plugin resolution, hook dispatch, config execution, or\n * layer construction.\n *\n * Parallel observer failures never fail the caller; they are returned from\n * `Plugins.parallel` with this same shape so they can be journalled on the\n * lossy telemetry channel.\n *\n * `cause` is the plugin's unredacted failure and may hold secrets; hosts\n * redact it before logging, persisting, or transmitting the error.\n *\n * @category errors\n * @since 1.0.0-rc.0\n */\nexport class PluginError extends Schema.TaggedError<PluginError>()(\"flows/plugin/PluginError\", {\n code: PluginErrorCode,\n message: Schema.String,\n plugin: Schema.optional(Schema.String),\n hook: Schema.optional(Schema.String),\n path: Schema.optional(Schema.String),\n cause: Schema.optional(Schema.Unknown)\n}) {}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,aAAwB;AAQjB,MAAM,kBAAkB,OAAO,SAAS;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAwBM,MAAM,oBAAoB,OAAO,YAAyB,EAAE,4BAA4B;AAAA,EAC7F,MAAM;AAAA,EACN,SAAS,OAAO;AAAA,EAChB,QAAQ,OAAO,SAAS,OAAO,MAAM;AAAA,EACrC,MAAM,OAAO,SAAS,OAAO,MAAM;AAAA,EACnC,MAAM,OAAO,SAAS,OAAO,MAAM;AAAA,EACnC,OAAO,OAAO,SAAS,OAAO,OAAO;AACvC,CAAC,EAAE;AAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,97 @@
1
+ /**
2
+ * The dispatcher: a plain service over a resolved plugin list, generic over the
3
+ * hook interface.
4
+ *
5
+ * The public package contract is documented at
6
+ * {@link https://smithers.sh/docs/reference/api/plugin}. Each host holds an instance over its
7
+ * augmented `FlowsHooks` and may dispatch only the runtime catalog it supplied.
8
+ * The shipped cell host owns the three
9
+ * waterfalls declared in `packages/smithers/agent/src/CellPlugin.ts`; there is
10
+ * no engine-wide lifecycle dispatcher.
11
+ *
12
+ * Cancellation is fiber interruption via scope closure; nothing here threads an
13
+ * `AbortSignal`.
14
+ *
15
+ * @since 1.0.0-rc.0
16
+ */
17
+ import * as Context from "effect/Context";
18
+ import * as Effect from "effect/Effect";
19
+ import * as Layer from "effect/Layer";
20
+ import type { ArgsOf, ContextOf, KeysOfKind, SuccessOf } from "./Hooks.ts";
21
+ import type { FlowsHooks } from "./index.ts";
22
+ import { PluginError } from "./PluginError.ts";
23
+ import { type HandlerRecord, type Resolved } from "./Resolve.ts";
24
+ /**
25
+ * The dispatch surface.
26
+ *
27
+ * @category models
28
+ * @since 1.0.0-rc.0
29
+ */
30
+ export interface Service<H = FlowsHooks> {
31
+ /** The resolved list this dispatcher walks. */
32
+ readonly resolved: Resolved<H>;
33
+ /** Frozen, ordered handler records for a hook. */
34
+ readonly handlers: (hook: string) => ReadonlyArray<HandlerRecord>;
35
+ /** Runs every handler in resolved order, one at a time. */
36
+ readonly sequential: <K extends KeysOfKind<H, "sequential">>(hook: K, ...args: ArgsOf<H[K]>) => Effect.Effect<ReadonlyArray<SuccessOf<H[K]>>, PluginError, ContextOf<H[K]>>;
37
+ /**
38
+ * Runs every handler concurrently, ignoring results. Never fails: handler
39
+ * failures are returned so the caller can report them at its own boundary.
40
+ */
41
+ readonly parallel: <K extends KeysOfKind<H, "parallel">>(hook: K, ...args: ArgsOf<H[K]>) => Effect.Effect<ReadonlyArray<PluginError>, never, ContextOf<H[K]>>;
42
+ /** Runs handlers in order until one returns `Option.some`. */
43
+ readonly first: <K extends KeysOfKind<H, "first">>(hook: K, ...args: ArgsOf<H[K]>) => Effect.Effect<SuccessOf<H[K]>, PluginError, ContextOf<H[K]>>;
44
+ /** Threads a value through every handler, merging each returned patch. */
45
+ readonly waterfall: <K extends KeysOfKind<H, "waterfall">>(hook: K, initial: ArgsOf<H[K]>[0], merge: (previous: ArgsOf<H[K]>[0], patch: Exclude<SuccessOf<H[K]>, void>) => ArgsOf<H[K]>[0]) => Effect.Effect<ArgsOf<H[K]>[0], PluginError, ContextOf<H[K]>>;
46
+ }
47
+ /**
48
+ * Builds a dispatcher over an already resolved plugin list.
49
+ *
50
+ * @category constructors
51
+ * @since 1.0.0-rc.0
52
+ */
53
+ export declare const make: <H = FlowsHooks>(resolved: Resolved<H>) => Service<H>;
54
+ /**
55
+ * A dispatcher with no plugins at all.
56
+ *
57
+ * @category constructors
58
+ * @since 1.0.0-rc.0
59
+ */
60
+ export declare const makeNoop: <H = FlowsHooks>() => Service<H>;
61
+ declare const Plugins_base: Context.ServiceClass<Plugins, "flows/plugin/Plugins", Service<FlowsHooks>>;
62
+ /**
63
+ * The shared dispatcher, as a service tag.
64
+ *
65
+ * This tag holds one dispatcher over the process-wide augmented `FlowsHooks`.
66
+ * `declare module "@smthrs/plugin"` augmentation is the supported extension
67
+ * mechanism for values placed in the tag. A host typed against a separate hook
68
+ * interface holds its `Service<H>` directly, as `@smthrs/agent` does, and does
69
+ * not use this tag or its layers.
70
+ *
71
+ * @category context
72
+ * @since 1.0.0-rc.0
73
+ */
74
+ export declare class Plugins extends Plugins_base {
75
+ }
76
+ /**
77
+ * Layer providing a dispatcher over an already resolved plugin list.
78
+ *
79
+ * This layer targets the shared augmented `FlowsHooks` catalog only. A host
80
+ * with a separate hook interface holds its `Service<H>` directly.
81
+ *
82
+ * @category layers
83
+ * @since 1.0.0-rc.0
84
+ */
85
+ export declare const layer: (resolved: Resolved) => Layer.Layer<Plugins>;
86
+ /**
87
+ * Layer providing a dispatcher with no plugins.
88
+ *
89
+ * This layer targets the shared augmented `FlowsHooks` catalog only. A host
90
+ * with a separate hook interface holds its `Service<H>` directly.
91
+ *
92
+ * @category layers
93
+ * @since 1.0.0-rc.0
94
+ */
95
+ export declare const layerNoop: Layer.Layer<Plugins>;
96
+ export {};
97
+ //# sourceMappingURL=Plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Plugins.d.ts","sourceRoot":"","sources":["../../src/Plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAY,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAA8B,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAoD5F;;;;;GAKG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,UAAU;IACrC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