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,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AppSkillMetadata,
|
|
3
|
+
AppSkillName,
|
|
4
|
+
AppSkillSource,
|
|
5
|
+
SkillDefinitionInvalid,
|
|
6
|
+
SkillFile,
|
|
7
|
+
SkillFilePath
|
|
8
|
+
} from "./chunk-JU7VHODU.js";
|
|
9
|
+
import {
|
|
10
|
+
Effect_exports,
|
|
11
|
+
Schema_exports
|
|
12
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
13
|
+
|
|
14
|
+
// src/implementation/skill-files.ts
|
|
15
|
+
var skillFromFiles = (input, source = {}) => Effect_exports.gen(function* () {
|
|
16
|
+
const file = `${source.directory === void 0 ? "" : `${source.directory}/`}SKILL.md`;
|
|
17
|
+
const invalid = (reason) => new SkillDefinitionInvalid({ file, reason });
|
|
18
|
+
const files = yield* Schema_exports.decodeUnknownEffect(Schema_exports.Array(SkillFile))(input).pipe(
|
|
19
|
+
Effect_exports.mapError(() => invalid("files"))
|
|
20
|
+
);
|
|
21
|
+
const document = files.find((file2) => file2.path === "SKILL.md");
|
|
22
|
+
if (document === void 0) return yield* invalid("missing-document");
|
|
23
|
+
const match = /^\uFEFF?---[ \t]*\r?\n([\s\S]*?)\r?\n---(?:[ \t]*\r?\n|[ \t]*$)/.exec(
|
|
24
|
+
document.content
|
|
25
|
+
);
|
|
26
|
+
if (match?.[1] === void 0) return yield* invalid("frontmatter");
|
|
27
|
+
const frontmatter = match[1];
|
|
28
|
+
const { parseDocument } = (yield* Effect_exports.promise(() => import("./browser-XIPJGLH2.js"))).default;
|
|
29
|
+
const value = yield* Effect_exports.try({
|
|
30
|
+
try: () => {
|
|
31
|
+
const yaml = parseDocument(frontmatter);
|
|
32
|
+
if (yaml.errors.length) throw yaml.errors[0];
|
|
33
|
+
return yaml.toJS();
|
|
34
|
+
},
|
|
35
|
+
catch: () => invalid("frontmatter")
|
|
36
|
+
});
|
|
37
|
+
const metadata = yield* Schema_exports.decodeUnknownEffect(AppSkillMetadata)(value).pipe(
|
|
38
|
+
Effect_exports.mapError(() => invalid("metadata"))
|
|
39
|
+
);
|
|
40
|
+
if (source.name !== void 0 && metadata.name !== source.name)
|
|
41
|
+
return yield* invalid("name-mismatch");
|
|
42
|
+
return yield* Schema_exports.decodeUnknownEffect(AppSkillSource)({ ...metadata, files }).pipe(
|
|
43
|
+
Effect_exports.mapError(() => invalid("files"))
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
var folderSkillsEffect = (options) => Effect_exports.gen(function* () {
|
|
47
|
+
const path = options.path ?? "skills";
|
|
48
|
+
if (!Schema_exports.is(SkillFilePath)(path))
|
|
49
|
+
return yield* new SkillDefinitionInvalid({ file: "SKILL.md", reason: "directory" });
|
|
50
|
+
const files = yield* Schema_exports.decodeUnknownEffect(Schema_exports.Array(SkillFile))(options.files).pipe(
|
|
51
|
+
Effect_exports.mapError(() => new SkillDefinitionInvalid({ file: path, reason: "files" }))
|
|
52
|
+
);
|
|
53
|
+
const prefix = `${path}/`;
|
|
54
|
+
const directories = /* @__PURE__ */ new Map();
|
|
55
|
+
for (const file of files) {
|
|
56
|
+
if (!file.path.startsWith(prefix)) continue;
|
|
57
|
+
const [name, ...relative] = file.path.slice(prefix.length).split("/");
|
|
58
|
+
if (relative.length === 0) continue;
|
|
59
|
+
if (name === void 0 || !Schema_exports.is(AppSkillName)(name))
|
|
60
|
+
return yield* new SkillDefinitionInvalid({ file: file.path, reason: "directory" });
|
|
61
|
+
const resource = { path: relative.join("/"), content: file.content };
|
|
62
|
+
const existing = directories.get(name);
|
|
63
|
+
if (existing === void 0) directories.set(name, [resource]);
|
|
64
|
+
else existing.push(resource);
|
|
65
|
+
}
|
|
66
|
+
return yield* Effect_exports.forEach(
|
|
67
|
+
[...directories].sort(([a], [b]) => a.localeCompare(b)),
|
|
68
|
+
([name, files2]) => skillFromFiles(
|
|
69
|
+
files2.sort((a, b) => a.path.localeCompare(b.path)),
|
|
70
|
+
{ name, directory: `${path}/${name}` }
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
skillFromFiles,
|
|
77
|
+
folderSkillsEffect
|
|
78
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Schema_exports
|
|
3
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
4
|
+
|
|
5
|
+
// src/contracts/skills.ts
|
|
6
|
+
var SkillFilePath = Schema_exports.NonEmptyString.check(
|
|
7
|
+
Schema_exports.makeFilter(
|
|
8
|
+
(path) => !path.startsWith("/") && !path.includes("\\") && !path.includes("\0") && path.split("/").every((part) => part !== "" && part !== "." && part !== "..")
|
|
9
|
+
)
|
|
10
|
+
);
|
|
11
|
+
var SkillFile = Schema_exports.Struct({ path: SkillFilePath, content: Schema_exports.String });
|
|
12
|
+
var skillFormatLimits = {
|
|
13
|
+
nameCharacters: 64,
|
|
14
|
+
descriptionCharacters: 1024,
|
|
15
|
+
compatibilityCharacters: 500
|
|
16
|
+
};
|
|
17
|
+
var AppSkillName = Schema_exports.NonEmptyString.check(
|
|
18
|
+
Schema_exports.makeFilter(
|
|
19
|
+
(value) => value === value.toLowerCase() && /^[\p{L}\p{N}]+(?:-[\p{L}\p{N}]+)*$/u.test(value) && [...value].length <= skillFormatLimits.nameCharacters
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
var AppSkillMetadata = Schema_exports.Struct({
|
|
23
|
+
name: AppSkillName,
|
|
24
|
+
description: Schema_exports.String.check(
|
|
25
|
+
Schema_exports.makeFilter(
|
|
26
|
+
(value) => value.trim().length > 0 && [...value].length <= skillFormatLimits.descriptionCharacters
|
|
27
|
+
)
|
|
28
|
+
),
|
|
29
|
+
license: Schema_exports.optionalKey(Schema_exports.String),
|
|
30
|
+
compatibility: Schema_exports.optionalKey(
|
|
31
|
+
Schema_exports.String.check(
|
|
32
|
+
Schema_exports.makeFilter(
|
|
33
|
+
(value) => value.trim().length > 0 && [...value].length <= skillFormatLimits.compatibilityCharacters
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
),
|
|
37
|
+
metadata: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.String, Schema_exports.String)),
|
|
38
|
+
"allowed-tools": Schema_exports.optionalKey(Schema_exports.String)
|
|
39
|
+
});
|
|
40
|
+
var AppSkillSource = Schema_exports.Struct({
|
|
41
|
+
...AppSkillMetadata.fields,
|
|
42
|
+
files: Schema_exports.Array(SkillFile).check(
|
|
43
|
+
Schema_exports.makeFilter(
|
|
44
|
+
(files) => files.some((file) => file.path === "SKILL.md") && new Set(files.map((file) => file.path)).size === files.length
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
});
|
|
48
|
+
var SkillDefinitionInvalid = class extends Schema_exports.TaggedError()(
|
|
49
|
+
"SkillDefinitionInvalid",
|
|
50
|
+
{
|
|
51
|
+
file: SkillFilePath,
|
|
52
|
+
reason: Schema_exports.Literals([
|
|
53
|
+
"files",
|
|
54
|
+
"directory",
|
|
55
|
+
"missing-document",
|
|
56
|
+
"frontmatter",
|
|
57
|
+
"metadata",
|
|
58
|
+
"name-mismatch"
|
|
59
|
+
])
|
|
60
|
+
},
|
|
61
|
+
{ httpApiStatus: 400 }
|
|
62
|
+
) {
|
|
63
|
+
};
|
|
64
|
+
var AppSkills = Schema_exports.Array(AppSkillSource).check(
|
|
65
|
+
Schema_exports.makeFilter((skills) => new Set(skills.map((skill) => skill.name)).size === skills.length)
|
|
66
|
+
);
|
|
67
|
+
var SkillServiceName = Schema_exports.String.check(
|
|
68
|
+
Schema_exports.isPattern(/^[A-Za-z0-9](?:[A-Za-z0-9 .-]{0,98}[A-Za-z0-9])?$/)
|
|
69
|
+
);
|
|
70
|
+
var SkillLoadFailed = class extends Schema_exports.TaggedError()("SkillLoadFailed", {
|
|
71
|
+
reason: Schema_exports.Literals([
|
|
72
|
+
"source",
|
|
73
|
+
"request",
|
|
74
|
+
"rate_limited",
|
|
75
|
+
"document",
|
|
76
|
+
"limit",
|
|
77
|
+
"changed",
|
|
78
|
+
"encoding"
|
|
79
|
+
]),
|
|
80
|
+
// Error instances read an omitted message as "", so an empty message means none was given.
|
|
81
|
+
message: Schema_exports.optional(Schema_exports.String.check(Schema_exports.isMaxLength(500))),
|
|
82
|
+
status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 })))
|
|
83
|
+
}) {
|
|
84
|
+
};
|
|
85
|
+
var skillLoadLimits = {
|
|
86
|
+
files: 1e3,
|
|
87
|
+
fileBytes: 2e6,
|
|
88
|
+
totalBytes: 2e7,
|
|
89
|
+
concurrency: 8
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
SkillFilePath,
|
|
94
|
+
SkillFile,
|
|
95
|
+
skillFormatLimits,
|
|
96
|
+
AppSkillName,
|
|
97
|
+
AppSkillMetadata,
|
|
98
|
+
AppSkillSource,
|
|
99
|
+
SkillDefinitionInvalid,
|
|
100
|
+
AppSkills,
|
|
101
|
+
SkillServiceName,
|
|
102
|
+
SkillLoadFailed,
|
|
103
|
+
skillLoadLimits
|
|
104
|
+
};
|
|
@@ -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,12 +158,12 @@ 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
|
-
} from "./chunk-
|
|
164
|
+
} from "./chunk-CZ7CSFO4.js";
|
|
165
165
|
|
|
166
|
-
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@
|
|
166
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/reactivity/AsyncResult.js
|
|
167
167
|
var AsyncResult_exports = {};
|
|
168
168
|
__export(AsyncResult_exports, {
|
|
169
169
|
Schema: () => Schema,
|
|
@@ -600,7 +600,7 @@ var Schema = (options) => {
|
|
|
600
600
|
});
|
|
601
601
|
};
|
|
602
602
|
|
|
603
|
-
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@
|
|
603
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/reactivity/AtomRegistry.js
|
|
604
604
|
var AtomRegistry_exports = {};
|
|
605
605
|
__export(AtomRegistry_exports, {
|
|
606
606
|
AtomRegistry: () => AtomRegistry,
|
|
@@ -1340,7 +1340,7 @@ function batchRebuildNode(node) {
|
|
|
1340
1340
|
}
|
|
1341
1341
|
}
|
|
1342
1342
|
|
|
1343
|
-
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@
|
|
1343
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/reactivity/Atom.js
|
|
1344
1344
|
var Atom_exports = {};
|
|
1345
1345
|
__export(Atom_exports, {
|
|
1346
1346
|
Interrupt: () => Interrupt,
|
|
@@ -1400,7 +1400,7 @@ __export(Atom_exports, {
|
|
|
1400
1400
|
writable: () => writable
|
|
1401
1401
|
});
|
|
1402
1402
|
|
|
1403
|
-
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@
|
|
1403
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/persistence/KeyValueStore.js
|
|
1404
1404
|
var ErrorTypeId = "~effect/persistence/KeyValueStore/KeyValueStoreError";
|
|
1405
1405
|
var KeyValueStoreError = class extends (/* @__PURE__ */ TaggedError("KeyValueStoreError")) {
|
|
1406
1406
|
/**
|
|
@@ -1442,7 +1442,7 @@ var toSchemaStore = (self, schema) => {
|
|
|
1442
1442
|
};
|
|
1443
1443
|
};
|
|
1444
1444
|
|
|
1445
|
-
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@
|
|
1445
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/reactivity/Atom.js
|
|
1446
1446
|
var TypeId3 = "~effect/reactivity/Atom";
|
|
1447
1447
|
var isAtom = (u) => hasProperty(u, TypeId3);
|
|
1448
1448
|
var WritableTypeId = "~effect/reactivity/Atom/Writable";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProviderError
|
|
3
|
+
} from "./chunk-R3EV5FTO.js";
|
|
4
|
+
import {
|
|
5
|
+
AccountId
|
|
6
|
+
} from "./chunk-27F7W2LG.js";
|
|
7
|
+
import {
|
|
8
|
+
Option_exports,
|
|
9
|
+
Schema_exports
|
|
10
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
11
|
+
|
|
12
|
+
// src/implementation/provider-error.ts
|
|
13
|
+
function parseProviderError(error) {
|
|
14
|
+
return Schema_exports.decodeUnknownOption(ProviderError)(error).pipe(
|
|
15
|
+
Option_exports.map(({ reason, status, accountId }) => new ProviderError({ reason, status, accountId }))
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function httpProviderError(status, headers = {}) {
|
|
19
|
+
if (status >= 500 && status <= 599) return new ProviderError({ reason: "unavailable", status });
|
|
20
|
+
if (status === 401) return new ProviderError({ reason: "unauthorized", status });
|
|
21
|
+
if (status === 429) return new ProviderError({ reason: "rate_limited", status });
|
|
22
|
+
if (status !== 403) return void 0;
|
|
23
|
+
const retry = headers["retry-after"];
|
|
24
|
+
if (headers["x-ratelimit-remaining"] === "0" || retry !== void 0 && (/^\d+$/.test(retry) || Number.isFinite(Date.parse(retry))))
|
|
25
|
+
return new ProviderError({ reason: "rate_limited", status });
|
|
26
|
+
if (/\bBearer\b.*\berror="insufficient_scope"/i.test(headers["www-authenticate"] ?? ""))
|
|
27
|
+
return new ProviderError({ reason: "forbidden", status });
|
|
28
|
+
return new ProviderError({ reason: "rejected", status });
|
|
29
|
+
}
|
|
30
|
+
function accountProviderError(error, accountId) {
|
|
31
|
+
const parsed = parseProviderError(error);
|
|
32
|
+
const account = Schema_exports.decodeUnknownOption(AccountId)(accountId);
|
|
33
|
+
if (Option_exports.isNone(parsed) || Option_exports.isNone(account)) return error;
|
|
34
|
+
return new ProviderError({
|
|
35
|
+
reason: parsed.value.reason,
|
|
36
|
+
status: parsed.value.status,
|
|
37
|
+
accountId: account.value
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function graphqlProviderError(errors, status) {
|
|
41
|
+
const codes = errors.flatMap((error) => {
|
|
42
|
+
const parsed = Schema_exports.decodeUnknownOption(
|
|
43
|
+
Schema_exports.Struct({
|
|
44
|
+
type: Schema_exports.optional(Schema_exports.String),
|
|
45
|
+
extensions: Schema_exports.optional(Schema_exports.Struct({ code: Schema_exports.optional(Schema_exports.String) }))
|
|
46
|
+
})
|
|
47
|
+
)(error);
|
|
48
|
+
return Option_exports.isSome(parsed) ? [parsed.value.type, parsed.value.extensions?.code] : [];
|
|
49
|
+
});
|
|
50
|
+
if (codes.includes("RATE_LIMITED") || codes.includes("TOO_MANY_REQUESTS"))
|
|
51
|
+
return new ProviderError({ reason: "rate_limited", status });
|
|
52
|
+
if (codes.includes("UNAUTHENTICATED"))
|
|
53
|
+
return new ProviderError({ reason: "unauthorized", status });
|
|
54
|
+
if (codes.includes("FORBIDDEN")) return new ProviderError({ reason: "forbidden", status });
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
parseProviderError,
|
|
60
|
+
httpProviderError,
|
|
61
|
+
accountProviderError,
|
|
62
|
+
graphqlProviderError
|
|
63
|
+
};
|
|
@@ -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
|
+
};
|