@nylorun/core 0.3.0-beta → 0.5.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 (58) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/compatibility.d.ts +48 -1
  3. package/dist/compatibility.js +192 -1
  4. package/dist/contracts.d.ts +562 -19
  5. package/dist/contracts.js +442 -29
  6. package/dist/define.d.ts +9 -3
  7. package/dist/define.js +3 -0
  8. package/dist/definition/assemble.js +35 -0
  9. package/dist/definition/bind-tool.js +3 -0
  10. package/dist/definition/bound.d.ts +3 -0
  11. package/dist/definition/builder.d.ts +5 -5
  12. package/dist/definition/declaration.d.ts +2 -2
  13. package/dist/definition/declaration.js +13 -1
  14. package/dist/definition/delegate.d.ts +35 -0
  15. package/dist/definition/delegate.js +72 -0
  16. package/dist/definition/from.js +15 -2
  17. package/dist/definition/helpers.d.ts +1 -1
  18. package/dist/definition/helpers.js +8 -1
  19. package/dist/definition/manifest.js +3 -0
  20. package/dist/definition/variant.d.ts +7 -0
  21. package/dist/definition/variant.js +87 -0
  22. package/dist/definition/workflow/build.d.ts +38 -0
  23. package/dist/definition/workflow/build.js +62 -0
  24. package/dist/definition/workflow/chain.d.ts +49 -0
  25. package/dist/definition/workflow/chain.js +41 -0
  26. package/dist/definition/workflow/diagnostics.d.ts +14 -0
  27. package/dist/definition/workflow/diagnostics.js +38 -0
  28. package/dist/definition/workflow/index.d.ts +18 -0
  29. package/dist/definition/workflow/index.js +10 -0
  30. package/dist/definition/workflow/loop.d.ts +54 -0
  31. package/dist/definition/workflow/loop.js +102 -0
  32. package/dist/definition/workflow/map.d.ts +17 -0
  33. package/dist/definition/workflow/map.js +46 -0
  34. package/dist/definition/workflow/parallel.d.ts +19 -0
  35. package/dist/definition/workflow/parallel.js +37 -0
  36. package/dist/definition/workflow/patch.d.ts +11 -0
  37. package/dist/definition/workflow/patch.js +45 -0
  38. package/dist/definition/workflow/runnable.d.ts +40 -0
  39. package/dist/definition/workflow/runnable.js +251 -0
  40. package/dist/definition/workflow/slot.d.ts +23 -0
  41. package/dist/definition/workflow/slot.js +16 -0
  42. package/dist/definition/workflow/switch.d.ts +26 -0
  43. package/dist/definition/workflow/switch.js +66 -0
  44. package/dist/definition/workflow/types.d.ts +25 -0
  45. package/dist/definition/workflow/types.js +7 -0
  46. package/dist/definition/workflow/verdict.d.ts +20 -0
  47. package/dist/definition/workflow/verdict.js +25 -0
  48. package/dist/index.d.ts +1 -0
  49. package/dist/types/agent.d.ts +5 -0
  50. package/dist/types/manifest.d.ts +5 -0
  51. package/dist/types/middleware.d.ts +5 -0
  52. package/dist/types/observe.d.ts +87 -1
  53. package/dist/types/tool.d.ts +11 -0
  54. package/dist/types/workflow.d.ts +106 -0
  55. package/dist/types/workflow.js +1 -0
  56. package/dist/utils/hash.d.ts +3 -2
  57. package/dist/utils/hash.js +1 -1
  58. package/package.json +1 -1
@@ -0,0 +1,106 @@
1
+ import type { AgentBinding } from "../definition/binding.js";
2
+ import type { BoundToolDefinition } from "../definition/bound.js";
3
+ import type { JsonObject, JsonValue } from "./shared.js";
4
+ import type { SandboxManifest } from "./manifest.js";
5
+ /** Loop verify outcome: pass, or fail with required feedback. */
6
+ export type Verdict = {
7
+ readonly pass: true;
8
+ readonly data?: JsonValue;
9
+ } | {
10
+ readonly pass: false;
11
+ readonly feedback: string;
12
+ readonly data?: JsonValue;
13
+ };
14
+ /** Local function marker in a workflow manifest (code never crosses the wire). */
15
+ export interface WorkflowFnRef {
16
+ readonly fn: true;
17
+ }
18
+ /** Agent leaf: referenced by definition id. */
19
+ export interface WorkflowAgentNode {
20
+ readonly agent: string;
21
+ }
22
+ /** Tool leaf: name and schemas only; implementation stays in the binding. */
23
+ export interface WorkflowToolNode {
24
+ readonly tool: {
25
+ readonly name: string;
26
+ readonly description?: string;
27
+ readonly inputSchema?: JsonObject;
28
+ readonly outputSchema?: JsonObject;
29
+ };
30
+ }
31
+ export interface WorkflowChainNode {
32
+ readonly chain: {
33
+ readonly id: string;
34
+ readonly steps: readonly WorkflowNode[];
35
+ };
36
+ }
37
+ export interface WorkflowSwitchNode {
38
+ readonly switch: {
39
+ readonly id: string;
40
+ readonly on: WorkflowFnRef;
41
+ readonly cases: Readonly<Record<string, WorkflowNode>>;
42
+ readonly default?: WorkflowNode;
43
+ };
44
+ }
45
+ export interface WorkflowParallelNode {
46
+ readonly parallel: {
47
+ readonly id: string;
48
+ readonly branches: Readonly<Record<string, WorkflowNode>>;
49
+ };
50
+ }
51
+ export interface WorkflowMapNode {
52
+ readonly map: {
53
+ readonly id: string;
54
+ readonly over: WorkflowFnRef;
55
+ readonly each: WorkflowNode;
56
+ };
57
+ }
58
+ export interface WorkflowLoopNode {
59
+ readonly loop: {
60
+ readonly id: string;
61
+ readonly run: WorkflowNode;
62
+ readonly verify: WorkflowFnRef | WorkflowAgentNode | WorkflowSlotNode;
63
+ readonly decide: WorkflowFnRef;
64
+ };
65
+ }
66
+ /** Rename and/or reshape a child: `{ slot: { id?, input?, run } }`. */
67
+ export interface WorkflowSlotNode {
68
+ readonly slot: {
69
+ readonly id?: string;
70
+ readonly input?: WorkflowFnRef;
71
+ readonly run: WorkflowNode;
72
+ };
73
+ }
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 {
77
+ readonly kind: "workflow";
78
+ readonly workflowSchemaVersion: 1;
79
+ readonly id: string;
80
+ readonly root: WorkflowNode;
81
+ readonly sandbox?: SandboxManifest;
82
+ }
83
+ /**
84
+ * Local implementation for a node key: a tool node, a pure `fn`, or a Loop `verify` function.
85
+ * Functions are never serialized.
86
+ */
87
+ export type WorkflowNodeImplementation = {
88
+ readonly kind: "tool";
89
+ readonly tool: BoundToolDefinition;
90
+ } | {
91
+ readonly kind: "fn";
92
+ readonly fn: (...args: never[]) => unknown;
93
+ } | {
94
+ readonly kind: "verify";
95
+ readonly fn: (...args: never[]) => unknown;
96
+ };
97
+ /**
98
+ * Built-workflow binding: manifest plus node-key → implementation, and referenced agent bindings.
99
+ * Not a wire format; `toJSON()` stays manifest-only.
100
+ */
101
+ export interface WorkflowBinding {
102
+ readonly manifest: WorkflowManifest;
103
+ /** Node key (path without Map indices) → local code. */
104
+ readonly nodes: Readonly<Record<string, WorkflowNodeImplementation>>;
105
+ readonly agents: Readonly<Record<string, AgentBinding>>;
106
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
1
  import type { AgentManifest } from "../types/manifest.js";
2
- /** Canonical SHA-256 hex digest of a manifest (agent identity). */
3
- export declare function hashManifest(manifest: AgentManifest): string;
2
+ import type { WorkflowManifest } from "../types/workflow.js";
3
+ /** Canonical SHA-256 hex digest of an agent or workflow definition document. */
4
+ export declare function hashManifest(manifest: AgentManifest | WorkflowManifest): string;
@@ -1,7 +1,7 @@
1
1
  import { sha256 } from "@noble/hashes/sha256";
2
2
  import { bytesToHex } from "@noble/hashes/utils";
3
3
  import { canonical } from "./canonical.js";
4
- /** Canonical SHA-256 hex digest of a manifest (agent identity). */
4
+ /** Canonical SHA-256 hex digest of an agent or workflow definition document. */
5
5
  export function hashManifest(manifest) {
6
6
  return bytesToHex(sha256(canonical(manifest)));
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/core",
3
- "version": "0.3.0-beta",
3
+ "version": "0.5.0-beta",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Shared agent definitions and wire contracts",