@office-kit/pptx-editor 0.1.1 → 0.2.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.
package/README.md CHANGED
@@ -194,7 +194,8 @@ tool with the next release.
194
194
 
195
195
  - **Names** are the export names (`setShapeFill`, `addSlideShape`, …), sorted.
196
196
  Four tools are the editor's own, for finding what the others take:
197
- `listSlides`, `listShapes` (refs, kind, bounds and text of each shape),
197
+ `listSlides`, `listShapes` (refs, kind, bounds and text of each shape, and a
198
+ chart's kind, title, categories and series values),
198
199
  `listLayouts` and `listComments`.
199
200
  - **Descriptions** are the exports' TSDoc. **Input schemas** are JSON Schema
200
201
  (draft 2020-12) generated from the functions' TypeScript signatures, one
@@ -326,6 +327,38 @@ The merge itself is `mergeDecks(base, ours, theirs)` from
326
327
  `@office-kit/pptx-editor/merge`. It has no DOM dependency, for hosts that merge
327
328
  on a server, and returns `{ ok: true, bytes }` or `{ ok: false, conflicts }`.
328
329
 
330
+ ### Small edits without the editor
331
+
332
+ `@office-kit/pptx-editor/headless` gives an agent that has no editor (on a
333
+ server, say) nine edits for small revisions, as one tool: `setShapeText`,
334
+ `setTableCellText`, `setChartData`, `setShapeTextFormat` (size, bold, italic,
335
+ color of a shape's whole text), `setShapeFill`, `setShapeBounds`,
336
+ `removeShape`, `moveSlide` and `removeSlide`, in one compact schema. Text edits always keep the formatting of the text they do not change.
337
+ It has no DOM dependency and runs in Node.
338
+
339
+ ```ts
340
+ import { loadPresentation, savePresentation } from '@office-kit/pptx';
341
+ import {
342
+ agentEditSchema,
343
+ applyAgentEdits,
344
+ decodeAgentEdits,
345
+ readForAgent,
346
+ } from '@office-kit/pptx-editor/headless';
347
+
348
+ const deck = await loadPresentation(bytes);
349
+ const context = readForAgent(deck, null); // slides, notes, shapes, chart values
350
+ // Give the model `agentEditSchema` as one tool's input schema; it answers `{ edits }`.
351
+ const { edits, touchedSlides } = decodeAgentEdits(input.edits);
352
+ await applyAgentEdits(deck, edits);
353
+ const revised = await savePresentation(deck);
354
+ ```
355
+
356
+ `decodeAgentEdits` checks the whole batch without a presentation and throws an
357
+ `AgentEditError` (`index: null`) naming every problem by its JSON Pointer.
358
+ `applyAgentEdits` applies the edits in order; when one fails it rejects with
359
+ that edit's `index`, and the edits before it have been applied, so discard
360
+ the presentation.
361
+
329
362
  ## Behaviour on your page
330
363
 
331
364
  - **Styles are isolated.** The editor renders inside a shadow root on an
@@ -1,5 +1,17 @@
1
- import { r as shapeRef } from "./src-BrBOgen_.js";
1
+ import { i as shapeRef } from "./shape-ref-B5iNfYWh.js";
2
2
  import * as pptx from "@office-kit/pptx";
3
+ //#region \0rolldown/runtime.js
4
+ var __defProp = Object.defineProperty;
5
+ var __exportAll = (all, no_symbols) => {
6
+ let target = {};
7
+ for (var name in all) __defProp(target, name, {
8
+ get: all[name],
9
+ enumerable: true
10
+ });
11
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
12
+ return target;
13
+ };
14
+ //#endregion
3
15
  //#region src/manifest/tools.generated.ts
4
16
  const generatedTools = {
5
17
  notTools: {
@@ -1995,10 +2007,6 @@ const generatedTools = {
1995
2007
  type: "string",
1996
2008
  enum: ["in", "out"]
1997
2009
  },
1998
- AnimationInOutOrString: { anyOf: [{ $ref: "#/$defs/AnimationInOut" }, {
1999
- type: "string",
2000
- enum: ["none", "cross"]
2001
- }] },
2002
2010
  Bar3DShape: {
2003
2011
  type: "string",
2004
2012
  enum: [
@@ -2074,7 +2082,7 @@ const generatedTools = {
2074
2082
  type: "string",
2075
2083
  enum: ["none", "cross"]
2076
2084
  }],
2077
- description: "Major-tick mark mode on the category axis (`<c:catAx><c:majorTickMark>`)."
2085
+ description: "Major-tick mark mode on the category axis (`<c:catAx><c:majorTickMark>`).\nDefault: `'none'` on bar / column charts, `'out'` otherwise."
2078
2086
  },
2079
2087
  CategoryAxisMinorGridlineColor: {
2080
2088
  type: "string",
@@ -2093,7 +2101,7 @@ const generatedTools = {
2093
2101
  type: "string",
2094
2102
  enum: ["none", "cross"]
2095
2103
  }],
2096
- description: "Minor-tick mark mode on the category axis (`<c:catAx><c:minorTickMark>`)."
2104
+ description: "Minor-tick mark mode on the category axis (`<c:catAx><c:minorTickMark>`); default `'none'`."
2097
2105
  },
2098
2106
  CategoryAxisNoMultiLevelLabel: {
2099
2107
  type: "boolean",
@@ -2167,41 +2175,12 @@ const generatedTools = {
2167
2175
  properties: {
2168
2176
  min: { type: "number" },
2169
2177
  max: { type: "number" },
2170
- majorUnit: {
2171
- type: "number",
2172
- description: "Major tick spacing (`<c:majorUnit val=\"N\"/>`)."
2173
- },
2174
- minorUnit: {
2175
- type: "number",
2176
- description: "Minor tick spacing (`<c:minorUnit val=\"N\"/>`)."
2177
- },
2178
- numberFormat: {
2179
- type: "string",
2180
- description: "Number-format code from `<c:numFmt formatCode=\"…\"/>`. Common\nvalues: `\"0%\"`, `\"0.0%\"`, `\"#,##0\"`, `\"$#,##0\"`, `\"yyyy-mm-dd\"`.\nRenderers project a subset of spreadsheet number formats to label text."
2181
- },
2182
- logBase: {
2183
- type: "number",
2184
- description: "Logarithmic base for the axis from `<c:scaling><c:logBase val=\"N\"/>`.\nTypical values are `2`, `10`, `Math.E`. When set, the renderer\nprojects values through `Math.log(v) / Math.log(logBase)` before\nmapping to plot coordinates. Linear when omitted."
2185
- },
2186
- displayUnits: {
2187
- type: "string",
2188
- enum: [
2189
- "hundreds",
2190
- "thousands",
2191
- "tenThousands",
2192
- "hundredThousands",
2193
- "millions",
2194
- "tenMillions",
2195
- "hundredMillions",
2196
- "billions",
2197
- "trillions"
2198
- ],
2199
- description: "Authored display-units scale from `<c:dispUnits><c:builtInUnit val=\"…\"/>`.\nToken values map to divisors:\n\n - `'hundreds'` (100), `'thousands'` (1e3), `'tenThousands'` (1e4),\n `'hundredThousands'` (1e5), `'millions'` (1e6),\n `'tenMillions'` (1e7), `'hundredMillions'` (1e8),\n `'billions'` (1e9), `'trillions'` (1e12)\n\nRenderers divide axis labels by the divisor and may append a unit\nsuffix (\"K\", \"M\", \"B\") for readability."
2200
- },
2201
- displayUnitsLabel: {
2202
- type: "boolean",
2203
- description: "Show the display-units caption next to the axis (\"Thousands\",\n\"Millions\", …) — an empty `<c:dispUnitsLbl/>` under `<c:dispUnits>`.\nOnly meaningful together with `displayUnits`."
2204
- }
2178
+ majorUnit: { $ref: "#/$defs/MajorUnit" },
2179
+ minorUnit: { $ref: "#/$defs/MinorUnit" },
2180
+ numberFormat: { $ref: "#/$defs/NumberFormat" },
2181
+ logBase: { $ref: "#/$defs/LogBase" },
2182
+ displayUnits: { $ref: "#/$defs/DisplayUnits" },
2183
+ displayUnitsLabel: { $ref: "#/$defs/DisplayUnitsLabel" }
2205
2184
  },
2206
2185
  additionalProperties: false
2207
2186
  },
@@ -2429,8 +2408,20 @@ const generatedTools = {
2429
2408
  type: "number",
2430
2409
  description: "Axis line width in EMU, the mirror of `ChartSpec.valueAxisLineWidthEmu`."
2431
2410
  },
2432
- majorTickMark: { $ref: "#/$defs/AnimationInOutOrString" },
2433
- minorTickMark: { $ref: "#/$defs/AnimationInOutOrString" },
2411
+ majorTickMark: {
2412
+ anyOf: [{ $ref: "#/$defs/AnimationInOut" }, {
2413
+ type: "string",
2414
+ enum: ["none", "cross"]
2415
+ }],
2416
+ description: "Major tick marks; default `'out'`."
2417
+ },
2418
+ minorTickMark: {
2419
+ anyOf: [{ $ref: "#/$defs/AnimationInOut" }, {
2420
+ type: "string",
2421
+ enum: ["none", "cross"]
2422
+ }],
2423
+ description: "Minor tick marks; default `'none'`."
2424
+ },
2434
2425
  tickLabelPos: {
2435
2426
  type: "string",
2436
2427
  enum: [
@@ -2444,7 +2435,15 @@ const generatedTools = {
2444
2435
  crossBetween: {
2445
2436
  type: "string",
2446
2437
  enum: ["between", "midCat"]
2447
- }
2438
+ },
2439
+ min: { type: "number" },
2440
+ max: { type: "number" },
2441
+ majorUnit: { $ref: "#/$defs/MajorUnit" },
2442
+ minorUnit: { $ref: "#/$defs/MinorUnit" },
2443
+ numberFormat: { $ref: "#/$defs/NumberFormat" },
2444
+ logBase: { $ref: "#/$defs/LogBase" },
2445
+ displayUnits: { $ref: "#/$defs/DisplayUnits" },
2446
+ displayUnitsLabel: { $ref: "#/$defs/DisplayUnitsLabel" }
2448
2447
  },
2449
2448
  additionalProperties: false
2450
2449
  },
@@ -2681,6 +2680,25 @@ const generatedTools = {
2681
2680
  ],
2682
2681
  description: "`<c:dispBlanksAs val=\"…\"/>` — how line / area renderers should\ntreat `null` values in series:\n\n - `'gap'` — leave a gap (the default)\n - `'zero'` — substitute zero\n - `'span'` — connect the surrounding points across the gap"
2683
2682
  },
2683
+ DisplayUnits: {
2684
+ type: "string",
2685
+ enum: [
2686
+ "hundreds",
2687
+ "thousands",
2688
+ "tenThousands",
2689
+ "hundredThousands",
2690
+ "millions",
2691
+ "tenMillions",
2692
+ "hundredMillions",
2693
+ "billions",
2694
+ "trillions"
2695
+ ],
2696
+ description: "Authored display-units scale from `<c:dispUnits><c:builtInUnit val=\"…\"/>`.\nToken values map to divisors:\n\n - `'hundreds'` (100), `'thousands'` (1e3), `'tenThousands'` (1e4),\n `'hundredThousands'` (1e5), `'millions'` (1e6),\n `'tenMillions'` (1e7), `'hundredMillions'` (1e8),\n `'billions'` (1e9), `'trillions'` (1e12)\n\nRenderers divide axis labels by the divisor and may append a unit\nsuffix (\"K\", \"M\", \"B\") for readability."
2697
+ },
2698
+ DisplayUnitsLabel: {
2699
+ type: "boolean",
2700
+ description: "Show the display-units caption next to the axis (\"Thousands\",\n\"Millions\", …) — an empty `<c:dispUnitsLbl/>` under `<c:dispUnits>`.\nOnly meaningful together with `displayUnits`."
2701
+ },
2684
2702
  DropLines: {
2685
2703
  type: "boolean",
2686
2704
  description: "Drop lines (`<c:dropLines>`) — vertical guide lines from each data\npoint down to the value axis. Common on line / area charts."
@@ -2776,6 +2794,14 @@ const generatedTools = {
2776
2794
  type: "number",
2777
2795
  description: "Optional line stroke width in EMU (`<c:ser><c:spPr><a:ln w=\"…\"/>`).\nOnly meaningful for line / area / scatter series. Default falls\nback to the renderer's own pick."
2778
2796
  },
2797
+ LogBase: {
2798
+ type: "number",
2799
+ description: "Logarithmic base for the axis from `<c:scaling><c:logBase val=\"N\"/>`.\nTypical values are `2`, `10`, `Math.E`. When set, the renderer\nprojects values through `Math.log(v) / Math.log(logBase)` before\nmapping to plot coordinates. Linear when omitted."
2800
+ },
2801
+ MajorUnit: {
2802
+ type: "number",
2803
+ description: "Major tick spacing (`<c:majorUnit val=\"N\"/>`)."
2804
+ },
2779
2805
  MarkerColor: {
2780
2806
  type: "string",
2781
2807
  description: "Optional marker fill + outline color (`<c:marker><c:spPr>`), as an sRGB\nhex. Defaults to `color`. The builder always writes it for line /\nscatter / radar series, because the reference desktop app paints a marker without\n`<c:spPr>` in the theme's automatic color instead of the series color."
@@ -2806,10 +2832,18 @@ const generatedTools = {
2806
2832
  }],
2807
2833
  description: "Optional marker style for line / scatter series (`<c:ser><c:marker>`).\n`none` hides the markers; the others render the matching glyph at\neach data point. Defaults to `auto`, which renderers map to a small\nfilled circle."
2808
2834
  },
2835
+ MinorUnit: {
2836
+ type: "number",
2837
+ description: "Minor tick spacing (`<c:minorUnit val=\"N\"/>`)."
2838
+ },
2809
2839
  Name: {
2810
2840
  type: "string",
2811
2841
  description: "Series label rendered in the legend."
2812
2842
  },
2843
+ NumberFormat: {
2844
+ type: "string",
2845
+ description: "Number-format code from `<c:numFmt formatCode=\"…\"/>`. Common\nvalues: `\"0%\"`, `\"0.0%\"`, `\"#,##0\"`, `\"$#,##0\"`, `\"yyyy-mm-dd\"`.\nRenderers project a subset of spreadsheet number formats to label text."
2846
+ },
2813
2847
  OverlapPct: {
2814
2848
  type: "number",
2815
2849
  description: "Overlap of adjacent bars within a category in `<c:overlap val=\"N\"/>`\npercent (-100..100). Negative pulls bars apart, positive overlaps.\nDefaults to 0 (clustered) / 100 (stacked)."
@@ -2865,7 +2899,7 @@ const generatedTools = {
2865
2899
  PointDataLabels: {
2866
2900
  type: "array",
2867
2901
  items: { anyOf: [{ type: "null" }, { $ref: "#/$defs/ChartDataLabels" }] },
2868
- description: "Optional per-data-point data-label overrides\n(`<c:dLbls><c:dLbl><c:idx val=\"N\"/>…`). Sparse — `null` slots fall back\nto the series-level `dataLabels`. The reference desktop app draws the per-point element\nover the series defaults, which is how pie / doughnut exporters give each\nslice its own label content and font."
2902
+ description: "Optional per-data-point data-label overrides\n(`<c:dLbls><c:dLbl><c:idx val=\"N\"/>…`). Sparse — `null` slots fall back\nto the series-level `dataLabels`, else the chart-level `dataLabels`, else\nno label. That fallback is written as the series' own `<c:dLbls>`, so\nreading the chart back reports it as the series' `dataLabels`. The\nreference desktop app draws the per-point element\nover the series defaults, which is how pie / doughnut exporters give each\nslice its own label content and font."
2869
2903
  },
2870
2904
  PointExplosions: {
2871
2905
  type: "array",
@@ -3064,7 +3098,7 @@ const generatedTools = {
3064
3098
  type: "string",
3065
3099
  enum: ["none", "cross"]
3066
3100
  }],
3067
- description: "Minor-tick mark mode on the value axis (`<c:valAx><c:minorTickMark>`)."
3101
+ description: "Minor-tick mark mode on the value axis (`<c:valAx><c:minorTickMark>`); default `'none'`."
3068
3102
  },
3069
3103
  ValueAxisOrientation: {
3070
3104
  type: "string",
@@ -4560,7 +4594,7 @@ const generatedTools = {
4560
4594
  },
4561
4595
  {
4562
4596
  name: "compactPackage",
4563
- description: "Removes media parts that no rels graph references. Returns the\nlist of removed part names. Useful after a sequence of slide\nremovals leaves orphan images behind.\n\nOnly `/ppt/media/...` parts are considered. The check walks every\n`.rels` part in the package and resolves each internal rel target\nagainst its source part name to build the live media set.",
4597
+ description: "Removes every part that cannot be reached from the package root\n(`/_rels/.rels`) through internal relationships, together with its\n`.rels` part and its `[Content_Types].xml` override. Returns the\nremoved part names.\n\n`removeSlide` removes only the slide and its `.rels`, so the slide's\ncharts, embedded workbooks, notes slide, tags and media stay in the\npackage until this runs. Parts still in use — including layouts no\nslide uses, which their master references — are kept. Any other part\nnothing points at, such as custom data added without a relationship, is\nremoved too. When `/_rels/.rels` does not reach `/ppt/presentation.xml`,\nnothing is removed.",
4564
4598
  args: [null],
4565
4599
  input_schema: {
4566
4600
  type: "object",
@@ -5072,7 +5106,7 @@ const generatedTools = {
5072
5106
  },
5073
5107
  {
5074
5108
  name: "removeSlide",
5075
- description: "Removes the given slide from the deck. Removes the `<p:sldId>`, the\n`presentation.xml.rels` entry, and the slide part + its `.rels` part.\nLinks to this slide from other slides are cleared to prevent accidental\nretargeting when a slide part name is reused.\n\nMedia parts are intentionally NOT cleaned up — they may be shared\nwith other slides. The freed `sldId` is NOT reused on subsequent\n`addSlide` calls (the reference desktop app's quirk, see plan §Risks).",
5109
+ description: "Removes the given slide from the deck. Removes the `<p:sldId>`, the\n`presentation.xml.rels` entry, and the slide part + its `.rels` part.\nLinks to this slide from other slides are cleared to prevent accidental\nretargeting when a slide part name is reused.\n\nParts the slide referenced (media, charts and their workbooks, the notes\nslide, tags) are left in place because other slides may share them; call\n`compactPackage` afterwards to drop the ones nothing references any more.\nThe freed `sldId` is NOT reused on subsequent `addSlide` calls (the\nreference desktop app's quirk, see plan §Risks).",
5076
5110
  args: [null, "slide"],
5077
5111
  input_schema: {
5078
5112
  type: "object",
@@ -5685,6 +5719,87 @@ const generatedTools = {
5685
5719
  },
5686
5720
  output: { type: "null" }
5687
5721
  },
5722
+ {
5723
+ name: "setChartData",
5724
+ description: "Replaces the data of a bar, column, line, area, pie or doughnut chart.\n\nWhen `kind` is the chart's own and `series` names the same series (in any\norder), only the values change: everything else in the chart, its\nformatting included, is kept. Changing `kind`, or adding, removing or\nrenaming a series, builds the chart again from its title, axis titles,\nlegend, series names and colors, and the rest of its formatting returns\nto the defaults; to keep it, copy the series names exactly as they are\nread. Each series needs one value per category: when changing\n`categories`, pass every series with values of the same length. A pie or\ndoughnut chart takes exactly one series. On a date axis the categories\nare read as date serial numbers (days since 1899-12-30, e.g. `\"45292\"`\nfor 2024-01-01) and must be passed the same way. The embedded workbook\nis rewritten with the new data.\n\nThrows when the chart is of another kind (scatter, bubble, stock,\nsurface, radar, or one this library cannot read), when `categories` or\n`series` is empty, when a series has more or fewer values than there are\ncategories, when a date-axis category is not a number, and when\ncategories change on a chart whose categories have several levels.",
5725
+ args: ["chart", "data"],
5726
+ input_schema: {
5727
+ type: "object",
5728
+ properties: {
5729
+ chart: { $ref: "#/$defs/ChartRef" },
5730
+ data: {
5731
+ type: "object",
5732
+ properties: {
5733
+ kind: {
5734
+ type: "string",
5735
+ enum: [
5736
+ "bar",
5737
+ "column",
5738
+ "line",
5739
+ "pie",
5740
+ "doughnut",
5741
+ "area"
5742
+ ]
5743
+ },
5744
+ categories: {
5745
+ type: "array",
5746
+ items: { type: "string" }
5747
+ },
5748
+ series: {
5749
+ type: "array",
5750
+ items: {
5751
+ type: "object",
5752
+ properties: {
5753
+ name: { type: "string" },
5754
+ values: {
5755
+ type: "array",
5756
+ items: { type: ["null", "number"] },
5757
+ description: "One value per category; `null` leaves the point empty."
5758
+ }
5759
+ },
5760
+ required: ["name", "values"],
5761
+ additionalProperties: false
5762
+ },
5763
+ description: "Every series of the chart, in order."
5764
+ }
5765
+ },
5766
+ additionalProperties: false
5767
+ }
5768
+ },
5769
+ required: ["chart", "data"],
5770
+ additionalProperties: false,
5771
+ $defs: {
5772
+ ChartRef: {
5773
+ $ref: "#/$defs/ShapeRef",
5774
+ description: "A chart, by the ShapeRef of the graphic frame that holds it."
5775
+ },
5776
+ ShapeRef: {
5777
+ type: "object",
5778
+ description: "A shape, by its slide and id, as `listShapes` or the user's selection reports it. `slideIndex` and `name` are informational.",
5779
+ properties: {
5780
+ slide: { $ref: "#/$defs/SlideRef" },
5781
+ shapeId: {
5782
+ type: "integer",
5783
+ minimum: 0
5784
+ },
5785
+ slideIndex: {
5786
+ type: "integer",
5787
+ minimum: 0
5788
+ },
5789
+ name: { type: "string" }
5790
+ },
5791
+ required: ["slide", "shapeId"],
5792
+ additionalProperties: false
5793
+ },
5794
+ SlideRef: {
5795
+ type: "string",
5796
+ pattern: "^/ppt/slides/[^/]+\\.xml$",
5797
+ description: "A slide, by its part name as `listSlides` reports it, e.g. \"/ppt/slides/slide1.xml\"."
5798
+ }
5799
+ }
5800
+ },
5801
+ output: { type: "null" }
5802
+ },
5688
5803
  {
5689
5804
  name: "setChartSpec",
5690
5805
  description: "Replaces the chart definition on an existing graphic-frame chart\nshape. Updates the inline `<c:strCache>` / `<c:numCache>` blocks so\nthe reference desktop app renders the new data without opening the embedded\nworkbook. The shape's geometry (position / size / rotation) is\npreserved verbatim.\n\nThe embedded xlsx is re-written too — it's what the \"Edit data\"\naffordance opens. The previous workbook is replaced wholesale (no\nattempt to preserve styles a user added in a spreadsheet app).\n\nPass any `ChartSpec`, including a different `kind` from the\noriginal; this acts as \"change my column chart to a line chart with\nfresh data.\"",
@@ -7416,10 +7531,6 @@ const generatedTools = {
7416
7531
  type: "string",
7417
7532
  enum: ["in", "out"]
7418
7533
  },
7419
- AnimationInOutOrString: { anyOf: [{ $ref: "#/$defs/AnimationInOut" }, {
7420
- type: "string",
7421
- enum: ["none", "cross"]
7422
- }] },
7423
7534
  Bar3DShape: {
7424
7535
  type: "string",
7425
7536
  enum: [
@@ -7495,7 +7606,7 @@ const generatedTools = {
7495
7606
  type: "string",
7496
7607
  enum: ["none", "cross"]
7497
7608
  }],
7498
- description: "Major-tick mark mode on the category axis (`<c:catAx><c:majorTickMark>`)."
7609
+ description: "Major-tick mark mode on the category axis (`<c:catAx><c:majorTickMark>`).\nDefault: `'none'` on bar / column charts, `'out'` otherwise."
7499
7610
  },
7500
7611
  CategoryAxisMinorGridlineColor: {
7501
7612
  type: "string",
@@ -7514,7 +7625,7 @@ const generatedTools = {
7514
7625
  type: "string",
7515
7626
  enum: ["none", "cross"]
7516
7627
  }],
7517
- description: "Minor-tick mark mode on the category axis (`<c:catAx><c:minorTickMark>`)."
7628
+ description: "Minor-tick mark mode on the category axis (`<c:catAx><c:minorTickMark>`); default `'none'`."
7518
7629
  },
7519
7630
  CategoryAxisNoMultiLevelLabel: {
7520
7631
  type: "boolean",
@@ -7588,41 +7699,12 @@ const generatedTools = {
7588
7699
  properties: {
7589
7700
  min: { type: "number" },
7590
7701
  max: { type: "number" },
7591
- majorUnit: {
7592
- type: "number",
7593
- description: "Major tick spacing (`<c:majorUnit val=\"N\"/>`)."
7594
- },
7595
- minorUnit: {
7596
- type: "number",
7597
- description: "Minor tick spacing (`<c:minorUnit val=\"N\"/>`)."
7598
- },
7599
- numberFormat: {
7600
- type: "string",
7601
- description: "Number-format code from `<c:numFmt formatCode=\"…\"/>`. Common\nvalues: `\"0%\"`, `\"0.0%\"`, `\"#,##0\"`, `\"$#,##0\"`, `\"yyyy-mm-dd\"`.\nRenderers project a subset of spreadsheet number formats to label text."
7602
- },
7603
- logBase: {
7604
- type: "number",
7605
- description: "Logarithmic base for the axis from `<c:scaling><c:logBase val=\"N\"/>`.\nTypical values are `2`, `10`, `Math.E`. When set, the renderer\nprojects values through `Math.log(v) / Math.log(logBase)` before\nmapping to plot coordinates. Linear when omitted."
7606
- },
7607
- displayUnits: {
7608
- type: "string",
7609
- enum: [
7610
- "hundreds",
7611
- "thousands",
7612
- "tenThousands",
7613
- "hundredThousands",
7614
- "millions",
7615
- "tenMillions",
7616
- "hundredMillions",
7617
- "billions",
7618
- "trillions"
7619
- ],
7620
- description: "Authored display-units scale from `<c:dispUnits><c:builtInUnit val=\"…\"/>`.\nToken values map to divisors:\n\n - `'hundreds'` (100), `'thousands'` (1e3), `'tenThousands'` (1e4),\n `'hundredThousands'` (1e5), `'millions'` (1e6),\n `'tenMillions'` (1e7), `'hundredMillions'` (1e8),\n `'billions'` (1e9), `'trillions'` (1e12)\n\nRenderers divide axis labels by the divisor and may append a unit\nsuffix (\"K\", \"M\", \"B\") for readability."
7621
- },
7622
- displayUnitsLabel: {
7623
- type: "boolean",
7624
- description: "Show the display-units caption next to the axis (\"Thousands\",\n\"Millions\", …) — an empty `<c:dispUnitsLbl/>` under `<c:dispUnits>`.\nOnly meaningful together with `displayUnits`."
7625
- }
7702
+ majorUnit: { $ref: "#/$defs/MajorUnit" },
7703
+ minorUnit: { $ref: "#/$defs/MinorUnit" },
7704
+ numberFormat: { $ref: "#/$defs/NumberFormat" },
7705
+ logBase: { $ref: "#/$defs/LogBase" },
7706
+ displayUnits: { $ref: "#/$defs/DisplayUnits" },
7707
+ displayUnitsLabel: { $ref: "#/$defs/DisplayUnitsLabel" }
7626
7708
  },
7627
7709
  additionalProperties: false
7628
7710
  },
@@ -7854,8 +7936,20 @@ const generatedTools = {
7854
7936
  type: "number",
7855
7937
  description: "Axis line width in EMU, the mirror of `ChartSpec.valueAxisLineWidthEmu`."
7856
7938
  },
7857
- majorTickMark: { $ref: "#/$defs/AnimationInOutOrString" },
7858
- minorTickMark: { $ref: "#/$defs/AnimationInOutOrString" },
7939
+ majorTickMark: {
7940
+ anyOf: [{ $ref: "#/$defs/AnimationInOut" }, {
7941
+ type: "string",
7942
+ enum: ["none", "cross"]
7943
+ }],
7944
+ description: "Major tick marks; default `'out'`."
7945
+ },
7946
+ minorTickMark: {
7947
+ anyOf: [{ $ref: "#/$defs/AnimationInOut" }, {
7948
+ type: "string",
7949
+ enum: ["none", "cross"]
7950
+ }],
7951
+ description: "Minor tick marks; default `'none'`."
7952
+ },
7859
7953
  tickLabelPos: {
7860
7954
  type: "string",
7861
7955
  enum: [
@@ -7869,7 +7963,15 @@ const generatedTools = {
7869
7963
  crossBetween: {
7870
7964
  type: "string",
7871
7965
  enum: ["between", "midCat"]
7872
- }
7966
+ },
7967
+ min: { type: "number" },
7968
+ max: { type: "number" },
7969
+ majorUnit: { $ref: "#/$defs/MajorUnit" },
7970
+ minorUnit: { $ref: "#/$defs/MinorUnit" },
7971
+ numberFormat: { $ref: "#/$defs/NumberFormat" },
7972
+ logBase: { $ref: "#/$defs/LogBase" },
7973
+ displayUnits: { $ref: "#/$defs/DisplayUnits" },
7974
+ displayUnitsLabel: { $ref: "#/$defs/DisplayUnitsLabel" }
7873
7975
  },
7874
7976
  additionalProperties: false
7875
7977
  },
@@ -8106,6 +8208,25 @@ const generatedTools = {
8106
8208
  ],
8107
8209
  description: "`<c:dispBlanksAs val=\"…\"/>` — how line / area renderers should\ntreat `null` values in series:\n\n - `'gap'` — leave a gap (the default)\n - `'zero'` — substitute zero\n - `'span'` — connect the surrounding points across the gap"
8108
8210
  },
8211
+ DisplayUnits: {
8212
+ type: "string",
8213
+ enum: [
8214
+ "hundreds",
8215
+ "thousands",
8216
+ "tenThousands",
8217
+ "hundredThousands",
8218
+ "millions",
8219
+ "tenMillions",
8220
+ "hundredMillions",
8221
+ "billions",
8222
+ "trillions"
8223
+ ],
8224
+ description: "Authored display-units scale from `<c:dispUnits><c:builtInUnit val=\"…\"/>`.\nToken values map to divisors:\n\n - `'hundreds'` (100), `'thousands'` (1e3), `'tenThousands'` (1e4),\n `'hundredThousands'` (1e5), `'millions'` (1e6),\n `'tenMillions'` (1e7), `'hundredMillions'` (1e8),\n `'billions'` (1e9), `'trillions'` (1e12)\n\nRenderers divide axis labels by the divisor and may append a unit\nsuffix (\"K\", \"M\", \"B\") for readability."
8225
+ },
8226
+ DisplayUnitsLabel: {
8227
+ type: "boolean",
8228
+ description: "Show the display-units caption next to the axis (\"Thousands\",\n\"Millions\", …) — an empty `<c:dispUnitsLbl/>` under `<c:dispUnits>`.\nOnly meaningful together with `displayUnits`."
8229
+ },
8109
8230
  DropLines: {
8110
8231
  type: "boolean",
8111
8232
  description: "Drop lines (`<c:dropLines>`) — vertical guide lines from each data\npoint down to the value axis. Common on line / area charts."
@@ -8197,6 +8318,14 @@ const generatedTools = {
8197
8318
  type: "number",
8198
8319
  description: "Optional line stroke width in EMU (`<c:ser><c:spPr><a:ln w=\"…\"/>`).\nOnly meaningful for line / area / scatter series. Default falls\nback to the renderer's own pick."
8199
8320
  },
8321
+ LogBase: {
8322
+ type: "number",
8323
+ description: "Logarithmic base for the axis from `<c:scaling><c:logBase val=\"N\"/>`.\nTypical values are `2`, `10`, `Math.E`. When set, the renderer\nprojects values through `Math.log(v) / Math.log(logBase)` before\nmapping to plot coordinates. Linear when omitted."
8324
+ },
8325
+ MajorUnit: {
8326
+ type: "number",
8327
+ description: "Major tick spacing (`<c:majorUnit val=\"N\"/>`)."
8328
+ },
8200
8329
  MarkerColor: {
8201
8330
  type: "string",
8202
8331
  description: "Optional marker fill + outline color (`<c:marker><c:spPr>`), as an sRGB\nhex. Defaults to `color`. The builder always writes it for line /\nscatter / radar series, because the reference desktop app paints a marker without\n`<c:spPr>` in the theme's automatic color instead of the series color."
@@ -8227,10 +8356,18 @@ const generatedTools = {
8227
8356
  }],
8228
8357
  description: "Optional marker style for line / scatter series (`<c:ser><c:marker>`).\n`none` hides the markers; the others render the matching glyph at\neach data point. Defaults to `auto`, which renderers map to a small\nfilled circle."
8229
8358
  },
8359
+ MinorUnit: {
8360
+ type: "number",
8361
+ description: "Minor tick spacing (`<c:minorUnit val=\"N\"/>`)."
8362
+ },
8230
8363
  Name: {
8231
8364
  type: "string",
8232
8365
  description: "Series label rendered in the legend."
8233
8366
  },
8367
+ NumberFormat: {
8368
+ type: "string",
8369
+ description: "Number-format code from `<c:numFmt formatCode=\"…\"/>`. Common\nvalues: `\"0%\"`, `\"0.0%\"`, `\"#,##0\"`, `\"$#,##0\"`, `\"yyyy-mm-dd\"`.\nRenderers project a subset of spreadsheet number formats to label text."
8370
+ },
8234
8371
  OverlapPct: {
8235
8372
  type: "number",
8236
8373
  description: "Overlap of adjacent bars within a category in `<c:overlap val=\"N\"/>`\npercent (-100..100). Negative pulls bars apart, positive overlaps.\nDefaults to 0 (clustered) / 100 (stacked)."
@@ -8286,7 +8423,7 @@ const generatedTools = {
8286
8423
  PointDataLabels: {
8287
8424
  type: "array",
8288
8425
  items: { anyOf: [{ type: "null" }, { $ref: "#/$defs/ChartDataLabels" }] },
8289
- description: "Optional per-data-point data-label overrides\n(`<c:dLbls><c:dLbl><c:idx val=\"N\"/>…`). Sparse — `null` slots fall back\nto the series-level `dataLabels`. The reference desktop app draws the per-point element\nover the series defaults, which is how pie / doughnut exporters give each\nslice its own label content and font."
8426
+ description: "Optional per-data-point data-label overrides\n(`<c:dLbls><c:dLbl><c:idx val=\"N\"/>…`). Sparse — `null` slots fall back\nto the series-level `dataLabels`, else the chart-level `dataLabels`, else\nno label. That fallback is written as the series' own `<c:dLbls>`, so\nreading the chart back reports it as the series' `dataLabels`. The\nreference desktop app draws the per-point element\nover the series defaults, which is how pie / doughnut exporters give each\nslice its own label content and font."
8290
8427
  },
8291
8428
  PointExplosions: {
8292
8429
  type: "array",
@@ -8503,7 +8640,7 @@ const generatedTools = {
8503
8640
  type: "string",
8504
8641
  enum: ["none", "cross"]
8505
8642
  }],
8506
- description: "Minor-tick mark mode on the value axis (`<c:valAx><c:minorTickMark>`)."
8643
+ description: "Minor-tick mark mode on the value axis (`<c:valAx><c:minorTickMark>`); default `'none'`."
8507
8644
  },
8508
8645
  ValueAxisOrientation: {
8509
8646
  type: "string",
@@ -22957,6 +23094,12 @@ const generatedTools = {
22957
23094
  };
22958
23095
  //#endregion
22959
23096
  //#region src/core/agent-tools.ts
23097
+ var agent_tools_exports = /* @__PURE__ */ __exportAll({
23098
+ editorTools: () => editorTools,
23099
+ runTool: () => runTool,
23100
+ schemaErrors: () => schemaErrors,
23101
+ shapeSummary: () => shapeSummary
23102
+ });
22960
23103
  const library = pptx;
22961
23104
  const DEFS = "#/$defs/";
22962
23105
  function slideByPartName(presentation, partName) {
@@ -23206,6 +23349,7 @@ const NO_INPUT = {
23206
23349
  properties: {},
23207
23350
  additionalProperties: false
23208
23351
  };
23352
+ /** A shape as `listShapes` reports it. */
23209
23353
  function shapeSummary(presentation, shape) {
23210
23354
  const bounds = pptx.getShapeBoundsResolved(presentation, shape);
23211
23355
  const summary = {
@@ -23222,6 +23366,17 @@ function shapeSummary(presentation, shape) {
23222
23366
  if (pptx.isTableShape(shape)) {
23223
23367
  const { rows, cols } = pptx.getTableDimensions(shape);
23224
23368
  summary.cells = Array.from({ length: rows }, (_, row) => Array.from({ length: cols }, (_, col) => pptx.getTableCellText(pptx.getTableCell(shape, row, col))));
23369
+ } else if (pptx.isChartShape(shape)) {
23370
+ const spec = pptx.getShapeChartSpec(shape);
23371
+ summary.chart = spec && {
23372
+ kind: spec.kind,
23373
+ title: spec.title ?? null,
23374
+ categories: spec.categories,
23375
+ series: spec.series.map(({ name, values }) => ({
23376
+ name,
23377
+ values
23378
+ }))
23379
+ };
23225
23380
  } else if (pptx.hasShapeText(shape)) summary.text = pptx.getShapeText(shape);
23226
23381
  return summary;
23227
23382
  }
@@ -23243,7 +23398,7 @@ const readTools = [
23243
23398
  },
23244
23399
  {
23245
23400
  name: "listShapes",
23246
- description: `Lists the shapes on a slide, back to front: each shape's ref (which other tools take as "shape", or with "row" and "col" added as a table "cell"), its kind, placeholder type, bounds and text (for a table, the text of every cell). Bounds are in EMU: 914400 per inch, 360000 per cm, 12700 per point.`,
23401
+ description: `Lists the shapes on a slide, back to front: each shape's ref (which other tools take as "shape", or with "row" and "col" added as a table "cell"), its kind, placeholder type, bounds and text (for a table, the text of every cell; for a chart, its kind, title, categories and series values, or null when its kind cannot be read; date-axis categories are date serial numbers). Bounds are in EMU: 914400 per inch, 360000 per cm, 12700 per point.`,
23247
23402
  input_schema: SLIDE_INPUT,
23248
23403
  read: (presentation, input) => pptx.getSlideShapes(input.slide).map((shape) => shapeSummary(presentation, shape))
23249
23404
  },
@@ -23284,6 +23439,18 @@ function defsOf(schema) {
23284
23439
  return schema.$defs ?? {};
23285
23440
  }
23286
23441
  /**
23442
+ * The problems with `value` against `schema`, a root schema with its own
23443
+ * `$defs`, each named by its JSON Pointer; empty when it matches.
23444
+ */
23445
+ function schemaErrors(schema, value) {
23446
+ const checking = {
23447
+ defs: defsOf(schema),
23448
+ errors: []
23449
+ };
23450
+ decode(schema, value, "", checking);
23451
+ return checking.errors;
23452
+ }
23453
+ /**
23287
23454
  * Runs tool `name` with the model's `input`. Rejects, editing nothing, when
23288
23455
  * there is no such tool or the input does not match its schema; the message
23289
23456
  * lists each problem by its JSON Pointer, for the model to correct.
@@ -23292,12 +23459,8 @@ async function runTool(host, name, input) {
23292
23459
  const tool = byName.get(name);
23293
23460
  if (!tool) throw new Error(`There is no tool ${JSON.stringify(name)}. Call one of the tools listed.`);
23294
23461
  const defs = defsOf(tool.input_schema);
23295
- const checking = {
23296
- defs,
23297
- errors: []
23298
- };
23299
- decode(tool.input_schema, input, "", checking);
23300
- if (checking.errors.length > 0) throw new Error(`Invalid input for ${name}:\n${checking.errors.map((error) => `- ${error}`).join("\n")}`);
23462
+ const errors = schemaErrors(tool.input_schema, input);
23463
+ if (errors.length > 0) throw new Error(`Invalid input for ${name}:\n${errors.map((error) => `- ${error}`).join("\n")}`);
23301
23464
  const resolve = (presentation) => decode(tool.input_schema, input, "", {
23302
23465
  defs,
23303
23466
  errors: [],
@@ -23318,6 +23481,6 @@ async function runTool(host, name, input) {
23318
23481
  return result;
23319
23482
  }
23320
23483
  //#endregion
23321
- export { editorTools, runTool };
23484
+ export { generatedTools as a, shapeSummary as i, runTool as n, schemaErrors as r, agent_tools_exports as t };
23322
23485
 
23323
- //# sourceMappingURL=agent-tools-CEZAOXNe.js.map
23486
+ //# sourceMappingURL=agent-tools-D8sCxM9t.js.map