@ziggy-ai/client-sdk 1.1.26 → 1.1.27

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 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAkB,MAAM,YAAY,CAAC;AACpF,OAAO,KAAK,EACV,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAQ7B,qBAAa,cAAc;IACzB,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,UAAU,CAA+C;IACjE,OAAO,CAAC,SAAS,CAAC,CAA0C;IAC5D,OAAO,CAAC,QAAQ,CAAgC;gBAEpC,cAAc,EAAE,cAAc;IAI1C,qCAAqC;IACrC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,GAAG,IAAI;IAShF;;;OAGG;IACH,qBAAqB,IAAI,IAAI;IAQ7B,oDAAoD;IACpD,IAAI,IAAI,IAAI;IAWZ;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAU9C;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAInC,kFAAkF;IAClF,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAQtF,iBAAiB,CAAC,OAAO,EAAE,MAAM,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IAQ7B,oDAAoD;IACpD,IAAI,IAAI,IAAI;IAWZ;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAU9C;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAInC,kFAAkF;IAClF,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAQtF,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIxE,qBAAqB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI3D,2EAA2E;IAC3E,uBAAuB,CAAC,IAAI,CAAC,EAAE,qBAAqB,GAAG,IAAI;IAI3D,kBAAkB,CAAC,IAAI,CAAC,EAAE,qBAAqB,GAAG,IAAI;IAItD;;;OAGG;IACH,wBAAwB,CAAC,WAAW,EAAE,wBAAwB,GAAG,IAAI;IAMrE;;;OAGG;IACG,KAAK,CAAC,IAAI,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAwC/D"}
package/dist/index.js CHANGED
@@ -165,6 +165,7 @@ var SessionManager = class {
165
165
  persistence;
166
166
  _sessionId = null;
167
167
  _conversationId = null;
168
+ _userId = null;
168
169
  constructor(connection, config) {
169
170
  this.connection = connection;
170
171
  this.appId = config.appId;
@@ -219,6 +220,7 @@ var SessionManager = class {
219
220
  }
220
221
  this._sessionId = response.sessionId;
221
222
  this._conversationId = response.conversationId;
223
+ this._userId = request.userId;
222
224
  if (this.persistence) {
223
225
  this.persistence.set(persistenceKey(this.appId, request.userId, "conversationId"), response.conversationId);
224
226
  this.persistence.set(persistenceKey(this.appId, request.userId, "sessionId"), response.sessionId);
@@ -238,6 +240,17 @@ var SessionManager = class {
238
240
  }
239
241
  return response;
240
242
  }
243
+ /**
244
+ * The server no longer knows this session (404). Forget it locally so the
245
+ * next `create()` starts a new one; the conversation id is kept so the
246
+ * thread resumes.
247
+ */
248
+ sessionLost() {
249
+ if (this.persistence && this._userId) {
250
+ this.persistence.remove(persistenceKey(this.appId, this._userId, "sessionId"));
251
+ }
252
+ this._sessionId = null;
253
+ }
241
254
  /**
242
255
  * Push context update (delta merge) with piggybacked trigger evaluation.
243
256
  */
@@ -731,7 +744,12 @@ var ContextManager = class {
731
744
  if (response.trigger && this.onTrigger) {
732
745
  this.onTrigger(response);
733
746
  }
734
- } catch {
747
+ } catch (err) {
748
+ if (err && typeof err === "object" && "status" in err && err.status === 404) {
749
+ this.stop();
750
+ this.sessionManager.sessionLost();
751
+ throw err;
752
+ }
735
753
  this.pendingContext = { ...context, ...this.pendingContext };
736
754
  this.pendingEvents = [...events, ...this.pendingEvents];
737
755
  }
package/dist/session.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare class SessionManager {
9
9
  private persistence;
10
10
  private _sessionId;
11
11
  private _conversationId;
12
+ private _userId;
12
13
  constructor(connection: Connection, config: ZiggyClientConfig);
13
14
  get sessionId(): string | null;
14
15
  get conversationId(): string | null;
@@ -22,6 +23,12 @@ export declare class SessionManager {
22
23
  * as `response.messages` + sets `response.restored = true`.
23
24
  */
24
25
  create(request: CreateSessionRequest): Promise<SessionResponse>;
26
+ /**
27
+ * The server no longer knows this session (404). Forget it locally so the
28
+ * next `create()` starts a new one; the conversation id is kept so the
29
+ * thread resumes.
30
+ */
31
+ sessionLost(): void;
25
32
  /**
26
33
  * Push context update (delta merge) with piggybacked trigger evaluation.
27
34
  */
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,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AU,CAAuB;IACzC,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,OAAO,CAAuB;gBAE1B,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB;IAM7D,IAAI,SAAS,IAAI,MAAM,GAAG,IAAI,CAE7B;IAED,IAAI,cAAc,IAAI,MAAM,GAAG,IAAI,CAElC;IAED;;;;;;;;OAQG;IACG,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;IAmErE;;;;OAIG;IACH,WAAW,IAAI,IAAI;IAOnB;;OAEG;IACG,WAAW,CACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EACrC,IAAI,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,GACjC,OAAO,CAAC,mBAAmB,CAAC;IAkB/B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAO/B"}
package/package.json CHANGED
@@ -1,48 +1,48 @@
1
- {
2
- "name": "@ziggy-ai/client-sdk",
3
- "version": "1.1.26",
4
- "description": "Client SDK for integrating with Ziggy's v1 API",
5
- "type": "module",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
12
- },
13
- "./styles": "./dist/styles/ziggy-highlights.css"
14
- },
15
- "files": [
16
- "dist",
17
- "README.md",
18
- "LICENSE"
19
- ],
20
- "scripts": {
21
- "build": "tsup src/index.ts --format esm --clean --external driver.js --external html2canvas && tsc --emitDeclarationOnly && node -e \"const fs=require('fs');fs.mkdirSync('dist/styles',{recursive:true});fs.copyFileSync('src/styles/ziggy-highlights.css','dist/styles/ziggy-highlights.css')\"",
22
- "dev": "tsup src/index.ts --format esm --watch",
23
- "typecheck": "tsc --noEmit",
24
- "test": "vitest",
25
- "prepublishOnly": "npm run build"
26
- },
27
- "devDependencies": {
28
- "@types/node": "^20.11.0",
29
- "tsup": "^8.0.0",
30
- "typescript": "^5.3.3",
31
- "vitest": "^1.2.2"
32
- },
33
- "keywords": [
34
- "ziggy",
35
- "client",
36
- "sdk",
37
- "chat",
38
- "streaming",
39
- "ndjson"
40
- ],
41
- "license": "MIT",
42
- "repository": {
43
- "type": "git",
44
- "url": "https://github.com/alchemyagentic/Ziggy.git",
45
- "directory": "packages/client-sdk"
46
- },
47
- "dependencies": {}
48
- }
1
+ {
2
+ "name": "@ziggy-ai/client-sdk",
3
+ "version": "1.1.27",
4
+ "description": "Client SDK for integrating with Ziggy's v1 API",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./styles": "./dist/styles/ziggy-highlights.css"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsup src/index.ts --format esm --clean --external driver.js --external html2canvas && tsc --emitDeclarationOnly && node -e \"const fs=require('fs');fs.mkdirSync('dist/styles',{recursive:true});fs.copyFileSync('src/styles/ziggy-highlights.css','dist/styles/ziggy-highlights.css')\"",
22
+ "dev": "tsup src/index.ts --format esm --watch",
23
+ "typecheck": "tsc --noEmit",
24
+ "test": "vitest",
25
+ "prepublishOnly": "npm run build"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^20.11.0",
29
+ "tsup": "^8.0.0",
30
+ "typescript": "^5.3.3",
31
+ "vitest": "^1.2.2"
32
+ },
33
+ "keywords": [
34
+ "ziggy",
35
+ "client",
36
+ "sdk",
37
+ "chat",
38
+ "streaming",
39
+ "ndjson"
40
+ ],
41
+ "license": "MIT",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/alchemyagentic/Ziggy.git",
45
+ "directory": "packages/client-sdk"
46
+ },
47
+ "dependencies": {}
48
+ }