@agent-smith/server 0.1.4 → 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 +25 -17
- package/package.json +11 -6
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
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
2
4
|
import { executeAgent, executeWorkflow } from '@agent-smith/core';
|
|
3
5
|
import cors from '@koa/cors';
|
|
4
6
|
import Koa from 'koa';
|
|
@@ -35,7 +37,7 @@ app.use(cors({
|
|
|
35
37
|
app.ws.use((ctx, next) => {
|
|
36
38
|
return next();
|
|
37
39
|
});
|
|
38
|
-
function runserver(routes, staticDir) {
|
|
40
|
+
function runserver(routes, staticDir = null, port = 5184) {
|
|
39
41
|
//state.init();
|
|
40
42
|
const router = useRouter(routes);
|
|
41
43
|
//console.log(router.apiRouter.stack.map(i => i.path));
|
|
@@ -176,22 +178,28 @@ function runserver(routes, staticDir) {
|
|
|
176
178
|
app
|
|
177
179
|
.use(baseRouter.routes()).use(baseRouter.allowedMethods())
|
|
178
180
|
.use(apiRouter.routes()).use(apiRouter.allowedMethods());
|
|
179
|
-
// 404
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
181
|
+
// SPA 404 handler - serve index.html for unmatched non-API routes
|
|
182
|
+
app.use(async (ctx) => {
|
|
183
|
+
if (!ctx.matched || ctx.matched.length === 0) {
|
|
184
|
+
if (!ctx.path.startsWith('/api/')) {
|
|
185
|
+
if (staticDir) {
|
|
186
|
+
ctx.status = 200;
|
|
187
|
+
ctx.type = 'html';
|
|
188
|
+
ctx.body = fs.createReadStream(path.join(staticDir, 'index.html'));
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
ctx.status = 404;
|
|
192
|
+
ctx.body = { error: 'Not Found', path: ctx.path };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
ctx.status = 404;
|
|
197
|
+
ctx.body = { error: 'Not Found', path: ctx.path };
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
app.listen(port, () => {
|
|
202
|
+
console.log(`Please open url http://localhost:${port} in a browser`);
|
|
195
203
|
});
|
|
196
204
|
}
|
|
197
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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"yaml": "^2.9.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@agent-smith/types": "^0.0.
|
|
25
|
+
"@agent-smith/types": "^0.0.7",
|
|
26
26
|
"@types/better-sqlite3": "^7.6.13",
|
|
27
27
|
"@types/koa": "^3.0.3",
|
|
28
28
|
"@types/koa__cors": "^5.0.1",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@types/koa-route": "^3.2.9",
|
|
31
31
|
"@types/koa-static": "^4.0.4",
|
|
32
32
|
"@types/koa-websocket": "^5.0.11",
|
|
33
|
-
"@types/node": "^
|
|
33
|
+
"@types/node": "^26.0.0",
|
|
34
34
|
"ts-node": "^10.9.2",
|
|
35
35
|
"tslib": "2.8.1",
|
|
36
36
|
"typescript": "^6.0.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
|
}
|