dsh-plugin-opc 0.1.33 → 0.1.35

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/lib/client.js CHANGED
@@ -56861,6 +56861,10 @@ function deploymentProgress(job) {
56861
56861
  if (job.status === "unknown") return { label: "\u6B63\u5728\u6838\u5BF9\u53D1\u5E03\u7ED3\u679C\u2026", tone: "warn" };
56862
56862
  return { label: "\u6B63\u5728\u6784\u5EFA\u90E8\u7F72\u2026", tone: "warn" };
56863
56863
  }
56864
+ function blockedByPreviousBuild(job) {
56865
+ const deploymentError = (job.error ?? "").split("; previous version recovery failed:", 1)[0];
56866
+ return job.failureStage === "deployment" && /1108/.test(deploymentError) && /Build in-progress for /i.test(deploymentError);
56867
+ }
56864
56868
  var isDeploymentInProgress = (status) => status === "publishing" || status === "building" || status === "verifying" || status === "unknown";
56865
56869
  function DeploymentLogs({ fetchLogs, live, buildOnly, failed, onCopy, copied }) {
56866
56870
  const [open2, setOpen] = (0, import_react8.useState)(live || failed);
@@ -57652,6 +57656,21 @@ function AppsPanel({
57652
57656
  setWizardBusy(false);
57653
57657
  }
57654
57658
  };
57659
+ const handleRetryDeployment = async () => {
57660
+ if (!wizardJob) return;
57661
+ setWizardBusy(true);
57662
+ setWizardError(null);
57663
+ try {
57664
+ const raw = await api.appReopenDeployment(wizardJob.id, contextId);
57665
+ const reopened = parseJson(raw, null);
57666
+ if (!reopened) throw new Error("\u65E0\u6CD5\u6062\u590D\u539F\u4EA4\u4ED8\u5305");
57667
+ await resumeWizardJob(reopened, 3);
57668
+ } catch (error62) {
57669
+ setWizardError(readErrorMessage(error62, "\u6062\u590D\u539F\u4EA4\u4ED8\u5305\u5931\u8D25"));
57670
+ } finally {
57671
+ setWizardBusy(false);
57672
+ }
57673
+ };
57655
57674
  const handleSaveLocalArtifact = async (jobId, filename) => {
57656
57675
  setWizardError(null);
57657
57676
  try {
@@ -58136,7 +58155,7 @@ function AppsPanel({
58136
58155
  )))), (wizardJob.proposal?.changes ?? []).length > 0 && /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-subcard" }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-subcard-head" }, /* @__PURE__ */ import_react8.default.createElement("span", null, "\u6E90\u7801\u6539\u9020\u6E05\u5355"), /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-pill oa-pill-accent" }, wizardJob.proposal.changes.length, " \u9879")), /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 8 } }, wizardJob.proposal.changes.map((ch, idx) => /* @__PURE__ */ import_react8.default.createElement("div", { key: ch.id || idx, style: { borderTop: idx > 0 ? "1px solid #f1f5f9" : "none", paddingTop: idx > 0 ? 8 : 0 } }, /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 8 } }, /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-code" }, ch.path), ch.group && /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-pill" }, ch.group)), /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-hint", style: { marginTop: 3 } }, ch.reason))))))), wizardStep === 4 && wizardJob && (() => {
58137
58156
  const progress = deploymentProgress(wizardJob);
58138
58157
  const failed = progress.tone === "danger";
58139
- return /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-deploy-progress" }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-deploy-status", role: "status" }, /* @__PURE__ */ import_react8.default.createElement("span", { className: `oa-pill oa-pill-${progress.tone}` }, /* @__PURE__ */ import_react8.default.createElement("span", { className: `oa-dot${progress.tone === "warn" ? " oa-pulse" : ""}` }), progress.label), progress.tone === "ok" && /* @__PURE__ */ import_react8.default.createElement("a", { href: wizardJob.url, target: "_blank", rel: "noreferrer", className: "oa-btn oa-btn-sm" }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "external", size: 13 }), " \u6253\u5F00\u5E94\u7528")), failed && /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-alert oa-alert-danger", role: "alert" }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "warning", size: 16 }), /* @__PURE__ */ import_react8.default.createElement("div", { style: { whiteSpace: "pre-wrap" } }, wizardJob.error || "\u5E73\u53F0\u672A\u8FD4\u56DE\u5177\u4F53\u5931\u8D25\u539F\u56E0\u3002")), api.appLogs && /* @__PURE__ */ import_react8.default.createElement(
58158
+ return /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-deploy-progress" }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-deploy-status", role: "status" }, /* @__PURE__ */ import_react8.default.createElement("span", { className: `oa-pill oa-pill-${progress.tone}` }, /* @__PURE__ */ import_react8.default.createElement("span", { className: `oa-dot${progress.tone === "warn" ? " oa-pulse" : ""}` }), progress.label), progress.tone === "ok" && /* @__PURE__ */ import_react8.default.createElement("a", { href: wizardJob.url, target: "_blank", rel: "noreferrer", className: "oa-btn oa-btn-sm" }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "external", size: 13 }), " \u6253\u5F00\u5E94\u7528")), failed && /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-alert oa-alert-danger", role: "alert" }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: "warning", size: 16 }), /* @__PURE__ */ import_react8.default.createElement("div", { style: { whiteSpace: "pre-wrap" } }, blockedByPreviousBuild(wizardJob) ? "\u670D\u52A1\u5668\u4E0A\u4E00\u8F6E\u6784\u5EFA\u8FD8\u5728\u8FDB\u884C\u3002\u7B49\u6784\u5EFA\u7ED3\u675F\u540E\uFF0C\u53EF\u6838\u5BF9\u5E76\u91CD\u65B0\u53D1\u5E03\u539F\u4EA4\u4ED8\u5305\u3002" : wizardJob.error || "\u5E73\u53F0\u672A\u8FD4\u56DE\u5177\u4F53\u5931\u8D25\u539F\u56E0\u3002")), api.appLogs && /* @__PURE__ */ import_react8.default.createElement(
58140
58159
  DeploymentLogs,
58141
58160
  {
58142
58161
  key: wizardJob.id + ":" + (wizardJob.version ?? ""),
@@ -58147,7 +58166,7 @@ function AppsPanel({
58147
58166
  onCopy: (text5) => void copyText("wizard-logs", text5),
58148
58167
  copied: copiedKey === "wizard-logs"
58149
58168
  }
58150
- ), /* @__PURE__ */ import_react8.default.createElement("div", null, /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn oa-btn-sm", disabled: wizardBusy, onClick: () => void handleLaunchRepair() }, "\u8BA9 AI \u5206\u6790\u4FEE\u590D\u95EE\u9898"))));
58169
+ ), /* @__PURE__ */ import_react8.default.createElement("div", null, blockedByPreviousBuild(wizardJob) ? /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn oa-btn-sm", disabled: wizardBusy, onClick: () => void handleRetryDeployment() }, "\u6838\u5BF9\u5E76\u91CD\u65B0\u90E8\u7F72") : /* @__PURE__ */ import_react8.default.createElement("button", { type: "button", className: "oa-btn oa-btn-sm", disabled: wizardBusy, onClick: () => void handleLaunchRepair() }, "\u8BA9 AI \u5206\u6790\u4FEE\u590D\u95EE\u9898"))));
58151
58170
  })()), /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-overlay-footer" }, wizardStep === 1 && /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(
58152
58171
  "button",
58153
58172
  {
@@ -59876,6 +59895,12 @@ function Panel({ api, sessionId, requestedPage, navigationRevision, visible = tr
59876
59895
  const [services, setServices] = (0, import_react11.useState)([]);
59877
59896
  const [appsRefreshTrigger, setAppsRefreshTrigger] = (0, import_react11.useState)(0);
59878
59897
  const [showSettings, setShowSettings] = (0, import_react11.useState)(false);
59898
+ const [knowledgeFilter, setKnowledgeFilter] = (0, import_react11.useState)("all");
59899
+ const [includesSharedKnowledge, setIncludesSharedKnowledge] = (0, import_react11.useState)(null);
59900
+ const knowledgeItems = items.filter((item) => {
59901
+ const shared = item.source_tenant_id && item.source_tenant_id !== item.tenant_id;
59902
+ return knowledgeFilter === "all" || (knowledgeFilter === "shared" ? shared : !shared);
59903
+ });
59879
59904
  const [kbSearchMode, setKbSearchMode] = (0, import_react11.useState)("doc");
59880
59905
  const [docQuery, setDocQuery] = (0, import_react11.useState)("");
59881
59906
  const [hasSearchedDoc, setHasSearchedDoc] = (0, import_react11.useState)(false);
@@ -59929,14 +59954,22 @@ function Panel({ api, sessionId, requestedPage, navigationRevision, visible = tr
59929
59954
  if (kind === "mcp") {
59930
59955
  const body = JSON.parse(await api.listMcpServices());
59931
59956
  if (version2 === epoch.current) setServices(body.data?.services ?? body.services ?? []);
59932
- } else {
59933
- const rows = JSON.parse(await (kind === "skills" ? api.listSkillsCatalog(query) : api.listKnowledgeBases(query)));
59957
+ } else if (kind === "skills") {
59958
+ const rows = JSON.parse(await api.listSkillsCatalog(query));
59934
59959
  if (version2 === epoch.current) setItems(rows);
59960
+ } else {
59961
+ const directory = JSON.parse(await api.listKnowledgeBases(query));
59962
+ if (version2 === epoch.current) {
59963
+ setItems(Array.isArray(directory) ? directory : directory.items);
59964
+ setIncludesSharedKnowledge(directory.includesShared === true);
59965
+ }
59935
59966
  }
59936
59967
  }, [api, kind, q]);
59937
59968
  (0, import_react11.useEffect)(() => {
59938
59969
  epoch.current++;
59939
59970
  setItems([]);
59971
+ setKnowledgeFilter("all");
59972
+ setIncludesSharedKnowledge(null);
59940
59973
  setHits([]);
59941
59974
  setDoc("");
59942
59975
  setServices([]);
@@ -60082,7 +60115,7 @@ function Panel({ api, sessionId, requestedPage, navigationRevision, visible = tr
60082
60115
  value: kb,
60083
60116
  onChange: (e) => setKb(e.target.value)
60084
60117
  },
60085
- /* @__PURE__ */ import_react11.default.createElement("option", { value: "" }, "\u5F53\u524D\u7A7A\u95F4\u5168\u90E8\u77E5\u8BC6\u5E93"),
60118
+ /* @__PURE__ */ import_react11.default.createElement("option", { value: "" }, "\u5F53\u524D\u7A7A\u95F4\u5168\u90E8\u53EF\u7528\u77E5\u8BC6\u5E93"),
60086
60119
  items.map((item) => /* @__PURE__ */ import_react11.default.createElement("option", { key: item.knowledge_base_id, value: item.knowledge_base_id }, item.name))
60087
60120
  ),
60088
60121
  /* @__PURE__ */ import_react11.default.createElement(
@@ -60144,7 +60177,7 @@ function Panel({ api, sessionId, requestedPage, navigationRevision, visible = tr
60144
60177
  },
60145
60178
  "\u6E05\u9664"
60146
60179
  )
60147
- ), hasSearchedDoc && hits.length === 0 && !busy && /* @__PURE__ */ import_react11.default.createElement("div", { className: "notice", style: { background: "#f8fafc", borderColor: "#94a3b8", color: "#64748b", fontSize: 12, margin: "8px 0" } }, "\u672A\u627E\u5230\u4E0E\u201C", docQuery, "\u201D\u76F8\u5173\u7684\u6587\u6863\u7247\u6BB5\u3002\u53EF\u5C1D\u8BD5\u66F4\u6362\u68C0\u7D22\u8BCD\uFF0C\u6216\u5728\u4E0A\u65B9\u9009\u62E9\u300C\u5F53\u524D\u7A7A\u95F4\u5168\u90E8\u77E5\u8BC6\u5E93\u300D\u3002"), hits.length > 0 && /* @__PURE__ */ import_react11.default.createElement("div", { className: "kb-results-card" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "kb-results-header" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "kb-results-title" }, /* @__PURE__ */ import_react11.default.createElement("span", null, "\u{1F4C4} \u6587\u6863\u68C0\u7D22\u7ED3\u679C"), /* @__PURE__ */ import_react11.default.createElement("span", { className: "badge badge-ok" }, hits.length, " \u6761\u76F8\u5173\u7247\u6BB5")), /* @__PURE__ */ import_react11.default.createElement(
60180
+ ), hasSearchedDoc && hits.length === 0 && !busy && /* @__PURE__ */ import_react11.default.createElement("div", { className: "notice", style: { background: "#f8fafc", borderColor: "#94a3b8", color: "#64748b", fontSize: 12, margin: "8px 0" } }, "\u672A\u627E\u5230\u4E0E\u201C", docQuery, "\u201D\u76F8\u5173\u7684\u6587\u6863\u7247\u6BB5\u3002\u53EF\u5C1D\u8BD5\u66F4\u6362\u68C0\u7D22\u8BCD\uFF0C\u6216\u5728\u4E0A\u65B9\u9009\u62E9\u300C\u5F53\u524D\u7A7A\u95F4\u5168\u90E8\u53EF\u7528\u77E5\u8BC6\u5E93\u300D\u3002"), hits.length > 0 && /* @__PURE__ */ import_react11.default.createElement("div", { className: "kb-results-card" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "kb-results-header" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "kb-results-title" }, /* @__PURE__ */ import_react11.default.createElement("span", null, "\u{1F4C4} \u6587\u6863\u68C0\u7D22\u7ED3\u679C"), /* @__PURE__ */ import_react11.default.createElement("span", { className: "badge badge-ok" }, hits.length, " \u6761\u76F8\u5173\u7247\u6BB5")), /* @__PURE__ */ import_react11.default.createElement(
60148
60181
  "button",
60149
60182
  {
60150
60183
  type: "button",
@@ -60170,10 +60203,10 @@ function Panel({ api, sessionId, requestedPage, navigationRevision, visible = tr
60170
60203
  String(hit.title ?? hit.knowledge_id)
60171
60204
  ), typeof hit.score === "number" && /* @__PURE__ */ import_react11.default.createElement("span", { className: "badge" }, "\u76F8\u5173\u5EA6: ", hit.score.toFixed(2))), /* @__PURE__ */ import_react11.default.createElement("p", { style: { margin: "6px 0 0", fontSize: 12, color: "#64748b", lineHeight: 1.5 } }, String(hit.snippet ?? hit.content ?? ""))))), doc && /* @__PURE__ */ import_react11.default.createElement("div", { className: "doc-box", style: { marginTop: 0, marginBottom: 14 } }, /* @__PURE__ */ import_react11.default.createElement("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 10 } }, /* @__PURE__ */ import_react11.default.createElement("strong", null, "\u{1F4C4} \u6587\u6863\u8BE6\u60C5\u6B63\u6587"), /* @__PURE__ */ import_react11.default.createElement("button", { onClick: () => setDoc("") }, "\u5173\u95ED\u6B63\u6587")), /* @__PURE__ */ import_react11.default.createElement(Markdown, null, doc)), pin && /* @__PURE__ */ import_react11.default.createElement("div", { className: "notice" }, /* @__PURE__ */ import_react11.default.createElement("strong", null, "\u5F53\u524D\u5BF9\u8BDD\u95EE\u7B54\u5DF2\u9650\u5B9A\u8303\u56F4\uFF1A"), items.find((item) => item.knowledge_base_id === pin)?.name ?? pin, /* @__PURE__ */ import_react11.default.createElement("button", { style: { marginLeft: 8 }, onClick: action(async () => {
60172
60205
  await api.setPinnedKnowledgeScope(sessionId, null, context.contextId);
60173
- }) }, "\u53D6\u6D88\u9650\u5B9A")), /* @__PURE__ */ import_react11.default.createElement("div", { className: "kb-section-header" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "kb-section-title" }, /* @__PURE__ */ import_react11.default.createElement("span", null, "\u{1F4DA} \u77E5\u8BC6\u5E93\u5217\u8868"), /* @__PURE__ */ import_react11.default.createElement("span", { className: "badge" }, items.length)), q ? /* @__PURE__ */ import_react11.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 6 } }, /* @__PURE__ */ import_react11.default.createElement("span", { className: "badge badge-warn" }, "\u5DF2\u6309\u201C", q, "\u201D\u8FC7\u6EE4"), /* @__PURE__ */ import_react11.default.createElement("button", { className: "btn-sm", onClick: () => {
60206
+ }) }, "\u53D6\u6D88\u9650\u5B9A")), /* @__PURE__ */ import_react11.default.createElement("div", { className: "kb-section-header" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "kb-section-title" }, /* @__PURE__ */ import_react11.default.createElement("span", null, "\u{1F4DA} \u77E5\u8BC6\u5E93\u5217\u8868"), /* @__PURE__ */ import_react11.default.createElement("span", { className: "badge" }, knowledgeItems.length), includesSharedKnowledge && /* @__PURE__ */ import_react11.default.createElement("select", { "aria-label": "\u77E5\u8BC6\u5E93\u6765\u6E90", value: knowledgeFilter, onChange: (e) => setKnowledgeFilter(e.target.value) }, /* @__PURE__ */ import_react11.default.createElement("option", { value: "all" }, "\u5168\u90E8\u53EF\u7528"), /* @__PURE__ */ import_react11.default.createElement("option", { value: "owned" }, "\u672C\u7A7A\u95F4"), /* @__PURE__ */ import_react11.default.createElement("option", { value: "shared" }, "\u5171\u4EAB\u7ED9\u6211"))), q ? /* @__PURE__ */ import_react11.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 6 } }, /* @__PURE__ */ import_react11.default.createElement("span", { className: "badge badge-warn" }, "\u5DF2\u6309\u201C", q, "\u201D\u8FC7\u6EE4"), /* @__PURE__ */ import_react11.default.createElement("button", { className: "btn-sm", onClick: () => {
60174
60207
  setQ("");
60175
60208
  void run(() => load(""));
60176
- } }, "\u6E05\u9664\u8FC7\u6EE4")) : /* @__PURE__ */ import_react11.default.createElement("span", { style: { fontSize: 11, color: "#94a3b8" } }, "\u70B9\u51FB\u5361\u7247\u300C\u68C0\u7D22\u6B64\u5E93\u300D\u53EF\u76F4\u63A5\u5B9A\u4F4D\u641C\u7D22")), /* @__PURE__ */ import_react11.default.createElement("div", { className: "cards-grid" }, items.map((item) => /* @__PURE__ */ import_react11.default.createElement("div", { key: item.knowledge_base_id, className: "resource-card" }, /* @__PURE__ */ import_react11.default.createElement("div", null, /* @__PURE__ */ import_react11.default.createElement("div", { className: "card-header" }, /* @__PURE__ */ import_react11.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 } }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "card-icon", style: { background: "#f8fafc", color: "#334155" } }, "\u{1F4D6}"), /* @__PURE__ */ import_react11.default.createElement("h3", { className: "card-title" }, item.name)), /* @__PURE__ */ import_react11.default.createElement("span", { className: `badge ${item.availability === "available" ? "badge-ok" : ""}` }, item.availability === "available" ? "\u5DF2\u5C31\u7EEA" : "\u672A\u5C31\u7EEA")), /* @__PURE__ */ import_react11.default.createElement("p", { className: "card-desc" }, item.description || "\u6682\u65E0\u77E5\u8BC6\u5E93\u63CF\u8FF0")), /* @__PURE__ */ import_react11.default.createElement("div", { className: "card-actions" }, /* @__PURE__ */ import_react11.default.createElement(
60209
+ } }, "\u6E05\u9664\u8FC7\u6EE4")) : /* @__PURE__ */ import_react11.default.createElement("span", { style: { fontSize: 11, color: "#94a3b8" } }, "\u70B9\u51FB\u5361\u7247\u300C\u68C0\u7D22\u6B64\u5E93\u300D\u53EF\u76F4\u63A5\u5B9A\u4F4D\u641C\u7D22")), includesSharedKnowledge === false && /* @__PURE__ */ import_react11.default.createElement("div", { className: "notice" }, "\u5F53\u524D\u5E73\u53F0\u7248\u672C\u4EC5\u63D0\u4F9B\u672C\u7A7A\u95F4\u77E5\u8BC6\u5E93\u76EE\u5F55\u3002"), items.length > 0 && knowledgeItems.length === 0 && /* @__PURE__ */ import_react11.default.createElement("div", { className: "notice" }, "\u6B64\u6765\u6E90\u4E0B\u6CA1\u6709\u53EF\u7528\u77E5\u8BC6\u5E93\u3002"), /* @__PURE__ */ import_react11.default.createElement("div", { className: "cards-grid" }, knowledgeItems.map((item) => /* @__PURE__ */ import_react11.default.createElement("div", { key: item.knowledge_base_id, className: "resource-card" }, /* @__PURE__ */ import_react11.default.createElement("div", null, /* @__PURE__ */ import_react11.default.createElement("div", { className: "card-header" }, /* @__PURE__ */ import_react11.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 } }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "card-icon", style: { background: "#f8fafc", color: "#334155" } }, "\u{1F4D6}"), /* @__PURE__ */ import_react11.default.createElement("h3", { className: "card-title" }, item.name)), /* @__PURE__ */ import_react11.default.createElement("span", { className: `badge ${item.availability === "available" ? "badge-ok" : ""}` }, item.availability === "available" ? "\u5DF2\u5C31\u7EEA" : "\u672A\u5C31\u7EEA")), item.source_tenant_id && item.source_tenant_id !== item.tenant_id && /* @__PURE__ */ import_react11.default.createElement("span", { className: "badge" }, "\u5171\u4EAB\u81EA ", item.source_tenant_name ?? item.source_tenant_id, item.permission === "viewer" ? " \xB7 \u53EA\u8BFB" : ""), /* @__PURE__ */ import_react11.default.createElement("p", { className: "card-desc" }, item.description || "\u6682\u65E0\u77E5\u8BC6\u5E93\u63CF\u8FF0")), /* @__PURE__ */ import_react11.default.createElement("div", { className: "card-actions" }, /* @__PURE__ */ import_react11.default.createElement(
60177
60210
  "button",
60178
60211
  {
60179
60212
  className: "primary",
package/lib/index.js CHANGED
@@ -510,6 +510,9 @@ function resourceItem(value) {
510
510
  tenant_id: item.tenant_id,
511
511
  name: item.name,
512
512
  availability: item.availability,
513
+ source_tenant_id: typeof item.source_tenant_id === "string" ? item.source_tenant_id : void 0,
514
+ source_tenant_name: typeof item.source_tenant_name === "string" ? item.source_tenant_name : void 0,
515
+ permission: typeof item.permission === "string" ? item.permission : void 0,
513
516
  catalog_id: typeof item.catalog_id === "string" ? item.catalog_id : void 0,
514
517
  knowledge_base_id: typeof item.knowledge_base_id === "string" ? item.knowledge_base_id : void 0,
515
518
  version: typeof item.version === "string" ? item.version : void 0,
@@ -557,7 +560,7 @@ var ResourceAuthorization = class {
557
560
  captured.assertCurrent();
558
561
  const key = JSON.stringify(["knowledge", tenant, id]);
559
562
  const cached = this.#entries.get(key);
560
- if (cached && cached.expires > Date.now()) return;
563
+ if (cached && cached.expires > Date.now()) return cached.item;
561
564
  const items = await list();
562
565
  captured.assertCurrent();
563
566
  const item = items.find((item2) => item2.tenant_id === tenant && item2.knowledge_base_id === id && item2.availability === "available");
@@ -566,6 +569,7 @@ var ResourceAuthorization = class {
566
569
  throw new OpcError("RESOURCE_NOT_ACCESSIBLE");
567
570
  }
568
571
  this.#entries.set(key, { item, expires: Date.now() + 3e4 });
572
+ return item;
569
573
  }
570
574
  async catalog(tenant, catalog) {
571
575
  this.sync();
@@ -974,14 +978,22 @@ var OpcCore = class extends EventEmitter2 {
974
978
  return response.body;
975
979
  }
976
980
  async catalog(kind, q = "") {
981
+ return (await this.resourceDirectory(kind, q)).items;
982
+ }
983
+ async knowledgeDirectory(q = "") {
984
+ return this.resourceDirectory("knowledge-bases", q);
985
+ }
986
+ async resourceDirectory(kind, q) {
977
987
  const captured = this.auth.contexts.capture();
978
988
  const items = [];
979
- let offset = 0, complete = true;
989
+ const sharedQuery = kind === "knowledge-bases" ? "&include_shared=true" : "";
990
+ let offset = 0, complete = true, includesShared = kind === "knowledge-bases";
980
991
  for (; ; ) {
981
- const page = await this.request(`/integration/v1/resources/${kind}?tenant_id=${encodeURIComponent(captured.context.tenant)}&q=${encodeURIComponent(q)}&offset=${offset}&limit=100`);
992
+ const page = await this.request(`/integration/v1/resources/${kind}?tenant_id=${encodeURIComponent(captured.context.tenant)}&q=${encodeURIComponent(q)}&offset=${offset}&limit=100${sharedQuery}`);
982
993
  captured.assertCurrent();
983
994
  if (!Array.isArray(page.items) || typeof page.total !== "number") throw new OpcError("INVALID_PLATFORM_RESPONSE");
984
995
  complete &&= page.complete === true && (!Array.isArray(page.failures) || page.failures.length === 0);
996
+ includesShared &&= page.includes_shared === true;
985
997
  const current = page.items.map(resourceItem);
986
998
  if (current.some((item) => item.tenant_id !== captured.context.tenant)) throw new OpcError("SCOPE_MISMATCH");
987
999
  items.push(...current);
@@ -994,7 +1006,8 @@ var OpcCore = class extends EventEmitter2 {
994
1006
  }
995
1007
  this.emit("skills-changed");
996
1008
  }
997
- return items;
1009
+ if (kind === "knowledge-bases" && !complete) throw new OpcError("RESOURCE_DIRECTORY_INCOMPLETE", "\u77E5\u8BC6\u5E93\u76EE\u5F55\u52A0\u8F7D\u4E0D\u5B8C\u6574\uFF0C\u8BF7\u5237\u65B0\u91CD\u8BD5\u3002");
1010
+ return { items, includesShared };
998
1011
  }
999
1012
  }
1000
1013
  }
@@ -1014,16 +1027,14 @@ var OpcCore = class extends EventEmitter2 {
1014
1027
  const captured = this.auth.contexts.capture();
1015
1028
  const scope = this.scopes.searchParams(session, turn, space, knowledgeBaseId);
1016
1029
  if (scope.tenant_id !== captured.context.tenant) throw new OpcError("SPACE_FORBIDDEN");
1017
- if (scope.knowledge_base_id) {
1018
- await this.authz.knowledge(captured.context.tenant, scope.knowledge_base_id, () => this.catalog("knowledge-bases"));
1019
- }
1030
+ const scopedItem = scope.knowledge_base_id ? await this.authz.knowledge(captured.context.tenant, scope.knowledge_base_id, () => this.catalog("knowledge-bases")) : void 0;
1020
1031
  captured.assertCurrent();
1021
- const result = await this.request("/integration/v1/knowledge/search", { query, ...scope });
1032
+ const result = await this.request("/integration/v1/knowledge/search", { query, ...scope, include_shared: true });
1022
1033
  captured.assertCurrent();
1023
1034
  if (!Array.isArray(result.results)) throw new OpcError("INVALID_PLATFORM_RESPONSE");
1024
1035
  const ids = result.results.map((hit) => {
1025
1036
  if (!hit || typeof hit !== "object" || typeof hit.knowledge_id !== "string") throw new OpcError("INVALID_PLATFORM_RESPONSE");
1026
- if (scope.knowledge_base_id && ((hit.source_tenant ?? hit.tenant_id) !== scope.tenant_id || hit.knowledge_base_id !== scope.knowledge_base_id)) throw new OpcError("SCOPE_MISMATCH");
1037
+ if ((hit.tenant_id ?? hit.source_tenant) !== scope.tenant_id || scopedItem && (hit.knowledge_base_id !== scopedItem.knowledge_base_id || (hit.source_tenant ?? hit.tenant_id) !== (scopedItem.source_tenant_id ?? scopedItem.tenant_id))) throw new OpcError("SCOPE_MISMATCH");
1027
1038
  return hit.knowledge_id;
1028
1039
  });
1029
1040
  this.scopes.recordHits(session, turn, ids);
@@ -1035,14 +1046,16 @@ var OpcCore = class extends EventEmitter2 {
1035
1046
  const scope = this.scopes.scope(session, turn);
1036
1047
  await this.authz.session();
1037
1048
  captured.assertCurrent();
1038
- if (scope) await this.authz.knowledge(captured.context.tenant, scope.knowledgeBaseId, () => this.catalog("knowledge-bases"));
1049
+ const scopedItem = scope ? await this.authz.knowledge(captured.context.tenant, scope.knowledgeBaseId, () => this.catalog("knowledge-bases")) : void 0;
1039
1050
  captured.assertCurrent();
1040
- const result = await this.request(`/integration/v1/knowledge/${encodeURIComponent(knowledgeId)}?include_content=true&tenant=${encodeURIComponent(captured.context.tenant)}${scope ? `&knowledge_base_id=${encodeURIComponent(scope.knowledgeBaseId)}` : ""}`);
1051
+ const result = await this.request(`/integration/v1/knowledge/${encodeURIComponent(knowledgeId)}?include_content=true&include_shared=true&tenant=${encodeURIComponent(captured.context.tenant)}${scope ? `&knowledge_base_id=${encodeURIComponent(scope.knowledgeBaseId)}` : ""}`);
1041
1052
  captured.assertCurrent();
1042
1053
  const data = result.data;
1043
- this.scopes.verifyDocument(session, turn, String(result.source_tenant ?? ""), data?.knowledge_base_id ?? "");
1044
- if (result.source_tenant !== captured.context.tenant || !data?.knowledge_base_id) throw new OpcError("SCOPE_MISMATCH");
1045
- await this.authz.knowledge(captured.context.tenant, data.knowledge_base_id, () => this.catalog("knowledge-bases"));
1054
+ const tenant = result.tenant_id ?? result.source_tenant;
1055
+ if (tenant !== captured.context.tenant || !data?.knowledge_base_id) throw new OpcError("SCOPE_MISMATCH");
1056
+ this.scopes.verifyDocument(session, turn, tenant, data.knowledge_base_id);
1057
+ const item = scopedItem ?? await this.authz.knowledge(tenant, data.knowledge_base_id, () => this.catalog("knowledge-bases"));
1058
+ if (result.source_tenant !== (item.source_tenant_id ?? item.tenant_id)) throw new OpcError("SCOPE_MISMATCH");
1046
1059
  captured.assertCurrent();
1047
1060
  if (typeof data?.content !== "string") throw new OpcError("KNOWLEDGE_CONTENT_UNAVAILABLE", "\u5E73\u53F0\u672A\u8FD4\u56DE\u6587\u6863\u6B63\u6587\uFF0C\u9700\u8981\u542F\u7528\u6B63\u6587\u8BFB\u53D6\u63A5\u53E3\u3002");
1048
1061
  return result;
@@ -1791,7 +1804,7 @@ var OpcRemoteService = class extends (_a = TypertRemoteService, _appList_dec = [
1791
1804
  this.core.auth.switchTenant(tenantId);
1792
1805
  }
1793
1806
  async listKnowledgeBases(q) {
1794
- return JSON.stringify(await this.core.catalog("knowledge-bases", q));
1807
+ return JSON.stringify(await this.core.knowledgeDirectory(q));
1795
1808
  }
1796
1809
  async listSkillsCatalog(q) {
1797
1810
  const captured = this.core.auth.contexts.capture();
@@ -2644,6 +2657,7 @@ var AppDelivery = class {
2644
2657
  busy = /* @__PURE__ */ new Set();
2645
2658
  analyses = /* @__PURE__ */ new Map();
2646
2659
  adminReplies = /* @__PURE__ */ new Map();
2660
+ preparedProposals = /* @__PURE__ */ new Map();
2647
2661
  analyze;
2648
2662
  getOptions() {
2649
2663
  return { ...this.options };
@@ -3288,6 +3302,10 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
3288
3302
  try {
3289
3303
  await this.save(root, job);
3290
3304
  } finally {
3305
+ const unused = this.preparedProposals.get(id);
3306
+ this.preparedProposals.delete(id);
3307
+ if (unused) await rm2(join3(root, unused.revision), { recursive: true, force: true }).catch(() => {
3308
+ });
3291
3309
  if (job.status !== "review" || !job.proposal?.adminAccountPending) this.adminReplies.delete(id);
3292
3310
  this.analyses.delete(id);
3293
3311
  this.busy.delete(id);
@@ -3301,6 +3319,20 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
3301
3319
  if (job.status !== "analyzing" && job.status !== "review") throw new Error("\u5F53\u524D\u5E94\u7528\u51C6\u5907\u9636\u6BB5\u65E0\u6CD5\u63A5\u6536\u56DE\u590D");
3302
3320
  const account = job.proposal?.contract?.admin_account;
3303
3321
  const adminReply = job.proposal?.adminAccountPending && account ? readAdminReply(account, text3) : void 0;
3322
+ const proposalWithAccount = adminReply && job.proposal ? { ...job.proposal, adminAccountPending: false } : void 0;
3323
+ if (job.status === "review" && adminReply && proposalWithAccount && !analysisQuestions(proposalWithAccount).length) {
3324
+ const next2 = {
3325
+ ...job,
3326
+ proposal: proposalWithAccount,
3327
+ analysisFailure: void 0,
3328
+ events: [...job.events, "\u5DF2\u6536\u5230\u7BA1\u7406\u5458\u8D26\u5BC6\uFF0C\u7EE7\u7EED\u751F\u6210\u4EA4\u4ED8\u5305"]
3329
+ };
3330
+ signal.throwIfAborted();
3331
+ await this.save(root, { ...next2, proposal: job.proposal });
3332
+ this.adminReplies.set(job.id, adminReply);
3333
+ Object.assign(job, next2);
3334
+ return "";
3335
+ }
3304
3336
  const reply = adminReply ? "\u7528\u6237\u5DF2\u7ECF\u5728\u5F53\u524D\u5BF9\u8BDD\u63D0\u4F9B\u7BA1\u7406\u5458\u8D26\u53F7\u548C\u5BC6\u7801\u3002\u4FDD\u7559\u4E0A\u4E00\u7248 admin_account \u8BA4\u8BC1\u65B9\u6848\u4E0E\u5B9E\u9645\u5B58\u50A8\u4F4D\u7F6E\u5E76\u91CD\u65B0\u63D0\u4EA4\uFF0COPC \u4F1A\u628A\u8D26\u5BC6\u5199\u5165\u5E94\u7528\u548C\u6280\u80FD\u3002" : await worker({ action: "redact_feedback", root, text: text3.slice(0, 2e4) }, signal);
3305
3337
  signal.throwIfAborted();
3306
3338
  const next = {
@@ -3441,7 +3473,7 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
3441
3473
  feedback: job.feedbackHistory ?? ""
3442
3474
  } }, scope.signal);
3443
3475
  }
3444
- async submit(job, root, proposal, signal) {
3476
+ async submit(job, root, proposal, signal, options) {
3445
3477
  if (proposal.contract?.slug !== job.slug || proposal.contract?.base_url !== job.url) throw new Error("\u5E94\u7528\u6807\u8BC6\u6216\u5730\u5740\u4E0E\u5BFC\u5165\u65F6\u4E0D\u4E00\u81F4");
3446
3478
  if (job.status !== "analyzing") throw new Error("\u672C\u8F6E\u5DF2\u63D0\u4EA4\u65B9\u6848");
3447
3479
  if (!Array.isArray(proposal.unresolved) || proposal.contract.unresolved !== void 0 && !Array.isArray(proposal.contract.unresolved)) {
@@ -3469,11 +3501,15 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
3469
3501
  }
3470
3502
  if (!job.portAuto && actualPort !== expectedPort) throw new Error(`${field} \u586B\u4E86 ${actualPort}\uFF0C\u4E0E\u5DF2\u9501\u5B9A\u7684\u5BB9\u5668\u7AEF\u53E3 ${expectedPort} \u4E0D\u4E00\u81F4\u3002\u6A21\u578B\u4E0D\u80FD\u9759\u9ED8\u6539\u53D8\u7528\u6237\u9009\u62E9\u7684\u5BB9\u5668\u7AEF\u53E3`);
3471
3503
  }
3504
+ const allowUnresolved = hasQuestions || adminAccountPending;
3505
+ const preparedRevision = options?.dockerfileOnly && !allowUnresolved ? randomUUID4().replaceAll("-", "") : void 0;
3472
3506
  const validated = await worker({
3473
- action: "validate",
3507
+ action: preparedRevision ? "bundle" : "validate",
3508
+ revision: preparedRevision,
3474
3509
  root,
3475
3510
  proposal,
3476
- allow_unresolved: hasQuestions || adminAccountPending,
3511
+ allow_unresolved: allowUnresolved,
3512
+ dockerfile_only: options?.dockerfileOnly === true,
3477
3513
  reuse_source_admin: !job.upgrade && !job.published && !adminReply && !canReusePrevious,
3478
3514
  admin_reply: adminReply,
3479
3515
  previous_skill_markdown: canReusePrevious ? job.skillMarkdown : void 0,
@@ -3483,7 +3519,14 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
3483
3519
  revision_count: job.revisionCount ?? 1,
3484
3520
  feedback: job.feedbackHistory ?? "",
3485
3521
  expected_port: job.portAuto ? null : job.port ?? 8080
3486
- }, signal);
3522
+ }, signal).catch(async (error) => {
3523
+ if (preparedRevision) await rm2(join3(root, preparedRevision), { recursive: true, force: true }).catch(() => {
3524
+ });
3525
+ throw error;
3526
+ });
3527
+ if (preparedRevision) {
3528
+ this.preparedProposals.set(job.id, { revision: preparedRevision, proposalHash: fingerprint(validated.proposal), result: validated });
3529
+ }
3487
3530
  signal.throwIfAborted();
3488
3531
  if (job.status !== "analyzing") throw new Error("\u672C\u8F6E\u5DF2\u63D0\u4EA4\u65B9\u6848");
3489
3532
  job.proposal = validated?.proposal ?? proposal;
@@ -3522,8 +3565,10 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
3522
3565
  job.events.push("\u6B63\u5728\u751F\u6210\u5E76\u68C0\u67E5\u4EA4\u4ED8\u5305");
3523
3566
  await this.save(root, job);
3524
3567
  try {
3525
- const revision = randomUUID4().replaceAll("-", "");
3526
- const result = await worker({
3568
+ const prepared = this.preparedProposals.get(job.id);
3569
+ const reusable = prepared && prepared.proposalHash === fingerprint(job.proposal) ? prepared : void 0;
3570
+ const revision = reusable?.revision ?? randomUUID4().replaceAll("-", "");
3571
+ const result = reusable?.result ?? await worker({
3527
3572
  action: "bundle",
3528
3573
  root,
3529
3574
  revision,
@@ -3539,6 +3584,7 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
3539
3584
  }, signal);
3540
3585
  signal.throwIfAborted();
3541
3586
  assertCurrent();
3587
+ if (reusable) this.preparedProposals.delete(job.id);
3542
3588
  job.revision = revision;
3543
3589
  job.hashes = result.summary.files;
3544
3590
  job.proposal = result.proposal ?? job.proposal;
@@ -4405,7 +4451,7 @@ function proposalParameters(port, portLocked = true) {
4405
4451
  impact: text2,
4406
4452
  recommendation: text2
4407
4453
  } } },
4408
- unresolved: { ...strings, description: "\u82E5\u6D89\u53CA\u4EE4\u724C/\u767B\u5F55/\u8D26\u5BC6/\u51ED\u636E/\u6388\u6743\u7801\u7B49\u963B\u585E\u95EE\u9898\uFF0C\u5FC5\u987B\u5728 contract.auth_blockers \u4E2D\u6DFB\u52A0 question \u5B8C\u5168\u4E00\u81F4\u7684\u6761\u76EE\uFF08\u7BA1\u7406\u5458\u767B\u5F55\u901A\u8FC7 admin_account \u5904\u7406\uFF0C\u4E0D\u8981\u5199\u5165 unresolved\uFF09" },
4454
+ unresolved: { ...strings, description: "\u4EC5\u586B\u5199\u5FC5\u987B\u7531\u7528\u6237\u5904\u7406\u7684\u90E8\u7F72\u963B\u585E\u3002\u9274\u6743\u963B\u585E\u9879\u4E0E contract.auth_blockers \u7684 question \u4FDD\u6301\u4E00\u81F4\u3002\u7BA1\u7406\u5458\u8D26\u5BC6\u4F7F\u7528 admin_account\u3002" },
4409
4455
  changes: { ...objects, items: { ...object2, properties: {
4410
4456
  id: text2,
4411
4457
  path: text2,
@@ -4430,7 +4476,7 @@ function proposalParameters(port, portLocked = true) {
4430
4476
  }
4431
4477
  } },
4432
4478
  build_context: { ...strings, required: true },
4433
- health: { ...object2, required: true, properties: { path: text2, status: { type: "integer", required: true }, json_contains: { ...object2, required: true } } },
4479
+ health: { ...object2, description: "\u53EF\u9009\u3002\u4EC5\u7528\u4E8E\u6807\u8BC6\u6E90\u7801\u5DF2\u6709\u7684\u5065\u5EB7\u5165\u53E3\uFF0C\u4E1A\u52A1\u9A8C\u8BC1\u4E0D\u5F97\u4F7F\u7528\u8BE5\u5165\u53E3\u3002\u6CA1\u6709\u5219\u7701\u7565\u3002", properties: { path: text2, status: { type: "integer" }, json_contains: object2 } },
4434
4480
  configs: { ...objects, description: '\u4EC5\u586B\u5199\u6E90\u7801\u771F\u5B9E\u5B58\u5728\u7684\u914D\u7F6E\u952E\uFF08\u53C2\u8003 inventory.source_configuration\uFF09\uFF1Bdefault \u5FC5\u987B\u4E3A\u7A7A\u5B57\u7B26\u4E32 ""\uFF1Bsource \u4EC5\u652F\u6301 YAML/JSON/TOML/.env/properties \u6587\u4EF6\uFF0C\u4E0D\u652F\u6301\u4EE3\u7801\u6587\u4EF6\uFF1B\u4E0D\u8981\u5C06 *.example/*.sample/*.template \u793A\u4F8B\u6587\u4EF6\u91CC\u7684 PORT \u6216\u5360\u4F4D\u5BC6\u94A5\u4F5C\u4E3A\u771F\u5B9E\u8FD0\u884C\u503C\u7ED1\u5B9A\uFF1B\u5982\u5E94\u7528\u5B58\u5728\u4EE3\u7801\u515C\u5E95\u9ED8\u8BA4\u503C\uFF08\u4EC5\u975E\u654F\u611F\uFF09\uFF0C\u53EF\u5199\u5165 app_default \u4F9B\u7B2C 3 \u6B65\u53C2\u8003\u5C55\u793A', items: { ...object2, properties: {
4435
4481
  key: text2,
4436
4482
  default: text2,
@@ -4452,7 +4498,7 @@ function proposalParameters(port, portLocked = true) {
4452
4498
  login_method: str,
4453
4499
  token_json_path: str
4454
4500
  } },
4455
- auth_profiles: { ...object2, description: '\u6309 ID \u4FDD\u5B58\u767B\u5F55\u65B9\u5F0F\u3002\u4F8B\uFF1A{"account":{"login_url":"/api/session","login_method":"POST","username_env":"APP_USER","password_env":"APP_PASSWORD"}}\u3002profile ID \u53EA\u51FA\u73B0\u4E00\u5C42\uFF0C\u63A5\u53E3\u901A\u8FC7 auth.profile \u5F15\u7528\u3002' },
4501
+ auth_profiles: { ...object2, description: '\u6309 ID \u4FDD\u5B58\u767B\u5F55\u65B9\u5F0F\u3002\u4F8B\uFF1A{"account":{"login_url":"/api/session","login_method":"POST","username_env":"APP_USER","password_env":"APP_PASSWORD"}}\u3002profile ID \u53EA\u51FA\u73B0\u4E00\u5C42\uFF0C\u63A5\u53E3\u901A\u8FC7 auth.profile \u5F15\u7528\u3002\u975E\u6807\u51C6\u767B\u5F55\u5B57\u6BB5\u7528 login_body_template\uFF0C\u4EC5\u5141\u8BB8\u8D26\u53F7\u548C\u5BC6\u7801\u5360\u4F4D\u7B26\u3002' },
4456
4502
  admin_account: { ...object2, description: "\u6309\u5E94\u7528\u6E90\u7801\u8BC1\u636E\u9009\u62E9 existing \u6216 create\u3002\u4EC5\u63CF\u8FF0\u8D26\u53F7\u6765\u6E90\u6216\u5199\u5165\u4F4D\u7F6E\uFF0C\u4E0D\u63D0\u4EA4\u5B9E\u9645\u8D26\u5BC6\u3002", properties: {
4457
4503
  mode: { ...text2, enum: ["existing", "create"] },
4458
4504
  profile: text2,
@@ -4460,12 +4506,12 @@ function proposalParameters(port, portLocked = true) {
4460
4506
  source: { ...object2, description: "\u4E3A\u5DF2\u6709\u53EF\u590D\u7528\u8D26\u5BC6\u63D0\u4F9B {username,password} \u5F15\u7528\uFF1A\u7ED3\u6784\u5316\u914D\u7F6E {path,keys}\u3001\u6E90\u7801 {path,line,name} \u6216 SQLite \u660E\u6587\u5B57\u6BB5 {path,table,column,where}\u3002\u6E90\u7801 name \u586B\u5B57\u6BB5\u540D\uFF08\u5982 username\u3001passwordHash\uFF09\uFF0Cline \u586B\u5B9A\u4E49\u8BE5\u5B57\u6BB5\u7684\u884C\u53F7\uFF0C\u7981\u6B62\u586B\u771F\u5B9E\u5BC6\u7801\u3002\u53EA\u6709\u6E90\u7801\u548C\u771F\u5B9E\u914D\u7F6E\u5747\u7F3A\u5C11\u53EF\u590D\u7528\u8D26\u5BC6\u65F6\u624D\u7701\u7565 source\u3002" },
4461
4507
  storage: { ...object2, description: "\u9996\u6B21\u5EFA\u53F7\u4EC5\u5728\u4EA4\u4ED8\u526F\u672C\u4E2D\u5199\u5165\u5E94\u7528\u771F\u6B63\u8BFB\u53D6\u7684 SQLite \u6216 JSON/YAML \u6587\u4EF6\uFF0C\u5177\u4F53\u7ED3\u6784\u89C1 references/contract.md\u3002" }
4462
4508
  } },
4463
- auth_rules: { ...objects, description: '\u6BCF\u6761\u89C4\u5219\u987B\u4E8C\u9009\u4E00\u586B\u5199 path \u6216 prefix\uFF1Bevidence \u662F\u89C4\u5219\u9876\u5C42\u5FC5\u586B\u6570\u7EC4\uFF08\u4E0E auth \u5E73\u7EA7\uFF0C\u4E0D\u8981\u653E\u5728 auth \u5185\u90E8\uFF09\uFF1B\u540C\u6743\u9650\u9875\u9762\u53EF\u7528 target="page" \u4E14 prefix="/" \u7EDF\u4E00\u8986\u76D6', items: { ...object2, properties: {
4509
+ auth_rules: { ...objects, description: "\u5171\u7528\u9274\u6743\u5199\u4E00\u6761 prefix \u89C4\u5219\uFF1B\u516C\u5F00\u767B\u5F55\u7B49\u4F8B\u5916\u7528 path \u548C method\u3002\u767B\u5F55\u65B9\u5F0F\u5199\u5728\u53D7\u4FDD\u62A4\u89C4\u5219\u7684 auth.profile\uFF0C\u4E0D\u80FD\u53EA\u5199\u5728\u516C\u5F00\u767B\u5F55\u63A5\u53E3\u4E0A\u3002evidence \u5728\u89C4\u5219\u9876\u5C42\u3002", items: { ...object2, properties: {
4464
4510
  target: { ...text2, enum: ["api", "page"] },
4465
4511
  path: str,
4466
4512
  prefix: str,
4467
4513
  method: str,
4468
- auth: { ...object2, required: true, properties: { type: { ...text2, enum: ["none", "header", "bearer"] } } },
4514
+ auth: { ...object2, required: true, properties: { type: { ...text2, enum: ["none", "header", "bearer"] }, profile: str, header: str, env: str } },
4469
4515
  evidence: { ...strings, required: true, description: '\u8BFB\u53D6\u5DE5\u5177\u8FD4\u56DE\u7684\u6E90\u7801\u4F4D\u7F6E\u6570\u7EC4\uFF0C\u4F8B\u5982 ["server.mjs:42"]' }
4470
4516
  } } },
4471
4517
  auth_blockers: { ...objects, description: "\u53EA\u586B\u786E\u5B9E\u963B\u585E\u6539\u9020\u7684\u5916\u90E8\u6388\u6743\u6216\u89D2\u8272\u51B3\u5B9A\uFF1B\u7BA1\u7406\u5458\u767B\u5F55\u901A\u8FC7 admin_account \u5904\u7406", items: { ...object2, properties: {
@@ -4486,15 +4532,15 @@ function proposalParameters(port, portLocked = true) {
4486
4532
  responses: { ...object2, required: true },
4487
4533
  auth: { ...routeAuth, required: true },
4488
4534
  effect: { ...text2, enum: ["read", "write", "destructive", "external"] },
4489
- confirmation_required: { ...bool, required: true }
4535
+ confirmation_required: { ...bool, required: true, description: "effect \u4E3A write\u3001destructive \u6216 external \u65F6\u5FC5\u987B\u4E3A true" }
4490
4536
  } } },
4491
4537
  pages: {
4492
4538
  ...objects,
4493
4539
  description: "\u626B\u63CF\u7ED3\u679C\u7531\u63D2\u4EF6\u5408\u5E76\uFF0C\u53EF\u4EE5\u4F20 [] \u6216\u53EA\u8865\u5145\u9700\u8981\u5B9A\u5236\u7684\u9875\u9762",
4494
4540
  items: { ...object2, properties: { auth: routeAuth } }
4495
4541
  },
4496
- verification: object2,
4497
- unresolved: { ...strings, description: "\u82E5\u6D89\u53CA\u4EE4\u724C/\u767B\u5F55/\u8D26\u5BC6/\u51ED\u636E/\u6388\u6743\u7801\u7B49\u963B\u585E\u95EE\u9898\uFF0C\u5FC5\u987B\u5728 contract.auth_blockers \u4E2D\u6DFB\u52A0 question \u5B8C\u5168\u4E00\u81F4\u7684\u6761\u76EE\uFF08\u7BA1\u7406\u5458\u767B\u5F55\u901A\u8FC7 admin_account \u5904\u7406\uFF0C\u4E0D\u8981\u5199\u5165 unresolved\uFF09" }
4542
+ verification: { ...object2, description: "\u4E00\u4E2A\u53EF\u6838\u5B9E\u54CD\u5E94\u5B57\u6BB5\u7684\u4EE3\u8868\u6027\u53EA\u8BFB\u4E1A\u52A1\u7528\u4F8B\u5373\u53EF\u3002\u6709\u53D7\u4FDD\u62A4\u7684\u53EA\u8BFB\u4E1A\u52A1\u63A5\u53E3\u65F6\u9009\u5176\u4E2D\u4E00\u4E2A\u3002\u7EAF\u9875\u9762\u5E94\u7528\u586B\u5199\u6D4F\u89C8\u5668\u7528\u4F8B\u3002" },
4543
+ unresolved: { ...strings, description: "\u4EC5\u4FDD\u7559\u963B\u585E\u90E8\u7F72\u4E14\u9700\u7528\u6237\u51B3\u5B9A\u7684\u95EE\u9898\u3002\u53EF\u9009\u96C6\u6210\u914D\u7F6E\u3001\u6539\u5BC6\u5EFA\u8BAE\u3001\u90E8\u7F72\u540E\u624D\u80FD\u786E\u8BA4\u7684\u4E8B\u9879\u653E\u5728\u6458\u8981\u3002\u9274\u6743\u963B\u585E\u9879\u4F7F\u7528 auth_blockers\uFF0C\u7BA1\u7406\u5458\u8D26\u5BC6\u4F7F\u7528 admin_account\u3002" }
4498
4544
  } },
4499
4545
  decisions: { ...objects, items: { ...object2, properties: {
4500
4546
  id: text2,
@@ -4502,7 +4548,6 @@ function proposalParameters(port, portLocked = true) {
4502
4548
  impact: text2,
4503
4549
  options: { ...strings, required: true }
4504
4550
  } } },
4505
- four_step_report: object2,
4506
4551
  proposal: { ...str, description: "\u65E7\u7248\u5B8C\u6574\u63D0\u6848 JSON \u5B57\u7B26\u4E32\uFF0C\u4EC5\u5728\u6CA1\u6709\u7ED3\u6784\u5316\u53C2\u6570\u65F6\u4F7F\u7528" }
4507
4552
  };
4508
4553
  }
@@ -4510,7 +4555,7 @@ function proposalParameters(port, portLocked = true) {
4510
4555
  // src/host/app-agent.ts
4511
4556
  var ANALYSIS_TIMEOUT_MS = 15 * 6e4;
4512
4557
  var REPLY_TIMEOUT_MS = 30 * 6e4;
4513
- var MAX_VALIDATION_ERRORS = 10;
4558
+ var MAX_VALIDATION_ERRORS = 3;
4514
4559
  function loadBundledSkillText(relativePath) {
4515
4560
  const fromSrc = fileURLToPath2(new URL(`../../runtime/app_delivery/${relativePath}`, import.meta.url));
4516
4561
  const fromLib = fileURLToPath2(new URL(`../runtime/app_delivery/${relativePath}`, import.meta.url));
@@ -4601,7 +4646,7 @@ function attachAppAgent(ctx, delivery) {
4601
4646
  const instructions = `${skill}
4602
4647
  ${portInstructions}${repairInstructions}`;
4603
4648
  const prevPlan = compactPreviousPlan(job.proposal);
4604
- const taskInstruction = "\u6309\u56DB\u6B65\u5B8C\u6210\u672C\u6B21\u5E94\u7528\u6539\u9020\u3002" + (isRepair ? "\u5148\u7528\u5931\u8D25\u5236\u54C1\u6838\u5B9E\u6839\u56E0\u3002" : prevPlan && feedback.trim() ? "\u7ED3\u5408\u7528\u6237\u8865\u5145\u590D\u6838\u4E0A\u4E00\u7248\u65B9\u6848\u3002" : "");
4649
+ const taskInstruction = "\u6309\u4E09\u6B65\u5B8C\u6210\u672C\u6B21\u5E94\u7528\u6539\u9020\u3002" + (isRepair ? "\u5148\u7528\u5931\u8D25\u5236\u54C1\u6838\u5B9E\u6839\u56E0\u3002" : prevPlan && feedback.trim() ? "\u7ED3\u5408\u7528\u6237\u8865\u5145\u590D\u6838\u4E0A\u4E00\u7248\u65B9\u6848\u3002" : "");
4605
4650
  const timeout = new AbortController();
4606
4651
  const abort = AbortSignal.any([signal, timeout.signal]);
4607
4652
  let deadline;
@@ -4647,7 +4692,7 @@ ${portInstructions}${repairInstructions}`;
4647
4692
  rejectedProposals.clear();
4648
4693
  repeatedProposal = false;
4649
4694
  replyCount++;
4650
- messages.push({ ...message, content: [{ type: "text", text: safeText }] });
4695
+ if (safeText) messages.push({ ...message, content: [{ type: "text", text: safeText }] });
4651
4696
  wakeReply?.();
4652
4697
  }
4653
4698
  return messages.length ? { ...decision, messages } : { kind: "reject" };
@@ -4692,7 +4737,7 @@ ${portInstructions}${repairInstructions}`;
4692
4737
  }));
4693
4738
  child.tools.register(defineTool2({
4694
4739
  name: "opc_delivery_propose_file",
4695
- description: "\u6682\u5B58\u6839\u76EE\u5F55 Dockerfile \u6216\u73B0\u6709\u5E94\u7528\u4EE3\u7801\u7684\u5FC5\u8981\u6539\u52A8\u3002\u7981\u6B62\u65B0\u589E\u6216\u6539\u5199 ENV \u73AF\u5883\u53D8\u91CF\u9ED8\u8BA4\u503C\uFF0C\u7981\u6B62\u65B0\u589E\u5065\u5EB7\u68C0\u67E5\u63A5\u53E3\u3002\u539F\u914D\u7F6E\u7531\u7528\u6237\u7EF4\u62A4\u3002\u6682\u5B58\u6587\u4EF6\u5728 opc_delivery_submit \u7684 changes \u4E2D\u6309 id \u548C path \u5F15\u7528\u3002",
4740
+ description: "\u6682\u5B58\u6839\u76EE\u5F55 Dockerfile \u7684\u5FC5\u8981\u6539\u52A8\u3002\u5E94\u7528\u6E90\u7801\u548C\u914D\u7F6E\u7531\u7528\u6237\u7EF4\u62A4\u3002\u6682\u5B58\u6587\u4EF6\u5728 opc_delivery_submit \u7684 changes \u4E2D\u6309 id \u548C path \u5F15\u7528\u3002",
4696
4741
  parameters: {
4697
4742
  id: { type: "string", required: true },
4698
4743
  path: { type: "string", required: true },
@@ -4706,7 +4751,7 @@ ${portInstructions}${repairInstructions}`;
4706
4751
  if (job.status !== "analyzing") throw new Error("\u672C\u8F6E\u5DF2\u63D0\u4EA4\u65B9\u6848");
4707
4752
  job.events.push(formatToolStep("propose_file", args.path));
4708
4753
  delivery.core.emit("change");
4709
- const res = await worker({ action: "propose_file", root, ...args }, abort);
4754
+ const res = await worker({ action: "propose_file", root, ...args, dockerfile_only: true }, abort);
4710
4755
  return JSON.stringify(res);
4711
4756
  }
4712
4757
  }));
@@ -4728,10 +4773,11 @@ ${portInstructions}${repairInstructions}`;
4728
4773
  if (candidate && typeof candidate.contract === "object" && candidate.contract !== null) {
4729
4774
  candidate.contract = { ...candidate.contract, slug: job.slug, base_url: job.url };
4730
4775
  }
4731
- await delivery.submit(job, root, candidate, abort);
4776
+ await delivery.submit(job, root, candidate, abort, { dockerfileOnly: true });
4732
4777
  } catch (error) {
4733
4778
  const message = error instanceof Error ? error.message : String(error);
4734
4779
  const detail = await worker({ action: "redact_feedback", root, text: message.slice(0, 2e3) }, abort);
4780
+ const duplicateError = validationErrors.includes(detail);
4735
4781
  validationErrors.push(detail);
4736
4782
  job.analysisFailure = detail;
4737
4783
  if (candidate) {
@@ -4749,14 +4795,14 @@ ${portInstructions}${repairInstructions}`;
4749
4795
  }
4750
4796
  rejectedProposals.add(rej);
4751
4797
  }
4752
- job.events.push(`\u63D0\u6848\u6821\u9A8C\u672A\u901A\u8FC7\uFF1A${detail}`);
4798
+ if (!duplicateError) job.events.push(`\u63D0\u6848\u6821\u9A8C\u672A\u901A\u8FC7\uFF1A${detail}`);
4753
4799
  delivery.core.emit("change");
4754
4800
  if (validationErrors.length === MAX_VALIDATION_ERRORS) cancel();
4755
4801
  throw new Error(detail);
4756
4802
  }
4757
4803
  const questions = analysisQuestions(job.proposal);
4758
4804
  return questions.length ? `\u65B9\u6848\u5DF2\u4FDD\u5B58\uFF0C\u7B49\u5F85\u7528\u6237\u56DE\u590D\u3002\u8BF7\u5728\u5F53\u524D\u5BF9\u8BDD\u4E2D\u5217\u51FA\u5F85\u786E\u8BA4\u7684\u95EE\u9898\u4E0E\u53EF\u9009\u65B9\u6848\uFF0C\u518D\u7ED3\u675F\u672C\u8F6E\uFF1A
4759
- ${questions.join("\n")}` : "\u5B8C\u6574\u65B9\u6848\u5DF2\u901A\u8FC7\u6821\u9A8C\u3002\u8BF7\u7B80\u8981\u8BF4\u660E\u7ED3\u679C\u5E76\u7ED3\u675F\u672C\u8F6E\uFF0COPC \u5C06\u81EA\u52A8\u751F\u6210\u4EA4\u4ED8\u5305\u3002";
4805
+ ${questions.join("\n")}` : "\u65B9\u6848\u901A\u8FC7\u3002\u53EA\u7528\u51E0\u53E5\u8BDD\u8BF4\u660E\u7AEF\u53E3\u3001\u5FC5\u8981\u6539\u9020\u548C\u6280\u80FD\u8303\u56F4\uFF0C\u7136\u540E\u7ED3\u675F\u672C\u8F6E\u3002OPC \u5C06\u81EA\u52A8\u751F\u6210\u4EA4\u4ED8\u5305\u3002";
4760
4806
  }
4761
4807
  }));
4762
4808
  }
@@ -4904,6 +4950,7 @@ ${questions.join("\n")}` : "\u5B8C\u6574\u65B9\u6848\u5DF2\u901A\u8FC7\u6821\u9A
4904
4950
  signal.throwIfAborted();
4905
4951
  if (abort.aborted && replyCount === repliesBeforeTurn) return;
4906
4952
  abort.throwIfAborted();
4953
+ if (job.status === "review" && !analysisQuestions(job.proposal).length) return;
4907
4954
  setDeadline(ANALYSIS_TIMEOUT_MS);
4908
4955
  } else {
4909
4956
  abort.throwIfAborted();
@@ -4944,7 +4991,7 @@ ${questions.join("\n")}` : "\u5B8C\u6574\u65B9\u6848\u5DF2\u901A\u8FC7\u6821\u9A
4944
4991
  }
4945
4992
  job.events.push(invalidOutput ? `\u{1F504} ${reason}\uFF0C\u6B63\u5728\u7F29\u77ED\u63D0\u4EA4\u5185\u5BB9\u540E\u91CD\u8BD5\uFF08${attempt + 1}/2\uFF09` : networkError ? `\u{1F504} AI \u670D\u52A1\u6682\u65F6\u4E2D\u65AD\uFF0C\u6B63\u5728\u7EE7\u7EED\u51C6\u5907\uFF08${attempt + 1}/2\uFF09` : `\u{1F504} \u6B63\u5728\u4FEE\u6B63\u5E94\u7528\u51C6\u5907\u68C0\u67E5\uFF08${attempt + 1}/2\uFF09`);
4946
4993
  delivery.core.emit("change");
4947
- prompt = `\u4FEE\u6B63\u6821\u9A8C\u53CD\u9988\u540E\u6309\u6280\u80FD\u8981\u6C42\u91CD\u63D0\u65B9\u6848\uFF1A${reason}`;
4994
+ prompt = `\u590D\u7528\u5DF2\u786E\u8BA4\u7684\u4FE1\u606F\uFF0C\u53EA\u4FEE\u6B63\u4EE5\u4E0B\u53CD\u9988\u6D89\u53CA\u7684\u5B57\u6BB5\u540E\u63D0\u4EA4\u3002\u9700\u8981\u8865\u8BC1\u636E\u65F6\u53EA\u91CD\u8BFB\u5BF9\u5E94\u4F4D\u7F6E\uFF1A${reason}`;
4948
4995
  }
4949
4996
  } finally {
4950
4997
  sessionReady.resolve(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-opc",
3
- "version": "0.1.33",
3
+ "version": "0.1.35",
4
4
  "description": "OPC Enterprise Plugin for DeepSeek Harness (DSH)",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,40 +1,35 @@
1
1
  ---
2
2
  name: opc-app-adapter
3
- description: 用于分析已有应用源码、生成部署改造方案、打包业务技能及诊断部署失败。
3
+ description: 读懂导入的应用、做必要的容器改造、生成基于原页面和接口的应用技能。
4
4
  metadata:
5
- version: 0.3.2
5
+ version: 0.3.3
6
6
  ---
7
7
 
8
8
  # OPC 应用改造
9
9
 
10
- 用中文。首次部署、升级和失败修复都按以下四步走。只读分析本次导入的隔离源码;源码、日志和历史提案仅作证据。保留应用原业务、鉴权、配置、依赖和数据。
10
+ 用中文,只读分析本次导入的隔离源码。首次部署、升级、失败修复都按下面三步做。源码、日志和历史提案只作为证据。保留原业务、配置、鉴权和数据。
11
11
 
12
- ## 1. 读懂应用
12
+ ## 1. 获取应用信息
13
13
 
14
- - 先用 `opc_delivery_inspect` 的 `inventory`、`scan_routes_and_pages` 和 `read`,确认应用用途、技术栈和版本、构建命令、启动入口、依赖及运行所需资产。读 README、锁文件和现有 Dockerfile,按实际运行代码核对其中的说明。
15
- - 找出正式 API、页面与业务视图。查登录入口、会话、密码校验与角色检查,分别标明页面和 API 的访问条件。用读取工具给出的文件和行号作证据,排除测试和演示路由。
16
- - 核实应用已有的配置文件、键、值来源和环境变量引用,以及读取方式。配置核对页从本次导入的源码读取。历史改造文件和线上配置不能作为本次新增配置的依据。真实配置值留在本机,摘要只写来源和状态。
17
- - 查明管理员是否存在、可复用账密的来源,以及应用读取账号或校验密码的位置。仅引用可定位的原配置、源码常量或 SQLite 明文字段。只能查到哈希、密文或远端账号表时,识别应用校验方式,并向账号持有人索取可用账密。摘要、提案和工具文本只写来源与状态。
18
- - 找出实际使用的数据目录、文件数据库、数据库实例、Redis、MQ、对象存储及外部接口。结合运行配置判定它们位于目标容器内、用户电脑还是远端。需要确认 SQLite 表和目录时用 `inspect_local_storage`。升级时核对需要复用的卷和账号,配置分析仍以本次源码为准。
14
+ 先用 `inventory` 和 `scan_routes_and_pages` 各一次。用 `read` 核实入口、依赖清单、README 要点、现有 Dockerfile、登录与权限中间件、配置和数据读取位置。按扫描返回的文件和行号定点阅读。共用中间件核实一次即可;插件会合并扫描出的页面和接口。得到以下信息后进入下一步:
19
15
 
20
- ## 2. 决定并实施改造
16
+ - 应用用途、语言与版本、构建和启动命令、原默认端口。
17
+ - 正式页面、API、登录入口、会话如何传递、权限如何限制。定位既有管理员账号来源,仅记录文件位置和可复用状态。账密由本机从可信引用读取,摘要与提案内不出现秘密。
18
+ - 原配置、文件数据目录、SQLite、数据库实例、Redis、MQ 和外部接口。区分应用容器内、用户电脑和远端服务。需要辨认 SQLite 时用 `inspect_local_storage`。
21
19
 
22
- - 现有 Dockerfile 可用就沿用;缺失时按语言和版本查 `template`,只新增根目录 `Dockerfile`。`runtime.port` 优先沿用应用自身默认端口;应用无默认端口或依赖外部注入 `PORT` 且无兜底时使用任务给出的 OPC 默认端口。容器内服务须监听 `0.0.0.0`。保留真实启动命令和依赖,只在现有代码中修正已证实的监听和启动问题。平台使用应用原有入口探测,禁止新增健康检查接口、健康包装脚本或相关变量。每项改动说明原文件证据和部署影响。
23
- - 沿用原配置文件和值。契约 `configs` 仅引用原应用可证实的键和来源,`default` 留空;`*.example` / `*.sample` / `*.template` 等示例文件仅作参考模板,不要绑定与 `runtime.port` 冲突的 `PORT` 或占位密钥,源码兜底的非敏感默认值可写入 `app_default`。禁止自行增加或替换环境变量、配置文件、模板、包装脚本、管理员初始化脚本、说明文件或依赖。确需补充时写入待确认事项,等用户在应用源工程处理后重新导入。
24
- - SQLite、JSON、上传等本地文件使用持久化卷,SQLite 挂载整个数据目录(含 WAL/SHM),使用工具的快照。升级复用原卷。库表变化优先只增不删,涉及删除、改名或影响回滚时列为待确认事项。
25
- - 远端数据库先沿用原连接,在部署后验证可达性。若源码连的是用户电脑上的数据库实例,暂停并请用户联系运维申请同引擎的企业数据库,由运维迁移后更新连接,再继续部署。真正与应用运行在同一容器内的依赖可以保留 loopback。
26
- - 用户电脑上的 Redis、MQ 等按用途判断是否要迁数据。纯缓存可重建,持久状态、队列积压或需要保留的业务数据须先核对迁移。用平台资源元数据确认可用服务;由用户决定目标并更新应用原配置。需要迁数据的,说明数据范围、目标与验收条件,等授权迁移完成再继续。只有宿主提供并实际执行了受支持的迁移工具,才能报告已迁移。
27
- - 已证实目标服务器无法调用的外部接口要暂停。写清配置位置、受影响的业务和验证方法,给用户一段可交给本地 AI 的修改说明,或说明需重新部署哪个依赖。对可达性未知的远端连接标记待验证。
28
- - 原值沿用 `read` 返回的 `{path,keys}` 引用。管理员账密用 `admin_account`。已有管理员用 `existing`;无可用密码时省略 `source`,由插件提示在左侧会话提供现有账密。确认首次部署且管理员存储为空才用 `create`,声明应用真正读取的 JSON/YAML 或 SQLite 位置和原有密码格式。插件在打包前把用户提供的账密写入交付副本。升级沿用已有账号。
20
+ ## 2. 做部署所需的改造
29
21
 
30
- ## 3. 生成应用技能
22
+ - Dockerfile 能用就沿用,缺失时按语言和版本查 `template`。只提交根目录 Dockerfile 的改动。端口沿用应用实际默认值,无默认值时使用任务给出的 OPC 默认端口。容器内监听 `0.0.0.0`,优先沿用应用已有的启动参数或配置。必须改源码才能运行时,指出文件、行号和原因,请用户在源工程处理。探测沿用应用入口。
23
+ - 保留现有业务功能所需依赖。构建超时时查日志和依赖安装步骤,避免通过删除依赖来换取构建通过。
24
+ - 原配置原样使用。契约只引用源码已有配置,`default` 留空,非敏感源码兜底值可写入 `app_default`。示例文件只供参考。保留应用原有文件结构,不创建配置、环境变量、健康接口或包装脚本。
25
+ - SQLite、JSON、上传等本地业务数据挂载实际使用的目录,SQLite 连同 WAL/SHM 一起保留;使用工具快照,升级复用卷。远端服务沿用原连接,部署时核实可达性。同容器依赖可以用回环地址。
26
+ - 确认依赖在用户电脑且部署后无法连接时,说明配置位置和受影响功能,请用户安排可达的对应服务。数据库需要迁移时先由运维完成迁移并更新应用原连接。Redis、MQ 有业务状态时保留数据,纯缓存可重建。只使用实际可用的平台资源,替换连接或迁移数据须由用户确认。
27
+ - 管理员来源用 `admin_account`。已有账号用 `existing`,有可用的源码或配置引用时复用。确实缺少可登录账密时省略 `source`,由插件在会话里收集。只有首次部署且已确认账号存储为空时才用 `create`,按原应用的数据位置和密码格式写入交付副本。升级沿用已有账号。
28
+ - 只有用户必须处理才能继续的事项才填 `unresolved`。可选企微等集成、建议改密码、上线后才能验证的连通性写进摘要。修复失败部署时先读失败制品和日志,只处理实际根因。上一轮构建尚未结束时,沿用原交付包,等平台释放构建后再部署。
31
29
 
32
- - 提交真实页面和 API 的用途、输入、结果、鉴权、角色与副作用。DSH 会合并扫描结果,`apis`、`pages` 只需提交扫描遗漏或需覆盖的条目。待核对的内部技术项由 AI 和校验器处理。
33
- - 受保护页面走应用原登录流程。受保护接口按实际认证传 Cookie、Bearer 或应用要求的请求头。自动换取会话时按实际登录地址、方法、请求字段和响应声明;浏览器登录、跳转或其他调用器不支持的流程要明确说明依赖。打包器把已确认的管理员账密写进生成技能的 `SKILL.md`,其他 Token 和密钥走运行时凭据引用。写入、删除和外部操作仍须用户确认。
34
- - 提交可真实验证的只读业务用例,覆盖用到的鉴权身份。涉及页面时记录实际操作与预期,纯页面应用由用户验收。用同一认证方式验证发布后的应用,分别记录部署、API 和页面结果。
30
+ ## 3. 生成技能并提交
35
31
 
36
- ## 4. 处理待确认项并进入部署核对
37
-
38
- - 汇总分析依据、必要改造及技能验收范围。连接地址、数据迁移、缺失的账号等需要用户决定时,写入 `unresolved`,提示具体影响并等待用户确认。收到答复后只修订相关项。已有部署沿用应用原账号。
39
- - 用 `opc_delivery_propose_file` 暂存允许的文件,再用 `opc_delivery_submit` 提交 `summary`、`changes`、`contract` 和 `unresolved`。按需查阅 `contract.md`。校验失败时按具体规则修复;源应用缺少必要配置或文件时请用户补齐。
40
- - 待确认项处理完且提案通过后,由插件生成交付包。用户可在第 3 步核对或按需调整运行时环境变量、差异、应用技能与持久化挂载,再主动确认发布。分析结果只说明实际准备和校验到的阶段。
32
+ - 复用第一步已有的接口、页面和鉴权信息。`apis`、`pages` 只补扫描遗漏或需修正的条目。共用鉴权写一条 `auth_rules`,在受保护规则中填写 `auth.profile`;公开登录入口用精确路径和方法声明。应用使用 Cookie、Bearer 或自定义头时按源码填写,页面按原登录流程走。
33
+ - 选择一个可以核实响应的只读业务用例。有受保护的只读接口时,用其中一个验证实际登录流程;纯页面应用填写实际操作和预期。保留原有角色限制,所有非只读接口填写 `confirmation_required: true`。
34
+ - 用 `opc_delivery_propose_file` 暂存必要文件,再用 `opc_delivery_submit` 提交摘要、改动、契约和真实阻塞项。字段拿不准只查 `contract.md` 对应段落。校验有反馈时只改点名的字段,缺证据只重读对应位置。
35
+ - 方案通过就简要说明实际端口、改了什么、技能覆盖哪些功能,结束分析。插件生成交付包和技能,用户在向导核对后决定发布。
@@ -52,6 +52,7 @@ Work 自动技术准备记录 `kind: ai-technical`、`scope: deployment-adaptati
52
52
  - 每个 API 必须含 purpose、源码 evidence、实际 parameters/request_body/responses、auth、effect。request_body 为 null 或包含 required、description、schema 的对象;完整 schema 与错误说明应保留,工具不声称完整实现 JSON Schema 验证。API 错误可能包含 HTTP 200 下的业务错误码,业务流程必须明确成功判断,不把 HTTP 成功等同业务成功。
53
53
  - auth.type 为 none、bearer 或 header;非 none 必须声明 env 环境变量名或引用 auth_profiles 中的 profile,header 还要提供 header。原始账号密码不要填入契约,由打包器写进生成应用技能的 `SKILL.md`。其他密钥和令牌沿用运行时引用。
54
54
  - 直接在 API 或页面上声明认证时,用 `auth.evidence` 引用登录、会话或权限代码。共用中间件的证据写在 `auth_rules[].evidence`。每条证据使用读取工具返回的相对路径与实际行号,修改过的文件以拟交付版本为准。
55
+ - 共用鉴权写一条前缀规则,例如 `{"target":"api","prefix":"/api/","auth":{"type":"header","header":"Cookie","profile":"account"},"evidence":["server.mjs:42"]}`。公开登录入口用精确的 `path`、`method` 和 `auth.type: none` 声明例外。
55
56
  - 账号密码换会话可用 `auth_profiles.account = {"login_url":"/api/session","login_method":"POST","username_env":"APP_USER","password_env":"APP_PASSWORD"}`。调用器向同源地址发送 JSON。非默认字段用 `login_body_template`,例如 `{"email":"${username}","secret":"${password}"}`。登录返回 `Set-Cookie` 时,受保护 API 声明 `{"type":"header","header":"Cookie","profile":"account"}`。返回 Token 时按实际响应声明 `token_json_path` 及接口要求的 Bearer 或请求头。凭据引用用于业务验证,无需加入容器配置。表单、重定向和 SSO 流程需要浏览器或专用调用方式。
56
57
  - `admin_account` 声明 `profile`、`mode` 和 `evidence`。`profile` 对应原应用的登录接口,`login_method` 填 `POST` 等 HTTP 动词。管理员接口及验证用例要使用这一个 profile。
57
58
  - `mode: existing` 复用已有管理员。确认有可用明文时,填写 `source: {"username":{"path":"admin.json","keys":["username"]},"password":{"path":"admin.json","keys":["password"]}}`。明确的源码字符串常量可用 `{path,line,name}`,SQLite 明文字段可用 `{path,table,column,where}` 引用。`where` 是用于唯一标识记录的字段与值。只能定位到哈希、密文或远端账号记录时,省略 `source`,OPC 会在 AI 改造会话提示按 `账号:…` 和 `密码:…` 两行回复已有可登录的账密。
@@ -59,7 +60,7 @@ Work 自动技术准备记录 `kind: ai-technical`、`scope: deployment-adaptati
59
60
  - 非只读 effect 必须 confirmation_required:true。不能仅按 HTTP 方法判断,POST 搜索也可以明确标为 read;GET 也可能需要确认。
60
61
  - pages 每项含 path、purpose、evidence、actions;无页面就填空数组,浏览器操作需要调用方提供浏览器工具。
61
62
  - 0.2.0 内置调用器只处理普通 HTTP/JSON 与标量 path/query/header 参数;参数名必须唯一。multipart 上传、二进制下载、流式/WebSocket、同名不同位置的参数及复杂数组参数编码需单独脚本并验证;先报告限制,请用户决定是否扩展,不能默默丢弃 API 或宣称已可调用。
62
- - verification.cases 是已核实无副作用的业务探针,包含 operation、params、可选 body、预期 status 和 json_contains。测试数据只能来自明确的测试环境,不擅自生成真实业务记录。
63
+ - verification.cases 是已核实无副作用的业务探针,包含 operation、params、可选 body、预期 status 和非空 json_contains。一个代表性用例即可。有受保护的只读业务接口时选其中一个验证实际鉴权,保留各接口原有角色限制。已有健康入口可用可选 health.path 标识。测试数据只能来自明确的测试环境,不擅自生成真实业务记录。
63
64
  - json_contains 对象按字段递归匹配;非空期望数组逐项匹配实际数组中的记录,顺序可不同;空期望只匹配空数组。空结果、不同条数或错误类型不能通过。多行顺序不稳定时先用获准条件过滤唯一测试记录,或提供专用验证。
64
65
  - verification.browser_cases 是页面操作验证计划,例如 `[{"page":"/orders","steps":["输入查询条件","执行只读搜索"],"expected":"显示符合条件的真实订单"}]`。page 必须在 pages 中;该计划不是执行证据。没有 API 探针时必须填写浏览器计划。
65
66
 
@@ -328,7 +328,7 @@ EMBEDDED_CREDENTIAL_FIELDS = {
328
328
  "username", "admin_username", "password", "admin_password",
329
329
  "default_username", "default_password", "default_token",
330
330
  "auth_token", "token", "api_key", "cookie", "default_credential",
331
- "login_body", "login_body_template",
331
+ "login_body",
332
332
  }
333
333
 
334
334
 
@@ -338,6 +338,13 @@ def validate_credential_references(contract):
338
338
  for profile in [contract.get("auth_profile", {})] + list(profiles.values()):
339
339
  require(isinstance(profile, dict), "credential profile must be an object")
340
340
  require(not any(profile.get(key) for key in EMBEDDED_CREDENTIAL_FIELDS), "Use runtime credential references, not embedded credentials")
341
+ if "login_body_template" in profile:
342
+ template = profile["login_body_template"]
343
+ require(isinstance(template, dict) and bool(template)
344
+ and all(isinstance(key, str) and key and isinstance(value, str)
345
+ and value in {"${username}", "${password}"} for key, value in template.items())
346
+ and set(template.values()) == {"${username}", "${password}"},
347
+ "login_body_template must map fields to username and password placeholders only")
341
348
  for key in ("username_env", "password_env", "token_env"):
342
349
  if key in profile:
343
350
  require(isinstance(profile[key], str) and ENV_NAME.fullmatch(profile[key]), "Credential reference must be an environment variable name")
@@ -131,7 +131,9 @@ def validate_account_plan(source, contract, reuse_source_admin=False):
131
131
  and profile["username_env"] != profile["password_env"]),
132
132
  "管理员账密必须绑定已有登录方式。请在 auth_profiles 的对应对象内直接声明 login_url、username_env、password_env。")
133
133
  routes = [*contract.get("apis", []), *contract.get("pages", [])]
134
- d.require(any(item.get("auth", {}).get("profile") == plan["profile"] for item in routes), "请将管理员登录方式绑定到实际受保护的接口或页面")
134
+ d.require(any(item.get("auth", {}).get("profile") == profile_id
135
+ and item["auth"].get("type") in {"header", "bearer"} for item in routes),
136
+ f"没有受保护的接口或页面引用登录方式 {profile_id}。请在真实鉴权路由的 auth 或匹配的 auth_rules[].auth 中填写 profile;公开登录入口不计。")
135
137
  if plan.get("mode") == "existing":
136
138
  d.require("storage" not in plan, "使用已有管理员时不修改账号存储")
137
139
  if "source" in plan:
@@ -60,7 +60,19 @@ def resolve_authentication(contract):
60
60
  if any(rank(r) == rank(best) and r.get('auth') != best.get('auth') for r in ranked[1:]):
61
61
  errors.append('存在互相冲突的认证规则:' + item['path'])
62
62
  continue
63
- item['auth'] = {**copy.deepcopy(best.get('auth', {})), 'evidence': best['evidence']}
63
+ auth = copy.deepcopy(best['auth'])
64
+ explicit = item.get('auth') or {}
65
+ # A shared guard describes the transport. Keep a route's explicit
66
+ # login reference when that guard uses the same transport and has
67
+ # not selected credentials of its own.
68
+ if (best.get('prefix') and auth['type'] in {'header', 'bearer'}
69
+ and explicit.get('type') == auth['type']
70
+ and str(explicit.get('header', '')).lower() == str(auth.get('header', '')).lower()):
71
+ if not (auth.get('profile') or auth.get('env')):
72
+ auth.update({key: explicit[key] for key in ('profile', 'env') if explicit.get(key)})
73
+ if 'roles' in explicit and 'roles' not in auth:
74
+ auth['roles'] = explicit['roles']
75
+ item['auth'] = {**auth, 'evidence': best['evidence']}
64
76
  auth = item.get('auth', {'type': 'unknown'})
65
77
  if auth.get('type') == 'unknown':
66
78
  evidence = item.get('evidence')
@@ -184,16 +196,15 @@ def validate_auth_questions(proposal):
184
196
 
185
197
 
186
198
  def validate_auth_probe_coverage(contract):
187
- """New auth plans must exercise every protected API identity with a read-only case."""
199
+ """Exercise a protected business read when the application has one."""
188
200
  if not contract.get('auth_rules') and not contract.get('auth_profiles'):
189
201
  return # Existing packaged skills keep their original verification contract.
190
- def identity(api):
191
- auth = api.get('auth', {})
192
- return (auth.get('profile', 'default'), auth.get('type'), auth.get('header', ''), auth.get('env', ''), tuple(auth.get('roles', [])))
193
- protected = [a for a in contract.get('apis', []) if a.get('auth', {}).get('type') in {'header', 'bearer'}]
194
- operations = {c.get('operation') for c in contract.get('verification', {}).get('cases', [])}
195
- covered = {identity(a) for a in protected if a.get('id') in operations and a.get('effect') == 'read'
196
- and a.get('path') != contract.get('health', {}).get('path')}
197
- missing = {identity(a) for a in protected} - covered
198
- if missing:
199
- raise ValueError('认证验证计划不完整:每种认证身份/权限范围需要只读业务用例;不能用公开健康接口代替。请自动补齐验证计划。')
202
+ health_path = (contract.get('health') or {}).get('path')
203
+ protected_reads = [api for api in contract.get('apis', [])
204
+ if api.get('auth', {}).get('type') in {'header', 'bearer'}
205
+ and api.get('effect') == 'read' and api.get('path') != health_path]
206
+ operations = {case.get('operation') for case in contract.get('verification', {}).get('cases', [])
207
+ if case.get('json_contains')}
208
+ if protected_reads and not any(api['id'] in operations for api in protected_reads):
209
+ examples = '、'.join(f"{api['id']}({api['method']} {api['path']})" for api in protected_reads[:3])
210
+ raise ValueError(f'请在 verification.cases 中选择一个受保护的只读业务接口,填写可核实的响应字段。可选:{examples}。')
package/runtime/worker.py CHANGED
@@ -75,7 +75,7 @@ def load_json_if_exists(path: Path, default):
75
75
  return default
76
76
 
77
77
 
78
- def validate_file_change(source: Path, change: dict):
78
+ def validate_file_change(source: Path, change: dict, dockerfile_only=False):
79
79
  d.require(isinstance(change, dict), "修改项必须是对象")
80
80
  d.require(isinstance(change.get("group", ""), str) and len(change.get("group", "")) <= 160, "修改分组必须是简短文字")
81
81
  path = change.get("path")
@@ -87,6 +87,8 @@ def validate_file_change(source: Path, change: dict):
87
87
  if not isinstance(change.get("path"), str) or not change["path"] or not isinstance(change.get("reason", "适配修改"), str) or not isinstance(change.get("content"), str):
88
88
  raise ValueError("修改项必须有路径、原因和完整文件内容")
89
89
  dockerfile = target.relative_to(source).as_posix() == "Dockerfile"
90
+ d.require(not dockerfile_only or dockerfile,
91
+ "AI 只能修改根目录 Dockerfile。确需修改应用代码时,请指出原文件位置和原因,由用户在源工程处理:" + path)
90
92
  exists = target.is_file()
91
93
  d.require(exists or dockerfile, "AI 只可新增根目录 Dockerfile;其余新增文件请由用户提供:" + path)
92
94
  if not dockerfile:
@@ -162,6 +164,7 @@ def resolve_and_enrich_proposal(
162
164
  feedback_text: str = "",
163
165
  expected_port: int | None = None,
164
166
  reuse_source_admin: bool = False,
167
+ dockerfile_only: bool = False,
165
168
  ) -> tuple[dict, dict | None, dict | None]:
166
169
  d.require(isinstance(proposal, dict) and isinstance(proposal.get("summary"), str) and proposal["summary"].strip(), "提案缺少摘要")
167
170
  for field in ("issues", "changes", "unresolved"):
@@ -195,7 +198,7 @@ def resolve_and_enrich_proposal(
195
198
  change = {**change, "id": change.get("path") or f"change-{idx + 1}"}
196
199
  if isinstance(change, dict) and not change.get("reason"):
197
200
  change = {**change, "reason": "容器化与部署适配"}
198
- validate_file_change(source, change)
201
+ validate_file_change(source, change, dockerfile_only)
199
202
  resolved_changes.append(change)
200
203
  except ValueError as exc:
201
204
  change_errors.append(str(exc))
@@ -341,7 +344,8 @@ def resolve_and_enrich_proposal(
341
344
 
342
345
 
343
346
  def apply_plan(root, proposal, target, *, repair=False, failed_revision="", failure_feedback="", expected_port=None,
344
- revision_count=1, feedback_text="", admin_reply=None, previous_skill_markdown="", reuse_source_admin=False):
347
+ revision_count=1, feedback_text="", admin_reply=None, previous_skill_markdown="", reuse_source_admin=False,
348
+ dockerfile_only=False):
345
349
  original = root / "review"
346
350
  d.require(d.inspect_source(original / "source")[0] == d.load(original / "inventory.json")["files"], "Source changed; import again")
347
351
  d.require(isinstance(proposal.get("summary"), str) and proposal["summary"].strip(), "summary required")
@@ -355,6 +359,7 @@ def apply_plan(root, proposal, target, *, repair=False, failed_revision="", fail
355
359
  revision_count=revision_count,
356
360
  feedback_text=feedback_text,
357
361
  reuse_source_admin=reuse_source_admin,
362
+ dockerfile_only=dockerfile_only,
358
363
  )
359
364
  d.require(not (proposal.get("unresolved") or proposal["contract"].get("unresolved")), "Resolve outstanding questions before preparation")
360
365
  shutil.copytree(original, target)
@@ -714,8 +719,8 @@ def main(body):
714
719
  d.save(root / "routes_scanned.json", {"scanned": True})
715
720
  res["_auto_contract_enrichment"] = (
716
721
  "提交方案时,系统会按同一规则复核 build_context 内的接口与页面并合并进契约。"
717
- "只提交需覆盖或补充的正式路由,不要把测试路径、演示入口和样例重新加进契约。"
718
- "认证方式必须根据正式入口及中间件确认,扫描待核对项不用向用户提问。"
722
+ "只提交需覆盖或补充的正式路由。按扫描给出的文件和行号核对正式入口与共用中间件即可。"
723
+ "共用鉴权写一条含 auth.profile 的规则,公开入口按路径及方法声明例外。"
719
724
  )
720
725
  return res
721
726
  if action == "inspect_local_storage":
@@ -744,7 +749,7 @@ def main(body):
744
749
  "executable": bool(body.get("executable", False)),
745
750
  "group": str(body.get("group") or ""),
746
751
  }
747
- validate_file_change(root / "review/source", change)
752
+ validate_file_change(root / "review/source", change, body.get("dockerfile_only") is True)
748
753
  draft_path = root / "draft_files.json"
749
754
  drafts = load_json_if_exists(draft_path, {})
750
755
  cid = change["id"]
@@ -772,6 +777,7 @@ def main(body):
772
777
  feedback_text=fb_text,
773
778
  expected_port=body.get("expected_port"),
774
779
  reuse_source_admin=body.get("reuse_source_admin") is True,
780
+ dockerfile_only=body.get("dockerfile_only") is True,
775
781
  )
776
782
  diffs = compute_change_diffs(source_dir, proposal.get("changes", []))
777
783
  _, has_orig = extract_original_config_values(source_dir, (proposal.get("contract") or {}).get("configs", []))
@@ -799,6 +805,7 @@ def main(body):
799
805
  admin_reply=body.get("admin_reply"),
800
806
  previous_skill_markdown=body.get("previous_skill_markdown", ""),
801
807
  reuse_source_admin=body.get("reuse_source_admin") is True,
808
+ dockerfile_only=body.get("dockerfile_only") is True,
802
809
  )
803
810
  d.bundle_work(temp_path / "approved", temp_path / "bundle", login)
804
811
  syntax_check = check_archive_syntax(temp_path / "bundle/app.tar")
@@ -832,6 +839,8 @@ def main(body):
832
839
  feedback_text=str(body.get("feedback") or ""),
833
840
  admin_reply=body.get("admin_reply"),
834
841
  previous_skill_markdown=body.get("previous_skill_markdown", ""),
842
+ reuse_source_admin=body.get("reuse_source_admin") is True,
843
+ dockerfile_only=body.get("dockerfile_only") is True,
835
844
  )
836
845
  result = d.bundle_work(dest / "approved", dest / "bundle", login)
837
846
  syntax_check = check_archive_syntax(dest / "bundle/app.tar")