@vite-hub/workspace 0.5.1 → 0.6.1

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.
@@ -1,4 +1,4 @@
1
- import { _ as redactInspectionText } from "./operations-CtRDU3cA.js";
1
+ import { _ as redactInspectionText } from "./operations-DS1C4uXd.js";
2
2
  import { a as workspaceConflict } from "./path-CuYE8-X6.js";
3
3
  import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B4me-ouV.js";
4
4
  import { d as normalizeHistoryPath } from "./utils-DXP9xfXo.js";
@@ -446,7 +446,7 @@ function loadNativePackageModule(id) {
446
446
  }
447
447
  function reexportNativeModule(file) {
448
448
  const url = JSON.stringify(pathToFileURL(realpathSync(file)).href);
449
- const hasDefault = /\bexport default\b|\bas default\b/.test(readFileSync(file, "utf8"));
449
+ const hasDefault = /^export\s+default\b|^export\s*\{[^}]*\bdefault\s*[,}]/m.test(readFileSync(file, "utf8"));
450
450
  const native = JSON.stringify(`data:text/javascript,${encodeURIComponent(`export * from ${url}${hasDefault ? `\nexport { default } from ${url}` : ""}`)}`);
451
451
  return `export * from ${native}\n${hasDefault ? `export { default } from ${native}\n` : ""}`;
452
452
  }
@@ -984,7 +984,7 @@ async function callOperation(target, name, input) {
984
984
  const url = new URL(operationRpcPath.slice(1), base);
985
985
  origin = url.origin;
986
986
  const env = target.roots?.length ? {} : target.env;
987
- try {
987
+ if (!target.authorization) try {
988
988
  readConsoleSigningKey(env);
989
989
  } catch (error) {
990
990
  return {
@@ -996,15 +996,18 @@ async function callOperation(target, name, input) {
996
996
  };
997
997
  }
998
998
  const outcome = await callOperationRpc(name, input ?? {}, async (body) => {
999
- const headers = await signedOperationHeaders(env, url, body);
999
+ const signal = target.signal ?? AbortSignal.timeout(target.timeout ?? 3e4);
1000
+ const headers = target.authorization ? operationHeaders() : await signedOperationHeaders(env, url, body);
1001
+ if (target.authorization) headers.set("authorization", target.authorization);
1000
1002
  if (target.confirmed !== void 0) headers.set(operationConfirmationHeader, target.confirmed ? "confirmed" : "required");
1001
1003
  if (target.roots?.length) headers.set(operationExpectedRootsHeader, target.roots.map(projectRootHash).join(","));
1004
+ signal.throwIfAborted();
1002
1005
  const response = await (target.fetch ?? fetch)(url.href, {
1003
1006
  body,
1004
1007
  headers,
1005
1008
  method: "POST",
1006
1009
  redirect: "manual",
1007
- signal: AbortSignal.timeout(target.timeout ?? 3e4)
1010
+ signal
1008
1011
  });
1009
1012
  const text = await response.text();
1010
1013
  let json;
@@ -1041,7 +1044,7 @@ async function callOperation(target, name, input) {
1041
1044
  } : void 0);
1042
1045
  if (failure) {
1043
1046
  if (target.roots?.length && failure.status === 401) failure.fix = `Pass --url ${base.href.slice(0, -1)} to send credentials. A command sends none to the dev server that it finds. ${failure.fix ?? "Set VITEHUB_CONSOLE_PRIVATE_KEY_<NAME> to a private key that `vitehub secret console-key` printed, and its public key in VITEHUB_CONSOLE_KEY_<NAME> on the app."}`;
1044
- if ((failure.status === 401 || failure.status === 403) && !hasCredentials(env) && !failure.fix) failure.fix = target.roots?.length ? `Pass --url <origin> to send deployment credentials. ${operationCredentialHint}` : operationCredentialHint;
1047
+ if ((failure.status === 401 || failure.status === 403) && !target.authorization && !hasCredentials(env) && !failure.fix) failure.fix = target.roots?.length ? `Pass --url <origin> to send deployment credentials. ${operationCredentialHint}` : operationCredentialHint;
1045
1048
  return {
1046
1049
  ok: false,
1047
1050
  ...failure
@@ -1081,7 +1084,7 @@ function table(rows) {
1081
1084
  return rows.map((row) => row.map((cell, column) => column === row.length - 1 ? cell : cell.padEnd(widths[column])).join(" ")).join("\n");
1082
1085
  }
1083
1086
  // src/operations.ts
1084
- const runtime = () => import("./operations-DfbqHWAe.js");
1087
+ const runtime = () => import("./operations-BIaK_uYG.js");
1085
1088
  const name = v.pipe(v.string(), v.check((value) => value.trim() !== "", "Name a Workspace."));
1086
1089
  const nonEmpty = (message) => v.pipe(v.string(), v.check((value) => value !== "", message));
1087
1090
  function defineWorkspaceOperation(definition, kind = "read") {
@@ -1,3 +1,3 @@
1
1
  import { t as workspaceCommitRequestBytes } from "./results-z-HpV9EP.js";
2
- import { t as workspaceOperations } from "./operations-CtRDU3cA.js";
2
+ import { t as workspaceOperations } from "./operations-DS1C4uXd.js";
3
3
  export { workspaceCommitRequestBytes, workspaceOperations };
package/dist/vite.d.ts CHANGED
@@ -320,7 +320,7 @@ interface ViteHubConsoleOperationAction {
320
320
  operation: string;
321
321
  input: Readonly<Record<string, string>>;
322
322
  /**
323
- * The result is `{ url }`, such as a one-time link or a provider sign-in: the Console opens it in a new tab, and loads
323
+ * The result is `{ url }`, such as a provider sign-in: the Console opens it in a new tab, and loads
324
324
  * the list again when the person comes back. The URL must be `https:`, or `http:` on a loopback host.
325
325
  */
326
326
  tab?: true;
package/dist/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as __exportAll$1, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-DnNXxpGL.js";
2
- import { S as resolve$1, _ as redactInspectionText, a as createNoExternalAddition, b as isAbsolute$1, c as isProductionBuild, d as resolveViteHubProjectRoot, f as shouldSkipViteProviderBuild, g as requireViteHubDevServerUrl, h as readViteHubDevTargetOption, i as createNativePackageLoading, l as isServerEnvironment, m as fetchViteHubDevEndpoint, n as callOperationFromCli, o as createViteHubEnvImportAliases, p as discoverViteHubDevServer, s as generatedViteHubWatchIgnoredAddition, t as workspaceOperations, u as publishViteHubDevServer, v as relativeDefinitionFile, x as relative$1, y as dirname$1 } from "./operations-CtRDU3cA.js";
2
+ import { S as resolve$1, _ as redactInspectionText, a as createNoExternalAddition, b as isAbsolute$1, c as isProductionBuild, d as resolveViteHubProjectRoot, f as shouldSkipViteProviderBuild, g as requireViteHubDevServerUrl, h as readViteHubDevTargetOption, i as createNativePackageLoading, l as isServerEnvironment, m as fetchViteHubDevEndpoint, n as callOperationFromCli, o as createViteHubEnvImportAliases, p as discoverViteHubDevServer, s as generatedViteHubWatchIgnoredAddition, t as workspaceOperations, u as publishViteHubDevServer, v as relativeDefinitionFile, x as relative$1, y as dirname$1 } from "./operations-DS1C4uXd.js";
3
3
  import { t as internalErrorDiagnostics } from "./error-diagnostics-kKXseq8d.js";
4
4
  import { n as isRecordOrFunction, t as isRecord$1 } from "./object-CAK6UYR5.js";
5
5
  import { a as refreshWorkspaceDevToken, c as workspaceDevHeader, d as workspaceDevTokenHeader, f as workspaceDevTokenServerId, n as ensureWorkspaceDevToken, o as runWorkspaceDevCommand, p as isViteHubSecretEqual, r as readWorkspaceDevToken, s as validateWorkspaceDevToken, u as workspaceDevRoute } from "./server-aa1a4rkV.js";
@@ -269,7 +269,11 @@ const encodedAliasExactMarker = "\0vitehub-exact:";
269
269
  /** Select the runtime constants from one resolved Vite configuration. */
270
270
  function resolveViteHubBundleDefines(config) {
271
271
  const defines = {};
272
- for (const name of ["__VITEHUB_PUBLIC_URL__", "__VITEHUB_APP_BASE_URL__"]) {
272
+ for (const name of [
273
+ "__VITEHUB_PUBLIC_URL__",
274
+ "__VITEHUB_APP_BASE_URL__",
275
+ "__VITEHUB_CONSOLE_URL__"
276
+ ]) {
273
277
  const value = config.define?.[name];
274
278
  if (typeof value === "string") defines[name] = value;
275
279
  }
@@ -664,20 +668,20 @@ function createFileUrlPlugin() {
664
668
  }
665
669
  };
666
670
  }
667
- /**
668
- * Copies a `.wasm?module` import next to the bundle and keeps it as a relative `.wasm` import. Wrangler and Nitro load
669
- * such an import as a compiled WebAssembly module, which Workers need because they can't compile WebAssembly bytes.
670
- * Node.js compiles WebAssembly bytes, so there the import becomes the bytes of the file.
671
- */
672
671
  function createWasmModulePlugin(outdir, workingDir, copy) {
673
672
  return {
674
673
  name: "vitehub-wasm-module",
675
674
  async resolveId(source, importer, extra) {
676
- if (!source.endsWith(".wasm?module")) return;
677
- const resolved = await this.resolve(source.slice(0, -7), importerFor(importer, workingDir), {
675
+ const explicitModule = source.endsWith(".wasm?module");
676
+ if (!explicitModule && (!copy || !source.endsWith(".wasm") || extra.custom?.[skipMarkdownTemplateResolve])) return;
677
+ const path = explicitModule ? source.slice(0, -7) : source;
678
+ const resolved = await this.resolve(path, importerFor(importer, workingDir), {
678
679
  custom: extra.custom,
679
- kind: extra.kind
680
+ isEntry: extra.isEntry,
681
+ kind: extra.kind,
682
+ skipSelf: true
680
683
  });
684
+ if (!explicitModule && (!isFileResolution(resolved) || !resolved.id.endsWith(".wasm"))) return resolved ?? void 0;
681
685
  if (!isFileResolution(resolved)) this.error(`[vitehub] Could not resolve ${JSON.stringify(source)}.`);
682
686
  if (!copy) return resolved.id;
683
687
  const bytes = await readFile(resolved.id);
@@ -20939,7 +20943,8 @@ function mergeNitroWorkspaceConfig(value, root, dev) {
20939
20943
  }
20940
20944
  kit.addHandler({
20941
20945
  handler: ownModule(import.meta.url, "runtime/request"),
20942
- middleware: true
20946
+ middleware: true,
20947
+ route: "/**"
20943
20948
  }, "start");
20944
20949
  return kit.config;
20945
20950
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-hub/workspace",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
4
  "description": "Agent-oriented filesystem state and Vite integration for ViteHub.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -150,8 +150,8 @@
150
150
  "dependencies": {
151
151
  "@valibot/to-json-schema": "^1.8.0",
152
152
  "@vercel/nft": "^1.11.12",
153
- "@vite-hub/runtime": "0.5.1",
154
- "@vite-hub/source": "0.5.1",
153
+ "@vite-hub/runtime": "0.6.1",
154
+ "@vite-hub/source": "0.6.1",
155
155
  "birpc": "^4.2.0",
156
156
  "defu": "^6.1.7",
157
157
  "exsolve": "^1.2.0",
@@ -162,18 +162,18 @@
162
162
  "nostics": "1.4.0",
163
163
  "valibot": "^1.5.0",
164
164
  "yaml": "^2.9.1",
165
- "@vite-hub/markdown-template": "0.5.1",
166
- "@vite-hub/blob": "0.5.1",
167
- "@vite-hub/database": "0.5.1",
168
- "@vite-hub/sandbox": "0.5.1"
165
+ "@vite-hub/markdown-template": "0.6.1",
166
+ "@vite-hub/blob": "0.6.1",
167
+ "@vite-hub/database": "0.6.1",
168
+ "@vite-hub/sandbox": "0.6.1"
169
169
  },
170
170
  "devDependencies": {
171
171
  "@types/node": "^24.19.2",
172
172
  "@vercel/blob": "^2.9.0",
173
- "@vite-hub/env": "0.5.1",
174
- "@vite-hub/forge": "0.5.1",
173
+ "@vite-hub/env": "0.6.1",
174
+ "@vite-hub/forge": "0.6.1",
175
175
  "@vite-hub/internal": "0.0.1",
176
- "@vite-hub/shell": "0.5.1",
176
+ "@vite-hub/shell": "0.6.1",
177
177
  "ai": "7.0.179",
178
178
  "esbuild": "^0.28.2",
179
179
  "publint": "^0.3.25",
@@ -186,11 +186,11 @@
186
186
  "@libsql/client": "^0.18.0"
187
187
  },
188
188
  "peerDependencies": {
189
- "@vite-hub/shell": "0.5.1",
189
+ "@vite-hub/shell": "0.6.1",
190
190
  "ai": "^6.0.0 || ^7.0.0-0",
191
191
  "vite": ">=8.0.0",
192
192
  "drizzle-orm": "1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0",
193
- "@vite-hub/forge": "0.5.1"
193
+ "@vite-hub/forge": "0.6.1"
194
194
  },
195
195
  "peerDependenciesMeta": {
196
196
  "@vite-hub/shell": {