@teamvibe/poller 0.1.8 → 0.1.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.
@@ -106,26 +106,33 @@ export async function acquireSessionLock(threadId, workspacePath) {
106
106
  // Session is idle/waiting - try to acquire lock
107
107
  const newLockToken = generateLockToken();
108
108
  const now = Date.now();
109
+ const hasOldToken = existingSession.lock_token != null;
110
+ const conditionExpression = hasOldToken
111
+ ? '#status IN (:idle, :waiting) AND (lock_token = :oldToken OR attribute_not_exists(lock_token))'
112
+ : '#status IN (:idle, :waiting) AND attribute_not_exists(lock_token)';
113
+ const expressionValues = {
114
+ ':processing': 'processing',
115
+ ':idle': 'idle',
116
+ ':waiting': 'waiting_for_input',
117
+ ':newToken': newLockToken,
118
+ ':now': now,
119
+ ':one': 1,
120
+ ':ttl': calculateTTL(),
121
+ };
122
+ if (hasOldToken) {
123
+ expressionValues[':oldToken'] = existingSession.lock_token;
124
+ }
109
125
  try {
110
126
  await createDocClient().send(new UpdateCommand({
111
127
  TableName: getTableName(),
112
128
  Key: buildKey(threadId),
113
129
  UpdateExpression: 'SET #status = :processing, lock_token = :newToken, last_activity = :now, message_count = message_count + :one, #ttl = :ttl',
114
- ConditionExpression: '#status IN (:idle, :waiting) AND (lock_token = :oldToken OR attribute_not_exists(lock_token))',
130
+ ConditionExpression: conditionExpression,
115
131
  ExpressionAttributeNames: {
116
132
  '#status': 'status',
117
133
  '#ttl': 'ttl',
118
134
  },
119
- ExpressionAttributeValues: {
120
- ':processing': 'processing',
121
- ':idle': 'idle',
122
- ':waiting': 'waiting_for_input',
123
- ':newToken': newLockToken,
124
- ':oldToken': existingSession.lock_token,
125
- ':now': now,
126
- ':one': 1,
127
- ':ttl': calculateTTL(),
128
- },
135
+ ExpressionAttributeValues: expressionValues,
129
136
  }));
130
137
  const updatedSession = {
131
138
  ...existingSession,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamvibe/poller",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {
@@ -13,7 +13,8 @@
13
13
  "dev": "tsx watch src/index.ts",
14
14
  "build": "tsc -p tsconfig.build.json",
15
15
  "start": "node dist/index.js",
16
- "typecheck": "tsc --noEmit"
16
+ "typecheck": "tsc --noEmit",
17
+ "publish:npm": "bun run build && NPM_TOKEN=$(grep NPM_TOKEN ../../.env | cut -d= -f2) && npm publish --access public --registry https://registry.npmjs.org/ --//registry.npmjs.org/:_authToken=$NPM_TOKEN"
17
18
  },
18
19
  "publishConfig": {
19
20
  "access": "public"