@automattic/agenttic-client 0.1.11 → 0.1.13

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.
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Chart extension for markdown processing
3
3
  */
4
+ import './charts.css';
4
5
  import React from 'react';
5
6
  import type { ChartExtensionConfig } from '../types';
6
7
  interface CodeProps extends React.HTMLAttributes<HTMLElement> {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/markdown-extensions/charts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGrD,UAAU,SAAU,SAAQ,KAAK,CAAC,cAAc,CAAE,WAAW,CAAE;IAC9D,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,KAAK,WAAW,GAAG,oBAAoB,CAAE,QAAQ,CAAE,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAE,MAAM,CAAC,EAAE,WAAW,IACrB,OAAO,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yFAqBhD;AAGD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MA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D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/E,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
package/dist/mocks.js ADDED
@@ -0,0 +1,311 @@
1
+ import { j as r, b as l } from "./BarChart-Cid6YH81.js";
2
+ import "react";
3
+ import "@wordpress/i18n";
4
+ import "@automattic/charts";
5
+ const b = () => ({
6
+ selectedBlockClientId: "qwu2",
7
+ currentPageContent: [
8
+ {
9
+ name: "core/post-content",
10
+ type: "content",
11
+ clientId: "kgrq",
12
+ innerBlocks: [
13
+ {
14
+ clientId: "hac1",
15
+ name: "core/group",
16
+ isValid: !0,
17
+ originalContent: '<div class="wp-block-group alignfull is-style-section-default" id="intro-section" style="margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40)"></div>',
18
+ validationIssues: [],
19
+ attributes: {
20
+ tagName: "div",
21
+ metadata: {
22
+ name: "Introduction",
23
+ patternCategory: "intro",
24
+ remotePatternId: 14040,
25
+ reason: "Creates a strong first impression by highlighting Mama's Bread's reputation and inviting customers to discover more. Features key imagery. "
26
+ },
27
+ align: "full",
28
+ className: "is-style-section-default",
29
+ style: {
30
+ spacing: {
31
+ margin: {
32
+ top: "0",
33
+ bottom: "0"
34
+ },
35
+ padding: {
36
+ top: "var:preset|spacing|40",
37
+ bottom: "var:preset|spacing|40"
38
+ }
39
+ }
40
+ },
41
+ layout: {
42
+ type: "constrained",
43
+ justifyContent: "center"
44
+ },
45
+ anchor: "intro-section"
46
+ },
47
+ innerBlocks: [
48
+ {
49
+ clientId: "XfP9",
50
+ name: "core/group",
51
+ isValid: !0,
52
+ originalContent: `<div class="wp-block-group alignwide">
53
+
54
+ </div>`,
55
+ validationIssues: [],
56
+ attributes: {
57
+ tagName: "div",
58
+ metadata: {
59
+ name: "Container"
60
+ },
61
+ align: "wide",
62
+ style: {
63
+ spacing: {
64
+ blockGap: "var:preset|spacing|40"
65
+ }
66
+ },
67
+ layout: {
68
+ type: "constrained"
69
+ }
70
+ },
71
+ innerBlocks: [
72
+ {
73
+ clientId: "bo18",
74
+ name: "core/columns",
75
+ isValid: !0,
76
+ originalContent: `<div class="wp-block-columns alignwide are-vertically-aligned-top">
77
+
78
+ </div>`,
79
+ validationIssues: [],
80
+ attributes: {
81
+ verticalAlignment: "top",
82
+ isStackedOnMobile: !0,
83
+ align: "wide",
84
+ style: {
85
+ spacing: {
86
+ blockGap: {
87
+ top: "var:preset|spacing|30"
88
+ }
89
+ }
90
+ }
91
+ },
92
+ innerBlocks: [
93
+ {
94
+ clientId: "B0cB",
95
+ name: "core/column",
96
+ isValid: !0,
97
+ originalContent: '<div class="wp-block-column is-vertically-aligned-top"></div>',
98
+ validationIssues: [],
99
+ attributes: {
100
+ verticalAlignment: "top",
101
+ width: "",
102
+ layout: {
103
+ type: "constrained",
104
+ justifyContent: "left",
105
+ contentSize: "480px"
106
+ }
107
+ },
108
+ innerBlocks: [
109
+ {
110
+ clientId: "2Vj9",
111
+ name: "core/heading",
112
+ isValid: !0,
113
+ originalContent: `<h2 class="wp-block-heading">Welcome to Oakland's Favorite Bakery</h2>`,
114
+ validationIssues: [],
115
+ attributes: {
116
+ content: "Welcome to Oakland's Favorite Bakery",
117
+ level: 2
118
+ },
119
+ innerBlocks: []
120
+ }
121
+ ]
122
+ },
123
+ {
124
+ clientId: "KHCI",
125
+ name: "core/column",
126
+ isValid: !0,
127
+ originalContent: `<div class="wp-block-column is-vertically-aligned-top" style="flex-basis:40%">
128
+
129
+ </div>`,
130
+ validationIssues: [],
131
+ attributes: {
132
+ verticalAlignment: "top",
133
+ width: "40%"
134
+ },
135
+ innerBlocks: [
136
+ {
137
+ clientId: "qwu2",
138
+ name: "core/paragraph",
139
+ isValid: !0,
140
+ originalContent: "<p>Discover why Mama's Bread is celebrated for its fresh, artisanal bread crafted with passion and tradition. Join us and taste the difference.</p>",
141
+ validationIssues: [],
142
+ attributes: {
143
+ content: "Discover why Mama's Bread is celebrated for its fresh, artisanal bread crafted with passion and tradition. Join us and taste the difference.",
144
+ dropCap: !1
145
+ },
146
+ innerBlocks: []
147
+ },
148
+ {
149
+ clientId: "o-IA",
150
+ name: "core/buttons",
151
+ isValid: !0,
152
+ originalContent: '<div class="wp-block-buttons"></div>',
153
+ validationIssues: [],
154
+ attributes: {},
155
+ innerBlocks: [
156
+ {
157
+ clientId: "wsbN",
158
+ name: "core/button",
159
+ isValid: !0,
160
+ originalContent: '<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="menu">Menu</a></div>',
161
+ validationIssues: [],
162
+ attributes: {
163
+ tagName: "a",
164
+ type: "button",
165
+ url: "menu",
166
+ text: "Menu"
167
+ },
168
+ innerBlocks: []
169
+ }
170
+ ]
171
+ }
172
+ ]
173
+ }
174
+ ]
175
+ },
176
+ {
177
+ clientId: "K9PG",
178
+ name: "core/image",
179
+ isValid: !0,
180
+ originalContent: '<figure class="wp-block-image alignwide size-full aspect-16/9"><img src="http://localhost:8888/wp-content/uploads/2025/05/image-pexels-1055271.jpg" alt="bakery" class="wp-image-145"/></figure>',
181
+ validationIssues: [],
182
+ attributes: {
183
+ url: "http://localhost:8888/wp-content/uploads/2025/05/image-pexels-1055271.jpg",
184
+ alt: "bakery",
185
+ caption: "",
186
+ id: 145,
187
+ sizeSlug: "full",
188
+ linkDestination: "none",
189
+ align: "wide",
190
+ className: "aspect-16/9"
191
+ },
192
+ innerBlocks: []
193
+ }
194
+ ]
195
+ }
196
+ ]
197
+ }
198
+ ]
199
+ }
200
+ ]
201
+ }), h = (i) => ({
202
+ getAvailableTools: async () => [
203
+ {
204
+ id: "display_graph",
205
+ name: "Sales Graph Display",
206
+ description: "Displays a sales graph for products with interactive visualization. Use when users ask to see sales data, product performance, or graphical representations of sales metrics. Just make up random data",
207
+ input_schema: {
208
+ type: "object",
209
+ properties: {
210
+ title: {
211
+ type: "string",
212
+ description: 'The title for the graph (e.g., "Top 5 Products by Sales")'
213
+ },
214
+ timeframe: {
215
+ type: "string",
216
+ description: 'Optional timeframe description (e.g., "Last 30 days", "Q3 2024")'
217
+ },
218
+ data: {
219
+ type: "array",
220
+ description: "Array of sales data for products",
221
+ items: {
222
+ type: "object",
223
+ properties: {
224
+ product: {
225
+ type: "string",
226
+ description: "Product name"
227
+ },
228
+ sales: {
229
+ type: "number",
230
+ description: "Number of sales/units sold"
231
+ }
232
+ },
233
+ required: ["product", "sales"]
234
+ }
235
+ }
236
+ },
237
+ required: ["title", "data"]
238
+ }
239
+ }
240
+ ],
241
+ executeTool: async (t, e, n, s) => {
242
+ switch (console.log(`Executing tool: ${t}`, {
243
+ args: e,
244
+ messageId: n,
245
+ toolCallId: s
246
+ }), t) {
247
+ case "display_graph":
248
+ if (!e.title || !e.data)
249
+ return {
250
+ result: "Error: Title and data are required for graph display",
251
+ returnToAgent: !0
252
+ };
253
+ const { MockSalesGraph: a } = await Promise.resolve().then(() => d);
254
+ return i({
255
+ id: crypto.randomUUID(),
256
+ role: "agent",
257
+ content: [
258
+ {
259
+ type: "component",
260
+ component: a,
261
+ componentProps: {
262
+ title: e.title,
263
+ data: e.data,
264
+ timeframe: e.timeframe
265
+ }
266
+ }
267
+ ],
268
+ timestamp: Date.now(),
269
+ archived: !1,
270
+ showIcon: !0
271
+ }), {
272
+ result: `Graph displayed: ${e.title} with ${e.data.length} data points`,
273
+ returnToAgent: !1
274
+ };
275
+ }
276
+ }
277
+ }), c = ({
278
+ title: i,
279
+ data: t,
280
+ timeframe: e
281
+ }) => {
282
+ const n = [
283
+ {
284
+ name: i,
285
+ label: i,
286
+ // SeriesData requires a label property
287
+ data: t.map((a) => ({
288
+ label: a.product,
289
+ value: a.sales
290
+ }))
291
+ }
292
+ ], s = t.reduce((a, o) => a + o.sales, 0);
293
+ return Math.round(s / t.length), /* @__PURE__ */ r.jsx(
294
+ l,
295
+ {
296
+ data: n,
297
+ mode: "item-comparison",
298
+ truncateLabels: !0,
299
+ maxLabelLength: 15,
300
+ showLegend: !1
301
+ }
302
+ );
303
+ }, d = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
304
+ __proto__: null,
305
+ MockSalesGraph: c
306
+ }, Symbol.toStringTag, { value: "Module" }));
307
+ export {
308
+ c as MockSalesGraph,
309
+ b as getClientContext,
310
+ h as getClientTools
311
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/agenttic-client",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "type": "module",
5
5
  "description": "A TypeScript client library for A2A (Agent2Agent) protocol communication",
6
6
  "main": "dist/index.js",
@@ -37,16 +37,17 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@wordpress/api-fetch": "^7.0.0",
40
- "tsup": "^8.0.0",
40
+ "autoprefixer": "^10.4.0",
41
41
  "typescript": "^5.0.0",
42
42
  "unified": "^11.0.5",
43
+ "vite": "^5.0.0",
44
+ "vite-plugin-lib-inject-css": "^2.2.2",
43
45
  "vitest": "^1.0.0"
44
46
  },
45
47
  "dependencies": {
46
48
  "@automattic/charts": ">=0.14.0 <1.0.0",
47
49
  "@types/react": "^18.0.0",
48
50
  "@visx/xychart": "^3.12.0",
49
- "@wordpress/element": "^6.2.0",
50
51
  "@wordpress/i18n": "^6.1.0",
51
52
  "react": "^18.0.0",
52
53
  "react-markdown": "^10.1.0",
@@ -67,10 +68,8 @@
67
68
  "branch": "trunk"
68
69
  },
69
70
  "scripts": {
70
- "build": "pnpm run clean && tsup src/index.ts src/mocks/index.ts --format esm --target node18 && tsc --project tsconfig.json --emitDeclarationOnly",
71
- "build:no-splitting": "pnpm run clean && tsup src/index.ts --format esm --target node18 --splitting=false && tsc --project tsconfig.json --emitDeclarationOnly",
72
- "dev": "tsup src/index.ts --format esm --watch",
73
- "dev:no-splitting": "tsup src/index.ts --format esm --target node18 --splitting=false --watch",
71
+ "build": "pnpm run clean && vite build && tsc --project tsconfig.json --emitDeclarationOnly",
72
+ "dev": "vite build --watch",
74
73
  "clean": "rm -rf dist",
75
74
  "type-check": "tsc --noEmit",
76
75
  "lint": "wp-scripts lint-js src --ext .ts,.tsx",
@@ -1,7 +0,0 @@
1
- import {
2
- MockSalesGraph
3
- } from "./chunk-ZDG7Y2LU.js";
4
- import "./chunk-LAB4XYXR.js";
5
- export {
6
- MockSalesGraph
7
- };