mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 03:03:24 +08:00
The Harness commands execute descriptor declares agentId, line, and images as required JSON wire fields (strict codec, no acceptsUndefined). The Host command executor only sent agentId and line, so the Typert gateway rejected every IM /compact call with arguments-invalid before the command could run. Send images: [] so /compact works from every IM channel.
25 lines
1 KiB
JavaScript
25 lines
1 KiB
JavaScript
/**
|
|
* Adapt the Host's Typert command gateway to the channel Harness client.
|
|
* Programmatic production fixtures may omit the gateway and exercise other assembly paths.
|
|
*/
|
|
export function createHarnessCommandExecutor(ctx, provided) {
|
|
if (provided !== undefined) {
|
|
if (typeof provided !== 'function') throw new TypeError('commandExecutor must be a function');
|
|
return provided;
|
|
}
|
|
const gateway = ctx?.typertGateway;
|
|
if (!gateway) return undefined;
|
|
if (typeof gateway.invoke !== 'function') {
|
|
throw new TypeError('dsh-im requires a callable ctx.typertGateway');
|
|
}
|
|
return (sessionId, line, options = {}) => gateway.invoke({
|
|
namespace: 'commands',
|
|
method: 'execute',
|
|
// The Harness commands execute descriptor declares agentId, line, and
|
|
// images as required JSON wire fields; omitting images makes the Typert
|
|
// gateway reject the call with arguments-invalid, so IM /compact always
|
|
// carried an empty image list.
|
|
args: { agentId: sessionId, line, images: [] },
|
|
signal: options.signal,
|
|
});
|
|
}
|