@nextclaw/kernel 0.1.2-beta.6 → 0.1.3

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 CHANGED
@@ -1,5 +1,14 @@
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-BAJqcsP5.js";
2
- import { NcpMessage, NcpSessionSummary } from "@nextclaw/ncp";
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, GatewayController, InboundAttachment, InboundMessage, LLMProvider, LLMResponse, LLMStreamEvent, MessageBus, SearchConfig, SessionManager, SessionMessage, SessionRequestDispatcher, SessionRequestManager, SessionRequestRecord, SessionRequestToolResult, SessionSearchManager, SpawnSessionAndRequestParams, ThinkingLevel, buildCompressingCompactionCheckpoint } from "@nextclaw/core";
3
+ import * as _$_nextclaw_shared0 from "@nextclaw/shared";
4
+ import { EventBus, Ingress, Unsubscribe } from "@nextclaw/shared";
5
+ import { LocalAssetStore } from "@nextclaw/ncp-agent-runtime";
6
+ import * as _$_nextclaw_ncp0 from "@nextclaw/ncp";
7
+ import { ListMessagesOptions, ListSessionsOptions, NcpAgentClientEndpoint, NcpAgentRunApi, NcpAgentRunInput, NcpAgentRuntime, NcpContextBuilder, NcpContextPrepareOptions, NcpEndpointEvent, NcpLLMApi, NcpLLMApiInput, NcpLLMApiOptions, NcpMessage, NcpMessagePart, NcpSessionApi, NcpSessionPatch, NcpSessionStatus, NcpSessionSummary, NcpTool, NcpToolDefinition, NcpToolRegistry, OpenAIChatChunk } from "@nextclaw/ncp";
8
+ import { AgentSessionStore, ChatTarget, DefaultNcpAgentBackend, NcpReplyInput, RuntimeFactoryParams } from "@nextclaw/ncp-toolkit";
9
+ import { McpNcpToolRegistryAdapter } from "@nextclaw/ncp-mcp";
10
+ import { PluginChannelBinding, PluginRegistry, PluginUiMetadata } from "@nextclaw/openclaw-compat";
11
+ import { NcpHttpAgentStreamProvider } from "@nextclaw/ncp-http-agent-server";
3
12
 
4
13
  //#region src/types/entity-ids.types.d.ts
5
14
  type AgentId = string;
@@ -7,7 +16,6 @@ type TaskId = string;
7
16
  type SessionId = string;
8
17
  type ToolId = string;
9
18
  type SkillId = string;
10
- type LlmProviderId = string;
11
19
  type AutomationId = string;
12
20
  type ChannelId = string;
13
21
  //#endregion
@@ -16,7 +24,6 @@ type AgentRecord = {
16
24
  id: AgentId;
17
25
  name: string;
18
26
  description?: string;
19
- defaultProviderId?: LlmProviderId | null;
20
27
  enabledSkillIds: SkillId[];
21
28
  enabledToolIds: ToolId[];
22
29
  metadata: Record<string, unknown>;
@@ -24,159 +31,583 @@ type AgentRecord = {
24
31
  //#endregion
25
32
  //#region src/managers/agent.manager.d.ts
26
33
  declare class AgentManager {
27
- readonly listAgents: () => never;
28
- readonly getAgent: (agentId: AgentId) => never;
29
- readonly requireAgent: (agentId: AgentId) => never;
30
- readonly saveAgent: (agent: AgentRecord) => never;
31
- readonly removeAgent: (agentId: AgentId) => never;
32
- readonly attachSkill: (agentId: AgentId, skillId: SkillId) => never;
33
- readonly detachSkill: (agentId: AgentId, skillId: SkillId) => never;
34
- readonly attachTool: (agentId: AgentId, toolId: ToolId) => never;
35
- readonly detachTool: (agentId: AgentId, toolId: ToolId) => never;
34
+ listAgents: () => never;
35
+ getAgent: (agentId: AgentId) => never;
36
+ requireAgent: (agentId: AgentId) => never;
37
+ saveAgent: (agent: AgentRecord) => never;
38
+ removeAgent: (agentId: AgentId) => never;
39
+ attachSkill: (agentId: AgentId, skillId: SkillId) => never;
40
+ detachSkill: (agentId: AgentId, skillId: SkillId) => never;
41
+ attachTool: (agentId: AgentId, toolId: ToolId) => never;
42
+ detachTool: (agentId: AgentId, toolId: ToolId) => never;
36
43
  }
37
44
  //#endregion
38
- //#region src/types/automation.types.d.ts
39
- type AutomationTrigger = {
40
- kind: "cron";
41
- expression: string;
42
- } | {
43
- kind: "manual";
44
- } | {
45
- kind: "event";
46
- event: string;
47
- };
48
- type AutomationRecord = {
49
- id: AutomationId;
50
- name: string;
51
- enabled: boolean;
52
- trigger: AutomationTrigger;
53
- agentId: AgentId;
54
- sessionId?: SessionId | null;
55
- inputTemplate?: unknown;
56
- metadata: Record<string, unknown>;
45
+ //#region src/managers/llm-provider.manager.d.ts
46
+ type ProviderChatParams = {
47
+ messages: Array<Record<string, unknown>>;
48
+ tools?: Array<Record<string, unknown>>;
49
+ model?: string | null;
50
+ maxTokens?: number;
51
+ thinkingLevel?: ThinkingLevel | null;
52
+ signal?: AbortSignal;
53
+ };
54
+ type LlmProviderRuntime = {
55
+ get: (model?: string | null) => LLMProvider;
56
+ chat: (params: ProviderChatParams) => Promise<LLMResponse>;
57
+ chatStream: (params: ProviderChatParams) => AsyncGenerator<LLMStreamEvent>;
58
+ };
59
+ type ProviderConnectionTestInput = {
60
+ providerName: string | null;
61
+ apiKey?: string | null;
62
+ apiBase?: string | null;
63
+ defaultModel: string;
64
+ extraHeaders?: Record<string, string> | null;
65
+ wireApi?: "auto" | "chat" | "responses" | null;
66
+ messages: Array<Record<string, unknown>>;
67
+ maxTokens?: number;
68
+ signal?: AbortSignal;
57
69
  };
70
+ declare class LlmProviderManager {
71
+ private readonly providerRegistry;
72
+ private readonly providerPool;
73
+ private readonly missingProvider;
74
+ private config;
75
+ constructor();
76
+ load: (config: Config) => void;
77
+ get: (model?: string | null) => LLMProvider;
78
+ readonly chat: (params: ProviderChatParams) => Promise<LLMResponse>;
79
+ readonly chatStream: (this: LlmProviderManager, params: ProviderChatParams) => AsyncGenerator<LLMStreamEvent>;
80
+ readonly testConnection: (input: ProviderConnectionTestInput) => Promise<void>;
81
+ private resolveRoute;
82
+ private resolveProvider;
83
+ private matchPrefixedProvider;
84
+ private getOrCreateProvider;
85
+ private createProvider;
86
+ private buildCacheKey;
87
+ }
58
88
  //#endregion
59
- //#region src/managers/automation.manager.d.ts
60
- declare class AutomationManager {
61
- readonly listAutomations: () => never;
62
- readonly getAutomation: (automationId: AutomationId) => never;
63
- readonly requireAutomation: (automationId: AutomationId) => never;
64
- readonly saveAutomation: (automation: AutomationRecord) => never;
65
- readonly enableAutomation: (automationId: AutomationId) => never;
66
- readonly disableAutomation: (automationId: AutomationId) => never;
67
- readonly deleteAutomation: (automationId: AutomationId) => never;
89
+ //#region src/managers/extension.manager.d.ts
90
+ type AgentRuntimeContribution = {
91
+ pluginId: string;
92
+ kind: string;
93
+ label: string;
94
+ createRuntime: (params: RuntimeFactoryParams) => NcpAgentRuntime;
95
+ createRuntimeForEntry?: (params: {
96
+ entry: {
97
+ id: string;
98
+ label: string;
99
+ type: string;
100
+ enabled?: boolean;
101
+ config?: Record<string, unknown>;
102
+ };
103
+ runtimeParams: RuntimeFactoryParams;
104
+ }) => NcpAgentRuntime;
105
+ describeSessionType?: (params?: {
106
+ describeMode?: "observation" | "probe";
107
+ }) => Promise<Record<string, unknown> | null | undefined> | Record<string, unknown> | null | undefined;
108
+ describeSessionTypeForEntry?: (params: {
109
+ entry: {
110
+ id: string;
111
+ label: string;
112
+ type: string;
113
+ enabled?: boolean;
114
+ config?: Record<string, unknown>;
115
+ };
116
+ describeParams?: {
117
+ describeMode?: "observation" | "probe";
118
+ };
119
+ }) => Promise<Record<string, unknown> | null | undefined> | Record<string, unknown> | null | undefined;
120
+ source?: string;
121
+ };
122
+ type NextclawExtensionRegistry = ExtensionRegistry & {
123
+ ncpAgentRuntimes: AgentRuntimeContribution[];
124
+ };
125
+ type ExtensionContributions = {
126
+ registry: PluginRegistry;
127
+ extensionRegistry: NextclawExtensionRegistry;
128
+ channelBindings?: PluginChannelBinding[];
129
+ uiMetadata?: PluginUiMetadata[];
130
+ };
131
+ declare class ExtensionManager {
132
+ private pluginRegistry;
133
+ private extensionRegistry;
134
+ private channelBindings;
135
+ private uiMetadata;
136
+ loadContributions: (contributions: ExtensionContributions) => void;
137
+ loadExtensionRegistry: (extensionRegistry: NextclawExtensionRegistry) => void;
138
+ getExtensionRegistry: () => NextclawExtensionRegistry;
139
+ getChannelBindings: () => PluginChannelBinding[];
140
+ getUiMetadata: () => PluginUiMetadata[];
141
+ toConfigView: (config: Config) => Config;
142
+ mergeConfigView: (current: Config, nextConfigView: Record<string, unknown>) => Config;
143
+ resolveMessageToolHints: (params: {
144
+ channel?: string | null;
145
+ config?: Config;
146
+ accountId?: string | null;
147
+ }) => string[];
68
148
  }
69
149
  //#endregion
70
- //#region src/types/channel.types.d.ts
71
- type ChannelDirection = "inbound" | "outbound" | "bidirectional";
72
- type ChannelRecord = {
73
- id: ChannelId;
74
- name: string;
75
- enabled: boolean;
76
- direction: ChannelDirection;
77
- metadata: Record<string, unknown>;
78
- };
150
+ //#region src/features/runtime-registry/services/agent-runtime-registry.service.d.ts
151
+ declare const DEFAULT_AGENT_RUNTIME_ENTRY_ID = "native";
152
+ type AgentRuntimeSessionTypeIcon = {
153
+ kind: "image";
154
+ src: string;
155
+ alt?: string | null;
156
+ };
157
+ type AgentRuntimeSessionTypeOption = {
158
+ value: string;
159
+ label: string;
160
+ icon?: AgentRuntimeSessionTypeIcon | null;
161
+ ready?: boolean;
162
+ reason?: string | null;
163
+ reasonMessage?: string | null;
164
+ supportedModels?: string[];
165
+ recommendedModel?: string | null;
166
+ cta?: {
167
+ kind: string;
168
+ label?: string;
169
+ href?: string;
170
+ } | null;
171
+ };
172
+ type AgentRuntimeSessionTypeDescribeParams = {
173
+ describeMode?: "observation" | "probe";
174
+ };
175
+ type AgentRuntimeEntry = {
176
+ id: string;
177
+ label: string;
178
+ icon?: AgentRuntimeSessionTypeIcon | null;
179
+ type: string;
180
+ enabled?: boolean;
181
+ config?: Record<string, unknown>;
182
+ };
183
+ type AgentRuntimeProviderRegistration = {
184
+ kind: string;
185
+ label: string;
186
+ createRuntime: (params: RuntimeFactoryParams) => NcpAgentRuntime;
187
+ createRuntimeForEntry?: (params: {
188
+ entry: AgentRuntimeEntry;
189
+ runtimeParams: RuntimeFactoryParams;
190
+ }) => NcpAgentRuntime;
191
+ describeSessionType?: (params?: AgentRuntimeSessionTypeDescribeParams) => Promise<Omit<AgentRuntimeSessionTypeOption, "value" | "label"> | null | undefined> | Omit<AgentRuntimeSessionTypeOption, "value" | "label"> | null | undefined;
192
+ describeSessionTypeForEntry?: (params: {
193
+ entry: AgentRuntimeEntry;
194
+ describeParams?: AgentRuntimeSessionTypeDescribeParams;
195
+ }) => Promise<Omit<AgentRuntimeSessionTypeOption, "value" | "label"> | null | undefined> | Omit<AgentRuntimeSessionTypeOption, "value" | "label"> | null | undefined;
196
+ };
197
+ declare function normalizeAgentRuntimeSessionTypeIcon(value: unknown): AgentRuntimeSessionTypeIcon | null;
198
+ type ConfigRuntimeEntry = {
199
+ enabled?: boolean;
200
+ label?: string;
201
+ icon?: unknown;
202
+ type?: string;
203
+ config?: Record<string, unknown>;
204
+ };
205
+ type AgentRuntimeResolverConfig = {
206
+ ui?: {
207
+ ncp?: {
208
+ runtimes?: {
209
+ native?: unknown;
210
+ };
211
+ };
212
+ };
213
+ agents: {
214
+ runtimes: {
215
+ entries?: Record<string, ConfigRuntimeEntry>;
216
+ };
217
+ };
218
+ };
219
+ declare function resolveAgentRuntimeEntries(params: {
220
+ config: AgentRuntimeResolverConfig;
221
+ providerKinds: string[];
222
+ }): {
223
+ defaultEntryId: string;
224
+ entries: AgentRuntimeEntry[];
225
+ };
226
+ declare class AgentRuntimeRegistry {
227
+ private readonly providers;
228
+ private entries;
229
+ private defaultEntryId;
230
+ register: (registration: AgentRuntimeProviderRegistration) => Disposable;
231
+ applyEntries: (params: {
232
+ entries: AgentRuntimeEntry[];
233
+ defaultEntryId?: string;
234
+ }) => void;
235
+ listProviderKinds: () => string[];
236
+ createRuntime: (params: RuntimeFactoryParams) => NcpAgentRuntime;
237
+ listSessionTypes: (params?: AgentRuntimeSessionTypeDescribeParams) => Promise<{
238
+ defaultType: string;
239
+ options: AgentRuntimeSessionTypeOption[];
240
+ }>;
241
+ }
79
242
  //#endregion
80
- //#region src/managers/channel.manager.d.ts
81
- declare class ChannelManager {
82
- readonly listChannels: () => never;
83
- readonly getChannel: (channelId: ChannelId) => never;
84
- readonly requireChannel: (channelId: ChannelId) => never;
85
- readonly saveChannel: (channel: ChannelRecord) => never;
86
- readonly enableChannel: (channelId: ChannelId) => never;
87
- readonly disableChannel: (channelId: ChannelId) => never;
243
+ //#region src/features/runtime-registry/controllers/plugin-runtime-registration.controller.d.ts
244
+ declare class PluginRuntimeRegistrationController {
245
+ private readonly runtimeRegistry;
246
+ private readonly extensions;
247
+ private readonly pluginRuntimeScopes;
248
+ private pluginRuntimeSnapshotKey;
249
+ constructor(runtimeRegistry: AgentRuntimeRegistry, extensions: ExtensionManager);
250
+ refreshPluginRuntimeRegistrations: () => void;
251
+ dispose: () => void;
252
+ private syncPluginRuntimeRegistrations;
253
+ private resolveActiveExtensionRegistry;
88
254
  }
89
255
  //#endregion
90
- //#region src/types/context.types.d.ts
91
- type ContextRecord = {
92
- sessionId: SessionId;
93
- taskId?: TaskId | null;
94
- agentId?: AgentId | null;
95
- workspace?: string | null;
96
- memoryRefs: string[];
97
- selectedSkillIds: SkillId[];
98
- selectedToolIds: ToolId[];
99
- selectedProviderId?: LlmProviderId | null;
100
- variables: Record<string, unknown>;
101
- };
102
- //#endregion
103
- //#region src/types/task.types.d.ts
104
- type TaskStatus = "pending" | "running" | "blocked" | "completed" | "failed" | "cancelled";
105
- type TaskRecord = {
106
- id: TaskId;
107
- title: string;
108
- status: TaskStatus;
109
- agentId: AgentId;
110
- sessionId: SessionId;
111
- input: unknown;
112
- output?: unknown;
113
- error?: string | null;
114
- createdAt: string;
115
- updatedAt: string;
116
- metadata: Record<string, unknown>;
117
- };
256
+ //#region src/features/ncp-dispatch/utils/agent-runtime-handle.utils.d.ts
257
+ type AgentRuntimeSessionTypes = Awaited<ReturnType<AgentRuntimeRegistry["listSessionTypes"]>>;
258
+ type AgentRuntimeEndpoint = {
259
+ agentClientEndpoint: NcpAgentClientEndpoint;
260
+ streamProvider?: NcpHttpAgentStreamProvider;
261
+ listSessionTypes?: (params?: AgentRuntimeSessionTypeDescribeParams) => Promise<AgentRuntimeSessionTypes> | AgentRuntimeSessionTypes;
262
+ assetApi?: {
263
+ put: (input: {
264
+ fileName: string;
265
+ mimeType?: string | null;
266
+ bytes: Uint8Array;
267
+ createdAt?: Date;
268
+ }) => ReturnType<LocalAssetStore["putBytes"]>;
269
+ stat: LocalAssetStore["statRecord"];
270
+ resolveContentPath: LocalAssetStore["resolveContentPath"];
271
+ };
272
+ basePath?: string;
273
+ };
274
+ type AgentRuntimeHandle = AgentRuntimeEndpoint & {
275
+ runApi: NcpAgentRunApi;
276
+ sessionApi: NcpSessionApi;
277
+ applyMcpConfig?: (config: Config) => Promise<void>;
278
+ dispose?: () => Promise<void>;
279
+ };
280
+ declare function createAgentRuntimeHandle(params: {
281
+ backend: DefaultNcpAgentBackend;
282
+ runtimeRegistry: AgentRuntimeRegistry;
283
+ refreshPluginRuntimeRegistrations: () => void;
284
+ refreshConfiguredRuntimeEntries: () => void;
285
+ applyMcpConfig: (config: Config) => Promise<void>;
286
+ dispose: () => Promise<void>;
287
+ assetStore: LocalAssetStore;
288
+ }): AgentRuntimeHandle;
118
289
  //#endregion
119
- //#region src/types/session.types.d.ts
120
- type SessionMessage = NcpMessage;
121
- type SessionRecord = {
122
- id: SessionId;
123
- title?: string;
124
- agentId?: AgentId | null;
125
- taskIds: TaskId[];
126
- contextVersion: number;
127
- createdAt: string;
128
- updatedAt: string;
129
- metadata: Record<string, unknown>;
130
- };
290
+ //#region src/features/ncp-dispatch/utils/nextclaw-ncp-runner.utils.d.ts
291
+ type AssetApi = {
292
+ put: (input: {
293
+ fileName: string;
294
+ mimeType?: string | null;
295
+ bytes: Uint8Array;
296
+ createdAt?: Date;
297
+ }) => Promise<{
298
+ uri: string;
299
+ }>;
300
+ resolveContentPath?: (uri: string) => string | null;
301
+ };
302
+ type NcpRunnerAgent = {
303
+ runApi: NcpAgentRunApi;
304
+ assetApi?: AssetApi;
305
+ };
306
+ type RunPromptOverNcpParams = {
307
+ agent: NcpRunnerAgent;
308
+ sessionId: string;
309
+ content: string;
310
+ attachments?: InboundAttachment[];
311
+ metadata?: Record<string, unknown>;
312
+ abortSignal?: AbortSignal;
313
+ onAssistantDelta?: (delta: string) => void;
314
+ onEvent?: (event: NcpEndpointEvent) => void;
315
+ missingCompletedMessageError?: string;
316
+ runErrorMessage?: string;
317
+ };
318
+ type StreamPromptOverNcpParams = Omit<RunPromptOverNcpParams, "onAssistantDelta" | "missingCompletedMessageError" | "runErrorMessage">;
319
+ declare function buildUserMessageParts(params: {
320
+ content: string;
321
+ attachments?: InboundAttachment[];
322
+ assetApi?: AssetApi;
323
+ }): Promise<NcpMessagePart[]>;
324
+ declare function buildNcpUserMessage(params: {
325
+ sessionId: string;
326
+ content: string;
327
+ attachments?: InboundAttachment[];
328
+ metadata?: Record<string, unknown>;
329
+ assetApi?: AssetApi;
330
+ }): Promise<NcpMessage>;
331
+ declare function streamPromptOverNcp(params: StreamPromptOverNcpParams): AsyncGenerator<NcpEndpointEvent>;
332
+ declare function runPromptOverNcp(params: RunPromptOverNcpParams): Promise<{
333
+ text: string;
334
+ completedMessage: NcpMessage;
335
+ }>;
131
336
  //#endregion
132
- //#region src/managers/session.manager.d.ts
133
- declare class SessionManager {
134
- readonly listSessions: () => never;
135
- readonly getSession: (sessionId: SessionId) => never;
136
- readonly requireSession: (sessionId: SessionId) => never;
137
- readonly createSession: (input?: {
138
- title?: string;
139
- agentId?: AgentId | null;
140
- metadata?: Record<string, unknown>;
141
- }) => never;
142
- readonly saveSession: (session: SessionRecord) => never;
143
- readonly appendMessage: (sessionId: SessionId, message: SessionMessage) => never;
144
- readonly attachTask: (sessionId: SessionId, taskId: TaskId) => never;
145
- readonly closeSession: (sessionId: SessionId) => never;
337
+ //#region src/features/ncp-dispatch/utils/channel-reply.utils.d.ts
338
+ type ReplyCapableChannel = BaseChannel<Record<string, unknown>> & {
339
+ consumeNcpReply(input: NcpReplyInput): Promise<void>;
340
+ };
341
+ type ChannelReplyRoute = {
342
+ target: ChatTarget;
343
+ channel: ReplyCapableChannel;
344
+ };
345
+ type ResolvedInboundRoute = {
346
+ accountId?: string | null;
347
+ };
348
+ type ChannelReplyRouterDispatchParams = {
349
+ agent: NcpRunnerAgent;
350
+ route: ChannelReplyRoute;
351
+ sessionId: string;
352
+ content: string;
353
+ attachments?: InboundAttachment[];
354
+ metadata?: Record<string, unknown>;
355
+ abortSignal?: AbortSignal;
356
+ onEvent?: (event: NcpEndpointEvent) => void;
357
+ };
358
+ declare function isReplyCapableChannel(channel: BaseChannel<Record<string, unknown>> | null | undefined): channel is ReplyCapableChannel;
359
+ declare function resolveChannelReplyRoute(params: {
360
+ channel: BaseChannel<Record<string, unknown>> | null | undefined;
361
+ message: InboundMessage;
362
+ route: ResolvedInboundRoute;
363
+ }): ChannelReplyRoute | null;
364
+ declare function dispatchChannelReplyRoute(params: ChannelReplyRouterDispatchParams): Promise<void>;
365
+ //#endregion
366
+ //#region src/features/ncp-dispatch/utils/nextclaw-ncp-dispatch.utils.d.ts
367
+ type DirectPromptDispatchParams = {
368
+ config: Config;
369
+ sessionManager: SessionManager;
370
+ resolveNcpAgent?: () => NcpRunnerAgent | null;
371
+ content: string;
372
+ sessionKey?: string;
373
+ channel?: string;
374
+ chatId?: string;
375
+ attachments?: InboundAttachment[];
376
+ metadata?: Record<string, unknown>;
377
+ agentId?: string;
378
+ abortSignal?: AbortSignal;
379
+ onAssistantDelta?: (delta: string) => void;
380
+ };
381
+ type GatewayInboundLoopRuntime = {
382
+ kernel: {
383
+ channels: ChannelManager$1;
384
+ };
385
+ messageBus: MessageBus;
386
+ sessionManager: SessionManager;
387
+ configManager: {
388
+ loadConfig: () => Config;
389
+ };
390
+ liveAgentRuntime: NcpRunnerAgent | null;
391
+ appEventBus?: EventBus;
392
+ };
393
+ declare function dispatchPromptOverNcp(params: DirectPromptDispatchParams): Promise<string>;
394
+ declare function runGatewayInboundLoop(runtime: GatewayInboundLoopRuntime): Promise<void>;
395
+ //#endregion
396
+ //#region src/types/llm-usage.types.d.ts
397
+ type LlmUsageSummary = {
398
+ promptTokens: number;
399
+ completionTokens: number;
400
+ totalTokens: number;
401
+ cachedTokens: number;
402
+ cacheHit: boolean;
403
+ cacheMetricKeys: string[];
404
+ };
405
+ type LlmUsageRecord = {
406
+ version: 1;
407
+ observedAt: string;
408
+ source: string;
409
+ model: string | null;
410
+ usage: Record<string, number>;
411
+ summary: LlmUsageSummary;
412
+ };
413
+ type LlmUsageSnapshot = LlmUsageRecord;
414
+ declare function createLlmUsageRecord(params: {
415
+ observedAt?: string;
416
+ source: string;
417
+ model?: string | null;
418
+ usage: Record<string, number>;
419
+ }): LlmUsageRecord;
420
+ declare function sanitizeLlmUsage(usage: Record<string, number>): Record<string, number>;
421
+ declare function hasLlmUsageTelemetry(usage: Record<string, number>): boolean;
422
+ declare function buildLlmUsageSummary(usage: Record<string, number>): LlmUsageSummary;
423
+ declare function normalizeLlmUsageModel(value: string | null | undefined): string | null;
424
+ //#endregion
425
+ //#region src/stores/llm-usage.store.d.ts
426
+ type LlmUsageStoreOptions = {
427
+ snapshotPath?: string;
428
+ historyPath?: string;
429
+ };
430
+ declare class LlmUsageStore {
431
+ private readonly options;
432
+ constructor(options?: LlmUsageStoreOptions);
433
+ get snapshotPath(): string;
434
+ get historyPath(): string;
435
+ readSnapshot: () => LlmUsageRecord | null;
436
+ writeSnapshot: (snapshot: LlmUsageRecord) => void;
437
+ clearSnapshot: () => void;
438
+ listHistory: () => LlmUsageRecord[];
439
+ appendHistory: (record: LlmUsageRecord) => void;
440
+ clearHistory: () => void;
146
441
  }
147
442
  //#endregion
148
- //#region src/managers/context-builder.manager.d.ts
149
- declare class ContextBuilder {
150
- private readonly sessions;
151
- constructor(sessions: SessionManager);
152
- readonly build: (input: {
153
- sessionId: SessionId;
154
- task?: TaskRecord | null;
155
- agent: AgentRecord;
156
- }) => ContextRecord;
443
+ //#region src/managers/llm-usage.manager.d.ts
444
+ type LlmUsageManagerOptions = {
445
+ store?: LlmUsageStore;
446
+ };
447
+ declare class LlmUsageManager {
448
+ private readonly store;
449
+ constructor(options?: LlmUsageManagerOptions);
450
+ observeProviderManager: (providerManager: LlmProviderRuntime, source: string) => LlmProviderRuntime;
451
+ record: (params: {
452
+ observedAt?: string;
453
+ source: string;
454
+ model?: string | null;
455
+ usage: Record<string, number>;
456
+ }) => LlmUsageRecord | null;
157
457
  }
158
458
  //#endregion
159
- //#region src/types/llm-provider.types.d.ts
160
- type LlmProviderRecord = {
161
- id: LlmProviderId;
162
- name: string;
163
- modelIds: string[];
459
+ //#region src/managers/agent-runtime.manager.d.ts
460
+ type AgentRuntimeManagerOptions = {
461
+ bus: MessageBus;
462
+ providerManager: LlmProviderRuntime;
463
+ sessions: SessionManager;
464
+ ingress: Ingress;
465
+ sessionRequests: SessionRequestManager;
466
+ sessionSearch: SessionSearchManager;
467
+ ncpAgentSessionStore: AgentSessionStore;
468
+ cronService?: CronService | null;
469
+ configManager: {
470
+ loadConfig: () => Config;
471
+ };
472
+ extensions: ExtensionManager;
473
+ eventBus: EventBus;
474
+ handleNcpEvent: (event: NcpEndpointEvent) => void;
475
+ llmUsage: LlmUsageManager;
476
+ onSessionUpdated: (sessionKey: string) => void;
477
+ };
478
+ declare class AgentRuntimeManager {
479
+ private readonly params;
480
+ private readonly runtimeRegistry;
481
+ private readonly mcpRuntimeSupport;
482
+ private readonly assetStore;
483
+ private readonly pluginRuntimeRegistrationController;
484
+ private readonly refreshConfiguredRuntimeEntries;
485
+ private backend;
486
+ private handle;
487
+ private builtinNarpRegistrations;
488
+ private kernelBootstrapped;
489
+ private warmupPromise;
490
+ private unsubscribeNcpEvents;
491
+ private unsubscribeAgentRuntimeRequestIngress;
492
+ private gatewayController;
493
+ private disposed;
494
+ constructor(params: AgentRuntimeManagerOptions);
495
+ get currentHandle(): AgentRuntimeHandle | null;
496
+ connectGatewayController: (gatewayController: GatewayController) => void;
497
+ bootstrap: () => Promise<AgentRuntimeHandle>;
498
+ warmDerivedCapabilities: () => Promise<void>;
499
+ dispose: () => Promise<void>;
500
+ private readonly registerCoreRuntimes;
501
+ private runDerivedCapabilityWarmup;
502
+ private publishSessionRunStatus;
503
+ private publishNcpEvent;
504
+ private handleSessionMessageRequest;
505
+ private updateToolCallResult;
506
+ private readonly assertNotDisposed;
507
+ }
508
+ //#endregion
509
+ //#region src/managers/automation.manager.d.ts
510
+ type AutomationManagerOptions = {
511
+ storePath: string;
512
+ };
513
+ declare class AutomationManager extends CronService {
514
+ constructor(options: AutomationManagerOptions);
515
+ }
516
+ //#endregion
517
+ //#region src/managers/config.manager.d.ts
518
+ type ConfigManagerRuntimeHooks = {
519
+ resolveChannelConfig?: (config: Config) => Config;
520
+ getExtensionChannels?: () => ExtensionRegistry["channels"];
521
+ applyAgentRuntimeConfig?: (config: Config) => void;
522
+ reloadCompanion?: (params: {
523
+ config: Config;
524
+ changedPaths: string[];
525
+ }) => Promise<void> | void;
526
+ reloadMcp?: (params: {
527
+ config: Config;
528
+ changedPaths: string[];
529
+ }) => Promise<void> | void;
530
+ reloadPlugins?: (params: {
531
+ config: Config;
532
+ changedPaths: string[];
533
+ }) => Promise<{
534
+ restartChannels?: boolean;
535
+ } | void> | {
536
+ restartChannels?: boolean;
537
+ } | void;
538
+ onRestartRequired?: (paths: string[]) => void;
539
+ };
540
+ type ConfigManagerOptions = {
541
+ configPath?: string;
542
+ channels: ChannelManager$1;
543
+ providerManager: LlmProviderManager;
544
+ };
545
+ declare class ConfigManager {
546
+ private readonly options;
547
+ readonly configPath: string;
548
+ private currentConfig;
549
+ private hooks;
550
+ private reloadTask;
551
+ private providerReloadTask;
552
+ private reloadTimer;
553
+ private reloadRunning;
554
+ private reloadPending;
555
+ constructor(options: ConfigManagerOptions);
556
+ get config(): Config;
557
+ loadConfig: () => Config;
558
+ installRuntimeHooks: (hooks: ConfigManagerRuntimeHooks) => void;
559
+ applyLiveConfigReload: () => Promise<void>;
560
+ applyReloadPlan: (nextConfig: Config) => Promise<void>;
561
+ scheduleReload: (reason: string) => void;
562
+ runReload: (reason: string) => Promise<void>;
563
+ reloadConfig: (reason?: string) => Promise<string>;
564
+ rebuildChannels: (nextConfig: Config, options?: {
565
+ start?: boolean;
566
+ }) => Promise<void>;
567
+ private resolveChannelConfig;
568
+ private resolveExtensionChannels;
569
+ private reloadProvider;
570
+ private reloadPlugins;
571
+ private reloadMcp;
572
+ private reloadCompanion;
573
+ }
574
+ //#endregion
575
+ //#region src/configs/learning-loop.config.d.ts
576
+ declare const LEARNING_LOOP_DISABLED_METADATA_KEY = "learning_loop_disabled";
577
+ declare const LEARNING_LOOP_LAST_TOOL_CALL_COUNT_METADATA_KEY = "learning_loop_last_tool_call_count";
578
+ declare const LEARNING_LOOP_LAST_REQUESTED_AT_METADATA_KEY = "learning_loop_last_requested_at";
579
+ declare const LEARNING_LOOP_LAST_REVIEW_SESSION_ID_METADATA_KEY = "learning_loop_last_review_session_id";
580
+ declare const LEARNING_LOOP_SOURCE_SESSION_ID_METADATA_KEY = "learning_loop_source_session_id";
581
+ declare const LEARNING_LOOP_REQUESTED_SKILLS: string[];
582
+ declare const DEFAULT_LEARNING_LOOP_TOOL_CALL_THRESHOLD = 15;
583
+ type LearningLoopRuntimeConfig = {
164
584
  enabled: boolean;
165
- metadata: Record<string, unknown>;
585
+ toolCallThreshold: number;
166
586
  };
587
+ declare function readLearningLoopRuntimeConfig(config: Config): LearningLoopRuntimeConfig;
167
588
  //#endregion
168
- //#region src/managers/llm-provider.manager.d.ts
169
- declare class LlmProviderManager {
170
- readonly listProviders: () => never;
171
- readonly getProvider: (providerId: LlmProviderId) => never;
172
- readonly requireProvider: (providerId: LlmProviderId) => never;
173
- readonly saveProvider: (provider: LlmProviderRecord) => never;
174
- readonly enableProvider: (providerId: LlmProviderId) => never;
175
- readonly disableProvider: (providerId: LlmProviderId) => never;
176
- readonly selectProvider: (input: {
177
- agent: AgentRecord;
178
- context: ContextRecord;
179
- }) => never;
589
+ //#region src/managers/learning-loop.manager.d.ts
590
+ type LearningLoopSessionRequester = {
591
+ spawnSessionAndRequest: (params: SpawnSessionAndRequestParams) => Promise<SessionRequestToolResult>;
592
+ };
593
+ type LearningLoopManagerOptions = {
594
+ eventBus: EventBus;
595
+ sessionManager: SessionManager;
596
+ sessionRequester: LearningLoopSessionRequester;
597
+ resolveLearningLoopConfig?: () => LearningLoopRuntimeConfig;
598
+ };
599
+ declare class LearningLoopManager {
600
+ private readonly options;
601
+ private readonly sessionStore;
602
+ private readonly inFlightSessionIds;
603
+ private unsubscribe;
604
+ constructor(options: LearningLoopManagerOptions);
605
+ start: () => void;
606
+ dispose: () => void;
607
+ private handleRunFinished;
608
+ private handleRunFinishedInBackground;
609
+ private readRuntimeConfig;
610
+ private buildReviewTitle;
180
611
  }
181
612
  //#endregion
182
613
  //#region src/types/skill.types.d.ts
@@ -191,32 +622,13 @@ type SkillRecord = {
191
622
  //#endregion
192
623
  //#region src/managers/skill.manager.d.ts
193
624
  declare class SkillManager {
194
- readonly listSkills: () => never;
195
- readonly getSkill: (skillId: SkillId) => never;
196
- readonly requireSkill: (skillId: SkillId) => never;
197
- readonly saveSkill: (skill: SkillRecord) => never;
198
- readonly enableSkill: (skillId: SkillId) => never;
199
- readonly disableSkill: (skillId: SkillId) => never;
200
- readonly resolveSkills: (skillIds: SkillId[]) => never;
201
- }
202
- //#endregion
203
- //#region src/managers/task.manager.d.ts
204
- declare class TaskManager {
205
- readonly listTasks: () => never;
206
- readonly getTask: (taskId: TaskId) => never;
207
- readonly requireTask: (taskId: TaskId) => never;
208
- readonly createTask: (input: {
209
- title: string;
210
- agentId: AgentId;
211
- sessionId: SessionId;
212
- input: unknown;
213
- metadata?: Record<string, unknown>;
214
- }) => never;
215
- readonly saveTask: (task: TaskRecord) => never;
216
- readonly updateTaskStatus: (taskId: TaskId, status: TaskStatus) => never;
217
- readonly completeTask: (taskId: TaskId, output: unknown) => never;
218
- readonly failTask: (taskId: TaskId, error: string) => never;
219
- readonly cancelTask: (taskId: TaskId) => never;
625
+ listSkills: () => never;
626
+ getSkill: (skillId: SkillId) => never;
627
+ requireSkill: (skillId: SkillId) => never;
628
+ saveSkill: (skill: SkillRecord) => never;
629
+ enableSkill: (skillId: SkillId) => never;
630
+ disableSkill: (skillId: SkillId) => never;
631
+ resolveSkills: (skillIds: SkillId[]) => never;
220
632
  }
221
633
  //#endregion
222
634
  //#region src/types/tool.types.d.ts
@@ -231,32 +643,41 @@ type ToolRecord = {
231
643
  //#endregion
232
644
  //#region src/managers/tool.manager.d.ts
233
645
  declare class ToolManager {
234
- readonly listTools: () => never;
235
- readonly getTool: (toolId: ToolId) => never;
236
- readonly requireTool: (toolId: ToolId) => never;
237
- readonly saveTool: (tool: ToolRecord) => never;
238
- readonly enableTool: (toolId: ToolId) => never;
239
- readonly disableTool: (toolId: ToolId) => never;
240
- readonly resolveTools: (toolIds: ToolId[]) => never;
646
+ listTools: () => never;
647
+ getTool: (toolId: ToolId) => never;
648
+ requireTool: (toolId: ToolId) => never;
649
+ saveTool: (tool: ToolRecord) => never;
650
+ enableTool: (toolId: ToolId) => never;
651
+ disableTool: (toolId: ToolId) => never;
652
+ resolveTools: (toolIds: ToolId[]) => never;
241
653
  }
242
654
  //#endregion
243
- //#region src/types/nextclaw-kernel.types.d.ts
244
- type NextclawKernelRunMetadata = {
245
- agentId?: AgentId;
246
- model?: string;
247
- skills?: SkillId[];
248
- };
249
- type NextclawKernelRunInput = {
250
- sessionId: SessionId;
251
- messages: NcpMessage[];
252
- metadata?: NextclawKernelRunMetadata;
253
- extra?: Record<string, unknown>;
254
- };
255
- type NextclawKernelRun = {
256
- taskId: TaskId;
257
- };
655
+ //#region src/services/ncp-session-api.service.d.ts
656
+ type NcpSessionApiServiceOptions = {
657
+ eventBus: EventBus;
658
+ getConfig: () => Config;
659
+ sessionManager: SessionManager;
660
+ };
661
+ declare class NcpSessionApiService implements NcpSessionApi {
662
+ private readonly options;
663
+ private unsubscribeSessionUpdated;
664
+ private readonly contextWindowPreview;
665
+ constructor(options: NcpSessionApiServiceOptions);
666
+ start: () => void;
667
+ dispose: () => void;
668
+ publishSessionChange: (sessionKey: string) => Promise<void>;
669
+ listSessions: (options?: ListSessionsOptions) => Promise<NcpSessionSummary[]>;
670
+ listSessionMessages: (sessionId: string, options?: ListMessagesOptions) => Promise<NcpMessage[]>;
671
+ getSession: (sessionId: string) => Promise<NcpSessionSummary | null>;
672
+ updateSession: (sessionId: string, patch: NcpSessionPatch) => Promise<NcpSessionSummary | null>;
673
+ deleteSession: (sessionId: string) => Promise<void>;
674
+ }
258
675
  //#endregion
259
676
  //#region src/app/nextclaw-kernel.d.ts
677
+ type NextclawKernelOptions = {
678
+ homeDir?: string;
679
+ configPath?: string;
680
+ };
260
681
  type NextclawKernelRuntimeControl<TGatewayInput, TUiInput, TStartInput> = {
261
682
  gateway: (input: TGatewayInput) => Promise<void>;
262
683
  ui: (input: TUiInput) => Promise<void>;
@@ -267,173 +688,278 @@ type NextclawKernelRuntimeControl<TGatewayInput, TUiInput, TStartInput> = {
267
688
  };
268
689
  declare class NextclawKernelControlManager<TGatewayInput, TUiInput, TStartInput> {
269
690
  private runtimeControl;
270
- readonly installRuntimeControl: (runtimeControl: NextclawKernelRuntimeControl<TGatewayInput, TUiInput, TStartInput>) => void;
271
- readonly requireRuntimeControl: () => NextclawKernelRuntimeControl<TGatewayInput, TUiInput, TStartInput>;
691
+ installRuntimeControl: (runtimeControl: NextclawKernelRuntimeControl<TGatewayInput, TUiInput, TStartInput>) => void;
692
+ requireRuntimeControl: () => NextclawKernelRuntimeControl<TGatewayInput, TUiInput, TStartInput>;
272
693
  }
273
- declare class NextclawKernel<TGatewayInput = unknown, TUiInput = unknown, TStartInput = unknown> {
694
+ declare class NextclawKernel {
695
+ readonly eventBus: EventBus;
696
+ readonly ingress: Ingress;
697
+ readonly messageBus: MessageBus;
698
+ readonly llmProviders: LlmProviderManager;
699
+ readonly llmUsage: LlmUsageManager;
700
+ readonly configManager: ConfigManager;
274
701
  readonly agents: AgentManager;
275
- readonly tasks: TaskManager;
276
702
  readonly sessions: SessionManager;
277
- readonly contextBuilder: ContextBuilder;
278
- readonly control: NextclawKernelControlManager<TGatewayInput, TUiInput, TStartInput>;
703
+ readonly control: NextclawKernelControlManager<unknown, unknown, unknown>;
279
704
  readonly tools: ToolManager;
280
705
  readonly skills: SkillManager;
281
- readonly llmProviders: LlmProviderManager;
282
706
  readonly automation: AutomationManager;
283
- readonly channels: ChannelManager;
284
- readonly run: (input: NextclawKernelRunInput) => NextclawKernelRun;
707
+ readonly channels: ChannelManager$1;
708
+ readonly sessionRequests: SessionRequestManager;
709
+ readonly sessionSearch: SessionSearchManager;
710
+ readonly ncpSessionApi: NcpSessionApiService;
711
+ readonly extensions: ExtensionManager;
712
+ readonly agentRuntimeManager: AgentRuntimeManager;
713
+ readonly learningLoop: LearningLoopManager;
714
+ private readonly sessionLifecycleEvents;
715
+ private readonly ncpAgentSessionStore;
716
+ private startPromise;
717
+ constructor(options?: NextclawKernelOptions);
718
+ start: () => Promise<void>;
719
+ dispose: () => Promise<void>;
720
+ private publishSessionUpdated;
721
+ private handleNcpEvent;
285
722
  }
286
723
  //#endregion
287
- //#region src/events/event-bus.types.d.ts
288
- type AppEventKey<T> = {
289
- readonly id: string;
290
- readonly _type?: T;
291
- };
292
- type AppEventSource = "backend" | "realtime" | "local";
293
- type AppEventEnvelope<T = unknown> = {
294
- type: string;
295
- payload: T;
296
- emittedAt?: string;
297
- source?: AppEventSource;
298
- };
299
- type AppEventEmitOptions = {
300
- emittedAt?: string;
301
- source?: AppEventSource;
302
- };
303
- type AppEventHandler<T> = (payload: T, envelope: AppEventEnvelope<T>) => void;
304
- type EventBusOptions = {
305
- onFirstSubscriber?: () => void;
306
- onListenerError?: (params: {
307
- type: string;
308
- payload: unknown;
309
- error: unknown;
310
- }) => void;
311
- onNoSubscribers?: () => void;
312
- };
313
- type ConfigUpdatedEvent = AppEventEnvelope<{
314
- path: string;
315
- }> & {
316
- type: "config.updated";
317
- };
318
- type ChannelConfigApplyStatusEvent = AppEventEnvelope<{
724
+ //#region src/utils/learning-loop-prompt.utils.d.ts
725
+ declare function buildLearningLoopTask(params: {
726
+ sessionId: string;
727
+ toolCallsSinceReview: number;
728
+ currentToolCallCount: number;
729
+ }): string;
730
+ //#endregion
731
+ //#region src/features/narp-runtime/services/builtin-narp-runtime-registration.service.d.ts
732
+ declare const NARP_HTTP_RUNTIME_KIND = "narp-http";
733
+ declare const NARP_STDIO_RUNTIME_KIND = "narp-stdio";
734
+ declare class BuiltinNarpRuntimeRegistrationService {
735
+ private readonly getConfig;
736
+ constructor(getConfig: () => Config);
737
+ registerInto: (runtimeRegistry: AgentRuntimeRegistry) => Disposable[];
738
+ private createUnavailableRuntime;
739
+ private createHttpRuntime;
740
+ private createStdioRuntime;
741
+ }
742
+ //#endregion
743
+ //#region src/features/native-runtime/services/context-compaction-preflight.service.d.ts
744
+ type ContextWindowOwner = "nextclaw" | "runtime";
745
+ type ContextCompactionPreflightResult = {
746
+ contextWindow: ContextWindowSnapshot;
747
+ metadata: Record<string, unknown>;
748
+ sessionMessages: NcpMessage[];
749
+ timelineMessage: NcpMessage | null;
750
+ };
751
+ type ContextCompactionPreflightBeginResult = ContextCompactionPreflightResult & {
752
+ pendingCompaction: ContextCompactionPendingWork | null;
753
+ };
754
+ type ContextCompactionPendingWork = {
755
+ checkpoint: ReturnType<typeof buildCompressingCompactionCheckpoint>;
756
+ contextTokens: number;
757
+ inputMessageIds: string[];
758
+ model: string;
759
+ plan: ContextCompactionPlan;
760
+ reservedContextTokens: number;
761
+ sessionId: string;
762
+ };
763
+ declare class ContextCompactionPreflightService {
764
+ private readonly options;
765
+ private readonly compactionService;
766
+ private readonly contextWindowBudgetService;
767
+ constructor(options: {
768
+ getConfig: () => Config;
769
+ providerManager?: LlmProviderRuntime;
770
+ sessionManager: SessionManager;
771
+ });
772
+ run: (params: {
773
+ contextWindowOwner: ContextWindowOwner;
774
+ inputMessages: readonly NcpMessage[];
775
+ requestMetadata: Record<string, unknown>;
776
+ sessionId: string;
777
+ sessionMessages: readonly NcpMessage[];
778
+ }) => Promise<ContextCompactionPreflightResult | null>;
779
+ preview: (params: {
780
+ contextWindowOwner: ContextWindowOwner;
781
+ requestMetadata: Record<string, unknown>;
782
+ sessionId: string;
783
+ sessionMessages: readonly NcpMessage[];
784
+ }) => ContextWindowSnapshot | null;
785
+ begin: (params: {
786
+ contextWindowOwner: ContextWindowOwner;
787
+ inputMessages: readonly NcpMessage[];
788
+ requestMetadata: Record<string, unknown>;
789
+ sessionId: string;
790
+ sessionMessages: readonly NcpMessage[];
791
+ }) => ContextCompactionPreflightBeginResult | null;
792
+ private buildContextWindowSnapshotForMessages;
793
+ finish: (pending: ContextCompactionPendingWork) => Promise<ContextCompactionPreflightResult>;
794
+ private generateSummary;
795
+ }
796
+ //#endregion
797
+ //#region src/features/native-runtime/services/native-agent-runtime-factory.service.d.ts
798
+ type NativeRuntimeFactory = (runtimeParams: RuntimeFactoryParams) => NcpAgentRuntime;
799
+ type UpdateToolCallResult = (params: {
800
+ sessionId: string;
801
+ toolCallId: string;
802
+ result: unknown;
803
+ }) => Promise<void>;
804
+ type NativeAgentRuntimeFactoryOptions = {
805
+ bus: MessageBus;
806
+ providerManager: LlmProviderRuntime;
807
+ sessions: SessionManager;
808
+ sessionRequests: SessionRequestManager;
809
+ sessionSearch: SessionSearchManager;
810
+ cronService?: CronService | null;
811
+ configManager: {
812
+ loadConfig: () => Config;
813
+ };
814
+ extensions: ExtensionManager;
815
+ llmUsage: LlmUsageManager;
816
+ onSessionUpdated: (sessionKey: string) => void;
817
+ resolveGatewayController: () => GatewayController | undefined;
818
+ mcpToolRegistryAdapter: McpNcpToolRegistryAdapter;
819
+ assetStore: LocalAssetStore;
820
+ updateToolCallResult: UpdateToolCallResult;
821
+ };
822
+ declare class NativeAgentRuntimeFactory {
823
+ private readonly options;
824
+ private readonly observedProviderManager;
825
+ constructor(options: NativeAgentRuntimeFactoryOptions);
826
+ create: NativeRuntimeFactory;
827
+ resolveOpenAiToolsForRuntime: (input: NcpAgentRunInput) => _$_nextclaw_ncp0.OpenAITool[] | undefined;
828
+ private createToolRegistry;
829
+ }
830
+ //#endregion
831
+ //#region src/features/native-runtime/services/nextclaw-ncp-tool-registry.service.d.ts
832
+ type NextclawNcpToolRegistryOptions = {
833
+ bus: MessageBus;
834
+ providerManager: LlmProviderRuntime;
835
+ sessionManager: SessionManager;
836
+ cronService?: CronService | null;
837
+ gatewayController?: GatewayController;
838
+ getConfig: () => Config;
839
+ getExtensionRegistry?: () => ExtensionRegistry | undefined;
840
+ getAdditionalTools?: (context: PreparedRunContext) => ReadonlyArray<NcpTool>;
841
+ onSessionUpdated?: (sessionKey: string) => void;
842
+ sessionRequestManager: SessionRequestManager;
843
+ updateToolCallResult: (params: {
844
+ sessionId: string;
845
+ toolCallId: string;
846
+ result: unknown;
847
+ }) => Promise<void>;
848
+ };
849
+ type PreparedRunContext = {
850
+ agentId: string;
319
851
  channel: string;
320
- status: "started" | "succeeded" | "failed";
321
- message?: string;
322
- }> & {
323
- type: "channel.config.apply-status";
324
- };
325
- type SessionUpdatedEvent = AppEventEnvelope<{
326
- sessionKey: string;
327
- }> & {
328
- type: "session.updated";
329
- };
330
- type SessionRunStatusEvent = AppEventEnvelope<{
331
- sessionKey: string;
332
- status: "running" | "idle";
333
- }> & {
334
- type: "session.run-status";
335
- };
336
- type SessionSummaryUpsertEvent = AppEventEnvelope<{
337
- summary: NcpSessionSummary;
338
- }> & {
339
- type: "session.summary.upsert";
340
- };
341
- type SessionSummaryDeleteEvent = AppEventEnvelope<{
852
+ chatId: string;
853
+ config: Config;
854
+ contextTokens: number;
855
+ execTimeoutSeconds: number;
856
+ handoffDepth: number;
857
+ maxTokens?: number;
858
+ metadata: Record<string, unknown>;
859
+ model: string;
860
+ restrictToWorkspace: boolean;
861
+ searchConfig: SearchConfig;
862
+ sessionId: string;
863
+ workspace: string;
864
+ };
865
+ declare class NextclawNcpToolRegistry implements NcpToolRegistry {
866
+ private readonly options;
867
+ private registry;
868
+ private readonly tools;
869
+ private currentExtensionToolContext;
870
+ constructor(options: NextclawNcpToolRegistryOptions);
871
+ prepareForRun: (context: PreparedRunContext) => void;
872
+ listTools: () => ReadonlyArray<NcpTool>;
873
+ getTool: (name: string) => NcpTool | undefined;
874
+ getToolDefinitions: () => ReadonlyArray<NcpToolDefinition>;
875
+ execute: (toolCallId: string, toolName: string, args: unknown) => Promise<unknown>;
876
+ private buildToolExecutionContext;
877
+ private registerDefaultTools;
878
+ private registerMessagingTools;
879
+ private registerExtensionTools;
880
+ private registerTool;
881
+ private registerAdditionalTools;
882
+ private isToolAvailable;
883
+ }
884
+ declare function resolveAgentHandoffDepth(metadata: Record<string, unknown>): number;
885
+ declare function readAccountIdForHints(metadata: Record<string, unknown>, sessionMetadata: Record<string, unknown>): string | undefined;
886
+ //#endregion
887
+ //#region src/features/native-runtime/services/nextclaw-ncp-context-builder.service.d.ts
888
+ type MessageToolHintsResolver = (params: {
342
889
  sessionKey: string;
343
- }> & {
344
- type: "session.summary.delete";
345
- };
346
- type ConfigReloadStartedEvent = AppEventEnvelope<Record<string, unknown> | undefined> & {
347
- type: "config.reload.started";
348
- };
349
- type ConfigReloadFinishedEvent = AppEventEnvelope<Record<string, unknown> | undefined> & {
350
- type: "config.reload.finished";
351
- };
352
- type ErrorEvent = AppEventEnvelope<{
353
- message: string;
354
- code?: string;
355
- }> & {
356
- type: "error";
357
- };
358
- type ConnectionOpenEvent = AppEventEnvelope<Record<string, never> | undefined> & {
359
- type: "connection.open";
360
- };
361
- type ConnectionCloseEvent = AppEventEnvelope<Record<string, never> | undefined> & {
362
- type: "connection.close";
363
- };
364
- type ConnectionErrorEvent = AppEventEnvelope<{
365
- message?: string;
366
- } | undefined> & {
367
- type: "connection.error";
368
- };
369
- type RuntimeUpdateSnapshotEvent = AppEventEnvelope<UpdateSnapshot> & {
370
- type: "runtime.update.snapshot";
371
- };
372
- type AppEvent = ConfigUpdatedEvent | ChannelConfigApplyStatusEvent | SessionUpdatedEvent | SessionRunStatusEvent | SessionSummaryUpsertEvent | SessionSummaryDeleteEvent | ConfigReloadStartedEvent | ConfigReloadFinishedEvent | ErrorEvent | ConnectionOpenEvent | ConnectionCloseEvent | ConnectionErrorEvent | RuntimeUpdateSnapshotEvent;
373
- //#endregion
374
- //#region src/events/event-bus.service.d.ts
375
- declare class EventBus {
376
- private readonly listeners;
377
- private readonly globalListeners;
378
- private listenerCount;
379
- private readonly onFirstSubscriber?;
380
- private readonly onListenerError?;
381
- private readonly onNoSubscribers?;
382
- constructor(options?: EventBusOptions);
383
- emit: <T>(key: AppEventKey<T>, payload: T, options?: AppEventEmitOptions) => void;
384
- emitEnvelope: <T>(event: AppEventEnvelope<T>) => void;
385
- on: <T>(key: AppEventKey<T>, handler: AppEventHandler<T>) => (() => void);
386
- off: <T>(key: AppEventKey<T>, handler: AppEventHandler<T>) => void;
387
- once: <T>(key: AppEventKey<T>, handler: AppEventHandler<T>) => (() => void);
388
- subscribeAll: (handler: (event: AppEventEnvelope) => void) => (() => void);
389
- private registerSubscriber;
390
- private unregisterSubscriber;
391
- private safeInvokeListener;
392
- private safeInvokeGlobalListener;
890
+ channel: string;
891
+ chatId: string;
892
+ accountId?: string | null;
893
+ }) => string[];
894
+ type NextclawNcpContextBuilderOptions = {
895
+ sessionManager: SessionManager;
896
+ toolRegistry: NextclawNcpToolRegistry;
897
+ getConfig: () => Config;
898
+ resolveMessageToolHints?: MessageToolHintsResolver;
899
+ assetStore?: LocalAssetStore | null;
900
+ };
901
+ declare class NextclawNcpContextBuilder implements NcpContextBuilder {
902
+ private readonly options;
903
+ private readonly inputBudgetPruner;
904
+ constructor(options: NextclawNcpContextBuilderOptions);
905
+ prepare: (input: NcpAgentRunInput, _options?: NcpContextPrepareOptions) => NcpLLMApiInput;
906
+ private prepareRunContext;
907
+ private buildModelMessages;
908
+ private pruneModelMessages;
393
909
  }
394
910
  //#endregion
395
- //#region src/app/nextclaw-app.service.d.ts
396
- type NextClawApp = {
397
- readonly eventBus: EventBus;
398
- };
399
- declare const nextclaw: NextClawApp;
911
+ //#region src/features/native-runtime/services/provider-manager-ncp-llm-api.service.d.ts
912
+ declare class ProviderManagerNcpLLMApi implements NcpLLMApi {
913
+ private readonly providerManager;
914
+ constructor(providerManager: LlmProviderRuntime);
915
+ readonly generate: (this: ProviderManagerNcpLLMApi, input: NcpLLMApiInput, options?: NcpLLMApiOptions) => AsyncGenerator<OpenAIChatChunk>;
916
+ }
400
917
  //#endregion
401
- //#region src/events/event-keys.config.d.ts
402
- declare function createAppEventKey<T>(id: string): AppEventKey<T>;
403
- declare const eventKeys: {
404
- readonly configUpdated: AppEventKey<{
405
- path: string;
406
- }>;
407
- readonly channelConfigApplyStatus: AppEventKey<{
408
- channel: string;
409
- status: "started" | "succeeded" | "failed";
410
- message?: string;
411
- }>;
412
- readonly sessionUpdated: AppEventKey<{
413
- sessionKey: string;
414
- }>;
415
- readonly sessionRunStatus: AppEventKey<{
416
- sessionKey: string;
417
- status: "running" | "idle";
418
- }>;
419
- readonly sessionSummaryUpsert: AppEventKey<{
420
- summary: NcpSessionSummary;
421
- }>;
422
- readonly sessionSummaryDelete: AppEventKey<{
423
- sessionKey: string;
424
- }>;
425
- readonly configReloadStarted: AppEventKey<Record<string, unknown> | undefined>;
426
- readonly configReloadFinished: AppEventKey<Record<string, unknown> | undefined>;
427
- readonly error: AppEventKey<{
428
- message: string;
429
- code?: string;
430
- }>;
431
- readonly connectionOpen: AppEventKey<Record<string, never> | undefined>;
432
- readonly connectionClose: AppEventKey<Record<string, never> | undefined>;
433
- readonly connectionError: AppEventKey<{
434
- message?: string;
435
- } | undefined>;
436
- readonly runtimeUpdateSnapshot: AppEventKey<UpdateSnapshot>;
437
- };
918
+ //#region src/features/native-runtime/tools/ncp-asset.tools.d.ts
919
+ declare function createAssetTools(params: {
920
+ assetStore: LocalAssetStore;
921
+ contentBasePath?: string;
922
+ }): NcpTool[];
923
+ //#endregion
924
+ //#region src/features/session-request/utils/agent-runtime-session-request-dispatcher.utils.d.ts
925
+ declare const AGENT_RUNTIME_SESSION_MESSAGE_INGRESS_TYPE: _$_nextclaw_shared0.TypedKey<AgentRuntimeSessionMessageRequest>;
926
+ type AgentRuntimeSessionMessageRequest = {
927
+ message: NcpMessage;
928
+ requestId: string;
929
+ sessionId: string;
930
+ };
931
+ type AgentRuntimeSessionRequestDispatcherOptions = {
932
+ eventBus: EventBus;
933
+ ingress: Ingress;
934
+ };
935
+ declare function waitForAgentRuntimeSessionReply(input: {
936
+ eventBus: EventBus;
937
+ onAccepted: (messageId: string) => void;
938
+ requestId: string;
939
+ }): {
940
+ dispose: Unsubscribe;
941
+ promise: Promise<NcpMessage>;
942
+ };
943
+ declare function dispatchAgentRuntimeSessionRequest(input: {
944
+ ingress: Ingress;
945
+ request: SessionRequestRecord;
946
+ task: string;
947
+ }): Promise<void>;
948
+ declare function createAgentRuntimeSessionRequestDispatcher(options: AgentRuntimeSessionRequestDispatcherOptions): SessionRequestDispatcher;
949
+ //#endregion
950
+ //#region src/utils/ncp-session-summary.utils.d.ts
951
+ declare function createNcpSessionSummary(params: {
952
+ sessionId: string;
953
+ agentId?: string;
954
+ messages: readonly NcpMessage[];
955
+ updatedAt: string;
956
+ status: NcpSessionStatus;
957
+ metadata?: Record<string, unknown>;
958
+ contextWindow?: Record<string, unknown> | null;
959
+ }): NcpSessionSummary;
960
+ //#endregion
961
+ //#region src/utils/ncp-session-message-adapter.utils.d.ts
962
+ declare function toNcpMessages(sessionId: string, messages: SessionMessage[]): NcpMessage[];
963
+ declare function resolveLegacyEventType(message: SessionMessage): string;
438
964
  //#endregion
439
- export { AgentId, AgentManager, AgentRecord, type AppEvent, type AppEventEmitOptions, type AppEventEnvelope, type AppEventHandler, type AppEventKey, type AppEventSource, AutomationId, AutomationManager, AutomationRecord, AutomationTrigger, type ChannelConfigApplyStatusEvent, ChannelDirection, ChannelId, ChannelManager, ChannelRecord, type ConfigReloadFinishedEvent, type ConfigReloadStartedEvent, type ConfigUpdatedEvent, type ConnectionCloseEvent, type ConnectionErrorEvent, type ConnectionOpenEvent, ContextBuilder, ContextRecord, type ErrorEvent, EventBus, type EventBusOptions, InstallationKind, LlmProviderId, LlmProviderManager, LlmProviderRecord, NextClawApp, NextclawKernel, NextclawKernelRun, NextclawKernelRunInput, NextclawKernelRunMetadata, type RuntimeUpdateSnapshotEvent, SessionId, SessionManager, SessionMessage, SessionRecord, type SessionRunStatusEvent, type SessionSummaryDeleteEvent, type SessionSummaryUpsertEvent, type SessionUpdatedEvent, SkillId, SkillManager, SkillRecord, TaskId, TaskManager, TaskRecord, TaskStatus, ToolId, ToolManager, ToolRecord, UnsignedUpdateManifest, UpdateBlockReason, UpdateHostKind, UpdateManifest, UpdateManifestReader, UpdatePreferences, UpdateProgress, UpdateSnapshot, UpdateStatus, createAppEventKey, eventKeys, getUnsignedUpdateManifest, nextclaw, serializeUnsignedUpdateManifest };
965
+ export { AGENT_RUNTIME_SESSION_MESSAGE_INGRESS_TYPE, AgentId, AgentManager, AgentRecord, AgentRuntimeContribution, AgentRuntimeEndpoint, AgentRuntimeEntry, type AgentRuntimeHandle, AgentRuntimeManager, AgentRuntimeManagerOptions, AgentRuntimeProviderRegistration, AgentRuntimeRegistry, AgentRuntimeSessionMessageRequest, AgentRuntimeSessionRequestDispatcherOptions, AgentRuntimeSessionTypeDescribeParams, AgentRuntimeSessionTypeIcon, AgentRuntimeSessionTypeOption, AutomationId, AutomationManager, AutomationManagerOptions, BuiltinNarpRuntimeRegistrationService, ChannelId, ChannelManager, ChannelReplyRouterDispatchParams, ConfigManager, ConfigManagerOptions, ConfigManagerRuntimeHooks, ContextCompactionPendingWork, ContextCompactionPreflightBeginResult, ContextCompactionPreflightResult, ContextCompactionPreflightService, ContextWindowOwner, DEFAULT_AGENT_RUNTIME_ENTRY_ID, DEFAULT_LEARNING_LOOP_TOOL_CALL_THRESHOLD, DirectPromptDispatchParams, ExtensionContributions, ExtensionManager, GatewayInboundLoopRuntime, InstallationKind, LEARNING_LOOP_DISABLED_METADATA_KEY, LEARNING_LOOP_LAST_REQUESTED_AT_METADATA_KEY, LEARNING_LOOP_LAST_REVIEW_SESSION_ID_METADATA_KEY, LEARNING_LOOP_LAST_TOOL_CALL_COUNT_METADATA_KEY, LEARNING_LOOP_REQUESTED_SKILLS, LEARNING_LOOP_SOURCE_SESSION_ID_METADATA_KEY, LearningLoopManager, LearningLoopManagerOptions, LearningLoopRuntimeConfig, LearningLoopSessionRequester, LlmProviderManager, LlmProviderRuntime, LlmUsageManager, LlmUsageManagerOptions, LlmUsageRecord, LlmUsageSnapshot, LlmUsageStore, LlmUsageStoreOptions, LlmUsageSummary, NARP_HTTP_RUNTIME_KIND, NARP_STDIO_RUNTIME_KIND, NativeAgentRuntimeFactory, NativeAgentRuntimeFactoryOptions, NativeRuntimeFactory, NcpRunnerAgent, NcpSessionApiService, NcpSessionApiServiceOptions, NextclawExtensionRegistry, NextclawKernel, NextclawKernelOptions, NextclawNcpContextBuilder, NextclawNcpToolRegistry, PluginRuntimeRegistrationController, ProviderManagerNcpLLMApi, RunPromptOverNcpParams, SessionId, SkillId, SkillManager, SkillRecord, StreamPromptOverNcpParams, TaskId, ToolId, ToolManager, ToolRecord, UnsignedUpdateManifest, UpdateBlockReason, UpdateHostKind, UpdateManifest, UpdateManifestReader, UpdatePreferences, UpdateProgress, UpdateSnapshot, UpdateStatus, UpdateToolCallResult, buildLearningLoopTask, buildLlmUsageSummary, buildNcpUserMessage, buildUserMessageParts, createAgentRuntimeHandle, createAgentRuntimeSessionRequestDispatcher, createAssetTools, createLlmUsageRecord, createNcpSessionSummary, dispatchAgentRuntimeSessionRequest, dispatchChannelReplyRoute, dispatchPromptOverNcp, getUnsignedUpdateManifest, hasLlmUsageTelemetry, isReplyCapableChannel, normalizeAgentRuntimeSessionTypeIcon, normalizeLlmUsageModel, readAccountIdForHints, readLearningLoopRuntimeConfig, resolveAgentHandoffDepth, resolveAgentRuntimeEntries, resolveChannelReplyRoute, resolveLegacyEventType, runGatewayInboundLoop, runPromptOverNcp, sanitizeLlmUsage, serializeUnsignedUpdateManifest, streamPromptOverNcp, toNcpMessages, waitForAgentRuntimeSessionReply };