@listdoing/core 0.1.4 → 0.2.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/dist/index.d.mts +209 -41
- package/dist/index.d.ts +209 -41
- package/dist/index.js +1405 -501
- package/dist/index.mjs +1395 -501
- package/package.json +5 -2
package/dist/index.d.mts
CHANGED
|
@@ -143,6 +143,8 @@ interface SkillDefinition {
|
|
|
143
143
|
parallelSafe?: boolean;
|
|
144
144
|
tier?: SkillTier;
|
|
145
145
|
timeout?: number;
|
|
146
|
+
/** Opt in only for handlers whose late side effects are controlled by the host. */
|
|
147
|
+
timeoutMode?: 'cooperative' | 'deadline';
|
|
146
148
|
/** Direct handler (execution mode: call) */
|
|
147
149
|
handler?: SkillHandler;
|
|
148
150
|
/** Agent-based skill: model autonomously loops using tools */
|
|
@@ -242,6 +244,19 @@ interface WorkflowProgress {
|
|
|
242
244
|
failedSteps: string[];
|
|
243
245
|
}
|
|
244
246
|
interface LLMAdapterConfig {
|
|
247
|
+
/** Disabled by default. Covers headers, response body and retry delays. */
|
|
248
|
+
requestTimeoutMs?: number;
|
|
249
|
+
/** Disabled by default. Maximum wait between streaming chunks. */
|
|
250
|
+
streamIdleTimeoutMs?: number;
|
|
251
|
+
/** Opt in for providers that reliably emit finish_reason or [DONE]. */
|
|
252
|
+
strictStream?: boolean;
|
|
253
|
+
/** Opt in to provider-reported prompt cache usage. Streaming requests may include stream_options. */
|
|
254
|
+
collectPromptCacheUsage?: boolean;
|
|
255
|
+
/** Retries only HTTP 429/502/503/504 before consuming a response. Default: no retries. */
|
|
256
|
+
retry?: {
|
|
257
|
+
maxRetries?: number;
|
|
258
|
+
baseDelayMs?: number;
|
|
259
|
+
};
|
|
245
260
|
adapter: 'openai' | 'anthropic' | 'ollama' | 'custom';
|
|
246
261
|
model: string;
|
|
247
262
|
baseUrl?: string;
|
|
@@ -268,12 +283,20 @@ interface StandardLLMResponse {
|
|
|
268
283
|
input: number;
|
|
269
284
|
output: number;
|
|
270
285
|
};
|
|
286
|
+
promptCacheUsage?: PromptCacheUsage;
|
|
271
287
|
finishReason?: string;
|
|
272
288
|
}
|
|
289
|
+
interface PromptCacheUsage {
|
|
290
|
+
inputTokens?: number;
|
|
291
|
+
cachedTokens?: number;
|
|
292
|
+
cacheWriteTokens?: number;
|
|
293
|
+
}
|
|
273
294
|
interface ToolCall {
|
|
274
295
|
id: string;
|
|
275
296
|
name: string;
|
|
276
297
|
arguments: Record<string, any>;
|
|
298
|
+
/** Adapter detected invalid arguments; the handler must not be invoked. */
|
|
299
|
+
parseError?: string;
|
|
277
300
|
}
|
|
278
301
|
interface ToolDef {
|
|
279
302
|
name: string;
|
|
@@ -322,7 +345,16 @@ interface Session {
|
|
|
322
345
|
systemPrompt?: string;
|
|
323
346
|
messages: Message[];
|
|
324
347
|
}
|
|
348
|
+
/** Instructions and local tools scoped to one chat invocation. */
|
|
349
|
+
interface ChatRunContext {
|
|
350
|
+
systemPromptSuffix?: string;
|
|
351
|
+
skills?: readonly SkillDefinition[];
|
|
352
|
+
}
|
|
325
353
|
interface ChatOptions {
|
|
354
|
+
/** Optional, transient context. It is not written to the session. */
|
|
355
|
+
runContext?: ChatRunContext;
|
|
356
|
+
/** Optional parent cancellation, also used by nested tasks. */
|
|
357
|
+
signal?: AbortSignal;
|
|
326
358
|
sessionId?: string;
|
|
327
359
|
requireApproval?: string[];
|
|
328
360
|
/** Skip all approval checks for this chat call (overrides everything) */
|
|
@@ -356,6 +388,7 @@ interface ChatOptions {
|
|
|
356
388
|
_skipLock?: boolean;
|
|
357
389
|
}
|
|
358
390
|
interface ChatResult {
|
|
391
|
+
terminationReason?: 'stop' | 'max_turns' | 'cancelled';
|
|
359
392
|
reply: string;
|
|
360
393
|
sessionId: string;
|
|
361
394
|
executionTrace: ExecutionTrace[];
|
|
@@ -496,6 +529,12 @@ type StreamEvent = {
|
|
|
496
529
|
type: 'graph:failed';
|
|
497
530
|
plan: GraphPlan;
|
|
498
531
|
failedNodes: string[];
|
|
532
|
+
} | {
|
|
533
|
+
type: 'context:compressed';
|
|
534
|
+
sessionId: string;
|
|
535
|
+
beforeTokens: number;
|
|
536
|
+
afterTokens: number;
|
|
537
|
+
reason: 'auto' | 'manual';
|
|
499
538
|
} | {
|
|
500
539
|
type: 'done';
|
|
501
540
|
reply: string;
|
|
@@ -504,13 +543,31 @@ type StreamEvent = {
|
|
|
504
543
|
output: number;
|
|
505
544
|
};
|
|
506
545
|
totalDuration: number;
|
|
546
|
+
terminationReason?: 'stop' | 'max_turns' | 'cancelled';
|
|
507
547
|
} | {
|
|
508
548
|
type: 'error';
|
|
509
549
|
code: number;
|
|
510
550
|
message: string;
|
|
511
551
|
};
|
|
552
|
+
type LLMProxyMode = 'backend' | 'listdoing-server';
|
|
553
|
+
type McpConnectionStatus = 'not-configured' | 'unchecked' | 'connected' | 'failed';
|
|
554
|
+
interface LLMRouteStatus {
|
|
555
|
+
mode: LLMProxyMode | 'legacy';
|
|
556
|
+
endpoint: string;
|
|
557
|
+
verified: boolean;
|
|
558
|
+
}
|
|
512
559
|
interface LdoingConfig {
|
|
560
|
+
/** Observability only: exceptions in this callback never interrupt the agent. */
|
|
561
|
+
onDiagnostic?: (event: {
|
|
562
|
+
kind: string;
|
|
563
|
+
sessionId?: string;
|
|
564
|
+
message: string;
|
|
565
|
+
model?: string;
|
|
566
|
+
promptCacheUsage?: PromptCacheUsage;
|
|
567
|
+
}) => void;
|
|
513
568
|
llm: LLMAdapterConfig;
|
|
569
|
+
/** Opt in to explicit proxy routing. Omit to keep legacy routing. */
|
|
570
|
+
llmProxyMode?: LLMProxyMode;
|
|
514
571
|
serverUrl?: string;
|
|
515
572
|
authToken?: string;
|
|
516
573
|
/** Custom headers sent on every request (health, MCP, LLM) */
|
|
@@ -543,13 +600,17 @@ interface ContextConfig {
|
|
|
543
600
|
outputReserve?: number;
|
|
544
601
|
autoCompress?: boolean;
|
|
545
602
|
compressThreshold?: number;
|
|
603
|
+
/** When true (default) and a summarizer is available, use LLM-based semantic summarization. */
|
|
604
|
+
useLLMSummary?: boolean;
|
|
546
605
|
historyStrategy?: {
|
|
547
|
-
type: 'sliding_window' | 'token_budget' | 'relevance' | 'summary' | 'hybrid';
|
|
606
|
+
type: 'sliding_window' | 'token_budget' | 'relevance' | 'summary' | 'hybrid' | 'llm_summary';
|
|
548
607
|
rules?: any[];
|
|
549
608
|
};
|
|
550
609
|
syncToServer?: boolean;
|
|
551
610
|
}
|
|
552
611
|
interface SkillsConfig {
|
|
612
|
+
/** Opt-in JSON Schema validation; legacy definitions remain accepted by default. */
|
|
613
|
+
validateInputs?: boolean;
|
|
553
614
|
loadDefaults?: boolean;
|
|
554
615
|
disable?: string[];
|
|
555
616
|
enable?: string[];
|
|
@@ -564,6 +625,8 @@ interface LimitsConfig {
|
|
|
564
625
|
interface InitResult {
|
|
565
626
|
agentId: string;
|
|
566
627
|
mode: 'local' | 'remote' | 'hybrid';
|
|
628
|
+
llmRoute?: LLMRouteStatus;
|
|
629
|
+
mcpStatus?: McpConnectionStatus;
|
|
567
630
|
llm: {
|
|
568
631
|
connected: boolean;
|
|
569
632
|
provider: string;
|
|
@@ -590,7 +653,9 @@ interface ILLMAdapter {
|
|
|
590
653
|
}): AsyncIterable<StreamEvent>;
|
|
591
654
|
}
|
|
592
655
|
interface ITransport {
|
|
593
|
-
send(method: string, params: any
|
|
656
|
+
send(method: string, params: any, options?: {
|
|
657
|
+
signal?: AbortSignal;
|
|
658
|
+
}): Promise<any>;
|
|
594
659
|
notify(method: string, params: any): void;
|
|
595
660
|
}
|
|
596
661
|
interface IPersistence {
|
|
@@ -706,6 +771,7 @@ declare const ACPErrorCodes: {
|
|
|
706
771
|
readonly LLM_CALL_FAILED: -32130;
|
|
707
772
|
readonly LLM_EMPTY_RESPONSE: -32135;
|
|
708
773
|
readonly LLM_TOKEN_LIMIT: -32131;
|
|
774
|
+
readonly LLM_PROXY_CONFIG_INVALID: -32136;
|
|
709
775
|
readonly LLM_RATE_LIMIT: -32132;
|
|
710
776
|
readonly LLM_PROVIDER_UNAVAILABLE: -32133;
|
|
711
777
|
readonly TOKEN_BUDGET_EXCEEDED: -32134;
|
|
@@ -745,11 +811,19 @@ declare class ACPError extends Error {
|
|
|
745
811
|
* Works with OpenAI, OneAPI, FastGPT, Azure OpenAI, and any compatible proxy.
|
|
746
812
|
*/
|
|
747
813
|
declare class OpenAIAdapter implements ILLMAdapter {
|
|
814
|
+
private options?;
|
|
748
815
|
private config;
|
|
749
816
|
private contentAdapter;
|
|
750
|
-
|
|
817
|
+
private verified;
|
|
818
|
+
constructor(config: LLMAdapterConfig, options?: {
|
|
819
|
+
rejectRedirects?: boolean;
|
|
820
|
+
} | undefined);
|
|
751
821
|
private getBaseUrl;
|
|
752
822
|
private getEndpoint;
|
|
823
|
+
getConnectionStatus(): {
|
|
824
|
+
endpoint: string;
|
|
825
|
+
verified: boolean;
|
|
826
|
+
};
|
|
753
827
|
private buildHeaders;
|
|
754
828
|
private messagesToOpenAI;
|
|
755
829
|
private toolsToOpenAI;
|
|
@@ -764,12 +838,19 @@ declare class OpenAIAdapter implements ILLMAdapter {
|
|
|
764
838
|
chatStream(messages: Message[], tools: ToolDef[], options?: {
|
|
765
839
|
signal?: AbortSignal;
|
|
766
840
|
}): AsyncGenerator<StreamEvent>;
|
|
841
|
+
private parseToolCall;
|
|
842
|
+
private createRequest;
|
|
843
|
+
private fetchResponse;
|
|
844
|
+
private readChunk;
|
|
767
845
|
/**
|
|
768
846
|
* Check if the error response indicates context length exceeded.
|
|
769
847
|
* Throws ACPError with CONTEXT_OVERFLOW code if detected.
|
|
770
848
|
*/
|
|
771
849
|
private checkContextOverflow;
|
|
850
|
+
/** AbortError for the given signal — used so a cancelled stream surfaces an abort, not a parse error. */
|
|
851
|
+
private throwIfAborted;
|
|
772
852
|
private parseResponse;
|
|
853
|
+
private parsePromptCacheUsage;
|
|
773
854
|
}
|
|
774
855
|
|
|
775
856
|
declare class SkillRegistry {
|
|
@@ -777,6 +858,8 @@ declare class SkillRegistry {
|
|
|
777
858
|
register(skill: SkillDefinition): void;
|
|
778
859
|
unregister(name: string): boolean;
|
|
779
860
|
get(name: string): SkillDefinition | undefined;
|
|
861
|
+
/** Identity of this registration, replaced on every register call. */
|
|
862
|
+
getRegistrationIdentity(skill: SkillDefinition): object;
|
|
780
863
|
getHandler(name: string): SkillHandler | undefined;
|
|
781
864
|
list(): SkillDefinition[];
|
|
782
865
|
listToolDefs(filter?: {
|
|
@@ -788,12 +871,17 @@ declare class SkillRegistry {
|
|
|
788
871
|
}
|
|
789
872
|
|
|
790
873
|
declare class SkillExecutor {
|
|
874
|
+
private options?;
|
|
791
875
|
private registry;
|
|
792
876
|
private worker;
|
|
793
|
-
|
|
877
|
+
private validators;
|
|
878
|
+
constructor(registry: SkillRegistry, worker?: SkillWorker, options?: {
|
|
879
|
+
validateInputs?: boolean;
|
|
880
|
+
} | undefined);
|
|
794
881
|
getWorker(): SkillWorker;
|
|
795
882
|
getRegistry(): SkillRegistry;
|
|
796
883
|
execute(name: string, params: Record<string, any>, context: SkillContext): Promise<SkillResult>;
|
|
884
|
+
private getValidator;
|
|
797
885
|
/**
|
|
798
886
|
* Directly invoke a skill by name — used by ctx.invoke().
|
|
799
887
|
* No LLM loop, no approval. Shares parent's signal and timeout context.
|
|
@@ -808,7 +896,9 @@ interface McpServerConnection {
|
|
|
808
896
|
name: string;
|
|
809
897
|
transport: 'stdio' | 'http';
|
|
810
898
|
toolDefs: ToolDef[];
|
|
811
|
-
call(toolName: string, args: Record<string, any
|
|
899
|
+
call(toolName: string, args: Record<string, any>, options?: {
|
|
900
|
+
signal?: AbortSignal;
|
|
901
|
+
}): Promise<any>;
|
|
812
902
|
disconnect(): Promise<void>;
|
|
813
903
|
}
|
|
814
904
|
/**
|
|
@@ -852,7 +942,9 @@ declare class McpRouter {
|
|
|
852
942
|
/**
|
|
853
943
|
* Route a tool call to the appropriate MCP Server.
|
|
854
944
|
*/
|
|
855
|
-
call(prefixedName: string, args: Record<string, any
|
|
945
|
+
call(prefixedName: string, args: Record<string, any>, options?: {
|
|
946
|
+
signal?: AbortSignal;
|
|
947
|
+
}): Promise<any>;
|
|
856
948
|
/**
|
|
857
949
|
* Resolve `mcp:` prefixed tool names from a tools list to ToolDef[].
|
|
858
950
|
* Non-mcp names are silently skipped.
|
|
@@ -864,6 +956,7 @@ declare class McpRouter {
|
|
|
864
956
|
isConnected(serverName: string): boolean;
|
|
865
957
|
}
|
|
866
958
|
|
|
959
|
+
type SessionMergeStrategy = 'full' | 'summary' | 'summary_and_artifacts';
|
|
867
960
|
declare class SessionManager {
|
|
868
961
|
private sessions;
|
|
869
962
|
create(options?: {
|
|
@@ -872,6 +965,7 @@ declare class SessionManager {
|
|
|
872
965
|
systemPrompt?: string;
|
|
873
966
|
}): Session;
|
|
874
967
|
get(sessionId: string): Session | undefined;
|
|
968
|
+
restore(session: Session): void;
|
|
875
969
|
getOrThrow(sessionId: string): Session;
|
|
876
970
|
list(options?: {
|
|
877
971
|
status?: string;
|
|
@@ -892,21 +986,47 @@ declare class SessionManager {
|
|
|
892
986
|
addMessage(sessionId: string, message: Message): void;
|
|
893
987
|
delete(sessionId: string): boolean;
|
|
894
988
|
archive(sessionId: string): void;
|
|
895
|
-
merge(fromId: string, toId: string, strategy?:
|
|
896
|
-
|
|
989
|
+
merge(fromId: string, toId: string, strategy?: SessionMergeStrategy): void;
|
|
990
|
+
static mergeContent(from: Session, to: Session, strategy?: SessionMergeStrategy): void;
|
|
991
|
+
private static createSummary;
|
|
897
992
|
}
|
|
898
993
|
|
|
994
|
+
/**
|
|
995
|
+
* A summarizer produces a compact semantic summary of a set of messages.
|
|
996
|
+
* Used by ContextManager to replace mechanical truncation with LLM-based
|
|
997
|
+
* summarization (Claude Code style auto-compact).
|
|
998
|
+
*/
|
|
999
|
+
type SummarizerFn = (messages: Message[], opts?: {
|
|
1000
|
+
signal?: AbortSignal;
|
|
1001
|
+
}) => Promise<string>;
|
|
1002
|
+
|
|
899
1003
|
interface BuildWindowResult {
|
|
900
1004
|
messages: Message[];
|
|
901
1005
|
usedTokens: number;
|
|
902
1006
|
budget: number;
|
|
903
1007
|
}
|
|
1008
|
+
interface CompressResult {
|
|
1009
|
+
messages: Message[];
|
|
1010
|
+
beforeTokens: number;
|
|
1011
|
+
afterTokens: number;
|
|
1012
|
+
}
|
|
1013
|
+
interface EnsureContextFitsResult {
|
|
1014
|
+
messages: Message[];
|
|
1015
|
+
wasCompressed: boolean;
|
|
1016
|
+
/** Estimated full input before compression, including the system prompt and tools. */
|
|
1017
|
+
beforeTokens?: number;
|
|
1018
|
+
/** Estimated input of the request window built from the compressed messages. */
|
|
1019
|
+
afterTokens?: number;
|
|
1020
|
+
}
|
|
904
1021
|
declare class ContextManager {
|
|
905
1022
|
private config;
|
|
906
1023
|
private model;
|
|
1024
|
+
private summarizer?;
|
|
907
1025
|
constructor(config?: ContextConfig, model?: string);
|
|
908
1026
|
/** Update model (called when LLM config changes) */
|
|
909
1027
|
setModel(model: string): void;
|
|
1028
|
+
/** Inject an LLM-based summarizer. When set, auto-compression uses semantic summarization. */
|
|
1029
|
+
setSummarizer(fn?: SummarizerFn): void;
|
|
910
1030
|
/** Compute the token budget for the current model & config */
|
|
911
1031
|
getBudget(): number;
|
|
912
1032
|
/**
|
|
@@ -917,20 +1037,28 @@ declare class ContextManager {
|
|
|
917
1037
|
buildWindow(messages: Message[], systemPrompt?: string, tools?: ToolDef[], maxTokens?: number): BuildWindowResult;
|
|
918
1038
|
/**
|
|
919
1039
|
* Ensure context fits within budget. Triggers auto-compression when
|
|
920
|
-
* usage exceeds the configured threshold.
|
|
1040
|
+
* usage exceeds the configured threshold. Prefers LLM-based semantic
|
|
1041
|
+
* summarization (when a summarizer is set and enabled) over mechanical truncation.
|
|
921
1042
|
*/
|
|
922
|
-
ensureContextFits(messages: Message[], systemPrompt: string | undefined, tools: ToolDef[], model?: string):
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
1043
|
+
ensureContextFits(messages: Message[], systemPrompt: string | undefined, tools: ToolDef[], model?: string, signal?: AbortSignal): Promise<EnsureContextFitsResult>;
|
|
1044
|
+
/** Build one smaller request after a provider rejects the current window. */
|
|
1045
|
+
compressForOverflow(messages: Message[], rejected: BuildWindowResult, systemPrompt: string, tools: ToolDef[], signal: AbortSignal): Promise<(CompressResult & {
|
|
1046
|
+
window: BuildWindowResult;
|
|
1047
|
+
}) | undefined>;
|
|
926
1048
|
/**
|
|
927
|
-
* Compress context by summarizing older messages.
|
|
1049
|
+
* Compress context by summarizing older messages. When strategy is
|
|
1050
|
+
* 'llm_summary' (or resolved via config) it uses the injected summarizer,
|
|
1051
|
+
* falling back to mechanical 'hybrid' truncation on failure.
|
|
928
1052
|
*/
|
|
929
|
-
compress(messages: Message[], strategy?: 'sliding_window' | 'token_budget' | 'summary' | 'hybrid'):
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1053
|
+
compress(messages: Message[], strategy?: 'sliding_window' | 'token_budget' | 'summary' | 'hybrid' | 'llm_summary'): Promise<CompressResult>;
|
|
1054
|
+
/** Mechanical (non-LLM) compression — the original truncation strategies. */
|
|
1055
|
+
private compressSync;
|
|
1056
|
+
/**
|
|
1057
|
+
* LLM-based semantic summarization. Returns null when it cannot be performed
|
|
1058
|
+
* (no summarizer, nothing to summarize, or the LLM call fails) so callers can
|
|
1059
|
+
* fall back to mechanical compression.
|
|
1060
|
+
*/
|
|
1061
|
+
private compressWithLLM;
|
|
934
1062
|
/**
|
|
935
1063
|
* Search across messages for relevant content.
|
|
936
1064
|
*/
|
|
@@ -1014,12 +1142,16 @@ declare class HttpTransport implements ITransport {
|
|
|
1014
1142
|
setSessionId(id: string): void;
|
|
1015
1143
|
setAuthToken(token: string): void;
|
|
1016
1144
|
private buildHeaders;
|
|
1017
|
-
send(method: string, params: any
|
|
1145
|
+
send(method: string, params: any, options?: {
|
|
1146
|
+
signal?: AbortSignal;
|
|
1147
|
+
}): Promise<any>;
|
|
1018
1148
|
notify(method: string, params: any): void;
|
|
1019
1149
|
/**
|
|
1020
1150
|
* Stream a chat request via SSE.
|
|
1021
1151
|
*/
|
|
1022
|
-
streamChat(method: string, params: any
|
|
1152
|
+
streamChat(method: string, params: any, options?: {
|
|
1153
|
+
signal?: AbortSignal;
|
|
1154
|
+
}): AsyncGenerator<{
|
|
1023
1155
|
method: string;
|
|
1024
1156
|
params: any;
|
|
1025
1157
|
} | {
|
|
@@ -1035,6 +1167,8 @@ declare class Ldoing {
|
|
|
1035
1167
|
private agentId;
|
|
1036
1168
|
private initialized;
|
|
1037
1169
|
private startTime;
|
|
1170
|
+
private mcpStatus;
|
|
1171
|
+
private discoveredServerSkills;
|
|
1038
1172
|
protected llmAdapter: OpenAIAdapter;
|
|
1039
1173
|
protected skillRegistry: SkillRegistry;
|
|
1040
1174
|
protected skillExecutor: SkillExecutor;
|
|
@@ -1045,45 +1179,45 @@ declare class Ldoing {
|
|
|
1045
1179
|
protected persistence: IPersistence;
|
|
1046
1180
|
private currentSessionId;
|
|
1047
1181
|
private abortControllers;
|
|
1182
|
+
private runContexts;
|
|
1048
1183
|
private runningSessions;
|
|
1049
1184
|
private approvalResolvers;
|
|
1185
|
+
private sessionStorageQueues;
|
|
1186
|
+
private managingSessions;
|
|
1187
|
+
private compressingSessions;
|
|
1050
1188
|
private eventHandlers;
|
|
1051
1189
|
private tokenCalibrationRatio;
|
|
1052
1190
|
constructor(config: LdoingConfig);
|
|
1053
1191
|
init(): Promise<InitResult>;
|
|
1054
1192
|
destroy(): Promise<void>;
|
|
1055
1193
|
getStatus(): {
|
|
1056
|
-
agentId: string;
|
|
1057
|
-
mode: string;
|
|
1058
|
-
uptime: number;
|
|
1059
|
-
activeSessions: number;
|
|
1060
|
-
loadedSkills: number;
|
|
1061
1194
|
llm: {
|
|
1062
1195
|
adapter: "custom" | "openai" | "anthropic" | "ollama";
|
|
1063
1196
|
model: string;
|
|
1064
1197
|
connected: boolean;
|
|
1065
1198
|
};
|
|
1199
|
+
mcpStatus: McpConnectionStatus;
|
|
1200
|
+
llmRoute?: LLMRouteStatus;
|
|
1201
|
+
agentId: string;
|
|
1202
|
+
mode: string;
|
|
1203
|
+
uptime: number;
|
|
1204
|
+
activeSessions: number;
|
|
1205
|
+
loadedSkills: number;
|
|
1066
1206
|
};
|
|
1207
|
+
private getConnectionDetails;
|
|
1067
1208
|
chat(message: string | ContentBlock[], options?: ChatOptions): Promise<ChatResult>;
|
|
1068
1209
|
chatStream(message: string | ContentBlock[], options?: ChatOptions): AsyncGenerator<StreamEvent>;
|
|
1069
1210
|
abort(sessionId?: string): Promise<void>;
|
|
1070
1211
|
/**
|
|
1071
1212
|
* 在启动新的 agent loop 前获取会话锁。
|
|
1072
1213
|
* 根据并发策略处理正在运行的旧请求:
|
|
1073
|
-
* - 'abort' (默认):
|
|
1214
|
+
* - 'abort' (默认): 中止旧请求,等待其真正退出,发送前修复未配对消息,然后返回
|
|
1074
1215
|
* - 'reject': 若已有运行请求,抛错
|
|
1075
1216
|
* - 'queue': 预留,当前回退到 'abort'
|
|
1076
1217
|
*
|
|
1077
1218
|
* 返回一个 release 函数,agent loop 结束时必须调用以释放锁。
|
|
1078
1219
|
*/
|
|
1079
1220
|
private acquireSessionLock;
|
|
1080
|
-
/**
|
|
1081
|
-
* 清理被 abort 打断的半截消息:
|
|
1082
|
-
* 如果 session.messages 最后一条是 assistant 且带 tool_calls,
|
|
1083
|
-
* 但后面没有对应的 tool 消息,则删除这条 assistant。
|
|
1084
|
-
* 避免下次 LLM 调用因 tool_calls 未配对而报错。
|
|
1085
|
-
*/
|
|
1086
|
-
private cleanupInterruptedMessages;
|
|
1087
1221
|
approveTool(callId: string, approved: boolean, _reason?: string): void;
|
|
1088
1222
|
private waitForApproval;
|
|
1089
1223
|
registerSkill(skill: SkillDefinition): void;
|
|
@@ -1117,6 +1251,7 @@ declare class Ldoing {
|
|
|
1117
1251
|
title?: string;
|
|
1118
1252
|
meta?: Record<string, any>;
|
|
1119
1253
|
systemPrompt?: string;
|
|
1254
|
+
activate?: boolean;
|
|
1120
1255
|
}): Session;
|
|
1121
1256
|
getSession(sessionId: string): Session | undefined;
|
|
1122
1257
|
listSessions(options?: {
|
|
@@ -1137,7 +1272,22 @@ declare class Ldoing {
|
|
|
1137
1272
|
}[];
|
|
1138
1273
|
mergeSessions(fromId: string, toId: string, strategy?: 'full' | 'summary' | 'summary_and_artifacts'): void;
|
|
1139
1274
|
deleteSession(sessionId: string): void;
|
|
1275
|
+
private removeLiveSession;
|
|
1140
1276
|
archiveSession(sessionId: string): void;
|
|
1277
|
+
/** List committed history without loading it into the Agent. */
|
|
1278
|
+
listStoredSessions(options?: Parameters<IPersistence['listSessions']>[0]): Promise<Session[]>;
|
|
1279
|
+
/** Load one stored session on demand. A live session takes precedence. */
|
|
1280
|
+
restoreSession(sessionId: string, options?: {
|
|
1281
|
+
activate?: boolean;
|
|
1282
|
+
}): Promise<Session | null>;
|
|
1283
|
+
/** Archive a stored or live session, publishing the update after commit. */
|
|
1284
|
+
archiveStoredSession(sessionId: string): Promise<void>;
|
|
1285
|
+
/** Commit an idle session, then release its live copy. Restore it by ID when needed. */
|
|
1286
|
+
unloadSession(sessionId: string): Promise<boolean>;
|
|
1287
|
+
/** Merge history into the target session and commit the target. */
|
|
1288
|
+
mergeStoredSessions(fromId: string, toId: string, strategy?: SessionMergeStrategy): Promise<void>;
|
|
1289
|
+
/** Delete committed and live history, including when a chat save is pending. */
|
|
1290
|
+
deleteStoredSession(sessionId: string): Promise<void>;
|
|
1141
1291
|
getContext(sessionId: string, format?: 'messages' | 'summary' | 'window'): Message[] | string;
|
|
1142
1292
|
searchContext(query: string, options?: {
|
|
1143
1293
|
limit?: number;
|
|
@@ -1148,18 +1298,19 @@ declare class Ldoing {
|
|
|
1148
1298
|
content: string;
|
|
1149
1299
|
source: string;
|
|
1150
1300
|
}[];
|
|
1151
|
-
compressContext(sessionId: string, strategy?: 'sliding_window' | 'token_budget' | 'summary' | 'hybrid'): {
|
|
1301
|
+
compressContext(sessionId: string, strategy?: 'sliding_window' | 'token_budget' | 'summary' | 'hybrid' | 'llm_summary'): Promise<{
|
|
1152
1302
|
beforeTokens: number;
|
|
1153
1303
|
afterTokens: number;
|
|
1154
1304
|
compressionRatio: number;
|
|
1155
|
-
}
|
|
1305
|
+
}>;
|
|
1306
|
+
private prepareOverflowRetry;
|
|
1156
1307
|
configure(config: Partial<LdoingConfig>): void;
|
|
1308
|
+
private configureProxy;
|
|
1157
1309
|
on(event: string, handler: EventHandler): void;
|
|
1158
1310
|
off(event: string, handler: EventHandler): void;
|
|
1159
1311
|
private emit;
|
|
1160
1312
|
/**
|
|
1161
|
-
*
|
|
1162
|
-
* Forwards llm_text events to the caller and collects the full StandardLLMResponse.
|
|
1313
|
+
* Forward streaming events, or emit the complete response for a non-streaming adapter.
|
|
1163
1314
|
*/
|
|
1164
1315
|
private streamLlmResponse;
|
|
1165
1316
|
/**
|
|
@@ -1183,12 +1334,26 @@ declare class Ldoing {
|
|
|
1183
1334
|
private planToolExecution;
|
|
1184
1335
|
private processApprovalQueue;
|
|
1185
1336
|
private executeToolBatch;
|
|
1337
|
+
private streamToolBatch;
|
|
1186
1338
|
private executeToolBatchStream;
|
|
1187
1339
|
/**
|
|
1188
1340
|
* Execute a tool call, routing mcp: prefixed tools to McpRouter.
|
|
1189
1341
|
*/
|
|
1190
1342
|
private executeToolCall;
|
|
1343
|
+
private prepareRunContext;
|
|
1344
|
+
private buildRunSystemPrompt;
|
|
1345
|
+
private listRunTools;
|
|
1346
|
+
private beginExecution;
|
|
1347
|
+
private ensureSessionIsNotBeingManaged;
|
|
1348
|
+
private manageSessionStorage;
|
|
1349
|
+
private readSessionForStorage;
|
|
1350
|
+
private requireSessionForStorage;
|
|
1351
|
+
private commitStoredSession;
|
|
1352
|
+
private snapshotSession;
|
|
1353
|
+
private queueSessionStorage;
|
|
1354
|
+
private saveSessionSafely;
|
|
1191
1355
|
private ensureInitialized;
|
|
1356
|
+
private reportPromptCacheUsage;
|
|
1192
1357
|
private ensureSession;
|
|
1193
1358
|
/** Resolve system prompt — can be overridden by subclasses to inject context */
|
|
1194
1359
|
protected resolveSystemPrompt(sessionId: string, base: string): string;
|
|
@@ -1283,7 +1448,7 @@ declare class MemoryPersistence implements IPersistence {
|
|
|
1283
1448
|
declare class TaskPlanner {
|
|
1284
1449
|
private llmAdapter;
|
|
1285
1450
|
constructor(llmAdapter: ILLMAdapter);
|
|
1286
|
-
plan(goal: string, availableTools: ToolDef[]): Promise<TaskPlan>;
|
|
1451
|
+
plan(goal: string, availableTools: ToolDef[], signal?: AbortSignal): Promise<TaskPlan>;
|
|
1287
1452
|
private buildPlanningPrompt;
|
|
1288
1453
|
private parsePlan;
|
|
1289
1454
|
private extractSteps;
|
|
@@ -1360,7 +1525,7 @@ declare class TaskGraph {
|
|
|
1360
1525
|
declare class GraphPlanner {
|
|
1361
1526
|
protected llmAdapter: ILLMAdapter;
|
|
1362
1527
|
constructor(llmAdapter: ILLMAdapter);
|
|
1363
|
-
planGraph(goal: string, availableTools: ToolDef[]): Promise<GraphPlan>;
|
|
1528
|
+
planGraph(goal: string, availableTools: ToolDef[], signal?: AbortSignal): Promise<GraphPlan>;
|
|
1364
1529
|
private buildGraphPlanningPrompt;
|
|
1365
1530
|
private parseGraphPlan;
|
|
1366
1531
|
private extractGraphNodes;
|
|
@@ -1384,9 +1549,11 @@ declare class GraphExecutor {
|
|
|
1384
1549
|
private abortController;
|
|
1385
1550
|
private toolFailureCount;
|
|
1386
1551
|
private emit;
|
|
1552
|
+
private unlinkParent;
|
|
1387
1553
|
constructor(options: {
|
|
1388
1554
|
graph: TaskGraph;
|
|
1389
1555
|
parentAgent: Ldoing;
|
|
1556
|
+
parentSignal?: AbortSignal;
|
|
1390
1557
|
plan: GraphPlan;
|
|
1391
1558
|
maxConcurrency?: number;
|
|
1392
1559
|
maxDepth?: number;
|
|
@@ -1429,6 +1596,7 @@ declare class SubAgent {
|
|
|
1429
1596
|
private parentAgent;
|
|
1430
1597
|
private sessionId;
|
|
1431
1598
|
private abortController;
|
|
1599
|
+
private unlinkParent;
|
|
1432
1600
|
private status;
|
|
1433
1601
|
constructor(options: {
|
|
1434
1602
|
nodeId: string;
|
|
@@ -1470,4 +1638,4 @@ declare class OpenAIContentAdapter implements IContentAdapter {
|
|
|
1470
1638
|
formatMessageContent(content: string | ContentBlock[]): string | any[];
|
|
1471
1639
|
}
|
|
1472
1640
|
|
|
1473
|
-
export { ACPError, ACPErrorCodes, type BuildWindowResult, type ChatOptions, type ChatResult, type CodeExecutionConfig, type ContentBlock, type ContextConfig, ContextManager, type ExecutionTrace, type FallbackStrategy, type FileInput, type GraphCheckpoint, type GraphDefinition, GraphExecutor, type GraphNode, type GraphPlan, GraphPlanner, type GraphProgress, HttpTransport, type IContentAdapter, type ILLMAdapter, type IPersistence, type ISkillProvider, type ITransport, type InitResult, type InstallOptions, type JsonRpcRequest, type JsonRpcResponse, type LLMAdapterConfig, Ldoing, type LdoingConfig, type LimitsConfig, type LoadedSkill, LocalTransport, McpRouter, type McpServerConnection, MemoryPersistence, type Message, type ModelCapabilities, type NodeResult, type NodeStatus, OpenAIAdapter, OpenAIContentAdapter, PERMISSION_MODE_DEFAULTS, type PermissionMode, type PermissionPolicy, PlanTracker, type RetryPolicy, SENSITIVE_PERMISSIONS, type ServerConfig, type Session, SessionManager, type SkillContext, type SkillDefinition, SkillExecutor, type SkillHandler, type SkillInstallRequest, type SkillInstallResult, type SkillPack, type SkillPackEnv, type SkillPackRegistration, type SkillPackResult, SkillRegistry, type SkillResult, type SkillSource, type SkillTier, type SkillWorker, type SkillsConfig, type StandardLLMResponse, type StepPlan, type StepResult, type StepStatus, type StreamEvent, SubAgent, type SubAgentConfig, type TaskCheckpoint, TaskGraph, type TaskPlan, type TaskPlanStatus, TaskPlanner, type TaskProgress, type ToolCall, type ToolDef, type TriggerRule, type UploadConfig, type WorkflowDefinition, type WorkflowProgress, type WorkflowStep, contentToPreview, contentToString, detectRuntime, estimateContentTokens, estimateMessageTokens, estimateRequestTokens, estimateTextTokens, estimateToolDefTokens, fileInputsToContentBlocks, interpolateInstruction, interpolateTemplate, resolveModelCapabilities, resolveModelContextLength, resolvePermissionPolicy };
|
|
1641
|
+
export { ACPError, ACPErrorCodes, type BuildWindowResult, type ChatOptions, type ChatResult, type ChatRunContext, type CodeExecutionConfig, type ContentBlock, type ContextConfig, ContextManager, type ExecutionTrace, type FallbackStrategy, type FileInput, type GraphCheckpoint, type GraphDefinition, GraphExecutor, type GraphNode, type GraphPlan, GraphPlanner, type GraphProgress, HttpTransport, type IContentAdapter, type ILLMAdapter, type IPersistence, type ISkillProvider, type ITransport, type InitResult, type InstallOptions, type JsonRpcRequest, type JsonRpcResponse, type LLMAdapterConfig, type LLMProxyMode, type LLMRouteStatus, Ldoing, type LdoingConfig, type LimitsConfig, type LoadedSkill, LocalTransport, type McpConnectionStatus, McpRouter, type McpServerConnection, MemoryPersistence, type Message, type ModelCapabilities, type NodeResult, type NodeStatus, OpenAIAdapter, OpenAIContentAdapter, PERMISSION_MODE_DEFAULTS, type PermissionMode, type PermissionPolicy, PlanTracker, type PromptCacheUsage, type RetryPolicy, SENSITIVE_PERMISSIONS, type ServerConfig, type Session, SessionManager, type SkillContext, type SkillDefinition, SkillExecutor, type SkillHandler, type SkillInstallRequest, type SkillInstallResult, type SkillPack, type SkillPackEnv, type SkillPackRegistration, type SkillPackResult, SkillRegistry, type SkillResult, type SkillSource, type SkillTier, type SkillWorker, type SkillsConfig, type StandardLLMResponse, type StepPlan, type StepResult, type StepStatus, type StreamEvent, SubAgent, type SubAgentConfig, type TaskCheckpoint, TaskGraph, type TaskPlan, type TaskPlanStatus, TaskPlanner, type TaskProgress, type ToolCall, type ToolDef, type TriggerRule, type UploadConfig, type WorkflowDefinition, type WorkflowProgress, type WorkflowStep, contentToPreview, contentToString, detectRuntime, estimateContentTokens, estimateMessageTokens, estimateRequestTokens, estimateTextTokens, estimateToolDefTokens, fileInputsToContentBlocks, interpolateInstruction, interpolateTemplate, resolveModelCapabilities, resolveModelContextLength, resolvePermissionPolicy };
|