@seclai/react 0.0.19 → 0.0.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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +36 -34
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -285,7 +285,7 @@ The stylesheet adds these variables for media: `--seclai-media-aspect-ratio` (a
285
285
 
286
286
  ### Audio, video and PDFs
287
287
 
288
- - **Seeking doesn't work yet, and Safari may not play video.** The previews stream through the `download` handler, and the Seclai API doesn't answer HTTP `Range` requests for run attachments yet ([seclai/seclai#2556](https://github.com/seclai/seclai/issues/2556)), nor can `@seclai/sdk` send them ([seclai/seclai-javascript#21](https://github.com/seclai/seclai-javascript/issues/21)). So audio and video play from the start but can't skip ahead, and Safari, which wants `206 Partial Content` for video, may refuse to play it at all. The download link still works. The handler will forward `Range` once both land.
288
+ - **Seeking doesn't work yet, and Safari may not play video.** The previews stream through the `download` handler, and the Seclai API doesn't answer HTTP `Range` requests for run attachments yet, nor can `@seclai/sdk` send them ([seclai/seclai-javascript#21](https://github.com/seclai/seclai-javascript/issues/21)). So audio and video play from the start but can't skip ahead, and Safari, which wants `206 Partial Content` for video, may refuse to play it at all. The download link still works. The handler will forward `Range` once both land.
289
289
  - **Your Content Security Policy** must let the page load media and objects from the handler's URL: if you set `media-src` or `object-src` (or `default-src`), they need `'self'`, or wherever you mount the handler. `object-src 'none'`, a common recommendation, stops PDFs from showing, as do `frame-ancestors 'none'` and `X-Frame-Options: DENY` on the handler's responses (`SAMEORIGIN` is fine). The handler's own `sandbox` policy on the files it serves doesn't stop `<audio>` and `<video>` from playing them: a response's policy only applies when it's opened as a page.
290
290
 
291
291
  ### Saving files
package/dist/index.js CHANGED
@@ -33,15 +33,15 @@ function createEndpoints({
33
33
  agentId
34
34
  } = {}) {
35
35
  const trimmed = basePath.replace(/\/+$/, "");
36
- const base2 = agentId ? `${trimmed}/${encodeURIComponent(agentId)}` : trimmed;
36
+ const base = agentId ? `${trimmed}/${encodeURIComponent(agentId)}` : trimmed;
37
37
  return {
38
- attachmentReferences: `${base2}/attachment-references`,
39
- upload: `${base2}/upload`,
40
- run: `${base2}/run`,
38
+ attachmentReferences: `${base}/attachment-references`,
39
+ upload: `${base}/upload`,
40
+ run: `${base}/run`,
41
41
  download(runId, attachmentId, name) {
42
42
  const params = new URLSearchParams({ runId, attachmentId });
43
43
  if (name) params.set("name", name);
44
- return `${base2}/download?${params}`;
44
+ return `${base}/download?${params}`;
45
45
  }
46
46
  };
47
47
  }
@@ -70,10 +70,10 @@ function withQuery(url, params) {
70
70
  const query = new URLSearchParams(params).toString();
71
71
  if (!query) return url;
72
72
  const hashAt = url.indexOf("#");
73
- const base2 = hashAt < 0 ? url : url.slice(0, hashAt);
73
+ const base = hashAt < 0 ? url : url.slice(0, hashAt);
74
74
  const hash = hashAt < 0 ? "" : url.slice(hashAt);
75
- const separator = !base2.includes("?") ? "?" : base2.endsWith("?") || base2.endsWith("&") ? "" : "&";
76
- return `${base2}${separator}${query}${hash}`;
75
+ const separator = !base.includes("?") ? "?" : base.endsWith("?") || base.endsWith("&") ? "" : "&";
76
+ return `${base}${separator}${query}${hash}`;
77
77
  }
78
78
 
79
79
  // src/attachments.ts
@@ -190,7 +190,7 @@ function splitPoints(tree, source, rawHtml = true) {
190
190
  // src/markdown/extensions.tsx
191
191
  import { createContext, useContext } from "react";
192
192
  import { jsx } from "react/jsx-runtime";
193
- var ExtensionsContext = createContext([]);
193
+ var ExtensionsContext = /* @__PURE__ */ createContext([]);
194
194
  function SeclaiMarkdownProvider({ extensions, children }) {
195
195
  return /* @__PURE__ */ jsx(ExtensionsContext.Provider, { value: extensions, children });
196
196
  }
@@ -342,25 +342,26 @@ var svgAttributes = {
342
342
  feComposite: ["in", "in2", "operator", "k1", "k2", "k3", "k4", "result"]
343
343
  };
344
344
  var DROPPED = /* @__PURE__ */ new Set(["accessKey", "tabIndex"]);
345
- var base = defaultSchema.attributes ?? {};
346
- var sanitizeSchema = {
347
- ...defaultSchema,
348
- tagNames: [...defaultSchema.tagNames ?? [], ...SVG_TAGS],
349
- attributes: {
350
- ...base,
351
- "*": (base["*"] ?? []).filter((attribute) => typeof attribute !== "string" || !DROPPED.has(attribute)),
352
- ...Object.fromEntries(SVG_TAGS.map((tag) => [tag, [...SVG_COMMON, ...svgAttributes[tag] ?? []]]))
353
- },
354
- protocols: {
355
- ...defaultSchema.protocols,
356
- href: ["http", "https", "mailto"],
357
- src: ["http", "https"]
358
- },
359
- // Dropped with their content. Other disallowed elements, such as `form`, are
360
- // unwrapped and their content kept.
361
- strip: ["script", "style", "foreignObject", "iframe", "noscript", "template"]
362
- };
363
- var CLOBBER_PREFIX = defaultSchema.clobberPrefix ?? "user-content-";
345
+ var sanitizeSchema = /* @__PURE__ */ (() => {
346
+ const base = defaultSchema.attributes ?? {};
347
+ return {
348
+ ...defaultSchema,
349
+ tagNames: [...defaultSchema.tagNames ?? [], ...SVG_TAGS],
350
+ attributes: {
351
+ ...base,
352
+ "*": (base["*"] ?? []).filter((attribute) => typeof attribute !== "string" || !DROPPED.has(attribute)),
353
+ ...Object.fromEntries(SVG_TAGS.map((tag) => [tag, [...SVG_COMMON, ...svgAttributes[tag] ?? []]]))
354
+ },
355
+ protocols: {
356
+ ...defaultSchema.protocols,
357
+ href: ["http", "https", "mailto"],
358
+ src: ["http", "https"]
359
+ },
360
+ // Dropped with their content. Other disallowed elements, such as `form`, are
361
+ // unwrapped and their content kept.
362
+ strip: ["script", "style", "foreignObject", "iframe", "noscript", "template"]
363
+ };
364
+ })();
364
365
  var isElement = (node) => node.type === "element";
365
366
  function walk(node, visit, inSvg = false) {
366
367
  for (const child of node.children) {
@@ -372,6 +373,7 @@ function walk(node, visit, inSvg = false) {
372
373
  }
373
374
  var URL_REFERENCE = /url\(\s*(['"]?)([^)'"]*)\1\s*\)/gi;
374
375
  function rehypeSafeReferences() {
376
+ const prefix = defaultSchema.clobberPrefix ?? "user-content-";
375
377
  return (tree) => {
376
378
  walk(tree, (element, _parent, inSvg) => {
377
379
  const { properties } = element;
@@ -380,7 +382,7 @@ function rehypeSafeReferences() {
380
382
  if (typeof value !== "string") continue;
381
383
  if (key === "href" || key === "xLinkHref") {
382
384
  if (value.startsWith("#")) {
383
- properties[key] = `#${CLOBBER_PREFIX}${value.slice(1)}`;
385
+ properties[key] = `#${prefix}${value.slice(1)}`;
384
386
  } else if (inSvg && element.tagName !== "a") {
385
387
  delete properties[key];
386
388
  }
@@ -390,7 +392,7 @@ function rehypeSafeReferences() {
390
392
  let external2 = false;
391
393
  const rewritten = value.replace(URL_REFERENCE, (_, _quote, target) => {
392
394
  if (!target.startsWith("#")) external2 = true;
393
- return `url(#${CLOBBER_PREFIX}${target.slice(1)})`;
395
+ return `url(#${prefix}${target.slice(1)})`;
394
396
  });
395
397
  if (external2 || /url\(/i.test(rewritten.replace(URL_REFERENCE, ""))) delete properties[key];
396
398
  else properties[key] = rewritten;
@@ -486,7 +488,7 @@ function pipelineFor(extensions) {
486
488
  function remarkOnTree(onTree) {
487
489
  return (tree, file) => onTree(tree, String(file.value));
488
490
  }
489
- var Block = memo(
491
+ var Block = /* @__PURE__ */ memo(
490
492
  function Block2({ text, pipeline, onTree }) {
491
493
  return /* @__PURE__ */ jsx2(
492
494
  Markdown,
@@ -531,7 +533,7 @@ var Splitter = class {
531
533
  return { starts, onTree };
532
534
  }
533
535
  };
534
- var MarkdownContent = memo(function MarkdownContent2({
536
+ var MarkdownContent = /* @__PURE__ */ memo(function MarkdownContent2({
535
537
  content,
536
538
  streaming = false,
537
539
  extensions
@@ -597,8 +599,8 @@ function extensionForMime(mime) {
597
599
  }
598
600
  function attachmentFileName(attachment, number) {
599
601
  if (attachment.name) return attachment.name;
600
- const base2 = number != null ? `${mediaKind(attachment) ?? "file"}-${number}` : attachment.id;
601
- return `${base2}.${extensionForMime(attachment.mime)}`;
602
+ const base = number != null ? `${mediaKind(attachment) ?? "file"}-${number}` : attachment.id;
603
+ return `${base}.${extensionForMime(attachment.mime)}`;
602
604
  }
603
605
  var SAFE_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "blob:"]);
604
606
  function isSafeUrl(url) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seclai/react",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "React components and hooks for running Seclai agents: run form, chat, and streaming output.",
5
5
  "license": "MIT",
6
6
  "type": "module",