@agent-native/core 0.157.10 → 0.157.11

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.
@@ -194,6 +194,29 @@ interface ParsedCssBorder {
194
194
  color: string;
195
195
  }
196
196
 
197
+ /**
198
+ * PowerPoint's `a:spcPct val="100000"` is 100% of the font's *natural* line
199
+ * height, which CSS renders as `line-height: 1.2`, so the importer multiplies a
200
+ * declared percentage by that ratio. Writing the CSS value back out as `lnSpc`
201
+ * unchanged applied that correction a second time, and every imported paragraph
202
+ * came back 20% looser than the source. Neither copy of the constant is
203
+ * exported — `SINGLE_LINE_SPACING_RATIO` in packages/core/src/ingestion/pptx.ts
204
+ * and `DEFAULT_LINE_SPACING` in server/handlers/import/html-converter.ts — so
205
+ * all three have to move together.
206
+ */
207
+ const SINGLE_LINE_SPACING_RATIO = 1.2;
208
+
209
+ /** A CSS line-height ratio as the single-spacing multiple `lnSpc` measures. */
210
+ function cssLineHeightToSpacingMultiple(
211
+ lineHeight: number | undefined,
212
+ ): number | undefined {
213
+ return lineHeight !== undefined &&
214
+ Number.isFinite(lineHeight) &&
215
+ lineHeight > 0
216
+ ? lineHeight / SINGLE_LINE_SPACING_RATIO
217
+ : undefined;
218
+ }
219
+
197
220
  /** Parse a CSS `border` shorthand. `none`/`hidden` borders yield `undefined`. */
198
221
  function parseCssBorder(
199
222
  border: string | null | undefined,
@@ -320,6 +343,8 @@ interface ShapeElement {
320
343
  lineTransparency?: number; // 0-100, percent transparent
321
344
  lineWidth?: number; // in pt
322
345
  lineDashType?: NonNullable<PptxGenJS.ShapeLineProps["dashType"]>;
346
+ lineHeadType?: NonNullable<PptxGenJS.ShapeLineProps["beginArrowType"]>;
347
+ lineTailType?: NonNullable<PptxGenJS.ShapeLineProps["endArrowType"]>;
323
348
  /** A PowerPoint preset geometry name, or `custGeom` when `points` carry a traced outline. */
324
349
  shapeType?: string;
325
350
  rectRadius?: number; // inches; roundRect corner radius
@@ -591,6 +616,8 @@ export function parseSlideHtml(
591
616
  w: contentW,
592
617
  h: elHeight + 0.2,
593
618
  letterSpacing: letterSpacing ? parseFloat(letterSpacing) : undefined,
619
+ // Editor-authored HTML already uses the multiple pptxgenjs expects;
620
+ // the importer-only correction belongs in parseImportedSlideHtml.
594
621
  lineSpacingMultiple: lineH,
595
622
  });
596
623
 
@@ -748,6 +775,7 @@ function parseImportedSlideHtml(html: string, dims: SlideDims): ParsedSlide {
748
775
  const border = parseCssBorder(getStyle(style, "border"));
749
776
  const parsedLine = border ? colorToHex(border.color) : undefined;
750
777
  const outline = importedFreeformStroke(innerHtml, dims);
778
+ const line = importedLineStroke(style, innerHtml, dims);
751
779
  shapes.push({
752
780
  ...geometry,
753
781
  ...(parsedFill
@@ -770,6 +798,9 @@ function parseImportedSlideHtml(html: string, dims: SlideDims): ParsedSlide {
770
798
  }
771
799
  : {}),
772
800
  ...importedShapeGeometry(attrs, style, outline?.path, geometry, dims),
801
+ // A single-edge border is the importer's own verdict that this box is a
802
+ // line rather than an outline, so it settles the geometry too.
803
+ ...line,
773
804
  ...(rotate != null ? { rotate } : {}),
774
805
  order: match.index,
775
806
  });
@@ -818,7 +849,9 @@ function parseImportedSlideHtml(html: string, dims: SlideDims): ParsedSlide {
818
849
  bold: runs.length > 0 && runs.every((run) => run.options.bold === true),
819
850
  align:
820
851
  alignValue === "center" || alignValue === "right" ? alignValue : "left",
821
- lineSpacingMultiple: lineHeight ? Number(lineHeight) : undefined,
852
+ lineSpacingMultiple: cssLineHeightToSpacingMultiple(
853
+ lineHeight ? Number(lineHeight) : undefined,
854
+ ),
822
855
  x: geometry.x,
823
856
  y: geometry.y,
824
857
  w: geometry.w,
@@ -998,6 +1031,88 @@ function importedFreeformStroke(
998
1031
  };
999
1032
  }
1000
1033
 
1034
+ /** The line axis each single-edge border the importer writes draws along. */
1035
+ const SINGLE_EDGE_BORDER_AXES = {
1036
+ "border-top": "x",
1037
+ "border-left": "y",
1038
+ } as const;
1039
+
1040
+ /**
1041
+ * The stroke of a `<p:cxnSp>` or a degenerate `<p:sp>` — a box with one
1042
+ * dimension of zero. The importer draws those with a single `border-left` or
1043
+ * `border-top` rather than the `border` shorthand (`strokeDecoration` in
1044
+ * server/handlers/import/html-converter.ts), which `parseCssBorder` above
1045
+ * cannot see, so every connector used to export as a `rect` of `cx="0"` with
1046
+ * `<a:noFill/>` and an empty `<a:ln/>`: no width, no color, no ends, nothing
1047
+ * drawn. Reading the edge the importer actually wrote gives back the real line.
1048
+ */
1049
+ function importedLineStroke(
1050
+ style: string,
1051
+ innerHtml: string,
1052
+ dims: SlideDims,
1053
+ ):
1054
+ | Pick<
1055
+ ShapeElement,
1056
+ | "shapeType"
1057
+ | "lineColor"
1058
+ | "lineTransparency"
1059
+ | "lineWidth"
1060
+ | "lineDashType"
1061
+ | "lineHeadType"
1062
+ | "lineTailType"
1063
+ >
1064
+ | undefined {
1065
+ for (const [property, axis] of Object.entries(SINGLE_EDGE_BORDER_AXES)) {
1066
+ const border = parseCssBorder(getStyle(style, property));
1067
+ if (!border) continue;
1068
+ const color = colorToHex(border.color);
1069
+ return {
1070
+ shapeType: "line",
1071
+ lineColor: color.hex,
1072
+ lineTransparency: color.transparency,
1073
+ // The same 0.5pt floor the outline paths use, for the same reason:
1074
+ // `pxToPt` rounds, and a hairline that rounds to 0pt draws nothing.
1075
+ lineWidth: Math.max(0.5, pxToPt(border.widthPx, dims)),
1076
+ ...(border.dashType ? { lineDashType: border.dashType } : {}),
1077
+ ...importedLineEndTypes(innerHtml, axis),
1078
+ };
1079
+ }
1080
+ return undefined;
1081
+ }
1082
+
1083
+ /**
1084
+ * The `<a:headEnd>`/`<a:tailEnd>` the importer redraws as absolutely
1085
+ * positioned `<circle>` overlays (`lineEndCaps` in html-converter.ts). It only
1086
+ * ever reproduces `oval`, and it centers the overlay on the line, so a circle
1087
+ * before the viewBox midpoint caps the head and one after it caps the tail —
1088
+ * still true for a flipped source, because the importer swapped the two before
1089
+ * drawing them.
1090
+ */
1091
+ function importedLineEndTypes(
1092
+ innerHtml: string,
1093
+ axis: "x" | "y",
1094
+ ): Pick<ShapeElement, "lineHeadType" | "lineTailType"> {
1095
+ const svg = innerHtml.match(/<svg\b([^>]*)>([\s\S]*?)<\/svg>/i);
1096
+ const viewBox = getAttribute(svg?.[1] ?? "", "viewBox")
1097
+ ?.trim()
1098
+ .split(/[\s,]+/)
1099
+ .map(Number);
1100
+ if (!svg || viewBox?.length !== 4 || !viewBox.every(Number.isFinite)) {
1101
+ return {};
1102
+ }
1103
+ const middle = (axis === "x" ? viewBox[2] : viewBox[3]) / 2;
1104
+ const ends: Pick<ShapeElement, "lineHeadType" | "lineTailType"> = {};
1105
+ for (const circle of svg[2].matchAll(/<circle\b([^>]*)>/gi)) {
1106
+ const alongAttribute = getAttribute(circle[1], axis === "x" ? "cx" : "cy");
1107
+ if (alongAttribute == null) continue;
1108
+ const along = Number(alongAttribute);
1109
+ if (!Number.isFinite(along)) continue;
1110
+ if (along < middle) ends.lineHeadType = "oval";
1111
+ else ends.lineTailType = "oval";
1112
+ }
1113
+ return ends;
1114
+ }
1115
+
1001
1116
  type CustomGeometryPoint = NonNullable<ShapeElement["points"]>[number];
1002
1117
 
1003
1118
  /** Numbers each SVG path command consumes. The importer emits only these. */
@@ -2021,6 +2136,12 @@ export default defineAction({
2021
2136
  ...(shape.lineDashType
2022
2137
  ? { dashType: shape.lineDashType }
2023
2138
  : {}),
2139
+ ...(shape.lineHeadType
2140
+ ? { beginArrowType: shape.lineHeadType }
2141
+ : {}),
2142
+ ...(shape.lineTailType
2143
+ ? { endArrowType: shape.lineTailType }
2144
+ : {}),
2024
2145
  ...(shape.lineTransparency != null
2025
2146
  ? { transparency: shape.lineTransparency }
2026
2147
  : {}),
@@ -14,10 +14,18 @@ const UPLOAD_URL =
14
14
  "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart&fields=id,webViewLink";
15
15
 
16
16
  /**
17
- * Uploads a browser-generated PPTX into the user's Drive, letting Drive convert
18
- * it to a native Google Slides deck. The PPTX comes from the client because the
19
- * browser export renders the real slide DOM — the server-side pptxgenjs export
20
- * is a lower-fidelity fallback and would ship a visibly worse deck to Google.
17
+ * Uploads a PPTX into the user's Drive, letting Drive convert it to a native
18
+ * Google Slides deck. The caller decides which exporter produced those bytes,
19
+ * and which one is higher fidelity depends on the deck:
20
+ *
21
+ * - Source-imported decks go through the server `export-pptx`, which writes the
22
+ * source's own geometry as real vector shapes. The browser exporter cannot —
23
+ * `dom-to-pptx` has no custom-geometry support at all and rasterizes every
24
+ * vector shape to a bitmap, so Google receives silhouettes instead of curves.
25
+ * - Editor-authored decks go through the browser exporter, the only place
26
+ * geometry positioned in the DOM is measurable.
27
+ *
28
+ * See "Export Behavior" in `templates/slides/AGENTS.md` for the routing rule.
21
29
  */
22
30
  export default defineEventHandler(async (event) => {
23
31
  const session = await getSession(event).catch(() => null);
@@ -62,11 +62,11 @@ export declare const postAwareness: import("h3").EventHandlerWithFetch<import("h
62
62
  error: string;
63
63
  states?: undefined;
64
64
  } | {
65
- error?: undefined;
66
65
  states: {
67
66
  clientId: number;
68
67
  state: string;
69
68
  }[];
69
+ error?: undefined;
70
70
  }>>;
71
71
  /**
72
72
  * GET /_agent-native/collab/:docId/users
@@ -77,9 +77,9 @@ export declare const getActiveUsers: import("h3").EventHandlerWithFetch<import("
77
77
  error: string;
78
78
  users?: undefined;
79
79
  } | {
80
- error?: undefined;
81
80
  users: {
82
81
  clientId: number;
83
82
  lastSeen: number;
84
83
  }[];
84
+ error?: undefined;
85
85
  }>>;
package/dist/db/client.js CHANGED
@@ -763,6 +763,7 @@ export async function withDbTimeout(op, run, ms = dbOpTimeoutMs(), onTimeout) {
763
763
  */
764
764
  export function isServerlessRuntime() {
765
765
  return (!!process.env.NETLIFY ||
766
+ !!process.env.NETLIFY_FUNCTION_NAME ||
766
767
  !!process.env.VERCEL ||
767
768
  !!process.env.AWS_LAMBDA_FUNCTION_NAME ||
768
769
  !!process.env.LAMBDA_TASK_ROOT ||
@@ -41,27 +41,27 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
- error?: undefined;
45
- ok?: undefined;
46
44
  summary: import("./types.js").TraceSummary;
47
45
  spans: import("./types.js").TraceSpan[];
48
46
  id?: undefined;
49
- } | {
50
47
  error?: undefined;
51
48
  ok?: undefined;
49
+ } | {
52
50
  summary?: undefined;
53
51
  spans?: undefined;
54
52
  id: string;
55
- } | {
53
+ error?: undefined;
56
54
  ok?: undefined;
55
+ } | {
57
56
  summary?: undefined;
58
57
  spans?: undefined;
59
58
  id?: undefined;
60
59
  error: any;
60
+ ok?: undefined;
61
61
  } | {
62
- error?: undefined;
63
62
  summary?: undefined;
64
63
  spans?: undefined;
65
64
  id?: undefined;
65
+ error?: undefined;
66
66
  ok: boolean;
67
67
  }>>;
@@ -34,37 +34,37 @@ export declare function createListSecretsHandler(): import("h3").EventHandlerWit
34
34
  /** POST /_agent-native/secrets/:key — write a secret. */
35
35
  export declare function createWriteSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
36
36
  error: string;
37
- ok?: undefined;
38
37
  status?: undefined;
38
+ ok?: undefined;
39
39
  } | {
40
- error?: undefined;
41
40
  ok: boolean;
42
41
  status: string;
42
+ error?: undefined;
43
43
  } | {
44
- ok?: undefined;
45
44
  error: string;
46
45
  removed?: undefined;
46
+ ok?: undefined;
47
47
  } | {
48
- error?: undefined;
49
48
  ok: boolean;
50
49
  removed: boolean;
50
+ error?: undefined;
51
51
  }>>;
52
52
  /**
53
53
  * POST /_agent-native/secrets/:key/test — validate an optional candidate value
54
54
  * or the current stored value without changing anything.
55
55
  */
56
56
  export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
57
- ok?: undefined;
58
57
  error: string;
59
58
  note?: undefined;
59
+ ok?: undefined;
60
60
  } | {
61
- error?: undefined;
62
61
  ok: boolean;
63
62
  note?: undefined;
64
- } | {
65
63
  error?: undefined;
64
+ } | {
66
65
  ok: boolean;
67
66
  note: string;
67
+ error?: undefined;
68
68
  } | {
69
69
  note?: undefined;
70
70
  ok: boolean;
@@ -95,11 +95,11 @@ export interface AdHocSecretPayload {
95
95
  export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
96
96
  error: string;
97
97
  } | {
98
- error?: undefined;
99
98
  ok: boolean;
100
99
  key: string;
101
- } | {
102
100
  error?: undefined;
101
+ } | {
103
102
  ok: boolean;
104
103
  removed: boolean;
104
+ error?: undefined;
105
105
  }>>;
@@ -27,10 +27,10 @@ export declare function resolveAgentEngineApiKeyWriteTarget(event: H3Event, scop
27
27
  export declare function createAgentEngineApiKeyHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
28
28
  error: any;
29
29
  } | {
30
- error?: undefined;
31
30
  ok: boolean;
32
31
  key: string;
33
32
  baseUrlKey?: string;
34
33
  scope: AgentEngineApiKeyScope;
34
+ error?: undefined;
35
35
  }>>;
36
36
  export {};
@@ -20,6 +20,6 @@ export declare function createTranscribeVoiceHandler(): import("h3").EventHandle
20
20
  error: string;
21
21
  text?: undefined;
22
22
  } | {
23
- text: string;
24
23
  error?: undefined;
24
+ text: string;
25
25
  }>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.157.10",
3
+ "version": "0.157.11",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {