@agentic-surfaces/core 0.1.26 → 0.1.27

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.
@@ -79,11 +79,11 @@ export const agentHandler = {
79
79
  else
80
80
  throw new Error(`agent ${cfg.agent} returned an off-allowlist command: ${String(raw)}`);
81
81
  }
82
- return { output: { command, text: result.text, skillsUsed: result.skillsUsed, toolsUsed: result.toolsUsed } };
82
+ return { output: { command, text: result.text, skillsUsed: result.skillsUsed, toolsUsed: result.toolsUsed, usage: result.usage } };
83
83
  }
84
84
  // Inline decision schema: surface its fields at the top level (0.1.7 behaviour).
85
85
  if (cfg.decision && result.data && typeof result.data === "object" && !Array.isArray(result.data)) {
86
- return { output: { ...result.data, text: result.text, skillsUsed: result.skillsUsed, toolsUsed: result.toolsUsed } };
86
+ return { output: { ...result.data, text: result.text, skillsUsed: result.skillsUsed, toolsUsed: result.toolsUsed, usage: result.usage } };
87
87
  }
88
88
  return { output: result };
89
89
  },
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from "./cache.js";
7
7
  export * from "./observer.js";
8
8
  export * from "./secrets.js";
9
9
  export * from "./project-config.js";
10
+ export * from "./pause.js";
10
11
  export * from "./agents.js";
11
12
  export * from "./handlers/foreach.js";
12
13
  export * from "./handlers/run-workflow.js";
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ export * from "./cache.js";
7
7
  export * from "./observer.js";
8
8
  export * from "./secrets.js";
9
9
  export * from "./project-config.js";
10
+ export * from "./pause.js";
10
11
  export * from "./agents.js";
11
12
  export * from "./handlers/foreach.js";
12
13
  export * from "./handlers/run-workflow.js";
@@ -0,0 +1,21 @@
1
+ /**
2
+ * A platform-wide play/pause switch. When paused, the scheduler stops firing cron workflows
3
+ * (in-flight runs finish; new scheduled fires are skipped). It's a master switch for the
4
+ * autonomous loop — manual dashboard runs still work.
5
+ */
6
+ export interface PauseState {
7
+ isPaused(): boolean;
8
+ pause(): void;
9
+ resume(): void;
10
+ }
11
+ /**
12
+ * File-backed pause state: the presence of a sentinel file (default `.flow-paused`) means paused.
13
+ * A file (not in-memory) so the state survives a `start --watch` restart and is inspectable.
14
+ */
15
+ export declare class FilePauseState implements PauseState {
16
+ private readonly path;
17
+ constructor(path?: string);
18
+ isPaused(): boolean;
19
+ pause(): void;
20
+ resume(): void;
21
+ }
package/dist/pause.js ADDED
@@ -0,0 +1,26 @@
1
+ import { existsSync, writeFileSync, rmSync } from "node:fs";
2
+ /**
3
+ * File-backed pause state: the presence of a sentinel file (default `.flow-paused`) means paused.
4
+ * A file (not in-memory) so the state survives a `start --watch` restart and is inspectable.
5
+ */
6
+ export class FilePauseState {
7
+ path;
8
+ constructor(path = ".flow-paused") {
9
+ this.path = path;
10
+ }
11
+ isPaused() {
12
+ return existsSync(this.path);
13
+ }
14
+ pause() {
15
+ if (!this.isPaused())
16
+ writeFileSync(this.path, `paused ${new Date().toISOString()}\n`);
17
+ }
18
+ resume() {
19
+ try {
20
+ rmSync(this.path);
21
+ }
22
+ catch {
23
+ /* already gone — nothing to do */
24
+ }
25
+ }
26
+ }
@@ -1,4 +1,5 @@
1
1
  import { HandlerRegistry } from "./registry.js";
2
+ import type { PauseState } from "./pause.js";
2
3
  import type { RunObserver, Services, Workflow } from "./types.js";
3
4
  export declare function defaultRegistry(): HandlerRegistry;
4
5
  export declare function runWorkflowOnce(workflow: Workflow, opts: {
@@ -19,11 +20,15 @@ export declare class Scheduler {
19
20
  private services;
20
21
  private registry;
21
22
  private observer;
23
+ /** When set + paused, scheduled cron fires are skipped (the platform-wide play/pause switch). */
24
+ private pause?;
22
25
  private crons;
23
26
  private active;
24
27
  private pending;
25
28
  private workflows;
26
- constructor(services: Services, registry?: HandlerRegistry, observer?: RunObserver);
29
+ constructor(services: Services, registry?: HandlerRegistry, observer?: RunObserver,
30
+ /** When set + paused, scheduled cron fires are skipped (the platform-wide play/pause switch). */
31
+ pause?: PauseState | undefined);
27
32
  add(workflow: Workflow): void;
28
33
  start(): void;
29
34
  private enqueue;
package/dist/scheduler.js CHANGED
@@ -58,14 +58,18 @@ export class Scheduler {
58
58
  services;
59
59
  registry;
60
60
  observer;
61
+ pause;
61
62
  crons = [];
62
63
  active = 0;
63
64
  pending = [];
64
65
  workflows = [];
65
- constructor(services, registry = defaultRegistry(), observer = new ConsoleObserver()) {
66
+ constructor(services, registry = defaultRegistry(), observer = new ConsoleObserver(),
67
+ /** When set + paused, scheduled cron fires are skipped (the platform-wide play/pause switch). */
68
+ pause) {
66
69
  this.services = services;
67
70
  this.registry = registry;
68
71
  this.observer = observer;
72
+ this.pause = pause;
69
73
  }
70
74
  add(workflow) { this.workflows.push(workflow); }
71
75
  start() {
@@ -74,14 +78,21 @@ export class Scheduler {
74
78
  if (node.type !== "trigger.cron")
75
79
  continue;
76
80
  const pattern = String(node.config.cron);
77
- this.crons.push(new Cron(pattern, () => this.enqueue(() => runWorkflowOnce(wf, { registry: this.registry, services: this.services, triggerNodeId: node.id, observer: this.observer })
78
- .then(() => { })
79
- // A failed scheduled run must not crash the scheduler (unhandled
80
- // rejection). The failure is already reported to the observer; log
81
- // and carry on so the next trigger still fires.
82
- .catch((err) => this.services.logger?.error?.("scheduled run failed", {
83
- workflow: wf.name, error: err instanceof Error ? err.message : String(err),
84
- })))));
81
+ this.crons.push(new Cron(pattern, () => {
82
+ // Platform-wide pause: skip this scheduled fire (in-flight runs are unaffected).
83
+ if (this.pause?.isPaused()) {
84
+ this.services.logger?.info?.(`paused skipping scheduled run of ${wf.name}`);
85
+ return;
86
+ }
87
+ this.enqueue(() => runWorkflowOnce(wf, { registry: this.registry, services: this.services, triggerNodeId: node.id, observer: this.observer })
88
+ .then(() => { })
89
+ // A failed scheduled run must not crash the scheduler (unhandled
90
+ // rejection). The failure is already reported to the observer; log
91
+ // and carry on so the next trigger still fires.
92
+ .catch((err) => this.services.logger?.error?.("scheduled run failed", {
93
+ workflow: wf.name, error: err instanceof Error ? err.message : String(err),
94
+ })));
95
+ }));
85
96
  }
86
97
  }
87
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentic-surfaces/core",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -24,7 +24,7 @@
24
24
  "jsonata": "^2.2.1",
25
25
  "yaml": "^2.9.0",
26
26
  "zod": "^4.4.3",
27
- "@agentic-surfaces/agent": "0.1.26"
27
+ "@agentic-surfaces/agent": "0.1.27"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/better-sqlite3": "^7.6.13",