apps 0.0.1-beta.1 → 0.0.1-beta.11
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 +65 -43
- package/framework-reference.json +1 -1
- package/js/browser-XIPJGLH2.js +65 -0
- package/js/{chunk-SATWJKN6.js → chunk-27F7W2LG.js} +1 -1
- package/js/{chunk-HDJH3RPR.js → chunk-57RKNWL2.js} +2 -2
- package/js/{chunk-2HHMABB6.js → chunk-5T57N25Q.js} +61 -13
- package/js/{chunk-FW5HBOIK.js → chunk-CDL5PM2Q.js} +307 -169
- package/js/{chunk-X7SFGU4Q.js → chunk-EFAPIRVB.js} +28 -9
- package/js/chunk-GPFVWWDZ.js +209 -0
- package/js/{chunk-OHRT55C4.js → chunk-IJX4CYZO.js} +3 -6
- package/js/{chunk-ZTFQHGEB.js → chunk-IPI4MFSN.js} +3 -5
- package/js/{chunk-YEJOQEII.js → chunk-JU7VHODU.js} +1 -1
- package/js/{chunk-IHQ4ML7K.js → chunk-KRSCJDTW.js} +586 -111
- package/js/chunk-KUMBKVJD.js +39 -0
- package/js/{chunk-EVJUVWN2.js → chunk-M3B3DE4K.js} +2 -2
- package/js/{chunk-ZJWDMTE3.js → chunk-MKWZPDR6.js} +3 -3
- package/js/{chunk-BMOIAIVR.js → chunk-N7YDVXYJ.js} +49 -1
- package/js/chunk-NKLWZJLE.js +172 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-ODEIDRGW.js} +3 -4
- package/js/{chunk-M6ZRRIBI.js → chunk-PJJ24GU7.js} +1 -1
- package/js/{chunk-FZJOYIZO.js → chunk-PZB6T6KU.js} +1 -1
- package/js/chunk-R3EV5FTO.js +97 -0
- package/js/{chunk-KOXMLKTM.js → chunk-RELFXUOO.js} +308 -316
- package/js/{chunk-6YBRWRK3.js → chunk-RFVIONFX.js} +43 -14
- package/js/{chunk-RBAC33PQ.js → chunk-TYVDBQSI.js} +58 -83
- package/js/{chunk-QKHR7BMF.js → chunk-UK573G7W.js} +1 -1
- package/js/{chunk-NCYXZN2G.js → chunk-UVL56Z6E.js} +390 -23
- package/js/{chunk-4LPG6RCH.js → chunk-VFZKSM3T.js} +5 -25
- package/js/{chunk-6IIO4NPI.js → chunk-WVVV4TX2.js} +21 -9
- package/js/{chunk-G7IE6BKC.js → chunk-YBRC463S.js} +8 -8
- package/js/chunk-Z2QY3YTF.js +507 -0
- package/js/{chunk-PLCMJREA.js → chunk-ZQINWV4W.js} +60 -20
- package/js/client.js +10 -26
- package/js/contracts.js +70 -15
- package/js/effect.js +19 -19
- package/js/es-APDZKREY.js +40968 -0
- package/js/graphql.js +34 -39
- package/js/host.js +23 -23
- package/js/index.js +199 -195
- package/js/mcp/effect.js +21 -21
- package/js/mcp/stdio.js +25 -25
- package/js/mcp.js +60 -44
- package/js/openapi.js +826 -41682
- package/js/react.js +3 -3
- package/js/skills/effect.js +3 -4
- package/js/skills.js +53 -17
- package/js/storage/facet.js +4 -4
- package/js/ui/auth/contracts.js +8 -9
- package/js/ui/auth.js +16 -14
- package/js/ui/contracts.js +4 -4
- package/js/ui/serving.js +9 -8
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +42 -2
- package/types/app-cache/src/index.d.ts +59 -1
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/app-data/src/implementation/schema.d.ts +2 -17
- package/types/apps/src/contracts/app.d.ts +7 -6
- package/types/apps/src/contracts/cache.d.ts +4 -1
- package/types/apps/src/contracts/failure.d.ts +25 -0
- package/types/apps/src/contracts/host.d.ts +34 -679
- package/types/apps/src/contracts/mcp.d.ts +16 -0
- package/types/apps/src/contracts/openapi.d.ts +11 -1
- 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.d.ts +56 -5
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/skills.d.ts +17 -8
- package/types/apps/src/contracts/storage.d.ts +3 -3
- 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 +1 -3
- package/types/apps/src/implementation/account-router.d.ts +12 -0
- package/types/apps/src/implementation/app.d.ts +5 -4
- package/types/apps/src/implementation/cache.d.ts +3 -1
- package/types/apps/src/implementation/catalog-cache.d.ts +9 -2
- package/types/apps/src/implementation/elicitation.d.ts +1 -1
- package/types/apps/src/implementation/failure-detail.d.ts +25 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +1 -4
- package/types/apps/src/implementation/mcp-catalog.d.ts +1 -4
- package/types/apps/src/implementation/mcp-client.d.ts +35 -19
- package/types/apps/src/implementation/mcp.d.ts +35 -19
- package/types/apps/src/implementation/openapi-compile.d.ts +3 -2
- package/types/apps/src/implementation/openapi-document.d.ts +0 -2
- package/types/apps/src/implementation/openapi-names.d.ts +18 -0
- package/types/apps/src/implementation/openapi-request.d.ts +0 -1
- package/types/apps/src/implementation/openapi-source.d.ts +7 -7
- 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.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 +5 -6
- 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 +21 -6
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +5 -4
- package/types/apps/src/openapi.d.ts +6 -6
- package/types/apps/src/skills.d.ts +6 -3
- package/types/apps/src/ui-auth.d.ts +2 -2
- package/types/telemetry/src/browser-operations.d.ts +5 -2
- package/js/chunk-PZ36XMXW.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-TE4KO4HI.js +0 -47
- package/js/chunk-W7D7WVSY.js +0 -18
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
appSignInCallbackPath
|
|
3
|
+
} from "./chunk-VFZKSM3T.js";
|
|
4
|
+
import {
|
|
5
|
+
HttpServerResponse_exports
|
|
6
|
+
} from "./chunk-UK573G7W.js";
|
|
7
|
+
|
|
8
|
+
// src/implementation/ui-auth.ts
|
|
9
|
+
var appPrivateHeaders = {
|
|
10
|
+
"cache-control": "no-store",
|
|
11
|
+
"referrer-policy": "no-referrer",
|
|
12
|
+
"x-content-type-options": "nosniff",
|
|
13
|
+
"content-security-policy": "frame-ancestors 'none'"
|
|
14
|
+
};
|
|
15
|
+
var appRedirect = (url) => HttpServerResponse_exports.redirect(url, { status: 302, headers: appPrivateHeaders });
|
|
16
|
+
var appSignInCallback = (origin, request, code) => {
|
|
17
|
+
const callback = new URL(appSignInCallbackPath, origin);
|
|
18
|
+
callback.searchParams.set("request", request);
|
|
19
|
+
callback.searchParams.set("code", code);
|
|
20
|
+
return callback.href;
|
|
21
|
+
};
|
|
22
|
+
var appSignInFailed = () => HttpServerResponse_exports.text(
|
|
23
|
+
`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Could not open app</title></head><body><p>Could not sign in to this app. Try opening it again.</p><a href="/">Try again</a></body></html>`,
|
|
24
|
+
{
|
|
25
|
+
status: 401,
|
|
26
|
+
contentType: "text/html",
|
|
27
|
+
headers: {
|
|
28
|
+
...appPrivateHeaders,
|
|
29
|
+
"content-security-policy": "default-src 'none'; frame-ancestors 'none'; base-uri 'none'"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
appPrivateHeaders,
|
|
36
|
+
appRedirect,
|
|
37
|
+
appSignInCallback,
|
|
38
|
+
appSignInFailed
|
|
39
|
+
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
invalidate,
|
|
4
4
|
layer,
|
|
5
5
|
mutation
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PJJ24GU7.js";
|
|
7
7
|
import {
|
|
8
8
|
Boolean,
|
|
9
9
|
Cause,
|
|
@@ -158,7 +158,7 @@ import {
|
|
|
158
158
|
void_2,
|
|
159
159
|
whileLoop,
|
|
160
160
|
zipRight
|
|
161
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
162
162
|
import {
|
|
163
163
|
__export
|
|
164
164
|
} from "./chunk-CZ7CSFO4.js";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProviderError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-R3EV5FTO.js";
|
|
4
4
|
import {
|
|
5
5
|
AccountId
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-27F7W2LG.js";
|
|
7
7
|
import {
|
|
8
8
|
Option_exports,
|
|
9
9
|
Schema_exports
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
11
11
|
|
|
12
12
|
// src/implementation/provider-error.ts
|
|
13
13
|
function parseProviderError(error) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Schema_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
4
4
|
|
|
5
5
|
// ../app-data/src/contracts/database.ts
|
|
6
6
|
var DataName = Schema_exports.String.check(
|
|
@@ -113,6 +113,51 @@ var defaultDatabaseLimits = {
|
|
|
113
113
|
valueBytes: 64 * 1024,
|
|
114
114
|
indexBytes: 2048
|
|
115
115
|
};
|
|
116
|
+
var DatabaseLimit = Schema_exports.Literals([
|
|
117
|
+
"scanCalls",
|
|
118
|
+
"directGets",
|
|
119
|
+
"rowsRead",
|
|
120
|
+
"rowsReturned",
|
|
121
|
+
"pageSize",
|
|
122
|
+
"bytesRead",
|
|
123
|
+
"writes",
|
|
124
|
+
"valueBytes"
|
|
125
|
+
]);
|
|
126
|
+
var count = (value) => value.toLocaleString("en-US");
|
|
127
|
+
var limitMessages = {
|
|
128
|
+
scanCalls: (maximum, requested) => `This invocation made ${count(requested)} index queries; the limit is ${count(maximum)}. Each first(), take(), collect(), count() or paginate() call on withIndex(...) counts once. Read related rows with one take() or paginate() over a shared index prefix instead of one first() per item, use get(id) for known IDs, or split the work across workflow steps.`,
|
|
129
|
+
directGets: (maximum, requested) => `This invocation made ${count(requested)} get(id) calls, including those made by update and delete; the limit is ${count(maximum)}. Split the work across workflow steps or mutations.`,
|
|
130
|
+
rowsRead: (maximum, requested) => `This invocation scanned ${count(requested)} rows; the limit is ${count(maximum)}. Narrow the index range, or page with paginate() across calls or workflow steps.`,
|
|
131
|
+
rowsReturned: (maximum, requested) => `This invocation returned ${count(requested)} rows; the limit is ${count(maximum)}. collect() fails rather than truncating. Page with paginate() across calls or workflow steps.`,
|
|
132
|
+
pageSize: (maximum, requested) => `One call asked for ${count(requested)} rows; take(n) and paginate({ numItems }) accept at most ${count(maximum)}. Page with paginate() across calls or workflow steps.`,
|
|
133
|
+
bytesRead: (maximum, requested) => `This invocation read ${count(requested)} bytes; the limit is ${count(maximum)}. Read fewer or smaller rows per call, or page with paginate() across calls or workflow steps.`,
|
|
134
|
+
writes: (maximum, requested) => `This mutation made ${count(requested)} writes; the limit is ${count(maximum)}. Split large ingests into batches, one batch per mutation or workflow step.`,
|
|
135
|
+
valueBytes: (maximum, requested) => `A row encodes to ${count(requested)} bytes; each row may use at most ${count(maximum)}. Store large content outside the row or split it across rows.`
|
|
136
|
+
};
|
|
137
|
+
var DatabaseLimitExceeded = class extends Schema_exports.TaggedError()(
|
|
138
|
+
"DatabaseLimitExceeded",
|
|
139
|
+
{
|
|
140
|
+
limit: DatabaseLimit,
|
|
141
|
+
maximum: Schema_exports.Int,
|
|
142
|
+
requested: Schema_exports.Int
|
|
143
|
+
}
|
|
144
|
+
) {
|
|
145
|
+
get message() {
|
|
146
|
+
return limitMessages[this.limit](this.maximum, this.requested);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
var reservedFieldNames = ["id", "createdAt", "updatedAt"];
|
|
150
|
+
var DatabaseFieldReserved = class extends Schema_exports.TaggedError()(
|
|
151
|
+
"DatabaseFieldReserved",
|
|
152
|
+
{
|
|
153
|
+
table: Schema_exports.String,
|
|
154
|
+
field: Schema_exports.Literals(reservedFieldNames)
|
|
155
|
+
}
|
|
156
|
+
) {
|
|
157
|
+
get message() {
|
|
158
|
+
return `Table "${this.table}" declares "${this.field}", which is reserved: the host adds id, createdAt and updatedAt to every row. Rename the field, or use the row's own ${this.field}.`;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
116
161
|
var DatabaseRuntimeLimits = Schema_exports.Struct({
|
|
117
162
|
maxCursorChars: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
|
|
118
163
|
connectionCacheCapacity: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
|
|
@@ -134,5 +179,8 @@ export {
|
|
|
134
179
|
AppDatabaseError,
|
|
135
180
|
DatabaseLimits,
|
|
136
181
|
defaultDatabaseLimits,
|
|
182
|
+
DatabaseLimitExceeded,
|
|
183
|
+
reservedFieldNames,
|
|
184
|
+
DatabaseFieldReserved,
|
|
137
185
|
defaultDatabaseRuntimeLimits
|
|
138
186
|
};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CacheAcquired,
|
|
3
|
+
CacheEntry,
|
|
4
|
+
CacheError,
|
|
5
|
+
cacheLimits
|
|
6
|
+
} from "./chunk-R3EV5FTO.js";
|
|
7
|
+
import {
|
|
8
|
+
Clock_exports,
|
|
9
|
+
Duration_exports,
|
|
10
|
+
Effect_exports,
|
|
11
|
+
Exit_exports,
|
|
12
|
+
Schema_exports
|
|
13
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
14
|
+
|
|
15
|
+
// ../app-cache/src/index.ts
|
|
16
|
+
var canonical = (value) => {
|
|
17
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
18
|
+
if (value !== null && typeof value === "object")
|
|
19
|
+
return `{${Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(",")}}`;
|
|
20
|
+
return JSON.stringify(value);
|
|
21
|
+
};
|
|
22
|
+
var cacheKey = (key) => Effect_exports.gen(function* () {
|
|
23
|
+
const parsed = yield* Schema_exports.decodeUnknownEffect(Schema_exports.Json)(key).pipe(
|
|
24
|
+
Effect_exports.mapError(() => new CacheError({ reason: "invalid" }))
|
|
25
|
+
);
|
|
26
|
+
const bytes = new TextEncoder().encode(canonical(parsed));
|
|
27
|
+
if (bytes.byteLength > cacheLimits.keyBytes)
|
|
28
|
+
return yield* new CacheError({ reason: "capacity" });
|
|
29
|
+
const hash = yield* Effect_exports.tryPromise({
|
|
30
|
+
try: () => crypto.subtle.digest("SHA-256", bytes),
|
|
31
|
+
catch: () => new CacheError({ reason: "invalid" })
|
|
32
|
+
});
|
|
33
|
+
return [...new Uint8Array(hash)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
34
|
+
});
|
|
35
|
+
var makeCache = (host, background, scope = "shared", deadline) => {
|
|
36
|
+
const transport = (command) => host(command).pipe(
|
|
37
|
+
Effect_exports.withSpan("app.cache.command", {
|
|
38
|
+
attributes: { "cache.operation": command.operation }
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
const keyOf = (key) => cacheKey([scope, key]);
|
|
42
|
+
const readKeys = (keys) => transport({ operation: "read", keys }).pipe(
|
|
43
|
+
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(Schema_exports.NullOr(CacheEntry)))),
|
|
44
|
+
Effect_exports.mapError(() => new CacheError({ reason: "storage" }))
|
|
45
|
+
);
|
|
46
|
+
const durations = (freshFor, staleFor = 0) => Effect_exports.try({
|
|
47
|
+
try: () => {
|
|
48
|
+
const fresh = Duration_exports.toMillis(Duration_exports.fromInputUnsafe(freshFor));
|
|
49
|
+
const stale = Duration_exports.toMillis(Duration_exports.fromInputUnsafe(staleFor));
|
|
50
|
+
if (![fresh, stale].every((value) => Number.isFinite(value) && value >= 0) || fresh + stale > cacheLimits.retentionMs)
|
|
51
|
+
throw new CacheError({ reason: "invalid" });
|
|
52
|
+
return { fresh, stale };
|
|
53
|
+
},
|
|
54
|
+
catch: () => new CacheError({ reason: "invalid" })
|
|
55
|
+
});
|
|
56
|
+
const get = (options, refresh) => Effect_exports.gen(function* () {
|
|
57
|
+
const key = yield* keyOf(options.key);
|
|
58
|
+
const { fresh, stale } = yield* durations(options.freshFor, options.staleFor);
|
|
59
|
+
const decode = (value) => Schema_exports.decodeUnknownEffect(options.schema)(value);
|
|
60
|
+
const load = (lease) => Effect_exports.gen(function* () {
|
|
61
|
+
const value = yield* options.load.pipe(Effect_exports.flatMap(decode));
|
|
62
|
+
const json = yield* Schema_exports.decodeUnknownEffect(Schema_exports.Json)(value).pipe(
|
|
63
|
+
Effect_exports.mapError(() => new CacheError({ reason: "invalid" }))
|
|
64
|
+
);
|
|
65
|
+
const now = yield* Clock_exports.currentTimeMillis;
|
|
66
|
+
const published = yield* transport({
|
|
67
|
+
operation: "publish",
|
|
68
|
+
key,
|
|
69
|
+
lease,
|
|
70
|
+
entry: {
|
|
71
|
+
value: json,
|
|
72
|
+
version: crypto.randomUUID(),
|
|
73
|
+
freshUntil: now + fresh,
|
|
74
|
+
staleUntil: now + fresh + stale
|
|
75
|
+
}
|
|
76
|
+
}).pipe(Effect_exports.withSpan("app.cache.publish"));
|
|
77
|
+
if (published !== true) return yield* new CacheError({ reason: "unavailable" });
|
|
78
|
+
return value;
|
|
79
|
+
}).pipe(
|
|
80
|
+
Effect_exports.withSpan("app.cache.load"),
|
|
81
|
+
Effect_exports.timeout(cacheLimits.loadTimeoutMs),
|
|
82
|
+
// Publishing clears the lease in the same transaction. Only an unpublished load releases it.
|
|
83
|
+
Effect_exports.onExit(
|
|
84
|
+
(exit) => Exit_exports.isSuccess(exit) ? Effect_exports.void : transport({ operation: "release", key, lease }).pipe(
|
|
85
|
+
Effect_exports.catch(() => Effect_exports.void)
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
const waitUntil = Math.min(
|
|
90
|
+
(yield* Clock_exports.currentTimeMillis) + cacheLimits.waitMs,
|
|
91
|
+
deadline ?? Number.POSITIVE_INFINITY
|
|
92
|
+
);
|
|
93
|
+
let initialVersion;
|
|
94
|
+
while (true) {
|
|
95
|
+
const { entry, lease } = yield* transport({
|
|
96
|
+
operation: "acquire",
|
|
97
|
+
key,
|
|
98
|
+
refresh,
|
|
99
|
+
...initialVersion === void 0 ? {} : { version: initialVersion }
|
|
100
|
+
}).pipe(
|
|
101
|
+
Effect_exports.flatMap(
|
|
102
|
+
(reply) => Schema_exports.decodeUnknownEffect(CacheAcquired)(reply).pipe(
|
|
103
|
+
Effect_exports.mapError(() => new CacheError({ reason: "storage" }))
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
const now = yield* Clock_exports.currentTimeMillis;
|
|
108
|
+
if (initialVersion === void 0) initialVersion = entry?.version ?? null;
|
|
109
|
+
const refreshed = refresh && entry !== null && entry.version !== initialVersion;
|
|
110
|
+
if (entry !== null && (refreshed || !refresh && lease === null && now < entry.freshUntil)) {
|
|
111
|
+
yield* Effect_exports.annotateCurrentSpan("cache.result", "fresh");
|
|
112
|
+
return yield* decode(entry.value);
|
|
113
|
+
}
|
|
114
|
+
if (!refresh && entry !== null && now < entry.staleUntil) {
|
|
115
|
+
yield* Effect_exports.annotateCurrentSpan("cache.result", "stale");
|
|
116
|
+
if (lease !== null) yield* background(load(lease).pipe(Effect_exports.asVoid));
|
|
117
|
+
return yield* decode(entry.value);
|
|
118
|
+
}
|
|
119
|
+
if (lease !== null) {
|
|
120
|
+
yield* Effect_exports.annotateCurrentSpan("cache.result", "miss");
|
|
121
|
+
return yield* load(lease);
|
|
122
|
+
}
|
|
123
|
+
if (now >= waitUntil) {
|
|
124
|
+
yield* Effect_exports.annotateCurrentSpan("cache.result", "local");
|
|
125
|
+
return yield* options.load.pipe(
|
|
126
|
+
Effect_exports.flatMap(decode),
|
|
127
|
+
Effect_exports.timeout(cacheLimits.loadTimeoutMs),
|
|
128
|
+
Effect_exports.withSpan("app.cache.load", { attributes: { "cache.load.leased": false } })
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
yield* Effect_exports.sleep("100 millis");
|
|
132
|
+
}
|
|
133
|
+
}).pipe(Effect_exports.withSpan("app.cache.get"));
|
|
134
|
+
return {
|
|
135
|
+
/** Read arbitrary retained JSON entries without initiating a refresh. Missing and null are distinct. */
|
|
136
|
+
read: (keys) => Effect_exports.forEach(keys, keyOf).pipe(Effect_exports.flatMap(readKeys)),
|
|
137
|
+
/** Publish bounded immutable parts before publishing the manifest that references them. */
|
|
138
|
+
write: (entries, retention) => Effect_exports.gen(function* () {
|
|
139
|
+
const { fresh } = yield* durations(retention);
|
|
140
|
+
const now = yield* Clock_exports.currentTimeMillis;
|
|
141
|
+
const values = yield* Effect_exports.forEach(
|
|
142
|
+
entries,
|
|
143
|
+
({ key, value }) => Effect_exports.gen(function* () {
|
|
144
|
+
return {
|
|
145
|
+
key: yield* keyOf(key),
|
|
146
|
+
entry: {
|
|
147
|
+
value,
|
|
148
|
+
version: crypto.randomUUID(),
|
|
149
|
+
freshUntil: now + fresh,
|
|
150
|
+
staleUntil: now + fresh
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
})
|
|
154
|
+
);
|
|
155
|
+
yield* transport({ operation: "write", entries: values });
|
|
156
|
+
}),
|
|
157
|
+
/** Revoke retained data and any loader's right to publish its in-flight result. */
|
|
158
|
+
invalidate: (key) => keyOf(key).pipe(
|
|
159
|
+
Effect_exports.flatMap((key2) => transport({ operation: "invalidate", key: key2 })),
|
|
160
|
+
Effect_exports.asVoid
|
|
161
|
+
),
|
|
162
|
+
/** Read fresh data, refresh stale data in the background, or wait for the lease owner. */
|
|
163
|
+
get: (options) => get(options, false),
|
|
164
|
+
/** Force one awaited refresh without removing the retained value. Concurrent refreshes share a load. */
|
|
165
|
+
revalidate: (options) => get(options, true)
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export {
|
|
170
|
+
cacheKey,
|
|
171
|
+
makeCache
|
|
172
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FetchHttpClient_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-57RKNWL2.js";
|
|
4
4
|
import {
|
|
5
5
|
HttpBody_exports,
|
|
6
6
|
HttpClient,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
setBody,
|
|
19
19
|
transformResponse,
|
|
20
20
|
uint8Array
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-UK573G7W.js";
|
|
22
22
|
import {
|
|
23
23
|
Array as Array2,
|
|
24
24
|
Boolean2 as Boolean,
|
|
@@ -125,7 +125,7 @@ import {
|
|
|
125
125
|
withDefault2 as withDefault,
|
|
126
126
|
withTracerEnabled,
|
|
127
127
|
zero
|
|
128
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
129
129
|
import {
|
|
130
130
|
__export
|
|
131
131
|
} from "./chunk-CZ7CSFO4.js";
|
|
@@ -2508,7 +2508,6 @@ export {
|
|
|
2508
2508
|
withRemoteSpan,
|
|
2509
2509
|
invocationFetch,
|
|
2510
2510
|
collectTelemetry,
|
|
2511
|
-
TraceContext,
|
|
2512
2511
|
externalTrace,
|
|
2513
2512
|
traceLinks,
|
|
2514
2513
|
pendingSpan
|
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
useSpan,
|
|
59
59
|
void_2 as void_,
|
|
60
60
|
withFiber
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
62
62
|
|
|
63
63
|
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/reactivity/Reactivity.js
|
|
64
64
|
var TypeId = "~effect/reactivity/Reactivity";
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountId
|
|
3
|
+
} from "./chunk-27F7W2LG.js";
|
|
4
|
+
import {
|
|
5
|
+
Schema_exports
|
|
6
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
7
|
+
|
|
8
|
+
// src/contracts/provider-error.ts
|
|
9
|
+
var ProviderError = class extends Schema_exports.TaggedError()("ProviderError", {
|
|
10
|
+
reason: Schema_exports.Literals(["unauthorized", "forbidden", "rate_limited", "unavailable", "rejected"]),
|
|
11
|
+
status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 }))),
|
|
12
|
+
accountId: Schema_exports.optional(AccountId)
|
|
13
|
+
}) {
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// ../app-cache/src/contracts/cache.ts
|
|
17
|
+
var CacheError = class extends Schema_exports.TaggedError()("CacheError", {
|
|
18
|
+
reason: Schema_exports.Literals(["unavailable", "storage", "invalid", "capacity", "timeout"])
|
|
19
|
+
}) {
|
|
20
|
+
};
|
|
21
|
+
var cacheLimits = {
|
|
22
|
+
keyBytes: 8192,
|
|
23
|
+
entryBytes: 2e6,
|
|
24
|
+
batchBytes: 8e6,
|
|
25
|
+
batchEntries: 128,
|
|
26
|
+
totalBytes: 128e6,
|
|
27
|
+
totalEntries: 1e5,
|
|
28
|
+
retentionMs: 7 * 24 * 60 * 60 * 1e3,
|
|
29
|
+
loadTimeoutMs: 9e4,
|
|
30
|
+
/**
|
|
31
|
+
* A loader's lease lapses this long after its host last renewed it. Hosts renew every
|
|
32
|
+
* `renewMs` while the invocation that claimed it runs, so a stalled or lost holder frees the
|
|
33
|
+
* key well inside an MCP execute budget.
|
|
34
|
+
*/
|
|
35
|
+
leaseMs: 15e3,
|
|
36
|
+
renewMs: 5e3,
|
|
37
|
+
/** The longest a caller waits on another loader before loading for itself without publishing. */
|
|
38
|
+
waitMs: 1e4,
|
|
39
|
+
/** Bound for one command to a host store; a lost reply fails instead of holding its caller. */
|
|
40
|
+
commandTimeoutMs: 1e4
|
|
41
|
+
};
|
|
42
|
+
var Key = Schema_exports.String.check(Schema_exports.isPattern(/^[a-f0-9]{64}$/));
|
|
43
|
+
var Time = Schema_exports.Finite.check(Schema_exports.isGreaterThanOrEqualTo(0));
|
|
44
|
+
var CacheEntry = Schema_exports.Struct({
|
|
45
|
+
value: Schema_exports.Json,
|
|
46
|
+
version: Schema_exports.String,
|
|
47
|
+
freshUntil: Time,
|
|
48
|
+
staleUntil: Time
|
|
49
|
+
});
|
|
50
|
+
var CacheAcquired = Schema_exports.Struct({
|
|
51
|
+
entry: Schema_exports.NullOr(CacheEntry),
|
|
52
|
+
lease: Schema_exports.NullOr(Schema_exports.String)
|
|
53
|
+
});
|
|
54
|
+
var CacheCommand = Schema_exports.Union([
|
|
55
|
+
Schema_exports.Struct({ operation: Schema_exports.Literal("read"), keys: Schema_exports.Array(Key) }),
|
|
56
|
+
Schema_exports.Struct({
|
|
57
|
+
operation: Schema_exports.Literal("acquire"),
|
|
58
|
+
key: Key,
|
|
59
|
+
/** Claim even a fresh entry, as an explicit refresh does. */
|
|
60
|
+
refresh: Schema_exports.Boolean,
|
|
61
|
+
/** Claim only while the entry still has this version. Absent accepts the current one. */
|
|
62
|
+
version: Schema_exports.optionalKey(Schema_exports.NullOr(Schema_exports.String))
|
|
63
|
+
}),
|
|
64
|
+
Schema_exports.Struct({
|
|
65
|
+
operation: Schema_exports.Literal("claim"),
|
|
66
|
+
key: Key,
|
|
67
|
+
version: Schema_exports.NullOr(Schema_exports.String)
|
|
68
|
+
}),
|
|
69
|
+
Schema_exports.Struct({
|
|
70
|
+
operation: Schema_exports.Literal("publish"),
|
|
71
|
+
key: Key,
|
|
72
|
+
lease: Schema_exports.String,
|
|
73
|
+
entry: CacheEntry
|
|
74
|
+
}),
|
|
75
|
+
Schema_exports.Struct({ operation: Schema_exports.Literal("release"), key: Key, lease: Schema_exports.String }),
|
|
76
|
+
/** Extend a lease its holder still owns. Replies false once the lease lapsed or was replaced. */
|
|
77
|
+
Schema_exports.Struct({ operation: Schema_exports.Literal("renew"), key: Key, lease: Schema_exports.String }),
|
|
78
|
+
Schema_exports.Struct({
|
|
79
|
+
operation: Schema_exports.Literal("write"),
|
|
80
|
+
entries: Schema_exports.Array(Schema_exports.Struct({ key: Key, entry: CacheEntry }))
|
|
81
|
+
}),
|
|
82
|
+
Schema_exports.Struct({ operation: Schema_exports.Literal("invalidate"), key: Key })
|
|
83
|
+
]);
|
|
84
|
+
var CacheReply = Schema_exports.Union([
|
|
85
|
+
Schema_exports.Struct({ ok: Schema_exports.Literal(true), value: Schema_exports.Json }),
|
|
86
|
+
Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: CacheError })
|
|
87
|
+
]);
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
ProviderError,
|
|
91
|
+
CacheError,
|
|
92
|
+
cacheLimits,
|
|
93
|
+
CacheEntry,
|
|
94
|
+
CacheAcquired,
|
|
95
|
+
CacheCommand,
|
|
96
|
+
CacheReply
|
|
97
|
+
};
|