@ai.weget.jp/bot 0.1.11 → 0.1.13
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/README.md +12 -1
- package/dist/src/index.js +1 -1
- package/dist/src/ipc/registerHandlers.js +1 -1
- package/dist/src/main.js +1 -1
- package/dist/src/preload.cjs +10 -4
- package/dist/src/renderer/app.js +1 -1
- package/dist/src/renderer/index.html +257 -63
- package/dist/src/renderer/styles.css +519 -4
- package/dist/src/services/authApiService.js +1 -1
- package/dist/src/services/codexService.js +1 -1
- package/dist/src/services/gatewayFileBridgeService.js +1 -0
- package/dist/src/skillHostState.js +1 -1
- package/dist/src/skillRuntimeManager.js +1 -0
- package/package.json +7 -5
- package/scripts/build-ts.cjs +2 -0
- package/dist/src/gmoCoinRuntime.js +0 -1
- package/dist/src/gmoFxRuntime.js +0 -1
|
@@ -6,11 +6,72 @@ body {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.app-shell {
|
|
9
|
-
max-width:
|
|
9
|
+
max-width: 1400px;
|
|
10
10
|
margin: 16px auto;
|
|
11
11
|
padding: 0 12px 16px;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
.app-layout {
|
|
15
|
+
display: grid;
|
|
16
|
+
grid-template-columns: 260px minmax(0, 1fr);
|
|
17
|
+
gap: 14px;
|
|
18
|
+
align-items: start;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.content-shell {
|
|
22
|
+
min-width: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.sidebar-nav {
|
|
26
|
+
position: sticky;
|
|
27
|
+
top: 16px;
|
|
28
|
+
display: grid;
|
|
29
|
+
gap: 12px;
|
|
30
|
+
padding: 14px;
|
|
31
|
+
border-radius: 14px;
|
|
32
|
+
background: linear-gradient(180deg, #122033 0%, #18283f 100%);
|
|
33
|
+
color: #dce7f5;
|
|
34
|
+
box-shadow: 0 10px 24px rgba(20, 25, 45, 0.18);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.sidebar-head {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: space-between;
|
|
41
|
+
gap: 10px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.sidebar-toggle-btn {
|
|
45
|
+
min-width: 38px;
|
|
46
|
+
padding: 8px 10px;
|
|
47
|
+
background: rgba(255, 255, 255, 0.12);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.app-shell.sidebar-collapsed .app-layout {
|
|
51
|
+
grid-template-columns: 76px minmax(0, 1fr);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.app-shell.sidebar-collapsed .sidebar-nav {
|
|
55
|
+
padding-inline: 10px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.app-shell.sidebar-collapsed .sidebar-head strong,
|
|
59
|
+
.app-shell.sidebar-collapsed .tab-group-label {
|
|
60
|
+
display: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.app-shell.sidebar-collapsed .tab-btn {
|
|
64
|
+
width: 52px;
|
|
65
|
+
min-width: 52px;
|
|
66
|
+
min-height: 44px;
|
|
67
|
+
padding: 8px 6px;
|
|
68
|
+
justify-items: center;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.app-shell.sidebar-collapsed .tab-btn-label {
|
|
72
|
+
display: none;
|
|
73
|
+
}
|
|
74
|
+
|
|
14
75
|
.user-notice {
|
|
15
76
|
position: fixed;
|
|
16
77
|
top: 14px;
|
|
@@ -173,7 +234,6 @@ body {
|
|
|
173
234
|
.tabs-shell {
|
|
174
235
|
display: grid;
|
|
175
236
|
gap: 10px;
|
|
176
|
-
margin-bottom: 12px;
|
|
177
237
|
}
|
|
178
238
|
|
|
179
239
|
.tab-group {
|
|
@@ -190,9 +250,8 @@ body {
|
|
|
190
250
|
}
|
|
191
251
|
|
|
192
252
|
.tabs {
|
|
193
|
-
display:
|
|
253
|
+
display: grid;
|
|
194
254
|
gap: 8px;
|
|
195
|
-
flex-wrap: wrap;
|
|
196
255
|
}
|
|
197
256
|
|
|
198
257
|
.tab-btn {
|
|
@@ -202,6 +261,11 @@ body {
|
|
|
202
261
|
border-radius: 8px;
|
|
203
262
|
padding: 8px 12px;
|
|
204
263
|
cursor: pointer;
|
|
264
|
+
text-align: left;
|
|
265
|
+
display: grid;
|
|
266
|
+
grid-template-columns: auto 1fr;
|
|
267
|
+
align-items: center;
|
|
268
|
+
gap: 10px;
|
|
205
269
|
}
|
|
206
270
|
|
|
207
271
|
.tab-btn.is-active {
|
|
@@ -210,6 +274,31 @@ body {
|
|
|
210
274
|
border-color: #2359d1;
|
|
211
275
|
}
|
|
212
276
|
|
|
277
|
+
.tab-btn-icon {
|
|
278
|
+
width: 28px;
|
|
279
|
+
height: 28px;
|
|
280
|
+
display: inline-grid;
|
|
281
|
+
place-items: center;
|
|
282
|
+
border-radius: 8px;
|
|
283
|
+
background: rgba(35, 89, 209, 0.12);
|
|
284
|
+
color: #2359d1;
|
|
285
|
+
font-size: 12px;
|
|
286
|
+
font-weight: 700;
|
|
287
|
+
line-height: 1;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.tab-btn.is-active .tab-btn-icon {
|
|
291
|
+
background: rgba(255, 255, 255, 0.18);
|
|
292
|
+
color: #ffffff;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.tab-btn-label {
|
|
296
|
+
min-width: 0;
|
|
297
|
+
overflow: hidden;
|
|
298
|
+
text-overflow: ellipsis;
|
|
299
|
+
white-space: nowrap;
|
|
300
|
+
}
|
|
301
|
+
|
|
213
302
|
.tab-panel {
|
|
214
303
|
display: none;
|
|
215
304
|
}
|
|
@@ -318,6 +407,17 @@ body {
|
|
|
318
407
|
border-color: #d8dee8;
|
|
319
408
|
}
|
|
320
409
|
|
|
410
|
+
.tab-btn.is-active.is-disabled {
|
|
411
|
+
background: #2359d1;
|
|
412
|
+
color: #fff;
|
|
413
|
+
border-color: #2359d1;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.tab-btn.is-active.is-disabled .tab-btn-icon {
|
|
417
|
+
background: rgba(255, 255, 255, 0.18);
|
|
418
|
+
color: #ffffff;
|
|
419
|
+
}
|
|
420
|
+
|
|
321
421
|
.market-layout {
|
|
322
422
|
display: grid;
|
|
323
423
|
grid-template-columns: 1fr 340px;
|
|
@@ -978,6 +1078,10 @@ button.is-loading::before {
|
|
|
978
1078
|
gap: 12px;
|
|
979
1079
|
}
|
|
980
1080
|
|
|
1081
|
+
.browser-skill-shell:empty {
|
|
1082
|
+
display: none;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
981
1085
|
.browser-skill-card {
|
|
982
1086
|
border: 1px solid #dbe4f1;
|
|
983
1087
|
border-radius: 12px;
|
|
@@ -991,6 +1095,319 @@ button.is-loading::before {
|
|
|
991
1095
|
margin: 0;
|
|
992
1096
|
}
|
|
993
1097
|
|
|
1098
|
+
.browser-mcp-status-row {
|
|
1099
|
+
display: grid;
|
|
1100
|
+
gap: 8px;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
.browser-skill-card textarea[readonly] {
|
|
1104
|
+
min-height: 96px;
|
|
1105
|
+
resize: vertical;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
.status-output {
|
|
1109
|
+
margin: 0;
|
|
1110
|
+
border-radius: 10px;
|
|
1111
|
+
background: #0f1626;
|
|
1112
|
+
color: #dce7f5;
|
|
1113
|
+
padding: 12px;
|
|
1114
|
+
white-space: pre-wrap;
|
|
1115
|
+
word-break: break-word;
|
|
1116
|
+
overflow: auto;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
.gateway-skill-grid {
|
|
1120
|
+
display: grid;
|
|
1121
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
1122
|
+
gap: 12px;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
.gateway-test-card {
|
|
1126
|
+
align-content: start;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
.gateway-test-head {
|
|
1130
|
+
display: flex;
|
|
1131
|
+
justify-content: space-between;
|
|
1132
|
+
gap: 10px;
|
|
1133
|
+
align-items: center;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
.macro-toolbar {
|
|
1137
|
+
display: flex;
|
|
1138
|
+
justify-content: space-between;
|
|
1139
|
+
align-items: end;
|
|
1140
|
+
gap: 12px;
|
|
1141
|
+
flex-wrap: wrap;
|
|
1142
|
+
margin-top: 12px;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
.macro-toolbar-actions {
|
|
1146
|
+
display: flex;
|
|
1147
|
+
gap: 8px;
|
|
1148
|
+
flex-wrap: wrap;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
.macro-date-field {
|
|
1152
|
+
margin: 0;
|
|
1153
|
+
min-width: 220px;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
.macro-status-strip {
|
|
1157
|
+
display: grid;
|
|
1158
|
+
grid-template-columns: minmax(0, 1fr) auto auto;
|
|
1159
|
+
align-items: center;
|
|
1160
|
+
gap: 12px;
|
|
1161
|
+
padding: 12px 14px;
|
|
1162
|
+
border: 1px solid #dbe4f1;
|
|
1163
|
+
border-radius: 12px;
|
|
1164
|
+
background: #f8fbff;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
.macro-status-main {
|
|
1168
|
+
display: flex;
|
|
1169
|
+
align-items: center;
|
|
1170
|
+
gap: 18px;
|
|
1171
|
+
flex-wrap: wrap;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
.macro-status-main > strong {
|
|
1175
|
+
color: #16253c;
|
|
1176
|
+
font-size: 18px;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
.macro-status-hint {
|
|
1180
|
+
margin: 10px 2px 0;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
.macro-two-col {
|
|
1184
|
+
display: grid;
|
|
1185
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
1186
|
+
gap: 12px;
|
|
1187
|
+
margin-top: 12px;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
.macro-side-card {
|
|
1191
|
+
align-content: start;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
.macro-stat-row {
|
|
1195
|
+
display: flex;
|
|
1196
|
+
align-items: baseline;
|
|
1197
|
+
gap: 8px;
|
|
1198
|
+
white-space: nowrap;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
.macro-stat-row strong {
|
|
1202
|
+
color: #223451;
|
|
1203
|
+
font-size: 18px;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
.macro-chip-grid {
|
|
1207
|
+
display: grid;
|
|
1208
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
1209
|
+
gap: 8px;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
.macro-chip {
|
|
1213
|
+
border-radius: 10px;
|
|
1214
|
+
padding: 10px 12px;
|
|
1215
|
+
background: #edf4ff;
|
|
1216
|
+
border: 1px solid #d4e2fb;
|
|
1217
|
+
display: grid;
|
|
1218
|
+
gap: 4px;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
.macro-chip.is-negative {
|
|
1222
|
+
background: #fff1f1;
|
|
1223
|
+
border-color: #f7d3d3;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
.macro-chip-code {
|
|
1227
|
+
color: #597090;
|
|
1228
|
+
font-size: 12px;
|
|
1229
|
+
font-weight: 700;
|
|
1230
|
+
letter-spacing: 0.03em;
|
|
1231
|
+
text-transform: uppercase;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
.macro-chip-value {
|
|
1235
|
+
color: #16253c;
|
|
1236
|
+
font-size: 18px;
|
|
1237
|
+
font-weight: 700;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
.macro-chip-delta {
|
|
1241
|
+
color: #1f9d55;
|
|
1242
|
+
font-size: 13px;
|
|
1243
|
+
font-weight: 600;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
.macro-chip-delta.is-negative {
|
|
1247
|
+
color: #d64545;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
.macro-treemap {
|
|
1251
|
+
position: relative;
|
|
1252
|
+
height: 240px;
|
|
1253
|
+
border-radius: 12px;
|
|
1254
|
+
overflow: hidden;
|
|
1255
|
+
background: #d7e3ea;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
.macro-treemap-empty {
|
|
1259
|
+
position: absolute;
|
|
1260
|
+
inset: 0;
|
|
1261
|
+
display: flex;
|
|
1262
|
+
align-items: center;
|
|
1263
|
+
justify-content: center;
|
|
1264
|
+
place-items: center;
|
|
1265
|
+
color: #60708a;
|
|
1266
|
+
background: #f4f7fb;
|
|
1267
|
+
padding: 12px;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
.macro-treemap-tile {
|
|
1271
|
+
position: absolute;
|
|
1272
|
+
box-sizing: border-box;
|
|
1273
|
+
border: 1px solid rgba(255, 255, 255, 0.75);
|
|
1274
|
+
display: flex;
|
|
1275
|
+
flex-direction: column;
|
|
1276
|
+
align-content: center;
|
|
1277
|
+
align-items: center;
|
|
1278
|
+
justify-items: center;
|
|
1279
|
+
justify-content: center;
|
|
1280
|
+
text-align: center;
|
|
1281
|
+
padding: 12px 10px;
|
|
1282
|
+
gap: 4px;
|
|
1283
|
+
color: #ffffff;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
.macro-treemap-tile.up {
|
|
1287
|
+
background: color-mix(in srgb, #22c55e calc(var(--tile-intensity, 0.5) * 100%), #96f0b5);
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
.macro-treemap-tile.down {
|
|
1291
|
+
background: color-mix(in srgb, #ef4444 calc(var(--tile-intensity, 0.5) * 100%), #f7b0b0);
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
.macro-treemap-symbol {
|
|
1295
|
+
font-size: clamp(17px, 1.8vw, 30px);
|
|
1296
|
+
font-weight: 700;
|
|
1297
|
+
line-height: 1;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
.macro-treemap-change {
|
|
1301
|
+
font-size: clamp(15px, 1.5vw, 22px);
|
|
1302
|
+
font-weight: 600;
|
|
1303
|
+
line-height: 1;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
.table-scroll {
|
|
1307
|
+
overflow-x: auto;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
.macro-table td {
|
|
1311
|
+
vertical-align: top;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
.macro-table td:nth-child(2),
|
|
1315
|
+
.macro-table td:nth-child(3),
|
|
1316
|
+
.macro-table td:nth-child(4),
|
|
1317
|
+
.macro-table th:nth-child(2),
|
|
1318
|
+
.macro-table th:nth-child(3),
|
|
1319
|
+
.macro-table th:nth-child(4) {
|
|
1320
|
+
text-align: left;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
.macro-analyzer {
|
|
1324
|
+
max-width: none;
|
|
1325
|
+
white-space: pre-wrap;
|
|
1326
|
+
word-break: break-word;
|
|
1327
|
+
line-height: 1.55;
|
|
1328
|
+
background: #f8fbff;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
.macro-ai-label {
|
|
1332
|
+
color: #62748f;
|
|
1333
|
+
font-weight: 700;
|
|
1334
|
+
text-align: center;
|
|
1335
|
+
vertical-align: middle;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
.macro-ai-row td {
|
|
1339
|
+
border-top: 0;
|
|
1340
|
+
padding: 12px 14px;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
.macro-data-row td {
|
|
1344
|
+
vertical-align: top;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
.macro-title-cell {
|
|
1348
|
+
color: #10233f;
|
|
1349
|
+
line-height: 1.45;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
.macro-title-cell strong {
|
|
1353
|
+
font-weight: 800;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
.macro-impact-badge {
|
|
1357
|
+
display: inline-flex;
|
|
1358
|
+
align-items: center;
|
|
1359
|
+
justify-content: center;
|
|
1360
|
+
min-width: 64px;
|
|
1361
|
+
border-radius: 999px;
|
|
1362
|
+
padding: 4px 10px;
|
|
1363
|
+
font-size: 12px;
|
|
1364
|
+
font-weight: 700;
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
.macro-impact-badge.high {
|
|
1368
|
+
background: #fee2e2;
|
|
1369
|
+
color: #991b1b;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
.macro-impact-badge.medium {
|
|
1373
|
+
background: #fef3c7;
|
|
1374
|
+
color: #92400e;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
.macro-impact-badge.low {
|
|
1378
|
+
background: #dcfce7;
|
|
1379
|
+
color: #166534;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
.macro-importance-stars {
|
|
1383
|
+
color: #f59e0b;
|
|
1384
|
+
letter-spacing: 0.08em;
|
|
1385
|
+
font-size: 14px;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
.macro-direction {
|
|
1389
|
+
display: inline-block;
|
|
1390
|
+
font-weight: 800;
|
|
1391
|
+
letter-spacing: 0.06em;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
.macro-direction.up {
|
|
1395
|
+
color: #22c55e;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
.macro-direction.down {
|
|
1399
|
+
color: #ef4444;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
.macro-direction.flat {
|
|
1403
|
+
color: #64748b;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
.macro-link {
|
|
1407
|
+
color: #2359d1;
|
|
1408
|
+
word-break: break-all;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
994
1411
|
.chat-tools {
|
|
995
1412
|
display: flex;
|
|
996
1413
|
gap: 8px;
|
|
@@ -1024,6 +1441,63 @@ button.is-loading::before {
|
|
|
1024
1441
|
background: #f2f4f8;
|
|
1025
1442
|
}
|
|
1026
1443
|
|
|
1444
|
+
.msg-title {
|
|
1445
|
+
font-weight: 700;
|
|
1446
|
+
margin-bottom: 6px;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
.msg.assistant-thinking {
|
|
1450
|
+
background: linear-gradient(135deg, #eef4ff 0%, #f8fbff 100%);
|
|
1451
|
+
border: 1px solid #d7e3f6;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
.thinking-body {
|
|
1455
|
+
display: inline-flex;
|
|
1456
|
+
align-items: center;
|
|
1457
|
+
gap: 10px;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
.thinking-text {
|
|
1461
|
+
color: #294267;
|
|
1462
|
+
font-weight: 600;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
.thinking-dots {
|
|
1466
|
+
display: inline-flex;
|
|
1467
|
+
gap: 4px;
|
|
1468
|
+
align-items: center;
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
.thinking-dots span {
|
|
1472
|
+
width: 8px;
|
|
1473
|
+
height: 8px;
|
|
1474
|
+
border-radius: 50%;
|
|
1475
|
+
background: #2359d1;
|
|
1476
|
+
opacity: 0.35;
|
|
1477
|
+
animation: thinking-bounce 1.1s infinite ease-in-out;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
.thinking-dots span:nth-child(2) {
|
|
1481
|
+
animation-delay: 0.15s;
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
.thinking-dots span:nth-child(3) {
|
|
1485
|
+
animation-delay: 0.3s;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
@keyframes thinking-bounce {
|
|
1489
|
+
0%,
|
|
1490
|
+
80%,
|
|
1491
|
+
100% {
|
|
1492
|
+
transform: translateY(0);
|
|
1493
|
+
opacity: 0.35;
|
|
1494
|
+
}
|
|
1495
|
+
40% {
|
|
1496
|
+
transform: translateY(-4px);
|
|
1497
|
+
opacity: 1;
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1027
1501
|
.msg.line-user {
|
|
1028
1502
|
background: #e6f7ee;
|
|
1029
1503
|
}
|
|
@@ -1137,6 +1611,24 @@ button.is-loading::before {
|
|
|
1137
1611
|
}
|
|
1138
1612
|
|
|
1139
1613
|
@media (max-width: 980px) {
|
|
1614
|
+
.app-layout {
|
|
1615
|
+
grid-template-columns: 1fr;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
.sidebar-nav {
|
|
1619
|
+
position: static;
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
.app-shell.sidebar-collapsed .app-layout {
|
|
1623
|
+
grid-template-columns: 1fr;
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
.app-shell.sidebar-collapsed .sidebar-head strong,
|
|
1627
|
+
.app-shell.sidebar-collapsed .tab-group-label,
|
|
1628
|
+
.app-shell.sidebar-collapsed .tab-btn:not(.is-active) {
|
|
1629
|
+
display: initial;
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1140
1632
|
.positions-grid {
|
|
1141
1633
|
grid-template-columns: 1fr;
|
|
1142
1634
|
}
|
|
@@ -1148,4 +1640,27 @@ button.is-loading::before {
|
|
|
1148
1640
|
.browser-skill-shell {
|
|
1149
1641
|
grid-template-columns: 1fr;
|
|
1150
1642
|
}
|
|
1643
|
+
|
|
1644
|
+
.gateway-skill-grid {
|
|
1645
|
+
grid-template-columns: 1fr;
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
.macro-status-strip,
|
|
1649
|
+
.macro-two-col {
|
|
1650
|
+
grid-template-columns: 1fr;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
.macro-status-main {
|
|
1654
|
+
align-items: flex-start;
|
|
1655
|
+
flex-direction: column;
|
|
1656
|
+
gap: 8px;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
.macro-chip-grid {
|
|
1660
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
.macro-treemap {
|
|
1664
|
+
height: 220px;
|
|
1665
|
+
}
|
|
1151
1666
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=t=>t&&"object"==typeof t?t:{},e=(t,o="")=>{if(null==t)return t;const r=String(o||"");if("string"==typeof t)return/(password|token|authorization|api_?key|secret|cookie|jwt)/i.test(r)?t.length<=8?"****":`${t.slice(0,3)}****${t.slice(-3)}`:t.length>2e3?`${t.slice(0,2e3)}...(truncated)`:t;if("number"==typeof t||"boolean"==typeof t)return t;if(Array.isArray(t)){const o=t.slice(0,50).map(t=>e(t,r));return t.length>50&&o.push(`...(${t.length-50} more items)`),o}if("object"==typeof t){const o={};for(const[r,i]of Object.entries(t))o[r]=e(i,r);return o}return String(t)};export const createAuthApiService=({getEnv:o,emitLog:r,getCurrentSession:i})=>{const n=async e=>{const o=await e.text();if(!o)return{};try{const e=JSON.parse(o);return t(e)}catch{return{raw:o}}};return{signInWithLoginApi:async(e,i)=>{const s=o();if(!s.loginApiUrl)throw new Error("Missing loginApiUrl in local config");const l=new AbortController,a=setTimeout(()=>l.abort(),15e3);let c;r("[auth] login api request",{url:s.loginApiUrl,email:e});try{c=await fetch(s.loginApiUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:i,client:"bot"}),signal:l.signal})}catch(e){const o=t(t(e).cause),r=o?`${String(o.code||"")} ${String(o.syscall||"")} ${String(o.hostname||"")}`.trim():"";throw new Error("login fetch failed"+(r?`: ${r}`:""))}finally{clearTimeout(a)}r("[auth] login api response",{status:c.status});const p=await n(c);if(!c.ok)throw new Error(String(p.error||p.message||p.msg||"Login failed"));return((e,o)=>{const r=t(e),i=t(r.data),n=t(r.user),s=t(i.user),l=r.access_token||r.token||r.jwt||i.access_token||i.token;if(!l)throw new Error("Login API response missing token field (access_token/token/jwt)");const a=r.user_id||n.id||r.sub||i.user_id||s.id||"",c=r.email||n.email||i.email||s.email||o,p=r.chat_model||i.chat_model||"gpt-4
|
|
1
|
+
const t=t=>t&&"object"==typeof t?t:{},e=(t,o="")=>{if(null==t)return t;const r=String(o||"");if("string"==typeof t)return/(password|token|authorization|api_?key|secret|cookie|jwt)/i.test(r)?t.length<=8?"****":`${t.slice(0,3)}****${t.slice(-3)}`:t.length>2e3?`${t.slice(0,2e3)}...(truncated)`:t;if("number"==typeof t||"boolean"==typeof t)return t;if(Array.isArray(t)){const o=t.slice(0,50).map(t=>e(t,r));return t.length>50&&o.push(`...(${t.length-50} more items)`),o}if("object"==typeof t){const o={};for(const[r,i]of Object.entries(t))o[r]=e(i,r);return o}return String(t)};export const createAuthApiService=({getEnv:o,emitLog:r,getCurrentSession:i})=>{const n=async e=>{const o=await e.text();if(!o)return{};try{const e=JSON.parse(o);return t(e)}catch{return{raw:o}}};return{signInWithLoginApi:async(e,i)=>{const s=o();if(!s.loginApiUrl)throw new Error("Missing loginApiUrl in local config");const l=new AbortController,a=setTimeout(()=>l.abort(),15e3);let c;r("[auth] login api request",{url:s.loginApiUrl,email:e});try{c=await fetch(s.loginApiUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:i,client:"bot"}),signal:l.signal})}catch(e){const o=t(t(e).cause),r=o?`${String(o.code||"")} ${String(o.syscall||"")} ${String(o.hostname||"")}`.trim():"";throw new Error("login fetch failed"+(r?`: ${r}`:""))}finally{clearTimeout(a)}r("[auth] login api response",{status:c.status});const p=await n(c);if(!c.ok)throw new Error(String(p.error||p.message||p.msg||"Login failed"));return((e,o)=>{const r=t(e),i=t(r.data),n=t(r.user),s=t(i.user),l=r.access_token||r.token||r.jwt||i.access_token||i.token;if(!l)throw new Error("Login API response missing token field (access_token/token/jwt)");const a=r.user_id||n.id||r.sub||i.user_id||s.id||"",c=r.email||n.email||i.email||s.email||o,p=r.chat_model||i.chat_model||"gpt-5.4",u=r.chat_system_prompt||i.chat_system_prompt||"";return{accessToken:String(l),userId:String(a),email:String(c),chatModel:String(p),chatSystemPrompt:String(u)}})(p,e)},callBotApi:async(t,o)=>{if(!t)throw new Error("bot control api url is missing");const s=i();if(!s?.accessToken)throw new Error("bot session access token missing");r("[bot-api] request",{url:t,bot_id:s.botId||"",body:e(o)});const l=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.accessToken}`},body:JSON.stringify(o||{})}),a=await n(l);if(r("[bot-api] response",{url:t,status:l.status,ok:l.ok,body:e(a)}),!l.ok)throw new Error(String(a.error||a.message||`api failed: ${l.status}`));return a},requestBotImageUploadUrl:async({filename:t,contentType:s})=>{const l=(()=>{const t=o();return t.botUploadApiUrl?t.botUploadApiUrl:t.loginApiUrl?t.loginApiUrl.replace(/\/login\/?$/i,"/bot/upload-url"):""})();if(!l)throw new Error("Missing upload/login api url in local config");const a=i();if(!a?.accessToken)throw new Error("bot session access token missing");r("[bot-api] request",{url:l,bot_id:a.botId||"",body:e({bot_id:a.botId||"",filename:t,content_type:s})});const c=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.accessToken}`},body:JSON.stringify({bot_id:a.botId||"",filename:t,content_type:s})}),p=await n(c);if(r("[bot-api] response",{url:l,status:c.status,ok:c.ok,body:e(p)}),!c.ok)throw new Error(String(p.error||p.message||"failed to request bot upload url"));if(!p.upload_url||!p.preview_url)throw new Error("upload url api response missing upload_url or preview_url");return{upload_url:String(p.upload_url),preview_url:String(p.preview_url),file_url:p.file_url?String(p.file_url):void 0}},uploadImageToSignedUrl:async({uploadUrl:t,contentType:e,bytes:o})=>{const r=await fetch(t,{method:"PUT",headers:{"Content-Type":e},body:o});if(!r.ok){const t=await r.text();throw new Error(`s3 upload failed: ${r.status} ${t}`)}},getBotRuntimeConfigApiUrl:()=>{const t=o();return t.botRuntimeConfigApiUrl?t.botRuntimeConfigApiUrl:t.loginApiUrl?t.loginApiUrl.replace(/\/login\/?$/i,"/bot/runtime-config"):""},getBotSkillsListApiUrl:()=>{const t=o();return t.botSkillsListApiUrl?t.botSkillsListApiUrl:t.loginApiUrl?t.loginApiUrl.replace(/\/login\/?$/i,"/bot/skills/list"):""}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"node:fs/promises";import e from"node:os";import o from"node:path";import{spawn as r}from"node:child_process";const n="gpt-4.1-mini",i=async t=>{if(!t)return"";const e=[];for await(const o of t)e.push(Buffer.isBuffer(o)?o:Buffer.from(String(o)));return Buffer.concat(e).toString("utf8")},d=async({args:t,stdinText:e,cwd:o})=>new Promise((n,d)=>{const s=r("codex",t,{cwd:o,stdio:["pipe","pipe","pipe"],windowsHide:!0});let a=!1;const c=t=>{a||(a=!0,t())},u=i(s.stdout),l=i(s.stderr);s.on("error",t=>{c(()=>d(t))}),s.on("close",async t=>{const[e,o]=await Promise.all([u,l]);c(()=>n({stdout:e,stderr:o,exitCode:Number.isFinite(t)?Number(t):1}))}),"string"==typeof e&&s.stdin.write(e),s.stdin.end()});export const createCodexService=({getModel:i,getWorkingDir:s,emitLog:a})=>({runPrompt:async({prompt:r,model:c,contextLabel:u})=>{const l=String(c||i()||n).trim()||n,g=s(),m=await t.mkdtemp(o.join(e.tmpdir(),"weget-codex-")),f=o.join(m,"last-message.txt"),w=`${String(r||"").trim()}\n\nRespond as plain text only.`;a("[codex] exec start",{model:l,cwd:g,context:String(u||"").trim()});try{const e=await d({cwd:g,args:["exec","-C",g,"--skip-git-repo-check","-m",l,"-o",f,"-"],stdinText:w}),o=await t.readFile(f,"utf8").catch(()=>"");if(0!==e.exitCode)throw new Error((e.stderr||e.stdout||`codex exec failed with code ${e.exitCode}`).trim());const r=String(o||e.stdout||"").trim();if(!r)throw new Error("codex returned empty output");return a("[codex] exec completed",{model:l,context:String(u||"").trim()}),r}finally{await t.rm(m,{recursive:!0,force:!0}).catch(()=>{})}},getAuthStatus:async()=>{try{const t=await d({cwd:s(),args:["login","status"]}),e=String(t.stdout||t.stderr||"").trim();return 0!==t.exitCode?{status:"unknown",detail:e||"codex login status failed"}:/logged in/i.test(e)?{status:"logged_in",detail:e}:/not logged in|logged out/i.test(e)?{status:"logged_out",detail:e}:{status:"unknown",detail:e||"unknown codex auth state"}}catch(t){return{status:"unknown",detail:t instanceof Error?t.message:String(t)}}},startLogin:async()=>{const t=s();try{if("win32"===process.platform)return r("cmd.exe",["/c","start",'""',"codex","login","--device-auth"],{cwd:t,detached:!0,stdio:"ignore",windowsHide:!1}).unref(),{ok:!0,detail:"Started `codex login --device-auth` in a new terminal window."};if("darwin"===process.platform){const e=`cd ${JSON.stringify(t)} && codex login --device-auth`;return r("open",["-a","Terminal",e],{cwd:t,detached:!0,stdio:"ignore"}).unref(),{ok:!0,detail:"Started `codex login --device-auth` in Terminal."}}const e=`cd ${JSON.stringify(t)} && codex login --device-auth; exec $SHELL`,o=[["x-terminal-emulator",["-e","bash","-lc",e]],["gnome-terminal",["--","bash","-lc",e]],["konsole",["-e","bash","-lc",e]]];for(const[e,n]of o)try{return r(e,n,{cwd:t,detached:!0,stdio:"ignore"}).unref(),{ok:!0,detail:`Started \`codex login --device-auth\` using ${e}.`}}catch{}return{ok:!1,detail:"No supported terminal launcher was found. Run `codex login --device-auth` manually."}}catch(t){const e=t instanceof Error?t.message:String(t);return a("[codex] login launch failed",{error:e}),{ok:!1,detail:e}}}});
|
|
1
|
+
import t from"node:fs/promises";import{existsSync as e}from"node:fs";import{createRequire as r}from"node:module";import s from"node:os";import o from"node:path";import{spawn as a,spawnSync as n}from"node:child_process";const i="gpt-5.4",c=r(import.meta.url);let d=null,l=null,g=null,u=null;const m=async t=>{if(!t)return"";const e=[];for await(const r of t)e.push(Buffer.isBuffer(r)?r:Buffer.from(String(r)));return Buffer.concat(e).toString("utf8")},w=t=>String(t||"").replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g,""),p=t=>{let e="";return{push:r=>{if(!t)return;e+=w(Buffer.isBuffer(r)?r.toString("utf8"):String(r));const s=e.split(/\r?\n/);e=s.pop()||"";for(const e of s){const r=String(e||"").trim();r&&t(r)}},flush:()=>{if(!t)return;const r=String(e||"").trim();r&&t(r),e=""}}},f=t=>{const e=w(String(t||"")).trim();return e?/^[{}[\],:]+$/.test(e)||/^["']?[a-zA-Z0-9_-]+["']?\s*:\s*$/.test(e)||/^`{3,}|^#{1,6}\s*$/.test(e)||/^Assistant:?\s*$/i.test(e)||/^Warning: no last agent message/i.test(e)?"":/^ERROR:\s*unexpected status\s+\d+/i.test(e)?"Tool call failed":e:""},x=(t,e)=>{const r=w(String(t||"")).replace(/\s+/g," ").trim();return r?r.length>180?`${r.slice(0,177)}...`:r:e},h=e=>{const r=(new Date).toISOString(),s=`exec-${Date.now()}`;let a="",n="",i=!1,c=Promise.resolve();const d=[],l=async()=>{if(i)return n;const r=o.join(e,"codex-sessions");await t.mkdir(r,{recursive:!0});const c=String(a||s||"").trim().replace(/[^a-zA-Z0-9._-]+/g,"_");return n=o.join(r,`${c}.log`),i=!0,d.length>0&&(await t.appendFile(n,d.join(""),"utf8"),d.length=0),n},g=(e,r={})=>{(e=>{c=c.then(async()=>{if(!i&&!a)return void d.push(e);const r=await l();await t.appendFile(r,e,"utf8")}).catch(()=>{})})(`${JSON.stringify({ts:(new Date).toISOString(),event:e,...r},null,0)}\n`)};return{get startedAt(){return r},setSessionId:t=>{const e=String(t||"").trim();e&&a!==e&&(a=e,g("session_identified",{sessionId:e}))},write:g,flush:async()=>(i||await l(),await c,n)}},y=()=>{if(l)return l;const t=[o.join(String(process.env.ProgramFiles||"C:\\Program Files"),"nodejs","npx.cmd"),o.join(String(process.env["ProgramFiles(x86)"]||"C:\\Program Files (x86)"),"nodejs","npx.cmd"),o.join(String(process.env.APPDATA||""),"npm","npx.cmd")].filter(Boolean);for(const r of t)if(e(r))return l=r,r;const r=n("where.exe",["npx.cmd"],{windowsHide:!0,encoding:"utf8"}),s=String(r.stdout||"").split(/\r?\n/).map(t=>t.trim()).find(Boolean);return s?(l=s,s):"npx.cmd"},S=()=>{if(g)return g;const t=[o.join(String(process.env.ProgramFiles||"C:\\Program Files"),"nodejs","node.exe"),o.join(String(process.env["ProgramFiles(x86)"]||"C:\\Program Files (x86)"),"nodejs","node.exe")];for(const r of t)if(e(r))return g=r,r;return g="node",g},C=()=>{if(u)return u;try{const t=c.resolve("@ai.weget.jp/weget-gateway-mcp/dist/index.js");return u=t,t}catch{}const t=[o.join(String(process.env.APPDATA||""),"npm","node_modules","@ai.weget.jp","weget-gateway-mcp","dist","index.js"),o.join(String(process.env.ProgramFiles||"C:\\Program Files"),"nodejs","node_modules","@ai.weget.jp","weget-gateway-mcp","dist","index.js"),o.join(String(process.env["ProgramFiles(x86)"]||"C:\\Program Files (x86)"),"nodejs","node_modules","@ai.weget.jp","weget-gateway-mcp","dist","index.js")].filter(Boolean);for(const r of t)if(e(r))return u=r,r;return u=o.join(String(process.env.APPDATA||""),"npm","node_modules","@ai.weget.jp","weget-gateway-mcp","dist","index.js"),u},_=t=>{const e=o.join(t,"weget-gateway-context.json");return"win32"===process.platform?{command:S(),args:[C(),"--context-file",e]}:{command:"npx",args:["-y","@ai.weget.jp/weget-gateway-mcp@latest","--context-file",e]}},v=t=>String(t||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),P=(t,e)=>{const r=String(t||""),s=_(e);if("win32"===process.platform){const t=new RegExp(`command:\\s+${v(s.command)}`,"i"),e=new RegExp(v(String(s.args[0]||"")),"i"),o=new RegExp(v(String(s.args[2]||"")),"i");return t.test(r)&&e.test(r)&&o.test(r)}return new RegExp(`command:\\s+${v(s.command)}`,"i").test(r)&&r.includes(String(s.args[0]||""))},k=async({args:t,stdinText:r,cwd:s,extraEnv:i,onStdoutLine:c,onStderrLine:l})=>new Promise((g,u)=>{const w=(()=>{if(d)return d;if("win32"===process.platform){const t=[String(process.env.ProgramFiles||"C:\\Program Files"),String(process.env["ProgramFiles(x86)"]||"C:\\Program Files (x86)")];for(const r of t){const t=o.join(r,"nodejs","node.exe"),s=o.join(r,"nodejs","node_modules","@openai","codex","bin","codex.js");if(e(t)&&e(s))return d={command:t,baseArgs:[s]},d}const r=["codex.cmd","codex"];for(const t of r){const e=n("where.exe",[t],{windowsHide:!0,encoding:"utf8"}),r=String(e.stdout||"").split(/\r?\n/).map(t=>t.trim()).find(Boolean);if(r)return d={command:r,baseArgs:[]},d}}return d={command:"codex",baseArgs:[]},d})(),f={...process.env,...i||{},NO_COLOR:"1",FORCE_COLOR:"0",CLICOLOR:"0"},x=a(w.command,[...w.baseArgs,...t],{cwd:s,stdio:["pipe","pipe","pipe"],windowsHide:!0,env:f});let h=!1;const y=t=>{h||(h=!0,t())},S=m(x.stdout),C=m(x.stderr),_=p(c),v=p(l);x.stdout?.on("data",t=>_.push(t)),x.stderr?.on("data",t=>v.push(t)),x.on("error",t=>{y(()=>u(t))}),x.on("close",async t=>{_.flush(),v.flush();const[e,r]=await Promise.all([S,C]);y(()=>g({stdout:e,stderr:r,exitCode:Number.isFinite(t)?Number(t):1}))}),"string"==typeof r&&x.stdin.write(r),x.stdin.end()}),$=async({command:t,args:e,cwd:r})=>new Promise((s,o)=>{const n=a(t,e,{cwd:r,stdio:["pipe","pipe","pipe"],windowsHide:!0,env:{...process.env,NO_COLOR:"1",FORCE_COLOR:"0",CLICOLOR:"0"}});let i=!1;const c=t=>{i||(i=!0,t())},d=m(n.stdout),l=m(n.stderr);n.on("error",t=>c(()=>o(t))),n.on("close",async t=>{const[e,r]=await Promise.all([d,l]);c(()=>s({stdout:e,stderr:r,exitCode:Number.isFinite(t)?Number(t):1}))})});export const createCodexService=({getModel:e,getWorkingDir:r,getLogDir:n,emitLog:c,getGatewayContext:d})=>{const l=()=>{const t=d?.()||{},e={WEGET_ACTIVE_SKILLS:JSON.stringify(Array.isArray(t.activeSkills)?t.activeSkills:[]),WEGET_HOST_METADATA:JSON.stringify(t.hostMetadata&&"object"==typeof t.hostMetadata?t.hostMetadata:{})},r=String(t.botId||"").trim(),s=String(t.platformApiBaseUrl||"").trim(),o=String(t.accessToken||"").trim(),a=String(t.fileBridgeDir||"").trim(),n=String(t.fileBridgeToken||"").trim();return r&&(e.WEGET_BOT_ID=r),s&&(e.WEGET_PLATFORM_API_BASE_URL=s),o&&(e.WEGET_PLATFORM_API_ACCESS_TOKEN=o),a&&(e.WEGET_FILE_BRIDGE_DIR=a),n&&(e.WEGET_FILE_BRIDGE_TOKEN=n),e},g=()=>o.join(r(),"weget-gateway-context.json"),u=async()=>{const e=d?.()||{};await t.mkdir(r(),{recursive:!0}),await t.writeFile(g(),JSON.stringify({activeSkills:Array.isArray(e.activeSkills)?e.activeSkills:[],hostMetadata:e.hostMetadata&&"object"==typeof e.hostMetadata?e.hostMetadata:{},botId:String(e.botId||"").trim(),platformApiBaseUrl:String(e.platformApiBaseUrl||"").trim(),accessToken:String(e.accessToken||"").trim(),fileBridgeDir:String(e.fileBridgeDir||"").trim(),fileBridgeToken:String(e.fileBridgeToken||"").trim(),logDir:n(),updatedAt:(new Date).toISOString()},null,2),"utf8")},m=async({target:e,payload:r})=>{const s=o.join(n(),"gateway-tests");await t.mkdir(s,{recursive:!0});const a=o.join(s,`${e}-${Date.now()}.log`);return await t.writeFile(a,`${JSON.stringify(r,null,2)}\n`,"utf8"),a},w=async({userPrompt:t,contextLabel:r})=>{const s=d?.()||{},o=Array.isArray(s.activeSkills)?s.activeSkills:[],a=s.hostMetadata&&"object"==typeof s.hostMetadata?s.hostMetadata:{},[n,c]=await Promise.all([p("weget-gateway"),S()]);return["You are running inside WeGet Bot Host.","","Active skills:",...o.length?o.map(t=>{const e=Array.isArray(t.tools)&&t.tools.length?` tools=${t.tools.join(", ")}`:"",r=String(t.version||"").trim()?` v${String(t.version||"").trim()}`:"";return`- ${String(t.name||"").trim()}${r}${e}`}):["- none"],"","Runtime status:",...[`- weget-gateway MCP: ${n.status}`,`- browser runtime: ${c.status}`,`- context: ${String(r||"").trim()||"general"}`,`- default model: ${String(a.aiModel||e()||i).trim()||i}`],"","Tool policy:","- Prefer direct reasoning for simple text-only requests.","- When the user asks about macro conditions, economic situation, calendar, or news, prefer the WeGet macro tools before summarizing.","- Use WeGet browser tools only for website access, page extraction, navigation, or screenshots.","- If browser runtime or gateway MCP is unavailable, state that limitation explicitly instead of pretending the task was executed.","- For trading or any action with side effects, do not claim execution unless a concrete tool call actually performed it.","- Keep the final answer plain text only.",...(t=>{const e=String(t||"").trim().toLowerCase();return!!e&&[/macro/,/economic/,/economy/,/calendar/,/news/,/usd\s*\/\s*jpy/,/usd_jpy/,/risk sentiment/,/economic situation/,/macro snapshot/,/经济/,/宏观/,/日历/,/新闻/,/形势/,/経済/,/マクロ/,/ニュース/,/カレンダー/,/相場/].some(t=>t.test(e))})(t)?["","Macro tool routing hint:","- This request matches macro intent.","- Before answering, use the WeGet macro tools to fetch snapshot, calendar, and news if available.","- Prefer gateway tool calls such as weget_macro_get_snapshot, weget_macro_list_calendar, and weget_macro_list_news.","- Base the summary on fetched tool results rather than unsupported memory."]:[],"","User request:",String(t||"").trim(),"","Respond as plain text only."].join("\n")},p=async t=>{const e=String(t||"").trim();if(!e)return{status:"unknown",detail:"MCP server name is required"};try{"weget-gateway"===e&&await u().catch(()=>{});const t=await k({cwd:r(),args:["mcp","get",e],extraEnv:l()}),s=String(t.stdout||t.stderr||"").trim();return 0!==t.exitCode?/No MCP server named/i.test(s)?{status:"missing",detail:s}:{status:"unknown",detail:s||"codex mcp list failed"}:"playwright"!==e||(t=>{const e=String(t||"");return"win32"===process.platform?/command:\s+.*node(?:\.exe)?/i.test(e)&&/@playwright[\\\/]mcp[\\\/]cli\.js/i.test(e)&&/args:\s+.*--headless/i.test(e):/command:\s+npx/i.test(e)&&/@playwright\/mcp@latest/i.test(e)&&/args:\s+.*--headless/i.test(e)})(s)?"weget-gateway"!==e||P(s,r())?{status:"configured",detail:s||`${e} is configured`}:{status:"missing",detail:"WeGet Gateway MCP exists but points to an outdated launch path. Reinstall it from the host UI."}:{status:"missing",detail:"Playwright MCP exists but uses an unsupported Windows wrapper. Click Install Playwright MCP to repair it."}}catch(t){return{status:"unknown",detail:t instanceof Error?t.message:String(t)}}},S=async()=>{try{const t="win32"===process.platform?"powershell.exe":"npx",e="win32"===process.platform?["-NoProfile","-Command",`& '${y().replace(/'/g,"''")}' playwright install --list`]:["playwright","install","--list"],s=await $({command:t,args:e,cwd:r()}),o=String(s.stdout||s.stderr||"").trim();return 0!==s.exitCode?{status:"unknown",detail:o||"playwright install --list failed"}:/chromium-\d+/i.test(o)||/\\ms-playwright\\chromium-/i.test(o)?{status:"installed",detail:o}:{status:"missing",detail:o||"Chromium is not installed for Playwright."}}catch(t){return{status:"unknown",detail:t instanceof Error?t.message:String(t)}}};return{runPrompt:async({prompt:a,model:d,contextLabel:m,onStatus:p})=>{const x=String(d||e()||i).trim()||i,y=r();await u().catch(()=>{});const S=h(n()),C=await t.mkdtemp(o.join(s.tmpdir(),"weget-codex-")),_=o.join(C,"last-message.txt"),v=await w({userPrompt:String(a||"").trim(),contextLabel:m});S.write("exec_start",{model:x,cwd:y,context:String(m||"").trim(),prompt:String(a||"").trim(),instruction:v,outputPath:_,tempDir:C,gatewayContextFile:g(),traceStartedAt:S.startedAt}),p?.("Preparing request"),c("[codex] exec start",{model:x,cwd:y,context:String(m||"").trim()});try{const e=await k({cwd:y,extraEnv:l(),args:["exec","--enable","rmcp_client","--dangerously-bypass-approvals-and-sandbox","-C",y,"--skip-git-repo-check","-m",x,"-o",_,"-"],stdinText:v,onStdoutLine:t=>{S.write("stdout_line",{line:t});const e=f(t);if(e)return/^re-connecting/i.test(e)||/checking tools|tool use|using tool|calling tool/i.test(e)?(S.write("status",{source:"stdout",status:e}),void p?.(e)):void(/reading data|fetching|loading|snapshot|calendar|news/i.test(e)&&(S.write("status",{source:"stdout",status:e}),p?.(e)))},onStderrLine:t=>{S.write("stderr_line",{line:t});const e=String(t||"").match(/session id:\s*([a-zA-Z0-9-]+)/i);e?.[1]&&S.setSessionId(e[1]);const r=f(t);if(r&&!/^--------$/.test(r)&&!/^user$/i.test(r))return/^OpenAI Codex/i.test(r)?(S.write("status",{source:"stderr",status:"Starting Codex"}),void p?.("Starting Codex")):void(/workdir:|model:|provider:|approval:|sandbox:|reasoning effort:|reasoning summaries:|session id:/i.test(r)||(S.write("status",{source:"stderr",status:r}),p?.(r)))}});S.write("status",{source:"host",status:"Finalizing reply"}),p?.("Finalizing reply");const r=await t.readFile(_,"utf8").catch(()=>"");if(0!==e.exitCode)throw S.write("exec_error",{exitCode:e.exitCode,stdout:e.stdout,stderr:e.stderr,lastMessage:r}),new Error((e.stderr||e.stdout||`codex exec failed with code ${e.exitCode}`).trim());const s=String(r||e.stdout||"").trim();if(!s)throw S.write("exec_error",{exitCode:e.exitCode,stdout:e.stdout,stderr:e.stderr,lastMessage:r,error:"codex returned empty output"}),new Error("codex returned empty output");return S.write("exec_completed",{exitCode:e.exitCode,stdout:e.stdout,stderr:e.stderr,lastMessage:r,finalAnswer:s}),c("[codex] exec completed",{model:x,context:String(m||"").trim()}),s}catch(t){throw S.write("exec_exception",{error:t instanceof Error?t.message:String(t)}),t}finally{const e=await S.flush().catch(()=>"");e&&c("[codex] session trace written",{context:String(m||"").trim(),tracePath:e}),await t.rm(C,{recursive:!0,force:!0}).catch(()=>{})}},getAuthStatus:async()=>{try{const t=await k({cwd:r(),args:["login","status"]}),e=String(t.stdout||t.stderr||"").trim();return 0!==t.exitCode?{status:"unknown",detail:e||"codex login status failed"}:/logged in/i.test(e)?{status:"logged_in",detail:e}:/not logged in|logged out/i.test(e)?{status:"logged_out",detail:e}:{status:"unknown",detail:e||"unknown codex auth state"}}catch(t){return{status:"unknown",detail:t instanceof Error?t.message:String(t)}}},startLogin:async()=>{const e=r();try{if("win32"===process.platform){const r=String(e||"").replace(/'/g,"''"),n=o.join(s.tmpdir(),`weget-codex-login-${Date.now()}.ps1`),i=["$OutputEncoding = [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)","chcp 65001 > $null",'$env:NO_COLOR = "1"','$env:FORCE_COLOR = "0"','$env:CLICOLOR = "0"','$env:LANG = "en_US.UTF-8"','$env:LC_ALL = "en_US.UTF-8"',`Set-Location -LiteralPath '${r}'`,"$stripAnsi = {"," param([string]$line)",' if ($null -eq $line) { return "" }',' return ($line -replace "`e\\[[0-9;?]*[ -/]*[@-~]", "")',"}","codex login --device-auth 2>&1 | ForEach-Object { & $stripAnsi ([string]$_) }"].join(`${s.EOL}`);await t.writeFile(n,i,"utf8");const c=["$script = @()",'$script += "-NoExit"','$script += "-ExecutionPolicy"','$script += "Bypass"','$script += "-File"',`$script += '${n.replace(/'/g,"''")}'`,`Start-Process -FilePath 'powershell.exe' -WorkingDirectory '${r}' -ArgumentList $script`].join("; ");return a("powershell.exe",["-NoProfile","-ExecutionPolicy","Bypass","-Command",c],{cwd:e,stdio:"ignore",windowsHide:!0}).unref(),{ok:!0,detail:"Started `codex login --device-auth` in a new PowerShell window with UTF-8 output."}}if("darwin"===process.platform){const t=`cd ${JSON.stringify(e)} && codex login --device-auth`;return a("open",["-a","Terminal",t],{cwd:e,detached:!0,stdio:"ignore"}).unref(),{ok:!0,detail:"Started `codex login --device-auth` in Terminal."}}const r=`cd ${JSON.stringify(e)} && codex login --device-auth; exec $SHELL`,n=[["x-terminal-emulator",["-e","bash","-lc",r]],["gnome-terminal",["--","bash","-lc",r]],["konsole",["-e","bash","-lc",r]]];for(const[t,r]of n)try{return a(t,r,{cwd:e,detached:!0,stdio:"ignore"}).unref(),{ok:!0,detail:`Started \`codex login --device-auth\` using ${t}.`}}catch{}return{ok:!1,detail:"No supported terminal launcher was found. Run `codex login --device-auth` manually."}}catch(t){const e=t instanceof Error?t.message:String(t);return c("[codex] login launch failed",{error:e}),{ok:!1,detail:e}}},getMcpServerStatus:p,installWegetGatewayMcp:async()=>{try{await u();const t=await p("weget-gateway");if("configured"===t.status&&P(t.detail,r()))return{ok:!0,detail:t.detail||"WeGet Gateway MCP is already configured."};const e=await k({cwd:r(),args:["mcp","remove","weget-gateway"],extraEnv:l()});if(0!==e.exitCode){const t=String(e.stdout||e.stderr||"").trim().toLowerCase();if(!(t.includes("no mcp server named")||t.includes("not found")||t.includes("no server named")))return{ok:!1,detail:String(e.stdout||e.stderr||"").trim()||"Failed to remove existing WeGet Gateway MCP entry."}}const s=_(r()),o=await k({cwd:r(),args:["mcp","add","weget-gateway",s.command,...s.args],extraEnv:l()}),a=String(o.stdout||o.stderr||"").trim();if(0!==o.exitCode)return{ok:!1,detail:a||"Failed to add WeGet Gateway MCP to Codex."};const n=await p("weget-gateway");return"configured"===n.status?{ok:!0,detail:n.detail||"WeGet Gateway MCP configured."}:{ok:!0,detail:a||"WeGet Gateway MCP add command completed, but verification returned no explicit entry."}}catch(t){const e=t instanceof Error?t.message:String(t);return c("[codex] weget gateway mcp install failed",{error:e}),{ok:!1,detail:e}}},getPlaywrightBrowserStatus:S,getGatewayContextFilePath:g,runGatewaySelfTest:async e=>{if("codex_macro"===e){const a=(new Date).toISOString().slice(0,10);await u().catch(()=>{});const c=h(n()),d=await t.mkdtemp(o.join(s.tmpdir(),"weget-codex-test-")),w=o.join(d,"last-message.txt"),p=["You are running a WeGet gateway chain self-test.","Use WeGet gateway MCP tools only.",`Call weget_macro_get_snapshot, weget_macro_list_calendar with dateKey=${a}, and weget_macro_list_news with dateKey=${a}.`,"If all three tool calls succeed, reply with exactly: OK macro chain","If any tool call fails, reply with exactly: NG macro chain: <short reason>","Respond as plain text only."].join("\n");c.write("exec_start",{model:i,cwd:r(),context:"gateway_self_test:codex_macro",prompt:"codex macro chain self-test",instruction:p,outputPath:w,tempDir:d,gatewayContextFile:g(),traceStartedAt:c.startedAt});try{const s=await k({cwd:r(),extraEnv:l(),args:["exec","--enable","rmcp_client","--dangerously-bypass-approvals-and-sandbox","-C",r(),"--skip-git-repo-check","-m",i,"-o",w,"-"],stdinText:p,onStdoutLine:t=>{c.write("stdout_line",{line:t})},onStderrLine:t=>{c.write("stderr_line",{line:t});const e=String(t||"").match(/session id:\s*([a-zA-Z0-9-]+)/i);e?.[1]&&c.setSessionId(e[1])}}),o=await t.readFile(w,"utf8").catch(()=>""),n=String(o||s.stdout||"").trim(),u=String(s.stderr||""),f=String(s.stdout||""),h=/tool weget-gateway\.weget_macro_get_snapshot\(\{\}\)/i.test(u),y=new RegExp(`tool weget-gateway\\.weget_macro_list_calendar\\(\\{"dateKey":"${v(a)}"\\}\\)`,"i").test(u),S=new RegExp(`tool weget-gateway\\.weget_macro_list_news\\(\\{"dateKey":"${v(a)}"\\}\\)`,"i").test(u),C=/weget-gateway\.weget_macro_get_snapshot\(\{\}\) success/i.test(u),_=/weget-gateway\.weget_macro_list_calendar\(\{\"dateKey\":\"\d{4}-\d{2}-\d{2}\"\}\) success/i.test(u),P=/weget-gateway\.weget_macro_list_news\(\{\"dateKey\":\"\d{4}-\d{2}-\d{2}\"\}\) success/i.test(u),$=0===s.exitCode&&/^OK macro chain$/i.test(n)&&h&&y&&S&&C&&_&&P;c.write($?"exec_completed":"exec_error",{exitCode:s.exitCode,stdout:f,stderr:u,lastMessage:o,finalAnswer:n,invokedSnapshot:h,invokedCalendar:y,invokedNews:S,succeededSnapshot:C,succeededCalendar:_,succeededNews:P});const O=await c.flush().catch(()=>""),E={target:e,ok:$,summary:$?"Codex gateway macro chain OK":"Codex gateway macro chain failed",contextFilePath:g(),tracePath:O,codex:{exitCode:s.exitCode,stdout:f,stderr:u,finalAnswer:n},assertions:{invokedSnapshot:h,invokedCalendar:y,invokedNews:S,succeededSnapshot:C,succeededCalendar:_,succeededNews:P},ts:(new Date).toISOString()},j=await m({target:e,payload:E});return await t.rm(d,{recursive:!0,force:!0}).catch(()=>{}),{ok:$,summary:$?"Codex gateway macro chain OK":x(n||u,"Codex gateway macro chain failed"),detail:n||u||f,logPath:j,result:E}}catch(r){c.write("exec_exception",{error:r instanceof Error?r.message:String(r)});const s=await c.flush().catch(()=>""),o=r instanceof Error?r.message:String(r),a=await m({target:e,payload:{target:e,ok:!1,summary:"Codex gateway macro chain failed",contextFilePath:g(),tracePath:s,error:o,ts:(new Date).toISOString()}});return await t.rm(d,{recursive:!0,force:!0}).catch(()=>{}),{ok:!1,summary:x(o,"Codex gateway macro chain failed"),detail:o,logPath:a}}}await u();const c=_(r());let d,w=null;try{d=await $({command:c.command,args:[...c.args,"--self-test","--test-target",e],cwd:r()}),"gateway"===e&&(w=await(async({command:t,args:e,cwd:r,timeoutMs:s=2500})=>new Promise((o,n)=>{const i=a(t,e,{cwd:r,stdio:["ignore","pipe","pipe"],windowsHide:!0,env:{...process.env,NO_COLOR:"1",FORCE_COLOR:"0",CLICOLOR:"0"}}),c=[],d=[];let l=!1;const g=t=>{l||(l=!0,o(t))};i.stdout.on("data",t=>c.push(Buffer.from(t))),i.stderr.on("data",t=>d.push(Buffer.from(t))),i.on("error",t=>{l||(l=!0,n(t))}),i.on("close",t=>{g({ok:!1,exitCode:Number.isFinite(t)?Number(t):1,stdout:Buffer.concat(c).toString("utf8"),stderr:Buffer.concat(d).toString("utf8"),responseText:""})}),setTimeout(()=>{const t=i.stdin;t?.write(`${JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2024-11-05",capabilities:{},clientInfo:{name:"weget-gateway-probe",version:"0.1.0"}}})}\n`)},150),setTimeout(()=>{if(l)return;const t=Buffer.concat(c).toString("utf8"),e=Buffer.concat(d).toString("utf8"),r=t.trim(),s=/"result"\s*:/.test(r)&&/"protocolVersion"\s*:/.test(r);i.kill(),g({ok:s,exitCode:null,stdout:t,stderr:e,responseText:r})},Math.max(250,s))}))({command:c.command,args:c.args,cwd:r()}))}catch(t){const r=t instanceof Error?t.message:String(t),s=await m({target:e,payload:{target:e,launch:c,contextFilePath:g(),failure:"spawn_exception",error:r,ts:(new Date).toISOString()}});return{ok:!1,summary:x(r,`${e} test failed`),detail:r,logPath:s}}const p=String(d.stdout||d.stderr||"").trim();let f;if(p)try{f=JSON.parse(p)}catch{}let y=0===d.exitCode&&Boolean(!f||!1!==f.ok),S=x(p,`${e} self-test completed`);"gateway"===e&&w&&!w.ok?(y=!1,S=x(w.stderr||w.stdout,"Gateway handshake probe failed.")):"gateway"===e&&w?.ok&&(S="Gateway MCP handshake OK");const C={target:e,ok:y,summary:S,launch:c,contextFilePath:g(),selfTest:{exitCode:d.exitCode,stdout:d.stdout,stderr:d.stderr,result:f??null},handshakeProbe:w?{ok:w.ok,exitCode:w.exitCode,stdout:w.stdout,stderr:w.stderr,responseText:w.responseText}:null,ts:(new Date).toISOString()};return{ok:y,summary:S,detail:p||S,logPath:await m({target:e,payload:C}),result:f}}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"node:crypto";import r from"node:fs/promises";import e from"node:path";export const createGatewayFileBridgeService=({getMacroSnapshot:a,getMacroCalendar:i,getMacroNews:o,emitLog:n,getWorkingDir:s})=>{let c=null,d=null,l=!1;const w=(t,r)=>n?.(`[gateway-file-bridge] ${t}`,r),f=()=>e.join(s(),"weget-gateway-file-bridge"),y=()=>e.join(f(),"requests"),u=()=>e.join(f(),"responses"),m=async(t,a)=>{const i=e.join(u(),`${t}.json`);await r.writeFile(i,`${JSON.stringify(a,null,2)}\n`,"utf8")},g=async t=>{const e=await r.readFile(t,"utf8"),n=JSON.parse(e),s=String(n.id||"").trim(),d=String(n.token||"").trim();if(s)if(c&&d===c.token)try{if("macro_snapshot"===n.action){const t=await a({force:Boolean(n.payload?.force)});return void await m(s,{ok:!0,snapshot:t})}if("macro_calendar"===n.action){const t=String(n.payload?.dateKey||"").trim();if(!t)throw new Error("dateKey is required");const r=await i({dateKey:t});return void await m(s,{ok:!0,rows:r})}if("macro_news"===n.action){const t=String(n.payload?.dateKey||"").trim();if(!t)throw new Error("dateKey is required");const r=await o({dateKey:t});return void await m(s,{ok:!0,rows:r})}await m(s,{ok:!1,error:`unsupported action: ${n.action}`})}catch(t){await m(s,{ok:!1,error:t instanceof Error?t.message:String(t)})}finally{await r.unlink(t).catch(()=>{})}else await m(s,{ok:!1,error:"unauthorized"})};return{ensureStarted:async()=>c||(await(async()=>{await r.mkdir(y(),{recursive:!0}),await r.mkdir(u(),{recursive:!0})})(),c={dir:f(),token:t.randomUUID()},d=setInterval(()=>{(async()=>{if(!l){l=!0;try{const t=(await r.readdir(y()).catch(()=>[])).filter(t=>t.endsWith(".json")).slice(0,8);for(const r of t)await g(e.join(y(),r))}finally{l=!1}}})()},100),w("started",{dir:c.dir}),c),getContext:()=>c,stop:async()=>{var t;d&&clearInterval(d),d=null,c=null,await(t=0,new Promise(r=>setTimeout(r,t))),w("stopped")}}};
|