@harnessio/ai-chat-core 0.0.21 → 0.0.23

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.
@@ -8,3 +8,7 @@ export { useContentFocus } from './useContentFocus';
8
8
  export { useCapability } from './useCapability';
9
9
  export { useCapabilityExecution } from './useCapabilityExecution';
10
10
  export { usePageContext } from './usePageContext';
11
+ export { useQuickActionScope } from './useQuickActionScope';
12
+ export { useQuickAction } from './useQuickAction';
13
+ export { useQuickActions } from './useQuickActions';
14
+ export { useRegisterQuickActions } from './useRegisterQuickActions';
@@ -0,0 +1,26 @@
1
+ import { QuickActionConfig } from '../../types/quick-action';
2
+ /**
3
+ * Register a quick action that appears in the welcome screen.
4
+ * Automatically unregisters when the component unmounts.
5
+ *
6
+ * @param config - Quick action configuration
7
+ * @param scope - The scope to register this action in (defaults to current active scope)
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * function PipelineQuickActions() {
12
+ * useQuickActionScope('pipelines', 'merge')
13
+ *
14
+ * useQuickAction({
15
+ * id: 'list-pipelines',
16
+ * label: 'List pipelines',
17
+ * prompt: 'Show me all pipelines in this project',
18
+ * icon: 'pipeline',
19
+ * priority: 10
20
+ * }, 'pipelines')
21
+ *
22
+ * return null
23
+ * }
24
+ * ```
25
+ */
26
+ export declare function useQuickAction(config: QuickActionConfig, scope?: string): void;
@@ -0,0 +1,21 @@
1
+ import { QuickActionScopeMode } from '../../types/quick-action';
2
+ /**
3
+ * Activate a quick action scope for the duration of this component's lifecycle.
4
+ * When the component unmounts, the scope is deactivated and the previous scope is restored.
5
+ *
6
+ * Use this at the page/module level to declare "this page owns quick actions".
7
+ *
8
+ * @param scope - Unique identifier for this scope (e.g., "pipelines", "dashboards")
9
+ * @param mode - How to display actions: 'merge' (global + current), 'replace' (only current), 'append' (all scopes)
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * function PipelinePage() {
14
+ * useQuickActionScope('pipelines', 'merge')
15
+ *
16
+ * // Component automatically cleans up on unmount
17
+ * return <div>Pipeline content</div>
18
+ * }
19
+ * ```
20
+ */
21
+ export declare function useQuickActionScope(scope: string, mode?: QuickActionScopeMode): void;
@@ -0,0 +1,25 @@
1
+ import { QuickAction, QuickActionFilter } from '../../types/quick-action';
2
+ /**
3
+ * Get all visible quick actions, respecting their condition functions and the active scope.
4
+ *
5
+ * @param filter - Optional filter by scope
6
+ * @returns Array of visible quick actions, sorted by priority
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * function WelcomeScreen() {
11
+ * const quickActions = useQuickActions()
12
+ *
13
+ * return (
14
+ * <div>
15
+ * {quickActions.map(action => (
16
+ * <Button key={action.id} onClick={() => send(action.prompt)}>
17
+ * {action.label}
18
+ * </Button>
19
+ * ))}
20
+ * </div>
21
+ * )
22
+ * }
23
+ * ```
24
+ */
25
+ export declare function useQuickActions(filter?: QuickActionFilter): QuickAction[];
@@ -0,0 +1,25 @@
1
+ import { QuickActionConfig } from '../../types/quick-action';
2
+ /**
3
+ * Register multiple quick actions at once.
4
+ *
5
+ * All actions are automatically registered when the component mounts and
6
+ * unregistered when it unmounts. This hook is useful for registering
7
+ * multiple quick actions from a centralized configuration array.
8
+ *
9
+ * @param actions - Array of quick action configurations to register
10
+ * @param scope - Optional scope for the actions (defaults to active scope)
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const GLOBAL_ACTIONS = [
15
+ * { id: 'action-1', label: 'Action 1', prompt: 'Do action 1', icon: 'star' },
16
+ * { id: 'action-2', label: 'Action 2', prompt: 'Do action 2', icon: 'heart' },
17
+ * ]
18
+ *
19
+ * function MyQuickActions() {
20
+ * useRegisterQuickActions(GLOBAL_ACTIONS, 'global')
21
+ * return null
22
+ * }
23
+ * ```
24
+ */
25
+ export declare function useRegisterQuickActions(actions: QuickActionConfig[], scope?: string): void;
@@ -1,5 +1,6 @@
1
1
  import { CapabilityExecutionManager, CapabilityRegistry } from '../../core';
2
2
  import { PluginRegistry } from '../../core/PluginRegistry';
3
+ import { QuickActionRegistry } from '../../core/QuickActionRegistry';
3
4
  import { ChatPlugin } from '../../types/plugin';
4
5
  import { BaseSubscribable } from '../../utils/Subscribable';
5
6
  import { ContentFocusRuntime } from '../ContentFocusRuntime/ContentFocusRuntime';
@@ -13,6 +14,7 @@ export declare class AssistantRuntime extends BaseSubscribable {
13
14
  readonly pluginRegistry: PluginRegistry;
14
15
  readonly capabilityRegistry: CapabilityRegistry;
15
16
  readonly capabilityExecutionManager: CapabilityExecutionManager;
17
+ readonly quickActionRegistry: QuickActionRegistry;
16
18
  private _contentFocusRuntime;
17
19
  private _currentThreadUnsubscribe?;
18
20
  constructor(config: AssistantRuntimeConfig);
@@ -1,5 +1,5 @@
1
1
  import { SystemEvent } from '../../types/adapters';
2
- import { AppendMessage, Message } from '../../types/message';
2
+ import { AppendMessage, Message, MessageContent } from '../../types/message';
3
3
  import { RuntimeCapabilities, ThreadState } from '../../types/thread';
4
4
  import { BaseSubscribable, Unsubscribe } from '../../utils/Subscribable';
5
5
  import { default as ComposerRuntime } from '../ComposerRuntime/ComposerRuntime';
@@ -40,5 +40,6 @@ export declare class ThreadRuntime extends BaseSubscribable {
40
40
  reset(messages?: Message[]): void;
41
41
  setConversationId(conversationId: string | undefined): void;
42
42
  setTitle(title: string | undefined): void;
43
+ updateMessageContent(messageId: string, updater: (content: MessageContent[]) => MessageContent[]): void;
43
44
  subscribe(callback: () => void): Unsubscribe;
44
45
  }
@@ -1,6 +1,6 @@
1
1
  import { CapabilityExecutionManager } from '../../core';
2
2
  import { StreamAdapter, SystemEvent } from '../../types/adapters';
3
- import { AppendMessage, Message } from '../../types/message';
3
+ import { AppendMessage, Message, MessageContent } from '../../types/message';
4
4
  import { RuntimeCapabilities } from '../../types/thread';
5
5
  import { BaseSubscribable } from '../../utils/Subscribable';
6
6
  export interface ThreadRuntimeCoreConfig {
@@ -58,4 +58,5 @@ export declare class ThreadRuntimeCore extends BaseSubscribable {
58
58
  reset(messages?: Message[]): void;
59
59
  setConversationId(conversationId: string | undefined): void;
60
60
  setTitle(title: string | undefined): void;
61
+ updateMessageContent(messageId: string, updater: (content: MessageContent[]) => MessageContent[]): void;
61
62
  }
@@ -5,3 +5,4 @@ export type { StreamAdapter, ThreadListAdapter, StreamEvent, StreamRequest, Stre
5
5
  export type { SSEEvent } from '../utils/BaseSSEStreamAdapter';
6
6
  export type { CapabilityStatus, CapabilityExecutionContext, CapabilityExecution, CapabilityHandler, CapabilityRendererProps, CapabilityRenderer, CapabilityConfig, CapabilityContent } from './capability';
7
7
  export type { ChatContextItem, ChatContextMap, ChatContextData, ChatContextValue } from './context';
8
+ export type { QuickAction, QuickActionConfig, QuickActionScopeMode, QuickActionScopeConfig, QuickActionFilter } from './quick-action';
@@ -0,0 +1,21 @@
1
+ export interface QuickAction {
2
+ id: string;
3
+ label: string;
4
+ prompt: string;
5
+ icon?: string;
6
+ description?: string;
7
+ priority?: number;
8
+ scope?: string;
9
+ }
10
+ export interface QuickActionConfig extends QuickAction {
11
+ condition?: () => boolean | Promise<boolean>;
12
+ }
13
+ export type QuickActionScopeMode = 'replace' | 'append' | 'merge';
14
+ export interface QuickActionScopeConfig {
15
+ scope: string;
16
+ mode?: QuickActionScopeMode;
17
+ }
18
+ export interface QuickActionFilter {
19
+ scope?: string;
20
+ visible?: boolean;
21
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harnessio/ai-chat-core",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "private": false,