apps 0.0.1-beta.33 → 0.0.1-beta.35

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 (83) hide show
  1. package/framework-reference.json +1 -1
  2. package/js/{chunk-TEV5IMOM.js → chunk-5CQMUXW7.js} +2 -2
  3. package/js/{chunk-N72RKJ5E.js → chunk-5KNA2Z5I.js} +13 -102
  4. package/js/{chunk-UMCMZFXW.js → chunk-73AV3JVU.js} +1 -1
  5. package/js/{chunk-6ZJ2H6P4.js → chunk-A4O72Z3A.js} +298 -190
  6. package/js/{chunk-FBBXFFFJ.js → chunk-BI45HZWM.js} +2 -2
  7. package/js/{chunk-5DLG2FVN.js → chunk-BI6R577B.js} +93 -2
  8. package/js/{chunk-4OKYLVU4.js → chunk-ENJCQWVF.js} +3 -3
  9. package/js/{chunk-OX233L7N.js → chunk-FFTALB6S.js} +2 -2
  10. package/js/{chunk-DASNNAP4.js → chunk-HDAQBRT5.js} +391 -14
  11. package/js/{chunk-HW3DPBZR.js → chunk-I7CNZ4CM.js} +1 -1
  12. package/js/{chunk-GMMS4BY3.js → chunk-IA3VSGR4.js} +7 -7
  13. package/js/{chunk-EXGKN554.js → chunk-IJQ5LE74.js} +9805 -9254
  14. package/js/{chunk-5JVNM3CQ.js → chunk-IU7CCCUC.js} +12 -12
  15. package/js/{chunk-AYM2FUI5.js → chunk-JU7F4PRK.js} +2 -2
  16. package/js/{chunk-E6C2DUIA.js → chunk-KBXQOJYW.js} +8 -8
  17. package/js/{chunk-CJY5X26R.js → chunk-KOOJUMLR.js} +86 -50
  18. package/js/{chunk-ETLILMHY.js → chunk-KZFV3WCJ.js} +21 -19
  19. package/js/{chunk-AKKJDDOT.js → chunk-LUROQKFP.js} +10 -10
  20. package/js/{chunk-ZOY7PDMI.js → chunk-NHCFIWN5.js} +1 -1
  21. package/js/chunk-NHUHTWAF.js +0 -0
  22. package/js/{chunk-QYM4STZW.js → chunk-PHO7HXTC.js} +149 -353
  23. package/js/{chunk-O3OAFU7Q.js → chunk-POOIHRPF.js} +2 -2
  24. package/js/{chunk-AUFVX4KM.js → chunk-RSNZDT4L.js} +2 -2
  25. package/js/chunk-SRB2WDU7.js +49 -0
  26. package/js/{chunk-MFHUR5SB.js → chunk-TADLIUEU.js} +4 -4
  27. package/js/{chunk-3BHBWZLD.js → chunk-UWOIEJ56.js} +20 -18
  28. package/js/chunk-V5DWGYRK.js +268 -0
  29. package/js/{chunk-75JKK3ZE.js → chunk-VBVOPW4U.js} +3 -3
  30. package/js/{chunk-GZ4UHXRT.js → chunk-WDBUOIWV.js} +3 -3
  31. package/js/{chunk-6KG4DZD7.js → chunk-Y3XN4X4Q.js} +1 -1
  32. package/js/{chunk-WWSRAE5Y.js → chunk-YW333DH3.js} +11 -8
  33. package/js/{chunk-2SRLJHPM.js → chunk-YYK6GEMC.js} +14 -53
  34. package/js/client.js +12 -11
  35. package/js/contracts.js +17 -16
  36. package/js/effect.js +23 -20
  37. package/js/graphql.js +27 -25
  38. package/js/host.js +23 -20
  39. package/js/index.js +18 -16
  40. package/js/mcp/effect.js +25 -22
  41. package/js/mcp/stdio.js +25 -22
  42. package/js/mcp.js +28 -25
  43. package/js/openapi.js +25 -22
  44. package/js/react.js +3 -3
  45. package/js/skills/effect.js +6 -5
  46. package/js/skills.js +119 -49
  47. package/js/storage/facet.js +19 -345
  48. package/js/ui/auth/contracts.js +2 -2
  49. package/js/ui/auth.js +5 -5
  50. package/js/ui/contracts.js +6 -5
  51. package/js/ui/serving.js +10 -9
  52. package/package.json +3 -3
  53. package/runtime.json +1 -1
  54. package/types/app-data/src/implementation/sqlite.d.ts +1 -1
  55. package/types/apps/src/contracts/cache.d.ts +14 -0
  56. package/types/apps/src/contracts/elicitation.d.ts +6 -6
  57. package/types/apps/src/contracts/protocols/1.d.ts +4 -4
  58. package/types/apps/src/contracts/protocols/2.d.ts +4 -4
  59. package/types/apps/src/contracts/protocols/3.d.ts +4 -4
  60. package/types/apps/src/contracts/protocols/4.d.ts +4 -4
  61. package/types/apps/src/contracts/protocols/5.d.ts +4 -4
  62. package/types/apps/src/contracts/protocols/6.d.ts +4 -4
  63. package/types/apps/src/contracts/protocols/7.d.ts +4 -4
  64. package/types/apps/src/contracts/protocols/8.d.ts +4 -4
  65. package/types/apps/src/contracts/skills.d.ts +16 -4
  66. package/types/apps/src/contracts/ui.d.ts +1 -1
  67. package/types/apps/src/implementation/catalog-cache.d.ts +14 -17
  68. package/types/apps/src/implementation/live.d.ts +2 -2
  69. package/types/apps/src/implementation/network.d.ts +1 -1
  70. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  71. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  72. package/types/apps/src/implementation/skills.d.ts +13 -19
  73. package/types/apps/src/implementation/ui-auth.d.ts +1 -1
  74. package/types/apps/src/implementation/ui-client.d.ts +1 -1
  75. package/types/apps/src/implementation/ui-serving.d.ts +1 -1
  76. package/types/apps/src/react.d.ts +1 -1
  77. package/types/apps/src/skills.d.ts +4 -3
  78. package/types/telemetry/src/browser-operations.d.ts +1 -1
  79. package/types/telemetry/src/browser.d.ts +2 -2
  80. package/types/telemetry/src/layer.d.ts +2 -2
  81. package/types/telemetry/src/relay.d.ts +2 -2
  82. package/types/telemetry/src/transport.d.ts +1 -1
  83. package/types/utils/src/api-error.d.ts +1 -1
package/js/mcp/stdio.js CHANGED
@@ -3,37 +3,40 @@ import {
3
3
  answeredError,
4
4
  mcpClient,
5
5
  mcpJsonSchemaValidator
6
- } from "../chunk-GMMS4BY3.js";
6
+ } from "../chunk-IA3VSGR4.js";
7
7
  import {
8
8
  protocolRouter
9
- } from "../chunk-TEV5IMOM.js";
9
+ } from "../chunk-5CQMUXW7.js";
10
10
  import "../chunk-BCSNKUAC.js";
11
- import "../chunk-3BHBWZLD.js";
12
- import "../chunk-AYM2FUI5.js";
13
- import "../chunk-2SRLJHPM.js";
14
- import "../chunk-OX233L7N.js";
15
- import "../chunk-E6C2DUIA.js";
16
- import "../chunk-5JVNM3CQ.js";
17
- import "../chunk-75JKK3ZE.js";
18
- import "../chunk-4OKYLVU4.js";
11
+ import "../chunk-UWOIEJ56.js";
12
+ import "../chunk-JU7F4PRK.js";
13
+ import "../chunk-YYK6GEMC.js";
14
+ import "../chunk-SRB2WDU7.js";
15
+ import "../chunk-FFTALB6S.js";
16
+ import "../chunk-KBXQOJYW.js";
17
+ import "../chunk-IU7CCCUC.js";
18
+ import "../chunk-VBVOPW4U.js";
19
+ import "../chunk-ENJCQWVF.js";
20
+ import "../chunk-NHUHTWAF.js";
19
21
  import {
20
22
  McpError,
21
23
  ProcessConfig
22
- } from "../chunk-N72RKJ5E.js";
23
- import "../chunk-UMCMZFXW.js";
24
- import "../chunk-5DLG2FVN.js";
25
- import "../chunk-HW3DPBZR.js";
26
- import "../chunk-ETLILMHY.js";
27
- import "../chunk-MFHUR5SB.js";
28
- import "../chunk-O3OAFU7Q.js";
29
- import "../chunk-6KG4DZD7.js";
30
- import "../chunk-FBBXFFFJ.js";
31
- import "../chunk-QYM4STZW.js";
32
- import "../chunk-CJY5X26R.js";
24
+ } from "../chunk-5KNA2Z5I.js";
25
+ import "../chunk-73AV3JVU.js";
26
+ import "../chunk-BI6R577B.js";
27
+ import "../chunk-I7CNZ4CM.js";
28
+ import "../chunk-KZFV3WCJ.js";
29
+ import "../chunk-TADLIUEU.js";
30
+ import "../chunk-POOIHRPF.js";
31
+ import "../chunk-Y3XN4X4Q.js";
32
+ import "../chunk-BI45HZWM.js";
33
+ import "../chunk-PHO7HXTC.js";
34
+ import "../chunk-V5DWGYRK.js";
35
+ import "../chunk-KOOJUMLR.js";
33
36
  import {
34
37
  Effect_exports,
35
38
  Schema_exports
36
- } from "../chunk-EXGKN554.js";
39
+ } from "../chunk-IJQ5LE74.js";
37
40
  import "../chunk-CZ7CSFO4.js";
38
41
 
39
42
  // src/implementation/mcp-stdio.ts
package/js/mcp.js CHANGED
@@ -1,54 +1,57 @@
1
1
  import {
2
2
  mcpClientEffect,
3
3
  mcpHealthEffect
4
- } from "./chunk-AKKJDDOT.js";
4
+ } from "./chunk-LUROQKFP.js";
5
5
  import {
6
6
  catalogCache,
7
7
  catalogScope
8
- } from "./chunk-WWSRAE5Y.js";
8
+ } from "./chunk-YW333DH3.js";
9
9
  import {
10
10
  adaptMcpTool
11
- } from "./chunk-GMMS4BY3.js";
11
+ } from "./chunk-IA3VSGR4.js";
12
12
  import {
13
13
  protocolOperations
14
- } from "./chunk-TEV5IMOM.js";
14
+ } from "./chunk-5CQMUXW7.js";
15
15
  import "./chunk-BCSNKUAC.js";
16
- import "./chunk-3BHBWZLD.js";
16
+ import "./chunk-UWOIEJ56.js";
17
17
  import {
18
18
  cacheKey
19
- } from "./chunk-AYM2FUI5.js";
19
+ } from "./chunk-JU7F4PRK.js";
20
20
  import {
21
21
  operationDescription
22
- } from "./chunk-2SRLJHPM.js";
23
- import "./chunk-OX233L7N.js";
24
- import "./chunk-E6C2DUIA.js";
25
- import "./chunk-5JVNM3CQ.js";
22
+ } from "./chunk-YYK6GEMC.js";
23
+ import "./chunk-SRB2WDU7.js";
24
+ import "./chunk-FFTALB6S.js";
25
+ import "./chunk-KBXQOJYW.js";
26
+ import "./chunk-IU7CCCUC.js";
26
27
  import {
27
28
  nativeOperation,
28
29
  routerDeclaration
29
- } from "./chunk-75JKK3ZE.js";
30
- import "./chunk-4OKYLVU4.js";
30
+ } from "./chunk-VBVOPW4U.js";
31
+ import "./chunk-ENJCQWVF.js";
32
+ import "./chunk-NHUHTWAF.js";
31
33
  import {
32
34
  McpCredentialsUnverified,
33
35
  McpError,
34
36
  McpServerHeader,
35
37
  McpToolMetadata,
36
38
  McpToolsOptions
37
- } from "./chunk-N72RKJ5E.js";
38
- import "./chunk-UMCMZFXW.js";
39
- import "./chunk-5DLG2FVN.js";
40
- import "./chunk-HW3DPBZR.js";
41
- import "./chunk-ETLILMHY.js";
42
- import "./chunk-MFHUR5SB.js";
43
- import "./chunk-O3OAFU7Q.js";
44
- import "./chunk-6KG4DZD7.js";
45
- import "./chunk-FBBXFFFJ.js";
46
- import "./chunk-QYM4STZW.js";
47
- import "./chunk-CJY5X26R.js";
39
+ } from "./chunk-5KNA2Z5I.js";
40
+ import "./chunk-73AV3JVU.js";
41
+ import "./chunk-BI6R577B.js";
42
+ import "./chunk-I7CNZ4CM.js";
43
+ import "./chunk-KZFV3WCJ.js";
44
+ import "./chunk-TADLIUEU.js";
45
+ import "./chunk-POOIHRPF.js";
46
+ import "./chunk-Y3XN4X4Q.js";
47
+ import "./chunk-BI45HZWM.js";
48
+ import "./chunk-PHO7HXTC.js";
49
+ import "./chunk-V5DWGYRK.js";
50
+ import "./chunk-KOOJUMLR.js";
48
51
  import {
49
52
  Effect_exports,
50
53
  Schema_exports
51
- } from "./chunk-EXGKN554.js";
54
+ } from "./chunk-IJQ5LE74.js";
52
55
  import "./chunk-CZ7CSFO4.js";
53
56
 
54
57
  // src/implementation/mcp-catalog.ts
@@ -74,7 +77,7 @@ var mcpCatalog = (options, kinds) => Effect_exports.gen(function* () {
74
77
  signal: options.signal,
75
78
  timeoutMs: options.timeoutMs
76
79
  }).pipe(Effect_exports.mapError(invalid));
77
- const cache = yield* catalogScope(options, invalid);
80
+ const cache = yield* catalogScope(options, options.headers, invalid);
78
81
  const id = yield* cacheKey({ url: parsed.url });
79
82
  const key = ["mcp-catalog-v3", id, "current"];
80
83
  const changed = cache === void 0 ? void 0 : invoke(() => cache.invalidate(key));
package/js/openapi.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  protocolOperations,
10
10
  protocolRouter
11
- } from "./chunk-TEV5IMOM.js";
11
+ } from "./chunk-5CQMUXW7.js";
12
12
  import {
13
13
  OpenapiCompileError,
14
14
  OpenapiCompileErrorCode,
@@ -21,63 +21,67 @@ import {
21
21
  OpenapiSkippedOperation,
22
22
  OpenapiToolsOptions,
23
23
  defaultOpenapiResponseLimits,
24
- failOnNetworkRefusal,
25
24
  isOpenapiFileSchema,
26
25
  isOpenapiJsonSequence,
27
26
  isOpenapiReadMethod,
28
27
  isOpenapiTextMedia,
29
28
  openapiBinaryResultSchema,
30
29
  openapiMediaKind
31
- } from "./chunk-2SRLJHPM.js";
32
- import "./chunk-OX233L7N.js";
30
+ } from "./chunk-YYK6GEMC.js";
31
+ import {
32
+ failOnNetworkRefusal
33
+ } from "./chunk-SRB2WDU7.js";
34
+ import "./chunk-FFTALB6S.js";
33
35
  import {
34
36
  fromPromise,
35
37
  nativeOperation,
36
38
  routerDeclaration,
37
39
  toPromise
38
- } from "./chunk-75JKK3ZE.js";
40
+ } from "./chunk-VBVOPW4U.js";
39
41
  import {
40
42
  accountProviderError,
41
43
  httpProviderError
42
- } from "./chunk-4OKYLVU4.js";
44
+ } from "./chunk-ENJCQWVF.js";
45
+ import "./chunk-NHUHTWAF.js";
43
46
  import {
44
47
  ApiErrorRecovery,
45
48
  ApiErrorResponse,
46
- NetworkRefused,
47
49
  OpenapiResponseError,
48
50
  RouterMeta,
49
51
  defaultOpenapiErrorLimits
50
- } from "./chunk-N72RKJ5E.js";
51
- import "./chunk-UMCMZFXW.js";
52
+ } from "./chunk-5KNA2Z5I.js";
53
+ import "./chunk-73AV3JVU.js";
52
54
  import {
55
+ NetworkRefused,
53
56
  ProviderError,
54
57
  cacheLimits
55
- } from "./chunk-5DLG2FVN.js";
56
- import "./chunk-HW3DPBZR.js";
57
- import "./chunk-ETLILMHY.js";
58
+ } from "./chunk-BI6R577B.js";
59
+ import "./chunk-I7CNZ4CM.js";
60
+ import "./chunk-KZFV3WCJ.js";
58
61
  import {
59
62
  FetchHttpClient_exports
60
- } from "./chunk-MFHUR5SB.js";
63
+ } from "./chunk-TADLIUEU.js";
61
64
  import {
62
65
  jsonSchema,
63
66
  lazyJsonSchemaDecoder,
64
67
  once,
65
68
  wrap
66
- } from "./chunk-O3OAFU7Q.js";
67
- import "./chunk-6KG4DZD7.js";
69
+ } from "./chunk-POOIHRPF.js";
70
+ import "./chunk-Y3XN4X4Q.js";
68
71
  import {
69
72
  JsonObject
70
- } from "./chunk-FBBXFFFJ.js";
71
- import "./chunk-QYM4STZW.js";
73
+ } from "./chunk-BI45HZWM.js";
74
+ import "./chunk-PHO7HXTC.js";
75
+ import "./chunk-V5DWGYRK.js";
72
76
  import {
73
77
  HttpClientRequest_exports,
74
78
  HttpClient_exports
75
- } from "./chunk-CJY5X26R.js";
79
+ } from "./chunk-KOOJUMLR.js";
76
80
  import {
81
+ Base64_exports,
77
82
  Deferred_exports,
78
83
  Duration_exports,
79
84
  Effect_exports,
80
- Encoding_exports,
81
85
  Exit_exports,
82
86
  JsonPointer_exports,
83
87
  JsonSchema_exports,
@@ -85,7 +89,7 @@ import {
85
89
  SchemaIssue_exports,
86
90
  Schema_exports,
87
91
  Stream_exports
88
- } from "./chunk-EXGKN554.js";
92
+ } from "./chunk-IJQ5LE74.js";
89
93
  import "./chunk-CZ7CSFO4.js";
90
94
 
91
95
  // src/implementation/swagger-client.ts
@@ -391,8 +395,7 @@ function createRequest(config) {
391
395
  data.set(chunk, offset);
392
396
  offset += chunk.length;
393
397
  }
394
- if (!isOpenapiTextMedia(contentType))
395
- return { base64: Encoding_exports.encodeBase64(data), contentType };
398
+ if (!isOpenapiTextMedia(contentType)) return { base64: Base64_exports.encode(data), contentType };
396
399
  const text = new TextDecoder().decode(data);
397
400
  return contentType.includes("json") && !isOpenapiJsonSequence(contentType) ? yield* Schema_exports.decodeUnknownEffect(Schema_exports.fromJsonString(Schema_exports.Json))(text).pipe(
398
401
  Effect_exports.mapError(() => unreadable)
package/js/react.js CHANGED
@@ -2,11 +2,11 @@ import {
2
2
  AsyncResult_exports,
3
3
  AtomRegistry_exports,
4
4
  queryCommitted
5
- } from "./chunk-6ZJ2H6P4.js";
6
- import "./chunk-DASNNAP4.js";
5
+ } from "./chunk-A4O72Z3A.js";
6
+ import "./chunk-HDAQBRT5.js";
7
7
  import {
8
8
  Option_exports
9
- } from "./chunk-EXGKN554.js";
9
+ } from "./chunk-IJQ5LE74.js";
10
10
  import "./chunk-CZ7CSFO4.js";
11
11
 
12
12
  // src/react.ts
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  folderSkillsEffect,
3
3
  skillFromFiles
4
- } from "../chunk-OX233L7N.js";
5
- import "../chunk-HW3DPBZR.js";
6
- import "../chunk-QYM4STZW.js";
7
- import "../chunk-CJY5X26R.js";
8
- import "../chunk-EXGKN554.js";
4
+ } from "../chunk-FFTALB6S.js";
5
+ import "../chunk-I7CNZ4CM.js";
6
+ import "../chunk-PHO7HXTC.js";
7
+ import "../chunk-V5DWGYRK.js";
8
+ import "../chunk-KOOJUMLR.js";
9
+ import "../chunk-IJQ5LE74.js";
9
10
  import "../chunk-CZ7CSFO4.js";
10
11
  export {
11
12
  folderSkillsEffect,
package/js/skills.js CHANGED
@@ -1,15 +1,25 @@
1
1
  import {
2
- catalogCache
3
- } from "./chunk-WWSRAE5Y.js";
4
- import "./chunk-AYM2FUI5.js";
2
+ catalogCache,
3
+ catalogScope
4
+ } from "./chunk-YW333DH3.js";
5
+ import "./chunk-JU7F4PRK.js";
6
+ import {
7
+ failOnNetworkRefusal
8
+ } from "./chunk-SRB2WDU7.js";
5
9
  import {
6
10
  folderSkillsEffect,
7
11
  skillFromFiles
8
- } from "./chunk-OX233L7N.js";
12
+ } from "./chunk-FFTALB6S.js";
9
13
  import {
14
+ accountProviderError,
10
15
  httpProviderError
11
- } from "./chunk-4OKYLVU4.js";
12
- import "./chunk-5DLG2FVN.js";
16
+ } from "./chunk-ENJCQWVF.js";
17
+ import "./chunk-NHUHTWAF.js";
18
+ import {
19
+ NetworkRefused,
20
+ ProviderError,
21
+ networkRefusalStatus
22
+ } from "./chunk-BI6R577B.js";
13
23
  import {
14
24
  AppSkillMetadata,
15
25
  AppSkillSource,
@@ -19,25 +29,28 @@ import {
19
29
  SkillLoadFailed,
20
30
  SkillServiceName,
21
31
  skillLoadLimits
22
- } from "./chunk-HW3DPBZR.js";
32
+ } from "./chunk-I7CNZ4CM.js";
33
+ import "./chunk-KZFV3WCJ.js";
23
34
  import {
24
35
  FetchHttpClient_exports
25
- } from "./chunk-MFHUR5SB.js";
36
+ } from "./chunk-TADLIUEU.js";
26
37
  import {
27
38
  wrap
28
- } from "./chunk-O3OAFU7Q.js";
29
- import "./chunk-FBBXFFFJ.js";
30
- import "./chunk-QYM4STZW.js";
39
+ } from "./chunk-POOIHRPF.js";
40
+ import "./chunk-BI45HZWM.js";
41
+ import "./chunk-PHO7HXTC.js";
42
+ import "./chunk-V5DWGYRK.js";
31
43
  import {
32
44
  HttpBody_exports,
33
45
  HttpClient_exports
34
- } from "./chunk-CJY5X26R.js";
46
+ } from "./chunk-KOOJUMLR.js";
35
47
  import {
48
+ Base64_exports,
36
49
  Effect_exports,
37
50
  Ref_exports,
38
51
  Schema_exports,
39
52
  Stream_exports
40
- } from "./chunk-EXGKN554.js";
53
+ } from "./chunk-IJQ5LE74.js";
41
54
  import "./chunk-CZ7CSFO4.js";
42
55
 
43
56
  // src/implementation/inflate.ts
@@ -600,6 +613,11 @@ var withService = (service) => (effect) => service === void 0 || !Schema_exports
600
613
  }) : error
601
614
  )
602
615
  );
616
+ var refusedRequest = (refused) => new SkillLoadFailed({
617
+ reason: "source",
618
+ status: networkRefusalStatus,
619
+ message: refused.message.slice(0, 500)
620
+ });
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 refused = request.refused ?? refusedRequest;
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 a request Executor's app network refused.
656
+ Effect_exports.mapError(
657
+ (error) => Schema_exports.is(NetworkRefused)(error.cause) ? refused(error.cause) : failed("request")
658
+ )
659
+ );
660
+ yield* failOnNetworkRefusal(response).pipe(Effect_exports.mapError(refused));
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),
@@ -680,21 +706,40 @@ var git = (run) => Effect_exports.tryPromise({
680
706
  try: async () => run(),
681
707
  catch: (error) => error instanceof InflateLimitExceeded ? failed("limit") : unreadable()
682
708
  });
683
- var resolveCommit = (remote, repo, ref) => Effect_exports.gen(function* () {
709
+ var githubHosts = ["github.com", "raw.githubusercontent.com"];
710
+ var githubRequests = (remote, repo, token) => {
711
+ const refused = (host) => (refusal) => refusal.refusal.reason === "credential_host" ? new SkillLoadFailed({
712
+ reason: "source",
713
+ status: networkRefusalStatus,
714
+ message: `Executor did not send the GitHub token to ${host}. The account's provider must declare hosts ${githubHosts.join(" and ")}; reconnect an account connected with other hosts.`
715
+ }) : refusedRequest(refusal);
716
+ const upload = (body) => remote.fetchBytes(`https://${githubHosts[0]}/${repo}.git/git-upload-pack`, {
717
+ body,
718
+ headers: {
719
+ ...gitRequestHeaders,
720
+ ...token === void 0 ? {} : { Authorization: `Basic ${Base64_exports.encode(`x-access-token:${token}`)}` }
721
+ },
722
+ refused: refused(githubHosts[0])
723
+ });
724
+ const file = (commit, path) => remote.read(pathUrl(`https://${githubHosts[1]}/${repo}/${commit}/`, path), {
725
+ ...token === void 0 ? {} : { headers: { Authorization: `token ${token}` } },
726
+ refused: refused(githubHosts[1])
727
+ });
728
+ return { repo, authenticated: token !== void 0, upload, file };
729
+ };
730
+ var resolveCommit = (github, ref) => Effect_exports.gen(function* () {
731
+ const { repo } = github;
684
732
  if (ref !== void 0 && /^[a-f0-9]{40}$/.test(ref)) return ref;
685
733
  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({
734
+ const response = yield* github.upload(lsRefsRequest(names)).pipe(
735
+ Effect_exports.mapError((error) => {
736
+ const hidden = error.reason === "request" && (error.status === 404 || error.status === 401 && !github.authenticated);
737
+ return hidden ? new SkillLoadFailed({
693
738
  reason: "source",
694
- message: `GitHub has no public repository named ${repo}.`,
739
+ message: github.authenticated ? `GitHub has no repository named ${repo} that the account's token can read.` : `GitHub has no public repository named ${repo}. To read a private repository, pass a GitHub account and its token.`,
695
740
  status: error.status
696
- }) : error
697
- )
741
+ }) : error;
742
+ })
698
743
  );
699
744
  const refs = yield* git(() => parseLsRefs(response));
700
745
  const commit = names.map((name) => refs.get(name)).find((sha) => sha !== void 0);
@@ -705,10 +750,7 @@ var resolveCommit = (remote, repo, ref) => Effect_exports.gen(function* () {
705
750
  });
706
751
  return commit;
707
752
  });
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(
753
+ var listFiles = (github, commit, path) => github.upload(treeFetchRequest(commit)).pipe(
712
754
  Effect_exports.flatMap(
713
755
  (response) => git(
714
756
  () => parseTreeFetch(response, commit, path, { objectBytes: skillLoadLimits.fileBytes })
@@ -721,8 +763,8 @@ var SkillDirectories = Schema_exports.Array(
721
763
  files: Schema_exports.Array(Schema_exports.Struct({ path: Schema_exports.String, mode: Schema_exports.String }))
722
764
  })
723
765
  );
724
- var skillDirectories = (remote, repo, commit, path) => Effect_exports.gen(function* () {
725
- const files = yield* listFiles(remote, repo, commit, path);
766
+ var skillDirectories = (github, commit, path) => Effect_exports.gen(function* () {
767
+ const files = yield* listFiles(github, commit, path);
726
768
  const documents = files.filter(
727
769
  (file) => file.path === "SKILL.md" || file.path.endsWith("/SKILL.md")
728
770
  );
@@ -734,15 +776,21 @@ var skillDirectories = (remote, repo, commit, path) => Effect_exports.gen(functi
734
776
  return yield* failed("limit");
735
777
  return directories;
736
778
  });
737
- var cachedSkillDirectories = (cache, transport, repo, commit, path) => Effect_exports.tryPromise({
779
+ var cachedSkillDirectories = (cache, transport, options, commit) => Effect_exports.tryPromise({
738
780
  try: () => cache.get({
739
- key: ["apps/githubSkills/directories", 1, repo, commit, path ?? null],
781
+ key: ["apps/githubSkills/directories", 1, options.repo, commit, options.path ?? null],
740
782
  schema: wrap(SkillDirectories, false),
741
783
  freshFor: "7 days",
742
784
  load: (context) => Effect_exports.runPromise(
743
- // Keep the author's fetch, as every other read in this load does.
785
+ // Keep the author's fetch and this read's token, as every other request in it does.
744
786
  reader({ fetch: transport.fetch, signal: context.signal }).pipe(
745
- Effect_exports.flatMap((remote) => skillDirectories(remote, repo, commit, path))
787
+ Effect_exports.flatMap(
788
+ (remote) => skillDirectories(
789
+ githubRequests(remote, options.repo, options.token),
790
+ commit,
791
+ options.path
792
+ )
793
+ )
746
794
  ),
747
795
  { signal: context.signal }
748
796
  )
@@ -769,20 +817,42 @@ var cachedCatalog = (options, prefix, load) => options.cache === void 0 ? load(o
769
817
  })
770
818
  )
771
819
  );
820
+ var GitHubToken = Schema_exports.String.check(Schema_exports.isPattern(/^[\x21-\x7e]+$/));
821
+ var scopeMessages = {
822
+ "missing-account": "A GitHub token needs its account. Pass account: ctx.accounts.<slot> with it.",
823
+ "unselected-account": "The GitHub account is not one of this app's selected accounts."
824
+ };
825
+ var githubCache = (options) => options.account !== void 0 && !Schema_exports.is(GitHubToken)(options.token) ? Effect_exports.fail(
826
+ new SkillLoadFailed({
827
+ reason: "source",
828
+ message: "The GitHub account was passed without a valid token."
829
+ })
830
+ ) : catalogScope(
831
+ options,
832
+ options.token,
833
+ (problem) => new SkillLoadFailed({ reason: "source", message: scopeMessages[problem] })
834
+ );
835
+ var attributed = (account) => (error) => account !== void 0 && error.reason === "request" && (error.status === 401 || error.status === 403) ? accountProviderError(
836
+ new ProviderError({
837
+ reason: error.status === 401 ? "unauthorized" : "rejected",
838
+ status: error.status
839
+ }),
840
+ account.id
841
+ ) : error;
772
842
  var githubSkillsEffect = (options) => Effect_exports.gen(function* () {
773
843
  if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(options.repo) || options.path !== void 0 && !resourcePath(options.path))
774
844
  return yield* failed("source");
845
+ const cache = yield* githubCache(options);
775
846
  return yield* cachedCatalog(
776
- options,
847
+ cache === void 0 ? options : { ...options, cache },
777
848
  ["apps/githubSkills/catalog", 1, options.repo, options.ref ?? null, options.path ?? null],
778
- (transport, cache) => githubCatalog(options, transport, cache)
849
+ (transport, cache2) => githubCatalog(options, transport, cache2)
779
850
  );
780
- }).pipe(withService("GitHub"));
851
+ }).pipe(withService("GitHub"), Effect_exports.mapError(attributed(options.account)));
781
852
  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}/`;
853
+ const github = githubRequests(yield* reader(transport), options.repo, options.token);
854
+ const commit = yield* resolveCommit(github, options.ref);
855
+ const resources = yield* cache === void 0 ? skillDirectories(github, commit, options.path) : cachedSkillDirectories(cache, transport, options, commit);
786
856
  const skills = yield* Effect_exports.forEach(
787
857
  resources,
788
858
  ({ directory, files }) => Effect_exports.gen(function* () {
@@ -792,7 +862,7 @@ var githubCatalog = (options, transport, cache) => Effect_exports.gen(function*
792
862
  const path = file.path.slice(directory.length);
793
863
  if (!resourcePath(file.path) || !resourcePath(path) || file.mode === "120000")
794
864
  return yield* failed("source");
795
- return { path, content: yield* remote.read(pathUrl(base, file.path)) };
865
+ return { path, content: yield* github.file(commit, file.path) };
796
866
  }),
797
867
  { concurrency: skillLoadLimits.concurrency }
798
868
  );