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

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,178 @@
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 ImmutableMap from "@smthrs/canonical/ReadonlyMap";
18
+ import * as Context from "effect/Context";
19
+ import * as Effect from "effect/Effect";
20
+ import * as Layer from "effect/Layer";
21
+ import * as Option from "effect/Option";
22
+ import { engineHooks } from "./Hooks.js";
23
+ import { PluginError } from "./PluginError.js";
24
+ import { defaultParallelConcurrency } from "./Resolve.js";
25
+ const empty = Object.freeze([]);
26
+ // The typed catalog and the runtime catalog can only drift when a host casts
27
+ // around `KeysOfKind`; refuse before any handler runs rather than execute a
28
+ // hook under semantics its declaration never promised.
29
+ const kindMismatch = (resolved, hook, kind) => {
30
+ if (!Object.hasOwn(resolved.kinds, hook))
31
+ return undefined;
32
+ const declared = resolved.kinds[hook];
33
+ if (declared === kind)
34
+ return undefined;
35
+ return new PluginError({
36
+ code: "hook_kind_mismatch",
37
+ message: `hook "${hook}" is declared ${JSON.stringify(declared)} in the runtime catalog but was dispatched as ${JSON.stringify(kind)}`,
38
+ hook
39
+ });
40
+ };
41
+ const runHandler = (record, args) => {
42
+ const onCause = (cause) => Effect.fail(new PluginError({
43
+ code: "hook_failed",
44
+ message: `hook "${record.hook}" failed in plugin "${record.plugin}"`,
45
+ plugin: record.plugin,
46
+ hook: record.hook,
47
+ cause
48
+ }));
49
+ return Effect.sync(() => record.handler(...args)).pipe(Effect.catchCause(onCause), Effect.flatMap((result) => Effect.isEffect(result)
50
+ ? result.pipe(Effect.catchCause(onCause))
51
+ : Effect.fail(new PluginError({
52
+ code: "hook_failed",
53
+ message: `hook "${record.hook}" in plugin "${record.plugin}" returned a non-Effect (${typeof result})`,
54
+ plugin: record.plugin,
55
+ hook: record.hook
56
+ }))));
57
+ };
58
+ /**
59
+ * Builds a dispatcher over an already resolved plugin list.
60
+ *
61
+ * @category constructors
62
+ * @since 1.0.0-rc.0
63
+ */
64
+ export const make = (resolved) => {
65
+ const handlers = (hook) => resolved.handlers.get(hook) ?? empty;
66
+ const sequential = ((hook, ...args) => Effect.gen(function* () {
67
+ const mismatch = kindMismatch(resolved, hook, "sequential");
68
+ if (mismatch !== undefined)
69
+ return yield* Effect.fail(mismatch);
70
+ const results = [];
71
+ for (const record of handlers(hook)) {
72
+ results.push(yield* runHandler(record, args));
73
+ }
74
+ return results;
75
+ }));
76
+ const parallel = ((hook, ...args) => {
77
+ const mismatch = kindMismatch(resolved, hook, "parallel");
78
+ if (mismatch !== undefined)
79
+ return Effect.succeed([mismatch]);
80
+ return Effect.forEach(handlers(hook), (record) => runHandler(record, args).pipe(Effect.match({ onFailure: (error) => [error], onSuccess: () => [] })), { concurrency: resolved.parallelConcurrency }).pipe(Effect.map((chunks) => chunks.flat()));
81
+ });
82
+ const first = ((hook, ...args) => Effect.gen(function* () {
83
+ const mismatch = kindMismatch(resolved, hook, "first");
84
+ if (mismatch !== undefined)
85
+ return yield* Effect.fail(mismatch);
86
+ for (const record of handlers(hook)) {
87
+ const result = yield* runHandler(record, args);
88
+ if (!Option.isOption(result)) {
89
+ return yield* Effect.fail(new PluginError({
90
+ code: "invalid_hook_result",
91
+ message: `first hook "${record.hook}" in plugin "${record.plugin}" did not return an Option`,
92
+ plugin: record.plugin,
93
+ hook: record.hook
94
+ }));
95
+ }
96
+ if (Option.isSome(result))
97
+ return result;
98
+ }
99
+ return Option.none();
100
+ }));
101
+ const waterfall = ((hook, initial, merge) => Effect.gen(function* () {
102
+ const mismatch = kindMismatch(resolved, hook, "waterfall");
103
+ if (mismatch !== undefined)
104
+ return yield* Effect.fail(mismatch);
105
+ let value = initial;
106
+ for (const record of handlers(hook)) {
107
+ const patch = yield* runHandler(record, [value]);
108
+ if (patch !== undefined) {
109
+ value = yield* Effect.try({
110
+ try: () => merge(value, patch),
111
+ catch: (cause) => cause instanceof PluginError
112
+ ? new PluginError({
113
+ code: cause.code,
114
+ message: cause.message,
115
+ plugin: record.plugin,
116
+ hook: record.hook,
117
+ path: cause.path
118
+ })
119
+ : new PluginError({
120
+ code: "config_invalid",
121
+ message: `waterfall hook "${record.hook}" in plugin "${record.plugin}" returned an invalid patch`,
122
+ plugin: record.plugin,
123
+ hook: record.hook
124
+ })
125
+ });
126
+ }
127
+ }
128
+ return value;
129
+ }));
130
+ return Object.freeze({ resolved, handlers, sequential, parallel, first, waterfall });
131
+ };
132
+ /**
133
+ * A dispatcher with no plugins at all.
134
+ *
135
+ * @category constructors
136
+ * @since 1.0.0-rc.0
137
+ */
138
+ export const makeNoop = () => make(Object.freeze({
139
+ plugins: Object.freeze([]),
140
+ handlers: ImmutableMap.make(),
141
+ kinds: engineHooks,
142
+ parallelConcurrency: defaultParallelConcurrency
143
+ }));
144
+ /**
145
+ * The shared dispatcher, as a service tag.
146
+ *
147
+ * This tag holds one dispatcher over the process-wide augmented `FlowsHooks`.
148
+ * `declare module "@smthrs/plugin"` augmentation is the supported extension
149
+ * mechanism for values placed in the tag. A host typed against a separate hook
150
+ * interface holds its `Service<H>` directly, as `@smthrs/agent` does, and does
151
+ * not use this tag or its layers.
152
+ *
153
+ * @category context
154
+ * @since 1.0.0-rc.0
155
+ */
156
+ export class Plugins extends Context.Service()("flows/plugin/Plugins") {
157
+ }
158
+ /**
159
+ * Layer providing a dispatcher over an already resolved plugin list.
160
+ *
161
+ * This layer targets the shared augmented `FlowsHooks` catalog only. A host
162
+ * with a separate hook interface holds its `Service<H>` directly.
163
+ *
164
+ * @category layers
165
+ * @since 1.0.0-rc.0
166
+ */
167
+ export const layer = (resolved) => Layer.succeed(Plugins)(make(resolved));
168
+ /**
169
+ * Layer providing a dispatcher with no plugins.
170
+ *
171
+ * This layer targets the shared augmented `FlowsHooks` catalog only. A host
172
+ * with a separate hook interface holds its `Service<H>` directly.
173
+ *
174
+ * @category layers
175
+ * @since 1.0.0-rc.0
176
+ */
177
+ export const layerNoop = Layer.succeed(Plugins)(makeNoop());
178
+ //# sourceMappingURL=Plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Plugins.js","sourceRoot":"","sources":["../../src/Plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAA;AAE7D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,0BAA0B,EAAqC,MAAM,cAAc,CAAA;AAE5F,MAAM,KAAK,GAAiC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAE7D,6EAA6E;AAC7E,4EAA4E;AAC5E,uDAAuD;AACvD,MAAM,YAAY,GAAG,CAAC,QAA2B,EAAE,IAAY,EAAE,IAAc,EAA2B,EAAE;IAC1G,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;QAAE,OAAO,SAAS,CAAA;IAC1D,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAA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,6BAA6B;4BACjG,MAAM,EAAE,MAAM,CAAC,MAAM;4BACrB,IAAI,EAAE,MAAM,CAAC,IAAI;yBAClB,CAAC;iBACP,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC,CAAC,CAA4B,CAAA;IAElC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;AACtF,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,GAA+B,EAAE,CACvD,IAAI,CAAI,MAAM,CAAC,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IAC1B,QAAQ,EAAE,YAAY,CAAC,IAAI,EAAwC;IACnE,KAAK,EAAE,WAAW;IAClB,mBAAmB,EAAE,0BAA0B;CAChD,CAAC,CAAC,CAAA;AAEL;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,OAAQ,SAAQ,OAAO,CAAC,OAAO,EAAoB,CAAC,sBAAsB,CAAC;CAAG;AAE3F;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,QAAkB,EAAwB,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEzG;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAyB,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA","sourcesContent":["/**\n * The dispatcher: a plain service over a resolved plugin list, generic over the\n * hook interface.\n *\n * The public package contract is documented at\n * {@link https://smithers.sh/docs/reference/api/plugin}. Each host holds an instance over its\n * augmented `FlowsHooks` and may dispatch only the runtime catalog it supplied.\n * The shipped cell host owns the three\n * waterfalls declared in `packages/smithers/agent/src/CellPlugin.ts`; there is\n * no engine-wide lifecycle dispatcher.\n *\n * Cancellation is fiber interruption via scope closure; nothing here threads an\n * `AbortSignal`.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as ImmutableMap from \"@smthrs/canonical/ReadonlyMap\"\nimport type * as Cause from \"effect/Cause\"\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport * as Option from \"effect/Option\"\nimport type { ArgsOf, ContextOf, HookKind, KeysOfKind, SuccessOf } from \"./Hooks.ts\"\nimport { engineHooks } from \"./Hooks.ts\"\nimport type { FlowsHooks } from \"./index.ts\"\nimport { PluginError } from \"./PluginError.ts\"\nimport { defaultParallelConcurrency, type HandlerRecord, type Resolved } from \"./Resolve.ts\"\n\nconst empty: ReadonlyArray<HandlerRecord> = Object.freeze([])\n\n// The typed catalog and the runtime catalog can only drift when a host casts\n// around `KeysOfKind`; refuse before any handler runs rather than execute a\n// hook under semantics its declaration never promised.\nconst kindMismatch = (resolved: Resolved<unknown>, hook: string, kind: HookKind): PluginError | undefined => {\n if (!Object.hasOwn(resolved.kinds, hook)) return undefined\n const declared = resolved.kinds[hook]\n if (declared === kind) return undefined\n return new PluginError({\n code: \"hook_kind_mismatch\",\n message: `hook \"${hook}\" is declared ${JSON.stringify(declared)} in the runtime catalog but was dispatched as ${\n JSON.stringify(kind)\n }`,\n hook\n })\n}\n\nconst runHandler = (\n record: HandlerRecord,\n args: ReadonlyArray<unknown>\n): Effect.Effect<unknown, PluginError, any> => {\n const onCause = (cause: Cause.Cause<unknown>) =>\n Effect.fail(\n new PluginError({\n code: \"hook_failed\",\n message: `hook \"${record.hook}\" failed in plugin \"${record.plugin}\"`,\n plugin: record.plugin,\n hook: record.hook,\n cause\n })\n )\n\n return Effect.sync(() => record.handler(...args)).pipe(\n Effect.catchCause(onCause),\n Effect.flatMap((result) =>\n Effect.isEffect(result)\n ? result.pipe(Effect.catchCause(onCause))\n : Effect.fail(\n new PluginError({\n code: \"hook_failed\",\n message: `hook \"${record.hook}\" in plugin \"${record.plugin}\" returned a non-Effect (${typeof result})`,\n plugin: record.plugin,\n hook: record.hook\n })\n )\n )\n )\n}\n\n/**\n * The dispatch surface.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Service<H = FlowsHooks> {\n /** The resolved list this dispatcher walks. */\n readonly resolved: Resolved<H>\n /** Frozen, ordered handler records for a hook. */\n readonly handlers: (hook: string) => ReadonlyArray<HandlerRecord>\n /** Runs every handler in resolved order, one at a time. */\n readonly sequential: <K extends KeysOfKind<H, \"sequential\">>(\n hook: K,\n ...args: ArgsOf<H[K]>\n ) => Effect.Effect<ReadonlyArray<SuccessOf<H[K]>>, PluginError, ContextOf<H[K]>>\n /**\n * Runs every handler concurrently, ignoring results. Never fails: handler\n * failures are returned so the caller can report them at its own boundary.\n */\n readonly parallel: <K extends KeysOfKind<H, \"parallel\">>(\n hook: K,\n ...args: ArgsOf<H[K]>\n ) => Effect.Effect<ReadonlyArray<PluginError>, never, ContextOf<H[K]>>\n /** Runs handlers in order until one returns `Option.some`. */\n readonly first: <K extends KeysOfKind<H, \"first\">>(\n hook: K,\n ...args: ArgsOf<H[K]>\n ) => Effect.Effect<SuccessOf<H[K]>, PluginError, ContextOf<H[K]>>\n /** Threads a value through every handler, merging each returned patch. */\n readonly waterfall: <K extends KeysOfKind<H, \"waterfall\">>(\n hook: K,\n initial: ArgsOf<H[K]>[0],\n merge: (previous: ArgsOf<H[K]>[0], patch: Exclude<SuccessOf<H[K]>, void>) => ArgsOf<H[K]>[0]\n ) => Effect.Effect<ArgsOf<H[K]>[0], PluginError, ContextOf<H[K]>>\n}\n\n/**\n * Builds a dispatcher over an already resolved plugin list.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const make = <H = FlowsHooks>(resolved: Resolved<H>): Service<H> => {\n const handlers = (hook: string): ReadonlyArray<HandlerRecord> => resolved.handlers.get(hook) ?? empty\n\n const sequential = ((hook: string, ...args: Array<unknown>) =>\n Effect.gen(function*() {\n const mismatch = kindMismatch(resolved, hook, \"sequential\")\n if (mismatch !== undefined) return yield* Effect.fail(mismatch)\n const results: Array<unknown> = []\n for (const record of handlers(hook)) {\n results.push(yield* runHandler(record, args))\n }\n return results\n })) as Service<H>[\"sequential\"]\n\n const parallel = ((hook: string, ...args: Array<unknown>) => {\n const mismatch = kindMismatch(resolved, hook, \"parallel\")\n if (mismatch !== undefined) return Effect.succeed([mismatch])\n return Effect.forEach(\n handlers(hook),\n (record) =>\n runHandler(record, args).pipe(\n Effect.match({ onFailure: (error) => [error], onSuccess: () => [] as Array<PluginError> })\n ),\n { concurrency: resolved.parallelConcurrency }\n ).pipe(Effect.map((chunks) => chunks.flat()))\n }) as Service<H>[\"parallel\"]\n\n const first = ((hook: string, ...args: Array<unknown>) =>\n Effect.gen(function*() {\n const mismatch = kindMismatch(resolved, hook, \"first\")\n if (mismatch !== undefined) return yield* Effect.fail(mismatch)\n for (const record of handlers(hook)) {\n const result = yield* runHandler(record, args)\n if (!Option.isOption(result)) {\n return yield* Effect.fail(\n new PluginError({\n code: \"invalid_hook_result\",\n message: `first hook \"${record.hook}\" in plugin \"${record.plugin}\" did not return an Option`,\n plugin: record.plugin,\n hook: record.hook\n })\n )\n }\n if (Option.isSome(result)) return result\n }\n return Option.none()\n })) as unknown as Service<H>[\"first\"]\n\n const waterfall =\n ((hook: string, initial: unknown, merge: (previous: unknown, patch: unknown) => unknown) =>\n Effect.gen(function*() {\n const mismatch = kindMismatch(resolved, hook, \"waterfall\")\n if (mismatch !== undefined) return yield* Effect.fail(mismatch)\n let value = initial\n for (const record of handlers(hook)) {\n const patch = yield* runHandler(record, [value])\n if (patch !== undefined) {\n value = yield* Effect.try({\n try: () => merge(value, patch),\n catch: (cause) =>\n cause instanceof PluginError\n ? new PluginError({\n code: cause.code,\n message: cause.message,\n plugin: record.plugin,\n hook: record.hook,\n path: cause.path\n })\n : new PluginError({\n code: \"config_invalid\",\n message: `waterfall hook \"${record.hook}\" in plugin \"${record.plugin}\" returned an invalid patch`,\n plugin: record.plugin,\n hook: record.hook\n })\n })\n }\n }\n return value\n })) as Service<H>[\"waterfall\"]\n\n return Object.freeze({ resolved, handlers, sequential, parallel, first, waterfall })\n}\n\n/**\n * A dispatcher with no plugins at all.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const makeNoop = <H = FlowsHooks>(): Service<H> =>\n make<H>(Object.freeze({\n plugins: Object.freeze([]),\n handlers: ImmutableMap.make<string, ReadonlyArray<HandlerRecord>>(),\n kinds: engineHooks,\n parallelConcurrency: defaultParallelConcurrency\n }))\n\n/**\n * The shared dispatcher, as a service tag.\n *\n * This tag holds one dispatcher over the process-wide augmented `FlowsHooks`.\n * `declare module \"@smthrs/plugin\"` augmentation is the supported extension\n * mechanism for values placed in the tag. A host typed against a separate hook\n * interface holds its `Service<H>` directly, as `@smthrs/agent` does, and does\n * not use this tag or its layers.\n *\n * @category context\n * @since 1.0.0-rc.0\n */\nexport class Plugins extends Context.Service<Plugins, Service>()(\"flows/plugin/Plugins\") {}\n\n/**\n * Layer providing a dispatcher over an already resolved plugin list.\n *\n * This layer targets the shared augmented `FlowsHooks` catalog only. A host\n * with a separate hook interface holds its `Service<H>` directly.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layer = (resolved: Resolved): Layer.Layer<Plugins> => Layer.succeed(Plugins)(make(resolved))\n\n/**\n * Layer providing a dispatcher with no plugins.\n *\n * This layer targets the shared augmented `FlowsHooks` catalog only. A host\n * with a separate hook interface holds its `Service<H>` directly.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layerNoop: Layer.Layer<Plugins> = Layer.succeed(Plugins)(makeNoop())\n"]}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Bounded plugin resolution: admit, filter, validate, order, and snapshot.
3
+ *
4
+ * The resulting catalog owns every record it exposes. Dispatch never reads a
5
+ * caller-owned map, plugin record, hook object, config value, or cache identity.
6
+ *
7
+ * @since 1.0.0-rc.0
8
+ */
9
+ import type { Action } from "@smthrs/flow";
10
+ import * as Effect from "effect/Effect";
11
+ import * as Layer from "effect/Layer";
12
+ import type { FlowsConfig } from "./Config.ts";
13
+ import type { HookCatalog, HookKind } from "./Hooks.ts";
14
+ import type { FlowsHooks } from "./index.ts";
15
+ import type { FlowsPlugin, PluginInput } from "./Plugin.ts";
16
+ import { PluginError } from "./PluginError.ts";
17
+ /**
18
+ * Maximum nested preset-array depth accepted at startup.
19
+ *
20
+ * @category limits
21
+ * @since 1.0.0-rc.0
22
+ */
23
+ export declare const maximumPluginDepth = 64;
24
+ /**
25
+ * Maximum plugins accepted by one kernel.
26
+ *
27
+ * @category limits
28
+ * @since 1.0.0-rc.0
29
+ */
30
+ export declare const maximumPlugins = 256;
31
+ /**
32
+ * Maximum aggregate hook handlers accepted by one kernel.
33
+ *
34
+ * @category limits
35
+ * @since 1.0.0-rc.0
36
+ */
37
+ export declare const maximumHandlers = 1024;
38
+ /**
39
+ * Maximum input nodes, including arrays and omitted entries.
40
+ *
41
+ * @category limits
42
+ * @since 1.0.0-rc.0
43
+ */
44
+ export declare const maximumPluginInputNodes = 4096;
45
+ /**
46
+ * Maximum UTF-16 length of one plugin or hook name.
47
+ *
48
+ * @category limits
49
+ * @since 1.0.0-rc.0
50
+ */
51
+ export declare const maximumPluginNameLength = 256;
52
+ /**
53
+ * Default fiber bound for parallel observers.
54
+ *
55
+ * @category limits
56
+ * @since 1.0.0-rc.0
57
+ */
58
+ export declare const defaultParallelConcurrency = 16;
59
+ /**
60
+ * Maximum configurable parallel-observer bound.
61
+ *
62
+ * @category limits
63
+ * @since 1.0.0-rc.0
64
+ */
65
+ export declare const maximumParallelConcurrency = 256;
66
+ /**
67
+ * One resolved handler with immutable attribution.
68
+ *
69
+ * @category models
70
+ * @since 1.0.0-rc.0
71
+ */
72
+ export interface HandlerRecord {
73
+ readonly plugin: string;
74
+ readonly hook: string;
75
+ readonly handler: (...args: Array<any>) => unknown;
76
+ }
77
+ /**
78
+ * The immutable output of plugin resolution.
79
+ *
80
+ * @category models
81
+ * @since 1.0.0-rc.0
82
+ */
83
+ export interface Resolved<H = FlowsHooks> {
84
+ readonly plugins: ReadonlyArray<FlowsPlugin<H>>;
85
+ readonly handlers: ReadonlyMap<string, ReadonlyArray<HandlerRecord>>;
86
+ /** The frozen runtime catalog this resolution admitted. Dispatch refuses a method whose kind differs from it. */
87
+ readonly kinds: Readonly<Record<string, HookKind>>;
88
+ readonly parallelConcurrency: number;
89
+ readonly cacheEnvironment?: Action.CacheEnvironment | undefined;
90
+ }
91
+ /**
92
+ * Options for {@link resolve}.
93
+ *
94
+ * @category models
95
+ * @since 1.0.0-rc.0
96
+ */
97
+ export interface Options<H = FlowsHooks> {
98
+ /** Pre-resolution config tested by `apply` predicates. */
99
+ readonly config?: FlowsConfig | undefined;
100
+ /** Host whose literal `apply` selectors are active. Defaults to `"engine"`. */
101
+ readonly target?: "engine" | "harness" | undefined;
102
+ /**
103
+ * Hook names recognized by this host, each with the kind `H` declares for
104
+ * it. The shared `config` and `configResolved` hooks are fixed to
105
+ * `waterfall` and `parallel`; another kind fails with `hook_kind_mismatch`.
106
+ */
107
+ readonly hooks?: HookCatalog<H> | undefined;
108
+ /** Complete composition identity for sealed activity keys. Requires every selected plugin to have a version. */
109
+ readonly cacheEnvironment?: Action.CacheEnvironment | undefined;
110
+ /** Maximum observers run at once. Defaults to 16 and cannot exceed 256. */
111
+ readonly parallelConcurrency?: number | undefined;
112
+ }
113
+ /**
114
+ * Resolves a plugin preset into an immutable, resource-bounded catalog.
115
+ *
116
+ * @category constructors
117
+ * @since 1.0.0-rc.0
118
+ */
119
+ export declare const resolve: <H = FlowsHooks>(input: PluginInput<NoInfer<H>>, options?: Options<NoInfer<H>>, configOverride?: FlowsConfig) => Effect.Effect<Resolved<H>, PluginError>;
120
+ /**
121
+ * Merges every resolved plugin layer left-to-right and supplies the detached
122
+ * cache environment captured during resolution.
123
+ *
124
+ * @category combinators
125
+ * @since 1.0.0-rc.0
126
+ */
127
+ export declare const layer: <H>(resolved: Resolved<H>) => Layer.Layer<any, PluginError, any>;
128
+ //# sourceMappingURL=Resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Resolve.d.ts","sourceRoot":"","sources":["../../src/Resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAc,MAAM,YAAY,CAAA;AAEnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAI5C,OAAO,KAAK,EAAS,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,WAAW,EAAwB,MAAM,kBAAkB,CAAA;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAA;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,MAAM,CAAA;AAEjC;;;;;GAKG;AACH,eAAO,MAAM,eAAe,OAAQ,CAAA;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,OAAQ,CAAA;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,MAAM,CAAA;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAA;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,MAAM,CAAA;AAE7C;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,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