CodeAct sandbox graph builder runs on the shared graph DSL core - #4782
Merged
Conversation
nodetool.graph() in the CodeAct sandbox and the GraphPlanner's submit_graph programs were two hand-rolled graph DSLs with divergent semantics: different handle shapes, different auto-id schemes, and the sandbox builder missing the DSL's guards. Extract one guest-side core (src/graph-dsl-core.ts) and rebuild both surfaces on it. The sandbox builder gains the DSL's validation: node(type, props) argument checks, snake_case auto ids, connect() refusing an id the graph does not have, and handles that throw when interpolated into a string instead of silently wiring nothing and leaving "[object Object]" in a property. The planner DSL gains the duplicate-explicit-id check. The sandbox layer keeps only the tool-backed methods (validate/save/run). Also sync the agents package's stale package-lock entry with its package.json (@napi-rs/canvas, @nodetool-ai/image-editor). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QJiThBaVnDxz4ipkQuGdd7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
nodetool.graph()in the CodeAct sandbox and the GraphPlanner'ssubmit_graphDSL were two hand-rolled graph-building implementations with divergent semantics: incompatible handle shapes (__ntOutput/node/slotvs__handle/source/sourceHandle), different auto-id schemes (stringinput_1vsstring_input), and the sandbox builder missing the DSL's guards. This extracts one guest-side core —packages/agents/src/graph-dsl-core.ts(__graphDslBuilder) — and rebuilds both surfaces on it, so a wiring fix lands in both and the two DSLs cannot drift.Validation the sandbox builder gains
ref.output()into a string used to silently wire nothing and leave"[object Object]"in a property — a broken graph that only failed downstream. It now throws at the point of the mistake (Symbol.toPrimitiveguard, previously planner-only).connect()id checks: connecting to an id the graph does not have now throws naming the known ids, instead of producing a dangling edge caught only byvalidate_workflow.node(type, props)argument validation and a required non-emptytargetHandleonconnect().text_to_image,text_to_image_2) — the planner DSL's readable scheme replaces the builder'stexttoimage_2.The planner DSL gains the duplicate-explicit-id check the builder already had. The sandbox layer keeps only what needs the toolbelt:
validate(),save(), and the save-and-runrun().Succinctness
The planner's
GRAPH_DSL_PRELUDEshrinks to a thin wrapper (node()/graph()over one core builder), andnodetool-api.tsdrops its ~150-line duplicate builder. Sandbox refs and planner refs now share one shape (both carry.set(),.properties, interchangeable handles), and the graph-namespace prompt section documents the new build-time checks in two lines.Tests
tests/graph-dsl.test.ts: +2 (interpolated-handle refusal, duplicate explicit id); existing id-scheme and wiring tests pass unchanged.tests/nodetool-api.test.ts: +1 (build-time wiring validation: interpolation guard, unknownconnect()target, bad type, snake_case ids).packages/agentssuite: 150 files, 2132 passed.npm run lintclean;npm run typecheckclean for web and electron (mobile has no dependency tree in this container — pre-existing, unrelated).Also syncs the agents package's stale
package-lock.jsonentry with itspackage.json(@napi-rs/canvas,@nodetool-ai/image-editor), which was breaking clean installs.🤖 Generated with Claude Code
https://claude.ai/code/session_01QJiThBaVnDxz4ipkQuGdd7
Generated by Claude Code