@threadplane/langgraph 0.0.52 → 0.0.54
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.
|
@@ -496,7 +496,7 @@ function isLgTraceEnabled() {
|
|
|
496
496
|
function lgTrace(...args) {
|
|
497
497
|
if (isLgTraceEnabled()) {
|
|
498
498
|
// eslint-disable-next-line no-console
|
|
499
|
-
console.debug('[
|
|
499
|
+
console.debug('[tplane-chat-stream]', ...args);
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
502
|
function captureAgentRuntimeTelemetry(sink, event, properties) {
|
|
@@ -547,9 +547,9 @@ function createStreamManagerBridge({ options, subjects, threadId$, destroy$ }) {
|
|
|
547
547
|
onSubagentChange: publishSubagents,
|
|
548
548
|
});
|
|
549
549
|
const telemetryProperties = { transport: 'langgraph', surface: 'agent' };
|
|
550
|
-
captureAgentRuntimeTelemetry(options.telemetry, '
|
|
550
|
+
captureAgentRuntimeTelemetry(options.telemetry, 'tplane:runtime_instance_created', telemetryProperties);
|
|
551
551
|
function captureRuntimeRequestTelemetry(requestType) {
|
|
552
|
-
captureAgentRuntimeTelemetry(options.telemetry, '
|
|
552
|
+
captureAgentRuntimeTelemetry(options.telemetry, 'tplane:runtime_request_created', {
|
|
553
553
|
...telemetryProperties,
|
|
554
554
|
requestType,
|
|
555
555
|
});
|
|
@@ -734,7 +734,7 @@ function createStreamManagerBridge({ options, subjects, threadId$, destroy$ }) {
|
|
|
734
734
|
abortController = new AbortController();
|
|
735
735
|
const startedAt = Date.now();
|
|
736
736
|
captureRuntimeRequestTelemetry('join_queued');
|
|
737
|
-
captureAgentRuntimeTelemetry(options.telemetry, '
|
|
737
|
+
captureAgentRuntimeTelemetry(options.telemetry, 'tplane:stream_started', telemetryProperties);
|
|
738
738
|
subjects.custom$.next([]);
|
|
739
739
|
subjects.toolProgress$.next([]);
|
|
740
740
|
toolProgressMap.clear();
|
|
@@ -754,7 +754,7 @@ function createStreamManagerBridge({ options, subjects, threadId$, destroy$ }) {
|
|
|
754
754
|
// post-process node mutations (RemoveMessage, id-match content
|
|
755
755
|
// replacement) reflected on the server are picked up client-side.
|
|
756
756
|
await refreshHistory(true);
|
|
757
|
-
captureAgentRuntimeTelemetry(options.telemetry, '
|
|
757
|
+
captureAgentRuntimeTelemetry(options.telemetry, 'tplane:stream_ended', {
|
|
758
758
|
...telemetryProperties,
|
|
759
759
|
durationMs: Date.now() - startedAt,
|
|
760
760
|
});
|
|
@@ -763,7 +763,7 @@ function createStreamManagerBridge({ options, subjects, threadId$, destroy$ }) {
|
|
|
763
763
|
catch (err) {
|
|
764
764
|
subjects.error$.next(toAgentError(err));
|
|
765
765
|
subjects.status$.next(ResourceStatus.Error);
|
|
766
|
-
captureAgentRuntimeTelemetry(options.telemetry, '
|
|
766
|
+
captureAgentRuntimeTelemetry(options.telemetry, 'tplane:stream_errored', {
|
|
767
767
|
...telemetryProperties,
|
|
768
768
|
durationMs: Date.now() - startedAt,
|
|
769
769
|
errorClass: agentRuntimeTelemetryErrorClass(err),
|
|
@@ -776,7 +776,7 @@ function createStreamManagerBridge({ options, subjects, threadId$, destroy$ }) {
|
|
|
776
776
|
userAbortRequested = false;
|
|
777
777
|
const startedAt = Date.now();
|
|
778
778
|
captureRuntimeRequestTelemetry(requestType);
|
|
779
|
-
captureAgentRuntimeTelemetry(options.telemetry, '
|
|
779
|
+
captureAgentRuntimeTelemetry(options.telemetry, 'tplane:stream_started', telemetryProperties);
|
|
780
780
|
subjects.status$.next(ResourceStatus.Loading);
|
|
781
781
|
subjects.error$.next(undefined);
|
|
782
782
|
subjects.custom$.next([]);
|
|
@@ -820,7 +820,7 @@ function createStreamManagerBridge({ options, subjects, threadId$, destroy$ }) {
|
|
|
820
820
|
// authoritative after run completion.
|
|
821
821
|
await refreshHistory(true);
|
|
822
822
|
await drainQueue();
|
|
823
|
-
captureAgentRuntimeTelemetry(options.telemetry, '
|
|
823
|
+
captureAgentRuntimeTelemetry(options.telemetry, 'tplane:stream_ended', {
|
|
824
824
|
...telemetryProperties,
|
|
825
825
|
durationMs: Date.now() - startedAt,
|
|
826
826
|
});
|
|
@@ -839,7 +839,7 @@ function createStreamManagerBridge({ options, subjects, threadId$, destroy$ }) {
|
|
|
839
839
|
: new AgentError({ kind: 'connection', message: AGENT_ERROR_MESSAGES.connection, retryable: true, cause: err });
|
|
840
840
|
subjects.error$.next(e);
|
|
841
841
|
subjects.status$.next(ResourceStatus.Error);
|
|
842
|
-
captureAgentRuntimeTelemetry(options.telemetry, '
|
|
842
|
+
captureAgentRuntimeTelemetry(options.telemetry, 'tplane:stream_errored', {
|
|
843
843
|
...telemetryProperties,
|
|
844
844
|
durationMs: Date.now() - startedAt,
|
|
845
845
|
errorClass: agentRuntimeTelemetryErrorClass(err),
|
|
@@ -848,7 +848,7 @@ function createStreamManagerBridge({ options, subjects, threadId$, destroy$ }) {
|
|
|
848
848
|
else {
|
|
849
849
|
subjects.error$.next(toAgentError(err));
|
|
850
850
|
subjects.status$.next(ResourceStatus.Error);
|
|
851
|
-
captureAgentRuntimeTelemetry(options.telemetry, '
|
|
851
|
+
captureAgentRuntimeTelemetry(options.telemetry, 'tplane:stream_errored', {
|
|
852
852
|
...telemetryProperties,
|
|
853
853
|
durationMs: Date.now() - startedAt,
|
|
854
854
|
errorClass: agentRuntimeTelemetryErrorClass(err),
|
|
@@ -1146,7 +1146,7 @@ function createStreamManagerBridge({ options, subjects, threadId$, destroy$ }) {
|
|
|
1146
1146
|
abortController = new AbortController();
|
|
1147
1147
|
const startedAt = Date.now();
|
|
1148
1148
|
captureRuntimeRequestTelemetry('join');
|
|
1149
|
-
captureAgentRuntimeTelemetry(options.telemetry, '
|
|
1149
|
+
captureAgentRuntimeTelemetry(options.telemetry, 'tplane:stream_started', telemetryProperties);
|
|
1150
1150
|
subjects.custom$.next([]);
|
|
1151
1151
|
subjects.toolProgress$.next([]);
|
|
1152
1152
|
toolProgressMap.clear();
|
|
@@ -1160,7 +1160,7 @@ function createStreamManagerBridge({ options, subjects, threadId$, destroy$ }) {
|
|
|
1160
1160
|
}
|
|
1161
1161
|
subjects.status$.next(ResourceStatus.Resolved);
|
|
1162
1162
|
await refreshHistory();
|
|
1163
|
-
captureAgentRuntimeTelemetry(options.telemetry, '
|
|
1163
|
+
captureAgentRuntimeTelemetry(options.telemetry, 'tplane:stream_ended', {
|
|
1164
1164
|
...telemetryProperties,
|
|
1165
1165
|
durationMs: Date.now() - startedAt,
|
|
1166
1166
|
});
|
|
@@ -1168,7 +1168,7 @@ function createStreamManagerBridge({ options, subjects, threadId$, destroy$ }) {
|
|
|
1168
1168
|
catch (err) {
|
|
1169
1169
|
subjects.error$.next(toAgentError(err));
|
|
1170
1170
|
subjects.status$.next(ResourceStatus.Error);
|
|
1171
|
-
captureAgentRuntimeTelemetry(options.telemetry, '
|
|
1171
|
+
captureAgentRuntimeTelemetry(options.telemetry, 'tplane:stream_errored', {
|
|
1172
1172
|
...telemetryProperties,
|
|
1173
1173
|
durationMs: Date.now() - startedAt,
|
|
1174
1174
|
errorClass: agentRuntimeTelemetryErrorClass(err),
|
|
@@ -2894,6 +2894,12 @@ class MockAgentTransport {
|
|
|
2894
2894
|
*
|
|
2895
2895
|
* Neutral `Agent`-contract signals come from {@link mockAgent}; LangGraph-specific
|
|
2896
2896
|
* signals are declared here and layered on top.
|
|
2897
|
+
*
|
|
2898
|
+
* @example
|
|
2899
|
+
* ```ts
|
|
2900
|
+
* const agent = mockLangGraphAgent({ isThreadLoading: true });
|
|
2901
|
+
* agent.messages.set([{ id: '1', role: 'assistant', content: 'Hi' }]);
|
|
2902
|
+
* ```
|
|
2897
2903
|
*/
|
|
2898
2904
|
function mockLangGraphAgent(initial = {}) {
|
|
2899
2905
|
const base = mockAgent({
|
|
@@ -3067,6 +3073,13 @@ function delay(ms) {
|
|
|
3067
3073
|
* advanced manual scripting (tool calls, interrupts, multi-batch), provide
|
|
3068
3074
|
* the agent yourself with
|
|
3069
3075
|
* `provideAgent({ assistantId, transport: new MockAgentTransport(...) })`.
|
|
3076
|
+
*
|
|
3077
|
+
* @example
|
|
3078
|
+
* ```ts
|
|
3079
|
+
* TestBed.configureTestingModule({
|
|
3080
|
+
* providers: [provideFakeAgent({ responses: ['Hi from the fake LangGraph agent'] })],
|
|
3081
|
+
* });
|
|
3082
|
+
* ```
|
|
3070
3083
|
*/
|
|
3071
3084
|
function provideFakeAgent(config = {}) {
|
|
3072
3085
|
return provideAgent({
|