@otterware/openclaw-otter 0.2.1 → 0.2.2
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/index.js +5 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AsyncResource } from "node:async_hooks";
|
|
2
1
|
import { randomUUID } from "node:crypto";
|
|
3
2
|
import {
|
|
4
3
|
createChannelPluginBase,
|
|
@@ -6,6 +5,7 @@ import {
|
|
|
6
5
|
defineChannelPluginEntry,
|
|
7
6
|
} from "openclaw/plugin-sdk/channel-core";
|
|
8
7
|
import { toInboundMediaFacts } from "openclaw/plugin-sdk/channel-inbound";
|
|
8
|
+
import { runInDetachedAsyncContext } from "openclaw/plugin-sdk/concurrency-runtime";
|
|
9
9
|
import { defineStableChannelIngressIdentity } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
10
10
|
import { resolveAgentWorkspaceDir } from "openclaw/plugin-sdk/agent-runtime";
|
|
11
11
|
import { dispatchGatewayMethod } from "openclaw/plugin-sdk/gateway-method-runtime";
|
|
@@ -26,12 +26,6 @@ import {
|
|
|
26
26
|
tell,
|
|
27
27
|
} from "./otter.js";
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* Where a message sent from Otter starts its run: outside the request that carried it,
|
|
31
|
-
* so the run is the channel's owner's and not that connection's, and outlives it.
|
|
32
|
-
*/
|
|
33
|
-
const receiving = new AsyncResource("otter-inbound");
|
|
34
|
-
|
|
35
29
|
const owner = defineStableChannelIngressIdentity({
|
|
36
30
|
key: "otter-sender",
|
|
37
31
|
normalize: (value) => String(value).trim(),
|
|
@@ -169,7 +163,10 @@ export default defineChannelPluginEntry({
|
|
|
169
163
|
const cfg = context?.getRuntimeConfig?.() ?? api.config;
|
|
170
164
|
if (!isOwnerConfigured(cfg)) throw new Error("otter_not_owner");
|
|
171
165
|
const message = messageOf(params);
|
|
172
|
-
|
|
166
|
+
// The run starts outside the request that carried it (the gateway's context-free root,
|
|
167
|
+
// whatever request loaded this plugin), so it's the channel owner's, not that
|
|
168
|
+
// connection's, and outlives it.
|
|
169
|
+
runInDetachedAsyncContext(() =>
|
|
173
170
|
runDetachedWebhookWork(() => receive(api, cfg, message)).catch((error) =>
|
|
174
171
|
api.logger?.warn?.(`otter: a message from Otter failed: ${String(error)}`),
|
|
175
172
|
),
|
package/package.json
CHANGED