@effected/github-actions 0.33.2 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Action.js CHANGED
@@ -19,9 +19,9 @@ import { FetchHttpClient } from "effect/http";
19
19
  * a GitHub Action is a Node process on a GitHub-provided runner.
20
20
  *
21
21
  * **The cache, artifact and blob services are deliberately NOT in here.** They
22
- * are the only modules that import `@azure/storage-blob`, and folding them into
23
- * the default runtime would put a blob-storage client in the bundle of every
24
- * action that merely sets an output. Their requirements are all satisfied by
22
+ * carry the Twirp results protocols and the blob transport, and folding them
23
+ * into the default runtime would put both in the bundle of every action that
24
+ * merely sets an output. Their requirements are all satisfied by
25
25
  * this layer, so taking one costs a caller exactly one line:
26
26
  * `Action.run(program, { layer: ActionCache.layer })`.
27
27
  *
package/ActionCache.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { ActionEnvironment } from "./ActionEnvironment.js";
2
- import { BlobTransferError } from "./BlobTransfer.js";
3
2
  import { misconfiguredDetail, resultsBackend } from "./internal/actionsResults.js";
4
- import { blobCause } from "./internal/blobCause.js";
3
+ import { httpFileTransfer } from "./internal/blobTransport.js";
5
4
  import { CACHE_SERVICE, finalizeUpload, lookupDownload, reserveUpload } from "./internal/cacheService.js";
6
5
  import { sha256Hex } from "./internal/digest.js";
7
6
  import { isWindowsRunner } from "./internal/runner.js";
@@ -10,7 +9,6 @@ import { twirpCall, twirpFailureFields } from "./internal/twirp.js";
10
9
  import { unstubbed } from "./internal/unstubbed.js";
11
10
  import { Context, Effect, FileSystem, Layer, Option, Path, Schema } from "effect";
12
11
  import { HttpClient } from "effect/http";
13
- import { BlobClient, BlockBlobClient } from "@azure/storage-blob";
14
12
  import { GlobPattern, GlobSet } from "@effected/glob";
15
13
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
16
14
 
@@ -82,36 +80,6 @@ const versionOf = (paths) => sha256Hex([
82
80
  "gzip",
83
81
  "1.0"
84
82
  ].join("|"));
85
- /**
86
- * The Azure half, duplicated on purpose.
87
- *
88
- * @remarks
89
- * `@azure/storage-blob` may be imported here, by `Artifact` and by
90
- * `BlobStore.githubCache`, and nowhere else — hoisting these two calls into a
91
- * shared `internal/` helper is exactly how a heavy import leaks into the graph
92
- * of a module that only sets an output. `__test__/reachability.test.ts`
93
- * measures that these are the only three.
94
- */
95
- const azure = {
96
- uploadFile: (url, file) => Effect.tryPromise({
97
- try: () => new BlockBlobClient(url).uploadFile(file, {
98
- blockSize: 67108864,
99
- concurrency: 8,
100
- maxSingleShotSize: 134217728
101
- }),
102
- catch: (cause) => new BlobTransferError({
103
- reason: "uploadFailed",
104
- cause: blobCause(cause)
105
- })
106
- }).pipe(Effect.asVoid),
107
- downloadToFile: (url, file) => Effect.tryPromise({
108
- try: () => new BlobClient(url).downloadToFile(file),
109
- catch: (cause) => new BlobTransferError({
110
- reason: "downloadFailed",
111
- cause: blobCause(cause)
112
- })
113
- }).pipe(Effect.asVoid)
114
- };
115
83
  /** The primary key and the ladder to fall back through. */
116
84
  const ladder = (key, restoreKeys) => typeof key === "string" ? {
117
85
  primary: key,
@@ -120,9 +88,10 @@ const ladder = (key, restoreKeys) => typeof key === "string" ? {
120
88
  primary: key.key,
121
89
  fallbacks: restoreKeys ?? key.restoreKeys
122
90
  };
123
- const make = (transfer) => Effect.gen(function* () {
91
+ const make = (custom) => Effect.gen(function* () {
124
92
  const http = yield* HttpClient.HttpClient;
125
93
  const fs = yield* FileSystem.FileSystem;
94
+ const transfer = custom ?? httpFileTransfer(http, fs);
126
95
  const path = yield* Path.Path;
127
96
  const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
128
97
  const env = yield* ActionEnvironment;
@@ -353,8 +322,16 @@ const dies = unstubbed("ActionCache.makeTest");
353
322
  * @public
354
323
  */
355
324
  var ActionCache = class ActionCache extends Context.Service()("@effected/github-actions/ActionCache") {
356
- /** The cache, over the real Azure client and the real `tar`. */
357
- static layer = Layer.effect(this, make(azure));
325
+ /**
326
+ * The cache, over the `HttpClient` blob transport and the real `tar`.
327
+ *
328
+ * @remarks
329
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
330
+ * the caller's client, not a bundled SDK or a platform client of this
331
+ * package's own. Also requires `FileSystem`, `Path`, `ChildProcessSpawner`
332
+ * and `ActionEnvironment`.
333
+ */
334
+ static layer = Layer.effect(this, make());
358
335
  /**
359
336
  * The cache, over a supplied transport.
360
337
  *
package/Artifact.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import { ActionEnvironment } from "./ActionEnvironment.js";
2
- import { BlobTransferError } from "./BlobTransfer.js";
3
2
  import { misconfiguredDetail, resultsBackend } from "./internal/actionsResults.js";
4
3
  import { unzipCommand, zipCommand, zipManifest } from "./internal/archiveCommands.js";
5
- import { blobCause } from "./internal/blobCause.js";
4
+ import { httpFileTransfer } from "./internal/blobTransport.js";
6
5
  import { digestFileHex } from "./internal/digest.js";
7
6
  import { isWindowsRunner } from "./internal/runner.js";
8
7
  import { spawnOnce } from "./internal/spawn.js";
@@ -10,7 +9,6 @@ import { CONFLICT, field, isOk, stringField, twirpCall, twirpFailureFields } fro
10
9
  import { unstubbed } from "./internal/unstubbed.js";
11
10
  import { Context, DateTime, Duration, Effect, FileSystem, Layer, Option, Path, Result, Schema } from "effect";
12
11
  import { HttpClient } from "effect/http";
13
- import { BlobClient, BlockBlobClient } from "@azure/storage-blob";
14
12
  import { ChildProcessSpawner } from "effect/process";
15
13
 
16
14
  // src/Artifact.ts
@@ -76,36 +74,6 @@ const SERVICE = "github.actions.results.api.v1.ArtifactService";
76
74
  * create the backend rejects.
77
75
  */
78
76
  const ARTIFACT_VERSION = 7;
79
- /**
80
- * The Azure half, duplicated on purpose.
81
- *
82
- * @remarks
83
- * `@azure/storage-blob` may be imported here, by `ActionCache` and by
84
- * `BlobStore.githubCache`, and nowhere else. Hoisting these two calls into a
85
- * shared `internal/` helper is exactly how a heavy import leaks into the graph
86
- * of a module that only sets an output; `__test__/reachability.test.ts`
87
- * measures that these are the only three.
88
- */
89
- const azure = {
90
- uploadFile: (url, file) => Effect.tryPromise({
91
- try: () => new BlockBlobClient(url).uploadFile(file, {
92
- blockSize: 67108864,
93
- concurrency: 8,
94
- maxSingleShotSize: 134217728
95
- }),
96
- catch: (cause) => new BlobTransferError({
97
- reason: "uploadFailed",
98
- cause: blobCause(cause)
99
- })
100
- }).pipe(Effect.asVoid),
101
- downloadToFile: (url, file) => Effect.tryPromise({
102
- try: () => new BlobClient(url).downloadToFile(file),
103
- catch: (cause) => new BlobTransferError({
104
- reason: "downloadFailed",
105
- cause: blobCause(cause)
106
- })
107
- }).pipe(Effect.asVoid)
108
- };
109
77
  /** One row of a `ListArtifacts` answer, read under either field spelling. */
110
78
  const toItem = (row) => {
111
79
  const createdAt = stringField(row, "createdAt");
@@ -116,9 +84,10 @@ const toItem = (row) => {
116
84
  ...createdAt === void 0 ? {} : { createdAt }
117
85
  };
118
86
  };
119
- const make = (transfer) => Effect.gen(function* () {
87
+ const make = (custom) => Effect.gen(function* () {
120
88
  const http = yield* HttpClient.HttpClient;
121
89
  const fs = yield* FileSystem.FileSystem;
90
+ const transfer = custom ?? httpFileTransfer(http, fs);
122
91
  const path = yield* Path.Path;
123
92
  const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
124
93
  const env = yield* ActionEnvironment;
@@ -373,8 +342,16 @@ const dies = unstubbed("Artifact.makeTest");
373
342
  * @public
374
343
  */
375
344
  var Artifact = class Artifact extends Context.Service()("@effected/github-actions/Artifact") {
376
- /** The service, over the real Azure client and the real `zip`. */
377
- static layer = Layer.effect(this, make(azure));
345
+ /**
346
+ * The service, over the `HttpClient` blob transport and the real `zip`.
347
+ *
348
+ * @remarks
349
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
350
+ * the caller's client, not a bundled SDK or a platform client of this
351
+ * package's own. Also requires `FileSystem`, `Path`, `ChildProcessSpawner`
352
+ * and `ActionEnvironment`.
353
+ */
354
+ static layer = Layer.effect(this, make());
378
355
  /**
379
356
  * The service, over a supplied transport.
380
357
  *
@@ -1,15 +1,13 @@
1
1
  import { ActionEnvironment } from "./ActionEnvironment.js";
2
2
  import { BlobEnvelope } from "./BlobEnvelope.js";
3
3
  import { BlobStore, BlobStoreError } from "./BlobStore.js";
4
- import { BlobTransferError } from "./BlobTransfer.js";
5
4
  import { misconfiguredDetail, resultsBackend } from "./internal/actionsResults.js";
6
- import { blobCause } from "./internal/blobCause.js";
5
+ import { httpDataTransfer } from "./internal/blobTransport.js";
7
6
  import { CACHE_SERVICE, finalizeUpload, lookupDownload, reserveUpload } from "./internal/cacheService.js";
8
7
  import { sha256Hex } from "./internal/digest.js";
9
8
  import { twirpCall, twirpFailureFields } from "./internal/twirp.js";
10
9
  import { Effect, Layer, Option } from "effect";
11
10
  import { HttpClient } from "effect/http";
12
- import { BlobClient, BlockBlobClient } from "@azure/storage-blob";
13
11
 
14
12
  // src/BlobStore.githubCache.ts
15
13
  /**
@@ -26,34 +24,9 @@ import { BlobClient, BlockBlobClient } from "@azure/storage-blob";
26
24
  * that strands every existing entry.
27
25
  */
28
26
  const VERSION = sha256Hex("blobstore|1.0");
29
- /**
30
- * The Azure half, ~15 lines and duplicated on purpose.
31
- *
32
- * @remarks
33
- * `@azure/storage-blob` may be imported by this module, `ActionCache` and
34
- * `Artifact` and by nothing else. Hoisting these two calls into a shared
35
- * `internal/` helper is exactly how the import would leak into the graph of a
36
- * module that only sets an output — so the three modules each carry their own,
37
- * and `__test__/reachability.test.ts` measures that they are the only three.
38
- */
39
- const azure = {
40
- uploadData: (url, data) => Effect.tryPromise({
41
- try: () => new BlockBlobClient(url).uploadData(data),
42
- catch: (cause) => new BlobTransferError({
43
- reason: "uploadFailed",
44
- cause: blobCause(cause)
45
- })
46
- }).pipe(Effect.asVoid),
47
- downloadToBuffer: (url) => Effect.tryPromise({
48
- try: () => new BlobClient(url).downloadToBuffer(),
49
- catch: (cause) => new BlobTransferError({
50
- reason: "downloadFailed",
51
- cause: blobCause(cause)
52
- })
53
- }).pipe(Effect.map((buffer) => new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength)))
54
- };
55
- const make = (transfer) => Effect.gen(function* () {
27
+ const make = (custom) => Effect.gen(function* () {
56
28
  const http = yield* HttpClient.HttpClient;
29
+ const transfer = custom ?? httpDataTransfer(http);
57
30
  const env = yield* ActionEnvironment;
58
31
  const backend = resultsBackend(env).pipe(Effect.mapError((name) => new BlobStoreError({
59
32
  reason: "misconfigured",
@@ -114,9 +87,8 @@ const make = (transfer) => Effect.gen(function* () {
114
87
  * The Actions cache is reachable over a Twirp v2 protocol at
115
88
  * `ACTIONS_RESULTS_URL`, which answers a `CreateCacheEntry` /
116
89
  * `GetCacheEntryDownloadURL` RPC with a **pre-signed Azure blob url** — which is
117
- * why this backend lives in its own module rather than beside the S3 one: it,
118
- * `ActionCache` and `Artifact` are the only three modules that import the
119
- * Azure client.
90
+ * why this backend lives in its own module rather than beside the S3 one. The
91
+ * bytes move over the package's own `HttpClient` blob transport.
120
92
  *
121
93
  * **Only reachable from a `uses:` step.** The runner injects
122
94
  * `ACTIONS_RESULTS_URL` and `ACTIONS_RUNTIME_TOKEN` into action execution
@@ -126,9 +98,9 @@ const make = (transfer) => Effect.gen(function* () {
126
98
  * for exactly that reason.
127
99
  *
128
100
  * The layer statics live here rather than on {@link BlobStore} because a static
129
- * belongs to the module that owns the dependency it needs: putting
130
- * `BlobStore.layerGitHubCache` on the service class would make `@azure/storage-blob`
131
- * reachable from every module that reads a blob.
101
+ * belongs to the module that owns the protocol it needs: putting
102
+ * `BlobStore.layerGitHubCache` on the service class would make the Twirp cache
103
+ * protocol reachable from every module that reads a blob.
132
104
  *
133
105
  * @example
134
106
  * ```ts
@@ -142,21 +114,23 @@ const make = (transfer) => Effect.gen(function* () {
142
114
  var GitHubCacheBlobStore = class {
143
115
  constructor() {}
144
116
  /**
145
- * The backend, over the real Azure client.
117
+ * The backend, over the `HttpClient` blob transport.
146
118
  *
147
119
  * @remarks
148
- * Requires `ActionEnvironment` for `ACTIONS_RESULTS_URL` and
120
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
121
+ * the caller's client, not a bundled SDK or a platform client of this
122
+ * package's own. Requires `ActionEnvironment` for `ACTIONS_RESULTS_URL` and
149
123
  * `ACTIONS_RUNTIME_TOKEN`; fails with `BlobStoreError` (`misconfigured`) when
150
124
  * either is absent.
151
125
  */
152
- static layer = Layer.effect(BlobStore, make(azure));
126
+ static layer = Layer.effect(BlobStore, make());
153
127
  /**
154
128
  * The backend, over a supplied transport.
155
129
  *
156
130
  * @remarks
157
131
  * The Twirp protocol — the RPC sequence, the conflict handling, the retry
158
132
  * policy, the framing — is what this package owns and what a test needs to
159
- * exercise; the Azure client is a pre-signed `PUT` that owns none of it. This
133
+ * exercise; the blob transfer is a pre-signed `PUT` that owns none of it. This
160
134
  * is also the seam an integration test uses to point the same protocol at a
161
135
  * local blob endpoint.
162
136
  *
@@ -97,7 +97,7 @@ var PackageManagerInstallerError = class extends Schema.TaggedError()("PackageMa
97
97
  var AmbientPackageManager = class extends Schema.Class("AmbientPackageManager")({
98
98
  /** The discriminant: the runner's own toolchain answered. */
99
99
  source: Schema.tag("ambient"),
100
- /** The package-manager name (`npm`, `pnpm`, `yarn` or `bun`). */
100
+ /** The package-manager name (`npm`, `pnpm` or `bun`). */
101
101
  name: PackageManagerPinName,
102
102
  /** The exact installed version, in string form. */
103
103
  version: Schema.String,
@@ -118,8 +118,8 @@ var AmbientPackageManager = class extends Schema.Class("AmbientPackageManager")(
118
118
  * bare name); for bun it is the entry directory itself, because the cached
119
119
  * `bun` binary is directly executable and a shim would add nothing but a
120
120
  * fork. `bins` still maps each published bin name to the underlying entry —
121
- * a Node script to run with `node` for npm, yarn and pnpm 11 and earlier; an
122
- * executable to run directly for bun and for pnpm 12+, whose `pnpm` is the
121
+ * a Node script to run with `node` for npm; an
122
+ * executable to run directly for bun and for pnpm, whose `pnpm` is the
123
123
  * host's native binary (overlaid onto the cached wrapper the way pnpm's own
124
124
  * install script does) and whose `pn`/`pnpx`/`pnx` are shell aliases of it.
125
125
  * Each shim already applies that distinction. Calling `addPath` remains
@@ -132,7 +132,7 @@ var AmbientPackageManager = class extends Schema.Class("AmbientPackageManager")(
132
132
  var CachedPackageManager = class extends Schema.Class("CachedPackageManager")({
133
133
  /** The discriminant: the manager lives in the tool cache. */
134
134
  source: Schema.tag("tool-cache"),
135
- /** The package-manager name (`npm`, `pnpm`, `yarn` or `bun`). */
135
+ /** The package-manager name (`npm`, `pnpm` or `bun`). */
136
136
  name: PackageManagerPinName,
137
137
  /** The exact installed version, in string form. */
138
138
  version: Schema.String,
@@ -194,14 +194,8 @@ const bunTarget = (runnerOs, arch) => {
194
194
  const cpu = BUN_CPU[arch];
195
195
  return os === void 0 || cpu === void 0 ? Option.none() : Option.some(`bun-${os}-${cpu}`);
196
196
  };
197
- /**
198
- * The registry tarball url for an npm-registry-distributed manager.
199
- *
200
- * The yarn split is corepack's own: `<2.0.0` is the `yarn` package, `>=2.0.0`
201
- * (Berry) ships as `@yarnpkg/cli-dist` — a scoped package, whose tarball
202
- * basename drops the scope (`/@yarnpkg/cli-dist/-/cli-dist-<v>.tgz`).
203
- */
204
- const registryTarballUrl = (name, version, major, registry) => name === "yarn" && major >= 2 ? `${registry}/@yarnpkg/cli-dist/-/cli-dist-${version}.tgz` : `${registry}/${name}/-/${name}-${version}.tgz`;
197
+ /** The registry tarball url for an npm-registry-distributed manager. */
198
+ const registryTarballUrl = (name, version, registry) => `${registry}/${name}/-/${name}-${version}.tgz`;
205
199
  /** Normalize a package.json `bin` value into name → relative path entries. */
206
200
  const normalizeBins = (bin, fallbackName) => {
207
201
  if (typeof bin === "string") return Option.some({ [fallbackName]: bin.replace(/^\.\//, "") });
@@ -292,13 +286,11 @@ const make = Effect.gen(function* () {
292
286
  /**
293
287
  * What a package directory's own manifest says about its entry points: the
294
288
  * `bin` map, plus the `@pnpm/exe.*` optional dependencies that mark the
295
- * pnpm 12 native-binary layout (empty for every other manager and version).
289
+ * pnpm native-binary layout (empty for every other manager). A pnpm
290
+ * artifact without one is refused as `layoutUnexpected`.
296
291
  *
297
- * Read from the artifact rather than hardcoded per manager, because the
298
- * layouts genuinely move — corepack's own table has pnpm's entry at
299
- * `bin/pnpm.cjs` through v10 and `bin/pnpm.mjs` from v11, and from v12 the
300
- * `pnpm` bin is a placeholder for a native binary shipped as a separate
301
- * package. Both maps are attacker-supplied bytes and are normalized to
292
+ * Read from the artifact rather than hardcoded per manager: the `pnpm` bin
293
+ * is a placeholder for a native binary shipped as a separate package. Both maps are attacker-supplied bytes and are normalized to
302
294
  * string → string before anything downstream reads them.
303
295
  */
304
296
  const readPackageManifest = (pin, packageDir) => Effect.gen(function* () {
@@ -327,9 +319,14 @@ const make = Effect.gen(function* () {
327
319
  }));
328
320
  yield* assertFile(pin, target, `bin ${name} (${relative}) is missing`);
329
321
  }
322
+ const nativePackages = nativePackagesOf(manifest.optionalDependencies);
323
+ if (pin.name === "pnpm" && Object.keys(nativePackages).length === 0) return yield* Effect.fail(errorFor(pin)({
324
+ reason: "layoutUnexpected",
325
+ subject: `package.json declares no ${PNPM_EXE_PREFIX}* optionalDependency`
326
+ }));
330
327
  return {
331
328
  bins,
332
- nativePackages: nativePackagesOf(manifest.optionalDependencies)
329
+ nativePackages
333
330
  };
334
331
  });
335
332
  /**
@@ -571,10 +568,9 @@ const make = Effect.gen(function* () {
571
568
  const installFromRegistry = (pin, source) => Effect.gen(function* () {
572
569
  const { name } = pin;
573
570
  const version = pin.version.toString();
574
- const url = registryTarballUrl(name, version, pin.version.major, source.registry);
571
+ const url = registryTarballUrl(name, version, source.registry);
575
572
  const archive = yield* installer.download(url).pipe(Effect.mapError(fromInstaller(pin)));
576
- const berry = name === "yarn" && pin.version.major >= 2;
577
- if (!berry) yield* verifyIntegrity(pin, archive);
573
+ yield* verifyIntegrity(pin, archive);
578
574
  const extracted = yield* installer.extractTar(archive).pipe(Effect.mapError(fromInstaller(pin)));
579
575
  const packageDir = path.join(extracted, "package");
580
576
  if ((yield* typeAt(fs, packageDir)) !== "Directory") return yield* Effect.fail(errorFor(pin)({
@@ -583,11 +579,6 @@ const make = Effect.gen(function* () {
583
579
  }));
584
580
  const manifest = yield* readPackageManifest(pin, packageDir);
585
581
  const bins = Object.keys(manifest.nativePackages).length > 0 ? yield* overlayNativeBinary(pin, packageDir, manifest, source) : manifest.bins;
586
- if (berry) {
587
- const cli = path.join(packageDir, "bin/yarn.js");
588
- yield* assertFile(pin, cli, "bin/yarn.js is missing from the cli-dist tarball");
589
- yield* verifyIntegrity(pin, cli);
590
- }
591
582
  const destination = installer.cachePath(name, version);
592
583
  yield* writeShims(pin, packageDir, destination, bins, { skipExisting: false });
593
584
  const directory = yield* installer.cacheDir(packageDir, name, version).pipe(Effect.mapError(fromInstaller(pin)));
@@ -669,8 +660,8 @@ const dies = unstubbed("PackageManagerInstaller.makeTest");
669
660
  * Takes a corepack pin (`@effected/npm`'s `PackageManagerPin`) and answers
670
661
  * with an installed manager: tool-cache `find` first, then — for npm — an
671
662
  * ambient `npm --version` probe (every Node toolchain ships npm), and only
672
- * then the manager's own dist: npm, pnpm and yarn 1.x from their registry
673
- * tarballs, yarn 2+ (Berry) from `@yarnpkg/cli-dist`, bun from its
663
+ * then the manager's own dist: npm and pnpm from their registry tarballs,
664
+ * bun from its
674
665
  * per-platform GitHub-release zip. An install with an expected integrity —
675
666
  * the pin's `+<integrity>` tail or the `integrity` option — is verified
676
667
  * fail-closed against what corepack itself hashes; one without proceeds with
package/README.md CHANGED
@@ -123,7 +123,7 @@ const program = Effect.gen(function* () {
123
123
 
124
124
  ## The runner's cache, artifacts and OIDC
125
125
 
126
- `ActionCache` and `Artifact` speak the Actions Twirp v2 protocol directly — no `@actions/cache` or `@actions/artifact` dependency, and both are excluded from `ActionRuntime.layer` on purpose, so a consumer that only sets an output never links `@azure/storage-blob`:
126
+ `ActionCache` and `Artifact` speak the Actions Twirp v2 protocol directly — no `@actions/cache` or `@actions/artifact` dependency, and both are excluded from `ActionRuntime.layer` on purpose, so a consumer that only sets an output never links the blob transport:
127
127
 
128
128
  ```ts
129
129
  import { ActionCache, CacheKey } from "@effected/github-actions";
@@ -301,7 +301,7 @@ const TestOutputs = ActionOutputs.layerTest({
301
301
  - `DryRun` — the rehearsal guard every mutation goes through, driven by the `dry-run` input by default.
302
302
  - `Secret` — the one declassification seam between a `Redacted` value and a plain string, masking before it returns plaintext.
303
303
  - `GitHubToken` — the App-token lifecycle shaped like the `pre`/`main`/`post` workflow: mint, verify scopes, persist, read, revoke.
304
- - `ActionCache` / `Artifact` — the runner's cache and artifact protocols over Twirp v2, excluded from the default runtime so a consumer that skips them never links Azure.
304
+ - `ActionCache` / `Artifact` — the runner's cache and artifact protocols over Twirp v2, excluded from the default runtime so a consumer that skips them never links the blob transport.
305
305
  - `CacheKey` — cache keys and their restore-key ladder, `withNamespace(segment)` for a bust token or a shared-runner prefix, plus `hashFiles`/`matchingFiles`/`hashMatching` byte-compatible with `@actions/glob`.
306
306
  - `OidcTokenIssuer` — the runner's OIDC token service, with unverified claim decoding for provenance predicates, and a `recording(claims)` double that journals the audiences asked for.
307
307
  - `ActionsRegistryCredential` — `workload({ audience, prefix })` mints an identity token for a registry, masks the bare and the prefixed value, and returns `@effected/npm`'s publish-only `WorkloadCredential` for `PackagePublish.setupAuth`.
package/index.d.ts CHANGED
@@ -943,9 +943,9 @@ type ActionServices = ActionEnvironment | ActionLogger | ActionOutputs | ActionS
943
943
  * a GitHub Action is a Node process on a GitHub-provided runner.
944
944
  *
945
945
  * **The cache, artifact and blob services are deliberately NOT in here.** They
946
- * are the only modules that import `@azure/storage-blob`, and folding them into
947
- * the default runtime would put a blob-storage client in the bundle of every
948
- * action that merely sets an output. Their requirements are all satisfied by
946
+ * carry the Twirp results protocols and the blob transport, and folding them
947
+ * into the default runtime would put both in the bundle of every action that
948
+ * merely sets an output. Their requirements are all satisfied by
949
949
  * this layer, so taking one costs a caller exactly one line:
950
950
  * `Action.run(program, { layer: ActionCache.layer })`.
951
951
  *
@@ -1103,8 +1103,8 @@ export declare class BlobTransferError extends BlobTransferError_base {
1103
1103
  * pre-signed Azure url, and everything interesting — the RPC sequence, the
1104
1104
  * conflict handling, the retry policy, the version hash — happens on this side
1105
1105
  * of it. Taking the transport as an argument means all of that is exercised by
1106
- * a test rather than described by one, and the Azure client stays confined to
1107
- * the three modules permitted to import it.
1106
+ * a test rather than described by one. The default transport is the package's
1107
+ * own `HttpClient` implementation of the Azure Blob REST calls.
1108
1108
  *
1109
1109
  * A url is a plain string on purpose: it is a **credential** (the signature is
1110
1110
  * in the query), and it is never logged, annotated on a span, or carried on an
@@ -1607,7 +1607,15 @@ declare const ActionCache_base: Context.ServiceClass<ActionCache, "@effected/git
1607
1607
  * @public
1608
1608
  */
1609
1609
  export declare class ActionCache extends ActionCache_base {
1610
- /** The cache, over the real Azure client and the real `tar`. */
1610
+ /**
1611
+ * The cache, over the `HttpClient` blob transport and the real `tar`.
1612
+ *
1613
+ * @remarks
1614
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
1615
+ * the caller's client, not a bundled SDK or a platform client of this
1616
+ * package's own. Also requires `FileSystem`, `Path`, `ChildProcessSpawner`
1617
+ * and `ActionEnvironment`.
1618
+ */
1611
1619
  static readonly layer: Layer.Layer<ActionCache, never, ActionEnvironment | HttpClient.HttpClient | FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>;
1612
1620
  /**
1613
1621
  * The cache, over a supplied transport.
@@ -3021,7 +3029,15 @@ declare const Artifact_base: Context.ServiceClass<Artifact, "@effected/github-ac
3021
3029
  * @public
3022
3030
  */
3023
3031
  export declare class Artifact extends Artifact_base {
3024
- /** The service, over the real Azure client and the real `zip`. */
3032
+ /**
3033
+ * The service, over the `HttpClient` blob transport and the real `zip`.
3034
+ *
3035
+ * @remarks
3036
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
3037
+ * the caller's client, not a bundled SDK or a platform client of this
3038
+ * package's own. Also requires `FileSystem`, `Path`, `ChildProcessSpawner`
3039
+ * and `ActionEnvironment`.
3040
+ */
3025
3041
  static readonly layer: Layer.Layer<Artifact, never, ActionEnvironment | HttpClient.HttpClient | FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>;
3026
3042
  /**
3027
3043
  * The service, over a supplied transport.
@@ -3353,9 +3369,8 @@ export declare class BlobStore extends BlobStore_base {
3353
3369
  * The Actions cache is reachable over a Twirp v2 protocol at
3354
3370
  * `ACTIONS_RESULTS_URL`, which answers a `CreateCacheEntry` /
3355
3371
  * `GetCacheEntryDownloadURL` RPC with a **pre-signed Azure blob url** — which is
3356
- * why this backend lives in its own module rather than beside the S3 one: it,
3357
- * `ActionCache` and `Artifact` are the only three modules that import the
3358
- * Azure client.
3372
+ * why this backend lives in its own module rather than beside the S3 one. The
3373
+ * bytes move over the package's own `HttpClient` blob transport.
3359
3374
  *
3360
3375
  * **Only reachable from a `uses:` step.** The runner injects
3361
3376
  * `ACTIONS_RESULTS_URL` and `ACTIONS_RUNTIME_TOKEN` into action execution
@@ -3365,9 +3380,9 @@ export declare class BlobStore extends BlobStore_base {
3365
3380
  * for exactly that reason.
3366
3381
  *
3367
3382
  * The layer statics live here rather than on {@link BlobStore} because a static
3368
- * belongs to the module that owns the dependency it needs: putting
3369
- * `BlobStore.layerGitHubCache` on the service class would make `@azure/storage-blob`
3370
- * reachable from every module that reads a blob.
3383
+ * belongs to the module that owns the protocol it needs: putting
3384
+ * `BlobStore.layerGitHubCache` on the service class would make the Twirp cache
3385
+ * protocol reachable from every module that reads a blob.
3371
3386
  *
3372
3387
  * @example
3373
3388
  * ```ts
@@ -3381,10 +3396,12 @@ export declare class BlobStore extends BlobStore_base {
3381
3396
  export declare class GitHubCacheBlobStore {
3382
3397
  private constructor();
3383
3398
  /**
3384
- * The backend, over the real Azure client.
3399
+ * The backend, over the `HttpClient` blob transport.
3385
3400
  *
3386
3401
  * @remarks
3387
- * Requires `ActionEnvironment` for `ACTIONS_RESULTS_URL` and
3402
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
3403
+ * the caller's client, not a bundled SDK or a platform client of this
3404
+ * package's own. Requires `ActionEnvironment` for `ACTIONS_RESULTS_URL` and
3388
3405
  * `ACTIONS_RUNTIME_TOKEN`; fails with `BlobStoreError` (`misconfigured`) when
3389
3406
  * either is absent.
3390
3407
  */
@@ -3395,7 +3412,7 @@ export declare class GitHubCacheBlobStore {
3395
3412
  * @remarks
3396
3413
  * The Twirp protocol — the RPC sequence, the conflict handling, the retry
3397
3414
  * policy, the framing — is what this package owns and what a test needs to
3398
- * exercise; the Azure client is a pre-signed `PUT` that owns none of it. This
3415
+ * exercise; the blob transfer is a pre-signed `PUT` that owns none of it. This
3399
3416
  * is also the seam an integration test uses to point the same protocol at a
3400
3417
  * local blob endpoint.
3401
3418
  *
@@ -5287,7 +5304,7 @@ declare const PackageManagerInstallerError_base: Schema.Class<PackageManagerInst
5287
5304
  */
5288
5305
  readonly reason: Schema.Literals<readonly ["downloadFailed", "extractFailed", "integrityMismatch", "integrityMissing", "unsupportedPlatform", "layoutUnexpected", "cacheFailed"]>;
5289
5306
  /** The package manager being installed. */
5290
- readonly name: Schema.Literals<readonly ["npm", "pnpm", "yarn", "bun"]>;
5307
+ readonly name: Schema.Literals<readonly ["npm", "pnpm", "bun"]>;
5291
5308
  /** The exact version being installed, in string form. */
5292
5309
  readonly version: Schema.String;
5293
5310
  /** What was being worked on — a url, a path, or an OS/arch pair. */
@@ -5331,15 +5348,14 @@ interface PackageManagerInstallOptions {
5331
5348
  * Corepack form only (`<algo>.<hex>`), the same brand the pin's own
5332
5349
  * `integrity` carries; convert a registry or lockfile SRI string with
5333
5350
  * `CorepackIntegrityHash.fromSri` from `@effected/npm`. It verifies
5334
- * exactly what a pin integrity verifies — the registry tarball for npm,
5335
- * pnpm and yarn 1.x, the standalone `yarn.js` for yarn 2+, the platform zip
5336
- * for bun — and stands in for the pin's in every rule: it silences the
5351
+ * exactly what a pin integrity verifies — the registry tarball for npm
5352
+ * and pnpm, the platform zip for bun — and stands in for the pin's in every rule: it silences the
5337
5353
  * "carries no integrity hash" warning, satisfies `requireIntegrity`, and a
5338
5354
  * tool-cache hit is answered without re-verifying, exactly as it is for an
5339
5355
  * integrity-carrying pin.
5340
5356
  *
5341
5357
  * Fail-closed, before any cache lookup or download: a value not in corepack
5342
- * form (an SRI or yarn hash) fails with `integrityMismatch` on its
5358
+ * form (an SRI hash) fails with `integrityMismatch` on its
5343
5359
  * could-not-verify arm (no `expected`, no `actual`, `subject` naming the
5344
5360
  * option); and when the pin also carries an integrity and the two differ,
5345
5361
  * the install fails with `integrityMismatch` (`expected` is this option,
@@ -5349,10 +5365,10 @@ interface PackageManagerInstallOptions {
5349
5365
  */
5350
5366
  readonly integrity?: IntegrityHashBrand | undefined;
5351
5367
  /**
5352
- * The npm registry host the npm, pnpm and yarn tarballs download from.
5368
+ * The npm registry host the npm and pnpm tarballs download from.
5353
5369
  * Defaults to `https://registry.npmjs.org`. A corporate mirror qualifies
5354
5370
  * when it serves the standard `/<name>/-/<basename>-<version>.tgz` tarball
5355
- * route and — for pnpm 12 and later, whose native binary is a second
5371
+ * route and — for pnpm, whose native binary is a second
5356
5372
  * artifact verified against the registry's own integrity — the
5357
5373
  * `/<name>/<version>` packument route as JSON carrying `dist.integrity`.
5358
5374
  * A tarball-only proxy fails a pnpm 12 pin with `downloadFailed` naming
@@ -5368,8 +5384,7 @@ interface PackageManagerInstallOptions {
5368
5384
  * entry.
5369
5385
  *
5370
5386
  * @remarks
5371
- * Consulted only for a pin whose wrapper overlays a native binary (pnpm 12
5372
- * and later); every other pin ignores it. When supplied, the installer
5387
+ * Consulted only for a pin whose wrapper overlays a native binary (pnpm); every other pin ignores it. When supplied, the installer
5373
5388
  * verifies the host's `@pnpm/exe.<target>` tarball against this map's entry
5374
5389
  * (its strongest listed algorithm) INSTEAD of the registry's packument, so
5375
5390
  * the packument route is never requested and a tarball-only mirror
@@ -5402,8 +5417,8 @@ interface PackageManagerInstallOptions {
5402
5417
  declare const AmbientPackageManager_base: Schema.Class<AmbientPackageManager, Schema.Struct<{
5403
5418
  /** The discriminant: the runner's own toolchain answered. */
5404
5419
  readonly source: Schema.tag<"ambient">;
5405
- /** The package-manager name (`npm`, `pnpm`, `yarn` or `bun`). */
5406
- readonly name: Schema.Literals<readonly ["npm", "pnpm", "yarn", "bun"]>;
5420
+ /** The package-manager name (`npm`, `pnpm` or `bun`). */
5421
+ readonly name: Schema.Literals<readonly ["npm", "pnpm", "bun"]>;
5407
5422
  /** The exact installed version, in string form. */
5408
5423
  readonly version: Schema.String;
5409
5424
  /** Bin name → the ambient command name that invokes it. */
@@ -5423,8 +5438,8 @@ export declare class AmbientPackageManager extends AmbientPackageManager_base {}
5423
5438
  declare const CachedPackageManager_base: Schema.Class<CachedPackageManager, Schema.Struct<{
5424
5439
  /** The discriminant: the manager lives in the tool cache. */
5425
5440
  readonly source: Schema.tag<"tool-cache">;
5426
- /** The package-manager name (`npm`, `pnpm`, `yarn` or `bun`). */
5427
- readonly name: Schema.Literals<readonly ["npm", "pnpm", "yarn", "bun"]>;
5441
+ /** The package-manager name (`npm`, `pnpm` or `bun`). */
5442
+ readonly name: Schema.Literals<readonly ["npm", "pnpm", "bun"]>;
5428
5443
  /** The exact installed version, in string form. */
5429
5444
  readonly version: Schema.String;
5430
5445
  /** The cached entry: `<tool-cache>/<name>/<version>/<arch>`. */
@@ -5448,8 +5463,8 @@ declare const CachedPackageManager_base: Schema.Class<CachedPackageManager, Sche
5448
5463
  * bare name); for bun it is the entry directory itself, because the cached
5449
5464
  * `bun` binary is directly executable and a shim would add nothing but a
5450
5465
  * fork. `bins` still maps each published bin name to the underlying entry —
5451
- * a Node script to run with `node` for npm, yarn and pnpm 11 and earlier; an
5452
- * executable to run directly for bun and for pnpm 12+, whose `pnpm` is the
5466
+ * a Node script to run with `node` for npm; an
5467
+ * executable to run directly for bun and for pnpm, whose `pnpm` is the
5453
5468
  * host's native binary (overlaid onto the cached wrapper the way pnpm's own
5454
5469
  * install script does) and whose `pn`/`pnpx`/`pnx` are shell aliases of it.
5455
5470
  * Each shim already applies that distinction. Calling `addPath` remains
@@ -5507,8 +5522,8 @@ declare const PackageManagerInstaller_base: Context.ServiceClass<PackageManagerI
5507
5522
  * Takes a corepack pin (`@effected/npm`'s `PackageManagerPin`) and answers
5508
5523
  * with an installed manager: tool-cache `find` first, then — for npm — an
5509
5524
  * ambient `npm --version` probe (every Node toolchain ships npm), and only
5510
- * then the manager's own dist: npm, pnpm and yarn 1.x from their registry
5511
- * tarballs, yarn 2+ (Berry) from `@yarnpkg/cli-dist`, bun from its
5525
+ * then the manager's own dist: npm and pnpm from their registry tarballs,
5526
+ * bun from its
5512
5527
  * per-platform GitHub-release zip. An install with an expected integrity —
5513
5528
  * the pin's `+<integrity>` tail or the `integrity` option — is verified
5514
5529
  * fail-closed against what corepack itself hashes; one without proceeds with
@@ -1,9 +1,7 @@
1
- import { Predicate } from "effect";
2
1
  import { UrlParams } from "effect/http";
3
2
  import { HttpRedaction } from "@effected/crypto";
4
3
 
5
4
  // src/internal/blobCause.ts
6
- const REDACTED = "REDACTED";
7
5
  const SAS_NAMES = [
8
6
  "sig",
9
7
  "se",
@@ -20,81 +18,5 @@ const SAS_NAMES = [
20
18
  ];
21
19
  /** A signed blob url with its SAS credential fields and userinfo redacted. */
22
20
  const blobUrl = (raw) => UrlParams.redactUrl(HttpRedaction.url(raw), SAS_NAMES);
23
- const text = (raw) => HttpRedaction.text(raw).replace(/https?:\/\/[^\s"'<>`]+/gi, (match) => UrlParams.redactUrl(match, SAS_NAMES));
24
- /** A header record (`details`, or a response's headers) minus cookies, sensitive values redacted. */
25
- const headerRecord = (input) => {
26
- const entries = headerEntries(input);
27
- if (entries === void 0) return void 0;
28
- const out = {};
29
- for (const [name, value] of entries) {
30
- const lower = name.toLowerCase();
31
- if (lower === "set-cookie" || lower === "cookie") continue;
32
- if (typeof value === "string") out[name] = HttpRedaction.isSensitiveHeader(lower) ? REDACTED : text(value);
33
- else if (Predicate.isNumber(value) || Predicate.isBoolean(value)) out[name] = value;
34
- }
35
- return out;
36
- };
37
- const headerEntries = (input) => {
38
- if (input === null || typeof input !== "object") return void 0;
39
- if (Predicate.hasProperty(input, "toJSON") && typeof input.toJSON === "function") {
40
- const json = input.toJSON();
41
- return json !== null && typeof json === "object" ? Object.entries(json) : void 0;
42
- }
43
- return Object.entries(input);
44
- };
45
- const isRestShaped = (value) => Predicate.hasProperty(value, "request") || Predicate.hasProperty(value, "response");
46
- const MAX_DEPTH = 8;
47
- const define = (target, key, value, enumerable) => {
48
- Object.defineProperty(target, key, {
49
- value,
50
- enumerable,
51
- writable: true,
52
- configurable: true
53
- });
54
- };
55
- const copy = (value, depth) => {
56
- if (typeof value === "string") return text(value);
57
- if (value === null || typeof value !== "object") return value;
58
- if (depth >= MAX_DEPTH) return void 0;
59
- const source = value;
60
- const out = value instanceof Error ? Object.create(Object.getPrototypeOf(value)) : new Error(text(typeof source.message === "string" ? source.message : Object.prototype.toString.call(value)));
61
- if (value instanceof Error) {
62
- define(out, "message", text(value.message), false);
63
- if (value.stack !== void 0) define(out, "stack", text(value.stack), false);
64
- }
65
- for (const [key, field] of Object.entries(source)) if (key === "details") {
66
- const details = headerRecord(field);
67
- if (details !== void 0) define(out, key, details, true);
68
- } else if (typeof field === "string") define(out, key, text(field), true);
69
- else if (Predicate.isNumber(field) || Predicate.isBoolean(field)) define(out, key, field, true);
70
- const request = Predicate.hasProperty(value, "request") ? asRecord(value.request) : void 0;
71
- if (request !== void 0) define(out, "request", {
72
- ...typeof request.method === "string" ? { method: request.method } : {},
73
- ...typeof request.url === "string" ? { url: blobUrl(request.url) } : {},
74
- ...headerRecord(request.headers) !== void 0 ? { headers: headerRecord(request.headers) } : {}
75
- }, false);
76
- const response = Predicate.hasProperty(value, "response") ? asRecord(value.response) : void 0;
77
- if (response !== void 0) define(out, "response", {
78
- ...Predicate.isNumber(response.status) ? { status: response.status } : {},
79
- ...headerRecord(response.headers) !== void 0 ? { headers: headerRecord(response.headers) } : {}
80
- }, false);
81
- if (Predicate.hasProperty(value, "cause") && value.cause !== void 0) {
82
- const nested = copy(value.cause, depth + 1);
83
- if (nested !== void 0) define(out, "cause", nested, true);
84
- }
85
- return out;
86
- };
87
- const asRecord = (value) => value !== null && typeof value === "object" ? value : void 0;
88
- /**
89
- * Sanitize what a blob transfer threw before keeping it as a cause: a
90
- * `RestError`-shaped value (one carrying a `request` or `response`) becomes a
91
- * copy on the same prototype that keeps `name`, `message`, `code`,
92
- * `statusCode`, the method, the url with its SAS credential fields redacted,
93
- * and the headers minus `set-cookie`, with sensitive values redacted; the
94
- * request and response bodies, the pipeline options and the raw url are gone.
95
- * Anything else — a filesystem error writing the download, a kit error — is
96
- * returned unchanged, by identity.
97
- */
98
- const blobCause = (cause) => cause !== null && typeof cause === "object" && isRestShaped(cause) ? copy(cause, 0) : cause;
99
21
 
100
- export { blobCause, blobUrl };
22
+ export { blobUrl };
@@ -0,0 +1,172 @@
1
+ import { BlobTransferError } from "../BlobTransfer.js";
2
+ import { blobUrl } from "./blobCause.js";
3
+ import { Effect, PlatformError, Schedule, Stream } from "effect";
4
+ import { HttpBody, HttpClientRequest } from "effect/http";
5
+
6
+ // src/internal/blobTransport.ts
7
+ /**
8
+ * The storage service version sent as `x-ms-version`.
9
+ *
10
+ * @remarks
11
+ * The version `@azure/storage-blob` 12.34 sent, which is the one the transport
12
+ * replaced. A SAS url's own `sv` governs what the signature authorizes; this
13
+ * header selects the REST behaviour of the call.
14
+ *
15
+ * @internal
16
+ */
17
+ const SERVICE_VERSION = "2026-10-06";
18
+ const MIB = 1048576;
19
+ /** The sizing `ActionCache` and `Artifact` upload files with. @internal */
20
+ const FILE_OPTIONS = {
21
+ maxSingleShotSize: 128 * MIB,
22
+ blockSize: 64 * MIB,
23
+ concurrency: 8,
24
+ retrySchedule: Schedule.exponential("1 second", 2),
25
+ retries: 4
26
+ };
27
+ /** The sizing `BlobStore.githubCache` uploads buffers with. @internal */
28
+ const DATA_OPTIONS = {
29
+ ...FILE_OPTIONS,
30
+ maxSingleShotSize: 256 * MIB
31
+ };
32
+ /**
33
+ * Why a blob request did not succeed.
34
+ *
35
+ * @remarks
36
+ * A plain `Error` subclass rather than a Schema class: it is only ever kept as
37
+ * `BlobTransferError.cause`, and it holds nothing that was not redacted on the
38
+ * way in.
39
+ *
40
+ * @internal
41
+ */
42
+ var BlobRequestError = class extends Error {
43
+ name = "BlobRequestError";
44
+ method;
45
+ /** The request url with its SAS credential fields redacted. */
46
+ url;
47
+ /** The HTTP status, absent for a transport fault. */
48
+ statusCode;
49
+ /** The storage service's `<Code>`, read from an XML error body. */
50
+ code;
51
+ /** The `x-ms-request-id` the service answered with. */
52
+ requestId;
53
+ constructor(fields) {
54
+ super(fields.message);
55
+ this.method = fields.method;
56
+ this.url = blobUrl(fields.url);
57
+ if (fields.statusCode !== void 0) this.statusCode = fields.statusCode;
58
+ if (fields.code !== void 0) this.code = fields.code;
59
+ if (fields.requestId !== void 0) this.requestId = fields.requestId;
60
+ }
61
+ };
62
+ const isTransient = (error) => error.statusCode === void 0 || error.statusCode >= 500 || error.statusCode === 408 || error.statusCode === 429;
63
+ /** The service's `<Code>` out of an XML error body. */
64
+ const errorCode = (body) => /<Code>([^<]+)<\/Code>/.exec(body)?.[1];
65
+ const base = (method, url) => (method === "PUT" ? HttpClientRequest.put(url) : HttpClientRequest.get(url)).pipe(HttpClientRequest.setHeader("x-ms-version", SERVICE_VERSION));
66
+ /** Send one request; a non-2xx answer or a transport fault is a {@link BlobRequestError}. */
67
+ const send = (http, method, url, request) => http.execute(request).pipe(Effect.mapError((cause) => new BlobRequestError({
68
+ method,
69
+ url,
70
+ message: `${method} did not complete (${cause.reason._tag})`
71
+ })), Effect.flatMap((response) => {
72
+ if (response.status >= 200 && response.status < 300) return Effect.succeed(response);
73
+ return response.text.pipe(Effect.orElseSucceed(() => ""), Effect.flatMap((body) => Effect.fail(new BlobRequestError({
74
+ method,
75
+ url,
76
+ message: `${method} answered ${response.status}`,
77
+ statusCode: response.status,
78
+ code: errorCode(body),
79
+ requestId: response.headers["x-ms-request-id"]
80
+ }))));
81
+ }));
82
+ const withRetry = (options, attempt) => Effect.retry(attempt, {
83
+ schedule: options.retrySchedule,
84
+ times: options.retries,
85
+ while: (error) => error instanceof BlobRequestError && isTransient(error)
86
+ });
87
+ const putBody = (http, options, url, params, body, blobType) => {
88
+ const request = Object.entries(params).reduce((req, [name, value]) => HttpClientRequest.setUrlParam(req, name, value), base("PUT", url).pipe(HttpClientRequest.setBody(body)));
89
+ const typed = blobType ? HttpClientRequest.setHeader(request, "x-ms-blob-type", "BlockBlob") : request;
90
+ return withRetry(options, Effect.asVoid(Effect.scoped(send(http, "PUT", url, typed))));
91
+ };
92
+ /** The fixed-width base64 id of block `index`; every id in a blob must be one length. */
93
+ const blockId = (index) => btoa(String(index).padStart(8, "0"));
94
+ const blocklistXml = (count) => `<?xml version="1.0" encoding="utf-8"?><BlockList>${Array.from({ length: count }, (_, index) => `<Latest>${blockId(index)}</Latest>`).join("")}</BlockList>`;
95
+ /**
96
+ * Upload `size` bytes, whole or as blocks, reading each span with `read`.
97
+ *
98
+ * @remarks
99
+ * `read` runs once per block, outside the retry: a retried `PUT` sends the
100
+ * same bytes again, which a `Uint8Array` body can do and a consumed stream
101
+ * could not.
102
+ */
103
+ const upload = (http, options, url, size, read) => {
104
+ if (size <= options.maxSingleShotSize) return Effect.flatMap(read(0, size), (bytes) => putBody(http, options, url, {}, HttpBody.uint8Array(bytes, "application/octet-stream"), true));
105
+ const count = Math.ceil(size / options.blockSize);
106
+ return Effect.forEach(Array.from({ length: count }, (_, index) => index), (index) => Effect.flatMap(read(index * options.blockSize, Math.min(options.blockSize, size - index * options.blockSize)), (bytes) => putBody(http, options, url, {
107
+ comp: "block",
108
+ blockid: blockId(index)
109
+ }, HttpBody.uint8Array(bytes, "application/octet-stream"), false)), {
110
+ concurrency: options.concurrency,
111
+ discard: true
112
+ }).pipe(Effect.andThen(putBody(http, options, url, { comp: "blocklist" }, HttpBody.text(blocklistXml(count), "application/xml"), false)));
113
+ };
114
+ /**
115
+ * Read `length` bytes of `file` from `offset` into one buffer, written as each chunk arrives: the chunks are never
116
+ * held beside the joined copy, so a block costs its own size once. A file that ends early fails, rather than send
117
+ * zero bytes the signature would accept.
118
+ */
119
+ const readSpan = (fs, file, offset, length) => Effect.suspend(() => {
120
+ const out = new Uint8Array(length);
121
+ let at = 0;
122
+ return fs.stream(file, {
123
+ offset,
124
+ bytesToRead: length
125
+ }).pipe(Stream.runForEach((chunk) => Effect.sync(() => {
126
+ const take = Math.min(chunk.byteLength, length - at);
127
+ out.set(take === chunk.byteLength ? chunk : chunk.subarray(0, take), at);
128
+ at += take;
129
+ })), Effect.flatMap(() => at === length ? Effect.succeed(out) : Effect.fail(PlatformError.systemError({
130
+ _tag: "UnexpectedEof",
131
+ module: "FileSystem",
132
+ method: "stream",
133
+ description: `expected ${length} bytes at offset ${offset}, read ${at}`,
134
+ pathOrDescriptor: file
135
+ }))));
136
+ });
137
+ const uploadFailed = (cause) => new BlobTransferError({
138
+ reason: "uploadFailed",
139
+ cause
140
+ });
141
+ const downloadFailed = (cause) => new BlobTransferError({
142
+ reason: "downloadFailed",
143
+ cause
144
+ });
145
+ /**
146
+ * The {@link DataBlobTransfer} over `HttpClient`.
147
+ *
148
+ * @internal
149
+ */
150
+ const httpDataTransfer = (http, options = DATA_OPTIONS) => ({
151
+ uploadData: (url, data) => upload(http, options, url, data.byteLength, (offset, length) => Effect.succeed(data.subarray(offset, offset + length))).pipe(Effect.mapError(uploadFailed)),
152
+ downloadToBuffer: (url) => withRetry(options, Effect.scoped(Effect.flatMap(send(http, "GET", url, base("GET", url)), (response) => response.arrayBuffer.pipe(Effect.map((buffer) => new Uint8Array(buffer)), Effect.mapError((cause) => new BlobRequestError({
153
+ method: "GET",
154
+ url,
155
+ message: `GET body did not complete (${cause.reason._tag})`
156
+ })))))).pipe(Effect.mapError(downloadFailed))
157
+ });
158
+ /**
159
+ * The {@link FileBlobTransfer} over `HttpClient` and `FileSystem`.
160
+ *
161
+ * @internal
162
+ */
163
+ const httpFileTransfer = (http, fs, options = FILE_OPTIONS) => ({
164
+ uploadFile: (url, file) => Effect.flatMap(fs.stat(file), (info) => upload(http, options, url, Number(info.size), (offset, length) => readSpan(fs, file, offset, length))).pipe(Effect.mapError(uploadFailed)),
165
+ downloadToFile: (url, file) => withRetry(options, Effect.scoped(Effect.flatMap(send(http, "GET", url, base("GET", url)), (response) => response.stream.pipe(Stream.mapError((cause) => new BlobRequestError({
166
+ method: "GET",
167
+ url,
168
+ message: `GET body did not complete (${cause.reason._tag})`
169
+ })), Stream.run(fs.sink(file)))))).pipe(Effect.mapError(downloadFailed))
170
+ });
171
+
172
+ export { BlobRequestError, DATA_OPTIONS, FILE_OPTIONS, SERVICE_VERSION, httpDataTransfer, httpFileTransfer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/github-actions",
3
- "version": "0.33.2",
3
+ "version": "0.35.0",
4
4
  "private": false,
5
5
  "description": "The GitHub Actions runtime: env, inputs, outputs, state, logging, cache, artifacts, blob storage, OIDC and the token bridge.",
6
6
  "keywords": [
@@ -38,19 +38,18 @@
38
38
  "./package.json": "./package.json"
39
39
  },
40
40
  "dependencies": {
41
- "@azure/storage-blob": "^12.33.0",
42
41
  "@effected/crypto": "^0.7.0",
43
- "@effected/github": "^0.32.1",
42
+ "@effected/github": "^0.33.0",
44
43
  "@effected/github-commands": "^0.10.0",
45
- "@effected/glob": "^0.22.0",
44
+ "@effected/glob": "^0.23.0",
46
45
  "@effected/jwt": "^0.10.0",
47
46
  "@effected/markdown": "^0.29.0",
48
- "@effected/npm": "^0.34.1",
47
+ "@effected/npm": "^0.35.1",
49
48
  "@effected/oidc": "^0.5.0",
50
49
  "@effected/sbom": "^0.21.0",
51
50
  "@effected/semver": "^0.24.0",
52
51
  "@effected/templates": "^0.20.0",
53
- "@effected/walker": "^0.29.0",
52
+ "@effected/walker": "^0.30.0",
54
53
  "@effected/yaml": "^0.30.0"
55
54
  },
56
55
  "peerDependencies": {