sentinelayer-cli 0.30.9 → 0.30.10

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": "sentinelayer-cli",
3
- "version": "0.30.9",
3
+ "version": "0.30.10",
4
4
  "description": "Scaffold Sentinelayer spec/prompt/guide artifacts with secure browser auth and token bootstrap.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -138,6 +138,49 @@ function normalizeString(value) {
138
138
  return String(value || "").trim();
139
139
  }
140
140
 
141
+ function messagePartsHaveContent(messageParts) {
142
+ const parts = Array.isArray(messageParts) ? messageParts : [messageParts];
143
+ return parts.some((part) => normalizeString(part));
144
+ }
145
+
146
+ function joinMessageParts(messageParts) {
147
+ if (Array.isArray(messageParts)) {
148
+ return messageParts.length === 1 ? String(messageParts[0] || "") : messageParts.join(" ");
149
+ }
150
+ return String(messageParts || "");
151
+ }
152
+
153
+ async function readUtf8FromStdin(stdin = process.stdin) {
154
+ if (stdin.isTTY) {
155
+ throw new Error("--stdin requires piped input.");
156
+ }
157
+ stdin.setEncoding("utf8");
158
+ let text = "";
159
+ for await (const chunk of stdin) {
160
+ text += String(chunk);
161
+ }
162
+ return text;
163
+ }
164
+
165
+ async function resolveSessionSayMessageInput(messageParts, options = {}) {
166
+ const hasPositionalMessage = messagePartsHaveContent(messageParts);
167
+ const hasMessageFile = Boolean(normalizeString(options.messageFile));
168
+ const hasStdin = Boolean(options.stdin);
169
+ const sources = [hasPositionalMessage, hasMessageFile, hasStdin].filter(Boolean).length;
170
+ if (sources > 1) {
171
+ throw new Error("Use only one message source: positional message, --message-file, or --stdin.");
172
+ }
173
+ if (hasMessageFile) {
174
+ return normalizeString(
175
+ await fsp.readFile(path.resolve(process.cwd(), String(options.messageFile)), "utf-8"),
176
+ );
177
+ }
178
+ if (hasStdin) {
179
+ return normalizeString(await readUtf8FromStdin());
180
+ }
181
+ return normalizeString(joinMessageParts(messageParts));
182
+ }
183
+
141
184
  function optionWasSetByCli(command, optionName) {
142
185
  if (!command || typeof command.getOptionValueSource !== "function") {
143
186
  return false;
@@ -3343,7 +3386,7 @@ export function registerSessionCommand(program) {
3343
3386
  });
3344
3387
 
3345
3388
  session
3346
- .command("say <sessionId> <message>")
3389
+ .command("say <sessionId> [message...]")
3347
3390
  .description("Send a message to the session")
3348
3391
  .option(
3349
3392
  "--agent <id>",
@@ -3367,16 +3410,18 @@ export function registerSessionCommand(program) {
3367
3410
  .option("--to <agent>", "Direct the message to a specific agent id")
3368
3411
  .option("--reply-to <sequence>", "Mark this message as a reply to a target sequence id")
3369
3412
  .option("--reply-cursor <cursor>", "Mark this message as a reply to a target event cursor")
3413
+ .option("--message-file <path>", "Read the message body from a UTF-8 file")
3414
+ .option("--stdin", "Read the message body from stdin")
3370
3415
  .option("--force-cli-user", "Allow fallback sends as cli-user when no agent identity can be resolved")
3371
3416
  .option("--local-only", "Append only to the local session cache without remote send confirmation")
3372
3417
  .option("--path <path>", "Workspace path for the session", ".")
3373
3418
  .option("--json", "Emit machine-readable output")
3374
- .action(async (sessionId, message, options, command) => {
3419
+ .action(async (sessionId, messageParts, options, command) => {
3375
3420
  const normalizedSessionId = normalizeString(sessionId);
3376
3421
  if (!normalizedSessionId) {
3377
3422
  throw new Error("session id is required.");
3378
3423
  }
3379
- const normalizedMessage = normalizeString(message);
3424
+ const normalizedMessage = await resolveSessionSayMessageInput(messageParts, options);
3380
3425
  if (!normalizedMessage) {
3381
3426
  throw new Error("message is required.");
3382
3427
  }