apps 0.0.1-beta.5 → 0.0.1-beta.55

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 (188) hide show
  1. package/README.md +68 -44
  2. package/framework-reference.json +1 -1
  3. package/js/chunk-47F7VXST.js +221 -0
  4. package/js/chunk-5FHWNLCI.js +88 -0
  5. package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
  6. package/js/chunk-7UUHJR2Q.js +49 -0
  7. package/js/{chunk-CYYBFC2K.js → chunk-AQU56EPI.js} +9 -5
  8. package/js/chunk-BTSIG4NQ.js +1885 -0
  9. package/js/chunk-CDXQDN7W.js +92 -0
  10. package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
  11. package/js/{chunk-27F7W2LG.js → chunk-H2CJWXA3.js} +2 -2
  12. package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
  13. package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
  14. package/js/{chunk-UDDE5KOR.js → chunk-JK5S2N2S.js} +148 -34
  15. package/js/{chunk-RJDDBDSN.js → chunk-JM7LOD2W.js} +628 -85
  16. package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
  17. package/js/{chunk-FWQC6I3C.js → chunk-KGCTYL2S.js} +523 -63
  18. package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
  19. package/js/chunk-L4K2K22P.js +42 -0
  20. package/js/chunk-LTDHQJ2Z.js +171 -0
  21. package/js/chunk-MWKHKOTL.js +240 -0
  22. package/js/chunk-OD3KFKZD.js +1617 -0
  23. package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
  24. package/js/chunk-PXXZ6ABC.js +266 -0
  25. package/js/chunk-QEBRH5AP.js +729 -0
  26. package/js/chunk-TLWLJ7PD.js +4342 -0
  27. package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
  28. package/js/{chunk-XHO2ZX6W.js → chunk-UM62MBJQ.js} +96 -41
  29. package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
  30. package/js/chunk-XCSG7FT7.js +340 -0
  31. package/js/client.js +142 -94
  32. package/js/contracts.js +123 -33
  33. package/js/effect.js +19 -21
  34. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  35. package/js/graphql.js +63 -60
  36. package/js/host.js +83 -60
  37. package/js/index.js +262 -222
  38. package/js/mcp/effect.js +23 -23
  39. package/js/mcp/stdio.js +48 -40
  40. package/js/mcp.js +109 -72
  41. package/js/openapi.js +4129 -1419
  42. package/js/react.js +2 -3
  43. package/js/skills/effect.js +6 -3
  44. package/js/skills.js +208 -82
  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 +2 -3
  51. package/runtime.json +1 -1
  52. package/types/app-cache/src/index.d.ts +10 -1
  53. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  54. package/types/apps/src/contracts/app.d.ts +9 -8
  55. package/types/apps/src/contracts/cache.d.ts +20 -0
  56. package/types/apps/src/contracts/context.d.ts +19 -11
  57. package/types/apps/src/contracts/elicitation.d.ts +6 -6
  58. package/types/apps/src/contracts/events.d.ts +93 -0
  59. package/types/apps/src/contracts/failure.d.ts +30 -1
  60. package/types/apps/src/contracts/graphql.d.ts +2 -1
  61. package/types/apps/src/contracts/host.d.ts +57 -18
  62. package/types/apps/src/contracts/live.d.ts +2 -0
  63. package/types/apps/src/contracts/mcp.d.ts +96 -10
  64. package/types/apps/src/contracts/network.d.ts +84 -0
  65. package/types/apps/src/contracts/openapi-compile.d.ts +32 -3
  66. package/types/apps/src/contracts/openapi.d.ts +45 -9
  67. package/types/apps/src/contracts/operations.d.ts +8 -9
  68. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  69. package/types/apps/src/contracts/protocols/1.d.ts +733 -81
  70. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  71. package/types/apps/src/contracts/protocols/2.d.ts +69 -26
  72. package/types/apps/src/contracts/protocols/3.d.ts +133 -33
  73. package/types/apps/src/contracts/protocols/4.d.ts +1306 -0
  74. package/types/apps/src/contracts/protocols/5.d.ts +1200 -0
  75. package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
  76. package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
  77. package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
  78. package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
  79. package/types/apps/src/contracts/protocols/current.d.ts +2476 -0
  80. package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
  81. package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
  82. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  83. package/types/apps/src/contracts/provider.d.ts +115 -10
  84. package/types/apps/src/contracts/router.d.ts +59 -0
  85. package/types/apps/src/contracts/skills.d.ts +50 -13
  86. package/types/apps/src/contracts/sql.d.ts +58 -0
  87. package/types/apps/src/contracts/ui.d.ts +19 -1
  88. package/types/apps/src/contracts/workflows.d.ts +6 -0
  89. package/types/apps/src/facet.d.ts +4 -5
  90. package/types/apps/src/graphql.d.ts +1 -3
  91. package/types/apps/src/host.d.ts +5 -0
  92. package/types/apps/src/implementation/account-router.d.ts +13 -0
  93. package/types/apps/src/implementation/app.d.ts +5 -4
  94. package/types/apps/src/implementation/authoring.d.ts +25 -5
  95. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  96. package/types/apps/src/implementation/cache.d.ts +4 -0
  97. package/types/apps/src/implementation/catalog-cache.d.ts +43 -5
  98. package/types/apps/src/implementation/elicitation.d.ts +18 -15
  99. package/types/apps/src/implementation/events.d.ts +59 -0
  100. package/types/apps/src/implementation/failure-detail.d.ts +25 -3
  101. package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
  102. package/types/apps/src/implementation/graphql.d.ts +4 -3
  103. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  104. package/types/apps/src/implementation/invocation-timing.d.ts +16 -0
  105. package/types/apps/src/implementation/live.d.ts +2 -2
  106. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  107. package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
  108. package/types/apps/src/implementation/mcp-client.d.ts +49 -25
  109. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  110. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  111. package/types/apps/src/implementation/mcp.d.ts +52 -25
  112. package/types/apps/src/implementation/network.d.ts +16 -0
  113. package/types/apps/src/implementation/openapi-compile.d.ts +27 -6
  114. package/types/apps/src/implementation/openapi-document.d.ts +46 -19
  115. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  116. package/types/apps/src/implementation/openapi-request.d.ts +10 -2
  117. package/types/apps/src/implementation/openapi-source.d.ts +8 -6
  118. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  119. package/types/apps/src/implementation/operations.d.ts +43 -5
  120. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  121. package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
  122. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  123. package/types/apps/src/implementation/provider.d.ts +19 -5
  124. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  125. package/types/apps/src/implementation/router-catalog.d.ts +223 -0
  126. package/types/apps/src/implementation/router.d.ts +70 -0
  127. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  128. package/types/apps/src/implementation/schema.d.ts +95 -11
  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/workflow-context.d.ts +1 -1
  141. package/types/apps/src/implementation/workflows.d.ts +1 -1
  142. package/types/apps/src/index.d.ts +32 -13
  143. package/types/apps/src/mcp-stdio.d.ts +2 -5
  144. package/types/apps/src/mcp.d.ts +25 -5
  145. package/types/apps/src/openapi.d.ts +6 -6
  146. package/types/apps/src/react.d.ts +1 -1
  147. package/types/apps/src/skills.d.ts +10 -8
  148. package/types/telemetry/src/app-records.d.ts +42 -0
  149. package/types/telemetry/src/browser-operations.d.ts +7 -4
  150. package/types/telemetry/src/browser.d.ts +8 -3
  151. package/types/telemetry/src/config.d.ts +2 -2
  152. package/types/telemetry/src/index.d.ts +1 -0
  153. package/types/telemetry/src/layer.d.ts +2 -2
  154. package/types/telemetry/src/ownership.d.ts +56 -0
  155. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  156. package/types/telemetry/src/relay.d.ts +2 -2
  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-3XKZDQLM.js +0 -93
  163. package/js/chunk-4M277YTM.js +0 -136
  164. package/js/chunk-67EVWIGJ.js +0 -224
  165. package/js/chunk-C3VAOK5B.js +0 -215
  166. package/js/chunk-DQAZTA4I.js +0 -2375
  167. package/js/chunk-G7T27IWB.js +0 -63
  168. package/js/chunk-LUVSFETN.js +0 -1347
  169. package/js/chunk-N7YDVXYJ.js +0 -186
  170. package/js/chunk-PJJ24GU7.js +0 -877
  171. package/js/chunk-PZB6T6KU.js +0 -19
  172. package/js/chunk-SB3V4YVR.js +0 -18
  173. package/js/chunk-TDNYXSIX.js +0 -29
  174. package/js/chunk-W4DMKWAB.js +0 -35
  175. package/js/chunk-YEPYT6SD.js +0 -85
  176. package/js/chunk-ZQINWV4W.js +0 -630
  177. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  178. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  179. package/types/app-data/src/implementation/promise.d.ts +0 -68
  180. package/types/app-data/src/implementation/range.d.ts +0 -8
  181. package/types/app-data/src/implementation/schema.d.ts +0 -18
  182. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  183. package/types/app-data/src/index.d.ts +0 -4
  184. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  185. package/types/apps/src/contracts/storage.d.ts +0 -68
  186. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  187. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
  188. package/types/apps/src/implementation/storage.d.ts +0 -15
@@ -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>;
@@ -23,6 +23,6 @@ export declare const collectTelemetry: <A, E, R>(effect: Effect.Effect<A, E, R>)
23
23
  logs: string[];
24
24
  dropped: number;
25
25
  };
26
- }, E, Exclude<Exclude<R, import("effect/unstable/observability/OtlpExporter").Flusher>, never>>;
26
+ }, E, Exclude<Exclude<R, import("effect/observability/OtlpExporter").Flusher>, never>>;
27
27
  /** 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>;
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/http/HttpClientError").HttpClientError | import("effect/Cause").TimeoutError, never>;
@@ -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;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The fixed sentence traces and error reports record for a tagged error, beside its tag. Telemetry
3
+ * records no other text from a tagged error: one that declares no sentence is recorded by its tag
4
+ * alone (`@executor-js/telemetry/recorded-failure`). Declare one from fixed text and closed fields
5
+ * only, never from a value the caller supplied (a slug, a name, a tool name, an argument's key),
6
+ * an app's own text or a service's reply. That text still reaches the caller the error is for.
7
+ * `ApiError` and `UserFacingError` declare a fixed message for you; a message derived from fields
8
+ * declares `recorded`.
9
+ */
10
+ export declare const RecordedMessage: unique symbol;
11
+ /** The fixed sentence an error declares for telemetry, if it declares one. */
12
+ export declare const recordedMessage: (error: unknown) => string | undefined;
13
+ /**
14
+ * Declare a recorded message on one error that Executor did not define the text of, such as an
15
+ * error decoded from an app's reply. An error class's own declaration is kept. The error's fields
16
+ * and wire encoding are unchanged.
17
+ */
18
+ export declare const recordAs: <E>(error: E, message: string) => E;
@@ -0,0 +1,83 @@
1
+ import { Schema, type Cause } from "effect";
2
+ import "effect/http-api";
3
+ import { MessageField } from "./api-error.js";
4
+ /** Curated explanation and recovery. Never include raw diagnostics, credentials, or form values. */
5
+ export interface ErrorPresentation {
6
+ readonly title: string;
7
+ readonly description: string;
8
+ readonly recovery: {
9
+ readonly action: string;
10
+ readonly instructions: string;
11
+ };
12
+ /** Repeating the failed operation can help. Configuration changes are not retries. */
13
+ readonly retryable?: boolean;
14
+ /** False when the user's agent cannot act on the fix prompt, so hosts do not offer it. */
15
+ readonly agentFixable?: boolean;
16
+ /** One safe value the user needs for recovery, such as a URL to send to the service. */
17
+ readonly detail?: {
18
+ readonly label: string;
19
+ readonly value: string;
20
+ };
21
+ /**
22
+ * Present only when the Executor team must fix the problem. Safe evidence for a public
23
+ * report: fixed codes and statuses, never user data, URLs, or upstream text.
24
+ */
25
+ readonly report?: string;
26
+ }
27
+ type PresentationProperties = Required<Omit<ErrorPresentation, "detail" | "report">> & {
28
+ readonly detail: ErrorPresentation["detail"];
29
+ readonly report: ErrorPresentation["report"];
30
+ readonly code: string;
31
+ readonly fixPrompt: string;
32
+ };
33
+ /** A yieldable error that owns its safe user explanation and agent recovery task. */
34
+ export interface UserFacingError extends Cause.YieldableError, PresentationProperties {
35
+ readonly _tag: string;
36
+ }
37
+ type Header<Tag extends string> = {
38
+ readonly tag: Tag;
39
+ readonly status: number;
40
+ };
41
+ type Definition<Tag extends string, Fields extends Schema.Struct.Fields> = Header<Tag> & {
42
+ readonly fields: Fields & {
43
+ readonly [Key in keyof PresentationProperties | "_tag" | "message"]?: never;
44
+ };
45
+ /**
46
+ * What traces and error reports record beside the tag. A fixed description is recorded as is; a
47
+ * presentation derived from fields is recorded only through this, from fixed text and closed
48
+ * fields, never a value the caller chose, an app's text or a service's reply. Without it the
49
+ * error is recorded by its tag alone.
50
+ */
51
+ readonly recorded?: (fields: Schema.Struct.Type<Fields>) => string;
52
+ } & (ErrorPresentation | {
53
+ readonly presentation: (fields: Schema.Struct.Type<Fields>) => ErrorPresentation;
54
+ });
55
+ declare const RecoveryField: Schema.decodeTo<Schema.optionalKey<Schema.Struct<{
56
+ readonly action: Schema.String;
57
+ readonly instructions: Schema.String;
58
+ }>>, Schema.Struct<{
59
+ readonly action: Schema.String;
60
+ readonly instructions: Schema.String;
61
+ }>, never, never>;
62
+ type DerivedFields = {
63
+ readonly message: typeof MessageField;
64
+ readonly recovery: typeof RecoveryField;
65
+ };
66
+ type ErrorFields<Tag extends string, Fields extends Schema.Struct.Fields> = Omit<Schema.TaggedStruct<Tag, Fields & DerivedFields>, "~type.make.in"> & {
67
+ readonly "~type.make.in": Schema.TaggedStruct<Tag, Fields>["~type.make.in"];
68
+ };
69
+ type ErrorClass<Tag extends string, Fields extends Schema.Struct.Fields> = Schema.Class<Schema.Struct.Type<Fields> & UserFacingError & {
70
+ readonly _tag: Tag;
71
+ }, ErrorFields<Tag, Fields>, UserFacingError>;
72
+ /** Define a schema-backed error with no payload. Its tag becomes its public error code. */
73
+ declare function define<const Tag extends string>(definition: Header<Tag> & ErrorPresentation): ErrorClass<Tag, {}>;
74
+ /** Define a schema-backed error whose safe presentation can depend on its parsed fields. */
75
+ declare function define<const Tag extends string, const Fields extends Schema.Struct.Fields>(definition: Definition<Tag, Fields>): ErrorClass<Tag, Fields>;
76
+ /** Define the schema, error constructor, user copy, and agent recovery together. */
77
+ export declare const UserFacingError: {
78
+ define: typeof define;
79
+ is: (value: unknown) => value is UserFacingError;
80
+ };
81
+ /** Defects get a safe explanation without exposing an arbitrary cause. */
82
+ export declare const UnexpectedError: ErrorClass<"UnexpectedError", {}>;
83
+ export {};
@@ -1,93 +0,0 @@
1
- import {
2
- decoderOf
3
- } from "./chunk-FWQC6I3C.js";
4
- import {
5
- Effect_exports
6
- } from "./chunk-CDL5PM2Q.js";
7
-
8
- // src/implementation/authoring.ts
9
- var NativeCallback = /* @__PURE__ */ Symbol("apps.NativeCallback");
10
- var fromPromise = (callback) => (...args) => {
11
- if (NativeCallback in callback) {
12
- const native = callback[NativeCallback];
13
- return native(...args);
14
- }
15
- return Effect_exports.tryPromise({ try: () => callback(...args), catch: (error) => error });
16
- };
17
- var toPromise = (operation, signal) => {
18
- const native = (...args) => Effect_exports.suspend(() => {
19
- if (signal === void 0) return operation(...args);
20
- if (signal.aborted) return Effect_exports.interrupt;
21
- const cancelled = Effect_exports.callback((resume) => {
22
- if (signal.aborted) {
23
- resume(Effect_exports.interrupt);
24
- return;
25
- }
26
- const abort = () => resume(Effect_exports.interrupt);
27
- signal.addEventListener("abort", abort, { once: true });
28
- return Effect_exports.sync(() => signal.removeEventListener("abort", abort));
29
- });
30
- return Effect_exports.raceFirst(
31
- cancelled,
32
- Effect_exports.suspend(() => operation(...args))
33
- );
34
- });
35
- return Object.assign((...args) => Effect_exports.runPromise(native(...args)), {
36
- [NativeCallback]: native
37
- });
38
- };
39
-
40
- // src/implementation/operations.ts
41
- var NativeOperation = /* @__PURE__ */ Symbol("apps.Operation");
42
- var operationDeclaration = (operation) => ({
43
- kind: operation.kind,
44
- [NativeOperation]: operation
45
- });
46
- var nativeOperation = (value) => {
47
- if (typeof value !== "object" || value === null || !(NativeOperation in value)) return void 0;
48
- return value[NativeOperation];
49
- };
50
- var operationOptions = (options) => {
51
- const approval = options.approval;
52
- return {
53
- ...options.description === void 0 ? {} : { description: options.description },
54
- ...options.title === void 0 ? {} : { title: options.title },
55
- ...options.annotations === void 0 ? {} : { annotations: options.annotations },
56
- ...options._meta === void 0 ? {} : { _meta: options._meta },
57
- input: decoderOf(options.input),
58
- ...approval === void 0 ? {} : {
59
- approval: (context) => Effect_exports.tryPromise({ try: async () => approval(context), catch: (error) => error })
60
- }
61
- };
62
- };
63
- var withApproval = (operation, approval) => ({
64
- ...operation,
65
- [NativeOperation]: {
66
- ...operation[NativeOperation],
67
- approval: (context) => Effect_exports.tryPromise({ try: async () => approval(context), catch: (error) => error })
68
- }
69
- });
70
- var make = (kind, options, run) => operationDeclaration({
71
- ...operationOptions(options),
72
- kind,
73
- // The host always validates JSON serialization, even without a stronger output declaration.
74
- ...options.output === void 0 ? {} : { output: decoderOf(options.output) },
75
- run: (context, input) => Effect_exports.tryPromise({
76
- // SAFETY: defineApp checks the handler context against its requirements.
77
- // The host validates account bindings and creates the matching storage facade.
78
- try: () => run(context, input),
79
- catch: (error) => error
80
- })
81
- });
82
- var query = (options, run) => make("query", options, run);
83
- var mutation = (options, run) => make("mutation", options, run);
84
-
85
- export {
86
- fromPromise,
87
- toPromise,
88
- operationDeclaration,
89
- nativeOperation,
90
- withApproval,
91
- query,
92
- mutation
93
- };
@@ -1,136 +0,0 @@
1
- import {
2
- ApiErrorResponse
3
- } from "./chunk-W4DMKWAB.js";
4
- import {
5
- AccountId,
6
- HttpUrl,
7
- JsonObject
8
- } from "./chunk-27F7W2LG.js";
9
- import {
10
- Schema_exports
11
- } from "./chunk-CDL5PM2Q.js";
12
-
13
- // src/contracts/openapi.ts
14
- var OpenapiErrorResponse = Schema_exports.Struct({
15
- code: ApiErrorResponse.fields.code,
16
- status: ApiErrorResponse.fields.status,
17
- message: Schema_exports.Union([
18
- Schema_exports.Struct({ source: Schema_exports.Literal("body") }),
19
- Schema_exports.Struct({ source: Schema_exports.Literal("schema"), value: ApiErrorResponse.fields.message })
20
- ]),
21
- schema: JsonObject
22
- });
23
- var OpenapiParameter = Schema_exports.Struct({
24
- name: Schema_exports.String,
25
- in: Schema_exports.Literals(["path", "query", "header", "cookie"]),
26
- required: Schema_exports.optionalKey(Schema_exports.Boolean),
27
- schema: Schema_exports.optionalKey(JsonObject),
28
- style: Schema_exports.optionalKey(Schema_exports.String),
29
- explode: Schema_exports.optionalKey(Schema_exports.Boolean),
30
- allowReserved: Schema_exports.optionalKey(Schema_exports.Boolean),
31
- allowEmptyValue: Schema_exports.optionalKey(Schema_exports.Boolean),
32
- content: Schema_exports.optionalKey(JsonObject)
33
- });
34
- var OpenapiRequestBody = Schema_exports.Struct({
35
- required: Schema_exports.optionalKey(Schema_exports.Boolean),
36
- content: Schema_exports.Record(
37
- Schema_exports.String,
38
- Schema_exports.Struct({
39
- schema: Schema_exports.optionalKey(JsonObject),
40
- encoding: Schema_exports.optionalKey(JsonObject)
41
- })
42
- )
43
- });
44
- var OpenapiOperation = Schema_exports.Struct({
45
- /** The tool name after `queries.` or `mutations.`, grouped as `<group>.<leaf>`. */
46
- name: Schema_exports.NonEmptyString,
47
- /** The document's operationId, when it declares one. `kinds` overrides are keyed by it. */
48
- operationId: Schema_exports.optionalKey(Schema_exports.String),
49
- description: Schema_exports.String,
50
- method: Schema_exports.Literals(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]),
51
- path: Schema_exports.String,
52
- baseUrl: HttpUrl,
53
- openapi: Schema_exports.String,
54
- securitySchemes: Schema_exports.Record(Schema_exports.String, JsonObject),
55
- /** The resolved OpenAPI Operation Object; Executor schemas remain separate. */
56
- request: Schema_exports.Struct({
57
- parameters: Schema_exports.Array(OpenapiParameter),
58
- requestBody: Schema_exports.optionalKey(OpenapiRequestBody),
59
- security: Schema_exports.Array(Schema_exports.Record(Schema_exports.String, Schema_exports.Array(Schema_exports.String))),
60
- responses: Schema_exports.Record(Schema_exports.String, JsonObject)
61
- }),
62
- /** Streams remain in the metadata but cannot run through a single-result tool call. */
63
- streaming: Schema_exports.optionalKey(Schema_exports.Literal(true)),
64
- input: JsonObject,
65
- outputSchema: Schema_exports.optionalKey(JsonObject),
66
- errorResponses: Schema_exports.optionalKey(Schema_exports.Array(OpenapiErrorResponse))
67
- });
68
- var CredentialBinding = Schema_exports.Struct({
69
- scheme: Schema_exports.String,
70
- field: Schema_exports.String,
71
- part: Schema_exports.Literals(["value", "username", "password"]),
72
- prefix: Schema_exports.String
73
- });
74
- var OpenapiAccount = Schema_exports.Struct({
75
- id: Schema_exports.optional(AccountId),
76
- method: Schema_exports.String,
77
- fields: Schema_exports.Record(Schema_exports.String, Schema_exports.Unknown)
78
- });
79
- var OpenapiParameterDefaults = Schema_exports.Struct({
80
- path: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.String, Schema_exports.String)),
81
- query: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.String, Schema_exports.String)),
82
- headers: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.String, Schema_exports.String))
83
- });
84
- var OpenapiToolsOptions = Schema_exports.Struct({
85
- operations: Schema_exports.Array(OpenapiOperation),
86
- /**
87
- * Component schemas stored once per app and referenced as `#/$defs/<name>`. Operations
88
- * generated before shared definitions carry their own `$defs` and omit this.
89
- */
90
- definitions: Schema_exports.optional(Schema_exports.Record(Schema_exports.String, JsonObject)),
91
- methods: Schema_exports.Record(Schema_exports.String, Schema_exports.Array(CredentialBinding)),
92
- oauth: Schema_exports.Array(Schema_exports.String),
93
- account: Schema_exports.optional(OpenapiAccount),
94
- parameterDefaults: Schema_exports.optional(OpenapiParameterDefaults),
95
- signal: Schema_exports.optional(Schema_exports.instanceOf(AbortSignal)),
96
- fetch: Schema_exports.optional(
97
- Schema_exports.declare((value) => typeof value === "function")
98
- )
99
- });
100
- var OpenapiError = class extends Schema_exports.TaggedError()("OpenapiError", {
101
- reason: Schema_exports.Literals(["invalid_definition", "invalid_input", "request"]),
102
- status: Schema_exports.optional(Schema_exports.Number)
103
- }) {
104
- };
105
- var defaultOpenapiResponseLimits = {
106
- maxBodyBytes: 16777216,
107
- readTimeoutMs: 3e4
108
- };
109
- var isOpenapiTextMedia = (type) => /^(?:text\/|application\/(?:[\w.-]+\+)?(?:json|xml)|application\/(?:javascript|x-ndjson|x-www-form-urlencoded))/i.test(
110
- type
111
- );
112
- var isOpenapiFileSchema = (shape) => shape.contentMediaType !== void 0 && shape.contentEncoding === void 0 || shape.type === "string" && shape.format === "binary";
113
- var openapiBinaryResultSchema = {
114
- type: "object",
115
- properties: {
116
- base64: { type: "string", contentEncoding: "base64" },
117
- contentType: { type: "string" }
118
- },
119
- required: ["base64", "contentType"],
120
- additionalProperties: false
121
- };
122
- var openapiMediaKind = (type) => type.includes("json") && !type.includes("ndjson") ? "json" : type === "application/x-www-form-urlencoded" ? "form" : type === "multipart/form-data" ? "multipart" : isOpenapiTextMedia(type) ? "text" : "binary";
123
-
124
- export {
125
- OpenapiErrorResponse,
126
- OpenapiParameter,
127
- OpenapiRequestBody,
128
- OpenapiOperation,
129
- OpenapiToolsOptions,
130
- OpenapiError,
131
- defaultOpenapiResponseLimits,
132
- isOpenapiTextMedia,
133
- isOpenapiFileSchema,
134
- openapiBinaryResultSchema,
135
- openapiMediaKind
136
- };