@nylorun/core 0.7.0-beta → 0.9.0-beta

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 (61) hide show
  1. package/CHANGELOG.md +249 -0
  2. package/dist/compatibility.d.ts +42 -4
  3. package/dist/compatibility.js +65 -3
  4. package/dist/contracts.d.ts +2165 -328
  5. package/dist/contracts.js +1246 -100
  6. package/dist/define.d.ts +13 -5
  7. package/dist/define.js +7 -2
  8. package/dist/definition/assemble.js +16 -14
  9. package/dist/definition/bind-tool.js +1 -0
  10. package/dist/definition/bound.d.ts +2 -0
  11. package/dist/definition/builder.d.ts +116 -16
  12. package/dist/definition/builder.js +330 -53
  13. package/dist/definition/capability.d.ts +55 -0
  14. package/dist/definition/capability.js +104 -0
  15. package/dist/definition/declaration.js +6 -2
  16. package/dist/definition/delegate.d.ts +25 -4
  17. package/dist/definition/delegate.js +34 -6
  18. package/dist/definition/flow/compile.d.ts +23 -0
  19. package/dist/definition/flow/compile.js +274 -0
  20. package/dist/definition/flow/from.d.ts +11 -0
  21. package/dist/definition/flow/from.js +78 -0
  22. package/dist/definition/flow/index.d.ts +11 -0
  23. package/dist/definition/flow/index.js +11 -0
  24. package/dist/definition/flow/paths.d.ts +60 -0
  25. package/dist/definition/flow/paths.js +90 -0
  26. package/dist/definition/flow/spec.d.ts +66 -0
  27. package/dist/definition/flow/spec.js +130 -0
  28. package/dist/definition/flow/types.d.ts +157 -0
  29. package/dist/definition/flow/types.js +1 -0
  30. package/dist/definition/from.js +5 -1
  31. package/dist/definition/helpers.d.ts +1 -16
  32. package/dist/definition/helpers.js +1 -30
  33. package/dist/definition/mcp.d.ts +37 -0
  34. package/dist/definition/mcp.js +81 -0
  35. package/dist/definition/model-failure.d.ts +4 -0
  36. package/dist/definition/model-failure.js +22 -0
  37. package/dist/definition/sandbox-capability.d.ts +12 -0
  38. package/dist/definition/sandbox-capability.js +33 -0
  39. package/dist/definition/schema.js +3 -0
  40. package/dist/definition/workflow/build.d.ts +3 -13
  41. package/dist/definition/workflow/build.js +3 -25
  42. package/dist/definition/workflow/chain.js +0 -1
  43. package/dist/definition/workflow/loop.js +2 -4
  44. package/dist/definition/workflow/map.js +0 -1
  45. package/dist/definition/workflow/parallel.js +0 -1
  46. package/dist/definition/workflow/runnable.d.ts +13 -5
  47. package/dist/definition/workflow/runnable.js +11 -41
  48. package/dist/definition/workflow/switch.js +0 -2
  49. package/dist/errors.d.ts +3 -1
  50. package/dist/types/manifest.d.ts +4 -2
  51. package/dist/types/middleware.d.ts +1 -3
  52. package/dist/types/model.d.ts +32 -1
  53. package/dist/types/observe.d.ts +7 -1
  54. package/dist/types/tool.d.ts +6 -0
  55. package/dist/types/transcript.d.ts +14 -1
  56. package/dist/types/workflow.d.ts +72 -3
  57. package/dist/utils/deprecate.d.ts +3 -0
  58. package/dist/utils/deprecate.js +25 -0
  59. package/dist/utils/sandbox.d.ts +0 -4
  60. package/dist/utils/sandbox.js +0 -16
  61. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import type { AgentBinding } from "../definition/binding.js";
2
2
  import type { BoundToolDefinition } from "../definition/bound.js";
3
3
  import type { JsonObject, JsonValue } from "./shared.js";
4
- import type { SandboxManifest } from "./manifest.js";
4
+ import type { AgentManifest, SandboxManifest } from "./manifest.js";
5
5
  /** Loop verify outcome: pass, or fail with required feedback. */
6
6
  export type Verdict = {
7
7
  readonly pass: true;
@@ -72,14 +72,83 @@ export interface WorkflowSlotNode {
72
72
  };
73
73
  }
74
74
  export type WorkflowNode = WorkflowAgentNode | WorkflowToolNode | WorkflowChainNode | WorkflowSwitchNode | WorkflowParallelNode | WorkflowMapNode | WorkflowLoopNode | WorkflowSlotNode;
75
- /** Wire document for a workflow definition. Missing `kind` is never a workflow. */
76
- export interface WorkflowManifest {
75
+ /** Workflow manifest v1: control nodes carry ids, and agents are resolved from the registry. */
76
+ export interface WorkflowManifestV1 {
77
77
  readonly kind: "workflow";
78
78
  readonly workflowSchemaVersion: 1;
79
79
  readonly id: string;
80
80
  readonly root: WorkflowNode;
81
81
  readonly sandbox?: SandboxManifest;
82
82
  }
83
+ /**
84
+ * Fields every v2 node may carry. `id` names the stage: for an agent or tool it
85
+ * replaces the leaf's path part, for a control node it is the stage key and the
86
+ * `results` key. `input` marks a function that reshapes what the node receives.
87
+ */
88
+ export interface WorkflowNodeOptionsV2 {
89
+ readonly id?: string;
90
+ readonly input?: WorkflowFnRef;
91
+ }
92
+ /** Agent leaf, or a nested flow agent: a key of the enclosing manifest's `agents`. */
93
+ export interface WorkflowAgentNodeV2 extends WorkflowNodeOptionsV2 {
94
+ readonly agent: string;
95
+ }
96
+ export interface WorkflowToolNodeV2 extends WorkflowNodeOptionsV2 {
97
+ readonly tool: WorkflowToolNode["tool"];
98
+ }
99
+ export interface WorkflowChainNodeV2 extends WorkflowNodeOptionsV2 {
100
+ readonly chain: readonly WorkflowNodeV2[];
101
+ }
102
+ export interface WorkflowSwitchNodeV2 extends WorkflowNodeOptionsV2 {
103
+ readonly switch: {
104
+ readonly on: WorkflowFnRef;
105
+ readonly cases: Readonly<Record<string, WorkflowNodeV2>>;
106
+ readonly default?: WorkflowNodeV2;
107
+ };
108
+ }
109
+ export interface WorkflowParallelNodeV2 extends WorkflowNodeOptionsV2 {
110
+ readonly parallel: Readonly<Record<string, WorkflowNodeV2>>;
111
+ }
112
+ /** Runs `each` once per item of its input, which must be an array. */
113
+ export interface WorkflowMapNodeV2 extends WorkflowNodeOptionsV2 {
114
+ readonly map: {
115
+ readonly each: WorkflowNodeV2;
116
+ };
117
+ }
118
+ /**
119
+ * Runs `run`, judges it with `verify`, then retries or stops. Without `decide`, a pass
120
+ * returns the output and a fail retries with the feedback, up to `max` attempts.
121
+ */
122
+ export interface WorkflowLoopNodeV2 extends WorkflowNodeOptionsV2 {
123
+ readonly loop: {
124
+ readonly run: WorkflowNodeV2;
125
+ readonly verify: WorkflowFnRef | WorkflowAgentNodeV2;
126
+ readonly max?: number;
127
+ readonly decide?: WorkflowFnRef;
128
+ };
129
+ }
130
+ export type WorkflowNodeV2 = WorkflowAgentNodeV2 | WorkflowToolNodeV2 | WorkflowChainNodeV2 | WorkflowSwitchNodeV2 | WorkflowParallelNodeV2 | WorkflowMapNodeV2 | WorkflowLoopNodeV2;
131
+ /**
132
+ * Workflow manifest v2: a flow agent. Its leaf agents are embedded in `agents`, so one
133
+ * manifest hash covers the whole agent, and session paths come from the leaves.
134
+ */
135
+ export interface WorkflowManifestV2 {
136
+ readonly kind: "workflow";
137
+ readonly workflowSchemaVersion: 2;
138
+ readonly id: string;
139
+ readonly name?: string;
140
+ readonly description?: string;
141
+ readonly metadata?: JsonObject;
142
+ readonly inputSchema?: JsonObject;
143
+ readonly outputSchema?: JsonObject;
144
+ /** The sandbox every leaf that declares one shares. */
145
+ readonly sandbox?: SandboxManifest;
146
+ readonly root: WorkflowNodeV2;
147
+ /** Every agent the flow runs, by id: ReAct agents (v4) and nested flow agents (v2). */
148
+ readonly agents: Readonly<Record<string, AgentManifest | WorkflowManifestV2>>;
149
+ }
150
+ /** Wire document for a workflow definition. Missing `kind` is never a workflow. */
151
+ export type WorkflowManifest = WorkflowManifestV1 | WorkflowManifestV2;
83
152
  /**
84
153
  * Local implementation for a node key: a tool node, a pure `fn`, or a Loop `verify` function.
85
154
  * Functions are never serialized.
@@ -0,0 +1,3 @@
1
+ export declare function deprecate(code: string, message: string): void;
2
+ /** Test hook: forget which codes have warned. */
3
+ export declare function resetDeprecationWarnings(): void;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Warn once per code that an authoring form is deprecated.
3
+ *
4
+ * Uses `process.emitWarning` when a Node-like `process` exists, so `--no-deprecation`
5
+ * and `process.noDeprecation` silence it; otherwise falls back to `console.warn`.
6
+ * Core imports no `node:` module, so this reads `process` from `globalThis`.
7
+ */
8
+ const warned = new Set();
9
+ export function deprecate(code, message) {
10
+ if (warned.has(code))
11
+ return;
12
+ warned.add(code);
13
+ const proc = globalThis.process;
14
+ if (proc?.noDeprecation)
15
+ return;
16
+ if (typeof proc?.emitWarning === "function") {
17
+ proc.emitWarning(message, { type: "DeprecationWarning", code });
18
+ return;
19
+ }
20
+ console.warn(`DeprecationWarning [${code}]: ${message}`);
21
+ }
22
+ /** Test hook: forget which codes have warned. */
23
+ export function resetDeprecationWarnings() {
24
+ warned.clear();
25
+ }
@@ -4,10 +4,6 @@ export declare const SANDBOX_TOOL_NAMES: readonly ["bash", "read", "write", "edi
4
4
  export type SandboxToolName = (typeof SANDBOX_TOOL_NAMES)[number];
5
5
  export declare const SANDBOX_WORKSPACE = "/workspace";
6
6
  export declare const SANDBOX_NETWORK_PRESETS: readonly ["none", "dev", "open"];
7
- /** Manifest fields this version implements. Anything else is rejected with a teaching error. */
8
- export declare const SANDBOX_FIELDS: readonly ["image", "network", "resources", "idle"];
9
- /** Fields from the sandbox design that later versions will accept. */
10
- export declare const SANDBOX_DEFERRED_FIELDS: readonly ["setup", "setupKey", "files", "secrets", "mount", "onStart", "scope", "isolation", "own", "tools", "snapshot"];
11
7
  export declare function isSandboxToolName(name: string): name is SandboxToolName;
12
8
  /** Parse "15m", "30s", "1h" into milliseconds. Returns undefined when invalid. */
13
9
  export declare function parseSandboxDuration(value: string): number | undefined;
@@ -10,22 +10,6 @@ export const SANDBOX_TOOL_NAMES = Object.freeze([
10
10
  ]);
11
11
  export const SANDBOX_WORKSPACE = "/workspace";
12
12
  export const SANDBOX_NETWORK_PRESETS = Object.freeze(["none", "dev", "open"]);
13
- /** Manifest fields this version implements. Anything else is rejected with a teaching error. */
14
- export const SANDBOX_FIELDS = Object.freeze(["image", "network", "resources", "idle"]);
15
- /** Fields from the sandbox design that later versions will accept. */
16
- export const SANDBOX_DEFERRED_FIELDS = Object.freeze([
17
- "setup",
18
- "setupKey",
19
- "files",
20
- "secrets",
21
- "mount",
22
- "onStart",
23
- "scope",
24
- "isolation",
25
- "own",
26
- "tools",
27
- "snapshot",
28
- ]);
29
13
  export function isSandboxToolName(name) {
30
14
  return SANDBOX_TOOL_NAMES.includes(name);
31
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/core",
3
- "version": "0.7.0-beta",
3
+ "version": "0.9.0-beta",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Shared agent definitions and wire contracts",