@fefeding/aicmd 0.1.15 → 1.0.3

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.
@@ -1,6 +1,6 @@
1
1
  import { i as __toESM, n as __esmMin, t as __commonJSMin } from "./rolldown-runtime.js";
2
- import { C as createBlock, D as createVNode, E as createTextVNode, F as onMounted, H as withCtx, L as openBlock, N as nextTick, O as defineComponent, P as onBeforeUnmount, Q as ref, R as renderList, S as createBaseVNode, T as createElementBlock, U as withDirectives, V as watch, Z as reactive, _ as vShow, at as toDisplayString, b as Fragment, c as useI18n, f as vModelCheckbox, g as vModelText, h as vModelSelect, it as normalizeStyle, l as init_vue_runtime_esm_bundler, m as vModelRadio, p as vModelDynamic, rt as normalizeClass, s as init_vue_i18n, tt as unref, v as withKeys, w as createCommentVNode, x as computed, y as withModifiers } from "./vue.js";
3
- import { _ as config_default, a as init_modal$2, b as axios$1, c as toast, d as defineStore, f as init_pinia, g as setLocale, h as init_i18n, i as showConfirm, l as _plugin_vue_export_helper_default, m as i18n, n as init_modal$1, o as modal_default, p as getLocale, r as showAlert, s as init_toast, t as getModalInstance, u as init__plugin_vue_export_helper, v as init_config, y as init_axios } from "./index.js";
2
+ import { $ as ref, C as createBaseVNode, D as createTextVNode, E as createElementBlock, F as onBeforeUnmount, H as watch, I as onMounted, O as createVNode, P as nextTick, Q as reactive, R as openBlock, S as computed, T as createCommentVNode, U as withCtx, W as withDirectives, _ as vModelText, at as normalizeStyle, b as withModifiers, c as useI18n, g as vModelSelect, h as vModelRadio, it as normalizeClass, k as defineComponent, l as init_vue_runtime_esm_bundler, m as vModelDynamic, nt as unref, ot as toDisplayString, p as vModelCheckbox, s as init_vue_i18n, v as vShow, w as createBlock, x as Fragment, y as withKeys, z as renderList } from "./vue.js";
3
+ import { C as subscribe, S as init_eventBus, _ as config_default, a as init_modal$2, b as axios$1, c as toast, d as defineStore, f as init_pinia, g as setLocale, h as init_i18n, i as showConfirm, l as _plugin_vue_export_helper_default, m as i18n, n as init_modal$1, o as modal_default, p as getLocale, r as showAlert, s as init_toast, t as getModalInstance, u as init__plugin_vue_export_helper, v as init_config, w as unsubscribe, y as init_axios } from "./index.js";
4
4
  import { i as require_xterm, n as require_addon_web_links, r as require_addon_fit, t as init_xterm } from "./xterm.js";
5
5
  //#region src/utils/request.ts
6
6
  async function request$1(url, data, option) {
@@ -36,7 +36,7 @@ var init_detect = __esmMin((() => {
36
36
  return false;
37
37
  }
38
38
  })();
39
- isElectron = typeof process === "object" && process.versions?.electron !== void 0;
39
+ isElectron = typeof process === "object" && process.versions?.electron !== void 0 || Boolean(typeof window !== "undefined" && window.electronAPI?.isElectron);
40
40
  isBrowser = typeof window !== "undefined" && !isNWjs && !isVSCode && !isChromeExtension && !isElectron;
41
41
  isBrowser && window.top;
42
42
  UA = isBrowser ? navigator.userAgent : "";
@@ -3353,12 +3353,52 @@ var init_audit = __esmMin((() => {
3353
3353
  init_base();
3354
3354
  }));
3355
3355
  //#endregion
3356
+ //#region src/utils/clipboard.ts
3357
+ function copyText(text) {
3358
+ const clip = window.electronAPI?.clipboard;
3359
+ if (clip) try {
3360
+ clip.writeText(text);
3361
+ return true;
3362
+ } catch {
3363
+ return false;
3364
+ }
3365
+ const textarea = document.createElement("textarea");
3366
+ textarea.value = text;
3367
+ textarea.setAttribute("readonly", "");
3368
+ document.body.appendChild(textarea);
3369
+ textarea.select();
3370
+ try {
3371
+ return document.execCommand("copy");
3372
+ } catch {
3373
+ return false;
3374
+ } finally {
3375
+ document.body.removeChild(textarea);
3376
+ }
3377
+ }
3378
+ async function copy(text) {
3379
+ const clip = window.electronAPI?.clipboard;
3380
+ if (clip) try {
3381
+ clip.writeText(text);
3382
+ return true;
3383
+ } catch {
3384
+ return false;
3385
+ }
3386
+ try {
3387
+ await navigator.clipboard.writeText(text);
3388
+ return true;
3389
+ } catch {
3390
+ return copyText(text);
3391
+ }
3392
+ }
3393
+ var init_clipboard = __esmMin((() => {}));
3394
+ //#endregion
3356
3395
  //#region src/components/audit-panel/index.vue?vue&type=script&setup=true&lang.ts
3357
3396
  var _hoisted_1$8, _hoisted_2$8, _hoisted_3$8, _hoisted_4$8, _hoisted_5$8, _hoisted_6$7, _hoisted_7$7, _hoisted_8$7, _hoisted_9$7, _hoisted_10$7, _hoisted_11$7, _hoisted_12$7, _hoisted_13$7, _hoisted_14$7, _hoisted_15$7, _hoisted_16$7, _hoisted_17$6, _hoisted_18$6, _hoisted_19$6, _hoisted_20$6, _hoisted_21$5, _hoisted_22$5, _hoisted_23$4, _hoisted_24$4, _hoisted_25$3, _hoisted_26$3, _hoisted_27$3, _hoisted_28$3, _hoisted_29$3, _hoisted_30$3, _hoisted_31$3, _hoisted_32$2, _hoisted_33$2, _hoisted_34$2, _hoisted_35$2, _hoisted_36$2, _hoisted_37$2, _hoisted_38$2, _hoisted_39$2, _hoisted_40$2, _hoisted_41$2, index_vue_vue_type_script_setup_true_lang_default$6;
3358
3397
  var init_index_vue_vue_type_script_setup_true_lang$6 = __esmMin((() => {
3359
3398
  init_vue_runtime_esm_bundler();
3360
3399
  init_vue_i18n();
3361
3400
  init_audit();
3401
+ init_clipboard();
3362
3402
  _hoisted_1$8 = { class: "audit-panel" };
3363
3403
  _hoisted_2$8 = { class: "audit-header" };
3364
3404
  _hoisted_3$8 = { class: "audit-header-left" };
@@ -3494,7 +3534,7 @@ var init_index_vue_vue_type_script_setup_true_lang$6 = __esmMin((() => {
3494
3534
  }
3495
3535
  }
3496
3536
  function copyText(text) {
3497
- navigator.clipboard.writeText(text).catch(() => {});
3537
+ copy(text);
3498
3538
  }
3499
3539
  /** 添加实时审计条目(从 WebSocket 调用) */
3500
3540
  function addRealtimeEntry(entry) {
@@ -3593,17 +3633,17 @@ var init_index_vue_vue_type_script_setup_true_lang$6 = __esmMin((() => {
3593
3633
  });
3594
3634
  }));
3595
3635
  //#endregion
3596
- //#region src/components/audit-panel/index.vue?vue&type=style&index=0&scoped=6149c4f8&lang.css
3597
- var init_index_vue_vue_type_style_index_0_scoped_6149c4f8_lang = __esmMin((() => {}));
3636
+ //#region src/components/audit-panel/index.vue?vue&type=style&index=0&scoped=88945d8c&lang.css
3637
+ var init_index_vue_vue_type_style_index_0_scoped_88945d8c_lang = __esmMin((() => {}));
3598
3638
  //#endregion
3599
3639
  //#region src/components/audit-panel/index.vue
3600
3640
  var audit_panel_default;
3601
3641
  var init_audit_panel = __esmMin((() => {
3602
3642
  init_index_vue_vue_type_script_setup_true_lang$6();
3603
3643
  init_index_vue_vue_type_script_setup_true_lang$6();
3604
- init_index_vue_vue_type_style_index_0_scoped_6149c4f8_lang();
3644
+ init_index_vue_vue_type_style_index_0_scoped_88945d8c_lang();
3605
3645
  init__plugin_vue_export_helper();
3606
- audit_panel_default = /* @__PURE__ */ _plugin_vue_export_helper_default(index_vue_vue_type_script_setup_true_lang_default$6, [["__scopeId", "data-v-6149c4f8"]]);
3646
+ audit_panel_default = /* @__PURE__ */ _plugin_vue_export_helper_default(index_vue_vue_type_script_setup_true_lang_default$6, [["__scopeId", "data-v-88945d8c"]]);
3607
3647
  }));
3608
3648
  //#endregion
3609
3649
  //#region src/service/monitor.ts
@@ -4446,11 +4486,10 @@ var init_index_vue_vue_type_script_setup_true_lang$4 = __esmMin((() => {
4446
4486
  messages.value = [];
4447
4487
  currentAssistantIdx = -1;
4448
4488
  loadDisplayHistory();
4449
- });
4489
+ }, { immediate: true });
4450
4490
  onMounted(() => {
4451
4491
  if (props.isOpen) inputRef.value?.focus();
4452
4492
  loadSkills();
4453
- loadDisplayHistory();
4454
4493
  });
4455
4494
  __expose({
4456
4495
  handleAgentEvent,
@@ -4608,17 +4647,17 @@ var init_index_vue_vue_type_script_setup_true_lang$4 = __esmMin((() => {
4608
4647
  });
4609
4648
  }));
4610
4649
  //#endregion
4611
- //#region src/components/ai-chat/index.vue?vue&type=style&index=0&scoped=e20ce435&lang.css
4612
- var init_index_vue_vue_type_style_index_0_scoped_e20ce435_lang = __esmMin((() => {}));
4650
+ //#region src/components/ai-chat/index.vue?vue&type=style&index=0&scoped=eed12088&lang.css
4651
+ var init_index_vue_vue_type_style_index_0_scoped_eed12088_lang = __esmMin((() => {}));
4613
4652
  //#endregion
4614
4653
  //#region src/components/ai-chat/index.vue
4615
4654
  var ai_chat_default;
4616
4655
  var init_ai_chat = __esmMin((() => {
4617
4656
  init_index_vue_vue_type_script_setup_true_lang$4();
4618
4657
  init_index_vue_vue_type_script_setup_true_lang$4();
4619
- init_index_vue_vue_type_style_index_0_scoped_e20ce435_lang();
4658
+ init_index_vue_vue_type_style_index_0_scoped_eed12088_lang();
4620
4659
  init__plugin_vue_export_helper();
4621
- ai_chat_default = /* @__PURE__ */ _plugin_vue_export_helper_default(index_vue_vue_type_script_setup_true_lang_default$4, [["__scopeId", "data-v-e20ce435"]]);
4660
+ ai_chat_default = /* @__PURE__ */ _plugin_vue_export_helper_default(index_vue_vue_type_script_setup_true_lang_default$4, [["__scopeId", "data-v-eed12088"]]);
4622
4661
  }));
4623
4662
  //#endregion
4624
4663
  //#region src/components/file-transfer.vue?vue&type=script&setup=true&lang.ts
@@ -4947,9 +4986,24 @@ var init_file_transfer_vue_vue_type_script_setup_true_lang = __esmMin((() => {
4947
4986
  }
4948
4987
  }
4949
4988
  /**
4950
- * 通过 HTTP POST 上传文件到服务端
4989
+ * 通过 HTTP POST 上传文件到服务端(Web 模式)
4990
+ * 或 IPC 上传到主进程(Electron 模式,app:// 协议下 fetch 不可用)
4951
4991
  */
4952
4992
  async function httpFileUpload(file, remoteName, sessionId) {
4993
+ const electronApi = window.electronAPI;
4994
+ if (electronApi?.api?.uploadFile) try {
4995
+ const buffer = await file.arrayBuffer();
4996
+ console.log(`[FileTransfer] IPC upload: ${file.name} -> ${remoteName}, size=${file.size}`);
4997
+ const result = await electronApi.api.uploadFile(sessionId || "", remoteName, buffer);
4998
+ console.log(`[FileTransfer] IPC upload result:`, result);
4999
+ return result;
5000
+ } catch (err) {
5001
+ console.error(`[FileTransfer] IPC upload error:`, err);
5002
+ return {
5003
+ success: false,
5004
+ error: err.message || "IPC upload failed"
5005
+ };
5006
+ }
4953
5007
  try {
4954
5008
  console.log(`[FileTransfer] POST /api/file-upload, size=${file.size}`);
4955
5009
  const data = await (await fetch("/api/file-upload", {
@@ -5165,17 +5219,17 @@ var init_file_transfer_vue_vue_type_script_setup_true_lang = __esmMin((() => {
5165
5219
  });
5166
5220
  }));
5167
5221
  //#endregion
5168
- //#region src/components/file-transfer.vue?vue&type=style&index=0&scoped=6efabb84&lang.css
5169
- var init_file_transfer_vue_vue_type_style_index_0_scoped_6efabb84_lang = __esmMin((() => {}));
5222
+ //#region src/components/file-transfer.vue?vue&type=style&index=0&scoped=c74be8ef&lang.css
5223
+ var init_file_transfer_vue_vue_type_style_index_0_scoped_c74be8ef_lang = __esmMin((() => {}));
5170
5224
  //#endregion
5171
5225
  //#region src/components/file-transfer.vue
5172
5226
  var file_transfer_default;
5173
5227
  var init_file_transfer = __esmMin((() => {
5174
5228
  init_file_transfer_vue_vue_type_script_setup_true_lang();
5175
5229
  init_file_transfer_vue_vue_type_script_setup_true_lang();
5176
- init_file_transfer_vue_vue_type_style_index_0_scoped_6efabb84_lang();
5230
+ init_file_transfer_vue_vue_type_style_index_0_scoped_c74be8ef_lang();
5177
5231
  init__plugin_vue_export_helper();
5178
- file_transfer_default = /* @__PURE__ */ _plugin_vue_export_helper_default(file_transfer_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-6efabb84"]]);
5232
+ file_transfer_default = /* @__PURE__ */ _plugin_vue_export_helper_default(file_transfer_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-c74be8ef"]]);
5179
5233
  }));
5180
5234
  //#endregion
5181
5235
  //#region src/components/terminal-tab.vue?vue&type=script&setup=true&lang.ts
@@ -5249,6 +5303,7 @@ var init_terminal_tab_vue_vue_type_script_setup_true_lang = __esmMin((() => {
5249
5303
  let ws = null;
5250
5304
  let ipcCleanup = null;
5251
5305
  let sessionId = null;
5306
+ const pendingSessionId = `ssh-${Date.now()}-${Math.random().toString(36).substr(2, 8)}`;
5252
5307
  let resizeObserver = null;
5253
5308
  let sentry = null;
5254
5309
  let zmodemSession = null;
@@ -5327,27 +5382,56 @@ var init_terminal_tab_vue_vue_type_script_setup_true_lang = __esmMin((() => {
5327
5382
  terminal.onData((data) => {
5328
5383
  sendToServer({
5329
5384
  type: "terminal",
5330
- sessionId: sessionId || void 0,
5385
+ sessionId: sessionId || pendingSessionId,
5331
5386
  data
5332
5387
  });
5333
5388
  });
5334
5389
  terminal.onBinary((data) => {
5335
5390
  sendToServer({
5336
5391
  type: "terminal",
5337
- sessionId: sessionId || void 0,
5392
+ sessionId: sessionId || pendingSessionId,
5338
5393
  data
5339
5394
  });
5340
5395
  });
5341
5396
  terminal.onResize(({ cols, rows }) => {
5342
5397
  sendToServer({
5343
5398
  type: "resize",
5344
- sessionId: sessionId || void 0,
5399
+ sessionId: sessionId || pendingSessionId,
5345
5400
  data: {
5346
5401
  cols,
5347
5402
  rows
5348
5403
  }
5349
5404
  });
5350
5405
  });
5406
+ terminal.attachCustomKeyEventHandler((event) => {
5407
+ const modKey = window.electronAPI?.platform === "darwin" || navigator.platform.includes("Mac") ? event.metaKey : event.ctrlKey;
5408
+ const key = event.key.toLowerCase();
5409
+ const isCopyTrigger = modKey && key === "c";
5410
+ const isPasteTrigger = modKey && key === "v";
5411
+ if (!isCopyTrigger && !isPasteTrigger) return true;
5412
+ const clip = window.electronAPI?.clipboard;
5413
+ const hasSelection = !!(terminal && terminal.getSelection());
5414
+ if (isCopyTrigger) {
5415
+ if (hasSelection) {
5416
+ const text = terminal.getSelection();
5417
+ if (clip) clip.writeText(text);
5418
+ else navigator.clipboard?.writeText(text).catch(() => {});
5419
+ return false;
5420
+ }
5421
+ if (event.shiftKey) return false;
5422
+ return true;
5423
+ }
5424
+ if (isPasteTrigger) {
5425
+ const text = clip ? clip.readText() : "";
5426
+ if (text && terminal) sendToServer({
5427
+ type: "terminal",
5428
+ sessionId: sessionId || pendingSessionId,
5429
+ data: text
5430
+ });
5431
+ return false;
5432
+ }
5433
+ return true;
5434
+ });
5351
5435
  initSentry();
5352
5436
  }
5353
5437
  function initSentry() {
@@ -5363,7 +5447,7 @@ var init_terminal_tab_vue_vue_type_script_setup_true_lang = __esmMin((() => {
5363
5447
  const b64 = octetsToBase64(octets);
5364
5448
  if (ws && ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({
5365
5449
  type: "terminal",
5366
- sessionId: sessionId || void 0,
5450
+ sessionId: sessionId || pendingSessionId,
5367
5451
  data: b64,
5368
5452
  binary: true
5369
5453
  }));
@@ -5523,6 +5607,7 @@ var init_terminal_tab_vue_vue_type_script_setup_true_lang = __esmMin((() => {
5523
5607
  console.log(`[TerminalTab] WebSocket connected, sending create`);
5524
5608
  sendToServer({
5525
5609
  type: "create",
5610
+ sessionId: pendingSessionId,
5526
5611
  data: {
5527
5612
  connectionId: props.connection.id,
5528
5613
  cols: terminal?.cols || 80,
@@ -5574,7 +5659,7 @@ var init_terminal_tab_vue_vue_type_script_setup_true_lang = __esmMin((() => {
5574
5659
  if (!ws || ws.readyState === WebSocket.CLOSED || ws.readyState === WebSocket.CLOSING) connectWebSocket();
5575
5660
  else sendToServer({
5576
5661
  type: "reconnect",
5577
- sessionId: sessionId || void 0,
5662
+ sessionId: sessionId || pendingSessionId,
5578
5663
  data: {
5579
5664
  connectionId: props.connection.id,
5580
5665
  cols: terminal?.cols || 80,
@@ -5645,7 +5730,7 @@ var init_terminal_tab_vue_vue_type_script_setup_true_lang = __esmMin((() => {
5645
5730
  const b64 = octetsToBase64(octets);
5646
5731
  if (ws && ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({
5647
5732
  type: "terminal",
5648
- sessionId: sessionId || void 0,
5733
+ sessionId: sessionId || pendingSessionId,
5649
5734
  data: b64,
5650
5735
  binary: true
5651
5736
  }));
@@ -5706,6 +5791,8 @@ var init_terminal_tab_vue_vue_type_script_setup_true_lang = __esmMin((() => {
5706
5791
  });
5707
5792
  }
5708
5793
  function handleServerMessage(msg) {
5794
+ const myId = sessionId || pendingSessionId;
5795
+ if (msg.sessionId && myId && msg.sessionId !== myId) return;
5709
5796
  switch (msg.type) {
5710
5797
  case "terminal":
5711
5798
  if (msg.data && sentry) {
@@ -5955,17 +6042,17 @@ var init_terminal_tab_vue_vue_type_script_setup_true_lang = __esmMin((() => {
5955
6042
  });
5956
6043
  }));
5957
6044
  //#endregion
5958
- //#region src/components/terminal-tab.vue?vue&type=style&index=0&scoped=3f00519a&lang.css
5959
- var init_terminal_tab_vue_vue_type_style_index_0_scoped_3f00519a_lang = __esmMin((() => {}));
6045
+ //#region src/components/terminal-tab.vue?vue&type=style&index=0&scoped=a2ff4224&lang.css
6046
+ var init_terminal_tab_vue_vue_type_style_index_0_scoped_a2ff4224_lang = __esmMin((() => {}));
5960
6047
  //#endregion
5961
6048
  //#region src/components/terminal-tab.vue
5962
6049
  var terminal_tab_default;
5963
6050
  var init_terminal_tab = __esmMin((() => {
5964
6051
  init_terminal_tab_vue_vue_type_script_setup_true_lang();
5965
6052
  init_terminal_tab_vue_vue_type_script_setup_true_lang();
5966
- init_terminal_tab_vue_vue_type_style_index_0_scoped_3f00519a_lang();
6053
+ init_terminal_tab_vue_vue_type_style_index_0_scoped_a2ff4224_lang();
5967
6054
  init__plugin_vue_export_helper();
5968
- terminal_tab_default = /* @__PURE__ */ _plugin_vue_export_helper_default(terminal_tab_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-3f00519a"]]);
6055
+ terminal_tab_default = /* @__PURE__ */ _plugin_vue_export_helper_default(terminal_tab_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-a2ff4224"]]);
5969
6056
  }));
5970
6057
  //#endregion
5971
6058
  //#region src/components/connection-editor/index.vue?vue&type=script&setup=true&lang.ts
@@ -6637,6 +6724,7 @@ var init_index_vue_vue_type_script_setup_true_lang$1 = __esmMin((() => {
6637
6724
  init_vue_i18n();
6638
6725
  init_batch();
6639
6726
  init_terminal$1();
6727
+ init_clipboard();
6640
6728
  _hoisted_1$1 = { class: "batch-panel" };
6641
6729
  _hoisted_2$1 = { class: "batch-controls" };
6642
6730
  _hoisted_3$1 = { class: "batch-input-row" };
@@ -6755,7 +6843,7 @@ var init_index_vue_vue_type_script_setup_true_lang$1 = __esmMin((() => {
6755
6843
  return `${(ms / 1e3).toFixed(1)}s`;
6756
6844
  }
6757
6845
  function copyText(text) {
6758
- navigator.clipboard.writeText(text).catch(() => {});
6846
+ copy(text);
6759
6847
  }
6760
6848
  onMounted(async () => {
6761
6849
  await loadSessions();
@@ -6834,17 +6922,17 @@ var init_index_vue_vue_type_script_setup_true_lang$1 = __esmMin((() => {
6834
6922
  });
6835
6923
  }));
6836
6924
  //#endregion
6837
- //#region src/components/batch-panel/index.vue?vue&type=style&index=0&scoped=2a808712&lang.css
6838
- var init_index_vue_vue_type_style_index_0_scoped_2a808712_lang = __esmMin((() => {}));
6925
+ //#region src/components/batch-panel/index.vue?vue&type=style&index=0&scoped=3a165556&lang.css
6926
+ var init_index_vue_vue_type_style_index_0_scoped_3a165556_lang = __esmMin((() => {}));
6839
6927
  //#endregion
6840
6928
  //#region src/components/batch-panel/index.vue
6841
6929
  var batch_panel_default;
6842
6930
  var init_batch_panel = __esmMin((() => {
6843
6931
  init_index_vue_vue_type_script_setup_true_lang$1();
6844
6932
  init_index_vue_vue_type_script_setup_true_lang$1();
6845
- init_index_vue_vue_type_style_index_0_scoped_2a808712_lang();
6933
+ init_index_vue_vue_type_style_index_0_scoped_3a165556_lang();
6846
6934
  init__plugin_vue_export_helper();
6847
- batch_panel_default = /* @__PURE__ */ _plugin_vue_export_helper_default(index_vue_vue_type_script_setup_true_lang_default$1, [["__scopeId", "data-v-2a808712"]]);
6935
+ batch_panel_default = /* @__PURE__ */ _plugin_vue_export_helper_default(index_vue_vue_type_script_setup_true_lang_default$1, [["__scopeId", "data-v-3a165556"]]);
6848
6936
  }));
6849
6937
  //#endregion
6850
6938
  //#region src/views/index.vue?vue&type=script&setup=true&lang.ts
@@ -6852,6 +6940,7 @@ var _hoisted_1, _hoisted_2, _hoisted_3, _hoisted_4, _hoisted_5, _hoisted_6, _hoi
6852
6940
  var init_index_vue_vue_type_script_setup_true_lang = __esmMin((() => {
6853
6941
  init_vue_runtime_esm_bundler();
6854
6942
  init_vue_i18n();
6943
+ init_eventBus();
6855
6944
  init_terminal();
6856
6945
  init_terminal$1();
6857
6946
  init_terminal_sidebar();
@@ -7021,15 +7110,20 @@ var init_index_vue_vue_type_script_setup_true_lang = __esmMin((() => {
7021
7110
  store.toggleSidebar();
7022
7111
  }
7023
7112
  }
7113
+ let menuNewConnSubId = null;
7024
7114
  onMounted(async () => {
7025
7115
  await store.loadConnections();
7026
7116
  await restoreOrCreateTabs();
7027
7117
  document.addEventListener("keydown", handleKeydown);
7028
7118
  document.addEventListener("click", hideContextMenu);
7119
+ menuNewConnSubId = subscribe("MENU_NEW_CONNECTION", () => {
7120
+ openEditor();
7121
+ });
7029
7122
  });
7030
7123
  onBeforeUnmount(() => {
7031
7124
  document.removeEventListener("keydown", handleKeydown);
7032
7125
  document.removeEventListener("click", hideContextMenu);
7126
+ if (menuNewConnSubId) unsubscribe(menuNewConnSubId);
7033
7127
  });
7034
7128
  /**
7035
7129
  * 从 server 端恢复 TAB 信息
@@ -7211,8 +7305,8 @@ var init_index_vue_vue_type_script_setup_true_lang = __esmMin((() => {
7211
7305
  });
7212
7306
  }));
7213
7307
  //#endregion
7214
- //#region src/views/index.vue?vue&type=style&index=0&scoped=c7fee8c8&lang.css
7215
- var init_index_vue_vue_type_style_index_0_scoped_c7fee8c8_lang = __esmMin((() => {}));
7308
+ //#region src/views/index.vue?vue&type=style&index=0&scoped=5cfb7c8d&lang.css
7309
+ var init_index_vue_vue_type_style_index_0_scoped_5cfb7c8d_lang = __esmMin((() => {}));
7216
7310
  //#endregion
7217
7311
  //#region src/views/index.vue
7218
7312
  var views_default;
@@ -7220,8 +7314,8 @@ var views_default;
7220
7314
  __esmMin((() => {
7221
7315
  init_index_vue_vue_type_script_setup_true_lang();
7222
7316
  init_index_vue_vue_type_script_setup_true_lang();
7223
- init_index_vue_vue_type_style_index_0_scoped_c7fee8c8_lang();
7317
+ init_index_vue_vue_type_style_index_0_scoped_5cfb7c8d_lang();
7224
7318
  init__plugin_vue_export_helper();
7225
- views_default = /* @__PURE__ */ _plugin_vue_export_helper_default(index_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-c7fee8c8"]]);
7319
+ views_default = /* @__PURE__ */ _plugin_vue_export_helper_default(index_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-5cfb7c8d"]]);
7226
7320
  }))();
7227
7321
  export { views_default as default };
@@ -12873,4 +12873,4 @@ var init_core = __esmMin((() => {
12873
12873
  Number.POSITIVE_INFINITY;
12874
12874
  }));
12875
12875
  //#endregion
12876
- export { toRaw as $, hasInjectionContext as A, resolveComponent as B, createBlock as C, createVNode as D, createTextVNode as E, onMounted as F, getCurrentScope as G, withCtx as H, onUnmounted as I, isRef as J, init_reactivity_esm_bundler as K, openBlock as L, inject as M, nextTick as N, defineComponent as O, onBeforeUnmount as P, ref as Q, renderList as R, createBaseVNode as S, createElementBlock as T, withDirectives as U, watch as V, effectScope as W, onScopeDispose as X, markRaw as Y, reactive as Z, vShow as _, init_vue_router as a, toDisplayString$1 as at, Fragment as b, useI18n as c, init_runtime_dom_esm_bundler as d, toRefs as et, vModelCheckbox as f, vModelText as g, vModelSelect as h, createWebHistory as i, normalizeStyle as it, init_runtime_core_esm_bundler as j, getCurrentInstance$1 as k, init_vue_runtime_esm_bundler as l, vModelRadio as m, useTitle as n, init_shared_esm_bundler as nt, createI18n as o, vModelDynamic as p, isReactive as q, createRouter as r, normalizeClass as rt, init_vue_i18n as s, init_core as t, unref as tt, createApp as u, withKeys as v, createCommentVNode as w, computed as x, withModifiers as y, renderSlot as z };
12876
+ export { ref as $, getCurrentInstance$1 as A, renderSlot as B, createBaseVNode as C, createTextVNode as D, createElementBlock as E, onBeforeUnmount as F, effectScope as G, watch as H, onMounted as I, isReactive as J, getCurrentScope as K, onUnmounted as L, init_runtime_core_esm_bundler as M, inject as N, createVNode as O, nextTick as P, reactive as Q, openBlock as R, computed as S, createCommentVNode as T, withCtx as U, resolveComponent as V, withDirectives as W, markRaw as X, isRef as Y, onScopeDispose as Z, vModelText as _, init_vue_router as a, normalizeStyle as at, withModifiers as b, useI18n as c, createApp as d, toRaw as et, init_runtime_dom_esm_bundler as f, vModelSelect as g, vModelRadio as h, createWebHistory as i, normalizeClass as it, hasInjectionContext as j, defineComponent as k, init_vue_runtime_esm_bundler as l, vModelDynamic as m, useTitle as n, unref as nt, createI18n as o, toDisplayString$1 as ot, vModelCheckbox as p, init_reactivity_esm_bundler as q, createRouter as r, init_shared_esm_bundler as rt, init_vue_i18n as s, init_core as t, toRefs as tt, Transition as u, vShow as v, createBlock as w, Fragment as x, withKeys as y, renderList as z };
@@ -1,7 +1,5 @@
1
1
  import { AuditService } from './audit.service';
2
- /**
3
- * AI 配置接口
4
- */
2
+ import type { Message, ToolDefinition } from '@cicctencent/agent-core';
5
3
  export interface AIConfig {
6
4
  enabled: boolean;
7
5
  apiKey: string;
@@ -10,34 +8,9 @@ export interface AIConfig {
10
8
  maxTokens?: number;
11
9
  temperature?: number;
12
10
  }
13
- /**
14
- * 对话消息接口(支持 tool calling)
15
- */
16
- export interface ChatMessage {
17
- role: 'system' | 'user' | 'assistant' | 'tool';
18
- content: string | null;
19
- tool_calls?: ToolCall[];
20
- tool_call_id?: string;
21
- name?: string;
22
- }
23
- /**
24
- * 工具调用接口(OpenAI function calling 格式)
25
- */
26
- export interface ToolCall {
27
- id: string;
28
- type: 'function';
29
- function: {
30
- name: string;
31
- arguments: string;
32
- };
33
- }
34
- /**
35
- * Agent 事件类型
36
- */
11
+ /** Agent 事件类型 */
37
12
  export type AgentEventType = 'thinking' | 'message' | 'tool_call' | 'tool_result' | 'audit_entry' | 'done' | 'error' | 'system_info';
38
- /**
39
- * Agent 事件
40
- */
13
+ /** Agent 事件(应用层简化格式) */
41
14
  export interface AgentEvent {
42
15
  type: AgentEventType;
43
16
  content?: string;
@@ -47,22 +20,8 @@ export interface AgentEvent {
47
20
  error?: string;
48
21
  auditEntry?: any;
49
22
  }
50
- /** Agent 事件回调 */
51
23
  export type AgentEventCallback = (event: AgentEvent) => void;
52
- /**
53
- * 工具定义(OpenAI tools 格式)
54
- */
55
- export interface ToolDefinition {
56
- type: 'function';
57
- function: {
58
- name: string;
59
- description: string;
60
- parameters: object;
61
- };
62
- }
63
- /** 工具执行器 */
64
24
  export type ToolExecutor = (args: any, sessionId: string) => Promise<string>;
65
- /** 前端显示消息(持久化用) */
66
25
  export interface DisplayMessage {
67
26
  role: 'user' | 'assistant';
68
27
  content: string;
@@ -77,7 +36,6 @@ export interface DisplayAgentStep {
77
36
  result?: string;
78
37
  collapsed?: boolean;
79
38
  }
80
- /** 历史文件元数据 */
81
39
  export interface HistoryMeta {
82
40
  sessionId: string;
83
41
  sessionName?: string;
@@ -97,29 +55,29 @@ interface ISkillService {
97
55
  content: string;
98
56
  } | undefined;
99
57
  }
100
- /**
101
- * AI Agent 服务 - 支持工具调用和自主操作终端
102
- */
103
58
  export declare class AIService {
104
59
  private configDir;
105
60
  private configPath;
106
61
  private config;
107
62
  private historyDir;
108
- /** LLM 上下文消息持久化目录(项目执行目录下 data/messages) */
109
63
  private messagesDir;
110
- private chatHistories;
111
- /** 已从文件加载过的 sessionId 集合 */
112
- private loadedSessions;
113
- private agentStates;
64
+ private llmProvider?;
114
65
  private toolRegistry;
66
+ private contextManager;
67
+ private securityGuard;
68
+ private engine?;
69
+ private abortControllers;
70
+ private loadedSessions;
115
71
  private sshService?;
116
72
  private skillService?;
117
73
  private auditService?;
118
- private readonly MAX_HISTORY_AGE;
119
74
  private readonly MAX_MESSAGES;
120
75
  private readonly MAX_AGENT_ITERATIONS;
121
- private readonly AGENT_SYSTEM_PROMPT;
122
76
  constructor(sshService?: ISSHService, skillService?: ISkillService, auditService?: AuditService);
77
+ private ensureLLMProvider;
78
+ private resetProviderAndEngine;
79
+ private getEngine;
80
+ private buildHooks;
123
81
  private getDefaultConfig;
124
82
  private loadConfig;
125
83
  private saveConfig;
@@ -128,7 +86,6 @@ export declare class AIService {
128
86
  private getEncryptionKey;
129
87
  private encryptSecret;
130
88
  private decryptSecret;
131
- private cleanupOldHistories;
132
89
  getConfig(): AIConfig;
133
90
  getFullConfig(): AIConfig;
134
91
  updateConfig(updates: Partial<AIConfig>): AIConfig;
@@ -136,94 +93,29 @@ export declare class AIService {
136
93
  success: boolean;
137
94
  message: string;
138
95
  }>;
139
- /**
140
- * 注册工具
141
- */
142
96
  registerTool(name: string, definition: ToolDefinition, executor: ToolExecutor): void;
143
- /**
144
- * 获取所有工具定义(OpenAI tools 格式)
145
- */
146
97
  getToolDefinitions(): ToolDefinition[];
147
- /**
148
- * 注册内置工具
149
- */
150
98
  private registerBuiltinTools;
151
- /**
152
- * 检测会话是否为 Windows 环境
153
- */
154
99
  private isWindowsSession;
155
- /**
156
- * 危险命令拦截:将 rm/Remove-Item 转换为移动到回收站,阻止极端破坏性操作
157
- */
158
100
  private sanitizeCommand;
159
- /**
160
- * Unix (Linux/macOS) 命令安全检查
161
- */
162
- private sanitizeUnixCommand;
163
- /**
164
- * Windows (PowerShell) 命令安全检查
165
- */
166
101
  private sanitizeWindowsCommand;
167
- /**
168
- * 执行命令并捕获输出
169
- */
170
102
  private executeCommand;
171
- /**
172
- * 读取终端当前输出
173
- */
174
103
  private readTerminal;
175
- private getOrCreateHistory;
176
- private addMessage;
104
+ private getSessionContext;
105
+ private mapCoreEvent;
106
+ agentRun(sessionId: string, userMessage: string, context: string | undefined, eventCallback: AgentEventCallback, skillId?: string, locale?: string): Promise<void>;
107
+ stopAgent(sessionId: string): boolean;
108
+ chat(sessionId: string, userMessage: string, context?: string): Promise<string>;
109
+ chatStream(sessionId: string, userMessage: string, context?: string): AsyncGenerator<string, void, unknown>;
177
110
  clearHistory(sessionId: string): void;
178
- getHistory(sessionId: string): ChatMessage[] | null;
179
- /**
180
- * 保存 LLM 上下文消息到 data/messages/{sessionId}.json
181
- */
111
+ getHistory(sessionId: string): Message[] | null;
182
112
  private saveChatMessages;
183
- /**
184
- * 从 data/messages/{sessionId}.json 加载 LLM 上下文消息
185
- */
186
113
  private loadChatMessages;
187
- /**
188
- * 删除 LLM 上下文消息文件
189
- */
190
114
  private deleteChatMessagesFile;
191
- /**
192
- * 保存前端显示消息到文件(含元数据)
193
- */
194
115
  saveDisplayHistory(sessionId: string, displayMessages: DisplayMessage[], sessionName?: string): void;
195
- /**
196
- * 加载前端显示消息(兼容新旧格式)
197
- */
198
116
  loadDisplayHistory(sessionId: string): DisplayMessage[] | null;
199
- /**
200
- * 列出所有历史对话(仅元数据)
201
- */
202
117
  listDisplayHistories(): HistoryMeta[];
203
- /**
204
- * 删除持久化的对话历史
205
- */
206
118
  deleteDisplayHistoryFile(sessionId: string): void;
207
- /**
208
- * 获取会话的系统上下文(从 sshService 的 session 元数据获取)
209
- * 保证每次对话都带上系统环境信息
210
- */
211
- private getSessionContext;
212
- /**
213
- * 运行 Agent
214
- * Agent 循环:调用 LLM → 处理 tool_calls → 执行工具 → 反馈结果 → 重复直到完成
215
- */
216
- agentRun(sessionId: string, userMessage: string, context: string | undefined, eventCallback: AgentEventCallback, skillId?: string, locale?: string): Promise<void>;
217
- /**
218
- * 停止 Agent
219
- */
220
- stopAgent(sessionId: string): boolean;
221
- /**
222
- * 调用 OpenAI API(非流式,用于 Agent 循环)
223
- */
224
- private callLLM;
225
- chat(sessionId: string, userMessage: string, context?: string): Promise<string>;
226
- chatStream(sessionId: string, userMessage: string, context?: string): AsyncGenerator<string, void, unknown>;
227
119
  }
228
120
  export {};
229
121
  //# sourceMappingURL=ai.service.d.ts.map