apps 0.0.1-beta.41 → 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.
Files changed (54) hide show
  1. package/framework-reference.json +1 -1
  2. package/js/{chunk-AHGGO2VY.js → chunk-47BLLMRQ.js} +15 -14
  3. package/js/{chunk-ZUKBIHMK.js → chunk-4ZTVLEN6.js} +3 -3
  4. package/js/{chunk-JI3EP2GL.js → chunk-5GLC42LK.js} +35 -26
  5. package/js/{chunk-DKUEYTYD.js → chunk-74YVXBKY.js} +1 -1
  6. package/js/{chunk-RIXVGVA6.js → chunk-AQU56EPI.js} +9 -5
  7. package/js/{chunk-KAQD3DTI.js → chunk-EG72MSVK.js} +1 -1
  8. package/js/{chunk-TT6OU4UG.js → chunk-EJUK2NK5.js} +2 -2
  9. package/js/{chunk-EM4UL26F.js → chunk-EMHFXFTJ.js} +3 -3
  10. package/js/{chunk-YQ35E7KS.js → chunk-H2CJWXA3.js} +1 -1
  11. package/js/{chunk-MXDKXAY4.js → chunk-IFJU5SYQ.js} +10 -0
  12. package/js/{chunk-MJZYV7IO.js → chunk-ILYK7BQG.js} +3 -3
  13. package/js/{chunk-CQD3WSYH.js → chunk-IN2WIN7I.js} +2 -2
  14. package/js/{chunk-NKWWPJYX.js → chunk-JPEUKEV4.js} +1 -1
  15. package/js/{chunk-UOZMSUJ2.js → chunk-KBIKBWSS.js} +5 -3
  16. package/js/{chunk-WPBR4AWB.js → chunk-KGCTYL2S.js} +2 -2
  17. package/js/{chunk-VIU2XXA7.js → chunk-KSGYJV46.js} +2 -2
  18. package/js/{chunk-ADD6H64X.js → chunk-KTPKTBKZ.js} +9 -9
  19. package/js/{chunk-3MMG2H6M.js → chunk-LNSVJS2Q.js} +1 -1
  20. package/js/{chunk-6XGB4BAL.js → chunk-MSDGZ7FA.js} +9 -9
  21. package/js/{chunk-P7MGDPFD.js → chunk-MWKHKOTL.js} +2 -2
  22. package/js/{chunk-VJQXXOQ3.js → chunk-MZH4J2PO.js} +2 -2
  23. package/js/{chunk-OTCLXFLL.js → chunk-OBXHQNWC.js} +5 -5
  24. package/js/{chunk-FXWRE655.js → chunk-RIKH5H2X.js} +7 -7
  25. package/js/{chunk-KIM5HXNK.js → chunk-T65AFHU3.js} +3 -3
  26. package/js/{chunk-PNVCCB4L.js → chunk-VU6GQ2SH.js} +4 -4
  27. package/js/{chunk-JJSLEJ6T.js → chunk-XSD3RZFX.js} +5 -5
  28. package/js/{chunk-UTJIGUSS.js → chunk-Z3S2IVI3.js} +2 -2
  29. package/js/client.js +10 -10
  30. package/js/contracts.js +8 -8
  31. package/js/effect.js +19 -19
  32. package/js/graphql.js +21 -21
  33. package/js/host.js +19 -19
  34. package/js/index.js +12 -12
  35. package/js/mcp/effect.js +21 -21
  36. package/js/mcp/stdio.js +21 -21
  37. package/js/mcp.js +23 -23
  38. package/js/openapi.js +17 -17
  39. package/js/react.js +2 -2
  40. package/js/skills/effect.js +6 -6
  41. package/js/skills.js +50 -23
  42. package/js/ui/auth/contracts.js +2 -2
  43. package/js/ui/auth.js +5 -5
  44. package/js/ui/contracts.js +5 -5
  45. package/js/ui/serving.js +10 -10
  46. package/package.json +1 -1
  47. package/runtime.json +1 -1
  48. package/types/app-cache/src/index.d.ts +10 -1
  49. package/types/apps/src/contracts/cache.d.ts +6 -0
  50. package/types/apps/src/contracts/skills.d.ts +12 -5
  51. package/types/apps/src/implementation/catalog-cache.d.ts +12 -1
  52. package/types/telemetry/src/browser-operations.d.ts +1 -1
  53. package/types/utils/src/connection-failure.d.ts +33 -0
  54. package/types/utils/src/user-facing-error.d.ts +81 -0
@@ -10,6 +10,12 @@ export interface CacheGet<A> {
10
10
  readonly schema: Schema.Decoder<A>;
11
11
  readonly freshFor: Duration.Input;
12
12
  readonly staleFor?: Duration.Input;
13
+ /**
14
+ * What a read does with a value past `freshFor` and within `staleFor`. `serve`, the default,
15
+ * returns it while one background load replaces it. `revalidate` awaits that load first, like a
16
+ * miss; the value stays readable to the load, which can confirm it instead of rebuilding it.
17
+ */
18
+ readonly stale?: "serve" | "revalidate";
13
19
  readonly load: Effect.Effect<A, unknown>;
14
20
  }
15
21
  /** Create a scoped cache client; a background runner must retain all task resources until completion. */
@@ -30,7 +36,10 @@ deadline?: number) => {
30
36
  }[], retention: Duration.Input) => Effect.Effect<void, CacheError, never>;
31
37
  /** Revoke retained data and any loader's right to publish its in-flight result. */
32
38
  invalidate: (key: Schema.Json) => Effect.Effect<void, CacheError, never>;
33
- /** Read fresh data, refresh stale data in the background, or wait for the lease owner. */
39
+ /**
40
+ * Read fresh data, refresh stale data in the background (or first, with `stale: "revalidate"`),
41
+ * or wait for the lease owner.
42
+ */
34
43
  get: <A>(options: CacheGet<A>) => Effect.Effect<A, unknown, never>;
35
44
  /** Force one awaited refresh without removing the retained value. Concurrent refreshes share a load. */
36
45
  revalidate: <A>(options: CacheGet<A>) => Effect.Effect<A, unknown, never>;
@@ -15,6 +15,12 @@ export interface CacheGetOptions<A> {
15
15
  readonly schema: Schema<A, boolean>;
16
16
  readonly freshFor: Duration.Input;
17
17
  readonly staleFor?: Duration.Input;
18
+ /**
19
+ * Past `freshFor`, `serve` (the default) returns the kept value while `load` replaces it in the
20
+ * background. `revalidate` awaits `load` first; the kept value stays readable with `read`, so
21
+ * the loader can confirm it with the source instead of rebuilding it.
22
+ */
23
+ readonly stale?: "serve" | "revalidate";
18
24
  readonly load: (context: CacheLoadContext) => Promise<A>;
19
25
  }
20
26
  /** Cache keys describe every input that affects the value; the host adds app/build isolation. */
@@ -98,6 +98,8 @@ export declare const skillLoadLimits: {
98
98
  readonly fileBytes: 2000000;
99
99
  readonly totalBytes: 20000000;
100
100
  readonly concurrency: 8;
101
+ /** The request that checks whether a kept catalog's publication changed. */
102
+ readonly checkMillis: 5000;
101
103
  };
102
104
  /** Invocation-owned transport and cancellation, supplied by the app context. */
103
105
  export interface SkillTransport {
@@ -109,14 +111,19 @@ export interface SkillReaderOptions extends SkillTransport {
109
111
  readonly service: string;
110
112
  }
111
113
  /**
112
- * Catalog reuse shared by remote skill loaders, with the same policy as MCP tool catalogs. Pass
113
- * `ctx.cache` to keep the loaded catalog; without it every read fetches the source again.
114
+ * Catalog reuse shared by remote skill loaders. Pass `ctx.cache` to keep the loaded catalog;
115
+ * without it every read fetches the source again. Unlike an MCP tool catalog, a skill catalog
116
+ * past `freshFor` is not served while it refreshes: the read first asks the source whether its
117
+ * publication changed, so agents never read skills that a refresh replaces moments later.
114
118
  */
115
119
  export interface SkillCacheOptions {
116
120
  readonly cache?: import("./cache.js").AppCache;
117
- /** Reuse the catalog for this duration. Defaults to five minutes. */
121
+ /** Reuse the catalog without asking the source for this duration. Defaults to five minutes. */
118
122
  readonly freshFor?: import("effect").Duration.Input;
119
- /** Serve the retained catalog while refreshing. Defaults to one day. */
123
+ /**
124
+ * Keep the catalog this long after `freshFor`. A read then confirms it with one request and
125
+ * loads the files again only when the publication changed. Defaults to one day.
126
+ */
120
127
  readonly staleFor?: import("effect").Duration.Input;
121
128
  }
122
129
  /**
@@ -133,7 +140,7 @@ export type GitHubSkillsAccount = import("./cache.js").AccountCredential<{
133
140
  }>;
134
141
  /**
135
142
  * A GitHub repository and an optional immutable commit, tag or branch. With a cache, a branch or
136
- * tag is resolved again when the catalog refreshes, and each commit's file list is kept.
143
+ * tag is resolved again once the catalog is past `freshFor`, and each commit's file list is kept.
137
144
  */
138
145
  export type GitHubSkillsOptions = SkillTransport & SkillCacheOptions & GitHubSkillsAccount & {
139
146
  readonly repo: string;
@@ -34,6 +34,11 @@ export interface CatalogLoad<A> {
34
34
  readonly tools: readonly A[];
35
35
  readonly header?: JsonObject;
36
36
  }
37
+ /** The catalog a refresh replaces, read only when its loader asks for it. */
38
+ export interface KeptCatalog<A> {
39
+ readonly header: JsonObject | undefined;
40
+ readonly tools: Effect.Effect<readonly A[], unknown>;
41
+ }
37
42
  export declare const catalogCache: <A extends {
38
43
  readonly name: string;
39
44
  }, S>(options: Omit<CatalogCacheOptions, "cache"> & {
@@ -46,7 +51,13 @@ export declare const catalogCache: <A extends {
46
51
  readonly schema: Schema.Decoder<S>;
47
52
  readonly of: (tool: A) => S;
48
53
  };
49
- readonly load: (context?: CacheLoadContext) => Effect.Effect<CatalogLoad<A>, unknown>;
54
+ /** Past `freshFor`, serve the kept catalog while refreshing, or refresh first. */
55
+ readonly stale?: "serve" | "revalidate";
56
+ /**
57
+ * Load the catalog. A refresh also gets the catalog it replaces, if one is kept, so a source
58
+ * that can confirm it is unchanged need not load it again.
59
+ */
60
+ readonly load: (context?: CacheLoadContext, kept?: Effect.Effect<KeptCatalog<A> | undefined, unknown>) => Effect.Effect<CatalogLoad<A>, unknown>;
50
61
  }) => Effect.Effect<{
51
62
  list: () => Effect.Effect<readonly A[], unknown, never>;
52
63
  /** The record stored with the current revision, if the source supplied one. */
@@ -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 {};