@teammy/server 0.2.24 → 0.2.25
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/main.js +1966 -1437
- package/dist/native-pi-entry.js +60 -0
- package/dist/project-pi-entry.js +60 -0
- package/dist/web/assets/{Assistant-BeWIo88A.js → Assistant-C-GBv5St.js} +1 -1
- package/dist/web/assets/{Computers-CEBC9xd4.js → Computers-B-FvcufX.js} +4 -4
- package/dist/web/assets/{Conversation-BMA0djTl.js → Conversation-Dzr18Rmq.js} +1 -1
- package/dist/web/assets/{Dashboard-DtNpBYI5.js → Dashboard-5ksfc6l9.js} +1 -1
- package/dist/web/assets/{Files-C-00txBh.js → Files-DqrIDBJI.js} +1 -1
- package/dist/web/assets/{Help-C5yLJzSE.js → Help-JsdkpQ8l.js} +22 -1
- package/dist/web/assets/{MessageComposer-D7ml-LaD.js → MessageComposer-DOJ1PYXg.js} +1 -1
- package/dist/web/assets/{ResourceLibrary-Ceon9f0i.js → ResourceLibrary--aVsAt6m.js} +1 -1
- package/dist/web/assets/{TerminalPane-CZYb0vIG.js → TerminalPane-jJa53g04.js} +1 -1
- package/dist/web/assets/{WorkspaceTree-C2sVptdG.js → WorkspaceTree-CuwIu3vj.js} +1 -1
- package/dist/web/assets/{file-links-CQ6ShuxD.js → file-links-BnaVOi2G.js} +1 -1
- package/dist/web/assets/index-Ck_8bv0N.js +40 -0
- package/dist/web/assets/{project-links-BwYckk7L.js → project-links-CodATITq.js} +1 -1
- package/dist/web/downloads/teammy-inbox-skill.zip +0 -0
- package/dist/web/downloads/teammy-skill.zip +0 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-BCj5CDtq.js +0 -40
package/dist/native-pi-entry.js
CHANGED
|
@@ -228,6 +228,66 @@ var workflowZh = {
|
|
|
228
228
|
|
|
229
229
|
// packages/i18n/workflow-extra.ts
|
|
230
230
|
var workflowExtra = {
|
|
231
|
+
"local.tool.list_agent_sessions": [
|
|
232
|
+
"\u5217\u51FA\u5F53\u524D\u9879\u76EE\u5185\u672C\u4EBA\u53EF\u8054\u7CFB\u7684\u5176\u4ED6 Agent \u4F1A\u8BDD\uFF0C\u8FD4\u56DE\u901A\u4FE1\u5730\u5740\u3001Teammy \u6807\u9898\u548C\u76EE\u5F55\u540D\u79F0\u3002",
|
|
233
|
+
"List your other reachable Agent sessions in this project: address, Teammy title and directory name."
|
|
234
|
+
],
|
|
235
|
+
"local.tool.send_agent_message": [
|
|
236
|
+
"\u5411\u5217\u8868\u4E2D\u7684\u4F1A\u8BDD\u7559\u8A00\uFF0Cto \u586B\u5B8C\u6574\u901A\u4FE1\u5730\u5740\u3002\u5BF9\u65B9\u5FD9\u788C\u65F6\u6392\u961F\uFF1B\u8FD4\u56DE\u56DE\u6267\u4E0D\u8868\u793A\u5DF2\u9605\u8BFB\u6216\u5904\u7406\uFF0C\u65E0\u987B\u7B49\u5F85\u56DE\u590D\u3002",
|
|
237
|
+
"Leave a note for a listed session using its full address in to. Busy sessions queue it. The receipt does not mean it was read or processed; no reply is expected."
|
|
238
|
+
],
|
|
239
|
+
"local.tool.get_agent_message_status": [
|
|
240
|
+
"\u6309\u56DE\u6267\u67E5\u8BE2\u672C\u4F1A\u8BDD\u53D1\u51FA\u7684\u7559\u8A00\u72B6\u6001\uFF0C\u4E0D\u8BFB\u53D6\u5BF9\u65B9\u56DE\u590D\u3002\u4EC5\u6309\u9700\u67E5\u8BE2\uFF1B\u65E0\u9700\u6301\u7EED\u8F6E\u8BE2\u6216\u56E0\u6392\u961F\u800C\u91CD\u590D\u53D1\u9001\u3002",
|
|
241
|
+
"Check a receipt for a note sent by this session, without reading the recipient\u2019s replies. Query as needed; do not continuously poll or resend a queued note."
|
|
242
|
+
],
|
|
243
|
+
"agentNote.input": [
|
|
244
|
+
"\u6536\u5230\u6765\u81EA Teammy \u4F1A\u8BDD\u300C{{title}}\u300D\uFF08{{address}}\uFF09\u7684\u7559\u8A00\u3002\n\u8BF7\u7ED3\u5408\u5F53\u524D\u4EFB\u52A1\u548C\u5DF2\u6709\u6388\u6743\u6309\u9700\u5904\u7406\uFF0C\u65E0\u987B\u4EC5\u4E3A\u786E\u8BA4\u6536\u5230\u800C\u56DE\u590D\u3002\n\n\u7559\u8A00\u5185\u5BB9\uFF1A\n",
|
|
245
|
+
"You received a note from Teammy session \u201C{{title}}\u201D ({{address}}).\nHandle it as needed within your current task and existing authorization. No acknowledgement is needed.\n\nNote content:\n"
|
|
246
|
+
],
|
|
247
|
+
"agentNote.invalidArgument": [
|
|
248
|
+
"\u8BF7\u4F7F\u7528\u5DE5\u5177\u5217\u51FA\u7684\u5B57\u6BB5\u3001\u5B8C\u6574\u901A\u4FE1\u5730\u5740\u6216\u7559\u8A00\u56DE\u6267\uFF1B\u6B63\u6587\u987B\u4E3A\u975E\u7A7A\u6587\u672C\u4E14\u4E0D\u8D85\u8FC7 16000 \u4E2A\u5B57\u7B26\u3002",
|
|
249
|
+
"Use the listed fields and a complete session address or note receipt. Text must be nonblank and at most 16000 characters."
|
|
250
|
+
],
|
|
251
|
+
"agentNote.unavailable": [
|
|
252
|
+
"\u5F53\u524D\u4F1A\u8BDD\u6682\u65F6\u65E0\u6CD5\u4F7F\u7528\u7559\u8A00\u5DE5\u5177\u3002",
|
|
253
|
+
"Note tools are currently unavailable in this session."
|
|
254
|
+
],
|
|
255
|
+
"agentNote.status.submitted": [
|
|
256
|
+
"\u670D\u52A1\u7AEF\u5DF2\u4FDD\u5B58\u7559\u8A00\uFF0C\u5C1A\u672A\u786E\u8BA4\u8FDB\u5165\u63A5\u6536\u65B9\u672C\u5730\u961F\u5217\u3002",
|
|
257
|
+
"The server saved the note; the recipient\u2019s local queue has not yet confirmed it."
|
|
258
|
+
],
|
|
259
|
+
"agentNote.status.queued": [
|
|
260
|
+
"\u63A5\u6536\u5668\u6700\u8FD1\u786E\u8BA4\u7559\u8A00\u4ECD\u5728\u6392\u961F\uFF0C\u5C1A\u672A\u786E\u8BA4\u9001\u5165\u5BF9\u65B9\u4F1A\u8BDD\u3002",
|
|
261
|
+
"The receiver last confirmed the note was queued; admission to the session has not yet been confirmed."
|
|
262
|
+
],
|
|
263
|
+
"agentNote.status.processing": [
|
|
264
|
+
"Provider \u5DF2\u786E\u8BA4\u5BF9\u5E94\u56DE\u5408\u5F00\u59CB\uFF0C\u5C1A\u672A\u786E\u8BA4\u7ED3\u675F\u3002",
|
|
265
|
+
"The provider confirmed the corresponding turn started; completion has not yet been confirmed."
|
|
266
|
+
],
|
|
267
|
+
"agentNote.status.finished": [
|
|
268
|
+
"\u5BF9\u5E94\u56DE\u5408\u5DF2\u6B63\u5E38\u7ED3\u675F\uFF0C\u4E0D\u4EE3\u8868\u8D44\u6E90\u91CA\u653E\u7B49\u4E1A\u52A1\u76EE\u6807\u5DF2\u5B8C\u6210\u3002",
|
|
269
|
+
"The corresponding turn ended normally; this does not confirm business outcomes such as releasing a resource."
|
|
270
|
+
],
|
|
271
|
+
"agentNote.status.failed": [
|
|
272
|
+
"\u7559\u8A00\u6295\u9012\u6216\u542F\u52A8\u5931\u8D25\uFF0C\u672A\u786E\u8BA4\u8FDB\u5165\u5904\u7406\u56DE\u5408\u3002",
|
|
273
|
+
"Delivery or startup failed; admission to a processing turn was not confirmed."
|
|
274
|
+
],
|
|
275
|
+
"agentNote.status.processingFailed": [
|
|
276
|
+
"\u7559\u8A00\u5DF2\u8FDB\u5165\u5904\u7406\u56DE\u5408\uFF0C\u4F46\u8BE5\u56DE\u5408\u6267\u884C\u5931\u8D25\u3002",
|
|
277
|
+
"The note entered a processing turn, but that turn failed."
|
|
278
|
+
],
|
|
279
|
+
"agentNote.status.cancelled": [
|
|
280
|
+
"\u5904\u7406\u5DF2\u53D6\u6D88\u6216\u4E2D\u6B62\uFF0C\u5DF2\u53D1\u751F\u7684\u64CD\u4F5C\u4E0D\u4F1A\u81EA\u52A8\u64A4\u9500\u3002",
|
|
281
|
+
"Processing was cancelled or interrupted; prior effects are not undone."
|
|
282
|
+
],
|
|
283
|
+
"agentNote.status.uncertain": [
|
|
284
|
+
"\u6700\u65B0\u72B6\u6001\u65E0\u6CD5\u786E\u8BA4\uFF1B\u6700\u540E\u786E\u8BA4\u9636\u6BB5\uFF1A{{stage}}\u3002\u8BF7\u52FF\u636E\u6B64\u91CD\u590D\u53D1\u9001\u3002",
|
|
285
|
+
"The latest state is unknown. Last confirmed stage: {{stage}}. Do not resend on this basis."
|
|
286
|
+
],
|
|
287
|
+
"agentNote.stage.submitted": ["\u670D\u52A1\u7AEF\u5DF2\u4FDD\u5B58", "saved by the server"],
|
|
288
|
+
"agentNote.stage.queued": ["\u672C\u5730\u5DF2\u6392\u961F", "queued locally"],
|
|
289
|
+
"agentNote.stage.processing": ["\u5BF9\u5E94\u56DE\u5408\u5DF2\u5F00\u59CB", "corresponding turn started"],
|
|
290
|
+
"agentNote.stage.finished": ["\u5BF9\u5E94\u56DE\u5408\u5DF2\u7ED3\u675F", "corresponding turn ended"],
|
|
231
291
|
"work.channelRecalled": [
|
|
232
292
|
"\u64A4\u56DE\u4E86\u6B64\u524D\u7684\u4E00\u6761\u53D1\u8A00\u3002\u8BF7\u636E\u6B64\u66F4\u65B0\u7406\u89E3\uFF1B\u5DF2\u6267\u884C\u7684\u64CD\u4F5C\u4E0D\u4F1A\u81EA\u52A8\u64A4\u9500\u3002",
|
|
233
293
|
"A previous message was recalled. Update your understanding accordingly; actions already performed are not automatically undone."
|
package/dist/project-pi-entry.js
CHANGED
|
@@ -101,6 +101,66 @@ var workflowZh = {
|
|
|
101
101
|
|
|
102
102
|
// packages/i18n/workflow-extra.ts
|
|
103
103
|
var workflowExtra = {
|
|
104
|
+
"local.tool.list_agent_sessions": [
|
|
105
|
+
"\u5217\u51FA\u5F53\u524D\u9879\u76EE\u5185\u672C\u4EBA\u53EF\u8054\u7CFB\u7684\u5176\u4ED6 Agent \u4F1A\u8BDD\uFF0C\u8FD4\u56DE\u901A\u4FE1\u5730\u5740\u3001Teammy \u6807\u9898\u548C\u76EE\u5F55\u540D\u79F0\u3002",
|
|
106
|
+
"List your other reachable Agent sessions in this project: address, Teammy title and directory name."
|
|
107
|
+
],
|
|
108
|
+
"local.tool.send_agent_message": [
|
|
109
|
+
"\u5411\u5217\u8868\u4E2D\u7684\u4F1A\u8BDD\u7559\u8A00\uFF0Cto \u586B\u5B8C\u6574\u901A\u4FE1\u5730\u5740\u3002\u5BF9\u65B9\u5FD9\u788C\u65F6\u6392\u961F\uFF1B\u8FD4\u56DE\u56DE\u6267\u4E0D\u8868\u793A\u5DF2\u9605\u8BFB\u6216\u5904\u7406\uFF0C\u65E0\u987B\u7B49\u5F85\u56DE\u590D\u3002",
|
|
110
|
+
"Leave a note for a listed session using its full address in to. Busy sessions queue it. The receipt does not mean it was read or processed; no reply is expected."
|
|
111
|
+
],
|
|
112
|
+
"local.tool.get_agent_message_status": [
|
|
113
|
+
"\u6309\u56DE\u6267\u67E5\u8BE2\u672C\u4F1A\u8BDD\u53D1\u51FA\u7684\u7559\u8A00\u72B6\u6001\uFF0C\u4E0D\u8BFB\u53D6\u5BF9\u65B9\u56DE\u590D\u3002\u4EC5\u6309\u9700\u67E5\u8BE2\uFF1B\u65E0\u9700\u6301\u7EED\u8F6E\u8BE2\u6216\u56E0\u6392\u961F\u800C\u91CD\u590D\u53D1\u9001\u3002",
|
|
114
|
+
"Check a receipt for a note sent by this session, without reading the recipient\u2019s replies. Query as needed; do not continuously poll or resend a queued note."
|
|
115
|
+
],
|
|
116
|
+
"agentNote.input": [
|
|
117
|
+
"\u6536\u5230\u6765\u81EA Teammy \u4F1A\u8BDD\u300C{{title}}\u300D\uFF08{{address}}\uFF09\u7684\u7559\u8A00\u3002\n\u8BF7\u7ED3\u5408\u5F53\u524D\u4EFB\u52A1\u548C\u5DF2\u6709\u6388\u6743\u6309\u9700\u5904\u7406\uFF0C\u65E0\u987B\u4EC5\u4E3A\u786E\u8BA4\u6536\u5230\u800C\u56DE\u590D\u3002\n\n\u7559\u8A00\u5185\u5BB9\uFF1A\n",
|
|
118
|
+
"You received a note from Teammy session \u201C{{title}}\u201D ({{address}}).\nHandle it as needed within your current task and existing authorization. No acknowledgement is needed.\n\nNote content:\n"
|
|
119
|
+
],
|
|
120
|
+
"agentNote.invalidArgument": [
|
|
121
|
+
"\u8BF7\u4F7F\u7528\u5DE5\u5177\u5217\u51FA\u7684\u5B57\u6BB5\u3001\u5B8C\u6574\u901A\u4FE1\u5730\u5740\u6216\u7559\u8A00\u56DE\u6267\uFF1B\u6B63\u6587\u987B\u4E3A\u975E\u7A7A\u6587\u672C\u4E14\u4E0D\u8D85\u8FC7 16000 \u4E2A\u5B57\u7B26\u3002",
|
|
122
|
+
"Use the listed fields and a complete session address or note receipt. Text must be nonblank and at most 16000 characters."
|
|
123
|
+
],
|
|
124
|
+
"agentNote.unavailable": [
|
|
125
|
+
"\u5F53\u524D\u4F1A\u8BDD\u6682\u65F6\u65E0\u6CD5\u4F7F\u7528\u7559\u8A00\u5DE5\u5177\u3002",
|
|
126
|
+
"Note tools are currently unavailable in this session."
|
|
127
|
+
],
|
|
128
|
+
"agentNote.status.submitted": [
|
|
129
|
+
"\u670D\u52A1\u7AEF\u5DF2\u4FDD\u5B58\u7559\u8A00\uFF0C\u5C1A\u672A\u786E\u8BA4\u8FDB\u5165\u63A5\u6536\u65B9\u672C\u5730\u961F\u5217\u3002",
|
|
130
|
+
"The server saved the note; the recipient\u2019s local queue has not yet confirmed it."
|
|
131
|
+
],
|
|
132
|
+
"agentNote.status.queued": [
|
|
133
|
+
"\u63A5\u6536\u5668\u6700\u8FD1\u786E\u8BA4\u7559\u8A00\u4ECD\u5728\u6392\u961F\uFF0C\u5C1A\u672A\u786E\u8BA4\u9001\u5165\u5BF9\u65B9\u4F1A\u8BDD\u3002",
|
|
134
|
+
"The receiver last confirmed the note was queued; admission to the session has not yet been confirmed."
|
|
135
|
+
],
|
|
136
|
+
"agentNote.status.processing": [
|
|
137
|
+
"Provider \u5DF2\u786E\u8BA4\u5BF9\u5E94\u56DE\u5408\u5F00\u59CB\uFF0C\u5C1A\u672A\u786E\u8BA4\u7ED3\u675F\u3002",
|
|
138
|
+
"The provider confirmed the corresponding turn started; completion has not yet been confirmed."
|
|
139
|
+
],
|
|
140
|
+
"agentNote.status.finished": [
|
|
141
|
+
"\u5BF9\u5E94\u56DE\u5408\u5DF2\u6B63\u5E38\u7ED3\u675F\uFF0C\u4E0D\u4EE3\u8868\u8D44\u6E90\u91CA\u653E\u7B49\u4E1A\u52A1\u76EE\u6807\u5DF2\u5B8C\u6210\u3002",
|
|
142
|
+
"The corresponding turn ended normally; this does not confirm business outcomes such as releasing a resource."
|
|
143
|
+
],
|
|
144
|
+
"agentNote.status.failed": [
|
|
145
|
+
"\u7559\u8A00\u6295\u9012\u6216\u542F\u52A8\u5931\u8D25\uFF0C\u672A\u786E\u8BA4\u8FDB\u5165\u5904\u7406\u56DE\u5408\u3002",
|
|
146
|
+
"Delivery or startup failed; admission to a processing turn was not confirmed."
|
|
147
|
+
],
|
|
148
|
+
"agentNote.status.processingFailed": [
|
|
149
|
+
"\u7559\u8A00\u5DF2\u8FDB\u5165\u5904\u7406\u56DE\u5408\uFF0C\u4F46\u8BE5\u56DE\u5408\u6267\u884C\u5931\u8D25\u3002",
|
|
150
|
+
"The note entered a processing turn, but that turn failed."
|
|
151
|
+
],
|
|
152
|
+
"agentNote.status.cancelled": [
|
|
153
|
+
"\u5904\u7406\u5DF2\u53D6\u6D88\u6216\u4E2D\u6B62\uFF0C\u5DF2\u53D1\u751F\u7684\u64CD\u4F5C\u4E0D\u4F1A\u81EA\u52A8\u64A4\u9500\u3002",
|
|
154
|
+
"Processing was cancelled or interrupted; prior effects are not undone."
|
|
155
|
+
],
|
|
156
|
+
"agentNote.status.uncertain": [
|
|
157
|
+
"\u6700\u65B0\u72B6\u6001\u65E0\u6CD5\u786E\u8BA4\uFF1B\u6700\u540E\u786E\u8BA4\u9636\u6BB5\uFF1A{{stage}}\u3002\u8BF7\u52FF\u636E\u6B64\u91CD\u590D\u53D1\u9001\u3002",
|
|
158
|
+
"The latest state is unknown. Last confirmed stage: {{stage}}. Do not resend on this basis."
|
|
159
|
+
],
|
|
160
|
+
"agentNote.stage.submitted": ["\u670D\u52A1\u7AEF\u5DF2\u4FDD\u5B58", "saved by the server"],
|
|
161
|
+
"agentNote.stage.queued": ["\u672C\u5730\u5DF2\u6392\u961F", "queued locally"],
|
|
162
|
+
"agentNote.stage.processing": ["\u5BF9\u5E94\u56DE\u5408\u5DF2\u5F00\u59CB", "corresponding turn started"],
|
|
163
|
+
"agentNote.stage.finished": ["\u5BF9\u5E94\u56DE\u5408\u5DF2\u7ED3\u675F", "corresponding turn ended"],
|
|
104
164
|
"work.channelRecalled": [
|
|
105
165
|
"\u64A4\u56DE\u4E86\u6B64\u524D\u7684\u4E00\u6761\u53D1\u8A00\u3002\u8BF7\u636E\u6B64\u66F4\u65B0\u7406\u89E3\uFF1B\u5DF2\u6267\u884C\u7684\u64CD\u4F5C\u4E0D\u4F1A\u81EA\u52A8\u64A4\u9500\u3002",
|
|
106
166
|
"A previous message was recalled. Update your understanding accordingly; actions already performed are not automatically undone."
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,Bt as t,C as n,E as r,F as i,Gt as a,H as o,Ht as s,It as c,K as ee,Lt as l,M as u,O as te,P as d,T as ne,U as re,V as ie,Vt as f,Z as ae,Zt as p,at as m,en as h,f as oe,h as se,it as g,m as ce,p as _,q as v,qt as le}from"./project-links-BwYckk7L.js";import{A as y,J as ue,K as de,M as fe,N as pe,P as b,Z as x,a as me,j as he,k as ge,r as _e,tt as ve,z as ye}from"./index-BCj5CDtq.js";import{i as be,n as xe,r as Se,t as Ce}from"./Conversation-BMA0djTl.js";import{t as we}from"./MessageComposer-D7ml-LaD.js";var S=h(p(),1),C=o(),Te=s({topics:c(s({id:a(),title:a(),summary:a(),author:a(),replies:f(),unread:l(),createdAt:a(),updatedAt:a(),delivery:s({available:l(),connected:l(),state:a(),error:a().nullable()})}))}),Ee=e=>new Date(e).toLocaleTimeString(g(),{hour:`2-digit`,minute:`2-digit`}),w=e=>e.replace(/[#*_`>]/g,``).replace(/\s+/g,` `).trim();function T({me:o,mode:c=`messages`}){ie();let{projectId:f,request:p}=ve(),h=i(),T=d(f,o,`${c}-selection`),E=d(f,o,`${c}-drafts`),Oe=(0,S.useCallback)(e=>p(`agents/outbox`,pe,{signal:e}),[p]),D=u(Oe,3e3,d(f,o,`outbox`)),ke=(0,S.useCallback)(async e=>c===`messages`?p(`agents/chats`,ge,{signal:e}):{chats:(await p(`channels/topics`,Te,{signal:e})).topics.map(e=>({...e,kind:`matter`,state:null}))},[p,c]),O=u(ke,3e3,d(f,o,c,`chats`)),[k,Ae]=(0,S.useState)(()=>{let e=new URLSearchParams(location.search),t=e.get(`chat`);return t?`chat:${t}`:e.get(`message`)??h?.get(T)??``}),A=k.startsWith(`chat:`)?k.slice(5):``,j=!k||!!A,[M,N]=(0,S.useState)(()=>h?.get(d(f,o,`chat`,A))),P=M?.id===A?M:h?.get(d(f,o,`chat`,A)),F=O.data?.chats.find(e=>e.id===A),je=j?F?.title??P?.title??(A?m(`web.Assistant.1`):`Tim`):m(k===`debug`?`web.Assistant.2`:`web.Assistant.3`);_e(k?je:void 0);let I=F&&`delivery`in F?F.delivery:void 0,[Me,L]=(0,S.useState)(),[R,z]=(0,S.useState)(()=>h?.get(E)??{}),Ne=R[k]??``,Pe=e=>z(t=>({...t,[k]:e})),[B,V]=(0,S.useState)(!1),[H,Fe]=(0,S.useState)(!1),[Ie,Le]=(0,S.useState)(!1),[Re,U]=(0,S.useState)(!1),[W,ze]=(0,S.useState)(``),[Be,Ve]=(0,S.useState)(``),He=(0,S.useRef)(v()),G=te(),[Ue,K]=e(),q=(0,S.useRef)(new Map),We=(0,S.useRef)(null),Ge=(0,S.useRef)(!0),J=(0,S.useRef)(k);J.current=k,(0,S.useEffect)(()=>{M&&h?.set(d(f,o,`chat`,M.id),M)},[h,f,o,M]),(0,S.useEffect)(()=>{h?.set(E,R)},[h,E,R]);function Y(e){J.current=e,Ae(e),h?.set(T,e);let t=new URL(location.href);e.startsWith(`chat:`)?t.searchParams.set(`chat`,e.slice(5)):t.searchParams.delete(`chat`),e&&!e.startsWith(`chat:`)&&e!==`debug`?t.searchParams.set(`message`,e):t.searchParams.delete(`message`),history.replaceState(history.state,``,t)}(0,S.useEffect)(()=>{!k&&O.data?.chats.length&&Y(`chat:${O.data.chats[0].id}`)},[k,O.data]);let X=(D.data?.messages??[]).filter(e=>c===`messages`&&e.box===`debug`).reverse(),Z=D.data?.messages.find(e=>e.id===(k===`debug`?Me:k));(0,S.useEffect)(()=>{k!==`debug`&&Z?.conversationId&&Y(`chat:${Z.conversationId}`)},[k,Z?.conversationId]);let Q=X.filter(e=>!e.readAt).map(e=>e.id).join(`,`);(0,S.useEffect)(()=>{Z&&!Z.readAt&&k!==`debug`&&p(`agents/outbox/${Z.id}/read`,b,{method:`POST`}).then(()=>{window.dispatchEvent(new Event(`teammy:outbox`)),D.reload()}).catch(e=>G(e))},[Z?.id,Z?.readAt,k,p,D.reload]),(0,S.useEffect)(()=>{k===`debug`&&Q&&Promise.all(Q.split(`,`).map(e=>p(`agents/outbox/${e}/read`,b,{method:`POST`}))).then(()=>{window.dispatchEvent(new Event(`teammy:outbox`)),D.reload()}).catch(e=>G(e))},[k,Q,p,D.reload]),(0,S.useEffect)(()=>{if(K(``),!A)return;let e=!0,t=-1,n=!1,r=new AbortController,i=r=>{!e||r.id!==A||r.cursor<t||(t=r.cursor,n=!0,r.redirect?Y(`chat:${r.redirect}`):r.entry===`channel`&&c!==`channels`?location.replace(ae(`/projects/${f}/channels?chat=${r.id}`)):(N(r),K(``)))};p(`agents/chats/${A}`,y,{signal:r.signal}).then(i).catch(t=>{e&&!r.signal.aborted&&(t instanceof re&&[401,403,404].includes(t.status)&&(h?.delete(d(f,o,`chat`,A)),N(e=>e?.id===A?void 0:e)),n||K(()=>ee(t)))});let l=n=>{let r=Number(n.lastEventId);return!e||!Number.isSafeInteger(r)||r<=t?!1:(t=r,!0)},u=new EventSource(ae(`/api/v1/projects/${encodeURIComponent(f)}/agents/chats/${encodeURIComponent(A)}/events`));u.addEventListener(`snapshot`,t=>{if(e)try{i(y.parse(JSON.parse(t.data)))}catch(e){K(()=>ee(e))}}),u.onerror=()=>{e&&K(()=>m(`web.Assistant.4`))},u.addEventListener(`context`,e=>{if(!l(e))return;let n=y.pick({kind:!0,title:!0,status:!0,visibility:!0,participants:!0,pending:!0,hold:!0,redirect:!0}).parse(JSON.parse(e.data));n.redirect?Y(`chat:${n.redirect}`):N(e=>e?.id===A?{...e,...n,cursor:t}:e)}),u.addEventListener(`message`,e=>{if(!l(e))return;let t=he.parse(JSON.parse(e.data));N(n=>n?.id===A?{...n,readCursor:Math.max(n.readCursor,t.seq),cursor:Math.max(n.cursor,Number(e.lastEventId)||0),messages:[...n.messages.filter(e=>e.id!==t.id),t].sort((e,t)=>e.seq-t.seq)}:n)}),u.addEventListener(`message_removed`,e=>{if(!l(e))return;let{id:n}=s({id:a()}).parse(JSON.parse(e.data));N(e=>e?.id===A?{...e,cursor:t,messages:e.messages.filter(e=>e.id!==n)}:e)}),u.addEventListener(`run`,e=>{if(!l(e))return;let t=fe.parse(JSON.parse(e.data));N(n=>n?.id===A?{...n,cursor:Math.max(n.cursor,Number(e.lastEventId)||0),runs:n.runs.some(e=>e.id===t.id)?n.runs:[...n.runs,t]}:n)});for(let e of[`delta`,`reset`,`state`])u.addEventListener(e,t=>{if(!l(t))return;let n=JSON.parse(t.data);N(r=>r?.id===A?{...r,cursor:Math.max(r.cursor,Number(t.lastEventId)||0),messages:r.messages.map(t=>t.runId!==n.id||t.role!==`assistant`?t:{...t,body:e===`delta`?t.body+(n.text??``):e===`reset`?``:n.answer??t.body,state:n.state??t.state}),runs:r.runs.map(t=>t.id===n.id?{...t,answer:e===`delta`?t.answer+(n.text??``):e===`reset`?``:n.answer??t.answer,state:n.state??t.state,error:n.error===void 0?t.error:n.error}:t)}:r)});return()=>{e=!1,r.abort(),u.close()}},[f,A,o,p,h]),(0,S.useEffect)(()=>{if(!P||P.id!==A)return;let e=()=>{document.visibilityState===`visible`&&p(`agents/chats/${A}/read`,s({ok:l()}),{method:`POST`,body:{cursor:P.readCursor}}).then(()=>{O.reload(),window.dispatchEvent(new Event(`teammy:outbox`))}).catch(e=>G(e))},t=setTimeout(e,300);return document.addEventListener(`visibilitychange`,e),()=>{clearTimeout(t),document.removeEventListener(`visibilitychange`,e)}},[A,P?.readCursor,P?.kind,p]),(0,S.useEffect)(()=>{Ge.current&&We.current?.scrollIntoView({block:`end`})},[k,M?.messages,Z?.recipients,X.length]);function Ke(){window.dispatchEvent(new Event(`teammy:outbox`)),D.reload()}async function $(e){if(Ge.current=!0,Y(e),G(``),L(void 0),e.startsWith(`chat:`)||e===`debug`)return;let t=D.data?.messages.find(t=>t.id===e)?.conversationId;if(t)Y(`chat:${t}`);else try{await p(`agents/outbox/${e}/read`,b,{method:`POST`}),Ke()}catch(e){G(e)}}async function qe(){if(!H){Fe(!0),G(``);try{let e=await p(`agents/chats`,y,{method:`POST`});N(e),await $(`chat:${e.id}`),O.reload()}catch(e){G(e)}finally{Fe(!1)}}}async function Je(e){e.preventDefault();let t=Ne.trim();if(!t||B||H)return;V(!0),G(``);let n=q.current.get(k);n&&n.text===t||(n={text:t,id:v()},q.current.set(k,n));try{if(j){let e=n.target??A;if(!e){let r=await p(`agents/chats`,y,{method:`POST`});e=r.id,n.target=e,q.current.set(`chat:${e}`,n),z(n=>({...n,[`chat:${e}`]:t})),J.current===k&&(N(r),Y(`chat:${e}`))}let r=await p(`agents/chats/${e}`,fe.extend({conversationId:a().optional()}),{method:`POST`,body:{text:t,requestId:n.id}});r.conversationId&&r.conversationId!==e&&(J.current===k||J.current===`chat:${e}`)&&Y(`chat:${r.conversationId}`),N(t=>t?.id===e?{...t,runs:t.runs.some(e=>e.id===r.id)?t.runs:[...t.runs,r]}:t),O.reload()}else{let e=await p(`agents/outbox/${Z.id}/reply`,s({conversationId:a()}),{method:`POST`,body:{body:t,requestId:n.id}});Ke(),J.current===k&&Y(`chat:${e.conversationId}`),O.reload(),L(void 0)}q.current.delete(k),n.target&&q.current.delete(`chat:${n.target}`),z(e=>({...e,[k]:``,...n.target?{[`chat:${n.target}`]:``}:{}}))}catch(e){G(e)}finally{V(!1)}}let Ye=c===`channels`?Se:Ce,Xe=j&&!P?.closed&&(c!==`channels`||!!A)||!!Z&&!Z.archivedAt,Ze=j&&!P&&(!!A||!O.data);return(0,C.jsxs)(xe,{className:c===`channels`?`channel-layout`:``,testId:`assistant-page`,label:m(j?`web.Assistant.5`:`web.Assistant.6`),navigation:(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(ue,{title:m(c===`channels`?`web.Assistant.7`:`web.Assistant.8`),children:(0,C.jsxs)(`div`,{className:`assistant-list-actions`,children:[(0,C.jsx)(_,{className:`assistant-new-chat`,icon:`clear`,label:m(`web.Assistant.9`),disabled:Ie,onClick:()=>{Le(!0),G(``),p(`communication/read`,s({ok:t(!0)}),{method:`POST`,body:{scope:c}}).then(async()=>{window.dispatchEvent(new Event(`teammy:outbox`)),await Promise.all([O.reload(),D.reload()])}).catch(e=>G(e)).finally(()=>Le(!1))}}),(0,C.jsx)(_,{className:`assistant-new-chat`,icon:`plus`,label:m(c===`channels`?`web.Assistant.10`:`web.Assistant.11`),disabled:H,onClick:()=>c===`channels`?U(!0):void qe(),"data-testid":`assistant-launcher`})]})}),(0,C.jsxs)(`div`,{className:`assistant-message-scroll`,children:[O.loading&&!O.data&&(0,C.jsx)(`p`,{className:`assistant-list-status`,role:`status`,children:m(`web.Memory.4`)}),O.data?.chats.map(e=>(0,C.jsxs)(`button`,{type:`button`,"data-testid":`assistant-chat-${e.id}`,className:`assistant-message-item assistant-chat-item ${A===e.id?`selected`:``}`,"aria-pressed":A===e.id,onClick:()=>void $(`chat:${e.id}`),children:[(0,C.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,C.jsx)(x,{selected:A===e.id,children:(0,C.jsx)(`strong`,{children:e.title})}),c===`channels`&&`summary`in e&&(0,C.jsx)(`span`,{className:`topic-preview`,children:w(String(e.summary)).slice(0,140)}),(0,C.jsxs)(`time`,{dateTime:e.updatedAt,children:[new Date(e.updatedAt).toLocaleDateString(g(),{month:`numeric`,day:`numeric`}),` `,Ee(e.updatedAt)]})]}),(0,C.jsx)(`span`,{className:`assistant-message-dot ${e.unread||c!==`channels`&&(e.state===`running`||e.state===`queued`)?`unread`:``}`})]},e.id)),!!X.length&&(0,C.jsxs)(`button`,{type:`button`,"data-testid":`debug-outbox`,className:`assistant-message-item ${k===`debug`?`selected`:``}`,onClick:()=>void $(`debug`),children:[(0,C.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,C.jsx)(x,{selected:k===`debug`,children:(0,C.jsx)(`strong`,{children:m(`web.Assistant.2`)})}),(0,C.jsx)(`span`,{children:w(X.at(-1).body)})]}),(0,C.jsx)(`span`,{className:`assistant-message-dot ${Q?`unread`:``}`})]}),D.data?.messages.filter(e=>c===`messages`&&e.box!==`debug`&&!e.conversationId).sort((e,t)=>Number(!!e.archivedAt)-Number(!!t.archivedAt)).map(e=>(0,C.jsxs)(`button`,{type:`button`,"data-testid":`outbox-${e.id}`,className:`assistant-message-item ${e.archivedAt?`archived`:``} ${k===e.id?`selected`:``}`,onClick:()=>void $(e.id),children:[(0,C.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,C.jsx)(x,{selected:k===e.id,children:(0,C.jsx)(`strong`,{children:w(e.body)})}),(0,C.jsxs)(`time`,{dateTime:e.createdAt,children:[new Date(e.createdAt).toLocaleDateString(g(),{month:`numeric`,day:`numeric`}),` `,Ee(e.createdAt)]})]}),(0,C.jsx)(`span`,{className:`assistant-message-dot ${e.readAt?``:`unread`}`})]},e.id))]}),(0,C.jsx)(r,{resource:D}),(0,C.jsx)(r,{resource:O})]}),children:[Re&&(0,C.jsx)(se,{id:`new-topic`,title:m(`web.Assistant.10`),onClose:()=>U(!1),children:(0,C.jsx)(we,{inset:!0,plain:!0,value:Be,onChange:Ve,label:m(`web.Assistant.12`),placeholder:m(`web.Assistant.13`),sendLabel:m(`web.Assistant.10`),sendDisabled:B||!W.trim(),heading:(0,C.jsx)(`input`,{className:`topic-title`,"aria-label":m(`web.Assistant.14`),placeholder:m(`web.Assistant.14`),required:!0,value:W,onChange:e=>ze(e.target.value)}),onSubmit:e=>{e.preventDefault(),V(!0),G(``),p(`channels/topics`,y,{method:`POST`,body:{id:He.current,title:W,body:Be}}).then(e=>{N(e),Y(`chat:${e.id}`),U(!1),ze(``),Ve(``),He.current=v(),O.reload()}).catch(e=>G(e)).finally(()=>V(!1))}})}),(0,C.jsx)(de,{title:(0,C.jsx)(`h2`,{children:je}),actions:(0,C.jsxs)(C.Fragment,{children:[c===`channels`&&A&&(0,C.jsx)(me,{conversation:A}),c!==`channels`&&P?.kind===`matter`&&(0,C.jsxs)(`span`,{className:`assistant-participants`,title:P.participants?.join(`、`),children:[P.visibility===`project`?m(`web.Assistant.15`):``,P.participants?.join(`、`)]}),c===`channels`&&I?.available&&(I.state===`web`||I.state===`cancelled`||!I.connected)&&(0,C.jsx)(_,{icon:`send`,label:m(`web.Assistant.16`),disabled:B,onClick:()=>{V(!0),p(`channels/topics/${A}/publish`,le(),{method:`POST`}).then(()=>O.reload()).catch(e=>G(e)).finally(()=>V(!1))}})]})}),c===`channels`&&(0,C.jsx)(n,{children:I?.error}),c!==`channels`&&P?.kind===`matter`&&(P.hold||P.pending||P.status===`completed`)&&(0,C.jsx)(`div`,{className:`assistant-matter-state`,role:`status`,children:P.hold?`${P.hold.scope===`all`?m(`web.EventRoutingSettings.28`):m(`web.Assistant.25`)} · ${P.hold.reason}`:P.pending?m(`web.Assistant.17`,{p0:P.pending.members.join(`、`),p1:P.pending.question}):m(`web.Computers.12`)}),(0,C.jsxs)(be,{"data-testid":`assistant-transcript`,onScroll:e=>{let t=e.currentTarget;Ge.current=t.scrollHeight-t.scrollTop-t.clientHeight<100},children:[j?Ze?(0,C.jsxs)(`div`,{className:`assistant-empty`,"data-testid":`assistant-loading`,children:[(0,C.jsx)(ce,{}),(0,C.jsx)(`p`,{role:`status`,children:Ue||(O.error?m(`web.Assistant.18`):m(`web.Memory.4`))})]}):P?.messages.length?P.messages.filter(e=>e.body||[`queued`,`running`,`failed`].includes(e.state)).map(e=>(0,C.jsx)(`div`,{className:`assistant-turn`,children:(0,C.jsxs)(Ye,{mine:e.role===`user`&&e.author===o,author:`${e.role===`assistant`?`Tim`:e.author}${e.source===`wecom`?m(`web.Assistant.26`):``}`,time:e.createdAt,children:[e.body&&(0,C.jsx)(`div`,{className:`markdown`,children:(0,C.jsx)(ye,{children:e.source===`receipt`?m(`request.replyRecorded`):e.body})}),e.role===`assistant`&&[`queued`,`running`].includes(e.state)&&(0,C.jsxs)(`span`,{className:`assistant-typing`,"aria-label":m(`web.Assistant.19`),children:[(0,C.jsx)(`i`,{}),(0,C.jsx)(`i`,{}),(0,C.jsx)(`i`,{})]}),e.state===`failed`&&(0,C.jsx)(n,{children:P.runs.find(t=>t.id===e.runId)?.error||m(`web.Assistant.20`)})]})},e.id)):(0,C.jsxs)(`div`,{className:`assistant-empty`,children:[(0,C.jsx)(ce,{}),(0,C.jsx)(`p`,{children:m(`web.Assistant.21`)})]}):!D.data&&D.loading?(0,C.jsx)(`div`,{className:`assistant-empty`,children:(0,C.jsx)(`p`,{role:`status`,children:m(`web.Memory.4`)})}):k===`debug`?X.map(e=>(0,C.jsx)(De,{item:e,onReply:e.archivedAt?void 0:()=>{L(e.id),Pe(``),G(``)}},e.id)):Z&&(0,C.jsx)(De,{item:Z}),(0,C.jsx)(`div`,{ref:We})]}),(0,C.jsx)(ne,{message:j&&P?Ue:void 0}),Xe?(0,C.jsx)(we,{value:Ne,onChange:Pe,onSubmit:e=>void Je(e),disabled:H,sendDisabled:B||Ze,label:m(j?`web.Assistant.22`:`web.Assistant.23`)}):k!==`debug`&&Z&&(0,C.jsxs)(`div`,{className:`assistant-archived`,children:[(0,C.jsx)(oe,{name:`archive`}),m(`web.Computers.25`)]})]})}function De({item:e,onReply:t}){return ie(),(0,C.jsx)(`div`,{"data-testid":`outbox-thread-${e.id}`,children:(0,C.jsxs)(Ce,{author:e.box===`debug`?m(`web.Assistant.2`):`Tim`,time:e.createdAt,children:[(0,C.jsx)(`div`,{className:`markdown`,children:(0,C.jsx)(ye,{children:e.body})}),t&&(0,C.jsx)(`button`,{type:`button`,className:`assistant-debug-reply`,onClick:t,children:m(`web.Assistant.24`)})]})})}export{T as Assistant};
|
|
1
|
+
import{B as e,Bt as t,C as n,E as r,F as i,Gt as a,H as o,Ht as s,It as c,K as ee,Lt as l,M as u,O as te,P as d,T as ne,U as re,V as ie,Vt as f,Z as ae,Zt as p,at as m,en as h,f as oe,h as se,it as g,m as ce,p as _,q as v,qt as le}from"./project-links-CodATITq.js";import{A as y,J as ue,K as de,M as fe,N as pe,P as b,Z as x,a as me,j as he,k as ge,r as _e,tt as ve,z as ye}from"./index-Ck_8bv0N.js";import{i as be,n as xe,r as Se,t as Ce}from"./Conversation-Dzr18Rmq.js";import{t as we}from"./MessageComposer-DOJ1PYXg.js";var S=h(p(),1),C=o(),Te=s({topics:c(s({id:a(),title:a(),summary:a(),author:a(),replies:f(),unread:l(),createdAt:a(),updatedAt:a(),delivery:s({available:l(),connected:l(),state:a(),error:a().nullable()})}))}),Ee=e=>new Date(e).toLocaleTimeString(g(),{hour:`2-digit`,minute:`2-digit`}),w=e=>e.replace(/[#*_`>]/g,``).replace(/\s+/g,` `).trim();function T({me:o,mode:c=`messages`}){ie();let{projectId:f,request:p}=ve(),h=i(),T=d(f,o,`${c}-selection`),E=d(f,o,`${c}-drafts`),Oe=(0,S.useCallback)(e=>p(`agents/outbox`,pe,{signal:e}),[p]),D=u(Oe,3e3,d(f,o,`outbox`)),ke=(0,S.useCallback)(async e=>c===`messages`?p(`agents/chats`,ge,{signal:e}):{chats:(await p(`channels/topics`,Te,{signal:e})).topics.map(e=>({...e,kind:`matter`,state:null}))},[p,c]),O=u(ke,3e3,d(f,o,c,`chats`)),[k,Ae]=(0,S.useState)(()=>{let e=new URLSearchParams(location.search),t=e.get(`chat`);return t?`chat:${t}`:e.get(`message`)??h?.get(T)??``}),A=k.startsWith(`chat:`)?k.slice(5):``,j=!k||!!A,[M,N]=(0,S.useState)(()=>h?.get(d(f,o,`chat`,A))),P=M?.id===A?M:h?.get(d(f,o,`chat`,A)),F=O.data?.chats.find(e=>e.id===A),je=j?F?.title??P?.title??(A?m(`web.Assistant.1`):`Tim`):m(k===`debug`?`web.Assistant.2`:`web.Assistant.3`);_e(k?je:void 0);let I=F&&`delivery`in F?F.delivery:void 0,[Me,L]=(0,S.useState)(),[R,z]=(0,S.useState)(()=>h?.get(E)??{}),Ne=R[k]??``,Pe=e=>z(t=>({...t,[k]:e})),[B,V]=(0,S.useState)(!1),[H,Fe]=(0,S.useState)(!1),[Ie,Le]=(0,S.useState)(!1),[Re,U]=(0,S.useState)(!1),[W,ze]=(0,S.useState)(``),[Be,Ve]=(0,S.useState)(``),He=(0,S.useRef)(v()),G=te(),[Ue,K]=e(),q=(0,S.useRef)(new Map),We=(0,S.useRef)(null),Ge=(0,S.useRef)(!0),J=(0,S.useRef)(k);J.current=k,(0,S.useEffect)(()=>{M&&h?.set(d(f,o,`chat`,M.id),M)},[h,f,o,M]),(0,S.useEffect)(()=>{h?.set(E,R)},[h,E,R]);function Y(e){J.current=e,Ae(e),h?.set(T,e);let t=new URL(location.href);e.startsWith(`chat:`)?t.searchParams.set(`chat`,e.slice(5)):t.searchParams.delete(`chat`),e&&!e.startsWith(`chat:`)&&e!==`debug`?t.searchParams.set(`message`,e):t.searchParams.delete(`message`),history.replaceState(history.state,``,t)}(0,S.useEffect)(()=>{!k&&O.data?.chats.length&&Y(`chat:${O.data.chats[0].id}`)},[k,O.data]);let X=(D.data?.messages??[]).filter(e=>c===`messages`&&e.box===`debug`).reverse(),Z=D.data?.messages.find(e=>e.id===(k===`debug`?Me:k));(0,S.useEffect)(()=>{k!==`debug`&&Z?.conversationId&&Y(`chat:${Z.conversationId}`)},[k,Z?.conversationId]);let Q=X.filter(e=>!e.readAt).map(e=>e.id).join(`,`);(0,S.useEffect)(()=>{Z&&!Z.readAt&&k!==`debug`&&p(`agents/outbox/${Z.id}/read`,b,{method:`POST`}).then(()=>{window.dispatchEvent(new Event(`teammy:outbox`)),D.reload()}).catch(e=>G(e))},[Z?.id,Z?.readAt,k,p,D.reload]),(0,S.useEffect)(()=>{k===`debug`&&Q&&Promise.all(Q.split(`,`).map(e=>p(`agents/outbox/${e}/read`,b,{method:`POST`}))).then(()=>{window.dispatchEvent(new Event(`teammy:outbox`)),D.reload()}).catch(e=>G(e))},[k,Q,p,D.reload]),(0,S.useEffect)(()=>{if(K(``),!A)return;let e=!0,t=-1,n=!1,r=new AbortController,i=r=>{!e||r.id!==A||r.cursor<t||(t=r.cursor,n=!0,r.redirect?Y(`chat:${r.redirect}`):r.entry===`channel`&&c!==`channels`?location.replace(ae(`/projects/${f}/channels?chat=${r.id}`)):(N(r),K(``)))};p(`agents/chats/${A}`,y,{signal:r.signal}).then(i).catch(t=>{e&&!r.signal.aborted&&(t instanceof re&&[401,403,404].includes(t.status)&&(h?.delete(d(f,o,`chat`,A)),N(e=>e?.id===A?void 0:e)),n||K(()=>ee(t)))});let l=n=>{let r=Number(n.lastEventId);return!e||!Number.isSafeInteger(r)||r<=t?!1:(t=r,!0)},u=new EventSource(ae(`/api/v1/projects/${encodeURIComponent(f)}/agents/chats/${encodeURIComponent(A)}/events`));u.addEventListener(`snapshot`,t=>{if(e)try{i(y.parse(JSON.parse(t.data)))}catch(e){K(()=>ee(e))}}),u.onerror=()=>{e&&K(()=>m(`web.Assistant.4`))},u.addEventListener(`context`,e=>{if(!l(e))return;let n=y.pick({kind:!0,title:!0,status:!0,visibility:!0,participants:!0,pending:!0,hold:!0,redirect:!0}).parse(JSON.parse(e.data));n.redirect?Y(`chat:${n.redirect}`):N(e=>e?.id===A?{...e,...n,cursor:t}:e)}),u.addEventListener(`message`,e=>{if(!l(e))return;let t=he.parse(JSON.parse(e.data));N(n=>n?.id===A?{...n,readCursor:Math.max(n.readCursor,t.seq),cursor:Math.max(n.cursor,Number(e.lastEventId)||0),messages:[...n.messages.filter(e=>e.id!==t.id),t].sort((e,t)=>e.seq-t.seq)}:n)}),u.addEventListener(`message_removed`,e=>{if(!l(e))return;let{id:n}=s({id:a()}).parse(JSON.parse(e.data));N(e=>e?.id===A?{...e,cursor:t,messages:e.messages.filter(e=>e.id!==n)}:e)}),u.addEventListener(`run`,e=>{if(!l(e))return;let t=fe.parse(JSON.parse(e.data));N(n=>n?.id===A?{...n,cursor:Math.max(n.cursor,Number(e.lastEventId)||0),runs:n.runs.some(e=>e.id===t.id)?n.runs:[...n.runs,t]}:n)});for(let e of[`delta`,`reset`,`state`])u.addEventListener(e,t=>{if(!l(t))return;let n=JSON.parse(t.data);N(r=>r?.id===A?{...r,cursor:Math.max(r.cursor,Number(t.lastEventId)||0),messages:r.messages.map(t=>t.runId!==n.id||t.role!==`assistant`?t:{...t,body:e===`delta`?t.body+(n.text??``):e===`reset`?``:n.answer??t.body,state:n.state??t.state}),runs:r.runs.map(t=>t.id===n.id?{...t,answer:e===`delta`?t.answer+(n.text??``):e===`reset`?``:n.answer??t.answer,state:n.state??t.state,error:n.error===void 0?t.error:n.error}:t)}:r)});return()=>{e=!1,r.abort(),u.close()}},[f,A,o,p,h]),(0,S.useEffect)(()=>{if(!P||P.id!==A)return;let e=()=>{document.visibilityState===`visible`&&p(`agents/chats/${A}/read`,s({ok:l()}),{method:`POST`,body:{cursor:P.readCursor}}).then(()=>{O.reload(),window.dispatchEvent(new Event(`teammy:outbox`))}).catch(e=>G(e))},t=setTimeout(e,300);return document.addEventListener(`visibilitychange`,e),()=>{clearTimeout(t),document.removeEventListener(`visibilitychange`,e)}},[A,P?.readCursor,P?.kind,p]),(0,S.useEffect)(()=>{Ge.current&&We.current?.scrollIntoView({block:`end`})},[k,M?.messages,Z?.recipients,X.length]);function Ke(){window.dispatchEvent(new Event(`teammy:outbox`)),D.reload()}async function $(e){if(Ge.current=!0,Y(e),G(``),L(void 0),e.startsWith(`chat:`)||e===`debug`)return;let t=D.data?.messages.find(t=>t.id===e)?.conversationId;if(t)Y(`chat:${t}`);else try{await p(`agents/outbox/${e}/read`,b,{method:`POST`}),Ke()}catch(e){G(e)}}async function qe(){if(!H){Fe(!0),G(``);try{let e=await p(`agents/chats`,y,{method:`POST`});N(e),await $(`chat:${e.id}`),O.reload()}catch(e){G(e)}finally{Fe(!1)}}}async function Je(e){e.preventDefault();let t=Ne.trim();if(!t||B||H)return;V(!0),G(``);let n=q.current.get(k);n&&n.text===t||(n={text:t,id:v()},q.current.set(k,n));try{if(j){let e=n.target??A;if(!e){let r=await p(`agents/chats`,y,{method:`POST`});e=r.id,n.target=e,q.current.set(`chat:${e}`,n),z(n=>({...n,[`chat:${e}`]:t})),J.current===k&&(N(r),Y(`chat:${e}`))}let r=await p(`agents/chats/${e}`,fe.extend({conversationId:a().optional()}),{method:`POST`,body:{text:t,requestId:n.id}});r.conversationId&&r.conversationId!==e&&(J.current===k||J.current===`chat:${e}`)&&Y(`chat:${r.conversationId}`),N(t=>t?.id===e?{...t,runs:t.runs.some(e=>e.id===r.id)?t.runs:[...t.runs,r]}:t),O.reload()}else{let e=await p(`agents/outbox/${Z.id}/reply`,s({conversationId:a()}),{method:`POST`,body:{body:t,requestId:n.id}});Ke(),J.current===k&&Y(`chat:${e.conversationId}`),O.reload(),L(void 0)}q.current.delete(k),n.target&&q.current.delete(`chat:${n.target}`),z(e=>({...e,[k]:``,...n.target?{[`chat:${n.target}`]:``}:{}}))}catch(e){G(e)}finally{V(!1)}}let Ye=c===`channels`?Se:Ce,Xe=j&&!P?.closed&&(c!==`channels`||!!A)||!!Z&&!Z.archivedAt,Ze=j&&!P&&(!!A||!O.data);return(0,C.jsxs)(xe,{className:c===`channels`?`channel-layout`:``,testId:`assistant-page`,label:m(j?`web.Assistant.5`:`web.Assistant.6`),navigation:(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(ue,{title:m(c===`channels`?`web.Assistant.7`:`web.Assistant.8`),children:(0,C.jsxs)(`div`,{className:`assistant-list-actions`,children:[(0,C.jsx)(_,{className:`assistant-new-chat`,icon:`clear`,label:m(`web.Assistant.9`),disabled:Ie,onClick:()=>{Le(!0),G(``),p(`communication/read`,s({ok:t(!0)}),{method:`POST`,body:{scope:c}}).then(async()=>{window.dispatchEvent(new Event(`teammy:outbox`)),await Promise.all([O.reload(),D.reload()])}).catch(e=>G(e)).finally(()=>Le(!1))}}),(0,C.jsx)(_,{className:`assistant-new-chat`,icon:`plus`,label:m(c===`channels`?`web.Assistant.10`:`web.Assistant.11`),disabled:H,onClick:()=>c===`channels`?U(!0):void qe(),"data-testid":`assistant-launcher`})]})}),(0,C.jsxs)(`div`,{className:`assistant-message-scroll`,children:[O.loading&&!O.data&&(0,C.jsx)(`p`,{className:`assistant-list-status`,role:`status`,children:m(`web.Memory.4`)}),O.data?.chats.map(e=>(0,C.jsxs)(`button`,{type:`button`,"data-testid":`assistant-chat-${e.id}`,className:`assistant-message-item assistant-chat-item ${A===e.id?`selected`:``}`,"aria-pressed":A===e.id,onClick:()=>void $(`chat:${e.id}`),children:[(0,C.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,C.jsx)(x,{selected:A===e.id,children:(0,C.jsx)(`strong`,{children:e.title})}),c===`channels`&&`summary`in e&&(0,C.jsx)(`span`,{className:`topic-preview`,children:w(String(e.summary)).slice(0,140)}),(0,C.jsxs)(`time`,{dateTime:e.updatedAt,children:[new Date(e.updatedAt).toLocaleDateString(g(),{month:`numeric`,day:`numeric`}),` `,Ee(e.updatedAt)]})]}),(0,C.jsx)(`span`,{className:`assistant-message-dot ${e.unread||c!==`channels`&&(e.state===`running`||e.state===`queued`)?`unread`:``}`})]},e.id)),!!X.length&&(0,C.jsxs)(`button`,{type:`button`,"data-testid":`debug-outbox`,className:`assistant-message-item ${k===`debug`?`selected`:``}`,onClick:()=>void $(`debug`),children:[(0,C.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,C.jsx)(x,{selected:k===`debug`,children:(0,C.jsx)(`strong`,{children:m(`web.Assistant.2`)})}),(0,C.jsx)(`span`,{children:w(X.at(-1).body)})]}),(0,C.jsx)(`span`,{className:`assistant-message-dot ${Q?`unread`:``}`})]}),D.data?.messages.filter(e=>c===`messages`&&e.box!==`debug`&&!e.conversationId).sort((e,t)=>Number(!!e.archivedAt)-Number(!!t.archivedAt)).map(e=>(0,C.jsxs)(`button`,{type:`button`,"data-testid":`outbox-${e.id}`,className:`assistant-message-item ${e.archivedAt?`archived`:``} ${k===e.id?`selected`:``}`,onClick:()=>void $(e.id),children:[(0,C.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,C.jsx)(x,{selected:k===e.id,children:(0,C.jsx)(`strong`,{children:w(e.body)})}),(0,C.jsxs)(`time`,{dateTime:e.createdAt,children:[new Date(e.createdAt).toLocaleDateString(g(),{month:`numeric`,day:`numeric`}),` `,Ee(e.createdAt)]})]}),(0,C.jsx)(`span`,{className:`assistant-message-dot ${e.readAt?``:`unread`}`})]},e.id))]}),(0,C.jsx)(r,{resource:D}),(0,C.jsx)(r,{resource:O})]}),children:[Re&&(0,C.jsx)(se,{id:`new-topic`,title:m(`web.Assistant.10`),onClose:()=>U(!1),children:(0,C.jsx)(we,{inset:!0,plain:!0,value:Be,onChange:Ve,label:m(`web.Assistant.12`),placeholder:m(`web.Assistant.13`),sendLabel:m(`web.Assistant.10`),sendDisabled:B||!W.trim(),heading:(0,C.jsx)(`input`,{className:`topic-title`,"aria-label":m(`web.Assistant.14`),placeholder:m(`web.Assistant.14`),required:!0,value:W,onChange:e=>ze(e.target.value)}),onSubmit:e=>{e.preventDefault(),V(!0),G(``),p(`channels/topics`,y,{method:`POST`,body:{id:He.current,title:W,body:Be}}).then(e=>{N(e),Y(`chat:${e.id}`),U(!1),ze(``),Ve(``),He.current=v(),O.reload()}).catch(e=>G(e)).finally(()=>V(!1))}})}),(0,C.jsx)(de,{title:(0,C.jsx)(`h2`,{children:je}),actions:(0,C.jsxs)(C.Fragment,{children:[c===`channels`&&A&&(0,C.jsx)(me,{conversation:A}),c!==`channels`&&P?.kind===`matter`&&(0,C.jsxs)(`span`,{className:`assistant-participants`,title:P.participants?.join(`、`),children:[P.visibility===`project`?m(`web.Assistant.15`):``,P.participants?.join(`、`)]}),c===`channels`&&I?.available&&(I.state===`web`||I.state===`cancelled`||!I.connected)&&(0,C.jsx)(_,{icon:`send`,label:m(`web.Assistant.16`),disabled:B,onClick:()=>{V(!0),p(`channels/topics/${A}/publish`,le(),{method:`POST`}).then(()=>O.reload()).catch(e=>G(e)).finally(()=>V(!1))}})]})}),c===`channels`&&(0,C.jsx)(n,{children:I?.error}),c!==`channels`&&P?.kind===`matter`&&(P.hold||P.pending||P.status===`completed`)&&(0,C.jsx)(`div`,{className:`assistant-matter-state`,role:`status`,children:P.hold?`${P.hold.scope===`all`?m(`web.EventRoutingSettings.28`):m(`web.Assistant.25`)} · ${P.hold.reason}`:P.pending?m(`web.Assistant.17`,{p0:P.pending.members.join(`、`),p1:P.pending.question}):m(`web.Computers.12`)}),(0,C.jsxs)(be,{"data-testid":`assistant-transcript`,onScroll:e=>{let t=e.currentTarget;Ge.current=t.scrollHeight-t.scrollTop-t.clientHeight<100},children:[j?Ze?(0,C.jsxs)(`div`,{className:`assistant-empty`,"data-testid":`assistant-loading`,children:[(0,C.jsx)(ce,{}),(0,C.jsx)(`p`,{role:`status`,children:Ue||(O.error?m(`web.Assistant.18`):m(`web.Memory.4`))})]}):P?.messages.length?P.messages.filter(e=>e.body||[`queued`,`running`,`failed`].includes(e.state)).map(e=>(0,C.jsx)(`div`,{className:`assistant-turn`,children:(0,C.jsxs)(Ye,{mine:e.role===`user`&&e.author===o,author:`${e.role===`assistant`?`Tim`:e.author}${e.source===`wecom`?m(`web.Assistant.26`):``}`,time:e.createdAt,children:[e.body&&(0,C.jsx)(`div`,{className:`markdown`,children:(0,C.jsx)(ye,{children:e.source===`receipt`?m(`request.replyRecorded`):e.body})}),e.role===`assistant`&&[`queued`,`running`].includes(e.state)&&(0,C.jsxs)(`span`,{className:`assistant-typing`,"aria-label":m(`web.Assistant.19`),children:[(0,C.jsx)(`i`,{}),(0,C.jsx)(`i`,{}),(0,C.jsx)(`i`,{})]}),e.state===`failed`&&(0,C.jsx)(n,{children:P.runs.find(t=>t.id===e.runId)?.error||m(`web.Assistant.20`)})]})},e.id)):(0,C.jsxs)(`div`,{className:`assistant-empty`,children:[(0,C.jsx)(ce,{}),(0,C.jsx)(`p`,{children:m(`web.Assistant.21`)})]}):!D.data&&D.loading?(0,C.jsx)(`div`,{className:`assistant-empty`,children:(0,C.jsx)(`p`,{role:`status`,children:m(`web.Memory.4`)})}):k===`debug`?X.map(e=>(0,C.jsx)(De,{item:e,onReply:e.archivedAt?void 0:()=>{L(e.id),Pe(``),G(``)}},e.id)):Z&&(0,C.jsx)(De,{item:Z}),(0,C.jsx)(`div`,{ref:We})]}),(0,C.jsx)(ne,{message:j&&P?Ue:void 0}),Xe?(0,C.jsx)(we,{value:Ne,onChange:Pe,onSubmit:e=>void Je(e),disabled:H,sendDisabled:B||Ze,label:m(j?`web.Assistant.22`:`web.Assistant.23`)}):k!==`debug`&&Z&&(0,C.jsxs)(`div`,{className:`assistant-archived`,children:[(0,C.jsx)(oe,{name:`archive`}),m(`web.Computers.25`)]})]})}function De({item:e,onReply:t}){return ie(),(0,C.jsx)(`div`,{"data-testid":`outbox-thread-${e.id}`,children:(0,C.jsxs)(Ce,{author:e.box===`debug`?m(`web.Assistant.2`):`Tim`,time:e.createdAt,children:[(0,C.jsx)(`div`,{className:`markdown`,children:(0,C.jsx)(ye,{children:e.body})}),t&&(0,C.jsx)(`button`,{type:`button`,className:`assistant-debug-reply`,onClick:t,children:m(`web.Assistant.24`)})]})})}export{T as Assistant};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TerminalPane-
|
|
2
|
-
import{B as e,Bt as t,C as n,E as r,Et as i,F as a,Ft as o,Gt as s,H as c,Ht as l,It as u,K as d,Lt as f,M as p,O as m,P as h,Rt as g,T as _,U as v,V as y,Vt as b,Z as x,Zt as S,_ as C,a as w,at as T,ct as E,en as D,f as O,h as k,it as A,k as j,p as M,q as N,qt as ee,st as P}from"./project-links-BwYckk7L.js";import{B as F,C as te,D as ne,J as re,K as I,O as L,S as ie,T as ae,V as oe,X as se,_ as ce,b as le,c as ue,d as de,et as fe,f as pe,g as me,h as R,i as he,l as ge,m as _e,nt as ve,o as ye,p as be,r as xe,s as Se,t as Ce,tt as we,u as Te,v as Ee,w as De,x as Oe,y as ke,z as Ae}from"./index-BCj5CDtq.js";import{a as je,i as Me,n as Ne,t as Pe}from"./Conversation-BMA0djTl.js";import{n as Fe,t as Ie}from"./MessageComposer-D7ml-LaD.js";import{l as Le,r as Re}from"./WorkspaceTree-C2sVptdG.js";var z=D(S(),1),B=c();function ze({title:e,busy:t,onSave:n}){y();let[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(e);return r?(0,B.jsx)(`form`,{className:`session-title-form`,onSubmit:t=>{t.preventDefault(),a.trim()&&a.trim()!==e&&n(a.trim()),i(!1)},children:(0,B.jsx)(`input`,{autoFocus:!0,"aria-label":T(`web.SessionTitle.1`),value:a,disabled:t,onChange:e=>o(e.target.value),onBlur:()=>i(!1),onKeyDown:e=>{ye(e.nativeEvent)||e.key===`Escape`&&(e.preventDefault(),i(!1))}})}):(0,B.jsx)(`h2`,{children:(0,B.jsx)(`button`,{type:`button`,className:`session-rename`,title:T(`web.SessionTitle.2`),"aria-label":T(`web.SessionTitle.3`,{p0:e}),onClick:()=>{o(e),i(!0)},children:e})})}var V=l({id:s().uuid(),directory:s(),title:s(),cwd:s(),createdAt:s(),state:o([`running`,`exited`]),exitCode:b().nullable()}),H={id:s().uuid(),directory:s().min(1).max(200)},Be={cols:b().int().min(2).max(500),rows:b().int().min(1).max(300)};g(`type`,[l({type:t(`create`),...H,...Be,title:s().trim().min(1).max(160)}),l({type:t(`attach`),...H}),l({type:t(`detach`),...H}),l({type:t(`input`),...H,data:s().max(65536)}),l({type:t(`resize`),...H,...Be}),l({type:t(`rename`),...H,title:s().trim().min(1).max(160)}),l({type:t(`close`),...H})]);var Ve=g(`type`,[l({type:t(`size`),id:s(),...Be}),l({type:t(`inventory`),directories:u(s()),terminals:u(V)}),l({type:t(`snapshot`),id:s(),data:s(),cols:b(),rows:b(),seq:b()}),l({type:t(`output`),id:s(),data:s(),seq:b()}),l({type:t(`result`),id:s(),operation:s(),error:s().optional()})]);function He(e,t){let n=(0,z.useRef)(null),r=(0,z.useRef)(new Set),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)([]),[c,l]=(0,z.useState)([]);(0,z.useEffect)(()=>{if(!t)return;let i=!1,o,c,u=()=>{let t=new URL(x(`/api/v1/projects/${encodeURIComponent(e)}/web/terminals`),location.origin);t.protocol=t.protocol===`https:`?`wss:`:`ws:`,c=new WebSocket(t),n.current=c,c.onmessage=e=>{let t=Ve.safeParse(JSON.parse(e.data));if(!t.success||i)return;let n=t.data;n.type===`inventory`&&(l(n.terminals),s(n.directories),a(!0));for(let e of r.current)e(n)},c.onclose=()=>{a(!1),s([]),i||(o=setTimeout(u,2e3))}};return u(),()=>{i=!0,clearTimeout(o),c?.close(),n.current=null}},[e,t]);let u=(0,z.useCallback)(e=>(r.current.add(e),()=>{r.current.delete(e)}),[]),d=(0,z.useCallback)(e=>{if(n.current?.readyState!==WebSocket.OPEN)throw Error(T(`web.terminals.1`));n.current.send(JSON.stringify(e))},[]);return{connected:i,directories:o,terminals:c,subscribe:u,send:d,request:(0,z.useCallback)(e=>new Promise((t,n)=>{let r=setTimeout(()=>{i(),n(Error(T(`web.terminals.2`)))},15e3),i=u(a=>{a.type===`result`&&a.id===e.id&&a.operation===e.type&&(clearTimeout(r),i(),a.error?n(Error(a.error)):t())});try{d(e)}catch(e){clearTimeout(r),i(),n(e)}}),[d,u])}}l({provider:_e,cursor:s().optional(),session:Ee.optional()});var Ue=l({id:Ee,title:s(),cwd:s(),updatedAt:s().datetime().nullable(),active:f().default(!1)}),We=l({sessions:u(Ue),nextCursor:s().nullable()}),Ge=l({command:ke,history:We.nullable()});function Ke(e,t=Date.now()){if(!e)return``;let n=new Date(e),r=Math.max(0,t-n.getTime());return Number.isFinite(r)?r<36e5?`${Math.floor(r/6e4)}min`:r<864e5?`${Math.floor(r/36e5)}h`:r<=6048e5?`${Math.floor(r/864e5)}day`:`${String(n.getFullYear()).slice(-2)}/${String(n.getMonth()+1).padStart(2,`0`)}/${String(n.getDate()).padStart(2,`0`)}`:``}function qe({id:e,label:t,value:n,onChange:r,options:i,placeholder:a,loading:o=!1,disabled:s=!1,empty:c=T(`web.Combobox.1`),footer:l}){y();let[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(``),[m,h]=(0,z.useState)(),g=(0,z.useRef)(null),_=(0,z.useRef)(null),v=(0,z.useRef)(null),b=i.find(e=>e.value===n),x=b?``:n.trim().toLocaleLowerCase(),S=i.filter(e=>`${e.label} ${e.value}`.toLocaleLowerCase().includes(x)),C=S.filter(e=>!e.disabled),w=S.findIndex(e=>e.value===f);(0,z.useEffect)(()=>p(``),[n]),(0,z.useEffect)(()=>{if(!u)return;let e=e=>{g.current?.contains(e.target)||d(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[u]),(0,z.useLayoutEffect)(()=>{if(!u)return;let e=()=>{let e=_.current?.getBoundingClientRect();if(!e)return;let t=innerHeight-e.bottom-16,n=e.top-16,r=t<220&&n>t;h({left:e.left,width:e.width,top:r?void 0:e.bottom+6,bottom:r?innerHeight-e.top+6:void 0,maxHeight:Math.min(320,r?n:t)})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[u]),(0,z.useEffect)(()=>{u&&w>=0&&document.getElementById(`${e}-option-${w}`)?.scrollIntoView({block:`nearest`})},[u,w,e]);function E(e){e.disabled||(r(e.value),d(!1),v.current?.focus())}return(0,B.jsxs)(`div`,{className:`combobox`,ref:g,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||d(!1)},onKeyDown:e=>{ye(e.nativeEvent)||e.key===`Escape`&&u&&(e.preventDefault(),e.stopPropagation(),d(!1),v.current?.focus())},children:[(0,B.jsxs)(`div`,{className:`combobox-field`,ref:_,children:[(0,B.jsx)(`input`,{id:e,ref:v,role:`combobox`,"aria-label":t,"aria-autocomplete":`list`,"aria-expanded":u,"aria-controls":`${e}-list`,"aria-activedescendant":u&&w>=0?`${e}-option-${w}`:void 0,autoComplete:`off`,disabled:s,value:b?.label??n,title:b?.value,placeholder:a,onClick:()=>d(!0),onChange:e=>{r(e.target.value),d(!0)},onKeyDown:e=>{if(!ye(e.nativeEvent)){if([`ArrowDown`,`ArrowUp`].includes(e.key)){e.preventDefault(),d(!0);let t=C.findIndex(e=>e.value===f),n=t<0?e.key===`ArrowDown`?0:C.length-1:(t+(e.key===`ArrowDown`?1:-1)+C.length)%C.length;p(C[n]?.value??``)}else e.key===`Enter`&&u&&w>=0?(e.preventDefault(),E(S[w])):e.key===`Tab`&&d(!1)}}}),(0,B.jsx)(M,{icon:u?`chevronUp`:`chevronDown`,label:`${T(u?`web.TaskBoard.15`:`web.Combobox.3`)}${t}`,disabled:s,"aria-expanded":u,"aria-controls":`${e}-list`,onClick:()=>{d(!u),v.current?.focus()}})]}),u&&(0,B.jsxs)(`div`,{className:`combobox-popup`,style:m,children:[(0,B.jsxs)(`div`,{id:`${e}-list`,role:`listbox`,"aria-label":t,"aria-busy":o,children:[S.map((t,r)=>(0,B.jsxs)(`button`,{id:`${e}-option-${r}`,type:`button`,role:`option`,"aria-selected":t.value===n,disabled:t.disabled,tabIndex:-1,className:`combobox-option ${t.value===f?`active`:``}`,title:`${t.label} · ${t.value}`,onMouseDown:e=>e.preventDefault(),onClick:()=>E(t),children:[(0,B.jsxs)(`span`,{className:`combobox-option-copy`,children:[(0,B.jsx)(`span`,{children:t.label}),t.description&&(0,B.jsx)(`small`,{children:t.description})]}),t.detail&&(0,B.jsx)(`span`,{className:`combobox-option-detail`,children:t.detail})]},t.value)),o&&(0,B.jsx)(`p`,{className:`combobox-message`,role:`status`,children:T(`web.Combobox.2`)}),!o&&!S.length&&(0,B.jsx)(`p`,{className:`combobox-message`,children:c})]}),l&&(0,B.jsx)(`div`,{className:`combobox-footer`,children:l})]})]})}function Je({directory:e,provider:t,providers:n,sessions:r,request:i,onClose:a,onImport:o}){y();let[s,c]=(0,z.useState)(t),[l,u]=(0,z.useState)([]),[d,f]=(0,z.useState)(null),[p,h]=(0,z.useState)(``),[g,_]=(0,z.useState)(null),v=m(),b=(0,z.useRef)(null),x=e=>r.find(t=>!t.hidden&&t.provider===s&&(t.nativeSession??t.resumeSession)===e);async function S(t,n){let r=N();for(await i(`web/local-agents/${e}/history`,ke,{method:`POST`,signal:n,body:{id:r,argument:JSON.stringify({provider:s,...t})}});!n.aborted;){let t=await i(`web/local-agents/${e}/history/${r}`,Ge,{signal:n});if(t.command.state===`succeeded`&&t.history)return{...t.history,id:r};if(![`queued`,`running`].includes(t.command.state))throw Error(t.command.error||T(`web.NativeHistoryDialog.1`));await new Promise(e=>{let t=()=>{clearTimeout(r),n.removeEventListener(`abort`,t),e()},r=setTimeout(t,1e3);n.addEventListener(`abort`,t,{once:!0})})}throw new DOMException(`Aborted`,`AbortError`)}async function C(t,n,r){let a=x(t.id)??await i(`web/local-agents/${e}/sessions`,ce,{method:`POST`,signal:r,body:{id:N(),title:t.title,provider:s,resumeSession:t.id,historyRequest:n}});r.aborted||o(a)}async function w(e,t){b.current?.abort();let n=new AbortController;b.current=n,_(e),v(``);try{await t(n.signal)}catch(e){n.signal.aborted||v(e)}finally{n.signal.aborted||_(null)}}let E=e=>w(`list`,async t=>{let n=await S(e?{cursor:e}:{},t);t.aborted||(u(t=>{let r=[...e?t:[],...n.sessions.map(e=>({...e,requestId:n.id}))];return[...new Map(r.map(e=>[e.id,e])).values()].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``))}),f(n.nextCursor))});(0,z.useEffect)(()=>(u([]),f(null),h(``),E(),()=>b.current?.abort()),[s,e,i]);let D=l.find(e=>e.id===p),O=g===`import`;return(0,B.jsx)(k,{id:`computer-import-session`,title:T(`web.Computers.32`),onClose:a,children:(0,B.jsxs)(`form`,{className:`native-history`,onSubmit:e=>{e.preventDefault(),w(`import`,async e=>{let t=p.trim(),n=x(t);if(n)return o(n);if(D)return C(D,D.requestId,e);let r=await S({session:t},e),i=r.sessions.find(e=>e.id===t);if(!i)throw Error(T(`web.NativeHistoryDialog.2`));await C(i,r.id,e)})},children:[(0,B.jsx)(ue,{label:T(`web.NativeHistoryDialog.3`),value:s,onChange:c,providers:[t,...n],disabled:O}),(0,B.jsxs)(`div`,{className:`field`,children:[(0,B.jsx)(`label`,{htmlFor:`native-history-session`,children:`Session`}),(0,B.jsxs)(`div`,{className:`native-history-input-row`,children:[(0,B.jsx)(qe,{id:`native-history-session`,label:T(`web.NativeHistoryDialog.4`),value:p,onChange:h,placeholder:T(`web.NativeHistoryDialog.5`),disabled:O,loading:g===`list`,empty:T(p?`web.NativeHistoryDialog.6`:`web.NativeHistoryDialog.7`),options:l.map(e=>({value:e.id,label:e.title,description:e.id,detail:x(e.id)?T(`web.EventRoutingSettings.22`):e.active?T(`web.Computers.2`):Ke(e.updatedAt),disabled:e.active&&!x(e.id)})),footer:(0,B.jsxs)(B.Fragment,{children:[d&&(0,B.jsx)(`button`,{className:`native-history-more`,type:`button`,disabled:!!g,onClick:()=>void E(d),children:T(`web.labels.52`)}),(0,B.jsx)(M,{icon:`refresh`,label:T(`web.NativeHistoryDialog.8`),disabled:!!g,onClick:()=>void E()})]})},s),(0,B.jsx)(`button`,{type:`submit`,disabled:O||!Ee.safeParse(p.trim()).success||!!D?.active&&!x(D.id),children:O?T(`web.NativeHistoryDialog.9`):x(p.trim())?T(`web.NativeHistoryDialog.10`):T(`web.NativeHistoryDialog.11`)})]})]}),(0,B.jsx)(`small`,{className:`muted`,children:T(`web.NativeHistoryDialog.12`)})]})})}var U={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,webp:`image/webp`,gif:`image/gif`,avif:`image/avif`,bmp:`image/bmp`,ico:`image/x-icon`,svg:`image/svg+xml`};function Ye(e,t){let n=e.toLowerCase().split(`.`).at(-1)??``;return t&&Object.values(U).includes(t)?t:Object.hasOwn(U,n)?U[n]:n===`pdf`?`application/pdf`:/^(md|markdown|mdown)$/.test(n)?`text/markdown`:/^html?$/.test(n)?`text/html`:/^(txt|log|csv|tsv|jsonl?|ndjson|ya?ml|toml|ini|cfg|conf|xml|sql|diff|patch|sh|bash|zsh|fish|py|js|jsx|mjs|cjs|ts|tsx|css|scss|vue|svelte|go|rs|c|cc|cpp|h|hpp|java|kt|swift|rb|lua|r|tex|rst|properties|env|lock)$/.test(n)||/^(readme|license|makefile|dockerfile|cmakelists\.txt|\.gitignore)$/i.test(e)?`text/plain`:``}async function Xe(e,t){let n=e.body.getReader(),r=[],i=0,a=(t??0)>L;try{for(;;){let{done:e,value:t}=await n.read();if(e)break;let o=Math.min(t.length,L-i);if(r.push(t.slice(0,o)),i+=o,o<t.length||a&&i===524288){a=!0;break}}}finally{await n.cancel(),n.releaseLock()}return{blob:new Blob(r),truncated:a}}async function Ze(e,t,n,r){let i=e.previewUrl??e.url;if(i.startsWith(`data:`)&&t.startsWith(`image/`))return{format:t,preview:i,download:i};if(!t&&!e.previewUrl)return{format:``};let a=await fetch(i,{credentials:`same-origin`,cache:`no-store`,signal:n});if(!a.ok)throw Error((await a.json().catch(()=>null))?.error?.message??T(`web.FilePreview.1`));if(!t)return await a.body?.cancel(),{format:``};if(t.startsWith(`text/`)){let n=a.headers.get(`X-Teammy-File-Size`)??a.headers.get(`Content-Length`),{blob:i,truncated:o}=await Xe(a,n===null?e.size:Number(n)),s=o?void 0:r(i.slice(0,i.size,`application/octet-stream`)),c;try{c=new TextDecoder(`utf-8`,{fatal:!0}).decode(await i.arrayBuffer(),{stream:o})}catch{return{format:``,download:s}}return c.includes(`\0`)?{format:``,download:s}:{format:t,text:c,truncated:o,download:s}}let o=await a.blob();if(t===`image/svg+xml`)return{format:t,preview:`data:image/svg+xml;charset=utf-8,`+encodeURIComponent(await o.text()),download:r(o.slice(0,o.size,`application/octet-stream`))};if(t===`application/pdf`&&(navigator.pdfViewerEnabled===!1||await o.slice(0,5).text()!==`%PDF-`))return{format:``,download:r(o.slice(0,o.size,`application/octet-stream`))};let s=r(o.slice(0,o.size,t));return{format:t,preview:s,download:s}}function Qe({file:t,onClose:r,gallery:i}){y();let[a,o]=(0,z.useState)(),[s,c]=e(),[l,u]=(0,z.useState)(0),[f,p]=(0,z.useState)(!1),m=(0,z.useRef)(null),h=(0,z.useRef)(null),g=Ye(t.name,t.mimeType),{name:_,url:v,previewUrl:b,size:x}=t;(0,z.useEffect)(()=>{let e=new AbortController,t;return o(void 0),c(``),p(!1),Ze({name:_,url:v,previewUrl:b,size:x},g,e.signal,n=>(e.signal.throwIfAborted(),t=URL.createObjectURL(n),t)).then(t=>{e.signal.aborted||o(t)}).catch(t=>{e.signal.aborted||c(()=>d(t))}),m.current?.focus(),()=>{e.abort(),t&&URL.revokeObjectURL(t)}},[v,x,b,_,g,l]),(0,z.useEffect)(()=>{h.current?.scrollIntoView({block:`center`})},[a,t.line]);let S=t.line&&a?.text!==void 0?a.text.split(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TerminalPane-jJa53g04.js","./project-links-CodATITq.js","./project-links-ktgqMqAD.css","./index-Ck_8bv0N.js","./index-B9gF6reY.css","./TerminalPane-BrSy-0jI.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{B as e,Bt as t,C as n,E as r,Et as i,F as a,Ft as o,Gt as s,H as c,Ht as l,It as u,K as d,Lt as f,M as p,O as m,P as h,Rt as g,T as _,U as v,V as y,Vt as b,Z as x,Zt as S,_ as C,a as w,at as T,ct as E,en as D,f as O,h as k,it as A,k as j,p as M,q as N,qt as ee,st as P}from"./project-links-CodATITq.js";import{B as F,C as te,D as ne,J as re,K as I,O as L,S as ie,T as ae,V as oe,X as se,_ as ce,b as le,c as ue,d as de,et as fe,f as pe,g as me,h as R,i as he,l as ge,m as _e,nt as ve,o as ye,p as be,r as xe,s as Se,t as Ce,tt as we,u as Te,v as Ee,w as De,x as Oe,y as ke,z as Ae}from"./index-Ck_8bv0N.js";import{a as je,i as Me,n as Ne,t as Pe}from"./Conversation-Dzr18Rmq.js";import{n as Fe,t as Ie}from"./MessageComposer-DOJ1PYXg.js";import{l as Le,r as Re}from"./WorkspaceTree-CuwIu3vj.js";var z=D(S(),1),B=c();function ze({title:e,busy:t,onSave:n}){y();let[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(e);return r?(0,B.jsx)(`form`,{className:`session-title-form`,onSubmit:t=>{t.preventDefault(),a.trim()&&a.trim()!==e&&n(a.trim()),i(!1)},children:(0,B.jsx)(`input`,{autoFocus:!0,"aria-label":T(`web.SessionTitle.1`),value:a,disabled:t,onChange:e=>o(e.target.value),onBlur:()=>i(!1),onKeyDown:e=>{ye(e.nativeEvent)||e.key===`Escape`&&(e.preventDefault(),i(!1))}})}):(0,B.jsx)(`h2`,{children:(0,B.jsx)(`button`,{type:`button`,className:`session-rename`,title:T(`web.SessionTitle.2`),"aria-label":T(`web.SessionTitle.3`,{p0:e}),onClick:()=>{o(e),i(!0)},children:e})})}var V=l({id:s().uuid(),directory:s(),title:s(),cwd:s(),createdAt:s(),state:o([`running`,`exited`]),exitCode:b().nullable()}),H={id:s().uuid(),directory:s().min(1).max(200)},Be={cols:b().int().min(2).max(500),rows:b().int().min(1).max(300)};g(`type`,[l({type:t(`create`),...H,...Be,title:s().trim().min(1).max(160)}),l({type:t(`attach`),...H}),l({type:t(`detach`),...H}),l({type:t(`input`),...H,data:s().max(65536)}),l({type:t(`resize`),...H,...Be}),l({type:t(`rename`),...H,title:s().trim().min(1).max(160)}),l({type:t(`close`),...H})]);var Ve=g(`type`,[l({type:t(`size`),id:s(),...Be}),l({type:t(`inventory`),directories:u(s()),terminals:u(V)}),l({type:t(`snapshot`),id:s(),data:s(),cols:b(),rows:b(),seq:b()}),l({type:t(`output`),id:s(),data:s(),seq:b()}),l({type:t(`result`),id:s(),operation:s(),error:s().optional()})]);function He(e,t){let n=(0,z.useRef)(null),r=(0,z.useRef)(new Set),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)([]),[c,l]=(0,z.useState)([]);(0,z.useEffect)(()=>{if(!t)return;let i=!1,o,c,u=()=>{let t=new URL(x(`/api/v1/projects/${encodeURIComponent(e)}/web/terminals`),location.origin);t.protocol=t.protocol===`https:`?`wss:`:`ws:`,c=new WebSocket(t),n.current=c,c.onmessage=e=>{let t=Ve.safeParse(JSON.parse(e.data));if(!t.success||i)return;let n=t.data;n.type===`inventory`&&(l(n.terminals),s(n.directories),a(!0));for(let e of r.current)e(n)},c.onclose=()=>{a(!1),s([]),i||(o=setTimeout(u,2e3))}};return u(),()=>{i=!0,clearTimeout(o),c?.close(),n.current=null}},[e,t]);let u=(0,z.useCallback)(e=>(r.current.add(e),()=>{r.current.delete(e)}),[]),d=(0,z.useCallback)(e=>{if(n.current?.readyState!==WebSocket.OPEN)throw Error(T(`web.terminals.1`));n.current.send(JSON.stringify(e))},[]);return{connected:i,directories:o,terminals:c,subscribe:u,send:d,request:(0,z.useCallback)(e=>new Promise((t,n)=>{let r=setTimeout(()=>{i(),n(Error(T(`web.terminals.2`)))},15e3),i=u(a=>{a.type===`result`&&a.id===e.id&&a.operation===e.type&&(clearTimeout(r),i(),a.error?n(Error(a.error)):t())});try{d(e)}catch(e){clearTimeout(r),i(),n(e)}}),[d,u])}}l({provider:_e,cursor:s().optional(),session:Ee.optional()});var Ue=l({id:Ee,title:s(),cwd:s(),updatedAt:s().datetime().nullable(),active:f().default(!1)}),We=l({sessions:u(Ue),nextCursor:s().nullable()}),Ge=l({command:ke,history:We.nullable()});function Ke(e,t=Date.now()){if(!e)return``;let n=new Date(e),r=Math.max(0,t-n.getTime());return Number.isFinite(r)?r<36e5?`${Math.floor(r/6e4)}min`:r<864e5?`${Math.floor(r/36e5)}h`:r<=6048e5?`${Math.floor(r/864e5)}day`:`${String(n.getFullYear()).slice(-2)}/${String(n.getMonth()+1).padStart(2,`0`)}/${String(n.getDate()).padStart(2,`0`)}`:``}function qe({id:e,label:t,value:n,onChange:r,options:i,placeholder:a,loading:o=!1,disabled:s=!1,empty:c=T(`web.Combobox.1`),footer:l}){y();let[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(``),[m,h]=(0,z.useState)(),g=(0,z.useRef)(null),_=(0,z.useRef)(null),v=(0,z.useRef)(null),b=i.find(e=>e.value===n),x=b?``:n.trim().toLocaleLowerCase(),S=i.filter(e=>`${e.label} ${e.value}`.toLocaleLowerCase().includes(x)),C=S.filter(e=>!e.disabled),w=S.findIndex(e=>e.value===f);(0,z.useEffect)(()=>p(``),[n]),(0,z.useEffect)(()=>{if(!u)return;let e=e=>{g.current?.contains(e.target)||d(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[u]),(0,z.useLayoutEffect)(()=>{if(!u)return;let e=()=>{let e=_.current?.getBoundingClientRect();if(!e)return;let t=innerHeight-e.bottom-16,n=e.top-16,r=t<220&&n>t;h({left:e.left,width:e.width,top:r?void 0:e.bottom+6,bottom:r?innerHeight-e.top+6:void 0,maxHeight:Math.min(320,r?n:t)})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[u]),(0,z.useEffect)(()=>{u&&w>=0&&document.getElementById(`${e}-option-${w}`)?.scrollIntoView({block:`nearest`})},[u,w,e]);function E(e){e.disabled||(r(e.value),d(!1),v.current?.focus())}return(0,B.jsxs)(`div`,{className:`combobox`,ref:g,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||d(!1)},onKeyDown:e=>{ye(e.nativeEvent)||e.key===`Escape`&&u&&(e.preventDefault(),e.stopPropagation(),d(!1),v.current?.focus())},children:[(0,B.jsxs)(`div`,{className:`combobox-field`,ref:_,children:[(0,B.jsx)(`input`,{id:e,ref:v,role:`combobox`,"aria-label":t,"aria-autocomplete":`list`,"aria-expanded":u,"aria-controls":`${e}-list`,"aria-activedescendant":u&&w>=0?`${e}-option-${w}`:void 0,autoComplete:`off`,disabled:s,value:b?.label??n,title:b?.value,placeholder:a,onClick:()=>d(!0),onChange:e=>{r(e.target.value),d(!0)},onKeyDown:e=>{if(!ye(e.nativeEvent)){if([`ArrowDown`,`ArrowUp`].includes(e.key)){e.preventDefault(),d(!0);let t=C.findIndex(e=>e.value===f),n=t<0?e.key===`ArrowDown`?0:C.length-1:(t+(e.key===`ArrowDown`?1:-1)+C.length)%C.length;p(C[n]?.value??``)}else e.key===`Enter`&&u&&w>=0?(e.preventDefault(),E(S[w])):e.key===`Tab`&&d(!1)}}}),(0,B.jsx)(M,{icon:u?`chevronUp`:`chevronDown`,label:`${T(u?`web.TaskBoard.15`:`web.Combobox.3`)}${t}`,disabled:s,"aria-expanded":u,"aria-controls":`${e}-list`,onClick:()=>{d(!u),v.current?.focus()}})]}),u&&(0,B.jsxs)(`div`,{className:`combobox-popup`,style:m,children:[(0,B.jsxs)(`div`,{id:`${e}-list`,role:`listbox`,"aria-label":t,"aria-busy":o,children:[S.map((t,r)=>(0,B.jsxs)(`button`,{id:`${e}-option-${r}`,type:`button`,role:`option`,"aria-selected":t.value===n,disabled:t.disabled,tabIndex:-1,className:`combobox-option ${t.value===f?`active`:``}`,title:`${t.label} · ${t.value}`,onMouseDown:e=>e.preventDefault(),onClick:()=>E(t),children:[(0,B.jsxs)(`span`,{className:`combobox-option-copy`,children:[(0,B.jsx)(`span`,{children:t.label}),t.description&&(0,B.jsx)(`small`,{children:t.description})]}),t.detail&&(0,B.jsx)(`span`,{className:`combobox-option-detail`,children:t.detail})]},t.value)),o&&(0,B.jsx)(`p`,{className:`combobox-message`,role:`status`,children:T(`web.Combobox.2`)}),!o&&!S.length&&(0,B.jsx)(`p`,{className:`combobox-message`,children:c})]}),l&&(0,B.jsx)(`div`,{className:`combobox-footer`,children:l})]})]})}function Je({directory:e,provider:t,providers:n,sessions:r,request:i,onClose:a,onImport:o}){y();let[s,c]=(0,z.useState)(t),[l,u]=(0,z.useState)([]),[d,f]=(0,z.useState)(null),[p,h]=(0,z.useState)(``),[g,_]=(0,z.useState)(null),v=m(),b=(0,z.useRef)(null),x=e=>r.find(t=>!t.hidden&&t.provider===s&&(t.nativeSession??t.resumeSession)===e);async function S(t,n){let r=N();for(await i(`web/local-agents/${e}/history`,ke,{method:`POST`,signal:n,body:{id:r,argument:JSON.stringify({provider:s,...t})}});!n.aborted;){let t=await i(`web/local-agents/${e}/history/${r}`,Ge,{signal:n});if(t.command.state===`succeeded`&&t.history)return{...t.history,id:r};if(![`queued`,`running`].includes(t.command.state))throw Error(t.command.error||T(`web.NativeHistoryDialog.1`));await new Promise(e=>{let t=()=>{clearTimeout(r),n.removeEventListener(`abort`,t),e()},r=setTimeout(t,1e3);n.addEventListener(`abort`,t,{once:!0})})}throw new DOMException(`Aborted`,`AbortError`)}async function C(t,n,r){let a=x(t.id)??await i(`web/local-agents/${e}/sessions`,ce,{method:`POST`,signal:r,body:{id:N(),title:t.title,provider:s,resumeSession:t.id,historyRequest:n}});r.aborted||o(a)}async function w(e,t){b.current?.abort();let n=new AbortController;b.current=n,_(e),v(``);try{await t(n.signal)}catch(e){n.signal.aborted||v(e)}finally{n.signal.aborted||_(null)}}let E=e=>w(`list`,async t=>{let n=await S(e?{cursor:e}:{},t);t.aborted||(u(t=>{let r=[...e?t:[],...n.sessions.map(e=>({...e,requestId:n.id}))];return[...new Map(r.map(e=>[e.id,e])).values()].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``))}),f(n.nextCursor))});(0,z.useEffect)(()=>(u([]),f(null),h(``),E(),()=>b.current?.abort()),[s,e,i]);let D=l.find(e=>e.id===p),O=g===`import`;return(0,B.jsx)(k,{id:`computer-import-session`,title:T(`web.Computers.32`),onClose:a,children:(0,B.jsxs)(`form`,{className:`native-history`,onSubmit:e=>{e.preventDefault(),w(`import`,async e=>{let t=p.trim(),n=x(t);if(n)return o(n);if(D)return C(D,D.requestId,e);let r=await S({session:t},e),i=r.sessions.find(e=>e.id===t);if(!i)throw Error(T(`web.NativeHistoryDialog.2`));await C(i,r.id,e)})},children:[(0,B.jsx)(ue,{label:T(`web.NativeHistoryDialog.3`),value:s,onChange:c,providers:[t,...n],disabled:O}),(0,B.jsxs)(`div`,{className:`field`,children:[(0,B.jsx)(`label`,{htmlFor:`native-history-session`,children:`Session`}),(0,B.jsxs)(`div`,{className:`native-history-input-row`,children:[(0,B.jsx)(qe,{id:`native-history-session`,label:T(`web.NativeHistoryDialog.4`),value:p,onChange:h,placeholder:T(`web.NativeHistoryDialog.5`),disabled:O,loading:g===`list`,empty:T(p?`web.NativeHistoryDialog.6`:`web.NativeHistoryDialog.7`),options:l.map(e=>({value:e.id,label:e.title,description:e.id,detail:x(e.id)?T(`web.EventRoutingSettings.22`):e.active?T(`web.Computers.2`):Ke(e.updatedAt),disabled:e.active&&!x(e.id)})),footer:(0,B.jsxs)(B.Fragment,{children:[d&&(0,B.jsx)(`button`,{className:`native-history-more`,type:`button`,disabled:!!g,onClick:()=>void E(d),children:T(`web.labels.52`)}),(0,B.jsx)(M,{icon:`refresh`,label:T(`web.NativeHistoryDialog.8`),disabled:!!g,onClick:()=>void E()})]})},s),(0,B.jsx)(`button`,{type:`submit`,disabled:O||!Ee.safeParse(p.trim()).success||!!D?.active&&!x(D.id),children:O?T(`web.NativeHistoryDialog.9`):x(p.trim())?T(`web.NativeHistoryDialog.10`):T(`web.NativeHistoryDialog.11`)})]})]}),(0,B.jsx)(`small`,{className:`muted`,children:T(`web.NativeHistoryDialog.12`)})]})})}var U={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,webp:`image/webp`,gif:`image/gif`,avif:`image/avif`,bmp:`image/bmp`,ico:`image/x-icon`,svg:`image/svg+xml`};function Ye(e,t){let n=e.toLowerCase().split(`.`).at(-1)??``;return t&&Object.values(U).includes(t)?t:Object.hasOwn(U,n)?U[n]:n===`pdf`?`application/pdf`:/^(md|markdown|mdown)$/.test(n)?`text/markdown`:/^html?$/.test(n)?`text/html`:/^(txt|log|csv|tsv|jsonl?|ndjson|ya?ml|toml|ini|cfg|conf|xml|sql|diff|patch|sh|bash|zsh|fish|py|js|jsx|mjs|cjs|ts|tsx|css|scss|vue|svelte|go|rs|c|cc|cpp|h|hpp|java|kt|swift|rb|lua|r|tex|rst|properties|env|lock)$/.test(n)||/^(readme|license|makefile|dockerfile|cmakelists\.txt|\.gitignore)$/i.test(e)?`text/plain`:``}async function Xe(e,t){let n=e.body.getReader(),r=[],i=0,a=(t??0)>L;try{for(;;){let{done:e,value:t}=await n.read();if(e)break;let o=Math.min(t.length,L-i);if(r.push(t.slice(0,o)),i+=o,o<t.length||a&&i===524288){a=!0;break}}}finally{await n.cancel(),n.releaseLock()}return{blob:new Blob(r),truncated:a}}async function Ze(e,t,n,r){let i=e.previewUrl??e.url;if(i.startsWith(`data:`)&&t.startsWith(`image/`))return{format:t,preview:i,download:i};if(!t&&!e.previewUrl)return{format:``};let a=await fetch(i,{credentials:`same-origin`,cache:`no-store`,signal:n});if(!a.ok)throw Error((await a.json().catch(()=>null))?.error?.message??T(`web.FilePreview.1`));if(!t)return await a.body?.cancel(),{format:``};if(t.startsWith(`text/`)){let n=a.headers.get(`X-Teammy-File-Size`)??a.headers.get(`Content-Length`),{blob:i,truncated:o}=await Xe(a,n===null?e.size:Number(n)),s=o?void 0:r(i.slice(0,i.size,`application/octet-stream`)),c;try{c=new TextDecoder(`utf-8`,{fatal:!0}).decode(await i.arrayBuffer(),{stream:o})}catch{return{format:``,download:s}}return c.includes(`\0`)?{format:``,download:s}:{format:t,text:c,truncated:o,download:s}}let o=await a.blob();if(t===`image/svg+xml`)return{format:t,preview:`data:image/svg+xml;charset=utf-8,`+encodeURIComponent(await o.text()),download:r(o.slice(0,o.size,`application/octet-stream`))};if(t===`application/pdf`&&(navigator.pdfViewerEnabled===!1||await o.slice(0,5).text()!==`%PDF-`))return{format:``,download:r(o.slice(0,o.size,`application/octet-stream`))};let s=r(o.slice(0,o.size,t));return{format:t,preview:s,download:s}}function Qe({file:t,onClose:r,gallery:i}){y();let[a,o]=(0,z.useState)(),[s,c]=e(),[l,u]=(0,z.useState)(0),[f,p]=(0,z.useState)(!1),m=(0,z.useRef)(null),h=(0,z.useRef)(null),g=Ye(t.name,t.mimeType),{name:_,url:v,previewUrl:b,size:x}=t;(0,z.useEffect)(()=>{let e=new AbortController,t;return o(void 0),c(``),p(!1),Ze({name:_,url:v,previewUrl:b,size:x},g,e.signal,n=>(e.signal.throwIfAborted(),t=URL.createObjectURL(n),t)).then(t=>{e.signal.aborted||o(t)}).catch(t=>{e.signal.aborted||c(()=>d(t))}),m.current?.focus(),()=>{e.abort(),t&&URL.revokeObjectURL(t)}},[v,x,b,_,g,l]),(0,z.useEffect)(()=>{h.current?.scrollIntoView({block:`center`})},[a,t.line]);let S=t.line&&a?.text!==void 0?a.text.split(`
|
|
3
3
|
`):null,C=(t.line??1)-1,w=g.startsWith(`image/`);return(0,B.jsx)(k,{id:`session-image-lightbox`,title:t.name,label:T(w?`web.FilePreview.2`:`web.labels.2`),onClose:r,onKeyDown:e=>{i&&[`ArrowLeft`,`ArrowRight`].includes(e.key)&&(e.preventDefault(),i.move(e.key===`ArrowLeft`?-1:1))},actions:(0,B.jsxs)(B.Fragment,{children:[i&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(M,{icon:`chevron`,className:`session-image-previous`,label:T(`web.FilePreview.3`),onClick:()=>i.move(-1)}),(0,B.jsxs)(`small`,{children:[i.index+1,` / `,i.count]}),(0,B.jsx)(M,{icon:`chevron`,label:T(`web.FilePreview.4`),onClick:()=>i.move(1)})]}),w&&a?.format&&(0,B.jsx)(M,{icon:f?`zoomOut`:`zoomIn`,label:T(f?`web.FilePreview.5`:`web.FilePreview.6`),"aria-pressed":f,onClick:()=>p(!f)}),(0,B.jsx)(`a`,{className:`icon-button`,href:s?void 0:a?.download??t.url,"aria-disabled":!!s,download:t.name,"aria-label":T(`web.FilePreview.7`),title:T(`web.FilePreview.7`),children:(0,B.jsx)(O,{name:`download`})})]}),children:(0,B.jsx)(`div`,{ref:m,tabIndex:-1,className:`session-image-viewer`,children:s?(0,B.jsx)(n,{announce:!0,retry:()=>u(e=>e+1),children:s}):a?a.format?w?(0,B.jsx)(`div`,{className:`session-image-stage`+(f?` original-size`:``),children:(0,B.jsx)(`img`,{src:a.preview,alt:t.name,onError:()=>o({format:``,download:a.download})})}):a.format===`application/pdf`?(0,B.jsx)(`iframe`,{className:`file-preview-document`,src:a.preview,title:t.name+T(`web.FilePreview.10`)}):a.format===`text/html`&&!t.line?(0,B.jsx)(Le,{name:t.name,url:t.url}):(0,B.jsxs)(`div`,{className:`file-preview-text`,children:[a.format===`text/markdown`&&!t.line?(0,B.jsx)(`article`,{className:`markdown`,children:(0,B.jsx)(Ae,{children:a.text??``})}):(0,B.jsx)(`pre`,{className:`raw`,children:S&&C<S.length?(0,B.jsxs)(B.Fragment,{children:[C>0&&S.slice(0,C).join(`
|
|
4
4
|
`)+`
|
|
5
5
|
`,(0,B.jsx)(`mark`,{ref:h,children:S[C]||` `}),S.length>C+1?`
|
|
6
6
|
`+S.slice(C+1).join(`
|
|
7
|
-
`):``]}):a.text}),a.truncated&&(0,B.jsx)(`small`,{children:T(`web.FilePreview.11`)})]}):(0,B.jsx)(`p`,{className:`file-preview-empty`,children:T(`web.FilePreview.9`)}):(0,B.jsx)(`p`,{role:`status`,children:T(`web.FilePreview.8`)})})})}var $e=[];function et(e){if(`image/png,image/jpeg,image/webp`.split(`,`).includes(e.type))return e.type;if(e.type&&e.type!==`application/octet-stream`)return null;let t=e.name.split(`.`).at(-1)?.toLowerCase();return t===`png`?`image/png`:t===`jpg`||t===`jpeg`?`image/jpeg`:t===`webp`?`image/webp`:null}var W=class{sessions=new Map;listeners=new Set;uploads=new Map;get=e=>this.sessions.get(e)??$e;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));set(e,t){this.sessions.set(e,t);for(let e of this.listeners)e()}patch(e,t,n){this.set(e,this.get(e).map(e=>e.id===t?{...e,...n}:e))}add(e,t,n,r=!1){if(!e||!t.length)return;if(t.length+this.get(e).length>4)return T(r?`web.session-attachment-drafts.1`:`web.session-attachment-drafts.2`,{p0:4});if(Array.from(t).some(e=>r&&(!et(e)||!e.size)||e.size>ae))return T(r?`web.session-attachment-drafts.3`:`web.session-attachment-drafts.4`);let i=Array.from(t,e=>({id:N(),name:e.name.slice(0,200)||T(`web.SessionImages.8`),imageOnly:r,file:e,state:`uploading`}));this.set(e,[...this.get(e),...i]);for(let t of i)this.upload(e,t.id,n)}remove(e,t){this.uploads.get(t)?.abort(),this.uploads.delete(t),this.set(e,this.get(e).filter(e=>e.id!==t))}async upload(e,t,n){let r=this.get(e).find(e=>e.id===t);if(!r?.file||this.uploads.has(t))return;let a=new AbortController;this.uploads.set(t,a),this.patch(e,t,{state:`uploading`,error:``});try{let o=r.file,s=`web/local-agent-sessions/${e}/attachments/${t}`,c;if(o.size>5242880){for(let c=r.uploaded??0;c<o.size;c+=De){let r=o.slice(c,c+De);await n(`${s}/parts/${c/De}?size=${o.size}`,l({ok:f()}),{method:`POST`,signal:a.signal,timeoutMs:i,body:r}),this.patch(e,t,{uploaded:c+r.size})}c=await n(`${s}/finish`,ne,{method:`POST`,signal:a.signal,timeoutMs:i,body:{name:r.name,size:o.size,imageOnly:r.imageOnly}})}else{let s=await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(String(n.result)),n.onerror=()=>t(Error(T(`web.session-attachment-drafts.5`))),n.onabort=()=>t(Error(T(`web.session-attachment-drafts.6`))),a.signal.addEventListener(`abort`,()=>n.abort(),{once:!0}),n.readAsDataURL(o)});if(a.signal.aborted)return;et(o)&&this.patch(e,t,{preview:s}),c=await n(`web/local-agent-sessions/${e}/${r.imageOnly?`images`:`attachments`}`,ne,{method:`POST`,signal:a.signal,timeoutMs:i,body:{id:t,name:r.name,data:s.split(`,`,2)[1]}})}a.signal.aborted||this.set(e,this.get(e).map(e=>e.id===t?{id:t,name:c.name,state:`ready`,attachment:c,imageOnly:e.imageOnly}:e))}catch(n){a.signal.aborted||this.patch(e,t,{state:`failed`,error:d(n),...n instanceof v&&n.code===`ATTACHMENT_INCOMPLETE`?{uploaded:0}:{}})}finally{this.uploads.get(t)===a&&this.uploads.delete(t)}}},tt=(e,t,n,r=!1)=>x(`/api/v1/projects/${encodeURIComponent(e)}/local-agent/sessions/${encodeURIComponent(t)}/${r?`attachments`:`images`}/${encodeURIComponent(n)}`);function nt({images:e,remove:t,retry:n,disabled:r=!1}){y();let[i,a]=(0,z.useState)(),[o,s]=(0,z.useState)([]),c=e.find(e=>e.id===i),l=e.filter(e=>!e.file&&!o.includes(e.id)),u=l.findIndex(e=>e.id===i);return e.length?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`session-images`,children:e.map(e=>(0,B.jsxs)(`div`,{className:`session-image${e.file?` session-file`:``}`,children:[e.file?(0,B.jsxs)(`button`,{type:`button`,className:`session-file-name`,title:e.name,"aria-label":T(`web.SessionImages.1`,{p0:e.name}),disabled:!e.url||e.state===`uploading`||e.state===`failed`,onClick:()=>a(e.id),children:[(0,B.jsx)(O,{name:`attachment`,size:`small`}),(0,B.jsx)(`span`,{children:e.name})]}):o.includes(e.id)?(0,B.jsxs)(`button`,{type:`button`,className:`session-image-preview session-image-unavailable`,title:T(`web.SessionImages.2`),onClick:()=>s(t=>t.filter(t=>t!==e.id)),children:[(0,B.jsx)(O,{name:`refresh`,size:`small`}),(0,B.jsx)(`span`,{children:e.name}),(0,B.jsx)(`small`,{children:T(`web.SessionImages.3`)})]}):(0,B.jsx)(`button`,{type:`button`,className:`session-image-preview`,"aria-label":T(`web.SessionImages.4`,{p0:e.name}),title:e.name,disabled:!e.url,onClick:()=>a(e.id),children:e.url?(0,B.jsx)(`img`,{src:e.url,alt:e.name,loading:`lazy`,onError:()=>s(t=>[...t,e.id])}):(0,B.jsx)(O,{name:`image`})}),e.state===`uploading`&&(0,B.jsx)(`span`,{className:`session-image-status`,role:`status`,"aria-label":T(`web.SessionImages.5`,{p0:e.name}),children:(0,B.jsx)(O,{name:`loading`,size:`small`})}),e.state===`failed`&&(0,B.jsx)(`button`,{type:`button`,className:`session-image-status`,"aria-label":T(`web.SessionImages.6`,{p0:e.name}),title:e.error,disabled:r,onClick:()=>n?.(e.id),children:(0,B.jsx)(O,{name:`refresh`,size:`small`})}),t&&(0,B.jsx)(`button`,{type:`button`,className:`session-image-remove`,"aria-label":T(`web.SessionImages.7`,{p0:e.file?T(`web.SessionImages.8`):T(`web.labels.66`),p1:e.name}),disabled:r,onClick:()=>t(e.id),children:(0,B.jsx)(O,{name:`close`,size:`small`})}),e.state===`failed`&&(0,B.jsx)(`small`,{className:`session-image-error`,children:e.error})]},e.id))}),c&&(0,B.jsx)(Qe,{file:c,onClose:()=>a(void 0),gallery:u>=0&&l.length>1?{index:u,count:l.length,move:e=>a(l[(u+e+l.length)%l.length]?.id)}:void 0},c.id)]}):null}function G({images:e,url:t}){return y(),(0,B.jsx)(nt,{images:e.map(e=>({...e,file:e.mimeType===`application/octet-stream`,url:t(e.id)}))})}function rt(e,t,n){let r=a(),i=h(t,`computer-attachment-uploads`),o=(0,z.useMemo)(()=>{let e=r?.get(i)??new W;return r?.set(i,e),e},[r,i]),s=(0,z.useSyncExternalStore)(o.subscribe,()=>o.get(e)),c=m(),l=(0,z.useRef)(null),u=(0,z.useRef)(null);(0,z.useEffect)(()=>c(``),[e,t]);let d=s.flatMap(e=>e.attachment?[e.attachment]:[]),f=s.some(e=>e.state===`uploading`),p=n=>tt(t,e,n,!0),g=(t,r=!1)=>c(o.add(e,t,n,r)??``);return{files:d,busy:f,count:s.length,failed:s.some(e=>e.state===`failed`),add:g,clear:()=>{for(let t of d)o.remove(e,t.id)},picker:(e,t)=>(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`input`,{ref:u,type:`file`,className:`session-image-file`,multiple:!0,"aria-label":T(`web.SessionImages.9`),disabled:e,onChange:e=>{e.target.files&&g(e.target.files),e.target.value=``}}),t&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`input`,{ref:l,type:`file`,className:`session-image-file`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,"aria-label":T(`web.SessionImages.10`),disabled:e,onChange:e=>{e.target.files&&g(e.target.files,!0),e.target.value=``}}),(0,B.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":T(`web.SessionImages.11`),title:T(`web.SessionImages.12`),disabled:e,onClick:()=>l.current?.click(),children:(0,B.jsx)(O,{name:`image`,size:`small`})})]}),(0,B.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":T(`web.SessionImages.8`),title:T(`web.SessionImages.13`),disabled:e,onClick:()=>u.current?.click(),children:(0,B.jsx)(O,{name:`attachment`,size:`small`})})]}),preview:t=>(0,B.jsx)(nt,{images:s.map(e=>({id:e.id,name:e.name,mimeType:e.attachment?.mimeType??e.file?.type,url:e.attachment?p(e.id):e.preview??``,size:e.attachment?.size??e.file?.size??0,file:e.attachment?e.attachment.mimeType===`application/octet-stream`:!!e.file&&(e.file.size>5242880||!et(e.file)),state:e.state,...e.error?{error:e.error}:{}})),disabled:t,remove:t=>{o.remove(e,t),n(`web/local-agent-sessions/${e}/attachments/${t}`,ee(),{method:`DELETE`}).catch(()=>{})},retry:t=>void o.upload(e,t,n)})}}var it={offered:{get label(){return T(`web.Computers.7`)},icon:`clock`},received:{get label(){return T(`web.Computers.7`)},icon:`clock`},queued:{get label(){return T(`web.QueuedMessage.1`)},icon:`clock`},dispatching:{get label(){return T(`web.QueuedMessage.2`)},icon:`loading`,spinning:!0},running:{get label(){return T(`web.QueuedMessage.3`)},icon:`loading`,spinning:!0},cancelled:{get label(){return T(`web.QueuedMessage.4`)},icon:`close`},interrupted:{get label(){return T(`web.QueuedMessage.5`)},icon:`stop`},failed:{get label(){return T(`web.QueuedMessage.6`)},icon:`warning`},human_routed:{get label(){return T(`web.Computers.9`)},icon:`warning`},uncertain:{get label(){return T(`web.Computers.5`)},icon:`warning`}};function at({state:e,error:t}){y();let n=it[e];if(!n)return null;let r=t?T(`common.withDetail`,{label:n.label,detail:t}):n.label;return(0,B.jsx)(`span`,{className:`execution-status${n.spinning?` is-spinning`:``}`,role:`img`,"aria-label":r,title:r,children:(0,B.jsx)(O,{name:n.icon,size:`small`})})}function ot({message:e}){return y(),!e.queue||e.queue.state===`running`?null:(0,B.jsx)(at,{state:e.queue.state,error:e.queue.error})}function st(e,t,n,r){let[i,a]=(0,z.useState)(),[o,s]=(0,z.useState)(),c=(0,z.useRef)(null);(0,z.useEffect)(()=>{if(!t)return;let i=new AbortController,{signal:o}=i,u=`web/local-agent-sessions/${encodeURIComponent(t)}`,p=new URLSearchParams(location.search).get(`question`),m=new URLSearchParams(location.search).get(`message`),h,g,_=-1,y=``,b=0,S=0,C=(e,n)=>{if(o.aborted||n<_)return;_=n;let r=JSON.stringify(e);r!==y&&(y=r,s({session:t,value:e}))},w=!1,T=!1,E=Promise.resolve(),D=(e=``)=>{o.aborted||a({session:t,...h?{data:h}:{},error:e,loadingOlder:w})},O=e=>n(u+(Object.keys(e).length?`?`+new URLSearchParams(e):``),me,{signal:o}),k=e=>(E=E.then(async()=>{if(!o.aborted)try{await e()}catch(e){e instanceof v&&[401,403,404].includes(e.status)&&(h=void 0,s(void 0)),T=!0,D(d(e))}}),E),A=e=>k(async()=>{if(e!==void 0&&h&&h.cursor>=e&&!T)return;let t=g,n=await O(t===void 0?!h&&p?{question:p}:!h&&m&&/^[1-9]\d*$/.test(m)?{message:m}:{}:{from:String(t)});o.aborted||(h&&!r(!1)&&j(!1),g!==t&&g!==void 0&&n.olderBefore!==null&&n.olderBefore>g&&(n=await O({from:String(g)})),!h&&(p||m)&&(g=n.olderBefore??1),h=n,n.attention&&C(n.attention,n.cursor),T=!1,D())});function j(e){e&&!w?g=void 0:h&&g===void 0&&(g=h.olderBefore??1)}function M(){h?.olderBefore&&!w&&(j(!1),w=!0,D(),k(async()=>{try{if(!h?.olderBefore)return;let e=await O({before:String(h.olderBefore)}),t=e.olderBefore??1,n=e.cursor===h.cursor?{...h,messages:[...e.messages,...h.messages],olderBefore:e.olderBefore}:await O({from:String(t)});if(o.aborted)return;r(!0),g=t,h=n,T=!1}finally{w=!1,D()}}))}c.current={reload:()=>A(),markRead:e=>(S=Math.max(S,e),k(async()=>{let e=S;e<=b||(await n(u+`/read`,l({ok:f()}),{method:`POST`,body:{through:e},signal:o}),b=e,window.dispatchEvent(new Event(`teammy:outbox`)))})),older:M,follow:j,reveal:e=>k(async()=>{if(h?.messages.some(t=>t.seq===e))return;let t=Math.min(e,h?.messages[0]?.seq??e),n=await O({from:String(t)});g=t,h=n,T=!1,D()})},A();let N=new EventSource(x(`/api/v1/projects/${encodeURIComponent(e)}/${u}/events?updates=1&attention=1`)),ee=e=>{document.hidden||A(Number(e.lastEventId))};N.addEventListener(`change`,ee),N.addEventListener(`snapshot`,ee),N.addEventListener(`attention`,e=>{C(R.parse(JSON.parse(e.data)),Number(e.lastEventId))});let P=setInterval(()=>{!document.hidden&&(T||N.readyState!==EventSource.OPEN)&&A()},15e3),F=()=>{document.hidden||A()};return document.addEventListener(`visibilitychange`,F),()=>{i.abort(),c.current=null,N.close(),clearInterval(P),document.removeEventListener(`visibilitychange`,F)}},[t,e,n,r]);let u=(0,z.useCallback)(()=>c.current?.reload()??Promise.resolve(),[]),p=(0,z.useCallback)(e=>c.current?.markRead(e)??Promise.resolve(),[]),m=(0,z.useCallback)(()=>c.current?.older(),[]),h=(0,z.useCallback)(e=>c.current?.follow(e),[]),g=(0,z.useCallback)(e=>c.current?.reveal(e)??Promise.resolve(),[]);return{...i?.session===t?i:void 0,attention:o?.session===t?o.value:void 0,reload:u,older:m,follow:h,reveal:g,markRead:p}}var ct={模式:`Mode`,工作模式:`Mode`,权限:`Permissions`,按需审批:`Ask as needed`,完全访问:`Full access`,默认审批:`Default permissions`,自动接受编辑:`Accept edits`,原生规则:`Native rules`,自动审批:`Auto-approve`,只读:`Read-only`,工作区写入:`Workspace write`,工作区:`Workspace`,"执行任务,工具操作遵循审批设置":`Carry out tasks with the configured approval policy`,"先探索并制定计划,确认后实施":`Explore and plan before implementing with confirmation`,"只读问答,不修改文件或执行命令":`Answer questions without editing files or running commands`,"遵循 Cursor 规则,需要授权时确认":`Follow Cursor rules and ask when permission is needed`,"自动批准工具请求,保留原生限制和问答确认":`Approve tool requests while preserving native restrictions and questions`,"遵循 Claude 的权限规则,按需确认":`Follow Claude permission rules and ask as needed`,"自动接受工作目录内的编辑,其他操作按需确认":`Accept workspace edits; ask as needed for other actions`,"先探索和制定计划,确认后开始实施":`Explore and plan before implementing with confirmation`,"跳过常规工具审批,保留原生限制及问答":`Skip routine tool approvals; preserve native restrictions and questions`,"遵循 OpenCode 和当前工作模式的权限规则":`Follow OpenCode and current mode permission rules`,"自动允许工具审批请求,保留原生禁止规则及问答确认":`Approve tool requests; preserve native deny rules and questions`,"读取文件,不修改代码":`Read files without modifying code`,"可修改工作区,额外权限按需审批":`Edit workspace files; ask for additional permissions as needed`,"允许全部访问,执行时无需审批":`Allow full access without asking for approval`};function K(e,t,n){if(e!==`en`)return n;let r=Oe(t);return n.map(e=>{let t=r.find(t=>t.key===e.key);if(!t)return e;let n=e=>e===void 0?void 0:ct[e]??e;return{...e,label:e.label===t.label?n(e.label):e.label,choices:e.choices.map(e=>{let r=t.choices.find(t=>t.value===e.value);return!r||r.label!==e.label?e:{...e,label:n(e.label),shortLabel:n(e.shortLabel),description:e.description===r.description?n(e.description):e.description}})}})}function lt(e,t){let n=(t,n)=>E(e,t,n);if(t.kind===`control`)return n(`session.control.${t.command}`);let{before:r,after:i,provider:a}=t,o=[],s=(e,t)=>o.push(n(`session.settings.${e}`,{value:t})),c=K(e,a,Oe(a)),l=(e,t)=>c.find(t=>t.key===e)?.choices.find(e=>e.value===t)?.label??t??n(`session.default`);if(r.model!==i.model&&s(`model`,i.model??n(`session.default`)),r.effort!==i.effort){let e=i.effort?a!==`opencode`&&[`minimal`,`low`,`medium`,`high`,`xhigh`,`max`,`ultra`,`none`].includes(i.effort)?n(`session.effort.${i.effort}`):i.effort:n(`session.default`);s(a===`opencode`?`variant`:`effort`,e)}return r.mode!==i.mode&&s(`mode`,l(`mode`,i.mode)),r.permission!==i.permission&&s(`permission`,l(`permission`,i.permission)),JSON.stringify(r.options??{})!==JSON.stringify(i.options??{})&&o.push(n(`session.settings.options`)),t.directory!==void 0&&s(`directory`,t.directory),o.join(` · `)}function q({message:e,images:t,status:r,rewind:i,onFile:a}){y();let o=i?.commands.find(t=>t.kind===`rewind`&&[`queued`,`running`,`uncertain`].includes(t.state)&&JSON.parse(t.argument).messageId===e.id),[s,c]=(0,z.useState)(!!o),[l,u]=(0,z.useState)(o?JSON.parse(o.argument).body:e.body),[d,f]=(0,z.useState)(!1),p=m(),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)(),b=(0,z.useRef)(void 0),x=Fe(l);(0,z.useLayoutEffect)(()=>{s&&x.current&&(x.current.style.height=`0px`,x.current.style.height=`${x.current.scrollHeight}px`)},[s]);let S=i?.commands.find(e=>e.id===_?.id)??_??o,C=h||S&&[`queued`,`running`].includes(S.state),w=i?.available&&e.source===`web_session`&&e.id.startsWith(`input:`)&&(!e.queue||[`handled`,`interrupted`].includes(e.queue.state));async function E(){if(!i||C||!l.trim())return;let t=JSON.stringify({messageId:e.id,body:l.trim(),expectedLastMessage:i.expectedLastMessage});(S&&[`failed`,`uncertain`].includes(S.state)||b.current?.argument!==t)&&(b.current={id:N(),argument:t}),g(!0),p(``);try{let e=await i.request(`web/local-agent-sessions/${i.session}/commands`,ke,{method:`POST`,body:{id:b.current.id,kind:`rewind`,argument:b.current.argument}});v(e),i.refresh()}catch(e){p(e)}finally{g(!1)}}return(0,B.jsxs)(`div`,{className:`computer-user-entry${s?` editing`:``}`,children:[(0,B.jsxs)(Pe,{mine:!0,author:e.source===`human_message`?T(`session.forwardedByTim`):T(`web.ComputerUserMessage.1`),time:e.createdAt,children:[t,s?(0,B.jsxs)(`form`,{className:`computer-message-edit`,onSubmit:e=>{e.preventDefault(),E()},children:[(0,B.jsx)(`textarea`,{ref:x,"aria-label":T(`web.ComputerUserMessage.2`),value:l,onChange:e=>u(e.target.value),disabled:!!C,autoFocus:!0,rows:1}),(0,B.jsxs)(`div`,{className:`computer-message-edit-footer`,children:[(0,B.jsx)(`small`,{children:T(`web.ComputerUserMessage.3`)}),(0,B.jsx)(M,{icon:`close`,label:T(`web.ComputerUserMessage.4`),disabled:!!C,onClick:()=>{c(!1),p(``),u(e.body)}}),(0,B.jsx)(`button`,{type:`submit`,className:`message-send primary`,"aria-label":T(C?`web.ComputerUserMessage.5`:`web.ComputerUserMessage.6`),title:T(C?`web.ComputerUserMessage.5`:`web.ComputerUserMessage.6`),disabled:!!C||!l.trim(),children:(0,B.jsx)(O,{name:C?`loading`:`send`,size:`small`})})]}),(0,B.jsx)(n,{children:S&&[`failed`,`uncertain`].includes(S.state)&&S.error})]}):(0,B.jsx)(`div`,{className:`markdown`,children:(0,B.jsx)(Ae,{onFile:a,children:e.body})}),!s&&r]}),!s&&(0,B.jsxs)(`div`,{className:`computer-message-actions`,children:[(0,B.jsx)(M,{icon:d?`check`:`copy`,label:T(d?`web.labels.100`:`web.ComputerUserMessage.7`),onClick:()=>{p(``),j(e.body).then(()=>f(!0)).catch(e=>p(e))}}),w&&(0,B.jsx)(M,{icon:`edit`,label:T(`web.ComputerUserMessage.8`),onClick:()=>{u(e.body),c(!0)}})]})]})}function J({label:e,meta:t,children:n,className:r=``,onToggle:i}){return y(),(0,B.jsxs)(`details`,{className:`tool-details ${r}`,onToggle:i,children:[(0,B.jsxs)(`summary`,{className:`tool-summary`,title:e,children:[(0,B.jsx)(O,{name:`chevron`,size:`small`}),(0,B.jsx)(`span`,{className:`tool-details-label`,children:e}),t&&(0,B.jsx)(`span`,{className:`tool-details-status`,children:t})]}),n]})}function Y(e){if(e<1e3)return T(`web.ComputerMessages.1`);let t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return[r?T(`web.TaskBoard.30`,{p0:r}):``,n%60?T(`web.ComputerMessages.2`,{p0:n%60}):``,t%60?T(`web.ComputerMessages.3`,{p0:t%60}):``].filter(Boolean).join(` `)}function X({children:e,readSeq:t}){return y(),(0,B.jsx)(`div`,{className:`computer-divider`,"data-completion-seq":t,children:(0,B.jsx)(`span`,{children:e})})}function Z({message:e,readable:t=!1}){y();let n=e.state===`succeeded`?T(`web.ComputerMessages.4`):e.state===`interrupted`?T(`web.QueuedMessage.5`):e.state===`failed`?T(`web.ComputerMessages.5`):T(`web.Computers.5`);return(0,B.jsxs)(X,{readSeq:t?e.seq:void 0,children:[n,e.activity?.durationMs===void 0?``:` · ${Y(e.activity.durationMs)}`]})}var ut={get offered(){return T(`web.Computers.7`)},get pending(){return T(`web.Computers.10`)},get human_routed(){return T(`web.Computers.9`)},get failed(){return T(`web.Computers.14`)},get uncertain(){return T(`web.Computers.5`)}};function Q(e){let t=[];for(let n of e)if(n.role===`assistant`&&n.activity?.kind===`tool`&&!n.question){let e=t.at(-1);Array.isArray(e)&&e[0].activity?.turnId===n.activity.turnId?e.push(n):t.push([n])}else t.push(n);return t}function $({text:e,onFile:t}){y();let n=[],r=0;if(t)for(let{start:i,end:a,link:o}of oe(e))n.push(e.slice(r,i),(0,B.jsx)(`button`,{type:`button`,className:`computer-file-link`,onClick:()=>t(o),children:e.slice(i,a)},i)),r=a;return(0,B.jsxs)(`pre`,{children:[n,e.slice(r)]})}function dt({call:e,onFile:t,visible:n,onOpen:r}){y();let[i,a]=(0,z.useState)(!1);return(0,B.jsx)(J,{className:`computer-tool`,onToggle:e=>{let t=e.currentTarget.open;a(t),r?.(t)},label:e.activity?.labelMessage?P(A(),e.activity.labelMessage):e.activity?.label??T(`web.ComputerMessages.6`),meta:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(at,{state:e.state}),e.activity?.durationMs!==void 0&&(0,B.jsx)(`span`,{children:Y(e.activity.durationMs)})]}),children:i&&n&&(0,B.jsx)($,{text:e.body,onFile:t})})}function ft({calls:e,onFile:t}){y();let n=(0,z.useId)(),[r,i]=(0,z.useState)(!1),a=e.length>1,o=[`failed`,`uncertain`,`interrupted`].find(t=>e.some(e=>e.state===t));return(0,B.jsxs)(`div`,{className:a?`tool-details computer-tool-group`:void 0,children:[a&&(0,B.jsxs)(`button`,{type:`button`,className:`tool-summary`,"aria-expanded":r,"aria-controls":n,onClick:()=>i(!r),children:[(0,B.jsx)(O,{name:`chevron`,size:`small`}),T(`tools.calls`,{count:e.length}),o&&(0,B.jsx)(at,{state:o}),e.some(e=>e.state===`running`)&&(0,B.jsx)(at,{state:`running`})]}),(0,B.jsx)(`div`,{id:n,className:a?`computer-tool-list`:void 0,hidden:a&&!r,children:e.map(e=>(0,B.jsx)(dt,{call:e,onFile:t,visible:!a||r,onOpen:a?void 0:i},e.id))})]})}function pt({messages:e,renderQuestion:t,imageUrl:n,renderQueue:r,rewind:i,onFile:a}){y();let o=new Map(e.filter(e=>e.activity?.kind===`turn`).map(e=>[e.activity.turnId,e])),s=new Map,c=new Set(e.flatMap(e=>{let t=e.question?.planSource;return t?[JSON.stringify([t.turnId,t.itemId])]:[]})),l=new Set(e.flatMap(e=>{let t=e.activity;return t?.kind===`commentary`&&c.has(JSON.stringify([t.turnId,t.itemId]))?[JSON.stringify([t.turnId,e.body])]:[]}));for(let t of e)t.activity?.kind===`answer`&&s.set(t.activity.turnId,t.id);let u=e.filter(({activity:e,body:t})=>e?.kind!==`commentary`||!c.has(JSON.stringify([e.turnId,e.itemId]))&&!l.has(JSON.stringify([e.turnId,t]))),d=(0,z.useRef)({keys:new Map,next:0}),f=new Map,p=new Set,m=d.current.next,h=Q(u);for(let e of h){if(!Array.isArray(e))continue;let t;for(let n of e){if(t=d.current.keys.get(n.id),t!==void 0&&!p.has(t))break;t=void 0}t??=m++,p.add(t);for(let n of e)f.set(n.id,t)}return(0,z.useLayoutEffect)(()=>{d.current={keys:f,next:m}}),(0,B.jsx)(`div`,{className:`computer-messages`,children:h.map(e=>{if(Array.isArray(e))return(0,B.jsx)(ft,{calls:e,onFile:a},`tools:${f.get(e[0].id)}`);let c=e.activity;if(e.role===`system`)return(0,B.jsx)(X,{children:e.presentation?lt(A(),e.presentation):e.body},e.id);if(c?.kind===`turn`)return s.has(c.turnId)?null:(0,B.jsx)(Z,{message:e,readable:!0},e.id);if(e.role===`user`)return(0,B.jsx)(q,{message:e,rewind:i,onFile:a,images:n&&(e.attachments??e.images)?.length?(0,B.jsx)(G,{images:e.attachments??e.images,url:t=>n(t,!!e.attachments)}):null,status:e.queue&&r?r(e):ut[e.state]&&(0,B.jsx)(je,{label:ut[e.state],state:e.state})},e.id);let l=c?.kind===`answer`&&s.get(c.turnId)===e.id?o.get(c.turnId):void 0;return(0,B.jsxs)(z.Fragment,{children:[l&&(0,B.jsx)(Z,{message:l}),(0,B.jsx)(`article`,{"data-message-seq":e.seq,"data-completion-seq":l?.seq??(e.source===`agent-final`&&[`sent`,`succeeded`,`failed`,`interrupted`,`uncertain`].includes(e.state)?e.seq:void 0),id:e.question?`computer-question-${e.question.id}`:void 0,tabIndex:e.question?-1:void 0,className:`computer-agent-message ${c?.kind===`commentary`?`computer-commentary`:``} ${e.question?`question-bubble`:``}`,children:e.question?t(e.question):(0,B.jsx)(`div`,{className:`markdown`,children:(0,B.jsx)(Ae,{onFile:a,children:e.body})})})]},e.id)})})}function mt({disabled:e,onSend:t,initialValue:n=``,placeholder:r}){y();let[i,a]=(0,z.useState)(n),[o,s]=(0,z.useState)(!!n),c=T(`web.InlineReply.1`),l=(0,z.useRef)(null),u=(0,z.useCallback)(e=>{if(!l.current)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.font=getComputedStyle(e).font;let n=Math.max(...(i||`${c}…`).split(`
|
|
7
|
+
`):``]}):a.text}),a.truncated&&(0,B.jsx)(`small`,{children:T(`web.FilePreview.11`)})]}):(0,B.jsx)(`p`,{className:`file-preview-empty`,children:T(`web.FilePreview.9`)}):(0,B.jsx)(`p`,{role:`status`,children:T(`web.FilePreview.8`)})})})}var $e=[];function et(e){if(`image/png,image/jpeg,image/webp`.split(`,`).includes(e.type))return e.type;if(e.type&&e.type!==`application/octet-stream`)return null;let t=e.name.split(`.`).at(-1)?.toLowerCase();return t===`png`?`image/png`:t===`jpg`||t===`jpeg`?`image/jpeg`:t===`webp`?`image/webp`:null}var W=class{sessions=new Map;listeners=new Set;uploads=new Map;get=e=>this.sessions.get(e)??$e;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));set(e,t){this.sessions.set(e,t);for(let e of this.listeners)e()}patch(e,t,n){this.set(e,this.get(e).map(e=>e.id===t?{...e,...n}:e))}add(e,t,n,r=!1){if(!e||!t.length)return;if(t.length+this.get(e).length>4)return T(r?`web.session-attachment-drafts.1`:`web.session-attachment-drafts.2`,{p0:4});if(Array.from(t).some(e=>r&&(!et(e)||!e.size)||e.size>ae))return T(r?`web.session-attachment-drafts.3`:`web.session-attachment-drafts.4`);let i=Array.from(t,e=>({id:N(),name:e.name.slice(0,200)||T(`web.SessionImages.8`),imageOnly:r,file:e,state:`uploading`}));this.set(e,[...this.get(e),...i]);for(let t of i)this.upload(e,t.id,n)}remove(e,t){this.uploads.get(t)?.abort(),this.uploads.delete(t),this.set(e,this.get(e).filter(e=>e.id!==t))}async upload(e,t,n){let r=this.get(e).find(e=>e.id===t);if(!r?.file||this.uploads.has(t))return;let a=new AbortController;this.uploads.set(t,a),this.patch(e,t,{state:`uploading`,error:``});try{let o=r.file,s=`web/local-agent-sessions/${e}/attachments/${t}`,c;if(o.size>5242880){for(let c=r.uploaded??0;c<o.size;c+=De){let r=o.slice(c,c+De);await n(`${s}/parts/${c/De}?size=${o.size}`,l({ok:f()}),{method:`POST`,signal:a.signal,timeoutMs:i,body:r}),this.patch(e,t,{uploaded:c+r.size})}c=await n(`${s}/finish`,ne,{method:`POST`,signal:a.signal,timeoutMs:i,body:{name:r.name,size:o.size,imageOnly:r.imageOnly}})}else{let s=await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(String(n.result)),n.onerror=()=>t(Error(T(`web.session-attachment-drafts.5`))),n.onabort=()=>t(Error(T(`web.session-attachment-drafts.6`))),a.signal.addEventListener(`abort`,()=>n.abort(),{once:!0}),n.readAsDataURL(o)});if(a.signal.aborted)return;et(o)&&this.patch(e,t,{preview:s}),c=await n(`web/local-agent-sessions/${e}/${r.imageOnly?`images`:`attachments`}`,ne,{method:`POST`,signal:a.signal,timeoutMs:i,body:{id:t,name:r.name,data:s.split(`,`,2)[1]}})}a.signal.aborted||this.set(e,this.get(e).map(e=>e.id===t?{id:t,name:c.name,state:`ready`,attachment:c,imageOnly:e.imageOnly}:e))}catch(n){a.signal.aborted||this.patch(e,t,{state:`failed`,error:d(n),...n instanceof v&&n.code===`ATTACHMENT_INCOMPLETE`?{uploaded:0}:{}})}finally{this.uploads.get(t)===a&&this.uploads.delete(t)}}},tt=(e,t,n,r=!1)=>x(`/api/v1/projects/${encodeURIComponent(e)}/local-agent/sessions/${encodeURIComponent(t)}/${r?`attachments`:`images`}/${encodeURIComponent(n)}`);function nt({images:e,remove:t,retry:n,disabled:r=!1}){y();let[i,a]=(0,z.useState)(),[o,s]=(0,z.useState)([]),c=e.find(e=>e.id===i),l=e.filter(e=>!e.file&&!o.includes(e.id)),u=l.findIndex(e=>e.id===i);return e.length?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`session-images`,children:e.map(e=>(0,B.jsxs)(`div`,{className:`session-image${e.file?` session-file`:``}`,children:[e.file?(0,B.jsxs)(`button`,{type:`button`,className:`session-file-name`,title:e.name,"aria-label":T(`web.SessionImages.1`,{p0:e.name}),disabled:!e.url||e.state===`uploading`||e.state===`failed`,onClick:()=>a(e.id),children:[(0,B.jsx)(O,{name:`attachment`,size:`small`}),(0,B.jsx)(`span`,{children:e.name})]}):o.includes(e.id)?(0,B.jsxs)(`button`,{type:`button`,className:`session-image-preview session-image-unavailable`,title:T(`web.SessionImages.2`),onClick:()=>s(t=>t.filter(t=>t!==e.id)),children:[(0,B.jsx)(O,{name:`refresh`,size:`small`}),(0,B.jsx)(`span`,{children:e.name}),(0,B.jsx)(`small`,{children:T(`web.SessionImages.3`)})]}):(0,B.jsx)(`button`,{type:`button`,className:`session-image-preview`,"aria-label":T(`web.SessionImages.4`,{p0:e.name}),title:e.name,disabled:!e.url,onClick:()=>a(e.id),children:e.url?(0,B.jsx)(`img`,{src:e.url,alt:e.name,loading:`lazy`,onError:()=>s(t=>[...t,e.id])}):(0,B.jsx)(O,{name:`image`})}),e.state===`uploading`&&(0,B.jsx)(`span`,{className:`session-image-status`,role:`status`,"aria-label":T(`web.SessionImages.5`,{p0:e.name}),children:(0,B.jsx)(O,{name:`loading`,size:`small`})}),e.state===`failed`&&(0,B.jsx)(`button`,{type:`button`,className:`session-image-status`,"aria-label":T(`web.SessionImages.6`,{p0:e.name}),title:e.error,disabled:r,onClick:()=>n?.(e.id),children:(0,B.jsx)(O,{name:`refresh`,size:`small`})}),t&&(0,B.jsx)(`button`,{type:`button`,className:`session-image-remove`,"aria-label":T(`web.SessionImages.7`,{p0:e.file?T(`web.SessionImages.8`):T(`web.labels.66`),p1:e.name}),disabled:r,onClick:()=>t(e.id),children:(0,B.jsx)(O,{name:`close`,size:`small`})}),e.state===`failed`&&(0,B.jsx)(`small`,{className:`session-image-error`,children:e.error})]},e.id))}),c&&(0,B.jsx)(Qe,{file:c,onClose:()=>a(void 0),gallery:u>=0&&l.length>1?{index:u,count:l.length,move:e=>a(l[(u+e+l.length)%l.length]?.id)}:void 0},c.id)]}):null}function G({images:e,url:t}){return y(),(0,B.jsx)(nt,{images:e.map(e=>({...e,file:e.mimeType===`application/octet-stream`,url:t(e.id)}))})}function rt(e,t,n){let r=a(),i=h(t,`computer-attachment-uploads`),o=(0,z.useMemo)(()=>{let e=r?.get(i)??new W;return r?.set(i,e),e},[r,i]),s=(0,z.useSyncExternalStore)(o.subscribe,()=>o.get(e)),c=m(),l=(0,z.useRef)(null),u=(0,z.useRef)(null);(0,z.useEffect)(()=>c(``),[e,t]);let d=s.flatMap(e=>e.attachment?[e.attachment]:[]),f=s.some(e=>e.state===`uploading`),p=n=>tt(t,e,n,!0),g=(t,r=!1)=>c(o.add(e,t,n,r)??``);return{files:d,busy:f,count:s.length,failed:s.some(e=>e.state===`failed`),add:g,clear:()=>{for(let t of d)o.remove(e,t.id)},picker:(e,t)=>(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`input`,{ref:u,type:`file`,className:`session-image-file`,multiple:!0,"aria-label":T(`web.SessionImages.9`),disabled:e,onChange:e=>{e.target.files&&g(e.target.files),e.target.value=``}}),t&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`input`,{ref:l,type:`file`,className:`session-image-file`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,"aria-label":T(`web.SessionImages.10`),disabled:e,onChange:e=>{e.target.files&&g(e.target.files,!0),e.target.value=``}}),(0,B.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":T(`web.SessionImages.11`),title:T(`web.SessionImages.12`),disabled:e,onClick:()=>l.current?.click(),children:(0,B.jsx)(O,{name:`image`,size:`small`})})]}),(0,B.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":T(`web.SessionImages.8`),title:T(`web.SessionImages.13`),disabled:e,onClick:()=>u.current?.click(),children:(0,B.jsx)(O,{name:`attachment`,size:`small`})})]}),preview:t=>(0,B.jsx)(nt,{images:s.map(e=>({id:e.id,name:e.name,mimeType:e.attachment?.mimeType??e.file?.type,url:e.attachment?p(e.id):e.preview??``,size:e.attachment?.size??e.file?.size??0,file:e.attachment?e.attachment.mimeType===`application/octet-stream`:!!e.file&&(e.file.size>5242880||!et(e.file)),state:e.state,...e.error?{error:e.error}:{}})),disabled:t,remove:t=>{o.remove(e,t),n(`web/local-agent-sessions/${e}/attachments/${t}`,ee(),{method:`DELETE`}).catch(()=>{})},retry:t=>void o.upload(e,t,n)})}}var it={offered:{get label(){return T(`web.Computers.7`)},icon:`clock`},received:{get label(){return T(`web.Computers.7`)},icon:`clock`},queued:{get label(){return T(`web.QueuedMessage.1`)},icon:`clock`},dispatching:{get label(){return T(`web.QueuedMessage.2`)},icon:`loading`,spinning:!0},running:{get label(){return T(`web.QueuedMessage.3`)},icon:`loading`,spinning:!0},cancelled:{get label(){return T(`web.QueuedMessage.4`)},icon:`close`},interrupted:{get label(){return T(`web.QueuedMessage.5`)},icon:`stop`},failed:{get label(){return T(`web.QueuedMessage.6`)},icon:`warning`},human_routed:{get label(){return T(`web.Computers.9`)},icon:`warning`},uncertain:{get label(){return T(`web.Computers.5`)},icon:`warning`}};function at({state:e,error:t}){y();let n=it[e];if(!n)return null;let r=t?T(`common.withDetail`,{label:n.label,detail:t}):n.label;return(0,B.jsx)(`span`,{className:`execution-status${n.spinning?` is-spinning`:``}`,role:`img`,"aria-label":r,title:r,children:(0,B.jsx)(O,{name:n.icon,size:`small`})})}function ot({message:e}){return y(),!e.queue||e.queue.state===`running`?null:(0,B.jsx)(at,{state:e.queue.state,error:e.queue.error})}function st(e,t,n,r){let[i,a]=(0,z.useState)(),[o,s]=(0,z.useState)(),c=(0,z.useRef)(null);(0,z.useEffect)(()=>{if(!t)return;let i=new AbortController,{signal:o}=i,u=`web/local-agent-sessions/${encodeURIComponent(t)}`,p=new URLSearchParams(location.search).get(`question`),m=new URLSearchParams(location.search).get(`message`),h,g,_=-1,y=``,b=0,S=0,C=(e,n)=>{if(o.aborted||n<_)return;_=n;let r=JSON.stringify(e);r!==y&&(y=r,s({session:t,value:e}))},w=!1,T=!1,E=Promise.resolve(),D=(e=``)=>{o.aborted||a({session:t,...h?{data:h}:{},error:e,loadingOlder:w})},O=e=>n(u+(Object.keys(e).length?`?`+new URLSearchParams(e):``),me,{signal:o}),k=e=>(E=E.then(async()=>{if(!o.aborted)try{await e()}catch(e){e instanceof v&&[401,403,404].includes(e.status)&&(h=void 0,s(void 0)),T=!0,D(d(e))}}),E),A=e=>k(async()=>{if(e!==void 0&&h&&h.cursor>=e&&!T)return;let t=g,n=await O(t===void 0?!h&&p?{question:p}:!h&&m&&/^[1-9]\d*$/.test(m)?{message:m}:{}:{from:String(t)});o.aborted||(h&&!r(!1)&&j(!1),g!==t&&g!==void 0&&n.olderBefore!==null&&n.olderBefore>g&&(n=await O({from:String(g)})),!h&&(p||m)&&(g=n.olderBefore??1),h=n,n.attention&&C(n.attention,n.cursor),T=!1,D())});function j(e){e&&!w?g=void 0:h&&g===void 0&&(g=h.olderBefore??1)}function M(){h?.olderBefore&&!w&&(j(!1),w=!0,D(),k(async()=>{try{if(!h?.olderBefore)return;let e=await O({before:String(h.olderBefore)}),t=e.olderBefore??1,n=e.cursor===h.cursor?{...h,messages:[...e.messages,...h.messages],olderBefore:e.olderBefore}:await O({from:String(t)});if(o.aborted)return;r(!0),g=t,h=n,T=!1}finally{w=!1,D()}}))}c.current={reload:()=>A(),markRead:e=>(S=Math.max(S,e),k(async()=>{let e=S;e<=b||(await n(u+`/read`,l({ok:f()}),{method:`POST`,body:{through:e},signal:o}),b=e,window.dispatchEvent(new Event(`teammy:outbox`)))})),older:M,follow:j,reveal:e=>k(async()=>{if(h?.messages.some(t=>t.seq===e))return;let t=Math.min(e,h?.messages[0]?.seq??e),n=await O({from:String(t)});g=t,h=n,T=!1,D()})},A();let N=new EventSource(x(`/api/v1/projects/${encodeURIComponent(e)}/${u}/events?updates=1&attention=1`)),ee=e=>{document.hidden||A(Number(e.lastEventId))};N.addEventListener(`change`,ee),N.addEventListener(`snapshot`,ee),N.addEventListener(`attention`,e=>{C(R.parse(JSON.parse(e.data)),Number(e.lastEventId))});let P=setInterval(()=>{!document.hidden&&(T||N.readyState!==EventSource.OPEN)&&A()},15e3),F=()=>{document.hidden||A()};return document.addEventListener(`visibilitychange`,F),()=>{i.abort(),c.current=null,N.close(),clearInterval(P),document.removeEventListener(`visibilitychange`,F)}},[t,e,n,r]);let u=(0,z.useCallback)(()=>c.current?.reload()??Promise.resolve(),[]),p=(0,z.useCallback)(e=>c.current?.markRead(e)??Promise.resolve(),[]),m=(0,z.useCallback)(()=>c.current?.older(),[]),h=(0,z.useCallback)(e=>c.current?.follow(e),[]),g=(0,z.useCallback)(e=>c.current?.reveal(e)??Promise.resolve(),[]);return{...i?.session===t?i:void 0,attention:o?.session===t?o.value:void 0,reload:u,older:m,follow:h,reveal:g,markRead:p}}var ct={模式:`Mode`,工作模式:`Mode`,权限:`Permissions`,按需审批:`Ask as needed`,完全访问:`Full access`,默认审批:`Default permissions`,自动接受编辑:`Accept edits`,原生规则:`Native rules`,自动审批:`Auto-approve`,只读:`Read-only`,工作区写入:`Workspace write`,工作区:`Workspace`,"执行任务,工具操作遵循审批设置":`Carry out tasks with the configured approval policy`,"先探索并制定计划,确认后实施":`Explore and plan before implementing with confirmation`,"只读问答,不修改文件或执行命令":`Answer questions without editing files or running commands`,"遵循 Cursor 规则,需要授权时确认":`Follow Cursor rules and ask when permission is needed`,"自动批准工具请求,保留原生限制和问答确认":`Approve tool requests while preserving native restrictions and questions`,"遵循 Claude 的权限规则,按需确认":`Follow Claude permission rules and ask as needed`,"自动接受工作目录内的编辑,其他操作按需确认":`Accept workspace edits; ask as needed for other actions`,"先探索和制定计划,确认后开始实施":`Explore and plan before implementing with confirmation`,"跳过常规工具审批,保留原生限制及问答":`Skip routine tool approvals; preserve native restrictions and questions`,"遵循 OpenCode 和当前工作模式的权限规则":`Follow OpenCode and current mode permission rules`,"自动允许工具审批请求,保留原生禁止规则及问答确认":`Approve tool requests; preserve native deny rules and questions`,"读取文件,不修改代码":`Read files without modifying code`,"可修改工作区,额外权限按需审批":`Edit workspace files; ask for additional permissions as needed`,"允许全部访问,执行时无需审批":`Allow full access without asking for approval`};function K(e,t,n){if(e!==`en`)return n;let r=Oe(t);return n.map(e=>{let t=r.find(t=>t.key===e.key);if(!t)return e;let n=e=>e===void 0?void 0:ct[e]??e;return{...e,label:e.label===t.label?n(e.label):e.label,choices:e.choices.map(e=>{let r=t.choices.find(t=>t.value===e.value);return!r||r.label!==e.label?e:{...e,label:n(e.label),shortLabel:n(e.shortLabel),description:e.description===r.description?n(e.description):e.description}})}})}function lt(e,t){let n=(t,n)=>E(e,t,n);if(t.kind===`control`)return n(`session.control.${t.command}`);let{before:r,after:i,provider:a}=t,o=[],s=(e,t)=>o.push(n(`session.settings.${e}`,{value:t})),c=K(e,a,Oe(a)),l=(e,t)=>c.find(t=>t.key===e)?.choices.find(e=>e.value===t)?.label??t??n(`session.default`);if(r.model!==i.model&&s(`model`,i.model??n(`session.default`)),r.effort!==i.effort){let e=i.effort?a!==`opencode`&&[`minimal`,`low`,`medium`,`high`,`xhigh`,`max`,`ultra`,`none`].includes(i.effort)?n(`session.effort.${i.effort}`):i.effort:n(`session.default`);s(a===`opencode`?`variant`:`effort`,e)}return r.mode!==i.mode&&s(`mode`,l(`mode`,i.mode)),r.permission!==i.permission&&s(`permission`,l(`permission`,i.permission)),JSON.stringify(r.options??{})!==JSON.stringify(i.options??{})&&o.push(n(`session.settings.options`)),t.directory!==void 0&&s(`directory`,t.directory),o.join(` · `)}function q({message:e,images:t,status:r,rewind:i,onFile:a}){y();let o=i?.commands.find(t=>t.kind===`rewind`&&[`queued`,`running`,`uncertain`].includes(t.state)&&JSON.parse(t.argument).messageId===e.id),[s,c]=(0,z.useState)(!!o),[l,u]=(0,z.useState)(o?JSON.parse(o.argument).body:e.body),[d,f]=(0,z.useState)(!1),p=m(),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)(),b=(0,z.useRef)(void 0),x=Fe(l);(0,z.useLayoutEffect)(()=>{s&&x.current&&(x.current.style.height=`0px`,x.current.style.height=`${x.current.scrollHeight}px`)},[s]);let S=i?.commands.find(e=>e.id===_?.id)??_??o,C=h||S&&[`queued`,`running`].includes(S.state),w=i?.available&&e.source===`web_session`&&e.id.startsWith(`input:`)&&(!e.queue||[`handled`,`interrupted`].includes(e.queue.state));async function E(){if(!i||C||!l.trim())return;let t=JSON.stringify({messageId:e.id,body:l.trim(),expectedLastMessage:i.expectedLastMessage});(S&&[`failed`,`uncertain`].includes(S.state)||b.current?.argument!==t)&&(b.current={id:N(),argument:t}),g(!0),p(``);try{let e=await i.request(`web/local-agent-sessions/${i.session}/commands`,ke,{method:`POST`,body:{id:b.current.id,kind:`rewind`,argument:b.current.argument}});v(e),i.refresh()}catch(e){p(e)}finally{g(!1)}}return(0,B.jsxs)(`div`,{className:`computer-user-entry${s?` editing`:``}`,children:[(0,B.jsxs)(Pe,{mine:!0,author:e.agentMessage?T(e.agentMessage.direction===`sent`?`agentNote.to`:`agentNote.from`,{title:e.agentMessage.peer.title}):e.source===`human_message`?T(`session.forwardedByTim`):T(`web.ComputerUserMessage.1`),time:e.createdAt,children:[t,s?(0,B.jsxs)(`form`,{className:`computer-message-edit`,onSubmit:e=>{e.preventDefault(),E()},children:[(0,B.jsx)(`textarea`,{ref:x,"aria-label":T(`web.ComputerUserMessage.2`),value:l,onChange:e=>u(e.target.value),disabled:!!C,autoFocus:!0,rows:1}),(0,B.jsxs)(`div`,{className:`computer-message-edit-footer`,children:[(0,B.jsx)(`small`,{children:T(`web.ComputerUserMessage.3`)}),(0,B.jsx)(M,{icon:`close`,label:T(`web.ComputerUserMessage.4`),disabled:!!C,onClick:()=>{c(!1),p(``),u(e.body)}}),(0,B.jsx)(`button`,{type:`submit`,className:`message-send primary`,"aria-label":T(C?`web.ComputerUserMessage.5`:`web.ComputerUserMessage.6`),title:T(C?`web.ComputerUserMessage.5`:`web.ComputerUserMessage.6`),disabled:!!C||!l.trim(),children:(0,B.jsx)(O,{name:C?`loading`:`send`,size:`small`})})]}),(0,B.jsx)(n,{children:S&&[`failed`,`uncertain`].includes(S.state)&&S.error})]}):(0,B.jsx)(`div`,{className:`markdown`,children:(0,B.jsx)(Ae,{onFile:a,children:e.body})}),!s&&r]}),!s&&(0,B.jsxs)(`div`,{className:`computer-message-actions`,children:[(0,B.jsx)(M,{icon:d?`check`:`copy`,label:T(d?`web.labels.100`:`web.ComputerUserMessage.7`),onClick:()=>{p(``),j(e.body).then(()=>f(!0)).catch(e=>p(e))}}),w&&(0,B.jsx)(M,{icon:`edit`,label:T(`web.ComputerUserMessage.8`),onClick:()=>{u(e.body),c(!0)}})]})]})}function J({label:e,meta:t,children:n,className:r=``,onToggle:i}){return y(),(0,B.jsxs)(`details`,{className:`tool-details ${r}`,onToggle:i,children:[(0,B.jsxs)(`summary`,{className:`tool-summary`,title:e,children:[(0,B.jsx)(O,{name:`chevron`,size:`small`}),(0,B.jsx)(`span`,{className:`tool-details-label`,children:e}),t&&(0,B.jsx)(`span`,{className:`tool-details-status`,children:t})]}),n]})}function Y(e){if(e<1e3)return T(`web.ComputerMessages.1`);let t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return[r?T(`web.TaskBoard.30`,{p0:r}):``,n%60?T(`web.ComputerMessages.2`,{p0:n%60}):``,t%60?T(`web.ComputerMessages.3`,{p0:t%60}):``].filter(Boolean).join(` `)}function X({children:e,readSeq:t}){return y(),(0,B.jsx)(`div`,{className:`computer-divider`,"data-completion-seq":t,children:(0,B.jsx)(`span`,{children:e})})}function Z({message:e,readable:t=!1}){y();let n=e.state===`succeeded`?T(`web.ComputerMessages.4`):e.state===`interrupted`?T(`web.QueuedMessage.5`):e.state===`failed`?T(`web.ComputerMessages.5`):T(`web.Computers.5`);return(0,B.jsxs)(X,{readSeq:t?e.seq:void 0,children:[n,e.activity?.durationMs===void 0?``:` · ${Y(e.activity.durationMs)}`]})}var ut={get offered(){return T(`web.Computers.7`)},get pending(){return T(`web.Computers.10`)},get human_routed(){return T(`web.Computers.9`)},get failed(){return T(`web.Computers.14`)},get uncertain(){return T(`web.Computers.5`)}};function Q(e){let t=[];for(let n of e)if(n.role===`assistant`&&n.activity?.kind===`tool`&&!n.question){let e=t.at(-1);Array.isArray(e)&&e[0].activity?.turnId===n.activity.turnId?e.push(n):t.push([n])}else t.push(n);return t}function $({text:e,onFile:t}){y();let n=[],r=0;if(t)for(let{start:i,end:a,link:o}of oe(e))n.push(e.slice(r,i),(0,B.jsx)(`button`,{type:`button`,className:`computer-file-link`,onClick:()=>t(o),children:e.slice(i,a)},i)),r=a;return(0,B.jsxs)(`pre`,{children:[n,e.slice(r)]})}function dt({call:e,onFile:t,visible:n,onOpen:r}){y();let[i,a]=(0,z.useState)(!1);return(0,B.jsx)(J,{className:`computer-tool`,onToggle:e=>{let t=e.currentTarget.open;a(t),r?.(t)},label:e.activity?.labelMessage?P(A(),e.activity.labelMessage):e.activity?.label??T(`web.ComputerMessages.6`),meta:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(at,{state:e.state}),e.activity?.durationMs!==void 0&&(0,B.jsx)(`span`,{children:Y(e.activity.durationMs)})]}),children:i&&n&&(0,B.jsx)($,{text:e.body,onFile:t})})}function ft({calls:e,onFile:t}){y();let n=(0,z.useId)(),[r,i]=(0,z.useState)(!1),a=e.length>1,o=[`failed`,`uncertain`,`interrupted`].find(t=>e.some(e=>e.state===t));return(0,B.jsxs)(`div`,{className:a?`tool-details computer-tool-group`:void 0,children:[a&&(0,B.jsxs)(`button`,{type:`button`,className:`tool-summary`,"aria-expanded":r,"aria-controls":n,onClick:()=>i(!r),children:[(0,B.jsx)(O,{name:`chevron`,size:`small`}),T(`tools.calls`,{count:e.length}),o&&(0,B.jsx)(at,{state:o}),e.some(e=>e.state===`running`)&&(0,B.jsx)(at,{state:`running`})]}),(0,B.jsx)(`div`,{id:n,className:a?`computer-tool-list`:void 0,hidden:a&&!r,children:e.map(e=>(0,B.jsx)(dt,{call:e,onFile:t,visible:!a||r,onOpen:a?void 0:i},e.id))})]})}function pt({messages:e,renderQuestion:t,imageUrl:n,renderQueue:r,rewind:i,onFile:a}){y();let o=new Map(e.filter(e=>e.activity?.kind===`turn`).map(e=>[e.activity.turnId,e])),s=new Map,c=new Set(e.flatMap(e=>{let t=e.question?.planSource;return t?[JSON.stringify([t.turnId,t.itemId])]:[]})),l=new Set(e.flatMap(e=>{let t=e.activity;return t?.kind===`commentary`&&c.has(JSON.stringify([t.turnId,t.itemId]))?[JSON.stringify([t.turnId,e.body])]:[]}));for(let t of e)t.activity?.kind===`answer`&&s.set(t.activity.turnId,t.id);let u=e.filter(({activity:e,body:t})=>e?.kind!==`commentary`||!c.has(JSON.stringify([e.turnId,e.itemId]))&&!l.has(JSON.stringify([e.turnId,t]))),d=(0,z.useRef)({keys:new Map,next:0}),f=new Map,p=new Set,m=d.current.next,h=Q(u);for(let e of h){if(!Array.isArray(e))continue;let t;for(let n of e){if(t=d.current.keys.get(n.id),t!==void 0&&!p.has(t))break;t=void 0}t??=m++,p.add(t);for(let n of e)f.set(n.id,t)}return(0,z.useLayoutEffect)(()=>{d.current={keys:f,next:m}}),(0,B.jsx)(`div`,{className:`computer-messages`,children:h.map(e=>{if(Array.isArray(e))return(0,B.jsx)(ft,{calls:e,onFile:a},`tools:${f.get(e[0].id)}`);let c=e.activity;if(e.role===`system`&&!e.agentMessage)return(0,B.jsx)(X,{children:e.presentation?lt(A(),e.presentation):e.body},e.id);if(c?.kind===`turn`)return s.has(c.turnId)?null:(0,B.jsx)(Z,{message:e,readable:!0},e.id);if(e.role===`user`||e.agentMessage)return(0,B.jsx)(q,{message:e,rewind:i,onFile:a,images:n&&(e.attachments??e.images)?.length?(0,B.jsx)(G,{images:e.attachments??e.images,url:t=>n(t,!!e.attachments)}):null,status:e.agentMessage?(0,B.jsxs)(`small`,{title:e.agentMessage.detail,children:[T(`agentNote.${e.agentMessage.status}`),` ·`,` `,e.agentMessage.messageId]}):e.queue&&r?r(e):ut[e.state]&&(0,B.jsx)(je,{label:ut[e.state],state:e.state})},e.id);let l=c?.kind===`answer`&&s.get(c.turnId)===e.id?o.get(c.turnId):void 0;return(0,B.jsxs)(z.Fragment,{children:[l&&(0,B.jsx)(Z,{message:l}),(0,B.jsx)(`article`,{"data-message-seq":e.seq,"data-completion-seq":l?.seq??(e.source===`agent-final`&&[`sent`,`succeeded`,`failed`,`interrupted`,`uncertain`].includes(e.state)?e.seq:void 0),id:e.question?`computer-question-${e.question.id}`:void 0,tabIndex:e.question?-1:void 0,className:`computer-agent-message ${c?.kind===`commentary`?`computer-commentary`:``} ${e.question?`question-bubble`:``}`,children:e.question?t(e.question):(0,B.jsx)(`div`,{className:`markdown`,children:(0,B.jsx)(Ae,{onFile:a,children:e.body})})})]},e.id)})})}function mt({disabled:e,onSend:t,initialValue:n=``,placeholder:r}){y();let[i,a]=(0,z.useState)(n),[o,s]=(0,z.useState)(!!n),c=T(`web.InlineReply.1`),l=(0,z.useRef)(null),u=(0,z.useCallback)(e=>{if(!l.current)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.font=getComputedStyle(e).font;let n=Math.max(...(i||`${c}…`).split(`
|
|
8
8
|
`).map(e=>t.measureText(e).width));l.current.style.setProperty(`--reply-width`,`${Math.ceil(n+(o?52:26))}px`)},[i,o,c]),d=Fe(i,u);return(0,B.jsxs)(`form`,{ref:l,className:`inline-reply${o?` active`:``}`,onFocus:()=>s(!0),onBlur:e=>{!i&&!e.currentTarget.contains(e.relatedTarget)&&s(!1)},onSubmit:n=>{n.preventDefault(),!e&&i.trim()&&t(i.trim()).then(e=>{e&&a(``)})},children:[(0,B.jsx)(`textarea`,{ref:d,rows:1,"aria-label":T(`web.InlineReply.2`),placeholder:r??`${c}…`,value:i,disabled:e,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&!ye(t.nativeEvent)&&(t.preventDefault(),!e&&i.trim()&&t.currentTarget.form?.requestSubmit())}}),o&&(0,B.jsx)(`button`,{className:`inline-reply-send`,type:`submit`,disabled:e||!i.trim(),"aria-label":T(`web.InlineReply.3`,{p0:c}),title:T(`web.InlineReply.3`,{p0:c}),children:(0,B.jsx)(O,{name:`send`,size:`small`})})]})}function ht(e,t){let n=new Set,r=()=>{if(document.hidden||!document.hasFocus())return;let e=document.querySelector(`dialog[open]`);for(let r of n){if(e&&!e.contains(r))continue;let n=r.getBoundingClientRect(),i=r.closest(`.assistant-transcript`)?.getBoundingClientRect();n.width>0&&n.height>0&&n.bottom>Math.max(0,i?.top??0)&&n.top<Math.min(innerHeight,i?.bottom??innerHeight)&&t(r)}},i=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&t.intersectionRect.height>0?n.add(t.target):n.delete(t.target);r()});for(let t of e)i.observe(t);return window.addEventListener(`focus`,r),document.addEventListener(`focusin`,r),document.addEventListener(`visibilitychange`,r),()=>{i.disconnect(),window.removeEventListener(`focus`,r),document.removeEventListener(`focusin`,r),document.removeEventListener(`visibilitychange`,r)}}function gt({question:e,session:t,request:n,refresh:r}){y();let[i,a]=(0,z.useState)({}),[o,s]=(0,z.useState)({}),c=m(),[u,d]=(0,z.useState)(!1),[p,h]=(0,z.useState)(!1),[g,_]=(0,z.useState)(``),v=(0,z.useRef)(null),b=(0,z.useRef)(!1),x=(0,z.useRef)(void 0);(0,z.useEffect)(()=>{if(e.state!==`pending`||b.current||!v.current)return;let r=!1;return ht([v.current],()=>{b.current||r||(r=!0,n(`web/local-agent-sessions/${t}/questions/${e.id}/presented`,l({ok:f()}),{method:`POST`}).then(()=>{b.current=!0,window.dispatchEvent(new Event(`teammy:outbox`))}).catch(e=>c(e)).finally(()=>{r=!1}))})},[e.id,e.state,t,n]);async function S(i){let a=JSON.stringify(i);x.current?.fingerprint!==a&&(x.current={fingerprint:a,value:{...i,id:N()}}),d(!0),c(``);try{return await n(`web/local-agent-sessions/${t}/questions/${e.id}/answers`,ee(),{method:`POST`,body:x.current.value}),x.current=void 0,r(),!0}catch(e){return c(e),!1}finally{d(!1)}}let[C,w]=(0,z.useState)(Date.now);(0,z.useEffect)(()=>{if(!e.approval||e.state!==`pending`||e.autoApproveAt==null)return;w(Date.now());let t=setInterval(()=>w(Date.now()),1e3);return()=>clearInterval(t)},[e.approval,e.state,e.autoApproveAt]);let E=e.autoApprove!==!1&&e.autoApproveAt!=null?Math.max(0,Math.ceil((e.autoApproveAt-C)/1e3)):null,D=e=>e.labelMessage?P(A(),e.labelMessage):e.label,k=e=>e.descriptionMessage?P(A(),e.descriptionMessage):e.description,j=(e,t)=>e.optionLabels?.[t]?P(A(),e.optionLabels[t]):t,M=e.response,F=e.state===`answered`,ne=[`expired`,`cancelled`].includes(e.state),re=[`human_routed`,`failed`,`handled`].includes(e.submissionState??``)&&!F,I=te(e),L=e.kind===`plan`,ie=e.actions?.find(e=>e.id===M?.actionId),ae=ne?T(`web.NativeInteractionCard.1`):e.state===`uncertain`||e.submissionState===`uncertain`?T(`web.NativeInteractionCard.2`):F?L?ie?D(ie):T(`web.NativeInteractionCard.3`):e.approval?M?.decision===!0?T(`web.NativeInteractionCard.4`):M?.decision===!1?T(`web.NativeInteractionCard.5`):T(`web.NativeInteractionCard.3`):ie?D(ie):M?``:T(`web.NativeInteractionCard.6`):re?T(`web.NativeInteractionCard.7`):M?T(`web.NativeInteractionCard.8`):``,oe=ne||M?.decision===!1||re?`close`:F?`check`:`clock`,se=e.questions.length>1||e.questions.some(e=>e.multiSelect),ce=(t=i)=>S({body:e.questions.length===1?t[e.questions[0].id]||(o[e.questions[0].id]??[]).join(`、`):JSON.stringify(t),...e.kind||e.questions.some(e=>e.multiSelect)?{answers:t}:{},...e.questions.some(e=>e.multiSelect)?{selections:o}:{}});if(e.delivery===`async`&&(F||ne)){let t=F&&M?e.questions.flatMap(e=>[...M.selections?.[e.id]??[],M.answers[e.id]].filter(e=>!!e).map(t=>j(e,t))):[];return t.length?(0,B.jsxs)(`div`,{className:`question-response native-async-answer`,children:[(0,B.jsx)(O,{name:`check`,size:`small`}),(0,B.jsx)(`span`,{children:t.join(`
|
|
9
9
|
`)})]}):null}return(0,B.jsxs)(`div`,{className:`native-question ${L?`native-plan`:``} ${I?`native-question-pending`:``}`,ref:v,children:[L?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`native-plan-heading`,children:[(0,B.jsx)(O,{name:`file`,size:`small`}),(0,B.jsx)(`span`,{children:T(`web.NativeInteractionCard.9`)})]}),I?(0,B.jsx)(`div`,{className:`native-plan-content markdown`,children:(0,B.jsx)(Ae,{children:e.plan??``})}):(0,B.jsxs)(`details`,{className:`native-plan-history markdown`,children:[(0,B.jsx)(`summary`,{children:T(`web.NativeInteractionCard.10`)}),(0,B.jsx)(Ae,{children:e.plan??``})]}),I&&(0,B.jsxs)(B.Fragment,{children:[!p&&(0,B.jsx)(`div`,{className:`question-actions native-plan-actions ${e.actions&&e.actions.length>3?`native-plan-actions-expanded`:``}`,children:e.actions?.map(e=>(0,B.jsx)(`button`,{type:`button`,disabled:u,title:k(e),className:e.id===`implement`?`primary`:``,onClick:()=>e.id===`revise`?h(!0):void S({body:e.label,actionId:e.id}),children:D(e)},e.id))}),!p&&e.actions?.find(e=>e.id===`implement`)?.description&&(0,B.jsxs)(`small`,{className:`native-plan-note muted`,children:[T(`web.NativeInteractionCard.11`),k(e.actions.find(e=>e.id===`implement`))]}),p&&(0,B.jsxs)(`form`,{className:`native-plan-feedback`,onSubmit:e=>{e.preventDefault(),S({body:g,actionId:`revise`})},children:[(0,B.jsxs)(`label`,{children:[T(`web.NativeInteractionCard.12`),(0,B.jsx)(`textarea`,{autoFocus:!0,value:g,onChange:e=>_(e.target.value),placeholder:T(`web.NativeInteractionCard.13`)})]}),(0,B.jsxs)(`div`,{className:`question-actions native-plan-feedback-actions`,children:[(0,B.jsx)(`button`,{className:`primary`,disabled:u||!g.trim(),children:T(`web.NativeInteractionCard.14`)}),(0,B.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>h(!1),children:T(`web.NativeInteractionCard.15`)})]})]})]}),!I&&M?.actionId===`revise`&&M.answers.feedback&&(0,B.jsx)(`div`,{className:`question-response`,children:M.answers.feedback})]}):e.approval?(0,B.jsxs)(`div`,{className:`native-approval-row`,children:[(0,B.jsx)(J,{className:`native-approval-details`,label:e.questions.map(e=>(e.textMessage?P(A(),e.textMessage):e.text).split(`
|
|
10
10
|
`).filter(Boolean).slice(0,2).join(` · `)).join(` · `),children:(0,B.jsx)(`pre`,{children:e.questions.map(e=>e.textMessage?P(A(),e.textMessage):e.text).join(`
|
|
11
11
|
|
|
12
12
|
`)})}),I?(0,B.jsxs)(`div`,{className:`native-approval-options`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`primary`,disabled:u,"aria-label":T(`web.NativeInteractionCard.16`),title:E===null?void 0:T(`web.NativeInteractionCard.17`),onClick:()=>void S({body:T(`common.allow`),decision:!0}),children:[T(`web.NativeInteractionCard.16`),E!==null&&(0,B.jsxs)(`span`,{"aria-hidden":`true`,children:[`(`,E,`s)`]})]}),(0,B.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>void S({body:T(`common.deny`),decision:!1}),children:T(`web.NativeInteractionCard.18`)})]}):ae&&(0,B.jsxs)(`small`,{className:`question-result`,children:[(0,B.jsx)(O,{name:oe,size:`small`}),ae]})]}):(0,B.jsxs)(B.Fragment,{children:[e.questions.map(t=>(0,B.jsxs)(`div`,{className:`native-question-part`,children:[(0,B.jsx)(`p`,{children:t.textMessage?P(A(),t.textMessage):t.text}),I&&(0,B.jsx)(`div`,{className:`question-options ${Object.values(t.descriptions??{}).some(Boolean)?`question-options-described`:``}`,children:t.options.map(e=>(0,B.jsxs)(`button`,{type:`button`,disabled:u,"aria-pressed":t.multiSelect?o[t.id]?.includes(e)??!1:i[t.id]===e,title:[j(t,e),t.descriptions?.[e]].filter(Boolean).join(` | `),onClick:()=>{if(t.multiSelect){s(n=>({...n,[t.id]:n[t.id]?.includes(e)?n[t.id].filter(t=>t!==e):[...n[t.id]??[],e]}));return}let n={...i,[t.id]:e};a(n),se||ce(n)},children:[(0,B.jsxs)(`span`,{className:`question-option-label`,children:[t.multiSelect&&(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`question-check`,children:o[t.id]?.includes(e)&&(0,B.jsx)(O,{name:`check`,size:`small`})}),(0,B.jsx)(`span`,{className:`question-option-text`,children:j(t,e)})]}),t.descriptions?.[e]&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`question-option-separator`,"aria-hidden":`true`,children:`|`}),(0,B.jsx)(`span`,{className:`question-option-description`,title:t.descriptions[e],children:t.descriptions[e]})]})]},e))}),t.freeText&&I&&(0,B.jsx)(mt,{initialValue:t.initialValue,placeholder:t.placeholder,disabled:u,onSend:async e=>{let n={...i,[t.id]:e};return a(n),se?!0:ce(n)}}),I&&se&&i[t.id]&&!t.options.includes(i[t.id])&&(0,B.jsx)(`small`,{children:i[t.id]}),!I&&!e.approval&&(M?.answers[t.id]||M?.selections?.[t.id]?.length)&&(0,B.jsxs)(`div`,{className:`question-response`,children:[(0,B.jsx)(O,{name:F?`check`:`clock`,size:`small`}),(0,B.jsx)(`span`,{children:[...M.selections?.[t.id]??[],M.answers[t.id]].filter(e=>!!e).map(e=>j(t,e)).join(A()===`en`?`, `:`、`)})]})]},t.id)),I&&e.actions?.length&&(0,B.jsx)(`div`,{className:`question-actions`,children:e.actions.map(e=>(0,B.jsx)(`button`,{disabled:u,onClick:()=>void S({body:e.label,actionId:e.id}),children:D(e)},e.id))}),I&&se&&(0,B.jsx)(`div`,{className:`question-actions`,children:(0,B.jsx)(`button`,{disabled:u||e.questions.some(e=>!i[e.id]?.trim()&&!o[e.id]?.length),onClick:()=>void ce(),children:T(`web.NativeInteractionCard.19`)})})]}),ae&&(!e.approval||L)&&(0,B.jsxs)(`small`,{className:`question-result`,children:[(0,B.jsx)(O,{name:oe,size:`small`}),ae]})]})}function _t({session:e,active:t,commands:n,request:r,refresh:i,onError:a}){y();let[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(),u=(0,z.useRef)(void 0),f=n.find(e=>e.id===c?.id)??c,p=o||f&&[`queued`,`running`].includes(f.state)||n.some(e=>e.kind===`stop`&&[`queued`,`running`].includes(e.state));if(!t&&!p)return null;async function m(){if(!p){u.current??=N(),s(!0),a(``);try{let t=await r(`web/local-agent-sessions/${e}/commands`,ke,{method:`POST`,body:{id:u.current,kind:`stop`}});l(t),u.current=void 0,i()}catch(e){a(d(e))}finally{s(!1)}}}return(0,B.jsxs)(`button`,{type:`button`,className:`message-stop`,"aria-label":T(p?`web.SessionStopButton.1`:`web.SessionStopButton.2`),title:T(p?`web.SessionStopButton.1`:`web.SessionStopButton.2`),disabled:!!p,onClick:()=>void m(),children:[(0,B.jsx)(`span`,{className:`message-stop-ring`,"aria-hidden":`true`}),(0,B.jsx)(O,{name:`stop`,size:`small`})]})}var vt={queued:`web.Computers.10`,running:`web.Computers.13`,succeeded:`web.Computers.12`,failed:`web.Computers.14`,uncertain:`web.Computers.5`};function yt(e){return`${e.kind===`stop`?T(`web.Computers.48`):e.kind} · ${T(vt[e.state])}`}function bt({commands:e,cacheKey:t}){y();let n=a(),r=(0,z.useRef)(n?.get(t)),i=m();return(0,z.useEffect)(()=>{let a=r.current?e.filter(e=>[`failed`,`uncertain`].includes(e.state)&&![`diff`,`history`,`rewind`].includes(e.kind)&&r.current.get(e.id)!==e.state):[];r.current=new Map(e.map(e=>[e.id,e.state])),n?.set(t,r.current),a.length&&i(a.map(e=>`${yt(e)}${e.error?`:${e.error}`:``}`).join(`
|
|
13
13
|
`))},[e,n,t,i]),e.filter(e=>[`queued`,`running`].includes(e.state)&&![`diff`,`history`,`rewind`,`stop`].includes(e.kind)).slice(-3).map(e=>(0,B.jsx)(`p`,{className:`computer-control-status`,role:`status`,children:yt(e)},e.id))}function xt({commands:e,onClose:t}){y();let r=e.filter(e=>![`diff`,`history`].includes(e.kind));return(0,B.jsx)(k,{id:`session-command-history`,title:T(`session.commands.history`),onClose:t,children:r.length?(0,B.jsx)(`ol`,{className:`session-command-history`,children:r.reverse().map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`p`,{children:yt(e)}),(0,B.jsx)(n,{children:e.error})]},e.id))}):(0,B.jsx)(`p`,{className:`muted`,children:T(`session.commands.empty`)})})}var St={get minimal(){return T(`web.LocalComposerControls.1`)},get low(){return T(`web.LocalComposerControls.2`)},get medium(){return T(`web.LocalComposerControls.3`)},get high(){return T(`web.LocalComposerControls.4`)},get xhigh(){return T(`web.LocalComposerControls.5`)},get max(){return T(`web.LocalComposerControls.6`)},get ultra(){return T(`web.LocalComposerControls.7`)},get none(){return T(`web.LocalComposerControls.8`)},get off(){return T(`web.labels.13`)}};function Ct({id:e,label:t,current:n,options:r,disabled:i,onSelect:a}){y();let o=r.find(e=>e.value===n);return(0,B.jsx)(w,{id:`${e}-menu`,triggerId:e,placement:`top`,className:`composer-menu composer-choice`,label:T(`web.LocalComposerControls.9`,{p0:t}),disabled:i,routeKey:n,trigger:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{title:T(`common.withDetail`,{label:t,detail:o?.label??n}),children:o?.shortLabel??o?.label??n}),(0,B.jsx)(O,{name:`chevronDown`,size:`small`})]}),children:e=>(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`composer-menu-heading`,children:t}),r.map(t=>(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":t.label,onClick:()=>{e(),a(t.value)},children:[(0,B.jsxs)(`span`,{className:`composer-option-copy`,children:[(0,B.jsx)(`span`,{children:t.label}),t.description&&(0,B.jsx)(`small`,{children:t.description})]}),t.value===n&&(0,B.jsx)(O,{name:`check`,size:`small`})]},t.value))]})})}function wt({session:e,models:t,busy:n,available:r,online:i,commands:a,controls:o,draft:s,onInsert:c,onConfig:l}){y();let[u,d]=(0,z.useState)(!1);(0,z.useEffect)(()=>{/^[/$]([^\s]*)$/.exec(s)?d(!0):d(!1)},[s]);let f=e.config.model??e.effectiveConfig?.model,p=t.find(e=>e.id===f||e.resolvedModel===f)??(e.config.model?void 0:t.find(e=>e.isDefault)),m=n||!r,h=e.provider===`claude`,g=e.provider===`cursor`,_=K(A(),e.provider,o??Oe(e.provider)),v=p?.effortLabel??T(`web.LocalComposerControls.10`),b=e=>p?.effortLabel?e:St[e]??e,x=e.appliedRevision===e.revision?e.effectiveConfig?.mode:void 0,S=t.find(e=>e.isDefault)?.id??(e.config.model?null:e.effectiveConfig?.model),C=t.find(e=>e.id===S)?.name??S,E=e=>h?e.replace(/^Claude\s+/,``):e,D=[{value:``,label:C?T(`web.LocalComposerControls.11`,{p0:C}):t.length?T(`web.LocalComposerControls.12`):T(`web.LocalComposerControls.13`),shortLabel:C?E(C):t.length?T(`web.LocalComposerControls.12`):T(`web.LocalComposerControls.14`)},...t.map(e=>({value:e.id,label:e.name,shortLabel:E(e.name)}))];e.config.model&&!t.some(t=>t.id===e.config.model)&&D.push({value:e.config.model,label:e.config.model,shortLabel:E(e.config.model)});let k=p?.id===e.effectiveConfig?.model?e.effectiveConfig?.effort:p?.defaultEffort,j=[{value:``,label:k?T(`web.LocalComposerControls.11`,{p0:b(k)}):T(`web.LocalComposerControls.15`,{p0:v}),shortLabel:k?b(k):p?.effortLabel??T(`web.LocalComposerControls.16`)},...(p?.efforts??[]).map(e=>({value:e,label:b(e)}))];return e.config.effort&&!j.some(t=>t.value===e.config.effort)&&j.push({value:e.config.effort,label:b(e.config.effort)}),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(w,{id:`session-commands`,triggerId:`session-command-trigger`,label:T(`web.LocalComposerControls.17`),placement:`top`,className:`composer-menu composer-commands`,routeKey:e.id,trigger:(0,B.jsx)(O,{name:`command`,size:`small`}),open:u,onOpenChange:d,focusFirst:!1,disabled:m||!i,children:e=>(0,B.jsxs)(B.Fragment,{children:[[...a].sort((e,t)=>e.name.localeCompare(t.name,`en`)).map(t=>(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,title:[t.description,t.path].filter(Boolean).join(`
|
|
14
|
-
`),onClick:()=>{e(),c(t)},children:(0,B.jsxs)(`span`,{className:`composer-command-row`,children:[(0,B.jsxs)(`span`,{className:`composer-command-name`,children:[t.prefix??(t.kind===`skill`?`$`:`/`),t.name]}),(0,B.jsx)(`small`,{children:t.description})]})},`${t.kind}:${t.path??t.name}`)),!a.length&&(0,B.jsx)(`div`,{className:`composer-menu-heading`,children:T(`web.LocalComposerControls.18`)})]})}),(0,B.jsx)(Ct,{id:`session-model`,label:T(`web.LocalComposerControls.14`),current:e.config.model??``,options:D,disabled:m,onSelect:n=>{let r=t.find(e=>e.id===n);l({...e.config,model:n||null,...g?{options:{}}:{},effort:e.config.effort&&r?.efforts.includes(e.config.effort)?e.config.effort:null})}}),(e.provider===`codex`||h||(p?.efforts.length??0)>0||!!e.config.effort)&&(0,B.jsx)(Ct,{id:`session-effort`,label:v,current:e.config.effort??``,options:j,disabled:m,onSelect:t=>l({...e.config,effort:t||null})}),p?.options?.map(t=>(0,B.jsx)(Ct,{id:`session-option-${t.id}`,label:t.name,current:e.config.options?.[t.id]??``,options:[{value:``,label:T(`web.LocalComposerControls.11`,{p0:t.choices.find(e=>e.value===t.defaultValue)?.label??t.defaultValue})},...t.choices],disabled:m,onSelect:n=>{let r={...e.config.options};n?r[t.id]=n:delete r[t.id],l({...e.config,options:r})}},t.id)),_.map(t=>(0,B.jsx)(Ct,{id:t.key===`mode`&&!h?`session-mode`:`session-permission`,label:t.label,current:t.key===`mode`?x??e.config.mode??t.defaultValue:e.config.permission,options:t.choices,disabled:m,onSelect:n=>l(t.key===`mode`?{...e.config,mode:n||void 0}:{...e.config,permission:n})},t.key))]})}var Tt=(0,z.lazy)(()=>Ce(()=>import(`./TerminalPane-CZYb0vIG.js`),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)),Et={get idle(){return T(`web.Computers.1`)},get working(){return T(`web.Computers.2`)},get waiting(){return T(`web.Computers.3`)},get queued(){return T(`web.Computers.4`)},get uncertain(){return T(`web.Computers.5`)},get human(){return T(`web.Computers.6`)},get offered(){return T(`web.Computers.7`)},get accepted(){return T(`web.Computers.8`)},get human_routed(){return T(`web.Computers.9`)},get pending(){return T(`web.Computers.10`)},get sent(){return T(`web.Computers.11`)},get succeeded(){return T(`web.Computers.12`)},get running(){return T(`web.Computers.13`)},get failed(){return T(`web.Computers.14`)}};function Dt(e){return{width:e.clientWidth,height:e.clientHeight,top:e.scrollHeight-e.clientHeight}}function Ot({navigate:e,memberId:t}){y();let{request:n,projectId:i}=we(),a=(0,z.useCallback)(e=>n(`web/local-agent-settings`,be,{signal:e}),[n]),o=p(a,3e4);return(0,z.useEffect)(()=>{let e=()=>void o.reload();return window.addEventListener(`teammy:local-access`,e),()=>window.removeEventListener(`teammy:local-access`,e)},[o.reload]),!o.data&&o.error?(0,B.jsx)(r,{resource:o}):o.data?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(_,{message:o.error}),(0,B.jsx)(kt,{localAvailable:o.data.accessible,navigate:e,memberId:t},`${i}/${t}`)]}):null}function kt({localAvailable:e,navigate:t,memberId:i}){y();let o=we(),s=a(),c=h(o.projectId,i,`computer-selection`),l=h(o.projectId,i,`computer-drafts`),u=s?.get(c),[d,f]=(0,z.useState)(()=>new Set),[g,_]=(0,z.useState)(()=>({project:o.projectId,directory:new URLSearchParams(location.search).get(`directory`)??u?.directory??``,session:new URLSearchParams(location.search).get(`session`)??(new URLSearchParams(location.search).has(`terminal`)?``:u?.session??``),terminal:new URLSearchParams(location.search).get(`terminal`)??(new URLSearchParams(location.search).has(`session`)?``:u?.terminal??``)})),v=m(),[b,S]=(0,z.useState)(!1),[E,D]=(0,z.useState)(!1),[j,P]=(0,z.useState)(()=>s?.get(l)??{}),ne=j[g.session]??``,L=e=>P(t=>({...t,[g.session]:typeof e==`function`?e(t[g.session]??``):e}));(0,z.useEffect)(()=>{s?.set(l,j)},[s,l,j]);let[ae,oe]=(0,z.useState)(``),[ue,me]=(0,z.useState)(!1),[R,ye]=(0,z.useState)(`codex`),[be,Ce]=(0,z.useState)(!1),[Ee,De]=(0,z.useState)(``),[Oe,ke]=(0,z.useState)(),[Ae,Pe]=(0,z.useState)(!1),[Fe,Le]=(0,z.useState)(Date.now);(0,z.useEffect)(()=>{let e=setInterval(()=>Le(Date.now()),6e4);return()=>clearInterval(e)},[]);let V=(0,z.useRef)(null),H=(0,z.useRef)(!0),Be=(0,z.useRef)(null),Ve=(0,z.useCallback)(e=>{let t=Dt(e),n=Be.current,r=n&&(t.width!==n.width||t.height!==n.height||t.top!==n.top);return(H.current&&r?Math.min(n.top,t.top):t.top)-e.scrollTop<96},[]),Ue=(0,z.useCallback)(e=>{e.scrollTop=e.scrollHeight,Be.current=Dt(e)},[]),We=(0,z.useRef)(null),Ge=(0,z.useCallback)(e=>{let t=V.current;if(!t)return!0;if(Ve(t)||(H.current=!1),!e||H.current)return H.current;let n=t.getBoundingClientRect().top,r=Array.from(t.querySelectorAll(`.computer-messages > :not(.computer-tool-group), .computer-tool-group > .tool-summary, .computer-tool-group .computer-tool`)).find(e=>{let t=e.getBoundingClientRect();return t.height>0&&t.bottom>n});return We.current={...r?{node:r}:{},offset:r?.getBoundingClientRect().top??0,top:t.scrollTop,height:t.scrollHeight},!1},[Ve]),qe=(0,z.useRef)(new URLSearchParams(location.search).get(`question`)),U=(0,z.useRef)(Number(new URLSearchParams(location.search).get(`message`))||null),Xe=(0,z.useRef)(null),Ze=(0,z.useRef)(void 0),$e=(0,z.useRef)(N()),et=(0,z.useCallback)(async t=>e?(await o.request(`web/local-agent-computers`,de,{signal:t})).computers.map(e=>({...e,project:o.projectId})):[],[o,e]),W=p(et,3e3),nt=(W.data??[]).flatMap(e=>e.directories.map(t=>({c:e,d:t,label:pe(W.data??[],e,t)}))).sort((e,t)=>e.label.localeCompare(t.label)),G=W.data?.find(e=>e.project===g.project&&e.directories.some(e=>e.id===g.directory)),it=He(o.projectId,e),at=it.terminals.find(e=>e.id===g.terminal),ct=(0,z.useRef)(at);at&&(ct.current=at);let K=at??(ct.current?.id===g.terminal?ct.current:void 0),lt=G?.directories.find(e=>e.id===g.directory),q=W.data?.find(e=>e.directories.some(e=>e.id===Ee))??G,J=q?.directories.find(e=>e.id===Ee)??lt;fe(g.project);let Y=(0,z.useCallback)((e,t,n)=>fe(g.project).request(e,t,n),[g.project]),X=rt(g.session,g.project,Y),Z=st(g.project,e?g.session:``,Y,Ge);function ut(e){let t=Ve(e);return t&&!H.current&&(Be.current=Dt(e)),H.current=t,Z.follow(t),t}let Q=Z.data;(0,z.useLayoutEffect)(()=>{Pe(!1),H.current=!0,Be.current=null,Xe.current=null,We.current=null},[g.project,g.session]);let $=Q?.session;he(g.project,$?.id??``);let dt=Z.attention,ft=dt?.title??$?.title,mt=dt?.question?{question:T(`web.Computers.15`),approval:T(`web.Computers.16`),plan:T(`web.Memory.7`)}[dt.question]:dt?.completion?T(`web.Computers.17`):``;xe(g.session&&ft?`${mt?`[${mt}] `:``}${ft}`:void 0);let vt=Q?.pendingQuestions??Q?.messages.flatMap(({question:e,seq:t})=>e?.delivery===`async`&&te(e)?[{id:e.id,seq:t}]:[])??[];function yt(e){let t=V.current,n=document.getElementById(`computer-question-${e}`);return!t||!n||!t.contains(n)||!n.getClientRects().length?!1:(H.current=!1,Xe.current=e,t.scrollTop+=n.getBoundingClientRect().top-t.getBoundingClientRect().top-16,n.focus({preventScroll:!0}),!0)}function St(e){let t=V.current,n=t?.querySelector(`[data-message-seq="${e}"], [data-completion-seq="${e}"]`);return!t||!n||!n.getClientRects().length?!1:(H.current=!1,t.scrollTop+=n.getBoundingClientRect().top-t.getBoundingClientRect().top-16,!0)}(0,z.useEffect)(()=>{let e=e=>{let t=e.detail;if(t.project!==g.project||t.session!==g.session)return;let n=new URL(location.href);n.searchParams.delete(`question`),n.searchParams.delete(`message`),qe.current=t.question??null,U.current=t.question?null:t.sequence,n.searchParams.set(`directory`,g.directory),n.searchParams.set(`session`,g.session),n.searchParams.set(t.question?`question`:`message`,t.question??String(t.sequence)),history.replaceState(null,``,n),(t.question?yt(t.question):St(t.sequence))?(qe.current=null,U.current=null):Z.reveal(t.sequence)};return window.addEventListener(`teammy:notification-open`,e),()=>window.removeEventListener(`teammy:notification-open`,e)},[g.project,g.session,g.directory,Z.reveal]),(0,z.useLayoutEffect)(()=>{if(!$||!V.current)return;let e=V.current;if(qe.current){let e=qe.current;if(yt(e)){qe.current=null,We.current=null;return}}if(U.current&&St(U.current)){U.current=null,We.current=null;return}let t=We.current;We.current=null,t&&!H.current?t.node&&e.contains(t.node)?e.scrollTop+=t.node.getBoundingClientRect().top-t.offset:e.scrollTop=t.top+e.scrollHeight-t.height:H.current&&Ue(e)},[$?.id,lt?.id,Q,Ue]),(0,z.useLayoutEffect)(()=>{let e=V.current;if(!e||!$)return;let t=new ResizeObserver(()=>{H.current&&Ve(e)&&Ue(e)});t.observe(e);let n=e.querySelector(`.computer-messages`);return n&&t.observe(n),()=>t.disconnect()},[$?.id,lt?.id,Ve,Ue]),(0,z.useEffect)(()=>{G?.online===!1&&Z.reload()},[G?.online,Z.reload]);let Ct=(0,z.useRef)(Q?.messages);(0,z.useLayoutEffect)(()=>{Ct.current=Q?.messages},[Q?.messages]);let Ot=(0,z.useCallback)(({path:e,line:t})=>{let n=F(e,g.terminal?K?.cwd:$?.cwd);if(!n)return;let r=n.split(`/`).at(-1),i=/\/\.workspace\/\.teammy-attachments\/([0-9a-f-]{36})\/[^/]+$/i.exec(n);if(!g.terminal&&$&&i){let e=Ct.current?.flatMap(e=>e.attachments??[]).find(e=>e.id===i[1]);ke({...e,name:e?.name??r,line:t,url:tt(g.project,$.id,i[1],!0)});return}let a=g.terminal?K?.directory:$?.executionDirectory??$?.directory;if(!a)return;let o=x(`/api/v1/projects/${encodeURIComponent(g.project)}/web/local-agents/${encodeURIComponent(a)}/file?${new URLSearchParams({path:n})}`),s=Ye(r);ke({name:r,line:t,url:o,previewUrl:o+(s.startsWith(`text/`)?`&view=text`:s?``:`&view=info`)})},[g.project,g.terminal,$?.directory,$?.executionDirectory,$?.id,$?.cwd,K?.directory,K?.cwd]),kt=G?.capabilities.includes(`local-sessions-v1`),At=(e,t,n=``,r=``)=>{ke(void 0),_({project:e,directory:t,session:n,terminal:r}),s?.set(c,{directory:t,session:n,terminal:r}),me(!1),Ce(!1),v(``);let i=new URL(location.href);(g.session!==n||r)&&(i.searchParams.delete(`question`),i.searchParams.delete(`message`),qe.current=null,U.current=null),i.searchParams.delete(`view`),i.searchParams.delete(`section`),i.searchParams.set(`directory`,t),r?i.searchParams.set(`terminal`,r):i.searchParams.delete(`terminal`),n?i.searchParams.set(`session`,n):i.searchParams.delete(`session`),e===o.projectId&&history.replaceState(null,``,i)};(0,z.useEffect)(()=>{let e=W.data?.find(e=>e.sessions.some(e=>e.id===g.session))??W.data?.find(e=>e.directories.length);if(!g.directory&&e?.directories.length){let t=e.directories[0],n=e.sessions.find(e=>e.id===g.session);At(e.project,n?.directory??t.id,n?.id??t.defaultSession??e.sessions.find(e=>e.directory===t.id)?.id)}},[W.data]),(0,z.useEffect)(()=>{if($&&V.current)return ht([...V.current.querySelectorAll(`[data-completion-seq]`)],e=>void Z.markRead(Number(e.getAttribute(`data-completion-seq`))))},[$?.id,Q?.messages,Z.markRead]);async function jt(e){S(!0),v(``);try{await e(),await Promise.all([Z.reload(),W.reload()])}catch(e){v(e)}finally{S(!1)}}function Mt(e,t){return jt(async()=>{if(await o.request(`web/local-agent-sessions/${e.id}/metadata`,ce,{method:`PUT`,body:{expectedRevision:e.metadataRevision,...t}}),t.hidden&&g.session===e.id){let t=G?.sessions.find(t=>t.directory===e.directory&&t.id!==e.id&&!t.hidden);At(g.project,e.directory,t?.id)}})}function Nt(e){let n=new URLSearchParams({tab:`connect`,directory:e,session:g.session});t(`/projects/${o.projectId}/settings?${n}`)}function Pt(e){let t=nt.find(({d:t})=>t.id===e),n=t?.d.provider??`codex`;return le(n)&&!t?.c.providers.some(e=>e.id===n&&e.available)?`codex`:n}function Ft(e=g.directory){let t=W.data?.find(t=>t.directories.some(t=>t.id===e))??G,n=t?.directories.find(t=>t.id===e)??t?.directories[0];!n||!t?D(!0):($e.current=N(),De(n.id),me(!0),ye(Pt(n.id)),v(``))}let[It,Lt]=(0,z.useState)(null);(0,z.useEffect)(()=>Lt(null),[$?.id]);let Rt=G?.catalogs.find(e=>e.provider===($?.provider??`codex`)&&($?.cwd?e.cwd===$.cwd:e.directory===($?.executionDirectory??$?.directory))),zt=Rt?.commands??[],Bt=Rt?.models??G?.providers.find(e=>e.id===$?.provider)?.models??($?.provider===`codex`?G?.models??[]:[]),Vt=Bt.find(e=>e.id===($?.config.model??$?.effectiveConfig?.model)||!!e.resolvedModel&&e.resolvedModel===($?.config.model??$?.effectiveConfig?.model))??($?.config.model?void 0:Bt.find(e=>e.isDefault)),Ht=!!G?.capabilities.includes(`local-agent-attachments-v1`),Ut=!!(Vt?.images??(!$?.config.model&&G?.providers.find(e=>e.id===$?.provider)?.defaultImages))&&!!G?.capabilities.includes(`local-agent-images-v1`),Wt=$?.state===`working`&&!Q?.commands.some(e=>e.kind===`stop`&&[`queued`,`running`].includes(e.state)),Gt=($?.provider===`cursor`||le($?.provider))&&G?.capabilities.includes(`local-agent-steer-v1`),Kt=!G?.capabilities.includes(`local-agent-steer-v1`)&&($?.provider===`cursor`||$?.provider===`claude`);function qt(e){let t=ne.trim();if(!$||!t&&!X.files.length)return;let n=X.files.map(e=>e.id),r=Ut?X.files.filter(e=>e.mimeType!==`application/octet-stream`).map(e=>e.id):[],i=It?.path&&t.startsWith(`$${It.name}`)?[{name:It.name,path:It.path}]:void 0,a=JSON.stringify({session:$.id,body:t,skills:i,attachments:n,images:r,delivery:e});Ze.current?.fingerprint!==a&&(Ze.current={fingerprint:a,id:N()});let o=Ze.current;jt(async()=>{await Y(`web/local-agent-sessions/${$.id}/messages`,ee(),{method:`POST`,body:{id:o.id,body:t,delivery:e,...r.length?{images:r}:{},...n.length?{attachments:n}:{},...i?{skills:i}:{}}}),L(e=>e.trim()===t?``:e),Lt(null),X.clear(),Ze.current===o&&(Ze.current=void 0)})}let Jt=(0,z.useMemo)(()=>(0,B.jsx)(pt,{onFile:Ot,messages:$?Q.messages:[],rewind:$?{session:$.id,available:!!Q?.canRewind&&$.state===`idle`&&!$.archived,expectedLastMessage:Q?.messages.at(-1)?.id??``,commands:Q?.commands??[],request:Y,refresh:Z.reload}:void 0,imageUrl:(e,t)=>tt(g.project,$.id,e,t),renderQueue:e=>(0,B.jsx)(ot,{message:e}),renderQuestion:e=>(0,B.jsx)(gt,{question:e,session:$.id,request:Y,refresh:Z.reload})}),[$,Q,Y,Z.reload,g.project,Ot]);return(0,B.jsxs)(Ne,{className:`computers-layout`,testId:`computers-page`,label:T(`web.Computers.18`),tree:!0,navigation:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(re,{title:T(`web.Computers.19`)}),(0,B.jsx)(`div`,{className:`assistant-message-scroll computer-tree`,role:`tree`,"aria-label":T(`web.Computers.20`),onKeyDown:Re,children:nt.map(({c:e,d:t,label:n})=>{let r=`${e.project}/${t.id}`,i=!d.has(r);return(0,B.jsxs)(`div`,{role:`none`,children:[(0,B.jsxs)(`div`,{className:`computer-tree-row`,role:`none`,children:[(0,B.jsxs)(se,{className:`tree-item tree-folder`,role:`treeitem`,"aria-level":1,"aria-expanded":i,style:{"--tree-level":1},leading:(0,B.jsx)(`span`,{className:`tree-chevron ${i?`expanded`:``}`,children:(0,B.jsx)(O,{name:`chevron`,size:`small`})}),onClick:()=>{g.directory!==t.id&&At(e.project,t.id,t.defaultSession??e.sessions.find(e=>e.directory===t.id)?.id),f(e=>{let t=new Set(e);return i?t.add(r):t.delete(r),t})},children:[(0,B.jsx)(O,{name:`files`}),(0,B.jsx)(`span`,{className:`tree-name`,title:n,children:n})]}),(0,B.jsx)(M,{icon:`plus`,label:T(`web.Computers.21`,{p0:n}),className:`computer-tree-action`,onClick:()=>Ft(t.id)})]}),i&&(0,B.jsxs)(`div`,{role:`group`,children:[it.terminals.filter(e=>e.directory===t.id).map(n=>(0,B.jsx)(`div`,{className:`computer-tree-row computer-session-row computer-terminal-row`,role:`none`,children:(0,B.jsxs)(se,{className:`tree-item`,role:`treeitem`,"aria-level":2,"aria-selected":g.terminal===n.id,style:{"--tree-level":2},leading:(0,B.jsx)(`span`,{className:`tree-chevron`}),onClick:()=>At(e.project,t.id,``,n.id),children:[(0,B.jsx)(O,{name:`command`}),(0,B.jsxs)(`span`,{className:`computer-session-copy`,children:[(0,B.jsx)(`span`,{className:`tree-name`,children:n.title}),(0,B.jsx)(`time`,{dateTime:n.createdAt,children:n.state===`exited`?T(`web.Computers.22`):Ke(n.createdAt,Fe)})]})]})},n.id)),e.sessions.filter(e=>e.directory===t.id).map(n=>(0,B.jsxs)(`div`,{className:`computer-tree-row computer-session-row`,role:`none`,children:[(0,B.jsxs)(se,{className:`tree-item`,role:`treeitem`,"aria-level":2,"aria-selected":g.session===n.id&&g.project===e.project,style:{"--tree-level":2},leading:(0,B.jsx)(`span`,{className:`tree-chevron`,children:(0,B.jsx)(`span`,{className:`assistant-message-dot ${n.unread?`unread`:``}`})}),title:`${n.title} · ${ie[n.provider]}`,onClick:()=>At(e.project,t.id,n.id),children:[(0,B.jsx)(Te,{provider:n.provider}),(0,B.jsxs)(`span`,{className:`computer-session-copy`,children:[(0,B.jsx)(`span`,{className:`tree-name`,children:n.title}),(0,B.jsx)(`time`,{dateTime:n.updatedAt,title:new Date(n.updatedAt).toLocaleString(A()),children:Ke(n.updatedAt,Fe)})]})]}),(0,B.jsx)(M,{icon:`link`,className:`computer-tree-action computer-session-pin${n.pinned?` pinned`:``}`,label:T(`common.withDetail`,{label:n.pinned?T(`web.Computers.23`):T(`web.Computers.24`),detail:n.title}),"aria-pressed":n.pinned,tooltip:n.pinned?T(`web.Computers.23`):T(`web.Computers.24`),disabled:b||n.archived,onClick:()=>void Mt(n,{pinned:!n.pinned})}),n.archived?(0,B.jsx)(`span`,{title:T(`web.Computers.25`),role:`img`,"aria-label":T(`web.Computers.25`),children:(0,B.jsx)(O,{name:`archive`,size:`small`})}):n.state!==`idle`&&(0,B.jsx)(je,{state:n.state,label:Et[n.state]??n.state})]},n.id))]})]},t.id)})}),(0,B.jsx)(r,{resource:W})]}),children:[E&&(0,B.jsx)(Se,{onClose:()=>D(!1)}),be&&q&&J&&(0,B.jsx)(Je,{directory:J.id,provider:R===`terminal`?J.provider:R,providers:q.providers.filter(e=>!le(e.id)||e.available).map(e=>e.id),sessions:q.sessions,request:Y,onClose:()=>Ce(!1),onImport:e=>{At(g.project,e.directory,e.id),W.reload()}}),ue&&J&&(0,B.jsx)(k,{id:`computer-new-session`,title:T(`web.Computers.26`),onClose:()=>me(!1),children:(0,B.jsxs)(`form`,{className:`computer-panel stack`,onSubmit:e=>{e.preventDefault(),jt(async()=>{if(R===`terminal`){let e=$e.current;await it.request({type:`create`,id:e,directory:J.id,title:ae.trim(),cols:100,rows:28}),$e.current=N(),oe(``),At(g.project,J.id,``,e);return}let e=await Y(`web/local-agents/${J.id}/sessions`,ce,{method:`POST`,body:{id:$e.current,title:ae,provider:R}});$e.current=N(),me(!1),oe(``),At(g.project,J.id,e.id)})},children:[nt.length>1?(0,B.jsx)(ve,{title:T(`web.Computers.27`),children:(0,B.jsx)(`select`,{"aria-label":T(`web.Computers.27`),disabled:b,value:J.id,onChange:e=>{De(e.target.value),ye(Pt(e.target.value))},children:nt.map(({d:e,label:t})=>(0,B.jsx)(`option`,{value:e.id,children:t},e.id))})}):(0,B.jsxs)(`p`,{className:`muted computer-create-scope`,children:[T(`web.Computers.28`),J.name]}),(0,B.jsxs)(`label`,{children:[T(`web.Computers.29`),(0,B.jsx)(`input`,{autoFocus:!0,required:!0,disabled:b,placeholder:T(`web.Computers.29`),value:ae,onChange:e=>oe(e.target.value)})]}),(0,B.jsx)(ge,{label:T(`web.Computers.30`),value:R,onChange:ye,disabled:b,providers:_e.options.filter(e=>e===`codex`||(e===`claude`?q?.capabilities.includes(`local-agent-providers-v1`):q?.providers.some(t=>t.id===e&&(!le(e)||t.available)))),terminal:it.directories.includes(J.id)}),R===`terminal`&&(0,B.jsx)(`p`,{className:`muted computer-create-scope`,children:T(`web.Computers.31`)}),(0,B.jsx)(n,{children:q?.providers.find(e=>e.id===R)?.error}),(0,B.jsxs)(`div`,{className:`computer-create-options`,children:[R!==`terminal`&&(0,B.jsx)(`button`,{type:`button`,disabled:!q?.online||!q.capabilities.includes(`local-agent-history-v1`),onClick:()=>{me(!1),Ce(!0)},children:T(`web.Computers.32`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{me(!1),D(!0)},children:T(`web.Computers.33`)}),(0,B.jsx)(`button`,{className:`primary`,disabled:b||!ae.trim()||(R===`terminal`?!it.directories.includes(J.id):!kt),children:T(`web.Computers.34`)})]})]})}),Oe&&(0,B.jsx)(Qe,{file:Oe,onClose:()=>ke(void 0)},Oe.url),g.terminal?K?(0,B.jsx)(z.Suspense,{fallback:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(I,{title:K.title}),(0,B.jsx)(`div`,{className:`assistant-empty`,children:T(`web.Computers.35`)})]}),children:(0,B.jsx)(Tt,{terminal:K,onFile:Ot,connection:it,onClosed:()=>At(g.project,g.directory)},K.id)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(I,{title:T(`web.Computers.36`)}),(0,B.jsx)(`div`,{className:`assistant-empty`,children:it.connected?T(`web.Computers.37`):T(`web.Computers.38`)})]}):lt?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(I,{title:$?(0,B.jsx)(ze,{title:$.title,busy:b,onSave:e=>Mt($,{title:e})},$.id):(0,B.jsx)(`h2`,{children:lt.name}),actions:(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(w,{align:`end`,id:`computer-session-menu`,triggerId:`computer-session-actions`,label:T(`web.Computers.39`),trigger:(0,B.jsx)(O,{name:`more`}),className:`computer-create-menu`,routeKey:$?.id??``,disabled:!$,children:e=>(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{role:`menuitem`,onClick:()=>{e(),Pe(!0)},children:T(`session.commands.history`)}),(0,B.jsx)(`button`,{role:`menuitem`,disabled:b,onClick:()=>{e(),$&&Mt($,{hidden:!0})},children:T(`web.Computers.40`)}),(0,B.jsx)(`button`,{role:`menuitem`,onClick:()=>{e(),Nt(lt.id)},children:T(`web.Computers.41`)}),(0,B.jsx)(`button`,{role:`menuitem`,onClick:()=>{e(),Nt(lt.id)},children:T(`web.Computers.42`)})]})})})}),!kt&&(0,B.jsx)(C,{children:T(`web.Computers.43`)}),(0,B.jsxs)(Me,{ref:V,onClickCapture:({target:e,currentTarget:t})=>{e instanceof Element&&e.closest(`.tool-summary`)&&(H.current=!1,requestAnimationFrame(()=>{t===V.current&&t.contains(e)&&ut(t)}))},onWheel:e=>{e.deltaY<0&&e.currentTarget.scrollTop<=0&&Q?.olderBefore&&(H.current=!1,Z.older())},onScroll:e=>{let t=e.currentTarget;!ut(t)&&t.scrollTop<100&&Q?.olderBefore&&Z.older()},"aria-label":T(`web.Computers.44`),children:[Q?.olderBefore&&(0,B.jsx)(`button`,{type:`button`,className:`computer-older`,disabled:Z.loadingOlder,onClick:()=>{H.current=!1,Z.older()},children:Z.loadingOlder?T(`web.labels.9`):T(`web.Computers.45`)}),(0,B.jsx)(r,{resource:Z}),Jt,(0,B.jsx)(n,{children:$?.error}),Q&&!Q.messages.length&&!Q.olderBefore&&(0,B.jsx)(`div`,{className:`assistant-empty`,children:$?.resumeSession?T(`web.Computers.46`):T(`web.Computers.47`)})]}),$&&Q&&(0,B.jsx)(bt,{cacheKey:h(g.project,i,$.id,`command-feedback`),commands:Q.commands},h(g.project,$.id)),Ae&&$&&Q&&(0,B.jsx)(xt,{commands:Q.commands,onClose:()=>Pe(!1)}),vt.length>0&&(0,B.jsx)(`div`,{className:`computer-question-shortcut`,children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{let e=(vt.findIndex(e=>e.id===Xe.current)+1)%vt.length,t=vt[e];yt(t.id)||(H.current=!1,qe.current=t.id,Z.reveal(t.seq))},children:[(0,B.jsx)(O,{name:`question`,size:`small`}),T(`session.pendingQuestions`,{count:vt.length})]})}),$&&(0,B.jsx)(Ie,{value:ne,onChange:L,label:T(`web.Computers.51`),sendLabel:T(Wt?Gt?`web.Computers.52`:Kt?`web.Computers.53`:`web.Computers.54`:`web.Computers.55`),onQueue:[`working`,`waiting`].includes($.state)&&G?.capabilities.includes(`local-agent-queue-v1`)?()=>qt(`queue`):void 0,placeholder:$.archived?T(`web.Computers.56`):T(`web.Computers.57`),disabled:$.archived||!kt,sendDisabled:b||X.busy||X.failed||X.count>0&&!Ht||Q?.commands.some(e=>e.kind===`rewind`&&[`queued`,`running`,`uncertain`].includes(e.state)),attachments:(0,B.jsxs)(B.Fragment,{children:[X.preview(b),X.files.some(e=>e.mimeType!==`application/octet-stream`)&&!Ut&&(0,B.jsx)(C,{children:T(`web.Computers.58`)})]}),hasAttachments:X.count>0,onFiles:Ht&&!b?e=>void X.add(e):void 0,beforeSend:(0,B.jsx)(_t,{session:$.id,active:[`working`,`waiting`].includes($.state),commands:Q?.commands??[],request:Y,refresh:Z.reload,onError:v},$.id),actions:(0,B.jsxs)(B.Fragment,{children:[Ht?X.picker(b||!kt,Ut):Ut?(0,B.jsx)(`span`,{title:T(`web.Computers.59`),children:(0,B.jsx)(`button`,{type:`button`,className:`icon-button`,disabled:!0,"aria-label":T(`web.Computers.59`),children:(0,B.jsx)(O,{name:`attachment`,size:`small`})})}):null,(0,B.jsx)(wt,{session:$,models:Bt,busy:b,available:!!kt,online:!!G?.online,commands:zt,controls:Rt?.controls,draft:ne,onInsert:e=>{Lt(e.kind===`skill`?e:null),L(`${e.prefix??(e.kind===`skill`?`$`:`/`)}${e.name} `),requestAnimationFrame(()=>document.querySelector(`.message-composer textarea`)?.focus())},onConfig:e=>{jt(()=>Y(`web/local-agent-sessions/${$.id}/settings`,ce,{method:`PUT`,body:{expectedRevision:$.revision,config:e}}))}})]}),onSubmit:()=>qt(`auto`)})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(I,{title:T(`web.Computers.18`)}),(0,B.jsxs)(`div`,{className:`assistant-empty`,children:[T(`web.Computers.60`),(0,B.jsx)(`button`,{onClick:()=>D(!0),children:T(`web.Computers.33`)})]})]})]})}export{Ot as Computers,ze as t};
|
|
14
|
+
`),onClick:()=>{e(),c(t)},children:(0,B.jsxs)(`span`,{className:`composer-command-row`,children:[(0,B.jsxs)(`span`,{className:`composer-command-name`,children:[t.prefix??(t.kind===`skill`?`$`:`/`),t.name]}),(0,B.jsx)(`small`,{children:t.description})]})},`${t.kind}:${t.path??t.name}`)),!a.length&&(0,B.jsx)(`div`,{className:`composer-menu-heading`,children:T(`web.LocalComposerControls.18`)})]})}),(0,B.jsx)(Ct,{id:`session-model`,label:T(`web.LocalComposerControls.14`),current:e.config.model??``,options:D,disabled:m,onSelect:n=>{let r=t.find(e=>e.id===n);l({...e.config,model:n||null,...g?{options:{}}:{},effort:e.config.effort&&r?.efforts.includes(e.config.effort)?e.config.effort:null})}}),(e.provider===`codex`||h||(p?.efforts.length??0)>0||!!e.config.effort)&&(0,B.jsx)(Ct,{id:`session-effort`,label:v,current:e.config.effort??``,options:j,disabled:m,onSelect:t=>l({...e.config,effort:t||null})}),p?.options?.map(t=>(0,B.jsx)(Ct,{id:`session-option-${t.id}`,label:t.name,current:e.config.options?.[t.id]??``,options:[{value:``,label:T(`web.LocalComposerControls.11`,{p0:t.choices.find(e=>e.value===t.defaultValue)?.label??t.defaultValue})},...t.choices],disabled:m,onSelect:n=>{let r={...e.config.options};n?r[t.id]=n:delete r[t.id],l({...e.config,options:r})}},t.id)),_.map(t=>(0,B.jsx)(Ct,{id:t.key===`mode`&&!h?`session-mode`:`session-permission`,label:t.label,current:t.key===`mode`?x??e.config.mode??t.defaultValue:e.config.permission,options:t.choices,disabled:m,onSelect:n=>l(t.key===`mode`?{...e.config,mode:n||void 0}:{...e.config,permission:n})},t.key))]})}var Tt=(0,z.lazy)(()=>Ce(()=>import(`./TerminalPane-jJa53g04.js`),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)),Et={get idle(){return T(`web.Computers.1`)},get working(){return T(`web.Computers.2`)},get waiting(){return T(`web.Computers.3`)},get queued(){return T(`web.Computers.4`)},get uncertain(){return T(`web.Computers.5`)},get human(){return T(`web.Computers.6`)},get offered(){return T(`web.Computers.7`)},get accepted(){return T(`web.Computers.8`)},get human_routed(){return T(`web.Computers.9`)},get pending(){return T(`web.Computers.10`)},get sent(){return T(`web.Computers.11`)},get succeeded(){return T(`web.Computers.12`)},get running(){return T(`web.Computers.13`)},get failed(){return T(`web.Computers.14`)}};function Dt(e){return{width:e.clientWidth,height:e.clientHeight,top:e.scrollHeight-e.clientHeight}}function Ot({navigate:e,memberId:t}){y();let{request:n,projectId:i}=we(),a=(0,z.useCallback)(e=>n(`web/local-agent-settings`,be,{signal:e}),[n]),o=p(a,3e4);return(0,z.useEffect)(()=>{let e=()=>void o.reload();return window.addEventListener(`teammy:local-access`,e),()=>window.removeEventListener(`teammy:local-access`,e)},[o.reload]),!o.data&&o.error?(0,B.jsx)(r,{resource:o}):o.data?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(_,{message:o.error}),(0,B.jsx)(kt,{localAvailable:o.data.accessible,navigate:e,memberId:t},`${i}/${t}`)]}):null}function kt({localAvailable:e,navigate:t,memberId:i}){y();let o=we(),s=a(),c=h(o.projectId,i,`computer-selection`),l=h(o.projectId,i,`computer-drafts`),u=s?.get(c),[d,f]=(0,z.useState)(()=>new Set),[g,_]=(0,z.useState)(()=>({project:o.projectId,directory:new URLSearchParams(location.search).get(`directory`)??u?.directory??``,session:new URLSearchParams(location.search).get(`session`)??(new URLSearchParams(location.search).has(`terminal`)?``:u?.session??``),terminal:new URLSearchParams(location.search).get(`terminal`)??(new URLSearchParams(location.search).has(`session`)?``:u?.terminal??``)})),v=m(),[b,S]=(0,z.useState)(!1),[E,D]=(0,z.useState)(!1),[j,P]=(0,z.useState)(()=>s?.get(l)??{}),ne=j[g.session]??``,L=e=>P(t=>({...t,[g.session]:typeof e==`function`?e(t[g.session]??``):e}));(0,z.useEffect)(()=>{s?.set(l,j)},[s,l,j]);let[ae,oe]=(0,z.useState)(``),[ue,me]=(0,z.useState)(!1),[R,ye]=(0,z.useState)(`codex`),[be,Ce]=(0,z.useState)(!1),[Ee,De]=(0,z.useState)(``),[Oe,ke]=(0,z.useState)(),[Ae,Pe]=(0,z.useState)(!1),[Fe,Le]=(0,z.useState)(Date.now);(0,z.useEffect)(()=>{let e=setInterval(()=>Le(Date.now()),6e4);return()=>clearInterval(e)},[]);let V=(0,z.useRef)(null),H=(0,z.useRef)(!0),Be=(0,z.useRef)(null),Ve=(0,z.useCallback)(e=>{let t=Dt(e),n=Be.current,r=n&&(t.width!==n.width||t.height!==n.height||t.top!==n.top);return(H.current&&r?Math.min(n.top,t.top):t.top)-e.scrollTop<96},[]),Ue=(0,z.useCallback)(e=>{e.scrollTop=e.scrollHeight,Be.current=Dt(e)},[]),We=(0,z.useRef)(null),Ge=(0,z.useCallback)(e=>{let t=V.current;if(!t)return!0;if(Ve(t)||(H.current=!1),!e||H.current)return H.current;let n=t.getBoundingClientRect().top,r=Array.from(t.querySelectorAll(`.computer-messages > :not(.computer-tool-group), .computer-tool-group > .tool-summary, .computer-tool-group .computer-tool`)).find(e=>{let t=e.getBoundingClientRect();return t.height>0&&t.bottom>n});return We.current={...r?{node:r}:{},offset:r?.getBoundingClientRect().top??0,top:t.scrollTop,height:t.scrollHeight},!1},[Ve]),qe=(0,z.useRef)(new URLSearchParams(location.search).get(`question`)),U=(0,z.useRef)(Number(new URLSearchParams(location.search).get(`message`))||null),Xe=(0,z.useRef)(null),Ze=(0,z.useRef)(void 0),$e=(0,z.useRef)(N()),et=(0,z.useCallback)(async t=>e?(await o.request(`web/local-agent-computers`,de,{signal:t})).computers.map(e=>({...e,project:o.projectId})):[],[o,e]),W=p(et,3e3),nt=(W.data??[]).flatMap(e=>e.directories.map(t=>({c:e,d:t,label:pe(W.data??[],e,t)}))).sort((e,t)=>e.label.localeCompare(t.label)),G=W.data?.find(e=>e.project===g.project&&e.directories.some(e=>e.id===g.directory)),it=He(o.projectId,e),at=it.terminals.find(e=>e.id===g.terminal),ct=(0,z.useRef)(at);at&&(ct.current=at);let K=at??(ct.current?.id===g.terminal?ct.current:void 0),lt=G?.directories.find(e=>e.id===g.directory),q=W.data?.find(e=>e.directories.some(e=>e.id===Ee))??G,J=q?.directories.find(e=>e.id===Ee)??lt;fe(g.project);let Y=(0,z.useCallback)((e,t,n)=>fe(g.project).request(e,t,n),[g.project]),X=rt(g.session,g.project,Y),Z=st(g.project,e?g.session:``,Y,Ge);function ut(e){let t=Ve(e);return t&&!H.current&&(Be.current=Dt(e)),H.current=t,Z.follow(t),t}let Q=Z.data;(0,z.useLayoutEffect)(()=>{Pe(!1),H.current=!0,Be.current=null,Xe.current=null,We.current=null},[g.project,g.session]);let $=Q?.session;he(g.project,$?.id??``);let dt=Z.attention,ft=dt?.title??$?.title,mt=dt?.question?{question:T(`web.Computers.15`),approval:T(`web.Computers.16`),plan:T(`web.Memory.7`)}[dt.question]:dt?.completion?T(`web.Computers.17`):``;xe(g.session&&ft?`${mt?`[${mt}] `:``}${ft}`:void 0);let vt=Q?.pendingQuestions??Q?.messages.flatMap(({question:e,seq:t})=>e?.delivery===`async`&&te(e)?[{id:e.id,seq:t}]:[])??[];function yt(e){let t=V.current,n=document.getElementById(`computer-question-${e}`);return!t||!n||!t.contains(n)||!n.getClientRects().length?!1:(H.current=!1,Xe.current=e,t.scrollTop+=n.getBoundingClientRect().top-t.getBoundingClientRect().top-16,n.focus({preventScroll:!0}),!0)}function St(e){let t=V.current,n=t?.querySelector(`[data-message-seq="${e}"], [data-completion-seq="${e}"]`);return!t||!n||!n.getClientRects().length?!1:(H.current=!1,t.scrollTop+=n.getBoundingClientRect().top-t.getBoundingClientRect().top-16,!0)}(0,z.useEffect)(()=>{let e=e=>{let t=e.detail;if(t.project!==g.project||t.session!==g.session)return;let n=new URL(location.href);n.searchParams.delete(`question`),n.searchParams.delete(`message`),qe.current=t.question??null,U.current=t.question?null:t.sequence,n.searchParams.set(`directory`,g.directory),n.searchParams.set(`session`,g.session),n.searchParams.set(t.question?`question`:`message`,t.question??String(t.sequence)),history.replaceState(null,``,n),(t.question?yt(t.question):St(t.sequence))?(qe.current=null,U.current=null):Z.reveal(t.sequence)};return window.addEventListener(`teammy:notification-open`,e),()=>window.removeEventListener(`teammy:notification-open`,e)},[g.project,g.session,g.directory,Z.reveal]),(0,z.useLayoutEffect)(()=>{if(!$||!V.current)return;let e=V.current;if(qe.current){let e=qe.current;if(yt(e)){qe.current=null,We.current=null;return}}if(U.current&&St(U.current)){U.current=null,We.current=null;return}let t=We.current;We.current=null,t&&!H.current?t.node&&e.contains(t.node)?e.scrollTop+=t.node.getBoundingClientRect().top-t.offset:e.scrollTop=t.top+e.scrollHeight-t.height:H.current&&Ue(e)},[$?.id,lt?.id,Q,Ue]),(0,z.useLayoutEffect)(()=>{let e=V.current;if(!e||!$)return;let t=new ResizeObserver(()=>{H.current&&Ve(e)&&Ue(e)});t.observe(e);let n=e.querySelector(`.computer-messages`);return n&&t.observe(n),()=>t.disconnect()},[$?.id,lt?.id,Ve,Ue]),(0,z.useEffect)(()=>{G?.online===!1&&Z.reload()},[G?.online,Z.reload]);let Ct=(0,z.useRef)(Q?.messages);(0,z.useLayoutEffect)(()=>{Ct.current=Q?.messages},[Q?.messages]);let Ot=(0,z.useCallback)(({path:e,line:t})=>{let n=F(e,g.terminal?K?.cwd:$?.cwd);if(!n)return;let r=n.split(`/`).at(-1),i=/\/\.workspace\/\.teammy-attachments\/([0-9a-f-]{36})\/[^/]+$/i.exec(n);if(!g.terminal&&$&&i){let e=Ct.current?.flatMap(e=>e.attachments??[]).find(e=>e.id===i[1]);ke({...e,name:e?.name??r,line:t,url:tt(g.project,$.id,i[1],!0)});return}let a=g.terminal?K?.directory:$?.executionDirectory??$?.directory;if(!a)return;let o=x(`/api/v1/projects/${encodeURIComponent(g.project)}/web/local-agents/${encodeURIComponent(a)}/file?${new URLSearchParams({path:n})}`),s=Ye(r);ke({name:r,line:t,url:o,previewUrl:o+(s.startsWith(`text/`)?`&view=text`:s?``:`&view=info`)})},[g.project,g.terminal,$?.directory,$?.executionDirectory,$?.id,$?.cwd,K?.directory,K?.cwd]),kt=G?.capabilities.includes(`local-sessions-v1`),At=(e,t,n=``,r=``)=>{ke(void 0),_({project:e,directory:t,session:n,terminal:r}),s?.set(c,{directory:t,session:n,terminal:r}),me(!1),Ce(!1),v(``);let i=new URL(location.href);(g.session!==n||r)&&(i.searchParams.delete(`question`),i.searchParams.delete(`message`),qe.current=null,U.current=null),i.searchParams.delete(`view`),i.searchParams.delete(`section`),i.searchParams.set(`directory`,t),r?i.searchParams.set(`terminal`,r):i.searchParams.delete(`terminal`),n?i.searchParams.set(`session`,n):i.searchParams.delete(`session`),e===o.projectId&&history.replaceState(null,``,i)};(0,z.useEffect)(()=>{let e=W.data?.find(e=>e.sessions.some(e=>e.id===g.session))??W.data?.find(e=>e.directories.length);if(!g.directory&&e?.directories.length){let t=e.directories[0],n=e.sessions.find(e=>e.id===g.session);At(e.project,n?.directory??t.id,n?.id??t.defaultSession??e.sessions.find(e=>e.directory===t.id)?.id)}},[W.data]),(0,z.useEffect)(()=>{if($&&V.current)return ht([...V.current.querySelectorAll(`[data-completion-seq]`)],e=>void Z.markRead(Number(e.getAttribute(`data-completion-seq`))))},[$?.id,Q?.messages,Z.markRead]);async function jt(e){S(!0),v(``);try{await e(),await Promise.all([Z.reload(),W.reload()])}catch(e){v(e)}finally{S(!1)}}function Mt(e,t){return jt(async()=>{if(await o.request(`web/local-agent-sessions/${e.id}/metadata`,ce,{method:`PUT`,body:{expectedRevision:e.metadataRevision,...t}}),t.hidden&&g.session===e.id){let t=G?.sessions.find(t=>t.directory===e.directory&&t.id!==e.id&&!t.hidden);At(g.project,e.directory,t?.id)}})}function Nt(e){let n=new URLSearchParams({tab:`connect`,directory:e,session:g.session});t(`/projects/${o.projectId}/settings?${n}`)}function Pt(e){let t=nt.find(({d:t})=>t.id===e),n=t?.d.provider??`codex`;return le(n)&&!t?.c.providers.some(e=>e.id===n&&e.available)?`codex`:n}function Ft(e=g.directory){let t=W.data?.find(t=>t.directories.some(t=>t.id===e))??G,n=t?.directories.find(t=>t.id===e)??t?.directories[0];!n||!t?D(!0):($e.current=N(),De(n.id),me(!0),ye(Pt(n.id)),v(``))}let[It,Lt]=(0,z.useState)(null);(0,z.useEffect)(()=>Lt(null),[$?.id]);let Rt=G?.catalogs.find(e=>e.provider===($?.provider??`codex`)&&($?.cwd?e.cwd===$.cwd:e.directory===($?.executionDirectory??$?.directory))),zt=Rt?.commands??[],Bt=Rt?.models??G?.providers.find(e=>e.id===$?.provider)?.models??($?.provider===`codex`?G?.models??[]:[]),Vt=Bt.find(e=>e.id===($?.config.model??$?.effectiveConfig?.model)||!!e.resolvedModel&&e.resolvedModel===($?.config.model??$?.effectiveConfig?.model))??($?.config.model?void 0:Bt.find(e=>e.isDefault)),Ht=!!G?.capabilities.includes(`local-agent-attachments-v1`),Ut=!!(Vt?.images??(!$?.config.model&&G?.providers.find(e=>e.id===$?.provider)?.defaultImages))&&!!G?.capabilities.includes(`local-agent-images-v1`),Wt=$?.state===`working`&&!Q?.commands.some(e=>e.kind===`stop`&&[`queued`,`running`].includes(e.state)),Gt=($?.provider===`cursor`||le($?.provider))&&G?.capabilities.includes(`local-agent-steer-v1`),Kt=!G?.capabilities.includes(`local-agent-steer-v1`)&&($?.provider===`cursor`||$?.provider===`claude`);function qt(e){let t=ne.trim();if(!$||!t&&!X.files.length)return;let n=X.files.map(e=>e.id),r=Ut?X.files.filter(e=>e.mimeType!==`application/octet-stream`).map(e=>e.id):[],i=It?.path&&t.startsWith(`$${It.name}`)?[{name:It.name,path:It.path}]:void 0,a=JSON.stringify({session:$.id,body:t,skills:i,attachments:n,images:r,delivery:e});Ze.current?.fingerprint!==a&&(Ze.current={fingerprint:a,id:N()});let o=Ze.current;jt(async()=>{await Y(`web/local-agent-sessions/${$.id}/messages`,ee(),{method:`POST`,body:{id:o.id,body:t,delivery:e,...r.length?{images:r}:{},...n.length?{attachments:n}:{},...i?{skills:i}:{}}}),L(e=>e.trim()===t?``:e),Lt(null),X.clear(),Ze.current===o&&(Ze.current=void 0)})}let Jt=(0,z.useMemo)(()=>(0,B.jsx)(pt,{onFile:Ot,messages:$?Q.messages:[],rewind:$?{session:$.id,available:!!Q?.canRewind&&$.state===`idle`&&!$.archived,expectedLastMessage:Q?.messages.at(-1)?.id??``,commands:Q?.commands??[],request:Y,refresh:Z.reload}:void 0,imageUrl:(e,t)=>tt(g.project,$.id,e,t),renderQueue:e=>(0,B.jsx)(ot,{message:e}),renderQuestion:e=>(0,B.jsx)(gt,{question:e,session:$.id,request:Y,refresh:Z.reload})}),[$,Q,Y,Z.reload,g.project,Ot]);return(0,B.jsxs)(Ne,{className:`computers-layout`,testId:`computers-page`,label:T(`web.Computers.18`),tree:!0,navigation:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(re,{title:T(`web.Computers.19`)}),(0,B.jsx)(`div`,{className:`assistant-message-scroll computer-tree`,role:`tree`,"aria-label":T(`web.Computers.20`),onKeyDown:Re,children:nt.map(({c:e,d:t,label:n})=>{let r=`${e.project}/${t.id}`,i=!d.has(r);return(0,B.jsxs)(`div`,{role:`none`,children:[(0,B.jsxs)(`div`,{className:`computer-tree-row`,role:`none`,children:[(0,B.jsxs)(se,{className:`tree-item tree-folder`,role:`treeitem`,"aria-level":1,"aria-expanded":i,style:{"--tree-level":1},leading:(0,B.jsx)(`span`,{className:`tree-chevron ${i?`expanded`:``}`,children:(0,B.jsx)(O,{name:`chevron`,size:`small`})}),onClick:()=>{g.directory!==t.id&&At(e.project,t.id,t.defaultSession??e.sessions.find(e=>e.directory===t.id)?.id),f(e=>{let t=new Set(e);return i?t.add(r):t.delete(r),t})},children:[(0,B.jsx)(O,{name:`files`}),(0,B.jsx)(`span`,{className:`tree-name`,title:n,children:n})]}),(0,B.jsx)(M,{icon:`plus`,label:T(`web.Computers.21`,{p0:n}),className:`computer-tree-action`,onClick:()=>Ft(t.id)})]}),i&&(0,B.jsxs)(`div`,{role:`group`,children:[it.terminals.filter(e=>e.directory===t.id).map(n=>(0,B.jsx)(`div`,{className:`computer-tree-row computer-session-row computer-terminal-row`,role:`none`,children:(0,B.jsxs)(se,{className:`tree-item`,role:`treeitem`,"aria-level":2,"aria-selected":g.terminal===n.id,style:{"--tree-level":2},leading:(0,B.jsx)(`span`,{className:`tree-chevron`}),onClick:()=>At(e.project,t.id,``,n.id),children:[(0,B.jsx)(O,{name:`command`}),(0,B.jsxs)(`span`,{className:`computer-session-copy`,children:[(0,B.jsx)(`span`,{className:`tree-name`,children:n.title}),(0,B.jsx)(`time`,{dateTime:n.createdAt,children:n.state===`exited`?T(`web.Computers.22`):Ke(n.createdAt,Fe)})]})]})},n.id)),e.sessions.filter(e=>e.directory===t.id).map(n=>(0,B.jsxs)(`div`,{className:`computer-tree-row computer-session-row`,role:`none`,children:[(0,B.jsxs)(se,{className:`tree-item`,role:`treeitem`,"aria-level":2,"aria-selected":g.session===n.id&&g.project===e.project,style:{"--tree-level":2},leading:(0,B.jsx)(`span`,{className:`tree-chevron`,children:(0,B.jsx)(`span`,{className:`assistant-message-dot ${n.unread?`unread`:``}`})}),title:`${n.title} · ${ie[n.provider]}`,onClick:()=>At(e.project,t.id,n.id),children:[(0,B.jsx)(Te,{provider:n.provider}),(0,B.jsxs)(`span`,{className:`computer-session-copy`,children:[(0,B.jsx)(`span`,{className:`tree-name`,children:n.title}),(0,B.jsx)(`time`,{dateTime:n.updatedAt,title:new Date(n.updatedAt).toLocaleString(A()),children:Ke(n.updatedAt,Fe)})]})]}),(0,B.jsx)(M,{icon:`link`,className:`computer-tree-action computer-session-pin${n.pinned?` pinned`:``}`,label:T(`common.withDetail`,{label:n.pinned?T(`web.Computers.23`):T(`web.Computers.24`),detail:n.title}),"aria-pressed":n.pinned,tooltip:n.pinned?T(`web.Computers.23`):T(`web.Computers.24`),disabled:b||n.archived,onClick:()=>void Mt(n,{pinned:!n.pinned})}),n.archived?(0,B.jsx)(`span`,{title:T(`web.Computers.25`),role:`img`,"aria-label":T(`web.Computers.25`),children:(0,B.jsx)(O,{name:`archive`,size:`small`})}):n.state!==`idle`&&(0,B.jsx)(je,{state:n.state,label:Et[n.state]??n.state})]},n.id))]})]},t.id)})}),(0,B.jsx)(r,{resource:W})]}),children:[E&&(0,B.jsx)(Se,{onClose:()=>D(!1)}),be&&q&&J&&(0,B.jsx)(Je,{directory:J.id,provider:R===`terminal`?J.provider:R,providers:q.providers.filter(e=>!le(e.id)||e.available).map(e=>e.id),sessions:q.sessions,request:Y,onClose:()=>Ce(!1),onImport:e=>{At(g.project,e.directory,e.id),W.reload()}}),ue&&J&&(0,B.jsx)(k,{id:`computer-new-session`,title:T(`web.Computers.26`),onClose:()=>me(!1),children:(0,B.jsxs)(`form`,{className:`computer-panel stack`,onSubmit:e=>{e.preventDefault(),jt(async()=>{if(R===`terminal`){let e=$e.current;await it.request({type:`create`,id:e,directory:J.id,title:ae.trim(),cols:100,rows:28}),$e.current=N(),oe(``),At(g.project,J.id,``,e);return}let e=await Y(`web/local-agents/${J.id}/sessions`,ce,{method:`POST`,body:{id:$e.current,title:ae,provider:R}});$e.current=N(),me(!1),oe(``),At(g.project,J.id,e.id)})},children:[nt.length>1?(0,B.jsx)(ve,{title:T(`web.Computers.27`),children:(0,B.jsx)(`select`,{"aria-label":T(`web.Computers.27`),disabled:b,value:J.id,onChange:e=>{De(e.target.value),ye(Pt(e.target.value))},children:nt.map(({d:e,label:t})=>(0,B.jsx)(`option`,{value:e.id,children:t},e.id))})}):(0,B.jsxs)(`p`,{className:`muted computer-create-scope`,children:[T(`web.Computers.28`),J.name]}),(0,B.jsxs)(`label`,{children:[T(`web.Computers.29`),(0,B.jsx)(`input`,{autoFocus:!0,required:!0,disabled:b,placeholder:T(`web.Computers.29`),value:ae,onChange:e=>oe(e.target.value)})]}),(0,B.jsx)(ge,{label:T(`web.Computers.30`),value:R,onChange:ye,disabled:b,providers:_e.options.filter(e=>e===`codex`||(e===`claude`?q?.capabilities.includes(`local-agent-providers-v1`):q?.providers.some(t=>t.id===e&&(!le(e)||t.available)))),terminal:it.directories.includes(J.id)}),R===`terminal`&&(0,B.jsx)(`p`,{className:`muted computer-create-scope`,children:T(`web.Computers.31`)}),(0,B.jsx)(n,{children:q?.providers.find(e=>e.id===R)?.error}),(0,B.jsxs)(`div`,{className:`computer-create-options`,children:[R!==`terminal`&&(0,B.jsx)(`button`,{type:`button`,disabled:!q?.online||!q.capabilities.includes(`local-agent-history-v1`),onClick:()=>{me(!1),Ce(!0)},children:T(`web.Computers.32`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{me(!1),D(!0)},children:T(`web.Computers.33`)}),(0,B.jsx)(`button`,{className:`primary`,disabled:b||!ae.trim()||(R===`terminal`?!it.directories.includes(J.id):!kt),children:T(`web.Computers.34`)})]})]})}),Oe&&(0,B.jsx)(Qe,{file:Oe,onClose:()=>ke(void 0)},Oe.url),g.terminal?K?(0,B.jsx)(z.Suspense,{fallback:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(I,{title:K.title}),(0,B.jsx)(`div`,{className:`assistant-empty`,children:T(`web.Computers.35`)})]}),children:(0,B.jsx)(Tt,{terminal:K,onFile:Ot,connection:it,onClosed:()=>At(g.project,g.directory)},K.id)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(I,{title:T(`web.Computers.36`)}),(0,B.jsx)(`div`,{className:`assistant-empty`,children:it.connected?T(`web.Computers.37`):T(`web.Computers.38`)})]}):lt?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(I,{title:$?(0,B.jsx)(ze,{title:$.title,busy:b,onSave:e=>Mt($,{title:e})},$.id):(0,B.jsx)(`h2`,{children:lt.name}),actions:(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(w,{align:`end`,id:`computer-session-menu`,triggerId:`computer-session-actions`,label:T(`web.Computers.39`),trigger:(0,B.jsx)(O,{name:`more`}),className:`computer-create-menu`,routeKey:$?.id??``,disabled:!$,children:e=>(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{role:`menuitem`,onClick:()=>{e(),Pe(!0)},children:T(`session.commands.history`)}),(0,B.jsx)(`button`,{role:`menuitem`,disabled:b,onClick:()=>{e(),$&&Mt($,{hidden:!0})},children:T(`web.Computers.40`)}),(0,B.jsx)(`button`,{role:`menuitem`,onClick:()=>{e(),Nt(lt.id)},children:T(`web.Computers.41`)}),(0,B.jsx)(`button`,{role:`menuitem`,onClick:()=>{e(),Nt(lt.id)},children:T(`web.Computers.42`)})]})})})}),!kt&&(0,B.jsx)(C,{children:T(`web.Computers.43`)}),(0,B.jsxs)(Me,{ref:V,onClickCapture:({target:e,currentTarget:t})=>{e instanceof Element&&e.closest(`.tool-summary`)&&(H.current=!1,requestAnimationFrame(()=>{t===V.current&&t.contains(e)&&ut(t)}))},onWheel:e=>{e.deltaY<0&&e.currentTarget.scrollTop<=0&&Q?.olderBefore&&(H.current=!1,Z.older())},onScroll:e=>{let t=e.currentTarget;!ut(t)&&t.scrollTop<100&&Q?.olderBefore&&Z.older()},"aria-label":T(`web.Computers.44`),children:[Q?.olderBefore&&(0,B.jsx)(`button`,{type:`button`,className:`computer-older`,disabled:Z.loadingOlder,onClick:()=>{H.current=!1,Z.older()},children:Z.loadingOlder?T(`web.labels.9`):T(`web.Computers.45`)}),(0,B.jsx)(r,{resource:Z}),Jt,(0,B.jsx)(n,{children:$?.error}),Q&&!Q.messages.length&&!Q.olderBefore&&(0,B.jsx)(`div`,{className:`assistant-empty`,children:$?.resumeSession?T(`web.Computers.46`):T(`web.Computers.47`)})]}),$&&Q&&(0,B.jsx)(bt,{cacheKey:h(g.project,i,$.id,`command-feedback`),commands:Q.commands},h(g.project,$.id)),Ae&&$&&Q&&(0,B.jsx)(xt,{commands:Q.commands,onClose:()=>Pe(!1)}),vt.length>0&&(0,B.jsx)(`div`,{className:`computer-question-shortcut`,children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{let e=(vt.findIndex(e=>e.id===Xe.current)+1)%vt.length,t=vt[e];yt(t.id)||(H.current=!1,qe.current=t.id,Z.reveal(t.seq))},children:[(0,B.jsx)(O,{name:`question`,size:`small`}),T(`session.pendingQuestions`,{count:vt.length})]})}),$&&(0,B.jsx)(Ie,{value:ne,onChange:L,label:T(`web.Computers.51`),sendLabel:T(Wt?Gt?`web.Computers.52`:Kt?`web.Computers.53`:`web.Computers.54`:`web.Computers.55`),onQueue:[`working`,`waiting`].includes($.state)&&G?.capabilities.includes(`local-agent-queue-v1`)?()=>qt(`queue`):void 0,placeholder:$.archived?T(`web.Computers.56`):T(`web.Computers.57`),disabled:$.archived||!kt,sendDisabled:b||X.busy||X.failed||X.count>0&&!Ht||Q?.commands.some(e=>e.kind===`rewind`&&[`queued`,`running`,`uncertain`].includes(e.state)),attachments:(0,B.jsxs)(B.Fragment,{children:[X.preview(b),X.files.some(e=>e.mimeType!==`application/octet-stream`)&&!Ut&&(0,B.jsx)(C,{children:T(`web.Computers.58`)})]}),hasAttachments:X.count>0,onFiles:Ht&&!b?e=>void X.add(e):void 0,beforeSend:(0,B.jsx)(_t,{session:$.id,active:[`working`,`waiting`].includes($.state),commands:Q?.commands??[],request:Y,refresh:Z.reload,onError:v},$.id),actions:(0,B.jsxs)(B.Fragment,{children:[Ht?X.picker(b||!kt,Ut):Ut?(0,B.jsx)(`span`,{title:T(`web.Computers.59`),children:(0,B.jsx)(`button`,{type:`button`,className:`icon-button`,disabled:!0,"aria-label":T(`web.Computers.59`),children:(0,B.jsx)(O,{name:`attachment`,size:`small`})})}):null,(0,B.jsx)(wt,{session:$,models:Bt,busy:b,available:!!kt,online:!!G?.online,commands:zt,controls:Rt?.controls,draft:ne,onInsert:e=>{Lt(e.kind===`skill`?e:null),L(`${e.prefix??(e.kind===`skill`?`$`:`/`)}${e.name} `),requestAnimationFrame(()=>document.querySelector(`.message-composer textarea`)?.focus())},onConfig:e=>{jt(()=>Y(`web/local-agent-sessions/${$.id}/settings`,ce,{method:`PUT`,body:{expectedRevision:$.revision,config:e}}))}})]}),onSubmit:()=>qt(`auto`)})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(I,{title:T(`web.Computers.18`)}),(0,B.jsxs)(`div`,{className:`assistant-empty`,children:[T(`web.Computers.60`),(0,B.jsx)(`button`,{onClick:()=>D(!0),children:T(`web.Computers.33`)})]})]})]})}export{Ot as Computers,ze as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as e,V as t,at as n,it as r}from"./project-links-
|
|
1
|
+
import{H as e,V as t,at as n,it as r}from"./project-links-CodATITq.js";import{Y as i}from"./index-Ck_8bv0N.js";var a=e();function o({navigation:e,children:r,className:o=``,tree:s=!1,label:c,testId:l}){return t(),(0,a.jsx)(i,{className:`assistant-layout conversation-layout ${o}`,"data-testid":l,navigation:(0,a.jsx)(`aside`,{className:`assistant-list ${s?`file-tree-pane`:``}`,"aria-label":n(`web.Conversation.1`,{p0:c}),children:e}),children:(0,a.jsx)(`section`,{className:`assistant-thread`,"aria-label":c,children:r})})}function s({mine:e=!1,author:n,time:i,children:o,className:s=``,ref:c,...l}){return t(),(0,a.jsx)(`div`,{...l,ref:c,className:`assistant-bubble-row ${e?`mine`:``} ${s}`,children:(0,a.jsxs)(`div`,{className:`assistant-bubble`,children:[(0,a.jsxs)(`div`,{className:`assistant-bubble-meta`,children:[(0,a.jsx)(`span`,{children:n}),i&&(0,a.jsx)(`time`,{dateTime:i,children:new Date(i).toLocaleTimeString(r(),{hour:`2-digit`,minute:`2-digit`})})]}),o]})})}function c({label:e,state:n=`idle`}){return t(),(0,a.jsx)(`span`,{className:`conversation-status state-${n}`,role:`img`,"aria-label":e,title:e})}function l({author:e,time:n,children:i}){return t(),(0,a.jsxs)(`article`,{className:`conversation-post assistant-bubble`,children:[(0,a.jsxs)(`header`,{className:`assistant-bubble-meta`,children:[(0,a.jsx)(`strong`,{children:e}),n&&(0,a.jsx)(`time`,{dateTime:n,children:new Date(n).toLocaleString(r(),{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})})]}),i]})}function u({ref:e,...n}){return t(),(0,a.jsx)(`div`,{role:`log`,"aria-live":`polite`,...n,ref:e,className:`assistant-transcript`})}export{c as a,u as i,o as n,l as r,s as t};
|