apps 0.0.1-beta.9 → 0.0.1-beta.91
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 +56 -38
- package/framework-reference.json +1 -1
- package/js/chunk-3LEVTFD4.js +712 -0
- package/js/chunk-5FHWNLCI.js +88 -0
- package/js/{chunk-FL2QR3XW.js → chunk-5MDA7MKL.js} +338 -73
- package/js/chunk-6XQLA5NC.js +5047 -0
- package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
- package/js/chunk-7PHHWYV4.js +335 -0
- package/js/chunk-DADXWWRZ.js +449 -0
- package/js/{chunk-27F7W2LG.js → chunk-DDHBUKXX.js} +18 -2
- package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
- package/js/{chunk-5T57N25Q.js → chunk-GQ33QSNB.js} +583 -69
- package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
- package/js/chunk-I5C7FD5Z.js +171 -0
- package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
- package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
- package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
- package/js/{chunk-RFVIONFX.js → chunk-KUCCHNVY.js} +123 -44
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
- package/js/{chunk-72JNVHPK.js → chunk-PYQLOLOC.js} +4 -3
- package/js/{chunk-ODEIDRGW.js → chunk-QWQM3CLH.js} +795 -176
- package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
- package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
- package/js/chunk-XPRZTLHD.js +1915 -0
- package/js/chunk-YNJ5CZMJ.js +93 -0
- package/js/chunk-YRGL4QEF.js +49 -0
- package/js/{chunk-Z5M2LQOZ.js → chunk-YWFUWTUJ.js} +113 -58
- package/js/client.js +142 -78
- package/js/contracts.js +142 -21
- package/js/effect.js +18 -19
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +49 -40
- package/js/host.js +85 -62
- package/js/index.js +165 -70
- package/js/mcp/effect.js +21 -21
- package/js/mcp.js +76 -56
- package/js/openapi.js +4189 -1411
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +208 -81
- package/js/storage/facet.js +1 -540
- 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 +8605 -225
- package/package.json +3 -8
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +18 -0
- package/types/app-cache/src/index.d.ts +34 -2
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +60 -11
- package/types/apps/src/contracts/cache.d.ts +20 -0
- package/types/apps/src/contracts/context.d.ts +60 -17
- package/types/apps/src/contracts/elicitation.d.ts +23 -7
- package/types/apps/src/contracts/events.d.ts +94 -0
- package/types/apps/src/contracts/failure.d.ts +30 -1
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +1446 -17
- package/types/apps/src/contracts/icons.d.ts +28 -0
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +81 -20
- package/types/apps/src/contracts/network.d.ts +120 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
- package/types/apps/src/contracts/openapi.d.ts +41 -9
- package/types/apps/src/contracts/operations.d.ts +14 -7
- package/types/apps/src/contracts/placement.d.ts +102 -0
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +733 -81
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/11.d.ts +1149 -0
- package/types/apps/src/contracts/protocols/12.d.ts +3310 -0
- package/types/apps/src/contracts/protocols/2.d.ts +69 -26
- package/types/apps/src/contracts/protocols/3.d.ts +133 -33
- package/types/apps/src/contracts/protocols/4.d.ts +122 -45
- package/types/apps/src/contracts/protocols/5.d.ts +157 -47
- package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
- package/types/apps/src/contracts/protocols/current.d.ts +6669 -0
- package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +90 -6
- package/types/apps/src/contracts/schedules.d.ts +7 -1
- package/types/apps/src/contracts/schema.d.ts +21 -0
- package/types/apps/src/contracts/skills.d.ts +50 -13
- package/types/apps/src/contracts/sql.d.ts +63 -0
- package/types/apps/src/contracts/ui.d.ts +44 -14
- package/types/apps/src/contracts/webhooks.d.ts +24 -7
- package/types/apps/src/contracts/workflows.d.ts +19 -17
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/host.d.ts +5 -0
- package/types/apps/src/implementation/account-router.d.ts +4 -3
- package/types/apps/src/implementation/app.d.ts +41 -14
- package/types/apps/src/implementation/authoring.d.ts +25 -5
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/cache.d.ts +29 -2
- package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
- package/types/apps/src/implementation/elicitation.d.ts +18 -15
- package/types/apps/src/implementation/events.d.ts +64 -0
- package/types/apps/src/implementation/failure-detail.d.ts +28 -5
- package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/input-problems.d.ts +6 -2
- package/types/apps/src/implementation/invocation-timing.d.ts +18 -0
- package/types/apps/src/implementation/live.d.ts +2 -2
- package/types/apps/src/implementation/mcp-call.d.ts +6 -5
- package/types/apps/src/implementation/mcp-catalog.d.ts +6 -4
- package/types/apps/src/implementation/mcp-client.d.ts +17 -9
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +20 -9
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +28 -7
- package/types/apps/src/implementation/openapi-document.d.ts +46 -19
- 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 +23 -1
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +57 -7
- package/types/apps/src/implementation/optimistic.d.ts +1 -1
- package/types/apps/src/implementation/placement.d.ts +60 -0
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +19 -4
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +20 -18
- package/types/apps/src/implementation/router.d.ts +24 -5
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schedules.d.ts +39 -8
- package/types/apps/src/implementation/schema.d.ts +98 -11
- package/types/apps/src/implementation/skills.d.ts +18 -24
- package/types/apps/src/implementation/sql.d.ts +71 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +1 -1
- 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 +26 -9
- 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 +15 -6
- package/types/apps/src/implementation/workflow-context.d.ts +6 -2
- package/types/apps/src/implementation/workflows.d.ts +11 -4
- package/types/apps/src/index.d.ts +68 -19
- package/types/apps/src/mcp.d.ts +20 -1
- package/types/apps/src/openapi.d.ts +6 -1
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +10 -8
- package/types/apps/src/ui-serving.d.ts +1 -1
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +2 -2
- package/types/telemetry/src/browser.d.ts +8 -3
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/index.d.ts +2 -1
- package/types/telemetry/src/layer.d.ts +10 -4
- package/types/telemetry/src/measurements.d.ts +1 -1
- package/types/telemetry/src/ownership.d.ts +60 -0
- package/types/telemetry/src/recorded-failure.d.ts +29 -0
- package/types/telemetry/src/relay.d.ts +16 -6
- package/types/telemetry/src/span-attributes.d.ts +17 -1
- package/types/telemetry/src/transport.d.ts +8 -1
- package/types/utils/src/api-error.d.ts +55 -0
- package/types/utils/src/connection-failure.d.ts +33 -0
- package/types/utils/src/recorded-message.d.ts +18 -0
- package/types/utils/src/user-facing-error.d.ts +83 -0
- package/js/chunk-7EK2JDX4.js +0 -299
- package/js/chunk-IKS2C5MQ.js +0 -224
- package/js/chunk-MKWZPDR6.js +0 -63
- package/js/chunk-N7YDVXYJ.js +0 -186
- package/js/chunk-NKLWZJLE.js +0 -172
- package/js/chunk-PJJ24GU7.js +0 -877
- package/js/chunk-PZB6T6KU.js +0 -19
- package/js/chunk-R3EV5FTO.js +0 -97
- package/js/chunk-SJFZCGXG.js +0 -1243
- package/js/chunk-WLE7WX2U.js +0 -2645
- package/js/chunk-YXQHV65J.js +0 -242
- package/js/chunk-ZQINWV4W.js +0 -630
- package/js/mcp/stdio.js +0 -128
- package/types/app-data/src/implementation/cursor.d.ts +0 -10
- package/types/app-data/src/implementation/index-key.d.ts +0 -7
- package/types/app-data/src/implementation/promise.d.ts +0 -68
- package/types/app-data/src/implementation/range.d.ts +0 -8
- package/types/app-data/src/implementation/schema.d.ts +0 -18
- package/types/app-data/src/implementation/sqlite.d.ts +0 -11
- package/types/app-data/src/index.d.ts +0 -4
- package/types/apps/src/contracts/storage.d.ts +0 -68
- package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
- package/types/apps/src/implementation/storage.d.ts +0 -15
- package/types/apps/src/mcp-stdio.d.ts +0 -5
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App-owned SQLite. An app with migrations in `migrations/` reads and writes its own database with
|
|
3
|
+
* plain SQL. The author API mirrors Cloudflare's `SqlStorage`, so tools built for Durable Object
|
|
4
|
+
* SQLite fit it.
|
|
5
|
+
*/
|
|
6
|
+
/** A value SQLite stores or returns. */
|
|
7
|
+
export type SqlValue = string | number | null | ArrayBuffer;
|
|
8
|
+
/** One result row, keyed by column name. */
|
|
9
|
+
export type SqlRow = Record<string, SqlValue>;
|
|
10
|
+
/** The rows of one statement, already read, and what the statement read and wrote. */
|
|
11
|
+
export interface SqlCursor<Row extends SqlRow = SqlRow> extends Iterable<Row> {
|
|
12
|
+
readonly columnNames: readonly string[];
|
|
13
|
+
readonly rowsRead: number;
|
|
14
|
+
readonly rowsWritten: number;
|
|
15
|
+
toArray(): Row[];
|
|
16
|
+
/** The only row. Throws unless the statement returned exactly one. */
|
|
17
|
+
one(): Row;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Read-only SQL. Query tools receive this. A query runs in a transaction that is always rolled
|
|
21
|
+
* back, so nothing it changes commits; one that changes rows fails.
|
|
22
|
+
*/
|
|
23
|
+
export interface SqlReader {
|
|
24
|
+
exec<Row extends SqlRow = SqlRow>(query: string, ...bindings: SqlValue[]): SqlCursor<Row>;
|
|
25
|
+
}
|
|
26
|
+
/** SQL inside one transaction. */
|
|
27
|
+
export type SqlTransaction = SqlReader;
|
|
28
|
+
/**
|
|
29
|
+
* Writable SQL. Outside a transaction every statement commits on its own. `transaction` runs its
|
|
30
|
+
* callback synchronously in one SQLite transaction, so no transaction can stay open while the app
|
|
31
|
+
* waits on anything else; throwing rolls it back. Apps call outside services between transactions.
|
|
32
|
+
*/
|
|
33
|
+
export interface Sql extends SqlReader {
|
|
34
|
+
transaction<T>(work: (tx: SqlTransaction) => Synchronous<T>): T;
|
|
35
|
+
}
|
|
36
|
+
/** A transaction callback's result: a Promise means the callback awaited, which is refused. */
|
|
37
|
+
export type Synchronous<T> = T extends PromiseLike<unknown> ? never : T;
|
|
38
|
+
/** The Durable Object storage a data facet hands its app. App code never receives it. */
|
|
39
|
+
export interface AppSqlStorage {
|
|
40
|
+
readonly sql: {
|
|
41
|
+
exec(query: string, ...bindings: SqlValue[]): {
|
|
42
|
+
readonly columnNames: string[];
|
|
43
|
+
readonly rowsRead: number;
|
|
44
|
+
readonly rowsWritten: number;
|
|
45
|
+
toArray(): Record<string, SqlValue>[];
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
transactionSync<T>(work: () => T): T;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Tables Executor keeps in an app's database: applied migrations, workflow step receipts, and
|
|
52
|
+
* `_executor_legacy_rows (table_name, id, body)`, the rows of the document API apps used before
|
|
53
|
+
* SQL, with JSON bodies (empty for apps that never stored any). Apps should only read them; a
|
|
54
|
+
* changed migration history fails the next deploy.
|
|
55
|
+
*/
|
|
56
|
+
export declare const reservedTablePrefix = "_executor_";
|
|
57
|
+
/** Where an app keeps its migrations: `0001_create_notes.sql`, applied in number order. */
|
|
58
|
+
export declare const migrationsDirectory = "migrations";
|
|
59
|
+
/**
|
|
60
|
+
* The most values one statement may bind. Durable Object SQLite sets `SQLITE_LIMIT_VARIABLE_NUMBER`
|
|
61
|
+
* to 100 on every host; `ctx.sql` checks it first so the error names the limit.
|
|
62
|
+
*/
|
|
63
|
+
export declare const sqlBindingsLimit = 100;
|
|
@@ -1,24 +1,57 @@
|
|
|
1
1
|
/** Browser-to-host operations bind identity and authentication outside authored app code. */
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/
|
|
4
|
-
/**
|
|
2
|
+
import { Schema, type Effect, type Stream } from "effect";
|
|
3
|
+
import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
|
|
4
|
+
/**
|
|
5
|
+
* Non-secret page context injected by the serving host. `accounts` names the account IDs the page
|
|
6
|
+
* runs with, by requirement, when the app has requirements.
|
|
7
|
+
*/
|
|
5
8
|
export declare const UiContext: Schema.Struct<{
|
|
6
9
|
readonly deployment: Schema.NonEmptyString;
|
|
7
|
-
readonly
|
|
8
|
-
readonly expectedProfileRevision: Schema.optional<Schema.Int>;
|
|
10
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
9
11
|
}>;
|
|
12
|
+
/** A problem with one of the page's accounts, from stored state. Labels are the owner's own names. */
|
|
13
|
+
export type UiAccountProblem = {
|
|
14
|
+
readonly provider: string;
|
|
15
|
+
readonly reason: "missing" | "removed" | "incompatible";
|
|
16
|
+
} | {
|
|
17
|
+
readonly provider: string;
|
|
18
|
+
readonly account: string;
|
|
19
|
+
readonly reason: "credentials_rejected" | "forbidden" | "upstream_unavailable" | "check_failed";
|
|
20
|
+
};
|
|
21
|
+
/** Account problems found when the page opened, with dashboard links that resolve them. */
|
|
22
|
+
export interface UiAccountNotice {
|
|
23
|
+
readonly app: string;
|
|
24
|
+
readonly problems: readonly UiAccountProblem[];
|
|
25
|
+
/** The app's accounts in the dashboard. */
|
|
26
|
+
readonly fix: string;
|
|
27
|
+
}
|
|
10
28
|
/** Retained browser bytes. Hosts authorize access before reading or rendering them. */
|
|
11
|
-
export interface
|
|
29
|
+
export interface AppUiFile {
|
|
12
30
|
readonly body: Uint8Array;
|
|
13
31
|
readonly contentType: string;
|
|
14
32
|
}
|
|
33
|
+
/** One byte range of a stored file, already within its size. */
|
|
34
|
+
export interface AppUiRange {
|
|
35
|
+
readonly offset: number;
|
|
36
|
+
readonly length: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A public file the deployment's source served from `ui/public/`, which the host copied to its
|
|
40
|
+
* own store. `etag` names its exact bytes. Hosts authorize access before reading it.
|
|
41
|
+
*/
|
|
42
|
+
export interface AppUiStoredFile {
|
|
43
|
+
readonly contentType: string;
|
|
44
|
+
readonly size: number;
|
|
45
|
+
readonly etag: string;
|
|
46
|
+
readonly read: (range: AppUiRange | undefined) => Effect.Effect<Stream.Stream<Uint8Array, UiFailed>, UiFailed>;
|
|
47
|
+
}
|
|
48
|
+
export type AppUiAsset = AppUiFile | AppUiStoredFile;
|
|
15
49
|
/** Requests name an operation on this app and the page's deployment, never another app or account. */
|
|
16
50
|
export declare const UiOperation: Schema.Struct<{
|
|
17
51
|
readonly name: Schema.NonEmptyString;
|
|
18
52
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
19
53
|
readonly deployment: Schema.NonEmptyString;
|
|
20
|
-
readonly
|
|
21
|
-
readonly expectedProfileRevision: Schema.optional<Schema.Int>;
|
|
54
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
22
55
|
}>;
|
|
23
56
|
declare const UiUnauthorized_base: Schema.Class<UiUnauthorized, Schema.TaggedStruct<"UiUnauthorized", {}>, import("effect/Cause").YieldableError>;
|
|
24
57
|
/** The app session is absent or its parent login was revoked. */
|
|
@@ -54,20 +87,17 @@ export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGro
|
|
|
54
87
|
readonly name: Schema.NonEmptyString;
|
|
55
88
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
56
89
|
readonly deployment: Schema.NonEmptyString;
|
|
57
|
-
readonly
|
|
58
|
-
readonly expectedProfileRevision: Schema.optional<Schema.Int>;
|
|
90
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
59
91
|
}>>, never, Schema.toCodecJson<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiDeploymentChanged | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"mutate", "POST", "/_executor/api/mutate", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
60
92
|
readonly name: Schema.NonEmptyString;
|
|
61
93
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
62
94
|
readonly deployment: Schema.NonEmptyString;
|
|
63
|
-
readonly
|
|
64
|
-
readonly expectedProfileRevision: Schema.optional<Schema.Int>;
|
|
95
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
65
96
|
}>>, never, Schema.toCodecJson<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiDeploymentChanged | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"subscribe", "POST", "/_executor/api/subscribe", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
66
97
|
readonly name: Schema.NonEmptyString;
|
|
67
98
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
68
99
|
readonly deployment: Schema.NonEmptyString;
|
|
69
|
-
readonly
|
|
70
|
-
readonly expectedProfileRevision: Schema.optional<Schema.Int>;
|
|
100
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
71
101
|
}>>, never, HttpApiSchema.StreamSse<HttpApiSchema.SseEventFromData<Schema.Union<readonly [Schema.Struct<{
|
|
72
102
|
readonly type: Schema.Literal<"snapshot">;
|
|
73
103
|
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
/** Account-bound webhook lifecycle. Register and unregister must be idempotent for subscriptionId. */
|
|
2
2
|
import type { Effect, Schema } from "effect";
|
|
3
3
|
import type { ManualWebhookSetup } from "./webhook-protocol.js";
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import type { AccountScope, BoundContext, ScopedSlots } from "./app.js";
|
|
5
|
+
/** What every webhook context provides; a context with `user` serves user-account webhooks. */
|
|
6
|
+
type HookContext = Pick<BoundContext<ScopedSlots, AccountScope>, "app" | "fetch" | "signal">;
|
|
7
|
+
/**
|
|
8
|
+
* The accounts of the webhook's scope. A context with `user` names a user requirement; one of the
|
|
9
|
+
* `"app"` scope, which has no `user`, an app requirement.
|
|
10
|
+
*/
|
|
11
|
+
type ScopeAccounts<Context extends HookContext> = Context extends {
|
|
12
|
+
readonly user: {
|
|
13
|
+
readonly accounts: infer Accounts;
|
|
14
|
+
};
|
|
15
|
+
} ? Accounts : Context["app"]["accounts"];
|
|
16
|
+
type SourceAccount<Context extends HookContext> = Context extends {
|
|
17
|
+
readonly user: unknown;
|
|
18
|
+
} ? {
|
|
19
|
+
readonly user: keyof ScopeAccounts<Context> & string;
|
|
20
|
+
} : {
|
|
21
|
+
readonly app: keyof ScopeAccounts<Context> & string;
|
|
22
|
+
};
|
|
23
|
+
type SelectedAccount<Context extends HookContext> = {
|
|
24
|
+
[Slot in keyof ScopeAccounts<Context>]: ScopeAccounts<Context>[Slot] extends readonly (infer Account)[] ? Account : ScopeAccounts<Context>[Slot];
|
|
25
|
+
}[keyof ScopeAccounts<Context>];
|
|
9
26
|
/**
|
|
10
27
|
* Registration, delivery and cleanup share the selected accounts.
|
|
11
28
|
* The host stores account IDs and parsed state, never credentials.
|
|
12
29
|
* Register runs when enabling a subscription, not on every app evaluation.
|
|
13
30
|
*/
|
|
14
|
-
interface WebhookLifecycle<Context extends
|
|
31
|
+
interface WebhookLifecycle<Context extends HookContext, Config extends Schema.Decoder<unknown>, State extends Schema.Decoder<unknown>, Error = unknown> {
|
|
15
32
|
readonly account: SourceAccount<Context>;
|
|
16
33
|
readonly config: Config;
|
|
17
34
|
readonly state: State;
|
|
@@ -43,7 +60,7 @@ interface WebhookLifecycle<Context extends Pick<BoundContext<AccountSlots>, "acc
|
|
|
43
60
|
}) => Effect.Effect<void, Error>;
|
|
44
61
|
}
|
|
45
62
|
/** Manual subscriptions collect the state schema in a private browser form instead of invoking provider APIs. */
|
|
46
|
-
export type Webhook<Context extends
|
|
63
|
+
export type Webhook<Context extends HookContext, Config extends Schema.Decoder<unknown>, State extends Schema.Decoder<unknown>, Error = unknown> = (WebhookLifecycle<Context, Config, State, Error> & {
|
|
47
64
|
readonly setup?: never;
|
|
48
65
|
}) | (Omit<WebhookLifecycle<Context, Config, State, Error>, "register" | "unregister"> & {
|
|
49
66
|
readonly setup: typeof ManualWebhookSetup.Type;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/** Portable workflow declarations, run views and durable execution capabilities. */
|
|
2
2
|
import { Schema, type Effect } from "effect";
|
|
3
|
+
import { RecordedMessage } from "../../../utils/src/recorded-message.js";
|
|
3
4
|
import { JsonValue } from "./schema.js";
|
|
4
5
|
import type { AppContext, AppRequirements, QueryContext, MutationContext } from "./context.js";
|
|
6
|
+
import type { AccountScope } from "./app.js";
|
|
5
7
|
import type { Operation } from "../implementation/operations.js";
|
|
6
8
|
import type { HostContext } from "./host.js";
|
|
7
9
|
/** Run identity is opaque and shared by author and SDK interfaces. */
|
|
@@ -49,6 +51,11 @@ declare const WorkflowFailure_base: Schema.Class<WorkflowFailure, Schema.TaggedS
|
|
|
49
51
|
}>, import("effect/Cause").YieldableError>;
|
|
50
52
|
/** Failures cross host boundaries as reason codes plus the app's own bounded error detail. */
|
|
51
53
|
export declare class WorkflowFailure extends WorkflowFailure_base {
|
|
54
|
+
/**
|
|
55
|
+
* The step name and error detail are the app's. Its run's owner reads them; telemetry records
|
|
56
|
+
* only the reason, however the failure was built or decoded.
|
|
57
|
+
*/
|
|
58
|
+
get [RecordedMessage](): string | undefined;
|
|
52
59
|
}
|
|
53
60
|
/** Explicitly stop retrying an authored step. Its message is reported like any step error. */
|
|
54
61
|
export declare class NonRetryableError extends Error {
|
|
@@ -67,7 +74,6 @@ export type HostedWorkflow = typeof HostedWorkflow.Type;
|
|
|
67
74
|
/** Results are available only on completed runs; failures carry a reason code and app error detail. */
|
|
68
75
|
export declare const WorkflowRun: Schema.Union<readonly [Schema.Struct<{
|
|
69
76
|
readonly status: Schema.Literals<readonly ["queued", "running", "waiting", "paused", "waitingForPause"]>;
|
|
70
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
71
77
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
72
78
|
readonly app: Schema.NonEmptyString;
|
|
73
79
|
readonly deployment: Schema.NonEmptyString;
|
|
@@ -76,7 +82,6 @@ export declare const WorkflowRun: Schema.Union<readonly [Schema.Struct<{
|
|
|
76
82
|
}>, Schema.Struct<{
|
|
77
83
|
readonly status: Schema.Literal<"complete">;
|
|
78
84
|
readonly output: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
79
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
80
85
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
81
86
|
readonly app: Schema.NonEmptyString;
|
|
82
87
|
readonly deployment: Schema.NonEmptyString;
|
|
@@ -91,7 +96,6 @@ export declare const WorkflowRun: Schema.Union<readonly [Schema.Struct<{
|
|
|
91
96
|
errorName: Schema.optionalKey<Schema.String>;
|
|
92
97
|
message: Schema.optionalKey<Schema.String>;
|
|
93
98
|
}>>;
|
|
94
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
95
99
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
96
100
|
readonly app: Schema.NonEmptyString;
|
|
97
101
|
readonly deployment: Schema.NonEmptyString;
|
|
@@ -99,7 +103,6 @@ export declare const WorkflowRun: Schema.Union<readonly [Schema.Struct<{
|
|
|
99
103
|
readonly createdAt: Schema.String;
|
|
100
104
|
}>, Schema.Struct<{
|
|
101
105
|
readonly status: Schema.Literal<"terminated">;
|
|
102
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
103
106
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
104
107
|
readonly app: Schema.NonEmptyString;
|
|
105
108
|
readonly deployment: Schema.NonEmptyString;
|
|
@@ -111,7 +114,6 @@ export type WorkflowRun = typeof WorkflowRun.Type;
|
|
|
111
114
|
export declare const WorkflowRunPage: Schema.Struct<{
|
|
112
115
|
readonly items: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
113
116
|
readonly status: Schema.Literals<readonly ["queued", "running", "waiting", "paused", "waitingForPause"]>;
|
|
114
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
115
117
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
116
118
|
readonly app: Schema.NonEmptyString;
|
|
117
119
|
readonly deployment: Schema.NonEmptyString;
|
|
@@ -120,7 +122,6 @@ export declare const WorkflowRunPage: Schema.Struct<{
|
|
|
120
122
|
}>, Schema.Struct<{
|
|
121
123
|
readonly status: Schema.Literal<"complete">;
|
|
122
124
|
readonly output: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
123
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
124
125
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
125
126
|
readonly app: Schema.NonEmptyString;
|
|
126
127
|
readonly deployment: Schema.NonEmptyString;
|
|
@@ -135,7 +136,6 @@ export declare const WorkflowRunPage: Schema.Struct<{
|
|
|
135
136
|
errorName: Schema.optionalKey<Schema.String>;
|
|
136
137
|
message: Schema.optionalKey<Schema.String>;
|
|
137
138
|
}>>;
|
|
138
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
139
139
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
140
140
|
readonly app: Schema.NonEmptyString;
|
|
141
141
|
readonly deployment: Schema.NonEmptyString;
|
|
@@ -143,7 +143,6 @@ export declare const WorkflowRunPage: Schema.Struct<{
|
|
|
143
143
|
readonly createdAt: Schema.String;
|
|
144
144
|
}>, Schema.Struct<{
|
|
145
145
|
readonly status: Schema.Literal<"terminated">;
|
|
146
|
-
readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
|
|
147
146
|
readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
|
|
148
147
|
readonly app: Schema.NonEmptyString;
|
|
149
148
|
readonly deployment: Schema.NonEmptyString;
|
|
@@ -175,25 +174,28 @@ export interface WorkflowControls extends WorkflowReads {
|
|
|
175
174
|
readonly run: string;
|
|
176
175
|
}) => Promise<WorkflowRun>;
|
|
177
176
|
}
|
|
178
|
-
/**
|
|
179
|
-
|
|
177
|
+
/**
|
|
178
|
+
* External steps get fresh credentials and cancellation, without storage or live elicitation. A run
|
|
179
|
+
* started by app-scope work, such as an app schedule, has the `"app"` scope: no `user`.
|
|
180
|
+
*/
|
|
181
|
+
export type WorkflowStepContext<Requirements extends AppRequirements = AppRequirements, Scope extends AccountScope = "user"> = Omit<AppContext<Requirements, Scope>, "elicit" | "workflows"> & {
|
|
180
182
|
readonly runId: WorkflowRunId;
|
|
181
183
|
readonly stepId: string;
|
|
182
184
|
readonly idempotencyKey: string;
|
|
183
185
|
};
|
|
184
186
|
/** Explicit durable boundaries; database access passes through registered app operations. */
|
|
185
|
-
export interface WorkflowStep<Requirements extends AppRequirements = AppRequirements> {
|
|
186
|
-
do<Output>(name: string, run: (context: WorkflowStepContext<Requirements>) => Promise<Output>): Promise<Output>;
|
|
187
|
-
do<Output>(name: string, options: WorkflowStepOptions, run: (context: WorkflowStepContext<Requirements>) => Promise<Output>): Promise<Output>;
|
|
188
|
-
runQuery<Input, Output>(name: string, operation: Operation<Input, Output, "query", QueryContext<Requirements>>, input: NoInfer<Input>, options?: WorkflowStepOptions): Promise<Output>;
|
|
189
|
-
runMutation<Input, Output>(name: string, operation: Operation<Input, Output, "mutation", MutationContext<Requirements>>, input: NoInfer<Input>, options?: WorkflowStepOptions): Promise<Output>;
|
|
187
|
+
export interface WorkflowStep<Requirements extends AppRequirements = AppRequirements, Scope extends AccountScope = "user"> {
|
|
188
|
+
do<Output>(name: string, run: (context: WorkflowStepContext<Requirements, Scope>) => Promise<Output>): Promise<Output>;
|
|
189
|
+
do<Output>(name: string, options: WorkflowStepOptions, run: (context: WorkflowStepContext<Requirements, Scope>) => Promise<Output>): Promise<Output>;
|
|
190
|
+
runQuery<Input, Output>(name: string, operation: Operation<Input, Output, "query", QueryContext<Requirements, Scope>>, input: NoInfer<Input>, options?: WorkflowStepOptions): Promise<Output>;
|
|
191
|
+
runMutation<Input, Output>(name: string, operation: Operation<Input, Output, "mutation", MutationContext<Requirements, Scope>>, input: NoInfer<Input>, options?: WorkflowStepOptions): Promise<Output>;
|
|
190
192
|
readonly sleep: (name: string, duration: WorkflowDuration) => Promise<void>;
|
|
191
193
|
readonly sleepUntil: (name: string, timestamp: number | Date) => Promise<void>;
|
|
192
194
|
}
|
|
193
195
|
/** The orchestration body gets no account, database or interactive capabilities. */
|
|
194
|
-
export interface WorkflowContext<Requirements extends AppRequirements = AppRequirements> {
|
|
196
|
+
export interface WorkflowContext<Requirements extends AppRequirements = AppRequirements, Scope extends AccountScope = "user"> {
|
|
195
197
|
readonly runId: WorkflowRunId;
|
|
196
|
-
readonly step: WorkflowStep<Requirements>;
|
|
198
|
+
readonly step: WorkflowStep<Requirements, Scope>;
|
|
197
199
|
}
|
|
198
200
|
/** Framework-owned native declaration; only the callback crosses the author Promise boundary. */
|
|
199
201
|
export interface AppWorkflow<Input = unknown, Output = unknown> {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare const facetStorage: (storage: NonNullable<Sqlite.SqliteClientConfig["storage"]>) => AppStorage;
|
|
1
|
+
/** The data facet's storage capability; used only by the generated data facet, never browser bundles. */
|
|
2
|
+
import type { AppSqlStorage } from "./contracts/sql.js";
|
|
3
|
+
/** Bind one facet's storage at the runtime edge. App code receives `ctx.sql` over it, never the storage. */
|
|
4
|
+
export declare const facetStorage: (storage: AppSqlStorage) => AppSqlStorage;
|
package/types/apps/src/host.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ export { isolatedCacheSession } from "./implementation/cache-session.js";
|
|
|
6
6
|
export declare const hostContext: (accounts: ResolvedAccountsInput, approval?: unknown) => HostContext;
|
|
7
7
|
/** Portable Promise handler. Invoke only after the host has authorized and resolved accounts. */
|
|
8
8
|
export declare const createAppHandler: (app: unknown) => ((request: Request, context: HostContext) => Promise<Response>);
|
|
9
|
+
/**
|
|
10
|
+
* The clock this framework's spans read, in nanoseconds. The runtime's bridge times the isolate's
|
|
11
|
+
* whole dispatch with it, so that time and the invocation's own timing share one clock.
|
|
12
|
+
*/
|
|
13
|
+
export declare const isolatedClock: () => bigint;
|
|
9
14
|
/** Isolates return bounded, telemetry beside the protocol result; no exporter secret enters app code. */
|
|
10
15
|
export declare const createIsolatedAppHandler: (app: unknown) => (request: Request, context: HostContext) => Promise<Response>;
|
|
11
16
|
/**
|
|
@@ -3,10 +3,11 @@ import { type RouterDeclaration } from "./router.js";
|
|
|
3
3
|
* Discover each selected account's router and combine matching names.
|
|
4
4
|
* Calls take { accountId, input }; each branch retains its account's input schema,
|
|
5
5
|
* credentials, approval and output validation. Empty selections expose no operations.
|
|
6
|
-
* Discovery is sequential and cancellation follows the caller's signal.
|
|
6
|
+
* Discovery is sequential and cancellation follows the caller's signal. `discover` may return the
|
|
7
|
+
* router or a Promise of it, and the combined router keeps its operations' handler contexts.
|
|
7
8
|
*/
|
|
8
9
|
export declare const accountRouter: <Account extends {
|
|
9
10
|
readonly id: string;
|
|
10
|
-
}>(accounts: readonly Account[], discover: (account: Account) => Promise<RouterDeclaration
|
|
11
|
+
}, Query = unknown, Mutation = unknown>(accounts: readonly Account[], discover: (account: Account) => RouterDeclaration<Query, Mutation> | Promise<RouterDeclaration<Query, Mutation>>, options: {
|
|
11
12
|
readonly signal: AbortSignal;
|
|
12
|
-
}) => Promise<RouterDeclaration
|
|
13
|
+
}) => Promise<RouterDeclaration<Query, Mutation>>;
|
|
@@ -1,41 +1,68 @@
|
|
|
1
1
|
import type { ScheduleDeclaration } from "./schedules.js";
|
|
2
|
-
import type { App as NativeApp, AppDefinition as NativeDefinition } from "../contracts/app.js";
|
|
3
|
-
import type { AppRequirements,
|
|
2
|
+
import type { App as NativeApp, AccountScope, AppDefinition as NativeDefinition, EvaluationContext } from "../contracts/app.js";
|
|
3
|
+
import type { AppRequirements, QueryContext, MutationContext, RequirementSlots, WebhookContext } from "../contracts/context.js";
|
|
4
4
|
import { type PromiseMethods } from "./authoring.js";
|
|
5
5
|
import { type WorkflowDeclaration } from "./workflows.js";
|
|
6
6
|
import type { WorkflowContext } from "../contracts/workflows.js";
|
|
7
7
|
import { type RouterDeclaration } from "./router.js";
|
|
8
8
|
import { type Schema } from "./schema.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
/** One native webhook definition with the given handler context. */
|
|
10
|
+
type NativeWebhook<Context> = NonNullable<NativeDefinition<Context>["webhooks"]>[string];
|
|
11
|
+
/** A webhook as authors write it: Promise handlers, author schemas and its source requirement. */
|
|
12
|
+
type AuthorWebhook<Context, Account> = {
|
|
13
|
+
readonly [Key in keyof NativeWebhook<Context>]: Key extends "config" | "state" ? Schema<unknown, boolean> : Key extends "account" ? Account : PromiseMethods<NativeWebhook<Context>>[Key];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A user-account webhook gets the caller-shaped context; an app-account webhook runs without a
|
|
17
|
+
* caller, so its context has no `user`.
|
|
18
|
+
*/
|
|
19
|
+
type AuthorWebhooks<Requirements extends AppRequirements> = Readonly<Record<string, AuthorWebhook<WebhookContext<Requirements>, {
|
|
20
|
+
readonly user: keyof RequirementSlots<Requirements>["user"] & string;
|
|
21
|
+
}> | AuthorWebhook<WebhookContext<Requirements, "app">, {
|
|
22
|
+
readonly app: keyof RequirementSlots<Requirements>["app"] & string;
|
|
23
|
+
}>>>;
|
|
24
|
+
/**
|
|
25
|
+
* User schedules run as each member who enables them; app schedules run without a caller, so their
|
|
26
|
+
* mutation takes a context of the `"app"` scope.
|
|
27
|
+
*/
|
|
28
|
+
type AuthorSchedules<Requirements extends AppRequirements> = Readonly<Record<string, ScheduleDeclaration<MutationContext<Requirements>, "user"> | ScheduleDeclaration<MutationContext<Requirements, "app">, "app">>>;
|
|
29
|
+
/**
|
|
30
|
+
* A run started by a caller binds its accounts; one started without a caller, such as by an app
|
|
31
|
+
* schedule, has no `user`, so its workflow declares a context of the `"app"` scope.
|
|
32
|
+
*/
|
|
33
|
+
type AuthorWorkflows<Requirements extends AppRequirements> = Readonly<Record<string, WorkflowDeclaration<WorkflowContext<Requirements>> | WorkflowDeclaration<WorkflowContext<Requirements, "app">>>>;
|
|
14
34
|
/** Author definition projected from native capabilities. Excluding callable objects keeps
|
|
15
35
|
* factories from being inferred as definitions and preserves contextual handler inference. */
|
|
16
36
|
export type AppDefinition<Requirements extends AppRequirements> = {
|
|
17
|
-
readonly [Key in keyof NativeDefinition<WebhookContext<Requirements>>]: Key extends "workflows" ?
|
|
37
|
+
readonly [Key in keyof NativeDefinition<WebhookContext<Requirements>>]: Key extends "workflows" ? AuthorWorkflows<Requirements> : Key extends "schedules" ? AuthorSchedules<Requirements> : Key extends "tools" ? RouterDeclaration<QueryContext<Requirements>, MutationContext<Requirements>> : Key extends "webhooks" ? AuthorWebhooks<Requirements> : NativeDefinition<WebhookContext<Requirements>>[Key];
|
|
18
38
|
} & {
|
|
19
39
|
readonly name?: never;
|
|
20
40
|
readonly queries?: never;
|
|
21
41
|
readonly mutations?: never;
|
|
22
42
|
readonly call?: never;
|
|
23
43
|
};
|
|
44
|
+
/** A webhook context as the host builds it: an app-account hook's has no `user`. */
|
|
45
|
+
type HostWebhookContext = WebhookContext<AppRequirements, AccountScope> & Partial<Pick<WebhookContext, "user">>;
|
|
24
46
|
/** Adapt operation and webhook catalogs without evaluating their handlers. */
|
|
25
47
|
export type EffectDefinition<Def> = {
|
|
26
|
-
readonly [Key in keyof Def]: Key extends "tools" ? NonNullable<NativeDefinition<unknown>["tools"]> : Key extends "workflows" ? Readonly<Record<string, import("../contracts/workflows.js").AppWorkflow>> : Key extends "schedules" ? NonNullable<NativeDefinition<unknown>["schedules"]> : Key extends "webhooks" ? NonNullable<NativeDefinition<
|
|
48
|
+
readonly [Key in keyof Def]: Key extends "tools" ? NonNullable<NativeDefinition<unknown>["tools"]> : Key extends "workflows" ? Readonly<Record<string, import("../contracts/workflows.js").AppWorkflow>> : Key extends "schedules" ? NonNullable<NativeDefinition<unknown>["schedules"]> : Key extends "webhooks" ? NonNullable<NativeDefinition<HostWebhookContext>["webhooks"]> : Key extends "skills" ? NonNullable<NativeDefinition<unknown>["skills"]> : Key extends "dynamicSkills" ? NonNullable<NativeDefinition<unknown>["dynamicSkills"]> : Def[Key];
|
|
27
49
|
};
|
|
28
50
|
declare const InternalApp: unique symbol;
|
|
29
51
|
/** Recognize a declaration from this framework instance before host adaptation. */
|
|
30
52
|
export declare const isApp: (value: unknown) => value is App<AppRequirements, AppDefinition<AppRequirements>>;
|
|
31
53
|
/** Public app handle; the native app is retained for host use without an async round trip. */
|
|
32
54
|
export interface App<Requirements extends AppRequirements, Def extends AppDefinition<Requirements>> {
|
|
33
|
-
readonly [InternalApp]: NativeApp<Requirements
|
|
34
|
-
readonly accounts: Requirements
|
|
35
|
-
readonly evaluate: (context:
|
|
55
|
+
readonly [InternalApp]: NativeApp<RequirementSlots<Requirements>, EffectDefinition<Def>>;
|
|
56
|
+
readonly accounts: RequirementSlots<Requirements>;
|
|
57
|
+
readonly evaluate: (context: AppFactoryContext<Requirements>) => Promise<Def>;
|
|
36
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* What a dynamic definition's factory receives. App-scope work, such as an app schedule, evaluates
|
|
61
|
+
* the app without a caller, so `user` is absent then.
|
|
62
|
+
*/
|
|
63
|
+
export type AppFactoryContext<Requirements extends AppRequirements> = EvaluationContext<RequirementSlots<Requirements>>;
|
|
37
64
|
/** Retrieve the same declaration for an Effect host. No evaluation or I/O occurs. */
|
|
38
|
-
export declare const toEffectApp: <Requirements extends AppRequirements, Def extends AppDefinition<Requirements>>(app: App<Requirements, Def>) => NativeApp<Requirements
|
|
65
|
+
export declare const toEffectApp: <Requirements extends AppRequirements, Def extends AppDefinition<Requirements>>(app: App<Requirements, Def>) => NativeApp<RequirementSlots<Requirements>, EffectDefinition<Def>>;
|
|
39
66
|
/** Assemble app behavior. Package names belong in package.json; hosts name installed copies. */
|
|
40
|
-
export declare const defineApp: <const Requirements extends AppRequirements, Def extends AppDefinition<Requirements>>(requirements: Requirements, definition: (Def & AppDefinition<Requirements>) | ((context:
|
|
67
|
+
export declare const defineApp: <const Requirements extends AppRequirements, Def extends AppDefinition<Requirements>>(requirements: Requirements, definition: (Def & AppDefinition<Requirements>) | ((context: AppFactoryContext<Requirements>) => Promise<Def & AppDefinition<Requirements>>)) => App<Requirements, Def>;
|
|
41
68
|
export {};
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
/** Small, explicit adapters between authored callbacks and native Effect operations. */
|
|
2
|
-
import { Effect } from "effect";
|
|
2
|
+
import { Effect, type Context } from "effect";
|
|
3
3
|
/** Project one Effect operation into its author-facing Promise signature. */
|
|
4
4
|
export type PromiseMethod<Method> = Method extends (...args: infer Args) => Effect.Effect<infer A, infer _E> ? (...args: Args) => Promise<A> : Method;
|
|
5
5
|
/** Project only an object's methods; data and schema types are not recursively rewritten. */
|
|
6
6
|
export type PromiseMethods<T> = {
|
|
7
7
|
readonly [Key in keyof T]: PromiseMethod<T[Key]>;
|
|
8
8
|
};
|
|
9
|
-
/**
|
|
10
|
-
export
|
|
11
|
-
/**
|
|
12
|
-
|
|
9
|
+
/** Which of the app's callbacks runs, recorded on the `app.code` span around it. */
|
|
10
|
+
export type AppCode = "factory" | "router" | "approval" | "handler" | "loader" | "cache" | "webhook" | "check" | "skills" | "elicitation" | "workflow" | "step";
|
|
11
|
+
/**
|
|
12
|
+
* Run `effect` as the app's own code. Its time is the app's, except for work it starts for
|
|
13
|
+
* Executor, an upstream or a person, which opens its own boundary inside.
|
|
14
|
+
*/
|
|
15
|
+
export declare const appCode: (code: AppCode) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, import("effect/Tracer").ParentSpan>>;
|
|
16
|
+
/**
|
|
17
|
+
* Reuse a framework callback's cancellation-bound Effect, or run an ordinary async callback as the
|
|
18
|
+
* app's code. Every callback an app supplies enters the framework here, so its time is the app's.
|
|
19
|
+
*/
|
|
20
|
+
export declare const fromPromise: <Args extends readonly unknown[], A>(callback: (...args: Args) => Promise<A>, code: AppCode) => ((...args: Args) => Effect.Effect<A, unknown>);
|
|
21
|
+
/**
|
|
22
|
+
* `target[key]`, called on `target`. A method read off its object as a bare value loses its
|
|
23
|
+
* receiver, so an app's method, such as one of its cache's, enters `fromPromise` through this.
|
|
24
|
+
*/
|
|
25
|
+
export declare const method: <K extends PropertyKey, T extends { readonly [P in K]: (...args: never) => unknown; }>(target: T, key: K) => T[K];
|
|
26
|
+
/**
|
|
27
|
+
* Bind cancellation once so Promise callers and native framework callers run the same operation.
|
|
28
|
+
* `signalOf` is the signal, or reads it from each call's arguments, such as a loader's `context.signal`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const toPromise: <Args extends readonly unknown[], A, E>(operation: (...args: Args) => Effect.Effect<A, E>, signalOf?: AbortSignal | ((...args: Args) => AbortSignal),
|
|
31
|
+
/** Services a Promise call runs with, such as its invocation's telemetry. */
|
|
32
|
+
services?: Context.Context<never>) => ((...args: Args) => Promise<A>);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Compiled from src/browser/app-watch.ts. */
|
|
2
|
+
export declare const appWatchSource = "\"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();})();";
|
|
3
|
+
/** Compiled from src/browser/app-failure.ts. */
|
|
4
|
+
export declare const appFailureSource = "\"use strict\";(()=>{var M=()=>{let d,w=Date.now(),m=0,g=0,f=new Map,v=/^(?:chrome|moz|safari-web)-extension:/,A=new Set([\"ResizeObserver loop completed with undelivered notifications.\",\"ResizeObserver loop limit exceeded\"]),V=new Set([\"Error\",\"TypeError\",\"ReferenceError\",\"SyntaxError\",\"RangeError\",\"URIError\",\"EvalError\",\"AggregateError\"]),b=(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},h=(e,t,i=[])=>{let r=Date.now();r-w>=6e4&&(w=r,m=0,f.clear());let a=`${e}:${t.slice(0,2e3)}`,x=f.get(a);if(x!==void 0&&r-x<1e3||m>=20){g++;return}f.set(a,r),m++,i.push({key:\"executor.ui.failure.suppressed\",value:{intValue:String(g)}}),g=0;let E=Array.from(crypto.getRandomValues(new Uint8Array(16)),s=>s.toString(16).padStart(2,\"0\")).join(\"\"),S=`${Date.now()}000000`,n,l=\"Sending error report\\u2026\",k=()=>{if(d?.open)return;let s=document.createElement(\"div\"),D=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 R=document.createElement(\"details\"),T=document.createElement(\"summary\");T.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: ${E}`,R.append(T,c),n=document.createElement(\"p\"),n.setAttribute(\"role\",\"status\"),n.textContent=l;let u=document.createElement(\"button\");u.type=\"button\",u.textContent=\"Reload page\",u.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,R,n,u,p),D.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:E,spanId:E.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=>{l=s.ok?\"Error report sent.\":\"Could not send the error report. You can copy the error details.\",n&&(n.textContent=l)},()=>{l=\"Could not send the error report. You can copy the error details.\",n&&(n.textContent=l)})};window.addEventListener(\"error\",e=>{if(e instanceof ErrorEvent){if(v.test(e.filename)||e.error===null&&e.lineno===0&&A.has(e.message))return;let t=b(e.filename,e.lineno,e.colno);e.error instanceof Error&&V.has(e.error.name)&&t.push({key:\"exception.type\",value:{stringValue:e.error.name}}),h(\"runtime\",e.error instanceof Error?e.error.stack??e.message:e.message,t)}else e.target instanceof HTMLScriptElement&&h(\"script\",`Could not load script: ${e.target.src}`,b(e.target.src))},!0),window.addEventListener(\"unhandledrejection\",e=>{let t=e.reason;h(\"rejection\",t instanceof Error?t.stack??t.message:\"An app operation failed without handling its error.\")})};M();})();";
|
|
5
|
+
/** Compiled from src/browser/account-notice.ts. */
|
|
6
|
+
export declare const accountNoticeSource = "\"use strict\";(()=>{var g=()=>{let r=document.getElementById(\"executor-account-notice\")?.textContent;if(!r)return;let t=JSON.parse(r);if(typeof t!=\"object\"||t===null||!(\"items\"in t)||!(\"fix\"in t))return;let c=t.items,s=t.fix;if(!Array.isArray(c)||typeof s!=\"string\")return;let a=()=>{let i=document.createElement(\"div\"),x=i.attachShadow({mode:\"open\"}),d=document.createElement(\"style\");d.textContent=\"aside{position:fixed;right:16px;bottom:16px;z-index:2147483647;max-width:360px;box-sizing:border-box;padding:14px 16px;border-radius:10px;border:1px solid #fcd34d;background:#fffbeb;color:#451a03;font:14px/1.45 ui-sans-serif,system-ui,sans-serif;box-shadow:0 8px 24px rgb(0 0 0/.12)}strong{display:block;margin-bottom:4px}ul{margin:0 0 10px;padding-left:18px}div{display:flex;gap:12px;align-items:center}a{color:inherit;font-weight:600}button{margin-left:auto;font:inherit;background:none;border:0;padding:0;color:inherit;text-decoration:underline;cursor:pointer}\";let e=document.createElement(\"aside\");e.setAttribute(\"role\",\"status\"),e.setAttribute(\"aria-label\",\"Account warning\");let l=document.createElement(\"strong\");l.textContent=\"Some things might not work\";let m=document.createElement(\"ul\");for(let f of c){let p=document.createElement(\"li\");p.textContent=String(f),m.append(p)}let u=document.createElement(\"div\"),n=document.createElement(\"a\");n.href=s,n.target=\"_top\",n.textContent=\"Review accounts\";let o=document.createElement(\"button\");o.type=\"button\",o.textContent=\"Dismiss\",o.addEventListener(\"click\",()=>i.remove()),u.append(n,o),e.append(l,m,u),x.append(d,e),document.documentElement.append(i)};document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",a,{once:!0}):a()};g();})();";
|
|
@@ -1,8 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
import type
|
|
1
|
+
/** Bind the portable Effect cache to an app invocation's author API. */
|
|
2
|
+
import { type Context } from "effect";
|
|
3
|
+
import type { AppCache, CacheGetOptions, HostCache } from "../contracts/cache.js";
|
|
4
|
+
import { type ResolvedAccounts } from "../contracts/host.js";
|
|
5
|
+
import type { JsonValue } from "../contracts/schema.js";
|
|
6
|
+
/**
|
|
7
|
+
* Framework-only: `get` that also reads other keys of the same scope in its round trip to the
|
|
8
|
+
* store. Authored code never sees it; framework helpers use it when a cache provides it.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getWithReads: unique symbol;
|
|
11
|
+
/**
|
|
12
|
+
* A `get` value, the store key it was read under, and the stored values of the other keys when
|
|
13
|
+
* the value was read from the store. The values are not decoded: the caller decodes only those it
|
|
14
|
+
* uses. A key with no value reads `undefined`.
|
|
15
|
+
*/
|
|
16
|
+
export interface GetWithReads<A> {
|
|
17
|
+
readonly value: A;
|
|
18
|
+
/** The entry's store key, unique to the cache's scope and the key. */
|
|
19
|
+
readonly key: string;
|
|
20
|
+
/** Undefined when the value was loaded or the store did not read them: read them separately. */
|
|
21
|
+
readonly reads: readonly unknown[] | undefined;
|
|
22
|
+
}
|
|
23
|
+
/** The framework-only `get` an app's cache provides beside the author API. */
|
|
24
|
+
export type CacheWithReads = AppCache & {
|
|
25
|
+
/** `keys` gets the entry's store key and names the other keys to read with it. */
|
|
26
|
+
readonly [getWithReads]?: <A>(options: CacheGetOptions<A>, keys: (key: string) => readonly JsonValue[]) => Promise<GetWithReads<A>>;
|
|
27
|
+
};
|
|
3
28
|
/** Missing host support is explicit on use; ordinary apps do not need cache support. */
|
|
4
29
|
export declare const unavailableCache: HostCache;
|
|
5
30
|
/** Account scopes are derived from trusted current bindings. Loaders get a fresh owned HTTP signal. */
|
|
6
31
|
export declare const authorCache: (host: HostCache, accounts: ResolvedAccounts, signal: AbortSignal,
|
|
32
|
+
/** The invocation's telemetry, which Promise calls from authored code run in. */
|
|
33
|
+
telemetry: Context.Context<never>,
|
|
7
34
|
/** The invocation's trusted deadline. Waiting on another caller's load never runs past it. */
|
|
8
35
|
deadline?: number) => AppCache;
|