@nextclaw/kernel 0.1.2-beta.1 → 0.1.2-beta.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 +147 -2
- package/dist/index.js +99 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-BAJqcsP5.js";
|
|
2
|
-
import { NcpMessage } from "@nextclaw/ncp";
|
|
2
|
+
import { NcpMessage, NcpSessionSummary } from "@nextclaw/ncp";
|
|
3
3
|
|
|
4
4
|
//#region src/types/entity-ids.types.d.ts
|
|
5
5
|
type AgentId = string;
|
|
@@ -284,4 +284,149 @@ declare class NextclawKernel<TGatewayInput = unknown, TUiInput = unknown, TStart
|
|
|
284
284
|
readonly run: (input: NextclawKernelRunInput) => NextclawKernelRun;
|
|
285
285
|
}
|
|
286
286
|
//#endregion
|
|
287
|
-
|
|
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
|
+
onListenerError?: (params: {
|
|
306
|
+
type: string;
|
|
307
|
+
payload: unknown;
|
|
308
|
+
error: unknown;
|
|
309
|
+
}) => void;
|
|
310
|
+
};
|
|
311
|
+
type ConfigUpdatedEvent = AppEventEnvelope<{
|
|
312
|
+
path: string;
|
|
313
|
+
}> & {
|
|
314
|
+
type: "config.updated";
|
|
315
|
+
};
|
|
316
|
+
type ChannelConfigApplyStatusEvent = AppEventEnvelope<{
|
|
317
|
+
channel: string;
|
|
318
|
+
status: "started" | "succeeded" | "failed";
|
|
319
|
+
message?: string;
|
|
320
|
+
}> & {
|
|
321
|
+
type: "channel.config.apply-status";
|
|
322
|
+
};
|
|
323
|
+
type SessionUpdatedEvent = AppEventEnvelope<{
|
|
324
|
+
sessionKey: string;
|
|
325
|
+
}> & {
|
|
326
|
+
type: "session.updated";
|
|
327
|
+
};
|
|
328
|
+
type SessionRunStatusEvent = AppEventEnvelope<{
|
|
329
|
+
sessionKey: string;
|
|
330
|
+
status: "running" | "idle";
|
|
331
|
+
}> & {
|
|
332
|
+
type: "session.run-status";
|
|
333
|
+
};
|
|
334
|
+
type SessionSummaryUpsertEvent = AppEventEnvelope<{
|
|
335
|
+
summary: NcpSessionSummary;
|
|
336
|
+
}> & {
|
|
337
|
+
type: "session.summary.upsert";
|
|
338
|
+
};
|
|
339
|
+
type SessionSummaryDeleteEvent = AppEventEnvelope<{
|
|
340
|
+
sessionKey: string;
|
|
341
|
+
}> & {
|
|
342
|
+
type: "session.summary.delete";
|
|
343
|
+
};
|
|
344
|
+
type ConfigReloadStartedEvent = AppEventEnvelope<Record<string, unknown> | undefined> & {
|
|
345
|
+
type: "config.reload.started";
|
|
346
|
+
};
|
|
347
|
+
type ConfigReloadFinishedEvent = AppEventEnvelope<Record<string, unknown> | undefined> & {
|
|
348
|
+
type: "config.reload.finished";
|
|
349
|
+
};
|
|
350
|
+
type ErrorEvent = AppEventEnvelope<{
|
|
351
|
+
message: string;
|
|
352
|
+
code?: string;
|
|
353
|
+
}> & {
|
|
354
|
+
type: "error";
|
|
355
|
+
};
|
|
356
|
+
type ConnectionOpenEvent = AppEventEnvelope<Record<string, never> | undefined> & {
|
|
357
|
+
type: "connection.open";
|
|
358
|
+
};
|
|
359
|
+
type ConnectionCloseEvent = AppEventEnvelope<Record<string, never> | undefined> & {
|
|
360
|
+
type: "connection.close";
|
|
361
|
+
};
|
|
362
|
+
type ConnectionErrorEvent = AppEventEnvelope<{
|
|
363
|
+
message?: string;
|
|
364
|
+
} | undefined> & {
|
|
365
|
+
type: "connection.error";
|
|
366
|
+
};
|
|
367
|
+
type RuntimeUpdateSnapshotEvent = AppEventEnvelope<UpdateSnapshot> & {
|
|
368
|
+
type: "runtime.update.snapshot";
|
|
369
|
+
};
|
|
370
|
+
type AppEvent = ConfigUpdatedEvent | ChannelConfigApplyStatusEvent | SessionUpdatedEvent | SessionRunStatusEvent | SessionSummaryUpsertEvent | SessionSummaryDeleteEvent | ConfigReloadStartedEvent | ConfigReloadFinishedEvent | ErrorEvent | ConnectionOpenEvent | ConnectionCloseEvent | ConnectionErrorEvent | RuntimeUpdateSnapshotEvent;
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region src/events/event-bus.service.d.ts
|
|
373
|
+
declare class EventBus {
|
|
374
|
+
private readonly listeners;
|
|
375
|
+
private readonly globalListeners;
|
|
376
|
+
private readonly onListenerError?;
|
|
377
|
+
constructor(options?: EventBusOptions);
|
|
378
|
+
emit: <T>(key: AppEventKey<T>, payload: T, options?: AppEventEmitOptions) => void;
|
|
379
|
+
emitEnvelope: <T>(event: AppEventEnvelope<T>) => void;
|
|
380
|
+
on: <T>(key: AppEventKey<T>, handler: AppEventHandler<T>) => (() => void);
|
|
381
|
+
off: <T>(key: AppEventKey<T>, handler: AppEventHandler<T>) => void;
|
|
382
|
+
once: <T>(key: AppEventKey<T>, handler: AppEventHandler<T>) => (() => void);
|
|
383
|
+
subscribeAll: (handler: (event: AppEventEnvelope) => void) => (() => void);
|
|
384
|
+
private safeInvokeListener;
|
|
385
|
+
private safeInvokeGlobalListener;
|
|
386
|
+
}
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region src/app/nextclaw-app.service.d.ts
|
|
389
|
+
type NextClawApp = {
|
|
390
|
+
readonly eventBus: EventBus;
|
|
391
|
+
};
|
|
392
|
+
declare const nextclaw: NextClawApp;
|
|
393
|
+
//#endregion
|
|
394
|
+
//#region src/events/event.keys.d.ts
|
|
395
|
+
declare function createAppEventKey<T>(id: string): AppEventKey<T>;
|
|
396
|
+
declare const eventKeys: {
|
|
397
|
+
readonly configUpdated: AppEventKey<{
|
|
398
|
+
path: string;
|
|
399
|
+
}>;
|
|
400
|
+
readonly channelConfigApplyStatus: AppEventKey<{
|
|
401
|
+
channel: string;
|
|
402
|
+
status: "started" | "succeeded" | "failed";
|
|
403
|
+
message?: string;
|
|
404
|
+
}>;
|
|
405
|
+
readonly sessionUpdated: AppEventKey<{
|
|
406
|
+
sessionKey: string;
|
|
407
|
+
}>;
|
|
408
|
+
readonly sessionRunStatus: AppEventKey<{
|
|
409
|
+
sessionKey: string;
|
|
410
|
+
status: "running" | "idle";
|
|
411
|
+
}>;
|
|
412
|
+
readonly sessionSummaryUpsert: AppEventKey<{
|
|
413
|
+
summary: NcpSessionSummary;
|
|
414
|
+
}>;
|
|
415
|
+
readonly sessionSummaryDelete: AppEventKey<{
|
|
416
|
+
sessionKey: string;
|
|
417
|
+
}>;
|
|
418
|
+
readonly configReloadStarted: AppEventKey<Record<string, unknown> | undefined>;
|
|
419
|
+
readonly configReloadFinished: AppEventKey<Record<string, unknown> | undefined>;
|
|
420
|
+
readonly error: AppEventKey<{
|
|
421
|
+
message: string;
|
|
422
|
+
code?: string;
|
|
423
|
+
}>;
|
|
424
|
+
readonly connectionOpen: AppEventKey<Record<string, never> | undefined>;
|
|
425
|
+
readonly connectionClose: AppEventKey<Record<string, never> | undefined>;
|
|
426
|
+
readonly connectionError: AppEventKey<{
|
|
427
|
+
message?: string;
|
|
428
|
+
} | undefined>;
|
|
429
|
+
readonly runtimeUpdateSnapshot: AppEventKey<UpdateSnapshot>;
|
|
430
|
+
};
|
|
431
|
+
//#endregion
|
|
432
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -249,4 +249,102 @@ var NextclawKernel = class {
|
|
|
249
249
|
};
|
|
250
250
|
};
|
|
251
251
|
//#endregion
|
|
252
|
-
|
|
252
|
+
//#region src/events/event-bus.service.ts
|
|
253
|
+
var EventBus = class {
|
|
254
|
+
listeners = /* @__PURE__ */ new Map();
|
|
255
|
+
globalListeners = /* @__PURE__ */ new Set();
|
|
256
|
+
onListenerError;
|
|
257
|
+
constructor(options = {}) {
|
|
258
|
+
this.onListenerError = options.onListenerError;
|
|
259
|
+
}
|
|
260
|
+
emit = (key, payload, options = {}) => {
|
|
261
|
+
const envelope = {
|
|
262
|
+
type: key.id,
|
|
263
|
+
payload,
|
|
264
|
+
...options.emittedAt ? { emittedAt: options.emittedAt } : {},
|
|
265
|
+
...options.source ? { source: options.source } : {}
|
|
266
|
+
};
|
|
267
|
+
this.emitEnvelope(envelope);
|
|
268
|
+
};
|
|
269
|
+
emitEnvelope = (event) => {
|
|
270
|
+
const listeners = this.listeners.get(event.type);
|
|
271
|
+
if (listeners) for (const listener of listeners) this.safeInvokeListener(event, listener);
|
|
272
|
+
if (this.globalListeners.size === 0) return;
|
|
273
|
+
for (const listener of this.globalListeners) this.safeInvokeGlobalListener(event, listener);
|
|
274
|
+
};
|
|
275
|
+
on = (key, handler) => {
|
|
276
|
+
const listeners = this.listeners.get(key.id) ?? /* @__PURE__ */ new Set();
|
|
277
|
+
listeners.add(handler);
|
|
278
|
+
this.listeners.set(key.id, listeners);
|
|
279
|
+
return () => {
|
|
280
|
+
this.off(key, handler);
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
off = (key, handler) => {
|
|
284
|
+
const listeners = this.listeners.get(key.id);
|
|
285
|
+
if (!listeners) return;
|
|
286
|
+
listeners.delete(handler);
|
|
287
|
+
if (listeners.size === 0) this.listeners.delete(key.id);
|
|
288
|
+
};
|
|
289
|
+
once = (key, handler) => {
|
|
290
|
+
const wrappedHandler = (payload, envelope) => {
|
|
291
|
+
unsubscribe();
|
|
292
|
+
handler(payload, envelope);
|
|
293
|
+
};
|
|
294
|
+
const unsubscribe = this.on(key, wrappedHandler);
|
|
295
|
+
return unsubscribe;
|
|
296
|
+
};
|
|
297
|
+
subscribeAll = (handler) => {
|
|
298
|
+
this.globalListeners.add(handler);
|
|
299
|
+
return () => {
|
|
300
|
+
this.globalListeners.delete(handler);
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
safeInvokeListener = (event, listener) => {
|
|
304
|
+
try {
|
|
305
|
+
listener(event.payload, event);
|
|
306
|
+
} catch (error) {
|
|
307
|
+
this.onListenerError?.({
|
|
308
|
+
type: event.type,
|
|
309
|
+
payload: event.payload,
|
|
310
|
+
error
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
safeInvokeGlobalListener = (event, listener) => {
|
|
315
|
+
try {
|
|
316
|
+
listener(event);
|
|
317
|
+
} catch (error) {
|
|
318
|
+
this.onListenerError?.({
|
|
319
|
+
type: event.type,
|
|
320
|
+
payload: event.payload,
|
|
321
|
+
error
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/app/nextclaw-app.service.ts
|
|
328
|
+
const nextclaw = { eventBus: new EventBus() };
|
|
329
|
+
//#endregion
|
|
330
|
+
//#region src/events/event.keys.ts
|
|
331
|
+
function createAppEventKey(id) {
|
|
332
|
+
return { id };
|
|
333
|
+
}
|
|
334
|
+
const eventKeys = {
|
|
335
|
+
configUpdated: createAppEventKey("config.updated"),
|
|
336
|
+
channelConfigApplyStatus: createAppEventKey("channel.config.apply-status"),
|
|
337
|
+
sessionUpdated: createAppEventKey("session.updated"),
|
|
338
|
+
sessionRunStatus: createAppEventKey("session.run-status"),
|
|
339
|
+
sessionSummaryUpsert: createAppEventKey("session.summary.upsert"),
|
|
340
|
+
sessionSummaryDelete: createAppEventKey("session.summary.delete"),
|
|
341
|
+
configReloadStarted: createAppEventKey("config.reload.started"),
|
|
342
|
+
configReloadFinished: createAppEventKey("config.reload.finished"),
|
|
343
|
+
error: createAppEventKey("error"),
|
|
344
|
+
connectionOpen: createAppEventKey("connection.open"),
|
|
345
|
+
connectionClose: createAppEventKey("connection.close"),
|
|
346
|
+
connectionError: createAppEventKey("connection.error"),
|
|
347
|
+
runtimeUpdateSnapshot: createAppEventKey("runtime.update.snapshot")
|
|
348
|
+
};
|
|
349
|
+
//#endregion
|
|
350
|
+
export { AgentManager, AutomationManager, ChannelManager, ContextBuilder, EventBus, LlmProviderManager, NextclawKernel, SessionManager, SkillManager, TaskManager, ToolManager, UpdateManifestReader, createAppEventKey, eventKeys, getUnsignedUpdateManifest, nextclaw, serializeUnsignedUpdateManifest };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/kernel",
|
|
3
|
-
"version": "0.1.2-beta.
|
|
3
|
+
"version": "0.1.2-beta.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "NextClaw product kernel skeleton for agents, tasks, sessions, context, tools, skills, providers, automation, and channels.",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@nextclaw/ncp": "0.5.6-beta.
|
|
23
|
+
"@nextclaw/ncp": "0.5.6-beta.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^20.17.6",
|