@sweny-ai/core 0.1.61 → 0.1.63

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/schema.js CHANGED
@@ -63,11 +63,26 @@ export const skillZ = z
63
63
  .refine((s) => s.tools.length > 0 || s.instruction || s.mcp, {
64
64
  message: "Skill must provide at least one of: tools, instruction, or mcp",
65
65
  });
66
+ /**
67
+ * NodeSources: either an array of Sources (additive — inherits cascade)
68
+ * or an object `{ only?: boolean, sources: Source[] }` where `only: true`
69
+ * blocks the cascade for that field.
70
+ */
71
+ export const nodeSourcesZ = z.union([
72
+ z.array(sourceZ),
73
+ z.object({
74
+ only: z.boolean().optional(),
75
+ sources: z.array(sourceZ),
76
+ }),
77
+ ]);
66
78
  export const nodeZ = z.object({
67
79
  name: z.string().min(1),
68
80
  instruction: sourceZ,
69
81
  skills: z.array(z.string()).default([]),
70
82
  output: jsonSchemaZ.optional(),
83
+ max_turns: z.number().int().min(1).optional(),
84
+ rules: nodeSourcesZ.optional(),
85
+ context: nodeSourcesZ.optional(),
71
86
  });
72
87
  export const edgeZ = z.object({
73
88
  from: z.string().min(1),
@@ -83,6 +98,8 @@ export const workflowZ = z.object({
83
98
  edges: z.array(edgeZ),
84
99
  entry: z.string().min(1),
85
100
  skills: z.record(skillDefinitionZ).default({}),
101
+ rules: z.array(sourceZ).optional(),
102
+ context: z.array(sourceZ).optional(),
86
103
  });
87
104
  /** Parse + validate a raw object as a Workflow. Throws on invalid input. */
88
105
  export function parseWorkflow(raw) {
@@ -268,12 +285,38 @@ export const workflowJsonSchema = {
268
285
  type: "object",
269
286
  required: ["id", "name", "nodes", "edges", "entry"],
270
287
  additionalProperties: false,
271
- $defs: { Source: sourceJsonSchema },
288
+ $defs: {
289
+ Source: sourceJsonSchema,
290
+ NodeSources: {
291
+ oneOf: [
292
+ { type: "array", items: { $ref: "#/$defs/Source" } },
293
+ {
294
+ type: "object",
295
+ required: ["sources"],
296
+ additionalProperties: false,
297
+ properties: {
298
+ only: { type: "boolean" },
299
+ sources: { type: "array", items: { $ref: "#/$defs/Source" } },
300
+ },
301
+ },
302
+ ],
303
+ },
304
+ },
272
305
  properties: {
273
306
  id: { type: "string", minLength: 1 },
274
307
  name: { type: "string", minLength: 1 },
275
308
  description: { type: "string" },
276
309
  entry: { type: "string", minLength: 1, description: "ID of the entry node" },
310
+ rules: {
311
+ type: "array",
312
+ items: { $ref: "#/$defs/Source" },
313
+ description: "Directives prepended to every node's instruction.",
314
+ },
315
+ context: {
316
+ type: "array",
317
+ items: { $ref: "#/$defs/Source" },
318
+ description: "Background knowledge prepended to every node's instruction.",
319
+ },
277
320
  nodes: {
278
321
  type: "object",
279
322
  additionalProperties: {
@@ -292,6 +335,19 @@ export const workflowJsonSchema = {
292
335
  type: "object",
293
336
  description: "Optional JSON Schema for structured output",
294
337
  },
338
+ max_turns: {
339
+ type: "integer",
340
+ minimum: 1,
341
+ description: "Max AI model turns for this node. When absent, the executor's default applies.",
342
+ },
343
+ rules: {
344
+ $ref: "#/$defs/NodeSources",
345
+ description: "Per-node rules. Additive by default; set { only: true } to block cascade.",
346
+ },
347
+ context: {
348
+ $ref: "#/$defs/NodeSources",
349
+ description: "Per-node context. Additive by default; set { only: true } to block cascade.",
350
+ },
295
351
  },
296
352
  },
297
353
  },
package/dist/types.d.ts CHANGED
@@ -37,6 +37,18 @@ export interface Skill {
37
37
  /** External MCP server definition wired for nodes referencing this skill. */
38
38
  mcp?: McpServerConfig;
39
39
  }
40
+ /**
41
+ * Per-node rules or context.
42
+ *
43
+ * - Array form (additive): inherits workflow/runtime sources AND adds these.
44
+ * - Object form: when `only: true`, blocks the cascade for this field and
45
+ * uses only `sources`. When `only` is absent/false, behaves like the
46
+ * array form.
47
+ */
48
+ export type NodeSources = _Source[] | {
49
+ only?: boolean;
50
+ sources: _Source[];
51
+ };
40
52
  /** A node in the workflow DAG */
41
53
  export interface Node {
42
54
  /** Human-readable name */
@@ -47,6 +59,12 @@ export interface Node {
47
59
  skills: string[];
48
60
  /** Optional structured output schema */
49
61
  output?: JSONSchema;
62
+ /** Max AI model turns for this node. When absent, the executor's default applies. */
63
+ max_turns?: number;
64
+ /** Per-node directives. Additive by default; set `{ only: true, sources: [...] }` to block cascade. */
65
+ rules?: NodeSources;
66
+ /** Per-node background knowledge. Additive by default; set `{ only: true, sources: [...] }` to block cascade. */
67
+ context?: NodeSources;
50
68
  }
51
69
  /** An edge connecting two nodes */
52
70
  export interface Edge {
@@ -66,6 +84,10 @@ export interface Workflow {
66
84
  edges: Edge[];
67
85
  entry: string;
68
86
  skills?: Record<string, SkillDefinition>;
87
+ /** Directives prepended to every node's instruction. Cascade into per-node rules. */
88
+ rules?: _Source[];
89
+ /** Background knowledge prepended to every node's instruction. Cascade into per-node context. */
90
+ context?: _Source[];
69
91
  }
70
92
  /**
71
93
  * Inline skill definition in a workflow's `skills` block.
@@ -170,6 +192,8 @@ export interface Claude {
170
192
  outputSchema?: JSONSchema;
171
193
  /** Called with status messages while Claude is working (tool name, etc.) */
172
194
  onProgress?: (message: string) => void;
195
+ /** Per-node turn limit. Overrides the client default when set. */
196
+ maxTurns?: number;
173
197
  }): Promise<NodeResult>;
174
198
  /** Evaluate a routing condition — pick one of N choices */
175
199
  evaluate(opts: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sweny-ai/core",
3
- "version": "0.1.61",
3
+ "version": "0.1.63",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "sweny": "./dist/cli/main.js"