@copilotkitnext/core 1.54.1-next.5 → 1.54.1
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.cjs +144 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +34 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +143 -26
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +145 -28
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
package/dist/index.umd.js
CHANGED
|
@@ -593,9 +593,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
593
593
|
function isZodError(error) {
|
|
594
594
|
return error !== null && typeof error === "object" && "name" in error && error.name === "ZodError";
|
|
595
595
|
}
|
|
596
|
+
function isAbortError(error) {
|
|
597
|
+
return (error instanceof DOMException || error instanceof Error) && error.name === "AbortError";
|
|
598
|
+
}
|
|
596
599
|
function withAbortErrorHandling(observable) {
|
|
597
600
|
return observable.pipe((0, rxjs_operators.catchError)((error) => {
|
|
598
|
-
if (isZodError(error)) return rxjs.EMPTY;
|
|
601
|
+
if (isZodError(error) || isAbortError(error)) return rxjs.EMPTY;
|
|
599
602
|
throw error;
|
|
600
603
|
}));
|
|
601
604
|
}
|
|
@@ -1514,6 +1517,17 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1514
1517
|
constructor(core) {
|
|
1515
1518
|
this.core = core;
|
|
1516
1519
|
_defineProperty(this, "_tools", []);
|
|
1520
|
+
_defineProperty(this, "_runAbortController", null);
|
|
1521
|
+
_defineProperty(this, "_runDepth", 0);
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Abort the current run. Called by `CopilotKitCore.stopAgent()` to signal
|
|
1525
|
+
* that in-flight tool handlers should stop and `processAgentResult` should
|
|
1526
|
+
* not start a follow-up run.
|
|
1527
|
+
*/
|
|
1528
|
+
abortCurrentRun() {
|
|
1529
|
+
var _this$_runAbortContro;
|
|
1530
|
+
(_this$_runAbortContro = this._runAbortController) === null || _this$_runAbortContro === void 0 || _this$_runAbortContro.abort();
|
|
1517
1531
|
}
|
|
1518
1532
|
/**
|
|
1519
1533
|
* Typed access to CopilotKitCore's internal ("friend") methods.
|
|
@@ -1609,6 +1623,18 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1609
1623
|
if (agent.agentId) this._internal.suggestionEngine.clearSuggestions(agent.agentId);
|
|
1610
1624
|
if (agent instanceof _ag_ui_client.HttpAgent) agent.headers = { ...this._internal.headers };
|
|
1611
1625
|
if (agent.detachActiveRun) await agent.detachActiveRun();
|
|
1626
|
+
const isTopLevel = this._runDepth === 0;
|
|
1627
|
+
let originalAbortRun;
|
|
1628
|
+
if (isTopLevel) {
|
|
1629
|
+
this._runAbortController = new AbortController();
|
|
1630
|
+
const controller = this._runAbortController;
|
|
1631
|
+
originalAbortRun = agent.abortRun.bind(agent);
|
|
1632
|
+
agent.abortRun = () => {
|
|
1633
|
+
controller.abort();
|
|
1634
|
+
originalAbortRun();
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
this._runDepth++;
|
|
1612
1638
|
try {
|
|
1613
1639
|
const runAgentResult = await agent.runAgent({
|
|
1614
1640
|
forwardedProps: {
|
|
@@ -1618,7 +1644,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1618
1644
|
tools: this.buildFrontendTools(agent.agentId),
|
|
1619
1645
|
context: Object.values(this._internal.context)
|
|
1620
1646
|
}, this.createAgentErrorSubscriber(agent));
|
|
1621
|
-
return this.processAgentResult({
|
|
1647
|
+
return await this.processAgentResult({
|
|
1622
1648
|
runAgentResult,
|
|
1623
1649
|
agent
|
|
1624
1650
|
});
|
|
@@ -1632,12 +1658,16 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1632
1658
|
context
|
|
1633
1659
|
});
|
|
1634
1660
|
return { newMessages: [] };
|
|
1661
|
+
} finally {
|
|
1662
|
+
this._runDepth--;
|
|
1663
|
+
if (isTopLevel && originalAbortRun) agent.abortRun = originalAbortRun;
|
|
1635
1664
|
}
|
|
1636
1665
|
}
|
|
1637
1666
|
/**
|
|
1638
1667
|
* Process agent result and execute tools
|
|
1639
1668
|
*/
|
|
1640
1669
|
async processAgentResult({ runAgentResult, agent }) {
|
|
1670
|
+
var _this$_runAbortContro2;
|
|
1641
1671
|
const { newMessages } = runAgentResult;
|
|
1642
1672
|
const agentId = agent.agentId;
|
|
1643
1673
|
let needsFollowUp = false;
|
|
@@ -1660,7 +1690,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1660
1690
|
}
|
|
1661
1691
|
}
|
|
1662
1692
|
}
|
|
1663
|
-
if (needsFollowUp) {
|
|
1693
|
+
if (needsFollowUp && !((_this$_runAbortContro2 = this._runAbortController) === null || _this$_runAbortContro2 === void 0 ? void 0 : _this$_runAbortContro2.signal.aborted)) {
|
|
1664
1694
|
await this._internal.waitForPendingFrameworkUpdates();
|
|
1665
1695
|
return await this.runAgent({ agent });
|
|
1666
1696
|
}
|
|
@@ -1707,9 +1737,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1707
1737
|
});
|
|
1708
1738
|
}, "Subscriber onToolExecutionStart error:");
|
|
1709
1739
|
if (!errorMessage) try {
|
|
1740
|
+
var _this$_runAbortContro3;
|
|
1710
1741
|
const result = await tool.handler(parsedArgs, {
|
|
1711
1742
|
toolCall,
|
|
1712
|
-
agent
|
|
1743
|
+
agent,
|
|
1744
|
+
signal: (_this$_runAbortContro3 = this._runAbortController) === null || _this$_runAbortContro3 === void 0 ? void 0 : _this$_runAbortContro3.signal
|
|
1713
1745
|
});
|
|
1714
1746
|
if (result === void 0 || result === null) toolCallResult = "";
|
|
1715
1747
|
else if (typeof result === "string") toolCallResult = result;
|
|
@@ -2482,6 +2514,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2482
2514
|
return this.runHandler.connectAgent(params);
|
|
2483
2515
|
}
|
|
2484
2516
|
stopAgent(params) {
|
|
2517
|
+
this.runHandler.abortCurrentRun();
|
|
2485
2518
|
params.agent.abortRun();
|
|
2486
2519
|
}
|
|
2487
2520
|
async runAgent(params) {
|
|
@@ -2981,15 +3014,19 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2981
3014
|
const initialThreadState = {
|
|
2982
3015
|
threads: [],
|
|
2983
3016
|
isLoading: false,
|
|
3017
|
+
isFetchingNextPage: false,
|
|
2984
3018
|
error: null,
|
|
2985
3019
|
context: null,
|
|
2986
3020
|
sessionId: 0,
|
|
2987
|
-
metadataCredentialsRequested: false
|
|
3021
|
+
metadataCredentialsRequested: false,
|
|
3022
|
+
metadataJoinCode: null,
|
|
3023
|
+
nextCursor: null
|
|
2988
3024
|
};
|
|
2989
3025
|
const threadAdapterEvents = createActionGroup("Thread Adapter", {
|
|
2990
3026
|
started: empty(),
|
|
2991
3027
|
stopped: empty(),
|
|
2992
3028
|
contextChanged: props(),
|
|
3029
|
+
fetchNextPageRequested: empty(),
|
|
2993
3030
|
renameRequested: props(),
|
|
2994
3031
|
archiveRequested: props(),
|
|
2995
3032
|
deleteRequested: props()
|
|
@@ -2998,6 +3035,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2998
3035
|
listRequested: props(),
|
|
2999
3036
|
listSucceeded: props(),
|
|
3000
3037
|
listFailed: props(),
|
|
3038
|
+
nextPageSucceeded: props(),
|
|
3039
|
+
nextPageFailed: props(),
|
|
3001
3040
|
metadataCredentialsRequested: props(),
|
|
3002
3041
|
metadataCredentialsSucceeded: props(),
|
|
3003
3042
|
metadataCredentialsFailed: props(),
|
|
@@ -3030,14 +3069,20 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3030
3069
|
sessionId: state.sessionId + 1,
|
|
3031
3070
|
threads: [],
|
|
3032
3071
|
isLoading: Boolean(context),
|
|
3072
|
+
isFetchingNextPage: false,
|
|
3033
3073
|
error: null,
|
|
3034
|
-
metadataCredentialsRequested: false
|
|
3074
|
+
metadataCredentialsRequested: false,
|
|
3075
|
+
metadataJoinCode: null,
|
|
3076
|
+
nextCursor: null
|
|
3035
3077
|
})), on(threadAdapterEvents.stopped, (state) => ({
|
|
3036
3078
|
...state,
|
|
3037
3079
|
threads: [],
|
|
3038
3080
|
isLoading: false,
|
|
3081
|
+
isFetchingNextPage: false,
|
|
3039
3082
|
error: null,
|
|
3040
|
-
metadataCredentialsRequested: false
|
|
3083
|
+
metadataCredentialsRequested: false,
|
|
3084
|
+
metadataJoinCode: null,
|
|
3085
|
+
nextCursor: null
|
|
3041
3086
|
})), on(threadRestEvents.listRequested, (state, { sessionId }) => {
|
|
3042
3087
|
if (sessionId !== state.sessionId || !state.context) return state;
|
|
3043
3088
|
return {
|
|
@@ -3045,13 +3090,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3045
3090
|
isLoading: true,
|
|
3046
3091
|
error: null
|
|
3047
3092
|
};
|
|
3048
|
-
}), on(threadRestEvents.listSucceeded, (state, { sessionId, threads }) => {
|
|
3093
|
+
}), on(threadRestEvents.listSucceeded, (state, { sessionId, threads, joinCode, nextCursor }) => {
|
|
3049
3094
|
if (sessionId !== state.sessionId) return state;
|
|
3050
3095
|
return {
|
|
3051
3096
|
...state,
|
|
3052
3097
|
threads: sortThreadsByUpdatedAt(threads),
|
|
3053
3098
|
isLoading: false,
|
|
3054
|
-
error: null
|
|
3099
|
+
error: null,
|
|
3100
|
+
metadataJoinCode: joinCode,
|
|
3101
|
+
nextCursor
|
|
3055
3102
|
};
|
|
3056
3103
|
}), on(threadRestEvents.listFailed, (state, { sessionId, error }) => {
|
|
3057
3104
|
if (sessionId !== state.sessionId) return state;
|
|
@@ -3060,6 +3107,23 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3060
3107
|
isLoading: false,
|
|
3061
3108
|
error
|
|
3062
3109
|
};
|
|
3110
|
+
}), on(threadRestEvents.nextPageSucceeded, (state, { sessionId, threads, nextCursor }) => {
|
|
3111
|
+
if (sessionId !== state.sessionId) return state;
|
|
3112
|
+
let merged = state.threads;
|
|
3113
|
+
for (const thread of threads) merged = upsertThread(merged, thread);
|
|
3114
|
+
return {
|
|
3115
|
+
...state,
|
|
3116
|
+
threads: merged,
|
|
3117
|
+
isFetchingNextPage: false,
|
|
3118
|
+
nextCursor
|
|
3119
|
+
};
|
|
3120
|
+
}), on(threadRestEvents.nextPageFailed, (state, { sessionId, error }) => {
|
|
3121
|
+
if (sessionId !== state.sessionId) return state;
|
|
3122
|
+
return {
|
|
3123
|
+
...state,
|
|
3124
|
+
isFetchingNextPage: false,
|
|
3125
|
+
error
|
|
3126
|
+
};
|
|
3063
3127
|
}), on(threadRestEvents.metadataCredentialsFailed, (state, { sessionId, error }) => {
|
|
3064
3128
|
if (sessionId !== state.sessionId) return state;
|
|
3065
3129
|
return {
|
|
@@ -3072,6 +3136,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3072
3136
|
...state,
|
|
3073
3137
|
metadataCredentialsRequested: true
|
|
3074
3138
|
};
|
|
3139
|
+
}), on(threadAdapterEvents.fetchNextPageRequested, (state) => {
|
|
3140
|
+
if (!state.nextCursor || state.isFetchingNextPage) return state;
|
|
3141
|
+
return {
|
|
3142
|
+
...state,
|
|
3143
|
+
isFetchingNextPage: true
|
|
3144
|
+
};
|
|
3075
3145
|
}), on(threadRestEvents.mutationFinished, (state, { outcome }) => ({
|
|
3076
3146
|
...state,
|
|
3077
3147
|
error: outcome.ok ? state.error : outcome.error
|
|
@@ -3091,6 +3161,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3091
3161
|
const selectThreads = createSelector((state) => state.threads);
|
|
3092
3162
|
const selectThreadsIsLoading = createSelector((state) => state.isLoading);
|
|
3093
3163
|
const selectThreadsError = createSelector((state) => state.error);
|
|
3164
|
+
const selectHasNextPage = createSelector((state) => state.nextCursor != null);
|
|
3165
|
+
const selectIsFetchingNextPage = createSelector((state) => state.isFetchingNextPage);
|
|
3094
3166
|
let threadRequestId = 0;
|
|
3095
3167
|
function createThreadRequestId() {
|
|
3096
3168
|
threadRequestId += 1;
|
|
@@ -3098,11 +3170,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3098
3170
|
}
|
|
3099
3171
|
function createThreadFetchObservable(environment, context, sessionId) {
|
|
3100
3172
|
return (0, rxjs.defer)(() => {
|
|
3101
|
-
const params =
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
return (0, rxjs_fetch.fromFetch)(`${context.runtimeUrl}/threads?${
|
|
3173
|
+
const params = { agentId: context.agentId };
|
|
3174
|
+
if (context.includeArchived) params.includeArchived = "true";
|
|
3175
|
+
if (context.limit != null) params.limit = String(context.limit);
|
|
3176
|
+
const qs = new URLSearchParams(params);
|
|
3177
|
+
return (0, rxjs_fetch.fromFetch)(`${context.runtimeUrl}/threads?${qs.toString()}`, {
|
|
3106
3178
|
selector: (response) => {
|
|
3107
3179
|
if (!response.ok) throw new Error(`Failed to fetch threads: ${response.status}`);
|
|
3108
3180
|
return response.json();
|
|
@@ -3115,10 +3187,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3115
3187
|
with: () => {
|
|
3116
3188
|
throw new Error("Request timed out");
|
|
3117
3189
|
}
|
|
3118
|
-
}), (0, rxjs_operators.map)((data) =>
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3190
|
+
}), (0, rxjs_operators.map)((data) => {
|
|
3191
|
+
var _data$nextCursor;
|
|
3192
|
+
return threadRestEvents.listSucceeded({
|
|
3193
|
+
sessionId,
|
|
3194
|
+
threads: data.threads,
|
|
3195
|
+
joinCode: typeof data.joinCode === "string" && data.joinCode.length > 0 ? data.joinCode : null,
|
|
3196
|
+
nextCursor: (_data$nextCursor = data.nextCursor) !== null && _data$nextCursor !== void 0 ? _data$nextCursor : null
|
|
3197
|
+
});
|
|
3198
|
+
}), (0, rxjs_operators.catchError)((error) => {
|
|
3122
3199
|
return (0, rxjs.of)(threadRestEvents.listFailed({
|
|
3123
3200
|
sessionId,
|
|
3124
3201
|
error: error instanceof Error ? error : new Error(String(error))
|
|
@@ -3139,7 +3216,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3139
3216
|
...context.headers,
|
|
3140
3217
|
"Content-Type": "application/json"
|
|
3141
3218
|
},
|
|
3142
|
-
body: JSON.stringify({
|
|
3219
|
+
body: JSON.stringify({})
|
|
3143
3220
|
}).pipe((0, rxjs_operators.timeout)({
|
|
3144
3221
|
first: REQUEST_TIMEOUT_MS,
|
|
3145
3222
|
with: () => {
|
|
@@ -3196,7 +3273,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3196
3273
|
})), (0, rxjs_operators.takeUntil)(actions$.pipe(ofType(threadAdapterEvents.contextChanged, threadAdapterEvents.stopped))), (0, rxjs_operators.switchMap)(({ action: currentAction, context }) => createThreadFetchObservable(environment, context, currentAction.sessionId)))))),
|
|
3197
3274
|
createEffect((actions$, state$) => actions$.pipe(ofType(threadRestEvents.listSucceeded), (0, rxjs_operators.withLatestFrom)(state$), (0, rxjs_operators.filter)(([action, state]) => {
|
|
3198
3275
|
var _state$context;
|
|
3199
|
-
return action.sessionId === state.sessionId && !state.metadataCredentialsRequested && Boolean((_state$context = state.context) === null || _state$context === void 0 ? void 0 : _state$context.wsUrl);
|
|
3276
|
+
return action.sessionId === state.sessionId && !state.metadataCredentialsRequested && Boolean((_state$context = state.context) === null || _state$context === void 0 ? void 0 : _state$context.wsUrl) && Boolean(state.metadataJoinCode);
|
|
3200
3277
|
}), (0, rxjs_operators.map)(([action]) => threadRestEvents.metadataCredentialsRequested({ sessionId: action.sessionId })))),
|
|
3201
3278
|
createEffect((actions$, state$) => actions$.pipe(ofType(threadRestEvents.metadataCredentialsRequested), (0, rxjs_operators.switchMap)((action) => state$.pipe((0, rxjs_operators.map)((state) => state.context), (0, rxjs_operators.filter)((context) => Boolean(context)), (0, rxjs_operators.take)(1), (0, rxjs_operators.map)((context) => ({
|
|
3202
3279
|
action,
|
|
@@ -3208,6 +3285,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3208
3285
|
}), (0, rxjs_operators.switchMap)(([action, state]) => {
|
|
3209
3286
|
const context = state.context;
|
|
3210
3287
|
const joinToken = action.joinToken;
|
|
3288
|
+
const joinCode = state.metadataJoinCode;
|
|
3211
3289
|
const shutdown$ = actions$.pipe(ofType(threadAdapterEvents.contextChanged, threadAdapterEvents.stopped));
|
|
3212
3290
|
return (0, rxjs.defer)(() => {
|
|
3213
3291
|
const socket$ = ɵphoenixSocket$({
|
|
@@ -3223,7 +3301,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3223
3301
|
}));
|
|
3224
3302
|
const channel$ = ɵphoenixChannel$({
|
|
3225
3303
|
socket$,
|
|
3226
|
-
topic: `user_meta:${
|
|
3304
|
+
topic: `user_meta:${joinCode}`
|
|
3227
3305
|
}).pipe((0, rxjs_operators.shareReplay)({
|
|
3228
3306
|
bufferSize: 1,
|
|
3229
3307
|
refCount: true
|
|
@@ -3239,19 +3317,54 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3239
3317
|
}))), ɵobservePhoenixJoinOutcome$(channel$).pipe((0, rxjs_operators.filter)((outcome) => outcome.type !== "joined"), (0, rxjs_operators.map)((outcome) => outcome.type === "timeout" ? threadSocketEvents.joinTimedOut({ sessionId: action.sessionId }) : threadSocketEvents.joinFailed({ sessionId: action.sessionId })))).pipe((0, rxjs_operators.takeUntil)((0, rxjs.merge)(shutdown$, fatalSocketShutdown$)));
|
|
3240
3318
|
});
|
|
3241
3319
|
}))),
|
|
3242
|
-
createEffect((actions$, state$) => actions$.pipe(ofType(threadSocketEvents.metadataReceived), (0, rxjs_operators.withLatestFrom)(state$), (0, rxjs_operators.filter)(([action, state]) => {
|
|
3320
|
+
createEffect((actions$, state$) => actions$.pipe(ofType(threadSocketEvents.metadataReceived), (0, rxjs_operators.withLatestFrom)(state$), (0, rxjs_operators.filter)(([action, state]) => action.sessionId === state.sessionId), (0, rxjs_operators.map)(([action, state]) => {
|
|
3243
3321
|
var _state$context3;
|
|
3244
|
-
return action.sessionId === state.sessionId && action.payload.userId === ((_state$context3 = state.context) === null || _state$context3 === void 0 ? void 0 : _state$context3.userId);
|
|
3245
|
-
}), (0, rxjs_operators.map)(([action]) => {
|
|
3246
3322
|
if (action.payload.operation === "deleted") return threadDomainEvents.threadDeleted({
|
|
3247
3323
|
sessionId: action.sessionId,
|
|
3248
3324
|
threadId: action.payload.deleted.id
|
|
3249
3325
|
});
|
|
3326
|
+
if (action.payload.operation === "archived" && !((_state$context3 = state.context) === null || _state$context3 === void 0 ? void 0 : _state$context3.includeArchived)) return threadDomainEvents.threadDeleted({
|
|
3327
|
+
sessionId: action.sessionId,
|
|
3328
|
+
threadId: action.payload.threadId
|
|
3329
|
+
});
|
|
3250
3330
|
return threadDomainEvents.threadUpserted({
|
|
3251
3331
|
sessionId: action.sessionId,
|
|
3252
3332
|
thread: action.payload.thread
|
|
3253
3333
|
});
|
|
3254
3334
|
}))),
|
|
3335
|
+
createEffect((actions$, state$) => actions$.pipe(ofType(threadAdapterEvents.fetchNextPageRequested), (0, rxjs_operators.withLatestFrom)(state$), (0, rxjs_operators.filter)(([, state]) => Boolean(state.context) && Boolean(state.nextCursor)), (0, rxjs_operators.switchMap)(([, state]) => {
|
|
3336
|
+
const context = state.context;
|
|
3337
|
+
const params = {
|
|
3338
|
+
agentId: context.agentId,
|
|
3339
|
+
cursor: state.nextCursor
|
|
3340
|
+
};
|
|
3341
|
+
if (context.includeArchived) params.includeArchived = "true";
|
|
3342
|
+
if (context.limit != null) params.limit = String(context.limit);
|
|
3343
|
+
return (0, rxjs_fetch.fromFetch)(`${context.runtimeUrl}/threads?${new URLSearchParams(params).toString()}`, {
|
|
3344
|
+
selector: (response) => {
|
|
3345
|
+
if (!response.ok) throw new Error(`Failed to fetch next page: ${response.status}`);
|
|
3346
|
+
return response.json();
|
|
3347
|
+
},
|
|
3348
|
+
fetch: environment.fetch,
|
|
3349
|
+
method: "GET",
|
|
3350
|
+
headers: { ...context.headers }
|
|
3351
|
+
}).pipe((0, rxjs_operators.timeout)({
|
|
3352
|
+
first: REQUEST_TIMEOUT_MS,
|
|
3353
|
+
with: () => {
|
|
3354
|
+
throw new Error("Request timed out");
|
|
3355
|
+
}
|
|
3356
|
+
}), (0, rxjs_operators.map)((data) => {
|
|
3357
|
+
var _data$nextCursor2;
|
|
3358
|
+
return threadRestEvents.nextPageSucceeded({
|
|
3359
|
+
sessionId: state.sessionId,
|
|
3360
|
+
threads: data.threads,
|
|
3361
|
+
nextCursor: (_data$nextCursor2 = data.nextCursor) !== null && _data$nextCursor2 !== void 0 ? _data$nextCursor2 : null
|
|
3362
|
+
});
|
|
3363
|
+
}), (0, rxjs_operators.catchError)((error) => (0, rxjs.of)(threadRestEvents.nextPageFailed({
|
|
3364
|
+
sessionId: state.sessionId,
|
|
3365
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
3366
|
+
}))), (0, rxjs_operators.takeUntil)(actions$.pipe(ofType(threadAdapterEvents.contextChanged, threadAdapterEvents.stopped))));
|
|
3367
|
+
}))),
|
|
3255
3368
|
createEffect((actions$, state$) => actions$.pipe(ofType(threadAdapterEvents.renameRequested, threadAdapterEvents.archiveRequested, threadAdapterEvents.deleteRequested), (0, rxjs_operators.withLatestFrom)(state$), (0, rxjs_operators.mergeMap)(([action, state]) => {
|
|
3256
3369
|
const context = state.context;
|
|
3257
3370
|
if (!(context === null || context === void 0 ? void 0 : context.runtimeUrl)) {
|
|
@@ -3262,10 +3375,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3262
3375
|
error: /* @__PURE__ */ new Error("Runtime URL is not configured")
|
|
3263
3376
|
} }));
|
|
3264
3377
|
}
|
|
3265
|
-
const commonBody = {
|
|
3266
|
-
userId: context.userId,
|
|
3267
|
-
agentId: context.agentId
|
|
3268
|
-
};
|
|
3378
|
+
const commonBody = { agentId: context.agentId };
|
|
3269
3379
|
if (threadAdapterEvents.renameRequested.match(action)) return createThreadMutationObservable(environment, context, {
|
|
3270
3380
|
requestId: action.requestId,
|
|
3271
3381
|
method: "PATCH",
|
|
@@ -3314,6 +3424,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3314
3424
|
setContext(context) {
|
|
3315
3425
|
store.dispatch(threadAdapterEvents.contextChanged({ context }));
|
|
3316
3426
|
},
|
|
3427
|
+
fetchNextPage() {
|
|
3428
|
+
store.dispatch(threadAdapterEvents.fetchNextPageRequested());
|
|
3429
|
+
},
|
|
3317
3430
|
renameThread(threadId, name) {
|
|
3318
3431
|
return trackMutation(threadAdapterEvents.renameRequested({
|
|
3319
3432
|
requestId: createThreadRequestId(),
|
|
@@ -3343,6 +3456,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3343
3456
|
const ɵselectThreads = selectThreads;
|
|
3344
3457
|
const ɵselectThreadsIsLoading = selectThreadsIsLoading;
|
|
3345
3458
|
const ɵselectThreadsError = selectThreadsError;
|
|
3459
|
+
const ɵselectHasNextPage = selectHasNextPage;
|
|
3460
|
+
const ɵselectIsFetchingNextPage = selectIsFetchingNextPage;
|
|
3346
3461
|
|
|
3347
3462
|
//#endregion
|
|
3348
3463
|
exports.AgentRegistry = AgentRegistry;
|
|
@@ -3377,6 +3492,8 @@ exports.ɵobservePhoenixSocketHealth$ = ɵobservePhoenixSocketHealth$;
|
|
|
3377
3492
|
exports.ɵobservePhoenixSocketSignals$ = ɵobservePhoenixSocketSignals$;
|
|
3378
3493
|
exports.ɵphoenixChannel$ = ɵphoenixChannel$;
|
|
3379
3494
|
exports.ɵphoenixSocket$ = ɵphoenixSocket$;
|
|
3495
|
+
exports.ɵselectHasNextPage = ɵselectHasNextPage;
|
|
3496
|
+
exports.ɵselectIsFetchingNextPage = ɵselectIsFetchingNextPage;
|
|
3380
3497
|
exports.ɵselectThreads = ɵselectThreads;
|
|
3381
3498
|
exports.ɵselectThreadsError = ɵselectThreadsError;
|
|
3382
3499
|
exports.ɵselectThreadsIsLoading = ɵselectThreadsIsLoading;
|