@agent-smith/server 0.1.5 → 0.1.6
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/main.d.ts +1 -1
- package/dist/main.js +2 -2
- package/dist/routes/agents.js +6 -2
- package/dist/routes/index.js +2 -1
- package/dist/routes/skills.d.ts +3 -0
- package/dist/routes/skills.js +9 -0
- package/dist/server/server.d.ts +1 -1
- package/dist/server/server.js +3 -3
- package/package.json +9 -4
package/dist/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { baseRoutes } from "./routes/index.js";
|
|
2
2
|
import type Router from "@koa/router";
|
|
3
|
-
declare function runServer(routes?: ((r: Router) => void)[], staticDir?: string): void;
|
|
3
|
+
declare function runServer(routes?: ((r: Router) => void)[], staticDir?: string, port?: number): void;
|
|
4
4
|
export { runServer, baseRoutes, };
|
package/dist/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { runserver } from "./server/server.js";
|
|
2
2
|
import { baseRoutes } from "./routes/index.js";
|
|
3
|
-
function runServer(routes, staticDir) {
|
|
3
|
+
function runServer(routes, staticDir, port = 5184) {
|
|
4
4
|
const r = routes ? [...baseRoutes, ...routes] : baseRoutes;
|
|
5
|
-
runserver(r, staticDir);
|
|
5
|
+
runserver(r, staticDir, port);
|
|
6
6
|
}
|
|
7
7
|
export { runServer, baseRoutes, };
|
package/dist/routes/agents.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { db, fs } from '@agent-smith/core';
|
|
1
|
+
import { db, fs, state } from '@agent-smith/core';
|
|
2
2
|
import { excludedTaskTypes } from '../utils.js';
|
|
3
3
|
function getAgentsRoute(r) {
|
|
4
4
|
r.get('/agents', async (ctx, next) => {
|
|
5
|
+
await state.init();
|
|
5
6
|
const agents = db.readFeaturesType("agent");
|
|
6
7
|
let ag = {};
|
|
7
8
|
for (const [name, feat] of Object.entries(agents)) {
|
|
@@ -22,13 +23,16 @@ function getAgentsRoute(r) {
|
|
|
22
23
|
}
|
|
23
24
|
function getAgentRoute(r) {
|
|
24
25
|
r.get('/agent/:id', async (ctx, next) => {
|
|
26
|
+
await state.init();
|
|
25
27
|
//console.log(ctx.params.id)
|
|
26
28
|
let spec;
|
|
27
29
|
try {
|
|
28
30
|
spec = fs.openAgentSpec(ctx.params.id);
|
|
29
31
|
}
|
|
30
32
|
catch (e) {
|
|
31
|
-
|
|
33
|
+
const msg = `error reading the agent spec file ${ctx.params.id}: ${e}`;
|
|
34
|
+
console.error(msg);
|
|
35
|
+
ctx.body = msg;
|
|
32
36
|
ctx.status = 500;
|
|
33
37
|
return;
|
|
34
38
|
}
|
package/dist/routes/index.js
CHANGED
|
@@ -12,5 +12,6 @@ import { getOrCreateAppConfigFileRoute, updateAppConfigFileRoute } from "./apps.
|
|
|
12
12
|
import { getWorkspaceRoute, updateDefaultWorkspaceRoute, upsertWorkspaceRoute } from "./workspace.js";
|
|
13
13
|
import { getSettingsRoute } from "./settings.js";
|
|
14
14
|
import { applyTemplateRoute } from "./templates.js";
|
|
15
|
-
|
|
15
|
+
import { getSkillssRoute } from "./skills.js";
|
|
16
|
+
const baseRoutes = new Array(getConfRoute, getAgentRoute, getAgentsRoute, getModelsRoute, getModelsPresetsRoute, getToolsRoute, getAgentSettingsCmd, getStateRoute, createConfRoute, updateAgentSettingsCmd, installPluginRoute, addFolderRoute, getWorkflowRoute, getWorkflowsRoute, getBackendsRoute, setBackendRoute, getOrCreateAppConfigFileRoute, updateAppConfigFileRoute, getWorkspaceRoute, upsertWorkspaceRoute, updateDefaultWorkspaceRoute, getSettingsRoute, upsertModelPresetRoute, delModelPresetRoute, applyTemplateRoute, getSkillssRoute);
|
|
16
17
|
export { baseRoutes };
|
package/dist/server/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Router } from "@koa/router";
|
|
3
|
-
declare function runserver(routes?: ((r: Router) => void)[], staticDir?: string): void;
|
|
3
|
+
declare function runserver(routes?: ((r: Router) => void)[], staticDir?: string | null, port?: number): void;
|
|
4
4
|
export { runserver };
|
package/dist/server/server.js
CHANGED
|
@@ -37,7 +37,7 @@ app.use(cors({
|
|
|
37
37
|
app.ws.use((ctx, next) => {
|
|
38
38
|
return next();
|
|
39
39
|
});
|
|
40
|
-
function runserver(routes, staticDir) {
|
|
40
|
+
function runserver(routes, staticDir = null, port = 5184) {
|
|
41
41
|
//state.init();
|
|
42
42
|
const router = useRouter(routes);
|
|
43
43
|
//console.log(router.apiRouter.stack.map(i => i.path));
|
|
@@ -198,8 +198,8 @@ function runserver(routes, staticDir) {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
});
|
|
201
|
-
app.listen(
|
|
202
|
-
console.log(
|
|
201
|
+
app.listen(port, () => {
|
|
202
|
+
console.log(`Please open url http://localhost:${port} in a browser`);
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
205
|
export { runserver };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-smith/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Agent Smith Nodejs server",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@agent-smith/core": "^0.0.
|
|
13
|
+
"@agent-smith/core": "^0.0.10",
|
|
14
14
|
"@koa/cors": "^5.0.0",
|
|
15
15
|
"@koa/router": "^15.6.0",
|
|
16
16
|
"ansi-colors": "^4.1.3",
|
|
@@ -47,11 +47,16 @@
|
|
|
47
47
|
"dist"
|
|
48
48
|
],
|
|
49
49
|
"bin": {
|
|
50
|
-
"agentserver": "
|
|
50
|
+
"agentserver": "dist/index.js"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public",
|
|
54
54
|
"registry": "https://registry.npmjs.org/"
|
|
55
55
|
},
|
|
56
|
-
"license": "MIT"
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"directories": {
|
|
58
|
+
"doc": "doc"
|
|
59
|
+
},
|
|
60
|
+
"keywords": [],
|
|
61
|
+
"author": ""
|
|
57
62
|
}
|