@jitsusama/agentic-harness.core 0.2.0 → 0.3.1

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 CHANGED
File without changes
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Google Calendar API client.
3
3
  */
4
- import { google } from "googleapis";
4
+ import { google } from "./client.js";
5
5
  /**
6
6
  * List calendar events in a date range.
7
7
  */
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The googleapis client, loaded on first use.
3
+ *
4
+ * googleapis bundles a client for every Google API, about 1,800
5
+ * modules, and every extension that imports this package would load
6
+ * all of them at startup. This stands in for its `google` export and
7
+ * loads the real one the first time any API is asked for.
8
+ */
9
+ import type { GoogleApis } from "googleapis";
10
+ export declare const google: GoogleApis;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The googleapis client, loaded on first use.
3
+ *
4
+ * googleapis bundles a client for every Google API, about 1,800
5
+ * modules, and every extension that imports this package would load
6
+ * all of them at startup. This stands in for its `google` export and
7
+ * loads the real one the first time any API is asked for.
8
+ */
9
+ import { createRequire } from "node:module";
10
+ const require = createRequire(import.meta.url);
11
+ let loaded;
12
+ function load() {
13
+ loaded ??= require("googleapis").google;
14
+ return loaded;
15
+ }
16
+ export const google = new Proxy({}, {
17
+ get(_, property) {
18
+ const real = load();
19
+ const value = Reflect.get(real, property);
20
+ // The API factories read shared options off `this`.
21
+ return typeof value === "function" ? value.bind(real) : value;
22
+ },
23
+ });
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Google Docs API client.
3
3
  */
4
- import { google } from "googleapis";
4
+ import { google } from "./client.js";
5
5
  /**
6
6
  * Get document content, including all tabs.
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Google Drive API client.
3
3
  */
4
- import { google } from "googleapis";
4
+ import { google } from "./client.js";
5
5
  /**
6
6
  * List Drive files with optional filtering.
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Gmail API client.
3
3
  */
4
- import { google } from "googleapis";
4
+ import { google } from "./client.js";
5
5
  /**
6
6
  * Search emails using Gmail query syntax.
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Google Sheets API client.
3
3
  */
4
- import { google } from "googleapis";
4
+ import { google } from "./client.js";
5
5
  /**
6
6
  * Get spreadsheet content.
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Google Slides API client.
3
3
  */
4
- import { google } from "googleapis";
4
+ import { google } from "./client.js";
5
5
  /**
6
6
  * Get presentation content.
7
7
  */
@@ -7,7 +7,15 @@
7
7
  * own database file. Rows are queryable on demand, roll up
8
8
  * into periodic per-model and per-persona summaries before
9
9
  * they age out, and drive a compact status-line figure.
10
+ *
11
+ * The ledger beside it covers the other side of the bill: the
12
+ * main loop's own turns, addressed by content so a total can
13
+ * be trusted.
14
+ *
15
+ * Reading a harness's log format into those turns is that
16
+ * harness's own business and lives in its package.
10
17
  */
18
+ export { type CallScope, type CostDimension, type CostSlice, type DroppedCallRecord, type LedgerTotal, openTurnStore, type PaybackReplay, type RecordOutcome, type Regret, type RegretReport, type RepeatedCall, type SessionRecord, type ToolCallRecord, type TurnKind, type TurnRecord, type TurnStore, type VerifierKind, type VerifierOutcome, } from "./ledger/index.js";
11
19
  export { type RunRecorder, type RunRecordInput, recordRunEverywhere, registerRunRecorder, runRecordFrom, } from "./recorder.js";
12
20
  export { openRunStore, type RunQuery, type RunStore } from "./store.js";
13
21
  export type { RunCost, RunRecord, RunRollup, RunSummary, RunTokens, VerifyOutcome, } from "./types.js";
@@ -7,6 +7,14 @@
7
7
  * own database file. Rows are queryable on demand, roll up
8
8
  * into periodic per-model and per-persona summaries before
9
9
  * they age out, and drive a compact status-line figure.
10
+ *
11
+ * The ledger beside it covers the other side of the bill: the
12
+ * main loop's own turns, addressed by content so a total can
13
+ * be trusted.
14
+ *
15
+ * Reading a harness's log format into those turns is that
16
+ * harness's own business and lives in its package.
10
17
  */
18
+ export { openTurnStore, } from "./ledger/index.js";
11
19
  export { recordRunEverywhere, registerRunRecorder, runRecordFrom, } from "./recorder.js";
12
20
  export { openRunStore } from "./store.js";
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The ledger: a store of billable turns, and what one is.
3
+ *
4
+ * Cost is derived from the logs a harness already writes rather than
5
+ * recorded a second time, so there is exactly one writer of the truth
6
+ * and the ledger can be rebuilt from scratch whenever its shape
7
+ * changes.
8
+ *
9
+ * Reading those logs is not here. A turn is a portable idea; the format
10
+ * it was written in is not, so each harness parses its own and hands
11
+ * over records. This module knows what a turn is and where to keep it.
12
+ */
13
+ export { type CostDimension, type CostSlice, type LedgerTotal, openTurnStore, type RecordOutcome, type TurnStore, } from "./store.js";
14
+ export type { CallScope, DroppedCallRecord, PaybackReplay, Regret, RegretReport, RepeatedCall, SessionRecord, ToolCallRecord, TurnKind, TurnRecord, VerifierKind, VerifierOutcome, } from "./types.js";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The ledger: a store of billable turns, and what one is.
3
+ *
4
+ * Cost is derived from the logs a harness already writes rather than
5
+ * recorded a second time, so there is exactly one writer of the truth
6
+ * and the ledger can be rebuilt from scratch whenever its shape
7
+ * changes.
8
+ *
9
+ * Reading those logs is not here. A turn is a portable idea; the format
10
+ * it was written in is not, so each harness parses its own and hands
11
+ * over records. This module knows what a turn is and where to keep it.
12
+ */
13
+ export { openTurnStore, } from "./store.js";
@@ -0,0 +1,50 @@
1
+ import type { CallScope, DroppedCallRecord, PaybackReplay, RegretReport, RepeatedCall, SessionRecord, ToolCallRecord, TurnRecord, VerifierOutcome } from "./types.js";
2
+ /** What a dimension's slice of spend came to. */
3
+ export interface CostSlice {
4
+ readonly key: string;
5
+ readonly cost: number;
6
+ readonly turns: number;
7
+ }
8
+ /** Everything the ledger holds, with its own blind spots stated. */
9
+ export interface LedgerTotal {
10
+ readonly cost: number;
11
+ readonly turns: number;
12
+ /** Turns held with no cost, so a total can say what it is missing. */
13
+ readonly unmetered: number;
14
+ readonly cacheWriteTokens: number;
15
+ /** Of those, the ones billed at the one-hour rate. */
16
+ readonly cacheWrite1hTokens: number;
17
+ }
18
+ /** How many turns a write added, and how many it had already seen. */
19
+ export interface RecordOutcome {
20
+ readonly inserted: number;
21
+ readonly duplicates: number;
22
+ }
23
+ /** What a total or a slice may be narrowed to. */
24
+ export type CostDimension = "model" | "session" | "kind" | "day" | "repo" | "quest";
25
+ /** A content-addressed store of billable turns. */
26
+ export interface TurnStore {
27
+ recordTurns(turns: readonly TurnRecord[]): Promise<RecordOutcome>;
28
+ recordSession(session: SessionRecord): Promise<void>;
29
+ recordCalls(calls: readonly ToolCallRecord[]): Promise<RecordOutcome>;
30
+ queryCalls(): Promise<ToolCallRecord[]>;
31
+ /** Arguments asked more than once in one session, heaviest first. */
32
+ repeatedCalls(scope?: CallScope): Promise<RepeatedCall[]>;
33
+ recordDropped(dropped: readonly DroppedCallRecord[]): Promise<RecordOutcome>;
34
+ queryDropped(): Promise<DroppedCallRecord[]>;
35
+ /** Dropped calls asked again after the drop, with how many could have been. */
36
+ regret(scope?: CallScope): Promise<RegretReport>;
37
+ /** Pass, fail and unknown counts per verifier kind that ran at all. */
38
+ verifierOutcomes(): Promise<VerifierOutcome[]>;
39
+ /** How real compactions compare against the payback test. */
40
+ paybackReplay(): Promise<PaybackReplay>;
41
+ total(): Promise<LedgerTotal>;
42
+ costBy(dimension: CostDimension): Promise<CostSlice[]>;
43
+ close(): Promise<void>;
44
+ }
45
+ /**
46
+ * Open (creating if needed) a turn ledger at the given path. Safe to
47
+ * point at the same file as the run store: the tables are disjoint and
48
+ * WAL keeps readers clear of the single writer.
49
+ */
50
+ export declare function openTurnStore(dbPath: string): Promise<TurnStore>;