apps 0.0.1-beta.1 → 0.0.1-beta.100
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 +112 -72
- package/framework-reference.json +1 -1
- package/js/browser-XIPJGLH2.js +65 -0
- package/js/chunk-2CURR5Y7.js +264 -0
- package/js/chunk-2LSGC7XY.js +42 -0
- package/js/{chunk-YEJOQEII.js → chunk-4PIQKACY.js} +65 -10
- package/js/chunk-4UPC36ZL.js +5185 -0
- package/js/{chunk-4LPG6RCH.js → chunk-4X2UI4R2.js} +7 -27
- package/js/chunk-5C6RAGAS.js +335 -0
- package/js/chunk-62NVUKED.js +39 -0
- package/js/chunk-74H25C4X.js +95 -0
- package/js/chunk-7HG422GB.js +90 -0
- package/js/chunk-7STIP5CS.js +171 -0
- package/js/{chunk-QKHR7BMF.js → chunk-ACQXVKVQ.js} +87 -51
- package/js/{chunk-OHRT55C4.js → chunk-DILSCQPJ.js} +226 -265
- package/js/chunk-ILYCJ3HV.js +449 -0
- package/js/chunk-K6TSCYAO.js +712 -0
- package/js/{chunk-EVJUVWN2.js → chunk-KLSEU35Y.js} +463 -218
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/chunk-OWN3DP2W.js +88 -0
- package/js/{chunk-ZTFQHGEB.js → chunk-PBGPES67.js} +3 -5
- package/js/chunk-QI66R4FP.js +786 -0
- package/js/chunk-RN4YB4JT.js +1922 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-URKOTNDA.js} +795 -177
- package/js/{chunk-NCYXZN2G.js → chunk-UVL56Z6E.js} +390 -23
- package/js/{chunk-2HHMABB6.js → chunk-VAI3EVCS.js} +700 -78
- package/js/chunk-VCYWAA4N.js +49 -0
- package/js/{chunk-HDJH3RPR.js → chunk-YDW7DX3A.js} +4 -4
- package/js/chunk-YWVISRZD.js +268 -0
- package/js/{chunk-FW5HBOIK.js → chunk-ZKDXML77.js} +19272 -18299
- package/js/client.js +148 -100
- package/js/contracts.js +208 -24
- package/js/effect.js +18 -19
- package/js/es-DIULA3ZF.js +39371 -0
- package/js/graphql.js +62 -58
- package/js/host.js +83 -60
- package/js/index.js +381 -263
- package/js/mcp/effect.js +21 -21
- package/js/mcp.js +117 -74
- package/js/openapi.js +4613 -42691
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -4
- package/js/skills.js +233 -70
- package/js/storage/facet.js +1 -540
- package/js/ui/auth/contracts.js +8 -9
- package/js/ui/auth.js +16 -14
- package/js/ui/contracts.js +9 -8
- package/js/ui/serving.js +8609 -227
- package/package.json +3 -8
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +60 -2
- package/types/app-cache/src/index.d.ts +92 -2
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +63 -17
- package/types/apps/src/contracts/cache.d.ts +24 -1
- 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 +54 -0
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +1325 -534
- 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 +97 -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-document.d.ts +1 -1
- package/types/apps/src/contracts/openapi.d.ts +51 -9
- package/types/apps/src/contracts/operations.d.ts +14 -12
- package/types/apps/src/contracts/placement.d.ts +102 -0
- package/types/apps/src/contracts/protocol-version.d.ts +6 -0
- package/types/apps/src/contracts/protocols/1.d.ts +2241 -0
- 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 +711 -0
- package/types/apps/src/contracts/protocols/3.d.ts +776 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1306 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1200 -0
- 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 +6857 -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 +140 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- 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/shared-catalog.d.ts +11 -0
- package/types/apps/src/contracts/skills.d.ts +60 -14
- package/types/apps/src/contracts/sql.d.ts +63 -0
- package/types/apps/src/contracts/ui-auth.d.ts +6 -14
- package/types/apps/src/contracts/ui.d.ts +70 -30
- package/types/apps/src/contracts/webhooks.d.ts +24 -7
- package/types/apps/src/contracts/workflows.d.ts +89 -36
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/host.d.ts +5 -0
- package/types/apps/src/implementation/account-router.d.ts +13 -0
- package/types/apps/src/implementation/app.d.ts +44 -16
- 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 +32 -3
- package/types/apps/src/implementation/catalog-cache.d.ts +43 -5
- 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 +48 -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/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 +7 -8
- package/types/apps/src/implementation/mcp-client.d.ts +49 -25
- 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 +30 -8
- package/types/apps/src/implementation/openapi-document.d.ts +46 -21
- package/types/apps/src/implementation/openapi-names.d.ts +23 -0
- package/types/apps/src/implementation/openapi-request.d.ts +10 -3
- package/types/apps/src/implementation/openapi-source.d.ts +30 -8
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +84 -10
- 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 +6 -4
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +26 -6
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +227 -0
- package/types/apps/src/implementation/router.d.ts +78 -0
- 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 +111 -15
- 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/swagger-client.d.ts +28 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +12 -6
- package/types/apps/src/implementation/ui-client.d.ts +3 -3
- 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 +31 -12
- 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 +17 -5
- package/types/apps/src/implementation/workflows.d.ts +11 -4
- package/types/apps/src/index.d.ts +71 -21
- package/types/apps/src/mcp.d.ts +25 -5
- package/types/apps/src/openapi.d.ts +11 -6
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +13 -8
- package/types/apps/src/ui-auth.d.ts +2 -2
- 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 +7 -4
- 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/legacy-keys.d.ts +20 -0
- package/types/utils/src/recorded-message.d.ts +18 -0
- package/types/utils/src/schema-definitions.d.ts +13 -0
- package/types/utils/src/user-facing-error.d.ts +83 -0
- package/js/chunk-6IIO4NPI.js +0 -29
- package/js/chunk-6YBRWRK3.js +0 -160
- package/js/chunk-BMOIAIVR.js +0 -138
- package/js/chunk-FZJOYIZO.js +0 -19
- package/js/chunk-G7IE6BKC.js +0 -224
- package/js/chunk-IHQ4ML7K.js +0 -2193
- package/js/chunk-KOXMLKTM.js +0 -1288
- package/js/chunk-M6ZRRIBI.js +0 -877
- package/js/chunk-PLCMJREA.js +0 -590
- package/js/chunk-PZ36XMXW.js +0 -93
- package/js/chunk-RBAC33PQ.js +0 -267
- package/js/chunk-SATWJKN6.js +0 -34
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-TE4KO4HI.js +0 -47
- package/js/chunk-W7D7WVSY.js +0 -18
- package/js/chunk-X7SFGU4Q.js +0 -280
- package/js/chunk-ZJWDMTE3.js +0 -63
- 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 -33
- 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/dynamic-tools.d.ts +0 -13
- package/types/apps/src/contracts/storage.d.ts +0 -68
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
- package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
- package/types/apps/src/implementation/storage.d.ts +0 -13
- package/types/apps/src/mcp-stdio.d.ts +0 -8
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Portable Agent Skills returned by an app factory or loaded from published files. */
|
|
2
2
|
import { Schema } from "effect";
|
|
3
|
+
import { ApiError } from "../../../utils/src/api-error.js";
|
|
3
4
|
/** Canonical resource path within one skill. */
|
|
4
5
|
export declare const SkillFilePath: Schema.NonEmptyString;
|
|
5
6
|
/** UTF-8 text resource. Reading a resource never executes it. */
|
|
@@ -40,13 +41,25 @@ export declare const AppSkillSource: Schema.Struct<{
|
|
|
40
41
|
readonly "allowed-tools": Schema.optionalKey<Schema.String>;
|
|
41
42
|
}>;
|
|
42
43
|
export type AppSkillSource = typeof AppSkillSource.Type;
|
|
43
|
-
|
|
44
|
+
/** Invalid selected skill files fail the load. Errors identify the file without disclosing its contents. */
|
|
45
|
+
export declare const SkillDefinitionInvalid: Schema.Class<{
|
|
46
|
+
readonly file: string;
|
|
47
|
+
readonly reason: "metadata" | "files" | "directory" | "missing-document" | "frontmatter" | "name-mismatch";
|
|
48
|
+
} & ApiError & {
|
|
49
|
+
readonly _tag: "SkillDefinitionInvalid";
|
|
50
|
+
}, Omit<Schema.TaggedStruct<"SkillDefinitionInvalid", {
|
|
44
51
|
readonly file: Schema.NonEmptyString;
|
|
45
52
|
readonly reason: Schema.Literals<readonly ["files", "directory", "missing-document", "frontmatter", "metadata", "name-mismatch"]>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
} & {
|
|
54
|
+
readonly message: typeof import("../../../utils/src/api-error.js").MessageField;
|
|
55
|
+
}>, "~type.make.in"> & {
|
|
56
|
+
readonly "~type.make.in": {
|
|
57
|
+
readonly reason: "metadata" | "files" | "directory" | "missing-document" | "frontmatter" | "name-mismatch";
|
|
58
|
+
readonly file: string;
|
|
59
|
+
readonly _tag?: "SkillDefinitionInvalid";
|
|
60
|
+
};
|
|
61
|
+
}, ApiError>;
|
|
62
|
+
export type SkillDefinitionInvalid = typeof SkillDefinitionInvalid.Type;
|
|
50
63
|
/** One evaluated catalog cannot contain ambiguous names. */
|
|
51
64
|
export declare const AppSkills: Schema.$Array<Schema.Struct<{
|
|
52
65
|
readonly files: Schema.$Array<Schema.Struct<{
|
|
@@ -66,11 +79,16 @@ declare const SkillLoadFailed_base: Schema.Class<SkillLoadFailed, Schema.TaggedS
|
|
|
66
79
|
readonly reason: Schema.Literals<readonly ["source", "request", "rate_limited", "document", "limit", "changed", "encoding"]>;
|
|
67
80
|
readonly message: Schema.optional<Schema.String>;
|
|
68
81
|
readonly status: Schema.optional<Schema.Int>;
|
|
82
|
+
readonly missing: Schema.optional<Schema.Literals<readonly ["repository", "ref"]>>;
|
|
69
83
|
}>, import("effect/Cause").YieldableError>;
|
|
70
84
|
/**
|
|
71
85
|
* A skill loader failure shown to people. `message` is the explanation they read; write it for
|
|
72
86
|
* them and never include URLs, tokens or response bodies. `reason` selects the title and whether
|
|
73
87
|
* a retry can help. Custom loaders throw this error to get the same presentation as built-ins.
|
|
88
|
+
* With `source`, `missing` names what the service's answer points to as missing: the `repository`,
|
|
89
|
+
* or the branch or tag (`ref`). It may be missing, or not readable with the request's credentials.
|
|
90
|
+
* Without it, the source's settings or the paths it lists are not valid.
|
|
91
|
+
* These fields choose the explanation; they never show that the failure lies outside Executor.
|
|
74
92
|
*/
|
|
75
93
|
export declare class SkillLoadFailed extends SkillLoadFailed_base {
|
|
76
94
|
}
|
|
@@ -80,6 +98,8 @@ export declare const skillLoadLimits: {
|
|
|
80
98
|
readonly fileBytes: 2000000;
|
|
81
99
|
readonly totalBytes: 20000000;
|
|
82
100
|
readonly concurrency: 8;
|
|
101
|
+
/** The request that checks whether a kept catalog's publication changed. */
|
|
102
|
+
readonly checkMillis: 5000;
|
|
83
103
|
};
|
|
84
104
|
/** Invocation-owned transport and cancellation, supplied by the app context. */
|
|
85
105
|
export interface SkillTransport {
|
|
@@ -90,19 +110,45 @@ export interface SkillTransport {
|
|
|
90
110
|
export interface SkillReaderOptions extends SkillTransport {
|
|
91
111
|
readonly service: string;
|
|
92
112
|
}
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Catalog reuse shared by remote skill loaders. Pass `ctx.cache` to keep the loaded catalog;
|
|
115
|
+
* without it every read fetches the source again. Unlike an MCP tool catalog, a skill catalog
|
|
116
|
+
* past `freshFor` is not served while it refreshes: the read first asks the source whether its
|
|
117
|
+
* publication changed, so agents never read skills that a refresh replaces moments later.
|
|
118
|
+
*/
|
|
119
|
+
export interface SkillCacheOptions {
|
|
120
|
+
readonly cache?: import("./cache.js").AppCache;
|
|
121
|
+
/** Reuse the catalog without asking the source for this duration. Defaults to five minutes. */
|
|
122
|
+
readonly freshFor?: import("effect").Duration.Input;
|
|
98
123
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
124
|
+
* Keep the catalog this long after `freshFor`. A read then confirms it with one request and
|
|
125
|
+
* loads the files again only when the publication changed. Defaults to one day.
|
|
101
126
|
*/
|
|
102
|
-
readonly
|
|
127
|
+
readonly staleFor?: import("effect").Duration.Input;
|
|
103
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Whose access reads the repository. A public repository needs neither field. A private one takes
|
|
131
|
+
* a GitHub account and its token, sent on every request of this read. The token comes only with
|
|
132
|
+
* its account, so the catalog is cached in that account's scope and failures name the account.
|
|
133
|
+
*/
|
|
134
|
+
export type GitHubSkillsAccount = import("./cache.js").AccountCredential<{
|
|
135
|
+
/**
|
|
136
|
+
* The account's token or its handle, such as `account.fields.token`. Its provider declares
|
|
137
|
+
* hosts `github.com` and `raw.githubusercontent.com`, so app code never holds the value.
|
|
138
|
+
*/
|
|
139
|
+
readonly token: string;
|
|
140
|
+
}>;
|
|
141
|
+
/**
|
|
142
|
+
* A GitHub repository and an optional immutable commit, tag or branch. With a cache, a branch or
|
|
143
|
+
* tag is resolved again once the catalog is past `freshFor`, and each commit's file list is kept.
|
|
144
|
+
*/
|
|
145
|
+
export type GitHubSkillsOptions = SkillTransport & SkillCacheOptions & GitHubSkillsAccount & {
|
|
146
|
+
readonly repo: string;
|
|
147
|
+
readonly path?: string;
|
|
148
|
+
readonly ref?: string;
|
|
149
|
+
};
|
|
104
150
|
/** A published directory index, including its listed skill documents and text references. */
|
|
105
|
-
export interface WellKnownSkillsOptions extends SkillTransport {
|
|
151
|
+
export interface WellKnownSkillsOptions extends SkillTransport, SkillCacheOptions {
|
|
106
152
|
readonly url: string;
|
|
107
153
|
}
|
|
108
154
|
/** A folder in the deployed package; omitted path selects skills/. No host filesystem access. */
|
|
@@ -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,7 +1,5 @@
|
|
|
1
1
|
/** Browser authentication protocol. Identity and session storage belong to the host. */
|
|
2
2
|
import { Schema } from "effect";
|
|
3
|
-
import { HttpApi, HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
|
|
4
|
-
import { UiFailed, UiForbidden, UiUnauthorized } from "./ui.js";
|
|
5
3
|
/** Opaque correlation ID; possession alone does not authorize an app session. */
|
|
6
4
|
export declare const AppSignInId: Schema.brand<Schema.String, "AppSignInId">;
|
|
7
5
|
export type AppSignInId = typeof AppSignInId.Type;
|
|
@@ -10,19 +8,13 @@ export declare const AppSignInCode: Schema.RedactedFromValue<Schema.String>;
|
|
|
10
8
|
/** A path on the current app origin, including its query and fragment; never a redirect to another host or host-owned route. */
|
|
11
9
|
export declare const AppReturnPath: Schema.brand<Schema.String, "AppReturnPath">;
|
|
12
10
|
export type AppReturnPath = typeof AppReturnPath.Type;
|
|
13
|
-
/**
|
|
11
|
+
/** Callback query on the app origin. The code is single-use and works only with its attempt's cookie. */
|
|
14
12
|
export declare const AppSignInCallback: Schema.Struct<{
|
|
15
13
|
readonly request: Schema.brand<Schema.String, "AppSignInId">;
|
|
16
14
|
readonly code: Schema.RedactedFromValue<Schema.String>;
|
|
17
15
|
}>;
|
|
18
|
-
/** Host-owned
|
|
19
|
-
export declare const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}>>, Schema.toCodecJson<typeof UiForbidden | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"complete", "POST", "/_executor/auth/complete", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
24
|
-
readonly request: Schema.brand<Schema.String, "AppSignInId">;
|
|
25
|
-
readonly code: Schema.RedactedFromValue<Schema.String>;
|
|
26
|
-
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
27
|
-
readonly returnTo: Schema.brand<Schema.String, "AppReturnPath">;
|
|
28
|
-
}>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiFailed>, never, never>, false>>;
|
|
16
|
+
/** Host-owned callback path on every app origin. */
|
|
17
|
+
export declare const appSignInCallbackPath = "/_executor/auth/callback";
|
|
18
|
+
/** Why the product could not authorize an attempt; the dashboard explains it without retrying. */
|
|
19
|
+
export declare const AppSignInFailure: Schema.Literals<readonly ["ended", "forbidden", "unavailable"]>;
|
|
20
|
+
export type AppSignInFailure = typeof AppSignInFailure.Type;
|
|
@@ -1,24 +1,58 @@
|
|
|
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
|
-
|
|
5
|
-
export declare const UiContext: Schema.Struct<{
|
|
6
|
-
readonly
|
|
7
|
-
readonly
|
|
8
|
-
|
|
2
|
+
import { Schema, type Effect, type Stream } from "effect";
|
|
3
|
+
import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
|
|
4
|
+
import { withLegacyKeys } from "../../../utils/src/legacy-keys.js";
|
|
5
|
+
export declare const UiContext: withLegacyKeys<Schema.Struct<{
|
|
6
|
+
readonly version: Schema.NonEmptyString;
|
|
7
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
8
|
+
}>, {
|
|
9
|
+
readonly version: "deployment";
|
|
9
10
|
}>;
|
|
11
|
+
/** A problem with one of the page's accounts, from stored state. Labels are the owner's own names. */
|
|
12
|
+
export type UiAccountProblem = {
|
|
13
|
+
readonly provider: string;
|
|
14
|
+
readonly reason: "missing" | "removed" | "incompatible";
|
|
15
|
+
} | {
|
|
16
|
+
readonly provider: string;
|
|
17
|
+
readonly account: string;
|
|
18
|
+
readonly reason: "credentials_rejected" | "forbidden" | "upstream_unavailable" | "check_failed";
|
|
19
|
+
};
|
|
20
|
+
/** Account problems found when the page opened, with dashboard links that resolve them. */
|
|
21
|
+
export interface UiAccountNotice {
|
|
22
|
+
readonly app: string;
|
|
23
|
+
readonly problems: readonly UiAccountProblem[];
|
|
24
|
+
/** The app's accounts in the dashboard. */
|
|
25
|
+
readonly fix: string;
|
|
26
|
+
}
|
|
10
27
|
/** Retained browser bytes. Hosts authorize access before reading or rendering them. */
|
|
11
|
-
export interface
|
|
28
|
+
export interface AppUiFile {
|
|
12
29
|
readonly body: Uint8Array;
|
|
13
30
|
readonly contentType: string;
|
|
14
31
|
}
|
|
15
|
-
/**
|
|
16
|
-
export
|
|
32
|
+
/** One byte range of a stored file, already within its size. */
|
|
33
|
+
export interface AppUiRange {
|
|
34
|
+
readonly offset: number;
|
|
35
|
+
readonly length: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A public file the version's source served from `ui/public/`, which the host copied to its
|
|
39
|
+
* own store. `etag` names its exact bytes. Hosts authorize access before reading it.
|
|
40
|
+
*/
|
|
41
|
+
export interface AppUiStoredFile {
|
|
42
|
+
readonly contentType: string;
|
|
43
|
+
readonly size: number;
|
|
44
|
+
readonly etag: string;
|
|
45
|
+
readonly read: (range: AppUiRange | undefined) => Effect.Effect<Stream.Stream<Uint8Array, UiFailed>, UiFailed>;
|
|
46
|
+
}
|
|
47
|
+
export type AppUiAsset = AppUiFile | AppUiStoredFile;
|
|
48
|
+
/** Requests name an operation on this app and the page's version, never another app or account. */
|
|
49
|
+
export declare const UiOperation: withLegacyKeys<Schema.Struct<{
|
|
17
50
|
readonly name: Schema.NonEmptyString;
|
|
18
51
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
19
|
-
readonly
|
|
20
|
-
readonly
|
|
21
|
-
|
|
52
|
+
readonly version: Schema.NonEmptyString;
|
|
53
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
54
|
+
}>, {
|
|
55
|
+
readonly version: "deployment";
|
|
22
56
|
}>;
|
|
23
57
|
declare const UiUnauthorized_base: Schema.Class<UiUnauthorized, Schema.TaggedStruct<"UiUnauthorized", {}>, import("effect/Cause").YieldableError>;
|
|
24
58
|
/** The app session is absent or its parent login was revoked. */
|
|
@@ -28,9 +62,12 @@ declare const UiForbidden_base: Schema.Class<UiForbidden, Schema.TaggedStruct<"U
|
|
|
28
62
|
/** The request did not originate from the configured app. */
|
|
29
63
|
export declare class UiForbidden extends UiForbidden_base {
|
|
30
64
|
}
|
|
31
|
-
declare const
|
|
32
|
-
/**
|
|
33
|
-
|
|
65
|
+
declare const UiVersionChanged_base: Schema.Class<UiVersionChanged, Schema.TaggedStruct<"UiDeploymentChanged", {}>, import("effect/Cause").YieldableError>;
|
|
66
|
+
/**
|
|
67
|
+
* The page should reload before starting another operation. The tag keeps its former name: pages
|
|
68
|
+
* built with earlier framework releases reload on it.
|
|
69
|
+
*/
|
|
70
|
+
export declare class UiVersionChanged extends UiVersionChanged_base {
|
|
34
71
|
}
|
|
35
72
|
declare const UiFailed_base: Schema.Class<UiFailed, Schema.TaggedStruct<"UiFailed", {
|
|
36
73
|
readonly reason: Schema.Literals<readonly ["unavailable", "operation_failed", "account_required"]>;
|
|
@@ -50,24 +87,27 @@ export declare const UiSnapshot: Schema.Union<readonly [Schema.Struct<{
|
|
|
50
87
|
readonly type: Schema.Literal<"heartbeat">;
|
|
51
88
|
}>]>;
|
|
52
89
|
/** Portable serving contract; the host authenticates and resolves the configured app. */
|
|
53
|
-
export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGroup<"ui", HttpApiEndpoint.HttpApiEndpoint<"query", "POST", "/_executor/api/query", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
90
|
+
export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGroup<"ui", HttpApiEndpoint.HttpApiEndpoint<"query", "POST", "/_executor/api/query", never, never, Schema.toCodecJson<withLegacyKeys<Schema.Struct<{
|
|
54
91
|
readonly name: Schema.NonEmptyString;
|
|
55
92
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
56
|
-
readonly
|
|
57
|
-
readonly
|
|
58
|
-
|
|
59
|
-
|
|
93
|
+
readonly version: Schema.NonEmptyString;
|
|
94
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
95
|
+
}>, {
|
|
96
|
+
readonly version: "deployment";
|
|
97
|
+
}>>, never, Schema.toCodecJson<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiVersionChanged | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"mutate", "POST", "/_executor/api/mutate", never, never, Schema.toCodecJson<withLegacyKeys<Schema.Struct<{
|
|
60
98
|
readonly name: Schema.NonEmptyString;
|
|
61
99
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
62
|
-
readonly
|
|
63
|
-
readonly
|
|
64
|
-
|
|
65
|
-
|
|
100
|
+
readonly version: Schema.NonEmptyString;
|
|
101
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
102
|
+
}>, {
|
|
103
|
+
readonly version: "deployment";
|
|
104
|
+
}>>, never, Schema.toCodecJson<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiVersionChanged | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"subscribe", "POST", "/_executor/api/subscribe", never, never, Schema.toCodecJson<withLegacyKeys<Schema.Struct<{
|
|
66
105
|
readonly name: Schema.NonEmptyString;
|
|
67
106
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
68
|
-
readonly
|
|
69
|
-
readonly
|
|
70
|
-
|
|
107
|
+
readonly version: Schema.NonEmptyString;
|
|
108
|
+
readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
|
|
109
|
+
}>, {
|
|
110
|
+
readonly version: "deployment";
|
|
71
111
|
}>>, never, HttpApiSchema.StreamSse<HttpApiSchema.SseEventFromData<Schema.Union<readonly [Schema.Struct<{
|
|
72
112
|
readonly type: Schema.Literal<"snapshot">;
|
|
73
113
|
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
@@ -77,7 +117,7 @@ export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGro
|
|
|
77
117
|
readonly error: typeof UiFailed;
|
|
78
118
|
}>, Schema.Struct<{
|
|
79
119
|
readonly type: Schema.Literal<"heartbeat">;
|
|
80
|
-
}>]>>, Schema.Union<readonly [typeof UiUnauthorized, typeof UiForbidden, typeof
|
|
120
|
+
}>]>>, Schema.Union<readonly [typeof UiUnauthorized, typeof UiForbidden, typeof UiVersionChanged, typeof UiFailed]>, {
|
|
81
121
|
readonly value: Schema.Json;
|
|
82
122
|
readonly type: "snapshot";
|
|
83
123
|
readonly trace?: unknown;
|
|
@@ -86,5 +126,5 @@ export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGro
|
|
|
86
126
|
readonly error: UiFailed;
|
|
87
127
|
} | {
|
|
88
128
|
readonly type: "heartbeat";
|
|
89
|
-
}>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof
|
|
129
|
+
}>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiVersionChanged | typeof UiFailed>, never, never>, false>>;
|
|
90
130
|
export {};
|
|
@@ -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;
|