@agent-native/core 0.114.10 → 0.114.12
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/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +12 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/client/extensions/EmbeddedExtension.tsx +89 -1
- package/corpus/core/src/extensions/actions.ts +219 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +19 -0
- package/corpus/templates/clips/app/components/player/video-player.tsx +48 -0
- package/corpus/templates/clips/app/lib/fmp4.ts +26 -4
- package/corpus/templates/clips/app/lib/mse-video-loader.ts +13 -2
- package/corpus/templates/clips/changelog/2026-07-20-rewind-capture-status.md +6 -0
- package/corpus/templates/clips/desktop/src/app.tsx +81 -71
- package/corpus/templates/clips/desktop/src/lib/rewind-status.ts +103 -0
- package/corpus/templates/clips/desktop/src/styles.css +10 -0
- package/dist/client/extensions/EmbeddedExtension.d.ts.map +1 -1
- package/dist/client/extensions/EmbeddedExtension.js +65 -1
- package/dist/client/extensions/EmbeddedExtension.js.map +1 -1
- package/dist/extensions/actions.d.ts.map +1 -1
- package/dist/extensions/actions.js +193 -1
- package/dist/extensions/actions.js.map +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/templates/workspace-core/.agents/skills/extensions/SKILL.md +19 -0
- package/package.json +1 -1
- package/src/client/extensions/EmbeddedExtension.tsx +89 -1
- package/src/extensions/actions.ts +219 -0
- package/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +19 -0
|
@@ -86,6 +86,7 @@ import {
|
|
|
86
86
|
type RecorderStopResult,
|
|
87
87
|
} from "./lib/recorder";
|
|
88
88
|
import { REWIND_AGENT_PROMPT } from "./lib/rewind-agent-prompt";
|
|
89
|
+
import { getRewindStatusPresentation } from "./lib/rewind-status";
|
|
89
90
|
import {
|
|
90
91
|
loadBool,
|
|
91
92
|
loadString,
|
|
@@ -893,6 +894,7 @@ export function App() {
|
|
|
893
894
|
const [homeScreenMemoryStatus, setHomeScreenMemoryStatus] =
|
|
894
895
|
useState<ScreenMemoryStatus | null>(null);
|
|
895
896
|
const [homeScreenMemoryBusy, setHomeScreenMemoryBusy] = useState(false);
|
|
897
|
+
const homeScreenMemoryRefreshVersionRef = useRef(0);
|
|
896
898
|
const [rewindAgentPromptCopied, setRewindAgentPromptCopied] = useState(false);
|
|
897
899
|
const [agentHandoff, setAgentHandoff] =
|
|
898
900
|
useState<RewindAgentHandoffRequest | null>(null);
|
|
@@ -946,26 +948,54 @@ export function App() {
|
|
|
946
948
|
const isRecording = recorder !== null;
|
|
947
949
|
// Whether the popover window is shown; driven by the visibility effect below.
|
|
948
950
|
const [popoverVisible, setPopoverVisible] = useState(false);
|
|
951
|
+
const homeRewindPresentation = getRewindStatusPresentation({
|
|
952
|
+
status: homeScreenMemoryStatus,
|
|
953
|
+
config: featureConfig?.screenMemory ?? DEFAULT_SCREEN_MEMORY_CONFIG,
|
|
954
|
+
clipRecordingActive: isRecording || recordingFlowActive,
|
|
955
|
+
});
|
|
956
|
+
const refreshHomeScreenMemoryStatus = useCallback(() => {
|
|
957
|
+
const version = ++homeScreenMemoryRefreshVersionRef.current;
|
|
958
|
+
invoke<ScreenMemoryStatus>("screen_memory_status")
|
|
959
|
+
.then((status) => {
|
|
960
|
+
if (version === homeScreenMemoryRefreshVersionRef.current) {
|
|
961
|
+
setHomeScreenMemoryStatus(status);
|
|
962
|
+
}
|
|
963
|
+
})
|
|
964
|
+
.catch(() => {});
|
|
965
|
+
}, []);
|
|
949
966
|
useEffect(() => {
|
|
950
967
|
if (featureConfig?.screenMemory?.enabled !== true) {
|
|
968
|
+
homeScreenMemoryRefreshVersionRef.current += 1;
|
|
951
969
|
setHomeScreenMemoryStatus(null);
|
|
952
970
|
return;
|
|
953
971
|
}
|
|
954
972
|
let cancelled = false;
|
|
955
973
|
const refresh = () => {
|
|
956
|
-
|
|
957
|
-
.then((status) => {
|
|
958
|
-
if (!cancelled) setHomeScreenMemoryStatus(status);
|
|
959
|
-
})
|
|
960
|
-
.catch(() => {});
|
|
974
|
+
if (!cancelled) refreshHomeScreenMemoryStatus();
|
|
961
975
|
};
|
|
962
976
|
refresh();
|
|
963
977
|
const timer = window.setInterval(refresh, popoverVisible ? 5_000 : 30_000);
|
|
978
|
+
let unlisten: (() => void) | undefined;
|
|
979
|
+
listen("clips:screen-memory-changed", refresh)
|
|
980
|
+
.then((stopListening) => {
|
|
981
|
+
if (cancelled) {
|
|
982
|
+
stopListening();
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
unlisten = stopListening;
|
|
986
|
+
})
|
|
987
|
+
.catch(() => {});
|
|
964
988
|
return () => {
|
|
965
989
|
cancelled = true;
|
|
990
|
+
homeScreenMemoryRefreshVersionRef.current += 1;
|
|
966
991
|
window.clearInterval(timer);
|
|
992
|
+
unlisten?.();
|
|
967
993
|
};
|
|
968
|
-
}, [
|
|
994
|
+
}, [
|
|
995
|
+
featureConfig?.screenMemory?.enabled,
|
|
996
|
+
popoverVisible,
|
|
997
|
+
refreshHomeScreenMemoryStatus,
|
|
998
|
+
]);
|
|
969
999
|
const recordShortcutHandlerRef = useRef<() => void>(() => {});
|
|
970
1000
|
// Mirrors `bubbleActive` (assigned below once it is computed) so device
|
|
971
1001
|
// probes can synchronously tell whether the camera bubble owns the grant.
|
|
@@ -3154,8 +3184,11 @@ export function App() {
|
|
|
3154
3184
|
},
|
|
3155
3185
|
},
|
|
3156
3186
|
});
|
|
3157
|
-
|
|
3158
|
-
|
|
3187
|
+
// The native producer can take a moment to finish pausing. Do not keep
|
|
3188
|
+
// the Home switch locked while that status request waits; the existing
|
|
3189
|
+
// change event and bounded poll will reconcile it, and this best-effort
|
|
3190
|
+
// refresh can do the same without blocking the next resume action.
|
|
3191
|
+
refreshHomeScreenMemoryStatus();
|
|
3159
3192
|
} catch (err) {
|
|
3160
3193
|
console.error(
|
|
3161
3194
|
"[clips-tray] update Rewind remembering state failed:",
|
|
@@ -3633,34 +3666,13 @@ export function App() {
|
|
|
3633
3666
|
<section className="rewind-home-card" aria-label="Rewind status">
|
|
3634
3667
|
<div className="rewind-home-status">
|
|
3635
3668
|
<span
|
|
3636
|
-
className={`rewind-home-dot ${
|
|
3637
|
-
featureConfig?.screenMemory?.enabled === true &&
|
|
3638
|
-
featureConfig.screenMemory.paused !== true &&
|
|
3639
|
-
homeScreenMemoryStatus?.state === "recording"
|
|
3640
|
-
? "is-live"
|
|
3641
|
-
: ""
|
|
3642
|
-
}`}
|
|
3669
|
+
className={`rewind-home-dot ${homeRewindPresentation.isLive ? "is-live" : ""}`}
|
|
3643
3670
|
/>
|
|
3644
3671
|
<div>
|
|
3645
|
-
<strong>
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
? "Rewind is paused"
|
|
3650
|
-
: homeScreenMemoryStatus?.exclusionActive
|
|
3651
|
-
? "Rewind is protecting a private moment"
|
|
3652
|
-
: "Rewind is remembering"}
|
|
3653
|
-
</strong>
|
|
3654
|
-
{featureConfig?.screenMemory?.enabled !== true ||
|
|
3655
|
-
featureConfig.screenMemory.paused ||
|
|
3656
|
-
homeScreenMemoryStatus?.exclusionActive ? (
|
|
3657
|
-
<p>
|
|
3658
|
-
{featureConfig?.screenMemory?.enabled !== true
|
|
3659
|
-
? "Private memory for moments you may need later."
|
|
3660
|
-
: featureConfig.screenMemory.paused
|
|
3661
|
-
? "Existing local memory is still available."
|
|
3662
|
-
: "An excluded app is being skipped."}
|
|
3663
|
-
</p>
|
|
3672
|
+
<strong>{homeRewindPresentation.title}</strong>
|
|
3673
|
+
{!homeRewindPresentation.isLive ||
|
|
3674
|
+
homeRewindPresentation.hasError ? (
|
|
3675
|
+
<p>{homeRewindPresentation.detail}</p>
|
|
3664
3676
|
) : null}
|
|
3665
3677
|
</div>
|
|
3666
3678
|
<div className="rewind-home-controls">
|
|
@@ -4941,6 +4953,7 @@ function Setup({
|
|
|
4941
4953
|
);
|
|
4942
4954
|
const [screenMemoryStatus, setScreenMemoryStatus] =
|
|
4943
4955
|
useState<ScreenMemoryStatus | null>(null);
|
|
4956
|
+
const screenMemoryStatusRefreshVersionRef = useRef(0);
|
|
4944
4957
|
const [screenMemoryMessage, setScreenMemoryMessage] = useState<{
|
|
4945
4958
|
kind: "ok" | "error";
|
|
4946
4959
|
text: string;
|
|
@@ -4976,7 +4989,11 @@ function Setup({
|
|
|
4976
4989
|
(sum, segment) => sum + segment.bytes,
|
|
4977
4990
|
0,
|
|
4978
4991
|
);
|
|
4979
|
-
const
|
|
4992
|
+
const rewindStatusPresentation = getRewindStatusPresentation({
|
|
4993
|
+
status: screenMemoryStatus,
|
|
4994
|
+
config: screenMemory,
|
|
4995
|
+
clipRecordingActive: recordingActive,
|
|
4996
|
+
});
|
|
4980
4997
|
const captureControlsLocked = recordingActive;
|
|
4981
4998
|
|
|
4982
4999
|
useEffect(() => {
|
|
@@ -5172,11 +5189,16 @@ function Setup({
|
|
|
5172
5189
|
}
|
|
5173
5190
|
}
|
|
5174
5191
|
|
|
5175
|
-
|
|
5192
|
+
const refreshScreenMemoryStatus = useCallback(() => {
|
|
5193
|
+
const version = ++screenMemoryStatusRefreshVersionRef.current;
|
|
5176
5194
|
invoke<ScreenMemoryStatus>("screen_memory_status")
|
|
5177
|
-
.then(
|
|
5195
|
+
.then((status) => {
|
|
5196
|
+
if (version === screenMemoryStatusRefreshVersionRef.current) {
|
|
5197
|
+
setScreenMemoryStatus(status);
|
|
5198
|
+
}
|
|
5199
|
+
})
|
|
5178
5200
|
.catch(() => {});
|
|
5179
|
-
}
|
|
5201
|
+
}, []);
|
|
5180
5202
|
|
|
5181
5203
|
function refreshRewindEgressLog() {
|
|
5182
5204
|
invoke<RewindEgressEvent[]>("rewind_list_evidence_egress", { limit: 20 })
|
|
@@ -5257,6 +5279,7 @@ function Setup({
|
|
|
5257
5279
|
const status = await invoke<ScreenMemoryStatus>(
|
|
5258
5280
|
"screen_memory_delete_all",
|
|
5259
5281
|
);
|
|
5282
|
+
screenMemoryStatusRefreshVersionRef.current += 1;
|
|
5260
5283
|
setScreenMemoryStatus(status);
|
|
5261
5284
|
setScreenMemoryMessage({ kind: "ok", text: "Rewind cleared." });
|
|
5262
5285
|
} catch (err) {
|
|
@@ -5424,13 +5447,10 @@ function Setup({
|
|
|
5424
5447
|
useEffect(() => {
|
|
5425
5448
|
let cancelled = false;
|
|
5426
5449
|
const refresh = () => {
|
|
5427
|
-
|
|
5428
|
-
.then((status) => {
|
|
5429
|
-
if (!cancelled) setScreenMemoryStatus(status);
|
|
5430
|
-
})
|
|
5431
|
-
.catch(() => {});
|
|
5450
|
+
if (!cancelled) refreshScreenMemoryStatus();
|
|
5432
5451
|
};
|
|
5433
5452
|
refresh();
|
|
5453
|
+
const timer = window.setInterval(refresh, 5_000);
|
|
5434
5454
|
const unlistens: Array<() => void> = [];
|
|
5435
5455
|
const track = (p: Promise<() => void>) => {
|
|
5436
5456
|
p.then((u) => {
|
|
@@ -5448,6 +5468,8 @@ function Setup({
|
|
|
5448
5468
|
track(listen("clips:screen-memory-changed", refresh));
|
|
5449
5469
|
return () => {
|
|
5450
5470
|
cancelled = true;
|
|
5471
|
+
screenMemoryStatusRefreshVersionRef.current += 1;
|
|
5472
|
+
window.clearInterval(timer);
|
|
5451
5473
|
unlistens.forEach((u) => {
|
|
5452
5474
|
try {
|
|
5453
5475
|
u();
|
|
@@ -5456,7 +5478,7 @@ function Setup({
|
|
|
5456
5478
|
}
|
|
5457
5479
|
});
|
|
5458
5480
|
};
|
|
5459
|
-
}, []);
|
|
5481
|
+
}, [refreshScreenMemoryStatus]);
|
|
5460
5482
|
|
|
5461
5483
|
// Load model status on mount and keep it current via events.
|
|
5462
5484
|
useEffect(() => {
|
|
@@ -6044,17 +6066,16 @@ function Setup({
|
|
|
6044
6066
|
</div>
|
|
6045
6067
|
<div className="rewind-settings-status">
|
|
6046
6068
|
<span
|
|
6047
|
-
className={`rewind-home-dot ${
|
|
6069
|
+
className={`rewind-home-dot ${rewindStatusPresentation.isLive ? "is-live" : ""}`}
|
|
6048
6070
|
/>
|
|
6049
|
-
<span>
|
|
6050
|
-
{
|
|
6051
|
-
|
|
6052
|
-
|
|
6071
|
+
<span className="rewind-settings-status-copy">
|
|
6072
|
+
<strong>{rewindStatusPresentation.title}</strong>
|
|
6073
|
+
<span>
|
|
6074
|
+
{rewindStatusPresentation.kind === "recording" &&
|
|
6075
|
+
!rewindStatusPresentation.hasError
|
|
6053
6076
|
? `${screenMemorySegments.length} retained segment${screenMemorySegments.length === 1 ? "" : "s"} · ${formatStorageBytes(screenMemoryTotalBytes)}`
|
|
6054
|
-
:
|
|
6055
|
-
|
|
6056
|
-
: screenMemoryStatus?.lastError ||
|
|
6057
|
-
"Waiting for screen-recording permission."}
|
|
6077
|
+
: rewindStatusPresentation.detail}
|
|
6078
|
+
</span>
|
|
6058
6079
|
</span>
|
|
6059
6080
|
</div>
|
|
6060
6081
|
<div className="setup-section-heading">Privacy</div>
|
|
@@ -6550,17 +6571,11 @@ function Setup({
|
|
|
6550
6571
|
<div className="setup-section rewind-settings-entry">
|
|
6551
6572
|
<div className="rewind-settings-entry-main">
|
|
6552
6573
|
<span
|
|
6553
|
-
className={`rewind-home-dot ${
|
|
6574
|
+
className={`rewind-home-dot ${rewindStatusPresentation.isLive ? "is-live" : ""}`}
|
|
6554
6575
|
/>
|
|
6555
6576
|
<div>
|
|
6556
6577
|
<strong>Rewind</strong>
|
|
6557
|
-
<p className="setup-hint">
|
|
6558
|
-
{!screenMemory.enabled
|
|
6559
|
-
? "Off"
|
|
6560
|
-
: screenMemory.paused
|
|
6561
|
-
? "Paused · existing local memory is still available"
|
|
6562
|
-
: "Remembering locally"}
|
|
6563
|
-
</p>
|
|
6578
|
+
<p className="setup-hint">{rewindStatusPresentation.title}</p>
|
|
6564
6579
|
</div>
|
|
6565
6580
|
</div>
|
|
6566
6581
|
<button type="button" className="secondary" onClick={onOpenRewind}>
|
|
@@ -6738,21 +6753,16 @@ function Setup({
|
|
|
6738
6753
|
bundle ID cannot be detected.
|
|
6739
6754
|
</p>
|
|
6740
6755
|
<div className="whisper-status">
|
|
6741
|
-
{
|
|
6756
|
+
{rewindStatusPresentation.isLive ? (
|
|
6742
6757
|
<IconCircleCheck size={13} className="whisper-status-icon" />
|
|
6743
6758
|
) : (
|
|
6744
6759
|
<IconAlertTriangle size={13} className="whisper-status-icon" />
|
|
6745
6760
|
)}
|
|
6746
6761
|
<span>
|
|
6747
|
-
{
|
|
6748
|
-
|
|
6749
|
-
:
|
|
6750
|
-
|
|
6751
|
-
: screenMemory.paused
|
|
6752
|
-
? "Capture paused. Existing local coverage remains available."
|
|
6753
|
-
: screenMemoryStatus?.lastError
|
|
6754
|
-
? screenMemoryStatus.lastError
|
|
6755
|
-
: "Capture status is waiting for screen-recording permission."}
|
|
6762
|
+
{rewindStatusPresentation.kind === "recording" &&
|
|
6763
|
+
!rewindStatusPresentation.hasError
|
|
6764
|
+
? `Rewind is retaining local coverage: ${screenMemorySegments.length} segment${screenMemorySegments.length === 1 ? "" : "s"}, ${formatStorageBytes(screenMemoryTotalBytes)}.`
|
|
6765
|
+
: rewindStatusPresentation.detail}
|
|
6756
6766
|
</span>
|
|
6757
6767
|
</div>
|
|
6758
6768
|
{screenMemorySegments[0] ? (
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ScreenMemoryConfig, ScreenMemoryStatus } from "../shared/config";
|
|
2
|
+
|
|
3
|
+
export type RewindPresentationKind =
|
|
4
|
+
| "off"
|
|
5
|
+
| "paused"
|
|
6
|
+
| "recording"
|
|
7
|
+
| "excluded"
|
|
8
|
+
| "idle"
|
|
9
|
+
| "error"
|
|
10
|
+
| "unavailable";
|
|
11
|
+
|
|
12
|
+
export interface RewindStatusPresentation {
|
|
13
|
+
kind: RewindPresentationKind;
|
|
14
|
+
title: string;
|
|
15
|
+
detail: string;
|
|
16
|
+
isLive: boolean;
|
|
17
|
+
hasError: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getRewindStatusPresentation({
|
|
21
|
+
status,
|
|
22
|
+
config,
|
|
23
|
+
clipRecordingActive = false,
|
|
24
|
+
}: {
|
|
25
|
+
status: ScreenMemoryStatus | null;
|
|
26
|
+
config: ScreenMemoryConfig;
|
|
27
|
+
clipRecordingActive?: boolean;
|
|
28
|
+
}): RewindStatusPresentation {
|
|
29
|
+
const runtimeConfig = status?.config ?? config;
|
|
30
|
+
|
|
31
|
+
if (!runtimeConfig.enabled || status?.state === "disabled") {
|
|
32
|
+
return {
|
|
33
|
+
kind: "off",
|
|
34
|
+
title: "Rewind is off",
|
|
35
|
+
detail: "Private memory for moments you may need later.",
|
|
36
|
+
isLive: false,
|
|
37
|
+
hasError: false,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (runtimeConfig.paused || status?.state === "paused") {
|
|
42
|
+
return {
|
|
43
|
+
kind: "paused",
|
|
44
|
+
title: "Rewind is paused",
|
|
45
|
+
detail: "Existing local memory is still available.",
|
|
46
|
+
isLive: false,
|
|
47
|
+
hasError: false,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (status?.exclusionActive) {
|
|
52
|
+
return {
|
|
53
|
+
kind: "excluded",
|
|
54
|
+
title: "Rewind is protecting a private moment",
|
|
55
|
+
detail: status.coverage || "An excluded app is being skipped.",
|
|
56
|
+
isLive: false,
|
|
57
|
+
hasError: false,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (status?.available === false) {
|
|
62
|
+
return {
|
|
63
|
+
kind: "unavailable",
|
|
64
|
+
title: "Rewind is unavailable",
|
|
65
|
+
detail: "Rewind capture is not available on this device.",
|
|
66
|
+
isLive: false,
|
|
67
|
+
hasError: false,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (status?.state === "recording") {
|
|
72
|
+
return {
|
|
73
|
+
kind: "recording",
|
|
74
|
+
title: "Rewind is remembering",
|
|
75
|
+
detail:
|
|
76
|
+
status.lastError ||
|
|
77
|
+
status.coverage ||
|
|
78
|
+
"Rewind is retaining local coverage.",
|
|
79
|
+
isLive: true,
|
|
80
|
+
hasError: Boolean(status.lastError),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (status?.lastError) {
|
|
85
|
+
return {
|
|
86
|
+
kind: "error",
|
|
87
|
+
title: "Rewind needs attention",
|
|
88
|
+
detail: status.lastError,
|
|
89
|
+
isLive: false,
|
|
90
|
+
hasError: true,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
kind: "idle",
|
|
96
|
+
title: "Rewind is enabled but not currently capturing",
|
|
97
|
+
detail: clipRecordingActive
|
|
98
|
+
? "Rewind will resume when this Clip ends."
|
|
99
|
+
: "No new local coverage is being retained right now.",
|
|
100
|
+
isLive: false,
|
|
101
|
+
hasError: false,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -1707,6 +1707,16 @@ body[data-clips-route="recording-pill"] #root {
|
|
|
1707
1707
|
margin: -4px 0 0;
|
|
1708
1708
|
}
|
|
1709
1709
|
|
|
1710
|
+
.rewind-settings-status-copy {
|
|
1711
|
+
display: grid;
|
|
1712
|
+
gap: 1px;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
.rewind-settings-status-copy strong {
|
|
1716
|
+
color: var(--fg);
|
|
1717
|
+
font-weight: 600;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1710
1720
|
.rewind-agent-row {
|
|
1711
1721
|
border-bottom: none;
|
|
1712
1722
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedExtension.d.ts","sourceRoot":"","sources":["../../../src/client/extensions/EmbeddedExtension.tsx"],"names":[],"mappings":"AAwFA;;;;;;;;;;GAUG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GAClD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUzB;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB;2CACuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf;iDAC6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzC,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;qEAEiE;IACjE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;4EAGwE;IACxE,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,MAAM,EACN,OAAO,EACP,SAAS,EACT,aAAkB,EAClB,OAAO,EACP,aAAa,GACd,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"EmbeddedExtension.d.ts","sourceRoot":"","sources":["../../../src/client/extensions/EmbeddedExtension.tsx"],"names":[],"mappings":"AAwFA;;;;;;;;;;GAUG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GAClD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUzB;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB;2CACuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf;iDAC6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzC,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;qEAEiE;IACjE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;4EAGwE;IACxE,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,MAAM,EACN,OAAO,EACP,SAAS,EACT,aAAkB,EAClB,OAAO,EACP,aAAa,GACd,EAAE,sBAAsB,sCAsZxB"}
|
|
@@ -102,6 +102,7 @@ export function EmbeddedExtension({ extensionId, slotId, context, className, ini
|
|
|
102
102
|
// originates inside the same sandboxed realm as user code) and must be
|
|
103
103
|
// ignored so a viewer cannot self-escalate to owner.
|
|
104
104
|
const bindingLatchedRef = useRef(false);
|
|
105
|
+
const extensionRef = useRef(null);
|
|
105
106
|
useEffect(() => {
|
|
106
107
|
setIsDark(document.documentElement.classList.contains("dark"));
|
|
107
108
|
const observer = new MutationObserver(() => {
|
|
@@ -131,6 +132,7 @@ export function EmbeddedExtension({ extensionId, slotId, context, className, ini
|
|
|
131
132
|
retry: shouldRetryExtensionLoad,
|
|
132
133
|
retryDelay: (attempt) => Math.min(1000 * 2 ** attempt, 4000),
|
|
133
134
|
});
|
|
135
|
+
extensionRef.current = extension ?? null;
|
|
134
136
|
// Notify the host once when the extension can't be loaded for this viewer so
|
|
135
137
|
// it can show a fallback instead of a blank panel.
|
|
136
138
|
const onUnavailableRef = useRef(onUnavailable);
|
|
@@ -238,6 +240,68 @@ export function EmbeddedExtension({ extensionId, slotId, context, className, ini
|
|
|
238
240
|
});
|
|
239
241
|
return;
|
|
240
242
|
}
|
|
243
|
+
if (message.type === "agent-native-extension-error-fix") {
|
|
244
|
+
const name = extensionRef.current?.name ?? extensionId;
|
|
245
|
+
const errors = Array.isArray(message.errors)
|
|
246
|
+
? message.errors
|
|
247
|
+
: [];
|
|
248
|
+
const errorDetails = Array.isArray(message.errorDetails)
|
|
249
|
+
? message.errorDetails
|
|
250
|
+
: [];
|
|
251
|
+
const consoleLogs = Array.isArray(message.consoleLogs)
|
|
252
|
+
? message.consoleLogs
|
|
253
|
+
: [];
|
|
254
|
+
const networkLogs = Array.isArray(message.networkLogs)
|
|
255
|
+
? message.networkLogs
|
|
256
|
+
: [];
|
|
257
|
+
const detailedTrace = errorDetails
|
|
258
|
+
.filter((e) => e && typeof e === "object")
|
|
259
|
+
.map((e) => {
|
|
260
|
+
const msg = typeof e.message === "string" ? e.message : String(e.message);
|
|
261
|
+
return typeof e.stack === "string" ? `${msg}\n${e.stack}` : msg;
|
|
262
|
+
})
|
|
263
|
+
.join("\n\n");
|
|
264
|
+
// Force a fresh read from the server, same as ExtensionViewer's fix
|
|
265
|
+
// flow — the query cache may hold the agent's previous (broken) turn.
|
|
266
|
+
let freshContent;
|
|
267
|
+
try {
|
|
268
|
+
const res = await fetch(agentNativePath(`/_agent-native/extensions/${extensionId}`), { cache: "no-store" });
|
|
269
|
+
if (res.ok) {
|
|
270
|
+
const fresh = (await res.json());
|
|
271
|
+
freshContent =
|
|
272
|
+
typeof fresh?.content === "string" ? fresh.content : undefined;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
// Fall through with no snapshot — agent can still re-read via get-extension.
|
|
277
|
+
}
|
|
278
|
+
const contextParts = [
|
|
279
|
+
`The user is viewing a dashboard panel embedding extension "${name}" (id: ${extensionId}, slot: ${slotId}) and there are runtime errors that need fixing.`,
|
|
280
|
+
`\nFull error details:\n${detailedTrace}`,
|
|
281
|
+
];
|
|
282
|
+
if (consoleLogs.length > 0) {
|
|
283
|
+
const consoleStr = consoleLogs
|
|
284
|
+
.map((l) => `[${l.level}] ${l.message}`)
|
|
285
|
+
.join("\n");
|
|
286
|
+
contextParts.push(`\nRecent console output:\n${consoleStr}`);
|
|
287
|
+
}
|
|
288
|
+
if (networkLogs.length > 0) {
|
|
289
|
+
const netStr = networkLogs
|
|
290
|
+
.map((l) => `${l.method} ${l.path} → ${l.ok ? l.status : "FAILED: " + (l.error || l.status)}`)
|
|
291
|
+
.join("\n");
|
|
292
|
+
contextParts.push(`\nRecent network requests:\n${netStr}`);
|
|
293
|
+
}
|
|
294
|
+
if (freshContent) {
|
|
295
|
+
contextParts.push(`\nCurrent extension content (just re-read from the database — this is the authoritative source, not anything you may have written in a previous turn):\n\`\`\`html\n${freshContent}\n\`\`\``);
|
|
296
|
+
}
|
|
297
|
+
sendToAgentChat({
|
|
298
|
+
message: `Fix runtime errors in extension "${name}" (id: ${extensionId}), embedded as a dashboard panel. The content snapshot below was just re-read from the database — treat it as authoritative and ignore any prior version you may have generated in this chat. If in doubt, call get-extension first.\n\nErrors:\n${errors.join("\n")}`,
|
|
299
|
+
context: contextParts.join("\n"),
|
|
300
|
+
submit: true,
|
|
301
|
+
openSidebar: true,
|
|
302
|
+
});
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
241
305
|
if (message.type !== "agent-native-extension-request")
|
|
242
306
|
return;
|
|
243
307
|
const requestId = String(message.requestId ?? "");
|
|
@@ -306,7 +370,7 @@ export function EmbeddedExtension({ extensionId, slotId, context, className, ini
|
|
|
306
370
|
};
|
|
307
371
|
window.addEventListener("message", handleMessage);
|
|
308
372
|
return () => window.removeEventListener("message", handleMessage);
|
|
309
|
-
}, [extensionId]);
|
|
373
|
+
}, [extensionId, slotId]);
|
|
310
374
|
if (!extension) {
|
|
311
375
|
if (!isLoading && !isFetching)
|
|
312
376
|
return null;
|