@selvajs/selva 4.21.0-beta.19 → 4.21.0-beta.21

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 (43) hide show
  1. package/build/adapter-node.js +1 -1
  2. package/build/client/_app/immutable/chunks/C36Kxzt3.js +1 -0
  3. package/build/client/_app/immutable/chunks/C36Kxzt3.js.br +1 -0
  4. package/build/client/_app/immutable/chunks/C36Kxzt3.js.gz +0 -0
  5. package/build/client/_app/immutable/chunks/{D2C9ht__.js → C6zhj8Tc.js} +59 -59
  6. package/build/client/_app/immutable/chunks/C6zhj8Tc.js.br +0 -0
  7. package/build/client/_app/immutable/chunks/C6zhj8Tc.js.gz +0 -0
  8. package/build/client/_app/immutable/entry/{app.D3YN7-nC.js → app.C2KpbBu3.js} +2 -2
  9. package/build/client/_app/immutable/entry/app.C2KpbBu3.js.br +0 -0
  10. package/build/client/_app/immutable/entry/app.C2KpbBu3.js.gz +0 -0
  11. package/build/client/_app/immutable/nodes/21.C3YDbmsU.js +1 -0
  12. package/build/client/_app/immutable/nodes/21.C3YDbmsU.js.br +0 -0
  13. package/build/client/_app/immutable/nodes/21.C3YDbmsU.js.gz +0 -0
  14. package/build/client/_app/version.json +1 -1
  15. package/build/client/_app/version.json.br +0 -0
  16. package/build/client/_app/version.json.gz +0 -0
  17. package/build/server/chunks/capture.js +1 -1
  18. package/build/server/chunks/instance.js +3 -3
  19. package/build/server/chunks/internal.js +1 -1
  20. package/build/server/chunks/package.js +1 -1
  21. package/build/server/chunks/package.js.map +1 -1
  22. package/build/server/chunks/schema.js +1 -1
  23. package/build/server/chunks/schema.js.map +1 -1
  24. package/build/server/chunks/solve.js +1 -1
  25. package/build/server/entries/endpoints/mcp/_server.ts.js +71 -28
  26. package/build/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
  27. package/build/server/entries/pages/library/_guid_/_page.svelte.js +3 -1
  28. package/build/server/entries/pages/library/_guid_/_page.svelte.js.map +1 -1
  29. package/build/server/manifest-full.js +1 -1
  30. package/build/server/manifest.js +1 -1
  31. package/build/server/nodes/21.js +1 -1
  32. package/build/server/server.js +1 -1
  33. package/package.json +6 -6
  34. package/build/client/_app/immutable/chunks/D2C9ht__.js.br +0 -0
  35. package/build/client/_app/immutable/chunks/D2C9ht__.js.gz +0 -0
  36. package/build/client/_app/immutable/chunks/DIMAEw3m.js +0 -1
  37. package/build/client/_app/immutable/chunks/DIMAEw3m.js.br +0 -1
  38. package/build/client/_app/immutable/chunks/DIMAEw3m.js.gz +0 -0
  39. package/build/client/_app/immutable/entry/app.D3YN7-nC.js.br +0 -0
  40. package/build/client/_app/immutable/entry/app.D3YN7-nC.js.gz +0 -0
  41. package/build/client/_app/immutable/nodes/21.BA-9DMG6.js +0 -1
  42. package/build/client/_app/immutable/nodes/21.BA-9DMG6.js.br +0 -0
  43. package/build/client/_app/immutable/nodes/21.BA-9DMG6.js.gz +0 -0
@@ -21179,14 +21179,20 @@ async function capture(response, options) {
21179
21179
  });
21180
21180
  await page.setContent(html, { waitUntil: "load" });
21181
21181
  const hdr = options.hdr ? await options.hdr() : void 0;
21182
- return await page.evaluate((req) => globalThis.selvaCapture(req), {
21182
+ const { pngs, drawn } = await page.evaluate((req) => globalThis.selvaCapture(req), {
21183
21183
  response,
21184
- view: options.view ?? "iso",
21184
+ views: options.views?.length ? options.views : [options.view ?? "default"],
21185
21185
  grid: options.grid ?? true,
21186
21186
  look: options.look,
21187
21187
  background: options.background,
21188
+ camera: options.camera,
21188
21189
  hdr
21189
21190
  });
21191
+ return {
21192
+ png: pngs[0] ?? "",
21193
+ pngs,
21194
+ drawn
21195
+ };
21190
21196
  } finally {
21191
21197
  options.signal?.removeEventListener("abort", closePage);
21192
21198
  await page.close().catch(() => {});
@@ -21913,6 +21919,7 @@ async function readCover(api, guid, signal) {
21913
21919
  };
21914
21920
  }
21915
21921
  var CAPTURE_VIEWS = [
21922
+ "default",
21916
21923
  "iso",
21917
21924
  "top",
21918
21925
  "front",
@@ -21921,6 +21928,16 @@ var CAPTURE_VIEWS = [
21921
21928
  "right",
21922
21929
  "bottom"
21923
21930
  ];
21931
+ var PREVIEW_LOOKS = [
21932
+ "technical",
21933
+ "studio",
21934
+ "showcase",
21935
+ "arctic",
21936
+ "xray",
21937
+ "lineart",
21938
+ "wireframe",
21939
+ "night"
21940
+ ];
21924
21941
  var DEFAULT_BACKGROUND = "#E6E6E6";
21925
21942
  var ListOutput = z.object({
21926
21943
  items: z.array(z.record(z.string(), z.unknown())),
@@ -21932,6 +21949,8 @@ var SolveOutput = z.object({
21932
21949
  errors: z.array(z.string()),
21933
21950
  warnings: z.array(z.string()),
21934
21951
  link: z.string(),
21952
+ /** For selva_capture_preview, which renders it without solving again. */
21953
+ solveId: z.string().optional(),
21935
21954
  response: z.unknown().optional()
21936
21955
  });
21937
21956
  var PublishOutput = z.object({
@@ -22196,18 +22215,25 @@ function selvaTools(origin, options) {
22196
22215
  link: pageOf(guid),
22197
22216
  stash
22198
22217
  });
22218
+ const solveId = await stash.put({
22219
+ kind: "solve",
22220
+ name: schema.name,
22221
+ contentType: "application/json",
22222
+ data: jsonBytes(res)
22223
+ });
22224
+ const text = `${summary.text}\nSolve id ${solveId}: selva_capture_preview draws it without solving again, for an hour.`;
22225
+ const structured = {
22226
+ ...summary.structured,
22227
+ solveId
22228
+ };
22199
22229
  const meta = apps ? { [SOLVE_VIEW_KEY]: {
22200
22230
  title: schema.name,
22201
22231
  look: schema.viewerOptions?.look,
22202
22232
  background: schema.viewerOptions?.backgroundColor ?? DEFAULT_BACKGROUND,
22233
+ camera: schema.viewerOptions?.camera,
22203
22234
  load: {
22204
22235
  tool: "selva_solve_geometry",
22205
- arguments: { token: await stash.put({
22206
- kind: "solve",
22207
- name: schema.name,
22208
- contentType: "application/json",
22209
- data: jsonBytes(res)
22210
- }) }
22236
+ arguments: { token: solveId }
22211
22237
  },
22212
22238
  form: {
22213
22239
  tool: "selva_solve",
@@ -22220,7 +22246,8 @@ function selvaTools(origin, options) {
22220
22246
  }
22221
22247
  } } : void 0;
22222
22248
  if (detail !== "full") return {
22223
- ...summary,
22249
+ text,
22250
+ structured,
22224
22251
  meta
22225
22252
  };
22226
22253
  const response = {
@@ -22228,9 +22255,9 @@ function selvaTools(origin, options) {
22228
22255
  values: res.values?.filter((t) => !isPlumbing(t))
22229
22256
  };
22230
22257
  return {
22231
- ...summary,
22258
+ text,
22232
22259
  structured: {
22233
- ...summary.structured,
22260
+ ...structured,
22234
22261
  response
22235
22262
  },
22236
22263
  meta
@@ -22259,50 +22286,66 @@ function selvaTools(origin, options) {
22259
22286
  tool({
22260
22287
  name: "selva_capture_preview",
22261
22288
  title: "Render a preview",
22262
- description: "Solves a definition and draws the result in Selva's own 3D viewer, with the look and background the definition opens in, then returns the picture. Spends compute like selva_solve. The picture is kept for an hour under a preview id: pass it to selva_set_cover_image to make it the cover.",
22289
+ description: "Draws a solve in Selva's own 3D viewer and returns a picture per view, with the look and background the definition opens in unless `look` says otherwise. Pass `solve`, the solve id selva_solve returned, to draw that result without solving again; otherwise it solves `values` first and spends compute like selva_solve. Extra views cost no compute. Each picture is kept for an hour under a preview id: pass one to selva_set_cover_image to make it the cover.",
22263
22290
  input: z.object({
22264
22291
  definition: definitionArg,
22292
+ solve: z.string().optional().describe("A solve id from selva_solve. When given, `values` is ignored."),
22265
22293
  values: valuesArg,
22266
22294
  version: versionArg,
22267
- view: z.enum(CAPTURE_VIEWS).default("iso").describe("Camera direction."),
22295
+ views: z.array(z.enum(CAPTURE_VIEWS)).min(1).max(4).default(["default"]).describe("Camera directions, a picture each. `default` is the view the definition opens in, or iso when it saves none."),
22296
+ look: z.enum(PREVIEW_LOOKS).optional().describe("The viewer look. Default: the definition's own. `night` lights lamps."),
22268
22297
  width: z.number().int().min(256).max(2048).default(1200),
22269
22298
  height: z.number().int().min(256).max(2048).default(800),
22270
22299
  grid: z.boolean().default(false).describe("Draw the viewer's ground grid.")
22271
22300
  }),
22272
22301
  calls: SOLVE_CALLS,
22273
- async run(api, { definition, values, version, view, width, height, grid }, { signal }) {
22274
- const { schema, res } = await runSolve(api, definition, values, version, signal);
22302
+ async run(api, args, { signal }) {
22303
+ const { definition, solve, values, version, views, look, width, height, grid } = args;
22304
+ let schema;
22305
+ let res;
22306
+ if (solve) {
22307
+ const guid = await resolveDefinition(api, definition, signal);
22308
+ const held = await stash.get(solve, "solve");
22309
+ if (!held) throw new Error("That solve id has expired or is unknown. Leave `solve` out to solve `values` again.");
22310
+ ({schema} = await schemaFor(api, guid, version, signal));
22311
+ res = fromJsonBytes(held.data);
22312
+ } else ({schema, res} = await runSolve(api, definition, values, version, signal));
22275
22313
  let capture;
22276
22314
  try {
22277
22315
  capture = await captureSolve(res, {
22278
- view,
22316
+ views,
22279
22317
  width,
22280
22318
  height,
22281
22319
  grid,
22282
- look: schema.viewerOptions?.look,
22320
+ look: look ?? schema.viewerOptions?.look,
22283
22321
  background: schema.viewerOptions?.backgroundColor ?? DEFAULT_BACKGROUND,
22322
+ camera: schema.viewerOptions?.camera,
22284
22323
  hdr: captureHdr,
22285
22324
  html: captureHtml,
22286
22325
  executablePath: options.previewBrowser || void 0,
22287
22326
  signal
22288
22327
  });
22289
22328
  } catch (err) {
22290
- if (err instanceof CaptureUnavailableError) throw new Error(`${err.message} An operator sets this up; the solve itself worked.`, { cause: err });
22329
+ if (err instanceof CaptureUnavailableError) throw new Error(`${err.message} An operator sets this up. The solve itself worked: selva_solve still returns its numbers.`, { cause: err });
22291
22330
  throw err;
22292
22331
  }
22293
22332
  if (!capture.drawn) return `${schema.name} solved, but drew nothing: it has no Display output with geometry for these values.`;
22294
- const previewId = await stash.put({
22295
- kind: "preview",
22296
- name: `${schema.name}.png`,
22297
- contentType: "image/png",
22298
- data: new Uint8Array(Buffer.from(capture.png, "base64"))
22299
- });
22333
+ const lines = [`${schema.name}, ${width}×${height}${look ? `, ${look} look` : ""}.`];
22334
+ for (const [i, png] of capture.pngs.entries()) {
22335
+ const previewId = await stash.put({
22336
+ kind: "preview",
22337
+ name: `${schema.name}.png`,
22338
+ contentType: "image/png",
22339
+ data: new Uint8Array(Buffer.from(png, "base64"))
22340
+ });
22341
+ lines.push(`${views[i]} view: preview id ${previewId}.`);
22342
+ }
22300
22343
  return {
22301
- text: `${schema.name}, ${view} view, ${width}×${height}. Preview id ${previewId}.`,
22302
- images: [{
22303
- data: capture.png,
22344
+ text: lines.join("\n"),
22345
+ images: capture.pngs.map((data) => ({
22346
+ data,
22304
22347
  mimeType: "image/png"
22305
- }]
22348
+ }))
22306
22349
  };
22307
22350
  }
22308
22351
  }),