axmap-cli 1.5.0 → 1.7.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/.claude/commands/pipeline.md +9 -0
- package/README.ko.md +37 -0
- package/README.md +37 -0
- package/bin/axmap.mjs +6 -0
- package/mcp/README.md +9 -0
- package/mcp/pipeline.html +184 -0
- package/mcp/server.mjs +161 -20
- package/package.json +12 -3
- package/skills/pipeline/SKILL.md +14 -0
- package/src/agentcli.mjs +17 -14
- package/src/agentcli.mts +19 -0
- package/src/bridge.mjs +297 -219
- package/src/bridge.mts +282 -0
- package/src/codex-connection.mjs +151 -0
- package/src/codex-connection.mts +83 -0
- package/src/external-console.mjs +140 -97
- package/src/external-console.mts +128 -0
- package/src/managed-session.mjs +325 -169
- package/src/managed-session.mts +242 -0
- package/src/monitor-cli.mjs +89 -0
- package/src/monitor-cli.mts +66 -0
- package/src/monitor.mjs +245 -0
- package/src/monitor.mts +199 -0
- package/src/node-pty.d.ts +13 -0
- package/src/pipeline-graph.mjs +55 -0
- package/src/pipeline-graph.mts +51 -0
- package/src/pipeline-mcp.mjs +111 -0
- package/src/pipeline-mcp.mts +105 -0
- package/src/pipeline-statusline.mjs +135 -0
- package/src/pipeline-statusline.mts +106 -0
- package/src/pipeline-web.mjs +56 -0
- package/src/pipeline-web.mts +31 -0
- package/src/session-dialogue.mjs +168 -116
- package/src/session-dialogue.mts +136 -0
- package/src/session-mailbox.mjs +190 -0
- package/src/session-mailbox.mts +157 -0
- package/src/session-status.mjs +47 -41
- package/src/session-status.mts +50 -0
- package/src/session-types.mjs +7 -0
- package/src/session-types.mts +119 -0
- package/src/session-usage.mjs +33 -28
- package/src/session-usage.mts +39 -0
- package/src/terminal-bridge.mjs +293 -209
- package/src/terminal-bridge.mts +235 -0
- package/src/windows-console.mjs +42 -0
- package/src/windows-console.mts +29 -0
- package/tools/bench-console.mjs +70 -0
- package/tools/bridge.mjs +41 -6
- package/tools/build.mjs +39 -0
- package/tools/monitor.mjs +5 -0
- package/tools/pipeline.mjs +34 -0
- package/tools/run-tests.mjs +3 -2
- package/tools/windows-console.cs +116 -0
package/src/session-usage.mjs
CHANGED
|
@@ -1,34 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const count = value => Number.isSafeInteger(value) && value >= 0
|
|
5
|
-
const fields = ['inputTokens', 'cachedInputTokens', 'outputTokens', 'reasoningTokens', 'totalTokens', 'providerTotalTokens']
|
|
6
|
-
|
|
1
|
+
// Generated from src/session-usage.mts. Edit the .mts source and run npm run build.
|
|
2
|
+
const count = (value) => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
|
|
3
|
+
const fields = ['inputTokens', 'cachedInputTokens', 'outputTokens', 'reasoningTokens', 'totalTokens', 'providerTotalTokens'];
|
|
7
4
|
export function normalizeUsage(provider, raw) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
if (!raw || typeof raw !== 'object')
|
|
6
|
+
return null;
|
|
7
|
+
const counters = raw;
|
|
8
|
+
const candidate = provider === 'codex' ? {
|
|
9
|
+
inputTokens: counters.inputTokens, cachedInputTokens: counters.cachedInputTokens,
|
|
10
|
+
outputTokens: counters.outputTokens, reasoningTokens: counters.reasoningOutputTokens,
|
|
11
|
+
totalTokens: counters.totalTokens, providerTotalTokens: counters.totalTokens,
|
|
12
|
+
} : {
|
|
13
|
+
inputTokens: counters.input_tokens, cachedInputTokens: counters.cache_read_tokens,
|
|
14
|
+
outputTokens: counters.output_tokens, reasoningTokens: counters.thinking_tokens,
|
|
15
|
+
totalTokens: count(counters.total_tokens) && count(counters.cache_read_tokens) ? counters.total_tokens + counters.cache_read_tokens : null,
|
|
16
|
+
providerTotalTokens: counters.total_tokens,
|
|
17
|
+
};
|
|
18
|
+
if (fields.some(key => !count(candidate[key])))
|
|
19
|
+
return null;
|
|
20
|
+
// All six fields have been checked above, including provider-specific counters.
|
|
21
|
+
const u = candidate;
|
|
22
|
+
if (provider === 'agy')
|
|
23
|
+
u.inputTokens += u.cachedInputTokens;
|
|
24
|
+
if (u.cachedInputTokens > u.inputTokens || u.reasoningTokens > u.outputTokens)
|
|
25
|
+
return null;
|
|
26
|
+
return u;
|
|
23
27
|
}
|
|
24
|
-
|
|
25
28
|
export function usageDelta(current, previous = null) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
if (!current)
|
|
30
|
+
return null;
|
|
31
|
+
const delta = Object.fromEntries(fields.map(k => [k, current[k] - (previous?.[k] || 0)]));
|
|
32
|
+
return fields.every(k => count(delta[k])) ? delta : null;
|
|
29
33
|
}
|
|
30
|
-
|
|
31
34
|
export function sumUsage(rows) {
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
const known = rows.filter((row) => Boolean(row));
|
|
36
|
+
if (known.length !== rows.length)
|
|
37
|
+
return null;
|
|
38
|
+
return Object.fromEntries(fields.map(k => [k, known.reduce((sum, row) => sum + row[k], 0)]));
|
|
34
39
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Provider counters are cumulative. Cached input and reasoning are subsets in
|
|
2
|
+
* Codex, while agy reports cached reads separately from its input/total. Keep
|
|
3
|
+
* both the provider total and all processed tokens; never add reasoning twice. */
|
|
4
|
+
import type { Usage, Provider } from './session-types.mjs'
|
|
5
|
+
const count = (value: unknown): value is number => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0
|
|
6
|
+
const fields = ['inputTokens', 'cachedInputTokens', 'outputTokens', 'reasoningTokens', 'totalTokens', 'providerTotalTokens'] as const
|
|
7
|
+
|
|
8
|
+
export function normalizeUsage(provider: Provider, raw: unknown): Usage | null {
|
|
9
|
+
if (!raw || typeof raw !== 'object') return null
|
|
10
|
+
const counters = raw as Record<string, unknown>
|
|
11
|
+
const candidate = provider === 'codex' ? {
|
|
12
|
+
inputTokens: counters.inputTokens, cachedInputTokens: counters.cachedInputTokens,
|
|
13
|
+
outputTokens: counters.outputTokens, reasoningTokens: counters.reasoningOutputTokens,
|
|
14
|
+
totalTokens: counters.totalTokens, providerTotalTokens: counters.totalTokens,
|
|
15
|
+
} : {
|
|
16
|
+
inputTokens: counters.input_tokens, cachedInputTokens: counters.cache_read_tokens,
|
|
17
|
+
outputTokens: counters.output_tokens, reasoningTokens: counters.thinking_tokens,
|
|
18
|
+
totalTokens: count(counters.total_tokens) && count(counters.cache_read_tokens) ? counters.total_tokens + counters.cache_read_tokens : null,
|
|
19
|
+
providerTotalTokens: counters.total_tokens,
|
|
20
|
+
}
|
|
21
|
+
if (fields.some(key => !count(candidate[key]))) return null
|
|
22
|
+
// All six fields have been checked above, including provider-specific counters.
|
|
23
|
+
const u = candidate as Usage
|
|
24
|
+
if (provider === 'agy') u.inputTokens += u.cachedInputTokens
|
|
25
|
+
if (u.cachedInputTokens > u.inputTokens || u.reasoningTokens > u.outputTokens) return null
|
|
26
|
+
return u
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function usageDelta(current: Usage | null, previous: Usage | null = null): Usage | null {
|
|
30
|
+
if (!current) return null
|
|
31
|
+
const delta = Object.fromEntries(fields.map(k => [k, current[k] - (previous?.[k] || 0)])) as unknown as Usage
|
|
32
|
+
return fields.every(k => count(delta[k])) ? delta : null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function sumUsage(rows: ReadonlyArray<Usage | null | undefined>): Usage | null {
|
|
36
|
+
const known = rows.filter((row): row is Usage => Boolean(row))
|
|
37
|
+
if (known.length !== rows.length) return null
|
|
38
|
+
return Object.fromEntries(fields.map(k => [k, known.reduce((sum, row) => sum + row[k], 0)])) as unknown as Usage
|
|
39
|
+
}
|