@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,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Child compositions, composed lazily and memoized by workflow slug **and
|
|
3
|
+
* delegation chain**: the denials a child inherits are every ancestor's, so the
|
|
4
|
+
* same slug reached through two different callers is two compositions.
|
|
5
|
+
*
|
|
6
|
+
* Lazy so a workflow nothing delegates to costs nothing; memoized on the
|
|
7
|
+
* **promise** so concurrent dispatches of one slug under one chain compose it
|
|
8
|
+
* once. Every failure here is a *dispatch* failure, never an assembly failure: a
|
|
9
|
+
* parent must still assemble when a workflow it might delegate to is broken.
|
|
10
|
+
*/
|
|
11
|
+
import { loadMachineSpec } from "../machine/load-spec.js";
|
|
12
|
+
import { WorkflowMachine } from "../machine/machine.js";
|
|
13
|
+
import { MANUAL_TRIGGER } from "../machine/triggers.js";
|
|
14
|
+
import { workflowPaths } from "../workflow/paths.js";
|
|
15
|
+
import { SubWorkflowError, } from "../workflow/sub-workflow.js";
|
|
16
|
+
import { rubricsAsSubagents, rubricsFromSpec } from "../rubrics/rubrics.js";
|
|
17
|
+
import { composeGoverned, inheritedDenials, renderSystemPrompt } from "./compose.js";
|
|
18
|
+
/** Build the registry the root composition and every child dispatch through. */
|
|
19
|
+
export function createDelegationRegistry(ctx, root) {
|
|
20
|
+
const composed = new Map();
|
|
21
|
+
/**
|
|
22
|
+
* The child's *machine*, without its agent, so a dispatch can be refused on
|
|
23
|
+
* the target's `requires` for the price of a spec read. Shared with
|
|
24
|
+
* `resolve`, so an accepted dispatch never loads the spec twice.
|
|
25
|
+
*/
|
|
26
|
+
const loads = new Map();
|
|
27
|
+
function load(target) {
|
|
28
|
+
let loading = loads.get(target);
|
|
29
|
+
if (!loading) {
|
|
30
|
+
// A failed load is not cached: a spec fixed between dispatches should be
|
|
31
|
+
// picked up rather than remembered as broken forever.
|
|
32
|
+
loading = loadSpec(target).catch((err) => {
|
|
33
|
+
loads.delete(target);
|
|
34
|
+
throw err;
|
|
35
|
+
});
|
|
36
|
+
loads.set(target, loading);
|
|
37
|
+
}
|
|
38
|
+
return loading;
|
|
39
|
+
}
|
|
40
|
+
async function loadSpec(target) {
|
|
41
|
+
const paths = workflowPaths(target);
|
|
42
|
+
const loaded = await loadMachineSpec(ctx.authoring, paths);
|
|
43
|
+
if (!loaded.usable || !loaded.spec) {
|
|
44
|
+
const detail = loaded.issues.some((i) => i.kind === "missing")
|
|
45
|
+
? `no '${paths.workflowYaml}' found`
|
|
46
|
+
: loaded.issues.map((i) => i.message).join("; ") || "no valid machine spec";
|
|
47
|
+
throw new SubWorkflowError("unknown-workflow", target, `Cannot run sub-workflow '${target}': ${detail}.`);
|
|
48
|
+
}
|
|
49
|
+
// Rubrics are deliberately *not* inherited: a child is graded by the
|
|
50
|
+
// standards its own spec declares, so its registry comes from `loaded.spec`
|
|
51
|
+
// when the child runtime is composed, never from the caller's.
|
|
52
|
+
const machine = WorkflowMachine.fromSpec(loaded.spec, ctx.params.essentialTools);
|
|
53
|
+
// A caller enters where a host would: the `manual` entry. A machine with
|
|
54
|
+
// none cannot be started at all (fail-closed, as at the host ingress).
|
|
55
|
+
if (!machine.startStateForTrigger(MANUAL_TRIGGER)) {
|
|
56
|
+
throw new SubWorkflowError("not-delegatable", target, `Cannot run sub-workflow '${target}': it declares no '${MANUAL_TRIGGER}' trigger ` +
|
|
57
|
+
`entry, so it has no state to start in. Add ` +
|
|
58
|
+
`"trigger: ${MANUAL_TRIGGER}" to the state a session should start in.`);
|
|
59
|
+
}
|
|
60
|
+
return { body: loaded.body, machine };
|
|
61
|
+
}
|
|
62
|
+
async function compose(target, caller) {
|
|
63
|
+
const { body, machine } = await load(target);
|
|
64
|
+
const systemPrompt = await renderSystemPrompt(ctx, machine, body, { workflow: target });
|
|
65
|
+
// The child's graders are its own: a rubric declared in one `workflow.yaml`
|
|
66
|
+
// is not resolvable from another, so a sub-run is held to the standards its
|
|
67
|
+
// own machine declares — and its `task` tool is registered with those.
|
|
68
|
+
const rubrics = rubricsFromSpec(machine.spec);
|
|
69
|
+
const childCtx = {
|
|
70
|
+
...ctx,
|
|
71
|
+
rubrics,
|
|
72
|
+
subagents: rubricsAsSubagents(rubrics, ctx.rubricModel),
|
|
73
|
+
};
|
|
74
|
+
const child = await composeGoverned(childCtx, {
|
|
75
|
+
machine,
|
|
76
|
+
workflow: target,
|
|
77
|
+
systemPrompt,
|
|
78
|
+
trigger: { id: MANUAL_TRIGGER },
|
|
79
|
+
// Denials compose downward and accumulate: the caller hands down what it
|
|
80
|
+
// inherited plus its own policy, so the child may narrow what is permitted
|
|
81
|
+
// but never re-grant what any ancestor forbade. A caller-less resolve (a
|
|
82
|
+
// direct child of the root) inherits the root's alone.
|
|
83
|
+
inheritedPolicyRules: caller?.inheritedPolicyRules ?? inheritedDenials(ctx, root),
|
|
84
|
+
registry,
|
|
85
|
+
});
|
|
86
|
+
// A child is driven exactly as the top-level agent drives itself: through
|
|
87
|
+
// its turn runner, which binds the child's own session and streams its text.
|
|
88
|
+
return { graph: { invoke: child.driver.invoke }, machine };
|
|
89
|
+
}
|
|
90
|
+
const registry = {
|
|
91
|
+
resolve(target, caller) {
|
|
92
|
+
const key = [...(caller?.chain ?? []), target].join(" > ");
|
|
93
|
+
let composing = composed.get(key);
|
|
94
|
+
if (!composing) {
|
|
95
|
+
composing = compose(target, caller).catch((err) => {
|
|
96
|
+
composed.delete(key);
|
|
97
|
+
throw err;
|
|
98
|
+
});
|
|
99
|
+
composed.set(key, composing);
|
|
100
|
+
}
|
|
101
|
+
return composing;
|
|
102
|
+
},
|
|
103
|
+
async signature(target) {
|
|
104
|
+
const { machine } = await load(target);
|
|
105
|
+
const title = machine.spec.title?.trim();
|
|
106
|
+
return {
|
|
107
|
+
requires: machine.requiresForTrigger(MANUAL_TRIGGER),
|
|
108
|
+
returns: machine.returnsForTrigger(MANUAL_TRIGGER),
|
|
109
|
+
...(title ? { title } : {}),
|
|
110
|
+
// Reported, not enforced here: a disabled target still binds a tool so
|
|
111
|
+
// disabling a leaf does not fail every caller; the dispatcher refuses.
|
|
112
|
+
...(machine.disabled ? { disabled: true } : {}),
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
return registry;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=delegation-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation-registry.js","sourceRoot":"","sources":["../../src/assembly/deleg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CAAC,GAAG,CAAC,CAAC;oBACrB,MAAM,GAAG,CAAC;gBACZ,CAAC,CAAC,CAAC;gBACH,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YAC/B,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,MAAM;YACpB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC;YACvC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;YACzC,OAAO;gBACL,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC,cAAc,CAAC;gBACpD,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC;gBAClD,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3B,uEAAuE;gBACvE,uEAAuE;gBACvE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAChD,CAAC;QACJ,CAAC;KACF,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import type { BaseChatModel } from "@langchain/core/language_models/chat_models";
|
|
2
|
+
import type { StructuredTool } from "@langchain/core/tools";
|
|
3
|
+
import type { BaseCheckpointSaver } from "@langchain/langgraph";
|
|
4
|
+
import type { AgentMiddleware } from "langchain";
|
|
5
|
+
import type { BackendProtocolV2, CreateDeepAgentParams } from "deepagents";
|
|
6
|
+
import { type Agent } from "../agent.js";
|
|
7
|
+
import { type WorkflowEventHandler } from "../core/events.js";
|
|
8
|
+
import type { MountSpec } from "../core/mounts.js";
|
|
9
|
+
import type { SessionStore } from "../core/session-store.js";
|
|
10
|
+
import { type PricingTable } from "../core/usage.js";
|
|
11
|
+
import { type ModelFactory } from "../env.js";
|
|
12
|
+
import type { GovernanceRule } from "../kernel/kernel.js";
|
|
13
|
+
import type { HookExecutor } from "../lifecycle/runner.js";
|
|
14
|
+
import { type TriggerInput } from "../machine/triggers.js";
|
|
15
|
+
import type { SandboxRuntime } from "../sandbox/runtime.js";
|
|
16
|
+
import type { PromptCacheOptions } from "../workflow/prompt-cache.js";
|
|
17
|
+
/**
|
|
18
|
+
* Workspace composition, grouped. `rootDir`, `mounts` and `sessionStore` all
|
|
19
|
+
* answer one question — where this agent's files come from and where its
|
|
20
|
+
* sessions go — and none of them exists in Deep Agents.
|
|
21
|
+
*/
|
|
22
|
+
export interface AgentWorkspaceParams {
|
|
23
|
+
/**
|
|
24
|
+
* Agent workspace root used by the default filesystem backend. Defaults to
|
|
25
|
+
* the consumer's current working directory (the repository's
|
|
26
|
+
* `examples/customer-support` is the reference workspace).
|
|
27
|
+
*/
|
|
28
|
+
rootDir?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Authored mounts as a `CompositeBackend` route table: key → backend, or
|
|
31
|
+
* `{ backend, readOnly }`. A key ending in `/` is a directory mount; a key
|
|
32
|
+
* without one (`"/AGENTS.md"`) is an exact-path file mount. Mounts are
|
|
33
|
+
* read-only unless declared otherwise. Omitted on the default filesystem
|
|
34
|
+
* backend, `defaultMounts(rootDir)` is applied — a convention, not a
|
|
35
|
+
* constraint; spread it to extend. Omitted with a custom `backend`, nothing
|
|
36
|
+
* authored is served: exposing it is an explicit act
|
|
37
|
+
* (`mountSubtree(backend, "skills")`).
|
|
38
|
+
*/
|
|
39
|
+
mounts?: Record<string, MountSpec>;
|
|
40
|
+
/**
|
|
41
|
+
* Physical storage for sessions — checkpoints, artifacts, scratchpad and
|
|
42
|
+
* offloaded context. Build one with `createFilesystemSessionStore({ dir })`,
|
|
43
|
+
* `createBackendSessionStore({ backend, prefix? })` or
|
|
44
|
+
* `createMemorySessionStore()`. With the default backend this defaults to a
|
|
45
|
+
* filesystem store at `<rootDir>/sessions`; with a custom `backend` it is
|
|
46
|
+
* required — assembly throws `SessionStoreRequiredError` rather than inferring
|
|
47
|
+
* storage.
|
|
48
|
+
*/
|
|
49
|
+
sessionStore?: SessionStore;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Parameters for {@link createAgent}.
|
|
53
|
+
*
|
|
54
|
+
* Every concept shared with LangChain Deep Agents keeps **Deep Agents' own name
|
|
55
|
+
* and meaning** — `model`, `tools`, `systemPrompt`, `middleware`,
|
|
56
|
+
* `backend`, `skills`, `checkpointer`, `store`, `interruptOn`, `name` — so a
|
|
57
|
+
* `createDeepAgent` call ports by changing only the import, with one recorded
|
|
58
|
+
* exception: there is no `subagents` parameter. An agent-facing subagent is not
|
|
59
|
+
* a concept the archmax harness offers — grading is a **rubric** declared in `workflow.yaml`
|
|
60
|
+
* and delegating work is a **sub-workflow** — so `task` is disclosed to no
|
|
61
|
+
* state. The harness's concerns are otherwise strictly additive: `workflow`
|
|
62
|
+
* (governance), `workspace` (file composition), `authoring` (the
|
|
63
|
+
* governance-plane backend), and the extension points below.
|
|
64
|
+
*/
|
|
65
|
+
export interface CreateAgentParams {
|
|
66
|
+
/** Chat model; defaults to the env-configured OpenAI-compatible model. */
|
|
67
|
+
model?: BaseChatModel;
|
|
68
|
+
/**
|
|
69
|
+
* Extra tools bound to the agent alongside the built-in sandbox and control
|
|
70
|
+
* tools — e.g. resolved connector/MCP capabilities (see `toolsFromMap`).
|
|
71
|
+
* Workflow governance still gates which of these the agent may call at any
|
|
72
|
+
* given point; this only makes them exist as invokable functions.
|
|
73
|
+
*/
|
|
74
|
+
tools?: StructuredTool[];
|
|
75
|
+
/** Appended after the workspace's `AGENTS.md` in the system prompt. */
|
|
76
|
+
systemPrompt?: string;
|
|
77
|
+
/** Extra middleware appended after the runtime's own — the workflow instrumentation when governed (e.g. test mocks). Honoured on both paths. */
|
|
78
|
+
middleware?: AgentMiddleware[];
|
|
79
|
+
/**
|
|
80
|
+
* Declares that authored content comes from somewhere other than the local
|
|
81
|
+
* filesystem root — a store, sandbox, or remote Deep Agents backend. This
|
|
82
|
+
* backend reaches the workspace only through `workspace.mounts`, and its
|
|
83
|
+
* presence withdraws every zero-config default, so `workspace.sessionStore`
|
|
84
|
+
* becomes required.
|
|
85
|
+
*/
|
|
86
|
+
backend?: BackendProtocolV2;
|
|
87
|
+
/**
|
|
88
|
+
* Where the workspace's skills live, as **sources** read through the backend
|
|
89
|
+
* — a parent directory of bundles (`"skills/"`) or a single bundle. Defaults
|
|
90
|
+
* to `DEFAULT_SKILL_SOURCES` (`["skills/"]`). Pass `[]` for a workspace with
|
|
91
|
+
* no skills.
|
|
92
|
+
*/
|
|
93
|
+
skills?: string[];
|
|
94
|
+
/**
|
|
95
|
+
* LangGraph checkpointer — the custom-adapter escape hatch. Defaults to a
|
|
96
|
+
* `BackendCheckpointSaver` that persists each session durably through the
|
|
97
|
+
* session store (`<sessionId>/checkpoints/`), so sessions survive restarts
|
|
98
|
+
* and can be listed and resumed. Supply a `MemorySaver` for ephemeral runs.
|
|
99
|
+
*/
|
|
100
|
+
checkpointer?: BaseCheckpointSaver;
|
|
101
|
+
/** LangGraph store, passed through to the framework untouched. */
|
|
102
|
+
store?: CreateDeepAgentParams["store"];
|
|
103
|
+
/**
|
|
104
|
+
* Framework-level interrupt configuration, passed through untouched. Distinct
|
|
105
|
+
* from a workflow `type: human` state, which parks through the machine.
|
|
106
|
+
*/
|
|
107
|
+
interruptOn?: CreateDeepAgentParams["interruptOn"];
|
|
108
|
+
/** Agent name, passed through for tracing and display. */
|
|
109
|
+
name?: string;
|
|
110
|
+
/** Human-readable description, passed through to graph compilation. */
|
|
111
|
+
description?: string;
|
|
112
|
+
/**
|
|
113
|
+
* The governance layer: a named workflow under `workflows/<slug>/`. Omit it
|
|
114
|
+
* and the result is a plain Deep Agent — no machine, no `archmax_advance`, no
|
|
115
|
+
* per-state gating — and `agent.workflow` is `undefined`. A named workflow
|
|
116
|
+
* with no loadable spec throws {@link WorkflowLoadError} rather than silently
|
|
117
|
+
* returning an ungoverned agent.
|
|
118
|
+
*
|
|
119
|
+
* Omitted, the default workflow (`DEFAULT_WORKFLOW`) is still *looked for* on
|
|
120
|
+
* the authoring backend, and governs the agent when found. Pass `false` for an
|
|
121
|
+
* agent that is ungoverned **by declaration**: no spec is read and no rubric
|
|
122
|
+
* discovered, so a stray `workflows/` tree under the resolved root cannot
|
|
123
|
+
* govern it.
|
|
124
|
+
*/
|
|
125
|
+
workflow?: string | false;
|
|
126
|
+
/** Where files come from and where sessions go. See {@link AgentWorkspaceParams}. */
|
|
127
|
+
workspace?: AgentWorkspaceParams;
|
|
128
|
+
/**
|
|
129
|
+
* Backend serving the **authored governance plane** — machine specs,
|
|
130
|
+
* `WORKFLOW.md` prose, lifecycle hook scripts, and cases. The agent's
|
|
131
|
+
* workspace composite has no route to them. Defaults to `backend` when one is
|
|
132
|
+
* supplied, else a filesystem backend over the resolved root. Handing it to a
|
|
133
|
+
* *writable* mount fails assembly (`AuthoringPlaneExposedError`).
|
|
134
|
+
*/
|
|
135
|
+
authoring?: BackendProtocolV2;
|
|
136
|
+
/** How a session is started when a turn names no trigger. Defaults to `{ id: "manual" }`. */
|
|
137
|
+
trigger?: TriggerInput;
|
|
138
|
+
/**
|
|
139
|
+
* Variables seeded before any turn, keyed by name. Every seed is **locked**:
|
|
140
|
+
* a host-supplied fact is exactly what a `${{name}}` guard should bind to. The
|
|
141
|
+
* same seeds a delivery carries, the CLI takes (`--variables`) and a delegation
|
|
142
|
+
* hands a child — one concept, one name.
|
|
143
|
+
*/
|
|
144
|
+
variables?: Record<string, unknown>;
|
|
145
|
+
/**
|
|
146
|
+
* Where a firing's session id lives, as a dotted path over the variables
|
|
147
|
+
* (`triggers.-1.conversationId`) — the same form a `triggers` entry declares,
|
|
148
|
+
* applied to every firing this assembly resolves.
|
|
149
|
+
*/
|
|
150
|
+
sessionPath?: string;
|
|
151
|
+
/**
|
|
152
|
+
* Supplies the chat model per role (`agent`, `judge`, `subagent`) so the
|
|
153
|
+
* runtime can run against any LangChain `BaseChatModel`. When both `model`
|
|
154
|
+
* and `modelFactory` are given, `model` wins for the agent role.
|
|
155
|
+
*/
|
|
156
|
+
modelFactory?: ModelFactory;
|
|
157
|
+
/**
|
|
158
|
+
* Tool names to treat as always-on: disclosed and permitted in every state,
|
|
159
|
+
* like the file tools. A per-state `tools.allow` entry naming one still
|
|
160
|
+
* narrows it, and the safety/policy rules still bind.
|
|
161
|
+
*/
|
|
162
|
+
essentialTools?: string[];
|
|
163
|
+
/**
|
|
164
|
+
* Custom governance rules inserted after the non-overridable safety rules and
|
|
165
|
+
* the workflow `policy` rules, before the per-state `allow` defaults. A custom
|
|
166
|
+
* rule may block a call a state would permit; it cannot loosen a safety rule.
|
|
167
|
+
*/
|
|
168
|
+
policyRules?: GovernanceRule[];
|
|
169
|
+
/**
|
|
170
|
+
* Custom lifecycle hook-kind executors, registered alongside `script` and
|
|
171
|
+
* `subagent`. Registering one under a built-in kind fails assembly.
|
|
172
|
+
*/
|
|
173
|
+
hookExecutors?: Record<string, HookExecutor>;
|
|
174
|
+
/** Script-execution backend for the sandbox tools and lifecycle scripts. Defaults to QuickJS. */
|
|
175
|
+
sandboxRuntime?: SandboxRuntime;
|
|
176
|
+
/**
|
|
177
|
+
* Lifecycle event subscriber. When supplied, every runtime diagnostic is
|
|
178
|
+
* delivered here as a typed event and the runtime writes nothing to the
|
|
179
|
+
* console; when omitted, a default console subscriber renders them.
|
|
180
|
+
*/
|
|
181
|
+
onEvent?: WorkflowEventHandler;
|
|
182
|
+
/** Provider prompt caching for the stable prompt prefix (on by default, 5-minute lifetime). */
|
|
183
|
+
promptCache?: PromptCacheOptions;
|
|
184
|
+
/**
|
|
185
|
+
* Token prices in USD per 1M tokens, keyed by model id (`default` applies to
|
|
186
|
+
* any). Makes `costUsd` appear on usage events, in artifacts and in the CLI
|
|
187
|
+
* footer; without pricing, cost is omitted — never guessed.
|
|
188
|
+
*/
|
|
189
|
+
pricing?: PricingTable;
|
|
190
|
+
}
|
|
191
|
+
/** Assemble an agent. See the module note. */
|
|
192
|
+
export declare function createAgent(params?: CreateAgentParams): Promise<Agent>;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assembly: `createAgent` and its parameters.
|
|
3
|
+
*
|
|
4
|
+
* Takes Deep Agents' parameters verbatim and adds `workflow`: omit it for a
|
|
5
|
+
* plain Deep Agent, supply it and the same agent is governed by that machine.
|
|
6
|
+
* Every file the assembly reads — machine spec, system prompt, hook scripts,
|
|
7
|
+
* scripts — is served through a configured backend, never via direct `fs`, and
|
|
8
|
+
* the authored governance plane is served by a *separate* backend the agent's
|
|
9
|
+
* workspace has no route to.
|
|
10
|
+
*/
|
|
11
|
+
import { randomUUID } from "node:crypto";
|
|
12
|
+
import { mergeConfigs } from "@langchain/core/runnables";
|
|
13
|
+
import { AGENT_DEFAULT_CONFIG, ArchmaxAgent, } from "../agent.js";
|
|
14
|
+
import { consoleEventHandler, createWorkflowEventEmitter } from "../core/events.js";
|
|
15
|
+
import { DEFAULT_SKILL_SOURCES, discoverSkills, skillPrefixes } from "../core/skills.js";
|
|
16
|
+
import { createUsageTracker } from "../core/usage.js";
|
|
17
|
+
import { createWorkspaceContext } from "../core/workspace-context.js";
|
|
18
|
+
import { createChatModel, loadDotenv, loadEnv, loadPricingEnv, } from "../env.js";
|
|
19
|
+
import { loadMachineSpec, WorkflowDisabledError, WorkflowLoadError, } from "../machine/load-spec.js";
|
|
20
|
+
import { WorkflowMachine } from "../machine/machine.js";
|
|
21
|
+
import { assertNoReservedToolNames } from "../machine/tool-names.js";
|
|
22
|
+
import { DEFAULT_TRIGGER_ID, resolveTrigger } from "../machine/triggers.js";
|
|
23
|
+
import { buildSeededVariables } from "../machine/variables.js";
|
|
24
|
+
import { isRuntimeContractSupported, resolveRuntimeContract, UnsupportedRuntimeContractError, } from "../runtime/contract.js";
|
|
25
|
+
import { rubricsAsSubagents, rubricsFromSpec } from "../rubrics/rubrics.js";
|
|
26
|
+
import { createArtifactEmitter, createSessionOperations, createSpecSnapshotReader, } from "../sessions/operations.js";
|
|
27
|
+
import { resolveSession } from "../sessions/resolve.js";
|
|
28
|
+
import { decide, deliver, EmptyMessageError, outcomeOf, reply, resume, settle } from "../sessions/resume.js";
|
|
29
|
+
import { BackendCheckpointSaver } from "../workflow/checkpointer.js";
|
|
30
|
+
import { DEFAULT_WORKFLOW, workflowPaths } from "../workflow/paths.js";
|
|
31
|
+
import { createPlainTurnRunner } from "../workflow/turn-runner.js";
|
|
32
|
+
import { composeGoverned, renderSystemPrompt, sessionBinder } from "./compose.js";
|
|
33
|
+
import { createDelegationRegistry } from "./delegation-registry.js";
|
|
34
|
+
import { composePlain } from "./plain.js";
|
|
35
|
+
/** Assemble an agent. See the module note. */
|
|
36
|
+
export async function createAgent(params = {}) {
|
|
37
|
+
const workspaceParams = params.workspace ?? {};
|
|
38
|
+
loadDotenv(workspaceParams.rootDir);
|
|
39
|
+
// The namespace is a guarantee, not a convention: a host tool wearing it is
|
|
40
|
+
// refused before anything is assembled, on both paths.
|
|
41
|
+
assertNoReservedToolNames(params.tools);
|
|
42
|
+
// `false` declares the agent ungoverned: nothing is looked for. Otherwise a
|
|
43
|
+
// named workflow — or the default — is read off the authoring backend.
|
|
44
|
+
const governed = params.workflow !== false;
|
|
45
|
+
const workflowName = params.workflow === false ? "" : (params.workflow ?? DEFAULT_WORKFLOW);
|
|
46
|
+
const paths = workflowPaths(workflowName);
|
|
47
|
+
// Root resolution and backend selection (session store as the workspace root +
|
|
48
|
+
// read-only authored mounts) are the shared context's. A custom backend without a session store fails here.
|
|
49
|
+
const { backend, workspace, authoring, sessionZone, sessionStore, mountPrefixes } = createWorkspaceContext({
|
|
50
|
+
rootDir: workspaceParams.rootDir,
|
|
51
|
+
backend: params.backend,
|
|
52
|
+
...(workspaceParams.mounts ? { mounts: workspaceParams.mounts } : {}),
|
|
53
|
+
...(workspaceParams.sessionStore ? { sessionStore: workspaceParams.sessionStore } : {}),
|
|
54
|
+
...(params.authoring ? { authoring: params.authoring } : {}),
|
|
55
|
+
});
|
|
56
|
+
// Sessions are durable by default: the checkpointer writes through the
|
|
57
|
+
// session zone, so a session survives restarts and can be listed and resumed.
|
|
58
|
+
const checkpointer = params.checkpointer ?? new BackendCheckpointSaver(workspace);
|
|
59
|
+
// The usage tracker sits in the event chain so a session's totals are known
|
|
60
|
+
// where artifacts are written; every event still reaches `onEvent` (or the
|
|
61
|
+
// console).
|
|
62
|
+
const usage = createUsageTracker({ onEvent: params.onEvent ?? consoleEventHandler });
|
|
63
|
+
const emit = createWorkflowEventEmitter((event) => usage.handler(event));
|
|
64
|
+
// Load the machine spec once from workflow.yaml (the sole spec source).
|
|
65
|
+
const loaded = governed
|
|
66
|
+
? await loadMachineSpec(authoring, paths)
|
|
67
|
+
: { spec: null, issues: [], lint: [], body: "", specFile: paths.workflowYaml, usable: false };
|
|
68
|
+
for (const issue of [...loaded.issues, ...loaded.lint]) {
|
|
69
|
+
if (issue.kind !== "missing")
|
|
70
|
+
emit({ type: "warning", scope: "workflow", message: issue.message });
|
|
71
|
+
}
|
|
72
|
+
// Grading rubrics come from the spec that was just loaded — no directory to
|
|
73
|
+
// list, no file format to parse, and nothing to merge: a grader is declared on
|
|
74
|
+
// the hook that applies it, so it arrives with the machine and is scoped to it.
|
|
75
|
+
const rubrics = rubricsFromSpec(loaded.spec ?? { states: {} });
|
|
76
|
+
// Skills are discovered once; the resolved registry is the single input to
|
|
77
|
+
// what the kernel refuses, what the prompt names, and what a listing returns.
|
|
78
|
+
const skillSources = params.skills ?? [...DEFAULT_SKILL_SOURCES];
|
|
79
|
+
const skillRegistry = await discoverSkills(workspace, skillSources, emit);
|
|
80
|
+
const machine = loaded.usable && loaded.spec
|
|
81
|
+
? WorkflowMachine.fromSpec(loaded.spec, params.essentialTools)
|
|
82
|
+
: null;
|
|
83
|
+
// Fail closed when governance was requested but cannot be loaded. The plain
|
|
84
|
+
// agent remains for the unrequested-default case with no definition, and for
|
|
85
|
+
// `workflow: false`.
|
|
86
|
+
if (!machine && governed) {
|
|
87
|
+
const fileMissing = loaded.issues.some((i) => i.kind === "missing");
|
|
88
|
+
if (!fileMissing)
|
|
89
|
+
throw new WorkflowLoadError(workflowName, loaded.specFile, "no valid machine spec");
|
|
90
|
+
if (params.workflow !== undefined) {
|
|
91
|
+
throw new WorkflowLoadError(workflowName, paths.workflowYaml, "no workflow.yaml found");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Enforce the runtime contract before any model-driven work.
|
|
95
|
+
const runtimeContract = resolveRuntimeContract(machine?.spec.runtime);
|
|
96
|
+
if (machine && !isRuntimeContractSupported(runtimeContract)) {
|
|
97
|
+
throw new UnsupportedRuntimeContractError(runtimeContract);
|
|
98
|
+
}
|
|
99
|
+
// Models per role. `env` is a thunk, so `.env` variables are required only by
|
|
100
|
+
// what actually reads them: a caller supplying an explicit `model` never loads it.
|
|
101
|
+
let cachedEnv;
|
|
102
|
+
const env = () => (cachedEnv ??= loadEnv());
|
|
103
|
+
const model = params.model ?? (params.modelFactory ? params.modelFactory("agent", env) : createChatModel());
|
|
104
|
+
// The model a *state* runs on: a workflow may name an id at either position
|
|
105
|
+
// (`settings.model`, a state's `model`), resolved through the same factory seam
|
|
106
|
+
// as every other model and memoized per distinct id, so one model is built per
|
|
107
|
+
// id per assembly however many turns run on it.
|
|
108
|
+
//
|
|
109
|
+
// An explicit `model` outranks every declared id: a host that constructed an
|
|
110
|
+
// instance means it, and the SDK cannot rebuild that instance under another id
|
|
111
|
+
// without guessing at its provider. The composition says so once (see
|
|
112
|
+
// `resolveStateModels`) rather than ignoring the declaration in silence.
|
|
113
|
+
const agentModels = new Map([["", model]]);
|
|
114
|
+
const agentModel = (id) => {
|
|
115
|
+
const key = params.model !== undefined ? "" : (id ?? "");
|
|
116
|
+
let resolved = agentModels.get(key);
|
|
117
|
+
if (!resolved) {
|
|
118
|
+
resolved = params.modelFactory
|
|
119
|
+
? params.modelFactory("agent", env, key)
|
|
120
|
+
: createChatModel({ ...env(), model: key });
|
|
121
|
+
agentModels.set(key, resolved);
|
|
122
|
+
}
|
|
123
|
+
return resolved;
|
|
124
|
+
};
|
|
125
|
+
// Pricing feeds `costUsd` on usage events (host option first, then env).
|
|
126
|
+
const pricing = params.pricing ?? loadPricingEnv();
|
|
127
|
+
// The grader's model: a rubric may name its own id, resolved through the same
|
|
128
|
+
// factory seam as every other model, and memoized per distinct id so one model
|
|
129
|
+
// is built per id per assembly.
|
|
130
|
+
const rubricModels = new Map();
|
|
131
|
+
const rubricModel = (rubric) => {
|
|
132
|
+
const key = rubric.model ?? "";
|
|
133
|
+
if (!rubricModels.has(key)) {
|
|
134
|
+
rubricModels.set(key, params.modelFactory
|
|
135
|
+
? params.modelFactory("rubric", env, rubric.model)
|
|
136
|
+
: rubric.model !== undefined
|
|
137
|
+
? createChatModel({ ...env(), model: rubric.model })
|
|
138
|
+
: undefined);
|
|
139
|
+
}
|
|
140
|
+
return rubricModels.get(key);
|
|
141
|
+
};
|
|
142
|
+
const ctx = {
|
|
143
|
+
params,
|
|
144
|
+
workflowName,
|
|
145
|
+
workspace,
|
|
146
|
+
authoring,
|
|
147
|
+
backend,
|
|
148
|
+
sessionZone,
|
|
149
|
+
sessionStore,
|
|
150
|
+
mountPrefixes,
|
|
151
|
+
checkpointer,
|
|
152
|
+
emit,
|
|
153
|
+
usage,
|
|
154
|
+
model,
|
|
155
|
+
agentModel,
|
|
156
|
+
honoursDeclaredModels: params.model === undefined,
|
|
157
|
+
rubrics,
|
|
158
|
+
rubricModel,
|
|
159
|
+
subagents: rubricsAsSubagents(rubrics, rubricModel),
|
|
160
|
+
skillSources,
|
|
161
|
+
skillRegistry,
|
|
162
|
+
skillTable: skillPrefixes(skillRegistry),
|
|
163
|
+
runtimeContract,
|
|
164
|
+
...(pricing ? { pricing } : {}),
|
|
165
|
+
};
|
|
166
|
+
const systemPrompt = await renderSystemPrompt(ctx, machine, loaded.body, { workflow: workflowName });
|
|
167
|
+
if (skillRegistry.size > 0)
|
|
168
|
+
emit({ type: "skills-loaded", names: [...skillRegistry.keys()] });
|
|
169
|
+
// The session-level members every agent carries, governed or plain.
|
|
170
|
+
const members = (graph, dispose, toolMocks) => ({
|
|
171
|
+
dispose,
|
|
172
|
+
runtimeContract,
|
|
173
|
+
toolMocks,
|
|
174
|
+
emitRunArtifacts: createArtifactEmitter({ graph, machine, workspace, workflowName, runtimeContract, usage, emit }),
|
|
175
|
+
sessions: createSessionOperations({ checkpointer, sessionStore, workspace, mountPrefixes, dispose }),
|
|
176
|
+
getSpecSnapshot: createSpecSnapshotReader(workspace),
|
|
177
|
+
});
|
|
178
|
+
if (!machine) {
|
|
179
|
+
const plain = composePlain(ctx, systemPrompt);
|
|
180
|
+
// Bound like a governed session: `configurable.thread_id` names the session
|
|
181
|
+
// whose zone the agent's id-free paths resolve in.
|
|
182
|
+
const driver = createPlainTurnRunner({ graph: plain.graph, bindSession: sessionBinder(ctx) });
|
|
183
|
+
return new ArchmaxAgent({
|
|
184
|
+
graph: plain.graph,
|
|
185
|
+
members: members(plain.graph, () => { }, plain.toolMocks),
|
|
186
|
+
driver,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
const registry = createDelegationRegistry(ctx, machine);
|
|
190
|
+
const composed = await composeGoverned(ctx, {
|
|
191
|
+
machine,
|
|
192
|
+
workflow: workflowName,
|
|
193
|
+
systemPrompt,
|
|
194
|
+
...(params.trigger ? { trigger: params.trigger } : {}),
|
|
195
|
+
...(params.variables ? { variables: params.variables } : {}),
|
|
196
|
+
registry,
|
|
197
|
+
});
|
|
198
|
+
const agentMembers = members(composed.graph, composed.dispose, composed.toolMocks);
|
|
199
|
+
const { resumable, driver } = composed;
|
|
200
|
+
const workflow = {
|
|
201
|
+
name: workflowName,
|
|
202
|
+
machine,
|
|
203
|
+
resolveTrigger: (trigger) => resolveTrigger(machine, trigger),
|
|
204
|
+
decide: (sessionId, resolution) => decide(resumable, sessionId, resolution),
|
|
205
|
+
reply: (sessionId, message) => reply(resumable, sessionId, message),
|
|
206
|
+
respond: (sessionId, message) => reply(resumable, sessionId, message),
|
|
207
|
+
deliver: (sessionId, delivery) => deliver(resumable, sessionId, delivery),
|
|
208
|
+
resolveSession: (input) => resolveSession(machine, {
|
|
209
|
+
// The id *is* the address: one direct projection, no mapping step.
|
|
210
|
+
findSession: (sessionId) => agentMembers.sessions.get(sessionId),
|
|
211
|
+
mintSessionId: () => `session-${randomUUID()}`,
|
|
212
|
+
}, { ...(params.sessionPath ? { sessionPath: params.sessionPath } : {}), ...input }, (message) => emit({ type: "warning", scope: "session", message })),
|
|
213
|
+
send: async (sessionId, input, config) => {
|
|
214
|
+
if ("decision" in input)
|
|
215
|
+
return outcomeOf(await resume(resumable, sessionId, input, config), "decide");
|
|
216
|
+
if ("delivery" in input)
|
|
217
|
+
return outcomeOf(await resume(resumable, sessionId, input, config), "deliver");
|
|
218
|
+
// A turn: the session's disposition decides whether it is a fresh turn, a
|
|
219
|
+
// reply to a person's hold, or a delivery to a waiting park.
|
|
220
|
+
const turn = input;
|
|
221
|
+
const resolved = await workflow.resolveSession({
|
|
222
|
+
sessionId,
|
|
223
|
+
...(turn.trigger ? { trigger: turn.trigger } : {}),
|
|
224
|
+
...(turn.variables ? { variables: turn.variables } : {}),
|
|
225
|
+
...(turn.sessionPath ? { sessionPath: turn.sessionPath } : {}),
|
|
226
|
+
});
|
|
227
|
+
if (resolved.disposition === "reply") {
|
|
228
|
+
return outcomeOf(await resume(resumable, sessionId, { message: turn.message }, config), "reply");
|
|
229
|
+
}
|
|
230
|
+
if (resolved.disposition === "resume") {
|
|
231
|
+
// The person's message travels with the firing rather than being dropped.
|
|
232
|
+
const delivery = {
|
|
233
|
+
trigger: turn.trigger ?? { id: DEFAULT_TRIGGER_ID },
|
|
234
|
+
...(turn.variables ? { variables: turn.variables } : {}),
|
|
235
|
+
...(turn.message?.trim() ? { message: turn.message } : {}),
|
|
236
|
+
};
|
|
237
|
+
return outcomeOf(await resume(resumable, sessionId, { delivery }, config), "deliver");
|
|
238
|
+
}
|
|
239
|
+
if (machine.disabled)
|
|
240
|
+
throw new WorkflowDisabledError(workflowName);
|
|
241
|
+
const message = (turn.message ?? "").trim();
|
|
242
|
+
if (!message)
|
|
243
|
+
throw new EmptyMessageError(sessionId);
|
|
244
|
+
const trigger = { id: resolveTrigger(machine, turn.trigger).id };
|
|
245
|
+
const turnConfig = mergeConfigs(AGENT_DEFAULT_CONFIG, config, {
|
|
246
|
+
configurable: { thread_id: sessionId },
|
|
247
|
+
});
|
|
248
|
+
const result = await driver.invoke({
|
|
249
|
+
messages: [{ role: "user", content: message }],
|
|
250
|
+
trigger,
|
|
251
|
+
// Seeded per turn, locked, like a delivery's seeds; the channel's
|
|
252
|
+
// merge keeps the first lock, so a later seed cannot overwrite it.
|
|
253
|
+
...(turn.variables ? { variables: buildSeededVariables(turn.variables) } : {}),
|
|
254
|
+
}, turnConfig);
|
|
255
|
+
return outcomeOf(settle(result, sessionId), "turn");
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
return new ArchmaxAgent({
|
|
259
|
+
graph: composed.graph,
|
|
260
|
+
members: agentMembers,
|
|
261
|
+
driver,
|
|
262
|
+
workflow,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/assembly/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAuB,MAAM,2BAA2B,CAAC;AAK9E,OAAO,EACL,oBAAoB,EACpB,YAAY,GAKb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAA6B,MAAM,mBAAmB,CAAC;AAG/G,OAAO,EAAE,qBAAqB,EAAE,c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MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAChC;gBACE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;gBAC9C,OAAO;gBACP,kEAAkE;gBAClE,mEAAmE;gBACnE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC/E,EACD,UAAU,CACX,CAAC;YACF,OAAO,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;KACF,CAAC;IAEF,OAAO,IAAI,YAAY,CAAC;QACtB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,OAAO,EAAE,YAAY;QACrB,MAAM;QACN,QAAQ;KACT,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type CompiledAgentGraph } from "../core/deepagents.js";
|
|
2
|
+
import { type AssemblyContext } from "./compose.js";
|
|
3
|
+
/** Compose the plain agent: its graph, and whether the host's tool-mock middleware is among its middleware. */
|
|
4
|
+
export declare function composePlain(ctx: AssemblyContext, systemPrompt: string): {
|
|
5
|
+
graph: CompiledAgentGraph;
|
|
6
|
+
toolMocks: boolean;
|
|
7
|
+
};
|