@botiverse/kimi-code-sdk 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +1 -1
- package/README.md +1 -1
- package/dist/index.d.mts +102 -27
- package/dist/index.mjs +13466 -1961
- package/dist/lib-uthR5TlF.mjs +1238 -0
- package/package.json +3 -3
package/NOTICE.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# NOTICE
|
|
2
2
|
|
|
3
3
|
@botiverse/kimi-code-sdk is a repackage of the built **@moonshot-ai/kimi-code-sdk** node-sdk
|
|
4
|
-
from [MoonshotAI/kimi-code](https://github.com/MoonshotAI/kimi-code) at `@moonshot-ai/kimi-code@0.
|
|
4
|
+
from [MoonshotAI/kimi-code](https://github.com/MoonshotAI/kimi-code) at `@moonshot-ai/kimi-code@0.17.0`, distributed under upstream's MIT License (see LICENSE). Sibling packages are bundled into `dist`.
|
|
5
5
|
Mirror + provenance: https://github.com/botiverse/kimi-code-sdk
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @botiverse/kimi-code-sdk
|
|
2
2
|
|
|
3
|
-
Built repackage of `@moonshot-ai/kimi-code-sdk` (kimi-code @moonshot-ai/kimi-code@0.
|
|
3
|
+
Built repackage of `@moonshot-ai/kimi-code-sdk` (kimi-code @moonshot-ai/kimi-code@0.17.0) for Slock/Botiverse.
|
|
4
4
|
Read-only mirror + release notes: https://github.com/botiverse/kimi-code-sdk
|
|
5
5
|
|
|
6
6
|
> Not affiliated with Moonshot AI. MIT (see LICENSE).
|
package/dist/index.d.mts
CHANGED
|
@@ -78,6 +78,7 @@ declare class Agent {
|
|
|
78
78
|
readonly log: Logger;
|
|
79
79
|
readonly telemetry: TelemetryClient;
|
|
80
80
|
readonly experimentalFlags: ExperimentalFlagResolver;
|
|
81
|
+
readonly llmRequestLogger: LlmRequestLogger;
|
|
81
82
|
readonly blobStore: BlobStore | undefined;
|
|
82
83
|
readonly records: AgentRecords;
|
|
83
84
|
readonly fullCompaction: FullCompaction;
|
|
@@ -96,15 +97,12 @@ declare class Agent {
|
|
|
96
97
|
readonly cron: CronManager | null;
|
|
97
98
|
readonly goal: GoalMode;
|
|
98
99
|
readonly replayBuilder: ReplayBuilder;
|
|
99
|
-
private lastLlmConfigLogSignature?;
|
|
100
100
|
constructor(options: AgentOptions);
|
|
101
101
|
setKaos(kaos: Kaos): void;
|
|
102
102
|
get generate(): typeof generate;
|
|
103
103
|
get llm(): KosongLLM;
|
|
104
|
-
private logLlmRequest;
|
|
105
|
-
private logLlmConfigIfChanged;
|
|
106
104
|
useProfile(profile: ResolvedAgentProfile, context?: PreparedSystemPromptContext): void;
|
|
107
|
-
resume(): Promise<{
|
|
105
|
+
resume(options?: AgentRecordsReplayOptions): Promise<{
|
|
108
106
|
warning?: string;
|
|
109
107
|
}>;
|
|
110
108
|
get rpcMethods(): PromisableMethods<AgentAPI>;
|
|
@@ -215,6 +213,7 @@ declare interface AgentOptions {
|
|
|
215
213
|
readonly telemetry?: TelemetryClient | undefined;
|
|
216
214
|
readonly pluginSessionStarts?: readonly EnabledPluginSessionStart[];
|
|
217
215
|
readonly experimentalFlags?: ExperimentalFlagResolver;
|
|
216
|
+
readonly replay?: ReplayBuilderOptions;
|
|
218
217
|
}
|
|
219
218
|
|
|
220
219
|
declare type AgentRecord = {
|
|
@@ -326,13 +325,17 @@ declare class AgentRecords {
|
|
|
326
325
|
constructor(agent: Agent, persistence?: AgentRecordPersistence | undefined);
|
|
327
326
|
get restoring(): RestoringContext | null;
|
|
328
327
|
logRecord(record: AgentRecord): void;
|
|
329
|
-
restore(record: AgentRecord):
|
|
330
|
-
replay(): Promise<{
|
|
328
|
+
restore(record: AgentRecord): boolean;
|
|
329
|
+
replay(options?: AgentRecordsReplayOptions): Promise<{
|
|
331
330
|
warning?: string;
|
|
332
331
|
}>;
|
|
333
332
|
flush(): Promise<void>;
|
|
334
333
|
}
|
|
335
334
|
|
|
335
|
+
declare interface AgentRecordsReplayOptions {
|
|
336
|
+
readonly rewriteMigratedRecords?: boolean;
|
|
337
|
+
}
|
|
338
|
+
|
|
336
339
|
export declare type AgentReplayRecord = {
|
|
337
340
|
readonly time: number;
|
|
338
341
|
} & AgentReplayRecordPayload;
|
|
@@ -448,6 +451,10 @@ declare interface ApprovalResponse_2 {
|
|
|
448
451
|
|
|
449
452
|
export declare type ApprovalScope = 'session';
|
|
450
453
|
|
|
454
|
+
declare interface ArchiveSessionPayload {
|
|
455
|
+
readonly sessionId: string;
|
|
456
|
+
}
|
|
457
|
+
|
|
451
458
|
export { AssistantDeltaEvent }
|
|
452
459
|
|
|
453
460
|
declare interface AudioURLPart {
|
|
@@ -900,6 +907,13 @@ declare interface ChatProvider {
|
|
|
900
907
|
uploadVideo?(input: string | VideoUploadInput, options?: GenerateOptions): Promise<VideoURLPart>;
|
|
901
908
|
}
|
|
902
909
|
|
|
910
|
+
declare interface ClientTelemetryInfo {
|
|
911
|
+
readonly id?: string | undefined;
|
|
912
|
+
readonly name?: string | undefined;
|
|
913
|
+
readonly version?: string | undefined;
|
|
914
|
+
readonly uiMode?: string | undefined;
|
|
915
|
+
}
|
|
916
|
+
|
|
903
917
|
declare interface ClockSources {
|
|
904
918
|
/**
|
|
905
919
|
* Wall-clock epoch milliseconds. May be overridden in tests / bench
|
|
@@ -918,10 +932,6 @@ declare interface CloseSessionPayload {
|
|
|
918
932
|
readonly sessionId: string;
|
|
919
933
|
}
|
|
920
934
|
|
|
921
|
-
declare interface CompactedHistory {
|
|
922
|
-
text: string;
|
|
923
|
-
}
|
|
924
|
-
|
|
925
935
|
declare interface CompactionBeginData {
|
|
926
936
|
instruction?: string;
|
|
927
937
|
source: CompactionSource;
|
|
@@ -957,8 +967,6 @@ declare interface CompactionSummaryOrigin {
|
|
|
957
967
|
readonly kind: 'compaction_summary';
|
|
958
968
|
}
|
|
959
969
|
|
|
960
|
-
declare type CompactionTelemetryTrigger = CompactionBeginData['source'] | 'manual-with-prompt' | 'unknown';
|
|
961
|
-
|
|
962
970
|
export declare interface CompactOptions {
|
|
963
971
|
readonly instruction?: string | undefined;
|
|
964
972
|
}
|
|
@@ -1058,6 +1066,7 @@ declare interface CoreAPI extends SessionAPIWithId {
|
|
|
1058
1066
|
removeKimiProvider: (payload: RemoveKimiProviderPayload) => KimiConfig;
|
|
1059
1067
|
createSession: (payload: CreateSessionPayload) => SessionSummary_2;
|
|
1060
1068
|
closeSession: (payload: CloseSessionPayload) => void;
|
|
1069
|
+
archiveSession: (payload: ArchiveSessionPayload) => void;
|
|
1061
1070
|
resumeSession: (payload: ResumeSessionPayload) => ResumeSessionResult;
|
|
1062
1071
|
reloadSession: (payload: ReloadSessionPayload) => ResumeSessionResult;
|
|
1063
1072
|
forkSession: (payload: ForkSessionPayload) => ResumeSessionResult;
|
|
@@ -1125,6 +1134,7 @@ declare interface CreateSessionPayload {
|
|
|
1125
1134
|
readonly permission?: PermissionMode_2 | undefined;
|
|
1126
1135
|
readonly metadata?: JsonObject_2 | undefined;
|
|
1127
1136
|
readonly mcpServers?: Readonly<Record<string, McpServerConfig>>;
|
|
1137
|
+
readonly client?: ClientTelemetryInfo | undefined;
|
|
1128
1138
|
}
|
|
1129
1139
|
|
|
1130
1140
|
export { CronFiredEvent }
|
|
@@ -1833,20 +1843,14 @@ declare class FullCompaction {
|
|
|
1833
1843
|
protected compactionCountInTurn: number;
|
|
1834
1844
|
protected compacting: {
|
|
1835
1845
|
abortController: AbortController;
|
|
1836
|
-
startedAt: number;
|
|
1837
|
-
telemetryTrigger: CompactionTelemetryTrigger;
|
|
1838
1846
|
promise: Promise<void>;
|
|
1839
1847
|
blockedByTurn: boolean;
|
|
1840
1848
|
} | null;
|
|
1841
|
-
protected _compactedHistory: CompactedHistory[];
|
|
1842
1849
|
protected readonly strategy: CompactionStrategy;
|
|
1843
1850
|
constructor(agent: Agent, strategy?: CompactionStrategy);
|
|
1844
1851
|
get isCompacting(): boolean;
|
|
1845
|
-
get compactedHistory(): readonly CompactedHistory[];
|
|
1846
1852
|
begin(data: Readonly<CompactionBeginData>): void;
|
|
1847
|
-
private startCompactionWorker;
|
|
1848
1853
|
cancel(): void;
|
|
1849
|
-
private markCanceled;
|
|
1850
1854
|
markCompleted(): void;
|
|
1851
1855
|
private get tokenCountWithPending();
|
|
1852
1856
|
resetForTurn(): void;
|
|
@@ -1857,6 +1861,7 @@ declare class FullCompaction {
|
|
|
1857
1861
|
private beginAutoCompaction;
|
|
1858
1862
|
private block;
|
|
1859
1863
|
private compactionWorker;
|
|
1864
|
+
private compactionRound;
|
|
1860
1865
|
private triggerPreCompactHook;
|
|
1861
1866
|
private triggerPostCompactHook;
|
|
1862
1867
|
private postProcessSummary;
|
|
@@ -2529,6 +2534,8 @@ declare interface KaosProcess {
|
|
|
2529
2534
|
wait(): Promise<number>;
|
|
2530
2535
|
/** Send a signal to the process (defaults to `SIGTERM`). */
|
|
2531
2536
|
kill(signal?: NodeJS.Signals): Promise<void>;
|
|
2537
|
+
/** Release stdin/stdout/stderr resources owned by this process wrapper. */
|
|
2538
|
+
dispose(): Promise<void> | void;
|
|
2532
2539
|
}
|
|
2533
2540
|
|
|
2534
2541
|
export declare const KIMI_ERROR_INFO: {
|
|
@@ -3260,6 +3267,7 @@ declare class KimiCore implements PromisableMethods<CoreAPI> {
|
|
|
3260
3267
|
getCoreInfo(): CoreInfo;
|
|
3261
3268
|
getExperimentalFeatures(): readonly ExperimentalFeatureState[];
|
|
3262
3269
|
closeSession({ sessionId }: CloseSessionPayload): Promise<void>;
|
|
3270
|
+
archiveSession({ sessionId }: ArchiveSessionPayload): Promise<void>;
|
|
3263
3271
|
resumeSession(input: ResumeSessionPayload): Promise<ResumeSessionResult>;
|
|
3264
3272
|
resumeSessionWithOverrides(input: ResumeSessionPayload, overrides: {
|
|
3265
3273
|
kaos?: Kaos;
|
|
@@ -3531,7 +3539,6 @@ declare class KosongLLM implements LLM {
|
|
|
3531
3539
|
|
|
3532
3540
|
declare interface KosongLLMConfig {
|
|
3533
3541
|
readonly provider: ChatProvider;
|
|
3534
|
-
readonly modelName: string;
|
|
3535
3542
|
readonly systemPrompt: string;
|
|
3536
3543
|
readonly capability?: ModelCapability | undefined;
|
|
3537
3544
|
/**
|
|
@@ -3555,6 +3562,7 @@ export declare interface ListSessionsOptions {
|
|
|
3555
3562
|
declare interface ListSessionsPayload {
|
|
3556
3563
|
readonly workDir?: string;
|
|
3557
3564
|
readonly sessionId?: string;
|
|
3565
|
+
readonly includeArchive?: boolean;
|
|
3558
3566
|
}
|
|
3559
3567
|
|
|
3560
3568
|
declare interface LLM {
|
|
@@ -3569,7 +3577,7 @@ declare interface LLMChatParams {
|
|
|
3569
3577
|
messages: Message[];
|
|
3570
3578
|
tools: readonly Tool[];
|
|
3571
3579
|
signal: AbortSignal;
|
|
3572
|
-
|
|
3580
|
+
requestLogFields?: LLMRequestLogFields;
|
|
3573
3581
|
onTextDelta?: ((delta: string) => void) | undefined;
|
|
3574
3582
|
onThinkDelta?: ((delta: string) => void) | undefined;
|
|
3575
3583
|
onToolCallDelta?: ((delta: ToolCallDelta) => void) | undefined;
|
|
@@ -3597,12 +3605,23 @@ declare interface LLMChatResponse {
|
|
|
3597
3605
|
streamTiming?: LLMStreamTiming;
|
|
3598
3606
|
}
|
|
3599
3607
|
|
|
3600
|
-
declare interface
|
|
3601
|
-
readonly
|
|
3602
|
-
readonly
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3608
|
+
declare interface LLMRequestLogFields {
|
|
3609
|
+
readonly turnStep: string;
|
|
3610
|
+
readonly attempt?: string;
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
declare class LlmRequestLogger {
|
|
3614
|
+
private readonly log;
|
|
3615
|
+
private lastConfigLogSignature;
|
|
3616
|
+
constructor(log: Logger);
|
|
3617
|
+
logRequest(input: {
|
|
3618
|
+
readonly provider: ChatProvider;
|
|
3619
|
+
readonly modelAlias?: string;
|
|
3620
|
+
readonly systemPrompt: string;
|
|
3621
|
+
readonly tools: readonly Tool[];
|
|
3622
|
+
readonly messages: readonly Message[];
|
|
3623
|
+
readonly fields: LLMRequestLogFields | undefined;
|
|
3624
|
+
}): void;
|
|
3606
3625
|
}
|
|
3607
3626
|
|
|
3608
3627
|
declare interface LLMStreamTiming {
|
|
@@ -3617,6 +3636,17 @@ declare interface LLMStreamTiming {
|
|
|
3617
3636
|
*/
|
|
3618
3637
|
export declare function loadBuiltInCatalog(text?: string): Catalog | undefined;
|
|
3619
3638
|
|
|
3639
|
+
/**
|
|
3640
|
+
* Lenient variant of `loadRuntimeConfig` that never throws: schema errors
|
|
3641
|
+
* drop only the offending sections (whole entry for `providers`/`models`,
|
|
3642
|
+
* whole top-level section otherwise) and a bad KIMI_MODEL_* env overlay is
|
|
3643
|
+
* skipped, each reported as a warning. A file that cannot be used at all
|
|
3644
|
+
* additionally sets `fileError` so startup can fail fast while mid-run
|
|
3645
|
+
* reloads degrade. Runtime read paths use this; write paths must keep using
|
|
3646
|
+
* the strict readers so a broken file is never silently rewritten.
|
|
3647
|
+
*/
|
|
3648
|
+
export declare function loadRuntimeConfigSafe(filePath: string, env?: Readonly<Record<string, string | undefined>>): RuntimeConfigLoadResult;
|
|
3649
|
+
|
|
3620
3650
|
/**
|
|
3621
3651
|
* Root logger. Import and use directly for events that don't belong to any
|
|
3622
3652
|
* session (CLI startup, harness construction, etc.):
|
|
@@ -4798,18 +4828,37 @@ declare type RenameSessionRequest = SessionScopedPayload<RenameSessionPayload>;
|
|
|
4798
4828
|
|
|
4799
4829
|
declare class ReplayBuilder {
|
|
4800
4830
|
readonly agent: Agent;
|
|
4831
|
+
private readonly options;
|
|
4801
4832
|
postRestoring: boolean;
|
|
4802
4833
|
captureLiveRecords: boolean;
|
|
4803
4834
|
protected readonly records: AgentReplayRecord[];
|
|
4804
|
-
|
|
4835
|
+
private frozen;
|
|
4836
|
+
private segmentStart;
|
|
4837
|
+
constructor(agent: Agent, options?: ReplayBuilderOptions);
|
|
4805
4838
|
push(record: AgentReplayRecordPayload): void;
|
|
4806
4839
|
patchLast<T extends AgentReplayRecord['type']>(type: T, patch: Partial<Extract<AgentReplayRecord, {
|
|
4807
4840
|
type: T;
|
|
4808
4841
|
}>>): void;
|
|
4809
4842
|
removeLastMessages(removedMessages: ReadonlySet<ContextMessage>): void;
|
|
4843
|
+
finishRestoringRecord(type: string): boolean;
|
|
4810
4844
|
buildResult(): readonly AgentReplayRecord[];
|
|
4845
|
+
private removeMessagesFrom;
|
|
4846
|
+
}
|
|
4847
|
+
|
|
4848
|
+
declare interface ReplayBuilderOptions {
|
|
4849
|
+
readonly range?: ReplayRangeOptions;
|
|
4850
|
+
}
|
|
4851
|
+
|
|
4852
|
+
declare interface ReplayRangeOptions {
|
|
4853
|
+
readonly start?: number;
|
|
4854
|
+
readonly count?: number;
|
|
4811
4855
|
}
|
|
4812
4856
|
|
|
4857
|
+
export declare function resolveConfigPath(input: {
|
|
4858
|
+
readonly homeDir?: string | undefined;
|
|
4859
|
+
readonly configPath?: string | undefined;
|
|
4860
|
+
}): string;
|
|
4861
|
+
|
|
4813
4862
|
declare interface ResolvedAgentProfile {
|
|
4814
4863
|
name: string;
|
|
4815
4864
|
description?: string;
|
|
@@ -4937,6 +4986,22 @@ declare interface RunSubagentOptions {
|
|
|
4937
4986
|
readonly suppressRateLimitFailureEvent?: boolean;
|
|
4938
4987
|
}
|
|
4939
4988
|
|
|
4989
|
+
declare interface RuntimeConfigLoadResult {
|
|
4990
|
+
readonly config: KimiConfig;
|
|
4991
|
+
/** Problems in config.toml itself; non-empty means parts (or all) of the file were ignored. */
|
|
4992
|
+
readonly fileWarnings: readonly string[];
|
|
4993
|
+
/** Problems applying KIMI_MODEL_* env overrides; the overlay was skipped. */
|
|
4994
|
+
readonly envWarnings: readonly string[];
|
|
4995
|
+
/**
|
|
4996
|
+
* Set when the file is entirely unusable (unreadable, TOML syntax error, or
|
|
4997
|
+
* nothing salvageable) and `config` is pure defaults. Startup fails fast on
|
|
4998
|
+
* this — defaults-only means the user looks logged out, which is worse than
|
|
4999
|
+
* an actionable parse error. Mid-run reloads ignore it and keep the last
|
|
5000
|
+
* good config instead.
|
|
5001
|
+
*/
|
|
5002
|
+
readonly fileError?: KimiError;
|
|
5003
|
+
}
|
|
5004
|
+
|
|
4940
5005
|
declare interface SDKAgentAPI {
|
|
4941
5006
|
emitEvent: (event: AgentEvent) => void;
|
|
4942
5007
|
requestApproval: (request: ApprovalRequest) => Promise<ApprovalResponse>;
|
|
@@ -6192,6 +6257,16 @@ declare class TurnFlow {
|
|
|
6192
6257
|
/** Allocates the next monotonic turn id. */
|
|
6193
6258
|
private allocateTurnId;
|
|
6194
6259
|
restorePrompt(): void;
|
|
6260
|
+
/**
|
|
6261
|
+
* Raise the turn counter to cover a turnId observed in a replayed loop event.
|
|
6262
|
+
* This is the authoritative source of the restored counter: every turn that
|
|
6263
|
+
* ran — a prompted turn, a goal continuation, or a steer-launched turn —
|
|
6264
|
+
* emits loop events carrying its real turnId, even though only prompted turns
|
|
6265
|
+
* write a `turn.prompt` record. Resuming then continues from `max + 1`. Only
|
|
6266
|
+
* ever raises the counter, never lowers it, so the live path (where `turnId`
|
|
6267
|
+
* is already allocated before any loop event) is unaffected.
|
|
6268
|
+
*/
|
|
6269
|
+
observeRestoredTurnId(turnId: number): void;
|
|
6195
6270
|
restoreSteer(input: readonly ContentPart[], origin: PromptOrigin): void;
|
|
6196
6271
|
cancel(turnId?: number, reason?: unknown): void;
|
|
6197
6272
|
get currentId(): number;
|