aai-lark-bridge 0.1.5 → 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.5",
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,7 +14724,12 @@ async function runAgentBatch(deps) {
14724
14724
  });
14725
14725
  }
14726
14726
  }
14727
- const scopeEngaged = Boolean(sessions2.getRaw(scope)) || (sessionCatalog?.hasActiveForScope(scope) ?? false);
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);
14728
14733
  let topicContext = [];
14729
14734
  if (mode === "topic" && threadId && !scopeEngaged) {
14730
14735
  const exclude = /* @__PURE__ */ new Set([...batchIds, ...quoteTargets]);
@@ -16939,15 +16944,28 @@ var SessionCatalog = class {
16939
16944
  return { ...entry };
16940
16945
  }
16941
16946
  /**
16942
- * Whether this scope has any live session, regardless of agent, cwd or
16943
- * policy. Callers that run before the policy is resolved cannot build a
16944
- * full identity, but still need to know "has the agent already engaged
16945
- * here" — topic upstream backfill is the case: it must not re-inject the
16946
- * thread's history into a conversation that already carries it.
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.
16947
16963
  */
16948
- hasActiveForScope(scopeId) {
16964
+ hasResumableForScope(probe) {
16949
16965
  for (const entry of this.data.values()) {
16950
- if (entry.scopeId !== scopeId) continue;
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;
16951
16969
  if (entry.status !== "active") continue;
16952
16970
  if (!isValidAgentEntry(entry)) continue;
16953
16971
  return true;