@agent-team-foundation/first-tree-hub 0.14.9-alpha.294.1 → 0.14.9-alpha.296.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,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $ as cleanWorkspaces, A as printResults, B as ClientRuntime, C as migrateLocalAgentDirs, D as checkNodeVersion, E as checkClientConfig, G as removeLocalAgent, I as restartClientService, J as ClientOrgMismatchError, K as fail, L as startClientService, M as getClientServiceStatus, N as installClientService, O as checkServerReachable, P as isServiceSupported, Q as SessionRegistry, R as stopClientService, S as createApiNameResolver, T as checkBackgroundService, U as findStaleAliases, V as handleClientOrgMismatch, W as formatStaleReason, X as FirstTreeHubSDK, Y as ClientUserMismatchError, Z as SdkError, _ as loadOnboardState, a as declineUpdate, b as saveOnboardState, c as detectInstallMode, d as reconcileLocalRuntimeProviders, et as probeCapabilities, f as uploadClientCapabilities, g as formatCheckReport, h as promptMissingFields, i as createExecuteUpdate, j as reconcileAgentConfigs, k as checkWebSocket, l as fetchLatestVersion, m as promptAddAgent, nt as configureClientLoggerForService, o as promptUpdate, p as isInteractive, q as success, r as registerSaaSConnectCommand, s as PACKAGE_NAME, tt as applyClientLoggerConfig, u as installGlobalLatest, v as onboardCheck, w as checkAgentConfigs, x as runHomeMigration, y as onboardCreate } from "../saas-connect-DzbieDfo.mjs";
2
+ import { $ as cleanWorkspaces, A as printResults, B as ClientRuntime, C as migrateLocalAgentDirs, D as checkNodeVersion, E as checkClientConfig, G as removeLocalAgent, I as restartClientService, J as ClientOrgMismatchError, K as fail, L as startClientService, M as getClientServiceStatus, N as installClientService, O as checkServerReachable, P as isServiceSupported, Q as SessionRegistry, R as stopClientService, S as createApiNameResolver, T as checkBackgroundService, U as findStaleAliases, V as handleClientOrgMismatch, W as formatStaleReason, X as FirstTreeHubSDK, Y as ClientUserMismatchError, Z as SdkError, _ as loadOnboardState, a as declineUpdate, b as saveOnboardState, c as detectInstallMode, d as reconcileLocalRuntimeProviders, et as probeCapabilities, f as uploadClientCapabilities, g as formatCheckReport, h as promptMissingFields, i as createExecuteUpdate, j as reconcileAgentConfigs, k as checkWebSocket, l as fetchLatestVersion, m as promptAddAgent, nt as configureClientLoggerForService, o as promptUpdate, p as isInteractive, q as success, r as registerSaaSConnectCommand, s as PACKAGE_NAME, tt as applyClientLoggerConfig, u as installGlobalLatest, v as onboardCheck, w as checkAgentConfigs, x as runHomeMigration, y as onboardCreate } from "../saas-connect-DgR60HGv.mjs";
3
3
  import { C as resolveConfigReadonly, S as resetConfigMeta, _ as initConfig, a as loadCredentials, b as readConfigFile, c as saveAgentConfig, d as DEFAULT_DATA_DIR, f as DEFAULT_HOME_DIR, g as getConfigValue, i as ensureFreshAdminToken, m as clientConfigSchema, p as agentConfigSchema, r as ensureFreshAccessToken, s as resolveServerUrl, u as DEFAULT_CONFIG_DIR, v as loadAgents, w as setConfigValue, x as resetConfig } from "../bootstrap-D6RsdtJg.mjs";
4
4
  import { a as print, n as CLI_USER_AGENT, o as setJsonMode, r as COMMAND_VERSION, t as cliFetch } from "../cli-fetch-BGVItZxo.mjs";
5
5
  import { n as bindFeishuUser, t as bindFeishuBot } from "../feishu-CwD_5b9W.mjs";
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as printResults, B as ClientRuntime, D as checkNodeVersion, E as checkClientConfig, F as resolveCliInvocation, H as rotateClientIdWithBackup, I as restartClientService, L as startClientService, M as getClientServiceStatus, N as installClientService, O as checkServerReachable, P as isServiceSupported, R as stopClientService, V as handleClientOrgMismatch, X as FirstTreeHubSDK, Z as SdkError, g as formatCheckReport, h as promptMissingFields, k as checkWebSocket, m as promptAddAgent, n as deriveHubUrlFromToken, p as isInteractive, t as HubUrlDerivationError, v as onboardCheck, w as checkAgentConfigs, x as runHomeMigration, y as onboardCreate, z as uninstallClientService } from "./saas-connect-DzbieDfo.mjs";
1
+ import { A as printResults, B as ClientRuntime, D as checkNodeVersion, E as checkClientConfig, F as resolveCliInvocation, H as rotateClientIdWithBackup, I as restartClientService, L as startClientService, M as getClientServiceStatus, N as installClientService, O as checkServerReachable, P as isServiceSupported, R as stopClientService, V as handleClientOrgMismatch, X as FirstTreeHubSDK, Z as SdkError, g as formatCheckReport, h as promptMissingFields, k as checkWebSocket, m as promptAddAgent, n as deriveHubUrlFromToken, p as isInteractive, t as HubUrlDerivationError, v as onboardCheck, w as checkAgentConfigs, x as runHomeMigration, y as onboardCreate, z as uninstallClientService } from "./saas-connect-DgR60HGv.mjs";
2
2
  import { i as ensureFreshAdminToken, n as AuthRefreshRateLimitedError, o as resolveAccessToken, r as ensureFreshAccessToken, s as resolveServerUrl, t as AuthRefreshFailedError } from "./bootstrap-D6RsdtJg.mjs";
3
3
  import { i as blank, s as status } from "./cli-fetch-BGVItZxo.mjs";
4
4
  import { n as bindFeishuUser, t as bindFeishuBot } from "./feishu-CwD_5b9W.mjs";
@@ -10286,25 +10286,15 @@ function createResultSink(deps) {
10286
10286
  async function buildMetadata(text) {
10287
10287
  const metadata = {};
10288
10288
  const documentBasePath = await deps.getDocumentBasePath?.();
10289
- if (documentBasePath) {
10290
- let snapshotsWritten = false;
10291
- try {
10292
- const { docs, skipped } = await buildMessageDocumentSnapshots(text, documentBasePath);
10293
- if (docs.length > 0) {
10294
- metadata.documentContext = documentContextSchema.parse({
10295
- kind: "snapshot",
10296
- docs
10297
- });
10298
- snapshotsWritten = true;
10299
- }
10300
- if (skipped > 0) deps.log(`doc snapshot: skipped ${skipped} unresolvable link(s)`);
10301
- } catch (err) {
10302
- deps.log(`doc snapshot: build failed, falling back to path variant: ${err.message}`);
10303
- }
10304
- if (!snapshotsWritten) metadata.documentContext = documentContextSchema.parse({
10305
- kind: "path",
10306
- basePath: documentBasePath
10289
+ if (documentBasePath) try {
10290
+ const { docs, skipped } = await buildMessageDocumentSnapshots(text, documentBasePath);
10291
+ if (docs.length > 0) metadata.documentContext = documentContextSchema.parse({
10292
+ kind: "snapshot",
10293
+ docs
10307
10294
  });
10295
+ if (skipped > 0) deps.log(`doc snapshot: skipped ${skipped} unresolvable link(s)`);
10296
+ } catch (err) {
10297
+ deps.log(`doc snapshot: build failed, no documentContext attached: ${err.message}`);
10308
10298
  }
10309
10299
  return Object.keys(metadata).length > 0 ? metadata : void 0;
10310
10300
  }
@@ -10398,12 +10388,32 @@ var SessionRegistry = class {
10398
10388
  }
10399
10389
  }
10400
10390
  };
10401
- function documentBasePathFromRuntimeConfig(payload) {
10402
- if (payload.gitRepos.length !== 1) return null;
10403
- const repo = payload.gitRepos[0];
10404
- if (!repo) return null;
10405
- const localPath = repoLocalPath(repo).trim();
10406
- return localPath.length > 0 ? localPath : null;
10391
+ /**
10392
+ * Resolve the base path the runtime reads markdown doc snapshots against.
10393
+ *
10394
+ * NEVER returns null — every chat has a workspace, and the snapshot scanner
10395
+ * existence-checks each candidate inside the returned root, so a bare mention
10396
+ * that doesn't physically exist simply stays plain text rather than
10397
+ * mis-resolving. Previously this returned null for zero/multi-repo
10398
+ * workspaces, which left those messages with no `documentContext` at all, so
10399
+ * a doc the agent wrote in the workspace could never be previewed.
10400
+ *
10401
+ * Resolution:
10402
+ * - exactly one repo → that repo's worktree, the unambiguous markdown-link
10403
+ * root. The worktree is materialised at `<perChatRoot>/<localPath>`, so the
10404
+ * base MUST be that ABSOLUTE path. Returning a bare relative `localPath`
10405
+ * (the old behaviour) made the runtime resolve it against its own
10406
+ * `process.cwd()` — the launch dir, not the per-chat workspace — so it
10407
+ * silently failed to find any doc and cloud preview was dead.
10408
+ * - zero or multiple repos → the per-chat workspace root.
10409
+ */
10410
+ function documentBasePathFromRuntimeConfig(payload, perChatRoot) {
10411
+ if (payload.gitRepos.length === 1) {
10412
+ const repo = payload.gitRepos[0];
10413
+ const localPath = repo ? repoLocalPath(repo).trim() : "";
10414
+ if (localPath.length > 0) return join(perChatRoot, localPath);
10415
+ }
10416
+ return perChatRoot;
10407
10417
  }
10408
10418
  function repoLocalPath(repo) {
10409
10419
  return repo.localPath ?? deriveRepoLocalPath(repo.url);
@@ -10886,7 +10896,7 @@ var SessionManager = class {
10886
10896
  this.currentTrigger.delete(chatId);
10887
10897
  },
10888
10898
  log,
10889
- getDocumentBasePath: () => this.resolveDocumentBasePath(log)
10899
+ getDocumentBasePath: () => this.resolveDocumentBasePath(log, chatId)
10890
10900
  });
10891
10901
  const envCtx = {
10892
10902
  sdk: this.config.sdk,
@@ -10914,14 +10924,15 @@ var SessionManager = class {
10914
10924
  resolveSenderLabel: async (senderId) => resolveSenderLabel(senderId, await participants.get())
10915
10925
  };
10916
10926
  }
10917
- async resolveDocumentBasePath(log) {
10918
- if (!this.config.agentConfigCache) return null;
10927
+ async resolveDocumentBasePath(log, chatId) {
10928
+ const perChatRoot = join(this.config.handlerConfig.workspaceRoot, chatId);
10929
+ if (!this.config.agentConfigCache) return perChatRoot;
10919
10930
  try {
10920
10931
  const { payload } = await this.config.agentConfigCache.refreshIfNewer(this.config.agentIdentity.agentId, 0);
10921
- return documentBasePathFromRuntimeConfig(payload);
10932
+ return documentBasePathFromRuntimeConfig(payload, perChatRoot);
10922
10933
  } catch (err) {
10923
- log(`document preview base path unavailable: ${err instanceof Error ? err.message : String(err)}`);
10924
- return null;
10934
+ log(`document preview base path: config unavailable, using workspace root: ${err instanceof Error ? err.message : String(err)}`);
10935
+ return perChatRoot;
10925
10936
  }
10926
10937
  }
10927
10938
  /** Update per-session runtime state and recompute aggregate. Only active sessions may update. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-team-foundation/first-tree-hub",
3
- "version": "0.14.9-alpha.294.1",
3
+ "version": "0.14.9-alpha.296.1",
4
4
  "type": "module",
5
5
  "description": "First Tree Hub — unified CLI for client and agent management",
6
6
  "exports": {