@arc-dev/core
Advanced tools
@@ -7,5 +7,79 @@ import { ArcStateContext } from "../types/state"; | ||
| import type { Arc as IArc } from "../types/arc"; | ||
| import type { ModelId } from "@arc-dev/models"; | ||
| import type { ModelId } from "@arc-dev/model"; | ||
| import type { z } from "zod"; | ||
| import type { WaitConfig } from "../types/edge"; | ||
| /** | ||
| * Type for node factory functions or NodeRef objects | ||
| */ | ||
| type NodeOrFactory<State extends Record<string, any>, OutputContext extends Record<string, any>> = NodeRef | ((arc: ArcBuilder<State, OutputContext>) => NodeRef); | ||
| /** | ||
| * Chainable builder for the simplified .edge() API | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const arc = defineArc<State>("my-arc", arc => | ||
| * arc | ||
| * .edge(node1, node2) | ||
| * .edge(node2, [node3, node4]) | ||
| * .edge(node3, node5) | ||
| * .when("condition-name", ({ context }) => context.get("key") === "value") | ||
| * ); | ||
| * ``` | ||
| */ | ||
| export declare class EdgeChainBuilder<State extends Record<string, any>, OutputContext extends Record<string, any>> { | ||
| private arcBuilder; | ||
| private internalBuilder; | ||
| private lastEdge; | ||
| constructor(arcBuilder: ArcBuilder<State, OutputContext>, internalBuilder: InternalArcBuilder<State, OutputContext>); | ||
| /** | ||
| * Create an edge from a source node to one or more target nodes. | ||
| * Automatically handles factory functions for node registration. | ||
| * | ||
| * @param from - Source node (NodeRef or factory function), or null/undefined for entry edge | ||
| * @param to - Target node(s) (NodeRef, NodeRef[], or factory function(s)) | ||
| * @param wait - Optional wait config for entry edges | ||
| * @returns This builder for chaining | ||
| */ | ||
| edge(from: NodeOrFactory<State, OutputContext> | null | undefined, to: NodeOrFactory<State, OutputContext> | NodeOrFactory<State, OutputContext>[], wait?: WaitConfig): this; | ||
| /** | ||
| * Apply a condition to the last edge created. | ||
| * | ||
| * @param name - Condition name | ||
| * @param condition - Condition function | ||
| * @returns This builder for chaining | ||
| */ | ||
| when(name: string, condition: (sc: ArcStateContext<State, OutputContext>) => boolean): this; | ||
| /** | ||
| * Create a loop with explicit configuration. | ||
| * @param node - The node or sub-arc to loop | ||
| * @param config - Loop configuration with while condition and max iterations | ||
| */ | ||
| loop<Node extends NodeRef>(node: Node, config: { | ||
| while: (sc: ArcStateContext<State, OutputContext>) => boolean; | ||
| max: number; | ||
| }): this; | ||
| /** | ||
| * Use a sub-arc as a step in this arc. | ||
| * @param id - The node ID for the sub-arc | ||
| * @param arc - The sub-arc to use | ||
| * @returns A NodeRef for the sub-arc node | ||
| */ | ||
| use<NodeId extends string>(id: NodeId, arc: IArc<any>): NodeRef<NodeId>; | ||
| /** | ||
| * Wait for input with the given ID, then create an edge to the target node. | ||
| * This is a convenience method that creates an entry edge with wait config. | ||
| * | ||
| * @param id - The input ID to wait for | ||
| * @param to - Target node(s) (NodeRef, NodeRef[], or factory function(s)) | ||
| * @returns This builder for chaining | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * arc.waitForInput("player", playerMoveAction) | ||
| * .edge(playerMoveAction, nextNode) | ||
| * ``` | ||
| */ | ||
| waitForInput(id: string, to: NodeOrFactory<State, OutputContext> | NodeOrFactory<State, OutputContext>[]): this; | ||
| } | ||
| /** | ||
| * Main Arc builder API that provides both node and edge methods. | ||
@@ -68,5 +142,6 @@ * This is the primary interface for building arcs programmatically. | ||
| from<Node extends NodeRef>(node: Node | ((arc: ArcBuilder<State, OutputContext>) => NodeRef)): this; | ||
| to<Node extends NodeRef>(node: Node | Node[] | ((arc: ArcBuilder<State, OutputContext>) => NodeRef)): ReturnType<EdgeBuilder<State, OutputContext>["to"]>; | ||
| to(node: NodeRef | NodeRef[] | ((arc: ArcBuilder<State, OutputContext>) => NodeRef) | ((arc: ArcBuilder<State, OutputContext>) => NodeRef)[]): ReturnType<EdgeBuilder<State, OutputContext>["to"]>; | ||
| condition<ConditionName extends string>(name: ConditionName, fn: (sc: ArcStateContext<State, OutputContext>) => boolean): string; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=builder.arc.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":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B,EAAE,EAAE,CAAC,EAAE,EAAE,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,OAAO,GACzD,MAAM;CAGV"} |
@@ -11,3 +11,3 @@ import { ArcStateContext } from "../types/state"; | ||
| to<NodeId extends string>(nodeId: NodeId, factory: (arc: ArcBuilder<State, OutputContext>) => NodeRef<NodeId>): ChainableToBuilder<State, OutputContext>; | ||
| to<Node extends NodeRef>(node: Node | Node[]): ChainableEdgeBuilder<State, OutputContext, Node>; | ||
| to(node: any): ChainableEdgeBuilder<State, OutputContext, NodeRef>; | ||
| } | ||
@@ -42,5 +42,5 @@ export declare class ChainableEdgeBuilder<State extends Record<string, any>, OutputContext extends Record<string, any>, LastTarget extends NodeRef = NodeRef> { | ||
| from<Node extends NodeRef>(node: Node | ((arc: ArcBuilder<State, OutputContext>) => NodeRef), arcBuilder?: ArcBuilder<State, OutputContext>): this; | ||
| to<Node extends NodeRef>(node: Node | Node[] | ((arc: ArcBuilder<State, OutputContext>) => NodeRef), arcBuilder?: ArcBuilder<State, OutputContext>): ChainableEdgeBuilder<State, OutputContext, Node>; | ||
| to(node: NodeRef | NodeRef[] | ((arc: ArcBuilder<State, OutputContext>) => NodeRef) | ((arc: ArcBuilder<State, OutputContext>) => NodeRef)[], arcBuilder?: ArcBuilder<State, OutputContext>): ChainableEdgeBuilder<State, OutputContext, NodeRef>; | ||
| condition<ConditionName extends string>(name: ConditionName, fn: (sc: ArcStateContext<State, OutputContext>) => boolean): string; | ||
| } | ||
| //# sourceMappingURL=builder.edge.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"builder.edge.d.ts","sourceRoot":"","sources":["../../src/builders/builder.edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC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from "@arc-dev/models"; | ||
| import { ModelId } from "@arc-dev/model"; | ||
| export interface NodeRef<NodeId extends string = string> { | ||
@@ -9,0 +9,0 @@ id: NodeId; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"builder.node.d.ts","sourceRoot":"","sources":["../../src/builders/builder.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAgB,OAAO,EAAU,MAAM,iBAAiB,CAAC;AAIhE,MAAM,WAAW,OAAO,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM;IACrD,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,qBAAa,WAAW,CACtB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAE7B,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,kBAAkB,CAAC,KAAK,EAAE,aAAa,CAAC;IAErE,KAAK,CAAC,MAAM,SAAS,MAAM,EAAE,MAAM,SAAS,CAAC,CAAC,UAAU,EACtD,EAAE,EAAE,MAAM,EACV,MAAM,EAAE;QACN,KAAK,EAAE,OAAO,CAAC;QACf,QAAQ,EAAE,CAAC,EAAE,EAAE,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK;YACvD,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;YACxB,OAAO,EAAE,MAAM,CAAC;SACjB,EAAE,CAAC;QACJ,MAAM,EAAE,MAAM,CAAC;KAChB,GACA,OAAO,CAAC,MAAM,CAAC;IAkEl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E;QACN,KAAK,EAAE,OAAO,CAAC;QACf,QAAQ,EAAE,CAAC,EAAE,EAAE,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK;YACvD,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;YACxB,OAAO,EAAE,MAAM,CAAC;SACjB,EAAE,CAAC;QACJ,MAAM,EAAE,MAAM,CAAC;KAChB,GACA,OAAO,CAAC,MAAM,CAAC;IAmElB,MAAM,CAAC,MAAM,SAAS,MAAM,EAC1B,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,CACP,EAAE,EAAE,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,KACtC,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,GAClE,OAAO,CAAC,MAAM,CAAC;IAiBlB,GAAG,CAAC,MAAM,SAAS,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAexE"} |
| import type { Arc as IArc } from "../types/arc"; | ||
| import { ArcBuilder } from "./builder.arc"; | ||
| import { ArcBuilder, EdgeChainBuilder } from "./builder.arc"; | ||
| export { InternalArcBuilder } from "./builder.internal"; | ||
| export type { NodeRef } from "./builder.node"; | ||
| export { EdgeConditionBuilder } from "./builder.edge-condition"; | ||
| export { ArcBuilder } from "./builder.arc"; | ||
| export { ArcBuilder, EdgeChainBuilder } from "./builder.arc"; | ||
| export { action, agent, arc as arcNode, createAction, createAgent, } from "./node-functions"; | ||
@@ -35,6 +35,6 @@ export { renderAsDot } from "../renderers/renderer.dot"; | ||
| (id: string): ArcBuilder<State, OutputContext>; | ||
| (id: string, configurator: (arc: ArcBuilder<State, OutputContext>) => void): IArc<State, OutputContext>; | ||
| (id: string, configurator: (arc: EdgeChainBuilder<State, OutputContext>) => void): IArc<State, OutputContext>; | ||
| }; | ||
| export declare function defineArc<State extends Record<string, any>, OutputContext extends Record<string, any> = any>(id: string): ArcBuilder<State, OutputContext>; | ||
| export declare function defineArc<State extends Record<string, any>, OutputContext extends Record<string, any> = any>(id: string, configurator: (arc: ArcBuilder<State, OutputContext>) => void): IArc<State, OutputContext>; | ||
| export declare function defineArc<State extends Record<string, any>, OutputContext extends Record<string, any> = any>(id: string, configurator: (arc: EdgeChainBuilder<State, OutputContext>) => void): IArc<State, OutputContext>; | ||
| /** | ||
@@ -41,0 +41,0 @@ * Legacy function name - use defineArc instead |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builders/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,MAAM,EACN,KAAK,EACL,GAAG,IAAI,OAAO,EACd,YAAY,EACZ,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CACvB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,KAC5C;IACH,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAC/C,CACE,EAAE,EAAE,MAAM,EACV,YAAY,EAAE,CAAC,GAAG,EAAE,UAAU,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AAM,2BAA2B,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CACvB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,KAC5C;IACH,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAC/C,CACE,EAAE,EAAE,MAAM,EACV,YAAY,EAAE,CAAC,GAAG,EAAE,gBAAgB,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,IAAI,GAClE,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;CAC/B,CAAC;AACF,wBAAgB,SAAS,CACvB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAC/C,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;AAChD,wBAAgB,SAAS,CACvB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAE/C,EAAE,EAAE,MAAM,EACV,YAAY,EAAE,CAAC,GAAG,EAAE,gBAAgB,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,IAAI,GAClE,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;AAgE9B;;;GAGG;AACH,eAAO,MAAM,GAAG,kBAAY,CAAC"} |
@@ -6,3 +6,3 @@ import { ArcStateContext } from "../types/state"; | ||
| import { z } from "zod"; | ||
| import type { ModelId } from "@arc-dev/models"; | ||
| import type { ModelId } from "@arc-dev/model"; | ||
| import type { Arc as IArc } from "../types/arc"; | ||
@@ -9,0 +9,0 @@ import type { z as ZodType } from "zod"; |
@@ -1,1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,CAInB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CACzB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EACvC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC/D,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,MAAM,SAAS,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,EAEtD,EAAE,EAAE,MAAM,EACV,MAAM,EAAE;IACN,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,CAAC,EAAE,EAAE,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK;QACvD,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;QACxB,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;IACJ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,CAAC,MAAM,SAAS,KAAK,EAAE,QAAQ,SAAS,aAAa,EACtD,GAAG,EAAE,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,KAC9B,OAAO,CAAC,MAAM,CAAC,CAanB;AAED;;GAEG;AACH,wBAAgB,GAAG,CACjB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzC,MAAM,SAAS,MAAM,EAErB,UAAU,EAAE,UAAU,CAAC,KAAK,EAAE,aAAa,CAAC,EAC5C,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GACb,OAAO,CAAC,MAAM,CAAC,CAEjB"} |
+185
-280
@@ -5,24 +5,3 @@ 'use strict'; | ||
| var immutable = require('immutable'); | ||
| var models = require('@arc-dev/models'); | ||
| var readline = require('node:readline'); | ||
| function _interopNamespaceDefault(e) { | ||
| var n = Object.create(null); | ||
| if (e) { | ||
| Object.keys(e).forEach(function (k) { | ||
| if (k !== 'default') { | ||
| var d = Object.getOwnPropertyDescriptor(e, k); | ||
| Object.defineProperty(n, k, d.get ? d : { | ||
| enumerable: true, | ||
| get: function () { return e[k]; } | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
| n.default = e; | ||
| return Object.freeze(n); | ||
| } | ||
| var readline__namespace = /*#__PURE__*/_interopNamespaceDefault(readline); | ||
| exports.ArcNodeKind = void 0; | ||
@@ -247,5 +226,4 @@ (function (ArcNodeKind) { | ||
| id: `${id}-agent`, | ||
| run: async function* (stateContext) { | ||
| const models$1 = models.createModels(); | ||
| const model = models$1.get(config.model); | ||
| run: async function* (stateContext, nodeId, models) { | ||
| const model = models.get(config.model); | ||
| const messages = config.messages(stateContext); | ||
@@ -270,3 +248,3 @@ const jsonSchema = zod.z.toJSONSchema(config.output); | ||
| yield { | ||
| type: "node-output-token", | ||
| type: "node-output-delta", | ||
| nodeId: id, | ||
@@ -281,3 +259,3 @@ chunk: streamEvent.chunk, | ||
| yield { | ||
| type: "node-output-token", | ||
| type: "node-output-delta", | ||
| nodeId: id, | ||
@@ -304,3 +282,3 @@ chunk: "", | ||
| id: `${id}-action`, | ||
| run: async function* (stateContext) { | ||
| run: async function* (stateContext, nodeId, models) { | ||
| const result = await handler(stateContext); | ||
@@ -315,4 +293,4 @@ stateContext.__pendingState = result; | ||
| id: `${id}-arc`, | ||
| run: async function* () { | ||
| // NoOp | ||
| run: async function* (stateContext, nodeId, models) { | ||
| // NoOp - Arc nodes don't execute, they're just placeholders | ||
| }, | ||
@@ -390,6 +368,23 @@ arc, | ||
| } | ||
| // Otherwise, use direct NodeRef pattern | ||
| const nodes = Array.isArray(nodeIdOrNode) | ||
| ? nodeIdOrNode | ||
| : [nodeIdOrNode]; | ||
| // Handle factory functions and NodeRef objects | ||
| let nodes; | ||
| if (Array.isArray(nodeIdOrNode)) { | ||
| // Resolve factory functions in array | ||
| nodes = nodeIdOrNode.map((item) => { | ||
| if (typeof item === "function") { | ||
| return item(this.arcBuilder); | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
| else { | ||
| // Single item - could be factory function or NodeRef | ||
| const item = nodeIdOrNode; | ||
| if (typeof item === "function") { | ||
| nodes = [item(this.arcBuilder)]; | ||
| } | ||
| else { | ||
| nodes = [item]; | ||
| } | ||
| } | ||
| for (const node of nodes) { | ||
@@ -404,3 +399,5 @@ const edge = { | ||
| // Return ChainableEdgeBuilder for further chaining with simpler .to(node) pattern | ||
| return new ChainableEdgeBuilder(this.builder, lastNode.id, this.lastNodeId, lastNode.id, undefined, this.arcBuilder); | ||
| // Pass all nodes as sources to support fan-out: subsequent .to() calls will chain from all nodes | ||
| const sourceIds = nodes.map((node) => node.id); | ||
| return new ChainableEdgeBuilder(this.builder, lastNode.id, this.lastNodeId, lastNode.id, sourceIds, this.arcBuilder); | ||
| } | ||
@@ -464,6 +461,7 @@ } | ||
| const lastTarget = resolvedTargets[resolvedTargets.length - 1]; | ||
| // Return a new chainable builder with the last target as the new source | ||
| // Auto-chaining: last target becomes source for next .to() | ||
| // Return a new chainable builder with all targets as the new sources | ||
| // Auto-chaining: all targets become sources for next .to() (supports fan-out) | ||
| const newSources = resolvedTargets.map((target) => target.id); | ||
| return new ChainableEdgeBuilder(this.builder, lastTarget.id, sources[0], // Use first source for condition builder | ||
| lastTarget.id, undefined, // sources will be set from lastTarget | ||
| lastTarget.id, newSources, // Pass all targets as sources to support fan-out | ||
| this.arcBuilder); | ||
@@ -511,7 +509,8 @@ } | ||
| const lastTarget = resolvedTargets[resolvedTargets.length - 1]; | ||
| // Return chainable builder starting from the last target | ||
| // Return chainable builder starting from all targets | ||
| // Set up condition builder for the last edge created | ||
| // Use undefined for entry edges (when sourceNode is null) | ||
| // Auto-chaining: last target becomes source for next .to() | ||
| return new ChainableEdgeBuilder(builder, lastTarget.id, sourceNode || undefined, lastTarget.id, undefined, arcBuilder); | ||
| // Auto-chaining: all targets become sources for next .to() (supports fan-out) | ||
| const sourceIds = resolvedTargets.map((target) => target.id); | ||
| return new ChainableEdgeBuilder(builder, lastTarget.id, sourceNode || undefined, lastTarget.id, sourceIds, arcBuilder); | ||
| }, | ||
@@ -558,13 +557,19 @@ }; | ||
| } | ||
| // Handle factory functions | ||
| let resolvedNode; | ||
| if (typeof node === "function" && arcBuilder) { | ||
| resolvedNode = node(arcBuilder); | ||
| // Handle factory functions and NodeRef objects | ||
| let resolvedTargets; | ||
| if (Array.isArray(node)) { | ||
| // Resolve factory functions in array | ||
| resolvedTargets = node.map((item) => { | ||
| if (typeof item === "function" && arcBuilder) { | ||
| return item(arcBuilder); | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
| else if (typeof node === "function" && arcBuilder) { | ||
| resolvedTargets = [node(arcBuilder)]; | ||
| } | ||
| else { | ||
| resolvedNode = node; | ||
| resolvedTargets = [node]; | ||
| } | ||
| const resolvedTargets = Array.isArray(resolvedNode) | ||
| ? resolvedNode | ||
| : [resolvedNode]; | ||
| const source = this.sourceNode; | ||
@@ -582,3 +587,5 @@ for (const target of resolvedTargets) { | ||
| // This allows .to(node1).to(node2) without needing .from() in between | ||
| return new ChainableEdgeBuilder(this.builder, lastTarget.id, source, lastTarget.id, undefined, this.arcBuilder); | ||
| // Pass all targets as sources to support fan-out | ||
| const sourceIds = resolvedTargets.map((target) => target.id); | ||
| return new ChainableEdgeBuilder(this.builder, lastTarget.id, source, lastTarget.id, sourceIds, this.arcBuilder); | ||
| } | ||
@@ -592,2 +599,109 @@ condition(name, fn) { | ||
| /** | ||
| * Chainable builder for the simplified .edge() API | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const arc = defineArc<State>("my-arc", arc => | ||
| * arc | ||
| * .edge(node1, node2) | ||
| * .edge(node2, [node3, node4]) | ||
| * .edge(node3, node5) | ||
| * .when("condition-name", ({ context }) => context.get("key") === "value") | ||
| * ); | ||
| * ``` | ||
| */ | ||
| class EdgeChainBuilder { | ||
| arcBuilder; | ||
| internalBuilder; | ||
| lastEdge = null; | ||
| constructor(arcBuilder, internalBuilder) { | ||
| this.arcBuilder = arcBuilder; | ||
| this.internalBuilder = internalBuilder; | ||
| } | ||
| /** | ||
| * Create an edge from a source node to one or more target nodes. | ||
| * Automatically handles factory functions for node registration. | ||
| * | ||
| * @param from - Source node (NodeRef or factory function), or null/undefined for entry edge | ||
| * @param to - Target node(s) (NodeRef, NodeRef[], or factory function(s)) | ||
| * @param wait - Optional wait config for entry edges | ||
| * @returns This builder for chaining | ||
| */ | ||
| edge(from, to, wait) { | ||
| // Resolve source node (null/undefined for entry edges) | ||
| const fromNode = from === null || from === undefined | ||
| ? null | ||
| : typeof from === "function" | ||
| ? from(this.arcBuilder) | ||
| : from; | ||
| // Resolve target nodes | ||
| const toNodes = Array.isArray(to) | ||
| ? to.map((t) => (typeof t === "function" ? t(this.arcBuilder) : t)) | ||
| : [typeof to === "function" ? to(this.arcBuilder) : to]; | ||
| // Create edges for each target | ||
| for (const toNode of toNodes) { | ||
| const edge = { | ||
| from: fromNode?.id, | ||
| to: toNode.id, | ||
| wait: wait, | ||
| }; | ||
| this.internalBuilder.addEdge(edge); | ||
| this.lastEdge = edge; // Track last edge for .when() | ||
| } | ||
| return this; | ||
| } | ||
| /** | ||
| * Apply a condition to the last edge created. | ||
| * | ||
| * @param name - Condition name | ||
| * @param condition - Condition function | ||
| * @returns This builder for chaining | ||
| */ | ||
| when(name, condition) { | ||
| if (!this.lastEdge) { | ||
| throw new Error("Cannot call .when() before creating an edge with .edge()"); | ||
| } | ||
| // Register the condition | ||
| this.arcBuilder.condition(name, condition); | ||
| // Apply condition to the last edge | ||
| this.lastEdge.condition = name; | ||
| return this; | ||
| } | ||
| /** | ||
| * Create a loop with explicit configuration. | ||
| * @param node - The node or sub-arc to loop | ||
| * @param config - Loop configuration with while condition and max iterations | ||
| */ | ||
| loop(node, config) { | ||
| this.arcBuilder.loop(node, config); | ||
| return this; | ||
| } | ||
| /** | ||
| * Use a sub-arc as a step in this arc. | ||
| * @param id - The node ID for the sub-arc | ||
| * @param arc - The sub-arc to use | ||
| * @returns A NodeRef for the sub-arc node | ||
| */ | ||
| use(id, arc) { | ||
| return this.arcBuilder.use(id, arc); | ||
| } | ||
| /** | ||
| * Wait for input with the given ID, then create an edge to the target node. | ||
| * This is a convenience method that creates an entry edge with wait config. | ||
| * | ||
| * @param id - The input ID to wait for | ||
| * @param to - Target node(s) (NodeRef, NodeRef[], or factory function(s)) | ||
| * @returns This builder for chaining | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * arc.waitForInput("player", playerMoveAction) | ||
| * .edge(playerMoveAction, nextNode) | ||
| * ``` | ||
| */ | ||
| waitForInput(id, to) { | ||
| return this.edge(null, to, { id }); | ||
| } | ||
| } | ||
| /** | ||
| * Main Arc builder API that provides both node and edge methods. | ||
@@ -747,8 +861,11 @@ * This is the primary interface for building arcs programmatically. | ||
| }); | ||
| const arcBuilder = new ArcBuilder(internalBuilder); | ||
| if (configurator) { | ||
| configurator(arcBuilder); | ||
| return internalBuilder.build(); | ||
| const arcBuilder = new ArcBuilder(internalBuilder); | ||
| const edgeBuilder = new EdgeChainBuilder(arcBuilder, internalBuilder); | ||
| configurator(edgeBuilder); | ||
| // Build from the arc builder | ||
| return arcBuilder.build(); | ||
| } | ||
| return arcBuilder; | ||
| // Return ArcBuilder for imperative usage | ||
| return new ArcBuilder(internalBuilder); | ||
| }; | ||
@@ -762,8 +879,11 @@ return curriedFn; | ||
| }); | ||
| const arcBuilder = new ArcBuilder(internalBuilder); | ||
| if (configurator) { | ||
| configurator(arcBuilder); | ||
| return internalBuilder.build(); | ||
| const arcBuilder = new ArcBuilder(internalBuilder); | ||
| const edgeBuilder = new EdgeChainBuilder(arcBuilder, internalBuilder); | ||
| configurator(edgeBuilder); | ||
| // Build from the arc builder | ||
| return arcBuilder.build(); | ||
| } | ||
| return arcBuilder; | ||
| // Return ArcBuilder for imperative usage | ||
| return new ArcBuilder(internalBuilder); | ||
| } | ||
@@ -798,221 +918,2 @@ /** | ||
| class TerminalChannel { | ||
| verbosity; | ||
| currentNode; | ||
| streamingNodeId; | ||
| constructor(verbosity) { | ||
| this.verbosity = verbosity; | ||
| this.verbosity = verbosity ?? LogVerbosityLevel.Info; | ||
| } | ||
| async consume(runtime, events) { | ||
| let finalState; | ||
| let finalContext; | ||
| console.log("🚀 Starting Arc execution..."); | ||
| console.log(); | ||
| let nodeIndex = 0; | ||
| for await (const event of events) { | ||
| this.streamEvent(event); | ||
| switch (event.type) { | ||
| case "arc-started": { | ||
| console.log(`\x1b[36mArc "${event.arcId}" started\x1b[0m`); | ||
| if (event.initialState && | ||
| Object.keys(event.initialState).length > 0) { | ||
| console.log("\x1b[90mInitial State:\x1b[0m"); | ||
| this.printObject(event.initialState, 2); | ||
| } | ||
| console.log(); | ||
| break; | ||
| } | ||
| case "arc-completed": { | ||
| console.log(); | ||
| this.printSuccess(`Arc "${event.arcId}" completed successfully`); | ||
| finalState = event.finalState; | ||
| finalContext = event.finalContext; | ||
| if (event.finalState && Object.keys(event.finalState).length > 0) { | ||
| console.log("\x1b[90mFinal State:\x1b[0m"); | ||
| this.printObject(event.finalState, 2); | ||
| } | ||
| if (event.finalContext && | ||
| Object.keys(event.finalContext).length > 0) { | ||
| console.log("\x1b[90mFinal Context:\x1b[0m"); | ||
| this.printObject(event.finalContext, 2); | ||
| } | ||
| break; | ||
| } | ||
| case "arc-error": { | ||
| console.log(); | ||
| this.printError(event.error); | ||
| throw event.error; | ||
| } | ||
| case "log": { | ||
| this.printLog(event.level, event.message); | ||
| break; | ||
| } | ||
| case "node-started": { | ||
| if (event.nodeId && event.nodeId !== this.currentNode) { | ||
| if (nodeIndex > 0) { | ||
| console.log(); | ||
| } | ||
| this.currentNode = event.nodeId; | ||
| this.printNodeHeader(event.nodeId); | ||
| nodeIndex++; | ||
| } | ||
| break; | ||
| } | ||
| case "node-completed": { | ||
| if (event.state && Object.keys(event.state).length > 0) { | ||
| console.log("\x1b[90m State:\x1b[0m"); | ||
| this.printObject(event.state, 4); | ||
| } | ||
| if (event.context && Object.keys(event.context).length > 0) { | ||
| console.log("\x1b[90m Context:\x1b[0m"); | ||
| this.printObject(event.context, 4); | ||
| } | ||
| break; | ||
| } | ||
| case "node-error": { | ||
| console.log(); | ||
| console.log(`\x1b[31m✗ Node "${event.nodeId}" failed: ${event.error.message}\x1b[0m`); | ||
| if (event.error.stack) { | ||
| console.log(`\x1b[90m${event.error.stack}\x1b[0m`); | ||
| } | ||
| throw event.error; | ||
| } | ||
| case "node-paused": { | ||
| console.log(); | ||
| const answer = await this.askUser(event.prompt || "Enter input: "); | ||
| const resumeKey = event.sessionId || event.nodeId; | ||
| await runtime.resume(resumeKey, answer); | ||
| break; | ||
| } | ||
| case "node-output-token": { | ||
| if (event.nodeId !== this.streamingNodeId) { | ||
| // Start of a new stream | ||
| this.streamingNodeId = event.nodeId; | ||
| process.stdout.write("\x1b[90m "); | ||
| } | ||
| if (event.chunk) { | ||
| // Write chunk directly to stdout for real-time streaming | ||
| process.stdout.write(event.chunk); | ||
| } | ||
| if (event.done) { | ||
| // End of stream | ||
| process.stdout.write("\x1b[0m\n"); | ||
| this.streamingNodeId = undefined; | ||
| } | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (!finalState || !finalContext) { | ||
| throw new Error("Arc did not complete successfully"); | ||
| } | ||
| return { finalState, finalContext }; | ||
| } | ||
| streamEvent(event) { | ||
| // Stream event information - can be extended to emit to other streams | ||
| // For now, events are handled in the switch statement above | ||
| } | ||
| printNodeHeader(id) { | ||
| console.log(`\x1b[36m→ ${id}\x1b[0m`); | ||
| } | ||
| printLog(level, message) { | ||
| if (this.shouldLog(level)) { | ||
| return; | ||
| } | ||
| const colors = { | ||
| debug: "\x1b[90m", // gray | ||
| info: "\x1b[36m", // cyan | ||
| warn: "\x1b[33m", // yellow | ||
| error: "\x1b[31m", // red | ||
| fatal: "\x1b[31m", // red | ||
| trace: "\x1b[90m", // gray | ||
| }; | ||
| const color = colors[level] || "\x1b[0m"; | ||
| const prefix = level.toUpperCase().padEnd(5); | ||
| console.log(` ${color}[${prefix}] ${message}\x1b[0m`); | ||
| } | ||
| shouldLog(level) { | ||
| if (this.verbosity === LogVerbosityLevel.Silent) { | ||
| return true; | ||
| } | ||
| const levels = [ | ||
| "silent", | ||
| "fatal", | ||
| "error", | ||
| "warn", | ||
| "info", | ||
| "debug", | ||
| "trace", | ||
| ]; | ||
| const verbosityIndex = levels.indexOf(this.verbosity || LogVerbosityLevel.Info); | ||
| const levelIndex = levels.indexOf(level); | ||
| return levelIndex > verbosityIndex; | ||
| } | ||
| printSuccess(message = "Arc completed successfully") { | ||
| console.log(`\x1b[32m✓ ${message}\x1b[0m`); | ||
| } | ||
| printError(error) { | ||
| console.log(`\x1b[31m✗ Arc failed: ${error.message}\x1b[0m`); | ||
| if (error.stack) { | ||
| console.log(`\x1b[90m${error.stack}\x1b[0m`); | ||
| } | ||
| } | ||
| printObject(obj, indent = 0) { | ||
| const indentStr = " ".repeat(indent); | ||
| const formatValue = (value) => { | ||
| if (value === null) | ||
| return "\x1b[90mnull\x1b[0m"; | ||
| if (value === undefined) | ||
| return "\x1b[90mundefined\x1b[0m"; | ||
| if (typeof value === "string") | ||
| return `\x1b[33m"${value}"\x1b[0m`; | ||
| if (typeof value === "number") | ||
| return `\x1b[35m${value}\x1b[0m`; | ||
| if (typeof value === "boolean") | ||
| return `\x1b[35m${value}\x1b[0m`; | ||
| if (Array.isArray(value)) { | ||
| if (value.length === 0) | ||
| return "\x1b[90m[]\x1b[0m"; | ||
| return `[\n${value | ||
| .map((v) => `${indentStr} ${formatValue(v)}`) | ||
| .join(",\n")}\n${indentStr}]`; | ||
| } | ||
| if (typeof value === "object") { | ||
| const keys = Object.keys(value); | ||
| if (keys.length === 0) | ||
| return "\x1b[90m{}\x1b[0m"; | ||
| return `{\n${keys | ||
| .map((k) => `${indentStr} \x1b[36m${k}\x1b[0m: ${formatValue(value[k])}`) | ||
| .join(",\n")}\n${indentStr}}`; | ||
| } | ||
| return String(value); | ||
| }; | ||
| if (typeof obj === "object" && obj !== null && !Array.isArray(obj)) { | ||
| const keys = Object.keys(obj); | ||
| if (keys.length === 0) { | ||
| console.log(`${indentStr}\x1b[90m{}\x1b[0m`); | ||
| return; | ||
| } | ||
| keys.forEach((key) => { | ||
| console.log(`${indentStr}\x1b[36m${key}\x1b[0m: ${formatValue(obj[key])}`); | ||
| }); | ||
| } | ||
| else { | ||
| console.log(`${indentStr}${formatValue(obj)}`); | ||
| } | ||
| } | ||
| async askUser(prompt) { | ||
| const rl = readline__namespace.createInterface({ | ||
| input: process.stdin, | ||
| output: process.stdout, | ||
| }); | ||
| const answer = await new Promise((resolve) => { | ||
| rl.question(`\x1b[33m${prompt}\x1b[0m `, resolve); | ||
| }); | ||
| rl.close(); | ||
| return answer; | ||
| } | ||
| } | ||
| class ArcState { | ||
@@ -1022,6 +923,8 @@ state; | ||
| edgeContext; | ||
| constructor(initial) { | ||
| models; | ||
| constructor(initial, models) { | ||
| this.state = immutable.Map(initial); | ||
| this.nodeContext = immutable.Map(); | ||
| this.edgeContext = immutable.Map(); | ||
| this.models = models; | ||
| } | ||
@@ -1044,2 +947,5 @@ getState() { | ||
| } | ||
| getModels() { | ||
| return this.models; | ||
| } | ||
| setState(newState) { | ||
@@ -1069,4 +975,4 @@ this.state = newState; | ||
| } | ||
| static fromSerialized(serialized) { | ||
| const arcState = new ArcState(serialized.state); | ||
| static fromSerialized(serialized, models) { | ||
| const arcState = new ArcState(serialized.state, models); | ||
| if (serialized.nodeContext) { | ||
@@ -1093,3 +999,2 @@ for (const [key, value] of Object.entries(serialized.nodeContext)) { | ||
| exports.LogVerbosityLevel = LogVerbosityLevel; | ||
| exports.TerminalChannel = TerminalChannel; | ||
| exports.action = action; | ||
@@ -1096,0 +1001,0 @@ exports.agent = agent; |
+90
-34
| import { Map as Map$1 } from 'immutable'; | ||
| export { Map as ImmutableMap } from 'immutable'; | ||
| import { z } from 'zod'; | ||
| import { ModelId } from '@arc-dev/models'; | ||
| import { Models, ModelId } from '@arc-dev/model'; | ||
@@ -161,3 +161,3 @@ type TypedImmutableMap<T extends Record<string, any>> = Omit<Map$1<string, any>, "get"> & { | ||
| type ArcEventType = "log" | "arc-started" | "arc-completed" | "arc-error" | "node-started" | "node-completed" | "node-error" | "node-paused" | "node-output-token"; | ||
| type ArcEventType = "log" | "arc-started" | "arc-completed" | "arc-error" | "node-started" | "node-completed" | "node-error" | "node-paused" | "node-output-delta"; | ||
| type BaseEvent = { | ||
@@ -216,4 +216,4 @@ timestamp: number; | ||
| }; | ||
| type NodeOutputTokenEvent = BaseEvent & { | ||
| type: "node-output-token"; | ||
| type NodeOutputDeltaEvent = BaseEvent & { | ||
| type: "node-output-delta"; | ||
| nodeId: string; | ||
@@ -223,3 +223,3 @@ chunk: string; | ||
| }; | ||
| type ArcEvent<State extends Record<string, any>, OutputContext extends Record<string, any>> = LogEvent | ArcStartedEvent<State> | ArcCompletedEvent<State, OutputContext> | ArcErrorEvent | NodeStartedEvent | NodeCompletedEvent<State, OutputContext> | NodeErrorEvent | NodePausedEvent<State, OutputContext> | NodeOutputTokenEvent; | ||
| type ArcEvent<State extends Record<string, any>, OutputContext extends Record<string, any>> = LogEvent | ArcStartedEvent<State> | ArcCompletedEvent<State, OutputContext> | ArcErrorEvent | NodeStartedEvent | NodeCompletedEvent<State, OutputContext> | NodeErrorEvent | NodePausedEvent<State, OutputContext> | NodeOutputDeltaEvent; | ||
@@ -236,3 +236,3 @@ declare enum ArcNodeKind { | ||
| id: string; | ||
| run: (sc: ArcStateContext<State, OutputContext>, nodeId: string) => AsyncIterable<ArcEvent<State, OutputContext>>; | ||
| run: (sc: ArcStateContext<State, OutputContext>, nodeId: string, models: Models) => AsyncIterable<ArcEvent<State, OutputContext>>; | ||
| arc?: Arc$1<State, OutputContext>; | ||
@@ -310,3 +310,3 @@ }; | ||
| to<NodeId extends string>(nodeId: NodeId, factory: (arc: ArcBuilder<State, OutputContext>) => NodeRef<NodeId>): ChainableToBuilder<State, OutputContext>; | ||
| to<Node extends NodeRef>(node: Node | Node[]): ChainableEdgeBuilder<State, OutputContext, Node>; | ||
| to(node: any): ChainableEdgeBuilder<State, OutputContext, NodeRef>; | ||
| } | ||
@@ -341,3 +341,3 @@ declare class ChainableEdgeBuilder<State extends Record<string, any>, OutputContext extends Record<string, any>, LastTarget extends NodeRef = NodeRef> { | ||
| from<Node extends NodeRef>(node: Node | ((arc: ArcBuilder<State, OutputContext>) => NodeRef), arcBuilder?: ArcBuilder<State, OutputContext>): this; | ||
| to<Node extends NodeRef>(node: Node | Node[] | ((arc: ArcBuilder<State, OutputContext>) => NodeRef), arcBuilder?: ArcBuilder<State, OutputContext>): ChainableEdgeBuilder<State, OutputContext, Node>; | ||
| to(node: NodeRef | NodeRef[] | ((arc: ArcBuilder<State, OutputContext>) => NodeRef) | ((arc: ArcBuilder<State, OutputContext>) => NodeRef)[], arcBuilder?: ArcBuilder<State, OutputContext>): ChainableEdgeBuilder<State, OutputContext, NodeRef>; | ||
| condition<ConditionName extends string>(name: ConditionName, fn: (sc: ArcStateContext<State, OutputContext>) => boolean): string; | ||
@@ -347,2 +347,75 @@ } | ||
| /** | ||
| * Type for node factory functions or NodeRef objects | ||
| */ | ||
| type NodeOrFactory<State extends Record<string, any>, OutputContext extends Record<string, any>> = NodeRef | ((arc: ArcBuilder<State, OutputContext>) => NodeRef); | ||
| /** | ||
| * Chainable builder for the simplified .edge() API | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const arc = defineArc<State>("my-arc", arc => | ||
| * arc | ||
| * .edge(node1, node2) | ||
| * .edge(node2, [node3, node4]) | ||
| * .edge(node3, node5) | ||
| * .when("condition-name", ({ context }) => context.get("key") === "value") | ||
| * ); | ||
| * ``` | ||
| */ | ||
| declare class EdgeChainBuilder<State extends Record<string, any>, OutputContext extends Record<string, any>> { | ||
| private arcBuilder; | ||
| private internalBuilder; | ||
| private lastEdge; | ||
| constructor(arcBuilder: ArcBuilder<State, OutputContext>, internalBuilder: InternalArcBuilder<State, OutputContext>); | ||
| /** | ||
| * Create an edge from a source node to one or more target nodes. | ||
| * Automatically handles factory functions for node registration. | ||
| * | ||
| * @param from - Source node (NodeRef or factory function), or null/undefined for entry edge | ||
| * @param to - Target node(s) (NodeRef, NodeRef[], or factory function(s)) | ||
| * @param wait - Optional wait config for entry edges | ||
| * @returns This builder for chaining | ||
| */ | ||
| edge(from: NodeOrFactory<State, OutputContext> | null | undefined, to: NodeOrFactory<State, OutputContext> | NodeOrFactory<State, OutputContext>[], wait?: WaitConfig): this; | ||
| /** | ||
| * Apply a condition to the last edge created. | ||
| * | ||
| * @param name - Condition name | ||
| * @param condition - Condition function | ||
| * @returns This builder for chaining | ||
| */ | ||
| when(name: string, condition: (sc: ArcStateContext<State, OutputContext>) => boolean): this; | ||
| /** | ||
| * Create a loop with explicit configuration. | ||
| * @param node - The node or sub-arc to loop | ||
| * @param config - Loop configuration with while condition and max iterations | ||
| */ | ||
| loop<Node extends NodeRef>(node: Node, config: { | ||
| while: (sc: ArcStateContext<State, OutputContext>) => boolean; | ||
| max: number; | ||
| }): this; | ||
| /** | ||
| * Use a sub-arc as a step in this arc. | ||
| * @param id - The node ID for the sub-arc | ||
| * @param arc - The sub-arc to use | ||
| * @returns A NodeRef for the sub-arc node | ||
| */ | ||
| use<NodeId extends string>(id: NodeId, arc: Arc$1<any>): NodeRef<NodeId>; | ||
| /** | ||
| * Wait for input with the given ID, then create an edge to the target node. | ||
| * This is a convenience method that creates an entry edge with wait config. | ||
| * | ||
| * @param id - The input ID to wait for | ||
| * @param to - Target node(s) (NodeRef, NodeRef[], or factory function(s)) | ||
| * @returns This builder for chaining | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * arc.waitForInput("player", playerMoveAction) | ||
| * .edge(playerMoveAction, nextNode) | ||
| * ``` | ||
| */ | ||
| waitForInput(id: string, to: NodeOrFactory<State, OutputContext> | NodeOrFactory<State, OutputContext>[]): this; | ||
| } | ||
| /** | ||
| * Main Arc builder API that provides both node and edge methods. | ||
@@ -405,3 +478,3 @@ * This is the primary interface for building arcs programmatically. | ||
| from<Node extends NodeRef>(node: Node | ((arc: ArcBuilder<State, OutputContext>) => NodeRef)): this; | ||
| to<Node extends NodeRef>(node: Node | Node[] | ((arc: ArcBuilder<State, OutputContext>) => NodeRef)): ReturnType<EdgeBuilder<State, OutputContext>["to"]>; | ||
| to(node: NodeRef | NodeRef[] | ((arc: ArcBuilder<State, OutputContext>) => NodeRef) | ((arc: ArcBuilder<State, OutputContext>) => NodeRef)[]): ReturnType<EdgeBuilder<State, OutputContext>["to"]>; | ||
| condition<ConditionName extends string>(name: ConditionName, fn: (sc: ArcStateContext<State, OutputContext>) => boolean): string; | ||
@@ -500,6 +573,6 @@ } | ||
| (id: string): ArcBuilder<State, OutputContext>; | ||
| (id: string, configurator: (arc: ArcBuilder<State, OutputContext>) => void): Arc$1<State, OutputContext>; | ||
| (id: string, configurator: (arc: EdgeChainBuilder<State, OutputContext>) => void): Arc$1<State, OutputContext>; | ||
| }; | ||
| declare function defineArc<State extends Record<string, any>, OutputContext extends Record<string, any> = any>(id: string): ArcBuilder<State, OutputContext>; | ||
| declare function defineArc<State extends Record<string, any>, OutputContext extends Record<string, any> = any>(id: string, configurator: (arc: ArcBuilder<State, OutputContext>) => void): Arc$1<State, OutputContext>; | ||
| declare function defineArc<State extends Record<string, any>, OutputContext extends Record<string, any> = any>(id: string, configurator: (arc: EdgeChainBuilder<State, OutputContext>) => void): Arc$1<State, OutputContext>; | ||
| /** | ||
@@ -511,21 +584,2 @@ * Legacy function name - use defineArc instead | ||
| declare class TerminalChannel { | ||
| private readonly verbosity?; | ||
| private currentNode; | ||
| private streamingNodeId; | ||
| constructor(verbosity?: LogVerbosity | undefined); | ||
| consume<State extends Record<string, any>, OutputContext extends Record<string, any>>(runtime: ArcRuntime, events: AsyncIterable<ArcEvent<State, OutputContext>>): Promise<{ | ||
| finalState: State; | ||
| finalContext: OutputContext; | ||
| }>; | ||
| private streamEvent; | ||
| private printNodeHeader; | ||
| private printLog; | ||
| private shouldLog; | ||
| private printSuccess; | ||
| private printError; | ||
| private printObject; | ||
| private askUser; | ||
| } | ||
| declare class ArcState<State extends Record<string, any>, OutputContext extends Record<string, any> = Record<string, never>> { | ||
@@ -535,3 +589,4 @@ private state; | ||
| private edgeContext; | ||
| constructor(initial: State); | ||
| private models; | ||
| constructor(initial: State, models: Models); | ||
| getState(): Map$1<string, any>; | ||
@@ -541,2 +596,3 @@ getContext(): Map$1<string, any> & OutputContext; | ||
| getStateContext(): ArcStateContext<State, OutputContext>; | ||
| getModels(): Models; | ||
| setState(newState: Map$1<string, any>): Map$1<string, any>; | ||
@@ -557,6 +613,6 @@ setContext<K extends string, V>(key: K, value: V): Map$1<string, any> & (OutputContext & { | ||
| edgeContext?: Record<string, any>; | ||
| }): ArcState<State, OutputContext>; | ||
| }, models: Models): ArcState<State, OutputContext>; | ||
| } | ||
| export { ArcBuilder, ArcNodeKind, ArcRunStatus, ArcState, LogVerbosityLevel, TerminalChannel, action, agent, arc as arcNode, createAction, createAgent, Arc as createArc, defineArc }; | ||
| export type { Arc$1 as Arc, ArcCompletedEvent, ArcEdge, ArcEdgeCondition, ArcErrorEvent, ArcEvent, ArcEventType, ArcNode, ArcOutputContext, ArcRunId, ArcRunResult, ArcRuntime, ArcStartedEvent, ArcStateContext, AvailableOutputs, EventValidator, InferContext, InferContextFromAgents, InferOutputContext, InferOutputContextFromAgents, LogEvent, LogVerbosity, NodeCompletedEvent, NodeErrorEvent, NodeOutputTokenEvent, NodePausedEvent, NodeRef, NodeStartedEvent, OutputContextFromOutput, TypedImmutableMap, ValidationResult, WaitConfig }; | ||
| export { ArcBuilder, ArcNodeKind, ArcRunStatus, ArcState, LogVerbosityLevel, action, agent, arc as arcNode, createAction, createAgent, Arc as createArc, defineArc }; | ||
| export type { Arc$1 as Arc, ArcCompletedEvent, ArcEdge, ArcEdgeCondition, ArcErrorEvent, ArcEvent, ArcEventType, ArcNode, ArcOutputContext, ArcRunId, ArcRunResult, ArcRuntime, ArcStartedEvent, ArcStateContext, AvailableOutputs, EventValidator, InferContext, InferContextFromAgents, InferOutputContext, InferOutputContextFromAgents, LogEvent, LogVerbosity, NodeCompletedEvent, NodeErrorEvent, NodeOutputDeltaEvent, NodePausedEvent, NodeRef, NodeStartedEvent, OutputContextFromOutput, TypedImmutableMap, ValidationResult, WaitConfig }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,GAAG,IAAI,SAAS,EAAE,gBAAgB;AAClC,MAAM,EACN,KAAK,EACL,OAAO,EACP,YAAY,EACZ,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,GAAG,IAAI,SAAS,EAAE,gBAAgB;AAClC,MAAM,EACN,KAAK,EACL,OAAO,EACP,YAAY,EACZ,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC"} |
+185
-260
| import { z } from 'zod'; | ||
| import { Map as Map$1 } from 'immutable'; | ||
| export { Map as ImmutableMap } from 'immutable'; | ||
| import { createModels } from '@arc-dev/models'; | ||
| import * as readline from 'node:readline'; | ||
@@ -226,4 +224,3 @@ var ArcNodeKind; | ||
| id: `${id}-agent`, | ||
| run: async function* (stateContext) { | ||
| const models = createModels(); | ||
| run: async function* (stateContext, nodeId, models) { | ||
| const model = models.get(config.model); | ||
@@ -249,3 +246,3 @@ const messages = config.messages(stateContext); | ||
| yield { | ||
| type: "node-output-token", | ||
| type: "node-output-delta", | ||
| nodeId: id, | ||
@@ -260,3 +257,3 @@ chunk: streamEvent.chunk, | ||
| yield { | ||
| type: "node-output-token", | ||
| type: "node-output-delta", | ||
| nodeId: id, | ||
@@ -283,3 +280,3 @@ chunk: "", | ||
| id: `${id}-action`, | ||
| run: async function* (stateContext) { | ||
| run: async function* (stateContext, nodeId, models) { | ||
| const result = await handler(stateContext); | ||
@@ -294,4 +291,4 @@ stateContext.__pendingState = result; | ||
| id: `${id}-arc`, | ||
| run: async function* () { | ||
| // NoOp | ||
| run: async function* (stateContext, nodeId, models) { | ||
| // NoOp - Arc nodes don't execute, they're just placeholders | ||
| }, | ||
@@ -369,6 +366,23 @@ arc, | ||
| } | ||
| // Otherwise, use direct NodeRef pattern | ||
| const nodes = Array.isArray(nodeIdOrNode) | ||
| ? nodeIdOrNode | ||
| : [nodeIdOrNode]; | ||
| // Handle factory functions and NodeRef objects | ||
| let nodes; | ||
| if (Array.isArray(nodeIdOrNode)) { | ||
| // Resolve factory functions in array | ||
| nodes = nodeIdOrNode.map((item) => { | ||
| if (typeof item === "function") { | ||
| return item(this.arcBuilder); | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
| else { | ||
| // Single item - could be factory function or NodeRef | ||
| const item = nodeIdOrNode; | ||
| if (typeof item === "function") { | ||
| nodes = [item(this.arcBuilder)]; | ||
| } | ||
| else { | ||
| nodes = [item]; | ||
| } | ||
| } | ||
| for (const node of nodes) { | ||
@@ -383,3 +397,5 @@ const edge = { | ||
| // Return ChainableEdgeBuilder for further chaining with simpler .to(node) pattern | ||
| return new ChainableEdgeBuilder(this.builder, lastNode.id, this.lastNodeId, lastNode.id, undefined, this.arcBuilder); | ||
| // Pass all nodes as sources to support fan-out: subsequent .to() calls will chain from all nodes | ||
| const sourceIds = nodes.map((node) => node.id); | ||
| return new ChainableEdgeBuilder(this.builder, lastNode.id, this.lastNodeId, lastNode.id, sourceIds, this.arcBuilder); | ||
| } | ||
@@ -443,6 +459,7 @@ } | ||
| const lastTarget = resolvedTargets[resolvedTargets.length - 1]; | ||
| // Return a new chainable builder with the last target as the new source | ||
| // Auto-chaining: last target becomes source for next .to() | ||
| // Return a new chainable builder with all targets as the new sources | ||
| // Auto-chaining: all targets become sources for next .to() (supports fan-out) | ||
| const newSources = resolvedTargets.map((target) => target.id); | ||
| return new ChainableEdgeBuilder(this.builder, lastTarget.id, sources[0], // Use first source for condition builder | ||
| lastTarget.id, undefined, // sources will be set from lastTarget | ||
| lastTarget.id, newSources, // Pass all targets as sources to support fan-out | ||
| this.arcBuilder); | ||
@@ -490,7 +507,8 @@ } | ||
| const lastTarget = resolvedTargets[resolvedTargets.length - 1]; | ||
| // Return chainable builder starting from the last target | ||
| // Return chainable builder starting from all targets | ||
| // Set up condition builder for the last edge created | ||
| // Use undefined for entry edges (when sourceNode is null) | ||
| // Auto-chaining: last target becomes source for next .to() | ||
| return new ChainableEdgeBuilder(builder, lastTarget.id, sourceNode || undefined, lastTarget.id, undefined, arcBuilder); | ||
| // Auto-chaining: all targets become sources for next .to() (supports fan-out) | ||
| const sourceIds = resolvedTargets.map((target) => target.id); | ||
| return new ChainableEdgeBuilder(builder, lastTarget.id, sourceNode || undefined, lastTarget.id, sourceIds, arcBuilder); | ||
| }, | ||
@@ -537,13 +555,19 @@ }; | ||
| } | ||
| // Handle factory functions | ||
| let resolvedNode; | ||
| if (typeof node === "function" && arcBuilder) { | ||
| resolvedNode = node(arcBuilder); | ||
| // Handle factory functions and NodeRef objects | ||
| let resolvedTargets; | ||
| if (Array.isArray(node)) { | ||
| // Resolve factory functions in array | ||
| resolvedTargets = node.map((item) => { | ||
| if (typeof item === "function" && arcBuilder) { | ||
| return item(arcBuilder); | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
| else if (typeof node === "function" && arcBuilder) { | ||
| resolvedTargets = [node(arcBuilder)]; | ||
| } | ||
| else { | ||
| resolvedNode = node; | ||
| resolvedTargets = [node]; | ||
| } | ||
| const resolvedTargets = Array.isArray(resolvedNode) | ||
| ? resolvedNode | ||
| : [resolvedNode]; | ||
| const source = this.sourceNode; | ||
@@ -561,3 +585,5 @@ for (const target of resolvedTargets) { | ||
| // This allows .to(node1).to(node2) without needing .from() in between | ||
| return new ChainableEdgeBuilder(this.builder, lastTarget.id, source, lastTarget.id, undefined, this.arcBuilder); | ||
| // Pass all targets as sources to support fan-out | ||
| const sourceIds = resolvedTargets.map((target) => target.id); | ||
| return new ChainableEdgeBuilder(this.builder, lastTarget.id, source, lastTarget.id, sourceIds, this.arcBuilder); | ||
| } | ||
@@ -571,2 +597,109 @@ condition(name, fn) { | ||
| /** | ||
| * Chainable builder for the simplified .edge() API | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const arc = defineArc<State>("my-arc", arc => | ||
| * arc | ||
| * .edge(node1, node2) | ||
| * .edge(node2, [node3, node4]) | ||
| * .edge(node3, node5) | ||
| * .when("condition-name", ({ context }) => context.get("key") === "value") | ||
| * ); | ||
| * ``` | ||
| */ | ||
| class EdgeChainBuilder { | ||
| arcBuilder; | ||
| internalBuilder; | ||
| lastEdge = null; | ||
| constructor(arcBuilder, internalBuilder) { | ||
| this.arcBuilder = arcBuilder; | ||
| this.internalBuilder = internalBuilder; | ||
| } | ||
| /** | ||
| * Create an edge from a source node to one or more target nodes. | ||
| * Automatically handles factory functions for node registration. | ||
| * | ||
| * @param from - Source node (NodeRef or factory function), or null/undefined for entry edge | ||
| * @param to - Target node(s) (NodeRef, NodeRef[], or factory function(s)) | ||
| * @param wait - Optional wait config for entry edges | ||
| * @returns This builder for chaining | ||
| */ | ||
| edge(from, to, wait) { | ||
| // Resolve source node (null/undefined for entry edges) | ||
| const fromNode = from === null || from === undefined | ||
| ? null | ||
| : typeof from === "function" | ||
| ? from(this.arcBuilder) | ||
| : from; | ||
| // Resolve target nodes | ||
| const toNodes = Array.isArray(to) | ||
| ? to.map((t) => (typeof t === "function" ? t(this.arcBuilder) : t)) | ||
| : [typeof to === "function" ? to(this.arcBuilder) : to]; | ||
| // Create edges for each target | ||
| for (const toNode of toNodes) { | ||
| const edge = { | ||
| from: fromNode?.id, | ||
| to: toNode.id, | ||
| wait: wait, | ||
| }; | ||
| this.internalBuilder.addEdge(edge); | ||
| this.lastEdge = edge; // Track last edge for .when() | ||
| } | ||
| return this; | ||
| } | ||
| /** | ||
| * Apply a condition to the last edge created. | ||
| * | ||
| * @param name - Condition name | ||
| * @param condition - Condition function | ||
| * @returns This builder for chaining | ||
| */ | ||
| when(name, condition) { | ||
| if (!this.lastEdge) { | ||
| throw new Error("Cannot call .when() before creating an edge with .edge()"); | ||
| } | ||
| // Register the condition | ||
| this.arcBuilder.condition(name, condition); | ||
| // Apply condition to the last edge | ||
| this.lastEdge.condition = name; | ||
| return this; | ||
| } | ||
| /** | ||
| * Create a loop with explicit configuration. | ||
| * @param node - The node or sub-arc to loop | ||
| * @param config - Loop configuration with while condition and max iterations | ||
| */ | ||
| loop(node, config) { | ||
| this.arcBuilder.loop(node, config); | ||
| return this; | ||
| } | ||
| /** | ||
| * Use a sub-arc as a step in this arc. | ||
| * @param id - The node ID for the sub-arc | ||
| * @param arc - The sub-arc to use | ||
| * @returns A NodeRef for the sub-arc node | ||
| */ | ||
| use(id, arc) { | ||
| return this.arcBuilder.use(id, arc); | ||
| } | ||
| /** | ||
| * Wait for input with the given ID, then create an edge to the target node. | ||
| * This is a convenience method that creates an entry edge with wait config. | ||
| * | ||
| * @param id - The input ID to wait for | ||
| * @param to - Target node(s) (NodeRef, NodeRef[], or factory function(s)) | ||
| * @returns This builder for chaining | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * arc.waitForInput("player", playerMoveAction) | ||
| * .edge(playerMoveAction, nextNode) | ||
| * ``` | ||
| */ | ||
| waitForInput(id, to) { | ||
| return this.edge(null, to, { id }); | ||
| } | ||
| } | ||
| /** | ||
| * Main Arc builder API that provides both node and edge methods. | ||
@@ -726,8 +859,11 @@ * This is the primary interface for building arcs programmatically. | ||
| }); | ||
| const arcBuilder = new ArcBuilder(internalBuilder); | ||
| if (configurator) { | ||
| configurator(arcBuilder); | ||
| return internalBuilder.build(); | ||
| const arcBuilder = new ArcBuilder(internalBuilder); | ||
| const edgeBuilder = new EdgeChainBuilder(arcBuilder, internalBuilder); | ||
| configurator(edgeBuilder); | ||
| // Build from the arc builder | ||
| return arcBuilder.build(); | ||
| } | ||
| return arcBuilder; | ||
| // Return ArcBuilder for imperative usage | ||
| return new ArcBuilder(internalBuilder); | ||
| }; | ||
@@ -741,8 +877,11 @@ return curriedFn; | ||
| }); | ||
| const arcBuilder = new ArcBuilder(internalBuilder); | ||
| if (configurator) { | ||
| configurator(arcBuilder); | ||
| return internalBuilder.build(); | ||
| const arcBuilder = new ArcBuilder(internalBuilder); | ||
| const edgeBuilder = new EdgeChainBuilder(arcBuilder, internalBuilder); | ||
| configurator(edgeBuilder); | ||
| // Build from the arc builder | ||
| return arcBuilder.build(); | ||
| } | ||
| return arcBuilder; | ||
| // Return ArcBuilder for imperative usage | ||
| return new ArcBuilder(internalBuilder); | ||
| } | ||
@@ -777,221 +916,2 @@ /** | ||
| class TerminalChannel { | ||
| verbosity; | ||
| currentNode; | ||
| streamingNodeId; | ||
| constructor(verbosity) { | ||
| this.verbosity = verbosity; | ||
| this.verbosity = verbosity ?? LogVerbosityLevel.Info; | ||
| } | ||
| async consume(runtime, events) { | ||
| let finalState; | ||
| let finalContext; | ||
| console.log("🚀 Starting Arc execution..."); | ||
| console.log(); | ||
| let nodeIndex = 0; | ||
| for await (const event of events) { | ||
| this.streamEvent(event); | ||
| switch (event.type) { | ||
| case "arc-started": { | ||
| console.log(`\x1b[36mArc "${event.arcId}" started\x1b[0m`); | ||
| if (event.initialState && | ||
| Object.keys(event.initialState).length > 0) { | ||
| console.log("\x1b[90mInitial State:\x1b[0m"); | ||
| this.printObject(event.initialState, 2); | ||
| } | ||
| console.log(); | ||
| break; | ||
| } | ||
| case "arc-completed": { | ||
| console.log(); | ||
| this.printSuccess(`Arc "${event.arcId}" completed successfully`); | ||
| finalState = event.finalState; | ||
| finalContext = event.finalContext; | ||
| if (event.finalState && Object.keys(event.finalState).length > 0) { | ||
| console.log("\x1b[90mFinal State:\x1b[0m"); | ||
| this.printObject(event.finalState, 2); | ||
| } | ||
| if (event.finalContext && | ||
| Object.keys(event.finalContext).length > 0) { | ||
| console.log("\x1b[90mFinal Context:\x1b[0m"); | ||
| this.printObject(event.finalContext, 2); | ||
| } | ||
| break; | ||
| } | ||
| case "arc-error": { | ||
| console.log(); | ||
| this.printError(event.error); | ||
| throw event.error; | ||
| } | ||
| case "log": { | ||
| this.printLog(event.level, event.message); | ||
| break; | ||
| } | ||
| case "node-started": { | ||
| if (event.nodeId && event.nodeId !== this.currentNode) { | ||
| if (nodeIndex > 0) { | ||
| console.log(); | ||
| } | ||
| this.currentNode = event.nodeId; | ||
| this.printNodeHeader(event.nodeId); | ||
| nodeIndex++; | ||
| } | ||
| break; | ||
| } | ||
| case "node-completed": { | ||
| if (event.state && Object.keys(event.state).length > 0) { | ||
| console.log("\x1b[90m State:\x1b[0m"); | ||
| this.printObject(event.state, 4); | ||
| } | ||
| if (event.context && Object.keys(event.context).length > 0) { | ||
| console.log("\x1b[90m Context:\x1b[0m"); | ||
| this.printObject(event.context, 4); | ||
| } | ||
| break; | ||
| } | ||
| case "node-error": { | ||
| console.log(); | ||
| console.log(`\x1b[31m✗ Node "${event.nodeId}" failed: ${event.error.message}\x1b[0m`); | ||
| if (event.error.stack) { | ||
| console.log(`\x1b[90m${event.error.stack}\x1b[0m`); | ||
| } | ||
| throw event.error; | ||
| } | ||
| case "node-paused": { | ||
| console.log(); | ||
| const answer = await this.askUser(event.prompt || "Enter input: "); | ||
| const resumeKey = event.sessionId || event.nodeId; | ||
| await runtime.resume(resumeKey, answer); | ||
| break; | ||
| } | ||
| case "node-output-token": { | ||
| if (event.nodeId !== this.streamingNodeId) { | ||
| // Start of a new stream | ||
| this.streamingNodeId = event.nodeId; | ||
| process.stdout.write("\x1b[90m "); | ||
| } | ||
| if (event.chunk) { | ||
| // Write chunk directly to stdout for real-time streaming | ||
| process.stdout.write(event.chunk); | ||
| } | ||
| if (event.done) { | ||
| // End of stream | ||
| process.stdout.write("\x1b[0m\n"); | ||
| this.streamingNodeId = undefined; | ||
| } | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (!finalState || !finalContext) { | ||
| throw new Error("Arc did not complete successfully"); | ||
| } | ||
| return { finalState, finalContext }; | ||
| } | ||
| streamEvent(event) { | ||
| // Stream event information - can be extended to emit to other streams | ||
| // For now, events are handled in the switch statement above | ||
| } | ||
| printNodeHeader(id) { | ||
| console.log(`\x1b[36m→ ${id}\x1b[0m`); | ||
| } | ||
| printLog(level, message) { | ||
| if (this.shouldLog(level)) { | ||
| return; | ||
| } | ||
| const colors = { | ||
| debug: "\x1b[90m", // gray | ||
| info: "\x1b[36m", // cyan | ||
| warn: "\x1b[33m", // yellow | ||
| error: "\x1b[31m", // red | ||
| fatal: "\x1b[31m", // red | ||
| trace: "\x1b[90m", // gray | ||
| }; | ||
| const color = colors[level] || "\x1b[0m"; | ||
| const prefix = level.toUpperCase().padEnd(5); | ||
| console.log(` ${color}[${prefix}] ${message}\x1b[0m`); | ||
| } | ||
| shouldLog(level) { | ||
| if (this.verbosity === LogVerbosityLevel.Silent) { | ||
| return true; | ||
| } | ||
| const levels = [ | ||
| "silent", | ||
| "fatal", | ||
| "error", | ||
| "warn", | ||
| "info", | ||
| "debug", | ||
| "trace", | ||
| ]; | ||
| const verbosityIndex = levels.indexOf(this.verbosity || LogVerbosityLevel.Info); | ||
| const levelIndex = levels.indexOf(level); | ||
| return levelIndex > verbosityIndex; | ||
| } | ||
| printSuccess(message = "Arc completed successfully") { | ||
| console.log(`\x1b[32m✓ ${message}\x1b[0m`); | ||
| } | ||
| printError(error) { | ||
| console.log(`\x1b[31m✗ Arc failed: ${error.message}\x1b[0m`); | ||
| if (error.stack) { | ||
| console.log(`\x1b[90m${error.stack}\x1b[0m`); | ||
| } | ||
| } | ||
| printObject(obj, indent = 0) { | ||
| const indentStr = " ".repeat(indent); | ||
| const formatValue = (value) => { | ||
| if (value === null) | ||
| return "\x1b[90mnull\x1b[0m"; | ||
| if (value === undefined) | ||
| return "\x1b[90mundefined\x1b[0m"; | ||
| if (typeof value === "string") | ||
| return `\x1b[33m"${value}"\x1b[0m`; | ||
| if (typeof value === "number") | ||
| return `\x1b[35m${value}\x1b[0m`; | ||
| if (typeof value === "boolean") | ||
| return `\x1b[35m${value}\x1b[0m`; | ||
| if (Array.isArray(value)) { | ||
| if (value.length === 0) | ||
| return "\x1b[90m[]\x1b[0m"; | ||
| return `[\n${value | ||
| .map((v) => `${indentStr} ${formatValue(v)}`) | ||
| .join(",\n")}\n${indentStr}]`; | ||
| } | ||
| if (typeof value === "object") { | ||
| const keys = Object.keys(value); | ||
| if (keys.length === 0) | ||
| return "\x1b[90m{}\x1b[0m"; | ||
| return `{\n${keys | ||
| .map((k) => `${indentStr} \x1b[36m${k}\x1b[0m: ${formatValue(value[k])}`) | ||
| .join(",\n")}\n${indentStr}}`; | ||
| } | ||
| return String(value); | ||
| }; | ||
| if (typeof obj === "object" && obj !== null && !Array.isArray(obj)) { | ||
| const keys = Object.keys(obj); | ||
| if (keys.length === 0) { | ||
| console.log(`${indentStr}\x1b[90m{}\x1b[0m`); | ||
| return; | ||
| } | ||
| keys.forEach((key) => { | ||
| console.log(`${indentStr}\x1b[36m${key}\x1b[0m: ${formatValue(obj[key])}`); | ||
| }); | ||
| } | ||
| else { | ||
| console.log(`${indentStr}${formatValue(obj)}`); | ||
| } | ||
| } | ||
| async askUser(prompt) { | ||
| const rl = readline.createInterface({ | ||
| input: process.stdin, | ||
| output: process.stdout, | ||
| }); | ||
| const answer = await new Promise((resolve) => { | ||
| rl.question(`\x1b[33m${prompt}\x1b[0m `, resolve); | ||
| }); | ||
| rl.close(); | ||
| return answer; | ||
| } | ||
| } | ||
| class ArcState { | ||
@@ -1001,6 +921,8 @@ state; | ||
| edgeContext; | ||
| constructor(initial) { | ||
| models; | ||
| constructor(initial, models) { | ||
| this.state = Map$1(initial); | ||
| this.nodeContext = Map$1(); | ||
| this.edgeContext = Map$1(); | ||
| this.models = models; | ||
| } | ||
@@ -1023,2 +945,5 @@ getState() { | ||
| } | ||
| getModels() { | ||
| return this.models; | ||
| } | ||
| setState(newState) { | ||
@@ -1048,4 +973,4 @@ this.state = newState; | ||
| } | ||
| static fromSerialized(serialized) { | ||
| const arcState = new ArcState(serialized.state); | ||
| static fromSerialized(serialized, models) { | ||
| const arcState = new ArcState(serialized.state, models); | ||
| if (serialized.nodeContext) { | ||
@@ -1065,3 +990,3 @@ for (const [key, value] of Object.entries(serialized.nodeContext)) { | ||
| export { ArcBuilder, ArcNodeKind, ArcRunStatus, ArcState, LogVerbosityLevel, TerminalChannel, action, agent, arc as arcNode, createAction, createAgent, Arc as createArc, defineArc }; | ||
| export { ArcBuilder, ArcNodeKind, ArcRunStatus, ArcState, LogVerbosityLevel, action, agent, arc as arcNode, createAction, createAgent, Arc as createArc, defineArc }; | ||
| //# sourceMappingURL=index.js.map |
+5
-2
| import { Map as ImmutableMap } from "immutable"; | ||
| import { ArcStateContext } from "./types/state"; | ||
| import type { Models } from "@arc-dev/model"; | ||
| export declare class ArcState<State extends Record<string, any>, OutputContext extends Record<string, any> = Record<string, never>> { | ||
@@ -7,3 +8,4 @@ private state; | ||
| private edgeContext; | ||
| constructor(initial: State); | ||
| private models; | ||
| constructor(initial: State, models: Models); | ||
| getState(): ImmutableMap<string, any>; | ||
@@ -13,2 +15,3 @@ getContext(): ImmutableMap<string, any> & OutputContext; | ||
| getStateContext(): ArcStateContext<State, OutputContext>; | ||
| getModels(): Models; | ||
| setState(newState: ImmutableMap<string, any>): ImmutableMap<string, any>; | ||
@@ -29,4 +32,4 @@ setContext<K extends string, V>(key: K, value: V): ImmutableMap<string, any> & (OutputContext & { | ||
| edgeContext?: Record<string, any>; | ||
| }): ArcState<State, OutputContext>; | ||
| }, models: Models): ArcState<State, OutputContext>; | ||
| } | ||
| //# sourceMappingURL=state.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,eAAe,EAAqB,MAAM,eAAe,CAAC;AAEnE,qBAAa,QAAQ,CACnB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAEjE,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,WAAW,CAA4B;gBAEnC,OAAO,EAAE,KAAK;IAM1B,QAAQ,IAAI,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC;IAIrC,UAAU,IAAI,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,aAAa;IAIvD,cAAc,IAAI,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC;IAI3C,eAAe,IAAI,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC;IAQxD,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC;IAKxE,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAC5B,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,CAAC,GACP,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,GAAG;SAAG,CAAC,IAAI,CAAC,GAAG,CAAC;KAAE,CAAC;IAYhE,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE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AG,aAAa;IAIvD,cAAc,IAAI,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC;IAI3C,eAAe,IAAI,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC;IAQxD,SAAS,IAAI,MAAM;IAInB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC;IAKxE,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAC5B,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,CAAC,GACP,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,GAAG;SAAG,CAAC,IAAI,CAAC,GAAG,CAAC;KAAE,CAAC;IAYhE,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAIhD,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAItC,SAAS,IAAI;QACX,KAAK,EAAE,GAAG,CAAC;QACX,WAAW,EAAE,GAAG,CAAC;QACjB,WAAW,EAAE,GAAG,CAAC;KAClB;IAQD,MAAM,CAAC,cAAc,CACnB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAEzC,UAAU,EAAE;QACV,KAAK,EAAE,KAAK,CAAC;QACb,WAAW,CAAC,EAAE,aAAa,CAAC;QAC5B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACnC,EACD,MAAM,EAAE,MAAM,GACb,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;CAoBlC"} |
| import { LogVerbosity } from "./logging"; | ||
| export type ArcEventType = "log" | "arc-started" | "arc-completed" | "arc-error" | "node-started" | "node-completed" | "node-error" | "node-paused" | "node-output-token"; | ||
| export type ArcEventType = "log" | "arc-started" | "arc-completed" | "arc-error" | "node-started" | "node-completed" | "node-error" | "node-paused" | "node-output-delta"; | ||
| type BaseEvent = { | ||
@@ -56,4 +56,4 @@ timestamp: number; | ||
| }; | ||
| export type NodeOutputTokenEvent = BaseEvent & { | ||
| type: "node-output-token"; | ||
| export type NodeOutputDeltaEvent = BaseEvent & { | ||
| type: "node-output-delta"; | ||
| nodeId: string; | ||
@@ -63,4 +63,4 @@ chunk: string; | ||
| }; | ||
| export type ArcEvent<State extends Record<string, any>, OutputContext extends Record<string, any>> = LogEvent | ArcStartedEvent<State> | ArcCompletedEvent<State, OutputContext> | ArcErrorEvent | NodeStartedEvent | NodeCompletedEvent<State, OutputContext> | NodeErrorEvent | NodePausedEvent<State, OutputContext> | NodeOutputTokenEvent; | ||
| export type ArcEvent<State extends Record<string, any>, OutputContext extends Record<string, any>> = LogEvent | ArcStartedEvent<State> | ArcCompletedEvent<State, OutputContext> | ArcErrorEvent | NodeStartedEvent | NodeCompletedEvent<State, OutputContext> | NodeErrorEvent | NodePausedEvent<State, OutputContext> | NodeOutputDeltaEvent; | ||
| export {}; | ||
| //# sourceMappingURL=events.d.ts.map |
| import type { Arc } from "./arc"; | ||
| import { ArcStateContext } from "./state"; | ||
| import { ArcEvent } from "./events"; | ||
| import type { Models } from "@arc-dev/model"; | ||
| export declare enum ArcNodeKind { | ||
@@ -14,3 +15,3 @@ Agent = "agent", | ||
| id: string; | ||
| run: (sc: ArcStateContext<State, OutputContext>, nodeId: string) => AsyncIterable<ArcEvent<State, OutputContext>>; | ||
| run: (sc: ArcStateContext<State, OutputContext>, nodeId: string, models: Models) => AsyncIterable<ArcEvent<State, OutputContext>>; | ||
| arc?: Arc<State, OutputContext>; | ||
@@ -17,0 +18,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/types/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,M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ClB,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,GAAG,EAAE,CACH,EAAE,EAAE,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,EACzC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,KACX,aAAa,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;QACnD,GAAG,CAAC,EAAE,GAAG,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;KACjC,CAAC;CACH"} |
+2
-2
| { | ||
| "name": "@arc-dev/core", | ||
| "version": "0.0.2-alpha.6", | ||
| "version": "0.0.2-alpha.7", | ||
| "description": "Core ARC runtime types utilities and builder", | ||
@@ -38,3 +38,3 @@ "type": "module", | ||
| "zod": "^4.1.13", | ||
| "@arc-dev/models": "0.0.2-alpha.5" | ||
| "@arc-dev/model": "0.0.2-alpha.6" | ||
| }, | ||
@@ -41,0 +41,0 @@ "scripts": { |
| export * from "./terminal"; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"} |
| import { ArcRuntime } from "../types/runtime"; | ||
| import { ArcEvent } from "../types/events"; | ||
| import { LogVerbosity } from "../types/logging"; | ||
| export declare class TerminalChannel { | ||
| private readonly verbosity?; | ||
| private currentNode; | ||
| private streamingNodeId; | ||
| constructor(verbosity?: LogVerbosity | undefined); | ||
| consume<State extends Record<string, any>, OutputContext extends Record<string, any>>(runtime: ArcRuntime, events: AsyncIterable<ArcEvent<State, OutputContext>>): Promise<{ | ||
| finalState: State; | ||
| finalContext: OutputContext; | ||
| }>; | ||
| private streamEvent; | ||
| private printNodeHeader; | ||
| private printLog; | ||
| private shouldLog; | ||
| private printSuccess; | ||
| private printError; | ||
| private printObject; | ||
| private askUser; | ||
| } | ||
| //# sourceMappingURL=terminal.d.ts.map |
| {"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../src/channels/terminal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAqB,MAAM,kBAAkB,CAAC;AAEnE,qBAAa,eAAe;IAId,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;IAHvC,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,eAAe,CAAqB;gBAEf,SAAS,CAAC,EAAE,YAAY,YAAA;IAI/C,OAAO,CACX,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAEzC,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,GACpD,OAAO,CAAC;QAAE,UAAU,EAAE,KAAK,CAAC;QAAC,YAAY,EAAE,aAAa,CAAA;KAAE,CAAC;IAkI9D,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,QAAQ;IAmBhB,OAAO,CAAC,SAAS;IAuBjB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,WAAW;YA0CL,OAAO;CAatB"} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
321753
-4.01%46
-8%3209
-1.59%+ Added
+ Added
- Removed
- Removed