farseer-cli 1.11.2 → 1.12.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 CHANGED
@@ -515,10 +515,32 @@ farseer app configure My App --add-arg "Year=2025"
515
515
 
516
516
  # Set description
517
517
  farseer app configure My App --description "Imports data"
518
+
519
+ # Run it every morning at 06:00
520
+ farseer app configure My App --schedule "0 6 * * *"
521
+
522
+ # Pick the jobrunner and the container image it runs in
523
+ farseer app configure My App --runner runner-1 --runner-image runner-typescript:latest
524
+
525
+ # Give the run a machine of its own, sized large
526
+ farseer app configure My App --compute batch:l
518
527
  ```
519
528
 
520
529
  Settings you don't pass are preserved — `configure` only changes what you specify.
521
530
 
531
+ | Flag | Sets |
532
+ |---|---|
533
+ | `--schedule <cron>` | Cron expression the app runs on. Five fields, or six when the first is seconds. Sent as written: nothing here checks it, because the UI and the API don't either, and a check in one surface only would make the same expression valid or invalid depending on where it was typed. A schedule the runner can't read means the job never runs. |
534
+ | `--runner <name>` | Which connected jobrunner runs the app. Unset means any of them. |
535
+ | `--runner-image <image>` | Container image, as `<repository>:<tag>` — the tenant's registry prefix is filled in — or a full registry reference. |
536
+ | `--compute <choice>` | `local`, `batch`, or `batch:<size>` with size `s`, `m`, `l` or `xl`. `local` runs the job in a container on the jobrunner's own machine; `batch` creates a machine for that one run, and bare `batch` takes the deployment's default size. |
537
+
538
+ Pass `none` to `--schedule`, `--runner` or `--runner-image` to clear it.
539
+
540
+ A runner that isn't connected, or one that can't run the compute you picked, is
541
+ reported as a warning rather than an error: these settings outlive any one
542
+ connection, so a jobrunner that happens to be restarting doesn't block you.
543
+
522
544
  If you move the source folder to one that doesn't contain the app's current
523
545
  entrypoint, pass `--entrypoint` in the same command — `configure` errors rather
524
546
  than silently clearing or relocating the entrypoint.
@@ -673,6 +695,7 @@ Once configured, AI assistants have access to:
673
695
  - `farseer_get_app` - Get app details
674
696
  - `farseer_create_app` - Create new app
675
697
  - `farseer_configure_app` - Configure app (scripts can be referenced by filename or full path)
698
+ - `predefinedActions` replaces the app's whole list. A secret argument's value reads back as `<secret>`; send `<secret>` to keep the stored value of the action with exactly that name; where two actions share a name, give the real value. `none` clears `schedule`, `runner` or `runnerImage`.
676
699
  - `farseer_delete_app` - Delete app
677
700
  - `farseer_run_app` - Run app locally
678
701
  - `farseer_install` - Install dependencies (auto-creates package.json, supports adding extra npm packages)
@@ -779,6 +802,9 @@ apps/
779
802
  { "name": "Year", "defaultValue": "2025" },
780
803
  { "name": "Version", "defaultValue": "Plan" }
781
804
  ],
805
+ "schedule": "0 6 * * *",
806
+ "runnerImage": "europe-docker.pkg.dev/farseer/runners/runner-typescript:1.4.0",
807
+ "compute": "batch:l",
782
808
  "_remote": {
783
809
  "id": 123,
784
810
  "reference": "123"
@@ -791,6 +817,40 @@ apps/
791
817
  - For **existing apps**: `_remote` links local JSON to remote app
792
818
  - Never edit `_remote` manually
793
819
 
820
+ `schedule`, `runnerImage` and `compute` are managed by whether the key is there.
821
+ A key present means the file decides that setting and `push` writes it —
822
+ including `null`, which clears it. A key absent means the file says nothing about
823
+ it and `push` leaves whatever the tenant has, so a config written before these
824
+ fields existed never clears a live schedule. `pull` writes all three, so pulling
825
+ once puts them under version control — including in a file that predates them,
826
+ which the first `pull` after upgrading rewrites to add the missing keys.
827
+
828
+ Two settings are not in the file, and are set with `app configure` or the
829
+ `farseer_configure_app` tool instead:
830
+
831
+ - **The runner.** The backend assigns a runner to a scheduled job that has none,
832
+ and stores it. A file cannot tell that assignment from a choice, so pulling it
833
+ would pin whatever the scheduler happened to pick, and pushing would clear it
834
+ only for the scheduler to assign it again.
835
+ - **Predefined actions.** The backend returns their values readable even for
836
+ arguments marked secret, so writing them to the file would put secrets in the
837
+ workspace and in git. `app show` and `farseer_get_app` show a secret
838
+ argument's value as `<secret>`. Pushing a file never touches the tenant's
839
+ actions.
840
+
841
+ `pull` removes `runner` and `predefinedActions` from a file an earlier version
842
+ wrote them into.
843
+
844
+ The file holds stored values, not the shorthands `app configure` accepts.
845
+ `runnerImage` must be the full registry reference: `push` sends it as written and
846
+ the API rejects a bare `<repository>:<tag>`. `none` is a flag keyword, so write
847
+ `null` in the file to clear a setting. `schedule` is sent as written and is not
848
+ checked here — see the note under `--schedule` above.
849
+
850
+ A teammate still on an older CLI drops these three keys from the file on their
851
+ next `pull`, because their version does not know about them; the tenant's own
852
+ settings are untouched and the next `pull` on this version puts the keys back.
853
+
794
854
  ---
795
855
 
796
856
  ## Configuration
@@ -45,7 +45,7 @@ Commands:
45
45
  list [tenant] List all apps
46
46
  show [tenant] <name...> Show app details
47
47
  create [tenant] <name...> Create a new app
48
- configure [tenant] <name...> Configure app (source folder, entrypoint, arguments)
48
+ configure [tenant] <name...> Configure app (source folder, entrypoint, arguments, schedule, runner, compute)
49
49
  delete [tenant] <name...> Delete an app (requires --force)
50
50
 
51
51
  Note: App names with spaces don't need quotes when the tenant comes from FARSEER_TENANT.
@@ -55,6 +55,7 @@ Examples:
55
55
  $ farseer app show mycompany "My App" # Explicit tenant
56
56
  $ farseer app show My App # Uses FARSEER_TENANT
57
57
  $ farseer app configure "My App" --entrypoint index.ts
58
+ $ farseer app configure "My App" --schedule "0 6 * * *" --compute batch:l
58
59
  `
59
60
  );
60
61
  appCmd.command("list [tenant]").description("List all apps on a Farseer instance").option("--details", "Show detailed information for each app").action(async (tenantArg, options) => {
@@ -81,6 +82,16 @@ Examples:
81
82
  console.log(
82
83
  ` Status: ${details.status === "AVAILABLE" ? import_chalk.default.green(details.status) : import_chalk.default.yellow(details.status)}`
83
84
  );
85
+ if (details.schedule) {
86
+ console.log(` Schedule: ${details.schedule}`);
87
+ }
88
+ if (details.runnerName) {
89
+ console.log(` Runner: ${details.runnerName}`);
90
+ }
91
+ if (details.runnerImage) {
92
+ console.log(` Runner image: ${details.runnerImage}`);
93
+ }
94
+ console.log(` Compute: ${(0, import_apps.formatCompute)(details.compute)}`);
84
95
  const detailScripts = details.scriptFiles ?? [];
85
96
  if (detailScripts.length > 0) {
86
97
  const mainScript = detailScripts.find((s) => s.id === details.mainScriptFileId);
@@ -136,6 +147,10 @@ Examples:
136
147
  if (app.description) {
137
148
  console.log(` Description: ${app.description}`);
138
149
  }
150
+ console.log(` Schedule: ${app.schedule || "(none)"}`);
151
+ console.log(` Runner: ${app.runnerName || "(any)"}`);
152
+ console.log(` Runner image: ${app.runnerImage || "(default)"}`);
153
+ console.log(` Compute: ${(0, import_apps.formatCompute)(app.compute)}`);
139
154
  console.log();
140
155
  const appScripts = app.scriptFiles ?? [];
141
156
  if (appScripts.length > 0) {
@@ -159,6 +174,15 @@ Examples:
159
174
  console.log(" Arguments: None");
160
175
  }
161
176
  console.log();
177
+ const actions = (0, import_apps.redactActionValues)(app.predefinedActions ?? [], app.expectedArguments);
178
+ if (actions.length > 0) {
179
+ console.log(" Predefined actions:");
180
+ for (const action of actions) {
181
+ const preset = Object.entries(action.runArguments ?? {}).map(([name, value]) => `${name}=${value}`).join(", ");
182
+ console.log(` - ${action.name}: ${import_chalk.default.dim(preset)}`);
183
+ }
184
+ console.log();
185
+ }
162
186
  });
163
187
  appCmd.command("create <args...>").description("Create a new app").action(async (args) => {
164
188
  const { organisation, tenant, appName } = (0, import_helpers.parseAppArgs)(args);
@@ -210,7 +234,7 @@ Examples:
210
234
  process.exit(1);
211
235
  }
212
236
  });
213
- appCmd.command("configure [args...]").description("Configure an app (set source folder, entrypoint, arguments)").option(
237
+ appCmd.command("configure [args...]").description("Configure an app (source folder, entrypoint, arguments, schedule, runner, compute)").option(
214
238
  "--entrypoint <script>",
215
239
  `Set the entrypoint script \u2014 must be a file in the app's source folder (e.g., "index.ts")`
216
240
  ).option(
@@ -221,7 +245,13 @@ Examples:
221
245
  'Add argument in format "Name=DefaultValue" (can be used multiple times)',
222
246
  collectArgs,
223
247
  []
224
- ).option("--description <desc>", "Set app description").option("--name <name>", "Rename the app").option("--id <id>", "Select the app by its numeric id (use when names collide)").action(async (args, options) => {
248
+ ).option("--description <desc>", "Set app description").option("--name <name>", "Rename the app").option("--id <id>", "Select the app by its numeric id (use when names collide)").option("--schedule <cron>", 'Run the app on a cron schedule (e.g. "0 6 * * *"). Use "none" to clear.').option("--runner <name>", 'Set which jobrunner runs the app. Use "none" to clear.').option(
249
+ "--runner-image <image>",
250
+ 'Set the container image, as "<repository>:<tag>" (e.g. "runner-typescript:latest") or a full registry reference. Use "none" to clear.'
251
+ ).option(
252
+ "--compute <choice>",
253
+ `Where a run executes: ${import_apps.APP_COMPUTE_CHOICES.join(", ")}. "local" is a container on the jobrunner's own machine, "batch" a machine created for that run; the size suffix picks how much machine, and bare "batch" takes the deployment's default size.`
254
+ ).action(async (args, options) => {
225
255
  const { organisation, tenant, appName } = (0, import_helpers.parseAppArgs)(args, {
226
256
  allowEmptyName: !!options.id,
227
257
  command: "app configure"
@@ -254,6 +284,19 @@ Examples:
254
284
  import_logger.logger.error(sourceFolderError);
255
285
  process.exit(1);
256
286
  }
287
+ const runSettings = await (0, import_helpers.orExit)(
288
+ (0, import_apps.applyRunSettings)(api, app, changes, {
289
+ schedule: options.schedule,
290
+ runner: options.runner,
291
+ runnerImage: options.runnerImage,
292
+ compute: options.compute
293
+ }),
294
+ "Failed to read the tenant's runner images."
295
+ );
296
+ if ("error" in runSettings) {
297
+ import_logger.logger.error(runSettings.error);
298
+ process.exit(1);
299
+ }
257
300
  if (options.addArg && options.addArg.length > 0) {
258
301
  const newArgs = [...app.expectedArguments];
259
302
  for (const arg of options.addArg) {
@@ -279,7 +322,7 @@ Examples:
279
322
  if (Object.keys(changes).length === 0) {
280
323
  import_logger.logger.warning("No changes specified.");
281
324
  import_logger.logger.dim(
282
- "Use --entrypoint, --source-folder, --add-arg, --description, or --name to configure the app."
325
+ "Use --entrypoint, --source-folder, --add-arg, --description, --name, --schedule, --runner, --runner-image or --compute to configure the app."
283
326
  );
284
327
  return;
285
328
  }
@@ -309,6 +352,13 @@ Examples:
309
352
  }).join(", ")}`
310
353
  );
311
354
  }
355
+ if ("schedule" in changes) console.log(` Schedule: ${updated.schedule || "(none)"}`);
356
+ if ("runnerName" in changes) console.log(` Runner: ${updated.runnerName || "(any)"}`);
357
+ if ("runnerImage" in changes) console.log(` Runner image: ${updated.runnerImage || "(default)"}`);
358
+ if (changes.compute) console.log(` Compute: ${(0, import_apps.formatCompute)(updated.compute)}`);
359
+ for (const warning of runSettings.warnings) {
360
+ import_logger.logger.warning(warning);
361
+ }
312
362
  } catch (error) {
313
363
  import_logger.logger.error("Failed to update app.");
314
364
  if (error instanceof Error) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/commands/app.ts"],
4
- "sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { preflight, preflightForPair } from '../services/preflight';\nimport { AppArgument, AppUpdateChanges, applySourceFolderChange } from '../services/apps';\nimport { orExit, parseAppArgs, resolveAppItemOrExit, resolveAppOrExit } from '../utils/helpers';\nimport { matchByName } from '../utils/nameResolver';\n\nexport function registerAppCommand(program: Command): void {\n const appCmd = program\n .command('app')\n .description('Manage apps on a Farseer instance')\n .addHelpText(\n 'after',\n `\nCommands:\n list [tenant] List all apps\n show [tenant] <name...> Show app details\n create [tenant] <name...> Create a new app\n configure [tenant] <name...> Configure app (source folder, entrypoint, arguments)\n delete [tenant] <name...> Delete an app (requires --force)\n\nNote: App names with spaces don't need quotes when the tenant comes from FARSEER_TENANT.\n\nExamples:\n $ farseer app list mycompany # List all apps\n $ farseer app show mycompany \"My App\" # Explicit tenant\n $ farseer app show My App # Uses FARSEER_TENANT\n $ farseer app configure \"My App\" --entrypoint index.ts\n`,\n );\n\n // List apps\n appCmd\n .command('list [tenant]')\n .description('List all apps on a Farseer instance')\n .option('--details', 'Show detailed information for each app')\n .action(async (tenantArg, options) => {\n const { tenant, client: api, authType } = await preflight(tenantArg);\n const authLabel = authType === 'apiKey' ? 'API key' : 'browser login';\n logger.info(`Fetching apps from ${tenant} (using ${authLabel})...`);\n\n try {\n const apps = await api.listApps();\n\n if (apps.length === 0) {\n logger.warning('No apps found.');\n logger.dim('Create an app with: farseer app create <name>');\n return;\n }\n\n logger.header(`Apps on ${tenant}`);\n console.log();\n\n if (options.details) {\n // Fetch full details for each app\n for (const app of apps) {\n const details = await api.getApp(app.reference);\n if (details) {\n console.log(` \uD83D\uDCE6 ${chalk.bold(details.name)}`);\n if (details.description) {\n console.log(` ${chalk.dim(details.description)}`);\n }\n console.log(\n ` Status: ${details.status === 'AVAILABLE' ? chalk.green(details.status) : chalk.yellow(details.status)}`,\n );\n const detailScripts = details.scriptFiles ?? [];\n if (detailScripts.length > 0) {\n const mainScript = detailScripts.find((s) => s.id === details.mainScriptFileId);\n console.log(\n ` Entrypoint: ${mainScript ? chalk.cyan(mainScript.name) : chalk.red('Not set')}`,\n );\n console.log(` Scripts:`);\n for (const script of detailScripts) {\n const isMain = script.id === details.mainScriptFileId;\n console.log(\n ` ${isMain ? chalk.green('\u25B6') : ' '} ${script.name}${isMain ? chalk.dim(' (entrypoint)') : ''}`,\n );\n }\n } else {\n console.log(` Scripts: ${chalk.dim('None')}`);\n }\n if (details.expectedArguments.length > 0) {\n console.log(` Arguments:`);\n for (const arg of details.expectedArguments) {\n console.log(` - ${arg.name}: ${chalk.dim(arg.defaultValue ?? '')}`);\n }\n }\n console.log();\n }\n }\n } else {\n // Simple list\n for (const app of apps) {\n console.log(` \uD83D\uDCE6 ${app.name}`);\n }\n console.log();\n logger.dim(`Total: ${apps.length} app(s)`);\n logger.dim('Use --details to see more information.');\n }\n } catch (error) {\n logger.error('Failed to list apps.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Show app details\n appCmd\n .command('show [args...]')\n .description('Show details of an app')\n .option('--id <id>', 'Select the app by its numeric id (use when names collide)')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args, {\n allowEmptyName: !!options.id,\n command: 'app show',\n });\n const { client: api } = await preflightForPair(organisation, tenant);\n const app = await resolveAppOrExit(api, { appName, id: options.id, tenant });\n\n logger.header(`App: ${app.name}`);\n console.log();\n console.log(` ID: ${app.id}`);\n console.log(` Status: ${app.status}`);\n if (app.description) {\n console.log(` Description: ${app.description}`);\n }\n console.log();\n\n const appScripts = app.scriptFiles ?? [];\n if (appScripts.length > 0) {\n console.log(' Scripts:');\n for (const script of appScripts) {\n const isMain = script.id === app.mainScriptFileId;\n console.log(\n ` ${isMain ? chalk.green('\u25B6') : ' '} ${script.name}${isMain ? chalk.dim(' (entrypoint)') : ''}`,\n );\n }\n } else {\n console.log(' Scripts: None');\n }\n console.log();\n\n if (app.expectedArguments.length > 0) {\n console.log(' Arguments:');\n for (const arg of app.expectedArguments) {\n console.log(` - ${arg.name}: ${chalk.dim(arg.defaultValue ?? '')}`);\n }\n } else {\n console.log(' Arguments: None');\n }\n console.log();\n });\n\n // Create app\n appCmd\n .command('create <args...>')\n .description('Create a new app')\n .action(async (args: string[]) => {\n const { organisation, tenant, appName } = parseAppArgs(args);\n const { client: api } = await preflightForPair(organisation, tenant);\n\n // Any name match means the name is taken \u2014 a collision still counts.\n const existing = matchByName(await orExit(api.listApps(), 'Failed to list apps.'), appName);\n if (existing.length > 0) {\n logger.error(`App already exists: ${appName}`);\n process.exit(1);\n }\n\n logger.info(`Creating app: ${appName}...`);\n\n try {\n const app = await api.createApp(appName);\n logger.success(`App created: ${app.name} (ID: ${app.id})`);\n logger.dim('Configure it with: farseer app configure \"' + appName + '\"');\n } catch (error) {\n logger.error('Failed to create app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Delete app\n appCmd\n .command('delete [args...]')\n .description('Delete an app')\n .option('--force', 'Skip confirmation')\n .option('--id <id>', 'Select the app by its numeric id (use when names collide)')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args, {\n allowEmptyName: !!options.id,\n command: 'app delete',\n });\n const { client: api } = await preflightForPair(organisation, tenant);\n\n const item = await resolveAppItemOrExit(api, { appName, id: options.id, tenant });\n\n if (!options.force) {\n logger.warning(`This will permanently delete app: ${item.name}`);\n logger.dim('Use --force to skip this confirmation.');\n process.exit(1);\n }\n\n logger.info(`Deleting app: ${item.name}...`);\n\n try {\n await api.deleteApp(item.reference);\n\n // The folder API 200s even when nothing was deleted; confirm.\n const remaining = await api.listApps();\n if (remaining.some((a) => a.reference === item.reference)) {\n logger.error(`Delete reported success but \"${item.name}\" is still present.`);\n process.exit(1);\n }\n\n logger.success(`App deleted: ${item.name}`);\n } catch (error) {\n logger.error('Failed to delete app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Configure app\n appCmd\n .command('configure [args...]')\n .description('Configure an app (set source folder, entrypoint, arguments)')\n .option(\n '--entrypoint <script>',\n 'Set the entrypoint script \u2014 must be a file in the app\\'s source folder (e.g., \"index.ts\")',\n )\n .option(\n '--source-folder <path>',\n 'Set the source folder the app\\'s scripts come from (path under Files/, e.g. \"Scripts/MyApp\")',\n )\n .option(\n '--add-arg <arg>',\n 'Add argument in format \"Name=DefaultValue\" (can be used multiple times)',\n collectArgs,\n [],\n )\n .option('--description <desc>', 'Set app description')\n .option('--name <name>', 'Rename the app')\n .option('--id <id>', 'Select the app by its numeric id (use when names collide)')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args, {\n allowEmptyName: !!options.id,\n command: 'app configure',\n });\n const { client: api } = await preflightForPair(organisation, tenant);\n\n const item = await resolveAppItemOrExit(api, { appName, id: options.id, tenant });\n\n const app = await orExit(api.getApp(item.reference), `Failed to load app details: ${item.name}`);\n if (!app) {\n logger.error(`Failed to load app details: ${item.name}`);\n process.exit(1);\n }\n\n // Build the set of changes. updateApp merges these onto the app's\n // current state, so anything left out here is preserved.\n const changes: AppUpdateChanges = {};\n\n if (options.name) {\n changes.name = options.name;\n }\n\n if (options.description !== undefined) {\n changes.description = options.description;\n }\n\n // Source folder + entrypoint. An app's scripts are derived from its\n // source folder, and the entrypoint must be one of those files. The\n // decision lives in applySourceFolderChange (shared with the MCP\n // configure_app tool); the 'cli' caller gets dimmed, flag-worded hints.\n const sourceFolderError = await orExit(\n applySourceFolderChange(\n api,\n app,\n changes,\n { sourceFolder: options.sourceFolder, entrypoint: options.entrypoint },\n 'cli',\n ),\n 'Failed to read the source folder.',\n );\n if (sourceFolderError) {\n logger.error(sourceFolderError);\n process.exit(1);\n }\n\n // Handle arguments\n if (options.addArg && options.addArg.length > 0) {\n const newArgs: AppArgument[] = [...app.expectedArguments];\n\n for (const arg of options.addArg) {\n const [name, defaultValue] = arg.split('=');\n if (!name || defaultValue === undefined) {\n logger.error(`Invalid argument format: ${arg}`);\n logger.dim('Use format: --add-arg \"Name=DefaultValue\"');\n process.exit(1);\n }\n\n // Check if arg already exists. Lookup is case-insensitive\n // (user-friendly: --add-arg JOBNAME=x updates an existing\n // jobName), but the written name uses the backend's stored\n // casing \u2014 validateExpectedArguments on the server is\n // case-sensitive, and writing the caller-supplied case\n // would silently rename the arg.\n //\n // --add-arg only sets the defaultValue on a string arg; any\n // existing axes (`dataType`, `fixed`, `options`, `secret`)\n // are preserved so updating a boolean/dropdown/locked arg\n // with --add-arg doesn't silently demote it.\n const existingIdx = newArgs.findIndex((a) => a.name.toLowerCase() === name.toLowerCase());\n if (existingIdx >= 0) {\n const existing = newArgs[existingIdx];\n newArgs[existingIdx] = {\n ...existing,\n defaultValue,\n };\n } else {\n newArgs.push({ name, dataType: 'string', defaultValue });\n }\n }\n\n changes.expectedArguments = newArgs;\n }\n\n if (Object.keys(changes).length === 0) {\n logger.warning('No changes specified.');\n logger.dim(\n 'Use --entrypoint, --source-folder, --add-arg, --description, or --name to configure the app.',\n );\n return;\n }\n\n logger.info(`Updating app: ${app.name}...`);\n\n try {\n const updated = await api.updateApp(item.reference, changes, app);\n logger.success(`App updated: ${updated.name}`);\n\n // Show summary of changes\n if (changes.name) console.log(` Name: ${updated.name}`);\n if (changes.description !== undefined)\n console.log(` Description: ${updated.description || '(empty)'}`);\n if (changes.sourceFolderId !== undefined || changes.mainScriptFileId !== undefined) {\n const updatedScripts = updated.scriptFiles ?? [];\n const mainScript = updatedScripts.find((s) => s.id === updated.mainScriptFileId);\n console.log(` Entrypoint: ${mainScript?.name ?? '(none)'}`);\n console.log(` Scripts: ${updatedScripts.map((s) => s.name).join(', ') || '(none)'}`);\n }\n if (changes.expectedArguments) {\n console.log(\n ` Arguments: ${updated.expectedArguments\n .map((a) => {\n const tags: string[] = [];\n if (a.fixed) tags.push('locked');\n if (a.dataType === 'boolean') tags.push('boolean');\n else if (a.options && a.options.length > 0) tags.push('dropdown');\n if (a.secret) tags.push('secret');\n const suffix = tags.length > 0 ? ` (${tags.join(', ')})` : '';\n return `${a.name}=${a.defaultValue ?? ''}${suffix}`;\n })\n .join(', ')}`,\n );\n }\n } catch (error) {\n logger.error('Failed to update app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n}\n\n// Helper to collect multiple --add-arg options\nfunction collectArgs(value: string, previous: string[]): string[] {\n return previous.concat([value]);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAuB;AACvB,uBAA4C;AAC5C,kBAAuE;AACvE,qBAA6E;AAC7E,0BAA4B;AAErB,SAAS,mBAAmB,SAAwB;AACvD,QAAM,SAAS,QACV,QAAQ,KAAK,EACb,YAAY,mCAAmC,EAC/C;AAAA,IACG;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBJ;AAGJ,SACK,QAAQ,eAAe,EACvB,YAAY,qCAAqC,EACjD,OAAO,aAAa,wCAAwC,EAC5D,OAAO,OAAO,WAAW,YAAY;AAClC,UAAM,EAAE,QAAQ,QAAQ,KAAK,SAAS,IAAI,UAAM,4BA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OAAO,CAAC,KAAK,CAAC;AAClC;",
4
+ "sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { preflight, preflightForPair } from '../services/preflight';\nimport {\n APP_COMPUTE_CHOICES,\n AppArgument,\n AppUpdateChanges,\n applyRunSettings,\n applySourceFolderChange,\n formatCompute,\n redactActionValues,\n} from '../services/apps';\nimport { orExit, parseAppArgs, resolveAppItemOrExit, resolveAppOrExit } from '../utils/helpers';\nimport { matchByName } from '../utils/nameResolver';\n\nexport function registerAppCommand(program: Command): void {\n const appCmd = program\n .command('app')\n .description('Manage apps on a Farseer instance')\n .addHelpText(\n 'after',\n `\nCommands:\n list [tenant] List all apps\n show [tenant] <name...> Show app details\n create [tenant] <name...> Create a new app\n configure [tenant] <name...> Configure app (source folder, entrypoint, arguments, schedule, runner, compute)\n delete [tenant] <name...> Delete an app (requires --force)\n\nNote: App names with spaces don't need quotes when the tenant comes from FARSEER_TENANT.\n\nExamples:\n $ farseer app list mycompany # List all apps\n $ farseer app show mycompany \"My App\" # Explicit tenant\n $ farseer app show My App # Uses FARSEER_TENANT\n $ farseer app configure \"My App\" --entrypoint index.ts\n $ farseer app configure \"My App\" --schedule \"0 6 * * *\" --compute batch:l\n`,\n );\n\n // List apps\n appCmd\n .command('list [tenant]')\n .description('List all apps on a Farseer instance')\n .option('--details', 'Show detailed information for each app')\n .action(async (tenantArg, options) => {\n const { tenant, client: api, authType } = await preflight(tenantArg);\n const authLabel = authType === 'apiKey' ? 'API key' : 'browser login';\n logger.info(`Fetching apps from ${tenant} (using ${authLabel})...`);\n\n try {\n const apps = await api.listApps();\n\n if (apps.length === 0) {\n logger.warning('No apps found.');\n logger.dim('Create an app with: farseer app create <name>');\n return;\n }\n\n logger.header(`Apps on ${tenant}`);\n console.log();\n\n if (options.details) {\n // Fetch full details for each app\n for (const app of apps) {\n const details = await api.getApp(app.reference);\n if (details) {\n console.log(` \uD83D\uDCE6 ${chalk.bold(details.name)}`);\n if (details.description) {\n console.log(` ${chalk.dim(details.description)}`);\n }\n console.log(\n ` Status: ${details.status === 'AVAILABLE' ? chalk.green(details.status) : chalk.yellow(details.status)}`,\n );\n if (details.schedule) {\n console.log(` Schedule: ${details.schedule}`);\n }\n if (details.runnerName) {\n console.log(` Runner: ${details.runnerName}`);\n }\n if (details.runnerImage) {\n console.log(` Runner image: ${details.runnerImage}`);\n }\n console.log(` Compute: ${formatCompute(details.compute)}`);\n const detailScripts = details.scriptFiles ?? [];\n if (detailScripts.length > 0) {\n const mainScript = detailScripts.find((s) => s.id === details.mainScriptFileId);\n console.log(\n ` Entrypoint: ${mainScript ? chalk.cyan(mainScript.name) : chalk.red('Not set')}`,\n );\n console.log(` Scripts:`);\n for (const script of detailScripts) {\n const isMain = script.id === details.mainScriptFileId;\n console.log(\n ` ${isMain ? chalk.green('\u25B6') : ' '} ${script.name}${isMain ? chalk.dim(' (entrypoint)') : ''}`,\n );\n }\n } else {\n console.log(` Scripts: ${chalk.dim('None')}`);\n }\n if (details.expectedArguments.length > 0) {\n console.log(` Arguments:`);\n for (const arg of details.expectedArguments) {\n console.log(` - ${arg.name}: ${chalk.dim(arg.defaultValue ?? '')}`);\n }\n }\n console.log();\n }\n }\n } else {\n // Simple list\n for (const app of apps) {\n console.log(` \uD83D\uDCE6 ${app.name}`);\n }\n console.log();\n logger.dim(`Total: ${apps.length} app(s)`);\n logger.dim('Use --details to see more information.');\n }\n } catch (error) {\n logger.error('Failed to list apps.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Show app details\n appCmd\n .command('show [args...]')\n .description('Show details of an app')\n .option('--id <id>', 'Select the app by its numeric id (use when names collide)')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args, {\n allowEmptyName: !!options.id,\n command: 'app show',\n });\n const { client: api } = await preflightForPair(organisation, tenant);\n const app = await resolveAppOrExit(api, { appName, id: options.id, tenant });\n\n logger.header(`App: ${app.name}`);\n console.log();\n console.log(` ID: ${app.id}`);\n console.log(` Status: ${app.status}`);\n if (app.description) {\n console.log(` Description: ${app.description}`);\n }\n console.log(` Schedule: ${app.schedule || '(none)'}`);\n console.log(` Runner: ${app.runnerName || '(any)'}`);\n console.log(` Runner image: ${app.runnerImage || '(default)'}`);\n console.log(` Compute: ${formatCompute(app.compute)}`);\n console.log();\n\n const appScripts = app.scriptFiles ?? [];\n if (appScripts.length > 0) {\n console.log(' Scripts:');\n for (const script of appScripts) {\n const isMain = script.id === app.mainScriptFileId;\n console.log(\n ` ${isMain ? chalk.green('\u25B6') : ' '} ${script.name}${isMain ? chalk.dim(' (entrypoint)') : ''}`,\n );\n }\n } else {\n console.log(' Scripts: None');\n }\n console.log();\n\n if (app.expectedArguments.length > 0) {\n console.log(' Arguments:');\n for (const arg of app.expectedArguments) {\n console.log(` - ${arg.name}: ${chalk.dim(arg.defaultValue ?? '')}`);\n }\n } else {\n console.log(' Arguments: None');\n }\n console.log();\n\n const actions = redactActionValues(app.predefinedActions ?? [], app.expectedArguments);\n if (actions.length > 0) {\n console.log(' Predefined actions:');\n for (const action of actions) {\n const preset = Object.entries(action.runArguments ?? {})\n .map(([name, value]) => `${name}=${value}`)\n .join(', ');\n console.log(` - ${action.name}: ${chalk.dim(preset)}`);\n }\n console.log();\n }\n });\n\n // Create app\n appCmd\n .command('create <args...>')\n .description('Create a new app')\n .action(async (args: string[]) => {\n const { organisation, tenant, appName } = parseAppArgs(args);\n const { client: api } = await preflightForPair(organisation, tenant);\n\n // Any name match means the name is taken \u2014 a collision still counts.\n const existing = matchByName(await orExit(api.listApps(), 'Failed to list apps.'), appName);\n if (existing.length > 0) {\n logger.error(`App already exists: ${appName}`);\n process.exit(1);\n }\n\n logger.info(`Creating app: ${appName}...`);\n\n try {\n const app = await api.createApp(appName);\n logger.success(`App created: ${app.name} (ID: ${app.id})`);\n logger.dim('Configure it with: farseer app configure \"' + appName + '\"');\n } catch (error) {\n logger.error('Failed to create app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Delete app\n appCmd\n .command('delete [args...]')\n .description('Delete an app')\n .option('--force', 'Skip confirmation')\n .option('--id <id>', 'Select the app by its numeric id (use when names collide)')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args, {\n allowEmptyName: !!options.id,\n command: 'app delete',\n });\n const { client: api } = await preflightForPair(organisation, tenant);\n\n const item = await resolveAppItemOrExit(api, { appName, id: options.id, tenant });\n\n if (!options.force) {\n logger.warning(`This will permanently delete app: ${item.name}`);\n logger.dim('Use --force to skip this confirmation.');\n process.exit(1);\n }\n\n logger.info(`Deleting app: ${item.name}...`);\n\n try {\n await api.deleteApp(item.reference);\n\n // The folder API 200s even when nothing was deleted; confirm.\n const remaining = await api.listApps();\n if (remaining.some((a) => a.reference === item.reference)) {\n logger.error(`Delete reported success but \"${item.name}\" is still present.`);\n process.exit(1);\n }\n\n logger.success(`App deleted: ${item.name}`);\n } catch (error) {\n logger.error('Failed to delete app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Configure app\n appCmd\n .command('configure [args...]')\n .description('Configure an app (source folder, entrypoint, arguments, schedule, runner, compute)')\n .option(\n '--entrypoint <script>',\n 'Set the entrypoint script \u2014 must be a file in the app\\'s source folder (e.g., \"index.ts\")',\n )\n .option(\n '--source-folder <path>',\n 'Set the source folder the app\\'s scripts come from (path under Files/, e.g. \"Scripts/MyApp\")',\n )\n .option(\n '--add-arg <arg>',\n 'Add argument in format \"Name=DefaultValue\" (can be used multiple times)',\n collectArgs,\n [],\n )\n .option('--description <desc>', 'Set app description')\n .option('--name <name>', 'Rename the app')\n .option('--id <id>', 'Select the app by its numeric id (use when names collide)')\n .option('--schedule <cron>', 'Run the app on a cron schedule (e.g. \"0 6 * * *\"). Use \"none\" to clear.')\n .option('--runner <name>', 'Set which jobrunner runs the app. Use \"none\" to clear.')\n .option(\n '--runner-image <image>',\n 'Set the container image, as \"<repository>:<tag>\" (e.g. \"runner-typescript:latest\") or a full registry reference. Use \"none\" to clear.',\n )\n .option(\n '--compute <choice>',\n `Where a run executes: ${APP_COMPUTE_CHOICES.join(', ')}. \"local\" is a container on the jobrunner's own machine, \"batch\" a machine created for that run; the size suffix picks how much machine, and bare \"batch\" takes the deployment's default size.`,\n )\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args, {\n allowEmptyName: !!options.id,\n command: 'app configure',\n });\n const { client: api } = await preflightForPair(organisation, tenant);\n\n const item = await resolveAppItemOrExit(api, { appName, id: options.id, tenant });\n\n const app = await orExit(api.getApp(item.reference), `Failed to load app details: ${item.name}`);\n if (!app) {\n logger.error(`Failed to load app details: ${item.name}`);\n process.exit(1);\n }\n\n // Build the set of changes. updateApp merges these onto the app's\n // current state, so anything left out here is preserved.\n const changes: AppUpdateChanges = {};\n\n if (options.name) {\n changes.name = options.name;\n }\n\n if (options.description !== undefined) {\n changes.description = options.description;\n }\n\n // Source folder + entrypoint. An app's scripts are derived from its\n // source folder, and the entrypoint must be one of those files. The\n // decision lives in applySourceFolderChange (shared with the MCP\n // configure_app tool); the 'cli' caller gets dimmed, flag-worded hints.\n const sourceFolderError = await orExit(\n applySourceFolderChange(\n api,\n app,\n changes,\n { sourceFolder: options.sourceFolder, entrypoint: options.entrypoint },\n 'cli',\n ),\n 'Failed to read the source folder.',\n );\n if (sourceFolderError) {\n logger.error(sourceFolderError);\n process.exit(1);\n }\n\n // Schedule, runner, image and compute. Shared with the MCP\n // configure_app tool so both surfaces take the same vocabulary.\n const runSettings = await orExit(\n applyRunSettings(api, app, changes, {\n schedule: options.schedule,\n runner: options.runner,\n runnerImage: options.runnerImage,\n compute: options.compute,\n }),\n \"Failed to read the tenant's runner images.\",\n );\n if ('error' in runSettings) {\n logger.error(runSettings.error);\n process.exit(1);\n }\n\n // Handle arguments\n if (options.addArg && options.addArg.length > 0) {\n const newArgs: AppArgument[] = [...app.expectedArguments];\n\n for (const arg of options.addArg) {\n const [name, defaultValue] = arg.split('=');\n if (!name || defaultValue === undefined) {\n logger.error(`Invalid argument format: ${arg}`);\n logger.dim('Use format: --add-arg \"Name=DefaultValue\"');\n process.exit(1);\n }\n\n // Check if arg already exists. Lookup is case-insensitive\n // (user-friendly: --add-arg JOBNAME=x updates an existing\n // jobName), but the written name uses the backend's stored\n // casing \u2014 validateExpectedArguments on the server is\n // case-sensitive, and writing the caller-supplied case\n // would silently rename the arg.\n //\n // --add-arg only sets the defaultValue on a string arg; any\n // existing axes (`dataType`, `fixed`, `options`, `secret`)\n // are preserved so updating a boolean/dropdown/locked arg\n // with --add-arg doesn't silently demote it.\n const existingIdx = newArgs.findIndex((a) => a.name.toLowerCase() === name.toLowerCase());\n if (existingIdx >= 0) {\n const existing = newArgs[existingIdx];\n newArgs[existingIdx] = {\n ...existing,\n defaultValue,\n };\n } else {\n newArgs.push({ name, dataType: 'string', defaultValue });\n }\n }\n\n changes.expectedArguments = newArgs;\n }\n\n if (Object.keys(changes).length === 0) {\n logger.warning('No changes specified.');\n logger.dim(\n 'Use --entrypoint, --source-folder, --add-arg, --description, --name, --schedule, --runner, --runner-image or --compute to configure the app.',\n );\n return;\n }\n\n logger.info(`Updating app: ${app.name}...`);\n\n try {\n const updated = await api.updateApp(item.reference, changes, app);\n logger.success(`App updated: ${updated.name}`);\n\n // Show summary of changes\n if (changes.name) console.log(` Name: ${updated.name}`);\n if (changes.description !== undefined)\n console.log(` Description: ${updated.description || '(empty)'}`);\n if (changes.sourceFolderId !== undefined || changes.mainScriptFileId !== undefined) {\n const updatedScripts = updated.scriptFiles ?? [];\n const mainScript = updatedScripts.find((s) => s.id === updated.mainScriptFileId);\n console.log(` Entrypoint: ${mainScript?.name ?? '(none)'}`);\n console.log(` Scripts: ${updatedScripts.map((s) => s.name).join(', ') || '(none)'}`);\n }\n if (changes.expectedArguments) {\n console.log(\n ` Arguments: ${updated.expectedArguments\n .map((a) => {\n const tags: string[] = [];\n if (a.fixed) tags.push('locked');\n if (a.dataType === 'boolean') tags.push('boolean');\n else if (a.options && a.options.length > 0) tags.push('dropdown');\n if (a.secret) tags.push('secret');\n const suffix = tags.length > 0 ? ` (${tags.join(', ')})` : '';\n return `${a.name}=${a.defaultValue ?? ''}${suffix}`;\n })\n .join(', ')}`,\n );\n }\n if ('schedule' in changes) console.log(` Schedule: ${updated.schedule || '(none)'}`);\n if ('runnerName' in changes) console.log(` Runner: ${updated.runnerName || '(any)'}`);\n if ('runnerImage' in changes) console.log(` Runner image: ${updated.runnerImage || '(default)'}`);\n if (changes.compute) console.log(` Compute: ${formatCompute(updated.compute)}`);\n\n for (const warning of runSettings.warnings) {\n logger.warning(warning);\n }\n } catch (error) {\n logger.error('Failed to update app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n}\n\n// Helper to collect multiple --add-arg options\nfunction collectArgs(value: string, previous: string[]): string[] {\n return previous.concat([value]);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAuB;AACvB,uBAA4C;AAC5C,kBAQO;AACP,qBAA6E;AAC7E,0BAA4B;AAErB,SAAS,mBAAmB,SAAwB;AACvD,QAAM,SAAS,QACV,QAAQ,KAAK,EACb,YAAY,mCAAmC,EAC/C;AAAA,IACG;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBJ;AAGJ,SACK,QAAQ,eAAe,EACvB,YAAY,qCAAqC,EACjD,OAAO,aAAa,wCAAwC,EAC5D,OAAO,OAAO,WAAW,YAAY;AAClC,UAAM,EAAE,QAAQ,QAAQ,KAAK,SAAS,IAAI,UAAM,4BAAU,SAAS;AACnE,UAAM,YAAY,aAAa,WAAW,YAAY;AACtD,yBAAO,KAAK,sBAAsB,MAAM,WAAW,SAAS,MAAM;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AAE;AACrF,UAAI,iBAAiB,QAAS,SAAQ,IAAI,mBAAmB,QAAQ,eAAe,WAAW,EAAE;AACjG,UAAI,QAAQ,QAAS,SAAQ,IAAI,kBAAc,2BAAc,QAAQ,OAAO,CAAC,EAAE;AAE/E,iBAAW,WAAW,YAAY,UAAU;AACxC,6BAAO,QAAQ,OAAO;AAAA,MAC1B;AAAA,IACJ,SAAS,OAAO;AACZ,2BAAO,MAAM,uBAAuB;AACpC,UAAI,iBAAiB,OAAO;AACxB,6BAAO,IAAI,MAAM,OAAO;AAAA,MAC5B;AACA,cAAQ,KAAK,CAAC;AAAA,IAClB;AAAA,EACJ,CAAC;AACT;AAGA,SAAS,YAAY,OAAe,UAA8B;AAC9D,SAAO,SAAS,OAAO,CAAC,KAAK,CAAC;AAClC;",
6
6
  "names": ["chalk"]
7
7
  }
@@ -311,6 +311,8 @@ Steps to follow:
311
311
  Copy the source JSON file and modify:
312
312
  - Change "name" to "${newAppName}"
313
313
  - **IMPORTANT: Remove "_remote" field** (this makes it a new app)
314
+ - Set "schedule" to null, unless the user asked for the copy to run on the
315
+ same schedule \u2014 otherwise both apps run at the same moment
314
316
  - Modify arguments, description as needed
315
317
 
316
318
  4. JSON format for new app:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/mcp/prompts/workflows.ts"],
4
- "sourcesContent": ["/**\n * Workflow Prompts\n *\n * Reusable prompt templates for common Farseer workflows.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\n\n// Define schemas outside of prompt registration to avoid deep type instantiation\nconst setupTenantSchema = {\n tenant: z.string().describe('Tenant name to setup'),\n};\n\nconst createAppSchema = {\n tenant: z.string().describe('Tenant name'),\n appName: z.string().describe('Name for the new app'),\n scriptName: z.string().optional().describe('Main script filename (default: index.ts)'),\n};\n\nconst understandModelSchema = {\n tenant: z.string().describe('Tenant name'),\n};\n\nconst writeImportScriptSchema = {\n tenant: z.string().describe('Tenant name'),\n variableName: z.string().describe('Target variable to import into'),\n};\n\nconst copyAppSchema = {\n tenant: z.string().describe('Tenant name'),\n sourceApp: z.string().describe('Name of app to copy'),\n newAppName: z.string().describe('Name for the new app'),\n};\n\nconst exportDataSchema = {\n tenant: z.string().describe('Tenant name'),\n variableName: z.string().describe('Variable to export'),\n};\n\nconst debugSyncSchema = {\n tenant: z.string().describe('Tenant name'),\n};\n\nexport function registerWorkflowPrompts(server: McpServer): void {\n // Cast to any to avoid very deep generic type instantiation from the MCP SDK\n const anyServer = server as any;\n // Setup new tenant\n anyServer.prompt(\n 'setup_new_tenant',\n 'Guide for getting started on the tenant this server is bound to: verify login, pull, install dependencies.',\n setupTenantSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `You are setting up a new Farseer tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Check authentication and the bound tenant with farseer_whoami\n2. If not logged in, inform the user to run \"farseer login\" in terminal (MCP cannot do browser login)\n3. If farseer_whoami does not show \"${tenant}\", tell the user to set --tenant ${tenant} in this MCP server's config and reconnect \u2014 MCP tools cannot change the tenant\n4. Pull files and apps with farseer_pull\n5. Tell user to run \"farseer install ${tenant}\" in terminal to install npm dependencies\n6. Use farseer_list_apps to show available apps\n7. Use farseer_export_model to understand the data structure\n\nAfter setup, the user can:\n- Run apps with farseer_run_app\n- Edit scripts in apps/${tenant}/files/Scripts/\n- Push changes with farseer_push\n- Check model with farseer_get_variable or farseer_get_table`,\n },\n },\n ],\n };\n },\n );\n\n // Create new app\n anyServer.prompt(\n 'create_new_app',\n 'Guide for creating a new Farseer app from scratch.',\n createAppSchema,\n async (params: { tenant: string; appName: string; scriptName?: string }) => {\n const { tenant, appName, scriptName } = params;\n const script = scriptName || 'index.ts';\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Creating a new Farseer app \"${appName}\" for tenant \"${tenant}\".\n\nIMPORTANT: A Farseer App = a TypeScript script + an app config that tells Farseer which script to run and with what arguments.\nThe script uses \\`farseer-client\\` to interact with the Farseer API.\nAuthentication is automatic - \\`new FarseerClient()\\` reads credentials from environment variables injected by the CLI.\nYou NEVER hardcode credentials in scripts.\n\nSteps to follow:\n\n1. Write the script file at farseer-apps/${tenant}/files/Scripts/${script}\n Use the template below as a starting point.\n\n2. Push the script to remote with farseer_push\n (Scripts must exist on remote before they can be assigned to an app)\n\n3. Create the app with farseer_create_app (name: \"${appName}\")\n\n4. Configure the app with farseer_configure_app:\n - sourceFolder: \"Scripts\"\n - entrypoint: \"${script}\"\n - arguments: Add any arguments the script expects (they arrive via process.argv)\n\n5. Test with farseer_run_app\n The CLI injects auth credentials as env vars and runs the script with npx tsx.\n\nScript template:\n\\`\\`\\`typescript\nimport * as farseer from 'farseer-client';\n\n// FarseerClient auto-configures from env vars injected by \"farseer run\"\n// NEVER hardcode credentials - just use the empty constructor\nconst client = new farseer.FarseerClient();\n\n// Arguments come via process.argv in the order defined by app config\nconst args = process.argv.slice(2);\n\nasync function main() {\n // Load dimension/variable metadata\n await client.initTagMap();\n\n // Your code here\n console.log('App running successfully');\n}\n\nmain().catch(farseer.handleUnknownError);\n\\`\\`\\``,\n },\n },\n ],\n };\n },\n );\n\n // Understand model\n anyServer.prompt(\n 'understand_model',\n 'Explore and understand the data model of a Farseer tenant.',\n understandModelSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Analyzing the data model for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_export_model to get the full model structure\n\n2. Review dimension tables:\n - Use farseer_list_tables for overview\n - Key dimensions usually include: Products, Regions, Time (Months, Years), Versions\n - Check foreign key relationships between tables\n\n3. Review variables:\n - Use farseer_list_variables for overview\n - Use farseer_get_variable for specific variable details\n - Note which dimensions each variable has\n\n4. For import scripts, you need to know:\n - Target variable name\n - All dimensions the variable has\n - Valid members for each dimension\n\nKey concepts:\n- Dimensions structure the data (Product, Region, Month, Year, Version)\n- Variables store values at dimension intersections\n- Formulas calculate values automatically\n- Roll-up types determine aggregation (SUM, AVERAGE, etc.)\n\nCommon dimension tables:\n- Months, Years (time)\n- Versions (Plan, Actual, Forecast)\n- Products, Categories, Brands\n- Regions, Entities, Cost Centers`,\n },\n },\n ],\n };\n },\n );\n\n // Write import script\n anyServer.prompt(\n 'write_import_script',\n 'Guide for writing a data import script.',\n writeImportScriptSchema,\n async (params: { tenant: string; variableName: string }) => {\n const { tenant, variableName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Writing an import script for variable \"${variableName}\" in tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_get_variable to understand the target variable:\n - What dimensions does it have?\n - What is the roll-up type?\n\n2. Use farseer_get_table for each dimension to see valid members\n\n3. Create the import script with this pattern:\n\n\\`\\`\\`typescript\nimport * as farseer from 'farseer-client';\n\nconst client = new farseer.FarseerClient();\n\nasync function main() {\n await client.initTagMap();\n\n // Create import job with column definitions\n const importJob = await client.createImportJob({\n title: 'Import ${variableName}',\n columns: [\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Product' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Years' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Months' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Versions' },\n { type: 'VARIABLE', variableName: '${variableName}' },\n ],\n labels: ['auto', 'import-${variableName.toLowerCase().replace(/\\s+/g, '-')}']\n });\n\n // Add rows - each row matches column order\n const rows = [\n ['ProductA', 'Y2025', 'M1', 'Plan', 1000],\n ['ProductB', 'Y2025', 'M1', 'Plan', 2000],\n ];\n\n await importJob.addRows(rows);\n await importJob.flushRows();\n await importJob.undoPrevious(); // Remove previous import\n await importJob.commit();\n\n console.log('Import completed!');\n}\n\nmain().catch(farseer.handleUnknownError);\n\\`\\`\\`\n\n4. Save script to apps/${tenant}/files/Scripts/\n5. Push with farseer_push\n6. Create app with farseer_create_app\n7. Configure with farseer_configure_app\n8. Test with farseer_run_app\n\nALTERNATIVE: For simple imports without a script, use the farseer_create_import_job tool directly.\nIt handles the full workflow (create metadata, add rows, undo previous, commit) in a single call.\nUse farseer_create_import_job when:\n- Data is already available (no need to fetch from external source)\n- The import is a one-time or simple operation\n- You want to quickly import without creating a full script\n\nUse a script when:\n- Data comes from external sources (APIs, databases, files)\n- Complex data transformation is needed\n- The import runs on a schedule as an App`,\n },\n },\n ],\n };\n },\n );\n\n // Copy existing app\n anyServer.prompt(\n 'copy_app',\n 'Guide for copying an existing app to create a new one.',\n copyAppSchema,\n async (params: { tenant: string; sourceApp: string; newAppName: string }) => {\n const { tenant, sourceApp, newAppName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Copying app \"${sourceApp}\" to create \"${newAppName}\" for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Pull latest with farseer_pull to get current app JSON\n\n2. Use farseer_get_app to see the source app configuration\n\n3. The app JSON files are in apps/${tenant}/apps/\n\n Copy the source JSON file and modify:\n - Change \"name\" to \"${newAppName}\"\n - **IMPORTANT: Remove \"_remote\" field** (this makes it a new app)\n - Modify arguments, description as needed\n\n4. JSON format for new app:\n\\`\\`\\`json\n{\n \"name\": \"${newAppName}\",\n \"description\": \"Copied from ${sourceApp}\",\n \"entrypoint\": \"script.ts\",\n \"scripts\": [\"script.ts\"],\n \"arguments\": [\n { \"name\": \"Year\", \"defaultValue\": \"2025\" }\n ]\n}\n\\`\\`\\`\n\nNote: Do NOT include \"_remote\" for new apps - CLI adds it after first push.\n\n5. Push with farseer_push to create the new app\n\n6. Test with farseer_run_app`,\n },\n },\n ],\n };\n },\n );\n\n // Export data\n anyServer.prompt(\n 'export_data',\n 'Guide for exporting variable data from Farseer.',\n exportDataSchema,\n async (params: { tenant: string; variableName: string }) => {\n const { tenant, variableName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Exporting data for variable \"${variableName}\" from tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_get_variable to understand the variable:\n - What dimensions does it span?\n - What is its data type?\n\n2. Choose export method:\n\n **Option A: Quick export (farseer_export_variable_data)**\n - Uses ExportApi.exportFormula() internally\n - Returns CSV/JSON data inline\n - Good for quick inspection or small datasets\n - Use 'limit' parameter for large datasets\n\n **Option B: Structured export (farseer_load_variable_data)**\n - Uses data.loadFarseerVariable() internally\n - Can specify which dimensions to include as columns\n - Returns structured CSV data\n - Good when you need specific dimension breakdowns\n\n **Option C: CLI export (farseer variable export)**\n - Saves CSV/JSON/XLSX to a local file\n - Best for saving data locally for analysis\n\n3. For analysis:\n - Parse the CSV data returned by the tools\n - Summarize, filter, or transform as needed`,\n },\n },\n ],\n };\n },\n );\n\n // Debug sync issues\n anyServer.prompt(\n 'debug_sync_issues',\n 'Troubleshoot synchronization problems between local and remote.',\n debugSyncSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Debugging sync issues for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Check authentication: farseer_whoami\n - Is JWT valid?\n - Which tenant is this server bound to (via --tenant)?\n\n2. Check sync status: farseer_status\n - Are there modified files?\n - Are there only-local or only-remote files?\n\n3. If files show as modified:\n - Use farseer_diff to see differences\n - Decide: pull (accept remote) or push (upload local)\n\n4. Common issues and solutions:\n\n **\"No credentials found\"**\n \u2192 User needs to run \"farseer login\" in terminal\n \u2192 Or configure API key: \"farseer config set ${tenant} --api-key KEY\"\n\n **\"Remote has changes\"**\n \u2192 Pull first with farseer_pull\n \u2192 Then push with farseer_push\n\n **\"Token expired\"**\n \u2192 User needs to run \"farseer login\" again\n\n **Apps not syncing**\n \u2192 Need JWT login (browser), not API key\n \u2192 API key only syncs files, not apps\n\n5. Force resolution:\n - To accept all remote changes: farseer_pull with force=true (overwrites local)\n - To accept all local changes: farseer_push with force=true (overwrites remote)\n - For selective resolution: farseer_pull without force will skip conflicts (resolve via CLI)\n\n6. Check specific file diff:\n - Use farseer_diff with file parameter to see exact changes`,\n },\n },\n ],\n };\n },\n );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAkB;AAGlB,MAAM,oBAAoB;AAAA,EACtB,QAAQ,aAAE,OAAO,EAAE,SAAS,sBAAsB;AACtD;AAEA,MAAM,kBAAkB;AAAA,EACpB,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAAA,EACzC,SAAS,aAAE,OAAO,EAAE,SAAS,sBAAsB;AAAA,EACnD,YAAY,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,0CAA0C;AACzF;AAEA,MAAM,wBAAwB;AAAA,EAC1B,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAC7C;AAEA,MAAM,0BAA0B;AAAA,EAC5B,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAAA,EACzC,cAAc,aAAE,OAAO,EAAE,SAAS,gCAAgC;AACtE;AAEA,MAAM,gBAAgB;AAAA,EAClB,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAAA,EACzC,WAAW,aAAE,OAAO,EAAE,SAAS,qBAAqB;AAAA,EACpD,YAAY,aAAE,OAAO,EAAE,SAAS,sBAAsB;AAC1D;AAEA,MAAM,mBAAmB;AAAA,EACrB,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAAA,EACzC,cAAc,aAAE,OAAO,EAAE,SAAS,oBAAoB;AAC1D;AAEA,MAAM,kBAAkB;AAAA,EACpB,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAC7C;AAEO,SAAS,wBAAwB,QAAyB;AAE7D,QAAM,YAAY;AAElB,YAAU;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,WAA+B;AAClC,YAAM,EAAE,OAAO,IAAI;AACnB,aAAO;AAAA,QACH,UAAU;AAAA,UACN;AAAA,YACI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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAoB/B;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;",
4
+ "sourcesContent": ["/**\n * Workflow Prompts\n *\n * Reusable prompt templates for common Farseer workflows.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\n\n// Define schemas outside of prompt registration to avoid deep type instantiation\nconst setupTenantSchema = {\n tenant: z.string().describe('Tenant name to setup'),\n};\n\nconst createAppSchema = {\n tenant: z.string().describe('Tenant name'),\n appName: z.string().describe('Name for the new app'),\n scriptName: z.string().optional().describe('Main script filename (default: index.ts)'),\n};\n\nconst understandModelSchema = {\n tenant: z.string().describe('Tenant name'),\n};\n\nconst writeImportScriptSchema = {\n tenant: z.string().describe('Tenant name'),\n variableName: z.string().describe('Target variable to import into'),\n};\n\nconst copyAppSchema = {\n tenant: z.string().describe('Tenant name'),\n sourceApp: z.string().describe('Name of app to copy'),\n newAppName: z.string().describe('Name for the new app'),\n};\n\nconst exportDataSchema = {\n tenant: z.string().describe('Tenant name'),\n variableName: z.string().describe('Variable to export'),\n};\n\nconst debugSyncSchema = {\n tenant: z.string().describe('Tenant name'),\n};\n\nexport function registerWorkflowPrompts(server: McpServer): void {\n // Cast to any to avoid very deep generic type instantiation from the MCP SDK\n const anyServer = server as any;\n // Setup new tenant\n anyServer.prompt(\n 'setup_new_tenant',\n 'Guide for getting started on the tenant this server is bound to: verify login, pull, install dependencies.',\n setupTenantSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `You are setting up a new Farseer tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Check authentication and the bound tenant with farseer_whoami\n2. If not logged in, inform the user to run \"farseer login\" in terminal (MCP cannot do browser login)\n3. If farseer_whoami does not show \"${tenant}\", tell the user to set --tenant ${tenant} in this MCP server's config and reconnect \u2014 MCP tools cannot change the tenant\n4. Pull files and apps with farseer_pull\n5. Tell user to run \"farseer install ${tenant}\" in terminal to install npm dependencies\n6. Use farseer_list_apps to show available apps\n7. Use farseer_export_model to understand the data structure\n\nAfter setup, the user can:\n- Run apps with farseer_run_app\n- Edit scripts in apps/${tenant}/files/Scripts/\n- Push changes with farseer_push\n- Check model with farseer_get_variable or farseer_get_table`,\n },\n },\n ],\n };\n },\n );\n\n // Create new app\n anyServer.prompt(\n 'create_new_app',\n 'Guide for creating a new Farseer app from scratch.',\n createAppSchema,\n async (params: { tenant: string; appName: string; scriptName?: string }) => {\n const { tenant, appName, scriptName } = params;\n const script = scriptName || 'index.ts';\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Creating a new Farseer app \"${appName}\" for tenant \"${tenant}\".\n\nIMPORTANT: A Farseer App = a TypeScript script + an app config that tells Farseer which script to run and with what arguments.\nThe script uses \\`farseer-client\\` to interact with the Farseer API.\nAuthentication is automatic - \\`new FarseerClient()\\` reads credentials from environment variables injected by the CLI.\nYou NEVER hardcode credentials in scripts.\n\nSteps to follow:\n\n1. Write the script file at farseer-apps/${tenant}/files/Scripts/${script}\n Use the template below as a starting point.\n\n2. Push the script to remote with farseer_push\n (Scripts must exist on remote before they can be assigned to an app)\n\n3. Create the app with farseer_create_app (name: \"${appName}\")\n\n4. Configure the app with farseer_configure_app:\n - sourceFolder: \"Scripts\"\n - entrypoint: \"${script}\"\n - arguments: Add any arguments the script expects (they arrive via process.argv)\n\n5. Test with farseer_run_app\n The CLI injects auth credentials as env vars and runs the script with npx tsx.\n\nScript template:\n\\`\\`\\`typescript\nimport * as farseer from 'farseer-client';\n\n// FarseerClient auto-configures from env vars injected by \"farseer run\"\n// NEVER hardcode credentials - just use the empty constructor\nconst client = new farseer.FarseerClient();\n\n// Arguments come via process.argv in the order defined by app config\nconst args = process.argv.slice(2);\n\nasync function main() {\n // Load dimension/variable metadata\n await client.initTagMap();\n\n // Your code here\n console.log('App running successfully');\n}\n\nmain().catch(farseer.handleUnknownError);\n\\`\\`\\``,\n },\n },\n ],\n };\n },\n );\n\n // Understand model\n anyServer.prompt(\n 'understand_model',\n 'Explore and understand the data model of a Farseer tenant.',\n understandModelSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Analyzing the data model for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_export_model to get the full model structure\n\n2. Review dimension tables:\n - Use farseer_list_tables for overview\n - Key dimensions usually include: Products, Regions, Time (Months, Years), Versions\n - Check foreign key relationships between tables\n\n3. Review variables:\n - Use farseer_list_variables for overview\n - Use farseer_get_variable for specific variable details\n - Note which dimensions each variable has\n\n4. For import scripts, you need to know:\n - Target variable name\n - All dimensions the variable has\n - Valid members for each dimension\n\nKey concepts:\n- Dimensions structure the data (Product, Region, Month, Year, Version)\n- Variables store values at dimension intersections\n- Formulas calculate values automatically\n- Roll-up types determine aggregation (SUM, AVERAGE, etc.)\n\nCommon dimension tables:\n- Months, Years (time)\n- Versions (Plan, Actual, Forecast)\n- Products, Categories, Brands\n- Regions, Entities, Cost Centers`,\n },\n },\n ],\n };\n },\n );\n\n // Write import script\n anyServer.prompt(\n 'write_import_script',\n 'Guide for writing a data import script.',\n writeImportScriptSchema,\n async (params: { tenant: string; variableName: string }) => {\n const { tenant, variableName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Writing an import script for variable \"${variableName}\" in tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_get_variable to understand the target variable:\n - What dimensions does it have?\n - What is the roll-up type?\n\n2. Use farseer_get_table for each dimension to see valid members\n\n3. Create the import script with this pattern:\n\n\\`\\`\\`typescript\nimport * as farseer from 'farseer-client';\n\nconst client = new farseer.FarseerClient();\n\nasync function main() {\n await client.initTagMap();\n\n // Create import job with column definitions\n const importJob = await client.createImportJob({\n title: 'Import ${variableName}',\n columns: [\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Product' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Years' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Months' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Versions' },\n { type: 'VARIABLE', variableName: '${variableName}' },\n ],\n labels: ['auto', 'import-${variableName.toLowerCase().replace(/\\s+/g, '-')}']\n });\n\n // Add rows - each row matches column order\n const rows = [\n ['ProductA', 'Y2025', 'M1', 'Plan', 1000],\n ['ProductB', 'Y2025', 'M1', 'Plan', 2000],\n ];\n\n await importJob.addRows(rows);\n await importJob.flushRows();\n await importJob.undoPrevious(); // Remove previous import\n await importJob.commit();\n\n console.log('Import completed!');\n}\n\nmain().catch(farseer.handleUnknownError);\n\\`\\`\\`\n\n4. Save script to apps/${tenant}/files/Scripts/\n5. Push with farseer_push\n6. Create app with farseer_create_app\n7. Configure with farseer_configure_app\n8. Test with farseer_run_app\n\nALTERNATIVE: For simple imports without a script, use the farseer_create_import_job tool directly.\nIt handles the full workflow (create metadata, add rows, undo previous, commit) in a single call.\nUse farseer_create_import_job when:\n- Data is already available (no need to fetch from external source)\n- The import is a one-time or simple operation\n- You want to quickly import without creating a full script\n\nUse a script when:\n- Data comes from external sources (APIs, databases, files)\n- Complex data transformation is needed\n- The import runs on a schedule as an App`,\n },\n },\n ],\n };\n },\n );\n\n // Copy existing app\n anyServer.prompt(\n 'copy_app',\n 'Guide for copying an existing app to create a new one.',\n copyAppSchema,\n async (params: { tenant: string; sourceApp: string; newAppName: string }) => {\n const { tenant, sourceApp, newAppName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Copying app \"${sourceApp}\" to create \"${newAppName}\" for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Pull latest with farseer_pull to get current app JSON\n\n2. Use farseer_get_app to see the source app configuration\n\n3. The app JSON files are in apps/${tenant}/apps/\n\n Copy the source JSON file and modify:\n - Change \"name\" to \"${newAppName}\"\n - **IMPORTANT: Remove \"_remote\" field** (this makes it a new app)\n - Set \"schedule\" to null, unless the user asked for the copy to run on the\n same schedule \u2014 otherwise both apps run at the same moment\n - Modify arguments, description as needed\n\n4. JSON format for new app:\n\\`\\`\\`json\n{\n \"name\": \"${newAppName}\",\n \"description\": \"Copied from ${sourceApp}\",\n \"entrypoint\": \"script.ts\",\n \"scripts\": [\"script.ts\"],\n \"arguments\": [\n { \"name\": \"Year\", \"defaultValue\": \"2025\" }\n ]\n}\n\\`\\`\\`\n\nNote: Do NOT include \"_remote\" for new apps - CLI adds it after first push.\n\n5. Push with farseer_push to create the new app\n\n6. Test with farseer_run_app`,\n },\n },\n ],\n };\n },\n );\n\n // Export data\n anyServer.prompt(\n 'export_data',\n 'Guide for exporting variable data from Farseer.',\n exportDataSchema,\n async (params: { tenant: string; variableName: string }) => {\n const { tenant, variableName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Exporting data for variable \"${variableName}\" from tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_get_variable to understand the variable:\n - What dimensions does it span?\n - What is its data type?\n\n2. Choose export method:\n\n **Option A: Quick export (farseer_export_variable_data)**\n - Uses ExportApi.exportFormula() internally\n - Returns CSV/JSON data inline\n - Good for quick inspection or small datasets\n - Use 'limit' parameter for large datasets\n\n **Option B: Structured export (farseer_load_variable_data)**\n - Uses data.loadFarseerVariable() internally\n - Can specify which dimensions to include as columns\n - Returns structured CSV data\n - Good when you need specific dimension breakdowns\n\n **Option C: CLI export (farseer variable export)**\n - Saves CSV/JSON/XLSX to a local file\n - Best for saving data locally for analysis\n\n3. For analysis:\n - Parse the CSV data returned by the tools\n - Summarize, filter, or transform as needed`,\n },\n },\n ],\n };\n },\n );\n\n // Debug sync issues\n anyServer.prompt(\n 'debug_sync_issues',\n 'Troubleshoot synchronization problems between local and remote.',\n debugSyncSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Debugging sync issues for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Check authentication: farseer_whoami\n - Is JWT valid?\n - Which tenant is this server bound to (via --tenant)?\n\n2. Check sync status: farseer_status\n - Are there modified files?\n - Are there only-local or only-remote files?\n\n3. If files show as modified:\n - Use farseer_diff to see differences\n - Decide: pull (accept remote) or push (upload local)\n\n4. Common issues and solutions:\n\n **\"No credentials found\"**\n \u2192 User needs to run \"farseer login\" in terminal\n \u2192 Or configure API key: \"farseer config set ${tenant} --api-key KEY\"\n\n **\"Remote has changes\"**\n \u2192 Pull first with farseer_pull\n \u2192 Then push with farseer_push\n\n **\"Token expired\"**\n \u2192 User needs to run \"farseer login\" again\n\n **Apps not syncing**\n \u2192 Need JWT login (browser), not API key\n \u2192 API key only syncs files, not apps\n\n5. Force resolution:\n - To accept all remote changes: farseer_pull with force=true (overwrites local)\n - To accept all local changes: farseer_push with force=true (overwrites remote)\n - For selective resolution: farseer_pull without force will skip conflicts (resolve via CLI)\n\n6. Check specific file diff:\n - Use farseer_diff with file parameter to see exact changes`,\n },\n },\n ],\n };\n },\n );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAkB;AAGlB,MAAM,oBAAoB;AAAA,EACtB,QAAQ,aAAE,OAAO,EAAE,SAAS,sBAAsB;AACtD;AAEA,MAAM,kBAAkB;AAAA,EACpB,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAAA,EACzC,SAAS,aAAE,OAAO,EAAE,SAAS,sBAAsB;AAAA,EACnD,YAAY,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,0CAA0C;AACzF;AAEA,MAAM,wBAAwB;AAAA,EAC1B,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAC7C;AAEA,MAAM,0BAA0B;AAAA,EAC5B,QAAQ,aAAE,OAAO,EAA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MAAM;AAAA,cACN,MAAM,gCAAgC,YAAY,kBAAkB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YA6B9E;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AAGA,YAAU;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,WAA+B;AAClC,YAAM,EAAE,OAAO,IAAI;AACnB,aAAO;AAAA,QACH,UAAU;AAAA,UACN;AAAA,YACI,MAAM;AAAA,YACN,SAAS;AAAA,cACL,MAAM;AAAA,cACN,MAAM,qCAAqC,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sDAoB5B,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAoB/B;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;",
6
6
  "names": []
7
7
  }
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var appTools_exports = {};
20
20
  __export(appTools_exports, {
21
21
  argumentSchema: () => argumentSchema,
22
+ predefinedActionSchema: () => predefinedActionSchema,
22
23
  registerAppTools: () => registerAppTools
23
24
  });
24
25
  module.exports = __toCommonJS(appTools_exports);
@@ -55,6 +56,10 @@ const argumentSchema = import_zod.z.object({
55
56
  message: "defaultValue must be one of the options",
56
57
  path: ["defaultValue"]
57
58
  });
59
+ const predefinedActionSchema = import_zod.z.object({
60
+ name: import_zod.z.string(),
61
+ runArguments: import_zod.z.record(import_zod.z.string()).describe("Argument name to the value this action runs with.")
62
+ });
58
63
  const configureAppSchema = {
59
64
  appName: import_zod.z.string().optional().describe("Name of the app to configure. Omit if using appId."),
60
65
  appId: import_zod.z.string().optional().describe("Numeric app id \u2014 use instead of appName when names collide."),
@@ -62,7 +67,16 @@ const configureAppSchema = {
62
67
  sourceFolder: import_zod.z.string().optional().describe(`Source folder the app's scripts come from (path under Files/, e.g. "Scripts/MyApp")`),
63
68
  description: import_zod.z.string().optional().describe("App description"),
64
69
  arguments: import_zod.z.array(argumentSchema).optional().describe("App arguments with default values"),
65
- newName: import_zod.z.string().optional().describe("Rename the app")
70
+ newName: import_zod.z.string().optional().describe("Rename the app"),
71
+ schedule: import_zod.z.string().optional().describe(`Cron expression to run the app on, e.g. "0 6 * * *". Pass "${import_apps.CLEAR_SETTING}" to clear it.`),
72
+ runner: import_zod.z.string().optional().describe(`Name of the jobrunner that runs the app. Pass "${import_apps.CLEAR_SETTING}" to let any runner take it.`),
73
+ runnerImage: import_zod.z.string().optional().describe(
74
+ `Container image the app runs in, as "<repository>:<tag>" (e.g. "runner-typescript:latest") or a full registry reference. Pass "${import_apps.CLEAR_SETTING}" for the tenant default.`
75
+ ),
76
+ compute: import_zod.z.enum(import_apps.APP_COMPUTE_CHOICES).optional().describe(
77
+ `Where a run executes: "local" is a container on the jobrunner's own machine, "batch" a machine created for that run. The size suffix picks how much machine; bare "batch" takes the deployment's default size.`
78
+ ),
79
+ predefinedActions: import_zod.z.array(predefinedActionSchema).optional().describe("Named argument presets offered as buttons in the UI. Replaces the existing list wholesale.")
66
80
  };
67
81
  const deleteAppSchema = {
68
82
  appName: import_zod.z.string().optional().describe("Name of the app to delete. Omit if using appId."),
@@ -138,7 +152,9 @@ Returns:
138
152
  - App name and description
139
153
  - Entry point script (main script that runs)
140
154
  - List of all included scripts
141
- - Expected arguments with their default values`,
155
+ - Expected arguments with their default values
156
+ - Schedule, runner, runner image and compute selection
157
+ - Predefined actions (named argument presets)`,
142
158
  getAppSchema,
143
159
  async (params) => {
144
160
  const gate = await (0, import_session.requireSession)();
@@ -176,7 +192,12 @@ Returns:
176
192
  ...a.secret !== void 0 ? { secret: a.secret } : {}
177
193
  })),
178
194
  status: app.status,
179
- lastHeartbeat: app.lastHeartbeat
195
+ lastHeartbeat: app.lastHeartbeat,
196
+ schedule: app.schedule ?? null,
197
+ runner: app.runnerName ?? null,
198
+ runnerImage: app.runnerImage ?? null,
199
+ compute: (0, import_apps.formatCompute)(app.compute),
200
+ predefinedActions: (0, import_apps.redactActionValues)(app.predefinedActions ?? [], app.expectedArguments)
180
201
  }
181
202
  });
182
203
  } catch (error) {
@@ -236,6 +257,15 @@ You can set:
236
257
  value at run time), optional options (closed allowed-value set, string
237
258
  dataType only), optional defaultValue, and optional secret.
238
259
  - newName: Rename the app
260
+ - schedule: Cron expression the app runs on (e.g. "0 6 * * *")
261
+ - runner: Which jobrunner runs the app
262
+ - runnerImage: Container image, as "<repository>:<tag>" or a full registry reference
263
+ - compute: Where a run executes \u2014 'local', 'batch', or 'batch:<size>' with size s, m, l or xl
264
+ - predefinedActions: Named argument presets offered as buttons in the UI. The
265
+ list you pass replaces the app's whole list. farseer_get_app shows a secret
266
+ argument's value as "<secret>"; send "<secret>" back to keep the stored value
267
+ of the action with exactly that name. Where two actions share a name, give
268
+ the real value.
239
269
 
240
270
  Important:
241
271
  - The app's scripts are derived from its source folder; the entrypoint must be
@@ -243,6 +273,7 @@ Important:
243
273
  - Changing sourceFolder to a folder that doesn't contain the current entrypoint
244
274
  requires passing entrypoint in the same call.
245
275
  - Settings you don't pass are preserved (this only changes what you specify).
276
+ - Pass "${import_apps.CLEAR_SETTING}" to schedule, runner or runnerImage to clear it.
246
277
  - Arguments are passed to the script as a JSON-encoded FARSEER_ARGS env var
247
278
  - Boolean dataType requires defaultValue \u2208 { "true", "false" }; defaultValue
248
279
  must be one of options when options is set`,
@@ -296,12 +327,30 @@ Important:
296
327
  if (sourceFolderError) {
297
328
  return (0, import_helpers.errorResponse)(sourceFolderError, "VALIDATION_ERROR");
298
329
  }
330
+ if (params.predefinedActions) {
331
+ const restored = (0, import_apps.restoreRedactedValues)(params.predefinedActions, app.predefinedActions ?? []);
332
+ if ("error" in restored) {
333
+ return (0, import_helpers.errorResponse)(restored.error, "VALIDATION_ERROR");
334
+ }
335
+ changes.predefinedActions = restored.actions;
336
+ }
337
+ const runSettings = await (0, import_apps.applyRunSettings)(client, app, changes, {
338
+ schedule: params.schedule,
339
+ runner: params.runner,
340
+ runnerImage: params.runnerImage,
341
+ compute: params.compute
342
+ });
343
+ if ("error" in runSettings) {
344
+ return (0, import_helpers.errorResponse)(runSettings.error, "VALIDATION_ERROR");
345
+ }
299
346
  const reference = app.id.toString();
300
- await client.updateApp(reference, changes, app);
347
+ const updated = await client.updateApp(reference, changes, app);
301
348
  return (0, import_helpers.successResponse)({
302
349
  tenant,
303
350
  appName: params.newName || app.name,
304
351
  updated: Object.keys(changes),
352
+ compute: (0, import_apps.formatCompute)(updated.compute),
353
+ warnings: runSettings.warnings,
305
354
  message: `App "${app.name}" configured successfully`
306
355
  });
307
356
  } catch (error) {
@@ -355,6 +404,7 @@ This does NOT delete the script files, only the app configuration.`,
355
404
  // Annotate the CommonJS export names for ESM import in node:
356
405
  0 && (module.exports = {
357
406
  argumentSchema,
407
+ predefinedActionSchema,
358
408
  registerAppTools
359
409
  });
360
410
  //# sourceMappingURL=appTools.js.map