@agentic-surfaces/cli 0.1.0

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/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/bin.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { run } from "./index.js";
3
+ run(process.argv.slice(2)).then(code => process.exit(code));
@@ -0,0 +1 @@
1
+ export declare function run(argv: string[]): Promise<number>;
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ import { readFileSync, readdirSync } from "node:fs";
2
+ import { join, dirname } from "node:path";
3
+ import { loadWorkflow, runWorkflowOnce, Scheduler, loadProjectConfig } from "@agentic-surfaces/core";
4
+ import { buildServices } from "./services.js";
5
+ export async function run(argv) {
6
+ const [cmd, ...rest] = argv;
7
+ try {
8
+ if (cmd === "validate") {
9
+ loadWorkflow(readFileSync(rest[0], "utf8"));
10
+ console.log("OK:", rest[0]);
11
+ return 0;
12
+ }
13
+ if (cmd === "run-once") {
14
+ const file = rest.find(a => !a.startsWith("--"));
15
+ if (!file) {
16
+ console.error("run-once: missing workflow file");
17
+ return 1;
18
+ }
19
+ const fake = rest.includes("--fake");
20
+ const pc = loadProjectConfig(dirname(file));
21
+ const wf = loadWorkflow(readFileSync(file, "utf8"));
22
+ const services = buildServices(fake ? { fakeAgent: [{ text: "fake reply" }], projectConfig: pc } : { projectConfig: pc });
23
+ const outputs = await runWorkflowOnce(wf, { services });
24
+ console.log("ran", wf.name, "->", [...outputs.keys()].join(", "));
25
+ return 0;
26
+ }
27
+ if (cmd === "start") {
28
+ const dir = rest[0] ?? ".";
29
+ const pc = loadProjectConfig(dir);
30
+ const workflowsDir = pc?.workflows ? join(dir, pc.workflows) : dir;
31
+ 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")));
35
+ sched.start();
36
+ console.log("scheduler started; watching", workflowsDir);
37
+ return 0;
38
+ }
39
+ console.error("usage: flow <validate|run-once|start> ...");
40
+ return 1;
41
+ }
42
+ catch (err) {
43
+ console.error("error:", err instanceof Error ? err.message : String(err));
44
+ return 1;
45
+ }
46
+ }
@@ -0,0 +1,7 @@
1
+ import { type ProjectConfig } from "@agentic-surfaces/core";
2
+ import { type AgentResult } from "@agentic-surfaces/agent";
3
+ import type { Services } from "@agentic-surfaces/core";
4
+ export declare function buildServices(opts?: {
5
+ fakeAgent?: AgentResult[];
6
+ projectConfig?: ProjectConfig;
7
+ }): Services;
@@ -0,0 +1,18 @@
1
+ import { SqliteCache } from "@agentic-surfaces/core";
2
+ import { ClaudeAgentRunner } from "@agentic-surfaces/agent";
3
+ import { FakeAgentRunner } from "@agentic-surfaces/agent/testing";
4
+ export function buildServices(opts = {}) {
5
+ const pc = opts.projectConfig;
6
+ return {
7
+ agent: opts.fakeAgent ? new FakeAgentRunner(opts.fakeAgent) : new ClaudeAgentRunner({ model: pc?.agent?.model }),
8
+ cache: new SqliteCache(".flow-cache.sqlite"),
9
+ logger: { info: (m, meta) => console.log(m, meta ?? ""), error: (m, meta) => console.error(m, meta ?? "") },
10
+ fetch: globalThis.fetch,
11
+ dryRun: pc?.dryRun ?? false,
12
+ agentDefaults: pc ? {
13
+ model: pc.agent?.model,
14
+ runner: pc.agent?.runner,
15
+ mcpServers: pc.agent?.mcpServers,
16
+ } : undefined,
17
+ };
18
+ }
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@agentic-surfaces/cli",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "bin": {
18
+ "flow": "dist/bin.js"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "dependencies": {
24
+ "@agentic-surfaces/core": "0.1.0",
25
+ "@agentic-surfaces/agent": "0.1.0"
26
+ },
27
+ "scripts": {
28
+ "build": "tsc -b",
29
+ "test": "vitest run --root ../.."
30
+ }
31
+ }