@beignet/core 0.0.34 → 0.0.36

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 (120) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +145 -15
  3. package/dist/agent-capabilities/index.d.ts +197 -0
  4. package/dist/agent-capabilities/index.d.ts.map +1 -0
  5. package/dist/agent-capabilities/index.js +282 -0
  6. package/dist/agent-capabilities/index.js.map +1 -0
  7. package/dist/application/index.d.ts +2 -2
  8. package/dist/application/index.d.ts.map +1 -1
  9. package/dist/application/index.js +13 -3
  10. package/dist/application/index.js.map +1 -1
  11. package/dist/client/client.d.ts +2 -0
  12. package/dist/client/client.d.ts.map +1 -1
  13. package/dist/client/client.js +33 -16
  14. package/dist/client/client.js.map +1 -1
  15. package/dist/contracts/contract-builder.d.ts +5 -3
  16. package/dist/contracts/contract-builder.d.ts.map +1 -1
  17. package/dist/contracts/contract-builder.js +3 -12
  18. package/dist/contracts/contract-builder.js.map +1 -1
  19. package/dist/contracts/contract-group.d.ts +2 -2
  20. package/dist/contracts/contract-group.d.ts.map +1 -1
  21. package/dist/contracts/contract-group.js +2 -1
  22. package/dist/contracts/contract-group.js.map +1 -1
  23. package/dist/contracts/metadata.d.ts +3 -0
  24. package/dist/contracts/metadata.d.ts.map +1 -0
  25. package/dist/contracts/metadata.js +14 -0
  26. package/dist/contracts/metadata.js.map +1 -0
  27. package/dist/contracts/types.d.ts +20 -0
  28. package/dist/contracts/types.d.ts.map +1 -1
  29. package/dist/contracts/types.js.map +1 -1
  30. package/dist/events/index.d.ts +4 -4
  31. package/dist/events/index.d.ts.map +1 -1
  32. package/dist/events/index.js +5 -5
  33. package/dist/events/index.js.map +1 -1
  34. package/dist/idempotency/index.d.ts.map +1 -1
  35. package/dist/idempotency/index.js +14 -9
  36. package/dist/idempotency/index.js.map +1 -1
  37. package/dist/jobs/index.d.ts.map +1 -1
  38. package/dist/jobs/index.js +10 -4
  39. package/dist/jobs/index.js.map +1 -1
  40. package/dist/openapi/index.js +15 -8
  41. package/dist/openapi/index.js.map +1 -1
  42. package/dist/ports/auth.d.ts +2 -0
  43. package/dist/ports/auth.d.ts.map +1 -1
  44. package/dist/ports/auth.js +2 -0
  45. package/dist/ports/auth.js.map +1 -1
  46. package/dist/providers/index.d.ts +1 -1
  47. package/dist/providers/index.d.ts.map +1 -1
  48. package/dist/providers/index.js.map +1 -1
  49. package/dist/providers/provider.d.ts +9 -1
  50. package/dist/providers/provider.d.ts.map +1 -1
  51. package/dist/providers/provider.js.map +1 -1
  52. package/dist/schedules/index.d.ts +6 -13
  53. package/dist/schedules/index.d.ts.map +1 -1
  54. package/dist/schedules/index.js +24 -44
  55. package/dist/schedules/index.js.map +1 -1
  56. package/dist/server/index.d.ts +2 -2
  57. package/dist/server/index.d.ts.map +1 -1
  58. package/dist/server/index.js +1 -1
  59. package/dist/server/index.js.map +1 -1
  60. package/dist/server/request-executor.d.ts +72 -0
  61. package/dist/server/request-executor.d.ts.map +1 -0
  62. package/dist/server/request-executor.js +781 -0
  63. package/dist/server/request-executor.js.map +1 -0
  64. package/dist/server/request-preparation.d.ts +39 -0
  65. package/dist/server/request-preparation.d.ts.map +1 -0
  66. package/dist/server/request-preparation.js +248 -0
  67. package/dist/server/request-preparation.js.map +1 -0
  68. package/dist/server/response-finalization.d.ts +34 -0
  69. package/dist/server/response-finalization.d.ts.map +1 -0
  70. package/dist/server/response-finalization.js +279 -0
  71. package/dist/server/response-finalization.js.map +1 -0
  72. package/dist/server/route-definitions.d.ts +139 -0
  73. package/dist/server/route-definitions.d.ts.map +1 -0
  74. package/dist/server/route-definitions.js +94 -0
  75. package/dist/server/route-definitions.js.map +1 -0
  76. package/dist/server/route-matching.d.ts +15 -0
  77. package/dist/server/route-matching.d.ts.map +1 -0
  78. package/dist/server/route-matching.js +46 -0
  79. package/dist/server/route-matching.js.map +1 -0
  80. package/dist/server/server.d.ts +6 -147
  81. package/dist/server/server.d.ts.map +1 -1
  82. package/dist/server/server.js +29 -1350
  83. package/dist/server/server.js.map +1 -1
  84. package/dist/server/use-case-route.d.ts +1 -1
  85. package/dist/tracing/index.d.ts +1 -1
  86. package/dist/tracing/index.d.ts.map +1 -1
  87. package/dist/tracing/index.js.map +1 -1
  88. package/dist/uploads/client.js +4 -7
  89. package/dist/uploads/client.js.map +1 -1
  90. package/dist/uploads/index.d.ts.map +1 -1
  91. package/dist/uploads/index.js +59 -12
  92. package/dist/uploads/index.js.map +1 -1
  93. package/package.json +5 -1
  94. package/skills/app-architecture/SKILL.md +27 -1
  95. package/src/agent-capabilities/index.ts +643 -0
  96. package/src/application/index.ts +19 -5
  97. package/src/client/client.ts +41 -17
  98. package/src/contracts/contract-builder.ts +8 -16
  99. package/src/contracts/contract-group.ts +4 -6
  100. package/src/contracts/metadata.ts +20 -0
  101. package/src/contracts/types.ts +39 -0
  102. package/src/events/index.ts +16 -20
  103. package/src/idempotency/index.ts +17 -9
  104. package/src/jobs/index.ts +8 -3
  105. package/src/openapi/index.ts +24 -12
  106. package/src/ports/auth.ts +2 -0
  107. package/src/providers/index.ts +1 -0
  108. package/src/providers/provider.ts +17 -2
  109. package/src/schedules/index.ts +57 -63
  110. package/src/server/index.ts +4 -2
  111. package/src/server/request-executor.ts +1170 -0
  112. package/src/server/request-preparation.ts +409 -0
  113. package/src/server/response-finalization.ts +385 -0
  114. package/src/server/route-definitions.ts +338 -0
  115. package/src/server/route-matching.ts +64 -0
  116. package/src/server/server.ts +63 -2139
  117. package/src/server/use-case-route.ts +1 -1
  118. package/src/tracing/index.ts +1 -0
  119. package/src/uploads/client.ts +4 -7
  120. package/src/uploads/index.ts +70 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @beignet/core
2
2
 
3
+ ## 0.0.36
4
+
5
+ ### Patch Changes
6
+
7
+ - 5c7f6bb: Harden agent capability execution with lazy Better Auth executors, runtime required-constraint checks, validated lifecycle data, and adapter test utilities.
8
+
9
+ ## 0.0.35
10
+
11
+ ### Patch Changes
12
+
13
+ - 2101386: Authorize agent capabilities against their exact parsed input and keep custom Agent Auth locations outside the Beignet execution bridge.
14
+ - 2290c4a: Add typed, validated agent capability registries and execution, plus a Better Auth Agent Auth bridge with constraint-safe validation, verified principals, grants, and redacted protocol errors.
15
+ - 42921da: Keep agent capability registries type-safe, observe pre-context failures, and preserve application error codes across Agent Auth execution modes.
16
+ - 2a5b224: Preserve idempotency and outbox delivery guarantees on persistence and handler failures, enforce multipart limits from actual bytes, support Date and JSON query serialization, and add bounded MySQL deadlock backoff.
17
+ - 74aad51: Replace the schedule-specific instrumentation sink with shared provider targets, serve bodyless HEAD responses from GET routes, improve missing JSON content-type diagnostics, and expose the auth error HTTP status.
18
+ - db79263: Align route, listener, auth-provider, and webhook-integration APIs before 1.0. Route declarations now use an app-bound `createRoutes<AppContext>()` builder, listeners put their stable name first, Better Auth exports `createBetterAuthProvider(...)`, and vendor webhook verifiers live in `@beignet/webhooks-*` packages outside provider audits.
19
+ - 397f106: Standardize framework-owned operational errors, degrade opaque OpenAPI path parameters safely, and add direct Redis, Pino, and Upstash adapters.
20
+ - 40f4155: Refresh package-shipped agent guidance for app-bound route builders, configured route-builder paths, webhook integrations, and operational error responses.
21
+ - d1c0efd: Make contract and contract-group OpenAPI metadata compose consistently across `meta()` and `openapi()` calls.
22
+ - c403db2: Isolate use-case observers, authenticate operational routes before context creation, honor configured generated-test roots, correct feature-helper linting, preserve optional OpenAPI descriptions, and keep upload resets stable.
23
+ - 4cc5254: Decompose the server runtime into focused internal modules while preserving the existing public API and request behavior.
24
+ - 7d0c795: Expose stable named provider types while keeping private config schemas out of package declarations and preserving validated config and contributed-port inference. Drizzle's Postgres and MySQL config schema constants are now internal; use the exported config interfaces for validated shapes.
25
+
3
26
  ## 0.0.34
4
27
 
5
28
  ### Patch Changes
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  > evaluation, and APIs may change between releases while the framework settles.
8
8
 
9
9
  This package provides Beignet's framework primitives: contracts, server runtime,
10
- typed client, use cases, ports, domain helpers, app errors, config, events,
10
+ typed client, use cases, agent capabilities, ports, domain helpers, app errors, config, events,
11
11
  idempotency, locks, outbox, mail, notifications, payments, search, webhooks,
12
12
  feature flags, error reporting, schedules, uploads, entitlements, pagination
13
13
  helpers, testing helpers, and OpenAPI generation.
@@ -46,6 +46,7 @@ name the framework area they depend on.
46
46
 
47
47
  | Import path | Responsibility |
48
48
  | --- | --- |
49
+ | `@beignet/core/agent-capabilities` | Typed agent capability definitions, registries, validation, and execution |
49
50
  | `@beignet/core/application` | Use case builder and test helpers |
50
51
  | `@beignet/core/client` | Typed HTTP client |
51
52
  | `@beignet/core/client-only` | Static lint marker for modules intended for client-side imports |
@@ -89,6 +90,77 @@ import "@beignet/core/client-only";
89
90
  import "@beignet/core/server-only";
90
91
  ```
91
92
 
93
+ ## Agent capabilities
94
+
95
+ Agent capabilities are validated application entrypoints for authenticated AI
96
+ agent transports. Definitions remain transport-neutral and should delegate
97
+ business behavior to the same use cases called by HTTP routes, jobs, and
98
+ scripts.
99
+
100
+ ```typescript
101
+ import {
102
+ createAgentCapabilities,
103
+ createAgentCapabilityExecutor,
104
+ } from "@beignet/core/agent-capabilities";
105
+ import { z } from "zod";
106
+ import type { AppContext } from "@/app-context";
107
+ import { createIssueUseCase } from "@/features/issues/use-cases";
108
+
109
+ type AgentPrincipal = { agentId: string; userId: string };
110
+
111
+ const { defineAgentCapability, defineAgentCapabilityRegistry } =
112
+ createAgentCapabilities<AppContext, AgentPrincipal>();
113
+
114
+ const createIssue = defineAgentCapability("issues.create", {
115
+ description: "Create an issue in one workspace.",
116
+ input: z.object({ workspaceId: z.string(), title: z.string().min(1) }),
117
+ output: z.object({ id: z.string(), title: z.string() }),
118
+ async handle({ ctx, input }) {
119
+ const { workspaceId: _workspaceId, ...useCaseInput } = input;
120
+ return createIssueUseCase.run({ ctx, input: useCaseInput });
121
+ },
122
+ });
123
+
124
+ const registry = defineAgentCapabilityRegistry([createIssue]);
125
+
126
+ export const executor = createAgentCapabilityExecutor({
127
+ registry,
128
+ async createContext({ principal, input }) {
129
+ const membership = await server.ports.members.findMembership({
130
+ workspaceId: input.workspaceId,
131
+ userId: principal.userId,
132
+ });
133
+ if (!membership) throw new Error("Not a workspace member");
134
+
135
+ return server.createServiceContext({
136
+ asUser: { id: principal.userId, role: membership.role },
137
+ tenantId: input.workspaceId,
138
+ });
139
+ },
140
+ });
141
+ ```
142
+
143
+ Input is validated before `createContext(...)` runs. Output is validated before
144
+ it reaches the transport. Context construction remains app-owned: authenticate
145
+ the transport first, re-read tenant membership from an authoritative port, and
146
+ call `server.createServiceContext(...)` instead of assembling `AppContext` by
147
+ hand. Use `@beignet/agent-auth-better-auth` to expose a registry through Better
148
+ Auth Agent Auth.
149
+
150
+ Registry creation comes from the same app-bound factory as
151
+ `defineAgentCapability`, so definitions with another context or principal type
152
+ are rejected. Executor hooks observe the complete attempt and include a
153
+ `stage`. Completion events contain the capability, context, principal,
154
+ validated input, validated output, and duration. Failure events expose context
155
+ and validated input only when execution reached those stages; raw malformed
156
+ input and unvalidated output are not exposed. Dynamic transport adapters may
157
+ provide `authorize(...)` to inspect the exact parsed input before context
158
+ construction without causing a second validation pass. Pass an independent
159
+ `instrumentation` target and `tracing` port to the executor when lookup,
160
+ input-validation, and context failures must be visible before an app context
161
+ exists. Without those options, successful context construction lets the
162
+ executor derive observability ports from `ctx`.
163
+
92
164
  ## Durable failure language
93
165
 
94
166
  Jobs, outbox delivery, and schedule runners use the same terms:
@@ -229,6 +301,13 @@ import type { providers } from "@/server/providers";
229
301
  export type AppRuntimePorts = AppPorts & InferProviderPorts<typeof providers>;
230
302
  ```
231
303
 
304
+ Reusable provider packages should export a named `ServiceProvider` return type
305
+ and use `AnyProviderConfigSchema<Config>` for its config generic. That keeps a
306
+ private Zod or other Standard Schema implementation out of the package
307
+ declaration while preserving the validated config output and exact
308
+ contributed-port inference. App-local providers should keep their concrete
309
+ schema inference because they do not have a package compatibility boundary.
310
+
232
311
  App-local providers can declare required ports, app context, and
233
312
  service-context input through the curried `createProvider()` form. `setup`
234
313
  then receives typed `ports` and a `createServiceContext` factory that returns
@@ -549,6 +628,15 @@ can compute the digest before `prepare`. Use `verifyFile(...)` for app-owned
549
628
  scanning, moderation, and quarantine decisions that run after the object exists
550
629
  in storage and before `onComplete(...)`.
551
630
 
631
+ `createUploadRouter(...)` bounds JSON request bodies and server-handled
632
+ multipart bodies. Multipart limits are enforced against both a declared
633
+ `Content-Length` and the bytes actually read, so chunked requests cannot bypass
634
+ `limits.multipartMaxBytes` before `formData()` parsing.
635
+
636
+ Upload route failures use Beignet's flat `{ code, message, details? }` error
637
+ body. The typed upload client maps that response to `UploadClientError` with
638
+ the same code, status, and details.
639
+
552
640
  ## Webhooks
553
641
 
554
642
  Use `@beignet/core/webhooks` for provider-neutral inbound webhook definitions,
@@ -584,8 +672,8 @@ export const issueWebhook = defineWebhook("issues.provider", {
584
672
 
585
673
  Use `createMemoryWebhookVerifier(...)` in tests and `createWebhookRoute(...)`
586
674
  from `@beignet/next` to expose raw-body webhook routes in Next.js apps. Use a
587
- provider package such as `@beignet/provider-webhooks-github` or
588
- `@beignet/provider-webhooks-stripe` when a vendor has signature semantics beyond
675
+ provider package such as `@beignet/webhooks-github` or
676
+ `@beignet/webhooks-stripe` when a vendor has signature semantics beyond
589
677
  the generic HMAC verifier. For billing flows backed by `ctx.ports.payments`,
590
678
  use `@beignet/core/payments` with `createPaymentWebhookRoute(...)` from
591
679
  `@beignet/next` instead of a generic webhook catalog.
@@ -780,10 +868,14 @@ may only be registered once, contract names must be unique across the route
780
868
  registry because typed clients, OpenAPI operations, and devtools key on them,
781
869
  and an introspectable `.pathParams(...)` object schema must declare exactly the
782
870
  `:param` keys from the path template. Mismatches fail server startup with the
783
- contract name and path. At dispatch time, a request that matches a registered
871
+ contract name and path. Opaque Standard Schemas skip that registration-time key
872
+ comparison; OpenAPI falls back to required string parameters from the literal
873
+ path template unless a custom schema introspector is supplied. At dispatch
874
+ time, a request that matches a registered
784
875
  path with an unregistered method receives a framework-owned `405
785
876
  METHOD_NOT_ALLOWED` response with an `Allow` header listing the registered
786
- methods; `HEAD` is intentionally not served by `GET` handlers.
877
+ methods. `GET` routes also serve `HEAD` when no explicit `HEAD` route exists;
878
+ explicit `HEAD` routes take precedence, and every `HEAD` response is bodyless.
787
879
 
788
880
  ### Runtime integrity
789
881
 
@@ -844,6 +936,10 @@ the returned handler at the route's own path.
844
936
  Use `.headers(...)` for request headers that are part of the endpoint contract. Declare header keys in lowercase; server and client runtime matching is case-insensitive.
845
937
 
846
938
  Request bodies are supported for `POST`, `PUT`, and `PATCH` contracts only.
939
+ JSON bodies require `Content-Type: application/json`; otherwise the runtime
940
+ passes the body to validation as text. When a missing content type accompanies
941
+ a valid JSON object or array that fails validation, the framework-owned error
942
+ includes a targeted `details.hint` without changing the response code.
847
943
 
848
944
  If you do not pass `name`, Beignet generates one from the HTTP method and full path:
849
945
 
@@ -1519,6 +1615,11 @@ a transaction-scoped `tx.idempotency` port from the app Unit of Work so
1519
1615
  reservation, business writes, audit records, domain-event records, and
1520
1616
  idempotency completion commit together.
1521
1617
 
1618
+ `runIdempotently(...)` releases a reservation only when the protected work
1619
+ throws. If the work succeeds but `complete(...)` fails, the reservation stays
1620
+ in progress and the completion error is rethrown so an immediate retry cannot
1621
+ repeat the successful work.
1622
+
1522
1623
  ### Outbox
1523
1624
 
1524
1625
  Use `@beignet/core/outbox` when events or jobs must be recorded in the same
@@ -1569,6 +1670,11 @@ await drainOutbox({
1569
1670
  The outbox is at-least-once delivery. Use idempotent listeners or jobs when a
1570
1671
  duplicate delivery would be harmful.
1571
1672
 
1673
+ When an inline dispatcher exposes Beignet's single-attempt delivery hook, an
1674
+ `onError` observer is still notified but cannot swallow the failure. The outbox
1675
+ retains retry and dead-letter ownership instead of marking the message
1676
+ delivered.
1677
+
1572
1678
  Use `OutboxAdminPort` only from operational contexts. It lets `beignet outbox`
1573
1679
  list, show, requeue, purge dead-lettered rows, and prune delivered rows without
1574
1680
  exposing those destructive operations to transaction-scoped use cases.
@@ -1585,7 +1691,7 @@ import { createInlineScheduleRunner } from "@beignet/core/schedules";
1585
1691
 
1586
1692
  const runner = createInlineScheduleRunner<AppContext>({
1587
1693
  ctx,
1588
- instrumentation: ctx.ports.devtools,
1694
+ instrumentation: ctx.ports,
1589
1695
  instrumentationContext: {
1590
1696
  requestId: ctx.requestId,
1591
1697
  traceId: ctx.traceId,
@@ -1596,9 +1702,10 @@ await runner.run(SendDailyDigestSchedule, { source: "vercel-cron" });
1596
1702
  ```
1597
1703
 
1598
1704
  `instrumentationContext` attaches request correlation fields to recorded
1599
- events. Recording failures are isolated from schedule execution and reported
1600
- to `onHookError` when provided. Handler failures still reject `runner.run(...)`
1601
- after `onError` runs so trigger hosts can retry.
1705
+ events. The shared provider instrumentation helper applies watcher checks,
1706
+ redaction, and sink-failure isolation. Lifecycle hook failures still reach
1707
+ `onHookError` when provided. Handler failures reject `runner.run(...)` after
1708
+ `onError` runs so trigger hosts can retry.
1602
1709
 
1603
1710
  ### Contract metadata and route hooks
1604
1711
 
@@ -1631,8 +1738,13 @@ install `createRateLimitHooks(...)` and `createIdempotencyHooks(...)` where the
1631
1738
  server is composed. Use route hooks for runtime enforcement of route-specific
1632
1739
  policy where the route is wired:
1633
1740
 
1741
+ Bind route declarations to the app context once in `lib/routes.ts` with
1742
+ `createRoutes<AppContext>()`, then import the resulting builders in feature
1743
+ route files.
1744
+
1634
1745
  ```ts
1635
- import { createAuthHooks, defineRouteGroup } from "@beignet/core/server";
1746
+ import { createAuthHooks } from "@beignet/core/server";
1747
+ import { defineRouteGroup } from "@/lib/routes";
1636
1748
  import type { AppContext } from "@/app-context";
1637
1749
 
1638
1750
  const auth = createAuthHooks<AppContext>()({
@@ -1641,7 +1753,7 @@ const auth = createAuthHooks<AppContext>()({
1641
1753
  },
1642
1754
  });
1643
1755
 
1644
- export const messageRoutes = defineRouteGroup<AppContext>()({
1756
+ export const messageRoutes = defineRouteGroup({
1645
1757
  name: "messages",
1646
1758
  routes: [
1647
1759
  {
@@ -1663,7 +1775,7 @@ contract's sole request schema by reference, the server skips the use case's
1663
1775
  input re-parse — one schema, one parse.
1664
1776
 
1665
1777
  Use `{ contract, handle }` as the escape hatch for response headers,
1666
- streaming, and multi-status responses. `defineRoute<AppContext>()` remains
1778
+ streaming, and multi-status responses. `defineRoute` remains
1667
1779
  available for full handlers that read hook-added `ctx` fields.
1668
1780
 
1669
1781
  When credentials live in request headers, declare a `headers` schema on the
@@ -1857,6 +1969,10 @@ port is installed, it also creates an active child span. Pass
1857
1969
  `instrumentation: false` to opt out of instrumentation events; tracing is
1858
1970
  controlled by whether the app installs `ports.tracing`.
1859
1971
 
1972
+ App-owned `onRun` observers are best-effort. Synchronous throws and rejected
1973
+ observer promises are ignored so instrumentation cannot fail a use case or
1974
+ replace its original error.
1975
+
1860
1976
  `createInstrumentedAuditLog({ audit, instrumentation })` from
1861
1977
  `@beignet/core/ports` writes durable audit entries first and mirrors sanitized
1862
1978
  audit activity into the resolved instrumentation sink.
@@ -1918,12 +2034,23 @@ export const getTodo = todos
1918
2034
  });
1919
2035
  ```
1920
2036
 
2037
+ `.openapi(...)` and `.meta({ openapi: ... })` share the same shallow merge
2038
+ semantics. OpenAPI fields from contract groups and earlier calls are preserved,
2039
+ while a later value replaces the same field. Structured fields such as
2040
+ `responses` are replaced as a whole rather than deep-merged. Prefer
2041
+ `.openapi(...)` for operation metadata; use `.meta(...)` when composing it with
2042
+ other metadata conventions.
2043
+
1921
2044
  Use `requestBody`, `responses`, and `parameters` overrides when an operation
1922
2045
  needs non-JSON media such as multipart uploads, binary downloads, event streams,
1923
2046
  or cookie parameters. `contractsToOpenAPI(...)` accepts `schemaConverters` for
1924
2047
  non-Zod Standard Schema libraries; custom converters run before Beignet's
1925
2048
  default Zod converter.
1926
2049
 
2050
+ Descriptions attached before `.optional()` are preserved on generated query
2051
+ and header parameters, matching descriptions attached to the outer optional
2052
+ schema.
2053
+
1927
2054
  ### Schema introspection
1928
2055
 
1929
2056
  Contracts expose their schemas for runtime introspection:
@@ -1980,8 +2107,8 @@ standard error envelope.
1980
2107
  | `.body(schema)` | Define request body schema |
1981
2108
  | `.responses({ ... })` | Define or merge response schemas by status code |
1982
2109
  | `.errors({ ... })` | Declare route-owned catalog errors using Beignet's standard error envelope; merges with group and earlier declarations |
1983
- | `.meta(metadata)` | Add custom metadata |
1984
- | `.openapi(options)` | Add OpenAPI metadata (summary, tags, etc.) |
2110
+ | `.meta(metadata)` | Merge custom metadata; nested `openapi` fields merge one level deep |
2111
+ | `.openapi(options)` | Merge OpenAPI metadata (summary, tags, etc.) |
1985
2112
 
1986
2113
  ## Standard Schema support
1987
2114
 
@@ -1991,7 +2118,10 @@ This package works with any [Standard Schema](https://github.com/standard-schema
1991
2118
  - **Valibot** - Lightweight alternative to Zod
1992
2119
  - **ArkType** - High-performance runtime validation
1993
2120
 
1994
- OpenAPI generation currently requires Zod schemas, even though core contracts can use any Standard Schema-compatible library.
2121
+ OpenAPI generation includes a Zod converter and introspector by default. Other
2122
+ Standard Schema libraries can supply `schemaConverters` and a
2123
+ `schemaIntrospector`; opaque path parameter schemas degrade to required string
2124
+ parameters derived from the contract path.
1995
2125
 
1996
2126
  ## Related packages
1997
2127
 
@@ -0,0 +1,197 @@
1
+ import type { StandardSchemaV1 } from "@standard-schema/spec";
2
+ import { type ProviderInstrumentationTarget } from "../providers/index.js";
3
+ import type { TracingPort } from "../tracing/index.js";
4
+ /** Any Standard Schema compatible validator. */
5
+ export type AgentCapabilitySchema = StandardSchemaV1<unknown, unknown>;
6
+ /** Value or promise of that value. */
7
+ export type MaybePromise<T> = T | Promise<T>;
8
+ /** Infer the input accepted by a capability schema. */
9
+ export type InferAgentCapabilitySchemaInput<Schema extends StandardSchemaV1> = StandardSchemaV1.InferInput<Schema>;
10
+ /** Infer the parsed output produced by a capability schema. */
11
+ export type InferAgentCapabilitySchemaOutput<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema>;
12
+ /** A typed action that an authenticated agent transport may expose. */
13
+ export interface AgentCapabilityDef<Name extends string = string, Input extends AgentCapabilitySchema = AgentCapabilitySchema, Output extends AgentCapabilitySchema = AgentCapabilitySchema, Ctx = unknown, Principal = unknown> {
14
+ readonly kind: "agentCapability";
15
+ readonly name: Name;
16
+ readonly description: string;
17
+ readonly input: Input;
18
+ readonly output: Output;
19
+ readonly handle: (args: {
20
+ capability: AgentCapabilityDef<Name, Input, Output, Ctx, Principal>;
21
+ ctx: Ctx;
22
+ principal: Principal;
23
+ input: InferAgentCapabilitySchemaOutput<Input>;
24
+ }) => MaybePromise<InferAgentCapabilitySchemaInput<Output>>;
25
+ }
26
+ /** Broad capability definition shape tied to one context and principal. */
27
+ export interface AgentCapabilityFor<Ctx, Principal> {
28
+ readonly kind: "agentCapability";
29
+ readonly name: string;
30
+ readonly description: string;
31
+ readonly input: AgentCapabilitySchema;
32
+ readonly output: AgentCapabilitySchema;
33
+ readonly handle: (args: {
34
+ capability: never;
35
+ ctx: Ctx;
36
+ principal: Principal;
37
+ input: never;
38
+ }) => MaybePromise<unknown>;
39
+ }
40
+ /** Broad capability definition shape used by registries and adapters. */
41
+ export type AnyAgentCapabilityDef = AgentCapabilityFor<never, never>;
42
+ /** Infer a capability's application context. */
43
+ export type AgentCapabilityContext<Capability extends AnyAgentCapabilityDef> = Capability extends {
44
+ handle(args: {
45
+ ctx: infer Ctx;
46
+ }): unknown;
47
+ } ? Ctx : never;
48
+ /** Infer a capability's verified principal. */
49
+ export type AgentCapabilityPrincipal<Capability extends AnyAgentCapabilityDef> = Capability extends {
50
+ handle(args: {
51
+ principal: infer Principal;
52
+ }): unknown;
53
+ } ? Principal : never;
54
+ /** Infer a capability's raw input. */
55
+ export type AgentCapabilityInput<Capability extends AnyAgentCapabilityDef> = InferAgentCapabilitySchemaInput<Capability["input"]>;
56
+ /** Infer the parsed input passed to capability context and execution. */
57
+ export type AgentCapabilityParsedInput<Capability extends AnyAgentCapabilityDef> = InferAgentCapabilitySchemaOutput<Capability["input"]>;
58
+ /** Infer a capability's validated output. */
59
+ export type AgentCapabilityOutput<Capability extends AnyAgentCapabilityDef> = InferAgentCapabilitySchemaOutput<Capability["output"]>;
60
+ /** Options accepted by `defineAgentCapability(...)`. */
61
+ export interface DefineAgentCapabilityOptions<Name extends string, Input extends AgentCapabilitySchema, Output extends AgentCapabilitySchema, Ctx, Principal> {
62
+ description: string;
63
+ input: Input;
64
+ output: Output;
65
+ handle(args: {
66
+ capability: AgentCapabilityDef<Name, Input, Output, Ctx, Principal>;
67
+ ctx: Ctx;
68
+ principal: Principal;
69
+ input: InferAgentCapabilitySchemaOutput<Input>;
70
+ }): MaybePromise<InferAgentCapabilitySchemaInput<Output>>;
71
+ }
72
+ /** Context-bound capability definition helpers. */
73
+ export interface AgentCapabilities<Ctx, Principal> {
74
+ defineAgentCapability<const Name extends string, Input extends AgentCapabilitySchema, Output extends AgentCapabilitySchema>(name: Name, options: DefineAgentCapabilityOptions<Name, Input, Output, Ctx, Principal>): AgentCapabilityDef<Name, Input, Output, Ctx, Principal>;
75
+ defineAgentCapabilityRegistry<const Definitions extends readonly AgentCapabilityFor<Ctx, Principal>[]>(definitions: Definitions): AgentCapabilityRegistry<Definitions>;
76
+ }
77
+ /** Bind application context and principal types once for capability definitions. */
78
+ export declare function createAgentCapabilities<Ctx, Principal>(): AgentCapabilities<Ctx, Principal>;
79
+ /** Error thrown when a capability registry is ambiguous. */
80
+ export declare class AgentCapabilityRegistryError extends Error {
81
+ constructor(message: string);
82
+ }
83
+ /** Registered capability definitions available to execution adapters. */
84
+ export interface AgentCapabilityRegistry<Definitions extends readonly AnyAgentCapabilityDef[] = readonly AnyAgentCapabilityDef[]> {
85
+ readonly definitions: Definitions;
86
+ get(name: string): Definitions[number] | undefined;
87
+ }
88
+ /** Stable capability execution failure categories. */
89
+ export type AgentCapabilityErrorCode = "unknown_capability" | "invalid_input" | "invalid_output" | "execution_failed";
90
+ /** Error raised by capability lookup, validation, or execution. */
91
+ export declare class AgentCapabilityError extends Error {
92
+ readonly code: AgentCapabilityErrorCode;
93
+ readonly capabilityName: string;
94
+ readonly issues?: readonly StandardSchemaV1.Issue[];
95
+ readonly cause?: unknown;
96
+ constructor(args: {
97
+ code: AgentCapabilityErrorCode;
98
+ capabilityName: string;
99
+ message: string;
100
+ issues?: readonly StandardSchemaV1.Issue[];
101
+ cause?: unknown;
102
+ });
103
+ }
104
+ /** A parsed invocation passed to the app-owned context resolver. */
105
+ export type AgentCapabilityContextRequest<Definitions extends readonly AnyAgentCapabilityDef[], Principal> = {
106
+ [Capability in Definitions[number] as Capability["name"]]: {
107
+ capability: Capability;
108
+ name: Capability["name"];
109
+ principal: Principal;
110
+ input: InferAgentCapabilitySchemaOutput<Capability["input"]>;
111
+ };
112
+ }[Definitions[number]["name"]];
113
+ /** Stage reached by an agent capability attempt. */
114
+ export type AgentCapabilityRunStage = "lookup" | "input" | "authorization" | "context" | "handler" | "output";
115
+ /** Successful capability lifecycle event with validated application data. */
116
+ export type AgentCapabilityCompletedRunEvent<Ctx, Principal, Definitions extends readonly AnyAgentCapabilityDef[] = readonly AnyAgentCapabilityDef[], Capability extends Definitions[number] = Definitions[number]> = Capability extends Definitions[number] ? {
117
+ name: Capability["name"];
118
+ phase: "end";
119
+ stage: "output";
120
+ capability: Capability;
121
+ ctx: Ctx;
122
+ principal: Principal;
123
+ input: AgentCapabilityParsedInput<Capability>;
124
+ output: AgentCapabilityOutput<Capability>;
125
+ durationMs: number;
126
+ error?: undefined;
127
+ } : never;
128
+ /** Lifecycle event observed around a capability attempt. */
129
+ export type AgentCapabilityRunEvent<Ctx, Principal, Definitions extends readonly AnyAgentCapabilityDef[] = readonly AnyAgentCapabilityDef[]> = {
130
+ name: string;
131
+ phase: "start";
132
+ stage: "lookup";
133
+ capability?: Definitions[number];
134
+ ctx?: undefined;
135
+ principal: Principal;
136
+ input?: undefined;
137
+ output?: undefined;
138
+ durationMs?: undefined;
139
+ error?: undefined;
140
+ } | AgentCapabilityCompletedRunEvent<Ctx, Principal, Definitions> | {
141
+ name: string;
142
+ phase: "error";
143
+ stage: AgentCapabilityRunStage;
144
+ capability?: Definitions[number];
145
+ ctx?: Ctx;
146
+ principal: Principal;
147
+ /** Present only when input validation completed successfully. */
148
+ input?: unknown;
149
+ output?: undefined;
150
+ durationMs: number;
151
+ error: unknown;
152
+ };
153
+ /** Best-effort lifecycle observer for capability execution. */
154
+ export type AgentCapabilityHook<Ctx, Principal, Definitions extends readonly AnyAgentCapabilityDef[] = readonly AnyAgentCapabilityDef[]> = (event: AgentCapabilityRunEvent<Ctx, Principal, Definitions>) => MaybePromise<void>;
155
+ /** Options for a capability executor. */
156
+ export interface CreateAgentCapabilityExecutorOptions<Ctx, Principal, Definitions extends readonly AnyAgentCapabilityDef[]> {
157
+ registry: AgentCapabilityRegistry<Definitions>;
158
+ createContext(request: AgentCapabilityContextRequest<Definitions, Principal>): MaybePromise<Ctx>;
159
+ hooks?: readonly AgentCapabilityHook<Ctx, Principal, Definitions>[];
160
+ /** Independent target used to observe failures before context exists. */
161
+ instrumentation?: ProviderInstrumentationTarget;
162
+ tracing?: TracingPort;
163
+ }
164
+ /** Raw dynamic invocation accepted by protocol adapters. */
165
+ export interface DynamicAgentCapabilityInvocation<Principal> {
166
+ name: string;
167
+ principal: Principal;
168
+ input: unknown;
169
+ /**
170
+ * Transport-owned authorization against the exact parsed input that will be
171
+ * passed to context construction and the capability handler.
172
+ */
173
+ authorize?(request: DynamicAgentCapabilityAuthorization<Principal>): MaybePromise<void>;
174
+ }
175
+ /** Parsed invocation exposed to a dynamic transport authorization callback. */
176
+ export interface DynamicAgentCapabilityAuthorization<Principal> {
177
+ capability: AnyAgentCapabilityDef;
178
+ name: string;
179
+ principal: Principal;
180
+ input: unknown;
181
+ }
182
+ /** Typed and dynamic execution surface for one capability registry. */
183
+ export interface AgentCapabilityExecutor<Principal, Definitions extends readonly AnyAgentCapabilityDef[]> {
184
+ execute<Name extends Definitions[number]["name"]>(args: {
185
+ name: Name;
186
+ principal: Principal;
187
+ input: AgentCapabilityInput<Extract<Definitions[number], {
188
+ name: Name;
189
+ }>>;
190
+ }): Promise<AgentCapabilityOutput<Extract<Definitions[number], {
191
+ name: Name;
192
+ }>>>;
193
+ executeDynamic(args: DynamicAgentCapabilityInvocation<Principal>): Promise<unknown>;
194
+ }
195
+ /** Create a validated, traced executor for a capability registry. */
196
+ export declare function createAgentCapabilityExecutor<const Definitions extends readonly AnyAgentCapabilityDef[]>(options: CreateAgentCapabilityExecutorOptions<AgentCapabilityContext<Definitions[number]>, AgentCapabilityPrincipal<Definitions[number]>, Definitions>): AgentCapabilityExecutor<AgentCapabilityPrincipal<Definitions[number]>, Definitions>;
197
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent-capabilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,gDAAgD;AAChD,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAEvE,sCAAsC;AACtC,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7C,uDAAuD;AACvD,MAAM,MAAM,+BAA+B,CAAC,MAAM,SAAS,gBAAgB,IACzE,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAEtC,+DAA+D;AAC/D,MAAM,MAAM,gCAAgC,CAAC,MAAM,SAAS,gBAAgB,IAC1E,gBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAEvC,uEAAuE;AACvE,MAAM,WAAW,kBAAkB,CACjC,IAAI,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