vzcode 3.2.0 → 3.3.0

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 (64) hide show
  1. package/README.md +185 -40
  2. package/dist/assets/App-C9mRI7eH.js +387 -0
  3. package/dist/assets/App-CxiKy3Rs.css +1 -0
  4. package/dist/assets/bindings_wasm_bg-IWNG_AjZ.wasm +0 -0
  5. package/dist/assets/buildWorker-N5tFTOqM.js +794 -0
  6. package/dist/assets/index-COLyIkCc.js +43 -0
  7. package/dist/assets/index-CZT-v4sH.css +1 -0
  8. package/dist/assets/rolldown-runtime-COiEfhsA.js +1 -0
  9. package/dist/assets/worker-BpV7Ustv.js +223 -0
  10. package/dist/assets/worker-CLeezw6h.js +458 -0
  11. package/dist/assets/worker-DaSIYBQX.js +327 -0
  12. package/dist/cli.js +170 -99
  13. package/dist/index.html +3 -2
  14. package/dist/server/accessControl.js +104 -0
  15. package/dist/server/computeInitialDocument.js +4 -1
  16. package/dist/server/createServer.js +356 -104
  17. package/dist/server/index.js +4 -3
  18. package/dist/server/workspaceSecurity.js +115 -0
  19. package/dist/server/workspaceSync.js +141 -0
  20. package/package.json +74 -72
  21. package/src/cli.ts +203 -182
  22. package/src/client/App/index.tsx +2 -0
  23. package/src/client/App/usePending.ts +3 -1
  24. package/src/client/RunCodeWidget/index.tsx +1 -0
  25. package/src/client/VZCodeContext/types.ts +6 -0
  26. package/src/client/VZCodeContext/useVZCodeState.ts +2 -0
  27. package/src/client/VZSidebar/AIChatWrapper.tsx +2 -0
  28. package/src/client/VZSidebar/VisualEditor/CheckboxWidget.tsx +22 -30
  29. package/src/client/VZSidebar/VisualEditor/ColorWidget.tsx +198 -126
  30. package/src/client/VZSidebar/VisualEditor/DropdownWidget.tsx +25 -67
  31. package/src/client/VZSidebar/VisualEditor/PropertySection.tsx +41 -0
  32. package/src/client/VZSidebar/VisualEditor/SegmentedWidget.tsx +34 -0
  33. package/src/client/VZSidebar/VisualEditor/SliderWidget.tsx +60 -12
  34. package/src/client/VZSidebar/VisualEditor/VisualEditor.tsx +31 -393
  35. package/src/client/VZSidebar/VisualEditor/VisualEditorControls.tsx +478 -0
  36. package/src/client/VZSidebar/VisualEditor/colorUtils.ts +12 -0
  37. package/src/client/VZSidebar/VisualEditor/status.ts +47 -0
  38. package/src/client/VZSidebar/VisualEditor/updateConfig.ts +51 -24
  39. package/src/client/VZSidebar/VisualEditor/utils.ts +1 -1
  40. package/src/client/VZSidebar/styles.scss +420 -0
  41. package/src/client/WorkspaceConflictBanner.tsx +120 -0
  42. package/src/client/index.ts +2 -0
  43. package/src/client/main.jsx +54 -12
  44. package/src/llm-streaming-server/README.md +4 -16
  45. package/src/llm-streaming-ui/README.md +41 -2
  46. package/src/llm-streaming-ui/components/ChatInput.tsx +65 -13
  47. package/src/llm-streaming-ui/components/index.tsx +2 -0
  48. package/src/llm-streaming-ui/hooks/useAutoScroll.ts +1 -1
  49. package/src/llm-streaming-ui/index.ts +1 -0
  50. package/src/llm-streaming-ui/props.ts +26 -2
  51. package/src/server/accessControl.ts +151 -0
  52. package/src/server/computeInitialDocument.ts +6 -2
  53. package/src/server/createServer.ts +487 -138
  54. package/src/server/index.ts +4 -5
  55. package/src/server/workspaceSecurity.ts +160 -0
  56. package/src/server/workspaceSync.ts +203 -0
  57. package/src/types.ts +29 -27
  58. package/dist/assets/bindings_wasm_bg-9w8E-TmY.wasm +0 -0
  59. package/dist/assets/buildWorker-BZlya278.js +0 -687
  60. package/dist/assets/index-B7NRhsN6.js +0 -356
  61. package/dist/assets/index-D1V1AKed.css +0 -1
  62. package/dist/assets/worker-1oQYaz-F.js +0 -342
  63. package/dist/assets/worker-BfgPD8zR.js +0 -125
  64. package/dist/assets/worker-CoJaqtpi.js +0 -436
@@ -1212,4 +1212,424 @@
1212
1212
  font-weight: 400;
1213
1213
  }
1214
1214
  }
1215
+
1216
+ // Shared Visual Properties panel. All widgets inherit a single, theme-aware
1217
+ // layout rather than drawing separate cards with hard-coded neon accents.
1218
+ .visual-editor {
1219
+ padding: 0;
1220
+ gap: 0;
1221
+ min-width: 0;
1222
+ font-family: var(--vzcode-font-family);
1223
+ color: var(--vz-color-neutral-04);
1224
+ }
1225
+
1226
+ .visual-properties-header {
1227
+ padding: 16px 16px 12px;
1228
+ border-bottom: 1px solid var(--vz-color-neutral-02);
1229
+ }
1230
+
1231
+ .visual-properties-title {
1232
+ font-size: 14px;
1233
+ font-weight: 650;
1234
+ line-height: 1.4;
1235
+ letter-spacing: -0.01em;
1236
+ }
1237
+
1238
+ .visual-properties-hint {
1239
+ margin: 4px 0 0;
1240
+ font-size: 11px;
1241
+ line-height: 1.45;
1242
+ opacity: 0.7;
1243
+ }
1244
+
1245
+ .visual-properties-section {
1246
+ min-width: 0;
1247
+ border-bottom: 1px solid var(--vz-color-neutral-02);
1248
+ }
1249
+
1250
+ .visual-properties-section-toggle {
1251
+ display: flex;
1252
+ width: 100%;
1253
+ align-items: center;
1254
+ justify-content: space-between;
1255
+ padding: 13px 16px;
1256
+ border: 0;
1257
+ background: transparent;
1258
+ color: inherit;
1259
+ font: 600 12px var(--vzcode-font-family);
1260
+ letter-spacing: 0.015em;
1261
+ cursor: pointer;
1262
+ text-align: left;
1263
+
1264
+ &:hover {
1265
+ background: var(--vz-color-neutral-02);
1266
+ }
1267
+ &:focus-visible {
1268
+ outline: 2px solid currentColor;
1269
+ outline-offset: -2px;
1270
+ }
1271
+ }
1272
+
1273
+ .visual-properties-chevron {
1274
+ display: inline-block;
1275
+ opacity: 0.65;
1276
+ transition: transform 160ms ease;
1277
+
1278
+ &.collapsed {
1279
+ transform: rotate(-90deg);
1280
+ }
1281
+ }
1282
+
1283
+ .visual-properties-section-body {
1284
+ display: flex;
1285
+ flex-direction: column;
1286
+ gap: 14px;
1287
+ padding: 2px 16px 18px;
1288
+ min-width: 0;
1289
+ }
1290
+
1291
+ .visual-editor {
1292
+ .visual-editor-slider,
1293
+ .visual-editor-checkbox,
1294
+ .visual-editor-dropdown,
1295
+ .visual-editor-text-input,
1296
+ .visual-editor-color {
1297
+ background: transparent;
1298
+ border: 0;
1299
+ border-radius: 0;
1300
+ box-shadow: none;
1301
+ padding: 0;
1302
+ gap: 7px;
1303
+ transition: none;
1304
+
1305
+ &:hover {
1306
+ background: transparent;
1307
+ border-color: transparent;
1308
+ }
1309
+ }
1310
+
1311
+ .slider-header,
1312
+ .checkbox-header,
1313
+ .dropdown-header,
1314
+ .text-input-header,
1315
+ .color-header {
1316
+ margin: 0;
1317
+ }
1318
+
1319
+ .slider-label,
1320
+ .checkbox-label,
1321
+ .dropdown-label,
1322
+ .text-input-label,
1323
+ .color-label {
1324
+ font: 500 12px var(--vzcode-font-family);
1325
+ color: var(--vz-color-neutral-04);
1326
+ }
1327
+
1328
+ .slider-value,
1329
+ .checkbox-value,
1330
+ .color-value {
1331
+ background: var(--vz-color-neutral-02);
1332
+ color: var(--vz-color-neutral-04);
1333
+ font: 500 12px var(--vzcode-font-family);
1334
+ border-radius: 5px;
1335
+ }
1336
+
1337
+ .slider-track-fill {
1338
+ background: var(--vz-color-neutral-04);
1339
+ opacity: 0.55;
1340
+ }
1341
+ .slider-input {
1342
+ &::-webkit-slider-thumb {
1343
+ background: var(--vz-color-neutral-04);
1344
+ border-color: var(--vz-color-neutral-01);
1345
+ box-shadow: 0 0 0 1px var(--vz-color-neutral-03);
1346
+ }
1347
+ &::-moz-range-thumb {
1348
+ background: var(--vz-color-neutral-04);
1349
+ border-color: var(--vz-color-neutral-01);
1350
+ box-shadow: 0 0 0 1px var(--vz-color-neutral-03);
1351
+ }
1352
+ &:focus-visible {
1353
+ outline: 2px solid currentColor;
1354
+ outline-offset: 3px;
1355
+ }
1356
+ }
1357
+ .dropdown-button:focus-visible,
1358
+ .text-input-field:focus-visible {
1359
+ border-color: var(--vz-color-neutral-04);
1360
+ box-shadow: 0 0 0 2px var(--vz-color-neutral-03);
1361
+ }
1362
+ .dropdown-option.selected {
1363
+ background: var(--vz-color-neutral-04);
1364
+ color: var(--vz-color-neutral-01);
1365
+ }
1366
+ .checkbox-indicator.checked {
1367
+ background: var(--vz-color-neutral-04);
1368
+ box-shadow: none;
1369
+ }
1370
+ .checkbox-input:checked + .checkbox-visual {
1371
+ border-color: var(--vz-color-neutral-04);
1372
+ background: var(--vz-color-neutral-02);
1373
+ }
1374
+ }
1375
+
1376
+ // Compact, accessible color picker with optional advanced HCL controls.
1377
+ .visual-editor .visual-editor-color {
1378
+ position: relative;
1379
+ }
1380
+ .color-picker-trigger {
1381
+ display: inline-flex;
1382
+ align-items: center;
1383
+ gap: 8px;
1384
+ max-width: 100%;
1385
+ padding: 3px 7px 3px 3px;
1386
+ border: 1px solid var(--vz-color-neutral-03);
1387
+ border-radius: 6px;
1388
+ background: var(--vz-color-neutral-02);
1389
+ color: var(--vz-color-neutral-04);
1390
+ font: 500 11px var(--vzcode-font-family);
1391
+ cursor: pointer;
1392
+ &:focus-visible {
1393
+ outline: 2px solid currentColor;
1394
+ outline-offset: 2px;
1395
+ }
1396
+ }
1397
+ .color-picker-swatch {
1398
+ width: 26px;
1399
+ height: 26px;
1400
+ flex: none;
1401
+ border-radius: 4px;
1402
+ border: 1px solid var(--vz-color-neutral-03);
1403
+ }
1404
+ .color-picker-hex {
1405
+ font-family: ui-monospace, SFMono-Regular, monospace;
1406
+ }
1407
+ .color-picker-popover {
1408
+ display: flex;
1409
+ flex-direction: column;
1410
+ gap: 12px;
1411
+ margin-top: 4px;
1412
+ padding: 12px;
1413
+ border: 1px solid var(--vz-color-neutral-03);
1414
+ border-radius: 9px;
1415
+ background: var(--vz-color-neutral-01);
1416
+ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
1417
+ min-width: 0;
1418
+ }
1419
+ .color-picker-field {
1420
+ display: flex;
1421
+ flex-direction: column;
1422
+ gap: 5px;
1423
+ font-size: 11px;
1424
+ }
1425
+ .color-picker-native {
1426
+ width: 100%;
1427
+ height: 42px;
1428
+ padding: 2px;
1429
+ cursor: pointer;
1430
+ border: 1px solid var(--vz-color-neutral-03);
1431
+ border-radius: 6px;
1432
+ background: transparent;
1433
+ }
1434
+ .color-picker-hex-input {
1435
+ width: 100%;
1436
+ min-width: 0;
1437
+ box-sizing: border-box;
1438
+ padding: 8px;
1439
+ border-radius: 6px;
1440
+ border: 1px solid var(--vz-color-neutral-03);
1441
+ background: var(--vz-color-neutral-02);
1442
+ color: var(--vz-color-neutral-04);
1443
+ font:
1444
+ 12px ui-monospace,
1445
+ SFMono-Regular,
1446
+ monospace;
1447
+ &:focus-visible {
1448
+ outline: 2px solid currentColor;
1449
+ outline-offset: 1px;
1450
+ }
1451
+ }
1452
+ .color-picker-preset-label {
1453
+ font-size: 11px;
1454
+ font-weight: 600;
1455
+ }
1456
+ .color-picker-presets {
1457
+ display: grid;
1458
+ grid-template-columns: repeat(8, minmax(0, 1fr));
1459
+ gap: 5px;
1460
+ }
1461
+ .color-picker-preset {
1462
+ aspect-ratio: 1;
1463
+ min-width: 0;
1464
+ padding: 0;
1465
+ border: 1px solid var(--vz-color-neutral-03);
1466
+ border-radius: 5px;
1467
+ cursor: pointer;
1468
+ &:hover,
1469
+ &:focus-visible {
1470
+ outline: 2px solid var(--vz-color-neutral-04);
1471
+ outline-offset: 1px;
1472
+ }
1473
+ &[aria-pressed='true'] {
1474
+ outline: 2px solid var(--vz-color-neutral-04);
1475
+ outline-offset: 2px;
1476
+ }
1477
+ }
1478
+ .color-picker-advanced-toggle {
1479
+ align-self: flex-start;
1480
+ padding: 0;
1481
+ border: 0;
1482
+ background: none;
1483
+ color: var(--vz-color-neutral-04);
1484
+ text-align: left;
1485
+ font: 500 11px var(--vzcode-font-family);
1486
+ cursor: pointer;
1487
+ &:focus-visible {
1488
+ outline: 2px solid currentColor;
1489
+ outline-offset: 2px;
1490
+ }
1491
+ }
1492
+
1493
+ .visual-editor .slider-header {
1494
+ gap: 8px;
1495
+ }
1496
+ .visual-editor .slider-number-input {
1497
+ width: 70px;
1498
+ min-width: 0;
1499
+ padding: 5px 6px;
1500
+ box-sizing: border-box;
1501
+ text-align: right;
1502
+ font: 500 12px var(--vzcode-font-family);
1503
+ color: var(--vz-color-neutral-04);
1504
+ background: var(--vz-color-neutral-02);
1505
+ border: 1px solid var(--vz-color-neutral-03);
1506
+ border-radius: 5px;
1507
+ &:focus-visible {
1508
+ outline: 2px solid currentColor;
1509
+ outline-offset: 1px;
1510
+ }
1511
+ }
1512
+ .visual-editor .visual-editor-checkbox {
1513
+ display: flex;
1514
+ flex-direction: row;
1515
+ align-items: center;
1516
+ justify-content: space-between;
1517
+ min-height: 28px;
1518
+ }
1519
+ .visual-editor .checkbox-container {
1520
+ width: 42px;
1521
+ height: 22px;
1522
+ flex: none;
1523
+ }
1524
+ .visual-editor .checkbox-input {
1525
+ height: 22px;
1526
+ }
1527
+ .visual-editor .visual-properties-select {
1528
+ width: 100%;
1529
+ min-width: 0;
1530
+ box-sizing: border-box;
1531
+ padding: 9px 10px;
1532
+ color: var(--vz-color-neutral-04);
1533
+ background: var(--vz-color-neutral-02);
1534
+ border: 1px solid var(--vz-color-neutral-03);
1535
+ border-radius: 6px;
1536
+ font: 500 12px var(--vzcode-font-family);
1537
+ &:focus-visible {
1538
+ outline: 2px solid currentColor;
1539
+ outline-offset: 2px;
1540
+ }
1541
+ }
1542
+ .visual-editor-segmented {
1543
+ display: flex;
1544
+ flex-direction: column;
1545
+ gap: 8px;
1546
+ min-width: 0;
1547
+ }
1548
+ .segmented-label {
1549
+ font: 500 12px var(--vzcode-font-family);
1550
+ }
1551
+ .segmented-options {
1552
+ display: flex;
1553
+ min-width: 0;
1554
+ padding: 3px;
1555
+ gap: 2px;
1556
+ border: 1px solid var(--vz-color-neutral-03);
1557
+ border-radius: 7px;
1558
+ background: var(--vz-color-neutral-02);
1559
+ }
1560
+ .segmented-option {
1561
+ flex: 1;
1562
+ min-width: 0;
1563
+ padding: 7px 5px;
1564
+ border: 0;
1565
+ border-radius: 5px;
1566
+ font: 500 11px var(--vzcode-font-family);
1567
+ color: var(--vz-color-neutral-04);
1568
+ background: transparent;
1569
+ cursor: pointer;
1570
+ white-space: nowrap;
1571
+ overflow: hidden;
1572
+ text-overflow: ellipsis;
1573
+ &[aria-pressed='true'] {
1574
+ background: var(--vz-color-neutral-01);
1575
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
1576
+ font-weight: 650;
1577
+ }
1578
+ &:focus-visible {
1579
+ outline: 2px solid currentColor;
1580
+ outline-offset: -2px;
1581
+ }
1582
+ }
1583
+
1584
+ .visual-properties-section-body[hidden] {
1585
+ display: none;
1586
+ }
1587
+ .visual-properties-field {
1588
+ display: flex;
1589
+ flex-direction: column;
1590
+ gap: 5px;
1591
+ min-width: 0;
1592
+ }
1593
+ .visual-properties-field-footer {
1594
+ display: flex;
1595
+ align-items: flex-start;
1596
+ justify-content: space-between;
1597
+ gap: 8px;
1598
+ min-width: 0;
1599
+ }
1600
+ .visual-properties-description {
1601
+ flex: 1;
1602
+ color: var(--vz-color-neutral-04);
1603
+ opacity: 0.7;
1604
+ font: 400 11px/1.45 var(--vzcode-font-family);
1605
+ }
1606
+ .visual-properties-reset {
1607
+ flex: none;
1608
+ border: none;
1609
+ padding: 0;
1610
+ background: transparent;
1611
+ font: 500 11px var(--vzcode-font-family);
1612
+ color: var(--vz-color-neutral-04);
1613
+ text-decoration: underline;
1614
+ text-underline-offset: 2px;
1615
+ cursor: pointer;
1616
+ &:disabled {
1617
+ opacity: 0.35;
1618
+ cursor: default;
1619
+ text-decoration: none;
1620
+ }
1621
+ &:focus-visible {
1622
+ outline: 2px solid currentColor;
1623
+ outline-offset: 3px;
1624
+ }
1625
+ }
1626
+ .slider-number-wrapper {
1627
+ display: flex;
1628
+ gap: 4px;
1629
+ align-items: center;
1630
+ }
1631
+ .slider-number-unit {
1632
+ font-size: 11px;
1633
+ opacity: 0.7;
1634
+ }
1215
1635
  }
@@ -0,0 +1,120 @@
1
+ import { useContext, useState } from 'react';
2
+ import { VZCodeContext } from './VZCodeContext';
3
+
4
+ /**
5
+ * Standalone-only conflict resolution. Embedded hosts can provide their
6
+ * own affordance for external file conflicts.
7
+ */
8
+ export const WorkspaceConflictBanner = () => {
9
+ const { content } = useContext(VZCodeContext);
10
+ const conflicts: string[] =
11
+ (
12
+ content as unknown as {
13
+ workspaceConflicts?: string[];
14
+ } | null
15
+ )?.workspaceConflicts ?? [];
16
+ const [busy, setBusy] = useState<string | null>(null);
17
+ const [error, setError] = useState<string | null>(null);
18
+
19
+ if (!conflicts.length) return null;
20
+
21
+ const resolve = async (
22
+ name: string,
23
+ choice: 'disk' | 'editor',
24
+ ) => {
25
+ if (
26
+ choice === 'editor' &&
27
+ !window.confirm(
28
+ 'Overwrite the external disk changes for "' +
29
+ name +
30
+ '" with the editor version?',
31
+ )
32
+ ) {
33
+ return;
34
+ }
35
+ setBusy(name);
36
+ setError(null);
37
+ try {
38
+ const response = await fetch(
39
+ '/workspace-conflicts/resolve',
40
+ {
41
+ method: 'POST',
42
+ credentials: 'same-origin',
43
+ headers: {
44
+ 'Content-Type': 'application/json',
45
+ },
46
+ body: JSON.stringify({ name, choice }),
47
+ },
48
+ );
49
+ if (!response.ok) {
50
+ const body = await response
51
+ .json()
52
+ .catch(() => ({}));
53
+ throw new Error(
54
+ body.error || 'Unable to resolve conflict',
55
+ );
56
+ }
57
+ } catch (caught: any) {
58
+ setError(caught.message ?? String(caught));
59
+ } finally {
60
+ setBusy(null);
61
+ }
62
+ };
63
+
64
+ return (
65
+ <aside
66
+ role="alert"
67
+ aria-live="polite"
68
+ style={{
69
+ position: 'fixed',
70
+ top: 8,
71
+ left: '50%',
72
+ transform: 'translateX(-50%)',
73
+ zIndex: 10000,
74
+ maxHeight: '45vh',
75
+ overflowY: 'auto',
76
+ maxWidth: 'min(600px, 95vw)',
77
+ padding: 14,
78
+ borderRadius: 8,
79
+ background: '#fff4dc',
80
+ color: '#3a2a12',
81
+ border: '1px solid #d6a341',
82
+ boxShadow: '0 4px 20px #0003',
83
+ }}
84
+ >
85
+ <strong>External filesystem conflict</strong>
86
+ <p>
87
+ Changes were made to these files outside VZCode
88
+ while there were unsaved editor changes. Autosave is
89
+ paused to prevent data loss.
90
+ </p>
91
+ {conflicts.map((name) => (
92
+ <div
93
+ key={name}
94
+ style={{
95
+ display: 'flex',
96
+ flexWrap: 'wrap',
97
+ alignItems: 'center',
98
+ gap: 8,
99
+ marginBottom: 8,
100
+ }}
101
+ >
102
+ <code>{name}</code>
103
+ <button
104
+ disabled={busy !== null}
105
+ onClick={() => void resolve(name, 'disk')}
106
+ >
107
+ Load disk version
108
+ </button>
109
+ <button
110
+ disabled={busy !== null}
111
+ onClick={() => void resolve(name, 'editor')}
112
+ >
113
+ Overwrite disk with editor
114
+ </button>
115
+ </div>
116
+ ))}
117
+ {error ? <p>{error}</p> : null}
118
+ </aside>
119
+ );
120
+ };
@@ -6,6 +6,8 @@ export {
6
6
  VZCodeContext,
7
7
  } from './VZCodeContext';
8
8
  export { VZSidebar } from './VZSidebar';
9
+ export { VisualEditorControls } from './VZSidebar/VisualEditor/VisualEditorControls';
10
+ export type { VisualEditorControlsProps } from './VZSidebar/VisualEditor/VisualEditorControls';
9
11
  export { VZSettings } from './VZSettings';
10
12
  export { VZKeyboardShortcutsDoc } from './VZKeyboardShortcutsDoc';
11
13
  export { VZResizer } from './VZResizer';
@@ -1,33 +1,75 @@
1
1
  import * as React from 'react';
2
2
  import * as ReactDOM from 'react-dom/client';
3
- import App from './App';
4
3
  import './standalone.scss';
5
4
  import { BrowserRouter } from 'react-router-dom';
6
5
 
7
- // Global error handler to catch CodeMirror DOM position errors
8
- // These can occur when CodeMirror instances are created but not yet
9
- // attached to the DOM, or when presence indicators try to render
10
- // on offscreen editor instances.
6
+ // Global error handler for a known, non-fatal CodeMirror DOM error.
11
7
  window.addEventListener('error', (event) => {
12
- // Check if this is the specific CodeMirror posFromDOM/posAtDOM error
13
8
  if (
14
9
  event.error instanceof RangeError &&
15
10
  event.error.message.includes(
16
11
  'Trying to find position for a DOM position outside of the document',
17
12
  )
18
13
  ) {
19
- // Log the error for debugging purposes
20
14
  console.log(
21
15
  'Suppressed CodeMirror DOM position error:',
22
16
  event.error,
23
17
  );
24
- // Prevent the error from being logged to console by returning true
25
18
  return true;
26
19
  }
27
20
  });
28
21
 
29
- ReactDOM.createRoot(document.getElementById('root')).render(
30
- <BrowserRouter>
31
- <App />
32
- </BrowserRouter>,
22
+ const root = ReactDOM.createRoot(
23
+ document.getElementById('root'),
33
24
  );
25
+
26
+ async function start() {
27
+ // The capability token is in the URL fragment, never sent in HTTP
28
+ // requests or referrers. Exchange it for an HttpOnly session cookie.
29
+ const fragment = new URLSearchParams(
30
+ window.location.hash.slice(1),
31
+ );
32
+ const token = fragment.get('vzcode-token');
33
+ if (token) {
34
+ const response = await fetch('/auth/session', {
35
+ method: 'POST',
36
+ headers: { Authorization: 'Bearer ' + token },
37
+ credentials: 'same-origin',
38
+ });
39
+ if (!response.ok) {
40
+ throw new Error('Invalid VZCode access link.');
41
+ }
42
+ // Remove the sensitive fragment from browser history.
43
+ window.history.replaceState(
44
+ null,
45
+ '',
46
+ window.location.pathname + window.location.search,
47
+ );
48
+ }
49
+
50
+ const status = await fetch('/auth/status', {
51
+ credentials: 'same-origin',
52
+ cache: 'no-store',
53
+ });
54
+ if (!status.ok) {
55
+ throw new Error(
56
+ 'Authorization required. Open the private URL printed by the VZCode CLI.',
57
+ );
58
+ }
59
+ // App creates its WebSocket at module initialization; it must load
60
+ // only after the session cookie has been established.
61
+ const { default: App } = await import('./App');
62
+ root.render(
63
+ <BrowserRouter>
64
+ <App />
65
+ </BrowserRouter>,
66
+ );
67
+ }
68
+
69
+ start().catch((error) => {
70
+ console.error('VZCode authentication failed:', error);
71
+ const message = document.createElement('p');
72
+ message.style.padding = '2rem';
73
+ message.textContent = error.message;
74
+ document.getElementById('root').replaceChildren(message);
75
+ });
@@ -4,7 +4,7 @@ Server-side library for streaming LLM responses with ShareDB integration.
4
4
 
5
5
  ## Overview
6
6
 
7
- This module is being extracted from VZCode's AI chat functionality to become a standalone, reusable library. It provides server-side functionality for:
7
+ This is an internal VZCode module that provides server-side functionality for:
8
8
 
9
9
  - **LLM Streaming**: Creating and managing streaming LLM functions with OpenAI/OpenRouter
10
10
  - **AI Code Editing**: Performing AI-assisted code transformations and edits
@@ -12,9 +12,10 @@ This module is being extracted from VZCode's AI chat functionality to become a s
12
12
  - **Request Validation**: Validating incoming AI chat requests
13
13
  - **Error Handling**: Handling errors gracefully in streaming contexts
14
14
 
15
- ## Current Status
15
+ ## Status
16
16
 
17
- ⚠️ **Work in Progress**: This is Phase 1 of the extraction plan. The files have been copied to this directory and imports have been updated, but the code is not yet decoupled from VZCode.
17
+ The module is used by VZCode's AI chat handler. It still depends on VZCode
18
+ types and utilities, and is not published as a standalone package.
18
19
 
19
20
  ## Files
20
21
 
@@ -35,19 +36,6 @@ Declared in `package.json`:
35
36
  - `editcodewithai` - Code editing utilities
36
37
  - VZCode utilities: `../types.js`, `../ot.js`, `../randomId.js`, etc.
37
38
 
38
- ## Future Plans
39
-
40
- This module will eventually be:
41
-
42
- 1. Decoupled from VZCode-specific types and utilities
43
- 2. Published as `@vizhub/llm-streaming-server` on npm
44
- 3. Made framework-agnostic (can work with Express, Fastify, etc.)
45
- 4. Fully documented with usage examples
46
-
47
- This module is being extracted into a standalone package
48
- (`@vizhub/llm-streaming-server`). Follow the conventions in
49
- `../llm-streaming-ui/README.md` when contributing.
50
-
51
39
  ## Usage (Current)
52
40
 
53
41
  Currently, this module is imported by `src/server/aiChatHandler/index.ts`: