@amodalai/react 0.1.17 → 0.1.18

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/dist/react.js CHANGED
@@ -1,21 +1,21 @@
1
- import { jsx as v, jsxs as w } from "react/jsx-runtime";
2
- import { createContext as F, useMemo as B, useContext as U, useReducer as Q, useRef as N, useCallback as A, useEffect as R, useState as y } from "react";
1
+ import { jsx as v, jsxs as I } from "react/jsx-runtime";
2
+ import { createContext as F, useMemo as B, useContext as U, useReducer as Q, useRef as N, useCallback as A, useEffect as w, useState as y } from "react";
3
3
  import { RuntimeClient as V } from "./client.js";
4
- import { ChatClient as me, ChatStream as fe } from "./client.js";
4
+ import { ChatClient as me, ChatStream as pe } from "./client.js";
5
5
  import { a as ge, d as _e, m as he, u as ve, b as ye, c as Ee } from "./theme-VAUsolBG.js";
6
- import { T as be, W as Te, c as Ae, a as Ne, d as xe, g as Ce, l as we, p as Re, s as ke, b as Ie, e as De, u as Me } from "./event-bus-h26clqbZ.js";
6
+ import { T as be, W as Te, c as Ae, a as Ne, d as xe, g as Ce, l as Ie, p as we, s as Re, b as ke, e as De, u as Me } from "./event-bus-h26clqbZ.js";
7
7
  const j = F(null);
8
- function Z({ runtimeUrl: s, appId: r, getToken: t, children: e }) {
9
- const n = B(
10
- () => new V({ runtimeUrl: s, appId: r, getToken: t }),
11
- [s, r, t]
12
- ), a = B(
13
- () => ({ client: n, runtimeUrl: s, appId: r }),
14
- [n, s, r]
8
+ function Z({ runtimeUrl: s, getToken: r, children: t }) {
9
+ const e = B(
10
+ () => new V({ runtimeUrl: s, getToken: r }),
11
+ [s, r]
12
+ ), o = B(
13
+ () => ({ client: e, runtimeUrl: s }),
14
+ [e, s]
15
15
  );
16
- return /* @__PURE__ */ v(j.Provider, { value: a, children: e });
16
+ return /* @__PURE__ */ v(j.Provider, { value: o, children: t });
17
17
  }
18
- function k() {
18
+ function R() {
19
19
  const s = U(j);
20
20
  if (!s)
21
21
  throw new Error("useAmodalContext must be used within an <AmodalProvider>");
@@ -72,26 +72,26 @@ function X(s, r) {
72
72
  case "STREAM_TEXT_DELTA": {
73
73
  const t = [...s.messages], e = t[t.length - 1];
74
74
  if (e && e.type === "assistant_text") {
75
- const n = [...e.contentBlocks], a = n[n.length - 1];
76
- a && a.type === "text" ? n[n.length - 1] = { type: "text", text: a.text + r.content } : n.push({ type: "text", text: r.content }), t[t.length - 1] = { ...e, text: e.text + r.content, contentBlocks: n };
75
+ const o = [...e.contentBlocks], a = o[o.length - 1];
76
+ a && a.type === "text" ? o[o.length - 1] = { type: "text", text: a.text + r.content } : o.push({ type: "text", text: r.content }), t[t.length - 1] = { ...e, text: e.text + r.content, contentBlocks: o };
77
77
  }
78
78
  return { ...s, messages: t };
79
79
  }
80
80
  case "STREAM_TOOL_CALL_START": {
81
- const t = [...s.messages], e = t[t.length - 1], n = {
81
+ const t = [...s.messages], e = t[t.length - 1], o = {
82
82
  toolId: r.toolId,
83
83
  toolName: r.toolName,
84
84
  parameters: r.parameters,
85
85
  status: "running"
86
86
  };
87
87
  if (e && e.type === "assistant_text") {
88
- const a = [...e.toolCalls, n], c = [...e.contentBlocks], u = c[c.length - 1];
89
- u && u.type === "tool_calls" ? c[c.length - 1] = { type: "tool_calls", calls: [...u.calls, n] } : c.push({ type: "tool_calls", calls: [n] }), t[t.length - 1] = { ...e, toolCalls: a, contentBlocks: c };
88
+ const a = [...e.toolCalls, o], c = [...e.contentBlocks], u = c[c.length - 1];
89
+ u && u.type === "tool_calls" ? c[c.length - 1] = { type: "tool_calls", calls: [...u.calls, o] } : c.push({ type: "tool_calls", calls: [o] }), t[t.length - 1] = { ...e, toolCalls: a, contentBlocks: c };
90
90
  }
91
91
  return {
92
92
  ...s,
93
93
  messages: t,
94
- activeToolCalls: [...s.activeToolCalls, n]
94
+ activeToolCalls: [...s.activeToolCalls, o]
95
95
  };
96
96
  }
97
97
  case "STREAM_TOOL_CALL_RESULT": {
@@ -109,16 +109,16 @@ function X(s, r) {
109
109
  );
110
110
  t[t.length - 1] = { ...e, toolCalls: c, contentBlocks: u };
111
111
  }
112
- const n = s.activeToolCalls.filter(
112
+ const o = s.activeToolCalls.filter(
113
113
  (a) => a.toolId !== r.toolId
114
114
  );
115
- return { ...s, messages: t, activeToolCalls: n };
115
+ return { ...s, messages: t, activeToolCalls: o };
116
116
  }
117
117
  case "STREAM_SUBAGENT_EVENT": {
118
118
  const t = [...s.messages], e = t[t.length - 1];
119
119
  if (e && e.type === "assistant_text") {
120
- const n = (u) => u.toolId === r.parentToolId ? { ...u, subagentEvents: [...u.subagentEvents ?? [], r.event] } : u, a = e.toolCalls.map(n), c = e.contentBlocks.map(
121
- (u) => u.type === "tool_calls" ? { ...u, calls: u.calls.map(n) } : u
120
+ const o = (u) => u.toolId === r.parentToolId ? { ...u, subagentEvents: [...u.subagentEvents ?? [], r.event] } : u, a = e.toolCalls.map(o), c = e.contentBlocks.map(
121
+ (u) => u.type === "tool_calls" ? { ...u, calls: u.calls.map(o) } : u
122
122
  );
123
123
  t[t.length - 1] = { ...e, toolCalls: a, contentBlocks: c };
124
124
  }
@@ -127,14 +127,14 @@ function X(s, r) {
127
127
  case "STREAM_WIDGET": {
128
128
  const t = [...s.messages], e = t[t.length - 1];
129
129
  if (e && e.type === "assistant_text") {
130
- const n = {
130
+ const o = {
131
131
  type: "widget",
132
132
  widgetType: r.widgetType,
133
133
  data: r.data
134
134
  };
135
135
  t[t.length - 1] = {
136
136
  ...e,
137
- contentBlocks: [...e.contentBlocks, n]
137
+ contentBlocks: [...e.contentBlocks, o]
138
138
  };
139
139
  }
140
140
  return { ...s, messages: t };
@@ -142,14 +142,14 @@ function X(s, r) {
142
142
  case "STREAM_CONFIRMATION_REQUIRED": {
143
143
  const t = [...s.messages], e = t[t.length - 1];
144
144
  if (e && e.type === "assistant_text") {
145
- const n = {
145
+ const o = {
146
146
  type: "confirmation",
147
147
  confirmation: r.confirmation
148
148
  };
149
149
  t[t.length - 1] = {
150
150
  ...e,
151
151
  confirmations: [...e.confirmations, r.confirmation],
152
- contentBlocks: [...e.contentBlocks, n]
152
+ contentBlocks: [...e.contentBlocks, o]
153
153
  };
154
154
  }
155
155
  return { ...s, messages: t };
@@ -157,12 +157,12 @@ function X(s, r) {
157
157
  case "CONFIRMATION_RESPONDED": {
158
158
  const t = [...s.messages], e = t[t.length - 1];
159
159
  if (e && e.type === "assistant_text") {
160
- const n = e.confirmations.map(
160
+ const o = e.confirmations.map(
161
161
  (c) => c.correlationId === r.correlationId ? { ...c, status: r.approved ? "approved" : "denied" } : c
162
162
  ), a = e.contentBlocks.map(
163
163
  (c) => c.type === "confirmation" && c.confirmation.correlationId === r.correlationId ? { ...c, confirmation: { ...c.confirmation, status: r.approved ? "approved" : "denied" } } : c
164
164
  );
165
- t[t.length - 1] = { ...e, confirmations: n, contentBlocks: a };
165
+ t[t.length - 1] = { ...e, confirmations: o, contentBlocks: a };
166
166
  }
167
167
  return { ...s, messages: t };
168
168
  }
@@ -176,8 +176,8 @@ function X(s, r) {
176
176
  );
177
177
  t[t.length - 1] = { ...e, toolCalls: c, contentBlocks: u };
178
178
  }
179
- const n = r.usage ? { inputTokens: s.usage.inputTokens + r.usage.inputTokens, outputTokens: s.usage.outputTokens + r.usage.outputTokens } : s.usage;
180
- return { ...s, messages: t, isStreaming: !1, activeToolCalls: [], usage: n };
179
+ const o = r.usage ? { inputTokens: s.usage.inputTokens + r.usage.inputTokens, outputTokens: s.usage.outputTokens + r.usage.outputTokens } : s.usage;
180
+ return { ...s, messages: t, isStreaming: !1, activeToolCalls: [], usage: o };
181
181
  }
182
182
  case "RESET":
183
183
  return { ...G };
@@ -186,26 +186,26 @@ function X(s, r) {
186
186
  }
187
187
  }
188
188
  function W(s) {
189
- const { client: r } = k(), [t, e] = Q(X, G), n = N((s == null ? void 0 : s.initialSessionId) ?? null), a = N(null), c = N(s);
190
- c.current = s, n.current = t.sessionId ?? n.current;
189
+ const { client: r } = R(), [t, e] = Q(X, G), o = N((s == null ? void 0 : s.initialSessionId) ?? null), a = N(null), c = N(s);
190
+ c.current = s, o.current = t.sessionId ?? o.current;
191
191
  const u = A(
192
192
  (_) => {
193
193
  if (t.isStreaming) return;
194
194
  e({ type: "SEND_MESSAGE", text: _ });
195
195
  const h = new AbortController();
196
196
  a.current = h, (async () => {
197
- var o, d, p, l, b, T, x, C, M, D, O;
198
- let f = !1;
197
+ var n, d, f, l, b, T, x, C, M, D, O;
198
+ let p = !1;
199
199
  try {
200
- const I = r.chatStream(_, {
201
- sessionId: n.current ?? void 0,
202
- context: (o = c.current) == null ? void 0 : o.context,
200
+ const k = r.chatStream(_, {
201
+ sessionId: o.current ?? void 0,
202
+ context: (n = c.current) == null ? void 0 : n.context,
203
203
  signal: h.signal
204
204
  });
205
- for await (const g of I)
205
+ for await (const g of k)
206
206
  switch (g.type) {
207
207
  case "init":
208
- e({ type: "STREAM_INIT", sessionId: g.session_id }), (p = (d = c.current) == null ? void 0 : d.onSessionCreated) == null || p.call(d, g.session_id);
208
+ e({ type: "STREAM_INIT", sessionId: g.session_id }), (f = (d = c.current) == null ? void 0 : d.onSessionCreated) == null || f.call(d, g.session_id);
209
209
  break;
210
210
  case "text_delta":
211
211
  e({ type: "STREAM_TEXT_DELTA", content: g.content });
@@ -278,7 +278,7 @@ function W(s) {
278
278
  e({ type: "STREAM_ERROR", message: g.message });
279
279
  break;
280
280
  case "done":
281
- f = !0, e({
281
+ p = !0, e({
282
282
  type: "STREAM_DONE",
283
283
  usage: g.usage ? { inputTokens: g.usage.input_tokens, outputTokens: g.usage.output_tokens } : void 0
284
284
  }), (M = (C = c.current) == null ? void 0 : C.onStreamEnd) == null || M.call(C);
@@ -286,13 +286,13 @@ function W(s) {
286
286
  default:
287
287
  break;
288
288
  }
289
- } catch (I) {
290
- I instanceof DOMException && I.name === "AbortError" || e({
289
+ } catch (k) {
290
+ k instanceof DOMException && k.name === "AbortError" || e({
291
291
  type: "STREAM_ERROR",
292
- message: I instanceof Error ? I.message : "Unknown error"
292
+ message: k instanceof Error ? k.message : "Unknown error"
293
293
  });
294
294
  } finally {
295
- a.current = null, !f && !h.signal.aborted && (e({ type: "STREAM_DONE" }), (O = (D = c.current) == null ? void 0 : D.onStreamEnd) == null || O.call(D));
295
+ a.current = null, !p && !h.signal.aborted && (e({ type: "STREAM_DONE" }), (O = (D = c.current) == null ? void 0 : D.onStreamEnd) == null || O.call(D));
296
296
  }
297
297
  })();
298
298
  },
@@ -309,7 +309,7 @@ function W(s) {
309
309
  },
310
310
  [u, t.isStreaming]
311
311
  );
312
- return R(
312
+ return w(
313
313
  () => () => {
314
314
  a.current && a.current.abort();
315
315
  },
@@ -334,13 +334,13 @@ function W(s) {
334
334
  */
335
335
  function H({ confirmation: s, onApprove: r, onDeny: t }) {
336
336
  const e = s.status === "pending";
337
- return /* @__PURE__ */ w("div", { className: "amodal-confirm-card", "data-testid": "confirm-card", children: [
338
- /* @__PURE__ */ w("div", { className: "amodal-confirm-card__header", children: [
337
+ return /* @__PURE__ */ I("div", { className: "amodal-confirm-card", "data-testid": "confirm-card", children: [
338
+ /* @__PURE__ */ I("div", { className: "amodal-confirm-card__header", children: [
339
339
  /* @__PURE__ */ v("span", { className: "amodal-confirm-card__method", children: s.method }),
340
340
  /* @__PURE__ */ v("span", { className: "amodal-confirm-card__endpoint", children: s.endpoint })
341
341
  ] }),
342
342
  /* @__PURE__ */ v("p", { className: "amodal-confirm-card__reason", children: s.reason }),
343
- e ? /* @__PURE__ */ w("div", { className: "amodal-confirm-card__actions", children: [
343
+ e ? /* @__PURE__ */ I("div", { className: "amodal-confirm-card__actions", children: [
344
344
  /* @__PURE__ */ v(
345
345
  "button",
346
346
  {
@@ -369,22 +369,22 @@ function H({ confirmation: s, onApprove: r, onDeny: t }) {
369
369
  */
370
370
  function J({ confirmation: s, onApprove: r, onDeny: t }) {
371
371
  const e = s.status === "pending";
372
- return /* @__PURE__ */ w("div", { className: "amodal-review-card", "data-testid": "review-card", children: [
373
- /* @__PURE__ */ w("div", { className: "amodal-review-card__header", children: [
372
+ return /* @__PURE__ */ I("div", { className: "amodal-review-card", "data-testid": "review-card", children: [
373
+ /* @__PURE__ */ I("div", { className: "amodal-review-card__header", children: [
374
374
  /* @__PURE__ */ v("span", { className: "amodal-review-card__method", children: s.method }),
375
375
  /* @__PURE__ */ v("span", { className: "amodal-review-card__endpoint", children: s.endpoint }),
376
376
  s.escalated && /* @__PURE__ */ v("span", { className: "amodal-review-card__badge", "data-testid": "escalation-badge", children: "Escalated" })
377
377
  ] }),
378
- s.connectionName && /* @__PURE__ */ w("div", { className: "amodal-review-card__connection", children: [
378
+ s.connectionName && /* @__PURE__ */ I("div", { className: "amodal-review-card__connection", children: [
379
379
  "Connection: ",
380
380
  s.connectionName
381
381
  ] }),
382
382
  /* @__PURE__ */ v("p", { className: "amodal-review-card__reason", children: s.reason }),
383
- s.params && Object.keys(s.params).length > 0 && /* @__PURE__ */ w("div", { className: "amodal-review-card__params", "data-testid": "review-params", children: [
383
+ s.params && Object.keys(s.params).length > 0 && /* @__PURE__ */ I("div", { className: "amodal-review-card__params", "data-testid": "review-params", children: [
384
384
  /* @__PURE__ */ v("div", { className: "amodal-review-card__params-title", children: "Parameters" }),
385
385
  /* @__PURE__ */ v("pre", { className: "amodal-review-card__params-body", children: JSON.stringify(s.params, null, 2) })
386
386
  ] }),
387
- e ? /* @__PURE__ */ w("div", { className: "amodal-review-card__actions", children: [
387
+ e ? /* @__PURE__ */ I("div", { className: "amodal-review-card__actions", children: [
388
388
  /* @__PURE__ */ v(
389
389
  "button",
390
390
  {
@@ -411,64 +411,64 @@ function ee({
411
411
  renderText: r,
412
412
  renderToolCall: t,
413
413
  renderConfirmation: e,
414
- className: n,
414
+ className: o,
415
415
  ...a
416
416
  }) {
417
417
  const { messages: c, send: u, isStreaming: i, respondToConfirmation: S } = W(a), [E, _] = y(""), h = N(null), m = A(
418
- (o) => {
419
- o.preventDefault();
418
+ (n) => {
419
+ n.preventDefault();
420
420
  const d = E.trim();
421
421
  d.length === 0 || i || (_(""), u(d));
422
422
  },
423
423
  [E, i, u]
424
- ), f = ["amodal-chat", n].filter(Boolean).join(" ");
425
- return /* @__PURE__ */ w("div", { className: f, "data-testid": "amodal-chat", children: [
426
- /* @__PURE__ */ w("div", { className: "amodal-chat__messages", "data-testid": "message-list", children: [
427
- c.map((o) => {
428
- switch (o.type) {
424
+ ), p = ["amodal-chat", o].filter(Boolean).join(" ");
425
+ return /* @__PURE__ */ I("div", { className: p, "data-testid": "amodal-chat", children: [
426
+ /* @__PURE__ */ I("div", { className: "amodal-chat__messages", "data-testid": "message-list", children: [
427
+ c.map((n) => {
428
+ switch (n.type) {
429
429
  case "user":
430
- return /* @__PURE__ */ v("div", { className: "amodal-chat__message amodal-chat__message--user", "data-testid": "user-message", children: o.text }, o.id);
430
+ return /* @__PURE__ */ v("div", { className: "amodal-chat__message amodal-chat__message--user", "data-testid": "user-message", children: n.text }, n.id);
431
431
  case "assistant_text":
432
- return /* @__PURE__ */ v("div", { className: "amodal-chat__message amodal-chat__message--assistant", "data-testid": "assistant-message", children: o.contentBlocks.map((d, p) => {
432
+ return /* @__PURE__ */ v("div", { className: "amodal-chat__message amodal-chat__message--assistant", "data-testid": "assistant-message", children: n.contentBlocks.map((d, f) => {
433
433
  switch (d.type) {
434
434
  case "text":
435
- return /* @__PURE__ */ v("div", { className: "amodal-chat__text", children: r ? r(d.text) : d.text }, `text-${String(p)}`);
435
+ return /* @__PURE__ */ v("div", { className: "amodal-chat__text", children: r ? r(d.text) : d.text }, `text-${String(f)}`);
436
436
  case "tool_calls":
437
437
  return /* @__PURE__ */ v("div", { className: "amodal-chat__tool-calls", children: d.calls.map(
438
- (l) => t ? /* @__PURE__ */ v("div", { children: t(l) }, l.toolId) : /* @__PURE__ */ w("div", { className: "amodal-chat__tool-call", "data-testid": "tool-call", children: [
438
+ (l) => t ? /* @__PURE__ */ v("div", { children: t(l) }, l.toolId) : /* @__PURE__ */ I("div", { className: "amodal-chat__tool-call", "data-testid": "tool-call", children: [
439
439
  /* @__PURE__ */ v("span", { className: "amodal-chat__tool-name", children: l.toolName }),
440
440
  /* @__PURE__ */ v("span", { className: "amodal-chat__tool-status", children: l.status })
441
441
  ] }, l.toolId)
442
- ) }, `tools-${String(p)}`);
442
+ ) }, `tools-${String(f)}`);
443
443
  case "confirmation": {
444
444
  const l = d.confirmation, b = () => {
445
445
  l.correlationId && S(l.correlationId, !0);
446
446
  }, T = () => {
447
447
  l.correlationId && S(l.correlationId, !1);
448
448
  };
449
- return e ? /* @__PURE__ */ v("div", { children: e(l, b, T) }, `conf-${String(p)}`) : l.escalated || l.params && Object.keys(l.params).length > 0 ? /* @__PURE__ */ v(J, { confirmation: l, onApprove: b, onDeny: T }, `conf-${String(p)}`) : /* @__PURE__ */ v(H, { confirmation: l, onApprove: b, onDeny: T }, `conf-${String(p)}`);
449
+ return e ? /* @__PURE__ */ v("div", { children: e(l, b, T) }, `conf-${String(f)}`) : l.escalated || l.params && Object.keys(l.params).length > 0 ? /* @__PURE__ */ v(J, { confirmation: l, onApprove: b, onDeny: T }, `conf-${String(f)}`) : /* @__PURE__ */ v(H, { confirmation: l, onApprove: b, onDeny: T }, `conf-${String(f)}`);
450
450
  }
451
451
  case "widget":
452
- return /* @__PURE__ */ v("div", { className: "amodal-chat__widget", "data-testid": "widget", children: d.widgetType }, `widget-${String(p)}`);
452
+ return /* @__PURE__ */ v("div", { className: "amodal-chat__widget", "data-testid": "widget", children: d.widgetType }, `widget-${String(f)}`);
453
453
  default:
454
454
  return null;
455
455
  }
456
- }) }, o.id);
456
+ }) }, n.id);
457
457
  case "error":
458
- return /* @__PURE__ */ v("div", { className: "amodal-chat__message amodal-chat__message--error", "data-testid": "error-message", children: o.message }, o.id);
458
+ return /* @__PURE__ */ v("div", { className: "amodal-chat__message amodal-chat__message--error", "data-testid": "error-message", children: n.message }, n.id);
459
459
  default:
460
460
  return null;
461
461
  }
462
462
  }),
463
463
  /* @__PURE__ */ v("div", { ref: h })
464
464
  ] }),
465
- /* @__PURE__ */ w("form", { className: "amodal-chat__input-bar", onSubmit: m, "data-testid": "input-bar", children: [
465
+ /* @__PURE__ */ I("form", { className: "amodal-chat__input-bar", onSubmit: m, "data-testid": "input-bar", children: [
466
466
  /* @__PURE__ */ v(
467
467
  "input",
468
468
  {
469
469
  className: "amodal-chat__input",
470
470
  value: E,
471
- onChange: (o) => _(o.target.value),
471
+ onChange: (n) => _(n.target.value),
472
472
  placeholder: s,
473
473
  disabled: i,
474
474
  "data-testid": "chat-input"
@@ -487,43 +487,43 @@ function ee({
487
487
  ] })
488
488
  ] });
489
489
  }
490
- function te({ prompt: s, label: r, context: t, onComplete: e, onError: n }) {
490
+ function te({ prompt: s, label: r, context: t, onComplete: e, onError: o }) {
491
491
  const [a, c] = y(!1), { messages: u, send: i, isStreaming: S, respondToConfirmation: E } = W({
492
492
  context: t,
493
493
  onStreamEnd: () => {
494
- const o = u[u.length - 1];
495
- o && o.type === "assistant_text" ? e == null || e(o.text) : o && o.type === "error" && (n == null || n(o.message));
494
+ const n = u[u.length - 1];
495
+ n && n.type === "assistant_text" ? e == null || e(n.text) : n && n.type === "error" && (o == null || o(n.message));
496
496
  }
497
497
  }), _ = A(() => {
498
498
  a || S || (c(!0), i(s));
499
- }, [a, S, i, s]), h = [...u].reverse().find((o) => o.type === "assistant_text"), m = h && h.type === "assistant_text" ? h.confirmations.filter((o) => o.status === "pending") : [], f = (o, d) => {
500
- const p = () => {
501
- o.correlationId && E(o.correlationId, !0);
499
+ }, [a, S, i, s]), h = [...u].reverse().find((n) => n.type === "assistant_text"), m = h && h.type === "assistant_text" ? h.confirmations.filter((n) => n.status === "pending") : [], p = (n, d) => {
500
+ const f = () => {
501
+ n.correlationId && E(n.correlationId, !0);
502
502
  }, l = () => {
503
- o.correlationId && E(o.correlationId, !1);
503
+ n.correlationId && E(n.correlationId, !1);
504
504
  };
505
- return o.escalated || o.params && Object.keys(o.params).length > 0 ? /* @__PURE__ */ v(
505
+ return n.escalated || n.params && Object.keys(n.params).length > 0 ? /* @__PURE__ */ v(
506
506
  J,
507
507
  {
508
- confirmation: o,
509
- onApprove: p,
508
+ confirmation: n,
509
+ onApprove: f,
510
510
  onDeny: l
511
511
  },
512
- o.correlationId ?? String(d)
512
+ n.correlationId ?? String(d)
513
513
  ) : /* @__PURE__ */ v(
514
514
  H,
515
515
  {
516
- confirmation: o,
517
- onApprove: p,
516
+ confirmation: n,
517
+ onApprove: f,
518
518
  onDeny: l
519
519
  },
520
- o.correlationId ?? String(d)
520
+ n.correlationId ?? String(d)
521
521
  );
522
522
  };
523
- return a ? /* @__PURE__ */ w("div", { className: "amodal-action", "data-testid": "action-container", children: [
523
+ return a ? /* @__PURE__ */ I("div", { className: "amodal-action", "data-testid": "action-container", children: [
524
524
  S && /* @__PURE__ */ v("div", { className: "amodal-action__loading", "data-testid": "action-loading", children: "Processing..." }),
525
525
  h && h.type === "assistant_text" && h.text && /* @__PURE__ */ v("div", { className: "amodal-action__result", "data-testid": "action-result", children: h.text }),
526
- m.map(f)
526
+ m.map(p)
527
527
  ] }) : /* @__PURE__ */ v(
528
528
  "button",
529
529
  {
@@ -540,20 +540,20 @@ function te({ prompt: s, label: r, context: t, onComplete: e, onError: n }) {
540
540
  * SPDX-License-Identifier: MIT
541
541
  */
542
542
  function se(s) {
543
- const { prompt: r, context: t, autoFetch: e = !0 } = s, { client: n } = k(), [a, c] = y(null), [u, i] = y(!1), [S, E] = y(null), _ = N(null), h = N(!1), m = A(async () => {
543
+ const { prompt: r, context: t, autoFetch: e = !0 } = s, { client: o } = R(), [a, c] = y(null), [u, i] = y(!1), [S, E] = y(null), _ = N(null), h = N(!1), m = A(async () => {
544
544
  _.current && _.current.abort();
545
- const o = new AbortController();
546
- _.current = o, i(!0), E(null);
545
+ const n = new AbortController();
546
+ _.current = n, i(!0), E(null);
547
547
  try {
548
548
  let d = "";
549
- const p = [];
550
- for await (const l of n.chatStream(r, { context: t, signal: o.signal }))
549
+ const f = [];
550
+ for await (const l of o.chatStream(r, { context: t, signal: n.signal }))
551
551
  switch (l.type) {
552
552
  case "text_delta":
553
553
  d += l.content;
554
554
  break;
555
555
  case "tool_call_start":
556
- p.push({
556
+ f.push({
557
557
  toolId: l.tool_id,
558
558
  toolName: l.tool_name,
559
559
  parameters: l.parameters,
@@ -561,7 +561,7 @@ function se(s) {
561
561
  });
562
562
  break;
563
563
  case "tool_call_result": {
564
- const b = p.find((T) => T.toolId === l.tool_id);
564
+ const b = f.find((T) => T.toolId === l.tool_id);
565
565
  b && (b.status = l.status, b.result = l.result, b.duration_ms = l.duration_ms, b.error = l.error);
566
566
  break;
567
567
  }
@@ -571,18 +571,18 @@ function se(s) {
571
571
  default:
572
572
  break;
573
573
  }
574
- c({ text: d, toolCalls: p });
574
+ c({ text: d, toolCalls: f });
575
575
  } catch (d) {
576
576
  d instanceof DOMException && d.name === "AbortError" || E(d instanceof Error ? d.message : "Unknown error");
577
577
  } finally {
578
578
  i(!1), _.current = null;
579
579
  }
580
- }, [n, r, t]), f = A(() => {
580
+ }, [o, r, t]), p = A(() => {
581
581
  m();
582
582
  }, [m]);
583
- return R(() => (e && !h.current && (h.current = !0, m()), () => {
583
+ return w(() => (e && !h.current && (h.current = !0, m()), () => {
584
584
  _.current && _.current.abort();
585
- }), [e, m]), { brief: a, isLoading: u, error: S, refresh: f };
585
+ }), [e, m]), { brief: a, isLoading: u, error: S, refresh: p };
586
586
  }
587
587
  /**
588
588
  * @license
@@ -590,13 +590,13 @@ function se(s) {
590
590
  * SPDX-License-Identifier: MIT
591
591
  */
592
592
  function re(s) {
593
- const { prompt: r, context: t, autoFetch: e = !0 } = s, { client: n } = k(), [a, c] = y("idle"), [u, i] = y(""), [S, E] = y(""), [_, h] = y(null), m = N(null), f = N(!1), o = A(async () => {
593
+ const { prompt: r, context: t, autoFetch: e = !0 } = s, { client: o } = R(), [a, c] = y("idle"), [u, i] = y(""), [S, E] = y(""), [_, h] = y(null), m = N(null), p = N(!1), n = A(async () => {
594
594
  m.current && m.current.abort();
595
- const p = new AbortController();
596
- m.current = p, c("loading"), h(null), i(""), E("");
595
+ const f = new AbortController();
596
+ m.current = f, c("loading"), h(null), i(""), E("");
597
597
  try {
598
598
  let l = "";
599
- for await (const T of n.chatStream(r, { context: t, signal: p.signal }))
599
+ for await (const T of o.chatStream(r, { context: t, signal: f.signal }))
600
600
  switch (T.type) {
601
601
  case "text_delta":
602
602
  l += T.content;
@@ -616,12 +616,12 @@ function re(s) {
616
616
  } finally {
617
617
  m.current = null;
618
618
  }
619
- }, [n, r, t]), d = A(() => {
620
- o();
621
- }, [o]);
622
- return R(() => (e && !f.current && (f.current = !0, o()), () => {
619
+ }, [o, r, t]), d = A(() => {
620
+ n();
621
+ }, [n]);
622
+ return w(() => (e && !p.current && (p.current = !0, n()), () => {
623
623
  m.current && m.current.abort();
624
- }), [e, o]), { status: a, summary: u, details: S, isLoading: a === "loading", error: _, refresh: d };
624
+ }), [e, n]), { status: a, summary: u, details: S, isLoading: a === "loading", error: _, refresh: d };
625
625
  }
626
626
  /**
627
627
  * @license
@@ -629,10 +629,10 @@ function re(s) {
629
629
  * SPDX-License-Identifier: MIT
630
630
  */
631
631
  function ae(s) {
632
- const { taskId: r, autoStream: t = !0 } = s, { client: e } = k(), [n, a] = y("idle"), [c, u] = y(""), [i, S] = y(""), [E, _] = y([]), [h, m] = y(null), f = N(null), o = N(!1), d = A(async () => {
633
- f.current && f.current.abort();
632
+ const { taskId: r, autoStream: t = !0 } = s, { client: e } = R(), [o, a] = y("idle"), [c, u] = y(""), [i, S] = y(""), [E, _] = y([]), [h, m] = y(null), p = N(null), n = N(!1), d = A(async () => {
633
+ p.current && p.current.abort();
634
634
  const b = new AbortController();
635
- f.current = b, a("running"), m(null), _([]), S(""), u("");
635
+ p.current = b, a("running"), m(null), _([]), S(""), u("");
636
636
  try {
637
637
  let T = "";
638
638
  for await (const x of e.streamTask(r, b.signal))
@@ -655,25 +655,25 @@ function ae(s) {
655
655
  default:
656
656
  break;
657
657
  }
658
- n === "running" && a("completed");
658
+ o === "running" && a("completed");
659
659
  } catch (T) {
660
660
  T instanceof DOMException && T.name === "AbortError" || (m(T instanceof Error ? T.message : "Unknown error"), a("error"));
661
661
  } finally {
662
- f.current = null;
662
+ p.current = null;
663
663
  }
664
- }, [e, r, n]), p = A(() => {
665
- f.current && (f.current.abort(), f.current = null);
664
+ }, [e, r, o]), f = A(() => {
665
+ p.current && (p.current.abort(), p.current = null);
666
666
  }, []), l = N(d);
667
- return l.current = d, R(() => (t && !o.current && (o.current = !0, l.current()), () => {
668
- f.current && f.current.abort();
667
+ return l.current = d, w(() => (t && !n.current && (n.current = !0, l.current()), () => {
668
+ p.current && p.current.abort();
669
669
  }), [t]), {
670
- status: n,
670
+ status: o,
671
671
  progress: c,
672
672
  result: i,
673
673
  events: E,
674
674
  error: h,
675
675
  start: () => void d(),
676
- stop: p
676
+ stop: f
677
677
  };
678
678
  }
679
679
  /**
@@ -682,19 +682,19 @@ function ae(s) {
682
682
  * SPDX-License-Identifier: MIT
683
683
  */
684
684
  function ne(s) {
685
- const { prompt: r, context: t, autoFetch: e = !0 } = s, { client: n } = k(), [a, c] = y(null), [u, i] = y(!1), [S, E] = y(null), _ = N(null), h = N(!1), m = A(async () => {
685
+ const { prompt: r, context: t, autoFetch: e = !0 } = s, { client: o } = R(), [a, c] = y(null), [u, i] = y(!1), [S, E] = y(null), _ = N(null), h = N(!1), m = A(async () => {
686
686
  _.current && _.current.abort();
687
- const o = new AbortController();
688
- _.current = o, i(!0), E(null);
687
+ const n = new AbortController();
688
+ _.current = n, i(!0), E(null);
689
689
  try {
690
690
  let d = "";
691
- for await (const p of n.chatStream(r, { context: t, signal: o.signal }))
692
- switch (p.type) {
691
+ for await (const f of o.chatStream(r, { context: t, signal: n.signal }))
692
+ switch (f.type) {
693
693
  case "text_delta":
694
- d += p.content;
694
+ d += f.content;
695
695
  break;
696
696
  case "error":
697
- E(p.message);
697
+ E(f.message);
698
698
  break;
699
699
  default:
700
700
  break;
@@ -705,12 +705,12 @@ function ne(s) {
705
705
  } finally {
706
706
  i(!1), _.current = null;
707
707
  }
708
- }, [n, r, t]), f = A(() => {
708
+ }, [o, r, t]), p = A(() => {
709
709
  m();
710
710
  }, [m]);
711
- return R(() => (e && !h.current && (h.current = !0, m()), () => {
711
+ return w(() => (e && !h.current && (h.current = !0, m()), () => {
712
712
  _.current && _.current.abort();
713
- }), [e, m]), { data: a, isLoading: u, error: S, refetch: f };
713
+ }), [e, m]), { data: a, isLoading: u, error: S, refetch: p };
714
714
  }
715
715
  /**
716
716
  * @license
@@ -718,37 +718,37 @@ function ne(s) {
718
718
  * SPDX-License-Identifier: MIT
719
719
  */
720
720
  function oe(s, r) {
721
- const { key: t, refreshInterval: e = 3e4 } = r, { client: n } = k(), [a, c] = y(null), [u, i] = y([]), [S, E] = y(!0), [_, h] = y(null), m = N(null), f = A(async () => {
721
+ const { key: t, refreshInterval: e = 3e4 } = r, { client: o } = R(), [a, c] = y(null), [u, i] = y([]), [S, E] = y(!0), [_, h] = y(null), m = N(null), p = A(async () => {
722
722
  m.current && m.current.abort();
723
723
  const d = new AbortController();
724
724
  m.current = d;
725
725
  try {
726
- const p = await n.getStoreDocument(s, t, d.signal);
727
- c(p.document), i(p.history), h(null);
728
- } catch (p) {
729
- p instanceof DOMException && p.name === "AbortError" || h(p instanceof Error ? p.message : "Failed to fetch document");
726
+ const f = await o.getStoreDocument(s, t, d.signal);
727
+ c(f.document), i(f.history), h(null);
728
+ } catch (f) {
729
+ f instanceof DOMException && f.name === "AbortError" || h(f instanceof Error ? f.message : "Failed to fetch document");
730
730
  } finally {
731
731
  E(!1), m.current = null;
732
732
  }
733
- }, [n, s, t]), o = A(() => {
734
- f();
735
- }, [f]);
736
- return R(() => (E(!0), f(), () => {
733
+ }, [o, s, t]), n = A(() => {
734
+ p();
735
+ }, [p]);
736
+ return w(() => (E(!0), p(), () => {
737
737
  m.current && m.current.abort();
738
- }), [f]), R(() => {
738
+ }), [p]), w(() => {
739
739
  if (e <= 0) return;
740
740
  const d = setInterval(() => {
741
- f();
741
+ p();
742
742
  }, e);
743
743
  return () => clearInterval(d);
744
- }, [f, e]), {
744
+ }, [p, e]), {
745
745
  data: (a == null ? void 0 : a.payload) ?? null,
746
746
  meta: (a == null ? void 0 : a.meta) ?? null,
747
747
  document: a,
748
748
  history: u,
749
749
  isLoading: S,
750
750
  error: _,
751
- refetch: o
751
+ refetch: n
752
752
  };
753
753
  }
754
754
  /**
@@ -757,29 +757,29 @@ function oe(s, r) {
757
757
  * SPDX-License-Identifier: MIT
758
758
  */
759
759
  function le(s, r = {}) {
760
- const { filter: t, sort: e, limit: n = 20, refreshInterval: a = 3e4 } = r, { client: c } = k(), [u, i] = y([]), [S, E] = y(0), [_, h] = y(!1), [m, f] = y(!0), [o, d] = y(null), p = N(null), l = t ? JSON.stringify(t) : "", b = A(async () => {
761
- p.current && p.current.abort();
760
+ const { filter: t, sort: e, limit: o = 20, refreshInterval: a = 3e4 } = r, { client: c } = R(), [u, i] = y([]), [S, E] = y(0), [_, h] = y(!1), [m, p] = y(!0), [n, d] = y(null), f = N(null), l = t ? JSON.stringify(t) : "", b = A(async () => {
761
+ f.current && f.current.abort();
762
762
  const x = new AbortController();
763
- p.current = x;
763
+ f.current = x;
764
764
  try {
765
765
  const C = await c.getStoreDocuments(s, {
766
766
  filter: l ? JSON.parse(l) : void 0,
767
767
  sort: e,
768
- limit: n,
768
+ limit: o,
769
769
  signal: x.signal
770
770
  });
771
771
  i(C.documents), E(C.total), h(C.hasMore), d(null);
772
772
  } catch (C) {
773
773
  C instanceof DOMException && C.name === "AbortError" || d(C instanceof Error ? C.message : "Failed to fetch store list");
774
774
  } finally {
775
- f(!1), p.current = null;
775
+ p(!1), f.current = null;
776
776
  }
777
- }, [c, s, l, e, n]), T = A(() => {
777
+ }, [c, s, l, e, o]), T = A(() => {
778
778
  b();
779
779
  }, [b]);
780
- return R(() => (f(!0), b(), () => {
781
- p.current && p.current.abort();
782
- }), [b]), R(() => {
780
+ return w(() => (p(!0), b(), () => {
781
+ f.current && f.current.abort();
782
+ }), [b]), w(() => {
783
783
  if (a <= 0) return;
784
784
  const x = setInterval(() => {
785
785
  b();
@@ -791,7 +791,7 @@ function le(s, r = {}) {
791
791
  total: S,
792
792
  hasMore: _,
793
793
  isLoading: m,
794
- error: o,
794
+ error: n,
795
795
  refetch: T
796
796
  };
797
797
  }
@@ -801,32 +801,32 @@ function le(s, r = {}) {
801
801
  * SPDX-License-Identifier: MIT
802
802
  */
803
803
  function ce(s, r = {}) {
804
- const { client: t } = k(), [e, n] = y(!1), [a, c] = y(null), [u, i] = y(null), S = N(null);
804
+ const { client: t } = R(), [e, o] = y(!1), [a, c] = y(null), [u, i] = y(null), S = N(null);
805
805
  return { execute: A(
806
806
  (_) => {
807
807
  S.current && S.current.abort();
808
808
  const h = new AbortController();
809
- S.current = h, n(!0), c(null), i(null);
809
+ S.current = h, o(!0), c(null), i(null);
810
810
  let m = `Run skill "${s}"`;
811
811
  _ && Object.keys(_).length > 0 && (m += ` with parameters: ${JSON.stringify(_)}`), r.stores && r.stores.length > 0 && (m += `. Write results to stores: ${r.stores.join(", ")}`), r.confirm && (m += ". Confirm before writing."), (async () => {
812
812
  try {
813
- let f = "";
814
- for await (const o of t.chatStream(m, { signal: h.signal }))
815
- switch (o.type) {
813
+ let p = "";
814
+ for await (const n of t.chatStream(m, { signal: h.signal }))
815
+ switch (n.type) {
816
816
  case "text_delta":
817
- f += o.content;
817
+ p += n.content;
818
818
  break;
819
819
  case "error":
820
- i(o.message);
820
+ i(n.message);
821
821
  break;
822
822
  default:
823
823
  break;
824
824
  }
825
- c(f);
826
- } catch (f) {
827
- f instanceof DOMException && f.name === "AbortError" || i(f instanceof Error ? f.message : "Skill execution failed");
825
+ c(p);
826
+ } catch (p) {
827
+ p instanceof DOMException && p.name === "AbortError" || i(p instanceof Error ? p.message : "Skill execution failed");
828
828
  } finally {
829
- n(!1), S.current = null;
829
+ o(!1), S.current = null;
830
830
  }
831
831
  })();
832
832
  },
@@ -849,7 +849,7 @@ export {
849
849
  ee as AmodalChat,
850
850
  Z as AmodalProvider,
851
851
  me as ChatClient,
852
- fe as ChatStream,
852
+ pe as ChatStream,
853
853
  H as ConfirmCard,
854
854
  q as NavigateContext,
855
855
  J as ReviewCard,
@@ -862,16 +862,16 @@ export {
862
862
  xe as defaultEntityExtractor,
863
863
  _e as defaultTheme,
864
864
  Ce as getSessionHistory,
865
- we as listSessions,
865
+ Ie as listSessions,
866
866
  he as mergeTheme,
867
- Re as parseSSELine,
868
- ke as streamChat,
869
- Ie as streamSSE,
867
+ we as parseSSELine,
868
+ Re as streamChat,
869
+ ke as streamSSE,
870
870
  De as streamSSEGet,
871
871
  Me as updateSession,
872
872
  se as useAmodalBrief,
873
873
  W as useAmodalChat,
874
- k as useAmodalContext,
874
+ R as useAmodalContext,
875
875
  re as useAmodalInsight,
876
876
  ne as useAmodalQuery,
877
877
  ae as useAmodalTask,