@asermax/pi-tentacles 0.1.0 → 1.1.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.
@@ -3037,6 +3037,38 @@ var fail$4 = fail$5;
3037
3037
  */
3038
3038
  var isResult = isResult$1;
3039
3039
  /**
3040
+ * Checks whether a `Result` is a `Failure`.
3041
+ *
3042
+ * **When to use**
3043
+ *
3044
+ * Use to narrow a known `Result` to the `Failure` variant.
3045
+ *
3046
+ * **Details**
3047
+ *
3048
+ * - Acts as a TypeScript type guard, narrowing to `Failure<A, E>`
3049
+ * - After narrowing, you can access `.failure` to read the error value
3050
+ *
3051
+ * **Example** (Narrowing to failure)
3052
+ *
3053
+ * ```ts import.meta.vitest
3054
+ * import { Result } from "effect"
3055
+ *
3056
+ * const result = Result.fail("oops")
3057
+ *
3058
+ * if (Result.isFailure(result)) {
3059
+ * result.failure // => "oops"
3060
+ * }
3061
+ * ```
3062
+ *
3063
+ * @see {@link isSuccess} for the opposite check
3064
+ * @see {@link isResult} to check if a value is any Result
3065
+ *
3066
+ * @stability stable
3067
+ * @category guards
3068
+ * @since 4.0.0
3069
+ */
3070
+ var isFailure = isFailure$1;
3071
+ /**
3040
3072
  * Checks whether a `Result` is a `Success`.
3041
3073
  *
3042
3074
  * **When to use**
@@ -3069,6 +3101,43 @@ var isResult = isResult$1;
3069
3101
  */
3070
3102
  var isSuccess$1 = isSuccess$2;
3071
3103
  /**
3104
+ * Folds a `Result` into a single value by applying one of two functions.
3105
+ *
3106
+ * **When to use**
3107
+ *
3108
+ * Use when a `Result`'s success and failure branches should be collapsed into
3109
+ * one plain output type.
3110
+ *
3111
+ * **Details**
3112
+ *
3113
+ * - Applies `onSuccess` if the result is a `Success`
3114
+ * - Applies `onFailure` if the result is a `Failure`
3115
+ * - Both branches must return the same type (or a common supertype)
3116
+ *
3117
+ * **Example** (Folding to a string)
3118
+ *
3119
+ * ```ts import.meta.vitest
3120
+ * import { pipe, Result } from "effect"
3121
+ *
3122
+ * const format = Result.match({
3123
+ * onSuccess: (n: number) => `Got ${n}`,
3124
+ * onFailure: (e: string) => `Err: ${e}`
3125
+ * })
3126
+ *
3127
+ * format(Result.succeed(42)) // => "Got 42"
3128
+ *
3129
+ * format(Result.fail("timeout")) // => "Err: timeout"
3130
+ * ```
3131
+ *
3132
+ * @see {@link merge} to extract `A | E` without mapping
3133
+ * @see {@link getOrElse} to unwrap only the success with a fallback
3134
+ *
3135
+ * @stability stable
3136
+ * @category pattern matching
3137
+ * @since 2.0.0
3138
+ */
3139
+ var match$1 = /*#__PURE__*/ dual(2, (self, { onFailure, onSuccess }) => isFailure(self) ? onFailure(self.failure) : onSuccess(self.success));
3140
+ /**
3072
3141
  * Maps a record into another record by applying a transformation function to each of its values.
3073
3142
  *
3074
3143
  * **Example** (Mapping record values)
@@ -5013,6 +5082,66 @@ function taggedMatch() {
5013
5082
  * @since 2.0.0
5014
5083
  */
5015
5084
  var TaggedError$1 = TaggedError$2;
5085
+ // ../../node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/encoding/EncodingError.js
5086
+ /**
5087
+ * Shared error type for encoding and decoding operations.
5088
+ *
5089
+ * @stability stable
5090
+ * @since 4.0.0
5091
+ */
5092
+ /**
5093
+ * Type identifier stored on `EncodingError` values and used by
5094
+ * `isEncodingError`.
5095
+ *
5096
+ * **When to use**
5097
+ *
5098
+ * Use when implementing low-level `EncodingError`-compatible values that need
5099
+ * to carry the runtime marker.
5100
+ *
5101
+ * **Details**
5102
+ *
5103
+ * This marker is part of the runtime representation of `EncodingError`. Prefer
5104
+ * `isEncodingError` when narrowing unknown values.
5105
+ *
5106
+ * @see {@link isEncodingError} for the public guard that checks this marker
5107
+ *
5108
+ * @stability stable
5109
+ * @category type IDs
5110
+ * @since 4.0.0
5111
+ */
5112
+ var EncodingErrorTypeId = "~effect/encoding/EncodingError";
5113
+ /**
5114
+ * Error returned when an encoding or decoding operation cannot process its input.
5115
+ *
5116
+ * **When to use**
5117
+ *
5118
+ * Use when you need to handle or inspect failures from encoding or decoding
5119
+ * operations.
5120
+ *
5121
+ * **Details**
5122
+ *
5123
+ * The error records whether the failure happened during encoding or decoding,
5124
+ * which encoding module reported it, the original input, and a human-readable
5125
+ * message.
5126
+ *
5127
+ * @see {@link isEncodingError} for checking whether a value is an EncodingError
5128
+ *
5129
+ * @stability stable
5130
+ * @category errors
5131
+ * @since 4.0.0
5132
+ */
5133
+ var EncodingError = class extends (/*#__PURE__*/ TaggedError$1("EncodingError")) {
5134
+ /**
5135
+ * Marks this value as an encoding or decoding error for runtime guards.
5136
+ *
5137
+ * **When to use**
5138
+ *
5139
+ * Use to identify `EncodingError` instances through `isEncodingError`.
5140
+ *
5141
+ * @since 4.0.0
5142
+ */
5143
+ [EncodingErrorTypeId] = EncodingErrorTypeId;
5144
+ };
5016
5145
  var hexCodes = /*#__PURE__*/ (/* @__PURE__ */ new Uint8Array(256)).fill(255);
5017
5146
  for (let i = 0; i < 16; i++) {
5018
5147
  hexCodes[/*#__PURE__*/ "0123456789abcdef".charCodeAt(i)] = i;
@@ -5443,6 +5572,11 @@ var suspend$1 = /*#__PURE__*/ makePrimitive({
5443
5572
  }
5444
5573
  });
5445
5574
  /** @internal */
5575
+ var fromResult$1 = /*#__PURE__*/ match$1({
5576
+ onFailure: fail$3,
5577
+ onSuccess: succeed$3
5578
+ });
5579
+ /** @internal */
5446
5580
  var failCauseSync$1 = (evaluate) => suspend$1(() => failCause$1(evaluate()));
5447
5581
  /** @internal */
5448
5582
  var die$2 = (defect) => exitDie(defect);
@@ -5656,12 +5790,19 @@ var map$3 = /*#__PURE__*/ dual(2, (self, f) => new ContImpl(self, mapCont, f));
5656
5790
  /** @internal */
5657
5791
  var mapEager$1 = /*#__PURE__*/ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map$3(self, f));
5658
5792
  /** @internal */
5793
+ var mapErrorEager$1 = /*#__PURE__*/ dual(2, (self, f) => effectIsExit(self) ? exitMapError(self, f) : mapError(self, f));
5794
+ /** @internal */
5659
5795
  var exitIsSuccess = (self) => self._tag === "Success";
5660
5796
  /** @internal */
5661
5797
  var exitVoid = /*#__PURE__*/ exitSucceed(void 0);
5662
5798
  /** @internal */
5663
5799
  var exitMap = /*#__PURE__*/ dual(2, (self, f) => self._tag === "Success" ? exitSucceed(f(self.value)) : self);
5664
5800
  /** @internal */
5801
+ var exitMapError = /*#__PURE__*/ dual(2, (self, f) => {
5802
+ if (self._tag === "Success") return self;
5803
+ return exitFailCause(causeMap(self.cause, f));
5804
+ });
5805
+ /** @internal */
5665
5806
  var exitAsVoidAll = (exits) => {
5666
5807
  const failures = [];
5667
5808
  for (const exit of exits) if (exit._tag === "Failure") failures.push(...exit.cause.reasons);
@@ -5703,6 +5844,8 @@ var OnFailureImpl = function(self, f) {
5703
5844
  this[contE] = f;
5704
5845
  };
5705
5846
  OnFailureImpl.prototype = OnFailureProto;
5847
+ /** @internal */
5848
+ var mapError = /*#__PURE__*/ dual(2, (self, f) => catchCause$1(self, (cause) => failCause$1(causeMap(cause, f))));
5706
5849
  var OnSuccessAndFailureProto = /*#__PURE__*/ makePrimitiveProto({
5707
5850
  op: "OnSuccessAndFailure",
5708
5851
  [evaluate]: evaluateCont
@@ -7666,6 +7809,31 @@ var try_ = try_$1;
7666
7809
  */
7667
7810
  var withFiber = withFiber$1;
7668
7811
  /**
7812
+ * Converts a `Result` to an `Effect`.
7813
+ *
7814
+ * **Example** (Converting a Result into an Effect)
7815
+ *
7816
+ * ```ts import.meta.vitest
7817
+ * import { Effect, Result } from "effect"
7818
+ * const output: Array<unknown> = []
7819
+ *
7820
+ * const success = Result.succeed(42)
7821
+ * const failure = Result.fail("Something went wrong")
7822
+ *
7823
+ * const effect1 = Effect.fromResult(success)
7824
+ * const effect2 = Effect.fromResult(failure)
7825
+ *
7826
+ * void output.push(Effect.runSync(effect1))
7827
+ * void output.push(Effect.runSync(Effect.flip(effect2)))
7828
+ * output // => [42, "Something went wrong"]
7829
+ * ```
7830
+ *
7831
+ * @stability stable
7832
+ * @category converting
7833
+ * @since 4.0.0
7834
+ */
7835
+ var fromResult = fromResult$1;
7836
+ /**
7669
7837
  * Chains effects to produce new `Effect` instances, useful for combining
7670
7838
  * operations that depend on previous results.
7671
7839
  *
@@ -8029,6 +8197,53 @@ var runSyncExit = runSyncExit$1;
8029
8197
  */
8030
8198
  var mapEager = mapEager$1;
8031
8199
  /**
8200
+ * Applies `mapError` eagerly when an effect is already resolved.
8201
+ *
8202
+ * **When to use**
8203
+ *
8204
+ * Use when an already-resolved failed effect should apply an error
8205
+ * transformation immediately while pending effects still use regular error
8206
+ * mapping.
8207
+ *
8208
+ * **Details**
8209
+ *
8210
+ * Success effects pass through unchanged because there is no error to
8211
+ * transform. Failure effects apply the mapping function immediately, and
8212
+ * pending effects fall back to regular `mapError` behavior.
8213
+ *
8214
+ * Maps every typed error in the cause, preserving defects, interrupts and
8215
+ * reason order. Unlike typed recovery, mapping does not convert errors to defects.
8216
+ *
8217
+ * **Example** (Mapping errors eagerly when possible)
8218
+ *
8219
+ * ```ts import.meta.vitest
8220
+ * import { Effect } from "effect"
8221
+ * const output: Array<unknown> = []
8222
+ *
8223
+ * // For resolved failure effects, the error mapping is applied immediately
8224
+ * const failed = Effect.fail("original error")
8225
+ * const mapped = Effect.mapErrorEager(failed, (err: string) => `mapped: ${err}`) // Applied eagerly
8226
+ *
8227
+ * // For pending effects, behaves like regular mapError
8228
+ * const pending = Effect.delay(Effect.fail("error"), 0)
8229
+ * const mappedPending = Effect.mapErrorEager(
8230
+ * pending,
8231
+ * (err: string) => `mapped: ${err}`
8232
+ * ) // Uses regular mapError
8233
+ *
8234
+ * void output.push(await Effect.runPromise(Effect.all([
8235
+ * Effect.flip(mapped),
8236
+ * Effect.flip(mappedPending)
8237
+ * ])))
8238
+ * output // => [['mapped: original error', 'mapped: error']]
8239
+ * ```
8240
+ *
8241
+ * @stability stable
8242
+ * @category error handling
8243
+ * @since 4.0.0
8244
+ */
8245
+ var mapErrorEager = mapErrorEager$1;
8246
+ /**
8032
8247
  * Applies `flatMap` eagerly when an effect is already resolved.
8033
8248
  *
8034
8249
  * **When to use**
@@ -8096,10 +8311,214 @@ var flatMapEager = flatMapEager$1;
8096
8311
  * @since 4.0.0
8097
8312
  */
8098
8313
  var fnUntracedEager = fnUntracedEager$1;
8314
+ // ../../node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/internal/base64.js
8315
+ /**
8316
+ * Decodes `str` with native `Uint8Array.fromBase64`.
8317
+ *
8318
+ * Returns `undefined` when native decoding is unavailable or skipped for a
8319
+ * short input, and `null` when native decoding rejected the input. In both
8320
+ * cases the caller's JS path produces the module's own result or error.
8321
+ *
8322
+ * Native decoding also skips ASCII whitespace and accepts missing padding, so
8323
+ * callers validate the length and padding first and pass the byte length a
8324
+ * valid input decodes to. Skipped whitespace always yields fewer bytes, so a
8325
+ * result of any other length counts as rejected.
8326
+ *
8327
+ * @internal
8328
+ */
8329
+ var decodeNative = (str, decodedLength, options) => {
8330
+ if (str.length < 128) return void 0;
8331
+ const NativeUint8Array = Uint8Array;
8332
+ if (typeof NativeUint8Array.fromBase64 !== "function") return void 0;
8333
+ try {
8334
+ const bytes = NativeUint8Array.fromBase64(str, options);
8335
+ return bytes.length === decodedLength ? bytes : null;
8336
+ } catch {
8337
+ return null;
8338
+ }
8339
+ };
8340
+ /** @internal */
8341
+ var stripCrlf = (str) => str.indexOf("\n") === -1 && str.indexOf("\r") === -1 ? str : str.replace(/[\n\r]/g, "");
8342
+ // ../../node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/encoding/Base64.js
8343
+ /**
8344
+ * Base64 encoding and decoding helpers.
8345
+ *
8346
+ * @stability stable
8347
+ * @since 4.0.0
8348
+ */
8349
+ /**
8350
+ * Encodes the given value into a Base64 (RFC 4648) string.
8351
+ *
8352
+ * **When to use**
8353
+ *
8354
+ * Use to encode text or bytes as a standard padded Base64 string for storage or
8355
+ * transport.
8356
+ *
8357
+ * **Details**
8358
+ *
8359
+ * String inputs are encoded as UTF-8 bytes before Base64 encoding.
8360
+ * `Uint8Array` inputs are encoded directly. The output uses the standard
8361
+ * RFC 4648 alphabet with `=` padding.
8362
+ *
8363
+ * **Example** (Encoding Base64 strings and bytes)
8364
+ *
8365
+ * ```ts import.meta.vitest
8366
+ * import { Base64 } from "effect/encoding"
8367
+ *
8368
+ * Base64.encode("hello") // => "aGVsbG8="
8369
+ *
8370
+ * const bytes = new Uint8Array([72, 101, 108, 108, 111])
8371
+ * Base64.encode(bytes) // => "SGVsbG8="
8372
+ * ```
8373
+ *
8374
+ * @see {@link decode} for decoding standard Base64 to bytes
8375
+ * @see {@link decodeString} for decoding standard Base64 to UTF-8 text
8376
+ *
8377
+ * @stability stable
8378
+ * @category encoding
8379
+ * @since 4.0.0
8380
+ */
8381
+ var encode = (input) => encodeBytes(typeof input === "string" ? encoder$1.encode(input) : input);
8382
+ /**
8383
+ * Decodes a Base64 (RFC 4648) string into bytes safely.
8384
+ *
8385
+ * **When to use**
8386
+ *
8387
+ * Use to decode a standard padded Base64 string into bytes without throwing on
8388
+ * invalid input.
8389
+ *
8390
+ * **Details**
8391
+ *
8392
+ * Returns `Result.succeed` with a `Uint8Array` when decoding succeeds, or
8393
+ * `Result.fail` with an `EncodingError` when the input is not valid Base64.
8394
+ *
8395
+ * **Example** (Decoding Base64 bytes)
8396
+ *
8397
+ * ```ts import.meta.vitest
8398
+ * import { Result } from "effect"
8399
+ * import { Base64 } from "effect/encoding"
8400
+ *
8401
+ * Base64.decode("SGVsbG8=") // => Result.succeed(new Uint8Array([72, 101, 108, 108, 111]))
8402
+ * ```
8403
+ *
8404
+ * @stability stable
8405
+ * @category decoding
8406
+ * @since 4.0.0
8407
+ */
8408
+ var decode = (str) => {
8409
+ const stripped = stripCrlf(str);
8410
+ const length = stripped.length;
8411
+ if (length % 4 !== 0) return fail$4(new EncodingError({
8412
+ kind: "Decode",
8413
+ module: "Base64",
8414
+ input: stripped,
8415
+ message: `Length must be a multiple of 4, but is ${length}`
8416
+ }));
8417
+ const index = stripped.indexOf("=");
8418
+ if (index !== -1 && (index < length - 2 || index === length - 2 && stripped[length - 1] !== "=")) return fail$4(new EncodingError({
8419
+ kind: "Decode",
8420
+ module: "Base64",
8421
+ input: stripped,
8422
+ message: "Found a '=' character, but it is not at the end"
8423
+ }));
8424
+ const missingOctets = stripped.endsWith("==") ? 2 : stripped.endsWith("=") ? 1 : 0;
8425
+ const decodedLength = 3 * (length / 4) - missingOctets;
8426
+ const native = decodeNative(stripped, decodedLength, void 0);
8427
+ if (native) return succeed$4(native);
8428
+ if (native === null) {
8429
+ const invalid = invalidCharacter.exec(stripped);
8430
+ if (invalid !== null) return fail$4(new EncodingError({
8431
+ kind: "Decode",
8432
+ module: "Base64",
8433
+ input: stripped,
8434
+ message: `Invalid character ${invalid[0]}`
8435
+ }));
8436
+ }
8437
+ try {
8438
+ const result = new Uint8Array(decodedLength);
8439
+ for (let i = 0, j = 0; i < length; i += 4, j += 3) {
8440
+ const buffer = getCode(stripped.charCodeAt(i)) << 18 | getCode(stripped.charCodeAt(i + 1)) << 12 | getCode(stripped.charCodeAt(i + 2)) << 6 | getCode(stripped.charCodeAt(i + 3));
8441
+ result[j] = buffer >> 16;
8442
+ result[j + 1] = buffer >> 8 & 255;
8443
+ result[j + 2] = buffer & 255;
8444
+ }
8445
+ return succeed$4(result);
8446
+ } catch (cause) {
8447
+ return fail$4(new EncodingError({
8448
+ kind: "Decode",
8449
+ module: "Base64",
8450
+ input: stripped,
8451
+ message: cause instanceof Error ? cause.message : "Invalid input"
8452
+ }));
8453
+ }
8454
+ };
8455
+ var encodeBytes = (bytes) => {
8456
+ const length = bytes.length;
8457
+ const toBase64 = Uint8Array.prototype.toBase64;
8458
+ if (length >= 32 && typeof toBase64 === "function") return toBase64.call(bytes);
8459
+ return length < 128 ? encodeShort(bytes) : encodeLong(bytes);
8460
+ };
8461
+ var encodeShort = (bytes) => {
8462
+ const length = bytes.length;
8463
+ let result = "";
8464
+ let i = 2;
8465
+ for (; i < length; i += 3) {
8466
+ result += alphabet[bytes[i - 2] >> 2];
8467
+ result += alphabet[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
8468
+ result += alphabet[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
8469
+ result += alphabet[bytes[i] & 63];
8470
+ }
8471
+ if (i === length + 1) {
8472
+ result += alphabet[bytes[i - 2] >> 2];
8473
+ result += alphabet[(bytes[i - 2] & 3) << 4];
8474
+ result += "==";
8475
+ }
8476
+ if (i === length) {
8477
+ result += alphabet[bytes[i - 2] >> 2];
8478
+ result += alphabet[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
8479
+ result += alphabet[(bytes[i - 1] & 15) << 2];
8480
+ result += "=";
8481
+ }
8482
+ return result;
8483
+ };
8484
+ var encodeLong = (bytes) => {
8485
+ const length = bytes.length;
8486
+ const result = new Uint8Array(Math.ceil(length / 3) * 4);
8487
+ let i;
8488
+ let j = 0;
8489
+ for (i = 2; i < length; i += 3, j += 4) {
8490
+ result[j] = alphabetCodes[bytes[i - 2] >> 2];
8491
+ result[j + 1] = alphabetCodes[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
8492
+ result[j + 2] = alphabetCodes[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
8493
+ result[j + 3] = alphabetCodes[bytes[i] & 63];
8494
+ }
8495
+ if (i === length + 1) {
8496
+ result[j] = alphabetCodes[bytes[i - 2] >> 2];
8497
+ result[j + 1] = alphabetCodes[(bytes[i - 2] & 3) << 4];
8498
+ result[j + 2] = paddingCode;
8499
+ result[j + 3] = paddingCode;
8500
+ }
8501
+ if (i === length) {
8502
+ result[j] = alphabetCodes[bytes[i - 2] >> 2];
8503
+ result[j + 1] = alphabetCodes[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
8504
+ result[j + 2] = alphabetCodes[(bytes[i - 1] & 15) << 2];
8505
+ result[j + 3] = paddingCode;
8506
+ }
8507
+ return decoder.decode(result);
8508
+ };
8509
+ var encoder$1 = /*#__PURE__*/ new TextEncoder();
8510
+ var decoder = /*#__PURE__*/ new TextDecoder("utf-8", { ignoreBOM: true });
8099
8511
  var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
8512
+ var alphabetCodes = /*#__PURE__*/ encoder$1.encode(alphabet);
8513
+ var paddingCode = /*#__PURE__*/ "=".charCodeAt(0);
8514
+ var invalidCharacter = /[^A-Za-z0-9+/=]/;
8100
8515
  var codes = /*#__PURE__*/ (/* @__PURE__ */ new Uint8Array(123)).fill(255);
8101
8516
  for (let i = 0; i < 64; i++) codes[/*#__PURE__*/ alphabet.charCodeAt(i)] = i;
8102
8517
  codes[/*#__PURE__*/ "=".charCodeAt(0)] = 0;
8518
+ var getCode = (charCode) => {
8519
+ if (charCode >= codes.length || codes[charCode] === 255) throw new TypeError(`Invalid character ${String.fromCharCode(charCode)}`);
8520
+ return codes[charCode];
8521
+ };
8103
8522
  ({ ...BaseProto });
8104
8523
  ({ ...BaseProto });
8105
8524
  ({ ...PipeInspectableProto });
@@ -9005,6 +9424,61 @@ function stringifyJson(options) {
9005
9424
  catch: () => new InvalidValue({ expected: "a JSON-serializable value" }, input, parseOptions)
9006
9425
  }));
9007
9426
  }
9427
+ /**
9428
+ * Encodes a `Uint8Array` or string to a Base64 string.
9429
+ *
9430
+ * **Details**
9431
+ *
9432
+ * The getter is pure and never fails.
9433
+ *
9434
+ * **Example** (Encoding to Base64)
9435
+ *
9436
+ * ```ts import.meta.vitest
9437
+ * import { Effect, Option, SchemaGetter } from "effect"
9438
+ *
9439
+ * const encode = SchemaGetter.encodeBase64<Uint8Array>()
9440
+ * const result = Effect.runSync(SchemaGetter.run(encode, Option.some(new Uint8Array([1, 2, 3])), {}))
9441
+ * result // => Option.some("AQID")
9442
+ * ```
9443
+ *
9444
+ * @see {@link decodeBase64} for the inverse operation to `Uint8Array`
9445
+ * @see {@link decodeBase64String} for the inverse operation to `string`
9446
+ * @see {@link encodeBase64Url} for the URL-safe variant
9447
+ *
9448
+ * @stability stable
9449
+ * @category encoding
9450
+ * @since 4.0.0
9451
+ */
9452
+ function encodeBase64() {
9453
+ return transform$1(encode);
9454
+ }
9455
+ /**
9456
+ * Decodes a Base64 string to a `Uint8Array`.
9457
+ *
9458
+ * **Details**
9459
+ *
9460
+ * - Fails with `SchemaIssue.InvalidValue` if the input is not valid Base64.
9461
+ *
9462
+ * **Example** (Decoding Base64 to bytes)
9463
+ *
9464
+ * ```ts import.meta.vitest
9465
+ * import { Effect, Option, SchemaGetter } from "effect"
9466
+ *
9467
+ * const decode = SchemaGetter.decodeBase64<string>()
9468
+ * const result = await Effect.runPromise(SchemaGetter.run(decode, Option.some("AQID"), {}))
9469
+ * Option.map(result, Array.from) // => Option.some([1, 2, 3])
9470
+ * ```
9471
+ *
9472
+ * @see {@link decodeBase64String} to decode to `string` instead
9473
+ * @see {@link encodeBase64} for the inverse operation
9474
+ *
9475
+ * @stability stable
9476
+ * @category decoding
9477
+ * @since 4.0.0
9478
+ */
9479
+ function decodeBase64() {
9480
+ return transformEffect$1((input, options) => mapErrorEager(fromResult(decode(input)), () => new InvalidValue({ expected: "a valid Base64 string" }, input, options)));
9481
+ }
9008
9482
  // ../../node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/internal/schema/content.js
9009
9483
  var ContentTypeId = /*#__PURE__*/ Symbol.for("~effect/Schema/content");
9010
9484
  /** @internal */
@@ -9169,6 +9643,39 @@ function passthrough() {
9169
9643
  */
9170
9644
  var numberFromString = /*#__PURE__*/ new Transformation(/*#__PURE__*/ Number$3(), /*#__PURE__*/ String$3());
9171
9645
  /**
9646
+ * Decodes a Base64-encoded `string` into a `Uint8Array` and encodes a
9647
+ * `Uint8Array` back to a Base64 string.
9648
+ *
9649
+ * **When to use**
9650
+ *
9651
+ * Use when you need a schema transformation for binary data transmitted as
9652
+ * Base64 strings (e.g. file uploads, API payloads).
9653
+ *
9654
+ * **Details**
9655
+ *
9656
+ * Decoding parses the Base64 string into bytes. Encoding writes the byte array
9657
+ * as a Base64 string.
9658
+ *
9659
+ * **Example** (Converting Base64 to a Uint8Array)
9660
+ *
9661
+ * ```ts import.meta.vitest
9662
+ * import { Schema, SchemaTransformation } from "effect"
9663
+ *
9664
+ * const schema = Schema.String.pipe(
9665
+ * Schema.decodeTo(Schema.Uint8Array, SchemaTransformation.uint8ArrayFromBase64String)
9666
+ * )
9667
+ * Array.from(Schema.decodeSync(schema)("AQID")) // => [1, 2, 3]
9668
+ * ```
9669
+ *
9670
+ * @see {@link fromJsonString}
9671
+ * @see `Schema.Uint8ArrayFromBase64` - a ready-made schema wrapping this transformation.
9672
+ *
9673
+ * @stability stable
9674
+ * @category encoding
9675
+ * @since 4.0.0
9676
+ */
9677
+ var uint8ArrayFromBase64String = /*#__PURE__*/ new Transformation(/*#__PURE__*/ decodeBase64(), /*#__PURE__*/ encodeBase64());
9678
+ /**
9172
9679
  * Decodes a JSON string with `JSON.parse` and encodes a value with
9173
9680
  * `JSON.stringify`.
9174
9681
  *
@@ -14129,6 +14636,41 @@ function toTaggedUnion(tag) {
14129
14636
  };
14130
14637
  }
14131
14638
  /**
14639
+ * Creates a schema that validates values using `instanceof`.
14640
+ * Decoding and encoding pass the value through unchanged.
14641
+ *
14642
+ * **Example** (Defining a schema for a built-in class)
14643
+ *
14644
+ * ```ts import.meta.vitest
14645
+ * import { Schema } from "effect"
14646
+ *
14647
+ * const DateSchema = Schema.instanceOf(Date)
14648
+ *
14649
+ * const decoded = Schema.decodeUnknownSync(DateSchema)(new Date("2024-01-01"))
14650
+ * decoded.toISOString() // => "2024-01-01T00:00:00.000Z"
14651
+ * ```
14652
+ *
14653
+ * @stability stable
14654
+ * @category constructors
14655
+ * @since 3.10.0
14656
+ */
14657
+ function instanceOf(constructor, annotations) {
14658
+ return declare((u) => u instanceof constructor, annotations);
14659
+ }
14660
+ /**
14661
+ * Constructs an `SchemaAST.Link` that describes how a value of type `T` encodes to and decodes from a `To` schema.
14662
+ * Used when building low-level AST transformations that bridge two schema types.
14663
+ *
14664
+ * @stability stable
14665
+ * @category transforming
14666
+ * @since 4.0.0
14667
+ */
14668
+ function link() {
14669
+ return (encodeTo, transformation) => {
14670
+ return new Link(encodeTo.ast, makeTransformation(transformation));
14671
+ };
14672
+ }
14673
+ /**
14132
14674
  * Creates a custom validation filter from a predicate function.
14133
14675
  *
14134
14676
  * **Details**
@@ -14369,6 +14911,51 @@ function isInt(annotations) {
14369
14911
  * @since 3.10.0
14370
14912
  */
14371
14913
  var Int = /*#__PURE__*/ Number$1.check(/*#__PURE__*/ isInt());
14914
+ /**
14915
+ * Validates that a value has at most the specified length. Works with strings
14916
+ * and arrays.
14917
+ *
14918
+ * **Details**
14919
+ *
14920
+ * JSON Schema:
14921
+ *
14922
+ * The bound must be finite; it is rounded down and clamped to zero. This check
14923
+ * corresponds to `maxItems` for arrays. Strings use the same bound for
14924
+ * `maxLength`, which cannot reject a string accepted by this check because a
14925
+ * string has no more code points than UTF-16 code units.
14926
+ *
14927
+ * Arbitrary:
14928
+ *
14929
+ * During arbitrary generation, this applies a `maxLength`
14930
+ * constraint to ensure generated strings or arrays have at most the required
14931
+ * length.
14932
+ *
14933
+ * @stability stable
14934
+ * @category validation
14935
+ * @since 4.0.0
14936
+ */
14937
+ function isMaxLength(maxLength, annotations) {
14938
+ maxLength = normalizeCardinality(maxLength);
14939
+ return makeFilter((input) => input.length <= maxLength, {
14940
+ expected: `a value with a length of at most ${maxLength}`,
14941
+ representation: {
14942
+ id: "effect/schema/isMaxLength",
14943
+ payload: { maxLength }
14944
+ },
14945
+ toJsonSchema: ({ type }) => type === "string" ? maxLength === 0 ? { maxLength } : [{ maxLength }, true] : type === "array" ? { maxItems: maxLength } : type === void 0 ? [{
14946
+ maxLength,
14947
+ maxItems: maxLength
14948
+ }, true] : [{}, true],
14949
+ toCode: () => ({ runtime: `Schema.isMaxLength(${maxLength})` }),
14950
+ [STRUCTURAL_ANNOTATION_KEY]: true,
14951
+ arbitraryConstraint: { maxLength },
14952
+ ...annotations
14953
+ });
14954
+ }
14955
+ function normalizeCardinality(value) {
14956
+ if (!globalThis.Number.isFinite(value)) throw new globalThis.RangeError(`Expected a finite number, got ${value}`);
14957
+ return Math.max(0, Math.floor(value));
14958
+ }
14372
14959
  globalThis.RegExp;
14373
14960
  globalThis.URL;
14374
14961
  var JsonString = /*#__PURE__*/ String$1.annotate({ expected: "a string that will be decoded as JSON" });
@@ -14407,7 +14994,36 @@ function fromJsonString(schema, options) {
14407
14994
  }
14408
14995
  globalThis.File;
14409
14996
  globalThis.URLSearchParams;
14410
- globalThis.Uint8Array;
14997
+ var Base64String = /*#__PURE__*/ String$1.annotate({
14998
+ expected: "a base64 encoded string that will be decoded as Uint8Array",
14999
+ format: "byte",
15000
+ contentEncoding: "base64"
15001
+ });
15002
+ /**
15003
+ * Schema for JavaScript `Uint8Array` objects.
15004
+ *
15005
+ * **Details**
15006
+ *
15007
+ * Default JSON serializer:
15008
+ *
15009
+ * The default JSON serializer encodes Uint8Array as a Base64 encoded string.
15010
+ *
15011
+ * @stability stable
15012
+ * @category schemas
15013
+ * @since 4.0.0
15014
+ */
15015
+ var Uint8Array$1 = /*#__PURE__*/ instanceOf(globalThis.Uint8Array, {
15016
+ representation: {
15017
+ id: "effect/schema/Uint8Array",
15018
+ payload: null
15019
+ },
15020
+ toCode: () => ({
15021
+ runtime: `Schema.Uint8Array`,
15022
+ Type: `globalThis.Uint8Array`
15023
+ }),
15024
+ expected: "Uint8Array",
15025
+ toCodecJson: () => link()(Base64String, uint8ArrayFromBase64String)
15026
+ });
14411
15027
  var immerable = /*#__PURE__*/ globalThis.Symbol.for("immer-draftable");
14412
15028
  var payloadToken = {};
14413
15029
  function makeClass(Inherited, identifier, struct$1, annotations, proto) {
@@ -14743,6 +15359,18 @@ var Entry = Union([
14743
15359
  }),
14744
15360
  TaggedStruct("subagentResult", { text: String$1 })
14745
15361
  ]).pipe(toTaggedUnion("_tag"));
15362
+ var Settings = Struct({
15363
+ provider: String$1,
15364
+ model: String$1,
15365
+ effort: String$1,
15366
+ image: String$1,
15367
+ size: String$1,
15368
+ lifetime: Int,
15369
+ repository: NullOr(Struct({
15370
+ url: String$1.check(isPattern(/^https?:\/\/[^/\s]+/, { message: "repository URL must start with https:// (or http://) and name a host" })),
15371
+ shallow: Boolean$1
15372
+ }))
15373
+ });
14746
15374
  // ../../packages/worker-api/src/session-state.ts
14747
15375
  var SessionStatuses = {
14748
15376
  running: "running",
@@ -14756,12 +15384,26 @@ var Question = Struct({
14756
15384
  id: QuestionId,
14757
15385
  text: String$1
14758
15386
  });
15387
+ var SessionDetails = Struct({
15388
+ settings: Settings,
15389
+ skills: ArraySchema(String$1),
15390
+ agents: ArraySchema(String$1)
15391
+ });
14759
15392
  var SessionState = Union([
14760
- TaggedStruct(SessionStatuses.running, {}),
14761
- TaggedStruct(SessionStatuses.waiting, { question: Question }),
14762
- TaggedStruct(SessionStatuses.idle, { lastEntry: optionalKey(Entry) }),
14763
- TaggedStruct(SessionStatuses.failed, { failure: String$1 }),
14764
- TaggedStruct(SessionStatuses.closed, {})
15393
+ TaggedStruct(SessionStatuses.running, SessionDetails.fields),
15394
+ TaggedStruct(SessionStatuses.waiting, {
15395
+ ...SessionDetails.fields,
15396
+ question: Question
15397
+ }),
15398
+ TaggedStruct(SessionStatuses.idle, {
15399
+ ...SessionDetails.fields,
15400
+ lastEntry: optionalKey(Entry)
15401
+ }),
15402
+ TaggedStruct(SessionStatuses.failed, {
15403
+ ...SessionDetails.fields,
15404
+ failure: String$1
15405
+ }),
15406
+ TaggedStruct(SessionStatuses.closed, SessionDetails.fields)
14765
15407
  ]).pipe(toTaggedUnion("_tag"));
14766
15408
  /** The registry's status for a state. */
14767
15409
  var statusOf = (state) => SessionState.match(state, {
@@ -14779,6 +15421,10 @@ var SessionRef = Struct({
14779
15421
  name: String$1,
14780
15422
  status: SessionStatus
14781
15423
  });
15424
+ var SessionListing = Struct({
15425
+ ...SessionRef.fields,
15426
+ ...SessionDetails.fields
15427
+ });
14782
15428
  // ../../node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/internal/matcher.js
14783
15429
  /** @internal */
14784
15430
  var TypeId$6 = "~effect/Match/Matcher";
@@ -15136,11 +15782,13 @@ var orElse = orElse$1;
15136
15782
  var SessionNotFound = class extends TaggedError()("SessionNotFound", { sessionId: SessionId }, { httpApiStatus: 404 }) {};
15137
15783
  var QuestionNotWaiting = class extends TaggedError()("QuestionNotWaiting", { questionId: QuestionId }, { httpApiStatus: 409 }) {};
15138
15784
  var Unauthorized = class extends TaggedError()("Unauthorized", {}, { httpApiStatus: 401 }) {};
15785
+ var InvalidArchive = class extends TaggedError()("InvalidArchive", { message: String$1 }, { httpApiStatus: 400 }) {};
15139
15786
  /** Every error the API returns; the helper's command result carries it. */
15140
15787
  var TentaclesError = Union([
15141
15788
  SessionNotFound,
15142
15789
  QuestionNotWaiting,
15143
- Unauthorized
15790
+ Unauthorized,
15791
+ InvalidArchive
15144
15792
  ]);
15145
15793
  var WatchLineJson = fromJsonString(Union([Struct({
15146
15794
  sessionId: SessionId,
@@ -16457,33 +17105,49 @@ var http = (options) => Object.assign(Object.create(Proto), {
16457
17105
  * @since 4.0.0
16458
17106
  */
16459
17107
  var bearer = /*#__PURE__*/ http({ scheme: "Bearer" });
17108
+ // ../../packages/worker-api/src/archive-kinds.ts
17109
+ /**
17110
+ * The kinds of archive a create request carries. `expandsInto` is where the workspace container
17111
+ * expands the kind's archive; a null one is read by the Worker only and never reaches the container.
17112
+ */
17113
+ var archiveKinds = {
17114
+ skills: {
17115
+ heading: "Skills",
17116
+ expandsInto: "/skills"
17117
+ },
17118
+ agents: {
17119
+ heading: "Agents",
17120
+ expandsInto: null
17121
+ },
17122
+ context: {
17123
+ heading: "Context",
17124
+ expandsInto: "/context"
17125
+ }
17126
+ };
17127
+ keys(archiveKinds).flatMap((kind) => {
17128
+ const { expandsInto } = archiveKinds[kind];
17129
+ return expandsInto == null ? [] : [{
17130
+ kind,
17131
+ directory: expandsInto
17132
+ }];
17133
+ });
16460
17134
  // ../../packages/worker-api/src/middleware.ts
16461
17135
  /** Every request carries the API key as a bearer token; a provider checks it against its secret. */
16462
17136
  var ApiKey = class extends Service()("tentacles/ApiKey", {
16463
17137
  security: { bearer },
16464
17138
  error: Unauthorized
16465
17139
  }) {};
16466
- var Settings = Struct({
16467
- provider: String$1,
16468
- model: String$1,
16469
- effort: String$1,
16470
- image: String$1,
16471
- size: String$1,
16472
- lifetime: Int,
16473
- repository: NullOr(Struct({
16474
- url: String$1,
16475
- shallow: Boolean$1
16476
- }))
16477
- });
16478
17140
  var PromptMode = Enum({
16479
17141
  followUp: "followUp",
16480
17142
  steer: "steer"
16481
17143
  });
17144
+ var Archive = Uint8Array$1.check(isMaxLength(5242880));
16482
17145
  var CreateSession = Struct({
16483
17146
  name: String$1,
16484
17147
  parent: Parent,
16485
17148
  settings: Settings,
16486
- prompt: String$1
17149
+ prompt: String$1,
17150
+ ...map$5(archiveKinds, () => optionalKey(Archive))
16487
17151
  });
16488
17152
  var Prompt = Struct({
16489
17153
  text: String$1,
@@ -16497,7 +17161,8 @@ var sessionParams = { sessionId: SessionId };
16497
17161
  var MessageCount = Int.check(isGreaterThanOrEqualTo(1));
16498
17162
  var SessionsGroup = class extends make("sessions").add(post("create", "/sessions", {
16499
17163
  payload: CreateSession,
16500
- success: Struct({ sessionId: SessionId })
17164
+ success: Struct({ sessionId: SessionId }),
17165
+ error: InvalidArchive
16501
17166
  }), post("prompt", "/sessions/:sessionId/prompt", {
16502
17167
  params: sessionParams,
16503
17168
  payload: Prompt,
@@ -16523,7 +17188,7 @@ var SessionsGroup = class extends make("sessions").add(post("create", "/sessions
16523
17188
  error: SessionNotFound
16524
17189
  }), get("list", "/sessions", {
16525
17190
  query: Parent.fields,
16526
- success: ArraySchema(SessionRef)
17191
+ success: ArraySchema(SessionListing)
16527
17192
  }), get("socket", "/sessions/:sessionId/socket", {
16528
17193
  params: sessionParams,
16529
17194
  success: Empty(101),
@@ -16569,8 +17234,15 @@ var endpointArguments = (name) => {
16569
17234
  };
16570
17235
  /** What the agent sends to spawn: the glue fills the parent. */
16571
17236
  var SpawnArguments = CreateSession.mapFields((fields) => ({
16572
- ...fields,
16573
- settings: optionalKey(Settings.mapFields(map(optionalKey)))
17237
+ ...omit(fields, [
17238
+ "skills",
17239
+ "agents",
17240
+ "context"
17241
+ ]),
17242
+ settings: optionalKey(Settings.mapFields(map(optionalKey))),
17243
+ skills: optionalKey(ArraySchema(String$1).annotate({ description: "Paths of skill folders on this machine, each holding a SKILL.md." })),
17244
+ agents: optionalKey(ArraySchema(String$1).annotate({ description: "Paths of agent definition files on this machine." })),
17245
+ context: optionalKey(ArraySchema(String$1).annotate({ description: "Paths of files or folders on this machine; the remote agent finds them in /context, each under its own name." }))
16574
17246
  })).mapFields(omit(["parent"]));
16575
17247
  // src/core/tool-table.ts
16576
17248
  var ToolNames = {
@@ -16589,7 +17261,7 @@ var spawnDocument = toJsonSchemaDocument(SpawnArguments);
16589
17261
  var ToolTable = {
16590
17262
  spawn: ToolEntry.Endpoint({
16591
17263
  name: ToolNames.spawn,
16592
- description: "Start a remote agent with a name, a first prompt and optional settings. The settings left out come from the plugin's defaults. Answers with the new session's id.",
17264
+ description: "Start a remote agent with a name, a first prompt and optional settings. The settings left out come from the plugin's defaults. Optionally takes the paths of skill folders and agent definition files, and the paths of context files or folders the remote agent finds in /context, which stay fixed for the session. Answers with the new session's id.",
16593
17265
  endpoint: "create",
16594
17266
  harnesses: bothHarnesses,
16595
17267
  arguments: {
@@ -16667,7 +17339,8 @@ var decodeWatchLine = decodeUnknownOption(WatchLineJson);
16667
17339
  var failureText = type().pipe(tagsExhaustive({
16668
17340
  SessionNotFound: (error) => `SessionNotFound: session ${error.sessionId} does not exist.`,
16669
17341
  QuestionNotWaiting: (error) => `QuestionNotWaiting: question ${error.questionId} is no longer waiting.`,
16670
- Unauthorized: () => "Unauthorized: the Worker refused the API key in TENTACLES_API_KEY."
17342
+ Unauthorized: () => "Unauthorized: the Worker refused the API key in TENTACLES_API_KEY.",
17343
+ InvalidArchive: (error) => error.message
16671
17344
  }));
16672
17345
  var wakeKeyOf = (state) => value(state).pipe(tag(SessionStatuses.waiting, (waiting) => `${SessionStatuses.waiting}:${waiting.question.id}`), orElse(statusOf));
16673
17346
  /** Holds the local-state transitions, which states wake the parent and when the watch restarts; both glues run it. */