@kodax-ai/kodax 0.7.57 → 0.7.59
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 +2032 -1920
- package/README.md +1228 -1219
- package/README_CN.md +647 -638
- package/dist/chunks/agent-QQCRBU4C.js +2 -0
- package/dist/chunks/argument-completer-7Q2T4YWA.js +2 -0
- package/dist/chunks/{chunk-LZKGOR2C.js → chunk-2UUOFT3Z.js} +1 -1
- package/dist/chunks/chunk-5GPJ6MB5.js +405 -0
- package/dist/chunks/chunk-BEXLPFFB.js +7 -0
- package/dist/chunks/chunk-D6QVXQNI.js +1 -0
- package/dist/chunks/chunk-D7RENPQQ.js +322 -0
- package/dist/chunks/chunk-PRIBJN5E.js +683 -0
- package/dist/chunks/chunk-S4GVQO3W.js +31 -0
- package/dist/chunks/chunk-SDSLWDAZ.js +17 -0
- package/dist/chunks/chunk-SVEJFERZ.js +326 -0
- package/dist/chunks/chunk-TBXP7FEG.js +52 -0
- package/dist/chunks/chunk-UA744TZM.js +2 -0
- package/dist/chunks/{chunk-YSVPF6SN.js → chunk-UXQILGRX.js} +262 -259
- package/dist/chunks/{chunk-4SHP3M67.js → chunk-YADBB5GN.js} +1 -1
- package/dist/chunks/chunk-Z23LK3IV.js +310 -0
- package/dist/chunks/chunk-Z3ZXV3DZ.js +18 -0
- package/dist/chunks/compaction-config-GQIPCVFD.js +2 -0
- package/dist/chunks/{construction-bootstrap-55B7Q5RX.js → construction-bootstrap-YON4ZEMO.js} +1 -1
- package/dist/chunks/dist-73L4OYPD.js +2 -0
- package/dist/chunks/dist-EZXBR6NW.js +2 -0
- package/dist/chunks/host-LO6ZNTMV.js +2 -0
- package/dist/chunks/paste-4THGP5XW.js +2 -0
- package/dist/chunks/run-manager-HTLXKU66.js +2 -0
- package/dist/chunks/utils-5XVW33SY.js +2 -0
- package/dist/index.d.ts +15 -14
- package/dist/index.js +2 -2
- package/dist/kodax_cli.js +1222 -1047
- package/dist/provider-capabilities.json +971 -986
- package/dist/sdk-agent.d.ts +156 -14
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-coding.d.ts +253 -188
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-llm.d.ts +66 -43
- package/dist/sdk-llm.js +1 -1
- package/dist/sdk-mcp.js +1 -1
- package/dist/sdk-media.d.ts +18 -2
- package/dist/sdk-media.js +1 -1
- package/dist/sdk-repl.d.ts +21 -22
- package/dist/sdk-repl.js +2 -2
- package/dist/sdk-session.d.ts +8 -7
- package/dist/sdk-session.js +1 -1
- package/dist/sdk-skills.d.ts +4 -231
- package/dist/sdk-skills.js +1 -1
- package/dist/types-chunks/{base.d-BnjQrSVf.d.ts → base.d-BA9Doaj_.d.ts} +3 -3
- package/dist/types-chunks/{bash-prefix-extractor.d-BgvMbfq6.d.ts → bash-prefix-extractor.d-BNdpV4Cf.d.ts} +515 -69
- package/dist/types-chunks/capability-learning.d-DRV80ISB.d.ts +29 -0
- package/dist/types-chunks/{cost-tracker.d-wRtyEW9d.d.ts → cost-tracker.d-CBLk1fiD.d.ts} +24 -2
- package/dist/types-chunks/{guardrail.d-C1DhxnvC.d.ts → guardrail.d-CNdKuSD_.d.ts} +4 -4
- package/dist/types-chunks/{process.d-BZncyzEj.d.ts → process.d-BOrAxjvM.d.ts} +188 -15
- package/dist/types-chunks/{resolver.d-ZvKQgl0X.d.ts → resolver.d-DFAKKUvt.d.ts} +87 -4
- package/dist/types-chunks/{capsule.d-DwJp5r63.d.ts → run-manager.d-CsJC9zYf.d.ts} +113 -5
- package/dist/types-chunks/{sdk-session-DAScB0rW.d.ts → sdk-session-ByZlwgdM.d.ts} +83 -9
- package/dist/types-chunks/{storage.d-CPvn9qI0.d.ts → storage.d-DHL3XpAL.d.ts} +2 -2
- package/dist/types-chunks/{guardrail.d-BP3yyr6u.d.ts → types.d-CE_Ter29.d.ts} +125 -3
- package/dist/types-chunks/{types.d-6VOXvF88.d.ts → types.d-Ci5YPFEh.d.ts} +39 -5
- package/dist/types-chunks/types.d-vJExiRje.d.ts +232 -0
- package/dist/types-chunks/{utils.d-CpgVIjYZ.d.ts → utils.d-D9FHU4wB.d.ts} +84 -6
- package/package.json +2 -2
- package/dist/chunks/agent-EHWQZA4C.js +0 -2
- package/dist/chunks/argument-completer-AYDAYGKL.js +0 -2
- package/dist/chunks/chunk-3WWPJGPQ.js +0 -2
- package/dist/chunks/chunk-KN6IJMTB.js +0 -636
- package/dist/chunks/chunk-MJFPFRGK.js +0 -423
- package/dist/chunks/chunk-N2N2W3AQ.js +0 -584
- package/dist/chunks/chunk-PCPFLPS4.js +0 -5
- package/dist/chunks/chunk-TCLSPUTR.js +0 -31
- package/dist/chunks/chunk-VACH6QWN.js +0 -315
- package/dist/chunks/compaction-config-TLDMFMZO.js +0 -2
- package/dist/chunks/dist-IE4HVWP7.js +0 -2
- package/dist/chunks/dist-IKOK2MJQ.js +0 -2
- package/dist/chunks/paste-WTL2XN7P.js +0 -2
- package/dist/chunks/utils-EJ2VCRTC.js +0 -2
- package/dist/types-chunks/types.d-D8WcfrOD.d.ts +0 -143
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { j as KodaXMessage } from './types.d-
|
|
2
|
-
import { Q as QueueEventListener,
|
|
3
|
-
import {
|
|
1
|
+
import { j as KodaXMessage } from './types.d-Ci5YPFEh.js';
|
|
2
|
+
import { Q as QueueEventListener, f as QueuedMessage, E as EnqueueInput, D as DequeueFilter } from './types.d-CE_Ter29.js';
|
|
3
|
+
import { g as AgentMessage, aU as SessionEntry, aS as Session, aW as SessionExtension, aa as KodaXSessionLineage, a0 as KodaXJsonValue, q as CompactionDetails, P as KodaXCompactMemorySeed, a6 as KodaXSessionEntry, ah as KodaXSessionTreeNode, a9 as KodaXSessionLabelEntry, a8 as KodaXSessionGoalEntry, ad as KodaXSessionNavigationOptions, a2 as KodaXSessionArtifactLedgerEntry, y as FileOperations, bz as WorkflowMeta, bA as WorkflowModelHint, bB as WorkflowModule, bR as WorkflowProcessTrackerOptions, bs as WorkflowEvent, bL as WorkflowProcessSnapshot, bF as WorkflowProcessEvent } from './process.d-BOrAxjvM.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @kodax-ai/agent Constants
|
|
@@ -758,6 +758,13 @@ declare const WORKFLOW_CAPSULE_API_VERSION: 1;
|
|
|
758
758
|
type WorkflowCapsuleEnvironmentRequirement = 'git-repo' | 'worktree-capable';
|
|
759
759
|
interface WorkflowCapsuleIntent {
|
|
760
760
|
readonly taskClass: string;
|
|
761
|
+
/**
|
|
762
|
+
* The full set of workflow patterns the script declares (manifest.patterns).
|
|
763
|
+
* `taskClass` keeps only the primary pattern; this records the whole
|
|
764
|
+
* combination so a declared ['fan-out-and-synthesize', 'adversarial-verification']
|
|
765
|
+
* is preserved rather than collapsed to its first id.
|
|
766
|
+
*/
|
|
767
|
+
readonly patterns?: readonly string[];
|
|
761
768
|
readonly originalRequest?: string;
|
|
762
769
|
readonly reusableFor?: readonly string[];
|
|
763
770
|
readonly notFor?: readonly string[];
|
|
@@ -806,6 +813,107 @@ interface CreateWorkflowCapsuleInput {
|
|
|
806
813
|
declare function validateWorkflowCapsule(value: unknown): WorkflowCapsule;
|
|
807
814
|
declare function createWorkflowCapsule(input: CreateWorkflowCapsuleInput): WorkflowCapsule;
|
|
808
815
|
declare function createWorkflowModuleFromCapsule(capsule: WorkflowCapsule): WorkflowModule;
|
|
816
|
+
/**
|
|
817
|
+
* Single source of truth for deriving a capsule intent from a workflow manifest.
|
|
818
|
+
* `taskClass` keeps the primary pattern; the full declared set is recorded on
|
|
819
|
+
* `patterns` so a combination like ['fan-out-and-synthesize',
|
|
820
|
+
* 'adversarial-verification'] is preserved rather than collapsed to its first id
|
|
821
|
+
* (M15). Used by every capsule-save path so the propagation logic is tested once.
|
|
822
|
+
*/
|
|
823
|
+
declare function buildWorkflowCapsuleIntent(manifest: {
|
|
824
|
+
readonly patterns: readonly string[];
|
|
825
|
+
readonly name: string;
|
|
826
|
+
readonly description: string;
|
|
827
|
+
}, opts?: {
|
|
828
|
+
readonly originalRequest?: string;
|
|
829
|
+
}): WorkflowCapsuleIntent;
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* FEATURE_246 Part A0 (ADR-046) — neutral workflow run lifecycle manager.
|
|
833
|
+
*
|
|
834
|
+
* Domain-neutral run registry + lifecycle (pause / resume / stop), process-event
|
|
835
|
+
* tracking, and terminal settle — lifted out of `@kodax-ai/coding` so any agent
|
|
836
|
+
* (including non-coding SDK hosts) can host and manage workflow runs.
|
|
837
|
+
*
|
|
838
|
+
* It never knows HOW a run executes: the caller injects a `runFn` thunk that
|
|
839
|
+
* receives lifecycle hooks (`onEvent` / `signal` / `beforeSpawn`) and returns a
|
|
840
|
+
* caller-shaped outcome, plus a `classify` mapping that outcome to a neutral
|
|
841
|
+
* terminal status and an `onError` that synthesizes a failure outcome. The
|
|
842
|
+
* coding layer wires `runFn` to its `runWorkflowModule` / `runWorkflowFromOptions`
|
|
843
|
+
* (backend + run-graph + worktrees); SDK hosts wire their own. Dependency arrows
|
|
844
|
+
* therefore point only coding → agent — no cycle.
|
|
845
|
+
*/
|
|
846
|
+
|
|
847
|
+
type ManagedWorkflowStatus = 'running' | 'paused' | 'completed' | 'failed' | 'denied' | 'stopped';
|
|
848
|
+
/** Provenance/display metadata for a run's process tracker. */
|
|
849
|
+
type WorkflowProcessMetadata = Pick<WorkflowProcessTrackerOptions, 'displayName' | 'goal' | 'source' | 'savedWorkflowName' | 'sourceRunId' | 'sourceWorkflowName' | 'revisionOf' | 'resumedFromRunId' | 'hostMetadata'>;
|
|
850
|
+
interface ManagedWorkflowSnapshot {
|
|
851
|
+
readonly runId: string;
|
|
852
|
+
readonly workflow: string;
|
|
853
|
+
readonly status: ManagedWorkflowStatus;
|
|
854
|
+
readonly totalSpawned: number;
|
|
855
|
+
readonly eventCount: number;
|
|
856
|
+
readonly startedAt: number;
|
|
857
|
+
readonly endedAt?: number;
|
|
858
|
+
readonly error?: string;
|
|
859
|
+
readonly resultText?: string;
|
|
860
|
+
}
|
|
861
|
+
interface ManagedWorkflowRun<TOutcome = unknown> {
|
|
862
|
+
readonly runId: string;
|
|
863
|
+
readonly done: Promise<TOutcome>;
|
|
864
|
+
getSnapshot(): ManagedWorkflowSnapshot | undefined;
|
|
865
|
+
getProcessSnapshot(): WorkflowProcessSnapshot | undefined;
|
|
866
|
+
}
|
|
867
|
+
/** Lifecycle hooks the manager injects into the caller's `runFn`. */
|
|
868
|
+
interface ManagedRunHooks {
|
|
869
|
+
/** Forward every workflow event so the manager can track spawn/progress. */
|
|
870
|
+
readonly onEvent: (event: WorkflowEvent) => void;
|
|
871
|
+
/** Abort signal owned by the manager (fires on stop()). */
|
|
872
|
+
readonly signal: AbortSignal;
|
|
873
|
+
/** Await before launching each agent so pause() can gate new spawns. */
|
|
874
|
+
readonly beforeSpawn: () => Promise<void>;
|
|
875
|
+
}
|
|
876
|
+
/** Neutral terminal classification of a caller-shaped outcome. */
|
|
877
|
+
interface ManagedRunClassification {
|
|
878
|
+
readonly status: 'completed' | 'failed' | 'denied';
|
|
879
|
+
readonly error?: Error;
|
|
880
|
+
readonly resultText?: string;
|
|
881
|
+
}
|
|
882
|
+
interface StartManagedRunInput<TOutcome> {
|
|
883
|
+
readonly runId: string;
|
|
884
|
+
/** Display name (usually the workflow's `meta.name`). */
|
|
885
|
+
readonly workflow: string;
|
|
886
|
+
readonly phases?: readonly string[];
|
|
887
|
+
readonly maxAgents?: number;
|
|
888
|
+
readonly plannedAgents?: number;
|
|
889
|
+
readonly tokenBudget?: number;
|
|
890
|
+
readonly processMetadata?: WorkflowProcessMetadata;
|
|
891
|
+
readonly signal?: AbortSignal;
|
|
892
|
+
/** Executes the run with the manager's lifecycle hooks injected. */
|
|
893
|
+
readonly runFn: (hooks: ManagedRunHooks) => Promise<TOutcome>;
|
|
894
|
+
/** Map the caller's terminal outcome to a neutral status for the snapshot. */
|
|
895
|
+
readonly classify: (outcome: TOutcome) => ManagedRunClassification;
|
|
896
|
+
/** Synthesize a caller-shaped outcome when `runFn` throws. */
|
|
897
|
+
readonly onError: (error: unknown) => TOutcome;
|
|
898
|
+
}
|
|
899
|
+
interface WorkflowRunManager {
|
|
900
|
+
start<TOutcome>(input: StartManagedRunInput<TOutcome>): ManagedWorkflowRun<TOutcome>;
|
|
901
|
+
list(): readonly ManagedWorkflowSnapshot[];
|
|
902
|
+
get(runId: string): ManagedWorkflowSnapshot | undefined;
|
|
903
|
+
subscribeWorkflowProcess(listener: (event: WorkflowProcessEvent) => void): () => void;
|
|
904
|
+
getWorkflowProcessSnapshot(runId: string): WorkflowProcessSnapshot | undefined;
|
|
905
|
+
listWorkflowProcessSnapshots(options?: {
|
|
906
|
+
readonly activeOnly?: boolean;
|
|
907
|
+
readonly limit?: number;
|
|
908
|
+
}): readonly WorkflowProcessSnapshot[];
|
|
909
|
+
pause(runId: string): boolean;
|
|
910
|
+
resume(runId: string): boolean;
|
|
911
|
+
stop(runId: string, reason?: string): boolean;
|
|
912
|
+
}
|
|
913
|
+
declare function createWorkflowRunManager(deps?: {
|
|
914
|
+
readonly now?: () => number;
|
|
915
|
+
}): WorkflowRunManager;
|
|
916
|
+
declare function getDefaultWorkflowRunManager(): WorkflowRunManager;
|
|
809
917
|
|
|
810
|
-
export {
|
|
811
|
-
export type { WorkflowCapsuleInputs as
|
|
918
|
+
export { buildWorkflowCapsuleIntent as $, WORKFLOW_CAPSULE_FORMAT as A, WORKFLOW_CAPSULE_VERSION as B, DefaultSummaryCompaction as D, WORKFLOW_PATTERN_IDS as E, KODAX_API_MIN_INTERVAL as K, LINEAGE_ENTRY_TYPES as L, PROMISE_PATTERN as P, appendSessionLineageLabel as U, applyLineageTruncation as V, WORKFLOW_CAPSULE_API_VERSION as W, applySessionCompaction as X, archiveOldIslands as Y, buildSessionTree as Z, _resetMessageQueueForTests as _, cleanupIncompleteToolCalls as a0, countActiveLineageMessages as a1, countTokens as a2, createSessionLineage as a3, createWorkflowCapsule as a4, createWorkflowModuleFromCapsule as a5, createWorkflowRunManager as a6, estimateTokens as a7, extractArtifactLedger as a8, extractFileOps as a9, extractTitleFromMessages as aa, findPreviousUserEntryId as ab, forkSessionLineage as ac, generateSessionId as ad, getAgentConfigHome as ae, getAgentConfigPath as af, getAppDataDir as ag, getDefaultWorkflowRunManager as ah, getMessageQueue as ai, getSessionLineagePath as aj, getSessionMessagesFromLineage as ak, mergeArtifactLedger as al, mergeFileOps as am, resolveSessionLineageTarget as an, rewindSessionLineage as ao, setAgentConfigHome as ap, setSessionLineageActiveEntry as aq, validateAndFixToolHistory as ar, validateWorkflowCapsule as as, validateWorkflowScriptManifest as at, KODAX_DEFAULT_TIMEOUT as f, KODAX_HARD_TIMEOUT as g, KODAX_MAX_INCOMPLETE_RETRIES as h, KODAX_MAX_MAXTOKENS_RETRIES as i, KODAX_MAX_RETRIES as j, KODAX_MAX_TOKENS as k, KODAX_RETRY_BASE_DELAY as l, KODAX_STAGGER_DELAY as m, LineageCompaction as o, LineageExtension as r, MessageQueue as y };
|
|
919
|
+
export type { CompactionContext as C, WorkflowCapsule as F, WorkflowCapsuleEnvironmentRequirement as G, WorkflowCapsuleInputs as H, WorkflowCapsuleIntent as I, WorkflowCapsuleProvenance as J, ManagedRunClassification as M, WorkflowCapsuleRequirements as N, WorkflowPatternId as O, WorkflowProcessMetadata as Q, WorkflowRunManager as R, StartManagedRunInput as S, WorkflowScriptManifest as T, CompactionEntry as a, CompactionEntryPayload as b, CompactionPolicy as c, CreateWorkflowCapsuleInput as d, DefaultSummaryCompactionOptions as e, LineageArtifactLedgerPayload as n, LineageCompactionDelegates as p, LineageEntryType as q, LineageLabelPayload as s, LineageTreeNode as t, ManagedRunHooks as u, ManagedWorkflowRun as v, ManagedWorkflowSnapshot as w, ManagedWorkflowStatus as x, PolicyCompactionResult as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as PermissionMode,
|
|
2
|
-
import { E as KodaXReasoningMode, j as KodaXMessage, c as KodaXContentBlock } from './types.d-
|
|
3
|
-
import { m as KodaXAgentMode } from './bash-prefix-extractor.d-
|
|
4
|
-
import {
|
|
1
|
+
import { b as PermissionMode, F as FileSessionStorage, S as SessionData } from './storage.d-DHL3XpAL.js';
|
|
2
|
+
import { E as KodaXReasoningMode, j as KodaXMessage, c as KodaXContentBlock } from './types.d-Ci5YPFEh.js';
|
|
3
|
+
import { m as KodaXAgentMode } from './bash-prefix-extractor.d-BNdpV4Cf.js';
|
|
4
|
+
import { ai as KodaXSessionUiHistoryItem, am as KodaXSessionUiToolCall } from './process.d-BOrAxjvM.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* TextBuffer - Text buffer management class - 文本缓冲区管理类
|
|
@@ -540,7 +540,7 @@ interface ToolCall {
|
|
|
540
540
|
* History item type - 历史项类型
|
|
541
541
|
* Reference: Gemini CLI HistoryItem - 参考: Gemini CLI HistoryItem
|
|
542
542
|
*/
|
|
543
|
-
type HistoryItemType = "user" | "assistant" | "system" | "tool_group" | "thinking" | "error" | "event" | "info" | "hint";
|
|
543
|
+
type HistoryItemType = "user" | "assistant" | "system" | "tool_group" | "thinking" | "error" | "event" | "info" | "hint" | "sidecar";
|
|
544
544
|
/**
|
|
545
545
|
* History item base class - 历史项基类
|
|
546
546
|
*/
|
|
@@ -624,15 +624,30 @@ interface HistoryItemHint extends HistoryItemBase {
|
|
|
624
624
|
type: "hint";
|
|
625
625
|
text: string;
|
|
626
626
|
}
|
|
627
|
+
/**
|
|
628
|
+
* Sidecar Verifier message - Sidecar 验证器消息
|
|
629
|
+
* Displayed as an independent "role" with its own header so the user can
|
|
630
|
+
* clearly see that the Sidecar Verifier is actively reviewing the output.
|
|
631
|
+
* verdict: 'revise' | 'blocked' | undefined; delivery 'budget-exhausted' means
|
|
632
|
+
* the verifier ran out of budget before returning a verdict.
|
|
633
|
+
*/
|
|
634
|
+
interface HistoryItemSidecar extends HistoryItemBase {
|
|
635
|
+
type: "sidecar";
|
|
636
|
+
text: string;
|
|
637
|
+
/** 'revise' or 'blocked'; absent when delivery === 'budget-exhausted' */
|
|
638
|
+
verdict?: "revise" | "blocked";
|
|
639
|
+
/** Set when the verifier exhausted its token budget before reaching a verdict */
|
|
640
|
+
delivery?: "budget-exhausted";
|
|
641
|
+
}
|
|
627
642
|
/**
|
|
628
643
|
* Union type of all history items - 所有历史项的联合类型
|
|
629
644
|
*/
|
|
630
|
-
type HistoryItem = HistoryItemUser | HistoryItemAssistant | HistoryItemSystem | HistoryItemToolGroup | HistoryItemThinking | HistoryItemError | HistoryItemEvent | HistoryItemInfo | HistoryItemHint;
|
|
645
|
+
type HistoryItem = HistoryItemUser | HistoryItemAssistant | HistoryItemSystem | HistoryItemToolGroup | HistoryItemThinking | HistoryItemError | HistoryItemEvent | HistoryItemInfo | HistoryItemHint | HistoryItemSidecar;
|
|
631
646
|
/**
|
|
632
647
|
* Creatable history item types (with text property) - 可创建的历史项类型(带 text 属性)
|
|
633
648
|
* Used for addHistoryItem function parameter type - 用于 addHistoryItem 等函数的参数类型
|
|
634
649
|
*/
|
|
635
|
-
type CreatableHistoryItem = Omit<HistoryItemUser, "id" | "timestamp"> | Omit<HistoryItemAssistant, "id" | "timestamp"> | Omit<HistoryItemSystem, "id" | "timestamp"> | Omit<HistoryItemThinking, "id" | "timestamp"> | Omit<HistoryItemError, "id" | "timestamp"> | Omit<HistoryItemEvent, "id" | "timestamp"> | Omit<HistoryItemInfo, "id" | "timestamp"> | Omit<HistoryItemHint, "id" | "timestamp"> | Omit<HistoryItemToolGroup, "id" | "timestamp">;
|
|
650
|
+
type CreatableHistoryItem = Omit<HistoryItemUser, "id" | "timestamp"> | Omit<HistoryItemAssistant, "id" | "timestamp"> | Omit<HistoryItemSystem, "id" | "timestamp"> | Omit<HistoryItemThinking, "id" | "timestamp"> | Omit<HistoryItemError, "id" | "timestamp"> | Omit<HistoryItemEvent, "id" | "timestamp"> | Omit<HistoryItemInfo, "id" | "timestamp"> | Omit<HistoryItemHint, "id" | "timestamp"> | Omit<HistoryItemSidecar, "id" | "timestamp"> | Omit<HistoryItemToolGroup, "id" | "timestamp">;
|
|
636
651
|
/**
|
|
637
652
|
* UI global state interface - UI 全局状态接口
|
|
638
653
|
* Reference: Gemini CLI UIStateContext - 参考: Gemini CLI UIStateContext
|
|
@@ -723,6 +738,10 @@ type RestoredHistorySeed = {
|
|
|
723
738
|
} | {
|
|
724
739
|
type: "thinking";
|
|
725
740
|
text: string;
|
|
741
|
+
} | {
|
|
742
|
+
type: "sidecar";
|
|
743
|
+
text: string;
|
|
744
|
+
verdict?: "revise" | "blocked";
|
|
726
745
|
} | {
|
|
727
746
|
type: "tool_summary";
|
|
728
747
|
text: string;
|
|
@@ -740,6 +759,13 @@ interface HistorySeedSourceMessage {
|
|
|
740
759
|
role: KodaXMessage["role"];
|
|
741
760
|
content: string | KodaXContentBlock[];
|
|
742
761
|
_synthetic?: boolean;
|
|
762
|
+
/**
|
|
763
|
+
* Provenance marker persisted on host-injected messages. `'sidecar-verifier'`
|
|
764
|
+
* tags the synthetic user message the Sidecar Verifier injects on a `revise`
|
|
765
|
+
* verdict, so restore can render it under the Sidecar identity instead of
|
|
766
|
+
* swallowing it with the generic `_synthetic` skip.
|
|
767
|
+
*/
|
|
768
|
+
_source?: string;
|
|
743
769
|
}
|
|
744
770
|
declare function extractHistorySeedsFromMessage(message: HistorySeedSourceMessage): RestoredHistorySeed[];
|
|
745
771
|
declare function extractHistorySeedsFromMessages(messages: readonly HistorySeedSourceMessage[]): RestoredHistorySeed[];
|
|
@@ -757,6 +783,50 @@ declare function extractTitle(messages: KodaXMessage[]): string;
|
|
|
757
783
|
*/
|
|
758
784
|
declare function formatMessagePreview(content: string, maxLength?: number): string;
|
|
759
785
|
|
|
786
|
+
/**
|
|
787
|
+
* FEATURE_247 (R6) — imperative session compaction.
|
|
788
|
+
*
|
|
789
|
+
* Lets an SDK embedder (KodaX-Space) compact a session by id immediately —
|
|
790
|
+
* e.g. when the user clicks a "/compact" button — instead of forging a token
|
|
791
|
+
* snapshot or appending an empty message to trip auto-compaction. Loads the
|
|
792
|
+
* session, runs the same `compact()` pass the REPL `/compact` command uses,
|
|
793
|
+
* applies the result to the session lineage (so `loadFullTranscript` / resume
|
|
794
|
+
* see the compaction entry), and writes it back.
|
|
795
|
+
*
|
|
796
|
+
* Applies uniformly to Partner and Coder sessions. Never throws — failures
|
|
797
|
+
* return `{ compacted: false, reason }`.
|
|
798
|
+
*/
|
|
799
|
+
|
|
800
|
+
interface CompactSessionOptions {
|
|
801
|
+
/** Provider alias for the summarizer. Defaults to the session's persisted provider, then 'anthropic'. */
|
|
802
|
+
readonly provider?: string;
|
|
803
|
+
/** Model override forwarded to the summarizer. */
|
|
804
|
+
readonly model?: string;
|
|
805
|
+
/** Custom summarizer instructions (same as `/compact <text>`). */
|
|
806
|
+
readonly customInstructions?: string;
|
|
807
|
+
/** Provider context-window override (tokens). Otherwise resolved from the provider/model. */
|
|
808
|
+
readonly contextWindow?: number;
|
|
809
|
+
/** Sessions directory (mirrors createSessionManager's override). */
|
|
810
|
+
readonly sessionsDir?: string;
|
|
811
|
+
/** Injected storage instance (takes precedence over sessionsDir). */
|
|
812
|
+
readonly storage?: FileSessionStorage;
|
|
813
|
+
}
|
|
814
|
+
interface CompactSessionResult {
|
|
815
|
+
/** True when the session was actually rewritten. */
|
|
816
|
+
readonly compacted: boolean;
|
|
817
|
+
readonly tokensBefore: number;
|
|
818
|
+
readonly tokensAfter: number;
|
|
819
|
+
/** The rewritten (or unchanged) message list. */
|
|
820
|
+
readonly messages: KodaXMessage[];
|
|
821
|
+
/** Populated when `compacted` is false to explain why (not-found / no-op / error). */
|
|
822
|
+
readonly reason?: string;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Compact a session by id, writing the result (lineage + messages) back to
|
|
826
|
+
* storage. Never throws.
|
|
827
|
+
*/
|
|
828
|
+
declare function compactSession(sessionId: string, options?: CompactSessionOptions): Promise<CompactSessionResult>;
|
|
829
|
+
|
|
760
830
|
/**
|
|
761
831
|
* FEATURE_173 Part B (v0.7.42) — Session Management Public SDK.
|
|
762
832
|
*
|
|
@@ -777,6 +847,8 @@ interface SessionSummary {
|
|
|
777
847
|
readonly runtimeInfo?: {
|
|
778
848
|
workspaceRoot?: string;
|
|
779
849
|
gitRoot?: string;
|
|
850
|
+
surface?: string;
|
|
851
|
+
profileId?: string;
|
|
780
852
|
};
|
|
781
853
|
/**
|
|
782
854
|
* FEATURE_219 (v0.7.46) — the per-project directory key this session lives
|
|
@@ -848,6 +920,8 @@ interface SessionManager {
|
|
|
848
920
|
unarchiveSession: typeof unarchiveSession;
|
|
849
921
|
listRunningSessions: typeof listRunningSessions;
|
|
850
922
|
watchSessions: typeof watchSessions;
|
|
923
|
+
/** FEATURE_247 (R6) — imperatively compact a session by id (writes lineage + emits nothing; returns stats). */
|
|
924
|
+
compactSession: typeof compactSession;
|
|
851
925
|
/**
|
|
852
926
|
* v0.7.43 — the raw write-side storage instance. SDK embedders pass
|
|
853
927
|
* this into `runKodaX({ session: { id, scope, storage } })` so the
|
|
@@ -975,5 +1049,5 @@ declare function createSessionManager(opts?: {
|
|
|
975
1049
|
sessionsDir?: string;
|
|
976
1050
|
}): SessionManager;
|
|
977
1051
|
|
|
978
|
-
export { DEFAULT_UI_STATE as D, StreamingState as
|
|
979
|
-
export type {
|
|
1052
|
+
export { DEFAULT_UI_STATE as D, StreamingState as O, TOOL_STATUS_ICONS as T, TextBuffer as U, ToolCallStatus as _, archiveSession as a5, createSessionManager as a6, deleteSession as a7, extractHistorySeedsFromMessage as a8, extractHistorySeedsFromMessages as a9, extractTextContent as aa, extractTitle as ab, forkSession as ac, formatMessagePreview as ad, listRunningSessions as ae, listSessions as af, loadFullTranscript as ag, loadSession as ah, restoreHistoryItemsFromSession as ai, rewindSession as aj, seedToHistoryItem as ak, setActiveEntry as al, toolCallSeedToHistoryToolCall as am, trimPersistedUiHistorySnapshot as an, unarchiveSession as ao, watchSessions as ap, KeypressHandlerPriority as v };
|
|
1053
|
+
export type { UIActions as $, AppProps as A, RunningSessionInfo as B, Completer as C, SessionSummary as E, FullTranscriptSessionData as F, SessionTranscriptEntry as G, HistoryEntry as H, InputPromptProps as I, SessionTranscriptEntryType as J, KeyInfo as K, LegacyMessageListProps as L, Message as M, StatusBarProps as N, PastedContent as P, Suggestion as Q, RestoreHistoryItemsFromSessionInput as R, SessionManager as S, TextBufferOptions as V, Theme as W, ThemeColors as X, ThemeSymbols as Y, ToolCall as Z, AppState as a, UIState as a0, UseTextBufferReturn as a1, VisualCursor as a2, VisualLayout as a3, WatchSessionsCallback as a4, Completion as b, CreatableHistoryItem as c, CursorPosition as d, DeleteSessionResult as e, HistoryItem as f, HistoryItemAssistant as g, HistoryItemBase as h, HistoryItemError as i, HistoryItemEvent as j, HistoryItemHint as k, HistoryItemInfo as l, HistoryItemSidecar as m, HistoryItemSystem as n, HistoryItemThinking as o, HistoryItemToolGroup as p, HistoryItemType as q, HistoryItemUser as r, HistorySeedSourceMessage as s, KeypressEvent as t, KeypressHandler as u, ListSessionsOptions as w, PromptEditingMode as x, PromptSubmitPayload as y, RestoredHistorySeed as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as BashPrefixExtractor } from './bash-prefix-extractor.d-
|
|
2
|
-
import {
|
|
1
|
+
import { a as BashPrefixExtractor } from './bash-prefix-extractor.d-BNdpV4Cf.js';
|
|
2
|
+
import { a5 as KodaXSessionData, aa as KodaXSessionLineage, ad as KodaXSessionNavigationOptions, ae as KodaXSessionRuntimeInfo, ag as KodaXSessionStorage } from './process.d-BOrAxjvM.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Permission Types
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z as Guardrail, aO as RunnerToolCall, e as Agent, g as AgentMessage, aR as RunnerToolResult, a_ as Span, _ as KodaXInputArtifact } from './process.d-BOrAxjvM.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Guardrail Runtime — FEATURE_085 (v0.7.26).
|
|
@@ -151,5 +151,127 @@ declare function runToolBeforeGuardrails(call: RunnerToolCall, guardrails: reado
|
|
|
151
151
|
*/
|
|
152
152
|
declare function runToolAfterGuardrails(call: RunnerToolCall, result: RunnerToolResult, guardrails: readonly ToolGuardrail[], ctx: GuardrailContext, agentSpan: Span | null): Promise<RunnerToolResult>;
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
/**
|
|
155
|
+
* @kodax-ai/agent/messaging — Message queue types
|
|
156
|
+
*
|
|
157
|
+
* FEATURE_115 (v0.7.36): agentId-scoped 2-tier priority queue infrastructure.
|
|
158
|
+
*
|
|
159
|
+
* Per ADR-021: messaging is a generic agent-platform primitive (not coding-
|
|
160
|
+
* specific). Downstream consumers:
|
|
161
|
+
* - @kodax-ai/coding runner-driven mid-turn drain
|
|
162
|
+
* - @kodax-ai/repl InkREPL ESC soft-pause + text injection (FEATURE_111 absorbed)
|
|
163
|
+
* - subagent task-notification routing (FEATURE_155 idle-yield wakeup)
|
|
164
|
+
*
|
|
165
|
+
* Phase 0.6 study (`c:/tmp/claude-code-actual-usage.md`): Claude Code's
|
|
166
|
+
* `'now'` priority has zero production usage; KodaX simplifies to 2 tiers.
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
type MessagePriority = 'user' | 'background';
|
|
170
|
+
type MessageMode = 'prompt' | 'task-notification' | 'system-reminder';
|
|
171
|
+
type QueuedInputArtifact = KodaXInputArtifact;
|
|
172
|
+
interface QueuedMessage {
|
|
173
|
+
/** Stable id for tracing / dedup. Format: `msg-<sequence>`. */
|
|
174
|
+
readonly id: string;
|
|
175
|
+
readonly priority: MessagePriority;
|
|
176
|
+
/**
|
|
177
|
+
* Routing key:
|
|
178
|
+
* undefined = main thread / coordinator agent
|
|
179
|
+
* 'agent-id-XYZ' = subagent / specific consumer
|
|
180
|
+
*
|
|
181
|
+
* Drain consumers MUST filter by agentId match — undefined matches only
|
|
182
|
+
* undefined-agentId messages, not "any agent".
|
|
183
|
+
*/
|
|
184
|
+
readonly agentId?: string;
|
|
185
|
+
readonly mode: MessageMode;
|
|
186
|
+
readonly content: string;
|
|
187
|
+
readonly inputArtifacts?: readonly QueuedInputArtifact[];
|
|
188
|
+
/** Wall-clock timestamp (`Date.now()`) for tracing only — not used for ordering. */
|
|
189
|
+
readonly enqueuedAt: number;
|
|
190
|
+
}
|
|
191
|
+
interface DequeueFilter {
|
|
192
|
+
/**
|
|
193
|
+
* Only return messages with this agentId.
|
|
194
|
+
* undefined matches messages with no agentId (main-thread messages only).
|
|
195
|
+
*/
|
|
196
|
+
readonly agentId?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Highest priority level included in the drain.
|
|
199
|
+
* 'user' → only user priority drained, background stays queued
|
|
200
|
+
* 'background' → both user + background drained (Sleep-gated case)
|
|
201
|
+
*/
|
|
202
|
+
readonly maxPriority: MessagePriority;
|
|
203
|
+
/**
|
|
204
|
+
* Optional cap on number of messages drained in this call.
|
|
205
|
+
* Defaults to unlimited (drains all matching).
|
|
206
|
+
*/
|
|
207
|
+
readonly limit?: number;
|
|
208
|
+
/**
|
|
209
|
+
* FEATURE_159 (v0.7.40) — optional mode filter. Lets REPL split the
|
|
210
|
+
* single queue into mode-typed views (e.g. `mode:'prompt'` for user
|
|
211
|
+
* input vs `mode:'task-notification'` for child completion banners)
|
|
212
|
+
* without separate queues. When omitted, all modes match.
|
|
213
|
+
*/
|
|
214
|
+
readonly mode?: MessageMode;
|
|
215
|
+
/**
|
|
216
|
+
* FEATURE_159 (v0.7.40) — optional precise-id filter. Single-message
|
|
217
|
+
* targeted removal — drives Esc-pop-this-uuid in REPL. When set, all
|
|
218
|
+
* other filters still apply (agentId / priority / mode mismatches still
|
|
219
|
+
* skip the message), so callers can't accidentally remove a message
|
|
220
|
+
* outside their scope.
|
|
221
|
+
*/
|
|
222
|
+
readonly id?: string;
|
|
223
|
+
/**
|
|
224
|
+
* FEATURE_159 (v0.7.40) — optional escape-hatch predicate, AND-ed with
|
|
225
|
+
* the structured filters. Lets SDK consumers express conditions the
|
|
226
|
+
* typed fields don't cover (e.g. timestamp ranges, content-match) without
|
|
227
|
+
* forcing every new use case to extend `DequeueFilter`. KodaX-internal
|
|
228
|
+
* code should prefer the typed fields for readability; this is the
|
|
229
|
+
* "data-driven main path + predicate escape" pattern.
|
|
230
|
+
*
|
|
231
|
+
* Evaluated AFTER the typed filters succeed — so a `predicate` that
|
|
232
|
+
* inspects `message.content` never runs on messages outside the
|
|
233
|
+
* caller's `agentId` / `mode` / `id` scope.
|
|
234
|
+
*/
|
|
235
|
+
readonly predicate?: (message: QueuedMessage) => boolean;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* FEATURE_159 (v0.7.40) — structured queue event emitted to subscribers.
|
|
239
|
+
*
|
|
240
|
+
* Replaces the prior `() => void` bare-notify signal. Carries the kind +
|
|
241
|
+
* affected messages so SDK observability consumers (logging, tracing,
|
|
242
|
+
* metrics) can react per-event without re-diffing snapshots.
|
|
243
|
+
*
|
|
244
|
+
* Event granularity rules:
|
|
245
|
+
* - `enqueued` fires ONCE per `enqueue()` call (always 1 message).
|
|
246
|
+
* - `dequeued` fires ONCE per `dequeue()` call that removed ≥1 message,
|
|
247
|
+
* carrying ALL drained messages in priority+FIFO order. No-op drains
|
|
248
|
+
* (filter matched nothing) fire no event — quiet by design so the
|
|
249
|
+
* `waitForWakeEvent` 100ms poll doesn't spam idle subscribers.
|
|
250
|
+
* - `cleared` fires ONCE per `clear()` call that removed ≥1 message,
|
|
251
|
+
* carrying the pre-clear messages. Empty-queue clear fires nothing.
|
|
252
|
+
*
|
|
253
|
+
* The `useSyncExternalStore` React hook ignores the event payload (it
|
|
254
|
+
* only needs the change signal); SDK / tracer consumers read the event.
|
|
255
|
+
*/
|
|
256
|
+
type QueueEvent = {
|
|
257
|
+
readonly kind: 'enqueued';
|
|
258
|
+
readonly message: QueuedMessage;
|
|
259
|
+
} | {
|
|
260
|
+
readonly kind: 'dequeued';
|
|
261
|
+
readonly messages: readonly QueuedMessage[];
|
|
262
|
+
} | {
|
|
263
|
+
readonly kind: 'cleared';
|
|
264
|
+
readonly messages: readonly QueuedMessage[];
|
|
265
|
+
};
|
|
266
|
+
/** FEATURE_159 — `MessageQueue.subscribe` listener signature. */
|
|
267
|
+
type QueueEventListener = (event: QueueEvent) => void;
|
|
268
|
+
interface EnqueueInput {
|
|
269
|
+
readonly priority: MessagePriority;
|
|
270
|
+
readonly mode: MessageMode;
|
|
271
|
+
readonly content: string;
|
|
272
|
+
readonly agentId?: string;
|
|
273
|
+
readonly inputArtifacts?: readonly QueuedInputArtifact[];
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export { GuardrailBlockedError as G, GuardrailEscalateError as b, collectGuardrails as h, runOutputGuardrails as i, runToolAfterGuardrails as j, runToolBeforeGuardrails as k, runInputGuardrails as r };
|
|
277
|
+
export type { DequeueFilter as D, EnqueueInput as E, InputGuardrail as I, MessageMode as M, OutputGuardrail as O, QueueEventListener as Q, ToolBeforeOutcome as T, GuardrailContext as a, GuardrailVerdict as c, MessagePriority as d, QueuedInputArtifact as e, QueuedMessage as f, ToolGuardrail as g };
|
|
@@ -12,6 +12,31 @@ interface KodaXToolUseBlock {
|
|
|
12
12
|
id: string;
|
|
13
13
|
name: string;
|
|
14
14
|
input: Record<string, unknown>;
|
|
15
|
+
/**
|
|
16
|
+
* Set true when `input` was salvaged from malformed JSON (strict `JSON.parse`
|
|
17
|
+
* threw). RAW signal — set regardless of stop reason. On its own it means the
|
|
18
|
+
* payload is syntactically suspect: even a "complete" turn can carry malformed
|
|
19
|
+
* JSON (e.g. unescaped quotes) that the partial-json salvage silently truncates
|
|
20
|
+
* mid-value. `checkIncompleteToolCalls` therefore treats a salvaged input on a
|
|
21
|
+
* MUTATING tool (write/edit/bash — `isToolMutation`) as incomplete even on a
|
|
22
|
+
* clean stop, because executing a silently-cut payload corrupts files; a
|
|
23
|
+
* salvaged input on a read-only tool is allowed through on a clean stop.
|
|
24
|
+
*/
|
|
25
|
+
_salvaged?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Set true when `input` was salvaged AND the stream did NOT end on a
|
|
28
|
+
* recognized clean stop (`max_tokens`/`length`, or an ambiguous/`unknown`
|
|
29
|
+
* stop). A truncating stop means the payload may be cut mid-value, so this is
|
|
30
|
+
* unsafe to execute for ANY tool (not just mutating ones) — the agent loop
|
|
31
|
+
* routes it into the incomplete-tool retry (CAP-072). Subset of `_salvaged`.
|
|
32
|
+
*
|
|
33
|
+
* Both markers are internal: provider serializers never write them to the wire
|
|
34
|
+
* (they read only type/id/name/input). They may transiently remain on an
|
|
35
|
+
* assistant tool_use block in session history on the retry-cap path; harmless
|
|
36
|
+
* and never reaches the model. Mirrors the `KodaXMessage._synthetic`
|
|
37
|
+
* convention.
|
|
38
|
+
*/
|
|
39
|
+
_truncated?: boolean;
|
|
15
40
|
}
|
|
16
41
|
/**
|
|
17
42
|
* Tool-result content blocks — a structural subset of the full
|
|
@@ -93,6 +118,14 @@ interface KodaXMessage {
|
|
|
93
118
|
content: string | KodaXContentBlock[];
|
|
94
119
|
/** Marks messages injected by the system (auto-continue, retry prompts). Hidden in REPL display. */
|
|
95
120
|
_synthetic?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Identifies which subsystem injected a synthetic message so consumers can
|
|
123
|
+
* render/attribute it distinctly instead of treating it like a user query.
|
|
124
|
+
* Absent on genuine user/assistant/system messages. Known values include
|
|
125
|
+
* `'sidecar-verifier'` (Sidecar Verifier revise feedback). Exposed verbatim
|
|
126
|
+
* through `KodaXResult.messages` and session-load APIs for SDK consumers.
|
|
127
|
+
*/
|
|
128
|
+
_source?: string;
|
|
96
129
|
}
|
|
97
130
|
interface KodaXTokenUsage {
|
|
98
131
|
inputTokens: number;
|
|
@@ -133,7 +166,7 @@ interface KodaXReasoningEffortPreset {
|
|
|
133
166
|
readonly isDefault?: boolean;
|
|
134
167
|
readonly isUserVisible?: boolean;
|
|
135
168
|
}
|
|
136
|
-
type KodaXReasoningEffortWireStrategy = 'openai-responses-effort' | 'openai-chat-effort' | 'codex-cli-config' | 'anthropic-output-effort' | 'provider-budget' | 'provider-toggle' | 'prompt-only' | 'none';
|
|
169
|
+
type KodaXReasoningEffortWireStrategy = 'openai-responses-effort' | 'openai-chat-effort' | 'codex-cli-config' | 'anthropic-output-effort' | 'anthropic-reasoning-effort' | 'provider-budget' | 'provider-toggle' | 'prompt-only' | 'none';
|
|
137
170
|
type KodaXThinkingWireStrategy = 'anthropic-adaptive' | 'anthropic-budget' | 'provider-budget' | 'provider-toggle' | 'none';
|
|
138
171
|
interface KodaXReasoningProfile {
|
|
139
172
|
readonly reasoningPreset?: KodaXReasoningPresetName;
|
|
@@ -540,10 +573,11 @@ interface KodaXProviderStreamOptions {
|
|
|
540
573
|
}) => void;
|
|
541
574
|
/** 会话标识,用于多轮对话上下文恢复 */
|
|
542
575
|
/**
|
|
543
|
-
* Passive capability learning
|
|
544
|
-
* reasoning-effort value (400/422 naming the param).
|
|
545
|
-
*
|
|
546
|
-
* offered or sent again (see
|
|
576
|
+
* Passive capability learning: fired when a provider HARD-rejects a
|
|
577
|
+
* reasoning-effort value (400/422 naming the param). Hosts can record it via
|
|
578
|
+
* the agent-layer capability cache so the rung is removed from the effective
|
|
579
|
+
* ladder and never offered or sent again (see
|
|
580
|
+
* `classifyReasoningEffortRejection`).
|
|
547
581
|
*/
|
|
548
582
|
onReasoningEffortRejected?: (event: {
|
|
549
583
|
provider: string;
|