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, 04:45 UTC
| 1 | // @effect-diagnostics nodeBuiltinImport:off |
| 2 | import * as NodePath from "node:path"; |
| 3 | import * as NodeURL from "node:url"; |
| 4 | |
| 5 | import * as NodeCrypto from "@effect/platform-node/NodeCrypto"; |
| 6 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
| 7 | import * as Layer from "effect/Layer"; |
| 8 | import { ProviderInstanceId } from "@t3tools/contracts"; |
| 9 | import { AcpRegistrySettings } from "@t3tools/provider-acp-registry/settings"; |
| 10 | import { describe, expect, it } from "@effect/vitest"; |
| 11 | import * as Effect from "effect/Effect"; |
| 12 | import * as FileSystem from "effect/FileSystem"; |
| 13 | import * as Schema from "effect/Schema"; |
| 14 | import * as EffectAcpErrors from "effect-acp/errors"; |
| 15 | |
| 16 | import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime"; |
| 17 | import { |
| 18 | acpRegistryProbeFailure, |
| 19 | acpRegistryProbeResult, |
| 20 | listAcpRegistrySessions, |
| 21 | logoutAcpRegistry, |
| 22 | normalizeAcpRegistryAuthMethods, |
| 23 | normalizeAcpRegistryCommands, |
| 24 | probeAcpRegistryConfiguration, |
| 25 | } from "@t3tools/provider-acp-registry/testing"; |
| 26 | import * as AcpRegistrySupport from "@t3tools/provider-acp-registry/server/AcpRegistrySupport"; |
| 27 | |
| 28 | const instanceId = ProviderInstanceId.make("acpRegistry_codex"); |
| 29 | const __dirname = NodePath.dirname(NodeURL.fileURLToPath(import.meta.url)); |
| 30 | const mockAgentPath = NodePath.join(__dirname, "../../scripts/acp-mock-agent.ts"); |
| 31 | const decodeSettings = Schema.decodeSync(AcpRegistrySettings); |
| 32 | |
| 33 | describe("ACP Registry probe", () => { |
| 34 | it("returns advertised auth methods and de-duplicated models", () => { |
| 35 | const result = acpRegistryProbeResult(instanceId, { |
| 36 | sessionId: "probe-session", |
| 37 | initializeResult: { |
| 38 | protocolVersion: 1, |
| 39 | agentCapabilities: { |
| 40 | loadSession: true, |
| 41 | auth: { logout: {} }, |
| 42 | sessionCapabilities: { list: {}, resume: {} }, |
| 43 | }, |
| 44 | authMethods: [ |
| 45 | { id: "chatgpt", name: "ChatGPT" }, |
| 46 | { |
| 47 | id: "api-key", |
| 48 | name: "API key", |
| 49 | type: "env_var", |
| 50 | vars: [{ name: "OPENAI_API_KEY", label: "OpenAI API key" }], |
| 51 | }, |
| 52 | { id: "login", name: "Terminal login", type: "terminal" }, |
| 53 | ], |
| 54 | }, |
| 55 | sessionSetupResult: { |
| 56 | sessionId: "probe-session", |
| 57 | configOptions: [ |
| 58 | { |
| 59 | id: "model", |
| 60 | name: "Model", |
| 61 | category: "model", |
| 62 | type: "select", |
| 63 | currentValue: "gpt-5.4", |
| 64 | options: [ |
| 65 | { value: "gpt-5.4", name: "GPT-5.4" }, |
| 66 | { value: "gpt-5.4", name: "Duplicate" }, |
| 67 | ], |
| 68 | }, |
| 69 | { |
| 70 | id: "effort", |
| 71 | name: "Effort", |
| 72 | category: "thought_level", |
| 73 | type: "select", |
| 74 | currentValue: "high", |
| 75 | options: [{ value: "high", name: "High" }], |
| 76 | }, |
| 77 | { |
| 78 | id: "mode", |
| 79 | name: "Mode", |
| 80 | category: "mode", |
| 81 | type: "select", |
| 82 | currentValue: "ask", |
| 83 | options: [{ value: "ask", name: "Ask" }], |
| 84 | }, |
| 85 | ], |
| 86 | }, |
| 87 | modelConfigId: "model", |
| 88 | } satisfies AcpSessionRuntime.AcpSessionRuntimeStartResult); |
| 89 | |
| 90 | expect(result).toEqual({ |
| 91 | instanceId, |
| 92 | ready: true, |
| 93 | icon: null, |
| 94 | authMethods: [ |
| 95 | { id: "chatgpt", name: "ChatGPT", description: null, type: "agent" }, |
| 96 | { |
| 97 | id: "api-key", |
| 98 | name: "API key", |
| 99 | description: null, |
| 100 | type: "env_var", |
| 101 | envVarNames: ["OPENAI_API_KEY"], |
| 102 | }, |
| 103 | { id: "login", name: "Terminal login", description: null, type: "terminal" }, |
| 104 | ], |
| 105 | models: [{ id: "gpt-5.4", name: "GPT-5.4", description: null }], |
| 106 | currentModelId: "gpt-5.4", |
| 107 | configOptions: [ |
| 108 | { |
| 109 | id: "effort", |
| 110 | label: "Effort", |
| 111 | type: "select", |
| 112 | options: [{ id: "high", label: "High" }], |
| 113 | currentValue: "high", |
| 114 | role: "reasoning", |
| 115 | }, |
| 116 | { |
| 117 | id: "mode", |
| 118 | label: "Mode", |
| 119 | type: "select", |
| 120 | options: [{ id: "ask", label: "Ask" }], |
| 121 | currentValue: "ask", |
| 122 | }, |
| 123 | ], |
| 124 | modelOptionIds: ["effort"], |
| 125 | sessionManagement: { |
| 126 | canList: true, |
| 127 | canLoad: true, |
| 128 | canResume: true, |
| 129 | canLogout: true, |
| 130 | canDelete: false, |
| 131 | canConfigureProviders: false, |
| 132 | }, |
| 133 | }); |
| 134 | }); |
| 135 | |
| 136 | it("composes runnable terminal auth commands from the resolved spawn recipe", () => { |
| 137 | const methods = normalizeAcpRegistryAuthMethods( |
| 138 | [ |
| 139 | { |
| 140 | id: "login", |
| 141 | name: "Terminal login", |
| 142 | type: "terminal", |
| 143 | args: ["auth", "log in"], |
| 144 | env: { FORCE_TTY: "1" }, |
| 145 | }, |
| 146 | ], |
| 147 | { command: "/opt/agents/devin", args: ["--acp"] }, |
| 148 | ); |
| 149 | |
| 150 | expect(methods).toEqual([ |
| 151 | { |
| 152 | id: "login", |
| 153 | name: "Terminal login", |
| 154 | description: null, |
| 155 | type: "terminal", |
| 156 | command: "FORCE_TTY=1 /opt/agents/devin --acp auth 'log in'", |
| 157 | }, |
| 158 | ]); |
| 159 | }); |
| 160 | |
| 161 | it("omits unsafe truncated auth commands instead of publishing broken shell", () => { |
| 162 | const methods = normalizeAcpRegistryAuthMethods( |
| 163 | [ |
| 164 | { |
| 165 | id: "login", |
| 166 | name: "Terminal login", |
| 167 | type: "terminal", |
| 168 | args: ["x".repeat(2_048)], |
| 169 | }, |
| 170 | ], |
| 171 | { command: "/opt/agents/devin", args: ["--acp"] }, |
| 172 | ); |
| 173 | |
| 174 | expect(methods[0]).not.toHaveProperty("command"); |
| 175 | }); |
| 176 | |
| 177 | it("omits overlong opaque model ids instead of publishing mutated ids", () => { |
| 178 | const result = acpRegistryProbeResult(instanceId, { |
| 179 | sessionId: "probe-session", |
| 180 | initializeResult: { protocolVersion: 1 }, |
| 181 | sessionSetupResult: { |
| 182 | sessionId: "probe-session", |
| 183 | configOptions: [ |
| 184 | { |
| 185 | id: "model", |
| 186 | name: "Model", |
| 187 | category: "model", |
| 188 | type: "select", |
| 189 | currentValue: "x".repeat(129), |
| 190 | options: [ |
| 191 | { value: "x".repeat(129), name: "Too long" }, |
| 192 | { value: "valid", name: "Valid" }, |
| 193 | ], |
| 194 | }, |
| 195 | ], |
| 196 | }, |
| 197 | modelConfigId: "model", |
| 198 | } satisfies AcpSessionRuntime.AcpSessionRuntimeStartResult); |
| 199 | |
| 200 | expect(result.models).toEqual([{ id: "valid", name: "Valid", description: null }]); |
| 201 | expect(result.currentModelId).toBeNull(); |
| 202 | }); |
| 203 | |
| 204 | it("preserves grouped model values and advertises reasoning choices", () => { |
| 205 | const codexModel = '["codex","gpt-6.1-sol"]'; |
| 206 | const goModel = '["opencode-go","deepseek-v4.1-flash"]'; |
| 207 | const result = acpRegistryProbeResult(instanceId, { |
| 208 | sessionId: "probe-session", |
| 209 | initializeResult: { protocolVersion: 1 }, |
| 210 | sessionSetupResult: { |
| 211 | sessionId: "probe-session", |
| 212 | configOptions: [ |
| 213 | { |
| 214 | id: "model", |
| 215 | name: "Model", |
| 216 | category: "model", |
| 217 | type: "select", |
| 218 | currentValue: goModel, |
| 219 | options: [ |
| 220 | { |
| 221 | groupId: "codex", |
| 222 | name: "Codex", |
| 223 | options: [{ value: codexModel, name: "GPT-6.1 Sol" }], |
| 224 | }, |
| 225 | { |
| 226 | groupId: "opencode-go", |
| 227 | name: "OpenCode Go", |
| 228 | options: [{ value: goModel, name: "DeepSeek V4.1 Flash" }], |
| 229 | }, |
| 230 | ], |
| 231 | }, |
| 232 | { |
| 233 | id: "reasoning", |
| 234 | name: "Reasoning", |
| 235 | category: "thought_level", |
| 236 | type: "select", |
| 237 | currentValue: "high", |
| 238 | options: [ |
| 239 | { |
| 240 | groupId: "effort", |
| 241 | name: "Effort", |
| 242 | options: [ |
| 243 | { value: "medium", name: "Medium" }, |
| 244 | { value: "high", name: "High" }, |
| 245 | ], |
| 246 | }, |
| 247 | ], |
| 248 | }, |
| 249 | ], |
| 250 | }, |
| 251 | modelConfigId: "model", |
| 252 | } satisfies AcpSessionRuntime.AcpSessionRuntimeStartResult); |
| 253 | |
| 254 | expect(result.models).toEqual([ |
| 255 | { id: codexModel, name: "GPT-6.1 Sol", description: null }, |
| 256 | { id: goModel, name: "DeepSeek V4.1 Flash", description: null }, |
| 257 | ]); |
| 258 | expect(result.currentModelId).toBe(goModel); |
| 259 | expect(result.configOptions).toEqual([ |
| 260 | { |
| 261 | id: "reasoning", |
| 262 | label: "Reasoning", |
| 263 | type: "select", |
| 264 | currentValue: "high", |
| 265 | options: [ |
| 266 | { id: "medium", label: "Medium" }, |
| 267 | { id: "high", label: "High" }, |
| 268 | ], |
| 269 | role: "reasoning", |
| 270 | }, |
| 271 | ]); |
| 272 | }); |
| 273 | |
| 274 | it.each(["config option", "session model state"] as const)( |
| 275 | "retains the current model beyond the catalog cap from %s", |
| 276 | (source) => { |
| 277 | const models = Array.from({ length: 257 }, (_, index) => ({ |
| 278 | modelId: `model-${index}`, |
| 279 | name: `Model ${index}`, |
| 280 | })); |
| 281 | const result = acpRegistryProbeResult(instanceId, { |
| 282 | sessionId: "probe-session", |
| 283 | initializeResult: { protocolVersion: 1 }, |
| 284 | sessionSetupResult: { |
| 285 | sessionId: "probe-session", |
| 286 | ...(source === "config option" |
| 287 | ? { |
| 288 | configOptions: [ |
| 289 | { |
| 290 | id: "model", |
| 291 | name: "Model", |
| 292 | category: "model", |
| 293 | type: "select", |
| 294 | currentValue: "model-256", |
| 295 | options: models.map(({ modelId, name }) => ({ value: modelId, name })), |
| 296 | }, |
| 297 | ], |
| 298 | } |
| 299 | : { models: { currentModelId: "model-256", availableModels: models } }), |
| 300 | }, |
| 301 | modelConfigId: source === "config option" ? "model" : undefined, |
| 302 | } satisfies AcpSessionRuntime.AcpSessionRuntimeStartResult); |
| 303 | |
| 304 | expect(result.models).toHaveLength(256); |
| 305 | expect(result.models[0]?.id).toBe("model-0"); |
| 306 | expect(result.models.at(-1)?.id).toBe("model-256"); |
| 307 | expect(result.currentModelId).toBe("model-256"); |
| 308 | }, |
| 309 | ); |
| 310 | |
| 311 | it("keeps every distinct advertised command and de-duplicates the rest", () => { |
| 312 | const commands = normalizeAcpRegistryCommands([ |
| 313 | { |
| 314 | name: "create_plan", |
| 315 | description: " Create a plan ", |
| 316 | input: { type: "text", hint: " topic " }, |
| 317 | }, |
| 318 | { name: "CREATE_PLAN", description: "duplicate" }, |
| 319 | ...Array.from({ length: 140 }, (_, index) => ({ |
| 320 | name: `command_${index}`, |
| 321 | description: "", |
| 322 | })), |
| 323 | { name: "$late-skill", description: "Advertised after 128 commands" }, |
| 324 | ]); |
| 325 | |
| 326 | expect(commands.slashCommands).toHaveLength(141); |
| 327 | expect(commands.slashCommands.at(-1)).toEqual({ name: "command_139" }); |
| 328 | expect(commands.slashCommands[0]).toEqual({ |
| 329 | name: "create_plan", |
| 330 | description: "Create a plan", |
| 331 | input: { hint: "topic" }, |
| 332 | }); |
| 333 | expect( |
| 334 | commands.slashCommands.filter((command) => command.name.toLowerCase() === "create_plan"), |
| 335 | ).toHaveLength(1); |
| 336 | expect(commands.skills.map((skill) => skill.name)).toEqual(["late-skill"]); |
| 337 | }); |
| 338 | |
| 339 | it("routes dollar-prefixed ACP commands to the provider skill menu", () => { |
| 340 | expect( |
| 341 | normalizeAcpRegistryCommands([ |
| 342 | { name: "$workspace-skill", description: "Run the workspace skill" }, |
| 343 | { name: "$WORKSPACE-SKILL", description: "duplicate" }, |
| 344 | { name: "$", description: "empty" }, |
| 345 | { name: "review", description: "Review changes" }, |
| 346 | ]), |
| 347 | ).toEqual({ |
| 348 | slashCommands: [{ name: "review", description: "Review changes" }], |
| 349 | skills: [ |
| 350 | { |
| 351 | name: "workspace-skill", |
| 352 | description: "Run the workspace skill", |
| 353 | path: "acp://skill/workspace-skill", |
| 354 | scope: "agent", |
| 355 | enabled: true, |
| 356 | }, |
| 357 | ], |
| 358 | }); |
| 359 | }); |
| 360 | |
| 361 | it.effect("lists native sessions and logs out through generic ACP lifecycle methods", () => { |
| 362 | const catalog = AcpRegistrySupport.AcpRegistryCatalog.of({ |
| 363 | search: () => Effect.die("unused search"), |
| 364 | prepare: () => Effect.die("unused prepare"), |
| 365 | inspect: () => Effect.die("unused inspect"), |
| 366 | uninstallManagedBinary: () => Effect.die("unused uninstall"), |
| 367 | resolve: () => |
| 368 | Effect.succeed({ |
| 369 | agent: { |
| 370 | id: "mock-agent", |
| 371 | name: "Mock Agent", |
| 372 | version: "1.0.0", |
| 373 | description: "ACP session management test agent", |
| 374 | distribution: { npx: { package: "mock-agent@1.0.0" } }, |
| 375 | }, |
| 376 | distribution: "npx" as const, |
| 377 | spawn: { |
| 378 | command: "node", |
| 379 | args: [mockAgentPath], |
| 380 | env: { |
| 381 | ...process.env, |
| 382 | T3_ACP_SESSION_LIFECYCLE: "1", |
| 383 | T3_ACP_AUTH_METHOD_ID: "mock-login", |
| 384 | }, |
| 385 | }, |
| 386 | }), |
| 387 | }); |
| 388 | const input = { |
| 389 | instanceId, |
| 390 | settings: decodeSettings({ agentId: "mock-agent" }), |
| 391 | cwd: process.cwd(), |
| 392 | environment: process.env, |
| 393 | }; |
| 394 | |
| 395 | return Effect.gen(function* () { |
| 396 | const listed = yield* listAcpRegistrySessions(input); |
| 397 | expect(listed).toMatchObject({ |
| 398 | canLoad: true, |
| 399 | canResume: true, |
| 400 | nextCursor: null, |
| 401 | sessions: [ |
| 402 | { |
| 403 | sessionId: "mock-session-1", |
| 404 | cwd: process.cwd(), |
| 405 | importedThreadId: null, |
| 406 | }, |
| 407 | ], |
| 408 | }); |
| 409 | yield* logoutAcpRegistry(input); |
| 410 | }).pipe( |
| 411 | Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog), |
| 412 | Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)), |
| 413 | ); |
| 414 | }); |
| 415 | |
| 416 | it.live.each(["succeeds", "fails"] as const)( |
| 417 | "deletes its health-probe session when deletion is advertised and %s", |
| 418 | (deleteOutcome) => |
| 419 | Effect.gen(function* () { |
| 420 | const fs = yield* FileSystem.FileSystem; |
| 421 | const directory = yield* fs.makeTempDirectoryScoped({ prefix: "acp-probe-delete-" }); |
| 422 | const requestLogPath = NodePath.join(directory, "requests.ndjson"); |
| 423 | const catalog = AcpRegistrySupport.AcpRegistryCatalog.of({ |
| 424 | search: () => Effect.die("unused search"), |
| 425 | prepare: () => Effect.die("unused prepare"), |
| 426 | inspect: () => Effect.die("unused inspect"), |
| 427 | uninstallManagedBinary: () => Effect.die("unused uninstall"), |
| 428 | resolve: () => |
| 429 | Effect.succeed({ |
| 430 | agent: { |
| 431 | id: "mock-agent", |
| 432 | name: "Mock Agent", |
| 433 | version: "1.0.0", |
| 434 | description: "ACP probe cleanup test agent", |
| 435 | distribution: { npx: { package: "mock-agent@1.0.0" } }, |
| 436 | }, |
| 437 | distribution: "npx" as const, |
| 438 | spawn: { |
| 439 | command: "node", |
| 440 | args: [mockAgentPath], |
| 441 | env: { |
| 442 | ...process.env, |
| 443 | T3_ACP_V2_MANAGEMENT: "1", |
| 444 | T3_ACP_REQUEST_LOG_PATH: requestLogPath, |
| 445 | ...(deleteOutcome === "fails" ? { T3_ACP_FAIL_DELETE_SESSION: "1" } : {}), |
| 446 | }, |
| 447 | }, |
| 448 | }), |
| 449 | }); |
| 450 | |
| 451 | const result = yield* probeAcpRegistryConfiguration({ |
| 452 | instanceId, |
| 453 | settings: decodeSettings({ agentId: "mock-agent" }), |
| 454 | cwd: process.cwd(), |
| 455 | environment: process.env, |
| 456 | }).pipe(Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog)); |
| 457 | expect(result.probe.ready).toBe(true); |
| 458 | expect(result.probe.sessionManagement.canDelete).toBe(true); |
| 459 | |
| 460 | const requests = (yield* fs.readFileString(requestLogPath)) |
| 461 | .split("\n") |
| 462 | .filter((line) => line.length > 0) |
| 463 | .map((line) => JSON.parse(line)); |
| 464 | expect(requests.filter((request) => request.method === "session/delete")).toEqual([ |
| 465 | expect.objectContaining({ params: { sessionId: "mock-session-1" } }), |
| 466 | ]); |
| 467 | }).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))), |
| 468 | ); |
| 469 | |
| 470 | it.live("keeps DeepSeek Harness probe history in a temporary directory", () => |
| 471 | Effect.gen(function* () { |
| 472 | const fs = yield* FileSystem.FileSystem; |
| 473 | const directory = yield* fs.makeTempDirectoryScoped({ prefix: "acp-probe-dsh-" }); |
| 474 | const launcher = NodePath.join(directory, "dsh-fixture.mjs"); |
| 475 | const launchLog = NodePath.join(directory, "launch.json"); |
| 476 | yield* fs.writeFileString( |
| 477 | launcher, |
| 478 | ` |
| 479 | import { readFileSync, writeFileSync } from "node:fs"; |
| 480 | import { pathToFileURL } from "node:url"; |
| 481 | const [,, agentPath, logPath, ...args] = process.argv; |
| 482 | const patchFlag = args.lastIndexOf("--patch"); |
| 483 | const patchPath = patchFlag === -1 ? null : args[patchFlag + 1]; |
| 484 | const patch = patchPath === null ? null : JSON.parse(readFileSync(patchPath, "utf8")); |
| 485 | writeFileSync(logPath, JSON.stringify({ args, patch })); |
| 486 | await import(pathToFileURL(agentPath).href); |
| 487 | `, |
| 488 | ); |
| 489 | const userPatch = NodePath.join(directory, "user-patch.json"); |
| 490 | yield* fs.writeFileString(userPatch, "[]"); |
| 491 | const commandArgs = ["--profile", "acp", "--patch", userPatch]; |
| 492 | const catalog = AcpRegistrySupport.AcpRegistryCatalog.of({ |
| 493 | search: () => Effect.die("unused search"), |
| 494 | prepare: () => Effect.die("unused prepare"), |
| 495 | inspect: () => Effect.die("unused inspect"), |
| 496 | uninstallManagedBinary: () => Effect.die("unused uninstall"), |
| 497 | resolve: () => |
| 498 | Effect.succeed({ |
| 499 | distribution: "local", |
| 500 | spawn: { |
| 501 | command: process.execPath, |
| 502 | args: [launcher, mockAgentPath, launchLog, ...commandArgs], |
| 503 | }, |
| 504 | }), |
| 505 | }); |
| 506 | const result = yield* probeAcpRegistryConfiguration({ |
| 507 | instanceId, |
| 508 | settings: decodeSettings({ source: "local", commandPath: "dsh", commandArgs }), |
| 509 | cwd: directory, |
| 510 | environment: process.env, |
| 511 | }).pipe(Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog)); |
| 512 | expect(result.probe.ready).toBe(true); |
| 513 | expect(result.probe.models.length).toBeGreaterThan(0); |
| 514 | |
| 515 | const { args, patch } = JSON.parse(yield* fs.readFileString(launchLog)); |
| 516 | expect(args).toEqual([...commandArgs, "--patch", expect.any(String)]); |
| 517 | const probeDirectory = NodePath.dirname(args.at(-1)); |
| 518 | expect(patch).toEqual([ |
| 519 | { |
| 520 | id: "session-persistence-jsonl", |
| 521 | config: { root: NodePath.join(probeDirectory, "sessions") }, |
| 522 | }, |
| 523 | { id: "session-projection-cache", disabled: true }, |
| 524 | ]); |
| 525 | expect(yield* fs.exists(probeDirectory)).toBe(false); |
| 526 | }).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))), |
| 527 | ); |
| 528 | |
| 529 | it("distinguishes authentication failures from generic probe failures", () => { |
| 530 | const advertised = normalizeAcpRegistryAuthMethods([ |
| 531 | { id: "grok-login", name: "Log in with Grok" }, |
| 532 | ]); |
| 533 | const cause = new EffectAcpErrors.AcpRequestError({ |
| 534 | code: -32000, |
| 535 | errorMessage: "login required", |
| 536 | }); |
| 537 | const authFailure = acpRegistryProbeFailure(cause, advertised); |
| 538 | expect(authFailure.reason).toBe("authentication_failed"); |
| 539 | expect(authFailure.message).toBe("The ACP agent could not complete authentication."); |
| 540 | expect(authFailure.cause).toBe(cause); |
| 541 | expect(authFailure.authMethods).toEqual([ |
| 542 | { |
| 543 | id: "grok-login", |
| 544 | name: "Log in with Grok", |
| 545 | description: null, |
| 546 | type: "agent", |
| 547 | }, |
| 548 | ]); |
| 549 | expect( |
| 550 | acpRegistryProbeFailure( |
| 551 | new EffectAcpErrors.AcpTransportError({ |
| 552 | detail: "Authentication required", |
| 553 | cause: "credentials missing", |
| 554 | }), |
| 555 | ).reason, |
| 556 | ).toBe("authentication_failed"); |
| 557 | const genericCause = new EffectAcpErrors.AcpTransportError({ |
| 558 | detail: "connection closed", |
| 559 | cause: "closed", |
| 560 | }); |
| 561 | const genericFailure = acpRegistryProbeFailure(genericCause); |
| 562 | expect(genericFailure.reason).toBe("probe_failed"); |
| 563 | expect(genericFailure.message).toBe("The ACP agent could not create a test session."); |
| 564 | expect(genericFailure.cause).toBe(genericCause); |
| 565 | expect( |
| 566 | acpRegistryProbeFailure( |
| 567 | new EffectAcpErrors.AcpTransportError({ |
| 568 | detail: "Failed while logging request", |
| 569 | cause: "logging failed", |
| 570 | }), |
| 571 | ).reason, |
| 572 | ).toBe("probe_failed"); |
| 573 | }); |
| 574 | }); |