apps 0.0.1-beta.0 → 0.0.1-beta.10
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 +145 -30
- package/framework-reference.json +1 -1
- package/js/browser-XIPJGLH2.js +65 -0
- package/js/{chunk-36DNRFZQ.js → chunk-27F7W2LG.js} +1 -1
- package/js/{chunk-VFUZI3NY.js → chunk-57RKNWL2.js} +4 -4
- package/js/{chunk-BPEFS4YF.js → chunk-5T57N25Q.js} +122 -18
- package/js/chunk-72JNVHPK.js +41 -0
- package/js/{chunk-2OTCEKL2.js → chunk-CDL5PM2Q.js} +2643 -1646
- package/js/{chunk-KWTCHVLT.js → chunk-CRDWFA74.js} +69 -54
- package/js/chunk-CZ7CSFO4.js +39 -0
- package/js/{chunk-WIDTG42X.js → chunk-EPT3ZP52.js} +79 -26
- package/js/chunk-FL2QR3XW.js +507 -0
- package/js/{chunk-3ANFZFCV.js → chunk-IJX4CYZO.js} +15 -18
- package/js/chunk-IPI4MFSN.js +78 -0
- package/js/chunk-JU7VHODU.js +104 -0
- package/js/chunk-KUMBKVJD.js +39 -0
- package/js/{chunk-YDR4CPJA.js → chunk-M3B3DE4K.js} +8 -8
- package/js/chunk-MKWZPDR6.js +63 -0
- package/js/{chunk-7JXHF5IF.js → chunk-N7YDVXYJ.js} +49 -1
- package/js/chunk-NKLWZJLE.js +172 -0
- package/js/{chunk-OWD2YICM.js → chunk-ODEIDRGW.js} +116 -88
- package/js/{chunk-D6BKYP2L.js → chunk-PJJ24GU7.js} +4 -4
- package/js/{chunk-EP6AEUZO.js → chunk-PZB6T6KU.js} +1 -1
- package/js/chunk-R3EV5FTO.js +97 -0
- package/js/chunk-RFVIONFX.js +189 -0
- package/js/{chunk-W7Q5EOTS.js → chunk-UK573G7W.js} +32 -32
- package/js/chunk-UVL56Z6E.js +6641 -0
- package/js/{chunk-Q2FD5IBM.js → chunk-V5KNQVCT.js} +505 -124
- package/js/{chunk-SBKHUC5L.js → chunk-VFZKSM3T.js} +5 -25
- package/js/{chunk-HP7E42X6.js → chunk-WLE7WX2U.js} +1158 -232
- package/js/{chunk-X3YBZCJW.js → chunk-YXQHV65J.js} +58 -62
- package/js/chunk-Z5M2LQOZ.js +209 -0
- package/js/{chunk-R6JMJSVT.js → chunk-ZQINWV4W.js} +60 -20
- package/js/client.js +11 -27
- package/js/contracts.js +138 -27
- package/js/effect.js +20 -15
- package/js/es-APDZKREY.js +40968 -0
- package/js/graphql.js +220 -123
- package/js/host.js +75 -19
- package/js/index.js +261 -117
- package/js/mcp/effect.js +24 -17
- package/js/mcp/stdio.js +26 -21
- package/js/mcp.js +127 -26
- package/js/openapi.js +3048 -150
- package/js/operations/approval.js +1 -1
- package/js/react.js +4 -4
- package/js/skills/effect.js +11 -0
- package/js/skills.js +893 -0
- package/js/storage/facet.js +7 -7
- package/js/ui/auth/contracts.js +9 -10
- package/js/ui/auth.js +17 -15
- package/js/ui/contracts.js +5 -5
- package/js/ui/serving.js +14 -13
- package/package.json +9 -1
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +119 -0
- package/types/app-cache/src/index.d.ts +93 -0
- 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 +43 -0
- package/types/apps/src/contracts/app.d.ts +16 -4
- package/types/apps/src/contracts/cache.d.ts +44 -0
- package/types/apps/src/contracts/dynamic-skills.d.ts +10 -0
- package/types/apps/src/contracts/failure.d.ts +25 -0
- package/types/apps/src/contracts/graphql.d.ts +18 -1
- package/types/apps/src/contracts/host.d.ts +76 -528
- package/types/apps/src/contracts/mcp.d.ts +19 -1
- package/types/apps/src/contracts/openapi-compile.d.ts +11 -0
- package/types/apps/src/contracts/openapi-document.d.ts +53 -0
- package/types/apps/src/contracts/openapi.d.ts +160 -30
- package/types/apps/src/contracts/operations.d.ts +0 -5
- package/types/apps/src/contracts/protocol-version.d.ts +6 -0
- package/types/apps/src/contracts/protocols/1.d.ts +1589 -0
- package/types/apps/src/contracts/protocols/2.d.ts +668 -0
- package/types/apps/src/contracts/protocols/3.d.ts +676 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1229 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1090 -0
- package/types/apps/src/contracts/provider-error.d.ts +15 -0
- package/types/apps/src/contracts/provider.d.ts +69 -6
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/skills.d.ts +122 -0
- package/types/apps/src/contracts/storage.d.ts +3 -3
- package/types/apps/src/contracts/swagger-client.d.ts +29 -0
- package/types/apps/src/contracts/ui-auth.d.ts +6 -14
- package/types/apps/src/contracts/workflows.d.ts +34 -3
- package/types/apps/src/graphql.d.ts +5 -7
- package/types/apps/src/host.d.ts +1 -0
- 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/cache-session.d.ts +7 -0
- package/types/apps/src/implementation/cache.d.ts +8 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +36 -0
- package/types/apps/src/implementation/dynamic-skills.d.ts +7 -0
- package/types/apps/src/implementation/elicitation.d.ts +13 -13
- package/types/apps/src/implementation/failure-detail.d.ts +25 -0
- package/types/apps/src/implementation/git.d.ts +25 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +7 -0
- package/types/apps/src/implementation/graphql.d.ts +81 -3
- package/types/apps/src/implementation/inflate.d.ts +16 -0
- package/types/apps/src/implementation/input-problems.d.ts +3 -0
- package/types/apps/src/implementation/mcp-call.d.ts +3 -2
- package/types/apps/src/implementation/mcp-catalog.d.ts +9 -0
- package/types/apps/src/implementation/mcp-client.d.ts +39 -22
- package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
- package/types/apps/src/implementation/mcp-tools.d.ts +6 -3
- package/types/apps/src/implementation/mcp.d.ts +55 -2
- package/types/apps/src/implementation/openapi-compile.d.ts +120 -0
- package/types/apps/src/implementation/openapi-document.d.ts +51 -0
- package/types/apps/src/implementation/openapi-names.d.ts +18 -0
- package/types/apps/src/implementation/openapi-request.d.ts +10 -4
- package/types/apps/src/implementation/openapi-source.d.ts +36 -0
- package/types/apps/src/implementation/openapi.d.ts +39 -3
- package/types/apps/src/implementation/operations.d.ts +26 -3
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
- package/types/apps/src/implementation/provider-error.d.ts +10 -0
- package/types/apps/src/implementation/provider.d.ts +9 -4
- package/types/apps/src/implementation/router-catalog.d.ts +225 -0
- package/types/apps/src/implementation/router.d.ts +59 -0
- package/types/apps/src/implementation/schema.d.ts +11 -6
- package/types/apps/src/implementation/skill-files.d.ts +10 -0
- package/types/apps/src/implementation/skills.d.ts +43 -0
- package/types/apps/src/implementation/storage.d.ts +5 -3
- package/types/apps/src/implementation/swagger-client.d.ts +28 -0
- package/types/apps/src/implementation/ui-auth.d.ts +11 -5
- package/types/apps/src/implementation/ui-serving.d.ts +4 -2
- 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 +11 -3
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +8 -7
- package/types/apps/src/openapi.d.ts +8 -6
- package/types/apps/src/skills.d.ts +75 -0
- package/types/apps/src/ui-auth.d.ts +2 -2
- package/types/telemetry/src/browser-operations.d.ts +5 -2
- package/types/telemetry/src/config.d.ts +2 -0
- package/js/chunk-22WRQZT7.js +0 -389
- package/js/chunk-BKVL7XAJ.js +0 -47
- package/js/chunk-C24KEZXR.js +0 -59
- package/js/chunk-LOKGDT6B.js +0 -28
- package/js/chunk-MLKGABMK.js +0 -9
- package/types/apps/src/implementation/account-operations.d.ts +0 -32
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/** Serializable cache protocol. Hosts bind the application and build namespace separately. */
|
|
2
|
+
import { Schema, type Effect } from "effect";
|
|
3
|
+
declare const CacheError_base: Schema.Class<CacheError, Schema.TaggedStruct<"CacheError", {
|
|
4
|
+
readonly reason: Schema.Literals<readonly ["unavailable", "storage", "invalid", "capacity", "timeout"]>;
|
|
5
|
+
}>, import("effect/Cause").YieldableError>;
|
|
6
|
+
/** Expected cache failures never include keys, values or upstream exception text. */
|
|
7
|
+
export declare class CacheError extends CacheError_base {
|
|
8
|
+
}
|
|
9
|
+
/** Bounded defaults shared by loaders and persistent adapters. */
|
|
10
|
+
export declare const cacheLimits: {
|
|
11
|
+
readonly keyBytes: 8192;
|
|
12
|
+
readonly entryBytes: 2000000;
|
|
13
|
+
readonly batchBytes: 8000000;
|
|
14
|
+
readonly batchEntries: 128;
|
|
15
|
+
readonly totalBytes: 128000000;
|
|
16
|
+
readonly totalEntries: 100000;
|
|
17
|
+
readonly retentionMs: number;
|
|
18
|
+
readonly loadTimeoutMs: 90000;
|
|
19
|
+
/**
|
|
20
|
+
* A loader's lease lapses this long after its host last renewed it. Hosts renew every
|
|
21
|
+
* `renewMs` while the invocation that claimed it runs, so a stalled or lost holder frees the
|
|
22
|
+
* key well inside an MCP execute budget.
|
|
23
|
+
*/
|
|
24
|
+
readonly leaseMs: 15000;
|
|
25
|
+
readonly renewMs: 5000;
|
|
26
|
+
/** The longest a caller waits on another loader before loading for itself without publishing. */
|
|
27
|
+
readonly waitMs: 10000;
|
|
28
|
+
/** Bound for one command to a host store; a lost reply fails instead of holding its caller. */
|
|
29
|
+
readonly commandTimeoutMs: 10000;
|
|
30
|
+
};
|
|
31
|
+
/** Stored values carry a version independent of their freshness clock. */
|
|
32
|
+
export declare const CacheEntry: Schema.Struct<{
|
|
33
|
+
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
34
|
+
readonly version: Schema.String;
|
|
35
|
+
readonly freshUntil: Schema.Finite;
|
|
36
|
+
readonly staleUntil: Schema.Finite;
|
|
37
|
+
}>;
|
|
38
|
+
/** Decoded cache value envelope. */
|
|
39
|
+
export type CacheEntry = typeof CacheEntry.Type;
|
|
40
|
+
/** The current entry, and a lease when this caller now owns its load. */
|
|
41
|
+
export declare const CacheAcquired: Schema.Struct<{
|
|
42
|
+
readonly entry: Schema.NullOr<Schema.Struct<{
|
|
43
|
+
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
44
|
+
readonly version: Schema.String;
|
|
45
|
+
readonly freshUntil: Schema.Finite;
|
|
46
|
+
readonly staleUntil: Schema.Finite;
|
|
47
|
+
}>>;
|
|
48
|
+
readonly lease: Schema.NullOr<Schema.String>;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Publication requires the lease acquired against the previously observed version.
|
|
52
|
+
* `acquire` reads one entry and claims its load in the same transaction, so a cache
|
|
53
|
+
* miss costs one round trip. `read` and `claim` remain for builds retained before it.
|
|
54
|
+
*/
|
|
55
|
+
export declare const CacheCommand: Schema.Union<readonly [Schema.Struct<{
|
|
56
|
+
readonly operation: Schema.Literal<"read">;
|
|
57
|
+
readonly keys: Schema.$Array<Schema.String>;
|
|
58
|
+
}>, Schema.Struct<{
|
|
59
|
+
readonly operation: Schema.Literal<"acquire">;
|
|
60
|
+
readonly key: Schema.String;
|
|
61
|
+
/** Claim even a fresh entry, as an explicit refresh does. */
|
|
62
|
+
readonly refresh: Schema.Boolean;
|
|
63
|
+
/** Claim only while the entry still has this version. Absent accepts the current one. */
|
|
64
|
+
readonly version: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
65
|
+
}>, Schema.Struct<{
|
|
66
|
+
readonly operation: Schema.Literal<"claim">;
|
|
67
|
+
readonly key: Schema.String;
|
|
68
|
+
readonly version: Schema.NullOr<Schema.String>;
|
|
69
|
+
}>, Schema.Struct<{
|
|
70
|
+
readonly operation: Schema.Literal<"publish">;
|
|
71
|
+
readonly key: Schema.String;
|
|
72
|
+
readonly lease: Schema.String;
|
|
73
|
+
readonly entry: Schema.Struct<{
|
|
74
|
+
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
75
|
+
readonly version: Schema.String;
|
|
76
|
+
readonly freshUntil: Schema.Finite;
|
|
77
|
+
readonly staleUntil: Schema.Finite;
|
|
78
|
+
}>;
|
|
79
|
+
}>, Schema.Struct<{
|
|
80
|
+
readonly operation: Schema.Literal<"release">;
|
|
81
|
+
readonly key: Schema.String;
|
|
82
|
+
readonly lease: Schema.String;
|
|
83
|
+
}>, Schema.Struct<{
|
|
84
|
+
readonly operation: Schema.Literal<"renew">;
|
|
85
|
+
readonly key: Schema.String;
|
|
86
|
+
readonly lease: Schema.String;
|
|
87
|
+
}>, Schema.Struct<{
|
|
88
|
+
readonly operation: Schema.Literal<"write">;
|
|
89
|
+
readonly entries: Schema.$Array<Schema.Struct<{
|
|
90
|
+
readonly key: Schema.String;
|
|
91
|
+
readonly entry: Schema.Struct<{
|
|
92
|
+
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
93
|
+
readonly version: Schema.String;
|
|
94
|
+
readonly freshUntil: Schema.Finite;
|
|
95
|
+
readonly staleUntil: Schema.Finite;
|
|
96
|
+
}>;
|
|
97
|
+
}>>;
|
|
98
|
+
}>, Schema.Struct<{
|
|
99
|
+
readonly operation: Schema.Literal<"invalidate">;
|
|
100
|
+
readonly key: Schema.String;
|
|
101
|
+
}>]>;
|
|
102
|
+
/** Parsed host command; namespaces cannot be selected by app code. */
|
|
103
|
+
export type CacheCommand = typeof CacheCommand.Type;
|
|
104
|
+
/** Replies remain JSON across Worker RPC and are decoded by each caller. */
|
|
105
|
+
export type CacheTransport = (command: CacheCommand) => Effect.Effect<Schema.Json, CacheError>;
|
|
106
|
+
/**
|
|
107
|
+
* Whether a command replaced or removed retained data: a published refresh, a direct write or an
|
|
108
|
+
* invalidation. Hosts report these so results evaluated from the earlier data are not reused.
|
|
109
|
+
*/
|
|
110
|
+
export declare const changesCache: (command: unknown) => boolean;
|
|
111
|
+
/** Safe protocol envelope used at process boundaries. */
|
|
112
|
+
export declare const CacheReply: Schema.Union<readonly [Schema.Struct<{
|
|
113
|
+
readonly ok: Schema.Literal<true>;
|
|
114
|
+
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
115
|
+
}>, Schema.Struct<{
|
|
116
|
+
readonly ok: Schema.Literal<false>;
|
|
117
|
+
readonly error: typeof CacheError;
|
|
118
|
+
}>]>;
|
|
119
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** Portable Effect cache mechanics. Adapters own storage and the background task lifetime. */
|
|
2
|
+
import { Duration, Effect, Schema } from "effect";
|
|
3
|
+
import { CacheError, type CacheTransport } from "./contracts/cache.js";
|
|
4
|
+
export * from "./contracts/cache.js";
|
|
5
|
+
/** Hash key material before storage or transport; keys and credential scope never enter telemetry. */
|
|
6
|
+
export declare const cacheKey: (key: unknown) => Effect.Effect<string, CacheError, never>;
|
|
7
|
+
/** A cache hit is decoded with the caller's schema. Loader failures are never cached. */
|
|
8
|
+
export interface CacheGet<A> {
|
|
9
|
+
readonly key: Schema.Json;
|
|
10
|
+
readonly schema: Schema.Decoder<A>;
|
|
11
|
+
readonly freshFor: Duration.Input;
|
|
12
|
+
readonly staleFor?: Duration.Input;
|
|
13
|
+
readonly load: Effect.Effect<A, unknown>;
|
|
14
|
+
}
|
|
15
|
+
/** Create a scoped cache client; a background runner must retain all task resources until completion. */
|
|
16
|
+
export declare const makeCache: (host: CacheTransport, background: (task: Effect.Effect<void, unknown>) => Effect.Effect<void>, scope?: Schema.Json,
|
|
17
|
+
/** The caller's own deadline, when the host supplies one. Waiting never runs past it. */
|
|
18
|
+
deadline?: number) => {
|
|
19
|
+
/** Read arbitrary retained JSON entries without initiating a refresh. Missing and null are distinct. */
|
|
20
|
+
read: (keys: readonly Schema.Json[]) => Effect.Effect<readonly ({
|
|
21
|
+
readonly value: Schema.Json;
|
|
22
|
+
readonly version: string;
|
|
23
|
+
readonly freshUntil: number;
|
|
24
|
+
readonly staleUntil: number;
|
|
25
|
+
} | null)[], CacheError, never>;
|
|
26
|
+
/** Publish bounded immutable parts before publishing the manifest that references them. */
|
|
27
|
+
write: (entries: readonly {
|
|
28
|
+
readonly key: Schema.Json;
|
|
29
|
+
readonly value: Schema.Json;
|
|
30
|
+
}[], retention: Duration.Input) => Effect.Effect<void, CacheError, never>;
|
|
31
|
+
/** Revoke retained data and any loader's right to publish its in-flight result. */
|
|
32
|
+
invalidate: (key: Schema.Json) => Effect.Effect<void, CacheError, never>;
|
|
33
|
+
/** Read fresh data, refresh stale data in the background, or wait for the lease owner. */
|
|
34
|
+
get: <A>(options: CacheGet<A>) => Effect.Effect<A, unknown, never>;
|
|
35
|
+
/** Force one awaited refresh without removing the retained value. Concurrent refreshes share a load. */
|
|
36
|
+
revalidate: <A>(options: CacheGet<A>) => Effect.Effect<A, unknown, never>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Host-side lease ownership for one app invocation. Leases the invocation claims are renewed while
|
|
40
|
+
* it runs, so a slow load keeps its key, and released when the host ends the invocation, including
|
|
41
|
+
* interrupted and cancelled ones and loads whose own release never arrived. A holder that stops
|
|
42
|
+
* running, or whose store channel stops answering, loses its lease within `leaseMs`.
|
|
43
|
+
*/
|
|
44
|
+
export declare const holdLeases: (transport: CacheTransport) => Effect.Effect<{
|
|
45
|
+
/** Use for every command of the invocation. Each command is bounded by `commandTimeoutMs`. */
|
|
46
|
+
transport: (input: {
|
|
47
|
+
readonly operation: "read";
|
|
48
|
+
readonly keys: readonly string[];
|
|
49
|
+
} | {
|
|
50
|
+
readonly operation: "acquire";
|
|
51
|
+
readonly key: string;
|
|
52
|
+
readonly refresh: boolean;
|
|
53
|
+
readonly version?: string | null;
|
|
54
|
+
} | {
|
|
55
|
+
readonly operation: "claim";
|
|
56
|
+
readonly key: string;
|
|
57
|
+
readonly version: string | null;
|
|
58
|
+
} | {
|
|
59
|
+
readonly operation: "publish";
|
|
60
|
+
readonly key: string;
|
|
61
|
+
readonly lease: string;
|
|
62
|
+
readonly entry: {
|
|
63
|
+
readonly value: Schema.Json;
|
|
64
|
+
readonly version: string;
|
|
65
|
+
readonly freshUntil: number;
|
|
66
|
+
readonly staleUntil: number;
|
|
67
|
+
};
|
|
68
|
+
} | {
|
|
69
|
+
readonly operation: "release";
|
|
70
|
+
readonly key: string;
|
|
71
|
+
readonly lease: string;
|
|
72
|
+
} | {
|
|
73
|
+
readonly operation: "renew";
|
|
74
|
+
readonly key: string;
|
|
75
|
+
readonly lease: string;
|
|
76
|
+
} | {
|
|
77
|
+
readonly operation: "write";
|
|
78
|
+
readonly entries: readonly {
|
|
79
|
+
readonly key: string;
|
|
80
|
+
readonly entry: {
|
|
81
|
+
readonly value: Schema.Json;
|
|
82
|
+
readonly version: string;
|
|
83
|
+
readonly freshUntil: number;
|
|
84
|
+
readonly staleUntil: number;
|
|
85
|
+
};
|
|
86
|
+
}[];
|
|
87
|
+
} | {
|
|
88
|
+
readonly operation: "invalidate";
|
|
89
|
+
readonly key: string;
|
|
90
|
+
}) => Effect.Effect<Schema.Json, CacheError, never>;
|
|
91
|
+
/** Stop renewing and release every lease the invocation still holds. */
|
|
92
|
+
close: Effect.Effect<void, never, never>;
|
|
93
|
+
}, never, never>;
|
|
@@ -157,6 +157,33 @@ export declare const DatabaseLimits: Schema.Struct<{
|
|
|
157
157
|
export type DatabaseLimits = typeof DatabaseLimits.Type;
|
|
158
158
|
/** Current per-invocation budgets, shared by every database adapter. */
|
|
159
159
|
export declare const defaultDatabaseLimits: DatabaseLimits;
|
|
160
|
+
/**
|
|
161
|
+
* The budget a query or mutation exhausted. `pageSize` bounds one take(n) or paginate call;
|
|
162
|
+
* `valueBytes` bounds one stored row; the rest accumulate across the whole invocation.
|
|
163
|
+
*/
|
|
164
|
+
export declare const DatabaseLimit: Schema.Literals<readonly ["scanCalls", "directGets", "rowsRead", "rowsReturned", "pageSize", "bytesRead", "writes", "valueBytes"]>;
|
|
165
|
+
export type DatabaseLimit = typeof DatabaseLimit.Type;
|
|
166
|
+
declare const DatabaseLimitExceeded_base: Schema.Class<DatabaseLimitExceeded, Schema.TaggedStruct<"DatabaseLimitExceeded", {
|
|
167
|
+
readonly limit: Schema.Literals<readonly ["scanCalls", "directGets", "rowsRead", "rowsReturned", "pageSize", "bytesRead", "writes", "valueBytes"]>;
|
|
168
|
+
readonly maximum: Schema.Int;
|
|
169
|
+
readonly requested: Schema.Int;
|
|
170
|
+
}>, import("effect/Cause").YieldableError>;
|
|
171
|
+
/** A query or mutation exceeded one of its database budgets. Nothing it wrote is committed. */
|
|
172
|
+
export declare class DatabaseLimitExceeded extends DatabaseLimitExceeded_base {
|
|
173
|
+
get message(): string;
|
|
174
|
+
}
|
|
175
|
+
/** Host-owned row metadata that authored tables cannot declare. */
|
|
176
|
+
export declare const reservedFieldNames: readonly ["id", "createdAt", "updatedAt"];
|
|
177
|
+
declare const DatabaseFieldReserved_base: Schema.Class<DatabaseFieldReserved, Schema.TaggedStruct<"DatabaseFieldReserved", {
|
|
178
|
+
readonly table: Schema.String;
|
|
179
|
+
readonly field: Schema.Literals<readonly ["id", "createdAt", "updatedAt"]>;
|
|
180
|
+
}>, import("effect/Cause").YieldableError>;
|
|
181
|
+
/** A table declared a field the host adds to every row. */
|
|
182
|
+
export declare class DatabaseFieldReserved extends DatabaseFieldReserved_base {
|
|
183
|
+
get message(): string;
|
|
184
|
+
}
|
|
185
|
+
/** Failures a database session reports to authored code and its host. */
|
|
186
|
+
export type DatabaseError = AppDatabaseError | DatabaseLimitExceeded;
|
|
160
187
|
/** Host resource bounds outside an individual database transaction. Durations are milliseconds. */
|
|
161
188
|
export declare const DatabaseRuntimeLimits: Schema.Struct<{
|
|
162
189
|
readonly maxCursorChars: Schema.Int;
|
|
@@ -173,21 +200,21 @@ export declare const defaultDatabaseRuntimeLimits: {
|
|
|
173
200
|
/** The host binds one database and read/write authority for the entire invocation. */
|
|
174
201
|
export interface DatabaseSession {
|
|
175
202
|
/** Host-only idempotency receipt, committed atomically with the mutation and validated result. */
|
|
176
|
-
readonly once: <E, R>(key: string, fingerprint: string, work: () => Effect.Effect<Schema.Json, E, R>) => Effect.Effect<Schema.Json, E |
|
|
203
|
+
readonly once: <E, R>(key: string, fingerprint: string, work: () => Effect.Effect<Schema.Json, E, R>) => Effect.Effect<Schema.Json, E | DatabaseError, R>;
|
|
177
204
|
readonly readTables: ReadonlySet<string>;
|
|
178
205
|
readonly changedTables: ReadonlySet<string>;
|
|
179
|
-
readonly execute: (operation: DatabaseOperation) => Effect.Effect<OperationResult,
|
|
206
|
+
readonly execute: (operation: DatabaseOperation) => Effect.Effect<OperationResult, DatabaseError>;
|
|
180
207
|
}
|
|
181
208
|
/** Native operation scope owns snapshot consistency, write rollback and commit notifications. */
|
|
182
209
|
export interface AppDatabase {
|
|
183
210
|
readonly schema: DatabaseSchema;
|
|
184
211
|
readonly schemaHash: string;
|
|
185
|
-
readonly read: <A, E, R>(work: (session: DatabaseSession) => Effect.Effect<A, E, R>) => Effect.Effect<A, E |
|
|
186
|
-
readonly mutate: <A, E, R>(work: (session: DatabaseSession) => Effect.Effect<A, E, R>) => Effect.Effect<A, E |
|
|
212
|
+
readonly read: <A, E, R>(work: (session: DatabaseSession) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | DatabaseError, R>;
|
|
213
|
+
readonly mutate: <A, E, R>(work: (session: DatabaseSession) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | DatabaseError, R>;
|
|
187
214
|
}
|
|
188
215
|
/** Product-independent app partitions. A host supplies persistent storage; callers never choose filenames. */
|
|
189
216
|
export interface AppDatabases {
|
|
190
|
-
readonly read: <A, E>(app: string, schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E |
|
|
191
|
-
readonly mutate: <A, E>(app: string, schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E |
|
|
217
|
+
readonly read: <A, E>(app: string, schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | DatabaseError>;
|
|
218
|
+
readonly mutate: <A, E>(app: string, schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | DatabaseError>;
|
|
192
219
|
}
|
|
193
220
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Validate declarations and write values before touching SQLite. */
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
-
import { AppDatabaseError, DatabaseSchema, RowMetadata, type Field, type Row, type Scalar, type Table } from "../contracts/database.js";
|
|
3
|
+
import { AppDatabaseError, DatabaseFieldReserved, DatabaseSchema, RowMetadata, type Field, type Row, type Scalar, type Table } from "../contracts/database.js";
|
|
4
4
|
/** Built-in creation ordering and stable tie-breakers apply to every index. */
|
|
5
5
|
export declare const indexesFor: (table: Table) => {
|
|
6
6
|
name: string;
|
|
@@ -11,22 +11,7 @@ export declare const fieldFor: (table: Table, name: string) => Field | undefined
|
|
|
11
11
|
/** Finite numbers and well-formed strings keep JSON and index ordering consistent. */
|
|
12
12
|
export declare const validScalar: (field: Field, value: unknown) => value is Scalar;
|
|
13
13
|
/** Parse the whole schema, including references and composite-index definitions. */
|
|
14
|
-
export declare const parseDatabaseSchema: (input: unknown) => Effect.Effect<
|
|
15
|
-
readonly [x: string]: {
|
|
16
|
-
readonly fields: {
|
|
17
|
-
readonly [x: string]: {
|
|
18
|
-
readonly kind: "string" | "number" | "boolean" | "id" | "userId";
|
|
19
|
-
readonly optional?: boolean | undefined;
|
|
20
|
-
readonly default?: string | number | boolean | undefined;
|
|
21
|
-
readonly references?: string | undefined;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
readonly indexes: readonly {
|
|
25
|
-
readonly name: string;
|
|
26
|
-
readonly fields: readonly [string, ...string[]];
|
|
27
|
-
}[];
|
|
28
|
-
};
|
|
29
|
-
}, AppDatabaseError, never>;
|
|
14
|
+
export declare const parseDatabaseSchema: (input: unknown) => Effect.Effect<DatabaseSchema, AppDatabaseError | DatabaseFieldReserved>;
|
|
30
15
|
/** Canonical ordering for schema fingerprints and query-bound cursors. */
|
|
31
16
|
export declare const canonicalSchema: (schema: DatabaseSchema) => string;
|
|
32
17
|
/** Inserts apply declared defaults; updates reject unknown/metadata fields and clear optional values with null. */
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** Bounded recovery a declared API error published for its caller: a short next step and agent guidance. */
|
|
3
|
+
export declare const ApiErrorRecovery: Schema.Struct<{
|
|
4
|
+
readonly action: Schema.NonEmptyString;
|
|
5
|
+
readonly instructions: Schema.NonEmptyString;
|
|
6
|
+
}>;
|
|
7
|
+
/** Recovery copied from an error response body; extra keys are dropped on decode. */
|
|
8
|
+
export type ApiErrorRecovery = typeof ApiErrorRecovery.Type;
|
|
9
|
+
/** Bounded public fields from a response matching its declared API error schema. */
|
|
10
|
+
export declare const ApiErrorResponse: Schema.Struct<{
|
|
11
|
+
readonly code: Schema.NonEmptyString;
|
|
12
|
+
readonly status: Schema.Int;
|
|
13
|
+
readonly message: Schema.NonEmptyString;
|
|
14
|
+
readonly recovery: Schema.optionalKey<Schema.Struct<{
|
|
15
|
+
readonly action: Schema.NonEmptyString;
|
|
16
|
+
readonly instructions: Schema.NonEmptyString;
|
|
17
|
+
}>>;
|
|
18
|
+
}>;
|
|
19
|
+
/** Safe projection of a response matching a declared API error schema. */
|
|
20
|
+
export type ApiErrorResponse = typeof ApiErrorResponse.Type;
|
|
21
|
+
declare const OpenapiResponseError_base: Schema.Class<OpenapiResponseError, Schema.TaggedStruct<"OpenapiResponseError", {
|
|
22
|
+
readonly code: Schema.NonEmptyString;
|
|
23
|
+
readonly status: Schema.Int;
|
|
24
|
+
readonly message: Schema.NonEmptyString;
|
|
25
|
+
readonly recovery: Schema.optionalKey<Schema.Struct<{
|
|
26
|
+
readonly action: Schema.NonEmptyString;
|
|
27
|
+
readonly instructions: Schema.NonEmptyString;
|
|
28
|
+
}>>;
|
|
29
|
+
}>, import("effect/Cause").YieldableError>;
|
|
30
|
+
/** A validated OpenAPI failure with its declared message or static schema explanation. */
|
|
31
|
+
export declare class OpenapiResponseError extends OpenapiResponseError_base {
|
|
32
|
+
}
|
|
33
|
+
/** Error response reads have independent byte and time bounds, including chunked bodies. */
|
|
34
|
+
export declare const OpenapiErrorLimits: Schema.Struct<{
|
|
35
|
+
readonly maxBodyBytes: Schema.Int;
|
|
36
|
+
readonly readTimeoutMs: Schema.Int;
|
|
37
|
+
}>;
|
|
38
|
+
/** Stop reading on overflow or timeout and keep the generic HTTP failure. */
|
|
39
|
+
export declare const defaultOpenapiErrorLimits: {
|
|
40
|
+
readonly maxBodyBytes: number;
|
|
41
|
+
readonly readTimeoutMs: number;
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { AppSkillSource, SkillFile } from "./skills.js";
|
|
1
2
|
import type { DatabaseDefinition } from "./storage.js";
|
|
2
3
|
/** Native app contracts; factories and handlers compose in the host's Effect runtime. */
|
|
3
4
|
import { type Effect, Schema } from "effect";
|
|
4
5
|
import type { OperationSchedule } from "./schedules.js";
|
|
5
|
-
import type { AppOperation } from "./operations.js";
|
|
6
6
|
import type { AccountOf, AuthMethods, ManyAccounts, Provider } from "./provider.js";
|
|
7
7
|
import type { AppWorkflow, WorkflowReads } from "./workflows.js";
|
|
8
8
|
import type { Elicit } from "./elicitation.js";
|
|
@@ -10,12 +10,16 @@ import type { Elicit } from "./elicitation.js";
|
|
|
10
10
|
type Handler<Context> = (context: Context, input: never) => Effect.Effect<unknown, unknown>;
|
|
11
11
|
/** App capabilities share one account context. Package metadata belongs in package.json. */
|
|
12
12
|
export interface AppDefinition<Context> {
|
|
13
|
+
/** The app's root router. Its keys form tool paths such as `issues.list`. */
|
|
14
|
+
readonly tools?: import("./router.js").AppRouter | import("./router.js").DynamicRouter;
|
|
15
|
+
/** Omission reads packaged skills/. An explicit catalog replaces that default, including []. */
|
|
16
|
+
readonly skills?: readonly AppSkillSource[];
|
|
17
|
+
/** Optional lazy skills, added to the static catalog. Only skill reads call them. */
|
|
18
|
+
readonly dynamicSkills?: import("./dynamic-skills.js").DynamicSkills;
|
|
13
19
|
readonly workflows?: Readonly<Record<string, AppWorkflow>>;
|
|
14
20
|
readonly schedules?: Readonly<Record<string, Omit<OperationSchedule, "name"> & {
|
|
15
21
|
readonly tool: string;
|
|
16
22
|
}>>;
|
|
17
|
-
readonly queries?: Readonly<Record<string, AppOperation>>;
|
|
18
|
-
readonly mutations?: Readonly<Record<string, AppOperation>>;
|
|
19
23
|
readonly webhooks?: Readonly<Record<string, {
|
|
20
24
|
readonly account: string;
|
|
21
25
|
readonly config: Schema.Decoder<unknown>;
|
|
@@ -31,11 +35,19 @@ export type AccountSlots = Readonly<Record<string, Provider<AuthMethods> | ManyA
|
|
|
31
35
|
type AccountsFor<Slot> = Slot extends ManyAccounts<infer Auth> ? readonly AccountOf<Provider<Auth>>[] : AccountOf<Slot>;
|
|
32
36
|
/** Current credentials for one invocation. Never retained in source or build output. */
|
|
33
37
|
export interface BoundContext<Slots extends AccountSlots> {
|
|
38
|
+
/** Explicit app/build-scoped caching. Account-specific loaders opt into forAccount. */
|
|
39
|
+
readonly cache: import("./cache.js").AppCache;
|
|
40
|
+
/** Text files retained in this deployment. Paths are package-relative, never host filesystem paths. */
|
|
41
|
+
readonly files: readonly SkillFile[];
|
|
34
42
|
/** Read-only run management, bound to this configured app. */
|
|
35
43
|
readonly workflows: WorkflowReads;
|
|
36
44
|
/** Ask for user input during this tool call. Unavailable during discovery and after the invocation closes. */
|
|
37
45
|
readonly elicit: Elicit;
|
|
38
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Invocation-owned HTTP requests with trace propagation and host cancellation. It lasts until the
|
|
48
|
+
* invocation and every app cache refresh it started in the background have ended, so a catalog
|
|
49
|
+
* loader given this fetch can refresh after the reply.
|
|
50
|
+
*/
|
|
39
51
|
readonly fetch: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
40
52
|
/** Host cancellation for this invocation. Pass it to fetch and other interruptible APIs. */
|
|
41
53
|
readonly signal: AbortSignal;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Author cache API; schemas parse persisted values before they re-enter app code. */
|
|
2
|
+
import type { Duration, Effect } from "effect";
|
|
3
|
+
import type { CacheTransport } from "../../../app-cache/src/contracts/cache.js";
|
|
4
|
+
import type { Schema } from "../implementation/schema.js";
|
|
5
|
+
import type { JsonValue } from "./schema.js";
|
|
6
|
+
/** A cache loader owns its own cancellation and HTTP capability, including during SWR. */
|
|
7
|
+
export interface CacheLoadContext {
|
|
8
|
+
readonly cache: AppCache;
|
|
9
|
+
readonly signal: AbortSignal;
|
|
10
|
+
readonly fetch: typeof globalThis.fetch;
|
|
11
|
+
}
|
|
12
|
+
/** Load options shared by normal reads and explicit refreshes. */
|
|
13
|
+
export interface CacheGetOptions<A> {
|
|
14
|
+
readonly key: JsonValue;
|
|
15
|
+
readonly schema: Schema<A, boolean>;
|
|
16
|
+
readonly freshFor: Duration.Input;
|
|
17
|
+
readonly staleFor?: Duration.Input;
|
|
18
|
+
readonly load: (context: CacheLoadContext) => Promise<A>;
|
|
19
|
+
}
|
|
20
|
+
/** Cache keys describe every input that affects the value; the host adds app/build isolation. */
|
|
21
|
+
export interface AppCache {
|
|
22
|
+
readonly get: <A>(options: CacheGetOptions<A>) => Promise<A>;
|
|
23
|
+
/** Await a fresh load, coalescing concurrent refreshes and retaining the previous value on failure. */
|
|
24
|
+
readonly revalidate: <A>(options: CacheGetOptions<A>) => Promise<A>;
|
|
25
|
+
readonly read: <A>(key: JsonValue, schema: Schema<A, boolean>) => Promise<A | undefined>;
|
|
26
|
+
readonly readMany: <A>(keys: readonly JsonValue[], schema: Schema<A, boolean>) => Promise<readonly (A | undefined)[]>;
|
|
27
|
+
readonly write: (entries: readonly {
|
|
28
|
+
readonly key: JsonValue;
|
|
29
|
+
readonly value: JsonValue;
|
|
30
|
+
}[], retention: Duration.Input) => Promise<void>;
|
|
31
|
+
readonly invalidate: (key: JsonValue) => Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Scope entries to a bound account and its credential generation. Token renewal keeps the
|
|
34
|
+
* entries; reconnecting or replacing the account's credentials starts an empty scope.
|
|
35
|
+
*/
|
|
36
|
+
readonly forAccount: (account: {
|
|
37
|
+
readonly id: string;
|
|
38
|
+
}) => AppCache;
|
|
39
|
+
}
|
|
40
|
+
/** Trusted storage and background ownership; never accepted from request JSON. */
|
|
41
|
+
export interface HostCache {
|
|
42
|
+
readonly transport: CacheTransport;
|
|
43
|
+
readonly background: (task: Effect.Effect<void, unknown>) => Effect.Effect<void>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Lazy skill loading, shaped like dynamic tools. Only skill reads call it. */
|
|
2
|
+
import type { Effect } from "effect";
|
|
3
|
+
import type { AppSkillSource } from "./skills.js";
|
|
4
|
+
/**
|
|
5
|
+
* `list` returns complete skills, including their files, added to the static catalog. Every
|
|
6
|
+
* skill read loads the full catalog. Names must not repeat across both catalogs.
|
|
7
|
+
*/
|
|
8
|
+
export interface DynamicSkills {
|
|
9
|
+
readonly list: () => Effect.Effect<readonly AppSkillSource[], unknown>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Failure detail that crosses the runtime boundary to the app's own caller. */
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
/** Longest failure message carried across the runtime boundary. */
|
|
4
|
+
export declare const maxFailureMessageLength = 2048;
|
|
5
|
+
/**
|
|
6
|
+
* `app` for errors thrown by authored code, `storage` for app data failures the host raised, and
|
|
7
|
+
* `service` for an external API the app called through a framework helper.
|
|
8
|
+
*/
|
|
9
|
+
export declare const FailureSource: Schema.Literals<readonly ["app", "storage", "service"]>;
|
|
10
|
+
/** The thrown error's name, such as `TypeError`, or the host error's tag. */
|
|
11
|
+
export declare const FailureName: Schema.String;
|
|
12
|
+
/** A stable host failure code, such as an app data reason. */
|
|
13
|
+
export declare const FailureCode: Schema.String;
|
|
14
|
+
/** Bounded, with the invocation's account secrets replaced. */
|
|
15
|
+
export declare const FailureMessage: Schema.String;
|
|
16
|
+
/**
|
|
17
|
+
* The error an app's own code raised, or the specific host failure it hit. Stacks and cause
|
|
18
|
+
* values stay private. Builds from before these fields existed send none.
|
|
19
|
+
*/
|
|
20
|
+
export declare const FailureDetail: {
|
|
21
|
+
source: Schema.optionalKey<Schema.Literals<readonly ["app", "storage", "service"]>>;
|
|
22
|
+
errorName: Schema.optionalKey<Schema.String>;
|
|
23
|
+
code: Schema.optionalKey<Schema.String>;
|
|
24
|
+
message: Schema.optionalKey<Schema.String>;
|
|
25
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProviderError } from "./provider-error.js";
|
|
1
2
|
/** GraphQL discovery contracts. Catalogs are evaluated with the selected account. */
|
|
2
3
|
import { Schema, type Effect } from "effect";
|
|
3
4
|
import { type JsonValue } from "./schema.js";
|
|
@@ -15,6 +16,7 @@ export declare const defaultGraphqlClientLimits: {
|
|
|
15
16
|
/** Endpoint and credential snapshot for one app evaluation. */
|
|
16
17
|
export declare const GraphqlToolsOptions: Schema.Struct<{
|
|
17
18
|
readonly url: Schema.String;
|
|
19
|
+
readonly accountId: Schema.optional<Schema.brand<Schema.String, "acc">>;
|
|
18
20
|
readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
19
21
|
readonly signal: Schema.optional<Schema.instanceOf<AbortSignal, AbortSignal>>;
|
|
20
22
|
readonly timeoutMs: Schema.optional<Schema.Int>;
|
|
@@ -95,8 +97,23 @@ export interface GraphqlTool {
|
|
|
95
97
|
readonly description: string;
|
|
96
98
|
readonly readOnly: boolean;
|
|
97
99
|
readonly input: Schema.Decoder<JsonValue>;
|
|
98
|
-
readonly run: (context: unknown, input: JsonValue) => Effect.Effect<JsonValue, GraphqlError>;
|
|
100
|
+
readonly run: (context: unknown, input: JsonValue) => Effect.Effect<JsonValue, GraphqlError | ProviderError>;
|
|
99
101
|
}
|
|
100
102
|
/** One tool per root field; subscriptions require a separate long-lived host. */
|
|
101
103
|
export type GraphqlTools = Readonly<Record<string, GraphqlTool>>;
|
|
104
|
+
/** Persisted execution data for one root field; no credentials or executable schema. */
|
|
105
|
+
export declare const GraphqlToolDefinition: Schema.Struct<{
|
|
106
|
+
readonly name: Schema.String;
|
|
107
|
+
readonly kind: Schema.Literals<readonly ["query", "mutation"]>;
|
|
108
|
+
readonly field: Schema.String;
|
|
109
|
+
readonly description: Schema.String;
|
|
110
|
+
readonly arguments: Schema.$Array<Schema.Struct<{
|
|
111
|
+
readonly name: Schema.String;
|
|
112
|
+
readonly type: Schema.String;
|
|
113
|
+
}>>;
|
|
114
|
+
readonly inputSchema: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
115
|
+
readonly composite: Schema.Boolean;
|
|
116
|
+
readonly selection: Schema.String;
|
|
117
|
+
}>;
|
|
118
|
+
export type GraphqlToolDefinition = typeof GraphqlToolDefinition.Type;
|
|
102
119
|
export {};
|