Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(orca): preserve remote Agent admission failure codes

davide38ad856ebe9
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkers.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkers.test.ts
index 429fe7234b..3ed12d278e 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkers.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkers.test.ts
@@ -209,6 +209,30 @@ describe('execution devices', () => {
});
describe('openRemoteWorker', () => {
+ // PR #6787 review: unit coverage through the public open boundary. Existing
+ // transport/directory failures miss an online execution host rejecting its
+ // nested Agent route; callers must retain the share reason or connectivity code.
+ it.each([
+ ['REMOTE_AGENT_SHARE_PAUSED', 'REMOTE_AGENT_SHARE_PAUSED'],
+ ['REMOTE_AGENT_SHARE_REMOVED', 'REMOTE_AGENT_SHARE_REMOVED'],
+ ['REMOTE_AGENT_SHARE_UNAVAILABLE', 'REMOTE_AGENT_SHARE_UNAVAILABLE'],
+ ['DEVICE_LINK_DEVICE_OFFLINE', 'REMOTE_AGENT_DEVICE_UNREACHABLE'],
+ ['REMOTE_AGENT_DEVICE_UNREACHABLE', 'REMOTE_AGENT_DEVICE_UNREACHABLE'],
+ ])('preserves nested Agent admission failure %s as %s', async (code, expected) => {
+ const { workers, remoteInvoke } = setup({ handle: (_device, channel) => {
+ if (channel === 'maker:orca:remote-worker:caps') return ok({ version: 1, agentDevice: true });
+ if (channel === 'maker:orca:remote-worker:open') return fail('IPC_ERROR', `[${code}] Agent route unavailable`);
+ return undefined;
+ } });
+ try {
+ await expect(workers.openRemoteWorker({ ...openInput, agentDeviceId: 'provider-pc' }))
+ .resolves.toMatchObject({ ok: false, errorCode: expected, message: expect.stringContaining(code) });
+ expect(remoteInvoke.mock.calls.filter(([, channel]) => channel === 'maker:orca:remote-worker:open')).toHaveLength(1);
+ expect(store.addRemoteWorker).not.toHaveBeenCalled();
+ expect(store.removeRemoteWorkerOpen).not.toHaveBeenCalled();
+ } finally { workers.stop(); }
+ });
+
// Unit: old execution hosts silently discard unknown model-location fields.
// Reject before open; a capable host must receive and return the exact route.
it.each([false, true])('negotiates the independent model computer (supported=%s)', async supported => {
@@ -1390,12 +1414,12 @@ describe('remote open recovery', () => {
workers.stop();
});
- it('retains a timed out open even if the reconciliation receives a definitive error', async () => {
+ it.each(['ALREADY_EXISTS', 'REMOTE_AGENT_SHARE_PAUSED'])('retains an uncertain open when reconciliation receives %s', async code => {
let opens = 0;
const { workers } = setup({ handle: (_device, channel) =>
channel === 'maker:orca:remote-worker:open'
- ? fail(++opens === 1 ? 'INVOKE_TIMEOUT' : 'ALREADY_EXISTS', 'reply lost or released') : undefined });
- await expect(workers.openRemoteWorker(openInput)).resolves.toMatchObject({ ok: false });
+ ? fail(++opens === 1 ? 'INVOKE_TIMEOUT' : 'IPC_ERROR', `[${code}] reply lost or rejected`) : undefined });
+ await expect(workers.openRemoteWorker(openInput)).resolves.toMatchObject({ ok: false, errorCode: 'INTERNAL' });
expect(store.removeRemoteWorkerOpen).not.toHaveBeenCalled();
workers.stop();
});
diff --git a/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.ts b/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.ts
index e60f0f4c7b..d4a8847331 100644
--- a/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.ts
+++ b/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.ts
@@ -41,10 +41,11 @@ import {
removeWorker,
} from '../localDb/orcaTeamStore.js';
import { createHostSendFailure } from '../maker-host/send-outcome.js';
-import type {
- OrcaRemoteWorkerOpenResult,
- OrcaWorkerCreationDeps,
- OrcaWorkerCreationErrorCode,
+import {
+ agentDeviceCatalogFailure,
+ type OrcaRemoteWorkerOpenResult,
+ type OrcaWorkerCreationDeps,
+ type OrcaWorkerCreationErrorCode,
} from './orcaWorkerCreationService.js';
import {
createOrcaRemoteWorkerRuntime,
@@ -502,6 +503,12 @@ export function createOrcaRemoteWorkers(deps: OrcaRemoteWorkersDeps) {
message: `${name} 的 Cindy 版本过旧,需要更新后才能运行协同 Worker。`,
};
}
+ const agentFailure = agentDeviceCatalogFailure(err);
+ if (!uncertainOpen && (code?.startsWith('DEVICE_LINK_') || code === agentFailure.errorCode)) {
+ // The execution host answered; its nested Agent route owns this failure.
+ // A lost open ACK still takes the uncertain-result path below.
+ return agentFailure;
+ }
deps.log.warn('orca remote worker: open failed', { deviceId: input.deviceId, code });
return {
ok: false,
diff --git a/apps/desktop/src/main/maker-ipc/orcaWorkerCreationService.ts b/apps/desktop/src/main/maker-ipc/orcaWorkerCreationService.ts
index e6e26e6022..568351d2f4 100644
--- a/apps/desktop/src/main/maker-ipc/orcaWorkerCreationService.ts
+++ b/apps/desktop/src/main/maker-ipc/orcaWorkerCreationService.ts
@@ -273,7 +273,7 @@ export type OrcaRemoteWorkerOpenResult =
| {
ok: false;
errorCode: Extract<OrcaWorkerCreationErrorCode,
- 'REMOTE_AGENT_DEVICE_UNREACHABLE' | 'UNSUPPORTED_CAPABILITY' | 'INVALID_PARAMS' | 'INTERNAL' |
+ `REMOTE_AGENT_${string}` | 'UNSUPPORTED_CAPABILITY' | 'INVALID_PARAMS' | 'INTERNAL' |
'REMOTE_WORKDIR_NOT_FOUND' | 'REMOTE_WORKDIR_NOT_DIRECTORY' | 'REMOTE_WORKDIR_INVALID' | 'REMOTE_WORKDIR_UNAVAILABLE'>;
message: string;
};
@@ -801,7 +801,11 @@ function leadProviderGroupFollowCandidate(
const SHARE_ROUTE_REJECTION = /\[(REMOTE_AGENT_SHARE_(?:PAUSED|REMOVED|UNAVAILABLE))\]/;
/** 读不到 Worker 的 Agent 所在电脑的目录:分享保留具体原因,其余按那台连不上。 */
-export function agentDeviceCatalogFailure(err: unknown): Extract<OrcaWorkerCreationResult, { ok: false }> {
+export function agentDeviceCatalogFailure(err: unknown): {
+ ok: false;
+ errorCode: Extract<OrcaWorkerCreationErrorCode, `REMOTE_AGENT_${string}`>;
+ message: string;
+} {
const message = err instanceof Error ? err.message : String(err);
const share = SHARE_ROUTE_REJECTION.exec(message)?.[1] as
| 'REMOTE_AGENT_SHARE_PAUSED'