harness-reflex 0.0.0-stage → 0.3.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/CHANGELOG.md +20 -0
- package/README.md +266 -2
- package/USER_GUIDE.md +639 -0
- package/dist/adapters/agy.d.ts +8 -0
- package/dist/adapters/agy.js +80 -0
- package/dist/adapters/agy.js.map +1 -0
- package/dist/adapters/claude.d.ts +13 -0
- package/dist/adapters/claude.js +46 -0
- package/dist/adapters/claude.js.map +1 -0
- package/dist/adapters/codex.d.ts +139 -0
- package/dist/adapters/codex.js +368 -0
- package/dist/adapters/codex.js.map +1 -0
- package/dist/backend/defaults.d.ts +31 -0
- package/dist/backend/defaults.js +32 -0
- package/dist/backend/defaults.js.map +1 -0
- package/dist/backend/factory.d.ts +11 -0
- package/dist/backend/factory.js +40 -0
- package/dist/backend/factory.js.map +1 -0
- package/dist/backend/jev.d.ts +524 -0
- package/dist/backend/jev.js +1486 -0
- package/dist/backend/jev.js.map +1 -0
- package/dist/backend/mock.d.ts +26 -0
- package/dist/backend/mock.js +320 -0
- package/dist/backend/mock.js.map +1 -0
- package/dist/backend/route-prompt.d.ts +37 -0
- package/dist/backend/route-prompt.js +42 -0
- package/dist/backend/route-prompt.js.map +1 -0
- package/dist/backend/simple-jev.d.ts +35 -0
- package/dist/backend/simple-jev.js +273 -0
- package/dist/backend/simple-jev.js.map +1 -0
- package/dist/backend/types.d.ts +270 -0
- package/dist/backend/types.js +5 -0
- package/dist/backend/types.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +278 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/calibrate.d.ts +56 -0
- package/dist/core/calibrate.js +144 -0
- package/dist/core/calibrate.js.map +1 -0
- package/dist/core/closing.d.ts +90 -0
- package/dist/core/closing.js +111 -0
- package/dist/core/closing.js.map +1 -0
- package/dist/core/evidence.d.ts +119 -0
- package/dist/core/evidence.js +209 -0
- package/dist/core/evidence.js.map +1 -0
- package/dist/core/gate.d.ts +25 -0
- package/dist/core/gate.js +114 -0
- package/dist/core/gate.js.map +1 -0
- package/dist/core/judge.d.ts +221 -0
- package/dist/core/judge.js +251 -0
- package/dist/core/judge.js.map +1 -0
- package/dist/core/ledger.d.ts +67 -0
- package/dist/core/ledger.js +173 -0
- package/dist/core/ledger.js.map +1 -0
- package/dist/core/orchestrate-closing.d.ts +237 -0
- package/dist/core/orchestrate-closing.js +250 -0
- package/dist/core/orchestrate-closing.js.map +1 -0
- package/dist/core/orchestrate-correction.d.ts +209 -0
- package/dist/core/orchestrate-correction.js +141 -0
- package/dist/core/orchestrate-correction.js.map +1 -0
- package/dist/core/orchestrate-host.d.ts +225 -0
- package/dist/core/orchestrate-host.js +80 -0
- package/dist/core/orchestrate-host.js.map +1 -0
- package/dist/core/orchestrate-stagnation.d.ts +259 -0
- package/dist/core/orchestrate-stagnation.js +270 -0
- package/dist/core/orchestrate-stagnation.js.map +1 -0
- package/dist/core/orchestrate.d.ts +357 -0
- package/dist/core/orchestrate.js +418 -0
- package/dist/core/orchestrate.js.map +1 -0
- package/dist/core/policy.d.ts +122 -0
- package/dist/core/policy.js +102 -0
- package/dist/core/policy.js.map +1 -0
- package/dist/core/prune-plan.d.ts +141 -0
- package/dist/core/prune-plan.js +390 -0
- package/dist/core/prune-plan.js.map +1 -0
- package/dist/core/prune.d.ts +30 -0
- package/dist/core/prune.js +73 -0
- package/dist/core/prune.js.map +1 -0
- package/dist/core/route.d.ts +35 -0
- package/dist/core/route.js +39 -0
- package/dist/core/route.js.map +1 -0
- package/dist/core/score.d.ts +40 -0
- package/dist/core/score.js +49 -0
- package/dist/core/score.js.map +1 -0
- package/dist/core/screen.d.ts +22 -0
- package/dist/core/screen.js +117 -0
- package/dist/core/screen.js.map +1 -0
- package/dist/core/stagnation.d.ts +23 -0
- package/dist/core/stagnation.js +93 -0
- package/dist/core/stagnation.js.map +1 -0
- package/dist/core/text.d.ts +36 -0
- package/dist/core/text.js +66 -0
- package/dist/core/text.js.map +1 -0
- package/dist/hook/cli.d.ts +9 -0
- package/dist/hook/cli.js +52 -0
- package/dist/hook/cli.js.map +1 -0
- package/dist/hook/contract.d.ts +125 -0
- package/dist/hook/contract.js +159 -0
- package/dist/hook/contract.js.map +1 -0
- package/dist/hook/decision.d.ts +97 -0
- package/dist/hook/decision.js +955 -0
- package/dist/hook/decision.js.map +1 -0
- package/dist/hook/memory-store.d.ts +81 -0
- package/dist/hook/memory-store.js +157 -0
- package/dist/hook/memory-store.js.map +1 -0
- package/dist/hook/payload.d.ts +55 -0
- package/dist/hook/payload.js +129 -0
- package/dist/hook/payload.js.map +1 -0
- package/dist/hook/run.d.ts +48 -0
- package/dist/hook/run.js +218 -0
- package/dist/hook/run.js.map +1 -0
- package/dist/hook/store-port.d.ts +72 -0
- package/dist/hook/store-port.js +2 -0
- package/dist/hook/store-port.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/server.d.ts +12 -0
- package/dist/mcp/server.js +368 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/ports/audit.d.ts +18 -0
- package/dist/ports/audit.js +11 -0
- package/dist/ports/audit.js.map +1 -0
- package/dist/ports/clock.d.ts +14 -0
- package/dist/ports/clock.js +11 -0
- package/dist/ports/clock.js.map +1 -0
- package/dist/ports/decision.d.ts +75 -0
- package/dist/ports/decision.js +2 -0
- package/dist/ports/decision.js.map +1 -0
- package/dist/ports/index.d.ts +14 -0
- package/dist/ports/index.js +2 -0
- package/dist/ports/index.js.map +1 -0
- package/dist/ports/log.d.ts +22 -0
- package/dist/ports/log.js +12 -0
- package/dist/ports/log.js.map +1 -0
- package/dist/ports/state.d.ts +46 -0
- package/dist/ports/state.js +13 -0
- package/dist/ports/state.js.map +1 -0
- package/dist/state/clock.d.ts +40 -0
- package/dist/state/clock.js +43 -0
- package/dist/state/clock.js.map +1 -0
- package/dist/state/file-store.d.ts +340 -0
- package/dist/state/file-store.js +849 -0
- package/dist/state/file-store.js.map +1 -0
- package/dist/state/paths.d.ts +41 -0
- package/dist/state/paths.js +73 -0
- package/dist/state/paths.js.map +1 -0
- package/docs/USER_GUIDE.en.md +721 -0
- package/docs/claude-code.md +281 -0
- package/docs/design/v0.2.0-harness-plugins.md +381 -0
- package/docs/design/v0.3.0-orchestration-unification.md +580 -0
- package/docs/dsh-plugin.md +578 -0
- package/docs/reflex-ui-regression-2026-10-20.md +34 -0
- package/docs/release-checklist-v0.1.0.md +315 -0
- package/docs/release-handbook-porting-notes.md +106 -0
- package/docs/release-handbook.md +393 -0
- package/docs/release-notes-v0.1.0.md +63 -0
- package/docs/release-notes-v0.3.0.md +152 -0
- package/docs/research/claude-code-harness.md +607 -0
- package/docs/research/pi-harness.md +621 -0
- package/experiments/data/calibration_sample.json +14 -0
- package/experiments/index.ts +29 -0
- package/experiments/runner.ts +156 -0
- package/package.json +82 -4
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host-independent hook decision.
|
|
3
|
+
*
|
|
4
|
+
* Everything a command-hook run needs in order to *decide* lives here: the
|
|
5
|
+
* per-event handlers, the budget accounting, the idempotency commit, and the
|
|
6
|
+
* audit line. It knows nothing about stdin, stdout, exit codes, timeouts, or
|
|
7
|
+
* signals — those are properties of one delivery mechanism (a child process per
|
|
8
|
+
* event) and stay in `run.ts`.
|
|
9
|
+
*
|
|
10
|
+
* The separation exists because the same decisions must run in hosts that do not
|
|
11
|
+
* fork: the DSH plugin, a pi extension, and an opencode plugin all intercept in
|
|
12
|
+
* process and call this class directly with their own {@link HookStorePort}.
|
|
13
|
+
*
|
|
14
|
+
* @module hook/decision
|
|
15
|
+
*/
|
|
16
|
+
import type { DecisionBackend } from '../backend/types.js';
|
|
17
|
+
import type { HookClock } from '../state/clock.js';
|
|
18
|
+
import type { HookStorePort } from './store-port.js';
|
|
19
|
+
import { type EventBudget, type HookEvent, type HookMode, type HookOutput } from './contract.js';
|
|
20
|
+
export declare const MAX_STDIN_BYTES: number;
|
|
21
|
+
/** Resolved hook configuration; every number has a documented default. */
|
|
22
|
+
export interface HookConfig {
|
|
23
|
+
maxInterventionsPerTurn: number;
|
|
24
|
+
maxJudgmentsPerTurn: number;
|
|
25
|
+
maxJudgmentsPerSession: number;
|
|
26
|
+
repeatThreshold: number;
|
|
27
|
+
failureThreshold: number;
|
|
28
|
+
windowSize: number;
|
|
29
|
+
minConfidence: number;
|
|
30
|
+
pruneThreshold: number;
|
|
31
|
+
pruneMinLines: number;
|
|
32
|
+
maxRetainedChars: number;
|
|
33
|
+
pruneFloorRatio: number;
|
|
34
|
+
pruneHeadChars: number;
|
|
35
|
+
pruneTailChars: number;
|
|
36
|
+
claimMinConfidence: number;
|
|
37
|
+
closingEvidenceChars: number;
|
|
38
|
+
closingIntent: string;
|
|
39
|
+
maxClosingBlocksPerTurn: number;
|
|
40
|
+
eventBudgets: Record<HookEvent, EventBudget>;
|
|
41
|
+
}
|
|
42
|
+
/** Defaults mirrored from the DSH intervention policy (config.ts). */
|
|
43
|
+
export declare const DEFAULT_HOOK_CONFIG: HookConfig;
|
|
44
|
+
/** A stable label for `meta.mode`, the only place a single mode string is stored. */
|
|
45
|
+
export type HookCapability = 'stagnation' | 'prune' | 'gate' | 'closing';
|
|
46
|
+
/** One resolved mode per capability. */
|
|
47
|
+
export type HookModeMap = Record<HookCapability, HookMode>;
|
|
48
|
+
/** A stable label for `meta.mode`, the only place a single mode string is stored. */
|
|
49
|
+
export declare function modeLabel(modes: HookModeMap): string;
|
|
50
|
+
/**
|
|
51
|
+
* The S3 default: the three tool-call interventions act, the closing check only
|
|
52
|
+
* observes. A closing block is the most destructive action available (it keeps
|
|
53
|
+
* the user's turn open), so it ships opt-in (design §4.2).
|
|
54
|
+
*/
|
|
55
|
+
export declare const DEFAULT_CAPABILITY_MODES: HookModeMap;
|
|
56
|
+
/**
|
|
57
|
+
* Resolve the per-capability modes.
|
|
58
|
+
*
|
|
59
|
+
* Precedence, highest first:
|
|
60
|
+
* 1. `HARNESS_REFLEX_MODE` — one global override, kept for the S2 fixtures and
|
|
61
|
+
* for users who want to silence or shadow the whole layer;
|
|
62
|
+
* 2. a capability's own `HARNESS_REFLEX_<CAP>_MODE`;
|
|
63
|
+
* 3. the plugin's `userConfig` option, exported as `CLAUDE_PLUGIN_OPTION_<KEY>`
|
|
64
|
+
* (only `closing` has one: `closing_mode`, default `observe`);
|
|
65
|
+
* 4. the S3 defaults in {@link DEFAULT_CAPABILITY_MODES}.
|
|
66
|
+
*
|
|
67
|
+
* @param env - environment to read.
|
|
68
|
+
* @returns one mode per capability.
|
|
69
|
+
*/
|
|
70
|
+
export declare function resolveHookModes(env?: NodeJS.ProcessEnv): HookModeMap;
|
|
71
|
+
/** One string field, when it is a non-empty string. */
|
|
72
|
+
export declare function stringField(value: unknown): string | undefined;
|
|
73
|
+
/** The text a tool result shows the model, from any of the host's shapes. */
|
|
74
|
+
export declare function toolResponseText(response: unknown): string;
|
|
75
|
+
/** The dedupe key of design §2.5, extended for the events without a call id. */
|
|
76
|
+
export declare function dedupeKeyFor(event: HookEvent, payload: Record<string, unknown>): string;
|
|
77
|
+
export declare class HookDecision {
|
|
78
|
+
#private;
|
|
79
|
+
constructor(args: {
|
|
80
|
+
store: HookStorePort;
|
|
81
|
+
backend: DecisionBackend;
|
|
82
|
+
config: HookConfig;
|
|
83
|
+
modes: HookModeMap;
|
|
84
|
+
sessionId: string;
|
|
85
|
+
clock: HookClock;
|
|
86
|
+
stderr: (message: string) => void;
|
|
87
|
+
});
|
|
88
|
+
/** Mark the turn as timed out: later completion must not write anything. */
|
|
89
|
+
abort(): void;
|
|
90
|
+
/** The current turn number, from the discardable cache. */
|
|
91
|
+
turnNo(): number;
|
|
92
|
+
/** Append an error record; never throws and never becomes a decision. */
|
|
93
|
+
auditError(event: HookEvent, reason: string, message: string, key: string): void;
|
|
94
|
+
/** Dispatch one event. Callers have already ensured the session exists. */
|
|
95
|
+
handle(event: HookEvent, payload: Record<string, unknown>, budget: EventBudget): Promise<HookOutput>;
|
|
96
|
+
}
|
|
97
|
+
/** Run one hook invocation. Never throws; failure is always `{}` + exit 0. */
|