@archmax-ai/harness 0.7.1 → 0.9.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 +11 -4
- package/dist/agent.d.ts +4 -2
- package/dist/agent.js +4 -2
- package/dist/agent.js.map +1 -1
- package/dist/assembly/compose.d.ts +5 -3
- package/dist/assembly/compose.js +24 -8
- package/dist/assembly/compose.js.map +1 -1
- package/dist/assembly/index.d.ts +13 -2
- package/dist/assembly/index.js +35 -10
- package/dist/assembly/index.js.map +1 -1
- package/dist/authoring-skill/archmax-harness/SKILL.md +9 -5
- package/dist/authoring-skill/archmax-harness/references/backend-integration.md +12 -8
- package/dist/authoring-skill/archmax-harness/references/cases.md +3 -2
- package/dist/authoring-skill/archmax-harness/references/diagnostics.md +5 -3
- package/dist/authoring-skill/archmax-harness/references/hook-and-test-scripts.md +52 -7
- package/dist/authoring-skill/archmax-harness/references/hooks-and-scripts.md +2 -1
- package/dist/authoring-skill/archmax-harness/references/wiring.md +1 -1
- package/dist/authoring-skill/archmax-harness/references/workflow-schema.md +107 -46
- package/dist/authoring-skill/archmax-harness/references/workflow-yaml.md +43 -17
- package/dist/cli/turn.js +1 -2
- 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/deepagents.d.ts +9 -2
- package/dist/core/deepagents.js +15 -2
- package/dist/core/deepagents.js.map +1 -1
- package/dist/core/message-readers.d.ts +21 -0
- package/dist/core/message-readers.js +36 -0
- package/dist/core/message-readers.js.map +1 -1
- package/dist/core/messages.d.ts +8 -8
- package/dist/core/messages.js +11 -13
- package/dist/core/messages.js.map +1 -1
- package/dist/core/platform-prompt.generated.js +1 -1
- package/dist/core/platform-prompt.generated.js.map +1 -1
- package/dist/core/workspace-prompt.js +2 -1
- package/dist/core/workspace-prompt.js.map +1 -1
- package/dist/kernel/kernel.js +15 -10
- package/dist/kernel/kernel.js.map +1 -1
- package/dist/lifecycle/runner.d.ts +14 -0
- package/dist/lifecycle/runner.js +50 -4
- package/dist/lifecycle/runner.js.map +1 -1
- package/dist/lifecycle/tool-calls.d.ts +9 -0
- package/dist/lifecycle/tool-calls.js +57 -0
- package/dist/lifecycle/tool-calls.js.map +1 -0
- package/dist/lifecycle/transcript.d.ts +10 -6
- package/dist/lifecycle/transcript.js +15 -10
- package/dist/lifecycle/transcript.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 +77 -29
- package/dist/machine/lint-spec.js.map +1 -1
- package/dist/machine/machine.d.ts +38 -17
- package/dist/machine/machine.js +64 -32
- package/dist/machine/machine.js.map +1 -1
- package/dist/machine/spec-schema.d.ts +24 -13
- package/dist/machine/spec-schema.js +91 -15
- package/dist/machine/spec-schema.js.map +1 -1
- package/dist/machine/tool-names.d.ts +16 -7
- package/dist/machine/tool-names.js +17 -8
- package/dist/machine/tool-names.js.map +1 -1
- package/dist/machine/tool-paths.d.ts +10 -3
- package/dist/machine/tool-paths.js +14 -3
- package/dist/machine/tool-paths.js.map +1 -1
- package/dist/machine/types.d.ts +23 -9
- package/dist/machine/types.js +2 -0
- package/dist/machine/types.js.map +1 -1
- package/dist/machine/variables.d.ts +2 -0
- package/dist/machine/variables.js.map +1 -1
- package/dist/public/sandbox.d.ts +35 -3
- package/dist/public/sandbox.js +1 -1
- package/dist/public/sandbox.js.map +1 -1
- package/dist/public/spec.d.ts +5 -5
- package/dist/public/spec.js +4 -4
- package/dist/public/spec.js.map +1 -1
- package/dist/sandbox/executor.js +10 -0
- package/dist/sandbox/executor.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 +10 -5
- package/dist/sessions/resume.js +11 -8
- package/dist/sessions/resume.js.map +1 -1
- package/dist/sessions/scope.d.ts +10 -0
- package/dist/sessions/scope.js +17 -0
- package/dist/sessions/scope.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 +19 -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.js +1 -0
- package/dist/testing/interpreter.js.map +1 -1
- 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/control-tools.js +26 -2
- package/dist/workflow/control-tools.js.map +1 -1
- package/dist/workflow/governance.d.ts +3 -1
- package/dist/workflow/governance.js +27 -6
- package/dist/workflow/governance.js.map +1 -1
- package/dist/workflow/middleware.js +22 -4
- package/dist/workflow/middleware.js.map +1 -1
- package/dist/workflow/on-error.js +2 -0
- package/dist/workflow/on-error.js.map +1 -1
- package/dist/workflow/parks.js +2 -0
- package/dist/workflow/parks.js.map +1 -1
- package/dist/workflow/render-prompt.d.ts +2 -1
- package/dist/workflow/render-prompt.js +24 -5
- package/dist/workflow/render-prompt.js.map +1 -1
- package/dist/workflow/state.d.ts +41 -0
- package/dist/workflow/state.js +33 -4
- package/dist/workflow/state.js.map +1 -1
- package/dist/workflow/sub-workflow.js +7 -3
- package/dist/workflow/sub-workflow.js.map +1 -1
- package/dist/workflow/tool-service.d.ts +1 -1
- package/dist/workflow/tool-service.js +1 -1
- package/dist/workflow/tool-service.js.map +1 -1
- package/dist/workflow/turn-boundary.js +8 -0
- package/dist/workflow/turn-boundary.js.map +1 -1
- package/dist/workflow/turn-runner.js +36 -7
- package/dist/workflow/turn-runner.js.map +1 -1
- package/dist/workflow/visits.d.ts +21 -0
- package/dist/workflow/visits.js +45 -0
- package/dist/workflow/visits.js.map +1 -0
- package/package.json +1 -1
- package/skills/archmax-harness/SKILL.md +9 -5
- package/skills/archmax-harness/references/backend-integration.md +12 -8
- package/skills/archmax-harness/references/cases.md +3 -2
- package/skills/archmax-harness/references/diagnostics.md +5 -3
- package/skills/archmax-harness/references/hook-and-test-scripts.md +52 -7
- package/skills/archmax-harness/references/hooks-and-scripts.md +2 -1
- package/skills/archmax-harness/references/wiring.md +1 -1
- package/skills/archmax-harness/references/workflow-schema.md +107 -46
- package/skills/archmax-harness/references/workflow-yaml.md +43 -17
|
@@ -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 });
|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K,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,4BAA4B,gBAAgB,MAAO,GAAa,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAC9G,CAAC;AACH,CAAC"}
|
|
@@ -105,10 +105,17 @@ export declare function asModelCallResult(result: unknown, origin: string): Mode
|
|
|
105
105
|
* The `recursionLimit` a turn runs under when the caller names none. One invoke
|
|
106
106
|
* is one whole turn across states — every hook, model call and tool batch is a
|
|
107
107
|
* super-step — so this is generous by design: the authored budgets
|
|
108
|
-
* (`budget.maxTurns`, `maxParks`) are the real bound, and
|
|
109
|
-
* run nothing else bounds.
|
|
108
|
+
* (`budget.maxModelCalls`, `maxTurns`, `maxParks`) are the real bound, and
|
|
109
|
+
* this only stops a run nothing else bounds. A governed invocation runs under
|
|
110
|
+
* {@link turnStepLimit} of its workflow's turn budget, never below this.
|
|
110
111
|
*/
|
|
111
112
|
export declare const DEFAULT_RECURSION_LIMIT = 400;
|
|
113
|
+
/**
|
|
114
|
+
* The step limit an invocation runs under when the caller names none: enough that
|
|
115
|
+
* a workflow's turn budget, and the error handler it routes to, run out first, so
|
|
116
|
+
* the governed bound ends the turn and the step limit only stops what it missed.
|
|
117
|
+
*/
|
|
118
|
+
export declare function turnStepLimit(maxModelCalls: number): number;
|
|
112
119
|
/** The input a Deep Agent graph is invoked with: messages plus any state channel. */
|
|
113
120
|
export type AgentInput = Parameters<DeepAgent["invoke"]>[0];
|
|
114
121
|
/** The settled state a Deep Agent graph resolves to. */
|
package/dist/core/deepagents.js
CHANGED
|
@@ -101,10 +101,23 @@ function describeModelResult(result) {
|
|
|
101
101
|
* The `recursionLimit` a turn runs under when the caller names none. One invoke
|
|
102
102
|
* is one whole turn across states — every hook, model call and tool batch is a
|
|
103
103
|
* super-step — so this is generous by design: the authored budgets
|
|
104
|
-
* (`budget.maxTurns`, `maxParks`) are the real bound, and
|
|
105
|
-
* run nothing else bounds.
|
|
104
|
+
* (`budget.maxModelCalls`, `maxTurns`, `maxParks`) are the real bound, and
|
|
105
|
+
* this only stops a run nothing else bounds. A governed invocation runs under
|
|
106
|
+
* {@link turnStepLimit} of its workflow's turn budget, never below this.
|
|
106
107
|
*/
|
|
107
108
|
export const DEFAULT_RECURSION_LIMIT = 400;
|
|
109
|
+
/** Graph steps one model call takes, with a step to spare (an advance cycle measures about 7). */
|
|
110
|
+
const STEPS_PER_MODEL_CALL = 8;
|
|
111
|
+
/** Model calls past the turn budget an `on_error` handler may make before the step limit stops it. */
|
|
112
|
+
const HANDLER_CALLS = 10;
|
|
113
|
+
/**
|
|
114
|
+
* The step limit an invocation runs under when the caller names none: enough that
|
|
115
|
+
* a workflow's turn budget, and the error handler it routes to, run out first, so
|
|
116
|
+
* the governed bound ends the turn and the step limit only stops what it missed.
|
|
117
|
+
*/
|
|
118
|
+
export function turnStepLimit(maxModelCalls) {
|
|
119
|
+
return Math.max(DEFAULT_RECURSION_LIMIT, (maxModelCalls + HANDLER_CALLS) * STEPS_PER_MODEL_CALL);
|
|
120
|
+
}
|
|
108
121
|
/**
|
|
109
122
|
* Narrow a compiled graph to {@link CompiledAgentGraph}. The governed and plain
|
|
110
123
|
* graphs' declared state generics differ, so neither is assignable to a shared
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepagents.js","sourceRoot":"","sources":["../../src/core/deepagents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AA+GrD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA4C;IAC5E,OAAO,CAAC,KAAK,IAAI,EAAE,CAAgC,CAAC;AACtD,CAAC;AAgBD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK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AAK,KAAK,GAAG,CAAC;AACtD,CAAC;AAED,iFAAiF;AAEjF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,kGAAkG;AAClG,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,sGAAsG;AACtG,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,aAAqB;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,CAAC,aAAa,GAAG,aAAa,CAAC,GAAG,oBAAoB,CAAC,CAAC;AACnG,CAAC;AAmCD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,KAA2B,CAAC;AACrC,CAAC;AAkCD;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,KAA0B;IACxD,OAAO,KAA4C,CAAC;AACtD,CAAC"}
|
|
@@ -26,6 +26,27 @@ 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. A completion check's revision request
|
|
46
|
+
* (an `after` note) takes back what came before it, so a rejected draft never
|
|
47
|
+
* reaches the person; no other note does. Empty when the turn said nothing.
|
|
48
|
+
*/
|
|
49
|
+
export declare function turnReply(messages: unknown[], anchor: TurnAnchor): string;
|
|
29
50
|
/**
|
|
30
51
|
* What the runtime wrote into a transcript, and why.
|
|
31
52
|
*
|
|
@@ -56,6 +56,42 @@ 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. A completion check's revision request
|
|
78
|
+
* (an `after` note) takes back what came before it, so a rejected draft never
|
|
79
|
+
* reaches the person; no other note does. Empty when the turn said nothing.
|
|
80
|
+
*/
|
|
81
|
+
export function turnReply(messages, anchor) {
|
|
82
|
+
const start = anchorIndex(messages, anchor);
|
|
83
|
+
let said = [];
|
|
84
|
+
for (const message of messages.slice(start)) {
|
|
85
|
+
if (runtimeNoteKind(message) === "after")
|
|
86
|
+
said = [];
|
|
87
|
+
if (!isAiMessage(message) || isRuntimeNote(message))
|
|
88
|
+
continue;
|
|
89
|
+
const text = contentToString(message.content).trim();
|
|
90
|
+
if (text)
|
|
91
|
+
said.push(text);
|
|
92
|
+
}
|
|
93
|
+
return said.join("\n\n");
|
|
94
|
+
}
|
|
59
95
|
/** Where the marker lives on a message: `additional_kwargs.archmax.note`. */
|
|
60
96
|
export const NOTE_KEY = "archmax";
|
|
61
97
|
/**
|
|
@@ -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,EAAE,EAAE;QAC/C,GAAG,CAAC,IAAI;QACR,GAAG,CAAC,IAAI;QACR,EAAE,CAAC;IACL,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,MAAM,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACjC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,WAAW,CAAC;AACzC,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,MAAM,CAAC,GAAG,aAAa,CAAC,OA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AAM,GAAG,CAAC,CAAC;IAC9B,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,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
|
|
@@ -38,12 +38,12 @@ export interface RunContext {
|
|
|
38
38
|
userRequest: string;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* Build the
|
|
42
|
-
*
|
|
41
|
+
* Build the view a rubric grader reads: the messages from `visitStart` on (the
|
|
42
|
+
* visit its hook sees) plus the person's latest message.
|
|
43
43
|
*
|
|
44
|
-
* `userRequest` is
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
44
|
+
* `userRequest` is read from the **whole** list, not the visit: a grader asked
|
|
45
|
+
* whether the reply satisfies the request must see the request, which an
|
|
46
|
+
* earlier state usually received (issue #61). It is the latest user message,
|
|
47
|
+
* not the first: a later turn is answering the question asked in that turn.
|
|
48
48
|
*/
|
|
49
|
-
export declare function runContextFromMessages(messages: unknown[]): RunContext;
|
|
49
|
+
export declare function runContextFromMessages(messages: unknown[], visitStart?: number): RunContext;
|
package/dist/core/messages.js
CHANGED
|
@@ -4,7 +4,7 @@ import { NOTE_TOOL } from "../machine/tool-names.js";
|
|
|
4
4
|
import { contentToString, messageTypeOf, NOTE_KEY, ROLE_BY_TYPE } 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,8 +49,6 @@ 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
52
|
/** One message as a hook reads it: its role, its text, and any tool calls it made. */
|
|
55
53
|
function historyEntry(m) {
|
|
56
54
|
const msg = m;
|
|
@@ -67,19 +65,19 @@ function historyEntry(m) {
|
|
|
67
65
|
return entry;
|
|
68
66
|
}
|
|
69
67
|
/**
|
|
70
|
-
* Build the
|
|
71
|
-
*
|
|
68
|
+
* Build the view a rubric grader reads: the messages from `visitStart` on (the
|
|
69
|
+
* visit its hook sees) plus the person's latest message.
|
|
72
70
|
*
|
|
73
|
-
* `userRequest` is
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
71
|
+
* `userRequest` is read from the **whole** list, not the visit: a grader asked
|
|
72
|
+
* whether the reply satisfies the request must see the request, which an
|
|
73
|
+
* earlier state usually received (issue #61). It is the latest user message,
|
|
74
|
+
* not the first: a later turn is answering the question asked in that turn.
|
|
77
75
|
*/
|
|
78
|
-
export function runContextFromMessages(messages) {
|
|
76
|
+
export function runContextFromMessages(messages, visitStart = 0) {
|
|
79
77
|
const all = Array.isArray(messages) ? messages : [];
|
|
80
|
-
const history = all.slice(
|
|
81
|
-
const
|
|
82
|
-
const userRequest =
|
|
78
|
+
const history = all.slice(visitStart).map(historyEntry);
|
|
79
|
+
const latest = [...all].reverse().find((m) => (ROLE_BY_TYPE[messageTypeOf(m) || "?"] ?? "") === "user");
|
|
80
|
+
const userRequest = latest !== undefined ? contentToString(latest.content) : "";
|
|
83
81
|
return { history, userRequest };
|
|
84
82
|
}
|
|
85
83
|
//# 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,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAwB,MAAM,sBAAsB,CAAC;AAEpH,4FAA4F;AAC5F,oFAAoF;AACpF,OAAO,EACL,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,aAAa,EACb,aAAa,EACb,SAAS,EACT,eAAe,EACf,0BAA0B,
|
|
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,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAwB,MAAM,sBAAsB,CAAC;AAEpH,4FAA4F;AAC5F,oFAAoF;AACpF,OAAO,EACL,WAAW,EACX,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,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AAW,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Generated from platform-prompt.md by scripts/generate-platform-prompt.mjs. Do not edit.
|
|
2
2
|
/** The bundled platform prompt: how to move through the graph and which tools are the runtime's. */
|
|
3
|
-
export const PLATFORM_PROMPT = "# Graph state execution\n\nYou run inside a **declarative workflow graph**: you occupy one **state** at a\ntime, and its spec governs which tools you may call and which files you may read\nor write.\n\n## How you move\n\n<!-- top-level-only -->\n1. **Name the run first.** Before anything else in your first turn, call\n **`archmax_set_variables({ \"variables\": { \"title\": \"<a few words>\" } })`** — see\n \"Naming the run\" below.\n<!-- /top-level-only -->\n2. Do the current state's work. Write files where its instructions or listed\n mounts say; `scratchpad
|
|
3
|
+
export const PLATFORM_PROMPT = "# Graph state execution\n\nYou run inside a **declarative workflow graph**: you occupy one **state** at a\ntime, and its spec governs which tools you may call and which files you may read\nor write.\n\n## How you move\n\n<!-- top-level-only -->\n1. **Name the run first.** Before anything else in your first turn, call\n **`archmax_set_variables({ \"variables\": { \"title\": \"<a few words>\" } })`** — see\n \"Naming the run\" below.\n<!-- /top-level-only -->\n2. Do the current state's work. Write files where its instructions or listed\n mounts say; `scratchpad/` is only the default.\n3. Call **`archmax_advance({ \"to\": \"<next>\", \"reason\": \"<one sentence>\" })`**,\n choosing `to` from the transitions under \"Current state\" by their descriptions.\n `to` takes the target's **slug** — the backticked token on the transition line.\n A parenthesized note gives the edge's type (`approve`, `reject`, `refine`) and\n marks a **human decision node** or a **terminal** target. A state with no\n transitions says so: the run ends there, so finish its work and stop.\n4. The runtime validates the edge and runs this state's `after` hook and then the\n target's `before` hook — either may send you back to correct or veto the move —\n before the next state's tools unlock.\n\n**One transition per message.** A second `archmax_advance` in the same message is\nrefused; chain states over successive turns.\n\n**Text alone ends your turn.** A message with no tool call is the last thing you\ndo until someone writes again: the run stays where it is, and whatever you meant\nto do next never happens. So when the work is to tell the person something *and\nthen* advance, wait or raise, write that text and make the call in the **same\nmessage**.\n\n**A conversation keeps its position.** A new message finds you in the state your\nlast turn ended in. When that state can serve it, stay and answer there: a new\nmessage is not a reason to reset. If it cannot — no transition reaches what was\nasked, or an earlier turn took a wrong path — call\n**`archmax_reset({ \"reason\": \"<one sentence>\" })`** to return to the state the\nconversation began in. The conversation and every file written so far are kept.\nA reset only ever goes back there, so never call it while you are still in that\nstate — nothing has moved you out of it since the conversation began or since\nyour last reset.\n\n**A terminal state you moved into never serves a follow-up.** When a message lands\non a run that was *already sitting* in a terminal state it moved into, reset\n**before** answering, or you skip every state the answer depends on. Three cases\ntake no reset: a run you parked with `archmax_wait`, which resumes where it was on\npurpose; a terminal state you were routed into *this turn*, by your own advance or\na person's decision — do its work, then stop; and a terminal state the\nconversation began in, where a reset would leave you exactly where you are —\nanswer there. Never reset out of a state you just arrived in, and never\n`archmax_wait` for the runtime to move you.\n\n### Waiting and deciding\n\n- Something has to **arrive** from outside the run — an event, a callback, a reply\n someone sends in their own time → call\n **`archmax_wait({ \"reason\": \"<what you are waiting for>\" })`** and stop. You\n resume in **this same state**, with what arrived in your transcript and any\n values it carried in the variables. Waiting for a *time*? Add `\"until\": \"1d\"` (a\n duration or an ISO-8601 instant); an earlier event still resumes you.\n- Someone has to **decide**, approve, review or choose → `archmax_advance` into the\n **human decision node** the author declared for it. The runtime parks the run\n there and presents the options itself: do the work its transitions require,\n advance in, and stop. Never advance out of one yourself, and never `archmax_wait`\n to ask for a decision.\n\n### When the work fails\n\nIf the task **cannot be completed** — a system it depends on keeps failing, what it\nneeds does not exist, the request is one this workflow cannot serve — try to\nrecover once or twice (a retry, another tool, another approach). If that fails\ntoo, call **`archmax_raise({ \"code\": \"<short-token>\", \"reason\": \"<what failed>\" })`**:\nit ends the session as a failure from any state, and whoever started the run\nreads your `code` (e.g. `orders-unavailable`) and `reason`. **When you are about to\ntell the person the task cannot be done, make that call in the same message**: the\nmessage's text is what they read, and no other tool call goes with it. A reply\nthat only explains the failure ends the run as a success. Never raise to finish\nwork that worked, or in place of `archmax_wait`, `archmax_reset` or a human node.\n\n### The state you are in\n\nThe active state's **`instructions`** arrive under a \"Current state\" heading:\nfollow them. You are shown the edges out of this state and nothing else of the\ngraph — there is no map of the workflow to consult. Do not guess at slugs, and do\nnot treat a state named anywhere else (a message, a file, your own earlier turns)\nas somewhere you can move to. Skills the state may use are listed under \"Skills\navailable in this state\", each naming the `SKILL.md` to read first.\n\n**`before`/`after` hooks** run on their own and may approve, ask for a\ncorrection, or block the run: fix the work rather than arguing with it.\n\n## Tools\n\nTool access is **closed by default**: you see only the active state's tools, and\na state may narrow a tool's arguments (e.g. `write_file` to one path). Tools named\n`archmax_*` are the runtime's controls. A blocked call names the tool, the state\nand the policy: fix the call, or advance if you are done.\n\n**Write code instead of many calls.** **`archmax_eval({ \"code\": \"…\" })`**, when\nyour tools include it, runs JavaScript in a sandbox where `tools.*` calls your tools,\ngoverned exactly as your own calls are. Reach for it by default for loops,\nfilters, arithmetic, or more than about two calls whose results feed each other:\n**only your last expression and whatever you `console.log` come back to you**, so\nthe rest of what those tools returned never enters the conversation. The REPL\nkeeps its state between calls. Your code cannot read the run's variables:\ninterpolate a scalar one into it with `${{name}}` (below), or use\n**`archmax_run({ \"file_path\": \"…\" })`**, the same sandbox subject to the state's\npath constraints, whose script receives whole structured values as\n`args.variables`.\n\n<!-- top-level-only -->\n**Naming the run.** `title` is a reserved run variable: a one-line label of a few\nwords (`Refund for order A-1042`) that tells this run apart in a list of runs.\nThis is step 1 above, and it is not optional. Write it from what the request\nalready says, **before** the state's own work and before any other tool call — it\nis a label, not a plan, so never read anything to produce one — and it still goes\nfirst when the state's instructions tell you to do something else first. After\nthat, leave it alone unless the conversation **as a whole** has moved to a\nsubject the old title no longer describes. Judge that against the whole\nconversation, not its latest message: a follow-up, a detail, a correction or a\nside question on the same subject keeps the title. When you do rename, name what\nthe whole conversation is about. Never pass `lock` with it: that call is refused.\n\n<!-- /top-level-only -->\n**Reference a run variable instead of retyping it.** In any text argument,\n`${{name}}` (or `${{name.path.to.value}}`) is replaced with that variable's value\nbefore the call runs, also **inside** a longer string and as often as you like:\n\n```\n\"Thanks — your refund is on its way.\n\n--- Original message ---\n\n${{inbound.text}}\"\n```\n\nPrefer the reference to writing the value out: the value is what you spend tokens\non, and a reference cannot paraphrase, truncate or mistype it.\n`archmax_get_variables` shows what is set; a reference that does not resolve\nrefuses the call and says why. To write `${{…}}` literally, double the dollar:\n`$${{name}}`.\n";
|
|
4
4
|
//# sourceMappingURL=platform-prompt.generated.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-prompt.generated.js","sourceRoot":"","sources":["../../src/core/platform-prompt.generated.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAE1F,oGAAoG;AACpG,MAAM,CAAC,MAAM,eAAe,GAAW,
|
|
1
|
+
{"version":3,"file":"platform-prompt.generated.js","sourceRoot":"","sources":["../../src/core/platform-prompt.generated.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAE1F,oGAAoG;AACpG,MAAM,CAAC,MAAM,eAAe,GAAW,4+PAA4+P,CAAC"}
|
|
@@ -54,7 +54,8 @@ export function renderWorkspaceZones(mounts = NO_MOUNTS) {
|
|
|
54
54
|
const writable = mountNames(mounts, true);
|
|
55
55
|
const bullets = [
|
|
56
56
|
`- **\`${SESSION_OPEN_DIR}/\`** — your working area: intermediate files and the ` +
|
|
57
|
-
`artifacts you produce.
|
|
57
|
+
`artifacts you produce. Readable and writable in every state, with the file tools ` +
|
|
58
|
+
`that state gives you.`,
|
|
58
59
|
`- **${offload}** — where the runtime parks oversized tool results and ` +
|
|
59
60
|
`history. Read them when handed a path (paginate with \`read_file\` offset/limit); ` +
|
|
60
61
|
`you cannot write there.`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-prompt.js","sourceRoot":"","sources":["../../src/core/workspace-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,gBAAgB,GAEjB,MA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K,CAAC,IAAI,CACR,mFAAmF;gBACjF,8EAA8E,CACjF,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,CAAC,CAAyC,EAAE,EAAE,CAC9E,SAAS,CAAC,CAAC,KAAK,QAAQ,OAAO,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC1E,OAAO,CAAC,IAAI,CACV,yFAAyF,EACzF,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,EAClC,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACnC,yEAAyE;QACzE,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CACvB,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,IAAI,CACV,8EAA8E;QAC5E,6EAA6E,CAChF,CAAC;IACF,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,4EAA4E;QAC5E,qEAAqE;QACrE,OAAO,CAAC,IAAI,CACV,kFAAkF;YAChF,qFAAqF;YACrF,kCAAkC,CACrC,CAAC;IACJ,CAAC;IAED,OAAO;QACL,oBAAoB;QACpB,EAAE;QACF,4EAA4E;QAC5E,8EAA8E;QAC9E,EAAE;QACF,GAAG,OAAO;KACX,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
package/dist/kernel/kernel.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ADVANCE_TOOL,
|
|
1
|
+
import { ADVANCE_TOOL, DEFAULT_TOOLS, HARNESS_CONTROL_TOOLS, EVAL_TOOL, SET_VARIABLES_TOOL, UNGRANTABLE_TOOLS, } from "../machine/tool-names.js";
|
|
2
2
|
import { FORBID_ANY_TOOL } from "../machine/spec-schema.js";
|
|
3
3
|
import { argsSatisfy, normalizeAllowEntry, pathGuardMatches, } from "../machine/allow.js";
|
|
4
|
-
import { BUILT_IN_TOOL_PATH_TABLE, declaredPathsOf, malformedPathArgs, MUTATING_ACCESSES, OFFLOAD_ACCESSES, pathValuesOf, SCRATCHPAD_ACCESSES, } from "../machine/tool-paths.js";
|
|
4
|
+
import { BUILT_IN_TOOL_PATH_TABLE, declaredPathsOf, malformedPathArgs, MUTATING_ACCESSES, OFFLOAD_ACCESSES, pathArgNamesOf, pathValuesOf, SCRATCHPAD_ACCESSES, } from "../machine/tool-paths.js";
|
|
5
5
|
import { unmetRequirements } from "../workflow/control-tools.js";
|
|
6
6
|
import { canonicalizeRelPath } from "../core/workspace.js";
|
|
7
7
|
import { classifyWorkspacePath, mountNameOf, SESSION_INTERNAL_DIRS, SESSION_OFFLOAD_DIRS, SESSION_OPEN_DIR, } from "../core/zones.js";
|
|
@@ -562,17 +562,21 @@ export function compileForbiddenSkillRules(slugs, source) {
|
|
|
562
562
|
* still block it), just ahead of the per-state defaults — so it loosens only
|
|
563
563
|
* the state `allow` list, never the governed run paths outside it.
|
|
564
564
|
*
|
|
565
|
-
* It opens these areas only to
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
*
|
|
569
|
-
*
|
|
570
|
-
*
|
|
565
|
+
* It opens these areas only to a default file tool the active state is granted
|
|
566
|
+
* — by the workflow-wide grant or its own entry, whatever that entry narrows —
|
|
567
|
+
* and to the host's `essentialTools` (see {@link WorkflowMachine.opensWorkingAreas}).
|
|
568
|
+
* A default tool the state is not granted gets nothing here, so the areas never
|
|
569
|
+
* make a withheld tool callable. Any other tool is left to the state's grant:
|
|
570
|
+
* declaring a host tool's path arguments only ever narrows what it may do, and
|
|
571
|
+
* never makes it callable in a state that does not grant it.
|
|
571
572
|
*/
|
|
572
573
|
const runOpenAccessRule = (action, api) => {
|
|
573
574
|
if (action.kind !== "tool-call")
|
|
574
575
|
return null;
|
|
575
|
-
|
|
576
|
+
const opens = api.machine
|
|
577
|
+
? api.machine.opensWorkingAreas(action.state, action.tool)
|
|
578
|
+
: DEFAULT_TOOLS.has(action.tool);
|
|
579
|
+
if (!opens)
|
|
576
580
|
return null;
|
|
577
581
|
const paths = pathsOf(action, api);
|
|
578
582
|
if (paths.length === 0)
|
|
@@ -814,9 +818,10 @@ function denialMatches(entry, action, api) {
|
|
|
814
818
|
return pathGuardMatches(entry, values, "any", variables) ?? true;
|
|
815
819
|
}
|
|
816
820
|
let unresolved = false;
|
|
821
|
+
const kinds = { pathArgs: pathArgNamesOf(action.tool, toolPathsOf(action.tool, api)), side: "deny" };
|
|
817
822
|
const satisfied = argsSatisfy(entry.argMatchers, action.args, variables, () => {
|
|
818
823
|
unresolved = true;
|
|
819
|
-
});
|
|
824
|
+
}, kinds);
|
|
820
825
|
return satisfied || unresolved;
|
|
821
826
|
}
|
|
822
827
|
/**
|