apps 0.0.1-beta.5 → 0.0.1-beta.55

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 (188) hide show
  1. package/README.md +68 -44
  2. package/framework-reference.json +1 -1
  3. package/js/chunk-47F7VXST.js +221 -0
  4. package/js/chunk-5FHWNLCI.js +88 -0
  5. package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
  6. package/js/chunk-7UUHJR2Q.js +49 -0
  7. package/js/{chunk-CYYBFC2K.js → chunk-AQU56EPI.js} +9 -5
  8. package/js/chunk-BTSIG4NQ.js +1885 -0
  9. package/js/chunk-CDXQDN7W.js +92 -0
  10. package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
  11. package/js/{chunk-27F7W2LG.js → chunk-H2CJWXA3.js} +2 -2
  12. package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
  13. package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
  14. package/js/{chunk-UDDE5KOR.js → chunk-JK5S2N2S.js} +148 -34
  15. package/js/{chunk-RJDDBDSN.js → chunk-JM7LOD2W.js} +628 -85
  16. package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
  17. package/js/{chunk-FWQC6I3C.js → chunk-KGCTYL2S.js} +523 -63
  18. package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
  19. package/js/chunk-L4K2K22P.js +42 -0
  20. package/js/chunk-LTDHQJ2Z.js +171 -0
  21. package/js/chunk-MWKHKOTL.js +240 -0
  22. package/js/chunk-OD3KFKZD.js +1617 -0
  23. package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
  24. package/js/chunk-PXXZ6ABC.js +266 -0
  25. package/js/chunk-QEBRH5AP.js +729 -0
  26. package/js/chunk-TLWLJ7PD.js +4342 -0
  27. package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
  28. package/js/{chunk-XHO2ZX6W.js → chunk-UM62MBJQ.js} +96 -41
  29. package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
  30. package/js/chunk-XCSG7FT7.js +340 -0
  31. package/js/client.js +142 -94
  32. package/js/contracts.js +123 -33
  33. package/js/effect.js +19 -21
  34. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  35. package/js/graphql.js +63 -60
  36. package/js/host.js +83 -60
  37. package/js/index.js +262 -222
  38. package/js/mcp/effect.js +23 -23
  39. package/js/mcp/stdio.js +48 -40
  40. package/js/mcp.js +109 -72
  41. package/js/openapi.js +4129 -1419
  42. package/js/react.js +2 -3
  43. package/js/skills/effect.js +6 -3
  44. package/js/skills.js +208 -82
  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 +2 -3
  51. package/runtime.json +1 -1
  52. package/types/app-cache/src/index.d.ts +10 -1
  53. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  54. package/types/apps/src/contracts/app.d.ts +9 -8
  55. package/types/apps/src/contracts/cache.d.ts +20 -0
  56. package/types/apps/src/contracts/context.d.ts +19 -11
  57. package/types/apps/src/contracts/elicitation.d.ts +6 -6
  58. package/types/apps/src/contracts/events.d.ts +93 -0
  59. package/types/apps/src/contracts/failure.d.ts +30 -1
  60. package/types/apps/src/contracts/graphql.d.ts +2 -1
  61. package/types/apps/src/contracts/host.d.ts +57 -18
  62. package/types/apps/src/contracts/live.d.ts +2 -0
  63. package/types/apps/src/contracts/mcp.d.ts +96 -10
  64. package/types/apps/src/contracts/network.d.ts +84 -0
  65. package/types/apps/src/contracts/openapi-compile.d.ts +32 -3
  66. package/types/apps/src/contracts/openapi.d.ts +45 -9
  67. package/types/apps/src/contracts/operations.d.ts +8 -9
  68. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  69. package/types/apps/src/contracts/protocols/1.d.ts +733 -81
  70. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  71. package/types/apps/src/contracts/protocols/2.d.ts +69 -26
  72. package/types/apps/src/contracts/protocols/3.d.ts +133 -33
  73. package/types/apps/src/contracts/protocols/4.d.ts +1306 -0
  74. package/types/apps/src/contracts/protocols/5.d.ts +1200 -0
  75. package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
  76. package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
  77. package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
  78. package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
  79. package/types/apps/src/contracts/protocols/current.d.ts +2476 -0
  80. package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
  81. package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
  82. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  83. package/types/apps/src/contracts/provider.d.ts +115 -10
  84. package/types/apps/src/contracts/router.d.ts +59 -0
  85. package/types/apps/src/contracts/skills.d.ts +50 -13
  86. package/types/apps/src/contracts/sql.d.ts +58 -0
  87. package/types/apps/src/contracts/ui.d.ts +19 -1
  88. package/types/apps/src/contracts/workflows.d.ts +6 -0
  89. package/types/apps/src/facet.d.ts +4 -5
  90. package/types/apps/src/graphql.d.ts +1 -3
  91. package/types/apps/src/host.d.ts +5 -0
  92. package/types/apps/src/implementation/account-router.d.ts +13 -0
  93. package/types/apps/src/implementation/app.d.ts +5 -4
  94. package/types/apps/src/implementation/authoring.d.ts +25 -5
  95. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  96. package/types/apps/src/implementation/cache.d.ts +4 -0
  97. package/types/apps/src/implementation/catalog-cache.d.ts +43 -5
  98. package/types/apps/src/implementation/elicitation.d.ts +18 -15
  99. package/types/apps/src/implementation/events.d.ts +59 -0
  100. package/types/apps/src/implementation/failure-detail.d.ts +25 -3
  101. package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
  102. package/types/apps/src/implementation/graphql.d.ts +4 -3
  103. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  104. package/types/apps/src/implementation/invocation-timing.d.ts +16 -0
  105. package/types/apps/src/implementation/live.d.ts +2 -2
  106. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  107. package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
  108. package/types/apps/src/implementation/mcp-client.d.ts +49 -25
  109. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  110. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  111. package/types/apps/src/implementation/mcp.d.ts +52 -25
  112. package/types/apps/src/implementation/network.d.ts +16 -0
  113. package/types/apps/src/implementation/openapi-compile.d.ts +27 -6
  114. package/types/apps/src/implementation/openapi-document.d.ts +46 -19
  115. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  116. package/types/apps/src/implementation/openapi-request.d.ts +10 -2
  117. package/types/apps/src/implementation/openapi-source.d.ts +8 -6
  118. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  119. package/types/apps/src/implementation/operations.d.ts +43 -5
  120. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  121. package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
  122. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  123. package/types/apps/src/implementation/provider.d.ts +19 -5
  124. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  125. package/types/apps/src/implementation/router-catalog.d.ts +223 -0
  126. package/types/apps/src/implementation/router.d.ts +70 -0
  127. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  128. package/types/apps/src/implementation/schema.d.ts +95 -11
  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/workflow-context.d.ts +1 -1
  141. package/types/apps/src/implementation/workflows.d.ts +1 -1
  142. package/types/apps/src/index.d.ts +32 -13
  143. package/types/apps/src/mcp-stdio.d.ts +2 -5
  144. package/types/apps/src/mcp.d.ts +25 -5
  145. package/types/apps/src/openapi.d.ts +6 -6
  146. package/types/apps/src/react.d.ts +1 -1
  147. package/types/apps/src/skills.d.ts +10 -8
  148. package/types/telemetry/src/app-records.d.ts +42 -0
  149. package/types/telemetry/src/browser-operations.d.ts +7 -4
  150. package/types/telemetry/src/browser.d.ts +8 -3
  151. package/types/telemetry/src/config.d.ts +2 -2
  152. package/types/telemetry/src/index.d.ts +1 -0
  153. package/types/telemetry/src/layer.d.ts +2 -2
  154. package/types/telemetry/src/ownership.d.ts +56 -0
  155. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  156. package/types/telemetry/src/relay.d.ts +2 -2
  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-3XKZDQLM.js +0 -93
  163. package/js/chunk-4M277YTM.js +0 -136
  164. package/js/chunk-67EVWIGJ.js +0 -224
  165. package/js/chunk-C3VAOK5B.js +0 -215
  166. package/js/chunk-DQAZTA4I.js +0 -2375
  167. package/js/chunk-G7T27IWB.js +0 -63
  168. package/js/chunk-LUVSFETN.js +0 -1347
  169. package/js/chunk-N7YDVXYJ.js +0 -186
  170. package/js/chunk-PJJ24GU7.js +0 -877
  171. package/js/chunk-PZB6T6KU.js +0 -19
  172. package/js/chunk-SB3V4YVR.js +0 -18
  173. package/js/chunk-TDNYXSIX.js +0 -29
  174. package/js/chunk-W4DMKWAB.js +0 -35
  175. package/js/chunk-YEPYT6SD.js +0 -85
  176. package/js/chunk-ZQINWV4W.js +0 -630
  177. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  178. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  179. package/types/app-data/src/implementation/promise.d.ts +0 -68
  180. package/types/app-data/src/implementation/range.d.ts +0 -8
  181. package/types/app-data/src/implementation/schema.d.ts +0 -18
  182. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  183. package/types/app-data/src/index.d.ts +0 -4
  184. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  185. package/types/apps/src/contracts/storage.d.ts +0 -68
  186. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  187. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
  188. 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-XHO2ZX6W.js";
4
- import "./chunk-CYYBFC2K.js";
2
+ catalogCache,
3
+ catalogScope
4
+ } from "./chunk-UM62MBJQ.js";
5
+ import "./chunk-AQU56EPI.js";
6
+ import {
7
+ failOnNetworkRefusal
8
+ } from "./chunk-7UUHJR2Q.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-LTDHQJ2Z.js";
9
20
  import {
10
- httpProviderError
11
- } from "./chunk-G7T27IWB.js";
12
- import "./chunk-YEPYT6SD.js";
21
+ NetworkRefused,
22
+ ProviderError,
23
+ networkRefusalStatus
24
+ } from "./chunk-MWKHKOTL.js";
13
25
  import {
14
26
  AppSkillMetadata,
15
27
  AppSkillSource,
@@ -19,25 +31,29 @@ import {
19
31
  SkillLoadFailed,
20
32
  SkillServiceName,
21
33
  skillLoadLimits
22
- } from "./chunk-JU7VHODU.js";
23
- import "./chunk-SB3V4YVR.js";
34
+ } from "./chunk-H72MEDMN.js";
35
+ import {
36
+ wrap
37
+ } from "./chunk-KGCTYL2S.js";
38
+ import "./chunk-JM7LOD2W.js";
24
39
  import {
25
40
  FetchHttpClient_exports
26
- } from "./chunk-57RKNWL2.js";
41
+ } from "./chunk-PD6I2SDG.js";
42
+ import "./chunk-5FHWNLCI.js";
43
+ import "./chunk-H2CJWXA3.js";
44
+ import "./chunk-TUMGL2OC.js";
27
45
  import {
28
46
  HttpBody_exports,
29
47
  HttpClient_exports
30
- } from "./chunk-UK573G7W.js";
31
- import {
32
- wrap
33
- } from "./chunk-FWQC6I3C.js";
34
- import "./chunk-27F7W2LG.js";
48
+ } from "./chunk-EOPQ727L.js";
35
49
  import {
50
+ Base64_exports,
36
51
  Effect_exports,
52
+ Hex_exports,
37
53
  Ref_exports,
38
54
  Schema_exports,
39
55
  Stream_exports
40
- } from "./chunk-CDL5PM2Q.js";
56
+ } from "./chunk-IFJU5SYQ.js";
41
57
  import "./chunk-CZ7CSFO4.js";
42
58
 
43
59
  // src/implementation/inflate.ts
@@ -593,13 +609,15 @@ var describe = (service, { reason, status }) => {
593
609
  };
594
610
  var withService = (service) => (effect) => service === void 0 || !Schema_exports.is(SkillServiceName)(service) ? effect : effect.pipe(
595
611
  Effect_exports.mapError(
596
- (error) => !error.message ? new SkillLoadFailed({
612
+ (error) => Schema_exports.is(SkillLoadFailed)(error) && !error.message ? new SkillLoadFailed({
597
613
  reason: error.reason,
598
614
  message: describe(service, error),
599
- ...error.status === void 0 ? {} : { status: error.status }
615
+ ...error.status === void 0 ? {} : { status: error.status },
616
+ ...error.missing === void 0 ? {} : { missing: error.missing }
600
617
  }) : error
601
618
  )
602
619
  );
620
+ var loaderFailure = (error, otherwise) => Schema_exports.is(SkillLoadFailed)(error) || Schema_exports.is(NetworkRefused)(error) ? error : otherwise();
603
621
  var parse = (schema, input) => Schema_exports.decodeUnknownEffect(schema)(input).pipe(Effect_exports.mapError(() => failed("document")));
604
622
  var resourcePath = (path) => {
605
623
  if (!Schema_exports.is(SkillFilePath)(path)) return false;
@@ -615,23 +633,31 @@ var resourcePath = (path) => {
615
633
  var pathUrl = (base, path) => new URL(path.split("/").map(encodeURIComponent).join("/"), base).href;
616
634
  var reader = (transport) => Effect_exports.gen(function* () {
617
635
  const budget = yield* Ref_exports.make(0);
618
- const fetchBytes = (url, post) => Effect_exports.gen(function* () {
636
+ const fetchBytes = (url, request = {}) => Effect_exports.gen(function* () {
619
637
  const parsed = yield* Effect_exports.try({
620
638
  try: () => new URL(url),
621
639
  catch: () => failed("source")
622
640
  });
623
641
  if (!["https:", "http:"].includes(parsed.protocol) || parsed.username || parsed.password || parsed.hash)
624
642
  return yield* failed("source");
643
+ const refusal = request.refused ?? ((refused) => refused);
625
644
  const client = HttpClient_exports.withScope(yield* HttpClient_exports.HttpClient);
626
645
  const headers = {
627
646
  "User-Agent": "executor-skills",
628
647
  Accept: "application/json, text/plain",
629
- "Cache-Control": "no-cache"
648
+ "Cache-Control": "no-cache",
649
+ ...request.headers
630
650
  };
631
- const response = yield* (post === void 0 ? client.get(parsed, { headers }) : client.post(parsed, {
632
- headers: { ...headers, ...post.headers },
633
- body: HttpBody_exports.uint8Array(post.body, post.headers["Content-Type"])
634
- })).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));
635
661
  if (response.status < 200 || response.status >= 300)
636
662
  return yield* rejected(response.status, response.headers);
637
663
  const chunks = [];
@@ -661,7 +687,7 @@ var reader = (transport) => Effect_exports.gen(function* () {
661
687
  Effect_exports.provideService(FetchHttpClient_exports.RequestInit, { redirect: "manual" }),
662
688
  Effect_exports.provideService(FetchHttpClient_exports.Fetch, transport.fetch ?? globalThis.fetch)
663
689
  );
664
- const read = (url) => fetchBytes(url).pipe(
690
+ const read = (url, request = {}) => fetchBytes(url, request).pipe(
665
691
  Effect_exports.flatMap(
666
692
  (result) => Effect_exports.try({
667
693
  try: () => new TextDecoder("utf-8", { fatal: true }).decode(result),
@@ -676,39 +702,68 @@ var unreadable = () => new SkillLoadFailed({
676
702
  reason: "request",
677
703
  message: "GitHub returned a git response Executor could not read."
678
704
  });
679
- var git = (run) => Effect_exports.tryPromise({
680
- try: async () => run(),
681
- catch: (error) => error instanceof InflateLimitExceeded ? failed("limit") : unreadable()
682
- });
683
- 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;
684
735
  if (ref !== void 0 && /^[a-f0-9]{40}$/.test(ref)) return ref;
685
736
  const names = refCandidates(ref);
686
- const response = yield* remote.fetchBytes(`https://github.com/${repo}.git/git-upload-pack`, {
687
- body: lsRefsRequest(names),
688
- headers: gitRequestHeaders
689
- }).pipe(
690
- // GitHub asks for credentials when a repository is missing or private.
691
- Effect_exports.mapError(
692
- (error) => error.status === 401 || error.status === 404 ? new SkillLoadFailed({
693
- reason: "source",
694
- message: `GitHub has no public repository named ${repo}.`,
695
- status: error.status
696
- }) : error
697
- )
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
+ })
698
755
  );
699
756
  const refs = yield* git(() => parseLsRefs(response));
700
757
  const commit = names.map((name) => refs.get(name)).find((sha) => sha !== void 0);
701
758
  if (commit === void 0)
702
759
  return yield* new SkillLoadFailed({
703
760
  reason: "source",
704
- 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"
705
763
  });
706
764
  return commit;
707
765
  });
708
- var listFiles = (remote, repo, commit, path) => remote.fetchBytes(`https://github.com/${repo}.git/git-upload-pack`, {
709
- body: treeFetchRequest(commit),
710
- headers: gitRequestHeaders
711
- }).pipe(
766
+ var listFiles = (github, commit, path) => github.upload(treeFetchRequest(commit)).pipe(
712
767
  Effect_exports.flatMap(
713
768
  (response) => git(
714
769
  () => parseTreeFetch(response, commit, path, { objectBytes: skillLoadLimits.fileBytes })
@@ -721,8 +776,8 @@ var SkillDirectories = Schema_exports.Array(
721
776
  files: Schema_exports.Array(Schema_exports.Struct({ path: Schema_exports.String, mode: Schema_exports.String }))
722
777
  })
723
778
  );
724
- var skillDirectories = (remote, repo, commit, path) => Effect_exports.gen(function* () {
725
- 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);
726
781
  const documents = files.filter(
727
782
  (file) => file.path === "SKILL.md" || file.path.endsWith("/SKILL.md")
728
783
  );
@@ -734,55 +789,122 @@ var skillDirectories = (remote, repo, commit, path) => Effect_exports.gen(functi
734
789
  return yield* failed("limit");
735
790
  return directories;
736
791
  });
737
- var cachedSkillDirectories = (cache, transport, repo, commit, path) => Effect_exports.tryPromise({
738
- try: () => cache.get({
739
- key: ["apps/githubSkills/directories", 1, repo, commit, path ?? null],
740
- schema: wrap(SkillDirectories, false),
741
- freshFor: "7 days",
742
- load: (context) => Effect_exports.runPromise(
743
- // 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.
744
803
  reader({ fetch: transport.fetch, signal: context.signal }).pipe(
745
- Effect_exports.flatMap((remote) => skillDirectories(remote, repo, commit, path))
746
- ),
747
- { 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
+ })
748
824
  )
749
- }),
750
- catch: (error) => Schema_exports.is(SkillLoadFailed)(error) ? error : new SkillLoadFailed({
751
- reason: "request",
752
- 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"))
753
837
  })
754
- });
755
- 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({
756
840
  cache: options.cache,
757
841
  ...options.freshFor === void 0 ? {} : { freshFor: options.freshFor },
758
842
  ...options.staleFor === void 0 ? {} : { staleFor: options.staleFor },
843
+ stale: "revalidate",
759
844
  prefix,
760
845
  schema: AppSkillSource,
761
846
  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)
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
+ })
763
854
  }).pipe(
764
855
  Effect_exports.flatMap((catalog) => catalog.list()),
765
856
  Effect_exports.mapError(
766
- (error) => Schema_exports.is(SkillLoadFailed)(error) ? error : new SkillLoadFailed({
767
- reason: "request",
768
- message: "Executor could not read or update the app cache for skills."
769
- })
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
+ )
770
864
  )
771
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;
772
888
  var githubSkillsEffect = (options) => Effect_exports.gen(function* () {
773
889
  if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(options.repo) || options.path !== void 0 && !resourcePath(options.path))
774
890
  return yield* failed("source");
891
+ const cache = yield* githubCache(options);
775
892
  return yield* cachedCatalog(
776
- options,
893
+ cache === void 0 ? options : { ...options, cache },
777
894
  ["apps/githubSkills/catalog", 1, options.repo, options.ref ?? null, options.path ?? null],
778
- (transport, cache) => githubCatalog(options, transport, cache)
895
+ (transport, cache2) => githubPublication(options, transport, cache2)
779
896
  );
780
- }).pipe(withService("GitHub"));
781
- var githubCatalog = (options, transport, cache) => Effect_exports.gen(function* () {
782
- const remote = yield* reader(transport);
783
- const commit = yield* resolveCommit(remote, options.repo, options.ref);
784
- const resources = yield* cache === void 0 ? skillDirectories(remote, options.repo, commit, options.path) : cachedSkillDirectories(cache, transport, options.repo, commit, options.path);
785
- 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);
786
908
  const skills = yield* Effect_exports.forEach(
787
909
  resources,
788
910
  ({ directory, files }) => Effect_exports.gen(function* () {
@@ -792,7 +914,7 @@ var githubCatalog = (options, transport, cache) => Effect_exports.gen(function*
792
914
  const path = file.path.slice(directory.length);
793
915
  if (!resourcePath(file.path) || !resourcePath(path) || file.mode === "120000")
794
916
  return yield* failed("source");
795
- return { path, content: yield* remote.read(pathUrl(base, file.path)) };
917
+ return { path, content: yield* github.file(commit, file.path) };
796
918
  }),
797
919
  { concurrency: skillLoadLimits.concurrency }
798
920
  );
@@ -826,13 +948,17 @@ var wellKnownSkillsEffect = (options) => Effect_exports.gen(function* () {
826
948
  return yield* cachedCatalog(
827
949
  options,
828
950
  ["apps/wellKnownSkills/catalog", 1, url.href],
829
- (transport) => wellKnownCatalog(url, transport)
951
+ (transport) => wellKnownPublication(url, transport)
830
952
  );
831
953
  }).pipe(withService(URL.canParse(options.url) ? new URL(options.url).hostname : void 0));
832
- var wellKnownCatalog = (url, transport) => Effect_exports.gen(function* () {
954
+ var wellKnownPublication = (url, transport) => Effect_exports.gen(function* () {
833
955
  const remote = yield* reader(transport);
834
- const first = yield* remote.read(url.href);
956
+ const first = yield* checked(remote.read(url.href));
835
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* () {
836
962
  if (index.skills.reduce((count, skill) => count + skill.files.length, 0) > skillLoadLimits.files)
837
963
  return yield* failed("limit");
838
964
  const skills = yield* Effect_exports.forEach(