@8lines/gauntlet-typescript-core 0.1.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 (83) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +326 -0
  3. package/dist/adapter-catalog.d.ts +50 -0
  4. package/dist/adapter-catalog.d.ts.map +1 -0
  5. package/dist/adapter-catalog.js +206 -0
  6. package/dist/adapter-catalog.js.map +1 -0
  7. package/dist/ajv-schema-validator.d.ts +9 -0
  8. package/dist/ajv-schema-validator.d.ts.map +1 -0
  9. package/dist/ajv-schema-validator.js +73 -0
  10. package/dist/ajv-schema-validator.js.map +1 -0
  11. package/dist/capability-endpoints.d.ts +14 -0
  12. package/dist/capability-endpoints.d.ts.map +1 -0
  13. package/dist/capability-endpoints.js +2 -0
  14. package/dist/capability-endpoints.js.map +1 -0
  15. package/dist/capability-registry.d.ts +19 -0
  16. package/dist/capability-registry.d.ts.map +1 -0
  17. package/dist/capability-registry.js +34 -0
  18. package/dist/capability-registry.js.map +1 -0
  19. package/dist/data-source-registry.d.ts +10 -0
  20. package/dist/data-source-registry.d.ts.map +1 -0
  21. package/dist/data-source-registry.js +30 -0
  22. package/dist/data-source-registry.js.map +1 -0
  23. package/dist/data-source.d.ts +7 -0
  24. package/dist/data-source.d.ts.map +1 -0
  25. package/dist/data-source.js +2 -0
  26. package/dist/data-source.js.map +1 -0
  27. package/dist/execution-coordinator.d.ts +44 -0
  28. package/dist/execution-coordinator.d.ts.map +1 -0
  29. package/dist/execution-coordinator.js +93 -0
  30. package/dist/execution-coordinator.js.map +1 -0
  31. package/dist/in-memory-run-store.d.ts +12 -0
  32. package/dist/in-memory-run-store.d.ts.map +1 -0
  33. package/dist/in-memory-run-store.js +122 -0
  34. package/dist/in-memory-run-store.js.map +1 -0
  35. package/dist/index.d.ts +19 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +19 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/json-ownership.d.ts +7 -0
  40. package/dist/json-ownership.d.ts.map +1 -0
  41. package/dist/json-ownership.js +9 -0
  42. package/dist/json-ownership.js.map +1 -0
  43. package/dist/operation-internals.d.ts +5 -0
  44. package/dist/operation-internals.d.ts.map +1 -0
  45. package/dist/operation-internals.js +128 -0
  46. package/dist/operation-internals.js.map +1 -0
  47. package/dist/operation-registry.d.ts +12 -0
  48. package/dist/operation-registry.d.ts.map +1 -0
  49. package/dist/operation-registry.js +62 -0
  50. package/dist/operation-registry.js.map +1 -0
  51. package/dist/operation.d.ts +30 -0
  52. package/dist/operation.d.ts.map +1 -0
  53. package/dist/operation.js +21 -0
  54. package/dist/operation.js.map +1 -0
  55. package/dist/placements.d.ts +4 -0
  56. package/dist/placements.d.ts.map +1 -0
  57. package/dist/placements.js +10 -0
  58. package/dist/placements.js.map +1 -0
  59. package/dist/problems.d.ts +13 -0
  60. package/dist/problems.d.ts.map +1 -0
  61. package/dist/problems.js +81 -0
  62. package/dist/problems.js.map +1 -0
  63. package/dist/run-context.d.ts +17 -0
  64. package/dist/run-context.d.ts.map +1 -0
  65. package/dist/run-context.js +2 -0
  66. package/dist/run-context.js.map +1 -0
  67. package/dist/run-manager.d.ts +57 -0
  68. package/dist/run-manager.d.ts.map +1 -0
  69. package/dist/run-manager.js +1487 -0
  70. package/dist/run-manager.js.map +1 -0
  71. package/dist/run-store.d.ts +15 -0
  72. package/dist/run-store.d.ts.map +1 -0
  73. package/dist/run-store.js +13 -0
  74. package/dist/run-store.js.map +1 -0
  75. package/dist/runtime-validation.d.ts +30 -0
  76. package/dist/runtime-validation.d.ts.map +1 -0
  77. package/dist/runtime-validation.js +160 -0
  78. package/dist/runtime-validation.js.map +1 -0
  79. package/dist/schema-validator.d.ts +5 -0
  80. package/dist/schema-validator.d.ts.map +1 -0
  81. package/dist/schema-validator.js +2 -0
  82. package/dist/schema-validator.js.map +1 -0
  83. package/package.json +35 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,326 @@
1
+ # Gauntlet TypeScript Core
2
+
3
+ Framework-neutral registries and runtime for an application's explicitly
4
+ registered Gauntlet features, operations, data sources, runs, and optional
5
+ capabilities. This package does not expose HTTP routes or a dashboard and does
6
+ not discover arbitrary application handlers, commands, URLs, or database
7
+ queries.
8
+
9
+ Use it only in selected non-production environments. A Node or Next transport
10
+ can expose the resulting `AdapterCatalog` at `/_gauntlet/v1`.
11
+
12
+ ## Install
13
+
14
+ Release consumers install matching exact versions from the public npm registry
15
+ (no registry configuration or token is needed; see
16
+ [installing packages](../../../docs/releases/installing-packages.md)):
17
+
18
+ ```sh
19
+ pnpm add @8lines/gauntlet-protocol@0.1.0 \
20
+ @8lines/gauntlet-typescript-core@0.1.0
21
+ ```
22
+
23
+ Inside this repository, workspace packages use `workspace:*` dependencies and
24
+ run `pnpm install` from the repository root:
25
+
26
+ ```json
27
+ {
28
+ "dependencies": {
29
+ "@8lines/gauntlet-protocol": "workspace:*",
30
+ "@8lines/gauntlet-typescript-core": "workspace:*"
31
+ }
32
+ }
33
+ ```
34
+
35
+ For offline release verification, build and pack both packages:
36
+
37
+ ```sh
38
+ mkdir -p /tmp/gauntlet-packages
39
+ pnpm --filter @8lines/gauntlet-protocol build
40
+ pnpm --filter @8lines/gauntlet-typescript-core build
41
+ pnpm --filter @8lines/gauntlet-protocol pack --pack-destination /tmp/gauntlet-packages
42
+ pnpm --filter @8lines/gauntlet-typescript-core pack --pack-destination /tmp/gauntlet-packages
43
+ ```
44
+
45
+ Reference both tarballs from the consumer's `package.json`:
46
+
47
+ ```json
48
+ {
49
+ "dependencies": {
50
+ "@8lines/gauntlet-protocol": "file:/tmp/gauntlet-packages/8lines-gauntlet-protocol-0.1.0.tgz",
51
+ "@8lines/gauntlet-typescript-core": "file:/tmp/gauntlet-packages/8lines-gauntlet-typescript-core-0.1.0.tgz"
52
+ }
53
+ }
54
+ ```
55
+
56
+ Pin Core's transitive protocol dependency to the same tarball in an offline
57
+ consumer's `pnpm-workspace.yaml`:
58
+
59
+ ```yaml
60
+ overrides:
61
+ '@8lines/gauntlet-protocol': 'file:/tmp/gauntlet-packages/8lines-gauntlet-protocol-0.1.0.tgz'
62
+ ```
63
+
64
+ Then run:
65
+
66
+ ```sh
67
+ pnpm install
68
+ ```
69
+
70
+ Add `@8lines/gauntlet-typescript-node` for a native Node host or
71
+ `@8lines/gauntlet-next-adapter` for an App Router bridge.
72
+
73
+ ## Build a catalog
74
+
75
+ The complete, compile-checked reference is
76
+ [`catalog-example.ts`](../../../examples/typescript-fixture/src/catalog-example.ts).
77
+ It demonstrates the whole application-side composition in one file:
78
+
79
+ 1. `OperationRegistry` owns feature groups and operations created only with
80
+ `defineOperation()`.
81
+ 2. `DataSourceRegistry` owns bounded query/resolve providers used by rich UI
82
+ controls.
83
+ 3. `RunManager` validates requests and persists immutable Run snapshots.
84
+ 4. `CapabilityRegistry` advertises only endpoint SPIs that the application
85
+ actually installs.
86
+ 5. `createAdapterCatalog()` exposes the validated, framework-neutral API that
87
+ an HTTP adapter consumes.
88
+
89
+ The important shape is:
90
+
91
+ ```ts
92
+ const operations = new OperationRegistry();
93
+ operations.registerFeature({ id: "applications", label: "Applications" });
94
+ operations.register(defineOperation({
95
+ id: "applications.change-state",
96
+ label: "Change application state",
97
+ featureId: "applications",
98
+ order: 10,
99
+ tags: ["applications", "workflow"],
100
+ requirements: {
101
+ profiles: ["tc-schema-core@1", "tc-rich-forms@1", "tc-rich-results@1"],
102
+ capabilities: ["tc-run-cancellation@1"],
103
+ },
104
+ inputSchema: {
105
+ $schema: "https://json-schema.org/draft/2020-12/schema",
106
+ type: "object",
107
+ required: ["applicationId", "workflowState", "effectiveAt", "notify"],
108
+ properties: {
109
+ applicationId: { type: "string", minLength: 1 },
110
+ workflowState: { type: "string", enum: ["pending", "approved", "blocked"] },
111
+ effectiveAt: { type: "string", format: "date-time" },
112
+ notify: { type: "boolean", default: false },
113
+ reason: { type: "string", minLength: 3, maxLength: 500 },
114
+ },
115
+ additionalProperties: false,
116
+ },
117
+ uiSchema: {
118
+ profile: "tc-rich-forms@1",
119
+ root: {
120
+ type: "group",
121
+ label: "Workflow change",
122
+ children: [
123
+ {
124
+ type: "columns",
125
+ children: [
126
+ {
127
+ type: "field",
128
+ pointer: "/applicationId",
129
+ widget: "autocomplete",
130
+ dataSourceId: "pending-applications",
131
+ },
132
+ { type: "field", pointer: "/workflowState", widget: "select" },
133
+ ],
134
+ },
135
+ { type: "field", pointer: "/effectiveAt", widget: "date-time" },
136
+ { type: "field", pointer: "/notify", widget: "toggle" },
137
+ {
138
+ type: "field",
139
+ pointer: "/reason",
140
+ widget: "textarea",
141
+ visibleWhen: {
142
+ op: "in",
143
+ pointer: "/workflowState",
144
+ values: ["approved", "blocked"],
145
+ },
146
+ },
147
+ ],
148
+ },
149
+ },
150
+ dataSources: [{
151
+ id: "pending-applications",
152
+ inputPointer: "/applicationId",
153
+ dependencyPointers: ["/workflowState"],
154
+ required: true,
155
+ }],
156
+ presets: [{
157
+ id: "return-to-pending",
158
+ label: "Return to pending",
159
+ input: { workflowState: "pending", notify: false },
160
+ lockedPointers: ["/workflowState"],
161
+ }],
162
+ execution: {
163
+ impact: "write",
164
+ confirmationRequired: true,
165
+ dryRunSupported: false,
166
+ idempotency: "required",
167
+ cancellationSupported: true,
168
+ timeoutSeconds: 120,
169
+ concurrency: "queue",
170
+ },
171
+ output: {
172
+ schema: {
173
+ $schema: "https://json-schema.org/draft/2020-12/schema",
174
+ type: "object",
175
+ },
176
+ presentation: { profile: "tc-rich-results@1", defaultView: "summary" },
177
+ },
178
+ }, async (input, context) => {
179
+ context.report({ phase: "changing-state", current: 0, total: 1 });
180
+ // Call one explicit application service here.
181
+ return { output: input };
182
+ }));
183
+ ```
184
+
185
+ The linked source supplies the complete typed handler and output schema. It
186
+ also registers `pending-applications` with search, cursor limits, ordered
187
+ resolve behavior, and a dependency schema keyed by the JSON Pointer
188
+ `/workflowState`. The dashboard can therefore render and refresh the
189
+ autocomplete without knowing application-specific APIs.
190
+
191
+ Do not make a generic operation that accepts a class, command, route, SQL, or
192
+ URL name. Each operation handler and data source is an explicit allow-listed
193
+ application binding.
194
+
195
+ ## Run storage and idempotency
196
+
197
+ Construct the manager with the same validator used by the catalog:
198
+
199
+ ```ts
200
+ const schemaValidator = new AjvSchemaValidator();
201
+ const runs = new RunManager(operations, sharedRunStore, {
202
+ validateSchema: ({ schema, value }) => schemaValidator.validate(schema, value),
203
+ validateFileReference: () => [], // replace when file input rules are registered
204
+ idempotencySecret,
205
+ });
206
+ ```
207
+
208
+ `idempotencySecret` must contain at least 32 high-entropy bytes. Configure the
209
+ same stable value for every process, worker, pod, and restart that shares a
210
+ store. There is no generated or random fallback: construction fails when the
211
+ secret is missing, has the wrong runtime type, or is shorter than 32 bytes.
212
+ Load it from deployment-owned secret storage, decode it into a `Uint8Array`,
213
+ and discard the source string after construction. Never log the source string,
214
+ decoded bytes, or raw idempotency keys. `RunManager` defensively copies the
215
+ bytes and HMAC-fingerprints raw idempotency keys before calling the store; raw
216
+ keys must never be persisted or logged.
217
+
218
+ `InMemoryRunStore` is suitable only for tests and a genuinely single-process
219
+ development host. Multiple workers or pods require an application-owned
220
+ database/Redis implementation of `RunStore` shared by every replica. Its
221
+ `create(run, idempotencyFingerprint)` operation must atomically reserve both the queued
222
+ Run and the operation-scoped fingerprint, throwing
223
+ `DuplicateIdempotencyKeyError` on a uniqueness race. `get`,
224
+ `findByIdempotencyKey`, and `update` must return/persist complete canonical Run
225
+ snapshots. `update(next, expectedPreviousSequence)` is a required atomic
226
+ compare-and-set: throw `RunStoreConflictError` when the stored sequence differs
227
+ and never mutate the winner. Do not deploy replicas with independent in-memory
228
+ stores.
229
+
230
+ ## Execution policy and coordination
231
+
232
+ `RunManager` enforces each operation's `execution` policy. Missing
233
+ `concurrency` and `"allow"` admit handlers independently. `"forbid"` returns
234
+ the fixed 409 `operation-busy` Problem while another run of that operation is
235
+ queued or running; a concurrent request with the same idempotency key still
236
+ replays its original run. `"queue"` admits runs in FIFO order and starts one
237
+ handler at a time. `timeoutSeconds` starts when the run enters `running`,
238
+ aborts `RunContext.signal`, and persists one `timed_out` terminal snapshot.
239
+
240
+ Cancellation and timeout close the context immediately, so late progress,
241
+ artifacts, actions, logs, warnings, and results are ignored. JavaScript cannot
242
+ forcibly stop arbitrary application code: a handler that ignores its
243
+ `AbortSignal` keeps the queue/forbid execution lease until its Promise actually
244
+ settles. Handlers should observe `context.signal` or call
245
+ `context.throwIfCancelled()` around application-service boundaries.
246
+
247
+ The optional `schedule` hook receives a process-local, revocable, one-shot
248
+ function. It may retain that function only for local deferred execution; it
249
+ must never serialize it, place it on a durable/general-purpose queue, or report
250
+ acceptance and then drop it. Invoke it at least once after acceptance; repeated
251
+ or concurrent calls are safe no-ops. The runtime releases captured input,
252
+ secret guards, and invocation context when the task starts or is revoked by a
253
+ failed/cancelled reservation, even if the scheduler keeps its function object.
254
+ Throw synchronously from `schedule` when ownership cannot be accepted.
255
+
256
+ The default `InMemoryExecutionCoordinator` coordinates only one JavaScript
257
+ process. It is suitable for tests and a single-process development host. A
258
+ multi-worker or multi-pod adapter must inject one shared
259
+ `ExecutionCoordinator` that provides distributed admission/FIFO leases and
260
+ cancellation publication (for example through database locks plus pub/sub):
261
+
262
+ ```ts
263
+ const runs = new RunManager(operations, sharedRunStore, {
264
+ validateSchema: ({ schema, value }) => schemaValidator.validate(schema, value),
265
+ validateFileReference: validateUploadReference,
266
+ idempotencySecret,
267
+ executionCoordinator: sharedExecutionCoordinator,
268
+ });
269
+ ```
270
+
271
+ The coordinator's `commitAdmission()` boundary follows the durable
272
+ `RunStore.create`; admission conflicts wait for that decision before returning
273
+ busy or replaying an idempotent run. Coordinator cancellation must reach the
274
+ lease's `signal` in every replica. This SPI is deliberately separate from
275
+ `RunStore`, so a deployment can use the same database for both without making
276
+ the in-memory default look globally safe. A local timeout closes and
277
+ terminalizes its run without waiting for cancellation publication; coordinator
278
+ publication is best-effort for notifying other replicas and must not be used as
279
+ the local timeout acknowledgement.
280
+
281
+ ## Optional capability SPIs
282
+
283
+ Uploads, SSE, and session launch are advertised only when their typed endpoint
284
+ is registered. A real `RunManager` automatically advertises managed
285
+ `tc-run-cancellation@1`; an optional cancellation endpoint remains a fallback
286
+ for run IDs owned outside that manager:
287
+
288
+ ```ts
289
+ const capabilities = new CapabilityRegistry();
290
+ capabilities.registerCancellation(externalCancellationFallback); // optional
291
+ capabilities.registerEvents(runEventsEndpoint);
292
+ capabilities.registerUploads(uploadEndpoint);
293
+ capabilities.registerSessionLaunch(sessionLaunchEndpoint);
294
+ ```
295
+
296
+ The matching capabilities are `tc-run-cancellation@1`, `tc-run-sse@1`,
297
+ `tc-uploads@1`, and `tc-session-launch@1`. An absent optional SPI stays
298
+ unadvertised and the transport returns the protocol's fixed 501 response.
299
+ Endpoint results are treated as untrusted and validated before crossing the
300
+ adapter boundary.
301
+ `registerProvider()` may advertise a non-core capability requirement, but it
302
+ does not create a custom HTTP executor.
303
+
304
+ ## Expose the catalog
305
+
306
+ Pass the completed catalog to exactly one transport. The native Node example
307
+ preserves the raw request target; the Next bridge requires a trusted ingress
308
+ because Next normalizes the request before the route handler sees it.
309
+
310
+ - [Node adapter integration](../node/README.md)
311
+ - [Next.js App Router integration](../next/README.md)
312
+ - [live conformance catalog](../../../examples/typescript-fixture/src/index.ts)
313
+
314
+ ## Verify
315
+
316
+ From the repository root:
317
+
318
+ ```sh
319
+ pnpm --filter @8lines/gauntlet-typescript-core typecheck
320
+ pnpm --filter @8lines/gauntlet-typescript-core test
321
+ pnpm --filter @8lines/gauntlet-typescript-core build
322
+ pnpm --filter @8lines/gauntlet-typescript-core test:package
323
+ pnpm --filter @8lines/gauntlet-typescript-fixture typecheck
324
+ ```
325
+
326
+ [Documentation index](../../../docs/README.md)
@@ -0,0 +1,50 @@
1
+ import { type AdapterHealth, type AdapterManifest, type ApplicationMetadata, type CoreCapabilityId, type CreateRunRequest, type DataSourcePage, type DataSourceQuery, type DataSourceResolveRequest, type DataSourceResolveResponse, type OperationDefinition, type Problem, type ProfileId, type ProtocolId, type Run, type RunEvent, type SessionLaunchResponse, type UploadResponse } from "@8lines/gauntlet-protocol";
2
+ import { CapabilityRegistry } from "./capability-registry.js";
3
+ import { DataSourceRegistry } from "./data-source-registry.js";
4
+ import { OperationRegistry } from "./operation-registry.js";
5
+ import { RunManager, type RunProjectionExpectation } from "./run-manager.js";
6
+ import type { SchemaValidator } from "./schema-validator.js";
7
+ export type CapabilityDispatch<T> = {
8
+ readonly ok: true;
9
+ readonly value: T;
10
+ } | {
11
+ readonly ok: false;
12
+ readonly problem: Problem;
13
+ };
14
+ export type CapabilityAvailability = {
15
+ readonly supported: true;
16
+ } | {
17
+ readonly supported: false;
18
+ readonly problem: Problem;
19
+ };
20
+ export declare class AdapterCatalogError extends Error {
21
+ readonly problem: Problem;
22
+ constructor(problem: Problem);
23
+ }
24
+ export interface AdapterCatalog {
25
+ health(): AdapterHealth;
26
+ manifest(): AdapterManifest;
27
+ operation(operationId: string): OperationDefinition | undefined;
28
+ createRun(operationId: string, request: CreateRunRequest): ReturnType<RunManager["create"]>;
29
+ run(runId: string): Promise<Run | undefined>;
30
+ runProjectionIsValid?(run: Run, expected?: RunProjectionExpectation): Promise<boolean>;
31
+ queryDataSource(dataSourceId: string, request: DataSourceQuery): Promise<DataSourcePage>;
32
+ resolveDataSource(dataSourceId: string, request: DataSourceResolveRequest): Promise<DataSourceResolveResponse>;
33
+ capabilityAvailability(capability: CoreCapabilityId): CapabilityAvailability;
34
+ cancelRun(runId: ProtocolId): Promise<CapabilityDispatch<Run>>;
35
+ runEvents(runId: ProtocolId, lastEventId?: string): Promise<CapabilityDispatch<AsyncIterable<RunEvent>>>;
36
+ createUpload(file: Blob): Promise<CapabilityDispatch<UploadResponse>>;
37
+ launchSession(runId: ProtocolId, artifactId: ProtocolId): Promise<CapabilityDispatch<SessionLaunchResponse>>;
38
+ }
39
+ export interface AdapterCatalogOptions {
40
+ readonly application: ApplicationMetadata;
41
+ readonly profiles: readonly ProfileId[];
42
+ readonly capabilities: CapabilityRegistry;
43
+ readonly operations: OperationRegistry;
44
+ readonly dataSources: DataSourceRegistry;
45
+ readonly runs: RunManager;
46
+ readonly schemaValidator: SchemaValidator;
47
+ readonly now?: () => string;
48
+ }
49
+ export declare function createAdapterCatalog(options: AdapterCatalogOptions): AdapterCatalog;
50
+ //# sourceMappingURL=adapter-catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-catalog.d.ts","sourceRoot":"","sources":["../src/adapter-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,aAAa,EAElB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAExB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAG9B,KAAK,mBAAmB,EAExB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,GAAG,EACR,KAAK,QAAQ,EACb,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EAEpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAO5D,OAAO,EAAE,UAAU,EAAE,KAAK,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAa7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,E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