@vite-hub/workspace 0.0.3 → 0.0.4

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 (86) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +13 -2
  3. package/dist/{ai-Ce3PtWFW.js → ai-BqCC8BpY.js} +2 -2
  4. package/dist/{ai-nmHdzjCM.d.ts → ai-CjxvGqM0.d.ts} +1 -1
  5. package/dist/ai.d.ts +2 -2
  6. package/dist/ai.js +1 -1
  7. package/dist/{asset-registry-CaG9b7tf.js → asset-registry-8QI3ML3K.js} +1 -1
  8. package/dist/chunk-2rV9d50f.js +35 -0
  9. package/dist/cloudflare.d.ts +1 -1
  10. package/dist/cloudflare.js +1 -1
  11. package/dist/collections.d.ts +2 -2
  12. package/dist/collections.js +1 -1
  13. package/dist/{config-CZLO0m9h.js → config-Bc3c4Su1.js} +213 -120
  14. package/dist/{config-CDoyls2X.js → config-CHLLWklZ.js} +9 -3
  15. package/dist/{config-3I1BnsdO.d.ts → config-DE9xlaIw.d.ts} +1 -1
  16. package/dist/{file-CHfsZpso.js → file-Bc1X7pco.js} +3 -3
  17. package/dist/{files-QRV55OCx.js → files-Q6xZjDHA.js} +20 -9
  18. package/dist/{github-CfA5vpJ5.js → github-DHnjxQIX.js} +24 -15
  19. package/dist/{glob-D0vD_wRY.js → glob-CEZKeZFC.js} +5 -4
  20. package/dist/host-DJH8cuoU.js +1030 -0
  21. package/dist/{hosted-C1-tTTTf.js → hosted-RPeJOCFz.js} +121 -31
  22. package/dist/hosted-vercel-blob-d6C8ND5j.js +23580 -0
  23. package/dist/hosted-vercel-blob.d.ts +1 -1
  24. package/dist/hosted-vercel-blob.js +1 -1
  25. package/dist/hosted.d.ts +1 -1
  26. package/dist/hosted.js +1 -1
  27. package/dist/index.d.ts +42 -51
  28. package/dist/index.js +124 -419
  29. package/dist/lifecycle-LrL3sA4n.js +316 -0
  30. package/dist/loader.d.ts +1 -1
  31. package/dist/loader.js +1 -1
  32. package/dist/metadata-target-B0tOmVW7.js +717 -0
  33. package/dist/mountx.d.ts +1 -1
  34. package/dist/nitro.d.ts +1 -1
  35. package/dist/nitro.js +1 -1
  36. package/dist/nuxt.d.ts +1 -1
  37. package/dist/nuxt.js +8 -2
  38. package/dist/{path-CNI6wKIU.js → path-Cp59koVz.js} +28 -4
  39. package/dist/{provider-C3_elpEh.js → provider-B1yLjCJJ.js} +194 -47
  40. package/dist/providers/github/store.d.ts +1 -1
  41. package/dist/providers/github/store.js +1 -1
  42. package/dist/publish.d.ts +1 -1
  43. package/dist/publish.js +2 -2
  44. package/dist/registry-D3yzt8HQ.js +127 -0
  45. package/dist/{registry-BIQVCBWI.d.ts → registry-Uj6IVxes.d.ts} +3 -3
  46. package/dist/{request-execution-u9mgUXKX.js → request-execution-B-dSFlGB.js} +8 -4
  47. package/dist/runtime/assets.d.ts +1 -1
  48. package/dist/runtime/assets.js +4 -2
  49. package/dist/runtime/empty-assets-registry.d.ts +1 -1
  50. package/dist/runtime/empty-registry.d.ts +1 -1
  51. package/dist/runtime/state.d.ts +4 -4
  52. package/dist/runtime/state.js +10 -7
  53. package/dist/runtime/workspace.d.ts +1 -1
  54. package/dist/runtime/workspace.js +1 -1
  55. package/dist/runtime-type-iEE6BjQJ.js +34 -0
  56. package/dist/runtime.d.ts +42 -7
  57. package/dist/runtime.js +275 -82
  58. package/dist/{search-C4REyHj9.js → search-BpiCF2Tw.js} +2 -2
  59. package/dist/server.d.ts +2 -2
  60. package/dist/server.js +23 -50
  61. package/dist/{shared-jfogBrd5.js → shared-DTR1Hhma.js} +97 -39
  62. package/dist/source-metadata.d.ts +9 -2
  63. package/dist/source-metadata.js +34 -2
  64. package/dist/{state-TTqa3x3Y.d.ts → state-tYcRWEh2.d.ts} +13 -12
  65. package/dist/store-Dt_Jyys3.js +608 -0
  66. package/dist/{sync-DiuDmSGk.js → sync-DnTQwt8r.js} +6 -5
  67. package/dist/test.d.ts +1 -1
  68. package/dist/test.js +1 -1
  69. package/dist/token-CVzURBxC.js +61 -0
  70. package/dist/{types-60Yn149G.d.ts → types-CYuwjJ4V.d.ts} +94 -27
  71. package/dist/{use-CsV3oIxH.js → use-BTNDR5Rd.js} +145 -31
  72. package/dist/{use-CUFSnFCS.d.ts → use-BiHzt0xA.d.ts} +21 -4
  73. package/dist/vite-BptCrpv2.js +4526 -0
  74. package/dist/vite-CtA9guIM.d.ts +66 -0
  75. package/dist/vite.d.ts +2 -50
  76. package/dist/vite.js +2 -2
  77. package/dist/{workspace-C4k92Ow8.js → workspace-Dq08Yn72.js} +224 -529
  78. package/dist/{workspace-66SKyiec.d.ts → workspace-Xddf4G1B.d.ts} +1 -1
  79. package/package.json +15 -18
  80. package/dist/chunk-8H4AJuhK.js +0 -14
  81. package/dist/host-CAnbugpI.js +0 -370
  82. package/dist/hosted-vercel-blob-CWBILDVo.js +0 -257
  83. package/dist/lifecycle-BYoa9hVb.js +0 -176
  84. package/dist/registry-CqyDTW9Y.js +0 -74
  85. package/dist/store-Bs1SLh55.js +0 -414
  86. package/dist/vite-tbfDxtlu.js +0 -2191
@@ -1,6 +1,7 @@
1
- import { i as decodeFile, o as normalizeSafeWorkspacePath, p as workspaceError } from "./path-CNI6wKIU.js";
1
+ import { _ as workspaceError, i as decodeFile, s as normalizeSafeWorkspacePath } from "./path-Cp59koVz.js";
2
2
  import { posix } from "node:path";
3
3
  import { defu } from "defu";
4
+ import { sourceIgnores } from "@vite-hub/source";
4
5
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.99/node_modules/effect/dist/Pipeable.js
5
6
  /**
6
7
  * The `Pipeable` module defines the shared interface and implementation helpers
@@ -2045,7 +2046,7 @@ const fail$3 = (failure) => {
2045
2046
  return a;
2046
2047
  };
2047
2048
  /** @internal */
2048
- const succeed$2 = (success) => {
2049
+ const succeed$3 = (success) => {
2049
2050
  const a = Object.create(SuccessProto);
2050
2051
  a.success = success;
2051
2052
  return a;
@@ -2385,7 +2386,7 @@ const getOrUndefined = /*#__PURE__*/ (/* @__PURE__ */ dual(2, (self, onNone) =>
2385
2386
  * @category constructors
2386
2387
  * @since 4.0.0
2387
2388
  */
2388
- const succeed$1 = succeed$2;
2389
+ const succeed$2 = succeed$3;
2389
2390
  /**
2390
2391
  * Creates a `Result` holding a `Failure` value.
2391
2392
  *
@@ -4341,7 +4342,7 @@ const causeInterrupt = (fiberId) => new CauseImpl([new Interrupt(fiberId)]);
4341
4342
  const findError$1 = (self) => {
4342
4343
  for (let i = 0; i < self.reasons.length; i++) {
4343
4344
  const reason = self.reasons[i];
4344
- if (reason._tag === "Fail") return succeed$1(reason.error);
4345
+ if (reason._tag === "Fail") return succeed$2(reason.error);
4345
4346
  }
4346
4347
  return fail$2(self);
4347
4348
  };
@@ -4356,7 +4357,7 @@ const causeFilterInterruptors = (self) => {
4356
4357
  interruptors ??= /* @__PURE__ */ new Set();
4357
4358
  if (f.fiberId !== void 0) interruptors.add(f.fiberId);
4358
4359
  }
4359
- return interruptors ? succeed$1(interruptors) : fail$2(self);
4360
+ return interruptors ? succeed$2(interruptors) : fail$2(self);
4360
4361
  };
4361
4362
  /** @internal */
4362
4363
  const causeCombine = /*#__PURE__*/ dual(2, (self, that) => {
@@ -4560,7 +4561,7 @@ const fiberAwaitAll = (self) => callback((resume) => {
4560
4561
  });
4561
4562
  return;
4562
4563
  }
4563
- resume(succeed(exits));
4564
+ resume(succeed$1(exits));
4564
4565
  }
4565
4566
  loop();
4566
4567
  return sync$1(() => cancel?.());
@@ -4576,7 +4577,7 @@ const fiberInterruptAll = (fibers) => withFiber((parent) => {
4576
4577
  return asVoid(fiberAwaitAll(fiberArr));
4577
4578
  });
4578
4579
  /** @internal */
4579
- const succeed = exitSucceed;
4580
+ const succeed$1 = exitSucceed;
4580
4581
  /** @internal */
4581
4582
  const failCause = exitFailCause;
4582
4583
  /** @internal */
@@ -4616,11 +4617,7 @@ const die = (defect) => exitDie(defect);
4616
4617
  /** @internal */
4617
4618
  const failSync = (error) => suspend(() => fail$1(internalCall(error)));
4618
4619
  /** @internal */
4619
- const void_$2 = /*#__PURE__*/ succeed(void 0);
4620
- /** @internal */
4621
- const promise$1 = (evaluate) => callbackOptions(function(resume, signal) {
4622
- internalCall(() => evaluate(signal)).then((a) => resume(succeed(a)), (e) => resume(die(e)));
4623
- }, evaluate.length !== 0);
4620
+ const void_$2 = /*#__PURE__*/ succeed$1(void 0);
4624
4621
  /** @internal */
4625
4622
  const tryPromise$1 = (options) => {
4626
4623
  const f = typeof options === "function" ? options : options.try;
@@ -4634,7 +4631,7 @@ const tryPromise$1 = (options) => {
4634
4631
  }
4635
4632
  };
4636
4633
  try {
4637
- internalCall(() => f(signal)).then((a) => resume(succeed(a)), failWithCatch);
4634
+ internalCall(() => f(signal)).then((a) => resume(succeed$1(a)), failWithCatch);
4638
4635
  } catch (err) {
4639
4636
  failWithCatch(err);
4640
4637
  }
@@ -4743,7 +4740,7 @@ const fromIteratorUnsafe = /*#__PURE__*/ makePrimitive({
4743
4740
  const iter = this[args][0];
4744
4741
  while (true) {
4745
4742
  const state = iter.next(value);
4746
- if (state.done) return succeed(state.value);
4743
+ if (state.done) return succeed$1(state.value);
4747
4744
  if (!effectIsExit(state.value)) {
4748
4745
  fiber._stack.push(this);
4749
4746
  return state.value;
@@ -4757,7 +4754,7 @@ const fromIteratorUnsafe = /*#__PURE__*/ makePrimitive({
4757
4754
  });
4758
4755
  /** @internal */
4759
4756
  const as = /*#__PURE__*/ dual(2, (self, value) => {
4760
- const b = succeed(value);
4757
+ const b = succeed$1(value);
4761
4758
  return flatMap$1(self, (_) => b);
4762
4759
  });
4763
4760
  /** @internal */
@@ -4812,7 +4809,7 @@ const OnSuccessProto = /*#__PURE__*/ makePrimitiveProto({
4812
4809
  /** @internal */
4813
4810
  const effectIsExit = (effect) => ExitTypeId in effect;
4814
4811
  /** @internal */
4815
- const map = /*#__PURE__*/ dual(2, (self, f) => flatMap$1(self, (a) => succeed(internalCall(() => f(a)))));
4812
+ const map = /*#__PURE__*/ dual(2, (self, f) => flatMap$1(self, (a) => succeed$1(internalCall(() => f(a)))));
4816
4813
  /** @internal */
4817
4814
  const exitIsSuccess = (self) => self._tag === "Success";
4818
4815
  /** @internal */
@@ -4903,10 +4900,10 @@ const exitPrimitive = /*#__PURE__*/ makePrimitive({
4903
4900
  return this[args];
4904
4901
  },
4905
4902
  [contA](value, _, exit) {
4906
- return succeed(exit ?? exitSucceed(value));
4903
+ return succeed$1(exit ?? exitSucceed(value));
4907
4904
  },
4908
4905
  [contE](cause, _, exit) {
4909
- return succeed(exit ?? exitFailCause(cause));
4906
+ return succeed$1(exit ?? exitFailCause(cause));
4910
4907
  }
4911
4908
  });
4912
4909
  /** @internal */
@@ -5582,7 +5579,7 @@ const catchDone = /*#__PURE__*/ dual(2, (effect, f) => catchCauseFilter(effect,
5582
5579
  * @category Done
5583
5580
  * @since 4.0.0
5584
5581
  */
5585
- const filterDone = /*#__PURE__*/ composePassthrough(findError, (e) => isDone(e) ? succeed$1(e) : fail$2(e));
5582
+ const filterDone = /*#__PURE__*/ composePassthrough(findError, (e) => isDone(e) ? succeed$2(e) : fail$2(e));
5586
5583
  /**
5587
5584
  * Filters a Cause to extract the leftover value from done errors.
5588
5585
  *
@@ -5594,7 +5591,7 @@ const filterDone = /*#__PURE__*/ composePassthrough(findError, (e) => isDone(e)
5594
5591
  * @category Done
5595
5592
  * @since 4.0.0
5596
5593
  */
5597
- const filterDoneLeftover = /*#__PURE__*/ composePassthrough(findError, (e) => isDone(e) ? succeed$1(e.value) : fail$2(e));
5594
+ const filterDoneLeftover = /*#__PURE__*/ composePassthrough(findError, (e) => isDone(e) ? succeed$2(e.value) : fail$2(e));
5598
5595
  /**
5599
5596
  * Pattern matches on a Pull, handling success, failure, and done cases.
5600
5597
  *
@@ -5783,7 +5780,7 @@ const fromStepWithMetadata = (step) => fromStep(map(step, (f) => {
5783
5780
  * @category destructors
5784
5781
  * @since 4.0.0
5785
5782
  */
5786
- const toStep = (schedule) => catchCause(schedule.step, (cause) => succeed(() => failCause(cause)));
5783
+ const toStep = (schedule) => catchCause(schedule.step, (cause) => succeed$1(() => failCause(cause)));
5787
5784
  /**
5788
5785
  * Extracts a step function from a `Schedule` that sleeps for each computed
5789
5786
  * delay and returns metadata for the completed step.
@@ -5847,7 +5844,7 @@ const toStepWithMetadata = (schedule) => clockWith((clock) => map(toStep(schedul
5847
5844
  * @since 2.0.0
5848
5845
  */
5849
5846
  const passthrough = (self) => fromStep(map(toStep(self), (step) => (now, input) => matchEffect(step(now, input), {
5850
- onSuccess: (result) => succeed([input, result[1]]),
5847
+ onSuccess: (result) => succeed$1([input, result[1]]),
5851
5848
  onFailure: failCause,
5852
5849
  onDone: () => done(input)
5853
5850
  })));
@@ -5910,7 +5907,7 @@ const passthrough = (self) => fromStep(map(toStep(self), (step) => (now, input)
5910
5907
  */
5911
5908
  const spaced = (duration) => {
5912
5909
  const decoded = fromInputUnsafe(duration);
5913
- return fromStepWithMetadata(succeed((meta) => succeed([meta.attempt - 1, decoded])));
5910
+ return fromStepWithMetadata(succeed$1((meta) => succeed$1([meta.attempt - 1, decoded])));
5914
5911
  };
5915
5912
  const while_ = /*#__PURE__*/ dual(2, (self, predicate) => fromStep(map(toStep(self), (step) => {
5916
5913
  const meta = metadataFn();
@@ -5921,7 +5918,7 @@ const while_ = /*#__PURE__*/ dual(2, (self, predicate) => fromStep(map(toStep(se
5921
5918
  output,
5922
5919
  duration
5923
5920
  });
5924
- return flatMap$1(isEffect(eff) ? eff : succeed(eff), (check) => check ? succeed(result) : done(output));
5921
+ return flatMap$1(isEffect(eff) ? eff : succeed$1(eff), (check) => check ? succeed$1(result) : done(output));
5925
5922
  });
5926
5923
  })));
5927
5924
  /**
@@ -5980,65 +5977,18 @@ const buildFromOptions = (options) => {
5980
5977
  let schedule = options.schedule ? passthrough(options.schedule) : passthroughForever;
5981
5978
  if (options.while) schedule = while_(schedule, ({ input }) => {
5982
5979
  const applied = options.while(input);
5983
- return isEffect(applied) ? applied : succeed(applied);
5980
+ return isEffect(applied) ? applied : succeed$1(applied);
5984
5981
  });
5985
5982
  if (options.until) schedule = while_(schedule, ({ input }) => {
5986
5983
  const applied = options.until(input);
5987
- return isEffect(applied) ? map(applied, (b) => !b) : succeed(!applied);
5984
+ return isEffect(applied) ? map(applied, (b) => !b) : succeed$1(!applied);
5988
5985
  });
5989
- if (options.times !== void 0) schedule = while_(schedule, ({ attempt }) => succeed(attempt <= options.times));
5986
+ if (options.times !== void 0) schedule = while_(schedule, ({ attempt }) => succeed$1(attempt <= options.times));
5990
5987
  return schedule;
5991
5988
  };
5992
5989
  //#endregion
5993
5990
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.99/node_modules/effect/dist/Effect.js
5994
5991
  /**
5995
- * Creates an `Effect` that represents an asynchronous computation guaranteed to
5996
- * succeed.
5997
- *
5998
- * **When to use**
5999
- *
6000
- * Use to convert a `Promise` into an `Effect` when the async operation is
6001
- * guaranteed to succeed and will not reject.
6002
- *
6003
- * **Details**
6004
- *
6005
- * An optional `AbortSignal` can be provided to allow for interruption of the
6006
- * wrapped `Promise` API.
6007
- *
6008
- * **Gotchas**
6009
- *
6010
- * The `Promise` must not reject. If it rejects, the rejection is treated as a
6011
- * defect, not as a typed failure. Use `tryPromise` when rejection is expected.
6012
- *
6013
- * Interruption aborts the provided `AbortSignal`, but the underlying
6014
- * asynchronous operation only stops if it observes that signal.
6015
- *
6016
- * **Example** (Wrapping a non-rejecting Promise)
6017
- *
6018
- * ```ts
6019
- * import { Effect } from "effect"
6020
- *
6021
- * const delay = (message: string) =>
6022
- * Effect.promise<string>(
6023
- * () =>
6024
- * new Promise((resolve) => {
6025
- * setTimeout(() => {
6026
- * resolve(message)
6027
- * }, 2000)
6028
- * })
6029
- * )
6030
- *
6031
- * // ┌─── Effect<string, never, never>
6032
- * // ▼
6033
- * const program = delay("Async operation completed successfully!")
6034
- * ```
6035
- *
6036
- * @see {@link tryPromise} for a version that can handle failures.
6037
- * @category constructors
6038
- * @since 2.0.0
6039
- */
6040
- const promise = promise$1;
6041
- /**
6042
5992
  * Creates an `Effect` from an asynchronous computation that may throw or
6043
5993
  * reject, mapping failures into the error channel.
6044
5994
  *
@@ -6110,6 +6060,31 @@ const promise = promise$1;
6110
6060
  */
6111
6061
  const tryPromise = tryPromise$1;
6112
6062
  /**
6063
+ * Creates an `Effect` that always succeeds with a given value.
6064
+ *
6065
+ * **When to use**
6066
+ *
6067
+ * Use when an effect should complete successfully with a specific value without any errors
6068
+ * or external dependencies.
6069
+ *
6070
+ * **Example** (Creating a successful effect)
6071
+ *
6072
+ * ```ts
6073
+ * import { Effect } from "effect"
6074
+ *
6075
+ * // Creating an effect that represents a successful scenario
6076
+ * //
6077
+ * // ┌─── Effect<number, never, never>
6078
+ * // ▼
6079
+ * const success = Effect.succeed(42)
6080
+ * ```
6081
+ *
6082
+ * @see {@link fail} to create an effect that represents a failure.
6083
+ * @category constructors
6084
+ * @since 2.0.0
6085
+ */
6086
+ const succeed = succeed$1;
6087
+ /**
6113
6088
  * Creates an `Effect` that represents a synchronous side-effectful computation.
6114
6089
  *
6115
6090
  * **When to use**
@@ -6973,8 +6948,10 @@ function createEffectBoundary(options) {
6973
6948
  tryPromise: tryPromise$2
6974
6949
  };
6975
6950
  }
6976
- //#endregion
6977
- //#region ../internal/src/http-request.ts
6951
+ const maximumHttpMaxResponseBytes = 25 * 1024 * 1024;
6952
+ function primitiveRuntimeTag(value) {
6953
+ return value !== null && value !== void 0 && Object(value) !== value ? Object.prototype.toString.call(value) : void 0;
6954
+ }
6978
6955
  const httpEffectBoundary = createEffectBoundary({
6979
6956
  aggregateMessage: "[vitehub] HTTP request failed.",
6980
6957
  interruptionMessage: "[vitehub] HTTP request was interrupted."
@@ -7000,19 +6977,30 @@ async function executeHttpRequest(definition, options = {}) {
7000
6977
  }
7001
6978
  function fetchWithRetry(definition, responseType, schema) {
7002
6979
  const attempts = definition.method === "GET" || definition.method === "HEAD" ? 2 : 1;
7003
- const attempt = fetchOnce(definition, responseType, schema);
7004
- return retry(definition.timeout ? timeoutOrElse(attempt, {
6980
+ return retry(timeoutOrElse(fetchOnce(definition, responseType), {
7005
6981
  duration: definition.timeout,
7006
6982
  orElse: () => fail(new HttpAttemptFailure({
7007
6983
  cause: new DOMException("This operation was aborted", "AbortError"),
7008
6984
  retryable: true
7009
6985
  }))
7010
- }) : attempt, {
6986
+ }), {
7011
6987
  times: attempts - 1,
7012
6988
  while: (error) => error.retryable
7013
- }).pipe(mapError((error) => new EffectBoundaryFailure({ cause: error.cause })));
6989
+ }).pipe(flatMap(({ data, response }) => schema ? tryPromise({
6990
+ catch: (cause) => new HttpAttemptFailure({
6991
+ cause,
6992
+ retryable: false
6993
+ }),
6994
+ try: async () => ({
6995
+ data: await parseStandardSchema(schema, data, "HTTP response"),
6996
+ response
6997
+ })
6998
+ }) : succeed({
6999
+ data,
7000
+ response
7001
+ })), mapError((error) => new EffectBoundaryFailure({ cause: error.cause })));
7014
7002
  }
7015
- function fetchOnce(definition, responseType, schema) {
7003
+ function fetchOnce(definition, responseType) {
7016
7004
  return acquireUseRelease(sync(() => new AbortController()), (controller) => tryPromise({
7017
7005
  catch: (cause) => new HttpAttemptFailure({
7018
7006
  cause,
@@ -7029,7 +7017,7 @@ function fetchOnce(definition, responseType, schema) {
7029
7017
  });
7030
7018
  }
7031
7019
  }).pipe(flatMap((response) => {
7032
- if (response.ok) return decodeHttpResponse(response, responseType, schema);
7020
+ if (response.ok) return decodeHttpResponse(response, responseType, definition.maxResponseBytes, controller.signal);
7033
7021
  const cause = new HttpStatusError(response.status);
7034
7022
  return cancelResponseBody(response).pipe(andThen(fail(new HttpAttemptFailure({
7035
7023
  cause,
@@ -7039,21 +7027,20 @@ function fetchOnce(definition, responseType, schema) {
7039
7027
  }
7040
7028
  function cancelResponseBody(response) {
7041
7029
  const body = response.body;
7042
- return body ? promise(() => body.cancel().catch(() => {})) : void_;
7030
+ return body ? sync(() => {
7031
+ body.cancel().catch(() => {});
7032
+ }) : void_;
7043
7033
  }
7044
- function decodeHttpResponse(response, responseType, schema) {
7034
+ function decodeHttpResponse(response, responseType, maxResponseBytes, signal) {
7045
7035
  return tryPromise({
7046
7036
  catch: (cause) => new HttpAttemptFailure({
7047
7037
  cause,
7048
7038
  retryable: false
7049
7039
  }),
7050
- try: async () => {
7051
- const decoded = await decodeResponse(response, responseType);
7052
- return {
7053
- data: schema ? await parseStandardSchema(schema, decoded, "HTTP response") : decoded,
7054
- response
7055
- };
7056
- }
7040
+ try: async () => ({
7041
+ data: await decodeResponse(response, responseType, maxResponseBytes, signal),
7042
+ response
7043
+ })
7057
7044
  }).pipe(onInterrupt(() => cancelResponseBody(response)));
7058
7045
  }
7059
7046
  function applyCookies(headers, cookies) {
@@ -7063,8 +7050,8 @@ function applyCookies(headers, cookies) {
7063
7050
  headers.set("cookie", existing ? `${existing}; ${value}` : value);
7064
7051
  }
7065
7052
  function serializeRequestBody(body, headers) {
7066
- if (typeof body === "undefined") return void 0;
7067
- if (typeof body === "string" || body instanceof Uint8Array || body instanceof ArrayBuffer || ArrayBuffer.isView(body) || typeof Blob !== "undefined" && body instanceof Blob || typeof FormData !== "undefined" && body instanceof FormData || typeof URLSearchParams !== "undefined" && body instanceof URLSearchParams || typeof ReadableStream !== "undefined" && body instanceof ReadableStream) return body;
7053
+ if (body === void 0) return void 0;
7054
+ if (primitiveRuntimeTag(body) === "[object String]" || body instanceof Uint8Array || body instanceof ArrayBuffer || ArrayBuffer.isView(body) || body instanceof Blob || body instanceof FormData || body instanceof URLSearchParams || body instanceof ReadableStream) return body;
7068
7055
  if (!headers.has("content-type")) headers.set("content-type", "application/json");
7069
7056
  return JSON.stringify(body);
7070
7057
  }
@@ -7072,9 +7059,9 @@ function urlWithQuery(definition) {
7072
7059
  const url = new URL(definition.url);
7073
7060
  if (!definition.query) return url;
7074
7061
  for (const [key, value] of Object.entries(definition.query)) {
7075
- if (typeof value === "undefined") continue;
7062
+ if (value === void 0) continue;
7076
7063
  if (Array.isArray(value)) {
7077
- for (const item of value) if (typeof item !== "undefined") url.searchParams.append(key, queryValue(item));
7064
+ for (const item of value) if (item !== void 0) url.searchParams.append(key, queryValue(item));
7078
7065
  continue;
7079
7066
  }
7080
7067
  url.searchParams.set(key, queryValue(value));
@@ -7083,23 +7070,71 @@ function urlWithQuery(definition) {
7083
7070
  }
7084
7071
  function queryValue(value) {
7085
7072
  if (value === null) return "";
7086
- if (typeof value === "string") return value;
7087
- if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return String(value);
7073
+ const tag = primitiveRuntimeTag(value);
7074
+ if (tag === "[object String]" || tag === "[object Number]" || tag === "[object Boolean]" || tag === "[object BigInt]") return String(value);
7088
7075
  return JSON.stringify(value);
7089
7076
  }
7090
- async function decodeResponse(response, responseType) {
7091
- if (responseType === "text") return await response.text();
7092
- if (responseType === "arrayBuffer") return await response.arrayBuffer();
7093
- if (responseType === "blob") return await response.blob();
7094
- const text = await response.text();
7077
+ async function decodeResponse(response, responseType, maxResponseBytes, signal) {
7078
+ const bytes = await readResponseBytes(response, maxResponseBytes, signal);
7079
+ if (responseType === "arrayBuffer") return bytes.slice().buffer;
7080
+ if (responseType === "blob") return new Blob([bytes.slice()], { type: response.headers.get("content-type") || "" });
7081
+ const text = new TextDecoder().decode(bytes);
7082
+ if (responseType === "text") return text;
7095
7083
  return text ? JSON.parse(text) : void 0;
7096
7084
  }
7085
+ async function readResponseBytes(response, maxResponseBytes, signal) {
7086
+ const declaredLength = response.headers.get("content-length")?.trim();
7087
+ if (response.body && !response.headers.has("content-encoding") && declaredLength && /^\d+$/.test(declaredLength) && BigInt(declaredLength) > BigInt(maxResponseBytes)) {
7088
+ const error = responseSizeError(maxResponseBytes);
7089
+ response.body.cancel(error).catch(() => {});
7090
+ throw error;
7091
+ }
7092
+ const body = response.body;
7093
+ if (!body) return new Uint8Array();
7094
+ const reader = body.getReader();
7095
+ const cancelReader = () => {
7096
+ reader.cancel(signal.reason).catch(() => {});
7097
+ };
7098
+ signal.addEventListener("abort", cancelReader, { once: true });
7099
+ const chunks = [];
7100
+ let totalBytes = 0;
7101
+ try {
7102
+ while (true) {
7103
+ const chunk = await reader.read();
7104
+ if (chunk.done) break;
7105
+ totalBytes += chunk.value.byteLength;
7106
+ if (totalBytes > maxResponseBytes) {
7107
+ const error = responseSizeError(maxResponseBytes);
7108
+ reader.cancel(error).catch(() => {});
7109
+ throw error;
7110
+ }
7111
+ chunks.push(chunk.value);
7112
+ }
7113
+ } finally {
7114
+ signal.removeEventListener("abort", cancelReader);
7115
+ reader.releaseLock();
7116
+ }
7117
+ const bytes = new Uint8Array(totalBytes);
7118
+ let offset = 0;
7119
+ for (const chunk of chunks) {
7120
+ bytes.set(chunk, offset);
7121
+ offset += chunk.byteLength;
7122
+ }
7123
+ return bytes;
7124
+ }
7125
+ function responseSizeError(maxResponseBytes) {
7126
+ return /* @__PURE__ */ new RangeError(`[vitehub] HTTP response exceeds the configured ${maxResponseBytes}-byte limit.`);
7127
+ }
7097
7128
  function normalizeHttpRequest(definition) {
7098
7129
  const method = (definition.method || "GET").toUpperCase();
7099
7130
  if (method !== "GET" && method !== "HEAD" && method !== "POST") throw new TypeError(`[vitehub] HTTP request method "${method}" is not supported. Use GET, HEAD, or POST.`);
7131
+ if (definition.timeout !== void 0 && (!Number.isFinite(definition.timeout) || definition.timeout <= 0 || definition.timeout > 2147483647)) throw new TypeError("[vitehub] HTTP request timeout must be a positive finite number no greater than 2147483647.");
7132
+ if (definition.maxResponseBytes !== void 0 && (!Number.isSafeInteger(definition.maxResponseBytes) || definition.maxResponseBytes <= 0 || definition.maxResponseBytes > 26214400)) throw new TypeError(`[vitehub] HTTP request maxResponseBytes must be a positive safe integer no greater than ${maximumHttpMaxResponseBytes}.`);
7100
7133
  return {
7101
7134
  ...definition,
7135
+ maxResponseBytes: definition.maxResponseBytes ?? 5242880,
7102
7136
  method,
7137
+ timeout: definition.timeout ?? 3e4,
7103
7138
  url: definition.url instanceof URL ? definition.url : new URL(definition.url)
7104
7139
  };
7105
7140
  }
@@ -7112,7 +7147,7 @@ async function parseStandardSchema(schema, value, label) {
7112
7147
  function redactedHttpRequestSummary(definition, responseType) {
7113
7148
  return {
7114
7149
  cookies: definition.cookies && Object.keys(definition.cookies).length ? "redacted" : "none",
7115
- hasBody: typeof definition.body !== "undefined",
7150
+ hasBody: definition.body !== void 0,
7116
7151
  hasQuery: Boolean(definition.query && Object.keys(definition.query).length),
7117
7152
  headers: definition.headers && Object.keys(definition.headers).length ? "redacted" : "none",
7118
7153
  method: definition.method,
@@ -7121,8 +7156,8 @@ function redactedHttpRequestSummary(definition, responseType) {
7121
7156
  };
7122
7157
  }
7123
7158
  function formatIssues(issues) {
7124
- if (Array.isArray(issues)) return issues.map((issue) => typeof issue === "string" ? issue : JSON.stringify(issue)).join("; ");
7125
- return typeof issues === "string" ? issues : JSON.stringify(issues);
7159
+ if (Array.isArray(issues)) return issues.map((issue) => primitiveRuntimeTag(issue) === "[object String]" ? String(issue) : JSON.stringify(issue)).join("; ");
7160
+ return primitiveRuntimeTag(issues) === "[object String]" ? String(issues) : JSON.stringify(issues);
7126
7161
  }
7127
7162
  //#endregion
7128
7163
  //#region src/sources/live.ts
@@ -7201,6 +7236,7 @@ function createFetchSource(options) {
7201
7236
  },
7202
7237
  materialize: options.materialize || (options.sync ? "none" : "lazy"),
7203
7238
  mount: mountPath,
7239
+ name: "fetch",
7204
7240
  probeKeys: options.probeKeys || (key ? [key] : void 0),
7205
7241
  sync: options.sync,
7206
7242
  async getKeys() {
@@ -7250,6 +7286,7 @@ function resolvableFetchSource(resolve) {
7250
7286
  return {
7251
7287
  fingerprint: { sourceResolution: "fetch" },
7252
7288
  materialize: "lazy",
7289
+ name: "fetch",
7253
7290
  async getKeys() {
7254
7291
  return [];
7255
7292
  },
@@ -7259,9 +7296,6 @@ function resolvableFetchSource(resolve) {
7259
7296
  async getItems() {
7260
7297
  return [];
7261
7298
  },
7262
- async search() {
7263
- return [];
7264
- },
7265
7299
  async resolve(ctx) {
7266
7300
  const options = await resolve(ctx);
7267
7301
  return options ? createFetchSource(options) : false;
@@ -7334,7 +7368,7 @@ function schemaProjection(schema, option) {
7334
7368
  function concreteQueryFromOptions(options) {
7335
7369
  const parsed = options.url instanceof URL ? options.url : new URL(options.url);
7336
7370
  const query = {};
7337
- for (const key of new Set([...parsed.searchParams.keys()])) {
7371
+ for (const key of new Set(parsed.searchParams.keys())) {
7338
7372
  const values = parsed.searchParams.getAll(key);
7339
7373
  query[key] = values.length > 1 ? values : values[0];
7340
7374
  }
@@ -7364,6 +7398,7 @@ async function defaultFetchSourceRequest(options, method, ctx, overrides = {}) {
7364
7398
  ...additions?.headers
7365
7399
  },
7366
7400
  method,
7401
+ maxResponseBytes: additions?.maxResponseBytes ?? options.maxResponseBytes,
7367
7402
  query,
7368
7403
  timeout: additions?.timeout ?? options.timeout
7369
7404
  };
@@ -7433,7 +7468,7 @@ function requestBaseUrl(url) {
7433
7468
  }
7434
7469
  function queryFromUrl(url) {
7435
7470
  const query = {};
7436
- for (const key of new Set([...url.searchParams.keys()])) {
7471
+ for (const key of new Set(url.searchParams.keys())) {
7437
7472
  const values = url.searchParams.getAll(key);
7438
7473
  query[key] = values.length > 1 ? values : values[0];
7439
7474
  }
@@ -7470,6 +7505,28 @@ function redactedUrl(url) {
7470
7505
  return `${parsed.origin}${parsed.pathname}`;
7471
7506
  }
7472
7507
  //#endregion
7508
+ //#region src/sources/github-ignore.ts
7509
+ function resolveGitHubIgnore(ignore) {
7510
+ if (ignore === false) return;
7511
+ if (ignore === void 0) return [...sourceIgnores.defaults];
7512
+ const single = runtimeString(ignore);
7513
+ if (single !== void 0) return [...sourceIgnores.defaults, single];
7514
+ if (!Array.isArray(ignore)) throw invalidGitHubIgnore();
7515
+ const parsed = [];
7516
+ for (const value of ignore) {
7517
+ const item = runtimeString(value);
7518
+ if (item === void 0) throw invalidGitHubIgnore();
7519
+ parsed.push(item);
7520
+ }
7521
+ return [...sourceIgnores.defaults, ...parsed];
7522
+ }
7523
+ function runtimeString(value) {
7524
+ return Object.prototype.toString.call(value) === "[object String]" ? String(value) : void 0;
7525
+ }
7526
+ function invalidGitHubIgnore() {
7527
+ return workspaceError("[vitehub] GitHub Source ignore must be false, a string, or an array of strings.");
7528
+ }
7529
+ //#endregion
7473
7530
  //#region src/sources/mcp-resources-loader.ts
7474
7531
  let mcpResourcesSourceLoader;
7475
7532
  function registerMcpResourcesSourceLoader(loader) {
@@ -7480,6 +7537,25 @@ async function loadMcpResourcesSource(input) {
7480
7537
  return await mcpResourcesSourceLoader(input);
7481
7538
  }
7482
7539
  //#endregion
7540
+ //#region src/sources/preparation.ts
7541
+ const revisionResolutionByContext = /* @__PURE__ */ new WeakMap();
7542
+ async function prepareWorkspaceSource(source, ctx, options = {}) {
7543
+ if (options.refreshRevision) {
7544
+ revisionResolutionByContext.delete(ctx);
7545
+ ctx.revision = void 0;
7546
+ }
7547
+ let revisionResolution = revisionResolutionByContext.get(ctx);
7548
+ if (!revisionResolution) {
7549
+ revisionResolution = ctx.revision ? Promise.resolve() : (async () => {
7550
+ const revision = await source.resolveRevision?.(ctx);
7551
+ if (revision) ctx.revision = revision;
7552
+ })();
7553
+ revisionResolutionByContext.set(ctx, revisionResolution);
7554
+ }
7555
+ await revisionResolution;
7556
+ await source.prepare?.(ctx);
7557
+ }
7558
+ //#endregion
7483
7559
  //#region src/sources/config.ts
7484
7560
  function copyWorkspaceSourceMetadata(source, target) {
7485
7561
  const livePaths = getLiveWorkspaceSourcePaths(source);
@@ -7523,7 +7599,6 @@ function normalizeWorkspaceSources(sources) {
7523
7599
  }
7524
7600
  function normalizeWorkspaceSource(key, input) {
7525
7601
  const source = toWorkspaceSource(input);
7526
- if (source && typeof source === "object" && "instructions" in source) throw new TypeError(`[vitehub] Workspace source "${key}" instructions were removed. Put model-facing guidance in Agent Driver Instructions with ::source coverage.`);
7527
7602
  const mount = normalizeSourceMount(source);
7528
7603
  const cache = mount.cache ?? normalizeSourceCache(source) ?? false;
7529
7604
  const sync = normalizeSourceSync(source.sync);
@@ -7657,13 +7732,14 @@ function createInferredWorkspaceSource(family, input) {
7657
7732
  }
7658
7733
  const source = {
7659
7734
  ...inferredSourceDefaults(family, input),
7735
+ name: family,
7660
7736
  fingerprint: {
7661
7737
  inferredSource: family,
7662
- options: input
7738
+ options: inferredSourceFingerprintOptions(family, input)
7663
7739
  },
7664
7740
  async prepare(ctx) {
7665
7741
  const loaded = await loadSource();
7666
- await loaded.prepare?.(ctx);
7742
+ await prepareWorkspaceSource(loaded, ctx);
7667
7743
  copyLivePaths(livePaths, getLiveWorkspaceSourcePaths(loaded));
7668
7744
  },
7669
7745
  async getKeys(ctx) {
@@ -7674,23 +7750,40 @@ function createInferredWorkspaceSource(family, input) {
7674
7750
  },
7675
7751
  async getItems(ctx) {
7676
7752
  const source = await loadSource();
7677
- return await source.getItems?.(ctx) ?? await Promise.all((await source.getKeys(ctx)).map(async (key) => await source.getItem(key, ctx)));
7753
+ if (source.getItems) return await source.getItems(ctx);
7754
+ return await Promise.all((await source.getKeys(ctx)).map(async (key) => {
7755
+ const [item, metadata] = await Promise.all([source.getItem(key, ctx), source.getMeta?.(key, ctx)]);
7756
+ return metadata ? {
7757
+ ...item,
7758
+ metadata: {
7759
+ ...metadata,
7760
+ ...item.metadata
7761
+ }
7762
+ } : item;
7763
+ }));
7678
7764
  },
7679
7765
  async getMeta(key, ctx) {
7680
7766
  return await (await loadSource()).getMeta?.(key, ctx);
7681
7767
  },
7682
- async search(query, ctx) {
7683
- return await (await loadSource()).search?.(query, ctx) ?? [];
7768
+ async resolveRevision(ctx) {
7769
+ return await (await loadSource()).resolveRevision?.(ctx);
7684
7770
  }
7685
7771
  };
7686
7772
  return livePaths ? markLiveWorkspaceSource(source, livePaths) : source;
7687
7773
  }
7774
+ function inferredSourceFingerprintOptions(family, input) {
7775
+ if (family !== "github" || !isPlainRecord(input)) return input;
7776
+ return {
7777
+ ...input,
7778
+ ignore: resolveGitHubIgnore(input.ignore)
7779
+ };
7780
+ }
7688
7781
  async function loadInferredWorkspaceSource(family, input) {
7689
7782
  if (family === "fetch" && isPlainRecord(input)) return createInferredFetchSource(input);
7690
7783
  if (family === "fetch") return createInferredFetchSource(input);
7691
- if (family === "file") return (await import("./file-CHfsZpso.js").then((n) => n.n)).file(input);
7692
- if (family === "github") return (await import("./github-CfA5vpJ5.js").then((n) => n.n)).github(input);
7693
- if (family === "glob") return (await import("./glob-D0vD_wRY.js").then((n) => n.n)).glob(input);
7784
+ if (family === "file") return (await import("./file-Bc1X7pco.js").then((n) => n.n)).file(input);
7785
+ if (family === "github") return (await import("./github-DHnjxQIX.js").then((n) => n.n)).github(input);
7786
+ if (family === "glob") return (await import("./glob-CEZKeZFC.js").then((n) => n.n)).glob(input);
7694
7787
  return await loadMcpResourcesSource(input);
7695
7788
  }
7696
7789
  function inferredSourceDefaults(family, input) {
@@ -7808,4 +7901,4 @@ function hasOwn(input, key) {
7808
7901
  return Object.prototype.hasOwnProperty.call(input, key);
7809
7902
  }
7810
7903
  //#endregion
7811
- export { normalizeWorkspaceSources as a, sourceMountIntersectsPath as c, fetch$1 as d, getWorkspaceSourceRequestDescriptor as f, markLiveWorkspaceSource as g, workspaceSourceRequestDescriptorPath as h, normalizeWorkspaceSourceMetadata as i, workspaceSourceGrantPaths as l, isWorkspaceSourceRequestOnly as m, createSourceContext as n, normalizeWorkspaceSourcesMetadata as o, getWorkspaceSourceRequestExecutor as p, normalizeWorkspaceSource as r, sourceMountContainsPath as s, copyWorkspaceSourceMetadata as t, registerMcpResourcesSourceLoader as u };
7904
+ export { workspaceSourceRequestDescriptorPath as _, normalizeWorkspaceSources as a, sourceMountIntersectsPath as c, registerMcpResourcesSourceLoader as d, resolveGitHubIgnore as f, isWorkspaceSourceRequestOnly as g, getWorkspaceSourceRequestExecutor as h, normalizeWorkspaceSourceMetadata as i, workspaceSourceGrantPaths as l, getWorkspaceSourceRequestDescriptor as m, createSourceContext as n, normalizeWorkspaceSourcesMetadata as o, fetch$1 as p, normalizeWorkspaceSource as r, sourceMountContainsPath as s, copyWorkspaceSourceMetadata as t, prepareWorkspaceSource as u, markLiveWorkspaceSource as v };