@tangle-network/agent-app 0.36.0 → 0.37.1
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/dist/{chunk-GZGF3JWQ.js → chunk-FFBZJEBE.js} +226 -171
- package/dist/chunk-FFBZJEBE.js.map +1 -0
- package/dist/{chunk-MH6AVXQ7.js → chunk-VT5DI6GL.js} +40 -34
- package/dist/chunk-VT5DI6GL.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/sandbox/index.d.ts +22 -26
- package/dist/sandbox/index.js +2 -2
- package/dist/studio-react/index.js +2 -1
- package/dist/studio-react/index.js.map +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/web-react/index.js +31 -13
- package/dist/web-react/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-GZGF3JWQ.js.map +0 -1
- package/dist/chunk-MH6AVXQ7.js.map +0 -1
package/dist/web-react/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "../chunk-5VXPDXZJ.js";
|
|
8
8
|
|
|
9
9
|
// src/web-react/index.tsx
|
|
10
|
-
import { useEffect as useEffect5, useMemo as useMemo3, useRef as
|
|
10
|
+
import { useEffect as useEffect5, useMemo as useMemo3, useRef as useRef4, useState as useState6, memo } from "react";
|
|
11
11
|
|
|
12
12
|
// src/web-react/smooth-text.ts
|
|
13
13
|
import { useEffect, useRef, useState } from "react";
|
|
@@ -740,7 +740,7 @@ function AgentActivityPanel({ fetchActivity, renderMissionRef, title = "Agent ac
|
|
|
740
740
|
}
|
|
741
741
|
|
|
742
742
|
// src/web-react/sandbox-terminal.ts
|
|
743
|
-
import { useCallback as useCallback2, useEffect as useEffect4, useState as useState4 } from "react";
|
|
743
|
+
import { useCallback as useCallback2, useEffect as useEffect4, useRef as useRef3, useState as useState4 } from "react";
|
|
744
744
|
var DEFAULT_PROVISION_POLL_INTERVAL_MS = 2e3;
|
|
745
745
|
var DEFAULT_PROVISION_POLL_TIMEOUT_MS = 9e4;
|
|
746
746
|
var DEFAULT_TOKEN_REFRESH_SKEW_MS = 12e4;
|
|
@@ -755,6 +755,8 @@ var EMPTY_CONNECTION = {
|
|
|
755
755
|
};
|
|
756
756
|
function useSandboxTerminalConnection(opts) {
|
|
757
757
|
const [conn, setConn] = useState4(EMPTY_CONNECTION);
|
|
758
|
+
const mountedRef = useRef3(false);
|
|
759
|
+
const generationRef = useRef3(0);
|
|
758
760
|
const fetcher = opts.fetcher ?? fetch;
|
|
759
761
|
const pollIntervalMs = opts.provisionPollIntervalMs ?? DEFAULT_PROVISION_POLL_INTERVAL_MS;
|
|
760
762
|
const pollTimeoutMs = opts.provisionPollTimeoutMs ?? DEFAULT_PROVISION_POLL_TIMEOUT_MS;
|
|
@@ -764,17 +766,25 @@ function useSandboxTerminalConnection(opts) {
|
|
|
764
766
|
return opts.connectionUrl ?? `/api/workspaces/${encodeURIComponent(opts.workspaceId)}/sandbox/connection`;
|
|
765
767
|
}, [opts.connectionUrl, opts.workspaceId]);
|
|
766
768
|
const connect = useCallback2(async () => {
|
|
767
|
-
|
|
769
|
+
const generation = generationRef.current + 1;
|
|
770
|
+
generationRef.current = generation;
|
|
771
|
+
const isCurrent = () => mountedRef.current && generationRef.current === generation;
|
|
772
|
+
const setCurrentConn = (value) => {
|
|
773
|
+
if (!isCurrent()) return;
|
|
774
|
+
setConn(value);
|
|
775
|
+
};
|
|
776
|
+
setCurrentConn((current) => ({ ...current, loading: true, error: null }));
|
|
768
777
|
const deadline = Date.now() + pollTimeoutMs;
|
|
769
|
-
while (
|
|
778
|
+
while (isCurrent()) {
|
|
770
779
|
try {
|
|
771
780
|
const res = await fetcher(connectionUrl());
|
|
772
781
|
const data = await res.json();
|
|
782
|
+
if (!isCurrent()) return;
|
|
773
783
|
const runtimeUrl = data.runtimeUrl ?? data.sidecarUrl;
|
|
774
784
|
if (res.ok && runtimeUrl && data.token && data.expiresAt) {
|
|
775
|
-
|
|
785
|
+
setCurrentConn({
|
|
776
786
|
runtimeUrl,
|
|
777
|
-
sidecarUrl: runtimeUrl,
|
|
787
|
+
sidecarUrl: data.sidecarUrl ?? runtimeUrl,
|
|
778
788
|
token: data.token,
|
|
779
789
|
expiresAt: data.expiresAt,
|
|
780
790
|
status: data.status ?? "running",
|
|
@@ -785,7 +795,7 @@ function useSandboxTerminalConnection(opts) {
|
|
|
785
795
|
return;
|
|
786
796
|
}
|
|
787
797
|
if (res.ok) {
|
|
788
|
-
|
|
798
|
+
setCurrentConn({
|
|
789
799
|
runtimeUrl: null,
|
|
790
800
|
sidecarUrl: null,
|
|
791
801
|
token: null,
|
|
@@ -798,7 +808,7 @@ function useSandboxTerminalConnection(opts) {
|
|
|
798
808
|
return;
|
|
799
809
|
}
|
|
800
810
|
if (res.status === 503 && Date.now() < deadline) {
|
|
801
|
-
|
|
811
|
+
setCurrentConn((current) => ({
|
|
802
812
|
...current,
|
|
803
813
|
loading: true,
|
|
804
814
|
status: data.status ?? "provisioning",
|
|
@@ -807,7 +817,7 @@ function useSandboxTerminalConnection(opts) {
|
|
|
807
817
|
await sleep(pollIntervalMs);
|
|
808
818
|
continue;
|
|
809
819
|
}
|
|
810
|
-
|
|
820
|
+
setCurrentConn((current) => ({
|
|
811
821
|
...current,
|
|
812
822
|
runtimeUrl: null,
|
|
813
823
|
sidecarUrl: null,
|
|
@@ -819,11 +829,12 @@ function useSandboxTerminalConnection(opts) {
|
|
|
819
829
|
}));
|
|
820
830
|
return;
|
|
821
831
|
} catch (err) {
|
|
832
|
+
if (!isCurrent()) return;
|
|
822
833
|
if (Date.now() < deadline) {
|
|
823
834
|
await sleep(pollIntervalMs);
|
|
824
835
|
continue;
|
|
825
836
|
}
|
|
826
|
-
|
|
837
|
+
setCurrentConn((current) => ({
|
|
827
838
|
...current,
|
|
828
839
|
runtimeUrl: null,
|
|
829
840
|
sidecarUrl: null,
|
|
@@ -836,6 +847,13 @@ function useSandboxTerminalConnection(opts) {
|
|
|
836
847
|
}
|
|
837
848
|
}
|
|
838
849
|
}, [connectionUrl, fetcher, pollIntervalMs, pollTimeoutMs]);
|
|
850
|
+
useEffect4(() => {
|
|
851
|
+
mountedRef.current = true;
|
|
852
|
+
return () => {
|
|
853
|
+
mountedRef.current = false;
|
|
854
|
+
generationRef.current += 1;
|
|
855
|
+
};
|
|
856
|
+
}, []);
|
|
839
857
|
useEffect4(() => {
|
|
840
858
|
void connect();
|
|
841
859
|
}, [connect]);
|
|
@@ -1338,9 +1356,9 @@ function AssistantMessageImpl({
|
|
|
1338
1356
|
const content = useSmoothText(msg.content, streaming);
|
|
1339
1357
|
const reasoning = useSmoothText(msg.reasoning ?? "", streaming);
|
|
1340
1358
|
const body = useMemo3(() => renderBody(content), [renderBody, content]);
|
|
1341
|
-
const reasoningScrollRef =
|
|
1342
|
-
const thinkStartRef =
|
|
1343
|
-
const thinkMsRef =
|
|
1359
|
+
const reasoningScrollRef = useRef4(null);
|
|
1360
|
+
const thinkStartRef = useRef4(null);
|
|
1361
|
+
const thinkMsRef = useRef4(null);
|
|
1344
1362
|
if (streaming && reasoning && !content && thinkStartRef.current === null) {
|
|
1345
1363
|
thinkStartRef.current = performance.now();
|
|
1346
1364
|
}
|