@copilotkitnext/core 1.54.1-next.6 → 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 CHANGED
@@ -2854,6 +2854,7 @@ const initialThreadState = {
2854
2854
  context: null,
2855
2855
  sessionId: 0,
2856
2856
  metadataCredentialsRequested: false,
2857
+ metadataJoinCode: null,
2857
2858
  nextCursor: null
2858
2859
  };
2859
2860
  const threadAdapterEvents = createActionGroup("Thread Adapter", {
@@ -2906,6 +2907,7 @@ const threadReducer = createReducer(initialThreadState, on(threadAdapterEvents.c
2906
2907
  isFetchingNextPage: false,
2907
2908
  error: null,
2908
2909
  metadataCredentialsRequested: false,
2910
+ metadataJoinCode: null,
2909
2911
  nextCursor: null
2910
2912
  })), on(threadAdapterEvents.stopped, (state) => ({
2911
2913
  ...state,
@@ -2914,6 +2916,7 @@ const threadReducer = createReducer(initialThreadState, on(threadAdapterEvents.c
2914
2916
  isFetchingNextPage: false,
2915
2917
  error: null,
2916
2918
  metadataCredentialsRequested: false,
2919
+ metadataJoinCode: null,
2917
2920
  nextCursor: null
2918
2921
  })), on(threadRestEvents.listRequested, (state, { sessionId }) => {
2919
2922
  if (sessionId !== state.sessionId || !state.context) return state;
@@ -2922,13 +2925,14 @@ const threadReducer = createReducer(initialThreadState, on(threadAdapterEvents.c
2922
2925
  isLoading: true,
2923
2926
  error: null
2924
2927
  };
2925
- }), on(threadRestEvents.listSucceeded, (state, { sessionId, threads, nextCursor }) => {
2928
+ }), on(threadRestEvents.listSucceeded, (state, { sessionId, threads, joinCode, nextCursor }) => {
2926
2929
  if (sessionId !== state.sessionId) return state;
2927
2930
  return {
2928
2931
  ...state,
2929
2932
  threads: sortThreadsByUpdatedAt(threads),
2930
2933
  isLoading: false,
2931
2934
  error: null,
2935
+ metadataJoinCode: joinCode,
2932
2936
  nextCursor
2933
2937
  };
2934
2938
  }), on(threadRestEvents.listFailed, (state, { sessionId, error }) => {
@@ -3001,10 +3005,7 @@ function createThreadRequestId() {
3001
3005
  }
3002
3006
  function createThreadFetchObservable(environment, context, sessionId) {
3003
3007
  return (0, rxjs.defer)(() => {
3004
- const params = {
3005
- userId: context.userId,
3006
- agentId: context.agentId
3007
- };
3008
+ const params = { agentId: context.agentId };
3008
3009
  if (context.includeArchived) params.includeArchived = "true";
3009
3010
  if (context.limit != null) params.limit = String(context.limit);
3010
3011
  const qs = new URLSearchParams(params);
@@ -3024,6 +3025,7 @@ function createThreadFetchObservable(environment, context, sessionId) {
3024
3025
  }), (0, rxjs_operators.map)((data) => threadRestEvents.listSucceeded({
3025
3026
  sessionId,
3026
3027
  threads: data.threads,
3028
+ joinCode: typeof data.joinCode === "string" && data.joinCode.length > 0 ? data.joinCode : null,
3027
3029
  nextCursor: data.nextCursor ?? null
3028
3030
  })), (0, rxjs_operators.catchError)((error) => {
3029
3031
  return (0, rxjs.of)(threadRestEvents.listFailed({
@@ -3046,7 +3048,7 @@ function createThreadMetadataCredentialsObservable(environment, context, session
3046
3048
  ...context.headers,
3047
3049
  "Content-Type": "application/json"
3048
3050
  },
3049
- body: JSON.stringify({ userId: context.userId })
3051
+ body: JSON.stringify({})
3050
3052
  }).pipe((0, rxjs_operators.timeout)({
3051
3053
  first: REQUEST_TIMEOUT_MS,
3052
3054
  with: () => {
@@ -3102,7 +3104,7 @@ function createThreadStore(environment) {
3102
3104
  context
3103
3105
  })), (0, rxjs_operators.takeUntil)(actions$.pipe(ofType(threadAdapterEvents.contextChanged, threadAdapterEvents.stopped))), (0, rxjs_operators.switchMap)(({ action: currentAction, context }) => createThreadFetchObservable(environment, context, currentAction.sessionId)))))),
3104
3106
  createEffect((actions$, state$) => actions$.pipe(ofType(threadRestEvents.listSucceeded), (0, rxjs_operators.withLatestFrom)(state$), (0, rxjs_operators.filter)(([action, state]) => {
3105
- return action.sessionId === state.sessionId && !state.metadataCredentialsRequested && Boolean(state.context?.wsUrl);
3107
+ return action.sessionId === state.sessionId && !state.metadataCredentialsRequested && Boolean(state.context?.wsUrl) && Boolean(state.metadataJoinCode);
3106
3108
  }), (0, rxjs_operators.map)(([action]) => threadRestEvents.metadataCredentialsRequested({ sessionId: action.sessionId })))),
3107
3109
  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) => ({
3108
3110
  action,
@@ -3113,6 +3115,7 @@ function createThreadStore(environment) {
3113
3115
  }), (0, rxjs_operators.switchMap)(([action, state]) => {
3114
3116
  const context = state.context;
3115
3117
  const joinToken = action.joinToken;
3118
+ const joinCode = state.metadataJoinCode;
3116
3119
  const shutdown$ = actions$.pipe(ofType(threadAdapterEvents.contextChanged, threadAdapterEvents.stopped));
3117
3120
  return (0, rxjs.defer)(() => {
3118
3121
  const socket$ = ɵphoenixSocket$({
@@ -3128,7 +3131,7 @@ function createThreadStore(environment) {
3128
3131
  }));
3129
3132
  const channel$ = ɵphoenixChannel$({
3130
3133
  socket$,
3131
- topic: `user_meta:${context.userId}`
3134
+ topic: `user_meta:${joinCode}`
3132
3135
  }).pipe((0, rxjs_operators.shareReplay)({
3133
3136
  bufferSize: 1,
3134
3137
  refCount: true
@@ -3144,9 +3147,7 @@ function createThreadStore(environment) {
3144
3147
  }))), ɵ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$)));
3145
3148
  });
3146
3149
  }))),
3147
- createEffect((actions$, state$) => actions$.pipe(ofType(threadSocketEvents.metadataReceived), (0, rxjs_operators.withLatestFrom)(state$), (0, rxjs_operators.filter)(([action, state]) => {
3148
- return action.sessionId === state.sessionId && action.payload.userId === state.context?.userId;
3149
- }), (0, rxjs_operators.map)(([action, state]) => {
3150
+ 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]) => {
3150
3151
  if (action.payload.operation === "deleted") return threadDomainEvents.threadDeleted({
3151
3152
  sessionId: action.sessionId,
3152
3153
  threadId: action.payload.deleted.id
@@ -3163,7 +3164,6 @@ function createThreadStore(environment) {
3163
3164
  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]) => {
3164
3165
  const context = state.context;
3165
3166
  const params = {
3166
- userId: context.userId,
3167
3167
  agentId: context.agentId,
3168
3168
  cursor: state.nextCursor
3169
3169
  };
@@ -3201,10 +3201,7 @@ function createThreadStore(environment) {
3201
3201
  error: /* @__PURE__ */ new Error("Runtime URL is not configured")
3202
3202
  } }));
3203
3203
  }
3204
- const commonBody = {
3205
- userId: context.userId,
3206
- agentId: context.agentId
3207
- };
3204
+ const commonBody = { agentId: context.agentId };
3208
3205
  if (threadAdapterEvents.renameRequested.match(action)) return createThreadMutationObservable(environment, context, {
3209
3206
  requestId: action.requestId,
3210
3207
  method: "PATCH",