commonswarm 0.1.76 → 0.1.77

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.
Files changed (2) hide show
  1. package/cswarm.cjs +272 -194
  2. package/package.json +1 -1
package/cswarm.cjs CHANGED
@@ -65,6 +65,51 @@ var init_signal_duration = __esm({
65
65
  }
66
66
  });
67
67
 
68
+ // src/cloud/config.ts
69
+ function cloudTarget(url, anonKey) {
70
+ if (!url.trim()) {
71
+ throw new Error(
72
+ /* Not "who invited you" — self-serve signup is live and that reader has no inviter.
73
+ * See D-067 and the matching wording in current-target.ts. */
74
+ "--url is required: the service we run is https://api.commonswarm.com. A deployment uses its own base URL. Or start with cswarm accept --link-stdin because invite links carry the Cloud target; scripts and CI may pass --url and --anon-key or set SWARM_CLOUD_URL and SWARM_CLOUD_ANON_KEY."
75
+ );
76
+ }
77
+ const parsed = new URL(url);
78
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
79
+ throw new Error("--url must use http or https");
80
+ }
81
+ if (parsed.username || parsed.password || parsed.search || parsed.hash) {
82
+ throw new Error("--url must not contain credentials, a query, or a fragment");
83
+ }
84
+ if (parsed.pathname !== "/" && parsed.pathname !== "") {
85
+ throw new Error("--url must be the service base URL, with no path");
86
+ }
87
+ if (!anonKey.trim()) throw new Error("--anon-key is required");
88
+ const normalized = parsed.origin;
89
+ return {
90
+ url: normalized,
91
+ anonKey: anonKey.trim(),
92
+ profileId: (0, import_node_crypto.createHash)("sha256").update(normalized).digest("hex").slice(0, 24)
93
+ };
94
+ }
95
+ function commandEndpoint(target2) {
96
+ return `${target2.url}/functions/v1/command`;
97
+ }
98
+ function readEndpoint(target2) {
99
+ return `${target2.url}/functions/v1/read`;
100
+ }
101
+ function authStorageKey(target2) {
102
+ return `cswarm-${target2.profileId}-auth`;
103
+ }
104
+ var import_node_crypto, CLIENT_PROTOCOL_VERSION;
105
+ var init_config = __esm({
106
+ "src/cloud/config.ts"() {
107
+ "use strict";
108
+ import_node_crypto = require("node:crypto");
109
+ CLIENT_PROTOCOL_VERSION = "0.1.0";
110
+ }
111
+ });
112
+
68
113
  // src/cloud/signal-limits.ts
69
114
  var SIGNAL_BODY_MAX, SIGNAL_ABOUT_MAX, SIGNAL_RECIPIENT_MAX;
70
115
  var init_signal_limits = __esm({
@@ -133,51 +178,6 @@ var init_agent_onboarding_contract = __esm({
133
178
  }
134
179
  });
135
180
 
136
- // src/cloud/config.ts
137
- function cloudTarget(url, anonKey) {
138
- if (!url.trim()) {
139
- throw new Error(
140
- /* Not "who invited you" — self-serve signup is live and that reader has no inviter.
141
- * See D-067 and the matching wording in current-target.ts. */
142
- "--url is required: the service we run is https://api.commonswarm.com. A deployment uses its own base URL. Or start with cswarm accept --link-stdin because invite links carry the Cloud target; scripts and CI may pass --url and --anon-key or set SWARM_CLOUD_URL and SWARM_CLOUD_ANON_KEY."
143
- );
144
- }
145
- const parsed = new URL(url);
146
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
147
- throw new Error("--url must use http or https");
148
- }
149
- if (parsed.username || parsed.password || parsed.search || parsed.hash) {
150
- throw new Error("--url must not contain credentials, a query, or a fragment");
151
- }
152
- if (parsed.pathname !== "/" && parsed.pathname !== "") {
153
- throw new Error("--url must be the service base URL, with no path");
154
- }
155
- if (!anonKey.trim()) throw new Error("--anon-key is required");
156
- const normalized = parsed.origin;
157
- return {
158
- url: normalized,
159
- anonKey: anonKey.trim(),
160
- profileId: (0, import_node_crypto.createHash)("sha256").update(normalized).digest("hex").slice(0, 24)
161
- };
162
- }
163
- function commandEndpoint(target2) {
164
- return `${target2.url}/functions/v1/command`;
165
- }
166
- function readEndpoint(target2) {
167
- return `${target2.url}/functions/v1/read`;
168
- }
169
- function authStorageKey(target2) {
170
- return `cswarm-${target2.profileId}-auth`;
171
- }
172
- var import_node_crypto, CLIENT_PROTOCOL_VERSION;
173
- var init_config = __esm({
174
- "src/cloud/config.ts"() {
175
- "use strict";
176
- import_node_crypto = require("node:crypto");
177
- CLIENT_PROTOCOL_VERSION = "0.1.0";
178
- }
179
- });
180
-
181
181
  // src/cloud/agent-credential-input.ts
182
182
  function sourceName(source) {
183
183
  return source.kind === "file" ? `agent credential file ${source.path}` : "agent credential input from stdin";
@@ -255,7 +255,7 @@ function parseAgentCredentialInput(value, source) {
255
255
  invalidKeys.push("status");
256
256
  }
257
257
  for (const key2 of ["principal_id", "token_id", "run_id"]) {
258
- if (Object.hasOwn(artifact, key2) && (typeof artifact[key2] !== "string" || !UUID_RE.test(artifact[key2]))) {
258
+ if (Object.hasOwn(artifact, key2) && (typeof artifact[key2] !== "string" || !UUID_RE2.test(artifact[key2]))) {
259
259
  invalidKeys.push(key2);
260
260
  }
261
261
  }
@@ -291,11 +291,11 @@ function parseAgentCredentialInput(value, source) {
291
291
  durable: true
292
292
  };
293
293
  }
294
- var UUID_RE, AGENT_TOKEN_RE, AGENT_CREDENTIAL_MESSAGE, AGENT_CREDENTIAL_MESSAGE_D088, ACCEPTED_AGENT_CREDENTIAL_MESSAGES, AgentCredentialInputError, AGENT_CREDENTIAL_REQUIRED_FIELDS, AGENT_CREDENTIAL_OPTIONAL_FIELDS, ALLOWED_ARTIFACT_KEYS;
294
+ var UUID_RE2, AGENT_TOKEN_RE, AGENT_CREDENTIAL_MESSAGE, AGENT_CREDENTIAL_MESSAGE_D088, ACCEPTED_AGENT_CREDENTIAL_MESSAGES, AgentCredentialInputError, AGENT_CREDENTIAL_REQUIRED_FIELDS, AGENT_CREDENTIAL_OPTIONAL_FIELDS, ALLOWED_ARTIFACT_KEYS;
295
295
  var init_agent_credential_input = __esm({
296
296
  "src/cloud/agent-credential-input.ts"() {
297
297
  "use strict";
298
- UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
298
+ UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
299
299
  AGENT_TOKEN_RE = /^swm_agt_[A-Za-z0-9_-]{43}$/;
300
300
  AGENT_CREDENTIAL_MESSAGE = "Agent credential minted. It is bound to this task and run so the agent's work stays scoped and attributable.";
301
301
  AGENT_CREDENTIAL_MESSAGE_D088 = "Agent credential minted. It is bound to this run, so the agent's work is attributable to it.";
@@ -412,7 +412,7 @@ function parseRecord(raw) {
412
412
  } catch {
413
413
  throw new Error("stored credential record is malformed");
414
414
  }
415
- if (value.version !== 1 || typeof value.refreshToken !== "string" || value.refreshToken.length < 8 || value.refreshToken.length > 2048 || /[|\u0000-\u001f\u007f]/.test(value.refreshToken) || !Number.isSafeInteger(value.generation) || (value.generation ?? -1) < 0 || typeof value.deviceId !== "string" || !UUID_RE2.test(value.deviceId) || typeof value.userId !== "string" || !UUID_RE2.test(value.userId)) {
415
+ if (value.version !== 1 || typeof value.refreshToken !== "string" || value.refreshToken.length < 8 || value.refreshToken.length > 2048 || /[|\u0000-\u001f\u007f]/.test(value.refreshToken) || !Number.isSafeInteger(value.generation) || (value.generation ?? -1) < 0 || typeof value.deviceId !== "string" || !UUID_RE3.test(value.deviceId) || typeof value.userId !== "string" || !UUID_RE3.test(value.userId)) {
416
416
  throw new Error("stored credential record is malformed");
417
417
  }
418
418
  return value;
@@ -452,7 +452,7 @@ function parseProfile(raw) {
452
452
  throw new Error("stored credential profile is malformed");
453
453
  }
454
454
  const pending = value.pendingCommands;
455
- if (value.version !== 1 || !(value.userId === null || typeof value.userId === "string" && UUID_RE2.test(value.userId)) || !(value.workspaceId === null || typeof value.workspaceId === "string" && UUID_RE2.test(value.workspaceId)) || !(value.email === void 0 || value.email === null || typeof value.email === "string" && value.email.length >= 3 && value.email.length <= 320 && !/[\u0000-\u001f\u007f-\u009f]/.test(value.email)) || !(value.principalId === void 0 || value.principalId === null || typeof value.principalId === "string" && UUID_RE2.test(value.principalId)) || !(value.principalName === void 0 || value.principalName === null || typeof value.principalName === "string" && value.principalName.length >= 1 && value.principalName.length <= 80 && /^[a-z0-9._@-]+$/.test(value.principalName)) || !pending || typeof pending !== "object" || Array.isArray(pending) || Object.keys(pending).length > MAX_PENDING_COMMANDS) {
455
+ if (value.version !== 1 || !(value.userId === null || typeof value.userId === "string" && UUID_RE3.test(value.userId)) || !(value.workspaceId === null || typeof value.workspaceId === "string" && UUID_RE3.test(value.workspaceId)) || !(value.email === void 0 || value.email === null || typeof value.email === "string" && value.email.length >= 3 && value.email.length <= 320 && !/[\u0000-\u001f\u007f-\u009f]/.test(value.email)) || !(value.principalId === void 0 || value.principalId === null || typeof value.principalId === "string" && UUID_RE3.test(value.principalId)) || !(value.principalName === void 0 || value.principalName === null || typeof value.principalName === "string" && value.principalName.length >= 1 && value.principalName.length <= 80 && /^[a-z0-9._@-]+$/.test(value.principalName)) || !pending || typeof pending !== "object" || Array.isArray(pending) || Object.keys(pending).length > MAX_PENDING_COMMANDS) {
456
456
  throw new Error("stored credential profile is malformed");
457
457
  }
458
458
  for (const [intentHash2, record3] of Object.entries(pending)) {
@@ -669,7 +669,7 @@ async function credentialStore(options) {
669
669
  return new SecureFileStore(stateDirectory2, options.target.profileId, warn);
670
670
  }
671
671
  async function agentSignalPendingStore(options) {
672
- if (!UUID_RE2.test(options.principalId)) {
672
+ if (!UUID_RE3.test(options.principalId)) {
673
673
  throw new Error("agent principal id must be a UUID");
674
674
  }
675
675
  const configured = options.stateDirectory ?? process.env.SWARM_AGENT_STATE_DIR ?? (process.env.XDG_STATE_HOME ? (0, import_node_path.join)(process.env.XDG_STATE_HOME, "cswarm", "agent-pending") : (0, import_node_path.join)((0, import_node_os.homedir)(), ".cswarm", "agent-state"));
@@ -686,7 +686,7 @@ async function agentSignalPendingStore(options) {
686
686
  });
687
687
  return store2;
688
688
  }
689
- var import_node_fs, import_promises, import_node_os, import_node_path, import_node_crypto2, import_node_child_process, import_promises2, KEYCHAIN_SERVICE, LOCK_STALE_MS, LOCK_TIMEOUT_MS, MAX_KEYCHAIN_RECORD_BYTES, MAX_PROFILE_BYTES, MAX_PENDING_COMMANDS, UUID_RE2, COMMAND_ID_RE, SHA256_RE, FALLBACK_WARNING, StoredRecordOversizedError, FileLockTimeoutError, heldFileLocks, heldFileLockExitHookInstalled, LockedCredentialStore, MacKeychainStore, SecureFileStore;
689
+ var import_node_fs, import_promises, import_node_os, import_node_path, import_node_crypto2, import_node_child_process, import_promises2, KEYCHAIN_SERVICE, LOCK_STALE_MS, LOCK_TIMEOUT_MS, MAX_KEYCHAIN_RECORD_BYTES, MAX_PROFILE_BYTES, MAX_PENDING_COMMANDS, UUID_RE3, COMMAND_ID_RE, SHA256_RE, FALLBACK_WARNING, StoredRecordOversizedError, FileLockTimeoutError, heldFileLocks, heldFileLockExitHookInstalled, LockedCredentialStore, MacKeychainStore, SecureFileStore;
690
690
  var init_storage = __esm({
691
691
  "src/cloud/storage.ts"() {
692
692
  "use strict";
@@ -703,7 +703,7 @@ var init_storage = __esm({
703
703
  MAX_KEYCHAIN_RECORD_BYTES = 126;
704
704
  MAX_PROFILE_BYTES = 64 * 1024;
705
705
  MAX_PENDING_COMMANDS = 32;
706
- UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
706
+ UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
707
707
  COMMAND_ID_RE = /^[A-Za-z0-9_-]{8,72}$/;
708
708
  SHA256_RE = /^[0-9a-f]{64}$/;
709
709
  FALLBACK_WARNING = "\u26A0 no OS keychain found. Storing the rotating refresh credential in a 0600 file under a 0700 directory. This is less protected than a keychain.";
@@ -863,9 +863,9 @@ function parseAgentCredentialRecord(raw) {
863
863
  } catch {
864
864
  throw new Error("stored agent credential record is malformed");
865
865
  }
866
- if (value.version !== 1 || !(value.token === null || typeof value.token === "string" && AGENT_TOKEN_RE2.test(value.token)) || !(value.tokenId === null || typeof value.tokenId === "string" && UUID_RE3.test(value.tokenId)) || !(value.principalId === null || typeof value.principalId === "string" && UUID_RE3.test(value.principalId)) || !(value.runId === null || typeof value.runId === "string" && UUID_RE3.test(value.runId)) || // A record naming a secret must name the token it belongs to, and vice versa; half of
866
+ if (value.version !== 1 || !(value.token === null || typeof value.token === "string" && AGENT_TOKEN_RE2.test(value.token)) || !(value.tokenId === null || typeof value.tokenId === "string" && UUID_RE4.test(value.tokenId)) || !(value.principalId === null || typeof value.principalId === "string" && UUID_RE4.test(value.principalId)) || !(value.runId === null || typeof value.runId === "string" && UUID_RE4.test(value.runId)) || // A record naming a secret must name the token it belongs to, and vice versa; half of
867
867
  // an identity is a record no reader can check the lineage of.
868
- value.token === null !== (value.tokenId === null) || !(value.rootTokenId === null || typeof value.rootTokenId === "string" && UUID_RE3.test(value.rootTokenId)) || !Number.isSafeInteger(value.generation) || (value.generation ?? -1) < 0 || !Number.isSafeInteger(value.issuedAt) || (value.issuedAt ?? -1) < 0 || !(value.expiresAt === null || Number.isSafeInteger(value.expiresAt) && (value.expiresAt ?? -1) >= 0) || // A live successor with no deadline could never be renewed on time.
868
+ value.token === null !== (value.tokenId === null) || !(value.rootTokenId === null || typeof value.rootTokenId === "string" && UUID_RE4.test(value.rootTokenId)) || !Number.isSafeInteger(value.generation) || (value.generation ?? -1) < 0 || !Number.isSafeInteger(value.issuedAt) || (value.issuedAt ?? -1) < 0 || !(value.expiresAt === null || Number.isSafeInteger(value.expiresAt) && (value.expiresAt ?? -1) >= 0) || // A live successor with no deadline could never be renewed on time.
869
869
  value.token !== null && value.expiresAt === null || !(value.horizonExpiresAt === null || Number.isSafeInteger(value.horizonExpiresAt) && (value.horizonExpiresAt ?? -1) >= 0) || !(value.successorsRemaining === null || Number.isSafeInteger(value.successorsRemaining) && (value.successorsRemaining ?? -1) >= 0) || !isPendingRenewal(value.pendingRenewal)) {
870
870
  throw new Error("stored agent credential record is malformed");
871
871
  }
@@ -907,7 +907,7 @@ async function agentCredentialStore(options) {
907
907
  }
908
908
  };
909
909
  }
910
- var import_node_crypto3, import_node_os2, import_node_path2, UUID_RE3, AGENT_TOKEN_RE2, MAX_RECORD_BYTES;
910
+ var import_node_crypto3, import_node_os2, import_node_path2, UUID_RE4, AGENT_TOKEN_RE2, MAX_RECORD_BYTES;
911
911
  var init_agent_credential = __esm({
912
912
  "src/cloud/agent-credential.ts"() {
913
913
  "use strict";
@@ -915,7 +915,7 @@ var init_agent_credential = __esm({
915
915
  import_node_os2 = require("node:os");
916
916
  import_node_path2 = require("node:path");
917
917
  init_storage();
918
- UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
918
+ UUID_RE4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
919
919
  AGENT_TOKEN_RE2 = /^swm_agt_[A-Za-z0-9_-]{43}$/;
920
920
  MAX_RECORD_BYTES = 4 * 1024;
921
921
  }
@@ -936,14 +936,14 @@ function nullableTimestamp(value, field) {
936
936
  }
937
937
  return text;
938
938
  }
939
- function uuid(value, field) {
940
- if (typeof value !== "string" || !UUID_RE4.test(value)) {
939
+ function uuid2(value, field) {
940
+ if (typeof value !== "string" || !UUID_RE5.test(value)) {
941
941
  throw new Error(`renewal grant read returned malformed ${field}`);
942
942
  }
943
943
  return value.toLowerCase();
944
944
  }
945
945
  function nullableUuid(value, field) {
946
- return value === null ? null : uuid(value, field);
946
+ return value === null ? null : uuid2(value, field);
947
947
  }
948
948
  function parseGrant(value) {
949
949
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -961,8 +961,8 @@ function parseGrant(value) {
961
961
  throw new Error("renewal grant read returned an invalid kind/horizon pair");
962
962
  }
963
963
  return {
964
- renewal_grant_id: uuid(row.renewal_grant_id, "renewal_grant_id"),
965
- principal_id: uuid(row.principal_id, "principal_id"),
964
+ renewal_grant_id: uuid2(row.renewal_grant_id, "renewal_grant_id"),
965
+ principal_id: uuid2(row.principal_id, "principal_id"),
966
966
  kind: row.kind,
967
967
  horizon_expires_at: horizon,
968
968
  bound_device_id: nullableUuid(row.bound_device_id, "bound_device_id"),
@@ -1037,12 +1037,12 @@ function describeRenewalGrant(grant) {
1037
1037
  }
1038
1038
  return lines;
1039
1039
  }
1040
- var UUID_RE4, STANDING_IDLE_PAUSE_DAYS, STANDING_RESUME_ACTORS, STANDING_RESUME_ACTORS_SENTENCE, STANDING_GRANT_RULES;
1040
+ var UUID_RE5, STANDING_IDLE_PAUSE_DAYS, STANDING_RESUME_ACTORS, STANDING_RESUME_ACTORS_SENTENCE, STANDING_GRANT_RULES;
1041
1041
  var init_renewal_grants = __esm({
1042
1042
  "src/cloud/renewal-grants.ts"() {
1043
1043
  "use strict";
1044
1044
  init_config();
1045
- UUID_RE4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
1045
+ UUID_RE5 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
1046
1046
  STANDING_IDLE_PAUSE_DAYS = 14;
1047
1047
  STANDING_RESUME_ACTORS = [
1048
1048
  "a workspace owner",
@@ -1207,10 +1207,10 @@ async function requestSuccessor(options) {
1207
1207
  throw new RenewalMalformedResponseError("renewal response was not valid JSON");
1208
1208
  }
1209
1209
  }
1210
- if (options.listenerMode && response.status !== 401 && response.status !== 403 && body2.principal_id !== void 0 && body2.principal_id !== null && (typeof body2.principal_id !== "string" || !UUID_RE5.test(body2.principal_id))) {
1210
+ if (options.listenerMode && response.status !== 401 && response.status !== 403 && body2.principal_id !== void 0 && body2.principal_id !== null && (typeof body2.principal_id !== "string" || !UUID_RE6.test(body2.principal_id))) {
1211
1211
  throw new RenewalMalformedResponseError("renewal response carried a malformed principal_id");
1212
1212
  }
1213
- const principalId = typeof body2.principal_id === "string" && UUID_RE5.test(body2.principal_id) ? body2.principal_id.toLowerCase() : null;
1213
+ const principalId = typeof body2.principal_id === "string" && UUID_RE6.test(body2.principal_id) ? body2.principal_id.toLowerCase() : null;
1214
1214
  if (response.status === 401 || response.status === 403) {
1215
1215
  if (options.listenerMode) {
1216
1216
  if (response.status === 401 && body2.error === "unauthenticated") {
@@ -1337,7 +1337,7 @@ async function requestSuccessor(options) {
1337
1337
  }
1338
1338
  const tokenId = typeof body2.token_id === "string" ? body2.token_id : "";
1339
1339
  const runId = typeof body2.run_id === "string" ? body2.run_id : "";
1340
- if (!UUID_RE5.test(tokenId) || !UUID_RE5.test(runId) || principalId === null) {
1340
+ if (!UUID_RE6.test(tokenId) || !UUID_RE6.test(runId) || principalId === null) {
1341
1341
  if (!options.listenerMode) throw new RenewalRefused(
1342
1342
  response.status,
1343
1343
  "incomplete_successor",
@@ -1409,7 +1409,7 @@ async function requestSuccessor(options) {
1409
1409
  ...wake === void 0 ? {} : { wake }
1410
1410
  };
1411
1411
  }
1412
- var import_node_crypto4, AGENT_TOKEN_DEFAULT_TTL_MS, AGENT_TOKEN_MAX_TTL_MS, RENEWAL_HORIZON_DEFAULT_MS, RENEWAL_HORIZON_MAX_MS, RENEWAL_LEAD_FRACTION, RENEWAL_LEAD_FLOOR_MS, RENEWAL_LEAD_CEILING_MS, RENEWAL_PENDING_RECOVERY_MS, RENEW_TIMEOUT_MS, UUID_RE5, AGENT_TOKEN_RE3, RenewalReauthorisationRequired, RenewalRevoked, RenewalSuspended, RenewalUnsupported, RenewalSuperseded, RenewalOutcomeUnknown, RenewalMalformedResponseError, RenewalCredentialCheckError, RenewalRetryError, RenewalRefused, RenewalUpgradeRequiredError, RENEWAL_UPGRADE_LISTENER_ACTION, RENEWAL_UPGRADE_COMMAND_ACTION, REVOCATION_REASONS_LIST, REVOCATION_REASONS, REVOKED_MESSAGE, LOCALLY_EXPIRED_MESSAGE, UNEXPLAINED_REFUSAL_MESSAGE, AgentCredentialSession;
1412
+ var import_node_crypto4, AGENT_TOKEN_DEFAULT_TTL_MS, AGENT_TOKEN_MAX_TTL_MS, RENEWAL_HORIZON_DEFAULT_MS, RENEWAL_HORIZON_MAX_MS, RENEWAL_LEAD_FRACTION, RENEWAL_LEAD_FLOOR_MS, RENEWAL_LEAD_CEILING_MS, RENEWAL_PENDING_RECOVERY_MS, RENEW_TIMEOUT_MS, UUID_RE6, AGENT_TOKEN_RE3, RenewalReauthorisationRequired, RenewalRevoked, RenewalSuspended, RenewalUnsupported, RenewalSuperseded, RenewalOutcomeUnknown, RenewalMalformedResponseError, RenewalCredentialCheckError, RenewalRetryError, RenewalRefused, RenewalUpgradeRequiredError, RENEWAL_UPGRADE_LISTENER_ACTION, RENEWAL_UPGRADE_COMMAND_ACTION, REVOCATION_REASONS_LIST, REVOCATION_REASONS, REVOKED_MESSAGE, LOCALLY_EXPIRED_MESSAGE, UNEXPLAINED_REFUSAL_MESSAGE, AgentCredentialSession;
1413
1413
  var init_renewal = __esm({
1414
1414
  "src/cloud/renewal.ts"() {
1415
1415
  "use strict";
@@ -1426,7 +1426,7 @@ var init_renewal = __esm({
1426
1426
  RENEWAL_LEAD_CEILING_MS = 15 * 6e4;
1427
1427
  RENEWAL_PENDING_RECOVERY_MS = 60 * 6e4;
1428
1428
  RENEW_TIMEOUT_MS = 3e4;
1429
- UUID_RE5 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
1429
+ UUID_RE6 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
1430
1430
  AGENT_TOKEN_RE3 = /^swm_agt_[A-Za-z0-9_-]{43}$/;
1431
1431
  RenewalReauthorisationRequired = class extends Error {
1432
1432
  constructor(reason, principalId, message) {
@@ -3575,7 +3575,7 @@ function parseSessionContext(raw) {
3575
3575
  const releasedAt = parseReleasedAt(row.released_at);
3576
3576
  const sessionKey = typeof row.session_key === "string" ? row.session_key : null;
3577
3577
  const keyOk = sessionKey !== null && (releasedAt !== null ? sessionKey === "" || isSessionKey(sessionKey) : isSessionKey(sessionKey));
3578
- if (row.version !== SESSION_CONTEXT_VERSION || typeof row.url !== "string" || !URL_RE.test(row.url) || typeof row.profile_id !== "string" || !/^[0-9a-f]{24}$/.test(row.profile_id) || typeof row.workspace_id !== "string" || !UUID_RE6.test(row.workspace_id) || typeof row.principal_id !== "string" || !UUID_RE6.test(row.principal_id) || typeof row.session_id !== "string" || !isSessionUuid(row.session_id) || typeof row.generation !== "number" || !Number.isSafeInteger(row.generation) || row.generation < 0 || sessionKey === null || !keyOk || provider === null || mode3 === null || typeof row.host_session_id !== "string" || row.host_session_id.length < 1 || row.host_session_id.length > 200 || typeof row.token_file !== "string" || !(0, import_node_path3.isAbsolute)(row.token_file) || typeof row.acquire_command_id !== "string" || !/^[A-Za-z0-9_-]{8,72}$/.test(row.acquire_command_id) || !(row.host_label === null || typeof row.host_label === "string" && row.host_label.length <= 120) || releasedAt === void 0) {
3578
+ if (row.version !== SESSION_CONTEXT_VERSION || typeof row.url !== "string" || !URL_RE.test(row.url) || typeof row.profile_id !== "string" || !/^[0-9a-f]{24}$/.test(row.profile_id) || typeof row.workspace_id !== "string" || !UUID_RE7.test(row.workspace_id) || typeof row.principal_id !== "string" || !UUID_RE7.test(row.principal_id) || typeof row.session_id !== "string" || !isSessionUuid(row.session_id) || typeof row.generation !== "number" || !Number.isSafeInteger(row.generation) || row.generation < 0 || sessionKey === null || !keyOk || provider === null || mode3 === null || typeof row.host_session_id !== "string" || row.host_session_id.length < 1 || row.host_session_id.length > 200 || typeof row.token_file !== "string" || !(0, import_node_path3.isAbsolute)(row.token_file) || typeof row.acquire_command_id !== "string" || !/^[A-Za-z0-9_-]{8,72}$/.test(row.acquire_command_id) || !(row.host_label === null || typeof row.host_label === "string" && row.host_label.length <= 120) || releasedAt === void 0) {
3579
3579
  throw new SessionContextError(
3580
3580
  "session_context_corrupt",
3581
3581
  "session context fields are malformed"
@@ -3937,7 +3937,7 @@ async function releaseSessionReceiverLockIfHeld(contextPath, pid = process.pid)
3937
3937
  if (existing === null || existing.pid !== pid) return;
3938
3938
  await (0, import_promises3.unlink)(lockPath).catch(() => void 0);
3939
3939
  }
3940
- var import_node_crypto7, import_promises3, import_node_os3, import_node_path3, UUID_RE6, MAX_CONTEXT_BYTES, URL_RE, SessionContextError, SESSION_ACQUIRE_BINDING_FIELDS, SESSION_RECEIVER_KINDS, RECEIVER_LOCK_MAX_BYTES;
3940
+ var import_node_crypto7, import_promises3, import_node_os3, import_node_path3, UUID_RE7, MAX_CONTEXT_BYTES, URL_RE, SessionContextError, SESSION_ACQUIRE_BINDING_FIELDS, SESSION_RECEIVER_KINDS, RECEIVER_LOCK_MAX_BYTES;
3941
3941
  var init_session_context = __esm({
3942
3942
  "src/cloud/session-context.ts"() {
3943
3943
  "use strict";
@@ -3949,7 +3949,7 @@ var init_session_context = __esm({
3949
3949
  init_session_contract();
3950
3950
  init_session_proof();
3951
3951
  init_command_client();
3952
- UUID_RE6 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
3952
+ UUID_RE7 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
3953
3953
  MAX_CONTEXT_BYTES = 16 * 1024;
3954
3954
  URL_RE = /^https?:\/\/[^/\s]+$/i;
3955
3955
  SessionContextError = class extends Error {
@@ -4462,7 +4462,7 @@ function validatedPayload(value) {
4462
4462
  throw new Error("invite link target is malformed");
4463
4463
  }
4464
4464
  cloudTarget(value.url, value.anon_key);
4465
- if (typeof value.workspace_id !== "string" || !UUID_RE7.test(value.workspace_id)) {
4465
+ if (typeof value.workspace_id !== "string" || !UUID_RE8.test(value.workspace_id)) {
4466
4466
  throw new Error("invite link workspace_id must be a UUID");
4467
4467
  }
4468
4468
  if (typeof value.invitation_token !== "string") {
@@ -4472,7 +4472,7 @@ function validatedPayload(value) {
4472
4472
  if (typeof value.workspace_name !== "string" || typeof value.inviter_display_name !== "string" || value.workspace_name.length > MAX_LABEL_INPUT_LENGTH || value.inviter_display_name.length > MAX_LABEL_INPUT_LENGTH) {
4473
4473
  throw new Error("invite link display labels are malformed");
4474
4474
  }
4475
- if (value.inviter_user_id !== void 0 && (typeof value.inviter_user_id !== "string" || !UUID_RE7.test(value.inviter_user_id))) {
4475
+ if (value.inviter_user_id !== void 0 && (typeof value.inviter_user_id !== "string" || !UUID_RE8.test(value.inviter_user_id))) {
4476
4476
  throw new Error("invite link inviter_user_id must be a UUID");
4477
4477
  }
4478
4478
  return value;
@@ -4605,7 +4605,7 @@ async function requirePinnedOrigin(target2, options) {
4605
4605
  throw new Error(`origin confirmation did not exactly match ${host}; refusing before login`);
4606
4606
  }
4607
4607
  }
4608
- var import_node_crypto9, MAX_LINK_PAYLOAD_BYTES, MAX_LABEL_INPUT_LENGTH, CONTROL_GLOBAL_RE, ANSI_ESCAPE_GLOBAL_RE, UUID_RE7, STRICT_BASE64URL_RE, RAW_BASE64_PAYLOAD_CANDIDATE_RE, CURRENT_INVITE_SCHEME, RETIRED_INVITE_SCHEME, INVITE_WRAPPER_ERROR, ACCEPT_INPUT_ERROR, RETIRED_CLOUD_ORIGIN, PRODUCTION_CLOUD_ORIGINS;
4608
+ var import_node_crypto9, MAX_LINK_PAYLOAD_BYTES, MAX_LABEL_INPUT_LENGTH, CONTROL_GLOBAL_RE, ANSI_ESCAPE_GLOBAL_RE, UUID_RE8, STRICT_BASE64URL_RE, RAW_BASE64_PAYLOAD_CANDIDATE_RE, CURRENT_INVITE_SCHEME, RETIRED_INVITE_SCHEME, INVITE_WRAPPER_ERROR, ACCEPT_INPUT_ERROR, RETIRED_CLOUD_ORIGIN, PRODUCTION_CLOUD_ORIGINS;
4609
4609
  var init_invite_link = __esm({
4610
4610
  "src/cloud/invite-link.ts"() {
4611
4611
  "use strict";
@@ -4616,7 +4616,7 @@ var init_invite_link = __esm({
4616
4616
  MAX_LABEL_INPUT_LENGTH = 1024;
4617
4617
  CONTROL_GLOBAL_RE = /[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g;
4618
4618
  ANSI_ESCAPE_GLOBAL_RE = /\u001b\[[0-?]*[ -/]*[@-~]/g;
4619
- UUID_RE7 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
4619
+ UUID_RE8 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
4620
4620
  STRICT_BASE64URL_RE = /^[A-Za-z0-9_-]+$/;
4621
4621
  RAW_BASE64_PAYLOAD_CANDIDATE_RE = /^[A-Za-z0-9+/_=-]+$/;
4622
4622
  CURRENT_INVITE_SCHEME = "cswarm://accept/";
@@ -4632,7 +4632,7 @@ var init_invite_link = __esm({
4632
4632
 
4633
4633
  // src/cloud/workspaces.ts
4634
4634
  function resolveWorkspaceMember(selector, members2) {
4635
- if (UUID_RE8.test(selector)) {
4635
+ if (UUID_RE9.test(selector)) {
4636
4636
  const selected = members2.find(
4637
4637
  (member) => member.user_id === selector.toLowerCase()
4638
4638
  );
@@ -4666,7 +4666,7 @@ function sortWorkspaces(workspaces) {
4666
4666
  );
4667
4667
  }
4668
4668
  function checkedUuid(value, field) {
4669
- if (typeof value !== "string" || !UUID_RE8.test(value)) {
4669
+ if (typeof value !== "string" || !UUID_RE9.test(value)) {
4670
4670
  throw new Error(`workspace read returned a malformed ${field}`);
4671
4671
  }
4672
4672
  return value.toLowerCase();
@@ -4985,13 +4985,13 @@ async function updateWorkspaceDefaultAfterClose(store2, userId, closedWorkspaceI
4985
4985
  }
4986
4986
  function workspaceOverride(explicit, environmental) {
4987
4987
  if (explicit !== void 0) {
4988
- if (!UUID_RE8.test(explicit)) {
4988
+ if (!UUID_RE9.test(explicit)) {
4989
4989
  throw new Error("--workspace-id must be a UUID");
4990
4990
  }
4991
4991
  return explicit.toLowerCase();
4992
4992
  }
4993
4993
  if (environmental) {
4994
- if (!UUID_RE8.test(environmental)) {
4994
+ if (!UUID_RE9.test(environmental)) {
4995
4995
  throw new Error("SWARM_CLOUD_WORKSPACE_ID must be a UUID");
4996
4996
  }
4997
4997
  return environmental.toLowerCase();
@@ -5051,7 +5051,7 @@ async function selectWorkspace(selector, workspaces, store2, userId) {
5051
5051
  function resolveWorkspaceSelector(selector, workspaces) {
5052
5052
  const sorted = sortWorkspaces(workspaces);
5053
5053
  let selected;
5054
- if (UUID_RE8.test(selector)) {
5054
+ if (UUID_RE9.test(selector)) {
5055
5055
  const normalized = selector.toLowerCase();
5056
5056
  selected = sorted.find(
5057
5057
  (workspace) => workspace.workspace_id === normalized
@@ -5160,13 +5160,13 @@ function renderStatus(options) {
5160
5160
  }
5161
5161
  return lines.join("\n");
5162
5162
  }
5163
- var UUID_RE8, ROLES, MemberSelectionError, DEFAULT_MEMBERSHIP_REVOKED, PROJECT_NOT_AVAILABLE, ARCHIVED_PROJECT_NOT_AVAILABLE, WorkspaceCliError, WorkspaceResolutionError, WorkspaceUnavailableError, WorkspaceAmbiguousNameError;
5163
+ var UUID_RE9, ROLES, MemberSelectionError, DEFAULT_MEMBERSHIP_REVOKED, PROJECT_NOT_AVAILABLE, ARCHIVED_PROJECT_NOT_AVAILABLE, WorkspaceCliError, WorkspaceResolutionError, WorkspaceUnavailableError, WorkspaceAmbiguousNameError;
5164
5164
  var init_workspaces = __esm({
5165
5165
  "src/cloud/workspaces.ts"() {
5166
5166
  "use strict";
5167
5167
  init_invite_link();
5168
5168
  init_renewal_grants();
5169
- UUID_RE8 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
5169
+ UUID_RE9 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
5170
5170
  ROLES = /* @__PURE__ */ new Set(["owner", "admin", "member"]);
5171
5171
  MemberSelectionError = class extends Error {
5172
5172
  constructor(code, message, matches = []) {
@@ -5303,7 +5303,7 @@ function parseSignalAttachments(value, options = {}) {
5303
5303
  throw new SignalAttachmentMalformedError("signal read returned a malformed attachment");
5304
5304
  }
5305
5305
  const row = valueAtPosition;
5306
- if (typeof row.file_id !== "string" || !UUID_RE9.test(row.file_id) || typeof row.version_n !== "number" || !Number.isSafeInteger(row.version_n) || row.version_n < 1 || typeof row.name !== "string" || row.name.length < 1 || row.name.length > 255 || typeof row.content_type !== "string" || row.content_type.length < 1 || typeof row.size_bytes !== "number" || !Number.isSafeInteger(row.size_bytes) || row.size_bytes < 0) {
5306
+ if (typeof row.file_id !== "string" || !UUID_RE10.test(row.file_id) || typeof row.version_n !== "number" || !Number.isSafeInteger(row.version_n) || row.version_n < 1 || typeof row.name !== "string" || row.name.length < 1 || row.name.length > 255 || typeof row.content_type !== "string" || row.content_type.length < 1 || typeof row.size_bytes !== "number" || !Number.isSafeInteger(row.size_bytes) || row.size_bytes < 0) {
5307
5307
  throw new SignalAttachmentMalformedError("signal read returned malformed attachment metadata");
5308
5308
  }
5309
5309
  const fileId = row.file_id.toLowerCase();
@@ -5323,7 +5323,7 @@ function parseSignalAttachments(value, options = {}) {
5323
5323
  return attachments;
5324
5324
  }
5325
5325
  function attachmentRetrievalCommand(workspaceId2, attachment) {
5326
- if (!UUID_RE9.test(workspaceId2) || !UUID_RE9.test(attachment.file_id)) {
5326
+ if (!UUID_RE10.test(workspaceId2) || !UUID_RE10.test(attachment.file_id)) {
5327
5327
  throw new Error("attachment retrieval command needs UUID identifiers");
5328
5328
  }
5329
5329
  if (!Number.isSafeInteger(attachment.version_n) || attachment.version_n < 1) {
@@ -5337,12 +5337,12 @@ function formatAttachmentSize(bytes) {
5337
5337
  if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
5338
5338
  return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
5339
5339
  }
5340
- var SIGNAL_ATTACHMENT_MAX, UUID_RE9, SignalAttachmentMalformedError;
5340
+ var SIGNAL_ATTACHMENT_MAX, UUID_RE10, SignalAttachmentMalformedError;
5341
5341
  var init_attachments = __esm({
5342
5342
  "src/cloud/attachments.ts"() {
5343
5343
  "use strict";
5344
5344
  SIGNAL_ATTACHMENT_MAX = 8;
5345
- UUID_RE9 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
5345
+ UUID_RE10 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
5346
5346
  SignalAttachmentMalformedError = class extends Error {
5347
5347
  name = "SignalAttachmentMalformedError";
5348
5348
  };
@@ -5362,7 +5362,7 @@ function plainMalformedError(message) {
5362
5362
  return error2;
5363
5363
  }
5364
5364
  function checkedUuid2(value, field) {
5365
- if (typeof value !== "string" || !UUID_RE10.test(value)) {
5365
+ if (typeof value !== "string" || !UUID_RE11.test(value)) {
5366
5366
  throw new SignalMalformedError(`signal read returned a malformed ${field}`);
5367
5367
  }
5368
5368
  return value.toLowerCase();
@@ -6092,7 +6092,7 @@ async function readAgentSignalDirectory(target2, token, workspaceId2, fetcherOrO
6092
6092
  }
6093
6093
  function resolveSignalRecipient(selector, directory) {
6094
6094
  const resolved = Array.isArray(directory) ? { members: directory, agents: [] } : directory;
6095
- if (UUID_RE10.test(selector)) {
6095
+ if (UUID_RE11.test(selector)) {
6096
6096
  const normalized = selector.toLowerCase();
6097
6097
  const member = resolved.members.find((row) => row.user_id === normalized);
6098
6098
  const agent = resolved.agents.find(
@@ -6170,10 +6170,10 @@ async function pollForSignals(options) {
6170
6170
  return { signals: [], timedOut: true };
6171
6171
  }
6172
6172
  function normalizedSignalQuery(query) {
6173
- if (!UUID_RE10.test(query.workspaceId)) {
6173
+ if (!UUID_RE11.test(query.workspaceId)) {
6174
6174
  throw new Error("--workspace-id must be a UUID");
6175
6175
  }
6176
- if (query.in_reply_to !== void 0 && !UUID_RE10.test(query.in_reply_to)) {
6176
+ if (query.in_reply_to !== void 0 && !UUID_RE11.test(query.in_reply_to)) {
6177
6177
  throw new Error("in_reply_to must be a signal UUID");
6178
6178
  }
6179
6179
  const after = checkedAfter(query.after);
@@ -6679,7 +6679,7 @@ async function runInboxFollow(options) {
6679
6679
  }
6680
6680
  }
6681
6681
  }
6682
- var UUID_RE10, SIGNAL_KINDS, SIGNAL_BODY_DISPLAY_MAX, SIGNAL_ABOUT_DISPLAY_MAX, SIGNAL_READ_TIMEOUT_MS, SignalReadTimeoutError, SignalHostPortsExhaustedError, SIGNAL_WAIT_MIN_SECONDS, SIGNAL_WAIT_MAX_SECONDS, SIGNAL_WAIT_POLL_MS, SIGNAL_FOLLOW_POLL_MS, SIGNAL_FOLLOW_BACKOFF_INITIAL_MS, SIGNAL_FOLLOW_BACKOFF_MAX_MS, SIGNAL_FOLLOW_SEEN_MAX, SIGNAL_FOLLOW_POST_EMIT_MS, SIGNAL_FOLLOW_PAGE_LIMIT, SignalHttpError, SignalTransportError, LocalCredentialSecretAbsentError, ListenerCredentialStateMismatchError, SignalMalformedError, SignalRecipientError, plainHttpRetryAfterMs, plainHttpStatus, plainHttpEnvelope, plainTransportErrors, plainTransportFailureCodes, plainMalformedErrors, SENDER_OWNER_RELATIONS, SIGNAL_RECIPIENT_KINDS, READ_RETRY_ATTEMPTS, READ_RETRY_BASE_MS, SIGNAL_STATUS_UNAVAILABLE_MESSAGE, ASK_WAIT_TIMEOUT_MESSAGE, BoundedSignalIdSet, DEFAULT_REFUSAL_TOLERANCE_MS, MAX_REFUSAL_TOLERANCE_MS, CONFIRMED_CREDENTIAL_LOSS_CODES, COMMAND_CONFIRMED_CREDENTIAL_LOSS_CODES, READ_CONFIRMED_CREDENTIAL_LOSS_CODE_SET, COMMAND_CONFIRMED_CREDENTIAL_LOSS_CODE_SET;
6682
+ var UUID_RE11, SIGNAL_KINDS, SIGNAL_BODY_DISPLAY_MAX, SIGNAL_ABOUT_DISPLAY_MAX, SIGNAL_READ_TIMEOUT_MS, SignalReadTimeoutError, SignalHostPortsExhaustedError, SIGNAL_WAIT_MIN_SECONDS, SIGNAL_WAIT_MAX_SECONDS, SIGNAL_WAIT_POLL_MS, SIGNAL_FOLLOW_POLL_MS, SIGNAL_FOLLOW_BACKOFF_INITIAL_MS, SIGNAL_FOLLOW_BACKOFF_MAX_MS, SIGNAL_FOLLOW_SEEN_MAX, SIGNAL_FOLLOW_POST_EMIT_MS, SIGNAL_FOLLOW_PAGE_LIMIT, SignalHttpError, SignalTransportError, LocalCredentialSecretAbsentError, ListenerCredentialStateMismatchError, SignalMalformedError, SignalRecipientError, plainHttpRetryAfterMs, plainHttpStatus, plainHttpEnvelope, plainTransportErrors, plainTransportFailureCodes, plainMalformedErrors, SENDER_OWNER_RELATIONS, SIGNAL_RECIPIENT_KINDS, READ_RETRY_ATTEMPTS, READ_RETRY_BASE_MS, SIGNAL_STATUS_UNAVAILABLE_MESSAGE, ASK_WAIT_TIMEOUT_MESSAGE, BoundedSignalIdSet, DEFAULT_REFUSAL_TOLERANCE_MS, MAX_REFUSAL_TOLERANCE_MS, CONFIRMED_CREDENTIAL_LOSS_CODES, COMMAND_CONFIRMED_CREDENTIAL_LOSS_CODES, READ_CONFIRMED_CREDENTIAL_LOSS_CODE_SET, COMMAND_CONFIRMED_CREDENTIAL_LOSS_CODE_SET;
6683
6683
  var init_signals = __esm({
6684
6684
  "src/cloud/signals.ts"() {
6685
6685
  "use strict";
@@ -6689,7 +6689,7 @@ var init_signals = __esm({
6689
6689
  init_error_envelope();
6690
6690
  init_attachments();
6691
6691
  init_wake();
6692
- UUID_RE10 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
6692
+ UUID_RE11 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
6693
6693
  SIGNAL_KINDS = /* @__PURE__ */ new Set(["working-on", "note", "ask"]);
6694
6694
  SIGNAL_BODY_DISPLAY_MAX = 8e3;
6695
6695
  SIGNAL_ABOUT_DISPLAY_MAX = 500;
@@ -8624,7 +8624,7 @@ function datetime(args) {
8624
8624
  const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
8625
8625
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
8626
8626
  }
8627
- var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, guid, uuid2, email, _emoji, ipv4, ipv6, cidrv4, cidrv6, base64, base64url, httpProtocol, e164, dateSource, date, string, integer, number, boolean, _null, lowercase, uppercase;
8627
+ var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, guid, uuid3, email, _emoji, ipv4, ipv6, cidrv4, cidrv6, base64, base64url, httpProtocol, e164, dateSource, date, string, integer, number, boolean, _null, lowercase, uppercase;
8628
8628
  var init_regexes = __esm({
8629
8629
  "../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/zod/v4/core/regexes.js"() {
8630
8630
  cuid = /^[cC][0-9a-z]{6,}$/;
@@ -8635,7 +8635,7 @@ var init_regexes = __esm({
8635
8635
  nanoid = /^[a-zA-Z0-9_-]{21}$/;
8636
8636
  duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
8637
8637
  guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
8638
- uuid2 = (version4) => {
8638
+ uuid3 = (version4) => {
8639
8639
  if (!version4)
8640
8640
  return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
8641
8641
  return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version4}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
@@ -9668,9 +9668,9 @@ var init_schemas = __esm({
9668
9668
  const v = versionMap[def.version];
9669
9669
  if (v === void 0)
9670
9670
  throw new Error(`Invalid UUID version: "${def.version}"`);
9671
- def.pattern ?? (def.pattern = uuid2(v));
9671
+ def.pattern ?? (def.pattern = uuid3(v));
9672
9672
  } else
9673
- def.pattern ?? (def.pattern = uuid2());
9673
+ def.pattern ?? (def.pattern = uuid3());
9674
9674
  $ZodStringFormat.init(inst, def);
9675
9675
  });
9676
9676
  $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
@@ -24846,7 +24846,7 @@ function observationCommandId(signalId) {
24846
24846
  return `observe_${signalId.toLowerCase().replaceAll("-", "")}`;
24847
24847
  }
24848
24848
  function checkedUuid3(value, field) {
24849
- if (typeof value !== "string" || !UUID_RE11.test(value)) {
24849
+ if (typeof value !== "string" || !UUID_RE12.test(value)) {
24850
24850
  throw new DeliveryMalformedResponseError(
24851
24851
  `delivery response returned a malformed ${field}`
24852
24852
  );
@@ -24957,7 +24957,7 @@ function checkedClaimCapabilities(value) {
24957
24957
  }
24958
24958
  function checkedOptionalUuidArray(value, field) {
24959
24959
  if (value === void 0) return;
24960
- if (!Array.isArray(value) || value.some((item) => typeof item !== "string" || !UUID_RE11.test(item))) {
24960
+ if (!Array.isArray(value) || value.some((item) => typeof item !== "string" || !UUID_RE12.test(item))) {
24961
24961
  throw new DeliveryMalformedResponseError(
24962
24962
  `delivery response returned a malformed ${field}`
24963
24963
  );
@@ -25140,7 +25140,7 @@ function checkedCommandId(value) {
25140
25140
  return value;
25141
25141
  }
25142
25142
  function checkedUuidRequest(value, field) {
25143
- if (!UUID_RE11.test(value)) {
25143
+ if (!UUID_RE12.test(value)) {
25144
25144
  throw new Error(`${field} must be a UUID for an agent delivery command`);
25145
25145
  }
25146
25146
  }
@@ -25212,7 +25212,7 @@ function successBody(response, text, verb) {
25212
25212
  }
25213
25213
  return body2;
25214
25214
  }
25215
- var UUID_RE11, RFC3339_TIMESTAMP_RE, DELIVERY_KINDS, SENDER_OWNER_RELATIONS2, DELIVERY_ACK_OUTCOMES, DELIVERY_HANDLED_OUTCOMES, DELIVERY_PROVIDER_PROVEN_OUTCOMES, DELIVERY_REQUEST_TIMEOUT_MS, COMMAND_ID_VALIDATOR_RE, FAILED_TERMINAL_CODES_SET, H0_SEAT_CLAIM_REFUSED_CODE, H0_SEAT_LISTENER_STOP_SENTENCE, DELIVERY_FAILED_TERMINAL_CODES, DELIVERY_SESSION_PROOF_CODES, DELIVERY_SERVER_ERROR_CODES, SERVER_ERROR_CODES_SET, DELIVERY_UNKNOWN_ERROR_CODE, DeliveryTransportError, DeliveryHttpError, DeliveryProtocolError, DeliveryResponseError, DeliveryMalformedResponseError, DeliveryCommandClient;
25215
+ var UUID_RE12, RFC3339_TIMESTAMP_RE, DELIVERY_KINDS, SENDER_OWNER_RELATIONS2, DELIVERY_ACK_OUTCOMES, DELIVERY_HANDLED_OUTCOMES, DELIVERY_PROVIDER_PROVEN_OUTCOMES, DELIVERY_REQUEST_TIMEOUT_MS, COMMAND_ID_VALIDATOR_RE, FAILED_TERMINAL_CODES_SET, H0_SEAT_CLAIM_REFUSED_CODE, H0_SEAT_LISTENER_STOP_SENTENCE, DELIVERY_FAILED_TERMINAL_CODES, DELIVERY_SESSION_PROOF_CODES, DELIVERY_SERVER_ERROR_CODES, SERVER_ERROR_CODES_SET, DELIVERY_UNKNOWN_ERROR_CODE, DeliveryTransportError, DeliveryHttpError, DeliveryProtocolError, DeliveryResponseError, DeliveryMalformedResponseError, DeliveryCommandClient;
25216
25216
  var init_delivery = __esm({
25217
25217
  "src/cloud/delivery.ts"() {
25218
25218
  "use strict";
@@ -25222,7 +25222,7 @@ var init_delivery = __esm({
25222
25222
  init_wake();
25223
25223
  init_session_ack();
25224
25224
  init_session_wire();
25225
- UUID_RE11 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
25225
+ UUID_RE12 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
25226
25226
  RFC3339_TIMESTAMP_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|([+-]\d{2}):(\d{2}))$/i;
25227
25227
  DELIVERY_KINDS = /* @__PURE__ */ new Set(["ask", "note"]);
25228
25228
  SENDER_OWNER_RELATIONS2 = /* @__PURE__ */ new Set([
@@ -51601,7 +51601,7 @@ function capMcpResult(value) {
51601
51601
  if (Buffer.byteLength(raw) <= MCP_RESULT_MAX_BYTES) return value;
51602
51602
  return { truncated: true, message: "Result exceeds the MCP byte cap. Narrow the request." };
51603
51603
  }
51604
- var MCP_ARGUMENT_NAME_ECHO_MAX, MCP_RESULT_MAX_BYTES, string3, body, requestId, UUID_LENGTH, uuid6, common, schema, MCP_TOOL_TABLE, MCP_TOOLS;
51604
+ var MCP_ARGUMENT_NAME_ECHO_MAX, MCP_RESULT_MAX_BYTES, string3, body, requestId, UUID_LENGTH, uuid7, common, schema, MCP_TOOL_TABLE, MCP_TOOLS;
51605
51605
  var init_tools = __esm({
51606
51606
  "src/mcp/tools.ts"() {
51607
51607
  "use strict";
@@ -51621,7 +51621,7 @@ var init_tools = __esm({
51621
51621
  body = string3(SIGNAL_BODY_MAX, 1);
51622
51622
  requestId = string3(H0_REQUEST_ID_MAX, H0_REQUEST_ID_MIN, H0_REQUEST_ID_RE.source);
51623
51623
  UUID_LENGTH = "00000000-0000-0000-0000-000000000000".length;
51624
- uuid6 = string3(UUID_LENGTH, UUID_LENGTH, ONBOARDING_UUID.source.replaceAll("a-f", "a-fA-F").replaceAll("[89ab]", "[89abAB]"));
51624
+ uuid7 = string3(UUID_LENGTH, UUID_LENGTH, ONBOARDING_UUID.source.replaceAll("a-f", "a-fA-F").replaceAll("[89ab]", "[89abAB]"));
51625
51625
  common = { body, about: string3(SIGNAL_ABOUT_MAX), channel: { ...string3(CHANNEL_SLUG_MAX, 1, CHANNEL_SLUG_RE.source), not: { enum: RESERVED_CHANNEL_SLUGS } }, until: string3(void 0, void 0, SIGNAL_DURATION_RE.source), request_id: requestId };
51626
51626
  schema = (properties, required2 = []) => ({
51627
51627
  type: "object",
@@ -51631,10 +51631,10 @@ var init_tools = __esm({
51631
51631
  });
51632
51632
  MCP_TOOL_TABLE = [
51633
51633
  { name: "whoami", description: "Show this authenticated agent and workspace.", inputSchema: schema({}), mapResult: mapWhoami },
51634
- { name: "check", description: "Read new directed messages. If a result is lost, call check with its message_id to read the cached full text.", inputSchema: schema({ message_id: uuid6 }), mapResult: { fresh: mapCheck, cached: mapCachedCheck } },
51634
+ { name: "check", description: "Read new directed messages. If a result is lost, call check with its message_id to read the cached full text.", inputSchema: schema({ message_id: uuid7 }), mapResult: { fresh: mapCheck, cached: mapCachedCheck } },
51635
51635
  { name: "ask", description: "Ask a teammate. Channel slugs are lowercase. Retry with the same request_id and arguments if the outcome is unknown.", inputSchema: schema({ ...common, to: string3(SIGNAL_RECIPIENT_MAX, 1) }, ["body", "request_id"]), mapResult: mapSignal },
51636
51636
  { name: "note", description: "Share a note. Channel slugs are lowercase. Retry with the same request_id and arguments if the outcome is unknown.", inputSchema: schema({ ...common, to: string3(SIGNAL_RECIPIENT_MAX, 1) }, ["body", "request_id"]), mapResult: mapSignal },
51637
- { name: "reply", description: "Reply privately to a signal. Retry with the same request_id and arguments if the outcome is unknown.", inputSchema: schema({ signal_id: uuid6, body, request_id: requestId }, ["signal_id", "body", "request_id"]), mapResult: mapSignal },
51637
+ { name: "reply", description: "Reply privately to a signal. Retry with the same request_id and arguments if the outcome is unknown.", inputSchema: schema({ signal_id: uuid7, body, request_id: requestId }, ["signal_id", "body", "request_id"]), mapResult: mapSignal },
51638
51638
  { name: "working_on", description: "Share current work. Channel slugs are lowercase. Retry with the same request_id and arguments if the outcome is unknown.", inputSchema: schema(common, ["body", "request_id"]), mapResult: mapSignal },
51639
51639
  { name: "members", description: "List members and agents in this workspace.", inputSchema: schema({}), mapResult: mapMembers }
51640
51640
  ];
@@ -52009,6 +52009,67 @@ __export(cli_exports, {
52009
52009
  module.exports = __toCommonJS(cli_exports);
52010
52010
  var import_node_crypto24 = require("node:crypto");
52011
52011
  init_signal_duration();
52012
+
52013
+ // src/cloud/pending-access.ts
52014
+ init_config();
52015
+ var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
52016
+ var uuid = (value) => typeof value === "string" && UUID_RE.test(value);
52017
+ function parsePendingAccess(value) {
52018
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("pending access read returned malformed data");
52019
+ const rows3 = value.pending;
52020
+ if (!Array.isArray(rows3)) throw new Error("pending access read returned malformed data");
52021
+ return rows3.map((value2) => {
52022
+ if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) throw new Error("pending access read returned malformed row");
52023
+ const row = value2;
52024
+ const common2 = uuid(row.owner_user_id) && typeof row.issuer_display === "string" && typeof row.issued_at === "string" && Number.isFinite(Date.parse(row.issued_at)) && (row.expires_at === null || typeof row.expires_at === "string" && Number.isFinite(Date.parse(row.expires_at)));
52025
+ const classic = row.kind === "classic" && uuid(row.principal_id) && typeof row.principal_name === "string" && row.join_credential_id === null && row.seats_used === null && row.seat_cap === null;
52026
+ const join23 = row.kind === "join" && row.principal_id === null && row.principal_name === null && uuid(row.join_credential_id) && Number.isSafeInteger(row.seats_used) && Number.isSafeInteger(row.seat_cap) && Number(row.seats_used) >= 0 && Number(row.seat_cap) > Number(row.seats_used);
52027
+ if (!common2 || !classic && !join23) throw new Error("pending access read returned malformed row");
52028
+ return {
52029
+ kind: row.kind,
52030
+ principal_id: row.principal_id,
52031
+ principal_name: row.principal_name,
52032
+ join_credential_id: row.join_credential_id,
52033
+ owner_user_id: row.owner_user_id,
52034
+ issuer_display: row.issuer_display,
52035
+ issued_at: row.issued_at,
52036
+ expires_at: row.expires_at,
52037
+ seats_used: row.seats_used,
52038
+ seat_cap: row.seat_cap
52039
+ };
52040
+ });
52041
+ }
52042
+ async function readPendingAccess(target2, bearer, workspaceId2, fetcher = fetch) {
52043
+ const response = await fetcher(readEndpoint(target2), {
52044
+ method: "POST",
52045
+ headers: {
52046
+ authorization: `Bearer ${bearer}`,
52047
+ apikey: target2.anonKey,
52048
+ "content-type": "application/json"
52049
+ },
52050
+ body: JSON.stringify({ resource: "pending_access", workspace_id: workspaceId2 }),
52051
+ signal: AbortSignal.timeout(1e4)
52052
+ });
52053
+ if (!response.ok) throw new Error(`pending access read failed (${response.status})`);
52054
+ return parsePendingAccess(await response.json());
52055
+ }
52056
+ async function readPendingAccessOptional(target2, bearer, workspaceId2, fetcher = fetch) {
52057
+ try {
52058
+ return await readPendingAccess(target2, bearer, workspaceId2, fetcher);
52059
+ } catch {
52060
+ return null;
52061
+ }
52062
+ }
52063
+ function pendingAccessAge(issuedAt, now = Date.now()) {
52064
+ const minutes = Math.max(0, Math.floor((now - Date.parse(issuedAt)) / 6e4));
52065
+ if (minutes < 1) return "just now";
52066
+ if (minutes < 60) return `${minutes}m ago`;
52067
+ const hours = Math.floor(minutes / 60);
52068
+ if (hours < 24) return `${hours}h ago`;
52069
+ return `${Math.floor(hours / 24)}d ago`;
52070
+ }
52071
+
52072
+ // src/cli.ts
52012
52073
  init_signal_limits();
52013
52074
  init_signal_limits();
52014
52075
 
@@ -55820,7 +55881,7 @@ function osUsername() {
55820
55881
  }
55821
55882
 
55822
55883
  // src/cloud/seed.ts
55823
- var UUID_RE12 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
55884
+ var UUID_RE13 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
55824
55885
  var P0_SCOPES = [
55825
55886
  "create",
55826
55887
  "acquire",
@@ -55845,15 +55906,15 @@ function deterministicUuid(label) {
55845
55906
  hex.slice(20)
55846
55907
  ].join("-");
55847
55908
  }
55848
- function uuid3(value, label) {
55849
- if (!UUID_RE12.test(value)) throw new Error(`${label} must be a UUID`);
55909
+ function uuid4(value, label) {
55910
+ if (!UUID_RE13.test(value)) throw new Error(`${label} must be a UUID`);
55850
55911
  return value;
55851
55912
  }
55852
55913
  async function seedDogfood(options) {
55853
55914
  if (!options.databaseUrl) throw new Error("DATABASE_URL is required");
55854
- const userId = uuid3(options.userId, "uid");
55855
- const deviceId = options.deviceId ? uuid3(options.deviceId, "device id") : deterministicUuid(`cloud-swarm:device:${userId}`);
55856
- const workspaceId2 = options.workspaceId ? uuid3(options.workspaceId, "workspace id") : deterministicUuid(`cloud-swarm:workspace:${userId}`);
55915
+ const userId = uuid4(options.userId, "uid");
55916
+ const deviceId = options.deviceId ? uuid4(options.deviceId, "device id") : deterministicUuid(`cloud-swarm:device:${userId}`);
55917
+ const workspaceId2 = options.workspaceId ? uuid4(options.workspaceId, "workspace id") : deterministicUuid(`cloud-swarm:workspace:${userId}`);
55857
55918
  const requestedStreamId = deterministicUuid(
55858
55919
  `cloud-swarm:workspace-stream:${workspaceId2}`
55859
55920
  );
@@ -56313,7 +56374,7 @@ function acceptedResponse(result) {
56313
56374
  }
56314
56375
  return result.response;
56315
56376
  }
56316
- function uuid4(value, field) {
56377
+ function uuid5(value, field) {
56317
56378
  if (typeof value !== "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value)) {
56318
56379
  throw new Error(`server returned a malformed ${field}`);
56319
56380
  }
@@ -56685,7 +56746,7 @@ function cloudAcceptOperations(target2, store2, fetcher = fetch) {
56685
56746
  );
56686
56747
  return {
56687
56748
  status: "accepted",
56688
- workspaceId: uuid4(response.workspace_id, "workspace_id")
56749
+ workspaceId: uuid5(response.workspace_id, "workspace_id")
56689
56750
  };
56690
56751
  } catch (error2) {
56691
56752
  if (error2 instanceof CommandHttpError && error2.status === 403) {
@@ -56709,7 +56770,7 @@ function cloudAcceptOperations(target2, store2, fetcher = fetch) {
56709
56770
  if (result.response.status === "accepted") {
56710
56771
  return {
56711
56772
  status: "accepted",
56712
- principalId: uuid4(result.response.principal_id, "principal_id")
56773
+ principalId: uuid5(result.response.principal_id, "principal_id")
56713
56774
  };
56714
56775
  }
56715
56776
  if (String(result.response.reason) === "principal_name_taken") {
@@ -56821,7 +56882,7 @@ init_signals();
56821
56882
  init_storage();
56822
56883
  init_idle_poll();
56823
56884
  init_wake2();
56824
- var UUID_RE13 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
56885
+ var UUID_RE14 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
56825
56886
  var CURSOR_MAX_BYTES = 4 * 1024;
56826
56887
  var ARRIVAL_SNIPPET_MAX = 180;
56827
56888
  var WATCH_LOCK_MAX_BYTES = 512;
@@ -56989,7 +57050,7 @@ function parseCursor(raw, workspaceId2, principalId) {
56989
57050
  }
56990
57051
  const row = value;
56991
57052
  const cursor = row.cursor;
56992
- if (row.version !== 1 || row.workspace_id !== workspaceId2.toLowerCase() || row.principal_id !== principalId.toLowerCase() || !(cursor === null || typeof cursor === "object" && !Array.isArray(cursor) && typeof cursor.created_at === "string" && Number.isFinite(Date.parse(cursor.created_at)) && typeof cursor.id === "string" && UUID_RE13.test(cursor.id))) {
57053
+ if (row.version !== 1 || row.workspace_id !== workspaceId2.toLowerCase() || row.principal_id !== principalId.toLowerCase() || !(cursor === null || typeof cursor === "object" && !Array.isArray(cursor) && typeof cursor.created_at === "string" && Number.isFinite(Date.parse(cursor.created_at)) && typeof cursor.id === "string" && UUID_RE14.test(cursor.id))) {
56993
57054
  throw new Error("stored arrival cursor is malformed");
56994
57055
  }
56995
57056
  if (cursor === null) return null;
@@ -57001,7 +57062,7 @@ function parseCursor(raw, workspaceId2, principalId) {
57001
57062
  function fileArrivalCursorStore(options) {
57002
57063
  const workspaceId2 = options.workspaceId.toLowerCase();
57003
57064
  const principalId = options.principalId.toLowerCase();
57004
- if (!UUID_RE13.test(workspaceId2) || !UUID_RE13.test(principalId)) {
57065
+ if (!UUID_RE14.test(workspaceId2) || !UUID_RE14.test(principalId)) {
57005
57066
  throw new Error("arrival cursor identity must use workspace and principal UUIDs");
57006
57067
  }
57007
57068
  const location2 = arrivalCursorPath(
@@ -57270,7 +57331,7 @@ init_idle_poll();
57270
57331
  // src/cloud/delivery-receipts.ts
57271
57332
  init_config();
57272
57333
  init_signals();
57273
- var UUID_RE14 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
57334
+ var UUID_RE15 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
57274
57335
  var DeliveryReceiptReadError = class extends Error {
57275
57336
  constructor(code, message, status = null) {
57276
57337
  super(message);
@@ -57288,8 +57349,8 @@ var ACK_OUTCOMES = /* @__PURE__ */ new Set([
57288
57349
  "expired",
57289
57350
  "failed_terminal"
57290
57351
  ]);
57291
- function uuid5(value, field) {
57292
- if (typeof value !== "string" || !UUID_RE14.test(value)) {
57352
+ function uuid6(value, field) {
57353
+ if (typeof value !== "string" || !UUID_RE15.test(value)) {
57293
57354
  throw new DeliveryReceiptReadError(
57294
57355
  "protocol",
57295
57356
  `delivery receipt returned a malformed ${field}`
@@ -57337,7 +57398,7 @@ function parseDeliveryReceipt(value) {
57337
57398
  const row = value;
57338
57399
  if (Object.hasOwn(row, "recipient_user_id")) {
57339
57400
  return {
57340
- recipient_user_id: uuid5(row.recipient_user_id, "recipient_user_id"),
57401
+ recipient_user_id: uuid6(row.recipient_user_id, "recipient_user_id"),
57341
57402
  ...Object.hasOwn(row, "display_name") ? { display_name: displayName(row.display_name, "display_name") } : {},
57342
57403
  seen_at: nullableTimestamp2(row.seen_at, "seen_at")
57343
57404
  };
@@ -57362,7 +57423,7 @@ function parseDeliveryReceipt(value) {
57362
57423
  );
57363
57424
  }
57364
57425
  return {
57365
- recipient_agent_principal_id: uuid5(
57426
+ recipient_agent_principal_id: uuid6(
57366
57427
  row.recipient_agent_principal_id,
57367
57428
  "recipient_agent_principal_id"
57368
57429
  ),
@@ -57402,8 +57463,8 @@ function parseBroadcastAgent(value) {
57402
57463
  "delivery receipt returned malformed legacy agent compatibility fields"
57403
57464
  );
57404
57465
  }
57405
- const principalId = uuid5(row.principal_id, "principal_id");
57406
- const recipientPrincipalId = uuid5(
57466
+ const principalId = uuid6(row.principal_id, "principal_id");
57467
+ const recipientPrincipalId = uuid6(
57407
57468
  row.recipient_agent_principal_id,
57408
57469
  "recipient_agent_principal_id"
57409
57470
  );
@@ -57604,8 +57665,8 @@ async function readAgentDeliveryReceipts(target2, token, workspaceId2, signalId,
57604
57665
  },
57605
57666
  body: JSON.stringify({
57606
57667
  resource: "delivery_receipts",
57607
- workspace_id: uuid5(workspaceId2, "workspace_id"),
57608
- signal_id: uuid5(signalId, "signal_id")
57668
+ workspace_id: uuid6(workspaceId2, "workspace_id"),
57669
+ signal_id: uuid6(signalId, "signal_id")
57609
57670
  }),
57610
57671
  signal
57611
57672
  }),
@@ -57986,9 +58047,9 @@ init_command_client();
57986
58047
  init_signals();
57987
58048
  init_attachments();
57988
58049
  init_types2();
57989
- var UUID_RE15 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
58050
+ var UUID_RE16 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
57990
58051
  function listenerReplyCommandId(signalId, effectOrdinal = 0) {
57991
- if (!UUID_RE15.test(signalId)) {
58052
+ if (!UUID_RE16.test(signalId)) {
57992
58053
  throw new Error("listener signal id must be a UUID");
57993
58054
  }
57994
58055
  if (!Number.isSafeInteger(effectOrdinal) || effectOrdinal < 0) {
@@ -58049,7 +58110,7 @@ var import_node_os8 = require("node:os");
58049
58110
  var import_node_path13 = require("node:path");
58050
58111
  var import_node_util3 = require("node:util");
58051
58112
  init_storage();
58052
- var UUID_RE16 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
58113
+ var UUID_RE17 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
58053
58114
  var COMMAND_ID_RE2 = /^[A-Za-z0-9_-]{8,72}$/;
58054
58115
  var MAX_EFFECT_BYTES = 1024 * 1024;
58055
58116
  var STATES = /* @__PURE__ */ new Set([
@@ -58099,7 +58160,7 @@ function defaultListenerStateDirectory() {
58099
58160
  return process.env.XDG_STATE_HOME ? (0, import_node_path13.join)(process.env.XDG_STATE_HOME, "cswarm", "listeners") : (0, import_node_path13.join)((0, import_node_os8.homedir)(), ".cswarm", "listeners");
58100
58161
  }
58101
58162
  function listenerInstanceKey(input) {
58102
- if (!UUID_RE16.test(input.workspaceId) || !UUID_RE16.test(input.principalId)) {
58163
+ if (!UUID_RE17.test(input.workspaceId) || !UUID_RE17.test(input.principalId)) {
58103
58164
  throw new Error("listener workspace and principal ids must be UUIDs");
58104
58165
  }
58105
58166
  if (!input.profileId || input.profileId.includes("\0")) {
@@ -58132,7 +58193,7 @@ function parseListenerEffectRecord(raw, expectedId) {
58132
58193
  }
58133
58194
  const row = value;
58134
58195
  rejectSensitiveKeys(row);
58135
- if (typeof row.version !== "number" || row.version !== 1 && row.version !== 2 || typeof row.signalId !== "string" || row.signalId.toLowerCase() !== expectedId || !UUID_RE16.test(row.signalId)) {
58196
+ if (typeof row.version !== "number" || row.version !== 1 && row.version !== 2 || typeof row.signalId !== "string" || row.signalId.toLowerCase() !== expectedId || !UUID_RE17.test(row.signalId)) {
58136
58197
  throw new Error("stored listener effect is malformed");
58137
58198
  }
58138
58199
  if (row.version === 1) {
@@ -58147,7 +58208,7 @@ function upcastV1Ask(row) {
58147
58208
  if (row.effectOrdinal !== 0 || typeof row.commandId !== "string" || !COMMAND_ID_RE2.test(row.commandId) || typeof row.askBody !== "string" || row.askBody.length < 1 || typeof row.askUntil !== "string" || !Number.isFinite(Date.parse(row.askUntil)) || typeof row.senderOwnerRelation !== "string" || !RELATIONS.has(row.senderOwnerRelation) || typeof row.state !== "string" || !STATES.has(row.state) || !integer2(row.promptAttempts) || !integer2(row.postAttempts) || !nullableString2(row.replyBody, 2e3) || typeof row.replyTruncated !== "boolean" || !nullableString2(row.replySignalId, 64) || !nullableString2(row.failureCode, 96) || typeof row.updatedAt !== "string" || !Number.isFinite(Date.parse(row.updatedAt))) {
58148
58209
  throw new Error("stored listener effect is malformed");
58149
58210
  }
58150
- if (row.replySignalId !== null && !UUID_RE16.test(row.replySignalId)) {
58211
+ if (row.replySignalId !== null && !UUID_RE17.test(row.replySignalId)) {
58151
58212
  throw new Error("stored listener effect is malformed");
58152
58213
  }
58153
58214
  return {
@@ -58186,7 +58247,7 @@ function parseV2Record(row) {
58186
58247
  if (typeof row.commandId !== "string" || !COMMAND_ID_RE2.test(row.commandId) || row.state === "observed") {
58187
58248
  throw new Error("stored listener effect is malformed");
58188
58249
  }
58189
- if (row.replySignalId !== null && !UUID_RE16.test(row.replySignalId)) {
58250
+ if (row.replySignalId !== null && !UUID_RE17.test(row.replySignalId)) {
58190
58251
  throw new Error("stored listener effect is malformed");
58191
58252
  }
58192
58253
  }
@@ -58210,7 +58271,7 @@ function parseV2Record(row) {
58210
58271
  };
58211
58272
  }
58212
58273
  function newObservedNoteRecord(input) {
58213
- if (!UUID_RE16.test(input.signalId)) {
58274
+ if (!UUID_RE17.test(input.signalId)) {
58214
58275
  throw new Error("listener note signal id must be a UUID");
58215
58276
  }
58216
58277
  if (input.body.length < 1) {
@@ -58344,7 +58405,7 @@ var FileListenerEffectStore = class {
58344
58405
  );
58345
58406
  }
58346
58407
  checkedId(signalId) {
58347
- if (!UUID_RE16.test(signalId)) {
58408
+ if (!UUID_RE17.test(signalId)) {
58348
58409
  throw new Error("listener signal id must be a UUID");
58349
58410
  }
58350
58411
  return signalId.toLowerCase();
@@ -58363,7 +58424,7 @@ init_types2();
58363
58424
  // src/listener/main-routing.ts
58364
58425
  var import_node_path14 = require("node:path");
58365
58426
  init_storage();
58366
- var UUID_RE17 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
58427
+ var UUID_RE18 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
58367
58428
  var MAX_QUEUE_BYTES = 1024 * 1024;
58368
58429
  var QUEUE_FILE = "pending-for-main.json";
58369
58430
  var QUEUE_LOCK = "pending-for-main";
@@ -58473,7 +58534,7 @@ function parseEntry(value, rejectUnknownKeys) {
58473
58534
  if (rejectUnknownKeys && Object.keys(row).some((key2) => !ENTRY_KEYS.has(key2))) {
58474
58535
  throw new Error("stored pending-for-main entry is malformed");
58475
58536
  }
58476
- if (typeof row.signalId !== "string" || !UUID_RE17.test(row.signalId) || typeof row.workspaceId !== "string" || !UUID_RE17.test(row.workspaceId) || typeof row.principalId !== "string" || !UUID_RE17.test(row.principalId) || typeof row.fromId !== "string" || !UUID_RE17.test(row.fromId) || row.fromKind !== "user" && row.fromKind !== "agent" || !(row.kind === void 0 || row.kind === "ask" || row.kind === "note") || !(row.senderName === null || typeof row.senderName === "string" && row.senderName.length <= 200) || typeof row.body !== "string" || row.body.length < 1 || !(row.attachmentCount === void 0 || typeof row.attachmentCount === "number" && Number.isSafeInteger(row.attachmentCount) && row.attachmentCount >= 1 && row.attachmentCount <= 8) || !checkedTimestamp2(row.createdAt) || !checkedTimestamp2(row.queuedAt) || !(row.observationPending === void 0 || row.observationPending === true)) {
58537
+ if (typeof row.signalId !== "string" || !UUID_RE18.test(row.signalId) || typeof row.workspaceId !== "string" || !UUID_RE18.test(row.workspaceId) || typeof row.principalId !== "string" || !UUID_RE18.test(row.principalId) || typeof row.fromId !== "string" || !UUID_RE18.test(row.fromId) || row.fromKind !== "user" && row.fromKind !== "agent" || !(row.kind === void 0 || row.kind === "ask" || row.kind === "note") || !(row.senderName === null || typeof row.senderName === "string" && row.senderName.length <= 200) || typeof row.body !== "string" || row.body.length < 1 || !(row.attachmentCount === void 0 || typeof row.attachmentCount === "number" && Number.isSafeInteger(row.attachmentCount) && row.attachmentCount >= 1 && row.attachmentCount <= 8) || !checkedTimestamp2(row.createdAt) || !checkedTimestamp2(row.queuedAt) || !(row.observationPending === void 0 || row.observationPending === true)) {
58477
58538
  throw new Error("stored pending-for-main entry is malformed");
58478
58539
  }
58479
58540
  return {
@@ -58673,7 +58734,7 @@ var ListenerH0SeatError = class extends Error {
58673
58734
  this.name = "ListenerH0SeatError";
58674
58735
  }
58675
58736
  };
58676
- var UUID_RE18 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
58737
+ var UUID_RE19 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
58677
58738
  var ListenerCapabilityError = class _ListenerCapabilityError extends Error {
58678
58739
  static CODES = Object.freeze([
58679
58740
  "sender_relation_capability_missing",
@@ -59060,7 +59121,7 @@ async function runListenerRuntime(options) {
59060
59121
  new Error("listener instance id and delivery journal must be configured together")
59061
59122
  );
59062
59123
  }
59063
- if (hasInstanceId && !UUID_RE18.test(options.listenerInstanceId)) {
59124
+ if (hasInstanceId && !UUID_RE19.test(options.listenerInstanceId)) {
59064
59125
  return await closeBeforeStart(
59065
59126
  options.model,
59066
59127
  new Error("listener instance id must be a UUID")
@@ -60474,7 +60535,7 @@ init_storage();
60474
60535
  init_wake2();
60475
60536
  init_delivery();
60476
60537
  init_credential_redaction();
60477
- var UUID_RE19 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
60538
+ var UUID_RE20 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
60478
60539
  var SEMVER_RE2 = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
60479
60540
  var MAX_STATUS_BYTES = 32 * 1024;
60480
60541
  var MAX_CONTROL_BYTES = 8 * 1024;
@@ -60632,7 +60693,7 @@ function parseHeldBackDeliveries(value) {
60632
60693
  for (const key2 of Object.keys(entry2)) {
60633
60694
  if (key2 !== "signalId" && key2 !== "at" && key2 !== "reason") return null;
60634
60695
  }
60635
- if (typeof entry2.signalId !== "string" || !UUID_RE19.test(entry2.signalId) || typeof entry2.at !== "string" || !Number.isFinite(Date.parse(entry2.at)) || typeof entry2.reason !== "string" || !LISTENER_DELIVERY_HOLD_RELEASE_REASONS.includes(
60696
+ if (typeof entry2.signalId !== "string" || !UUID_RE20.test(entry2.signalId) || typeof entry2.at !== "string" || !Number.isFinite(Date.parse(entry2.at)) || typeof entry2.reason !== "string" || !LISTENER_DELIVERY_HOLD_RELEASE_REASONS.includes(
60636
60697
  entry2.reason
60637
60698
  )) {
60638
60699
  return null;
@@ -60696,13 +60757,13 @@ function parseStatus(raw, rejectUnknownKeys = false) {
60696
60757
  throw new Error("stored listener status is malformed");
60697
60758
  }
60698
60759
  }
60699
- const nullableUuid3 = (candidate) => candidate === null || typeof candidate === "string" && UUID_RE19.test(candidate);
60760
+ const nullableUuid3 = (candidate) => candidate === null || typeof candidate === "string" && UUID_RE20.test(candidate);
60700
60761
  const nullableCount = (candidate) => candidate === null || typeof candidate === "number" && Number.isSafeInteger(candidate) && candidate >= 0;
60701
60762
  const nullableTimestamp3 = (candidate) => candidate === null || typeof candidate === "string" && Number.isFinite(Date.parse(candidate));
60702
60763
  const readHealth = row.readHealth === void 0 ? void 0 : parseListenerReadHealth(row.readHealth, rejectUnknownKeys);
60703
60764
  const heldBackDeliveries = row.heldBackDeliveries === void 0 ? void 0 : parseHeldBackDeliveries(row.heldBackDeliveries);
60704
60765
  const wake = row.wake === void 0 ? void 0 : parseListenerWake(row.wake, rejectUnknownKeys);
60705
- if (row.version !== 1 || typeof row.instanceId !== "string" || !UUID_RE19.test(row.instanceId) || row.provider !== "grok" && row.provider !== "opencode" && row.provider !== "claude" && row.provider !== "codex" || typeof row.profileId !== "string" || typeof row.workspaceId !== "string" || !UUID_RE19.test(row.workspaceId) || typeof row.principalId !== "string" || !UUID_RE19.test(row.principalId) || !Number.isSafeInteger(row.pid) || row.pid < 1 || typeof row.state !== "string" || !LISTENER_STATUS_STATES.includes(row.state) || typeof row.startedAt !== "string" || !Number.isFinite(Date.parse(row.startedAt)) || !(row.readyAt === null || typeof row.readyAt === "string" && Number.isFinite(Date.parse(row.readyAt))) || typeof row.updatedAt !== "string" || !Number.isFinite(Date.parse(row.updatedAt)) || !(row.stoppedAt === null || typeof row.stoppedAt === "string" && Number.isFinite(Date.parse(row.stoppedAt))) || !nullableUuid3(row.lastSignalId) || !(row.lastErrorCode === null || typeof row.lastErrorCode === "string" && /^[a-z0-9_-]{1,96}$/.test(row.lastErrorCode)) || !(row.lastErrorDetail === void 0 || row.lastErrorDetail === null || typeof row.lastErrorDetail === "string" && row.lastErrorDetail.length > 0 && row.lastErrorDetail.length <= 2048 && !SECRET_SHAPE_RE.test(row.lastErrorDetail)) || !(row.lastErrorReasonCode === void 0 || row.lastErrorReasonCode === null || typeof row.lastErrorReasonCode === "string" && /^[a-z0-9_-]{1,96}$/.test(row.lastErrorReasonCode)) || !(row.providerExecutable === void 0 || row.providerExecutable === null || typeof row.providerExecutable === "string" && (0, import_node_path15.isAbsolute)(row.providerExecutable)) || !(row.providerVersion === void 0 || row.providerVersion === null || typeof row.providerVersion === "string" && SEMVER_RE2.test(row.providerVersion)) || !(row.providerLastMeasuredVersion === void 0 || row.providerLastMeasuredVersion === null || typeof row.providerLastMeasuredVersion === "string" && SEMVER_RE2.test(row.providerLastMeasuredVersion)) || !(row.providerBundledAgentSdkVersion === void 0 || row.providerBundledAgentSdkVersion === null || typeof row.providerBundledAgentSdkVersion === "string" && SEMVER_RE2.test(row.providerBundledAgentSdkVersion)) || !(row.providerBundledClaudeCodeVersion === void 0 || row.providerBundledClaudeCodeVersion === null || typeof row.providerBundledClaudeCodeVersion === "string" && SEMVER_RE2.test(row.providerBundledClaudeCodeVersion)) || !(row.providerMinimumRequiredVersion === void 0 || row.providerMinimumRequiredVersion === null || typeof row.providerMinimumRequiredVersion === "string" && SEMVER_RE2.test(row.providerMinimumRequiredVersion)) || !(row.cswarmVersion === void 0 || row.cswarmVersion === null || typeof row.cswarmVersion === "string" && SEMVER_RE2.test(row.cswarmVersion)) || (row.providerVersion === null || row.providerVersion === void 0) !== (row.providerLastMeasuredVersion === null || row.providerLastMeasuredVersion === void 0) || !(row.lastWorkerStderrTail === void 0 || row.lastWorkerStderrTail === null || typeof row.lastWorkerStderrTail === "string" && row.lastWorkerStderrTail.length > 0 && row.lastWorkerStderrTail.length <= 2048 && !SECRET_SHAPE_RE.test(row.lastWorkerStderrTail)) || typeof row.logPath !== "string" || !(0, import_node_path15.isAbsolute)(row.logPath) || !(row.deliveryMode === void 0 || row.deliveryMode === null || typeof row.deliveryMode === "string" && STATUS_DELIVERY_MODES.has(row.deliveryMode)) || !(row.pendingDeliveryCount === void 0 || nullableCount(row.pendingDeliveryCount)) || !(row.lastTerminalDeliveryFailureCount === void 0 || nullableCount(row.lastTerminalDeliveryFailureCount)) || !(row.lastTerminalDeliveryFailureAt === void 0 || nullableTimestamp3(row.lastTerminalDeliveryFailureAt)) || !(row.lastClaimAt === void 0 || nullableTimestamp3(row.lastClaimAt)) || !(row.lastAckAt === void 0 || nullableTimestamp3(row.lastAckAt)) || !(row.lastAckOutcome === void 0 || row.lastAckOutcome === null || typeof row.lastAckOutcome === "string" && deliveryOutcomes.has(row.lastAckOutcome)) || !(row.consecutiveAckFailureCount === void 0 || nullableCount(row.consecutiveAckFailureCount)) || !(row.lastAckSignalId === void 0 || row.lastAckSignalId === null || typeof row.lastAckSignalId === "string" && UUID_RE19.test(row.lastAckSignalId)) || !(row.currentDeliverySignalId === void 0 || row.currentDeliverySignalId === null || typeof row.currentDeliverySignalId === "string" && UUID_RE19.test(row.currentDeliverySignalId)) || !(row.currentDeliverySince === void 0 || nullableTimestamp3(row.currentDeliverySince)) || heldBackDeliveries === null || !(row.pendingDeliveryCountAt === void 0 || nullableTimestamp3(row.pendingDeliveryCountAt)) || !(row.routeMode === void 0 || typeof row.routeMode === "string" && isStoredListenerRouteMode(row.routeMode)) || !(row.deferOverChars === void 0 || row.deferOverChars === null || typeof row.deferOverChars === "number" && Number.isSafeInteger(row.deferOverChars) && row.deferOverChars >= 1 && row.deferOverChars <= 1e4) || !(row.pendingForMainCount === void 0 || typeof row.pendingForMainCount === "number" && Number.isSafeInteger(row.pendingForMainCount) && row.pendingForMainCount >= 0) || !(row.droppedForMainCount === void 0 || typeof row.droppedForMainCount === "number" && Number.isSafeInteger(row.droppedForMainCount) && row.droppedForMainCount >= 0) || readHealth === null || wake === null || !(row.connectionsOpened === void 0 || typeof row.connectionsOpened === "number" && Number.isSafeInteger(row.connectionsOpened) && row.connectionsOpened >= 0) || !(row.connectionReuseRatio === void 0 || typeof row.connectionReuseRatio === "number" && Number.isFinite(row.connectionReuseRatio) && row.connectionReuseRatio >= 0) || !(row.activityPublishFailures === void 0 || typeof row.activityPublishFailures === "number" && Number.isSafeInteger(row.activityPublishFailures) && row.activityPublishFailures >= 0) || !(row.activityLastErrorCode === void 0 || row.activityLastErrorCode === null || typeof row.activityLastErrorCode === "string" && STATUS_ACTIVITY_ERROR_CODES.has(
60766
+ if (row.version !== 1 || typeof row.instanceId !== "string" || !UUID_RE20.test(row.instanceId) || row.provider !== "grok" && row.provider !== "opencode" && row.provider !== "claude" && row.provider !== "codex" || typeof row.profileId !== "string" || typeof row.workspaceId !== "string" || !UUID_RE20.test(row.workspaceId) || typeof row.principalId !== "string" || !UUID_RE20.test(row.principalId) || !Number.isSafeInteger(row.pid) || row.pid < 1 || typeof row.state !== "string" || !LISTENER_STATUS_STATES.includes(row.state) || typeof row.startedAt !== "string" || !Number.isFinite(Date.parse(row.startedAt)) || !(row.readyAt === null || typeof row.readyAt === "string" && Number.isFinite(Date.parse(row.readyAt))) || typeof row.updatedAt !== "string" || !Number.isFinite(Date.parse(row.updatedAt)) || !(row.stoppedAt === null || typeof row.stoppedAt === "string" && Number.isFinite(Date.parse(row.stoppedAt))) || !nullableUuid3(row.lastSignalId) || !(row.lastErrorCode === null || typeof row.lastErrorCode === "string" && /^[a-z0-9_-]{1,96}$/.test(row.lastErrorCode)) || !(row.lastErrorDetail === void 0 || row.lastErrorDetail === null || typeof row.lastErrorDetail === "string" && row.lastErrorDetail.length > 0 && row.lastErrorDetail.length <= 2048 && !SECRET_SHAPE_RE.test(row.lastErrorDetail)) || !(row.lastErrorReasonCode === void 0 || row.lastErrorReasonCode === null || typeof row.lastErrorReasonCode === "string" && /^[a-z0-9_-]{1,96}$/.test(row.lastErrorReasonCode)) || !(row.providerExecutable === void 0 || row.providerExecutable === null || typeof row.providerExecutable === "string" && (0, import_node_path15.isAbsolute)(row.providerExecutable)) || !(row.providerVersion === void 0 || row.providerVersion === null || typeof row.providerVersion === "string" && SEMVER_RE2.test(row.providerVersion)) || !(row.providerLastMeasuredVersion === void 0 || row.providerLastMeasuredVersion === null || typeof row.providerLastMeasuredVersion === "string" && SEMVER_RE2.test(row.providerLastMeasuredVersion)) || !(row.providerBundledAgentSdkVersion === void 0 || row.providerBundledAgentSdkVersion === null || typeof row.providerBundledAgentSdkVersion === "string" && SEMVER_RE2.test(row.providerBundledAgentSdkVersion)) || !(row.providerBundledClaudeCodeVersion === void 0 || row.providerBundledClaudeCodeVersion === null || typeof row.providerBundledClaudeCodeVersion === "string" && SEMVER_RE2.test(row.providerBundledClaudeCodeVersion)) || !(row.providerMinimumRequiredVersion === void 0 || row.providerMinimumRequiredVersion === null || typeof row.providerMinimumRequiredVersion === "string" && SEMVER_RE2.test(row.providerMinimumRequiredVersion)) || !(row.cswarmVersion === void 0 || row.cswarmVersion === null || typeof row.cswarmVersion === "string" && SEMVER_RE2.test(row.cswarmVersion)) || (row.providerVersion === null || row.providerVersion === void 0) !== (row.providerLastMeasuredVersion === null || row.providerLastMeasuredVersion === void 0) || !(row.lastWorkerStderrTail === void 0 || row.lastWorkerStderrTail === null || typeof row.lastWorkerStderrTail === "string" && row.lastWorkerStderrTail.length > 0 && row.lastWorkerStderrTail.length <= 2048 && !SECRET_SHAPE_RE.test(row.lastWorkerStderrTail)) || typeof row.logPath !== "string" || !(0, import_node_path15.isAbsolute)(row.logPath) || !(row.deliveryMode === void 0 || row.deliveryMode === null || typeof row.deliveryMode === "string" && STATUS_DELIVERY_MODES.has(row.deliveryMode)) || !(row.pendingDeliveryCount === void 0 || nullableCount(row.pendingDeliveryCount)) || !(row.lastTerminalDeliveryFailureCount === void 0 || nullableCount(row.lastTerminalDeliveryFailureCount)) || !(row.lastTerminalDeliveryFailureAt === void 0 || nullableTimestamp3(row.lastTerminalDeliveryFailureAt)) || !(row.lastClaimAt === void 0 || nullableTimestamp3(row.lastClaimAt)) || !(row.lastAckAt === void 0 || nullableTimestamp3(row.lastAckAt)) || !(row.lastAckOutcome === void 0 || row.lastAckOutcome === null || typeof row.lastAckOutcome === "string" && deliveryOutcomes.has(row.lastAckOutcome)) || !(row.consecutiveAckFailureCount === void 0 || nullableCount(row.consecutiveAckFailureCount)) || !(row.lastAckSignalId === void 0 || row.lastAckSignalId === null || typeof row.lastAckSignalId === "string" && UUID_RE20.test(row.lastAckSignalId)) || !(row.currentDeliverySignalId === void 0 || row.currentDeliverySignalId === null || typeof row.currentDeliverySignalId === "string" && UUID_RE20.test(row.currentDeliverySignalId)) || !(row.currentDeliverySince === void 0 || nullableTimestamp3(row.currentDeliverySince)) || heldBackDeliveries === null || !(row.pendingDeliveryCountAt === void 0 || nullableTimestamp3(row.pendingDeliveryCountAt)) || !(row.routeMode === void 0 || typeof row.routeMode === "string" && isStoredListenerRouteMode(row.routeMode)) || !(row.deferOverChars === void 0 || row.deferOverChars === null || typeof row.deferOverChars === "number" && Number.isSafeInteger(row.deferOverChars) && row.deferOverChars >= 1 && row.deferOverChars <= 1e4) || !(row.pendingForMainCount === void 0 || typeof row.pendingForMainCount === "number" && Number.isSafeInteger(row.pendingForMainCount) && row.pendingForMainCount >= 0) || !(row.droppedForMainCount === void 0 || typeof row.droppedForMainCount === "number" && Number.isSafeInteger(row.droppedForMainCount) && row.droppedForMainCount >= 0) || readHealth === null || wake === null || !(row.connectionsOpened === void 0 || typeof row.connectionsOpened === "number" && Number.isSafeInteger(row.connectionsOpened) && row.connectionsOpened >= 0) || !(row.connectionReuseRatio === void 0 || typeof row.connectionReuseRatio === "number" && Number.isFinite(row.connectionReuseRatio) && row.connectionReuseRatio >= 0) || !(row.activityPublishFailures === void 0 || typeof row.activityPublishFailures === "number" && Number.isSafeInteger(row.activityPublishFailures) && row.activityPublishFailures >= 0) || !(row.activityLastErrorCode === void 0 || row.activityLastErrorCode === null || typeof row.activityLastErrorCode === "string" && STATUS_ACTIVITY_ERROR_CODES.has(
60706
60767
  row.activityLastErrorCode
60707
60768
  )) || !(row.idlePollMs === void 0 || row.idlePollMs === null || typeof row.idlePollMs === "number" && Number.isSafeInteger(row.idlePollMs) && row.idlePollMs >= 0) || !(row.pushReconcileWaitMs === void 0 || row.pushReconcileWaitMs === null || typeof row.pushReconcileWaitMs === "number" && Number.isSafeInteger(row.pushReconcileWaitMs) && row.pushReconcileWaitMs >= 0) || !(row.nextAttemptAt === void 0 || nullableTimestamp3(row.nextAttemptAt)) || !(row.credentialStopAt === void 0 || nullableTimestamp3(row.credentialStopAt)) || !(row.renewalExpiresAt === void 0 || nullableTimestamp3(row.renewalExpiresAt)) || !(row.credentialCheckEdge === void 0 || row.credentialCheckEdge === null || row.credentialCheckEdge === "read" || row.credentialCheckEdge === "command") || !(row.claimRetryCount === void 0 || typeof row.claimRetryCount === "number" && Number.isSafeInteger(row.claimRetryCount) && row.claimRetryCount >= 0) || !(row.projectDirectory === void 0 || typeof row.projectDirectory === "string" && (0, import_node_path15.isAbsolute)(row.projectDirectory)) || !(row.targetUrl === void 0 || typeof row.targetUrl === "string" && (() => {
60708
60769
  try {
@@ -61177,7 +61238,7 @@ init_credential_redaction();
61177
61238
  init_session_proof();
61178
61239
  init_types2();
61179
61240
  init_wake2();
61180
- var UUID_RE20 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
61241
+ var UUID_RE21 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
61181
61242
  var LISTENER_RESTART_MAX_ATTEMPTS = 5;
61182
61243
  var LISTENER_RESTART_INITIAL_MS = 1e3;
61183
61244
  var LISTENER_RESTART_MAX_MS = 6e4;
@@ -61419,7 +61480,7 @@ async function runListenerSupervisor(options) {
61419
61480
  // before the socket can answer, before any status/event persistence.
61420
61481
  initialize: prepare ? async () => {
61421
61482
  const selected = await prepare(proposedInstanceId);
61422
- if (!selected || typeof selected !== "object" || typeof selected.instanceId !== "string" || !UUID_RE20.test(selected.instanceId)) {
61483
+ if (!selected || typeof selected !== "object" || typeof selected.instanceId !== "string" || !UUID_RE21.test(selected.instanceId)) {
61423
61484
  throw new Error("listener prepare returned an invalid instance id");
61424
61485
  }
61425
61486
  status = { ...status, instanceId: selected.instanceId };
@@ -62129,7 +62190,7 @@ async function waitForListenerReady(paths, options = {}) {
62129
62190
  var import_node_path16 = require("node:path");
62130
62191
  var import_node_util4 = require("node:util");
62131
62192
  init_storage();
62132
- var UUID_RE21 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
62193
+ var UUID_RE22 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
62133
62194
  var COMMAND_ID_RE3 = /^[A-Za-z0-9_-]{8,72}$/;
62134
62195
  var SIGNAL_FINGERPRINT_RE = /^[0-9a-f]{64}$/;
62135
62196
  var MAX_JOURNAL_BYTES = 8192;
@@ -62235,7 +62296,7 @@ var ALLOWED_ERROR_CODES = /* @__PURE__ */ new Set([
62235
62296
  "credential_unavailable"
62236
62297
  ]);
62237
62298
  function claimCommandId(listenerInstanceId, claimOrdinal) {
62238
- if (!UUID_RE21.test(listenerInstanceId)) {
62299
+ if (!UUID_RE22.test(listenerInstanceId)) {
62239
62300
  throw new Error("stored delivery journal is malformed");
62240
62301
  }
62241
62302
  if (!Number.isSafeInteger(claimOrdinal) || claimOrdinal < 0) {
@@ -62250,7 +62311,7 @@ function claimCommandId(listenerInstanceId, claimOrdinal) {
62250
62311
  return id;
62251
62312
  }
62252
62313
  function ackCommandId(leaseId) {
62253
- if (!UUID_RE21.test(leaseId)) {
62314
+ if (!UUID_RE22.test(leaseId)) {
62254
62315
  throw new Error("stored delivery journal is malformed");
62255
62316
  }
62256
62317
  const cleanLease = leaseId.toLowerCase().replace(/-/g, "");
@@ -62333,19 +62394,19 @@ function parseJournalRecord(raw, expectedWorkspaceId, expectedPrincipalId, rejec
62333
62394
  if (row.version !== 1) {
62334
62395
  throw new Error("stored delivery journal is malformed");
62335
62396
  }
62336
- if (typeof row.workspaceId !== "string" || !UUID_RE21.test(row.workspaceId) || row.workspaceId !== row.workspaceId.toLowerCase()) {
62397
+ if (typeof row.workspaceId !== "string" || !UUID_RE22.test(row.workspaceId) || row.workspaceId !== row.workspaceId.toLowerCase()) {
62337
62398
  throw new Error("stored delivery journal is malformed");
62338
62399
  }
62339
62400
  if (expectedWorkspaceId && row.workspaceId !== expectedWorkspaceId.toLowerCase()) {
62340
62401
  throw new Error("stored delivery journal is malformed");
62341
62402
  }
62342
- if (typeof row.principalId !== "string" || !UUID_RE21.test(row.principalId) || row.principalId !== row.principalId.toLowerCase()) {
62403
+ if (typeof row.principalId !== "string" || !UUID_RE22.test(row.principalId) || row.principalId !== row.principalId.toLowerCase()) {
62343
62404
  throw new Error("stored delivery journal is malformed");
62344
62405
  }
62345
62406
  if (expectedPrincipalId && row.principalId !== expectedPrincipalId.toLowerCase()) {
62346
62407
  throw new Error("stored delivery journal is malformed");
62347
62408
  }
62348
- if (typeof row.listenerInstanceId !== "string" || !UUID_RE21.test(row.listenerInstanceId) || row.listenerInstanceId !== row.listenerInstanceId.toLowerCase()) {
62409
+ if (typeof row.listenerInstanceId !== "string" || !UUID_RE22.test(row.listenerInstanceId) || row.listenerInstanceId !== row.listenerInstanceId.toLowerCase()) {
62349
62410
  throw new Error("stored delivery journal is malformed");
62350
62411
  }
62351
62412
  if (!Number.isSafeInteger(row.nextClaimOrdinal) || row.nextClaimOrdinal < 0) {
@@ -62419,10 +62480,10 @@ function parseJournalRecord(raw, expectedWorkspaceId, expectedPrincipalId, rejec
62419
62480
  if (active.claimLastAttemptAt === null) {
62420
62481
  throw new Error("stored delivery journal is malformed");
62421
62482
  }
62422
- if (typeof active.signalId !== "string" || !UUID_RE21.test(active.signalId) || active.signalId !== active.signalId.toLowerCase()) {
62483
+ if (typeof active.signalId !== "string" || !UUID_RE22.test(active.signalId) || active.signalId !== active.signalId.toLowerCase()) {
62423
62484
  throw new Error("stored delivery journal is malformed");
62424
62485
  }
62425
- if (typeof active.leaseId !== "string" || !UUID_RE21.test(active.leaseId) || active.leaseId !== active.leaseId.toLowerCase()) {
62486
+ if (typeof active.leaseId !== "string" || !UUID_RE22.test(active.leaseId) || active.leaseId !== active.leaseId.toLowerCase()) {
62426
62487
  throw new Error("stored delivery journal is malformed");
62427
62488
  }
62428
62489
  if (!isValidIsoTimestamp(active.leasedUntil) || Date.parse(active.leasedUntil) <= Date.parse(active.claimCreatedAt)) {
@@ -62514,7 +62575,7 @@ var FileListenerDeliveryJournal = class {
62514
62575
  ["profileId", "workspaceId", "principalId"],
62515
62576
  "delivery journal configuration rejected"
62516
62577
  );
62517
- if (typeof options.profileId !== "string" || !options.profileId || options.profileId.includes("\0") || typeof options.workspaceId !== "string" || !UUID_RE21.test(options.workspaceId) || typeof options.principalId !== "string" || !UUID_RE21.test(options.principalId)) {
62578
+ if (typeof options.profileId !== "string" || !options.profileId || options.profileId.includes("\0") || typeof options.workspaceId !== "string" || !UUID_RE22.test(options.workspaceId) || typeof options.principalId !== "string" || !UUID_RE22.test(options.principalId)) {
62518
62579
  throw new Error("delivery journal configuration rejected");
62519
62580
  }
62520
62581
  if (options.stateDirectory !== void 0) {
@@ -62628,7 +62689,7 @@ var FileListenerDeliveryJournal = class {
62628
62689
  ["signalId", "leaseId", "leasedUntil"],
62629
62690
  "delivery journal mutation rejected"
62630
62691
  );
62631
- if (typeof input.signalId !== "string" || !UUID_RE21.test(input.signalId) || typeof input.leaseId !== "string" || !UUID_RE21.test(input.leaseId) || !isValidIsoTimestamp(input.leasedUntil) || input.signalFingerprint !== void 0 && (typeof input.signalFingerprint !== "string" || !SIGNAL_FINGERPRINT_RE.test(input.signalFingerprint))) {
62692
+ if (typeof input.signalId !== "string" || !UUID_RE22.test(input.signalId) || typeof input.leaseId !== "string" || !UUID_RE22.test(input.leaseId) || !isValidIsoTimestamp(input.leasedUntil) || input.signalFingerprint !== void 0 && (typeof input.signalFingerprint !== "string" || !SIGNAL_FINGERPRINT_RE.test(input.signalFingerprint))) {
62632
62693
  throw new Error("delivery journal mutation rejected");
62633
62694
  }
62634
62695
  const canonicalSignalId = input.signalId.toLowerCase();
@@ -62760,7 +62821,7 @@ async function openListenerDeliveryJournal(options) {
62760
62821
  ["profileId", "workspaceId", "principalId", "proposedListenerInstanceId"],
62761
62822
  "delivery journal configuration rejected"
62762
62823
  );
62763
- if (typeof options.profileId !== "string" || !options.profileId || options.profileId.includes("\0") || typeof options.workspaceId !== "string" || !UUID_RE21.test(options.workspaceId) || typeof options.principalId !== "string" || !UUID_RE21.test(options.principalId) || typeof options.proposedListenerInstanceId !== "string" || !UUID_RE21.test(options.proposedListenerInstanceId)) {
62824
+ if (typeof options.profileId !== "string" || !options.profileId || options.profileId.includes("\0") || typeof options.workspaceId !== "string" || !UUID_RE22.test(options.workspaceId) || typeof options.principalId !== "string" || !UUID_RE22.test(options.principalId) || typeof options.proposedListenerInstanceId !== "string" || !UUID_RE22.test(options.proposedListenerInstanceId)) {
62764
62825
  throw new Error("delivery journal configuration rejected");
62765
62826
  }
62766
62827
  if (options.stateDirectory !== void 0) {
@@ -62971,7 +63032,7 @@ init_agent_check_budget();
62971
63032
  // src/listener/brain-digest.ts
62972
63033
  var import_node_path18 = require("node:path");
62973
63034
  init_storage();
62974
- var UUID_RE22 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
63035
+ var UUID_RE23 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
62975
63036
  var TOPIC_RE = /^[a-z0-9][a-z0-9._-]*$/;
62976
63037
  var BRAIN_DIGEST_FILE = "brain-digest.json";
62977
63038
  var BRAIN_DIGEST_LOCK = "brain-digest";
@@ -62991,7 +63052,7 @@ function parseState(raw) {
62991
63052
  }
62992
63053
  const row = value;
62993
63054
  const topicVersions = row.topicVersions;
62994
- if (row.version !== 1 || typeof row.principalId !== "string" || !UUID_RE22.test(row.principalId) || !topicVersions || typeof topicVersions !== "object" || Array.isArray(topicVersions) || Object.keys(topicVersions).length > MAX_BRAIN_DIGEST_TOPICS) {
63055
+ if (row.version !== 1 || typeof row.principalId !== "string" || !UUID_RE23.test(row.principalId) || !topicVersions || typeof topicVersions !== "object" || Array.isArray(topicVersions) || Object.keys(topicVersions).length > MAX_BRAIN_DIGEST_TOPICS) {
62995
63056
  throw new Error("stored brain digest state is malformed");
62996
63057
  }
62997
63058
  for (const [topic, version4] of Object.entries(topicVersions)) {
@@ -63034,7 +63095,7 @@ function renderBrainDigest(topicCount, topics) {
63034
63095
  var FileBrainDigestStore = class {
63035
63096
  constructor(instanceDirectory, principalId) {
63036
63097
  this.instanceDirectory = instanceDirectory;
63037
- if (!(0, import_node_path18.isAbsolute)(instanceDirectory) || !UUID_RE22.test(principalId)) {
63098
+ if (!(0, import_node_path18.isAbsolute)(instanceDirectory) || !UUID_RE23.test(principalId)) {
63038
63099
  throw new Error("brain digest state needs an absolute listener directory and principal UUID");
63039
63100
  }
63040
63101
  this.principalId = principalId.toLowerCase();
@@ -63081,7 +63142,7 @@ var FileBrainDigestStore = class {
63081
63142
  };
63082
63143
 
63083
63144
  // src/listener/hook.ts
63084
- var UUID_RE23 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
63145
+ var UUID_RE24 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
63085
63146
  var TOKEN_RE = /^swm_agt_[A-Za-z0-9_-]{43}$/;
63086
63147
  var INSTANCE_KEY_RE = /^[0-9a-f]{64}$/;
63087
63148
  var MAX_HOOK_CREDENTIAL_BYTES = 8 * 1024;
@@ -63146,7 +63207,7 @@ function parseListenerCredential(raw, rejectUnknownKeys = false) {
63146
63207
  throw new Error("stored listener hook credential is malformed");
63147
63208
  }
63148
63209
  const row = value;
63149
- if (!(rejectUnknownKeys ? exactKeys2(row, LISTENER_CREDENTIAL_KEYS) : hasRequiredKeys(row, LISTENER_CREDENTIAL_KEYS)) || row.version !== 1 || typeof row.profileId !== "string" || !/^[0-9a-f]{24}$/.test(row.profileId) || typeof row.targetUrl !== "string" || typeof row.anonKey !== "string" || row.anonKey.length < 1 || row.anonKey.length > 4096 || typeof row.workspaceId !== "string" || !UUID_RE23.test(row.workspaceId) || typeof row.principalId !== "string" || !UUID_RE23.test(row.principalId) || typeof row.credential !== "string" || !TOKEN_RE.test(row.credential) || typeof row.updatedAt !== "string" || !Number.isFinite(Date.parse(row.updatedAt))) {
63210
+ if (!(rejectUnknownKeys ? exactKeys2(row, LISTENER_CREDENTIAL_KEYS) : hasRequiredKeys(row, LISTENER_CREDENTIAL_KEYS)) || row.version !== 1 || typeof row.profileId !== "string" || !/^[0-9a-f]{24}$/.test(row.profileId) || typeof row.targetUrl !== "string" || typeof row.anonKey !== "string" || row.anonKey.length < 1 || row.anonKey.length > 4096 || typeof row.workspaceId !== "string" || !UUID_RE24.test(row.workspaceId) || typeof row.principalId !== "string" || !UUID_RE24.test(row.principalId) || typeof row.credential !== "string" || !TOKEN_RE.test(row.credential) || typeof row.updatedAt !== "string" || !Number.isFinite(Date.parse(row.updatedAt))) {
63150
63211
  throw new Error("stored listener hook credential is malformed");
63151
63212
  }
63152
63213
  const target2 = cloudTarget(row.targetUrl, row.anonKey);
@@ -63204,7 +63265,7 @@ function parseSurface(raw, rejectUnknownKeys = false) {
63204
63265
  throw new Error("stored listener hook surface state is malformed");
63205
63266
  }
63206
63267
  const row = value;
63207
- if (rejectUnknownKeys && Object.keys(row).some((key2) => !HOOK_SURFACE_KEYS.has(key2)) || row.version !== 1 || !Array.isArray(row.surfacedSignalIds) || row.surfacedSignalIds.length > HOOK_SURFACED_IDS_MAX || row.surfacedSignalIds.some((id) => typeof id !== "string" || !UUID_RE23.test(id)) || !(row.reportedDroppedCount === void 0 || typeof row.reportedDroppedCount === "number" && Number.isSafeInteger(row.reportedDroppedCount) && row.reportedDroppedCount >= 0) || !(row.credentialFailureReported === void 0 || typeof row.credentialFailureReported === "boolean")) {
63268
+ if (rejectUnknownKeys && Object.keys(row).some((key2) => !HOOK_SURFACE_KEYS.has(key2)) || row.version !== 1 || !Array.isArray(row.surfacedSignalIds) || row.surfacedSignalIds.length > HOOK_SURFACED_IDS_MAX || row.surfacedSignalIds.some((id) => typeof id !== "string" || !UUID_RE24.test(id)) || !(row.reportedDroppedCount === void 0 || typeof row.reportedDroppedCount === "number" && Number.isSafeInteger(row.reportedDroppedCount) && row.reportedDroppedCount >= 0) || !(row.credentialFailureReported === void 0 || typeof row.credentialFailureReported === "boolean")) {
63208
63269
  throw new Error("stored listener hook surface state is malformed");
63209
63270
  }
63210
63271
  const ids = row.surfacedSignalIds.map((id) => String(id).toLowerCase());
@@ -63235,7 +63296,7 @@ var FileHookSurfaceStore = class {
63235
63296
  const unseen = [];
63236
63297
  for (const item of items) {
63237
63298
  const signalId = item.signalId.toLowerCase();
63238
- if (!UUID_RE23.test(signalId) || seen.has(signalId)) continue;
63299
+ if (!UUID_RE24.test(signalId) || seen.has(signalId)) continue;
63239
63300
  seen.add(signalId);
63240
63301
  unseen.push(item);
63241
63302
  }
@@ -63266,7 +63327,7 @@ var FileHookSurfaceStore = class {
63266
63327
  const unseen = [];
63267
63328
  for (const item of items) {
63268
63329
  const signalId = item.signalId.toLowerCase();
63269
- if (!UUID_RE23.test(signalId) || seen.has(signalId)) continue;
63330
+ if (!UUID_RE24.test(signalId) || seen.has(signalId)) continue;
63270
63331
  seen.add(signalId);
63271
63332
  unseen.push(item);
63272
63333
  }
@@ -63289,7 +63350,7 @@ var FileHookSurfaceStore = class {
63289
63350
  const seen = new Set(state.surfacedSignalIds);
63290
63351
  for (const signalId of options.signalIds ?? []) {
63291
63352
  const checked = signalId.toLowerCase();
63292
- if (UUID_RE23.test(checked)) seen.add(checked);
63353
+ if (UUID_RE24.test(checked)) seen.add(checked);
63293
63354
  }
63294
63355
  await writeSecureJsonFile(
63295
63356
  this.path,
@@ -63418,7 +63479,7 @@ async function discoverContexts(stateDirectory2, principalIds, isListenerLive =
63418
63479
  }
63419
63480
  selectedPrincipals = availablePrincipals;
63420
63481
  } else {
63421
- if (principalIds.some((principalId) => !UUID_RE23.test(principalId))) {
63482
+ if (principalIds.some((principalId) => !UUID_RE24.test(principalId))) {
63422
63483
  return { contexts: [], requiresPrincipalScope: false };
63423
63484
  }
63424
63485
  selectedPrincipals = new Set(principalIds.map((principalId) => principalId.toLowerCase()));
@@ -65669,10 +65730,10 @@ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
65669
65730
  "write",
65670
65731
  "allow-duplicate-name"
65671
65732
  ]);
65672
- var UUID_RE24 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
65733
+ var UUID_RE25 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
65673
65734
  function packageVersion() {
65674
- if ("0.1.76".length > 0) {
65675
- return "0.1.76";
65735
+ if ("0.1.77".length > 0) {
65736
+ return "0.1.77";
65676
65737
  }
65677
65738
  try {
65678
65739
  const value = JSON.parse(
@@ -66491,7 +66552,7 @@ async function workspaceId(args, cloud, human, options = {}) {
66491
66552
  warn: options.warn ?? writeWorkspaceWarning
66492
66553
  });
66493
66554
  }
66494
- function uuid7(value, field) {
66555
+ function uuid8(value, field) {
66495
66556
  if (value === void 0 || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value)) {
66496
66557
  throw new Error(`server returned a malformed ${field}`);
66497
66558
  }
@@ -66596,7 +66657,7 @@ async function runNew(args) {
66596
66657
  throw error2;
66597
66658
  }
66598
66659
  const response = acceptedConnect("workspace creation", result);
66599
- const created = uuid7(response.workspace_id, "workspace_id");
66660
+ const created = uuid8(response.workspace_id, "workspace_id");
66600
66661
  if (created !== proposedId) {
66601
66662
  throw new Error(
66602
66663
  "the server confirmed a different workspace than this command created; run cswarm workspaces before doing anything else"
@@ -66612,7 +66673,7 @@ async function runNew(args) {
66612
66673
  project: {
66613
66674
  workspace_id: created,
66614
66675
  name,
66615
- stream_id: typeof response.stream_id === "string" && UUID_RE24.test(response.stream_id) ? response.stream_id : null
66676
+ stream_id: typeof response.stream_id === "string" && UUID_RE25.test(response.stream_id) ? response.stream_id : null
66616
66677
  }
66617
66678
  });
66618
66679
  return;
@@ -66885,7 +66946,7 @@ async function runInvite(args) {
66885
66946
  );
66886
66947
  }
66887
66948
  assertInvitationToken(response.invitation_token);
66888
- const responseWorkspaceId = uuid7(response.workspace_id, "workspace_id");
66949
+ const responseWorkspaceId = uuid8(response.workspace_id, "workspace_id");
66889
66950
  if (typeof response.workspace_name !== "string" || typeof response.inviter_display_name !== "string") {
66890
66951
  throw new Error(
66891
66952
  "the invitation was created without its fresh display labels; run invite again to issue a complete link"
@@ -66905,7 +66966,7 @@ async function runInvite(args) {
66905
66966
  printJson({
66906
66967
  message: "Invitation created. Share the one-time link below with its intended recipient. It can be accepted once before it expires; use a GitHub account with a distinct verified email for a second person.",
66907
66968
  status: response.status,
66908
- invitation_id: uuid7(response.invitation_id, "invitation_id"),
66969
+ invitation_id: uuid8(response.invitation_id, "invitation_id"),
66909
66970
  invite_link: inviteLink
66910
66971
  });
66911
66972
  }
@@ -67017,7 +67078,7 @@ async function runLegacyAccept(args) {
67017
67078
  { kind: "accept_invitation", token: invitationToken }
67018
67079
  )
67019
67080
  );
67020
- const acceptedWorkspace = uuid7(response.workspace_id, "workspace_id");
67081
+ const acceptedWorkspace = uuid8(response.workspace_id, "workspace_id");
67021
67082
  await writeWorkspaceDefault(human.store, human.userId, acceptedWorkspace);
67022
67083
  await writeCurrentTarget(cloud);
67023
67084
  printJson({
@@ -67170,7 +67231,7 @@ async function runPrincipal(args) {
67170
67231
  "Agent identity created. It makes this machine's agent auditable inside the shared workspace. Its name is visible to everyone in the workspace, so avoid naming it after anything private."
67171
67232
  ),
67172
67233
  status: response.status,
67173
- principal_id: uuid7(response.principal_id, "principal_id")
67234
+ principal_id: uuid8(response.principal_id, "principal_id")
67174
67235
  });
67175
67236
  return;
67176
67237
  }
@@ -67297,8 +67358,8 @@ async function runToken(args) {
67297
67358
  );
67298
67359
  printJson(agentCredentialArtifact({
67299
67360
  principalId,
67300
- tokenId: uuid7(response.token_id, "token_id"),
67301
- runId: uuid7(response.run_id, "run_id"),
67361
+ tokenId: uuid8(response.token_id, "token_id"),
67362
+ runId: uuid8(response.run_id, "run_id"),
67302
67363
  token: response.agent_token,
67303
67364
  expiresAt
67304
67365
  }));
@@ -67452,7 +67513,7 @@ async function runLinkNew(args) {
67452
67513
  2
67453
67514
  );
67454
67515
  const taskId = args.required("task-id");
67455
- if (!UUID_RE24.test(taskId)) {
67516
+ if (!UUID_RE25.test(taskId)) {
67456
67517
  throw new Error("--task-id must be the work item's UUID");
67457
67518
  }
67458
67519
  const site = capabilitySiteOrigin(
@@ -67482,11 +67543,11 @@ async function runLinkNew(args) {
67482
67543
  );
67483
67544
  if (response.capability_token === void 0) {
67484
67545
  throw new Error(
67485
- `this link was created on a prior attempt, and its credential is shown only in a fresh response \u2014 the server keeps just a hash, so it cannot be shown again; run cswarm link new to issue another, then run cswarm link revoke --capability-id ${uuid7(response.capability_id, "capability_id")} to withdraw the one you cannot see`
67546
+ `this link was created on a prior attempt, and its credential is shown only in a fresh response \u2014 the server keeps just a hash, so it cannot be shown again; run cswarm link new to issue another, then run cswarm link revoke --capability-id ${uuid8(response.capability_id, "capability_id")} to withdraw the one you cannot see`
67486
67547
  );
67487
67548
  }
67488
67549
  assertCapabilityToken(response.capability_token);
67489
- const capabilityId = uuid7(response.capability_id, "capability_id");
67550
+ const capabilityId = uuid8(response.capability_id, "capability_id");
67490
67551
  const expiresAt = capabilityTimestamp(response.expires_at, "expires_at");
67491
67552
  const url = capabilityUrl(site, response.capability_token);
67492
67553
  if (args.has("json")) {
@@ -67512,7 +67573,7 @@ async function runLinkRevoke(args) {
67512
67573
  2
67513
67574
  );
67514
67575
  const capabilityId = args.required("capability-id");
67515
- if (!UUID_RE24.test(capabilityId)) {
67576
+ if (!UUID_RE25.test(capabilityId)) {
67516
67577
  throw new Error(
67517
67578
  "--capability-id must be the id printed when the link was created"
67518
67579
  );
@@ -67530,7 +67591,7 @@ async function runLinkRevoke(args) {
67530
67591
  { kind: "revoke_capability_url", capability_id: capabilityId }
67531
67592
  )
67532
67593
  );
67533
- const revoked = uuid7(response.capability_id, "capability_id");
67594
+ const revoked = uuid8(response.capability_id, "capability_id");
67534
67595
  const revokedAt = capabilityTimestamp(response.revoked_at, "revoked_at");
67535
67596
  const message = renderCapabilityRevoke(revoked, revokedAt);
67536
67597
  if (args.has("json")) {
@@ -68241,7 +68302,7 @@ async function runReply(args) {
68241
68302
  );
68242
68303
  }
68243
68304
  const signalId = args.positionals[1];
68244
- if (signalId === void 0 || !UUID_RE24.test(signalId)) {
68305
+ if (signalId === void 0 || !UUID_RE25.test(signalId)) {
68245
68306
  throw new Error("reply requires the signal UUID being answered");
68246
68307
  }
68247
68308
  const body2 = await resolveSignalBody(args, 2, allowedFlags);
@@ -68341,7 +68402,7 @@ function workspaceLabel(directory) {
68341
68402
  function renderWorkspace(id, name) {
68342
68403
  return name === null ? id : `${name} (${id})`;
68343
68404
  }
68344
- function renderRoster(directory, memberNames, workspace) {
68405
+ function renderRoster(directory, memberNames, workspace, pending = []) {
68345
68406
  const lines = [];
68346
68407
  if (workspace !== void 0) {
68347
68408
  lines.push(`Workspace: ${renderWorkspace(workspace.workspaceId, workspace.workspaceName)}`);
@@ -68369,6 +68430,15 @@ function renderRoster(directory, memberNames, workspace) {
68369
68430
  );
68370
68431
  }
68371
68432
  lines.push("");
68433
+ lines.push(pending === null ? "Invited, not connected: could not load" : "Invited, not connected:");
68434
+ if (pending !== null && pending.length === 0) lines.push("- none yet");
68435
+ for (const entry2 of pending ?? []) {
68436
+ const name = entry2.kind === "classic" ? sanitizeDisplayLabel(entry2.principal_name ?? "", "Unnamed agent") : "Agent connect code";
68437
+ const id = entry2.principal_id ?? entry2.join_credential_id;
68438
+ const seats = entry2.kind === "join" ? ` \xB7 ${entry2.seats_used}/${entry2.seat_cap} seats used \xB7 issued by ${sanitizeDisplayLabel(entry2.issuer_display, "Workspace member")}` : "";
68439
+ lines.push(`- ${name} (${id}) \xB7 ${pendingAccessAge(entry2.issued_at)}${seats}`);
68440
+ }
68441
+ lines.push("");
68372
68442
  lines.push('Address an agent by the id in brackets: cswarm ask "\u2026" --to <id>');
68373
68443
  return `${lines.join("\n")}
68374
68444
  `;
@@ -68390,6 +68460,12 @@ async function runMembers(args) {
68390
68460
  selected.selectedWorkspace,
68391
68461
  selected
68392
68462
  );
68463
+ const pending = await readPendingAccessOptional(
68464
+ cloud,
68465
+ selected.bearer,
68466
+ selected.selectedWorkspace,
68467
+ selected.fetcher
68468
+ );
68393
68469
  const memberNames = new Map(
68394
68470
  directory.members.map((member) => [
68395
68471
  member.user_id,
@@ -68415,7 +68491,9 @@ async function runMembers(args) {
68415
68491
  * it. Report null rather than inventing an owner. */
68416
68492
  owner_user_id: agent.owner_user_id ?? null,
68417
68493
  owner_name: agent.owner_user_id === void 0 ? null : memberNames.get(agent.owner_user_id) ?? null
68418
- }))
68494
+ })),
68495
+ pending,
68496
+ ...pending === null ? { pending_error: "could not load" } : {}
68419
68497
  },
68420
68498
  null,
68421
68499
  2
@@ -68427,7 +68505,7 @@ async function runMembers(args) {
68427
68505
  process.stdout.write(renderRoster(directory, memberNames, {
68428
68506
  workspaceId: selected.selectedWorkspace,
68429
68507
  workspaceName: workspaceLabel(directory)
68430
- }));
68508
+ }, pending));
68431
68509
  }
68432
68510
  async function runWhoami(args) {
68433
68511
  args.assertShape([
@@ -68877,7 +68955,7 @@ async function runReceipt(args) {
68877
68955
  ...SESSION_CONTEXT_FLAGS
68878
68956
  ], 2);
68879
68957
  const signalId = args.positionals[1];
68880
- if (!UUID_RE24.test(signalId)) {
68958
+ if (!UUID_RE25.test(signalId)) {
68881
68959
  throw new Error("signal-id must be a UUID");
68882
68960
  }
68883
68961
  if (!hasAgentCredential(args)) {
@@ -69037,7 +69115,7 @@ async function runInboxFollowCommand(args) {
69037
69115
  }
69038
69116
  }
69039
69117
  function listenerUuid(value, flag) {
69040
- if (!value || !UUID_RE24.test(value)) {
69118
+ if (!value || !UUID_RE25.test(value)) {
69041
69119
  throw new Error(`--${flag} must be a UUID`);
69042
69120
  }
69043
69121
  return value.toLowerCase();
@@ -70710,7 +70788,7 @@ async function runSession(args) {
70710
70788
  const human = await humanCredential(args, cloud2);
70711
70789
  const workspace = await workspaceId(args, cloud2, human);
70712
70790
  const principalId = args.required("principal-id");
70713
- if (!UUID_RE24.test(principalId)) {
70791
+ if (!UUID_RE25.test(principalId)) {
70714
70792
  throw new Error("--principal-id must be a UUID");
70715
70793
  }
70716
70794
  const result2 = await runHumanSessionLifecycle(action, {
@@ -71183,7 +71261,7 @@ async function runHook(args) {
71183
71261
  if (command2 === "check") {
71184
71262
  args.assertShape(["cooldown", "principal-id"], 2);
71185
71263
  const rawPrincipalIds = args.all("principal-id");
71186
- if (rawPrincipalIds.some((principalId2) => !UUID_RE24.test(principalId2))) return;
71264
+ if (rawPrincipalIds.some((principalId2) => !UUID_RE25.test(principalId2))) return;
71187
71265
  const principalIds = rawPrincipalIds.map((principalId2) => principalId2.toLowerCase());
71188
71266
  const rawCooldown = args.optional("cooldown");
71189
71267
  const cooldownSeconds = rawCooldown === void 0 ? void 0 : Number(rawCooldown);
@@ -71311,7 +71389,7 @@ async function fileRows(context) {
71311
71389
  );
71312
71390
  }
71313
71391
  async function resolveFileSelector(context, selector) {
71314
- if (UUID_RE24.test(selector)) return selector.toLowerCase();
71392
+ if (UUID_RE25.test(selector)) return selector.toLowerCase();
71315
71393
  const rows3 = await fileRows(context);
71316
71394
  const match = rows3.find(
71317
71395
  (row) => row.name.toLowerCase() === selector.toLowerCase()
@@ -71757,7 +71835,7 @@ async function channelRows(context) {
71757
71835
  }
71758
71836
  }
71759
71837
  function channelSelectorKind(selector) {
71760
- if (UUID_RE24.test(selector)) return "id";
71838
+ if (UUID_RE25.test(selector)) return "id";
71761
71839
  const problem = channelSelectorProblem(selector);
71762
71840
  if (problem !== null) throw new Error(problem);
71763
71841
  return "name";