@astrosheep/square 0.3.52 → 0.3.54

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,6 +1,6 @@
1
1
  {
2
2
  "name": "square",
3
- "version": "0.3.52",
3
+ "version": "0.3.54",
4
4
  "description": "Native Claude Code turn-boundary delivery for Square participants",
5
5
  "author": {
6
6
  "name": "Square"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "square",
3
- "version": "0.3.52",
3
+ "version": "0.3.54",
4
4
  "description": "Shared Square activity with reliable participant attention at Codex boundaries.",
5
5
  "author": {
6
6
  "name": "Square"
@@ -1,9 +1,9 @@
1
1
  import { cmdActivity } from '../activity.js';
2
2
  import { formatActivityId, formatHardCap, parseActivityId, } from '../model.js';
3
3
  import { participantCommandPrefix, participantIdentity, quoteShell, renderEventCli, renderAmbientEvent, withPathOutput, } from '../presentation.js';
4
- import { claimSessionParticipant, hasAutomaticDeliveryIdentity, lookupParticipant, recordSessionDone, } from '../registry.js';
4
+ import { claimSessionParticipant, hasAutomaticDeliveryIdentity, localSessionIdentities, lookupParticipant, readParticipantOwner, recordSessionDone, } from '../registry.js';
5
5
  import { createHostLedgerPort } from '../host-ledger-file-adapter.js';
6
- import { projectLocalParticipantBinding, sessionIdsFromEnvironment } from '../square-projections.js';
6
+ import { sessionIdsFromEnvironment } from '../square-projections.js';
7
7
  import { nowMs } from '../runtime.js';
8
8
  import { createSquare, openSquare } from '../square-file-adapter.js';
9
9
  import { closeOpenSquare } from '../open-square.js';
@@ -90,13 +90,9 @@ export const joinCommand = {
90
90
  const hostLedger = createHostLedgerPort();
91
91
  const square = await Square.at({ path: squarePath, clock: nowMs, hostLedger, wakeTransport: await createDefaultWakeTransport(hostLedger, nowMs) });
92
92
  try {
93
- const reconnect = before.joined
94
- && await projectLocalParticipantBinding({
95
- hostLedger: createHostLedgerPort(),
96
- location: squarePath,
97
- participant: intent.name,
98
- sessionIds: sessionIdsFromEnvironment(),
99
- }) !== undefined;
93
+ const identity = localSessionIdentities()[0];
94
+ const owner = before.joined ? await readParticipantOwner(squarePath, intent.name) : undefined;
95
+ const reconnect = before.joined && identity !== undefined && owner?.sessionId === identity.sessionId;
100
96
  const isRejoin = before.joined;
101
97
  if (isRejoin && !intent.kick && !reconnect) {
102
98
  fail([
@@ -106,7 +102,7 @@ export const joinCommand = {
106
102
  `» ${participantCommandPrefix(squarePath, intent.name)} join --kick`,
107
103
  ].join('\n'));
108
104
  }
109
- const takeoverNeeded = isRejoin && intent.kick && !reconnect;
105
+ const takeoverNeeded = isRejoin && intent.kick;
110
106
  const oldBindings = takeoverNeeded ? await lookupParticipant(squarePath, intent.name) : [];
111
107
  let participant;
112
108
  if (takeoverNeeded) {
@@ -28,6 +28,9 @@ export async function catchUp(square, name, options = {}, project) {
28
28
  throw new SquareError('invalid_args', 'Catch idle duration must be a non-negative number');
29
29
  const deadline = Date.now() + idle;
30
30
  while (true) {
31
+ if (!await assertLiveOwner(square, name)) {
32
+ throw new SquareError('already_joined', `${participantIdentity(name)} is already bound to another session`);
33
+ }
31
34
  const attempt = await square.artifact.transact((state, version) => {
32
35
  const decision = decideCatch(state, name, options, square.clock(), project);
33
36
  return { ...(decision.changed ? { state } : {}), result: { version, decision } };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrosheep/square",
3
- "version": "0.3.52",
3
+ "version": "0.3.54",
4
4
  "description": "A shared public square where agents join, catch activity, express, and step out when done.",
5
5
  "type": "module",
6
6
  "bin": {