@threadplane/ag-ui 0.0.55 → 0.0.57
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/README.md +6 -1
- package/fesm2022/threadplane-ag-ui.mjs +462 -200
- package/fesm2022/threadplane-ag-ui.mjs.map +1 -1
- package/package.json +1 -1
- package/types/threadplane-ag-ui.d.ts +27 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Signal, Provider } from '@angular/core';
|
|
2
|
-
import { AbstractAgent,
|
|
2
|
+
import { AbstractAgent, BaseEvent, RunAgentInput } from '@ag-ui/client';
|
|
3
3
|
import { Agent, ClientToolsCapability, Subagent, AgentRuntimeTelemetrySink, AgentRef, Message } from '@threadplane/chat';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
import { FakeAgentConfig } from '@threadplane/chat/testing';
|
|
@@ -21,10 +21,12 @@ interface ToAgentOptions {
|
|
|
21
21
|
telemetry?: AgentRuntimeTelemetrySink | false;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* The neutral Agent contract, widened with the AG-UI adapter's
|
|
24
|
+
* The neutral Agent contract, widened with the AG-UI adapter's
|
|
25
25
|
* `customEvents` signal (the chat composition feature-detects it to enable
|
|
26
|
-
* live a2ui streaming)
|
|
27
|
-
*
|
|
26
|
+
* live a2ui streaming), the browser client-tools capability, and concrete
|
|
27
|
+
* ACTIVITY-backed `subagents`.
|
|
28
|
+
* Mirrors langgraph's LangGraphAgent extension where the protocol surfaces
|
|
29
|
+
* overlap.
|
|
28
30
|
*/
|
|
29
31
|
interface AgUiAgent<TState = Record<string, unknown>> extends Agent<TState> {
|
|
30
32
|
customEvents: Signal<CustomStreamEvent[]>;
|
|
@@ -47,6 +49,14 @@ interface AgUiAgent<TState = Record<string, unknown>> extends Agent<TState> {
|
|
|
47
49
|
* of toAgent() should treat the returned object's lifecycle as tied to the
|
|
48
50
|
* agent instance they constructed. The subscriber registered via
|
|
49
51
|
* source.subscribe() will fire for the lifetime of source.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { HttpAgent } from '@ag-ui/client';
|
|
56
|
+
* import { toAgent } from '@threadplane/ag-ui';
|
|
57
|
+
*
|
|
58
|
+
* const agent = toAgent(new HttpAgent({ url: '/api/agent' }));
|
|
59
|
+
* ```
|
|
50
60
|
*/
|
|
51
61
|
declare function toAgent(source: AbstractAgent, options?: ToAgentOptions): AgUiAgent;
|
|
52
62
|
|
|
@@ -116,6 +126,13 @@ declare function provideAgent(configOrFactory: AgentConfig | (() => AgentConfig)
|
|
|
116
126
|
declare function injectAgent(): AgUiAgent;
|
|
117
127
|
declare function injectAgent<T>(ref: AgentRef<T>): AgUiAgent<T>;
|
|
118
128
|
|
|
129
|
+
type FakeAgentScriptWhen = 'initial' | {
|
|
130
|
+
toolMessageFor: string;
|
|
131
|
+
};
|
|
132
|
+
interface FakeAgentScriptBranch {
|
|
133
|
+
when: FakeAgentScriptWhen;
|
|
134
|
+
events: readonly BaseEvent[];
|
|
135
|
+
}
|
|
119
136
|
/**
|
|
120
137
|
* In-process AG-UI agent that emits a canned streaming response.
|
|
121
138
|
*
|
|
@@ -134,13 +151,18 @@ declare class FakeAgent extends AbstractAgent {
|
|
|
134
151
|
private readonly reasoningTokens;
|
|
135
152
|
/** Milliseconds between successive token emissions. */
|
|
136
153
|
private readonly delayMs;
|
|
154
|
+
/** Optional deterministic event branches for tests that need exact streams. */
|
|
155
|
+
private readonly script;
|
|
137
156
|
constructor(opts?: {
|
|
138
157
|
tokens?: string[];
|
|
139
158
|
/** Optional reasoning chunks emitted before the text reply. */
|
|
140
159
|
reasoningTokens?: string[];
|
|
141
160
|
delayMs?: number;
|
|
161
|
+
script?: readonly FakeAgentScriptBranch[];
|
|
142
162
|
});
|
|
143
163
|
run(input: RunAgentInput): Observable<BaseEvent>;
|
|
164
|
+
private scriptedSequence;
|
|
165
|
+
private emitSequence;
|
|
144
166
|
}
|
|
145
167
|
|
|
146
168
|
/**
|
|
@@ -152,7 +174,7 @@ declare class FakeAgent extends AbstractAgent {
|
|
|
152
174
|
* @example
|
|
153
175
|
* ```ts
|
|
154
176
|
* TestBed.configureTestingModule({
|
|
155
|
-
* providers: [provideFakeAgent({
|
|
177
|
+
* providers: [provideFakeAgent({ tokens: ['Hello from the fake agent'] })],
|
|
156
178
|
* });
|
|
157
179
|
* ```
|
|
158
180
|
*/
|