currentDocId and import

These commands expose document context and external script loading behavior in runtime orchestration flows.

Syntax

@curDocId currentDocId
import "myApp" "mainChatScript"

# force import check each build pass
!import "myApp" "mainChatScript"

Example

@curDocId currentDocId
@agent7 alias $curDocId agent1

Example based on tests/pipelines/customTypes/fakeAgentTest.mjs. currentDocId returns the current document id string and is useful for dynamic aliasing or contextual method calls.

import "myApp" "mainChatScript"
!import "myApp" "mainChatScript"

import expects two arguments: appName and scriptName. Runtime loads script text via CodeManager, parses commands, defines variables in current document, and restarts build if definitions changed. Use !import when external script state must be rechecked on every build cycle.

Step-by-Step Interaction

The currentDocId command reads execution context from the active build and returns the current document identifier as plain value that other commands can consume. The import command then uses the supplied appName and scriptName to request script content from CodeManager. After retrieval, the runtime parses imported commands and defines each resulting variable in the current document graph. If the import operation changes at least one definition, the runtime restarts the build so dependency propagation remains consistent with the newly imported command surface.

Runtime Behavior Notes

The currentDocId command is intentionally minimal and deterministic, because its only responsibility is to expose document context as data. The import command is structural and potentially disruptive by design, because it can redefine variables and commands inside the active graph. For that reason, missing import parameters raise runtime errors immediately, and successful imports can trigger a controlled rebuild phase to keep graph state coherent. Use !import or import! to force import execution on every build pass.