@agents-at-scale/ark 0.1.64 → 0.1.67

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.
@@ -1,7 +1,9 @@
1
1
  import { Command } from 'commander';
2
2
  import { execa } from 'execa';
3
+ import chalk from 'chalk';
3
4
  import output from '../../lib/output.js';
4
- import { executeQuery } from '../../lib/executeQuery.js';
5
+ import { executeQuery, parseParameters } from '../../lib/executeQuery.js';
6
+ import { ExitCodes } from '../../lib/errors.js';
5
7
  async function listAgents(options) {
6
8
  try {
7
9
  // Use kubectl to get agents
@@ -55,12 +57,22 @@ export function createAgentsCommand(config) {
55
57
  .argument('<name>', 'Agent name')
56
58
  .argument('<message>', 'Message to send')
57
59
  .option('--timeout <timeout>', 'Query timeout (e.g., 30s, 5m, 1h)')
60
+ .option('-p, --parameter <name=value>', 'Template parameter in name=value format (can be used multiple times)', (val, acc) => [...acc, val], [])
58
61
  .action(async (name, message, options) => {
62
+ let parameters;
63
+ try {
64
+ parameters = parseParameters(options.parameter || []);
65
+ }
66
+ catch (error) {
67
+ console.error(chalk.red(error instanceof Error ? error.message : 'Unknown error'));
68
+ process.exit(ExitCodes.CliError);
69
+ }
59
70
  await executeQuery({
60
71
  targetType: 'agent',
61
72
  targetName: name,
62
73
  message,
63
74
  timeout: options.timeout || config.queryTimeout,
75
+ parameters,
64
76
  });
65
77
  });
66
78
  return agentsCommand;
@@ -1,27 +1,62 @@
1
1
  import { Command } from 'commander';
2
2
  import { execa } from 'execa';
3
3
  import output from '../../lib/output.js';
4
- async function importResources(filepath) {
5
- try {
6
- output.info(`importing ark resources from ${filepath}...`);
7
- const args = ['create', '-f', filepath];
8
- await execa('kubectl', args, {
9
- stdio: 'pipe',
10
- });
11
- output.success(`imported resources from ${filepath}`);
4
+ function countApplied(stdout) {
5
+ const counts = { created: 0, configured: 0, unchanged: 0 };
6
+ for (const line of stdout.split('\n')) {
7
+ const trimmed = line.trim();
8
+ if (trimmed.endsWith(' created')) {
9
+ counts.created++;
10
+ }
11
+ else if (trimmed.endsWith(' configured')) {
12
+ counts.configured++;
13
+ }
14
+ else if (trimmed.endsWith(' unchanged')) {
15
+ counts.unchanged++;
16
+ }
12
17
  }
13
- catch (error) {
14
- output.error('import failed:', error instanceof Error ? error.message : error);
18
+ return counts;
19
+ }
20
+ async function importResources(filepath, options) {
21
+ if (!options.upsert) {
22
+ try {
23
+ output.info(`importing ark resources from ${filepath}...`);
24
+ const args = ['create', '-f', filepath];
25
+ await execa('kubectl', args, {
26
+ stdio: 'pipe',
27
+ });
28
+ output.success(`imported resources from ${filepath}`);
29
+ }
30
+ catch (error) {
31
+ output.error('import failed:', error instanceof Error ? error.message : error);
32
+ process.exit(1);
33
+ }
34
+ return;
35
+ }
36
+ output.info(`importing ark resources from ${filepath} (upsert)...`);
37
+ const result = await execa('kubectl', ['apply', '-f', filepath], {
38
+ stdio: 'pipe',
39
+ reject: false,
40
+ });
41
+ const counts = countApplied(result.stdout ?? '');
42
+ if (result.exitCode !== 0) {
43
+ output.error(`import failed (${counts.created} created, ${counts.configured} configured, ${counts.unchanged} unchanged before errors):`);
44
+ const details = (result.stderr || result.stdout || '').trim();
45
+ if (details) {
46
+ output.error(details);
47
+ }
15
48
  process.exit(1);
16
49
  }
50
+ output.success(`import complete: ${counts.created} created, ${counts.configured} configured, ${counts.unchanged} unchanged`);
17
51
  }
18
52
  export function createImportCommand(_) {
19
53
  const importCommand = new Command('import');
20
54
  importCommand
21
55
  .description('import ARK resources from a file')
22
56
  .argument('<filepath>', 'input file path')
23
- .action(async (filepath) => {
24
- await importResources(filepath);
57
+ .option('--upsert', 'create or update resources (kubectl apply); allows re-import onto a cluster that already has some of these resources')
58
+ .action(async (filepath, options) => {
59
+ await importResources(filepath, options);
25
60
  });
26
61
  return importCommand;
27
62
  }
@@ -50,7 +50,7 @@ function backendInstallArgs(service, backend, values) {
50
50
  function isValidVersion(version) {
51
51
  return /^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$/.test(version);
52
52
  }
53
- function isVersionNotFoundError(error, options) {
53
+ function notFoundVersion(error, options) {
54
54
  let errorMsg = '';
55
55
  if (error && typeof error === 'object') {
56
56
  const err = error;
@@ -61,24 +61,30 @@ function isVersionNotFoundError(error, options) {
61
61
  errorMsg = String(error);
62
62
  }
63
63
  if (options.arkVersion && errorMsg.includes(`:${options.arkVersion}: not found`)) {
64
- return true;
64
+ return options.arkVersion;
65
65
  }
66
66
  if (options.marketplaceVersion && errorMsg.includes(`:${options.marketplaceVersion}: not found`)) {
67
- return true;
67
+ return options.marketplaceVersion;
68
68
  }
69
- return false;
69
+ return null;
70
70
  }
71
71
  function handleInstallError(error, service, options) {
72
- if (isVersionNotFoundError(error, options)) {
73
- const version = options.arkVersion || options.marketplaceVersion;
74
- output.warning(`${service.name} version ${version} not found, skipping...`);
75
- return true; // should continue to next service
72
+ const version = notFoundVersion(error, options);
73
+ if (version !== null) {
74
+ return version; // should continue to next service
76
75
  }
77
76
  // Other errors still fail
78
77
  output.error(`failed to install ${service.name}`);
79
78
  console.error(error);
80
79
  process.exit(1);
81
80
  }
81
+ function exitIfServicesSkipped(skipped) {
82
+ if (skipped.length === 0)
83
+ return;
84
+ const detail = skipped.map((s) => `${s.name}@${s.version}`).join(', ');
85
+ output.error(`installation incomplete: ${skipped.length} service(s) skipped because the requested version was not found: ${detail}`);
86
+ process.exit(1);
87
+ }
82
88
  async function uninstallPrerequisites(service, verbose = false) {
83
89
  if (!service.prerequisiteUninstalls?.length)
84
90
  return;
@@ -185,6 +191,7 @@ export async function installArk(config, serviceNames = [], options = {}) {
185
191
  process.exit(1);
186
192
  }
187
193
  const backend = requestedBackend;
194
+ const skippedServices = [];
188
195
  let postgresValues;
189
196
  if (backend === 'postgresql') {
190
197
  try {
@@ -233,7 +240,9 @@ export async function installArk(config, serviceNames = [], options = {}) {
233
240
  output.success(`${service.name} installed successfully`);
234
241
  }
235
242
  catch (error) {
236
- if (handleInstallError(error, service, options)) {
243
+ const skippedVersion = handleInstallError(error, service, options);
244
+ if (skippedVersion) {
245
+ skippedServices.push({ name: service.name, version: skippedVersion });
237
246
  continue;
238
247
  }
239
248
  }
@@ -258,7 +267,7 @@ export async function installArk(config, serviceNames = [], options = {}) {
258
267
  if (service.helmReleaseName === 'ark-apiserver' && backend === 'postgresql') {
259
268
  const spinner = ora('Waiting for ark-apiserver to be ready...').start();
260
269
  try {
261
- const results = await runReadinessChecks(120); // 2 minute timeout
270
+ const results = await runReadinessChecks(120, backend); // 2 minute timeout
262
271
  const failed = results.find((r) => !r.passed);
263
272
  if (failed) {
264
273
  spinner.fail(`ark-apiserver readiness check failed: ${failed.message || 'unknown error'}`);
@@ -274,11 +283,14 @@ export async function installArk(config, serviceNames = [], options = {}) {
274
283
  }
275
284
  }
276
285
  catch (error) {
277
- if (handleInstallError(error, service, options)) {
286
+ const skippedVersion = handleInstallError(error, service, options);
287
+ if (skippedVersion) {
288
+ skippedServices.push({ name: service.name, version: skippedVersion });
278
289
  continue;
279
290
  }
280
291
  }
281
292
  }
293
+ exitIfServicesSkipped(skippedServices);
282
294
  return;
283
295
  }
284
296
  // If not using -y flag, show checklist interface
@@ -417,7 +429,7 @@ export async function installArk(config, serviceNames = [], options = {}) {
417
429
  if (service.helmReleaseName === 'ark-apiserver' && backend === 'postgresql') {
418
430
  const spinner = ora('Waiting for ark-apiserver to be ready...').start();
419
431
  try {
420
- const results = await runReadinessChecks(120); // 2 minute timeout
432
+ const results = await runReadinessChecks(120, backend); // 2 minute timeout
421
433
  const failed = results.find((r) => !r.passed);
422
434
  if (failed) {
423
435
  spinner.fail(`ark-apiserver readiness check failed: ${failed.message || 'unknown error'}`);
@@ -434,7 +446,9 @@ export async function installArk(config, serviceNames = [], options = {}) {
434
446
  console.log(); // Add blank line after command output
435
447
  }
436
448
  catch (error) {
437
- if (handleInstallError(error, service, options)) {
449
+ const skippedVersion = handleInstallError(error, service, options);
450
+ if (skippedVersion) {
451
+ skippedServices.push({ name: service.name, version: skippedVersion });
438
452
  console.log(); // Add blank line after warning
439
453
  continue;
440
454
  }
@@ -476,7 +490,9 @@ export async function installArk(config, serviceNames = [], options = {}) {
476
490
  console.log(); // Add blank line after command output
477
491
  }
478
492
  catch (error) {
479
- if (handleInstallError(error, service, options)) {
493
+ const skippedVersion = handleInstallError(error, service, options);
494
+ if (skippedVersion) {
495
+ skippedServices.push({ name: service.name, version: skippedVersion });
480
496
  console.log(); // Add blank line after warning
481
497
  continue;
482
498
  }
@@ -496,7 +512,8 @@ export async function installArk(config, serviceNames = [], options = {}) {
496
512
  s.category === 'core' &&
497
513
  s.k8sDeploymentName &&
498
514
  s.namespace &&
499
- (!s.requiresBackend || s.requiresBackend === backend));
515
+ (!s.requiresBackend || s.requiresBackend === backend) &&
516
+ !skippedServices.some((sk) => sk.name === s.name));
500
517
  const spinner = ora(`Waiting for Ark to be ready (timeout: ${timeoutSeconds}s)...`).start();
501
518
  const statusMap = new Map();
502
519
  servicesToWait.forEach((s) => statusMap.set(s.name, false));
@@ -526,6 +543,7 @@ export async function installArk(config, serviceNames = [], options = {}) {
526
543
  process.exit(1);
527
544
  }
528
545
  }
546
+ exitIfServicesSkipped(skippedServices);
529
547
  }
530
548
  export function createInstallCommand(config) {
531
549
  const command = new Command('install');
@@ -23,6 +23,29 @@ export const defaultDeps = {
23
23
  };
24
24
  const POLL_INTERVAL_MS = 2000;
25
25
  const DEFAULT_TIMEOUT_MS = 5 * 60 * 1000;
26
+ const LOOPBACK_LITERALS = new Set(['127.0.0.1', '::1', 'localhost']);
27
+ function warnIfCallbackUnreachable(authorizationUrl, proxyBaseUrl) {
28
+ let redirect;
29
+ try {
30
+ const raw = new URL(authorizationUrl).searchParams.get('redirect_uri');
31
+ if (!raw)
32
+ return;
33
+ redirect = new URL(raw);
34
+ }
35
+ catch {
36
+ return;
37
+ }
38
+ const host = redirect.hostname.replace(/^\[|\]$/g, '');
39
+ if (!LOOPBACK_LITERALS.has(host))
40
+ return;
41
+ const proxyPort = new URL(proxyBaseUrl).port;
42
+ if (redirect.port && proxyPort && redirect.port !== proxyPort) {
43
+ output.warning(`callback is configured for ${redirect.host} but the CLI port-forward is on ` +
44
+ `port ${proxyPort}; the browser redirect will not reach ark-api. Set ` +
45
+ `ARK_API_PUBLIC_CALLBACK_URL to use port ${proxyPort}, or port-forward ` +
46
+ `ark-api on port ${redirect.port}.`);
47
+ }
48
+ }
26
49
  export async function runLogin(serverName, options, deps = defaultDeps) {
27
50
  let timeoutMs = DEFAULT_TIMEOUT_MS;
28
51
  if (options.timeout !== undefined) {
@@ -57,6 +80,7 @@ export async function runLogin(serverName, options, deps = defaultDeps) {
57
80
  }
58
81
  return 1;
59
82
  }
83
+ warnIfCallbackUnreachable(startResponse.authorization_url, proxy.baseUrl);
60
84
  console.log(`Authorization URL: ${startResponse.authorization_url}`);
61
85
  if (options.open !== false) {
62
86
  try {
@@ -109,34 +109,46 @@ export class KubernetesModelManifestBuilder {
109
109
  region: {
110
110
  value: config.region,
111
111
  },
112
- accessKeyId: {
113
- valueFrom: {
114
- secretKeyRef: {
115
- name: config.secretName,
116
- key: 'access-key-id',
117
- },
112
+ },
113
+ };
114
+ const bedrock = bedrockConfig.bedrock;
115
+ if (config.authMethod === 'api-key') {
116
+ bedrock.apiKey = {
117
+ valueFrom: {
118
+ secretKeyRef: {
119
+ name: config.secretName,
120
+ key: 'bedrock-api-key',
118
121
  },
119
122
  },
120
- secretAccessKey: {
121
- valueFrom: {
122
- secretKeyRef: {
123
- name: config.secretName,
124
- key: 'secret-access-key',
125
- },
123
+ };
124
+ }
125
+ else {
126
+ bedrock.accessKeyId = {
127
+ valueFrom: {
128
+ secretKeyRef: {
129
+ name: config.secretName,
130
+ key: 'access-key-id',
126
131
  },
127
132
  },
128
- },
129
- };
130
- const bedrock = bedrockConfig.bedrock;
131
- if (config.sessionToken) {
132
- bedrock.sessionToken = {
133
+ };
134
+ bedrock.secretAccessKey = {
133
135
  valueFrom: {
134
136
  secretKeyRef: {
135
137
  name: config.secretName,
136
- key: 'session-token',
138
+ key: 'secret-access-key',
137
139
  },
138
140
  },
139
141
  };
142
+ if (config.sessionToken) {
143
+ bedrock.sessionToken = {
144
+ valueFrom: {
145
+ secretKeyRef: {
146
+ name: config.secretName,
147
+ key: 'session-token',
148
+ },
149
+ },
150
+ };
151
+ }
140
152
  }
141
153
  if (config.modelArn) {
142
154
  bedrock.modelArn = {
@@ -23,10 +23,15 @@ export class KubernetesSecretManager {
23
23
  async createNewSecret(config) {
24
24
  const secretArgs = ['create', 'secret', 'generic', config.secretName];
25
25
  if (config.type === 'bedrock') {
26
- secretArgs.push(`--from-literal=access-key-id=${config.accessKeyId}`);
27
- secretArgs.push(`--from-literal=secret-access-key=${config.secretAccessKey}`);
28
- if (config.sessionToken) {
29
- secretArgs.push(`--from-literal=session-token=${config.sessionToken}`);
26
+ if (config.authMethod === 'api-key') {
27
+ secretArgs.push(`--from-literal=bedrock-api-key=${config.apiKey}`);
28
+ }
29
+ else {
30
+ secretArgs.push(`--from-literal=access-key-id=${config.accessKeyId}`);
31
+ secretArgs.push(`--from-literal=secret-access-key=${config.secretAccessKey}`);
32
+ if (config.sessionToken) {
33
+ secretArgs.push(`--from-literal=session-token=${config.sessionToken}`);
34
+ }
30
35
  }
31
36
  }
32
37
  else {
@@ -39,10 +44,15 @@ export class KubernetesSecretManager {
39
44
  async updateSecret(config) {
40
45
  const secretArgs = ['create', 'secret', 'generic', config.secretName];
41
46
  if (config.type === 'bedrock') {
42
- secretArgs.push(`--from-literal=access-key-id=${config.accessKeyId}`);
43
- secretArgs.push(`--from-literal=secret-access-key=${config.secretAccessKey}`);
44
- if (config.sessionToken) {
45
- secretArgs.push(`--from-literal=session-token=${config.sessionToken}`);
47
+ if (config.authMethod === 'api-key') {
48
+ secretArgs.push(`--from-literal=bedrock-api-key=${config.apiKey}`);
49
+ }
50
+ else {
51
+ secretArgs.push(`--from-literal=access-key-id=${config.accessKeyId}`);
52
+ secretArgs.push(`--from-literal=secret-access-key=${config.secretAccessKey}`);
53
+ if (config.sessionToken) {
54
+ secretArgs.push(`--from-literal=session-token=${config.sessionToken}`);
55
+ }
46
56
  }
47
57
  }
48
58
  else {
@@ -2,11 +2,14 @@ import { BaseProviderConfig, BaseCollectorOptions, ProviderConfigCollector } fro
2
2
  /**
3
3
  * Configuration for AWS Bedrock models.
4
4
  */
5
+ export type BedrockAuthMethod = 'api-key' | 'iam';
5
6
  export interface BedrockConfig extends BaseProviderConfig {
6
7
  type: 'bedrock';
7
8
  region: string;
8
- accessKeyId: string;
9
- secretAccessKey: string;
9
+ authMethod: BedrockAuthMethod;
10
+ apiKey?: string;
11
+ accessKeyId?: string;
12
+ secretAccessKey?: string;
10
13
  sessionToken?: string;
11
14
  modelArn?: string;
12
15
  }
@@ -15,6 +18,8 @@ export interface BedrockConfig extends BaseProviderConfig {
15
18
  */
16
19
  export interface BedrockCollectorOptions extends BaseCollectorOptions {
17
20
  region?: string;
21
+ authMethod?: BedrockAuthMethod;
22
+ apiKey?: string;
18
23
  accessKeyId?: string;
19
24
  secretAccessKey?: string;
20
25
  sessionToken?: string;
@@ -29,56 +29,103 @@ export class BedrockConfigCollector {
29
29
  if (!region) {
30
30
  throw new Error('region is required');
31
31
  }
32
- let accessKeyId = bedrockOptions.accessKeyId;
33
- if (!accessKeyId) {
32
+ let authMethod = bedrockOptions.authMethod;
33
+ if (!authMethod) {
34
34
  const answer = await inquirer.prompt([
35
35
  {
36
- type: 'input',
37
- name: 'accessKeyId',
38
- message: 'AWS access key ID:',
39
- validate: (input) => {
40
- if (!input)
41
- return 'access key ID is required';
42
- return true;
43
- },
36
+ type: 'list',
37
+ name: 'authMethod',
38
+ message: 'Authentication method:',
39
+ choices: [
40
+ { name: 'API key (bearer token)', value: 'api-key' },
41
+ { name: 'IAM credentials', value: 'iam' },
42
+ ],
43
+ default: 'iam',
44
44
  },
45
45
  ]);
46
- accessKeyId = answer.accessKeyId;
46
+ authMethod = answer.authMethod;
47
47
  }
48
- if (!accessKeyId) {
49
- throw new Error('access key ID is required');
48
+ if (!authMethod) {
49
+ throw new Error('authentication method is required');
50
50
  }
51
- let secretAccessKey = bedrockOptions.secretAccessKey;
52
- if (!secretAccessKey) {
53
- const answer = await inquirer.prompt([
54
- {
55
- type: 'password',
56
- name: 'secretAccessKey',
57
- message: 'AWS secret access key:',
58
- mask: '*',
59
- validate: (input) => {
60
- if (!input)
61
- return 'secret access key is required';
62
- return true;
51
+ let apiKey;
52
+ let accessKeyId;
53
+ let secretAccessKey;
54
+ let sessionToken;
55
+ if (authMethod === 'api-key') {
56
+ apiKey = bedrockOptions.apiKey;
57
+ if (!apiKey) {
58
+ const answer = await inquirer.prompt([
59
+ {
60
+ type: 'password',
61
+ name: 'apiKey',
62
+ message: 'Bedrock API key:',
63
+ mask: '*',
64
+ validate: (input) => {
65
+ if (!input)
66
+ return 'API key is required';
67
+ return true;
68
+ },
63
69
  },
64
- },
65
- ]);
66
- secretAccessKey = answer.secretAccessKey;
67
- }
68
- if (!secretAccessKey) {
69
- throw new Error('secret access key is required');
70
+ ]);
71
+ apiKey = answer.apiKey;
72
+ }
73
+ if (!apiKey) {
74
+ throw new Error('API key is required');
75
+ }
70
76
  }
71
- let sessionToken = bedrockOptions.sessionToken;
72
- if (!sessionToken) {
73
- const answer = await inquirer.prompt([
74
- {
75
- type: 'password',
76
- name: 'sessionToken',
77
- message: 'AWS session token (optional, press enter to skip):',
78
- mask: '*',
79
- },
80
- ]);
81
- sessionToken = answer.sessionToken;
77
+ else {
78
+ accessKeyId = bedrockOptions.accessKeyId;
79
+ if (!accessKeyId) {
80
+ const answer = await inquirer.prompt([
81
+ {
82
+ type: 'input',
83
+ name: 'accessKeyId',
84
+ message: 'AWS access key ID:',
85
+ validate: (input) => {
86
+ if (!input)
87
+ return 'access key ID is required';
88
+ return true;
89
+ },
90
+ },
91
+ ]);
92
+ accessKeyId = answer.accessKeyId;
93
+ }
94
+ if (!accessKeyId) {
95
+ throw new Error('access key ID is required');
96
+ }
97
+ secretAccessKey = bedrockOptions.secretAccessKey;
98
+ if (!secretAccessKey) {
99
+ const answer = await inquirer.prompt([
100
+ {
101
+ type: 'password',
102
+ name: 'secretAccessKey',
103
+ message: 'AWS secret access key:',
104
+ mask: '*',
105
+ validate: (input) => {
106
+ if (!input)
107
+ return 'secret access key is required';
108
+ return true;
109
+ },
110
+ },
111
+ ]);
112
+ secretAccessKey = answer.secretAccessKey;
113
+ }
114
+ if (!secretAccessKey) {
115
+ throw new Error('secret access key is required');
116
+ }
117
+ sessionToken = bedrockOptions.sessionToken;
118
+ if (!sessionToken) {
119
+ const answer = await inquirer.prompt([
120
+ {
121
+ type: 'password',
122
+ name: 'sessionToken',
123
+ message: 'AWS session token (optional, press enter to skip):',
124
+ mask: '*',
125
+ },
126
+ ]);
127
+ sessionToken = answer.sessionToken;
128
+ }
82
129
  }
83
130
  let modelArn = bedrockOptions.modelArn;
84
131
  if (!modelArn) {
@@ -96,6 +143,8 @@ export class BedrockConfigCollector {
96
143
  modelValue: options.model,
97
144
  secretName: '',
98
145
  region,
146
+ authMethod,
147
+ apiKey,
99
148
  accessKeyId,
100
149
  secretAccessKey,
101
150
  sessionToken: sessionToken || undefined,
@@ -1,6 +1,6 @@
1
1
  import { Command } from 'commander';
2
2
  import chalk from 'chalk';
3
- import { executeQuery, parseTarget } from '../../lib/executeQuery.js';
3
+ import { executeQuery, parseTarget, parseParameters, } from '../../lib/executeQuery.js';
4
4
  import { ExitCodes } from '../../lib/errors.js';
5
5
  export function createQueryCommand(config) {
6
6
  const queryCommand = new Command('query');
@@ -8,8 +8,9 @@ export function createQueryCommand(config) {
8
8
  .description('Execute a single query against a model or agent')
9
9
  .argument('<target>', 'Query target (e.g., model/default, agent/my-agent)')
10
10
  .argument('<message>', 'Message to send')
11
- .option('-o, --output <format>', 'Output format: yaml, json, name or events (shows structured event data)')
11
+ .option('-o, --output <format>', 'Output format: yaml, json, name, events (structured event data), or events-pretty (events with color-coded reasons and expanded key/value detail)')
12
12
  .option('--timeout <timeout>', 'Query timeout (e.g., 30s, 5m, 1h)')
13
+ .option('-p, --parameter <name=value>', 'Template parameter in name=value format (can be used multiple times)', (val, acc) => [...acc, val], [])
13
14
  .option('--session-id <sessionId>', 'Session ID to associate with the query for conversation continuity')
14
15
  .option('--conversation-id <conversationId>', 'Conversation ID to associate with the query for memory continuity')
15
16
  .action(async (target, message, options) => {
@@ -18,12 +19,21 @@ export function createQueryCommand(config) {
18
19
  console.error(chalk.red('Invalid target format. Use: model/name or agent/name etc'));
19
20
  process.exit(ExitCodes.CliError);
20
21
  }
22
+ let parameters;
23
+ try {
24
+ parameters = parseParameters(options.parameter || []);
25
+ }
26
+ catch (error) {
27
+ console.error(chalk.red(error instanceof Error ? error.message : 'Unknown error'));
28
+ process.exit(ExitCodes.CliError);
29
+ }
21
30
  await executeQuery({
22
31
  targetType: parsed.type,
23
32
  targetName: parsed.name,
24
33
  message,
25
34
  outputFormat: options.output,
26
35
  timeout: options.timeout || config.queryTimeout,
36
+ parameters,
27
37
  sessionId: options.sessionId,
28
38
  conversationId: options.conversationId,
29
39
  });