The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 11:00 UTC
fix(acp): show local agent reported version (#37229)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
DrStrangerUJN committed
Nov 16, 2026 at 00:07 UTC
aee231133ae40483bc6f6df2abcec236d251164e
4 files changed
+138
-4
packages/contracts/src/acpRegistry.ts
+1
@@ -278,6 +278,7 @@ export const AcpRegistryProbeResult = Schema.Struct({
278
// `ready` requires a disposable ACP session/new probe, not passive auth detection.
279
ready: Schema.Literal(true),
280
icon: Schema.NullOr(AcpRegistryUrl),
281
+ agentVersion: Schema.optionalKey(AcpRegistryProbeText),
282
authMethods: Schema.Array(AcpRegistryProbeAuthMethod).check(Schema.isMaxLength(32)),
283
models: Schema.Array(AcpRegistryProbeModel).check(Schema.isMaxLength(256)),
284
currentModelId: Schema.NullOr(AcpRegistryProbeText),
packages/provider-acp-registry/src/server/driver.test.ts
+98
-1
@@ -29,10 +29,12 @@ import {
29
buildCheckedAcpRegistrySnapshot,
30
checkAcpRegistryProviderReadiness,
31
checkAcpRegistryProviderStatus,
32
+ isAcpRegistryCacheValid,
33
updateAcpRegistryEnrichmentCache,
34
} from "./driver.ts";
35
import {
36
acpRegistryAdvertisesModelCatalog,
37
+ acpRegistryProbeResult,
38
normalizeAcpRegistryLiveConfiguration,
39
} from "./probe.ts";
40
@@ -100,6 +102,41 @@ function providerWithModels(
102
}
103
104
describe("acpRegistrySnapshotReadiness", () => {
105
+ it("shows the version reported by a local ACP agent", () => {
106
+ const probe = acpRegistryProbeResult(identity.instanceId, {
107
+ sessionId: "test-session",
108
+ initializeResult: {
109
+ protocolVersion: 1,
110
+ agentInfo: { name: "Example agent", version: "1.5.9" },
111
+ },
112
+ sessionSetupResult: {},
113
+ modelConfigId: undefined,
114
+ });
115
+ const snapshot = buildCheckedAcpRegistrySnapshot({
116
+ ...identity,
117
+ settings: decodeSettings({ source: "local", commandPath: "example" }),
118
+ checkedAt: "2026-08-13T10:00:00.000Z",
119
+ inspection: { status: "ready", agentId: "example", version: null, distribution: "local" },
120
+ probe: { probe, slashCommands: [], skills: [] },
121
+ });
122
+ expect(snapshot.version).toBe("1.5.9");
123
+ const withoutVersion = acpRegistryProbeResult(identity.instanceId, {
124
+ sessionId: "test-session",
125
+ initializeResult: { protocolVersion: 1 },
126
+ sessionSetupResult: {},
127
+ modelConfigId: undefined,
128
+ });
129
+ expect(
130
+ buildCheckedAcpRegistrySnapshot({
131
+ ...identity,
132
+ settings: decodeSettings({ source: "local", commandPath: "example" }),
133
+ checkedAt: "2026-08-13T10:00:00.000Z",
134
+ inspection: { status: "ready", agentId: "example", version: null, distribution: "local" },
135
+ probe: { probe: withoutVersion, slashCommands: [], skills: [] },
136
+ }).version,
137
+ ).toBeNull();
138
+ });
139
+
140
it("treats a live empty command advertisement as an authoritative replacement", () => {
141
const provider = buildCheckedAcpRegistrySnapshot({
142
...identity,
@@ -657,6 +694,13 @@ describe("acpRegistrySnapshotReadiness", () => {
694
});
695
696
describe("acpRegistryEnrichmentCache", () => {
697
+ it("reuses a local probe until expiry even when inspection has no version", () => {
698
+ const entry = { provider: providerWithModels([], null), expiresAt: 1_000 };
699
+ expect(isAcpRegistryCacheValid(entry, null, true, 999)).toBe(true);
700
+ expect(isAcpRegistryCacheValid(entry, null, true, 1_000)).toBe(false);
701
+ expect(isAcpRegistryCacheValid(entry, "2.0.0", false, 999)).toBe(false);
702
+ expect(isAcpRegistryCacheValid(entry, "1.0.0", false, 999)).toBe(true);
703
+ });
704
const settledConfiguration = {
705
models: [
706
{ id: "auto", name: "Auto", description: null },
@@ -773,7 +817,10 @@ createInterface({ input: process.stdin }).on("line", (line) => {
817
const { id, method } = JSON.parse(line);
818
if (id === undefined) return;
819
if (method === "initialize") {
776
- send({ id, result: { protocolVersion: 1, agentCapabilities: {}, authMethods: [] } });
820
+ send({
821
+ id,
822
+ result: { protocolVersion: 1, agentCapabilities: {}, authMethods: [], agentInfo: { name: "fake", version: "1.5.9" } },
823
+ });
824
} else if (method === "session/new") {
825
const modelIds = JSON.parse(readFileSync(process.argv[2], "utf8"));
826
send({
@@ -880,6 +927,56 @@ it.layer(driverLayer, { excludeTestServices: true })("AcpRegistryDriver", (it) =
927
}),
928
);
929
930
+ it.effect("keeps a local agent's reported version through the next readiness check", () =>
931
+ Effect.gen(function* () {
932
+ const fileSystem = yield* FileSystem.FileSystem;
933
+ const path = yield* Path.Path;
934
+ const directory = yield* fileSystem.makeTempDirectoryScoped({ prefix: "acp-driver-" });
935
+ const agentPath = path.join(directory, "agent.mjs");
936
+ const modelsPath = path.join(directory, "models.json");
937
+ yield* fileSystem.writeFileString(agentPath, fakeAgentSource);
938
+ yield* fileSystem.writeFileString(modelsPath, JSON.stringify(["model-a"]));
939
+
940
+ const instance = yield* AcpRegistryDriver.create({
941
+ instanceId: identity.instanceId,
942
+ displayName: identity.displayName,
943
+ enabled: true,
944
+ environment: [],
945
+ config: decodeSettings({ source: "local", commandPath: "agent" }),
946
+ }).pipe(
947
+ Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, {
948
+ ...catalogWithInspection({
949
+ status: "ready",
950
+ agentId: "agent",
951
+ version: null,
952
+ distribution: "local",
953
+ }),
954
+ resolve: () =>
955
+ Effect.succeed({
956
+ distribution: "local" as const,
957
+ spawn: { command: process.execPath, args: [agentPath, modelsPath] },
958
+ }),
959
+ }),
960
+ );
961
+ const probed = yield* instance.snapshot.streamChanges.pipe(
962
+ Stream.filter((snapshot) => snapshot.version === "1.5.9"),
963
+ Stream.runHead,
964
+ Effect.forkScoped({ startImmediately: true }),
965
+ );
966
+ yield* instance.snapshot.refresh;
967
+ yield* Fiber.join(probed);
968
+
969
+ const nextPublished = yield* instance.snapshot.streamChanges.pipe(
970
+ Stream.runHead,
971
+ Effect.forkScoped({ startImmediately: true }),
972
+ );
973
+ yield* instance.invalidateCaches ?? Effect.void;
974
+ yield* instance.snapshot.refresh;
975
+ const next = yield* Fiber.join(nextPublished);
976
+ expect(Option.map(next, (snapshot) => snapshot.version)).toEqual(Option.some("1.5.9"));
977
+ }),
978
+ );
979
+
980
it.effect("keeps options learned for each model across a refresh", () =>
981
Effect.gen(function* () {
982
const fileSystem = yield* FileSystem.FileSystem;
packages/provider-acp-registry/src/server/driver.ts
+36
-3
@@ -82,6 +82,18 @@ interface AcpRegistryEnrichmentCache {
82
} | null;
83
}
84
85
+export function isAcpRegistryCacheValid(
86
+ entry: NonNullable<AcpRegistryEnrichmentCache["entry"]>,
87
+ inspectedVersion: string | null,
88
+ local: boolean,
89
+ now: number,
90
+): boolean {
91
+ return (
92
+ entry.expiresAt > now &&
93
+ ((local && inspectedVersion === null) || entry.provider.version === inspectedVersion)
94
+ );
95
+}
96
+
97
export function updateAcpRegistryEnrichmentCache(input: {
98
readonly cache: AcpRegistryEnrichmentCache;
99
readonly configuration: AcpRegistryLiveConfiguration;
@@ -466,7 +478,10 @@ export function buildCheckedAcpRegistrySnapshot(
478
? { documentationUrl: input.inspection.documentationUrl }
479
: {}),
480
installed: readiness.installed,
469
- version: readiness.version,
481
+ version:
482
+ input.settings.source === "local"
483
+ ? (input.probe?.probe.agentVersion ?? readiness.version)
484
+ : readiness.version,
485
// Failed discovery is a warning: an installed agent may still run real turns.
486
status: probeFailed ? "warning" : readiness.status,
487
auth: input.probe
@@ -716,8 +731,19 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
731
}),
732
);
733
});
734
+ // A local executable's version comes only from probing it, so readiness checks reuse the last report.
735
+ const reportedLocalVersion = yield* Ref.make<string | null>(null);
736
const checkProvider = checkAcpRegistryProviderReadiness(readinessInput).pipe(
737
Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog),
738
+ Effect.flatMap((provider) =>
739
+ Ref.get(reportedLocalVersion).pipe(
740
+ Effect.map((version) =>
741
+ provider.installed && provider.version === null && version !== null
742
+ ? { ...provider, version }
743
+ : provider,
744
+ ),
745
+ ),
746
+ ),
747
Effect.flatMap(withLiveRuntimeState),
748
);
749
const enrichProvider = checkAcpRegistryProviderStatus(
@@ -748,8 +774,12 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
774
const cached = cacheState.entry;
775
if (
776
cached !== null &&
751
- cached.expiresAt > now &&
752
- cached.provider.version === baseSnapshot.version
777
+ isAcpRegistryCacheValid(
778
+ cached,
779
+ baseSnapshot.version,
780
+ effectiveConfig.source === "local",
781
+ now,
782
+ )
783
) {
784
return {
785
provider: { ...cached.provider, checkedAt: baseSnapshot.checkedAt },
@@ -757,6 +787,9 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
787
};
788
}
789
const enriched = yield* enrichProvider;
790
+ if (effectiveConfig.source === "local" && enriched.status === "ready") {
791
+ yield* Ref.set(reportedLocalVersion, enriched.version);
792
+ }
793
if (enriched.status === "ready") {
794
const completedAt = yield* Clock.currentTimeMillis;
795
yield* Ref.update(enrichmentCache, (current) =>
packages/provider-acp-registry/src/server/probe.ts
+3
@@ -330,6 +330,9 @@ export function acpRegistryProbeResult(
330
instanceId,
331
ready: true,
332
icon,
333
+ ...(started.initializeResult.agentInfo?.version?.trim()
334
+ ? { agentVersion: boundedText(started.initializeResult.agentInfo.version, MAX_ID_LENGTH) }
335
+ : {}),
336
authMethods: normalizeAcpRegistryAuthMethods(started.initializeResult.authMethods, spawn),
337
sessionManagement: {
338
canList: started.initializeResult.agentCapabilities?.sessionCapabilities?.list != null,