Skip to content
This repository was archived by the owner on Oct 21, 2026. It is now read-only.

Commit 8b7ee7f

Browse files
committed
Merge upstream/main into main
2 parents a5e0d44 + 3e6b450 commit 8b7ee7f

28 files changed

Lines changed: 1003 additions & 251 deletions

‎apps/server/src/git/GitManager.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import {
3535
type SourceControlProviderKind,
3636
type SourceControlWritingStyleSettings,
3737
type ThreadId,
38+
type VcsCreateWorktreeInput,
39+
type VcsCreateWorktreeResult,
3840
} from "@t3tools/contracts";
3941
import {
4042
hasProjectSettingsOverrides,
@@ -103,6 +105,10 @@ interface SourceControlTextGenerationSettings {
103105
export class GitManager extends Context.Service<
104106
GitManager,
105107
{
108+
readonly createWorktree: (
109+
input: VcsCreateWorktreeInput,
110+
options?: GitVcsDriver.CreateWorktreeOptions,
111+
) => Effect.Effect<VcsCreateWorktreeResult, GitCommandError>;
106112
readonly status: (
107113
input: VcsStatusInput,
108114
) => Effect.Effect<VcsStatusResult, GitManagerServiceError>;
@@ -727,6 +733,19 @@ export const make = Effect.gen(function* () {
727733
);
728734
return resolveProjectSettings(settings, projectId).settings;
729735
});
736+
const createWorktree: GitManager["Service"]["createWorktree"] = Effect.fn(
737+
"GitManager.createWorktree",
738+
)(function* (input, options) {
739+
const submodules =
740+
options?.submodules !== undefined
741+
? options.submodules
742+
: yield* projectSettingsFor(input).pipe(
743+
Effect.map((settings) => settings.worktreeSubmodules),
744+
Effect.orElseSucceed(() => null),
745+
);
746+
return yield* gitCore.createWorktree(input, { ...options, submodules });
747+
});
748+
730749
const readRepositoryInstructions = (cwd: string, fileName: string) =>
731750
Effect.gen(function* () {
732751
const root = yield* fileSystem.realPath(cwd);
@@ -2858,6 +2877,7 @@ export const make = Effect.gen(function* () {
28582877
);
28592878

28602879
return GitManager.of({
2880+
createWorktree,
28612881
localStatus,
28622882
remoteStatus,
28632883
status,

‎apps/server/src/git/GitWorkflowService.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ export const make = Effect.gen(function* () {
360360
),
361361
createWorktree: (input, options) =>
362362
ensureGitCommand("GitWorkflowService.createWorktree", input.cwd).pipe(
363-
Effect.andThen(git.createWorktree(input, options)),
363+
Effect.andThen(gitManager.createWorktree(input, options)),
364364
),
365365
listLocalBranchNames: (cwd) =>
366366
ensureGitCommand("GitWorkflowService.listLocalBranchNames", cwd).pipe(

‎apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ChildProcessSpawner } from "effect/unstable/process";
1515
import * as EffectAcpErrors from "effect-acp/errors";
1616

1717
import * as ServerConfig from "../../config.ts";
18+
import * as ServerSettings from "../../serverSettings.ts";
1819
import type {
1920
AcpRegistryAvailableCommands,
2021
AcpRegistryLiveConfiguration,
@@ -87,6 +88,7 @@ const testLayer = Layer.mergeAll(
8788
IdAllocator.layer,
8889
serverConfigLayer,
8990
registryLayer,
91+
ServerSettings.layerTest(),
9092
);
9193

9294
describe("AcpRegistryAdapterV2", () => {
@@ -121,6 +123,8 @@ describe("AcpRegistryAdapterV2", () => {
121123
assert.isTrue(BUILT_IN_PROVIDER_ADAPTER_DRIVER_KINDS_V2.has(ACP_REGISTRY_PROVIDER));
122124
assert.equal(AcpRegistryAdapterV2Driver.driverKind, ACP_REGISTRY_PROVIDER);
123125
assert.deepEqual(AcpRegistryAdapterV2Driver.defaultConfig(), {
126+
source: "registry",
127+
commandArgs: [],
124128
enabled: true,
125129
agentId: "",
126130
commandPath: "",

‎apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,17 @@ function makeAcpRegistryRuntime(options: AcpRegistryAdapterV2Options) {
183183

184184
export function makeAcpRegistryAdapterV2(options: AcpRegistryAdapterV2Options) {
185185
const runtimeCoordinator = options.runtimeCoordinator;
186-
const isDevin = options.settings.agentId === "devin";
186+
const registryAgentId = options.settings.source === "local" ? "" : options.settings.agentId;
187+
const startupKey =
188+
options.settings.source === "local" ? `local:${options.instanceId}` : registryAgentId;
189+
const isDevin = registryAgentId === "devin";
187190
const flavor: AcpAdapterV2Flavor = {
188191
driver: ACP_REGISTRY_PROVIDER,
189192
capabilities: AcpProviderCapabilitiesV2,
190-
promptFailure: (cause) => acpRegistryPromptFailure(options.settings.agentId, cause),
193+
promptFailure: (cause) => acpRegistryPromptFailure(registryAgentId, cause),
191194
// Per-agent exceptions (Mistral Vibe, Devin): see the note above
192195
// registerMistralVibeAcpExtensions before adding any more.
193-
...(options.settings.agentId === "mistral-vibe"
196+
...(registryAgentId === "mistral-vibe"
194197
? { registerExtensions: registerMistralVibeAcpExtensions }
195198
: {}),
196199
...(isDevin
@@ -230,7 +233,7 @@ export function makeAcpRegistryAdapterV2(options: AcpRegistryAdapterV2Options) {
230233
});
231234
},
232235
withRuntimeStartup: <A, E, R>(effect: Effect.Effect<A, E, R>) =>
233-
runtimeCoordinator.withForegroundStartup(options.settings.agentId, effect),
236+
runtimeCoordinator.withForegroundStartup(startupKey, effect),
234237
}),
235238
...(options.assertComplete === undefined ? {} : { assertComplete: options.assertComplete }),
236239
};

‎apps/server/src/provider/Drivers/AcpRegistryDriver.test.ts‎

Lines changed: 63 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,19 @@ describe("acpRegistrySnapshotReadiness", () => {
201201
}),
202202
).toMatchObject({ installed: false, version: "1.2.3", status: "error" });
203203

204+
expect(
205+
acpRegistrySnapshotReadiness({
206+
status: "missing_runner",
207+
version: null,
208+
distribution: "local",
209+
}),
210+
).toEqual({
211+
installed: false,
212+
version: null,
213+
status: "error",
214+
message: "Local ACP executable is not available on this environment's PATH.",
215+
});
216+
204217
expect(
205218
acpRegistrySnapshotReadiness({
206219
status: "unprepared",
@@ -312,49 +325,57 @@ describe("acpRegistrySnapshotReadiness", () => {
312325
expect(snapshot.models[0]?.isDefault).toBe(true);
313326
});
314327

315-
it("reports failed authentication without hiding successful local inspection", () => {
316-
const snapshot = buildCheckedAcpRegistrySnapshot({
317-
...identity,
318-
settings: decodeSettings({ agentId: "test-agent", authMethodId: "grok-login" }),
319-
checkedAt: "2026-08-13T10:00:00.000Z",
320-
inspection: {
321-
status: "ready",
322-
agentId: "test-agent",
323-
version: "1.0.0",
324-
distribution: "binary",
325-
},
326-
probeError: new AcpRegistryOperationError({
327-
reason: "authentication_failed",
328-
message: "Login required.",
329-
authMethods: [
330-
{
331-
id: "api-key",
332-
name: "API key",
333-
description: null,
334-
type: "env_var",
335-
},
336-
{
337-
id: "grok-login",
338-
name: "Log in with Grok",
339-
description: null,
340-
type: "agent",
341-
},
342-
],
343-
}),
344-
});
328+
it.each(["registry", "local"] as const)(
329+
"reports failed authentication after successful %s inspection",
330+
(source) => {
331+
const snapshot = buildCheckedAcpRegistrySnapshot({
332+
...identity,
333+
settings: decodeSettings({
334+
source,
335+
...(source === "local" ? { commandPath: "test-agent" } : { agentId: "test-agent" }),
336+
authMethodId: "grok-login",
337+
}),
338+
checkedAt: "2026-08-13T10:00:00.000Z",
339+
inspection: {
340+
status: "ready",
341+
agentId: "test-agent",
342+
version: source === "local" ? null : "1.0.0",
343+
distribution: source === "local" ? "local" : "binary",
344+
},
345+
probeError: new AcpRegistryOperationError({
346+
reason: "authentication_failed",
347+
message: "Login required.",
348+
authMethods: [
349+
{
350+
id: "api-key",
351+
name: "API key",
352+
description: null,
353+
type: "env_var",
354+
},
355+
{
356+
id: "grok-login",
357+
name: "Log in with Grok",
358+
description: null,
359+
type: "agent",
360+
},
361+
],
362+
}),
363+
});
345364

346-
expect(snapshot).toMatchObject({
347-
installed: true,
348-
version: "1.0.0",
349-
status: "warning",
350-
auth: {
351-
status: "unauthenticated",
352-
type: "agent",
353-
label: "Log in with Grok",
354-
},
355-
message: 'Sign in in provider settings using "Log in with Grok".',
356-
});
357-
});
365+
expect(snapshot).toMatchObject({
366+
installed: true,
367+
version: source === "local" ? null : "1.0.0",
368+
status: "warning",
369+
setup: { canAuthenticate: true },
370+
auth: {
371+
status: "unauthenticated",
372+
type: "agent",
373+
label: "Log in with Grok",
374+
},
375+
message: 'Sign in in provider settings using "Log in with Grok".',
376+
});
377+
},
378+
);
358379

359380
it.effect("runs the disposable probe only after local inspection is ready", () =>
360381
Effect.gen(function* () {

‎apps/server/src/provider/Drivers/AcpRegistryDriver.ts‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ export function acpRegistrySnapshotReadiness(
140140
installed: false,
141141
version: null,
142142
status: "warning",
143-
message: "Select an ACP Registry agent before starting a thread.",
143+
message:
144+
"Select an ACP Registry agent or configure a local ACP executable before starting a thread.",
144145
};
145146
case "not_found":
146147
return {
@@ -161,7 +162,10 @@ export function acpRegistrySnapshotReadiness(
161162
installed: false,
162163
version: inspection.version,
163164
status: "error",
164-
message: `ACP Registry agent '${inspection.agentId}' requires '${inspection.runner}' on this environment's PATH.`,
165+
message:
166+
inspection.distribution === "local"
167+
? "Local ACP executable is not available on this environment's PATH."
168+
: `ACP executable '${inspection.runner}' is not available on this environment's PATH.`,
165169
};
166170
case "unprepared":
167171
return {
@@ -198,11 +202,14 @@ function baseSnapshot(
198202
readonly documentationUrl?: string;
199203
readonly message?: string;
200204
readonly probe?: AcpRegistryConfigurationProbeResult;
205+
readonly probeError?: AcpRegistryOperationError;
201206
},
202207
): ServerProvider {
203208
const iconUrl =
204-
resolveOfficialAcpRegistryIconUrl(input.probe?.probe.icon) ??
205-
officialAcpRegistryIconUrlForAgentId(input.settings.agentId);
209+
input.settings.source === "local"
210+
? null
211+
: (resolveOfficialAcpRegistryIconUrl(input.probe?.probe.icon) ??
212+
officialAcpRegistryIconUrlForAgentId(input.settings.agentId));
206213
return {
207214
instanceId: input.instanceId,
208215
driver: DRIVER_KIND,
@@ -227,7 +234,9 @@ function baseSnapshot(
227234
input.installed &&
228235
(input.probe
229236
? input.probe.probe.authMethods.length > 0
230-
: input.settings.agentId.length > 0),
237+
: input.settings.source === "local"
238+
? (input.probeError?.authMethods?.length ?? 0) > 0
239+
: input.settings.agentId.length > 0),
231240
},
232241
...(input.message ? { message: input.message } : {}),
233242
models: modelsFromDiscovery(input.probe?.probe, input.settings.customModels),
@@ -636,7 +645,9 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
636645
const publishEnrichment = (
637646
Option.isSome(runtimeCoordinator)
638647
? runtimeCoordinator.value.runBackgroundProbe(
639-
effectiveConfig.agentId,
648+
effectiveConfig.source === "local"
649+
? `local:${instanceId}`
650+
: effectiveConfig.agentId,
640651
enrichProviderCached(snapshot),
641652
)
642653
: enrichProviderCached(snapshot).pipe(Effect.map(Option.some))

‎apps/server/src/provider/acp/AcpRegistryAuth.test.ts‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ const catalog: AcpRegistrySupport.AcpRegistryCatalog["Service"] = {
5757
uninstallManagedBinary: () => Effect.die("unused"),
5858
};
5959

60-
const makeHarness = (method: AcpSchema.AuthMethod, failVerification = false) =>
60+
const makeHarness = (
61+
method: AcpSchema.AuthMethod,
62+
failVerification = false,
63+
settings = decodeSettings({ agentId: "test-agent" }),
64+
providerInstanceId = instanceId,
65+
) =>
6166
Effect.gen(function* () {
6267
const verify = yield* Deferred.make<void>();
6368
const changed: boolean[] = [];
@@ -74,8 +79,8 @@ const makeHarness = (method: AcpSchema.AuthMethod, failVerification = false) =>
7479
const written: string[] = [];
7580
const sizes: number[][] = [];
7681
const controller = yield* makeAcpRegistryAuth({
77-
instanceId,
78-
settings: decodeSettings({ agentId: "test-agent" }),
82+
instanceId: providerInstanceId,
83+
settings,
7984
cwd: "/workspace",
8085
environment: { PATH: "/tools", OVERRIDE: "base" },
8186
onChanged: (value) =>
@@ -211,6 +216,26 @@ const makeHarness = (method: AcpSchema.AuthMethod, failVerification = false) =>
211216
};
212217
}).pipe(Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog));
213218

219+
it.effect("keeps local credentials separate from a matching registry agent ID", () =>
220+
Effect.gen(function* () {
221+
const registry = yield* makeHarness(browserMethod);
222+
const local = yield* makeHarness(
223+
browserMethod,
224+
false,
225+
decodeSettings({ source: "local", commandPath: "/different/agent" }),
226+
ProviderInstanceId.make("test-agent"),
227+
);
228+
assert.deepEqual(registry.controller.credentialBinding, {
229+
owner: "provider",
230+
key: "acp:test-agent",
231+
});
232+
assert.deepEqual(local.controller.credentialBinding, {
233+
owner: "provider",
234+
key: "acp:local:test-agent",
235+
});
236+
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
237+
);
238+
214239
it.effect(
215240
"discovers methods without signing in, then waits for browser consent and session verification",
216241
() =>

‎apps/server/src/provider/acp/AcpRegistryAuth.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export const makeAcpRegistryAuth = Effect.fn("makeAcpRegistryAuth")(function* (o
4545
const coordinator = yield* Effect.serviceOption(
4646
AcpRegistryRuntimeCoordinator.AcpRegistryRuntimeCoordinator,
4747
);
48+
const agentKey =
49+
options.settings.source === "local" ? `local:${options.instanceId}` : options.settings.agentId;
4850
const failure = (operation: string, detail: string, cause?: unknown) =>
4951
new ProviderSetupError({ instanceId: options.instanceId, operation, detail, cause });
5052
const resolve = catalog
@@ -139,7 +141,7 @@ export const makeAcpRegistryAuth = Effect.fn("makeAcpRegistryAuth")(function* (o
139141

140142
const methods = Option.isSome(coordinator)
141143
? coordinator.value
142-
.runBackgroundProbe(options.settings.agentId, discoverMethods)
144+
.runBackgroundProbe(agentKey, discoverMethods)
143145
.pipe(
144146
Effect.flatMap((result) =>
145147
Option.isSome(result)
@@ -327,7 +329,7 @@ export const makeAcpRegistryAuth = Effect.fn("makeAcpRegistryAuth")(function* (o
327329
}),
328330
);
329331
yield* Option.isSome(coordinator)
330-
? coordinator.value.withForegroundStartup(options.settings.agentId, login)
332+
? coordinator.value.withForegroundStartup(agentKey, login)
331333
: login;
332334
yield* options.onChanged(true);
333335
});
@@ -353,15 +355,13 @@ export const makeAcpRegistryAuth = Effect.fn("makeAcpRegistryAuth")(function* (o
353355
}),
354356
);
355357
const signOut = (
356-
Option.isSome(coordinator)
357-
? coordinator.value.withForegroundStartup(options.settings.agentId, logout)
358-
: logout
358+
Option.isSome(coordinator) ? coordinator.value.withForegroundStartup(agentKey, logout) : logout
359359
).pipe(Effect.andThen(options.onChanged(false)));
360360
return yield* ProviderAuthFlow.make({
361361
instanceId: options.instanceId,
362362
// ACP doesn't advertise its credential scope. Conservatively treat all
363363
// instances of the same agent on this environment as sharing credentials.
364-
credentialBinding: { owner: "provider", key: `acp:${options.settings.agentId}` },
364+
credentialBinding: { owner: "provider", key: `acp:${agentKey}` },
365365
methods,
366366
...(options.settings.authMethodId ? { defaultMethodId: options.settings.authMethodId } : {}),
367367
authenticate,

‎apps/server/src/provider/acp/AcpRegistryAuthenticationState.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export const makeAcpRegistryAuthenticationState = Effect.fn("makeAcpRegistryAuth
3434
// Cosmetic settings and model discovery can rebuild the driver without
3535
// changing the account. Credential overrides and profile paths cannot.
3636
const binding = hash({
37+
...(input.settings.source === "local"
38+
? { source: "local", commandArgs: input.settings.commandArgs }
39+
: {}),
3740
agentId: input.settings.agentId,
3841
commandPath: input.settings.commandPath,
3942
distribution: input.settings.distribution,

0 commit comments

Comments
 (0)