@automattic/agenttic-client 0.1.23 → 0.1.25

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EACN,YAAY,EAEZ,OAAO,EACP,iBAAiB,EAEjB,UAAU,EAIV,MAAM,eAAe,CAAC;AAuLvB;;GAEG;AACH,iBAAS,uBAAuB,IAAI,IAAI,CAEvC;AAED;;;;GAIG;AACH,iBAAS,qCAAqC,CAAE,WAAW,EAAE,GAAG,EAAE,GAAI,GAAG,EAAE,CA4B1E;AAkED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAE,OAAO,EAAE,OAAO,GAAI,OAAO,EAAE,CAmDxE;AA2kBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EAAE,qCAAqC,EAAE,uBAAuB,EAAE,CAAC;AAE1E,wBAAgB,YAAY,CAAE,MAAM,EAAE,YAAY,GAAI,MAAM,CAuV3D;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,iBAAiB,GACvB,OAAO,CAAE,UAAU,CAAE,CAavB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EACN,YAAY,EAEZ,OAAO,EACP,iBAAiB,EAEjB,UAAU,EAIV,MAAM,eAAe,CAAC;AAuMvB;;GAEG;AACH,iBAAS,uBAAuB,IAAI,IAAI,CAEvC;AAED;;;;GAIG;AACH,iBAAS,qCAAqC,CAAE,WAAW,EAAE,GAAG,EAAE,GAAI,GAAG,EAAE,CA4B1E;AAkED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAE,OAAO,EAAE,OAAO,GAAI,OAAO,EAAE,CAmDxE;AA2kBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EAAE,qCAAqC,EAAE,uBAAuB,EAAE,CAAC;AAE1E,wBAAgB,YAAY,CAAE,MAAM,EAAE,YAAY,GAAI,MAAM,CAuV3D;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,iBAAiB,GACvB,OAAO,CAAE,UAAU,CAAE,CAavB"}
package/dist/index.js CHANGED
@@ -24,18 +24,18 @@ function ot({
24
24
  const o = [];
25
25
  if (t)
26
26
  try {
27
- const l = await t();
28
- o.push(...l);
29
- } catch (l) {
30
- v("Error getting available tools: %O", l);
27
+ const c = await t();
28
+ o.push(...c);
29
+ } catch (c) {
30
+ v("Error getting available tools: %O", c);
31
31
  }
32
32
  return o;
33
33
  }, [t]), n = $(
34
- async (o, l) => {
34
+ async (o, c) => {
35
35
  if (!e)
36
36
  throw new Error("No executeTool callback provided");
37
37
  try {
38
- return await e(o, l);
38
+ return await e(o, c);
39
39
  } catch (i) {
40
40
  throw v("Error executing tool %s: %O", o, i), i;
41
41
  }
@@ -288,55 +288,55 @@ function jt(t, e = "") {
288
288
  `
289
289
  `,
290
290
  o
291
- ), m = i === -1 ? a.substring(o) : a.substring(o, i);
292
- if (m.startsWith("data:"))
291
+ ), l = i === -1 ? a.substring(o) : a.substring(o, i);
292
+ if (l.startsWith("data:"))
293
293
  n !== "" && (n += `
294
- `), n += m.substring(
295
- m.startsWith("data: ") ? 6 : 5
294
+ `), n += l.substring(
295
+ l.startsWith("data: ") ? 6 : 5
296
296
  );
297
- else if (m.trim() === "" && n) {
297
+ else if (l.trim() === "" && n) {
298
298
  try {
299
299
  s.push(JSON.parse(n)), r = i === -1 ? a.length : i + 1;
300
- } catch (g) {
301
- v("Failed to parse SSE event: %o", g), v("Problematic payload: %s", n);
300
+ } catch (f) {
301
+ v("Failed to parse SSE event: %o", f), v("Problematic payload: %s", n);
302
302
  }
303
303
  n = "";
304
304
  }
305
305
  i === -1 ? o = a.length : o = i + 1;
306
306
  }
307
- const l = a.substring(r);
308
- return { events: s, nextBuffer: l };
307
+ const c = a.substring(r);
308
+ return { events: s, nextBuffer: c };
309
309
  }
310
310
  async function* Jt(t, e = {}) {
311
- var m, g, h;
311
+ var l, f, h;
312
312
  const { supportDeltas: s = !1 } = e, a = t.getReader(), n = new TextDecoder();
313
313
  let r = "";
314
314
  const o = new Kt();
315
- let l = null, i = null;
315
+ let c = null, i = null;
316
316
  try {
317
317
  for (; ; ) {
318
- const { done: f, value: p } = await a.read();
319
- if (f)
318
+ const { done: m, value: p } = await a.read();
319
+ if (m)
320
320
  break;
321
- const S = n.decode(p, { stream: !0 }), { events: c, nextBuffer: u } = jt(S, r);
322
- if (c && Array.isArray(c))
323
- for (let w = 0; w < c.length; w++) {
324
- const d = c[w];
325
- if (w > 0 && d.method === "message/delta" && typeof requestAnimationFrame < "u" && await new Promise((y) => {
321
+ const S = n.decode(p, { stream: !0 }), { events: u, nextBuffer: d } = jt(S, r);
322
+ if (u && Array.isArray(u))
323
+ for (let w = 0; w < u.length; w++) {
324
+ const g = u[w];
325
+ if (w > 0 && g.method === "message/delta" && typeof requestAnimationFrame < "u" && await new Promise((y) => {
326
326
  requestAnimationFrame(() => y(void 0));
327
- }), d.error)
327
+ }), g.error)
328
328
  throw new Error(
329
- `Streaming error: ${d.error.message}`
329
+ `Streaming error: ${g.error.message}`
330
330
  );
331
- if (s && d.method === "message/delta" && ((m = d.params) != null && m.delta)) {
332
- const y = d.params.delta;
331
+ if (s && g.method === "message/delta" && ((l = g.params) != null && l.delta)) {
332
+ const y = g.params.delta;
333
333
  try {
334
334
  if (y.deltaType === "content" && (o.processContentDelta(
335
335
  y.content
336
- ), !l && d.params.id && (l = d.params.id), l)) {
336
+ ), !c && g.params.id && (c = g.params.id), c)) {
337
337
  const x = o.getCurrentMessage();
338
338
  yield {
339
- id: l,
339
+ id: c,
340
340
  status: {
341
341
  state: "working",
342
342
  message: x
@@ -348,29 +348,29 @@ async function* Jt(t, e = {}) {
348
348
  } catch (x) {
349
349
  v("Failed to process delta: %o", x);
350
350
  }
351
- } else d.result && d.result.status ? (l = d.result.id, i = d.result.status, (o.getTextContent() || o.getCurrentMessage().parts.length > 0) && o.reset(), yield {
352
- id: d.result.id,
353
- status: d.result.status,
354
- final: d.result.status.state === "completed" || d.result.status.state === "failed" || d.result.status.state === "canceled",
351
+ } else g.result && g.result.status ? (c = g.result.id, i = g.result.status, (o.getTextContent() || o.getCurrentMessage().parts.length > 0) && o.reset(), yield {
352
+ id: g.result.id,
353
+ status: g.result.status,
354
+ final: g.result.status.state === "completed" || g.result.status.state === "failed" || g.result.status.state === "canceled",
355
355
  text: D(
356
- ((g = d.result.status) == null ? void 0 : g.message) || {
356
+ ((f = g.result.status) == null ? void 0 : f.message) || {
357
357
  role: "agent",
358
358
  parts: []
359
359
  }
360
360
  )
361
- }) : d.id && d.result && (l = d.result.id, d.result.status && (yield {
362
- id: d.result.id,
363
- status: d.result.status,
364
- final: d.result.status.state === "completed" || d.result.status.state === "failed" || d.result.status.state === "canceled",
361
+ }) : g.id && g.result && (c = g.result.id, g.result.status && (yield {
362
+ id: g.result.id,
363
+ status: g.result.status,
364
+ final: g.result.status.state === "completed" || g.result.status.state === "failed" || g.result.status.state === "canceled",
365
365
  text: D(
366
- ((h = d.result.status) == null ? void 0 : h.message) || {
366
+ ((h = g.result.status) == null ? void 0 : h.message) || {
367
367
  role: "agent",
368
368
  parts: []
369
369
  }
370
370
  )
371
371
  }));
372
372
  }
373
- r = u;
373
+ r = d;
374
374
  }
375
375
  } finally {
376
376
  a.releaseLock();
@@ -526,51 +526,51 @@ function Mt(t, e, s) {
526
526
  };
527
527
  }
528
528
  async function X(t, e, s, a, n, r) {
529
- const { message: o, sessionId: l, taskId: i, metadata: m } = t, { agentId: g, agentUrl: h, authProvider: f, proxy: p } = e, { isStreaming: S = !1, enableTokenStreaming: c = !1 } = s, u = l || r, w = Vt(h, g), d = await Ut(
529
+ const { message: o, sessionId: c, taskId: i, metadata: l } = t, { agentId: f, agentUrl: h, authProvider: m, proxy: p } = e, { isStreaming: S = !1, enableTokenStreaming: u = !1 } = s, d = c || r, w = Vt(h, f), g = await Ut(
530
530
  o,
531
531
  a,
532
532
  n
533
533
  ), y = Nt(
534
534
  {
535
535
  id: i,
536
- sessionId: u,
537
- message: d,
538
- metadata: m
536
+ sessionId: d,
537
+ message: g,
538
+ metadata: l
539
539
  },
540
540
  S ? "message/stream" : "message/send",
541
- c && S
541
+ u && S
542
542
  // Only enable token streaming if using SSE
543
- ), x = await zt(f, S);
543
+ ), x = await zt(m, S);
544
544
  return Bt("POST", w, x, y), {
545
545
  request: y,
546
546
  headers: x,
547
- enhancedMessage: d,
548
- effectiveSessionId: u,
547
+ enhancedMessage: g,
548
+ effectiveSessionId: d,
549
549
  fullAgentUrl: w
550
550
  };
551
551
  }
552
552
  async function At(t, e, s = {}) {
553
- const { request: a, headers: n, fullAgentUrl: r } = t, { timeout: o } = e, { abortSignal: l } = s, { timeoutId: i, controller: m } = xt(
553
+ const { request: a, headers: n, fullAgentUrl: r } = t, { timeout: o } = e, { abortSignal: c } = s, { timeoutId: i, controller: l } = xt(
554
554
  o,
555
555
  "request"
556
- ), g = l ? bt(m.signal, l) : m.signal;
556
+ ), f = c ? bt(l.signal, c) : l.signal;
557
557
  try {
558
558
  const h = Mt(
559
559
  n,
560
560
  JSON.stringify(a),
561
- g
561
+ f
562
562
  );
563
563
  v("Making request to %s with options: %O", r, {
564
564
  method: h.method,
565
565
  headers: h.headers
566
566
  });
567
- const f = await fetch(r, h);
568
- clearTimeout(i), Ct(f, "request");
569
- const p = await f.json();
567
+ const m = await fetch(r, h);
568
+ clearTimeout(i), Ct(m, "request");
569
+ const p = await m.json();
570
570
  return v(
571
571
  "Response from %s: %d %O",
572
572
  r,
573
- f.status,
573
+ m.status,
574
574
  wt(p)
575
575
  ), Lt(p, "request");
576
576
  } catch (h) {
@@ -580,24 +580,24 @@ async function At(t, e, s = {}) {
580
580
  async function* St(t, e, s) {
581
581
  const { request: a, headers: n, fullAgentUrl: r } = t, {
582
582
  streamingTimeout: o = 6e4,
583
- abortSignal: l,
583
+ abortSignal: c,
584
584
  enableTokenStreaming: i = !1
585
- } = s, { timeoutId: m, controller: g } = xt(
585
+ } = s, { timeoutId: l, controller: f } = xt(
586
586
  o,
587
587
  "streaming request"
588
- ), h = l ? bt(g.signal, l) : g.signal;
588
+ ), h = c ? bt(f.signal, c) : f.signal;
589
589
  try {
590
- const f = JSON.stringify(a), p = Mt(n, f, h), S = await fetch(r, p);
591
- if (clearTimeout(m), Wt(S, "streaming request"), !S.body)
590
+ const m = JSON.stringify(a), p = Mt(n, m, h), S = await fetch(r, p);
591
+ if (clearTimeout(l), Wt(S, "streaming request"), !S.body)
592
592
  throw new Error(
593
593
  "Response body is null - server may not support streaming"
594
594
  );
595
- const c = i && a.tokenStreaming === !0;
595
+ const u = i && a.tokenStreaming === !0;
596
596
  yield* Jt(S.body, {
597
- supportDeltas: c
597
+ supportDeltas: u
598
598
  });
599
- } catch (f) {
600
- Tt(f, m, "streaming request");
599
+ } catch (m) {
600
+ Tt(m, l, "streaming request");
601
601
  }
602
602
  }
603
603
  const Qt = 12e4;
@@ -606,11 +606,21 @@ async function G(t, e, s, a, n) {
606
606
  const r = await t.getAbilities();
607
607
  if (r.length > 0)
608
608
  for (const o of r) {
609
- const l = o.name.replace(/\//g, "__").replace(/-/g, "_");
610
- if (e === l || e === o.name) {
609
+ const c = o.name.replace(/\//g, "__").replace(/-/g, "_");
610
+ if (e === c || e === o.name) {
611
611
  if (o.callback)
612
612
  try {
613
- return { result: await o.callback(s), returnToAgent: !0 };
613
+ const i = {
614
+ ...s,
615
+ ...a && { messageId: a }
616
+ }, l = await o.callback(i);
617
+ return {
618
+ result: l,
619
+ returnToAgent: (l == null ? void 0 : l.returnToAgent) !== void 0 ? l.returnToAgent : !0,
620
+ ...(l == null ? void 0 : l.agentMessage) && {
621
+ agentMessage: l.agentMessage
622
+ }
623
+ };
614
624
  } catch (i) {
615
625
  return v(
616
626
  "Error executing ability %s: %O",
@@ -705,29 +715,29 @@ async function vt(t, e, s) {
705
715
  const a = [], n = [];
706
716
  let r = !1;
707
717
  for (const o of t) {
708
- const { toolCallId: l, toolId: i, arguments: m } = o.data;
718
+ const { toolCallId: c, toolId: i, arguments: l } = o.data;
709
719
  try {
710
- const g = await G(
720
+ const f = await G(
711
721
  e,
712
722
  i,
713
- m,
723
+ l,
714
724
  s,
715
- l
716
- ), { result: h, returnToAgent: f, agentMessage: p } = it(g);
717
- f && (r = !0), p && n.push(W(p)), a.push(
725
+ c
726
+ ), { result: h, returnToAgent: m, agentMessage: p } = it(f);
727
+ m && (r = !0), p && n.push(W(p)), a.push(
718
728
  j(
719
- l,
729
+ c,
720
730
  i,
721
731
  h
722
732
  )
723
733
  );
724
- } catch (g) {
734
+ } catch (f) {
725
735
  r = !0, a.push(
726
736
  j(
727
- l,
737
+ c,
728
738
  i,
729
739
  void 0,
730
- g instanceof Error ? g.message : String(g)
740
+ f instanceof Error ? f.message : String(f)
731
741
  )
732
742
  );
733
743
  }
@@ -765,27 +775,27 @@ async function et(t, e, s, a, n, r, o) {
765
775
  abortSignal: o
766
776
  });
767
777
  }
768
- async function ft(t, e, s, a, n, r, o, l, i = []) {
769
- const m = {
778
+ async function ft(t, e, s, a, n, r, o, c, i = []) {
779
+ const l = {
770
780
  message: e,
771
781
  taskId: t,
772
782
  sessionId: void 0
773
783
  // Use task's session
774
- }, g = l || { isStreaming: !0 }, h = await X(
775
- m,
784
+ }, f = c || { isStreaming: !0 }, h = await X(
785
+ l,
776
786
  s,
777
787
  {
778
- ...g
788
+ ...f
779
789
  },
780
790
  a,
781
791
  n,
782
792
  r
783
- ), f = St(h, s, {
784
- ...g,
793
+ ), m = St(h, s, {
794
+ ...f,
785
795
  abortSignal: o
786
796
  });
787
797
  return kt(
788
- f,
798
+ m,
789
799
  a,
790
800
  n,
791
801
  s,
@@ -795,12 +805,12 @@ async function ft(t, e, s, a, n, r, o, l, i = []) {
795
805
  i,
796
806
  // preserve conversation parts across continuation
797
807
  o,
798
- g
808
+ f
799
809
  // Pass through the same request options
800
810
  );
801
811
  }
802
- async function* kt(t, e, s, a, n, r = !0, o = [], l, i) {
803
- var m, g, h, f, p, S, c, u, w, d, y, x;
812
+ async function* kt(t, e, s, a, n, r = !0, o = [], c, i) {
813
+ var l, f, h, m, p, S, u, d, w, g, y, x;
804
814
  for await (const I of t) {
805
815
  if (yield I, I.status.state === "running" && I.status.message && e && await Xt(
806
816
  e,
@@ -815,7 +825,7 @@ async function* kt(t, e, s, a, n, r = !0, o = [], l, i) {
815
825
  e,
816
826
  k,
817
827
  M,
818
- (g = (m = I.status) == null ? void 0 : m.message) == null ? void 0 : g.messageId,
828
+ (f = (l = I.status) == null ? void 0 : l.message) == null ? void 0 : f.messageId,
819
829
  b
820
830
  ).catch((C) => {
821
831
  v("Tool execution failed for %s: %O", k, C);
@@ -855,7 +865,7 @@ async function* kt(t, e, s, a, n, r = !0, o = [], l, i) {
855
865
  e,
856
866
  q,
857
867
  _,
858
- (f = (h = I.status) == null ? void 0 : h.message) == null ? void 0 : f.messageId,
868
+ (m = (h = I.status) == null ? void 0 : h.message) == null ? void 0 : m.messageId,
859
869
  A
860
870
  ), { result: R, returnToAgent: O, agentMessage: J } = it(E);
861
871
  if (O && (b = !0), J && M.push(
@@ -923,7 +933,7 @@ async function* kt(t, e, s, a, n, r = !0, o = [], l, i) {
923
933
  e,
924
934
  s,
925
935
  n,
926
- l,
936
+ c,
927
937
  i,
928
938
  o
929
939
  );
@@ -948,7 +958,7 @@ async function* kt(t, e, s, a, n, r = !0, o = [], l, i) {
948
958
  }
949
959
  )
950
960
  }; E.length > 0; ) {
951
- (c = R.status) != null && c.message && o.push(
961
+ (u = R.status) != null && u.message && o.push(
952
962
  R.status.message
953
963
  );
954
964
  const {
@@ -957,7 +967,7 @@ async function* kt(t, e, s, a, n, r = !0, o = [], l, i) {
957
967
  } = await vt(
958
968
  E,
959
969
  e,
960
- (w = (u = R.status) == null ? void 0 : u.message) == null ? void 0 : w.messageId
970
+ (w = (d = R.status) == null ? void 0 : d.message) == null ? void 0 : w.messageId
961
971
  );
962
972
  if (O.length > 0 && (yield {
963
973
  id: R.id,
@@ -986,7 +996,7 @@ async function* kt(t, e, s, a, n, r = !0, o = [], l, i) {
986
996
  e,
987
997
  s,
988
998
  n,
989
- l,
999
+ c,
990
1000
  i,
991
1001
  o
992
1002
  );
@@ -997,7 +1007,7 @@ async function* kt(t, e, s, a, n, r = !0, o = [], l, i) {
997
1007
  throw new Error(
998
1008
  "Continue task stream ended without final result"
999
1009
  );
1000
- R = H, E = (d = R.status) != null && d.message ? F(
1010
+ R = H, E = (g = R.status) != null && g.message ? F(
1001
1011
  R.status.message
1002
1012
  ) : [], E.length > 0 && (yield {
1003
1013
  id: R.id,
@@ -1062,40 +1072,40 @@ function Zt(t) {
1062
1072
  defaultSessionId: n,
1063
1073
  timeout: r = Qt,
1064
1074
  toolProvider: o,
1065
- contextProvider: l,
1075
+ contextProvider: c,
1066
1076
  enableStreaming: i = !1
1067
- } = t, m = {
1077
+ } = t, l = {
1068
1078
  agentId: e,
1069
1079
  agentUrl: s,
1070
1080
  authProvider: a,
1071
1081
  timeout: r
1072
1082
  };
1073
1083
  return {
1074
- async sendMessage(g) {
1075
- var d, y;
1076
- const { abortSignal: h } = g, f = g.sessionId || n || void 0, p = [];
1077
- p.push(g.message);
1084
+ async sendMessage(f) {
1085
+ var g, y;
1086
+ const { abortSignal: h } = f, m = f.sessionId || n || void 0, p = [];
1087
+ p.push(f.message);
1078
1088
  const S = await X(
1079
- g,
1080
- m,
1089
+ f,
1090
+ l,
1081
1091
  { isStreaming: !1 },
1082
1092
  o,
1083
- l,
1084
- f
1093
+ c,
1094
+ m
1085
1095
  );
1086
- let c = await At(
1096
+ let u = await At(
1087
1097
  S,
1088
- m,
1098
+ l,
1089
1099
  { abortSignal: h }
1090
1100
  );
1091
- const u = [], w = [];
1092
- for (; c.status.message && o; ) {
1101
+ const d = [], w = [];
1102
+ for (; u.status.message && o; ) {
1093
1103
  const x = F(
1094
- c.status.message
1104
+ u.status.message
1095
1105
  );
1096
1106
  if (x.length === 0)
1097
1107
  break;
1098
- u.push(...x);
1108
+ d.push(...x);
1099
1109
  const I = [];
1100
1110
  let P = !1;
1101
1111
  for (const T of x) {
@@ -1118,7 +1128,7 @@ function Zt(t) {
1118
1128
  k,
1119
1129
  A
1120
1130
  );
1121
- I.push(E), u.push(E);
1131
+ I.push(E), d.push(E);
1122
1132
  } catch (C) {
1123
1133
  const A = j(
1124
1134
  b,
@@ -1126,32 +1136,32 @@ function Zt(t) {
1126
1136
  void 0,
1127
1137
  C instanceof Error ? C.message : String(C)
1128
1138
  );
1129
- I.push(A), u.push(A);
1139
+ I.push(A), d.push(A);
1130
1140
  }
1131
1141
  }
1132
- if (p.push(c.status.message), P) {
1142
+ if (p.push(u.status.message), P) {
1133
1143
  const T = Q(I);
1134
- c = await et(
1135
- c.id,
1144
+ u = await et(
1145
+ u.id,
1136
1146
  T,
1137
- m,
1138
- o,
1139
1147
  l,
1140
- f,
1148
+ o,
1149
+ c,
1150
+ m,
1141
1151
  h
1142
1152
  );
1143
1153
  } else
1144
1154
  break;
1145
1155
  }
1146
- if (u.length > 0 && (d = c.status) != null && d.message) {
1156
+ if (d.length > 0 && (g = u.status) != null && g.message) {
1147
1157
  const x = {
1148
- ...c.status.message,
1149
- parts: u
1158
+ ...u.status.message,
1159
+ parts: d
1150
1160
  };
1151
- c = {
1152
- ...c,
1161
+ u = {
1162
+ ...u,
1153
1163
  status: {
1154
- ...c.status,
1164
+ ...u.status,
1155
1165
  message: x
1156
1166
  }
1157
1167
  };
@@ -1159,7 +1169,7 @@ function Zt(t) {
1159
1169
  if (w.length > 0) {
1160
1170
  const x = w.map((P) => D(P)).join(" "), I = W(x);
1161
1171
  return {
1162
- ...c,
1172
+ ...u,
1163
1173
  // Keep the enhanced message with tool results
1164
1174
  // The agent message will be handled separately by the caller
1165
1175
  text: x,
@@ -1168,94 +1178,94 @@ function Zt(t) {
1168
1178
  };
1169
1179
  }
1170
1180
  return {
1171
- ...c,
1181
+ ...u,
1172
1182
  text: D(
1173
- ((y = c.status) == null ? void 0 : y.message) || {
1183
+ ((y = u.status) == null ? void 0 : y.message) || {
1174
1184
  parts: [],
1175
1185
  messageId: N()
1176
1186
  }
1177
1187
  )
1178
1188
  };
1179
1189
  },
1180
- async *sendMessageStream(g) {
1190
+ async *sendMessageStream(f) {
1181
1191
  const {
1182
1192
  withHistory: h = !0,
1183
- abortSignal: f,
1193
+ abortSignal: m,
1184
1194
  enableStreaming: p
1185
- } = g, S = g.sessionId || n || void 0, c = p ?? i, u = [];
1186
- u.push(g.message);
1195
+ } = f, S = f.sessionId || n || void 0, u = p ?? i, d = [];
1196
+ d.push(f.message);
1187
1197
  const w = await X(
1188
- g,
1189
- m,
1198
+ f,
1199
+ l,
1190
1200
  {
1191
1201
  isStreaming: !0,
1192
1202
  // Always use message/stream endpoint for SSE
1193
- enableTokenStreaming: c
1203
+ enableTokenStreaming: u
1194
1204
  },
1195
1205
  o,
1196
- l,
1206
+ c,
1197
1207
  S
1198
- ), d = St(
1208
+ ), g = St(
1199
1209
  w,
1200
- m,
1210
+ l,
1201
1211
  {
1202
- enableTokenStreaming: c,
1212
+ enableTokenStreaming: u,
1203
1213
  // Token streaming is optional
1204
1214
  streamingTimeout: r,
1205
- abortSignal: f
1215
+ abortSignal: m
1206
1216
  }
1207
1217
  );
1208
1218
  yield* kt(
1209
- d,
1219
+ g,
1210
1220
  o,
1221
+ c,
1211
1222
  l,
1212
- m,
1213
1223
  S,
1214
1224
  h,
1215
- u,
1216
- f,
1225
+ d,
1226
+ m,
1217
1227
  {
1218
1228
  isStreaming: !0,
1219
- enableTokenStreaming: c,
1229
+ enableTokenStreaming: u,
1220
1230
  streamingTimeout: r
1221
1231
  }
1222
1232
  );
1223
1233
  },
1224
- async continueTask(g, h, f) {
1225
- var u;
1234
+ async continueTask(f, h, m) {
1235
+ var d;
1226
1236
  const p = nt(h);
1227
- let c = await et(
1228
- g,
1237
+ let u = await et(
1238
+ f,
1229
1239
  p,
1230
- m,
1231
- o,
1232
1240
  l,
1233
- f
1241
+ o,
1242
+ c,
1243
+ m
1234
1244
  );
1235
- for (; c.status.state === "input-required" && c.status.message && o; ) {
1245
+ for (; u.status.state === "input-required" && u.status.message && o; ) {
1236
1246
  const w = F(
1237
- c.status.message
1247
+ u.status.message
1238
1248
  );
1239
1249
  if (w.length === 0)
1240
1250
  break;
1241
- const { results: d, shouldReturnToAgent: y } = await vt(w, o);
1251
+ const { results: g, shouldReturnToAgent: y } = await vt(w, o);
1242
1252
  if (y) {
1243
- const x = Q(d);
1244
- c = await et(
1245
- c.id,
1253
+ const x = Q(g);
1254
+ u = await et(
1255
+ u.id,
1246
1256
  x,
1247
- m,
1248
- o,
1249
1257
  l,
1250
- f
1258
+ o,
1259
+ c,
1260
+ m
1251
1261
  );
1252
1262
  } else
1253
1263
  break;
1254
1264
  }
1255
1265
  return {
1256
- ...c,
1266
+ ...u,
1257
1267
  text: D(
1258
- ((u = c.status) == null ? void 0 : u.message) || {
1268
+ ((d = u.status) == null ? void 0 : d.message) || {
1259
1269
  parts: [],
1260
1270
  messageId: N()
1261
1271
  }
@@ -1272,33 +1282,33 @@ function Zt(t) {
1272
1282
  }
1273
1283
  const ct = "a8c_agenttic_conversation_history";
1274
1284
  function te(t) {
1275
- var g, h;
1285
+ var f, h;
1276
1286
  const e = t.parts.filter(
1277
- (f) => f.type === "text"
1278
- ), s = e.map((f) => f.text).join(`
1287
+ (m) => m.type === "text"
1288
+ ), s = e.map((m) => m.text).join(`
1279
1289
  `), a = e.some(
1280
- (f) => {
1290
+ (m) => {
1281
1291
  var p;
1282
- return ((p = f.metadata) == null ? void 0 : p.contentType) === "context";
1292
+ return ((p = m.metadata) == null ? void 0 : p.contentType) === "context";
1283
1293
  }
1284
1294
  ) ? "context" : void 0, n = t.parts.filter(
1285
- (f) => f.type === "data" && "toolCallId" in f.data && "arguments" in f.data
1286
- ).map((f) => ({
1287
- toolCallId: f.data.toolCallId,
1288
- toolId: f.data.toolId,
1289
- arguments: f.data.arguments
1295
+ (m) => m.type === "data" && "toolCallId" in m.data && "arguments" in m.data
1296
+ ).map((m) => ({
1297
+ toolCallId: m.data.toolCallId,
1298
+ toolId: m.data.toolId,
1299
+ arguments: m.data.arguments
1290
1300
  })), r = t.parts.filter(
1291
- (f) => f.type === "data" && "toolCallId" in f.data && "result" in f.data
1292
- ).map((f) => ({
1293
- toolCallId: f.data.toolCallId,
1294
- result: f.data.result,
1295
- error: f.data.error
1296
- })), l = n.length > 0 || r.length > 0 ? "agent" : t.role, i = ((g = t.metadata) == null ? void 0 : g.timestamp) ?? Date.now(), m = ((h = t.metadata) == null ? void 0 : h.archived) ?? void 0;
1301
+ (m) => m.type === "data" && "toolCallId" in m.data && "result" in m.data
1302
+ ).map((m) => ({
1303
+ toolCallId: m.data.toolCallId,
1304
+ result: m.data.result,
1305
+ error: m.data.error
1306
+ })), c = n.length > 0 || r.length > 0 ? "agent" : t.role, i = ((f = t.metadata) == null ? void 0 : f.timestamp) ?? Date.now(), l = ((h = t.metadata) == null ? void 0 : h.archived) ?? void 0;
1297
1307
  return {
1298
- role: l,
1308
+ role: c,
1299
1309
  content: s || "(No text content)",
1300
1310
  timestamp: i,
1301
- ...m !== void 0 && { archived: m },
1311
+ ...l !== void 0 && { archived: l },
1302
1312
  ...a && { contentType: a },
1303
1313
  ...n.length > 0 && { toolCalls: n },
1304
1314
  ...r.length > 0 && { toolResults: r }
@@ -1512,24 +1522,24 @@ function ce() {
1512
1522
  if (t.has(s))
1513
1523
  return t.get(s).client;
1514
1524
  const n = Zt(a), r = a.sessionId || null, o = a.conversationStorageKey;
1515
- let l = [];
1525
+ let c = [];
1516
1526
  if (r)
1517
1527
  try {
1518
- l = await ne(
1528
+ c = await ne(
1519
1529
  r,
1520
1530
  o
1521
1531
  );
1522
- } catch (m) {
1532
+ } catch (l) {
1523
1533
  ut(
1524
1534
  `Failed to load conversation history for agent ${s} with session ${r}:`,
1525
- m
1535
+ l
1526
1536
  );
1527
1537
  }
1528
1538
  const i = {
1529
1539
  client: n,
1530
1540
  sessionId: r,
1531
1541
  conversationStorageKey: o,
1532
- conversationHistory: l,
1542
+ conversationHistory: c,
1533
1543
  currentAbortController: null
1534
1544
  };
1535
1545
  return t.set(s, i), n;
@@ -1545,26 +1555,26 @@ function ce() {
1545
1555
  return t.delete(s);
1546
1556
  },
1547
1557
  async sendMessage(s, a, n = {}) {
1548
- var c;
1558
+ var u;
1549
1559
  const r = t.get(s);
1550
1560
  if (!r)
1551
1561
  throw new Error(`Agent with key "${s}" not found`);
1552
- const { withHistory: o = !0, ...l } = n, { client: i, conversationHistory: m } = r, g = n.message || mt(a, m), h = await i.sendMessage({
1553
- message: g,
1562
+ const { withHistory: o = !0, ...c } = n, { client: i, conversationHistory: l } = r, f = n.message || mt(a, l), h = await i.sendMessage({
1563
+ message: f,
1554
1564
  withHistory: o,
1555
- ...l
1565
+ ...c
1556
1566
  });
1557
- let f = null;
1558
- if ((c = h.status) != null && c.message) {
1559
- const u = h.status.message.parts.filter(
1560
- (d) => d.type === "data" && "toolCallId" in d.data && ("arguments" in d.data || "result" in d.data)
1567
+ let m = null;
1568
+ if ((u = h.status) != null && u.message) {
1569
+ const d = h.status.message.parts.filter(
1570
+ (g) => g.type === "data" && "toolCallId" in g.data && ("arguments" in g.data || "result" in g.data)
1561
1571
  ), w = h.status.message.parts.filter(
1562
- (d) => d.type === "text"
1572
+ (g) => g.type === "text"
1563
1573
  );
1564
- f = {
1574
+ m = {
1565
1575
  role: "agent",
1566
1576
  kind: "message",
1567
- parts: [...u, ...w],
1577
+ parts: [...d, ...w],
1568
1578
  messageId: N(),
1569
1579
  metadata: {
1570
1580
  timestamp: Date.now()
@@ -1572,20 +1582,20 @@ function ce() {
1572
1582
  };
1573
1583
  }
1574
1584
  const p = [
1575
- ...m,
1585
+ ...l,
1576
1586
  // Store only the new content from the user message (without history parts)
1577
1587
  nt(a),
1578
1588
  // Add complete agent response with tool calls/results if present
1579
- ...f ? [L(f)] : []
1589
+ ...m ? [L(m)] : []
1580
1590
  ];
1581
1591
  let S = p;
1582
1592
  if (h.agentMessage) {
1583
- const u = L(
1593
+ const d = L(
1584
1594
  h.agentMessage
1585
1595
  );
1586
1596
  S = [
1587
1597
  ...p,
1588
- u
1598
+ d
1589
1599
  ];
1590
1600
  }
1591
1601
  return r.conversationHistory = S, o && await e(
@@ -1594,45 +1604,45 @@ function ce() {
1594
1604
  ), h;
1595
1605
  },
1596
1606
  async *sendMessageStream(s, a, n = {}) {
1597
- var d, y, x, I, P, T;
1607
+ var g, y, x, I, P, T;
1598
1608
  const r = t.get(s);
1599
1609
  if (!r)
1600
1610
  throw new Error(`Agent with key "${s}" not found`);
1601
1611
  const {
1602
1612
  withHistory: o = !0,
1603
- abortSignal: l,
1613
+ abortSignal: c,
1604
1614
  metadata: i,
1605
- ...m
1606
- } = n, { client: g } = r, h = i ? (({ contentType: b, ...k }) => k)(i) : void 0, f = new AbortController();
1607
- r.currentAbortController = f, l && l.addEventListener(
1615
+ ...l
1616
+ } = n, { client: f } = r, h = i ? (({ contentType: b, ...k }) => k)(i) : void 0, m = new AbortController();
1617
+ r.currentAbortController = m, c && c.addEventListener(
1608
1618
  "abort",
1609
- () => f.abort()
1619
+ () => m.abort()
1610
1620
  );
1611
1621
  let p = [
1612
1622
  ...r.conversationHistory
1613
1623
  ], S = [];
1614
- const c = await le(
1624
+ const u = await le(
1615
1625
  p
1616
1626
  );
1617
- r.conversationHistory = c, p = c, o && await e(
1627
+ r.conversationHistory = u, p = u, o && await e(
1618
1628
  s,
1619
- c
1629
+ u
1620
1630
  );
1621
- const u = n.message || mt(
1631
+ const d = n.message || mt(
1622
1632
  a,
1623
- c
1633
+ u
1624
1634
  );
1625
1635
  if (n.metadata && !n.message) {
1626
1636
  const { contentType: b, ...k } = n.metadata;
1627
1637
  if (b) {
1628
- const M = u.parts[u.parts.length - 1];
1638
+ const M = d.parts[d.parts.length - 1];
1629
1639
  M && M.type === "text" && (M.metadata = {
1630
1640
  ...M.metadata,
1631
1641
  contentType: b
1632
1642
  });
1633
1643
  }
1634
- Object.keys(k).length > 0 && (u.metadata = {
1635
- ...u.metadata,
1644
+ Object.keys(k).length > 0 && (d.metadata = {
1645
+ ...d.metadata,
1636
1646
  ...k
1637
1647
  });
1638
1648
  }
@@ -1644,16 +1654,16 @@ function ce() {
1644
1654
  s,
1645
1655
  p
1646
1656
  );
1647
- for await (const b of g.sendMessageStream({
1648
- message: u,
1657
+ for await (const b of f.sendMessageStream({
1658
+ message: d,
1649
1659
  withHistory: o,
1650
- abortSignal: f.signal,
1651
- ...m,
1660
+ abortSignal: m.signal,
1661
+ ...l,
1652
1662
  ...h && Object.keys(h).length > 0 && {
1653
1663
  metadata: h
1654
1664
  }
1655
1665
  })) {
1656
- if (((d = b.status) == null ? void 0 : d.state) === "input-required" && ((y = b.status) != null && y.message)) {
1666
+ if (((g = b.status) == null ? void 0 : g.state) === "input-required" && ((y = b.status) != null && y.message)) {
1657
1667
  S = F(
1658
1668
  b.status.message
1659
1669
  ).map(
@@ -1745,19 +1755,19 @@ function de() {
1745
1755
  const [t, e] = yt([]), s = $(
1746
1756
  (r) => {
1747
1757
  e((o) => {
1748
- const l = o.findIndex(
1758
+ const c = o.findIndex(
1749
1759
  (i) => i.id === r.id
1750
1760
  );
1751
- if (l >= 0) {
1761
+ if (c >= 0) {
1752
1762
  const i = [...o];
1753
- return i[l] = r, i;
1763
+ return i[c] = r, i;
1754
1764
  }
1755
1765
  return [...o, r];
1756
1766
  });
1757
1767
  },
1758
1768
  []
1759
1769
  ), a = $((r) => {
1760
- e((o) => o.filter((l) => l.id !== r));
1770
+ e((o) => o.filter((c) => c.id !== r));
1761
1771
  }, []), n = $(() => {
1762
1772
  e([]);
1763
1773
  }, []);
@@ -1781,20 +1791,20 @@ function ge(t, e) {
1781
1791
  }));
1782
1792
  }
1783
1793
  const at = (t) => [...t].sort((e, s) => e.timestamp - s.timestamp), z = (t, e = []) => {
1784
- var o, l;
1794
+ var o, c;
1785
1795
  if (t.parts.some((i) => {
1786
1796
  if (i.type === "data") {
1787
- const m = i.data;
1788
- return m.toolCallId || m.toolId || m.result;
1797
+ const l = i.data;
1798
+ return l.toolCallId || l.toolId || l.result;
1789
1799
  }
1790
1800
  return !1;
1791
1801
  }))
1792
1802
  return null;
1793
1803
  const a = t.parts.map((i) => {
1794
- var m;
1804
+ var l;
1795
1805
  if (i.type === "text")
1796
1806
  return {
1797
- type: ((m = i.metadata) == null ? void 0 : m.contentType) || "text",
1807
+ type: ((l = i.metadata) == null ? void 0 : l.contentType) || "text",
1798
1808
  text: i.text
1799
1809
  };
1800
1810
  if (i.type === "file")
@@ -1803,14 +1813,14 @@ const at = (t) => [...t].sort((e, s) => e.timestamp - s.timestamp), z = (t, e =
1803
1813
  image_url: i.file.uri || `data:${i.file.mimeType};base64,${i.file.bytes}`
1804
1814
  };
1805
1815
  if (i.type === "data") {
1806
- const g = i.data;
1807
- return g.component && g.componentProps ? {
1816
+ const f = i.data;
1817
+ return f.component && f.componentProps ? {
1808
1818
  type: "component",
1809
- component: g.component,
1810
- componentProps: g.componentProps
1819
+ component: f.component,
1820
+ componentProps: f.componentProps
1811
1821
  } : {
1812
1822
  type: "text",
1813
- text: JSON.stringify(g)
1823
+ text: JSON.stringify(f)
1814
1824
  };
1815
1825
  }
1816
1826
  return {
@@ -1822,7 +1832,7 @@ const at = (t) => [...t].sort((e, s) => e.timestamp - s.timestamp), z = (t, e =
1822
1832
  role: t.role === "agent" ? "agent" : "user",
1823
1833
  content: a,
1824
1834
  timestamp: n,
1825
- archived: !!((l = t.metadata) != null && l.archived),
1835
+ archived: !!((c = t.metadata) != null && c.archived),
1826
1836
  showIcon: t.role === "agent",
1827
1837
  icon: t.role === "agent" ? "assistant" : void 0
1828
1838
  };
@@ -1860,18 +1870,18 @@ function Ee(t) {
1860
1870
  }), {
1861
1871
  registerMessageActions: r,
1862
1872
  unregisterMessageActions: o,
1863
- clearAllMessageActions: l,
1873
+ clearAllMessageActions: c,
1864
1874
  registrations: i
1865
- } = de(), m = Ot(i);
1875
+ } = de(), l = Ot(i);
1866
1876
  tt(() => {
1867
- m.current = i;
1877
+ l.current = i;
1868
1878
  }, [i]), tt(() => {
1869
1879
  if (!s)
1870
1880
  return;
1871
1881
  (async () => {
1872
1882
  if (e.sessionId) {
1873
- const u = st(), w = `${e.agentId}-${e.sessionId}`;
1874
- u.hasAgent(w) || await u.createAgent(w, {
1883
+ const d = st(), w = `${e.agentId}-${e.sessionId}`;
1884
+ d.hasAgent(w) || await d.createAgent(w, {
1875
1885
  agentId: e.agentId,
1876
1886
  agentUrl: e.agentUrl,
1877
1887
  sessionId: e.sessionId,
@@ -1880,17 +1890,17 @@ function Ee(t) {
1880
1890
  authProvider: t.authProvider,
1881
1891
  enableStreaming: t.enableStreaming
1882
1892
  });
1883
- const d = u.getConversationHistory(w);
1893
+ const g = d.getConversationHistory(w);
1884
1894
  n((y) => {
1885
- const x = d.map(
1895
+ const x = g.map(
1886
1896
  (I) => z(
1887
1897
  I,
1888
- m.current
1898
+ l.current
1889
1899
  )
1890
1900
  ).filter((I) => I !== null);
1891
1901
  return {
1892
1902
  ...y,
1893
- clientMessages: d,
1903
+ clientMessages: g,
1894
1904
  uiMessages: x
1895
1905
  };
1896
1906
  });
@@ -1906,17 +1916,17 @@ function Ee(t) {
1906
1916
  t.enableStreaming,
1907
1917
  s
1908
1918
  ]);
1909
- const g = $(
1910
- async (c, u) => {
1919
+ const f = $(
1920
+ async (u, d) => {
1911
1921
  var P;
1912
1922
  if (!s)
1913
1923
  throw new Error("Invalid agent configuration");
1914
- const w = st(), d = `${e.agentId}-${e.sessionId}`, y = Date.now(), x = (u == null ? void 0 : u.type) || "text", I = {
1924
+ const w = st(), g = `${e.agentId}-${e.sessionId}`, y = Date.now(), x = (d == null ? void 0 : d.type) || "text", I = {
1915
1925
  id: `user-${y}`,
1916
1926
  role: "user",
1917
- content: [{ type: x, text: c }],
1927
+ content: [{ type: x, text: u }],
1918
1928
  timestamp: y,
1919
- archived: (u == null ? void 0 : u.archived) ?? !1,
1929
+ archived: (d == null ? void 0 : d.archived) ?? !1,
1920
1930
  showIcon: !1
1921
1931
  };
1922
1932
  n((T) => ({
@@ -1928,13 +1938,13 @@ function Ee(t) {
1928
1938
  try {
1929
1939
  let T = null, b = !1;
1930
1940
  const k = {};
1931
- (u != null && u.archived || u != null && u.type) && (k.metadata = {
1932
- ...(u == null ? void 0 : u.archived) && { archived: !0 },
1933
- ...(u == null ? void 0 : u.type) && { contentType: u.type }
1941
+ (d != null && d.archived || d != null && d.type) && (k.metadata = {
1942
+ ...(d == null ? void 0 : d.archived) && { archived: !0 },
1943
+ ...(d == null ? void 0 : d.type) && { contentType: d.type }
1934
1944
  });
1935
1945
  for await (const M of w.sendMessageStream(
1936
- d,
1937
- c,
1946
+ g,
1947
+ u,
1938
1948
  k
1939
1949
  )) {
1940
1950
  if (!M.final && M.text)
@@ -1978,13 +1988,13 @@ function Ee(t) {
1978
1988
  b = !0;
1979
1989
  const C = T, A = z(
1980
1990
  M.status.message,
1981
- m.current
1991
+ l.current
1982
1992
  );
1983
1993
  A && n((q) => {
1984
1994
  const _ = q.uiMessages.map(
1985
1995
  (R) => R.id === C ? A : R
1986
1996
  ), E = w.getConversationHistory(
1987
- d
1997
+ g
1988
1998
  );
1989
1999
  return {
1990
2000
  ...q,
@@ -1996,7 +2006,7 @@ function Ee(t) {
1996
2006
  }
1997
2007
  }
1998
2008
  if (!b) {
1999
- const M = w.getConversationHistory(d);
2009
+ const M = w.getConversationHistory(g);
2000
2010
  n((C) => {
2001
2011
  let A = C.uiMessages;
2002
2012
  T && (A = C.uiMessages.filter(
@@ -2005,7 +2015,7 @@ function Ee(t) {
2005
2015
  const q = M.map(
2006
2016
  (O) => z(
2007
2017
  O,
2008
- m.current
2018
+ l.current
2009
2019
  )
2010
2020
  ).filter(
2011
2021
  (O) => O !== null
@@ -2047,41 +2057,41 @@ function Ee(t) {
2047
2057
  }
2048
2058
  },
2049
2059
  [e.agentId, e.sessionId, s]
2050
- ), h = $((c) => {
2051
- n((u) => ({
2052
- ...u,
2053
- uiMessages: at([...u.uiMessages, c])
2060
+ ), h = $((u) => {
2061
+ n((d) => ({
2062
+ ...d,
2063
+ uiMessages: at([...d.uiMessages, u])
2054
2064
  }));
2055
- }, []), f = $((c) => {
2056
- n((u) => ({
2057
- ...u,
2058
- suggestions: c
2065
+ }, []), m = $((u) => {
2066
+ n((d) => ({
2067
+ ...d,
2068
+ suggestions: u
2059
2069
  }));
2060
2070
  }, []), p = $(() => {
2061
- n((c) => ({
2062
- ...c,
2071
+ n((u) => ({
2072
+ ...u,
2063
2073
  suggestions: []
2064
2074
  }));
2065
2075
  }, []);
2066
2076
  tt(() => {
2067
- n((c) => {
2068
- if (c.clientMessages.length === 0)
2069
- return c;
2070
- const u = c.clientMessages.map(
2071
- (y) => z(y, m.current)
2077
+ n((u) => {
2078
+ if (u.clientMessages.length === 0)
2079
+ return u;
2080
+ const d = u.clientMessages.map(
2081
+ (y) => z(y, l.current)
2072
2082
  ).filter((y) => y !== null), w = new Set(
2073
- c.clientMessages.map((y) => y.messageId)
2074
- ), d = c.uiMessages.filter(
2083
+ u.clientMessages.map((y) => y.messageId)
2084
+ ), g = u.uiMessages.filter(
2075
2085
  (y) => {
2076
2086
  var x;
2077
2087
  return !w.has(y.id) && ((x = y.content[0]) == null ? void 0 : x.type) === "component";
2078
2088
  }
2079
2089
  );
2080
2090
  return {
2081
- ...c,
2091
+ ...u,
2082
2092
  uiMessages: at([
2083
- ...u,
2084
- ...d
2093
+ ...d,
2094
+ ...g
2085
2095
  ])
2086
2096
  };
2087
2097
  });
@@ -2089,23 +2099,23 @@ function Ee(t) {
2089
2099
  const S = $(() => {
2090
2100
  if (!s)
2091
2101
  return;
2092
- const c = st(), u = `${e.agentId}-${e.sessionId}`;
2093
- c.abortCurrentRequest(u);
2102
+ const u = st(), d = `${e.agentId}-${e.sessionId}`;
2103
+ u.abortCurrentRequest(d);
2094
2104
  }, [e.agentId, e.sessionId, s]);
2095
2105
  return {
2096
2106
  // AgentUI props
2097
2107
  messages: a.uiMessages,
2098
2108
  isProcessing: a.isProcessing,
2099
2109
  error: a.error,
2100
- onSubmit: g,
2110
+ onSubmit: f,
2101
2111
  suggestions: a.suggestions,
2102
2112
  // UI management methods
2103
- registerSuggestions: f,
2113
+ registerSuggestions: m,
2104
2114
  clearSuggestions: p,
2105
2115
  // Message actions methods
2106
2116
  registerMessageActions: r,
2107
2117
  unregisterMessageActions: o,
2108
- clearAllMessageActions: l,
2118
+ clearAllMessageActions: c,
2109
2119
  // Tool integration
2110
2120
  addMessage: h,
2111
2121
  // Abort control
@@ -2119,18 +2129,18 @@ function we() {
2119
2129
  return ((a = (s = window.JP_CONNECTION_INITIAL_STATE) == null ? void 0 : s.connectionStatus) == null ? void 0 : a.isRegistered) ? !1 : !!((n = window.Jetpack_Editor_Initial_State) != null && n.wpcomBlogId);
2120
2130
  }
2121
2131
  async function Ie(t, e = !0) {
2122
- var i, m;
2132
+ var i, l;
2123
2133
  const s = localStorage.getItem(pt);
2124
2134
  let a;
2125
2135
  if (s)
2126
2136
  try {
2127
2137
  a = JSON.parse(s);
2128
- } catch (g) {
2129
- v("Invalid cached Jetpack token: %O", g);
2138
+ } catch (f) {
2139
+ v("Invalid cached Jetpack token: %O", f);
2130
2140
  }
2131
2141
  if (a && (a != null && a.token) && (a != null && a.expire) && (a == null ? void 0 : a.expire) > Date.now() && e)
2132
2142
  return a;
2133
- const n = (i = window.JP_CONNECTION_INITIAL_STATE) == null ? void 0 : i.apiNonce, r = (m = window.Jetpack_Editor_Initial_State) == null ? void 0 : m.wpcomBlogId;
2143
+ const n = (i = window.JP_CONNECTION_INITIAL_STATE) == null ? void 0 : i.apiNonce, r = (l = window.Jetpack_Editor_Initial_State) == null ? void 0 : l.wpcomBlogId;
2134
2144
  let o = {
2135
2145
  token: "",
2136
2146
  blog_id: ""
@@ -2147,24 +2157,24 @@ async function Ie(t, e = !0) {
2147
2157
  },
2148
2158
  method: "POST"
2149
2159
  });
2150
- } catch (g) {
2151
- throw v("Failed to fetch Jetpack token: %O", g), new Error(t(g));
2160
+ } catch (f) {
2161
+ throw v("Failed to fetch Jetpack token: %O", f), new Error(t(f));
2152
2162
  }
2153
2163
  if (!(o != null && o.token))
2154
2164
  throw new Error(
2155
2165
  "Authentication failed. Please ensure Jetpack is properly connected and try again."
2156
2166
  );
2157
- const l = {
2167
+ const c = {
2158
2168
  token: o.token,
2159
2169
  blogId: o.blog_id || "",
2160
2170
  expire: Date.now() + ye
2161
2171
  };
2162
2172
  try {
2163
- localStorage.setItem(pt, JSON.stringify(l));
2164
- } catch (g) {
2165
- v("Error storing token in localStorage: %O", g);
2173
+ localStorage.setItem(pt, JSON.stringify(c));
2174
+ } catch (f) {
2175
+ v("Error storing token in localStorage: %O", f);
2166
2176
  }
2167
- return l;
2177
+ return c;
2168
2178
  }
2169
2179
  const Oe = (t) => async () => {
2170
2180
  const e = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/agenttic-client",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "type": "module",
5
5
  "description": "A TypeScript client library for A2A (Agent2Agent) protocol communication",
6
6
  "main": "dist/index.js",