@ariobarin/glossa 0.2.0-beta.1 → 0.2.0-beta.2

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/dist/app.js +73 -86
  2. package/package.json +1 -1
package/dist/app.js CHANGED
@@ -52027,6 +52027,14 @@ var DeviceRejectedError = class extends Error {
52027
52027
  this.name = "DeviceRejectedError";
52028
52028
  }
52029
52029
  };
52030
+ var RelayAccessProfileUnsupportedError = class extends Error {
52031
+ constructor(profile) {
52032
+ super(
52033
+ `The relay needs an update before it can represent ${profile} access. Update the relay before reconnecting this workspace.`
52034
+ );
52035
+ this.name = "RelayAccessProfileUnsupportedError";
52036
+ }
52037
+ };
52030
52038
  var RelayResponseError = class extends Error {
52031
52039
  constructor(status) {
52032
52040
  super(`The relay returned HTTP ${status}.`);
@@ -52166,7 +52174,9 @@ var RemoteWorker = class {
52166
52174
  await this.#pollGeneration(session);
52167
52175
  } catch (error46) {
52168
52176
  if (this.#signal.aborted) return;
52169
- if (error46 instanceof DeviceRejectedError) throw error46;
52177
+ if (error46 instanceof DeviceRejectedError || error46 instanceof RelayAccessProfileUnsupportedError) {
52178
+ throw error46;
52179
+ }
52170
52180
  const delay4 = reconnectDelayMs(
52171
52181
  failures,
52172
52182
  this.#random,
@@ -52224,100 +52234,74 @@ var RemoteWorker = class {
52224
52234
  workerId: this.#workerId,
52225
52235
  capabilities: { commandProgress: true, concurrentJobs: true }
52226
52236
  };
52227
- const versionedCurrentBody = this.#workerVersion ? { ...currentBody, workerVersion: this.#workerVersion } : void 0;
52228
- const versionedMutationBody = this.#workerVersion ? { ...mutationBody, workerVersion: this.#workerVersion } : void 0;
52229
- const versionedStructuredBody = this.#workerVersion ? { ...structuredBody, workerVersion: this.#workerVersion } : void 0;
52230
- const preferredProfileBody = this.#accessProfile ? {
52231
- ...versionedCurrentBody ?? currentBody,
52232
- accessProfile: this.#accessProfile,
52233
- ...this.#workspaceLabel ? { workspaceLabel: this.#workspaceLabel } : {}
52234
- } : void 0;
52235
- const attempts = [
52236
- ...preferredProfileBody ? [{ body: preferredProfileBody, legacyRelay: false }] : [],
52237
- ...versionedCurrentBody && this.#workspaceLabel ? [{
52238
- body: {
52239
- ...versionedCurrentBody,
52240
- workspaceLabel: this.#workspaceLabel
52241
- },
52242
- legacyRelay: false
52243
- }] : [],
52244
- ...this.#workspaceLabel ? [{
52245
- body: {
52246
- ...currentBody,
52247
- workspaceLabel: this.#workspaceLabel
52248
- },
52249
- legacyRelay: false
52250
- }] : [],
52251
- ...versionedCurrentBody ? [{ body: versionedCurrentBody, legacyRelay: false }] : [],
52237
+ const capabilityBodies = [
52238
+ currentBody,
52239
+ mutationBody,
52240
+ structuredBody,
52241
+ concurrentBody,
52252
52242
  {
52253
- body: currentBody,
52254
- legacyRelay: false
52255
- },
52256
- ...versionedMutationBody && this.#workspaceLabel ? [{
52257
- body: {
52258
- ...versionedMutationBody,
52259
- workspaceLabel: this.#workspaceLabel
52260
- },
52261
- legacyRelay: false
52262
- }] : [],
52263
- ...this.#workspaceLabel ? [{
52264
- body: {
52265
- ...mutationBody,
52266
- workspaceLabel: this.#workspaceLabel
52267
- },
52268
- legacyRelay: false
52269
- }] : [],
52270
- ...versionedMutationBody ? [{ body: versionedMutationBody, legacyRelay: false }] : [],
52271
- {
52272
- body: mutationBody,
52273
- legacyRelay: false
52243
+ workerId: this.#workerId,
52244
+ capabilities: { commandProgress: true }
52274
52245
  },
52275
- ...versionedStructuredBody && this.#workspaceLabel ? [{
52276
- body: {
52277
- ...versionedStructuredBody,
52278
- workspaceLabel: this.#workspaceLabel
52279
- },
52280
- legacyRelay: false
52281
- }] : [],
52282
- ...this.#workspaceLabel ? [{
52283
- body: {
52284
- ...structuredBody,
52285
- workspaceLabel: this.#workspaceLabel
52286
- },
52287
- legacyRelay: false
52288
- }] : [],
52289
- ...versionedStructuredBody ? [{ body: versionedStructuredBody, legacyRelay: false }] : [],
52246
+ { workerId: this.#workerId }
52247
+ ];
52248
+ const metadataPhases = [
52290
52249
  {
52291
- body: structuredBody,
52292
- legacyRelay: false
52250
+ includeVersion: Boolean(this.#workerVersion),
52251
+ includeLabel: Boolean(this.#workspaceLabel)
52293
52252
  },
52294
52253
  ...this.#workspaceLabel ? [{
52295
- body: {
52296
- ...concurrentBody,
52297
- workspaceLabel: this.#workspaceLabel
52298
- },
52299
- legacyRelay: false
52254
+ includeVersion: Boolean(this.#workerVersion),
52255
+ includeLabel: false
52300
52256
  }] : [],
52301
- {
52302
- body: concurrentBody,
52303
- legacyRelay: false
52304
- },
52305
- {
52306
- body: {
52307
- workerId: this.#workerId,
52308
- capabilities: { commandProgress: true }
52309
- },
52310
- legacyRelay: false
52311
- },
52312
- { body: { workerId: this.#workerId }, legacyRelay: false },
52313
- { body: {}, legacyRelay: true }
52257
+ ...this.#workerVersion && this.#workspaceLabel ? [{ includeVersion: false, includeLabel: true }] : [],
52258
+ { includeVersion: false, includeLabel: false }
52314
52259
  ];
52315
- for (const [index, attempt] of attempts.entries()) {
52260
+ const attempts = [];
52261
+ const seenAttempts = /* @__PURE__ */ new Set();
52262
+ const pushAttempt = (base, includeProfile, includeVersion, includeLabel, legacyRelay = false) => {
52263
+ const body = {
52264
+ ...base,
52265
+ ...includeProfile && this.#accessProfile ? { accessProfile: this.#accessProfile } : {},
52266
+ ...includeVersion && this.#workerVersion ? { workerVersion: this.#workerVersion } : {},
52267
+ ...includeLabel && this.#workspaceLabel ? { workspaceLabel: this.#workspaceLabel } : {}
52268
+ };
52269
+ const key = JSON.stringify(body);
52270
+ if (seenAttempts.has(key)) return;
52271
+ seenAttempts.add(key);
52272
+ attempts.push({ body, legacyRelay, profileIncluded: includeProfile });
52273
+ };
52274
+ if (this.#accessProfile) {
52275
+ for (const metadata of metadataPhases) {
52276
+ for (const body of capabilityBodies) {
52277
+ pushAttempt(
52278
+ body,
52279
+ true,
52280
+ metadata.includeVersion,
52281
+ metadata.includeLabel
52282
+ );
52283
+ }
52284
+ }
52285
+ }
52286
+ if (this.#accessProfile === void 0 || this.#accessProfile === "system") {
52287
+ for (const metadata of metadataPhases) {
52288
+ for (const body of capabilityBodies) {
52289
+ pushAttempt(
52290
+ body,
52291
+ false,
52292
+ metadata.includeVersion,
52293
+ metadata.includeLabel
52294
+ );
52295
+ }
52296
+ }
52297
+ attempts.push({ body: {}, legacyRelay: true, profileIncluded: false });
52298
+ }
52299
+ for (const attempt of attempts) {
52316
52300
  let response;
52317
52301
  try {
52318
52302
  response = await this.#post("/device/register", attempt.body);
52319
52303
  } catch (error46) {
52320
- if (error46 instanceof RelayResponseError && error46.status === 400 && index < attempts.length - 1) {
52304
+ if (error46 instanceof RelayResponseError && error46.status === 400) {
52321
52305
  continue;
52322
52306
  }
52323
52307
  throw error46;
@@ -52337,11 +52321,14 @@ var RemoteWorker = class {
52337
52321
  structuredReads: !attempt.legacyRelay && supportsCapability(value, "structuredReads"),
52338
52322
  structuredMutations: !attempt.legacyRelay && supportsCapability(value, "structuredMutations"),
52339
52323
  commandOutputRanges: !attempt.legacyRelay && supportsCapability(value, "commandOutputRanges"),
52340
- accessProfileAccepted: this.#accessProfile === void 0 || "accessProfile" in value && value.accessProfile === this.#accessProfile,
52324
+ accessProfileAccepted: this.#accessProfile === void 0 || "accessProfile" in value && value.accessProfile === this.#accessProfile || this.#accessProfile === "system" && !attempt.profileIncluded,
52341
52325
  workspaceLabelAccepted: this.#workspaceLabel === void 0 || "workspaceLabel" in value && value.workspaceLabel === this.#workspaceLabel,
52342
52326
  ...workerToken ? { workerToken } : {}
52343
52327
  };
52344
52328
  }
52329
+ if (this.#accessProfile && this.#accessProfile !== "system") {
52330
+ throw new RelayAccessProfileUnsupportedError(this.#accessProfile);
52331
+ }
52345
52332
  throw new Error("The relay rejected every supported registration shape.");
52346
52333
  }
52347
52334
  async #pollGeneration(session) {
@@ -54677,7 +54664,7 @@ async function acquireWorkspaceLease(root, options = {}) {
54677
54664
  }
54678
54665
 
54679
54666
  // src/main.ts
54680
- var VERSION = "0.2.0-beta.1";
54667
+ var VERSION = "0.2.0-beta.2";
54681
54668
  var DISTRIBUTION = "npm";
54682
54669
  var HELP = `Glossa ${VERSION}
54683
54670
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariobarin/glossa",
3
- "version": "0.2.0-beta.1",
3
+ "version": "0.2.0-beta.2",
4
4
  "private": false,
5
5
  "description": "Connect an explicitly exposed local coding workspace to the Glossa MCP relay.",
6
6
  "type": "module",