aai-lark-bridge 0.1.4 → 0.1.6

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/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import { Command } from "commander";
4
4
  // package.json
5
5
  var package_default = {
6
6
  name: "aai-lark-bridge",
7
- version: "0.1.4",
7
+ version: "0.1.6",
8
8
  description: "Lark AI Native Bridge - Lark\u57FA\u7840\u8BBE\u65BD\u5C42\u548CCLI\u96C6\u6210",
9
9
  type: "module",
10
10
  main: "./dist/index.js",
@@ -14724,8 +14724,14 @@ async function runAgentBatch(deps) {
14724
14724
  });
14725
14725
  }
14726
14726
  }
14727
+ const scopeCwd = workspaces.cwdFor(scope);
14728
+ const scopeEngaged = Boolean(sessions2.getRaw(scope)) || (sessionCatalog?.hasResumableForScope({
14729
+ scopeId: scope,
14730
+ agentId: controls.profileConfig.agentKind,
14731
+ ...scopeCwd ? { cwdRealpath: scopeCwd } : {}
14732
+ }) ?? false);
14727
14733
  let topicContext = [];
14728
- if (mode === "topic" && threadId && !sessions2.getRaw(scope)) {
14734
+ if (mode === "topic" && threadId && !scopeEngaged) {
14729
14735
  const exclude = /* @__PURE__ */ new Set([...batchIds, ...quoteTargets]);
14730
14736
  topicContext = await fetchTopicContext(channel, threadId, {
14731
14737
  maxMessages: 40,
@@ -16937,6 +16943,35 @@ var SessionCatalog = class {
16937
16943
  }
16938
16944
  return { ...entry };
16939
16945
  }
16946
+ /**
16947
+ * Whether a run for this scope would find something to resume. Callers that
16948
+ * run before the policy is resolved cannot build a full identity, but still
16949
+ * need to know "has the agent already engaged here" — topic upstream
16950
+ * backfill is the case: it must not re-inject the thread's history into a
16951
+ * conversation that already carries it.
16952
+ *
16953
+ * Narrow it with everything the caller *does* know. `activeFor()` resumes
16954
+ * only on an exact identity match, so a probe that answers on `scopeId`
16955
+ * alone reports "engaged" for entries that will not in fact be resumed —
16956
+ * and then a genuinely fresh session starts with no upstream history at all.
16957
+ * `/cd` and `/ws use` create exactly that state: they reset the session but
16958
+ * deliberately leave the old cwd's entry active so cd-ing back still resumes.
16959
+ *
16960
+ * `policyFingerprint` is the one axis that stays open: it does not exist
16961
+ * until the policy resolves. A profile change that alters it still costs the
16962
+ * next fresh session its backfill.
16963
+ */
16964
+ hasResumableForScope(probe) {
16965
+ for (const entry of this.data.values()) {
16966
+ if (entry.scopeId !== probe.scopeId) continue;
16967
+ if (entry.agentId !== probe.agentId) continue;
16968
+ if (probe.cwdRealpath !== void 0 && entry.cwdRealpath !== probe.cwdRealpath) continue;
16969
+ if (entry.status !== "active") continue;
16970
+ if (!isValidAgentEntry(entry)) continue;
16971
+ return true;
16972
+ }
16973
+ return false;
16974
+ }
16940
16975
  upsertActive(input) {
16941
16976
  assertAgentIdentity(input);
16942
16977
  const key = sessionCatalogKey(input);