@nextclaw/ncp-react 0.3.6 → 0.4.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/index.d.ts +1 -1
- package/dist/index.js +13 -3
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -145,6 +145,9 @@ function useNcpAgentRuntime({
|
|
|
145
145
|
function toError(error) {
|
|
146
146
|
return error instanceof Error ? error : new Error(String(error));
|
|
147
147
|
}
|
|
148
|
+
function resolveSessionHydratingState(params) {
|
|
149
|
+
return params.isHydrating || params.hydratedSessionId !== params.sessionId;
|
|
150
|
+
}
|
|
148
151
|
function useHydratedNcpAgent({
|
|
149
152
|
sessionId,
|
|
150
153
|
client,
|
|
@@ -155,6 +158,7 @@ function useHydratedNcpAgent({
|
|
|
155
158
|
const runtime = useNcpAgentRuntime({ sessionId, client, manager });
|
|
156
159
|
const [isHydrating, setIsHydrating] = useState2(true);
|
|
157
160
|
const [hydrateError, setHydrateError] = useState2(null);
|
|
161
|
+
const [hydratedSessionId, setHydratedSessionId] = useState2(null);
|
|
158
162
|
const loadStateRef = useRef2({ requestId: 0, controller: null });
|
|
159
163
|
const reloadSeed = useCallback(async () => {
|
|
160
164
|
loadStateRef.current.controller?.abort();
|
|
@@ -183,6 +187,7 @@ function useHydratedNcpAgent({
|
|
|
183
187
|
} : null
|
|
184
188
|
});
|
|
185
189
|
setHydrateError(null);
|
|
190
|
+
setHydratedSessionId(sessionId);
|
|
186
191
|
setIsHydrating(false);
|
|
187
192
|
if (seed.status === "running" && autoResumeRunningSession) {
|
|
188
193
|
void client.stream({ sessionId }).catch((error) => {
|
|
@@ -197,6 +202,7 @@ function useHydratedNcpAgent({
|
|
|
197
202
|
return;
|
|
198
203
|
}
|
|
199
204
|
setHydrateError(toError(error));
|
|
205
|
+
setHydratedSessionId(sessionId);
|
|
200
206
|
setIsHydrating(false);
|
|
201
207
|
} finally {
|
|
202
208
|
if (loadStateRef.current.controller === controller) {
|
|
@@ -213,7 +219,11 @@ function useHydratedNcpAgent({
|
|
|
213
219
|
}, [reloadSeed]);
|
|
214
220
|
return {
|
|
215
221
|
...runtime,
|
|
216
|
-
isHydrating
|
|
222
|
+
isHydrating: resolveSessionHydratingState({
|
|
223
|
+
sessionId,
|
|
224
|
+
hydratedSessionId,
|
|
225
|
+
isHydrating
|
|
226
|
+
}),
|
|
217
227
|
hydrateError,
|
|
218
228
|
reloadSeed
|
|
219
229
|
};
|
|
@@ -233,7 +243,7 @@ var DEFAULT_NCP_IMAGE_ATTACHMENT_MIME_TYPES = [
|
|
|
233
243
|
"image/webp",
|
|
234
244
|
"image/gif"
|
|
235
245
|
];
|
|
236
|
-
var DEFAULT_NCP_ATTACHMENT_MAX_BYTES =
|
|
246
|
+
var DEFAULT_NCP_ATTACHMENT_MAX_BYTES = 200 * 1024 * 1024;
|
|
237
247
|
var DEFAULT_NCP_IMAGE_ATTACHMENT_MAX_BYTES = DEFAULT_NCP_ATTACHMENT_MAX_BYTES;
|
|
238
248
|
var DEFAULT_NCP_FALLBACK_ATTACHMENT_MIME_TYPE = "application/octet-stream";
|
|
239
249
|
function createAttachmentId() {
|
|
@@ -305,7 +315,7 @@ function buildNcpRequestEnvelope(params) {
|
|
|
305
315
|
type: "file",
|
|
306
316
|
name: attachment.name,
|
|
307
317
|
mimeType: attachment.mimeType,
|
|
308
|
-
...attachment.
|
|
318
|
+
...attachment.assetUri?.trim() ? { assetUri: attachment.assetUri.trim() } : {},
|
|
309
319
|
...attachment.url?.trim() ? { url: attachment.url.trim() } : {},
|
|
310
320
|
...attachment.contentBase64?.trim() ? { contentBase64: attachment.contentBase64.trim() } : {},
|
|
311
321
|
sizeBytes: attachment.sizeBytes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/ncp-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "React bindings for building NCP-based agent applications.",
|
|
6
6
|
"type": "module",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@nextclaw/ncp
|
|
19
|
-
"@nextclaw/ncp": "0.
|
|
18
|
+
"@nextclaw/ncp": "0.4.0",
|
|
19
|
+
"@nextclaw/ncp-toolkit": "0.4.4"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"react": "^18.0.0 || ^19.0.0"
|