@optima-chat/agentic-sdk 0.23.0 → 0.24.0
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.
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { ChatError, ConnectionState } from '../types.js';
|
|
2
|
+
/** Options for {@link useConnectionState}'s `startNewSession`. */
|
|
3
|
+
export type StartNewSessionOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Also null `currentConversationId` before reconnecting (opt-in; default off).
|
|
6
|
+
* Use on COO ENTER, where the forceNew abandons the current session and its
|
|
7
|
+
* conversation pointer becomes a dangling reference the new session doesn't know.
|
|
8
|
+
*/
|
|
9
|
+
resetConversation?: boolean;
|
|
10
|
+
};
|
|
2
11
|
export declare function useConnectionState(): {
|
|
3
12
|
connectionState: ConnectionState;
|
|
4
13
|
/**
|
|
@@ -23,8 +32,16 @@ export declare function useConnectionState(): {
|
|
|
23
32
|
* `processingConversationIds` + resets the `isStreaming`/`isThinking` flags) — a
|
|
24
33
|
* forceNew deliberately drops the current session, so any turn still streaming on
|
|
25
34
|
* it can never emit `finish`, which would otherwise leave the composer stuck
|
|
26
|
-
* (#619).
|
|
35
|
+
* (#619).
|
|
36
|
+
*
|
|
37
|
+
* `opts.resetConversation` (opt-in): also null `currentConversationId` before
|
|
38
|
+
* reconnecting. The pointer survives a forceNew as a dangling reference to a
|
|
39
|
+
* conversation the NEW session doesn't know (e.g. the onboarding conversation on
|
|
40
|
+
* COO ENTER) — the first message would mis-route into it and the connected-edge
|
|
41
|
+
* auto-restore would fire a spurious `restore_request` for it. Nulling lets the
|
|
42
|
+
* shell lazily create a fresh conversation. Left OFF by default so EXIT (COO→chat)
|
|
43
|
+
* keeps the user's place; the caller decides per direction (#619 follow-up).
|
|
27
44
|
*/
|
|
28
|
-
startNewSession: () => Promise<void>;
|
|
45
|
+
startNewSession: (opts?: StartNewSessionOptions) => Promise<void>;
|
|
29
46
|
};
|
|
30
47
|
//# sourceMappingURL=use-connection-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-connection-state.d.ts","sourceRoot":"","sources":["../../src/hooks/use-connection-state.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D,wBAAgB,kBAAkB,IAAI;IACpC,eAAe,EAAE,eAAe,CAAC;IACjC;;;;;;;OAOG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB
|
|
1
|
+
{"version":3,"file":"use-connection-state.d.ts","sourceRoot":"","sources":["../../src/hooks/use-connection-state.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D,kEAAkE;AAClE,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,wBAAgB,kBAAkB,IAAI;IACpC,eAAe,EAAE,eAAe,CAAC;IACjC;;;;;;;OAOG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,EAAE,CAAC,IAAI,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnE,CA6CA"}
|
|
@@ -13,7 +13,7 @@ export function useConnectionState() {
|
|
|
13
13
|
const reconnect = useCallback(() => {
|
|
14
14
|
void client.reconnect();
|
|
15
15
|
}, [client]);
|
|
16
|
-
const startNewSession = useCallback(async () => {
|
|
16
|
+
const startNewSession = useCallback(async (opts) => {
|
|
17
17
|
// A forceNew session deliberately abandons the current gateway session, so a
|
|
18
18
|
// turn that was mid-stream at switch time (e.g. the onboarding greeting when
|
|
19
19
|
// the user hits "Enter COO") will never emit `finish` — its socket is torn
|
|
@@ -23,16 +23,22 @@ export function useConnectionState() {
|
|
|
23
23
|
// composer on "停止生成" (#619). Reconcile that abandoned state BEFORE
|
|
24
24
|
// reconnecting.
|
|
25
25
|
//
|
|
26
|
-
//
|
|
27
|
-
// untouched. It's a UI pointer to a still-restorable conversation, not
|
|
28
|
-
// abandoned-session state — nulling it here would fire on EXIT (COO→chat) too
|
|
29
|
-
// and drop the user's place. Route-level conversation reset is the caller's
|
|
30
|
-
// decision. Scoped to the forceNew path only: ordinary auto-reconnect must keep
|
|
26
|
+
// Scoped to the forceNew path only: ordinary auto-reconnect must keep
|
|
31
27
|
// processing so restore can resume the live turn on the SAME session.
|
|
32
28
|
const s = store.getState();
|
|
33
29
|
s.clearProcessingConversations();
|
|
34
30
|
s.setStreaming(false);
|
|
35
31
|
s.setThinking(false);
|
|
32
|
+
// Opt-in: also drop `currentConversationId`. It's a UI pointer that survives a
|
|
33
|
+
// forceNew as a dangling reference — the NEW session doesn't know it, so the
|
|
34
|
+
// first message would mis-route into it, and the connected-edge auto-restore
|
|
35
|
+
// (setConnectionState → _tryAutoRestore) would fire a spurious restore_request
|
|
36
|
+
// for it on the fresh session. Must run BEFORE `client.startNewSession()` so
|
|
37
|
+
// the pointer is already null when the socket's 'connected' edge fires. Left
|
|
38
|
+
// OFF by default: EXIT (COO→chat) keeps the user's place; the caller decides
|
|
39
|
+
// per direction (#619 follow-up: COO ENTER passes resetConversation:true).
|
|
40
|
+
if (opts?.resetConversation)
|
|
41
|
+
s.setCurrentConversationId(null);
|
|
36
42
|
await client.startNewSession();
|
|
37
43
|
}, [client, store]);
|
|
38
44
|
return { ...state, reconnect, startNewSession };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-connection-state.js","sourceRoot":"","sources":["../../src/hooks/use-connection-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"use-connection-state.js","sourceRoot":"","sources":["../../src/hooks/use-connection-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAa7D,MAAM,UAAU,kBAAkB;IAoChC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,QAAQ,CACpB,KAAK,EACL,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACjB,eAAe,EAAE,CAAC,CAAC,eAAe;QAClC,YAAY,EAAE,CAAC,CAAC,YAAY;QAC5B,KAAK,EAAE,CAAC,CAAC,eAAe;QACxB,gBAAgB,EAAE,CAAC,CAAC,gBAAgB;KACrC,CAAC,CAAC,CACJ,CAAC;IACF,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE;QACjC,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACb,MAAM,eAAe,GAAG,WAAW,CACjC,KAAK,EAAE,IAA6B,EAAE,EAAE;QACtC,6EAA6E;QAC7E,6EAA6E;QAC7E,2EAA2E;QAC3E,2EAA2E;QAC3E,gFAAgF;QAChF,+EAA+E;QAC/E,mEAAmE;QACnE,gBAAgB;QAChB,EAAE;QACF,sEAAsE;QACtE,sEAAsE;QACtE,MAAM,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC3B,CAAC,CAAC,4BAA4B,EAAE,CAAC;QACjC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,+EAA+E;QAC/E,6EAA6E;QAC7E,6EAA6E;QAC7E,+EAA+E;QAC/E,6EAA6E;QAC7E,6EAA6E;QAC7E,6EAA6E;QAC7E,2EAA2E;QAC3E,IAAI,IAAI,EAAE,iBAAiB;YAAE,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QAC9D,MAAM,MAAM,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,EACD,CAAC,MAAM,EAAE,KAAK,CAAC,CAChB,CAAC;IACF,OAAO,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AAClD,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.24.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED