@parcha/agentrun-import 0.1.0-beta.68 → 0.1.0-beta.69
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/reader.d.ts +3 -0
- package/dist/readers/cursor.js +1 -0
- package/dist/wrapped.d.ts +8 -0
- package/dist/wrapped.js +13 -6
- package/package.json +1 -1
package/dist/reader.d.ts
CHANGED
|
@@ -96,6 +96,9 @@ export type Reader<S extends string = string, C = unknown> = {
|
|
|
96
96
|
/** The session the locator's ran under, from a bounded head of its file, never the rest (Codex's first line): what ties
|
|
97
97
|
* a subagent a caller will not read (over its cap) to its run. None: no parent named there. */
|
|
98
98
|
parentOf?: (locator: Locator) => Promise<string | undefined>;
|
|
99
|
+
/** The source keeps no time for each request: the read dates every request at its session's start (Cursor). Wrapped
|
|
100
|
+
* counts those requests' time as unknown and adds none of it to the time at work. */
|
|
101
|
+
untimed?: true;
|
|
99
102
|
/** Subagents' sessions that name no parent themselves, each with the session it ran under (`of`). */
|
|
100
103
|
children?: (home: string, env?: Env) => Promise<{
|
|
101
104
|
locator: Locator;
|
package/dist/readers/cursor.js
CHANGED
|
@@ -299,6 +299,7 @@ export const cursor = {
|
|
|
299
299
|
source: "cursor",
|
|
300
300
|
name: "Cursor",
|
|
301
301
|
harness: "cursor",
|
|
302
|
+
untimed: true,
|
|
302
303
|
discover: async (home, env = {}) => (await storesIn(configDir(home, env))).map((file) => ({ file })),
|
|
303
304
|
read: (locator, _cursor, options = {}) => readChat(locator.file, options),
|
|
304
305
|
idOf: ({ file }) => cursorSessionId(file),
|
package/dist/wrapped.d.ts
CHANGED
|
@@ -13,6 +13,12 @@ export type Wrapped = {
|
|
|
13
13
|
* unlisted model, no usage), so a sum that left some out says so. */
|
|
14
14
|
cost: number;
|
|
15
15
|
unpricedRequests: number;
|
|
16
|
+
/** Requests whose session recorded no tokens for them (Cursor's CLI keeps none; pi leaves usage off an aborted
|
|
17
|
+
* request): `tokens` holds none of theirs, so a year of only these has unknown tokens, not zero. */
|
|
18
|
+
tokensUnknownRequests: number;
|
|
19
|
+
/** The year's requests whose time is only their session's start (Cursor keeps no message times): counted in the hours
|
|
20
|
+
* and days at that start, never in `activeMs`. */
|
|
21
|
+
timeUnknownRequests: number;
|
|
16
22
|
/** Local days with a request, ascending: that day's requests and tokens (input, output and cache together). */
|
|
17
23
|
days: {
|
|
18
24
|
day: string;
|
|
@@ -30,6 +36,7 @@ export type Wrapped = {
|
|
|
30
36
|
sessions: number;
|
|
31
37
|
requests: number;
|
|
32
38
|
tokens: number;
|
|
39
|
+
tokensUnknownRequests: number;
|
|
33
40
|
}[];
|
|
34
41
|
/** `unpricedRequests` per model: of its requests, those its `cost` leaves out (all of them: no price was known). */
|
|
35
42
|
models: {
|
|
@@ -38,6 +45,7 @@ export type Wrapped = {
|
|
|
38
45
|
tokens: Tokens;
|
|
39
46
|
cost: number;
|
|
40
47
|
unpricedRequests: number;
|
|
48
|
+
tokensUnknownRequests: number;
|
|
41
49
|
}[];
|
|
42
50
|
sources: {
|
|
43
51
|
source: string;
|
package/dist/wrapped.js
CHANGED
|
@@ -13,7 +13,7 @@ const by = (map, key, make) => map.get(key) ?? map.set(key, make()).get(key);
|
|
|
13
13
|
/** `year` under `home`, from parseHome's reads: its options (`state` and `requests` aside). */
|
|
14
14
|
export async function wrappedHome(home, year, options = {}) {
|
|
15
15
|
const prices = options.catalog === false ? undefined : (options.catalog ?? (await builtinCatalog()));
|
|
16
|
-
const out = { year, sessions: 0, turns: 0, requests: 0, tokens: noTokens(), cost: 0, unpricedRequests: 0, days: [], hours: new Array(24).fill(0), weekdays: new Array(7).fill(0), activeMs: 0, harnesses: [], models: [], sources: [] };
|
|
16
|
+
const out = { year, sessions: 0, turns: 0, requests: 0, tokens: noTokens(), cost: 0, unpricedRequests: 0, tokensUnknownRequests: 0, timeUnknownRequests: 0, days: [], hours: new Array(24).fill(0), weekdays: new Array(7).fill(0), activeMs: 0, harnesses: [], models: [], sources: [] };
|
|
17
17
|
const days = new Map();
|
|
18
18
|
const harnesses = new Map();
|
|
19
19
|
const models = new Map();
|
|
@@ -21,7 +21,8 @@ export async function wrappedHome(home, year, options = {}) {
|
|
|
21
21
|
// The usage of each model's requests of the year, priced once the read is over (a rejection of the price then rejects
|
|
22
22
|
// this call, with no promise left floating), and each request that carries none, which no price can cover.
|
|
23
23
|
const usages = new Map();
|
|
24
|
-
const
|
|
24
|
+
const readerOf = (source) => (options.readers ?? READERS)[source];
|
|
25
|
+
const harnessOf = (source) => readerOf(source)?.harness ?? source;
|
|
25
26
|
await parseHome(home, {
|
|
26
27
|
...options,
|
|
27
28
|
requests: (totals, requests, started) => {
|
|
@@ -31,8 +32,9 @@ export async function wrappedHome(home, year, options = {}) {
|
|
|
31
32
|
out.sessions += 1;
|
|
32
33
|
out.turns += totals.turns;
|
|
33
34
|
by(sources, totals.source, () => ({ sessions: 0, requests: 0 })).sessions += 1;
|
|
34
|
-
by(harnesses, harnessOf(totals.source), () => ({ sessions: 0, requests: 0, tokens: 0 })).sessions += 1;
|
|
35
|
+
by(harnesses, harnessOf(totals.source), () => ({ sessions: 0, requests: 0, tokens: 0, tokensUnknownRequests: 0 })).sessions += 1;
|
|
35
36
|
}
|
|
37
|
+
const untimed = readerOf(totals.source)?.untimed === true;
|
|
36
38
|
for (let i = 0; i < mine.length; i++) {
|
|
37
39
|
const r = mine[i];
|
|
38
40
|
const when = new Date(r.at);
|
|
@@ -46,14 +48,16 @@ export async function wrappedHome(home, year, options = {}) {
|
|
|
46
48
|
d.requests += 1;
|
|
47
49
|
d.tokens += held;
|
|
48
50
|
by(sources, totals.source, () => ({ sessions: 0, requests: 0 })).requests += 1;
|
|
49
|
-
const h = by(harnesses, harnessOf(totals.source), () => ({ sessions: 0, requests: 0, tokens: 0 }));
|
|
51
|
+
const h = by(harnesses, harnessOf(totals.source), () => ({ sessions: 0, requests: 0, tokens: 0, tokensUnknownRequests: 0 }));
|
|
50
52
|
h.requests += 1;
|
|
51
53
|
h.tokens += held;
|
|
52
|
-
const m = by(models, r.model ?? "unknown", () => ({ requests: 0, tokens: noTokens(), cost: 0, unpricedRequests: 0 }));
|
|
54
|
+
const m = by(models, r.model ?? "unknown", () => ({ requests: 0, tokens: noTokens(), cost: 0, unpricedRequests: 0, tokensUnknownRequests: 0 }));
|
|
53
55
|
m.requests += 1;
|
|
54
56
|
if (r.usage)
|
|
55
57
|
addTokens(m.tokens, r.usage);
|
|
56
|
-
if (
|
|
58
|
+
if (untimed)
|
|
59
|
+
out.timeUnknownRequests += 1;
|
|
60
|
+
else if (i > 0 && r.at - mine[i - 1].at < ACTIVE_GAP_MS)
|
|
57
61
|
out.activeMs += r.at - mine[i - 1].at;
|
|
58
62
|
// A request with no usage (pi leaves it off an aborted request) is unpriced; known zero usage is free and priced.
|
|
59
63
|
if (r.usage)
|
|
@@ -61,6 +65,9 @@ export async function wrappedHome(home, year, options = {}) {
|
|
|
61
65
|
else {
|
|
62
66
|
out.unpricedRequests += 1;
|
|
63
67
|
m.unpricedRequests += 1;
|
|
68
|
+
out.tokensUnknownRequests += 1;
|
|
69
|
+
h.tokensUnknownRequests += 1;
|
|
70
|
+
m.tokensUnknownRequests += 1;
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-import",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.69",
|
|
4
4
|
"description": "Reads the coding-agent sessions under a home (Claude Code, Codex, pi, OpenCode, GitHub Copilot CLI, Cursor) into one Session shape, with normalized token usage, subagents under their parent, byte-offset cursors for re-reads, and per-session totals.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|