@oxagen/cli 5.5.1-312 → 5.5.1-317
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/oxagen.mjs +850 -573
- package/package.json +1 -1
package/oxagen.mjs
CHANGED
|
@@ -4587,7 +4587,7 @@ function member(kind) {
|
|
|
4587
4587
|
function parseTachoEvent(value) {
|
|
4588
4588
|
return tachoEventSchema.parse(value);
|
|
4589
4589
|
}
|
|
4590
|
-
var TACHO_ENVELOPE_VERSION, digest, str, short, u8, u16, u32, u64, i32, bool, ts, json, TACHO_RUNTIMES, TACHO_FIDELITIES, TACHO_SOURCES, ENFORCEMENT_TIERS, TOOL_STATUSES, POLICY_DECISIONS, POLICY_SOURCES, EFFECT_KINDS, GAP_CAUSES, INCIDENT_KINDS, TOKEN_SOURCE_BASES, SYSTEM_CONTEXT_PART_KINDS, SYSTEM_CONTEXT_PARTS_MAX, systemContextPartSchema, toolFacts, modelFacts, TOKEN_SOURCE_COUNTS, promptFacts, policyFacts, subagentFacts, SUBAGENT_CHAINLESS_ATTR, healthFacts, lifecycleFacts, integrityFacts, MAX_OBSERVED_CHANGES, observedChangeSchema, MAX_SESSION_COMMIT_ITEMS, MAX_COMMIT_FILES, MAX_COMMIT_PARENTS, MAX_COMMIT_SUBJECT, commitName, sessionCommitFileSchema, sessionCommitSchema, observationFacts, inventoryFacts, totalsFacts, allFacts, BODY_MEMBER_NAMES, BODY_FACTS_SHAPE, pick, toolKeys, modelKeys, promptKeys, policyKeys, subagentKeys, healthKeys, lifecycleKeys, integrityKeys, inventoryKeys, totalsKeys, observationKeys, KIND_BODIES, TACHO_KINDS, agentIdentitySchema, subagentIdentitySchema, turnRefSchema, contextSchema, hostSchema, anthropicSchema, ADDRESS_MEMBERS, spanSchema, MAX_CONTENT_REDACTIONS, contentSchema, envelopeBase, members, TOKEN_SOURCE_KINDS, tachoRecordedEventSchema, tachoEventSchema;
|
|
4590
|
+
var TACHO_ENVELOPE_VERSION, digest, str, short, u8, u16, u32, u64, i32, bool, ts, json, TACHO_RUNTIMES, TACHO_FIDELITIES, TACHO_SOURCES, ENFORCEMENT_TIERS, TOOL_STATUSES, POLICY_DECISIONS, POLICY_SOURCES, EFFECT_KINDS, GAP_CAUSES, INCIDENT_KINDS, TOKEN_SOURCE_BASES, REASONING_SOURCES, reasoningBodySchema, SYSTEM_CONTEXT_PART_KINDS, SYSTEM_CONTEXT_PARTS_MAX, systemContextPartSchema, toolFacts, modelFacts, TOKEN_SOURCE_COUNTS, promptFacts, policyFacts, subagentFacts, SUBAGENT_CHAINLESS_ATTR, healthFacts, lifecycleFacts, integrityFacts, MAX_OBSERVED_CHANGES, observedChangeSchema, MAX_SESSION_COMMIT_ITEMS, MAX_COMMIT_FILES, MAX_COMMIT_PARENTS, MAX_COMMIT_SUBJECT, commitName, sessionCommitFileSchema, sessionCommitSchema, observationFacts, inventoryFacts, totalsFacts, allFacts, BODY_MEMBER_NAMES, BODY_FACTS_SHAPE, pick, toolKeys, modelKeys, promptKeys, policyKeys, subagentKeys, healthKeys, lifecycleKeys, integrityKeys, inventoryKeys, totalsKeys, observationKeys, KIND_BODIES, TACHO_KINDS, agentIdentitySchema, subagentIdentitySchema, turnRefSchema, contextSchema, hostSchema, anthropicSchema, ADDRESS_MEMBERS, spanSchema, MAX_CONTENT_REDACTIONS, contentSchema, envelopeBase, members, TOKEN_SOURCE_KINDS, tachoRecordedEventSchema, tachoEventSchema;
|
|
4591
4591
|
var init_envelope = __esm({
|
|
4592
4592
|
"../../packages/tacho/src/envelope.ts"() {
|
|
4593
4593
|
"use strict";
|
|
@@ -4672,6 +4672,20 @@ var init_envelope = __esm({
|
|
|
4672
4672
|
"unknown_model_cost"
|
|
4673
4673
|
];
|
|
4674
4674
|
TOKEN_SOURCE_BASES = ["reported", "estimated"];
|
|
4675
|
+
REASONING_SOURCES = ["thinking", "summary", "opaque"];
|
|
4676
|
+
reasoningBodySchema = external_exports.object({
|
|
4677
|
+
reasoning_source: external_exports.enum(REASONING_SOURCES),
|
|
4678
|
+
/** The block's place in its message, counted from 0 as the harness wrote it. */
|
|
4679
|
+
reasoning_index: u16.optional(),
|
|
4680
|
+
message_id: short.optional(),
|
|
4681
|
+
request_id: short.optional(),
|
|
4682
|
+
/** How long the thought took, when the harness timed it. */
|
|
4683
|
+
reasoning_duration_ms: u32.optional(),
|
|
4684
|
+
/** The UTF-8 length of data the provider returned that Oxagen cannot read. */
|
|
4685
|
+
reasoning_opaque_bytes: u32.optional(),
|
|
4686
|
+
/** The SHA-256 hash of that data. The data itself is never kept. */
|
|
4687
|
+
reasoning_opaque_digest: digest.optional()
|
|
4688
|
+
}).strict();
|
|
4675
4689
|
SYSTEM_CONTEXT_PART_KINDS = [
|
|
4676
4690
|
"system",
|
|
4677
4691
|
"tool",
|
|
@@ -5202,6 +5216,13 @@ var init_envelope = __esm({
|
|
|
5202
5216
|
...pick(...modelKeys),
|
|
5203
5217
|
...pick("mcp_server_name", "mcp_tool_name")
|
|
5204
5218
|
}),
|
|
5219
|
+
// What a model returned of its reasoning, one frame per block (#9364): the
|
|
5220
|
+
// thinking it showed, a summary its provider wrote, or data only the
|
|
5221
|
+
// provider can read. The body is opaque on the wire. Its strict schema is
|
|
5222
|
+
// `reasoningBodySchema` above, which the recorder applies before it seals
|
|
5223
|
+
// and the control plane applies to each typed member before it stores the
|
|
5224
|
+
// frame. The words are the frame's own content, never the `llm_call`'s.
|
|
5225
|
+
"oxagen:reasoning": external_exports.object({}).catchall(json),
|
|
5205
5226
|
// Policy
|
|
5206
5227
|
policy_decision: body({ ...pick(...toolKeys), ...pick(...policyKeys) }),
|
|
5207
5228
|
approval_request: body({ ...pick(...toolKeys), ...pick(...policyKeys) }),
|
|
@@ -12006,7 +12027,11 @@ var init_cursor_adapter = __esm({
|
|
|
12006
12027
|
// Cursor's own event, with no Claude Code counterpart: the agent's message
|
|
12007
12028
|
// once it has finished writing it. `stop` carries no message at all, so
|
|
12008
12029
|
// without this a Cursor run records every prompt and not one reply.
|
|
12009
|
-
afterAgentResponse: "AgentResponse"
|
|
12030
|
+
afterAgentResponse: "AgentResponse",
|
|
12031
|
+
// Cursor's own event too: one block of thinking once the agent has
|
|
12032
|
+
// finished it, as `text`, with how long it took as `duration_ms` (Cursor's
|
|
12033
|
+
// hook reference). The recorder keeps it as `thinking` (#9364).
|
|
12034
|
+
afterAgentThought: "AgentThought"
|
|
12010
12035
|
};
|
|
12011
12036
|
CURSOR_HOOK_EVENTS = Object.keys(
|
|
12012
12037
|
CURSOR_TO_CLAUDE_EVENT
|
|
@@ -13747,16 +13772,26 @@ function keptListOf(member4, value, text6) {
|
|
|
13747
13772
|
function pointerStep(step) {
|
|
13748
13773
|
return `/${String(step).replace(/~/g, "~0").replace(/\//g, "~1")}`;
|
|
13749
13774
|
}
|
|
13750
|
-
function
|
|
13751
|
-
return
|
|
13775
|
+
function namesBodyMember(path2, members3) {
|
|
13776
|
+
return members3.some((member4) => {
|
|
13752
13777
|
const root = `/body${pointerStep(member4)}`;
|
|
13753
13778
|
return path2 === root || path2.startsWith(`${root}/`);
|
|
13754
13779
|
});
|
|
13755
13780
|
}
|
|
13756
|
-
|
|
13781
|
+
function withheldBodyMemberNamesOf(kind) {
|
|
13782
|
+
return kind === REASONING_EVENT_KIND ? WITHHELD_BODY_MEMBER_NAMES : RETAINED_BODY_MEMBER_NAMES;
|
|
13783
|
+
}
|
|
13784
|
+
function isWithheldMemberPath(path2, kind) {
|
|
13785
|
+
return namesBodyMember(
|
|
13786
|
+
path2,
|
|
13787
|
+
kind === void 0 ? WITHHELD_BODY_MEMBER_NAMES : withheldBodyMemberNamesOf(kind)
|
|
13788
|
+
);
|
|
13789
|
+
}
|
|
13790
|
+
var PROMPT_ORIGIN_MEMBERS, PROMPT_ORIGIN_HOP_CHAIN, BACKGROUND_TASK_MEMBERS, SESSION_CRON_MEMBERS, KEPT_TEXT_MAX, HOP_CHAIN_MAX, RETAINED_BODY_MEMBERS, RETAINED_BODY_MEMBER_NAMES, REASONING_EVENT_KIND, REASONING_MEMBER_TYPES, REASONING_BODY_MEMBER_NAMES, WITHHELD_BODY_MEMBER_NAMES;
|
|
13757
13791
|
var init_retention_members = __esm({
|
|
13758
13792
|
"../../packages/tacho/src/retention-members.ts"() {
|
|
13759
13793
|
"use strict";
|
|
13794
|
+
init_envelope();
|
|
13760
13795
|
init_redaction();
|
|
13761
13796
|
PROMPT_ORIGIN_MEMBERS = [
|
|
13762
13797
|
"kind",
|
|
@@ -13803,6 +13838,15 @@ var init_retention_members = __esm({
|
|
|
13803
13838
|
RETAINED_BODY_MEMBER_NAMES = Object.keys(
|
|
13804
13839
|
RETAINED_BODY_MEMBERS
|
|
13805
13840
|
);
|
|
13841
|
+
REASONING_EVENT_KIND = "oxagen:reasoning";
|
|
13842
|
+
REASONING_MEMBER_TYPES = reasoningBodySchema.shape;
|
|
13843
|
+
REASONING_BODY_MEMBER_NAMES = Object.keys(
|
|
13844
|
+
REASONING_MEMBER_TYPES
|
|
13845
|
+
);
|
|
13846
|
+
WITHHELD_BODY_MEMBER_NAMES = [
|
|
13847
|
+
...RETAINED_BODY_MEMBER_NAMES,
|
|
13848
|
+
...REASONING_BODY_MEMBER_NAMES
|
|
13849
|
+
];
|
|
13806
13850
|
}
|
|
13807
13851
|
});
|
|
13808
13852
|
|
|
@@ -14814,6 +14858,12 @@ var init_retention = __esm({
|
|
|
14814
14858
|
llm_call: "model_call",
|
|
14815
14859
|
"oxagen:message": "model_call",
|
|
14816
14860
|
"oxagen:compaction": "model_call",
|
|
14861
|
+
// One block of what a model returned of its reasoning: the thinking it
|
|
14862
|
+
// showed, or a summary its provider wrote (#9364). Its words are model
|
|
14863
|
+
// traffic like the reply they came with. It had no class when the kind
|
|
14864
|
+
// was added, so no thought's words ever shipped, and every content_exact
|
|
14865
|
+
// run that held one was graded `body_missing`.
|
|
14866
|
+
"oxagen:reasoning": "model_call",
|
|
14817
14867
|
// The session title the harness generated or the person typed. It is the
|
|
14818
14868
|
// only notification that carries content.
|
|
14819
14869
|
"oxagen:notification": "model_call",
|
|
@@ -14996,7 +15046,8 @@ function leftovers(input2) {
|
|
|
14996
15046
|
for (const [key, value] of Object.entries(input2)) {
|
|
14997
15047
|
if (value === void 0) continue;
|
|
14998
15048
|
if (PROMOTED.has(key)) continue;
|
|
14999
|
-
if (key === "text" && input2.hook_event_name
|
|
15049
|
+
if (key === "text" && CONTENT_TEXT_EVENTS.has(input2.hook_event_name))
|
|
15050
|
+
continue;
|
|
15000
15051
|
attrs2[attrKey(`hook.${key}`)] = attrValue(value);
|
|
15001
15052
|
}
|
|
15002
15053
|
return attrs2;
|
|
@@ -15446,6 +15497,21 @@ function normalizeHook(raw, env, options) {
|
|
|
15446
15497
|
)
|
|
15447
15498
|
];
|
|
15448
15499
|
}
|
|
15500
|
+
case "AgentThought": {
|
|
15501
|
+
const text6 = str2(input2["text"]);
|
|
15502
|
+
const duration4 = count(input2.duration_ms);
|
|
15503
|
+
const body2 = {
|
|
15504
|
+
reasoning_source: "thinking",
|
|
15505
|
+
...duration4 !== void 0 ? { reasoning_duration_ms: duration4 } : {}
|
|
15506
|
+
};
|
|
15507
|
+
return [
|
|
15508
|
+
draft2(
|
|
15509
|
+
"oxagen:reasoning",
|
|
15510
|
+
body2,
|
|
15511
|
+
text6 !== void 0 ? { content: textContent(text6) } : {}
|
|
15512
|
+
)
|
|
15513
|
+
];
|
|
15514
|
+
}
|
|
15449
15515
|
case "PreCompact":
|
|
15450
15516
|
case "PostCompact": {
|
|
15451
15517
|
const trigger = str2(input2["trigger"]);
|
|
@@ -15596,7 +15662,7 @@ function normalizeHook(raw, env, options) {
|
|
|
15596
15662
|
}
|
|
15597
15663
|
}
|
|
15598
15664
|
}
|
|
15599
|
-
var textMember, pathMember, hookInputSchema, PAYLOAD_REPAIRS_ATTR, TYPED_MEMBERS, TURN_END_REASON_ATTR, PROMPT_SOURCE_DERIVED_ATTR, PROMOTED;
|
|
15665
|
+
var textMember, pathMember, hookInputSchema, PAYLOAD_REPAIRS_ATTR, TYPED_MEMBERS, TURN_END_REASON_ATTR, PROMPT_SOURCE_DERIVED_ATTR, PROMOTED, CONTENT_TEXT_EVENTS;
|
|
15600
15666
|
var init_hooks = __esm({
|
|
15601
15667
|
"../../packages/tacho/src/claude-code/hooks.ts"() {
|
|
15602
15668
|
"use strict";
|
|
@@ -15737,13 +15803,17 @@ var init_hooks = __esm({
|
|
|
15737
15803
|
// every body goes through. Cursor's `preToolUse` carries what the agent
|
|
15738
15804
|
// said before the call as `agent_message`, on every event that can carry
|
|
15739
15805
|
// it, so it is promoted globally. `text` is promoted only for
|
|
15740
|
-
// `AgentResponse` (see `leftovers`): it is Cursor's name
|
|
15741
|
-
//
|
|
15742
|
-
// use `text` for something
|
|
15743
|
-
//
|
|
15744
|
-
// content.
|
|
15806
|
+
// `AgentResponse` and `AgentThought` (see `leftovers`): it is Cursor's name
|
|
15807
|
+
// for the agent's whole message, or one whole thought, on those two
|
|
15808
|
+
// events, but another harness's hook is free to use `text` for something
|
|
15809
|
+
// ordinary, and promoting it everywhere would have skipped redaction for a
|
|
15810
|
+
// field this adapter never meant to carry content.
|
|
15745
15811
|
"agent_message"
|
|
15746
15812
|
]);
|
|
15813
|
+
CONTENT_TEXT_EVENTS = /* @__PURE__ */ new Set([
|
|
15814
|
+
"AgentResponse",
|
|
15815
|
+
"AgentThought"
|
|
15816
|
+
]);
|
|
15747
15817
|
}
|
|
15748
15818
|
});
|
|
15749
15819
|
|
|
@@ -18597,7 +18667,7 @@ var init_backfill = __esm({
|
|
|
18597
18667
|
init_record_basis();
|
|
18598
18668
|
init_context();
|
|
18599
18669
|
init_llm_call_dedupe();
|
|
18600
|
-
BACKFILL_NORMALIZER_VERSION = "
|
|
18670
|
+
BACKFILL_NORMALIZER_VERSION = "4";
|
|
18601
18671
|
TESTED_CLAUDE_CODE_VERSIONS = {
|
|
18602
18672
|
lowest: "2.1.263",
|
|
18603
18673
|
highest: "2.1.281"
|
|
@@ -19321,10 +19391,585 @@ var init_chain = __esm({
|
|
|
19321
19391
|
}
|
|
19322
19392
|
});
|
|
19323
19393
|
|
|
19324
|
-
// ../../packages/tacho/src/
|
|
19394
|
+
// ../../packages/tacho/src/claude-code/transcript.ts
|
|
19395
|
+
function queuedText(value) {
|
|
19396
|
+
if (typeof value === "string") return value.length > 0 ? value : void 0;
|
|
19397
|
+
if (!Array.isArray(value)) return void 0;
|
|
19398
|
+
const text6 = value.map((block) => {
|
|
19399
|
+
const item = rec(block);
|
|
19400
|
+
return s(item?.["type"]) === "text" ? s(item?.["text"]) : void 0;
|
|
19401
|
+
}).filter((t) => t !== void 0 && t.length > 0).join("\n");
|
|
19402
|
+
return text6.length > 0 ? text6 : void 0;
|
|
19403
|
+
}
|
|
19325
19404
|
function rec(value) {
|
|
19326
19405
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
19327
19406
|
}
|
|
19407
|
+
function s(value) {
|
|
19408
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
19409
|
+
}
|
|
19410
|
+
function n(value) {
|
|
19411
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.round(value) : void 0;
|
|
19412
|
+
}
|
|
19413
|
+
function b(value) {
|
|
19414
|
+
return typeof value === "boolean" ? value : void 0;
|
|
19415
|
+
}
|
|
19416
|
+
function defined(members3) {
|
|
19417
|
+
const out = {};
|
|
19418
|
+
for (const [key, value] of Object.entries(members3))
|
|
19419
|
+
if (value !== void 0) out[key] = value;
|
|
19420
|
+
return out;
|
|
19421
|
+
}
|
|
19422
|
+
function isInterrupt(record2, content) {
|
|
19423
|
+
if (typeof content === "string")
|
|
19424
|
+
return content.trimStart().startsWith(INTERRUPT_MARKER2);
|
|
19425
|
+
if (!Array.isArray(content)) return false;
|
|
19426
|
+
if (s(record2["interruptedMessageId"]) !== void 0) return true;
|
|
19427
|
+
return content.some((block) => {
|
|
19428
|
+
const item = rec(block);
|
|
19429
|
+
return s(item?.["type"]) === "text" && (s(item?.["text"]) ?? "").trimStart().startsWith(INTERRUPT_MARKER2);
|
|
19430
|
+
});
|
|
19431
|
+
}
|
|
19432
|
+
function assistantMessageText(content) {
|
|
19433
|
+
if (typeof content === "string")
|
|
19434
|
+
return content.length > 0 ? content : void 0;
|
|
19435
|
+
if (!Array.isArray(content)) return void 0;
|
|
19436
|
+
const parts = [];
|
|
19437
|
+
for (const block of content) {
|
|
19438
|
+
const item = rec(block);
|
|
19439
|
+
const type = s(item?.["type"]);
|
|
19440
|
+
if (type === "text") {
|
|
19441
|
+
const text6 = s(item?.["text"]);
|
|
19442
|
+
if (text6 !== void 0) parts.push(text6);
|
|
19443
|
+
} else if (type === "tool_use") {
|
|
19444
|
+
parts.push(
|
|
19445
|
+
JSON.stringify({
|
|
19446
|
+
tool_use: {
|
|
19447
|
+
...defined({ id: s(item?.["id"]) }),
|
|
19448
|
+
name: s(item?.["name"]) ?? "",
|
|
19449
|
+
input: item?.["input"] ?? null
|
|
19450
|
+
}
|
|
19451
|
+
})
|
|
19452
|
+
);
|
|
19453
|
+
}
|
|
19454
|
+
}
|
|
19455
|
+
return parts.length > 0 ? parts.join("\n") : void 0;
|
|
19456
|
+
}
|
|
19457
|
+
function opaqueReasoning(value) {
|
|
19458
|
+
if (typeof value !== "string" || value.length === 0) return {};
|
|
19459
|
+
return {
|
|
19460
|
+
reasoning_opaque_bytes: Buffer.byteLength(value, "utf8"),
|
|
19461
|
+
reasoning_opaque_digest: digestBytes(value)
|
|
19462
|
+
};
|
|
19463
|
+
}
|
|
19464
|
+
function reasoningParts(content, firstIndex = 0, display = {}) {
|
|
19465
|
+
if (!Array.isArray(content)) return [];
|
|
19466
|
+
const blocks = content.filter((block) => {
|
|
19467
|
+
const type = s(rec(block)?.["type"]);
|
|
19468
|
+
return type === "thinking" || type === "redacted_thinking";
|
|
19469
|
+
});
|
|
19470
|
+
const timed = blocks.length === 1 && display.durationMs !== void 0 && display.durationMs <= 4294967295 ? { reasoning_duration_ms: display.durationMs } : {};
|
|
19471
|
+
const shown3 = display.thinkingDisplay === "summarized" ? "summary" : "thinking";
|
|
19472
|
+
const parts = [];
|
|
19473
|
+
content.forEach((block, position) => {
|
|
19474
|
+
const item = rec(block);
|
|
19475
|
+
const type = s(item?.["type"]);
|
|
19476
|
+
if (type !== "thinking" && type !== "redacted_thinking") return;
|
|
19477
|
+
const at2 = firstIndex + position;
|
|
19478
|
+
const index = at2 <= 65535 ? { reasoning_index: at2 } : {};
|
|
19479
|
+
const text6 = type === "thinking" ? s(item?.["thinking"]) : void 0;
|
|
19480
|
+
const opaque = opaqueReasoning(
|
|
19481
|
+
type === "thinking" ? item?.["signature"] : item?.["data"]
|
|
19482
|
+
);
|
|
19483
|
+
if (text6 !== void 0) {
|
|
19484
|
+
parts.push({
|
|
19485
|
+
body: { reasoning_source: shown3, ...index, ...timed, ...opaque },
|
|
19486
|
+
text: text6
|
|
19487
|
+
});
|
|
19488
|
+
return;
|
|
19489
|
+
}
|
|
19490
|
+
if (opaque.reasoning_opaque_digest === void 0) return;
|
|
19491
|
+
parts.push({
|
|
19492
|
+
body: { reasoning_source: "opaque", ...index, ...timed, ...opaque }
|
|
19493
|
+
});
|
|
19494
|
+
});
|
|
19495
|
+
return parts;
|
|
19496
|
+
}
|
|
19497
|
+
function contextOf(record2) {
|
|
19498
|
+
return defined({
|
|
19499
|
+
cwd: s(record2["cwd"]),
|
|
19500
|
+
git_branch: s(record2["gitBranch"]),
|
|
19501
|
+
entrypoint: s(record2["entrypoint"]),
|
|
19502
|
+
session_kind: s(record2["sessionKind"]),
|
|
19503
|
+
permission_mode: s(record2["permissionMode"]),
|
|
19504
|
+
app_version: s(record2["version"]),
|
|
19505
|
+
// The effort the call ran at: the turn's own when the operator changed it
|
|
19506
|
+
// for one turn, else the session's.
|
|
19507
|
+
effort: s(record2["perTurnEffort"]) ?? s(record2["effort"])
|
|
19508
|
+
});
|
|
19509
|
+
}
|
|
19510
|
+
function tsOf(record2, fallback) {
|
|
19511
|
+
const value = s(record2["timestamp"]) ?? s(record2["ts"]);
|
|
19512
|
+
const millis = value === void 0 ? Number.NaN : Date.parse(value);
|
|
19513
|
+
if (isStorableInstant(millis)) return new Date(millis).toISOString();
|
|
19514
|
+
return fallback;
|
|
19515
|
+
}
|
|
19516
|
+
function resultText(content) {
|
|
19517
|
+
if (typeof content === "string") return content;
|
|
19518
|
+
if (!Array.isArray(content)) return void 0;
|
|
19519
|
+
const parts = content.map((block) => {
|
|
19520
|
+
const item = rec(block);
|
|
19521
|
+
return s(item?.["type"]) === "text" ? s(item?.["text"]) : void 0;
|
|
19522
|
+
}).filter((text6) => text6 !== void 0);
|
|
19523
|
+
return parts.length > 0 ? parts.join("\n") : void 0;
|
|
19524
|
+
}
|
|
19525
|
+
function normalizeTranscriptLine(line, fallbackTs, toolInputs) {
|
|
19526
|
+
const trimmed = line.trim();
|
|
19527
|
+
if (trimmed === "") return { drafts: [], totals: {} };
|
|
19528
|
+
let parsed2;
|
|
19529
|
+
try {
|
|
19530
|
+
parsed2 = JSON.parse(trimmed);
|
|
19531
|
+
} catch {
|
|
19532
|
+
return { drafts: [], totals: {} };
|
|
19533
|
+
}
|
|
19534
|
+
if (parsed2 === null || typeof parsed2 !== "object" || Array.isArray(parsed2))
|
|
19535
|
+
return { drafts: [], totals: {} };
|
|
19536
|
+
const record2 = parsed2;
|
|
19537
|
+
const type = s(record2["type"]);
|
|
19538
|
+
const ts2 = tsOf(record2, fallbackTs);
|
|
19539
|
+
const raw = digestJcs(record2);
|
|
19540
|
+
const promptId = s(record2["promptId"]);
|
|
19541
|
+
const draft2 = (kind, body2, attrs2 = {}) => ({
|
|
19542
|
+
kind,
|
|
19543
|
+
ts: ts2,
|
|
19544
|
+
body: body2,
|
|
19545
|
+
attrs: attrs2,
|
|
19546
|
+
context: contextOf(record2),
|
|
19547
|
+
...promptId !== void 0 ? { turn: { prompt_id: promptId } } : {},
|
|
19548
|
+
...defined({ is_sidechain: b(record2["isSidechain"]) }),
|
|
19549
|
+
raw_source_digest: raw
|
|
19550
|
+
});
|
|
19551
|
+
const titled = (raw2, source) => {
|
|
19552
|
+
const redacted2 = redactText(raw2);
|
|
19553
|
+
const text6 = redacted2.length > SESSION_TITLE_MAX ? cutAt(redacted2, SESSION_TITLE_MAX) : redacted2;
|
|
19554
|
+
return {
|
|
19555
|
+
drafts: [
|
|
19556
|
+
{
|
|
19557
|
+
...draft2("oxagen:session_title", { session_title: text6 }),
|
|
19558
|
+
hook_source_kind: source
|
|
19559
|
+
}
|
|
19560
|
+
],
|
|
19561
|
+
totals: { session_title: text6 },
|
|
19562
|
+
title: { text: text6, source }
|
|
19563
|
+
};
|
|
19564
|
+
};
|
|
19565
|
+
switch (type) {
|
|
19566
|
+
case "assistant": {
|
|
19567
|
+
const message2 = rec(record2["message"]);
|
|
19568
|
+
const usage4 = rec(message2?.["usage"]);
|
|
19569
|
+
const cacheCreation = rec(usage4?.["cache_creation"]);
|
|
19570
|
+
const outputDetails = rec(usage4?.["output_tokens_details"]);
|
|
19571
|
+
const serverTools = rec(usage4?.["server_tool_use"]);
|
|
19572
|
+
const apiError = b(record2["isApiErrorMessage"]) === true;
|
|
19573
|
+
const body2 = defined({
|
|
19574
|
+
model: s(message2?.["model"]),
|
|
19575
|
+
message_id: s(message2?.["id"]),
|
|
19576
|
+
message_uuid: s(record2["uuid"]),
|
|
19577
|
+
request_id: s(record2["requestId"]),
|
|
19578
|
+
stop_reason: s(message2?.["stop_reason"]),
|
|
19579
|
+
stop_sequence: s(message2?.["stop_sequence"]),
|
|
19580
|
+
stop_details: message2?.["stop_details"] ?? void 0,
|
|
19581
|
+
context_management: message2?.["context_management"] ?? void 0,
|
|
19582
|
+
input_tokens: n(usage4?.["input_tokens"]),
|
|
19583
|
+
output_tokens: n(usage4?.["output_tokens"]),
|
|
19584
|
+
cache_read_tokens: n(usage4?.["cache_read_input_tokens"]),
|
|
19585
|
+
cache_creation_tokens: n(usage4?.["cache_creation_input_tokens"]),
|
|
19586
|
+
cache_creation_5m_tokens: n(
|
|
19587
|
+
cacheCreation?.["ephemeral_5m_input_tokens"]
|
|
19588
|
+
),
|
|
19589
|
+
cache_creation_1h_tokens: n(
|
|
19590
|
+
cacheCreation?.["ephemeral_1h_input_tokens"]
|
|
19591
|
+
),
|
|
19592
|
+
thinking_tokens: n(outputDetails?.["thinking_tokens"]),
|
|
19593
|
+
web_search_requests: n(serverTools?.["web_search_requests"]),
|
|
19594
|
+
web_fetch_requests: n(serverTools?.["web_fetch_requests"]),
|
|
19595
|
+
service_tier: s(usage4?.["service_tier"]),
|
|
19596
|
+
speed: s(usage4?.["speed"]),
|
|
19597
|
+
inference_geo: s(usage4?.["inference_geo"]),
|
|
19598
|
+
iterations: Array.isArray(usage4?.["iterations"]) ? usage4?.["iterations"].length : void 0,
|
|
19599
|
+
api_block_index: n(record2["apiBlockIndex"]),
|
|
19600
|
+
truncated_after_output: b(record2["truncatedAfterOutput"]),
|
|
19601
|
+
skill_name: s(record2["attributionSkill"]),
|
|
19602
|
+
mcp_server_name: s(record2["attributionMcpServer"]),
|
|
19603
|
+
mcp_tool_name: s(record2["attributionMcpTool"]),
|
|
19604
|
+
api_error_class: apiError ? s(record2["error"]) ?? "api_error" : void 0
|
|
19605
|
+
});
|
|
19606
|
+
const attrs2 = {};
|
|
19607
|
+
const content = message2?.["content"];
|
|
19608
|
+
if (Array.isArray(content)) {
|
|
19609
|
+
const kinds = content.map(
|
|
19610
|
+
(block) => s(rec(block)?.["type"]) ?? "unknown"
|
|
19611
|
+
);
|
|
19612
|
+
attrs2["transcript.content_block_types"] = JSON.stringify(kinds);
|
|
19613
|
+
const toolUses2 = content.filter((block) => s(rec(block)?.["type"]) === "tool_use").map((block) => s(rec(block)?.["id"]) ?? "");
|
|
19614
|
+
for (const block of content) {
|
|
19615
|
+
const item = rec(block);
|
|
19616
|
+
const id2 = s(item?.["id"]);
|
|
19617
|
+
if (s(item?.["type"]) === "tool_use" && id2 !== void 0)
|
|
19618
|
+
toolInputs?.remember(
|
|
19619
|
+
id2,
|
|
19620
|
+
item?.["input"] ?? null,
|
|
19621
|
+
s(item?.["name"])
|
|
19622
|
+
);
|
|
19623
|
+
}
|
|
19624
|
+
if (toolUses2.length > 0)
|
|
19625
|
+
attrs2["transcript.tool_use_ids"] = JSON.stringify(toolUses2);
|
|
19626
|
+
}
|
|
19627
|
+
const text6 = assistantMessageText(content);
|
|
19628
|
+
const call2 = defined({
|
|
19629
|
+
message_id: s(message2?.["id"]),
|
|
19630
|
+
request_id: s(record2["requestId"])
|
|
19631
|
+
});
|
|
19632
|
+
const reasoning = reasoningParts(
|
|
19633
|
+
content,
|
|
19634
|
+
n(record2["apiBlockIndex"]) ?? 0,
|
|
19635
|
+
defined({
|
|
19636
|
+
thinkingDisplay: s(record2["thinkingDisplay"]),
|
|
19637
|
+
durationMs: n(record2["thinkingDurationMs"])
|
|
19638
|
+
})
|
|
19639
|
+
).map(
|
|
19640
|
+
(part) => ({
|
|
19641
|
+
...draft2("oxagen:reasoning", { ...part.body, ...call2 }),
|
|
19642
|
+
...part.text !== void 0 ? { content: textContent(part.text) } : {}
|
|
19643
|
+
})
|
|
19644
|
+
);
|
|
19645
|
+
return {
|
|
19646
|
+
drafts: [
|
|
19647
|
+
{
|
|
19648
|
+
...draft2(apiError ? "error" : "llm_call", body2, attrs2),
|
|
19649
|
+
...text6 !== void 0 ? { content: textContent(text6) } : {}
|
|
19650
|
+
},
|
|
19651
|
+
...reasoning
|
|
19652
|
+
],
|
|
19653
|
+
totals: {}
|
|
19654
|
+
};
|
|
19655
|
+
}
|
|
19656
|
+
case "user": {
|
|
19657
|
+
const message2 = rec(record2["message"]);
|
|
19658
|
+
const content = message2?.["content"];
|
|
19659
|
+
const drafts = [];
|
|
19660
|
+
if (typeof content === "string") {
|
|
19661
|
+
const origin = promptOriginOf(record2["origin"]);
|
|
19662
|
+
drafts.push({
|
|
19663
|
+
...draft2("oxagen:message", {
|
|
19664
|
+
prompt_digest: digestText(content),
|
|
19665
|
+
prompt_length: content.length,
|
|
19666
|
+
...defined({
|
|
19667
|
+
prompt_source: s(record2["promptSource"]),
|
|
19668
|
+
prompt_origin: origin,
|
|
19669
|
+
is_meta: b(record2["isMeta"]),
|
|
19670
|
+
is_sidechain: b(record2["isSidechain"]),
|
|
19671
|
+
interrupted_message_id: s(record2["interruptedMessageId"]),
|
|
19672
|
+
message_uuid: s(record2["uuid"])
|
|
19673
|
+
})
|
|
19674
|
+
}),
|
|
19675
|
+
...content.length > 0 ? { content: textContent(content) } : {}
|
|
19676
|
+
});
|
|
19677
|
+
} else if (Array.isArray(content)) {
|
|
19678
|
+
for (const block of content) {
|
|
19679
|
+
const item = rec(block);
|
|
19680
|
+
if (s(item?.["type"]) !== "tool_result") continue;
|
|
19681
|
+
const toolUseResult = record2["toolUseResult"];
|
|
19682
|
+
const toolUseId = s(item?.["tool_use_id"]);
|
|
19683
|
+
const failed5 = b(item?.["is_error"]) === true;
|
|
19684
|
+
const held = toolUseId !== void 0 ? toolInputs?.take(toolUseId) : void 0;
|
|
19685
|
+
const input2 = held?.input;
|
|
19686
|
+
const error2 = failed5 ? resultText(item?.["content"]) : void 0;
|
|
19687
|
+
const output2 = toolUseResult ?? (failed5 ? void 0 : item?.["content"]);
|
|
19688
|
+
const exitCode = error2 !== void 0 ? exitCodeOfErrorText(error2) : void 0;
|
|
19689
|
+
drafts.push({
|
|
19690
|
+
...draft2(
|
|
19691
|
+
"tool_call",
|
|
19692
|
+
{
|
|
19693
|
+
...defined({ tool_name: held?.name, tool_use_id: toolUseId }),
|
|
19694
|
+
tool_status: failed5 ? "error" : "ok",
|
|
19695
|
+
// The input's hash and size by the formula the hook uses, so
|
|
19696
|
+
// a call only the transcript recorded can be compared with
|
|
19697
|
+
// an identical call for loops and retries.
|
|
19698
|
+
...defined({
|
|
19699
|
+
tool_input_digest: input2 !== void 0 ? digestJcs(input2) : void 0,
|
|
19700
|
+
tool_input_bytes: input2 !== void 0 ? jsonByteLength(input2) : void 0
|
|
19701
|
+
}),
|
|
19702
|
+
...defined({
|
|
19703
|
+
tool_output_digest: toolUseResult !== void 0 ? digestJcs(toolUseResult) : void 0,
|
|
19704
|
+
tool_exit_code: exitCode,
|
|
19705
|
+
tool_denial_kind: s(record2["toolDenialKind"]),
|
|
19706
|
+
parent_tool_use_id: s(record2["sourceToolUseID"])
|
|
19707
|
+
})
|
|
19708
|
+
},
|
|
19709
|
+
input2 === void 0 && (output2 !== void 0 || error2 !== void 0) ? { [TOOL_INPUT_MISSING_ATTR]: "not_held" } : {}
|
|
19710
|
+
),
|
|
19711
|
+
...input2 !== void 0 || output2 !== void 0 || error2 !== void 0 ? { content: jsonContent(jcs({ input: input2, output: output2, error: error2 })) } : {}
|
|
19712
|
+
});
|
|
19713
|
+
}
|
|
19714
|
+
}
|
|
19715
|
+
return {
|
|
19716
|
+
drafts,
|
|
19717
|
+
totals: defined({ permission_mode: s(record2["permissionMode"]) }),
|
|
19718
|
+
...isInterrupt(record2, content) ? { interrupted: { ts: ts2, ...defined({ prompt_id: promptId }) } } : {}
|
|
19719
|
+
};
|
|
19720
|
+
}
|
|
19721
|
+
case "system": {
|
|
19722
|
+
const subtype = s(record2["subtype"]);
|
|
19723
|
+
if (subtype === "turn_duration") {
|
|
19724
|
+
return {
|
|
19725
|
+
drafts: [
|
|
19726
|
+
draft2(
|
|
19727
|
+
"oxagen:message",
|
|
19728
|
+
defined({
|
|
19729
|
+
turn_duration_ms: n(record2["durationMs"]),
|
|
19730
|
+
turn_message_count: n(record2["messageCount"])
|
|
19731
|
+
}),
|
|
19732
|
+
{ "transcript.subtype": subtype }
|
|
19733
|
+
)
|
|
19734
|
+
],
|
|
19735
|
+
totals: {}
|
|
19736
|
+
};
|
|
19737
|
+
}
|
|
19738
|
+
if (subtype === "stop_hook_summary") {
|
|
19739
|
+
return {
|
|
19740
|
+
drafts: [
|
|
19741
|
+
draft2(
|
|
19742
|
+
"oxagen:hook_health",
|
|
19743
|
+
{
|
|
19744
|
+
hook_name: "Stop",
|
|
19745
|
+
...defined({
|
|
19746
|
+
hook_count: n(record2["hookCount"]),
|
|
19747
|
+
hook_prevented_continuation: b(
|
|
19748
|
+
record2["preventedContinuation"]
|
|
19749
|
+
)
|
|
19750
|
+
})
|
|
19751
|
+
},
|
|
19752
|
+
{ "transcript.subtype": subtype }
|
|
19753
|
+
)
|
|
19754
|
+
],
|
|
19755
|
+
totals: {}
|
|
19756
|
+
};
|
|
19757
|
+
}
|
|
19758
|
+
if (subtype === "api_retry") {
|
|
19759
|
+
return {
|
|
19760
|
+
drafts: [
|
|
19761
|
+
draft2(
|
|
19762
|
+
"oxagen:api_retry",
|
|
19763
|
+
defined({
|
|
19764
|
+
api_retry_attempt: n(record2["attempt"]),
|
|
19765
|
+
api_retry_max: n(record2["max_retries"]),
|
|
19766
|
+
api_retry_delay_ms: n(record2["retry_delay_ms"]),
|
|
19767
|
+
api_retry_no_response: b(record2["no_response"]),
|
|
19768
|
+
api_status_code: n(record2["error_status"])
|
|
19769
|
+
})
|
|
19770
|
+
)
|
|
19771
|
+
],
|
|
19772
|
+
totals: {}
|
|
19773
|
+
};
|
|
19774
|
+
}
|
|
19775
|
+
return { drafts: [], totals: {} };
|
|
19776
|
+
}
|
|
19777
|
+
case "permission-mode": {
|
|
19778
|
+
const mode = s(record2["permissionMode"]);
|
|
19779
|
+
return {
|
|
19780
|
+
drafts: [
|
|
19781
|
+
draft2(
|
|
19782
|
+
"oxagen:permission_mode_change",
|
|
19783
|
+
defined({ permission_mode_to: mode })
|
|
19784
|
+
)
|
|
19785
|
+
],
|
|
19786
|
+
totals: defined({ permission_mode: mode })
|
|
19787
|
+
};
|
|
19788
|
+
}
|
|
19789
|
+
case "worktree-state": {
|
|
19790
|
+
const wt = rec(record2["worktreeSession"]);
|
|
19791
|
+
return {
|
|
19792
|
+
drafts: [
|
|
19793
|
+
{
|
|
19794
|
+
...draft2("oxagen:worktree", { worktree_reason: "worktree-state" }),
|
|
19795
|
+
context: defined({
|
|
19796
|
+
worktree_path: s(wt?.["worktreePath"]),
|
|
19797
|
+
worktree_branch: s(wt?.["worktreeBranch"])
|
|
19798
|
+
})
|
|
19799
|
+
}
|
|
19800
|
+
],
|
|
19801
|
+
totals: {}
|
|
19802
|
+
};
|
|
19803
|
+
}
|
|
19804
|
+
case "relocated":
|
|
19805
|
+
return {
|
|
19806
|
+
drafts: [
|
|
19807
|
+
draft2(
|
|
19808
|
+
"oxagen:cwd_change",
|
|
19809
|
+
defined({ cwd_new: s(record2["relocatedCwd"]) })
|
|
19810
|
+
)
|
|
19811
|
+
],
|
|
19812
|
+
totals: {}
|
|
19813
|
+
};
|
|
19814
|
+
case "attachment": {
|
|
19815
|
+
const attachment = rec(record2["attachment"]);
|
|
19816
|
+
if (s(attachment?.["type"]) !== QUEUED_COMMAND)
|
|
19817
|
+
return { drafts: [], totals: {} };
|
|
19818
|
+
const prompt = queuedText(attachment?.["prompt"]);
|
|
19819
|
+
if (prompt === void 0) return { drafts: [], totals: {} };
|
|
19820
|
+
const origin = promptOriginOf(attachment?.["origin"]);
|
|
19821
|
+
return {
|
|
19822
|
+
drafts: [
|
|
19823
|
+
{
|
|
19824
|
+
...draft2(
|
|
19825
|
+
"oxagen:message",
|
|
19826
|
+
{
|
|
19827
|
+
prompt_digest: digestText(prompt),
|
|
19828
|
+
prompt_length: prompt.length,
|
|
19829
|
+
...defined({
|
|
19830
|
+
prompt_origin: origin,
|
|
19831
|
+
message_uuid: s(record2["uuid"])
|
|
19832
|
+
})
|
|
19833
|
+
},
|
|
19834
|
+
{ [PROMPT_DELIVERY_ATTR]: MID_TURN_DELIVERY }
|
|
19835
|
+
),
|
|
19836
|
+
content: textContent(prompt)
|
|
19837
|
+
}
|
|
19838
|
+
],
|
|
19839
|
+
totals: {}
|
|
19840
|
+
};
|
|
19841
|
+
}
|
|
19842
|
+
case "queue-operation": {
|
|
19843
|
+
const queued = s(record2["content"]);
|
|
19844
|
+
return {
|
|
19845
|
+
drafts: [
|
|
19846
|
+
draft2(
|
|
19847
|
+
"oxagen:queue",
|
|
19848
|
+
defined({
|
|
19849
|
+
queue_operation: s(record2["operation"]),
|
|
19850
|
+
prompt_digest: queued !== void 0 ? digestText(queued) : void 0,
|
|
19851
|
+
prompt_length: queued?.length
|
|
19852
|
+
})
|
|
19853
|
+
)
|
|
19854
|
+
],
|
|
19855
|
+
totals: {}
|
|
19856
|
+
};
|
|
19857
|
+
}
|
|
19858
|
+
case "cost-state": {
|
|
19859
|
+
const cost = record2["totalCostUSD"];
|
|
19860
|
+
const totals2 = defined({
|
|
19861
|
+
total_cost_usd_micros: typeof cost === "number" ? Math.round(cost * 1e6) : void 0,
|
|
19862
|
+
api_duration_ms: n(record2["totalAPIDuration"]),
|
|
19863
|
+
api_duration_without_retries_ms: n(
|
|
19864
|
+
record2["totalAPIDurationWithoutRetries"]
|
|
19865
|
+
),
|
|
19866
|
+
tool_duration_ms_total: n(record2["totalToolDuration"]),
|
|
19867
|
+
duration_ms: n(record2["totalDuration"]),
|
|
19868
|
+
lines_added: n(record2["totalLinesAdded"]),
|
|
19869
|
+
lines_removed: n(record2["totalLinesRemoved"]),
|
|
19870
|
+
has_unknown_model_cost: b(record2["hasUnknownModelCost"]),
|
|
19871
|
+
models_used: rec(record2["modelUsage"])
|
|
19872
|
+
});
|
|
19873
|
+
return { drafts: [], totals: totals2 };
|
|
19874
|
+
}
|
|
19875
|
+
case "ai-title": {
|
|
19876
|
+
const title = s(record2["aiTitle"]);
|
|
19877
|
+
if (title === void 0) return { drafts: [], totals: {} };
|
|
19878
|
+
return titled(title, "ai-title");
|
|
19879
|
+
}
|
|
19880
|
+
case "custom-title": {
|
|
19881
|
+
const title = s(record2["customTitle"]);
|
|
19882
|
+
if (title === void 0) return { drafts: [], totals: {} };
|
|
19883
|
+
return titled(title, "custom-title");
|
|
19884
|
+
}
|
|
19885
|
+
case "pr-link": {
|
|
19886
|
+
const url2 = s(record2["prUrl"]);
|
|
19887
|
+
const number5 = n(record2["prNumber"]);
|
|
19888
|
+
if (url2 === void 0 || number5 === void 0)
|
|
19889
|
+
return { drafts: [], totals: {} };
|
|
19890
|
+
const repository = s(record2["prRepository"]);
|
|
19891
|
+
return {
|
|
19892
|
+
drafts: [
|
|
19893
|
+
draft2(
|
|
19894
|
+
"oxagen:pr_link",
|
|
19895
|
+
{},
|
|
19896
|
+
{
|
|
19897
|
+
"pr.number": String(number5),
|
|
19898
|
+
"pr.url": url2,
|
|
19899
|
+
...repository !== void 0 ? { "pr.repository": repository } : {}
|
|
19900
|
+
}
|
|
19901
|
+
)
|
|
19902
|
+
],
|
|
19903
|
+
totals: {}
|
|
19904
|
+
};
|
|
19905
|
+
}
|
|
19906
|
+
default:
|
|
19907
|
+
return { drafts: [], totals: {} };
|
|
19908
|
+
}
|
|
19909
|
+
}
|
|
19910
|
+
var PROMPT_DELIVERY_ATTR, MID_TURN_DELIVERY, QUEUED_COMMAND, SESSION_TITLE_MAX, INTERRUPT_MARKER2, TOOL_INPUT_MEMORY_CALLS, TOOL_INPUT_MEMORY_BYTES, ToolInputMemory;
|
|
19911
|
+
var init_transcript = __esm({
|
|
19912
|
+
"../../packages/tacho/src/claude-code/transcript.ts"() {
|
|
19913
|
+
"use strict";
|
|
19914
|
+
init_digest();
|
|
19915
|
+
init_timestamp();
|
|
19916
|
+
init_frame_body();
|
|
19917
|
+
init_redaction();
|
|
19918
|
+
init_replay_grade();
|
|
19919
|
+
init_context();
|
|
19920
|
+
init_payload_members();
|
|
19921
|
+
init_tools();
|
|
19922
|
+
PROMPT_DELIVERY_ATTR = "oxagen.prompt_delivery";
|
|
19923
|
+
MID_TURN_DELIVERY = "mid_turn";
|
|
19924
|
+
QUEUED_COMMAND = "queued_command";
|
|
19925
|
+
SESSION_TITLE_MAX = 512;
|
|
19926
|
+
INTERRUPT_MARKER2 = "[Request interrupted by user";
|
|
19927
|
+
TOOL_INPUT_MEMORY_CALLS = 128;
|
|
19928
|
+
TOOL_INPUT_MEMORY_BYTES = 8 * 1024 * 1024;
|
|
19929
|
+
ToolInputMemory = class {
|
|
19930
|
+
constructor(maxCalls = TOOL_INPUT_MEMORY_CALLS, maxBytes = TOOL_INPUT_MEMORY_BYTES) {
|
|
19931
|
+
this.maxCalls = maxCalls;
|
|
19932
|
+
this.maxBytes = maxBytes;
|
|
19933
|
+
}
|
|
19934
|
+
maxCalls;
|
|
19935
|
+
maxBytes;
|
|
19936
|
+
inputs = /* @__PURE__ */ new Map();
|
|
19937
|
+
bytes = 0;
|
|
19938
|
+
remember(id2, input2, name2) {
|
|
19939
|
+
const bytes = jsonByteLength(input2);
|
|
19940
|
+
this.forget(id2);
|
|
19941
|
+
if (bytes > this.maxBytes) return;
|
|
19942
|
+
this.inputs.set(id2, {
|
|
19943
|
+
call: { input: input2, ...name2 !== void 0 ? { name: name2 } : {} },
|
|
19944
|
+
bytes
|
|
19945
|
+
});
|
|
19946
|
+
this.bytes += bytes;
|
|
19947
|
+
for (const oldest of this.inputs.keys()) {
|
|
19948
|
+
if (this.inputs.size <= this.maxCalls && this.bytes <= this.maxBytes)
|
|
19949
|
+
break;
|
|
19950
|
+
this.forget(oldest);
|
|
19951
|
+
}
|
|
19952
|
+
}
|
|
19953
|
+
/** The call's input and name, once: a result is read for one call only. */
|
|
19954
|
+
take(id2) {
|
|
19955
|
+
const held = this.inputs.get(id2);
|
|
19956
|
+
this.forget(id2);
|
|
19957
|
+
return held?.call;
|
|
19958
|
+
}
|
|
19959
|
+
forget(id2) {
|
|
19960
|
+
const held = this.inputs.get(id2);
|
|
19961
|
+
if (held === void 0) return;
|
|
19962
|
+
this.bytes -= held.bytes;
|
|
19963
|
+
this.inputs.delete(id2);
|
|
19964
|
+
}
|
|
19965
|
+
};
|
|
19966
|
+
}
|
|
19967
|
+
});
|
|
19968
|
+
|
|
19969
|
+
// ../../packages/tacho/src/codex/rollout.ts
|
|
19970
|
+
function rec2(value) {
|
|
19971
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
19972
|
+
}
|
|
19328
19973
|
function short2(value) {
|
|
19329
19974
|
return typeof value === "string" && value.length > 0 && value.length <= 512 ? value : void 0;
|
|
19330
19975
|
}
|
|
@@ -19344,7 +19989,7 @@ function messageText(content) {
|
|
|
19344
19989
|
if (!Array.isArray(content)) return [];
|
|
19345
19990
|
const parts = [];
|
|
19346
19991
|
for (const block of content) {
|
|
19347
|
-
const item =
|
|
19992
|
+
const item = rec2(block);
|
|
19348
19993
|
if (item?.["type"] !== "output_text") continue;
|
|
19349
19994
|
const text6 = item["text"];
|
|
19350
19995
|
if (typeof text6 === "string" && text6.length > 0) parts.push(text6);
|
|
@@ -19447,7 +20092,7 @@ function hookShape(type, item) {
|
|
|
19447
20092
|
harnessName: name2
|
|
19448
20093
|
});
|
|
19449
20094
|
if (type === "local_shell_call") {
|
|
19450
|
-
const argv = words(
|
|
20095
|
+
const argv = words(rec2(item["action"])?.["command"]);
|
|
19451
20096
|
if (argv !== void 0) return command2(shlexJoin(argv));
|
|
19452
20097
|
}
|
|
19453
20098
|
if (type === "function_call") {
|
|
@@ -19457,7 +20102,7 @@ function hookShape(type, item) {
|
|
|
19457
20102
|
name: mcpToolName2(namespace, name2),
|
|
19458
20103
|
input: hookArguments(item["arguments"])
|
|
19459
20104
|
};
|
|
19460
|
-
const args =
|
|
20105
|
+
const args = rec2(argumentsOf(item["arguments"]));
|
|
19461
20106
|
const cmd = args?.["cmd"];
|
|
19462
20107
|
const script = args?.["command"];
|
|
19463
20108
|
const argv = words(script);
|
|
@@ -19476,7 +20121,7 @@ function exitCodeOf2(value) {
|
|
|
19476
20121
|
return typeof value === "number" && Number.isInteger(value) && value >= -2147483648 && value <= 2147483647 ? value : void 0;
|
|
19477
20122
|
}
|
|
19478
20123
|
function itemTurn(item) {
|
|
19479
|
-
const metadata =
|
|
20124
|
+
const metadata = rec2(item["internal_chat_message_metadata_passthrough"]);
|
|
19480
20125
|
return short2(metadata?.["turn_id"]);
|
|
19481
20126
|
}
|
|
19482
20127
|
function countUnknown(state, type) {
|
|
@@ -19494,7 +20139,7 @@ function dropHeld(state) {
|
|
|
19494
20139
|
}
|
|
19495
20140
|
function modeEffort(settings) {
|
|
19496
20141
|
return short2(
|
|
19497
|
-
|
|
20142
|
+
rec2(rec2(settings?.["collaboration_mode"])?.["settings"])?.["reasoning_effort"]
|
|
19498
20143
|
);
|
|
19499
20144
|
}
|
|
19500
20145
|
function withThreadSettings(state, settings) {
|
|
@@ -19524,7 +20169,8 @@ function holdItem(state, kind, item, parts, call2) {
|
|
|
19524
20169
|
calls: call2 !== void 0 && held.calls.length < CALLS_MAX ? [...held.calls, call2] : held.calls,
|
|
19525
20170
|
...turnId !== void 0 ? { turnId } : {},
|
|
19526
20171
|
...held.originalBytes !== void 0 ? { originalBytes: held.originalBytes } : {},
|
|
19527
|
-
...held.tooLarge === true ? { tooLarge: true } : {}
|
|
20172
|
+
...held.tooLarge === true ? { tooLarge: true } : {},
|
|
20173
|
+
...held.reasoning !== void 0 ? { reasoning: held.reasoning } : {}
|
|
19528
20174
|
};
|
|
19529
20175
|
if (next.tooLarge !== true && parts.length > 0) {
|
|
19530
20176
|
const added = parts.reduce(
|
|
@@ -19548,8 +20194,107 @@ function holdItem(state, kind, item, parts, call2) {
|
|
|
19548
20194
|
}
|
|
19549
20195
|
return { ...state, held: next };
|
|
19550
20196
|
}
|
|
20197
|
+
function reasoningOfItem(item, raw) {
|
|
20198
|
+
const out = [];
|
|
20199
|
+
const words3 = (list2, source) => {
|
|
20200
|
+
if (!Array.isArray(list2)) return;
|
|
20201
|
+
for (const part of list2) {
|
|
20202
|
+
const text6 = rec2(part)?.["text"];
|
|
20203
|
+
if (typeof text6 === "string" && text6.length > 0)
|
|
20204
|
+
out.push({ source, text: text6, raw, origin: "item" });
|
|
20205
|
+
}
|
|
20206
|
+
};
|
|
20207
|
+
words3(item["summary"], "summary");
|
|
20208
|
+
words3(item["content"], "thinking");
|
|
20209
|
+
const opaque = opaqueReasoning(item["encrypted_content"]);
|
|
20210
|
+
if (opaque.reasoning_opaque_digest !== void 0)
|
|
20211
|
+
out.push({
|
|
20212
|
+
source: "opaque",
|
|
20213
|
+
bytes: opaque.reasoning_opaque_bytes,
|
|
20214
|
+
digest: opaque.reasoning_opaque_digest,
|
|
20215
|
+
raw,
|
|
20216
|
+
origin: "item"
|
|
20217
|
+
});
|
|
20218
|
+
return out;
|
|
20219
|
+
}
|
|
20220
|
+
function holdReasoning(state, parts) {
|
|
20221
|
+
if (parts.length === 0) return state;
|
|
20222
|
+
const held = state.held ?? {
|
|
20223
|
+
parts: [],
|
|
20224
|
+
bytes: 0,
|
|
20225
|
+
kinds: [],
|
|
20226
|
+
calls: []
|
|
20227
|
+
};
|
|
20228
|
+
const reasoning = [...held.reasoning ?? []];
|
|
20229
|
+
let bytes = reasoning.some((part) => part.originalBytes !== void 0) ? REASONING_BYTES_MAX : reasoning.reduce(
|
|
20230
|
+
(sum3, part) => sum3 + (part.text === void 0 ? 0 : Buffer.byteLength(part.text, "utf8")),
|
|
20231
|
+
0
|
|
20232
|
+
);
|
|
20233
|
+
for (const part of parts) {
|
|
20234
|
+
if (reasoning.length >= REASONING_PARTS_MAX) break;
|
|
20235
|
+
const copyOf = reasoning.findIndex(
|
|
20236
|
+
(heldPart) => heldPart.matched !== true && heldPart.origin !== part.origin && heldPart.source === part.source && heldPart.text === part.text && heldPart.digest === part.digest
|
|
20237
|
+
);
|
|
20238
|
+
const original = reasoning[copyOf];
|
|
20239
|
+
if (original !== void 0) {
|
|
20240
|
+
reasoning[copyOf] = { ...original, matched: true };
|
|
20241
|
+
continue;
|
|
20242
|
+
}
|
|
20243
|
+
if (part.text === void 0) {
|
|
20244
|
+
reasoning.push(part);
|
|
20245
|
+
continue;
|
|
20246
|
+
}
|
|
20247
|
+
const room = REASONING_BYTES_MAX - bytes;
|
|
20248
|
+
if (room <= 0) continue;
|
|
20249
|
+
const text6 = cutUtf8(part.text, room);
|
|
20250
|
+
if (text6.length === 0) continue;
|
|
20251
|
+
if (text6 === part.text) {
|
|
20252
|
+
reasoning.push({ ...part, text: text6 });
|
|
20253
|
+
bytes += Buffer.byteLength(text6, "utf8");
|
|
20254
|
+
continue;
|
|
20255
|
+
}
|
|
20256
|
+
reasoning.push({ ...part, text: text6, ...wholePart(part.text) });
|
|
20257
|
+
bytes = REASONING_BYTES_MAX;
|
|
20258
|
+
}
|
|
20259
|
+
return { ...state, held: { ...held, reasoning } };
|
|
20260
|
+
}
|
|
20261
|
+
function wholePart(text6) {
|
|
20262
|
+
const prepared = prepareContent(textContent(text6));
|
|
20263
|
+
return prepared.truncated !== void 0 ? {
|
|
20264
|
+
originalBytes: prepared.truncated.originalBytes,
|
|
20265
|
+
originalDigest: prepared.truncated.originalDigest
|
|
20266
|
+
} : {
|
|
20267
|
+
originalBytes: prepared.body.bytes.byteLength,
|
|
20268
|
+
originalDigest: prepared.digest
|
|
20269
|
+
};
|
|
20270
|
+
}
|
|
20271
|
+
function reasoningDrafts(held, responseId, turnId, ts2) {
|
|
20272
|
+
return (held?.reasoning ?? []).map(
|
|
20273
|
+
(part, index) => ({
|
|
20274
|
+
kind: "oxagen:reasoning",
|
|
20275
|
+
ts: ts2,
|
|
20276
|
+
body: {
|
|
20277
|
+
reasoning_source: part.source,
|
|
20278
|
+
reasoning_index: index,
|
|
20279
|
+
...responseId !== void 0 ? { message_id: responseId } : {},
|
|
20280
|
+
...part.bytes !== void 0 ? { reasoning_opaque_bytes: part.bytes } : {},
|
|
20281
|
+
...part.digest !== void 0 ? { reasoning_opaque_digest: part.digest } : {}
|
|
20282
|
+
},
|
|
20283
|
+
attrs: part.originalBytes === void 0 ? {} : {
|
|
20284
|
+
[BODY_TRUNCATED_ATTR]: "too_large",
|
|
20285
|
+
[BODY_ORIGINAL_BYTES_ATTR]: String(part.originalBytes),
|
|
20286
|
+
...part.originalDigest !== void 0 ? { [BODY_ORIGINAL_DIGEST_ATTR]: part.originalDigest } : {}
|
|
20287
|
+
},
|
|
20288
|
+
// `normalizeRolloutLine` fills the context on every draft.
|
|
20289
|
+
context: {},
|
|
20290
|
+
...turnId !== void 0 ? { turn: { turn_id: turnId } } : {},
|
|
20291
|
+
raw_source_digest: part.raw,
|
|
20292
|
+
...part.text !== void 0 ? { content: textContent(part.text) } : {}
|
|
20293
|
+
})
|
|
20294
|
+
);
|
|
20295
|
+
}
|
|
19551
20296
|
function callBody(state, payload) {
|
|
19552
|
-
const usage4 =
|
|
20297
|
+
const usage4 = rec2(payload["usage"]);
|
|
19553
20298
|
const body2 = {};
|
|
19554
20299
|
const set2 = (key, value) => {
|
|
19555
20300
|
if (value !== void 0) body2[key] = value;
|
|
@@ -19602,7 +20347,8 @@ function closeResponse(state, record2, payload, ts2) {
|
|
|
19602
20347
|
raw_source_digest: digestJcs(record2),
|
|
19603
20348
|
...content !== void 0 ? { content } : {}
|
|
19604
20349
|
};
|
|
19605
|
-
|
|
20350
|
+
const reasoning = dropped ? [] : reasoningDrafts(held, short2(payload["response_id"]), turnId, ts2);
|
|
20351
|
+
return { drafts: [draft2, ...reasoning], state: rest };
|
|
19606
20352
|
}
|
|
19607
20353
|
function forgetInput(inputs, call2) {
|
|
19608
20354
|
const entry2 = inputs.byCall.get(call2);
|
|
@@ -19792,12 +20538,12 @@ function completionDraft(record2, payload, call2, ts2, facts) {
|
|
|
19792
20538
|
function errorClassOf(info) {
|
|
19793
20539
|
const named2 = short2(info);
|
|
19794
20540
|
if (named2 !== void 0) return named2;
|
|
19795
|
-
const variant =
|
|
20541
|
+
const variant = rec2(info);
|
|
19796
20542
|
return variant === void 0 ? void 0 : Object.keys(variant).map(short2).find((key) => key !== void 0);
|
|
19797
20543
|
}
|
|
19798
20544
|
function httpStatusOf(info, errorClass2) {
|
|
19799
20545
|
if (errorClass2 === void 0) return void 0;
|
|
19800
|
-
const status2 =
|
|
20546
|
+
const status2 = rec2(rec2(info)?.[errorClass2])?.["http_status_code"];
|
|
19801
20547
|
return typeof status2 === "number" && Number.isInteger(status2) && status2 >= 100 && status2 <= 599 ? status2 : void 0;
|
|
19802
20548
|
}
|
|
19803
20549
|
function failedTurn(state, record2, payload, error2, ts2) {
|
|
@@ -19824,13 +20570,13 @@ function failedTurn(state, record2, payload, error2, ts2) {
|
|
|
19824
20570
|
...typeof message2 === "string" && message2 !== "" ? { content: textContent(message2) } : {}
|
|
19825
20571
|
};
|
|
19826
20572
|
}
|
|
19827
|
-
function
|
|
20573
|
+
function contextOf2(state) {
|
|
19828
20574
|
return {
|
|
19829
20575
|
...state.version !== void 0 ? { app_version: state.version } : {},
|
|
19830
20576
|
...state.effort !== void 0 ? { effort: state.effort } : {}
|
|
19831
20577
|
};
|
|
19832
20578
|
}
|
|
19833
|
-
function
|
|
20579
|
+
function tsOf2(record2, fallback) {
|
|
19834
20580
|
const value = record2["timestamp"];
|
|
19835
20581
|
const millis = typeof value === "string" ? Date.parse(value) : Number.NaN;
|
|
19836
20582
|
if (isStorableInstant(millis)) return new Date(millis).toISOString();
|
|
@@ -19842,7 +20588,7 @@ function normalizeRolloutLine(line, previous, fallbackTs) {
|
|
|
19842
20588
|
const out = readLine(line, before, fallbackTs, inputs);
|
|
19843
20589
|
heldInputs.set(out.state, inputs);
|
|
19844
20590
|
if (out.normalized.drafts.length === 0) return out;
|
|
19845
|
-
const context =
|
|
20591
|
+
const context = contextOf2(before);
|
|
19846
20592
|
return {
|
|
19847
20593
|
normalized: {
|
|
19848
20594
|
...out.normalized,
|
|
@@ -19856,7 +20602,7 @@ function readLine(line, state, fallbackTs, inputs) {
|
|
|
19856
20602
|
if (trimmed === "") return { normalized: NOTHING, state };
|
|
19857
20603
|
let record2;
|
|
19858
20604
|
try {
|
|
19859
|
-
record2 =
|
|
20605
|
+
record2 = rec2(JSON.parse(trimmed));
|
|
19860
20606
|
} catch {
|
|
19861
20607
|
record2 = void 0;
|
|
19862
20608
|
}
|
|
@@ -19864,7 +20610,7 @@ function readLine(line, state, fallbackTs, inputs) {
|
|
|
19864
20610
|
return { normalized: NOTHING, state: countUnknown(state, "(not json)") };
|
|
19865
20611
|
const rawType = record2["type"];
|
|
19866
20612
|
const type = typeof rawType === "string" ? rawType : void 0;
|
|
19867
|
-
const payload =
|
|
20613
|
+
const payload = rec2(record2["payload"]) ?? {};
|
|
19868
20614
|
if (type === "session_meta") {
|
|
19869
20615
|
if (state.meta === true) return { normalized: NOTHING, state };
|
|
19870
20616
|
const historyStart = count3(payload["subagent_history_start_ordinal"]);
|
|
@@ -19913,9 +20659,9 @@ function readLine(line, state, fallbackTs, inputs) {
|
|
|
19913
20659
|
return { normalized: NOTHING, state: dropHeld(state) };
|
|
19914
20660
|
case "event_msg": {
|
|
19915
20661
|
const event = payload["type"];
|
|
19916
|
-
const error2 = event === "task_complete" ?
|
|
20662
|
+
const error2 = event === "task_complete" ? rec2(payload["error"]) : void 0;
|
|
19917
20663
|
if (error2 !== void 0) {
|
|
19918
|
-
const ts2 =
|
|
20664
|
+
const ts2 = tsOf2(record2, fallbackTs);
|
|
19919
20665
|
const draft2 = failedTurn(state, record2, payload, error2, ts2);
|
|
19920
20666
|
return {
|
|
19921
20667
|
normalized: { drafts: [draft2], totals: {} },
|
|
@@ -19927,10 +20673,10 @@ function readLine(line, state, fallbackTs, inputs) {
|
|
|
19927
20673
|
if (event === "thread_settings_applied")
|
|
19928
20674
|
return {
|
|
19929
20675
|
normalized: NOTHING,
|
|
19930
|
-
state: withThreadSettings(state,
|
|
20676
|
+
state: withThreadSettings(state, rec2(payload["thread_settings"]))
|
|
19931
20677
|
};
|
|
19932
20678
|
if (event === "item_completed") {
|
|
19933
|
-
const item =
|
|
20679
|
+
const item = rec2(payload["item"]);
|
|
19934
20680
|
const call2 = short2(item?.["id"]);
|
|
19935
20681
|
if (item === void 0 || call2 === void 0)
|
|
19936
20682
|
return { normalized: NOTHING, state };
|
|
@@ -19946,7 +20692,7 @@ function readLine(line, state, fallbackTs, inputs) {
|
|
|
19946
20692
|
kind === "McpToolCall" ? mcpCompletionName(item) : void 0
|
|
19947
20693
|
)
|
|
19948
20694
|
};
|
|
19949
|
-
const ts2 =
|
|
20695
|
+
const ts2 = tsOf2(record2, fallbackTs);
|
|
19950
20696
|
const draft2 = kind === "CommandExecution" && item["source"] !== "user_shell" ? commandCall(record2, payload, item, call2, ts2) : kind === "McpToolCall" ? mcpCall(record2, payload, item, call2, ts2) : kind === "FileChange" ? patchCall(record2, payload, item, call2, ts2) : void 0;
|
|
19951
20697
|
return draft2 === void 0 ? { normalized: NOTHING, state } : { normalized: { drafts: [draft2], totals: {} }, state };
|
|
19952
20698
|
}
|
|
@@ -19960,13 +20706,29 @@ function readLine(line, state, fallbackTs, inputs) {
|
|
|
19960
20706
|
payload["status"]
|
|
19961
20707
|
)
|
|
19962
20708
|
};
|
|
20709
|
+
if (event === "agent_reasoning" || event === "agent_reasoning_raw_content") {
|
|
20710
|
+
const text6 = payload["text"];
|
|
20711
|
+
if (typeof text6 !== "string" || text6.length === 0)
|
|
20712
|
+
return { normalized: NOTHING, state };
|
|
20713
|
+
return {
|
|
20714
|
+
normalized: NOTHING,
|
|
20715
|
+
state: holdReasoning(state, [
|
|
20716
|
+
{
|
|
20717
|
+
source: event === "agent_reasoning" ? "summary" : "thinking",
|
|
20718
|
+
text: text6,
|
|
20719
|
+
raw: digestJcs(record2),
|
|
20720
|
+
origin: "event"
|
|
20721
|
+
}
|
|
20722
|
+
])
|
|
20723
|
+
};
|
|
20724
|
+
}
|
|
19963
20725
|
return { normalized: NOTHING, state };
|
|
19964
20726
|
}
|
|
19965
20727
|
case "token_usage_record": {
|
|
19966
|
-
const ts2 =
|
|
20728
|
+
const ts2 = tsOf2(record2, fallbackTs);
|
|
19967
20729
|
const closed2 = closeResponse(state, record2, payload, ts2);
|
|
19968
20730
|
return {
|
|
19969
|
-
normalized: { drafts:
|
|
20731
|
+
normalized: { drafts: closed2.drafts, totals: {} },
|
|
19970
20732
|
state: closed2.state
|
|
19971
20733
|
};
|
|
19972
20734
|
}
|
|
@@ -19990,7 +20752,10 @@ function readLine(line, state, fallbackTs, inputs) {
|
|
|
19990
20752
|
if (item === "reasoning")
|
|
19991
20753
|
return {
|
|
19992
20754
|
normalized: NOTHING,
|
|
19993
|
-
state:
|
|
20755
|
+
state: holdReasoning(
|
|
20756
|
+
holdItem(state, item, payload, [], void 0),
|
|
20757
|
+
reasoningOfItem(payload, digestJcs(record2))
|
|
20758
|
+
)
|
|
19994
20759
|
};
|
|
19995
20760
|
if (Object.hasOwn(TOOL_ITEMS, item)) {
|
|
19996
20761
|
const input2 = toolInput(item, payload);
|
|
@@ -20007,7 +20772,7 @@ function readLine(line, state, fallbackTs, inputs) {
|
|
|
20007
20772
|
inputs,
|
|
20008
20773
|
record2,
|
|
20009
20774
|
payload,
|
|
20010
|
-
|
|
20775
|
+
tsOf2(record2, fallbackTs)
|
|
20011
20776
|
);
|
|
20012
20777
|
return {
|
|
20013
20778
|
normalized: { drafts: [closed2.draft], totals: {} },
|
|
@@ -20040,7 +20805,7 @@ function codexUserText(payload) {
|
|
|
20040
20805
|
if (!Array.isArray(content)) return void 0;
|
|
20041
20806
|
const parts = [];
|
|
20042
20807
|
for (const block of content) {
|
|
20043
|
-
const item =
|
|
20808
|
+
const item = rec2(block);
|
|
20044
20809
|
if (item?.["type"] !== "input_text") continue;
|
|
20045
20810
|
const text6 = item["text"];
|
|
20046
20811
|
if (typeof text6 === "string" && text6.length > 0) parts.push(text6);
|
|
@@ -20050,10 +20815,11 @@ function codexUserText(payload) {
|
|
|
20050
20815
|
function isCodexInputItem(type) {
|
|
20051
20816
|
return INPUT_ITEMS.has(type);
|
|
20052
20817
|
}
|
|
20053
|
-
var KNOWN_RECORDS, INPUT_ITEMS, TOOL_ITEMS, LOCAL_TOOL_ITEMS, OUTPUT_ITEMS, TURN_EVENTS, UNKNOWN_TYPES_MAX, UNKNOWN_TYPE_CHARS, KINDS_MAX, CALLS_MAX, PENDING_CALLS_MAX, HELD_INPUT_BYTES_MAX, COMMAND_TOOL, PATCH_TOOL, MCP_PREFIX2, BARE2, SINGLE, DOUBLE, heldInputs, NOTHING;
|
|
20818
|
+
var KNOWN_RECORDS, INPUT_ITEMS, TOOL_ITEMS, LOCAL_TOOL_ITEMS, OUTPUT_ITEMS, TURN_EVENTS, UNKNOWN_TYPES_MAX, UNKNOWN_TYPE_CHARS, KINDS_MAX, CALLS_MAX, REASONING_PARTS_MAX, REASONING_BYTES_MAX, PENDING_CALLS_MAX, HELD_INPUT_BYTES_MAX, COMMAND_TOOL, PATCH_TOOL, MCP_PREFIX2, BARE2, SINGLE, DOUBLE, heldInputs, NOTHING;
|
|
20054
20819
|
var init_rollout = __esm({
|
|
20055
20820
|
"../../packages/tacho/src/codex/rollout.ts"() {
|
|
20056
20821
|
"use strict";
|
|
20822
|
+
init_transcript();
|
|
20057
20823
|
init_timestamp();
|
|
20058
20824
|
init_digest();
|
|
20059
20825
|
init_frame_body();
|
|
@@ -20111,6 +20877,8 @@ var init_rollout = __esm({
|
|
|
20111
20877
|
UNKNOWN_TYPE_CHARS = 64;
|
|
20112
20878
|
KINDS_MAX = 64;
|
|
20113
20879
|
CALLS_MAX = 32;
|
|
20880
|
+
REASONING_PARTS_MAX = 64;
|
|
20881
|
+
REASONING_BYTES_MAX = TACHO_MAX_BODY_BYTES;
|
|
20114
20882
|
PENDING_CALLS_MAX = 32;
|
|
20115
20883
|
HELD_INPUT_BYTES_MAX = 2 * TACHO_MAX_BODY_BYTES;
|
|
20116
20884
|
COMMAND_TOOL = "Bash";
|
|
@@ -21695,14 +22463,14 @@ var init_otel = __esm({
|
|
|
21695
22463
|
});
|
|
21696
22464
|
|
|
21697
22465
|
// ../../packages/tacho/src/claude-code/result.ts
|
|
21698
|
-
function
|
|
22466
|
+
function rec3(value) {
|
|
21699
22467
|
return isRecord2(value) ? value : void 0;
|
|
21700
22468
|
}
|
|
21701
22469
|
function strings2(value) {
|
|
21702
22470
|
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : void 0;
|
|
21703
22471
|
}
|
|
21704
22472
|
function inventoryFromInit(record2) {
|
|
21705
|
-
const init =
|
|
22473
|
+
const init = rec3(record2);
|
|
21706
22474
|
if (!init || str2(init["type"]) !== "system" || str2(init["subtype"]) !== "init") {
|
|
21707
22475
|
return {};
|
|
21708
22476
|
}
|
|
@@ -21730,15 +22498,15 @@ function inventoryFromInit(record2) {
|
|
|
21730
22498
|
return out;
|
|
21731
22499
|
}
|
|
21732
22500
|
function totalsFromResult(record2) {
|
|
21733
|
-
const result2 =
|
|
22501
|
+
const result2 = rec3(record2);
|
|
21734
22502
|
const models = [];
|
|
21735
22503
|
if (!result2 || str2(result2["type"]) !== "result") {
|
|
21736
22504
|
return { models };
|
|
21737
22505
|
}
|
|
21738
|
-
const usage4 =
|
|
21739
|
-
const cacheCreation =
|
|
21740
|
-
const outputDetails =
|
|
21741
|
-
const serverTools =
|
|
22506
|
+
const usage4 = rec3(result2["usage"]);
|
|
22507
|
+
const cacheCreation = rec3(usage4?.["cache_creation"]);
|
|
22508
|
+
const outputDetails = rec3(usage4?.["output_tokens_details"]);
|
|
22509
|
+
const serverTools = rec3(usage4?.["server_tool_use"]);
|
|
21742
22510
|
const out = { models };
|
|
21743
22511
|
const set2 = (key, value) => {
|
|
21744
22512
|
if (value !== void 0) out[key] = value;
|
|
@@ -21782,9 +22550,9 @@ function totalsFromResult(record2) {
|
|
|
21782
22550
|
"session_outcome",
|
|
21783
22551
|
bool2(result2["is_error"]) === true ? "aborted" : "completed"
|
|
21784
22552
|
);
|
|
21785
|
-
const modelUsage =
|
|
22553
|
+
const modelUsage = rec3(result2["modelUsage"]);
|
|
21786
22554
|
for (const [model, raw] of Object.entries(modelUsage ?? {})) {
|
|
21787
|
-
const usageRecord =
|
|
22555
|
+
const usageRecord = rec3(raw);
|
|
21788
22556
|
if (!usageRecord) continue;
|
|
21789
22557
|
const modelCost = usageRecord["costUSD"];
|
|
21790
22558
|
models.push({
|
|
@@ -21816,523 +22584,6 @@ var init_result = __esm({
|
|
|
21816
22584
|
}
|
|
21817
22585
|
});
|
|
21818
22586
|
|
|
21819
|
-
// ../../packages/tacho/src/claude-code/transcript.ts
|
|
21820
|
-
function queuedText(value) {
|
|
21821
|
-
if (typeof value === "string") return value.length > 0 ? value : void 0;
|
|
21822
|
-
if (!Array.isArray(value)) return void 0;
|
|
21823
|
-
const text6 = value.map((block) => {
|
|
21824
|
-
const item = rec3(block);
|
|
21825
|
-
return s(item?.["type"]) === "text" ? s(item?.["text"]) : void 0;
|
|
21826
|
-
}).filter((t) => t !== void 0 && t.length > 0).join("\n");
|
|
21827
|
-
return text6.length > 0 ? text6 : void 0;
|
|
21828
|
-
}
|
|
21829
|
-
function rec3(value) {
|
|
21830
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
21831
|
-
}
|
|
21832
|
-
function s(value) {
|
|
21833
|
-
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
21834
|
-
}
|
|
21835
|
-
function n(value) {
|
|
21836
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.round(value) : void 0;
|
|
21837
|
-
}
|
|
21838
|
-
function b(value) {
|
|
21839
|
-
return typeof value === "boolean" ? value : void 0;
|
|
21840
|
-
}
|
|
21841
|
-
function defined(members3) {
|
|
21842
|
-
const out = {};
|
|
21843
|
-
for (const [key, value] of Object.entries(members3))
|
|
21844
|
-
if (value !== void 0) out[key] = value;
|
|
21845
|
-
return out;
|
|
21846
|
-
}
|
|
21847
|
-
function isInterrupt(record2, content) {
|
|
21848
|
-
if (typeof content === "string")
|
|
21849
|
-
return content.trimStart().startsWith(INTERRUPT_MARKER2);
|
|
21850
|
-
if (!Array.isArray(content)) return false;
|
|
21851
|
-
if (s(record2["interruptedMessageId"]) !== void 0) return true;
|
|
21852
|
-
return content.some((block) => {
|
|
21853
|
-
const item = rec3(block);
|
|
21854
|
-
return s(item?.["type"]) === "text" && (s(item?.["text"]) ?? "").trimStart().startsWith(INTERRUPT_MARKER2);
|
|
21855
|
-
});
|
|
21856
|
-
}
|
|
21857
|
-
function assistantMessageText(content) {
|
|
21858
|
-
if (typeof content === "string")
|
|
21859
|
-
return content.length > 0 ? content : void 0;
|
|
21860
|
-
if (!Array.isArray(content)) return void 0;
|
|
21861
|
-
const parts = [];
|
|
21862
|
-
for (const block of content) {
|
|
21863
|
-
const item = rec3(block);
|
|
21864
|
-
const type = s(item?.["type"]);
|
|
21865
|
-
if (type === "text") {
|
|
21866
|
-
const text6 = s(item?.["text"]);
|
|
21867
|
-
if (text6 !== void 0) parts.push(text6);
|
|
21868
|
-
} else if (type === "tool_use") {
|
|
21869
|
-
parts.push(
|
|
21870
|
-
JSON.stringify({
|
|
21871
|
-
tool_use: {
|
|
21872
|
-
...defined({ id: s(item?.["id"]) }),
|
|
21873
|
-
name: s(item?.["name"]) ?? "",
|
|
21874
|
-
input: item?.["input"] ?? null
|
|
21875
|
-
}
|
|
21876
|
-
})
|
|
21877
|
-
);
|
|
21878
|
-
}
|
|
21879
|
-
}
|
|
21880
|
-
return parts.length > 0 ? parts.join("\n") : void 0;
|
|
21881
|
-
}
|
|
21882
|
-
function contextOf2(record2) {
|
|
21883
|
-
return defined({
|
|
21884
|
-
cwd: s(record2["cwd"]),
|
|
21885
|
-
git_branch: s(record2["gitBranch"]),
|
|
21886
|
-
entrypoint: s(record2["entrypoint"]),
|
|
21887
|
-
session_kind: s(record2["sessionKind"]),
|
|
21888
|
-
permission_mode: s(record2["permissionMode"]),
|
|
21889
|
-
app_version: s(record2["version"]),
|
|
21890
|
-
// The effort the call ran at: the turn's own when the operator changed it
|
|
21891
|
-
// for one turn, else the session's.
|
|
21892
|
-
effort: s(record2["perTurnEffort"]) ?? s(record2["effort"])
|
|
21893
|
-
});
|
|
21894
|
-
}
|
|
21895
|
-
function tsOf2(record2, fallback) {
|
|
21896
|
-
const value = s(record2["timestamp"]) ?? s(record2["ts"]);
|
|
21897
|
-
const millis = value === void 0 ? Number.NaN : Date.parse(value);
|
|
21898
|
-
if (isStorableInstant(millis)) return new Date(millis).toISOString();
|
|
21899
|
-
return fallback;
|
|
21900
|
-
}
|
|
21901
|
-
function resultText(content) {
|
|
21902
|
-
if (typeof content === "string") return content;
|
|
21903
|
-
if (!Array.isArray(content)) return void 0;
|
|
21904
|
-
const parts = content.map((block) => {
|
|
21905
|
-
const item = rec3(block);
|
|
21906
|
-
return s(item?.["type"]) === "text" ? s(item?.["text"]) : void 0;
|
|
21907
|
-
}).filter((text6) => text6 !== void 0);
|
|
21908
|
-
return parts.length > 0 ? parts.join("\n") : void 0;
|
|
21909
|
-
}
|
|
21910
|
-
function normalizeTranscriptLine(line, fallbackTs, toolInputs) {
|
|
21911
|
-
const trimmed = line.trim();
|
|
21912
|
-
if (trimmed === "") return { drafts: [], totals: {} };
|
|
21913
|
-
let parsed2;
|
|
21914
|
-
try {
|
|
21915
|
-
parsed2 = JSON.parse(trimmed);
|
|
21916
|
-
} catch {
|
|
21917
|
-
return { drafts: [], totals: {} };
|
|
21918
|
-
}
|
|
21919
|
-
if (parsed2 === null || typeof parsed2 !== "object" || Array.isArray(parsed2))
|
|
21920
|
-
return { drafts: [], totals: {} };
|
|
21921
|
-
const record2 = parsed2;
|
|
21922
|
-
const type = s(record2["type"]);
|
|
21923
|
-
const ts2 = tsOf2(record2, fallbackTs);
|
|
21924
|
-
const raw = digestJcs(record2);
|
|
21925
|
-
const promptId = s(record2["promptId"]);
|
|
21926
|
-
const draft2 = (kind, body2, attrs2 = {}) => ({
|
|
21927
|
-
kind,
|
|
21928
|
-
ts: ts2,
|
|
21929
|
-
body: body2,
|
|
21930
|
-
attrs: attrs2,
|
|
21931
|
-
context: contextOf2(record2),
|
|
21932
|
-
...promptId !== void 0 ? { turn: { prompt_id: promptId } } : {},
|
|
21933
|
-
...defined({ is_sidechain: b(record2["isSidechain"]) }),
|
|
21934
|
-
raw_source_digest: raw
|
|
21935
|
-
});
|
|
21936
|
-
const titled = (raw2, source) => {
|
|
21937
|
-
const redacted2 = redactText(raw2);
|
|
21938
|
-
const text6 = redacted2.length > SESSION_TITLE_MAX ? cutAt(redacted2, SESSION_TITLE_MAX) : redacted2;
|
|
21939
|
-
return {
|
|
21940
|
-
drafts: [
|
|
21941
|
-
{
|
|
21942
|
-
...draft2("oxagen:session_title", { session_title: text6 }),
|
|
21943
|
-
hook_source_kind: source
|
|
21944
|
-
}
|
|
21945
|
-
],
|
|
21946
|
-
totals: { session_title: text6 },
|
|
21947
|
-
title: { text: text6, source }
|
|
21948
|
-
};
|
|
21949
|
-
};
|
|
21950
|
-
switch (type) {
|
|
21951
|
-
case "assistant": {
|
|
21952
|
-
const message2 = rec3(record2["message"]);
|
|
21953
|
-
const usage4 = rec3(message2?.["usage"]);
|
|
21954
|
-
const cacheCreation = rec3(usage4?.["cache_creation"]);
|
|
21955
|
-
const outputDetails = rec3(usage4?.["output_tokens_details"]);
|
|
21956
|
-
const serverTools = rec3(usage4?.["server_tool_use"]);
|
|
21957
|
-
const apiError = b(record2["isApiErrorMessage"]) === true;
|
|
21958
|
-
const body2 = defined({
|
|
21959
|
-
model: s(message2?.["model"]),
|
|
21960
|
-
message_id: s(message2?.["id"]),
|
|
21961
|
-
message_uuid: s(record2["uuid"]),
|
|
21962
|
-
request_id: s(record2["requestId"]),
|
|
21963
|
-
stop_reason: s(message2?.["stop_reason"]),
|
|
21964
|
-
stop_sequence: s(message2?.["stop_sequence"]),
|
|
21965
|
-
stop_details: message2?.["stop_details"] ?? void 0,
|
|
21966
|
-
context_management: message2?.["context_management"] ?? void 0,
|
|
21967
|
-
input_tokens: n(usage4?.["input_tokens"]),
|
|
21968
|
-
output_tokens: n(usage4?.["output_tokens"]),
|
|
21969
|
-
cache_read_tokens: n(usage4?.["cache_read_input_tokens"]),
|
|
21970
|
-
cache_creation_tokens: n(usage4?.["cache_creation_input_tokens"]),
|
|
21971
|
-
cache_creation_5m_tokens: n(
|
|
21972
|
-
cacheCreation?.["ephemeral_5m_input_tokens"]
|
|
21973
|
-
),
|
|
21974
|
-
cache_creation_1h_tokens: n(
|
|
21975
|
-
cacheCreation?.["ephemeral_1h_input_tokens"]
|
|
21976
|
-
),
|
|
21977
|
-
thinking_tokens: n(outputDetails?.["thinking_tokens"]),
|
|
21978
|
-
web_search_requests: n(serverTools?.["web_search_requests"]),
|
|
21979
|
-
web_fetch_requests: n(serverTools?.["web_fetch_requests"]),
|
|
21980
|
-
service_tier: s(usage4?.["service_tier"]),
|
|
21981
|
-
speed: s(usage4?.["speed"]),
|
|
21982
|
-
inference_geo: s(usage4?.["inference_geo"]),
|
|
21983
|
-
iterations: Array.isArray(usage4?.["iterations"]) ? usage4?.["iterations"].length : void 0,
|
|
21984
|
-
api_block_index: n(record2["apiBlockIndex"]),
|
|
21985
|
-
truncated_after_output: b(record2["truncatedAfterOutput"]),
|
|
21986
|
-
skill_name: s(record2["attributionSkill"]),
|
|
21987
|
-
mcp_server_name: s(record2["attributionMcpServer"]),
|
|
21988
|
-
mcp_tool_name: s(record2["attributionMcpTool"]),
|
|
21989
|
-
api_error_class: apiError ? s(record2["error"]) ?? "api_error" : void 0
|
|
21990
|
-
});
|
|
21991
|
-
const attrs2 = {};
|
|
21992
|
-
const content = message2?.["content"];
|
|
21993
|
-
if (Array.isArray(content)) {
|
|
21994
|
-
const kinds = content.map(
|
|
21995
|
-
(block) => s(rec3(block)?.["type"]) ?? "unknown"
|
|
21996
|
-
);
|
|
21997
|
-
attrs2["transcript.content_block_types"] = JSON.stringify(kinds);
|
|
21998
|
-
const toolUses2 = content.filter((block) => s(rec3(block)?.["type"]) === "tool_use").map((block) => s(rec3(block)?.["id"]) ?? "");
|
|
21999
|
-
for (const block of content) {
|
|
22000
|
-
const item = rec3(block);
|
|
22001
|
-
const id2 = s(item?.["id"]);
|
|
22002
|
-
if (s(item?.["type"]) === "tool_use" && id2 !== void 0)
|
|
22003
|
-
toolInputs?.remember(
|
|
22004
|
-
id2,
|
|
22005
|
-
item?.["input"] ?? null,
|
|
22006
|
-
s(item?.["name"])
|
|
22007
|
-
);
|
|
22008
|
-
}
|
|
22009
|
-
if (toolUses2.length > 0)
|
|
22010
|
-
attrs2["transcript.tool_use_ids"] = JSON.stringify(toolUses2);
|
|
22011
|
-
}
|
|
22012
|
-
const text6 = assistantMessageText(content);
|
|
22013
|
-
return {
|
|
22014
|
-
drafts: [
|
|
22015
|
-
{
|
|
22016
|
-
...draft2(apiError ? "error" : "llm_call", body2, attrs2),
|
|
22017
|
-
...text6 !== void 0 ? { content: textContent(text6) } : {}
|
|
22018
|
-
}
|
|
22019
|
-
],
|
|
22020
|
-
totals: {}
|
|
22021
|
-
};
|
|
22022
|
-
}
|
|
22023
|
-
case "user": {
|
|
22024
|
-
const message2 = rec3(record2["message"]);
|
|
22025
|
-
const content = message2?.["content"];
|
|
22026
|
-
const drafts = [];
|
|
22027
|
-
if (typeof content === "string") {
|
|
22028
|
-
const origin = promptOriginOf(record2["origin"]);
|
|
22029
|
-
drafts.push({
|
|
22030
|
-
...draft2("oxagen:message", {
|
|
22031
|
-
prompt_digest: digestText(content),
|
|
22032
|
-
prompt_length: content.length,
|
|
22033
|
-
...defined({
|
|
22034
|
-
prompt_source: s(record2["promptSource"]),
|
|
22035
|
-
prompt_origin: origin,
|
|
22036
|
-
is_meta: b(record2["isMeta"]),
|
|
22037
|
-
is_sidechain: b(record2["isSidechain"]),
|
|
22038
|
-
interrupted_message_id: s(record2["interruptedMessageId"]),
|
|
22039
|
-
message_uuid: s(record2["uuid"])
|
|
22040
|
-
})
|
|
22041
|
-
}),
|
|
22042
|
-
...content.length > 0 ? { content: textContent(content) } : {}
|
|
22043
|
-
});
|
|
22044
|
-
} else if (Array.isArray(content)) {
|
|
22045
|
-
for (const block of content) {
|
|
22046
|
-
const item = rec3(block);
|
|
22047
|
-
if (s(item?.["type"]) !== "tool_result") continue;
|
|
22048
|
-
const toolUseResult = record2["toolUseResult"];
|
|
22049
|
-
const toolUseId = s(item?.["tool_use_id"]);
|
|
22050
|
-
const failed5 = b(item?.["is_error"]) === true;
|
|
22051
|
-
const held = toolUseId !== void 0 ? toolInputs?.take(toolUseId) : void 0;
|
|
22052
|
-
const input2 = held?.input;
|
|
22053
|
-
const error2 = failed5 ? resultText(item?.["content"]) : void 0;
|
|
22054
|
-
const output2 = toolUseResult ?? (failed5 ? void 0 : item?.["content"]);
|
|
22055
|
-
const exitCode = error2 !== void 0 ? exitCodeOfErrorText(error2) : void 0;
|
|
22056
|
-
drafts.push({
|
|
22057
|
-
...draft2(
|
|
22058
|
-
"tool_call",
|
|
22059
|
-
{
|
|
22060
|
-
...defined({ tool_name: held?.name, tool_use_id: toolUseId }),
|
|
22061
|
-
tool_status: failed5 ? "error" : "ok",
|
|
22062
|
-
// The input's hash and size by the formula the hook uses, so
|
|
22063
|
-
// a call only the transcript recorded can be compared with
|
|
22064
|
-
// an identical call for loops and retries.
|
|
22065
|
-
...defined({
|
|
22066
|
-
tool_input_digest: input2 !== void 0 ? digestJcs(input2) : void 0,
|
|
22067
|
-
tool_input_bytes: input2 !== void 0 ? jsonByteLength(input2) : void 0
|
|
22068
|
-
}),
|
|
22069
|
-
...defined({
|
|
22070
|
-
tool_output_digest: toolUseResult !== void 0 ? digestJcs(toolUseResult) : void 0,
|
|
22071
|
-
tool_exit_code: exitCode,
|
|
22072
|
-
tool_denial_kind: s(record2["toolDenialKind"]),
|
|
22073
|
-
parent_tool_use_id: s(record2["sourceToolUseID"])
|
|
22074
|
-
})
|
|
22075
|
-
},
|
|
22076
|
-
input2 === void 0 && (output2 !== void 0 || error2 !== void 0) ? { [TOOL_INPUT_MISSING_ATTR]: "not_held" } : {}
|
|
22077
|
-
),
|
|
22078
|
-
...input2 !== void 0 || output2 !== void 0 || error2 !== void 0 ? { content: jsonContent(jcs({ input: input2, output: output2, error: error2 })) } : {}
|
|
22079
|
-
});
|
|
22080
|
-
}
|
|
22081
|
-
}
|
|
22082
|
-
return {
|
|
22083
|
-
drafts,
|
|
22084
|
-
totals: defined({ permission_mode: s(record2["permissionMode"]) }),
|
|
22085
|
-
...isInterrupt(record2, content) ? { interrupted: { ts: ts2, ...defined({ prompt_id: promptId }) } } : {}
|
|
22086
|
-
};
|
|
22087
|
-
}
|
|
22088
|
-
case "system": {
|
|
22089
|
-
const subtype = s(record2["subtype"]);
|
|
22090
|
-
if (subtype === "turn_duration") {
|
|
22091
|
-
return {
|
|
22092
|
-
drafts: [
|
|
22093
|
-
draft2(
|
|
22094
|
-
"oxagen:message",
|
|
22095
|
-
defined({
|
|
22096
|
-
turn_duration_ms: n(record2["durationMs"]),
|
|
22097
|
-
turn_message_count: n(record2["messageCount"])
|
|
22098
|
-
}),
|
|
22099
|
-
{ "transcript.subtype": subtype }
|
|
22100
|
-
)
|
|
22101
|
-
],
|
|
22102
|
-
totals: {}
|
|
22103
|
-
};
|
|
22104
|
-
}
|
|
22105
|
-
if (subtype === "stop_hook_summary") {
|
|
22106
|
-
return {
|
|
22107
|
-
drafts: [
|
|
22108
|
-
draft2(
|
|
22109
|
-
"oxagen:hook_health",
|
|
22110
|
-
{
|
|
22111
|
-
hook_name: "Stop",
|
|
22112
|
-
...defined({
|
|
22113
|
-
hook_count: n(record2["hookCount"]),
|
|
22114
|
-
hook_prevented_continuation: b(
|
|
22115
|
-
record2["preventedContinuation"]
|
|
22116
|
-
)
|
|
22117
|
-
})
|
|
22118
|
-
},
|
|
22119
|
-
{ "transcript.subtype": subtype }
|
|
22120
|
-
)
|
|
22121
|
-
],
|
|
22122
|
-
totals: {}
|
|
22123
|
-
};
|
|
22124
|
-
}
|
|
22125
|
-
if (subtype === "api_retry") {
|
|
22126
|
-
return {
|
|
22127
|
-
drafts: [
|
|
22128
|
-
draft2(
|
|
22129
|
-
"oxagen:api_retry",
|
|
22130
|
-
defined({
|
|
22131
|
-
api_retry_attempt: n(record2["attempt"]),
|
|
22132
|
-
api_retry_max: n(record2["max_retries"]),
|
|
22133
|
-
api_retry_delay_ms: n(record2["retry_delay_ms"]),
|
|
22134
|
-
api_retry_no_response: b(record2["no_response"]),
|
|
22135
|
-
api_status_code: n(record2["error_status"])
|
|
22136
|
-
})
|
|
22137
|
-
)
|
|
22138
|
-
],
|
|
22139
|
-
totals: {}
|
|
22140
|
-
};
|
|
22141
|
-
}
|
|
22142
|
-
return { drafts: [], totals: {} };
|
|
22143
|
-
}
|
|
22144
|
-
case "permission-mode": {
|
|
22145
|
-
const mode = s(record2["permissionMode"]);
|
|
22146
|
-
return {
|
|
22147
|
-
drafts: [
|
|
22148
|
-
draft2(
|
|
22149
|
-
"oxagen:permission_mode_change",
|
|
22150
|
-
defined({ permission_mode_to: mode })
|
|
22151
|
-
)
|
|
22152
|
-
],
|
|
22153
|
-
totals: defined({ permission_mode: mode })
|
|
22154
|
-
};
|
|
22155
|
-
}
|
|
22156
|
-
case "worktree-state": {
|
|
22157
|
-
const wt = rec3(record2["worktreeSession"]);
|
|
22158
|
-
return {
|
|
22159
|
-
drafts: [
|
|
22160
|
-
{
|
|
22161
|
-
...draft2("oxagen:worktree", { worktree_reason: "worktree-state" }),
|
|
22162
|
-
context: defined({
|
|
22163
|
-
worktree_path: s(wt?.["worktreePath"]),
|
|
22164
|
-
worktree_branch: s(wt?.["worktreeBranch"])
|
|
22165
|
-
})
|
|
22166
|
-
}
|
|
22167
|
-
],
|
|
22168
|
-
totals: {}
|
|
22169
|
-
};
|
|
22170
|
-
}
|
|
22171
|
-
case "relocated":
|
|
22172
|
-
return {
|
|
22173
|
-
drafts: [
|
|
22174
|
-
draft2(
|
|
22175
|
-
"oxagen:cwd_change",
|
|
22176
|
-
defined({ cwd_new: s(record2["relocatedCwd"]) })
|
|
22177
|
-
)
|
|
22178
|
-
],
|
|
22179
|
-
totals: {}
|
|
22180
|
-
};
|
|
22181
|
-
case "attachment": {
|
|
22182
|
-
const attachment = rec3(record2["attachment"]);
|
|
22183
|
-
if (s(attachment?.["type"]) !== QUEUED_COMMAND)
|
|
22184
|
-
return { drafts: [], totals: {} };
|
|
22185
|
-
const prompt = queuedText(attachment?.["prompt"]);
|
|
22186
|
-
if (prompt === void 0) return { drafts: [], totals: {} };
|
|
22187
|
-
const origin = promptOriginOf(attachment?.["origin"]);
|
|
22188
|
-
return {
|
|
22189
|
-
drafts: [
|
|
22190
|
-
{
|
|
22191
|
-
...draft2(
|
|
22192
|
-
"oxagen:message",
|
|
22193
|
-
{
|
|
22194
|
-
prompt_digest: digestText(prompt),
|
|
22195
|
-
prompt_length: prompt.length,
|
|
22196
|
-
...defined({
|
|
22197
|
-
prompt_origin: origin,
|
|
22198
|
-
message_uuid: s(record2["uuid"])
|
|
22199
|
-
})
|
|
22200
|
-
},
|
|
22201
|
-
{ [PROMPT_DELIVERY_ATTR]: MID_TURN_DELIVERY }
|
|
22202
|
-
),
|
|
22203
|
-
content: textContent(prompt)
|
|
22204
|
-
}
|
|
22205
|
-
],
|
|
22206
|
-
totals: {}
|
|
22207
|
-
};
|
|
22208
|
-
}
|
|
22209
|
-
case "queue-operation": {
|
|
22210
|
-
const queued = s(record2["content"]);
|
|
22211
|
-
return {
|
|
22212
|
-
drafts: [
|
|
22213
|
-
draft2(
|
|
22214
|
-
"oxagen:queue",
|
|
22215
|
-
defined({
|
|
22216
|
-
queue_operation: s(record2["operation"]),
|
|
22217
|
-
prompt_digest: queued !== void 0 ? digestText(queued) : void 0,
|
|
22218
|
-
prompt_length: queued?.length
|
|
22219
|
-
})
|
|
22220
|
-
)
|
|
22221
|
-
],
|
|
22222
|
-
totals: {}
|
|
22223
|
-
};
|
|
22224
|
-
}
|
|
22225
|
-
case "cost-state": {
|
|
22226
|
-
const cost = record2["totalCostUSD"];
|
|
22227
|
-
const totals2 = defined({
|
|
22228
|
-
total_cost_usd_micros: typeof cost === "number" ? Math.round(cost * 1e6) : void 0,
|
|
22229
|
-
api_duration_ms: n(record2["totalAPIDuration"]),
|
|
22230
|
-
api_duration_without_retries_ms: n(
|
|
22231
|
-
record2["totalAPIDurationWithoutRetries"]
|
|
22232
|
-
),
|
|
22233
|
-
tool_duration_ms_total: n(record2["totalToolDuration"]),
|
|
22234
|
-
duration_ms: n(record2["totalDuration"]),
|
|
22235
|
-
lines_added: n(record2["totalLinesAdded"]),
|
|
22236
|
-
lines_removed: n(record2["totalLinesRemoved"]),
|
|
22237
|
-
has_unknown_model_cost: b(record2["hasUnknownModelCost"]),
|
|
22238
|
-
models_used: rec3(record2["modelUsage"])
|
|
22239
|
-
});
|
|
22240
|
-
return { drafts: [], totals: totals2 };
|
|
22241
|
-
}
|
|
22242
|
-
case "ai-title": {
|
|
22243
|
-
const title = s(record2["aiTitle"]);
|
|
22244
|
-
if (title === void 0) return { drafts: [], totals: {} };
|
|
22245
|
-
return titled(title, "ai-title");
|
|
22246
|
-
}
|
|
22247
|
-
case "custom-title": {
|
|
22248
|
-
const title = s(record2["customTitle"]);
|
|
22249
|
-
if (title === void 0) return { drafts: [], totals: {} };
|
|
22250
|
-
return titled(title, "custom-title");
|
|
22251
|
-
}
|
|
22252
|
-
case "pr-link": {
|
|
22253
|
-
const url2 = s(record2["prUrl"]);
|
|
22254
|
-
const number5 = n(record2["prNumber"]);
|
|
22255
|
-
if (url2 === void 0 || number5 === void 0)
|
|
22256
|
-
return { drafts: [], totals: {} };
|
|
22257
|
-
const repository = s(record2["prRepository"]);
|
|
22258
|
-
return {
|
|
22259
|
-
drafts: [
|
|
22260
|
-
draft2(
|
|
22261
|
-
"oxagen:pr_link",
|
|
22262
|
-
{},
|
|
22263
|
-
{
|
|
22264
|
-
"pr.number": String(number5),
|
|
22265
|
-
"pr.url": url2,
|
|
22266
|
-
...repository !== void 0 ? { "pr.repository": repository } : {}
|
|
22267
|
-
}
|
|
22268
|
-
)
|
|
22269
|
-
],
|
|
22270
|
-
totals: {}
|
|
22271
|
-
};
|
|
22272
|
-
}
|
|
22273
|
-
default:
|
|
22274
|
-
return { drafts: [], totals: {} };
|
|
22275
|
-
}
|
|
22276
|
-
}
|
|
22277
|
-
var PROMPT_DELIVERY_ATTR, MID_TURN_DELIVERY, QUEUED_COMMAND, SESSION_TITLE_MAX, INTERRUPT_MARKER2, TOOL_INPUT_MEMORY_CALLS, TOOL_INPUT_MEMORY_BYTES, ToolInputMemory;
|
|
22278
|
-
var init_transcript = __esm({
|
|
22279
|
-
"../../packages/tacho/src/claude-code/transcript.ts"() {
|
|
22280
|
-
"use strict";
|
|
22281
|
-
init_digest();
|
|
22282
|
-
init_timestamp();
|
|
22283
|
-
init_frame_body();
|
|
22284
|
-
init_redaction();
|
|
22285
|
-
init_replay_grade();
|
|
22286
|
-
init_context();
|
|
22287
|
-
init_payload_members();
|
|
22288
|
-
init_tools();
|
|
22289
|
-
PROMPT_DELIVERY_ATTR = "oxagen.prompt_delivery";
|
|
22290
|
-
MID_TURN_DELIVERY = "mid_turn";
|
|
22291
|
-
QUEUED_COMMAND = "queued_command";
|
|
22292
|
-
SESSION_TITLE_MAX = 512;
|
|
22293
|
-
INTERRUPT_MARKER2 = "[Request interrupted by user";
|
|
22294
|
-
TOOL_INPUT_MEMORY_CALLS = 128;
|
|
22295
|
-
TOOL_INPUT_MEMORY_BYTES = 8 * 1024 * 1024;
|
|
22296
|
-
ToolInputMemory = class {
|
|
22297
|
-
constructor(maxCalls = TOOL_INPUT_MEMORY_CALLS, maxBytes = TOOL_INPUT_MEMORY_BYTES) {
|
|
22298
|
-
this.maxCalls = maxCalls;
|
|
22299
|
-
this.maxBytes = maxBytes;
|
|
22300
|
-
}
|
|
22301
|
-
maxCalls;
|
|
22302
|
-
maxBytes;
|
|
22303
|
-
inputs = /* @__PURE__ */ new Map();
|
|
22304
|
-
bytes = 0;
|
|
22305
|
-
remember(id2, input2, name2) {
|
|
22306
|
-
const bytes = jsonByteLength(input2);
|
|
22307
|
-
this.forget(id2);
|
|
22308
|
-
if (bytes > this.maxBytes) return;
|
|
22309
|
-
this.inputs.set(id2, {
|
|
22310
|
-
call: { input: input2, ...name2 !== void 0 ? { name: name2 } : {} },
|
|
22311
|
-
bytes
|
|
22312
|
-
});
|
|
22313
|
-
this.bytes += bytes;
|
|
22314
|
-
for (const oldest of this.inputs.keys()) {
|
|
22315
|
-
if (this.inputs.size <= this.maxCalls && this.bytes <= this.maxBytes)
|
|
22316
|
-
break;
|
|
22317
|
-
this.forget(oldest);
|
|
22318
|
-
}
|
|
22319
|
-
}
|
|
22320
|
-
/** The call's input and name, once: a result is read for one call only. */
|
|
22321
|
-
take(id2) {
|
|
22322
|
-
const held = this.inputs.get(id2);
|
|
22323
|
-
this.forget(id2);
|
|
22324
|
-
return held?.call;
|
|
22325
|
-
}
|
|
22326
|
-
forget(id2) {
|
|
22327
|
-
const held = this.inputs.get(id2);
|
|
22328
|
-
if (held === void 0) return;
|
|
22329
|
-
this.bytes -= held.bytes;
|
|
22330
|
-
this.inputs.delete(id2);
|
|
22331
|
-
}
|
|
22332
|
-
};
|
|
22333
|
-
}
|
|
22334
|
-
});
|
|
22335
|
-
|
|
22336
22587
|
// ../../packages/tacho/src/claude-code/recorder.ts
|
|
22337
22588
|
function backfillBody(kind, body2) {
|
|
22338
22589
|
if (kind === "agent_start") {
|
|
@@ -22385,6 +22636,14 @@ function clipToSchema(schema, facts) {
|
|
|
22385
22636
|
}
|
|
22386
22637
|
return out;
|
|
22387
22638
|
}
|
|
22639
|
+
function fitReasoningBody(body2) {
|
|
22640
|
+
const shape = reasoningBodySchema.shape;
|
|
22641
|
+
return Object.fromEntries(
|
|
22642
|
+
Object.entries(clipToSchema(reasoningBodySchema, body2)).filter(
|
|
22643
|
+
([key, value]) => shape[key]?.safeParse(value).success === true
|
|
22644
|
+
)
|
|
22645
|
+
);
|
|
22646
|
+
}
|
|
22388
22647
|
function sealWithUnknownBodyKeysAsAttrs(unsealed, cursor) {
|
|
22389
22648
|
try {
|
|
22390
22649
|
return sealEvent(unsealed, cursor);
|
|
@@ -23246,6 +23505,7 @@ var init_recorder = __esm({
|
|
|
23246
23505
|
const harnessVersion = standard2?.harnessVersion ?? this.harnessVersion ?? context.app_version;
|
|
23247
23506
|
const parent = this.options.parent;
|
|
23248
23507
|
const prepared = fields.content !== void 0 ? prepareContent(fields.content) : void 0;
|
|
23508
|
+
const checkedBody = kind === "oxagen:reasoning" ? fitReasoningBody(body2) : body2;
|
|
23249
23509
|
const content = prepared !== void 0 ? { digest: prepared.digest, redactions: prepared.redactions } : fields.content_digest !== void 0 ? { digest: fields.content_digest, redactions: [] } : void 0;
|
|
23250
23510
|
const backfill = this.options.backfill;
|
|
23251
23511
|
const attrs2 = {
|
|
@@ -23315,7 +23575,7 @@ var init_recorder = __esm({
|
|
|
23315
23575
|
content,
|
|
23316
23576
|
raw_source_digest: fields.raw_source_digest,
|
|
23317
23577
|
kind,
|
|
23318
|
-
body: backfill !== void 0 ? backfillBody(kind,
|
|
23578
|
+
body: backfill !== void 0 ? backfillBody(kind, checkedBody) : checkedBody
|
|
23319
23579
|
});
|
|
23320
23580
|
const sealed = sealWithUnknownBodyKeysAsAttrs(unsealed, this.cursor);
|
|
23321
23581
|
this.cursor = sealed.next;
|
|
@@ -23996,7 +24256,10 @@ var init_recorder = __esm({
|
|
|
23996
24256
|
if (totals2.permission_mode !== void 0)
|
|
23997
24257
|
this.absorbContext({ permission_mode: totals2.permission_mode });
|
|
23998
24258
|
const out = [];
|
|
24259
|
+
let repeatedResponse = false;
|
|
23999
24260
|
for (const draft2 of drafts) {
|
|
24261
|
+
if (draft2.kind === "oxagen:reasoning" && repeatedResponse) continue;
|
|
24262
|
+
repeatedResponse = false;
|
|
24000
24263
|
this.absorbContext(draft2.context);
|
|
24001
24264
|
let body2 = draft2.body;
|
|
24002
24265
|
const sighting = draft2.kind === "llm_call" ? this.llmCallSighting(draft2.body, "transcript") : draft2.kind === "tool_call" ? this.toolCallSighting(
|
|
@@ -24015,6 +24278,7 @@ var init_recorder = __esm({
|
|
|
24015
24278
|
if (duplicate2 === void 0) {
|
|
24016
24279
|
if (codex) {
|
|
24017
24280
|
sighting.commit();
|
|
24281
|
+
repeatedResponse = true;
|
|
24018
24282
|
continue;
|
|
24019
24283
|
}
|
|
24020
24284
|
body2 = withoutUsage(body2);
|
|
@@ -24290,7 +24554,7 @@ var init_backfill2 = __esm({
|
|
|
24290
24554
|
init_codex_prompt_source();
|
|
24291
24555
|
init_record_basis();
|
|
24292
24556
|
init_rollout();
|
|
24293
|
-
CODEX_BACKFILL_NORMALIZER_VERSION = "codex-
|
|
24557
|
+
CODEX_BACKFILL_NORMALIZER_VERSION = "codex-3";
|
|
24294
24558
|
INJECTED_PREFIXES = [
|
|
24295
24559
|
"<environment_context>",
|
|
24296
24560
|
"<user_instructions>",
|
|
@@ -34569,7 +34833,7 @@ import { readFileSync as readFileSync13 } from "node:fs";
|
|
|
34569
34833
|
import { dirname as dirname14, resolve as resolve3 } from "node:path";
|
|
34570
34834
|
import { fileURLToPath } from "node:url";
|
|
34571
34835
|
function readVersion() {
|
|
34572
|
-
if (true) return "5.5.1-
|
|
34836
|
+
if (true) return "5.5.1-317";
|
|
34573
34837
|
try {
|
|
34574
34838
|
const here = dirname14(fileURLToPath(import.meta.url));
|
|
34575
34839
|
const pkg = JSON.parse(
|
|
@@ -82354,7 +82618,7 @@ var init_package = __esm({
|
|
|
82354
82618
|
"package.json"() {
|
|
82355
82619
|
package_default = {
|
|
82356
82620
|
name: "@oxagen/cli",
|
|
82357
|
-
version: "5.5.1-
|
|
82621
|
+
version: "5.5.1-317",
|
|
82358
82622
|
description: "Oxagen governance CLI: spend, source tracking, grounding, credentials, and audit (agentic coding lives in the stella CLI)",
|
|
82359
82623
|
type: "module",
|
|
82360
82624
|
main: "./dist/index.js",
|
|
@@ -99823,7 +100087,7 @@ function isDigest(value) {
|
|
|
99823
100087
|
function withheldMemberFrom(value) {
|
|
99824
100088
|
if (typeof value !== "object" || value === null) return null;
|
|
99825
100089
|
const { path: path2, reason: reason4, original_digest } = value;
|
|
99826
|
-
if (typeof path2 !== "string" || !
|
|
100090
|
+
if (typeof path2 !== "string" || !isWithheldMemberPath(path2) || typeof reason4 !== "string" || reason4 === "" || !isDigest(original_digest))
|
|
99827
100091
|
return null;
|
|
99828
100092
|
return { path: path2, reason: reason4, original_digest };
|
|
99829
100093
|
}
|
|
@@ -100127,6 +100391,11 @@ function safeDigestJcs(value) {
|
|
|
100127
100391
|
return null;
|
|
100128
100392
|
}
|
|
100129
100393
|
}
|
|
100394
|
+
function frameKindOf(frame2) {
|
|
100395
|
+
const event = asRecord2(frame2["event"]);
|
|
100396
|
+
const kind = event === null ? frame2["kind"] : event["kind"];
|
|
100397
|
+
return typeof kind === "string" ? kind : "";
|
|
100398
|
+
}
|
|
100130
100399
|
function checkWrappedFrame(frame2, attemptId) {
|
|
100131
100400
|
const reasons = [];
|
|
100132
100401
|
const shown3 = withheldOf(frame2["server_withheld"]);
|
|
@@ -100135,6 +100404,11 @@ function checkWrappedFrame(frame2, attemptId) {
|
|
|
100135
100404
|
"server_withheld is not a record of what the control plane withheld"
|
|
100136
100405
|
);
|
|
100137
100406
|
const withheld = shown3 === "malformed" ? null : shown3;
|
|
100407
|
+
const kind = frameKindOf(frame2);
|
|
100408
|
+
if (withheld !== null && !withheld.withheld.every(({ path: path2 }) => isWithheldMemberPath(path2, kind)))
|
|
100409
|
+
reasons.push(
|
|
100410
|
+
"server_withheld names a body member the control plane withholds only from an oxagen:reasoning event"
|
|
100411
|
+
);
|
|
100138
100412
|
if (frame2["event"] === void 0 || frame2["event"] === null) {
|
|
100139
100413
|
return { digest: reasons.length > 0 ? "broken" : "not_carried", reasons };
|
|
100140
100414
|
}
|
|
@@ -100599,7 +100873,7 @@ function verifyRunExport(files2) {
|
|
|
100599
100873
|
redactions
|
|
100600
100874
|
};
|
|
100601
100875
|
}
|
|
100602
|
-
var RUN_EXPORT_FORMAT, FORMAT_1, FORMAT_3, FORMAT_4, ACCEPTED_FORMATS, RUN_EXPORT_REDACTIONS_FORMAT, GENESIS_PREV_HASH2, EMPTY_EVENT_STREAM_DIGEST, DIGEST2, WITHHELD_BODY, WITHHELD_ENCRYPTED_PAYLOAD, WITHHELD_BODY_MEMBER;
|
|
100876
|
+
var RUN_EXPORT_FORMAT, FORMAT_1, FORMAT_3, FORMAT_4, FORMAT_5, ACCEPTED_FORMATS, RUN_EXPORT_REDACTIONS_FORMAT, GENESIS_PREV_HASH2, EMPTY_EVENT_STREAM_DIGEST, DIGEST2, WITHHELD_BODY, WITHHELD_ENCRYPTED_PAYLOAD, WITHHELD_BODY_MEMBER;
|
|
100603
100877
|
var init_run_export = __esm({
|
|
100604
100878
|
"../../packages/tacho/src/evidence/run-export.ts"() {
|
|
100605
100879
|
"use strict";
|
|
@@ -100607,18 +100881,21 @@ var init_run_export = __esm({
|
|
|
100607
100881
|
init_context();
|
|
100608
100882
|
init_digest();
|
|
100609
100883
|
init_key_id();
|
|
100884
|
+
init_retention_members();
|
|
100610
100885
|
init_server_withheld();
|
|
100611
100886
|
init_attestation();
|
|
100612
100887
|
init_merkle();
|
|
100613
|
-
RUN_EXPORT_FORMAT = "oxagen.run-export/
|
|
100888
|
+
RUN_EXPORT_FORMAT = "oxagen.run-export/6";
|
|
100614
100889
|
FORMAT_1 = "oxagen.run-export/1";
|
|
100615
100890
|
FORMAT_3 = "oxagen.run-export/3";
|
|
100616
100891
|
FORMAT_4 = "oxagen.run-export/4";
|
|
100892
|
+
FORMAT_5 = "oxagen.run-export/5";
|
|
100617
100893
|
ACCEPTED_FORMATS = /* @__PURE__ */ new Set([
|
|
100618
100894
|
FORMAT_1,
|
|
100619
100895
|
"oxagen.run-export/2",
|
|
100620
100896
|
FORMAT_3,
|
|
100621
100897
|
FORMAT_4,
|
|
100898
|
+
FORMAT_5,
|
|
100622
100899
|
RUN_EXPORT_FORMAT
|
|
100623
100900
|
]);
|
|
100624
100901
|
RUN_EXPORT_REDACTIONS_FORMAT = "oxagen.run-export.redactions/1";
|