@harnessio/ai-chat-core 0.0.19 → 0.0.21
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/core/CapabilityRegistry.d.ts +2 -2
- package/dist/index.js +222 -170
- package/dist/index.js.map +1 -1
- package/dist/runtime/ThreadRuntime/ThreadRuntime.d.ts +12 -0
- package/dist/runtime/ThreadRuntime/ThreadRuntimeCore.d.ts +11 -0
- package/dist/types/capability.d.ts +1 -0
- package/package.json +2 -1
|
@@ -22,6 +22,18 @@ export declare class ThreadRuntime extends BaseSubscribable {
|
|
|
22
22
|
getState(): ThreadState;
|
|
23
23
|
append(message: AppendMessage): void;
|
|
24
24
|
send(text: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Dispatches a system event (e.g. a user click on an elicitation card).
|
|
27
|
+
*
|
|
28
|
+
* Prior to this change, this method wrapped startSystemEventRun in a
|
|
29
|
+
* try/catch that silently swallowed the "A run is already in progress"
|
|
30
|
+
* error thrown by the core when _isRunning was still true — causing
|
|
31
|
+
* clicks fired during the tail of the previous run to disappear.
|
|
32
|
+
*
|
|
33
|
+
* Now we await waitForIdle() before dispatching so the event is
|
|
34
|
+
* reliably delivered as soon as the in-flight run completes. Callers
|
|
35
|
+
* do not need their own queueing primitive.
|
|
36
|
+
*/
|
|
25
37
|
sendSystemEvent(systemEvent: SystemEvent): Promise<void>;
|
|
26
38
|
cancelRun(): void;
|
|
27
39
|
clear(): void;
|
|
@@ -19,6 +19,7 @@ export declare class ThreadRuntimeCore extends BaseSubscribable {
|
|
|
19
19
|
private _abortController;
|
|
20
20
|
private _conversationId?;
|
|
21
21
|
private _title?;
|
|
22
|
+
private _idleWaiters;
|
|
22
23
|
private _currentPart;
|
|
23
24
|
constructor(config: ThreadRuntimeCoreConfig);
|
|
24
25
|
get messages(): readonly Message[];
|
|
@@ -34,6 +35,16 @@ export declare class ThreadRuntimeCore extends BaseSubscribable {
|
|
|
34
35
|
get capabilities(): RuntimeCapabilities;
|
|
35
36
|
private updateMessages;
|
|
36
37
|
append(message: AppendMessage): void;
|
|
38
|
+
/**
|
|
39
|
+
* Resolves when _isRunning flips to false. Use this to queue a
|
|
40
|
+
* follow-on dispatch (e.g. a system event from a card click that
|
|
41
|
+
* fires during the tail of the previous run) without racing the
|
|
42
|
+
* in-progress run's guard.
|
|
43
|
+
*
|
|
44
|
+
* Resolves immediately if nothing is running.
|
|
45
|
+
*/
|
|
46
|
+
waitForIdle(): Promise<void>;
|
|
47
|
+
private drainIdleWaiters;
|
|
37
48
|
startSystemEventRun(systemEvent: SystemEvent): Promise<void>;
|
|
38
49
|
startRun(userMessage: AppendMessage): Promise<void>;
|
|
39
50
|
private handleStreamEvent;
|
|
@@ -42,6 +42,7 @@ export interface CapabilityRenderer<TArgs = any, TResult = any> {
|
|
|
42
42
|
}
|
|
43
43
|
export interface CapabilityConfig<TArgs = any, TResult = any> {
|
|
44
44
|
name: string;
|
|
45
|
+
priority?: number;
|
|
45
46
|
execute?: (args: TArgs, context: CapabilityExecutionContext) => Promise<TResult> | TResult;
|
|
46
47
|
render?: React.ComponentType<CapabilityRendererProps<TArgs, TResult>>;
|
|
47
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harnessio/ai-chat-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"private": false,
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"build": "vite build",
|
|
53
53
|
"build:ci": "vite build",
|
|
54
54
|
"build:watch": "vite build --watch",
|
|
55
|
+
"test": "jest",
|
|
55
56
|
"pretty": "prettier --check ./src",
|
|
56
57
|
"pre-commit": "lint-staged"
|
|
57
58
|
}
|