@yanlinglabs/winter-agent-sdk 0.0.8 → 0.0.10

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.
@@ -236,6 +236,19 @@ function acquireLease(lockPath) {
236
236
  writeLeaseInfoReplacing(lockPath, fresh);
237
237
  return fresh;
238
238
  }
239
+ function releaseLease(lockPath) {
240
+ const existing = readLeaseInfo(lockPath);
241
+ if (existing === null || existing.pid !== process.pid)
242
+ return false;
243
+ try {
244
+ unlinkSync(lockPath);
245
+ } catch (err) {
246
+ if (err.code === "ENOENT")
247
+ return false;
248
+ throw err;
249
+ }
250
+ return true;
251
+ }
239
252
 
240
253
  // src/store/session-store.ts
241
254
  import {
@@ -702,6 +715,10 @@ class WinterCompatibilitySessionStore2 {
702
715
  acquireLease(lockPath);
703
716
  chmodSync(lockPath, 384);
704
717
  }
718
+ async releaseSessionLease(key) {
719
+ const lockPath = `${sessionStem(this.winterHome, key.projectKey, key.sessionId)}.lock`;
720
+ return releaseLease(lockPath);
721
+ }
705
722
  }
706
723
 
707
724
  export { BRAND_TOKEN_RE2, FIRST_PARTY_ORIGINATORS2, WINTER_BRAND2, resolveBrand2, envName2, mcpToolName2, userAgent2, isUnset2, resolveWinterHome2, resolveKeychainServiceForProfile2, WinterStoreError2, WinterStoreLeaseError2, DIALECT_RECORD_ENTRY_TYPE2, PROVIDER_STATE_FILE_SUFFIX2, WinterCompatibilitySessionStore2 };
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  DIALECT_RECORD_ENTRY_TYPE2,
15
15
  PROVIDER_STATE_FILE_SUFFIX2,
16
16
  WinterCompatibilitySessionStore2
17
- } from "./index-9e98bg1r.js";
17
+ } from "./index-qst9rwbb.js";
18
18
  import {
19
19
  deliveryUncertain2,
20
20
  refused2,
@@ -961,7 +961,7 @@ function query(args) {
961
961
  return gen;
962
962
  }
963
963
  // src/version.ts
964
- var SDK_VERSION = "0.0.8";
964
+ var SDK_VERSION = "0.0.10";
965
965
  // src/paths/project-key.ts
966
966
  var TRANSCRIPT_PROJECT_KEY_MAX_LENGTH = 64;
967
967
  var VENDOR_PROJECT_KEY_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
@@ -13,3 +13,15 @@ export declare function isPidAlive(pid: number): boolean;
13
13
  export declare function writeAllSync(fd: number, buf: Buffer): void;
14
14
  export declare function readLeaseInfo(lockPath: string): LeaseInfo | null;
15
15
  export declare function acquireLease(lockPath: string): LeaseInfo;
16
+ /**
17
+ * Releases the lease at `lockPath` -- but ONLY when THIS process currently holds it. Returns `true`
18
+ * when it did (and the lock file is now gone), `false` for every other case: no lease file at all,
19
+ * an unparseable one, or one a genuinely different pid holds. Idempotent -- a second call after a
20
+ * successful release finds nothing to release and returns `false`, never throws.
21
+ *
22
+ * Deliberately NOT "release whatever is there": a caller that raced with someone else's fresh
23
+ * acquire (this pid died and was stolen from, however unlikely between two calls in the same
24
+ * process) must never delete the NEW holder's lease out from under it. The pid check is the whole
25
+ * safety property.
26
+ */
27
+ export declare function releaseLease(lockPath: string): boolean;
@@ -108,4 +108,27 @@ export declare class WinterCompatibilitySessionStore implements SessionStore {
108
108
  projectKey: string;
109
109
  sessionId: string;
110
110
  }): Promise<void>;
111
+ /**
112
+ * Phase 10b Lane S, S8 (W18-5): releases the writer lease `acquireSessionLease`/`append`'s own
113
+ * opening sequence took, but ONLY when THIS pid holds it -- `leases.ts`'s own `releaseLease` is
114
+ * the entire safety property, reproduced here just for the routing: same-pid, idempotent, never
115
+ * another pid's lease. The router calls this for a WINTER destination, after its own write-ahead
116
+ * producer record lands and BEFORE `confirmInit` -- so the daemon's pid writes NOTHING to the
117
+ * canonical transcript once the winter child holds the lease (W18-5's own ordering constraint).
118
+ *
119
+ * Deliberately NOT part of the exported `SessionStore` type (same posture as
120
+ * `acquireSessionLease` immediately above) -- lives only on this concrete class.
121
+ *
122
+ * Fix round 1 (reviewer #2, minor): the OTHER half of `append`'s own load-bearing invariant
123
+ * (see that method's own header comment). This method's body is synchronous too (`releaseLease`
124
+ * is a single plain fs call, no `await`), so a `releaseSessionLease` call and a same-process
125
+ * `append` call can never interleave mid-way -- whichever one the event loop runs next, it runs
126
+ * to completion before the other can start. That is what makes "release between two appends"
127
+ * safe without any lock object anywhere in this class: JS's run-to-completion is the lock, for as
128
+ * long as neither method's synchronous stretch grows an `await`.
129
+ */
130
+ releaseSessionLease(key: {
131
+ projectKey: string;
132
+ sessionId: string;
133
+ }): Promise<boolean>;
111
134
  }
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  resolveWinterHome2,
10
10
  WinterCompatibilitySessionStore2
11
- } from "../index-9e98bg1r.js";
11
+ } from "../index-qst9rwbb.js";
12
12
 
13
13
  // src/tools/schemas.ts
14
14
  var SEND_MESSAGE_TO_MAX = 300;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yanlinglabs/winter-agent-sdk",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -45,15 +45,15 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@yanlinglabs/winter-provider-catalog": "0.0.8"
48
+ "@yanlinglabs/winter-provider-catalog": "0.0.10"
49
49
  },
50
50
  "optionalDependencies": {
51
- "@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.8"
51
+ "@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.10"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "^26.4.0",
55
- "@yanlinglabs/winter-conformance": "0.0.8",
56
- "winter-agent-runtime": "0.0.8"
55
+ "@yanlinglabs/winter-conformance": "0.0.10",
56
+ "winter-agent-runtime": "0.0.10"
57
57
  },
58
58
  "scripts": {}
59
59
  }