@polpo-ai/react 0.6.18 → 0.6.20
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.
|
@@ -7,6 +7,12 @@ export interface UseAgentReturn {
|
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Fetch a single agent by name from the `/agents/:name` endpoint.
|
|
10
|
+
*
|
|
11
|
+
* Pass `undefined` or `null` when the name is not yet known (e.g. a session
|
|
12
|
+
* without an associated agent, or data still loading) and the hook will
|
|
13
|
+
* no-op — no HTTP request, no spurious 404s. Previously consumers had
|
|
14
|
+
* to invent sentinel strings like `"__none__"` to avoid the call; that
|
|
15
|
+
* pattern is no longer necessary.
|
|
10
16
|
*/
|
|
11
|
-
export declare function useAgent(name: string): UseAgentReturn;
|
|
17
|
+
export declare function useAgent(name: string | undefined | null): UseAgentReturn;
|
|
12
18
|
//# sourceMappingURL=use-agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-agent.d.ts","sourceRoot":"","sources":["../../src/hooks/use-agent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED
|
|
1
|
+
{"version":3,"file":"use-agent.d.ts","sourceRoot":"","sources":["../../src/hooks/use-agent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,cAAc,CA8BxE"}
|
package/dist/hooks/use-agent.js
CHANGED
|
@@ -2,13 +2,21 @@ import { useCallback, useEffect, useState } from "react";
|
|
|
2
2
|
import { usePolpoContext } from "../provider/polpo-context.js";
|
|
3
3
|
/**
|
|
4
4
|
* Fetch a single agent by name from the `/agents/:name` endpoint.
|
|
5
|
+
*
|
|
6
|
+
* Pass `undefined` or `null` when the name is not yet known (e.g. a session
|
|
7
|
+
* without an associated agent, or data still loading) and the hook will
|
|
8
|
+
* no-op — no HTTP request, no spurious 404s. Previously consumers had
|
|
9
|
+
* to invent sentinel strings like `"__none__"` to avoid the call; that
|
|
10
|
+
* pattern is no longer necessary.
|
|
5
11
|
*/
|
|
6
12
|
export function useAgent(name) {
|
|
7
13
|
const { client } = usePolpoContext();
|
|
8
14
|
const [agent, setAgent] = useState(null);
|
|
9
|
-
const [isLoading, setIsLoading] = useState(
|
|
15
|
+
const [isLoading, setIsLoading] = useState(!!name);
|
|
10
16
|
const [error, setError] = useState(null);
|
|
11
17
|
const fetchAgent = useCallback(async () => {
|
|
18
|
+
if (!name)
|
|
19
|
+
return;
|
|
12
20
|
try {
|
|
13
21
|
setError(null);
|
|
14
22
|
const data = await client.getAgent(name);
|
|
@@ -22,6 +30,7 @@ export function useAgent(name) {
|
|
|
22
30
|
useEffect(() => {
|
|
23
31
|
if (!name) {
|
|
24
32
|
setAgent(null);
|
|
33
|
+
setError(null);
|
|
25
34
|
setIsLoading(false);
|
|
26
35
|
return;
|
|
27
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-agent.js","sourceRoot":"","sources":["../../src/hooks/use-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,Q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AC,CAAC;YACf,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO;QACT,CAAC;QACD,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;IAEvB,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAC1D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polpo-ai/react",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.20",
|
|
4
4
|
"description": "React SDK for OpenPolpo — hooks with real-time SSE updates, built on @polpo-ai/sdk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@polpo-ai/sdk": "0.6.
|
|
20
|
+
"@polpo-ai/sdk": "0.6.20"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": "^18.0.0 || ^19.0.0"
|