apps 0.0.1-beta.4 → 0.0.1-beta.40
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 +68 -44
- package/framework-reference.json +1 -1
- package/js/{chunk-QKHR7BMF.js → chunk-3MMG2H6M.js} +89 -53
- package/js/chunk-4TLZGG4B.js +729 -0
- package/js/chunk-6KABJTDO.js +255 -0
- package/js/{chunk-FDNTX5QJ.js → chunk-CQD3WSYH.js} +2 -2
- package/js/{chunk-EQB7JMAL.js → chunk-DHX2OI2X.js} +146 -31
- package/js/{chunk-EVJUVWN2.js → chunk-DKUEYTYD.js} +463 -218
- package/js/chunk-EM4UL26F.js +118 -0
- package/js/{chunk-WFSQXYUT.js → chunk-GHXRRFZA.js} +418 -52
- package/js/{chunk-5MQZEB6Y.js → chunk-KANDIVIH.js} +40 -12
- package/js/chunk-KAQD3DTI.js +16 -0
- package/js/chunk-KIM5HXNK.js +49 -0
- package/js/{chunk-FW5HBOIK.js → chunk-MXDKXAY4.js} +19117 -18309
- package/js/{chunk-2VPJHFOU.js → chunk-MYF7KWUB.js} +128 -24
- package/js/{chunk-T2LAZCAD.js → chunk-NKWWPJYX.js} +3 -3
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-3M2MEDNL.js → chunk-OTCLXFLL.js} +1337 -188
- package/js/chunk-P7MGDPFD.js +240 -0
- package/js/chunk-PDS2E2OZ.js +42 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-PNVCCB4L.js} +432 -79
- package/js/{chunk-D47C7KG5.js → chunk-RIXVGVA6.js} +2 -2
- package/js/{chunk-6VRYO2BG.js → chunk-SALJXSS3.js} +779 -251
- package/js/{chunk-NQ3OMCA5.js → chunk-TT6OU4UG.js} +2 -2
- package/js/{chunk-YEJOQEII.js → chunk-UOZMSUJ2.js} +61 -9
- package/js/{chunk-G7ZIRKMK.js → chunk-VIU2XXA7.js} +228 -264
- package/js/{chunk-HDJH3RPR.js → chunk-VJQXXOQ3.js} +4 -4
- package/js/chunk-XDGUGB2A.js +156 -0
- package/js/{chunk-SATWJKN6.js → chunk-YQ35E7KS.js} +2 -2
- package/js/chunk-ZUKBIHMK.js +92 -0
- package/js/client.js +122 -88
- package/js/contracts.js +116 -25
- package/js/effect.js +19 -20
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +57 -55
- package/js/host.js +19 -20
- package/js/index.js +245 -212
- package/js/mcp/effect.js +23 -22
- package/js/mcp/stdio.js +34 -30
- package/js/mcp.js +104 -68
- package/js/openapi.js +4087 -1503
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +147 -65
- package/js/storage/facet.js +1 -540
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +5 -4
- package/js/ui/serving.js +8517 -214
- package/package.json +2 -3
- package/runtime.json +1 -1
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +7 -8
- package/types/apps/src/contracts/cache.d.ts +14 -0
- package/types/apps/src/contracts/context.d.ts +12 -11
- package/types/apps/src/contracts/elicitation.d.ts +6 -6
- package/types/apps/src/contracts/failure.d.ts +54 -0
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +44 -17
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +96 -10
- package/types/apps/src/contracts/network.d.ts +84 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +32 -3
- package/types/apps/src/contracts/openapi.d.ts +45 -9
- package/types/apps/src/contracts/operations.d.ts +8 -9
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +263 -74
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/2.d.ts +66 -24
- package/types/apps/src/contracts/protocols/3.d.ts +715 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1297 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1174 -0
- package/types/apps/src/contracts/protocols/6.d.ts +1620 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1130 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1106 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +115 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/skills.d.ts +39 -9
- package/types/apps/src/contracts/sql.d.ts +58 -0
- package/types/apps/src/contracts/ui.d.ts +19 -1
- package/types/apps/src/contracts/workflows.d.ts +40 -3
- package/types/apps/src/facet.d.ts +4 -5
- 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/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +32 -5
- package/types/apps/src/implementation/elicitation.d.ts +9 -9
- package/types/apps/src/implementation/failure-detail.d.ts +47 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/input-problems.d.ts +4 -1
- package/types/apps/src/implementation/live.d.ts +2 -2
- package/types/apps/src/implementation/mcp-call.d.ts +6 -5
- package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
- package/types/apps/src/implementation/mcp-client.d.ts +49 -25
- package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +52 -25
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +27 -6
- package/types/apps/src/implementation/openapi-document.d.ts +46 -19
- package/types/apps/src/implementation/openapi-names.d.ts +9 -4
- package/types/apps/src/implementation/openapi-request.d.ts +10 -2
- package/types/apps/src/implementation/openapi-source.d.ts +8 -6
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +36 -3
- package/types/apps/src/implementation/optimistic.d.ts +1 -1
- package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +19 -5
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +223 -0
- package/types/apps/src/implementation/router.d.ts +68 -0
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schema.d.ts +86 -11
- package/types/apps/src/implementation/skills.d.ts +18 -24
- package/types/apps/src/implementation/sql.d.ts +66 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +1 -1
- package/types/apps/src/implementation/ui-client.d.ts +2 -2
- package/types/apps/src/implementation/ui-document.d.ts +5 -0
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +11 -5
- package/types/apps/src/implementation/ui-watch.d.ts +1 -1
- package/types/apps/src/implementation/upstream-error.d.ts +7 -0
- package/types/apps/src/implementation/webhooks.d.ts +1 -1
- package/types/apps/src/implementation/workflow-context.d.ts +11 -3
- package/types/apps/src/index.d.ts +30 -13
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +25 -5
- package/types/apps/src/openapi.d.ts +6 -6
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +10 -8
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +6 -3
- package/types/telemetry/src/browser.d.ts +2 -2
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/layer.d.ts +2 -2
- package/types/telemetry/src/recorded-failure.d.ts +20 -0
- package/types/telemetry/src/relay.d.ts +2 -2
- package/types/telemetry/src/transport.d.ts +8 -1
- package/types/utils/src/api-error.d.ts +53 -0
- package/types/utils/src/recorded-message.d.ts +15 -0
- package/js/chunk-BMOIAIVR.js +0 -138
- package/js/chunk-DHUDODG5.js +0 -213
- package/js/chunk-FZJOYIZO.js +0 -19
- package/js/chunk-LGIYBDWA.js +0 -85
- package/js/chunk-M6ZRRIBI.js +0 -877
- package/js/chunk-PLCMJREA.js +0 -590
- package/js/chunk-PYUYJRSK.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-W7D7WVSY.js +0 -18
- package/js/chunk-Z5NMEGJN.js +0 -29
- package/js/chunk-ZJWDMTE3.js +0 -63
- package/types/app-data/src/implementation/cursor.d.ts +0 -10
- package/types/app-data/src/implementation/index-key.d.ts +0 -7
- package/types/app-data/src/implementation/promise.d.ts +0 -68
- package/types/app-data/src/implementation/range.d.ts +0 -8
- package/types/app-data/src/implementation/schema.d.ts +0 -33
- package/types/app-data/src/implementation/sqlite.d.ts +0 -11
- package/types/app-data/src/index.d.ts +0 -4
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/contracts/storage.d.ts +0 -68
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
- package/types/apps/src/implementation/storage.d.ts +0 -13
package/js/react.js
CHANGED
|
@@ -2,11 +2,10 @@ import {
|
|
|
2
2
|
AsyncResult_exports,
|
|
3
3
|
AtomRegistry_exports,
|
|
4
4
|
queryCommitted
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-M6ZRRIBI.js";
|
|
5
|
+
} from "./chunk-DKUEYTYD.js";
|
|
7
6
|
import {
|
|
8
7
|
Option_exports
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-MXDKXAY4.js";
|
|
10
9
|
import "./chunk-CZ7CSFO4.js";
|
|
11
10
|
|
|
12
11
|
// src/react.ts
|
package/js/skills/effect.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
folderSkillsEffect,
|
|
3
3
|
skillFromFiles
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-CQD3WSYH.js";
|
|
5
|
+
import "../chunk-UOZMSUJ2.js";
|
|
6
|
+
import "../chunk-KAQD3DTI.js";
|
|
7
|
+
import "../chunk-VIU2XXA7.js";
|
|
8
|
+
import "../chunk-3MMG2H6M.js";
|
|
9
|
+
import "../chunk-MXDKXAY4.js";
|
|
7
10
|
import "../chunk-CZ7CSFO4.js";
|
|
8
11
|
export {
|
|
9
12
|
folderSkillsEffect,
|
package/js/skills.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
catalogCache
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
catalogCache,
|
|
3
|
+
catalogScope
|
|
4
|
+
} from "./chunk-KANDIVIH.js";
|
|
5
|
+
import "./chunk-RIXVGVA6.js";
|
|
6
|
+
import {
|
|
7
|
+
failOnNetworkRefusal
|
|
8
|
+
} from "./chunk-KIM5HXNK.js";
|
|
5
9
|
import {
|
|
6
10
|
folderSkillsEffect,
|
|
7
11
|
skillFromFiles
|
|
8
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-CQD3WSYH.js";
|
|
9
13
|
import {
|
|
14
|
+
accountProviderError,
|
|
10
15
|
httpProviderError
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import
|
|
16
|
+
} from "./chunk-EM4UL26F.js";
|
|
17
|
+
import {
|
|
18
|
+
NetworkRefused,
|
|
19
|
+
ProviderError,
|
|
20
|
+
networkRefusalStatus
|
|
21
|
+
} from "./chunk-P7MGDPFD.js";
|
|
13
22
|
import {
|
|
14
23
|
AppSkillMetadata,
|
|
15
24
|
AppSkillSource,
|
|
@@ -19,25 +28,28 @@ import {
|
|
|
19
28
|
SkillLoadFailed,
|
|
20
29
|
SkillServiceName,
|
|
21
30
|
skillLoadLimits
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
31
|
+
} from "./chunk-UOZMSUJ2.js";
|
|
32
|
+
import "./chunk-PNVCCB4L.js";
|
|
24
33
|
import {
|
|
25
34
|
FetchHttpClient_exports
|
|
26
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-VJQXXOQ3.js";
|
|
36
|
+
import {
|
|
37
|
+
wrap
|
|
38
|
+
} from "./chunk-GHXRRFZA.js";
|
|
39
|
+
import "./chunk-KAQD3DTI.js";
|
|
40
|
+
import "./chunk-YQ35E7KS.js";
|
|
41
|
+
import "./chunk-VIU2XXA7.js";
|
|
27
42
|
import {
|
|
28
43
|
HttpBody_exports,
|
|
29
44
|
HttpClient_exports
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import {
|
|
32
|
-
wrap
|
|
33
|
-
} from "./chunk-WFSQXYUT.js";
|
|
34
|
-
import "./chunk-SATWJKN6.js";
|
|
45
|
+
} from "./chunk-3MMG2H6M.js";
|
|
35
46
|
import {
|
|
47
|
+
Base64_exports,
|
|
36
48
|
Effect_exports,
|
|
37
49
|
Ref_exports,
|
|
38
50
|
Schema_exports,
|
|
39
51
|
Stream_exports
|
|
40
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-MXDKXAY4.js";
|
|
41
53
|
import "./chunk-CZ7CSFO4.js";
|
|
42
54
|
|
|
43
55
|
// src/implementation/inflate.ts
|
|
@@ -593,13 +605,15 @@ var describe = (service, { reason, status }) => {
|
|
|
593
605
|
};
|
|
594
606
|
var withService = (service) => (effect) => service === void 0 || !Schema_exports.is(SkillServiceName)(service) ? effect : effect.pipe(
|
|
595
607
|
Effect_exports.mapError(
|
|
596
|
-
(error) => !error.message ? new SkillLoadFailed({
|
|
608
|
+
(error) => Schema_exports.is(SkillLoadFailed)(error) && !error.message ? new SkillLoadFailed({
|
|
597
609
|
reason: error.reason,
|
|
598
610
|
message: describe(service, error),
|
|
599
|
-
...error.status === void 0 ? {} : { status: error.status }
|
|
611
|
+
...error.status === void 0 ? {} : { status: error.status },
|
|
612
|
+
...error.missing === void 0 ? {} : { missing: error.missing }
|
|
600
613
|
}) : error
|
|
601
614
|
)
|
|
602
615
|
);
|
|
616
|
+
var loaderFailure = (error, otherwise) => Schema_exports.is(SkillLoadFailed)(error) || Schema_exports.is(NetworkRefused)(error) ? error : otherwise();
|
|
603
617
|
var parse = (schema, input) => Schema_exports.decodeUnknownEffect(schema)(input).pipe(Effect_exports.mapError(() => failed("document")));
|
|
604
618
|
var resourcePath = (path) => {
|
|
605
619
|
if (!Schema_exports.is(SkillFilePath)(path)) return false;
|
|
@@ -615,23 +629,31 @@ var resourcePath = (path) => {
|
|
|
615
629
|
var pathUrl = (base, path) => new URL(path.split("/").map(encodeURIComponent).join("/"), base).href;
|
|
616
630
|
var reader = (transport) => Effect_exports.gen(function* () {
|
|
617
631
|
const budget = yield* Ref_exports.make(0);
|
|
618
|
-
const fetchBytes = (url,
|
|
632
|
+
const fetchBytes = (url, request = {}) => Effect_exports.gen(function* () {
|
|
619
633
|
const parsed = yield* Effect_exports.try({
|
|
620
634
|
try: () => new URL(url),
|
|
621
635
|
catch: () => failed("source")
|
|
622
636
|
});
|
|
623
637
|
if (!["https:", "http:"].includes(parsed.protocol) || parsed.username || parsed.password || parsed.hash)
|
|
624
638
|
return yield* failed("source");
|
|
639
|
+
const refusal = request.refused ?? ((refused) => refused);
|
|
625
640
|
const client = HttpClient_exports.withScope(yield* HttpClient_exports.HttpClient);
|
|
626
641
|
const headers = {
|
|
627
642
|
"User-Agent": "executor-skills",
|
|
628
643
|
Accept: "application/json, text/plain",
|
|
629
|
-
"Cache-Control": "no-cache"
|
|
644
|
+
"Cache-Control": "no-cache",
|
|
645
|
+
...request.headers
|
|
630
646
|
};
|
|
631
|
-
const response = yield* (
|
|
632
|
-
headers
|
|
633
|
-
body: HttpBody_exports.uint8Array(
|
|
634
|
-
})).pipe(
|
|
647
|
+
const response = yield* (request.body === void 0 ? client.get(parsed, { headers }) : client.post(parsed, {
|
|
648
|
+
headers,
|
|
649
|
+
body: HttpBody_exports.uint8Array(request.body, request.headers?.["Content-Type"])
|
|
650
|
+
})).pipe(
|
|
651
|
+
// `ctx.fetch` rejects with a network refusal; any other failed request got no answer.
|
|
652
|
+
Effect_exports.mapError(
|
|
653
|
+
(error) => Schema_exports.is(NetworkRefused)(error.cause) ? refusal(error.cause) : failed("request")
|
|
654
|
+
)
|
|
655
|
+
);
|
|
656
|
+
yield* failOnNetworkRefusal(response).pipe(Effect_exports.mapError(refusal));
|
|
635
657
|
if (response.status < 200 || response.status >= 300)
|
|
636
658
|
return yield* rejected(response.status, response.headers);
|
|
637
659
|
const chunks = [];
|
|
@@ -661,7 +683,7 @@ var reader = (transport) => Effect_exports.gen(function* () {
|
|
|
661
683
|
Effect_exports.provideService(FetchHttpClient_exports.RequestInit, { redirect: "manual" }),
|
|
662
684
|
Effect_exports.provideService(FetchHttpClient_exports.Fetch, transport.fetch ?? globalThis.fetch)
|
|
663
685
|
);
|
|
664
|
-
const read = (url) => fetchBytes(url).pipe(
|
|
686
|
+
const read = (url, request = {}) => fetchBytes(url, request).pipe(
|
|
665
687
|
Effect_exports.flatMap(
|
|
666
688
|
(result) => Effect_exports.try({
|
|
667
689
|
try: () => new TextDecoder("utf-8", { fatal: true }).decode(result),
|
|
@@ -680,35 +702,61 @@ var git = (run) => Effect_exports.tryPromise({
|
|
|
680
702
|
try: async () => run(),
|
|
681
703
|
catch: (error) => error instanceof InflateLimitExceeded ? failed("limit") : unreadable()
|
|
682
704
|
});
|
|
683
|
-
var
|
|
705
|
+
var githubHosts = ["github.com", "raw.githubusercontent.com"];
|
|
706
|
+
var githubRequests = (remote, repo, token) => {
|
|
707
|
+
const refused = (host) => (refusal) => refusal.refusal.reason === "credential_host" ? new SkillLoadFailed({
|
|
708
|
+
reason: "source",
|
|
709
|
+
status: networkRefusalStatus,
|
|
710
|
+
message: `A request with the GitHub token to ${host} was refused because the account's provider does not declare that host. The provider must declare hosts ${githubHosts.join(" and ")}; reconnect an account connected with other hosts.`
|
|
711
|
+
}) : refusal;
|
|
712
|
+
const upload = (body) => remote.fetchBytes(`https://${githubHosts[0]}/${repo}.git/git-upload-pack`, {
|
|
713
|
+
body,
|
|
714
|
+
headers: {
|
|
715
|
+
...gitRequestHeaders,
|
|
716
|
+
...token === void 0 ? {} : { Authorization: `Basic ${Base64_exports.encode(`x-access-token:${token}`)}` }
|
|
717
|
+
},
|
|
718
|
+
refused: refused(githubHosts[0])
|
|
719
|
+
});
|
|
720
|
+
const file = (commit, path) => remote.read(pathUrl(`https://${githubHosts[1]}/${repo}/${commit}/`, path), {
|
|
721
|
+
...token === void 0 ? {} : { headers: { Authorization: `token ${token}` } },
|
|
722
|
+
refused: refused(githubHosts[1])
|
|
723
|
+
});
|
|
724
|
+
return { repo, authenticated: token !== void 0, upload, file };
|
|
725
|
+
};
|
|
726
|
+
var resolveCommit = (github, ref) => Effect_exports.gen(function* () {
|
|
727
|
+
const { repo } = github;
|
|
684
728
|
if (ref !== void 0 && /^[a-f0-9]{40}$/.test(ref)) return ref;
|
|
685
729
|
const names = refCandidates(ref);
|
|
686
|
-
const response = yield*
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
730
|
+
const response = yield* github.upload(lsRefsRequest(names)).pipe(
|
|
731
|
+
Effect_exports.mapError((error) => {
|
|
732
|
+
if (!Schema_exports.is(SkillLoadFailed)(error) || error.reason !== "request") return error;
|
|
733
|
+
if (!github.authenticated && (error.status === 404 || error.status === 401))
|
|
734
|
+
return new SkillLoadFailed({
|
|
735
|
+
reason: "source",
|
|
736
|
+
message: `Reading GitHub repository ${repo} without credentials returned HTTP ${error.status}: it may not exist, or it may be private. To read a private repository, pass a GitHub account and its token.`,
|
|
737
|
+
status: error.status,
|
|
738
|
+
missing: "repository"
|
|
739
|
+
});
|
|
740
|
+
if (github.authenticated && error.status === 404)
|
|
741
|
+
return new SkillLoadFailed({
|
|
742
|
+
reason: "request",
|
|
743
|
+
message: `GitHub repository ${repo} is not available with the account's token (HTTP 404). Check the repository name and that the token can read it.`,
|
|
744
|
+
status: error.status
|
|
745
|
+
});
|
|
746
|
+
return error;
|
|
747
|
+
})
|
|
698
748
|
);
|
|
699
749
|
const refs = yield* git(() => parseLsRefs(response));
|
|
700
750
|
const commit = names.map((name) => refs.get(name)).find((sha) => sha !== void 0);
|
|
701
751
|
if (commit === void 0)
|
|
702
752
|
return yield* new SkillLoadFailed({
|
|
703
753
|
reason: "source",
|
|
704
|
-
message: `GitHub repository ${repo}
|
|
754
|
+
message: `The refs read from GitHub repository ${repo} include no branch or tag named ${ref}.`,
|
|
755
|
+
missing: "ref"
|
|
705
756
|
});
|
|
706
757
|
return commit;
|
|
707
758
|
});
|
|
708
|
-
var listFiles = (
|
|
709
|
-
body: treeFetchRequest(commit),
|
|
710
|
-
headers: gitRequestHeaders
|
|
711
|
-
}).pipe(
|
|
759
|
+
var listFiles = (github, commit, path) => github.upload(treeFetchRequest(commit)).pipe(
|
|
712
760
|
Effect_exports.flatMap(
|
|
713
761
|
(response) => git(
|
|
714
762
|
() => parseTreeFetch(response, commit, path, { objectBytes: skillLoadLimits.fileBytes })
|
|
@@ -721,8 +769,8 @@ var SkillDirectories = Schema_exports.Array(
|
|
|
721
769
|
files: Schema_exports.Array(Schema_exports.Struct({ path: Schema_exports.String, mode: Schema_exports.String }))
|
|
722
770
|
})
|
|
723
771
|
);
|
|
724
|
-
var skillDirectories = (
|
|
725
|
-
const files = yield* listFiles(
|
|
772
|
+
var skillDirectories = (github, commit, path) => Effect_exports.gen(function* () {
|
|
773
|
+
const files = yield* listFiles(github, commit, path);
|
|
726
774
|
const documents = files.filter(
|
|
727
775
|
(file) => file.path === "SKILL.md" || file.path.endsWith("/SKILL.md")
|
|
728
776
|
);
|
|
@@ -734,23 +782,32 @@ var skillDirectories = (remote, repo, commit, path) => Effect_exports.gen(functi
|
|
|
734
782
|
return yield* failed("limit");
|
|
735
783
|
return directories;
|
|
736
784
|
});
|
|
737
|
-
var cachedSkillDirectories = (cache, transport,
|
|
785
|
+
var cachedSkillDirectories = (cache, transport, options, commit) => Effect_exports.tryPromise({
|
|
738
786
|
try: () => cache.get({
|
|
739
|
-
key: ["apps/githubSkills/directories", 1, repo, commit, path ?? null],
|
|
787
|
+
key: ["apps/githubSkills/directories", 1, options.repo, commit, options.path ?? null],
|
|
740
788
|
schema: wrap(SkillDirectories, false),
|
|
741
789
|
freshFor: "7 days",
|
|
742
790
|
load: (context) => Effect_exports.runPromise(
|
|
743
|
-
// Keep the author's fetch, as every other
|
|
791
|
+
// Keep the author's fetch and this read's token, as every other request in it does.
|
|
744
792
|
reader({ fetch: transport.fetch, signal: context.signal }).pipe(
|
|
745
|
-
Effect_exports.flatMap(
|
|
793
|
+
Effect_exports.flatMap(
|
|
794
|
+
(remote) => skillDirectories(
|
|
795
|
+
githubRequests(remote, options.repo, options.token),
|
|
796
|
+
commit,
|
|
797
|
+
options.path
|
|
798
|
+
)
|
|
799
|
+
)
|
|
746
800
|
),
|
|
747
801
|
{ signal: context.signal }
|
|
748
802
|
)
|
|
749
803
|
}),
|
|
750
|
-
catch: (error) =>
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
804
|
+
catch: (error) => loaderFailure(
|
|
805
|
+
error,
|
|
806
|
+
() => new SkillLoadFailed({
|
|
807
|
+
reason: "request",
|
|
808
|
+
message: "Executor could not read or update the app cache for skills."
|
|
809
|
+
})
|
|
810
|
+
)
|
|
754
811
|
});
|
|
755
812
|
var cachedCatalog = (options, prefix, load) => options.cache === void 0 ? load(options, void 0) : catalogCache({
|
|
756
813
|
cache: options.cache,
|
|
@@ -759,30 +816,55 @@ var cachedCatalog = (options, prefix, load) => options.cache === void 0 ? load(o
|
|
|
759
816
|
prefix,
|
|
760
817
|
schema: AppSkillSource,
|
|
761
818
|
summary: { schema: AppSkillMetadata, of: ({ files: _files, ...metadata }) => metadata },
|
|
762
|
-
load: (context) => context === void 0 ? load(options, options.cache) : load({ fetch: options.fetch, signal: context.signal }, context.cache)
|
|
819
|
+
load: (context) => (context === void 0 ? load(options, options.cache) : load({ fetch: options.fetch, signal: context.signal }, context.cache)).pipe(Effect_exports.map((tools) => ({ tools })))
|
|
763
820
|
}).pipe(
|
|
764
821
|
Effect_exports.flatMap((catalog) => catalog.list()),
|
|
765
822
|
Effect_exports.mapError(
|
|
766
|
-
(error) =>
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
823
|
+
(error) => loaderFailure(
|
|
824
|
+
error,
|
|
825
|
+
() => new SkillLoadFailed({
|
|
826
|
+
reason: "request",
|
|
827
|
+
message: "Executor could not read or update the app cache for skills."
|
|
828
|
+
})
|
|
829
|
+
)
|
|
770
830
|
)
|
|
771
831
|
);
|
|
832
|
+
var GitHubToken = Schema_exports.String.check(Schema_exports.isPattern(/^[\x21-\x7e]+$/u));
|
|
833
|
+
var scopeMessages = {
|
|
834
|
+
"missing-account": "A GitHub token needs its account. Pass account: ctx.accounts.<slot> with it.",
|
|
835
|
+
"unselected-account": "The GitHub account is not one of this app's selected accounts."
|
|
836
|
+
};
|
|
837
|
+
var githubCache = (options) => options.account !== void 0 && !Schema_exports.is(GitHubToken)(options.token) ? Effect_exports.fail(
|
|
838
|
+
new SkillLoadFailed({
|
|
839
|
+
reason: "source",
|
|
840
|
+
message: "The GitHub account was passed without a valid token."
|
|
841
|
+
})
|
|
842
|
+
) : catalogScope(
|
|
843
|
+
options,
|
|
844
|
+
options.token,
|
|
845
|
+
(problem) => new SkillLoadFailed({ reason: "source", message: scopeMessages[problem] })
|
|
846
|
+
);
|
|
847
|
+
var attributed = (account) => (error) => account !== void 0 && Schema_exports.is(SkillLoadFailed)(error) && error.reason === "request" && (error.status === 401 || error.status === 403) ? accountProviderError(
|
|
848
|
+
new ProviderError({
|
|
849
|
+
reason: error.status === 401 ? "unauthorized" : "rejected",
|
|
850
|
+
status: error.status
|
|
851
|
+
}),
|
|
852
|
+
account.id
|
|
853
|
+
) : error;
|
|
772
854
|
var githubSkillsEffect = (options) => Effect_exports.gen(function* () {
|
|
773
855
|
if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(options.repo) || options.path !== void 0 && !resourcePath(options.path))
|
|
774
856
|
return yield* failed("source");
|
|
857
|
+
const cache = yield* githubCache(options);
|
|
775
858
|
return yield* cachedCatalog(
|
|
776
|
-
options,
|
|
859
|
+
cache === void 0 ? options : { ...options, cache },
|
|
777
860
|
["apps/githubSkills/catalog", 1, options.repo, options.ref ?? null, options.path ?? null],
|
|
778
|
-
(transport,
|
|
861
|
+
(transport, cache2) => githubCatalog(options, transport, cache2)
|
|
779
862
|
);
|
|
780
|
-
}).pipe(withService("GitHub"));
|
|
863
|
+
}).pipe(withService("GitHub"), Effect_exports.mapError(attributed(options.account)));
|
|
781
864
|
var githubCatalog = (options, transport, cache) => Effect_exports.gen(function* () {
|
|
782
|
-
const
|
|
783
|
-
const commit = yield* resolveCommit(
|
|
784
|
-
const resources = yield* cache === void 0 ? skillDirectories(
|
|
785
|
-
const base = `https://raw.githubusercontent.com/${options.repo}/${commit}/`;
|
|
865
|
+
const github = githubRequests(yield* reader(transport), options.repo, options.token);
|
|
866
|
+
const commit = yield* resolveCommit(github, options.ref);
|
|
867
|
+
const resources = yield* cache === void 0 ? skillDirectories(github, commit, options.path) : cachedSkillDirectories(cache, transport, options, commit);
|
|
786
868
|
const skills = yield* Effect_exports.forEach(
|
|
787
869
|
resources,
|
|
788
870
|
({ directory, files }) => Effect_exports.gen(function* () {
|
|
@@ -792,7 +874,7 @@ var githubCatalog = (options, transport, cache) => Effect_exports.gen(function*
|
|
|
792
874
|
const path = file.path.slice(directory.length);
|
|
793
875
|
if (!resourcePath(file.path) || !resourcePath(path) || file.mode === "120000")
|
|
794
876
|
return yield* failed("source");
|
|
795
|
-
return { path, content: yield*
|
|
877
|
+
return { path, content: yield* github.file(commit, file.path) };
|
|
796
878
|
}),
|
|
797
879
|
{ concurrency: skillLoadLimits.concurrency }
|
|
798
880
|
);
|