mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-14 19:20:50 +08:00
fix: improve WhatsApp settings and isolate IM host authentication
Some checks are pending
CI / Test, build, and verify package (push) Waiting to run
Some checks are pending
CI / Test, build, and verify package (push) Waiting to run
This commit is contained in:
parent
bcbe85fdb1
commit
bf73b0c0af
28 changed files with 848 additions and 116 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import { runHarnessHostOperation } from './harness-host-context.mjs';
|
||||
|
||||
/**
|
||||
* Adapt the Host's Typert command gateway to the channel Harness client.
|
||||
* Programmatic production fixtures may omit the gateway and exercise other assembly paths.
|
||||
|
|
@ -20,7 +22,7 @@ export function createHarnessCommandExecutor(ctx, provided) {
|
|||
signal: options.signal,
|
||||
};
|
||||
try {
|
||||
return await gateway.invoke(request);
|
||||
return await runHarnessHostOperation(ctx, () => gateway.invoke(request));
|
||||
} catch (error) {
|
||||
// Newer Hosts require images; older Hosts reject that field before
|
||||
// invoking the command. Retry only that exact pre-dispatch failure so
|
||||
|
|
@ -32,10 +34,10 @@ export function createHarnessCommandExecutor(ctx, provided) {
|
|||
throw error;
|
||||
}
|
||||
options.signal?.throwIfAborted();
|
||||
return gateway.invoke({
|
||||
return runHarnessHostOperation(ctx, () => gateway.invoke({
|
||||
...request,
|
||||
args: { agentId: sessionId, line },
|
||||
});
|
||||
}));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { modernHarnessApi } from './modern-harness-api.mjs';
|
||||
import { runHarnessHostOperation } from './harness-host-context.mjs';
|
||||
|
||||
function optionalService(ctx, name) {
|
||||
if (ctx && Object.hasOwn(ctx, name)) return ctx[name];
|
||||
|
|
@ -13,6 +14,7 @@ export function harnessConnection(ctx, config = {}) {
|
|||
const apiProxy = optionalService(ctx, 'apiProxy') ?? modernHarnessApi(ctx);
|
||||
return {
|
||||
apiProxy,
|
||||
runHostOperation: (operation) => runHarnessHostOperation(ctx, operation),
|
||||
// Cordis child contexts share one root; different Hosts must not share
|
||||
// ownership of pending questions and approvals.
|
||||
interactionScope: ctx.root ?? ctx,
|
||||
|
|
|
|||
10
plugin-src/host/harness-host-context.mjs
Normal file
10
plugin-src/host/harness-host-context.mjs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/** Run same-process IM operations without inheriting a browser's UDS identity. */
|
||||
export function runHarnessHostOperation(ctx, operation) {
|
||||
// Cordis property access requires inject even for an optional service.
|
||||
// ctx.get() supports dynamic lookup without making UDS a startup dependency.
|
||||
const auth = typeof ctx?.get === 'function' ? ctx.get('udsAuth') : ctx?.udsAuth;
|
||||
// Resolve on every call: auth can become ready or reload after IM starts.
|
||||
return typeof auth?.runAsHost === 'function'
|
||||
? auth.runAsHost(operation)
|
||||
: operation();
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ import { hasActiveHarnessInteractionOwner } from '../../src/channels/shared/harn
|
|||
const modernApis = new WeakMap();
|
||||
|
||||
function failureOf(error) {
|
||||
const failure = error?.failure;
|
||||
const failure = error?.failure ?? (error?.isDSHRemoteError === true ? error : null);
|
||||
if (failure && typeof failure === 'object'
|
||||
&& typeof failure.code === 'string'
|
||||
&& typeof failure.message === 'string') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue