@adecore/agents-react 0.36.0 → 0.37.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.
Files changed (56) hide show
  1. package/dist/agents/provider-paths.js +3 -1
  2. package/dist/chat/chat-client.d.ts +5 -0
  3. package/dist/chat/chat-client.js +91 -20
  4. package/dist/chat/index.d.ts +1 -0
  5. package/dist/chat/index.js +2 -1
  6. package/dist/chat/logic/picker-entries.js +11 -6
  7. package/dist/chat/logic/scrubber.d.ts +4 -2
  8. package/dist/chat/logic/scrubber.js +3 -3
  9. package/dist/chat/pending-prompts.d.ts +15 -0
  10. package/dist/chat/pending-prompts.js +93 -0
  11. package/dist/chat/reading-width.js +6 -2
  12. package/dist/chat/ui/PromptComposer.d.ts +2 -2
  13. package/dist/chat/ui/PromptComposer.js +92 -98
  14. package/dist/chat/ui/SubagentTimeline.js +128 -182
  15. package/dist/chat/ui/Timeline.js +86 -60
  16. package/dist/chat/ui/code-lines.d.ts +5 -0
  17. package/dist/chat/ui/code-lines.js +37 -0
  18. package/dist/chat/ui/composer/use-pending-requests.d.ts +2 -2
  19. package/dist/chat/ui/composer/use-pending-requests.js +29 -37
  20. package/dist/chat/ui/highlighter.d.ts +1 -1
  21. package/dist/chat/ui/highlighter.js +4 -2
  22. package/dist/locales/en/agent-chat.d.ts +1 -0
  23. package/dist/locales/en/agent-chat.js +1 -0
  24. package/dist/locales/nl/agent-chat.d.ts +1 -0
  25. package/dist/locales/nl/agent-chat.js +1 -0
  26. package/dist/prompts/logic/subjects.d.ts +5 -0
  27. package/dist/prompts/ui/PromptCard.js +1 -1
  28. package/dist/prompts/ui/PromptView.js +104 -95
  29. package/dist/providers/parts.js +2 -1
  30. package/dist/state/chats.d.ts +4 -0
  31. package/dist/state/chats.js +84 -48
  32. package/dist/theme.css +6 -2
  33. package/dist/usage/format.js +4 -2
  34. package/package.json +8 -8
  35. package/src/agents/provider-paths.ts +5 -1
  36. package/src/chat/chat-client.ts +92 -21
  37. package/src/chat/index.ts +2 -0
  38. package/src/chat/logic/picker-entries.ts +6 -4
  39. package/src/chat/logic/scrubber.ts +8 -6
  40. package/src/chat/pending-prompts.ts +108 -0
  41. package/src/chat/reading-width.ts +9 -2
  42. package/src/chat/ui/PromptComposer.tsx +10 -7
  43. package/src/chat/ui/SubagentTimeline.tsx +1 -24
  44. package/src/chat/ui/Timeline.tsx +66 -40
  45. package/src/chat/ui/code-lines.ts +37 -0
  46. package/src/chat/ui/composer/use-pending-requests.ts +13 -21
  47. package/src/chat/ui/highlighter.ts +4 -3
  48. package/src/locales/en/agent-chat.ts +1 -0
  49. package/src/locales/nl/agent-chat.ts +1 -0
  50. package/src/prompts/logic/subjects.ts +4 -1
  51. package/src/prompts/ui/PromptCard.tsx +1 -1
  52. package/src/prompts/ui/PromptView.tsx +7 -1
  53. package/src/providers/parts.tsx +2 -1
  54. package/src/state/chats.ts +63 -18
  55. package/src/theme.css +6 -2
  56. package/src/usage/format.ts +4 -2
@@ -12,6 +12,7 @@ import { useChatHost } from '../../host.js';
12
12
  import { useChatScope } from '../../scope.js';
13
13
  import { useChatActions } from '../actions.js';
14
14
  import { Button, Icon } from '@adecore/ui';
15
+ import { useProviders } from '../../state/providers.js';
15
16
  import { useHostExtraPrompts } from '../../host-hooks.js';
16
17
  /* The one being read stays in front; otherwise blocking before optional, oldest first, as everywhere else. */
17
18
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -19,7 +20,7 @@ function pickSubject(waiting, activeId) {
19
20
  return waiting.find(subject => promptIdOf(subject) === activeId) ?? orderPrompts(waiting, isBlockingSubject, promptCreatedAt)[0] ?? null;
20
21
  }
21
22
  export function PromptComposer(t0) {
22
- const $ = _c(65);
23
+ const $ = _c(64);
23
24
  const {
24
25
  chatId,
25
26
  pending,
@@ -40,35 +41,24 @@ export function PromptComposer(t0) {
40
41
  } = useChatScope();
41
42
  const host = useChatHost();
42
43
  const actions = useChatActions();
44
+ const providers = useProviders(_temp);
43
45
  const elsewhere = onShowElsewhere !== undefined;
44
46
  const extra = useHostExtraPrompts(id, chatId);
45
47
  let t1;
46
48
  if ($[0] !== chatId || $[1] !== extra || $[2] !== pending) {
47
49
  let t2;
48
50
  if ($[4] !== chatId) {
49
- t2 = item => ({
50
- kind: "chat",
51
+ t2 = prompt => ({
52
+ kind: "host",
51
53
  nodeId: chatId,
52
- item
54
+ prompt
53
55
  });
54
56
  $[4] = chatId;
55
57
  $[5] = t2;
56
58
  } else {
57
59
  t2 = $[5];
58
60
  }
59
- let t3;
60
- if ($[6] !== chatId) {
61
- t3 = prompt => ({
62
- kind: "host",
63
- nodeId: chatId,
64
- prompt
65
- });
66
- $[6] = chatId;
67
- $[7] = t3;
68
- } else {
69
- t3 = $[7];
70
- }
71
- t1 = [...pending.map(t2), ...extra.map(t3)];
61
+ t1 = [...pending, ...extra.map(t2)];
72
62
  $[0] = chatId;
73
63
  $[1] = extra;
74
64
  $[2] = pending;
@@ -78,18 +68,18 @@ export function PromptComposer(t0) {
78
68
  }
79
69
  const subjects = t1;
80
70
  let t2;
81
- if ($[8] !== disabled || $[9] !== subjects) {
71
+ if ($[6] !== disabled || $[7] !== subjects) {
82
72
  t2 = {
83
73
  prompts: subjects,
84
74
  idOf: promptIdOf,
85
75
  pick: pickSubject,
86
76
  disabled
87
77
  };
88
- $[8] = disabled;
89
- $[9] = subjects;
90
- $[10] = t2;
78
+ $[6] = disabled;
79
+ $[7] = subjects;
80
+ $[8] = t2;
91
81
  } else {
92
- t2 = $[10];
82
+ t2 = $[8];
93
83
  }
94
84
  const session = usePromptSession(t2);
95
85
  const ref = useRef(null);
@@ -102,34 +92,34 @@ export function PromptComposer(t0) {
102
92
  const expanded = !!active && !held;
103
93
  const heldKey = useRef(null);
104
94
  let t3;
105
- if ($[11] !== onAllAnswered) {
95
+ if ($[9] !== onAllAnswered) {
106
96
  t3 = () => onAllAnswered?.();
107
- $[11] = onAllAnswered;
108
- $[12] = t3;
97
+ $[9] = onAllAnswered;
98
+ $[10] = t3;
109
99
  } else {
110
- t3 = $[12];
100
+ t3 = $[10];
111
101
  }
112
102
  const refocus = useFocusAfterAnswer(activeKey, ref, t3);
113
103
  let t4;
114
104
  let t5;
115
- if ($[13] !== activeKey || $[14] !== held) {
105
+ if ($[11] !== activeKey || $[12] !== held) {
116
106
  t4 = () => {
117
107
  if (held) {
118
108
  heldKey.current = activeKey;
119
109
  }
120
110
  };
121
111
  t5 = [held, activeKey];
122
- $[13] = activeKey;
123
- $[14] = held;
124
- $[15] = t4;
125
- $[16] = t5;
112
+ $[11] = activeKey;
113
+ $[12] = held;
114
+ $[13] = t4;
115
+ $[14] = t5;
126
116
  } else {
127
- t4 = $[15];
128
- t5 = $[16];
117
+ t4 = $[13];
118
+ t5 = $[14];
129
119
  }
130
120
  useEffect(t4, t5);
131
121
  let t6;
132
- if ($[17] !== activeKey || $[18] !== elsewhere || $[19] !== expanded || $[20] !== focused || $[21] !== hasDraft || $[22] !== hold?.releasedBy) {
122
+ if ($[15] !== activeKey || $[16] !== elsewhere || $[17] !== expanded || $[18] !== focused || $[19] !== hasDraft || $[20] !== hold?.releasedBy) {
133
123
  t6 = () => {
134
124
  if (hold?.releasedBy === "blur" && heldKey.current === activeKey) {
135
125
  return;
@@ -142,33 +132,33 @@ export function PromptComposer(t0) {
142
132
  }
143
133
  }
144
134
  };
145
- $[17] = activeKey;
146
- $[18] = elsewhere;
147
- $[19] = expanded;
148
- $[20] = focused;
149
- $[21] = hasDraft;
150
- $[22] = hold?.releasedBy;
151
- $[23] = t6;
135
+ $[15] = activeKey;
136
+ $[16] = elsewhere;
137
+ $[17] = expanded;
138
+ $[18] = focused;
139
+ $[19] = hasDraft;
140
+ $[20] = hold?.releasedBy;
141
+ $[21] = t6;
152
142
  } else {
153
- t6 = $[23];
143
+ t6 = $[21];
154
144
  }
155
145
  const t7 = hold?.releasedBy;
156
146
  let t8;
157
- if ($[24] !== activeKey || $[25] !== elsewhere || $[26] !== expanded || $[27] !== focused || $[28] !== hasDraft || $[29] !== t7) {
147
+ if ($[22] !== activeKey || $[23] !== elsewhere || $[24] !== expanded || $[25] !== focused || $[26] !== hasDraft || $[27] !== t7) {
158
148
  t8 = [activeKey, expanded, focused, elsewhere, hasDraft, t7];
159
- $[24] = activeKey;
160
- $[25] = elsewhere;
161
- $[26] = expanded;
162
- $[27] = focused;
163
- $[28] = hasDraft;
164
- $[29] = t7;
165
- $[30] = t8;
149
+ $[22] = activeKey;
150
+ $[23] = elsewhere;
151
+ $[24] = expanded;
152
+ $[25] = focused;
153
+ $[26] = hasDraft;
154
+ $[27] = t7;
155
+ $[28] = t8;
166
156
  } else {
167
- t8 = $[30];
157
+ t8 = $[28];
168
158
  }
169
159
  useEffect(t6, t8);
170
160
  let t9;
171
- if ($[31] !== active || $[32] !== asksApproval || $[33] !== elsewhere || $[34] !== onShowElsewhere || $[35] !== t) {
161
+ if ($[29] !== active || $[30] !== asksApproval || $[31] !== elsewhere || $[32] !== onShowElsewhere || $[33] !== t) {
172
162
  t9 = active && elsewhere && /*#__PURE__*/_jsxs("button", {
173
163
  type: "button",
174
164
  className: "flex w-full items-center gap-2 px-3.5 py-3 text-left text-sm text-text-muted hover:text-text",
@@ -186,17 +176,17 @@ export function PromptComposer(t0) {
186
176
  className: "shrink-0"
187
177
  })]
188
178
  });
189
- $[31] = active;
190
- $[32] = asksApproval;
191
- $[33] = elsewhere;
192
- $[34] = onShowElsewhere;
193
- $[35] = t;
194
- $[36] = t9;
179
+ $[29] = active;
180
+ $[30] = asksApproval;
181
+ $[31] = elsewhere;
182
+ $[32] = onShowElsewhere;
183
+ $[33] = t;
184
+ $[34] = t9;
195
185
  } else {
196
- t9 = $[36];
186
+ t9 = $[34];
197
187
  }
198
188
  let t10;
199
- if ($[37] !== actions || $[38] !== active || $[39] !== activeKey || $[40] !== denyReason || $[41] !== disabled || $[42] !== elsewhere || $[43] !== expanded || $[44] !== hasDraft || $[45] !== host || $[46] !== refocus || $[47] !== session) {
189
+ if ($[35] !== actions || $[36] !== active || $[37] !== activeKey || $[38] !== denyReason || $[39] !== disabled || $[40] !== elsewhere || $[41] !== expanded || $[42] !== hasDraft || $[43] !== host || $[44] !== providers || $[45] !== refocus || $[46] !== session) {
200
190
  t10 = active && !elsewhere && /*#__PURE__*/_jsx("div", {
201
191
  hidden: !expanded,
202
192
  children: /*#__PURE__*/_jsx(PromptView, {
@@ -213,29 +203,30 @@ export function PromptComposer(t0) {
213
203
  },
214
204
  more: session.waiting.length - 1,
215
205
  hasDraft: hasDraft,
216
- denyReason: denyReason,
206
+ denyReason: active.kind === "chat" && active.source?.provider !== undefined ? providers.find(provider => provider.kind === active.source?.provider)?.capabilities.denyReason === true : denyReason,
217
207
  disabled: disabled,
218
208
  sending: session.sending,
219
209
  error: session.errorOf(promptIdOf(active))
220
210
  }, activeKey)
221
211
  });
222
- $[37] = actions;
223
- $[38] = active;
224
- $[39] = activeKey;
225
- $[40] = denyReason;
226
- $[41] = disabled;
227
- $[42] = elsewhere;
228
- $[43] = expanded;
229
- $[44] = hasDraft;
230
- $[45] = host;
231
- $[46] = refocus;
232
- $[47] = session;
233
- $[48] = t10;
212
+ $[35] = actions;
213
+ $[36] = active;
214
+ $[37] = activeKey;
215
+ $[38] = denyReason;
216
+ $[39] = disabled;
217
+ $[40] = elsewhere;
218
+ $[41] = expanded;
219
+ $[42] = hasDraft;
220
+ $[43] = host;
221
+ $[44] = providers;
222
+ $[45] = refocus;
223
+ $[46] = session;
224
+ $[47] = t10;
234
225
  } else {
235
- t10 = $[48];
226
+ t10 = $[47];
236
227
  }
237
228
  let t11;
238
- if ($[49] !== active || $[50] !== asksApproval || $[51] !== held || $[52] !== hold || $[53] !== t) {
229
+ if ($[48] !== active || $[49] !== asksApproval || $[50] !== held || $[51] !== hold || $[52] !== t) {
239
230
  t11 = held && active && /*#__PURE__*/_jsxs("div", {
240
231
  role: "status",
241
232
  className: "flex items-center gap-2 border-b border-border px-3.5 py-2.5",
@@ -248,52 +239,55 @@ export function PromptComposer(t0) {
248
239
  children: t(asksApproval ? "composer.held.approval" : "composer.held.question")
249
240
  }), /*#__PURE__*/_jsx(Button, {
250
241
  size: "sm",
251
- onMouseDown: _temp,
242
+ onMouseDown: _temp2,
252
243
  onClick: () => hold?.release("show"),
253
244
  children: t("composer.held.show")
254
245
  })]
255
246
  });
256
- $[49] = active;
257
- $[50] = asksApproval;
258
- $[51] = held;
259
- $[52] = hold;
260
- $[53] = t;
261
- $[54] = t11;
247
+ $[48] = active;
248
+ $[49] = asksApproval;
249
+ $[50] = held;
250
+ $[51] = hold;
251
+ $[52] = t;
252
+ $[53] = t11;
262
253
  } else {
263
- t11 = $[54];
254
+ t11 = $[53];
264
255
  }
265
256
  let t12;
266
- if ($[55] !== children || $[56] !== expanded) {
257
+ if ($[54] !== children || $[55] !== expanded) {
267
258
  t12 = /*#__PURE__*/_jsx("div", {
268
259
  hidden: expanded,
269
260
  children: children
270
261
  });
271
- $[55] = children;
272
- $[56] = expanded;
273
- $[57] = t12;
262
+ $[54] = children;
263
+ $[55] = expanded;
264
+ $[56] = t12;
274
265
  } else {
275
- t12 = $[57];
266
+ t12 = $[56];
276
267
  }
277
268
  let t13;
278
- if ($[58] !== session.onClickCapture || $[59] !== session.onPointerDownCapture || $[60] !== t10 || $[61] !== t11 || $[62] !== t12 || $[63] !== t9) {
269
+ if ($[57] !== session.onClickCapture || $[58] !== session.onPointerDownCapture || $[59] !== t10 || $[60] !== t11 || $[61] !== t12 || $[62] !== t9) {
279
270
  t13 = /*#__PURE__*/_jsxs("div", {
280
271
  ref: ref,
281
272
  onPointerDownCapture: session.onPointerDownCapture,
282
273
  onClickCapture: session.onClickCapture,
283
274
  children: [t9, t10, t11, t12]
284
275
  });
285
- $[58] = session.onClickCapture;
286
- $[59] = session.onPointerDownCapture;
287
- $[60] = t10;
288
- $[61] = t11;
289
- $[62] = t12;
290
- $[63] = t9;
291
- $[64] = t13;
276
+ $[57] = session.onClickCapture;
277
+ $[58] = session.onPointerDownCapture;
278
+ $[59] = t10;
279
+ $[60] = t11;
280
+ $[61] = t12;
281
+ $[62] = t9;
282
+ $[63] = t13;
292
283
  } else {
293
- t13 = $[64];
284
+ t13 = $[63];
294
285
  }
295
286
  return t13;
296
287
  }
297
- function _temp(e) {
288
+ function _temp2(e) {
298
289
  return e.preventDefault();
290
+ }
291
+ function _temp(row) {
292
+ return row.providers;
299
293
  }