@sweny-ai/core 0.1.157 → 0.1.158

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/types.d.ts CHANGED
@@ -3,6 +3,7 @@ export type { WorkflowInputs, WorkflowInputField, WorkflowInputType, InputValida
3
3
  export { WORKFLOW_INPUT_TYPES } from "./inputs.js";
4
4
  import type { Source as _Source, ResolvedSource as _ResolvedSource } from "./sources.js";
5
5
  import type { ToolClass } from "./harness/types.js";
6
+ import type { Budget, BudgetOverrun } from "./budget.js";
6
7
  export type JSONSchema = Record<string, unknown>;
7
8
  /** Context passed to tool handlers at execution time */
8
9
  export interface ToolContext {
@@ -294,6 +295,12 @@ export interface Node {
294
295
  output?: JSONSchema;
295
296
  /** Max AI model turns for this node. When absent, the executor's default applies. */
296
297
  max_turns?: number;
298
+ /**
299
+ * Spend ceiling for one visit to this node (all retry attempts included),
300
+ * in input + output tokens and/or reported USD. Never above the workflow's
301
+ * `budget`. A crossing stops the agent and fails the node (see `budget.ts`).
302
+ */
303
+ budget?: Budget;
297
304
  /** Per-node directives. Additive by default; set `{ only: true, sources: [...] }` to block cascade. */
298
305
  rules?: NodeSources;
299
306
  /** Per-node background knowledge. Additive by default; set `{ only: true, sources: [...] }` to block cascade. */
@@ -523,6 +530,11 @@ export interface Workflow {
523
530
  model?: string;
524
531
  /** Soft cap on expected judge calls per workflow run. Warning at load time when exceeded. */
525
532
  judge_budget?: number;
533
+ /**
534
+ * Spend ceiling for the whole run and for every node (#449). A node's own
535
+ * `budget` may only narrow it. The CLI's `--max-tokens` / `--max-cost` tighten it.
536
+ */
537
+ budget?: Budget;
526
538
  /**
527
539
  * What prior results a node's prompt receives (#337). `bounded` (default):
528
540
  * only nodes it can depend on (graph ancestors, nodes named by `requires`
@@ -612,6 +624,12 @@ export interface NodeResult {
612
624
  degraded?: string[];
613
625
  /** Safe outputs (#365): what the write stage did with each intent. Absent when the node declares none. */
614
626
  outputs?: SafeOutputReceipt[];
627
+ /**
628
+ * Set when this node's spend crossed a token or cost budget (#449), or when
629
+ * the run's budget was already spent before it could start. The node is
630
+ * `failed`, `fail_soft` and `on_fail: continue` do not apply, and the run halts.
631
+ */
632
+ budget?: BudgetOverrun;
615
633
  }
616
634
  export interface ToolCall {
617
635
  tool: string;
@@ -780,6 +798,13 @@ export interface Claude {
780
798
  * carry the same read-only and native-deny intent.
781
799
  */
782
800
  policy?: import("./harness/types.js").NodePolicy;
801
+ /**
802
+ * Live spend (#449): a harness that declares `capabilities.usage.live`
803
+ * calls this with the run's cumulative usage as it grows. The executor
804
+ * aborts `signal` when a budget is crossed. Harnesses that report usage
805
+ * only at the end never call it.
806
+ */
807
+ onUsage?: (usage: NodeUsage) => void;
783
808
  }): Promise<NodeResult>;
784
809
  /**
785
810
  * Evaluate a routing condition — pick one of N choices.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sweny-ai/core",
3
- "version": "0.1.157",
3
+ "version": "0.1.158",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "sweny": "./dist/cli/main.js"