@kodax-ai/kodax 0.7.42 → 0.7.43
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/CHANGELOG.md +34 -6
- package/README.md +87 -56
- package/README_CN.md +46 -25
- package/dist/chunks/chunk-7G5PSL6C.js +830 -0
- package/dist/chunks/{chunk-IYJ5EPRV.js → chunk-IYSK7LUK.js} +1 -1
- package/dist/chunks/chunk-K75O2CAE.js +31 -0
- package/dist/chunks/chunk-UG4262JI.js +502 -0
- package/dist/chunks/chunk-VHKAJDQD.js +425 -0
- package/dist/chunks/chunk-YMRZBS4G.js +2 -0
- package/dist/chunks/compaction-config-3E57ABCT.js +2 -0
- package/dist/chunks/{construction-bootstrap-J2WOCYEK.js → construction-bootstrap-JR63KI5N.js} +4 -4
- package/dist/chunks/dist-KWHUKXEL.js +2 -0
- package/dist/chunks/dist-XANXEVTU.js +2 -0
- package/dist/chunks/utils-HQ2QCKJA.js +2 -0
- package/dist/index.d.ts +10 -10
- package/dist/index.js +2 -2
- package/dist/kodax_cli.js +1124 -1102
- package/dist/sdk-agent.d.ts +850 -48
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-coding.d.ts +701 -815
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-llm.d.ts +5 -3
- package/dist/sdk-llm.js +1 -1
- package/dist/sdk-mcp.d.ts +1 -1
- package/dist/sdk-mcp.js +1 -1
- package/dist/sdk-repl.d.ts +9 -8
- package/dist/sdk-repl.js +1 -1
- package/dist/sdk-session.d.ts +22 -10
- package/dist/sdk-session.js +1 -1
- package/dist/sdk-skills.js +1 -1
- package/dist/types-chunks/{cost-tracker.d-B6vMoLLF.d.ts → base.d-FUJahC0i.d.ts} +2 -110
- package/dist/types-chunks/{bash-prefix-extractor.d-CkhaqKkg.d.ts → bash-prefix-extractor.d-DMrGImMl.d.ts} +35 -136
- package/dist/types-chunks/cost-tracker.d-wRtyEW9d.d.ts +110 -0
- package/dist/types-chunks/{history-cleanup.d-DznrzEiU.d.ts → file-tracker.d-zaLZeNBK.d.ts} +314 -6
- package/dist/types-chunks/manager.d-87belpiS.d.ts +370 -0
- package/dist/types-chunks/{resolver.d-DX9au4NJ.d.ts → resolver.d-CA68_NeH.d.ts} +149 -5
- package/dist/types-chunks/{session-storage.d-Cci897iM.d.ts → storage.d-DPAEX7zS.d.ts} +49 -2
- package/dist/types-chunks/{instance-discovery.d-BsKnIwpg.d.ts → types.d-CKJtjo-6.d.ts} +139 -2
- package/dist/types-chunks/{storage.d-Bc5DoAwp.d.ts → utils.d-DkLZD_wa.d.ts} +24 -46
- package/package.json +7 -6
- package/dist/chunks/chunk-3RKBXWZS.js +0 -2
- package/dist/chunks/chunk-7JLYVWAF.js +0 -1033
- package/dist/chunks/chunk-CD3R5YBH.js +0 -16
- package/dist/chunks/chunk-DKXUY5F2.js +0 -209
- package/dist/chunks/chunk-HMYEQJGT.js +0 -31
- package/dist/chunks/chunk-KUX5LRPP.js +0 -2
- package/dist/chunks/chunk-OWSKU55I.js +0 -13
- package/dist/chunks/chunk-ZZ4KRK2B.js +0 -465
- package/dist/chunks/compaction-config-FIFFP4FT.js +0 -2
- package/dist/chunks/dist-2ZHWDXMQ.js +0 -2
- package/dist/chunks/dist-W4CJWLIH.js +0 -2
- package/dist/chunks/utils-A5MWDTWZ.js +0 -2
- package/dist/types-chunks/transport.d-DuyjG30t.d.ts +0 -180
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { m as KodaXMessage } from './types.d-B1uGoVTE.js';
|
|
2
|
-
import { a as AgentMessage,
|
|
2
|
+
import { a as AgentMessage, V as SpanData, U as Span, W as SpanError, A as Agent, J as RunnerLlmReturn, o as Guardrail, N as RunnerToolObserver, h as CompactionDetails, n as FileOperations } from './types.d-CKJtjo-6.js';
|
|
3
|
+
import { o as KodaXSessionLineage, f as KodaXJsonValue, a as KodaXCompactMemorySeed, l as KodaXSessionEntry, v as KodaXSessionTreeNode, n as KodaXSessionLabelEntry, r as KodaXSessionNavigationOptions, h as KodaXSessionArtifactLedgerEntry } from './types.d-mM8vqvhT.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* @kodax-ai/agent Constants
|
|
@@ -42,7 +43,7 @@ declare function countTokens(text: string): number;
|
|
|
42
43
|
* Layer A Primitive: Session / SessionEntry / MessageEntry / SessionExtension
|
|
43
44
|
*
|
|
44
45
|
* FEATURE_081 (v0.7.23): Base Session shape. The thick
|
|
45
|
-
* `KodaXSessionLineage` lives in
|
|
46
|
+
* `KodaXSessionLineage` lives in `../session-lineage/index.js` and is re-expressed
|
|
46
47
|
* as a `LineageExtension` over this base.
|
|
47
48
|
*
|
|
48
49
|
* History: extracted to `@kodax-ai/core` in FEATURE_082 (v0.7.24); merged back
|
|
@@ -141,7 +142,7 @@ interface InMemorySessionOptions {
|
|
|
141
142
|
/**
|
|
142
143
|
* In-memory Session suitable for tests, examples, and embedded SDK use. Not
|
|
143
144
|
* durable across process restarts — persistence is provided by coding-specific
|
|
144
|
-
* adapters in
|
|
145
|
+
* adapters in `../session-lineage/index.js` and `@kodax-ai/agent`.
|
|
145
146
|
*/
|
|
146
147
|
declare function createInMemorySession(opts?: InMemorySessionOptions): Session;
|
|
147
148
|
|
|
@@ -154,7 +155,7 @@ declare function createInMemorySession(opts?: InMemorySessionOptions): Session;
|
|
|
154
155
|
* - Layer A (here): `CompactionPolicy` interface + `DefaultSummaryCompaction`
|
|
155
156
|
* — a minimal "token threshold → LLM summary of old messages" policy that
|
|
156
157
|
* any external Agent can pick up with zero KodaX runtime dependency.
|
|
157
|
-
* - Layer B (
|
|
158
|
+
* - Layer B (`../session-lineage/index.js/src/lineage.ts`): `LineageCompaction`
|
|
158
159
|
* wraps the full FEATURE_072 lineage-native compaction for the coding
|
|
159
160
|
* preset.
|
|
160
161
|
*
|
|
@@ -300,6 +301,12 @@ interface TraceOptions {
|
|
|
300
301
|
readonly onSpanEnd?: (span: Span) => void;
|
|
301
302
|
readonly onTraceEnd?: (trace: Trace) => void;
|
|
302
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* In-memory Trace implementation. External consumers can replace this with
|
|
306
|
+
* an adapter (OpenTelemetry Trace, Langfuse trace) by registering their own
|
|
307
|
+
* `TracingProcessor`.
|
|
308
|
+
*/
|
|
309
|
+
declare function createTrace(opts?: TraceOptions): Trace;
|
|
303
310
|
|
|
304
311
|
/**
|
|
305
312
|
* Tracer — convenience façade that creates Traces wired to the registered
|
|
@@ -333,6 +340,8 @@ declare class Tracer {
|
|
|
333
340
|
constructor(options?: TracerOptions);
|
|
334
341
|
startTrace(opts?: StartTraceOptions): Trace;
|
|
335
342
|
}
|
|
343
|
+
/** Default tracer shared by the KodaX runtime. External callers can create their own. */
|
|
344
|
+
declare const defaultTracer: Tracer;
|
|
336
345
|
|
|
337
346
|
/**
|
|
338
347
|
* Layer A Primitive: Quality Invariant + Admission Contract types.
|
|
@@ -1471,5 +1480,304 @@ declare function validateAndFixToolHistory(messages: KodaXMessage[]): KodaXMessa
|
|
|
1471
1480
|
*/
|
|
1472
1481
|
declare function cleanupIncompleteToolCalls(messages: KodaXMessage[]): KodaXMessage[];
|
|
1473
1482
|
|
|
1474
|
-
|
|
1475
|
-
|
|
1483
|
+
/**
|
|
1484
|
+
* LineageExtension — SessionExtension façade over lineage semantics.
|
|
1485
|
+
*
|
|
1486
|
+
* FEATURE_081 (v0.7.23): expresses today's `KodaXSessionLineage` operations
|
|
1487
|
+
* (label, rewind, compaction ledger, branch summary) as a
|
|
1488
|
+
* `SessionExtension` over the base `Session` primitive.
|
|
1489
|
+
*
|
|
1490
|
+
* FEATURE_082 (v0.7.24): moved from `@kodax-ai/coding/src/extensions/lineage.ts`
|
|
1491
|
+
* to this package. Depends on `../index.js` for `Session` / `SessionEntry` /
|
|
1492
|
+
* `SessionExtension` (Layer A primitives — extracted to `@kodax-ai/core` in
|
|
1493
|
+
* FEATURE_082, merged back into `../index.js` in v0.7.35.1 FEATURE_142).
|
|
1494
|
+
* `@kodax-ai/coding` keeps a barrel re-export.
|
|
1495
|
+
*
|
|
1496
|
+
* Scope:
|
|
1497
|
+
* - Declare the extension object.
|
|
1498
|
+
* - Implement `label` and `attachArtifact` operators that append standard
|
|
1499
|
+
* entries to a Session.
|
|
1500
|
+
* - Implement a `buildLineageTree` reducer that projects an entry stream
|
|
1501
|
+
* back to a navigable tree.
|
|
1502
|
+
* - NOT re-implemented here: `branch`, `rewind`, full compaction. Those
|
|
1503
|
+
* stay in `../index.js/session-lineage.ts` for coding-preset use; the
|
|
1504
|
+
* `LineageCompaction` policy in this package is the thin wrapper that
|
|
1505
|
+
* adapts them to the Layer A `CompactionPolicy` contract.
|
|
1506
|
+
*/
|
|
1507
|
+
|
|
1508
|
+
/**
|
|
1509
|
+
* Entry types claimed by `LineageExtension`. Mirrors the legacy
|
|
1510
|
+
* `KodaXSessionEntry` tagged union plus a `rewind_marker` placeholder (the
|
|
1511
|
+
* legacy lineage records rewinds via `activeEntryId` mutation; Session is
|
|
1512
|
+
* linear, so a marker entry is the equivalent).
|
|
1513
|
+
*/
|
|
1514
|
+
declare const LINEAGE_ENTRY_TYPES: readonly ["message", "label", "compaction", "branch_summary", "archive_marker", "rewind_marker", "artifact_ledger"];
|
|
1515
|
+
type LineageEntryType = (typeof LINEAGE_ENTRY_TYPES)[number];
|
|
1516
|
+
/**
|
|
1517
|
+
* Payload shape for a `label` entry. Mirrors
|
|
1518
|
+
* `KodaXSessionLabelEntry.targetId`/`label` fields on the legacy lineage.
|
|
1519
|
+
*/
|
|
1520
|
+
interface LineageLabelPayload {
|
|
1521
|
+
readonly targetId: string;
|
|
1522
|
+
readonly label?: string;
|
|
1523
|
+
}
|
|
1524
|
+
/**
|
|
1525
|
+
* Payload shape for an `artifact_ledger` entry. Mirrors a minimal subset of
|
|
1526
|
+
* `KodaXSessionArtifactLedgerEntry`; full semantic fidelity is kept on the
|
|
1527
|
+
* legacy side for now and normalised in FEATURE_082.
|
|
1528
|
+
*/
|
|
1529
|
+
interface LineageArtifactLedgerPayload {
|
|
1530
|
+
readonly ref: string;
|
|
1531
|
+
readonly kind?: string;
|
|
1532
|
+
readonly summary?: string;
|
|
1533
|
+
}
|
|
1534
|
+
/**
|
|
1535
|
+
* Projected tree node. Mirrors the navigation shape of
|
|
1536
|
+
* `KodaXSessionTreeNode` from `../index.js/types.ts`, restricted to the
|
|
1537
|
+
* fields the base Session can supply.
|
|
1538
|
+
*/
|
|
1539
|
+
interface LineageTreeNode {
|
|
1540
|
+
readonly entry: SessionEntry;
|
|
1541
|
+
readonly children: LineageTreeNode[];
|
|
1542
|
+
readonly label?: string;
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* The exported extension. Operators write standard-shaped entries; the
|
|
1546
|
+
* reducer projects an entry stream back to a navigable tree.
|
|
1547
|
+
*
|
|
1548
|
+
* Immutability: top-level object, `operators`, and `reducers` are all
|
|
1549
|
+
* frozen. Freezes are shallow — the functions stored inside `operators`
|
|
1550
|
+
* and `reducers` are immutable by nature (closures reference only
|
|
1551
|
+
* module-private state). External code must not mutate the extension;
|
|
1552
|
+
* doing so is a programmer error that the type-level `readonly` already
|
|
1553
|
+
* disallows without a cast.
|
|
1554
|
+
*/
|
|
1555
|
+
declare const LineageExtension: SessionExtension;
|
|
1556
|
+
|
|
1557
|
+
/**
|
|
1558
|
+
* LineageCompaction — `CompactionPolicy` adapter for the coding preset's
|
|
1559
|
+
* FEATURE_072 lineage-native compaction runtime.
|
|
1560
|
+
*
|
|
1561
|
+
* FEATURE_082 (v0.7.24): introduced alongside the lineage extraction so the
|
|
1562
|
+
* coding preset can implement `CompactionPolicy` without re-implementing the
|
|
1563
|
+
* compaction loop. The actual compaction runtime (microcompaction, post-
|
|
1564
|
+
* compact reconstruction, summary generation) stays in
|
|
1565
|
+
* `../index.js/src/compaction/` until FEATURE_084 (v0.7.26) consolidates it.
|
|
1566
|
+
*
|
|
1567
|
+
* Usage (inside @kodax-ai/coding):
|
|
1568
|
+
*
|
|
1569
|
+
* const policy = new LineageCompaction({
|
|
1570
|
+
* shouldCompact: (session, used, budget) => runFeature072Heuristic(used, budget),
|
|
1571
|
+
* compact: async (session, ctx) => runFeature072Compaction(session, ctx),
|
|
1572
|
+
* });
|
|
1573
|
+
*
|
|
1574
|
+
* The injected delegates keep this package free of coding-specific imports,
|
|
1575
|
+
* preserving the dependency direction
|
|
1576
|
+
* `@kodax-ai/coding -> @kodax-ai/session-lineage -> ../index.js`.
|
|
1577
|
+
*/
|
|
1578
|
+
|
|
1579
|
+
/**
|
|
1580
|
+
* Delegates required to implement `LineageCompaction`. The coding preset
|
|
1581
|
+
* supplies implementations that bridge to the existing FEATURE_072 code
|
|
1582
|
+
* paths.
|
|
1583
|
+
*/
|
|
1584
|
+
interface LineageCompactionDelegates {
|
|
1585
|
+
readonly shouldCompact: (session: Session, tokensUsed: number, budget: number) => boolean;
|
|
1586
|
+
readonly compact: (session: Session, ctx: CompactionContext) => Promise<PolicyCompactionResult>;
|
|
1587
|
+
readonly restore?: (session: Session, hint: unknown) => Promise<void>;
|
|
1588
|
+
}
|
|
1589
|
+
/**
|
|
1590
|
+
* `CompactionPolicy` implementation that preserves FEATURE_072 lineage-native
|
|
1591
|
+
* compaction semantics by delegating to injected coding-preset functions.
|
|
1592
|
+
*/
|
|
1593
|
+
declare class LineageCompaction implements CompactionPolicy {
|
|
1594
|
+
readonly name = "lineage-compaction";
|
|
1595
|
+
private readonly delegates;
|
|
1596
|
+
constructor(delegates: LineageCompactionDelegates);
|
|
1597
|
+
shouldCompact(session: Session, tokensUsed: number, budget: number): boolean;
|
|
1598
|
+
compact(session: Session, ctx: CompactionContext): Promise<PolicyCompactionResult>;
|
|
1599
|
+
restore(session: Session, hint: unknown): Promise<void>;
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
/**
|
|
1603
|
+
* ../index.js Session
|
|
1604
|
+
*
|
|
1605
|
+
* 会话管理 - Session ID 生成和消息处理
|
|
1606
|
+
*/
|
|
1607
|
+
|
|
1608
|
+
/**
|
|
1609
|
+
* 生成会话 ID
|
|
1610
|
+
* 格式: YYYYMMDD_HHMMSS
|
|
1611
|
+
*/
|
|
1612
|
+
declare function generateSessionId(): Promise<string>;
|
|
1613
|
+
/**
|
|
1614
|
+
* 从消息中提取标题
|
|
1615
|
+
* 取第一条用户消息的前50个字符
|
|
1616
|
+
*/
|
|
1617
|
+
declare function extractTitleFromMessages(messages: KodaXMessage[]): string;
|
|
1618
|
+
|
|
1619
|
+
type NavigableSessionEntry = Exclude<KodaXSessionEntry, KodaXSessionLabelEntry>;
|
|
1620
|
+
/**
|
|
1621
|
+
* Reconcile a linear message list against an existing lineage tree.
|
|
1622
|
+
*
|
|
1623
|
+
* Existing matching entries are reused when possible, and only the missing
|
|
1624
|
+
* tail is appended as new message entries.
|
|
1625
|
+
*/
|
|
1626
|
+
declare function createSessionLineage(messages: KodaXMessage[], previous?: KodaXSessionLineage): KodaXSessionLineage;
|
|
1627
|
+
/**
|
|
1628
|
+
* Walk the lineage from a target entry back to the root.
|
|
1629
|
+
*
|
|
1630
|
+
* Traversal stops safely if malformed data introduces a parent cycle.
|
|
1631
|
+
*/
|
|
1632
|
+
declare function getSessionLineagePath(lineage: KodaXSessionLineage, targetId?: string | null): NavigableSessionEntry[];
|
|
1633
|
+
/**
|
|
1634
|
+
* Build the effective LLM-visible message context for the active lineage path.
|
|
1635
|
+
*
|
|
1636
|
+
* FEATURE_072: for non-rewind compaction entries that carry
|
|
1637
|
+
* `postCompactAttachments`, the slicer inlines attachments immediately after
|
|
1638
|
+
* the summary. `getContextMessagesForEntry` stays 1-to-1 — attachments are a
|
|
1639
|
+
* slicer-layer concern, which preserves the contract
|
|
1640
|
+
* `entryMatchesContextMessage` and FEATURE_073's future firstKeptEntryId-based
|
|
1641
|
+
* slicing both depend on.
|
|
1642
|
+
*/
|
|
1643
|
+
declare function getSessionMessagesFromLineage(lineage: KodaXSessionLineage, targetId?: string | null): KodaXMessage[];
|
|
1644
|
+
/**
|
|
1645
|
+
* Resolve an entry selector using either a direct entry id or the latest label.
|
|
1646
|
+
*/
|
|
1647
|
+
declare function resolveSessionLineageTarget(lineage: KodaXSessionLineage, selector: string): NavigableSessionEntry | undefined;
|
|
1648
|
+
/**
|
|
1649
|
+
* Move the active leaf to a selected target, optionally appending a
|
|
1650
|
+
* branch-summary node that captures the abandoned path.
|
|
1651
|
+
*/
|
|
1652
|
+
declare function setSessionLineageActiveEntry(lineage: KodaXSessionLineage, selector: string, options?: KodaXSessionNavigationOptions): KodaXSessionLineage | null;
|
|
1653
|
+
/**
|
|
1654
|
+
* Append a label change entry that bookmarks a lineage node.
|
|
1655
|
+
*/
|
|
1656
|
+
declare function appendSessionLineageLabel(lineage: KodaXSessionLineage, selector: string, label?: string): KodaXSessionLineage | null;
|
|
1657
|
+
/**
|
|
1658
|
+
* Apply a compaction event to the lineage.
|
|
1659
|
+
*
|
|
1660
|
+
* FEATURE_072 signature change: `keptMessages` (the post-summary tail that
|
|
1661
|
+
* will become lineage entries) and `postCompactAttachments` (ledger +
|
|
1662
|
+
* file-content messages that live on the CompactionEntry itself) are now
|
|
1663
|
+
* separate parameters. The kept tail MUST NOT include attachments — otherwise
|
|
1664
|
+
* they would be double-stored (once as message entries in lineage, once on
|
|
1665
|
+
* the compaction entry). Phase A keeps `postCompactAttachments` optional so
|
|
1666
|
+
* current callers that pass `[]` (or omit it) behave identically to today.
|
|
1667
|
+
* Phase B migrates callers to supply real attachments.
|
|
1668
|
+
*/
|
|
1669
|
+
declare function applySessionCompaction(lineage: KodaXSessionLineage | undefined, compactedMessages: KodaXMessage[], anchor: {
|
|
1670
|
+
summary: string;
|
|
1671
|
+
tokensBefore?: number;
|
|
1672
|
+
tokensAfter?: number;
|
|
1673
|
+
artifactLedgerId?: string;
|
|
1674
|
+
reason?: string;
|
|
1675
|
+
details?: KodaXJsonValue | CompactionDetails;
|
|
1676
|
+
memorySeed?: KodaXCompactMemorySeed;
|
|
1677
|
+
}, postCompactAttachments?: readonly KodaXMessage[]): KodaXSessionLineage;
|
|
1678
|
+
/**
|
|
1679
|
+
* FEATURE_072 §7a: reconcile lineage after graceful-degradation trimming.
|
|
1680
|
+
*
|
|
1681
|
+
* Unlike `applySessionCompaction` (which creates a new island with a summary
|
|
1682
|
+
* CompactionEntry), graceful degradation is atomic-block trimming — no LLM
|
|
1683
|
+
* summary, no ledger re-injection. Routing it through `applySessionCompaction`
|
|
1684
|
+
* would produce a degenerate CompactionEntry with `summary: ''` that pollutes
|
|
1685
|
+
* the lineage view and session-tree UI.
|
|
1686
|
+
*
|
|
1687
|
+
* Instead, `applyLineageTruncation` reconciles the lineage against the trimmed
|
|
1688
|
+
* flat messages via `createSessionLineage`, which will:
|
|
1689
|
+
* - Match surviving messages to existing entries (reference or fingerprint)
|
|
1690
|
+
* - Drop unmatched entries from the active path
|
|
1691
|
+
* Fingerprint lookup handles the "trimmed tool_result content changed" case:
|
|
1692
|
+
* the trimmed message gets a new entry id under the same parent chain.
|
|
1693
|
+
*
|
|
1694
|
+
* This is distinct from `applySessionCompaction`: no new CompactionEntry is
|
|
1695
|
+
* appended, no summary is written, no island root is created. The lineage
|
|
1696
|
+
* stays on the same island; only the tail shape changes.
|
|
1697
|
+
*
|
|
1698
|
+
* Reserved for a future caller (v0.7.20 Phase C / v0.7.25 FEATURE_073). Phase B
|
|
1699
|
+
* defines the helper; no production caller yet.
|
|
1700
|
+
*/
|
|
1701
|
+
declare function applyLineageTruncation(lineage: KodaXSessionLineage | undefined, trimmedMessages: KodaXMessage[]): KodaXSessionLineage;
|
|
1702
|
+
/**
|
|
1703
|
+
* Rewind the current session lineage to a target entry, truncating all entries after it.
|
|
1704
|
+
* Records a rewind event in the lineage for auditability.
|
|
1705
|
+
* Returns null if targetEntryId is not found.
|
|
1706
|
+
*
|
|
1707
|
+
* @param lineage - The session lineage to rewind
|
|
1708
|
+
* @param targetEntryId - The entry ID to rewind to (inclusive)
|
|
1709
|
+
* @returns A new lineage with entries truncated after the target, or null if target not found
|
|
1710
|
+
*/
|
|
1711
|
+
/**
|
|
1712
|
+
* Find the entry ID of the second-to-last user message in the lineage.
|
|
1713
|
+
* Used by `/rewind` (no argument) to go back one conversational turn.
|
|
1714
|
+
* Returns null if fewer than 2 user messages exist.
|
|
1715
|
+
*/
|
|
1716
|
+
declare function findPreviousUserEntryId(lineage: KodaXSessionLineage): string | null;
|
|
1717
|
+
declare function rewindSessionLineage(lineage: KodaXSessionLineage, targetEntryId: string): KodaXSessionLineage | null;
|
|
1718
|
+
declare function forkSessionLineage(lineage: KodaXSessionLineage, selector?: string): KodaXSessionLineage | null;
|
|
1719
|
+
/**
|
|
1720
|
+
* Convert a lineage into a nested tree structure for UI presentation.
|
|
1721
|
+
*/
|
|
1722
|
+
declare function buildSessionTree(lineage: KodaXSessionLineage): KodaXSessionTreeNode[];
|
|
1723
|
+
/**
|
|
1724
|
+
* Count the effective context messages on the active lineage path.
|
|
1725
|
+
*/
|
|
1726
|
+
declare function countActiveLineageMessages(lineage: KodaXSessionLineage): number;
|
|
1727
|
+
/**
|
|
1728
|
+
* Archive message entries from old "islands" (disconnected subtrees).
|
|
1729
|
+
*
|
|
1730
|
+
* Each compaction entry has parentId: null, creating an independent island.
|
|
1731
|
+
* The active leaf lives in one island (the "current" island). All other
|
|
1732
|
+
* islands are considered "old" and eligible for archival.
|
|
1733
|
+
*
|
|
1734
|
+
* A "preserve closure" is computed first:
|
|
1735
|
+
* - All entries in the current island (active path + recent branches)
|
|
1736
|
+
* - Label targets and their ancestor chains
|
|
1737
|
+
* - Non-message entries and their ancestor chains (prevents tree drift)
|
|
1738
|
+
*
|
|
1739
|
+
* Only entries outside the preserve closure are archived.
|
|
1740
|
+
*/
|
|
1741
|
+
declare function archiveOldIslands(lineage: KodaXSessionLineage): {
|
|
1742
|
+
slimmedLineage: KodaXSessionLineage;
|
|
1743
|
+
archivedEntries: KodaXSessionEntry[];
|
|
1744
|
+
archivedCount: number;
|
|
1745
|
+
archiveBatchId: string;
|
|
1746
|
+
};
|
|
1747
|
+
|
|
1748
|
+
/**
|
|
1749
|
+
* ../../index.js File Tracking — artifactLedger extraction.
|
|
1750
|
+
*
|
|
1751
|
+
* FEATURE_185 (v0.7.42) extends the previous input-only extractor to also
|
|
1752
|
+
* read each tool_use's matching tool_result, enriching `metadata` with parsed
|
|
1753
|
+
* hits / matchedPaths / exitCode / tail. Pipeline:
|
|
1754
|
+
*
|
|
1755
|
+
* Round end (REPL: repl.ts:1279/1371)
|
|
1756
|
+
* → extractArtifactLedger(result.messages)
|
|
1757
|
+
* → tool_result still raw (top-of-loop microcompact hasn't run on these)
|
|
1758
|
+
* → buildArtifactEntry parses result content into metadata
|
|
1759
|
+
* → mergeArtifactLedger commits enrichment to context.artifactLedger
|
|
1760
|
+
* → storage.save persists the enriched ledger
|
|
1761
|
+
*
|
|
1762
|
+
* Top-of-loop microcompact (run-substrate.ts:621, iteration N+1)
|
|
1763
|
+
* → clears tool_result.content older than maxAge to `[Cleared: ...]`
|
|
1764
|
+
*
|
|
1765
|
+
* Compaction time (compaction.ts:257)
|
|
1766
|
+
* → extractArtifactLedger(toProcess) re-runs on cleared messages
|
|
1767
|
+
* → buildArtifactEntry's parsers refuse `[Cleared: ...]` → no fresh hits
|
|
1768
|
+
* → mergeArtifactLedger preserves the round-end enrichment via
|
|
1769
|
+
* per-key non-empty preference (see `mergeLedgerMetadata`).
|
|
1770
|
+
*
|
|
1771
|
+
* The metadata-aware merge is the keystone — without it, every compaction
|
|
1772
|
+
* would silently downgrade ledger entries to input-only. End-to-end
|
|
1773
|
+
* preservation is exercised by the "end-to-end enrichment survives
|
|
1774
|
+
* microcompact" tests in file-tracker.test.ts.
|
|
1775
|
+
*/
|
|
1776
|
+
|
|
1777
|
+
declare function extractFileOps(messages: KodaXMessage[]): FileOperations;
|
|
1778
|
+
declare function mergeFileOps(ops1: FileOperations, ops2: FileOperations): FileOperations;
|
|
1779
|
+
declare function extractArtifactLedger(messages: KodaXMessage[]): KodaXSessionArtifactLedgerEntry[];
|
|
1780
|
+
declare function mergeArtifactLedger(existing: KodaXSessionArtifactLedgerEntry[], next: KodaXSessionArtifactLedgerEntry[]): KodaXSessionArtifactLedgerEntry[];
|
|
1781
|
+
|
|
1782
|
+
export { DEFAULT_SYSTEM_CAP as D, KODAX_API_MIN_INTERVAL as K, LINEAGE_ENTRY_TYPES as L, PROMISE_PATTERN as P, Runner as V, generateSessionId as aA, getAdmittedAgentBindings as aB, getAgentConfigHome as aC, getAgentConfigPath as aD, getAppDataDir as aE, getSessionLineagePath as aF, getSessionMessagesFromLineage as aG, mergeArtifactLedger as aH, mergeFileOps as aI, registerPresetDispatcher as aJ, resolveSessionLineageTarget as aK, rewindSessionLineage as aL, runAdmissionAudit as aM, setAdmittedAgentBindings as aN, setAgentConfigHome as aO, setSessionLineageActiveEntry as aP, validateAndFixToolHistory as aQ, Tracer as aa, _resetAdmittedAgentBindings as ac, _resetPresetDispatchers as ad, appendSessionLineageLabel as ae, applyLineageTruncation as af, applySessionCompaction as ag, archiveOldIslands as ah, buildSessionTree as ai, buildSystemPrompt as aj, cleanupIncompleteToolCalls as ak, countActiveLineageMessages as al, countTokens as am, createInMemorySession as an, createInvariantSessionForAgent as ao, createSessionLineage as ap, createTrace as aq, defaultTracer as ar, detectInstructionsInjection as as, estimateTokens as at, extractArtifactLedger as au, extractAssistantTextFromMessage as av, extractFileOps as aw, extractTitleFromMessages as ax, findPreviousUserEntryId as ay, forkSessionLineage as az, DefaultSummaryCompaction as h, InvariantSession as m, KODAX_DEFAULT_TIMEOUT as n, KODAX_HARD_TIMEOUT as o, KODAX_MAX_INCOMPLETE_RETRIES as p, KODAX_MAX_MAXTOKENS_RETRIES as q, KODAX_MAX_RETRIES as r, KODAX_MAX_TOKENS as s, KODAX_RETRY_BASE_DELAY as t, KODAX_STAGGER_DELAY as u, LineageCompaction as w, LineageExtension as z };
|
|
1783
|
+
export type { SessionForkOptions as $, AdmissionAuditOptions as A, LineageLabelPayload as B, CompactionContext as C, LineageTreeNode as E, MessageEntry as F, PolicyCompactionResult as G, PresetDispatcher as H, InMemorySessionOptions as I, PresetTracingContext as J, ManifestPatch as M, ReadonlyRecorder as N, ObserveCtx as O, QualityInvariant as Q, ReadonlyMutationTracker as R, RunEvent as S, RunOptions as T, RunResult as U, RunnerEvent as W, Session as X, SessionDispatchResult as Y, SessionEntry as Z, SessionExtension as _, AdmissionCtx as a, StartTraceOptions as a0, StopHookContext as a1, StopHookFn as a2, StopHookResult as a3, SystemCap as a4, TerminalCtx as a5, ToolCapability as a6, ToolPermission as a7, Trace as a8, TraceOptions as a9, TracerOptions as ab, AdmissionVerdict as b, AdmittedHandle as c, AgentManifest as d, CompactionEntry as e, CompactionEntryPayload as f, CompactionPolicy as g, DefaultSummaryCompactionOptions as i, Deliverable as j, InvariantId as k, InvariantResult as l, LineageArtifactLedgerPayload as v, LineageCompactionDelegates as x, LineageEntryType as y };
|