Commit Graph

2778 Commits

Author SHA1 Message Date
Tat Dat Duong 8542079345 Expand hook timeout to 20_000 2025-07-03 14:25:56 +02:00
Tat Dat Duong f858150d6e Simplify start of server 2025-07-03 14:21:00 +02:00
Tat Dat Duong 5ff0446d9a Fix The URL must be of scheme file 2025-07-03 00:41:46 +02:00
Tat Dat Duong 85ed34c8dc Update lockfile 2025-07-03 00:33:50 +02:00
Tat Dat Duong 0055bea118 Merge branch 'main' into dqbd/lgjsapi 2025-07-03 00:29:57 +02:00
David Duong 4a0b43909f chore: move sdk-js to langgraphjs (#1329) 2025-07-02 21:40:38 +02:00
Tat Dat Duong 7e16bee986 Update lockfile again 2025-07-02 21:26:19 +02:00
Tat Dat Duong b082ee5903 Rename from sdk-js to sdk 2025-07-02 21:26:14 +02:00
Tat Dat Duong e7175caad5 Lockfile update 2025-07-02 21:23:46 +02:00
Tat Dat Duong 4295efcca7 Remove unused files 2025-07-02 21:21:32 +02:00
Tat Dat Duong d2913d89cb Make test more resilient 2025-07-02 20:54:34 +02:00
Tat Dat Duong 525a89474e Another script check 2025-07-02 20:32:41 +02:00
Tat Dat Duong 565b5dd5bd Remove 18.x from CI 2025-07-02 20:29:22 +02:00
Tat Dat Duong a4a710f3df Fix scripts 2025-07-02 20:26:16 +02:00
Tat Dat Duong aea5b9b6c4 Dedupe Prettier 2025-07-02 20:23:21 +02:00
Tat Dat Duong 5df63ba25c Update dependencies, remove circular dependency 2025-07-02 20:20:16 +02:00
Tat Dat Duong 559b9bac3f Merge remote-tracking branch 'sdk-js/main' into dqbd/sdk-js 2025-07-02 19:56:01 +02:00
Josh Rogers 7c33aa5c45 Bump js sdk to 0.0.89 (#5313) 2025-07-02 09:56:04 -07:00
Tat Dat Duong 9329cde70b Revert change to remove 18.x, disable auth tests instead 2025-07-02 18:32:41 +02:00
Tat Dat Duong f4a65923f1 Kill server 2025-07-02 03:42:54 +02:00
Tat Dat Duong 3aa7751837 Remove 18.x EOL 2025-07-02 03:09:40 +02:00
Tat Dat Duong a254b5e817 Make schemas timeout 2025-07-02 02:51:02 +02:00
Tat Dat Duong 005d83facf Remove only modifier 2025-07-02 02:47:05 +02:00
Tat Dat Duong 66219801db Test 2025-07-02 02:44:04 +02:00
Tat Dat Duong 8fa640beba Update turbo definitions 2025-07-02 02:35:57 +02:00
Tat Dat Duong 799a08edc3 Simplify build process, remove Bun 2025-07-02 01:46:19 +02:00
Josh Rogers c497c8e984 Updating message types to include all base message fields (#5298) 2025-07-01 15:40:13 -07:00
Tat Dat Duong decbaefbc0 Remove old yarn 2025-07-02 00:01:41 +02:00
Tat Dat Duong bcf06be8f7 Another pass at fixing build 2025-07-02 00:00:19 +02:00
Tat Dat Duong 2b211391c8 Update dependencies 2025-07-02 00:00:05 +02:00
Tat Dat Duong ace7c913f6 Merge remote-tracking branch 'langgraphjs-api/main' into dqbd/lgjsapi 2025-07-01 23:58:40 +02:00
David Duong e521f5f35f release(langgraph): 0.3.6 (#1326) 0.3.6 2025-07-01 12:45:05 +00:00
David Duong b0e9239c86 release(langgraph): 0.3.5 (#1325) 2025-07-01 12:37:59 +00:00
David Duong 1dc89b94fd release(sdk-js): 0.0.88 (#5294) 2025-07-01 14:30:37 +02:00
Tat Dat Duong 3463730b44 release(sdk-js): 0.0.88 2025-07-01 14:21:11 +02:00
David Duong d2767e827d feat(react): enhance useStream with initialValues, newThreadId, and onStop callback for improved UX (#5111) 2025-07-01 01:53:28 +02:00
Tat Dat Duong 1288696d8e Make sure to spread stream values 2025-07-01 01:39:53 +02:00
Tat Dat Duong 00550f18ea Fix non-existent assistantId 2025-07-01 01:35:59 +02:00
Tat Dat Duong 67344b3654 Fix typo 2025-07-01 01:33:08 +02:00
Tat Dat Duong 79155789f5 Cleanup 2025-07-01 01:19:07 +02:00
MauritsBrinkman 3b04510c00 test: add useStream onStop callback tests 2025-06-30 16:43:48 +02:00
MauritsBrinkman 55df97d60f feat: add onStop callback to useStream for custom stop behavior
Add onStop callback to useStream hook enabling developers to customize
UI behavior when streams are stopped. This is especially useful for
UI messages with loading states that need to show "stopped" status
instead of remaining in infinite loading state.

The callback provides the same mutate function as onCustomEvent for
immediate local state updates, while users can optionally update
server thread state using the threads client.

Example usage:
```typescript
const stream = useStream({
  assistantId: "my-assistant",
  onStop: async ({ mutate }) => {
    // Immediate UI update - stop loading components
    mutate((prev) => ({
      ...prev,
      ui: prev.ui?.map(component =>
        component.props?.isLoading
          ? {
              ...component,
              props: {
                ...component.props,
                isLoading: false,
                isStopped: true
              }
            }
          : component
      )
    }));

    // Optional server thread state update
    if (stream.threadId) {
      await stream.client.threads.updateState(stream.threadId, {
        values: {
          ui: prev.ui // persist stopped state to server
        }
      });
    }
  }
});
```

This is especially useful for cases where gen UI components have loading states,
where we don't want the loading state to persist on cancellation.
2025-06-30 16:43:13 +02:00
MauritsBrinkman a740542ce7 fix(sdk-js): convert SSE classes to factory functions to resolve tree shaking
- Convert BytesLineDecoder and SSEDecoder from classes extending TransformStream to factory functions
- Fixes tree shaking failures that prevented build completion
- Maintains identical API functionality, just removes 'new' keyword usage
- All tests continue to pass

Resolves tree shaking side effect detection issues with TransformStream extension
2025-06-30 16:43:13 +02:00
MauritsBrinkman 2613fa6b48 docs(react): add documentation and tests for initialValues and newThreadId options
- Document initialValues for cached thread display
- Document newThreadId for optimistic thread creation
- Add comprehensive test coverage for both features
2025-06-30 16:43:12 +02:00
MauritsBrinkman a838d2b824 feat(react): add initialValues option to useStream for cached thread display
Add initialValues parameter to UseStreamOptions to enable immediate display
of cached thread data while official history is being fetched from the server.

This addresses the common use case where applications cache thread data
locally (IndexedDB, localStorage, etc.) and want to show it instantly when
users navigate to existing threads, providing better UX with faster loading.

Key changes:
- Add initialValues?: Partial<StateType> | null to UseStreamOptions interface
- Update values precedence: streamValues > initialValues > historyValues
- Ensure optimisticValues properly override initialValues during submission
- Maintain full backward compatibility with existing API

Example usage:
```typescript
const stream = useStream({
  threadId,
  assistantId: 'my-assistant',
  initialValues: cachedThreadData?.values // Show cached data immediately
});
```

The values flow now follows this priority:
1. Initial load: shows initialValues while history loads
2. During submit: optimisticValues take precedence
3. After server response: official history replaces all
2025-06-30 16:43:12 +02:00
MauritsBrinkman d434e37e77 feat(react): add newThreadId option to useStream for optimistic UI
Add optional newThreadId parameter to useStream hook that allows specifying
a thread ID for new thread creation while keeping threadId null. This enables
optimistic UI patterns where developers need to know the thread ID beforehand
for routing/navigation without causing 404 errors from attempting to fetch
non-existent thread history.

Usage:
- Set threadId: null and newThreadId: "predetermined-id"
- Submit message to create thread with specified ID
- Use onThreadId callback to update threadId after creation

This solves the UX problem of having to await thread creation before
enabling optimistic navigation to e.g. /[threadId] routes.
2025-06-30 16:43:12 +02:00
David Duong 568941dbfb fix: Allow configuring stream mode in useStream.joinStream() (#5146) 2025-06-30 16:37:56 +02:00
David Duong cdddd5f6e8 chore(sdk-js): use embed LGP server for MSW mocking (#5174) 2025-06-30 16:33:47 +02:00
Tat Dat Duong e5d378ec25 Use published package 2025-06-30 13:51:32 +02:00
David Duong 8ca9c3c7e6 Merge pull request #89 from langchain-ai/dqbd/0.0.41
release: 0.0.41
2025-06-30 13:30:19 +02:00