apps 0.0.1-beta.12 → 0.0.1-beta.121

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