apps 0.0.1-beta.7 → 0.0.1-beta.73

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 (178) hide show
  1. package/README.md +25 -22
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-RJDDBDSN.js → chunk-3CVQ3VPP.js} +762 -171
  4. package/js/chunk-3R3KFCDU.js +426 -0
  5. package/js/chunk-5FHWNLCI.js +88 -0
  6. package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
  7. package/js/chunk-7LMU3ER3.js +274 -0
  8. package/js/chunk-CDXQDN7W.js +92 -0
  9. package/js/{chunk-RFVIONFX.js → chunk-ECCWT5GJ.js} +79 -41
  10. package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
  11. package/js/{chunk-CMYUWAX7.js → chunk-G7L5DHQX.js} +126 -31
  12. package/js/{chunk-27F7W2LG.js → chunk-H2CJWXA3.js} +2 -2
  13. package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
  14. package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
  15. package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
  16. package/js/{chunk-WLE7WX2U.js → chunk-JW5LYSER.js} +2262 -474
  17. package/js/{chunk-5T57N25Q.js → chunk-KGCTYL2S.js} +511 -63
  18. package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
  19. package/js/chunk-LTF4TLMO.js +347 -0
  20. package/js/chunk-MHB7IFG7.js +49 -0
  21. package/js/{chunk-FL2QR3XW.js → chunk-OBYMFSWA.js} +333 -69
  22. package/js/chunk-OD3KFKZD.js +1617 -0
  23. package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
  24. package/js/{chunk-72JNVHPK.js → chunk-QGHGYH5V.js} +4 -3
  25. package/js/{chunk-NKLWZJLE.js → chunk-RUP4JMKO.js} +25 -14
  26. package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
  27. package/js/{chunk-UESPOTUI.js → chunk-WCVV4PPS.js} +899 -190
  28. package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
  29. package/js/{chunk-Z5M2LQOZ.js → chunk-ZEJ3IKEC.js} +67 -55
  30. package/js/chunk-ZR7QAG67.js +171 -0
  31. package/js/client.js +142 -94
  32. package/js/contracts.js +125 -26
  33. package/js/effect.js +19 -19
  34. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  35. package/js/graphql.js +50 -40
  36. package/js/host.js +83 -58
  37. package/js/index.js +131 -46
  38. package/js/mcp/effect.js +23 -21
  39. package/js/mcp/stdio.js +44 -34
  40. package/js/mcp.js +76 -53
  41. package/js/openapi.js +4071 -1357
  42. package/js/react.js +2 -3
  43. package/js/skills/effect.js +6 -3
  44. package/js/skills.js +208 -81
  45. package/js/storage/facet.js +1 -540
  46. package/js/ui/auth/contracts.js +2 -2
  47. package/js/ui/auth.js +5 -5
  48. package/js/ui/contracts.js +5 -4
  49. package/js/ui/serving.js +8517 -214
  50. package/package.json +3 -4
  51. package/runtime.json +1 -1
  52. package/types/app-cache/src/contracts/cache.d.ts +2 -0
  53. package/types/app-cache/src/index.d.ts +10 -1
  54. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  55. package/types/apps/src/contracts/app.d.ts +7 -3
  56. package/types/apps/src/contracts/cache.d.ts +20 -0
  57. package/types/apps/src/contracts/context.d.ts +19 -11
  58. package/types/apps/src/contracts/elicitation.d.ts +6 -6
  59. package/types/apps/src/contracts/events.d.ts +93 -0
  60. package/types/apps/src/contracts/failure.d.ts +30 -1
  61. package/types/apps/src/contracts/graphql.d.ts +2 -1
  62. package/types/apps/src/contracts/host.d.ts +641 -16
  63. package/types/apps/src/contracts/live.d.ts +2 -0
  64. package/types/apps/src/contracts/mcp.d.ts +80 -10
  65. package/types/apps/src/contracts/network.d.ts +120 -0
  66. package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
  67. package/types/apps/src/contracts/openapi.d.ts +41 -9
  68. package/types/apps/src/contracts/operations.d.ts +8 -4
  69. package/types/apps/src/contracts/placement.d.ts +102 -0
  70. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  71. package/types/apps/src/contracts/protocols/1.d.ts +733 -81
  72. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  73. package/types/apps/src/contracts/protocols/2.d.ts +69 -26
  74. package/types/apps/src/contracts/protocols/3.d.ts +133 -33
  75. package/types/apps/src/contracts/protocols/4.d.ts +122 -45
  76. package/types/apps/src/contracts/protocols/5.d.ts +157 -47
  77. package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
  78. package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
  79. package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
  80. package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
  81. package/types/apps/src/contracts/protocols/current.d.ts +3842 -0
  82. package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
  83. package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
  84. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  85. package/types/apps/src/contracts/provider.d.ts +90 -6
  86. package/types/apps/src/contracts/skills.d.ts +50 -13
  87. package/types/apps/src/contracts/sql.d.ts +63 -0
  88. package/types/apps/src/contracts/ui.d.ts +19 -1
  89. package/types/apps/src/contracts/workflows.d.ts +6 -0
  90. package/types/apps/src/facet.d.ts +4 -5
  91. package/types/apps/src/host.d.ts +5 -0
  92. package/types/apps/src/implementation/account-router.d.ts +4 -3
  93. package/types/apps/src/implementation/authoring.d.ts +25 -5
  94. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  95. package/types/apps/src/implementation/cache.d.ts +4 -0
  96. package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
  97. package/types/apps/src/implementation/elicitation.d.ts +18 -15
  98. package/types/apps/src/implementation/events.d.ts +59 -0
  99. package/types/apps/src/implementation/failure-detail.d.ts +25 -3
  100. package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
  101. package/types/apps/src/implementation/graphql.d.ts +4 -3
  102. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  103. package/types/apps/src/implementation/invocation-timing.d.ts +16 -0
  104. package/types/apps/src/implementation/live.d.ts +2 -2
  105. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  106. package/types/apps/src/implementation/mcp-catalog.d.ts +6 -4
  107. package/types/apps/src/implementation/mcp-client.d.ts +17 -9
  108. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  109. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  110. package/types/apps/src/implementation/mcp.d.ts +20 -9
  111. package/types/apps/src/implementation/network.d.ts +16 -0
  112. package/types/apps/src/implementation/openapi-compile.d.ts +26 -6
  113. package/types/apps/src/implementation/openapi-document.d.ts +46 -19
  114. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  115. package/types/apps/src/implementation/openapi-request.d.ts +10 -2
  116. package/types/apps/src/implementation/openapi-source.d.ts +18 -0
  117. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  118. package/types/apps/src/implementation/operations.d.ts +17 -2
  119. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  120. package/types/apps/src/implementation/placement.d.ts +60 -0
  121. package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
  122. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  123. package/types/apps/src/implementation/provider.d.ts +18 -3
  124. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  125. package/types/apps/src/implementation/router-catalog.d.ts +11 -13
  126. package/types/apps/src/implementation/router.d.ts +16 -5
  127. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  128. package/types/apps/src/implementation/schema.d.ts +90 -10
  129. package/types/apps/src/implementation/skills.d.ts +18 -24
  130. package/types/apps/src/implementation/sql.d.ts +71 -0
  131. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  132. package/types/apps/src/implementation/ui-auth.d.ts +1 -1
  133. package/types/apps/src/implementation/ui-client.d.ts +2 -2
  134. package/types/apps/src/implementation/ui-document.d.ts +5 -0
  135. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  136. package/types/apps/src/implementation/ui-serving.d.ts +11 -5
  137. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  138. package/types/apps/src/implementation/upstream-error.d.ts +7 -0
  139. package/types/apps/src/implementation/webhooks.d.ts +1 -1
  140. package/types/apps/src/implementation/workflows.d.ts +1 -1
  141. package/types/apps/src/index.d.ts +55 -13
  142. package/types/apps/src/mcp.d.ts +20 -1
  143. package/types/apps/src/openapi.d.ts +1 -1
  144. package/types/apps/src/react.d.ts +1 -1
  145. package/types/apps/src/skills.d.ts +10 -8
  146. package/types/telemetry/src/app-records.d.ts +42 -0
  147. package/types/telemetry/src/browser-operations.d.ts +7 -4
  148. package/types/telemetry/src/browser.d.ts +8 -3
  149. package/types/telemetry/src/config.d.ts +2 -2
  150. package/types/telemetry/src/index.d.ts +2 -1
  151. package/types/telemetry/src/layer.d.ts +2 -2
  152. package/types/telemetry/src/measurements.d.ts +1 -1
  153. package/types/telemetry/src/ownership.d.ts +56 -0
  154. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  155. package/types/telemetry/src/relay.d.ts +16 -6
  156. package/types/telemetry/src/span-attributes.d.ts +17 -1
  157. package/types/telemetry/src/transport.d.ts +8 -1
  158. package/types/utils/src/api-error.d.ts +55 -0
  159. package/types/utils/src/connection-failure.d.ts +33 -0
  160. package/types/utils/src/recorded-message.d.ts +18 -0
  161. package/types/utils/src/user-facing-error.d.ts +83 -0
  162. package/js/chunk-MKWZPDR6.js +0 -63
  163. package/js/chunk-N7YDVXYJ.js +0 -186
  164. package/js/chunk-OCYUEU47.js +0 -224
  165. package/js/chunk-PJJ24GU7.js +0 -877
  166. package/js/chunk-PZB6T6KU.js +0 -19
  167. package/js/chunk-R3EV5FTO.js +0 -97
  168. package/js/chunk-YXQHV65J.js +0 -242
  169. package/js/chunk-ZQINWV4W.js +0 -630
  170. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  171. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  172. package/types/app-data/src/implementation/promise.d.ts +0 -68
  173. package/types/app-data/src/implementation/range.d.ts +0 -8
  174. package/types/app-data/src/implementation/schema.d.ts +0 -18
  175. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  176. package/types/app-data/src/index.d.ts +0 -4
  177. package/types/apps/src/contracts/storage.d.ts +0 -68
  178. package/types/apps/src/implementation/storage.d.ts +0 -15
@@ -1,4 +1,5 @@
1
1
  export { ProviderError } from "./contracts/provider-error.js";
2
+ export { FetchOptionUnsupported, NetworkRefused } from "./contracts/network.js";
2
3
  export type { AppCache, CacheLoadContext, CacheGetOptions } from "./contracts/cache.js";
3
4
  export { CacheError } from "../../app-cache/src/contracts/cache.js";
4
5
  /**
@@ -8,40 +9,76 @@ export { CacheError } from "../../app-cache/src/contracts/cache.js";
8
9
  import { type Schema as EffectSchema } from "effect";
9
10
  import type { WebhookContext } from "./contracts/context.js";
10
11
  import { type JsonResponse as NativeResponse } from "./contracts/http.js";
11
- import { type OAuth2Config, type OAuth2Method as NativeOAuth2Method, type SecretsMethod as NativeSecretsMethod } from "./contracts/provider.js";
12
+ import { type OAuth2Config as NativeOAuth2Config, type OAuth2Method as NativeOAuth2Method, type ReservedAuthorizationParam, type SecretsMethod as NativeSecretsMethod } from "./contracts/provider.js";
12
13
  import type { Webhook as NativeWebhook } from "./contracts/webhooks.js";
13
14
  import { type PromiseMethods } from "./implementation/authoring.js";
14
- import { type Fields, type Infer, type ObjectSchema, type Schema } from "./implementation/schema.js";
15
+ import { type PlacementInput, type RequestPlacements } from "./implementation/placement.js";
16
+ import type { Placement } from "./contracts/placement.js";
17
+ import type { AppContext as NativeAppContext, QueryContext as NativeQueryContext } from "./contracts/context.js";
18
+ import { query as operationQuery, type OperationOptions } from "./implementation/operations.js";
19
+ import { type Fields, type Infer, type ObjectSchema, type Schema, type SecretFields, type SecretObject } from "./implementation/schema.js";
15
20
  export { type JsonObject, type JsonValue, ValidationError } from "./contracts/schema.js";
16
- export { type Fields, type Infer, type ObjectSchema, type ObjectValue, type Schema, array, boolean, json, jsonSchema, literal, number, object, record, string, } from "./implementation/schema.js";
17
- export { type AccountCheckContext, type AccountCheckResult, type AccountInfo, type AccountOf, type AuthMethod, type AuthMethodData, type AuthMethods, type ManyAccounts, type OAuth2Config, type Provider, } from "./contracts/provider.js";
21
+ export { type Fields, type Infer, type ObjectSchema, type ObjectValue, type Schema, array, boolean, json, jsonSchema, literal, number, object, record, string, plain, raw, type SecretString, } from "./implementation/schema.js";
22
+ export { type AccountCheckContext, type AccountCheckResult, type AccountInfo, type AccountOf, type AuthMethod, type AuthMethodData, type AuthMethods, type ManyAccounts, type Provider, type ReservedAuthorizationParam, } from "./contracts/provider.js";
18
23
  export { defineProvider, type ProviderOptions } from "./implementation/provider.js";
24
+ export { base64, basic, bearer, header, t, type FieldRef, type FieldRefs, type PlacementInput, type PlacementValue, type RequestPlacements, } from "./implementation/placement.js";
25
+ export type { Placement };
26
+ export type { AccountRequest } from "./contracts/provider.js";
19
27
  export { accountRouter } from "./implementation/account-router.js";
20
- export { router, dynamicRouter, type RouterDeclaration, type RouterChild, type RouterOptions, } from "./implementation/router.js";
28
+ export { router, dynamicRouter, withApprovals, type OperationChild, type OperationDeclaration, type RouterDeclaration, type RouterChild, type RouterOptions, } from "./implementation/router.js";
21
29
  export type { RouterIcon } from "./contracts/router.js";
22
30
  export { dynamicSkills } from "./implementation/dynamic-skills.js";
23
31
  export type { HostedTool as OperationDescription } from "./contracts/host.js";
32
+ /** Account fields as app code receives them from a method declared with this schema. */
33
+ type AccountFields<S> = S extends ObjectSchema<infer F> ? SecretFields<F> : SecretObject<Infer<S>>;
24
34
  /** A secrets declaration inferred from an author schema. */
25
- export type SecretsMethod<Shape extends ObjectSchema<Fields>> = NativeSecretsMethod<EffectSchema.Decoder<Infer<Shape>>>;
35
+ export type SecretsMethod<Shape extends ObjectSchema<Fields>> = NativeSecretsMethod<EffectSchema.Decoder<AccountFields<Shape>>>;
26
36
  /** An OAuth declaration inferred from its author-facing response schema. */
27
- export type OAuth2Method<Response extends Schema<unknown, boolean>> = NativeOAuth2Method<EffectSchema.Decoder<Infer<Response>>>;
37
+ export type OAuth2Method<Response extends Schema<unknown, boolean>> = NativeOAuth2Method<EffectSchema.Decoder<AccountFields<Response>>>;
38
+ /** The names of an object schema's fields, which a method's `request` can reference. */
39
+ type FieldNameOf<S> = S extends ObjectSchema<infer F> ? keyof F & string : never;
28
40
  /** Default OAuth fields visible to app code. Host-only grants and clients stay private. */
29
41
  export declare const OAuth2AccessToken: Schema<{
30
42
  readonly access_token: string;
31
43
  }, false>;
32
- /** Declare a secrets method without requiring an Effect schema from the author. */
44
+ /**
45
+ * OAuth options as authors write them. `authorizationParams` naming a host-owned protocol
46
+ * parameter such as `state` or `scope` is a type error as well as a declaration failure.
47
+ */
48
+ export type OAuth2Config = WithoutReservedParams<NativeOAuth2Config>;
49
+ type WithoutReservedParams<Config> = Config extends unknown ? "authorizationParams" extends keyof Config ? Config & {
50
+ readonly authorizationParams?: {
51
+ readonly [Key in ReservedAuthorizationParam]?: never;
52
+ };
53
+ } : Config : never;
54
+ /**
55
+ * Declare a secrets method without requiring an Effect schema from the author. `request` says
56
+ * where its secret fields may be sent, such as `({ token }) => bearer(token)`; it runs once, here.
57
+ */
33
58
  export declare const secrets: <const F extends Fields>(options: {
34
59
  readonly label: string;
35
60
  readonly fields: ObjectSchema<F>;
61
+ readonly request?: RequestPlacements<keyof F & string>;
36
62
  }) => SecretsMethod<ObjectSchema<F>>;
37
- /** Declare OAuth discovery/endpoints and an optional app-visible response projection. */
38
- export declare function oauth2(options: OAuth2Config): OAuth2Method<typeof OAuth2AccessToken>;
63
+ /**
64
+ * Declare OAuth discovery/endpoints and an optional app-visible response projection.
65
+ * `authorizationParams` adds service-defined sign-in parameters; a declared `authorizationUrl`
66
+ * keeps its own query. Neither can set host-owned parameters, and each parameter appears once.
67
+ * `request` says where the projected secret fields may be sent, such as
68
+ * `({ access_token }) => bearer(access_token)`; it runs once, here.
69
+ */
70
+ export declare function oauth2(options: OAuth2Config & {
71
+ readonly request?: RequestPlacements<"access_token">;
72
+ }): OAuth2Method<typeof OAuth2AccessToken>;
39
73
  export declare function oauth2<Response extends Schema<unknown, boolean>>(options: OAuth2Config & {
40
74
  readonly response: Response;
75
+ readonly request?: RequestPlacements<FieldNameOf<Response>>;
41
76
  }): OAuth2Method<Response>;
42
77
  export type { AccountSlots } from "./contracts/app.js";
43
78
  export type { AppRequirements, AppContext, QueryContext, MutationContext, WebhookContext, } from "./contracts/context.js";
44
79
  export { type App, type AppDefinition, defineApp } from "./implementation/app.js";
80
+ export { event, type EventDeclaration, type EventEmitter } from "./implementation/events.js";
81
+ export type { EmitOptions } from "./contracts/events.js";
45
82
  export type { Approval, ApprovalContext, ApprovalDecision } from "./approval.js";
46
83
  type AuthorWebhook<Member, Config, State> = Member extends object ? Omit<PromiseMethods<Member>, "config" | "state"> & {
47
84
  readonly config: Config;
@@ -56,9 +93,14 @@ export type JsonResponse = PromiseMethods<NativeResponse>;
56
93
  export declare const decodeJson: <T>(response: JsonResponse, schema: Schema<T, boolean>) => Promise<T>;
57
94
  export { NotImplemented } from "./contracts/app.js";
58
95
  export { ElicitationFailed, type FormElicitation, type ElicitationResponse, type Elicit, } from "./contracts/elicitation.js";
59
- export { table, defineDatabase, type Table, type DatabaseReader, type Database, type DatabaseDefinition, } from "./implementation/storage.js";
60
- export { id, userId } from "./implementation/schema.js";
61
- export { query, mutation, withApproval, type Operation, type OperationOptions, } from "./implementation/operations.js";
96
+ export type { Sql, SqlCursor, SqlReader, SqlRow, SqlTransaction, SqlValue, } from "./contracts/sql.js";
97
+ /**
98
+ * `query(options, run)` declares a read operation. `query(name, value)` inside a method's
99
+ * `request` places a credential in a query parameter, such as `query("key", key)`.
100
+ */
101
+ export declare function query(name: string, value: PlacementInput): Placement;
102
+ export declare function query<Input, Output, Context extends NativeAppContext = NativeQueryContext>(options: OperationOptions<Input, Output>, run: (context: Context, input: Input) => Promise<Output>): ReturnType<typeof operationQuery<Input, Output, Context>>;
103
+ export { mutation, withApproval, toolAnnotations, type Operation, type OperationOptions, } from "./implementation/operations.js";
62
104
  export type { OperationContext } from "./contracts/operations.js";
63
105
  export { workflow, type Workflow, type WorkflowDeclaration } from "./implementation/workflows.js";
64
106
  export { NonRetryableError, WorkflowFailure, type WorkflowContext, type WorkflowStepContext, type WorkflowStep, type WorkflowStepOptions, type WorkflowDuration, type WorkflowReads, type WorkflowControls, } from "./contracts/workflows.js";
@@ -1,11 +1,30 @@
1
1
  /** HTTP MCP helpers. Requires the optional @modelcontextprotocol/sdk peer. */
2
2
  import type { OperationKinds } from "./implementation/protocol-operations.js";
3
+ import type { McpHealthOptions } from "./contracts/mcp.js";
4
+ import type { AccountCheckContext, AuthMethods } from "./contracts/provider.js";
3
5
  import { type McpCatalogOptions } from "./implementation/mcp-catalog.js";
4
6
  export type { McpCatalogOptions } from "./implementation/mcp-catalog.js";
5
- export { McpError, type McpToolContext, type McpToolsOptions, type McpToolResult, } from "./contracts/mcp.js";
7
+ export { McpCredentialsUnverified, McpError, type McpHealthOptions, type McpToolContext, type McpToolsOptions, type McpToolResult, } from "./contracts/mcp.js";
6
8
  /**
7
9
  * A router over a server's tools for the selected account. Its title, description and
8
10
  * instructions come from the server. Kinds override uncertain upstream read-only hints.
9
11
  */
10
12
  export declare const mcpRouter: (options: McpCatalogOptions, kinds?: OperationKinds) => Promise<import("./index.js").RouterDeclaration<unknown, unknown>>;
13
+ /**
14
+ * A provider `health` check for an MCP server. Pass the check context `health` receives, then the
15
+ * server's `url` and the `headers` that send the account's credentials:
16
+ * `health: (check) => mcpHealth(check, { url, headers: headers(check.account) })`.
17
+ *
18
+ * It connects with those headers, initializes, and reads the first page of tools, then does the
19
+ * same without any headers. No tool runs. The check passes only when the server accepts the account
20
+ * and refuses the attempt without credentials. A refused account throws `ProviderError`, as HTTP
21
+ * helpers do. An unreachable or unusable server throws `McpError`, and a request Executor's network
22
+ * refuses throws `NetworkRefused`. A server that also answers without credentials, or whose answer
23
+ * to that attempt is not a refusal, throws `McpCredentialsUnverified`. Each of these errors means
24
+ * the check could not verify the account, and the account form explains why. Send credentials only
25
+ * in `headers`; the attempt without them uses the same `url`. The check context's `signal` cancels
26
+ * both attempts, and they share one budget that ends early enough before its `deadline` to report a
27
+ * server that did not answer in time. `timeoutMs` can only shorten that budget.
28
+ */
29
+ export declare const mcpHealth: <Auth extends AuthMethods>(check: AccountCheckContext<Auth>, options: McpHealthOptions) => Promise<void>;
11
30
  export type { OperationKinds } from "./implementation/protocol-operations.js";
@@ -9,4 +9,4 @@ export { OpenapiError, isOpenapiTextMedia, openapiBinaryResultSchema, OpenapiErr
9
9
  export declare const openapiRouter: (options: OpenapiToolsOptions, kinds?: OperationKinds) => Promise<import("./index.js").RouterDeclaration<unknown, unknown>>;
10
10
  export type { OperationKinds } from "./implementation/protocol-operations.js";
11
11
  export * from "./contracts/openapi-compile.js";
12
- export { liveOpenapiRouter, type OpenapiSourceOptions } from "./implementation/openapi-source.js";
12
+ export { liveOpenapiRouter, openapiToolNames, type OpenapiSourceOptions, type OpenapiToolNamesOptions, } from "./implementation/openapi-source.js";
@@ -1,4 +1,4 @@
1
- import { AsyncResult, type Atom } from "effect/unstable/reactivity";
1
+ import { AsyncResult, type Atom } from "effect/reactivity";
2
2
  /** Subscribe for the component lifetime. Each mount owns and disposes its registry, including StrictMode remounts. */
3
3
  export declare const useAppQuery: <A, E>(atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>) => {
4
4
  data: A | undefined;
@@ -1,12 +1,13 @@
1
1
  import { type FolderSkillsOptions, type GitHubSkillsOptions, type SkillReaderOptions, type WellKnownSkillsOptions, type SkillFile } from "./contracts/skills.js";
2
- export { SkillLoadFailed, SkillDefinitionInvalid, SkillServiceName, type SkillReaderOptions, type FolderSkillsOptions, type AppSkillSource as Skill, type SkillFile, type GitHubSkillsOptions, type SkillCacheOptions, type WellKnownSkillsOptions, } from "./contracts/skills.js";
2
+ export { SkillLoadFailed, SkillDefinitionInvalid, SkillServiceName, type SkillReaderOptions, type FolderSkillsOptions, type AppSkillSource as Skill, type SkillFile, type GitHubSkillsAccount, type GitHubSkillsOptions, type SkillCacheOptions, type WellKnownSkillsOptions, } from "./contracts/skills.js";
3
3
  /**
4
- * Fetch a public GitHub skill collection from one resolved commit. Pass `cache: ctx.cache` to reuse
5
- * the catalog; without it, mutable refs resolve again on each call.
4
+ * Fetch a GitHub skill collection from one resolved commit. A private repository takes `account`
5
+ * and its `token`. Pass `cache: ctx.cache` to reuse the catalog; without it, mutable refs resolve
6
+ * again on each call.
6
7
  */
7
8
  export declare const githubSkills: (options: GitHubSkillsOptions) => Promise<readonly {
8
- readonly name: string;
9
9
  readonly description: string;
10
+ readonly name: string;
10
11
  readonly files: readonly {
11
12
  readonly path: string;
12
13
  readonly content: string;
@@ -20,8 +21,8 @@ export declare const githubSkills: (options: GitHubSkillsOptions) => Promise<rea
20
21
  }[]>;
21
22
  /** Fetch a published skill index and its text files. Pass `cache: ctx.cache` to reuse the catalog. */
22
23
  export declare const wellKnownSkills: (options: WellKnownSkillsOptions) => Promise<readonly {
23
- readonly name: string;
24
24
  readonly description: string;
25
+ readonly name: string;
25
26
  readonly files: readonly {
26
27
  readonly path: string;
27
28
  readonly content: string;
@@ -35,8 +36,8 @@ export declare const wellKnownSkills: (options: WellKnownSkillsOptions) => Promi
35
36
  }[]>;
36
37
  /** Parse a bundled standard skill directory into an app capability. */
37
38
  export declare const fileSkill: (files: readonly SkillFile[]) => Promise<{
38
- readonly name: string;
39
39
  readonly description: string;
40
+ readonly name: string;
40
41
  readonly files: readonly {
41
42
  readonly path: string;
42
43
  readonly content: string;
@@ -50,8 +51,8 @@ export declare const fileSkill: (files: readonly SkillFile[]) => Promise<{
50
51
  }>;
51
52
  /** Read skill directories from ctx.files. Omitted path selects skills/; missing folders return []. */
52
53
  export declare const folderSkills: (options: FolderSkillsOptions) => Promise<readonly {
53
- readonly name: string;
54
54
  readonly description: string;
55
+ readonly name: string;
55
56
  readonly files: readonly {
56
57
  readonly path: string;
57
58
  readonly content: string;
@@ -65,7 +66,8 @@ export declare const folderSkills: (options: FolderSkillsOptions) => Promise<rea
65
66
  }[]>;
66
67
  /**
67
68
  * Read files for a custom remote skill loader, such as one for GitLab. Reads share one byte
68
- * budget and reject with the same safe SkillLoadFailed errors as githubSkills, naming `service`.
69
+ * budget and reject with the same safe SkillLoadFailed errors as githubSkills, naming `service`,
70
+ * or with `NetworkRefused` when Executor's network refuses a request.
69
71
  */
70
72
  export declare const skillReader: (options: SkillReaderOptions) => {
71
73
  /** Fetch one UTF-8 text file. */
@@ -0,0 +1,42 @@
1
+ /**
2
+ * What the host keeps of the spans and logs an app isolate returns.
3
+ *
4
+ * Those records come from whatever framework the app's build bundles, and the app's own code runs
5
+ * in the same isolate: it can throw any text, name its errors and codes, and rewrite every record
6
+ * before the isolate returns it. So the host does not filter the records it receives. It builds
7
+ * new ones from a closed vocabulary: the framework's span names, attributes whose values are
8
+ * closed sets, counts and status codes, and each exception's kind. Ids, parents and timings are
9
+ * kept. Everything else, including events other than exceptions, links, status and exception
10
+ * messages, stacks and log bodies, is dropped or replaced with a fixed sentence.
11
+ *
12
+ * The vocabulary is the framework's (`packages/apps`, `app-cache`, `app-data`): host request
13
+ * operations, failure sources and reasons, MCP and cache attributes. A name or value outside it is
14
+ * recorded as `unrecognized` or not at all. `bun run check` (`scripts/check-app-telemetry.ts`)
15
+ * fails when the framework names a span or sets an attribute key this vocabulary does not know.
16
+ */
17
+ import type { Schema } from "effect";
18
+ type Json = Schema.Json;
19
+ type JsonObject = {
20
+ readonly [key: string]: Json;
21
+ };
22
+ /** What an exception message, stack or log body from an app isolate records instead. */
23
+ export declare const appText = "Text from the app is not recorded";
24
+ /** The framework's span names, and the libraries' spans it runs. */
25
+ export declare const appSpanNames: ReadonlySet<string>;
26
+ export declare const appSpanAttributeKeys: ReadonlySet<string>;
27
+ /**
28
+ * Attributes the framework sets whose values the app chooses, such as its tool names, so the host
29
+ * drops them. `scripts/check-app-telemetry.ts` fails on a framework attribute in neither set.
30
+ */
31
+ export declare const droppedAppAttributeKeys: ReadonlySet<string>;
32
+ /** The span the host records for one an app isolate returned, or nothing without its timings. */
33
+ export declare const appSpan: (span: JsonObject & {
34
+ readonly traceId: string;
35
+ readonly spanId: string;
36
+ }) => JsonObject | undefined;
37
+ /** The log record the host records for one an app isolate returned. */
38
+ export declare const appLog: (log: JsonObject & {
39
+ readonly traceId?: string | undefined;
40
+ readonly spanId?: string | undefined;
41
+ }) => JsonObject;
42
+ export {};
@@ -1,11 +1,14 @@
1
1
  /** Correlate transport and decoded outcomes without exporting response bodies or errors. */
2
2
  import { Effect, Schema, Tracer } from "effect";
3
- import { HttpClient, HttpClientError } from "effect/unstable/http";
4
- /** A random document identity. It is never an authentication or user identifier. */
5
- export declare const browserPageId: () => string;
3
+ import { HttpClient, HttpClientError } from "effect/http";
4
+ /**
5
+ * A random identity for the current browser document. It is never an authentication or user
6
+ * identifier. Server renders have no document, so they get none instead of sharing one per isolate.
7
+ */
8
+ export declare const browserPageId: () => string | undefined;
6
9
  /** Safe event shared with the host's error reporter and product analytics. */
7
10
  export declare const BrowserOperationFailure: Schema.Struct<{
8
- readonly error_type: Schema.Literals<readonly ["BrowserDecodeFailed", "BrowserTransportFailed", "BrowserOperationFailed"]>;
11
+ readonly error_type: Schema.Literals<readonly ["BrowserDecodeFailed", "BrowserConnectionFailed", "BrowserTransportFailed", "BrowserOperationFailed"]>;
9
12
  readonly trace_id: Schema.String;
10
13
  readonly span_id: Schema.String;
11
14
  readonly page_id: Schema.String;
@@ -1,11 +1,16 @@
1
1
  /** Browser-owned Effect telemetry, shared by Promise calls and Atom runtimes. */
2
2
  import { Context, Effect, Layer, ManagedRuntime } from "effect";
3
- import { OtlpExporter } from "effect/unstable/observability";
4
- import { Atom } from "effect/unstable/reactivity";
3
+ import { OtlpExporter } from "effect/observability";
4
+ import { Atom } from "effect/reactivity";
5
5
  import type { TelemetryConfig } from "./config.js";
6
6
  declare const BrowserTelemetry_base: Context.ServiceClass<BrowserTelemetry, "executor/BrowserTelemetry", {
7
+ /**
8
+ * `load` names the document's initial route without a span: hydration resolves no route
9
+ * change, and first load is measured by the vitals. `start` opens a `ui.navigation` span
10
+ * that the router's next `end` closes or the next `start` interrupts.
11
+ */
7
12
  readonly navigation: (event: {
8
- readonly type: "start";
13
+ readonly type: "load" | "start";
9
14
  readonly path: string;
10
15
  } | {
11
16
  readonly type: "end";
@@ -33,8 +33,8 @@ export declare const TelemetryConfig: Schema.Struct<{
33
33
  export type TelemetryConfig = typeof TelemetryConfig.Type;
34
34
  /** Host-only destinations; never copied into an app's invocation telemetry capability. */
35
35
  export declare const CurrentTelemetryConfig: Context.Reference<{
36
- readonly version: string;
37
36
  readonly service: string;
37
+ readonly version: string;
38
38
  readonly environment: string;
39
39
  readonly clock?: "system" | "cloudflare-io" | undefined;
40
40
  readonly traces?: {
@@ -59,8 +59,8 @@ export declare const CurrentTelemetryConfig: Context.Reference<{
59
59
  } | undefined>;
60
60
  /** Read OTLP endpoints uniformly for all signals; development chooses which signals to configure. */
61
61
  export declare const telemetryConfig: (service: string) => Effect.Effect<{
62
- readonly version: string;
63
62
  readonly service: string;
63
+ readonly version: string;
64
64
  readonly environment: string;
65
65
  readonly clock?: "system" | "cloudflare-io" | undefined;
66
66
  readonly traces?: {
@@ -5,5 +5,6 @@ export { captureTelemetry, traceHeaders, withRemoteSpan, invocationFetch, type I
5
5
  export { collectTelemetry, forwardTelemetry, makeTelemetryForwarder, TelemetryBatch, } from "./relay.js";
6
6
  export { TraceContext, currentTraceContext, externalTrace, traceLinks } from "./trace-context.js";
7
7
  export { pendingSpan } from "./pending-span.js";
8
+ export { makeOwnershipAccounting, measuredSpan, owned, ownedBy, ownerAttribute, type Owner, type SpanMeasure, } from "./ownership.js";
8
9
  export { recordWorkerMeasurements } from "./measurements.js";
9
- export { allowlistedSpans, httpSpanAttributeAllowlist, spanAttributeAllowed, } from "./span-attributes.js";
10
+ export { allowlistedSpans, httpSpanAttributeAllowlist, recordRoute, routeTemplates, spanAttributeAllowed, } from "./span-attributes.js";
@@ -2,6 +2,6 @@
2
2
  import { Layer, Logger } from "effect";
3
3
  import { type TelemetryConfig } from "./config.js";
4
4
  /** Build one tracer per runtime. Event mode defers export until Worker scope finalization. */
5
- export declare const telemetryLayer: (config: TelemetryConfig, lifetime?: "process" | "event", logger?: Logger.Logger<unknown, void>) => Layer.Layer<import("effect/unstable/observability/OtlpExporter").Flusher, never, never>;
5
+ export declare const telemetryLayer: (config: TelemetryConfig, lifetime?: "process" | "event", logger?: Logger.Logger<unknown, void>) => Layer.Layer<import("effect/observability/OtlpExporter").Flusher, never, never>;
6
6
  /** Node/local entry points resolve telemetry once and share it for their process lifetime. */
7
- export declare const telemetryFromConfig: (service: string) => Layer.Layer<import("effect/unstable/observability/OtlpExporter").Flusher, import("effect/Schema").SchemaError | import("effect/Config").ConfigError, never>;
7
+ export declare const telemetryFromConfig: (service: string) => Layer.Layer<import("effect/observability/OtlpExporter").Flusher, import("effect/Schema").SchemaError | import("effect/Config").ConfigError, never>;
@@ -3,6 +3,6 @@ import { Effect } from "effect";
3
3
  /** Classify URLs into a fixed set before attaching attributes; raw paths and query strings are never labels. */
4
4
  export declare const recordResponseReady: (path: string | undefined, method: string, status: number, milliseconds: number) => Effect.Effect<void, never, never>;
5
5
  /** Fixed failure metadata goes to both local/native logs and the metric registry, even when the remote exporter is down. */
6
- export declare const recordExportFailure: (path: string, reason?: "transport" | "interrupted" | "partial-success" | "capacity" | "acknowledgement", records?: number) => Effect.Effect<void, never, never>;
6
+ export declare const recordExportFailure: (path: string, reason: "transport" | "interrupted" | "partial-success" | "capacity" | "acknowledgement" | "timeout" | "relay" | "shutdown", records?: number) => Effect.Effect<void, never, never>;
7
7
  /** Record provider-owned invocation totals separately from response-ready timing. */
8
8
  export declare const recordWorkerMeasurements: (worker: string, outcome: string, cpu: number, wall: number) => Effect.Effect<void, never, never>;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Who a span's work belongs to, and how a measured span's time divides among them. A span that
3
+ * starts work for someone other than its caller declares the owner with `ownedBy`; any other span
4
+ * works for whoever its parent works for. Each instant then belongs to the innermost boundary in
5
+ * progress, so Executor's work inside an upstream session stays Executor's, and an app's callback
6
+ * inside Executor's cache stays the app's.
7
+ *
8
+ * Workers clocks advance only on I/O, so durations are comparable within one isolate and not across
9
+ * isolates: each isolate measures its own part, and the spans that already bracket the work define
10
+ * it, so the accounting and the trace agree.
11
+ */
12
+ import { Context, Effect, Tracer } from "effect";
13
+ /**
14
+ * Executor's own work; the app's authored code; waiting on an upstream provider; or waiting on a
15
+ * person's answer.
16
+ */
17
+ export type Owner = "executor" | "app" | "upstream" | "person";
18
+ /** The attribute that shows a boundary's owner in the trace; the telemetry tracer sets it. */
19
+ export declare const ownerAttribute = "executor.owner";
20
+ /** The owner a span declared when it started, if it is an ownership boundary. */
21
+ export declare const declaredOwner: (annotations: Context.Context<never>) => Owner | undefined;
22
+ /**
23
+ * Options for a span whose work belongs to `owner`. Every ownership boundary uses them, at the point
24
+ * the work starts: provider requests and sessions are the upstream's, Executor's services called by
25
+ * an app are Executor's, an app's callbacks are the app's, and waiting for an answer is the person's.
26
+ */
27
+ export declare const ownedBy: (owner: Owner, options?: Tracer.SpanOptionsNoTrace) => Tracer.SpanOptionsNoTrace;
28
+ /** Run `effect` in span `name`, owned by `owner`. */
29
+ export declare const owned: (owner: Owner, name: string, options?: Tracer.SpanOptionsNoTrace) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Tracer.ParentSpan>>;
30
+ /** What a measured span does with its work and its end. */
31
+ export interface SpanMeasure {
32
+ /** Wraps the work inside the span, for example to observe the spans it opens. */
33
+ readonly around?: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
34
+ /** Receives the span's end, before the span ends, to record what it measured on it. */
35
+ readonly end: (end: bigint, span: Tracer.Span) => void;
36
+ }
37
+ /**
38
+ * Run `effect` in span `name`, measured by `measure` from the span's own start to its own end, so
39
+ * the span's duration and the measurement share both boundaries.
40
+ */
41
+ export declare const measuredSpan: (name: string, options: Tracer.SpanOptionsNoTrace, measure: (start: bigint) => SpanMeasure) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Tracer.ParentSpan>>;
42
+ /**
43
+ * Divide a window that starts at `origin`, whose own work is `owner`'s, among owners. At each
44
+ * instant, the work in progress is the innermost span of each branch: a span with no child still
45
+ * open. Its owner takes the instant. With nothing open inside the window, `owner` takes it. Spans
46
+ * are counted as they open and end, in constant time each, and only spans still open are kept.
47
+ */
48
+ export declare const makeOwnershipAccounting: (origin: bigint, owner: Owner) => {
49
+ /** Run `effect` with the spans it opens observed, including spans it hands to later work. */
50
+ observe: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
51
+ /**
52
+ * Close the window at `end` and return its milliseconds by owner, each instant counted once.
53
+ * Spans still open count up to `end`; spans that open or end afterwards are ignored.
54
+ */
55
+ read: (end: bigint) => Readonly<Record<Owner, number>>;
56
+ };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Failures as Executor's telemetry records them. Traces and error reports keep an error's text only
3
+ * when Executor wrote it: a tagged error is recorded by its tag and the fixed sentence it declares
4
+ * (see `RecordedMessage`), or by its tag alone when it declares none. Its fields, message, stack and
5
+ * cause are not recorded, so a value an error carries for its caller, an app's text or a service's
6
+ * reply cannot reach telemetry by an error forgetting to declare. The error itself, and what its
7
+ * caller receives, are unchanged.
8
+ */
9
+ import { Cause } from "effect";
10
+ /**
11
+ * The error a trace or error report records in place of `error`.
12
+ *
13
+ * - A tagged error is named by its tag: a field called `name`, such as a requested skill's or an
14
+ * app's, replaces the error's own name. Its message is the sentence it declares, or empty. Its
15
+ * stack is generated here and names no frames: the error's own stack begins with its message,
16
+ * which can span lines that look like frames. Traces still show where it failed through the
17
+ * operation's own spans, which Effect appends to a recorded stack.
18
+ * - Any other value that is not an `Error`, such as a plain object Effect would print as JSON, is
19
+ * recorded as `UnrecognizedFailure` with no text.
20
+ * - An untagged `Error` is a defect or a platform's error: its message and stack come from the
21
+ * JavaScript engine or a library and are kept, as they are the only diagnosis of an Executor bug.
22
+ * Its cause is recorded by these same rules.
23
+ */
24
+ export declare const recordedError: (error: unknown) => unknown;
25
+ /**
26
+ * A failure's cause as traces record it: each failure and defect by `recordedError`. Interruptions
27
+ * are unchanged, and each reason keeps its annotations, which locate it.
28
+ */
29
+ export declare const recordedCause: <E>(cause: Cause.Cause<E>) => Cause.Cause<unknown>;
@@ -2,11 +2,13 @@
2
2
  import { Effect, Schema } from "effect";
3
3
  /**
4
4
  * Forward app telemetry in the host scope without delaying an app result.
5
- * One export runs at a time, with at most sixteen pending batches. Overload and
6
- * shutdown loss are reported through the normal safe export-failure signal.
7
- * Scope release drains for the same three-second budget as the other exporters.
5
+ * Batches wait in one queue and a single sender exports everything waiting as one request per
6
+ * signal, so a burst of finished runs costs a few exports instead of one each. The queue holds at
7
+ * most eight MiB of payload and one export carries at most four. Overload and shutdown loss are
8
+ * reported through the normal safe export-failure signal. Scope release drains for the same
9
+ * three-second budget as the other exporters.
8
10
  */
9
- export declare const makeTelemetryForwarder: Effect.Effect<(batch: TelemetryBatch, traceId: string, build?: string) => Effect.Effect<void, never, never>, never, import("effect/Scope").Scope>;
11
+ export declare const makeTelemetryForwarder: Effect.Effect<(batch: TelemetryBatch, traceId: string, source: TelemetrySource) => Effect.Effect<void, never, never>, never, import("effect/Scope").Scope>;
10
12
  /** Untrusted isolate batches are bounded before decoding; no endpoint or credential crosses back. */
11
13
  export declare const TelemetryBatch: Schema.Struct<{
12
14
  readonly traces: Schema.$Array<Schema.String>;
@@ -23,6 +25,14 @@ export declare const collectTelemetry: <A, E, R>(effect: Effect.Effect<A, E, R>)
23
25
  logs: string[];
24
26
  dropped: number;
25
27
  };
26
- }, E, Exclude<Exclude<R, import("effect/unstable/observability/OtlpExporter").Flusher>, never>>;
28
+ }, E, Exclude<Exclude<R, import("effect/observability/OtlpExporter").Flusher>, never>>;
29
+ /**
30
+ * What the host knows about the records' source, from its own invocation rather than the records:
31
+ * the build that ran and, for an app isolate, the app's opaque ID. Both become resource attributes.
32
+ */
33
+ export interface TelemetrySource {
34
+ readonly build?: string | undefined;
35
+ readonly app?: string | undefined;
36
+ }
27
37
  /** Validate isolated records and export only this call's trace, using parent-owned credentials/identity. */
28
- export declare const forwardTelemetry: (batch: TelemetryBatch, traceId: string | undefined, build: string | undefined, service?: "executor-app" | "executor-web") => Effect.Effect<void, Schema.SchemaError | import("effect/unstable/http/HttpClientError").HttpClientError | import("effect/Cause").TimeoutError, never>;
38
+ export declare const forwardTelemetry: (batch: TelemetryBatch, traceId: string | undefined, source: TelemetrySource, service?: "executor-app" | "executor-web") => Effect.Effect<void, Schema.SchemaError | import("effect/http/HttpClientError").HttpClientError | import("effect/Cause").TimeoutError, never>;
@@ -18,11 +18,27 @@
18
18
  *
19
19
  * Attributes outside these namespaces are the product's own and pass through.
20
20
  */
21
- import { Layer } from "effect";
21
+ import { Effect, Layer } from "effect";
22
22
  /** Every HTTP attribute an exported span may carry. */
23
23
  export declare const httpSpanAttributeAllowlist: ReadonlySet<string>;
24
24
  /** Record this attribute? HTTP names must be allowlisted; product names pass through. */
25
25
  export declare const spanAttributeAllowed: (key: string) => boolean;
26
+ /**
27
+ * Record the template of a route whose path an app or its caller chose, in place of the router's
28
+ * wildcard: an app's own page or asset, or an app's outbound request. Its last parameter stands
29
+ * for the rest of the path. It annotates the current span, so call it from the request's handler.
30
+ */
31
+ export declare const recordRoute: (template: `/${string}`) => Effect.Effect<void, never, never>;
32
+ /**
33
+ * A fixed set of endpoint templates served under one wildcard route, such as Better Auth's
34
+ * endpoints under `/api/auth/*`. `:name` stands for one segment. `record` names the request's
35
+ * endpoint by its template and leaves the wildcard for any path the set does not hold, so a span
36
+ * keeps which endpoint ran without any segment the caller chose.
37
+ */
38
+ export declare const routeTemplates: (templates: Iterable<`/${string}`>) => {
39
+ match: (path: string) => `/${string}` | undefined;
40
+ record: (path: string) => Effect.Effect<void, never, never>;
41
+ };
26
42
  /** Wrap whichever tracer is already in scope; provide this above the exporter. */
27
43
  export declare const spanAttributes: (clock?: "system" | "cloudflare-io", recordAll?: boolean) => Layer.Layer<never>;
28
44
  /** Header and URL filtering without making an unsupported claim about the runtime clock. */
@@ -1,6 +1,13 @@
1
1
  import { Context, Layer } from "effect";
2
- import { HttpClient } from "effect/unstable/http";
2
+ import { HttpClient, HttpClientError } from "effect/http";
3
3
  /** Local collector discovery can resolve its destination when an export runs. */
4
4
  export declare const CurrentTelemetryClient: Context.Reference<HttpClient.HttpClient | undefined>;
5
5
  /** Telemetry consumers inspect status and headers; release response I/O inside each export scope. */
6
6
  export declare const telemetryHttpClient: Layer.Layer<HttpClient.HttpClient, never, never>;
7
+ /**
8
+ * Resend an export the collector refused for now, as OTLP requires and Effect's own
9
+ * exporters do: lost connections, 429 and 5xx overload, at most three more times. A
10
+ * collector shedding load answers 429 or 503 with Retry-After, which sets the wait. A
11
+ * wait longer than the caller's budget ends with the budget, without sending again.
12
+ */
13
+ export declare const retryTelemetryExport: (client: HttpClient.HttpClient) => HttpClient.HttpClient.With<HttpClientError.HttpClientError, never>;
@@ -0,0 +1,55 @@
1
+ import { Schema, type Cause } from "effect";
2
+ import "effect/http-api";
3
+ /**
4
+ * Encode the class's `message` getter as a required wire string. Decoding validates the field,
5
+ * then omits it, so the class derives its own message from the parsed payload and a supplied
6
+ * value never replaces it.
7
+ */
8
+ export declare const MessageField: Schema.decodeTo<Schema.optionalKey<Schema.String>, Schema.String, never, never>;
9
+ /** An expected API error whose response states its cause in a `message` derived from its fields. */
10
+ export interface ApiError extends Cause.YieldableError {
11
+ readonly _tag: string;
12
+ }
13
+ type Header<Tag extends string> = {
14
+ readonly tag: Tag;
15
+ readonly status: number;
16
+ };
17
+ type Definition<Tag extends string, Fields extends Schema.Struct.Fields> = Header<Tag> & {
18
+ readonly fields: Fields & {
19
+ readonly [Key in "_tag" | "message"]?: never;
20
+ };
21
+ /**
22
+ * The cause, stated for API and agent callers. It is also the error's `message`, which traces
23
+ * record, so it never includes credentials, upstream response text or submitted values.
24
+ */
25
+ readonly message: string | ((fields: Schema.Struct.Type<Fields>) => string);
26
+ /**
27
+ * What traces and error reports record beside the tag. A fixed `message` is recorded as is; a
28
+ * message derived from fields is recorded only through this, from fixed text and closed fields,
29
+ * never a value the caller chose, an app's text or a service's reply. Without it the error is
30
+ * recorded by its tag alone.
31
+ */
32
+ readonly recorded?: (fields: Schema.Struct.Type<Fields>) => string;
33
+ };
34
+ type ErrorFields<Tag extends string, Fields extends Schema.Struct.Fields> = Omit<Schema.TaggedStruct<Tag, Fields & {
35
+ readonly message: typeof MessageField;
36
+ }>, "~type.make.in"> & {
37
+ readonly "~type.make.in": Schema.TaggedStruct<Tag, Fields>["~type.make.in"];
38
+ };
39
+ type ErrorClass<Tag extends string, Fields extends Schema.Struct.Fields> = Schema.Class<Schema.Struct.Type<Fields> & ApiError & {
40
+ readonly _tag: Tag;
41
+ }, ErrorFields<Tag, Fields>, ApiError>;
42
+ /** Define an error with no payload and a fixed message. Its tag is its public error code. */
43
+ declare function define<const Tag extends string>(definition: Header<Tag> & {
44
+ readonly message: string;
45
+ }): ErrorClass<Tag, {}>;
46
+ /** Define an error whose message can depend on its parsed fields. */
47
+ declare function define<const Tag extends string, const Fields extends Schema.Struct.Fields>(definition: Definition<Tag, Fields>): ErrorClass<Tag, Fields>;
48
+ /**
49
+ * Define the schema, constructor and API message of an expected error together. Errors that need
50
+ * a user-facing title and recovery use `UserFacingError`, which carries the same message field.
51
+ */
52
+ export declare const ApiError: {
53
+ define: typeof define;
54
+ };
55
+ export {};
@@ -0,0 +1,33 @@
1
+ /** Requests the browser could not complete because no response reached it. */
2
+ import { Cause } from "effect";
3
+ import { HttpClientError } from "effect/http";
4
+ import { UserFacingError } from "./user-facing-error.js";
5
+ /**
6
+ * Fetch rejects with a `TypeError` when no response arrives: the device is offline, the page
7
+ * navigated away first, the connection was reset before a response, or the browser blocked the
8
+ * request. The server may still have completed the request and records its own outcome. Failures Executor constructs itself, such as a batch reply
9
+ * that ended without an answer, carry no such cause and stay unexpected.
10
+ */
11
+ export declare const isConnectionFailure: (error: unknown) => error is HttpClientError.HttpClientError;
12
+ /** Typed API clients may surface a lost connection as a failure or, after narrowing, a defect. */
13
+ export declare const hasConnectionFailure: (cause: Cause.Cause<unknown>) => boolean;
14
+ /** The browser could not reach Executor. Nothing on the server needs fixing. */
15
+ export declare const ConnectionFailed: import("effect/Schema").Class<{} & UserFacingError & {
16
+ readonly _tag: "ConnectionFailed";
17
+ }, Omit<import("effect/Schema").TaggedStruct<"ConnectionFailed", {
18
+ readonly message: typeof import("./api-error.js").MessageField;
19
+ readonly recovery: import("effect/Schema").decodeTo<import("effect/Schema").optionalKey<import("effect/Schema").Struct<{
20
+ readonly action: import("effect/Schema").String;
21
+ readonly instructions: import("effect/Schema").String;
22
+ }>>, import("effect/Schema").Struct<{
23
+ readonly action: import("effect/Schema").String;
24
+ readonly instructions: import("effect/Schema").String;
25
+ }>, never, never>;
26
+ }>, "~type.make.in"> & {
27
+ readonly "~type.make.in": {
28
+ readonly _tag?: "ConnectionFailed";
29
+ };
30
+ }, UserFacingError>;
31
+ export type ConnectionFailed = typeof ConnectionFailed.Type;
32
+ /** What to show for a failure no contract declares: a lost connection, or an unexpected error. */
33
+ export declare const undeclaredError: (cause: Cause.Cause<unknown>) => UserFacingError;