@jitsusama/agentic-harness.core 0.1.0 → 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/dist/bin/cli.js +7 -0
- package/dist/bin/web.d.ts +30 -0
- package/dist/bin/web.js +97 -0
- package/dist/observability/index.d.ts +8 -0
- package/dist/observability/index.js +8 -0
- package/dist/observability/ledger/index.d.ts +14 -0
- package/dist/observability/ledger/index.js +13 -0
- package/dist/observability/ledger/store.d.ts +50 -0
- package/dist/observability/ledger/store.js +573 -0
- package/dist/observability/ledger/types.d.ts +197 -0
- package/dist/observability/ledger/types.js +1 -0
- package/dist/observability/recorder.d.ts +9 -2
- package/dist/observability/recorder.js +11 -18
- package/dist/observability/store.d.ts +5 -3
- package/dist/observability/store.js +152 -55
- package/dist/observability/types.d.ts +32 -4
- package/dist/web/audit/index.d.ts +1 -0
- package/dist/web/audit/index.js +1 -0
- package/dist/web/audit/motion.d.ts +87 -0
- package/dist/web/audit/motion.js +239 -0
- package/dist/web/design/index.d.ts +1 -0
- package/dist/web/design/index.js +1 -0
- package/dist/web/design/typography.d.ts +71 -0
- package/dist/web/design/typography.js +221 -0
- package/dist/web/hydration/capture.d.ts +37 -0
- package/dist/web/hydration/capture.js +96 -0
- package/dist/web/hydration/index.d.ts +10 -0
- package/dist/web/hydration/index.js +10 -0
- package/dist/web/hydration/judge.d.ts +56 -0
- package/dist/web/hydration/judge.js +191 -0
- package/dist/web/index.d.ts +1 -0
- package/dist/web/index.js +1 -0
- package/dist/web/perf/index.d.ts +1 -1
- package/dist/web/perf/index.js +1 -1
- package/dist/web/perf/view.js +19 -1
- package/dist/web/perf/vitals.d.ts +29 -0
- package/dist/web/perf/vitals.js +70 -0
- package/dist/web/session.d.ts +31 -2
- package/dist/web/session.js +75 -2
- package/package.json +12 -3
- package/dist/memory/db.d.ts +0 -15
- package/dist/memory/db.js +0 -25
package/dist/web/session.js
CHANGED
|
@@ -82,9 +82,10 @@ const WAIT_POLL_MS = 100;
|
|
|
82
82
|
const KNOWN_KEYS = new Set(Object.keys(_keyDefinitions));
|
|
83
83
|
import { readFile } from "node:fs/promises";
|
|
84
84
|
import { createRequire } from "node:module";
|
|
85
|
-
import { buildStructure, enabledRules, foldBehind, foldPair, parseRgb, readAxeRun, TARGET_CAPTURE, visualCaptureSource, } from "./audit/index.js";
|
|
86
|
-
import { inventorySource } from "./design/index.js";
|
|
85
|
+
import { buildStructure, enabledRules, foldBehind, foldPair, MOTION_CAPTURE, parseRgb, readAxeRun, TARGET_CAPTURE, visualCaptureSource, } from "./audit/index.js";
|
|
86
|
+
import { inventorySource, TYPOGRAPHY_CAPTURE, } from "./design/index.js";
|
|
87
87
|
import { describeThrow, evaluationSource, } from "./evaluate/index.js";
|
|
88
|
+
import { HYDRATION_CAPTURE } from "./hydration/index.js";
|
|
88
89
|
import { categoriesFor, compareHeap, foldLayers, foldProfile, foldTrace, LAYER_SETTLE_MS, nameNode, observerBootstrap, readVitalsSource, } from "./perf/index.js";
|
|
89
90
|
import { captureTiles } from "./screenshot.js";
|
|
90
91
|
import { ArtifactLedger } from "./session/artifacts.js";
|
|
@@ -1874,6 +1875,39 @@ export class BrowserSession {
|
|
|
1874
1875
|
});
|
|
1875
1876
|
return result.value;
|
|
1876
1877
|
}
|
|
1878
|
+
/**
|
|
1879
|
+
* What the page keeps doing when asked to hold still.
|
|
1880
|
+
*
|
|
1881
|
+
* Emulates prefers-reduced-motion: reduce, reloads so the page
|
|
1882
|
+
* decides its motion under the preference rather than being
|
|
1883
|
+
* caught mid-flight, reads what is still moving, then puts the
|
|
1884
|
+
* emulation back exactly as it was. The reload matters: a page
|
|
1885
|
+
* picks most of its motion at load, so flipping the preference
|
|
1886
|
+
* on a settled page measures its reaction to a change, not its
|
|
1887
|
+
* behaviour for a visitor who arrived with the preference set.
|
|
1888
|
+
*/
|
|
1889
|
+
async motionUnderReduce() {
|
|
1890
|
+
await this.ready();
|
|
1891
|
+
const before = this.emulation.asked;
|
|
1892
|
+
try {
|
|
1893
|
+
await this.emulation.change({ reducedMotion: true });
|
|
1894
|
+
await this.reload();
|
|
1895
|
+
const response = await this.cdp.send("Runtime.evaluate", {
|
|
1896
|
+
expression: MOTION_CAPTURE,
|
|
1897
|
+
returnByValue: true,
|
|
1898
|
+
});
|
|
1899
|
+
if (response.exceptionDetails) {
|
|
1900
|
+
const threw = describeThrow(response.exceptionDetails);
|
|
1901
|
+
throw new Error(`Could not read the motion: ${threw.message}`);
|
|
1902
|
+
}
|
|
1903
|
+
return response.result.value;
|
|
1904
|
+
}
|
|
1905
|
+
finally {
|
|
1906
|
+
// Wholesale, not merged: a merge cannot clear the reduce
|
|
1907
|
+
// this added when the session had no opinion before.
|
|
1908
|
+
await this.emulation.restore(before);
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1877
1911
|
async structure() {
|
|
1878
1912
|
// Every sibling read waits out a crash recovery first, and
|
|
1879
1913
|
// this one did not. Promise.all evaluates this.cdp.send when
|
|
@@ -1937,6 +1971,45 @@ export class BrowserSession {
|
|
|
1937
1971
|
}
|
|
1938
1972
|
return response.result.value;
|
|
1939
1973
|
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Both renders of the current page: what the server sends and
|
|
1976
|
+
* what hydration made of it.
|
|
1977
|
+
*
|
|
1978
|
+
* The server render is fetched from inside the page, so it
|
|
1979
|
+
* travels with the session's cookies, and parsed without
|
|
1980
|
+
* running a script. Judging the capture is the hydration
|
|
1981
|
+
* subdomain's job; pair it with logs() so the framework's own
|
|
1982
|
+
* complaints are read beside the comparison.
|
|
1983
|
+
*/
|
|
1984
|
+
async hydration() {
|
|
1985
|
+
await this.ready();
|
|
1986
|
+
const response = await this.cdp.send("Runtime.evaluate", {
|
|
1987
|
+
expression: HYDRATION_CAPTURE,
|
|
1988
|
+
awaitPromise: true,
|
|
1989
|
+
returnByValue: true,
|
|
1990
|
+
});
|
|
1991
|
+
if (response.exceptionDetails) {
|
|
1992
|
+
const threw = describeThrow(response.exceptionDetails);
|
|
1993
|
+
throw new Error(`Could not read the renders: ${threw.message}`);
|
|
1994
|
+
}
|
|
1995
|
+
return response.result.value;
|
|
1996
|
+
}
|
|
1997
|
+
/**
|
|
1998
|
+
* How the page's text blocks wrap, measured from real line
|
|
1999
|
+
* boxes rather than estimated from fonts.
|
|
2000
|
+
*/
|
|
2001
|
+
async typography() {
|
|
2002
|
+
await this.ready();
|
|
2003
|
+
const response = await this.cdp.send("Runtime.evaluate", {
|
|
2004
|
+
expression: TYPOGRAPHY_CAPTURE,
|
|
2005
|
+
returnByValue: true,
|
|
2006
|
+
});
|
|
2007
|
+
if (response.exceptionDetails) {
|
|
2008
|
+
const threw = describeThrow(response.exceptionDetails);
|
|
2009
|
+
throw new Error(`Could not measure the text: ${threw.message}`);
|
|
2010
|
+
}
|
|
2011
|
+
return response.result.value;
|
|
2012
|
+
}
|
|
1940
2013
|
async layout() {
|
|
1941
2014
|
await this.ready();
|
|
1942
2015
|
const response = await this.cdp.send("Runtime.evaluate", {
|
package/package.json
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jitsusama/agentic-harness.core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Pi-agnostic business logic for agentic-harness: state machines, guardian decisions, quest/TDD domain model.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"overrides": {
|
|
8
8
|
"google-auth-library": "$google-auth-library"
|
|
9
9
|
},
|
|
10
|
+
"pnpm": {
|
|
11
|
+
"overrides": {
|
|
12
|
+
"google-auth-library": "$google-auth-library"
|
|
13
|
+
},
|
|
14
|
+
"onlyBuiltDependencies": [
|
|
15
|
+
"sqlite3"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
10
18
|
"exports": {
|
|
11
19
|
"./tdd": "./dist/tdd/index.js",
|
|
12
20
|
"./tdd/presentation": "./dist/tdd/presentation.js",
|
|
@@ -73,6 +81,7 @@
|
|
|
73
81
|
"./web/environment": "./dist/web/environment/index.js",
|
|
74
82
|
"./web/environment/devices": "./dist/web/environment/devices.js",
|
|
75
83
|
"./web/evaluate": "./dist/web/evaluate/index.js",
|
|
84
|
+
"./web/hydration": "./dist/web/hydration/index.js",
|
|
76
85
|
"./web/input": "./dist/web/input/index.js",
|
|
77
86
|
"./web/mermaid": "./dist/web/mermaid.js",
|
|
78
87
|
"./web/perf": "./dist/web/perf/index.js",
|
|
@@ -105,11 +114,11 @@
|
|
|
105
114
|
],
|
|
106
115
|
"scripts": {
|
|
107
116
|
"build": "tsc -p tsconfig.build.json",
|
|
108
|
-
"prepare": "
|
|
117
|
+
"prepare": "tsc -p tsconfig.build.json",
|
|
109
118
|
"lint": "biome check .",
|
|
110
119
|
"lint:fix": "biome check --write .",
|
|
111
120
|
"typecheck": "tsc --noEmit",
|
|
112
|
-
"pretest": "
|
|
121
|
+
"pretest": "tsc -p tsconfig.build.json",
|
|
113
122
|
"test": "vitest run",
|
|
114
123
|
"test:watch": "vitest",
|
|
115
124
|
"test:browser": "vitest run --config vitest.browser.config.ts"
|
package/dist/memory/db.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Thin promise wrapper over the callback-based sqlite3 driver.
|
|
3
|
-
* sqlite3 is a native module, so it is lazy-imported on first
|
|
4
|
-
* open; callers speak promises and never touch the driver
|
|
5
|
-
* directly.
|
|
6
|
-
*/
|
|
7
|
-
/** A promise-speaking handle to a SQLite database. */
|
|
8
|
-
export interface Db {
|
|
9
|
-
run(sql: string, params?: readonly unknown[]): Promise<void>;
|
|
10
|
-
all<T>(sql: string, params?: readonly unknown[]): Promise<T[]>;
|
|
11
|
-
exec(sql: string): Promise<void>;
|
|
12
|
-
close(): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
/** Open a SQLite database at the given path (`:memory:` for tests). */
|
|
15
|
-
export declare function openDb(dbPath: string): Promise<Db>;
|
package/dist/memory/db.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Thin promise wrapper over the callback-based sqlite3 driver.
|
|
3
|
-
* sqlite3 is a native module, so it is lazy-imported on first
|
|
4
|
-
* open; callers speak promises and never touch the driver
|
|
5
|
-
* directly.
|
|
6
|
-
*/
|
|
7
|
-
/** Open a SQLite database at the given path (`:memory:` for tests). */
|
|
8
|
-
export async function openDb(dbPath) {
|
|
9
|
-
const sqlite3 = await import("sqlite3");
|
|
10
|
-
const database = new sqlite3.default.Database(dbPath);
|
|
11
|
-
return {
|
|
12
|
-
run: (sql, params = []) => new Promise((resolve, reject) => {
|
|
13
|
-
database.run(sql, params, (err) => (err ? reject(err) : resolve()));
|
|
14
|
-
}),
|
|
15
|
-
all: (sql, params = []) => new Promise((resolve, reject) => {
|
|
16
|
-
database.all(sql, params, (err, rows) => err ? reject(err) : resolve(rows));
|
|
17
|
-
}),
|
|
18
|
-
exec: (sql) => new Promise((resolve, reject) => {
|
|
19
|
-
database.exec(sql, (err) => (err ? reject(err) : resolve()));
|
|
20
|
-
}),
|
|
21
|
-
close: () => new Promise((resolve, reject) => {
|
|
22
|
-
database.close((err) => (err ? reject(err) : resolve()));
|
|
23
|
-
}),
|
|
24
|
-
};
|
|
25
|
-
}
|