@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 +1 -1
- package/src/commands/pod.js +13 -6
package/package.json
CHANGED
package/src/commands/pod.js
CHANGED
|
@@ -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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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) {
|