cogpit-memory 0.1.10 → 0.2.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.
@@ -0,0 +1,24 @@
1
+ export interface ParsedAgentEnvelope {
2
+ /** Sender named by the first envelope that names one, or null when none does. */
3
+ sender: string | null;
4
+ /** True when at least one envelope was unwrapped, even if it named no sender. */
5
+ matched: boolean;
6
+ /** Text with every envelope unwrapped. Unchanged when no envelope matched. */
7
+ body: string;
8
+ }
9
+ /**
10
+ * Removes envelope framing that wraps a body — an envelope no reader unwrapped,
11
+ * or the trailing tag the nested case above leaves behind. Only the wrapper
12
+ * goes: a tag quoted inside the body is content, and stays.
13
+ */
14
+ export declare function stripEnvelopeFraming(body: string): string;
15
+ export declare function parseAgentEnvelope(text: string): ParsedAgentEnvelope;
16
+ /**
17
+ * Whether a message reads as asking the reader for something: announced in the
18
+ * opening, or left on the closing line as a `?` or a request.
19
+ *
20
+ * This is the one guessed signal in agent mail, so callers must gate it on the
21
+ * message also being unanswered — a false positive then disappears as soon as
22
+ * the reader replies, and can never go stale on screen.
23
+ */
24
+ export declare function looksLikeQuestion(body: string): boolean;
@@ -0,0 +1,27 @@
1
+ export interface JsStringLiteral {
2
+ endIndex: number;
3
+ value: string;
4
+ }
5
+ export interface CodexExecInvocation {
6
+ name: string;
7
+ argumentSource: string;
8
+ startIndex: number;
9
+ }
10
+ export declare function readJsStringLiteral(source: string, startIndex: number): JsStringLiteral | null;
11
+ /**
12
+ * Extract actual tool invocations from a Codex code-mode `exec` script.
13
+ *
14
+ * This is a lexer, not a JavaScript evaluator: it deliberately ignores strings
15
+ * and comments, balances nested literals, and only recognizes calls rooted at
16
+ * the injected `tools` object. That keeps transcript rendering deterministic
17
+ * and safe even when the persisted script is malformed or user-controlled.
18
+ */
19
+ export declare function extractCodexExecInvocations(source: string): CodexExecInvocation[];
20
+ /** Return the source expression for a top-level property of an object argument. */
21
+ export declare function extractJsPropertySource(source: string, property: string): string | null;
22
+ /** Find simple string-valued object properties at any nesting depth. */
23
+ export declare function extractJsStringPropertyValues(source: string, property: string): string[];
24
+ /** Find simple numeric object properties at any nesting depth. */
25
+ export declare function extractJsNumberPropertyValues(source: string, property: string): number[];
26
+ /** Count top-level entries in an array literal, or one for a non-empty value. */
27
+ export declare function countJsCollectionEntries(source: string): number;
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Normalize a Codex function name to its canonical collaboration-tool name.
3
+ * Current collaboration tools carry a namespace separately, but older and
4
+ * transitional rollouts also encoded it in the function name itself.
5
+ */
6
+ export declare function normalizeFunctionName(rawName: string): string;
1
7
  export declare function inferToolError(output: string | null): boolean;
2
8
  /** Normalize Codex update_plan input to TodoWrite format. */
3
9
  export declare function normalizePlanToTodos(input: Record<string, unknown>): Record<string, unknown>;
@@ -5,6 +5,20 @@ export declare function matchSubagentToMember(leadSessionId: string, subagentFil
5
5
  agentType: string;
6
6
  prompt?: string;
7
7
  }>): Promise<string | null>;
8
+ /**
9
+ * Encode a cwd using Claude Code's project-directory naming convention: every
10
+ * character outside `[A-Za-z0-9]` becomes `-`, so both `/Users/x/proj` and
11
+ * `C:\Users\x\proj` collapse into a flat directory name under
12
+ * `~/.claude/projects`. Mirrors `shared/providers/claude.ts`; this package is
13
+ * published standalone and cannot import outside its own `src` root.
14
+ */
15
+ export declare function encodeClaudeDirName(cwd: string): string;
16
+ /**
17
+ * Best-effort inverse of {@link encodeClaudeDirName}. The encoding is lossy —
18
+ * a literal `-` is indistinguishable from a separator — so callers that can
19
+ * read a session's recorded `cwd` should always prefer that.
20
+ */
21
+ export declare function decodeClaudeDirName(dirName: string): string;
8
22
  export declare function projectDirToReadableName(dirName: string): {
9
23
  path: string;
10
24
  shortName: string;
@@ -24,8 +24,13 @@ export interface UserQuestionState {
24
24
  }
25
25
  export type PendingInteraction = PlanApprovalState | UserQuestionState | null;
26
26
  /**
27
- * Check if the previous turn's last tool call is the same interactive tool
28
- * with a pending/error result -- indicates a stuck loop we should suppress.
27
+ * Check if the previous turn's last tool call is the same interactive tool that
28
+ * *errored* -- indicates a stuck re-call loop we should suppress.
29
+ *
30
+ * An unanswered (result === null) prompt in the previous turn is NOT a loop:
31
+ * it just means the user replied with a message instead of answering, and the
32
+ * agent is now asking again. Treating that as stuck suppressed the current
33
+ * prompt entirely, leaving the turn blocked with no way to answer it.
29
34
  */
30
35
  export declare function isStuckInteractiveLoop(turns: Turn[], toolName: string): boolean;
31
36
  /**
@@ -5,13 +5,22 @@
5
5
  * dependencies. Extracted here as a dependency-free leaf module (imports only
6
6
  * from ./types) so both files can share a single source of truth.
7
7
  */
8
- import type { RawMessage, UserMessage, AssistantMessage, ProgressMessage, SystemMessage, SummaryMessage, QueueOperationMessage } from "./types";
8
+ import type { RawMessage, UserMessage, AssistantMessage, ProgressMessage, SystemMessage, SummaryMessage, QueueOperationMessage, AttachmentMessage } from "./types";
9
9
  export declare function isUserMessage(msg: RawMessage): msg is UserMessage;
10
10
  export declare function isAssistantMessage(msg: RawMessage): msg is AssistantMessage;
11
11
  export declare function isProgressMessage(msg: RawMessage): msg is ProgressMessage;
12
12
  export declare function isSystemMessage(msg: RawMessage): msg is SystemMessage;
13
13
  export declare function isSummaryMessage(msg: RawMessage): msg is SummaryMessage;
14
14
  export declare function isQueueOperationMessage(msg: RawMessage): msg is QueueOperationMessage;
15
+ export declare function isAttachmentMessage(msg: RawMessage): msg is AttachmentMessage;
16
+ /**
17
+ * The synthetic user message Claude Code writes after compacting, carrying the
18
+ * summary text. Flagged `isVisibleInTranscriptOnly` too — it is transcript
19
+ * furniture, never something the user typed.
20
+ */
21
+ export declare function isCompactSummaryMessage(msg: RawMessage): msg is UserMessage & {
22
+ isCompactSummary: true;
23
+ };
15
24
  export declare function isCompactBoundary(msg: RawMessage): msg is SystemMessage & {
16
25
  subtype: "compact_boundary";
17
26
  };
@@ -1,5 +1,9 @@
1
1
  /**
2
2
  * Session statistics computation — token usage aggregation and tool call tallying.
3
+ *
4
+ * Token totals are the raw figures the transcript reports. Costs are not
5
+ * computed here: pricing needs the live LiteLLM rate table, which callers
6
+ * apply via shared/usageCost/pricing.ts.
3
7
  */
4
8
  import type { Turn, SessionStats } from "./types";
5
9
  export declare function createEmptySessionStats(turnCount: number): SessionStats;
@@ -6,7 +6,7 @@
6
6
  * This is a pure function — status is always derived from data,
7
7
  * never stored as app state.
8
8
  */
9
- export type SessionStatus = "idle" | "thinking" | "tool_use" | "processing" | "completed" | "compacting" | "deferred";
9
+ export type SessionStatus = "idle" | "thinking" | "tool_use" | "processing" | "completed" | "compacting" | "deferred" | "awaiting_agents";
10
10
  export interface SessionStatusInfo {
11
11
  status: SessionStatus;
12
12
  /** Name of the tool currently being used (if status is tool_use) */
@@ -15,7 +15,15 @@ export interface SessionStatusInfo {
15
15
  pendingQueue?: number;
16
16
  /** Why the session terminated (from Claude Code's terminal_reason). Only set for non-normal endings. */
17
17
  terminalReason?: string;
18
+ /** Number of background agents/workflows still running (status awaiting_agents) */
19
+ pendingAgents?: number;
20
+ /** Short descriptions of the pending background agents, oldest first */
21
+ pendingAgentDescriptions?: string[];
18
22
  }
23
+ type RawMsg = {
24
+ type: string;
25
+ [key: string]: unknown;
26
+ };
19
27
  /**
20
28
  * Derive session status from raw JSONL message objects.
21
29
  *
@@ -26,11 +34,9 @@ export interface SessionStatusInfo {
26
34
  * format. If a third provider is added, add a detection branch here and in
27
35
  * `src/lib/providers/registry.ts`.
28
36
  */
29
- export declare function deriveSessionStatus(rawMessages: Array<{
30
- type: string;
31
- [key: string]: unknown;
32
- }>): SessionStatusInfo;
37
+ export declare function deriveSessionStatus(rawMessages: RawMsg[]): SessionStatusInfo;
33
38
  /** Human-readable label for terminal_reason values from Claude Code. */
34
39
  export declare function getTerminalReasonLabel(reason: string): string;
35
40
  /** Human-readable label for a session status. Returns null for "idle". */
36
- export declare function getStatusLabel(status: SessionStatus | undefined, toolName?: string, terminalReason?: string): string | null;
41
+ export declare function getStatusLabel(status: SessionStatus | undefined, toolName?: string, terminalReason?: string, pendingAgents?: number): string | null;
42
+ export {};
@@ -1,48 +1,27 @@
1
1
  /**
2
- * Token cost calculation library — single source of truth.
2
+ * Token display estimation and cost formatting.
3
3
  *
4
- * Pricing is reverse-engineered from the Claude Code binary (v2.1.53) to match
5
- * exactly what CC reports. CC calculates cost per API call in the message_delta
6
- * handler using final usage from the streaming response — but the JSONL only
7
- * records the message_start placeholder usage (output_tokens is severely
8
- * undercounted, thinking tokens are omitted entirely). We compensate by
9
- * estimating output from actual content (≈4 chars/token).
4
+ * Pricing lives in shared/usageCost/pricing.ts, driven by LiteLLM's live rate
5
+ * table — nothing here carries hardcoded rates. What remains is display-only
6
+ * accounting of the thinking/visible output split.
7
+ *
8
+ * Claude Code 2.1.19x+ reports thinking tokens directly on the assistant
9
+ * record, so that half of the split is now exact. Older transcripts recorded
10
+ * only the message_start placeholder usage, so they still fall back to a
11
+ * content estimate at ≈4 chars/token — as does the visible-output half, which
12
+ * the CLI does not break out.
10
13
  */
11
- import type { Turn, SubAgentMessage } from "./types";
14
+ import type { Turn } from "./types";
12
15
  /** Approximate characters per token for content-based estimation. */
13
16
  export declare const CHARS_PER_TOKEN = 4;
14
- export interface CostInput {
15
- model: string | null;
16
- inputTokens: number;
17
- outputTokens: number;
18
- cacheWriteTokens: number;
19
- cacheReadTokens: number;
20
- webSearchRequests?: number;
21
- /** Fast-mode flag from usage.speed — "fast" bills a higher tier on Opus 4.6/4.7 */
22
- speed?: string;
23
- }
24
17
  /**
25
- * Calculate the cost of a single API call / turn.
18
+ * Thinking tokens for a turn: the count the model reported when it is
19
+ * available, falling back to a character estimate for older transcripts.
26
20
  *
27
- * This is the single entry point for all cost calculations. All other
28
- * functions in the codebase should use this instead of computing cost
29
- * themselves.
30
- */
31
- export declare function calculateCost(c: CostInput): number;
32
- /**
33
- * Backward-compatible wrapper. Prefer `calculateCost()` for new code.
21
+ * A reported 0 is a fact — a turn that did no thinking — so presence is tested
22
+ * rather than truthiness.
34
23
  */
35
- export declare function calculateTurnCost(model: string | null, inputTokens: number, outputTokens: number, cacheCreationTokens: number, cacheReadTokens: number): number;
36
- /** Estimate thinking tokens from a turn's thinking blocks. */
37
24
  export declare function estimateThinkingTokens(turn: Turn): number;
38
25
  /** Estimate non-thinking output tokens (text + tool use JSON). */
39
26
  export declare function estimateVisibleOutputTokens(turn: Turn): number;
40
- /** Estimate total output tokens (thinking + visible). Uses max(estimated, reported). */
41
- export declare function estimateTotalOutputTokens(turn: Turn): number;
42
- /** Estimate output tokens for a sub-agent message. */
43
- export declare function estimateSubAgentOutput(sa: SubAgentMessage): number;
44
- /** Calculate cost for a turn using estimated output tokens. */
45
- export declare function calculateTurnCostEstimated(turn: Turn): number;
46
- /** Calculate cost for a sub-agent message using estimated output tokens. */
47
- export declare function calculateSubAgentCostEstimated(sa: SubAgentMessage): number;
48
27
  export declare function formatCost(usd: number): string;
@@ -2,4 +2,37 @@
2
2
  * Turn builder — state machine that converts raw JSONL messages into Turn objects.
3
3
  */
4
4
  import type { RawMessage, Turn } from "./types";
5
+ /**
6
+ * Attach each peer message to the `SendMessage` that answered it.
7
+ *
8
+ * Walks blocks in chronological order holding the still-unanswered messages per
9
+ * sender, so a reply claims the oldest outstanding message from that sender and
10
+ * pairing only ever runs forward in time. A `SendMessage` sent *before* any
11
+ * inbound message from that sender is an instruction, not a reply.
12
+ *
13
+ * The join is on the sender name, which is the only key available: the block
14
+ * carries no task id, because `origin.senderTaskId` names the sending agent's
15
+ * task rather than the message. `SendMessage.input.to` uses the same names that
16
+ * arrive in `origin.from`, so the join holds.
17
+ *
18
+ * A pure recompute: every existing pairing is cleared before the walk, so the
19
+ * answer depends only on the list handed in. Callers that assemble a transcript
20
+ * from several `buildTurns` calls — the page stitcher and the incremental
21
+ * append — re-run it over the joined list and get what a single parse of that
22
+ * list would have produced. Turns holding no peer message come back by
23
+ * reference, so a re-run costs nothing for the rest of the transcript.
24
+ */
25
+ export declare function pairAgentMessageReplies(turns: readonly Turn[]): Turn[];
26
+ /**
27
+ * Raw-message index where each turn `buildTurns` would produce begins, so
28
+ * `starts[i]` is the index that produces `turns[i]`.
29
+ *
30
+ * Incremental appends need both a rebuild cut point and the number of turns
31
+ * that precede it. Deriving them separately is how an append drifts out of
32
+ * sync with a full re-parse, so both come from this one pass.
33
+ *
34
+ * Mirrors the turn-creation rule of `buildTurns` below — a parser test asserts
35
+ * the two agree, so keep them in lockstep.
36
+ */
37
+ export declare function findTurnStartIndices(messages: RawMessage[]): number[];
5
38
  export declare function buildTurns(messages: RawMessage[]): Turn[];
@@ -80,6 +80,21 @@ export interface UserMessage extends BaseMessage {
80
80
  content: UserContent;
81
81
  };
82
82
  isMeta?: boolean;
83
+ /**
84
+ * Set on the synthetic user message Claude Code writes after a compaction.
85
+ * Its content is the real compaction summary wrapped in resume boilerplate —
86
+ * `compact_boundary.content` is only ever the fixed string "Conversation
87
+ * compacted", so this message is the sole source of the summary text.
88
+ */
89
+ isCompactSummary?: boolean;
90
+ /**
91
+ * Why Claude Code wrote this record. `"task-notification"` marks a
92
+ * background task reporting back, not a prompt the reader typed. Absent on
93
+ * records written before Claude Code added the field (pre-2.1.220).
94
+ */
95
+ origin?: {
96
+ kind?: string;
97
+ } | null;
83
98
  permissionMode?: string;
84
99
  thinkingMetadata?: {
85
100
  maxThinkingTokens: number;
@@ -94,6 +109,25 @@ export interface TokenUsage {
94
109
  cache_read_input_tokens?: number;
95
110
  /** "fast" when the turn ran in fast mode (billed at a higher tier on Opus 4.6/4.7) */
96
111
  speed?: string;
112
+ /**
113
+ * Claude Code 2.1.19x+ reports the thinking slice of `output_tokens`
114
+ * exactly. Already counted inside output_tokens — never add it to a cost sum.
115
+ */
116
+ output_tokens_details?: {
117
+ thinking_tokens?: number;
118
+ };
119
+ }
120
+ /**
121
+ * What drove a response, when Claude Code could attribute it (CC 2.1.17x+).
122
+ * Written as flat `attribution*` fields on the assistant record.
123
+ */
124
+ export interface MessageAttribution {
125
+ /** Subagent type, e.g. "Explore", "implementer", "workflow-subagent". */
126
+ agent?: string;
127
+ skill?: string;
128
+ plugin?: string;
129
+ mcpServer?: string;
130
+ mcpTool?: string;
97
131
  }
98
132
  export interface AssistantMessage extends BaseMessage {
99
133
  type: "assistant";
@@ -106,6 +140,17 @@ export interface AssistantMessage extends BaseMessage {
106
140
  usage: TokenUsage;
107
141
  };
108
142
  requestId?: string;
143
+ /**
144
+ * Reasoning effort this response ran at (CC 2.1.212+): low | medium | high |
145
+ * xhigh | max. Codex spells its own levels differently (e.g. "trivial"), so
146
+ * this stays a plain string rather than a union.
147
+ */
148
+ effort?: string;
149
+ attributionAgent?: string;
150
+ attributionSkill?: string;
151
+ attributionPlugin?: string;
152
+ attributionMcpServer?: string;
153
+ attributionMcpTool?: string;
109
154
  }
110
155
  /**
111
156
  * @deprecated Claude Code v2.1.63+ no longer emits inline agent_progress messages.
@@ -195,10 +240,12 @@ export interface SystemMessage extends BaseMessage {
195
240
  durationMs?: number;
196
241
  isMeta?: boolean;
197
242
  content?: string;
198
- compactMetadata?: {
199
- trigger: "auto" | "manual";
200
- preTokens: number;
201
- };
243
+ compactMetadata?: CompactionMeta;
244
+ }
245
+ export interface CompactionMeta {
246
+ trigger: "auto" | "manual";
247
+ preTokens: number;
248
+ postTokens?: number;
202
249
  }
203
250
  export interface FileHistorySnapshotMessage extends BaseMessage {
204
251
  type: "file-history-snapshot";
@@ -221,7 +268,57 @@ export interface QueueOperationMessage extends BaseMessage {
221
268
  operation: "enqueue" | "dequeue" | "remove" | string;
222
269
  content?: string | null;
223
270
  }
224
- export type RawMessage = UserMessage | AssistantMessage | ProgressMessage | SystemMessage | FileHistorySnapshotMessage | SummaryMessage | QueueOperationMessage;
271
+ /**
272
+ * Claude Code persists the text of a prompt queued mid-turn here, not on the
273
+ * queue-operation record. `commandMode` separates prompts the user typed
274
+ * ("prompt") from Claude's own injected notices ("task-notification").
275
+ */
276
+ export interface AttachmentMessage extends BaseMessage {
277
+ type: "attachment";
278
+ attachment?: {
279
+ type?: string;
280
+ prompt?: string | ContentBlock[] | null;
281
+ commandMode?: string;
282
+ timestamp?: string;
283
+ /**
284
+ * Who queued this prompt. `"human"` is the reader typing mid-turn;
285
+ * `"peer"` is another agent sending this session a message. `body` is the
286
+ * message with its envelope already stripped, so it beats re-parsing
287
+ * `prompt`. Absent on records written before Claude Code added the field.
288
+ */
289
+ origin?: {
290
+ kind?: string;
291
+ from?: string;
292
+ name?: string;
293
+ senderTaskId?: string;
294
+ body?: string;
295
+ } | null;
296
+ } | null;
297
+ }
298
+ /**
299
+ * Written when a session enters or leaves a `.claude/worktrees/*` checkout.
300
+ * The record is the session's current worktree state, so a later one supersedes
301
+ * an earlier one, and a null `worktreeSession` means the session left.
302
+ */
303
+ export interface WorktreeStateMessage extends BaseMessage {
304
+ type: "worktree-state";
305
+ worktreeSession?: {
306
+ originalCwd?: string;
307
+ preEnterOriginalCwd?: string;
308
+ worktreePath?: string;
309
+ worktreeName?: string;
310
+ worktreeBranch?: string;
311
+ originalBranch?: string;
312
+ originalHeadCommit?: string;
313
+ sessionId?: string;
314
+ } | null;
315
+ }
316
+ /** The agent type a session was launched as, e.g. "general-purpose". */
317
+ export interface AgentSettingMessage extends BaseMessage {
318
+ type: "agent-setting";
319
+ agentSetting?: string;
320
+ }
321
+ export type RawMessage = UserMessage | AssistantMessage | ProgressMessage | SystemMessage | FileHistorySnapshotMessage | SummaryMessage | QueueOperationMessage | AttachmentMessage;
225
322
  export interface ToolCall {
226
323
  id: string;
227
324
  name: string;
@@ -272,6 +369,26 @@ export type TurnContentBlock = {
272
369
  kind: "queued_prompt";
273
370
  content: string;
274
371
  timestamp?: string;
372
+ }
373
+ /**
374
+ * A message another agent sent this session mid-turn. Distinct from
375
+ * `queued_prompt`, which is the reader's own text. `reply` is filled by the
376
+ * pairing pass when a later SendMessage answered this sender.
377
+ *
378
+ * Deliberately carries no sender task id. `origin.senderTaskId` on the record
379
+ * identifies the sending agent's *task*, not the message — one agent's
380
+ * question and its later done-report share an id — so it is useless as a
381
+ * per-message key and destructive as a dedup key.
382
+ */
383
+ | {
384
+ kind: "agent_message";
385
+ sender: string;
386
+ body: string;
387
+ timestamp?: string;
388
+ reply?: {
389
+ summary: string;
390
+ timestamp: string;
391
+ };
275
392
  } | {
276
393
  kind: "sub_agent";
277
394
  messages: SubAgentMessage[];
@@ -302,6 +419,18 @@ export type TurnContentBlock = {
302
419
  kind: "recap";
303
420
  content: string;
304
421
  timestamp?: string;
422
+ }
423
+ /**
424
+ * A background task reporting back, which resumes the turn that launched it
425
+ * rather than opening one of its own. `content` is the raw record text —
426
+ * one or more `<task-notification>` blocks, possibly inside a
427
+ * `<system-reminder>` envelope (Claude Code 2.1.234+) — left unparsed here
428
+ * for the same reason `queued_prompt` is: the renderers own that grammar.
429
+ */
430
+ | {
431
+ kind: "task_notification";
432
+ content: string;
433
+ timestamp?: string;
305
434
  };
306
435
  export interface Turn {
307
436
  id: string;
@@ -316,15 +445,38 @@ export interface Turn {
316
445
  durationMs: number | null;
317
446
  tokenUsage: TokenUsage | null;
318
447
  model: string | null;
319
- /** Set when a compaction happened before this turn */
448
+ /**
449
+ * Summary of the compaction that happened before this turn, as written by
450
+ * the compacting model. Absent when the transcript records the boundary but
451
+ * not the summary (e.g. the session ended right after compacting).
452
+ */
320
453
  compactionSummary?: string;
454
+ /** Trigger and token counts of the compaction that happened before this turn */
455
+ compactionMeta?: CompactionMeta;
456
+ /**
457
+ * Reasoning effort the turn ran at, when the transcript recorded one.
458
+ * A turn spanning several assistant messages reports the last one, since
459
+ * effort can be changed mid-session.
460
+ */
461
+ effort?: string;
462
+ /**
463
+ * What drove this turn — skill, plugin, MCP server, subagent type. Merged
464
+ * across the turn's assistant messages, since a turn can start under a skill
465
+ * and later reach for an MCP tool. Undefined when nothing was attributed.
466
+ */
467
+ attribution?: MessageAttribution;
468
+ /**
469
+ * Set when this turn was opened without its start record — the parse window
470
+ * began mid-turn. Such a turn is the newer half of a byte-boundary cut and
471
+ * must be stitched onto the previous turn once the older page arrives.
472
+ */
473
+ isFragment?: boolean;
321
474
  }
322
475
  export interface SessionStats {
323
476
  totalInputTokens: number;
324
477
  totalOutputTokens: number;
325
478
  totalCacheCreationTokens: number;
326
479
  totalCacheReadTokens: number;
327
- totalCostUSD: number;
328
480
  toolCallCounts: Record<string, number>;
329
481
  errorCount: number;
330
482
  totalDurationMs: number;
package/package.json CHANGED
@@ -1,7 +1,23 @@
1
1
  {
2
2
  "name": "cogpit-memory",
3
- "version": "0.1.10",
3
+ "version": "0.2.1",
4
4
  "description": "CLI tool for Claude Code and Codex session introspection",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/gentritbiba/cogpit.git",
9
+ "directory": "packages/cogpit-memory"
10
+ },
11
+ "homepage": "https://github.com/gentritbiba/cogpit/tree/master/packages/cogpit-memory",
12
+ "bugs": "https://github.com/gentritbiba/cogpit/issues",
13
+ "keywords": [
14
+ "claude-code",
15
+ "codex",
16
+ "session",
17
+ "memory",
18
+ "cli",
19
+ "agent"
20
+ ],
5
21
  "packageManager": "bun@1.3.14",
6
22
  "main": "./dist/index.js",
7
23
  "types": "./dist/index.d.ts",
@@ -13,7 +29,9 @@
13
29
  },
14
30
  "files": [
15
31
  "dist/",
16
- "skill/"
32
+ "skill/",
33
+ "README.md",
34
+ "LICENSE"
17
35
  ],
18
36
  "scripts": {
19
37
  "test": "bun test",
package/skill/SKILL.md CHANGED
@@ -151,7 +151,7 @@ Response shape:
151
151
  ```
152
152
 
153
153
  Key details:
154
- - `contentBlocks` kinds: `thinking`, `text`, `tool_calls`, `sub_agent`, `background_agent`, `queued_prompt`, `hook_event`, `plan_mode`, `recap`
154
+ - `contentBlocks` kinds: `thinking`, `text`, `tool_calls`, `sub_agent`, `background_agent`, `queued_prompt`, `hook_event`, `plan_mode`, `recap`, `agent_message`
155
155
  - Tool call `result` is truncated at 10,000 chars -- check `resultTruncated: true`
156
156
  - Tool call `result` may be `null` if the tool hasn't returned yet
157
157
  - Sub-agent blocks show prompt + result text. For full sub-agent conversation, use Layer 3
@@ -1,30 +0,0 @@
1
- /**
2
- * Pricing tier constants and model-to-tier resolution.
3
- *
4
- * Sources: Claude Code v2.1.172 binary (decompiled JS bundle) for Anthropic
5
- * models, and the official OpenAI model pricing pages for GPT models.
6
- * Each model maps to a tier with five price points.
7
- *
8
- * Changes vs the old v2.1.53 table:
9
- * - Extended-context (>200k input) pricing is gone — flat pricing per model.
10
- * - New frontier tier for Fable 5 / Mythos 5 / Opus 4.8 ($10/$50).
11
- * - Sonnet 4.5/4.6 dropped to the $3/$15 tier (was $5/$25).
12
- * - Fast mode (usage.speed === "fast" on Opus 4.6/4.7) bills $30/$150;
13
- * Opus 4.8 fast bills the same as standard.
14
- */
15
- export interface PricingTier {
16
- input: number;
17
- output: number;
18
- cacheWrite: number;
19
- cacheRead: number;
20
- webSearch: number;
21
- }
22
- export declare function resolveTier(model: string, speed?: string): PricingTier;
23
- /**
24
- * Whether Cogpit has a published USD price for this model.
25
- *
26
- * Keep the historical Claude-family fallback for old rollouts whose model is
27
- * absent or abbreviated, but never price a future/unknown GPT model as if it
28
- * were Claude. That would create a precise-looking but invented dollar value.
29
- */
30
- export declare function hasKnownPricing(model: string | null | undefined): boolean;