agentflow-core 0.2.2 → 0.3.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/index.d.cts CHANGED
@@ -393,8 +393,72 @@ declare function runTraced(config: RunConfig): Promise<RunResult>;
393
393
  *
394
394
  * @module
395
395
  */
396
+
396
397
  declare function startLive(argv: string[]): void;
397
398
 
399
+ /**
400
+ * AgentFlow Watch — headless alert system for agent infrastructure.
401
+ *
402
+ * Polls directories for JSON/JSONL state files, detects status transitions
403
+ * (ok→error, stale, recovery), and sends alerts via Telegram, webhooks,
404
+ * shell commands, or stdout.
405
+ *
406
+ * @module
407
+ */
408
+ declare function startWatch(argv: string[]): void;
409
+
410
+ /**
411
+ * Type definitions for the `agentflow watch` alert system.
412
+ * @module
413
+ */
414
+ /** Alert condition parsed from --alert-on flags. */
415
+ type AlertCondition = {
416
+ readonly type: 'error';
417
+ } | {
418
+ readonly type: 'stale';
419
+ readonly durationMs: number;
420
+ } | {
421
+ readonly type: 'recovery';
422
+ } | {
423
+ readonly type: 'consecutive-errors';
424
+ readonly threshold: number;
425
+ };
426
+ /** Notification channel parsed from --notify flags. */
427
+ type NotifyChannel = {
428
+ readonly type: 'stdout';
429
+ } | {
430
+ readonly type: 'telegram';
431
+ readonly botToken: string;
432
+ readonly chatId: string;
433
+ } | {
434
+ readonly type: 'webhook';
435
+ readonly url: string;
436
+ } | {
437
+ readonly type: 'command';
438
+ readonly cmd: string;
439
+ };
440
+ /** Configuration for the watch command. */
441
+ interface WatchConfig {
442
+ readonly dirs: string[];
443
+ readonly recursive: boolean;
444
+ readonly pollIntervalMs: number;
445
+ readonly alertConditions: AlertCondition[];
446
+ readonly notifyChannels: NotifyChannel[];
447
+ readonly stateFilePath: string;
448
+ readonly cooldownMs: number;
449
+ }
450
+ /** Alert payload passed to notification channels. */
451
+ interface AlertPayload {
452
+ readonly agentId: string;
453
+ readonly condition: string;
454
+ readonly previousStatus: string;
455
+ readonly currentStatus: string;
456
+ readonly detail: string;
457
+ readonly file: string;
458
+ readonly timestamp: number;
459
+ readonly dirs: readonly string[];
460
+ }
461
+
398
462
  declare function groupByTraceId(graphs: ExecutionGraph[]): Map<string, ExecutionGraph[]>;
399
463
  declare function stitchTrace(graphs: ExecutionGraph[]): DistributedTrace;
400
464
  declare function getTraceTree(trace: DistributedTrace): ExecutionGraph[];
@@ -515,4 +579,4 @@ declare function getDepth(graph: ExecutionGraph): number;
515
579
  */
516
580
  declare function getStats(graph: ExecutionGraph): GraphStats;
517
581
 
518
- export { type Adapter, type AgentFlowConfig, type DistributedTrace, type EdgeType, type ExecutionEdge, type ExecutionGraph, type ExecutionNode, type GraphBuilder, type GraphStats, type GraphStatus, type MutableExecutionNode, type NodeStatus, type NodeType, type RunConfig, type RunResult, type StartNodeOptions, type TraceEvent, type TraceEventType, type Writer, createGraphBuilder, findWaitingOn, getChildren, getCriticalPath, getDepth, getDuration, getFailures, getHungNodes, getNode, getParent, getStats, getSubtree, getTraceTree, graphToJson, groupByTraceId, loadGraph, runTraced, startLive, stitchTrace };
582
+ export { type Adapter, type AgentFlowConfig, type AlertCondition, type AlertPayload, type DistributedTrace, type EdgeType, type ExecutionEdge, type ExecutionGraph, type ExecutionNode, type GraphBuilder, type GraphStats, type GraphStatus, type MutableExecutionNode, type NodeStatus, type NodeType, type NotifyChannel, type RunConfig, type RunResult, type StartNodeOptions, type TraceEvent, type TraceEventType, type WatchConfig, type Writer, createGraphBuilder, findWaitingOn, getChildren, getCriticalPath, getDepth, getDuration, getFailures, getHungNodes, getNode, getParent, getStats, getSubtree, getTraceTree, graphToJson, groupByTraceId, loadGraph, runTraced, startLive, startWatch, stitchTrace };
package/dist/index.d.ts CHANGED
@@ -393,8 +393,72 @@ declare function runTraced(config: RunConfig): Promise<RunResult>;
393
393
  *
394
394
  * @module
395
395
  */
396
+
396
397
  declare function startLive(argv: string[]): void;
397
398
 
399
+ /**
400
+ * AgentFlow Watch — headless alert system for agent infrastructure.
401
+ *
402
+ * Polls directories for JSON/JSONL state files, detects status transitions
403
+ * (ok→error, stale, recovery), and sends alerts via Telegram, webhooks,
404
+ * shell commands, or stdout.
405
+ *
406
+ * @module
407
+ */
408
+ declare function startWatch(argv: string[]): void;
409
+
410
+ /**
411
+ * Type definitions for the `agentflow watch` alert system.
412
+ * @module
413
+ */
414
+ /** Alert condition parsed from --alert-on flags. */
415
+ type AlertCondition = {
416
+ readonly type: 'error';
417
+ } | {
418
+ readonly type: 'stale';
419
+ readonly durationMs: number;
420
+ } | {
421
+ readonly type: 'recovery';
422
+ } | {
423
+ readonly type: 'consecutive-errors';
424
+ readonly threshold: number;
425
+ };
426
+ /** Notification channel parsed from --notify flags. */
427
+ type NotifyChannel = {
428
+ readonly type: 'stdout';
429
+ } | {
430
+ readonly type: 'telegram';
431
+ readonly botToken: string;
432
+ readonly chatId: string;
433
+ } | {
434
+ readonly type: 'webhook';
435
+ readonly url: string;
436
+ } | {
437
+ readonly type: 'command';
438
+ readonly cmd: string;
439
+ };
440
+ /** Configuration for the watch command. */
441
+ interface WatchConfig {
442
+ readonly dirs: string[];
443
+ readonly recursive: boolean;
444
+ readonly pollIntervalMs: number;
445
+ readonly alertConditions: AlertCondition[];
446
+ readonly notifyChannels: NotifyChannel[];
447
+ readonly stateFilePath: string;
448
+ readonly cooldownMs: number;
449
+ }
450
+ /** Alert payload passed to notification channels. */
451
+ interface AlertPayload {
452
+ readonly agentId: string;
453
+ readonly condition: string;
454
+ readonly previousStatus: string;
455
+ readonly currentStatus: string;
456
+ readonly detail: string;
457
+ readonly file: string;
458
+ readonly timestamp: number;
459
+ readonly dirs: readonly string[];
460
+ }
461
+
398
462
  declare function groupByTraceId(graphs: ExecutionGraph[]): Map<string, ExecutionGraph[]>;
399
463
  declare function stitchTrace(graphs: ExecutionGraph[]): DistributedTrace;
400
464
  declare function getTraceTree(trace: DistributedTrace): ExecutionGraph[];
@@ -515,4 +579,4 @@ declare function getDepth(graph: ExecutionGraph): number;
515
579
  */
516
580
  declare function getStats(graph: ExecutionGraph): GraphStats;
517
581
 
518
- export { type Adapter, type AgentFlowConfig, type DistributedTrace, type EdgeType, type ExecutionEdge, type ExecutionGraph, type ExecutionNode, type GraphBuilder, type GraphStats, type GraphStatus, type MutableExecutionNode, type NodeStatus, type NodeType, type RunConfig, type RunResult, type StartNodeOptions, type TraceEvent, type TraceEventType, type Writer, createGraphBuilder, findWaitingOn, getChildren, getCriticalPath, getDepth, getDuration, getFailures, getHungNodes, getNode, getParent, getStats, getSubtree, getTraceTree, graphToJson, groupByTraceId, loadGraph, runTraced, startLive, stitchTrace };
582
+ export { type Adapter, type AgentFlowConfig, type AlertCondition, type AlertPayload, type DistributedTrace, type EdgeType, type ExecutionEdge, type ExecutionGraph, type ExecutionNode, type GraphBuilder, type GraphStats, type GraphStatus, type MutableExecutionNode, type NodeStatus, type NodeType, type NotifyChannel, type RunConfig, type RunResult, type StartNodeOptions, type TraceEvent, type TraceEventType, type WatchConfig, type Writer, createGraphBuilder, findWaitingOn, getChildren, getCriticalPath, getDepth, getDuration, getFailures, getHungNodes, getNode, getParent, getStats, getSubtree, getTraceTree, graphToJson, groupByTraceId, loadGraph, runTraced, startLive, startWatch, stitchTrace };
package/dist/index.js CHANGED
@@ -17,8 +17,9 @@ import {
17
17
  loadGraph,
18
18
  runTraced,
19
19
  startLive,
20
+ startWatch,
20
21
  stitchTrace
21
- } from "./chunk-WOJEID7V.js";
22
+ } from "./chunk-NPH34CAL.js";
22
23
  export {
23
24
  createGraphBuilder,
24
25
  findWaitingOn,
@@ -38,5 +39,6 @@ export {
38
39
  loadGraph,
39
40
  runTraced,
40
41
  startLive,
42
+ startWatch,
41
43
  stitchTrace
42
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentflow-core",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Universal execution tracing for AI agent systems",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",