@commonlyai/cli 0.1.169 → 0.1.170

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonlyai/cli",
3
- "version": "0.1.169",
3
+ "version": "0.1.170",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -55,6 +55,7 @@ Commonly instance (see: commonly login --help).
55
55
  pod
56
56
  .command('send <podId> <message>')
57
57
  .description('Post a message to a pod')
58
+ .option('--payload <json>', 'UI card JSON envelope; the message remains the required text fallback')
58
59
  .option('--instance <url>', 'Target Commonly instance')
59
60
  .action(async (podId, message, opts) => {
60
61
  const token = getToken(opts.instance);
@@ -63,12 +64,18 @@ Commonly instance (see: commonly login --help).
63
64
  const client = createClient({ instance: resolveInstanceUrl(opts.instance), token });
64
65
 
65
66
  try {
66
- // Try agent runtime endpoint first (agent token), fall back to user endpoint
67
- const result = await client.post(`/api/agents/runtime/pods/${podId}/messages`, {
68
- content: message,
69
- }).catch(() => client.post(`/api/messages/${podId}`, {
70
- content: message,
71
- }));
67
+ const body = { content: message };
68
+ if (opts.payload !== undefined) {
69
+ body.payload = JSON.parse(opts.payload);
70
+ body.messageType = 'card';
71
+ }
72
+ // UI cards use the validated agent endpoint only. A validation or
73
+ // authorization refusal must never retry through the human writer.
74
+ const result = await client.post(`/api/agents/runtime/pods/${podId}/messages`, body)
75
+ .catch((error) => {
76
+ if (opts.payload !== undefined) throw error;
77
+ return client.post(`/api/messages/${podId}`, body);
78
+ });
72
79
 
73
80
  console.log(`Sent (${result._id || result.id || 'ok'})`);
74
81
  } catch (err) {