apps 0.0.1-beta.42 → 0.0.1-beta.43

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.
@@ -8,7 +8,7 @@ import { HttpClient, HttpClientError } from "effect/http";
8
8
  export declare const browserPageId: () => string | undefined;
9
9
  /** Safe event shared with the host's error reporter and product analytics. */
10
10
  export declare const BrowserOperationFailure: Schema.Struct<{
11
- readonly error_type: Schema.Literals<readonly ["BrowserDecodeFailed", "BrowserTransportFailed", "BrowserOperationFailed"]>;
11
+ readonly error_type: Schema.Literals<readonly ["BrowserDecodeFailed", "BrowserConnectionFailed", "BrowserTransportFailed", "BrowserOperationFailed"]>;
12
12
  readonly trace_id: Schema.String;
13
13
  readonly span_id: Schema.String;
14
14
  readonly page_id: Schema.String;
@@ -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,81 @@
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 instead of the description, when the description quotes
47
+ * an app's own error or a service's stated error for its caller. Only fixed text and typed fields.
48
+ */
49
+ readonly recorded?: (fields: Schema.Struct.Type<Fields>) => string;
50
+ } & (ErrorPresentation | {
51
+ readonly presentation: (fields: Schema.Struct.Type<Fields>) => ErrorPresentation;
52
+ });
53
+ declare const RecoveryField: Schema.decodeTo<Schema.optionalKey<Schema.Struct<{
54
+ readonly action: Schema.String;
55
+ readonly instructions: Schema.String;
56
+ }>>, Schema.Struct<{
57
+ readonly action: Schema.String;
58
+ readonly instructions: Schema.String;
59
+ }>, never, never>;
60
+ type DerivedFields = {
61
+ readonly message: typeof MessageField;
62
+ readonly recovery: typeof RecoveryField;
63
+ };
64
+ type ErrorFields<Tag extends string, Fields extends Schema.Struct.Fields> = Omit<Schema.TaggedStruct<Tag, Fields & DerivedFields>, "~type.make.in"> & {
65
+ readonly "~type.make.in": Schema.TaggedStruct<Tag, Fields>["~type.make.in"];
66
+ };
67
+ type ErrorClass<Tag extends string, Fields extends Schema.Struct.Fields> = Schema.Class<Schema.Struct.Type<Fields> & UserFacingError & {
68
+ readonly _tag: Tag;
69
+ }, ErrorFields<Tag, Fields>, UserFacingError>;
70
+ /** Define a schema-backed error with no payload. Its tag becomes its public error code. */
71
+ declare function define<const Tag extends string>(definition: Header<Tag> & ErrorPresentation): ErrorClass<Tag, {}>;
72
+ /** Define a schema-backed error whose safe presentation can depend on its parsed fields. */
73
+ declare function define<const Tag extends string, const Fields extends Schema.Struct.Fields>(definition: Definition<Tag, Fields>): ErrorClass<Tag, Fields>;
74
+ /** Define the schema, error constructor, user copy, and agent recovery together. */
75
+ export declare const UserFacingError: {
76
+ define: typeof define;
77
+ is: (value: unknown) => value is UserFacingError;
78
+ };
79
+ /** Defects get a safe explanation without exposing an arbitrary cause. */
80
+ export declare const UnexpectedError: ErrorClass<"UnexpectedError", {}>;
81
+ export {};