@steventsao/agent-session-core 0.1.1 → 0.1.2
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.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/session-config.d.ts +55 -0
- package/dist/session-config.d.ts.map +1 -0
- package/dist/session-config.js +35 -0
- package/dist/session-config.js.map +1 -0
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Refresh Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines how the client should behave when the sessionId changes.
|
|
5
|
+
* This is critical for document isolation in multi-document applications.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Refresh strategies for session changes
|
|
9
|
+
*
|
|
10
|
+
* - 'reset': Clear all client state and connect fresh (recommended for document isolation)
|
|
11
|
+
* - 'preserve': Attempt to reconnect to existing sandbox (for tab persistence scenarios)
|
|
12
|
+
*/
|
|
13
|
+
export type SessionRefreshStrategy = 'reset' | 'preserve';
|
|
14
|
+
export interface SessionRefreshConfig {
|
|
15
|
+
/**
|
|
16
|
+
* What to do when sessionId changes:
|
|
17
|
+
*
|
|
18
|
+
* 'reset' (default, recommended):
|
|
19
|
+
* - Clear sandboxId, sandboxUrl, messages, agentSessionId
|
|
20
|
+
* - Disconnect from old socket
|
|
21
|
+
* - Connect to new session with clean slate
|
|
22
|
+
* - Use this when sessionId represents a document UUID
|
|
23
|
+
*
|
|
24
|
+
* 'preserve':
|
|
25
|
+
* - Keep existing state during reconnection
|
|
26
|
+
* - Useful for browser tab persistence where same user returns
|
|
27
|
+
* - NOT recommended when switching between documents
|
|
28
|
+
*/
|
|
29
|
+
onSessionChange: SessionRefreshStrategy;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to clear chat messages when session changes (only applies to 'reset' strategy)
|
|
32
|
+
* Default: true
|
|
33
|
+
*/
|
|
34
|
+
clearMessagesOnReset?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to clear agent session ID when session changes (only applies to 'reset' strategy)
|
|
37
|
+
* Default: true
|
|
38
|
+
*/
|
|
39
|
+
clearAgentSessionOnReset?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Default configuration - full reset on session change
|
|
43
|
+
* This is the safest option for document isolation
|
|
44
|
+
*/
|
|
45
|
+
export declare const DEFAULT_SESSION_REFRESH_CONFIG: SessionRefreshConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Preserve configuration - for tab persistence scenarios
|
|
48
|
+
* Use with caution - only when you know the user is returning to the same document
|
|
49
|
+
*/
|
|
50
|
+
export declare const PRESERVE_SESSION_CONFIG: SessionRefreshConfig;
|
|
51
|
+
/**
|
|
52
|
+
* Helper to determine if state should be reset based on config
|
|
53
|
+
*/
|
|
54
|
+
export declare function shouldResetOnSessionChange(config: SessionRefreshConfig, oldSessionId: string | null, newSessionId: string | null): boolean;
|
|
55
|
+
//# sourceMappingURL=session-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-config.d.ts","sourceRoot":"","sources":["../src/session-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,UAAU,CAAC;AAE1D,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;;;;;;OAaG;IACH,eAAe,EAAE,sBAAsB,CAAC;IAExC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED;;;GAGG;AACH,eAAO,MAAM,8BAA8B,EAAE,oBAI5C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,oBAIrC,CAAC;AAEF;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,oBAAoB,EAC5B,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,GAC1B,OAAO,CAOT"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Refresh Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines how the client should behave when the sessionId changes.
|
|
5
|
+
* This is critical for document isolation in multi-document applications.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default configuration - full reset on session change
|
|
9
|
+
* This is the safest option for document isolation
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_SESSION_REFRESH_CONFIG = {
|
|
12
|
+
onSessionChange: 'reset',
|
|
13
|
+
clearMessagesOnReset: true,
|
|
14
|
+
clearAgentSessionOnReset: true,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Preserve configuration - for tab persistence scenarios
|
|
18
|
+
* Use with caution - only when you know the user is returning to the same document
|
|
19
|
+
*/
|
|
20
|
+
export const PRESERVE_SESSION_CONFIG = {
|
|
21
|
+
onSessionChange: 'preserve',
|
|
22
|
+
clearMessagesOnReset: false,
|
|
23
|
+
clearAgentSessionOnReset: false,
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Helper to determine if state should be reset based on config
|
|
27
|
+
*/
|
|
28
|
+
export function shouldResetOnSessionChange(config, oldSessionId, newSessionId) {
|
|
29
|
+
if (config.onSessionChange === 'preserve') {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
// Reset if sessions are different
|
|
33
|
+
return oldSessionId !== newSessionId && oldSessionId !== null && newSessionId !== null;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=session-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-config.js","sourceRoot":"","sources":["../src/session-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwCH;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAyB;IAClE,eAAe,EAAE,OAAO;IACxB,oBAAoB,EAAE,IAAI;IAC1B,wBAAwB,EAAE,IAAI;CAC/B,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAyB;IAC3D,eAAe,EAAE,UAAU;IAC3B,oBAAoB,EAAE,KAAK;IAC3B,wBAAwB,EAAE,KAAK;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAA4B,EAC5B,YAA2B,EAC3B,YAA2B;IAE3B,IAAI,MAAM,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,kCAAkC;IAClC,OAAO,YAAY,KAAK,YAAY,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,IAAI,CAAC;AACzF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steventsao/agent-session-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Shared types and protocol for agent-session",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
-
"files": [
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
15
17
|
"scripts": {
|
|
16
18
|
"build": "tsc",
|
|
17
19
|
"dev": "tsc --watch"
|