@archmax-ai/harness 0.8.0 → 1.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/README.md +58 -14
- package/dist/agent.d.ts +4 -4
- package/dist/agent.js +4 -4
- package/dist/assembly/compose.d.ts +5 -24
- package/dist/assembly/compose.js +40 -41
- package/dist/assembly/compose.js.map +1 -1
- package/dist/assembly/delegation-registry.js +3 -14
- package/dist/assembly/delegation-registry.js.map +1 -1
- package/dist/assembly/index.d.ts +18 -15
- package/dist/assembly/index.js +50 -32
- package/dist/assembly/index.js.map +1 -1
- package/dist/assembly/plain.js +1 -2
- package/dist/assembly/plain.js.map +1 -1
- package/dist/authoring-skill/archmax-harness/README.md +5 -5
- package/dist/authoring-skill/archmax-harness/SKILL.md +72 -30
- package/dist/authoring-skill/archmax-harness/references/backend-integration.md +35 -23
- package/dist/authoring-skill/archmax-harness/references/cases.md +44 -10
- package/dist/authoring-skill/archmax-harness/references/{hook-and-test-scripts.md → code-state-and-test-scripts.md} +617 -313
- package/dist/authoring-skill/archmax-harness/references/code-states-and-scripts.md +115 -0
- package/dist/authoring-skill/archmax-harness/references/diagnostics.md +40 -7
- package/dist/authoring-skill/archmax-harness/references/wiring.md +19 -10
- package/dist/authoring-skill/archmax-harness/references/workflow-schema.md +416 -276
- package/dist/authoring-skill/archmax-harness/references/workflow-yaml.md +161 -62
- package/dist/cli/state-flow.d.ts +1 -1
- package/dist/cli/state-flow.js +18 -28
- package/dist/cli/state-flow.js.map +1 -1
- package/dist/cli/turn.d.ts +1 -1
- package/dist/cli/turn.js +2 -3
- package/dist/cli/turn.js.map +1 -1
- package/dist/core/clock.d.ts +26 -0
- package/dist/core/clock.js +64 -0
- package/dist/core/clock.js.map +1 -0
- package/dist/core/code-description.d.ts +3 -3
- package/dist/core/code-description.js +3 -3
- package/dist/core/deepagents.d.ts +5 -5
- package/dist/core/deepagents.js +4 -4
- package/dist/core/events.d.ts +23 -42
- package/dist/core/events.js +21 -24
- package/dist/core/events.js.map +1 -1
- package/dist/core/message-readers.d.ts +22 -2
- package/dist/core/message-readers.js +31 -0
- package/dist/core/message-readers.js.map +1 -1
- package/dist/core/messages.d.ts +1 -23
- package/dist/core/messages.js +2 -35
- package/dist/core/messages.js.map +1 -1
- package/dist/core/mounts.js +3 -3
- package/dist/core/platform-prompt.generated.js +1 -1
- package/dist/core/platform-prompt.generated.js.map +1 -1
- package/dist/core/session-zone.d.ts +1 -1
- package/dist/core/session-zone.js +1 -1
- package/dist/core/workspace-context.d.ts +1 -1
- package/dist/core/workspace.d.ts +1 -1
- package/dist/core/workspace.js +1 -1
- package/dist/core/zones.d.ts +4 -4
- package/dist/core/zones.js +5 -5
- package/dist/core/zones.js.map +1 -1
- package/dist/env.d.ts +9 -9
- package/dist/index.d.ts +3 -7
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/kernel/kernel.d.ts +31 -61
- package/dist/kernel/kernel.js +57 -114
- package/dist/kernel/kernel.js.map +1 -1
- package/dist/machine/allow.d.ts +17 -2
- package/dist/machine/allow.js +16 -6
- package/dist/machine/allow.js.map +1 -1
- package/dist/machine/lint-spec.js +68 -12
- package/dist/machine/lint-spec.js.map +1 -1
- package/dist/machine/machine.d.ts +39 -16
- package/dist/machine/machine.js +72 -49
- package/dist/machine/machine.js.map +1 -1
- package/dist/machine/spec-schema.d.ts +34 -179
- package/dist/machine/spec-schema.js +93 -106
- package/dist/machine/spec-schema.js.map +1 -1
- package/dist/machine/tool-names.d.ts +34 -10
- package/dist/machine/tool-names.js +41 -10
- package/dist/machine/tool-names.js.map +1 -1
- package/dist/machine/tool-paths.d.ts +6 -0
- package/dist/machine/tool-paths.js +10 -0
- package/dist/machine/tool-paths.js.map +1 -1
- package/dist/machine/types.d.ts +14 -38
- package/dist/machine/types.js.map +1 -1
- package/dist/machine/validate-spec.d.ts +1 -1
- package/dist/machine/variables.d.ts +2 -0
- package/dist/machine/variables.js.map +1 -1
- package/dist/public/sandbox.d.ts +62 -66
- package/dist/public/sandbox.js +22 -23
- package/dist/public/sandbox.js.map +1 -1
- package/dist/public/spec.d.ts +12 -19
- package/dist/public/spec.js +11 -19
- package/dist/public/spec.js.map +1 -1
- package/dist/runtime/contract.d.ts +11 -12
- package/dist/runtime/contract.js +16 -16
- package/dist/runtime/contract.js.map +1 -1
- package/dist/sandbox/assets/parts/code-state.js +17 -0
- package/dist/sandbox/executor.d.ts +25 -7
- package/dist/sandbox/executor.js +56 -47
- package/dist/sandbox/executor.js.map +1 -1
- package/dist/sandbox/imports.d.ts +10 -10
- package/dist/sandbox/imports.js +11 -11
- package/dist/sandbox/imports.js.map +1 -1
- package/dist/sandbox/prelude.d.ts +5 -6
- package/dist/sandbox/prelude.js +38 -35
- package/dist/sandbox/prelude.js.map +1 -1
- package/dist/sandbox/ptc-gateway.d.ts +19 -18
- package/dist/sandbox/ptc-gateway.js +26 -22
- package/dist/sandbox/ptc-gateway.js.map +1 -1
- package/dist/sessions/operations.js +4 -5
- package/dist/sessions/operations.js.map +1 -1
- package/dist/sessions/resume.d.ts +12 -7
- package/dist/sessions/resume.js +12 -9
- package/dist/sessions/resume.js.map +1 -1
- package/dist/sessions/summary.d.ts +1 -1
- package/dist/testing/assertions.js +9 -4
- package/dist/testing/assertions.js.map +1 -1
- package/dist/testing/case-document.d.ts +2 -0
- package/dist/testing/case-document.js.map +1 -1
- package/dist/testing/case-schema.d.ts +1 -1
- package/dist/testing/case-schema.js +17 -1
- package/dist/testing/case-schema.js.map +1 -1
- package/dist/testing/driver.d.ts +4 -0
- package/dist/testing/driver.js +22 -3
- package/dist/testing/driver.js.map +1 -1
- package/dist/testing/grade.js +3 -3
- package/dist/testing/grade.js.map +1 -1
- package/dist/testing/interpreter.d.ts +2 -2
- package/dist/testing/interpreter.js +1 -0
- package/dist/testing/interpreter.js.map +1 -1
- package/dist/testing/runner.d.ts +2 -2
- package/dist/validate/validate.d.ts +1 -1
- package/dist/validate/validate.js +39 -70
- package/dist/validate/validate.js.map +1 -1
- package/dist/workflow/automated-controls.d.ts +63 -0
- package/dist/workflow/automated-controls.js +158 -0
- package/dist/workflow/automated-controls.js.map +1 -0
- package/dist/workflow/automated.d.ts +112 -0
- package/dist/workflow/automated.js +163 -0
- package/dist/workflow/automated.js.map +1 -0
- package/dist/workflow/checkpointer.d.ts +7 -0
- package/dist/workflow/checkpointer.js +28 -0
- package/dist/workflow/checkpointer.js.map +1 -1
- package/dist/workflow/code-state.d.ts +46 -0
- package/dist/workflow/code-state.js +26 -0
- package/dist/workflow/code-state.js.map +1 -0
- package/dist/workflow/control-tools.d.ts +54 -23
- package/dist/workflow/control-tools.js +121 -77
- package/dist/workflow/control-tools.js.map +1 -1
- package/dist/workflow/file-values.d.ts +4 -4
- package/dist/workflow/file-values.js +1 -1
- package/dist/workflow/file-values.js.map +1 -1
- package/dist/workflow/governance.d.ts +13 -22
- package/dist/workflow/governance.js +51 -87
- package/dist/workflow/governance.js.map +1 -1
- package/dist/workflow/grader-state.d.ts +55 -0
- package/dist/workflow/grader-state.js +182 -0
- package/dist/workflow/grader-state.js.map +1 -0
- package/dist/workflow/history.d.ts +11 -0
- package/dist/workflow/history.js +64 -0
- package/dist/workflow/history.js.map +1 -0
- package/dist/workflow/middleware.d.ts +14 -17
- package/dist/workflow/middleware.js +106 -74
- package/dist/workflow/middleware.js.map +1 -1
- package/dist/workflow/move-events.d.ts +21 -0
- package/dist/workflow/move-events.js +20 -0
- package/dist/workflow/move-events.js.map +1 -0
- package/dist/workflow/parks.d.ts +9 -2
- package/dist/workflow/parks.js +16 -8
- package/dist/workflow/parks.js.map +1 -1
- package/dist/workflow/paths.d.ts +9 -9
- package/dist/workflow/paths.js +19 -19
- package/dist/workflow/paths.js.map +1 -1
- package/dist/workflow/render-prompt.d.ts +7 -5
- package/dist/workflow/render-prompt.js +22 -37
- package/dist/workflow/render-prompt.js.map +1 -1
- package/dist/workflow/signature-checks.d.ts +2 -2
- package/dist/workflow/snapshot.js +5 -29
- package/dist/workflow/snapshot.js.map +1 -1
- package/dist/workflow/state.d.ts +19 -6
- package/dist/workflow/state.js +24 -8
- package/dist/workflow/state.js.map +1 -1
- package/dist/workflow/sub-workflow.d.ts +3 -3
- package/dist/workflow/tool-service.d.ts +1 -9
- package/dist/workflow/tool-service.js +21 -24
- package/dist/workflow/tool-service.js.map +1 -1
- package/dist/workflow/turn-boundary.d.ts +2 -2
- package/dist/workflow/turn-boundary.js +10 -7
- package/dist/workflow/turn-boundary.js.map +1 -1
- package/dist/workflow/turn-runner.js +30 -2
- package/dist/workflow/turn-runner.js.map +1 -1
- package/package.json +1 -1
- package/skills/archmax-harness/README.md +5 -5
- package/skills/archmax-harness/SKILL.md +72 -30
- package/skills/archmax-harness/references/backend-integration.md +35 -23
- package/skills/archmax-harness/references/cases.md +44 -10
- package/skills/archmax-harness/references/{hook-and-test-scripts.md → code-state-and-test-scripts.md} +617 -313
- package/skills/archmax-harness/references/code-states-and-scripts.md +115 -0
- package/skills/archmax-harness/references/diagnostics.md +40 -7
- package/skills/archmax-harness/references/wiring.md +19 -10
- package/skills/archmax-harness/references/workflow-schema.md +416 -276
- package/skills/archmax-harness/references/workflow-yaml.md +161 -62
- package/dist/authoring-skill/archmax-harness/references/hooks-and-scripts.md +0 -88
- package/dist/lifecycle/hook-shape.d.ts +0 -44
- package/dist/lifecycle/hook-shape.js +0 -66
- package/dist/lifecycle/hook-shape.js.map +0 -1
- package/dist/lifecycle/runner.d.ts +0 -183
- package/dist/lifecycle/runner.js +0 -373
- package/dist/lifecycle/runner.js.map +0 -1
- package/dist/lifecycle/transcript.d.ts +0 -27
- package/dist/lifecycle/transcript.js +0 -43
- package/dist/lifecycle/transcript.js.map +0 -1
- package/dist/rubrics/rubrics.d.ts +0 -135
- package/dist/rubrics/rubrics.js +0 -145
- package/dist/rubrics/rubrics.js.map +0 -1
- package/dist/sandbox/assets/parts/core.js +0 -22
- package/dist/sandbox/assets/parts/lifecycle-hook.js +0 -47
- package/dist/sandbox/bridge.d.ts +0 -16
- package/dist/sandbox/bridge.js +0 -95
- package/dist/sandbox/bridge.js.map +0 -1
- package/skills/archmax-harness/references/hooks-and-scripts.md +0 -88
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pinned clock: the instant a governed agent's prompt states as "now" in place
|
|
3
|
+
* of the real time, so a case or an evaluation reads the same date on every run.
|
|
4
|
+
* Set by the host's `clock` option or, per turn, by a case's `clock:` key, which
|
|
5
|
+
* the case driver writes into the run configuration under {@link CLOCK_CONFIG_KEY}.
|
|
6
|
+
* Only the prompt line reads it; every recorded timestamp stays real.
|
|
7
|
+
*/
|
|
8
|
+
/** The forms a pin takes, as an error message names them. */
|
|
9
|
+
export declare const CLOCK_FORMS = "an ISO 8601 date (2026-03-20) or a date-time with Z or an offset (2026-03-20T14:30:00Z)";
|
|
10
|
+
/** Where a turn's pin rides in `configurable`, beside the case's tool mocks. */
|
|
11
|
+
export declare const CLOCK_CONFIG_KEY = "__clock";
|
|
12
|
+
/**
|
|
13
|
+
* The instant `value` pins, or `undefined` for an empty string (no pin). Throws
|
|
14
|
+
* for anything else, naming the accepted forms. A date-time without a zone is
|
|
15
|
+
* refused, because JavaScript would read it in the machine's own zone and a case
|
|
16
|
+
* would render differently on each machine; so is a date or time that does not
|
|
17
|
+
* exist (`2026-02-30`, `25:00`), which `Date` would silently roll over.
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseClock(value: string): Date | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The pin a turn's run configuration carries, or `undefined`. A value that is
|
|
22
|
+
* not a string reads as unset; a string that is not a pin throws, because only a
|
|
23
|
+
* host writing the key by hand can produce one, and showing the real time
|
|
24
|
+
* instead would hide the mistake.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readClockPin(configurable: Record<string, unknown> | undefined): Date | undefined;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pinned clock: the instant a governed agent's prompt states as "now" in place
|
|
3
|
+
* of the real time, so a case or an evaluation reads the same date on every run.
|
|
4
|
+
* Set by the host's `clock` option or, per turn, by a case's `clock:` key, which
|
|
5
|
+
* the case driver writes into the run configuration under {@link CLOCK_CONFIG_KEY}.
|
|
6
|
+
* Only the prompt line reads it; every recorded timestamp stays real.
|
|
7
|
+
*/
|
|
8
|
+
/** The forms a pin takes, as an error message names them. */
|
|
9
|
+
export const CLOCK_FORMS = "an ISO 8601 date (2026-03-20) or a date-time with Z or an offset (2026-03-20T14:30:00Z)";
|
|
10
|
+
/** Where a turn's pin rides in `configurable`, beside the case's tool mocks. */
|
|
11
|
+
export const CLOCK_CONFIG_KEY = "__clock";
|
|
12
|
+
const DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
13
|
+
const DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|([+-])(\d{2}):(\d{2}))$/;
|
|
14
|
+
/**
|
|
15
|
+
* The instant `value` pins, or `undefined` for an empty string (no pin). Throws
|
|
16
|
+
* for anything else, naming the accepted forms. A date-time without a zone is
|
|
17
|
+
* refused, because JavaScript would read it in the machine's own zone and a case
|
|
18
|
+
* would render differently on each machine; so is a date or time that does not
|
|
19
|
+
* exist (`2026-02-30`, `25:00`), which `Date` would silently roll over.
|
|
20
|
+
*/
|
|
21
|
+
export function parseClock(value) {
|
|
22
|
+
if (value === "")
|
|
23
|
+
return undefined;
|
|
24
|
+
const date = DATE.exec(value);
|
|
25
|
+
const dateTime = date ? null : DATE_TIME.exec(value);
|
|
26
|
+
const m = date ?? dateTime;
|
|
27
|
+
if (!m)
|
|
28
|
+
throw new Error(`'${value}' is not ${CLOCK_FORMS}`);
|
|
29
|
+
const [y, mo, d, h, mi, s, ms] = [1, 2, 3, 4, 5, 6, 7].map((i) => Number(m[i] ?? 0));
|
|
30
|
+
const offsetMinutes = dateTime?.[9] === undefined
|
|
31
|
+
? 0
|
|
32
|
+
: (dateTime[9] === "-" ? -1 : 1) * (Number(dateTime[10]) * 60 + Number(dateTime[11]));
|
|
33
|
+
const written = new Date(Date.UTC(y, mo - 1, d, h, mi, s, ms));
|
|
34
|
+
// Date.UTC rolls an impossible field over; reading the same fields back catches it.
|
|
35
|
+
const exists = written.getUTCFullYear() === y &&
|
|
36
|
+
written.getUTCMonth() === mo - 1 &&
|
|
37
|
+
written.getUTCDate() === d &&
|
|
38
|
+
written.getUTCHours() === h &&
|
|
39
|
+
written.getUTCMinutes() === mi &&
|
|
40
|
+
written.getUTCSeconds() === s &&
|
|
41
|
+
Number(dateTime?.[11] ?? 0) < 60 &&
|
|
42
|
+
Number(dateTime?.[10] ?? 0) < 24;
|
|
43
|
+
if (!exists)
|
|
44
|
+
throw new Error(`'${value}' names a date or time that does not exist; use ${CLOCK_FORMS}`);
|
|
45
|
+
return new Date(written.getTime() - offsetMinutes * 60_000);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The pin a turn's run configuration carries, or `undefined`. A value that is
|
|
49
|
+
* not a string reads as unset; a string that is not a pin throws, because only a
|
|
50
|
+
* host writing the key by hand can produce one, and showing the real time
|
|
51
|
+
* instead would hide the mistake.
|
|
52
|
+
*/
|
|
53
|
+
export function readClockPin(configurable) {
|
|
54
|
+
const value = configurable?.[CLOCK_CONFIG_KEY];
|
|
55
|
+
if (typeof value !== "string")
|
|
56
|
+
return undefined;
|
|
57
|
+
try {
|
|
58
|
+
return parseClock(value);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
throw new Error(`The run configuration's '${CLOCK_CONFIG_KEY}': ${err.message}`, { cause: err });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=clock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../../src/core/clock.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,WAAW,G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AAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAC9G,CAAC;AACH,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `archmax_run` scripts carry their human-facing contract as a leading JSDoc
|
|
3
3
|
* block comment — the code-file analogue of a case file's `description`. Admin
|
|
4
|
-
* UIs display only that description.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* UIs display only that description. A code state's script is NOT covered by this convention:
|
|
5
|
+
* it is a hand-authored file whose only validation is that the referenced file
|
|
6
|
+
* exists and imports nothing foreign. This module is the canonical extractor so consumers never
|
|
7
7
|
* scrape comments themselves. It operates on source strings only (callers read
|
|
8
8
|
* the file through their configured backend) and never touches the filesystem.
|
|
9
9
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `archmax_run` scripts carry their human-facing contract as a leading JSDoc
|
|
3
3
|
* block comment — the code-file analogue of a case file's `description`. Admin
|
|
4
|
-
* UIs display only that description.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* UIs display only that description. A code state's script is NOT covered by this convention:
|
|
5
|
+
* it is a hand-authored file whose only validation is that the referenced file
|
|
6
|
+
* exists and imports nothing foreign. This module is the canonical extractor so consumers never
|
|
7
7
|
* scrape comments themselves. It operates on source strings only (callers read
|
|
8
8
|
* the file through their configured backend) and never touches the filesystem.
|
|
9
9
|
*/
|
|
@@ -79,7 +79,7 @@ export type AnyModelCallRequest = ModelRequest;
|
|
|
79
79
|
export type AnyToolCallHandler = ToolCallHandler;
|
|
80
80
|
/** The handler that runs the model for a generic model-call request. */
|
|
81
81
|
export type AnyModelCallHandler = (request: AnyModelCallRequest) => ModelCallResult | Promise<ModelCallResult>;
|
|
82
|
-
/** The framework runtime handed to
|
|
82
|
+
/** The framework runtime handed to middleware hooks (context, configurable, signal, store). */
|
|
83
83
|
export type FrameworkRuntime = Runtime;
|
|
84
84
|
export type { ToolMessage };
|
|
85
85
|
/**
|
|
@@ -103,10 +103,10 @@ export declare function asStructuredTools(tools: ModelCallRequest["tools"] | und
|
|
|
103
103
|
export declare function asModelCallResult(result: unknown, origin: string): ModelCallHookResult;
|
|
104
104
|
/**
|
|
105
105
|
* The `recursionLimit` a turn runs under when the caller names none. One invoke
|
|
106
|
-
* is one whole turn across states — every
|
|
107
|
-
* super-step — so this is
|
|
108
|
-
*
|
|
109
|
-
*
|
|
106
|
+
* is one whole turn across states — every model call, tool batch and automated
|
|
107
|
+
* state is a super-step — so this is LangGraph's bound on a whole turn: a
|
|
108
|
+
* caller's own `recursionLimit` replaces it, and a state's `maxTurns` and
|
|
109
|
+
* `maxParks` bound the states that declare them.
|
|
110
110
|
*/
|
|
111
111
|
export declare const DEFAULT_RECURSION_LIMIT = 400;
|
|
112
112
|
/** The input a Deep Agent graph is invoked with: messages plus any state channel. */
|
package/dist/core/deepagents.js
CHANGED
|
@@ -99,10 +99,10 @@ function describeModelResult(result) {
|
|
|
99
99
|
// --- Defaults -----------------------------------------------------------------
|
|
100
100
|
/**
|
|
101
101
|
* The `recursionLimit` a turn runs under when the caller names none. One invoke
|
|
102
|
-
* is one whole turn across states — every
|
|
103
|
-
* super-step — so this is
|
|
104
|
-
*
|
|
105
|
-
*
|
|
102
|
+
* is one whole turn across states — every model call, tool batch and automated
|
|
103
|
+
* state is a super-step — so this is LangGraph's bound on a whole turn: a
|
|
104
|
+
* caller's own `recursionLimit` replaces it, and a state's `maxTurns` and
|
|
105
|
+
* `maxParks` bound the states that declare them.
|
|
106
106
|
*/
|
|
107
107
|
export const DEFAULT_RECURSION_LIMIT = 400;
|
|
108
108
|
/**
|
package/dist/core/events.d.ts
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
* machine-governed workflow runs. Every runtime diagnostic flows through this
|
|
4
4
|
* single typed stream; callers subscribe via `onEvent` on
|
|
5
5
|
* `CreateWorkflowAgentOptions`. With no subscriber, the harness installs
|
|
6
|
-
* {@link consoleEventHandler} (`[workflow]` / `[interpreter]`
|
|
7
|
-
* console output).
|
|
6
|
+
* {@link consoleEventHandler} (`[workflow]` / `[interpreter]` console output).
|
|
8
7
|
*
|
|
9
8
|
* Two visual tiers: **node-change** events (`state-enter`, `state-leave`) render
|
|
10
|
-
* at the outer level; **action** events (`
|
|
11
|
-
* happen within a node and render indented beneath it.
|
|
9
|
+
* at the outer level; **action** events (`code-*`, `grader-*`, `advance`,
|
|
10
|
+
* `agent-text`) happen within a node and render indented beneath it.
|
|
12
11
|
*
|
|
13
12
|
* `callId` pairing rule: every event a tool call causes carries that call's
|
|
14
13
|
* `callId` — its own `tool-called`/`tool-result` pair and the effects it produced
|
|
@@ -26,13 +25,14 @@ export type WorkflowEventLevel = "info" | "warn" | "error";
|
|
|
26
25
|
*/
|
|
27
26
|
export declare const SESSION_ORIGIN = "__start__";
|
|
28
27
|
/**
|
|
29
|
-
* Where a tool call came from, on the tool events. Absent means
|
|
30
|
-
* the tool
|
|
31
|
-
*
|
|
28
|
+
* Where a tool call came from, on the tool events. Absent means a model called
|
|
29
|
+
* the tool — the session's agent, or a grader in a grader state; `script` marks
|
|
30
|
+
* a programmatic call from inside a sandbox script — the agent's
|
|
31
|
+
* `archmax_eval`/`archmax_run`, or a code state's script.
|
|
32
32
|
*/
|
|
33
|
-
export type ToolEventOrigin = "script"
|
|
33
|
+
export type ToolEventOrigin = "script";
|
|
34
34
|
/** How a programmatic tool call's origin reads in human-facing output. */
|
|
35
|
-
export declare function originLabel(
|
|
35
|
+
export declare function originLabel(_origin: ToolEventOrigin): string;
|
|
36
36
|
/**
|
|
37
37
|
* Event payloads, without the severity level (added by the emitter). Every
|
|
38
38
|
* `state` field carries a **state slug** — never a `title`, so a retitled node
|
|
@@ -43,9 +43,6 @@ export type WorkflowEventPayload = {
|
|
|
43
43
|
} | {
|
|
44
44
|
type: "skills-loaded";
|
|
45
45
|
names: string[];
|
|
46
|
-
} | {
|
|
47
|
-
type: "hooks-summary";
|
|
48
|
-
summary: string;
|
|
49
46
|
} | {
|
|
50
47
|
type: "graph-topology";
|
|
51
48
|
topology: string;
|
|
@@ -69,32 +66,28 @@ export type WorkflowEventPayload = {
|
|
|
69
66
|
to: string;
|
|
70
67
|
reason: string;
|
|
71
68
|
} | {
|
|
72
|
-
type: "
|
|
69
|
+
type: "code-start";
|
|
73
70
|
state: string;
|
|
74
|
-
|
|
75
|
-
label: string;
|
|
71
|
+
script: string;
|
|
76
72
|
} | {
|
|
77
|
-
type: "
|
|
73
|
+
type: "code-output";
|
|
78
74
|
state: string;
|
|
79
75
|
line: string;
|
|
80
76
|
} | {
|
|
81
|
-
type: "
|
|
77
|
+
type: "code-result";
|
|
82
78
|
state: string;
|
|
83
|
-
|
|
79
|
+
status: "ok" | "error";
|
|
80
|
+
durationMs: number;
|
|
81
|
+
reason?: string;
|
|
84
82
|
} | {
|
|
85
|
-
type: "
|
|
83
|
+
type: "grader-start";
|
|
86
84
|
state: string;
|
|
87
|
-
phase: "before" | "after";
|
|
88
|
-
label: string;
|
|
89
|
-
/** The hook's verdict, kept as the exact kernel vocabulary (never widened). */
|
|
90
|
-
verdict: "ok" | "correct" | "veto";
|
|
91
|
-
reason: string;
|
|
92
|
-
missing?: string[];
|
|
93
85
|
} | {
|
|
94
|
-
type: "
|
|
86
|
+
type: "grader-result";
|
|
95
87
|
state: string;
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
status: "ok" | "error";
|
|
89
|
+
durationMs: number;
|
|
90
|
+
reason?: string;
|
|
98
91
|
} | {
|
|
99
92
|
type: "advance";
|
|
100
93
|
from: string;
|
|
@@ -160,10 +153,10 @@ export type WorkflowEventPayload = {
|
|
|
160
153
|
sessionId: string;
|
|
161
154
|
} | {
|
|
162
155
|
type: "raised";
|
|
163
|
-
/** The state the
|
|
156
|
+
/** The state the raise was made in; the session's position stays there. */
|
|
164
157
|
state: string;
|
|
165
158
|
sessionId: string;
|
|
166
|
-
/** The
|
|
159
|
+
/** The raiser's own short code for what failed. */
|
|
167
160
|
code: string;
|
|
168
161
|
reason: string;
|
|
169
162
|
/** The `archmax_raise` call, matching its `tool-called`/`tool-result` pair. */
|
|
@@ -228,18 +221,6 @@ export type WorkflowEventPayload = {
|
|
|
228
221
|
callId?: string;
|
|
229
222
|
args?: Record<string, unknown>;
|
|
230
223
|
origin?: ToolEventOrigin;
|
|
231
|
-
} | {
|
|
232
|
-
type: "rubric-start";
|
|
233
|
-
state: string;
|
|
234
|
-
name: string;
|
|
235
|
-
dispatchId: string;
|
|
236
|
-
} | {
|
|
237
|
-
type: "rubric-result";
|
|
238
|
-
state: string;
|
|
239
|
-
name: string;
|
|
240
|
-
dispatchId: string;
|
|
241
|
-
status: "ok" | "error";
|
|
242
|
-
durationMs: number;
|
|
243
224
|
} | {
|
|
244
225
|
type: "sub-workflow-start";
|
|
245
226
|
/** The state the call was made from. */
|
package/dist/core/events.js
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
* machine-governed workflow runs. Every runtime diagnostic flows through this
|
|
4
4
|
* single typed stream; callers subscribe via `onEvent` on
|
|
5
5
|
* `CreateWorkflowAgentOptions`. With no subscriber, the harness installs
|
|
6
|
-
* {@link consoleEventHandler} (`[workflow]` / `[interpreter]`
|
|
7
|
-
* console output).
|
|
6
|
+
* {@link consoleEventHandler} (`[workflow]` / `[interpreter]` console output).
|
|
8
7
|
*
|
|
9
8
|
* Two visual tiers: **node-change** events (`state-enter`, `state-leave`) render
|
|
10
|
-
* at the outer level; **action** events (`
|
|
11
|
-
* happen within a node and render indented beneath it.
|
|
9
|
+
* at the outer level; **action** events (`code-*`, `grader-*`, `advance`,
|
|
10
|
+
* `agent-text`) happen within a node and render indented beneath it.
|
|
12
11
|
*
|
|
13
12
|
* `callId` pairing rule: every event a tool call causes carries that call's
|
|
14
13
|
* `callId` — its own `tool-called`/`tool-result` pair and the effects it produced
|
|
@@ -26,18 +25,18 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
26
25
|
*/
|
|
27
26
|
export const SESSION_ORIGIN = "__start__";
|
|
28
27
|
/** How a programmatic tool call's origin reads in human-facing output. */
|
|
29
|
-
export function originLabel(
|
|
30
|
-
return
|
|
28
|
+
export function originLabel(_origin) {
|
|
29
|
+
return "script";
|
|
31
30
|
}
|
|
32
31
|
function defaultLevel(event) {
|
|
33
32
|
switch (event.type) {
|
|
34
33
|
case "warning":
|
|
35
34
|
case "tool-blocked":
|
|
36
|
-
case "hook-rejected":
|
|
37
35
|
case "raised":
|
|
38
36
|
return "warn";
|
|
39
37
|
case "tool-result":
|
|
40
|
-
case "
|
|
38
|
+
case "code-result":
|
|
39
|
+
case "grader-result":
|
|
41
40
|
case "sub-workflow-result":
|
|
42
41
|
return event.status === "error" ? "warn" : "info";
|
|
43
42
|
default:
|
|
@@ -111,11 +110,9 @@ export function createWorkflowEventEmitter(handler) {
|
|
|
111
110
|
export function renderEventLine(event) {
|
|
112
111
|
switch (event.type) {
|
|
113
112
|
case "interpreter-enabled":
|
|
114
|
-
return "[interpreter] enabled (ptc:
|
|
113
|
+
return "[interpreter] enabled (ptc: the active state's tools)";
|
|
115
114
|
case "skills-loaded":
|
|
116
115
|
return `[skills] loaded: ${event.names.join(", ")}`;
|
|
117
|
-
case "hooks-summary":
|
|
118
|
-
return `[workflow] lifecycle: ${event.summary}`;
|
|
119
116
|
case "graph-topology":
|
|
120
117
|
return `[workflow] LangGraph graph:\n ${event.topology}`;
|
|
121
118
|
case "warning":
|
|
@@ -128,18 +125,20 @@ export function renderEventLine(event) {
|
|
|
128
125
|
return `[workflow] leaving node '${event.state}' -> workflowState=${event.next}`;
|
|
129
126
|
case "state-error-routed":
|
|
130
127
|
return `[workflow] '${event.state}' failed -> routing to on_error '${event.to}': ${event.reason}`;
|
|
131
|
-
case "
|
|
132
|
-
return `[workflow]
|
|
133
|
-
case "
|
|
128
|
+
case "code-start":
|
|
129
|
+
return `[workflow] code state '${event.state}': running ${event.script}`;
|
|
130
|
+
case "code-output":
|
|
134
131
|
return `[workflow:${event.state}] ${event.line}`;
|
|
135
|
-
case "
|
|
136
|
-
return
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
case "
|
|
142
|
-
return
|
|
132
|
+
case "code-result":
|
|
133
|
+
return event.status === "ok"
|
|
134
|
+
? `[workflow] code state '${event.state}' finished (${event.durationMs}ms)`
|
|
135
|
+
: `[workflow] code state '${event.state}' FAILED: ${event.reason ?? "unknown error"}`;
|
|
136
|
+
case "grader-start":
|
|
137
|
+
return `[workflow] grader state '${event.state}': grading`;
|
|
138
|
+
case "grader-result":
|
|
139
|
+
return event.status === "ok"
|
|
140
|
+
? `[workflow] grader state '${event.state}' decided (${event.durationMs}ms)`
|
|
141
|
+
: `[workflow] grader state '${event.state}' FAILED: ${event.reason ?? "unknown error"}`;
|
|
143
142
|
case "advance":
|
|
144
143
|
return event.from === SESSION_ORIGIN
|
|
145
144
|
? `[workflow] entering start state '${event.to}'`
|
|
@@ -184,8 +183,6 @@ export function renderEventLine(event) {
|
|
|
184
183
|
case "agent-text":
|
|
185
184
|
case "agent-text-delta":
|
|
186
185
|
case "tool-result":
|
|
187
|
-
case "rubric-start":
|
|
188
|
-
case "rubric-result":
|
|
189
186
|
case "model-usage":
|
|
190
187
|
// Accounting is not console output: the CLI renders its own usage footer
|
|
191
188
|
// from its own subscriber, so a line here would duplicate it.
|
package/dist/core/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/core/events.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/core/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIrD;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;AAU1C,0EAA0E;AAC1E,MAAM,UAAU,WAAW,CAAC,OAAwB;IAClD,OA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B,KAAK,CAAC,QAAQ,gBAAgB,KAAK,CAAC,UAAU,KAAK;gBACjF,CAAC,CAAC,4BAA4B,KAAK,CAAC,QAAQ,aAAa,KAAK,CAAC,MAAM,IAAI,eAAe,EAAE,CAAC;QAC/F,KAAK,aAAa,CAAC;QACnB,KAAK,YAAY,CAAC;QAClB,KAAK,kBAAkB,CAAC;QACxB,KAAK,aAAa,CAAC;QACnB,KAAK,aAAa;YAChB,yEAAyE;YACzE,8DAA8D;YAC9D,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAyB,CAAC,KAAK,EAAE,EAAE;IACjE,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACpC,IAAI,IAAI,IAAI,IAAI;QAAE,OAAO;IACzB,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM;QAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;;QACzC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC"}
|
|
@@ -26,17 +26,37 @@ export declare function isHumanMessage(message: unknown): boolean;
|
|
|
26
26
|
* answer as a person would read it.
|
|
27
27
|
*/
|
|
28
28
|
export declare function lastAgentText(messages: unknown[]): string;
|
|
29
|
+
/**
|
|
30
|
+
* Where a turn starts, recorded before it runs: the id of the transcript's last
|
|
31
|
+
* message and the transcript's length. The id outlives a rewrite of the list
|
|
32
|
+
* ahead of it (Deep Agents' tool-call patching inserts and drops tool messages
|
|
33
|
+
* but keeps every other message, id included); the length is the fallback.
|
|
34
|
+
*/
|
|
35
|
+
export interface TurnAnchor {
|
|
36
|
+
id?: string;
|
|
37
|
+
count: number;
|
|
38
|
+
}
|
|
39
|
+
/** The {@link TurnAnchor} of a transcript as it stands before a turn. */
|
|
40
|
+
export declare function turnAnchorOf(messages: unknown): TurnAnchor;
|
|
41
|
+
/** Where the messages after `anchor` begin in `messages`: after its id, else at its clamped count. */
|
|
42
|
+
export declare function anchorIndex(messages: readonly unknown[], anchor: TurnAnchor): number;
|
|
43
|
+
/**
|
|
44
|
+
* What the agent said during the turn that began at `anchor`: each assistant
|
|
45
|
+
* text, in order, joined by a blank line. Empty when the turn said nothing.
|
|
46
|
+
*/
|
|
47
|
+
export declare function turnReply(messages: unknown[], anchor: TurnAnchor): string;
|
|
29
48
|
/**
|
|
30
49
|
* What the runtime wrote into a transcript, and why.
|
|
31
50
|
*
|
|
32
51
|
* - `decision` — a person picked an edge at a human state and the session was routed
|
|
33
52
|
* - `event` — a trigger firing was delivered to a parked session
|
|
34
53
|
* - `error` — a failed state was routed to its `on_error` target
|
|
35
|
-
* - `
|
|
54
|
+
* - `grader` — a grader state moved the session (its reason is what the next state reads) or ended it
|
|
55
|
+
* - `code` — a code state moved the session or ended it
|
|
36
56
|
* - `sub-workflow` — a resumed child's result, handed back to its caller
|
|
37
57
|
* - `opening` — the fixed line a child session's own transcript opens with
|
|
38
58
|
*/
|
|
39
|
-
export type RuntimeNoteKind = "decision" | "event" | "error" | "
|
|
59
|
+
export type RuntimeNoteKind = "decision" | "event" | "error" | "grader" | "code" | "sub-workflow" | "opening";
|
|
40
60
|
/** Where the marker lives on a message: `additional_kwargs.archmax.note`. */
|
|
41
61
|
export declare const NOTE_KEY = "archmax";
|
|
42
62
|
/**
|
|
@@ -56,6 +56,37 @@ export function lastAgentText(messages) {
|
|
|
56
56
|
}
|
|
57
57
|
return "";
|
|
58
58
|
}
|
|
59
|
+
/** The {@link TurnAnchor} of a transcript as it stands before a turn. */
|
|
60
|
+
export function turnAnchorOf(messages) {
|
|
61
|
+
const list = Array.isArray(messages) ? messages : [];
|
|
62
|
+
const id = messageIdOf(list[list.length - 1]);
|
|
63
|
+
return { ...(id ? { id } : {}), count: list.length };
|
|
64
|
+
}
|
|
65
|
+
/** Where the messages after `anchor` begin in `messages`: after its id, else at its clamped count. */
|
|
66
|
+
export function anchorIndex(messages, anchor) {
|
|
67
|
+
const at = anchor.id === undefined ? -1 : messages.findIndex((m) => messageIdOf(m) === anchor.id);
|
|
68
|
+
return at >= 0 ? at + 1 : Math.min(Math.max(0, anchor.count), messages.length);
|
|
69
|
+
}
|
|
70
|
+
function messageIdOf(message) {
|
|
71
|
+
const msg = message;
|
|
72
|
+
const id = msg?.id ?? msg?.kwargs?.id;
|
|
73
|
+
return typeof id === "string" && id !== "" ? id : undefined;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* What the agent said during the turn that began at `anchor`: each assistant
|
|
77
|
+
* text, in order, joined by a blank line. Empty when the turn said nothing.
|
|
78
|
+
*/
|
|
79
|
+
export function turnReply(messages, anchor) {
|
|
80
|
+
const said = [];
|
|
81
|
+
for (const message of messages.slice(anchorIndex(messages, anchor))) {
|
|
82
|
+
if (!isAiMessage(message) || isRuntimeNote(message))
|
|
83
|
+
continue;
|
|
84
|
+
const text = contentToString(message.content).trim();
|
|
85
|
+
if (text)
|
|
86
|
+
said.push(text);
|
|
87
|
+
}
|
|
88
|
+
return said.join("\n\n");
|
|
89
|
+
}
|
|
59
90
|
/** Where the marker lives on a message: `additional_kwargs.archmax.note`. */
|
|
60
91
|
export const NOTE_KEY = "archmax";
|
|
61
92
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-readers.js","sourceRoot":"","sources":["../../src/core/message-readers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,YAAY,GAA2B;IAClD,KAAK,EAAE,MAAM;IACb,EAAE,EAAE,WAAW;IACf,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,MAAM;CACjB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,MAAM,GAAG,GAAG,OAAkC,CAAC;IAC/C,MAAM,CAAC,GACJ,GAAG,CAAC,QAAuC,EAAE,EAAE;QAC/C,GAAG,CAAC,OAAsC,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AG,CAAC,CAAC;QAAE,GAAG,EAAE,CAAC;IACpD,IAAI,GAAG,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IACvB,IAAI,KAAK,GAAG,GAAG,CAAC;IAChB,OAAO,KAAK,GAAG,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAAE,KAAK,EAAE,CAAC;IAC5D,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO;aACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,OAAO,IAAI,KAAK,QAAQ;YACtB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,OAAQ,IAA0B,EAAE,IAAI,KAAK,QAAQ;gBACrD,CAAC,CAAE,IAAyB,CAAC,IAAI;gBACjC,CAAC,CAAC,EAAE,CACT;aACA,IAAI,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/dist/core/messages.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HumanMessage } from "@langchain/core/messages";
|
|
2
2
|
import type { BaseMessage } from "@langchain/core/messages";
|
|
3
3
|
import { type RuntimeNoteKind } from "./message-readers.js";
|
|
4
|
-
export { contentToString, isAiMessage, isHumanMessage, isRuntimeNote, lastAgentText, lastMessageIsHuman, lastTurn, messagesSince, messageTypeOf, opensTurn, runtimeNoteKind, spokeSinceLastHumanMessage, type RuntimeNoteKind, } from "./message-readers.js";
|
|
4
|
+
export { anchorIndex, contentToString, isAiMessage, isHumanMessage, isRuntimeNote, lastAgentText, lastMessageIsHuman, lastTurn, messagesSince, messageTypeOf, opensTurn, runtimeNoteKind, spokeSinceLastHumanMessage, turnAnchorOf, turnReply, type RuntimeNoteKind, type TurnAnchor, } from "./message-readers.js";
|
|
5
5
|
/**
|
|
6
6
|
* A message the runtime wrote into a session's transcript on its own behalf, shaped
|
|
7
7
|
* as a **tool call and its result**: an assistant message carrying one
|
|
@@ -25,25 +25,3 @@ export declare function runtimeNote(kind: RuntimeNoteKind, text: string): BaseMe
|
|
|
25
25
|
* session has to open with a request, so it is marked rather than reshaped.
|
|
26
26
|
*/
|
|
27
27
|
export declare function humanNote(kind: RuntimeNoteKind, text: string): HumanMessage;
|
|
28
|
-
export interface HistoryEntry {
|
|
29
|
-
role: string;
|
|
30
|
-
content: string;
|
|
31
|
-
toolCalls?: {
|
|
32
|
-
name: string;
|
|
33
|
-
args: unknown;
|
|
34
|
-
}[];
|
|
35
|
-
}
|
|
36
|
-
export interface RunContext {
|
|
37
|
-
history: HistoryEntry[];
|
|
38
|
-
userRequest: string;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Build the compact view a lifecycle hook and a rubric grader read: the last
|
|
42
|
-
* {@link HISTORY_WINDOW} messages plus the request that opened the session.
|
|
43
|
-
*
|
|
44
|
-
* `userRequest` is derived from the **whole** list, not the window: a grader
|
|
45
|
-
* asked whether the reply satisfies the request must see the request, and a
|
|
46
|
-
* session of more than a couple of tool-calling turns pushes the opening message
|
|
47
|
-
* out of any fixed window (issue #61).
|
|
48
|
-
*/
|
|
49
|
-
export declare function runContextFromMessages(messages: unknown[]): RunContext;
|
package/dist/core/messages.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { AIMessage, HumanMessage, ToolMessage } from "@langchain/core/messages";
|
|
3
3
|
import { NOTE_TOOL } from "../machine/tool-names.js";
|
|
4
|
-
import {
|
|
4
|
+
import { NOTE_KEY } from "./message-readers.js";
|
|
5
5
|
// The readers are pure and live in `message-readers.ts` (the `@archmax-ai/harness/messages`
|
|
6
6
|
// subpath); re-exported so every runtime importer keeps one module for both halves.
|
|
7
|
-
export { contentToString, isAiMessage, isHumanMessage, isRuntimeNote, lastAgentText, lastMessageIsHuman, lastTurn, messagesSince, messageTypeOf, opensTurn, runtimeNoteKind, spokeSinceLastHumanMessage, } from "./message-readers.js";
|
|
7
|
+
export { anchorIndex, contentToString, isAiMessage, isHumanMessage, isRuntimeNote, lastAgentText, lastMessageIsHuman, lastTurn, messagesSince, messageTypeOf, opensTurn, runtimeNoteKind, spokeSinceLastHumanMessage, turnAnchorOf, turnReply, } from "./message-readers.js";
|
|
8
8
|
/** The marker every message of a runtime note carries. */
|
|
9
9
|
function marker(kind) {
|
|
10
10
|
return { [NOTE_KEY]: { note: kind } };
|
|
@@ -49,37 +49,4 @@ export function runtimeNote(kind, text) {
|
|
|
49
49
|
export function humanNote(kind, text) {
|
|
50
50
|
return new HumanMessage({ content: text, additional_kwargs: marker(kind) });
|
|
51
51
|
}
|
|
52
|
-
/** How many trailing messages a hook's compact `history` carries. */
|
|
53
|
-
const HISTORY_WINDOW = 24;
|
|
54
|
-
/** One message as a hook reads it: its role, its text, and any tool calls it made. */
|
|
55
|
-
function historyEntry(m) {
|
|
56
|
-
const msg = m;
|
|
57
|
-
const type = messageTypeOf(m) || "?";
|
|
58
|
-
const role = ROLE_BY_TYPE[type] ?? type;
|
|
59
|
-
const entry = { role, content: contentToString(msg.content) };
|
|
60
|
-
const toolCalls = msg.tool_calls;
|
|
61
|
-
if (Array.isArray(toolCalls) && toolCalls.length > 0) {
|
|
62
|
-
entry.toolCalls = toolCalls.map((c) => {
|
|
63
|
-
const call = c;
|
|
64
|
-
return { name: String(call.name ?? ""), args: call.args ?? {} };
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return entry;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Build the compact view a lifecycle hook and a rubric grader read: the last
|
|
71
|
-
* {@link HISTORY_WINDOW} messages plus the request that opened the session.
|
|
72
|
-
*
|
|
73
|
-
* `userRequest` is derived from the **whole** list, not the window: a grader
|
|
74
|
-
* asked whether the reply satisfies the request must see the request, and a
|
|
75
|
-
* session of more than a couple of tool-calling turns pushes the opening message
|
|
76
|
-
* out of any fixed window (issue #61).
|
|
77
|
-
*/
|
|
78
|
-
export function runContextFromMessages(messages) {
|
|
79
|
-
const all = Array.isArray(messages) ? messages : [];
|
|
80
|
-
const history = all.slice(-HISTORY_WINDOW).map(historyEntry);
|
|
81
|
-
const opening = all.find((m) => (ROLE_BY_TYPE[messageTypeOf(m) || "?"] ?? "") === "user");
|
|
82
|
-
const userRequest = opening !== undefined ? contentToString(opening.content) : "";
|
|
83
|
-
return { history, userRequest };
|
|
84
|
-
}
|
|
85
52
|
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/core/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEhF,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/core/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEhF,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAwB,MAAM,sBAAsB,CAAC;AAEtE,4FAA4F;AAC5F,oFAAoF;AACpF,OAAO,EACL,WAAW,EACX,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,aAAa,EACb,aAAa,EACb,SAAS,EACT,eAAe,EACf,0BAA0B,EAC1B,YAAY,EACZ,SAAS,GAGV,MAAM,sBAAsB,CAAC;AAE9B,0DAA0D;AAC1D,SAAS,MAAM,CAAC,IAAqB;IACnC,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,WAAW,CAAC,IAAqB,EAAE,IAAY;IAC7D,MAAM,MAAM,GAAG,QAAQ,UAAU,EAAE,EAAE,CAAC;IACtC,OAAO;QACL,IAAI,SAAS,CAAC;YACZ,OAAO,EAAE,EAAE;YACX,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;YACnE,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC;SAChC,CAAC;QACF,IAAI,WAAW,CAAC;YACd,OAAO,EAAE,IAAI;YACb,YAAY,EAAE,MAAM;YACpB,IAAI,EAAE,SAAS;YACf,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC;SAChC,CAAC;KACH,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,IAAqB,EAAE,IAAY;IAC3D,OAAO,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/core/mounts.js
CHANGED
|
@@ -104,9 +104,9 @@ export function resolveMounts(table = {}) {
|
|
|
104
104
|
* Deliberately short, and deliberately missing every {@link AUTHORING_PREFIXES}
|
|
105
105
|
* prefix. That plane is not workspace furniture the agent browses: it is what the
|
|
106
106
|
* runtime enforces the run *with*, served by the authoring backend and reachable by
|
|
107
|
-
* no tool call. `workflows/` holds the spec — its
|
|
108
|
-
* cannot read the criteria it is judged against — plus
|
|
109
|
-
* scripts, and the cases
|
|
107
|
+
* no tool call. `workflows/` holds the spec — its grader states' criteria
|
|
108
|
+
* included, so a session cannot read the criteria it is judged against — plus
|
|
109
|
+
* the prose addendum, the code-state scripts, and the cases testing the run.
|
|
110
110
|
*
|
|
111
111
|
* What ships in a skill bundle is the other kind of script — the ones the *agent*
|
|
112
112
|
* runs with `archmax_run` — together with the data a state reads
|