dsh-plugin-opc 0.1.31 → 0.1.33

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
@@ -19945,6 +19945,7 @@ var contribution = { package: "dsh-plugin-opc", descriptors: [
19945
19945
  { id: "dsh-plugin-opc#opc/startLogin", service: "opc", namespace: "opc", method: "startLogin", invocation: { kind: "direct" }, parameters: [], result: { mode: "strict", typeSymbol: "opc/startLogin:result", create: () => external_exports.string() } },
19946
19946
  { id: "dsh-plugin-opc#opc/cancelLogin", service: "opc", namespace: "opc", method: "cancelLogin", invocation: { kind: "direct" }, parameters: [], result: { mode: "strict", typeSymbol: "opc/cancelLogin:result", create: () => external_exports.void() } },
19947
19947
  { id: "dsh-plugin-opc#opc/logout", service: "opc", namespace: "opc", method: "logout", invocation: { kind: "direct" }, parameters: [], result: { mode: "strict", typeSymbol: "opc/logout:result", create: () => external_exports.void() } },
19948
+ { id: "dsh-plugin-opc#opc/syncSession", service: "opc", namespace: "opc", method: "syncSession", invocation: { kind: "direct" }, parameters: [], result: { mode: "strict", typeSymbol: "opc/syncSession:result", create: () => external_exports.void() } },
19948
19949
  { id: "dsh-plugin-opc#opc/switchTenant", service: "opc", namespace: "opc", method: "switchTenant", invocation: { kind: "direct" }, parameters: [{ name: "tenantId", wire: "tenantId", source: "json", codec: { mode: "strict", typeSymbol: "opc/switchTenant:tenantId", create: () => external_exports.string() } }], result: { mode: "strict", typeSymbol: "opc/switchTenant:result", create: () => external_exports.void() } },
19949
19950
  { id: "dsh-plugin-opc#opc/listKnowledgeBases", service: "opc", namespace: "opc", method: "listKnowledgeBases", invocation: { kind: "direct" }, parameters: [{ name: "q", wire: "q", source: "json", codec: { mode: "strict", typeSymbol: "opc/listKnowledgeBases:q", create: () => external_exports.string() } }], result: { mode: "strict", typeSymbol: "opc/listKnowledgeBases:result", create: () => external_exports.string() } },
19950
19951
  { id: "dsh-plugin-opc#opc/listSkillsCatalog", service: "opc", namespace: "opc", method: "listSkillsCatalog", invocation: { kind: "direct" }, parameters: [{ name: "q", wire: "q", source: "json", codec: { mode: "strict", typeSymbol: "opc/listSkillsCatalog:q", create: () => external_exports.string() } }], result: { mode: "strict", typeSymbol: "opc/listSkillsCatalog:result", create: () => external_exports.string() } },
@@ -30285,7 +30286,7 @@ function mergeJobConfigs(job, draft, fallbackPort = 8080) {
30285
30286
  return {
30286
30287
  ...c,
30287
30288
  value: String(effectivePort),
30288
- original_value: origVal ?? (appDefault || String(effectivePort)),
30289
+ original_value: origVal ?? "",
30289
30290
  app_default: appDefault,
30290
30291
  secret: false,
30291
30292
  has_value: true,
@@ -30380,7 +30381,7 @@ function mergeJobConfigs(job, draft, fallbackPort = 8080) {
30380
30381
  };
30381
30382
  });
30382
30383
  for (const extra of rowMap.values()) {
30383
- if (!extra.key) continue;
30384
+ if (!extra.key || extra.key.trim() === "PORT") continue;
30384
30385
  merged.push({
30385
30386
  key: extra.key,
30386
30387
  value: extra.resource_id ? "" : extra.value ?? "",
@@ -30527,7 +30528,6 @@ function AppDeliveryConfig({
30527
30528
  onChange,
30528
30529
  compact = false,
30529
30530
  lockedPort,
30530
- onReturnToPortStep,
30531
30531
  readOnly = false
30532
30532
  }) {
30533
30533
  const [revealed, setRevealed] = (0, import_react5.useState)({});
@@ -30675,7 +30675,7 @@ function AppDeliveryConfig({
30675
30675
  value: portValue,
30676
30676
  className: "oa-input oa-mono oa-cfg-readonly"
30677
30677
  }
30678
- ), onReturnToPortStep && !readOnly && /* @__PURE__ */ import_react5.default.createElement("button", { type: "button", className: "oa-btn oa-btn-xs", onClick: onReturnToPortStep }, "\u8FD4\u56DE\u8C03\u6574\u7AEF\u53E3")) : selected ? /* @__PURE__ */ import_react5.default.createElement(
30678
+ )) : selected ? /* @__PURE__ */ import_react5.default.createElement(
30679
30679
  "input",
30680
30680
  {
30681
30681
  "aria-label": `${item.key} \u914D\u7F6E\u503C`,
@@ -58103,7 +58103,6 @@ function AppsPanel({
58103
58103
  originals: originalConfigs,
58104
58104
  resources,
58105
58105
  lockedPort: wizardJob.port ?? opcConfig.defaultPort,
58106
- onReturnToPortStep: () => void handleReturnToReview(),
58107
58106
  onChange: handleStep3ConfigsChange
58108
58107
  }
58109
58108
  ), /* @__PURE__ */ import_react8.default.createElement("details", { className: "oa-subcard oa-cfg-ref-details" }, /* @__PURE__ */ import_react8.default.createElement("summary", null, /* @__PURE__ */ import_react8.default.createElement("span", null, "\u67E5\u770B\u539F\u9879\u76EE\u914D\u7F6E\u6587\u4EF6\u53C2\u8003", sourceConfiguration?.files?.length ? `\uFF08${sourceConfiguration.files.length} \u4E2A\u6587\u4EF6\uFF09` : ""), /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-hint" }, "\u4EC5\u53EA\u8BFB\u53C2\u8003\uFF1B\u5B8C\u6574\u6E90\u6587\u4EF6\u9700\u5728\u672C\u5730\u7F16\u8F91\u540E\u91CD\u65B0\u5BFC\u5165")), !sourceConfiguration ? /* @__PURE__ */ import_react8.default.createElement("p", { className: "oa-hint", style: { margin: "8px 0 0" } }, "\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u539F\u5E94\u7528\u914D\u7F6E\u6587\u4EF6\u3002") : /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 6, marginTop: 4 } }, sourceConfiguration.files.map((file2) => /* @__PURE__ */ import_react8.default.createElement("details", { key: file2.path, className: "oa-cfg-ref-file" }, /* @__PURE__ */ import_react8.default.createElement("summary", null, /* @__PURE__ */ import_react8.default.createElement("code", null, file2.path), file2.is_example && /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-pill" }, "\u793A\u4F8B\u6A21\u677F"), /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-hint" }, file2.fields.length, " \u9879")), file2.fields.length > 0 && /* @__PURE__ */ import_react8.default.createElement("dl", { className: "oa-cfg-ref-dl" }, file2.fields.map(({ key, value }, index3) => /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, { key: `${key}-${index3}` }, /* @__PURE__ */ import_react8.default.createElement("dt", null, /* @__PURE__ */ import_react8.default.createElement("code", null, key)), /* @__PURE__ */ import_react8.default.createElement("dd", null, /* @__PURE__ */ import_react8.default.createElement("code", null, value === "[REDACTED]" ? "\u654F\u611F\u503C\u5DF2\u9690\u85CF" : value || "\uFF08\u7A7A\uFF09"))))))), sourceConfiguration.references.length > 0 && /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-cfg-ref-file" }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-hint", style: { fontWeight: 600, marginBottom: 4 } }, "\u6E90\u7801\u5F15\u7528\u7684\u73AF\u5883\u53D8\u91CF"), /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", flexWrap: "wrap", gap: 6 } }, sourceConfiguration.references.map((key) => /* @__PURE__ */ import_react8.default.createElement("code", { key, className: "oa-code" }, key)))), !sourceConfiguration.files.length && !sourceConfiguration.references.length && /* @__PURE__ */ import_react8.default.createElement("p", { className: "oa-hint", style: { margin: "6px 0 0" } }, "\u5728\u5BFC\u5165\u7684\u6E90\u7801\u4E2D\u672A\u8BC6\u522B\u5230\u914D\u7F6E\u6587\u4EF6\u6216\u73AF\u5883\u53D8\u91CF\u5F15\u7528\u3002")))), configSubTab === "mounts" && /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-form-card" }, volumeMounts.length === 0 ? /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-hint" }, "\u6B64\u5E94\u7528\u6CA1\u6709\u76EE\u5F55\u6302\u8F7D\u3002") : /* @__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, "\u6301\u4E45\u5316\u76EE\u5F55\u4E0E\u5B58\u50A8\u8D44\u6E90"), /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-pill oa-pill-ok" }, volumeMounts.length, " \u9879")), /* @__PURE__ */ import_react8.default.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 10 } }, volumeMounts.map((mount) => {
@@ -59987,7 +59986,10 @@ function Panel({ api, sessionId, requestedPage, navigationRevision, visible = tr
59987
59986
  {
59988
59987
  className: "btn-header",
59989
59988
  disabled: busy,
59990
- onClick: action(load),
59989
+ onClick: action(async () => {
59990
+ if (kind !== "apps") await api.syncSession();
59991
+ await load();
59992
+ }),
59991
59993
  title: "\u5237\u65B0"
59992
59994
  },
59993
59995
  "\u5237\u65B0"
@@ -60556,6 +60558,7 @@ function registerPanels(ctx) {
60556
60558
  startLogin: () => unwrap(wire.startLogin()),
60557
60559
  cancelLogin: () => unwrap(wire.cancelLogin()),
60558
60560
  logout: () => unwrap(wire.logout()),
60561
+ syncSession: () => unwrap(wire.syncSession()),
60559
60562
  switchTenant: (tenant) => unwrap(wire.switchTenant(tenant)),
60560
60563
  listKnowledgeBases: (q) => unwrap(wire.listKnowledgeBases(q)),
60561
60564
  listSkillsCatalog: (q) => unwrap(wire.listSkillsCatalog(q)),
package/lib/index.js CHANGED
@@ -259,6 +259,7 @@ var AuthManager = class extends EventEmitter {
259
259
  #refresh = "";
260
260
  #expiresAt = 0;
261
261
  #revision = 0;
262
+ #sessionRequest = 0;
262
263
  #writes = Promise.resolve();
263
264
  #login;
264
265
  #error;
@@ -276,24 +277,17 @@ var AuthManager = class extends EventEmitter {
276
277
  });
277
278
  return next;
278
279
  }
279
- async accept(body, revision, newLogin = false) {
280
- if (revision !== this.#revision) throw new OpcError("CONTEXT_CHANGED");
281
- const access = text(body.access_token), refresh = text(body.refresh_token);
282
- if (!access || !refresh || typeof body.expires_in !== "number" || body.expires_in <= 0) throw new OpcError("INVALID_TOKEN_RESPONSE");
283
- let view = body;
284
- if (!text(view.subject) || !Array.isArray(view.spaces)) view = { ...body, ...check(await this.http.request("/integration/v1/session", { token: access })) };
285
- if (revision !== this.#revision) throw new OpcError("CONTEXT_CHANGED");
280
+ sessionContext(view, old, newLogin = false) {
286
281
  const subject = text(view.subject);
287
282
  if (!subject || !Array.isArray(view.spaces) || !view.spaces.every((s) => typeof s === "string")) throw new OpcError("INVALID_SESSION_RESPONSE");
288
- const old = this.contexts.current;
289
283
  const spaces = view.spaces;
290
284
  const tenant = old?.subject === subject && spaces.includes(old.tenant) ? old.tenant : spaces.includes(text(view.tenant)) ? text(view.tenant) : spaces[0] ?? "";
291
- const context = {
285
+ return {
292
286
  issuer: this.http.base.origin,
293
287
  subject,
294
288
  tenant,
295
289
  spaces,
296
- generation: newLogin || !old ? this.contexts.epoch + 1 : old.generation,
290
+ generation: newLogin || !old ? this.contexts.epoch + 1 : old.generation + Number(old.tenant !== tenant),
297
291
  displayName: text(view.name) || old?.displayName || "",
298
292
  email: text(view.email) || old?.email || "",
299
293
  spacesDetail: spaces.map((id) => {
@@ -302,6 +296,36 @@ var AuthManager = class extends EventEmitter {
302
296
  return { id, name: detail && typeof detail.name === "string" ? detail.name : id };
303
297
  })
304
298
  };
299
+ }
300
+ async syncSession() {
301
+ const revision = this.#revision;
302
+ const request = ++this.#sessionRequest;
303
+ const token = await this.token();
304
+ const isCurrent = () => revision === this.#revision && request === this.#sessionRequest && token === this.#access;
305
+ if (!isCurrent()) throw new OpcError("CONTEXT_CHANGED");
306
+ const response = await this.http.request("/integration/v1/session", { token });
307
+ if (!isCurrent()) throw new OpcError("CONTEXT_CHANGED");
308
+ if (response.status === 401 || ["SESSION_REVOKED", "SUBJECT_NOT_PROVISIONED"].includes(text(response.body.error?.code))) {
309
+ await this.invalidateSession();
310
+ }
311
+ const view = check(response);
312
+ const current = this.contexts.current;
313
+ if (!current || view.subject !== current.subject) throw new OpcError("INVALID_SESSION_RESPONSE");
314
+ const updated = this.sessionContext(view, current);
315
+ if (JSON.stringify(current) !== JSON.stringify(updated)) {
316
+ this.contexts.replace(updated);
317
+ this.changed();
318
+ }
319
+ }
320
+ async accept(body, revision, newLogin = false) {
321
+ if (revision !== this.#revision) throw new OpcError("CONTEXT_CHANGED");
322
+ const access = text(body.access_token), refresh = text(body.refresh_token);
323
+ if (!access || !refresh || typeof body.expires_in !== "number" || body.expires_in <= 0) throw new OpcError("INVALID_TOKEN_RESPONSE");
324
+ let view = body;
325
+ if (!text(view.subject) || !Array.isArray(view.spaces)) view = { ...body, ...check(await this.http.request("/integration/v1/session", { token: access })) };
326
+ if (revision !== this.#revision) throw new OpcError("CONTEXT_CHANGED");
327
+ const old = this.contexts.current;
328
+ const context = this.sessionContext(view, old, newLogin);
305
329
  try {
306
330
  await this.persist(async () => {
307
331
  if (revision !== this.#revision) throw new OpcError("CONTEXT_CHANGED");
@@ -343,7 +367,7 @@ var AuthManager = class extends EventEmitter {
343
367
  try {
344
368
  return await this.accept(check(await this.http.request("/integration/v1/auth/refresh", { body: { refresh_token: this.#refresh, client_id: this.clientId, device: this.device } })), revision);
345
369
  } catch (error) {
346
- if (revision === this.#revision && error instanceof OpcError && ["REFRESH_REUSE_DETECTED", "SESSION_REVOKED"].includes(error.code)) await this.clear();
370
+ if (revision === this.#revision && error instanceof OpcError && ["REFRESH_REUSE_DETECTED", "SESSION_REVOKED", "SUBJECT_NOT_PROVISIONED"].includes(error.code)) await this.clear();
347
371
  throw error;
348
372
  }
349
373
  }
@@ -1501,8 +1525,8 @@ async function pickSourceFolder(platform2 = process.platform, exec = execFileAsy
1501
1525
  }
1502
1526
  return { cancelled: true, unsupported: true };
1503
1527
  }
1504
- 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;
1505
- 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) {
1528
+ 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, _syncSession_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;
1529
+ 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], _syncSession_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) {
1506
1530
  constructor(ctx, options) {
1507
1531
  super(ctx, "opc");
1508
1532
  __runInitializers(_init, 5, this);
@@ -1760,6 +1784,9 @@ var OpcRemoteService = class extends (_a = TypertRemoteService, _appList_dec = [
1760
1784
  async logout() {
1761
1785
  await this.core.auth.logout();
1762
1786
  }
1787
+ async syncSession() {
1788
+ await this.core.auth.syncSession();
1789
+ }
1763
1790
  async switchTenant(tenantId) {
1764
1791
  this.core.auth.switchTenant(tenantId);
1765
1792
  }
@@ -1882,6 +1909,7 @@ __decorateElement(_init, 1, "watchState", _watchState_dec, OpcRemoteService);
1882
1909
  __decorateElement(_init, 1, "startLogin", _startLogin_dec, OpcRemoteService);
1883
1910
  __decorateElement(_init, 1, "cancelLogin", _cancelLogin_dec, OpcRemoteService);
1884
1911
  __decorateElement(_init, 1, "logout", _logout_dec, OpcRemoteService);
1912
+ __decorateElement(_init, 1, "syncSession", _syncSession_dec, OpcRemoteService);
1885
1913
  __decorateElement(_init, 1, "switchTenant", _switchTenant_dec, OpcRemoteService);
1886
1914
  __decorateElement(_init, 1, "listKnowledgeBases", _listKnowledgeBases_dec, OpcRemoteService);
1887
1915
  __decorateElement(_init, 1, "listSkillsCatalog", _listSkillsCatalog_dec, OpcRemoteService);
@@ -3446,6 +3474,7 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
3446
3474
  root,
3447
3475
  proposal,
3448
3476
  allow_unresolved: hasQuestions || adminAccountPending,
3477
+ reuse_source_admin: !job.upgrade && !job.published && !adminReply && !canReusePrevious,
3449
3478
  admin_reply: adminReply,
3450
3479
  previous_skill_markdown: canReusePrevious ? job.skillMarkdown : void 0,
3451
3480
  repair: Boolean(job.failedRevision),
@@ -3462,7 +3491,7 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
3462
3491
  if (job.portAuto && Number.isInteger(validatedPort) && validatedPort >= 1 && validatedPort <= 65535) {
3463
3492
  job.port = validatedPort;
3464
3493
  }
3465
- if (adminAccountPending) job.proposal.adminAccountPending = true;
3494
+ if (adminAccountPending && !job.proposal.contract.admin_account?.source) job.proposal.adminAccountPending = true;
3466
3495
  else delete job.proposal.adminAccountPending;
3467
3496
  job.discoveryReport = validated?.discovery_report ?? job.discoveryReport;
3468
3497
  job.transformationReport = validated?.transformation_report ?? job.transformationReport;
@@ -4423,12 +4452,12 @@ function proposalParameters(port, portLocked = true) {
4423
4452
  login_method: str,
4424
4453
  token_json_path: str
4425
4454
  } },
4426
- auth_profiles: { ...object2, description: "\u6309 ID \u4FDD\u5B58\u767B\u5F55\u65B9\u5F0F\uFF0C\u63A5\u53E3\u901A\u8FC7 auth.profile \u5F15\u7528" },
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' },
4427
4456
  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: {
4428
4457
  mode: { ...text2, enum: ["existing", "create"] },
4429
4458
  profile: text2,
4430
4459
  evidence: strings,
4431
- source: { ...object2, description: "\u5DF2\u6709\u53EF\u590D\u7528\u660E\u6587\u7684 {username,password} \u5F15\u7528\uFF1A\u7ED3\u6784\u5316\u914D\u7F6E {path,keys}\u3001\u6E90\u7801\u5E38\u91CF/\u5BF9\u8C61\u5C5E\u6027/\u9ED8\u8BA4\u503C/\u54C8\u5E0C\u51FD\u6570\u5B57\u7B26\u4E32\u5B57\u9762\u91CF\u53C2\u6570 {path,line,name} \u6216 SQLite \u660E\u6587\u5B57\u6BB5 {path,table,column,where}\u3002\u7F3A\u4EFB\u4F55\u4E00\u9879\u5219\u7701\u7565 source\u3002" },
4460
+ 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" },
4432
4461
  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" }
4433
4462
  } },
4434
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: {
@@ -5068,6 +5097,7 @@ var contribution = { package: "dsh-plugin-opc", descriptors: [
5068
5097
  { id: "dsh-plugin-opc#opc/startLogin", service: "opc", namespace: "opc", method: "startLogin", invocation: { kind: "direct" }, parameters: [], result: { mode: "strict", typeSymbol: "opc/startLogin:result", create: () => z.string() } },
5069
5098
  { id: "dsh-plugin-opc#opc/cancelLogin", service: "opc", namespace: "opc", method: "cancelLogin", invocation: { kind: "direct" }, parameters: [], result: { mode: "strict", typeSymbol: "opc/cancelLogin:result", create: () => z.void() } },
5070
5099
  { id: "dsh-plugin-opc#opc/logout", service: "opc", namespace: "opc", method: "logout", invocation: { kind: "direct" }, parameters: [], result: { mode: "strict", typeSymbol: "opc/logout:result", create: () => z.void() } },
5100
+ { id: "dsh-plugin-opc#opc/syncSession", service: "opc", namespace: "opc", method: "syncSession", invocation: { kind: "direct" }, parameters: [], result: { mode: "strict", typeSymbol: "opc/syncSession:result", create: () => z.void() } },
5071
5101
  { id: "dsh-plugin-opc#opc/switchTenant", service: "opc", namespace: "opc", method: "switchTenant", invocation: { kind: "direct" }, parameters: [{ name: "tenantId", wire: "tenantId", source: "json", codec: { mode: "strict", typeSymbol: "opc/switchTenant:tenantId", create: () => z.string() } }], result: { mode: "strict", typeSymbol: "opc/switchTenant:result", create: () => z.void() } },
5072
5102
  { id: "dsh-plugin-opc#opc/listKnowledgeBases", service: "opc", namespace: "opc", method: "listKnowledgeBases", invocation: { kind: "direct" }, parameters: [{ name: "q", wire: "q", source: "json", codec: { mode: "strict", typeSymbol: "opc/listKnowledgeBases:q", create: () => z.string() } }], result: { mode: "strict", typeSymbol: "opc/listKnowledgeBases:result", create: () => z.string() } },
5073
5103
  { id: "dsh-plugin-opc#opc/listSkillsCatalog", service: "opc", namespace: "opc", method: "listSkillsCatalog", invocation: { kind: "direct" }, parameters: [{ name: "q", wire: "q", source: "json", codec: { mode: "strict", typeSymbol: "opc/listSkillsCatalog:q", create: () => z.string() } }], result: { mode: "strict", typeSymbol: "opc/listSkillsCatalog:result", create: () => z.string() } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-opc",
3
- "version": "0.1.31",
3
+ "version": "0.1.33",
4
4
  "description": "OPC Enterprise Plugin for DeepSeek Harness (DSH)",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -76,14 +76,60 @@ def original_account_field(source, reference):
76
76
  return value
77
77
 
78
78
 
79
- def validate_account_plan(source, contract):
79
+ def initial_admin_source(source, evidence):
80
+ """Find one administrator seed object in the cited original code."""
81
+ locations = {}
82
+ for citation in evidence if isinstance(evidence, list) else []:
83
+ if not isinstance(citation, str):
84
+ continue
85
+ match = re.fullmatch(r"(.+):(\d+)(?:-(\d+))?", citation)
86
+ if match:
87
+ locations.setdefault(match[1], []).append((int(match[2]), int(match[3] or match[2])))
88
+ candidates = []
89
+ for name, spans in locations.items():
90
+ path = d.relative(source, name)
91
+ if path.suffix not in {".js", ".mjs", ".cjs", ".ts"} or not path.is_file():
92
+ continue
93
+ text = d.text_of(path) or ""
94
+ offset, line_number = 0, 1
95
+ for obj in re.finditer(r"\{[^{}]*\}", text):
96
+ lines = obj[0].splitlines()[1:-1]
97
+ line_number += text.count("\n", offset, obj.start())
98
+ offset = obj.start()
99
+ first = line_number + 1
100
+ if not any(start <= first + len(lines) - 1 and end >= first for start, end in spans):
101
+ continue
102
+ if not any(_extract_literal_rhs(line, "role") in ('"admin"', "'admin'") for line in lines):
103
+ continue
104
+ refs = {}
105
+ for kind, fields in (("username", ("username",)), ("password", ("password", "passwordHash"))):
106
+ matches = [
107
+ {"path": name, "line": number, "name": field}
108
+ for number, line in enumerate(lines, first)
109
+ for field in fields if _extract_literal_rhs(line, field)
110
+ ]
111
+ if len(matches) == 1:
112
+ refs[kind] = matches[0]
113
+ if len(refs) == 2 and all(original_account_field(source, ref) for ref in refs.values()):
114
+ candidates.append(refs)
115
+ return candidates[0] if len(candidates) == 1 else None
116
+
117
+
118
+ def validate_account_plan(source, contract, reuse_source_admin=False):
80
119
  plan = contract.get("admin_account")
81
120
  if plan is None:
82
121
  return
83
122
  d.require(isinstance(plan, dict) and set(plan) <= {"mode", "profile", "evidence", "source", "storage"}, "管理员方案只能声明位置与格式")
84
- profile = contract.get("auth_profiles", {}).get(plan.get("profile", ""))
85
- d.require(bool(profile and profile.get("login_url") and profile.get("username_env") and profile.get("password_env")
86
- and profile["username_env"] != profile["password_env"]), "管理员账密必须绑定已有登录方式")
123
+ profiles = contract.get("auth_profiles", {})
124
+ profile_id = plan.get("profile", "")
125
+ profile = profiles.get(profile_id) if isinstance(profiles, dict) and isinstance(profile_id, str) else None
126
+ login_fields = ("login_url", "username_env", "password_env")
127
+ if isinstance(profile, dict) and isinstance(profile.get(profile_id), dict) and not any(key in profile for key in login_fields):
128
+ nested = profile.pop(profile_id)
129
+ profiles[profile_id] = profile = {**profile, **nested}
130
+ d.require(bool(isinstance(profile, dict) and all(profile.get(key) for key in login_fields)
131
+ and profile["username_env"] != profile["password_env"]),
132
+ "管理员账密必须绑定已有登录方式。请在 auth_profiles 的对应对象内直接声明 login_url、username_env、password_env。")
87
133
  routes = [*contract.get("apis", []), *contract.get("pages", [])]
88
134
  d.require(any(item.get("auth", {}).get("profile") == plan["profile"] for item in routes), "请将管理员登录方式绑定到实际受保护的接口或页面")
89
135
  if plan.get("mode") == "existing":
@@ -91,7 +137,17 @@ def validate_account_plan(source, contract):
91
137
  if "source" in plan:
92
138
  references = plan["source"]
93
139
  d.require(isinstance(references, dict) and set(references) == {"username", "password"}, "请提供账号和密码的原始位置")
94
- d.require(all(original_account_field(source, ref) for ref in references.values()), "原配置没有完整的账密,请从改造会话询问")
140
+ try:
141
+ d.require(all(original_account_field(source, ref) for ref in references.values()), "原配置没有完整的账密")
142
+ return
143
+ except ValueError:
144
+ code_refs = all(isinstance(ref, dict) and "line" in ref for ref in references.values())
145
+ if reuse_source_admin and code_refs and (found := initial_admin_source(source, plan.get("evidence"))):
146
+ plan["source"] = found
147
+ return
148
+ raise
149
+ if reuse_source_admin and (found := initial_admin_source(source, plan.get("evidence"))):
150
+ plan["source"] = found
95
151
  return
96
152
  d.require(plan.get("mode") == "create" and "source" not in plan, "管理员方案必须选择 existing 或 create")
97
153
  target = plan.get("storage")
package/runtime/worker.py CHANGED
@@ -161,6 +161,7 @@ def resolve_and_enrich_proposal(
161
161
  revision_count: int = 1,
162
162
  feedback_text: str = "",
163
163
  expected_port: int | None = None,
164
+ reuse_source_admin: bool = False,
164
165
  ) -> tuple[dict, dict | None, dict | None]:
165
166
  d.require(isinstance(proposal, dict) and isinstance(proposal.get("summary"), str) and proposal["summary"].strip(), "提案缺少摘要")
166
167
  for field in ("issues", "changes", "unresolved"):
@@ -315,8 +316,8 @@ def resolve_and_enrich_proposal(
315
316
  lambda: validate_auth_questions(proposal),
316
317
  lambda: resolve_authentication(contract),
317
318
  lambda: validate_auth_evidence(source, proposal),
319
+ lambda: validate_account_plan(source, contract, reuse_source_admin),
318
320
  lambda: d.validate_credential_references(contract),
319
- lambda: validate_account_plan(source, contract),
320
321
  ]
321
322
  if not proposal.get("unresolved") and not contract.get("unresolved"):
322
323
  checks.append(lambda: validate_auth_probe_coverage(contract))
@@ -340,7 +341,7 @@ def resolve_and_enrich_proposal(
340
341
 
341
342
 
342
343
  def apply_plan(root, proposal, target, *, repair=False, failed_revision="", failure_feedback="", expected_port=None,
343
- revision_count=1, feedback_text="", admin_reply=None, previous_skill_markdown=""):
344
+ revision_count=1, feedback_text="", admin_reply=None, previous_skill_markdown="", reuse_source_admin=False):
344
345
  original = root / "review"
345
346
  d.require(d.inspect_source(original / "source")[0] == d.load(original / "inventory.json")["files"], "Source changed; import again")
346
347
  d.require(isinstance(proposal.get("summary"), str) and proposal["summary"].strip(), "summary required")
@@ -353,6 +354,7 @@ def apply_plan(root, proposal, target, *, repair=False, failed_revision="", fail
353
354
  expected_port=expected_port,
354
355
  revision_count=revision_count,
355
356
  feedback_text=feedback_text,
357
+ reuse_source_admin=reuse_source_admin,
356
358
  )
357
359
  d.require(not (proposal.get("unresolved") or proposal["contract"].get("unresolved")), "Resolve outstanding questions before preparation")
358
360
  shutil.copytree(original, target)
@@ -769,6 +771,7 @@ def main(body):
769
771
  revision_count=rev_count,
770
772
  feedback_text=fb_text,
771
773
  expected_port=body.get("expected_port"),
774
+ reuse_source_admin=body.get("reuse_source_admin") is True,
772
775
  )
773
776
  diffs = compute_change_diffs(source_dir, proposal.get("changes", []))
774
777
  _, has_orig = extract_original_config_values(source_dir, (proposal.get("contract") or {}).get("configs", []))
@@ -795,6 +798,7 @@ def main(body):
795
798
  feedback_text=fb_text,
796
799
  admin_reply=body.get("admin_reply"),
797
800
  previous_skill_markdown=body.get("previous_skill_markdown", ""),
801
+ reuse_source_admin=body.get("reuse_source_admin") is True,
798
802
  )
799
803
  d.bundle_work(temp_path / "approved", temp_path / "bundle", login)
800
804
  syntax_check = check_archive_syntax(temp_path / "bundle/app.tar")