@shadevkumar/agent-wrapped 0.0.0-stage → 0.1.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/LICENSE +25 -0
- package/README.md +71 -2
- package/dist/build.js +47 -0
- package/dist/cli.js +48 -0
- package/dist/files.js +114 -0
- package/dist/letter.js +60 -0
- package/dist/moments.js +283 -0
- package/dist/personality.js +65 -0
- package/dist/pricing.js +97 -0
- package/dist/sources/claude.js +103 -0
- package/dist/sources/codex.js +147 -0
- package/dist/story/fonts/OFL-Geist.txt +93 -0
- package/dist/story/fonts/OFL-Newsreader.txt +93 -0
- package/dist/story/fonts/geist-normal.woff2 +0 -0
- package/dist/story/fonts/newsreader-italic.woff2 +0 -0
- package/dist/story/fonts/newsreader-normal.woff2 +0 -0
- package/dist/story/index.html +234 -0
- package/dist/story/story.js +1155 -0
- package/dist/story.js +35 -0
- package/dist/types.js +22 -0
- package/dist/words.js +234 -0
- package/package.json +46 -4
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const n = (x) => Math.round(x).toLocaleString("en-US");
|
|
2
|
+
const pct = (x) => `${Math.round(x * 100)}%`;
|
|
3
|
+
const perPrompt = (w, count) => (w.totals.prompts ? count / w.totals.prompts : 0);
|
|
4
|
+
const TRAITS = [
|
|
5
|
+
{
|
|
6
|
+
id: "midnight-foreman",
|
|
7
|
+
name: "The Midnight Foreman",
|
|
8
|
+
score: (w) => w.rhythm.lateNight.share / 0.08,
|
|
9
|
+
line: (w) => `You gave ${n(w.rhythm.lateNight.prompts)} orders after midnight, and your agents kept working while the city slept.`,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
id: "one-word-director",
|
|
13
|
+
name: "The One-Word Director",
|
|
14
|
+
score: (w) => w.voice.shortShare / 0.25,
|
|
15
|
+
line: (w) => `${pct(w.voice.shortShare)} of your prompts were three words or fewer. Your agents learned to read minds.`,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "copy-paste-architect",
|
|
19
|
+
name: "The Copy-Paste Architect",
|
|
20
|
+
score: (w) => w.voice.pastedShare / 0.15,
|
|
21
|
+
line: (w) => `${pct(w.voice.pastedShare)} of your prompts reused text you had pasted before. You don't repeat yourself. You reuse yourself.`,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "fast-fingers",
|
|
25
|
+
name: "Fast Fingers",
|
|
26
|
+
score: (w) => (perPrompt(w, w.voice.typoCount) * 100) / 15,
|
|
27
|
+
line: (w) => `${n(w.voice.typoCount)} typos and your agents understood every one. Speed over spelling.`,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "polite-commander",
|
|
31
|
+
name: "The Polite Commander",
|
|
32
|
+
score: (w) => perPrompt(w, (w.voice.lexicon.please ?? 0) + (w.voice.lexicon.thanks ?? 0)) / 0.15,
|
|
33
|
+
line: (w) => `You said please ${n(w.voice.lexicon.please ?? 0)} times. When the machines rise, they will remember you kindly.`,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "interrogator",
|
|
37
|
+
name: "The Interrogator",
|
|
38
|
+
score: (w) => perPrompt(w, (w.voice.lexicon.why ?? 0) + (w.voice.lexicon.again ?? 0)) / 0.15,
|
|
39
|
+
line: (w) => `You asked why ${n(w.voice.lexicon.why ?? 0)} times. No answer went unchecked.`,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "marathoner",
|
|
43
|
+
name: "The Marathoner",
|
|
44
|
+
score: (w) => (w.rhythm.longestStreak?.days ?? 0) / 21,
|
|
45
|
+
line: (w) => `${w.rhythm.longestStreak?.days ?? 0} days in a row without a single day off from your agents.`,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "two-timer",
|
|
49
|
+
name: "The Two-Timer",
|
|
50
|
+
score: (w) => Math.min(w.loyalty.claudeShare, w.loyalty.codexShare) / 0.35,
|
|
51
|
+
line: (w) => `Claude and Codex both on ${n(w.loyalty.bothAgentDays)} days. Neither of them knows about the other.`,
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
export function pickPersonality(w) {
|
|
55
|
+
const ranked = TRAITS.map((t) => ({ t, s: t.score(w) }))
|
|
56
|
+
.filter((x) => Number.isFinite(x.s))
|
|
57
|
+
.sort((a, b) => b.s - a.s);
|
|
58
|
+
const top = ranked[0].t;
|
|
59
|
+
return {
|
|
60
|
+
id: top.id,
|
|
61
|
+
name: top.name,
|
|
62
|
+
line: top.line(w),
|
|
63
|
+
traits: ranked.slice(1, 3).filter((x) => x.s >= 1).map((x) => x.t.name),
|
|
64
|
+
};
|
|
65
|
+
}
|
package/dist/pricing.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { usageTokens } from "./types.js";
|
|
2
|
+
// What the same work would cost on the public API, in USD per million tokens.
|
|
3
|
+
// Standard tier, short context. Prices from the official pages, read 2026-10-28:
|
|
4
|
+
// https://platform.claude.com/docs/en/about-claude/pricing
|
|
5
|
+
// https://developers.openai.com/api/docs/pricing
|
|
6
|
+
// Long-context surcharges are not applied, so every figure here is a floor.
|
|
7
|
+
export const PRICES_AS_OF = "2026-10-28";
|
|
8
|
+
const claude = (input, w5m, w1h, read, output) => ({
|
|
9
|
+
input,
|
|
10
|
+
cacheRead: read,
|
|
11
|
+
cacheWrite: w5m,
|
|
12
|
+
cacheWrite1h: w1h,
|
|
13
|
+
output,
|
|
14
|
+
});
|
|
15
|
+
// OpenAI doesn't charge extra to write the cache.
|
|
16
|
+
const openai = (input, cached, output) => ({
|
|
17
|
+
input,
|
|
18
|
+
cacheRead: cached,
|
|
19
|
+
cacheWrite: input,
|
|
20
|
+
cacheWrite1h: input,
|
|
21
|
+
output,
|
|
22
|
+
});
|
|
23
|
+
// Matched by prefix, so dated ids like claude-opus-4-5-20251101 find their row.
|
|
24
|
+
const PRICES = [
|
|
25
|
+
["claude-fable-5-1", claude(10, 12.5, 20, 0.25, 50)],
|
|
26
|
+
["claude-fable-5", claude(10, 12.5, 20, 1, 50)],
|
|
27
|
+
["claude-opus-5-5", claude(4, 5, 8, 0.2, 20)],
|
|
28
|
+
["claude-opus-5", claude(5, 6.25, 10, 0.5, 25)],
|
|
29
|
+
["claude-opus-4-8", claude(5, 6.25, 10, 0.5, 25)],
|
|
30
|
+
["claude-opus-4-7", claude(5, 6.25, 10, 0.5, 25)],
|
|
31
|
+
["claude-opus-4-6", claude(5, 6.25, 10, 0.5, 25)],
|
|
32
|
+
["claude-opus-4-5", claude(5, 6.25, 10, 0.5, 25)],
|
|
33
|
+
["claude-sonnet-5-5", claude(2, 2.5, 4, 0.1, 10)],
|
|
34
|
+
["claude-sonnet-5", claude(2, 2.5, 4, 0.2, 10)],
|
|
35
|
+
["claude-sonnet-4-6", claude(3, 3.75, 6, 0.3, 15)],
|
|
36
|
+
["claude-sonnet-4-5", claude(3, 3.75, 6, 0.3, 15)],
|
|
37
|
+
["claude-haiku-5-5", claude(0.1, 0.125, 0.2, 0.01, 0.5)],
|
|
38
|
+
["claude-haiku-4-5", claude(1, 1.25, 2, 0.1, 5)],
|
|
39
|
+
["gpt-6-astra", openai(10, 1, 50)],
|
|
40
|
+
["gpt-6.1-sol", openai(2, 0.1, 10)],
|
|
41
|
+
["gpt-6.1-terra", openai(1, 0.05, 5)],
|
|
42
|
+
["gpt-6-sol", openai(2, 0.2, 10)],
|
|
43
|
+
["gpt-6-luna", openai(0.1, 0.01, 0.5)],
|
|
44
|
+
["gpt-5.6-sol", openai(4, 0.4, 20)], // promotional price, at least until 2026-11-21
|
|
45
|
+
["gpt-5.6-terra", openai(2, 0.2, 12)],
|
|
46
|
+
["gpt-5.6-luna", openai(0.2, 0.02, 1.2)],
|
|
47
|
+
["gpt-5.5", openai(5, 0.5, 30)],
|
|
48
|
+
["gpt-5.4", openai(2.5, 0.25, 15)],
|
|
49
|
+
];
|
|
50
|
+
export function priceFor(model) {
|
|
51
|
+
// Longest prefix first, so "claude-opus-5-5" wins over "claude-opus-5".
|
|
52
|
+
const hit = [...PRICES]
|
|
53
|
+
.sort((a, b) => b[0].length - a[0].length)
|
|
54
|
+
.find(([prefix]) => model === prefix || model.startsWith(prefix + "-"));
|
|
55
|
+
return hit ? hit[1] : null;
|
|
56
|
+
}
|
|
57
|
+
export function apiCost(usage, totals) {
|
|
58
|
+
const c = {
|
|
59
|
+
exactUsd: 0,
|
|
60
|
+
exactTokens: 0,
|
|
61
|
+
floorUsd: 0,
|
|
62
|
+
floorTokens: 0,
|
|
63
|
+
unpricedTokens: 0,
|
|
64
|
+
unpricedModels: [],
|
|
65
|
+
atLeastUsd: 0,
|
|
66
|
+
};
|
|
67
|
+
const unpriced = new Set();
|
|
68
|
+
for (const u of usage) {
|
|
69
|
+
const p = priceFor(u.model);
|
|
70
|
+
if (!p) {
|
|
71
|
+
c.unpricedTokens += usageTokens(u);
|
|
72
|
+
unpriced.add(u.model);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
c.exactTokens += usageTokens(u);
|
|
76
|
+
c.exactUsd +=
|
|
77
|
+
(u.input * p.input +
|
|
78
|
+
u.cacheRead * p.cacheRead +
|
|
79
|
+
u.cacheWrite * p.cacheWrite +
|
|
80
|
+
u.cacheWrite1h * p.cacheWrite1h +
|
|
81
|
+
u.output * p.output) /
|
|
82
|
+
1e6;
|
|
83
|
+
}
|
|
84
|
+
for (const t of totals) {
|
|
85
|
+
const p = priceFor(t.model);
|
|
86
|
+
if (!p) {
|
|
87
|
+
c.unpricedTokens += t.tokens;
|
|
88
|
+
unpriced.add(t.model);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
c.floorTokens += t.tokens;
|
|
92
|
+
c.floorUsd += (t.tokens * p.cacheRead) / 1e6;
|
|
93
|
+
}
|
|
94
|
+
c.unpricedModels = [...unpriced].sort();
|
|
95
|
+
c.atLeastUsd = c.exactUsd + c.floorUsd;
|
|
96
|
+
return c;
|
|
97
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { coverage, findFiles, localDay, namesFromPath, readJson, readJsonl, toDate } from "../files.js";
|
|
3
|
+
import { emptyHarvest } from "../types.js";
|
|
4
|
+
// Claude Code keeps three things in ~/.claude:
|
|
5
|
+
// - history.jsonl: every prompt typed, kept long term
|
|
6
|
+
// - stats-cache.json: older token totals per model, up to `lastComputedDate`
|
|
7
|
+
// - projects/**/*.jsonl: full transcripts, cleaned up after about 30 days
|
|
8
|
+
export function harvestClaude(home) {
|
|
9
|
+
const root = join(home, ".claude");
|
|
10
|
+
const h = emptyHarvest();
|
|
11
|
+
for (const row of readJsonl(join(root, "history.jsonl"))) {
|
|
12
|
+
if (typeof row.project === "string")
|
|
13
|
+
addNames(h, namesFromPath(row.project));
|
|
14
|
+
const at = toDate(row.timestamp);
|
|
15
|
+
const text = cleanClaudePrompt(String(row.display ?? ""));
|
|
16
|
+
if (!at || !text)
|
|
17
|
+
continue;
|
|
18
|
+
h.prompts.push({ agent: "claude", text, at, session: String(row.sessionId ?? "") });
|
|
19
|
+
}
|
|
20
|
+
h.coverage.push(coverage("claude", "prompts", h.prompts.map((p) => p.at)));
|
|
21
|
+
// Transcript replies on or before this day are already inside the stats totals.
|
|
22
|
+
const stats = readJson(join(root, "stats-cache.json"));
|
|
23
|
+
const statsDay = typeof stats?.lastComputedDate === "string" ? stats.lastComputedDate : null;
|
|
24
|
+
const statsAt = statsDay ? toDate(`${statsDay}T12:00:00`) : null;
|
|
25
|
+
if (stats && statsAt) {
|
|
26
|
+
for (const [model, u] of Object.entries(stats.modelUsage ?? {})) {
|
|
27
|
+
h.usage.push({
|
|
28
|
+
agent: "claude",
|
|
29
|
+
model,
|
|
30
|
+
at: statsAt,
|
|
31
|
+
input: num(u.inputTokens),
|
|
32
|
+
cacheRead: num(u.cacheReadInputTokens),
|
|
33
|
+
cacheWrite: num(u.cacheCreationInputTokens),
|
|
34
|
+
cacheWrite1h: 0,
|
|
35
|
+
output: num(u.outputTokens),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const days = (stats.dailyActivity ?? []).map((d) => toDate(`${d?.date}T12:00:00`)).filter(Boolean);
|
|
39
|
+
h.coverage.push(coverage("claude", "older token totals", days));
|
|
40
|
+
}
|
|
41
|
+
// Claude Code writes one line per content block, each repeating the reply's
|
|
42
|
+
// usage, and copies history into resumed sessions. Count each reply once.
|
|
43
|
+
const replies = new Map();
|
|
44
|
+
const turnIds = new Set();
|
|
45
|
+
// Only replies and turn timings matter here; tool output and attachments,
|
|
46
|
+
// most of each file, are skipped without being decoded.
|
|
47
|
+
const relevant = (line) => line.includes('"type":"assistant"') || line.includes('"turn_duration"');
|
|
48
|
+
for (const file of findFiles(join(root, "projects"), ".jsonl")) {
|
|
49
|
+
for (const row of readJsonl(file, relevant)) {
|
|
50
|
+
if (typeof row.cwd === "string")
|
|
51
|
+
addNames(h, namesFromPath(row.cwd));
|
|
52
|
+
const at = toDate(row.timestamp);
|
|
53
|
+
if (!at || (statsDay && localDay(at) <= statsDay))
|
|
54
|
+
continue;
|
|
55
|
+
if (row.type === "system" && row.subtype === "turn_duration" && num(row.durationMs) > 0) {
|
|
56
|
+
const id = String(row.uuid ?? `${row.sessionId}|${row.timestamp}`);
|
|
57
|
+
if (!turnIds.has(id)) {
|
|
58
|
+
turnIds.add(id);
|
|
59
|
+
h.turns.push({ agent: "claude", at, durationMs: num(row.durationMs) });
|
|
60
|
+
}
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const m = row.type === "assistant" ? row.message : null;
|
|
64
|
+
if (!m?.usage || typeof m.model !== "string" || m.model === "<synthetic>")
|
|
65
|
+
continue;
|
|
66
|
+
const writes = num(m.usage.cache_creation_input_tokens);
|
|
67
|
+
const writes1h = Math.min(writes, num(m.usage.cache_creation?.ephemeral_1h_input_tokens));
|
|
68
|
+
const usage = {
|
|
69
|
+
agent: "claude",
|
|
70
|
+
model: m.model,
|
|
71
|
+
at,
|
|
72
|
+
input: num(m.usage.input_tokens),
|
|
73
|
+
cacheRead: num(m.usage.cache_read_input_tokens),
|
|
74
|
+
cacheWrite: writes - writes1h,
|
|
75
|
+
cacheWrite1h: writes1h,
|
|
76
|
+
output: num(m.usage.output_tokens),
|
|
77
|
+
};
|
|
78
|
+
const key = `${m.id ?? row.uuid}|${row.requestId ?? ""}`;
|
|
79
|
+
const seen = replies.get(key);
|
|
80
|
+
if (!seen || usage.output >= seen.output)
|
|
81
|
+
replies.set(key, usage);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
h.usage.push(...replies.values());
|
|
85
|
+
h.coverage.push(coverage("claude", "replies", [...replies.values()].map((u) => u.at)));
|
|
86
|
+
return h;
|
|
87
|
+
}
|
|
88
|
+
// Drops slash and shell commands and paste placeholders; keeps what was typed.
|
|
89
|
+
export function cleanClaudePrompt(raw) {
|
|
90
|
+
const text = raw
|
|
91
|
+
.replace(/\[(Pasted text|Image) #\d+[^\]]*\]/g, "")
|
|
92
|
+
.trim();
|
|
93
|
+
if (!text || text.startsWith("/") || text.startsWith("!"))
|
|
94
|
+
return null;
|
|
95
|
+
return text;
|
|
96
|
+
}
|
|
97
|
+
function addNames(h, names) {
|
|
98
|
+
for (const n of names)
|
|
99
|
+
h.privateNames.add(n);
|
|
100
|
+
}
|
|
101
|
+
function num(v) {
|
|
102
|
+
return typeof v === "number" && Number.isFinite(v) ? v : 0;
|
|
103
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { DatabaseSync } from "node:sqlite";
|
|
4
|
+
import { coverage, lastJsonLine, namesFromGitUrl, namesFromPath, toDate } from "../files.js";
|
|
5
|
+
import { emptyHarvest } from "../types.js";
|
|
6
|
+
// Codex keeps, in ~/.codex:
|
|
7
|
+
// - state_N.sqlite `threads`: one row per thread, with its token total
|
|
8
|
+
// - thread_history_N.sqlite: every message and turn, kept long term
|
|
9
|
+
// - sessions/**/rollout-*.jsonl: token splits, only for recent threads
|
|
10
|
+
// These are Codex's internal files, so a query that no longer fits the
|
|
11
|
+
// schema is recorded as missing coverage instead of stopping the run.
|
|
12
|
+
export function harvestCodex(home) {
|
|
13
|
+
const root = join(home, ".codex");
|
|
14
|
+
const h = emptyHarvest();
|
|
15
|
+
const human = new Map(); // thread id -> started by a person
|
|
16
|
+
const state = openLatest(root, "state");
|
|
17
|
+
if (state) {
|
|
18
|
+
try {
|
|
19
|
+
const rows = state
|
|
20
|
+
.prepare("select id, rollout_path, created_at, cwd, tokens_used, model, git_origin_url, source from threads")
|
|
21
|
+
.all();
|
|
22
|
+
const threadDates = [];
|
|
23
|
+
for (const t of rows) {
|
|
24
|
+
human.set(t.id, !String(t.source ?? "").startsWith("{"));
|
|
25
|
+
if (t.cwd)
|
|
26
|
+
for (const n of namesFromPath(t.cwd))
|
|
27
|
+
h.privateNames.add(n);
|
|
28
|
+
if (t.git_origin_url)
|
|
29
|
+
for (const n of namesFromGitUrl(t.git_origin_url))
|
|
30
|
+
h.privateNames.add(n);
|
|
31
|
+
const at = toDate(Number(t.created_at) * 1000);
|
|
32
|
+
if (!at)
|
|
33
|
+
continue;
|
|
34
|
+
threadDates.push(at);
|
|
35
|
+
const model = String(t.model || "unknown");
|
|
36
|
+
const split = t.rollout_path && existsSync(t.rollout_path) ? rolloutUsage(t.rollout_path) : null;
|
|
37
|
+
if (split) {
|
|
38
|
+
h.usage.push({ agent: "codex", model, at, ...split });
|
|
39
|
+
}
|
|
40
|
+
else if (Number(t.tokens_used) > 0) {
|
|
41
|
+
h.totals.push({ agent: "codex", model, at, tokens: Number(t.tokens_used) });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
h.coverage.push(coverage("codex", "threads", threadDates));
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
h.coverage.push(coverage("codex", "threads", []));
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
state.close();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const history = openLatest(root, "thread_history");
|
|
54
|
+
if (history) {
|
|
55
|
+
try {
|
|
56
|
+
const items = history
|
|
57
|
+
.prepare("select thread_id, created_at_ms, item_json from thread_items where item_type = 'userMessage'")
|
|
58
|
+
.all();
|
|
59
|
+
for (const item of items) {
|
|
60
|
+
if (human.get(item.thread_id) === false)
|
|
61
|
+
continue; // written by a parent agent
|
|
62
|
+
const at = toDate(Number(item.created_at_ms));
|
|
63
|
+
const text = cleanCodexPrompt(messageText(item.item_json));
|
|
64
|
+
if (at && text)
|
|
65
|
+
h.prompts.push({ agent: "codex", text, at, session: item.thread_id });
|
|
66
|
+
}
|
|
67
|
+
h.coverage.push(coverage("codex", "prompts", h.prompts.map((p) => p.at)));
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
h.coverage.push(coverage("codex", "prompts", []));
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const turns = history
|
|
74
|
+
.prepare("select started_at, duration_ms from thread_turns where duration_ms > 0")
|
|
75
|
+
.all();
|
|
76
|
+
for (const t of turns) {
|
|
77
|
+
const at = toDate(Number(t.started_at) * 1000);
|
|
78
|
+
if (at)
|
|
79
|
+
h.turns.push({ agent: "codex", at, durationMs: Number(t.duration_ms) });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// Without turn timings the story skips agent hours; prompts still count.
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
history.close();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return h;
|
|
90
|
+
}
|
|
91
|
+
// The Codex app wraps a typed request with IDE context and tagged blocks.
|
|
92
|
+
// Returns only what the person typed, or null for text Codex wrote itself.
|
|
93
|
+
export function cleanCodexPrompt(raw) {
|
|
94
|
+
if (raw.includes('source="ambient-'))
|
|
95
|
+
return null;
|
|
96
|
+
const markers = [...raw.matchAll(/^## My request(?: for Codex)?:[ \t]*/gm)];
|
|
97
|
+
const last = markers.at(-1);
|
|
98
|
+
if (!last && raw.trimStart().startsWith("# "))
|
|
99
|
+
return null;
|
|
100
|
+
const typed = last ? raw.slice(last.index + last[0].length) : raw;
|
|
101
|
+
const text = typed.replace(/<([A-Za-z_][\w-]*)\b[^>]*>[\s\S]*?<\/\1>/g, "").trim();
|
|
102
|
+
return text || null;
|
|
103
|
+
}
|
|
104
|
+
function messageText(json) {
|
|
105
|
+
try {
|
|
106
|
+
const content = JSON.parse(json)?.content;
|
|
107
|
+
if (!Array.isArray(content))
|
|
108
|
+
return "";
|
|
109
|
+
return content.map((c) => (typeof c?.text === "string" ? c.text : "")).join("\n");
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return "";
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// The thread's final running total. `input_tokens` includes cached tokens.
|
|
116
|
+
function rolloutUsage(path) {
|
|
117
|
+
const row = lastJsonLine(path, '"token_count"', (r) => r.type === "event_msg" && r.payload?.type === "token_count" && !!r.payload.info?.total_token_usage);
|
|
118
|
+
const total = row?.payload.info.total_token_usage;
|
|
119
|
+
if (!total)
|
|
120
|
+
return null;
|
|
121
|
+
const cached = total.cached_input_tokens ?? 0;
|
|
122
|
+
return {
|
|
123
|
+
input: (total.input_tokens ?? 0) - cached,
|
|
124
|
+
cacheRead: cached,
|
|
125
|
+
cacheWrite: total.cache_write_input_tokens ?? 0,
|
|
126
|
+
cacheWrite1h: 0,
|
|
127
|
+
output: total.output_tokens ?? 0,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
// Codex numbers its database files (state_5.sqlite); open the newest, read-only.
|
|
131
|
+
function openLatest(root, prefix) {
|
|
132
|
+
if (!existsSync(root))
|
|
133
|
+
return null;
|
|
134
|
+
const pattern = new RegExp(`^${prefix}_(\\d+)\\.sqlite$`);
|
|
135
|
+
const newest = readdirSync(root)
|
|
136
|
+
.map((f) => ({ f, n: Number(f.match(pattern)?.[1] ?? -1) }))
|
|
137
|
+
.filter((x) => x.n >= 0)
|
|
138
|
+
.sort((a, b) => b.n - a.n)[0];
|
|
139
|
+
if (!newest)
|
|
140
|
+
return null;
|
|
141
|
+
try {
|
|
142
|
+
return new DatabaseSync(join(root, newest.f), { readOnly: true });
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font) Geist-Italic[wght].ttf: Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2020 The Newsreader Project Authors (http://github.com/productiontype/Newsreader)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|