apps 0.0.1-beta.3 → 0.0.1-beta.30
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.
- package/README.md +68 -44
- package/framework-reference.json +1 -1
- package/js/{chunk-G7ZIRKMK.js → chunk-2D2PKLGQ.js} +118 -197
- package/js/chunk-3SPRHIEE.js +42 -0
- package/js/{chunk-FDNTX5QJ.js → chunk-4N26L465.js} +2 -2
- package/js/chunk-5ZHHO4OM.js +92 -0
- package/js/{chunk-EVJUVWN2.js → chunk-65SZ23BK.js} +2 -2
- package/js/{chunk-M6ZRRIBI.js → chunk-6JBTHTI5.js} +1 -1
- package/js/{chunk-J7O55ZV7.js → chunk-6NK26ONC.js} +332 -187
- package/js/chunk-6VWYEQ4X.js +254 -0
- package/js/{chunk-RN2MXB4R.js → chunk-AE4FWJQU.js} +128 -24
- package/js/{chunk-HDJH3RPR.js → chunk-BBTELEAN.js} +2 -2
- package/js/{chunk-LGIYBDWA.js → chunk-BRGF7VFN.js} +65 -1
- package/js/{chunk-MYYEW3RA.js → chunk-BSRU52RU.js} +984 -61
- package/js/{chunk-FZJOYIZO.js → chunk-BTJMXW4I.js} +1 -1
- package/js/{chunk-HDTGZWP2.js → chunk-IMCEF6KE.js} +139 -32
- package/js/chunk-KQCMHI3K.js +118 -0
- package/js/{chunk-BMOIAIVR.js → chunk-M2KEEOIQ.js} +49 -1
- package/js/{chunk-YEJOQEII.js → chunk-MYCVMDWI.js} +45 -7
- package/js/{chunk-FW5HBOIK.js → chunk-NXTXZ635.js} +1841 -1701
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-JN55AYQH.js → chunk-OI5CKSBU.js} +61 -32
- package/js/{chunk-NQ3OMCA5.js → chunk-P46HIAX6.js} +2 -2
- package/js/chunk-PUC24GZP.js +801 -0
- package/js/{chunk-SATWJKN6.js → chunk-PWF2DRJ3.js} +1 -1
- package/js/{chunk-D47C7KG5.js → chunk-VUVBMNKC.js} +2 -2
- package/js/{chunk-ZCAMUXSG.js → chunk-WGBI5MVX.js} +3 -4
- package/js/{chunk-T2LAZCAD.js → chunk-WQ5MVBTP.js} +1 -1
- package/js/{chunk-PLCMJREA.js → chunk-XBQTJP76.js} +60 -20
- package/js/{chunk-QKHR7BMF.js → chunk-XGN5IFOZ.js} +3 -3
- package/js/{chunk-WFSQXYUT.js → chunk-YML53Z7H.js} +42 -5
- package/js/{chunk-5MQZEB6Y.js → chunk-ZZOCEUTB.js} +37 -12
- package/js/client.js +120 -84
- package/js/contracts.js +110 -16
- package/js/effect.js +20 -20
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +58 -54
- package/js/host.js +20 -20
- package/js/index.js +247 -204
- package/js/mcp/effect.js +24 -22
- package/js/mcp/stdio.js +35 -30
- package/js/mcp.js +105 -68
- package/js/openapi.js +4087 -1503
- package/js/react.js +3 -3
- package/js/skills/effect.js +5 -3
- package/js/skills.js +15 -15
- package/js/storage/facet.js +4 -4
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +5 -4
- package/js/ui/serving.js +8516 -214
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/app-data/src/implementation/schema.d.ts +2 -17
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +7 -6
- package/types/apps/src/contracts/failure.d.ts +54 -0
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +34 -11
- package/types/apps/src/contracts/mcp.d.ts +91 -10
- package/types/apps/src/contracts/network.d.ts +84 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +31 -3
- package/types/apps/src/contracts/openapi.d.ts +45 -9
- package/types/apps/src/contracts/operations.d.ts +5 -6
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +251 -69
- package/types/apps/src/contracts/protocols/2.d.ts +710 -0
- package/types/apps/src/contracts/protocols/3.d.ts +716 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1298 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1174 -0
- package/types/apps/src/contracts/protocols/6.d.ts +1620 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1119 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +115 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/skills.d.ts +18 -5
- package/types/apps/src/contracts/storage.d.ts +3 -3
- package/types/apps/src/contracts/ui.d.ts +18 -0
- package/types/apps/src/contracts/workflows.d.ts +34 -3
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/implementation/account-router.d.ts +12 -0
- package/types/apps/src/implementation/app.d.ts +5 -4
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +34 -4
- package/types/apps/src/implementation/elicitation.d.ts +9 -9
- package/types/apps/src/implementation/failure-detail.d.ts +46 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/mcp-call.d.ts +6 -5
- package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
- package/types/apps/src/implementation/mcp-client.d.ts +49 -25
- package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +52 -25
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +27 -6
- package/types/apps/src/implementation/openapi-document.d.ts +35 -8
- package/types/apps/src/implementation/openapi-names.d.ts +9 -4
- package/types/apps/src/implementation/openapi-request.d.ts +10 -2
- package/types/apps/src/implementation/openapi-source.d.ts +8 -6
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +36 -3
- package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +19 -5
- package/types/apps/src/implementation/router-catalog.d.ts +224 -0
- package/types/apps/src/implementation/router.d.ts +68 -0
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schema.d.ts +52 -1
- package/types/apps/src/implementation/skills.d.ts +2 -2
- package/types/apps/src/implementation/storage.d.ts +5 -3
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-client.d.ts +2 -2
- package/types/apps/src/implementation/ui-document.d.ts +5 -0
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +10 -4
- package/types/apps/src/implementation/ui-watch.d.ts +1 -1
- package/types/apps/src/implementation/upstream-error.d.ts +7 -0
- package/types/apps/src/implementation/webhooks.d.ts +1 -1
- package/types/apps/src/implementation/workflow-context.d.ts +11 -3
- package/types/apps/src/index.d.ts +29 -11
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +25 -5
- package/types/apps/src/openapi.d.ts +6 -6
- package/types/apps/src/skills.d.ts +4 -4
- package/types/telemetry/src/browser-operations.d.ts +5 -2
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/utils/src/api-error.d.ts +48 -0
- package/js/chunk-PYUYJRSK.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-W7D7WVSY.js +0 -18
- package/js/chunk-Z5NMEGJN.js +0 -29
- package/js/chunk-ZJWDMTE3.js +0 -63
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** Author schema facade. Internals use the native decoder retained by each value. */
|
|
2
2
|
import { Effect, Schema as EffectSchema } from "effect";
|
|
3
|
-
import {
|
|
3
|
+
import { JsonObject, ValidationError } from "../contracts/schema.js";
|
|
4
4
|
import type { Field } from "../../../app-data/src/contracts/database.js";
|
|
5
|
+
import type { FieldExposure } from "../contracts/provider.js";
|
|
5
6
|
declare const StorageField: unique symbol;
|
|
6
7
|
declare const Decoder: unique symbol;
|
|
7
8
|
/** An author-facing value schema. Effect is never required in author code. */
|
|
@@ -59,6 +60,44 @@ export declare function literal<const T extends string | number | boolean | null
|
|
|
59
60
|
export declare const array: <T>(item: Schema<T, boolean>) => Schema<readonly T[]>;
|
|
60
61
|
/** Parse declared fields and omit undeclared fields. */
|
|
61
62
|
export declare function object<const F extends Fields>(fields: F): ObjectSchema<F>;
|
|
63
|
+
declare const Exposure: unique symbol;
|
|
64
|
+
/** A schema marked with how app code sees the field in a provider that declares hosts. */
|
|
65
|
+
export type Exposed<S, E extends FieldExposure = FieldExposure> = S & {
|
|
66
|
+
readonly [Exposure]: E;
|
|
67
|
+
};
|
|
68
|
+
/** The marking of one account field, if any. */
|
|
69
|
+
export declare const exposureOf: (schema: Schema<unknown, boolean>) => FieldExposure | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* A field that is not secret, such as a subdomain or region. App code reads its real value and
|
|
72
|
+
* the connect form shows it.
|
|
73
|
+
*/
|
|
74
|
+
export declare const plain: <S extends Schema<unknown, boolean>>(schema: S) => Exposed<S, "plain">;
|
|
75
|
+
/**
|
|
76
|
+
* A secret field that app code reads as its real value, for request signing and similar uses.
|
|
77
|
+
* The connect form warns that the app can read it. Prefer an unmarked field, which app code
|
|
78
|
+
* receives as a handle that only reaches the provider's declared hosts.
|
|
79
|
+
*/
|
|
80
|
+
export declare const raw: <S extends Schema<unknown, boolean>>(schema: S) => Exposed<S, "raw">;
|
|
81
|
+
/** Marked fields of an account object, by name. */
|
|
82
|
+
export declare const fieldExposure: (fields: Fields) => Readonly<Record<string, FieldExposure>>;
|
|
83
|
+
declare const Secret: unique symbol;
|
|
84
|
+
/**
|
|
85
|
+
* A secret account value. In a provider that declares hosts it is a handle, which the host's
|
|
86
|
+
* outbound network replaces with the real value only on requests to those hosts. Pass it to
|
|
87
|
+
* clients and headers as an ordinary string; do not decode or transform it.
|
|
88
|
+
*/
|
|
89
|
+
export type SecretString = string & {
|
|
90
|
+
readonly [Secret]: true;
|
|
91
|
+
};
|
|
92
|
+
type Sealed<T> = T extends string ? SecretString : T;
|
|
93
|
+
/** Account fields as app code receives them: unmarked string fields are secret. */
|
|
94
|
+
export type SecretFields<F extends Fields> = {
|
|
95
|
+
readonly [Key in keyof ObjectValue<F>]: Key extends keyof F ? F[Key] extends Exposed<unknown> ? ObjectValue<F>[Key] : Sealed<ObjectValue<F>[Key]> : ObjectValue<F>[Key];
|
|
96
|
+
};
|
|
97
|
+
/** An account object without declared fields, such as a default OAuth projection. */
|
|
98
|
+
export type SecretObject<T> = {
|
|
99
|
+
readonly [Key in keyof T]: Sealed<T[Key]>;
|
|
100
|
+
};
|
|
62
101
|
declare const ImportedJsonSchema: unique symbol;
|
|
63
102
|
/** Read the original document for an imported decoder without a lossy schema round trip. */
|
|
64
103
|
export declare const importedJsonSchema: (decoder: EffectSchema.Decoder<unknown>) => unknown | undefined;
|
|
@@ -81,6 +120,14 @@ export declare const compileJsonSchemaDecoder: (document: JsonObject) => Effect.
|
|
|
81
120
|
};
|
|
82
121
|
}, ValidationError, never>;
|
|
83
122
|
export declare const lazyJsonSchemaDecoder: (document: () => JsonObject) => Effect.Effect<EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json>, never, never>;
|
|
123
|
+
/**
|
|
124
|
+
* A lazy decoder and the compilation it decodes with. Running `compile` first lets a caller
|
|
125
|
+
* reject an unsupported schema before a side effect whose result the decoder will check.
|
|
126
|
+
*/
|
|
127
|
+
export declare const preparedJsonSchemaDecoder: (document: JsonObject) => {
|
|
128
|
+
decoder: EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json>;
|
|
129
|
+
compile: Effect.Effect<EffectSchema.Decoder<EffectSchema.Json, never>, ValidationError, never>;
|
|
130
|
+
};
|
|
84
131
|
/** Preserve the JSON document; compile its validator only when a value is first decoded. */
|
|
85
132
|
export declare const jsonSchemaDecoder: (input: unknown) => Effect.Effect<EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json>, ValidationError, never>;
|
|
86
133
|
/** Import JSON metadata now; unsupported schemas and invalid values fail when parsed. */
|
|
@@ -91,4 +138,8 @@ export declare const storageFieldOf: (schema: Schema<unknown, boolean>) => Field
|
|
|
91
138
|
export declare const id: (table: string) => Schema<string>;
|
|
92
139
|
/** A host user identifier, stored as a string without imposing a product auth model. */
|
|
93
140
|
export declare const userId: () => Schema<string>;
|
|
141
|
+
/** Render a decoder as a JSON Schema document, keeping an imported upstream document as-is. */
|
|
142
|
+
export declare const jsonSchemaDocument: (decoder: EffectSchema.Decoder<unknown>) => Effect.Effect<{
|
|
143
|
+
readonly [x: string]: EffectSchema.Json;
|
|
144
|
+
}, EffectSchema.SchemaError, never>;
|
|
94
145
|
export {};
|
|
@@ -13,8 +13,8 @@ export declare const reader: (transport: SkillTransport) => Effect.Effect<{
|
|
|
13
13
|
json: (url: string) => Effect.Effect<unknown, SkillLoadFailed, never>;
|
|
14
14
|
}, never, never>;
|
|
15
15
|
export declare const githubSkillsEffect: (options: GitHubSkillsOptions) => Effect.Effect<readonly {
|
|
16
|
-
readonly name: string;
|
|
17
16
|
readonly description: string;
|
|
17
|
+
readonly name: string;
|
|
18
18
|
readonly files: readonly {
|
|
19
19
|
readonly path: string;
|
|
20
20
|
readonly content: string;
|
|
@@ -28,8 +28,8 @@ export declare const githubSkillsEffect: (options: GitHubSkillsOptions) => Effec
|
|
|
28
28
|
}[], SkillLoadFailed, never>;
|
|
29
29
|
/** Fetch all indexed files and reject a publication whose index changes during the read. */
|
|
30
30
|
export declare const wellKnownSkillsEffect: (options: WellKnownSkillsOptions) => Effect.Effect<readonly {
|
|
31
|
-
readonly name: string;
|
|
32
31
|
readonly description: string;
|
|
32
|
+
readonly name: string;
|
|
33
33
|
readonly files: readonly {
|
|
34
34
|
readonly path: string;
|
|
35
35
|
readonly content: string;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { type DatabaseSession } from "../../../app-data/src/index.js";
|
|
1
|
+
import { type DatabaseSession, type reservedFieldNames } from "../../../app-data/src/index.js";
|
|
2
|
+
type ReservedFieldName = (typeof reservedFieldNames)[number];
|
|
2
3
|
import { type AppStorage } from "../contracts/storage.js";
|
|
3
4
|
import type { DatabaseDefinition, Database, Table, Tables } from "../contracts/storage.js";
|
|
4
5
|
import { type Fields } from "./schema.js";
|
|
5
6
|
export type { DatabaseDefinition, Database, DatabaseReader, Table, Tables, RowOf, } from "../contracts/storage.js";
|
|
6
|
-
/** Declare scalar columns using the same schemas as operation inputs.
|
|
7
|
-
|
|
7
|
+
/** Declare scalar columns using the same schemas as operation inputs. The host adds `id`,
|
|
8
|
+
* `createdAt` and `updatedAt` to every row, so tables cannot declare those names. */
|
|
9
|
+
export declare const table: <const F extends Fields & { readonly [K in ReservedFieldName]?: never; }>(fields: F) => Table<F>;
|
|
8
10
|
/** Build a fresh Promise database facade for one authorized invocation. */
|
|
9
11
|
export declare const authorDatabase: <T extends Tables>(tables: T, session: DatabaseSession, signal: AbortSignal, writable: boolean) => Database<T>;
|
|
10
12
|
/** Declare storage independently of handlers; the host binds each invocation's database. */
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Host-rendered account notices; no authored app code or provider responses enter them. */
|
|
2
|
+
import type { UiAccountNotice, UiAccountProblem } from "../contracts/ui.js";
|
|
3
|
+
/** Missing, removed, incompatible, or rejected accounts stop the app; other failed checks are advisory. */
|
|
4
|
+
export declare const accountProblemBlocks: (problem: UiAccountProblem) => boolean;
|
|
5
|
+
export declare const accountProblemText: (problem: UiAccountProblem) => string;
|
|
6
|
+
/** Full page shown instead of the app while an account problem stops it from working. */
|
|
7
|
+
export declare const accountBlockedPage: (notice: UiAccountNotice) => string;
|
|
8
|
+
/** Inline card for advisory problems; the app still loads underneath. */
|
|
9
|
+
export declare const accountNoticeBootstrap: (notice: UiAccountNotice) => string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Atom } from "effect/unstable/reactivity";
|
|
1
|
+
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
|
2
2
|
import { type OperationReference } from "../contracts/live.js";
|
|
3
3
|
import { type Schema } from "./schema.js";
|
|
4
4
|
/** A scoped page client. Host-injected context carries only the deployment, never credentials. */
|
|
@@ -12,5 +12,5 @@ export declare const createAppClient: () => {
|
|
|
12
12
|
/** Create a callable mutation with optional withOptimisticUpdate projections over mounted queries. */
|
|
13
13
|
mutation: <Input, Output>(reference: OperationReference<Input, Output, "mutation">, output: Schema<NoInfer<Output>, boolean>) => import("../client.js").AppMutation<Input, Output>;
|
|
14
14
|
/** Share a live query across mounts and reconcile optimistic changes against fresh server reads. */
|
|
15
|
-
queryAtom: <Input, Output>(reference: OperationReference<Input, Output, "query">, input: NoInfer<Input>, output: Schema<NoInfer<Output>, boolean>) => Atom.Atom<
|
|
15
|
+
queryAtom: <Input, Output>(reference: OperationReference<Input, Output, "query">, input: NoInfer<Input>, output: Schema<NoInfer<Output>, boolean>) => Atom.Atom<AsyncResult.AsyncResult<Output, unknown>>;
|
|
16
16
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retained files sit at the deployment's asset root. Resolving path-relative resource URLs there,
|
|
3
|
+
* instead of with `<base>`, leaves the document base as the page URL for links, history and forms.
|
|
4
|
+
*/
|
|
5
|
+
export declare const deploymentDocument: (html: string, deployment: string) => string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Inline host script: no app dependencies, credentials, or authored HTML enter its source. */
|
|
2
|
-
export declare const appFailureBootstrap:
|
|
2
|
+
export declare const appFailureBootstrap = "<script>\"use strict\";(()=>{var D=()=>{let d,w=Date.now(),m=0,g=0,f=new Map,A=/^(?:chrome|moz|safari-web)-extension:/,R=new Set([\"Error\",\"TypeError\",\"ReferenceError\",\"SyntaxError\",\"RangeError\",\"URIError\",\"EvalError\",\"AggregateError\"]),x=(e,t=0,i=0)=>{let r=[];if(!URL.canParse(e))return r;let a=new URL(e);return a.origin!==location.origin||!a.pathname.startsWith(\"/_executor/assets/\")||!a.pathname.endsWith(\".js\")||(r.push({key:\"code.file.path\",value:{stringValue:a.pathname}}),Number.isSafeInteger(t)&&t>0&&r.push({key:\"code.line.number\",value:{intValue:String(t)}}),Number.isSafeInteger(i)&&i>0&&r.push({key:\"code.column.number\",value:{intValue:String(i)}})),r},E=(e,t,i=[])=>{let r=Date.now();r-w>=6e4&&(w=r,m=0,f.clear());let a=`${e}:${t.slice(0,2e3)}`,b=f.get(a);if(b!==void 0&&r-b<1e3||m>=20){g++;return}f.set(a,r),m++,i.push({key:\"executor.ui.failure.suppressed\",value:{intValue:String(g)}}),g=0;let h=Array.from(crypto.getRandomValues(new Uint8Array(16)),s=>s.toString(16).padStart(2,\"0\")).join(\"\"),S=`${Date.now()}000000`,n,u=\"Sending error report\\u2026\",k=()=>{if(d?.open)return;let s=document.createElement(\"div\"),V=s.attachShadow({mode:\"open\"}),o=document.createElement(\"dialog\");d=o,o.setAttribute(\"aria-labelledby\",\"executor-failure-title\");let y=document.createElement(\"h2\");y.id=\"executor-failure-title\",y.textContent=e===\"script\"?\"This app could not load\":\"This app stopped working\";let C=document.createElement(\"p\");C.textContent=e===\"script\"?\"A file needed by this page did not load. Reload the page to try again.\":\"The app encountered an unexpected error. Reload the page to try again.\";let L=document.createElement(\"p\");L.textContent=\"Copy any unsaved work before reloading.\";let T=document.createElement(\"details\"),v=document.createElement(\"summary\");v.textContent=\"Error details\";let c=document.createElement(\"textarea\");c.readOnly=!0,c.rows=10,c.cols=36,c.setAttribute(\"aria-label\",\"Error details\"),c.value=`${t.slice(0,12e3)}\n\nDiagnostic ID: ${h}`,T.append(v,c),n=document.createElement(\"p\"),n.setAttribute(\"role\",\"status\"),n.textContent=u;let l=document.createElement(\"button\");l.type=\"button\",l.textContent=\"Reload page\",l.addEventListener(\"click\",()=>location.reload());let p=document.createElement(\"button\");p.type=\"button\",p.textContent=\"Close\",p.addEventListener(\"click\",()=>o.close()),o.addEventListener(\"close\",()=>{d===o&&(d=void 0),s.remove()}),o.append(y,C,L,T,n,l,p),V.append(o),document.documentElement.append(s),o.showModal()};document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",k,{once:!0}):k(),fetch(\"/_executor/api/telemetry/traces\",{method:\"POST\",headers:{\"content-type\":\"application/json\"},credentials:\"same-origin\",keepalive:!0,body:JSON.stringify({resourceSpans:[{scopeSpans:[{spans:[{traceId:h,spanId:h.slice(0,16),name:\"ui.app.failure\",kind:1,startTimeUnixNano:S,endTimeUnixNano:S,status:{code:2},attributes:[{key:\"executor.ui.failure.kind\",value:{stringValue:e}},...i]}]}]}]})}).then(s=>{u=s.ok?\"Error report sent.\":\"Could not send the error report. You can copy the error details.\",n&&(n.textContent=u)},()=>{u=\"Could not send the error report. You can copy the error details.\",n&&(n.textContent=u)})};window.addEventListener(\"error\",e=>{if(e instanceof ErrorEvent){if(A.test(e.filename))return;let t=x(e.filename,e.lineno,e.colno);e.error instanceof Error&&R.has(e.error.name)&&t.push({key:\"exception.type\",value:{stringValue:e.error.name}}),E(\"runtime\",e.error instanceof Error?e.error.stack??e.message:e.message,t)}else e.target instanceof HTMLScriptElement&&E(\"script\",`Could not load script: ${e.target.src}`,x(e.target.src))},!0),window.addEventListener(\"unhandledrejection\",e=>{let t=e.reason;E(\"rejection\",t instanceof Error?t.stack??t.message:\"An app operation failed without handling its error.\")})};D();})();</script>";
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
3
|
-
import { UiForbidden, type AppUiAsset } from "../contracts/ui.js";
|
|
4
|
-
/**
|
|
3
|
+
import { UiForbidden, type AppUiAsset, type UiAccountNotice } from "../contracts/ui.js";
|
|
4
|
+
/**
|
|
5
|
+
* Render an authorized deployment with a host-owned deployment watcher. Account problems that stop
|
|
6
|
+
* the app replace its document with a page that links to their fix; others add a dismissible card.
|
|
7
|
+
*/
|
|
5
8
|
export declare const appDocument: <E, R>(options: {
|
|
6
9
|
readonly deployment: string;
|
|
7
10
|
readonly profile?: string | undefined;
|
|
8
11
|
readonly expectedProfileRevision?: number | undefined;
|
|
9
12
|
readonly origin: string;
|
|
13
|
+
readonly accounts?: UiAccountNotice | undefined;
|
|
10
14
|
readonly asset: (path: string) => Effect.Effect<AppUiAsset | undefined, E, R>;
|
|
11
15
|
}) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiForbidden | E, HttpServerRequest.HttpServerRequest | R>;
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
16
|
+
/** Serve an asset only after the host has checked current access and file existence.
|
|
17
|
+
* Asset URLs name their deployment, so their bytes never change: the browser keeps them for a year
|
|
18
|
+
* and does not ask again. Shared proxies never store them. Revoking access stops every new request
|
|
19
|
+
* and all app data, while bytes a browser already downloaded stay in its cache.
|
|
14
20
|
* HTML remains an uncached host-rendered entry point.
|
|
15
21
|
*/
|
|
16
22
|
export declare const appAsset: (asset: AppUiAsset | undefined, build: string, path: string) => Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Dependency-free browser source served by each host after app authorization. */
|
|
2
|
-
export declare const appWatchScript
|
|
2
|
+
export declare const appWatchScript = "\"use strict\";(()=>{var s=()=>{let i=document.getElementById(\"executor-context\")?.textContent;if(!i)return;let n=JSON.parse(i);if(typeof n!=\"object\"||n===null||!(\"deployment\"in n))return;let r=n.deployment;if(typeof r!=\"string\"||r.length===0)return;let t=new EventSource(\"/_executor/version\"),l=!1,o=()=>{l||(l=!0,t.close(),location.reload())};t.addEventListener(\"version\",d=>{let e=JSON.parse(d.data);typeof e==\"object\"&&e!==null&&\"deployment\"in e&&(e.deployment===null||typeof e.deployment==\"string\")&&e.deployment!==r&&o()}),t.addEventListener(\"revoked\",o),window.addEventListener(\"executor:deployment-changed\",o),window.addEventListener(\"pagehide\",()=>t.close(),{once:!0}),window.addEventListener(\"pageshow\",d=>{d.persisted&&o()})};s();})();";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UpstreamError } from "../contracts/failure.js";
|
|
2
|
+
/** Whether `bounded` shortened this message, so it may end partway through a secret. */
|
|
3
|
+
export declare const isShortenedUpstream: (message: string) => boolean;
|
|
4
|
+
/** The error a JSON error body states, if it uses JSON-RPC's or OAuth's error format. */
|
|
5
|
+
export declare const bodyUpstreamError: (json: unknown) => UpstreamError | undefined;
|
|
6
|
+
/** The `error` and `error_description` of a Bearer challenge (RFC 6750, section 3). */
|
|
7
|
+
export declare const challengeUpstreamError: (header: string | undefined) => UpstreamError | undefined;
|
|
@@ -26,4 +26,4 @@ export declare const dispatchWebhook: <Context extends {
|
|
|
26
26
|
readonly [x: string]: string;
|
|
27
27
|
};
|
|
28
28
|
readonly body: string;
|
|
29
|
-
},
|
|
29
|
+
}, HostOperationNotFound | HostInputInvalid | HostOutputInvalid | HostDeclarationInvalid | HostOperationFailed, never>;
|
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
import type { AppDefinition } from "../contracts/app.js";
|
|
4
4
|
import { WorkflowFailure, type WorkflowContext, type WorkflowExecution, type WorkflowStepContext } from "../contracts/workflows.js";
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Preserve typed failures and cancellation. Other errors keep their name and bounded message,
|
|
7
|
+
* with the given account secrets replaced.
|
|
8
|
+
*/
|
|
9
|
+
export declare const workflowSafe: <A>(work: Effect.Effect<A, unknown>, secrets: readonly string[]) => Effect.Effect<A, WorkflowFailure>;
|
|
7
10
|
/** Construct one replay's Promise context. Step callbacks acquire fresh capabilities per actual attempt. */
|
|
8
|
-
export declare const makeWorkflowContext: (execution: WorkflowExecution, definition: Pick<AppDefinition<never>, "
|
|
11
|
+
export declare const makeWorkflowContext: (execution: WorkflowExecution, definition: Pick<AppDefinition<never>, "tools">,
|
|
12
|
+
/** A step attempt's context, and the raw account secrets its failures must not reveal. */
|
|
13
|
+
fresh: (stepId: string, signal: AbortSignal) => Effect.Effect<{
|
|
14
|
+
readonly context: WorkflowStepContext;
|
|
15
|
+
readonly secrets: readonly string[];
|
|
16
|
+
}, WorkflowFailure>, signal: AbortSignal) => Effect.Effect<WorkflowContext>;
|
|
@@ -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,32 +9,49 @@ 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 Fields, type Infer, type ObjectSchema, type Schema, type SecretFields, type SecretObject } from "./implementation/schema.js";
|
|
15
16
|
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 AccountOf, type AuthMethod, type AuthMethodData, type AuthMethods, type ManyAccounts, type
|
|
18
|
-
export { defineProvider } from "./implementation/provider.js";
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
17
|
+
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";
|
|
18
|
+
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";
|
|
19
|
+
export { defineProvider, type ProviderOptions } from "./implementation/provider.js";
|
|
20
|
+
export { accountRouter } from "./implementation/account-router.js";
|
|
21
|
+
export { router, dynamicRouter, withApprovals, type RouterDeclaration, type RouterChild, type RouterOptions, } from "./implementation/router.js";
|
|
22
|
+
export type { RouterIcon } from "./contracts/router.js";
|
|
21
23
|
export { dynamicSkills } from "./implementation/dynamic-skills.js";
|
|
22
24
|
export type { HostedTool as OperationDescription } from "./contracts/host.js";
|
|
25
|
+
/** Account fields as app code receives them from a method declared with this schema. */
|
|
26
|
+
type AccountFields<S> = S extends ObjectSchema<infer F> ? SecretFields<F> : SecretObject<Infer<S>>;
|
|
23
27
|
/** A secrets declaration inferred from an author schema. */
|
|
24
|
-
export type SecretsMethod<Shape extends ObjectSchema<Fields>> = NativeSecretsMethod<EffectSchema.Decoder<
|
|
28
|
+
export type SecretsMethod<Shape extends ObjectSchema<Fields>> = NativeSecretsMethod<EffectSchema.Decoder<AccountFields<Shape>>>;
|
|
25
29
|
/** An OAuth declaration inferred from its author-facing response schema. */
|
|
26
|
-
export type OAuth2Method<Response extends Schema<unknown, boolean>> = NativeOAuth2Method<EffectSchema.Decoder<
|
|
30
|
+
export type OAuth2Method<Response extends Schema<unknown, boolean>> = NativeOAuth2Method<EffectSchema.Decoder<AccountFields<Response>>>;
|
|
27
31
|
/** Default OAuth fields visible to app code. Host-only grants and clients stay private. */
|
|
28
32
|
export declare const OAuth2AccessToken: Schema<{
|
|
29
33
|
readonly access_token: string;
|
|
30
34
|
}, false>;
|
|
35
|
+
/**
|
|
36
|
+
* OAuth options as authors write them. `authorizationParams` naming a host-owned protocol
|
|
37
|
+
* parameter such as `state` or `scope` is a type error as well as a declaration failure.
|
|
38
|
+
*/
|
|
39
|
+
export type OAuth2Config = WithoutReservedParams<NativeOAuth2Config>;
|
|
40
|
+
type WithoutReservedParams<Config> = Config extends unknown ? "authorizationParams" extends keyof Config ? Config & {
|
|
41
|
+
readonly authorizationParams?: {
|
|
42
|
+
readonly [Key in ReservedAuthorizationParam]?: never;
|
|
43
|
+
};
|
|
44
|
+
} : Config : never;
|
|
31
45
|
/** Declare a secrets method without requiring an Effect schema from the author. */
|
|
32
46
|
export declare const secrets: <const F extends Fields>(options: {
|
|
33
47
|
readonly label: string;
|
|
34
48
|
readonly fields: ObjectSchema<F>;
|
|
35
49
|
}) => SecretsMethod<ObjectSchema<F>>;
|
|
36
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Declare OAuth discovery/endpoints and an optional app-visible response projection.
|
|
52
|
+
* `authorizationParams` adds service-defined sign-in parameters; a declared `authorizationUrl`
|
|
53
|
+
* keeps its own query. Neither can set host-owned parameters, and each parameter appears once.
|
|
54
|
+
*/
|
|
37
55
|
export declare function oauth2(options: OAuth2Config): OAuth2Method<typeof OAuth2AccessToken>;
|
|
38
56
|
export declare function oauth2<Response extends Schema<unknown, boolean>>(options: OAuth2Config & {
|
|
39
57
|
readonly response: Response;
|
|
@@ -57,7 +75,7 @@ export { NotImplemented } from "./contracts/app.js";
|
|
|
57
75
|
export { ElicitationFailed, type FormElicitation, type ElicitationResponse, type Elicit, } from "./contracts/elicitation.js";
|
|
58
76
|
export { table, defineDatabase, type Table, type DatabaseReader, type Database, type DatabaseDefinition, } from "./implementation/storage.js";
|
|
59
77
|
export { id, userId } from "./implementation/schema.js";
|
|
60
|
-
export { query, mutation, withApproval, type Operation, type OperationOptions, } from "./implementation/operations.js";
|
|
78
|
+
export { query, mutation, withApproval, toolAnnotations, type Operation, type OperationOptions, } from "./implementation/operations.js";
|
|
61
79
|
export type { OperationContext } from "./contracts/operations.js";
|
|
62
80
|
export { workflow, type Workflow, type WorkflowDeclaration } from "./implementation/workflows.js";
|
|
63
81
|
export { NonRetryableError, WorkflowFailure, type WorkflowContext, type WorkflowStepContext, type WorkflowStep, type WorkflowStepOptions, type WorkflowDuration, type WorkflowReads, type WorkflowControls, } from "./contracts/workflows.js";
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { ProcessConfig } from "./contracts/mcp.js";
|
|
2
2
|
import { type OperationKinds } from "./implementation/protocol-operations.js";
|
|
3
3
|
export { McpError, type McpToolContext, type ProcessConfig } from "./contracts/mcp.js";
|
|
4
|
-
/** Discover an account's tools; each discovery and call owns and closes its subprocess. */
|
|
5
|
-
export declare const
|
|
6
|
-
queries: Record<string, import("./index.js").Operation<import("effect/Schema").Json, unknown, "query", import("./index.js").OperationContext>>;
|
|
7
|
-
mutations: Record<string, import("./index.js").Operation<import("effect/Schema").Json, unknown, "mutation", import("./index.js").OperationContext>>;
|
|
8
|
-
}>;
|
|
4
|
+
/** Discover an account's tools as a router; each discovery and call owns and closes its subprocess. */
|
|
5
|
+
export declare const stdioRouter: (config: ProcessConfig, signal?: AbortSignal, kinds?: OperationKinds) => Promise<import("./index.js").RouterDeclaration<unknown, unknown>>;
|
package/types/apps/src/mcp.d.ts
CHANGED
|
@@ -1,10 +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";
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export { McpCredentialsUnverified, McpError, type McpHealthOptions, type McpToolContext, type McpToolsOptions, type McpToolResult, } from "./contracts/mcp.js";
|
|
8
|
+
/**
|
|
9
|
+
* A router over a server's tools for the selected account. Its title, description and
|
|
10
|
+
* instructions come from the server. Kinds override uncertain upstream read-only hints.
|
|
11
|
+
*/
|
|
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>;
|
|
10
30
|
export type { OperationKinds } from "./implementation/protocol-operations.js";
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { type OperationKinds } from "./implementation/protocol-operations.js";
|
|
3
3
|
import type { OpenapiToolsOptions } from "./contracts/openapi.js";
|
|
4
4
|
export { OpenapiError, isOpenapiTextMedia, openapiBinaryResultSchema, OpenapiErrorResponse, type OpenapiToolsOptions, type OpenapiOperation, type CredentialBinding, OpenapiParameter, OpenapiRequestBody, openapiMediaKind, } from "./contracts/openapi.js";
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Discover a document's operations as a router for the selected account. Kinds override uncertain
|
|
7
|
+
* upstream read-only hints. Mount it under a key, or override its metadata with `router(...)`.
|
|
8
|
+
*/
|
|
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 {
|
|
12
|
+
export { liveOpenapiRouter, type OpenapiSourceOptions } from "./implementation/openapi-source.js";
|
|
@@ -5,8 +5,8 @@ export { SkillLoadFailed, SkillDefinitionInvalid, SkillServiceName, type SkillRe
|
|
|
5
5
|
* the catalog; without it, mutable refs resolve again on each call.
|
|
6
6
|
*/
|
|
7
7
|
export declare const githubSkills: (options: GitHubSkillsOptions) => Promise<readonly {
|
|
8
|
-
readonly name: string;
|
|
9
8
|
readonly description: string;
|
|
9
|
+
readonly name: string;
|
|
10
10
|
readonly files: readonly {
|
|
11
11
|
readonly path: string;
|
|
12
12
|
readonly content: string;
|
|
@@ -20,8 +20,8 @@ export declare const githubSkills: (options: GitHubSkillsOptions) => Promise<rea
|
|
|
20
20
|
}[]>;
|
|
21
21
|
/** Fetch a published skill index and its text files. Pass `cache: ctx.cache` to reuse the catalog. */
|
|
22
22
|
export declare const wellKnownSkills: (options: WellKnownSkillsOptions) => Promise<readonly {
|
|
23
|
-
readonly name: string;
|
|
24
23
|
readonly description: string;
|
|
24
|
+
readonly name: string;
|
|
25
25
|
readonly files: readonly {
|
|
26
26
|
readonly path: string;
|
|
27
27
|
readonly content: string;
|
|
@@ -35,8 +35,8 @@ export declare const wellKnownSkills: (options: WellKnownSkillsOptions) => Promi
|
|
|
35
35
|
}[]>;
|
|
36
36
|
/** Parse a bundled standard skill directory into an app capability. */
|
|
37
37
|
export declare const fileSkill: (files: readonly SkillFile[]) => Promise<{
|
|
38
|
-
readonly name: string;
|
|
39
38
|
readonly description: string;
|
|
39
|
+
readonly name: string;
|
|
40
40
|
readonly files: readonly {
|
|
41
41
|
readonly path: string;
|
|
42
42
|
readonly content: string;
|
|
@@ -50,8 +50,8 @@ export declare const fileSkill: (files: readonly SkillFile[]) => Promise<{
|
|
|
50
50
|
}>;
|
|
51
51
|
/** Read skill directories from ctx.files. Omitted path selects skills/; missing folders return []. */
|
|
52
52
|
export declare const folderSkills: (options: FolderSkillsOptions) => Promise<readonly {
|
|
53
|
-
readonly name: string;
|
|
54
53
|
readonly description: string;
|
|
54
|
+
readonly name: string;
|
|
55
55
|
readonly files: readonly {
|
|
56
56
|
readonly path: string;
|
|
57
57
|
readonly content: string;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/** Correlate transport and decoded outcomes without exporting response bodies or errors. */
|
|
2
2
|
import { Effect, Schema, Tracer } from "effect";
|
|
3
3
|
import { HttpClient, HttpClientError } from "effect/unstable/http";
|
|
4
|
-
/**
|
|
5
|
-
|
|
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
11
|
readonly error_type: Schema.Literals<readonly ["BrowserDecodeFailed", "BrowserTransportFailed", "BrowserOperationFailed"]>;
|
|
@@ -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?: {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Schema, type Cause } from "effect";
|
|
2
|
+
import "effect/unstable/httpapi";
|
|
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
|
+
type ErrorFields<Tag extends string, Fields extends Schema.Struct.Fields> = Omit<Schema.TaggedStruct<Tag, Fields & {
|
|
28
|
+
readonly message: typeof MessageField;
|
|
29
|
+
}>, "~type.make.in"> & {
|
|
30
|
+
readonly "~type.make.in": Schema.TaggedStruct<Tag, Fields>["~type.make.in"];
|
|
31
|
+
};
|
|
32
|
+
type ErrorClass<Tag extends string, Fields extends Schema.Struct.Fields> = Schema.Class<Schema.Struct.Type<Fields> & ApiError & {
|
|
33
|
+
readonly _tag: Tag;
|
|
34
|
+
}, ErrorFields<Tag, Fields>, ApiError>;
|
|
35
|
+
/** Define an error with no payload and a fixed message. Its tag is its public error code. */
|
|
36
|
+
declare function define<const Tag extends string>(definition: Header<Tag> & {
|
|
37
|
+
readonly message: string;
|
|
38
|
+
}): ErrorClass<Tag, {}>;
|
|
39
|
+
/** Define an error whose message can depend on its parsed fields. */
|
|
40
|
+
declare function define<const Tag extends string, const Fields extends Schema.Struct.Fields>(definition: Definition<Tag, Fields>): ErrorClass<Tag, Fields>;
|
|
41
|
+
/**
|
|
42
|
+
* Define the schema, constructor and API message of an expected error together. Errors that need
|
|
43
|
+
* a user-facing title and recovery use `UserFacingError`, which carries the same message field.
|
|
44
|
+
*/
|
|
45
|
+
export declare const ApiError: {
|
|
46
|
+
define: typeof define;
|
|
47
|
+
};
|
|
48
|
+
export {};
|
package/js/chunk-PYUYJRSK.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
decoderOf
|
|
3
|
-
} from "./chunk-WFSQXYUT.js";
|
|
4
|
-
import {
|
|
5
|
-
Effect_exports
|
|
6
|
-
} from "./chunk-FW5HBOIK.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
|
-
};
|