@agenticmail/enterprise 0.5.317 → 0.5.319
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/agent-tools-AT4D276V.js +13949 -0
- package/dist/agent-tools-MSTAPX2I.js +13949 -0
- package/dist/chunk-36XNMIHA.js +5087 -0
- package/dist/chunk-D24JY75H.js +1519 -0
- package/dist/chunk-FEAILFAQ.js +1519 -0
- package/dist/chunk-GTFZZUXX.js +4921 -0
- package/dist/chunk-MMYBDHDB.js +4921 -0
- package/dist/chunk-WJO57PMO.js +5087 -0
- package/dist/cli-agent-FXZ6DJKP.js +2357 -0
- package/dist/cli-agent-ZSHUPBBN.js +2357 -0
- package/dist/cli-serve-657NRUOX.js +140 -0
- package/dist/cli-serve-LNTT73P2.js +140 -0
- package/dist/cli.js +3 -3
- package/dist/index.js +3 -3
- package/dist/microsoft-HPLA5ZL5.js +2414 -0
- package/dist/microsoft-YUT6EIGP.js +3400 -0
- package/dist/runtime-4UVCTFNQ.js +45 -0
- package/dist/runtime-HTIM7GZR.js +45 -0
- package/dist/server-BMEJZGFG.js +28 -0
- package/dist/server-TXV3ZVVR.js +28 -0
- package/dist/setup-2JYXGTW6.js +20 -0
- package/dist/setup-ADSKKBGV.js +20 -0
- package/package.json +1 -1
- package/src/agent-tools/tools/microsoft/excel-vba.ts +331 -0
- package/src/agent-tools/tools/microsoft/excel.ts +261 -0
- package/src/agent-tools/tools/microsoft/index.ts +47 -7
- package/src/agent-tools/tools/microsoft/onenote.ts +186 -0
- package/src/agent-tools/tools/microsoft/planner.ts +200 -0
- package/src/agent-tools/tools/microsoft/powerbi.ts +266 -0
- package/src/agent-tools/tools/microsoft/powerpoint.ts +186 -0
- package/src/agent-tools/tools/microsoft/sharepoint.ts +328 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentRuntime,
|
|
3
|
+
EmailChannel,
|
|
4
|
+
FollowUpScheduler,
|
|
5
|
+
SessionManager,
|
|
6
|
+
SubAgentManager,
|
|
7
|
+
ToolRegistry,
|
|
8
|
+
callLLM,
|
|
9
|
+
createAgentRuntime,
|
|
10
|
+
createNoopHooks,
|
|
11
|
+
createRuntimeHooks,
|
|
12
|
+
estimateMessageTokens,
|
|
13
|
+
estimateTokens,
|
|
14
|
+
executeTool,
|
|
15
|
+
runAgentLoop,
|
|
16
|
+
toolsToDefinitions
|
|
17
|
+
} from "./chunk-GTFZZUXX.js";
|
|
18
|
+
import {
|
|
19
|
+
PROVIDER_REGISTRY,
|
|
20
|
+
listAllProviders,
|
|
21
|
+
resolveApiKeyForProvider,
|
|
22
|
+
resolveProvider
|
|
23
|
+
} from "./chunk-UF3ZJMJO.js";
|
|
24
|
+
import "./chunk-KFQGP6VL.js";
|
|
25
|
+
export {
|
|
26
|
+
AgentRuntime,
|
|
27
|
+
EmailChannel,
|
|
28
|
+
FollowUpScheduler,
|
|
29
|
+
PROVIDER_REGISTRY,
|
|
30
|
+
SessionManager,
|
|
31
|
+
SubAgentManager,
|
|
32
|
+
ToolRegistry,
|
|
33
|
+
callLLM,
|
|
34
|
+
createAgentRuntime,
|
|
35
|
+
createNoopHooks,
|
|
36
|
+
createRuntimeHooks,
|
|
37
|
+
estimateMessageTokens,
|
|
38
|
+
estimateTokens,
|
|
39
|
+
executeTool,
|
|
40
|
+
listAllProviders,
|
|
41
|
+
resolveApiKeyForProvider,
|
|
42
|
+
resolveProvider,
|
|
43
|
+
runAgentLoop,
|
|
44
|
+
toolsToDefinitions
|
|
45
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentRuntime,
|
|
3
|
+
EmailChannel,
|
|
4
|
+
FollowUpScheduler,
|
|
5
|
+
SessionManager,
|
|
6
|
+
SubAgentManager,
|
|
7
|
+
ToolRegistry,
|
|
8
|
+
callLLM,
|
|
9
|
+
createAgentRuntime,
|
|
10
|
+
createNoopHooks,
|
|
11
|
+
createRuntimeHooks,
|
|
12
|
+
estimateMessageTokens,
|
|
13
|
+
estimateTokens,
|
|
14
|
+
executeTool,
|
|
15
|
+
runAgentLoop,
|
|
16
|
+
toolsToDefinitions
|
|
17
|
+
} from "./chunk-MMYBDHDB.js";
|
|
18
|
+
import {
|
|
19
|
+
PROVIDER_REGISTRY,
|
|
20
|
+
listAllProviders,
|
|
21
|
+
resolveApiKeyForProvider,
|
|
22
|
+
resolveProvider
|
|
23
|
+
} from "./chunk-UF3ZJMJO.js";
|
|
24
|
+
import "./chunk-KFQGP6VL.js";
|
|
25
|
+
export {
|
|
26
|
+
AgentRuntime,
|
|
27
|
+
EmailChannel,
|
|
28
|
+
FollowUpScheduler,
|
|
29
|
+
PROVIDER_REGISTRY,
|
|
30
|
+
SessionManager,
|
|
31
|
+
SubAgentManager,
|
|
32
|
+
ToolRegistry,
|
|
33
|
+
callLLM,
|
|
34
|
+
createAgentRuntime,
|
|
35
|
+
createNoopHooks,
|
|
36
|
+
createRuntimeHooks,
|
|
37
|
+
estimateMessageTokens,
|
|
38
|
+
estimateTokens,
|
|
39
|
+
executeTool,
|
|
40
|
+
listAllProviders,
|
|
41
|
+
resolveApiKeyForProvider,
|
|
42
|
+
resolveProvider,
|
|
43
|
+
runAgentLoop,
|
|
44
|
+
toolsToDefinitions
|
|
45
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createServer
|
|
3
|
+
} from "./chunk-WJO57PMO.js";
|
|
4
|
+
import "./chunk-DJBCRQTD.js";
|
|
5
|
+
import "./chunk-UF3ZJMJO.js";
|
|
6
|
+
import "./chunk-P3HVY2HS.js";
|
|
7
|
+
import "./chunk-VSBC4SWO.js";
|
|
8
|
+
import "./chunk-AF3WSNVX.js";
|
|
9
|
+
import "./chunk-74ZCQKYU.js";
|
|
10
|
+
import "./chunk-BDCFOP7O.js";
|
|
11
|
+
import "./chunk-C6JP5NR6.js";
|
|
12
|
+
import "./chunk-M6ZIC5H3.js";
|
|
13
|
+
import "./chunk-PWWV2U5P.js";
|
|
14
|
+
import "./chunk-RH7KPWRQ.js";
|
|
15
|
+
import "./chunk-3FMK32KQ.js";
|
|
16
|
+
import "./chunk-Z7NVD3OQ.js";
|
|
17
|
+
import "./chunk-YDD5TC5Q.js";
|
|
18
|
+
import "./chunk-37ABTUFU.js";
|
|
19
|
+
import "./chunk-NU657BBQ.js";
|
|
20
|
+
import "./chunk-PGAU3W3M.js";
|
|
21
|
+
import "./chunk-JGEVQZDR.js";
|
|
22
|
+
import "./chunk-WUAWWKTN.js";
|
|
23
|
+
import "./chunk-HS5YWSGM.js";
|
|
24
|
+
import "./chunk-22U7TZPN.js";
|
|
25
|
+
import "./chunk-KFQGP6VL.js";
|
|
26
|
+
export {
|
|
27
|
+
createServer
|
|
28
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createServer
|
|
3
|
+
} from "./chunk-36XNMIHA.js";
|
|
4
|
+
import "./chunk-DJBCRQTD.js";
|
|
5
|
+
import "./chunk-UF3ZJMJO.js";
|
|
6
|
+
import "./chunk-P3HVY2HS.js";
|
|
7
|
+
import "./chunk-VSBC4SWO.js";
|
|
8
|
+
import "./chunk-AF3WSNVX.js";
|
|
9
|
+
import "./chunk-74ZCQKYU.js";
|
|
10
|
+
import "./chunk-BDCFOP7O.js";
|
|
11
|
+
import "./chunk-C6JP5NR6.js";
|
|
12
|
+
import "./chunk-M6ZIC5H3.js";
|
|
13
|
+
import "./chunk-PWWV2U5P.js";
|
|
14
|
+
import "./chunk-RH7KPWRQ.js";
|
|
15
|
+
import "./chunk-3FMK32KQ.js";
|
|
16
|
+
import "./chunk-Z7NVD3OQ.js";
|
|
17
|
+
import "./chunk-YDD5TC5Q.js";
|
|
18
|
+
import "./chunk-37ABTUFU.js";
|
|
19
|
+
import "./chunk-NU657BBQ.js";
|
|
20
|
+
import "./chunk-PGAU3W3M.js";
|
|
21
|
+
import "./chunk-JGEVQZDR.js";
|
|
22
|
+
import "./chunk-WUAWWKTN.js";
|
|
23
|
+
import "./chunk-HS5YWSGM.js";
|
|
24
|
+
import "./chunk-22U7TZPN.js";
|
|
25
|
+
import "./chunk-KFQGP6VL.js";
|
|
26
|
+
export {
|
|
27
|
+
createServer
|
|
28
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
promptCompanyInfo,
|
|
3
|
+
promptDatabase,
|
|
4
|
+
promptDeployment,
|
|
5
|
+
promptDomain,
|
|
6
|
+
promptRegistration,
|
|
7
|
+
provision,
|
|
8
|
+
runSetupWizard
|
|
9
|
+
} from "./chunk-FEAILFAQ.js";
|
|
10
|
+
import "./chunk-4EKXYIJF.js";
|
|
11
|
+
import "./chunk-KFQGP6VL.js";
|
|
12
|
+
export {
|
|
13
|
+
promptCompanyInfo,
|
|
14
|
+
promptDatabase,
|
|
15
|
+
promptDeployment,
|
|
16
|
+
promptDomain,
|
|
17
|
+
promptRegistration,
|
|
18
|
+
provision,
|
|
19
|
+
runSetupWizard
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
promptCompanyInfo,
|
|
3
|
+
promptDatabase,
|
|
4
|
+
promptDeployment,
|
|
5
|
+
promptDomain,
|
|
6
|
+
promptRegistration,
|
|
7
|
+
provision,
|
|
8
|
+
runSetupWizard
|
|
9
|
+
} from "./chunk-D24JY75H.js";
|
|
10
|
+
import "./chunk-4EKXYIJF.js";
|
|
11
|
+
import "./chunk-KFQGP6VL.js";
|
|
12
|
+
export {
|
|
13
|
+
promptCompanyInfo,
|
|
14
|
+
promptDatabase,
|
|
15
|
+
promptDeployment,
|
|
16
|
+
promptDomain,
|
|
17
|
+
promptRegistration,
|
|
18
|
+
provision,
|
|
19
|
+
runSetupWizard
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Microsoft Excel VBA / Macro Tools
|
|
3
|
+
*
|
|
4
|
+
* Execute Excel operations via workbook sessions, named ranges, functions, and custom formulas.
|
|
5
|
+
* Uses the Excel REST API workbook session for batch operations and calculated fields.
|
|
6
|
+
*
|
|
7
|
+
* Note: Graph API doesn't directly execute VBA macros, but provides:
|
|
8
|
+
* - Workbook sessions for transactional operations
|
|
9
|
+
* - Named range management
|
|
10
|
+
* - Formula evaluation
|
|
11
|
+
* - Pivot table refresh
|
|
12
|
+
* - Custom function calculation
|
|
13
|
+
* - Chart reading
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { AnyAgentTool, ToolCreationOptions } from '../../types.js';
|
|
17
|
+
import { jsonResult, errorResult } from '../../common.js';
|
|
18
|
+
import type { MicrosoftToolsConfig } from './index.js';
|
|
19
|
+
import { graph } from './graph-api.js';
|
|
20
|
+
|
|
21
|
+
function itemPath(p: { itemId?: string; path?: string; driveId?: string }): string {
|
|
22
|
+
if (p.driveId && p.itemId) return `/drives/${p.driveId}/items/${p.itemId}`;
|
|
23
|
+
if (p.itemId) return `/me/drive/items/${p.itemId}`;
|
|
24
|
+
if (p.path) return `/me/drive/root:${p.path}:`;
|
|
25
|
+
throw new Error('Provide itemId or path');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function createExcelAdvancedTools(config: MicrosoftToolsConfig, _options?: ToolCreationOptions): AnyAgentTool[] {
|
|
29
|
+
const tp = config.tokenProvider;
|
|
30
|
+
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
name: 'excel_create_session',
|
|
34
|
+
description: 'Create a workbook session for batch operations. Returns a session ID to use in subsequent calls for atomic transactions.',
|
|
35
|
+
category: 'utility' as const,
|
|
36
|
+
parameters: {
|
|
37
|
+
type: 'object' as const,
|
|
38
|
+
properties: {
|
|
39
|
+
itemId: { type: 'string', description: 'OneDrive/SharePoint item ID' },
|
|
40
|
+
path: { type: 'string', description: 'File path' },
|
|
41
|
+
driveId: { type: 'string', description: 'Drive ID' },
|
|
42
|
+
persistChanges: { type: 'boolean', description: 'Persist changes after session closes (default: true)' },
|
|
43
|
+
},
|
|
44
|
+
required: [],
|
|
45
|
+
},
|
|
46
|
+
async execute(_id: string, params: any) {
|
|
47
|
+
try {
|
|
48
|
+
const token = await tp.getAccessToken();
|
|
49
|
+
const base = itemPath(params);
|
|
50
|
+
const session = await graph(token, `${base}/workbook/createSession`, {
|
|
51
|
+
method: 'POST',
|
|
52
|
+
body: { persistChanges: params.persistChanges !== false },
|
|
53
|
+
});
|
|
54
|
+
return jsonResult({ sessionId: session.id, persistChanges: session.persistChanges });
|
|
55
|
+
} catch (e: any) { return errorResult(e.message); }
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
{
|
|
60
|
+
name: 'excel_close_session',
|
|
61
|
+
description: 'Close a workbook session. Commits or discards changes based on session config.',
|
|
62
|
+
category: 'utility' as const,
|
|
63
|
+
parameters: {
|
|
64
|
+
type: 'object' as const,
|
|
65
|
+
properties: {
|
|
66
|
+
itemId: { type: 'string', description: 'OneDrive/SharePoint item ID' },
|
|
67
|
+
path: { type: 'string', description: 'File path' },
|
|
68
|
+
driveId: { type: 'string', description: 'Drive ID' },
|
|
69
|
+
sessionId: { type: 'string', description: 'Session ID to close' },
|
|
70
|
+
},
|
|
71
|
+
required: ['sessionId'],
|
|
72
|
+
},
|
|
73
|
+
async execute(_id: string, params: any) {
|
|
74
|
+
try {
|
|
75
|
+
const token = await tp.getAccessToken();
|
|
76
|
+
const base = itemPath(params);
|
|
77
|
+
await graph(token, `${base}/workbook/closeSession`, {
|
|
78
|
+
method: 'POST',
|
|
79
|
+
headers: { 'workbook-session-id': params.sessionId },
|
|
80
|
+
});
|
|
81
|
+
return jsonResult({ closed: true, sessionId: params.sessionId });
|
|
82
|
+
} catch (e: any) { return errorResult(e.message); }
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
{
|
|
87
|
+
name: 'excel_evaluate_formula',
|
|
88
|
+
description: 'Evaluate an Excel formula without writing it to a cell. Supports any Excel function (SUM, VLOOKUP, IF, etc.).',
|
|
89
|
+
category: 'utility' as const,
|
|
90
|
+
parameters: {
|
|
91
|
+
type: 'object' as const,
|
|
92
|
+
properties: {
|
|
93
|
+
itemId: { type: 'string', description: 'OneDrive/SharePoint item ID' },
|
|
94
|
+
path: { type: 'string', description: 'File path' },
|
|
95
|
+
driveId: { type: 'string', description: 'Drive ID' },
|
|
96
|
+
worksheet: { type: 'string', description: 'Worksheet name (default: Sheet1)' },
|
|
97
|
+
formula: { type: 'string', description: 'Excel formula (e.g., "=SUM(A1:A10)", "=VLOOKUP(\"Alice\",A:C,3,FALSE)")' },
|
|
98
|
+
sessionId: { type: 'string', description: 'Optional session ID for batch operations' },
|
|
99
|
+
},
|
|
100
|
+
required: ['formula'],
|
|
101
|
+
},
|
|
102
|
+
async execute(_id: string, params: any) {
|
|
103
|
+
try {
|
|
104
|
+
const token = await tp.getAccessToken();
|
|
105
|
+
const base = itemPath(params);
|
|
106
|
+
const ws = params.worksheet || 'Sheet1';
|
|
107
|
+
// Write formula to a temp cell, read result, then clear
|
|
108
|
+
const headers: Record<string, string> = {};
|
|
109
|
+
if (params.sessionId) headers['workbook-session-id'] = params.sessionId;
|
|
110
|
+
// Use a far-away cell to avoid conflicts
|
|
111
|
+
const tempCell = 'ZZ9999';
|
|
112
|
+
await graph(token, `${base}/workbook/worksheets/${encodeURIComponent(ws)}/range(address='${tempCell}')`, {
|
|
113
|
+
method: 'PATCH', body: { formulas: [[params.formula]] }, headers,
|
|
114
|
+
});
|
|
115
|
+
const result = await graph(token, `${base}/workbook/worksheets/${encodeURIComponent(ws)}/range(address='${tempCell}')`, {
|
|
116
|
+
query: { '$select': 'values,text,formulas' }, headers,
|
|
117
|
+
});
|
|
118
|
+
// Clear the temp cell
|
|
119
|
+
await graph(token, `${base}/workbook/worksheets/${encodeURIComponent(ws)}/range(address='${tempCell}')/clear`, {
|
|
120
|
+
method: 'POST', body: { applyTo: 'All' }, headers,
|
|
121
|
+
});
|
|
122
|
+
return jsonResult({
|
|
123
|
+
formula: params.formula,
|
|
124
|
+
result: result.values?.[0]?.[0],
|
|
125
|
+
text: result.text?.[0]?.[0],
|
|
126
|
+
});
|
|
127
|
+
} catch (e: any) { return errorResult(e.message); }
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
{
|
|
132
|
+
name: 'excel_named_ranges',
|
|
133
|
+
description: 'List all named ranges in a workbook.',
|
|
134
|
+
category: 'utility' as const,
|
|
135
|
+
parameters: {
|
|
136
|
+
type: 'object' as const,
|
|
137
|
+
properties: {
|
|
138
|
+
itemId: { type: 'string', description: 'OneDrive/SharePoint item ID' },
|
|
139
|
+
path: { type: 'string', description: 'File path' },
|
|
140
|
+
driveId: { type: 'string', description: 'Drive ID' },
|
|
141
|
+
},
|
|
142
|
+
required: [],
|
|
143
|
+
},
|
|
144
|
+
async execute(_id: string, params: any) {
|
|
145
|
+
try {
|
|
146
|
+
const token = await tp.getAccessToken();
|
|
147
|
+
const base = itemPath(params);
|
|
148
|
+
const data = await graph(token, `${base}/workbook/names`);
|
|
149
|
+
const names = (data.value || []).map((n: any) => ({
|
|
150
|
+
name: n.name, value: n.value, type: n.type, visible: n.visible,
|
|
151
|
+
comment: n.comment,
|
|
152
|
+
}));
|
|
153
|
+
return jsonResult({ namedRanges: names, count: names.length });
|
|
154
|
+
} catch (e: any) { return errorResult(e.message); }
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
{
|
|
159
|
+
name: 'excel_read_named_range',
|
|
160
|
+
description: 'Read values from a named range.',
|
|
161
|
+
category: 'utility' as const,
|
|
162
|
+
parameters: {
|
|
163
|
+
type: 'object' as const,
|
|
164
|
+
properties: {
|
|
165
|
+
itemId: { type: 'string', description: 'OneDrive/SharePoint item ID' },
|
|
166
|
+
path: { type: 'string', description: 'File path' },
|
|
167
|
+
driveId: { type: 'string', description: 'Drive ID' },
|
|
168
|
+
name: { type: 'string', description: 'Named range name' },
|
|
169
|
+
},
|
|
170
|
+
required: ['name'],
|
|
171
|
+
},
|
|
172
|
+
async execute(_id: string, params: any) {
|
|
173
|
+
try {
|
|
174
|
+
const token = await tp.getAccessToken();
|
|
175
|
+
const base = itemPath(params);
|
|
176
|
+
const range = await graph(token, `${base}/workbook/names/${encodeURIComponent(params.name)}/range`, {
|
|
177
|
+
query: { '$select': 'address,values,text,formulas,rowCount,columnCount' }
|
|
178
|
+
});
|
|
179
|
+
return jsonResult({
|
|
180
|
+
name: params.name, address: range.address,
|
|
181
|
+
values: range.values, text: range.text,
|
|
182
|
+
rows: range.rowCount, columns: range.columnCount,
|
|
183
|
+
});
|
|
184
|
+
} catch (e: any) { return errorResult(e.message); }
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
{
|
|
189
|
+
name: 'excel_list_charts',
|
|
190
|
+
description: 'List all charts in an Excel worksheet.',
|
|
191
|
+
category: 'utility' as const,
|
|
192
|
+
parameters: {
|
|
193
|
+
type: 'object' as const,
|
|
194
|
+
properties: {
|
|
195
|
+
itemId: { type: 'string', description: 'OneDrive/SharePoint item ID' },
|
|
196
|
+
path: { type: 'string', description: 'File path' },
|
|
197
|
+
driveId: { type: 'string', description: 'Drive ID' },
|
|
198
|
+
worksheet: { type: 'string', description: 'Worksheet name (default: Sheet1)' },
|
|
199
|
+
},
|
|
200
|
+
required: [],
|
|
201
|
+
},
|
|
202
|
+
async execute(_id: string, params: any) {
|
|
203
|
+
try {
|
|
204
|
+
const token = await tp.getAccessToken();
|
|
205
|
+
const base = itemPath(params);
|
|
206
|
+
const ws = params.worksheet || 'Sheet1';
|
|
207
|
+
const data = await graph(token, `${base}/workbook/worksheets/${encodeURIComponent(ws)}/charts`);
|
|
208
|
+
const charts = (data.value || []).map((c: any) => ({
|
|
209
|
+
id: c.id, name: c.name, height: c.height, width: c.width,
|
|
210
|
+
top: c.top, left: c.left,
|
|
211
|
+
}));
|
|
212
|
+
return jsonResult({ charts, count: charts.length });
|
|
213
|
+
} catch (e: any) { return errorResult(e.message); }
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
{
|
|
218
|
+
name: 'excel_chart_image',
|
|
219
|
+
description: 'Get a chart as a base64 PNG image.',
|
|
220
|
+
category: 'utility' as const,
|
|
221
|
+
parameters: {
|
|
222
|
+
type: 'object' as const,
|
|
223
|
+
properties: {
|
|
224
|
+
itemId: { type: 'string', description: 'OneDrive/SharePoint item ID' },
|
|
225
|
+
path: { type: 'string', description: 'File path' },
|
|
226
|
+
driveId: { type: 'string', description: 'Drive ID' },
|
|
227
|
+
worksheet: { type: 'string', description: 'Worksheet name' },
|
|
228
|
+
chartName: { type: 'string', description: 'Chart name or ID' },
|
|
229
|
+
},
|
|
230
|
+
required: ['chartName'],
|
|
231
|
+
},
|
|
232
|
+
async execute(_id: string, params: any) {
|
|
233
|
+
try {
|
|
234
|
+
const token = await tp.getAccessToken();
|
|
235
|
+
const base = itemPath(params);
|
|
236
|
+
const ws = params.worksheet || 'Sheet1';
|
|
237
|
+
const img = await graph(token, `${base}/workbook/worksheets/${encodeURIComponent(ws)}/charts/${encodeURIComponent(params.chartName)}/image`);
|
|
238
|
+
return jsonResult({ chartName: params.chartName, base64Image: img.value, format: 'png' });
|
|
239
|
+
} catch (e: any) { return errorResult(e.message); }
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
{
|
|
244
|
+
name: 'excel_pivot_refresh',
|
|
245
|
+
description: 'Refresh all pivot tables in a workbook by recalculating the workbook.',
|
|
246
|
+
category: 'utility' as const,
|
|
247
|
+
parameters: {
|
|
248
|
+
type: 'object' as const,
|
|
249
|
+
properties: {
|
|
250
|
+
itemId: { type: 'string', description: 'OneDrive/SharePoint item ID' },
|
|
251
|
+
path: { type: 'string', description: 'File path' },
|
|
252
|
+
driveId: { type: 'string', description: 'Drive ID' },
|
|
253
|
+
sessionId: { type: 'string', description: 'Session ID (recommended for consistency)' },
|
|
254
|
+
},
|
|
255
|
+
required: [],
|
|
256
|
+
},
|
|
257
|
+
async execute(_id: string, params: any) {
|
|
258
|
+
try {
|
|
259
|
+
const token = await tp.getAccessToken();
|
|
260
|
+
const base = itemPath(params);
|
|
261
|
+
const headers: Record<string, string> = {};
|
|
262
|
+
if (params.sessionId) headers['workbook-session-id'] = params.sessionId;
|
|
263
|
+
await graph(token, `${base}/workbook/application/calculate`, {
|
|
264
|
+
method: 'POST',
|
|
265
|
+
body: { calculationType: 'Full' },
|
|
266
|
+
headers,
|
|
267
|
+
});
|
|
268
|
+
return jsonResult({ refreshed: true, calculationType: 'Full' });
|
|
269
|
+
} catch (e: any) { return errorResult(e.message); }
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
{
|
|
274
|
+
name: 'excel_set_cell_format',
|
|
275
|
+
description: 'Set number format, font, fill, or borders on a cell range.',
|
|
276
|
+
category: 'utility' as const,
|
|
277
|
+
parameters: {
|
|
278
|
+
type: 'object' as const,
|
|
279
|
+
properties: {
|
|
280
|
+
itemId: { type: 'string', description: 'OneDrive/SharePoint item ID' },
|
|
281
|
+
path: { type: 'string', description: 'File path' },
|
|
282
|
+
driveId: { type: 'string', description: 'Drive ID' },
|
|
283
|
+
worksheet: { type: 'string', description: 'Worksheet name' },
|
|
284
|
+
range: { type: 'string', description: 'Cell range (e.g., "A1:D10")' },
|
|
285
|
+
numberFormat: { type: 'string', description: 'Number format (e.g., "$#,##0.00", "0%", "mm/dd/yyyy")' },
|
|
286
|
+
bold: { type: 'boolean', description: 'Set font bold' },
|
|
287
|
+
italic: { type: 'boolean', description: 'Set font italic' },
|
|
288
|
+
fontColor: { type: 'string', description: 'Font color (e.g., "#FF0000")' },
|
|
289
|
+
fillColor: { type: 'string', description: 'Cell fill color (e.g., "#FFFF00")' },
|
|
290
|
+
horizontalAlignment: { type: 'string', description: 'Left, Center, Right, Fill, Justify' },
|
|
291
|
+
},
|
|
292
|
+
required: ['range'],
|
|
293
|
+
},
|
|
294
|
+
async execute(_id: string, params: any) {
|
|
295
|
+
try {
|
|
296
|
+
const token = await tp.getAccessToken();
|
|
297
|
+
const base = itemPath(params);
|
|
298
|
+
const ws = params.worksheet || 'Sheet1';
|
|
299
|
+
const rangePath = `${base}/workbook/worksheets/${encodeURIComponent(ws)}/range(address='${params.range}')`;
|
|
300
|
+
|
|
301
|
+
// Build format object
|
|
302
|
+
const format: any = {};
|
|
303
|
+
if (params.numberFormat) {
|
|
304
|
+
// numberFormat needs to be an array matching the range dimensions
|
|
305
|
+
await graph(token, `${rangePath}/format`, { method: 'PATCH', body: { columnWidth: null } }); // ensure format exists
|
|
306
|
+
}
|
|
307
|
+
if (params.bold !== undefined || params.italic !== undefined || params.fontColor) {
|
|
308
|
+
const font: any = {};
|
|
309
|
+
if (params.bold !== undefined) font.bold = params.bold;
|
|
310
|
+
if (params.italic !== undefined) font.italic = params.italic;
|
|
311
|
+
if (params.fontColor) font.color = params.fontColor;
|
|
312
|
+
await graph(token, `${rangePath}/format/font`, { method: 'PATCH', body: font });
|
|
313
|
+
}
|
|
314
|
+
if (params.fillColor) {
|
|
315
|
+
await graph(token, `${rangePath}/format/fill`, { method: 'PATCH', body: { color: params.fillColor } });
|
|
316
|
+
}
|
|
317
|
+
if (params.horizontalAlignment) {
|
|
318
|
+
await graph(token, `${rangePath}/format`, { method: 'PATCH', body: { horizontalAlignment: params.horizontalAlignment } });
|
|
319
|
+
}
|
|
320
|
+
if (params.numberFormat) {
|
|
321
|
+
// Get range dimensions first
|
|
322
|
+
const rangeInfo = await graph(token, rangePath, { query: { '$select': 'rowCount,columnCount' } });
|
|
323
|
+
const fmt = Array(rangeInfo.rowCount).fill(null).map(() => Array(rangeInfo.columnCount).fill(params.numberFormat));
|
|
324
|
+
await graph(token, rangePath, { method: 'PATCH', body: { numberFormat: fmt } });
|
|
325
|
+
}
|
|
326
|
+
return jsonResult({ formatted: true, range: params.range });
|
|
327
|
+
} catch (e: any) { return errorResult(e.message); }
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
];
|
|
331
|
+
}
|