@zhivex-ai/harness 1.0.0 → 1.1.0-rc.2
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 +97 -1
- package/README.md +52 -306
- package/SECURITY.md +1 -1
- package/SUPPORT.md +7 -3
- package/benchmarks/README.md +3 -3
- package/contracts/client-protocol-v1.schema.json +341 -0
- package/contracts/public-api.json +100 -1
- package/contracts/stable-api-signatures.json +14 -14
- package/dist/approval-diff.d.ts +45 -0
- package/dist/approval-history.d.ts +38 -0
- package/dist/approval-preview.d.ts +26 -0
- package/dist/cli-credentials.d.ts +38 -0
- package/dist/cli-help.d.ts +3 -0
- package/dist/cli-options.d.ts +1 -1
- package/dist/cli-stream.d.ts +3 -3
- package/dist/cli.d.ts +15 -69
- package/dist/cli.js +13796 -10032
- package/dist/client-contract.d.ts +208 -0
- package/dist/console-commands.d.ts +6 -0
- package/dist/console-context.d.ts +5 -1
- package/dist/console-input.d.ts +44 -4
- package/dist/console-model-catalog.d.ts +25 -0
- package/dist/console-navigation.d.ts +27 -0
- package/dist/console-presentation.d.ts +18 -0
- package/dist/console-welcome.d.ts +13 -0
- package/dist/execution-environment.d.ts +4 -0
- package/dist/harness.d.ts +3 -0
- package/dist/hostile-repository-demo.js +1913 -798
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7908 -6330
- package/dist/local-service.d.ts +34 -0
- package/dist/operations.d.ts +23 -1
- package/dist/orchestration.d.ts +3 -0
- package/dist/persistence-secrets.d.ts +2 -0
- package/dist/recorded-workspace.d.ts +4 -0
- package/dist/run-document.d.ts +91 -0
- package/dist/runtime-policy.d.ts +4 -4
- package/dist/service-cli.d.ts +2 -0
- package/dist/service-cli.js +10858 -0
- package/dist/service-client-cli.d.ts +2 -0
- package/dist/service-events.d.ts +50 -0
- package/dist/sessions.d.ts +3 -0
- package/dist/sqlite-access.d.ts +26 -0
- package/dist/sqlite-database.d.ts +2 -0
- package/dist/state-backup.d.ts +8 -0
- package/dist/task-memory.d.ts +2 -2
- package/dist/terminal-continuation.d.ts +3 -0
- package/dist/terminal-markdown.d.ts +1 -0
- package/dist/terminal-ui.d.ts +5 -0
- package/dist/usage-ledger.d.ts +84 -0
- package/dist/verify-historical-migrations.js +5699 -5191
- package/dist/workspace.d.ts +22 -0
- package/dist/zhx.js +13796 -10032
- package/docs/CLI.md +136 -30
- package/docs/CLIENT_PROTOCOL.md +212 -0
- package/docs/CREDENTIALS.md +59 -0
- package/docs/DURABLE_OPERATIONS.md +2 -2
- package/docs/FIRST_USE.md +82 -0
- package/docs/FIRST_USE_EXAMPLE.md +40 -0
- package/docs/HOSTILE_REPOSITORY_DEMO.md +1 -1
- package/docs/LOCAL_SERVICE.md +142 -0
- package/docs/README.md +24 -23
- package/docs/THREAT_MODEL.md +1 -1
- package/docs/TIME_TO_SAFE_FIX.md +2 -2
- package/docs/USAGE.md +181 -0
- package/evaluations/daily-cli-cohort.json +33 -0
- package/evaluations/representative-assembly-matrix.json +19 -1
- package/examples/README.md +26 -0
- package/examples/first-use/greeting.test.ts +3 -0
- package/examples/first-use/greeting.ts +1 -0
- package/examples/first-use/package.json +7 -0
- package/package.json +34 -9
- package/ROADMAP.md +0 -414
- package/benchmarks/baselines/context-navigation-2026-09-09.json +0 -94
- package/benchmarks/baselines/efficiency-2026-09-08.json +0 -233
- package/benchmarks/baselines/external-final-2026-09-08.json +0 -588
- package/benchmarks/baselines/external-intermediate-2026-09-08.json +0 -116
- package/benchmarks/baselines/external-matched-openai-2026-09-08.json +0 -1922
- package/benchmarks/baselines/external-matched-qwen-2026-09-08.json +0 -1706
- package/benchmarks/baselines/external-pilot-2026-09-08.json +0 -439
- package/benchmarks/baselines/external-qwen-flash-2026-09-08.json +0 -1570
- package/benchmarks/baselines/external-qwen-remediation-2026-09-09.json +0 -1509
- package/benchmarks/baselines/external-qwen-sdk-114-progress-2026-09-09.json +0 -2509
- package/benchmarks/baselines/external-sdk-upgrade-2026-09-08.json +0 -564
- package/benchmarks/baselines/external-verifier-recovery-2026-09-09.json +0 -794
- package/benchmarks/baselines/full-harness-review-2026-09-10.json +0 -134
- package/benchmarks/baselines/harness-audit-2026-09-09.json +0 -136
- package/benchmarks/baselines/harness-remediation-2026-09-09.json +0 -160
- package/benchmarks/baselines/oci-remediation-2026-09-10.json +0 -535
- package/benchmarks/baselines/rc14-holdout-2026-09-10.json +0 -854
- package/benchmarks/baselines/repair-architecture-audit-2026-09-09.json +0 -75
- package/benchmarks/baselines/time-to-safe-fix-live-expanded-2026-08-21.json +0 -186
- package/benchmarks/baselines/time-to-safe-fix-live-smoke-2026-08-21.json +0 -186
- package/docs/GA_READINESS.md +0 -29
- package/docs/GEMINI_1_0_DECISION.md +0 -9
- package/docs/LIVE_CERTIFICATION.md +0 -107
- package/docs/RC13_SECURITY_REVIEW.md +0 -28
- package/docs/RC14_DELEGATED_SECURITY_DECISION.md +0 -80
- package/docs/RC14_SECURITY_REVIEW.md +0 -40
- package/docs/RELEASE.md +0 -96
- package/docs/ROLLBACK.md +0 -9
- package/docs/SECURITY_REVIEW_EVIDENCE.md +0 -17
- package/docs/ga-readiness.json +0 -366
- package/docs/reports/EFFICIENCY_REVIEW.md +0 -156
- package/docs/reports/EXTERNAL_COMPARISON.md +0 -434
- package/docs/reports/FULL_HARNESS_REVIEW_2026-09-10.md +0 -200
- package/docs/reports/GA_BUDGET_REMEDIATION_2026-09-19.md +0 -38
- package/docs/reports/GA_REPAIR_RECOVERY_2026-09-19.md +0 -700
- package/docs/reports/GA_VALIDATION_2026-09-19.md +0 -111
- package/docs/reports/HARNESS_ARCHITECTURE_REVIEW_2026-09-09.md +0 -202
- package/docs/reports/HARNESS_AUDIT_2026-09-09.md +0 -306
- package/docs/reports/HARNESS_REMEDIATION_2026-09-09.md +0 -74
- package/docs/reports/HARNESS_REMEDIATION_2026-09-10.md +0 -90
- package/docs/reports/MODEL_COMPARISON_2026-09-09.md +0 -184
- package/docs/reports/QWEN_REMEDIATION_COMPARISON_2026-09-09.md +0 -142
- package/docs/reports/RC14_VALIDATION_2026-09-10.md +0 -45
- package/docs/reports/README.md +0 -26
- package/docs/reports/evidence/ga-budget-remediation-2026-09-19.json +0 -133
- package/docs/reports/evidence/ga-catalog-ablation-2026-09-19.json +0 -699
- package/docs/reports/evidence/ga-catalog-ablation-plan-2026-09-19.json +0 -40
- package/docs/reports/evidence/ga-catalog-observed-2026-09-19.json +0 -985
- package/docs/reports/evidence/ga-catalog-observed-plan-2026-09-19.json +0 -28
- package/docs/reports/evidence/ga-catalog-observed-status-2026-09-19.json +0 -15
- package/docs/reports/evidence/ga-complete-local-check-2026-09-19.json +0 -47
- package/docs/reports/evidence/ga-completion-reminder-2026-09-19.json +0 -22
- package/docs/reports/evidence/ga-fresh-cohort-plan-2026-09-19.json +0 -54
- package/docs/reports/evidence/ga-fresh-cohort-preparation-2026-09-19.json +0 -242
- package/docs/reports/evidence/ga-fresh-cohort-result-2026-09-19.json +0 -4318
- package/docs/reports/evidence/ga-local-validation-followup-2026-09-19.json +0 -66
- package/docs/reports/evidence/ga-node-consumers-2026-09-19.json +0 -31
- package/docs/reports/evidence/ga-package-content-validation-2026-09-19.json +0 -22
- package/docs/reports/evidence/ga-plan-completion-2026-09-19.json +0 -39
- package/docs/reports/evidence/ga-plan-reserve-2026-09-19.json +0 -573
- package/docs/reports/evidence/ga-plan-reserve-plan-2026-09-19.json +0 -24
- package/docs/reports/evidence/ga-plan-transition-2026-09-19.json +0 -19
- package/docs/reports/evidence/ga-private-verifier-plan-2026-09-19.json +0 -24
- package/docs/reports/evidence/ga-private-verifier-root-cause-2026-09-19.json +0 -41
- package/docs/reports/evidence/ga-published-sdk-2026-09-19.json +0 -35
- package/docs/reports/evidence/ga-python-checkout-imports-2026-09-19.json +0 -95
- package/docs/reports/evidence/ga-python-origin-delivery-2026-09-19.json +0 -211
- package/docs/reports/evidence/ga-python-origin-delivery-plan-2026-09-19.json +0 -27
- package/docs/reports/evidence/ga-qwen-patched-package-2026-09-19.json +0 -1092
- package/docs/reports/evidence/ga-qwen-patched-package-plan-2026-09-19.json +0 -18
- package/docs/reports/evidence/ga-qwen-published-2026-09-19.json +0 -571
- package/docs/reports/evidence/ga-qwen-published-plan-2026-09-19.json +0 -18
- package/docs/reports/evidence/ga-qwen-tool-choice-2026-09-19.json +0 -85
- package/docs/reports/evidence/ga-qwen-tool-choice-patched-2026-09-19.json +0 -85
- package/docs/reports/evidence/ga-recovery-development-2026-09-19.json +0 -1066
- package/docs/reports/evidence/ga-recovery-graded-development-2026-09-19.json +0 -1313
- package/docs/reports/evidence/ga-recovery-graded-v2-2026-09-19.json +0 -1151
- package/docs/reports/evidence/ga-recovery-v3-2026-09-19.json +0 -3943
- package/docs/reports/evidence/ga-recovery-v4-2026-09-19.json +0 -1055
- package/docs/reports/evidence/ga-recovery-v5-2026-09-19.json +0 -1245
- package/docs/reports/evidence/ga-recovery-v6-2026-09-19.json +0 -699
- package/docs/reports/evidence/ga-recovery-v7-2026-09-19.json +0 -854
- package/docs/reports/evidence/ga-recovery-v8-2026-09-19.json +0 -596
- package/docs/reports/evidence/ga-required-delivery-2026-09-19.json +0 -25
- package/docs/reports/evidence/ga-required-delivery-live-2026-09-19.json +0 -1337
- package/docs/reports/evidence/ga-required-delivery-live-plan-2026-09-19.json +0 -25
- package/docs/reports/evidence/ga-retained-candidate-grading-2026-09-19.json +0 -30
- package/docs/reports/evidence/ga-tool-selection-live-2026-09-19.json +0 -559
- package/docs/reports/evidence/ga-tool-selection-live-plan-2026-09-19.json +0 -28
- package/docs/reports/evidence/ga-tool-selection-recovery-2026-09-19.json +0 -27
- package/docs/reports/evidence/ga-validation-2026-09-19.json +0 -236
- package/docs/reports/evidence/ga-verifier-discovery-live-2026-09-19.json +0 -1369
- package/docs/reports/evidence/ga-verifier-discovery-plan-2026-09-19.json +0 -29
- package/docs/reports/evidence/ga-verifier-failure-identification-2026-09-19.json +0 -30
- package/docs/reports/evidence/ga-verifier-feedback-2026-09-19.json +0 -65
- package/docs/reports/evidence/ga-verifier-hints-live-2026-09-19.json +0 -1297
- package/docs/reports/evidence/ga-verifier-hints-plan-2026-09-19.json +0 -27
- package/docs/reports/evidence/ga-work-boundary-context-analysis-2026-09-19.json +0 -113
- package/docs/reports/evidence/ga-work-boundary-live-2026-09-19.json +0 -301
- package/docs/reports/evidence/ga-work-boundary-live-plan-2026-09-19.json +0 -84
- package/docs/reports/evidence/ga-work-budget-planning-2026-09-19.json +0 -32
- package/docs/reports/evidence/ga-working-context-2026-09-19.json +0 -22
- package/docs/reports/evidence/rc14-delegated-security-review-2026-09-20.json +0 -81
- package/docs/reports/evidence/rc14-ga-gate-2026-09-20.json +0 -18
- package/docs/reports/evidence/rc14-representative-2026-09-20.json +0 -509
- package/docs/reports/evidence/rc14-security-regressions-2026-09-20.json +0 -64
- package/docs/reports/evidence/security-current-2026-09-19.json +0 -91
- package/docs/reports/evidence/security-remediation-2026-09-19.json +0 -97
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type AgentStreamEvent } from "@zhivex-ai/agents";
|
|
2
|
+
import type { HarnessConfig } from "./config.js";
|
|
3
|
+
export interface HarnessActivityEvent {
|
|
4
|
+
schemaVersion: 1;
|
|
5
|
+
eventId: string;
|
|
6
|
+
sequence: number;
|
|
7
|
+
sessionId: string;
|
|
8
|
+
runId: string;
|
|
9
|
+
at: number;
|
|
10
|
+
activity: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export interface HarnessActivityRun {
|
|
13
|
+
text: string;
|
|
14
|
+
status: string;
|
|
15
|
+
truncated: boolean;
|
|
16
|
+
prompt?: string;
|
|
17
|
+
tools?: Record<string, {
|
|
18
|
+
name: string;
|
|
19
|
+
status: string;
|
|
20
|
+
exitCode?: number;
|
|
21
|
+
timedOut?: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export interface HarnessActivitySnapshot {
|
|
25
|
+
schemaVersion: 1;
|
|
26
|
+
sessionId: string;
|
|
27
|
+
sequence: number;
|
|
28
|
+
runs: Record<string, HarnessActivityRun>;
|
|
29
|
+
}
|
|
30
|
+
export interface HarnessActivityPage {
|
|
31
|
+
schemaVersion: 1;
|
|
32
|
+
cursorExpired: boolean;
|
|
33
|
+
nextCursor: number;
|
|
34
|
+
events: HarnessActivityEvent[];
|
|
35
|
+
snapshot?: HarnessActivitySnapshot;
|
|
36
|
+
}
|
|
37
|
+
export interface HarnessActivityStore {
|
|
38
|
+
prompt(sessionId: string, runId: string, prompt: string): void;
|
|
39
|
+
append(sessionId: string, runId: string, event: AgentStreamEvent): void;
|
|
40
|
+
checkpoint(sessionId: string, runId: string, status: string): void;
|
|
41
|
+
replay(sessionId: string, after?: number): HarnessActivityPage;
|
|
42
|
+
close(): void;
|
|
43
|
+
}
|
|
44
|
+
export interface HarnessActivityOptions {
|
|
45
|
+
maxEvents?: number;
|
|
46
|
+
retentionMs?: number;
|
|
47
|
+
sensitiveValues?: readonly string[];
|
|
48
|
+
now?: () => number;
|
|
49
|
+
}
|
|
50
|
+
export declare const openHarnessActivityStore: (config: HarnessConfig, options?: HarnessActivityOptions) => Promise<HarnessActivityStore>;
|
package/dist/sessions.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ export interface UpdateSessionInput {
|
|
|
61
61
|
expectedRevision?: number;
|
|
62
62
|
}
|
|
63
63
|
export interface ListSessionsQuery {
|
|
64
|
+
/** Literal case-insensitive substring of the title or session ID, before limiting. */
|
|
65
|
+
search?: string;
|
|
64
66
|
limit?: number;
|
|
65
67
|
includeArchived?: boolean;
|
|
66
68
|
includeDeleted?: boolean;
|
|
@@ -83,6 +85,7 @@ export interface OpenSessionStoreOptions {
|
|
|
83
85
|
maxRunsPerSession?: number;
|
|
84
86
|
maxMetadataBytes?: number;
|
|
85
87
|
maxIndexBytes?: number;
|
|
88
|
+
busyTimeoutMs?: number;
|
|
86
89
|
now?: () => number;
|
|
87
90
|
}
|
|
88
91
|
export interface CliSessionStore {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface SqliteAccessLease {
|
|
2
|
+
readonly fd: number;
|
|
3
|
+
close(): void;
|
|
4
|
+
}
|
|
5
|
+
/** macOS cooperative access protocol. Each core connection holds a shared kernel
|
|
6
|
+
* lock; an update may acquire exclusive access only after all such connections
|
|
7
|
+
* close. Keep the lock inode permanently, including through DB replacement.
|
|
8
|
+
* This does not certify exclusion of older clients or arbitrary SQLite libraries.
|
|
9
|
+
*/
|
|
10
|
+
export declare function acquireSqliteAccess(databasePath: string, exclusive?: boolean): SqliteAccessLease | undefined;
|
|
11
|
+
export declare function retainSqliteAccess(lease: SqliteAccessLease, databasePath: string): () => void;
|
|
12
|
+
/** Host-only transfer descriptor. Source verifier connections must close before
|
|
13
|
+
* transfer so SQLite handles themselves are not part of the handoff contract.
|
|
14
|
+
*/
|
|
15
|
+
export declare function exclusiveSqliteAccessDescriptor(lease: SqliteAccessLease, databasePath: string): number;
|
|
16
|
+
/** Worker-only bootstrap after the native helper has verified/acquired LOCK_EX
|
|
17
|
+
* on inherited fd 4..603. The private handoff supplies the corresponding paths.
|
|
18
|
+
* No arbitrary IPC descriptor may invoke this; the JS layer verifies inode binding,
|
|
19
|
+
* while the trusted native helper establishes lock mode before exec.
|
|
20
|
+
*/
|
|
21
|
+
export declare function adoptExclusiveSqliteAccess(databasePath: string, fd: number): SqliteAccessLease;
|
|
22
|
+
/** Existing exclusive owner can open its own verifier/backup connections without
|
|
23
|
+
* deadlocking on another shared lock. Only a live lease issued in this process
|
|
24
|
+
* works; a structurally similar object or a replaced lock inode is rejected.
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateSqliteAccess(lease: SqliteAccessLease, databasePath: string): void;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { type SqliteAccessLease } from "./sqlite-access.js";
|
|
1
2
|
export interface SqliteDatabaseOptions {
|
|
2
3
|
create?: boolean;
|
|
3
4
|
readonly?: boolean;
|
|
4
5
|
strict?: boolean;
|
|
6
|
+
accessLease?: SqliteAccessLease;
|
|
5
7
|
}
|
|
6
8
|
export interface SqliteStatement<TResult extends object = Record<string, unknown>, TParameters extends readonly unknown[] = readonly unknown[]> {
|
|
7
9
|
run(...parameters: TParameters): unknown;
|
package/dist/state-backup.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { HarnessConfig } from "./config.js";
|
|
3
|
+
import type { SqliteAccessLease } from "./sqlite-access.js";
|
|
3
4
|
export declare const HARNESS_STATE_BACKUP_SCHEMA_VERSION: 1;
|
|
4
5
|
export declare const HARNESS_STATE_BACKUP_MAX_BYTES: number;
|
|
5
6
|
export declare const stateBackupBundleSchema: z.ZodObject<{
|
|
@@ -108,6 +109,13 @@ export interface HarnessStateImportOptions {
|
|
|
108
109
|
failAfterWrites?: number;
|
|
109
110
|
}
|
|
110
111
|
export declare const createHarnessStateBackup: (config: HarnessConfig) => Promise<HarnessStateBackupBundle>;
|
|
112
|
+
/** Internal desktop archive reader: preserve the recorded workspace/scope binding
|
|
113
|
+
* when its checkout has been removed. Reads existing SQLite only; no migration,
|
|
114
|
+
* workspace creation, import or rebinding. Not exported by the public entrypoint.
|
|
115
|
+
*/
|
|
116
|
+
export declare const createArchivedHarnessStateBackup: (config: HarnessConfig, options?: {
|
|
117
|
+
accessLease?: SqliteAccessLease;
|
|
118
|
+
}) => Promise<HarnessStateBackupBundle>;
|
|
111
119
|
export declare const exportHarnessStateBackup: (config: HarnessConfig, target: string) => Promise<{
|
|
112
120
|
schemaVersion: 1;
|
|
113
121
|
kind: "state-export";
|
package/dist/task-memory.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const captureTaskSources: (metadata: unknown, messages: readonly
|
|
|
11
11
|
text: string;
|
|
12
12
|
}[];
|
|
13
13
|
export declare const createTaskTools: () => {
|
|
14
|
-
read_task: import("@zhivex-ai/
|
|
14
|
+
read_task: import("@zhivex-ai/core").ToolDefinition<z.ZodObject<{
|
|
15
15
|
id: z.ZodOptional<z.ZodString>;
|
|
16
16
|
offset: z.ZodDefault<z.ZodNumber>;
|
|
17
17
|
}, z.core.$strip>, {
|
|
@@ -22,7 +22,7 @@ export declare const createTaskTools: () => {
|
|
|
22
22
|
totalCharacters: number;
|
|
23
23
|
nextOffset: number | null;
|
|
24
24
|
}, any>;
|
|
25
|
-
repair_plan: import("@zhivex-ai/
|
|
25
|
+
repair_plan: import("@zhivex-ai/core").ToolDefinition<z.ZodObject<{
|
|
26
26
|
hypothesis: z.ZodString;
|
|
27
27
|
expectedBehavior: z.ZodString;
|
|
28
28
|
paths: z.ZodArray<z.ZodString>;
|
package/dist/terminal-ui.d.ts
CHANGED
|
@@ -33,6 +33,11 @@ export interface TerminalAppearanceOptions {
|
|
|
33
33
|
color?: boolean;
|
|
34
34
|
}
|
|
35
35
|
export declare const terminalSupportsColor: (isTTY: boolean, env?: Readonly<Record<string, string | undefined>>) => boolean;
|
|
36
|
+
export declare const formatVerificationSummary: (results: readonly {
|
|
37
|
+
toolName: string;
|
|
38
|
+
output?: unknown;
|
|
39
|
+
isError?: boolean;
|
|
40
|
+
}[]) => string;
|
|
36
41
|
/**
|
|
37
42
|
* Produce a compact activity line from a redacted event subset. Tool inputs,
|
|
38
43
|
* outputs, provider payloads, repository text, and raw errors are never read.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type LanguageModel } from "@zhivex-ai/core";
|
|
3
|
+
import type { AgentRunStore } from "@zhivex-ai/agents/ops";
|
|
4
|
+
import type { HarnessConfig } from "./config.js";
|
|
5
|
+
export declare const USAGE_LEDGER_KEY = "zhivexUsageLedger";
|
|
6
|
+
export declare const usagePricingSchema: z.ZodObject<{
|
|
7
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
8
|
+
prices: z.ZodArray<z.ZodObject<{
|
|
9
|
+
provider: z.ZodString;
|
|
10
|
+
model: z.ZodString;
|
|
11
|
+
inputUsdPerMillion: z.ZodNumber;
|
|
12
|
+
outputUsdPerMillion: z.ZodNumber;
|
|
13
|
+
source: z.ZodString;
|
|
14
|
+
asOf: z.ZodISODateTime;
|
|
15
|
+
expiresAt: z.ZodISODateTime;
|
|
16
|
+
}, z.core.$strict>>;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
export type UsagePricing = z.infer<typeof usagePricingSchema>;
|
|
19
|
+
export interface UsageAccountingOptions {
|
|
20
|
+
pricing?: UsagePricing;
|
|
21
|
+
limitUsd?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare const inspectUsageLedger: (value: unknown) => {
|
|
24
|
+
calls: number;
|
|
25
|
+
inputTokens: number;
|
|
26
|
+
outputTokens: number;
|
|
27
|
+
usageComplete: boolean;
|
|
28
|
+
estimatedUsd: number | null;
|
|
29
|
+
limitUsd: number | null;
|
|
30
|
+
schemaVersion: 1;
|
|
31
|
+
runId: string;
|
|
32
|
+
historicalUsageUnknown?: boolean | undefined;
|
|
33
|
+
costKind: "estimate-not-invoice";
|
|
34
|
+
routes: {
|
|
35
|
+
provider: string;
|
|
36
|
+
model: string;
|
|
37
|
+
calls: number;
|
|
38
|
+
inputTokens: number;
|
|
39
|
+
outputTokens: number;
|
|
40
|
+
unknownCalls: number;
|
|
41
|
+
estimatedUsd: number | null;
|
|
42
|
+
priceStatuses: ("estimate" | "missing" | "stale")[];
|
|
43
|
+
}[];
|
|
44
|
+
} | null;
|
|
45
|
+
export declare const formatUsageLedger: (value: unknown) => string;
|
|
46
|
+
/** A separate append-only transport ledger. SDK rollups are never added to these calls. */
|
|
47
|
+
export declare class UsageLedger {
|
|
48
|
+
private readonly database;
|
|
49
|
+
private readonly key;
|
|
50
|
+
private readonly options;
|
|
51
|
+
private readonly now;
|
|
52
|
+
private constructor();
|
|
53
|
+
static open(config: HarnessConfig, options?: UsageAccountingOptions, now?: () => number): Promise<UsageLedger>;
|
|
54
|
+
close(): void;
|
|
55
|
+
assertResume(runId: string): void;
|
|
56
|
+
private policy;
|
|
57
|
+
run<T>(runId: string, operation: () => Promise<T>, historicalUsageUnknown?: boolean): Promise<T>;
|
|
58
|
+
summary(runId: string): {
|
|
59
|
+
schemaVersion: number;
|
|
60
|
+
runId: string;
|
|
61
|
+
calls: number;
|
|
62
|
+
routes: {
|
|
63
|
+
provider: string;
|
|
64
|
+
model: string;
|
|
65
|
+
calls: number;
|
|
66
|
+
inputTokens: number;
|
|
67
|
+
outputTokens: number;
|
|
68
|
+
unknownCalls: number;
|
|
69
|
+
estimatedUsd: number | null;
|
|
70
|
+
priceStatuses: string[];
|
|
71
|
+
}[];
|
|
72
|
+
inputTokens: number;
|
|
73
|
+
outputTokens: number;
|
|
74
|
+
historicalUsageUnknown: boolean;
|
|
75
|
+
usageComplete: boolean;
|
|
76
|
+
estimatedUsd: number | null;
|
|
77
|
+
limitUsd: number | null;
|
|
78
|
+
costKind: "estimate-not-invoice";
|
|
79
|
+
};
|
|
80
|
+
private begin;
|
|
81
|
+
private finish;
|
|
82
|
+
model(model: LanguageModel): LanguageModel;
|
|
83
|
+
store(store: AgentRunStore): AgentRunStore;
|
|
84
|
+
}
|