@parcha/agentrun-dsl 0.1.0-beta.4 → 0.1.0-beta.40
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.
- package/README.md +167 -23
- package/dist/author-references.d.ts +8 -0
- package/dist/author-references.js +8 -0
- package/dist/author.d.ts +13 -5
- package/dist/author.js +47 -18
- package/dist/authoring.js +2 -2
- package/dist/cli.js +17 -12
- package/dist/code-exec.d.ts +6 -0
- package/dist/code-exec.js +126 -0
- package/dist/decision-provider.d.ts +165 -0
- package/dist/decision-provider.js +238 -0
- package/dist/decision-receipts.d.ts +159 -0
- package/dist/decision-receipts.js +93 -0
- package/dist/dry-run.d.ts +45 -2
- package/dist/dry-run.js +159 -26
- package/dist/evidence.d.ts +19 -0
- package/dist/evidence.js +62 -0
- package/dist/graph.d.ts +169 -0
- package/dist/graph.js +433 -0
- package/dist/index.d.ts +19 -11
- package/dist/index.js +14 -9
- package/dist/inspection.d.ts +5 -0
- package/dist/inspection.js +16 -3
- package/dist/job.d.ts +14 -0
- package/dist/job.js +5 -0
- package/dist/long-timer.d.ts +7 -0
- package/dist/long-timer.js +22 -0
- package/dist/observer-snapshot.d.ts +3 -0
- package/dist/observer-snapshot.js +46 -0
- package/dist/predicates.d.ts +32 -0
- package/dist/predicates.js +61 -0
- package/dist/recovery/binding.d.ts +10 -0
- package/dist/recovery/binding.js +43 -0
- package/dist/recovery/call-key.d.ts +9 -0
- package/dist/recovery/call-key.js +17 -0
- package/dist/recovery/canonical-hash.d.ts +7 -0
- package/dist/recovery/canonical-hash.js +22 -0
- package/dist/recovery/driver.d.ts +235 -0
- package/dist/recovery/driver.js +1333 -0
- package/dist/recovery/errors.d.ts +31 -0
- package/dist/recovery/errors.js +51 -0
- package/dist/recovery/execution-path.d.ts +53 -0
- package/dist/recovery/execution-path.js +167 -0
- package/dist/recovery/file-store.d.ts +7 -0
- package/dist/recovery/file-store.js +131 -0
- package/dist/recovery/frozen-snapshot.d.ts +274 -0
- package/dist/recovery/frozen-snapshot.js +187 -0
- package/dist/recovery/handoff-receipts.d.ts +7 -0
- package/dist/recovery/handoff-receipts.js +10 -0
- package/dist/recovery/index.d.ts +14 -0
- package/dist/recovery/index.js +13 -0
- package/dist/recovery/item-state.d.ts +48 -0
- package/dist/recovery/item-state.js +89 -0
- package/dist/recovery/journal.d.ts +28 -0
- package/dist/recovery/journal.js +139 -0
- package/dist/recovery/memory-store.d.ts +4 -0
- package/dist/recovery/memory-store.js +20 -0
- package/dist/recovery/store.d.ts +105 -0
- package/dist/recovery/store.js +6 -0
- package/dist/recovery/testing/conformance.d.ts +4 -0
- package/dist/recovery/testing/conformance.js +268 -0
- package/dist/recovery/testing/crash-points.d.ts +18 -0
- package/dist/recovery/testing/crash-points.js +43 -0
- package/dist/recovery/testing/crash-sweep.d.ts +65 -0
- package/dist/recovery/testing/crash-sweep.js +146 -0
- package/dist/recovery/testing/index.d.ts +3 -0
- package/dist/recovery/testing/index.js +4 -0
- package/dist/recovery/testing/preload.d.ts +1 -0
- package/dist/recovery/testing/preload.js +3 -0
- package/dist/recovery/transport-facts.d.ts +23 -0
- package/dist/recovery/transport-facts.js +46 -0
- package/dist/recovery/with-recovery.d.ts +50 -0
- package/dist/recovery/with-recovery.js +144 -0
- package/dist/submit-envelope.d.ts +9 -0
- package/dist/submit-envelope.js +40 -0
- package/dist/system-one.d.ts +40 -2
- package/dist/system-one.js +141 -6
- package/dist/testing/decision-provider.d.ts +32 -0
- package/dist/testing/decision-provider.js +183 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +2 -0
- package/dist/vocabulary.d.ts +31 -3
- package/dist/vocabulary.js +46 -14
- package/dist/workflow-shape.d.ts +7 -0
- package/dist/workflow-shape.js +112 -68
- package/dist/workflow.d.ts +362 -29
- package/dist/workflow.js +1844 -430
- package/package.json +27 -4
- package/schema/workflow.schema.json +551 -12
- package/skills/author/SKILL.md +6 -1
- package/skills/author/references/jev-decisions.md +69 -12
- package/skills/author/references/language.md +41 -24
- package/skills/author/references/sdk-authoring.md +2 -0
package/dist/author.d.ts
CHANGED
|
@@ -39,7 +39,8 @@ export declare function authorContract(options?: {
|
|
|
39
39
|
export interface CandidatePolicyOptions {
|
|
40
40
|
/** Authoritative rubric text by section name. Every generative node must name every section. */
|
|
41
41
|
rubricSections?: Record<string, string>;
|
|
42
|
-
/** Admits code, call and artifact nodes.
|
|
42
|
+
/** Admits code, call and artifact nodes. A candidate's code is syntax-checked before acceptance and run only after
|
|
43
|
+
* its host accepts it; in-process code is not a sandbox (see the README's `code` node note). */
|
|
43
44
|
allowExecutableCandidates?: boolean;
|
|
44
45
|
/** Direct tool calls admitted without executable authorization. */
|
|
45
46
|
allowedEffectTools?: readonly string[];
|
|
@@ -47,9 +48,16 @@ export interface CandidatePolicyOptions {
|
|
|
47
48
|
}
|
|
48
49
|
/** Author policy over a candidate, checked before validation so a refused candidate never evaluates code. */
|
|
49
50
|
export declare function candidatePolicyErrors(candidate: unknown, options: CandidatePolicyOptions): string[];
|
|
51
|
+
export interface HostOutputTypeOptions {
|
|
52
|
+
/** The host's name for an authored artifact type: an authored spelling (another case, dashes for underscores,
|
|
53
|
+
* an alias) mapped to one of `host.outputTypes`, or null when it names none; its answer decides, so null leaves even
|
|
54
|
+
* an exact name as authored. Absent, a type is matched exactly. */
|
|
55
|
+
normalizeType?: (type: string) => string | null | undefined;
|
|
56
|
+
}
|
|
50
57
|
/** The interpreter's view of a workflow written in a host's vocabulary: an artifact of a declared prose output
|
|
51
|
-
* type becomes the report writer it is. Validate and run this view; retain and digest the authored bytes.
|
|
52
|
-
|
|
58
|
+
* type becomes the report writer it is. Validate and run this view; retain and digest the authored bytes. With
|
|
59
|
+
* `normalizeType`, an artifact's type is first mapped to the host's name for it. */
|
|
60
|
+
export declare function applyHostOutputTypes(candidate: Workflow, host: AuthorHostAddendum | undefined, options?: HostOutputTypeOptions): Workflow;
|
|
53
61
|
export interface AuthorWorkflowOptions {
|
|
54
62
|
request: string;
|
|
55
63
|
outputDir: string;
|
|
@@ -59,6 +67,8 @@ export interface AuthorWorkflowOptions {
|
|
|
59
67
|
/** Keys available to a candidate without an input schema; defaults to the host's initial state keys. */
|
|
60
68
|
inputKeys?: string[];
|
|
61
69
|
rubricSections?: Record<string, string>;
|
|
70
|
+
/** Admits code, call and artifact nodes. A candidate's code is syntax-checked before acceptance and run only after
|
|
71
|
+
* its host accepts it; in-process code is not a sandbox (see the README's `code` node note). */
|
|
62
72
|
allowExecutableCandidates?: boolean;
|
|
63
73
|
maxCandidates?: number;
|
|
64
74
|
/** Host acceptance over a structurally valid candidate, in the interpreter's view (`applyHostOutputTypes`):
|
|
@@ -79,8 +89,6 @@ export interface AuthoredWorkflow {
|
|
|
79
89
|
/** Author one workflow and retain every candidate with its review in a new directory under `outputDir`.
|
|
80
90
|
* Policy, validation and host acceptance review each submission; a rejection returns to the same session. */
|
|
81
91
|
export declare function authorWorkflow(options: AuthorWorkflowOptions): Promise<AuthoredWorkflow>;
|
|
82
|
-
/** The packaged author skill's name, as a skill-loading host registers it. */
|
|
83
|
-
export declare const AUTHOR_SKILL_NAME = "agentrun-author";
|
|
84
92
|
/** The absolute directory of the packaged author skill (the one holding SKILL.md). */
|
|
85
93
|
export declare function authorSkillDirectory(): string;
|
|
86
94
|
/** A reference shipped with the author skill, for hosts without file-reading tools. */
|
package/dist/author.js
CHANGED
|
@@ -5,7 +5,9 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
import { join, resolve } from "node:path";
|
|
6
6
|
import { validateWorkflow } from "./workflow.js";
|
|
7
7
|
import { SYSTEM_ONE_LIMITS } from "./system-one.js";
|
|
8
|
-
import { WORKFLOW_NODE_KINDS, NODE_FIELDS, WORKFLOW_PREDICATES, PREDICATE_FIELDS, MECHANICAL_PREDICATES, EFFORT_LEVELS, THINKING_LEVELS, MODEL_TIERS, CALL_TRANSPORTS, CALL_RETRY_CLASSES, PROSE_ARTIFACT_TYPES, GENERATIVE_NODE_KINDS, JUDGMENT_NODE_KINDS, } from "./vocabulary.js";
|
|
8
|
+
import { WORKFLOW_NODE_KINDS, NODE_FIELDS, WORKFLOW_PREDICATES, PREDICATE_FIELDS, MECHANICAL_PREDICATES, FIELD_TYPES, EFFORT_LEVELS, THINKING_LEVELS, MODEL_TIERS, AGENT_CONTEXTS, CALL_TRANSPORTS, CALL_RETRY_CLASSES, EFFECT_FAILURE_CODES, PROSE_ARTIFACT_TYPES, GENERATIVE_NODE_KINDS, JUDGMENT_NODE_KINDS, GUARD_SIGNALS, GUARDED_NODE_KINDS, SELF_CONFIDENCE_KINDS, } from "./vocabulary.js";
|
|
9
|
+
import { GUARD_QUESTION_MAX } from "./workflow.js";
|
|
10
|
+
import { QUOTE_MIN_CHARS } from "./predicates.js";
|
|
9
11
|
const code = (value) => `\`${value}\``;
|
|
10
12
|
const list = (values) => values.map(code).join(", ");
|
|
11
13
|
const alternatives = (values) => values.join("|");
|
|
@@ -18,6 +20,9 @@ const PREDICATE_SHAPES = {
|
|
|
18
20
|
lt: "holds when the finite number at `path` is below `n`",
|
|
19
21
|
empty: "holds when the value at `path` is an empty array, an empty string, null or absent",
|
|
20
22
|
no_new_items: "takes `key`, not `path`; holds when that state key is an empty array or falsy",
|
|
23
|
+
field_type: `holds when the value at \`path\` is of \`type\`, one of ${FIELD_TYPES.join(", ")}; a number only when finite, and an absent value is of no type`,
|
|
24
|
+
quote_missing: `the quote check, in code: holds when a quote at \`path\` (a string, or a list of them; with \`field\`, a list of records each holding its quote at \`field\`) is in none of the pages at \`pages\` (state paths holding what this run's call steps fetched; every string under each is page text). Both sides are compared lowercased, with curly quotes straight, dashes as "-" and whitespace runs as one space, then once more as their letters and digits alone; a quote under ${QUOTE_MIN_CHARS} characters is not checked. \`{"predicate": "quote_missing", "path": "answer.evidence", "field": "quote", "pages": ["page"]}\` on an escalate hands back an answer quoting text no fetched page holds. Check quotes with it, never with a judge or an \`ask\``,
|
|
25
|
+
not: "holds when `of`, one mechanical predicate (never `ask`), does not; `{\"predicate\": \"not\", \"of\": {\"predicate\": \"field_type\", \"path\": \"score\", \"type\": \"number\"}}` holds when score is absent or not a finite number",
|
|
21
26
|
ask: "a yes/no question for the host's judge: `instructions` is the question, `state` what it sees (default: the whole state), `criteria` optional {true, false} descriptions; holds when the yes-probability is at least `gte` (in (0.5, 1], default 0.6)",
|
|
22
27
|
};
|
|
23
28
|
function nodeFieldLines() {
|
|
@@ -36,7 +41,7 @@ A workflow is {"v":2,"name","schemas","input"?,"output","root"}.
|
|
|
36
41
|
- The input contract: the run starts from the input object and nothing else. ${code("input.schemaId")}, when present, is enforced before the first node. A node may read only input keys and keys an earlier node wrote.
|
|
37
42
|
- ${code("output.schemaId")} validates the final value; ${code("output.path")} selects it from state and must name an input key or a key an earlier node wrote.
|
|
38
43
|
- State is one object. Each step writes its result under one key: its ${code("as")}, or, for an agent, decide, extract or code node without ${code("as")}, its label. A report writes ${code("report_markdown")}. A code node without ${code("as")} that returns an object merges that object's top-level fields instead.
|
|
39
|
-
- Keys that
|
|
44
|
+
- Keys that hold a ${code("$")} are engine-owned: ${code("$host")} (host state), ${code("<as>$answers")} (raw judge answers and confidences) and ${code("<as>$verify")} (verifier results). Read them; never write one. No ${code("as")} may hold a ${code("$")}, and neither may the label of an agent, decide, extract or code node without ${code("as")}.
|
|
40
45
|
- ${code("{dot.path}")} placeholders are replaced from state in ${code("state")} maps (including ${code("verify.state")} and ${code("ask.state")}), call ${code("args")}, ${code("input")}, ${code("env")} and ${code("produces")}, a child workflow's ${code("input")}, and ${code("escalate.summary")}; ${code("pick")} and ${code("sift")} ${code("describe")} templates also see ${code("{item...}")}. A placeholder that is the whole string keeps its value's type. Every key a state map, call or child input interpolates must be produced upstream. ${code("instructions")}, ${code("code")} and ${code("command")} are literal and never interpolated.
|
|
41
46
|
|
|
42
47
|
## Node kinds
|
|
@@ -59,9 +64,10 @@ Their fields:
|
|
|
59
64
|
- ${code("out")} names the schema the submission must satisfy; the value lands at ${code("as")}.
|
|
60
65
|
- ${code("requires")} lists state paths that must hold evidence before the node runs, each produced upstream: missing values, null, blank strings, empty arrays and empty objects stop the run; ${code("false")} and ${code("0")} pass.
|
|
61
66
|
- ${code("tools")} names tools the host offers. ${code("[]")} means no tools; omitting ${code("tools")} offers every tool the host allows. Never name a tool the host did not offer.
|
|
62
|
-
- ${code("effort")} is ${alternatives(EFFORT_LEVELS)}; ${code("thinking")} is ${alternatives(THINKING_LEVELS)} (never off); ${code("tier")} is ${alternatives(MODEL_TIERS)}. They are requests to the host: resource ceilings are the host's
|
|
67
|
+
- ${code("effort")} is ${alternatives(EFFORT_LEVELS)}; ${code("thinking")} is ${alternatives(THINKING_LEVELS)} (never off); ${code("tier")} is ${alternatives(MODEL_TIERS)}. They are requests to the host: resource ceilings are the host's. A node that names no ${code("thinking")} thinks at medium, unless its host sets another level.
|
|
68
|
+
- An ${code("agent")} node may carry ${code("budget_usd")}, the most it asks to spend in dollars (above 0), which the host caps by what it has left; ${code("max_turns")}, a positive integer, the most turns it asks its host for per attempt, which the host applies within its own cap and refuses above it (the engine enforces nothing, and naming it changes the workflow's digest); and ${code("context")}, ${alternatives(AGENT_CONTEXTS)}: ${code("fresh")} (the default) sees only its instructions and state; ${code("fork")} asks the host to start it from the caller's transcript, which a host refuses where it has none.
|
|
63
69
|
- ${code("sopSection")} names one heading of the host's SOP, or a list of them, as the exact text after "## ". The node receives those sections verbatim.
|
|
64
|
-
- ${code("verify")} reviews a submission before it is accepted: {"out": a question schema with at least one boolean question, "state"?, "maxDrives"?: 1
|
|
70
|
+
- ${code("verify")} reviews a submission before it is accepted: {"out": a question schema with at least one boolean question, "state"?, "maxDrives"?: an integer >= 1 (default 2, no maximum), "override"?: {"below": a number in (0, 1), default 0.3}}. A boolean question named after a submission field doubts that field when its yes-probability is below ${code("override.below")}; any other boolean question is a requirement met at 0.5. A rejected submission returns to the same session with the reasons.
|
|
65
71
|
- When the workflow has a report, no decide or extract ${code("out")} schema carries ${code("report_markdown")}.
|
|
66
72
|
|
|
67
73
|
### Terminal nodes: report and artifact
|
|
@@ -76,30 +82,42 @@ Typed questions answered by the host's judge in one request each: no tools, no s
|
|
|
76
82
|
- A question schema is a flat object. Each property's ${code("description")} is its question. A boolean yields a yes-probability; a string enum (at most ${SYSTEM_ONE_LIMITS.maxChoiceOptions} options, optional per-option ${code("criteria")}) yields a choice; an integer with ${code("criteria")}: [level descriptions] (${SYSTEM_ONE_LIMITS.minScoreLevels} to ${SYSTEM_ONE_LIMITS.maxScoreLevels} levels, minimum 0, maximum the last level index) yields a score. Nothing else is a question.
|
|
77
83
|
- ${code("judge")}: a non-empty ${code("state")} map, ${code("out")} (a question schema) and ${code("as")}. The decoded value lands at ${code("as")}, the raw answers at ${code("<as>$answers")}.
|
|
78
84
|
- ${code("pick")}: ${code("itemsPath")}, ${code("describe")} (the option text per item, such as "{item.name}"), ${code("instructions")} (the one question) and ${code("as")}; ${code("allowNone")} adds a none-of-these option. The result is {index, item, none, option}.
|
|
79
|
-
- ${code("sift")}: ${code("itemsPath")}, ${code("out")} (a question schema asked of every item
|
|
80
|
-
- ${code("route")}: a non-empty ${code("state")} map, ${code("instructions")} (the one question) and
|
|
85
|
+
- ${code("sift")}: ${code("itemsPath")}, ${code("out")} (a question schema asked of every item; the host splits the items across requests when they exceed its limits) and ${code("as")}. ${code("keep")} {path: a question id or <id>.confidence, never a choice, gte?} keeps passing items, in order, at ${code("<as>.items")}.
|
|
86
|
+
- ${code("route")} runs one of 2 or more named ${code("branches")}. Jev chooses: a non-empty ${code("state")} map, ${code("instructions")} (the one question) and up to ${SYSTEM_ONE_LIMITS.maxChoiceOptions} branches, each {criteria?, body}; ${code("unsure")} {branch, gte: a number in (0, 1]} takes that branch when the choice's confidence is below ${code("gte")}. Or the workflow already holds the choice: ${code("valuePath")} names the state string that is the branch, each branch is {body}, no question is asked, and ${code("otherwise")} (a branch) takes a missing or unknown name, which otherwise fails; a non-string fails. ${code("as")} records the choice.
|
|
81
87
|
- A decoded boolean is true at yes-probability 0.5. To hold a different threshold, read ${code("<as>$answers.answers.<id>.noul")} in a code node.
|
|
88
|
+
- ${code("images")} {token: reference} sends images with a decision (judge, pick, sift, a route Jev chooses, ask). Each token, such as "<page1>", must appear literally in the node's ${code("state")} or in a question's text; each reference is written as a state value is, such as "{item.pages.0.image}", and must resolve to an image path the host can read. Only a provider that takes image input answers such a node. Pass images by reference, never their bytes in state.
|
|
89
|
+
- Inside a ${code("map")} with ${code("onItemFailure")} ${code("collect")}, a decision whose provider fails (rate limit, HTTP error, invalid answer, timeout) fails that item, and one sent whose outcome was lost, or one the provider refused, ends the item as a row marked ${code("needs_review")}; the other items go on.
|
|
82
90
|
|
|
83
91
|
### Control nodes
|
|
84
92
|
|
|
85
93
|
- ${code("chain")}: non-empty ${code("steps")}, run in order.
|
|
86
|
-
- ${code("map")}: ${code("itemsPath")} (an upstream list), ${code("body")} and ${code("as")}. The body sees ${code("item")} and ${code("item_index")}; ${code("maxConcurrency")} is a positive integer (default 4); ${code("resultPath")} selects one path from each completed item's state.
|
|
94
|
+
- ${code("map")}: ${code("itemsPath")} (an upstream list), ${code("body")} and ${code("as")}. The body sees ${code("item")} and ${code("item_index")}; ${code("maxConcurrency")} is a positive integer (default 4); ${code("resultPath")} selects one path from each completed item's state. Without ${code("resultPath")}, and with no ${code("as")} in the body, each item's result is its whole state, the mapped list included: set ${code("resultPath")} (or an ${code("as")} in the body) for a large map; the validator warns. ${code("onItemFailure")} is ${code("stop")} (default: the first failing item stops the map and the run) or ${code("collect")}. With ${code("collect")}, an item whose node fails (a call that failed after its retries, an agent that delivered no record, output that does not match its schema, a failed check) ends as {item_index, label, code, message} in the list at ${code("failedAs")}, the other items finish, and ${code("as")} stays aligned with the items: ${code("as[i]")} is item i's result, or ${code("null")} when item i failed. Filter the nulls explicitly if only successes are wanted. Gate on ${code("failedAs")} with ${code("escalate")} or a code node; never let failures pass silently. A crash, a cancel, an ${code("escalate")} inside the item or an effect whose outcome is unknown is never collected.
|
|
87
95
|
- ${code("parallel")}: at least two ${code("branches")}, each starting from the state before the parallel node. Branches write disjoint keys and never read a sibling's writes.
|
|
88
|
-
- ${code("loop")}: ${code("body")}, ${code("until")} (a predicate) and an integer ${code("maxIters")}
|
|
96
|
+
- ${code("loop")}: ${code("body")}, ${code("until")} (a predicate) and an integer ${code("maxIters")} of at least 1 (no maximum), optionally an integer ${code("expect_iters")} of at least 1 (priced passes). At the bound the state passes through with ${code("until")} unmet; follow the loop with an escalate or gate on that condition.
|
|
89
97
|
- ${code("escalate")}: ${code("when")} (a predicate), and non-empty ${code("kind")}, ${code("stage")} and ${code("summary")}. When the predicate holds the run stops without output and returns the escalation with its interpolated summary.
|
|
90
98
|
- ${code("workflow")}: ${code("label")}, ${code("workflow")} (a complete inline child), ${code("input")} (an object, interpolated, the child's entire initial state), ${code("out")} (a parent schema checked against the child's output) and ${code("as")}. The child declares ${code("input.schemaId")} in its own schemas and contains no report or artifact.
|
|
91
99
|
- ${code("code")}: ${code("code")} is one synchronous function expression such as "(s) => ({ total: s.items.length })". It receives the full state; return new values and never mutate it. ${code("Date")}, ${code("Promise")}, timers, ${code("fetch")}, ${code("require")}, ${code("process")}, ${code("Function")} and ${code("globalThis")} are unavailable. It is trusted host JavaScript, not a sandbox. Use code for typed-state mechanics, never to read meaning from prose.
|
|
92
|
-
- ${code("call")}: one side effect with no model in the loop. ${code("via")} is ${alternatives(CALL_TRANSPORTS)}; ${code("as")} and ${code("deadline_s")} (greater than 0,
|
|
100
|
+
- ${code("call")}: one side effect with no model in the loop. ${code("via")} is ${alternatives(CALL_TRANSPORTS)}; ${code("as")} and ${code("deadline_s")} (a finite number greater than 0, no maximum) are required — an unbounded effect is how a stalled provider becomes a stalled job.
|
|
93
101
|
- ${code("via: tool")} takes ${code("tool")} (a host tool address), ${code("args")} (an object) and ${code("out")} (the tool's result schema).
|
|
94
102
|
- ${code("via: executor")} takes ${code("code")} (a body that returns its JSON result and uses only ${code("tools")} and ${code("input")}), ${code("input")} and ${code("out")}.
|
|
95
103
|
- ${code("via: shell")} takes ${code("command")} (literal) and ${code("env")} (UPPER_CASE names to strings, interpolated by value; the way long values reach a command). Its result has the fixed shape {code, stdout, stderr, truncated?}: no ${code("out")}. Only a shell call may declare ${code("produces")} (workspace-relative files, checked after the effect).
|
|
96
|
-
- ${code("retry")} {attempts: 1
|
|
97
|
-
- ${code("poll")} {until, fail_when?, interval_s: 0.1
|
|
104
|
+
- ${code("retry")} {attempts: an integer >= 1, backoff_s?: a number >= 0, on?: [${[...CALL_RETRY_CLASSES, ...EFFECT_FAILURE_CODES].join(", ")}]}. ${code("where")} accepts only "sandbox".
|
|
105
|
+
- ${code("poll")} {until, fail_when?, interval_s: >= 0.1 (a busy-loop guard), deadline_s: at least the call's deadline_s (no maximum)} repeats the call until ${code("until")} holds on its own result; ${code("fail_when")} fails it at once. Both are mechanical predicates whose paths are relative to the result and lie in its declared shape.
|
|
98
106
|
- Validation and dry runs never perform effects: they synthesize the declared result, and a shell result's stdout is "{}".
|
|
99
107
|
|
|
108
|
+
### Step guards
|
|
109
|
+
|
|
110
|
+
A ${code("guard")} on a step (${GUARDED_NODE_KINDS.join(", ")}) checks the step once it ran: below its threshold, the run hands the job back (it escalates, kind ${code("guard")}, at the step, with the state it reached), so an uncertain step never answers alone.
|
|
111
|
+
- ${code("guard")} is {"signal": ${alternatives(GUARD_SIGNALS)}, "threshold": a number between 0 and 1 (exclusive), "question"?: text, "fit"?: {"w", "b", "n", "fitted_at"}}.
|
|
112
|
+
- ${code("self")} reads the step's own confidence: ${SELF_CONFIDENCE_KINDS.join(", ")} nodes only. An agent or decide node with it submits a ${code("confidence")} field (0 to 1) beside its record, which lands at ${code("<key>$confidence")}, never in its value; its ${code("out")} is an object schema. A judge, pick or sift reads its weakest answer's confidence.
|
|
113
|
+
- ${code("jev")} asks Jev one yes/no question over what the step saw and what it wrote: ${code("question")} (at most ${GUARD_QUESTION_MAX} characters), or by default whether the output is right for the input. Every guarded kind may use it; it is the only signal for ${GUARDED_NODE_KINDS.filter((kind) => !SELF_CONFIDENCE_KINDS.includes(kind)).join(", ")} nodes.
|
|
114
|
+
- ${code("both")} combines the two: through ${code("fit")} when it has one, else the lower of the two.
|
|
115
|
+
- ${code("fit")} is the host's, written when it fits the threshold on graded runs: {"w": one weight per signal ([self, jev] for both), "b", "n": the runs it was fitted on, "fitted_at": an ISO time}. Never write or change one yourself. A raw confidence is not a calibrated probability: without a fit, set a threshold the host has measured, or leave the guard to the host.
|
|
116
|
+
|
|
100
117
|
## Predicates
|
|
101
118
|
|
|
102
119
|
${code("loop.until")} and ${code("escalate.when")} take one of these; ${code("poll")} takes only the first ${MECHANICAL_PREDICATES.length}. Each path or key reads a state value an input or an earlier node produced.
|
|
120
|
+
A predicate is one JSON object that names itself in its ${code("predicate")} field beside its own fields, for example ${code('{"predicate": "field_true", "path": "review.approved"}')}.
|
|
103
121
|
${predicateLines()}
|
|
104
122
|
|
|
105
123
|
## Authority
|
|
@@ -109,6 +127,7 @@ ${predicateLines()}
|
|
|
109
127
|
- When the host supplies rubric sections, they are authoritative source text: every generative node's ${code("sopSection")} lists all of them, a merged judgment inherits the union of its parents' sections, and policy is never paraphrased into instructions. Judgment nodes, ${code("ask")} predicates and ${code("verify")} clauses are then refused until the host reviews a separate question contract.
|
|
110
128
|
- Acceptance checks are the host's. Never change a check, fixture or threshold to pass.
|
|
111
129
|
- Bound loops and parallelism. Uncertainty escalates or takes an explicit fallback such as ${code("route.unsure")} or a threshold gate.
|
|
130
|
+
- Ask Jev only what needs judgment; compute what is certain in code. Once a judge and code have decided, route by ${code("valuePath")}: asking a route again can contradict that decision.
|
|
112
131
|
|
|
113
132
|
## Example
|
|
114
133
|
|
|
@@ -161,7 +180,12 @@ export function candidatePolicyErrors(candidate, options) {
|
|
|
161
180
|
errors.push(`${String(node.label ?? kind)}: this host does not run ${String(kind)} nodes`);
|
|
162
181
|
if (!options.allowExecutableCandidates && ["code", "call", "artifact"].includes(String(kind)) && !(kind === "call" && node.via === "tool" && typeof node.tool === "string" && options.allowedEffectTools?.includes(node.tool)))
|
|
163
182
|
errors.push(`${kind} requires allowExecutableCandidates`);
|
|
164
|
-
|
|
183
|
+
// `budget` on an agent is accepted for older documents and never read: an author writes budget_usd.
|
|
184
|
+
if (kind === "agent" && Object.hasOwn(node, "budget"))
|
|
185
|
+
errors.push(`${String(node.label ?? kind)}: budget is not read; declare budget_usd, the dollars the node asks to spend`);
|
|
186
|
+
// A route by valuePath asks no question, so like code it carries no rubric.
|
|
187
|
+
const asksJev = JUDGMENT_NODE_KINDS.includes(String(kind)) && !(kind === "route" && node.valuePath !== undefined);
|
|
188
|
+
if (sections.length && asksJev)
|
|
165
189
|
errors.push(`${String(kind)} cannot carry supplied SOP sections; use an LLM node with sopSection`);
|
|
166
190
|
const llm = GENERATIVE_NODE_KINDS.includes(String(kind));
|
|
167
191
|
const predicate = kind === "loop" ? record(node.until) : kind === "escalate" ? record(node.when) : undefined;
|
|
@@ -205,15 +229,18 @@ export function candidatePolicyErrors(candidate, options) {
|
|
|
205
229
|
return errors;
|
|
206
230
|
}
|
|
207
231
|
/** The interpreter's view of a workflow written in a host's vocabulary: an artifact of a declared prose output
|
|
208
|
-
* type becomes the report writer it is. Validate and run this view; retain and digest the authored bytes.
|
|
209
|
-
|
|
232
|
+
* type becomes the report writer it is. Validate and run this view; retain and digest the authored bytes. With
|
|
233
|
+
* `normalizeType`, an artifact's type is first mapped to the host's name for it. */
|
|
234
|
+
export function applyHostOutputTypes(candidate, host, options = {}) {
|
|
210
235
|
const prose = new Set(Object.entries(host?.outputTypes ?? {}).filter(([, spec]) => spec.kind === "prose").map(([type]) => type));
|
|
211
236
|
if (!prose.size)
|
|
212
237
|
return candidate;
|
|
238
|
+
// With a normaliser the host's answer is the name: null or undefined matches no type, the exact one included.
|
|
239
|
+
const nameOf = (type) => typeof type === "string" && options.normalizeType ? options.normalizeType(type) : type;
|
|
213
240
|
const visit = (node) => {
|
|
214
241
|
if (!node || typeof node !== "object")
|
|
215
242
|
return node;
|
|
216
|
-
if (node.node === "artifact" && prose.has(node.type))
|
|
243
|
+
if (node.node === "artifact" && prose.has(nameOf(node.type)))
|
|
217
244
|
return { ...node, type: "report" };
|
|
218
245
|
if (node.node === "chain")
|
|
219
246
|
return { ...node, steps: (node.steps || []).map(visit) };
|
|
@@ -223,6 +250,8 @@ export function applyHostOutputTypes(candidate, host) {
|
|
|
223
250
|
return { ...node, body: visit(node.body) };
|
|
224
251
|
if (node.node === "route")
|
|
225
252
|
return { ...node, branches: Object.fromEntries(Object.entries(node.branches || {}).map(([name, branch]) => [name, { ...branch, body: visit(branch?.body) }])) };
|
|
253
|
+
// Unlike desugarWorkflow, this does not descend into a child workflow: a child may not hold an artifact node
|
|
254
|
+
// (validateWorkflow rejects it, see containsReportNode), so there is nothing for the prose-type rewrite to reach there.
|
|
226
255
|
return node;
|
|
227
256
|
};
|
|
228
257
|
return { ...candidate, root: visit(candidate.root) };
|
|
@@ -260,7 +289,9 @@ export async function authorWorkflow(options) {
|
|
|
260
289
|
const errors = candidatePolicyErrors(value, options);
|
|
261
290
|
if (!errors.length) {
|
|
262
291
|
try {
|
|
263
|
-
|
|
292
|
+
// executeCode: false — a candidate's code is syntax-checked here, never run, so a candidate runs nothing
|
|
293
|
+
// until its host accepts it. Runs and dry runs after acceptance still probe the code.
|
|
294
|
+
const verdict = validateWorkflow(applyHostOutputTypes(value, options.host), { inputKeys, executeCode: false });
|
|
264
295
|
if (!verdict.ok)
|
|
265
296
|
errors.push(...verdict.errors);
|
|
266
297
|
}
|
|
@@ -290,8 +321,6 @@ export async function authorWorkflow(options) {
|
|
|
290
321
|
throw error;
|
|
291
322
|
}
|
|
292
323
|
}
|
|
293
|
-
/** The packaged author skill's name, as a skill-loading host registers it. */
|
|
294
|
-
export const AUTHOR_SKILL_NAME = "agentrun-author";
|
|
295
324
|
const skillRoot = new URL("../skills/author/", import.meta.url);
|
|
296
325
|
/** The absolute directory of the packaged author skill (the one holding SKILL.md). */
|
|
297
326
|
export function authorSkillDirectory() {
|
package/dist/authoring.js
CHANGED
|
@@ -57,7 +57,7 @@ export function defineWorkflow(definition) {
|
|
|
57
57
|
});
|
|
58
58
|
const result = validateWorkflow(document);
|
|
59
59
|
if (!result.ok)
|
|
60
|
-
throw new WorkflowInvalidError(document.name, result.errors);
|
|
60
|
+
throw new WorkflowInvalidError(document.name, result.errors, result.issues);
|
|
61
61
|
const inputSchema = resolveSchemaForWorkflow(document, document.schemas[definition.input]);
|
|
62
62
|
if (!objectContract(inputSchema)) {
|
|
63
63
|
throw new WorkflowSchemaConversionError(definition.input, new Error("workflow input must be constrained to JSON objects; declare type: object or object-only schema alternatives"));
|
|
@@ -98,7 +98,7 @@ function copyJson(value, ancestors, budget, depth) {
|
|
|
98
98
|
return value;
|
|
99
99
|
if (typeof value === "number" && Number.isFinite(value))
|
|
100
100
|
return value;
|
|
101
|
-
if (typeof value !== "object"
|
|
101
|
+
if (typeof value !== "object")
|
|
102
102
|
throw new Error("workflow documents must contain only finite JSON values");
|
|
103
103
|
if (utilTypes.isProxy(value))
|
|
104
104
|
throw new Error("workflow documents must not contain proxies");
|
package/dist/cli.js
CHANGED
|
@@ -8,12 +8,12 @@ import { demoScenarios, runTriageDemo, supportTriage } from "./demo.js";
|
|
|
8
8
|
import { inspectWorkflow, formatWorkflowTree } from "./inspection.js";
|
|
9
9
|
const help = `AgentRun DSL — build, test, and run agent workflows
|
|
10
10
|
|
|
11
|
-
agentrun demo [--scenario billing|technical|ambiguous] [--json]
|
|
12
|
-
agentrun example [file.json] Write the demo workflow (never overwrite)
|
|
13
|
-
agentrun inspect workflow.json [--json] Show structure without executing code
|
|
14
|
-
agentrun validate workflow.json [input.json] --trusted
|
|
15
|
-
agentrun dry-run workflow.json [input.json] --trusted
|
|
16
|
-
agentrun run workflow.json input.json --trusted
|
|
11
|
+
agentrun-dsl demo [--scenario billing|technical|ambiguous] [--json]
|
|
12
|
+
agentrun-dsl example [file.json] Write the demo workflow (never overwrite)
|
|
13
|
+
agentrun-dsl inspect workflow.json [--json] Show structure without executing code
|
|
14
|
+
agentrun-dsl validate workflow.json [input.json] --trusted
|
|
15
|
+
agentrun-dsl dry-run workflow.json [input.json] --trusted [--strict]
|
|
16
|
+
agentrun-dsl run workflow.json input.json --trusted
|
|
17
17
|
|
|
18
18
|
demo runs the real interpreter with scripted judgments, without a key or network.
|
|
19
19
|
run supports deterministic workflows; use the JavaScript API to supply agent,
|
|
@@ -22,6 +22,8 @@ during validation and running. Only use workflows you trust; this is not a sandb
|
|
|
22
22
|
validate checks a supplied input against the workflow's input contract.
|
|
23
23
|
dry-run uses supplied input, or synthesizes it from the declared input schema.
|
|
24
24
|
Without an input schema, dry-run starts with an empty input object.
|
|
25
|
+
dry-run exits 1 when a check fails. A check that could not run (status not_run, the
|
|
26
|
+
reasons under skipped) exits 0 unless --strict is given, which makes it exit 3.
|
|
25
27
|
`;
|
|
26
28
|
async function main(args) {
|
|
27
29
|
const [command] = args;
|
|
@@ -33,7 +35,7 @@ async function main(args) {
|
|
|
33
35
|
let scenario = "billing";
|
|
34
36
|
let scenarioProvided = false;
|
|
35
37
|
let json = false;
|
|
36
|
-
const usage = "Usage: agentrun demo [--scenario billing|technical|ambiguous] [--json]";
|
|
38
|
+
const usage = "Usage: agentrun-dsl demo [--scenario billing|technical|ambiguous] [--json]";
|
|
37
39
|
for (let i = 1; i < args.length; i++) {
|
|
38
40
|
const arg = args[i];
|
|
39
41
|
if (arg === "--json") {
|
|
@@ -77,23 +79,24 @@ async function main(args) {
|
|
|
77
79
|
if (command === "inspect") {
|
|
78
80
|
const positional = args.slice(1).filter(arg => arg !== "--json");
|
|
79
81
|
if (positional.length !== 1 || positional[0].startsWith("--"))
|
|
80
|
-
throw new Error("Usage: agentrun inspect workflow.json [--json]");
|
|
82
|
+
throw new Error("Usage: agentrun-dsl inspect workflow.json [--json]");
|
|
81
83
|
const inspection = inspectWorkflow(JSON.parse(await readFile(resolve(positional[0]), "utf8")));
|
|
82
84
|
console.log(args.includes("--json") ? JSON.stringify(inspection, null, 2) : formatWorkflowTree(inspection));
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
87
|
if (!["validate", "dry-run", "run"].includes(command))
|
|
86
|
-
throw new Error(`Unknown command "${command}". Use agentrun --help.`);
|
|
88
|
+
throw new Error(`Unknown command "${command}". Use agentrun-dsl --help.`);
|
|
87
89
|
if (!args.includes("--trusted"))
|
|
88
90
|
throw new Error("Pass --trusted only after reviewing the workflow. Authored JavaScript may execute, including during validation.");
|
|
89
|
-
const
|
|
91
|
+
const strict = command === "dry-run" && args.includes("--strict");
|
|
92
|
+
const positional = args.slice(1).filter(arg => arg !== "--trusted" && !(strict && arg === "--strict"));
|
|
90
93
|
const unknown = positional.find(arg => arg.startsWith("--"));
|
|
91
94
|
if (unknown)
|
|
92
|
-
throw new Error(`Unknown option "${unknown}". Use agentrun --help.`);
|
|
95
|
+
throw new Error(`Unknown option "${unknown}". Use agentrun-dsl --help.`);
|
|
93
96
|
if (!positional[0])
|
|
94
97
|
throw new Error("Provide a workflow JSON file.");
|
|
95
98
|
if (positional.length > 2)
|
|
96
|
-
throw new Error(`Usage: agentrun ${command} workflow.json ${command === "run" ? "input.json" : "[input.json]"} --trusted`);
|
|
99
|
+
throw new Error(`Usage: agentrun-dsl ${command} workflow.json ${command === "run" ? "input.json" : "[input.json]"} --trusted${command === "dry-run" ? " [--strict]" : ""}`);
|
|
97
100
|
if (command === "run" && !positional[1])
|
|
98
101
|
throw new Error("Provide an input JSON file.");
|
|
99
102
|
const workflow = JSON.parse(await readFile(resolve(positional[0]), "utf8"));
|
|
@@ -121,6 +124,8 @@ async function main(args) {
|
|
|
121
124
|
console.log(JSON.stringify(result, null, 2));
|
|
122
125
|
if (!result.ok)
|
|
123
126
|
process.exitCode = 1;
|
|
127
|
+
else if (strict && result.status === "not_run")
|
|
128
|
+
process.exitCode = 3;
|
|
124
129
|
}
|
|
125
130
|
else {
|
|
126
131
|
const result = await runWorkflow(workflow, input, {});
|
package/dist/code-exec.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/** The denied globals a transform's source names, in DENIED_GLOBALS order: a lexical scan of the source
|
|
2
|
+
* that skips comments, string and template text and regular-expression literals, and ignores a name
|
|
3
|
+
* read as a property (after `.` or `?.`). A name used as an object key or a local binding is still
|
|
4
|
+
* named: the lint refuses rather than guesses. It is a lint for untrusted authors, never a boundary:
|
|
5
|
+
* a host that runs such code isolates it (deps.runCode). */
|
|
6
|
+
export declare function deniedGlobalReferences(src: string): string[];
|
|
1
7
|
/** Parse the same expression as trusted execution, without evaluating it or calling its body.
|
|
2
8
|
* Syntax validity does not prove that the expression produces a function or a valid patch. */
|
|
3
9
|
export declare function compileTransformSyntax(src: string): void;
|
package/dist/code-exec.js
CHANGED
|
@@ -10,6 +10,132 @@ const DENIED_GLOBALS = [
|
|
|
10
10
|
"fetch", "XMLHttpRequest", "Function", "Buffer",
|
|
11
11
|
"setTimeout", "setInterval", "setImmediate", "queueMicrotask", "Promise", "Date",
|
|
12
12
|
];
|
|
13
|
+
/** Words after which a `/` starts a regular expression rather than a division. */
|
|
14
|
+
const REGEX_AFTER_WORDS = new Set(["return", "typeof", "instanceof", "in", "of", "new", "delete", "void", "throw", "case", "do", "else", "yield", "await"]);
|
|
15
|
+
const IDENTIFIER_START = /[A-Za-z_$\u0080-\uffff]/;
|
|
16
|
+
const IDENTIFIER_PART = /[A-Za-z0-9_$\u0080-\uffff]/;
|
|
17
|
+
/** The denied globals a transform's source names, in DENIED_GLOBALS order: a lexical scan of the source
|
|
18
|
+
* that skips comments, string and template text and regular-expression literals, and ignores a name
|
|
19
|
+
* read as a property (after `.` or `?.`). A name used as an object key or a local binding is still
|
|
20
|
+
* named: the lint refuses rather than guesses. It is a lint for untrusted authors, never a boundary:
|
|
21
|
+
* a host that runs such code isolates it (deps.runCode). */
|
|
22
|
+
export function deniedGlobalReferences(src) {
|
|
23
|
+
const denied = new Set(DENIED_GLOBALS);
|
|
24
|
+
const found = new Set();
|
|
25
|
+
const braces = [];
|
|
26
|
+
const n = typeof src === "string" ? src.length : 0;
|
|
27
|
+
let i = 0;
|
|
28
|
+
// The previous significant token: a word, a value (literal, closing bracket), or punctuation.
|
|
29
|
+
let prev = null;
|
|
30
|
+
/** Template text from i: true when it stopped at `${` (code follows), false at its closing backtick. */
|
|
31
|
+
const templateText = () => {
|
|
32
|
+
while (i < n) {
|
|
33
|
+
if (src[i] === "\\") {
|
|
34
|
+
i += 2;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (src[i] === "`") {
|
|
38
|
+
i += 1;
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (src[i] === "$" && src[i + 1] === "{") {
|
|
42
|
+
i += 2;
|
|
43
|
+
braces.push("template");
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
i += 1;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
};
|
|
50
|
+
while (i < n) {
|
|
51
|
+
const c = src[i];
|
|
52
|
+
if (/\s/.test(c)) {
|
|
53
|
+
i += 1;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (c === "/" && src[i + 1] === "/") {
|
|
57
|
+
const end = src.indexOf("\n", i);
|
|
58
|
+
i = end < 0 ? n : end;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (c === "/" && src[i + 1] === "*") {
|
|
62
|
+
const end = src.indexOf("*/", i + 2);
|
|
63
|
+
i = end < 0 ? n : end + 2;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (c === "'" || c === '"') {
|
|
67
|
+
i += 1;
|
|
68
|
+
while (i < n && src[i] !== c)
|
|
69
|
+
i += src[i] === "\\" ? 2 : 1;
|
|
70
|
+
i += 1;
|
|
71
|
+
prev = { kind: "value", text: c };
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (c === "`" || (c === "}" && braces[braces.length - 1] === "template")) {
|
|
75
|
+
if (c === "}")
|
|
76
|
+
braces.pop();
|
|
77
|
+
i += 1;
|
|
78
|
+
prev = templateText() ? null : { kind: "value", text: "`" };
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (c === "/") {
|
|
82
|
+
const regex = prev === null || (prev.kind === "punct" && !")]}".includes(prev.text)) || (prev.kind === "word" && REGEX_AFTER_WORDS.has(prev.text));
|
|
83
|
+
if (regex) {
|
|
84
|
+
i += 1;
|
|
85
|
+
let inClass = false;
|
|
86
|
+
while (i < n && (inClass || src[i] !== "/")) {
|
|
87
|
+
if (src[i] === "\\") {
|
|
88
|
+
i += 2;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (src[i] === "[")
|
|
92
|
+
inClass = true;
|
|
93
|
+
else if (src[i] === "]")
|
|
94
|
+
inClass = false;
|
|
95
|
+
i += 1;
|
|
96
|
+
}
|
|
97
|
+
i += 1;
|
|
98
|
+
while (i < n && IDENTIFIER_PART.test(src[i]))
|
|
99
|
+
i += 1;
|
|
100
|
+
prev = { kind: "value", text: "/" };
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (IDENTIFIER_START.test(c)) {
|
|
105
|
+
const start = i;
|
|
106
|
+
while (i < n && IDENTIFIER_PART.test(src[i]))
|
|
107
|
+
i += 1;
|
|
108
|
+
const word = src.slice(start, i);
|
|
109
|
+
if (denied.has(word) && !(prev?.kind === "punct" && prev.text === "."))
|
|
110
|
+
found.add(word);
|
|
111
|
+
prev = { kind: "word", text: word };
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (/[0-9]/.test(c)) {
|
|
115
|
+
while (i < n && IDENTIFIER_PART.test(src[i]))
|
|
116
|
+
i += 1;
|
|
117
|
+
prev = { kind: "value", text: "0" };
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (c === "." && src.startsWith("...", i)) {
|
|
121
|
+
i += 3;
|
|
122
|
+
prev = { kind: "punct", text: "..." };
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (c === "?" && src[i + 1] === "." && !/[0-9]/.test(src[i + 2] ?? "")) {
|
|
126
|
+
i += 2;
|
|
127
|
+
prev = { kind: "punct", text: "." };
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (c === "{")
|
|
131
|
+
braces.push("brace");
|
|
132
|
+
if (c === "}")
|
|
133
|
+
braces.pop();
|
|
134
|
+
i += 1;
|
|
135
|
+
prev = c === ")" || c === "]" || c === "}" ? { kind: "value", text: c } : { kind: "punct", text: c };
|
|
136
|
+
}
|
|
137
|
+
return DENIED_GLOBALS.filter((name) => found.has(name));
|
|
138
|
+
}
|
|
13
139
|
function createTransformFactory(src) {
|
|
14
140
|
if (typeof src !== "string" || !src.trim())
|
|
15
141
|
throw new Error("code transform source must be a non-empty string");
|