dsh-plugin-opc 0.1.11 → 0.1.12

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.
Files changed (3) hide show
  1. package/lib/client.js +155 -20
  2. package/lib/index.js +84 -42
  3. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -178,7 +178,7 @@ function registerMentions(ctx, api) {
178
178
  }
179
179
 
180
180
  // src/client/index.tsx
181
- var import_react11 = __toESM(require("react"), 1);
181
+ var import_react12 = __toESM(require("react"), 1);
182
182
 
183
183
  // node_modules/zod/v4/classic/external.js
184
184
  var external_exports = {};
@@ -19901,6 +19901,7 @@ function date4(params) {
19901
19901
  var contribution = { package: "dsh-plugin-opc", descriptors: [
19902
19902
  { id: "dsh-plugin-opc#opc/appList", service: "opc", namespace: "opc", method: "appList", invocation: { kind: "direct" }, parameters: [{ name: "expectedContextId", wire: "expectedContextId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appList:expectedContextId", create: () => external_exports.string() } }], result: { mode: "strict", typeSymbol: "opc/appList:result", create: () => external_exports.string() } },
19903
19903
  { id: "dsh-plugin-opc#opc/appJob", service: "opc", namespace: "opc", method: "appJob", invocation: { kind: "direct" }, parameters: [{ name: "id", wire: "id", source: "json", codec: { mode: "strict", typeSymbol: "opc/appJob:id", create: () => external_exports.string() } }, { name: "expectedContextId", wire: "expectedContextId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appJob:expectedContextId", create: () => external_exports.string() } }], result: { mode: "strict", typeSymbol: "opc/appJob:result", create: () => external_exports.string() } },
19904
+ { id: "dsh-plugin-opc#opc/appJobByAnalysisSession", service: "opc", namespace: "opc", method: "appJobByAnalysisSession", invocation: { kind: "direct" }, parameters: [{ name: "sessionId", wire: "sessionId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appJobByAnalysisSession:sessionId", create: () => external_exports.string() } }, { name: "expectedContextId", wire: "expectedContextId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appJobByAnalysisSession:expectedContextId", create: () => external_exports.string() } }], result: { mode: "strict", typeSymbol: "opc/appJobByAnalysisSession:result", create: () => external_exports.string() } },
19904
19905
  { id: "dsh-plugin-opc#opc/appCheckSlug", service: "opc", namespace: "opc", method: "appCheckSlug", invocation: { kind: "direct" }, parameters: [{ name: "slug", wire: "slug", source: "json", codec: { mode: "strict", typeSymbol: "opc/appCheckSlug:slug", create: () => external_exports.string() } }, { name: "expectedContextId", wire: "expectedContextId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appCheckSlug:expectedContextId", create: () => external_exports.string() } }], result: { mode: "strict", typeSymbol: "opc/appCheckSlug:result", create: () => external_exports.string() } },
19905
19906
  { id: "dsh-plugin-opc#opc/appOpcConfig", service: "opc", namespace: "opc", method: "appOpcConfig", invocation: { kind: "direct" }, parameters: [{ name: "expectedContextId", wire: "expectedContextId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appOpcConfig:expectedContextId", create: () => external_exports.string() } }], result: { mode: "strict", typeSymbol: "opc/appOpcConfig:result", create: () => external_exports.string() } },
19906
19907
  { id: "dsh-plugin-opc#opc/appPickSourceFolder", service: "opc", namespace: "opc", method: "appPickSourceFolder", invocation: { kind: "direct" }, parameters: [{ name: "expectedContextId", wire: "expectedContextId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appPickSourceFolder:expectedContextId", create: () => external_exports.string() } }], result: { mode: "strict", typeSymbol: "opc/appPickSourceFolder:result", create: () => external_exports.string() } },
@@ -30506,6 +30507,7 @@ function AppDeliveryReview({
30506
30507
  onReplaceSource,
30507
30508
  onNextStep,
30508
30509
  onInvalidate,
30510
+ beginAnalysisNavigation,
30509
30511
  initialFeedback = "",
30510
30512
  repairMode = false,
30511
30513
  onlineResources = [],
@@ -30593,15 +30595,16 @@ function AppDeliveryReview({
30593
30595
  const sendFeedback = async (customText, resume = false) => {
30594
30596
  const content3 = (customText ?? feedback).trim();
30595
30597
  if (!content3 && !resume || running || inFlight.current) return;
30598
+ const navigate = beginAnalysisNavigation?.();
30596
30599
  inFlight.current = true;
30597
30600
  setBusy(true);
30598
30601
  setError("");
30599
30602
  try {
30600
30603
  const mode = resume ? "resume" : repairMode || job?.analysis_mode === "repair" || job?.analysisMode === "repair" ? "repair" : "analysis";
30601
- if (api.appAnalyzeWithMode) {
30602
- await api.appAnalyzeWithMode(jobId, resume ? "" : content3, sessionId, mode, contextId);
30603
- } else {
30604
- await api.appAnalyze(jobId, content3, sessionId, contextId);
30604
+ const raw = api.appAnalyzeWithMode ? await api.appAnalyzeWithMode(jobId, resume ? "" : content3, sessionId, mode, contextId) : await api.appAnalyze(jobId, content3, sessionId, contextId);
30605
+ if (navigate) {
30606
+ const updated = JSON.parse(raw);
30607
+ if (updated?.id === jobId) navigate(updated);
30605
30608
  }
30606
30609
  onInvalidate?.();
30607
30610
  preparing.current = "";
@@ -56210,6 +56213,7 @@ function inferStepForJob(job) {
56210
56213
  case "ready":
56211
56214
  return 3;
56212
56215
  case "building":
56216
+ case "publishing":
56213
56217
  case "verifying":
56214
56218
  case "awaiting_page_verification":
56215
56219
  case "verified":
@@ -56217,6 +56221,7 @@ function inferStepForJob(job) {
56217
56221
  return 4;
56218
56222
  case "failed":
56219
56223
  if (job.failureStage === "import") return 1;
56224
+ if (job.failureStage === "deployment" || job.failureStage === "verification") return 4;
56220
56225
  if (job.failureStage === "analysis" || job.failureStage === "preparation" || job.analysis_failure && !job.published) return 2;
56221
56226
  if (job.published) return 4;
56222
56227
  if (job.proposal) return 2;
@@ -56303,9 +56308,21 @@ function AppsPanel({
56303
56308
  api,
56304
56309
  sessionId,
56305
56310
  contextId,
56306
- refreshSignal = 0
56311
+ refreshSignal = 0,
56312
+ prepareAnalysisNavigation
56307
56313
  }) {
56308
56314
  const [viewMode, setViewMode] = (0, import_react8.useState)("list");
56315
+ const [loadingLinkedJob, setLoadingLinkedJob] = (0, import_react8.useState)(Boolean(api.appJobByAnalysisSession));
56316
+ const [linkedJob, setLinkedJob] = (0, import_react8.useState)(null);
56317
+ const restoredLinkedJob = (0, import_react8.useRef)(false);
56318
+ const analysisViewActive = (0, import_react8.useRef)(false);
56319
+ (0, import_react8.useEffect)(() => {
56320
+ analysisViewActive.current = viewMode === "wizard";
56321
+ return () => {
56322
+ analysisViewActive.current = false;
56323
+ };
56324
+ }, [viewMode]);
56325
+ const beginAnalysisNavigation = () => prepareAnalysisNavigation?.(sessionId, contextId, () => analysisViewActive.current);
56309
56326
  const [loadingList, setLoadingList] = (0, import_react8.useState)(true);
56310
56327
  const [apps, setApps] = (0, import_react8.useState)([]);
56311
56328
  const [jobs, setJobs] = (0, import_react8.useState)([]);
@@ -56698,7 +56715,7 @@ function AppsPanel({
56698
56715
  [opcConfig.defaultPort]
56699
56716
  );
56700
56717
  const resumeWizardJob = (0, import_react8.useCallback)(
56701
- async (job, overrideStep) => {
56718
+ async (job, overrideStep, useSnapshot = false) => {
56702
56719
  setWizardError(null);
56703
56720
  setWizardNotice(null);
56704
56721
  setVerifyCredentials({});
@@ -56708,7 +56725,7 @@ function AppsPanel({
56708
56725
  setReviewInitialFeedback("");
56709
56726
  setConfigSubTab("configs");
56710
56727
  setViewMode("wizard");
56711
- const fresh = await refreshWizardJob(job.id) ?? job;
56728
+ const fresh = useSnapshot ? job : await refreshWizardJob(job.id) ?? job;
56712
56729
  setWizardJob(fresh);
56713
56730
  setUpgradeTarget(fresh.published || fresh.upgrade ? apps.find((a) => a.slug === fresh.slug && a.can_manage === true) ?? null : null);
56714
56731
  const targetStep = overrideStep ?? inferStepForJob(fresh);
@@ -56728,6 +56745,35 @@ function AppsPanel({
56728
56745
  },
56729
56746
  [apps, fetchWizardLogs, opcConfig.defaultPort, refreshWizardJob, syncStep3Drafts]
56730
56747
  );
56748
+ const openLinkedJob = (0, import_react8.useCallback)(async (job, refresh = true) => {
56749
+ const fresh = refresh ? await refreshWizardJob(job.id) ?? job : job;
56750
+ if (fresh.status === "verified") await openAppDetail(fresh.slug);
56751
+ else await resumeWizardJob(fresh, void 0, true);
56752
+ }, [openAppDetail, refreshWizardJob, resumeWizardJob]);
56753
+ (0, import_react8.useEffect)(() => {
56754
+ if (!api.appJobByAnalysisSession) return;
56755
+ let active = true;
56756
+ void api.appJobByAnalysisSession(sessionId, contextId).then((raw) => {
56757
+ if (active) setLinkedJob(parseJson(raw, null));
56758
+ }).catch((error62) => {
56759
+ if (active) setBannerError(readErrorMessage(error62, "\u65E0\u6CD5\u6062\u590D\u4E0E\u5F53\u524D\u4F1A\u8BDD\u5173\u8054\u7684\u4EFB\u52A1"));
56760
+ }).finally(() => {
56761
+ if (active) setLoadingLinkedJob(false);
56762
+ });
56763
+ return () => {
56764
+ active = false;
56765
+ };
56766
+ }, [api, contextId, sessionId]);
56767
+ (0, import_react8.useEffect)(() => {
56768
+ if (loadingLinkedJob || !linkedJob || restoredLinkedJob.current) return;
56769
+ restoredLinkedJob.current = true;
56770
+ void openLinkedJob(linkedJob, false);
56771
+ }, [linkedJob, loadingLinkedJob, openLinkedJob]);
56772
+ (0, import_react8.useEffect)(() => {
56773
+ if (viewMode !== "wizard" || wizardJob?.id !== linkedJob?.id || upgradeTarget || !(wizardJob?.upgrade || wizardJob?.published)) return;
56774
+ const target = apps.find((app) => app.slug === wizardJob.slug && app.can_manage === true);
56775
+ if (target) setUpgradeTarget(target);
56776
+ }, [apps, linkedJob?.id, upgradeTarget, viewMode, wizardJob]);
56731
56777
  const handleStep1Submit = async (e) => {
56732
56778
  e.preventDefault();
56733
56779
  setWizardError(null);
@@ -56762,6 +56808,7 @@ function AppsPanel({
56762
56808
  setWizardError("\u8BF7\u9009\u62E9\u6216\u586B\u5199\u672C\u673A\u6E90\u7801\u76EE\u5F55\u7684\u5B8C\u6574\u8DEF\u5F84");
56763
56809
  return;
56764
56810
  }
56811
+ const navigate = beginAnalysisNavigation();
56765
56812
  setWizardBusy(true);
56766
56813
  try {
56767
56814
  const payload = {
@@ -56794,7 +56841,10 @@ function AppsPanel({
56794
56841
  const analyzePromise = api.appAnalyzeWithMode ? api.appAnalyzeWithMode(created.id, "", sessionId, "analysis", contextId) : api.appAnalyze(created.id, "", sessionId, contextId);
56795
56842
  void analyzePromise.then((updatedRaw) => {
56796
56843
  const updated = parseJson(updatedRaw, null);
56797
- if (updated) setWizardJob(updated);
56844
+ if (updated) {
56845
+ setWizardJob(updated);
56846
+ navigate?.(updated);
56847
+ }
56798
56848
  void loadWorkspaceData(true);
56799
56849
  }).catch((err) => {
56800
56850
  setWizardError(readErrorMessage(err, "\u542F\u52A8\u6E90\u7801\u5206\u6790\u5931\u8D25"));
@@ -56995,6 +57045,7 @@ function AppsPanel({
56995
57045
  };
56996
57046
  const handleLaunchRepair = async () => {
56997
57047
  if (!wizardJob) return;
57048
+ const navigate = beginAnalysisNavigation();
56998
57049
  setWizardBusy(true);
56999
57050
  setWizardError(null);
57000
57051
  try {
@@ -57008,7 +57059,10 @@ function AppsPanel({
57008
57059
  setWizardStep(2);
57009
57060
  void analyzePromise.then((raw) => {
57010
57061
  const updated = parseJson(raw, null);
57011
- if (updated) setWizardJob(updated);
57062
+ if (updated) {
57063
+ setWizardJob(updated);
57064
+ navigate?.(updated);
57065
+ }
57012
57066
  }).catch((err) => {
57013
57067
  setWizardError(readErrorMessage(err, "\u542F\u52A8\u4FEE\u590D\u5206\u6790\u5931\u8D25"));
57014
57068
  void refreshWizardJob(wizardJob.id);
@@ -57225,7 +57279,7 @@ function AppsPanel({
57225
57279
  const currentVersion = (version2) => version2.is_active || detailApp?.status === "running" && detailApp.current_version === version2.version;
57226
57280
  const hasRunningVersion = detailApp?.status === "running" || versions.some((v) => v.status === "running" || v.is_active);
57227
57281
  const visibleVersions = versions.filter((version2, index3) => currentVersion(version2) || version2.status !== "failed" || !hasRunningVersion && index3 === 0);
57228
- const renderAppListView = () => /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 16 } }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-topbar" }, /* @__PURE__ */ import_react8.default.createElement("div", null, /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" } }, /* @__PURE__ */ import_react8.default.createElement("h2", { className: "oa-title" }, "\u4F01\u4E1A\u5E94\u7528"), /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-pill oa-pill-accent" }, apps.length, " \u4E2A\u5E94\u7528")), /* @__PURE__ */ import_react8.default.createElement("p", { className: "oa-subtitle", style: { marginTop: 4 } }, "\u5C06\u672C\u5730\u9879\u76EE\u63A5\u5165\u5E73\u53F0\u8FD0\u884C\u73AF\u5883\uFF0C\u81EA\u52A8\u5B8C\u6210\u5206\u6790\u6539\u9020\u3001\u914D\u7F6E\u6258\u7BA1\u4E0E\u4E0A\u7EBF\u53D1\u5E03\uFF0C\u540C\u65F6\u751F\u6210\u53EF\u8C03\u7528\u7684\u667A\u80FD\u4F53\u6280\u80FD\u3002")), /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 8 } }, /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn", disabled: loadingList, onClick: () => void loadWorkspaceData(false) }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "refresh", size: 14, className: loadingList ? "oa-spin" : "" }), /* @__PURE__ */ import_react8.default.createElement("span", null, "\u5237\u65B0")), /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn oa-btn-primary", onClick: () => startWizardNew() }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "plus", size: 14 }), /* @__PURE__ */ import_react8.default.createElement("span", null, "\u65B0\u5EFA\u5E94\u7528")))), bannerError && /* @__PURE__ */ import_react8.default.createElement("div", { role: "alert", className: "oa-alert oa-alert-danger" }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "warning", size: 16 }), /* @__PURE__ */ import_react8.default.createElement("div", { style: { flex: 1 } }, bannerError), /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn oa-btn-xs", onClick: () => setBannerError(null) }, "\u5173\u95ED")), bannerNotice && /* @__PURE__ */ import_react8.default.createElement("div", { role: "status", className: "oa-alert oa-alert-ok" }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "check", size: 16 }), /* @__PURE__ */ import_react8.default.createElement("div", { style: { flex: 1 } }, bannerNotice), /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn oa-btn-xs", onClick: () => setBannerNotice(null) }, "\u5173\u95ED")), resumableJob && (() => {
57282
+ const renderAppListView = () => /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 16 } }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-topbar" }, /* @__PURE__ */ import_react8.default.createElement("div", null, /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" } }, /* @__PURE__ */ import_react8.default.createElement("h2", { className: "oa-title" }, "\u4F01\u4E1A\u5E94\u7528"), /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-pill oa-pill-accent" }, apps.length, " \u4E2A\u5E94\u7528")), /* @__PURE__ */ import_react8.default.createElement("p", { className: "oa-subtitle", style: { marginTop: 4 } }, "\u5C06\u672C\u5730\u9879\u76EE\u63A5\u5165\u5E73\u53F0\u8FD0\u884C\u73AF\u5883\uFF0C\u81EA\u52A8\u5B8C\u6210\u5206\u6790\u6539\u9020\u3001\u914D\u7F6E\u6258\u7BA1\u4E0E\u4E0A\u7EBF\u53D1\u5E03\uFF0C\u540C\u65F6\u751F\u6210\u53EF\u8C03\u7528\u7684\u667A\u80FD\u4F53\u6280\u80FD\u3002")), /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 8 } }, /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn", disabled: loadingList, onClick: () => void loadWorkspaceData(false) }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "refresh", size: 14, className: loadingList ? "oa-spin" : "" }), /* @__PURE__ */ import_react8.default.createElement("span", null, "\u5237\u65B0")), /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn oa-btn-primary", onClick: () => startWizardNew() }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "plus", size: 14 }), /* @__PURE__ */ import_react8.default.createElement("span", null, "\u65B0\u5EFA\u5E94\u7528")))), bannerError && /* @__PURE__ */ import_react8.default.createElement("div", { role: "alert", className: "oa-alert oa-alert-danger" }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "warning", size: 16 }), /* @__PURE__ */ import_react8.default.createElement("div", { style: { flex: 1 } }, bannerError), /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn oa-btn-xs", onClick: () => setBannerError(null) }, "\u5173\u95ED")), bannerNotice && /* @__PURE__ */ import_react8.default.createElement("div", { role: "status", className: "oa-alert oa-alert-ok" }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "check", size: 16 }), /* @__PURE__ */ import_react8.default.createElement("div", { style: { flex: 1 } }, bannerNotice), /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn oa-btn-xs", onClick: () => setBannerNotice(null) }, "\u5173\u95ED")), linkedJob && /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-draft-banner" }, /* @__PURE__ */ import_react8.default.createElement("div", null, /* @__PURE__ */ import_react8.default.createElement("strong", null, linkedJob.name)), /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn oa-btn-sm oa-btn-primary", onClick: () => void openLinkedJob(linkedJob) }, "\u56DE\u5230\u5F53\u524D\u4EFB\u52A1")), resumableJob && resumableJob.id !== linkedJob?.id && (() => {
57229
57283
  const tone = jobStatusTone(resumableJob.status, resumableJob.userDisabled);
57230
57284
  return /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-draft-banner" }, /* @__PURE__ */ import_react8.default.createElement("div", { style: { minWidth: 0, flex: 1 } }, /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" } }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "sparkle", size: 15 }), /* @__PURE__ */ import_react8.default.createElement("strong", { style: { fontSize: 13.5, color: "#0f172a" } }, "\u672A\u5B8C\u6210\u7684\u5E94\u7528\u4EA4\u4ED8\u4EFB\u52A1\uFF1A", resumableJob.name), /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-code" }, resumableJob.slug), /* @__PURE__ */ import_react8.default.createElement("span", { className: `oa-pill ${tone.pillClass}` }, tone.spinning && /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-dot oa-pulse" }), tone.text)), /* @__PURE__ */ import_react8.default.createElement("p", { className: "oa-hint", style: { marginTop: 4 } }, resumableJob.status === "awaiting_page_verification" ? "\u5BB9\u5668\u4E0E\u63A5\u53E3\u68C0\u67E5\u5DF2\u5C31\u7EEA\uFF0C\u8BF7\u6253\u5F00\u5E94\u7528\u9875\u9762\u786E\u8BA4\u540E\u542F\u7528\u667A\u80FD\u4F53\u6280\u80FD\u3002" : resumableJob.error || resumableJob.analysis_failure || "\u53EF\u4ECE\u4E0A\u6B21\u8FDB\u5EA6\u7EE7\u7EED\u529E\u7406\u6216\u8C03\u6574\u6E90\u7801\u65B9\u6848\u3002")), /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 8, flexShrink: 0 } }, /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn oa-btn-sm oa-btn-primary", onClick: () => void resumeWizardJob(resumableJob) }, "\u7EE7\u7EED\u529E\u7406"), /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn oa-btn-sm", onClick: () => dismissDraftBanner(resumableJob) }, "\u9690\u85CF\u63D0\u793A")));
57231
57285
  })(), loadingList && apps.length === 0 ? /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-form-card", style: { textAlign: "center", padding: "44px 20px", color: "#64748b" } }, "\u6B63\u5728\u52A0\u8F7D\u4F01\u4E1A\u5E94\u7528\u76EE\u5F55\u2026") : apps.length === 0 ? /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-form-card", style: { textAlign: "center", padding: "48px 24px" } }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-app-icon-box", style: { margin: "0 auto 14px", width: 48, height: 48 } }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "sparkle", size: 22 })), /* @__PURE__ */ import_react8.default.createElement("div", { style: { fontSize: 16, fontWeight: 600, color: "#0f172a" } }, "\u6682\u65E0\u5DF2\u90E8\u7F72\u7684\u4F01\u4E1A\u5E94\u7528"), /* @__PURE__ */ import_react8.default.createElement("p", { className: "oa-subtitle", style: { maxWidth: 460, margin: "8px auto 18px" } }, "\u4E0A\u4F20\u9879\u76EE\u538B\u7F29\u5305\u6216\u9009\u62E9\u672C\u5730\u9879\u76EE\u6587\u4EF6\u5939\uFF0CAI \u5C06\u81EA\u52A8\u5206\u6790\u8FD0\u884C\u73AF\u5883\u3001\u6258\u7BA1\u914D\u7F6E\u5E76\u53D1\u5E03\u5230\u4F01\u4E1A\u8BBF\u95EE\u57DF\u540D\uFF0C\u540C\u65F6\u751F\u6210\u540C\u540D\u5E94\u7528\u6280\u80FD\u3002"), /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn oa-btn-primary", onClick: () => startWizardNew() }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "plus", size: 14 }), /* @__PURE__ */ import_react8.default.createElement("span", null, "\u65B0\u5EFA\u7B2C\u4E00\u4E2A\u5E94\u7528"))) : /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-apps-grid" }, apps.map((app) => {
@@ -57471,6 +57525,7 @@ function AppsPanel({
57471
57525
  sessionId,
57472
57526
  contextId,
57473
57527
  jobId: wizardJob.id,
57528
+ beginAnalysisNavigation,
57474
57529
  footerMode: "external",
57475
57530
  onlineResources: resources,
57476
57531
  repairMode: wizardJob.analysis_mode === "repair" || wizardJob.analysisMode === "repair",
@@ -57952,7 +58007,7 @@ function AppsPanel({
57952
58007
  "\u53D6\u6D88"
57953
58008
  ))))));
57954
58009
  };
57955
- return /* @__PURE__ */ import_react8.default.createElement("div", { className: "opc-apps-root" }, /* @__PURE__ */ import_react8.default.createElement("style", null, appsCss), viewMode === "list" && renderAppListView(), viewMode === "wizard" && renderWizardView(), viewMode === "detail" && renderDetailView());
58010
+ return /* @__PURE__ */ import_react8.default.createElement("div", { className: "opc-apps-root" }, /* @__PURE__ */ import_react8.default.createElement("style", null, appsCss), viewMode === "list" && (loadingLinkedJob || linkedJob && !restoredLinkedJob.current ? /* @__PURE__ */ import_react8.default.createElement("p", { role: "status" }, "\u6B63\u5728\u67E5\u627E\u5F53\u524D\u4F1A\u8BDD\u7684\u5E94\u7528\u4EFB\u52A1\u2026") : renderAppListView()), viewMode === "wizard" && renderWizardView(), viewMode === "detail" && renderDetailView());
57956
58011
  }
57957
58012
 
57958
58013
  // src/client/OpcSettingsPanel.tsx
@@ -58038,10 +58093,12 @@ var settingsCss = `
58038
58093
  align-items: center;
58039
58094
  gap: 8px;
58040
58095
  }
58041
- .opc-settings-input {
58096
+ .opc-panel .opc-settings-input {
58042
58097
  width: 100%;
58043
58098
  min-width: 0;
58044
58099
  height: 36px;
58100
+ min-height: 36px;
58101
+ flex: 0 0 auto;
58045
58102
  padding: 6px 12px;
58046
58103
  border: 1px solid #cbd5e1;
58047
58104
  border-radius: 8px;
@@ -58050,14 +58107,20 @@ var settingsCss = `
58050
58107
  font-size: 13px;
58051
58108
  transition: border-color 0.15s, background 0.15s;
58052
58109
  }
58053
- .opc-settings-input:focus {
58110
+ .opc-panel .opc-settings-input-row .opc-settings-input {
58111
+ flex: 1 1 0%;
58112
+ }
58113
+ .opc-panel .opc-settings-input:focus {
58054
58114
  outline: none;
58055
58115
  border-color: #245c9f;
58056
58116
  background: #ffffff;
58057
58117
  }
58058
- .opc-settings-port-input {
58059
- width: 120px !important;
58060
- flex: 0 0 120px !important;
58118
+ .opc-panel .opc-settings-port-input {
58119
+ width: 120px;
58120
+ max-width: 120px;
58121
+ height: 36px;
58122
+ min-height: 36px;
58123
+ flex: 0 0 auto;
58061
58124
  }
58062
58125
  .opc-settings-test-btn {
58063
58126
  height: 36px;
@@ -59114,7 +59177,7 @@ var css = `
59114
59177
  margin: 0 0 10px;
59115
59178
  }
59116
59179
  `;
59117
- function Panel({ api, sessionId, kind }) {
59180
+ function Panel({ api, sessionId, kind, prepareAnalysisNavigation }) {
59118
59181
  const [state, setState] = (0, import_react10.useState)({ signedIn: false, loginInProgress: false, context: null });
59119
59182
  const [error62, setError] = (0, import_react10.useState)(""), [busy, setBusy] = (0, import_react10.useState)(false), [q, setQ] = (0, import_react10.useState)("");
59120
59183
  const [items, setItems] = (0, import_react10.useState)([]), [hits, setHits] = (0, import_react10.useState)([]);
@@ -59245,6 +59308,7 @@ function Panel({ api, sessionId, kind }) {
59245
59308
  api,
59246
59309
  sessionId,
59247
59310
  contextId: context.applicationContextId,
59311
+ prepareAnalysisNavigation,
59248
59312
  refreshSignal: appsRefreshTrigger
59249
59313
  }
59250
59314
  ), kind === "knowledge" && /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement("div", { className: "s2-kb-tabs" }, /* @__PURE__ */ import_react10.default.createElement(
@@ -59628,6 +59692,75 @@ function McpDebug({ api, serviceId, toolName, contextId }) {
59628
59692
  } }, pending ? "\u6267\u884C\u4E2D\u2026" : "\u8C03\u7528"), result && /* @__PURE__ */ import_react10.default.createElement("pre", { style: { marginTop: 6, fontSize: 11, background: "#f1f5f9", padding: 8, borderRadius: 4, overflowX: "auto" } }, result));
59629
59693
  }
59630
59694
 
59695
+ // src/client/app-analysis-navigation.tsx
59696
+ var import_react11 = require("react");
59697
+ function OpenAnalysisSidebar({ open: open2 }) {
59698
+ (0, import_react11.useEffect)(() => {
59699
+ open2();
59700
+ }, [open2]);
59701
+ return null;
59702
+ }
59703
+ function registerAnalysisNavigation(ctx, api) {
59704
+ let attempt = 0;
59705
+ let pending;
59706
+ const sidebar = ctx.get("sidebarRight");
59707
+ const currentSession = () => sidebar?.mounted?.getSnapshot();
59708
+ if (sidebar?.mounted) {
59709
+ ctx.effect(() => sidebar.mounted.subscribe(() => {
59710
+ attempt++;
59711
+ if (pending && currentSession() !== pending) pending = void 0;
59712
+ }));
59713
+ }
59714
+ ctx.effect(() => () => {
59715
+ attempt++;
59716
+ pending = void 0;
59717
+ });
59718
+ ctx.effect(() => ctx.slots.inject("conversation.session.header.utilities", () => ctx.slots.register({
59719
+ name: "conversation.session.header.utilities",
59720
+ id: "opc-app-analysis-sidebar",
59721
+ inject: (sessionId) => ({
59722
+ open: () => {
59723
+ if (pending !== sessionId || currentSession() !== sessionId) return;
59724
+ pending = void 0;
59725
+ try {
59726
+ sidebar?.openTab("opc-apps");
59727
+ } catch {
59728
+ }
59729
+ }
59730
+ })
59731
+ }, OpenAnalysisSidebar)));
59732
+ return (origin, contextId, isActive) => {
59733
+ const started = ++attempt;
59734
+ const canNavigate = () => attempt === started && isActive() && currentSession() === origin;
59735
+ return (job) => {
59736
+ const workspace = ctx.get("uiWorkspace");
59737
+ if (!workspace || !sidebar || !canNavigate()) return;
59738
+ void (async () => {
59739
+ let current = job;
59740
+ while (canNavigate()) {
59741
+ const target = current.analysisSessionId;
59742
+ if (target) {
59743
+ if (target !== origin) {
59744
+ pending = target;
59745
+ try {
59746
+ workspace.openSession(target);
59747
+ } catch {
59748
+ pending = void 0;
59749
+ }
59750
+ }
59751
+ return;
59752
+ }
59753
+ if (current.status !== "analyzing" || !api.appJob) return;
59754
+ await new Promise((resolve) => setTimeout(resolve, 500));
59755
+ if (!canNavigate()) return;
59756
+ current = JSON.parse(await api.appJob(job.id, contextId));
59757
+ }
59758
+ })().catch(() => {
59759
+ });
59760
+ };
59761
+ };
59762
+ }
59763
+
59631
59764
  // src/client/index.tsx
59632
59765
  var inject = ["remote"];
59633
59766
  async function apply(ctx) {
@@ -59646,6 +59779,7 @@ function registerPanels(ctx) {
59646
59779
  appCatalog: (...args) => unwrap(wire.appCatalog(...args)),
59647
59780
  appList: (...args) => unwrap(wire.appList(...args)),
59648
59781
  appJob: (...args) => unwrap(wire.appJob(...args)),
59782
+ appJobByAnalysisSession: (...args) => unwrap(wire.appJobByAnalysisSession(...args)),
59649
59783
  appCheckSlug: (...args) => unwrap(wire.appCheckSlug(...args)),
59650
59784
  opcConfigGet: () => unwrap(wire.opcConfigGet()),
59651
59785
  opcConfigUpdate: (payloadJson) => unwrap(wire.opcConfigUpdate(payloadJson)),
@@ -59704,11 +59838,12 @@ function registerPanels(ctx) {
59704
59838
  decideDebugInvocation: (...args) => unwrap(wire.decideDebugInvocation(...args))
59705
59839
  };
59706
59840
  ctx.inject(["inputTriggers"], (child) => registerMentions(child, api));
59841
+ const prepareAnalysisNavigation = registerAnalysisNavigation(ctx, api);
59707
59842
  for (const [index3, kind] of ["knowledge", "skills", "mcp", "apps"].entries()) {
59708
59843
  const id = `dsh-plugin-opc/${kind}`;
59709
59844
  ctx.effect(() => ctx.sidebarRightTabs.register({ id, kind: `opc-${kind}`, priority: "extension", title: () => labels[kind], guide: [{ id: `opc-${kind}`, order: 10 + index3, icon: OpcIcon, title: () => labels[kind], description: () => "OPC \u5DE5\u4F5C\u7A7A\u95F4" }] }));
59710
- ctx.effect(() => ctx.slots.inject("sidebar.right.pane.tab.title", () => ctx.slots.register({ name: "sidebar.right.pane.tab.title", key: id }, () => /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, /* @__PURE__ */ import_react11.default.createElement(OpcIcon, null), " ", labels[kind]))));
59711
- ctx.effect(() => ctx.slots.inject("sidebar.right.pane.tab", () => ctx.slots.register({ name: "sidebar.right.pane.tab", key: id, inject: (sessionId) => ({ api, sessionId: String(sessionId), kind }) }, Panel)));
59845
+ ctx.effect(() => ctx.slots.inject("sidebar.right.pane.tab.title", () => ctx.slots.register({ name: "sidebar.right.pane.tab.title", key: id }, () => /* @__PURE__ */ import_react12.default.createElement(import_react12.default.Fragment, null, /* @__PURE__ */ import_react12.default.createElement(OpcIcon, null), " ", labels[kind]))));
59846
+ ctx.effect(() => ctx.slots.inject("sidebar.right.pane.tab", () => ctx.slots.register({ name: "sidebar.right.pane.tab", key: id, inject: (sessionId) => ({ api, sessionId: String(sessionId), kind, prepareAnalysisNavigation }) }, Panel)));
59712
59847
  }
59713
59848
  }
59714
59849
 
package/lib/index.js CHANGED
@@ -1431,8 +1431,8 @@ var OpcConfigStore = class {
1431
1431
 
1432
1432
  // src/host/remote-service.ts
1433
1433
  var execFileAsync = promisify(execFile);
1434
- var _decideDebugInvocation_dec, _unmountMcpService_dec, _mountMcpService_dec, _invokeMcpTool_dec, _listMcpServices_dec, _readKnowledgeDocument_dec, _searchKnowledge_dec, _setPinnedKnowledgeScope_dec, _uninstallSkill_dec, _setSkillEnabled_dec, _installSkill_dec, _listSkillsCatalog_dec, _listKnowledgeBases_dec, _switchTenant_dec, _logout_dec, _cancelLogin_dec, _startLogin_dec, _watchState_dec, _state_dec, _opcConfigTest_dec, _opcConfigReset_dec, _opcConfigUpdate_dec, _opcConfigGet_dec, _appRollback_dec, _appDelete_dec, _appUpdateConfig_dec, _appRecheck_dec, _appSaveDownload_dec, _appDownload_dec, _appStorage_dec, _appLogs_dec, _appVersions_dec, _appDetails_dec, _appResources_dec, _appSetSkillEnabled_dec, _appVerifyWithOptions_dec, _appVerify_dec, _appPublish_dec, _appConfirmDeployment_dec, _appSkillPreview_dec, _appHandoff_dec, _appSaveLocalArtifact_dec, _appLocalArtifact_dec, _appSaveConfigDraft_dec, _appConfigDraft_dec, _appCancelAnalysis_dec, _appReopenDeployment_dec, _appReopenReview_dec, _appPrepare_dec, _appAnalyzeWithMode_dec, _appAnalyze_dec, _appCreate_dec, _appCatalog_dec, _appModels_dec, _appPickSourceFolder_dec, _appOpcConfig_dec, _appCheckSlug_dec, _appJob_dec, _appList_dec, _a, _init;
1435
- var OpcRemoteService = class extends (_a = TypertRemoteService, _appList_dec = [Remote], _appJob_dec = [Remote], _appCheckSlug_dec = [Remote], _appOpcConfig_dec = [Remote], _appPickSourceFolder_dec = [Remote], _appModels_dec = [Remote], _appCatalog_dec = [Remote], _appCreate_dec = [Remote], _appAnalyze_dec = [Remote], _appAnalyzeWithMode_dec = [Remote], _appPrepare_dec = [Remote], _appReopenReview_dec = [Remote], _appReopenDeployment_dec = [Remote], _appCancelAnalysis_dec = [Remote], _appConfigDraft_dec = [Remote], _appSaveConfigDraft_dec = [Remote], _appLocalArtifact_dec = [Remote], _appSaveLocalArtifact_dec = [Remote], _appHandoff_dec = [Remote], _appSkillPreview_dec = [Remote], _appConfirmDeployment_dec = [Remote], _appPublish_dec = [Remote], _appVerify_dec = [Remote], _appVerifyWithOptions_dec = [Remote], _appSetSkillEnabled_dec = [Remote], _appResources_dec = [Remote], _appDetails_dec = [Remote], _appVersions_dec = [Remote], _appLogs_dec = [Remote], _appStorage_dec = [Remote], _appDownload_dec = [Remote], _appSaveDownload_dec = [Remote], _appRecheck_dec = [Remote], _appUpdateConfig_dec = [Remote], _appDelete_dec = [Remote], _appRollback_dec = [Remote], _opcConfigGet_dec = [Remote], _opcConfigUpdate_dec = [Remote], _opcConfigReset_dec = [Remote], _opcConfigTest_dec = [Remote], _state_dec = [Remote], _watchState_dec = [Remote({ mode: "stream" })], _startLogin_dec = [Remote], _cancelLogin_dec = [Remote], _logout_dec = [Remote], _switchTenant_dec = [Remote], _listKnowledgeBases_dec = [Remote], _listSkillsCatalog_dec = [Remote], _installSkill_dec = [Remote], _setSkillEnabled_dec = [Remote], _uninstallSkill_dec = [Remote], _setPinnedKnowledgeScope_dec = [Remote], _searchKnowledge_dec = [Remote], _readKnowledgeDocument_dec = [Remote], _listMcpServices_dec = [Remote], _invokeMcpTool_dec = [Remote], _mountMcpService_dec = [Remote], _unmountMcpService_dec = [Remote], _decideDebugInvocation_dec = [Remote], _a) {
1434
+ var _decideDebugInvocation_dec, _unmountMcpService_dec, _mountMcpService_dec, _invokeMcpTool_dec, _listMcpServices_dec, _readKnowledgeDocument_dec, _searchKnowledge_dec, _setPinnedKnowledgeScope_dec, _uninstallSkill_dec, _setSkillEnabled_dec, _installSkill_dec, _listSkillsCatalog_dec, _listKnowledgeBases_dec, _switchTenant_dec, _logout_dec, _cancelLogin_dec, _startLogin_dec, _watchState_dec, _state_dec, _opcConfigTest_dec, _opcConfigReset_dec, _opcConfigUpdate_dec, _opcConfigGet_dec, _appRollback_dec, _appDelete_dec, _appUpdateConfig_dec, _appRecheck_dec, _appSaveDownload_dec, _appDownload_dec, _appStorage_dec, _appLogs_dec, _appVersions_dec, _appDetails_dec, _appResources_dec, _appSetSkillEnabled_dec, _appVerifyWithOptions_dec, _appVerify_dec, _appPublish_dec, _appConfirmDeployment_dec, _appSkillPreview_dec, _appHandoff_dec, _appSaveLocalArtifact_dec, _appLocalArtifact_dec, _appSaveConfigDraft_dec, _appConfigDraft_dec, _appCancelAnalysis_dec, _appReopenDeployment_dec, _appReopenReview_dec, _appPrepare_dec, _appAnalyzeWithMode_dec, _appAnalyze_dec, _appCreate_dec, _appCatalog_dec, _appModels_dec, _appPickSourceFolder_dec, _appOpcConfig_dec, _appCheckSlug_dec, _appJobByAnalysisSession_dec, _appJob_dec, _appList_dec, _a, _init;
1435
+ var OpcRemoteService = class extends (_a = TypertRemoteService, _appList_dec = [Remote], _appJob_dec = [Remote], _appJobByAnalysisSession_dec = [Remote], _appCheckSlug_dec = [Remote], _appOpcConfig_dec = [Remote], _appPickSourceFolder_dec = [Remote], _appModels_dec = [Remote], _appCatalog_dec = [Remote], _appCreate_dec = [Remote], _appAnalyze_dec = [Remote], _appAnalyzeWithMode_dec = [Remote], _appPrepare_dec = [Remote], _appReopenReview_dec = [Remote], _appReopenDeployment_dec = [Remote], _appCancelAnalysis_dec = [Remote], _appConfigDraft_dec = [Remote], _appSaveConfigDraft_dec = [Remote], _appLocalArtifact_dec = [Remote], _appSaveLocalArtifact_dec = [Remote], _appHandoff_dec = [Remote], _appSkillPreview_dec = [Remote], _appConfirmDeployment_dec = [Remote], _appPublish_dec = [Remote], _appVerify_dec = [Remote], _appVerifyWithOptions_dec = [Remote], _appSetSkillEnabled_dec = [Remote], _appResources_dec = [Remote], _appDetails_dec = [Remote], _appVersions_dec = [Remote], _appLogs_dec = [Remote], _appStorage_dec = [Remote], _appDownload_dec = [Remote], _appSaveDownload_dec = [Remote], _appRecheck_dec = [Remote], _appUpdateConfig_dec = [Remote], _appDelete_dec = [Remote], _appRollback_dec = [Remote], _opcConfigGet_dec = [Remote], _opcConfigUpdate_dec = [Remote], _opcConfigReset_dec = [Remote], _opcConfigTest_dec = [Remote], _state_dec = [Remote], _watchState_dec = [Remote({ mode: "stream" })], _startLogin_dec = [Remote], _cancelLogin_dec = [Remote], _logout_dec = [Remote], _switchTenant_dec = [Remote], _listKnowledgeBases_dec = [Remote], _listSkillsCatalog_dec = [Remote], _installSkill_dec = [Remote], _setSkillEnabled_dec = [Remote], _uninstallSkill_dec = [Remote], _setPinnedKnowledgeScope_dec = [Remote], _searchKnowledge_dec = [Remote], _readKnowledgeDocument_dec = [Remote], _listMcpServices_dec = [Remote], _invokeMcpTool_dec = [Remote], _mountMcpService_dec = [Remote], _unmountMcpService_dec = [Remote], _decideDebugInvocation_dec = [Remote], _a) {
1436
1436
  constructor(ctx, options) {
1437
1437
  super(ctx, "opc");
1438
1438
  __runInitializers(_init, 5, this);
@@ -1477,6 +1477,9 @@ var OpcRemoteService = class extends (_a = TypertRemoteService, _appList_dec = [
1477
1477
  async appJob(id, expectedContextId) {
1478
1478
  return JSON.stringify(await this.delivery.getJob(id, expectedContextId));
1479
1479
  }
1480
+ async appJobByAnalysisSession(sessionId, expectedContextId) {
1481
+ return JSON.stringify(await this.delivery.getJobByAnalysisSession(sessionId, expectedContextId));
1482
+ }
1480
1483
  async appCheckSlug(slug, expectedContextId) {
1481
1484
  return JSON.stringify(await this.delivery.checkSlug(slug, expectedContextId));
1482
1485
  }
@@ -1772,6 +1775,7 @@ var OpcRemoteService = class extends (_a = TypertRemoteService, _appList_dec = [
1772
1775
  _init = __decoratorStart(_a);
1773
1776
  __decorateElement(_init, 1, "appList", _appList_dec, OpcRemoteService);
1774
1777
  __decorateElement(_init, 1, "appJob", _appJob_dec, OpcRemoteService);
1778
+ __decorateElement(_init, 1, "appJobByAnalysisSession", _appJobByAnalysisSession_dec, OpcRemoteService);
1775
1779
  __decorateElement(_init, 1, "appCheckSlug", _appCheckSlug_dec, OpcRemoteService);
1776
1780
  __decorateElement(_init, 1, "appOpcConfig", _appOpcConfig_dec, OpcRemoteService);
1777
1781
  __decorateElement(_init, 1, "appPickSourceFolder", _appPickSourceFolder_dec, OpcRemoteService);
@@ -2117,14 +2121,17 @@ ${combinedLog}` : combinedLog).slice(-24e3);
2117
2121
  }
2118
2122
  }
2119
2123
  }
2120
- async list(expected) {
2121
- const scope = this.scope(expected);
2122
- const directories = await this.directories(scope.directory);
2123
- const entries = (await Promise.all(directories.map((directory) => readdir2(directory).catch((error) => {
2124
+ async localJobIds(directory) {
2125
+ const directories = await this.directories(directory);
2126
+ const entries = (await Promise.all(directories.map((directory2) => readdir2(directory2).catch((error) => {
2124
2127
  if (error.code === "ENOENT") return [];
2125
2128
  throw error;
2126
2129
  })))).flat();
2127
- const jobs = await Promise.all([...new Set(entries.filter((id) => /^[a-f0-9-]{36}$/.test(id)))].map(async (id) => {
2130
+ return [...new Set(entries.filter((id) => /^[a-f0-9-]{36}$/.test(id)))];
2131
+ }
2132
+ async list(expected) {
2133
+ const scope = this.scope(expected);
2134
+ const jobs = await Promise.all((await this.localJobIds(scope.directory)).map(async (id) => {
2128
2135
  const result = await this.open(scope.directory, id).catch((error) => {
2129
2136
  if (error.code !== "ENOENT") throw error;
2130
2137
  return void 0;
@@ -2201,6 +2208,17 @@ ${combinedLog}` : combinedLog).slice(-24e3);
2201
2208
  if (job.status === "verified") view.userDisabled = await this.isSkillDisabled(scope.directory, job.slug);
2202
2209
  return view;
2203
2210
  }
2211
+ async getJobByAnalysisSession(sessionId, expected) {
2212
+ const scope = this.scope(expected);
2213
+ if (!/^[a-f0-9-]{36}$/.test(sessionId)) return null;
2214
+ const jobs = await Promise.all((await this.localJobIds(scope.directory)).map((id) => this.open(scope.directory, id).catch((error) => {
2215
+ if (error.code !== "ENOENT") throw error;
2216
+ return void 0;
2217
+ })));
2218
+ scope.assertCurrent();
2219
+ const match = jobs.find((entry) => entry?.job.analysisSessions?.includes(sessionId));
2220
+ return match ? this.getJob(match.job.id, expected) : null;
2221
+ }
2204
2222
  async checkSlug(slug, expected) {
2205
2223
  const trimmed = slug.trim();
2206
2224
  if (!/^[a-z][a-z0-9-]{2,39}$/.test(trimmed)) throw new Error("\u5E94\u7528\u552F\u4E00\u6807\u8BC6\u9700\u4E3A 3\u201340 \u4F4D\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u6216\u8FDE\u5B57\u7B26\uFF0C\u4E14\u4EE5\u5B57\u6BCD\u5F00\u5934");
@@ -2235,7 +2253,7 @@ ${combinedLog}` : combinedLog).slice(-24e3);
2235
2253
  };
2236
2254
  }
2237
2255
  public(job, root) {
2238
- const { proposal, skillMarkdown: _sm, dockerfileContent: _df, configDraft: _draft, confirmationToken: _token, ...rest } = job;
2256
+ const { proposal, skillMarkdown: _sm, dockerfileContent: _df, configDraft: _draft, confirmationToken: _token, analysisSessions: _analysisSessions, ...rest } = job;
2239
2257
  const hasOrigSet = new Set(job.hasOriginalKeys ?? []);
2240
2258
  const runtimeConfigs = (proposal?.contract?.configs ?? []).map((c) => {
2241
2259
  const hasOrig = hasOrigSet.has(c.key) || Boolean(c.has_original_value);
@@ -2490,7 +2508,7 @@ ${combinedLog}` : combinedLog).slice(-24e3);
2490
2508
  const resume = options?.mode === "resume";
2491
2509
  if (resume && (job.status !== "failed" || feedback.trim())) throw new Error("\u53EA\u80FD\u7EE7\u7EED\u5DF2\u6682\u505C\u7684\u5E94\u7528\u51C6\u5907");
2492
2510
  this.busy.add(id);
2493
- job.session = session || job.session;
2511
+ if (session && !job.analysisSessions?.includes(session)) job.session = session;
2494
2512
  let trimmedFeedback;
2495
2513
  try {
2496
2514
  trimmedFeedback = await worker({ action: "redact_feedback", root, text: feedback.slice(0, 2e4) }, scope.signal);
@@ -2538,6 +2556,7 @@ ${trimmedFeedback.trim()}` : trimmedFeedback.trim();
2538
2556
  }
2539
2557
  }
2540
2558
  job.status = "analyzing";
2559
+ delete job.analysisSessionId;
2541
2560
  job.failureStage = void 0;
2542
2561
  job.error = void 0;
2543
2562
  job.checks = void 0;
@@ -2555,7 +2574,14 @@ ${trimmedFeedback.trim()}` : trimmedFeedback.trim();
2555
2574
  this.core.emit("skills-changed");
2556
2575
  void (async () => {
2557
2576
  try {
2558
- await this.analyze(job, root, trimmedFeedback, analysisSignal);
2577
+ await this.analyze(job, root, trimmedFeedback, analysisSignal, async (sessionId) => {
2578
+ analysisSignal.throwIfAborted();
2579
+ scope.assertCurrent();
2580
+ const analysisSessions = [...(job.analysisSessions ?? []).filter((id2) => id2 !== sessionId), sessionId];
2581
+ await this.save(root, { ...job, analysisSessions, analysisSessionId: sessionId });
2582
+ job.analysisSessions = analysisSessions;
2583
+ job.analysisSessionId = sessionId;
2584
+ });
2559
2585
  analysisSignal.throwIfAborted();
2560
2586
  scope.assertCurrent();
2561
2587
  if (!job.proposal || job.status === "analyzing") throw new Error("AI \u672A\u63D0\u4EA4\u6709\u6548\u6539\u9020\u65B9\u6848\uFF0C\u8BF7\u8865\u5145\u8BF4\u660E\u540E\u91CD\u8BD5");
@@ -3562,38 +3588,16 @@ DEPLOYMENT REPAIR\uFF08\u90E8\u7F72/\u9A8C\u8BC1\u5931\u8D25\u4E13\u9879\u4FEE\u
3562
3588
  return text2;
3563
3589
  }
3564
3590
  function attachAppAgent(ctx, delivery) {
3565
- delivery.analyze = async (job, root, feedback, signal) => {
3591
+ delivery.analyze = async (job, root, feedback, signal, onSessionReady) => {
3566
3592
  const parent = ctx.agents.get(job.session);
3567
- if (!parent) throw new Error("\u8BF7\u5148\u5728\u5F53\u524D\u5DE5\u4F5C\u533A\u521B\u5EFA\u5BF9\u8BDD\uFF0C\u518D\u6253\u5F00 OPC \u5E94\u7528\u8FDB\u884C\u5206\u6790");
3568
3593
  const configured = job.modelSelection;
3569
3594
  const selection = configured ? {
3570
3595
  provider: configured.provider,
3571
3596
  model: configured.model,
3572
3597
  reasoningEffort: configured.reasoningEffort ? ReasoningEffortId(configured.reasoningEffort) : void 0
3573
- } : parent.model.current() ?? parent.session.requestHeader()?.config;
3598
+ } : parent?.model.current() ?? parent?.session.requestHeader()?.config;
3574
3599
  const appCtxId = delivery.core.auth.contexts.applicationContextId;
3575
- const previous = job.published ? await delivery.platform("/" + job.slug, appCtxId).catch(() => void 0) : void 0;
3576
- const runtimeLogs = job.published ? await delivery.platform("/" + job.slug + "/logs", appCtxId).catch(() => void 0) : void 0;
3577
- const rawResources = await delivery.platform("/resources", appCtxId).catch(() => ({ resources: [] }));
3578
- const filteredRes = await worker({
3579
- action: "filter_resources",
3580
- root,
3581
- resources: rawResources?.resources ?? [],
3582
- slug: job.slug,
3583
- default_only: true
3584
- }, signal).catch(() => ({ resources: [] }));
3585
3600
  const isRepair = Boolean(job.failedRevision || job.failedSnapshot || job.failureContext || job.analysisMode === "repair");
3586
- if (isRepair || previous?.error_message || previous?.build_log || runtimeLogs?.runtime_logs) {
3587
- const mergedFailure = [
3588
- job.failureContext,
3589
- previous?.error_message,
3590
- previous?.build_log?.slice(-8e3),
3591
- runtimeLogs?.runtime_logs?.slice(-4e3)
3592
- ].filter(Boolean).join("\n");
3593
- if (mergedFailure) {
3594
- job.failureContext = await worker({ action: "redact_feedback", root, text: mergedFailure.slice(-24e3) }, signal);
3595
- }
3596
- }
3597
3601
  const instructions = buildInstructions(isRepair);
3598
3602
  const prevPlan = compactPreviousPlan(job.proposal);
3599
3603
  const taskInstruction = isRepair ? "\u90E8\u7F72\u5931\u8D25\u4E13\u9879\u4FEE\u590D\uFF1A\u8BFB\u53D6\u5B9E\u9645\u5931\u8D25\u5236\u54C1\u4E0E\u539F\u59CB\u6E90\u7801\uFF0C\u5BF9\u6BD4\u65E7\u4FEE\u6539\uFF0C\u4FEE\u590D\u6839\u56E0\u3002\u4E0D\u80FD\u628A\u672C\u8F6E\u5F53\u6210\u914D\u7F6E\u786E\u8BA4\uFF0C\u4E0D\u80FD\u65E0\u4F9D\u636E\u590D\u7528\u9519\u8BEF\u4EE3\u7801\u3002" : prevPlan && feedback.trim() ? "\u8FD9\u662F\u57FA\u4E8E\u4E0A\u4E00\u8F6E\u5206\u6790\u7ED3\u679C\uFF08previous_plan\uFF09\u7684\u7528\u6237\u786E\u8BA4/\u8865\u5145\u8F6E\u6B21\u3002\u4E0A\u4E00\u8F6E\u6682\u5B58\u7684\u6587\u4EF6\u4FEE\u6539\uFF08changes\uFF09\u5DF2\u9884\u8F7D\u5165\u6682\u5B58\u533A\uFF08\u672A\u6539\u52A8\u7684\u6587\u4EF6\u53EF\u76F4\u63A5\u6309\u539F id \u5F15\u7528\uFF0C\u65E0\u9700\u91CD\u590D\u8BFB\u53D6\u6E90\u7801\u6216\u91CD\u65B0\u8C03\u7528 propose_file\uFF09\uFF0C\u626B\u63CF\u7684\u5168\u90E8\u63A5\u53E3\u4E0E\u9875\u9762\u4E5F\u5DF2\u7531\u540E\u7AEF\u7F13\u5B58\u5E76\u81EA\u52A8\u5408\u5E76\u3002\u8BF7\u4EC5\u9488\u5BF9 user_answers \u8FDB\u884C\u5FC5\u8981\u7684\u589E\u91CF\u8C03\u6574\u5E76\u76F4\u63A5\u8C03\u7528 opc_delivery_submit\uFF08unresolved \u4EC5\u4FDD\u7559\u771F\u6B63\u963B\u585E\u6539\u9020\u7684\u4E8B\u9879\uFF09\u3002\u672C\u8F6E summary \u53EA\u9700\u7B80\u660E\u8BF4\u660E\u5DF2\u6309\u7528\u6237\u786E\u8BA4\u5B8C\u6210\u4E86\u54EA\u4E9B\u8C03\u6574\uFF0C\u4E25\u7981\u91CD\u590D\u8F93\u51FA\u5168\u91CF\u6478\u5E95\u5185\u5BB9\uFF01" : "\u5206\u6790\u5E94\u7528\u5E76\u63D0\u4EA4\u5B8C\u6574\u4FEE\u6539\u63D0\u6848\u548C\u4E1A\u52A1\u5951\u7EA6\u3002\u5148\u8C03\u7528 scan_routes_and_pages \u4E0E\u8BFB\u53D6\u6E90\u7801\u5DE5\u5177\u5168\u9762\u6478\u6E05\u5E94\u7528\uFF0C\u5B8C\u6574\u6536\u5F55\u6240\u6709\u9875\u9762\u4E0E\u6240\u6709\u63A5\u53E3\uFF0C\u6309\u56DB\u6B65\u89C4\u8303\u5206\u6BB5\u6E05\u6670\u8F93\u51FA\u5206\u6790\u4E0E\u6539\u9020\u65B9\u6848\u3002";
@@ -3609,10 +3613,9 @@ function attachAppAgent(ctx, delivery) {
3609
3613
  }
3610
3614
  } catch {
3611
3615
  }
3612
- const handle = await ctx.agents.create({
3613
- sessionId: randomUUID5(),
3614
- meta: { cwd: root },
3615
- agentOptions: selection ? { provider: selection.provider, model: selection.model, reasoningEffort: selection.reasoningEffort } : { ...parent.options },
3616
+ const agentOptions = selection ? { provider: selection.provider, model: selection.model, reasoningEffort: selection.reasoningEffort } : { ...parent?.options };
3617
+ const options = {
3618
+ agentOptions,
3616
3619
  signal: abort,
3617
3620
  setup(child) {
3618
3621
  child.tools.restrict({ allow: [] });
@@ -3729,13 +3732,27 @@ function attachAppAgent(ctx, delivery) {
3729
3732
  }
3730
3733
  }));
3731
3734
  }
3735
+ };
3736
+ const previousSessionId = job.analysisSessions?.at(-1);
3737
+ let handle;
3738
+ if (previousSessionId && !ctx.agents.get(previousSessionId)) {
3739
+ try {
3740
+ handle = await ctx.agents.resume({ ...options, resumeSessionId: previousSessionId });
3741
+ } catch {
3742
+ abort.throwIfAborted();
3743
+ }
3744
+ }
3745
+ const analysis = handle ?? await ctx.agents.create({
3746
+ ...options,
3747
+ sessionId: randomUUID5(),
3748
+ meta: { cwd: root }
3732
3749
  });
3733
3750
  const cancel = () => {
3734
- handle.agent.cancel({ kind: "user" });
3751
+ analysis.agent.cancel({ kind: "user" });
3735
3752
  };
3736
3753
  abort.addEventListener("abort", cancel, { once: true });
3737
3754
  const send = (text2) => {
3738
- handle.agent.followup({
3755
+ analysis.agent.followup({
3739
3756
  id: randomUUID5(),
3740
3757
  role: "user",
3741
3758
  source: { kind: "user" },
@@ -3746,6 +3763,30 @@ function attachAppAgent(ctx, delivery) {
3746
3763
  });
3747
3764
  };
3748
3765
  try {
3766
+ abort.throwIfAborted();
3767
+ await onSessionReady(String(analysis.agent.session.id));
3768
+ abort.throwIfAborted();
3769
+ const previous = job.published ? await delivery.platform("/" + job.slug, appCtxId).catch(() => void 0) : void 0;
3770
+ const runtimeLogs = job.published ? await delivery.platform("/" + job.slug + "/logs", appCtxId).catch(() => void 0) : void 0;
3771
+ const rawResources = await delivery.platform("/resources", appCtxId).catch(() => ({ resources: [] }));
3772
+ const filteredRes = await worker({
3773
+ action: "filter_resources",
3774
+ root,
3775
+ resources: rawResources?.resources ?? [],
3776
+ slug: job.slug,
3777
+ default_only: true
3778
+ }, signal).catch(() => ({ resources: [] }));
3779
+ if (isRepair || previous?.error_message || previous?.build_log || runtimeLogs?.runtime_logs) {
3780
+ const mergedFailure = [
3781
+ job.failureContext,
3782
+ previous?.error_message,
3783
+ previous?.build_log?.slice(-8e3),
3784
+ runtimeLogs?.runtime_logs?.slice(-4e3)
3785
+ ].filter(Boolean).join("\n");
3786
+ if (mergedFailure) {
3787
+ job.failureContext = await worker({ action: "redact_feedback", root, text: mergedFailure.slice(-24e3) }, signal);
3788
+ }
3789
+ }
3749
3790
  abort.throwIfAborted();
3750
3791
  let prompt = JSON.stringify({
3751
3792
  name: job.name,
@@ -3768,7 +3809,7 @@ function attachAppAgent(ctx, delivery) {
3768
3809
  let transientError = "";
3769
3810
  try {
3770
3811
  send(prompt);
3771
- await handle.agent.whenIdle();
3812
+ await analysis.agent.whenIdle();
3772
3813
  } catch (err) {
3773
3814
  if (signal.aborted || abort.aborted && !repeatedProposal) throw err;
3774
3815
  const msg = err instanceof Error ? err.message : String(err);
@@ -3800,7 +3841,7 @@ function attachAppAgent(ctx, delivery) {
3800
3841
  }
3801
3842
  } finally {
3802
3843
  abort.removeEventListener("abort", cancel);
3803
- await handle.dispose();
3844
+ await analysis.dispose();
3804
3845
  }
3805
3846
  };
3806
3847
  ctx.effect(() => () => {
@@ -3897,6 +3938,7 @@ import { z } from "zod";
3897
3938
  var contribution = { package: "dsh-plugin-opc", descriptors: [
3898
3939
  { id: "dsh-plugin-opc#opc/appList", service: "opc", namespace: "opc", method: "appList", invocation: { kind: "direct" }, parameters: [{ name: "expectedContextId", wire: "expectedContextId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appList:expectedContextId", create: () => z.string() } }], result: { mode: "strict", typeSymbol: "opc/appList:result", create: () => z.string() } },
3899
3940
  { id: "dsh-plugin-opc#opc/appJob", service: "opc", namespace: "opc", method: "appJob", invocation: { kind: "direct" }, parameters: [{ name: "id", wire: "id", source: "json", codec: { mode: "strict", typeSymbol: "opc/appJob:id", create: () => z.string() } }, { name: "expectedContextId", wire: "expectedContextId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appJob:expectedContextId", create: () => z.string() } }], result: { mode: "strict", typeSymbol: "opc/appJob:result", create: () => z.string() } },
3941
+ { id: "dsh-plugin-opc#opc/appJobByAnalysisSession", service: "opc", namespace: "opc", method: "appJobByAnalysisSession", invocation: { kind: "direct" }, parameters: [{ name: "sessionId", wire: "sessionId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appJobByAnalysisSession:sessionId", create: () => z.string() } }, { name: "expectedContextId", wire: "expectedContextId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appJobByAnalysisSession:expectedContextId", create: () => z.string() } }], result: { mode: "strict", typeSymbol: "opc/appJobByAnalysisSession:result", create: () => z.string() } },
3900
3942
  { id: "dsh-plugin-opc#opc/appCheckSlug", service: "opc", namespace: "opc", method: "appCheckSlug", invocation: { kind: "direct" }, parameters: [{ name: "slug", wire: "slug", source: "json", codec: { mode: "strict", typeSymbol: "opc/appCheckSlug:slug", create: () => z.string() } }, { name: "expectedContextId", wire: "expectedContextId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appCheckSlug:expectedContextId", create: () => z.string() } }], result: { mode: "strict", typeSymbol: "opc/appCheckSlug:result", create: () => z.string() } },
3901
3943
  { id: "dsh-plugin-opc#opc/appOpcConfig", service: "opc", namespace: "opc", method: "appOpcConfig", invocation: { kind: "direct" }, parameters: [{ name: "expectedContextId", wire: "expectedContextId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appOpcConfig:expectedContextId", create: () => z.string() } }], result: { mode: "strict", typeSymbol: "opc/appOpcConfig:result", create: () => z.string() } },
3902
3944
  { id: "dsh-plugin-opc#opc/appPickSourceFolder", service: "opc", namespace: "opc", method: "appPickSourceFolder", invocation: { kind: "direct" }, parameters: [{ name: "expectedContextId", wire: "expectedContextId", source: "json", codec: { mode: "strict", typeSymbol: "opc/appPickSourceFolder:expectedContextId", create: () => z.string() } }], result: { mode: "strict", typeSymbol: "opc/appPickSourceFolder:result", create: () => z.string() } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-opc",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "OPC Enterprise Plugin for DeepSeek Harness (DSH)",
5
5
  "type": "module",
6
6
  "publishConfig": {