@standardagents/vue 0.10.1-dev.8f03957 → 0.10.1-dev.cea2b66

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
@@ -128,10 +128,45 @@ function useThreadSetup(threadId, options = {}) {
128
128
  }, { depth, includeSilent });
129
129
  connectionManager.connect();
130
130
  }
131
+ function buildOptimisticAttachments(attachmentPaths) {
132
+ if (!attachmentPaths || attachmentPaths.length === 0) return null;
133
+ const refs = attachmentPaths.map((path) => {
134
+ const file = pendingFiles.value.find((f) => f.path === path);
135
+ const ref2 = {
136
+ id: path,
137
+ type: "file",
138
+ path,
139
+ name: file?.name || path.split("/").pop() || "file",
140
+ mimeType: file?.mimeType || "application/octet-stream",
141
+ size: file?.size || 0
142
+ };
143
+ if (file?.isImage) {
144
+ if (file.width) ref2.width = file.width;
145
+ if (file.height) ref2.height = file.height;
146
+ if (file.localPreviewUrl) ref2.localPreviewUrl = file.localPreviewUrl;
147
+ }
148
+ return ref2;
149
+ });
150
+ return JSON.stringify(refs);
151
+ }
131
152
  async function sendMessage(payload) {
153
+ const optimisticId = `optimistic-${crypto.randomUUID()}`;
154
+ const optimisticMessage = {
155
+ id: optimisticId,
156
+ role: payload.role,
157
+ content: payload.content,
158
+ attachments: buildOptimisticAttachments(payload.attachments),
159
+ created_at: Date.now() * 1e3,
160
+ // microseconds
161
+ status: "pending"
162
+ };
163
+ messages.value = [...messages.value, optimisticMessage];
132
164
  try {
133
- return await client$1.sendMessage(threadId, payload);
165
+ const result = await client$1.sendMessage(threadId, payload);
166
+ messages.value = messages.value.filter((m) => m.id !== optimisticId);
167
+ return result;
134
168
  } catch (err) {
169
+ messages.value = messages.value.filter((m) => m.id !== optimisticId);
135
170
  error.value = err instanceof Error ? err : new Error(String(err));
136
171
  throw err;
137
172
  }
package/dist/index.js CHANGED
@@ -127,10 +127,45 @@ function useThreadSetup(threadId, options = {}) {
127
127
  }, { depth, includeSilent });
128
128
  connectionManager.connect();
129
129
  }
130
+ function buildOptimisticAttachments(attachmentPaths) {
131
+ if (!attachmentPaths || attachmentPaths.length === 0) return null;
132
+ const refs = attachmentPaths.map((path) => {
133
+ const file = pendingFiles.value.find((f) => f.path === path);
134
+ const ref2 = {
135
+ id: path,
136
+ type: "file",
137
+ path,
138
+ name: file?.name || path.split("/").pop() || "file",
139
+ mimeType: file?.mimeType || "application/octet-stream",
140
+ size: file?.size || 0
141
+ };
142
+ if (file?.isImage) {
143
+ if (file.width) ref2.width = file.width;
144
+ if (file.height) ref2.height = file.height;
145
+ if (file.localPreviewUrl) ref2.localPreviewUrl = file.localPreviewUrl;
146
+ }
147
+ return ref2;
148
+ });
149
+ return JSON.stringify(refs);
150
+ }
130
151
  async function sendMessage(payload) {
152
+ const optimisticId = `optimistic-${crypto.randomUUID()}`;
153
+ const optimisticMessage = {
154
+ id: optimisticId,
155
+ role: payload.role,
156
+ content: payload.content,
157
+ attachments: buildOptimisticAttachments(payload.attachments),
158
+ created_at: Date.now() * 1e3,
159
+ // microseconds
160
+ status: "pending"
161
+ };
162
+ messages.value = [...messages.value, optimisticMessage];
131
163
  try {
132
- return await client.sendMessage(threadId, payload);
164
+ const result = await client.sendMessage(threadId, payload);
165
+ messages.value = messages.value.filter((m) => m.id !== optimisticId);
166
+ return result;
133
167
  } catch (err) {
168
+ messages.value = messages.value.filter((m) => m.id !== optimisticId);
134
169
  error.value = err instanceof Error ? err : new Error(String(err));
135
170
  throw err;
136
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@standardagents/vue",
3
- "version": "0.10.1-dev.8f03957",
3
+ "version": "0.10.1-dev.cea2b66",
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.10.1-dev.8f03957"
25
+ "@standardagents/client": "0.10.1-dev.cea2b66"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "vue": "^3.3.0"