@nextclaw/kernel 0.1.10 → 0.1.12

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +299 -226
  2. package/dist/index.js +5210 -4929
  3. package/package.json +14 -14
package/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import { a as getUnsignedUpdateManifest, c as UpdateBlockReason, d as UpdateSnapshot, f as UpdateStatus, i as UpdateManifestReader, l as UpdatePreferences, n as UpdateHostKind, o as serializeUnsignedUpdateManifest, r as UpdateManifest, s as InstallationKind, t as UnsignedUpdateManifest, u as UpdateProgress } from "./update-manifest.types-DLWDvs_v.js";
2
- import { BaseChannel, ChannelManager, ChannelManager as ChannelManager$1, Config, ContextCompactionPlan, ContextWindowSnapshot, CronService, Disposable, ExtensionRegistry, ExtensionToolContext, GatewayController, InboundAttachment, InboundMessage, LLMProvider, LLMResponse, LLMStreamEvent, MessageBus, SearchConfig, Session, SessionManager, SessionMessage, SessionRequestDispatcher, SessionRequestManager, SessionRequestRecord, SessionSearchManager, SkillInfo, SkillInfo as SkillInfo$1, SkillScope, ThinkingLevel, Tool, buildCompressingCompactionCheckpoint } from "@nextclaw/core";
3
2
  import { EventBus, Ingress, Unsubscribe } from "@nextclaw/shared";
4
3
  import * as _$_nextclaw_ncp0 from "@nextclaw/ncp";
5
- import { ListMessagesOptions, ListSessionsOptions, NcpAgentConversationStateManager, NcpAgentRunInput, NcpAgentRunSendOptions, NcpAgentRunStreamOptions, NcpAgentRuntime, NcpContextBuilder, NcpContextPrepareOptions, NcpEndpointEvent, NcpLLMApi, NcpLLMApiInput, NcpLLMApiOptions, NcpMessage, NcpMessagePart, NcpRequestEnvelope, NcpSessionApi, NcpSessionPatch, NcpSessionStatus, NcpSessionSummary, NcpStreamRequestPayload, NcpTool, NcpToolRegistry, OpenAIChatChunk } from "@nextclaw/ncp";
6
- import { PluginChannelBinding, PluginRegistry, PluginUiMetadata } from "@nextclaw/openclaw-compat";
7
- import { AgentSessionStore, ChatTarget, EventPublisher, NcpReplyInput, RuntimeFactoryParams } from "@nextclaw/ncp-toolkit";
4
+ import { ListMessagesOptions, ListSessionsOptions, NcpAgentConversationStateManager, NcpAgentRunInput, NcpAgentRunSendOptions, NcpAgentRunStreamOptions, NcpAgentRuntime, NcpContextBuilder, NcpContextPrepareOptions, NcpEndpointEvent, NcpEventType, NcpLLMApi, NcpLLMApiInput, NcpLLMApiOptions, NcpMessage, NcpMessagePart, NcpRequestEnvelope, NcpSessionApi, NcpSessionPatch, NcpSessionSummary, NcpStreamRequestPayload, NcpTool, NcpToolRegistry, OpenAIChatChunk } from "@nextclaw/ncp";
8
5
  import { LocalAssetStore } from "@nextclaw/ncp-agent-runtime";
6
+ import { BaseChannel, ChannelManager, ChannelManager as ChannelManager$1, Config, ContextWindowSnapshot, CreateSessionInput, CreatedSession, CronService, Disposable, ExtensionRegistry, ExtensionToolContext, GatewayController, InboundAttachment, InboundMessage, LLMProvider, LLMResponse, LLMStreamEvent, MessageBus, RequestSessionParams, SearchConfig, Session, SessionManager, SessionMessage, SessionRequestDispatcher, SessionRequestRecord, SessionRequestToolResult, SessionSearchManager, SkillInfo, SkillInfo as SkillInfo$1, SkillScope, SpawnSessionAndRequestParams, ThinkingLevel, Tool } from "@nextclaw/core";
7
+ import { PluginChannelBinding, PluginRegistry, PluginUiMetadata } from "@nextclaw/openclaw-compat";
8
+ import * as _$_nextclaw_ncp_toolkit0 from "@nextclaw/ncp-toolkit";
9
+ import { AgentSessionRecord, ChatTarget, NcpReplyInput, RuntimeFactoryParams } from "@nextclaw/ncp-toolkit";
9
10
 
10
11
  //#region src/types/entity-ids.types.d.ts
11
12
  type AgentId = string;
@@ -97,11 +98,8 @@ type MaterializedAgentRunRequest = NcpRequestEnvelope & {
97
98
  type LiveSession = {
98
99
  sessionId: string;
99
100
  agentId?: string;
100
- createdAt: string;
101
101
  stateManager: NcpAgentConversationStateManager;
102
- metadata: Record<string, unknown>;
103
102
  runtime: NcpAgentRuntime;
104
- publisher: EventPublisher;
105
103
  activeExecution: LiveSessionExecution | null;
106
104
  };
107
105
  type PublishSessionEventOptions = {
@@ -193,7 +191,9 @@ declare class AgentRuntimeRegistry {
193
191
  entries: AgentRuntimeEntry[];
194
192
  defaultEntryId?: string;
195
193
  }) => void;
194
+ resolveSessionMetadata: (sessionMetadata: Record<string, unknown>) => Record<string, unknown>;
196
195
  createRuntime: (params: RuntimeFactoryParams) => NcpAgentRuntime;
196
+ private resolveRuntimeEntry;
197
197
  listSessionTypes: (params?: AgentRuntimeSessionTypeDescribeParams) => Promise<{
198
198
  defaultType: string;
199
199
  options: AgentRuntimeSessionTypeOption[];
@@ -215,6 +215,7 @@ declare class AgentRuntimeManager {
215
215
  constructor(params: AgentRuntimeManagerOptions);
216
216
  registerRuntimeProvider: (registration: AgentRuntimeProviderRegistration) => Disposable;
217
217
  createRuntime: (runtimeParams: RuntimeFactoryParams) => _$_nextclaw_ncp0.NcpAgentRuntime;
218
+ resolveSessionMetadata: (sessionMetadata: Record<string, unknown>) => Record<string, unknown>;
218
219
  listSessionTypes: (describeParams?: AgentRuntimeSessionTypeDescribeParams) => Promise<{
219
220
  defaultType: string;
220
221
  options: AgentRuntimeSessionTypeOption[];
@@ -223,72 +224,63 @@ declare class AgentRuntimeManager {
223
224
  private readonly assertNotDisposed;
224
225
  }
225
226
  //#endregion
226
- //#region src/managers/session-run.manager.d.ts
227
- declare class SessionRunManager {
228
- private readonly agentRuntimeManager;
229
- private readonly ncpAgentSessionStore;
230
- private readonly eventBus;
231
- private readonly onSessionUpdated;
232
- private readonly liveSessions;
233
- private readonly publisher;
234
- private disposed;
235
- constructor(options: {
236
- agentRuntimeManager: AgentRuntimeManager;
237
- ncpAgentSessionStore: AgentSessionStore;
238
- eventBus: EventBus;
239
- onSessionUpdated: (sessionKey: string) => void;
240
- });
241
- dispose: () => Promise<void>;
242
- isRunning: (sessionId: string) => boolean;
243
- getOrCreateLiveSession: (sessionId: string, initialMetadata?: Record<string, unknown>) => Promise<LiveSession>;
244
- getActiveSessionRun: (sessionId: string) => LiveSessionExecution | null;
245
- setActiveSessionRun: (sessionId: string, activeRun: LiveSessionExecution) => void;
246
- deleteActiveSessionRun: (sessionId: string, runId: string) => void;
247
- streamSessionEvents: (payload: NcpStreamRequestPayload, options?: NcpAgentRunStreamOptions) => AsyncIterable<NcpEndpointEvent>;
248
- updateToolCallResult: UpdateToolCallResult;
249
- appendSessionEvent: (sessionId: string, event: NcpEndpointEvent, options?: PublishSessionEventOptions) => Promise<void>;
250
- private readonly ensureLiveSession;
251
- private readonly requireLiveSession;
252
- private readonly publishSessionEvent;
253
- private readonly persistLiveSessionEvent;
254
- private readonly assertNotDisposed;
255
- private publishSessionRunStatus;
256
- }
227
+ //#region src/utils/ncp-agent-session-journal.utils.d.ts
228
+ declare const NCP_AGENT_SESSION_SNAPSHOT_MESSAGE_EVENT_TYPE = "session.snapshot.message";
229
+ declare const NCP_SESSION_REQUEST_ACCEPTED_EVENT_TYPE = "session.request.accepted";
230
+ declare const NCP_SESSION_REQUEST_COMPLETED_EVENT_TYPE = "session.request.completed";
231
+ declare const NCP_SESSION_REQUEST_FAILED_EVENT_TYPE = "session.request.failed";
232
+ type NcpAgentSessionSnapshotMessageEvent = {
233
+ type: typeof NCP_AGENT_SESSION_SNAPSHOT_MESSAGE_EVENT_TYPE;
234
+ payload: Extract<NcpEndpointEvent, {
235
+ type: NcpEventType.MessageSent;
236
+ }>["payload"];
237
+ };
238
+ type NcpSessionRequestJournalEventType = typeof NCP_SESSION_REQUEST_ACCEPTED_EVENT_TYPE | typeof NCP_SESSION_REQUEST_COMPLETED_EVENT_TYPE | typeof NCP_SESSION_REQUEST_FAILED_EVENT_TYPE;
239
+ type NcpSessionRequestJournalEvent = {
240
+ type: NcpSessionRequestJournalEventType;
241
+ payload: {
242
+ sessionId: string;
243
+ request: unknown;
244
+ };
245
+ };
246
+ type NcpAgentSessionJournalReplayEvent = NcpEndpointEvent | NcpAgentSessionSnapshotMessageEvent | NcpSessionRequestJournalEvent;
257
247
  //#endregion
258
- //#region src/managers/agent-run-request.manager.d.ts
259
- declare class AgentRunRequestManager {
260
- private readonly cleanups;
248
+ //#region src/stores/ncp-agent-session-journal.store.d.ts
249
+ declare class NcpAgentSessionJournalStore {
250
+ private readonly journalDir;
261
251
  private readonly sessions;
262
- private readonly ingress;
263
- private readonly sessionRunManager;
264
- private readonly onSessionUpdated;
265
- private disposed;
266
- private started;
267
- constructor(options: {
268
- sessions: SessionManager;
269
- ingress: Ingress;
270
- sessionRunManager: SessionRunManager;
271
- onSessionUpdated: (sessionKey: string) => void;
272
- });
273
- start: () => void;
274
- dispose: () => Promise<void>;
275
- run: (envelope: NcpRequestEnvelope, options?: NcpAgentRunSendOptions) => AsyncIterable<NcpEndpointEvent>;
276
- private readonly handleSendRequest;
277
- private readonly handleAbortRequest;
278
- private readonly iterateRun;
279
- private readonly materializeSendEnvelope;
280
- private readonly toNcpSendEnvelope;
281
- private readonly materializeRunEnvelope;
282
- private readonly handleSessionMessageRequest;
283
- private readonly assertNotDisposed;
284
- }
285
- //#endregion
286
- //#region src/managers/automation.manager.d.ts
287
- type AutomationManagerOptions = {
288
- storePath: string;
289
- };
290
- declare class AutomationManager extends CronService {
291
- constructor(options: AutomationManagerOptions);
252
+ private readonly nextSeqBySession;
253
+ private readonly writeChains;
254
+ private readonly metadataStore;
255
+ private readonly summaryIndexStore;
256
+ constructor(journalDir: string);
257
+ appendSessionEvent: (params: {
258
+ sessionId: string;
259
+ event: NcpAgentSessionJournalReplayEvent;
260
+ }) => Promise<void>;
261
+ getSession: (sessionId: string) => Promise<AgentSessionRecord | null>;
262
+ listSessionSummaries: () => Promise<NcpSessionSummary[]>;
263
+ listSessionMessages: (sessionId: string) => Promise<NcpMessage[]>;
264
+ setSessionMetadata: (params: {
265
+ sessionId: string;
266
+ metadata: Record<string, unknown>;
267
+ }) => Promise<boolean>;
268
+ updateSessionMetadata: (params: {
269
+ sessionId: string;
270
+ metadata: Record<string, unknown>;
271
+ }) => Promise<boolean>;
272
+ private setSessionMetadataNow;
273
+ private updateSessionMetadataNow;
274
+ importSessionSnapshot: (record: AgentSessionRecord) => Promise<void>;
275
+ deleteSession: (sessionId: string) => Promise<AgentSessionRecord | null>;
276
+ hasSession: (sessionId: string) => Promise<boolean>;
277
+ private appendSessionEventNow;
278
+ private withMetadata;
279
+ private loadSession;
280
+ private parseSessionJournal;
281
+ private appendJournalEntry;
282
+ private ensureJournalDir;
283
+ private sessionPath;
292
284
  }
293
285
  //#endregion
294
286
  //#region src/managers/llm-provider.manager.d.ts
@@ -418,6 +410,178 @@ declare class ConfigManager {
418
410
  private createConfigMutationResult;
419
411
  }
420
412
  //#endregion
413
+ //#region src/managers/ncp-session.manager.d.ts
414
+ type NcpSessionManagerOptions = {
415
+ configManager: ConfigManager;
416
+ eventBus: EventBus;
417
+ journalStore: NcpAgentSessionJournalStore;
418
+ sessionSearch: SessionSearchManager;
419
+ };
420
+ declare class NcpSessionManager implements NcpSessionApi {
421
+ private readonly options;
422
+ private readonly contextWindowPreview;
423
+ private readonly runningSessionIds;
424
+ private readonly unsubscribeSessionRunStatus;
425
+ constructor(options: NcpSessionManagerOptions);
426
+ dispose: () => void;
427
+ createSession: (params: CreateSessionInput) => Promise<CreatedSession>;
428
+ appendSessionEvent: (params: {
429
+ sessionId: string;
430
+ event: NcpAgentSessionJournalReplayEvent;
431
+ }) => Promise<void>;
432
+ setSessionMetadata: (sessionId: string, metadata: Record<string, unknown>) => Promise<boolean>;
433
+ updateSessionMetadata: (sessionId: string, metadata: Record<string, unknown>) => Promise<boolean>;
434
+ updateSession: (sessionId: string, patch: NcpSessionPatch) => Promise<NcpSessionSummary | null>;
435
+ deleteSession: (sessionId: string) => Promise<void>;
436
+ getSessionRecord: (sessionId: string) => Promise<AgentSessionRecord | null>;
437
+ listSessions: (options?: ListSessionsOptions) => Promise<NcpSessionSummary[]>;
438
+ listSessionMessages: (sessionId: string, options?: ListMessagesOptions) => Promise<NcpMessage[]>;
439
+ getSession: (sessionId: string) => Promise<NcpSessionSummary | null>;
440
+ getContextWindow: (sessionId: string, liveRecord?: AgentSessionRecord | null) => Promise<Record<string, unknown> | null>;
441
+ publishSessionChange: (sessionKey: string) => Promise<void>;
442
+ private createSummaryFromRecord;
443
+ private withLiveSessionStatus;
444
+ private handleSessionRunStatus;
445
+ private publishSessionMetadataChanged;
446
+ }
447
+ //#endregion
448
+ //#region src/managers/session-run.manager.d.ts
449
+ declare class SessionRunManager {
450
+ private readonly agentRuntimeManager;
451
+ private readonly ncpSessionManager;
452
+ private readonly eventBus;
453
+ private readonly liveSessions;
454
+ private readonly cleanups;
455
+ private disposed;
456
+ constructor(options: {
457
+ agentRuntimeManager: AgentRuntimeManager;
458
+ eventBus: EventBus;
459
+ ncpSessionManager: NcpSessionManager;
460
+ });
461
+ dispose: () => Promise<void>;
462
+ isRunning: (sessionId: string) => boolean;
463
+ getOrCreateLiveSession: (sessionId: string, initialMetadata?: Record<string, unknown>) => Promise<LiveSession>;
464
+ getActiveSessionRun: (sessionId: string) => LiveSessionExecution | null;
465
+ getLiveSessionRecord: (sessionId: string) => _$_nextclaw_ncp_toolkit0.AgentSessionRecord | null;
466
+ setActiveSessionRun: (sessionId: string, activeRun: LiveSessionExecution) => void;
467
+ deleteActiveSessionRun: (sessionId: string, runId: string) => void;
468
+ streamSessionEvents: (payload: NcpStreamRequestPayload, options?: NcpAgentRunStreamOptions) => AsyncIterable<NcpEndpointEvent>;
469
+ updateToolCallResult: UpdateToolCallResult;
470
+ updateSessionMetadata: (sessionId: string, metadata: Record<string, unknown>) => Promise<boolean>;
471
+ appendSessionEvent: (sessionId: string, event: NcpEndpointEvent, options?: PublishSessionEventOptions) => Promise<void>;
472
+ private readonly ensureLiveSession;
473
+ private readonly requireLiveSession;
474
+ private readonly publishSessionEvent;
475
+ private readonly persistLiveSessionEvent;
476
+ private readonly assertNotDisposed;
477
+ private publishSessionRunStatus;
478
+ }
479
+ //#endregion
480
+ //#region src/features/context-compaction/managers/context-compaction.manager.d.ts
481
+ declare class ContextWindowPreviewManager {
482
+ private readonly options;
483
+ private readonly contextWindowBudgetService;
484
+ constructor(options: {
485
+ configManager: ConfigManager;
486
+ });
487
+ preview: (params: {
488
+ requestMetadata: Record<string, unknown>;
489
+ sessionId: string;
490
+ sessionMessages: readonly NcpMessage[];
491
+ storedAgentId?: string;
492
+ storedMetadata: Record<string, unknown>;
493
+ }) => ContextWindowSnapshot | null;
494
+ }
495
+ declare class ContextCompactionManager {
496
+ private readonly options;
497
+ private readonly compactionService;
498
+ private readonly contextWindowBudgetService;
499
+ constructor(options: {
500
+ configManager: ConfigManager;
501
+ providerManager?: LlmProviderRuntime;
502
+ sessionRunManager: SessionRunManager;
503
+ });
504
+ runLivePreflight: (this: ContextCompactionManager, params: {
505
+ input: NcpAgentRunInput;
506
+ session: LiveSession;
507
+ }) => AsyncIterable<NcpEndpointEvent>;
508
+ private begin;
509
+ private finish;
510
+ private generateSummary;
511
+ private applyLivePreflightResult;
512
+ }
513
+ //#endregion
514
+ //#region src/features/context-compaction/utils/context-compaction-projection.utils.d.ts
515
+ declare function projectNcpMessagesWithContextCompaction(params: {
516
+ sessionId: string;
517
+ sessionMessages: readonly NcpMessage[];
518
+ }): NcpMessage[];
519
+ //#endregion
520
+ //#region src/features/context-compaction/utils/context-compaction-timeline-message.utils.d.ts
521
+ declare const NEXTCLAW_TIMELINE_KIND_METADATA_KEY = "nextclaw_timeline_kind";
522
+ declare const CONTEXT_COMPACTION_TIMELINE_KIND = "context_compaction";
523
+ type ContextCompactionTimelineCheckpoint = {
524
+ version: 1;
525
+ id: string;
526
+ status: "compressing" | "compressed";
527
+ summary: string;
528
+ coveredMessageCount: number;
529
+ coveredSessionMessageCount: number;
530
+ originalEstimatedTokens: number;
531
+ projectedEstimatedTokens: number;
532
+ createdAt: string;
533
+ updatedAt: string;
534
+ };
535
+ declare function buildContextCompactionTimelineNcpMessage(params: {
536
+ sessionId: string;
537
+ checkpoint: ContextCompactionTimelineCheckpoint;
538
+ }): NcpMessage;
539
+ declare function upsertContextCompactionTimelineMessage(params: {
540
+ session: Session;
541
+ checkpoint: ContextCompactionTimelineCheckpoint;
542
+ insertBeforeMessageIds?: readonly string[];
543
+ }): void;
544
+ declare function isContextCompactionTimelineMessage(message: {
545
+ metadata?: Record<string, unknown> | undefined;
546
+ } | null | undefined): boolean;
547
+ //#endregion
548
+ //#region src/managers/agent-run-request.manager.d.ts
549
+ declare class AgentRunRequestManager {
550
+ private readonly contextCompactionManager;
551
+ private readonly cleanups;
552
+ private readonly ingress;
553
+ private readonly ncpSessionManager;
554
+ private readonly sessionRunManager;
555
+ private disposed;
556
+ private started;
557
+ constructor(options: {
558
+ contextCompactionManager: ContextCompactionManager;
559
+ ingress: Ingress;
560
+ ncpSessionManager: NcpSessionManager;
561
+ sessionRunManager: SessionRunManager;
562
+ });
563
+ start: () => void;
564
+ dispose: () => Promise<void>;
565
+ run: (envelope: NcpRequestEnvelope, options?: NcpAgentRunSendOptions) => AsyncIterable<NcpEndpointEvent>;
566
+ private readonly handleSendRequest;
567
+ private readonly handleAbortRequest;
568
+ private readonly iterateRun;
569
+ private readonly materializeSendEnvelope;
570
+ private readonly toNcpSendEnvelope;
571
+ private readonly materializeRunEnvelope;
572
+ private readonly prepareRunSessionMetadata;
573
+ private readonly handleSessionMessageRequest;
574
+ private readonly assertNotDisposed;
575
+ }
576
+ //#endregion
577
+ //#region src/managers/automation.manager.d.ts
578
+ type AutomationManagerOptions = {
579
+ storePath: string;
580
+ };
581
+ declare class AutomationManager extends CronService {
582
+ constructor(options: AutomationManagerOptions);
583
+ }
584
+ //#endregion
421
585
  //#region src/services/extension-plugin-registry.service.d.ts
422
586
  type ExtensionPluginLoadProgress = {
423
587
  loadedPluginCount: number;
@@ -665,35 +829,46 @@ declare class SkillManager {
665
829
  private normalizeOptionalString;
666
830
  }
667
831
  //#endregion
668
- //#region src/services/ncp-session-api.service.d.ts
669
- type NcpAgentSessionReadableStore = AgentSessionStore & {
670
- listSessionSummaries?: () => Promise<NcpSessionSummary[]>;
671
- listSessionMessages?: (sessionId: string) => Promise<NcpMessage[]>;
832
+ //#region src/features/session-request/managers/session-request.manager.d.ts
833
+ type SessionRequestManagerOptions = {
834
+ dispatcher: SessionRequestDispatcher;
835
+ ncpSessionManager: NcpSessionManager;
672
836
  };
673
- type NcpSessionApiServiceOptions = {
674
- eventBus: EventBus;
675
- getConfig: () => Config;
676
- isLiveSessionRunning?: (sessionId: string) => boolean;
677
- ncpAgentSessionStore: NcpAgentSessionReadableStore;
678
- sessionManager: SessionManager;
679
- };
680
- declare class NcpSessionApiService implements NcpSessionApi {
837
+ declare class SessionRequestManager {
681
838
  private readonly options;
682
- private unsubscribeSessionUpdated;
683
- private readonly contextWindowPreview;
684
- constructor(options: NcpSessionApiServiceOptions);
685
- start: () => void;
686
- dispose: () => void;
687
- publishSessionChange: (sessionKey: string) => Promise<void>;
688
- listSessions: (options?: ListSessionsOptions) => Promise<NcpSessionSummary[]>;
689
- listSessionMessages: (sessionId: string, options?: ListMessagesOptions) => Promise<NcpMessage[]>;
690
- getSession: (sessionId: string) => Promise<NcpSessionSummary | null>;
691
- updateSession: (sessionId: string, patch: NcpSessionPatch) => Promise<NcpSessionSummary | null>;
692
- deleteSession: (sessionId: string) => Promise<void>;
693
- private createSummaryFromRecord;
694
- private withLiveSessionStatus;
839
+ constructor(options: SessionRequestManagerOptions);
840
+ spawnSessionAndRequest: (params: SpawnSessionAndRequestParams) => Promise<SessionRequestToolResult>;
841
+ requestSession: (params: RequestSessionParams) => Promise<SessionRequestToolResult>;
842
+ private dispatchRequest;
843
+ private toSessionRequestPayload;
844
+ private buildToolResult;
845
+ private appendRequestEvents;
846
+ private runRequest;
847
+ private runRequestAndUpdateToolCallResult;
848
+ private appendAcceptedRequestEvent;
849
+ private appendRequestEvent;
695
850
  }
696
851
  //#endregion
852
+ //#region src/features/session-request/utils/agent-runtime-session-request-dispatcher.utils.d.ts
853
+ type AgentRuntimeSessionRequestDispatcherOptions = {
854
+ eventBus: EventBus;
855
+ ingress: Ingress;
856
+ };
857
+ declare function waitForAgentRuntimeSessionReply(input: {
858
+ eventBus: EventBus;
859
+ onAccepted: (messageId: string) => void;
860
+ requestId: string;
861
+ }): {
862
+ dispose: Unsubscribe;
863
+ promise: Promise<NcpMessage>;
864
+ };
865
+ declare function dispatchAgentRuntimeSessionRequest(input: {
866
+ ingress: Ingress;
867
+ request: SessionRequestRecord;
868
+ task: string;
869
+ }): Promise<void>;
870
+ declare function createAgentRuntimeSessionRequestDispatcher(options: AgentRuntimeSessionRequestDispatcherOptions): SessionRequestDispatcher;
871
+ //#endregion
697
872
  //#region src/app/nextclaw-kernel.d.ts
698
873
  type NextclawKernelOptions = {
699
874
  homeDir?: string;
@@ -730,12 +905,11 @@ declare class NextclawKernel {
730
905
  readonly sessionSearch: SessionSearchManager;
731
906
  readonly assetStore: LocalAssetStore;
732
907
  readonly mcpManager: McpManager;
733
- readonly ncpSessionApi: NcpSessionApiService;
908
+ readonly ncpSessionManager: NcpSessionManager;
734
909
  readonly extensions: ExtensionManager;
735
910
  readonly agentRunRequestManager: AgentRunRequestManager;
736
911
  readonly sessionRunManager: SessionRunManager;
737
912
  readonly agentRuntimeManager: AgentRuntimeManager;
738
- private readonly ncpAgentSessionStore;
739
913
  private readonly ncpAgentSessionJournalStore;
740
914
  private readonly contributions;
741
915
  private gatewayController;
@@ -744,7 +918,6 @@ declare class NextclawKernel {
744
918
  getGatewayController: () => GatewayController | undefined;
745
919
  start: () => Promise<void>;
746
920
  dispose: () => Promise<void>;
747
- publishSessionUpdated: (sessionKey: string) => void;
748
921
  }
749
922
  //#endregion
750
923
  //#region src/contributions/learning-loop/config.d.ts
@@ -758,8 +931,8 @@ declare function readLearningLoopRuntimeConfig(config: Config): LearningLoopRunt
758
931
  declare const NARP_HTTP_RUNTIME_KIND = "narp-http";
759
932
  declare const NARP_STDIO_RUNTIME_KIND = "narp-stdio";
760
933
  declare class BuiltinNarpRuntimeProviderService {
761
- private readonly getConfig;
762
- constructor(getConfig: () => Config);
934
+ private readonly configManager;
935
+ constructor(configManager: Pick<ConfigManager, "loadConfig">);
763
936
  createProviders: () => AgentRuntimeProviderRegistration[];
764
937
  private createUnavailableRuntime;
765
938
  private createHttpRuntime;
@@ -867,7 +1040,6 @@ declare function dispatchChannelReplyRoute(params: ChannelReplyRouterDispatchPar
867
1040
  //#region src/features/ncp-dispatch/utils/nextclaw-ncp-dispatch.utils.d.ts
868
1041
  type DirectPromptDispatchParams = {
869
1042
  config: Config;
870
- sessionManager: SessionManager;
871
1043
  agentRunRequests: NcpRunnerAgent;
872
1044
  content: string;
873
1045
  sessionKey?: string;
@@ -881,104 +1053,12 @@ type DirectPromptDispatchParams = {
881
1053
  };
882
1054
  declare function dispatchPromptOverNcp(params: DirectPromptDispatchParams): Promise<string>;
883
1055
  //#endregion
884
- //#region src/features/context-compaction/services/context-compaction-preflight.service.d.ts
885
- type ContextWindowOwner = "nextclaw" | "runtime";
886
- type ContextCompactionPreflightResult = {
887
- contextWindow: ContextWindowSnapshot;
888
- metadata: Record<string, unknown>;
889
- sessionMessages: NcpMessage[];
890
- timelineMessage: NcpMessage | null;
891
- };
892
- type ContextCompactionPreflightBeginResult = ContextCompactionPreflightResult & {
893
- pendingCompaction: ContextCompactionPendingWork | null;
894
- };
895
- type ContextCompactionPendingWork = {
896
- checkpoint: ReturnType<typeof buildCompressingCompactionCheckpoint>;
897
- contextTokens: number;
898
- inputMessageIds: string[];
899
- model: string;
900
- plan: ContextCompactionPlan;
901
- reservedContextTokens: number;
902
- sessionId: string;
903
- };
904
- declare class ContextCompactionPreflightService {
905
- private readonly options;
906
- private readonly compactionService;
907
- private readonly contextWindowBudgetService;
908
- constructor(options: {
909
- getConfig: () => Config;
910
- providerManager?: LlmProviderRuntime;
911
- sessionManager: SessionManager;
912
- });
913
- run: (params: {
914
- contextWindowOwner: ContextWindowOwner;
915
- inputMessages: readonly NcpMessage[];
916
- requestMetadata: Record<string, unknown>;
917
- sessionId: string;
918
- sessionMessages: readonly NcpMessage[];
919
- }) => Promise<ContextCompactionPreflightResult | null>;
920
- preview: (params: {
921
- contextWindowOwner: ContextWindowOwner;
922
- requestMetadata: Record<string, unknown>;
923
- sessionId: string;
924
- sessionMessages: readonly NcpMessage[];
925
- }) => ContextWindowSnapshot | null;
926
- begin: (params: {
927
- contextWindowOwner: ContextWindowOwner;
928
- inputMessages: readonly NcpMessage[];
929
- requestMetadata: Record<string, unknown>;
930
- sessionId: string;
931
- sessionMessages: readonly NcpMessage[];
932
- }) => ContextCompactionPreflightBeginResult | null;
933
- private buildContextWindowSnapshotForMessages;
934
- finish: (pending: ContextCompactionPendingWork) => Promise<ContextCompactionPreflightResult>;
935
- private generateSummary;
936
- }
937
- //#endregion
938
- //#region src/features/context-compaction/utils/context-compaction-projection.utils.d.ts
939
- declare function projectNcpMessagesWithContextCompaction(params: {
940
- sessionId: string;
941
- sessionMessages: readonly NcpMessage[];
942
- }): NcpMessage[];
943
- //#endregion
944
- //#region src/features/context-compaction/utils/context-compaction-timeline-message.utils.d.ts
945
- declare const NEXTCLAW_TIMELINE_KIND_METADATA_KEY = "nextclaw_timeline_kind";
946
- declare const CONTEXT_COMPACTION_TIMELINE_KIND = "context_compaction";
947
- type ContextCompactionTimelineCheckpoint = {
948
- version: 1;
949
- id: string;
950
- status: "compressing" | "compressed";
951
- summary: string;
952
- coveredMessageCount: number;
953
- coveredSessionMessageCount: number;
954
- originalEstimatedTokens: number;
955
- projectedEstimatedTokens: number;
956
- createdAt: string;
957
- updatedAt: string;
958
- };
959
- declare function buildContextCompactionTimelineNcpMessage(params: {
960
- sessionId: string;
961
- checkpoint: ContextCompactionTimelineCheckpoint;
962
- }): NcpMessage;
963
- declare function upsertContextCompactionTimelineMessage(params: {
964
- session: Session;
965
- checkpoint: ContextCompactionTimelineCheckpoint;
966
- insertBeforeMessageIds?: readonly string[];
967
- }): void;
968
- declare function isContextCompactionTimelineMessage(message: {
969
- metadata?: Record<string, unknown> | undefined;
970
- } | null | undefined): boolean;
971
- //#endregion
972
1056
  //#region src/features/native-runtime/services/native-agent-runtime-factory.service.d.ts
973
1057
  type NativeRuntimeFactory = (runtimeParams: RuntimeFactoryParams) => NcpAgentRuntime;
974
1058
  type NativeAgentRuntimeFactoryOptions = {
975
1059
  providerManager: LlmProviderRuntime;
976
- sessions: SessionManager;
977
- configManager: {
978
- loadConfig: () => Config;
979
- };
1060
+ configManager: ConfigManager;
980
1061
  llmUsage: LlmUsageManager;
981
- onSessionUpdated: (sessionKey: string) => void;
982
1062
  assetStore: LocalAssetStore;
983
1063
  updateToolCallResult: UpdateToolCallResult;
984
1064
  toolManager: ToolManager;
@@ -993,9 +1073,9 @@ declare class NativeAgentRuntimeFactory {
993
1073
  //#endregion
994
1074
  //#region src/features/native-runtime/services/nextclaw-ncp-context-builder.service.d.ts
995
1075
  type NextclawNcpContextBuilderOptions = {
996
- sessionManager: SessionManager;
1076
+ agentId?: string;
997
1077
  toolRegistry: ToolRuntimeRegistry;
998
- getConfig: () => Config;
1078
+ configManager: ConfigManager;
999
1079
  assetStore?: LocalAssetStore | null;
1000
1080
  };
1001
1081
  declare class NextclawNcpContextBuilder implements NcpContextBuilder {
@@ -1021,25 +1101,30 @@ declare function createAssetTools(params: {
1021
1101
  contentBasePath?: string;
1022
1102
  }): NcpTool[];
1023
1103
  //#endregion
1024
- //#region src/features/session-request/utils/agent-runtime-session-request-dispatcher.utils.d.ts
1025
- type AgentRuntimeSessionRequestDispatcherOptions = {
1026
- eventBus: EventBus;
1027
- ingress: Ingress;
1104
+ //#region src/features/native-runtime/utils/nextclaw-ncp-session-preferences.utils.d.ts
1105
+ declare function normalizeOptionalString(value: unknown): string | undefined;
1106
+ declare function readMetadataModel(metadata: Record<string, unknown>): string | null;
1107
+ declare function readMetadataThinking(metadata: Record<string, unknown>): ThinkingLevel | "__clear__" | null;
1108
+ declare function resolveEffectiveModel(params: {
1109
+ sessionMetadata: Record<string, unknown>;
1110
+ requestMetadata: Record<string, unknown>;
1111
+ fallbackModel: string;
1112
+ }): {
1113
+ metadata: Record<string, unknown>;
1114
+ model: string;
1028
1115
  };
1029
- declare function waitForAgentRuntimeSessionReply(input: {
1030
- eventBus: EventBus;
1031
- onAccepted: (messageId: string) => void;
1032
- requestId: string;
1116
+ declare function syncSessionThinkingPreference(params: {
1117
+ sessionMetadata: Record<string, unknown>;
1118
+ requestMetadata: Record<string, unknown>;
1119
+ }): Record<string, unknown>;
1120
+ declare function resolveSessionChannelContext(params: {
1121
+ sessionMetadata: Record<string, unknown>;
1122
+ requestMetadata: Record<string, unknown>;
1033
1123
  }): {
1034
- dispose: Unsubscribe;
1035
- promise: Promise<NcpMessage>;
1124
+ channel: string;
1125
+ chatId: string;
1126
+ metadata: Record<string, unknown>;
1036
1127
  };
1037
- declare function dispatchAgentRuntimeSessionRequest(input: {
1038
- ingress: Ingress;
1039
- request: SessionRequestRecord;
1040
- task: string;
1041
- }): Promise<void>;
1042
- declare function createAgentRuntimeSessionRequestDispatcher(options: AgentRuntimeSessionRequestDispatcherOptions): SessionRequestDispatcher;
1043
1128
  //#endregion
1044
1129
  //#region src/features/extension-runtime/utils/extension-channel-catalog.utils.d.ts
1045
1130
  declare function listExtensionChannelIds(params: {
@@ -1047,18 +1132,6 @@ declare function listExtensionChannelIds(params: {
1047
1132
  workspace: string;
1048
1133
  }): string[];
1049
1134
  //#endregion
1050
- //#region src/utils/ncp-session-summary.utils.d.ts
1051
- declare function createNcpSessionSummary(params: {
1052
- sessionId: string;
1053
- agentId?: string;
1054
- messages: readonly NcpMessage[];
1055
- createdAt: string;
1056
- updatedAt: string;
1057
- status: NcpSessionStatus;
1058
- metadata?: Record<string, unknown>;
1059
- contextWindow?: Record<string, unknown> | null;
1060
- }): NcpSessionSummary;
1061
- //#endregion
1062
1135
  //#region src/utils/ncp-session-message-adapter.utils.d.ts
1063
1136
  declare function toNcpMessages(sessionId: string, messages: SessionMessage[]): NcpMessage[];
1064
1137
  declare function resolveLegacyEventType(message: SessionMessage): string;
@@ -1083,4 +1156,4 @@ type SkillRecord = {
1083
1156
  metadata: Record<string, unknown>;
1084
1157
  };
1085
1158
  //#endregion
1086
- export { AgentId, AgentManager, AgentRecord, AgentRunRequestManager, AgentRuntimeEntry, AgentRuntimeManager, AgentRuntimeManagerOptions, AgentRuntimeProviderRegistration, AgentRuntimeRegistry, AgentRuntimeSessionRequestDispatcherOptions, AgentRuntimeSessionTypeDescribeParams, AgentRuntimeSessionTypeIcon, AgentRuntimeSessionTypeOption, AutomationId, AutomationManager, AutomationManagerOptions, BuiltinNarpRuntimeProviderService, CONTEXT_COMPACTION_TIMELINE_KIND, ChannelId, ChannelManager, ChannelReplyRouterDispatchParams, ConfigManager, ConfigManagerOptions, ConfigManagerRuntimeHooks, ConfigMutationResult, ContextCompactionPendingWork, ContextCompactionPreflightBeginResult, ContextCompactionPreflightResult, ContextCompactionPreflightService, ContextCompactionTimelineCheckpoint, ContextWindowOwner, DEFAULT_AGENT_RUNTIME_ENTRY_ID, DirectPromptDispatchParams, ExtensionLoadProgress, ExtensionLoadResult, ExtensionManager, ExtensionPluginLoadProgress, ExtensionPluginRegistryService, GatewayInboundLoopRuntime, GatewayInboundProcessor, InstallationKind, InstalledSkillDetail, InstalledSkillSummary, InstalledSkillsList, type LearningLoopRuntimeConfig, LlmProviderManager, LlmProviderRuntime, LlmUsageManager, LlmUsageManagerOptions, LlmUsageRecord, LlmUsageSnapshot, LlmUsageStats, LlmUsageStore, LlmUsageStoreOptions, LlmUsageSummary, LocalizedTextMap, McpManager, NARP_HTTP_RUNTIME_KIND, NARP_STDIO_RUNTIME_KIND, NEXTCLAW_TIMELINE_KIND_METADATA_KEY, NativeAgentRuntimeFactory, NativeAgentRuntimeFactoryOptions, NativeRuntimeFactory, NcpRunnerAgent, NcpSessionApiService, NcpSessionApiServiceOptions, NextclawKernel, NextclawKernelOptions, NextclawNcpContextBuilder, ProviderManagerNcpLLMApi, RunPromptOverNcpParams, SessionId, SessionRunManager, SkillFrontmatter, SkillId, type SkillInfo, SkillManager, SkillRecord, type SkillScope, StreamPromptOverNcpParams, TaskId, ToolId, ToolManager, ToolProvider, ToolRecord, ToolRegistrationContext, ToolRunContext, ToolRuntimeRegistry, ToolRuntimeRegistryOptions, UnsignedUpdateManifest, UpdateBlockReason, UpdateHostKind, UpdateManifest, UpdateManifestReader, UpdatePreferences, UpdateProgress, UpdateSnapshot, UpdateStatus, UpdateToolCallResult, buildContextCompactionTimelineNcpMessage, buildLlmUsageSummary, buildLocalizedTextMap, buildNcpUserMessage, buildUserMessageParts, createAgentRuntimeSessionRequestDispatcher, createAssetTools, createLlmUsageRecord, createNcpSessionSummary, dispatchAgentRuntimeSessionRequest, dispatchChannelReplyRoute, dispatchPromptOverNcp, getUnsignedUpdateManifest, hasLlmUsageTelemetry, isContextCompactionTimelineMessage, isReplyCapableChannel, listExtensionChannelIds, normalizeAgentRuntimeSessionTypeIcon, normalizeLlmUsageModel, parseSkillFrontmatter, projectNcpMessagesWithContextCompaction, readLearningLoopRuntimeConfig, resolveAgentHandoffDepth, resolveAgentRuntimeEntries, resolveChannelReplyRoute, resolveLegacyEventType, runGatewayInboundLoop, runPromptOverNcp, sanitizeLlmUsage, serializeUnsignedUpdateManifest, streamPromptOverNcp, stripSkillFrontmatter, toNcpMessages, upsertContextCompactionTimelineMessage, waitForAgentRuntimeSessionReply };
1159
+ export { AgentId, AgentManager, AgentRecord, AgentRunRequestManager, AgentRuntimeEntry, AgentRuntimeManager, AgentRuntimeManagerOptions, AgentRuntimeProviderRegistration, AgentRuntimeRegistry, AgentRuntimeSessionRequestDispatcherOptions, AgentRuntimeSessionTypeDescribeParams, AgentRuntimeSessionTypeIcon, AgentRuntimeSessionTypeOption, AutomationId, AutomationManager, AutomationManagerOptions, BuiltinNarpRuntimeProviderService, CONTEXT_COMPACTION_TIMELINE_KIND, ChannelId, ChannelManager, ChannelReplyRouterDispatchParams, ConfigManager, ConfigManagerOptions, ConfigManagerRuntimeHooks, ConfigMutationResult, ContextCompactionManager, ContextCompactionTimelineCheckpoint, ContextWindowPreviewManager, DEFAULT_AGENT_RUNTIME_ENTRY_ID, DirectPromptDispatchParams, ExtensionLoadProgress, ExtensionLoadResult, ExtensionManager, ExtensionPluginLoadProgress, ExtensionPluginRegistryService, GatewayInboundLoopRuntime, GatewayInboundProcessor, InstallationKind, InstalledSkillDetail, InstalledSkillSummary, InstalledSkillsList, type LearningLoopRuntimeConfig, LlmProviderManager, LlmProviderRuntime, LlmUsageManager, LlmUsageManagerOptions, LlmUsageRecord, LlmUsageSnapshot, LlmUsageStats, LlmUsageStore, LlmUsageStoreOptions, LlmUsageSummary, LocalizedTextMap, McpManager, NARP_HTTP_RUNTIME_KIND, NARP_STDIO_RUNTIME_KIND, NEXTCLAW_TIMELINE_KIND_METADATA_KEY, NativeAgentRuntimeFactory, NativeAgentRuntimeFactoryOptions, NativeRuntimeFactory, NcpAgentSessionJournalStore, NcpRunnerAgent, NcpSessionManager, NcpSessionManagerOptions, NextclawKernel, NextclawKernelOptions, NextclawNcpContextBuilder, ProviderManagerNcpLLMApi, RunPromptOverNcpParams, SessionId, SessionRequestManager, SessionRequestManagerOptions, SessionRunManager, SkillFrontmatter, SkillId, type SkillInfo, SkillManager, SkillRecord, type SkillScope, StreamPromptOverNcpParams, TaskId, ToolId, ToolManager, ToolProvider, ToolRecord, ToolRegistrationContext, ToolRunContext, ToolRuntimeRegistry, ToolRuntimeRegistryOptions, UnsignedUpdateManifest, UpdateBlockReason, UpdateHostKind, UpdateManifest, UpdateManifestReader, UpdatePreferences, UpdateProgress, UpdateSnapshot, UpdateStatus, UpdateToolCallResult, buildContextCompactionTimelineNcpMessage, buildLlmUsageSummary, buildLocalizedTextMap, buildNcpUserMessage, buildUserMessageParts, createAgentRuntimeSessionRequestDispatcher, createAssetTools, createLlmUsageRecord, dispatchAgentRuntimeSessionRequest, dispatchChannelReplyRoute, dispatchPromptOverNcp, getUnsignedUpdateManifest, hasLlmUsageTelemetry, isContextCompactionTimelineMessage, isReplyCapableChannel, listExtensionChannelIds, normalizeAgentRuntimeSessionTypeIcon, normalizeLlmUsageModel, normalizeOptionalString, parseSkillFrontmatter, projectNcpMessagesWithContextCompaction, readLearningLoopRuntimeConfig, readMetadataModel, readMetadataThinking, resolveAgentHandoffDepth, resolveAgentRuntimeEntries, resolveChannelReplyRoute, resolveEffectiveModel, resolveLegacyEventType, resolveSessionChannelContext, runGatewayInboundLoop, runPromptOverNcp, sanitizeLlmUsage, serializeUnsignedUpdateManifest, streamPromptOverNcp, stripSkillFrontmatter, syncSessionThinkingPreference, toNcpMessages, upsertContextCompactionTimelineMessage, waitForAgentRuntimeSessionReply };