Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 100 additions & 91 deletions apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2831,101 +2831,110 @@ describe("AcpRegistryAdapterV2", () => {
}).pipe(Effect.provide(layerTest)),
);

it.effect("approves Devin's plan without choosing a bypass option it lists first", () =>
Effect.gen(function* () {
const session = yield* openClaudeReplaySession(
[
...claudeFrames.open.map((entry) =>
entry.frame.method === "initialize" && entry.type === "emit_inbound"
? {
...entry,
frame: {
...entry.frame,
result: { protocolVersion: 1, agentCapabilities: {}, authMethods: [] },
},
}
: entry,
),
{
type: "expect_outbound",
frame: { kind: "request", method: "session/prompt", params: "<any>" },
},
claudeFrames.update(CLAUDE_ROOT_SESSION, {
sessionUpdate: "tool_call",
toolCallId: "exit-plan",
title: "Exit plan mode",
kind: "switch_mode",
status: "pending",
}),
{
type: "emit_inbound",
frame: {
kind: "request",
method: "session/request_permission",
params: {
sessionId: CLAUDE_ROOT_SESSION,
toolCall: { toolCallId: "exit-plan" },
// Devin gives both plan approvals allow_once and does not promise their order.
options: [
{
optionId: "plan_bypass",
name: "Yes, implement plan and bypass permissions",
kind: "allow_once",
},
{
optionId: "plan_accept_edits",
name: "Yes, implement plan and accept edits",
kind: "allow_once",
},
{ optionId: "reject_once", name: "No, plan needs changes", kind: "reject_once" },
],
it.effect.each([
["registry", "devin"],
["local", { source: "local", commandPath: "/opt/devin/bin/devin" }],
] as const)(
"approves %s Devin's plan without choosing a bypass option it lists first",
([, agent]) =>
Effect.gen(function* () {
const session = yield* openClaudeReplaySession(
[
...claudeFrames.open.map((entry) =>
entry.frame.method === "initialize" && entry.type === "emit_inbound"
? {
...entry,
frame: {
...entry.frame,
result: { protocolVersion: 1, agentCapabilities: {}, authMethods: [] },
},
}
: entry,
),
{
type: "expect_outbound",
frame: { kind: "request", method: "session/prompt", params: "<any>" },
},
claudeFrames.update(CLAUDE_ROOT_SESSION, {
sessionUpdate: "tool_call",
toolCallId: "exit-plan",
title: "Exit plan mode",
kind: "switch_mode",
status: "pending",
}),
{
type: "emit_inbound",
frame: {
kind: "request",
method: "session/request_permission",
params: {
sessionId: CLAUDE_ROOT_SESSION,
toolCall: { toolCallId: "exit-plan" },
// Devin gives both plan approvals allow_once and does not promise their order.
options: [
{
optionId: "plan_bypass",
name: "Yes, implement plan and bypass permissions",
kind: "allow_once",
},
{
optionId: "plan_accept_edits",
name: "Yes, implement plan and accept edits",
kind: "allow_once",
},
{
optionId: "reject_once",
name: "No, plan needs changes",
kind: "reject_once",
},
],
},
},
},
},
{
type: "expect_outbound",
frame: {
kind: "response",
method: "session/request_permission",
result: { outcome: { outcome: "selected", optionId: "<any>" } },
{
type: "expect_outbound",
frame: {
kind: "response",
method: "session/request_permission",
result: { outcome: { outcome: "selected", optionId: "<any>" } },
},
},
},
{
type: "emit_inbound",
frame: {
kind: "response",
method: "session/prompt",
result: { stopReason: "end_turn" },
{
type: "emit_inbound",
frame: {
kind: "response",
method: "session/prompt",
result: { stopReason: "end_turn" },
},
},
},
claudeFrames.closeRequest,
claudeFrames.closed,
],
undefined,
false,
"devin",
);
yield* session.runtime.startTurn(session.turnInput(1)).pipe(Effect.forkScoped);
const seen = yield* session.until(
(event) =>
event.type === "runtime_request.updated" && event.runtimeRequest.status === "pending",
);
const request = seen.at(-1)!;
if (request.type !== "runtime_request.updated") throw new Error("Missing request");
yield* session.runtime.respondToRuntimeRequest({
requestId: request.runtimeRequest.id,
decision: "accept",
});
let answer: unknown;
while (answer === undefined) {
const frame = (yield* Queue.take(session.outgoing)) as {
readonly result?: { readonly outcome?: { readonly optionId?: string } };
};
answer = frame.result?.outcome;
}
assert.deepEqual(answer, { outcome: "selected", optionId: "plan_accept_edits" });
assert.equal((yield* session.terminal).status, "completed");
}).pipe(Effect.provide(layerTest), Effect.scoped),
claudeFrames.closeRequest,
claudeFrames.closed,
],
undefined,
false,
agent,
);
yield* session.runtime.startTurn(session.turnInput(1)).pipe(Effect.forkScoped);
const seen = yield* session.until(
(event) =>
event.type === "runtime_request.updated" && event.runtimeRequest.status === "pending",
);
const request = seen.at(-1)!;
if (request.type !== "runtime_request.updated") throw new Error("Missing request");
yield* session.runtime.respondToRuntimeRequest({
requestId: request.runtimeRequest.id,
decision: "accept",
});
let answer: unknown;
while (answer === undefined) {
const frame = (yield* Queue.take(session.outgoing)) as {
readonly result?: { readonly outcome?: { readonly optionId?: string } };
};
answer = frame.result?.outcome;
}
assert.deepEqual(answer, { outcome: "selected", optionId: "plan_accept_edits" });
assert.equal((yield* session.terminal).status, "completed");
}).pipe(Effect.provide(layerTest), Effect.scoped),
);

it.effect("counts per-turn usage for a local glm command", () =>
Expand Down
5 changes: 4 additions & 1 deletion packages/provider-acp-registry/src/server/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu
const registryAgentId = options.settings.source === "local" ? "" : options.settings.agentId;
const startupKey =
options.settings.source === "local" ? `local:${options.instanceId}` : registryAgentId;
const isDevin = registryAgentId === "devin";
const isDevin =
registryAgentId === "devin" ||
(options.settings.source === "local" &&
/^devin(\.exe|\.cmd)?$/i.test(options.settings.commandPath.split(/[\\/]/).pop() ?? ""));
const isAntigravityCli =
options.settings.source === "local" &&
/^agy(\.exe|\.cmd)?$/i.test(options.settings.commandPath.split(/[\\/]/).pop() ?? "");
Expand Down
Loading