fix(server): ACP Registry composer lists the project's own commands and skills #34965
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -827,0 +840,21 @@840+ return { ...machineSnapshot, ...live.value, slashCommandsPending: false };841+ }842+ const { slashCommands, skills } = yield* provideAcpManagementServices(843+ probeAcpRegistryConfiguration({844+ instanceId,845+ settings: effectiveConfig,846+ cwd,847+ environment: providerProbeEnvironment(processEnvironment),848+ }),849+ ).pipe(850+ Effect.mapError(851+ (cause) =>852+ new ProviderDriverError({853+ driver: DRIVER_KIND,854+ instanceId,855+ detail: `Failed to discover ACP Registry commands for '${cwd}'.`,856+ cause,857+ }),858+ ),859+ );860+ // Agents may advertise after the probe's grace period; keep what live sessions published.@@ -176,9 +183,17 @@176183 Effect.andThen(177- PubSub.publish(availableCommandsUpdates, {178- instanceId,179- commands,184+ Ref.update(availableCommandsByWorkspace, (current) => {185+ const next = new Map(current);186+ next.delete(instanceId);187+ return next;180188 }),181189 ),182- Effect.asVoid,183190 );184191192+ const publishAvailableCommands: AcpRegistryRuntimeCoordinator["Service"]["publishAvailableCommands"] =193+ Effect.fn("AcpRegistryRuntimeCoordinator.publishAvailableCommands")(194+ function* (instanceId, available, cwd) {195+ // The cwd list is stored first: the revision below makes clients rescan that cwd.196+ if (cwd) {197+ yield* Ref.update(availableCommandsByWorkspace, (current) => {198+ const next = new Map(current);199+ next.set(instanceId, new Map(current.get(instanceId)).set(cwd, available));
- @@ -683,3 +683,4 @@683683 models: provider.models,684684 slashCommands: provider.slashCommands,685685 skills: provider.skills,686+ workspaceSnapshotsRevision: provider.workspaceSnapshotsRevision,@@ -183,2 +190,21 @@183190 );184191192+ const publishAvailableCommands: AcpRegistryRuntimeCoordinator["Service"]["publishAvailableCommands"] =193+ Effect.fn("AcpRegistryRuntimeCoordinator.publishAvailableCommands")(194+ function* (instanceId, available, cwd) {195+ // The cwd list is stored first: the revision below makes clients rescan that cwd.196+ if (cwd) {197+ yield* Ref.update(availableCommandsByWorkspace, (current) => {198+ const next = new Map(current);199+ next.set(instanceId, new Map(current.get(instanceId)).set(cwd, available));200+ return next;201+ });202+ }203+ const revision = yield* Ref.updateAndGet(availableCommandsRevision, (value) => value + 1);204+ const commands = { ...available, revision };205+ yield* Ref.update(availableCommandsByInstance, (current) => {206+ const next = new Map(current);207+ next.set(instanceId, commands);208+ return next;209+ });210+ yield* PubSub.publish(availableCommandsUpdates, { instanceId, commands });@@ -827,0 +841,21 @@841+ }842+ const { slashCommands, skills } = yield* provideAcpManagementServices(843+ probeAcpRegistryConfiguration({844+ instanceId,845+ settings: effectiveConfig,846+ cwd,847+ environment: providerProbeEnvironment(processEnvironment),848+ }),849+ ).pipe(850+ Effect.mapError(851+ (cause) =>852+ new ProviderDriverError({853+ driver: DRIVER_KIND,854+ instanceId,855+ detail: `Failed to discover ACP Registry commands for '${cwd}'.`,856+ cause,857+ }),858+ ),859+ );860+ // Agents may advertise after the probe's grace period; keep what live sessions published.861+ if (slashCommands.length === 0 && skills.length === 0) return machineSnapshot;@@ -6352,5 +6354,6 @@63526354 );63536355 if (notification.update.sessionUpdate === "available_commands_update") {63546356 yield* (6355- flavor.onAvailableCommandsUpdate?.(notification.update.availableCommands) ??6356- Effect.void6357+ flavor.onAvailableCommandsUpdate?.(6358+ notification.update.availableCommands,6359+ input.runtimePolicy.cwd,
tanstack-source added labelsbug
juliusmarminge added labelstakeover:in-progress
- @@ -697,3 +732,5 @@697732 );698733 }),699734 );735+736+ it.effect("advertises a workspace's project commands and skills for that workspace", () =>@@ -862,3 +865,13 @@862865 ...snapshot,863866 refresh: snapshot.refresh.pipe(Effect.tap(() => controller.refreshMethods ?? Effect.void)),864867 },868+ snapshotForCwd: Effect.fn("AcpRegistryDriver.snapshotForCwd")(function* (cwd: string) {869+ const machineSnapshot = yield* snapshot.getSnapshot;870+ if (!effectiveConfig.enabled) return machineSnapshot;871+ // Agents advertise project-scoped commands for a session's cwd; a live session there wins,872+ // even with an empty list.873+ const live = Option.isSome(runtimeCoordinator)874+ ? yield* runtimeCoordinator.value.getAvailableCommandsForCwd(instanceId, cwd)875+ : Option.none();876+ if (Option.isSome(live)) {877+ return { ...machineSnapshot, ...live.value, slashCommandsPending: false };@@ -862,3 +865,15 @@862865 ...snapshot,863866 refresh: snapshot.refresh.pipe(Effect.tap(() => controller.refreshMethods ?? Effect.void)),864867 },868+ snapshotForCwd: Effect.fn("AcpRegistryDriver.snapshotForCwd")(function* (cwd: string) {869+ const machineSnapshot = yield* snapshot.getSnapshot;870+ if (!effectiveConfig.enabled) return machineSnapshot;871+ // Agents advertise project-scoped commands for a session's cwd; a live session there wins,872+ // even with an empty list.873+ const live = Option.isSome(runtimeCoordinator)874+ ? yield* runtimeCoordinator.value.getAvailableCommandsForCwd(instanceId, cwd)875+ : Option.none();876+ if (Option.isSome(live)) {877+ return { ...machineSnapshot, ...live.value, slashCommandsPending: false };878+ }879+ const { slashCommands, skills } = yield* provideAcpManagementServices(
juliusmarminge added labelstakeover:ready
juliusmarminge removed labelstakeover:in-progress
juliusmarminge added labelstakeover:needs-julius
juliusmarminge removed labelstakeover:ready
juliusmarminge closed this
Sign in to join this conversation.
















macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed