@nextclaw/kernel 0.6.20 → 0.6.22
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.ts +230 -94
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1823 -633
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AUTOMATIC_UPDATE_CHECK_INTERVAL_MS, getAutomaticUpdateCheckDelay, resolveAutomaticUpdateCheckIntervalMs } from "./utils/automatic-update-check.utils.js";
|
|
2
2
|
import { a as getUnsignedUpdateManifest, c as UpdateBlockReason, d as UpdateStatus, i as UpdateManifestReader, l as UpdateProgress, n as UpdateHostKind, o as serializeUnsignedUpdateManifest, r as UpdateManifest, s as InstallationKind, t as UnsignedUpdateManifest, u as UpdateSnapshot } from "./update-manifest.types-CQpbURTE.js";
|
|
3
|
-
import { BaseChannel, Config, ContextCompactionCheckpoint, ContextCompactionPlan, ContextWindowSnapshot, CreateAgentProfileInput, CreateSessionContextInheritanceInput, CreateSessionInput, CreatedSession, CronService, EffectiveAgentProfile, ExtensionChannelBinding, ExtensionDiagnostic, ExtensionRegistry, ExtensionUiMetadata, GatewayController, InboundAttachment, InboundMessage, LLMProvider, LLMResponse, LLMStreamEvent, MessageBus, ModelThinkingCapability, OutboundMessage, RequestSessionParams, RequestedSkillsMetadataReader, SearchConfig, SessionMessage, SessionRequestDispatcher, SessionRequestRecord, SessionRequestToolResult, SessionSearchService, SkillInfo, SkillInfo as SkillInfo$1, SkillScope, SpawnSessionAndRequestParams, ThinkingLevel, UpdateAgentProfileInput, buildCompressingCompactionCheckpoint, resolveThinkingLevel } from "@nextclaw/core";
|
|
3
|
+
import { BaseChannel, Config, ContextCompactionCheckpoint, ContextCompactionPhase, ContextCompactionPlan, ContextWindowSnapshot, CreateAgentProfileInput, CreateSessionContextInheritanceInput, CreateSessionInput, CreatedSession, CronService, EffectiveAgentProfile, ExtensionChannelBinding, ExtensionDiagnostic, ExtensionRegistry, ExtensionUiMetadata, GatewayController, InboundAttachment, InboundMessage, LLMProvider, LLMResponse, LLMStreamEvent, MessageBus, ModelThinkingCapability, OutboundMessage, ProviderModelDiscoveryResult, RequestSessionParams, RequestedSkillsMetadataReader, SearchConfig, SessionMessage, SessionRequestDispatcher, SessionRequestRecord, SessionRequestToolResult, SessionSearchService, SkillInfo, SkillInfo as SkillInfo$1, SkillScope, SpawnSessionAndRequestParams, ThinkingLevel, UpdateAgentProfileInput, buildCompressingCompactionCheckpoint, resolveThinkingLevel } from "@nextclaw/core";
|
|
4
4
|
import { ListMessagesOptions, ListSessionsOptions, NcpAgentConversationStateManager, NcpAgentRuntime, NcpEndpointEvent, NcpEventType, NcpLLMApi, NcpLLMApiInput, NcpLLMApiOptions, NcpMessage, NcpMessagePart, NcpRunHandle, NcpSessionApi, NcpSessionMessagePageInfo, NcpSessionPatch, NcpSessionSummary, NcpTool, OpenAIChatChunk } from "@nextclaw/ncp";
|
|
5
|
-
import { LocalAssetStore } from "@nextclaw/ncp-agent-runtime";
|
|
6
5
|
import { AgentRunSendIngressPayload, EventBus, InboxDelivery, InboxDeliveryContentType, InboxDeliveryContinueResult, InboxDeliveryListView, InboxDeliverySource, InboxDeliveryStateAction, Ingress, RuntimeModelSelectionMode, Unsubscribe } from "@nextclaw/shared";
|
|
6
|
+
import { LocalAssetStore } from "@nextclaw/ncp-agent-runtime";
|
|
7
7
|
import { AgentSessionRecord, ChatTarget, NcpReplyInput, RuntimeFactoryParams } from "@nextclaw/ncp-toolkit";
|
|
8
8
|
|
|
9
9
|
//#region src/features/runtime-registry/utils/agent-runtime-registry.utils.d.ts
|
|
@@ -156,8 +156,16 @@ type ProviderConnectionTestInput = {
|
|
|
156
156
|
maxTokens?: number;
|
|
157
157
|
signal?: AbortSignal;
|
|
158
158
|
};
|
|
159
|
+
type ProviderModelsDiscoverInput = {
|
|
160
|
+
providerName: string | null;
|
|
161
|
+
apiKey?: string | null;
|
|
162
|
+
apiBase?: string | null;
|
|
163
|
+
extraHeaders?: Record<string, string> | null;
|
|
164
|
+
signal?: AbortSignal;
|
|
165
|
+
};
|
|
159
166
|
declare class LlmProviderManager {
|
|
160
167
|
private readonly providerRegistry;
|
|
168
|
+
private readonly providerModelDiscovery;
|
|
161
169
|
private readonly providerPool;
|
|
162
170
|
private readonly missingProvider;
|
|
163
171
|
private config;
|
|
@@ -167,10 +175,13 @@ declare class LlmProviderManager {
|
|
|
167
175
|
readonly chat: (params: ProviderChatParams) => Promise<LLMResponse>;
|
|
168
176
|
readonly chatStream: (this: LlmProviderManager, params: ProviderChatParams) => AsyncGenerator<LLMStreamEvent>;
|
|
169
177
|
readonly testConnection: (input: ProviderConnectionTestInput) => Promise<void>;
|
|
178
|
+
supportsModelDiscovery: (providerName: string | null) => boolean;
|
|
179
|
+
discoverModels: (input: ProviderModelsDiscoverInput) => Promise<ProviderModelDiscoveryResult>;
|
|
170
180
|
private resolveRoute;
|
|
171
181
|
private resolveProvider;
|
|
172
182
|
private matchPrefixedProvider;
|
|
173
183
|
private resolveProviderType;
|
|
184
|
+
private resolveProviderApiKey;
|
|
174
185
|
private rewriteModelForTemplate;
|
|
175
186
|
private normalizeProviderModelConfigForRoute;
|
|
176
187
|
private getOrCreateProvider;
|
|
@@ -179,6 +190,53 @@ declare class LlmProviderManager {
|
|
|
179
190
|
private buildCacheKey;
|
|
180
191
|
}
|
|
181
192
|
//#endregion
|
|
193
|
+
//#region src/managers/provider-model-catalog.manager.d.ts
|
|
194
|
+
declare const PROVIDER_MODEL_CATALOG_REFRESH_INTERVAL_MS: number;
|
|
195
|
+
type ProviderModelCatalogEntry = {
|
|
196
|
+
providerId: string;
|
|
197
|
+
models: string[];
|
|
198
|
+
source: "provider" | "catalog" | null;
|
|
199
|
+
fetchedAt: string | null;
|
|
200
|
+
lastError: {
|
|
201
|
+
message: string;
|
|
202
|
+
occurredAt: string;
|
|
203
|
+
} | null;
|
|
204
|
+
};
|
|
205
|
+
type ProviderModelCatalogSnapshot = {
|
|
206
|
+
refreshIntervalMs: number;
|
|
207
|
+
refreshing: boolean;
|
|
208
|
+
lastRefreshStartedAt: string | null;
|
|
209
|
+
lastRefreshCompletedAt: string | null;
|
|
210
|
+
providers: Record<string, ProviderModelCatalogEntry>;
|
|
211
|
+
};
|
|
212
|
+
type ProviderModelCatalogManagerOptions = {
|
|
213
|
+
refreshIntervalMs?: number;
|
|
214
|
+
providerTimeoutMs?: number;
|
|
215
|
+
now?: () => Date;
|
|
216
|
+
};
|
|
217
|
+
declare class ProviderModelCatalogManager {
|
|
218
|
+
private readonly providerManager;
|
|
219
|
+
private config;
|
|
220
|
+
private readonly entries;
|
|
221
|
+
private readonly providerTimeoutMs;
|
|
222
|
+
private readonly refreshIntervalMs;
|
|
223
|
+
private readonly now;
|
|
224
|
+
private refreshTask;
|
|
225
|
+
private refreshPending;
|
|
226
|
+
private refreshTimer;
|
|
227
|
+
private started;
|
|
228
|
+
private lastRefreshStartedAt;
|
|
229
|
+
private lastRefreshCompletedAt;
|
|
230
|
+
constructor(providerManager: Pick<LlmProviderManager, "discoverModels" | "supportsModelDiscovery">, options?: ProviderModelCatalogManagerOptions);
|
|
231
|
+
load: (config: Config) => void;
|
|
232
|
+
start: () => void;
|
|
233
|
+
dispose: () => void;
|
|
234
|
+
refresh: () => Promise<void>;
|
|
235
|
+
getSnapshot: () => ProviderModelCatalogSnapshot;
|
|
236
|
+
private refreshConfiguredProviders;
|
|
237
|
+
private refreshProvider;
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
182
240
|
//#region src/managers/config.manager.d.ts
|
|
183
241
|
type ConfigManagerRuntimeHooks = {
|
|
184
242
|
resolveChannelConfig?: (config: Config) => Config;
|
|
@@ -198,6 +256,7 @@ type ConfigManagerOptions = {
|
|
|
198
256
|
configPath?: string;
|
|
199
257
|
channels: ChannelManager;
|
|
200
258
|
providerManager: LlmProviderManager;
|
|
259
|
+
providerModelCatalogManager?: Pick<ProviderModelCatalogManager, "load">;
|
|
201
260
|
};
|
|
202
261
|
type ConfigMutationResult = Record<string, unknown> & {
|
|
203
262
|
ok: boolean;
|
|
@@ -274,6 +333,10 @@ declare class AgentManager {
|
|
|
274
333
|
getAgent: (agentId: string) => EffectiveAgentProfile | null;
|
|
275
334
|
getDefaultAgentId: () => string;
|
|
276
335
|
resolveAgentProfile: (agentId?: string | null) => ResolvedAgentProfile;
|
|
336
|
+
resolveAgentProfileForContextWindow: (params: {
|
|
337
|
+
agentId: string;
|
|
338
|
+
contextTokens: number;
|
|
339
|
+
}) => ResolvedAgentProfile;
|
|
277
340
|
resolveAgentProfileForRun: (params?: {
|
|
278
341
|
agentId?: string | null;
|
|
279
342
|
requestMetadata?: Record<string, unknown>;
|
|
@@ -287,27 +350,6 @@ declare class AgentManager {
|
|
|
287
350
|
private resolveAgentProfileFromConfig;
|
|
288
351
|
}
|
|
289
352
|
//#endregion
|
|
290
|
-
//#region src/utils/ncp-agent-session-journal.utils.d.ts
|
|
291
|
-
declare const NCP_AGENT_SESSION_SNAPSHOT_MESSAGE_EVENT_TYPE = "session.snapshot.message";
|
|
292
|
-
declare const NCP_SESSION_REQUEST_ACCEPTED_EVENT_TYPE = "session.request.accepted";
|
|
293
|
-
declare const NCP_SESSION_REQUEST_COMPLETED_EVENT_TYPE = "session.request.completed";
|
|
294
|
-
declare const NCP_SESSION_REQUEST_FAILED_EVENT_TYPE = "session.request.failed";
|
|
295
|
-
type NcpAgentSessionSnapshotMessageEvent = {
|
|
296
|
-
type: typeof NCP_AGENT_SESSION_SNAPSHOT_MESSAGE_EVENT_TYPE;
|
|
297
|
-
payload: Extract<NcpEndpointEvent, {
|
|
298
|
-
type: NcpEventType.MessageSent;
|
|
299
|
-
}>["payload"];
|
|
300
|
-
};
|
|
301
|
-
type NcpSessionRequestJournalEventType = typeof NCP_SESSION_REQUEST_ACCEPTED_EVENT_TYPE | typeof NCP_SESSION_REQUEST_COMPLETED_EVENT_TYPE | typeof NCP_SESSION_REQUEST_FAILED_EVENT_TYPE;
|
|
302
|
-
type NcpSessionRequestJournalEvent = {
|
|
303
|
-
type: NcpSessionRequestJournalEventType;
|
|
304
|
-
payload: {
|
|
305
|
-
sessionId: string;
|
|
306
|
-
request: unknown;
|
|
307
|
-
};
|
|
308
|
-
};
|
|
309
|
-
type NcpAgentSessionJournalReplayEvent = NcpEndpointEvent | NcpAgentSessionSnapshotMessageEvent | NcpSessionRequestJournalEvent;
|
|
310
|
-
//#endregion
|
|
311
353
|
//#region src/types/agent-run.types.d.ts
|
|
312
354
|
type ThinkingEffort = string;
|
|
313
355
|
type ContextBlock = string;
|
|
@@ -349,6 +391,125 @@ type ToolProvider = {
|
|
|
349
391
|
provide: (request: AgentRunRequest) => Promise<readonly NcpTool[]> | readonly NcpTool[];
|
|
350
392
|
};
|
|
351
393
|
//#endregion
|
|
394
|
+
//#region src/managers/context-provider.manager.d.ts
|
|
395
|
+
declare class ContextProviderManager {
|
|
396
|
+
private readonly providers;
|
|
397
|
+
register: (provider: ContextProvider) => (() => void);
|
|
398
|
+
buildContext: (request: AgentRunRequest) => Promise<readonly ContextBlock[]>;
|
|
399
|
+
dispose: () => void;
|
|
400
|
+
}
|
|
401
|
+
//#endregion
|
|
402
|
+
//#region src/managers/tool-provider.manager.d.ts
|
|
403
|
+
type ToolRunContext = {
|
|
404
|
+
agentId: string;
|
|
405
|
+
channel: string;
|
|
406
|
+
chatId: string;
|
|
407
|
+
config: Config;
|
|
408
|
+
execTimeoutSeconds: number;
|
|
409
|
+
handoffDepth: number;
|
|
410
|
+
metadata: Record<string, unknown>;
|
|
411
|
+
restrictToWorkspace: boolean;
|
|
412
|
+
searchConfig: SearchConfig;
|
|
413
|
+
sessionId: string;
|
|
414
|
+
workspace: string;
|
|
415
|
+
};
|
|
416
|
+
declare class ToolProviderManager {
|
|
417
|
+
private readonly providers;
|
|
418
|
+
register: (provider: ToolProvider) => (() => void);
|
|
419
|
+
buildTools: (request: AgentRunRequest) => Promise<readonly NcpTool[]>;
|
|
420
|
+
dispose: () => void;
|
|
421
|
+
}
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/managers/agent-context-window.manager.d.ts
|
|
424
|
+
type AgentContextWindowEvaluation = {
|
|
425
|
+
agentId: string;
|
|
426
|
+
contextTokens: number;
|
|
427
|
+
fixedInputTokens: number;
|
|
428
|
+
minimumContextTokens: number;
|
|
429
|
+
reservedContextTokens: number;
|
|
430
|
+
};
|
|
431
|
+
type AgentRunSurface = {
|
|
432
|
+
contextBlocks: readonly string[];
|
|
433
|
+
tools: readonly NcpTool[];
|
|
434
|
+
};
|
|
435
|
+
declare class AgentContextWindowManager {
|
|
436
|
+
private readonly agentManager;
|
|
437
|
+
private readonly contextProviderManager;
|
|
438
|
+
private readonly toolProviderManager;
|
|
439
|
+
private readonly runInputBudgetBySession;
|
|
440
|
+
private readonly preflightService;
|
|
441
|
+
constructor(agentManager: AgentManager, contextProviderManager: ContextProviderManager, toolProviderManager: ToolProviderManager);
|
|
442
|
+
resolveRunSurface: (request: AgentRunRequest) => Promise<AgentRunSurface>;
|
|
443
|
+
forgetSession: (sessionId: string) => void;
|
|
444
|
+
previewSession: (params: {
|
|
445
|
+
requestMetadata: Record<string, unknown>;
|
|
446
|
+
sessionId: string;
|
|
447
|
+
sessionMessages: readonly NcpMessage[];
|
|
448
|
+
storedAgentId?: string;
|
|
449
|
+
storedMetadata: Record<string, unknown>;
|
|
450
|
+
}) => Promise<ContextWindowSnapshot | null>;
|
|
451
|
+
assertCanSave: (params: {
|
|
452
|
+
agentId: string;
|
|
453
|
+
contextTokens: number;
|
|
454
|
+
}) => Promise<AgentContextWindowEvaluation>;
|
|
455
|
+
assertDefaultCanSave: (contextTokens: number) => Promise<AgentContextWindowEvaluation[]>;
|
|
456
|
+
private createValidationRequest;
|
|
457
|
+
private estimateFixedInputTokens;
|
|
458
|
+
private resolveSessionFixedInputTokens;
|
|
459
|
+
private buildRunSurface;
|
|
460
|
+
private resolveMinimumContextTokens;
|
|
461
|
+
}
|
|
462
|
+
//#endregion
|
|
463
|
+
//#region src/managers/agent-run-context-compaction.manager.d.ts
|
|
464
|
+
type AgentRunContextCompactionInput = {
|
|
465
|
+
sessionId: string;
|
|
466
|
+
agentId: string;
|
|
467
|
+
contextBlocks: readonly string[];
|
|
468
|
+
messages: readonly NcpMessage[];
|
|
469
|
+
metadata: Record<string, unknown>;
|
|
470
|
+
model: string;
|
|
471
|
+
phase?: ContextCompactionPhase;
|
|
472
|
+
signal?: AbortSignal;
|
|
473
|
+
tools?: readonly NcpTool[];
|
|
474
|
+
};
|
|
475
|
+
declare class AgentRunContextCompactionManager {
|
|
476
|
+
private readonly preflightService;
|
|
477
|
+
constructor(agentManager: AgentManager, providerManager: LlmProviderRuntime);
|
|
478
|
+
runPreflight: (input: AgentRunContextCompactionInput) => AsyncIterable<NcpEndpointEvent>;
|
|
479
|
+
runManual: (input: AgentRunContextCompactionInput) => Promise<readonly NcpEndpointEvent[]>;
|
|
480
|
+
private run;
|
|
481
|
+
private toEvent;
|
|
482
|
+
}
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region src/utils/ncp-agent-session-journal.utils.d.ts
|
|
485
|
+
declare const NCP_AGENT_SESSION_SNAPSHOT_MESSAGE_EVENT_TYPE = "session.snapshot.message";
|
|
486
|
+
declare const NCP_SESSION_REQUEST_ACCEPTED_EVENT_TYPE = "session.request.accepted";
|
|
487
|
+
declare const NCP_SESSION_REQUEST_COMPLETED_EVENT_TYPE = "session.request.completed";
|
|
488
|
+
declare const NCP_SESSION_REQUEST_FAILED_EVENT_TYPE = "session.request.failed";
|
|
489
|
+
type NcpAgentSessionSnapshotMessageEvent = {
|
|
490
|
+
type: typeof NCP_AGENT_SESSION_SNAPSHOT_MESSAGE_EVENT_TYPE;
|
|
491
|
+
payload: Extract<NcpEndpointEvent, {
|
|
492
|
+
type: NcpEventType.MessageSent;
|
|
493
|
+
}>["payload"];
|
|
494
|
+
};
|
|
495
|
+
type NcpSessionRequestJournalEventType = typeof NCP_SESSION_REQUEST_ACCEPTED_EVENT_TYPE | typeof NCP_SESSION_REQUEST_COMPLETED_EVENT_TYPE | typeof NCP_SESSION_REQUEST_FAILED_EVENT_TYPE;
|
|
496
|
+
type NcpSessionRequestJournalEvent = {
|
|
497
|
+
type: NcpSessionRequestJournalEventType;
|
|
498
|
+
payload: {
|
|
499
|
+
sessionId: string;
|
|
500
|
+
request: unknown;
|
|
501
|
+
};
|
|
502
|
+
};
|
|
503
|
+
type NcpAgentSessionJournalReplayEvent = NcpEndpointEvent | NcpAgentSessionSnapshotMessageEvent | NcpSessionRequestJournalEvent;
|
|
504
|
+
//#endregion
|
|
505
|
+
//#region src/utils/ncp-agent-unfinished-run.utils.d.ts
|
|
506
|
+
type UnfinishedNcpAgentRun = {
|
|
507
|
+
sessionId: string;
|
|
508
|
+
messageId?: string;
|
|
509
|
+
runId?: string;
|
|
510
|
+
startedAt?: string;
|
|
511
|
+
};
|
|
512
|
+
//#endregion
|
|
352
513
|
//#region src/types/session.types.d.ts
|
|
353
514
|
type SessionMessagePage = {
|
|
354
515
|
messages: NcpMessage[];
|
|
@@ -408,6 +569,7 @@ declare class NcpAgentSessionJournalStore {
|
|
|
408
569
|
private readonly writeChains;
|
|
409
570
|
private readonly metadataStore;
|
|
410
571
|
private readonly messageProjectionStore;
|
|
572
|
+
private readonly unfinishedRunStore;
|
|
411
573
|
private readonly summaryIndexStore;
|
|
412
574
|
constructor(journalDir: string);
|
|
413
575
|
appendSessionEvent: (params: {
|
|
@@ -416,6 +578,7 @@ declare class NcpAgentSessionJournalStore {
|
|
|
416
578
|
}) => Promise<void>;
|
|
417
579
|
getSession: (sessionId: string) => Promise<AgentSessionRecord | null>;
|
|
418
580
|
listSessionSummaries: () => Promise<NcpSessionSummary[]>;
|
|
581
|
+
listUnfinishedRuns: () => Promise<UnfinishedNcpAgentRun[]>;
|
|
419
582
|
listSessionMessages: (sessionId: string) => Promise<NcpMessage[]>;
|
|
420
583
|
listSessionMessagePage: (params: {
|
|
421
584
|
sessionId: string;
|
|
@@ -504,6 +667,7 @@ type CreateNcpSessionInput = CreateSessionInput & {
|
|
|
504
667
|
sessionId?: string;
|
|
505
668
|
};
|
|
506
669
|
type SessionManagerOptions = {
|
|
670
|
+
agentContextWindowManager: AgentContextWindowManager;
|
|
507
671
|
agentManager: AgentManager;
|
|
508
672
|
configManager: ConfigManager;
|
|
509
673
|
eventBus: EventBus;
|
|
@@ -513,13 +677,10 @@ type SessionManagerOptions = {
|
|
|
513
677
|
};
|
|
514
678
|
declare class SessionManager implements NcpSessionApi {
|
|
515
679
|
private readonly options;
|
|
516
|
-
readonly cleanups: Array<() => void>;
|
|
517
|
-
private readonly contextWindowPreview;
|
|
518
680
|
private readonly eventIngestion;
|
|
519
681
|
private readonly workingDirResolver;
|
|
520
|
-
private started;
|
|
521
682
|
constructor(options: SessionManagerOptions);
|
|
522
|
-
start: () => void
|
|
683
|
+
start: () => Promise<void>;
|
|
523
684
|
dispose: () => void;
|
|
524
685
|
createSession: (params: CreateNcpSessionInput) => Promise<CreatedSession>;
|
|
525
686
|
appendSessionEvent: (params: {
|
|
@@ -547,31 +708,14 @@ declare class SessionManager implements NcpSessionApi {
|
|
|
547
708
|
getOrCreateAgentRunSession: (params: CreateAgentRunSessionParams) => Promise<AgentRunSession>;
|
|
548
709
|
patchSessionMetadata: (sessionId: string, patch: Record<string, unknown>) => Promise<void>;
|
|
549
710
|
clearSessionMessages: (sessionId: string) => Promise<number>;
|
|
711
|
+
rewindSessionBeforeMessage: (sessionId: string, messageId: string) => Promise<AgentSessionRecord>;
|
|
550
712
|
publishSessionChange: (sessionKey: string) => Promise<void>;
|
|
551
713
|
private createSummaryFromRecord;
|
|
714
|
+
private createSummaryWithContextWindow;
|
|
552
715
|
private publishSessionMetadataChanged;
|
|
553
716
|
private applySessionProjectPatch;
|
|
554
717
|
}
|
|
555
718
|
//#endregion
|
|
556
|
-
//#region src/managers/agent-run-context-compaction.manager.d.ts
|
|
557
|
-
type AgentRunContextCompactionInput = {
|
|
558
|
-
sessionId: string;
|
|
559
|
-
agentId: string;
|
|
560
|
-
contextBlocks: readonly string[];
|
|
561
|
-
messages: readonly NcpMessage[];
|
|
562
|
-
metadata: Record<string, unknown>;
|
|
563
|
-
model: string;
|
|
564
|
-
};
|
|
565
|
-
declare class AgentRunContextCompactionManager {
|
|
566
|
-
private readonly sessionManager;
|
|
567
|
-
private readonly preflightService;
|
|
568
|
-
constructor(agentManager: AgentManager, providerManager: LlmProviderRuntime, sessionManager: SessionManager);
|
|
569
|
-
runPreflight: (input: AgentRunContextCompactionInput) => Promise<readonly NcpEndpointEvent[]>;
|
|
570
|
-
runManual: (input: AgentRunContextCompactionInput) => Promise<readonly NcpEndpointEvent[]>;
|
|
571
|
-
private run;
|
|
572
|
-
private toEvents;
|
|
573
|
-
}
|
|
574
|
-
//#endregion
|
|
575
719
|
//#region src/managers/session-run.manager.d.ts
|
|
576
720
|
type SessionRunQueuedRequest = {
|
|
577
721
|
id: string;
|
|
@@ -604,6 +748,7 @@ declare class SessionRun {
|
|
|
604
748
|
messages: readonly NcpMessage[];
|
|
605
749
|
};
|
|
606
750
|
applyEvents: (events: readonly NcpEndpointEvent[]) => Promise<void>;
|
|
751
|
+
replaceMessages: (messages: readonly NcpMessage[]) => void;
|
|
607
752
|
onStatusChange: (listener: (status: "idle" | "running") => void) => (() => void);
|
|
608
753
|
enqueueRequest: (request: AgentRunRequest, session: AgentRunSession) => SessionRunQueuedRequest;
|
|
609
754
|
listQueuedRequests: () => readonly SessionRunQueuedRequest[];
|
|
@@ -691,56 +836,29 @@ declare class AgentRuntimeManager {
|
|
|
691
836
|
private disposeAllRuntimes;
|
|
692
837
|
}
|
|
693
838
|
//#endregion
|
|
694
|
-
//#region src/managers/context-provider.manager.d.ts
|
|
695
|
-
declare class ContextProviderManager {
|
|
696
|
-
private readonly providers;
|
|
697
|
-
register: (provider: ContextProvider) => (() => void);
|
|
698
|
-
buildContext: (request: AgentRunRequest) => Promise<readonly ContextBlock[]>;
|
|
699
|
-
dispose: () => void;
|
|
700
|
-
}
|
|
701
|
-
//#endregion
|
|
702
|
-
//#region src/managers/tool-provider.manager.d.ts
|
|
703
|
-
type ToolRunContext = {
|
|
704
|
-
agentId: string;
|
|
705
|
-
channel: string;
|
|
706
|
-
chatId: string;
|
|
707
|
-
config: Config;
|
|
708
|
-
execTimeoutSeconds: number;
|
|
709
|
-
handoffDepth: number;
|
|
710
|
-
metadata: Record<string, unknown>;
|
|
711
|
-
restrictToWorkspace: boolean;
|
|
712
|
-
searchConfig: SearchConfig;
|
|
713
|
-
sessionId: string;
|
|
714
|
-
workspace: string;
|
|
715
|
-
};
|
|
716
|
-
declare class ToolProviderManager {
|
|
717
|
-
private readonly providers;
|
|
718
|
-
register: (provider: ToolProvider) => (() => void);
|
|
719
|
-
buildTools: (request: AgentRunRequest) => Promise<readonly NcpTool[]>;
|
|
720
|
-
dispose: () => void;
|
|
721
|
-
}
|
|
722
|
-
//#endregion
|
|
723
839
|
//#region src/managers/agent-run-request.manager.d.ts
|
|
724
840
|
declare class AgentRunRequestManager {
|
|
725
841
|
private readonly agentRuntimeManager;
|
|
726
842
|
private readonly agentManager;
|
|
727
843
|
private readonly configManager;
|
|
728
|
-
private readonly
|
|
844
|
+
private readonly agentContextWindowManager;
|
|
729
845
|
private readonly eventBus;
|
|
730
846
|
private readonly ingress;
|
|
731
847
|
private readonly sessionManager;
|
|
732
848
|
private readonly sessionRunManager;
|
|
733
|
-
private readonly toolProviderManager;
|
|
734
849
|
readonly cleanups: Array<() => void>;
|
|
735
850
|
private readonly observedSessionRuns;
|
|
851
|
+
private readonly sessionCommandManager;
|
|
736
852
|
private started;
|
|
737
|
-
constructor(agentRuntimeManager: AgentRuntimeManager, agentManager: AgentManager, configManager: ConfigManager,
|
|
853
|
+
constructor(agentRuntimeManager: AgentRuntimeManager, agentManager: AgentManager, configManager: ConfigManager, agentContextWindowManager: AgentContextWindowManager, eventBus: EventBus, ingress: Ingress, sessionManager: SessionManager, sessionRunManager: SessionRunManager);
|
|
738
854
|
start: () => void;
|
|
739
855
|
dispose: () => void;
|
|
740
856
|
listQueuedInputs: (sessionId: string) => readonly SessionQueuedInput[];
|
|
741
857
|
removeQueuedInput: (sessionId: string, queuedInputId: string) => SessionQueuedInput | null;
|
|
742
858
|
private handleSendRequest;
|
|
743
859
|
private handleAbortRequest;
|
|
860
|
+
private handleEditMessageRequest;
|
|
861
|
+
private handleContinueRequest;
|
|
744
862
|
private handleSessionMessageRequest;
|
|
745
863
|
private send;
|
|
746
864
|
private startQueuedRun;
|
|
@@ -1587,6 +1705,7 @@ declare class NextclawKernel {
|
|
|
1587
1705
|
readonly ingress: Ingress;
|
|
1588
1706
|
readonly messageBus: MessageBus;
|
|
1589
1707
|
readonly llmProviders: LlmProviderManager;
|
|
1708
|
+
readonly providerModelCatalog: ProviderModelCatalogManager;
|
|
1590
1709
|
readonly llmUsage: LlmUsageManager;
|
|
1591
1710
|
readonly configManager: ConfigManager;
|
|
1592
1711
|
readonly accessManager: AccessManager;
|
|
@@ -1607,6 +1726,7 @@ declare class NextclawKernel {
|
|
|
1607
1726
|
readonly serviceAppManager: ServiceAppManager;
|
|
1608
1727
|
readonly extensions: ExtensionManager;
|
|
1609
1728
|
readonly agentRuntimeManager: AgentRuntimeManager;
|
|
1729
|
+
readonly agentContextWindowManager: AgentContextWindowManager;
|
|
1610
1730
|
readonly contextCompactionManager: AgentRunContextCompactionManager;
|
|
1611
1731
|
readonly contextProviderManager: ContextProviderManager;
|
|
1612
1732
|
readonly sessionRunManager: SessionRunManager;
|
|
@@ -1871,23 +1991,19 @@ declare const DEFAULT_SERVICE_ACTION_RISK: ServiceActionRisk;
|
|
|
1871
1991
|
declare function buildServiceActionId(appId: string, actionName: string): string;
|
|
1872
1992
|
declare function getServiceActionName(actionId: string, appId: string): string;
|
|
1873
1993
|
//#endregion
|
|
1874
|
-
//#region src/features/context-compaction/
|
|
1875
|
-
declare class
|
|
1876
|
-
private readonly
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
storedAgentId?: string;
|
|
1883
|
-
storedMetadata: Record<string, unknown>;
|
|
1884
|
-
}) => ContextWindowSnapshot | null;
|
|
1994
|
+
//#region src/features/context-compaction/services/context-compaction-journal-recovery.service.d.ts
|
|
1995
|
+
declare class ContextCompactionJournalRecoveryService {
|
|
1996
|
+
private readonly pendingMessageIds;
|
|
1997
|
+
private readonly recoveredTerminals;
|
|
1998
|
+
seed: (messages: readonly NcpMessage[]) => void;
|
|
1999
|
+
track: (event: NcpEndpointEvent) => void;
|
|
2000
|
+
terminalize: (message: NcpMessage) => NcpMessage;
|
|
2001
|
+
private readCheckpoint;
|
|
1885
2002
|
}
|
|
1886
2003
|
//#endregion
|
|
1887
2004
|
//#region src/features/context-compaction/services/context-compaction-preflight.service.d.ts
|
|
1888
2005
|
type ContextCompactionPreflightResult = {
|
|
1889
2006
|
contextWindow: ContextWindowSnapshot;
|
|
1890
|
-
metadataPatch: Record<string, unknown>;
|
|
1891
2007
|
sessionMessages: NcpMessage[];
|
|
1892
2008
|
timelineMessage: NcpMessage | null;
|
|
1893
2009
|
};
|
|
@@ -1897,13 +2013,21 @@ type ContextCompactionPreflightBeginResult = {
|
|
|
1897
2013
|
pendingCompaction: ContextCompactionPendingWork | null;
|
|
1898
2014
|
};
|
|
1899
2015
|
type ContextCompactionTrigger = "automatic" | "manual";
|
|
2016
|
+
type ContinuationMessageBoundary = {
|
|
2017
|
+
messageId: string;
|
|
2018
|
+
coveredPartCount: number;
|
|
2019
|
+
};
|
|
1900
2020
|
type ContextCompactionPendingWork = {
|
|
1901
2021
|
checkpoint: ReturnType<typeof buildCompressingCompactionCheckpoint>;
|
|
2022
|
+
contextBlockMessages: Record<string, unknown>[];
|
|
2023
|
+
continuationMessageBoundary: ContinuationMessageBoundary | null;
|
|
1902
2024
|
contextTokens: number;
|
|
2025
|
+
phase: ContextCompactionPhase;
|
|
1903
2026
|
serviceMessageId: string;
|
|
1904
2027
|
model: string;
|
|
1905
2028
|
plan: ContextCompactionPlan;
|
|
1906
2029
|
reservedContextTokens: number;
|
|
2030
|
+
snapshotFixedInputTokens: number;
|
|
1907
2031
|
sessionId: string;
|
|
1908
2032
|
sessionMessages: NcpMessage[];
|
|
1909
2033
|
};
|
|
@@ -1914,25 +2038,30 @@ declare class ContextCompactionPreflightService {
|
|
|
1914
2038
|
private readonly contextWindowBudgetService;
|
|
1915
2039
|
constructor(agentManager: AgentManager, providerManager?: LlmProviderRuntime | undefined);
|
|
1916
2040
|
preview: (params: {
|
|
2041
|
+
completeInputBudget?: boolean;
|
|
1917
2042
|
contextBlocks?: readonly string[];
|
|
2043
|
+
fixedInputTokens?: number;
|
|
1918
2044
|
requestMetadata: Record<string, unknown>;
|
|
1919
2045
|
sessionId: string;
|
|
1920
2046
|
sessionMessages: readonly NcpMessage[];
|
|
1921
2047
|
storedAgentId?: string;
|
|
1922
2048
|
storedMetadata: Record<string, unknown>;
|
|
2049
|
+
tools?: readonly NcpTool[];
|
|
1923
2050
|
}) => ContextWindowSnapshot | null;
|
|
1924
2051
|
begin: (params: {
|
|
1925
2052
|
contextBlocks?: readonly string[];
|
|
1926
2053
|
inputMessages: readonly NcpMessage[];
|
|
1927
2054
|
model: string;
|
|
2055
|
+
phase?: ContextCompactionPhase;
|
|
1928
2056
|
requestMetadata: Record<string, unknown>;
|
|
1929
2057
|
sessionId: string;
|
|
1930
2058
|
sessionMessages: readonly NcpMessage[];
|
|
1931
2059
|
storedAgentId?: string;
|
|
1932
2060
|
storedMetadata: Record<string, unknown>;
|
|
2061
|
+
tools?: readonly NcpTool[];
|
|
1933
2062
|
trigger?: ContextCompactionTrigger;
|
|
1934
2063
|
}) => ContextCompactionPreflightBeginResult;
|
|
1935
|
-
finish: (pending: ContextCompactionPendingWork) => Promise<ContextCompactionPreflightResult>;
|
|
2064
|
+
finish: (pending: ContextCompactionPendingWork, signal?: AbortSignal) => Promise<ContextCompactionPreflightResult>;
|
|
1936
2065
|
private generateSummary;
|
|
1937
2066
|
private resolveCompactionProfile;
|
|
1938
2067
|
}
|
|
@@ -1942,7 +2071,10 @@ declare const NEXTCLAW_TIMELINE_KIND_METADATA_KEY = "nextclaw_timeline_kind";
|
|
|
1942
2071
|
declare const CONTEXT_COMPACTION_TIMELINE_KIND = "context_compaction";
|
|
1943
2072
|
declare const CONTEXT_COMPACTION_PROJECTION_METADATA_KEY = "nextclaw_context_projection";
|
|
1944
2073
|
declare const CONTEXT_COMPACTION_PROJECTION_KIND = "compressed_context";
|
|
2074
|
+
declare const CONTEXT_COMPACTION_CONTINUATION_TEXT = "Continue the active run from the compressed working context. Do not repeat completed tool calls; proceed with the next required action.";
|
|
2075
|
+
declare const CONTEXT_COMPACTION_SYSTEM_PREAMBLE: string;
|
|
1945
2076
|
type ContextCompactionTimelineCheckpoint = ContextCompactionCheckpoint;
|
|
2077
|
+
declare function readContextCompactionCheckpoint(message: NcpMessage): ContextCompactionCheckpoint | null;
|
|
1946
2078
|
declare function createContextCompactionMessageId(): string;
|
|
1947
2079
|
declare function buildContextCompactionTimelineNcpMessage(params: {
|
|
1948
2080
|
messageId: string;
|
|
@@ -1956,10 +2088,14 @@ declare function isContextCompactionProjectionMessage(message: {
|
|
|
1956
2088
|
metadata?: Record<string, unknown> | undefined;
|
|
1957
2089
|
} | null | undefined): boolean;
|
|
1958
2090
|
declare function readLatestContextCompactionCheckpoint(sessionMessages: readonly NcpMessage[]): ContextCompactionCheckpoint | null;
|
|
1959
|
-
|
|
2091
|
+
type ContextCompactionModelProjection = {
|
|
2092
|
+
messages: NcpMessage[];
|
|
2093
|
+
stablePrefixMessageCount: number;
|
|
2094
|
+
};
|
|
2095
|
+
declare function buildContextCompactionModelProjection(params: {
|
|
1960
2096
|
sessionId: string;
|
|
1961
2097
|
sessionMessages: readonly NcpMessage[];
|
|
1962
|
-
}):
|
|
2098
|
+
}): ContextCompactionModelProjection;
|
|
1963
2099
|
declare function readContextWindowEventSessionId(event: NcpEndpointEvent): string | null;
|
|
1964
2100
|
declare function isContextWindowSnapshot(value: unknown): value is Record<string, unknown>;
|
|
1965
2101
|
declare function createContextWindowSignature(value: Record<string, unknown>): string;
|
|
@@ -2053,5 +2189,5 @@ declare function resolveLegacyEventType(message: SessionMessage): string;
|
|
|
2053
2189
|
declare function getUiContentParamsBootstrapScript(): string;
|
|
2054
2190
|
declare function injectUiContentParamsBootstrap(html: string): string;
|
|
2055
2191
|
//#endregion
|
|
2056
|
-
export { AUTOMATIC_UPDATE_CHECK_INTERVAL_MS, AccessLoginResult, AccessManager, AccessManagerOptions, AccessPasswordStatus, AccessPrincipal, AccessRole, AccessSessionRecord, AccessSessionState, AgentManager, AgentManagerOptions, AgentRunClient, type AgentRunReply, type AgentRunReplyOptions, AgentRunSession, type AgentRunStreamOptions, AgentRuntimeEntry, AgentRuntimeProviderRegistration, AgentRuntimeSessionRequestDispatcherOptions, AgentRuntimeSessionTypeDescribeParams, AgentRuntimeSessionTypeIcon, AgentRuntimeSessionTypeOption, AgentRuntimeSessionTypeProvider, type AssetApi, AutomationManager, AutomationManagerOptions, type BuildAgentRunSendPayloadParams, BuiltinNarpRuntimeProviderService, CONTEXT_COMPACTION_PROJECTION_KIND, CONTEXT_COMPACTION_PROJECTION_METADATA_KEY, CONTEXT_COMPACTION_TIMELINE_KIND, ChannelManager, ChannelReplyRouterDispatchParams, CommandRegistry, ConfigManager, ConfigManagerOptions, ConfigManagerRuntimeHooks, ConfigMutationResult, ContextCompactionPreflightBeginResult, ContextCompactionPreflightResult, ContextCompactionPreflightService, ContextCompactionTimelineCheckpoint, ContextCompactionTrigger,
|
|
2192
|
+
export { AUTOMATIC_UPDATE_CHECK_INTERVAL_MS, AccessLoginResult, AccessManager, AccessManagerOptions, AccessPasswordStatus, AccessPrincipal, AccessRole, AccessSessionRecord, AccessSessionState, AgentManager, AgentManagerOptions, AgentRunClient, type AgentRunReply, type AgentRunReplyOptions, AgentRunSession, type AgentRunStreamOptions, AgentRuntimeEntry, AgentRuntimeProviderRegistration, AgentRuntimeSessionRequestDispatcherOptions, AgentRuntimeSessionTypeDescribeParams, AgentRuntimeSessionTypeIcon, AgentRuntimeSessionTypeOption, AgentRuntimeSessionTypeProvider, type AssetApi, AutomationManager, AutomationManagerOptions, type BuildAgentRunSendPayloadParams, BuiltinNarpRuntimeProviderService, CONTEXT_COMPACTION_CONTINUATION_TEXT, CONTEXT_COMPACTION_PROJECTION_KIND, CONTEXT_COMPACTION_PROJECTION_METADATA_KEY, CONTEXT_COMPACTION_SYSTEM_PREAMBLE, CONTEXT_COMPACTION_TIMELINE_KIND, ChannelManager, ChannelReplyRouterDispatchParams, CommandRegistry, ConfigManager, ConfigManagerOptions, ConfigManagerRuntimeHooks, ConfigMutationResult, ContextCompactionJournalRecoveryService, ContextCompactionModelProjection, ContextCompactionPreflightBeginResult, ContextCompactionPreflightResult, ContextCompactionPreflightService, ContextCompactionTimelineCheckpoint, ContextCompactionTrigger, CreateAgentRunSessionParams, CreateInboxDeliveryInput, CreateProjectInput, DEFAULT_AGENT_RUNTIME_ENTRY_ID, DEFAULT_SERVICE_ACTION_RISK, DirectPromptDispatchParams, ExtensionLoadProgress, ExtensionLoadResult, ExtensionManager, GatewayInboundLoopRuntime, GatewayInboundProcessor, InboxDeliveryError, InboxDeliveryErrorCode, InboxDeliveryManager, InboxDeliveryManagerOptions, InstallationKind, InstalledSkillDetail, InstalledSkillSummary, InstalledSkillsList, type LearningLoopRuntimeConfig, LlmProviderManager, LlmProviderRuntime, LlmUsageManager, LlmUsageManagerOptions, LlmUsageRecord, LlmUsageSnapshot, LlmUsageStats, LlmUsageStore, LlmUsageStoreOptions, LlmUsageSummary, LocalizedTextMap, MAX_INBOX_DELIVERY_CONTENT_LENGTH, McpManager, McpServiceAppRuntimeService, NARP_HTTP_RUNTIME_KIND, NARP_STDIO_RUNTIME_KIND, NEXTCLAW_TIMELINE_KIND_METADATA_KEY, NcpAgentSessionJournalStore, NextclawKernel, NextclawKernelOptions, NextclawNcpResolvedAgentProfile, NextclawNcpResolvedRunContext, NextclawNcpRunContextResolveParams, PANEL_APP_AGENT_CAPABILITIES, PROJECT_TEMPLATE_IDS, PROVIDER_MODEL_CATALOG_REFRESH_INTERVAL_MS, PanelAppAgentCapability, PanelAppAgentGenerateObjectInput, PanelAppAgentGenerateObjectRequest, PanelAppAgentGenerateObjectResult, PanelAppAgentRunClient, PanelAppAgentSendPayload, PanelAppAgentSendRequest, PanelAppAgentSendResult, PanelAppAssetTokenService, PanelAppBridgeSession, PanelAppCapabilityGrant, PanelAppCapabilityGrantCaller, type PanelAppClientGrant, PanelAppContent, PanelAppDeleteResult, PanelAppEntry, PanelAppError, PanelAppErrorCode, PanelAppList, PanelAppManager, type PanelAppPreferencesUpdate, PreferenceEntry, PreferenceError, PreferenceErrorCode, PreferenceJsonValue, PreferenceManager, PreferenceManagerOptions, ProjectError, ProjectErrorCode, ProjectManager, ProjectManagerOptions, ProjectRecord, ProjectTemplate, ProjectTemplateId, ProviderManagerNcpLLMApi, ProviderModelCatalogEntry, ProviderModelCatalogManager, ProviderModelCatalogSnapshot, ProviderModelsDiscoverInput, ResolvedAgentProfile, SERVICE_APP_MANIFEST_FILE_NAME, ServiceAction, ServiceActionCaller, ServiceActionGrant, ServiceActionGrantRequest, ServiceActionGrantState, ServiceActionInvokeRequest, ServiceActionInvokeResult, ServiceActionRisk, ServiceActionRuntimeState, ServiceAppDeleteResult, ServiceAppError, ServiceAppErrorCode, ServiceAppList, ServiceAppManager, ServiceAppManifest, ServiceAppManifestAction, ServiceAppProtocol, ServiceAppRecord, ServiceAppRuntimeStatus, SessionContextCompactionError, SessionContextCompactionErrorCode, SessionContextCompactionManager, SessionContextCompactionResult, SessionManager, SessionManagerOptions, SessionMessageCursorError, SessionMessagePage, type SessionQueuedInput, SessionRequestManager, SessionRequestManagerOptions, SessionSettingsError, SessionSettingsPatch, SkillFrontmatter, type SkillInfo, SkillManager, type SkillScope, UnsignedUpdateManifest, UpdateBlockReason, UpdateHostKind, UpdateManifest, UpdateManifestReader, UpdateProgress, UpdateSnapshot, UpdateStatus, buildAgentRunSendPayload, buildContextCompactionModelProjection, buildContextCompactionTimelineNcpMessage, buildLlmUsageSummary, buildLocalizedTextMap, buildNextclawNcpRunContext, buildServiceActionId, createAgentRuntimeSessionRequestDispatcher, createAssetTools, createContextCompactionMessageId, createContextWindowSignature, createLlmUsageRecord, describeAgentRuntimeSessionTypes, dispatchAgentRuntimeSessionRequest, dispatchChannelReplyRoute, dispatchPromptOverNcp, getAutomaticUpdateCheckDelay, getServiceActionName, getServiceAppManifestPath, getUiContentParamsBootstrapScript, getUnsignedUpdateManifest, hasLlmUsageTelemetry, injectUiContentParamsBootstrap, isContextCompactionProjectionMessage, isContextCompactionTimelineMessage, isContextWindowSnapshot, isInboxDeliveryError, isPanelAppAgentCapability, isPanelAppError, isPreferenceError, isProjectError, isReplyCapableChannel, isServiceAppError, isSessionContextCompactionError, isSessionMessageCursorError, isSessionSettingsError, listExtensionChannelIds, listServiceAppManifestActions, mergeServiceAppRuntimeActions, normalizeAgentRuntimeSessionTypeIcon, normalizeLlmUsageModel, normalizeOptionalString, parseServiceAppManifest, parseSkillFrontmatter, readContextCompactionCheckpoint, readContextWindowEventSessionId, readLatestContextCompactionCheckpoint, readLearningLoopRuntimeConfig, readMetadataModel, readMetadataThinking, readServiceAppManifest, resolveAgentRuntimeEntries, resolveAutomaticUpdateCheckIntervalMs, resolveChannelReplyRoute, resolveEffectiveModel, resolveLegacyEventType, resolveSessionChannelContext, runGatewayInboundLoop, sanitizeLlmUsage, serializeUnsignedUpdateManifest, shouldRefreshContextWindowDuringStream, shouldRefreshContextWindowImmediately, stripSkillFrontmatter, syncSessionThinkingPreference, toNcpMessages, waitForAgentRuntimeSessionReply };
|
|
2057
2193
|
//# sourceMappingURL=index.d.ts.map
|