@openclaw/clickclack 2026.11.5 → 2026.11.10-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { h as resolveClickClackAccount, p as listClickClackAccountIds } from "./setup-surface-CSITttSD.mjs";
2
- import { A as clearDiscussionBindingGeneration, C as resolveDiscussionLabel, D as bindingMatchesActiveSessionIncarnation, E as attachBindingToCurrentActiveSession, F as reserveDiscussionBindingGeneration, M as getPendingDiscussionOpen, N as listPendingDiscussionOpens, O as getClickClackDiscussionBindingStore, P as recordPendingDiscussionOpen, S as isDiscussionSessionKey, T as truncateDiscussionDisplayTitle, _ as resolveDiscussionBindingAccount, b as discussionSessionKey, c as clearClickClackDiscussionChannelRevoked, d as markClickClackDiscussionChannelIdentityRevoked, f as markClickClackDiscussionChannelRevoked, g as normalizedServerBaseUrl, h as discussionInfoForBinding, j as clearPendingDiscussionOpen, k as readDiscussionSessionEntry, l as isClickClackDiscussionChannelRevoked, m as discussionAccounts, o as prepareDiscussionSessionEntry, p as prepareClickClackDiscussionChannelRevocation, s as adoptLegacyMarkers, u as isClickClackDiscussionChannelRevokedAsync, v as discussionCredentialFingerprint, w as slugifyDiscussionLabel, x as fallbackDiscussionLabel, y as discussionExternalRef } from "./channel-D3WIuNxS.mjs";
3
- import { a as createClickClackClient, i as ClickClackHttpError, o as isClickClackChannelNameConflict, t as findClickClackWorkspace } from "./resolve-BgFJI_p4.mjs";
1
+ import { g as resolveClickClackAccountAsync, p as listClickClackAccountIds, v as resolveClickClackAccountMetadata } from "./setup-surface-DSbHN_QA.mjs";
2
+ import { A as bindingMatchesActiveSessionIncarnation, C as discussionSessionKey, D as slugifyDiscussionLabel, E as resolveDiscussionLabel, F as getPendingDiscussionOpen, I as listPendingDiscussionOpens, L as recordPendingDiscussionOpen, M as readDiscussionSessionEntry, N as clearDiscussionBindingGeneration, O as truncateDiscussionDisplayTitle, P as clearPendingDiscussionOpen, R as reserveDiscussionBindingGeneration, S as discussionExternalRef, T as isDiscussionSessionKey, _ as normalizedServerBaseUrl, b as resolvePreparedDiscussionBindingAccount, c as clearClickClackDiscussionChannelRevoked, d as markClickClackDiscussionChannelIdentityRevoked, f as markClickClackDiscussionChannelRevoked, g as isDiscussionAccountCurrent, h as discussionInfoForBinding, j as getClickClackDiscussionBindingStore, k as attachBindingToCurrentActiveSession, l as isClickClackDiscussionChannelRevoked, m as discussionAccounts, o as prepareDiscussionSessionEntry, p as prepareClickClackDiscussionChannelRevocation, s as adoptLegacyMarkers, u as isClickClackDiscussionChannelRevokedAsync, v as prepareDiscussionBindingAccount, w as fallbackDiscussionLabel, x as discussionCredentialFingerprint, y as resolveDiscussionBindingAccount } from "./channel-BH4RFKFX.mjs";
3
+ import { a as createClickClackClient, i as ClickClackHttpError, o as isClickClackChannelNameConflict, t as findClickClackWorkspace } from "./resolve-qeIY2bou.mjs";
4
4
  import "../api.js";
5
5
  import { isDeepStrictEqual } from "node:util";
6
6
  import { randomUUID } from "node:crypto";
@@ -10,7 +10,7 @@ import { buildControlUiSessionPath, registerSessionDiscussionProvider } from "op
10
10
  import { createSessionVisibilityChecker } from "openclaw/plugin-sdk/session-visibility";
11
11
  import { textResult } from "openclaw/plugin-sdk/tool-results";
12
12
  import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
13
- //#region extensions/clickclack/src/discussions/binding-retention.ts
13
+ // extensions/clickclack/src/discussions/binding-retention.ts
14
14
  const MAX_RETAINED_DETACHED_DISCUSSION_BINDINGS = 1e3;
15
15
  var DetachedDiscussionBindingRetention = class {
16
16
  #runtime;
@@ -59,8 +59,7 @@ var DetachedDiscussionBindingRetention = class {
59
59
  }
60
60
  }
61
61
  };
62
- //#endregion
63
- //#region extensions/clickclack/src/discussions/control-session-url.ts
62
+ // extensions/clickclack/src/discussions/control-session-url.ts
64
63
  function controlSessionUrl(baseUrl, sessionKey, fallbackAgentId, mainKey, displayName) {
65
64
  if (!baseUrl) return;
66
65
  const url = new URL(baseUrl);
@@ -77,8 +76,7 @@ function controlSessionUrl(baseUrl, sessionKey, fallbackAgentId, mainKey, displa
77
76
  url.hash = "";
78
77
  return url.toString();
79
78
  }
80
- //#endregion
81
- //#region extensions/clickclack/src/discussions/installation.ts
79
+ // extensions/clickclack/src/discussions/installation.ts
82
80
  const INSTALLATION_NAMESPACE = "discussion-installation";
83
81
  const INSTALLATION_KEY = "current";
84
82
  /** Returns the durable installation namespace used in server-visible ownership refs. */
@@ -96,8 +94,7 @@ async function getClickClackDiscussionInstallationId(runtime) {
96
94
  if (!persisted) throw new Error("ClickClack discussion installation identity is unavailable; retry opening the discussion");
97
95
  return persisted;
98
96
  }
99
- //#endregion
100
- //#region extensions/clickclack/src/discussions/service-history.ts
97
+ // extensions/clickclack/src/discussions/service-history.ts
101
98
  function discussionRecordJson(value) {
102
99
  return JSON.stringify(value).replace(/[\u0085\u2028\u2029]/gu, (separator) => `\\u${separator.charCodeAt(0).toString(16).padStart(4, "0")}`);
103
100
  }
@@ -128,7 +125,7 @@ async function readDiscussionHistory(params) {
128
125
  sessionEntry.source();
129
126
  const current = bindingFacts.read();
130
127
  const config = runtime.config.current();
131
- return current !== void 0 && current.externalRef === binding.externalRef && current.serverBaseUrl === binding.serverBaseUrl && current.channelId === binding.channelId && sessionEntry.entry?.sessionId === binding.sessionId && sessionEntry.entry.archivedAt === void 0 && resolveDiscussionBindingAccount(config, binding).state === "active" && !channelRevocation.isRevoked(current);
128
+ return current !== void 0 && current.externalRef === binding.externalRef && current.serverBaseUrl === binding.serverBaseUrl && current.channelId === binding.channelId && sessionEntry.entry?.sessionId === binding.sessionId && sessionEntry.entry.archivedAt === void 0 && resolvePreparedDiscussionBindingAccount(config, binding, params.account).state === "active" && !channelRevocation.isRevoked(current);
132
129
  } catch {
133
130
  return false;
134
131
  }
@@ -146,8 +143,7 @@ async function readDiscussionHistory(params) {
146
143
  bindingFacts.release();
147
144
  }
148
145
  }
149
- //#endregion
150
- //#region extensions/clickclack/src/discussions/service-open.ts
146
+ // extensions/clickclack/src/discussions/service-open.ts
151
147
  const CHANNEL_NAME_MUTATION_ATTEMPTS = 4;
152
148
  function isDefinitiveNoCreateHttpError(error) {
153
149
  if (!(error instanceof ClickClackHttpError) || error.status < 400 || error.status >= 500) return false;
@@ -268,13 +264,11 @@ async function openClickClackDiscussionBinding(params) {
268
264
  const section = entry.category?.trim() || account.discussions.section;
269
265
  const externalUrl = controlSessionUrl(account.discussions.controlUrlBase, sessionKey, account.agentId ?? agentId, config.session?.mainKey, label);
270
266
  const assertCurrentAuthority = () => {
271
- const currentAccounts = discussionAccounts(runtime.config.current());
272
- const currentAccount = currentAccounts.length === 1 ? currentAccounts[0] : void 0;
273
267
  const currentEntry = runtime.agent.session.getSessionEntry({
274
268
  sessionKey,
275
269
  readConsistency: "latest"
276
270
  });
277
- if (!currentAccount || currentAccount.accountId !== account.accountId || normalizedServerBaseUrl(currentAccount) !== serverBaseUrl || currentAccount.apiEndpoint !== account.apiEndpoint || discussionCredentialFingerprint(currentAccount.token) !== credentialFingerprint || currentAccount.discussions.workspace !== account.discussions.workspace || !currentEntry?.sessionId || currentEntry.archivedAt !== void 0) throw new Error("ClickClack discussion authority changed while opening the channel");
271
+ if (!isDiscussionAccountCurrent(runtime.config.current(), account) || !currentEntry?.sessionId || currentEntry.archivedAt !== void 0) throw new Error("ClickClack discussion authority changed while opening the channel");
278
272
  return currentEntry;
279
273
  };
280
274
  return await params.withChannelMutationLock(async () => {
@@ -436,15 +430,18 @@ async function reconcilePendingDiscussionOpen(params) {
436
430
  return false;
437
431
  }
438
432
  const cfg = params.runtime.config.current();
439
- const account = listClickClackAccountIds(cfg).map((accountId) => resolveClickClackAccount({
433
+ const candidates = listClickClackAccountIds(cfg).map((accountId) => resolveClickClackAccountMetadata({
440
434
  cfg,
441
435
  accountId
442
- })).find((candidate) => candidate.configured && normalizedServerBaseUrl(candidate) === pending.serverBaseUrl && discussionCredentialFingerprint(candidate.token) === pending.credentialFingerprint);
436
+ })).filter((account) => normalizedServerBaseUrl(account) === pending.serverBaseUrl);
437
+ const account = (await Promise.all(candidates.map(({ accountId }) => resolveClickClackAccountAsync({
438
+ cfg,
439
+ accountId
440
+ })))).find((candidate) => candidate.configured && normalizedServerBaseUrl(candidate) === pending.serverBaseUrl && discussionCredentialFingerprint(candidate.token) === pending.credentialFingerprint);
443
441
  if (!account) return false;
444
442
  const client = params.clientFactory(account);
445
443
  const entry = await readDiscussionSessionEntry(params.runtime, pending.sessionKey);
446
- const activeAccounts = discussionAccounts(cfg);
447
- const retryAccount = activeAccounts.length === 1 ? activeAccounts[0] : void 0;
444
+ const retryAccount = isDiscussionAccountCurrent(params.runtime.config.current(), account) ? account : void 0;
448
445
  if (params.allowRetry !== false && entry?.sessionId && entry.archivedAt === void 0 && retryAccount && normalizedServerBaseUrl(retryAccount) === pending.serverBaseUrl && discussionCredentialFingerprint(retryAccount.token) === pending.credentialFingerprint) {
449
446
  const workspaces = await params.clientFactory(retryAccount).workspaces();
450
447
  if (findClickClackWorkspace(workspaces, retryAccount.discussions.workspace)?.id === pending.workspaceId) return true;
@@ -473,8 +470,7 @@ async function reconcilePendingDiscussionOpen(params) {
473
470
  });
474
471
  return false;
475
472
  }
476
- //#endregion
477
- //#region extensions/clickclack/src/discussions/service.ts
473
+ // extensions/clickclack/src/discussions/service.ts
478
474
  const RECONCILE_INTERVAL_MS = 6e4;
479
475
  const RECONCILE_DEBOUNCE_MS = 250;
480
476
  const RECONCILE_RETRY_MS = 1e3;
@@ -581,8 +577,9 @@ var ClickClackDiscussionService = class {
581
577
  hasEnabledAccount() {
582
578
  return discussionAccounts(this.#currentConfig()).length === 1;
583
579
  }
584
- resolveBindingAccount(binding) {
585
- return resolveDiscussionBindingAccount(this.#currentConfig(), binding);
580
+ async prepareBindingAccount(binding) {
581
+ const resolved = await prepareDiscussionBindingAccount(this.#currentConfig(), binding);
582
+ return resolved.state === "active" ? resolvePreparedDiscussionBindingAccount(this.#currentConfig(), binding, resolved.account) : resolved;
586
583
  }
587
584
  async info(sessionKey) {
588
585
  return await this.#withOperation(() => this.#sessionQueue.enqueue(sessionKey, async () => {
@@ -618,11 +615,16 @@ var ClickClackDiscussionService = class {
618
615
  this.#installationId ??= await getClickClackDiscussionInstallationId(this.#runtime);
619
616
  const accounts = discussionAccounts(this.#currentConfig());
620
617
  if (accounts.length > 1) throw new Error("ClickClack discussions require exactly one enabled discussion account");
621
- const account = accounts[0];
622
- if (!account) return { state: "none" };
618
+ const selected = accounts[0];
619
+ if (!selected) return { state: "none" };
620
+ const account = await resolveClickClackAccountAsync({
621
+ cfg: this.#currentConfig(),
622
+ accountId: selected.accountId
623
+ });
624
+ if (!isDiscussionAccountCurrent(this.#currentConfig(), account)) return { state: "none" };
623
625
  const existing = await this.#store.getAsync(sessionKey);
624
626
  if (existing) {
625
- const resolved = await this.#resolveBindingForUse(existing);
627
+ const resolved = await this.#resolveBindingForUse(existing, account);
626
628
  if (resolved.state === "retargeted") {
627
629
  if (!await this.#revokeAndDeleteBinding(sessionKey, existing)) return { state: "available" };
628
630
  } else if (resolved.state === "stale") {
@@ -703,6 +705,7 @@ var ClickClackDiscussionService = class {
703
705
  store: this.#store,
704
706
  sessionKey,
705
707
  binding: attached,
708
+ account: resolved.account,
706
709
  client: this.#clientFactory(resolved.account),
707
710
  limit
708
711
  });
@@ -735,7 +738,7 @@ var ClickClackDiscussionService = class {
735
738
  }
736
739
  const activeBinding = await this.#detachedBindings.clear(sessionKey, binding);
737
740
  if (!activeBinding) return;
738
- const resolved = resolvedAccount ? this.resolveBindingAccount(activeBinding) : await this.#resolveBindingForUse(activeBinding);
741
+ const resolved = resolvedAccount ? resolvePreparedDiscussionBindingAccount(this.#currentConfig(), activeBinding, resolvedAccount) : await this.#resolveBindingForUse(activeBinding);
739
742
  if (resolved.state === "retargeted") {
740
743
  await this.#revokeAndDeleteBinding(sessionKey, activeBinding);
741
744
  return;
@@ -767,7 +770,7 @@ var ClickClackDiscussionService = class {
767
770
  bindingForAttachment = freshBinding;
768
771
  observedSiblingTitleSupport = bindings.some(({ binding: candidate }) => candidate.displayTitle !== void 0 && candidate.serverBaseUrl === freshBinding.serverBaseUrl && candidate.accountId === freshBinding.accountId);
769
772
  }
770
- const current = this.resolveBindingAccount(bindingForAttachment);
773
+ const current = resolvePreparedDiscussionBindingAccount(this.#currentConfig(), bindingForAttachment, resolved.account);
771
774
  if (current.state !== "active") return;
772
775
  const account = current.account;
773
776
  const attached = await this.#refreshSessionAttachment(sessionKey, bindingForAttachment);
@@ -802,7 +805,7 @@ var ClickClackDiscussionService = class {
802
805
  const assertCurrentAuthority = () => {
803
806
  sessionAuthority.source();
804
807
  const bound = bindingFacts.read();
805
- if (!bound || bound.externalRef !== currentBinding.externalRef || bound.serverBaseUrl !== currentBinding.serverBaseUrl || bound.channelId !== currentBinding.channelId || sessionAuthority.entry?.sessionId !== currentBinding.sessionId || sessionAuthority.entry.archivedAt !== void 0 || this.resolveBindingAccount(currentBinding).state !== "active" || isRevoked(bound)) throw new Error("ClickClack discussion authority changed before channel update");
808
+ if (!bound || bound.externalRef !== currentBinding.externalRef || bound.serverBaseUrl !== currentBinding.serverBaseUrl || bound.channelId !== currentBinding.channelId || sessionAuthority.entry?.sessionId !== currentBinding.sessionId || sessionAuthority.entry.archivedAt !== void 0 || resolvePreparedDiscussionBindingAccount(this.#currentConfig(), currentBinding, account).state !== "active" || isRevoked(bound)) throw new Error("ClickClack discussion authority changed before channel update");
806
809
  };
807
810
  let updated;
808
811
  if (labelChanged) updated = await this.#withChannelMutationLock(() => renameDiscussionChannel({
@@ -861,12 +864,12 @@ var ClickClackDiscussionService = class {
861
864
  if (!await markClickClackDiscussionChannelRevoked(this.#runtime, sessionKey, binding)) return false;
862
865
  return await this.#store.deleteIfCurrent(sessionKey, binding);
863
866
  }
864
- async #resolveBindingForUse(binding) {
865
- const resolved = this.resolveBindingAccount(binding);
867
+ async #resolveBindingForUse(binding, account) {
868
+ const resolved = account ? resolvePreparedDiscussionBindingAccount(this.#currentConfig(), binding, account) : await this.prepareBindingAccount(binding);
866
869
  if (resolved.state !== "active") return resolved;
867
870
  const workspaces = await this.#clientFactory(resolved.account).workspaces();
868
871
  const workspace = findClickClackWorkspace(workspaces, resolved.account.discussions.workspace);
869
- const current = this.resolveBindingAccount(binding);
872
+ const current = resolvePreparedDiscussionBindingAccount(this.#currentConfig(), binding, resolved.account);
870
873
  if (current.state !== "active") return current;
871
874
  return workspace?.id === binding.workspaceId ? current : { state: "retargeted" };
872
875
  }
@@ -911,10 +914,19 @@ var ClickClackDiscussionService = class {
911
914
  return operation;
912
915
  }
913
916
  };
914
- //#endregion
915
- //#region extensions/clickclack/src/discussions/register.ts
917
+ // extensions/clickclack/src/discussions/register.ts
916
918
  const DEFAULT_MESSAGE_LIMIT = 30;
917
919
  const MAX_MESSAGE_LIMIT = 200;
920
+ const DiscussionParameters = {
921
+ type: "object",
922
+ properties: { limit: {
923
+ type: "integer",
924
+ minimum: 1,
925
+ maximum: MAX_MESSAGE_LIMIT,
926
+ description: `Maximum messages to return (default ${DEFAULT_MESSAGE_LIMIT}).`
927
+ } },
928
+ additionalProperties: false
929
+ };
918
930
  const TARGETED_SESSION_TOOLS = /* @__PURE__ */ new Set([
919
931
  "sessions_history",
920
932
  "sessions_send",
@@ -952,13 +964,14 @@ function registerClickClackDiscussions(api) {
952
964
  binding: current
953
965
  }), (current) => bindingMatchesActiveSessionIncarnation(runtime, targetSessionKey, current));
954
966
  }
955
- function currentDiscussionTarget(params, binding, isRevoked, isActiveSession) {
967
+ function currentDiscussionTarget(params, binding, isRevoked, isActiveSession, preparedAccount) {
956
968
  const { targetSessionKey } = params;
969
+ const cfg = runtime.config.current();
957
970
  if (binding && discussionSessionKey({
958
971
  runtime,
959
972
  mainSessionKey: targetSessionKey,
960
973
  ...binding
961
- }) === params.requesterSessionKey && !isRevoked(binding) && isActiveSession(binding) && service.resolveBindingAccount(binding).state === "active") return {
974
+ }) === params.requesterSessionKey && !isRevoked(binding) && isActiveSession(binding) && (preparedAccount ? resolvePreparedDiscussionBindingAccount(cfg, binding, preparedAccount) : resolveDiscussionBindingAccount(cfg, binding)).state === "active") return {
962
975
  sessionKey: targetSessionKey,
963
976
  binding
964
977
  };
@@ -976,10 +989,12 @@ function registerClickClackDiscussions(api) {
976
989
  runtime,
977
990
  ...binding
978
991
  });
992
+ const resolved = await service.prepareBindingAccount(binding);
993
+ if (resolved.state !== "active") return;
979
994
  session = await prepareDiscussionSessionEntry(runtime, params.targetSessionKey);
980
995
  session.source();
981
996
  const entry = session.entry;
982
- return currentDiscussionTarget(params, facts.read(), revocation.isRevoked, (current) => entry?.sessionId === current.sessionId && entry.archivedAt === void 0);
997
+ return currentDiscussionTarget(params, facts.read(), revocation.isRevoked, (current) => entry?.sessionId === current.sessionId && entry.archivedAt === void 0, resolved.account);
983
998
  } catch {
984
999
  return;
985
1000
  } finally {
@@ -998,16 +1013,7 @@ function registerClickClackDiscussions(api) {
998
1013
  name: "discussion",
999
1014
  label: "Discussion",
1000
1015
  description: "Read the latest messages from the ClickClack discussion bound to this session.",
1001
- parameters: {
1002
- type: "object",
1003
- properties: { limit: {
1004
- type: "integer",
1005
- minimum: 1,
1006
- maximum: MAX_MESSAGE_LIMIT,
1007
- description: `Maximum messages to return (default ${DEFAULT_MESSAGE_LIMIT}).`
1008
- } },
1009
- additionalProperties: false
1010
- },
1016
+ parameters: DiscussionParameters,
1011
1017
  async execute(_toolCallId, input) {
1012
1018
  if (!sessionKey) return textResult("No discussion is bound to this session.", { bound: false });
1013
1019
  const requested = typeof input === "object" && input !== null && "limit" in input ? Number(input.limit) : DEFAULT_MESSAGE_LIMIT;
@@ -1060,5 +1066,4 @@ function registerClickClackDiscussions(api) {
1060
1066
  }
1061
1067
  });
1062
1068
  }
1063
- //#endregion
1064
1069
  export { registerClickClackDiscussions as t };
@@ -1,6 +1,6 @@
1
1
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
2
2
  import { collectConditionalChannelFieldAssignments, createChannelSecretContract, hasConfiguredSecretInputValue } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
3
- //#region extensions/clickclack/src/secret-contract.ts
3
+ // extensions/clickclack/src/secret-contract.ts
4
4
  const channelSecrets = createChannelSecretContract({
5
5
  channelKey: "clickclack",
6
6
  account: ["token"],
@@ -22,5 +22,4 @@ const channelSecrets = createChannelSecretContract({
22
22
  }
23
23
  });
24
24
  const { secretTargetRegistryEntries, collectRuntimeConfigAssignments } = channelSecrets;
25
- //#endregion
26
25
  export { collectRuntimeConfigAssignments as n, secretTargetRegistryEntries as r, channelSecrets as t };
@@ -1,2 +1,2 @@
1
- export { t as channelSecrets, n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-CF7TKtkU.mjs";
1
+ export { t as channelSecrets, n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-Dj8nibUr.mjs";
2
2
  import "../secret-contract-api.js";
@@ -1,9 +1,9 @@
1
- import { a as isClickClackSetupLoopbackHost, i as buildClickClackSetupClaimUrl, o as requireClickClackSetupApiBaseUrl } from "./setup-surface-CSITttSD.mjs";
1
+ import { a as isClickClackSetupLoopbackHost, i as buildClickClackSetupClaimUrl, o as requireClickClackSetupApiBaseUrl } from "./setup-surface-DSbHN_QA.mjs";
2
2
  import { withTimeout } from "openclaw/plugin-sdk/text-utility-runtime";
3
3
  import { createProviderOperationDeadline, readProviderJsonResponse, readResponseTextLimited, resolveProviderOperationTimeoutMs } from "openclaw/plugin-sdk/provider-http";
4
- import { isStringArray } from "openclaw/plugin-sdk/collection-input-runtime";
5
4
  import { fetchWithSsrFGuard, resolvePinnedHostnameWithPolicy, ssrfPolicyFromHttpBaseUrlAllowedHostname } from "openclaw/plugin-sdk/ssrf-runtime";
6
- //#region extensions/clickclack/src/setup-claim.ts
5
+ import { isStringArray } from "openclaw/plugin-sdk/collection-input-runtime";
6
+ // extensions/clickclack/src/setup-claim.ts
7
7
  const CLICKCLACK_ERROR_BODY_LIMIT_BYTES = 8192;
8
8
  const CLICKCLACK_SETUP_CODE_CLAIM_JSON_LIMIT_BYTES = 65536;
9
9
  const CLICKCLACK_SETUP_CODE_CLAIM_TIMEOUT_MS = 3e4;
@@ -122,5 +122,4 @@ async function claimClickClackSetupCode(params) {
122
122
  await release();
123
123
  }
124
124
  }
125
- //#endregion
126
125
  export { claimClickClackSetupCode };
@@ -1,5 +1,5 @@
1
- import { l as clickClackConfigAdapter, n as clickClackSetupContract, s as clickClackConfigSchema, t as clickClackSetupWizard, u as clickClackMeta } from "./setup-surface-CSITttSD.mjs";
2
- //#region extensions/clickclack/src/channel.setup.ts
1
+ import { l as clickClackConfigAdapter, n as clickClackSetupContract, s as clickClackConfigSchema, t as clickClackSetupWizard, u as clickClackMeta } from "./setup-surface-DSbHN_QA.mjs";
2
+ // extensions/clickclack/src/channel.setup.ts
3
3
  const clickClackSetupPlugin = {
4
4
  id: "clickclack",
5
5
  meta: clickClackMeta,
@@ -14,5 +14,4 @@ const clickClackSetupPlugin = {
14
14
  setupContract: clickClackSetupContract,
15
15
  setupWizard: clickClackSetupWizard
16
16
  };
17
- //#endregion
18
17
  export { clickClackSetupPlugin as t };
@@ -0,0 +1 @@
1
+ export { t as clickClackSetupPlugin } from "./setup-plugin-api-Bv07Jgqa.mjs";
@@ -15,7 +15,7 @@ import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
15
15
  import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, applyAccountNameToChannelSection, baseUrlTextInput, createSetupTranslator, createStandardChannelSetupStatus, defineTokenCredential, formatDocsLink, hasConfiguredSecretInput, moveSingleAccountChannelSectionToDefaultAccount, patchScopedAccountConfig, prepareScopedSetupConfig, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
16
16
  import { createSetupInputPresenceValidator } from "openclaw/plugin-sdk/setup-runtime";
17
17
  import net from "node:net";
18
- //#region extensions/clickclack/src/accounts.ts
18
+ // extensions/clickclack/src/accounts.ts
19
19
  const DEFAULT_RECONNECT_MS = 1500;
20
20
  const MIN_RECONNECT_MS = 100;
21
21
  const MAX_RECONNECT_MS = 6e4;
@@ -46,7 +46,8 @@ function mergeClickClackGroups(...sources) {
46
46
  }
47
47
  return Object.fromEntries(merged);
48
48
  }
49
- function resolveClickClackAccountConfig(cfg, accountId) {
49
+ function resolveClickClackAccountConfig(cfg, rawAccountId) {
50
+ const accountId = normalizeAccountId(rawAccountId);
50
51
  const channel = cfg.channels?.clickclack;
51
52
  const merged = resolveMergedClickClackAccountConfig(cfg, accountId);
52
53
  const account = resolveNormalizedAccountEntry(channel?.accounts, accountId, normalizeAccountId);
@@ -82,11 +83,13 @@ function isClickClackAccountCurrent(params) {
82
83
  const endpoints = resolveClickClackAccountEndpoints(current);
83
84
  return current.enabled !== false && Boolean(endpoints.baseUrl && current.workspace?.trim()) && endpoints.baseUrl === account.baseUrl && endpoints.apiEndpoint === account.apiEndpoint && current.workspace?.trim() === account.config.workspace?.trim() && normalizeOptionalString(current.botUserId) === normalizeOptionalString(account.config.botUserId);
84
85
  }
86
+ function tokenFileConfigPath(cfg, accountId) {
87
+ return resolveNormalizedAccountEntry(cfg.channels?.clickclack?.accounts, accountId, normalizeAccountId)?.tokenFile?.trim() ? `channels.clickclack.accounts.${accountId}.tokenFile` : "channels.clickclack.tokenFile";
88
+ }
85
89
  function resolveClickClackToken(params) {
86
90
  const tokenFile = params.tokenFile?.trim();
87
91
  if (tokenFile) {
88
- const accountTokenFile = resolveNormalizedAccountEntry(params.cfg.channels?.clickclack?.accounts, params.accountId, normalizeAccountId)?.tokenFile?.trim();
89
- const result = tryReadSecretFileSync(tokenFile, "ClickClack bot token", { rejectSymlink: true }, { configPath: accountTokenFile ? `channels.clickclack.accounts.${params.accountId}.tokenFile` : "channels.clickclack.tokenFile" });
92
+ const result = tryReadSecretFileSync(tokenFile, "ClickClack bot token", { rejectSymlink: true }, { configPath: tokenFileConfigPath(params.cfg, params.accountId) });
90
93
  return result.status === "available" ? {
91
94
  token: result.value,
92
95
  tokenSource: "tokenFile",
@@ -146,15 +149,18 @@ function resolveClickClackToken(params) {
146
149
  tokenStatus: "available"
147
150
  };
148
151
  }
149
- function resolveClickClackAccount(params) {
152
+ function resolveClickClackAccountMetadata(params) {
150
153
  const accountId = normalizeAccountId(params.accountId);
151
154
  const merged = resolveClickClackAccountConfig(params.cfg, accountId);
152
155
  const enabled = params.cfg.channels?.clickclack?.enabled !== false && merged.enabled !== false;
153
156
  const { baseUrl, apiEndpoint } = resolveClickClackAccountEndpoints(merged);
154
- const token = resolveClickClackToken({
157
+ const token = merged.tokenFile?.trim() ? {
158
+ token: "",
159
+ tokenSource: "tokenFile",
160
+ tokenStatus: void 0
161
+ } : resolveClickClackToken({
155
162
  cfg: params.cfg,
156
163
  value: merged.token,
157
- tokenFile: merged.tokenFile,
158
164
  accountId,
159
165
  env: params.env
160
166
  });
@@ -203,14 +209,72 @@ function resolveClickClackAccount(params) {
203
209
  apiEndpoint
204
210
  };
205
211
  }
212
+ /** Compatibility for explicit synchronous SDK account and scoped-access callers. */
213
+ function resolveClickClackAccount(params) {
214
+ const account = resolveClickClackAccountMetadata(params);
215
+ return account.config.tokenFile?.trim() ? {
216
+ ...account,
217
+ ...resolveClickClackToken({
218
+ cfg: params.cfg,
219
+ value: account.config.token,
220
+ tokenFile: account.config.tokenFile,
221
+ accountId: account.accountId,
222
+ env: params.env
223
+ })
224
+ } : account;
225
+ }
226
+ /** Operational callers prepare the current external credential without blocking the Gateway. */
227
+ async function resolveClickClackAccountAsync(params) {
228
+ const account = resolveClickClackAccountMetadata(params);
229
+ const tokenFile = account.config.tokenFile?.trim();
230
+ if (!tokenFile) return account;
231
+ const [{ readSecretFile }, { FsSafeError }] = await Promise.all([import("openclaw/plugin-sdk/secret-file"), import("openclaw/plugin-sdk/security-runtime")]);
232
+ try {
233
+ return {
234
+ ...account,
235
+ token: await readSecretFile(tokenFile, "ClickClack bot token", { rejectSymlink: true }),
236
+ tokenStatus: "available"
237
+ };
238
+ } catch (error) {
239
+ if (!(error instanceof FsSafeError)) throw error;
240
+ return {
241
+ ...account,
242
+ tokenStatus: "configured_unavailable",
243
+ credentialDiagnostics: [{
244
+ code: "CREDENTIAL_FILE_UNAVAILABLE",
245
+ path: tokenFileConfigPath(params.cfg, account.accountId),
246
+ reason: error.code
247
+ }]
248
+ };
249
+ }
250
+ }
251
+ /** Read-only snapshots use configured facts; the channel lifetime owns credential health. */
252
+ function inspectClickClackAccount(cfg, rawAccountId) {
253
+ const accountId = normalizeAccountId(rawAccountId);
254
+ const config = resolveClickClackAccountConfig(cfg, accountId);
255
+ const { baseUrl } = resolveClickClackAccountEndpoints(config);
256
+ const credential = config.tokenFile?.trim() ? { tokenSource: "tokenFile" } : resolveClickClackToken({
257
+ cfg,
258
+ value: config.token,
259
+ accountId
260
+ });
261
+ return {
262
+ accountId,
263
+ name: normalizeOptionalString(config.name),
264
+ enabled: cfg.channels?.clickclack?.enabled !== false && config.enabled !== false,
265
+ configured: Boolean(baseUrl && config.workspace?.trim() && credential.tokenSource !== "none"),
266
+ baseUrl,
267
+ tokenSource: credential.tokenSource,
268
+ ..."tokenStatus" in credential ? { tokenStatus: credential.tokenStatus } : {}
269
+ };
270
+ }
206
271
  function listEnabledClickClackAccounts(cfg) {
207
272
  return listClickClackAccountIds(cfg).map((accountId) => resolveClickClackAccount({
208
273
  cfg,
209
274
  accountId
210
275
  })).filter((account) => account.enabled);
211
276
  }
212
- //#endregion
213
- //#region extensions/clickclack/src/channel-config.ts
277
+ // extensions/clickclack/src/channel-config.ts
214
278
  const CLICKCLACK_CHANNEL_ID = "clickclack";
215
279
  const clickClackMeta = { ...getChatChannelMeta(CLICKCLACK_CHANNEL_ID) };
216
280
  const clickClackConfigAdapter = {
@@ -219,19 +283,17 @@ const clickClackConfigAdapter = {
219
283
  cfg,
220
284
  accountId
221
285
  }),
222
- defaultAccountId: (cfg) => resolveDefaultClickClackAccountId(cfg),
223
- isConfigured: (account) => account.configured,
224
- resolveAllowFrom: ({ cfg, accountId }) => resolveClickClackAccount({
225
- cfg,
226
- accountId
227
- }).allowFrom,
228
- resolveDefaultTo: ({ cfg, accountId }) => resolveClickClackAccount({
286
+ resolveAccountAsync: (cfg, accountId) => resolveClickClackAccountAsync({
229
287
  cfg,
230
288
  accountId
231
- }).defaultTo
289
+ }),
290
+ inspectAccount: (cfg, accountId) => inspectClickClackAccount(cfg, accountId),
291
+ defaultAccountId: (cfg) => resolveDefaultClickClackAccountId(cfg),
292
+ isConfigured: (account) => account.configured,
293
+ resolveAllowFrom: ({ cfg, accountId }) => resolveClickClackAccountConfig(cfg, accountId).allowFrom ?? ["*"],
294
+ resolveDefaultTo: ({ cfg, accountId }) => resolveClickClackAccountConfig(cfg, accountId).defaultTo?.trim() || "channel:general"
232
295
  };
233
- //#endregion
234
- //#region extensions/clickclack/src/config-schema.ts
296
+ // extensions/clickclack/src/config-schema.ts
235
297
  const ClickClackAccountConfigSchema = z.object({
236
298
  name: z.string().optional(),
237
299
  enabled: z.boolean().optional(),
@@ -297,8 +359,7 @@ const clickClackConfigSchema = buildChannelConfigSchema(ClickClackConfigSchema,
297
359
  help: "Override the account policy for threads rooted in this bot's messages in this channel."
298
360
  }
299
361
  } });
300
- //#endregion
301
- //#region extensions/clickclack/src/setup-contract.ts
362
+ // extensions/clickclack/src/setup-contract.ts
302
363
  const CLICKCLACK_SETUP_CODE_CLAIM_PATH = "/api/bot-setup-codes/claim";
303
364
  const LOOPBACK_ADDRESSES = new net.BlockList();
304
365
  LOOPBACK_ADDRESSES.addSubnet("127.0.0.0", 8, "ipv4");
@@ -340,8 +401,7 @@ function requireClickClackSetupClaimUrl(value) {
340
401
  function buildClickClackSetupClaimUrl(baseUrl) {
341
402
  return baseUrl.replace(/\/+$/u, "") + CLICKCLACK_SETUP_CODE_CLAIM_PATH;
342
403
  }
343
- //#endregion
344
- //#region extensions/clickclack/src/setup-core.ts
404
+ // extensions/clickclack/src/setup-core.ts
345
405
  const channel$1 = "clickclack";
346
406
  const SETUP_CODE_ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
347
407
  const SETUP_CODE_LENGTH = 12;
@@ -450,7 +510,7 @@ const clickClackSetupAdapter = {
450
510
  const claimUrl = setup.exactClaimUrl && !privateApiBaseUrl ? setup.exactClaimUrl : buildClickClackSetupClaimUrl(privateApiBaseUrl ?? setup.baseUrl);
451
511
  let claim;
452
512
  try {
453
- const { claimClickClackSetupCode } = await import("./setup-claim-Ca2nzQHc.mjs");
513
+ const { claimClickClackSetupCode } = await import("./setup-claim-DDJ9VKhn.mjs");
454
514
  claim = await claimClickClackSetupCode({
455
515
  claimUrl,
456
516
  code: setup.code,
@@ -530,7 +590,7 @@ const clickClackSetupAdapter = {
530
590
  });
531
591
  },
532
592
  afterAccountConfigWritten: async ({ cfg, accountId, runtime }) => {
533
- const { verifyClickClackAccountAfterSetup } = await import("./setup-verify-DLfG0Fyt.mjs");
593
+ const { verifyClickClackAccountAfterSetup } = await import("./setup-verify-BRmRzZD7.mjs");
534
594
  await verifyClickClackAccountAfterSetup({
535
595
  cfg,
536
596
  accountId,
@@ -610,8 +670,7 @@ const clickClackSetupContract = defineChannelSetupContract({
610
670
  },
611
671
  legacyAdapter: clickClackSetupAdapter
612
672
  });
613
- //#endregion
614
- //#region extensions/clickclack/src/setup-surface.ts
673
+ // extensions/clickclack/src/setup-surface.ts
615
674
  const t = createSetupTranslator();
616
675
  const channel = "clickclack";
617
676
  function hasConfiguredClickClackCredential(account) {
@@ -630,7 +689,7 @@ const clickClackSetupWizard = {
630
689
  unconfiguredHint: t("wizard.channels.statusNeedsSetup"),
631
690
  configuredScore: 2,
632
691
  unconfiguredScore: 1,
633
- resolveConfigured: ({ cfg, accountId }) => (accountId ? [accountId] : listClickClackAccountIds(cfg)).some((resolvedAccountId) => isClickClackSetupConfigured(resolveClickClackAccount({
692
+ resolveConfigured: ({ cfg, accountId }) => (accountId ? [accountId] : listClickClackAccountIds(cfg)).some((resolvedAccountId) => isClickClackSetupConfigured(resolveClickClackAccountMetadata({
634
693
  cfg,
635
694
  accountId: resolvedAccountId
636
695
  })))
@@ -638,7 +697,7 @@ const clickClackSetupWizard = {
638
697
  introNote: {
639
698
  title: t("wizard.clickclack.botTokenTitle"),
640
699
  lines: [t("wizard.clickclack.helpCreateToken"), t("wizard.channels.docs", { link: formatDocsLink("/channels/clickclack", "clickclack") })],
641
- shouldShow: ({ cfg, accountId }) => !isClickClackSetupConfigured(resolveClickClackAccount({
700
+ shouldShow: ({ cfg, accountId }) => !isClickClackSetupConfigured(resolveClickClackAccountMetadata({
642
701
  cfg,
643
702
  accountId
644
703
  }))
@@ -654,7 +713,7 @@ const clickClackSetupWizard = {
654
713
  keepPrompt: t("wizard.clickclack.botTokenKeep"),
655
714
  inputPrompt: t("wizard.clickclack.botTokenInput"),
656
715
  allowEnv: ({ accountId }) => accountId === DEFAULT_ACCOUNT_ID$1,
657
- resolveAccount: ({ cfg, accountId }) => resolveClickClackAccount({
716
+ resolveAccount: ({ cfg, accountId }) => resolveClickClackAccountMetadata({
658
717
  cfg,
659
718
  accountId
660
719
  }),
@@ -677,7 +736,7 @@ const clickClackSetupWizard = {
677
736
  inputKey: "baseUrl",
678
737
  configKey: "baseUrl",
679
738
  message: t("wizard.clickclack.baseUrlPrompt"),
680
- resolveAccount: ({ cfg, accountId }) => resolveClickClackAccount({
739
+ resolveAccount: ({ cfg, accountId }) => resolveClickClackAccountMetadata({
681
740
  cfg,
682
741
  accountId
683
742
  }),
@@ -695,11 +754,11 @@ const clickClackSetupWizard = {
695
754
  message: t("wizard.clickclack.workspacePrompt"),
696
755
  helpTitle: t("wizard.clickclack.workspacePrompt"),
697
756
  helpLines: [t("wizard.clickclack.workspaceHelp")],
698
- currentValue: ({ cfg, accountId }) => resolveClickClackAccount({
757
+ currentValue: ({ cfg, accountId }) => resolveClickClackAccountMetadata({
699
758
  cfg,
700
759
  accountId
701
760
  }).workspace || void 0,
702
- initialValue: ({ cfg, accountId }) => resolveClickClackAccount({
761
+ initialValue: ({ cfg, accountId }) => resolveClickClackAccountMetadata({
703
762
  cfg,
704
763
  accountId
705
764
  }).workspace || void 0,
@@ -712,7 +771,7 @@ const clickClackSetupWizard = {
712
771
  })
713
772
  }],
714
773
  finalize: async ({ cfg, accountId, credentialValues, prompter }) => {
715
- const { checkClickClackSetupConnection } = await import("./setup-verify-DLfG0Fyt.mjs");
774
+ const { checkClickClackSetupConnection } = await import("./setup-verify-BRmRzZD7.mjs");
716
775
  const result = await checkClickClackSetupConnection({
717
776
  cfg,
718
777
  accountId,
@@ -731,5 +790,4 @@ const clickClackSetupWizard = {
731
790
  },
732
791
  disable: (cfg) => setSetupChannelEnabled(cfg, channel, false)
733
792
  };
734
- //#endregion
735
- export { resolveDefaultClickClackAccountId as _, isClickClackSetupLoopbackHost as a, CLICKCLACK_CHANNEL_ID as c, DEFAULT_ACCOUNT_ID$2 as d, isClickClackAccountCurrent as f, resolveClickClackAccountConfig as g, resolveClickClackAccount as h, buildClickClackSetupClaimUrl as i, clickClackConfigAdapter as l, listEnabledClickClackAccounts as m, clickClackSetupContract as n, requireClickClackSetupApiBaseUrl as o, listClickClackAccountIds as p, CLICKCLACK_SETUP_CODE_CLAIM_PATH as r, clickClackConfigSchema as s, clickClackSetupWizard as t, clickClackMeta as u };
793
+ export { resolveClickClackAccountConfig as _, isClickClackSetupLoopbackHost as a, CLICKCLACK_CHANNEL_ID as c, DEFAULT_ACCOUNT_ID$2 as d, isClickClackAccountCurrent as f, resolveClickClackAccountAsync as g, resolveClickClackAccount as h, buildClickClackSetupClaimUrl as i, clickClackConfigAdapter as l, listEnabledClickClackAccounts as m, clickClackSetupContract as n, requireClickClackSetupApiBaseUrl as o, listClickClackAccountIds as p, CLICKCLACK_SETUP_CODE_CLAIM_PATH as r, clickClackConfigSchema as s, clickClackSetupWizard as t, clickClackMeta as u, resolveClickClackAccountMetadata as v, resolveDefaultClickClackAccountId as y };
@@ -1,9 +1,9 @@
1
- import { h as resolveClickClackAccount } from "./setup-surface-CSITttSD.mjs";
2
- import { a as createClickClackClient, i as ClickClackHttpError, t as findClickClackWorkspace } from "./resolve-BgFJI_p4.mjs";
1
+ import { g as resolveClickClackAccountAsync } from "./setup-surface-DSbHN_QA.mjs";
2
+ import { a as createClickClackClient, i as ClickClackHttpError, t as findClickClackWorkspace } from "./resolve-qeIY2bou.mjs";
3
3
  import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
4
4
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
5
5
  import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/setup";
6
- //#region extensions/clickclack/src/setup-verify.ts
6
+ // extensions/clickclack/src/setup-verify.ts
7
7
  const GATEWAY_RUNNING_MESSAGE = "OpenClaw is running — ClickClack will connect automatically.";
8
8
  const GATEWAY_NOT_RUNNING_MESSAGE = "Start OpenClaw to connect: openclaw gateway";
9
9
  const GATEWAY_UNKNOWN_MESSAGE = "If OpenClaw is running it connects automatically; otherwise start it with: openclaw gateway";
@@ -12,7 +12,7 @@ function usesUnavailableImplicitEnvToken(account, tokenOverride) {
12
12
  }
13
13
  async function checkClickClackSetupConnection(params) {
14
14
  try {
15
- const account = resolveClickClackAccount({
15
+ const account = await resolveClickClackAccountAsync({
16
16
  cfg: params.cfg,
17
17
  accountId: params.accountId
18
18
  });
@@ -78,5 +78,4 @@ async function verifyClickClackAccountAfterSetup(params) {
78
78
  if (message) params.runtime.log(message);
79
79
  params.runtime.log(await probeClickClackGatewayStatus());
80
80
  }
81
- //#endregion
82
81
  export { checkClickClackSetupConnection, verifyClickClackAccountAfterSetup };