@agentic-surfaces/cli 0.1.8 → 0.1.9

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.
Files changed (2) hide show
  1. package/dist/index.js +41 -7
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { readFileSync, readdirSync, existsSync } from "node:fs";
2
2
  import { join, dirname, resolve } from "node:path";
3
3
  import { spawn } from "node:child_process";
4
- import { loadWorkflow, runWorkflowOnce, Scheduler, loadProjectConfig, buildWorkflowRunner, defaultRegistry } from "@agentic-surfaces/core";
4
+ import { loadWorkflow, runWorkflowOnce, Scheduler, loadProjectConfig, buildWorkflowRunner, defaultRegistry, parseAgentFile } from "@agentic-surfaces/core";
5
5
  import { serve, StreamingObserver } from "@agentic-surfaces/server";
6
6
  import { buildServices } from "./services.js";
7
7
  const CONFIG = "agentic-surfaces.config.yaml";
@@ -33,6 +33,36 @@ function loadWorkflows(dir) {
33
33
  }
34
34
  return map;
35
35
  }
36
+ // Load agents/<name>.md from the project into a name→AgentDefinition map.
37
+ // A bad agent file is reported and skipped (consistent with workflow loading).
38
+ function loadAgents(projectDir) {
39
+ const map = new Map();
40
+ const agentsDir = join(projectDir, "agents");
41
+ if (!existsSync(agentsDir))
42
+ return map;
43
+ for (const f of readdirSync(agentsDir).filter((f) => f.endsWith(".md"))) {
44
+ try {
45
+ const def = parseAgentFile(readFileSync(join(agentsDir, f), "utf8"), f.replace(/\.md$/, ""));
46
+ map.set(def.name, def);
47
+ }
48
+ catch (err) {
49
+ console.error(`skipping agent ${f}:`, err instanceof Error ? err.message : String(err));
50
+ }
51
+ }
52
+ return map;
53
+ }
54
+ // Walk up to the directory that contains agentic-surfaces.config.yaml.
55
+ function findProjectDir(start) {
56
+ let dir = resolve(start);
57
+ for (;;) {
58
+ if (existsSync(join(dir, CONFIG)))
59
+ return dir;
60
+ const parent = dirname(dir);
61
+ if (parent === dir)
62
+ return undefined;
63
+ dir = parent;
64
+ }
65
+ }
36
66
  // `--ui`: start the live dashboard (HTTP server + SSE) and return its
37
67
  // StreamingObserver so run lifecycle events stream to the browser.
38
68
  function startUi() {
@@ -88,11 +118,12 @@ export async function run(argv) {
88
118
  const pc = loadProjectConfig(dir);
89
119
  const workflowsDir = pc?.workflows ? join(dir, pc.workflows) : dir;
90
120
  const allWorkflows = loadWorkflows(workflowsDir);
121
+ const agents = loadAgents(dir);
91
122
  const registry = defaultRegistry();
92
123
  const observer = new StreamingObserver();
93
124
  const services = buildServices({ projectConfig: pc });
94
- const runWorkflowFn = buildWorkflowRunner({ workflows: allWorkflows, registry, services, observer });
95
- const servicesWithRunner = { ...services, runWorkflow: runWorkflowFn };
125
+ const runWorkflowFn = buildWorkflowRunner({ workflows: allWorkflows, registry, services: { ...services, agents }, observer });
126
+ const servicesWithRunner = { ...services, agents, runWorkflow: runWorkflowFn };
96
127
  // Cron-triggered workflows fire on schedule too.
97
128
  const sched = new Scheduler(servicesWithRunner, registry, observer);
98
129
  for (const [, w] of allWorkflows)
@@ -105,6 +136,7 @@ export async function run(argv) {
105
136
  workflows: [...allWorkflows.values()],
106
137
  onRun: (name) => runWorkflowFn(name, undefined),
107
138
  config: { dryRun: pc?.dryRun, agent: { model: pc?.agent?.model, effort: pc?.agent?.effort } },
139
+ agents: [...agents.values()],
108
140
  });
109
141
  const url = `http://127.0.0.1:${actualPort}`;
110
142
  openBrowser(url);
@@ -137,11 +169,12 @@ export async function run(argv) {
137
169
  }
138
170
  catch { /* skip unparseable */ }
139
171
  }
172
+ const agents = loadAgents(findProjectDir(dirname(file)) ?? dir);
140
173
  const registry = defaultRegistry();
141
174
  const session = rest.includes("--ui") ? startUi() : undefined;
142
175
  const observer = session?.observer;
143
- const runWorkflowFn = buildWorkflowRunner({ workflows: allWorkflows, registry, services, observer });
144
- const servicesWithRunner = { ...services, runWorkflow: runWorkflowFn };
176
+ const runWorkflowFn = buildWorkflowRunner({ workflows: allWorkflows, registry, services: { ...services, agents }, observer });
177
+ const servicesWithRunner = { ...services, agents, runWorkflow: runWorkflowFn };
145
178
  // A run error must NOT tear down the --ui server: the failure is already
146
179
  // streamed to the dashboard (the failed node + run), so keep serving so it
147
180
  // stays inspectable. Without --ui, an error still exits non-zero.
@@ -174,11 +207,12 @@ export async function run(argv) {
174
207
  }
175
208
  catch { /* skip unparseable */ }
176
209
  }
210
+ const agents = loadAgents(dir);
177
211
  const registry = defaultRegistry();
178
212
  const session = rest.includes("--ui") ? startUi() : undefined;
179
213
  const observer = session?.observer;
180
- const runWorkflowFn = buildWorkflowRunner({ workflows: allWorkflows, registry, services, observer });
181
- const servicesWithRunner = { ...services, runWorkflow: runWorkflowFn };
214
+ const runWorkflowFn = buildWorkflowRunner({ workflows: allWorkflows, registry, services: { ...services, agents }, observer });
215
+ const servicesWithRunner = { ...services, agents, runWorkflow: runWorkflowFn };
182
216
  const sched = new Scheduler(servicesWithRunner, registry, observer);
183
217
  for (const [, w] of allWorkflows)
184
218
  sched.add(w);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentic-surfaces/cli",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -21,9 +21,9 @@
21
21
  "dist"
22
22
  ],
23
23
  "dependencies": {
24
- "@agentic-surfaces/core": "0.1.8",
25
- "@agentic-surfaces/agent": "0.1.8",
26
- "@agentic-surfaces/server": "0.1.8"
24
+ "@agentic-surfaces/core": "0.1.9",
25
+ "@agentic-surfaces/agent": "0.1.9",
26
+ "@agentic-surfaces/server": "0.1.9"
27
27
  },
28
28
  "scripts": {
29
29
  "build": "tsc -b",