@qfei-design/make-ai-assistant 0.2.9 → 0.2.11
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/PUBLIC_API.md +17 -23
- package/README.md +12 -24
- package/capabilities.json +36 -9
- package/dist/conversation-CZfbgCXd.js +1111 -0
- package/dist/conversation-Cvh-IVRV.cjs +1 -0
- package/dist/core/conversation-management.d.ts +212 -0
- package/dist/core/conversation.d.ts +34 -2
- package/dist/core/index.d.ts +2 -0
- package/dist/core/response-state.d.ts +8 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +4 -4
- package/dist/make-app/protocol.d.ts +27 -0
- package/dist/make-app/stream.d.ts +20 -0
- package/dist/make-app.cjs +1 -1
- package/dist/make-app.d.ts +46 -11
- package/dist/make-app.mjs +698 -259
- package/dist/make-console.cjs +1 -1
- package/dist/make-console.mjs +1 -1
- package/dist/react/conversation-controls.d.ts +20 -0
- package/dist/react/use-attachments.d.ts +33 -0
- package/dist/react/use-conversation-manager.d.ts +35 -0
- package/dist/react.cjs +4 -4
- package/dist/react.mjs +2000 -845
- package/dist/sse.cjs +1 -1
- package/dist/sse.mjs +1 -1
- package/dist/styles.css +428 -13
- package/docs/backend-contract.md +8 -21
- package/docs/make-app-integration.md +80 -0
- package/examples/make-app/README.md +11 -0
- package/examples/make-app/index.html +5 -0
- package/examples/make-app/main.tsx +34 -0
- package/examples/make-app/style.css +4 -0
- package/examples/make-app/transport.ts +163 -0
- package/examples/make-app/vite.config.ts +7 -0
- package/package.json +10 -2
- package/recipes.json +36 -13
- package/dist/conversation-B7eGUXi-.js +0 -727
- package/dist/conversation-Cv1wdvCR.cjs +0 -1
package/dist/sse.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./conversation-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./conversation-Cvh-IVRV.cjs"),S=1e6,u=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),p=(e,t,r)=>{const a=Object.keys(e).find(s=>s.toLowerCase()===t.toLowerCase());a&&delete e[a],e[t]=r},A=e=>{const t={};return Array.isArray(e)?e.forEach(([r,a])=>p(t,r,a)):e&&typeof e.forEach=="function"?e.forEach((r,a)=>p(t,a,r)):e&&Object.entries(e).forEach(([r,a])=>p(t,r,a)),p(t,"Accept","text/event-stream"),p(t,"Content-Type","application/json"),t},I=(e,t)=>{if(!u(t))throw new Error("Invalid assistant SSE event: data");if(Object.prototype.hasOwnProperty.call(t,"type"))throw new Error("Invalid assistant SSE event: unsupported field");try{return b.parseAssistantEvent({...t,type:e})}catch(r){throw r instanceof Error&&r.message.startsWith("Invalid assistant event")?new Error(r.message.replace("Invalid assistant event","Invalid assistant SSE event")):r}},w=e=>{if(!e.trim())return;const t=e.split(`
|
|
2
2
|
`),r=t.find(n=>n.startsWith("event:"))?.slice(6).trim(),a=t.filter(n=>n.startsWith("data:")).map(n=>n.slice(5).trimStart()).join(`
|
|
3
3
|
`);if(t.some(n=>n.startsWith("event:")||n.startsWith("data:"))){if(!r||!a)throw new Error("Invalid assistant SSE event: missing event or data");try{return I(r,JSON.parse(a))}catch(n){throw n instanceof Error&&n.message.startsWith("Invalid assistant SSE event")?n:new Error("Invalid assistant SSE event: JSON")}}};async function*T(e,t,r=S){if(!e.body)throw new Error("当前运行环境无法读取 AI 助手流式响应");const a=e.body.getReader(),s=new TextDecoder;let n="",d=!1,h=!1,l;const c=()=>(l??=a.cancel().catch(o=>{console.error("[make-ai-assistant] SSE reader cancellation failed",{errorType:o instanceof Error?o.name:typeof o})}),l),f=()=>{c()};t?.addEventListener("abort",f,{once:!0});const m=o=>{const i=o.type==="error"||o.type==="run.cancelled"||o.type==="run.complete";return h||=i,i};try{for(;;){if(t?.aborted)throw new DOMException("Aborted","AbortError");const o=await a.read();if(t?.aborted)throw new DOMException("Aborted","AbortError");let i=s.decode(o.value,{stream:!o.done});d&&(i=`\r${i}`,d=!1),!o.done&&i.endsWith("\r")&&(i=i.slice(0,-1),d=!0),o.done&&d&&(i+="\r",d=!1),n+=i.replace(/\r\n|\r/g,`
|
|
4
4
|
`);let E=n.indexOf(`
|
package/dist/sse.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as b } from "./conversation-CZfbgCXd.js";
|
|
2
2
|
const S = 1e6, u = (e) => typeof e == "object" && e !== null && !Array.isArray(e), E = (e, t, r) => {
|
|
3
3
|
const a = Object.keys(e).find(
|
|
4
4
|
(s) => s.toLowerCase() === t.toLowerCase()
|
package/dist/styles.css
CHANGED
|
@@ -283,8 +283,8 @@
|
|
|
283
283
|
background: var(--make-ai-internal-bg);
|
|
284
284
|
border-bottom: 1px solid var(--make-ai-internal-border);
|
|
285
285
|
display: grid;
|
|
286
|
-
gap:
|
|
287
|
-
grid-template-columns:
|
|
286
|
+
gap: 10px;
|
|
287
|
+
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
|
288
288
|
grid-row: 1;
|
|
289
289
|
height: var(--make-ai-internal-header-height);
|
|
290
290
|
min-height: var(--make-ai-internal-header-height);
|
|
@@ -327,6 +327,7 @@
|
|
|
327
327
|
|
|
328
328
|
.make-ai-assistant__avatar svg,
|
|
329
329
|
.make-ai-assistant__icon-button svg,
|
|
330
|
+
.make-ai-assistant__task-list-trigger svg,
|
|
330
331
|
.make-ai-assistant__send svg {
|
|
331
332
|
fill: none;
|
|
332
333
|
height: 20px;
|
|
@@ -359,6 +360,71 @@
|
|
|
359
360
|
align-items: center;
|
|
360
361
|
display: flex;
|
|
361
362
|
gap: 2px;
|
|
363
|
+
justify-self: end;
|
|
364
|
+
min-width: 0;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.make-ai-assistant__header-leading {
|
|
368
|
+
justify-self: start;
|
|
369
|
+
min-width: 0;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.make-ai-assistant__header-center {
|
|
373
|
+
align-items: center;
|
|
374
|
+
display: flex;
|
|
375
|
+
gap: 8px;
|
|
376
|
+
justify-self: center;
|
|
377
|
+
max-width: min(100%, 310px);
|
|
378
|
+
min-width: 0;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.make-ai-assistant__header-center > .make-ai-assistant__avatar {
|
|
382
|
+
border-radius: 50%;
|
|
383
|
+
height: 30px;
|
|
384
|
+
width: 30px;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.make-ai-assistant__header-center > .make-ai-assistant__avatar svg {
|
|
388
|
+
height: 17px;
|
|
389
|
+
width: 17px;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.make-ai-assistant__task-list-trigger {
|
|
393
|
+
align-items: center;
|
|
394
|
+
background: transparent;
|
|
395
|
+
border: 1px solid transparent;
|
|
396
|
+
border-radius: 9px;
|
|
397
|
+
color: var(--make-ai-internal-text-secondary);
|
|
398
|
+
cursor: pointer;
|
|
399
|
+
display: inline-flex;
|
|
400
|
+
font-size: var(--make-ai-internal-font-size-meta);
|
|
401
|
+
gap: 6px;
|
|
402
|
+
height: 34px;
|
|
403
|
+
max-width: 118px;
|
|
404
|
+
padding: 0 8px;
|
|
405
|
+
white-space: nowrap;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.make-ai-assistant__task-list-trigger:hover,
|
|
409
|
+
.make-ai-assistant__task-list-trigger[aria-expanded="true"] {
|
|
410
|
+
background: var(--make-ai-internal-surface);
|
|
411
|
+
border-color: color-mix(in srgb, var(--make-ai-internal-accent) 30%, var(--make-ai-internal-border));
|
|
412
|
+
color: var(--make-ai-internal-text);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
.make-ai-assistant__task-list-trigger svg:first-child {
|
|
416
|
+
height: 17px;
|
|
417
|
+
width: 17px;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
.make-ai-assistant__task-list-trigger svg:last-child {
|
|
421
|
+
height: 12px;
|
|
422
|
+
transition: transform 160ms ease;
|
|
423
|
+
width: 12px;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
.make-ai-assistant__task-list-trigger[aria-expanded="true"] svg:last-child {
|
|
427
|
+
transform: rotate(180deg);
|
|
362
428
|
}
|
|
363
429
|
|
|
364
430
|
.make-ai-assistant__header-content,
|
|
@@ -375,6 +441,7 @@
|
|
|
375
441
|
|
|
376
442
|
.make-ai-assistant__header-title-row {
|
|
377
443
|
gap: 8px;
|
|
444
|
+
justify-content: center;
|
|
378
445
|
}
|
|
379
446
|
|
|
380
447
|
.make-ai-assistant__header-title {
|
|
@@ -385,6 +452,17 @@
|
|
|
385
452
|
white-space: nowrap;
|
|
386
453
|
}
|
|
387
454
|
|
|
455
|
+
.make-ai-assistant__current-conversation {
|
|
456
|
+
color: var(--make-ai-internal-text-secondary);
|
|
457
|
+
flex: 0 1 auto;
|
|
458
|
+
font-size: var(--make-ai-internal-font-size-caption);
|
|
459
|
+
line-height: var(--make-ai-internal-line-height-caption);
|
|
460
|
+
min-width: 0;
|
|
461
|
+
overflow: hidden;
|
|
462
|
+
text-overflow: ellipsis;
|
|
463
|
+
white-space: nowrap;
|
|
464
|
+
}
|
|
465
|
+
|
|
388
466
|
.make-ai-assistant__read-only-tag {
|
|
389
467
|
background: color-mix(in srgb, var(--make-ai-internal-accent) 10%, var(--make-ai-internal-bg));
|
|
390
468
|
border: 1px solid color-mix(in srgb, var(--make-ai-internal-accent) 24%, var(--make-ai-internal-border));
|
|
@@ -399,6 +477,7 @@
|
|
|
399
477
|
|
|
400
478
|
.make-ai-assistant__header-context {
|
|
401
479
|
gap: 6px;
|
|
480
|
+
justify-content: center;
|
|
402
481
|
margin-top: 1px;
|
|
403
482
|
}
|
|
404
483
|
|
|
@@ -1260,14 +1339,15 @@
|
|
|
1260
1339
|
}
|
|
1261
1340
|
|
|
1262
1341
|
.make-ai-assistant__composer {
|
|
1263
|
-
align-items: flex-end;
|
|
1264
1342
|
background: var(--make-ai-internal-surface);
|
|
1265
1343
|
border: 1px solid var(--make-ai-internal-border);
|
|
1266
1344
|
border-radius: 15px;
|
|
1267
|
-
display:
|
|
1268
|
-
gap:
|
|
1269
|
-
|
|
1270
|
-
|
|
1345
|
+
display: grid;
|
|
1346
|
+
gap: 7px 10px;
|
|
1347
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
1348
|
+
grid-template-rows: minmax(46px, auto) 36px;
|
|
1349
|
+
min-height: 96px;
|
|
1350
|
+
padding: 10px 10px 8px;
|
|
1271
1351
|
transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
|
|
1272
1352
|
}
|
|
1273
1353
|
|
|
@@ -1285,10 +1365,12 @@
|
|
|
1285
1365
|
color: var(--make-ai-internal-text);
|
|
1286
1366
|
font-size: var(--make-ai-internal-font-size-body);
|
|
1287
1367
|
line-height: var(--make-ai-internal-line-height-body);
|
|
1288
|
-
|
|
1289
|
-
|
|
1368
|
+
grid-column: 1 / -1;
|
|
1369
|
+
grid-row: 1;
|
|
1370
|
+
max-height: 128px;
|
|
1371
|
+
min-height: 46px;
|
|
1290
1372
|
outline: 0;
|
|
1291
|
-
padding:
|
|
1373
|
+
padding: 2px 5px;
|
|
1292
1374
|
resize: none;
|
|
1293
1375
|
width: 100%;
|
|
1294
1376
|
}
|
|
@@ -1312,12 +1394,20 @@
|
|
|
1312
1394
|
flex: 0 0 auto;
|
|
1313
1395
|
height: 34px;
|
|
1314
1396
|
justify-content: center;
|
|
1315
|
-
margin-bottom: 2px;
|
|
1316
1397
|
position: relative;
|
|
1317
1398
|
transition: background 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
|
|
1318
1399
|
width: 34px;
|
|
1319
1400
|
}
|
|
1320
1401
|
|
|
1402
|
+
.make-ai-assistant__composer-actions {
|
|
1403
|
+
align-items: center;
|
|
1404
|
+
display: flex;
|
|
1405
|
+
gap: 7px;
|
|
1406
|
+
grid-column: 2;
|
|
1407
|
+
grid-row: 2;
|
|
1408
|
+
justify-self: end;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1321
1411
|
.make-ai-assistant__send::before {
|
|
1322
1412
|
content: "";
|
|
1323
1413
|
inset: -5px;
|
|
@@ -1555,11 +1645,33 @@ button.make-ai-artifact__record:hover { background: var(--make-ai-internal-accen
|
|
|
1555
1645
|
|
|
1556
1646
|
@container (max-width: 360px) {
|
|
1557
1647
|
.make-ai-assistant__header {
|
|
1558
|
-
gap:
|
|
1559
|
-
grid-template-columns: auto minmax(0, 1fr)
|
|
1648
|
+
gap: 6px;
|
|
1649
|
+
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
|
1560
1650
|
padding: 7px var(--make-ai-internal-panel-gutter-compact);
|
|
1561
1651
|
}
|
|
1562
1652
|
|
|
1653
|
+
.make-ai-assistant__task-list-trigger {
|
|
1654
|
+
max-width: 34px;
|
|
1655
|
+
padding: 0 8px;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
.make-ai-assistant__task-list-trigger > span,
|
|
1659
|
+
.make-ai-assistant__task-list-trigger svg:last-child,
|
|
1660
|
+
.make-ai-assistant__current-conversation,
|
|
1661
|
+
.make-ai-assistant__read-only-tag,
|
|
1662
|
+
.make-ai-assistant__header-context {
|
|
1663
|
+
display: none;
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
.make-ai-assistant__header-center {
|
|
1667
|
+
gap: 6px;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
.make-ai-assistant__header-center > .make-ai-assistant__avatar {
|
|
1671
|
+
height: 26px;
|
|
1672
|
+
width: 26px;
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1563
1675
|
.make-ai-assistant__body {
|
|
1564
1676
|
padding: 16px var(--make-ai-internal-panel-gutter-compact) 24px;
|
|
1565
1677
|
}
|
|
@@ -1738,6 +1850,305 @@ button.make-ai-artifact__record:hover { background: var(--make-ai-internal-accen
|
|
|
1738
1850
|
}
|
|
1739
1851
|
}
|
|
1740
1852
|
|
|
1853
|
+
.make-ai-assistant__conversation-controls {
|
|
1854
|
+
background: var(--make-ai-internal-surface);
|
|
1855
|
+
border: 1px solid var(--make-ai-internal-border);
|
|
1856
|
+
border-radius: 12px;
|
|
1857
|
+
box-shadow: 0 14px 34px color-mix(in srgb, var(--make-ai-internal-text) 12%, transparent);
|
|
1858
|
+
font-size: var(--make-ai-internal-font-size-meta);
|
|
1859
|
+
left: var(--make-ai-internal-panel-gutter);
|
|
1860
|
+
max-height: min(430px, calc(100% - var(--make-ai-internal-header-height) - 24px));
|
|
1861
|
+
overflow: auto;
|
|
1862
|
+
padding: 12px 8px 8px;
|
|
1863
|
+
position: absolute;
|
|
1864
|
+
top: calc(var(--make-ai-internal-header-height) + 8px);
|
|
1865
|
+
width: min(300px, calc(100% - var(--make-ai-internal-panel-gutter) * 2));
|
|
1866
|
+
z-index: calc(var(--make-ai-internal-z-index) + 1);
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
.make-ai-assistant__panel--managed {
|
|
1870
|
+
grid-template-rows: auto minmax(0, 1fr) auto;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
.make-ai-assistant__response-status { color: var(--make-ai-internal-text-secondary); font-size: var(--make-ai-internal-font-size-meta); }
|
|
1874
|
+
|
|
1875
|
+
.make-ai-assistant__conversation-heading {
|
|
1876
|
+
align-items: center;
|
|
1877
|
+
color: var(--make-ai-internal-text-secondary);
|
|
1878
|
+
display: flex;
|
|
1879
|
+
font-size: var(--make-ai-internal-font-size-caption);
|
|
1880
|
+
justify-content: space-between;
|
|
1881
|
+
letter-spacing: .02em;
|
|
1882
|
+
min-height: 26px;
|
|
1883
|
+
padding: 0 7px 6px;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
.make-ai-assistant__conversation-list {
|
|
1887
|
+
max-height: 220px;
|
|
1888
|
+
overflow: auto;
|
|
1889
|
+
overscroll-behavior: contain;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
.make-ai-assistant__conversation-list > p {
|
|
1893
|
+
color: var(--make-ai-internal-text-secondary);
|
|
1894
|
+
margin: 16px 8px;
|
|
1895
|
+
text-align: center;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
.make-ai-assistant__conversation-row {
|
|
1899
|
+
align-items: center;
|
|
1900
|
+
display: flex;
|
|
1901
|
+
gap: 2px;
|
|
1902
|
+
min-width: 0;
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
.make-ai-assistant__conversation-row > button:first-child {
|
|
1906
|
+
align-items: center;
|
|
1907
|
+
border-color: transparent;
|
|
1908
|
+
display: flex;
|
|
1909
|
+
flex: 1;
|
|
1910
|
+
gap: 8px;
|
|
1911
|
+
min-height: 36px;
|
|
1912
|
+
min-width: 0;
|
|
1913
|
+
overflow: hidden;
|
|
1914
|
+
padding: 0 8px;
|
|
1915
|
+
text-align: left;
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
.make-ai-assistant__conversation-row > button:first-child svg,
|
|
1919
|
+
.make-ai-assistant__conversation-new svg {
|
|
1920
|
+
fill: none;
|
|
1921
|
+
flex: 0 0 auto;
|
|
1922
|
+
height: 16px;
|
|
1923
|
+
stroke: currentColor;
|
|
1924
|
+
stroke-linecap: round;
|
|
1925
|
+
stroke-linejoin: round;
|
|
1926
|
+
stroke-width: 1.7;
|
|
1927
|
+
width: 16px;
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
.make-ai-assistant__conversation-row > button:first-child span {
|
|
1931
|
+
min-width: 0;
|
|
1932
|
+
overflow: hidden;
|
|
1933
|
+
text-overflow: ellipsis;
|
|
1934
|
+
white-space: nowrap;
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
.make-ai-assistant__conversation-row > button[aria-pressed="true"] {
|
|
1938
|
+
background: var(--make-ai-internal-accent-soft);
|
|
1939
|
+
color: var(--make-ai-internal-accent);
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
.make-ai-assistant__conversation-row > button:last-child {
|
|
1943
|
+
background: transparent;
|
|
1944
|
+
border-color: transparent;
|
|
1945
|
+
color: var(--make-ai-internal-text-secondary);
|
|
1946
|
+
flex: 0 0 auto;
|
|
1947
|
+
height: 30px;
|
|
1948
|
+
padding: 0;
|
|
1949
|
+
width: 30px;
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
.make-ai-assistant__conversation-more,
|
|
1953
|
+
.make-ai-assistant__conversation-refresh {
|
|
1954
|
+
background: transparent !important;
|
|
1955
|
+
border-color: transparent !important;
|
|
1956
|
+
color: var(--make-ai-internal-text-secondary) !important;
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
.make-ai-assistant__conversation-more {
|
|
1960
|
+
margin-top: 4px;
|
|
1961
|
+
width: 100%;
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
.make-ai-assistant__conversation-management {
|
|
1965
|
+
border-top: 1px solid var(--make-ai-internal-border);
|
|
1966
|
+
margin-top: 8px;
|
|
1967
|
+
padding: 8px 7px 0;
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
.make-ai-assistant__conversation-management summary {
|
|
1971
|
+
color: var(--make-ai-internal-text-secondary);
|
|
1972
|
+
cursor: pointer;
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
.make-ai-assistant__conversation-actions {
|
|
1976
|
+
align-items: center;
|
|
1977
|
+
display: flex;
|
|
1978
|
+
flex-wrap: wrap;
|
|
1979
|
+
gap: 6px;
|
|
1980
|
+
padding-top: 8px;
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
.make-ai-assistant__conversation-actions input {
|
|
1984
|
+
flex: 1;
|
|
1985
|
+
min-width: 100px;
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
.make-ai-assistant__conversation-error {
|
|
1989
|
+
color: var(--make-ai-internal-danger);
|
|
1990
|
+
display: grid;
|
|
1991
|
+
gap: 6px;
|
|
1992
|
+
padding: 8px 7px 0;
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
.make-ai-assistant__conversation-new {
|
|
1996
|
+
align-items: center;
|
|
1997
|
+
background: transparent !important;
|
|
1998
|
+
border-color: transparent !important;
|
|
1999
|
+
border-radius: 8px !important;
|
|
2000
|
+
border-top: 1px solid var(--make-ai-internal-border) !important;
|
|
2001
|
+
color: var(--make-ai-internal-accent) !important;
|
|
2002
|
+
display: flex;
|
|
2003
|
+
font-weight: 650 !important;
|
|
2004
|
+
gap: 8px;
|
|
2005
|
+
justify-content: flex-start;
|
|
2006
|
+
margin-top: 8px;
|
|
2007
|
+
min-height: 40px;
|
|
2008
|
+
padding: 8px !important;
|
|
2009
|
+
width: 100%;
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
.make-ai-assistant__conversation-new:hover {
|
|
2013
|
+
background: var(--make-ai-internal-accent-soft) !important;
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
.make-ai-assistant__conversation-controls button,
|
|
2017
|
+
.make-ai-assistant__feedback button,
|
|
2018
|
+
.make-ai-assistant__attachment button {
|
|
2019
|
+
background: var(--make-ai-internal-surface);
|
|
2020
|
+
border: 1px solid var(--make-ai-internal-border);
|
|
2021
|
+
border-radius: 6px;
|
|
2022
|
+
color: inherit;
|
|
2023
|
+
cursor: pointer;
|
|
2024
|
+
font: inherit;
|
|
2025
|
+
padding: 4px 8px;
|
|
2026
|
+
}
|
|
2027
|
+
.make-ai-assistant__feedback { display: flex; flex-wrap: wrap; gap: 6px; font-size: var(--make-ai-internal-font-size-meta); }
|
|
2028
|
+
.make-ai-assistant__feedback button[aria-pressed="true"] { color: var(--make-ai-internal-accent); border-color: var(--make-ai-internal-accent); }
|
|
2029
|
+
.make-ai-assistant__feedback form { display: grid; flex-basis: 100%; gap: 6px; }
|
|
2030
|
+
.make-ai-assistant__feedback input,
|
|
2031
|
+
.make-ai-assistant__feedback textarea,
|
|
2032
|
+
.make-ai-assistant__conversation-actions input { border: 1px solid var(--make-ai-internal-border); border-radius: 6px; color: inherit; font: inherit; padding: 6px; width: 100%; }
|
|
2033
|
+
.make-ai-assistant__attachment { align-items: center; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid var(--make-ai-internal-border); border-radius: 8px; font-size: var(--make-ai-internal-font-size-meta); }
|
|
2034
|
+
.make-ai-assistant__attachment img,
|
|
2035
|
+
.make-ai-assistant__attachment video { max-height: 260px; max-width: 100%; object-fit: contain; }
|
|
2036
|
+
.make-ai-assistant__attachment audio { max-width: 100%; }
|
|
2037
|
+
|
|
2038
|
+
.make-ai-assistant__attachment-composer {
|
|
2039
|
+
align-self: center;
|
|
2040
|
+
font-size: var(--make-ai-internal-font-size-meta);
|
|
2041
|
+
grid-column: 1;
|
|
2042
|
+
grid-row: 2;
|
|
2043
|
+
justify-self: start;
|
|
2044
|
+
position: relative;
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
.make-ai-assistant__attachment-trigger {
|
|
2048
|
+
align-items: center;
|
|
2049
|
+
background: transparent;
|
|
2050
|
+
border: 1px solid transparent;
|
|
2051
|
+
border-radius: 50%;
|
|
2052
|
+
color: var(--make-ai-internal-text-secondary);
|
|
2053
|
+
cursor: pointer;
|
|
2054
|
+
display: flex;
|
|
2055
|
+
height: 34px;
|
|
2056
|
+
justify-content: center;
|
|
2057
|
+
padding: 0;
|
|
2058
|
+
width: 34px;
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
.make-ai-assistant__attachment-trigger:hover,
|
|
2062
|
+
.make-ai-assistant__attachment-trigger[aria-expanded="true"] {
|
|
2063
|
+
background: var(--make-ai-internal-surface-strong);
|
|
2064
|
+
border-color: color-mix(in srgb, var(--make-ai-internal-accent) 24%, var(--make-ai-internal-border));
|
|
2065
|
+
color: var(--make-ai-internal-text);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
.make-ai-assistant__attachment-trigger svg,
|
|
2069
|
+
.make-ai-assistant__attachment-menu svg {
|
|
2070
|
+
fill: none;
|
|
2071
|
+
height: 18px;
|
|
2072
|
+
stroke: currentColor;
|
|
2073
|
+
stroke-linecap: round;
|
|
2074
|
+
stroke-linejoin: round;
|
|
2075
|
+
stroke-width: 1.7;
|
|
2076
|
+
width: 18px;
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
.make-ai-assistant__attachment-menu {
|
|
2080
|
+
background: var(--make-ai-internal-surface);
|
|
2081
|
+
border: 1px solid var(--make-ai-internal-border);
|
|
2082
|
+
border-radius: 10px;
|
|
2083
|
+
bottom: calc(100% + 8px);
|
|
2084
|
+
box-shadow: 0 12px 28px color-mix(in srgb, var(--make-ai-internal-text) 12%, transparent);
|
|
2085
|
+
left: 0;
|
|
2086
|
+
min-width: 168px;
|
|
2087
|
+
padding: 5px;
|
|
2088
|
+
position: absolute;
|
|
2089
|
+
z-index: calc(var(--make-ai-internal-z-index) + 2);
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
.make-ai-assistant__attachment-menu button {
|
|
2093
|
+
align-items: center;
|
|
2094
|
+
background: transparent;
|
|
2095
|
+
border: 0;
|
|
2096
|
+
border-radius: 7px;
|
|
2097
|
+
color: var(--make-ai-internal-text);
|
|
2098
|
+
cursor: pointer;
|
|
2099
|
+
display: flex;
|
|
2100
|
+
gap: 9px;
|
|
2101
|
+
min-height: 38px;
|
|
2102
|
+
padding: 0 10px;
|
|
2103
|
+
text-align: left;
|
|
2104
|
+
width: 100%;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
.make-ai-assistant__attachment-menu button:hover {
|
|
2108
|
+
background: var(--make-ai-internal-surface-strong);
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
.make-ai-assistant__attachment-drafts {
|
|
2112
|
+
font-size: var(--make-ai-internal-font-size-meta);
|
|
2113
|
+
max-height: 140px;
|
|
2114
|
+
overflow: auto;
|
|
2115
|
+
padding-bottom: 8px;
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
.make-ai-assistant__attachment-drafts ul {
|
|
2119
|
+
display: flex;
|
|
2120
|
+
flex-wrap: wrap;
|
|
2121
|
+
gap: 6px;
|
|
2122
|
+
list-style: none;
|
|
2123
|
+
margin: 0;
|
|
2124
|
+
padding: 0;
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
.make-ai-assistant__attachment-drafts li {
|
|
2128
|
+
align-items: center;
|
|
2129
|
+
background: var(--make-ai-internal-surface);
|
|
2130
|
+
border: 1px solid var(--make-ai-internal-border);
|
|
2131
|
+
border-radius: 8px;
|
|
2132
|
+
display: flex;
|
|
2133
|
+
flex-wrap: wrap;
|
|
2134
|
+
gap: 4px;
|
|
2135
|
+
padding: 5px 7px;
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
.make-ai-assistant__attachment-drafts button {
|
|
2139
|
+
background: transparent;
|
|
2140
|
+
border: 0;
|
|
2141
|
+
color: var(--make-ai-internal-accent);
|
|
2142
|
+
cursor: pointer;
|
|
2143
|
+
padding: 2px 4px;
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
.make-ai-assistant__conversation-controls button:focus-visible,
|
|
2147
|
+
.make-ai-assistant__feedback button:focus-visible,
|
|
2148
|
+
.make-ai-assistant__attachment button:focus-visible,
|
|
2149
|
+
.make-ai-assistant__attachment-composer button:focus-visible,
|
|
2150
|
+
.make-ai-assistant__attachment-drafts button:focus-visible { outline: 2px solid var(--make-ai-internal-accent); outline-offset: 2px; }
|
|
2151
|
+
|
|
1741
2152
|
@media (prefers-reduced-motion: reduce) {
|
|
1742
2153
|
.make-ai-assistant__drawer,
|
|
1743
2154
|
.make-ai-assistant__launcher-orbit,
|
|
@@ -1756,4 +2167,8 @@ button.make-ai-artifact__record:hover { background: var(--make-ai-internal-accen
|
|
|
1756
2167
|
.make-ai-assistant__process summary::after {
|
|
1757
2168
|
transition: none;
|
|
1758
2169
|
}
|
|
2170
|
+
|
|
2171
|
+
.make-ai-assistant__task-list-trigger svg:last-child {
|
|
2172
|
+
transition: none;
|
|
2173
|
+
}
|
|
1759
2174
|
}
|
package/docs/backend-contract.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Make AI
|
|
1
|
+
# Make AI 助手后端配合合同
|
|
2
2
|
|
|
3
3
|
## Make Console 当前 Web 接口
|
|
4
4
|
|
|
@@ -26,28 +26,15 @@ Console BFF 与 Make App Browser API 的认证和资源模型不同,不能只
|
|
|
26
26
|
transport。平台包分别提供 `/make-console` 与 `/make-app` 两个入口,聊天 UI 与 Artifact
|
|
27
27
|
模板保持共享。
|
|
28
28
|
|
|
29
|
-
## Make App
|
|
29
|
+
## Make App 当前后端接入
|
|
30
30
|
|
|
31
|
-
Make App
|
|
32
|
-
下列语义操作,不定义或拼接任何部署路径:
|
|
31
|
+
Make App 通过 `/make-app` adapter 消费当前唯一契约。包提供 Chat 管理、历史、输入、输出、反馈、上传和原件的语义方法,实际 URL/身份与代理由宿主负责。完整接口映射与时序见 [接入说明](make-app-integration.md)。
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
| 订阅响应 | `{ chatId, responseId, cursor }` | 兼容 adapter 合同的 EventSource |
|
|
40
|
-
|
|
41
|
-
实际请求由宿主认证边界发起。URL、请求方法、Cookie、Ingress、Service 代理、租户与当前用户
|
|
42
|
-
解析都由宿主决定;浏览器不能读取或构造服务端凭证。宿主必须传递 `AbortSignal`,并在取消
|
|
43
|
-
后尽快停止尚未完成的请求。
|
|
44
|
-
|
|
45
|
-
当前事件包括 `run.started`、`response.delta`、`response.progress`、
|
|
46
|
-
`response.message`、`response.completed`、`response.failed` 和 `heartbeat`。
|
|
47
|
-
`response.message` 是完整文本替换,不是 delta。当前接口没有新建会话、远程取消和
|
|
48
|
-
Artifact;前端必须按能力降级,不应伪造这些能力。
|
|
49
|
-
Make App adapter 会在 `JSON.parse` 前限制单个 EventSource `data` 字符数,默认
|
|
50
|
-
1,000,000;历史恢复最多接受 200 条消息、1,000,000 字符正文和 500 个 Artifact。
|
|
33
|
+
宿主返回裸 JSON,204 没有 body,内容读取返回 Uint8Array。Chat 的 title/pinned 修改和删除使用 expectedRevision;创建和反馈使用稳定 requestId;发送使用稳定 messageId。历史从数值 cursor 正向读取,列表使用独立不透明游标。
|
|
34
|
+
|
|
35
|
+
SSE 使用 response.subscribed/state、output_item.added/output_text.delta/output_item.done、reset/snapshot 以及 completed/failed/cancelled。输出项身份与最终持久消息身份分离;生成完成后读历史对账,再提交反馈。快照覆盖已有视图;关闭订阅不会取消 Run,显式取消可能先返回 202,随后确认终态。
|
|
36
|
+
|
|
37
|
+
附件先完成分段上传,引用 ready 内容的长度/MIME/摘要后发送。模型媒体能力逐类验收,不能凭上传成功开放。当前 Make App 没有 Artifact 或重新生成的服务器语义,不发送未定义的 context/capabilities 扩展。
|
|
51
38
|
|
|
52
39
|
## 通用标准接口能力
|
|
53
40
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Make App 当前契约接入
|
|
2
|
+
|
|
3
|
+
本分支将现有 `/make-app` 入口原地接入当前个人多会话、反馈、附件和 item/part SSE 契约。没有协议版本选择,没有隐式定位单一会话,也不自动替宿主做登录。包版本发布号与业务协议无关。
|
|
4
|
+
|
|
5
|
+
## 宿主接线
|
|
6
|
+
|
|
7
|
+
从 `@qfei-design/make-ai-assistant/make-app` 导入 `createMakeAppAssistantTransport`,从 `/react` 导入 `MakeAiAssistant` 或 `AssistantPanel`。实现下面的语义回调;可复制 [宿主回调映射](../examples/make-app/transport.ts) 中的映射,替换为 POC 已有认证请求封装。所有 URL、Cookie 转发与服务端鉴权属于宿主。
|
|
8
|
+
|
|
9
|
+
| 宿主回调 | 作用与结果 |
|
|
10
|
+
|---|---|
|
|
11
|
+
| resolveScope(context) | 返回明确的 appKey、agentId、identityKey;用户或租户变化时 identityKey 必须改变 |
|
|
12
|
+
| listAgents | 产品内启用 Agent 数组的裸响应 |
|
|
13
|
+
| createChat | requestId 幂等创建;返回 Chat |
|
|
14
|
+
| listChats | 当前用户在产品/Agent 下的列表;返回 chats、nextCursor、hasMore |
|
|
15
|
+
| getChat / updateChat / deleteChat | 详情、title/pinned 更新、软删除;更新/删除带 expectedRevision |
|
|
16
|
+
| loadHistory | 指定 chatId 和数值 cursor;返回 messages、nextCursor、hasMore |
|
|
17
|
+
| sendMessage | 稳定 messageId;text 或 parts 二选一;返回 chatId、responseId、acceptedCursor |
|
|
18
|
+
| getResponse / cancelResponse | 权威快照、独立取消;取消可能返回仍 running 的快照与 cancelRequested=true |
|
|
19
|
+
| setFeedback | 持久助手 messageId、requestId、like/dislike/none,以及可选 reason/comment |
|
|
20
|
+
| startUpload / getUpload | 上传初始化与 completedParts 续传进度 |
|
|
21
|
+
| uploadPart / completeUpload | 从 0 编号的二进制分段,全部完成后获取 ready 内容引用 |
|
|
22
|
+
| readContent | 鉴权后原始 Uint8Array,不能把 contentRef 当公开 URL |
|
|
23
|
+
| eventSourceFactory | 以 chatId、responseId、cursor 创建带凭据的 EventSource;包负责关闭与重连 |
|
|
24
|
+
|
|
25
|
+
JSON 回调返回服务端裸对象,204 返回 void,内容返回 Uint8Array。不要在所有响应上统一解包 data 或 JSON.parse。每个异步回调都必须传递 AbortSignal。scopeKey 仅隔离浏览器内的状态,不能代替服务器授权。
|
|
26
|
+
|
|
27
|
+
会话查询和创建相互独立。`loadConversation(context,{threadId,cursor,signal})` 只恢复选中的会话,不隐式创建;UI 点击新建或首次主动发送才创建。公开返回的 `threadId` 对应 chatId,responseId 对应执行 Run。
|
|
28
|
+
|
|
29
|
+
## 包提供的交互
|
|
30
|
+
|
|
31
|
+
内置面板可列出、选择、新建会话,编辑标题、置顶/取消置顶、确认删除;改名/置顶/删除失败保留用户可见错误。修订冲突后读取最新详情,不自动换 revision 覆盖。
|
|
32
|
+
|
|
33
|
+
输入和重试保存稳定 UUID。多个输入可能对应同一 responseId;面板控制器在响应维度保持一个订阅,关闭面板继续保留当前 UI,切会话/身份或卸载只释放本地连接。停止按钮调用 cancelResponse,并等待终态;完成与取消竞争时接受服务端最终结果。
|
|
34
|
+
|
|
35
|
+
输出按 itemId/partId 归并,完整 done 文本覆盖增量。中间模型活动放在过程区域,不能充当最终可反馈消息。response.completed 后读取历史对账,切换到持久助手 messageId,再开放反馈。点踩说明提交失败保留表单,重新提交复用未知结果的原意图;撤销用 rating=none。
|
|
36
|
+
|
|
37
|
+
文件选择、拖拽和粘贴进入同一上传队列。分段大小读 partSize,重试先查 completedParts;未 ready 的附件不能发送。暂停/移除只影响本地任务和草稿,当前没有远程上传取消接口。附件卡片可鉴权下载和受控预览,不执行 HTML/SVG/脚本。
|
|
38
|
+
|
|
39
|
+
## 流式事件与恢复
|
|
40
|
+
|
|
41
|
+
公开流消费 `response.subscribed/state/output_item.added/output_text.delta/output_item.done/reset/snapshot/completed/failed/cancelled`。这些事件在 adapter 转换为 headless 的响应事件,不复用通用 SSE 的消息身份来猜最终答案。
|
|
42
|
+
|
|
43
|
+
公开 `AssistantEvent` 增加:
|
|
44
|
+
|
|
45
|
+
- response.accepted:输入受理与 responseId 关联。
|
|
46
|
+
- response.state、response.output_item.added、response.output_text.delta、response.output_item.done:运行状态和项级输出。
|
|
47
|
+
- response.snapshot:覆盖该响应已确认的输出视图。
|
|
48
|
+
- response.reconciled:持久消息对账。
|
|
49
|
+
- response.terminal:completed/failed/cancelled 终态。
|
|
50
|
+
|
|
51
|
+
`AssistantConversationState.responses` 保存各响应状态,activeRunId 只是当前活动响应的便利字段,不是唯一运行事实。终态后迟到增量不能重新打开响应。原有通用 SSE、Console、Mock 与 Artifact 公共入口仍各自归一化到同一 headless 合同。
|
|
52
|
+
|
|
53
|
+
EventSource.onerror 后先关闭旧实例,再由 adapter 从最后处理游标有界重连;不要同时设置第二套宿主重连循环。query cursor 优先于 Last-Event-ID。reset 后消费服务器快照;通道连续失败时切到权威快照。快照没有完整在途 token,也没有可直接切回 Redis 的水位,不能将任意旧 delta 追加到快照。
|
|
54
|
+
|
|
55
|
+
完成对账失败会报告恢复错误,不能被重连逻辑吞掉。普通断网与 HTTP/SSE 读取失败都不等同于业务 Run 已取消。
|
|
56
|
+
|
|
57
|
+
## 限制与未开放能力
|
|
58
|
+
|
|
59
|
+
| 事项 | 当前行为 |
|
|
60
|
+
|---|---|
|
|
61
|
+
| 输入 | 文本累计 8 KiB UTF-8;最多 32 个有序 parts;整体消息 JSON 64 KiB |
|
|
62
|
+
| 上传 | 单文件 64 MiB,分段当前 1 MiB;服务端按完整 Namespace 限流/限容量 |
|
|
63
|
+
| 历史 | cursor=-1 从最早事件正向扫描,limit 数底层事件;空可见页仍可 hasMore=true |
|
|
64
|
+
| 长历史 | 分页继续加载,有界展示最近加载的 200 条/正文预算;不会声称首个窗口是全部历史 |
|
|
65
|
+
| 模型媒体能力 | modelInputKinds 默认只有 text;逐类真实模型验收后由宿主开放 |
|
|
66
|
+
| 未完成上传 | 服务端当前 24 小时失效;无公开 abort/清理,容量不保证自动回收 |
|
|
67
|
+
| 下载 | 当前为 attachment/octet-stream,不承诺 Range/206;预览用本地受控 Blob |
|
|
68
|
+
| Artifact/页面上下文 | 通用能力保留;当前 Make App 请求不携带 context/capabilities,不从 Markdown 猜 Artifact |
|
|
69
|
+
| 重新生成 | 没有服务端替换语义,保持关闭;普通再次提问属于新消息 |
|
|
70
|
+
|
|
71
|
+
后端模型媒体适配未启用时,内部 LLM 可能返回 unsupported_media;公开消息先受理为 202 后再以 AI_RUN_FAILED 终止。前端不能依赖消息 POST 直接返回 422。
|
|
72
|
+
|
|
73
|
+
## 后续 POC 接手
|
|
74
|
+
|
|
75
|
+
1. 对接现有统一登录和 Service,完成所有语义回调;认证过期、产品/Agent/用户切换都重新核对。
|
|
76
|
+
2. 由宿主决定当前选中会话的 URL/持久化导航、草稿体验、Agent 入口和主题布局。刷新后可从包的列表选择历史会话恢复。
|
|
77
|
+
3. 用真实宿主验证未缓冲 SSE、断网重连、取消、修订冲突、反馈回显和附件字节;本地示例不是已部署 POC。
|
|
78
|
+
4. 经接手人检查后,按现有 GitLab CI 发布 alpha,再升级 POC 依赖。当前用户要求只交 feature 分支,本轮不发包、不部署 Dev。
|
|
79
|
+
|
|
80
|
+
完整字段说明以 agent-design 的 MakeAppProtocol/OpenAPI 与接口手册为准;交接飞书文档同时提供 17 项 HTTP 清单、请求示例、分支和本地验收结果。
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Make App 接入示例
|
|
2
|
+
|
|
3
|
+
本示例消费包的公开 `/react`、`/make-app` 和样式入口,展示 17 项语义回调如何连接宿主同源服务。所有 POC 复用包内会话、流式、反馈和上传状态,不复制其内部实现。
|
|
4
|
+
|
|
5
|
+
先在仓库根目录执行 `corepack pnpm build`,再执行 `corepack pnpm make-app:build`。输出在本目录的 dist,仅供宿主服务托管或本地验收;本例不处理登录、不读取 Token,也不提供生产 BFF。
|
|
6
|
+
|
|
7
|
+
宿主提供同源 `GET /runtime-config`,响应为 `{appKey, appName, agentId, identityKey}`;identityKey 是用户/租户变化时同步变化的非凭据缓存隔离键。该配置不构成服务器授权。生产 POC 应将示例 request 换成已有认证客户端,并沿现有 Service/Make Gateway 转发公共接口。
|
|
8
|
+
|
|
9
|
+
当前 Make App 后端只支持文本模型输入;示例的 modelInputKinds 为 `["text"]`。图片、文件、非实时音视频可先上传和查看原件,模型理解逐类验收后再配置开放。不要以文件上传成功判断模型已经支持。
|
|
10
|
+
|
|
11
|
+
详见 [接入说明](../../docs/make-app-integration.md)。正式发布仍由原仓库 GitLab CI 负责。
|