@agentnext/react 0.1.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.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +58 -0
- package/dist/index.mjs +31 -0
- package/package.json +51 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ActionDefinition } from '@agentnext/core';
|
|
3
|
+
|
|
4
|
+
interface AgentContextType {
|
|
5
|
+
actions: ActionDefinition<any, any>[];
|
|
6
|
+
}
|
|
7
|
+
declare const AgentProvider: React.FC<{
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}>;
|
|
10
|
+
declare function useAgentAction(action: ActionDefinition<any, any>): void;
|
|
11
|
+
declare function useAgentRegistry(): AgentContextType;
|
|
12
|
+
|
|
13
|
+
export { AgentProvider, useAgentAction, useAgentRegistry };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ActionDefinition } from '@agentnext/core';
|
|
3
|
+
|
|
4
|
+
interface AgentContextType {
|
|
5
|
+
actions: ActionDefinition<any, any>[];
|
|
6
|
+
}
|
|
7
|
+
declare const AgentProvider: React.FC<{
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}>;
|
|
10
|
+
declare function useAgentAction(action: ActionDefinition<any, any>): void;
|
|
11
|
+
declare function useAgentRegistry(): AgentContextType;
|
|
12
|
+
|
|
13
|
+
export { AgentProvider, useAgentAction, useAgentRegistry };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.tsx
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AgentProvider: () => AgentProvider,
|
|
24
|
+
useAgentAction: () => useAgentAction,
|
|
25
|
+
useAgentRegistry: () => useAgentRegistry
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_core = require("@agentnext/core");
|
|
30
|
+
var import_webmcp = require("@agentnext/webmcp");
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var AgentContext = (0, import_react.createContext)({ actions: [] });
|
|
33
|
+
var AgentProvider = ({ children }) => {
|
|
34
|
+
const [actions, setActions] = (0, import_react.useState)(import_core.registry.getAll());
|
|
35
|
+
(0, import_react.useEffect)(() => {
|
|
36
|
+
setActions(import_core.registry.getAll());
|
|
37
|
+
}, []);
|
|
38
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgentContext.Provider, { value: { actions }, children });
|
|
39
|
+
};
|
|
40
|
+
function useAgentAction(action) {
|
|
41
|
+
(0, import_react.useEffect)(() => {
|
|
42
|
+
let unregister;
|
|
43
|
+
import_core.registry.register(action);
|
|
44
|
+
const registration = (0, import_webmcp.registerActionWithWebMCP)(action);
|
|
45
|
+
return () => {
|
|
46
|
+
if (unregister) unregister();
|
|
47
|
+
};
|
|
48
|
+
}, [action]);
|
|
49
|
+
}
|
|
50
|
+
function useAgentRegistry() {
|
|
51
|
+
return (0, import_react.useContext)(AgentContext);
|
|
52
|
+
}
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
AgentProvider,
|
|
56
|
+
useAgentAction,
|
|
57
|
+
useAgentRegistry
|
|
58
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/index.tsx
|
|
2
|
+
import { createContext, useContext, useEffect, useState } from "react";
|
|
3
|
+
import { registry } from "@agentnext/core";
|
|
4
|
+
import { registerActionWithWebMCP } from "@agentnext/webmcp";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
var AgentContext = createContext({ actions: [] });
|
|
7
|
+
var AgentProvider = ({ children }) => {
|
|
8
|
+
const [actions, setActions] = useState(registry.getAll());
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setActions(registry.getAll());
|
|
11
|
+
}, []);
|
|
12
|
+
return /* @__PURE__ */ jsx(AgentContext.Provider, { value: { actions }, children });
|
|
13
|
+
};
|
|
14
|
+
function useAgentAction(action) {
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
let unregister;
|
|
17
|
+
registry.register(action);
|
|
18
|
+
const registration = registerActionWithWebMCP(action);
|
|
19
|
+
return () => {
|
|
20
|
+
if (unregister) unregister();
|
|
21
|
+
};
|
|
22
|
+
}, [action]);
|
|
23
|
+
}
|
|
24
|
+
function useAgentRegistry() {
|
|
25
|
+
return useContext(AgentContext);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
AgentProvider,
|
|
29
|
+
useAgentAction,
|
|
30
|
+
useAgentRegistry
|
|
31
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentnext/react",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "React integration for AgentNext — AgentProvider, useAgentAction, useAgentRegistry",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "AgentNext",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/your-org/agentnext"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"agentnext",
|
|
13
|
+
"webmcp",
|
|
14
|
+
"react",
|
|
15
|
+
"ai-agent"
|
|
16
|
+
],
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"module": "dist/index.mjs",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.mjs",
|
|
24
|
+
"require": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsup src/index.tsx --format cjs,esm --dts --clean",
|
|
32
|
+
"dev": "tsup src/index.tsx --format cjs,esm --dts --watch",
|
|
33
|
+
"lint": "eslint src/",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"prepublishOnly": "npm run build"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@agentnext/core": "^0.1.0",
|
|
39
|
+
"@agentnext/webmcp": "^0.1.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
43
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/react": "^18.0.0",
|
|
47
|
+
"tsup": "^8.0.0",
|
|
48
|
+
"typescript": "^5.0.0",
|
|
49
|
+
"vitest": "^1.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|