@standardagents/vue 0.14.1 → 0.15.0

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/dist/index.cjs CHANGED
@@ -33,6 +33,29 @@ function useStandardAgents() {
33
33
  return context;
34
34
  }
35
35
 
36
+ // src/utils/id.ts
37
+ function createClientId() {
38
+ const cryptoRef = globalThis.crypto;
39
+ if (typeof cryptoRef?.randomUUID === "function") {
40
+ return cryptoRef.randomUUID();
41
+ }
42
+ if (typeof cryptoRef?.getRandomValues === "function") {
43
+ const bytes = new Uint8Array(16);
44
+ cryptoRef.getRandomValues(bytes);
45
+ bytes[6] = bytes[6] & 15 | 64;
46
+ bytes[8] = bytes[8] & 63 | 128;
47
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0"));
48
+ return [
49
+ hex.slice(0, 4).join(""),
50
+ hex.slice(4, 6).join(""),
51
+ hex.slice(6, 8).join(""),
52
+ hex.slice(8, 10).join(""),
53
+ hex.slice(10, 16).join("")
54
+ ].join("-");
55
+ }
56
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
57
+ }
58
+
36
59
  // src/composables/useThreadSetup.ts
37
60
  var uploadManager = new client.FileUploadManager();
38
61
  function fileToBase64(file) {
@@ -228,7 +251,7 @@ function useThreadSetup(threadIdInput, options = {}) {
228
251
  connectionManager.connect();
229
252
  }
230
253
  async function sendMessage(payload) {
231
- const optimisticId = `optimistic-${crypto.randomUUID()}`;
254
+ const optimisticId = `optimistic-${createClientId()}`;
232
255
  const optimisticAttachments = attachments.value.map((a) => ({
233
256
  id: a.id,
234
257
  type: "file",
@@ -342,7 +365,7 @@ function useThreadSetup(threadIdInput, options = {}) {
342
365
  const newAttachments = filesToAdd.map((file) => {
343
366
  const isImage = file.type.startsWith("image/");
344
367
  return {
345
- id: crypto.randomUUID(),
368
+ id: createClientId(),
346
369
  file,
347
370
  name: file.name,
348
371
  mimeType: file.type,
package/dist/index.js CHANGED
@@ -32,6 +32,29 @@ function useStandardAgents() {
32
32
  return context;
33
33
  }
34
34
 
35
+ // src/utils/id.ts
36
+ function createClientId() {
37
+ const cryptoRef = globalThis.crypto;
38
+ if (typeof cryptoRef?.randomUUID === "function") {
39
+ return cryptoRef.randomUUID();
40
+ }
41
+ if (typeof cryptoRef?.getRandomValues === "function") {
42
+ const bytes = new Uint8Array(16);
43
+ cryptoRef.getRandomValues(bytes);
44
+ bytes[6] = bytes[6] & 15 | 64;
45
+ bytes[8] = bytes[8] & 63 | 128;
46
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0"));
47
+ return [
48
+ hex.slice(0, 4).join(""),
49
+ hex.slice(4, 6).join(""),
50
+ hex.slice(6, 8).join(""),
51
+ hex.slice(8, 10).join(""),
52
+ hex.slice(10, 16).join("")
53
+ ].join("-");
54
+ }
55
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
56
+ }
57
+
35
58
  // src/composables/useThreadSetup.ts
36
59
  var uploadManager = new FileUploadManager();
37
60
  function fileToBase64(file) {
@@ -227,7 +250,7 @@ function useThreadSetup(threadIdInput, options = {}) {
227
250
  connectionManager.connect();
228
251
  }
229
252
  async function sendMessage(payload) {
230
- const optimisticId = `optimistic-${crypto.randomUUID()}`;
253
+ const optimisticId = `optimistic-${createClientId()}`;
231
254
  const optimisticAttachments = attachments.value.map((a) => ({
232
255
  id: a.id,
233
256
  type: "file",
@@ -341,7 +364,7 @@ function useThreadSetup(threadIdInput, options = {}) {
341
364
  const newAttachments = filesToAdd.map((file) => {
342
365
  const isImage = file.type.startsWith("image/");
343
366
  return {
344
- id: crypto.randomUUID(),
367
+ id: createClientId(),
345
368
  file,
346
369
  name: file.name,
347
370
  mimeType: file.type,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@standardagents/vue",
3
- "version": "0.14.1",
3
+ "version": "0.15.0",
4
4
  "description": "Vue SDK for Standard Agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@standardagents/client": "0.14.1"
25
+ "@standardagents/client": "0.15.0"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "vue": "^3.3.0"