@archmax-ai/harness 0.0.0
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/LICENSE +21 -0
- package/README.md +219 -0
- package/dist/agent.d.ts +174 -0
- package/dist/agent.js +140 -0
- package/dist/agent.js.map +1 -0
- package/dist/assembly/compose.d.ts +170 -0
- package/dist/assembly/compose.js +391 -0
- package/dist/assembly/compose.js.map +1 -0
- package/dist/assembly/delegation-registry.d.ts +5 -0
- package/dist/assembly/delegation-registry.js +118 -0
- package/dist/assembly/delegation-registry.js.map +1 -0
- package/dist/assembly/index.d.ts +192 -0
- package/dist/assembly/index.js +265 -0
- package/dist/assembly/index.js.map +1 -0
- package/dist/assembly/plain.d.ts +7 -0
- package/dist/assembly/plain.js +41 -0
- package/dist/assembly/plain.js.map +1 -0
- package/dist/authoring-skill/archmax-harness/README.md +76 -0
- package/dist/authoring-skill/archmax-harness/SKILL.md +241 -0
- package/dist/authoring-skill/archmax-harness/references/backend-integration.md +626 -0
- package/dist/authoring-skill/archmax-harness/references/cases.md +41 -0
- package/dist/authoring-skill/archmax-harness/references/diagnostics.md +51 -0
- package/dist/authoring-skill/archmax-harness/references/hook-and-test-scripts.md +1070 -0
- package/dist/authoring-skill/archmax-harness/references/hooks-and-scripts.md +82 -0
- package/dist/authoring-skill/archmax-harness/references/wiring.md +101 -0
- package/dist/authoring-skill/archmax-harness/references/workflow-schema.md +1631 -0
- package/dist/authoring-skill/archmax-harness/references/workflow-yaml.md +241 -0
- package/dist/behaviour/support.d.ts +232 -0
- package/dist/behaviour/support.js +339 -0
- package/dist/behaviour/support.js.map +1 -0
- package/dist/cli/banner.d.ts +11 -0
- package/dist/cli/banner.js +29 -0
- package/dist/cli/banner.js.map +1 -0
- package/dist/cli/bootstrap.d.ts +33 -0
- package/dist/cli/bootstrap.js +153 -0
- package/dist/cli/bootstrap.js.map +1 -0
- package/dist/cli/command.d.ts +39 -0
- package/dist/cli/command.js +97 -0
- package/dist/cli/command.js.map +1 -0
- package/dist/cli/state-flow.d.ts +46 -0
- package/dist/cli/state-flow.js +268 -0
- package/dist/cli/state-flow.js.map +1 -0
- package/dist/cli/style.d.ts +41 -0
- package/dist/cli/style.js +64 -0
- package/dist/cli/style.js.map +1 -0
- package/dist/cli/turn.d.ts +41 -0
- package/dist/cli/turn.js +161 -0
- package/dist/cli/turn.js.map +1 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +426 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/code-description.d.ts +22 -0
- package/dist/core/code-description.js +38 -0
- package/dist/core/code-description.js.map +1 -0
- package/dist/core/deepagents.d.ts +183 -0
- package/dist/core/deepagents.js +128 -0
- package/dist/core/deepagents.js.map +1 -0
- package/dist/core/events.d.ts +350 -0
- package/dist/core/events.js +205 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/frontmatter.d.ts +15 -0
- package/dist/core/frontmatter.js +32 -0
- package/dist/core/frontmatter.js.map +1 -0
- package/dist/core/listing-redact.d.ts +37 -0
- package/dist/core/listing-redact.js +88 -0
- package/dist/core/listing-redact.js.map +1 -0
- package/dist/core/match.d.ts +26 -0
- package/dist/core/match.js +75 -0
- package/dist/core/match.js.map +1 -0
- package/dist/core/message-readers.d.ts +84 -0
- package/dist/core/message-readers.js +159 -0
- package/dist/core/message-readers.js.map +1 -0
- package/dist/core/messages.d.ts +49 -0
- package/dist/core/messages.js +85 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/mount-prompt.d.ts +28 -0
- package/dist/core/mount-prompt.js +55 -0
- package/dist/core/mount-prompt.js.map +1 -0
- package/dist/core/mount-redact.d.ts +28 -0
- package/dist/core/mount-redact.js +32 -0
- package/dist/core/mount-redact.js.map +1 -0
- package/dist/core/mounts.d.ts +88 -0
- package/dist/core/mounts.js +147 -0
- package/dist/core/mounts.js.map +1 -0
- package/dist/core/path-mapping.d.ts +52 -0
- package/dist/core/path-mapping.js +113 -0
- package/dist/core/path-mapping.js.map +1 -0
- package/dist/core/platform-prompt.generated.d.ts +2 -0
- package/dist/core/platform-prompt.generated.js +4 -0
- package/dist/core/platform-prompt.generated.js.map +1 -0
- package/dist/core/prompt.d.ts +42 -0
- package/dist/core/prompt.js +75 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/session-id.d.ts +38 -0
- package/dist/core/session-id.js +61 -0
- package/dist/core/session-id.js.map +1 -0
- package/dist/core/session-store.d.ts +85 -0
- package/dist/core/session-store.js +149 -0
- package/dist/core/session-store.js.map +1 -0
- package/dist/core/session-zone.d.ts +54 -0
- package/dist/core/session-zone.js +82 -0
- package/dist/core/session-zone.js.map +1 -0
- package/dist/core/skill-prompt.d.ts +31 -0
- package/dist/core/skill-prompt.js +54 -0
- package/dist/core/skill-prompt.js.map +1 -0
- package/dist/core/skill-redact.d.ts +15 -0
- package/dist/core/skill-redact.js +27 -0
- package/dist/core/skill-redact.js.map +1 -0
- package/dist/core/skills.d.ts +172 -0
- package/dist/core/skills.js +214 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/tool-mocks.d.ts +23 -0
- package/dist/core/tool-mocks.js +39 -0
- package/dist/core/tool-mocks.js.map +1 -0
- package/dist/core/tool-telemetry.d.ts +16 -0
- package/dist/core/tool-telemetry.js +40 -0
- package/dist/core/tool-telemetry.js.map +1 -0
- package/dist/core/usage.d.ts +114 -0
- package/dist/core/usage.js +226 -0
- package/dist/core/usage.js.map +1 -0
- package/dist/core/workspace-context.d.ts +136 -0
- package/dist/core/workspace-context.js +178 -0
- package/dist/core/workspace-context.js.map +1 -0
- package/dist/core/workspace-prompt.d.ts +7 -0
- package/dist/core/workspace-prompt.js +102 -0
- package/dist/core/workspace-prompt.js.map +1 -0
- package/dist/core/workspace-router.d.ts +61 -0
- package/dist/core/workspace-router.js +145 -0
- package/dist/core/workspace-router.js.map +1 -0
- package/dist/core/workspace.d.ts +85 -0
- package/dist/core/workspace.js +193 -0
- package/dist/core/workspace.js.map +1 -0
- package/dist/core/zones.d.ts +181 -0
- package/dist/core/zones.js +202 -0
- package/dist/core/zones.js.map +1 -0
- package/dist/env.d.ts +99 -0
- package/dist/env.js +271 -0
- package/dist/env.js.map +1 -0
- package/dist/index.d.ts +265 -0
- package/dist/index.js +197 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel/kernel.d.ts +192 -0
- package/dist/kernel/kernel.js +751 -0
- package/dist/kernel/kernel.js.map +1 -0
- package/dist/lifecycle/hook-shape.d.ts +44 -0
- package/dist/lifecycle/hook-shape.js +66 -0
- package/dist/lifecycle/hook-shape.js.map +1 -0
- package/dist/lifecycle/runner.d.ts +177 -0
- package/dist/lifecycle/runner.js +372 -0
- package/dist/lifecycle/runner.js.map +1 -0
- package/dist/lifecycle/transcript.d.ts +27 -0
- package/dist/lifecycle/transcript.js +43 -0
- package/dist/lifecycle/transcript.js.map +1 -0
- package/dist/machine/allow.d.ts +65 -0
- package/dist/machine/allow.js +107 -0
- package/dist/machine/allow.js.map +1 -0
- package/dist/machine/delegation.d.ts +9 -0
- package/dist/machine/delegation.js +10 -0
- package/dist/machine/delegation.js.map +1 -0
- package/dist/machine/diagnostic.d.ts +14 -0
- package/dist/machine/diagnostic.js +2 -0
- package/dist/machine/diagnostic.js.map +1 -0
- package/dist/machine/lint-spec.d.ts +4 -0
- package/dist/machine/lint-spec.js +266 -0
- package/dist/machine/lint-spec.js.map +1 -0
- package/dist/machine/load-spec.d.ts +90 -0
- package/dist/machine/load-spec.js +120 -0
- package/dist/machine/load-spec.js.map +1 -0
- package/dist/machine/machine.d.ts +273 -0
- package/dist/machine/machine.js +551 -0
- package/dist/machine/machine.js.map +1 -0
- package/dist/machine/mount-grants.d.ts +25 -0
- package/dist/machine/mount-grants.js +24 -0
- package/dist/machine/mount-grants.js.map +1 -0
- package/dist/machine/slug.d.ts +14 -0
- package/dist/machine/slug.js +17 -0
- package/dist/machine/slug.js.map +1 -0
- package/dist/machine/spec-schema.d.ts +662 -0
- package/dist/machine/spec-schema.js +717 -0
- package/dist/machine/spec-schema.js.map +1 -0
- package/dist/machine/tool-names.d.ts +98 -0
- package/dist/machine/tool-names.js +144 -0
- package/dist/machine/tool-names.js.map +1 -0
- package/dist/machine/triggers.d.ts +114 -0
- package/dist/machine/triggers.js +165 -0
- package/dist/machine/triggers.js.map +1 -0
- package/dist/machine/types.d.ts +186 -0
- package/dist/machine/types.js +12 -0
- package/dist/machine/types.js.map +1 -0
- package/dist/machine/validate-spec.d.ts +42 -0
- package/dist/machine/validate-spec.js +29 -0
- package/dist/machine/validate-spec.js.map +1 -0
- package/dist/machine/variables.d.ts +196 -0
- package/dist/machine/variables.js +415 -0
- package/dist/machine/variables.js.map +1 -0
- package/dist/public/cli.d.ts +15 -0
- package/dist/public/cli.js +14 -0
- package/dist/public/cli.js.map +1 -0
- package/dist/public/messages.d.ts +33 -0
- package/dist/public/messages.js +33 -0
- package/dist/public/messages.js.map +1 -0
- package/dist/public/sandbox.d.ts +99 -0
- package/dist/public/sandbox.js +32 -0
- package/dist/public/sandbox.js.map +1 -0
- package/dist/public/spec.d.ts +147 -0
- package/dist/public/spec.js +149 -0
- package/dist/public/spec.js.map +1 -0
- package/dist/public/testing.d.ts +71 -0
- package/dist/public/testing.js +39 -0
- package/dist/public/testing.js.map +1 -0
- package/dist/rubrics/rubrics.d.ts +135 -0
- package/dist/rubrics/rubrics.js +145 -0
- package/dist/rubrics/rubrics.js.map +1 -0
- package/dist/runtime/contract.d.ts +73 -0
- package/dist/runtime/contract.js +96 -0
- package/dist/runtime/contract.js.map +1 -0
- package/dist/sandbox/assets/parts/core.js +22 -0
- package/dist/sandbox/assets/parts/lifecycle-hook.js +47 -0
- package/dist/sandbox/bridge.d.ts +16 -0
- package/dist/sandbox/bridge.js +95 -0
- package/dist/sandbox/bridge.js.map +1 -0
- package/dist/sandbox/executor.d.ts +46 -0
- package/dist/sandbox/executor.js +119 -0
- package/dist/sandbox/executor.js.map +1 -0
- package/dist/sandbox/imports.d.ts +33 -0
- package/dist/sandbox/imports.js +67 -0
- package/dist/sandbox/imports.js.map +1 -0
- package/dist/sandbox/prelude.d.ts +12 -0
- package/dist/sandbox/prelude.js +51 -0
- package/dist/sandbox/prelude.js.map +1 -0
- package/dist/sandbox/ptc-gateway.d.ts +104 -0
- package/dist/sandbox/ptc-gateway.js +167 -0
- package/dist/sandbox/ptc-gateway.js.map +1 -0
- package/dist/sandbox/runtime.d.ts +59 -0
- package/dist/sandbox/runtime.js +51 -0
- package/dist/sandbox/runtime.js.map +1 -0
- package/dist/sandbox/tools.d.ts +34 -0
- package/dist/sandbox/tools.js +147 -0
- package/dist/sandbox/tools.js.map +1 -0
- package/dist/sessions/operations.d.ts +79 -0
- package/dist/sessions/operations.js +121 -0
- package/dist/sessions/operations.js.map +1 -0
- package/dist/sessions/resolve.d.ts +97 -0
- package/dist/sessions/resolve.js +145 -0
- package/dist/sessions/resolve.js.map +1 -0
- package/dist/sessions/resume.d.ts +242 -0
- package/dist/sessions/resume.js +288 -0
- package/dist/sessions/resume.js.map +1 -0
- package/dist/sessions/scope.d.ts +99 -0
- package/dist/sessions/scope.js +145 -0
- package/dist/sessions/scope.js.map +1 -0
- package/dist/sessions/summary.d.ts +65 -0
- package/dist/sessions/summary.js +56 -0
- package/dist/sessions/summary.js.map +1 -0
- package/dist/testing/assertions.d.ts +30 -0
- package/dist/testing/assertions.js +231 -0
- package/dist/testing/assertions.js.map +1 -0
- package/dist/testing/case-document.d.ts +141 -0
- package/dist/testing/case-document.js +51 -0
- package/dist/testing/case-document.js.map +1 -0
- package/dist/testing/case-schema.d.ts +29 -0
- package/dist/testing/case-schema.js +519 -0
- package/dist/testing/case-schema.js.map +1 -0
- package/dist/testing/discovery.d.ts +10 -0
- package/dist/testing/discovery.js +24 -0
- package/dist/testing/discovery.js.map +1 -0
- package/dist/testing/driver.d.ts +78 -0
- package/dist/testing/driver.js +117 -0
- package/dist/testing/driver.js.map +1 -0
- package/dist/testing/grade.d.ts +116 -0
- package/dist/testing/grade.js +261 -0
- package/dist/testing/grade.js.map +1 -0
- package/dist/testing/interpreter.d.ts +55 -0
- package/dist/testing/interpreter.js +103 -0
- package/dist/testing/interpreter.js.map +1 -0
- package/dist/testing/mock-middleware.d.ts +5 -0
- package/dist/testing/mock-middleware.js +33 -0
- package/dist/testing/mock-middleware.js.map +1 -0
- package/dist/testing/runner.d.ts +205 -0
- package/dist/testing/runner.js +266 -0
- package/dist/testing/runner.js.map +1 -0
- package/dist/testing/target.d.ts +27 -0
- package/dist/testing/target.js +21 -0
- package/dist/testing/target.js.map +1 -0
- package/dist/validate/validate.d.ts +41 -0
- package/dist/validate/validate.js +669 -0
- package/dist/validate/validate.js.map +1 -0
- package/dist/workflow/agent-tools.d.ts +10 -0
- package/dist/workflow/agent-tools.js +10 -0
- package/dist/workflow/agent-tools.js.map +1 -0
- package/dist/workflow/checkpointer.d.ts +52 -0
- package/dist/workflow/checkpointer.js +200 -0
- package/dist/workflow/checkpointer.js.map +1 -0
- package/dist/workflow/control-tools.d.ts +174 -0
- package/dist/workflow/control-tools.js +468 -0
- package/dist/workflow/control-tools.js.map +1 -0
- package/dist/workflow/governance.d.ts +104 -0
- package/dist/workflow/governance.js +546 -0
- package/dist/workflow/governance.js.map +1 -0
- package/dist/workflow/middleware.d.ts +85 -0
- package/dist/workflow/middleware.js +283 -0
- package/dist/workflow/middleware.js.map +1 -0
- package/dist/workflow/on-error.d.ts +25 -0
- package/dist/workflow/on-error.js +58 -0
- package/dist/workflow/on-error.js.map +1 -0
- package/dist/workflow/parks.d.ts +46 -0
- package/dist/workflow/parks.js +513 -0
- package/dist/workflow/parks.js.map +1 -0
- package/dist/workflow/paths.d.ts +67 -0
- package/dist/workflow/paths.js +108 -0
- package/dist/workflow/paths.js.map +1 -0
- package/dist/workflow/prompt-cache.d.ts +70 -0
- package/dist/workflow/prompt-cache.js +103 -0
- package/dist/workflow/prompt-cache.js.map +1 -0
- package/dist/workflow/prompt-pruning.d.ts +20 -0
- package/dist/workflow/prompt-pruning.js +83 -0
- package/dist/workflow/prompt-pruning.js.map +1 -0
- package/dist/workflow/render-prompt.d.ts +45 -0
- package/dist/workflow/render-prompt.js +140 -0
- package/dist/workflow/render-prompt.js.map +1 -0
- package/dist/workflow/runtime-config.d.ts +7 -0
- package/dist/workflow/runtime-config.js +9 -0
- package/dist/workflow/runtime-config.js.map +1 -0
- package/dist/workflow/session-artifacts.d.ts +90 -0
- package/dist/workflow/session-artifacts.js +134 -0
- package/dist/workflow/session-artifacts.js.map +1 -0
- package/dist/workflow/session-view.d.ts +31 -0
- package/dist/workflow/session-view.js +94 -0
- package/dist/workflow/session-view.js.map +1 -0
- package/dist/workflow/snapshot.d.ts +14 -0
- package/dist/workflow/snapshot.js +97 -0
- package/dist/workflow/snapshot.js.map +1 -0
- package/dist/workflow/state.d.ts +347 -0
- package/dist/workflow/state.js +322 -0
- package/dist/workflow/state.js.map +1 -0
- package/dist/workflow/sub-workflow.d.ts +174 -0
- package/dist/workflow/sub-workflow.js +392 -0
- package/dist/workflow/sub-workflow.js.map +1 -0
- package/dist/workflow/tool-service.d.ts +48 -0
- package/dist/workflow/tool-service.js +291 -0
- package/dist/workflow/tool-service.js.map +1 -0
- package/dist/workflow/turn-boundary.d.ts +39 -0
- package/dist/workflow/turn-boundary.js +128 -0
- package/dist/workflow/turn-boundary.js.map +1 -0
- package/dist/workflow/turn-runner.d.ts +40 -0
- package/dist/workflow/turn-runner.js +122 -0
- package/dist/workflow/turn-runner.js.map +1 -0
- package/dist/workflow/workflow-tools.d.ts +46 -0
- package/dist/workflow/workflow-tools.js +90 -0
- package/dist/workflow/workflow-tools.js.map +1 -0
- package/package.json +119 -0
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parks: how a session suspends for a person or an event, and how it resumes.
|
|
3
|
+
*
|
|
4
|
+
* A park has three moments, each in a different graph node so a process that
|
|
5
|
+
* dies between two of them sees a parked session rather than a lost one:
|
|
6
|
+
*
|
|
7
|
+
* 1. **Commit.** The record is written — by the tool seam (`archmax_advance`
|
|
8
|
+
* into a human state, `archmax_wait`, a delegated child's suspension) or by a
|
|
9
|
+
* hook — with `parkPhase: "closing"`.
|
|
10
|
+
* 2. **Close.** The run owes the person one tool-free message: `servePark` sets
|
|
11
|
+
* `replyOnly` and moves the phase to `suspend`; the model speaks; the hook
|
|
12
|
+
* after it marks the reply spent.
|
|
13
|
+
* 3. **Suspend.** The next hook site holding a record in phase `suspend` with
|
|
14
|
+
* nothing owed calls `interrupt(record)`. Nothing else happens in that node
|
|
15
|
+
* before the interrupt, so its re-execution on resume repeats no side effect.
|
|
16
|
+
*
|
|
17
|
+
* Resuming is `applyResume`: a decision routes, a message is answered (and the
|
|
18
|
+
* session suspends again on the same record), a delivered firing continues the
|
|
19
|
+
* parked state. All three are told apart structurally, never by reading words.
|
|
20
|
+
*/
|
|
21
|
+
import { HumanMessage } from "@langchain/core/messages";
|
|
22
|
+
import { interrupt, isGraphInterrupt } from "@langchain/langgraph";
|
|
23
|
+
import { contentToString, isAiMessage, isHumanMessage, isRuntimeNote, lastMessageIsHuman, runtimeNote, } from "../core/messages.js";
|
|
24
|
+
import { isMessageResume } from "../sessions/resume.js";
|
|
25
|
+
import { normalizeTitle, TITLE_VARIABLE, titleWriteError, TRIGGER_VARIABLE, } from "../machine/variables.js";
|
|
26
|
+
import { currentWorkflowState, isReplyOnly, parkedStateOf, pendingParkOf, readWorkflowState, WORKFLOW_STATUSES, isDecisionPark, } from "./state.js";
|
|
27
|
+
import { SubWorkflowError, subWorkflowParkOf } from "./sub-workflow.js";
|
|
28
|
+
// --- Records ------------------------------------------------------------------
|
|
29
|
+
/**
|
|
30
|
+
* The pending-decision record for a human state: its declared transitions and
|
|
31
|
+
* evidence (the author's list leads and is never displaced), plus whatever the
|
|
32
|
+
* transition attached, duplicates removed keeping first position.
|
|
33
|
+
*/
|
|
34
|
+
export function decisionRecordFor(machine, state, seq, attached = []) {
|
|
35
|
+
const declared = machine.spec.states[state];
|
|
36
|
+
const evidence = [];
|
|
37
|
+
for (const path of [...(declared?.evidence ?? []), ...attached]) {
|
|
38
|
+
if (path && !evidence.includes(path))
|
|
39
|
+
evidence.push(path);
|
|
40
|
+
}
|
|
41
|
+
const title = declared?.title?.trim();
|
|
42
|
+
return {
|
|
43
|
+
state,
|
|
44
|
+
node: state,
|
|
45
|
+
...(title ? { title } : {}),
|
|
46
|
+
seq,
|
|
47
|
+
transitions: (declared?.transitions ?? []).map((t) => ({
|
|
48
|
+
to: t.to,
|
|
49
|
+
...(t.description ? { description: t.description } : {}),
|
|
50
|
+
...(t.type ? { type: t.type } : {}),
|
|
51
|
+
})),
|
|
52
|
+
...(evidence.length ? { evidence } : {}),
|
|
53
|
+
createdAt: new Date().toISOString(),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** The pending-input record for a state the agent parked with `archmax_wait`. */
|
|
57
|
+
export function inputRecordFor(machine, state, reason, resumeAt) {
|
|
58
|
+
const title = machine.spec.states[state]?.title?.trim();
|
|
59
|
+
return {
|
|
60
|
+
state,
|
|
61
|
+
node: state,
|
|
62
|
+
...(title ? { title } : {}),
|
|
63
|
+
reason,
|
|
64
|
+
parkedAt: new Date().toISOString(),
|
|
65
|
+
...(resumeAt ? { resumeAt } : {}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// --- Reply-only turns ---------------------------------------------------------
|
|
69
|
+
/** Whether a reply-only turn still owes its one model call: the flag is set and the last message is what the run was told. */
|
|
70
|
+
function replyOwed(state) {
|
|
71
|
+
return isReplyOnly(state) && lastMessageIsHuman(messagesOf(state));
|
|
72
|
+
}
|
|
73
|
+
function messagesOf(state) {
|
|
74
|
+
return state?.messages ?? [];
|
|
75
|
+
}
|
|
76
|
+
/** How the state in front of the model is labelled: its title when it has one. */
|
|
77
|
+
function stateLabel(machine, slug) {
|
|
78
|
+
const title = machine.spec.states[slug]?.title?.trim();
|
|
79
|
+
return title ? `'${slug}' (${title})` : `'${slug}'`;
|
|
80
|
+
}
|
|
81
|
+
/** Whether a message was typed by a person, as opposed to written by the runtime. */
|
|
82
|
+
function isPersonsMessage(message) {
|
|
83
|
+
return message !== undefined && isHumanMessage(message) && !isRuntimeNote(message);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* What a reply-only turn is told. Four shapes of park reach this — handing the
|
|
87
|
+
* run to a person, being routed to one by a decision, waiting for something
|
|
88
|
+
* from outside, and answering someone while a person decides — each with its
|
|
89
|
+
* own first sentence. The last paragraph is the same in all: it is what stands
|
|
90
|
+
* between a parked run and a model that would rather keep working.
|
|
91
|
+
*/
|
|
92
|
+
export function replyOnlyDirective(machine, state) {
|
|
93
|
+
const fields = readWorkflowState(state);
|
|
94
|
+
const messages = messagesOf(state);
|
|
95
|
+
const position = currentWorkflowState(state, machine.entry);
|
|
96
|
+
const last = messages[messages.length - 1];
|
|
97
|
+
let opening;
|
|
98
|
+
if (isPersonsMessage(last)) {
|
|
99
|
+
opening =
|
|
100
|
+
`This run is parked at the ${stateLabel(machine, position)} checkpoint and a person ` +
|
|
101
|
+
`is deciding what happens next. Answer the message in front of you from what the ` +
|
|
102
|
+
`conversation already shows: what has been done, and that the decision is with them. ` +
|
|
103
|
+
`You cannot make that decision, predict it, or announce it.`;
|
|
104
|
+
}
|
|
105
|
+
else if (fields.pendingInput) {
|
|
106
|
+
opening =
|
|
107
|
+
`You have parked this run: it stays in ${stateLabel(machine, position)} until ` +
|
|
108
|
+
`something arrives from outside (${fields.pendingInput.reason}). Tell whoever you are ` +
|
|
109
|
+
`talking to what you have done and what you are waiting for.`;
|
|
110
|
+
}
|
|
111
|
+
else if (isRuntimeNote(last)) {
|
|
112
|
+
opening =
|
|
113
|
+
`A decision has routed this run to ${stateLabel(machine, position)}, which is now ` +
|
|
114
|
+
`waiting for a person's decision. Tell whoever you are talking to where the run stands ` +
|
|
115
|
+
`and that it is with a reviewer — do not promise what they will decide.`;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
const parkedAt = parkedStateOf(fields.pendingDecision) || position;
|
|
119
|
+
opening =
|
|
120
|
+
`You have just handed this run to a person: ${stateLabel(machine, parkedAt)} is now ` +
|
|
121
|
+
`waiting for their decision, and your own work here is finished. Tell whoever you are ` +
|
|
122
|
+
`talking to what you did and that it is now with a reviewer — do not promise what they ` +
|
|
123
|
+
`will decide.`;
|
|
124
|
+
}
|
|
125
|
+
return (`${opening}\n\n` +
|
|
126
|
+
`Write one short message to them, in your own voice, and nothing else. This turn has no ` +
|
|
127
|
+
`tools: you cannot read, write, move the run, or do any further work, and the run does not ` +
|
|
128
|
+
`continue when you finish — it stays parked until someone else acts.`);
|
|
129
|
+
}
|
|
130
|
+
/** Whether the last message is an AI message still carrying tool calls the tools node must answer. */
|
|
131
|
+
function lastReplyCallsTools(messages) {
|
|
132
|
+
const last = messages[messages.length - 1];
|
|
133
|
+
return last !== undefined && isAiMessage(last) && Array.isArray(last.tool_calls) && last.tool_calls.length > 0;
|
|
134
|
+
}
|
|
135
|
+
/** The update that starts a closing turn: one reply-only model call, after which the next hook site suspends. */
|
|
136
|
+
function closingTurn() {
|
|
137
|
+
return { parkPhase: "suspend", replyOnly: true };
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Move a park along, deterministically on state. Before the model: a record in
|
|
141
|
+
* phase `closing` gets its closing turn; a delegated child that parked becomes
|
|
142
|
+
* the pending decision and gets its closing turn. After the model: a reply-only
|
|
143
|
+
* turn that just spoke is spent, and an answer to a person's message is reported.
|
|
144
|
+
*/
|
|
145
|
+
export function servePark(ctx, state, runtime, site) {
|
|
146
|
+
const fields = readWorkflowState(state);
|
|
147
|
+
const messages = messagesOf(state);
|
|
148
|
+
const park = pendingParkOf(state);
|
|
149
|
+
if (site === "before-model") {
|
|
150
|
+
if (!park) {
|
|
151
|
+
const queue = fields.pendingDelegations ?? [];
|
|
152
|
+
if (queue.length === 0)
|
|
153
|
+
return undefined;
|
|
154
|
+
return presentDelegation(ctx, state, runtime, queue[0]);
|
|
155
|
+
}
|
|
156
|
+
return fields.parkPhase === "closing" ? closingTurn() : undefined;
|
|
157
|
+
}
|
|
158
|
+
if (!park || !isReplyOnly(state))
|
|
159
|
+
return undefined;
|
|
160
|
+
const last = messages[messages.length - 1];
|
|
161
|
+
// A reply-only turn that called tools instead is not spent yet: the tools node
|
|
162
|
+
// refuses the calls, and the hook after it suspends.
|
|
163
|
+
if (!last || !isAiMessage(last) || lastReplyCallsTools(messages))
|
|
164
|
+
return undefined;
|
|
165
|
+
if (isPersonsMessage(messages[messages.length - 2])) {
|
|
166
|
+
const text = contentToString(last.content).trim();
|
|
167
|
+
if (text) {
|
|
168
|
+
const position = currentWorkflowState(state, ctx.machine.entry);
|
|
169
|
+
ctx.emit({
|
|
170
|
+
type: "park-message",
|
|
171
|
+
node: position,
|
|
172
|
+
state: position,
|
|
173
|
+
sessionId: ctx.sessionIdOf(runtime),
|
|
174
|
+
direction: "outbound",
|
|
175
|
+
text,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return { replyOnly: null, parkPhase: "suspend" };
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Present the head of the delegation queue as the session's pending decision —
|
|
183
|
+
* the child's decision unchanged, since that is what the person is asked. Not
|
|
184
|
+
* counted against `maxParks`: nothing the calling agent did caused this.
|
|
185
|
+
*/
|
|
186
|
+
function presentDelegation(ctx, state, runtime, head) {
|
|
187
|
+
const fields = readWorkflowState(state);
|
|
188
|
+
const position = currentWorkflowState(state, ctx.machine.entry);
|
|
189
|
+
const sessionId = ctx.sessionIdOf(runtime);
|
|
190
|
+
// The channel has to be the one the child asked for. A child that called
|
|
191
|
+
// `archmax_wait` is waiting for an event, so presenting it as a decision would
|
|
192
|
+
// leave a park with no transitions to choose and nothing able to resume it.
|
|
193
|
+
if (!isDecisionPark(head.decision)) {
|
|
194
|
+
ctx.emit({ type: "parked", node: position, state: position, sessionId, awaiting: "input" });
|
|
195
|
+
return {
|
|
196
|
+
pendingInput: head.decision,
|
|
197
|
+
status: WORKFLOW_STATUSES.awaitingInput,
|
|
198
|
+
rejected: null,
|
|
199
|
+
...closingTurn(),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const seq = (fields.decisionCount ?? 0) + 1;
|
|
203
|
+
ctx.emit({ type: "parked", node: position, state: position, sessionId, awaiting: "decision" });
|
|
204
|
+
return {
|
|
205
|
+
pendingDecision: { ...head.decision, seq },
|
|
206
|
+
decisionCount: seq,
|
|
207
|
+
status: WORKFLOW_STATUSES.awaitingDecision,
|
|
208
|
+
rejected: null,
|
|
209
|
+
...closingTurn(),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* The suspension site: with a record in phase `suspend` and nothing owed, park
|
|
214
|
+
* the session on it. `interrupt()` throws on first arrival — the session parks
|
|
215
|
+
* durably — and on resume returns what a surface resumed with, which
|
|
216
|
+
* {@link applyResume} turns into the run's continuation.
|
|
217
|
+
*/
|
|
218
|
+
export async function suspendIfParked(ctx, state, runtime, site) {
|
|
219
|
+
const park = pendingParkOf(state);
|
|
220
|
+
if (!park || readWorkflowState(state).parkPhase !== "suspend")
|
|
221
|
+
return undefined;
|
|
222
|
+
if (replyOwed(state))
|
|
223
|
+
return undefined;
|
|
224
|
+
// Tool calls left unanswered would dangle across the park; the tools node
|
|
225
|
+
// answers (refuses) them first and the hook after it suspends.
|
|
226
|
+
if (lastReplyCallsTools(messagesOf(state)))
|
|
227
|
+
return undefined;
|
|
228
|
+
const resume = interrupt(park.record);
|
|
229
|
+
return applyResume(ctx, state, runtime, resume, site);
|
|
230
|
+
}
|
|
231
|
+
// --- Resuming -------------------------------------------------------------------
|
|
232
|
+
function isTriggerDelivery(resume) {
|
|
233
|
+
const trigger = resume?.trigger;
|
|
234
|
+
return trigger != null && typeof trigger === "object" && typeof trigger.id === "string";
|
|
235
|
+
}
|
|
236
|
+
/** `jumpTo: "model"` where the loop would otherwise exit — after the model. */
|
|
237
|
+
function continueToModel(site) {
|
|
238
|
+
return site === "after-model" ? { jumpTo: "model" } : {};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Turn what a surface resumed with into the run's continuation: a **message** is
|
|
242
|
+
* recorded as a person's and answered on a reply-only turn (the record stays and
|
|
243
|
+
* the session suspends again); a **delivery** seeds the firing's variables and
|
|
244
|
+
* continues the parked state; a **decision** routes — or, for a delegated park,
|
|
245
|
+
* is handed to the child that asked.
|
|
246
|
+
*/
|
|
247
|
+
async function applyResume(ctx, state, runtime, resume, site) {
|
|
248
|
+
const pending = readWorkflowState(state).pendingDelegations ?? [];
|
|
249
|
+
// A delivery is told apart first: it may carry the person's message with the
|
|
250
|
+
// firing, and a message alone is what a reply is. When a delegation is pending
|
|
251
|
+
// the firing belongs to the child that asked for it — routed here, because the
|
|
252
|
+
// parent's own delivery path would resume the parent and leave the child
|
|
253
|
+
// waiting forever.
|
|
254
|
+
if (isTriggerDelivery(resume)) {
|
|
255
|
+
return pending.length > 0
|
|
256
|
+
? resumeDelegated(ctx, state, runtime, resume, pending, site)
|
|
257
|
+
: applyDelivery(ctx, state, runtime, resume, site);
|
|
258
|
+
}
|
|
259
|
+
if (isMessageResume(resume)) {
|
|
260
|
+
const position = currentWorkflowState(state, ctx.machine.entry);
|
|
261
|
+
const text = resume.message.trim();
|
|
262
|
+
ctx.emit({
|
|
263
|
+
type: "park-message",
|
|
264
|
+
node: position,
|
|
265
|
+
state: position,
|
|
266
|
+
sessionId: ctx.sessionIdOf(runtime),
|
|
267
|
+
direction: "inbound",
|
|
268
|
+
text,
|
|
269
|
+
});
|
|
270
|
+
// A plain `HumanMessage`, the only runtime-appended one: a person wrote this.
|
|
271
|
+
return {
|
|
272
|
+
messages: [new HumanMessage(text)],
|
|
273
|
+
replyOnly: true,
|
|
274
|
+
parkPhase: "suspend",
|
|
275
|
+
...continueToModel(site),
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
// A decision routes, and a delegated park hands it to the child that asked. A
|
|
279
|
+
// message never reaches here: it is answered by the parent above, parked or
|
|
280
|
+
// delegated alike.
|
|
281
|
+
if (pending.length > 0)
|
|
282
|
+
return resumeDelegated(ctx, state, runtime, resume, pending, site);
|
|
283
|
+
return applyDecision(ctx, state, runtime, resume, site);
|
|
284
|
+
}
|
|
285
|
+
/** A person picked an edge at the run's own human state. */
|
|
286
|
+
function applyDecision(ctx, state, runtime, decision, site) {
|
|
287
|
+
const { machine } = ctx;
|
|
288
|
+
const fields = readWorkflowState(state);
|
|
289
|
+
const from = currentWorkflowState(state, machine.entry);
|
|
290
|
+
const sessionId = ctx.sessionIdOf(runtime);
|
|
291
|
+
const target = (decision?.target ?? "").trim();
|
|
292
|
+
const comment = (decision?.comment ?? "").trim();
|
|
293
|
+
const advanced = target !== from && machine.transitionTargets(from).includes(target);
|
|
294
|
+
const chosen = fields.pendingDecision?.transitions.find((t) => t.to === target);
|
|
295
|
+
const humanStep = {
|
|
296
|
+
to: advanced ? target : from,
|
|
297
|
+
kind: "human",
|
|
298
|
+
...(comment ? { reason: comment } : {}),
|
|
299
|
+
ts: Date.now(),
|
|
300
|
+
};
|
|
301
|
+
ctx.emit({ type: "decided", node: from, state: from, to: advanced ? target : "__end__", sessionId });
|
|
302
|
+
if (!advanced) {
|
|
303
|
+
// No declared edge was selected (the decision surface refuses this, but a
|
|
304
|
+
// checkpoint may predate it): the run ends rather than loops, decision on the trail.
|
|
305
|
+
return {
|
|
306
|
+
pendingDecision: null,
|
|
307
|
+
status: WORKFLOW_STATUSES.completed,
|
|
308
|
+
parkPhase: null,
|
|
309
|
+
replyOnly: null,
|
|
310
|
+
auditTrail: [humanStep],
|
|
311
|
+
...(site === "before-model" ? { jumpTo: "end" } : {}),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
// This note is the only thing the target state reads about how it got here.
|
|
315
|
+
const label = chosen?.type && chosen.type !== "none" ? `${chosen.type} → '${target}'` : `'${target}'`;
|
|
316
|
+
const note = runtimeNote("decision", `[decision] A human selected ${label} at the '${from}' checkpoint` +
|
|
317
|
+
(comment ? `: ${comment}.` : ".") +
|
|
318
|
+
` The run has already been routed: you are now in '${target}'. Do its work and ` +
|
|
319
|
+
`continue from here.`);
|
|
320
|
+
ctx.emit({ type: "state-leave", state: from, next: target });
|
|
321
|
+
ctx.emit({ type: "state-enter", state: target });
|
|
322
|
+
// Corrections are carried across unchanged: a person choosing `refine` again is
|
|
323
|
+
// judgment at human pace, not the runaway a correction budget exists to stop.
|
|
324
|
+
const routed = {
|
|
325
|
+
messages: note,
|
|
326
|
+
workflowState: target,
|
|
327
|
+
pendingDecision: null,
|
|
328
|
+
status: WORKFLOW_STATUSES.running,
|
|
329
|
+
replyOnly: null,
|
|
330
|
+
parkPhase: null,
|
|
331
|
+
stateTurns: null,
|
|
332
|
+
rejected: null,
|
|
333
|
+
auditTrail: [humanStep],
|
|
334
|
+
...continueToModel(site),
|
|
335
|
+
};
|
|
336
|
+
// Routed straight into another human state: present it. The run owes the person
|
|
337
|
+
// a closing message first — the one model call that reaches the next hook site.
|
|
338
|
+
if (machine.isHumanState(target)) {
|
|
339
|
+
const seq = (fields.decisionCount ?? 0) + 1;
|
|
340
|
+
ctx.emit({ type: "parked", node: target, state: target, sessionId, awaiting: "decision" });
|
|
341
|
+
return {
|
|
342
|
+
...routed,
|
|
343
|
+
pendingDecision: decisionRecordFor(machine, target, seq),
|
|
344
|
+
decisionCount: seq,
|
|
345
|
+
status: WORKFLOW_STATUSES.awaitingDecision,
|
|
346
|
+
...closingTurn(),
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
return routed;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* A person decided at a delegated child's human state: hand the decision to that
|
|
353
|
+
* child and record what it answered. A child that parks again is re-presented
|
|
354
|
+
* on the spot; a sibling still waiting is presented next; otherwise the calling
|
|
355
|
+
* state continues.
|
|
356
|
+
*/
|
|
357
|
+
async function resumeDelegated(ctx, state, runtime, resume, delegations, site) {
|
|
358
|
+
const fields = readWorkflowState(state);
|
|
359
|
+
const from = currentWorkflowState(state, ctx.machine.entry);
|
|
360
|
+
const sessionId = ctx.sessionIdOf(runtime);
|
|
361
|
+
const [head, ...rest] = delegations;
|
|
362
|
+
// Only a decision routes; a delivery hands the child its firing and the parent
|
|
363
|
+
// records nothing to have decided.
|
|
364
|
+
if (isDecisionPark(head.decision)) {
|
|
365
|
+
const decision = resume;
|
|
366
|
+
ctx.emit({ type: "decided", node: from, state: from, to: decision?.target ?? "", sessionId });
|
|
367
|
+
}
|
|
368
|
+
const present = (next, remaining, committed) => {
|
|
369
|
+
if (!isDecisionPark(next.decision)) {
|
|
370
|
+
ctx.emit({ type: "parked", node: from, state: from, sessionId, awaiting: "input" });
|
|
371
|
+
return {
|
|
372
|
+
...committed,
|
|
373
|
+
pendingDelegations: { remaining },
|
|
374
|
+
pendingInput: next.decision,
|
|
375
|
+
status: WORKFLOW_STATUSES.awaitingInput,
|
|
376
|
+
...closingTurn(),
|
|
377
|
+
...continueToModel(site),
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
const seq = (fields.decisionCount ?? 0) + 1;
|
|
381
|
+
ctx.emit({ type: "parked", node: from, state: from, sessionId, awaiting: "decision" });
|
|
382
|
+
return {
|
|
383
|
+
...committed,
|
|
384
|
+
pendingDelegations: { remaining },
|
|
385
|
+
pendingDecision: { ...next.decision, seq },
|
|
386
|
+
decisionCount: seq,
|
|
387
|
+
status: WORKFLOW_STATUSES.awaitingDecision,
|
|
388
|
+
...closingTurn(),
|
|
389
|
+
...continueToModel(site),
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
let text;
|
|
393
|
+
let status = "ok";
|
|
394
|
+
try {
|
|
395
|
+
if (!ctx.dispatcher) {
|
|
396
|
+
throw new SubWorkflowError("error", head.workflow, `Cannot resume sub-workflow '${head.workflow}': this assembly cannot run ` +
|
|
397
|
+
`sub-workflows (no dispatcher is wired).`);
|
|
398
|
+
}
|
|
399
|
+
const result = await ctx.dispatcher.resume({
|
|
400
|
+
workflow: head.workflow,
|
|
401
|
+
identity: head.identity,
|
|
402
|
+
dispatchId: head.dispatchId,
|
|
403
|
+
config: ctx.configOf(runtime),
|
|
404
|
+
resume,
|
|
405
|
+
state: from,
|
|
406
|
+
});
|
|
407
|
+
text = `[sub-workflow: ${result.workflow}] ${result.result}`;
|
|
408
|
+
}
|
|
409
|
+
catch (err) {
|
|
410
|
+
// Parked again — a second decision inside the same child, re-presented on the spot.
|
|
411
|
+
const reparked = subWorkflowParkOf(err);
|
|
412
|
+
if (reparked) {
|
|
413
|
+
const reentry = { ...head, decision: reparked.decision };
|
|
414
|
+
return present(reentry, [reentry, ...rest], {});
|
|
415
|
+
}
|
|
416
|
+
if (isGraphInterrupt(err))
|
|
417
|
+
throw err;
|
|
418
|
+
status = "error";
|
|
419
|
+
text =
|
|
420
|
+
`[error] sub-workflow '${head.workflow}' failed after the decision: ` +
|
|
421
|
+
`${err?.message ?? String(err)}`;
|
|
422
|
+
}
|
|
423
|
+
// The child's answer is a transcript fact: its tool call was answered when the run parked.
|
|
424
|
+
const committed = {
|
|
425
|
+
messages: runtimeNote(status === "ok" ? "sub-workflow" : "error", text),
|
|
426
|
+
auditTrail: [
|
|
427
|
+
{ to: from, kind: "sub-workflow", workflow: head.workflow, status, ts: Date.now() },
|
|
428
|
+
],
|
|
429
|
+
};
|
|
430
|
+
if (rest.length > 0)
|
|
431
|
+
return present(rest[0], rest, committed);
|
|
432
|
+
return {
|
|
433
|
+
...committed,
|
|
434
|
+
pendingDelegations: null,
|
|
435
|
+
pendingDecision: null,
|
|
436
|
+
pendingInput: null,
|
|
437
|
+
status: WORKFLOW_STATUSES.running,
|
|
438
|
+
parkPhase: null,
|
|
439
|
+
replyOnly: null,
|
|
440
|
+
...continueToModel(site),
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* A firing delivered into a wait park: the firing's variables as locked host
|
|
445
|
+
* seeds, the arrival in the transcript and on the trail, the delivered id as the
|
|
446
|
+
* run's current trigger — and the parked state continues in place. An id-less
|
|
447
|
+
* firing is accepted: the delivery surface validated the park, and refusing a
|
|
448
|
+
* resume the host committed to would leave the run parked forever.
|
|
449
|
+
*/
|
|
450
|
+
function applyDelivery(ctx, state, runtime, delivery, site) {
|
|
451
|
+
const slug = currentWorkflowState(state, ctx.machine.entry);
|
|
452
|
+
const sessionId = ctx.sessionIdOf(runtime);
|
|
453
|
+
const deliveredId = (delivery.trigger?.id ?? "").trim();
|
|
454
|
+
ctx.emit({ type: "delivered", node: slug, state: slug, trigger: deliveredId, to: slug, sessionId });
|
|
455
|
+
// Host seeds at a delivery boundary: locked, and marked `reseed` so a repeat
|
|
456
|
+
// park/deliver cycle can re-establish the same name. Only this path and the
|
|
457
|
+
// turn boundary set that marker, so no agent-reachable write bypasses a lock.
|
|
458
|
+
const delivered = {};
|
|
459
|
+
for (const [name, value] of Object.entries(delivery.variables ?? {})) {
|
|
460
|
+
// `title` is never locked. A malformed one is warned and skipped rather than
|
|
461
|
+
// thrown: dropping a whole resume over a bad label is the worse failure.
|
|
462
|
+
if (name === TITLE_VARIABLE) {
|
|
463
|
+
const problem = titleWriteError(value);
|
|
464
|
+
if (problem) {
|
|
465
|
+
ctx.emit({ type: "warning", scope: "workflow", message: `Delivered title ignored: ${problem}` });
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
delivered[name] = { value: normalizeTitle(value), locked: false, reseed: true };
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
delivered[name] = { value, locked: true, reseed: true };
|
|
472
|
+
}
|
|
473
|
+
const names = Object.keys(delivered);
|
|
474
|
+
if (names.length > 0) {
|
|
475
|
+
ctx.emit({ type: "variables-set", state: slug, names, locked: true });
|
|
476
|
+
const title = delivered[TITLE_VARIABLE]?.value;
|
|
477
|
+
if (typeof title === "string")
|
|
478
|
+
ctx.emit({ type: "title-set", title, state: slug });
|
|
479
|
+
}
|
|
480
|
+
// The delivered firing is the resumed turn's cause (`args.trigger`, `${{trigger}}`); `entryState` is untouched.
|
|
481
|
+
delivered[TRIGGER_VARIABLE] = { value: deliveredId, locked: true, reseed: true };
|
|
482
|
+
// The arrival in the transcript, the way a decision is recorded: the resumed state has to see what arrived.
|
|
483
|
+
const summary = Object.entries(delivery.variables ?? {})
|
|
484
|
+
.map(([name, value]) => `${name}=${JSON.stringify(value)}`)
|
|
485
|
+
.join(", ");
|
|
486
|
+
const detail = summary ? `: ${summary} (also readable as run variables)` : ".";
|
|
487
|
+
// A person's message that came with the firing: the one runtime-appended
|
|
488
|
+
// human message besides a reply, written in the same update as the arrival so
|
|
489
|
+
// the two cannot be split by a crash or land on a park that is gone.
|
|
490
|
+
const said = (delivery.message ?? "").trim();
|
|
491
|
+
if (said) {
|
|
492
|
+
ctx.emit({ type: "park-message", node: slug, state: slug, sessionId, direction: "inbound", text: said });
|
|
493
|
+
}
|
|
494
|
+
ctx.emit({ type: "state-enter", state: slug });
|
|
495
|
+
return {
|
|
496
|
+
messages: [
|
|
497
|
+
...runtimeNote("event", `[event] '${deliveredId}' arrived while the run waited in '${slug}'${detail} ` +
|
|
498
|
+
`You are still in '${slug}'; continue from here.` +
|
|
499
|
+
(said ? " The person's message that came with it follows." : "")),
|
|
500
|
+
...(said ? [new HumanMessage(said)] : []),
|
|
501
|
+
],
|
|
502
|
+
variables: delivered,
|
|
503
|
+
trigger: { id: deliveredId },
|
|
504
|
+
pendingInput: null,
|
|
505
|
+
status: WORKFLOW_STATUSES.running,
|
|
506
|
+
parkPhase: null,
|
|
507
|
+
replyOnly: null,
|
|
508
|
+
rejected: null,
|
|
509
|
+
auditTrail: [{ to: slug, kind: "trigger", reason: deliveredId, ts: Date.now() }],
|
|
510
|
+
...continueToModel(site),
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
//# sourceMappingURL=parks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parks.js","sourceRoot":"","sources":["../../src/workflow/parks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;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AI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,OAAO;QACL,QAAQ,EAAE;YACR,GAAG,WAAW,CACZ,OAAO,EACP,YAAY,WAAW,sCAAsC,IAAI,IAAI,MAAM,GAAG;gBAC5E,qBAAqB,IAAI,wBAAwB;gBACjD,CAAC,IAAI,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAC,EAAE,CAAC,CACnE;YACD,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1C;QACD,SAAS,EAAE,SAAS;QACpB,OAAO,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE;QAC5B,YAAY,EAAE,IAAI;QAClB,MAAM,EAAE,iBAAiB,CAAC,OAAO;QACjC,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAsB,CAAC;QACpG,GAAG,eAAe,CAAC,IAAI,CAAC;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** Default workflow slug when none is supplied. */
|
|
2
|
+
export declare const DEFAULT_WORKFLOW = "order-lookup";
|
|
3
|
+
/**
|
|
4
|
+
* Where a workspace may override the platform system prompt. Nothing needs to be
|
|
5
|
+
* served there: the runtime ships the default prompt in its code.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PLATFORM_PROMPT_PATH = ".platform/system/GRAPH_STATE.md";
|
|
8
|
+
export { PLATFORM_PROMPT_PATH as PLATFORM_BACKEND_PROMPT_PATH };
|
|
9
|
+
/** Workspace-relative paths for a named workflow (the read-only authored zone). */
|
|
10
|
+
export declare function workflowPaths(workflow: string): {
|
|
11
|
+
platformPrompt: string;
|
|
12
|
+
agentsPrompt: string;
|
|
13
|
+
/** The machine spec: a pure YAML mapping. */
|
|
14
|
+
workflowYaml: string;
|
|
15
|
+
/** Optional prose addendum, appended after the spec-rendered prompt section. Never a machine source. */
|
|
16
|
+
workflow: string;
|
|
17
|
+
testsDir: string;
|
|
18
|
+
/** Lifecycle hook scripts: the runtime's code, which the agent can neither read nor execute. */
|
|
19
|
+
hooksDir: string;
|
|
20
|
+
};
|
|
21
|
+
/** Where a hook script must live, relative to its workflow directory. */
|
|
22
|
+
export declare const HOOKS_DIR = "hooks";
|
|
23
|
+
/**
|
|
24
|
+
* Resolve a hook's declared `script:` to an authoring-backend path. A hook path
|
|
25
|
+
* is workflow-relative and confined to the workflow's own `hooks/`; anything
|
|
26
|
+
* leaving it is refused with a reason. This keeps the two script classes
|
|
27
|
+
* disjoint: a hook can never be an `archmax_run` target.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveHookScript(workflow: string, declared: string): {
|
|
30
|
+
ok: true;
|
|
31
|
+
path: string;
|
|
32
|
+
} | {
|
|
33
|
+
ok: false;
|
|
34
|
+
reason: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The runtime-internal layout of one session's folder. These paths carry the
|
|
38
|
+
* session id explicitly (`<sessionId>/…`) because internal writers run both
|
|
39
|
+
* inside and outside a bound turn; the agent addresses the same folders id-free.
|
|
40
|
+
*/
|
|
41
|
+
export declare function sessionPaths(sessionId: string): {
|
|
42
|
+
base: string;
|
|
43
|
+
/** Durable checkpoint and pending-write records, one immutable file each. */
|
|
44
|
+
checkpointsDir: string;
|
|
45
|
+
artifactsDir: string;
|
|
46
|
+
/** The run's working area (`scratchpad/…` to the agent). Durable; nothing cleans it up. */
|
|
47
|
+
scratchpadDir: string;
|
|
48
|
+
/** Deep Agents' context-offload areas: agent-readable, never agent-writable. */
|
|
49
|
+
largeToolResultsDir: string;
|
|
50
|
+
conversationHistoryDir: string;
|
|
51
|
+
};
|
|
52
|
+
/** Paths of a session's observability artifacts under `<sessionId>/artifacts/`. */
|
|
53
|
+
export declare function runArtifactPaths(sessionId: string): {
|
|
54
|
+
runDir: string;
|
|
55
|
+
graphJson: string;
|
|
56
|
+
graphMermaid: string;
|
|
57
|
+
trajectoryJson: string;
|
|
58
|
+
metadataJson: string;
|
|
59
|
+
trailJson: string;
|
|
60
|
+
variablesJson: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Path of a content-addressed spec snapshot, keyed by `specHash`. Lives under
|
|
64
|
+
* the session-agnostic `_specs/` prefix so every session sharing a spec version
|
|
65
|
+
* shares one file; the run-zone router passes this prefix through unprefixed.
|
|
66
|
+
*/
|
|
67
|
+
export declare function specSnapshotPath(hash: string): string;
|