@duct-sdk/sdk 0.3.3 → 0.3.5
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/CHANGELOG.md +13 -0
- package/dist/adapters/react/shell.js +54 -35
- package/dist/cli/generators/config.js +1 -0
- package/dist/cli/index.js +12 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
Public release notes for the Duct SDK. Versioning follows [semver](https://semver.org).
|
|
4
4
|
|
|
5
|
+
## [0.3.5] — 2026-06-10
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **Explicit drag handles** — `DuctShell` launcher and open panel no longer treat the whole chrome as a drag target. A small grab handle is the only drag surface; the bubble uses a normal click to open and the panel header stays fully interactive.
|
|
9
|
+
|
|
10
|
+
## [0.3.4] — 2026-06-10
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- **`duct push` schema validation** — validates the loaded manifest against `DuctConfigSchema` before upload. Catches missing `product.baseUrl` and other required fields instead of pushing a broken manifest that fails at action-invoke time.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- **Manual mode template** — `duct init --manual` product block now documents optional `apiBaseUrl` (action proxy target; defaults to `baseUrl`).
|
|
17
|
+
|
|
5
18
|
## [0.3.3] — 2026-06-09
|
|
6
19
|
|
|
7
20
|
### Fixed
|
|
@@ -62,6 +62,31 @@ function clampBubble(x, y) {
|
|
|
62
62
|
y: Math.min(Math.max(margin, y), Math.max(margin, maxY)),
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
+
/** Small grab handle — drag only starts from here, not the whole shell chrome. */
|
|
66
|
+
function ShellDragHandle({ onPointerDown, isDragging, isDark, title = "Drag", style, }) {
|
|
67
|
+
const barColor = isDark ? "rgba(255,255,255,0.28)" : "rgba(12,11,9,0.20)";
|
|
68
|
+
return (_jsx("div", { role: "button", tabIndex: -1, onPointerDown: onPointerDown, title: title, "aria-label": title, style: {
|
|
69
|
+
position: "absolute",
|
|
70
|
+
top: 6,
|
|
71
|
+
left: "50%",
|
|
72
|
+
transform: "translateX(-50%)",
|
|
73
|
+
zIndex: 2,
|
|
74
|
+
width: 44,
|
|
75
|
+
height: 22,
|
|
76
|
+
display: "flex",
|
|
77
|
+
alignItems: "center",
|
|
78
|
+
justifyContent: "center",
|
|
79
|
+
cursor: isDragging ? "grabbing" : "grab",
|
|
80
|
+
touchAction: "none",
|
|
81
|
+
borderRadius: 11,
|
|
82
|
+
...style,
|
|
83
|
+
}, children: _jsx("div", { "aria-hidden": "true", style: {
|
|
84
|
+
width: 32,
|
|
85
|
+
height: 4,
|
|
86
|
+
borderRadius: 2,
|
|
87
|
+
backgroundColor: barColor,
|
|
88
|
+
} }) }));
|
|
89
|
+
}
|
|
65
90
|
/** Keep a dragged panel visible inside the viewport. */
|
|
66
91
|
function clampPanel(x, y, width, height) {
|
|
67
92
|
if (typeof window === "undefined")
|
|
@@ -358,11 +383,7 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
358
383
|
setIsDragging(false);
|
|
359
384
|
const st = dragState.current;
|
|
360
385
|
dragState.current = null;
|
|
361
|
-
if (st
|
|
362
|
-
// Treat as a click → open the panel.
|
|
363
|
-
openPanel();
|
|
364
|
-
}
|
|
365
|
-
else if (bubblePos) {
|
|
386
|
+
if (st?.moved) {
|
|
366
387
|
try {
|
|
367
388
|
window.localStorage.setItem(`duct-shell-pos:${shellId}`, JSON.stringify(bubblePos));
|
|
368
389
|
}
|
|
@@ -378,7 +399,7 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
378
399
|
window.removeEventListener("pointermove", onMove);
|
|
379
400
|
window.removeEventListener("pointerup", onUp);
|
|
380
401
|
};
|
|
381
|
-
}, [isDragging, bubblePos,
|
|
402
|
+
}, [isDragging, bubblePos, shellId]);
|
|
382
403
|
// Free-drag the open panel using a top handle. The handle sits outside the
|
|
383
404
|
// iframe so dragging works without relying on iframe internals.
|
|
384
405
|
useEffect(() => {
|
|
@@ -487,48 +508,46 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
487
508
|
const bubbleShadow = isDarkChrome
|
|
488
509
|
? "0 4px 16px rgba(0,0,0,0.40), 0 2px 8px rgba(0,0,0,0.20)"
|
|
489
510
|
: "0 4px 16px rgba(12,11,9,0.16), 0 2px 8px rgba(12,11,9,0.08)";
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
height: `${BUBBLE_SIZE}px`,
|
|
511
|
+
const bubbleLauncherStyle = {
|
|
512
|
+
position: "relative",
|
|
513
|
+
width: "100%",
|
|
514
|
+
height: "100%",
|
|
495
515
|
borderRadius: "50%",
|
|
496
516
|
border: bubbleBorder,
|
|
497
|
-
cursor:
|
|
517
|
+
cursor: "pointer",
|
|
498
518
|
display: "flex",
|
|
499
519
|
alignItems: "center",
|
|
500
520
|
justifyContent: "center",
|
|
501
521
|
backgroundColor: bubbleBg,
|
|
502
522
|
boxShadow: bubbleShadow,
|
|
503
523
|
padding: 0,
|
|
504
|
-
touchAction: "none",
|
|
505
524
|
transition: isDragging ? "none" : "transform 150ms ease, box-shadow 150ms ease",
|
|
506
525
|
};
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
526
|
+
const bubbleIcon = !iconLoadFailed ? (_jsx("img", { src: currentIconSrc, alt: "Duct", width: 30, height: 30, draggable: false, onError: handleIconError, style: { width: "30px", height: "30px", objectFit: "contain", pointerEvents: "none" } })) : (_jsx("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M18 12c0-3.3-2.2-5.5-5.5-5.5C9 6.5 7 8.7 7 12s2 5.5 5.5 5.5c2 0 3.6-.8 4.6-2.2l-2.2-1.6c-.6.8-1.4 1.3-2.4 1.3-1.6 0-2.8-1.2-2.8-3s1.2-3 2.8-3c1 0 1.8.5 2.3 1.3L18 12z", fill: "#E8622A" }) }));
|
|
527
|
+
return (_jsxs(_Fragment, { children: [!panelOpen && (draggable ? (_jsxs("div", { style: {
|
|
528
|
+
...bubbleStyle,
|
|
529
|
+
position: "fixed",
|
|
530
|
+
zIndex: 9999,
|
|
531
|
+
width: `${BUBBLE_SIZE}px`,
|
|
532
|
+
height: `${BUBBLE_SIZE}px`,
|
|
533
|
+
}, className: className, children: [_jsx(ShellDragHandle, { onPointerDown: onBubblePointerDown, isDragging: isDragging, isDark: isDarkChrome, title: "Drag launcher", style: { top: -4, zIndex: 3 } }), _jsx("button", { type: "button", style: bubbleLauncherStyle, onClick: () => openPanel(), "aria-label": "Open Duct Shell", onMouseEnter: (e) => {
|
|
534
|
+
if (isDragging)
|
|
535
|
+
return;
|
|
536
|
+
e.currentTarget.style.transform = "scale(1.07)";
|
|
537
|
+
}, onMouseLeave: (e) => {
|
|
538
|
+
e.currentTarget.style.transform = "scale(1)";
|
|
539
|
+
}, children: bubbleIcon })] })) : (_jsx("button", { type: "button", style: {
|
|
540
|
+
...bubbleStyle,
|
|
541
|
+
...bubbleLauncherStyle,
|
|
542
|
+
position: "fixed",
|
|
543
|
+
zIndex: 9999,
|
|
544
|
+
width: `${BUBBLE_SIZE}px`,
|
|
545
|
+
height: `${BUBBLE_SIZE}px`,
|
|
546
|
+
}, onClick: () => openPanel(), "aria-label": "Open Duct Shell", className: className, onMouseEnter: (e) => {
|
|
518
547
|
e.currentTarget.style.transform = "scale(1.07)";
|
|
519
548
|
}, onMouseLeave: (e) => {
|
|
520
549
|
e.currentTarget.style.transform = "scale(1)";
|
|
521
|
-
}, children:
|
|
522
|
-
position: "absolute",
|
|
523
|
-
top: 0,
|
|
524
|
-
left: 0,
|
|
525
|
-
// Leave the header control cluster (+ New, close) clickable inside the iframe.
|
|
526
|
-
right: 140,
|
|
527
|
-
height: 44,
|
|
528
|
-
zIndex: 2,
|
|
529
|
-
cursor: isPanelDragging ? "grabbing" : "grab",
|
|
530
|
-
touchAction: "none",
|
|
531
|
-
} }), _jsx("iframe", { ref: iframeRef, src: shellUrl, title: "Duct Shell", sandbox: "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox", allow: "clipboard-write", referrerPolicy: "no-referrer-when-downgrade", style: {
|
|
550
|
+
}, children: bubbleIcon }))), _jsxs("div", { ref: panelRef, style: panelStyle, "data-duct-shell": shellId, children: [draggable && (_jsx(ShellDragHandle, { onPointerDown: onPanelPointerDown, isDragging: isPanelDragging, isDark: isDarkChrome, title: "Drag Duct Shell" })), _jsx("iframe", { ref: iframeRef, src: shellUrl, title: "Duct Shell", sandbox: "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox", allow: "clipboard-write", referrerPolicy: "no-referrer-when-downgrade", style: {
|
|
532
551
|
width: "100%",
|
|
533
552
|
height: "100%",
|
|
534
553
|
border: "none",
|
|
@@ -223,6 +223,7 @@ export default defineDuctConfig({
|
|
|
223
223
|
name: ${JSON.stringify(productName)},
|
|
224
224
|
description: ${JSON.stringify(`${productName} — AI-powered interaction shell`)},
|
|
225
225
|
baseUrl: ${JSON.stringify(baseUrl)},${logoLine}
|
|
226
|
+
// apiBaseUrl: optional separate origin for action HTTP proxy (defaults to baseUrl)
|
|
226
227
|
},
|
|
227
228
|
|
|
228
229
|
// Authentication — detected: ${authStrategy}
|
package/dist/cli/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import * as os from "os";
|
|
|
15
15
|
import * as vm from "node:vm";
|
|
16
16
|
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
17
17
|
import { readFileSync } from "fs";
|
|
18
|
+
import { DuctConfigSchema } from "../core/config.js";
|
|
18
19
|
// ----------------------------------------------------------------
|
|
19
20
|
// Load all standard .env files in dotenv priority order
|
|
20
21
|
// Priority (last-loaded wins when key already set by earlier file):
|
|
@@ -423,6 +424,17 @@ program
|
|
|
423
424
|
process.exit(1);
|
|
424
425
|
}
|
|
425
426
|
spinner.succeed("Config loaded");
|
|
427
|
+
const validation = DuctConfigSchema.safeParse(config);
|
|
428
|
+
if (!validation.success) {
|
|
429
|
+
spinner.fail("Config validation failed");
|
|
430
|
+
console.log(chalk.red("\nInvalid duct.config.ts:\n"));
|
|
431
|
+
for (const err of validation.error.errors) {
|
|
432
|
+
console.log(chalk.red(` • [${err.path.join(".")}] ${err.message}`));
|
|
433
|
+
}
|
|
434
|
+
console.log(chalk.gray("\nSee /docs/configuration for the required manifest shape.\n"));
|
|
435
|
+
process.exit(1);
|
|
436
|
+
}
|
|
437
|
+
config = validation.data;
|
|
426
438
|
// Warn on weak DUCT_SECRET_KEY — must be ≥ 32 chars for adequate HMAC entropy
|
|
427
439
|
const secretKey = process.env["DUCT_SECRET_KEY"];
|
|
428
440
|
if (secretKey && secretKey.length < 32) {
|