apps 0.0.1-beta.7 → 0.0.1-beta.70

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.
Files changed (178) hide show
  1. package/README.md +25 -22
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-UESPOTUI.js → chunk-2YSTJMBD.js} +899 -190
  4. package/js/{chunk-RJDDBDSN.js → chunk-3CVQ3VPP.js} +762 -171
  5. package/js/chunk-3R3KFCDU.js +426 -0
  6. package/js/{chunk-FL2QR3XW.js → chunk-4NCIPADO.js} +326 -69
  7. package/js/chunk-5FHWNLCI.js +88 -0
  8. package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
  9. package/js/chunk-7LMU3ER3.js +274 -0
  10. package/js/chunk-CDXQDN7W.js +92 -0
  11. package/js/{chunk-RFVIONFX.js → chunk-ECCWT5GJ.js} +79 -41
  12. package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
  13. package/js/{chunk-27F7W2LG.js → chunk-H2CJWXA3.js} +2 -2
  14. package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
  15. package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
  16. package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
  17. package/js/{chunk-WLE7WX2U.js → chunk-JW5LYSER.js} +2262 -474
  18. package/js/{chunk-5T57N25Q.js → chunk-KGCTYL2S.js} +511 -63
  19. package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
  20. package/js/chunk-M5OLYYNU.js +347 -0
  21. package/js/chunk-MHB7IFG7.js +49 -0
  22. package/js/chunk-OD3KFKZD.js +1617 -0
  23. package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
  24. package/js/{chunk-NKLWZJLE.js → chunk-RUP4JMKO.js} +25 -14
  25. package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
  26. package/js/{chunk-72JNVHPK.js → chunk-WDIVWSDG.js} +4 -3
  27. package/js/{chunk-CMYUWAX7.js → chunk-WGQP62EG.js} +126 -31
  28. package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
  29. package/js/{chunk-Z5M2LQOZ.js → chunk-ZEJ3IKEC.js} +67 -55
  30. package/js/chunk-ZR7QAG67.js +171 -0
  31. package/js/client.js +142 -94
  32. package/js/contracts.js +125 -26
  33. package/js/effect.js +19 -19
  34. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  35. package/js/graphql.js +50 -40
  36. package/js/host.js +83 -58
  37. package/js/index.js +131 -46
  38. package/js/mcp/effect.js +23 -21
  39. package/js/mcp/stdio.js +44 -34
  40. package/js/mcp.js +76 -53
  41. package/js/openapi.js +4063 -1359
  42. package/js/react.js +2 -3
  43. package/js/skills/effect.js +6 -3
  44. package/js/skills.js +208 -81
  45. package/js/storage/facet.js +1 -540
  46. package/js/ui/auth/contracts.js +2 -2
  47. package/js/ui/auth.js +5 -5
  48. package/js/ui/contracts.js +5 -4
  49. package/js/ui/serving.js +8517 -214
  50. package/package.json +3 -4
  51. package/runtime.json +1 -1
  52. package/types/app-cache/src/contracts/cache.d.ts +2 -0
  53. package/types/app-cache/src/index.d.ts +10 -1
  54. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  55. package/types/apps/src/contracts/app.d.ts +7 -3
  56. package/types/apps/src/contracts/cache.d.ts +20 -0
  57. package/types/apps/src/contracts/context.d.ts +19 -11
  58. package/types/apps/src/contracts/elicitation.d.ts +6 -6
  59. package/types/apps/src/contracts/events.d.ts +93 -0
  60. package/types/apps/src/contracts/failure.d.ts +30 -1
  61. package/types/apps/src/contracts/graphql.d.ts +2 -1
  62. package/types/apps/src/contracts/host.d.ts +641 -16
  63. package/types/apps/src/contracts/live.d.ts +2 -0
  64. package/types/apps/src/contracts/mcp.d.ts +80 -10
  65. package/types/apps/src/contracts/network.d.ts +120 -0
  66. package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
  67. package/types/apps/src/contracts/openapi.d.ts +41 -9
  68. package/types/apps/src/contracts/operations.d.ts +8 -4
  69. package/types/apps/src/contracts/placement.d.ts +102 -0
  70. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  71. package/types/apps/src/contracts/protocols/1.d.ts +733 -81
  72. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  73. package/types/apps/src/contracts/protocols/2.d.ts +69 -26
  74. package/types/apps/src/contracts/protocols/3.d.ts +133 -33
  75. package/types/apps/src/contracts/protocols/4.d.ts +122 -45
  76. package/types/apps/src/contracts/protocols/5.d.ts +157 -47
  77. package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
  78. package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
  79. package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
  80. package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
  81. package/types/apps/src/contracts/protocols/current.d.ts +3842 -0
  82. package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
  83. package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
  84. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  85. package/types/apps/src/contracts/provider.d.ts +90 -6
  86. package/types/apps/src/contracts/skills.d.ts +50 -13
  87. package/types/apps/src/contracts/sql.d.ts +63 -0
  88. package/types/apps/src/contracts/ui.d.ts +19 -1
  89. package/types/apps/src/contracts/workflows.d.ts +6 -0
  90. package/types/apps/src/facet.d.ts +4 -5
  91. package/types/apps/src/host.d.ts +5 -0
  92. package/types/apps/src/implementation/account-router.d.ts +4 -3
  93. package/types/apps/src/implementation/authoring.d.ts +25 -5
  94. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  95. package/types/apps/src/implementation/cache.d.ts +4 -0
  96. package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
  97. package/types/apps/src/implementation/elicitation.d.ts +18 -15
  98. package/types/apps/src/implementation/events.d.ts +59 -0
  99. package/types/apps/src/implementation/failure-detail.d.ts +25 -3
  100. package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
  101. package/types/apps/src/implementation/graphql.d.ts +4 -3
  102. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  103. package/types/apps/src/implementation/invocation-timing.d.ts +16 -0
  104. package/types/apps/src/implementation/live.d.ts +2 -2
  105. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  106. package/types/apps/src/implementation/mcp-catalog.d.ts +6 -4
  107. package/types/apps/src/implementation/mcp-client.d.ts +17 -9
  108. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  109. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  110. package/types/apps/src/implementation/mcp.d.ts +20 -9
  111. package/types/apps/src/implementation/network.d.ts +16 -0
  112. package/types/apps/src/implementation/openapi-compile.d.ts +26 -6
  113. package/types/apps/src/implementation/openapi-document.d.ts +46 -19
  114. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  115. package/types/apps/src/implementation/openapi-request.d.ts +10 -2
  116. package/types/apps/src/implementation/openapi-source.d.ts +18 -0
  117. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  118. package/types/apps/src/implementation/operations.d.ts +17 -2
  119. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  120. package/types/apps/src/implementation/placement.d.ts +60 -0
  121. package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
  122. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  123. package/types/apps/src/implementation/provider.d.ts +18 -3
  124. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  125. package/types/apps/src/implementation/router-catalog.d.ts +11 -13
  126. package/types/apps/src/implementation/router.d.ts +16 -5
  127. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  128. package/types/apps/src/implementation/schema.d.ts +90 -10
  129. package/types/apps/src/implementation/skills.d.ts +18 -24
  130. package/types/apps/src/implementation/sql.d.ts +71 -0
  131. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  132. package/types/apps/src/implementation/ui-auth.d.ts +1 -1
  133. package/types/apps/src/implementation/ui-client.d.ts +2 -2
  134. package/types/apps/src/implementation/ui-document.d.ts +5 -0
  135. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  136. package/types/apps/src/implementation/ui-serving.d.ts +11 -5
  137. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  138. package/types/apps/src/implementation/upstream-error.d.ts +7 -0
  139. package/types/apps/src/implementation/webhooks.d.ts +1 -1
  140. package/types/apps/src/implementation/workflows.d.ts +1 -1
  141. package/types/apps/src/index.d.ts +55 -13
  142. package/types/apps/src/mcp.d.ts +20 -1
  143. package/types/apps/src/openapi.d.ts +1 -1
  144. package/types/apps/src/react.d.ts +1 -1
  145. package/types/apps/src/skills.d.ts +10 -8
  146. package/types/telemetry/src/app-records.d.ts +42 -0
  147. package/types/telemetry/src/browser-operations.d.ts +7 -4
  148. package/types/telemetry/src/browser.d.ts +8 -3
  149. package/types/telemetry/src/config.d.ts +2 -2
  150. package/types/telemetry/src/index.d.ts +2 -1
  151. package/types/telemetry/src/layer.d.ts +2 -2
  152. package/types/telemetry/src/measurements.d.ts +1 -1
  153. package/types/telemetry/src/ownership.d.ts +56 -0
  154. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  155. package/types/telemetry/src/relay.d.ts +16 -6
  156. package/types/telemetry/src/span-attributes.d.ts +17 -1
  157. package/types/telemetry/src/transport.d.ts +8 -1
  158. package/types/utils/src/api-error.d.ts +55 -0
  159. package/types/utils/src/connection-failure.d.ts +33 -0
  160. package/types/utils/src/recorded-message.d.ts +18 -0
  161. package/types/utils/src/user-facing-error.d.ts +83 -0
  162. package/js/chunk-MKWZPDR6.js +0 -63
  163. package/js/chunk-N7YDVXYJ.js +0 -186
  164. package/js/chunk-OCYUEU47.js +0 -224
  165. package/js/chunk-PJJ24GU7.js +0 -877
  166. package/js/chunk-PZB6T6KU.js +0 -19
  167. package/js/chunk-R3EV5FTO.js +0 -97
  168. package/js/chunk-YXQHV65J.js +0 -242
  169. package/js/chunk-ZQINWV4W.js +0 -630
  170. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  171. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  172. package/types/app-data/src/implementation/promise.d.ts +0 -68
  173. package/types/app-data/src/implementation/range.d.ts +0 -8
  174. package/types/app-data/src/implementation/schema.d.ts +0 -18
  175. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  176. package/types/app-data/src/index.d.ts +0 -4
  177. package/types/apps/src/contracts/storage.d.ts +0 -68
  178. package/types/apps/src/implementation/storage.d.ts +0 -15
package/js/react.js CHANGED
@@ -2,11 +2,10 @@ import {
2
2
  AsyncResult_exports,
3
3
  AtomRegistry_exports,
4
4
  queryCommitted
5
- } from "./chunk-M3B3DE4K.js";
6
- import "./chunk-PJJ24GU7.js";
5
+ } from "./chunk-74YVXBKY.js";
7
6
  import {
8
7
  Option_exports
9
- } from "./chunk-CDL5PM2Q.js";
8
+ } from "./chunk-IFJU5SYQ.js";
10
9
  import "./chunk-CZ7CSFO4.js";
11
10
 
12
11
  // src/react.ts
@@ -1,9 +1,12 @@
1
1
  import {
2
2
  folderSkillsEffect,
3
3
  skillFromFiles
4
- } from "../chunk-IPI4MFSN.js";
5
- import "../chunk-JU7VHODU.js";
6
- import "../chunk-CDL5PM2Q.js";
4
+ } from "../chunk-XBG7HHXC.js";
5
+ import "../chunk-H72MEDMN.js";
6
+ import "../chunk-5FHWNLCI.js";
7
+ import "../chunk-TUMGL2OC.js";
8
+ import "../chunk-EOPQ727L.js";
9
+ import "../chunk-IFJU5SYQ.js";
7
10
  import "../chunk-CZ7CSFO4.js";
8
11
  export {
9
12
  folderSkillsEffect,
package/js/skills.js CHANGED
@@ -1,15 +1,27 @@
1
1
  import {
2
- catalogCache
3
- } from "./chunk-RFVIONFX.js";
4
- import "./chunk-NKLWZJLE.js";
2
+ catalogCache,
3
+ catalogScope
4
+ } from "./chunk-ECCWT5GJ.js";
5
+ import "./chunk-RUP4JMKO.js";
6
+ import {
7
+ failOnNetworkRefusal
8
+ } from "./chunk-MHB7IFG7.js";
5
9
  import {
6
10
  folderSkillsEffect,
7
11
  skillFromFiles
8
- } from "./chunk-IPI4MFSN.js";
12
+ } from "./chunk-XBG7HHXC.js";
13
+ import {
14
+ accountProviderError,
15
+ fromPromise,
16
+ httpProviderError,
17
+ method,
18
+ toPromise
19
+ } from "./chunk-ZR7QAG67.js";
9
20
  import {
10
- httpProviderError
11
- } from "./chunk-MKWZPDR6.js";
12
- import "./chunk-R3EV5FTO.js";
21
+ NetworkRefused,
22
+ ProviderError,
23
+ networkRefusalStatus
24
+ } from "./chunk-7LMU3ER3.js";
13
25
  import {
14
26
  AppSkillMetadata,
15
27
  AppSkillSource,
@@ -19,24 +31,29 @@ import {
19
31
  SkillLoadFailed,
20
32
  SkillServiceName,
21
33
  skillLoadLimits
22
- } from "./chunk-JU7VHODU.js";
34
+ } from "./chunk-H72MEDMN.js";
35
+ import {
36
+ wrap
37
+ } from "./chunk-KGCTYL2S.js";
38
+ import "./chunk-3CVQ3VPP.js";
23
39
  import {
24
40
  FetchHttpClient_exports
25
- } from "./chunk-57RKNWL2.js";
41
+ } from "./chunk-PD6I2SDG.js";
42
+ import "./chunk-5FHWNLCI.js";
43
+ import "./chunk-H2CJWXA3.js";
44
+ import "./chunk-TUMGL2OC.js";
26
45
  import {
27
46
  HttpBody_exports,
28
47
  HttpClient_exports
29
- } from "./chunk-UK573G7W.js";
30
- import {
31
- wrap
32
- } from "./chunk-5T57N25Q.js";
33
- import "./chunk-27F7W2LG.js";
48
+ } from "./chunk-EOPQ727L.js";
34
49
  import {
50
+ Base64_exports,
35
51
  Effect_exports,
52
+ Hex_exports,
36
53
  Ref_exports,
37
54
  Schema_exports,
38
55
  Stream_exports
39
- } from "./chunk-CDL5PM2Q.js";
56
+ } from "./chunk-IFJU5SYQ.js";
40
57
  import "./chunk-CZ7CSFO4.js";
41
58
 
42
59
  // src/implementation/inflate.ts
@@ -592,13 +609,15 @@ var describe = (service, { reason, status }) => {
592
609
  };
593
610
  var withService = (service) => (effect) => service === void 0 || !Schema_exports.is(SkillServiceName)(service) ? effect : effect.pipe(
594
611
  Effect_exports.mapError(
595
- (error) => !error.message ? new SkillLoadFailed({
612
+ (error) => Schema_exports.is(SkillLoadFailed)(error) && !error.message ? new SkillLoadFailed({
596
613
  reason: error.reason,
597
614
  message: describe(service, error),
598
- ...error.status === void 0 ? {} : { status: error.status }
615
+ ...error.status === void 0 ? {} : { status: error.status },
616
+ ...error.missing === void 0 ? {} : { missing: error.missing }
599
617
  }) : error
600
618
  )
601
619
  );
620
+ var loaderFailure = (error, otherwise) => Schema_exports.is(SkillLoadFailed)(error) || Schema_exports.is(NetworkRefused)(error) ? error : otherwise();
602
621
  var parse = (schema, input) => Schema_exports.decodeUnknownEffect(schema)(input).pipe(Effect_exports.mapError(() => failed("document")));
603
622
  var resourcePath = (path) => {
604
623
  if (!Schema_exports.is(SkillFilePath)(path)) return false;
@@ -614,23 +633,31 @@ var resourcePath = (path) => {
614
633
  var pathUrl = (base, path) => new URL(path.split("/").map(encodeURIComponent).join("/"), base).href;
615
634
  var reader = (transport) => Effect_exports.gen(function* () {
616
635
  const budget = yield* Ref_exports.make(0);
617
- const fetchBytes = (url, post) => Effect_exports.gen(function* () {
636
+ const fetchBytes = (url, request = {}) => Effect_exports.gen(function* () {
618
637
  const parsed = yield* Effect_exports.try({
619
638
  try: () => new URL(url),
620
639
  catch: () => failed("source")
621
640
  });
622
641
  if (!["https:", "http:"].includes(parsed.protocol) || parsed.username || parsed.password || parsed.hash)
623
642
  return yield* failed("source");
643
+ const refusal = request.refused ?? ((refused) => refused);
624
644
  const client = HttpClient_exports.withScope(yield* HttpClient_exports.HttpClient);
625
645
  const headers = {
626
646
  "User-Agent": "executor-skills",
627
647
  Accept: "application/json, text/plain",
628
- "Cache-Control": "no-cache"
648
+ "Cache-Control": "no-cache",
649
+ ...request.headers
629
650
  };
630
- const response = yield* (post === void 0 ? client.get(parsed, { headers }) : client.post(parsed, {
631
- headers: { ...headers, ...post.headers },
632
- body: HttpBody_exports.uint8Array(post.body, post.headers["Content-Type"])
633
- })).pipe(Effect_exports.mapError(() => failed("request")));
651
+ const response = yield* (request.body === void 0 ? client.get(parsed, { headers }) : client.post(parsed, {
652
+ headers,
653
+ body: HttpBody_exports.uint8Array(request.body, request.headers?.["Content-Type"])
654
+ })).pipe(
655
+ // `ctx.fetch` rejects with a network refusal; any other failed request got no answer.
656
+ Effect_exports.mapError(
657
+ (error) => Schema_exports.is(NetworkRefused)(error.cause) ? refusal(error.cause) : failed("request")
658
+ )
659
+ );
660
+ yield* failOnNetworkRefusal(response).pipe(Effect_exports.mapError(refusal));
634
661
  if (response.status < 200 || response.status >= 300)
635
662
  return yield* rejected(response.status, response.headers);
636
663
  const chunks = [];
@@ -660,7 +687,7 @@ var reader = (transport) => Effect_exports.gen(function* () {
660
687
  Effect_exports.provideService(FetchHttpClient_exports.RequestInit, { redirect: "manual" }),
661
688
  Effect_exports.provideService(FetchHttpClient_exports.Fetch, transport.fetch ?? globalThis.fetch)
662
689
  );
663
- const read = (url) => fetchBytes(url).pipe(
690
+ const read = (url, request = {}) => fetchBytes(url, request).pipe(
664
691
  Effect_exports.flatMap(
665
692
  (result) => Effect_exports.try({
666
693
  try: () => new TextDecoder("utf-8", { fatal: true }).decode(result),
@@ -675,39 +702,68 @@ var unreadable = () => new SkillLoadFailed({
675
702
  reason: "request",
676
703
  message: "GitHub returned a git response Executor could not read."
677
704
  });
678
- var git = (run) => Effect_exports.tryPromise({
679
- try: async () => run(),
680
- catch: (error) => error instanceof InflateLimitExceeded ? failed("limit") : unreadable()
681
- });
682
- var resolveCommit = (remote, repo, ref) => Effect_exports.gen(function* () {
705
+ var git = (run) => (
706
+ // oxlint-disable-next-line executor/authored-code-through-adapter -- this module's git parsing
707
+ Effect_exports.tryPromise({
708
+ try: async () => run(),
709
+ catch: (error) => error instanceof InflateLimitExceeded ? failed("limit") : unreadable()
710
+ })
711
+ );
712
+ var githubHosts = ["github.com", "raw.githubusercontent.com"];
713
+ var githubRequests = (remote, repo, token) => {
714
+ const refused = (host) => (refusal) => refusal.refusal.reason === "credential_host" ? new SkillLoadFailed({
715
+ reason: "source",
716
+ status: networkRefusalStatus,
717
+ 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.`
718
+ }) : refusal;
719
+ const upload = (body) => remote.fetchBytes(`https://${githubHosts[0]}/${repo}.git/git-upload-pack`, {
720
+ body,
721
+ headers: {
722
+ ...gitRequestHeaders,
723
+ ...token === void 0 ? {} : { Authorization: `Basic ${Base64_exports.encode(`x-access-token:${token}`)}` }
724
+ },
725
+ refused: refused(githubHosts[0])
726
+ });
727
+ const file = (commit, path) => remote.read(pathUrl(`https://${githubHosts[1]}/${repo}/${commit}/`, path), {
728
+ ...token === void 0 ? {} : { headers: { Authorization: `token ${token}` } },
729
+ refused: refused(githubHosts[1])
730
+ });
731
+ return { repo, authenticated: token !== void 0, upload, file };
732
+ };
733
+ var resolveCommit = (github, ref) => Effect_exports.gen(function* () {
734
+ const { repo } = github;
683
735
  if (ref !== void 0 && /^[a-f0-9]{40}$/.test(ref)) return ref;
684
736
  const names = refCandidates(ref);
685
- const response = yield* remote.fetchBytes(`https://github.com/${repo}.git/git-upload-pack`, {
686
- body: lsRefsRequest(names),
687
- headers: gitRequestHeaders
688
- }).pipe(
689
- // GitHub asks for credentials when a repository is missing or private.
690
- Effect_exports.mapError(
691
- (error) => error.status === 401 || error.status === 404 ? new SkillLoadFailed({
692
- reason: "source",
693
- message: `GitHub has no public repository named ${repo}.`,
694
- status: error.status
695
- }) : error
696
- )
737
+ const response = yield* github.upload(lsRefsRequest(names)).pipe(
738
+ Effect_exports.mapError((error) => {
739
+ if (!Schema_exports.is(SkillLoadFailed)(error) || error.reason !== "request") return error;
740
+ if (!github.authenticated && (error.status === 404 || error.status === 401))
741
+ return new SkillLoadFailed({
742
+ reason: "source",
743
+ 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.`,
744
+ status: error.status,
745
+ missing: "repository"
746
+ });
747
+ if (github.authenticated && error.status === 404)
748
+ return new SkillLoadFailed({
749
+ reason: "request",
750
+ 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.`,
751
+ status: error.status
752
+ });
753
+ return error;
754
+ })
697
755
  );
698
756
  const refs = yield* git(() => parseLsRefs(response));
699
757
  const commit = names.map((name) => refs.get(name)).find((sha) => sha !== void 0);
700
758
  if (commit === void 0)
701
759
  return yield* new SkillLoadFailed({
702
760
  reason: "source",
703
- message: `GitHub repository ${repo} has no branch or tag named ${ref}.`
761
+ message: `The refs read from GitHub repository ${repo} include no branch or tag named ${ref}.`,
762
+ missing: "ref"
704
763
  });
705
764
  return commit;
706
765
  });
707
- var listFiles = (remote, repo, commit, path) => remote.fetchBytes(`https://github.com/${repo}.git/git-upload-pack`, {
708
- body: treeFetchRequest(commit),
709
- headers: gitRequestHeaders
710
- }).pipe(
766
+ var listFiles = (github, commit, path) => github.upload(treeFetchRequest(commit)).pipe(
711
767
  Effect_exports.flatMap(
712
768
  (response) => git(
713
769
  () => parseTreeFetch(response, commit, path, { objectBytes: skillLoadLimits.fileBytes })
@@ -720,8 +776,8 @@ var SkillDirectories = Schema_exports.Array(
720
776
  files: Schema_exports.Array(Schema_exports.Struct({ path: Schema_exports.String, mode: Schema_exports.String }))
721
777
  })
722
778
  );
723
- var skillDirectories = (remote, repo, commit, path) => Effect_exports.gen(function* () {
724
- const files = yield* listFiles(remote, repo, commit, path);
779
+ var skillDirectories = (github, commit, path) => Effect_exports.gen(function* () {
780
+ const files = yield* listFiles(github, commit, path);
725
781
  const documents = files.filter(
726
782
  (file) => file.path === "SKILL.md" || file.path.endsWith("/SKILL.md")
727
783
  );
@@ -733,55 +789,122 @@ var skillDirectories = (remote, repo, commit, path) => Effect_exports.gen(functi
733
789
  return yield* failed("limit");
734
790
  return directories;
735
791
  });
736
- var cachedSkillDirectories = (cache, transport, repo, commit, path) => Effect_exports.tryPromise({
737
- try: () => cache.get({
738
- key: ["apps/githubSkills/directories", 1, repo, commit, path ?? null],
739
- schema: wrap(SkillDirectories, false),
740
- freshFor: "7 days",
741
- load: (context) => Effect_exports.runPromise(
742
- // Keep the author's fetch, as every other read in this load does.
792
+ var cachedSkillDirectories = (cache, transport, options, commit) => fromPromise(
793
+ method(cache, "get"),
794
+ "cache"
795
+ )({
796
+ key: ["apps/githubSkills/directories", 1, options.repo, commit, options.path ?? null],
797
+ schema: wrap(SkillDirectories, false),
798
+ freshFor: "7 days",
799
+ // Executor's own loader: the app's cache runs it natively, so only its requests are upstream.
800
+ load: toPromise(
801
+ (context) => (
802
+ // Keep the author's fetch and this read's token, as every other request in it does.
743
803
  reader({ fetch: transport.fetch, signal: context.signal }).pipe(
744
- Effect_exports.flatMap((remote) => skillDirectories(remote, repo, commit, path))
745
- ),
746
- { signal: context.signal }
804
+ Effect_exports.flatMap(
805
+ (remote) => skillDirectories(
806
+ githubRequests(remote, options.repo, options.token),
807
+ commit,
808
+ options.path
809
+ )
810
+ )
811
+ )
812
+ ),
813
+ // A cache may call the loader as a Promise; its own signal cancels that load.
814
+ (context) => context.signal
815
+ )
816
+ }).pipe(
817
+ Effect_exports.mapError(
818
+ (error) => loaderFailure(
819
+ error,
820
+ () => new SkillLoadFailed({
821
+ reason: "request",
822
+ message: "Executor could not read or update the app cache for skills."
823
+ })
747
824
  )
748
- }),
749
- catch: (error) => Schema_exports.is(SkillLoadFailed)(error) ? error : new SkillLoadFailed({
750
- reason: "request",
751
- message: "Executor could not read or update the app cache for skills."
825
+ )
826
+ );
827
+ var digest = (value) => (
828
+ // oxlint-disable-next-line executor/authored-code-through-adapter -- Web Crypto
829
+ Effect_exports.promise(
830
+ () => crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify(value)))
831
+ ).pipe(Effect_exports.map((bytes) => Hex_exports.encode(new Uint8Array(bytes))))
832
+ );
833
+ var checked = (request) => request.pipe(
834
+ Effect_exports.timeoutOrElse({
835
+ duration: skillLoadLimits.checkMillis,
836
+ orElse: () => Effect_exports.fail(failed("request"))
752
837
  })
753
- });
754
- var cachedCatalog = (options, prefix, load) => options.cache === void 0 ? load(options, void 0) : catalogCache({
838
+ );
839
+ var cachedCatalog = (options, prefix, publication) => options.cache === void 0 ? publication(options, void 0).pipe(Effect_exports.flatMap((source) => source.load)) : catalogCache({
755
840
  cache: options.cache,
756
841
  ...options.freshFor === void 0 ? {} : { freshFor: options.freshFor },
757
842
  ...options.staleFor === void 0 ? {} : { staleFor: options.staleFor },
843
+ stale: "revalidate",
758
844
  prefix,
759
845
  schema: AppSkillSource,
760
846
  summary: { schema: AppSkillMetadata, of: ({ files: _files, ...metadata }) => metadata },
761
- load: (context) => (context === void 0 ? load(options, options.cache) : load({ fetch: options.fetch, signal: context.signal }, context.cache)).pipe(Effect_exports.map((tools) => ({ tools })))
847
+ load: (context, kept) => Effect_exports.gen(function* () {
848
+ const source = yield* context === void 0 ? publication(options, options.cache) : publication({ fetch: options.fetch, signal: context.signal }, context.cache);
849
+ if (source.id === void 0) return { tools: yield* source.load };
850
+ const previous = kept === void 0 ? void 0 : yield* kept;
851
+ const tools = previous?.header?.["publication"] === source.id ? yield* previous.tools : yield* source.load;
852
+ return { tools, header: { publication: source.id } };
853
+ })
762
854
  }).pipe(
763
855
  Effect_exports.flatMap((catalog) => catalog.list()),
764
856
  Effect_exports.mapError(
765
- (error) => Schema_exports.is(SkillLoadFailed)(error) ? error : new SkillLoadFailed({
766
- reason: "request",
767
- message: "Executor could not read or update the app cache for skills."
768
- })
857
+ (error) => loaderFailure(
858
+ error,
859
+ () => new SkillLoadFailed({
860
+ reason: "request",
861
+ message: "Executor could not read or update the app cache for skills."
862
+ })
863
+ )
769
864
  )
770
865
  );
866
+ var GitHubToken = Schema_exports.String.check(Schema_exports.isPattern(/^[\x21-\x7e]+$/u));
867
+ var scopeMessages = {
868
+ "missing-account": "A GitHub token needs its account. Pass account: ctx.accounts.<slot> with it.",
869
+ "unselected-account": "The GitHub account is not one of this app's selected accounts."
870
+ };
871
+ var githubCache = (options) => options.account !== void 0 && !Schema_exports.is(GitHubToken)(options.token) ? Effect_exports.fail(
872
+ new SkillLoadFailed({
873
+ reason: "source",
874
+ message: "The GitHub account was passed without a valid token."
875
+ })
876
+ ) : catalogScope(
877
+ options,
878
+ options.token,
879
+ (problem) => new SkillLoadFailed({ reason: "source", message: scopeMessages[problem] })
880
+ );
881
+ var attributed = (account) => (error) => account !== void 0 && Schema_exports.is(SkillLoadFailed)(error) && error.reason === "request" && (error.status === 401 || error.status === 403) ? accountProviderError(
882
+ new ProviderError({
883
+ reason: error.status === 401 ? "unauthorized" : "rejected",
884
+ status: error.status
885
+ }),
886
+ account.id
887
+ ) : error;
771
888
  var githubSkillsEffect = (options) => Effect_exports.gen(function* () {
772
889
  if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(options.repo) || options.path !== void 0 && !resourcePath(options.path))
773
890
  return yield* failed("source");
891
+ const cache = yield* githubCache(options);
774
892
  return yield* cachedCatalog(
775
- options,
893
+ cache === void 0 ? options : { ...options, cache },
776
894
  ["apps/githubSkills/catalog", 1, options.repo, options.ref ?? null, options.path ?? null],
777
- (transport, cache) => githubCatalog(options, transport, cache)
895
+ (transport, cache2) => githubPublication(options, transport, cache2)
778
896
  );
779
- }).pipe(withService("GitHub"));
780
- var githubCatalog = (options, transport, cache) => Effect_exports.gen(function* () {
781
- const remote = yield* reader(transport);
782
- const commit = yield* resolveCommit(remote, options.repo, options.ref);
783
- const resources = yield* cache === void 0 ? skillDirectories(remote, options.repo, commit, options.path) : cachedSkillDirectories(cache, transport, options.repo, commit, options.path);
784
- const base = `https://raw.githubusercontent.com/${options.repo}/${commit}/`;
897
+ }).pipe(withService("GitHub"), Effect_exports.mapError(attributed(options.account)));
898
+ var githubPublication = (options, transport, cache) => Effect_exports.gen(function* () {
899
+ const github = githubRequests(yield* reader(transport), options.repo, options.token);
900
+ const commit = yield* checked(resolveCommit(github, options.ref));
901
+ return {
902
+ id: commit,
903
+ load: githubCatalog(options, github, commit, transport, cache)
904
+ };
905
+ });
906
+ var githubCatalog = (options, github, commit, transport, cache) => Effect_exports.gen(function* () {
907
+ const resources = yield* cache === void 0 ? skillDirectories(github, commit, options.path) : cachedSkillDirectories(cache, transport, options, commit);
785
908
  const skills = yield* Effect_exports.forEach(
786
909
  resources,
787
910
  ({ directory, files }) => Effect_exports.gen(function* () {
@@ -791,7 +914,7 @@ var githubCatalog = (options, transport, cache) => Effect_exports.gen(function*
791
914
  const path = file.path.slice(directory.length);
792
915
  if (!resourcePath(file.path) || !resourcePath(path) || file.mode === "120000")
793
916
  return yield* failed("source");
794
- return { path, content: yield* remote.read(pathUrl(base, file.path)) };
917
+ return { path, content: yield* github.file(commit, file.path) };
795
918
  }),
796
919
  { concurrency: skillLoadLimits.concurrency }
797
920
  );
@@ -825,13 +948,17 @@ var wellKnownSkillsEffect = (options) => Effect_exports.gen(function* () {
825
948
  return yield* cachedCatalog(
826
949
  options,
827
950
  ["apps/wellKnownSkills/catalog", 1, url.href],
828
- (transport) => wellKnownCatalog(url, transport)
951
+ (transport) => wellKnownPublication(url, transport)
829
952
  );
830
953
  }).pipe(withService(URL.canParse(options.url) ? new URL(options.url).hostname : void 0));
831
- var wellKnownCatalog = (url, transport) => Effect_exports.gen(function* () {
954
+ var wellKnownPublication = (url, transport) => Effect_exports.gen(function* () {
832
955
  const remote = yield* reader(transport);
833
- const first = yield* remote.read(url.href);
956
+ const first = yield* checked(remote.read(url.href));
834
957
  const index = yield* parse(Schema_exports.fromJsonString(Index), first);
958
+ const id = index.skills.every((skill) => skill.version !== void 0) ? yield* digest(index.skills.map(({ name, version, files }) => [name, version, files])) : void 0;
959
+ return { id, load: wellKnownCatalog(url, remote, first, index) };
960
+ });
961
+ var wellKnownCatalog = (url, remote, first, index) => Effect_exports.gen(function* () {
835
962
  if (index.skills.reduce((count, skill) => count + skill.files.length, 0) > skillLoadLimits.files)
836
963
  return yield* failed("limit");
837
964
  const skills = yield* Effect_exports.forEach(