@fased/fased 0.1.36 → 0.1.38
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/config/capability-catalog.json +241 -0
- package/config/dependency-ownership.json +130 -0
- package/config/official-channel-catalog.json +39 -0
- package/dist/agents/tools/web-fetch-utils.js +2 -1
- package/dist/agents/tools/web-fetch-visibility.js +3 -1
- package/dist/brand.js +1 -1
- package/dist/browser/pw-session.js +2 -1
- package/dist/browser/pw-tools-core.state.js +3 -2
- package/dist/browser/runtime-dependency.js +27 -0
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/capabilities/catalog.js +228 -0
- package/dist/cli/components-cli.js +105 -0
- package/dist/cli/hooks-cli.js +1 -1
- package/dist/cli/plugins-cli.js +3 -3
- package/dist/cli/program/register.subclis.js +9 -0
- package/dist/cli/update-cli/update-command.js +1 -1
- package/dist/commands/doctor-capabilities.js +26 -0
- package/dist/commands/doctor.js +2 -0
- package/dist/control-ui/assets/{app-DXYMrRJ9.js → app-JBrTSsNu.js} +1480 -1465
- package/dist/control-ui/assets/{index-iGQkJE0l.js → index-H-2DWAnH.js} +3 -3
- package/dist/control-ui/index.html +1 -1
- package/dist/gateway/method-scopes.js +1 -0
- package/dist/gateway/server-methods/plugins-marketplace.js +1 -1
- package/dist/gateway/server-methods/services.js +8 -0
- package/dist/gateway/server-methods-list.js +1 -0
- package/dist/infra/optional-runtime-dependency.js +46 -0
- package/dist/media/image-ops.js +6 -1
- package/dist/media/input-files.js +11 -2
- package/dist/media/mime.js +6 -1
- package/dist/memory/sqlite-vec.js +7 -1
- package/dist/plugin-sdk/{accounts-VqAX3HJ0.js → accounts-BwkH5bTD.js} +1 -1
- package/dist/plugin-sdk/{accounts-Zgt0NP54.js → accounts-RT6y7n3H.js} +1 -1
- package/dist/plugin-sdk/{actions-lB3PCwsz.js → actions-BrU_JMqM.js} +2 -2
- package/dist/plugin-sdk/{actions-BI5QViLk.js → actions-CUdVHzeJ.js} +2 -2
- package/dist/plugin-sdk/{active-listener-DKZiSaRA.js → active-listener-CE8t5g6l.js} +1 -1
- package/dist/plugin-sdk/{active-listener-D6_pdTMC.js → active-listener-Dx1SEGDn.js} +1 -1
- package/dist/plugin-sdk/{audio-preflight-Dx8J7XhV.js → audio-preflight-BPK8t0tI.js} +22 -22
- package/dist/plugin-sdk/{audio-preflight-CeRstduc.js → audio-preflight-kCa_KGRH.js} +22 -22
- package/dist/plugin-sdk/{audit-BImNOQvk.js → audit-DxB2Kml5.js} +11 -11
- package/dist/plugin-sdk/{audit-CKWkq0Un.js → audit-sSeRDwJb.js} +11 -11
- package/dist/plugin-sdk/channel-plugin-common.js +3 -2
- package/dist/plugin-sdk/{chunk-skAJZWCT.js → chunk-KCxbJLsV.js} +1 -1
- package/dist/plugin-sdk/{chunk-Cjw4712g.js → chunk-M2d7r-Zt.js} +1 -1
- package/dist/plugin-sdk/{chunk-items-Df5811D0.js → chunk-items-DGHUeFuI.js} +1 -1
- package/dist/plugin-sdk/command-status.js +22 -22
- package/dist/plugin-sdk/{commands-registry-5J619bQ2.js → commands-registry-CdT-nl7v.js} +2 -2
- package/dist/plugin-sdk/{commands-registry-CoLAT03J.js → commands-registry-DoWdYAJd.js} +2 -2
- package/dist/plugin-sdk/{common-CSTxewqY.js → common-Cpw-vuuM.js} +1 -1
- package/dist/plugin-sdk/{common-BiF0sTnY.js → common-DJWrErdE.js} +1 -1
- package/dist/plugin-sdk/{config-BxVjLTIv.js → config-C0qggNKQ.js} +7 -7
- package/dist/plugin-sdk/{config-TFokWwvO.js → config-CgwTaper.js} +45 -2
- package/dist/plugin-sdk/{config-DXlISPlx.js → config-DtqAN2L3.js} +45 -2
- package/dist/plugin-sdk/discord.js +2 -1
- package/dist/plugin-sdk/{fetch-guard-DPMynms8.js → fetch-guard-BLdujDnt.js} +1 -1
- package/dist/plugin-sdk/{fetch-guard-COLmW2TM.js → fetch-guard-DTKgMN9f.js} +1 -1
- package/dist/plugin-sdk/{handle-action-C-UndB8E.js → handle-action-B61D85yo.js} +12 -12
- package/dist/plugin-sdk/{handle-action-hhufKxmU.js → handle-action-CjcxGzQD.js} +12 -12
- package/dist/plugin-sdk/index.js +22 -22
- package/dist/plugin-sdk/{login-DL1oBBfL.js → login-CB_nCjX3.js} +3 -3
- package/dist/plugin-sdk/{login-Dnxas1dI.js → login-CzUuDd1v.js} +3 -3
- package/dist/plugin-sdk/{login-qr-CVQsGWKq.js → login-qr-D7MEpFza.js} +3 -3
- package/dist/plugin-sdk/{login-qr-B343JNXJ.js → login-qr-DgxfBFVN.js} +3 -3
- package/dist/plugin-sdk/{manager-BytwRIfK.js → manager-9see0IX5.js} +8 -3
- package/dist/plugin-sdk/{manager-BZjd_PCt.js → manager-D2kZ0Cps.js} +8 -3
- package/dist/plugin-sdk/{markdown-tables-krKiU4cT.js → markdown-tables-CCSD52rA.js} +1 -1
- package/dist/plugin-sdk/{markdown-tables-9rJDQ1X-.js → markdown-tables-DWUNvLrc.js} +1 -1
- package/dist/plugin-sdk/{media-D7ZkWU-A.js → media-C7YT4DeU.js} +13 -4
- package/dist/plugin-sdk/{media-C6C2c9a4.js → media-Cxw-xLGU.js} +13 -4
- package/dist/plugin-sdk/{monitor-BsLMfn3U.js → monitor-6lkdOqhQ.js} +26 -26
- package/dist/plugin-sdk/{monitor-BCxkQBoh.js → monitor-C6Ohw9BA.js} +26 -26
- package/dist/plugin-sdk/{monitor-BzDW50H6.js → monitor-o20KTHIi.js} +29 -29
- package/dist/plugin-sdk/{monitor-CVQNDfhs.js → monitor-rOs3mUol.js} +27 -27
- package/dist/plugin-sdk/{openresponses-http-BB67Z4QM.js → openresponses-http-BJONnUdy.js} +22 -22
- package/dist/plugin-sdk/{openresponses-http-NE76GGhj.js → openresponses-http-DkWqYznu.js} +22 -22
- package/dist/plugin-sdk/{ssrf-u0Ul7okY.js → optional-runtime-dependency-szS49voX.js} +46 -2
- package/dist/plugin-sdk/{outbound-PGNWU6T-.js → outbound-BCxOxdi-.js} +6 -6
- package/dist/plugin-sdk/{outbound-BHWJD9q0.js → outbound-JIwQbpRY.js} +6 -6
- package/dist/plugin-sdk/{outbound-attachment-BVzfhqnk.js → outbound-attachment-C-jSFaEB.js} +1 -1
- package/dist/plugin-sdk/{outbound-attachment-ClMvNW17.js → outbound-attachment-D6tj5Y5H.js} +1 -1
- package/dist/plugin-sdk/{pi-embedded-runner-DQ6UPx6-.js → pi-embedded-runner-DqDy0MWN.js} +72 -60
- package/dist/plugin-sdk/{pi-model-discovery-D51L5E9I.js → pi-model-discovery-DadlvsZW.js} +1 -1
- package/dist/plugin-sdk/{pi-model-discovery-runtime-DxoFm4Vd.js → pi-model-discovery-runtime-C5ssE6EW.js} +1 -1
- package/dist/plugin-sdk/{pi-model-discovery-runtime-DRuh4PNV.js → pi-model-discovery-runtime-DAaOPt64.js} +2 -2
- package/dist/plugin-sdk/{pi-model-discovery-runtime-BTWgkx4x.js → pi-model-discovery-runtime-gd77b0UF.js} +2 -2
- package/dist/plugin-sdk/{pi-model-discovery-CkH5l9X5.js → pi-model-discovery-yifTIDIn.js} +1 -1
- package/dist/plugin-sdk/{pw-ai-DZs6uYRd.js → pw-ai-Boor5vYw.js} +6 -5
- package/dist/plugin-sdk/{pw-ai-Cn-EUPZK.js → pw-ai-sH1Pi-Fh.js} +6 -5
- package/dist/plugin-sdk/{registry-B4HvWzob.js → registry-DNkJsNsz.js} +4 -3
- package/dist/plugin-sdk/{replies-jDMUBsNO.js → replies-fvzN5wnU.js} +2 -2
- package/dist/plugin-sdk/{replies-B_LW9c9f.js → replies-zebgZCHX.js} +2 -2
- package/dist/plugin-sdk/{resolve-route-_YZHbS-z.js → resolve-route-CNhTJG_2.js} +1 -1
- package/dist/plugin-sdk/{resolve-route-DlHzggnG.js → resolve-route-DO0WR4nB.js} +1 -1
- package/dist/plugin-sdk/{resolve-utils-zBhVX3Vx.js → resolve-utils-bixHYDBj.js} +1 -1
- package/dist/plugin-sdk/{retry-policy-DGLs5ebP.js → retry-policy-BLYEgIwP.js} +1 -1
- package/dist/plugin-sdk/{retry-policy-DaodShGa.js → retry-policy-sM01QZT2.js} +1 -1
- package/dist/plugin-sdk/{runtime-Dd0sswuW.js → runtime-BPyuAmka.js} +4 -3
- package/dist/plugin-sdk/{paths-CBCpJ5bu.js → runtime-dependency-Csswyv5r.js} +27 -3
- package/dist/plugin-sdk/{paths-DW-U2r7Y.js → runtime-dependency-Deg_sw2k.js} +36 -12
- package/dist/plugin-sdk/sat-runtime.js +1 -0
- package/dist/plugin-sdk/{send-8remZhsH.js → send-B09HRfHN.js} +6 -6
- package/dist/plugin-sdk/{send-DaaAscWj.js → send-BBYcgXA4.js} +5 -5
- package/dist/plugin-sdk/{send-DFTB0cnx.js → send-BQXQA81e.js} +6 -6
- package/dist/plugin-sdk/{send-CtMVvMJs.js → send-BzFdvD_i.js} +6 -6
- package/dist/plugin-sdk/{send-Di9irjS-.js → send-C3u-F_8s.js} +6 -6
- package/dist/plugin-sdk/{send-Dl88ZKq2.js → send-D3836_UN.js} +6 -6
- package/dist/plugin-sdk/{send-ifgZCHVB.js → send-D7tr-EsH.js} +5 -5
- package/dist/plugin-sdk/{send-DvUpYh0d.js → send-DRGzRdI3.js} +6 -6
- package/dist/plugin-sdk/{send-D2jlPeKH.js → send-DfkPKz_0.js} +4 -4
- package/dist/plugin-sdk/{send-QSt6nbny.js → send-DsxFXrCO.js} +4 -4
- package/dist/plugin-sdk/{session-CknrceVU.js → session-DG_bYisw.js} +2 -2
- package/dist/plugin-sdk/{session-CyRTcJ8N.js → session-EIStzK0E.js} +2 -2
- package/dist/plugin-sdk/{skill-commands-DHxkTA0s.js → skill-commands-CkgGmWBS.js} +2 -2
- package/dist/plugin-sdk/{skill-commands-CLXAG5sU.js → skill-commands-hyZA0LE3.js} +2 -2
- package/dist/plugin-sdk/{slack-Br9c6Yzs.js → slack-BErIh0uj.js} +34 -34
- package/dist/plugin-sdk/{slack-BpJXkwxF.js → slack-CGTAN4UD.js} +34 -34
- package/dist/plugin-sdk/{slack-actions-8tLGt1Ht.js → slack-actions-BQawWGTJ.js} +11 -11
- package/dist/plugin-sdk/{slack-actions-CDSSRo8Y.js → slack-actions-DDMszx56.js} +11 -11
- package/dist/plugin-sdk/slack.js +2 -1
- package/dist/plugin-sdk/src/brand.d.ts +2 -2
- package/dist/plugin-sdk/src/browser/runtime-dependency.d.ts +3 -0
- package/dist/plugin-sdk/src/infra/optional-runtime-dependency.d.ts +6 -0
- package/dist/plugin-sdk/{ssrf-fG4UHKBw.js → ssrf-Cce6LubA.js} +41 -7
- package/dist/plugin-sdk/{status-DoxnzyMC.js → status-CCGFb0f2.js} +76 -64
- package/dist/plugin-sdk/{sticker-cache-zmJ39ByC.js → sticker-cache-CKAkkCoU.js} +3 -3
- package/dist/plugin-sdk/{sticker-cache-D7WcMYsF.js → sticker-cache-wxl1Me2i.js} +3 -3
- package/dist/plugin-sdk/{tables-CkxblF0u.js → tables-BD7H5ug-.js} +1 -1
- package/dist/plugin-sdk/{tables-RBtf8G4P.js → tables-CJE8kB35.js} +1 -1
- package/dist/plugin-sdk/{telegram-actions-DAeYXSLk.js → telegram-actions-BRUNEXMr.js} +25 -25
- package/dist/plugin-sdk/{telegram-actions-BDeS3ocd.js → telegram-actions-r86ntIKR.js} +25 -25
- package/dist/plugin-sdk/telegram.js +2 -1
- package/dist/plugin-sdk/{thread-bindings.lifecycle-DsB94WbE.js → thread-bindings.lifecycle-Djem8FWF.js} +2 -2
- package/dist/plugin-sdk/{thread-bindings.lifecycle-DMhV3TsR.js → thread-bindings.lifecycle-gmHv3hc7.js} +2 -2
- package/dist/plugin-sdk/{thread-bindings.state-DYWpy7hJ.js → thread-bindings.state-CNT2vxm3.js} +2 -2
- package/dist/plugin-sdk/{thread-bindings.state-DG5cBaRn.js → thread-bindings.state-D8kN2X6H.js} +2 -2
- package/dist/plugin-sdk/{web-DJwacWQo.js → web-02I0vmdu.js} +26 -26
- package/dist/plugin-sdk/{web-IJ4NoGPJ.js → web-CXz56wyu.js} +26 -26
- package/dist/plugin-sdk/{whatsapp-actions-DAY8hWpD.js → whatsapp-actions-68Mfs2dJ.js} +12 -12
- package/dist/plugin-sdk/{whatsapp-actions-6opfo-oB.js → whatsapp-actions-DRqtzvTO.js} +12 -12
- package/dist/plugin-sdk/whatsapp.js +2 -1
- package/dist/plugin-sdk/{wsl-B2euLEc2.js → wsl-DcM2PgSS.js} +3 -3
- package/dist/plugin-sdk/{wsl-B8eyviuv.js → wsl-PXrdWitE.js} +3 -3
- package/dist/plugins/update.js +1 -1
- package/dist/tts/tts-core.js +6 -1
- package/dist/wizard/onboarding.finalize.js +9 -0
- package/extensions/acpx/package.json +1 -1
- package/extensions/bluebubbles/package.json +1 -1
- package/extensions/copilot-proxy/package.json +1 -1
- package/extensions/diagnostics-otel/package.json +1 -1
- package/extensions/fased-federation/package.json +1 -1
- package/extensions/google-gemini-cli-auth/package.json +1 -1
- package/extensions/imessage/package.json +1 -1
- package/extensions/irc/package.json +1 -1
- package/extensions/line/package.json +1 -1
- package/extensions/llm-task/package.json +1 -1
- package/extensions/lobster/package.json +1 -1
- package/extensions/matrix/CHANGELOG.md +12 -0
- package/extensions/matrix/package.json +1 -1
- package/extensions/mattermost/package.json +1 -1
- package/extensions/memory-core/package.json +2 -2
- package/extensions/memory-lancedb/package.json +1 -1
- package/extensions/minimax-portal-auth/package.json +1 -1
- package/extensions/msteams/CHANGELOG.md +12 -0
- package/extensions/msteams/package.json +1 -1
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nostr/CHANGELOG.md +12 -0
- package/extensions/nostr/package.json +1 -1
- package/extensions/open-prose/package.json +1 -1
- package/extensions/sat-mining/package.json +1 -1
- package/extensions/signal/package.json +1 -1
- package/extensions/synology-chat/package.json +1 -1
- package/extensions/tlon/package.json +1 -1
- package/extensions/twitch/CHANGELOG.md +12 -0
- package/extensions/twitch/package.json +1 -1
- package/extensions/voice-call/CHANGELOG.md +12 -0
- package/extensions/voice-call/package.json +1 -1
- package/extensions/zalo/CHANGELOG.md +12 -0
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalouser/CHANGELOG.md +12 -0
- package/extensions/zalouser/package.json +1 -1
- package/package.json +22 -15
- package/extensions/feishu/fased.plugin.json +0 -10
- package/extensions/feishu/index.ts +0 -63
- package/extensions/feishu/package.json +0 -33
- package/extensions/feishu/skills/feishu-doc/SKILL.md +0 -211
- package/extensions/feishu/skills/feishu-doc/references/block-types.md +0 -103
- package/extensions/feishu/skills/feishu-drive/SKILL.md +0 -97
- package/extensions/feishu/skills/feishu-perm/SKILL.md +0 -119
- package/extensions/feishu/skills/feishu-wiki/SKILL.md +0 -111
- package/extensions/feishu/src/accounts.ts +0 -159
- package/extensions/feishu/src/bitable.ts +0 -713
- package/extensions/feishu/src/bot.ts +0 -979
- package/extensions/feishu/src/channel.ts +0 -359
- package/extensions/feishu/src/client.ts +0 -118
- package/extensions/feishu/src/config-schema.ts +0 -226
- package/extensions/feishu/src/dedup.ts +0 -54
- package/extensions/feishu/src/directory.ts +0 -177
- package/extensions/feishu/src/doc-schema.ts +0 -122
- package/extensions/feishu/src/docx.ts +0 -998
- package/extensions/feishu/src/drive-schema.ts +0 -46
- package/extensions/feishu/src/drive.ts +0 -232
- package/extensions/feishu/src/dynamic-agent.ts +0 -131
- package/extensions/feishu/src/external-keys.ts +0 -19
- package/extensions/feishu/src/media.ts +0 -447
- package/extensions/feishu/src/mention.ts +0 -133
- package/extensions/feishu/src/monitor.ts +0 -434
- package/extensions/feishu/src/onboarding.ts +0 -430
- package/extensions/feishu/src/outbound.ts +0 -56
- package/extensions/feishu/src/perm-schema.ts +0 -52
- package/extensions/feishu/src/perm.ts +0 -180
- package/extensions/feishu/src/policy.ts +0 -116
- package/extensions/feishu/src/probe.ts +0 -44
- package/extensions/feishu/src/reactions.ts +0 -160
- package/extensions/feishu/src/reply-dispatcher.ts +0 -239
- package/extensions/feishu/src/runtime.ts +0 -14
- package/extensions/feishu/src/send-result.ts +0 -29
- package/extensions/feishu/src/send-target.ts +0 -25
- package/extensions/feishu/src/send.ts +0 -313
- package/extensions/feishu/src/streaming-card.ts +0 -218
- package/extensions/feishu/src/targets.ts +0 -78
- package/extensions/feishu/src/tool-account.ts +0 -58
- package/extensions/feishu/src/tools-config.ts +0 -21
- package/extensions/feishu/src/types.ts +0 -81
- package/extensions/feishu/src/typing.ts +0 -80
- package/extensions/feishu/src/wiki-schema.ts +0 -55
- package/extensions/feishu/src/wiki.ts +0 -237
- package/extensions/googlechat/fased.plugin.json +0 -9
- package/extensions/googlechat/index.ts +0 -19
- package/extensions/googlechat/package.json +0 -37
- package/extensions/googlechat/src/accounts.ts +0 -147
- package/extensions/googlechat/src/actions.ts +0 -176
- package/extensions/googlechat/src/api.ts +0 -282
- package/extensions/googlechat/src/auth.ts +0 -137
- package/extensions/googlechat/src/channel.ts +0 -591
- package/extensions/googlechat/src/monitor.ts +0 -996
- package/extensions/googlechat/src/onboarding.ts +0 -344
- package/extensions/googlechat/src/runtime.ts +0 -14
- package/extensions/googlechat/src/targets.ts +0 -65
- package/extensions/googlechat/src/types.config.ts +0 -3
- package/extensions/googlechat/src/types.ts +0 -73
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import os from "node:os";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { createDedupeCache, createPersistentDedupe } from "fased/plugin-sdk";
|
|
4
|
-
|
|
5
|
-
// Persistent TTL: 24 hours — survives restarts & WebSocket reconnects.
|
|
6
|
-
const DEDUP_TTL_MS = 24 * 60 * 60 * 1000;
|
|
7
|
-
const MEMORY_MAX_SIZE = 1_000;
|
|
8
|
-
const FILE_MAX_ENTRIES = 10_000;
|
|
9
|
-
|
|
10
|
-
const memoryDedupe = createDedupeCache({ ttlMs: DEDUP_TTL_MS, maxSize: MEMORY_MAX_SIZE });
|
|
11
|
-
|
|
12
|
-
function resolveStateDirFromEnv(env: NodeJS.ProcessEnv = process.env): string {
|
|
13
|
-
const stateOverride = env.FASED_STATE_DIR?.trim();
|
|
14
|
-
if (stateOverride) {
|
|
15
|
-
return stateOverride;
|
|
16
|
-
}
|
|
17
|
-
if (env.VITEST || env.NODE_ENV === "test") {
|
|
18
|
-
return path.join(os.tmpdir(), ["fased-vitest", String(process.pid)].join("-"));
|
|
19
|
-
}
|
|
20
|
-
return path.join(os.homedir(), ".fased");
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function resolveNamespaceFilePath(namespace: string): string {
|
|
24
|
-
const safe = namespace.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
25
|
-
return path.join(resolveStateDirFromEnv(), "feishu", "dedup", `${safe}.json`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const persistentDedupe = createPersistentDedupe({
|
|
29
|
-
ttlMs: DEDUP_TTL_MS,
|
|
30
|
-
memoryMaxSize: MEMORY_MAX_SIZE,
|
|
31
|
-
fileMaxEntries: FILE_MAX_ENTRIES,
|
|
32
|
-
resolveFilePath: resolveNamespaceFilePath,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Synchronous dedup — memory only.
|
|
37
|
-
* Kept for backward compatibility; prefer {@link tryRecordMessagePersistent}.
|
|
38
|
-
*/
|
|
39
|
-
export function tryRecordMessage(messageId: string): boolean {
|
|
40
|
-
return !memoryDedupe.check(messageId);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export async function tryRecordMessagePersistent(
|
|
44
|
-
messageId: string,
|
|
45
|
-
namespace = "global",
|
|
46
|
-
log?: (...args: unknown[]) => void,
|
|
47
|
-
): Promise<boolean> {
|
|
48
|
-
return persistentDedupe.checkAndRecord(messageId, {
|
|
49
|
-
namespace,
|
|
50
|
-
onDiskError: (error) => {
|
|
51
|
-
log?.(`feishu-dedup: disk error, falling back to memory: ${String(error)}`);
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import type { FasedAgentConfig } from "fased/plugin-sdk";
|
|
2
|
-
import { resolveFeishuAccount } from "./accounts.js";
|
|
3
|
-
import { createFeishuClient } from "./client.js";
|
|
4
|
-
import { normalizeFeishuTarget } from "./targets.js";
|
|
5
|
-
|
|
6
|
-
export type FeishuDirectoryPeer = {
|
|
7
|
-
kind: "user";
|
|
8
|
-
id: string;
|
|
9
|
-
name?: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type FeishuDirectoryGroup = {
|
|
13
|
-
kind: "group";
|
|
14
|
-
id: string;
|
|
15
|
-
name?: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export async function listFeishuDirectoryPeers(params: {
|
|
19
|
-
cfg: FasedAgentConfig;
|
|
20
|
-
query?: string;
|
|
21
|
-
limit?: number;
|
|
22
|
-
accountId?: string;
|
|
23
|
-
}): Promise<FeishuDirectoryPeer[]> {
|
|
24
|
-
const account = resolveFeishuAccount({ cfg: params.cfg, accountId: params.accountId });
|
|
25
|
-
const feishuCfg = account.config;
|
|
26
|
-
const q = params.query?.trim().toLowerCase() || "";
|
|
27
|
-
const ids = new Set<string>();
|
|
28
|
-
|
|
29
|
-
for (const entry of feishuCfg?.allowFrom ?? []) {
|
|
30
|
-
const trimmed = String(entry).trim();
|
|
31
|
-
if (trimmed && trimmed !== "*") {
|
|
32
|
-
ids.add(trimmed);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
for (const userId of Object.keys(feishuCfg?.dms ?? {})) {
|
|
37
|
-
const trimmed = userId.trim();
|
|
38
|
-
if (trimmed) {
|
|
39
|
-
ids.add(trimmed);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return Array.from(ids)
|
|
44
|
-
.map((raw) => raw.trim())
|
|
45
|
-
.filter(Boolean)
|
|
46
|
-
.map((raw) => normalizeFeishuTarget(raw) ?? raw)
|
|
47
|
-
.filter((id) => (q ? id.toLowerCase().includes(q) : true))
|
|
48
|
-
.slice(0, params.limit && params.limit > 0 ? params.limit : undefined)
|
|
49
|
-
.map((id) => ({ kind: "user" as const, id }));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export async function listFeishuDirectoryGroups(params: {
|
|
53
|
-
cfg: FasedAgentConfig;
|
|
54
|
-
query?: string;
|
|
55
|
-
limit?: number;
|
|
56
|
-
accountId?: string;
|
|
57
|
-
}): Promise<FeishuDirectoryGroup[]> {
|
|
58
|
-
const account = resolveFeishuAccount({ cfg: params.cfg, accountId: params.accountId });
|
|
59
|
-
const feishuCfg = account.config;
|
|
60
|
-
const q = params.query?.trim().toLowerCase() || "";
|
|
61
|
-
const ids = new Set<string>();
|
|
62
|
-
|
|
63
|
-
for (const groupId of Object.keys(feishuCfg?.groups ?? {})) {
|
|
64
|
-
const trimmed = groupId.trim();
|
|
65
|
-
if (trimmed && trimmed !== "*") {
|
|
66
|
-
ids.add(trimmed);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
for (const entry of feishuCfg?.groupAllowFrom ?? []) {
|
|
71
|
-
const trimmed = String(entry).trim();
|
|
72
|
-
if (trimmed && trimmed !== "*") {
|
|
73
|
-
ids.add(trimmed);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return Array.from(ids)
|
|
78
|
-
.map((raw) => raw.trim())
|
|
79
|
-
.filter(Boolean)
|
|
80
|
-
.filter((id) => (q ? id.toLowerCase().includes(q) : true))
|
|
81
|
-
.slice(0, params.limit && params.limit > 0 ? params.limit : undefined)
|
|
82
|
-
.map((id) => ({ kind: "group" as const, id }));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export async function listFeishuDirectoryPeersLive(params: {
|
|
86
|
-
cfg: FasedAgentConfig;
|
|
87
|
-
query?: string;
|
|
88
|
-
limit?: number;
|
|
89
|
-
accountId?: string;
|
|
90
|
-
}): Promise<FeishuDirectoryPeer[]> {
|
|
91
|
-
const account = resolveFeishuAccount({ cfg: params.cfg, accountId: params.accountId });
|
|
92
|
-
if (!account.configured) {
|
|
93
|
-
return listFeishuDirectoryPeers(params);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
const client = createFeishuClient(account);
|
|
98
|
-
const peers: FeishuDirectoryPeer[] = [];
|
|
99
|
-
const limit = params.limit ?? 50;
|
|
100
|
-
|
|
101
|
-
const response = await client.contact.user.list({
|
|
102
|
-
params: {
|
|
103
|
-
page_size: Math.min(limit, 50),
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
if (response.code === 0 && response.data?.items) {
|
|
108
|
-
for (const user of response.data.items) {
|
|
109
|
-
if (user.open_id) {
|
|
110
|
-
const q = params.query?.trim().toLowerCase() || "";
|
|
111
|
-
const name = user.name || "";
|
|
112
|
-
if (!q || user.open_id.toLowerCase().includes(q) || name.toLowerCase().includes(q)) {
|
|
113
|
-
peers.push({
|
|
114
|
-
kind: "user",
|
|
115
|
-
id: user.open_id,
|
|
116
|
-
name: name || undefined,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (peers.length >= limit) {
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return peers;
|
|
127
|
-
} catch {
|
|
128
|
-
return listFeishuDirectoryPeers(params);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export async function listFeishuDirectoryGroupsLive(params: {
|
|
133
|
-
cfg: FasedAgentConfig;
|
|
134
|
-
query?: string;
|
|
135
|
-
limit?: number;
|
|
136
|
-
accountId?: string;
|
|
137
|
-
}): Promise<FeishuDirectoryGroup[]> {
|
|
138
|
-
const account = resolveFeishuAccount({ cfg: params.cfg, accountId: params.accountId });
|
|
139
|
-
if (!account.configured) {
|
|
140
|
-
return listFeishuDirectoryGroups(params);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
try {
|
|
144
|
-
const client = createFeishuClient(account);
|
|
145
|
-
const groups: FeishuDirectoryGroup[] = [];
|
|
146
|
-
const limit = params.limit ?? 50;
|
|
147
|
-
|
|
148
|
-
const response = await client.im.chat.list({
|
|
149
|
-
params: {
|
|
150
|
-
page_size: Math.min(limit, 100),
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
if (response.code === 0 && response.data?.items) {
|
|
155
|
-
for (const chat of response.data.items) {
|
|
156
|
-
if (chat.chat_id) {
|
|
157
|
-
const q = params.query?.trim().toLowerCase() || "";
|
|
158
|
-
const name = chat.name || "";
|
|
159
|
-
if (!q || chat.chat_id.toLowerCase().includes(q) || name.toLowerCase().includes(q)) {
|
|
160
|
-
groups.push({
|
|
161
|
-
kind: "group",
|
|
162
|
-
id: chat.chat_id,
|
|
163
|
-
name: name || undefined,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
if (groups.length >= limit) {
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return groups;
|
|
174
|
-
} catch {
|
|
175
|
-
return listFeishuDirectoryGroups(params);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { Type, type Static } from "@sinclair/typebox";
|
|
2
|
-
|
|
3
|
-
export const FeishuDocSchema = Type.Union([
|
|
4
|
-
Type.Object({
|
|
5
|
-
action: Type.Literal("read"),
|
|
6
|
-
doc_token: Type.String({ description: "Document token (extract from URL /docx/XXX)" }),
|
|
7
|
-
}),
|
|
8
|
-
Type.Object({
|
|
9
|
-
action: Type.Literal("write"),
|
|
10
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
11
|
-
content: Type.String({
|
|
12
|
-
description: "Markdown content to write (replaces entire document content)",
|
|
13
|
-
}),
|
|
14
|
-
}),
|
|
15
|
-
Type.Object({
|
|
16
|
-
action: Type.Literal("append"),
|
|
17
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
18
|
-
content: Type.String({ description: "Markdown content to append to end of document" }),
|
|
19
|
-
}),
|
|
20
|
-
Type.Object({
|
|
21
|
-
action: Type.Literal("create"),
|
|
22
|
-
title: Type.String({ description: "Document title" }),
|
|
23
|
-
folder_token: Type.Optional(Type.String({ description: "Target folder token (optional)" })),
|
|
24
|
-
owner_open_id: Type.Optional(
|
|
25
|
-
Type.String({ description: "Open ID of the user to grant ownership permission" }),
|
|
26
|
-
),
|
|
27
|
-
owner_perm_type: Type.Optional(
|
|
28
|
-
Type.Union([Type.Literal("view"), Type.Literal("edit"), Type.Literal("full_access")], {
|
|
29
|
-
description: "Permission type (default: full_access)",
|
|
30
|
-
}),
|
|
31
|
-
),
|
|
32
|
-
}),
|
|
33
|
-
Type.Object({
|
|
34
|
-
action: Type.Literal("list_blocks"),
|
|
35
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
36
|
-
}),
|
|
37
|
-
Type.Object({
|
|
38
|
-
action: Type.Literal("get_block"),
|
|
39
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
40
|
-
block_id: Type.String({ description: "Block ID (from list_blocks)" }),
|
|
41
|
-
}),
|
|
42
|
-
Type.Object({
|
|
43
|
-
action: Type.Literal("update_block"),
|
|
44
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
45
|
-
block_id: Type.String({ description: "Block ID (from list_blocks)" }),
|
|
46
|
-
content: Type.String({ description: "New text content" }),
|
|
47
|
-
}),
|
|
48
|
-
Type.Object({
|
|
49
|
-
action: Type.Literal("delete_block"),
|
|
50
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
51
|
-
block_id: Type.String({ description: "Block ID" }),
|
|
52
|
-
}),
|
|
53
|
-
Type.Object({
|
|
54
|
-
action: Type.Literal("create_table"),
|
|
55
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
56
|
-
parent_block_id: Type.Optional(
|
|
57
|
-
Type.String({ description: "Parent block ID (default: document root)" }),
|
|
58
|
-
),
|
|
59
|
-
row_size: Type.Integer({ description: "Table row count", minimum: 1 }),
|
|
60
|
-
column_size: Type.Integer({ description: "Table column count", minimum: 1 }),
|
|
61
|
-
column_width: Type.Optional(
|
|
62
|
-
Type.Array(Type.Number({ minimum: 1 }), {
|
|
63
|
-
description: "Column widths in px (length should match column_size)",
|
|
64
|
-
}),
|
|
65
|
-
),
|
|
66
|
-
}),
|
|
67
|
-
Type.Object({
|
|
68
|
-
action: Type.Literal("write_table_cells"),
|
|
69
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
70
|
-
table_block_id: Type.String({ description: "Table block ID" }),
|
|
71
|
-
values: Type.Array(Type.Array(Type.String()), {
|
|
72
|
-
description: "2D matrix values[row][col] to write into table cells",
|
|
73
|
-
minItems: 1,
|
|
74
|
-
}),
|
|
75
|
-
}),
|
|
76
|
-
Type.Object({
|
|
77
|
-
action: Type.Literal("create_table_with_values"),
|
|
78
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
79
|
-
parent_block_id: Type.Optional(
|
|
80
|
-
Type.String({ description: "Parent block ID (default: document root)" }),
|
|
81
|
-
),
|
|
82
|
-
row_size: Type.Integer({ description: "Table row count", minimum: 1 }),
|
|
83
|
-
column_size: Type.Integer({ description: "Table column count", minimum: 1 }),
|
|
84
|
-
column_width: Type.Optional(
|
|
85
|
-
Type.Array(Type.Number({ minimum: 1 }), {
|
|
86
|
-
description: "Column widths in px (length should match column_size)",
|
|
87
|
-
}),
|
|
88
|
-
),
|
|
89
|
-
values: Type.Array(Type.Array(Type.String()), {
|
|
90
|
-
description: "2D matrix values[row][col] to write into table cells",
|
|
91
|
-
minItems: 1,
|
|
92
|
-
}),
|
|
93
|
-
}),
|
|
94
|
-
Type.Object({
|
|
95
|
-
action: Type.Literal("upload_image"),
|
|
96
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
97
|
-
url: Type.Optional(Type.String({ description: "Remote image URL (http/https)" })),
|
|
98
|
-
file_path: Type.Optional(Type.String({ description: "Local image file path" })),
|
|
99
|
-
parent_block_id: Type.Optional(
|
|
100
|
-
Type.String({ description: "Parent block ID (default: document root)" }),
|
|
101
|
-
),
|
|
102
|
-
filename: Type.Optional(Type.String({ description: "Optional filename override" })),
|
|
103
|
-
index: Type.Optional(
|
|
104
|
-
Type.Integer({
|
|
105
|
-
minimum: 0,
|
|
106
|
-
description: "Insert position (0-based index among siblings). Omit to append.",
|
|
107
|
-
}),
|
|
108
|
-
),
|
|
109
|
-
}),
|
|
110
|
-
Type.Object({
|
|
111
|
-
action: Type.Literal("upload_file"),
|
|
112
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
113
|
-
url: Type.Optional(Type.String({ description: "Remote file URL (http/https)" })),
|
|
114
|
-
file_path: Type.Optional(Type.String({ description: "Local file path" })),
|
|
115
|
-
parent_block_id: Type.Optional(
|
|
116
|
-
Type.String({ description: "Parent block ID (default: document root)" }),
|
|
117
|
-
),
|
|
118
|
-
filename: Type.Optional(Type.String({ description: "Optional filename override" })),
|
|
119
|
-
}),
|
|
120
|
-
]);
|
|
121
|
-
|
|
122
|
-
export type FeishuDocParams = Static<typeof FeishuDocSchema>;
|