@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Archmax AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# archmax harness
|
|
2
|
+
|
|
3
|
+
**A thin, governed layer over [LangChain Deep
|
|
4
|
+
Agents](https://docs.langchain.com/oss/javascript/deepagents/overview). Every session runs
|
|
5
|
+
under a declarative workflow state machine you author in one YAML file.**
|
|
6
|
+
|
|
7
|
+
The archmax harness is Node/TypeScript and ESM. It assembles one Deep Agent per workflow, serves that agent's
|
|
8
|
+
workspace through a Deep Agents backend, and enforces `workflows/<slug>/workflow.yaml` with
|
|
9
|
+
middleware and a pure decision kernel.
|
|
10
|
+
|
|
11
|
+
The runtime holds no use-case logic. Everything specific to your agent lives as files in your
|
|
12
|
+
workspace: persona, states, tool permissions, hooks, skill bundles, data.
|
|
13
|
+
|
|
14
|
+
- **One file is the source of truth.** `workflow.yaml` is the enforced machine: states,
|
|
15
|
+
transitions, per-state tool governance, lifecycle hooks, budgets, error routing, triggers.
|
|
16
|
+
What the model reads is rendered from the spec, so prose cannot drift from enforcement.
|
|
17
|
+
- **Closed by default, including the graph.** The agent sees the active state's tool surface and
|
|
18
|
+
its outgoing edges. Another state's slug, instructions, transitions and even the state count
|
|
19
|
+
stay out of the prompt. So the cached prefix does not grow with the graph, and a prompt
|
|
20
|
+
injection has no map to steer with.
|
|
21
|
+
- **Enforced by the kernel.** The agent moves only by calling `archmax_advance`. The workflow's
|
|
22
|
+
and the state's `allow`/`forbid` lists cover tools, skills and mounts alike, with deny beating
|
|
23
|
+
allow. The kernel applies them to every call, including the calls a sandboxed script makes.
|
|
24
|
+
Hooks return `ok`, `correct` or `veto`, and they fail closed.
|
|
25
|
+
- **Human-in-the-loop, natively.** A `type: human` state parks the session on a durable
|
|
26
|
+
checkpoint. A person picks the outgoing transition, and the session resumes where it stopped.
|
|
27
|
+
- **Backend-driven and durable.** Specs, prompts, skills and sessions all flow through Deep
|
|
28
|
+
Agents backends: filesystem, store, or remote. Every session is a resumable, inspectable
|
|
29
|
+
folder in a session store you choose.
|
|
30
|
+
|
|
31
|
+
## Why archmax harness
|
|
32
|
+
|
|
33
|
+
Reliable automation with AI agents should follow the process, and the people who own that
|
|
34
|
+
process should be able to author it. Today that is out of reach for most domain experts.
|
|
35
|
+
Current automation tools fall short in three ways.
|
|
36
|
+
|
|
37
|
+
- **The agent is a step, not the process.** The agent sits inside a fixed graph, so its
|
|
38
|
+
flexibility ends at the edge of one node. The process stays as rigid as the diagram someone
|
|
39
|
+
drew.
|
|
40
|
+
- **The process and its implementation drift apart.** Every business process is restated as a
|
|
41
|
+
technical graph. That makes two artifacts with two owners, and keeping them in step never
|
|
42
|
+
stops costing effort.
|
|
43
|
+
- **Complex data still ends up in code.** Nested payloads, loops and arithmetic land in a code
|
|
44
|
+
node. The person who owns the process cannot read it, let alone change it.
|
|
45
|
+
|
|
46
|
+
The archmax harness turns this around. The agent runs the whole process, and one `workflow.yaml` both
|
|
47
|
+
describes it and enforces it. Data work happens in a sandbox the same rules govern.
|
|
48
|
+
|
|
49
|
+
**Full documentation: <https://archmax-ai.github.io/harness/>**
|
|
50
|
+
|
|
51
|
+
## Install
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install @archmax-ai/harness
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Node 22 or later. The model is configured through the environment, against any OpenAI-compatible
|
|
58
|
+
endpoint. The archmax harness reads those keys from a `.env` in the workspace root:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
ARCHMAX_API_BASE_URL=https://api.example.com/v1
|
|
62
|
+
ARCHMAX_API_KEY=...
|
|
63
|
+
ARCHMAX_MODEL=...
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`ARCHMAX_MODEL` is the default. A workflow names the id its states run on with `settings.model`,
|
|
67
|
+
and a single state overrides that with its own `model:`. Either way it is an id, resolved over
|
|
68
|
+
the same endpoint and credentials. So a mechanical state can run on a small model while the state
|
|
69
|
+
whose output a person reads runs on a capable one.
|
|
70
|
+
|
|
71
|
+
See [configuration](https://archmax-ai.github.io/harness/reference/configuration/) for
|
|
72
|
+
every variable.
|
|
73
|
+
|
|
74
|
+
## Quickstart
|
|
75
|
+
|
|
76
|
+
### A workspace
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
my-workspace/
|
|
80
|
+
├── AGENTS.md # persona
|
|
81
|
+
├── workflows/order-lookup/
|
|
82
|
+
│ ├── workflow.yaml # the enforced state machine, and its grading rubrics
|
|
83
|
+
│ ├── WORKFLOW.md # optional prose addendum
|
|
84
|
+
│ ├── hooks/check-requester.js # lifecycle hook scripts
|
|
85
|
+
│ └── tests/*.test.yaml # cases for `archmax test`
|
|
86
|
+
├── skills/<slug>/ # skill bundles: SKILL.md, assets/, scripts/
|
|
87
|
+
└── sessions/ # default session store (gitignored)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```yaml
|
|
91
|
+
# workflows/order-lookup/workflow.yaml (excerpt)
|
|
92
|
+
title: Order lookup
|
|
93
|
+
instructions: Only ever disclose the requester's own company's orders.
|
|
94
|
+
tools: { forbid_always: [archmax_reset] } # denied in every state; deny beats allow
|
|
95
|
+
skills: { allow_always: [order-data] } # enabled in every state; a state's own
|
|
96
|
+
# `skills.allow` adds, `skills.forbid` subtracts
|
|
97
|
+
mounts: { allow_always: [reference] } # which STATES reach a host-governed mount;
|
|
98
|
+
# a grant may say `access: read` or `read_write`
|
|
99
|
+
|
|
100
|
+
states:
|
|
101
|
+
identify-case:
|
|
102
|
+
triggers:
|
|
103
|
+
manual:
|
|
104
|
+
instructions: Classify the request and archmax_advance to the matching path.
|
|
105
|
+
before: { script: hooks/check-requester.js }
|
|
106
|
+
transitions: # a description is REQUIRED on every edge: the
|
|
107
|
+
# agent is shown this state's edges and nothing
|
|
108
|
+
# else of the graph, so it is all it routes on
|
|
109
|
+
- to: orders-question
|
|
110
|
+
description: The user is asking about orders, status, shipping, or tracking.
|
|
111
|
+
orders-question: # no transitions: terminal
|
|
112
|
+
instructions: Answer from skills/order-data/assets/orders.json.
|
|
113
|
+
# no skills block: the workflow's grant reaches
|
|
114
|
+
# here, and enabling a bundle is the whole grant
|
|
115
|
+
# The standard this state's exit is graded against, declared where it applies.
|
|
116
|
+
# On the authoring plane, so the agent being graded can neither read it nor
|
|
117
|
+
# call it.
|
|
118
|
+
after:
|
|
119
|
+
- rubric:
|
|
120
|
+
max_iterations: 2 # how many times a `correct` may send the agent back
|
|
121
|
+
instructions: Judge the tone of the reply. Return ok, correct or veto with a reason.
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`examples/customer-support/` in this repository is a complete reference workspace.
|
|
125
|
+
|
|
126
|
+
### The CLI
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npx archmax run order-lookup "Which orders are delayed for Acme?" --root ./my-workspace
|
|
130
|
+
npx archmax test order-lookup --root ./my-workspace # run the workflow's cases
|
|
131
|
+
npx archmax validate order-lookup --root ./my-workspace # static checks, no model calls
|
|
132
|
+
npx archmax sessions --root ./my-workspace # list durable sessions
|
|
133
|
+
npx archmax decide <session> --to approved # resume a session parked at a human state
|
|
134
|
+
npx archmax reply <session> "Any update?" # answer a parked session; it stays parked
|
|
135
|
+
npx archmax deliver <session> --trigger email_reply # resume a session parked with archmax_wait
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Results go to stdout and the state flow to stderr. Exit 0 means done or parked, 1 a failure, 2 a
|
|
139
|
+
usage error. See the [CLI reference](https://archmax-ai.github.io/harness/reference/cli/).
|
|
140
|
+
|
|
141
|
+
### The library
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import { createAgent } from "@archmax-ai/harness";
|
|
145
|
+
|
|
146
|
+
const agent = await createAgent({
|
|
147
|
+
workflow: "order-lookup",
|
|
148
|
+
workspace: { rootDir: "./my-workspace" },
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// A turn, a decision, a reply or a delivery: one call, one Outcome.
|
|
152
|
+
const outcome = await agent.workflow!.send("session-42", {
|
|
153
|
+
message: "Which orders are delayed for Acme?",
|
|
154
|
+
});
|
|
155
|
+
console.log(outcome.kind, outcome.state, outcome.reply); // "parked" "refund-review" "..."
|
|
156
|
+
|
|
157
|
+
if (outcome.kind === "parked" && outcome.parkedChannel === "decision") {
|
|
158
|
+
await agent.workflow!.decide("session-42", { target: "approved", comment: "Within policy." });
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Omit `workflow` for a plain Deep Agent with the same parameters, or pass `workflow: false` to
|
|
163
|
+
declare an agent ungoverned. `onEvent` receives the typed event stream and
|
|
164
|
+
`workspace.sessionStore` puts sessions elsewhere. `workspace.mounts` composes what the agent can
|
|
165
|
+
see, and marking a mount `governed: true` hands the spec's `mounts` block the decision of which
|
|
166
|
+
states reach it. Marking one `searchable: false` keeps root-wide searches away from a backend
|
|
167
|
+
that must refuse them.
|
|
168
|
+
|
|
169
|
+
Five subpaths keep production imports small:
|
|
170
|
+
|
|
171
|
+
- `@archmax-ai/harness/sandbox`: hook authoring types
|
|
172
|
+
- `@archmax-ai/harness/testing`: the case engine
|
|
173
|
+
- `@archmax-ai/harness/cli`: the state-flow renderer
|
|
174
|
+
- `@archmax-ai/harness/spec`: the `workflow.yaml` schema, the pure validator and the grammars
|
|
175
|
+
- `@archmax-ai/harness/messages`: transcript readers
|
|
176
|
+
|
|
177
|
+
The last two are browser-safe, with no runtime behind them. See the
|
|
178
|
+
[public API reference](https://archmax-ai.github.io/harness/reference/public-api/).
|
|
179
|
+
|
|
180
|
+
### Authoring with a coding agent
|
|
181
|
+
|
|
182
|
+
The package ships an authoring skill at `dist/authoring-skill/archmax-harness/`. It teaches a coding agent
|
|
183
|
+
the schema, the hook contract, governance, human states, cases and the CLI. The
|
|
184
|
+
`BUNDLED_AUTHORING_SKILL_DIR` export resolves to its parent directory, and the source is
|
|
185
|
+
`skills/archmax-harness/`.
|
|
186
|
+
|
|
187
|
+
## Documentation
|
|
188
|
+
|
|
189
|
+
- [Quickstart](https://archmax-ai.github.io/harness/getting-started/quickstart/) and
|
|
190
|
+
[installation](https://archmax-ai.github.io/harness/getting-started/installation/)
|
|
191
|
+
- Guides: [the workflow machine](https://archmax-ai.github.io/harness/guides/workflow-machine/),
|
|
192
|
+
[sessions](https://archmax-ai.github.io/harness/guides/sessions/),
|
|
193
|
+
[triggers](https://archmax-ai.github.io/harness/guides/triggers/),
|
|
194
|
+
[skills](https://archmax-ai.github.io/harness/guides/skills/),
|
|
195
|
+
[sub-workflows](https://archmax-ai.github.io/harness/guides/sub-workflows/),
|
|
196
|
+
[testing](https://archmax-ai.github.io/harness/guides/testing/),
|
|
197
|
+
[token efficiency](https://archmax-ai.github.io/harness/guides/token-efficiency/)
|
|
198
|
+
- Reference: [machine spec](https://archmax-ai.github.io/harness/reference/machine-spec/),
|
|
199
|
+
[CLI](https://archmax-ai.github.io/harness/reference/cli/),
|
|
200
|
+
[public API](https://archmax-ai.github.io/harness/reference/public-api/),
|
|
201
|
+
[glossary](https://archmax-ai.github.io/harness/reference/glossary/),
|
|
202
|
+
[changelog](https://archmax-ai.github.io/harness/reference/changelog/)
|
|
203
|
+
|
|
204
|
+
## Development
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
npm run dev -- run order-lookup "..." --root examples/customer-support
|
|
208
|
+
npm run typecheck && npm test
|
|
209
|
+
npm run docs:dev
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Substantive changes flow through [OpenSpec](https://github.com/Fission-AI/OpenSpec) under
|
|
213
|
+
`openspec/`. Documentation, `README.md` and the authoring skill ship in the same change as the
|
|
214
|
+
behaviour they describe. See [CONTRIBUTING.md](CONTRIBUTING.md) and the
|
|
215
|
+
[development setup](https://archmax-ai.github.io/harness/contributing/development/).
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
MIT. See [LICENSE](LICENSE).
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { type RunnableConfig } from "@langchain/core/runnables";
|
|
2
|
+
import type { BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
3
|
+
import type { Graph } from "@langchain/core/runnables/graph";
|
|
4
|
+
import { type AgentInput, type AgentResult, type AgentStreamOptions, type CompiledAgentGraph } from "./core/deepagents.js";
|
|
5
|
+
import type { WorkflowMachine } from "./machine/machine.js";
|
|
6
|
+
import type { MachineSpec } from "./machine/types.js";
|
|
7
|
+
import type { ResolvedTrigger, TriggerInput } from "./machine/triggers.js";
|
|
8
|
+
import type { ResolvedRuntimeContract } from "./runtime/contract.js";
|
|
9
|
+
import type { EmitRunArtifacts, SessionOperations } from "./sessions/operations.js";
|
|
10
|
+
import type { ResolvedSession, ResolveSessionInput } from "./sessions/resolve.js";
|
|
11
|
+
import type { DecideOutcome, DecisionResolution, DeliverOutcome, Outcome, ReplyOutcome, ResumePayload, TriggerDelivery } from "./sessions/resume.js";
|
|
12
|
+
import type { TurnRunner } from "./workflow/turn-runner.js";
|
|
13
|
+
/**
|
|
14
|
+
* The default config an assembled agent carries: the integration metadata
|
|
15
|
+
* tracing backends key off, and the recursion limit a turn runs under when the
|
|
16
|
+
* caller names none. One invoke is one whole turn across states — every hook,
|
|
17
|
+
* model call and tool batch is a super-step — so the limit is generous by
|
|
18
|
+
* design: the authored budgets (`budget.maxTurns`, `maxParks`) are the real
|
|
19
|
+
* bound, and this only stops a turn nothing else bounds.
|
|
20
|
+
*/
|
|
21
|
+
export declare const AGENT_DEFAULT_CONFIG: RunnableConfig;
|
|
22
|
+
/**
|
|
23
|
+
* A turn's input to {@link WorkflowSurface.send}: what the person said, and —
|
|
24
|
+
* for a session's opening turn — how it is started and what it is seeded with.
|
|
25
|
+
* On a session parked at a human state the message is answered without moving
|
|
26
|
+
* it; on a session parked with `archmax_wait` the trigger and variables are
|
|
27
|
+
* delivered into it.
|
|
28
|
+
*/
|
|
29
|
+
export interface TurnInput {
|
|
30
|
+
/** What the person said. */
|
|
31
|
+
message: string;
|
|
32
|
+
/** How the session is started; defaults to `manual`. */
|
|
33
|
+
trigger?: TriggerInput;
|
|
34
|
+
/** Variables seeded for this turn, locked — the same seeds a delivery carries. */
|
|
35
|
+
variables?: Record<string, unknown>;
|
|
36
|
+
/** Where a firing's session id lives, overriding the trigger's declaration. */
|
|
37
|
+
sessionPath?: string;
|
|
38
|
+
}
|
|
39
|
+
/** What {@link WorkflowSurface.send} takes: a turn, or one of the three resumes. */
|
|
40
|
+
export type SendInput = TurnInput | ResumePayload;
|
|
41
|
+
/**
|
|
42
|
+
* The governance surface of a governed assembly, reached at `agent.workflow`.
|
|
43
|
+
*
|
|
44
|
+
* Carries only what is meaningless without a machine. Everything that describes
|
|
45
|
+
* *the session* — `sessions`, artifacts, spec snapshots, disposal — is on the
|
|
46
|
+
* agent itself, because an ungoverned assembly has those too. `undefined` on a
|
|
47
|
+
* plain assembly, so TypeScript makes the caller handle that.
|
|
48
|
+
*/
|
|
49
|
+
export interface WorkflowSurface {
|
|
50
|
+
/** Workflow slug this agent was assembled for. */
|
|
51
|
+
name: string;
|
|
52
|
+
/** The compiled machine backing this agent's workflow. */
|
|
53
|
+
machine: WorkflowMachine;
|
|
54
|
+
/** Map a trigger id to the start state it enters; throws `UnknownTriggerError`. */
|
|
55
|
+
resolveTrigger(trigger?: TriggerInput): ResolvedTrigger;
|
|
56
|
+
/** Resume a session parked at a human state with the person's decision. */
|
|
57
|
+
decide(sessionId: string, resolution: DecisionResolution): Promise<DecideOutcome>;
|
|
58
|
+
/** Reply to a session parked at a human state and get its answer; it stays parked. */
|
|
59
|
+
reply(sessionId: string, message: string): Promise<ReplyOutcome>;
|
|
60
|
+
/** @deprecated Older spelling of {@link reply}; kept for one release. */
|
|
61
|
+
respond(sessionId: string, message: string): Promise<ReplyOutcome>;
|
|
62
|
+
/** Resume a session parked with `archmax_wait` with a delivered firing. */
|
|
63
|
+
deliver(sessionId: string, delivery: TriggerDelivery): Promise<DeliverOutcome>;
|
|
64
|
+
/** Map a firing to the session it belongs to and the disposition it takes — without invoking. */
|
|
65
|
+
resolveSession(input: ResolveSessionInput): Promise<ResolvedSession>;
|
|
66
|
+
/**
|
|
67
|
+
* The one operation a host or the CLI needs: enter `sessionId` with a turn or
|
|
68
|
+
* a resume and get one {@link Outcome} back. A turn is resolved first — a new
|
|
69
|
+
* or finished session takes it as its next turn, a session parked at a human
|
|
70
|
+
* state has it answered as a reply, a session parked with `archmax_wait` has
|
|
71
|
+
* its trigger and variables delivered. `config` merges into the invoke config
|
|
72
|
+
* (a tool-mock declaration, a recursion limit).
|
|
73
|
+
*/
|
|
74
|
+
send(sessionId: string, input: SendInput, config?: RunnableConfig): Promise<Outcome>;
|
|
75
|
+
}
|
|
76
|
+
/** The session-level members every assembled agent carries, governed or plain. */
|
|
77
|
+
export interface AgentMembers {
|
|
78
|
+
/** Release every per-session resource held for `sessionId`. Idempotent. */
|
|
79
|
+
dispose(sessionId: string): void;
|
|
80
|
+
/** Runtime contract resolved (and enforced) for this agent. */
|
|
81
|
+
runtimeContract: ResolvedRuntimeContract;
|
|
82
|
+
/**
|
|
83
|
+
* Whether tool mocks declared for a session (`configurable.__toolMocks`, the
|
|
84
|
+
* case engine's `mocks:` channel) intercept **agent-initiated** tool calls —
|
|
85
|
+
* true when the tool-mock middleware is wired. Scripts' PTC calls are always
|
|
86
|
+
* intercepted; without this, interception would be partial, which is why the
|
|
87
|
+
* case engine refuses mock-declaring cases against an agent that lacks it.
|
|
88
|
+
*/
|
|
89
|
+
toolMocks: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Persist the session's graph snapshot, the supplied trajectory and (when
|
|
92
|
+
* governed) its trail, variables and usage under `<sessionId>/artifacts/`.
|
|
93
|
+
* Best-effort: the artifacts directory, or `null` if writing failed.
|
|
94
|
+
*/
|
|
95
|
+
emitRunArtifacts: EmitRunArtifacts;
|
|
96
|
+
/** Session handles over the configured session store. */
|
|
97
|
+
sessions: SessionOperations;
|
|
98
|
+
/** Resolve a machine spec persisted to the snapshot store by its `specHash`. */
|
|
99
|
+
getSpecSnapshot(hash: string): Promise<MachineSpec | null>;
|
|
100
|
+
}
|
|
101
|
+
/** @deprecated The members now live on {@link ArchmaxAgent} directly; use `Agent`. */
|
|
102
|
+
export type AgentRunSurface = AgentMembers;
|
|
103
|
+
/**
|
|
104
|
+
* An assembled agent: a wrapper over the compiled Deep Agent graph.
|
|
105
|
+
*
|
|
106
|
+
* This is the shape `createDeepAgent` returns — a thin delegating object holding
|
|
107
|
+
* the compiled graph — mirrored for two reasons. Familiarity: a consumer who
|
|
108
|
+
* knows `createDeepAgent` gets `invoke`/`stream`/`streamEvents`/`graph` where
|
|
109
|
+
* they expect them. Correctness: a compiled graph's `withConfig()` returns a
|
|
110
|
+
* **new** graph, so a governance namespace attached to a graph object would be
|
|
111
|
+
* dropped the first time anyone reconfigured it; {@link ArchmaxAgent.withConfig}
|
|
112
|
+
* rebuilds the wrapper, so `.workflow` survives.
|
|
113
|
+
*
|
|
114
|
+
* Every agent's `invoke`, `stream` and `streamEvents` go through a turn runner
|
|
115
|
+
* that binds the session zone and event context around the call, from
|
|
116
|
+
* `configurable.thread_id`. A governed agent's runner also streams the model's
|
|
117
|
+
* text as `agent-text-delta` events and settles parks; a plain agent's runner
|
|
118
|
+
* drives the graph as-is, bound.
|
|
119
|
+
*/
|
|
120
|
+
export declare class ArchmaxAgent implements AgentMembers {
|
|
121
|
+
#private;
|
|
122
|
+
readonly dispose: (sessionId: string) => void;
|
|
123
|
+
readonly runtimeContract: ResolvedRuntimeContract;
|
|
124
|
+
readonly toolMocks: boolean;
|
|
125
|
+
readonly emitRunArtifacts: EmitRunArtifacts;
|
|
126
|
+
readonly sessions: SessionOperations;
|
|
127
|
+
readonly getSpecSnapshot: (hash: string) => Promise<MachineSpec | null>;
|
|
128
|
+
/**
|
|
129
|
+
* Governance for this assembly, or `undefined` when no `workflow` was
|
|
130
|
+
* supplied. Carries only what is meaningless without a machine.
|
|
131
|
+
*/
|
|
132
|
+
readonly workflow: WorkflowSurface | undefined;
|
|
133
|
+
constructor(opts: {
|
|
134
|
+
graph: unknown;
|
|
135
|
+
members: AgentMembers;
|
|
136
|
+
workflow?: WorkflowSurface | undefined;
|
|
137
|
+
config?: RunnableConfig;
|
|
138
|
+
/** The session-bound turn runner the assembly drives its graph through. */
|
|
139
|
+
driver?: TurnRunner;
|
|
140
|
+
});
|
|
141
|
+
/** The compiled `CompiledStateGraph` — a real Pregel, for LangGraph-native use. */
|
|
142
|
+
get graph(): CompiledAgentGraph;
|
|
143
|
+
/** The checkpointer the graph was compiled with. */
|
|
144
|
+
get checkpointer(): BaseCheckpointSaver | boolean | undefined;
|
|
145
|
+
/** The LangGraph store the graph was compiled with, when one was supplied. */
|
|
146
|
+
get store(): BaseStore | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* A new agent of the same kind with `config` merged into its defaults.
|
|
149
|
+
* Returns a wrapper, never a bare graph: `.workflow` and the session-level
|
|
150
|
+
* members must survive reconfiguration.
|
|
151
|
+
*/
|
|
152
|
+
withConfig(config: RunnableConfig): ArchmaxAgent;
|
|
153
|
+
/** Drive one turn to a settled result. */
|
|
154
|
+
invoke(input: AgentInput, config?: RunnableConfig): Promise<AgentResult>;
|
|
155
|
+
/** Stream one turn's execution. */
|
|
156
|
+
stream(input: AgentInput, options?: AgentStreamOptions): Promise<AsyncIterable<unknown>>;
|
|
157
|
+
/** Stream the framework's own event feed. */
|
|
158
|
+
streamEvents(input: AgentInput, config: RunnableConfig, options?: unknown): AsyncIterable<unknown>;
|
|
159
|
+
getState(config: RunnableConfig, options?: unknown): Promise<unknown>;
|
|
160
|
+
getStateHistory(config: RunnableConfig, options?: unknown): AsyncIterableIterator<unknown>;
|
|
161
|
+
updateState(config: RunnableConfig, values: unknown, asNode?: string): Promise<RunnableConfig>;
|
|
162
|
+
getSubgraphs(namespace?: string, recurse?: boolean): Generator<[string, unknown]>;
|
|
163
|
+
getSubgraphsAsync(namespace?: string, recurse?: boolean): AsyncGenerator<[string, unknown]>;
|
|
164
|
+
getGraphAsync(config?: RunnableConfig): Promise<Graph>;
|
|
165
|
+
}
|
|
166
|
+
/** An assembled agent. See {@link ArchmaxAgent}. */
|
|
167
|
+
export type Agent = ArchmaxAgent;
|
|
168
|
+
/**
|
|
169
|
+
* @deprecated Narrow on `agent.workflow` instead; kept for one release. An
|
|
170
|
+
* {@link Agent} known to be governed: `workflow` is present.
|
|
171
|
+
*/
|
|
172
|
+
export type GovernedAgent = Agent & {
|
|
173
|
+
workflow: WorkflowSurface;
|
|
174
|
+
};
|
package/dist/agent.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { mergeConfigs } from "@langchain/core/runnables";
|
|
2
|
+
import { asCompiledAgentGraph, DEFAULT_RECURSION_LIMIT, } from "./core/deepagents.js";
|
|
3
|
+
/**
|
|
4
|
+
* The default config an assembled agent carries: the integration metadata
|
|
5
|
+
* tracing backends key off, and the recursion limit a turn runs under when the
|
|
6
|
+
* caller names none. One invoke is one whole turn across states — every hook,
|
|
7
|
+
* model call and tool batch is a super-step — so the limit is generous by
|
|
8
|
+
* design: the authored budgets (`budget.maxTurns`, `maxParks`) are the real
|
|
9
|
+
* bound, and this only stops a turn nothing else bounds.
|
|
10
|
+
*/
|
|
11
|
+
export const AGENT_DEFAULT_CONFIG = {
|
|
12
|
+
metadata: { ls_integration: "archmax-harness" },
|
|
13
|
+
recursionLimit: DEFAULT_RECURSION_LIMIT,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* An assembled agent: a wrapper over the compiled Deep Agent graph.
|
|
17
|
+
*
|
|
18
|
+
* This is the shape `createDeepAgent` returns — a thin delegating object holding
|
|
19
|
+
* the compiled graph — mirrored for two reasons. Familiarity: a consumer who
|
|
20
|
+
* knows `createDeepAgent` gets `invoke`/`stream`/`streamEvents`/`graph` where
|
|
21
|
+
* they expect them. Correctness: a compiled graph's `withConfig()` returns a
|
|
22
|
+
* **new** graph, so a governance namespace attached to a graph object would be
|
|
23
|
+
* dropped the first time anyone reconfigured it; {@link ArchmaxAgent.withConfig}
|
|
24
|
+
* rebuilds the wrapper, so `.workflow` survives.
|
|
25
|
+
*
|
|
26
|
+
* Every agent's `invoke`, `stream` and `streamEvents` go through a turn runner
|
|
27
|
+
* that binds the session zone and event context around the call, from
|
|
28
|
+
* `configurable.thread_id`. A governed agent's runner also streams the model's
|
|
29
|
+
* text as `agent-text-delta` events and settles parks; a plain agent's runner
|
|
30
|
+
* drives the graph as-is, bound.
|
|
31
|
+
*/
|
|
32
|
+
export class ArchmaxAgent {
|
|
33
|
+
#graph;
|
|
34
|
+
#config;
|
|
35
|
+
#members;
|
|
36
|
+
#driver;
|
|
37
|
+
dispose;
|
|
38
|
+
runtimeContract;
|
|
39
|
+
toolMocks;
|
|
40
|
+
emitRunArtifacts;
|
|
41
|
+
sessions;
|
|
42
|
+
getSpecSnapshot;
|
|
43
|
+
/**
|
|
44
|
+
* Governance for this assembly, or `undefined` when no `workflow` was
|
|
45
|
+
* supplied. Carries only what is meaningless without a machine.
|
|
46
|
+
*/
|
|
47
|
+
workflow;
|
|
48
|
+
constructor(opts) {
|
|
49
|
+
this.#graph = asCompiledAgentGraph(opts.graph);
|
|
50
|
+
this.#members = opts.members;
|
|
51
|
+
this.#config = mergeConfigs(AGENT_DEFAULT_CONFIG, opts.config);
|
|
52
|
+
this.#driver = opts.driver;
|
|
53
|
+
this.workflow = opts.workflow;
|
|
54
|
+
this.dispose = opts.members.dispose;
|
|
55
|
+
this.runtimeContract = opts.members.runtimeContract;
|
|
56
|
+
this.toolMocks = opts.members.toolMocks;
|
|
57
|
+
this.emitRunArtifacts = opts.members.emitRunArtifacts;
|
|
58
|
+
this.sessions = opts.members.sessions;
|
|
59
|
+
this.getSpecSnapshot = opts.members.getSpecSnapshot;
|
|
60
|
+
// Bound so the agent survives destructuring — `const { invoke } = agent` is
|
|
61
|
+
// how a caller naturally reaches for one method.
|
|
62
|
+
this.invoke = this.invoke.bind(this);
|
|
63
|
+
this.stream = this.stream.bind(this);
|
|
64
|
+
this.streamEvents = this.streamEvents.bind(this);
|
|
65
|
+
this.withConfig = this.withConfig.bind(this);
|
|
66
|
+
this.getState = this.getState.bind(this);
|
|
67
|
+
this.getStateHistory = this.getStateHistory.bind(this);
|
|
68
|
+
this.updateState = this.updateState.bind(this);
|
|
69
|
+
this.getSubgraphs = this.getSubgraphs.bind(this);
|
|
70
|
+
this.getSubgraphsAsync = this.getSubgraphsAsync.bind(this);
|
|
71
|
+
this.getGraphAsync = this.getGraphAsync.bind(this);
|
|
72
|
+
}
|
|
73
|
+
/** The compiled `CompiledStateGraph` — a real Pregel, for LangGraph-native use. */
|
|
74
|
+
get graph() {
|
|
75
|
+
return this.#graph;
|
|
76
|
+
}
|
|
77
|
+
/** The checkpointer the graph was compiled with. */
|
|
78
|
+
get checkpointer() {
|
|
79
|
+
return this.#graph.checkpointer;
|
|
80
|
+
}
|
|
81
|
+
/** The LangGraph store the graph was compiled with, when one was supplied. */
|
|
82
|
+
get store() {
|
|
83
|
+
return this.#graph.store;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A new agent of the same kind with `config` merged into its defaults.
|
|
87
|
+
* Returns a wrapper, never a bare graph: `.workflow` and the session-level
|
|
88
|
+
* members must survive reconfiguration.
|
|
89
|
+
*/
|
|
90
|
+
withConfig(config) {
|
|
91
|
+
return new ArchmaxAgent({
|
|
92
|
+
graph: this.#graph,
|
|
93
|
+
members: this.#members,
|
|
94
|
+
workflow: this.workflow,
|
|
95
|
+
config: mergeConfigs(this.#config, config),
|
|
96
|
+
...(this.#driver ? { driver: this.#driver } : {}),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/** Drive one turn to a settled result. */
|
|
100
|
+
invoke(input, config) {
|
|
101
|
+
const merged = mergeConfigs(this.#config, config);
|
|
102
|
+
if (this.#driver)
|
|
103
|
+
return this.#driver.invoke(input, merged);
|
|
104
|
+
return this.#graph.invoke(input, merged);
|
|
105
|
+
}
|
|
106
|
+
/** Stream one turn's execution. */
|
|
107
|
+
async stream(input, options) {
|
|
108
|
+
const merged = mergeConfigs(this.#config, options);
|
|
109
|
+
if (this.#driver)
|
|
110
|
+
return this.#driver.stream(input, merged);
|
|
111
|
+
return this.#graph.stream(input, merged);
|
|
112
|
+
}
|
|
113
|
+
/** Stream the framework's own event feed. */
|
|
114
|
+
streamEvents(input, config, options) {
|
|
115
|
+
const merged = mergeConfigs(this.#config, config);
|
|
116
|
+
if (this.#driver)
|
|
117
|
+
return this.#driver.streamEvents(input, merged, options);
|
|
118
|
+
return this.#graph.streamEvents(input, merged, options);
|
|
119
|
+
}
|
|
120
|
+
// --- Checkpoint surface, delegated to the compiled graph -------------------
|
|
121
|
+
getState(config, options) {
|
|
122
|
+
return this.#graph.getState(mergeConfigs(this.#config, config), options);
|
|
123
|
+
}
|
|
124
|
+
getStateHistory(config, options) {
|
|
125
|
+
return this.#graph.getStateHistory(mergeConfigs(this.#config, config), options);
|
|
126
|
+
}
|
|
127
|
+
updateState(config, values, asNode) {
|
|
128
|
+
return this.#graph.updateState(mergeConfigs(this.#config, config), values, asNode);
|
|
129
|
+
}
|
|
130
|
+
getSubgraphs(namespace, recurse) {
|
|
131
|
+
return this.#graph.getSubgraphs(namespace, recurse);
|
|
132
|
+
}
|
|
133
|
+
getSubgraphsAsync(namespace, recurse) {
|
|
134
|
+
return this.#graph.getSubgraphsAsync(namespace, recurse);
|
|
135
|
+
}
|
|
136
|
+
getGraphAsync(config) {
|
|
137
|
+
return this.#graph.getGraphAsync(config ? mergeConfigs(this.#config, config) : this.#config);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,2BAA2B,CAAC;AAG9E,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GAKxB,MAAM,sBAAsB,CAAC;AAkB9B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAmB;IAClD,QAAQ,EAAE,EAAE,cAAc,EAAE,iBAAiB,EAAE;IAC/C,cAAc,EAAE,uBAAuB;CACxC,CAAC;AAwFF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,YAAY;IACd,MAAM,CAAqB;IAC3B,OAAO,CAAiB;IACxB,QAAQ,CAAe;IACvB,OAAO,CAAyB;IAEhC,OAAO,CAA8B;IACrC,eAAe,CAA0B;IACzC,SAAS,CAAU;IACnB,gBAAgB,CAAmB;IACnC,QAAQ,CAAoB;IAC5B,eAAe,CAAgD;IAExE;;;OAGG;IACM,QAAQ,CAA8B;IAE/C,YAAY,IAOX;QACC,IAAI,CAAC,MAAM,GAAG,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO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