@hirey/hi-mcp-server 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/defaultReplyRoute.d.ts +15 -0
- package/dist/defaultReplyRoute.d.ts.map +1 -0
- package/dist/defaultReplyRoute.js +28 -0
- package/dist/server.js +11 -10
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type DefaultReplyDeliveryContext = {
|
|
2
|
+
channel: string | null;
|
|
3
|
+
to: string | null;
|
|
4
|
+
account_id: string | null;
|
|
5
|
+
thread_id: string | null;
|
|
6
|
+
};
|
|
7
|
+
export declare function resolveInstallDefaultReplyDeliveryContext(args: {
|
|
8
|
+
hostKind: 'openclaw' | 'generic';
|
|
9
|
+
hasSessionKey: boolean;
|
|
10
|
+
defaultReplyChannel?: unknown;
|
|
11
|
+
defaultReplyTo?: unknown;
|
|
12
|
+
defaultReplyAccountId?: unknown;
|
|
13
|
+
defaultReplyThreadId?: unknown;
|
|
14
|
+
}): DefaultReplyDeliveryContext | null;
|
|
15
|
+
//# sourceMappingURL=defaultReplyRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultReplyRoute.d.ts","sourceRoot":"","sources":["../src/defaultReplyRoute.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,wBAAgB,yCAAyC,CAAC,IAAI,EAAE;IAC9D,QAAQ,EAAE,UAAU,GAAG,SAAS,CAAC;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,GAAG,2BAA2B,GAAG,IAAI,CAyBrC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function normalizeText(input) {
|
|
2
|
+
return String(input || '').trim();
|
|
3
|
+
}
|
|
4
|
+
export function resolveInstallDefaultReplyDeliveryContext(args) {
|
|
5
|
+
const explicit = {
|
|
6
|
+
channel: normalizeText(args.defaultReplyChannel) || null,
|
|
7
|
+
to: normalizeText(args.defaultReplyTo) || null,
|
|
8
|
+
account_id: normalizeText(args.defaultReplyAccountId) || null,
|
|
9
|
+
thread_id: normalizeText(args.defaultReplyThreadId) || null,
|
|
10
|
+
};
|
|
11
|
+
const hasExplicit = !!(explicit.channel
|
|
12
|
+
|| explicit.to
|
|
13
|
+
|| explicit.account_id
|
|
14
|
+
|| explicit.thread_id);
|
|
15
|
+
if (hasExplicit)
|
|
16
|
+
return explicit;
|
|
17
|
+
// OpenClaw hooks continuation accepts `last|imessage`; when we already have the
|
|
18
|
+
// canonical session key, `last` is the canonical "same chat" lane.
|
|
19
|
+
if (args.hostKind === 'openclaw' && args.hasSessionKey) {
|
|
20
|
+
return {
|
|
21
|
+
channel: 'last',
|
|
22
|
+
to: null,
|
|
23
|
+
account_id: null,
|
|
24
|
+
thread_id: null,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -14,6 +14,7 @@ import { createHiAgentClients, exchangeHiAgentClientCredentialsToken, HiAgentGat
|
|
|
14
14
|
import { readState, resolveCanonicalOpenClawStateDir, resolveDefaultStateDir, resolveLegacyStateFiles, resolveStateFile, updateState, normalizeStateProfile, } from './state.js';
|
|
15
15
|
import { looksLikeOpenClawSessionKey, validateOpenClawSessionKey, } from './openclaw-session-key.js';
|
|
16
16
|
import { buildInstallReceiverCommandArgv, } from './receiver-command.js';
|
|
17
|
+
import { resolveInstallDefaultReplyDeliveryContext, } from './defaultReplyRoute.js';
|
|
17
18
|
const CAPABILITY_CACHE_TTL_MS = 30_000;
|
|
18
19
|
const resolvedProfile = normalizeStateProfile(process.env.HI_MCP_PROFILE);
|
|
19
20
|
const config = {
|
|
@@ -622,16 +623,15 @@ function buildDefaultReplyRoute(args, options = {}) {
|
|
|
622
623
|
const sessionKey = normalizeReplyRouteSessionKey(args.host_session_key, {
|
|
623
624
|
requireOpenClawSessionKey: options.requireOpenClawSessionKey,
|
|
624
625
|
});
|
|
625
|
-
const deliveryContext = {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|| deliveryContext.thread_id);
|
|
626
|
+
const deliveryContext = resolveInstallDefaultReplyDeliveryContext({
|
|
627
|
+
hostKind: options.hostKind === 'openclaw' ? 'openclaw' : 'generic',
|
|
628
|
+
hasSessionKey: !!sessionKey,
|
|
629
|
+
defaultReplyChannel: args.default_reply_channel,
|
|
630
|
+
defaultReplyTo: args.default_reply_to,
|
|
631
|
+
defaultReplyAccountId: args.default_reply_account_id,
|
|
632
|
+
defaultReplyThreadId: args.default_reply_thread_id,
|
|
633
|
+
});
|
|
634
|
+
const hasDeliveryContext = !!deliveryContext;
|
|
635
635
|
if (!sessionKey && !hasDeliveryContext)
|
|
636
636
|
return null;
|
|
637
637
|
return {
|
|
@@ -1204,6 +1204,7 @@ async function handleInstall(args) {
|
|
|
1204
1204
|
const defaultReplyRoute = buildDefaultReplyRoute(args, {
|
|
1205
1205
|
installationId: state.identity?.installation_id || null,
|
|
1206
1206
|
requireOpenClawSessionKey: hostKind === 'openclaw',
|
|
1207
|
+
hostKind,
|
|
1207
1208
|
});
|
|
1208
1209
|
const routeMissingPolicy = normalizeText(args.route_missing_policy)
|
|
1209
1210
|
|| (defaultReplyRoute ? 'use_explicit_default_route' : '');
|