negotium 0.2.15 → 0.2.16
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/agent-helpers.js +178 -26
- package/dist/agent-helpers.js.map +8 -8
- package/dist/{chunk-5g5a63vv.js → chunk-5cpdbbeh.js} +56 -6
- package/dist/{chunk-5g5a63vv.js.map → chunk-5cpdbbeh.js.map} +4 -4
- package/dist/hosted-agent.js +118 -9
- package/dist/hosted-agent.js.map +6 -6
- package/dist/main.js +389 -50
- package/dist/main.js.map +15 -15
- package/dist/mcp-factories.js +247 -36
- package/dist/mcp-factories.js.map +9 -9
- package/dist/registry.js +3 -3
- package/dist/registry.js.map +2 -2
- package/dist/rollout.js +1 -1
- package/dist/runtime/src/agents/codex-provider.ts +53 -2
- package/dist/runtime/src/agents/rollout/codex.ts +62 -0
- package/dist/runtime/src/mcp/factories/token-stats.ts +33 -11
- package/dist/runtime/src/mcp/runtime-spec.ts +58 -1
- package/dist/runtime/src/node-host.ts +1 -0
- package/dist/runtime/src/runtime/turn-event-stream.ts +17 -2
- package/dist/runtime/src/storage/token-stats.ts +200 -19
- package/dist/runtime/src/version.ts +1 -1
- package/dist/storage.js +112 -11
- package/dist/storage.js.map +3 -3
- package/dist/types/packages/core/src/agents/codex-provider.d.ts +13 -0
- package/dist/types/packages/core/src/agents/rollout/codex.d.ts +9 -0
- package/dist/types/packages/core/src/mcp/factories/token-stats.d.ts +4 -2
- package/dist/types/packages/core/src/storage/token-stats.d.ts +35 -6
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -38,6 +38,12 @@ export interface CodexContextUsage {
|
|
|
38
38
|
contextTokens: number;
|
|
39
39
|
contextWindow: number;
|
|
40
40
|
}
|
|
41
|
+
export interface CodexTokenTotals {
|
|
42
|
+
inputTokens: number;
|
|
43
|
+
outputTokens: number;
|
|
44
|
+
cachedInputTokens: number;
|
|
45
|
+
cacheWriteInputTokens: number;
|
|
46
|
+
}
|
|
41
47
|
export interface CodexPatchChangePreview {
|
|
42
48
|
path: string;
|
|
43
49
|
before?: string;
|
|
@@ -64,8 +70,11 @@ export declare function readCodexPatchCallIds(threadId: string): string[];
|
|
|
64
70
|
export declare function readLatestCodexPatchPreview(threadId: string, expectedPaths: string[], consumedCallIds?: ReadonlySet<string>, expectedCallId?: string): CodexPatchPreview | undefined;
|
|
65
71
|
/** Read the latest per-request context measurement from a Codex rollout. */
|
|
66
72
|
export declare function extractLatestCodexContextUsage(jsonl: string): CodexContextUsage | undefined;
|
|
73
|
+
/** Latest cumulative token counter persisted in a native Codex rollout. */
|
|
74
|
+
export declare function extractLatestCodexTokenTotals(jsonl: string): CodexTokenTotals | undefined;
|
|
67
75
|
/** Resolve a thread's current rollout and return its latest context measurement. */
|
|
68
76
|
export declare function readLatestCodexContextUsage(threadId: string): CodexContextUsage | undefined;
|
|
77
|
+
export declare function readLatestCodexTokenTotals(threadId: string): CodexTokenTotals | undefined;
|
|
69
78
|
/**
|
|
70
79
|
* Old and metadata-free Codex rollouts resume as native multi-agent v1 even
|
|
71
80
|
* when the feature flag is false. Rewrite their runtime metadata in place so
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { type Bucket } from "../../storage/token-stats";
|
|
2
|
+
import { type Bucket, type CurrentSessionUsage } from "../../storage/token-stats";
|
|
3
3
|
export interface TokenStatsMcpContext {
|
|
4
4
|
userId: string;
|
|
5
5
|
}
|
|
@@ -7,11 +7,13 @@ export interface TokenStatsSnapshot {
|
|
|
7
7
|
total: Bucket;
|
|
8
8
|
byHour: Record<string, Bucket>;
|
|
9
9
|
bySession: Record<string, Bucket>;
|
|
10
|
+
currentSessions?: CurrentSessionUsage[];
|
|
11
|
+
ignoredLegacyRecords?: number;
|
|
10
12
|
estimatedCostUsd: number;
|
|
11
13
|
}
|
|
12
14
|
export interface TokenStatsMcpHost {
|
|
13
15
|
getStats(userId: string, from?: string, to?: string): TokenStatsSnapshot;
|
|
14
|
-
calcCost(bucket: Pick<Bucket, "inputTokens" | "outputTokens" | "cacheCreationInputTokens" | "cacheReadInputTokens">): number;
|
|
16
|
+
calcCost(bucket: Pick<Bucket, "inputTokens" | "outputTokens" | "cacheCreationInputTokens" | "cacheReadInputTokens" | "estimatedCostUsd">): number;
|
|
15
17
|
extraSummaryLines?(userId: string): readonly string[];
|
|
16
18
|
}
|
|
17
19
|
export declare const defaultTokenStatsMcpHost: TokenStatsMcpHost;
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
import type { AgentKind, TokenUsage } from "../types";
|
|
1
2
|
export interface QueryRecord {
|
|
3
|
+
schemaVersion: 2;
|
|
2
4
|
timestamp: string;
|
|
3
5
|
session: string;
|
|
6
|
+
topicId: string;
|
|
7
|
+
providerSessionId?: string;
|
|
8
|
+
agent: AgentKind;
|
|
9
|
+
model: string;
|
|
10
|
+
/** Cache-miss input only. */
|
|
4
11
|
inputTokens: number;
|
|
5
12
|
outputTokens: number;
|
|
6
13
|
cacheCreationInputTokens: number;
|
|
7
14
|
cacheReadInputTokens: number;
|
|
15
|
+
contextTokens?: number;
|
|
16
|
+
contextWindow?: number;
|
|
17
|
+
estimatedCostUsd: number;
|
|
8
18
|
}
|
|
9
19
|
export interface Bucket {
|
|
10
20
|
inputTokens: number;
|
|
@@ -12,19 +22,38 @@ export interface Bucket {
|
|
|
12
22
|
cacheCreationInputTokens: number;
|
|
13
23
|
cacheReadInputTokens: number;
|
|
14
24
|
queries: number;
|
|
25
|
+
estimatedCostUsd: number;
|
|
26
|
+
}
|
|
27
|
+
export interface CurrentSessionUsage {
|
|
28
|
+
timestamp: string;
|
|
29
|
+
topicId: string;
|
|
30
|
+
topicTitle: string;
|
|
31
|
+
providerSessionId?: string;
|
|
32
|
+
agent: AgentKind;
|
|
33
|
+
model: string;
|
|
34
|
+
contextTokens: number;
|
|
35
|
+
contextWindow: number;
|
|
36
|
+
}
|
|
37
|
+
export interface TopicUsageSummary extends Bucket {
|
|
38
|
+
topicId: string;
|
|
39
|
+
currentSession?: CurrentSessionUsage;
|
|
15
40
|
}
|
|
16
41
|
export declare function tokenStatsFileId(userId: number | string): string;
|
|
17
|
-
export declare function calcCost(b: Pick<Bucket, "inputTokens" | "outputTokens" | "cacheCreationInputTokens" | "cacheReadInputTokens">): number;
|
|
42
|
+
export declare function calcCost(b: Pick<Bucket, "inputTokens" | "outputTokens" | "cacheCreationInputTokens" | "cacheReadInputTokens" | "estimatedCostUsd">): number;
|
|
18
43
|
/** 쿼리 완료 시 호출 — JSONL에 한 줄 추가 */
|
|
19
|
-
export declare function recordUsage(userId: number | string, session: string, usage: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
44
|
+
export declare function recordUsage(userId: number | string, session: string, usage: TokenUsage, context: {
|
|
45
|
+
topicId: string;
|
|
46
|
+
providerSessionId?: string;
|
|
47
|
+
agent: AgentKind;
|
|
48
|
+
model: string;
|
|
24
49
|
}): void;
|
|
25
50
|
export declare function getStats(userId: number | string, from?: string, to?: string): {
|
|
26
51
|
total: Bucket;
|
|
27
52
|
byHour: Record<string, Bucket>;
|
|
28
53
|
bySession: Record<string, Bucket>;
|
|
54
|
+
currentSessions: CurrentSessionUsage[];
|
|
55
|
+
ignoredLegacyRecords: number;
|
|
29
56
|
estimatedCostUsd: number;
|
|
30
57
|
};
|
|
58
|
+
/** Exact all-time usage for one topic, independent of transcript pagination. */
|
|
59
|
+
export declare function getTopicStats(userId: number | string, topicId: string): TopicUsageSummary;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const NEGOTIUM_VERSION = "0.2.
|
|
1
|
+
export declare const NEGOTIUM_VERSION = "0.2.16";
|