dsh-lark-bot 0.6.0 → 0.7.0
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/README.md +38 -90
- package/SECURITY.md +2 -3
- package/cordis.patch.yml +23 -5
- package/dist/cli.js +191 -997
- package/dist/cli.js.map +1 -1
- package/dist/notify.js +2 -7
- package/dist/notify.js.map +1 -1
- package/dist/plugin.d.ts +677 -90
- package/dist/plugin.js +5544 -705
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
package/dist/notify.js
CHANGED
|
@@ -3,13 +3,6 @@ import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
|
3
3
|
var name = "lark-notify";
|
|
4
4
|
var inject = ["tools"];
|
|
5
5
|
function apply(ctx, config = {}) {
|
|
6
|
-
const endpoint = config.endpoint;
|
|
7
|
-
const token = config.token;
|
|
8
|
-
if (!endpoint || !token) {
|
|
9
|
-
ctx.logger.warn(
|
|
10
|
-
"[lark-notify] endpoint/token not configured; DSH_LARK_NOTIFY_URL / DSH_LARK_NOTIFY_TOKEN must be set in the bridge process env"
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
6
|
ctx.tools.register(
|
|
14
7
|
defineTool({
|
|
15
8
|
name: "lark_notify",
|
|
@@ -52,6 +45,8 @@ function apply(ctx, config = {}) {
|
|
|
52
45
|
]
|
|
53
46
|
},
|
|
54
47
|
async execute(args) {
|
|
48
|
+
const endpoint = config.endpoint ?? process.env.DSH_LARK_NOTIFY_URL;
|
|
49
|
+
const token = config.token ?? process.env.DSH_LARK_NOTIFY_TOKEN;
|
|
55
50
|
if (!endpoint || !token) {
|
|
56
51
|
throw new Error("lark_notify is not configured (endpoint/token missing)");
|
|
57
52
|
}
|
package/dist/notify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/notify/tool.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport { defineTool } from '@deepseek-ai/dsh-tools';\n\n/** Cordis plugin name; referenced by the runtime patch row. */\nexport const name = 'lark-notify';\n\n/** Requires the dsh tool registry before registering. */\nexport const inject = ['tools'];\n\nexport interface Config {\n /** Localhost callback URL of the running bridge process. */\n endpoint?: string;\n /** Shared token authorizing the callback. */\n token?: string;\n}\n\n/**\n * dsh tool that lets the agent push Feishu/Lark messages (optionally with\n * user mentions) to the current chat or another scope known to the bridge.\n * The bridge runs a localhost-only callback server; this plugin is the\n * runtime side of that channel.\n */\nexport function apply(ctx: Context, config: Config = {}) {\n
|
|
1
|
+
{"version":3,"sources":["../src/notify/tool.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport { defineTool } from '@deepseek-ai/dsh-tools';\n\n/** Cordis plugin name; referenced by the runtime patch row. */\nexport const name = 'lark-notify';\n\n/** Requires the dsh tool registry before registering. */\nexport const inject = ['tools'];\n\nexport interface Config {\n /** Localhost callback URL of the running bridge process. */\n endpoint?: string;\n /** Shared token authorizing the callback. */\n token?: string;\n}\n\n/**\n * dsh tool that lets the agent push Feishu/Lark messages (optionally with\n * user mentions) to the current chat or another scope known to the bridge.\n * The bridge runs a localhost-only callback server; this plugin is the\n * runtime side of that channel.\n */\nexport function apply(ctx: Context, config: Config = {}) {\n ctx.tools.register(\n defineTool({\n name: 'lark_notify',\n description:\n 'Send a Feishu/Lark message to the current chat or to another chat/topic scope known to the dsh-lark-bot bridge. Use this when a task finishes and another session, group or member should be notified.',\n parameters: {\n text: {\n type: 'string',\n required: true,\n description: 'The message text to send.',\n },\n scope: {\n type: 'string',\n description:\n 'Target scope key: a chat id (e.g. oc_...) or a topic scope \"chatId:threadId\". Omit to send to the current chat.',\n },\n chat_id: {\n type: 'string',\n description: 'Direct chat id fallback when scope is unknown.',\n },\n mention_user_ids: {\n type: 'array',\n items: { type: 'string' },\n description: 'Feishu/Lark open_ids (ou_...) of users to @mention.',\n },\n },\n output: {\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n ok: { type: 'boolean', required: true },\n chatId: { type: 'string' },\n error: { type: 'string' },\n },\n },\n render: (_args, value) => [\n {\n type: 'text',\n text: value.ok\n ? `Message sent to ${value.chatId ?? 'chat'}`\n : `Message failed: ${value.error ?? 'unknown error'}`,\n },\n ],\n },\n async execute(args) {\n // The callback endpoint/token may be configured by the patch row or\n // injected at runtime: the bridge process sets the env vars when its\n // notify server starts, so read them lazily at execute time.\n const endpoint = config.endpoint ?? process.env.DSH_LARK_NOTIFY_URL;\n const token = config.token ?? process.env.DSH_LARK_NOTIFY_TOKEN;\n if (!endpoint || !token) {\n throw new Error('lark_notify is not configured (endpoint/token missing)');\n }\n const payload: Record<string, unknown> = {\n token,\n text: args.text,\n };\n if (args.scope) payload.scope = args.scope;\n if (args.chat_id) payload.chatId = args.chat_id;\n if (args.mention_user_ids && args.mention_user_ids.length > 0) {\n payload.mentions = args.mention_user_ids.map((userId: string) => ({ userId }));\n }\n const response = await fetch(endpoint, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(payload),\n });\n const body = (await response.json()) as { ok?: boolean; chatId?: string; error?: string };\n return {\n ok: response.ok && body.ok === true,\n ...(body.chatId === undefined ? {} : { chatId: body.chatId }),\n ...(body.error === undefined ? {} : { error: body.error }),\n };\n },\n }),\n );\n}\n"],"mappings":";AACA,SAAS,kBAAkB;AAGpB,IAAM,OAAO;AAGb,IAAM,SAAS,CAAC,OAAO;AAevB,SAAS,MAAM,KAAc,SAAiB,CAAC,GAAG;AACvD,MAAI,MAAM;AAAA,IACR,WAAW;AAAA,MACT,MAAM;AAAA,MACN,aACE;AAAA,MACF,YAAY;AAAA,QACV,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,UAAU;AAAA,UACV,aAAa;AAAA,QACf;AAAA,QACA,OAAO;AAAA,UACL,MAAM;AAAA,UACN,aACE;AAAA,QACJ;AAAA,QACA,SAAS;AAAA,UACP,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,kBAAkB;AAAA,UAChB,MAAM;A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