@agentic-surfaces/cli 0.1.1 → 0.1.3

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 +48 -7
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,7 +1,24 @@
1
1
  import { readFileSync, readdirSync } from "node:fs";
2
- import { join, dirname } from "node:path";
3
- import { loadWorkflow, runWorkflowOnce, Scheduler, loadProjectConfig } from "@agentic-surfaces/core";
2
+ import { join, dirname, resolve } from "node:path";
3
+ import { loadWorkflow, runWorkflowOnce, Scheduler, loadProjectConfig, buildWorkflowRunner, defaultRegistry } from "@agentic-surfaces/core";
4
4
  import { buildServices } from "./services.js";
5
+ // Walk up from a starting dir to find agentic-surfaces.config.yaml. run-once
6
+ // is pointed at a workflow file (e.g. <proj>/workflows/foo.yaml), but the
7
+ // project config — including the dryRun safety flag — lives at the project
8
+ // root (<proj>/). Without this, dryRun would default to false and a one-shot
9
+ // run could perform live writes. SAFETY-CRITICAL: do not remove.
10
+ function findProjectConfig(startDir) {
11
+ let dir = resolve(startDir);
12
+ for (;;) {
13
+ const pc = loadProjectConfig(dir);
14
+ if (pc)
15
+ return pc;
16
+ const parent = dirname(dir);
17
+ if (parent === dir)
18
+ return undefined;
19
+ dir = parent;
20
+ }
21
+ }
5
22
  export async function run(argv) {
6
23
  const [cmd, ...rest] = argv;
7
24
  try {
@@ -17,10 +34,22 @@ export async function run(argv) {
17
34
  return 1;
18
35
  }
19
36
  const fake = rest.includes("--fake");
20
- const pc = loadProjectConfig(dirname(file));
37
+ const pc = findProjectConfig(dirname(file));
21
38
  const wf = loadWorkflow(readFileSync(file, "utf8"));
22
39
  const services = buildServices(fake ? { fakeAgent: [{ text: "fake reply" }], projectConfig: pc } : { projectConfig: pc });
23
- const outputs = await runWorkflowOnce(wf, { services });
40
+ const dir = dirname(file);
41
+ const allWorkflows = new Map();
42
+ for (const f of readdirSync(dir).filter(f => f.endsWith(".yaml") && f !== "agentic-surfaces.config.yaml")) {
43
+ try {
44
+ const w = loadWorkflow(readFileSync(join(dir, f), "utf8"));
45
+ allWorkflows.set(w.name, w);
46
+ }
47
+ catch { /* skip unparseable */ }
48
+ }
49
+ const registry = defaultRegistry();
50
+ const runWorkflowFn = buildWorkflowRunner({ workflows: allWorkflows, registry, services });
51
+ const servicesWithRunner = { ...services, runWorkflow: runWorkflowFn };
52
+ const outputs = await runWorkflowOnce(wf, { registry, services: servicesWithRunner });
24
53
  console.log("ran", wf.name, "->", [...outputs.keys()].join(", "));
25
54
  return 0;
26
55
  }
@@ -29,9 +58,21 @@ export async function run(argv) {
29
58
  const pc = loadProjectConfig(dir);
30
59
  const workflowsDir = pc?.workflows ? join(dir, pc.workflows) : dir;
31
60
  const services = buildServices({ projectConfig: pc });
32
- const sched = new Scheduler(services);
33
- for (const f of readdirSync(workflowsDir).filter(f => f.endsWith(".yaml") && f !== "agentic-surfaces.config.yaml"))
34
- sched.add(loadWorkflow(readFileSync(join(workflowsDir, f), "utf8")));
61
+ const allWorkflows = new Map();
62
+ const yamlFiles = readdirSync(workflowsDir).filter(f => f.endsWith(".yaml") && f !== "agentic-surfaces.config.yaml");
63
+ for (const f of yamlFiles) {
64
+ try {
65
+ const w = loadWorkflow(readFileSync(join(workflowsDir, f), "utf8"));
66
+ allWorkflows.set(w.name, w);
67
+ }
68
+ catch { /* skip unparseable */ }
69
+ }
70
+ const registry = defaultRegistry();
71
+ const runWorkflowFn = buildWorkflowRunner({ workflows: allWorkflows, registry, services });
72
+ const servicesWithRunner = { ...services, runWorkflow: runWorkflowFn };
73
+ const sched = new Scheduler(servicesWithRunner, registry);
74
+ for (const [, w] of allWorkflows)
75
+ sched.add(w);
35
76
  sched.start();
36
77
  console.log("scheduler started; watching", workflowsDir);
37
78
  return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentic-surfaces/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -21,8 +21,8 @@
21
21
  "dist"
22
22
  ],
23
23
  "dependencies": {
24
- "@agentic-surfaces/core": "0.1.1",
25
- "@agentic-surfaces/agent": "0.1.1"
24
+ "@agentic-surfaces/agent": "0.1.3",
25
+ "@agentic-surfaces/core": "0.1.3"
26
26
  },
27
27
  "scripts": {
28
28
  "build": "tsc -b",