dsh-plugin-opc 0.1.31 → 0.1.32

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() } },
@@ -59987,7 +59988,10 @@ function Panel({ api, sessionId, requestedPage, navigationRevision, visible = tr
59987
59988
  {
59988
59989
  className: "btn-header",
59989
59990
  disabled: busy,
59990
- onClick: action(load),
59991
+ onClick: action(async () => {
59992
+ if (kind !== "apps") await api.syncSession();
59993
+ await load();
59994
+ }),
59991
59995
  title: "\u5237\u65B0"
59992
59996
  },
59993
59997
  "\u5237\u65B0"
@@ -60556,6 +60560,7 @@ function registerPanels(ctx) {
60556
60560
  startLogin: () => unwrap(wire.startLogin()),
60557
60561
  cancelLogin: () => unwrap(wire.cancelLogin()),
60558
60562
  logout: () => unwrap(wire.logout()),
60563
+ syncSession: () => unwrap(wire.syncSession()),
60559
60564
  switchTenant: (tenant) => unwrap(wire.switchTenant(tenant)),
60560
60565
  listKnowledgeBases: (q) => unwrap(wire.listKnowledgeBases(q)),
60561
60566
  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);
@@ -5068,6 +5096,7 @@ var contribution = { package: "dsh-plugin-opc", descriptors: [
5068
5096
  { 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
5097
  { 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
5098
  { 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() } },
5099
+ { 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
5100
  { 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
5101
  { 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
5102
  { 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.32",
4
4
  "description": "OPC Enterprise Plugin for DeepSeek Harness (DSH)",
5
5
  "type": "module",
6
6
  "publishConfig": {