@kodax-ai/kodax 0.7.63 → 0.7.67
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 +2390 -2189
- package/README.md +118 -16
- package/README_CN.md +78 -12
- package/dist/chunks/{agent-SL444XLN.js → agent-E4V5SLX6.js} +1 -1
- package/dist/chunks/argument-completer-N6RT5KYT.js +2 -0
- package/dist/chunks/{chunk-ARUWXX25.js → chunk-35P7QL2Q.js} +1 -1
- package/dist/chunks/chunk-AKMXJSGM.js +56 -0
- package/dist/chunks/{chunk-L3MF5V64.js → chunk-CW32NQFO.js} +1 -1
- package/dist/chunks/{chunk-KCFVGXVK.js → chunk-DEICMTHO.js} +9 -9
- package/dist/chunks/{chunk-7MPU7TP6.js → chunk-EN3O2C43.js} +270 -270
- package/dist/chunks/chunk-KBBGDRER.js +22 -0
- package/dist/chunks/chunk-NVDK375I.js +729 -0
- package/dist/chunks/{chunk-S4GVQO3W.js → chunk-O7N22GJ3.js} +1 -1
- package/dist/chunks/chunk-ONUPGMER.js +2 -0
- package/dist/chunks/{chunk-ZL5CEANW.js → chunk-PZTG2C33.js} +1 -1
- package/dist/chunks/chunk-QI6SQ2UQ.js +306 -0
- package/dist/chunks/{chunk-6OZ5KWG3.js → chunk-QJJKMNZF.js} +1 -1
- package/dist/chunks/chunk-RS2GAABJ.js +328 -0
- package/dist/chunks/chunk-W2XMNYLK.js +15 -0
- package/dist/chunks/chunk-WCSSXBHR.js +419 -0
- package/dist/chunks/chunk-YH5BTUQO.js +343 -0
- package/dist/chunks/{chunk-UA744TZM.js → chunk-YRBNXFHY.js} +1 -1
- package/dist/chunks/compaction-config-56NO42ZI.js +2 -0
- package/dist/chunks/{construction-bootstrap-EFZBONTK.js → construction-bootstrap-GLEHQ2KB.js} +1 -1
- package/dist/chunks/{devtools-4CRULTR2.js → devtools-CD6KSIHE.js} +1 -1
- package/dist/chunks/{devtools-YINBSZC7.js → devtools-XR5F2C6T.js} +1 -1
- package/dist/chunks/{dist-73L4OYPD.js → dist-4PXB7U22.js} +1 -1
- package/dist/chunks/dist-4UIRSSFS.js +2 -0
- package/dist/chunks/host-DMREFNSO.js +2 -0
- package/dist/chunks/{paste-FDYM7SZX.js → paste-C33GZQV5.js} +1 -1
- package/dist/chunks/run-manager-P5XMSGZ7.js +2 -0
- package/dist/chunks/utils-JENPFKAE.js +2 -0
- package/dist/constructed-handler-worker.js +2 -0
- package/dist/index.d.ts +25 -11
- package/dist/index.js +6 -6
- package/dist/kodax_cli.js +1282 -1232
- package/dist/runtime-worker.js +2872 -0
- package/dist/sdk-agent.d.ts +46 -10
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-coding.d.ts +337 -1020
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-llm.js +1 -1
- package/dist/sdk-mcp.d.ts +2 -1
- package/dist/sdk-mcp.js +1 -1
- package/dist/sdk-media.js +1 -1
- package/dist/sdk-repl.d.ts +208 -185
- package/dist/sdk-repl.js +2 -2
- package/dist/sdk-runtime.d.ts +1070 -0
- package/dist/sdk-runtime.js +2 -0
- package/dist/sdk-session.d.ts +4 -4
- package/dist/sdk-session.js +1 -1
- package/dist/sdk-skills.js +1 -1
- package/dist/semantic-worker.js +191 -10
- package/dist/types-chunks/{bash-prefix-extractor.d-CZW9fRoa.d.ts → bash-prefix-extractor.d-D57Gt6n8.d.ts} +186 -12
- package/dist/types-chunks/{run-manager.d-CYTnWhZY.d.ts → capsule.d-BZmqu_HL.d.ts} +5 -92
- package/dist/types-chunks/commands.d-Cg26ud-Y.d.ts +213 -0
- package/dist/types-chunks/{types.d-1CnTg7Sd.d.ts → guardrail.d-Ds7JHxR1.d.ts} +3 -128
- package/dist/types-chunks/{guardrail.d-MR6LwMB2.d.ts → guardrail.d-vSaBe64I.d.ts} +3 -3
- package/dist/types-chunks/{manager.d-DBD7SOTT.d.ts → manager.d-Zum9cGHU.d.ts} +3 -173
- package/dist/types-chunks/oauth-login.d-Bgb4rdLN.d.ts +174 -0
- package/dist/types-chunks/public-api.d-CPBMPDiU.d.ts +602 -0
- package/dist/types-chunks/run-manager.d-lnwnfyNC.d.ts +91 -0
- package/dist/types-chunks/{sdk-session-RBSBBKol.d.ts → sdk-session-ByoMLoUS.d.ts} +8 -306
- package/dist/types-chunks/{process.d-CY2g03Mb.d.ts → types.d-DG9B4SMm.d.ts} +369 -4
- package/dist/types-chunks/types.d-DU9lLkmE.d.ts +128 -0
- package/dist/types-chunks/types.d-DYv3a1ka.d.ts +975 -0
- package/dist/types-chunks/{utils.d-C14jZ9ZM.d.ts → utils.d-DMI-9GTR.d.ts} +88 -72
- package/docs/SDK_EMBEDDER_GUIDE.md +3079 -0
- package/package.json +8 -1
- package/dist/chunks/argument-completer-EN63ZVJK.js +0 -2
- package/dist/chunks/chunk-4MIHVNB7.js +0 -405
- package/dist/chunks/chunk-HP4FXMEM.js +0 -18
- package/dist/chunks/chunk-KHICMJIR.js +0 -310
- package/dist/chunks/chunk-LGR7ACBQ.js +0 -326
- package/dist/chunks/chunk-RR7W7UF6.js +0 -341
- package/dist/chunks/chunk-UGTK2JIJ.js +0 -731
- package/dist/chunks/chunk-V4WSBIXB.js +0 -2
- package/dist/chunks/chunk-VSWROENP.js +0 -52
- package/dist/chunks/compaction-config-4VIONMFB.js +0 -2
- package/dist/chunks/dist-EDF2YUF6.js +0 -2
- package/dist/chunks/host-J4HPDLFC.js +0 -2
- package/dist/chunks/run-manager-ZVSW2OWM.js +0 -2
- package/dist/chunks/utils-5HDLYTZJ.js +0 -2
- package/dist/types-chunks/storage.d-C6kkAEch.d.ts +0 -280
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { di as WorkflowProcessTrackerOptions, cV as WorkflowEvent, dc as WorkflowProcessSnapshot, d6 as WorkflowProcessEvent } from './types.d-DG9B4SMm.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* FEATURE_246 Part A0 (ADR-046) — neutral workflow run lifecycle manager.
|
|
5
|
+
*
|
|
6
|
+
* Domain-neutral run registry + lifecycle (pause / resume / stop), process-event
|
|
7
|
+
* tracking, and terminal settle — lifted out of `@kodax-ai/coding` so any agent
|
|
8
|
+
* (including non-coding SDK hosts) can host and manage workflow runs.
|
|
9
|
+
*
|
|
10
|
+
* It never knows HOW a run executes: the caller injects a `runFn` thunk that
|
|
11
|
+
* receives lifecycle hooks (`onEvent` / `signal` / `beforeSpawn`) and returns a
|
|
12
|
+
* caller-shaped outcome, plus a `classify` mapping that outcome to a neutral
|
|
13
|
+
* terminal status and an `onError` that synthesizes a failure outcome. The
|
|
14
|
+
* coding layer wires `runFn` to its `runWorkflowModule` / `runWorkflowFromOptions`
|
|
15
|
+
* (backend + run-graph + worktrees); SDK hosts wire their own. Dependency arrows
|
|
16
|
+
* therefore point only coding → agent — no cycle.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
type ManagedWorkflowStatus = 'running' | 'paused' | 'completed' | 'failed' | 'denied' | 'stopped';
|
|
20
|
+
/** Provenance/display metadata for a run's process tracker. */
|
|
21
|
+
type WorkflowProcessMetadata = Pick<WorkflowProcessTrackerOptions, 'displayName' | 'goal' | 'source' | 'savedWorkflowName' | 'sourceRunId' | 'sourceWorkflowName' | 'revisionOf' | 'resumedFromRunId' | 'hostMetadata'>;
|
|
22
|
+
interface ManagedWorkflowSnapshot {
|
|
23
|
+
readonly runId: string;
|
|
24
|
+
readonly workflow: string;
|
|
25
|
+
readonly status: ManagedWorkflowStatus;
|
|
26
|
+
readonly totalSpawned: number;
|
|
27
|
+
readonly eventCount: number;
|
|
28
|
+
readonly startedAt: number;
|
|
29
|
+
readonly endedAt?: number;
|
|
30
|
+
readonly error?: string;
|
|
31
|
+
readonly resultText?: string;
|
|
32
|
+
}
|
|
33
|
+
interface ManagedWorkflowRun<TOutcome = unknown> {
|
|
34
|
+
readonly runId: string;
|
|
35
|
+
readonly done: Promise<TOutcome>;
|
|
36
|
+
getSnapshot(): ManagedWorkflowSnapshot | undefined;
|
|
37
|
+
getProcessSnapshot(): WorkflowProcessSnapshot | undefined;
|
|
38
|
+
}
|
|
39
|
+
/** Lifecycle hooks the manager injects into the caller's `runFn`. */
|
|
40
|
+
interface ManagedRunHooks {
|
|
41
|
+
/** Forward every workflow event so the manager can track spawn/progress. */
|
|
42
|
+
readonly onEvent: (event: WorkflowEvent) => void;
|
|
43
|
+
/** Abort signal owned by the manager (fires on stop()). */
|
|
44
|
+
readonly signal: AbortSignal;
|
|
45
|
+
/** Await before launching each agent so pause() can gate new spawns. */
|
|
46
|
+
readonly beforeSpawn: () => Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
/** Neutral terminal classification of a caller-shaped outcome. */
|
|
49
|
+
interface ManagedRunClassification {
|
|
50
|
+
readonly status: 'completed' | 'failed' | 'denied';
|
|
51
|
+
readonly error?: Error;
|
|
52
|
+
readonly resultText?: string;
|
|
53
|
+
}
|
|
54
|
+
interface StartManagedRunInput<TOutcome> {
|
|
55
|
+
readonly runId: string;
|
|
56
|
+
/** Display name (usually the workflow's `meta.name`). */
|
|
57
|
+
readonly workflow: string;
|
|
58
|
+
readonly phases?: readonly string[];
|
|
59
|
+
readonly maxAgents?: number;
|
|
60
|
+
readonly plannedAgents?: number;
|
|
61
|
+
readonly tokenBudget?: number;
|
|
62
|
+
readonly processMetadata?: WorkflowProcessMetadata;
|
|
63
|
+
readonly signal?: AbortSignal;
|
|
64
|
+
/** Executes the run with the manager's lifecycle hooks injected. */
|
|
65
|
+
readonly runFn: (hooks: ManagedRunHooks) => Promise<TOutcome>;
|
|
66
|
+
/** Map the caller's terminal outcome to a neutral status for the snapshot. */
|
|
67
|
+
readonly classify: (outcome: TOutcome) => ManagedRunClassification;
|
|
68
|
+
/** Synthesize a caller-shaped outcome when `runFn` throws. */
|
|
69
|
+
readonly onError: (error: unknown) => TOutcome;
|
|
70
|
+
}
|
|
71
|
+
interface WorkflowRunManager {
|
|
72
|
+
start<TOutcome>(input: StartManagedRunInput<TOutcome>): ManagedWorkflowRun<TOutcome>;
|
|
73
|
+
list(): readonly ManagedWorkflowSnapshot[];
|
|
74
|
+
get(runId: string): ManagedWorkflowSnapshot | undefined;
|
|
75
|
+
subscribeWorkflowProcess(listener: (event: WorkflowProcessEvent) => void): () => void;
|
|
76
|
+
getWorkflowProcessSnapshot(runId: string): WorkflowProcessSnapshot | undefined;
|
|
77
|
+
listWorkflowProcessSnapshots(options?: {
|
|
78
|
+
readonly activeOnly?: boolean;
|
|
79
|
+
readonly limit?: number;
|
|
80
|
+
}): readonly WorkflowProcessSnapshot[];
|
|
81
|
+
pause(runId: string): boolean;
|
|
82
|
+
resume(runId: string): boolean;
|
|
83
|
+
stop(runId: string, reason?: string): boolean;
|
|
84
|
+
}
|
|
85
|
+
declare function createWorkflowRunManager(deps?: {
|
|
86
|
+
readonly now?: () => number;
|
|
87
|
+
}): WorkflowRunManager;
|
|
88
|
+
declare function getDefaultWorkflowRunManager(): WorkflowRunManager;
|
|
89
|
+
|
|
90
|
+
export { createWorkflowRunManager as f, getDefaultWorkflowRunManager as g };
|
|
91
|
+
export type { ManagedRunClassification as M, StartManagedRunInput as S, WorkflowProcessMetadata as W, ManagedRunHooks as a, ManagedWorkflowRun as b, ManagedWorkflowSnapshot as c, ManagedWorkflowStatus as d, WorkflowRunManager as e };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { E as KodaXReasoningMode, j as KodaXMessage, c as KodaXContentBlock
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { f as PermissionMode } from './public-api.d-CPBMPDiU.js';
|
|
2
|
+
import { E as KodaXReasoningMode, j as KodaXMessage, c as KodaXContentBlock } from './types.d-Bp4Lm1jv.js';
|
|
3
|
+
import { r as KodaXAgentMode } from './bash-prefix-extractor.d-D57Gt6n8.js';
|
|
4
|
+
import { bb as KodaXSessionUiHistoryItem, bf as KodaXSessionUiToolCall } from './types.d-DG9B4SMm.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* TextBuffer - Text buffer management class - 文本缓冲区管理类
|
|
@@ -380,6 +380,8 @@ interface InputPromptProps {
|
|
|
380
380
|
initialValue?: string;
|
|
381
381
|
/** Callback when input text changes - 输入文本变化时的回调 */
|
|
382
382
|
onInputChange?: (text: string) => void;
|
|
383
|
+
/** Called for a transient UI notice when image paste falls back to text. */
|
|
384
|
+
onPasteFallback?: (message: string) => void;
|
|
383
385
|
/**
|
|
384
386
|
* Called when the ↑ arrow history recall brings back an entry with stored
|
|
385
387
|
* paste contents. Consumer can hydrate a disk-backed paste cache here.
|
|
@@ -788,305 +790,5 @@ declare function extractTitle(messages: KodaXMessage[]): string;
|
|
|
788
790
|
*/
|
|
789
791
|
declare function formatMessagePreview(content: string, maxLength?: number): string;
|
|
790
792
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
*
|
|
794
|
-
* Lets an SDK embedder (KodaX-Space) compact a session by id immediately —
|
|
795
|
-
* e.g. when the user clicks a "/compact" button — instead of forging a token
|
|
796
|
-
* snapshot or appending an empty message to trip auto-compaction. Loads the
|
|
797
|
-
* session, runs the same `compact()` pass the REPL `/compact` command uses,
|
|
798
|
-
* applies the result to the session lineage (so `loadFullTranscript` / resume
|
|
799
|
-
* see the compaction entry), and writes it back.
|
|
800
|
-
*
|
|
801
|
-
* Applies uniformly to Partner and Coder sessions. Never throws — failures
|
|
802
|
-
* return `{ compacted: false, reason }`.
|
|
803
|
-
*/
|
|
804
|
-
|
|
805
|
-
interface CompactSessionOptions {
|
|
806
|
-
/** Provider alias for the summarizer. Defaults to the session's persisted provider, then 'anthropic'. */
|
|
807
|
-
readonly provider?: string;
|
|
808
|
-
/** Model override forwarded to the summarizer. */
|
|
809
|
-
readonly model?: string;
|
|
810
|
-
/** Custom summarizer instructions (same as `/compact <text>`). */
|
|
811
|
-
readonly customInstructions?: string;
|
|
812
|
-
/** Provider context-window override (tokens). Otherwise resolved from the provider/model. */
|
|
813
|
-
readonly contextWindow?: number;
|
|
814
|
-
/** Sessions directory (mirrors createSessionManager's override). */
|
|
815
|
-
readonly sessionsDir?: string;
|
|
816
|
-
/** Injected storage instance (takes precedence over sessionsDir). */
|
|
817
|
-
readonly storage?: FileSessionStorage;
|
|
818
|
-
}
|
|
819
|
-
interface CompactSessionResult {
|
|
820
|
-
/** True when the session was actually rewritten. */
|
|
821
|
-
readonly compacted: boolean;
|
|
822
|
-
readonly tokensBefore: number;
|
|
823
|
-
readonly tokensAfter: number;
|
|
824
|
-
/** The rewritten (or unchanged) message list. */
|
|
825
|
-
readonly messages: KodaXMessage[];
|
|
826
|
-
/** Populated when `compacted` is false to explain why (not-found / no-op / error). */
|
|
827
|
-
readonly reason?: string;
|
|
828
|
-
}
|
|
829
|
-
/**
|
|
830
|
-
* Compact a session by id, writing the result (lineage + messages) back to
|
|
831
|
-
* storage. Never throws.
|
|
832
|
-
*/
|
|
833
|
-
declare function compactSession(sessionId: string, options?: CompactSessionOptions): Promise<CompactSessionResult>;
|
|
834
|
-
|
|
835
|
-
/**
|
|
836
|
-
* FEATURE_173 Part B (v0.7.42) — Session Management Public SDK.
|
|
837
|
-
*
|
|
838
|
-
* Thin facades over FileSessionStorage + discoverInstances. All methods
|
|
839
|
-
* NEVER throw — missing sessions return null, blocked operations return
|
|
840
|
-
* an error envelope, missing directories return empty arrays / no-op
|
|
841
|
-
* watchers.
|
|
842
|
-
*
|
|
843
|
-
* The `@kodax-ai/kodax/session` SDK subpath re-exports this module.
|
|
844
|
-
*/
|
|
845
|
-
|
|
846
|
-
interface SessionSummary {
|
|
847
|
-
readonly id: string;
|
|
848
|
-
readonly title: string;
|
|
849
|
-
readonly msgCount: number;
|
|
850
|
-
readonly tag?: string;
|
|
851
|
-
readonly createdAt?: string;
|
|
852
|
-
readonly runtimeInfo?: {
|
|
853
|
-
workspaceRoot?: string;
|
|
854
|
-
gitRoot?: string;
|
|
855
|
-
surface?: string;
|
|
856
|
-
profileId?: string;
|
|
857
|
-
};
|
|
858
|
-
/**
|
|
859
|
-
* FEATURE_219 (v0.7.46) — the per-project directory key this session lives
|
|
860
|
-
* under (ADR-038 §7). A backward-compatible hint: consumers may pass it back
|
|
861
|
-
* for precise disambiguation, but `loadSession(id)` works without it.
|
|
862
|
-
*/
|
|
863
|
-
readonly projectKey?: string;
|
|
864
|
-
/** FEATURE_219 — true when the session is whole-session archived (only ever
|
|
865
|
-
* surfaced when `includeArchived` is set). */
|
|
866
|
-
readonly archived?: boolean;
|
|
867
|
-
}
|
|
868
|
-
type SessionTranscriptEntryType = 'message' | 'compaction' | 'branch_summary'
|
|
869
|
-
/** Rewind audit marker; not included in `FullTranscriptSessionData.messages`. */
|
|
870
|
-
| 'rewind_marker' | 'client_notice'
|
|
871
|
-
/**
|
|
872
|
-
* Synthetic task/workflow completion entry derived from `_taskResult`,
|
|
873
|
-
* `_taskResults`, or legacy `<task-completed>` banners. The original
|
|
874
|
-
* `KodaXMessage` is still exposed on `message`, but consumers that want a
|
|
875
|
-
* complete transcript should not filter only `type === 'message'`.
|
|
876
|
-
*/
|
|
877
|
-
| 'task_result';
|
|
878
|
-
type SessionTranscriptEntrySource = 'user' | 'assistant' | 'workflow' | 'child_task' | 'system' | 'client';
|
|
879
|
-
interface SessionTranscriptEntry {
|
|
880
|
-
readonly entryId: string;
|
|
881
|
-
readonly parentId: string | null;
|
|
882
|
-
/** Stable logical identity shared by cloned/forked copies of the same entry. */
|
|
883
|
-
readonly logicalId: string;
|
|
884
|
-
/** Root source physical entry id when this transcript entry was cloned/forked. */
|
|
885
|
-
readonly sourceEntryId?: string;
|
|
886
|
-
readonly timestamp: string;
|
|
887
|
-
readonly type: SessionTranscriptEntryType;
|
|
888
|
-
readonly source?: SessionTranscriptEntrySource;
|
|
889
|
-
readonly turnId?: string;
|
|
890
|
-
readonly message: KodaXMessage;
|
|
891
|
-
readonly active: boolean;
|
|
892
|
-
readonly summary?: string;
|
|
893
|
-
readonly payload?: unknown;
|
|
894
|
-
readonly taskResults?: readonly KodaXTaskResultMetadata[];
|
|
895
|
-
}
|
|
896
|
-
interface FullTranscriptSessionData extends Omit<SessionData, 'messages'> {
|
|
897
|
-
readonly messages: KodaXMessage[];
|
|
898
|
-
readonly activeMessages: KodaXMessage[];
|
|
899
|
-
readonly transcriptEntries: SessionTranscriptEntry[];
|
|
900
|
-
}
|
|
901
|
-
interface AppendClientNoticeOptions {
|
|
902
|
-
readonly source?: string;
|
|
903
|
-
readonly content: string;
|
|
904
|
-
readonly timestamp?: string;
|
|
905
|
-
readonly turnId?: string;
|
|
906
|
-
readonly payload?: KodaXJsonValue;
|
|
907
|
-
}
|
|
908
|
-
interface ListSessionsOptions {
|
|
909
|
-
/**
|
|
910
|
-
* Alias for gitRoot; backwards-compat with KodaX Space terminology.
|
|
911
|
-
* When provided, list() is scoped to sessions from this project root.
|
|
912
|
-
*/
|
|
913
|
-
readonly projectRoot?: string;
|
|
914
|
-
/**
|
|
915
|
-
* Which session scopes to include.
|
|
916
|
-
* - 'user' (default): only user-initiated sessions.
|
|
917
|
-
* - 'managed-task-worker': only managed-task worker sessions.
|
|
918
|
-
* - 'all': no scope filter.
|
|
919
|
-
*/
|
|
920
|
-
readonly scope?: 'user' | 'managed-task-worker' | 'all';
|
|
921
|
-
/**
|
|
922
|
-
* Whether to include whole-session-archived sessions. FEATURE_219 (v0.7.46):
|
|
923
|
-
* archived sessions live in `<projectKey>/archived/` (see `archiveSession`);
|
|
924
|
-
* also still hides the legacy `archived-` filename prefix. Default false.
|
|
925
|
-
*/
|
|
926
|
-
readonly includeArchived?: boolean;
|
|
927
|
-
/** Maximum number of sessions to return. Default 50. */
|
|
928
|
-
readonly limit?: number;
|
|
929
|
-
/**
|
|
930
|
-
* ISO date string — return only sessions whose createdAt is before this
|
|
931
|
-
* timestamp. Applied after list + scope filtering.
|
|
932
|
-
*/
|
|
933
|
-
readonly before?: string;
|
|
934
|
-
/** Exact match. Omitted means no tag filter. */
|
|
935
|
-
readonly tag?: string;
|
|
936
|
-
}
|
|
937
|
-
type WatchSessionsCallback = (event: {
|
|
938
|
-
kind: 'change' | 'add' | 'remove';
|
|
939
|
-
sessionId: string;
|
|
940
|
-
}) => void;
|
|
941
|
-
interface SessionManager {
|
|
942
|
-
listSessions: typeof listSessions;
|
|
943
|
-
loadSession: typeof loadSession;
|
|
944
|
-
loadFullTranscript: typeof loadFullTranscript;
|
|
945
|
-
appendClientNotice: typeof appendClientNotice;
|
|
946
|
-
forkSession: typeof forkSession;
|
|
947
|
-
rewindSession: typeof rewindSession;
|
|
948
|
-
setActiveEntry: typeof setActiveEntry;
|
|
949
|
-
deleteSession: typeof deleteSession;
|
|
950
|
-
archiveSession: typeof archiveSession;
|
|
951
|
-
unarchiveSession: typeof unarchiveSession;
|
|
952
|
-
listRunningSessions: typeof listRunningSessions;
|
|
953
|
-
watchSessions: typeof watchSessions;
|
|
954
|
-
/** FEATURE_247 (R6) — imperatively compact a session by id (writes lineage + emits nothing; returns stats). */
|
|
955
|
-
compactSession: typeof compactSession;
|
|
956
|
-
/**
|
|
957
|
-
* v0.7.43 — the raw write-side storage instance. SDK embedders pass
|
|
958
|
-
* this into `runKodaX({ session: { id, scope, storage } })` so the
|
|
959
|
-
* SA / AMA loops write per-turn JSONL snapshots to disk. Without an
|
|
960
|
-
* injected storage, `saveSessionSnapshot` is a silent no-op and the
|
|
961
|
-
* sessions directory stays empty regardless of `session.id`.
|
|
962
|
-
*
|
|
963
|
-
* See {@link FileSessionStorage} for the concrete implementation and
|
|
964
|
-
* `docs/SDK_EMBEDDER_GUIDE.md` §6 for the end-to-end recipe.
|
|
965
|
-
*/
|
|
966
|
-
storage: FileSessionStorage;
|
|
967
|
-
}
|
|
968
|
-
/**
|
|
969
|
-
* List sessions, optionally filtered by scope, limit, and date.
|
|
970
|
-
* NEVER throws. Returns [] when the sessions directory is empty or missing.
|
|
971
|
-
*/
|
|
972
|
-
declare function listSessions(opts?: ListSessionsOptions): Promise<SessionSummary[]>;
|
|
973
|
-
/**
|
|
974
|
-
* Load full session data by ID.
|
|
975
|
-
* Returns null for a missing session. NEVER throws.
|
|
976
|
-
*/
|
|
977
|
-
declare function loadSession(id: string): Promise<SessionData | null>;
|
|
978
|
-
/**
|
|
979
|
-
* Load append-order transcript data by ID.
|
|
980
|
-
*
|
|
981
|
-
* `loadSession` remains the active model-context API. This helper is for UI
|
|
982
|
-
* scrollback: it returns every persisted transcript-bearing lineage entry in
|
|
983
|
-
* append order and keeps the active branch in `activeMessages`.
|
|
984
|
-
*/
|
|
985
|
-
declare function loadFullTranscript(id: string): Promise<FullTranscriptSessionData | null>;
|
|
986
|
-
/**
|
|
987
|
-
* Append a host-owned transcript notice that never enters model context.
|
|
988
|
-
*
|
|
989
|
-
* Use this for local slash-command output such as `/doctor`, `/mcp status`,
|
|
990
|
-
* or host-side status panes. It is visible through `loadFullTranscript()` but
|
|
991
|
-
* `loadSession()` keeps returning only the active model messages.
|
|
992
|
-
*/
|
|
993
|
-
declare function appendClientNotice(id: string, options: AppendClientNoticeOptions): Promise<SessionTranscriptEntry | null>;
|
|
994
|
-
/**
|
|
995
|
-
* Fork a session at an optional selector.
|
|
996
|
-
* Returns null for a missing session. NEVER throws.
|
|
997
|
-
*/
|
|
998
|
-
declare function forkSession(id: string, opts?: {
|
|
999
|
-
selector?: string;
|
|
1000
|
-
sessionId?: string;
|
|
1001
|
-
title?: string;
|
|
1002
|
-
}): Promise<{
|
|
1003
|
-
sessionId: string;
|
|
1004
|
-
data: SessionData;
|
|
1005
|
-
} | null>;
|
|
1006
|
-
/**
|
|
1007
|
-
* Rewind a session to a previous user entry.
|
|
1008
|
-
* Returns null for a missing session. NEVER throws.
|
|
1009
|
-
*/
|
|
1010
|
-
declare function rewindSession(id: string, opts?: {
|
|
1011
|
-
selector?: string;
|
|
1012
|
-
}): Promise<SessionData | null>;
|
|
1013
|
-
/**
|
|
1014
|
-
* Set the active lineage entry by selector.
|
|
1015
|
-
* Returns null for a missing session. NEVER throws.
|
|
1016
|
-
*/
|
|
1017
|
-
declare function setActiveEntry(id: string, selector: string): Promise<SessionData | null>;
|
|
1018
|
-
interface RunningSessionInfo {
|
|
1019
|
-
readonly pid: number;
|
|
1020
|
-
readonly startedAt: number;
|
|
1021
|
-
readonly cwd: string;
|
|
1022
|
-
/**
|
|
1023
|
-
* v0.7.43 — populated from `PersistedSessionState.sessionId`, published
|
|
1024
|
-
* by the REPL after `createInteractiveContext`. Remains `undefined` for
|
|
1025
|
-
* a brief window during a peer's bootstrap (before the first sessionId
|
|
1026
|
-
* is generated) and for peers running pre-v0.7.43 binaries; consumers
|
|
1027
|
-
* MUST handle `undefined`.
|
|
1028
|
-
*/
|
|
1029
|
-
readonly sessionId: string | undefined;
|
|
1030
|
-
}
|
|
1031
|
-
/**
|
|
1032
|
-
* Returns live KodaX sibling instances (excluding this process).
|
|
1033
|
-
* Uses discoverInstances() from @kodax-ai/agent (FEATURE_125 Team Mode).
|
|
1034
|
-
* NEVER throws. Returns [] when no instances directory exists.
|
|
1035
|
-
*/
|
|
1036
|
-
declare function listRunningSessions(): Promise<RunningSessionInfo[]>;
|
|
1037
|
-
type DeleteSessionResult = {
|
|
1038
|
-
ok: true;
|
|
1039
|
-
} | {
|
|
1040
|
-
error: {
|
|
1041
|
-
code: 'session_running';
|
|
1042
|
-
runningProcess: {
|
|
1043
|
-
pid: number;
|
|
1044
|
-
startedAt: number;
|
|
1045
|
-
};
|
|
1046
|
-
};
|
|
1047
|
-
};
|
|
1048
|
-
/**
|
|
1049
|
-
* Delete a session by ID.
|
|
1050
|
-
* Returns { ok: true } on success (including when the session doesn't exist).
|
|
1051
|
-
* Returns an error envelope when the session is currently running.
|
|
1052
|
-
* NEVER throws.
|
|
1053
|
-
*/
|
|
1054
|
-
declare function deleteSession(id: string): Promise<DeleteSessionResult>;
|
|
1055
|
-
/**
|
|
1056
|
-
* FEATURE_219 (v0.7.46) — whole-session archive. Moves the session (and its
|
|
1057
|
-
* island sidecar) into `<projectKey>/archived/`. Returns false for a missing
|
|
1058
|
-
* session. NEVER throws. Archived sessions are hidden from the default listing
|
|
1059
|
-
* and resurface only with `listSessions({ includeArchived: true })`.
|
|
1060
|
-
*/
|
|
1061
|
-
declare function archiveSession(id: string): Promise<boolean>;
|
|
1062
|
-
/** Restore an archived session back into its project directory. NEVER throws. */
|
|
1063
|
-
declare function unarchiveSession(id: string): Promise<boolean>;
|
|
1064
|
-
/**
|
|
1065
|
-
* Watch the sessions directory for changes.
|
|
1066
|
-
* Returns { close() } that stops the watcher / poll interval.
|
|
1067
|
-
*
|
|
1068
|
-
* Platform branches:
|
|
1069
|
-
* - POSIX: fs.watch() with 100ms debounce.
|
|
1070
|
-
* - Windows: readdir poll every 1000ms, diffed against a snapshot.
|
|
1071
|
-
*
|
|
1072
|
-
* NEVER throws — if the directory doesn't exist the watcher is a no-op
|
|
1073
|
-
* until the directory is created.
|
|
1074
|
-
*/
|
|
1075
|
-
declare function watchSessions(cb: WatchSessionsCallback): {
|
|
1076
|
-
close: () => void;
|
|
1077
|
-
};
|
|
1078
|
-
/**
|
|
1079
|
-
* Factory that returns an object with all session management methods bound.
|
|
1080
|
-
*
|
|
1081
|
-
* v0.7.43 (FEATURE_173 Part B follow-up) — the `sessionsDir` override is
|
|
1082
|
-
* now honored. When provided, all read/write/watch operations go through
|
|
1083
|
-
* that directory instead of the module-load-frozen `KODAX_SESSIONS_DIR`.
|
|
1084
|
-
* `listRunningSessions` still consults the agent-config-home instances
|
|
1085
|
-
* directory (sibling-process awareness is not scoped per sessions dir).
|
|
1086
|
-
*/
|
|
1087
|
-
declare function createSessionManager(opts?: {
|
|
1088
|
-
sessionsDir?: string;
|
|
1089
|
-
}): SessionManager;
|
|
1090
|
-
|
|
1091
|
-
export { DEFAULT_UI_STATE as D, StreamingState as U, TOOL_STATUS_ICONS as W, TextBuffer as X, ToolCallStatus as a1, appendClientNotice as a8, archiveSession as a9, compactSession as aa, createSessionManager as ab, deleteSession as ac, extractHistorySeedsFromMessage as ad, extractHistorySeedsFromMessages as ae, extractTextContent as af, extractTitle as ag, forkSession as ah, formatMessagePreview as ai, listRunningSessions as aj, listSessions as ak, loadFullTranscript as al, loadSession as am, restoreHistoryItemsFromSession as an, rewindSession as ao, seedToHistoryItem as ap, setActiveEntry as aq, toolCallSeedToHistoryToolCall as ar, trimPersistedUiHistorySnapshot as as, unarchiveSession as at, watchSessions as au, KeypressHandlerPriority as y };
|
|
1092
|
-
export type { ThemeSymbols as $, AppProps as A, PromptEditingMode as B, CompactSessionOptions as C, PromptSubmitPayload as E, FullTranscriptSessionData as F, RestoredHistorySeed as G, HistoryEntry as H, InputPromptProps as I, RunningSessionInfo as J, KeyInfo as K, LegacyMessageListProps as L, Message as M, SessionSummary as N, SessionTranscriptEntry as O, PastedContent as P, SessionTranscriptEntryType as Q, RestoreHistoryItemsFromSessionInput as R, SessionManager as S, StatusBarProps as T, Suggestion as V, TextBufferOptions as Y, Theme as Z, ThemeColors as _, AppState as a, ToolCall as a0, UIActions as a2, UIState as a3, UseTextBufferReturn as a4, VisualCursor as a5, VisualLayout as a6, WatchSessionsCallback as a7, AppendClientNoticeOptions as b, CompactSessionResult as c, Completer as d, Completion as e, CreatableHistoryItem as f, CursorPosition as g, DeleteSessionResult as h, HistoryItem as i, HistoryItemAssistant as j, HistoryItemBase as k, HistoryItemError as l, HistoryItemEvent as m, HistoryItemHint as n, HistoryItemInfo as o, HistoryItemSidecar as p, HistoryItemSystem as q, HistoryItemThinking as r, HistoryItemToolGroup as s, HistoryItemType as t, HistoryItemUser as u, HistorySeedSourceMessage as v, KeypressEvent as w, KeypressHandler as x, ListSessionsOptions as z };
|
|
793
|
+
export { extractTitle as $, TextBuffer as B, DEFAULT_UI_STATE as D, ToolCallStatus as O, TOOL_STATUS_ICONS as T, extractHistorySeedsFromMessage as Y, extractHistorySeedsFromMessages as Z, extractTextContent as _, formatMessagePreview as a0, restoreHistoryItemsFromSession as a1, seedToHistoryItem as a2, toolCallSeedToHistoryToolCall as a3, trimPersistedUiHistorySnapshot as a4, KeypressHandlerPriority as u, StreamingState as y };
|
|
794
|
+
export type { AppProps as A, Completer as C, TextBufferOptions as E, Theme as F, ThemeColors as G, HistoryEntry as H, InputPromptProps as I, ThemeSymbols as J, KeyInfo as K, LegacyMessageListProps as L, Message as M, ToolCall as N, PastedContent as P, UIState as Q, RestoreHistoryItemsFromSessionInput as R, StatusBarProps as S, UIActions as U, UseTextBufferReturn as V, VisualCursor as W, VisualLayout as X, AppState as a, Completion as b, CreatableHistoryItem as c, CursorPosition as d, HistoryItem as e, HistoryItemAssistant as f, HistoryItemBase as g, HistoryItemError as h, HistoryItemEvent as i, HistoryItemHint as j, HistoryItemInfo as k, HistoryItemSidecar as l, HistoryItemSystem as m, HistoryItemThinking as n, HistoryItemToolGroup as o, HistoryItemType as p, HistoryItemUser as q, HistorySeedSourceMessage as r, KeypressEvent as s, KeypressHandler as t, PromptEditingMode as v, PromptSubmitPayload as w, RestoredHistorySeed as x, Suggestion as z };
|