@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 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, };
@@ -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
- ctx.body = `error reading the agent spec file ${ctx.params.id}`;
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
  }
@@ -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
- 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);
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 };
@@ -0,0 +1,3 @@
1
+ import type Router from '@koa/router';
2
+ declare function getSkillssRoute(r: Router): void;
3
+ export { getSkillssRoute, };
@@ -0,0 +1,9 @@
1
+ import { db } from '@agent-smith/core';
2
+ function getSkillssRoute(r) {
3
+ r.get('/skills', async (ctx, next) => {
4
+ const w = db.readFeaturesType("skill");
5
+ ctx.body = w;
6
+ ctx.status = 200;
7
+ });
8
+ }
9
+ export { getSkillssRoute, };
@@ -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 };
@@ -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(5184, () => {
202
- console.log('Please open url http://localhost:5184 in a browser');
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.5",
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.8",
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": "./dist/index.js"
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
  }