@jini-ai/diagnostics 0.7.3-next.2 → 0.7.3-next.3
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 +41 -0
- package/dist/browser-diagnostics.d.ts +43 -0
- package/dist/browser-diagnostics.js +92 -0
- package/dist/console-tee.d.ts +21 -6
- package/dist/console-tee.js +16 -4
- package/dist/domain-dns/index.d.ts +6 -14
- package/dist/domain-dns/index.js +4 -6
- package/dist/local-text.d.ts +4 -1
- package/dist/local-text.js +3 -2
- package/dist/observability/error-events.d.ts +32 -0
- package/dist/observability/error-events.js +32 -0
- package/dist/observability/fanout.js +9 -1
- package/dist/observability/index.d.ts +2 -1
- package/dist/observability/index.js +1 -0
- package/dist/observability/report-error.d.ts +9 -4
- package/dist/observability/report-error.js +7 -6
- package/dist/observability/telemetry-test.d.ts +1 -1
- package/dist/observability/tool-registrations.d.ts +21 -0
- package/dist/observability/tool-registrations.js +38 -0
- package/dist/observability/tracker-noop.d.ts +1 -1
- package/dist/observability/tracker-types.d.ts +2 -57
- package/dist/observability/tracker.d.ts +2 -1
- package/dist/observability/tracker.js +5 -1
- package/dist/redaction/repo-secret-scan.d.ts +48 -0
- package/dist/redaction/repo-secret-scan.js +77 -0
- package/dist/redaction/repo-secret-scan.node.d.ts +56 -0
- package/dist/redaction/repo-secret-scan.node.js +174 -0
- package/dist/redaction/secret-scan.d.ts +15 -0
- package/dist/redaction/secret-scan.js +18 -0
- package/dist/redaction/secrets-only.d.ts +1 -0
- package/dist/redaction/secrets-only.js +2 -0
- package/dist/redaction.d.ts +6 -0
- package/dist/redaction.js +9 -5
- package/dist/server-logs/agent-tools.d.ts +34 -0
- package/dist/server-logs/agent-tools.js +19 -0
- package/dist/server-logs/read-server-logs.d.ts +49 -0
- package/dist/server-logs/read-server-logs.js +90 -0
- package/dist/server-logs/tool-registrations.d.ts +25 -0
- package/dist/server-logs/tool-registrations.js +39 -0
- package/dist/tool-audit/repo.d.ts +107 -0
- package/dist/tool-audit/repo.js +117 -0
- package/dist/tool-audit/repo.memory.d.ts +31 -0
- package/dist/tool-audit/repo.memory.js +30 -0
- package/dist/tool-audit/repo.rows.d.ts +19 -0
- package/dist/tool-audit/repo.rows.js +2 -0
- package/dist/tool-audit/tool-gaps.repo.d.ts +22 -0
- package/dist/tool-audit/tool-gaps.repo.js +36 -0
- package/dist/web-evidence/agent-tools.d.ts +31 -0
- package/dist/web-evidence/agent-tools.js +61 -0
- package/dist/web-evidence/capture-budget.d.ts +3 -10
- package/dist/web-evidence/live-url.d.ts +86 -0
- package/dist/web-evidence/live-url.js +191 -0
- package/dist/web-evidence/page-performance-script.js +30 -32
- package/dist/web-evidence/playwright-browser.d.ts +2 -0
- package/dist/web-evidence/playwright-page-capture.d.ts +129 -0
- package/dist/web-evidence/playwright-page-capture.js +226 -0
- package/dist/web-evidence/public-page.d.ts +2 -1
- package/dist/web-evidence/published-page.d.ts +180 -0
- package/dist/web-evidence/published-page.js +172 -0
- package/dist/web-evidence/request-guard.d.ts +1 -31
- package/dist/web-evidence/site-path-policy.d.ts +20 -0
- package/dist/web-evidence/site-path-policy.js +54 -0
- package/dist/web-evidence/web-screenshot/agent-tools.d.ts +28 -0
- package/dist/web-evidence/web-screenshot/agent-tools.js +34 -0
- package/dist/web-evidence/web-screenshot/tool-registrations.d.ts +79 -0
- package/dist/web-evidence/web-screenshot/tool-registrations.js +47 -0
- package/package.json +114 -6
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `readServerLogs` — the ONE read behind both the admin route
|
|
3
|
+
* (`GET /api/admin/v1/workspaces/:ws/system/server-logs`) and the `system_read_server_logs` chat
|
|
4
|
+
* tool (gap A-04). Both call `parseServerLogFilters` then `readServerLogs`, so a filter means the
|
|
5
|
+
* same thing in the UI and in chat.
|
|
6
|
+
* Now: the route and the chat tool are a host's, and so is where the lines live: it injects a
|
|
7
|
+
* {@link ServerLogSourcePort}.
|
|
8
|
+
*/
|
|
9
|
+
export const SERVER_LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
10
|
+
export const DEFAULT_SERVER_LOG_LIMIT = 100;
|
|
11
|
+
export const MAX_SERVER_LOG_LIMIT = 500;
|
|
12
|
+
export const MAX_CONTAINS_LENGTH = 200;
|
|
13
|
+
const SEVERITY = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
14
|
+
/** A filter value the caller sent that cannot be used. The message names the field. */
|
|
15
|
+
export class ServerLogFilterError extends Error {
|
|
16
|
+
constructor({ message }) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = "ServerLogFilterError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function parseLevel({ raw }, _optional = {}) {
|
|
22
|
+
if (raw === undefined || raw === "")
|
|
23
|
+
return undefined;
|
|
24
|
+
if (typeof raw === "string" && SERVER_LOG_LEVELS.includes(raw))
|
|
25
|
+
return raw;
|
|
26
|
+
throw new ServerLogFilterError({ message: `level must be one of ${SERVER_LOG_LEVELS.join(", ")}` });
|
|
27
|
+
}
|
|
28
|
+
function parseSince({ raw }, _optional = {}) {
|
|
29
|
+
if (raw === undefined || raw === "")
|
|
30
|
+
return undefined;
|
|
31
|
+
if (typeof raw === "string" && !Number.isNaN(Date.parse(raw)))
|
|
32
|
+
return new Date(raw).toISOString();
|
|
33
|
+
throw new ServerLogFilterError({ message: "sinceIso must be an ISO-8601 date-time, e.g. 2026-10-05T12:00:00Z" });
|
|
34
|
+
}
|
|
35
|
+
function parseContains({ raw }, _optional = {}) {
|
|
36
|
+
if (raw === undefined || raw === "")
|
|
37
|
+
return undefined;
|
|
38
|
+
if (typeof raw === "string" && raw.length <= MAX_CONTAINS_LENGTH)
|
|
39
|
+
return raw;
|
|
40
|
+
throw new ServerLogFilterError({ message: `contains must be a string of at most ${MAX_CONTAINS_LENGTH} characters` });
|
|
41
|
+
}
|
|
42
|
+
function parseLimit({ raw }, _optional = {}) {
|
|
43
|
+
if (raw === undefined || raw === "")
|
|
44
|
+
return undefined;
|
|
45
|
+
const value = typeof raw === "string" && /^\d+$/.test(raw) ? Number(raw) : raw;
|
|
46
|
+
if (typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= MAX_SERVER_LOG_LIMIT)
|
|
47
|
+
return value;
|
|
48
|
+
throw new ServerLogFilterError({ message: `limit must be an integer from 1 to ${MAX_SERVER_LOG_LIMIT}` });
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Validates filters from either a JSON tool input or an HTTP query (where every value is a string).
|
|
52
|
+
* @param required The raw record; unknown keys are ignored here (the tool schema refuses them).
|
|
53
|
+
* @returns Normalized filters.
|
|
54
|
+
* @throws {ServerLogFilterError} Naming the first unusable field.
|
|
55
|
+
* @complexity O(1).
|
|
56
|
+
*/
|
|
57
|
+
export function parseServerLogFilters(required) {
|
|
58
|
+
const { raw } = required;
|
|
59
|
+
return { level: parseLevel({ raw: raw.level }), sinceIso: parseSince({ raw: raw.sinceIso }), contains: parseContains({ raw: raw.contains }), limit: parseLimit({ raw: raw.limit }) };
|
|
60
|
+
}
|
|
61
|
+
function matches({ entry, filters, sinceMs, needle }, _optional = {}) {
|
|
62
|
+
if (filters.level && SEVERITY[entry.level] < SEVERITY[filters.level])
|
|
63
|
+
return false;
|
|
64
|
+
if (sinceMs !== null && Date.parse(entry.at) < sinceMs)
|
|
65
|
+
return false;
|
|
66
|
+
return needle === null || entry.message.toLowerCase().includes(needle);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns the newest matching server log lines. Read-only; lines were redacted when captured.
|
|
70
|
+
* @param required The log source port.
|
|
71
|
+
* @param optional Filters from `parseServerLogFilters`.
|
|
72
|
+
* @returns Matching lines (oldest first) plus counts so a caller can say what was left out.
|
|
73
|
+
* @complexity O(n) over buffered lines (n <= the buffer cap).
|
|
74
|
+
* @example readServerLogs({ logs }, { level: "error", limit: 20 });
|
|
75
|
+
*/
|
|
76
|
+
export function readServerLogs(required, optional = {}) {
|
|
77
|
+
const { entries: all, capturing } = required.logs.read();
|
|
78
|
+
const sinceMs = optional.sinceIso ? Date.parse(optional.sinceIso) : null;
|
|
79
|
+
const needle = optional.contains ? optional.contains.toLowerCase() : null;
|
|
80
|
+
const matching = all.filter(entry => matches({ entry, filters: optional, sinceMs, needle }));
|
|
81
|
+
const limit = optional.limit ?? DEFAULT_SERVER_LOG_LIMIT;
|
|
82
|
+
return {
|
|
83
|
+
entries: matching.slice(-limit),
|
|
84
|
+
matched: matching.length,
|
|
85
|
+
buffered: all.length,
|
|
86
|
+
truncated: matching.length > limit,
|
|
87
|
+
capturing,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=read-server-logs.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type AgentToolSideEffect, type ToolContributor, type ToolRegistration } from "@jini-ai/core";
|
|
2
|
+
import type { AuthorizeFn } from "@jini-ai/core/contracts/events";
|
|
3
|
+
import { type ServerLogSourcePort } from "./read-server-logs.js";
|
|
4
|
+
export interface ServerLogsToolDeps {
|
|
5
|
+
authorize: AuthorizeFn;
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
/** Defaults to the log source the host bound on {@link contributeServerLogsTools}. */
|
|
8
|
+
serverLogs?: ServerLogSourcePort;
|
|
9
|
+
}
|
|
10
|
+
/** The log source a host binds once when contributing the tool (its own process log capture). */
|
|
11
|
+
export interface ServerLogsContributorArgs {
|
|
12
|
+
serverLogs: ServerLogSourcePort;
|
|
13
|
+
}
|
|
14
|
+
export declare const serverLogsDerivedRisk: ReadonlyMap<string, AgentToolSideEffect>;
|
|
15
|
+
/**
|
|
16
|
+
* Builds `system_read_server_logs`, gated by the same `system.read` permission as the admin route.
|
|
17
|
+
* @param deps - Site scope, authorization and the log source port.
|
|
18
|
+
* @returns One read-only registration.
|
|
19
|
+
* @throws {ToolInputError} For an unusable filter or denied system.read.
|
|
20
|
+
* @complexity O(n) over buffered lines.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildServerLogsRegistrations(deps: ServerLogsToolDeps & ServerLogsContributorArgs, _optional?: Record<string, never>): ToolRegistration[];
|
|
23
|
+
/** Keeps the diagnostic under its own contributor domain. */
|
|
24
|
+
export declare function contributeServerLogsTools(required: ServerLogsContributorArgs, _optional?: Record<string, never>): ToolContributor<ServerLogsToolDeps, unknown>;
|
|
25
|
+
//# sourceMappingURL=tool-registrations.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { toolMetadata } from "@jini-ai/core/tool-metadata/server-logs";
|
|
2
|
+
import { adaptLegacyAuthorize, buildDomainRegistrations, indexCatalogById, requireInputRecord, requireToolPermission, ToolInputError, ToolPermissionDeniedError as ForbiddenError } from "@jini-ai/core";
|
|
3
|
+
import { forbiddenRule, withModelFacingErrors } from "@jini-ai/core/model-facing-tool-errors";
|
|
4
|
+
import { serverLogsAgentToolCatalog } from "./agent-tools.js";
|
|
5
|
+
import { parseServerLogFilters, readServerLogs, ServerLogFilterError } from "./read-server-logs.js";
|
|
6
|
+
export const serverLogsDerivedRisk = new Map([
|
|
7
|
+
// -> readServerLogs over an in-memory buffer only; writes nothing.
|
|
8
|
+
["system_read_server_logs", "none"],
|
|
9
|
+
]);
|
|
10
|
+
/**
|
|
11
|
+
* Builds `system_read_server_logs`, gated by the same `system.read` permission as the admin route.
|
|
12
|
+
* @param deps - Site scope, authorization and the log source port.
|
|
13
|
+
* @returns One read-only registration.
|
|
14
|
+
* @throws {ToolInputError} For an unusable filter or denied system.read.
|
|
15
|
+
* @complexity O(n) over buffered lines.
|
|
16
|
+
*/
|
|
17
|
+
export function buildServerLogsRegistrations(deps, _optional = {}) {
|
|
18
|
+
return buildDomainRegistrations({ metadata: toolMetadata, domain: "system-server-logs", catalogModule: "server-logs/agent-tools.ts", catalog: indexCatalogById({ catalog: serverLogsAgentToolCatalog }), derivedRisk: serverLogsDerivedRisk, handlers: withModelFacingErrors({ handlers: {
|
|
19
|
+
system_read_server_logs: async (ctx) => {
|
|
20
|
+
const raw = requireInputRecord({ input: ctx.input });
|
|
21
|
+
await requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: deps.authorize }), workspaceId: deps.workspaceId, principalId: ctx.principal.id, permission: "system.read" }, { entityType: "server-logs" });
|
|
22
|
+
let filters;
|
|
23
|
+
try {
|
|
24
|
+
filters = parseServerLogFilters({ raw });
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
if (err instanceof ServerLogFilterError)
|
|
28
|
+
throw new ToolInputError({ message: err.message });
|
|
29
|
+
throw err;
|
|
30
|
+
}
|
|
31
|
+
return readServerLogs({ logs: deps.serverLogs }, filters);
|
|
32
|
+
},
|
|
33
|
+
}, rules: [forbiddenRule({ domainPrefix: "SERVER_LOGS", error: ForbiddenError })] }) });
|
|
34
|
+
}
|
|
35
|
+
/** Keeps the diagnostic under its own contributor domain. */
|
|
36
|
+
export function contributeServerLogsTools(required, _optional = {}) {
|
|
37
|
+
return { domain: "system-server-logs", build: deps => buildServerLogsRegistrations({ ...deps, serverLogs: deps.serverLogs ?? required.serverLogs }), risk: serverLogsDerivedRisk };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=tool-registrations.js.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file THE durable {@link ToolAttemptAuditSink} — persists agent tool-attempt phases into the
|
|
3
|
+
* content database's `agent_tool_attempts` (`repo.memory.ts` is the in-memory half, per ADR-006's
|
|
4
|
+
* rule-of-two). One Kysely query body for every dialect (storage plan §4, ADR-066); the host's
|
|
5
|
+
* SQLite binding is the thin subclass the composition root builds from the content db handle,
|
|
6
|
+
* passing its table name ({@link ToolAttemptTables}) and its error reporter.
|
|
7
|
+
*
|
|
8
|
+
* Purpose:
|
|
9
|
+
* Makes the attempt history outlive the daemon process. `@jini-ai/daemon`'s `ToolExecutor` holds its
|
|
10
|
+
* own audit records in an in-process `Map`, so today every requested/denied/failed execution is
|
|
11
|
+
* erased on restart — and the two cases it never records at all (unknown tool, throwing
|
|
12
|
+
* authorization) leave nothing behind even while the process lives.
|
|
13
|
+
*
|
|
14
|
+
* Retention:
|
|
15
|
+
* The table is append-only and would otherwise grow without bound, so {@link MAX_ROWS_PER_WORKSPACE}
|
|
16
|
+
* administrator rows are kept per workspace; anonymous-visitor has an independent 20,000-row
|
|
17
|
+
* bucket. Each bucket's excess is pruned oldest-first on write. The prune runs
|
|
18
|
+
* opportunistically rather than in a background job — there is no scheduler in the daemon process,
|
|
19
|
+
* and a scheduled pruner would be a new failure surface for a table nothing reads on a hot path.
|
|
20
|
+
*
|
|
21
|
+
* Architectural role:
|
|
22
|
+
* Infrastructure adapter. It takes a schema-free storage kernel and the host's table name; it never
|
|
23
|
+
* imports a concrete database handle.
|
|
24
|
+
*/
|
|
25
|
+
import type { Kysely } from "kysely";
|
|
26
|
+
import type { StorageKernel } from "@jini-ai/core/contracts/storage";
|
|
27
|
+
import type { ToolAttemptAuditSink, ToolAttemptEvent } from "@jini-ai/core/contracts/site/daemon-tool-audit";
|
|
28
|
+
/**
|
|
29
|
+
* Per-workspace row cap.
|
|
30
|
+
*
|
|
31
|
+
* A STARTING NUMBER, not a tuned or externally-derived one, and nothing in the codebase depends on
|
|
32
|
+
* its exact value — raise or lower it freely. Sized so that at roughly two or three rows per
|
|
33
|
+
* attempt it holds on the order of twenty thousand attempts per workspace, which is far more than
|
|
34
|
+
* any current diagnostic use needs while staying small enough that the table cannot quietly become
|
|
35
|
+
* the largest thing in `content.db`.
|
|
36
|
+
*/
|
|
37
|
+
export declare const MAX_ROWS_PER_WORKSPACE = 50000;
|
|
38
|
+
/** Anonymous traffic has its own retention bucket and can never evict administrator attempts. */
|
|
39
|
+
export declare const MAX_VISITOR_ROWS_PER_WORKSPACE = 20000;
|
|
40
|
+
/** Host-owned table name. No schema or product table default lives in the adapter. */
|
|
41
|
+
export interface ToolAttemptTables {
|
|
42
|
+
toolAttempts: string;
|
|
43
|
+
}
|
|
44
|
+
/** Receives a failed audit write. The host binds its own logger; the adapter never logs. */
|
|
45
|
+
export type ToolAuditErrorReporter = (required: {
|
|
46
|
+
error: unknown;
|
|
47
|
+
}, optional?: Record<string, never>) => void;
|
|
48
|
+
/** The sink's constructor object: the schema-free kernel, the host table name and the error reporter. */
|
|
49
|
+
export interface SqlToolAttemptAuditSinkRequired {
|
|
50
|
+
kernel: StorageKernel<Kysely<unknown>, unknown>;
|
|
51
|
+
tables: ToolAttemptTables;
|
|
52
|
+
/** Reported when a write fails. Required: there is no console default here. */
|
|
53
|
+
onError: ToolAuditErrorReporter;
|
|
54
|
+
}
|
|
55
|
+
export interface SqlToolAttemptAuditSinkOptions {
|
|
56
|
+
/** Per-workspace row cap. @default {@link MAX_ROWS_PER_WORKSPACE} */
|
|
57
|
+
maxRowsPerWorkspace?: number;
|
|
58
|
+
/** Separate anonymous bucket; the administrator cap excludes this principal entirely. */
|
|
59
|
+
maxVisitorRowsPerWorkspace?: number;
|
|
60
|
+
/** Appends between prune checks. Lower it in tests to reach the prune without 50k writes. @default {@link PRUNE_CHECK_INTERVAL} */
|
|
61
|
+
pruneCheckInterval?: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Content-database-backed audit sink.
|
|
65
|
+
*
|
|
66
|
+
* `append` deliberately never throws: the decorator that calls it treats audit as observation, and
|
|
67
|
+
* a write failure must not turn a successful tool call into a failed one. A failure is reported to
|
|
68
|
+
* the host-bound `onError` so it is loud in logs without being fatal in behavior.
|
|
69
|
+
*/
|
|
70
|
+
export declare class SqlToolAttemptAuditSink implements ToolAttemptAuditSink {
|
|
71
|
+
private readonly appendsSincePruneCheck;
|
|
72
|
+
protected readonly kernel: StorageKernel<Kysely<unknown>, unknown>;
|
|
73
|
+
protected readonly tables: ToolAttemptTables;
|
|
74
|
+
private readonly onError;
|
|
75
|
+
private readonly maxRows;
|
|
76
|
+
private readonly maxVisitorRows;
|
|
77
|
+
private readonly pruneCheckInterval;
|
|
78
|
+
constructor(required: SqlToolAttemptAuditSinkRequired, options?: SqlToolAttemptAuditSinkOptions);
|
|
79
|
+
/** Host-owned table name needs an explicit column schema, as in the webhook adapters. */
|
|
80
|
+
private table;
|
|
81
|
+
/**
|
|
82
|
+
* Appends one phase row, then prunes the workspace's oldest rows if the cap is exceeded.
|
|
83
|
+
*
|
|
84
|
+
* @param event - The phase to record. `detail` must already be redacted by the caller.
|
|
85
|
+
* @param optional - Daemon append options; an explicit detail overrides the legacy event field.
|
|
86
|
+
* @returns Resolves once the row is written, or once the failure has been reported — never rejects.
|
|
87
|
+
* @complexity O(1) for the insert. The prune runs at most once per
|
|
88
|
+
* {@link PRUNE_CHECK_INTERVAL} appends and is O(log n) per deleted row via the
|
|
89
|
+
* `(workspace_id, id)` index.
|
|
90
|
+
* @overallScore 100
|
|
91
|
+
*/
|
|
92
|
+
append(event: ToolAttemptEvent, optional?: Pick<ToolAttemptEvent, "detail">): Promise<void>;
|
|
93
|
+
/** Same non-throwing audit write, returning insertion evidence for product observers.
|
|
94
|
+
* A later retention failure cannot undo an inserted attempt. @complexity Same as append. */
|
|
95
|
+
appendCommitted(event: ToolAttemptEvent, optional?: Pick<ToolAttemptEvent, "detail">): Promise<boolean>;
|
|
96
|
+
/**
|
|
97
|
+
* Deletes this workspace/bucket's rows below its own newest `maxRows`.
|
|
98
|
+
*
|
|
99
|
+
* Uses `id` (monotonic identity) as the age ordering rather than `at`, so a clock that
|
|
100
|
+
* jumps backwards cannot make the prune delete the wrong rows.
|
|
101
|
+
*
|
|
102
|
+
* @complexity One indexed `OFFSET` probe plus one ranged delete.
|
|
103
|
+
* @overallScore 100
|
|
104
|
+
*/
|
|
105
|
+
private pruneWorkspace;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=repo.d.ts.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-workspace row cap.
|
|
3
|
+
*
|
|
4
|
+
* A STARTING NUMBER, not a tuned or externally-derived one, and nothing in the codebase depends on
|
|
5
|
+
* its exact value — raise or lower it freely. Sized so that at roughly two or three rows per
|
|
6
|
+
* attempt it holds on the order of twenty thousand attempts per workspace, which is far more than
|
|
7
|
+
* any current diagnostic use needs while staying small enough that the table cannot quietly become
|
|
8
|
+
* the largest thing in `content.db`.
|
|
9
|
+
*/
|
|
10
|
+
export const MAX_ROWS_PER_WORKSPACE = 50_000;
|
|
11
|
+
/** Anonymous traffic has its own retention bucket and can never evict administrator attempts. */
|
|
12
|
+
export const MAX_VISITOR_ROWS_PER_WORKSPACE = 20_000;
|
|
13
|
+
/** Prune every Nth append rather than on all of them — the cap is a bound, not a precise ceiling. */
|
|
14
|
+
const PRUNE_CHECK_INTERVAL = 256;
|
|
15
|
+
/**
|
|
16
|
+
* Content-database-backed audit sink.
|
|
17
|
+
*
|
|
18
|
+
* `append` deliberately never throws: the decorator that calls it treats audit as observation, and
|
|
19
|
+
* a write failure must not turn a successful tool call into a failed one. A failure is reported to
|
|
20
|
+
* the host-bound `onError` so it is loud in logs without being fatal in behavior.
|
|
21
|
+
*/
|
|
22
|
+
export class SqlToolAttemptAuditSink {
|
|
23
|
+
appendsSincePruneCheck = new Map();
|
|
24
|
+
kernel;
|
|
25
|
+
tables;
|
|
26
|
+
onError;
|
|
27
|
+
maxRows;
|
|
28
|
+
maxVisitorRows;
|
|
29
|
+
pruneCheckInterval;
|
|
30
|
+
constructor(required, options = {}) {
|
|
31
|
+
this.kernel = required.kernel;
|
|
32
|
+
this.tables = required.tables;
|
|
33
|
+
this.onError = required.onError;
|
|
34
|
+
this.maxRows = options.maxRowsPerWorkspace ?? MAX_ROWS_PER_WORKSPACE;
|
|
35
|
+
this.maxVisitorRows = options.maxVisitorRowsPerWorkspace ?? MAX_VISITOR_ROWS_PER_WORKSPACE;
|
|
36
|
+
this.pruneCheckInterval = options.pruneCheckInterval ?? PRUNE_CHECK_INTERVAL;
|
|
37
|
+
}
|
|
38
|
+
/** Host-owned table name needs an explicit column schema, as in the webhook adapters. */
|
|
39
|
+
table(db) {
|
|
40
|
+
return db.withTables();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Appends one phase row, then prunes the workspace's oldest rows if the cap is exceeded.
|
|
44
|
+
*
|
|
45
|
+
* @param event - The phase to record. `detail` must already be redacted by the caller.
|
|
46
|
+
* @param optional - Daemon append options; an explicit detail overrides the legacy event field.
|
|
47
|
+
* @returns Resolves once the row is written, or once the failure has been reported — never rejects.
|
|
48
|
+
* @complexity O(1) for the insert. The prune runs at most once per
|
|
49
|
+
* {@link PRUNE_CHECK_INTERVAL} appends and is O(log n) per deleted row via the
|
|
50
|
+
* `(workspace_id, id)` index.
|
|
51
|
+
* @overallScore 100
|
|
52
|
+
*/
|
|
53
|
+
async append(event, optional = {}) {
|
|
54
|
+
await this.appendCommitted(event, optional);
|
|
55
|
+
}
|
|
56
|
+
/** Same non-throwing audit write, returning insertion evidence for product observers.
|
|
57
|
+
* A later retention failure cannot undo an inserted attempt. @complexity Same as append. */
|
|
58
|
+
async appendCommitted(event, optional = {}) {
|
|
59
|
+
let committed = false;
|
|
60
|
+
try {
|
|
61
|
+
await this.kernel.run((db) => this.table(db)
|
|
62
|
+
.insertInto(this.tables.toolAttempts)
|
|
63
|
+
.values({
|
|
64
|
+
attempt_id: event.attemptId,
|
|
65
|
+
execution_id: event.executionId,
|
|
66
|
+
workspace_id: event.workspaceId,
|
|
67
|
+
run_id: event.runId,
|
|
68
|
+
tool_id: event.toolId,
|
|
69
|
+
principal_id: event.principalId,
|
|
70
|
+
phase: event.phase,
|
|
71
|
+
at: event.at,
|
|
72
|
+
// Released daemon callers pass detail in options; retain older event-shaped callers.
|
|
73
|
+
detail: optional.detail === undefined ? event.detail ?? null : optional.detail,
|
|
74
|
+
})
|
|
75
|
+
.execute());
|
|
76
|
+
committed = true;
|
|
77
|
+
const visitor = event.principalId === "anonymous-visitor";
|
|
78
|
+
const bucketKey = JSON.stringify([event.workspaceId, visitor]);
|
|
79
|
+
const appends = (this.appendsSincePruneCheck.get(bucketKey) ?? 0) + 1;
|
|
80
|
+
this.appendsSincePruneCheck.set(bucketKey, appends);
|
|
81
|
+
if (appends >= this.pruneCheckInterval) {
|
|
82
|
+
this.appendsSincePruneCheck.delete(bucketKey);
|
|
83
|
+
await this.pruneWorkspace({ workspaceId: event.workspaceId, visitor });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
this.onError({ error });
|
|
88
|
+
}
|
|
89
|
+
return committed;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Deletes this workspace/bucket's rows below its own newest `maxRows`.
|
|
93
|
+
*
|
|
94
|
+
* Uses `id` (monotonic identity) as the age ordering rather than `at`, so a clock that
|
|
95
|
+
* jumps backwards cannot make the prune delete the wrong rows.
|
|
96
|
+
*
|
|
97
|
+
* @complexity One indexed `OFFSET` probe plus one ranged delete.
|
|
98
|
+
* @overallScore 100
|
|
99
|
+
*/
|
|
100
|
+
async pruneWorkspace({ workspaceId, visitor }, _options = {}) {
|
|
101
|
+
const maxRows = visitor ? this.maxVisitorRows : this.maxRows;
|
|
102
|
+
const cutoff = await this.kernel.run((db) => this.table(db)
|
|
103
|
+
.selectFrom(this.tables.toolAttempts)
|
|
104
|
+
.select("id")
|
|
105
|
+
.where("workspace_id", "=", workspaceId)
|
|
106
|
+
.where("principal_id", visitor ? "=" : "!=", "anonymous-visitor")
|
|
107
|
+
.orderBy("id", "desc")
|
|
108
|
+
.limit(1)
|
|
109
|
+
.offset(maxRows - 1)
|
|
110
|
+
.executeTakeFirst());
|
|
111
|
+
if (!cutoff)
|
|
112
|
+
return;
|
|
113
|
+
await this.kernel.run((db) => this.table(db).deleteFrom(this.tables.toolAttempts).where("workspace_id", "=", workspaceId)
|
|
114
|
+
.where("principal_id", visitor ? "=" : "!=", "anonymous-visitor").where("id", "<", cutoff.id).execute());
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=repo.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file In-memory {@link ToolAttemptAuditSink} — the test double for the SQLite adapter, and the
|
|
3
|
+
* sink the host's in-memory database mode gets.
|
|
4
|
+
*
|
|
5
|
+
* Architectural role:
|
|
6
|
+
* `features/tool-audit` adapter. Depends only on this package's own `types.ts`.
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolAttemptAuditSink, ToolAttemptEvent } from "@jini-ai/core/contracts/site/daemon-tool-audit";
|
|
9
|
+
export interface InMemoryToolAttemptAuditSink extends ToolAttemptAuditSink {
|
|
10
|
+
/** Most recent retained events, in append order. Test-only read surface. */
|
|
11
|
+
readonly events: readonly ToolAttemptEvent[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates an in-memory audit sink bounded to the latest 20,000 events by default. The memory
|
|
15
|
+
* serving root can receive public traffic too; it must not grow with anonymous tool attempts.
|
|
16
|
+
*
|
|
17
|
+
* @returns A sink plus its `events` array, which reflects appends live (it is the same array the
|
|
18
|
+
* sink pushes onto, not a snapshot). Oldest events are evicted when `maxEvents` is reached.
|
|
19
|
+
* @throws RangeError if maxEvents is not a positive safe integer.
|
|
20
|
+
* @complexity O(maxEvents) time on eviction, bounded O(maxEvents) space. Array eviction preserves
|
|
21
|
+
* the existing live read contract without a second storage/ordering mechanism in this adapter.
|
|
22
|
+
* @example
|
|
23
|
+
* const sink = createInMemoryToolAttemptAuditSink({});
|
|
24
|
+
* await sink.append(event);
|
|
25
|
+
* assert.equal(sink.events[0].phase, "requested");
|
|
26
|
+
* @overallScore 100
|
|
27
|
+
*/
|
|
28
|
+
export declare function createInMemoryToolAttemptAuditSink(_required?: Record<string, never>, { maxEvents }?: {
|
|
29
|
+
maxEvents?: number;
|
|
30
|
+
}): InMemoryToolAttemptAuditSink;
|
|
31
|
+
//# sourceMappingURL=repo.memory.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an in-memory audit sink bounded to the latest 20,000 events by default. The memory
|
|
3
|
+
* serving root can receive public traffic too; it must not grow with anonymous tool attempts.
|
|
4
|
+
*
|
|
5
|
+
* @returns A sink plus its `events` array, which reflects appends live (it is the same array the
|
|
6
|
+
* sink pushes onto, not a snapshot). Oldest events are evicted when `maxEvents` is reached.
|
|
7
|
+
* @throws RangeError if maxEvents is not a positive safe integer.
|
|
8
|
+
* @complexity O(maxEvents) time on eviction, bounded O(maxEvents) space. Array eviction preserves
|
|
9
|
+
* the existing live read contract without a second storage/ordering mechanism in this adapter.
|
|
10
|
+
* @example
|
|
11
|
+
* const sink = createInMemoryToolAttemptAuditSink({});
|
|
12
|
+
* await sink.append(event);
|
|
13
|
+
* assert.equal(sink.events[0].phase, "requested");
|
|
14
|
+
* @overallScore 100
|
|
15
|
+
*/
|
|
16
|
+
export function createInMemoryToolAttemptAuditSink(_required = {}, { maxEvents = 20_000 } = {}) {
|
|
17
|
+
if (!Number.isSafeInteger(maxEvents) || maxEvents < 1)
|
|
18
|
+
throw new RangeError("maxEvents must be a positive safe integer");
|
|
19
|
+
const events = [];
|
|
20
|
+
return {
|
|
21
|
+
events,
|
|
22
|
+
append: async (event, optional = {}) => {
|
|
23
|
+
// Match the durable adapter's released daemon contract without losing legacy event detail.
|
|
24
|
+
events.push(optional.detail === undefined ? event : { ...event, detail: optional.detail });
|
|
25
|
+
if (events.length > maxEvents)
|
|
26
|
+
events.splice(0, events.length - maxEvents);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=repo.memory.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Generated } from "kysely";
|
|
2
|
+
/**
|
|
3
|
+
* @file Stored column shape of the tool-attempt audit table, copied without schema changes in the
|
|
4
|
+
* generated key order of the host's content database types. The table name is host-owned (see
|
|
5
|
+
* `ToolAttemptTables`).
|
|
6
|
+
*/
|
|
7
|
+
export interface AgentToolAttemptsTable {
|
|
8
|
+
id: Generated<number>;
|
|
9
|
+
attempt_id: string;
|
|
10
|
+
execution_id: string | null;
|
|
11
|
+
workspace_id: string;
|
|
12
|
+
run_id: string;
|
|
13
|
+
tool_id: string;
|
|
14
|
+
principal_id: string;
|
|
15
|
+
phase: string;
|
|
16
|
+
at: string;
|
|
17
|
+
detail: string | null;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=repo.rows.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import type { StorageKernel } from '@jini-ai/core/contracts/storage';
|
|
3
|
+
import type { ToolGapReadPort } from '@jini-ai/core/contracts/site/assistant-host-ports';
|
|
4
|
+
import type { ToolGapEntry } from '@jini-ai/core/contracts/site/daemon-tool-audit';
|
|
5
|
+
import type { ToolAttemptTables } from './repo.js';
|
|
6
|
+
/** The reader's constructor object: the schema-free kernel, the host table name, and the daemon's
|
|
7
|
+
* gap marker and decoder (`TOOL_GAP_AUDIT_ID` / `decodeToolGapEntry` from `@jini-ai/daemon/tool-audit`,
|
|
8
|
+
* bound by the host because this package does not depend on the daemon). */
|
|
9
|
+
export interface ToolGapReaderRequired {
|
|
10
|
+
kernel: StorageKernel<Kysely<unknown>, unknown>;
|
|
11
|
+
tables: ToolAttemptTables;
|
|
12
|
+
toolGapAuditId: string;
|
|
13
|
+
decodeToolGapEntry: (required: {
|
|
14
|
+
json: string | null;
|
|
15
|
+
}, optional?: Record<string, never>) => ToolGapEntry | null;
|
|
16
|
+
}
|
|
17
|
+
/** Read the existing bounded audit table, keeping the newest explanation revision per fallback.
|
|
18
|
+
* One query, scoped to this workspace and principal before grouping; no new table/migration.
|
|
19
|
+
* O(n) over at most the audit retention cap; returns at most 200 redacted summaries.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createToolGapReader(required: ToolGapReaderRequired, _optional?: {}): ToolGapReadPort;
|
|
22
|
+
//# sourceMappingURL=tool-gaps.repo.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Read the existing bounded audit table, keeping the newest explanation revision per fallback.
|
|
2
|
+
* One query, scoped to this workspace and principal before grouping; no new table/migration.
|
|
3
|
+
* O(n) over at most the audit retention cap; returns at most 200 redacted summaries.
|
|
4
|
+
*/
|
|
5
|
+
export function createToolGapReader(required, _optional = {}) {
|
|
6
|
+
const table = required.tables.toolAttempts;
|
|
7
|
+
return {
|
|
8
|
+
async list({ workspaceId, principalId }, { limit = 100 } = {}) {
|
|
9
|
+
const boundedLimit = Number.isFinite(limit) ? Math.max(1, Math.min(200, Math.trunc(limit))) : 100;
|
|
10
|
+
const entries = [];
|
|
11
|
+
// Page on so rows the decoder rejects never use up the caller's limit.
|
|
12
|
+
for (let offset = 0; entries.length < boundedLimit; offset += boundedLimit) {
|
|
13
|
+
const pageOffset = offset;
|
|
14
|
+
const rows = await required.kernel.run(handle => {
|
|
15
|
+
// Host-owned table name needs an explicit column schema, as in the audit sink.
|
|
16
|
+
const db = handle.withTables();
|
|
17
|
+
const page = db.selectFrom(table).select('detail')
|
|
18
|
+
.where('id', 'in', db.selectFrom(table).select(({ fn }) => fn.max('id').as('latest_id'))
|
|
19
|
+
.where('workspace_id', '=', workspaceId).where('principal_id', '=', principalId)
|
|
20
|
+
.where('tool_id', '=', required.toolGapAuditId).groupBy('attempt_id'))
|
|
21
|
+
.orderBy('id', 'desc').limit(boundedLimit);
|
|
22
|
+
return (pageOffset === 0 ? page : page.offset(pageOffset)).execute();
|
|
23
|
+
});
|
|
24
|
+
for (const row of rows) {
|
|
25
|
+
const entry = required.decodeToolGapEntry({ json: row.detail }, {});
|
|
26
|
+
if (entry && entries.length < boundedLimit)
|
|
27
|
+
entries.push(entry);
|
|
28
|
+
}
|
|
29
|
+
if (rows.length < boundedLimit)
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
return entries;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=tool-gaps.repo.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AgentToolDefinition as SharedAgentToolDefinition } from "@jini-ai/core";
|
|
2
|
+
/**
|
|
3
|
+
* @file The site-evidence domain's agent-tool catalog — one tool, `site_collect_page_evidence`.
|
|
4
|
+
*
|
|
5
|
+
* **Why this is a native first-party tool and not part of the host's `site-compliance` Agent Plugin.**
|
|
6
|
+
* Two independent reasons, both load-bearing:
|
|
7
|
+
*
|
|
8
|
+
* 1. An Agent Plugin's tool-bearing surface is its `mcp.json`'s `mcpServers`, which declares a
|
|
9
|
+
* remote or locally-spawned MCP server — never a first-party host tool implementation like this
|
|
10
|
+
* one (the host's agent-plugin capability projection now federates an auto-admitted REMOTE server's
|
|
11
|
+
* own advertised tools; see its 2026-09-10 header — but that path exists for a plugin naming a
|
|
12
|
+
* real MCP endpoint, not for embedding native code such as this domain's handler). A tool
|
|
13
|
+
* implemented here has no `mcp.json` shape to declare itself under at all.
|
|
14
|
+
* 2. Observing what a published page actually renders is not a compliance-only need. SEO checks,
|
|
15
|
+
* theme QA, link checking, and "did my page actually deploy" all want the same evidence.
|
|
16
|
+
* Burying it in a compliance package would strand a general capability in one silo and make the
|
|
17
|
+
* model's tool-selection problem worse by adding a narrow verb where a general one belongs.
|
|
18
|
+
*
|
|
19
|
+
* **What this tool deliberately does not do.** It does not evaluate anything. There is no `pass`,
|
|
20
|
+
* no `score`, no rule id, no severity. The description below says so to the model in as many words,
|
|
21
|
+
* because a tool whose output looked like a verdict would make the compliance skill's own
|
|
22
|
+
* "evidence, never a verdict" contract unenforceable — the verdict would already have been asserted
|
|
23
|
+
* upstream of the reasoning that is supposed to be constrained.
|
|
24
|
+
*/
|
|
25
|
+
export type AgentToolSideEffect = "none" | "mutates-durable-state" | "deletes-durable-state" | "mints-token";
|
|
26
|
+
export type AgentToolDefinition = SharedAgentToolDefinition & {
|
|
27
|
+
sideEffects: AgentToolSideEffect;
|
|
28
|
+
};
|
|
29
|
+
export declare const SITE_EVIDENCE_TOOL_ID = "site_collect_page_evidence";
|
|
30
|
+
export declare const siteEvidenceAgentToolCatalog: AgentToolDefinition[];
|
|
31
|
+
//# sourceMappingURL=agent-tools.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export const SITE_EVIDENCE_TOOL_ID = "site_collect_page_evidence";
|
|
2
|
+
export const siteEvidenceAgentToolCatalog = [
|
|
3
|
+
{
|
|
4
|
+
name: SITE_EVIDENCE_TOOL_ID,
|
|
5
|
+
description: "Loads pages of THIS site in a real headless browser and reports what was actually observed: " +
|
|
6
|
+
"cookies set (names, domains, flags — never values), network requests attempted (method, host, " +
|
|
7
|
+
"path, resource type, and whether they fired before or after a consent click), response headers, " +
|
|
8
|
+
"the page title/lang/text, and the rendered accessibility structure (landmarks, heading outline, " +
|
|
9
|
+
"image alt text, form-control label associations, and colour-contrast samples) — each with the CSS " +
|
|
10
|
+
"selector it came from. Use it for anything a configuration snapshot cannot prove: whether a " +
|
|
11
|
+
"tracking cookie fires before consent, whether a consent banner actually renders, whether a " +
|
|
12
|
+
"privacy policy page is reachable or is still placeholder text, whether headings and labels are " +
|
|
13
|
+
"really there in the published output. Set collectPerformance=true ONLY when the user asks for performance diagnosis: " +
|
|
14
|
+
"adds heap, DOM, mounted hidden panels, iframes, long tasks and plain-language suspects. " +
|
|
15
|
+
"This is a fresh anonymous page, not the operator's open admin tab or restored chat. " +
|
|
16
|
+
"SCOPE: this site's own origin only — it takes site-relative paths, never URLs, and will not " +
|
|
17
|
+
"fetch another host. It loads at most 5 pages per call under a 60s budget, never submits a form " +
|
|
18
|
+
"or any non-GET request, and persists nothing. " +
|
|
19
|
+
"IT REPORTS EVIDENCE, NOT VERDICTS: there is no pass/fail, no score, and no compliance " +
|
|
20
|
+
"assessment in the output, and the absence of an observation is never evidence that something " +
|
|
21
|
+
"is absent — a page listed under 'skipped' was not inspected at all.",
|
|
22
|
+
sideEffects: "none",
|
|
23
|
+
authorization: { permission: "content.read" },
|
|
24
|
+
inputSchema: {
|
|
25
|
+
type: "object",
|
|
26
|
+
additionalProperties: false,
|
|
27
|
+
required: ["paths"],
|
|
28
|
+
properties: {
|
|
29
|
+
paths: {
|
|
30
|
+
type: "array",
|
|
31
|
+
minItems: 1,
|
|
32
|
+
maxItems: 5,
|
|
33
|
+
items: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "A site-relative path on THIS site, e.g. '/', '/pricing', '/legal/privacy'. Absolute URLs, " +
|
|
36
|
+
"protocol-relative paths, and '..' segments are refused and reported in 'skipped'.",
|
|
37
|
+
},
|
|
38
|
+
description: "Up to 5 site-relative paths to load. Anything past the 5th is returned in 'skipped' with reason 'page-cap'.",
|
|
39
|
+
},
|
|
40
|
+
consentAcceptSelector: {
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "Optional CSS selector for this site's own consent-accept control (ask the operator for it). " +
|
|
43
|
+
"When given, the tool clicks it once after the first observation and marks everything seen " +
|
|
44
|
+
"afterwards with phase 'after', which is the only way to tell gated behaviour from ungated. " +
|
|
45
|
+
"When omitted, every observation is phase 'before' and nothing in the result says what " +
|
|
46
|
+
"changes on acceptance.",
|
|
47
|
+
},
|
|
48
|
+
collectPerformance: {
|
|
49
|
+
type: "boolean",
|
|
50
|
+
description: "On-demand only. Defaults false. Numeric performance sample of a fresh anonymous page; unavailable APIs are explicit. Does not inspect an existing signed-in admin tab.",
|
|
51
|
+
},
|
|
52
|
+
collectAccessibility: {
|
|
53
|
+
type: "boolean",
|
|
54
|
+
description: "Defaults to true. Set false to skip the rendered accessibility walk when only cookie/request " +
|
|
55
|
+
"evidence is wanted — a context-size choice, not a faster page load.",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
//# sourceMappingURL=agent-tools.js.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { CaptureBudgetLimits } from "@jini-ai/core/contracts/site/web-evidence-capture-budget";
|
|
2
|
+
/** Deprecated re-export: import these from `@jini-ai/core/contracts/site/web-evidence-capture-budget`; removed at the next major. */
|
|
3
|
+
export type { CaptureBudgetLimits } from "@jini-ai/core/contracts/site/web-evidence-capture-budget";
|
|
1
4
|
/** What the caller asked a capture to do. Every field is optional input from a tool call. */
|
|
2
5
|
export interface CaptureRequest {
|
|
3
6
|
/** Settle time in milliseconds. Replaced by `waitForSeconds` when that is given. */
|
|
@@ -6,16 +9,6 @@ export interface CaptureRequest {
|
|
|
6
9
|
/** The renderer's requested wait, in seconds. */
|
|
7
10
|
waitForSeconds?: number;
|
|
8
11
|
}
|
|
9
|
-
/** Host values. There are no defaults on purpose: the cap and the reserve belong to the host. */
|
|
10
|
-
export interface CaptureBudgetLimits {
|
|
11
|
-
baseMs: number;
|
|
12
|
-
/** Extra time a full-page scroll needs. */
|
|
13
|
-
fullPageMs: number;
|
|
14
|
-
/** The total never exceeds this. */
|
|
15
|
-
capMs: number;
|
|
16
|
-
/** Time kept at the end of the capture for the fallback on the current page. */
|
|
17
|
-
reserveMs: number;
|
|
18
|
-
}
|
|
19
12
|
export interface CaptureBudget {
|
|
20
13
|
totalMs: number;
|
|
21
14
|
/** `totalMs − reserveMs`: ordinary work must be done by then. */
|