farseer-cli 1.0.10 → 1.1.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.
Files changed (98) hide show
  1. package/README.md +19 -0
  2. package/dist/commands/app.js +348 -344
  3. package/dist/commands/app.js.map +7 -0
  4. package/dist/commands/apps.js +110 -82
  5. package/dist/commands/apps.js.map +7 -0
  6. package/dist/commands/cells.js +161 -0
  7. package/dist/commands/cells.js.map +7 -0
  8. package/dist/commands/checkout.js +140 -155
  9. package/dist/commands/checkout.js.map +7 -0
  10. package/dist/commands/config.js +128 -126
  11. package/dist/commands/config.js.map +7 -0
  12. package/dist/commands/dashboards.js +130 -0
  13. package/dist/commands/dashboards.js.map +7 -0
  14. package/dist/commands/diff.js +171 -193
  15. package/dist/commands/diff.js.map +7 -0
  16. package/dist/commands/dimensions.js +222 -119
  17. package/dist/commands/dimensions.js.map +7 -0
  18. package/dist/commands/files.js +96 -77
  19. package/dist/commands/files.js.map +7 -0
  20. package/dist/commands/formula.js +116 -0
  21. package/dist/commands/formula.js.map +7 -0
  22. package/dist/commands/install.js +74 -76
  23. package/dist/commands/install.js.map +7 -0
  24. package/dist/commands/list.js +91 -73
  25. package/dist/commands/list.js.map +7 -0
  26. package/dist/commands/login.js +137 -98
  27. package/dist/commands/login.js.map +7 -0
  28. package/dist/commands/logout.js +59 -41
  29. package/dist/commands/logout.js.map +7 -0
  30. package/dist/commands/mcp-server.js +36 -23
  31. package/dist/commands/mcp-server.js.map +7 -0
  32. package/dist/commands/model.js +186 -175
  33. package/dist/commands/model.js.map +7 -0
  34. package/dist/commands/pull.js +264 -274
  35. package/dist/commands/pull.js.map +7 -0
  36. package/dist/commands/push.js +209 -221
  37. package/dist/commands/push.js.map +7 -0
  38. package/dist/commands/run.js +276 -321
  39. package/dist/commands/run.js.map +7 -0
  40. package/dist/commands/sheets.js +200 -0
  41. package/dist/commands/sheets.js.map +7 -0
  42. package/dist/commands/status.js +149 -169
  43. package/dist/commands/status.js.map +7 -0
  44. package/dist/commands/variables.js +247 -188
  45. package/dist/commands/variables.js.map +7 -0
  46. package/dist/commands/whoami.js +65 -44
  47. package/dist/commands/whoami.js.map +7 -0
  48. package/dist/index.js +179 -115
  49. package/dist/index.js.map +7 -0
  50. package/dist/mcp/index.js +33 -16
  51. package/dist/mcp/index.js.map +7 -0
  52. package/dist/mcp/prompts/workflows.js +191 -145
  53. package/dist/mcp/prompts/workflows.js.map +7 -0
  54. package/dist/mcp/resources/documentation.js +158 -148
  55. package/dist/mcp/resources/documentation.js.map +7 -0
  56. package/dist/mcp/server.js +56 -33
  57. package/dist/mcp/server.js.map +7 -0
  58. package/dist/mcp/tools/appTools.js +309 -277
  59. package/dist/mcp/tools/appTools.js.map +7 -0
  60. package/dist/mcp/tools/authTools.js +130 -121
  61. package/dist/mcp/tools/authTools.js.map +7 -0
  62. package/dist/mcp/tools/cellTools.js +148 -0
  63. package/dist/mcp/tools/cellTools.js.map +7 -0
  64. package/dist/mcp/tools/dashboardTools.js +133 -0
  65. package/dist/mcp/tools/dashboardTools.js.map +7 -0
  66. package/dist/mcp/tools/dataTools.js +270 -267
  67. package/dist/mcp/tools/dataTools.js.map +7 -0
  68. package/dist/mcp/tools/modelTools.js +575 -229
  69. package/dist/mcp/tools/modelTools.js.map +7 -0
  70. package/dist/mcp/tools/runTools.js +201 -203
  71. package/dist/mcp/tools/runTools.js.map +7 -0
  72. package/dist/mcp/tools/sheetTools.js +240 -0
  73. package/dist/mcp/tools/sheetTools.js.map +7 -0
  74. package/dist/mcp/tools/syncTools.js +335 -314
  75. package/dist/mcp/tools/syncTools.js.map +7 -0
  76. package/dist/mcp/utils/helpers.js +117 -123
  77. package/dist/mcp/utils/helpers.js.map +7 -0
  78. package/dist/services/appSyncService.js +381 -437
  79. package/dist/services/appSyncService.js.map +7 -0
  80. package/dist/services/configService.js +154 -143
  81. package/dist/services/configService.js.map +7 -0
  82. package/dist/services/farseerApi.js +405 -400
  83. package/dist/services/farseerApi.js.map +7 -0
  84. package/dist/services/farseerFactory.js +208 -273
  85. package/dist/services/farseerFactory.js.map +7 -0
  86. package/dist/services/farseerService.js +453 -487
  87. package/dist/services/farseerService.js.map +7 -0
  88. package/dist/services/syncService.js +661 -731
  89. package/dist/services/syncService.js.map +7 -0
  90. package/dist/utils/constants.js +52 -19
  91. package/dist/utils/constants.js.map +7 -0
  92. package/dist/utils/entityResolver.js +78 -0
  93. package/dist/utils/entityResolver.js.map +7 -0
  94. package/dist/utils/helpers.js +331 -365
  95. package/dist/utils/helpers.js.map +7 -0
  96. package/dist/utils/logger.js +74 -42
  97. package/dist/utils/logger.js.map +7 -0
  98. package/package.json +3 -2
@@ -1,69 +1,68 @@
1
1
  "use strict";
2
- /**
3
- * App Management Tools
4
- *
5
- * Tools for managing Farseer apps (Remote Jobs).
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.registerAppTools = registerAppTools;
9
- const zod_1 = require("zod");
10
- const farseerFactory_1 = require("../../services/farseerFactory");
11
- const helpers_1 = require("../utils/helpers");
12
- // Define schemas outside of tool registration to avoid deep type instantiation
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var appTools_exports = {};
20
+ __export(appTools_exports, {
21
+ registerAppTools: () => registerAppTools
22
+ });
23
+ module.exports = __toCommonJS(appTools_exports);
24
+ var import_zod = require("zod");
25
+ var import_farseerFactory = require("../../services/farseerFactory");
26
+ var import_helpers = require("../utils/helpers");
13
27
  const listAppsSchema = {
14
- organisation: zod_1.z
15
- .string()
16
- .optional()
17
- .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
18
- tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
19
- details: zod_1.z.boolean().optional().describe('Include full details for each app'),
28
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
29
+ tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
30
+ details: import_zod.z.boolean().optional().describe("Include full details for each app")
20
31
  };
21
32
  const getAppSchema = {
22
- organisation: zod_1.z
23
- .string()
24
- .optional()
25
- .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
26
- tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
27
- appName: zod_1.z.string().describe('Name of the app (can include spaces)'),
33
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
34
+ tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
35
+ appName: import_zod.z.string().describe("Name of the app (can include spaces)")
28
36
  };
29
37
  const createAppSchema = {
30
- organisation: zod_1.z
31
- .string()
32
- .optional()
33
- .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
34
- tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
35
- appName: zod_1.z.string().describe('Name for the new app'),
38
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
39
+ tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
40
+ appName: import_zod.z.string().describe("Name for the new app")
36
41
  };
37
- const argumentSchema = zod_1.z.object({
38
- name: zod_1.z.string(),
39
- defaultValue: zod_1.z.string(),
42
+ const argumentSchema = import_zod.z.object({
43
+ name: import_zod.z.string(),
44
+ defaultValue: import_zod.z.string()
40
45
  });
41
46
  const configureAppSchema = {
42
- organisation: zod_1.z
43
- .string()
44
- .optional()
45
- .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
46
- tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
47
- appName: zod_1.z.string().describe('Name of the app to configure'),
48
- entrypoint: zod_1.z.string().optional().describe('Main script filename (e.g., "index.ts")'),
49
- scripts: zod_1.z.array(zod_1.z.string()).optional().describe('List of script filenames to include'),
50
- description: zod_1.z.string().optional().describe('App description'),
51
- arguments: zod_1.z.array(argumentSchema).optional().describe('App arguments with default values'),
52
- newName: zod_1.z.string().optional().describe('Rename the app'),
47
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
48
+ tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
49
+ appName: import_zod.z.string().describe("Name of the app to configure"),
50
+ entrypoint: import_zod.z.string().optional().describe('Main script filename (e.g., "index.ts")'),
51
+ scripts: import_zod.z.array(import_zod.z.string()).optional().describe("List of script filenames to include"),
52
+ description: import_zod.z.string().optional().describe("App description"),
53
+ arguments: import_zod.z.array(argumentSchema).optional().describe("App arguments with default values"),
54
+ newName: import_zod.z.string().optional().describe("Rename the app")
53
55
  };
54
56
  const deleteAppSchema = {
55
- organisation: zod_1.z
56
- .string()
57
- .optional()
58
- .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
59
- tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
60
- appName: zod_1.z.string().describe('Name of the app to delete'),
57
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
58
+ tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
59
+ appName: import_zod.z.string().describe("Name of the app to delete")
61
60
  };
62
61
  function registerAppTools(server) {
63
- // Cast to avoid TS2589 deep type instantiation with MCP SDK + Zod generics
64
- const s = server;
65
- // farseer_list_apps - List all apps
66
- s.tool('farseer_list_apps', `List all apps (Remote Jobs) configured on a Farseer tenant.
62
+ const s = server;
63
+ s.tool(
64
+ "farseer_list_apps",
65
+ `List all apps (Remote Jobs) configured on a Farseer tenant.
67
66
 
68
67
  Apps are executable script configurations that include:
69
68
  - Entry point script
@@ -72,61 +71,66 @@ Apps are executable script configurations that include:
72
71
 
73
72
  Use details=true to include full information for each app.
74
73
 
75
- If no tenant is specified, uses the currently checked-out tenant.`, listAppsSchema, async (params) => {
76
- const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
77
- if (!resolved) {
78
- return (0, helpers_1.tenantRequiredResponse)();
79
- }
80
- const { organisation, tenant } = resolved;
81
- const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
82
- if (!clientResult) {
83
- return (0, helpers_1.authRequiredResponse)(tenant);
74
+ If no tenant is specified, uses the currently checked-out tenant.`,
75
+ listAppsSchema,
76
+ async (params) => {
77
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
78
+ if (!resolved) {
79
+ return (0, import_helpers.tenantRequiredResponse)();
80
+ }
81
+ const { organisation, tenant } = resolved;
82
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
83
+ if (!clientResult) {
84
+ return (0, import_helpers.authRequiredResponse)(tenant);
85
+ }
86
+ try {
87
+ const appList = await clientResult.client.listApps();
88
+ if (!params.details) {
89
+ return (0, import_helpers.successResponse)({
90
+ tenant,
91
+ totalApps: appList.length,
92
+ apps: appList.map((a) => ({
93
+ name: a.name,
94
+ id: a.id,
95
+ reference: a.reference
96
+ }))
97
+ });
84
98
  }
85
- try {
86
- const appList = await clientResult.client.listApps();
87
- if (!params.details) {
88
- return (0, helpers_1.successResponse)({
89
- tenant,
90
- totalApps: appList.length,
91
- apps: appList.map((a) => ({
92
- name: a.name,
93
- id: a.id,
94
- reference: a.reference,
95
- })),
96
- });
97
- }
98
- // Get full details for each app
99
- const appsWithDetails = [];
100
- for (const item of appList) {
101
- const app = await clientResult.client.getApp(item.reference);
102
- if (app) {
103
- const appScripts = app.scriptFiles ?? [];
104
- const mainScript = appScripts.find((s) => s.id === app.mainScriptFileId);
105
- appsWithDetails.push({
106
- name: app.name,
107
- id: app.id,
108
- description: app.description || '',
109
- entrypoint: mainScript?.name || null,
110
- scripts: appScripts.map((s) => s.name),
111
- arguments: app.expectedArguments.map((a) => ({
112
- name: a.name,
113
- defaultValue: a.defaultValue,
114
- })),
115
- });
116
- }
117
- }
118
- return (0, helpers_1.successResponse)({
119
- tenant,
120
- totalApps: appsWithDetails.length,
121
- apps: appsWithDetails,
99
+ const appsWithDetails = [];
100
+ for (const item of appList) {
101
+ const app = await clientResult.client.getApp(item.reference);
102
+ if (app) {
103
+ const appScripts = app.scriptFiles ?? [];
104
+ const mainScript = appScripts.find((s2) => s2.id === app.mainScriptFileId);
105
+ appsWithDetails.push({
106
+ name: app.name,
107
+ id: app.id,
108
+ description: app.description || "",
109
+ entrypoint: mainScript?.name || null,
110
+ scripts: appScripts.map((s2) => s2.name),
111
+ arguments: app.expectedArguments.map((a) => ({
112
+ name: a.name,
113
+ defaultValue: a.defaultValue
114
+ }))
122
115
  });
116
+ }
123
117
  }
124
- catch (error) {
125
- return (0, helpers_1.errorResponse)(`List apps failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
126
- }
127
- });
128
- // farseer_get_app - Get app details
129
- s.tool('farseer_get_app', `Get detailed information about a specific Farseer app.
118
+ return (0, import_helpers.successResponse)({
119
+ tenant,
120
+ totalApps: appsWithDetails.length,
121
+ apps: appsWithDetails
122
+ });
123
+ } catch (error) {
124
+ return (0, import_helpers.errorResponse)(
125
+ `List apps failed: ${error instanceof Error ? error.message : "Unknown error"}`,
126
+ "NETWORK_ERROR"
127
+ );
128
+ }
129
+ }
130
+ );
131
+ s.tool(
132
+ "farseer_get_app",
133
+ `Get detailed information about a specific Farseer app.
130
134
 
131
135
  Returns:
132
136
  - App name and description
@@ -134,51 +138,57 @@ Returns:
134
138
  - List of all included scripts
135
139
  - Expected arguments with their default values
136
140
 
137
- If no tenant is specified, uses the currently checked-out tenant.`, getAppSchema, async (params) => {
138
- const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
139
- if (!resolved) {
140
- return (0, helpers_1.tenantRequiredResponse)();
141
- }
142
- const { organisation, tenant } = resolved;
143
- const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
144
- if (!clientResult) {
145
- return (0, helpers_1.authRequiredResponse)(tenant);
141
+ If no tenant is specified, uses the currently checked-out tenant.`,
142
+ getAppSchema,
143
+ async (params) => {
144
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
145
+ if (!resolved) {
146
+ return (0, import_helpers.tenantRequiredResponse)();
147
+ }
148
+ const { organisation, tenant } = resolved;
149
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
150
+ if (!clientResult) {
151
+ return (0, import_helpers.authRequiredResponse)(tenant);
152
+ }
153
+ try {
154
+ const app = await clientResult.client.getAppByName(params.appName);
155
+ if (!app) {
156
+ return (0, import_helpers.errorResponse)(`App "${params.appName}" not found`, "NOT_FOUND");
146
157
  }
147
- try {
148
- const app = await clientResult.client.getAppByName(params.appName);
149
- if (!app) {
150
- return (0, helpers_1.errorResponse)(`App "${params.appName}" not found`, 'NOT_FOUND');
151
- }
152
- const getAppScripts = app.scriptFiles ?? [];
153
- const mainScript = getAppScripts.find((s) => s.id === app.mainScriptFileId);
154
- return (0, helpers_1.successResponse)({
155
- tenant,
156
- app: {
157
- id: app.id,
158
- name: app.name,
159
- description: app.description || '',
160
- entrypoint: mainScript?.name || null,
161
- scripts: getAppScripts.map((s) => ({
162
- id: s.id,
163
- name: s.name,
164
- isEntrypoint: s.id === app.mainScriptFileId,
165
- })),
166
- arguments: app.expectedArguments.map((a) => ({
167
- name: a.name,
168
- type: a.type,
169
- defaultValue: a.defaultValue,
170
- })),
171
- status: app.status,
172
- lastHeartbeat: app.lastHeartbeat,
173
- },
174
- });
175
- }
176
- catch (error) {
177
- return (0, helpers_1.errorResponse)(`Get app failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
178
- }
179
- });
180
- // farseer_create_app - Create new app
181
- s.tool('farseer_create_app', `Create a new Farseer app.
158
+ const getAppScripts = app.scriptFiles ?? [];
159
+ const mainScript = getAppScripts.find((s2) => s2.id === app.mainScriptFileId);
160
+ return (0, import_helpers.successResponse)({
161
+ tenant,
162
+ app: {
163
+ id: app.id,
164
+ name: app.name,
165
+ description: app.description || "",
166
+ entrypoint: mainScript?.name || null,
167
+ scripts: getAppScripts.map((s2) => ({
168
+ id: s2.id,
169
+ name: s2.name,
170
+ isEntrypoint: s2.id === app.mainScriptFileId
171
+ })),
172
+ arguments: app.expectedArguments.map((a) => ({
173
+ name: a.name,
174
+ type: a.type,
175
+ defaultValue: a.defaultValue
176
+ })),
177
+ status: app.status,
178
+ lastHeartbeat: app.lastHeartbeat
179
+ }
180
+ });
181
+ } catch (error) {
182
+ return (0, import_helpers.errorResponse)(
183
+ `Get app failed: ${error instanceof Error ? error.message : "Unknown error"}`,
184
+ "NETWORK_ERROR"
185
+ );
186
+ }
187
+ }
188
+ );
189
+ s.tool(
190
+ "farseer_create_app",
191
+ `Create a new Farseer app.
182
192
 
183
193
  A Farseer App is a named configuration that points to a TypeScript script and defines its arguments.
184
194
  The script uses farseer-client to interact with the Farseer API (import data, export reports, etc.).
@@ -192,38 +202,43 @@ Workflow to create a new app:
192
202
 
193
203
  Scripts should use \`new FarseerClient()\` with no arguments - credentials are injected via environment variables by the CLI at runtime.
194
204
 
195
- If no tenant is specified, uses the currently checked-out tenant.`, createAppSchema, async (params) => {
196
- const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
197
- if (!resolved) {
198
- return (0, helpers_1.tenantRequiredResponse)();
199
- }
200
- const { organisation, tenant } = resolved;
201
- const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
202
- if (!clientResult) {
203
- return (0, helpers_1.authRequiredResponse)(tenant);
204
- }
205
- try {
206
- // Check if app already exists
207
- const existing = await clientResult.client.getAppByName(params.appName);
208
- if (existing) {
209
- return (0, helpers_1.errorResponse)(`App "${params.appName}" already exists`, 'VALIDATION_ERROR');
210
- }
211
- const app = await clientResult.client.createApp(params.appName);
212
- return (0, helpers_1.successResponse)({
213
- tenant,
214
- app: {
215
- id: app.id,
216
- name: app.name,
217
- },
218
- message: `App "${params.appName}" created. Use farseer_configure_app to set entrypoint, scripts, and arguments.`,
219
- });
205
+ If no tenant is specified, uses the currently checked-out tenant.`,
206
+ createAppSchema,
207
+ async (params) => {
208
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
209
+ if (!resolved) {
210
+ return (0, import_helpers.tenantRequiredResponse)();
211
+ }
212
+ const { organisation, tenant } = resolved;
213
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
214
+ if (!clientResult) {
215
+ return (0, import_helpers.authRequiredResponse)(tenant);
216
+ }
217
+ try {
218
+ const existing = await clientResult.client.getAppByName(params.appName);
219
+ if (existing) {
220
+ return (0, import_helpers.errorResponse)(`App "${params.appName}" already exists`, "VALIDATION_ERROR");
220
221
  }
221
- catch (error) {
222
- return (0, helpers_1.errorResponse)(`Create app failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
223
- }
224
- });
225
- // farseer_configure_app - Configure app settings
226
- s.tool('farseer_configure_app', `Configure an existing Farseer app.
222
+ const app = await clientResult.client.createApp(params.appName);
223
+ return (0, import_helpers.successResponse)({
224
+ tenant,
225
+ app: {
226
+ id: app.id,
227
+ name: app.name
228
+ },
229
+ message: `App "${params.appName}" created. Use farseer_configure_app to set entrypoint, scripts, and arguments.`
230
+ });
231
+ } catch (error) {
232
+ return (0, import_helpers.errorResponse)(
233
+ `Create app failed: ${error instanceof Error ? error.message : "Unknown error"}`,
234
+ "NETWORK_ERROR"
235
+ );
236
+ }
237
+ }
238
+ );
239
+ s.tool(
240
+ "farseer_configure_app",
241
+ `Configure an existing Farseer app.
227
242
 
228
243
  You can set:
229
244
  - entrypoint: Main script to execute (e.g., "index.ts")
@@ -237,112 +252,129 @@ Important:
237
252
  - If you set scripts but not entrypoint, the first script becomes entrypoint
238
253
  - Arguments are passed to the script via command line
239
254
 
240
- If no tenant is specified, uses the currently checked-out tenant.`, configureAppSchema, async (params) => {
241
- const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
242
- if (!resolved) {
243
- return (0, helpers_1.tenantRequiredResponse)();
255
+ If no tenant is specified, uses the currently checked-out tenant.`,
256
+ configureAppSchema,
257
+ async (params) => {
258
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
259
+ if (!resolved) {
260
+ return (0, import_helpers.tenantRequiredResponse)();
261
+ }
262
+ const { organisation, tenant } = resolved;
263
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
264
+ if (!clientResult) {
265
+ return (0, import_helpers.authRequiredResponse)(tenant);
266
+ }
267
+ try {
268
+ const app = await clientResult.client.getAppByName(params.appName);
269
+ if (!app) {
270
+ return (0, import_helpers.errorResponse)(`App "${params.appName}" not found`, "NOT_FOUND");
244
271
  }
245
- const { organisation, tenant } = resolved;
246
- const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
247
- if (!clientResult) {
248
- return (0, helpers_1.authRequiredResponse)(tenant);
272
+ const availableScripts = await clientResult.client.getScriptFiles();
273
+ const scriptIdMap = new Map(availableScripts.map((s2) => [s2.name.toLowerCase(), s2.id]));
274
+ const update = {};
275
+ if (params.newName) {
276
+ update.name = params.newName;
249
277
  }
250
- try {
251
- const app = await clientResult.client.getAppByName(params.appName);
252
- if (!app) {
253
- return (0, helpers_1.errorResponse)(`App "${params.appName}" not found`, 'NOT_FOUND');
254
- }
255
- // Get available scripts for ID lookup
256
- const availableScripts = await clientResult.client.getScriptFiles();
257
- const scriptIdMap = new Map(availableScripts.map((s) => [s.name.toLowerCase(), s.id]));
258
- // Build update payload
259
- const update = {};
260
- if (params.newName) {
261
- update.name = params.newName;
262
- }
263
- if (params.description !== undefined) {
264
- update.description = params.description;
265
- }
266
- if (params.arguments) {
267
- update.expectedArguments = params.arguments.map((a) => ({
268
- name: a.name,
269
- type: 'variable',
270
- defaultValue: a.defaultValue,
271
- }));
272
- }
273
- if (params.scripts && params.scripts.length > 0) {
274
- const scriptIds = [];
275
- const notFound = [];
276
- for (const scriptName of params.scripts) {
277
- const id = scriptIdMap.get(scriptName.toLowerCase());
278
- if (id) {
279
- scriptIds.push(id);
280
- }
281
- else {
282
- notFound.push(scriptName);
283
- }
284
- }
285
- if (notFound.length > 0) {
286
- return (0, helpers_1.errorResponse)(`Scripts not found on remote: ${notFound.join(', ')}. Push them first.`, 'VALIDATION_ERROR');
287
- }
288
- update.scriptFileIds = scriptIds;
289
- // Set entrypoint to first script if not explicitly specified
290
- if (!params.entrypoint && scriptIds.length > 0) {
291
- update.mainScriptFileId = scriptIds[0];
292
- }
293
- }
294
- if (params.entrypoint) {
295
- const entrypointId = scriptIdMap.get(params.entrypoint.toLowerCase());
296
- if (!entrypointId) {
297
- return (0, helpers_1.errorResponse)(`Entrypoint script "${params.entrypoint}" not found on remote. Push it first.`, 'VALIDATION_ERROR');
298
- }
299
- update.mainScriptFileId = entrypointId;
278
+ if (params.description !== void 0) {
279
+ update.description = params.description;
280
+ }
281
+ if (params.arguments) {
282
+ update.expectedArguments = params.arguments.map((a) => ({
283
+ name: a.name,
284
+ type: "variable",
285
+ defaultValue: a.defaultValue
286
+ }));
287
+ }
288
+ if (params.scripts && params.scripts.length > 0) {
289
+ const scriptIds = [];
290
+ const notFound = [];
291
+ for (const scriptName of params.scripts) {
292
+ const id = scriptIdMap.get(scriptName.toLowerCase());
293
+ if (id) {
294
+ scriptIds.push(id);
295
+ } else {
296
+ notFound.push(scriptName);
300
297
  }
301
- // Apply update
302
- const reference = app.id.toString();
303
- await clientResult.client.updateApp(reference, update);
304
- return (0, helpers_1.successResponse)({
305
- tenant,
306
- appName: params.newName || params.appName,
307
- updated: Object.keys(update),
308
- message: `App "${params.appName}" configured successfully`,
309
- });
298
+ }
299
+ if (notFound.length > 0) {
300
+ return (0, import_helpers.errorResponse)(
301
+ `Scripts not found on remote: ${notFound.join(", ")}. Push them first.`,
302
+ "VALIDATION_ERROR"
303
+ );
304
+ }
305
+ update.scriptFileIds = scriptIds;
306
+ if (!params.entrypoint && scriptIds.length > 0) {
307
+ update.mainScriptFileId = scriptIds[0];
308
+ }
310
309
  }
311
- catch (error) {
312
- return (0, helpers_1.errorResponse)(`Configure app failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
310
+ if (params.entrypoint) {
311
+ const entrypointId = scriptIdMap.get(params.entrypoint.toLowerCase());
312
+ if (!entrypointId) {
313
+ return (0, import_helpers.errorResponse)(
314
+ `Entrypoint script "${params.entrypoint}" not found on remote. Push it first.`,
315
+ "VALIDATION_ERROR"
316
+ );
317
+ }
318
+ update.mainScriptFileId = entrypointId;
313
319
  }
314
- });
315
- // farseer_delete_app - Delete app
316
- s.tool('farseer_delete_app', `Delete an app from a Farseer tenant.
320
+ const reference = app.id.toString();
321
+ await clientResult.client.updateApp(reference, update);
322
+ return (0, import_helpers.successResponse)({
323
+ tenant,
324
+ appName: params.newName || params.appName,
325
+ updated: Object.keys(update),
326
+ message: `App "${params.appName}" configured successfully`
327
+ });
328
+ } catch (error) {
329
+ return (0, import_helpers.errorResponse)(
330
+ `Configure app failed: ${error instanceof Error ? error.message : "Unknown error"}`,
331
+ "NETWORK_ERROR"
332
+ );
333
+ }
334
+ }
335
+ );
336
+ s.tool(
337
+ "farseer_delete_app",
338
+ `Delete an app from a Farseer tenant.
317
339
 
318
340
  WARNING: This is irreversible - the app will be permanently removed from the remote instance.
319
341
 
320
342
  This does NOT delete the script files, only the app configuration.
321
343
 
322
- If no tenant is specified, uses the currently checked-out tenant.`, deleteAppSchema, async (params) => {
323
- const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
324
- if (!resolved) {
325
- return (0, helpers_1.tenantRequiredResponse)();
326
- }
327
- const { organisation, tenant } = resolved;
328
- const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
329
- if (!clientResult) {
330
- return (0, helpers_1.authRequiredResponse)(tenant);
344
+ If no tenant is specified, uses the currently checked-out tenant.`,
345
+ deleteAppSchema,
346
+ async (params) => {
347
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
348
+ if (!resolved) {
349
+ return (0, import_helpers.tenantRequiredResponse)();
350
+ }
351
+ const { organisation, tenant } = resolved;
352
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
353
+ if (!clientResult) {
354
+ return (0, import_helpers.authRequiredResponse)(tenant);
355
+ }
356
+ try {
357
+ const app = await clientResult.client.getAppByName(params.appName);
358
+ if (!app) {
359
+ return (0, import_helpers.errorResponse)(`App "${params.appName}" not found`, "NOT_FOUND");
331
360
  }
332
- try {
333
- const app = await clientResult.client.getAppByName(params.appName);
334
- if (!app) {
335
- return (0, helpers_1.errorResponse)(`App "${params.appName}" not found`, 'NOT_FOUND');
336
- }
337
- await clientResult.client.deleteApp(app.id.toString());
338
- return (0, helpers_1.successResponse)({
339
- tenant,
340
- deletedApp: params.appName,
341
- message: `App "${params.appName}" has been deleted`,
342
- });
343
- }
344
- catch (error) {
345
- return (0, helpers_1.errorResponse)(`Delete app failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
346
- }
347
- });
361
+ await clientResult.client.deleteApp(app.id.toString());
362
+ return (0, import_helpers.successResponse)({
363
+ tenant,
364
+ deletedApp: params.appName,
365
+ message: `App "${params.appName}" has been deleted`
366
+ });
367
+ } catch (error) {
368
+ return (0, import_helpers.errorResponse)(
369
+ `Delete app failed: ${error instanceof Error ? error.message : "Unknown error"}`,
370
+ "NETWORK_ERROR"
371
+ );
372
+ }
373
+ }
374
+ );
348
375
  }
376
+ // Annotate the CommonJS export names for ESM import in node:
377
+ 0 && (module.exports = {
378
+ registerAppTools
379
+ });
380
+ //# sourceMappingURL=appTools.js.map