@openclaw/feishu 2026.5.2 → 2026.5.3-beta.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/dist/accounts-Ba3-WP1z.js +423 -0
- package/dist/api.js +2280 -0
- package/dist/app-registration-B8qc1MCM.js +184 -0
- package/dist/audio-preflight.runtime-BPlzkO3l.js +7 -0
- package/dist/card-interaction-BfRLgvw_.js +96 -0
- package/dist/channel-CSD_Jt8I.js +1668 -0
- package/dist/channel-entry.js +22 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel.runtime-DYsXcD36.js +700 -0
- package/dist/client-DBVoQL5w.js +157 -0
- package/dist/contract-api.js +9 -0
- package/dist/conversation-id-DWS3Ep2A.js +139 -0
- package/dist/directory.static-f3EeoRJd.js +44 -0
- package/dist/drive-C5eJLJr7.js +883 -0
- package/dist/index.js +68 -0
- package/dist/monitor-CT189QfR.js +60 -0
- package/dist/monitor.account-dJV2jO8C.js +4990 -0
- package/dist/monitor.state-DYM02ipp.js +100 -0
- package/dist/policy-D6c-wMPl.js +118 -0
- package/dist/probe-BNzzU_uR.js +149 -0
- package/dist/rolldown-runtime-DUslC3ob.js +14 -0
- package/dist/runtime-CG0DuRCy.js +8 -0
- package/dist/runtime-api.js +14 -0
- package/dist/secret-contract-Dm4Z_zQN.js +119 -0
- package/dist/secret-contract-api.js +2 -0
- package/dist/security-audit-DqJdocrN.js +11 -0
- package/dist/security-audit-shared-ByuMx9cJ.js +38 -0
- package/dist/security-contract-api.js +2 -0
- package/dist/send-DowxxbpH.js +1218 -0
- package/dist/session-conversation-B4nrW-vo.js +27 -0
- package/dist/session-key-api.js +2 -0
- package/dist/setup-api.js +2 -0
- package/dist/setup-entry.js +15 -0
- package/dist/subagent-hooks-C3UhPVLV.js +227 -0
- package/dist/subagent-hooks-api.js +23 -0
- package/dist/targets-JMFJRKSe.js +48 -0
- package/dist/thread-bindings-BmS6TLes.js +222 -0
- package/package.json +15 -6
- package/api.ts +0 -31
- package/channel-entry.ts +0 -20
- package/channel-plugin-api.ts +0 -1
- package/contract-api.ts +0 -16
- package/index.ts +0 -82
- package/runtime-api.ts +0 -55
- package/secret-contract-api.ts +0 -5
- package/security-contract-api.ts +0 -1
- package/session-key-api.ts +0 -1
- package/setup-api.ts +0 -3
- package/setup-entry.test.ts +0 -14
- package/setup-entry.ts +0 -13
- package/src/accounts.test.ts +0 -459
- package/src/accounts.ts +0 -326
- package/src/app-registration.ts +0 -331
- package/src/approval-auth.test.ts +0 -24
- package/src/approval-auth.ts +0 -25
- package/src/async.test.ts +0 -35
- package/src/async.ts +0 -104
- package/src/audio-preflight.runtime.ts +0 -9
- package/src/bitable.test.ts +0 -131
- package/src/bitable.ts +0 -762
- package/src/bot-content.ts +0 -474
- package/src/bot-group-name.test.ts +0 -108
- package/src/bot-runtime-api.ts +0 -12
- package/src/bot-sender-name.ts +0 -125
- package/src/bot.broadcast.test.ts +0 -463
- package/src/bot.card-action.test.ts +0 -577
- package/src/bot.checkBotMentioned.test.ts +0 -265
- package/src/bot.helpers.test.ts +0 -118
- package/src/bot.stripBotMention.test.ts +0 -126
- package/src/bot.test.ts +0 -3040
- package/src/bot.ts +0 -1559
- package/src/card-action.ts +0 -447
- package/src/card-interaction.test.ts +0 -129
- package/src/card-interaction.ts +0 -159
- package/src/card-test-helpers.ts +0 -47
- package/src/card-ux-approval.ts +0 -65
- package/src/card-ux-launcher.test.ts +0 -99
- package/src/card-ux-launcher.ts +0 -121
- package/src/card-ux-shared.ts +0 -33
- package/src/channel-runtime-api.ts +0 -16
- package/src/channel.runtime.ts +0 -47
- package/src/channel.test.ts +0 -959
- package/src/channel.ts +0 -1313
- package/src/chat-schema.ts +0 -25
- package/src/chat.test.ts +0 -196
- package/src/chat.ts +0 -188
- package/src/client.test.ts +0 -433
- package/src/client.ts +0 -290
- package/src/comment-dispatcher-runtime-api.ts +0 -6
- package/src/comment-dispatcher.test.ts +0 -169
- package/src/comment-dispatcher.ts +0 -107
- package/src/comment-handler-runtime-api.ts +0 -3
- package/src/comment-handler.test.ts +0 -486
- package/src/comment-handler.ts +0 -309
- package/src/comment-reaction.test.ts +0 -166
- package/src/comment-reaction.ts +0 -259
- package/src/comment-shared.test.ts +0 -182
- package/src/comment-shared.ts +0 -406
- package/src/comment-target.ts +0 -44
- package/src/config-schema.test.ts +0 -309
- package/src/config-schema.ts +0 -333
- package/src/conversation-id.test.ts +0 -18
- package/src/conversation-id.ts +0 -199
- package/src/dedup-runtime-api.ts +0 -1
- package/src/dedup.ts +0 -141
- package/src/directory.static.ts +0 -61
- package/src/directory.test.ts +0 -136
- package/src/directory.ts +0 -124
- package/src/doc-schema.ts +0 -182
- package/src/docx-batch-insert.test.ts +0 -91
- package/src/docx-batch-insert.ts +0 -223
- package/src/docx-color-text.ts +0 -154
- package/src/docx-table-ops.test.ts +0 -53
- package/src/docx-table-ops.ts +0 -316
- package/src/docx-types.ts +0 -38
- package/src/docx.account-selection.test.ts +0 -79
- package/src/docx.test.ts +0 -685
- package/src/docx.ts +0 -1616
- package/src/drive-schema.ts +0 -92
- package/src/drive.test.ts +0 -1219
- package/src/drive.ts +0 -829
- package/src/dynamic-agent.ts +0 -137
- package/src/event-types.ts +0 -45
- package/src/external-keys.test.ts +0 -20
- package/src/external-keys.ts +0 -19
- package/src/lifecycle.test-support.ts +0 -220
- package/src/media.test.ts +0 -900
- package/src/media.ts +0 -861
- package/src/mention-target.types.ts +0 -5
- package/src/mention.ts +0 -114
- package/src/message-action-contract.ts +0 -13
- package/src/monitor-state-runtime-api.ts +0 -7
- package/src/monitor-transport-runtime-api.ts +0 -7
- package/src/monitor.account.ts +0 -468
- package/src/monitor.acp-init-failure.lifecycle.test-support.ts +0 -219
- package/src/monitor.bot-identity.ts +0 -86
- package/src/monitor.bot-menu-handler.ts +0 -165
- package/src/monitor.bot-menu.lifecycle.test-support.ts +0 -224
- package/src/monitor.bot-menu.test.ts +0 -178
- package/src/monitor.broadcast.reply-once.lifecycle.test-support.ts +0 -264
- package/src/monitor.card-action.lifecycle.test-support.ts +0 -373
- package/src/monitor.cleanup.test.ts +0 -376
- package/src/monitor.comment-notice-handler.ts +0 -105
- package/src/monitor.comment.test.ts +0 -937
- package/src/monitor.comment.ts +0 -1386
- package/src/monitor.lifecycle.test.ts +0 -4
- package/src/monitor.message-handler.ts +0 -339
- package/src/monitor.reaction.lifecycle.test-support.ts +0 -68
- package/src/monitor.reaction.test.ts +0 -713
- package/src/monitor.startup.test.ts +0 -192
- package/src/monitor.startup.ts +0 -74
- package/src/monitor.state.defaults.test.ts +0 -46
- package/src/monitor.state.ts +0 -170
- package/src/monitor.synthetic-error.ts +0 -18
- package/src/monitor.test-mocks.ts +0 -45
- package/src/monitor.transport.ts +0 -424
- package/src/monitor.ts +0 -100
- package/src/monitor.webhook-e2e.test.ts +0 -272
- package/src/monitor.webhook-security.test.ts +0 -264
- package/src/monitor.webhook.test-helpers.ts +0 -116
- package/src/outbound-runtime-api.ts +0 -1
- package/src/outbound.test.ts +0 -935
- package/src/outbound.ts +0 -718
- package/src/perm-schema.ts +0 -52
- package/src/perm.ts +0 -170
- package/src/pins.ts +0 -108
- package/src/policy.test.ts +0 -334
- package/src/policy.ts +0 -236
- package/src/post.test.ts +0 -105
- package/src/post.ts +0 -275
- package/src/probe.test.ts +0 -275
- package/src/probe.ts +0 -166
- package/src/processing-claims.ts +0 -59
- package/src/qr-terminal.ts +0 -1
- package/src/reactions.ts +0 -123
- package/src/reasoning-preview.test.ts +0 -59
- package/src/reasoning-preview.ts +0 -20
- package/src/reply-dispatcher-runtime-api.ts +0 -7
- package/src/reply-dispatcher.test.ts +0 -1144
- package/src/reply-dispatcher.ts +0 -650
- package/src/runtime.ts +0 -9
- package/src/secret-contract.ts +0 -145
- package/src/secret-input.ts +0 -1
- package/src/security-audit-shared.ts +0 -69
- package/src/security-audit.test.ts +0 -61
- package/src/security-audit.ts +0 -1
- package/src/send-result.ts +0 -29
- package/src/send-target.test.ts +0 -80
- package/src/send-target.ts +0 -35
- package/src/send.reply-fallback.test.ts +0 -292
- package/src/send.test.ts +0 -550
- package/src/send.ts +0 -800
- package/src/sequential-key.test.ts +0 -72
- package/src/sequential-key.ts +0 -28
- package/src/sequential-queue.test.ts +0 -92
- package/src/sequential-queue.ts +0 -16
- package/src/session-conversation.ts +0 -42
- package/src/session-route.ts +0 -48
- package/src/setup-core.ts +0 -51
- package/src/setup-surface.test.ts +0 -174
- package/src/setup-surface.ts +0 -581
- package/src/streaming-card.test.ts +0 -190
- package/src/streaming-card.ts +0 -490
- package/src/subagent-hooks.test.ts +0 -603
- package/src/subagent-hooks.ts +0 -397
- package/src/targets.ts +0 -97
- package/src/test-support/lifecycle-test-support.ts +0 -453
- package/src/thread-bindings.test.ts +0 -143
- package/src/thread-bindings.ts +0 -330
- package/src/tool-account-routing.test.ts +0 -187
- package/src/tool-account.test.ts +0 -44
- package/src/tool-account.ts +0 -93
- package/src/tool-factory-test-harness.ts +0 -79
- package/src/tool-result.test.ts +0 -32
- package/src/tool-result.ts +0 -16
- package/src/tools-config.test.ts +0 -21
- package/src/tools-config.ts +0 -22
- package/src/types.ts +0 -104
- package/src/typing.test.ts +0 -144
- package/src/typing.ts +0 -214
- package/src/wiki-schema.ts +0 -55
- package/src/wiki.ts +0 -227
- package/subagent-hooks-api.ts +0 -31
- package/tsconfig.json +0 -16
package/src/probe.test.ts
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { clearProbeCache, FEISHU_PROBE_REQUEST_TIMEOUT_MS, probeFeishu } from "./probe.js";
|
|
3
|
-
|
|
4
|
-
const createFeishuClientMock = vi.hoisted(() => vi.fn());
|
|
5
|
-
|
|
6
|
-
vi.mock("./client.js", () => ({
|
|
7
|
-
createFeishuClient: createFeishuClientMock,
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
const DEFAULT_CREDS = { appId: "cli_123", appSecret: "secret" } as const; // pragma: allowlist secret
|
|
11
|
-
const DEFAULT_SUCCESS_RESPONSE = {
|
|
12
|
-
code: 0,
|
|
13
|
-
data: { pingBotInfo: { botName: "TestBot", botID: "ou_abc123" } },
|
|
14
|
-
} as const;
|
|
15
|
-
const DEFAULT_SUCCESS_RESULT = {
|
|
16
|
-
ok: true,
|
|
17
|
-
appId: "cli_123",
|
|
18
|
-
botName: "TestBot",
|
|
19
|
-
botOpenId: "ou_abc123",
|
|
20
|
-
} as const;
|
|
21
|
-
const BOT1_RESPONSE = {
|
|
22
|
-
code: 0,
|
|
23
|
-
data: { pingBotInfo: { botName: "Bot1", botID: "ou_1" } },
|
|
24
|
-
} as const;
|
|
25
|
-
|
|
26
|
-
function makeRequestFn(response: Record<string, unknown>) {
|
|
27
|
-
return vi.fn().mockResolvedValue(response);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function setupClient(response: Record<string, unknown>) {
|
|
31
|
-
const requestFn = makeRequestFn(response);
|
|
32
|
-
createFeishuClientMock.mockReturnValue({ request: requestFn });
|
|
33
|
-
return requestFn;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function setupSuccessClient() {
|
|
37
|
-
return setupClient(DEFAULT_SUCCESS_RESPONSE);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function expectDefaultSuccessResult(
|
|
41
|
-
creds = DEFAULT_CREDS,
|
|
42
|
-
expected: {
|
|
43
|
-
ok: true;
|
|
44
|
-
appId: string;
|
|
45
|
-
botName: string;
|
|
46
|
-
botOpenId: string;
|
|
47
|
-
} = DEFAULT_SUCCESS_RESULT,
|
|
48
|
-
) {
|
|
49
|
-
const result = await probeFeishu(creds);
|
|
50
|
-
expect(result).toEqual(expected);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async function withFakeTimers(run: () => Promise<void>) {
|
|
54
|
-
vi.useFakeTimers();
|
|
55
|
-
try {
|
|
56
|
-
await run();
|
|
57
|
-
} finally {
|
|
58
|
-
vi.useRealTimers();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function expectErrorResultCached(params: {
|
|
63
|
-
requestFn: ReturnType<typeof vi.fn>;
|
|
64
|
-
expectedError: string;
|
|
65
|
-
ttlMs: number;
|
|
66
|
-
}) {
|
|
67
|
-
createFeishuClientMock.mockReturnValue({ request: params.requestFn });
|
|
68
|
-
|
|
69
|
-
const first = await probeFeishu(DEFAULT_CREDS);
|
|
70
|
-
const second = await probeFeishu(DEFAULT_CREDS);
|
|
71
|
-
expect(first).toMatchObject({ ok: false, error: params.expectedError });
|
|
72
|
-
expect(second).toMatchObject({ ok: false, error: params.expectedError });
|
|
73
|
-
expect(params.requestFn).toHaveBeenCalledTimes(1);
|
|
74
|
-
|
|
75
|
-
vi.advanceTimersByTime(params.ttlMs + 1);
|
|
76
|
-
|
|
77
|
-
await probeFeishu(DEFAULT_CREDS);
|
|
78
|
-
expect(params.requestFn).toHaveBeenCalledTimes(2);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async function expectFreshDefaultProbeAfter(
|
|
82
|
-
requestFn: ReturnType<typeof vi.fn>,
|
|
83
|
-
invalidate: () => void,
|
|
84
|
-
) {
|
|
85
|
-
await probeFeishu(DEFAULT_CREDS);
|
|
86
|
-
expect(requestFn).toHaveBeenCalledTimes(1);
|
|
87
|
-
|
|
88
|
-
invalidate();
|
|
89
|
-
|
|
90
|
-
await probeFeishu(DEFAULT_CREDS);
|
|
91
|
-
expect(requestFn).toHaveBeenCalledTimes(2);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async function readSequentialDefaultProbePair() {
|
|
95
|
-
const first = await probeFeishu(DEFAULT_CREDS);
|
|
96
|
-
return { first, second: await probeFeishu(DEFAULT_CREDS) };
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
describe("probeFeishu", () => {
|
|
100
|
-
beforeEach(() => {
|
|
101
|
-
clearProbeCache();
|
|
102
|
-
vi.restoreAllMocks();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
afterEach(() => {
|
|
106
|
-
clearProbeCache();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("returns error when credentials are missing", async () => {
|
|
110
|
-
const result = await probeFeishu();
|
|
111
|
-
expect(result).toEqual({ ok: false, error: "missing credentials (appId, appSecret)" });
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("returns error when appId is missing", async () => {
|
|
115
|
-
const result = await probeFeishu({ appSecret: "secret" } as never); // pragma: allowlist secret
|
|
116
|
-
expect(result).toEqual({ ok: false, error: "missing credentials (appId, appSecret)" });
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("returns error when appSecret is missing", async () => {
|
|
120
|
-
const result = await probeFeishu({ appId: "cli_123" } as never);
|
|
121
|
-
expect(result).toEqual({ ok: false, error: "missing credentials (appId, appSecret)" });
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it("returns bot info on successful probe", async () => {
|
|
125
|
-
const requestFn = setupSuccessClient();
|
|
126
|
-
|
|
127
|
-
await expectDefaultSuccessResult();
|
|
128
|
-
expect(requestFn).toHaveBeenCalledTimes(1);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("passes the probe timeout to the Feishu request", async () => {
|
|
132
|
-
const requestFn = setupSuccessClient();
|
|
133
|
-
|
|
134
|
-
await probeFeishu(DEFAULT_CREDS);
|
|
135
|
-
|
|
136
|
-
expect(requestFn).toHaveBeenCalledWith(
|
|
137
|
-
expect.objectContaining({
|
|
138
|
-
method: "POST",
|
|
139
|
-
url: "/open-apis/bot/v1/openclaw_bot/ping",
|
|
140
|
-
data: { needBotInfo: true },
|
|
141
|
-
timeout: FEISHU_PROBE_REQUEST_TIMEOUT_MS,
|
|
142
|
-
}),
|
|
143
|
-
);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it("returns timeout error when request exceeds timeout", async () => {
|
|
147
|
-
await withFakeTimers(async () => {
|
|
148
|
-
const requestFn = vi.fn().mockImplementation(() => new Promise(() => {}));
|
|
149
|
-
createFeishuClientMock.mockReturnValue({ request: requestFn });
|
|
150
|
-
|
|
151
|
-
const promise = probeFeishu(DEFAULT_CREDS, { timeoutMs: 1_000 });
|
|
152
|
-
await vi.advanceTimersByTimeAsync(1_000);
|
|
153
|
-
const result = await promise;
|
|
154
|
-
|
|
155
|
-
expect(result).toMatchObject({ ok: false, error: "probe timed out after 1000ms" });
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it("returns aborted when abort signal is already aborted", async () => {
|
|
160
|
-
createFeishuClientMock.mockClear();
|
|
161
|
-
const abortController = new AbortController();
|
|
162
|
-
abortController.abort();
|
|
163
|
-
|
|
164
|
-
const result = await probeFeishu(
|
|
165
|
-
{ appId: "cli_123", appSecret: "secret" }, // pragma: allowlist secret
|
|
166
|
-
{ abortSignal: abortController.signal },
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
expect(result).toMatchObject({ ok: false, error: "probe aborted" });
|
|
170
|
-
expect(createFeishuClientMock).not.toHaveBeenCalled();
|
|
171
|
-
});
|
|
172
|
-
it("returns cached result on subsequent calls within TTL", async () => {
|
|
173
|
-
const requestFn = setupSuccessClient();
|
|
174
|
-
|
|
175
|
-
const { first, second } = await readSequentialDefaultProbePair();
|
|
176
|
-
|
|
177
|
-
expect(first).toEqual(second);
|
|
178
|
-
// Only one API call should have been made
|
|
179
|
-
expect(requestFn).toHaveBeenCalledTimes(1);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("makes a fresh API call after cache expires", async () => {
|
|
183
|
-
await withFakeTimers(async () => {
|
|
184
|
-
const requestFn = setupSuccessClient();
|
|
185
|
-
|
|
186
|
-
await expectFreshDefaultProbeAfter(requestFn, () => {
|
|
187
|
-
vi.advanceTimersByTime(10 * 60 * 1000 + 1);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it("caches failed probe results (API error) for the error TTL", async () => {
|
|
193
|
-
await withFakeTimers(async () => {
|
|
194
|
-
await expectErrorResultCached({
|
|
195
|
-
requestFn: makeRequestFn({ code: 99, msg: "token expired" }),
|
|
196
|
-
expectedError: "API error: token expired",
|
|
197
|
-
ttlMs: 60 * 1000,
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it("caches thrown request errors for the error TTL", async () => {
|
|
203
|
-
await withFakeTimers(async () => {
|
|
204
|
-
await expectErrorResultCached({
|
|
205
|
-
requestFn: vi.fn().mockRejectedValue(new Error("network error")),
|
|
206
|
-
expectedError: "network error",
|
|
207
|
-
ttlMs: 60 * 1000,
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it("caches per account independently", async () => {
|
|
213
|
-
const requestFn = setupClient(BOT1_RESPONSE);
|
|
214
|
-
|
|
215
|
-
await probeFeishu({ appId: "cli_aaa", appSecret: "s1" }); // pragma: allowlist secret
|
|
216
|
-
expect(requestFn).toHaveBeenCalledTimes(1);
|
|
217
|
-
|
|
218
|
-
// Different appId should trigger a new API call
|
|
219
|
-
await probeFeishu({ appId: "cli_bbb", appSecret: "s2" }); // pragma: allowlist secret
|
|
220
|
-
expect(requestFn).toHaveBeenCalledTimes(2);
|
|
221
|
-
|
|
222
|
-
// Same appId + appSecret as first call should return cached
|
|
223
|
-
await probeFeishu({ appId: "cli_aaa", appSecret: "s1" }); // pragma: allowlist secret
|
|
224
|
-
expect(requestFn).toHaveBeenCalledTimes(2);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it("does not share cache between accounts with same appId but different appSecret", async () => {
|
|
228
|
-
const requestFn = setupClient(BOT1_RESPONSE);
|
|
229
|
-
|
|
230
|
-
// First account with appId + secret A
|
|
231
|
-
await probeFeishu({ appId: "cli_shared", appSecret: "secret_aaa" }); // pragma: allowlist secret
|
|
232
|
-
expect(requestFn).toHaveBeenCalledTimes(1);
|
|
233
|
-
|
|
234
|
-
// Second account with same appId but different secret (e.g. after rotation)
|
|
235
|
-
// must NOT reuse the cached result
|
|
236
|
-
await probeFeishu({ appId: "cli_shared", appSecret: "secret_bbb" }); // pragma: allowlist secret
|
|
237
|
-
expect(requestFn).toHaveBeenCalledTimes(2);
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
it("uses accountId for cache key when available", async () => {
|
|
241
|
-
const requestFn = setupClient(BOT1_RESPONSE);
|
|
242
|
-
|
|
243
|
-
// Two accounts with same appId+appSecret but different accountIds are cached separately
|
|
244
|
-
await probeFeishu({ accountId: "acct-1", appId: "cli_123", appSecret: "secret" }); // pragma: allowlist secret
|
|
245
|
-
expect(requestFn).toHaveBeenCalledTimes(1);
|
|
246
|
-
|
|
247
|
-
await probeFeishu({ accountId: "acct-2", appId: "cli_123", appSecret: "secret" }); // pragma: allowlist secret
|
|
248
|
-
expect(requestFn).toHaveBeenCalledTimes(2);
|
|
249
|
-
|
|
250
|
-
// Same accountId should return cached
|
|
251
|
-
await probeFeishu({ accountId: "acct-1", appId: "cli_123", appSecret: "secret" }); // pragma: allowlist secret
|
|
252
|
-
expect(requestFn).toHaveBeenCalledTimes(2);
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
it("clearProbeCache forces fresh API call", async () => {
|
|
256
|
-
const requestFn = setupSuccessClient();
|
|
257
|
-
|
|
258
|
-
await expectFreshDefaultProbeAfter(requestFn, () => {
|
|
259
|
-
clearProbeCache();
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
it("handles response with pingBotInfo in data", async () => {
|
|
264
|
-
setupClient({
|
|
265
|
-
code: 0,
|
|
266
|
-
data: { pingBotInfo: { botName: "DataBot", botID: "ou_data" } },
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
await expectDefaultSuccessResult(DEFAULT_CREDS, {
|
|
270
|
-
...DEFAULT_SUCCESS_RESULT,
|
|
271
|
-
botName: "DataBot",
|
|
272
|
-
botOpenId: "ou_data",
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
});
|
package/src/probe.ts
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
2
|
-
import { raceWithTimeoutAndAbort } from "./async.js";
|
|
3
|
-
import { createFeishuClient, type FeishuClientCredentials } from "./client.js";
|
|
4
|
-
import type { FeishuProbeResult } from "./types.js";
|
|
5
|
-
|
|
6
|
-
/** Cache probe results to reduce repeated health-check calls.
|
|
7
|
-
* Gateway health checks call probeFeishu() every minute; without caching this
|
|
8
|
-
* burns ~43,200 calls/month, easily exceeding Feishu's free-tier quota.
|
|
9
|
-
* Successful bot info is effectively static, while failures are cached briefly
|
|
10
|
-
* to avoid hammering the API during transient outages. */
|
|
11
|
-
const probeCache = new Map<string, { result: FeishuProbeResult; expiresAt: number }>();
|
|
12
|
-
const PROBE_SUCCESS_TTL_MS = 10 * 60 * 1000; // 10 minutes
|
|
13
|
-
const PROBE_ERROR_TTL_MS = 60 * 1000; // 1 minute
|
|
14
|
-
const MAX_PROBE_CACHE_SIZE = 64;
|
|
15
|
-
export const FEISHU_PROBE_REQUEST_TIMEOUT_MS = 10_000;
|
|
16
|
-
export type ProbeFeishuOptions = {
|
|
17
|
-
timeoutMs?: number;
|
|
18
|
-
abortSignal?: AbortSignal;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type FeishuPingResponse = {
|
|
22
|
-
code: number;
|
|
23
|
-
msg?: string;
|
|
24
|
-
data?: { pingBotInfo?: { botID?: string; botName?: string } };
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type FeishuRequestClient = ReturnType<typeof createFeishuClient> & {
|
|
28
|
-
request(params: {
|
|
29
|
-
method: "POST";
|
|
30
|
-
url: string;
|
|
31
|
-
data: Record<string, unknown>;
|
|
32
|
-
timeout: number;
|
|
33
|
-
}): Promise<FeishuPingResponse>;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
function setCachedProbeResult(
|
|
37
|
-
cacheKey: string,
|
|
38
|
-
result: FeishuProbeResult,
|
|
39
|
-
ttlMs: number,
|
|
40
|
-
): FeishuProbeResult {
|
|
41
|
-
probeCache.set(cacheKey, { result, expiresAt: Date.now() + ttlMs });
|
|
42
|
-
if (probeCache.size > MAX_PROBE_CACHE_SIZE) {
|
|
43
|
-
const oldest = probeCache.keys().next().value;
|
|
44
|
-
if (oldest !== undefined) {
|
|
45
|
-
probeCache.delete(oldest);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export async function probeFeishu(
|
|
52
|
-
creds?: FeishuClientCredentials,
|
|
53
|
-
options: ProbeFeishuOptions = {},
|
|
54
|
-
): Promise<FeishuProbeResult> {
|
|
55
|
-
if (!creds?.appId || !creds?.appSecret) {
|
|
56
|
-
return {
|
|
57
|
-
ok: false,
|
|
58
|
-
error: "missing credentials (appId, appSecret)",
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if (options.abortSignal?.aborted) {
|
|
62
|
-
return {
|
|
63
|
-
ok: false,
|
|
64
|
-
appId: creds.appId,
|
|
65
|
-
error: "probe aborted",
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const timeoutMs = options.timeoutMs ?? FEISHU_PROBE_REQUEST_TIMEOUT_MS;
|
|
70
|
-
|
|
71
|
-
// Return cached result if still valid.
|
|
72
|
-
// Use accountId when available; otherwise include appSecret prefix so two
|
|
73
|
-
// accounts sharing the same appId (e.g. after secret rotation) don't
|
|
74
|
-
// pollute each other's cache entry.
|
|
75
|
-
const cacheKey = creds.accountId ?? `${creds.appId}:${creds.appSecret.slice(0, 8)}`;
|
|
76
|
-
const cached = probeCache.get(cacheKey);
|
|
77
|
-
if (cached && cached.expiresAt > Date.now()) {
|
|
78
|
-
return cached.result;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
const client = createFeishuClient(creds) as FeishuRequestClient;
|
|
83
|
-
// Feishu-provided endpoint for OpenClaw, supported on both Feishu (CN)
|
|
84
|
-
// and Lark (international). No OAuth scopes required. Validates
|
|
85
|
-
// credentials and registers the app as an AI agent (智能体).
|
|
86
|
-
const responseResult = await raceWithTimeoutAndAbort<FeishuPingResponse>(
|
|
87
|
-
client.request({
|
|
88
|
-
method: "POST",
|
|
89
|
-
url: "/open-apis/bot/v1/openclaw_bot/ping",
|
|
90
|
-
data: { needBotInfo: true },
|
|
91
|
-
timeout: timeoutMs,
|
|
92
|
-
}),
|
|
93
|
-
{
|
|
94
|
-
timeoutMs,
|
|
95
|
-
abortSignal: options.abortSignal,
|
|
96
|
-
},
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
if (responseResult.status === "aborted") {
|
|
100
|
-
return {
|
|
101
|
-
ok: false,
|
|
102
|
-
appId: creds.appId,
|
|
103
|
-
error: "probe aborted",
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
if (responseResult.status === "timeout") {
|
|
107
|
-
return setCachedProbeResult(
|
|
108
|
-
cacheKey,
|
|
109
|
-
{
|
|
110
|
-
ok: false,
|
|
111
|
-
appId: creds.appId,
|
|
112
|
-
error: `probe timed out after ${timeoutMs}ms`,
|
|
113
|
-
},
|
|
114
|
-
PROBE_ERROR_TTL_MS,
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const response = responseResult.value;
|
|
119
|
-
if (options.abortSignal?.aborted) {
|
|
120
|
-
return {
|
|
121
|
-
ok: false,
|
|
122
|
-
appId: creds.appId,
|
|
123
|
-
error: "probe aborted",
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (response.code !== 0) {
|
|
128
|
-
return setCachedProbeResult(
|
|
129
|
-
cacheKey,
|
|
130
|
-
{
|
|
131
|
-
ok: false,
|
|
132
|
-
appId: creds.appId,
|
|
133
|
-
error: `API error: ${response.msg || `code ${response.code}`}`,
|
|
134
|
-
},
|
|
135
|
-
PROBE_ERROR_TTL_MS,
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const botInfo = response.data?.pingBotInfo;
|
|
140
|
-
return setCachedProbeResult(
|
|
141
|
-
cacheKey,
|
|
142
|
-
{
|
|
143
|
-
ok: true,
|
|
144
|
-
appId: creds.appId,
|
|
145
|
-
botName: botInfo?.botName,
|
|
146
|
-
botOpenId: botInfo?.botID,
|
|
147
|
-
},
|
|
148
|
-
PROBE_SUCCESS_TTL_MS,
|
|
149
|
-
);
|
|
150
|
-
} catch (err) {
|
|
151
|
-
return setCachedProbeResult(
|
|
152
|
-
cacheKey,
|
|
153
|
-
{
|
|
154
|
-
ok: false,
|
|
155
|
-
appId: creds.appId,
|
|
156
|
-
error: formatErrorMessage(err),
|
|
157
|
-
},
|
|
158
|
-
PROBE_ERROR_TTL_MS,
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/** Clear the probe cache (for testing). */
|
|
164
|
-
export function clearProbeCache(): void {
|
|
165
|
-
probeCache.clear();
|
|
166
|
-
}
|
package/src/processing-claims.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const EVENT_DEDUP_TTL_MS = 5 * 60 * 1000;
|
|
2
|
-
const EVENT_MEMORY_MAX_SIZE = 2_000;
|
|
3
|
-
|
|
4
|
-
const processingClaims = new Map<string, number>();
|
|
5
|
-
|
|
6
|
-
function resolveEventDedupeKey(
|
|
7
|
-
namespace: string,
|
|
8
|
-
messageId: string | undefined | null,
|
|
9
|
-
): string | null {
|
|
10
|
-
const trimmed = messageId?.trim();
|
|
11
|
-
return trimmed ? `${namespace}:${trimmed}` : null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function pruneProcessingClaims(now: number): void {
|
|
15
|
-
const cutoff = now - EVENT_DEDUP_TTL_MS;
|
|
16
|
-
for (const [key, seenAt] of processingClaims) {
|
|
17
|
-
if (seenAt < cutoff) {
|
|
18
|
-
processingClaims.delete(key);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
while (processingClaims.size > EVENT_MEMORY_MAX_SIZE) {
|
|
22
|
-
const oldestKey = processingClaims.keys().next().value;
|
|
23
|
-
if (!oldestKey) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
processingClaims.delete(oldestKey);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function tryBeginFeishuMessageProcessing(
|
|
31
|
-
messageId: string | undefined | null,
|
|
32
|
-
namespace = "global",
|
|
33
|
-
): boolean {
|
|
34
|
-
const key = resolveEventDedupeKey(namespace, messageId);
|
|
35
|
-
if (!key) {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
const now = Date.now();
|
|
39
|
-
pruneProcessingClaims(now);
|
|
40
|
-
if (processingClaims.has(key)) {
|
|
41
|
-
processingClaims.delete(key);
|
|
42
|
-
processingClaims.set(key, now);
|
|
43
|
-
pruneProcessingClaims(now);
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
processingClaims.set(key, now);
|
|
47
|
-
pruneProcessingClaims(now);
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function releaseFeishuMessageProcessing(
|
|
52
|
-
messageId: string | undefined | null,
|
|
53
|
-
namespace = "global",
|
|
54
|
-
): void {
|
|
55
|
-
const key = resolveEventDedupeKey(namespace, messageId);
|
|
56
|
-
if (key) {
|
|
57
|
-
processingClaims.delete(key);
|
|
58
|
-
}
|
|
59
|
-
}
|
package/src/qr-terminal.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { renderQrTerminal } from "openclaw/plugin-sdk/media-runtime";
|
package/src/reactions.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import type { ClawdbotConfig } from "../runtime-api.js";
|
|
2
|
-
import { resolveFeishuRuntimeAccount } from "./accounts.js";
|
|
3
|
-
import { createFeishuClient } from "./client.js";
|
|
4
|
-
|
|
5
|
-
type FeishuReaction = {
|
|
6
|
-
reactionId: string;
|
|
7
|
-
emojiType: string;
|
|
8
|
-
operatorType: "app" | "user";
|
|
9
|
-
operatorId: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function resolveConfiguredFeishuClient(params: { cfg: ClawdbotConfig; accountId?: string }) {
|
|
13
|
-
const account = resolveFeishuRuntimeAccount(params);
|
|
14
|
-
if (!account.configured) {
|
|
15
|
-
throw new Error(`Feishu account "${account.accountId}" not configured`);
|
|
16
|
-
}
|
|
17
|
-
return createFeishuClient(account);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function assertFeishuReactionApiSuccess(response: { code?: number; msg?: string }, action: string) {
|
|
21
|
-
if (response.code !== 0) {
|
|
22
|
-
throw new Error(`Feishu ${action} failed: ${response.msg || `code ${response.code}`}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Add a reaction (emoji) to a message.
|
|
28
|
-
* @param emojiType - Feishu emoji type, e.g., "SMILE", "THUMBSUP", "HEART"
|
|
29
|
-
* @see https://open.feishu.cn/document/server-docs/im-v1/message-reaction/emojis-introduce
|
|
30
|
-
*/
|
|
31
|
-
export async function addReactionFeishu(params: {
|
|
32
|
-
cfg: ClawdbotConfig;
|
|
33
|
-
messageId: string;
|
|
34
|
-
emojiType: string;
|
|
35
|
-
accountId?: string;
|
|
36
|
-
}): Promise<{ reactionId: string }> {
|
|
37
|
-
const { cfg, messageId, emojiType, accountId } = params;
|
|
38
|
-
const client = resolveConfiguredFeishuClient({ cfg, accountId });
|
|
39
|
-
|
|
40
|
-
const response = (await client.im.messageReaction.create({
|
|
41
|
-
path: { message_id: messageId },
|
|
42
|
-
data: {
|
|
43
|
-
reaction_type: {
|
|
44
|
-
emoji_type: emojiType,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
})) as {
|
|
48
|
-
code?: number;
|
|
49
|
-
msg?: string;
|
|
50
|
-
data?: { reaction_id?: string };
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
assertFeishuReactionApiSuccess(response, "add reaction");
|
|
54
|
-
|
|
55
|
-
const reactionId = response.data?.reaction_id;
|
|
56
|
-
if (!reactionId) {
|
|
57
|
-
throw new Error("Feishu add reaction failed: no reaction_id returned");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return { reactionId };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Remove a reaction from a message.
|
|
65
|
-
*/
|
|
66
|
-
export async function removeReactionFeishu(params: {
|
|
67
|
-
cfg: ClawdbotConfig;
|
|
68
|
-
messageId: string;
|
|
69
|
-
reactionId: string;
|
|
70
|
-
accountId?: string;
|
|
71
|
-
}): Promise<void> {
|
|
72
|
-
const { cfg, messageId, reactionId, accountId } = params;
|
|
73
|
-
const client = resolveConfiguredFeishuClient({ cfg, accountId });
|
|
74
|
-
|
|
75
|
-
const response = (await client.im.messageReaction.delete({
|
|
76
|
-
path: {
|
|
77
|
-
message_id: messageId,
|
|
78
|
-
reaction_id: reactionId,
|
|
79
|
-
},
|
|
80
|
-
})) as { code?: number; msg?: string };
|
|
81
|
-
|
|
82
|
-
assertFeishuReactionApiSuccess(response, "remove reaction");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* List all reactions for a message.
|
|
87
|
-
*/
|
|
88
|
-
export async function listReactionsFeishu(params: {
|
|
89
|
-
cfg: ClawdbotConfig;
|
|
90
|
-
messageId: string;
|
|
91
|
-
emojiType?: string;
|
|
92
|
-
accountId?: string;
|
|
93
|
-
}): Promise<FeishuReaction[]> {
|
|
94
|
-
const { cfg, messageId, emojiType, accountId } = params;
|
|
95
|
-
const client = resolveConfiguredFeishuClient({ cfg, accountId });
|
|
96
|
-
|
|
97
|
-
const response = (await client.im.messageReaction.list({
|
|
98
|
-
path: { message_id: messageId },
|
|
99
|
-
params: emojiType ? { reaction_type: emojiType } : undefined,
|
|
100
|
-
})) as {
|
|
101
|
-
code?: number;
|
|
102
|
-
msg?: string;
|
|
103
|
-
data?: {
|
|
104
|
-
items?: Array<{
|
|
105
|
-
reaction_id?: string;
|
|
106
|
-
reaction_type?: { emoji_type?: string };
|
|
107
|
-
operator_type?: string;
|
|
108
|
-
operator_id?: { open_id?: string; user_id?: string; union_id?: string };
|
|
109
|
-
}>;
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
assertFeishuReactionApiSuccess(response, "list reactions");
|
|
114
|
-
|
|
115
|
-
const items = response.data?.items ?? [];
|
|
116
|
-
return items.map((item) => ({
|
|
117
|
-
reactionId: item.reaction_id ?? "",
|
|
118
|
-
emojiType: item.reaction_type?.emoji_type ?? "",
|
|
119
|
-
operatorType: item.operator_type === "app" ? "app" : "user",
|
|
120
|
-
operatorId:
|
|
121
|
-
item.operator_id?.open_id ?? item.operator_id?.user_id ?? item.operator_id?.union_id ?? "",
|
|
122
|
-
}));
|
|
123
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { resolveFeishuReasoningPreviewEnabled } from "./reasoning-preview.js";
|
|
3
|
-
|
|
4
|
-
const { loadSessionStoreMock } = vi.hoisted(() => ({
|
|
5
|
-
loadSessionStoreMock: vi.fn(),
|
|
6
|
-
}));
|
|
7
|
-
|
|
8
|
-
vi.mock("./bot-runtime-api.js", async () => {
|
|
9
|
-
const actual =
|
|
10
|
-
await vi.importActual<typeof import("./bot-runtime-api.js")>("./bot-runtime-api.js");
|
|
11
|
-
return {
|
|
12
|
-
...actual,
|
|
13
|
-
loadSessionStore: loadSessionStoreMock,
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe("resolveFeishuReasoningPreviewEnabled", () => {
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
vi.clearAllMocks();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("enables previews only for stream reasoning sessions", () => {
|
|
23
|
-
loadSessionStoreMock.mockReturnValue({
|
|
24
|
-
"agent:main:feishu:dm:ou_sender_1": { reasoningLevel: "stream" },
|
|
25
|
-
"agent:main:feishu:dm:ou_sender_2": { reasoningLevel: "on" },
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
expect(
|
|
29
|
-
resolveFeishuReasoningPreviewEnabled({
|
|
30
|
-
storePath: "/tmp/feishu-sessions.json",
|
|
31
|
-
sessionKey: "agent:main:feishu:dm:ou_sender_1",
|
|
32
|
-
}),
|
|
33
|
-
).toBe(true);
|
|
34
|
-
expect(
|
|
35
|
-
resolveFeishuReasoningPreviewEnabled({
|
|
36
|
-
storePath: "/tmp/feishu-sessions.json",
|
|
37
|
-
sessionKey: "agent:main:feishu:dm:ou_sender_2",
|
|
38
|
-
}),
|
|
39
|
-
).toBe(false);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("returns false for missing sessions or load failures", () => {
|
|
43
|
-
loadSessionStoreMock.mockImplementationOnce(() => {
|
|
44
|
-
throw new Error("disk unavailable");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
expect(
|
|
48
|
-
resolveFeishuReasoningPreviewEnabled({
|
|
49
|
-
storePath: "/tmp/feishu-sessions.json",
|
|
50
|
-
sessionKey: "agent:main:feishu:dm:ou_sender_1",
|
|
51
|
-
}),
|
|
52
|
-
).toBe(false);
|
|
53
|
-
expect(
|
|
54
|
-
resolveFeishuReasoningPreviewEnabled({
|
|
55
|
-
storePath: "/tmp/feishu-sessions.json",
|
|
56
|
-
}),
|
|
57
|
-
).toBe(false);
|
|
58
|
-
});
|
|
59
|
-
});
|
package/src/reasoning-preview.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { loadSessionStore, resolveSessionStoreEntry } from "./bot-runtime-api.js";
|
|
2
|
-
|
|
3
|
-
export function resolveFeishuReasoningPreviewEnabled(params: {
|
|
4
|
-
storePath: string;
|
|
5
|
-
sessionKey?: string;
|
|
6
|
-
}): boolean {
|
|
7
|
-
if (!params.sessionKey) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
const store = loadSessionStore(params.storePath, { skipCache: true });
|
|
13
|
-
return (
|
|
14
|
-
resolveSessionStoreEntry({ store, sessionKey: params.sessionKey }).existing
|
|
15
|
-
?.reasoningLevel === "stream"
|
|
16
|
-
);
|
|
17
|
-
} catch {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|