mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 03:03:24 +08:00
Map Host branded create failures and retry without broken presets.
Classify gateway/internal, workspace/*, and agent-preset/* into actionable IM codes, enrich field diagnostics, realpath-match workspaces, and retry session.create once without a failing Agent Preset. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
f1c9abfd1d
commit
f1d85d2985
8 changed files with 415 additions and 220 deletions
|
|
@ -648,6 +648,47 @@ test('HarnessClient reuses Host workspaces when only Windows path casing differs
|
|||
);
|
||||
});
|
||||
|
||||
test('HarnessClient retries session.create without agentPreset after preset/internal failure', async () => {
|
||||
const client = new HarnessClient({
|
||||
baseUrl: 'http://127.0.0.1:3080',
|
||||
workspace: '/tmp/dsh-feishu-workspace',
|
||||
agentPreset: 'broken-preset',
|
||||
autostart: false,
|
||||
dshBin: 'dsh',
|
||||
});
|
||||
const creates = [];
|
||||
client.ensureRunning = async () => undefined;
|
||||
client.rpc = async (method, payload) => {
|
||||
if (method === 'workspace.list') {
|
||||
return {
|
||||
items: [{
|
||||
workspaceId: 'workspace-one',
|
||||
path: '/tmp/dsh-feishu-workspace',
|
||||
sessionIds: [],
|
||||
}],
|
||||
archivedSessionIds: [],
|
||||
};
|
||||
}
|
||||
if (method === 'session.create') {
|
||||
creates.push(payload);
|
||||
if (payload.agentPreset) {
|
||||
const error = new Error('agent-presets: preset "broken-preset" not found');
|
||||
error.code = 'agent-preset/not-found';
|
||||
error.method = 'session.create';
|
||||
throw error;
|
||||
}
|
||||
return { sessionId: 'session-recovered' };
|
||||
}
|
||||
throw new Error(`unexpected method ${method}`);
|
||||
};
|
||||
|
||||
assert.equal(await client.createSession(), 'session-recovered');
|
||||
assert.deepEqual(creates, [
|
||||
{ workspaceId: 'workspace-one', agentPreset: 'broken-preset' },
|
||||
{ workspaceId: 'workspace-one' },
|
||||
]);
|
||||
});
|
||||
|
||||
test('HarnessClient asks do not control file-return tool availability', async () => {
|
||||
const client = new HarnessClient({
|
||||
baseUrl: 'http://127.0.0.1:3080',
|
||||
|
|
|
|||
|
|
@ -117,6 +117,28 @@ test('session.create failures tell operators to check the bot workspace path', (
|
|||
assert.match(failure.message, /工作区/);
|
||||
});
|
||||
|
||||
test('Host branded gateway/internal on session.create maps to SESSION_CREATE', () => {
|
||||
assert.equal(classifyMessageFailure({
|
||||
code: 'gateway/internal', method: 'session.create',
|
||||
message: 'failed to create session "session-x": Error: boom',
|
||||
}, options).code, 'SESSION_CREATE');
|
||||
});
|
||||
|
||||
test('Host branded workspace/invalid-path maps to WORKSPACE_UNAVAILABLE', () => {
|
||||
assert.equal(classifyMessageFailure({
|
||||
code: 'workspace/invalid-path', method: 'workspace.create',
|
||||
message: 'cannot create a Workspace at "D:\\\\missing": ENOENT',
|
||||
details: { path: 'D:\\missing' },
|
||||
}, options).code, 'WORKSPACE_UNAVAILABLE');
|
||||
});
|
||||
|
||||
test('Host branded agent-preset/not-found maps to PRESET_UNAVAILABLE', () => {
|
||||
assert.equal(classifyMessageFailure({
|
||||
code: 'agent-preset/not-found', method: 'session.create',
|
||||
details: { agentPreset: 'gone' },
|
||||
}, options).code, 'PRESET_UNAVAILABLE');
|
||||
});
|
||||
|
||||
test('message failure text contains a safe code and traceable reference', () => {
|
||||
const failure = classifyMessageFailure(new Error('secret-shaped internal detail'), options);
|
||||
assert.deepEqual(failure, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue