@alfe.ai/openclaw-teams 0.0.1
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/index.cjs +2 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/plugin.cjs +129 -0
- package/dist/plugin.d.cts +42 -0
- package/dist/plugin.d.cts.map +1 -0
- package/dist/plugin.d.ts +42 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +131 -0
- package/dist/plugin.js.map +1 -0
- package/openclaw.plugin.json +12 -0
- package/package.json +40 -0
package/dist/index.cjs
ADDED
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/plugin.cjs
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
let _sinclair_typebox = require("@sinclair/typebox");
|
|
2
|
+
let _alfe_ai_config = require("@alfe.ai/config");
|
|
3
|
+
let _alfe_ai_agent_api_client = require("@alfe.ai/agent-api-client");
|
|
4
|
+
//#region src/plugin.ts
|
|
5
|
+
/**
|
|
6
|
+
* @alfe/openclaw-teams — OpenClaw native plugin
|
|
7
|
+
*
|
|
8
|
+
* Registers Microsoft Teams tools with OpenClaw. Tools call the Alfe
|
|
9
|
+
* agent API via @alfe.ai/agent-api-client.
|
|
10
|
+
*
|
|
11
|
+
* This plugin provides:
|
|
12
|
+
* - teams_send_message — send a text message to a Teams conversation
|
|
13
|
+
* - teams_send_card — send an adaptive card to a Teams conversation
|
|
14
|
+
* - teams_list_channels — list Teams channels the bot has access to
|
|
15
|
+
*/
|
|
16
|
+
function ok(data) {
|
|
17
|
+
return {
|
|
18
|
+
content: [{
|
|
19
|
+
type: "text",
|
|
20
|
+
text: JSON.stringify(data)
|
|
21
|
+
}],
|
|
22
|
+
details: data
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function errResult(message) {
|
|
26
|
+
return {
|
|
27
|
+
content: [{
|
|
28
|
+
type: "text",
|
|
29
|
+
text: JSON.stringify({ error: message })
|
|
30
|
+
}],
|
|
31
|
+
details: { error: message }
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function defineTool(def) {
|
|
35
|
+
return {
|
|
36
|
+
name: def.name,
|
|
37
|
+
description: def.description,
|
|
38
|
+
label: def.name,
|
|
39
|
+
parameters: def.parameters,
|
|
40
|
+
execute: async (_toolCallId, params) => {
|
|
41
|
+
try {
|
|
42
|
+
return ok(await def.handler(params));
|
|
43
|
+
} catch (e) {
|
|
44
|
+
return errResult(e.message);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
let client = null;
|
|
50
|
+
function getClient() {
|
|
51
|
+
if (!client) throw new Error("Teams plugin not initialized — no API client");
|
|
52
|
+
return client;
|
|
53
|
+
}
|
|
54
|
+
const teamsTools = [
|
|
55
|
+
defineTool({
|
|
56
|
+
name: "teams_send_message",
|
|
57
|
+
description: "Send a text message to a Microsoft Teams conversation. You need the conversationId from an inbound Teams message or from teams_list_channels.",
|
|
58
|
+
parameters: _sinclair_typebox.Type.Object({
|
|
59
|
+
conversationId: _sinclair_typebox.Type.String({ description: "The Teams conversation ID to send the message to" }),
|
|
60
|
+
text: _sinclair_typebox.Type.String({ description: "The message text to send" })
|
|
61
|
+
}),
|
|
62
|
+
handler: async (params) => {
|
|
63
|
+
const { conversationId, text } = params;
|
|
64
|
+
return getClient().sendTeamsMessage({
|
|
65
|
+
conversationId,
|
|
66
|
+
text
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
defineTool({
|
|
71
|
+
name: "teams_send_card",
|
|
72
|
+
description: "Send an Adaptive Card to a Microsoft Teams conversation. Adaptive Cards support rich formatting, inputs, and actions. Pass a valid Adaptive Card JSON object.",
|
|
73
|
+
parameters: _sinclair_typebox.Type.Object({
|
|
74
|
+
conversationId: _sinclair_typebox.Type.String({ description: "The Teams conversation ID to send the card to" }),
|
|
75
|
+
adaptiveCard: _sinclair_typebox.Type.Object({}, {
|
|
76
|
+
description: "Adaptive Card JSON payload (see https://adaptivecards.io)",
|
|
77
|
+
additionalProperties: true
|
|
78
|
+
})
|
|
79
|
+
}),
|
|
80
|
+
handler: async (params) => {
|
|
81
|
+
const { conversationId, adaptiveCard } = params;
|
|
82
|
+
return getClient().sendTeamsMessage({
|
|
83
|
+
conversationId,
|
|
84
|
+
adaptiveCard
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}),
|
|
88
|
+
defineTool({
|
|
89
|
+
name: "teams_list_channels",
|
|
90
|
+
description: "List Microsoft Teams channels and conversations that the bot has access to. Returns channel IDs that can be used with teams_send_message and teams_send_card.",
|
|
91
|
+
parameters: _sinclair_typebox.Type.Object({}),
|
|
92
|
+
handler: async () => {
|
|
93
|
+
return getClient().listTeamsChannels();
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
];
|
|
97
|
+
const plugin = {
|
|
98
|
+
id: "@alfe.ai/openclaw-teams",
|
|
99
|
+
name: "Alfe Teams Plugin",
|
|
100
|
+
description: "Microsoft Teams integration — send messages and adaptive cards",
|
|
101
|
+
version: "0.0.1",
|
|
102
|
+
activate(api) {
|
|
103
|
+
const log = api.logger;
|
|
104
|
+
for (const tool of teamsTools) api.registerTool(tool);
|
|
105
|
+
log.info(`Registered ${String(teamsTools.length)} Teams tools: ${teamsTools.map((t) => t.name).join(", ")}`);
|
|
106
|
+
if (!globalThis.__teamsPluginActivated) {
|
|
107
|
+
globalThis.__teamsPluginActivated = true;
|
|
108
|
+
log.info("Alfe Teams plugin activating...");
|
|
109
|
+
try {
|
|
110
|
+
const config = (0, _alfe_ai_config.resolveConfig)();
|
|
111
|
+
client = new _alfe_ai_agent_api_client.AgentApiClient({
|
|
112
|
+
apiKey: config.apiKey,
|
|
113
|
+
apiUrl: config.apiUrl
|
|
114
|
+
});
|
|
115
|
+
} catch (err) {
|
|
116
|
+
log.error(`Failed to resolve config: ${err instanceof Error ? err.message : String(err)}`);
|
|
117
|
+
log.warn("Teams tools will fail — no API config available");
|
|
118
|
+
}
|
|
119
|
+
log.info("Alfe Teams plugin activated");
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
deactivate(api) {
|
|
123
|
+
globalThis.__teamsPluginActivated = false;
|
|
124
|
+
client = null;
|
|
125
|
+
api.logger.info("Alfe Teams plugin deactivated");
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
//#endregion
|
|
129
|
+
module.exports = plugin;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { TSchema } from "@sinclair/typebox";
|
|
2
|
+
|
|
3
|
+
//#region src/plugin.d.ts
|
|
4
|
+
|
|
5
|
+
interface Logger {
|
|
6
|
+
info(msg: string, ...args: unknown[]): void;
|
|
7
|
+
warn(msg: string, ...args: unknown[]): void;
|
|
8
|
+
error(msg: string, ...args: unknown[]): void;
|
|
9
|
+
debug(msg: string, ...args: unknown[]): void;
|
|
10
|
+
}
|
|
11
|
+
interface OpenClawPluginApi {
|
|
12
|
+
logger: Logger;
|
|
13
|
+
registerTool(tool: ToolDef): void;
|
|
14
|
+
registerGatewayMethod(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;
|
|
15
|
+
on(event: string, handler: (...args: unknown[]) => void | Promise<void>, options?: {
|
|
16
|
+
priority?: number;
|
|
17
|
+
}): void;
|
|
18
|
+
}
|
|
19
|
+
interface ToolDef {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
label: string;
|
|
23
|
+
parameters: TSchema;
|
|
24
|
+
execute: (toolCallId: string, params: Record<string, unknown>) => Promise<{
|
|
25
|
+
content: {
|
|
26
|
+
type: "text";
|
|
27
|
+
text: string;
|
|
28
|
+
}[];
|
|
29
|
+
details: unknown;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
declare const plugin: {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
version: string;
|
|
37
|
+
activate(api: OpenClawPluginApi): void;
|
|
38
|
+
deactivate(api: OpenClawPluginApi): void;
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { plugin as default };
|
|
42
|
+
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;UAgBU,MAAA,CAgBO;MAIH,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;MAC0B,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;OAA4B,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;EAAO,KAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;AAAA;UAdjE,iBAAA,CAoJT;QA7Be,EAtHN,MAsHM;cAwBE,CAAA,IAAA,EA7IG,OA6IH,CAAA,EAAA,IAAA;EAAiB,qBAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GA5IoC,OA4IpC,CAAA,OAAA,CAAA,CAAA,EAAA,IAAA;4DA3IyB;;;;UAKlD,OAAA;;;;cAII;wCAC0B,4BAA4B;;;;;;;;cAmG9D;;;;;gBAMU;kBAwBE"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { TSchema } from "@sinclair/typebox";
|
|
2
|
+
|
|
3
|
+
//#region src/plugin.d.ts
|
|
4
|
+
|
|
5
|
+
interface Logger {
|
|
6
|
+
info(msg: string, ...args: unknown[]): void;
|
|
7
|
+
warn(msg: string, ...args: unknown[]): void;
|
|
8
|
+
error(msg: string, ...args: unknown[]): void;
|
|
9
|
+
debug(msg: string, ...args: unknown[]): void;
|
|
10
|
+
}
|
|
11
|
+
interface OpenClawPluginApi {
|
|
12
|
+
logger: Logger;
|
|
13
|
+
registerTool(tool: ToolDef): void;
|
|
14
|
+
registerGatewayMethod(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;
|
|
15
|
+
on(event: string, handler: (...args: unknown[]) => void | Promise<void>, options?: {
|
|
16
|
+
priority?: number;
|
|
17
|
+
}): void;
|
|
18
|
+
}
|
|
19
|
+
interface ToolDef {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
label: string;
|
|
23
|
+
parameters: TSchema;
|
|
24
|
+
execute: (toolCallId: string, params: Record<string, unknown>) => Promise<{
|
|
25
|
+
content: {
|
|
26
|
+
type: "text";
|
|
27
|
+
text: string;
|
|
28
|
+
}[];
|
|
29
|
+
details: unknown;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
declare const plugin: {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
version: string;
|
|
37
|
+
activate(api: OpenClawPluginApi): void;
|
|
38
|
+
deactivate(api: OpenClawPluginApi): void;
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { plugin as default };
|
|
42
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;UAgBU,MAAA,CAgBO;MAIH,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;MAC0B,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;OAA4B,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;EAAO,KAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;AAAA;UAdjE,iBAAA,CAoJT;QA7Be,EAtHN,MAsHM;cAwBE,CAAA,IAAA,EA7IG,OA6IH,CAAA,EAAA,IAAA;EAAiB,qBAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GA5IoC,OA4IpC,CAAA,OAAA,CAAA,CAAA,EAAA,IAAA;4DA3IyB;;;;UAKlD,OAAA;;;;cAII;wCAC0B,4BAA4B;;;;;;;;cAmG9D;;;;;gBAMU;kBAwBE"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { resolveConfig } from "@alfe.ai/config";
|
|
3
|
+
import { AgentApiClient } from "@alfe.ai/agent-api-client";
|
|
4
|
+
//#region src/plugin.ts
|
|
5
|
+
/**
|
|
6
|
+
* @alfe/openclaw-teams — OpenClaw native plugin
|
|
7
|
+
*
|
|
8
|
+
* Registers Microsoft Teams tools with OpenClaw. Tools call the Alfe
|
|
9
|
+
* agent API via @alfe.ai/agent-api-client.
|
|
10
|
+
*
|
|
11
|
+
* This plugin provides:
|
|
12
|
+
* - teams_send_message — send a text message to a Teams conversation
|
|
13
|
+
* - teams_send_card — send an adaptive card to a Teams conversation
|
|
14
|
+
* - teams_list_channels — list Teams channels the bot has access to
|
|
15
|
+
*/
|
|
16
|
+
function ok(data) {
|
|
17
|
+
return {
|
|
18
|
+
content: [{
|
|
19
|
+
type: "text",
|
|
20
|
+
text: JSON.stringify(data)
|
|
21
|
+
}],
|
|
22
|
+
details: data
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function errResult(message) {
|
|
26
|
+
return {
|
|
27
|
+
content: [{
|
|
28
|
+
type: "text",
|
|
29
|
+
text: JSON.stringify({ error: message })
|
|
30
|
+
}],
|
|
31
|
+
details: { error: message }
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function defineTool(def) {
|
|
35
|
+
return {
|
|
36
|
+
name: def.name,
|
|
37
|
+
description: def.description,
|
|
38
|
+
label: def.name,
|
|
39
|
+
parameters: def.parameters,
|
|
40
|
+
execute: async (_toolCallId, params) => {
|
|
41
|
+
try {
|
|
42
|
+
return ok(await def.handler(params));
|
|
43
|
+
} catch (e) {
|
|
44
|
+
return errResult(e.message);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
let client = null;
|
|
50
|
+
function getClient() {
|
|
51
|
+
if (!client) throw new Error("Teams plugin not initialized — no API client");
|
|
52
|
+
return client;
|
|
53
|
+
}
|
|
54
|
+
const teamsTools = [
|
|
55
|
+
defineTool({
|
|
56
|
+
name: "teams_send_message",
|
|
57
|
+
description: "Send a text message to a Microsoft Teams conversation. You need the conversationId from an inbound Teams message or from teams_list_channels.",
|
|
58
|
+
parameters: Type.Object({
|
|
59
|
+
conversationId: Type.String({ description: "The Teams conversation ID to send the message to" }),
|
|
60
|
+
text: Type.String({ description: "The message text to send" })
|
|
61
|
+
}),
|
|
62
|
+
handler: async (params) => {
|
|
63
|
+
const { conversationId, text } = params;
|
|
64
|
+
return getClient().sendTeamsMessage({
|
|
65
|
+
conversationId,
|
|
66
|
+
text
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
defineTool({
|
|
71
|
+
name: "teams_send_card",
|
|
72
|
+
description: "Send an Adaptive Card to a Microsoft Teams conversation. Adaptive Cards support rich formatting, inputs, and actions. Pass a valid Adaptive Card JSON object.",
|
|
73
|
+
parameters: Type.Object({
|
|
74
|
+
conversationId: Type.String({ description: "The Teams conversation ID to send the card to" }),
|
|
75
|
+
adaptiveCard: Type.Object({}, {
|
|
76
|
+
description: "Adaptive Card JSON payload (see https://adaptivecards.io)",
|
|
77
|
+
additionalProperties: true
|
|
78
|
+
})
|
|
79
|
+
}),
|
|
80
|
+
handler: async (params) => {
|
|
81
|
+
const { conversationId, adaptiveCard } = params;
|
|
82
|
+
return getClient().sendTeamsMessage({
|
|
83
|
+
conversationId,
|
|
84
|
+
adaptiveCard
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}),
|
|
88
|
+
defineTool({
|
|
89
|
+
name: "teams_list_channels",
|
|
90
|
+
description: "List Microsoft Teams channels and conversations that the bot has access to. Returns channel IDs that can be used with teams_send_message and teams_send_card.",
|
|
91
|
+
parameters: Type.Object({}),
|
|
92
|
+
handler: async () => {
|
|
93
|
+
return getClient().listTeamsChannels();
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
];
|
|
97
|
+
const plugin = {
|
|
98
|
+
id: "@alfe.ai/openclaw-teams",
|
|
99
|
+
name: "Alfe Teams Plugin",
|
|
100
|
+
description: "Microsoft Teams integration — send messages and adaptive cards",
|
|
101
|
+
version: "0.0.1",
|
|
102
|
+
activate(api) {
|
|
103
|
+
const log = api.logger;
|
|
104
|
+
for (const tool of teamsTools) api.registerTool(tool);
|
|
105
|
+
log.info(`Registered ${String(teamsTools.length)} Teams tools: ${teamsTools.map((t) => t.name).join(", ")}`);
|
|
106
|
+
if (!globalThis.__teamsPluginActivated) {
|
|
107
|
+
globalThis.__teamsPluginActivated = true;
|
|
108
|
+
log.info("Alfe Teams plugin activating...");
|
|
109
|
+
try {
|
|
110
|
+
const config = resolveConfig();
|
|
111
|
+
client = new AgentApiClient({
|
|
112
|
+
apiKey: config.apiKey,
|
|
113
|
+
apiUrl: config.apiUrl
|
|
114
|
+
});
|
|
115
|
+
} catch (err) {
|
|
116
|
+
log.error(`Failed to resolve config: ${err instanceof Error ? err.message : String(err)}`);
|
|
117
|
+
log.warn("Teams tools will fail — no API config available");
|
|
118
|
+
}
|
|
119
|
+
log.info("Alfe Teams plugin activated");
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
deactivate(api) {
|
|
123
|
+
globalThis.__teamsPluginActivated = false;
|
|
124
|
+
client = null;
|
|
125
|
+
api.logger.info("Alfe Teams plugin deactivated");
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
//#endregion
|
|
129
|
+
export { plugin as default };
|
|
130
|
+
|
|
131
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["/**\n * @alfe/openclaw-teams — OpenClaw native plugin\n *\n * Registers Microsoft Teams tools with OpenClaw. Tools call the Alfe\n * agent API via @alfe.ai/agent-api-client.\n *\n * This plugin provides:\n * - teams_send_message — send a text message to a Teams conversation\n * - teams_send_card — send an adaptive card to a Teams conversation\n * - teams_list_channels — list Teams channels the bot has access to\n */\n\nimport { Type, type TSchema } from \"@sinclair/typebox\";\nimport { resolveConfig } from \"@alfe.ai/config\";\nimport { AgentApiClient } from \"@alfe.ai/agent-api-client\";\n\ninterface Logger {\n info(msg: string, ...args: unknown[]): void;\n warn(msg: string, ...args: unknown[]): void;\n error(msg: string, ...args: unknown[]): void;\n debug(msg: string, ...args: unknown[]): void;\n}\n\ninterface OpenClawPluginApi {\n logger: Logger;\n registerTool(tool: ToolDef): void;\n registerGatewayMethod(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;\n on(event: string, handler: (...args: unknown[]) => void | Promise<void>, options?: { priority?: number }): void;\n}\n\n// ── Tool types ───────────────────────────────────────────────\n\ninterface ToolDef {\n name: string;\n description: string;\n label: string;\n parameters: TSchema;\n execute: (toolCallId: string, params: Record<string, unknown>) => Promise<{\n content: { type: \"text\"; text: string }[];\n details: unknown;\n }>;\n}\n\nfunction ok(data: unknown) {\n return { content: [{ type: \"text\" as const, text: JSON.stringify(data) }], details: data };\n}\n\nfunction errResult(message: string) {\n return { content: [{ type: \"text\" as const, text: JSON.stringify({ error: message }) }], details: { error: message } };\n}\n\nfunction defineTool(def: {\n name: string;\n description: string;\n parameters: TSchema;\n handler: (params: Record<string, unknown>) => Promise<unknown>;\n}): ToolDef {\n return {\n name: def.name,\n description: def.description,\n label: def.name,\n parameters: def.parameters,\n execute: async (_toolCallId: string, params: Record<string, unknown>) => {\n try {\n const result = await def.handler(params);\n return ok(result);\n } catch (e) {\n return errResult((e as Error).message);\n }\n },\n };\n}\n\n// ── API client ───────────────────────────────────────────────\n\nlet client: AgentApiClient | null = null;\n\nfunction getClient(): AgentApiClient {\n if (!client) throw new Error(\"Teams plugin not initialized — no API client\");\n return client;\n}\n\n// ── Tool definitions ─────────────────────────────────────────\n\nconst teamsTools: ToolDef[] = [\n defineTool({\n name: \"teams_send_message\",\n description:\n \"Send a text message to a Microsoft Teams conversation. \" +\n \"You need the conversationId from an inbound Teams message or from teams_list_channels.\",\n parameters: Type.Object({\n conversationId: Type.String({ description: \"The Teams conversation ID to send the message to\" }),\n text: Type.String({ description: \"The message text to send\" }),\n }),\n handler: async (params) => {\n const { conversationId, text } = params as { conversationId: string; text: string };\n return getClient().sendTeamsMessage({ conversationId, text });\n },\n }),\n\n defineTool({\n name: \"teams_send_card\",\n description:\n \"Send an Adaptive Card to a Microsoft Teams conversation. \" +\n \"Adaptive Cards support rich formatting, inputs, and actions. \" +\n \"Pass a valid Adaptive Card JSON object.\",\n parameters: Type.Object({\n conversationId: Type.String({ description: \"The Teams conversation ID to send the card to\" }),\n adaptiveCard: Type.Object({}, {\n description: \"Adaptive Card JSON payload (see https://adaptivecards.io)\",\n additionalProperties: true,\n }),\n }),\n handler: async (params) => {\n const { conversationId, adaptiveCard } = params as {\n conversationId: string;\n adaptiveCard: Record<string, unknown>;\n };\n return getClient().sendTeamsMessage({ conversationId, adaptiveCard });\n },\n }),\n\n defineTool({\n name: \"teams_list_channels\",\n description:\n \"List Microsoft Teams channels and conversations that the bot has access to. \" +\n \"Returns channel IDs that can be used with teams_send_message and teams_send_card.\",\n parameters: Type.Object({}),\n handler: async () => {\n return getClient().listTeamsChannels();\n },\n }),\n];\n\n// ── Plugin definition ────────────────────────────────────────\n\nconst plugin = {\n id: \"@alfe.ai/openclaw-teams\",\n name: \"Alfe Teams Plugin\",\n description: \"Microsoft Teams integration — send messages and adaptive cards\",\n version: \"0.0.1\",\n\n activate(api: OpenClawPluginApi) {\n const log = api.logger;\n\n for (const tool of teamsTools) {\n api.registerTool(tool);\n }\n log.info(`Registered ${String(teamsTools.length)} Teams tools: ${teamsTools.map((t) => t.name).join(\", \")}`);\n\n if (!(globalThis as Record<string, unknown>).__teamsPluginActivated) {\n (globalThis as Record<string, unknown>).__teamsPluginActivated = true;\n log.info(\"Alfe Teams plugin activating...\");\n\n try {\n const config = resolveConfig();\n client = new AgentApiClient({ apiKey: config.apiKey, apiUrl: config.apiUrl });\n } catch (err) {\n log.error(`Failed to resolve config: ${err instanceof Error ? err.message : String(err)}`);\n log.warn(\"Teams tools will fail — no API config available\");\n }\n\n log.info(\"Alfe Teams plugin activated\");\n }\n },\n\n deactivate(api: OpenClawPluginApi) {\n (globalThis as Record<string, unknown>).__teamsPluginActivated = false;\n client = null;\n api.logger.info(\"Alfe Teams plugin deactivated\");\n },\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;AA2CA,SAAS,GAAG,MAAe;AACzB,QAAO;EAAE,SAAS,CAAC;GAAE,MAAM;GAAiB,MAAM,KAAK,UAAU,KAAK;GAAE,CAAC;EAAE,SAAS;EAAM;;AAG5F,SAAS,UAAU,SAAiB;AAClC,QAAO;EAAE,SAAS,CAAC;GAAE,MAAM;GAAiB,MAAM,KAAK,UAAU,EAAE,OAAO,SAAS,CAAC;GAAE,CAAC;EAAE,SAAS,EAAE,OAAO,SAAS;EAAE;;AAGxH,SAAS,WAAW,KAKR;AACV,QAAO;EACL,MAAM,IAAI;EACV,aAAa,IAAI;EACjB,OAAO,IAAI;EACX,YAAY,IAAI;EAChB,SAAS,OAAO,aAAqB,WAAoC;AACvE,OAAI;AAEF,WAAO,GADQ,MAAM,IAAI,QAAQ,OAAO,CACvB;YACV,GAAG;AACV,WAAO,UAAW,EAAY,QAAQ;;;EAG3C;;AAKH,IAAI,SAAgC;AAEpC,SAAS,YAA4B;AACnC,KAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,+CAA+C;AAC5E,QAAO;;AAKT,MAAM,aAAwB;CAC5B,WAAW;EACT,MAAM;EACN,aACE;EAEF,YAAY,KAAK,OAAO;GACtB,gBAAgB,KAAK,OAAO,EAAE,aAAa,oDAAoD,CAAC;GAChG,MAAM,KAAK,OAAO,EAAE,aAAa,4BAA4B,CAAC;GAC/D,CAAC;EACF,SAAS,OAAO,WAAW;GACzB,MAAM,EAAE,gBAAgB,SAAS;AACjC,UAAO,WAAW,CAAC,iBAAiB;IAAE;IAAgB;IAAM,CAAC;;EAEhE,CAAC;CAEF,WAAW;EACT,MAAM;EACN,aACE;EAGF,YAAY,KAAK,OAAO;GACtB,gBAAgB,KAAK,OAAO,EAAE,aAAa,iDAAiD,CAAC;GAC7F,cAAc,KAAK,OAAO,EAAE,EAAE;IAC5B,aAAa;IACb,sBAAsB;IACvB,CAAC;GACH,CAAC;EACF,SAAS,OAAO,WAAW;GACzB,MAAM,EAAE,gBAAgB,iBAAiB;AAIzC,UAAO,WAAW,CAAC,iBAAiB;IAAE;IAAgB;IAAc,CAAC;;EAExE,CAAC;CAEF,WAAW;EACT,MAAM;EACN,aACE;EAEF,YAAY,KAAK,OAAO,EAAE,CAAC;EAC3B,SAAS,YAAY;AACnB,UAAO,WAAW,CAAC,mBAAmB;;EAEzC,CAAC;CACH;AAID,MAAM,SAAS;CACb,IAAI;CACJ,MAAM;CACN,aAAa;CACb,SAAS;CAET,SAAS,KAAwB;EAC/B,MAAM,MAAM,IAAI;AAEhB,OAAK,MAAM,QAAQ,WACjB,KAAI,aAAa,KAAK;AAExB,MAAI,KAAK,cAAc,OAAO,WAAW,OAAO,CAAC,gBAAgB,WAAW,KAAK,MAAM,EAAE,KAAK,CAAC,KAAK,KAAK,GAAG;AAE5G,MAAI,CAAE,WAAuC,wBAAwB;AAClE,cAAuC,yBAAyB;AACjE,OAAI,KAAK,kCAAkC;AAE3C,OAAI;IACF,MAAM,SAAS,eAAe;AAC9B,aAAS,IAAI,eAAe;KAAE,QAAQ,OAAO;KAAQ,QAAQ,OAAO;KAAQ,CAAC;YACtE,KAAK;AACZ,QAAI,MAAM,6BAA6B,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GAAG;AAC1F,QAAI,KAAK,kDAAkD;;AAG7D,OAAI,KAAK,8BAA8B;;;CAI3C,WAAW,KAAwB;AAChC,aAAuC,yBAAyB;AACjE,WAAS;AACT,MAAI,OAAO,KAAK,gCAAgC;;CAEnD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "@alfe.ai/openclaw-teams",
|
|
3
|
+
"name": "Microsoft Teams",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "Send messages and adaptive cards to Microsoft Teams",
|
|
6
|
+
"entry": "./dist/plugin.js",
|
|
7
|
+
"configSchema": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {}
|
|
11
|
+
}
|
|
12
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alfe.ai/openclaw-teams",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "OpenClaw Microsoft Teams plugin for Alfe — send messages and adaptive cards to Teams",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./plugin": {
|
|
15
|
+
"types": "./dist/plugin.d.ts",
|
|
16
|
+
"require": "./dist/plugin.cjs",
|
|
17
|
+
"import": "./dist/plugin.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"openclaw": {
|
|
21
|
+
"extensions": [
|
|
22
|
+
"./dist/plugin.js"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"openclaw.plugin.json"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@sinclair/typebox": "^0.34.48",
|
|
31
|
+
"@alfe.ai/config": "0.0.7",
|
|
32
|
+
"@alfe.ai/agent-api-client": "0.0.7"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsdown",
|
|
36
|
+
"dev": "tsdown --watch",
|
|
37
|
+
"test": "vitest run --passWithNoTests",
|
|
38
|
+
"lint": "eslint ."
|
|
39
|
+
}
|
|
40
|
+
}
|