@agentic-surfaces/cli 0.1.9 → 0.1.10

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 +49 -23
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -63,14 +63,32 @@ function findProjectDir(start) {
63
63
  dir = parent;
64
64
  }
65
65
  }
66
- // `--ui`: start the live dashboard (HTTP server + SSE) and return its
67
- // StreamingObserver so run lifecycle events stream to the browser.
68
- function startUi() {
66
+ // This package's version, shown in the dashboard. npm always ships package.json
67
+ // in the tarball, so it resolves both from source and when installed via npx.
68
+ const VERSION = (() => {
69
+ try {
70
+ return JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
71
+ }
72
+ catch {
73
+ return "unknown";
74
+ }
75
+ })();
76
+ // Launch THE dashboard — one full UI, used by every `--ui` path (bare `ui`,
77
+ // `run --ui`, `start --ui`). Always serves the workflow list, Run buttons,
78
+ // agents, config + version. There is no lite variant.
79
+ function launchUi(opts) {
69
80
  const port = parseInt(process.env["FLOW_UI_PORT"] ?? "4000", 10);
70
- const { observer, port: p } = serve({ port });
81
+ const { port: p } = serve({
82
+ port,
83
+ observer: opts.observer,
84
+ workflows: [...opts.workflows.values()],
85
+ agents: [...opts.agents.values()],
86
+ onRun: opts.onRun,
87
+ config: { dryRun: opts.dryRun, agent: opts.agentDefaults, version: VERSION },
88
+ });
71
89
  const url = `http://127.0.0.1:${p}`;
72
90
  openBrowser(url);
73
- return { observer, url };
91
+ return url;
74
92
  }
75
93
  function openBrowser(url) {
76
94
  if (process.env["FLOW_NO_OPEN"])
@@ -129,18 +147,13 @@ export async function run(argv) {
129
147
  for (const [, w] of allWorkflows)
130
148
  sched.add(w);
131
149
  sched.start();
132
- const port = parseInt(process.env["FLOW_UI_PORT"] ?? "4000", 10);
133
- const { port: actualPort } = serve({
134
- port,
135
- observer,
136
- workflows: [...allWorkflows.values()],
150
+ const url = launchUi({
151
+ observer, workflows: allWorkflows, agents,
137
152
  onRun: (name) => runWorkflowFn(name, undefined),
138
- config: { dryRun: pc?.dryRun, agent: { model: pc?.agent?.model, effort: pc?.agent?.effort } },
139
- agents: [...agents.values()],
153
+ dryRun: pc?.dryRun,
154
+ agentDefaults: { model: pc?.agent?.model, effort: pc?.agent?.effort },
140
155
  });
141
- const url = `http://127.0.0.1:${actualPort}`;
142
- openBrowser(url);
143
- console.log(`\n▶ agentic-surfaces — ${url}`);
156
+ console.log(`\n▶ agentic-surfaces ${VERSION} — ${url}`);
144
157
  console.log(` project: ${dir} · ${allWorkflows.size} workflow(s) · Ctrl-C to exit`);
145
158
  await new Promise(() => { }); // serve until interrupted
146
159
  return 0;
@@ -171,10 +184,16 @@ export async function run(argv) {
171
184
  }
172
185
  const agents = loadAgents(findProjectDir(dirname(file)) ?? dir);
173
186
  const registry = defaultRegistry();
174
- const session = rest.includes("--ui") ? startUi() : undefined;
175
- const observer = session?.observer;
187
+ const ui = rest.includes("--ui");
188
+ const observer = ui ? new StreamingObserver() : undefined;
176
189
  const runWorkflowFn = buildWorkflowRunner({ workflows: allWorkflows, registry, services: { ...services, agents }, observer });
177
190
  const servicesWithRunner = { ...services, agents, runWorkflow: runWorkflowFn };
191
+ const url = ui ? launchUi({
192
+ observer: observer, workflows: allWorkflows, agents,
193
+ onRun: (name) => runWorkflowFn(name, undefined),
194
+ dryRun: pc?.dryRun,
195
+ agentDefaults: { model: pc?.agent?.model, effort: pc?.agent?.effort },
196
+ }) : undefined;
178
197
  // A run error must NOT tear down the --ui server: the failure is already
179
198
  // streamed to the dashboard (the failed node + run), so keep serving so it
180
199
  // stays inspectable. Without --ui, an error still exits non-zero.
@@ -187,8 +206,8 @@ export async function run(argv) {
187
206
  failed = true;
188
207
  console.error("run failed:", err instanceof Error ? err.message : String(err));
189
208
  }
190
- if (session) {
191
- console.log(`\n▶ Dashboard live at ${session.url} — Ctrl-C to exit${failed ? " (run failed — see the dashboard)" : ""}`);
209
+ if (url) {
210
+ console.log(`\n▶ agentic-surfaces ${VERSION} ${url} — Ctrl-C to exit${failed ? " (run failed — see the dashboard)" : ""}`);
192
211
  await new Promise(() => { }); // keep the server up so the run stays viewable
193
212
  }
194
213
  return failed ? 1 : 0;
@@ -209,8 +228,8 @@ export async function run(argv) {
209
228
  }
210
229
  const agents = loadAgents(dir);
211
230
  const registry = defaultRegistry();
212
- const session = rest.includes("--ui") ? startUi() : undefined;
213
- const observer = session?.observer;
231
+ const ui = rest.includes("--ui");
232
+ const observer = ui ? new StreamingObserver() : undefined;
214
233
  const runWorkflowFn = buildWorkflowRunner({ workflows: allWorkflows, registry, services: { ...services, agents }, observer });
215
234
  const servicesWithRunner = { ...services, agents, runWorkflow: runWorkflowFn };
216
235
  const sched = new Scheduler(servicesWithRunner, registry, observer);
@@ -218,8 +237,15 @@ export async function run(argv) {
218
237
  sched.add(w);
219
238
  sched.start();
220
239
  console.log("scheduler started; watching", workflowsDir);
221
- if (session)
222
- console.log(`▶ Dashboard live at ${session.url}`);
240
+ if (ui) {
241
+ const url = launchUi({
242
+ observer: observer, workflows: allWorkflows, agents,
243
+ onRun: (name) => runWorkflowFn(name, undefined),
244
+ dryRun: pc?.dryRun,
245
+ agentDefaults: { model: pc?.agent?.model, effort: pc?.agent?.effort },
246
+ });
247
+ console.log(`▶ agentic-surfaces ${VERSION} — ${url}`);
248
+ }
223
249
  return 0;
224
250
  }
225
251
  console.error("usage: flow <validate|run|start> [workflow|projectDir] [--ui] [--fake]");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentic-surfaces/cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
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.9",
25
- "@agentic-surfaces/agent": "0.1.9",
26
- "@agentic-surfaces/server": "0.1.9"
24
+ "@agentic-surfaces/core": "0.1.10",
25
+ "@agentic-surfaces/agent": "0.1.10",
26
+ "@agentic-surfaces/server": "0.1.10"
27
27
  },
28
28
  "scripts": {
29
29
  "build": "tsc -b",