@tangle-network/agent-app 0.58.14 → 0.58.16

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 (89) hide show
  1. package/dist/VaultPane-RIJM452Y.js +7 -0
  2. package/dist/agent-profiles/d1.js +4 -1
  3. package/dist/agent-profiles/d1.js.map +1 -1
  4. package/dist/agent-profiles/index.d.ts +1 -1
  5. package/dist/agent-profiles/index.js +10 -1
  6. package/dist/agent-profiles/self-management.d.ts +77 -0
  7. package/dist/assistant/index.js +13 -11
  8. package/dist/assistant/index.js.map +1 -1
  9. package/dist/chat-react/index.js +4 -4
  10. package/dist/chat-routes/index.js +7 -7
  11. package/dist/chat-store/index.js +2 -2
  12. package/dist/{chunk-W5VBZTNN.js → chunk-4ZMZDE24.js} +9 -9
  13. package/dist/chunk-B7CL7ENS.js +118 -0
  14. package/dist/chunk-B7CL7ENS.js.map +1 -0
  15. package/dist/{chunk-KU3XTB7O.js → chunk-BDCATWBV.js} +3 -3
  16. package/dist/{chunk-NWR5CERQ.js → chunk-FNRUXPXE.js} +2 -2
  17. package/dist/{chunk-FZCXV4NH.js → chunk-GEGCSRYQ.js} +2 -2
  18. package/dist/{chunk-WTGSLW5X.js → chunk-HTAFI247.js} +4 -4
  19. package/dist/{chunk-YEBSFADG.js → chunk-IBTM5SAZ.js} +121 -1
  20. package/dist/chunk-IBTM5SAZ.js.map +1 -0
  21. package/dist/{chunk-Y2TP52AB.js → chunk-KSLVMA2D.js} +3 -3
  22. package/dist/{chunk-SPLPFIWT.js → chunk-OFQUM5FP.js} +52 -15
  23. package/dist/chunk-OFQUM5FP.js.map +1 -0
  24. package/dist/chunk-PV33JZKV.js +115 -0
  25. package/dist/chunk-PV33JZKV.js.map +1 -0
  26. package/dist/{chunk-WN24GJ7A.js → chunk-Q3BLSWYP.js} +2 -2
  27. package/dist/{chunk-LLHHZHQC.js → chunk-S5MKEU2E.js} +2607 -1438
  28. package/dist/chunk-S5MKEU2E.js.map +1 -0
  29. package/dist/{chunk-EN5CP7T7.js → chunk-T5PPQPOD.js} +5 -111
  30. package/dist/chunk-T5PPQPOD.js.map +1 -0
  31. package/dist/{chunk-DWUBICLW.js → chunk-UGPV7VEW.js} +569 -236
  32. package/dist/chunk-UGPV7VEW.js.map +1 -0
  33. package/dist/{chunk-52PYOFI6.js → chunk-XOBVWCOA.js} +348 -312
  34. package/dist/chunk-XOBVWCOA.js.map +1 -0
  35. package/dist/{mention-editor-BPDSMGJI.js → mention-editor-4D32JTDS.js} +2 -2
  36. package/dist/preset-cloudflare/index.js +3 -3
  37. package/dist/profile/index.js +4 -2
  38. package/dist/profile/index.js.map +1 -1
  39. package/dist/profile-editor/index.d.ts +185 -0
  40. package/dist/profile-editor/index.js +18 -0
  41. package/dist/profile-editor/index.js.map +1 -0
  42. package/dist/profile-editor/server.d.ts +112 -0
  43. package/dist/profile-editor/server.js +635 -0
  44. package/dist/profile-editor/server.js.map +1 -0
  45. package/dist/public-consultation/index.js +4 -4
  46. package/dist/sandbox/index.js +3 -3
  47. package/dist/skills/frontmatter.d.ts +43 -0
  48. package/dist/skills/index.d.ts +1 -38
  49. package/dist/skills/index.js +4 -2
  50. package/dist/skills-placement/index.js +2 -1
  51. package/dist/skills-placement/index.js.map +1 -1
  52. package/dist/stories/fixtures/profile-editor.d.ts +17 -0
  53. package/dist/studio-react/index.js +3 -3
  54. package/dist/teams/invitations-api.js +3 -3
  55. package/dist/tools/index.js +3 -3
  56. package/dist/vault/VaultPane.d.ts +4 -4
  57. package/dist/vault/VaultTree.d.ts +39 -0
  58. package/dist/vault/contracts.d.ts +17 -7
  59. package/dist/vault/index.d.ts +5 -4
  60. package/dist/vault/index.js +7 -3
  61. package/dist/vault/lazy.js +1 -1
  62. package/dist/web-react/agent-profile-editor.d.ts +63 -1
  63. package/dist/web-react/agent-profile-files.d.ts +38 -0
  64. package/dist/web-react/agent-profile-form-kit.d.ts +87 -0
  65. package/dist/web-react/agent-profile-github-source.d.ts +35 -0
  66. package/dist/web-react/agent-profile-mcp-servers.d.ts +20 -0
  67. package/dist/web-react/agent-profile-suggest-input.d.ts +31 -0
  68. package/dist/web-react/agent-session-controls.d.ts +51 -0
  69. package/dist/web-react/controls.d.ts +31 -6
  70. package/dist/web-react/index.d.ts +3 -2
  71. package/dist/web-react/index.js +23 -15
  72. package/dist/workspace-react/index.js +4 -4
  73. package/package.json +11 -1
  74. package/dist/VaultPane-SPXE7XAC.js +0 -7
  75. package/dist/chunk-52PYOFI6.js.map +0 -1
  76. package/dist/chunk-DWUBICLW.js.map +0 -1
  77. package/dist/chunk-EN5CP7T7.js.map +0 -1
  78. package/dist/chunk-LLHHZHQC.js.map +0 -1
  79. package/dist/chunk-SPLPFIWT.js.map +0 -1
  80. package/dist/chunk-YEBSFADG.js.map +0 -1
  81. /package/dist/{VaultPane-SPXE7XAC.js.map → VaultPane-RIJM452Y.js.map} +0 -0
  82. /package/dist/{chunk-W5VBZTNN.js.map → chunk-4ZMZDE24.js.map} +0 -0
  83. /package/dist/{chunk-KU3XTB7O.js.map → chunk-BDCATWBV.js.map} +0 -0
  84. /package/dist/{chunk-NWR5CERQ.js.map → chunk-FNRUXPXE.js.map} +0 -0
  85. /package/dist/{chunk-FZCXV4NH.js.map → chunk-GEGCSRYQ.js.map} +0 -0
  86. /package/dist/{chunk-WTGSLW5X.js.map → chunk-HTAFI247.js.map} +0 -0
  87. /package/dist/{chunk-Y2TP52AB.js.map → chunk-KSLVMA2D.js.map} +0 -0
  88. /package/dist/{chunk-WN24GJ7A.js.map → chunk-Q3BLSWYP.js.map} +0 -0
  89. /package/dist/{mention-editor-BPDSMGJI.js.map → mention-editor-4D32JTDS.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-L7MB2LLM.js";
4
4
  import {
5
5
  usePopoverDialog
6
- } from "./chunk-FZCXV4NH.js";
6
+ } from "./chunk-GEGCSRYQ.js";
7
7
  import {
8
8
  CheckGlyph,
9
9
  EffortPicker,
@@ -11,10 +11,11 @@ import {
11
11
  OVERLAY_SHADOW,
12
12
  POPOVER_OPTION_FOCUS,
13
13
  PopoverSurface,
14
+ fieldPickerTriggerClass,
14
15
  pickerRootClass,
15
16
  quietPickerTriggerClass,
16
17
  usePopover
17
- } from "./chunk-SPLPFIWT.js";
18
+ } from "./chunk-OFQUM5FP.js";
18
19
  import {
19
20
  filterCommandPaletteItems
20
21
  } from "./chunk-SJWIZT7B.js";
@@ -338,7 +339,7 @@ import {
338
339
  } from "react";
339
340
  import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
340
341
  function createLazyMentionEditor() {
341
- return lazy(() => import("./mention-editor-BPDSMGJI.js").then((m) => m.loadMentionEditor()));
342
+ return lazy(() => import("./mention-editor-4D32JTDS.js").then((m) => m.loadMentionEditor()));
342
343
  }
343
344
  var IS_APPLE_PLATFORM = typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform);
344
345
  function SendGlyph({ className }) {
@@ -1220,271 +1221,6 @@ function ChatComposer({
1220
1221
  );
1221
1222
  }
1222
1223
 
1223
- // src/web-react/use-composer-attachments.ts
1224
- import { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo2, useRef as useRef3, useState as useState3 } from "react";
1225
- function newId() {
1226
- const cryptoObject = globalThis.crypto;
1227
- if (typeof cryptoObject?.randomUUID === "function") return cryptoObject.randomUUID();
1228
- return `att-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1229
- }
1230
- function dedupeName(name, taken) {
1231
- if (!taken.has(name)) return name;
1232
- const dot = name.lastIndexOf(".");
1233
- const base = dot > 0 ? name.slice(0, dot) : name;
1234
- const ext = dot > 0 ? name.slice(dot) : "";
1235
- let n = 2;
1236
- let candidate = `${base}-${n}${ext}`;
1237
- while (taken.has(candidate)) {
1238
- n += 1;
1239
- candidate = `${base}-${n}${ext}`;
1240
- }
1241
- return candidate;
1242
- }
1243
- function kindForMime(mime) {
1244
- return mime.startsWith("image/") ? "image" : "file";
1245
- }
1246
- async function parseUploadError(res) {
1247
- const detail = await res.json().catch(() => null);
1248
- if (detail && typeof detail === "object" && "error" in detail) {
1249
- const error = detail.error;
1250
- if (typeof error === "string" && error) return error;
1251
- if (error && typeof error === "object" && "message" in error) {
1252
- const message = error.message;
1253
- if (typeof message === "string" && message) return message;
1254
- }
1255
- }
1256
- return `Upload failed (${res.status})`;
1257
- }
1258
- var NO_UPLOAD_TARGET_MESSAGE = "No upload destination configured (pass uploadUrl or buildUploadRequest)";
1259
- function useComposerAttachments(options) {
1260
- const optionsRef = useRef3(options);
1261
- optionsRef.current = options;
1262
- const [staged, setStagedState] = useState3([]);
1263
- const stagedRef = useRef3([]);
1264
- const controllersRef = useRef3(/* @__PURE__ */ new Map());
1265
- const setStaged = useCallback3(
1266
- (updater) => {
1267
- const next = typeof updater === "function" ? updater(stagedRef.current) : updater;
1268
- stagedRef.current = next;
1269
- setStagedState(next);
1270
- },
1271
- []
1272
- );
1273
- const upload = useCallback3(
1274
- async (id, file, name) => {
1275
- const opts = optionsRef.current;
1276
- setStaged(
1277
- (prev) => prev.map((s) => s.id === id ? { ...s, status: "uploading", errorMessage: void 0 } : s)
1278
- );
1279
- const controller = new AbortController();
1280
- controllersRef.current.set(id, controller);
1281
- const form = new FormData();
1282
- form.append("file", file, name);
1283
- const request = opts.buildUploadRequest ? opts.buildUploadRequest({ file, name, form }) : opts.uploadUrl ? { url: opts.uploadUrl } : null;
1284
- if (!request) {
1285
- setStaged(
1286
- (prev) => prev.map(
1287
- (s) => s.id === id ? { ...s, status: "error", errorMessage: NO_UPLOAD_TARGET_MESSAGE } : s
1288
- )
1289
- );
1290
- opts.onError?.(NO_UPLOAD_TARGET_MESSAGE);
1291
- controllersRef.current.delete(id);
1292
- return;
1293
- }
1294
- try {
1295
- const res = await fetch(request.url, {
1296
- method: "POST",
1297
- credentials: "same-origin",
1298
- ...request.init,
1299
- body: form,
1300
- signal: controller.signal
1301
- });
1302
- if (!res.ok) {
1303
- const message = await parseUploadError(res);
1304
- setStaged(
1305
- (prev) => prev.map((s) => s.id === id ? { ...s, status: "error", errorMessage: message } : s)
1306
- );
1307
- opts.onError?.(message);
1308
- return;
1309
- }
1310
- const data = await res.json();
1311
- const uploaded = data.files?.[0];
1312
- if (!uploaded) {
1313
- const message = "Upload returned no file";
1314
- setStaged(
1315
- (prev) => prev.map((s) => s.id === id ? { ...s, status: "error", errorMessage: message } : s)
1316
- );
1317
- opts.onError?.(message);
1318
- return;
1319
- }
1320
- setStaged(
1321
- (prev) => prev.map((s) => s.id === id ? { ...s, status: "ready", reference: uploaded } : s)
1322
- );
1323
- } catch (err) {
1324
- if (err.name === "AbortError") return;
1325
- const message = err instanceof Error && err.message ? err.message : "Upload failed \u2014 check your connection";
1326
- setStaged(
1327
- (prev) => prev.map((s) => s.id === id ? { ...s, status: "error", errorMessage: message } : s)
1328
- );
1329
- opts.onError?.(message);
1330
- } finally {
1331
- controllersRef.current.delete(id);
1332
- }
1333
- },
1334
- [setStaged]
1335
- );
1336
- const addFiles = useCallback3(
1337
- async (files) => {
1338
- const opts = optionsRef.current;
1339
- const enabled2 = opts.enabled ?? true;
1340
- if (!enabled2) {
1341
- opts.onReject?.("Attachments are disabled");
1342
- return;
1343
- }
1344
- const accept = opts.accept ?? ATTACHMENT_ACCEPT;
1345
- const maxCount = opts.limits?.maxCount ?? ATTACHMENT_MAX_COUNT;
1346
- const maxBinaryBytes = opts.limits?.maxBinaryBytes ?? MAX_BINARY_ATTACHMENT_BYTES;
1347
- const maxTextBytes = opts.limits?.maxTextBytes ?? MAX_TEXT_ATTACHMENT_BYTES;
1348
- const maxTotalBytes = opts.limits?.maxTotalBytes ?? MAX_ATTACHMENT_TOTAL_BYTES;
1349
- const allowedKinds = opts.allowedKinds ?? ["image", "file"];
1350
- const list = Array.isArray(files) ? files : Array.from(files);
1351
- const currentCount = stagedRef.current.length;
1352
- const countAccepted = [];
1353
- for (const file of list) {
1354
- if (!isAcceptedFileType(file, accept)) {
1355
- opts.onReject?.(acceptRejectionReason(file, accept), file);
1356
- continue;
1357
- }
1358
- if (currentCount + countAccepted.length >= maxCount) {
1359
- opts.onReject?.(`"${file.name}" was not added \u2014 the ${maxCount}-file limit is already reached.`, file);
1360
- continue;
1361
- }
1362
- countAccepted.push(file);
1363
- }
1364
- const sizeAccepted = [];
1365
- for (const file of countAccepted) {
1366
- const bytes = new Uint8Array(await file.arrayBuffer());
1367
- const sniff = sniffBinary(bytes);
1368
- const typeCheck = checkAttachmentType(file.name, sniff);
1369
- if (!typeCheck.succeeded) {
1370
- opts.onReject?.(typeCheck.message, file);
1371
- continue;
1372
- }
1373
- const limit = sniff.binary ? maxBinaryBytes : maxTextBytes;
1374
- if (file.size > limit) {
1375
- opts.onReject?.(attachmentSizeErrorMessage(file.name, file.size, limit), file);
1376
- continue;
1377
- }
1378
- const mediaType = sniff.mime ?? file.type ?? "";
1379
- const kind = kindForMime(mediaType);
1380
- if (!allowedKinds.includes(kind)) {
1381
- opts.onReject?.(`"${file.name}" is a ${kind} attachment, which isn't accepted here`, file);
1382
- continue;
1383
- }
1384
- sizeAccepted.push(file);
1385
- }
1386
- const accepted = [];
1387
- let totalBytes = stagedRef.current.reduce((total, s) => total + s.size, 0);
1388
- for (const file of sizeAccepted) {
1389
- const nextTotalBytes = totalBytes + file.size;
1390
- if (nextTotalBytes > maxTotalBytes) {
1391
- opts.onReject?.(attachmentTotalSizeErrorMessage(nextTotalBytes, maxTotalBytes), file);
1392
- continue;
1393
- }
1394
- accepted.push(file);
1395
- totalBytes = nextTotalBytes;
1396
- }
1397
- if (accepted.length === 0) return;
1398
- const taken = new Set(stagedRef.current.map((s) => s.name));
1399
- const entries = accepted.map((file) => {
1400
- const name = dedupeName(sanitizeAttachmentFileName(file.name), taken);
1401
- taken.add(name);
1402
- return {
1403
- id: newId(),
1404
- file,
1405
- name,
1406
- size: file.size,
1407
- status: "pending",
1408
- previewUrl: file.type.startsWith("image/") ? URL.createObjectURL(file) : void 0
1409
- };
1410
- });
1411
- setStaged((prev) => [...prev, ...entries]);
1412
- for (const entry of entries) void upload(entry.id, entry.file, entry.name);
1413
- },
1414
- [setStaged, upload]
1415
- );
1416
- const retry = useCallback3(
1417
- (id) => {
1418
- const entry = stagedRef.current.find((s) => s.id === id);
1419
- if (!entry) return;
1420
- void upload(entry.id, entry.file, entry.name);
1421
- },
1422
- [upload]
1423
- );
1424
- const removeAttachment = useCallback3(
1425
- (id) => {
1426
- controllersRef.current.get(id)?.abort();
1427
- controllersRef.current.delete(id);
1428
- const entry = stagedRef.current.find((s) => s.id === id);
1429
- if (entry?.previewUrl) URL.revokeObjectURL(entry.previewUrl);
1430
- setStaged((prev) => prev.filter((s) => s.id !== id));
1431
- },
1432
- [setStaged]
1433
- );
1434
- const clear = useCallback3(() => {
1435
- for (const controller of controllersRef.current.values()) controller.abort();
1436
- controllersRef.current.clear();
1437
- for (const entry of stagedRef.current) {
1438
- if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);
1439
- }
1440
- setStaged([]);
1441
- }, [setStaged]);
1442
- useEffect4(
1443
- () => () => {
1444
- for (const controller of controllersRef.current.values()) controller.abort();
1445
- controllersRef.current.clear();
1446
- for (const entry of stagedRef.current) {
1447
- if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);
1448
- }
1449
- },
1450
- []
1451
- );
1452
- const composerFiles = useMemo2(
1453
- () => staged.map((s) => ({
1454
- id: s.id,
1455
- name: s.name,
1456
- size: s.size,
1457
- kind: "file",
1458
- status: s.status,
1459
- previewUrl: s.previewUrl,
1460
- errorMessage: s.errorMessage
1461
- })),
1462
- [staged]
1463
- );
1464
- const references = useMemo2(
1465
- () => staged.filter((s) => s.status === "ready" && !!s.reference).map((s) => s.reference),
1466
- [staged]
1467
- );
1468
- const hasPending = useMemo2(
1469
- () => staged.some((s) => s.status === "pending" || s.status === "uploading"),
1470
- [staged]
1471
- );
1472
- const hasError = useMemo2(() => staged.some((s) => s.status === "error"), [staged]);
1473
- const enabled = options.enabled ?? true;
1474
- const blockReason = !enabled ? "Attachments are disabled" : hasPending ? "Attachments are still uploading" : hasError ? "Remove failed attachments to send" : null;
1475
- return {
1476
- composerFiles,
1477
- references,
1478
- addFiles,
1479
- retry,
1480
- removeAttachment,
1481
- clear,
1482
- hasPending,
1483
- hasError,
1484
- blockReason
1485
- };
1486
- }
1487
-
1488
1224
  // src/web-react/harness-glyphs.tsx
1489
1225
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1490
1226
  var BRAND_PATHS = {
@@ -1571,7 +1307,7 @@ function HarnessGlyph({ harness, className }) {
1571
1307
  }
1572
1308
 
1573
1309
  // src/web-react/agent-settings-popover.tsx
1574
- import { useCallback as useCallback4, useEffect as useEffect5, useState as useState4 } from "react";
1310
+ import { useCallback as useCallback3, useEffect as useEffect4, useState as useState3 } from "react";
1575
1311
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1576
1312
  function AgentSettingsPopover({
1577
1313
  label = "Agent settings",
@@ -1583,13 +1319,13 @@ function AgentSettingsPopover({
1583
1319
  className,
1584
1320
  panelClassName
1585
1321
  }) {
1586
- const [localOpen, setLocalOpen] = useState4(false);
1322
+ const [localOpen, setLocalOpen] = useState3(false);
1587
1323
  const open = !disabled && (controlledOpen ?? localOpen);
1588
- const changeOpen = useCallback4((next) => {
1324
+ const changeOpen = useCallback3((next) => {
1589
1325
  setLocalOpen(next);
1590
1326
  onOpenChange?.(next);
1591
1327
  }, [onOpenChange]);
1592
- useEffect5(() => {
1328
+ useEffect4(() => {
1593
1329
  if (disabled) changeOpen(false);
1594
1330
  }, [disabled, changeOpen]);
1595
1331
  const { containerRef, triggerRef, panelRef, triggerProps, id } = usePopoverDialog(open, changeOpen);
@@ -1633,7 +1369,7 @@ function AgentSettingsPopover({
1633
1369
  }
1634
1370
 
1635
1371
  // src/web-react/agent-session-controls.tsx
1636
- import { useId as useId2, useMemo as useMemo3, useRef as useRef4, useState as useState5 } from "react";
1372
+ import { useId as useId2, useMemo as useMemo2, useRef as useRef3, useState as useState4 } from "react";
1637
1373
  import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1638
1374
  var HARNESS_LABELS = {
1639
1375
  opencode: "OpenCode (any model)",
@@ -1675,29 +1411,42 @@ function HarnessPicker({
1675
1411
  available,
1676
1412
  fullWidth = false,
1677
1413
  lockReason,
1678
- variant = "chip"
1414
+ variant = "chip",
1415
+ defaultOption,
1416
+ disabled = false,
1417
+ id,
1418
+ "aria-describedby": ariaDescribedBy
1679
1419
  }) {
1680
- const [open, setOpen] = useState5(false);
1681
- const [hintOpen, setHintOpen] = useState5(false);
1420
+ const [requestedOpen, setOpen] = useState4(false);
1421
+ const open = requestedOpen && !disabled;
1422
+ const [hintOpen, setHintOpen] = useState4(false);
1682
1423
  const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(open, setOpen);
1683
- const hintPanelRef = useRef4(null);
1424
+ const hintPanelRef = useRef3(null);
1684
1425
  const panelId = useId2();
1685
1426
  const reasonId = useId2();
1686
1427
  const locked = lockReason !== void 0;
1428
+ const field = variant === "field";
1687
1429
  const options = available ?? Object.keys(HARNESS_LABELS);
1688
1430
  const showHint = () => setHintOpen(true);
1689
1431
  const hideHint = () => setHintOpen(false);
1690
- return /* @__PURE__ */ jsxs5("div", { ref: containerRef, className: pickerRootClass(fullWidth), children: [
1432
+ const label = value ? harnessLabel(value) : defaultOption?.label ?? "Select harness";
1433
+ const choose = (next) => {
1434
+ onChange(next);
1435
+ setOpen(false);
1436
+ };
1437
+ return /* @__PURE__ */ jsxs5("div", { ref: containerRef, className: pickerRootClass(fullWidth || field), children: [
1691
1438
  /* @__PURE__ */ jsxs5(
1692
1439
  "button",
1693
1440
  {
1694
1441
  type: "button",
1695
1442
  ...triggerProps,
1443
+ id,
1444
+ disabled,
1696
1445
  "aria-haspopup": locked ? void 0 : true,
1697
1446
  "aria-expanded": locked ? void 0 : open,
1698
1447
  "aria-controls": !locked && open ? panelId : void 0,
1699
1448
  "aria-disabled": locked || void 0,
1700
- "aria-describedby": locked ? reasonId : void 0,
1449
+ "aria-describedby": [locked ? reasonId : void 0, ariaDescribedBy].filter(Boolean).join(" ") || void 0,
1701
1450
  onClick: locked ? void 0 : () => setOpen(!open),
1702
1451
  onMouseEnter: locked ? showHint : void 0,
1703
1452
  onMouseLeave: locked ? hideHint : void 0,
@@ -1705,11 +1454,11 @@ function HarnessPicker({
1705
1454
  onBlur: locked ? hideHint : void 0,
1706
1455
  title: "Agent backend",
1707
1456
  "data-state": !locked && open ? "open" : "closed",
1708
- className: variant === "quiet" ? `${quietPickerTriggerClass({ interactive: !locked })} w-full justify-between` : `inline-flex min-h-[36px] w-full items-center justify-between gap-1.5 rounded-full border border-border bg-card px-3 py-1.5 text-sm font-medium text-foreground transition ${locked ? "cursor-default" : "hover:bg-accent"} ${FOCUS_RING}`,
1457
+ className: field ? fieldPickerTriggerClass({ interactive: !locked && !disabled }) : variant === "quiet" ? `${quietPickerTriggerClass({ interactive: !locked })} w-full justify-between` : `inline-flex min-h-[36px] w-full items-center justify-between gap-1.5 rounded-full border border-border bg-card px-3 py-1.5 text-sm font-medium text-foreground transition ${locked ? "cursor-default" : "hover:bg-accent"} ${FOCUS_RING}`,
1709
1458
  children: [
1710
- /* @__PURE__ */ jsxs5("span", { className: "flex min-w-0 items-center gap-1.5", children: [
1711
- /* @__PURE__ */ jsx5(HarnessGlyph, { harness: value, className: variant === "quiet" ? "h-4 w-4 shrink-0" : "h-4 w-4 shrink-0 text-foreground" }),
1712
- /* @__PURE__ */ jsx5("span", { className: "truncate", children: harnessLabel(value) })
1459
+ /* @__PURE__ */ jsxs5("span", { className: `flex min-w-0 items-center ${field ? "flex-1 gap-2" : "gap-1.5"}`, children: [
1460
+ value ? /* @__PURE__ */ jsx5(HarnessGlyph, { harness: value, className: variant === "quiet" ? "h-4 w-4 shrink-0" : "h-4 w-4 shrink-0 text-foreground" }) : /* @__PURE__ */ jsx5(GearGlyph, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
1461
+ /* @__PURE__ */ jsx5("span", { className: `truncate ${value ? "" : "text-muted-foreground"}`, children: label })
1713
1462
  ] }),
1714
1463
  locked ? /* @__PURE__ */ jsx5(LockGlyph, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }) : /* @__PURE__ */ jsx5(ChevronDown, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" })
1715
1464
  ]
@@ -1724,13 +1473,13 @@ function HarnessPicker({
1724
1473
  role: "tooltip",
1725
1474
  triggerRef,
1726
1475
  panelRef: hintPanelRef,
1727
- matchTriggerWidth: fullWidth,
1728
- className: `max-w-[248px] rounded-lg border border-card-edge bg-popover px-2.5 py-1.5 text-xs leading-snug text-muted-foreground ${OVERLAY_SHADOW}`,
1476
+ matchTriggerWidth: fullWidth || field,
1477
+ className: `max-w-[248px] rounded-lg border border-card-edge bg-popover px-2.5 py-1.5 text-sm leading-snug text-muted-foreground ${OVERLAY_SHADOW}`,
1729
1478
  children: /* @__PURE__ */ jsx5("span", { "aria-hidden": true, children: lockReason })
1730
1479
  }
1731
1480
  )
1732
1481
  ] }),
1733
- /* @__PURE__ */ jsx5(
1482
+ /* @__PURE__ */ jsxs5(
1734
1483
  PopoverSurface,
1735
1484
  {
1736
1485
  open: !locked && open,
@@ -1739,33 +1488,48 @@ function HarnessPicker({
1739
1488
  triggerRef,
1740
1489
  panelRef,
1741
1490
  matchTriggerWidth: true,
1491
+ side: field ? "below" : void 0,
1742
1492
  className: `max-h-64 min-w-[248px] overflow-y-auto rounded-xl border border-card-edge bg-popover p-1 ${OVERLAY_SHADOW}`,
1743
- children: options.map((h) => /* @__PURE__ */ jsxs5(
1744
- "button",
1745
- {
1746
- type: "button",
1747
- role: "menuitemradio",
1748
- "aria-checked": h === value,
1749
- onClick: () => {
1750
- onChange(h);
1751
- setOpen(false);
1493
+ children: [
1494
+ defaultOption && /* @__PURE__ */ jsxs5(
1495
+ "button",
1496
+ {
1497
+ type: "button",
1498
+ role: "menuitemradio",
1499
+ "aria-checked": value === "",
1500
+ onClick: () => choose(""),
1501
+ className: `flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm transition ${FOCUS_RING} ${value === "" ? "bg-primary/10 font-medium" : "hover:bg-accent"}`,
1502
+ children: [
1503
+ /* @__PURE__ */ jsx5(GearGlyph, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
1504
+ /* @__PURE__ */ jsx5("span", { className: "truncate", children: defaultOption.label }),
1505
+ value === "" && /* @__PURE__ */ jsx5(CheckGlyph, { className: "ml-auto h-3.5 w-3.5 shrink-0 text-primary" })
1506
+ ]
1507
+ }
1508
+ ),
1509
+ options.map((h) => /* @__PURE__ */ jsxs5(
1510
+ "button",
1511
+ {
1512
+ type: "button",
1513
+ role: "menuitemradio",
1514
+ "aria-checked": h === value,
1515
+ onClick: () => choose(h),
1516
+ className: `flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm transition ${FOCUS_RING} ${h === value ? "bg-primary/10 font-medium" : "hover:bg-accent"}`,
1517
+ children: [
1518
+ /* @__PURE__ */ jsx5(HarnessGlyph, { harness: h, className: "h-4 w-4 shrink-0 text-foreground" }),
1519
+ /* @__PURE__ */ jsx5("span", { className: "truncate", children: harnessLabel(h) }),
1520
+ h === value && /* @__PURE__ */ jsx5(CheckGlyph, { className: "ml-auto h-3.5 w-3.5 shrink-0 text-primary" })
1521
+ ]
1752
1522
  },
1753
- className: `flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm transition ${FOCUS_RING} ${h === value ? "bg-primary/10 font-medium" : "hover:bg-accent"}`,
1754
- children: [
1755
- /* @__PURE__ */ jsx5(HarnessGlyph, { harness: h, className: "h-4 w-4 shrink-0 text-foreground" }),
1756
- /* @__PURE__ */ jsx5("span", { className: "truncate", children: harnessLabel(h) }),
1757
- h === value && /* @__PURE__ */ jsx5(CheckGlyph, { className: "ml-auto h-3.5 w-3.5 shrink-0 text-primary" })
1758
- ]
1759
- },
1760
- h
1761
- ))
1523
+ h
1524
+ ))
1525
+ ]
1762
1526
  }
1763
1527
  )
1764
1528
  ] });
1765
1529
  }
1766
1530
  function useCoherentHandlers(props) {
1767
1531
  const { model, models, harness, onModelChange, onHarnessChange, harnessLockReason } = props;
1768
- const canonicalIds = useMemo3(() => models.map((m) => m.id), [models]);
1532
+ const canonicalIds = useMemo2(() => models.map((m) => m.id), [models]);
1769
1533
  const harnessLocked = harnessLockReason !== void 0;
1770
1534
  const onModel = (next) => {
1771
1535
  onModelChange(next);
@@ -1800,7 +1564,7 @@ function AgentSessionControls(props) {
1800
1564
  settingsSummary
1801
1565
  } = props;
1802
1566
  const { onModel, onHarness } = useCoherentHandlers(props);
1803
- const [open, setOpen] = useState5(false);
1567
+ const [open, setOpen] = useState4(false);
1804
1568
  const { containerRef: popoverRef, triggerRef, panelRef, triggerProps } = usePopover(open, setOpen);
1805
1569
  const panelId = useId2();
1806
1570
  const selectedModel = models.find((m) => m.id === model);
@@ -1828,7 +1592,9 @@ function AgentSessionControls(props) {
1828
1592
  ] }),
1829
1593
  showHarness && /* @__PURE__ */ jsxs5("div", { className: "space-y-1.5", children: [
1830
1594
  /* @__PURE__ */ jsx5("p", { className: "text-xs font-medium text-muted-foreground", children: "Agent backend" }),
1831
- /* @__PURE__ */ jsx5(HarnessPicker, { value: harness, onChange: onHarness, available: availableHarnesses, lockReason: harnessLockReason, fullWidth: true, variant })
1595
+ /* @__PURE__ */ jsx5(HarnessPicker, { value: harness, onChange: (next) => {
1596
+ if (next) onHarness(next);
1597
+ }, available: availableHarnesses, lockReason: harnessLockReason, fullWidth: true, variant })
1832
1598
  ] }),
1833
1599
  showEffort && /* @__PURE__ */ jsxs5("div", { className: "space-y-1.5", children: [
1834
1600
  /* @__PURE__ */ jsx5("p", { className: "text-xs font-medium text-muted-foreground", children: "Thinking" }),
@@ -1843,7 +1609,9 @@ function AgentSessionControls(props) {
1843
1609
  HarnessPicker,
1844
1610
  {
1845
1611
  value: harness,
1846
- onChange: onHarness,
1612
+ onChange: (next) => {
1613
+ if (next) onHarness(next);
1614
+ },
1847
1615
  available: availableHarnesses,
1848
1616
  lockReason: harnessLockReason,
1849
1617
  variant
@@ -1884,7 +1652,9 @@ function AgentSessionControls(props) {
1884
1652
  HarnessPicker,
1885
1653
  {
1886
1654
  value: harness,
1887
- onChange: onHarness,
1655
+ onChange: (next) => {
1656
+ if (next) onHarness(next);
1657
+ },
1888
1658
  available: availableHarnesses,
1889
1659
  fullWidth: true,
1890
1660
  lockReason: harnessLockReason,
@@ -1905,6 +1675,271 @@ function AgentSessionControls(props) {
1905
1675
  ] });
1906
1676
  }
1907
1677
 
1678
+ // src/web-react/use-composer-attachments.ts
1679
+ import { useCallback as useCallback4, useEffect as useEffect5, useMemo as useMemo3, useRef as useRef4, useState as useState5 } from "react";
1680
+ function newId() {
1681
+ const cryptoObject = globalThis.crypto;
1682
+ if (typeof cryptoObject?.randomUUID === "function") return cryptoObject.randomUUID();
1683
+ return `att-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1684
+ }
1685
+ function dedupeName(name, taken) {
1686
+ if (!taken.has(name)) return name;
1687
+ const dot = name.lastIndexOf(".");
1688
+ const base = dot > 0 ? name.slice(0, dot) : name;
1689
+ const ext = dot > 0 ? name.slice(dot) : "";
1690
+ let n = 2;
1691
+ let candidate = `${base}-${n}${ext}`;
1692
+ while (taken.has(candidate)) {
1693
+ n += 1;
1694
+ candidate = `${base}-${n}${ext}`;
1695
+ }
1696
+ return candidate;
1697
+ }
1698
+ function kindForMime(mime) {
1699
+ return mime.startsWith("image/") ? "image" : "file";
1700
+ }
1701
+ async function parseUploadError(res) {
1702
+ const detail = await res.json().catch(() => null);
1703
+ if (detail && typeof detail === "object" && "error" in detail) {
1704
+ const error = detail.error;
1705
+ if (typeof error === "string" && error) return error;
1706
+ if (error && typeof error === "object" && "message" in error) {
1707
+ const message = error.message;
1708
+ if (typeof message === "string" && message) return message;
1709
+ }
1710
+ }
1711
+ return `Upload failed (${res.status})`;
1712
+ }
1713
+ var NO_UPLOAD_TARGET_MESSAGE = "No upload destination configured (pass uploadUrl or buildUploadRequest)";
1714
+ function useComposerAttachments(options) {
1715
+ const optionsRef = useRef4(options);
1716
+ optionsRef.current = options;
1717
+ const [staged, setStagedState] = useState5([]);
1718
+ const stagedRef = useRef4([]);
1719
+ const controllersRef = useRef4(/* @__PURE__ */ new Map());
1720
+ const setStaged = useCallback4(
1721
+ (updater) => {
1722
+ const next = typeof updater === "function" ? updater(stagedRef.current) : updater;
1723
+ stagedRef.current = next;
1724
+ setStagedState(next);
1725
+ },
1726
+ []
1727
+ );
1728
+ const upload = useCallback4(
1729
+ async (id, file, name) => {
1730
+ const opts = optionsRef.current;
1731
+ setStaged(
1732
+ (prev) => prev.map((s) => s.id === id ? { ...s, status: "uploading", errorMessage: void 0 } : s)
1733
+ );
1734
+ const controller = new AbortController();
1735
+ controllersRef.current.set(id, controller);
1736
+ const form = new FormData();
1737
+ form.append("file", file, name);
1738
+ const request = opts.buildUploadRequest ? opts.buildUploadRequest({ file, name, form }) : opts.uploadUrl ? { url: opts.uploadUrl } : null;
1739
+ if (!request) {
1740
+ setStaged(
1741
+ (prev) => prev.map(
1742
+ (s) => s.id === id ? { ...s, status: "error", errorMessage: NO_UPLOAD_TARGET_MESSAGE } : s
1743
+ )
1744
+ );
1745
+ opts.onError?.(NO_UPLOAD_TARGET_MESSAGE);
1746
+ controllersRef.current.delete(id);
1747
+ return;
1748
+ }
1749
+ try {
1750
+ const res = await fetch(request.url, {
1751
+ method: "POST",
1752
+ credentials: "same-origin",
1753
+ ...request.init,
1754
+ body: form,
1755
+ signal: controller.signal
1756
+ });
1757
+ if (!res.ok) {
1758
+ const message = await parseUploadError(res);
1759
+ setStaged(
1760
+ (prev) => prev.map((s) => s.id === id ? { ...s, status: "error", errorMessage: message } : s)
1761
+ );
1762
+ opts.onError?.(message);
1763
+ return;
1764
+ }
1765
+ const data = await res.json();
1766
+ const uploaded = data.files?.[0];
1767
+ if (!uploaded) {
1768
+ const message = "Upload returned no file";
1769
+ setStaged(
1770
+ (prev) => prev.map((s) => s.id === id ? { ...s, status: "error", errorMessage: message } : s)
1771
+ );
1772
+ opts.onError?.(message);
1773
+ return;
1774
+ }
1775
+ setStaged(
1776
+ (prev) => prev.map((s) => s.id === id ? { ...s, status: "ready", reference: uploaded } : s)
1777
+ );
1778
+ } catch (err) {
1779
+ if (err.name === "AbortError") return;
1780
+ const message = err instanceof Error && err.message ? err.message : "Upload failed \u2014 check your connection";
1781
+ setStaged(
1782
+ (prev) => prev.map((s) => s.id === id ? { ...s, status: "error", errorMessage: message } : s)
1783
+ );
1784
+ opts.onError?.(message);
1785
+ } finally {
1786
+ controllersRef.current.delete(id);
1787
+ }
1788
+ },
1789
+ [setStaged]
1790
+ );
1791
+ const addFiles = useCallback4(
1792
+ async (files) => {
1793
+ const opts = optionsRef.current;
1794
+ const enabled2 = opts.enabled ?? true;
1795
+ if (!enabled2) {
1796
+ opts.onReject?.("Attachments are disabled");
1797
+ return;
1798
+ }
1799
+ const accept = opts.accept ?? ATTACHMENT_ACCEPT;
1800
+ const maxCount = opts.limits?.maxCount ?? ATTACHMENT_MAX_COUNT;
1801
+ const maxBinaryBytes = opts.limits?.maxBinaryBytes ?? MAX_BINARY_ATTACHMENT_BYTES;
1802
+ const maxTextBytes = opts.limits?.maxTextBytes ?? MAX_TEXT_ATTACHMENT_BYTES;
1803
+ const maxTotalBytes = opts.limits?.maxTotalBytes ?? MAX_ATTACHMENT_TOTAL_BYTES;
1804
+ const allowedKinds = opts.allowedKinds ?? ["image", "file"];
1805
+ const list = Array.isArray(files) ? files : Array.from(files);
1806
+ const currentCount = stagedRef.current.length;
1807
+ const countAccepted = [];
1808
+ for (const file of list) {
1809
+ if (!isAcceptedFileType(file, accept)) {
1810
+ opts.onReject?.(acceptRejectionReason(file, accept), file);
1811
+ continue;
1812
+ }
1813
+ if (currentCount + countAccepted.length >= maxCount) {
1814
+ opts.onReject?.(`"${file.name}" was not added \u2014 the ${maxCount}-file limit is already reached.`, file);
1815
+ continue;
1816
+ }
1817
+ countAccepted.push(file);
1818
+ }
1819
+ const sizeAccepted = [];
1820
+ for (const file of countAccepted) {
1821
+ const bytes = new Uint8Array(await file.arrayBuffer());
1822
+ const sniff = sniffBinary(bytes);
1823
+ const typeCheck = checkAttachmentType(file.name, sniff);
1824
+ if (!typeCheck.succeeded) {
1825
+ opts.onReject?.(typeCheck.message, file);
1826
+ continue;
1827
+ }
1828
+ const limit = sniff.binary ? maxBinaryBytes : maxTextBytes;
1829
+ if (file.size > limit) {
1830
+ opts.onReject?.(attachmentSizeErrorMessage(file.name, file.size, limit), file);
1831
+ continue;
1832
+ }
1833
+ const mediaType = sniff.mime ?? file.type ?? "";
1834
+ const kind = kindForMime(mediaType);
1835
+ if (!allowedKinds.includes(kind)) {
1836
+ opts.onReject?.(`"${file.name}" is a ${kind} attachment, which isn't accepted here`, file);
1837
+ continue;
1838
+ }
1839
+ sizeAccepted.push(file);
1840
+ }
1841
+ const accepted = [];
1842
+ let totalBytes = stagedRef.current.reduce((total, s) => total + s.size, 0);
1843
+ for (const file of sizeAccepted) {
1844
+ const nextTotalBytes = totalBytes + file.size;
1845
+ if (nextTotalBytes > maxTotalBytes) {
1846
+ opts.onReject?.(attachmentTotalSizeErrorMessage(nextTotalBytes, maxTotalBytes), file);
1847
+ continue;
1848
+ }
1849
+ accepted.push(file);
1850
+ totalBytes = nextTotalBytes;
1851
+ }
1852
+ if (accepted.length === 0) return;
1853
+ const taken = new Set(stagedRef.current.map((s) => s.name));
1854
+ const entries = accepted.map((file) => {
1855
+ const name = dedupeName(sanitizeAttachmentFileName(file.name), taken);
1856
+ taken.add(name);
1857
+ return {
1858
+ id: newId(),
1859
+ file,
1860
+ name,
1861
+ size: file.size,
1862
+ status: "pending",
1863
+ previewUrl: file.type.startsWith("image/") ? URL.createObjectURL(file) : void 0
1864
+ };
1865
+ });
1866
+ setStaged((prev) => [...prev, ...entries]);
1867
+ for (const entry of entries) void upload(entry.id, entry.file, entry.name);
1868
+ },
1869
+ [setStaged, upload]
1870
+ );
1871
+ const retry = useCallback4(
1872
+ (id) => {
1873
+ const entry = stagedRef.current.find((s) => s.id === id);
1874
+ if (!entry) return;
1875
+ void upload(entry.id, entry.file, entry.name);
1876
+ },
1877
+ [upload]
1878
+ );
1879
+ const removeAttachment = useCallback4(
1880
+ (id) => {
1881
+ controllersRef.current.get(id)?.abort();
1882
+ controllersRef.current.delete(id);
1883
+ const entry = stagedRef.current.find((s) => s.id === id);
1884
+ if (entry?.previewUrl) URL.revokeObjectURL(entry.previewUrl);
1885
+ setStaged((prev) => prev.filter((s) => s.id !== id));
1886
+ },
1887
+ [setStaged]
1888
+ );
1889
+ const clear = useCallback4(() => {
1890
+ for (const controller of controllersRef.current.values()) controller.abort();
1891
+ controllersRef.current.clear();
1892
+ for (const entry of stagedRef.current) {
1893
+ if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);
1894
+ }
1895
+ setStaged([]);
1896
+ }, [setStaged]);
1897
+ useEffect5(
1898
+ () => () => {
1899
+ for (const controller of controllersRef.current.values()) controller.abort();
1900
+ controllersRef.current.clear();
1901
+ for (const entry of stagedRef.current) {
1902
+ if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);
1903
+ }
1904
+ },
1905
+ []
1906
+ );
1907
+ const composerFiles = useMemo3(
1908
+ () => staged.map((s) => ({
1909
+ id: s.id,
1910
+ name: s.name,
1911
+ size: s.size,
1912
+ kind: "file",
1913
+ status: s.status,
1914
+ previewUrl: s.previewUrl,
1915
+ errorMessage: s.errorMessage
1916
+ })),
1917
+ [staged]
1918
+ );
1919
+ const references = useMemo3(
1920
+ () => staged.filter((s) => s.status === "ready" && !!s.reference).map((s) => s.reference),
1921
+ [staged]
1922
+ );
1923
+ const hasPending = useMemo3(
1924
+ () => staged.some((s) => s.status === "pending" || s.status === "uploading"),
1925
+ [staged]
1926
+ );
1927
+ const hasError = useMemo3(() => staged.some((s) => s.status === "error"), [staged]);
1928
+ const enabled = options.enabled ?? true;
1929
+ const blockReason = !enabled ? "Attachments are disabled" : hasPending ? "Attachments are still uploading" : hasError ? "Remove failed attachments to send" : null;
1930
+ return {
1931
+ composerFiles,
1932
+ references,
1933
+ addFiles,
1934
+ retry,
1935
+ removeAttachment,
1936
+ clear,
1937
+ hasPending,
1938
+ hasError,
1939
+ blockReason
1940
+ };
1941
+ }
1942
+
1908
1943
  // src/web-react/composer-mode-controls.tsx
1909
1944
  import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1910
1945
  function ListChecksGlyph({ className }) {
@@ -1924,7 +1959,7 @@ function ComposerModeControls({ planMode }) {
1924
1959
  // Inset ring: this chip sits in a composer row that clips its overflow,
1925
1960
  // so an outward ring loses three of its four sides. Only the offset is
1926
1961
  // overridden — width and colour stay with the tokens.
1927
- "inline-flex h-7 items-center gap-1 rounded-full border px-2.5 text-xs transition-colors focus-visible:[outline-offset:-2px]",
1962
+ "inline-flex h-[var(--control-height-sm,2rem)] items-center gap-1 rounded-full border px-2.5 text-sm transition-colors focus-visible:[outline-offset:-2px]",
1928
1963
  planMode.enabled ? "border-primary/50 bg-primary/10 text-primary" : "border-border bg-transparent text-muted-foreground hover:text-foreground",
1929
1964
  planMode.saving && "opacity-60"
1930
1965
  ),
@@ -2038,11 +2073,12 @@ export {
2038
2073
  useDictation,
2039
2074
  RouteChunkBoundary,
2040
2075
  ChatComposer,
2041
- useComposerAttachments,
2042
2076
  HarnessGlyph,
2043
2077
  AgentSettingsPopover,
2078
+ HarnessPicker,
2044
2079
  AgentSessionControls,
2080
+ useComposerAttachments,
2045
2081
  ComposerModeControls,
2046
2082
  EntryComposer
2047
2083
  };
2048
- //# sourceMappingURL=chunk-52PYOFI6.js.map
2084
+ //# sourceMappingURL=chunk-XOBVWCOA.js.map