@valbuild/server 0.113.0 → 0.114.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.
@@ -372,13 +372,6 @@ export declare abstract class ValOps {
372
372
  } | {
373
373
  errorType: "patch-head-conflict";
374
374
  }>>;
375
- abstract getCommitSummary(preparedCommit: PreparedCommit): Promise<{
376
- commitSummary: string | null;
377
- error?: undefined;
378
- } | {
379
- commitSummary?: undefined;
380
- error: GenericErrorMessage;
381
- }>;
382
375
  abstract onInit(baseSha: BaseSha, schemaSha: SchemaSha): Promise<void>;
383
376
  abstract fetchPatches<ExcludePatchOps extends boolean>(filters: {
384
377
  patchIds?: PatchId[];
@@ -43,13 +43,6 @@ export declare class ValOpsFS extends ValOps {
43
43
  statusCode: 401 | 500;
44
44
  error: GenericErrorMessage;
45
45
  }>;
46
- getCommitSummary(): Promise<{
47
- commitSummary: string | null;
48
- error?: undefined;
49
- } | {
50
- commitSummary?: undefined;
51
- error: GenericErrorMessage;
52
- }>;
53
46
  getStat(params: {
54
47
  baseSha: BaseSha;
55
48
  schemaSha: SchemaSha;
@@ -46,13 +46,6 @@ export declare class ValOpsHttp extends ValOps {
46
46
  statusCode: 401 | 500;
47
47
  error: GenericErrorMessage;
48
48
  }>;
49
- getCommitSummary(preparedCommit: PreparedCommit): Promise<{
50
- commitSummary: string | null;
51
- error?: undefined;
52
- } | {
53
- commitSummary?: undefined;
54
- error: GenericErrorMessage;
55
- }>;
56
49
  getStat(params: {
57
50
  baseSha: BaseSha;
58
51
  schemaSha: SchemaSha;
@@ -127,12 +120,6 @@ export declare class ValOpsHttp extends ValOps {
127
120
  errors?: undefined;
128
121
  deleted?: undefined;
129
122
  }>;
130
- getCommitMessage(preparedCommit: PreparedCommit): Promise<{
131
- commitSummary: string;
132
- error?: undefined;
133
- } | {
134
- error: GenericErrorMessage;
135
- }>;
136
123
  commit(prepared: PreparedCommit, message: string, committer: AuthorId, filesDirectory: string, newBranch?: string): Promise<{
137
124
  isNotFastForward?: boolean;
138
125
  updatedFiles: string[];
@@ -5,4 +5,4 @@ import { ValidationError } from "@valbuild/core";
5
5
  * There is no schema in hand here — a `ValidationError` carries only the value
6
6
  * it flagged — so the shape is all there is to go on.
7
7
  */
8
- export declare function getValidationErrorFileRef(validationError: ValidationError): string | null;
8
+ export declare function getValidationErrorFileRef(validationError: ValidationError): any;
@@ -1,4 +1,4 @@
1
- import { ModuleFilePath, PatchId } from "@valbuild/core";
1
+ import { PatchId } from "@valbuild/core";
2
2
  import { z } from "zod";
3
3
  import type { AuthorId, BaseSha } from "./ValOps.js";
4
4
  import { PatchLogEntry, PatchLogProblem } from "./patchLog.js";
@@ -32,14 +32,14 @@ export declare const FSPatch: z.ZodObject<{
32
32
  patch: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
33
33
  op: z.ZodLiteral<"add">;
34
34
  path: z.ZodArray<z.ZodString>;
35
- value: z.ZodType<import("@valbuild/core/patch").JSONValue, unknown, z.core.$ZodTypeInternals<import("@valbuild/core/patch").JSONValue, unknown>>;
35
+ value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
36
36
  }, z.core.$strict>, z.ZodObject<{
37
37
  op: z.ZodLiteral<"remove">;
38
38
  path: z.ZodTuple<[z.ZodString], z.ZodString>;
39
39
  }, z.core.$strict>, z.ZodObject<{
40
40
  op: z.ZodLiteral<"replace">;
41
41
  path: z.ZodArray<z.ZodString>;
42
- value: z.ZodType<import("@valbuild/core/patch").JSONValue, unknown, z.core.$ZodTypeInternals<import("@valbuild/core/patch").JSONValue, unknown>>;
42
+ value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
43
43
  }, z.core.$strict>, z.ZodObject<{
44
44
  op: z.ZodLiteral<"move">;
45
45
  from: z.ZodTuple<[z.ZodString], z.ZodString>;
@@ -51,15 +51,15 @@ export declare const FSPatch: z.ZodObject<{
51
51
  }, z.core.$strict>, z.ZodObject<{
52
52
  op: z.ZodLiteral<"test">;
53
53
  path: z.ZodArray<z.ZodString>;
54
- value: z.ZodType<import("@valbuild/core/patch").JSONValue, unknown, z.core.$ZodTypeInternals<import("@valbuild/core/patch").JSONValue, unknown>>;
54
+ value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
55
55
  }, z.core.$strict>, z.ZodObject<{
56
56
  op: z.ZodLiteral<"file">;
57
57
  path: z.ZodArray<z.ZodString>;
58
58
  filePath: z.ZodString;
59
- value: z.ZodType<import("@valbuild/core/patch").JSONValue, unknown, z.core.$ZodTypeInternals<import("@valbuild/core/patch").JSONValue, unknown>>;
59
+ value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
60
60
  remote: z.ZodBoolean;
61
61
  nestedFilePath: z.ZodOptional<z.ZodArray<z.ZodString>>;
62
- metadata: z.ZodOptional<z.ZodType<import("@valbuild/core/patch").JSONValue, unknown, z.core.$ZodTypeInternals<import("@valbuild/core/patch").JSONValue, unknown>>>;
62
+ metadata: z.ZodOptional<z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>>;
63
63
  }, z.core.$strict>], "op">>;
64
64
  patchId: z.ZodString;
65
65
  baseSha: z.ZodString & z.ZodType<BaseSha, string, z.core.$ZodTypeInternals<BaseSha, string>>;
@@ -5352,13 +5352,6 @@ class ValOpsFS extends ValOps {
5352
5352
  };
5353
5353
  }
5354
5354
  }
5355
- async getCommitSummary() {
5356
- return {
5357
- error: {
5358
- message: "Val is in development / local mode. Cannot generate summary"
5359
- }
5360
- };
5361
- }
5362
5355
  async getStat(params) {
5363
5356
  // In ValOpsFS, we don't have a websocket server to listen to file changes so we use long-polling.
5364
5357
  // If a file that Val depends on changes, we break the connection and tell the client to request again to get the latest values.
@@ -6536,9 +6529,6 @@ const MetadataRes = z.z.object({
6536
6529
  metadata: Metadata,
6537
6530
  type: z.z.union([z.z.literal("file"), z.z.literal("image")]).nullable()
6538
6531
  });
6539
- const SummaryResponse = z.z.object({
6540
- commitSummary: z.z.string()
6541
- });
6542
6532
  const GetApplicablePatches = z.z.object({
6543
6533
  patches: z.z.array(z.z.object({
6544
6534
  path: z.z.string(),
@@ -6725,69 +6715,6 @@ class ValOpsHttp extends ValOps {
6725
6715
  };
6726
6716
  }
6727
6717
  }
6728
- async getCommitSummary(preparedCommit) {
6729
- try {
6730
- var _res$headers$get2;
6731
- const res = await fetch(`${this.contentUrl}/v1/${this.project}/commit-summary`, {
6732
- method: "POST",
6733
- headers: {
6734
- ...this.authHeaders,
6735
- "Content-Type": "application/json"
6736
- },
6737
- body: JSON.stringify({
6738
- patchedSourceFiles: preparedCommit.patchedSourceFiles,
6739
- previousSourceFiles: preparedCommit.previousSourceFiles
6740
- })
6741
- });
6742
- if (res.ok) {
6743
- const json = await res.json();
6744
- const parsed = SummaryResponse.safeParse(json);
6745
- if (parsed.success) {
6746
- return {
6747
- commitSummary: parsed.data.commitSummary
6748
- };
6749
- }
6750
- console.error(`Could not parse summary response. Error: ${zodValidationError.fromError(parsed.error).toString()}`);
6751
- return {
6752
- error: {
6753
- message: `Cannot get the summary of your changes. An error has been logged. Possible cause: the current version of Val might be too old. Please try again later or contact the developers on your team.`
6754
- }
6755
- };
6756
- }
6757
- if (res.status === 401) {
6758
- console.error("Unauthorized to get summary");
6759
- return {
6760
- error: {
6761
- message: "Could not get summary. Although your user is authorized, the application has authorization issues. Contact the developers on your team and ask them to verify the api keys."
6762
- }
6763
- };
6764
- }
6765
- const unknownErrorMessage = `Could not get summary. HTTP error: ${res.status} ${res.statusText}`;
6766
- if ((_res$headers$get2 = res.headers.get("Content-Type")) !== null && _res$headers$get2 !== void 0 && _res$headers$get2.includes("application/json")) {
6767
- const json = await res.json();
6768
- const message = internal.getErrorMessageFromUnknownJson(json, unknownErrorMessage);
6769
- console.error("Summary error:", message);
6770
- return {
6771
- error: {
6772
- message
6773
- }
6774
- };
6775
- }
6776
- console.error(unknownErrorMessage);
6777
- return {
6778
- error: {
6779
- message: unknownErrorMessage
6780
- }
6781
- };
6782
- } catch (e) {
6783
- console.error("Could not get summary (connection error?):", e);
6784
- return {
6785
- error: {
6786
- message: `Could not get summary. Error: ${e instanceof Error ? e.message : JSON.stringify(e)}`
6787
- }
6788
- };
6789
- }
6790
- }
6791
6718
  async getStat(params) {
6792
6719
  if (!(params !== null && params !== void 0 && params.profileId)) {
6793
6720
  return {
@@ -7115,7 +7042,7 @@ class ValOpsHttp extends ValOps {
7115
7042
  coreVersion: core.Internal.VERSION.core
7116
7043
  })
7117
7044
  }).then(async res => {
7118
- var _res$headers$get3;
7045
+ var _res$headers$get2;
7119
7046
  if (res.ok) {
7120
7047
  const parsed = SavePatchResponse.safeParse(await res.json());
7121
7048
  if (parsed.success) {
@@ -7134,7 +7061,7 @@ class ValOpsHttp extends ValOps {
7134
7061
  message: "Conflict: " + (await res.text())
7135
7062
  });
7136
7063
  }
7137
- if ((_res$headers$get3 = res.headers.get("Content-Type")) !== null && _res$headers$get3 !== void 0 && _res$headers$get3.includes("application/json")) {
7064
+ if ((_res$headers$get2 = res.headers.get("Content-Type")) !== null && _res$headers$get2 !== void 0 && _res$headers$get2.includes("application/json")) {
7138
7065
  const json = await res.json();
7139
7066
  const message = internal.getErrorMessageFromUnknownJson(json, "Unknown error");
7140
7067
  return fp.result.err({
@@ -7417,51 +7344,9 @@ class ValOpsHttp extends ValOps {
7417
7344
  };
7418
7345
  });
7419
7346
  }
7420
- async getCommitMessage(preparedCommit) {
7421
- var _res$headers$get4;
7422
- const res = await fetch(`${this.contentUrl}/v1/${this.project}/commit-summary`, {
7423
- method: "POST",
7424
- headers: {
7425
- ...this.authHeaders,
7426
- "Content-Type": "application/json"
7427
- },
7428
- body: JSON.stringify({
7429
- patchedSourceFiles: preparedCommit.patchedSourceFiles,
7430
- previousSourceFiles: preparedCommit.previousSourceFiles
7431
- })
7432
- });
7433
- if (res.ok) {
7434
- const json = await res.json();
7435
- const parsed = SummaryResponse.safeParse(json);
7436
- if (parsed.success) {
7437
- return {
7438
- commitSummary: parsed.data.commitSummary
7439
- };
7440
- }
7441
- return {
7442
- error: {
7443
- message: `Could not parse commit summary response. Error: ${zodValidationError.fromError(parsed.error)}`
7444
- }
7445
- };
7446
- }
7447
- if ((_res$headers$get4 = res.headers.get("Content-Type")) !== null && _res$headers$get4 !== void 0 && _res$headers$get4.includes("application/json")) {
7448
- const json = await res.json();
7449
- const message = internal.getErrorMessageFromUnknownJson(json, "Unknown error");
7450
- return {
7451
- error: {
7452
- message
7453
- }
7454
- };
7455
- }
7456
- return {
7457
- error: {
7458
- message: "Could not get commit message. HTTP error: " + res.status + " " + res.statusText
7459
- }
7460
- };
7461
- }
7462
7347
  async commit(prepared, message, committer, filesDirectory, newBranch) {
7463
7348
  try {
7464
- var _res$headers$get5;
7349
+ var _res$headers$get3;
7465
7350
  const existingBranch = this.branch;
7466
7351
  const res = await fetch(`${this.contentUrl}/v1/${this.project}/commit`, {
7467
7352
  method: "POST",
@@ -7498,7 +7383,7 @@ class ValOpsHttp extends ValOps {
7498
7383
  }
7499
7384
  };
7500
7385
  }
7501
- if ((_res$headers$get5 = res.headers.get("Content-Type")) !== null && _res$headers$get5 !== void 0 && _res$headers$get5.includes("application/json")) {
7386
+ if ((_res$headers$get3 = res.headers.get("Content-Type")) !== null && _res$headers$get3 !== void 0 && _res$headers$get3.includes("application/json")) {
7502
7387
  const json = z.z.object({
7503
7388
  isNotFastForward: z.z.boolean().optional()
7504
7389
  }).safeParse(await res.json());
@@ -9151,49 +9036,6 @@ const ValServer = (valModules, options, callbacks) => {
9151
9036
  });
9152
9037
  }
9153
9038
  },
9154
- "/commit-summary": {
9155
- GET: async req => {
9156
- const cookies = req.cookies;
9157
- const auth = getAuth(cookies);
9158
- if (auth.error) {
9159
- return {
9160
- status: 401,
9161
- json: {
9162
- message: auth.error
9163
- }
9164
- };
9165
- }
9166
- const query = req.query;
9167
- const patchIds = query.patch_id;
9168
- const patches = await serverOps.fetchPatches({
9169
- patchIds,
9170
- excludePatchOps: false
9171
- });
9172
- const analysis = serverOps.analyzePatches(patches.patches, patches.commits, commit);
9173
- const preparedCommit = await serverOps.prepare({
9174
- ...analysis,
9175
- ...patches
9176
- });
9177
- const res = await serverOps.getCommitSummary(preparedCommit);
9178
- if (res.error) {
9179
- console.error("Failed to summarize", res.error);
9180
- return {
9181
- status: 400,
9182
- json: {
9183
- message: res.error.message
9184
- }
9185
- };
9186
- }
9187
- return {
9188
- status: 200,
9189
- json: {
9190
- baseSha: await serverOps.getBaseSha(),
9191
- patchIds,
9192
- commitSummary: res.commitSummary
9193
- }
9194
- };
9195
- }
9196
- },
9197
9039
  "/save": {
9198
9040
  POST: async req => {
9199
9041
  const cookies = req.cookies;
@@ -9476,11 +9318,18 @@ const ValServer = (valModules, options, callbacks) => {
9476
9318
  }
9477
9319
  const json = await upstreamRes.json();
9478
9320
  const wsUrl = options.valContentUrl.replace(/^https:/, "wss:").replace(/^http:/, "ws:") + `/v1/${options.project}/ai/connect`;
9321
+ // Forwarded as-is, minus anything that is not a string: which
9322
+ // providers are reachable is the content server's to decide, and
9323
+ // this only has to carry the answer without editorialising.
9324
+ const providers = Array.isArray(json.providers) ? json.providers.filter(provider => typeof provider === "string") : undefined;
9479
9325
  return {
9480
9326
  status: 200,
9481
9327
  json: {
9482
9328
  nonce: json.nonce,
9483
- wsUrl
9329
+ wsUrl,
9330
+ ...(providers ? {
9331
+ providers
9332
+ } : {})
9484
9333
  }
9485
9334
  };
9486
9335
  } catch (err) {
@@ -5352,13 +5352,6 @@ class ValOpsFS extends ValOps {
5352
5352
  };
5353
5353
  }
5354
5354
  }
5355
- async getCommitSummary() {
5356
- return {
5357
- error: {
5358
- message: "Val is in development / local mode. Cannot generate summary"
5359
- }
5360
- };
5361
- }
5362
5355
  async getStat(params) {
5363
5356
  // In ValOpsFS, we don't have a websocket server to listen to file changes so we use long-polling.
5364
5357
  // If a file that Val depends on changes, we break the connection and tell the client to request again to get the latest values.
@@ -6536,9 +6529,6 @@ const MetadataRes = z.z.object({
6536
6529
  metadata: Metadata,
6537
6530
  type: z.z.union([z.z.literal("file"), z.z.literal("image")]).nullable()
6538
6531
  });
6539
- const SummaryResponse = z.z.object({
6540
- commitSummary: z.z.string()
6541
- });
6542
6532
  const GetApplicablePatches = z.z.object({
6543
6533
  patches: z.z.array(z.z.object({
6544
6534
  path: z.z.string(),
@@ -6725,69 +6715,6 @@ class ValOpsHttp extends ValOps {
6725
6715
  };
6726
6716
  }
6727
6717
  }
6728
- async getCommitSummary(preparedCommit) {
6729
- try {
6730
- var _res$headers$get2;
6731
- const res = await fetch(`${this.contentUrl}/v1/${this.project}/commit-summary`, {
6732
- method: "POST",
6733
- headers: {
6734
- ...this.authHeaders,
6735
- "Content-Type": "application/json"
6736
- },
6737
- body: JSON.stringify({
6738
- patchedSourceFiles: preparedCommit.patchedSourceFiles,
6739
- previousSourceFiles: preparedCommit.previousSourceFiles
6740
- })
6741
- });
6742
- if (res.ok) {
6743
- const json = await res.json();
6744
- const parsed = SummaryResponse.safeParse(json);
6745
- if (parsed.success) {
6746
- return {
6747
- commitSummary: parsed.data.commitSummary
6748
- };
6749
- }
6750
- console.error(`Could not parse summary response. Error: ${zodValidationError.fromError(parsed.error).toString()}`);
6751
- return {
6752
- error: {
6753
- message: `Cannot get the summary of your changes. An error has been logged. Possible cause: the current version of Val might be too old. Please try again later or contact the developers on your team.`
6754
- }
6755
- };
6756
- }
6757
- if (res.status === 401) {
6758
- console.error("Unauthorized to get summary");
6759
- return {
6760
- error: {
6761
- message: "Could not get summary. Although your user is authorized, the application has authorization issues. Contact the developers on your team and ask them to verify the api keys."
6762
- }
6763
- };
6764
- }
6765
- const unknownErrorMessage = `Could not get summary. HTTP error: ${res.status} ${res.statusText}`;
6766
- if ((_res$headers$get2 = res.headers.get("Content-Type")) !== null && _res$headers$get2 !== void 0 && _res$headers$get2.includes("application/json")) {
6767
- const json = await res.json();
6768
- const message = internal.getErrorMessageFromUnknownJson(json, unknownErrorMessage);
6769
- console.error("Summary error:", message);
6770
- return {
6771
- error: {
6772
- message
6773
- }
6774
- };
6775
- }
6776
- console.error(unknownErrorMessage);
6777
- return {
6778
- error: {
6779
- message: unknownErrorMessage
6780
- }
6781
- };
6782
- } catch (e) {
6783
- console.error("Could not get summary (connection error?):", e);
6784
- return {
6785
- error: {
6786
- message: `Could not get summary. Error: ${e instanceof Error ? e.message : JSON.stringify(e)}`
6787
- }
6788
- };
6789
- }
6790
- }
6791
6718
  async getStat(params) {
6792
6719
  if (!(params !== null && params !== void 0 && params.profileId)) {
6793
6720
  return {
@@ -7115,7 +7042,7 @@ class ValOpsHttp extends ValOps {
7115
7042
  coreVersion: core.Internal.VERSION.core
7116
7043
  })
7117
7044
  }).then(async res => {
7118
- var _res$headers$get3;
7045
+ var _res$headers$get2;
7119
7046
  if (res.ok) {
7120
7047
  const parsed = SavePatchResponse.safeParse(await res.json());
7121
7048
  if (parsed.success) {
@@ -7134,7 +7061,7 @@ class ValOpsHttp extends ValOps {
7134
7061
  message: "Conflict: " + (await res.text())
7135
7062
  });
7136
7063
  }
7137
- if ((_res$headers$get3 = res.headers.get("Content-Type")) !== null && _res$headers$get3 !== void 0 && _res$headers$get3.includes("application/json")) {
7064
+ if ((_res$headers$get2 = res.headers.get("Content-Type")) !== null && _res$headers$get2 !== void 0 && _res$headers$get2.includes("application/json")) {
7138
7065
  const json = await res.json();
7139
7066
  const message = internal.getErrorMessageFromUnknownJson(json, "Unknown error");
7140
7067
  return fp.result.err({
@@ -7417,51 +7344,9 @@ class ValOpsHttp extends ValOps {
7417
7344
  };
7418
7345
  });
7419
7346
  }
7420
- async getCommitMessage(preparedCommit) {
7421
- var _res$headers$get4;
7422
- const res = await fetch(`${this.contentUrl}/v1/${this.project}/commit-summary`, {
7423
- method: "POST",
7424
- headers: {
7425
- ...this.authHeaders,
7426
- "Content-Type": "application/json"
7427
- },
7428
- body: JSON.stringify({
7429
- patchedSourceFiles: preparedCommit.patchedSourceFiles,
7430
- previousSourceFiles: preparedCommit.previousSourceFiles
7431
- })
7432
- });
7433
- if (res.ok) {
7434
- const json = await res.json();
7435
- const parsed = SummaryResponse.safeParse(json);
7436
- if (parsed.success) {
7437
- return {
7438
- commitSummary: parsed.data.commitSummary
7439
- };
7440
- }
7441
- return {
7442
- error: {
7443
- message: `Could not parse commit summary response. Error: ${zodValidationError.fromError(parsed.error)}`
7444
- }
7445
- };
7446
- }
7447
- if ((_res$headers$get4 = res.headers.get("Content-Type")) !== null && _res$headers$get4 !== void 0 && _res$headers$get4.includes("application/json")) {
7448
- const json = await res.json();
7449
- const message = internal.getErrorMessageFromUnknownJson(json, "Unknown error");
7450
- return {
7451
- error: {
7452
- message
7453
- }
7454
- };
7455
- }
7456
- return {
7457
- error: {
7458
- message: "Could not get commit message. HTTP error: " + res.status + " " + res.statusText
7459
- }
7460
- };
7461
- }
7462
7347
  async commit(prepared, message, committer, filesDirectory, newBranch) {
7463
7348
  try {
7464
- var _res$headers$get5;
7349
+ var _res$headers$get3;
7465
7350
  const existingBranch = this.branch;
7466
7351
  const res = await fetch(`${this.contentUrl}/v1/${this.project}/commit`, {
7467
7352
  method: "POST",
@@ -7498,7 +7383,7 @@ class ValOpsHttp extends ValOps {
7498
7383
  }
7499
7384
  };
7500
7385
  }
7501
- if ((_res$headers$get5 = res.headers.get("Content-Type")) !== null && _res$headers$get5 !== void 0 && _res$headers$get5.includes("application/json")) {
7386
+ if ((_res$headers$get3 = res.headers.get("Content-Type")) !== null && _res$headers$get3 !== void 0 && _res$headers$get3.includes("application/json")) {
7502
7387
  const json = z.z.object({
7503
7388
  isNotFastForward: z.z.boolean().optional()
7504
7389
  }).safeParse(await res.json());
@@ -9151,49 +9036,6 @@ const ValServer = (valModules, options, callbacks) => {
9151
9036
  });
9152
9037
  }
9153
9038
  },
9154
- "/commit-summary": {
9155
- GET: async req => {
9156
- const cookies = req.cookies;
9157
- const auth = getAuth(cookies);
9158
- if (auth.error) {
9159
- return {
9160
- status: 401,
9161
- json: {
9162
- message: auth.error
9163
- }
9164
- };
9165
- }
9166
- const query = req.query;
9167
- const patchIds = query.patch_id;
9168
- const patches = await serverOps.fetchPatches({
9169
- patchIds,
9170
- excludePatchOps: false
9171
- });
9172
- const analysis = serverOps.analyzePatches(patches.patches, patches.commits, commit);
9173
- const preparedCommit = await serverOps.prepare({
9174
- ...analysis,
9175
- ...patches
9176
- });
9177
- const res = await serverOps.getCommitSummary(preparedCommit);
9178
- if (res.error) {
9179
- console.error("Failed to summarize", res.error);
9180
- return {
9181
- status: 400,
9182
- json: {
9183
- message: res.error.message
9184
- }
9185
- };
9186
- }
9187
- return {
9188
- status: 200,
9189
- json: {
9190
- baseSha: await serverOps.getBaseSha(),
9191
- patchIds,
9192
- commitSummary: res.commitSummary
9193
- }
9194
- };
9195
- }
9196
- },
9197
9039
  "/save": {
9198
9040
  POST: async req => {
9199
9041
  const cookies = req.cookies;
@@ -9476,11 +9318,18 @@ const ValServer = (valModules, options, callbacks) => {
9476
9318
  }
9477
9319
  const json = await upstreamRes.json();
9478
9320
  const wsUrl = options.valContentUrl.replace(/^https:/, "wss:").replace(/^http:/, "ws:") + `/v1/${options.project}/ai/connect`;
9321
+ // Forwarded as-is, minus anything that is not a string: which
9322
+ // providers are reachable is the content server's to decide, and
9323
+ // this only has to carry the answer without editorialising.
9324
+ const providers = Array.isArray(json.providers) ? json.providers.filter(provider => typeof provider === "string") : undefined;
9479
9325
  return {
9480
9326
  status: 200,
9481
9327
  json: {
9482
9328
  nonce: json.nonce,
9483
- wsUrl
9329
+ wsUrl,
9330
+ ...(providers ? {
9331
+ providers
9332
+ } : {})
9484
9333
  }
9485
9334
  };
9486
9335
  } catch (err) {
@@ -5318,13 +5318,6 @@ class ValOpsFS extends ValOps {
5318
5318
  };
5319
5319
  }
5320
5320
  }
5321
- async getCommitSummary() {
5322
- return {
5323
- error: {
5324
- message: "Val is in development / local mode. Cannot generate summary"
5325
- }
5326
- };
5327
- }
5328
5321
  async getStat(params) {
5329
5322
  // In ValOpsFS, we don't have a websocket server to listen to file changes so we use long-polling.
5330
5323
  // If a file that Val depends on changes, we break the connection and tell the client to request again to get the latest values.
@@ -6502,9 +6495,6 @@ const MetadataRes = z.object({
6502
6495
  metadata: Metadata,
6503
6496
  type: z.union([z.literal("file"), z.literal("image")]).nullable()
6504
6497
  });
6505
- const SummaryResponse = z.object({
6506
- commitSummary: z.string()
6507
- });
6508
6498
  const GetApplicablePatches = z.object({
6509
6499
  patches: z.array(z.object({
6510
6500
  path: z.string(),
@@ -6691,69 +6681,6 @@ class ValOpsHttp extends ValOps {
6691
6681
  };
6692
6682
  }
6693
6683
  }
6694
- async getCommitSummary(preparedCommit) {
6695
- try {
6696
- var _res$headers$get2;
6697
- const res = await fetch(`${this.contentUrl}/v1/${this.project}/commit-summary`, {
6698
- method: "POST",
6699
- headers: {
6700
- ...this.authHeaders,
6701
- "Content-Type": "application/json"
6702
- },
6703
- body: JSON.stringify({
6704
- patchedSourceFiles: preparedCommit.patchedSourceFiles,
6705
- previousSourceFiles: preparedCommit.previousSourceFiles
6706
- })
6707
- });
6708
- if (res.ok) {
6709
- const json = await res.json();
6710
- const parsed = SummaryResponse.safeParse(json);
6711
- if (parsed.success) {
6712
- return {
6713
- commitSummary: parsed.data.commitSummary
6714
- };
6715
- }
6716
- console.error(`Could not parse summary response. Error: ${fromError(parsed.error).toString()}`);
6717
- return {
6718
- error: {
6719
- message: `Cannot get the summary of your changes. An error has been logged. Possible cause: the current version of Val might be too old. Please try again later or contact the developers on your team.`
6720
- }
6721
- };
6722
- }
6723
- if (res.status === 401) {
6724
- console.error("Unauthorized to get summary");
6725
- return {
6726
- error: {
6727
- message: "Could not get summary. Although your user is authorized, the application has authorization issues. Contact the developers on your team and ask them to verify the api keys."
6728
- }
6729
- };
6730
- }
6731
- const unknownErrorMessage = `Could not get summary. HTTP error: ${res.status} ${res.statusText}`;
6732
- if ((_res$headers$get2 = res.headers.get("Content-Type")) !== null && _res$headers$get2 !== void 0 && _res$headers$get2.includes("application/json")) {
6733
- const json = await res.json();
6734
- const message = getErrorMessageFromUnknownJson(json, unknownErrorMessage);
6735
- console.error("Summary error:", message);
6736
- return {
6737
- error: {
6738
- message
6739
- }
6740
- };
6741
- }
6742
- console.error(unknownErrorMessage);
6743
- return {
6744
- error: {
6745
- message: unknownErrorMessage
6746
- }
6747
- };
6748
- } catch (e) {
6749
- console.error("Could not get summary (connection error?):", e);
6750
- return {
6751
- error: {
6752
- message: `Could not get summary. Error: ${e instanceof Error ? e.message : JSON.stringify(e)}`
6753
- }
6754
- };
6755
- }
6756
- }
6757
6684
  async getStat(params) {
6758
6685
  if (!(params !== null && params !== void 0 && params.profileId)) {
6759
6686
  return {
@@ -7081,7 +7008,7 @@ class ValOpsHttp extends ValOps {
7081
7008
  coreVersion: Internal.VERSION.core
7082
7009
  })
7083
7010
  }).then(async res => {
7084
- var _res$headers$get3;
7011
+ var _res$headers$get2;
7085
7012
  if (res.ok) {
7086
7013
  const parsed = SavePatchResponse.safeParse(await res.json());
7087
7014
  if (parsed.success) {
@@ -7100,7 +7027,7 @@ class ValOpsHttp extends ValOps {
7100
7027
  message: "Conflict: " + (await res.text())
7101
7028
  });
7102
7029
  }
7103
- if ((_res$headers$get3 = res.headers.get("Content-Type")) !== null && _res$headers$get3 !== void 0 && _res$headers$get3.includes("application/json")) {
7030
+ if ((_res$headers$get2 = res.headers.get("Content-Type")) !== null && _res$headers$get2 !== void 0 && _res$headers$get2.includes("application/json")) {
7104
7031
  const json = await res.json();
7105
7032
  const message = getErrorMessageFromUnknownJson(json, "Unknown error");
7106
7033
  return result.err({
@@ -7383,51 +7310,9 @@ class ValOpsHttp extends ValOps {
7383
7310
  };
7384
7311
  });
7385
7312
  }
7386
- async getCommitMessage(preparedCommit) {
7387
- var _res$headers$get4;
7388
- const res = await fetch(`${this.contentUrl}/v1/${this.project}/commit-summary`, {
7389
- method: "POST",
7390
- headers: {
7391
- ...this.authHeaders,
7392
- "Content-Type": "application/json"
7393
- },
7394
- body: JSON.stringify({
7395
- patchedSourceFiles: preparedCommit.patchedSourceFiles,
7396
- previousSourceFiles: preparedCommit.previousSourceFiles
7397
- })
7398
- });
7399
- if (res.ok) {
7400
- const json = await res.json();
7401
- const parsed = SummaryResponse.safeParse(json);
7402
- if (parsed.success) {
7403
- return {
7404
- commitSummary: parsed.data.commitSummary
7405
- };
7406
- }
7407
- return {
7408
- error: {
7409
- message: `Could not parse commit summary response. Error: ${fromError(parsed.error)}`
7410
- }
7411
- };
7412
- }
7413
- if ((_res$headers$get4 = res.headers.get("Content-Type")) !== null && _res$headers$get4 !== void 0 && _res$headers$get4.includes("application/json")) {
7414
- const json = await res.json();
7415
- const message = getErrorMessageFromUnknownJson(json, "Unknown error");
7416
- return {
7417
- error: {
7418
- message
7419
- }
7420
- };
7421
- }
7422
- return {
7423
- error: {
7424
- message: "Could not get commit message. HTTP error: " + res.status + " " + res.statusText
7425
- }
7426
- };
7427
- }
7428
7313
  async commit(prepared, message, committer, filesDirectory, newBranch) {
7429
7314
  try {
7430
- var _res$headers$get5;
7315
+ var _res$headers$get3;
7431
7316
  const existingBranch = this.branch;
7432
7317
  const res = await fetch(`${this.contentUrl}/v1/${this.project}/commit`, {
7433
7318
  method: "POST",
@@ -7464,7 +7349,7 @@ class ValOpsHttp extends ValOps {
7464
7349
  }
7465
7350
  };
7466
7351
  }
7467
- if ((_res$headers$get5 = res.headers.get("Content-Type")) !== null && _res$headers$get5 !== void 0 && _res$headers$get5.includes("application/json")) {
7352
+ if ((_res$headers$get3 = res.headers.get("Content-Type")) !== null && _res$headers$get3 !== void 0 && _res$headers$get3.includes("application/json")) {
7468
7353
  const json = z.object({
7469
7354
  isNotFastForward: z.boolean().optional()
7470
7355
  }).safeParse(await res.json());
@@ -9117,49 +9002,6 @@ const ValServer = (valModules, options, callbacks) => {
9117
9002
  });
9118
9003
  }
9119
9004
  },
9120
- "/commit-summary": {
9121
- GET: async req => {
9122
- const cookies = req.cookies;
9123
- const auth = getAuth(cookies);
9124
- if (auth.error) {
9125
- return {
9126
- status: 401,
9127
- json: {
9128
- message: auth.error
9129
- }
9130
- };
9131
- }
9132
- const query = req.query;
9133
- const patchIds = query.patch_id;
9134
- const patches = await serverOps.fetchPatches({
9135
- patchIds,
9136
- excludePatchOps: false
9137
- });
9138
- const analysis = serverOps.analyzePatches(patches.patches, patches.commits, commit);
9139
- const preparedCommit = await serverOps.prepare({
9140
- ...analysis,
9141
- ...patches
9142
- });
9143
- const res = await serverOps.getCommitSummary(preparedCommit);
9144
- if (res.error) {
9145
- console.error("Failed to summarize", res.error);
9146
- return {
9147
- status: 400,
9148
- json: {
9149
- message: res.error.message
9150
- }
9151
- };
9152
- }
9153
- return {
9154
- status: 200,
9155
- json: {
9156
- baseSha: await serverOps.getBaseSha(),
9157
- patchIds,
9158
- commitSummary: res.commitSummary
9159
- }
9160
- };
9161
- }
9162
- },
9163
9005
  "/save": {
9164
9006
  POST: async req => {
9165
9007
  const cookies = req.cookies;
@@ -9442,11 +9284,18 @@ const ValServer = (valModules, options, callbacks) => {
9442
9284
  }
9443
9285
  const json = await upstreamRes.json();
9444
9286
  const wsUrl = options.valContentUrl.replace(/^https:/, "wss:").replace(/^http:/, "ws:") + `/v1/${options.project}/ai/connect`;
9287
+ // Forwarded as-is, minus anything that is not a string: which
9288
+ // providers are reachable is the content server's to decide, and
9289
+ // this only has to carry the answer without editorialising.
9290
+ const providers = Array.isArray(json.providers) ? json.providers.filter(provider => typeof provider === "string") : undefined;
9445
9291
  return {
9446
9292
  status: 200,
9447
9293
  json: {
9448
9294
  nonce: json.nonce,
9449
- wsUrl
9295
+ wsUrl,
9296
+ ...(providers ? {
9297
+ providers
9298
+ } : {})
9450
9299
  }
9451
9300
  };
9452
9301
  } catch (err) {
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "./package.json": "./package.json"
17
17
  },
18
18
  "types": "dist/valbuild-server.cjs.d.ts",
19
- "version": "0.113.0",
19
+ "version": "0.114.0",
20
20
  "devDependencies": {
21
21
  "@prettier/sync": "^0.6.1",
22
22
  "@types/jest": "^30.0.0"
@@ -29,9 +29,9 @@
29
29
  "typescript": "^6.0.3",
30
30
  "zod": "^4.4.3",
31
31
  "zod-validation-error": "^5.0.0",
32
- "@valbuild/shared": "0.113.0",
33
- "@valbuild/ui": "0.113.0",
34
- "@valbuild/core": "0.111.0"
32
+ "@valbuild/core": "0.111.0",
33
+ "@valbuild/shared": "0.114.0",
34
+ "@valbuild/ui": "0.114.0"
35
35
  },
36
36
  "engines": {
37
37
  "node": "^20.19.0 || >=22"