@meshagent/meshagent-ts-auth 0.38.2 → 0.38.4

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [0.38.4]
2
+ - Stability
3
+
4
+ ## [0.38.3]
5
+ - Breaking: TypeScript container image summaries now use `references`/`preferredRef` and metadata fields (timestamps/media type), and `inspectImage` returns manifests/layers/content size; `tags`/`size` are removed.
6
+ - `getUsage` now supports filters for users, room, provider, model, and usage type.
7
+ - Room connection and errors improved: `RoomServerException` now carries `statusCode` and `retryable`, and `RoomClient` can route OAuth/secret requests via handler options.
8
+ - React hooks add robust connection retry/backoff, new authorization helpers, and optional secret/OAuth handlers; document connection now supports schema/initial JSON and improved cleanup.
9
+ - New Livekit support (client + protocol channel) and room participant hook; hosted toolkits are now shared per room to avoid duplicate starts.
10
+ - Breaking: `meshagent-react` no longer exports the legacy chat and file-upload modules.
11
+ - Tailwind chat UI is rebuilt with multi-thread support, new thread creation via agent tools, and file attachment utilities, with new exports for thread and conversation helpers.
12
+
1
13
  ## [0.38.2]
2
14
  - Stability
3
15
 
@@ -9880,10 +9880,12 @@ ${err.toString()}`);
9880
9880
 
9881
9881
  // ../meshagent-ts/dist/esm/room-server-client.js
9882
9882
  var RoomServerException = class extends Error {
9883
- constructor(message, code) {
9883
+ constructor(message, code, { statusCode, retryable = false } = {}) {
9884
9884
  super(message);
9885
9885
  this.name = "RoomServerException";
9886
+ this.statusCode = statusCode;
9886
9887
  this.code = code;
9888
+ this.retryable = retryable;
9887
9889
  }
9888
9890
  };
9889
9891
  var MeshDocument = class extends RuntimeDocument {
@@ -10360,6 +10362,30 @@ ${err.toString()}`);
10360
10362
  }
10361
10363
  return value;
10362
10364
  }
10365
+ function readOptionalStringField(data, field, operation) {
10366
+ const value = data[field];
10367
+ if (value === void 0 || value === null) {
10368
+ return void 0;
10369
+ }
10370
+ if (typeof value !== "string") {
10371
+ throw new RoomServerException(`unexpected return type from containers.${operation}`);
10372
+ }
10373
+ return value;
10374
+ }
10375
+ function parseTimestampField(data, field, operation) {
10376
+ const value = data[field];
10377
+ if (value === void 0 || value === null) {
10378
+ return void 0;
10379
+ }
10380
+ if (typeof value !== "string") {
10381
+ throw new RoomServerException(`unexpected return type from containers.${operation}`);
10382
+ }
10383
+ const timestamp = new Date(value);
10384
+ if (Number.isNaN(timestamp.getTime())) {
10385
+ throw new RoomServerException(`unexpected return type from containers.${operation}`);
10386
+ }
10387
+ return timestamp;
10388
+ }
10363
10389
  function decodeUtf8(data, operation) {
10364
10390
  try {
10365
10391
  return new TextDecoder("utf-8", { fatal: true }).decode(data);
@@ -10415,6 +10441,98 @@ ${err.toString()}`);
10415
10441
  }
10416
10442
  throw new RoomServerException(`unexpected return type from containers.${operation}`);
10417
10443
  }
10444
+ function normalizeImageReferences(entry, operation) {
10445
+ const referencesRaw = entry["references"];
10446
+ if (Array.isArray(referencesRaw)) {
10447
+ const references = referencesRaw.filter((item) => typeof item === "string");
10448
+ if (references.length !== referencesRaw.length) {
10449
+ throw new RoomServerException(`unexpected return type from containers.${operation}`);
10450
+ }
10451
+ return references;
10452
+ }
10453
+ const tagsRaw = entry["tags"];
10454
+ if (Array.isArray(tagsRaw)) {
10455
+ const references = tagsRaw.filter((item) => typeof item === "string");
10456
+ if (references.length !== tagsRaw.length) {
10457
+ throw new RoomServerException(`unexpected return type from containers.${operation}`);
10458
+ }
10459
+ return references;
10460
+ }
10461
+ if (referencesRaw === void 0 || referencesRaw === null) {
10462
+ return [];
10463
+ }
10464
+ throw new RoomServerException(`unexpected return type from containers.${operation}`);
10465
+ }
10466
+ function parseContainerImage(entry, operation) {
10467
+ const references = normalizeImageReferences(entry, operation);
10468
+ const preferredRef = readOptionalStringField(entry, "preferred_ref", operation) ?? references[0];
10469
+ return {
10470
+ id: readStringField(entry, "id", operation),
10471
+ preferredRef,
10472
+ references,
10473
+ labels: normalizeImageLabels(entry["labels"], operation),
10474
+ createdAt: parseTimestampField(entry, "created_at", operation),
10475
+ updatedAt: parseTimestampField(entry, "updated_at", operation),
10476
+ targetMediaType: readOptionalStringField(entry, "target_media_type", operation)
10477
+ };
10478
+ }
10479
+ function parseContainerImageDescriptor(entry, operation) {
10480
+ return {
10481
+ digest: readStringField(entry, "digest", operation),
10482
+ mediaType: readOptionalStringField(entry, "media_type", operation),
10483
+ size: readOptionalIntegerField(entry, "size", operation),
10484
+ annotations: normalizeImageLabels(entry["annotations"], operation)
10485
+ };
10486
+ }
10487
+ function parseOptionalContainerImageDescriptor(value, operation) {
10488
+ if (value === void 0 || value === null) {
10489
+ return void 0;
10490
+ }
10491
+ if (!isRecord2(value)) {
10492
+ throw new RoomServerException(`unexpected return type from containers.${operation}`);
10493
+ }
10494
+ return parseContainerImageDescriptor(value, operation);
10495
+ }
10496
+ function parseContainerImageManifest(entry, operation) {
10497
+ const descriptorRaw = entry["descriptor"];
10498
+ if (!isRecord2(descriptorRaw)) {
10499
+ throw new RoomServerException(`unexpected return type from containers.${operation}`);
10500
+ }
10501
+ return {
10502
+ descriptor: parseContainerImageDescriptor(descriptorRaw, operation),
10503
+ platformOs: readOptionalStringField(entry, "platform_os", operation),
10504
+ platformArchitecture: readOptionalStringField(entry, "platform_architecture", operation),
10505
+ platformVariant: readOptionalStringField(entry, "platform_variant", operation)
10506
+ };
10507
+ }
10508
+ function parseContainerImageInspection(entry, operation) {
10509
+ const imageRaw = entry["image"];
10510
+ const targetRaw = entry["target"];
10511
+ const manifestsRaw = entry["manifests"];
10512
+ const layersRaw = entry["layers"];
10513
+ if (!isRecord2(imageRaw) || !isRecord2(targetRaw) || !Array.isArray(manifestsRaw) || !Array.isArray(layersRaw)) {
10514
+ throw new RoomServerException(`unexpected return type from containers.${operation}`);
10515
+ }
10516
+ return {
10517
+ image: parseContainerImage(imageRaw, operation),
10518
+ target: parseContainerImageDescriptor(targetRaw, operation),
10519
+ selectedManifest: parseOptionalContainerImageDescriptor(entry["selected_manifest"], operation),
10520
+ manifests: manifestsRaw.map((manifest) => {
10521
+ if (!isRecord2(manifest)) {
10522
+ throw new RoomServerException(`unexpected return type from containers.${operation}`);
10523
+ }
10524
+ return parseContainerImageManifest(manifest, operation);
10525
+ }),
10526
+ config: parseOptionalContainerImageDescriptor(entry["config"], operation),
10527
+ layers: layersRaw.map((layer) => {
10528
+ if (!isRecord2(layer)) {
10529
+ throw new RoomServerException(`unexpected return type from containers.${operation}`);
10530
+ }
10531
+ return parseContainerImageDescriptor(layer, operation);
10532
+ }),
10533
+ contentSize: readOptionalIntegerField(entry, "content_size", operation)
10534
+ };
10535
+ }
10418
10536
  function parseImportedImage(data, operation) {
10419
10537
  const resolvedRef = data["resolved_ref"];
10420
10538
  const refsRaw = data["refs"];
@@ -10608,23 +10726,19 @@ ${err.toString()}`);
10608
10726
  if (!isRecord2(entry)) {
10609
10727
  throw this.unexpectedResponseError("list_images");
10610
10728
  }
10611
- const id2 = entry["id"];
10612
- const tags = entry["tags"];
10613
- const labelsRaw = entry["labels"];
10614
- if (typeof id2 !== "string" || !Array.isArray(tags)) {
10615
- throw this.unexpectedResponseError("list_images");
10616
- }
10617
- const normalizedTags = tags.filter((tag) => typeof tag === "string");
10618
- const size2 = entry["size"];
10619
- images.push({
10620
- id: id2,
10621
- tags: normalizedTags,
10622
- size: typeof size2 === "number" ? size2 : void 0,
10623
- labels: normalizeImageLabels(labelsRaw, "list_images")
10624
- });
10729
+ images.push(parseContainerImage(entry, "list_images"));
10625
10730
  }
10626
10731
  return images;
10627
10732
  }
10733
+ async inspectImage(params2) {
10734
+ const output = await this.invoke("inspect_image", {
10735
+ image_id: params2.imageId
10736
+ });
10737
+ if (!(output instanceof JsonContent) || !isRecord2(output.json)) {
10738
+ throw this.unexpectedResponseError("inspect_image");
10739
+ }
10740
+ return parseContainerImageInspection(output.json, "inspect_image");
10741
+ }
10628
10742
  async deleteImage(params2) {
10629
10743
  await this.invoke("delete_image", {
10630
10744
  image: params2.image
@@ -14857,13 +14971,18 @@ ${err.toString()}`);
14857
14971
  });
14858
14972
  }
14859
14973
  async getUsage(projectId, options = {}) {
14860
- const { start, end, interval, report } = options;
14974
+ const { start, end, interval, report, users, room, provider, model, usageType } = options;
14861
14975
  const data = await this.request(`/accounts/projects/${projectId}/usage`, {
14862
14976
  query: {
14863
14977
  start: start ? start.toISOString() : void 0,
14864
14978
  end: end ? end.toISOString() : void 0,
14865
14979
  interval,
14866
- report
14980
+ report,
14981
+ users: users && users.length > 0 ? users.join(",") : void 0,
14982
+ room: room && room.trim().length > 0 ? room.trim() : void 0,
14983
+ provider: provider && provider.trim().length > 0 ? provider.trim() : void 0,
14984
+ model: model && model.trim().length > 0 ? model.trim() : void 0,
14985
+ usage_type: usageType && usageType.trim().length > 0 ? usageType.trim() : void 0
14867
14986
  },
14868
14987
  action: "retrieve usage"
14869
14988
  });
@@ -18133,7 +18252,7 @@ ${err.toString()}`);
18133
18252
  }
18134
18253
  };
18135
18254
  var RoomClient = class _RoomClient {
18136
- constructor({ protocolFactory = null, reconnectTimeout = null } = {}) {
18255
+ constructor({ protocolFactory = null, reconnectTimeout = null, oauthTokenRequestHandler, secretRequestHandler } = {}) {
18137
18256
  this._entered = false;
18138
18257
  this._allowDisconnectedRequests = false;
18139
18258
  this._eventsController = new StreamController();
@@ -18180,7 +18299,11 @@ ${err.toString()}`);
18180
18299
  this.queues = new QueuesClient({ room: this });
18181
18300
  this.database = new DatabaseClient({ room: this });
18182
18301
  this.agents = new AgentsClient({ room: this });
18183
- this.secrets = new SecretsClient({ room: this });
18302
+ this.secrets = new SecretsClient({
18303
+ room: this,
18304
+ oauthTokenRequestHandler,
18305
+ secretRequestHandler
18306
+ });
18184
18307
  this.containers = new ContainersClient({ room: this });
18185
18308
  this.memory = new MemoryClient({ room: this });
18186
18309
  this.services = new ServicesClient({ room: this });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshagent/meshagent-ts-auth",
3
- "version": "0.38.2",
3
+ "version": "0.38.4",
4
4
  "description": "Meshagent Typescript Auth",
5
5
  "homepage": "https://github.com/meshagent/meshagent-ts-auth",
6
6
  "scripts": {
@@ -39,7 +39,7 @@
39
39
  "CHANGELOG.md"
40
40
  ],
41
41
  "dependencies": {
42
- "@meshagent/meshagent": "^0.38.2",
42
+ "@meshagent/meshagent": "^0.38.4",
43
43
  "typescript": "^5.8.3"
44
44
  },
45
45
  "devDependencies": {