replicas-engine 0.1.408 → 0.1.409

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 (2) hide show
  1. package/dist/src/index.js +110 -31
  2. package/package.json +1 -1
package/dist/src/index.js CHANGED
@@ -479,7 +479,7 @@ var WORKSPACE_SIZES = ["small", "large"];
479
479
  var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
480
480
 
481
481
  // ../shared/src/e2b.ts
482
- var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-08-v3";
482
+ var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-08-v4";
483
483
 
484
484
  // ../shared/src/runtime-env.ts
485
485
  function parsePosixEnvFile(content) {
@@ -6802,6 +6802,8 @@ var COMMAND_PROTECTION_SAFE_TOOLS = /* @__PURE__ */ new Set([
6802
6802
  "LS"
6803
6803
  ]);
6804
6804
  var CLAUDE_PARTIAL_MESSAGE_FLUSH_MS = 80;
6805
+ var CLAUDE_SLASH_COMMANDS_CACHE_MS = 6e4;
6806
+ var CLAUDE_SLASH_COMMANDS_DISCOVERY_TIMEOUT_MS = 3e4;
6805
6807
  function supportsClaudeThinkingDisplay(model) {
6806
6808
  const normalized = (normalizeClaudeModel(model) ?? model).toLowerCase();
6807
6809
  return AGENT_MODELS.claude.includes(normalized) || /^claude-(?:opus|sonnet|haiku)-[4-9]/.test(normalized);
@@ -6952,6 +6954,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
6952
6954
  /** Active tool-input requests keyed by requestId; resolved when the user selects an option. */
6953
6955
  pendingToolInputs = /* @__PURE__ */ new Map();
6954
6956
  supportedSlashCommands = [];
6957
+ slashCommandsDiscoveredAt = 0;
6958
+ slashCommandsDiscovery = null;
6955
6959
  authRetrying = false;
6956
6960
  constructor(options) {
6957
6961
  super(options);
@@ -6995,16 +6999,70 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
6995
6999
  }
6996
7000
  async listSlashCommands() {
6997
7001
  await this.initialized;
6998
- if (!this.activeQuery || this.isProcessing()) {
7002
+ if (this.activeQuery) {
7003
+ if (this.isProcessing()) {
7004
+ return this.supportedSlashCommands;
7005
+ }
7006
+ try {
7007
+ const commands = await this.activeQuery.supportedCommands();
7008
+ if (commands) {
7009
+ this.supportedSlashCommands = normalizeClaudeSlashCommands(commands);
7010
+ this.slashCommandsDiscoveredAt = Date.now();
7011
+ }
7012
+ } catch (error) {
7013
+ console.warn("[ClaudeManager] Failed to load slash commands:", error);
7014
+ }
7015
+ return this.supportedSlashCommands;
7016
+ }
7017
+ if (this.slashCommandsDiscoveredAt > 0 && Date.now() - this.slashCommandsDiscoveredAt < CLAUDE_SLASH_COMMANDS_CACHE_MS) {
6999
7018
  return this.supportedSlashCommands;
7000
7019
  }
7020
+ this.slashCommandsDiscovery ??= this.discoverSlashCommands().finally(() => {
7021
+ this.slashCommandsDiscovery = null;
7022
+ });
7023
+ return this.slashCommandsDiscovery;
7024
+ }
7025
+ /**
7026
+ * Sessions are created lazily on the first message, but the dashboard needs
7027
+ * the command list as soon as a chat opens — so with no session alive we
7028
+ * spawn a throwaway query (no prompt is ever pushed, so no model call is
7029
+ * made), read supportedCommands(), and terminate it.
7030
+ */
7031
+ async discoverSlashCommands() {
7032
+ const promptStream = new PromptStream();
7033
+ let discovery = null;
7034
+ let timeoutHandle;
7001
7035
  try {
7002
- const commands = await this.activeQuery?.supportedCommands();
7036
+ const shared = await this.buildSharedQueryOptions();
7037
+ discovery = query({
7038
+ prompt: promptStream,
7039
+ options: {
7040
+ cwd: this.workingDirectory,
7041
+ additionalDirectories: shared.additionalDirectories,
7042
+ settingSources: ["user", "project", "local"],
7043
+ ...this.mcpServersConfig ? { mcpServers: this.mcpServersConfig } : {},
7044
+ ...shared.plugins.length > 0 ? { plugins: shared.plugins } : {},
7045
+ ...shared.enableAllSkills ? { skills: "all" } : {},
7046
+ env: shared.env
7047
+ }
7048
+ });
7049
+ const timeout = new Promise((_, reject) => {
7050
+ timeoutHandle = setTimeout(
7051
+ () => reject(new Error("Slash command discovery timed out")),
7052
+ CLAUDE_SLASH_COMMANDS_DISCOVERY_TIMEOUT_MS
7053
+ );
7054
+ });
7055
+ const commands = await Promise.race([discovery.supportedCommands(), timeout]);
7003
7056
  if (commands) {
7004
7057
  this.supportedSlashCommands = normalizeClaudeSlashCommands(commands);
7005
7058
  }
7006
7059
  } catch (error) {
7007
- console.warn("[ClaudeManager] Failed to load slash commands:", error);
7060
+ console.warn("[ClaudeManager] Failed to discover slash commands:", error);
7061
+ } finally {
7062
+ this.slashCommandsDiscoveredAt = Date.now();
7063
+ clearTimeout(timeoutHandle);
7064
+ promptStream.close();
7065
+ discovery?.close();
7008
7066
  }
7009
7067
  return this.supportedSlashCommands;
7010
7068
  }
@@ -7376,6 +7434,21 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
7376
7434
  sessionSignaturesMatch(a, b) {
7377
7435
  return a.combinedInstructions === b.combinedInstructions && a.thinkingLevel === b.thinkingLevel && a.enableInteractiveTools === b.enableInteractiveTools && a.fastMode === b.fastMode;
7378
7436
  }
7437
+ /** Query inputs shared by real sessions and slash-command discovery. */
7438
+ async buildSharedQueryOptions() {
7439
+ const env = buildClaudeAgentEnv(this.envOverrides);
7440
+ const additionalDirectories = await getAgentAdditionalDirectories();
7441
+ let plugins = [];
7442
+ let enableAllSkills = false;
7443
+ try {
7444
+ const registryConfig = await buildClaudeRegistryConfig(ENGINE_ENV.HOME_DIR);
7445
+ plugins = registryConfig.plugins;
7446
+ enableAllSkills = registryConfig.enableAllSkills;
7447
+ } catch (error) {
7448
+ console.warn("[ClaudeManager] Failed to load skill registry config:", error);
7449
+ }
7450
+ return { env, additionalDirectories, plugins, enableAllSkills };
7451
+ }
7379
7452
  async startSession(args) {
7380
7453
  const {
7381
7454
  combinedInstructions,
@@ -7391,8 +7464,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
7391
7464
  preset: "claude_code",
7392
7465
  append: combinedInstructions
7393
7466
  };
7394
- const queryEnv = buildClaudeAgentEnv(this.envOverrides);
7395
- const additionalDirectories = await getAgentAdditionalDirectories();
7467
+ const shared = await this.buildSharedQueryOptions();
7396
7468
  const interactiveAllowed = enableInteractiveTools && resolvedPermissionMode === "plan";
7397
7469
  const useDefaultToolPolicy = !this.toolsOverride;
7398
7470
  const allowedTools = useDefaultToolPolicy ? [
@@ -7404,22 +7476,13 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
7404
7476
  ...useDefaultToolPolicy ? ALWAYS_DISALLOWED_TOOLS : [],
7405
7477
  ...interactiveAllowed ? [] : INTERACTIVE_TOOL_NAMES
7406
7478
  ];
7407
- let registryPlugins = [];
7408
- let enableRegistrySkills = false;
7409
- try {
7410
- const registryConfig = await buildClaudeRegistryConfig(ENGINE_ENV.HOME_DIR);
7411
- registryPlugins = registryConfig.plugins;
7412
- enableRegistrySkills = registryConfig.enableAllSkills;
7413
- } catch (error) {
7414
- console.warn("[ClaudeManager] Failed to load skill registry config:", error);
7415
- }
7416
7479
  const promptStream = new PromptStream();
7417
7480
  const response = query({
7418
7481
  prompt: promptStream,
7419
7482
  options: {
7420
7483
  resume: this.sessionId || void 0,
7421
7484
  cwd: this.workingDirectory,
7422
- additionalDirectories,
7485
+ additionalDirectories: shared.additionalDirectories,
7423
7486
  permissionMode: resolvedPermissionMode,
7424
7487
  allowDangerouslySkipPermissions: resolvedPermissionMode === "bypassPermissions",
7425
7488
  ...this.toolsOverride ? { tools: this.toolsOverride } : {},
@@ -7428,9 +7491,9 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
7428
7491
  settingSources: ["user", "project", "local"],
7429
7492
  systemPrompt,
7430
7493
  ...this.mcpServersConfig ? { mcpServers: this.mcpServersConfig } : {},
7431
- ...registryPlugins.length > 0 ? { plugins: registryPlugins } : {},
7432
- ...enableRegistrySkills ? { skills: "all" } : {},
7433
- env: queryEnv,
7494
+ ...shared.plugins.length > 0 ? { plugins: shared.plugins } : {},
7495
+ ...shared.enableAllSkills ? { skills: "all" } : {},
7496
+ env: shared.env,
7434
7497
  model: claudeCodeModel,
7435
7498
  settings: { fastMode: signature.fastMode },
7436
7499
  includePartialMessages: true,
@@ -7458,6 +7521,11 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
7458
7521
  this.sessionLoop = this.runSessionLoop(response).catch((err) => {
7459
7522
  console.error("[ClaudeManager] Session loop crashed:", err);
7460
7523
  });
7524
+ void response.supportedCommands().then((commands) => {
7525
+ this.supportedSlashCommands = normalizeClaudeSlashCommands(commands);
7526
+ this.slashCommandsDiscoveredAt = Date.now();
7527
+ }).catch(() => {
7528
+ });
7461
7529
  }
7462
7530
  async runSessionLoop(response) {
7463
7531
  const linearSessionId = ENGINE_ENV.LINEAR_SESSION_ID;
@@ -7791,6 +7859,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
7791
7859
  }
7792
7860
  if (message.type === "system" && message.subtype === "commands_changed") {
7793
7861
  this.supportedSlashCommands = normalizeClaudeSlashCommands(message.commands);
7862
+ this.slashCommandsDiscoveredAt = Date.now();
7794
7863
  }
7795
7864
  this.trackNativeCompaction(message);
7796
7865
  await this.recordEvent(message);
@@ -8018,7 +8087,7 @@ var AspClient = class {
8018
8087
  // src/managers/codex-asp/app-server-process.ts
8019
8088
  var DEFAULT_CODEX_BINARY = "codex";
8020
8089
  var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
8021
- var ENGINE_PACKAGE_VERSION = "0.1.408";
8090
+ var ENGINE_PACKAGE_VERSION = "0.1.409";
8022
8091
  var INITIALIZE_METHOD = "initialize";
8023
8092
  var INITIALIZED_NOTIFICATION = "initialized";
8024
8093
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -10192,9 +10261,10 @@ var CursorManager = class extends CodingAgentManager {
10192
10261
  }
10193
10262
  this.slashCommandsRequest ??= (async () => {
10194
10263
  try {
10264
+ const repoDirectories = await getAgentAdditionalDirectories();
10265
+ const commandDirectories = [this.workingDirectory, ...repoDirectories, ENGINE_ENV.HOME_DIR].map((directory) => join17(directory, ".cursor", "commands"));
10195
10266
  const commands = mergeSlashCommands(
10196
- await listCursorCommandsInDirectory(join17(this.workingDirectory, ".cursor", "commands")),
10197
- await listCursorCommandsInDirectory(join17(ENGINE_ENV.HOME_DIR, ".cursor", "commands"))
10267
+ ...await Promise.all(commandDirectories.map(listCursorCommandsInDirectory))
10198
10268
  );
10199
10269
  this.slashCommandsCache = { commands, expiresAt: Date.now() + CURSOR_SLASH_COMMANDS_CACHE_MS };
10200
10270
  return commands;
@@ -10546,15 +10616,24 @@ var OpencodeManager = class extends CodingAgentManager {
10546
10616
  this.slashCommandsRequest ??= (async () => {
10547
10617
  try {
10548
10618
  const client = await this.ensureClient(DEFAULT_OPENCODE_MODEL);
10549
- const location = { directory: this.workingDirectory };
10550
- const [commandResponse, skillResponse] = await Promise.all([
10551
- client.v2.command.list({ location }, { throwOnError: true }),
10552
- client.v2.skill.list({ location }, { throwOnError: true })
10553
- ]);
10554
- const commands = mergeSlashCommands(
10555
- opencodeCommandListToSlashCommands(commandResponse.data),
10556
- opencodeSkillListToSlashCommands(skillResponse.data)
10557
- );
10619
+ const directories = [this.workingDirectory, ...await getAgentAdditionalDirectories()];
10620
+ const perDirectory = await Promise.all(directories.map(async (directory) => {
10621
+ try {
10622
+ const location = { directory };
10623
+ const [commandResponse, skillResponse] = await Promise.all([
10624
+ client.v2.command.list({ location }, { throwOnError: true }),
10625
+ client.v2.skill.list({ location }, { throwOnError: true })
10626
+ ]);
10627
+ return mergeSlashCommands(
10628
+ opencodeCommandListToSlashCommands(commandResponse.data),
10629
+ opencodeSkillListToSlashCommands(skillResponse.data)
10630
+ );
10631
+ } catch (error) {
10632
+ console.warn("[OpencodeManager] Failed to load slash commands for directory:", directory, error);
10633
+ return [];
10634
+ }
10635
+ }));
10636
+ const commands = mergeSlashCommands(...perDirectory);
10558
10637
  this.slashCommandsCache = { commands, expiresAt: Date.now() + OPENCODE_SLASH_COMMANDS_CACHE_MS };
10559
10638
  return commands;
10560
10639
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.408",
3
+ "version": "0.1.409",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",