@kb-labs/shared-command-kit 2.118.0 → 2.118.2
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 +20 -2
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginContextV3, ManifestV3, CliGroupMeta, CliCommandDecl, PermissionSpec, RestRouteDecl, WebhookHandlerDecl, WebhookAuthConfig, JobDecl, CommandResult as CommandResult$1, MutateIntent, ExecuteIntent, HostContext, WSMessage, WSSender, WSInput } from '@kb-labs/plugin-contracts';
|
|
1
|
+
import { PluginContextV3, ManifestV3, CliGroupMeta, CliCommandDecl, PermissionSpec, RestRouteDecl, WebhookHandlerDecl, WebhookAuthConfig, JobDecl, CommandResult as CommandResult$1, MutateIntent, ExecuteIntent, HostContext, WSMessage, WSSender, WSInput, EventStreamSender, EventStreamInput } from '@kb-labs/plugin-contracts';
|
|
2
2
|
export { PluginContextV3 } from '@kb-labs/plugin-contracts';
|
|
3
3
|
import { FlagSchemaDefinition as FlagSchemaDefinition$1, InferFlags } from './flags/index.js';
|
|
4
4
|
export { ArrayFlagSchema, BaseFlagSchema, BooleanFlagSchema, FlagSchema, FlagSchemaWithInfer, FlagType, FlagValidationError, NumberFlagSchema, SafeValidationResult, StringFlagSchema, ValidationResult, defineFlags, validateFlags, validateFlagsSafe } from './flags/index.js';
|
|
@@ -1545,6 +1545,24 @@ declare function isWSHost(hostContext: HostContext): hostContext is Extract<Host
|
|
|
1545
1545
|
host: 'ws';
|
|
1546
1546
|
}>;
|
|
1547
1547
|
|
|
1548
|
+
interface EventStreamHandler<TConfig = unknown> {
|
|
1549
|
+
onConnect?(context: PluginContextV3<TConfig>, stream: EventStreamSender): Promise<void> | void;
|
|
1550
|
+
onDisconnect?(context: PluginContextV3<TConfig>): Promise<void> | void;
|
|
1551
|
+
onError?(context: PluginContextV3<TConfig>, error: Error, stream: EventStreamSender): Promise<void> | void;
|
|
1552
|
+
}
|
|
1553
|
+
interface EventStreamDefinition<TConfig = unknown> {
|
|
1554
|
+
path: string;
|
|
1555
|
+
description?: string;
|
|
1556
|
+
handler: EventStreamHandler<TConfig>;
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* Defines a declarative plugin SSE endpoint. The REST host owns the HTTP
|
|
1560
|
+
* connection and invokes this lifecycle in-process, just like defineWebSocket.
|
|
1561
|
+
*/
|
|
1562
|
+
declare function defineEventStream<TConfig = unknown>(definition: EventStreamDefinition<TConfig>): {
|
|
1563
|
+
execute(context: PluginContextV3<TConfig>, input: EventStreamInput): Promise<CommandResult$1>;
|
|
1564
|
+
};
|
|
1565
|
+
|
|
1548
1566
|
/**
|
|
1549
1567
|
* Define a workflow action handler
|
|
1550
1568
|
*/
|
|
@@ -1896,4 +1914,4 @@ interface CommandConfig<TFlags extends FlagSchemaDefinition$1 = FlagSchemaDefini
|
|
|
1896
1914
|
formatter?: CommandFormatter<TConfig, InferFlags<TFlags>, TResult, TArgv, TEnv>;
|
|
1897
1915
|
}
|
|
1898
1916
|
|
|
1899
|
-
export { type ActionDefinition, type ActionHandler, type CLIInput, type CliGroup, CmdBuilder, type Command, type CommandConfig, type CommandDefinition, type CommandFormatter, type CommandGroup, type CommandHandler, type CommandHandlerV3, type CommandResult, type ConfigUpdates, DELETE, type DefinedJob, type DestroyHandlerDefinition, type ErrorResult, FlagSchemaDefinition$1 as FlagSchemaDefinition, GET, type Handler, type HandlerDefinition, type HandlerRef, InferFlags, type JobDefinition, type JobHandler, type JobInput, type LifecycleContext, MessageBuilder, MessageRouter, PATCH, POST, PUT, type PluginId, type RestBase, type RestInput, type ResultWith, type RouteDefinition, type RouteHandler, type SemVer, type SetupHandlerDefinition, type SetupResult, type SuccessResult, type SystemCommandConfig, type TypedSender, type WebSocketDefinition, type WebSocketHandler, type WebhookDefinition, type WebhookHandler, type WorkspaceConfig, type WsBase, array, artifactId, boolean, cmd, commandId, createManifest, cwd, datetime, defineAction, defineCommand, defineCommandFlags, defineDestroyHandler, defineHandler, defineJob, defineManifest, defineMessage, defineRoute, defineSetupHandler, defineSystemCommand, defineSystemCommandGroup, defineWebSocket, defineWebhook, email, enumSchema, filePath, group, isCLIHost, isRESTHost, isWSHost, isWebhookHost, isWorkflowHost, json, mergeCliGroups, nonNegativeInt, object, pluginId, positiveInt, schema, scopeId, text, url, uuid, webhook };
|
|
1917
|
+
export { type ActionDefinition, type ActionHandler, type CLIInput, type CliGroup, CmdBuilder, type Command, type CommandConfig, type CommandDefinition, type CommandFormatter, type CommandGroup, type CommandHandler, type CommandHandlerV3, type CommandResult, type ConfigUpdates, DELETE, type DefinedJob, type DestroyHandlerDefinition, type ErrorResult, type EventStreamDefinition, type EventStreamHandler, FlagSchemaDefinition$1 as FlagSchemaDefinition, GET, type Handler, type HandlerDefinition, type HandlerRef, InferFlags, type JobDefinition, type JobHandler, type JobInput, type LifecycleContext, MessageBuilder, MessageRouter, PATCH, POST, PUT, type PluginId, type RestBase, type RestInput, type ResultWith, type RouteDefinition, type RouteHandler, type SemVer, type SetupHandlerDefinition, type SetupResult, type SuccessResult, type SystemCommandConfig, type TypedSender, type WebSocketDefinition, type WebSocketHandler, type WebhookDefinition, type WebhookHandler, type WorkspaceConfig, type WsBase, array, artifactId, boolean, cmd, commandId, createManifest, cwd, datetime, defineAction, defineCommand, defineCommandFlags, defineDestroyHandler, defineEventStream, defineHandler, defineJob, defineManifest, defineMessage, defineRoute, defineSetupHandler, defineSystemCommand, defineSystemCommandGroup, defineWebSocket, defineWebhook, email, enumSchema, filePath, group, isCLIHost, isRESTHost, isWSHost, isWebhookHost, isWorkflowHost, json, mergeCliGroups, nonNegativeInt, object, pluginId, positiveInt, schema, scopeId, text, url, uuid, webhook };
|
package/dist/index.js
CHANGED
|
@@ -1699,6 +1699,38 @@ function isWSHost(hostContext) {
|
|
|
1699
1699
|
return hostContext.host === "ws";
|
|
1700
1700
|
}
|
|
1701
1701
|
|
|
1702
|
+
// src/define-event-stream.ts
|
|
1703
|
+
function defineEventStream(definition) {
|
|
1704
|
+
return {
|
|
1705
|
+
async execute(context, input) {
|
|
1706
|
+
if (context.host !== "rest") {
|
|
1707
|
+
throw new Error(
|
|
1708
|
+
`Event stream ${definition.path} can only run in rest host (current: ${context.host})`
|
|
1709
|
+
);
|
|
1710
|
+
}
|
|
1711
|
+
if ((input.event === "connect" || input.event === "error") && !input.sender) {
|
|
1712
|
+
throw new Error("Event stream sender not provided in input");
|
|
1713
|
+
}
|
|
1714
|
+
switch (input.event) {
|
|
1715
|
+
case "connect":
|
|
1716
|
+
await definition.handler.onConnect?.(context, input.sender);
|
|
1717
|
+
break;
|
|
1718
|
+
case "disconnect":
|
|
1719
|
+
await definition.handler.onDisconnect?.(context);
|
|
1720
|
+
break;
|
|
1721
|
+
case "error":
|
|
1722
|
+
await definition.handler.onError?.(
|
|
1723
|
+
context,
|
|
1724
|
+
input.error ?? new Error("Event stream error"),
|
|
1725
|
+
input.sender
|
|
1726
|
+
);
|
|
1727
|
+
break;
|
|
1728
|
+
}
|
|
1729
|
+
return { ok: true };
|
|
1730
|
+
}
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1702
1734
|
// src/define-action.ts
|
|
1703
1735
|
function defineAction(definition) {
|
|
1704
1736
|
const wrappedHandler = {
|
|
@@ -1770,6 +1802,6 @@ var MessageRouter = class {
|
|
|
1770
1802
|
}
|
|
1771
1803
|
};
|
|
1772
1804
|
|
|
1773
|
-
export { CmdBuilder, DELETE, FlagValidationError, GET, MessageBuilder, MessageRouter, PATCH, POST, PUT, PluginError, array, artifactId, boolean, cmd, commandId, commonErrors, createAnalyticsWrapper, createManifest, cwd, datetime, defineAction, defineCommand, defineCommandFlags, defineDestroyHandler, defineError, defineFlags, defineHandler, defineJob, defineManifest, defineMessage, defineRoute, defineSetupHandler, defineSystemCommand, defineSystemCommandGroup, defineWebSocket, defineWebhook, email, enumSchema, filePath, formatError, getLLMTier, group, isCLIHost, isCacheAvailable, isDocumentDatabaseAvailable, isEmbeddingsAvailable, isKVStoreAvailable, isLLMAvailable, isPlatformConfigured, isRESTHost, isVectorStoreAvailable, isWSHost, isWebhookHost, isWorkflowHost, json, mergeCliGroups, nonNegativeInt, object, pluginId, positiveInt, schema, scopeId, text, trackAnalyticsEvent, trackEvent, url, useAnalytics, useCache, useConfig, useDocumentDatabase, useEmbeddings, useEnv, useKVStore, useLLM, useLogger, useLoggerWithContext, useNotifications, usePlatform, useStorage, useVectorStore, uuid, validateFlags, validateFlagsSafe, webhook, withAnalytics };
|
|
1805
|
+
export { CmdBuilder, DELETE, FlagValidationError, GET, MessageBuilder, MessageRouter, PATCH, POST, PUT, PluginError, array, artifactId, boolean, cmd, commandId, commonErrors, createAnalyticsWrapper, createManifest, cwd, datetime, defineAction, defineCommand, defineCommandFlags, defineDestroyHandler, defineError, defineEventStream, defineFlags, defineHandler, defineJob, defineManifest, defineMessage, defineRoute, defineSetupHandler, defineSystemCommand, defineSystemCommandGroup, defineWebSocket, defineWebhook, email, enumSchema, filePath, formatError, getLLMTier, group, isCLIHost, isCacheAvailable, isDocumentDatabaseAvailable, isEmbeddingsAvailable, isKVStoreAvailable, isLLMAvailable, isPlatformConfigured, isRESTHost, isVectorStoreAvailable, isWSHost, isWebhookHost, isWorkflowHost, json, mergeCliGroups, nonNegativeInt, object, pluginId, positiveInt, schema, scopeId, text, trackAnalyticsEvent, trackEvent, url, useAnalytics, useCache, useConfig, useDocumentDatabase, useEmbeddings, useEnv, useKVStore, useLLM, useLogger, useLoggerWithContext, useNotifications, usePlatform, useStorage, useVectorStore, uuid, validateFlags, validateFlagsSafe, webhook, withAnalytics };
|
|
1774
1806
|
//# sourceMappingURL=index.js.map
|
|
1775
1807
|
//# sourceMappingURL=index.js.map
|