@sparkelf/dsh-knowledge-base 0.6.10 → 0.6.12

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.
Files changed (3) hide show
  1. package/lib/client.js +638 -638
  2. package/lib/index.js +28 -17
  3. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -28445,28 +28445,30 @@ function apply(ctx, deploymentConfig) {
28445
28445
  })]),
28446
28446
  source: Object.freeze({ kind: "user" })
28447
28447
  });
28448
- const guardianWorkspaceRegistry = ctx.workspaceRegistry;
28449
- const guardianCwd = guardianWorkspaceRegistry?.list()[0]?.path ?? process.cwd();
28450
- const guardianPersistence = ctx.sessionPersistence;
28448
+ const getGuardianWorkspaceRegistry = () => ctx.get("workspaceRegistry");
28449
+ const resolveGuardianCwd = () => getGuardianWorkspaceRegistry()?.list()[0]?.path ?? process.cwd();
28450
+ const guardianPersistence = ctx.get("sessionPersistence");
28451
28451
  const attachGuardianToWorkspace = async (agent) => {
28452
- if (guardianWorkspaceRegistry === void 0) return;
28452
+ const registry = getGuardianWorkspaceRegistry();
28453
+ if (registry === void 0) return;
28453
28454
  const sessionId = agent.session?.id ?? agent.id;
28455
+ const cwd = resolveGuardianCwd();
28454
28456
  try {
28455
- await (await guardianWorkspaceRegistry.resolveByPath(guardianCwd))?.attachSession(sessionId);
28457
+ await (await registry.resolveByPath(cwd))?.attachSession(sessionId);
28456
28458
  } catch (error) {
28457
- ctx.logger.warn(`knowledge-base: guardian ${sessionId} did not join workspace at ${guardianCwd}: ${String(error)}`);
28459
+ ctx.logger.warn(`knowledge-base: guardian ${sessionId} did not join workspace at ${cwd}: ${String(error)}`);
28458
28460
  }
28459
28461
  };
28460
28462
  const guardianSessionHost = {
28461
28463
  usersRoot: memoryUsersRoot,
28462
- cwd: guardianCwd,
28464
+ cwd: process.cwd(),
28463
28465
  timeoutMs: DEFAULT_GUARDIAN_TIMEOUT_MS,
28464
28466
  getAgent: (sessionId) => guardianRegistry?.get(sessionId),
28465
28467
  createAgent: async ({ sessionId, title }) => {
28466
28468
  if (guardianLoop === void 0) throw new Error("the DSH agent loop is not available");
28467
28469
  const handle = await guardianLoop.createAgent(ctx, {
28468
28470
  sessionId,
28469
- meta: { cwd: guardianCwd },
28471
+ meta: { cwd: resolveGuardianCwd() },
28470
28472
  ...guardianAgentOptions === void 0 ? {} : { agentOptions: guardianAgentOptions }
28471
28473
  });
28472
28474
  try {
@@ -28490,7 +28492,8 @@ function apply(ctx, deploymentConfig) {
28490
28492
  } catch {
28491
28493
  persistedCwd = void 0;
28492
28494
  }
28493
- if (persistedCwd !== void 0 && persistedCwd !== guardianCwd) throw new Error(`guardian ${sessionId} cwd ${persistedCwd} differs from workspace ${guardianCwd}; recreating`);
28495
+ const targetCwd = resolveGuardianCwd();
28496
+ if (persistedCwd !== void 0 && persistedCwd !== targetCwd) throw new Error(`guardian ${sessionId} cwd ${persistedCwd} differs from workspace ${targetCwd}; recreating`);
28494
28497
  }
28495
28498
  const handle = await guardianLoop.resume(ctx, {
28496
28499
  resumeSessionId: sessionId,
@@ -28511,14 +28514,22 @@ function apply(ctx, deploymentConfig) {
28511
28514
  };
28512
28515
  const guardianSessions = new GuardianSessionStore(memoryUsersRoot);
28513
28516
  ctx.provide("memoryGuardianSessions", { listSessionIds: () => guardianSessions.listSessionIds() });
28514
- if (!isTeamDeployment(config)) (async () => {
28515
- try {
28516
- if (!await memorySettings.isEnabled("local")) return;
28517
- await resolveOrCreateGuardian(guardianSessionHost, LOCAL_USER_ID);
28518
- } catch (error) {
28519
- host.logger?.warn?.(`knowledge-base: eager guardian creation failed: ${String(error)}`);
28520
- }
28521
- })();
28517
+ if (!isTeamDeployment(config)) {
28518
+ const eagerGuardian = async (attempt) => {
28519
+ try {
28520
+ if (!await memorySettings.isEnabled("local")) return;
28521
+ await resolveOrCreateGuardian(guardianSessionHost, LOCAL_USER_ID);
28522
+ } catch (error) {
28523
+ if (attempt < 15) setTimeout(() => {
28524
+ eagerGuardian(attempt + 1);
28525
+ }, 2e3);
28526
+ else host.logger?.warn?.(`knowledge-base: eager guardian creation failed after retries: ${String(error)}`);
28527
+ }
28528
+ };
28529
+ setTimeout(() => {
28530
+ eagerGuardian(0);
28531
+ }, 3e3);
28532
+ }
28522
28533
  const memoryGuardianToolHost = {
28523
28534
  resolveCaller: async () => {
28524
28535
  return { userId: (await fetchCaller(host, config)).userId };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkelf/dsh-knowledge-base",
3
- "version": "0.6.10",
3
+ "version": "0.6.12",
4
4
  "description": "DataOps-backed knowledge base for DeepSeek Harness: a left-sidebar destination, Settings configuration, and index tooling over a mounted NAS view.",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",