@skrr-ai/cli 0.1.208 → 0.1.210

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.
Files changed (105) hide show
  1. package/dist/base-command.js +2 -1
  2. package/dist/commands/agent/message/no-reply.js +1 -1
  3. package/dist/commands/agent/message/react.d.ts +23 -0
  4. package/dist/commands/agent/message/react.js +128 -0
  5. package/dist/commands/agent/message/resolve.js +1 -1
  6. package/dist/commands/agent/message/retract.js +1 -1
  7. package/dist/commands/agent/message/send.d.ts +8 -13
  8. package/dist/commands/agent/message/send.js +60 -28
  9. package/dist/commands/agents/access/approve.js +1 -1
  10. package/dist/commands/agents/access/deny.js +1 -1
  11. package/dist/commands/agents/access/list.js +3 -1
  12. package/dist/commands/agents/access/reach.js +1 -1
  13. package/dist/commands/agents/access/revoke.js +1 -1
  14. package/dist/commands/agents/always-on/recovery-review.d.ts +10 -0
  15. package/dist/commands/agents/always-on/recovery-review.js +45 -0
  16. package/dist/commands/agents/chat.d.ts +22 -0
  17. package/dist/commands/agents/chat.js +400 -90
  18. package/dist/commands/agents/import.js +3 -3
  19. package/dist/commands/agents/manager/status.js +7 -6
  20. package/dist/commands/agents/not-for-task.d.ts +24 -0
  21. package/dist/commands/agents/not-for-task.js +64 -0
  22. package/dist/commands/agents/schedule-overview.d.ts +20 -0
  23. package/dist/commands/agents/schedule-overview.js +35 -2
  24. package/dist/commands/agents/shared-memory.js +1 -1
  25. package/dist/commands/agents/stop.d.ts +23 -0
  26. package/dist/commands/agents/stop.js +61 -0
  27. package/dist/commands/agents/update.d.ts +7 -0
  28. package/dist/commands/agents/update.js +45 -2
  29. package/dist/commands/convos/messages.js +5 -0
  30. package/dist/commands/convos/transcript.js +2 -2
  31. package/dist/commands/daemon/logs.d.ts +3 -1
  32. package/dist/commands/daemon/logs.js +6 -2
  33. package/dist/commands/dm/work.js +38 -9
  34. package/dist/commands/duties/advance-next.js +1 -1
  35. package/dist/commands/duties/preflight.js +17 -13
  36. package/dist/commands/duties/show.js +5 -0
  37. package/dist/commands/followups/watch-pr.js +2 -1
  38. package/dist/commands/harnesses/evaluations/evidence.js +2 -2
  39. package/dist/commands/harnesses/evaluations/grant.js +1 -1
  40. package/dist/commands/harnesses/evaluations/revoke.js +1 -1
  41. package/dist/commands/harnesses/evaluations/show.js +1 -1
  42. package/dist/commands/harnesses/rollouts/grant.js +1 -1
  43. package/dist/commands/harnesses/rollouts/revoke.js +1 -1
  44. package/dist/commands/machines/hosted/identity-evaluations/revoke.js +1 -1
  45. package/dist/commands/machines/hosted/identity-evaluations/show.js +1 -1
  46. package/dist/commands/memory/consolidation/undo.js +1 -0
  47. package/dist/commands/messages/list.js +9 -1
  48. package/dist/commands/slack/mutes.js +1 -1
  49. package/dist/commands/slack/unmute.js +1 -1
  50. package/dist/commands/tasks/actionability.js +1 -0
  51. package/dist/commands/tasks/ask.d.ts +2 -0
  52. package/dist/commands/tasks/ask.js +7 -1
  53. package/dist/commands/tasks/bulk-update.js +12 -0
  54. package/dist/commands/tasks/deliverable/add.d.ts +2 -0
  55. package/dist/commands/tasks/deliverable/add.js +25 -6
  56. package/dist/commands/tasks/input/show.d.ts +2 -0
  57. package/dist/commands/tasks/input/show.js +18 -3
  58. package/dist/commands/tasks/list.d.ts +8 -0
  59. package/dist/commands/tasks/list.js +50 -9
  60. package/dist/commands/tasks/move.d.ts +2 -10
  61. package/dist/commands/tasks/move.js +7 -18
  62. package/dist/commands/tasks/resource/add.d.ts +2 -0
  63. package/dist/commands/tasks/resource/add.js +11 -1
  64. package/dist/commands/tasks/result/show.js +19 -7
  65. package/dist/commands/tasks/show.d.ts +4 -3
  66. package/dist/commands/tasks/show.js +20 -8
  67. package/dist/commands/tasks/start.js +35 -16
  68. package/dist/commands/tasks/update.js +3 -0
  69. package/dist/commands/tasks/wait.js +2 -2
  70. package/dist/generated/agent-guides.json +483 -183
  71. package/dist/lib/agent-proactive-baseline.js +4 -1
  72. package/dist/lib/chat-stop.d.ts +17 -0
  73. package/dist/lib/chat-stop.js +70 -0
  74. package/dist/lib/cloud-reply.d.ts +21 -0
  75. package/dist/lib/cloud-reply.js +52 -0
  76. package/dist/lib/duties.d.ts +10 -0
  77. package/dist/lib/duties.js +111 -7
  78. package/dist/lib/duty-ledgers.js +19 -2
  79. package/dist/lib/file-mime.js +8 -0
  80. package/dist/lib/inbound-messages.d.ts +156 -0
  81. package/dist/lib/inbound-messages.js +375 -0
  82. package/dist/lib/message-intent.d.ts +18 -2
  83. package/dist/lib/message-intent.js +23 -1
  84. package/dist/lib/preflight-copy.d.ts +16 -1
  85. package/dist/lib/preflight-copy.js +33 -1
  86. package/dist/lib/space-resolver.d.ts +9 -0
  87. package/dist/lib/space-resolver.js +13 -0
  88. package/dist/lib/task-operations.d.ts +2 -0
  89. package/dist/lib/task-operations.js +28 -4
  90. package/dist/lib/task-preflight.js +1 -0
  91. package/dist/lib/task-review-notice.d.ts +21 -0
  92. package/dist/lib/task-review-notice.js +46 -0
  93. package/dist/lib/task-version.d.ts +9 -0
  94. package/dist/lib/task-version.js +16 -0
  95. package/dist/lib/task-work.js +5 -0
  96. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelopeBridge.js +6 -1
  97. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/managedWorkRuntime.d.ts +5 -0
  98. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/managedWorkRuntime.js +21 -4
  99. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelopeBridge.js +45 -15
  100. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/managedWorkRuntime.d.ts +5 -0
  101. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/managedWorkRuntime.js +31 -5
  102. package/dist/node_modules/@skrr-ai/auth-core/package.json +1 -1
  103. package/dist/node_modules/@skrr-ai/data-provider/index.js +12307 -11838
  104. package/oclif.manifest.json +307 -23
  105. package/package.json +6 -2
@@ -836,8 +836,9 @@ class BaseCommand extends core_1.Command {
836
836
  // UUID, so refs go through the same exact-match resolution as titles.
837
837
  if ((0, internal_id_1.looksLikeInternalObjectId)(query))
838
838
  return this.resolveObjectIdShapedSpace(query);
839
+ // A UUID is sent in lowercase, the only spelling a Space id has (OSK-33347).
839
840
  if (!query || (0, space_resolver_1.looksLikeCanonicalSpaceId)(query))
840
- return query;
841
+ return (0, space_resolver_1.canonicalSpaceIdSpelling)(query);
841
842
  if ((0, failed_lookup_1.isFailedLookupValue)(query)) {
842
843
  this.failWithCliError({
843
844
  message: (0, failed_lookup_1.describeFailedLookupValue)(query, 'Space'),
@@ -44,7 +44,7 @@ class AgentMessageNoReply extends base_command_1.BaseCommand {
44
44
  credential: (0, message_intent_1.sessionCredential)(sessionContext.token),
45
45
  body: { disposition: data_provider_1.TURN_REPLY_DISPOSITIONS[0] },
46
46
  });
47
- this.log(JSON.stringify(result, null, 2));
47
+ this.printJsonResult(result);
48
48
  }
49
49
  catch (error) {
50
50
  this.handleApiError(error);
@@ -0,0 +1,23 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ /**
3
+ * React to one of the owner's messages with an emoji, as the Agent (design §4.7, D5). A reaction
4
+ * is the lightest acknowledgement: "seen", "on it", "done", with no message to read. It replaces
5
+ * the Agent's earlier reaction to that message.
6
+ *
7
+ * Inside an interactive Agent session it reacts as that session's Agent. An unattended run is
8
+ * refused: nobody is there to acknowledge, so it sends a message instead. Outside a session the
9
+ * owner reacts as one of their Agents, named with `--agent`.
10
+ */
11
+ export default class AgentMessageReact extends BaseCommand {
12
+ static description: string;
13
+ static examples: string[];
14
+ static args: {
15
+ messageId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
16
+ emoji: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
17
+ };
18
+ static flags: {
19
+ agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
21
+ };
22
+ run(): Promise<void>;
23
+ }
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const data_provider_1 = require("@skrr-ai/data-provider");
5
+ const base_command_1 = require("../../../base-command");
6
+ const agent_resolver_1 = require("../../../lib/agent-resolver");
7
+ const http_error_1 = require("../../../lib/http-error");
8
+ const inbound_messages_1 = require("../../../lib/inbound-messages");
9
+ const message_intent_1 = require("../../../lib/message-intent");
10
+ // Outside the args: the command hygiene audit reads an `Args.string` block up to its first
11
+ // closing brace and paren, which a template in the description would end early.
12
+ const EMOJI_DESCRIPTION = `The reaction: ${Object.entries(inbound_messages_1.REACTION_NAMES)
13
+ .map(([emoji, name]) => `${emoji} (${name})`)
14
+ .join(', ')}`;
15
+ /**
16
+ * React to one of the owner's messages with an emoji, as the Agent (design §4.7, D5). A reaction
17
+ * is the lightest acknowledgement: "seen", "on it", "done", with no message to read. It replaces
18
+ * the Agent's earlier reaction to that message.
19
+ *
20
+ * Inside an interactive Agent session it reacts as that session's Agent. An unattended run is
21
+ * refused: nobody is there to acknowledge, so it sends a message instead. Outside a session the
22
+ * owner reacts as one of their Agents, named with `--agent`.
23
+ */
24
+ class AgentMessageReact extends base_command_1.BaseCommand {
25
+ static description = "React to one of the owner's messages with an emoji, as the Agent: the lightest acknowledgement. Replaces the Agent's earlier reaction to that message";
26
+ static examples = [
27
+ '<%= config.bin %> agent message react <message-id> 👀',
28
+ '<%= config.bin %> agent message react <message-id> done',
29
+ '<%= config.bin %> agent message react <message-id> thumbs-up --agent <agent-id> --json',
30
+ ];
31
+ static args = {
32
+ messageId: core_1.Args.string({
33
+ description: "The messageId of the owner's message (in `agent message context`, or from the chat)",
34
+ required: true,
35
+ ignoreStdin: true,
36
+ }),
37
+ emoji: core_1.Args.string({
38
+ description: EMOJI_DESCRIPTION,
39
+ required: true,
40
+ ignoreStdin: true,
41
+ }),
42
+ };
43
+ static flags = {
44
+ agent: core_1.Flags.string({
45
+ description: 'The Agent that reacts (outside an Agent session; inside one it is the session’s)',
46
+ }),
47
+ json: core_1.Flags.boolean({ description: 'Print the server’s answer as JSON' }),
48
+ };
49
+ async run() {
50
+ const { args, flags } = await this.parse(AgentMessageReact);
51
+ const emoji = (0, inbound_messages_1.reactionFromInput)(args.emoji);
52
+ if (!emoji) {
53
+ this.failWithCliError({
54
+ message: inbound_messages_1.AGENT_REPLY_REFUSAL_COPY.reaction_invalid,
55
+ code: 'reaction_invalid',
56
+ exit: 2,
57
+ retryable: false,
58
+ });
59
+ }
60
+ let sessionContext;
61
+ try {
62
+ sessionContext = (0, message_intent_1.resolveMessageCommandSessionContext)({
63
+ requireHumanAuth: () => this.requireAuth(),
64
+ });
65
+ }
66
+ catch (error) {
67
+ this.failWithCliError({
68
+ message: error.message,
69
+ code: error.code || 'MESSAGE_INTENT_ERROR',
70
+ exit: 2,
71
+ retryable: false,
72
+ });
73
+ }
74
+ let agentId;
75
+ try {
76
+ agentId = sessionContext
77
+ ? (0, agent_resolver_1.resolveSessionAgentIdentity)(flags.agent).id
78
+ : (await (0, agent_resolver_1.resolveAgentIdentity)(flags.agent)).id;
79
+ }
80
+ catch (error) {
81
+ const failure = (0, agent_resolver_1.agentResolutionFailure)(error);
82
+ this.failWithCliError({
83
+ message: failure.message,
84
+ code: failure.code,
85
+ exit: 2,
86
+ retryable: false,
87
+ details: { suggestion: failure.suggestion },
88
+ });
89
+ }
90
+ let answer;
91
+ try {
92
+ answer = sessionContext
93
+ ? await (0, message_intent_1.reactAsSession)({
94
+ context: sessionContext,
95
+ messageId: args.messageId,
96
+ emoji: emoji,
97
+ })
98
+ : await data_provider_1.dataService.reactToAgentDmMessage(agentId, args.messageId, { emoji: emoji });
99
+ }
100
+ catch (error) {
101
+ if (error instanceof Error && error.name === 'MessageIntentCliError') {
102
+ this.failWithCliError({
103
+ message: error.message,
104
+ code: error.code || 'MESSAGE_INTENT_ERROR',
105
+ exit: 2,
106
+ retryable: false,
107
+ });
108
+ }
109
+ const refusal = (0, inbound_messages_1.agentReplyRefusalOf)(error);
110
+ if (refusal) {
111
+ this.failWithCliError({
112
+ message: inbound_messages_1.AGENT_REPLY_REFUSAL_COPY[refusal.code],
113
+ code: refusal.code,
114
+ status: (0, http_error_1.httpStatusOf)(error),
115
+ exit: 1,
116
+ retryable: false,
117
+ });
118
+ }
119
+ this.handleApiError(error);
120
+ }
121
+ if (flags.json) {
122
+ this.printJsonResult(answer);
123
+ return;
124
+ }
125
+ this.log(`Reacted ${emoji} to message ${answer.messageId}. The owner sees it on the message.`);
126
+ }
127
+ }
128
+ exports.default = AgentMessageReact;
@@ -90,7 +90,7 @@ class AgentMessageResolve extends base_command_1.BaseCommand {
90
90
  this.handleApiError(error);
91
91
  }
92
92
  if (flags.json) {
93
- this.log(JSON.stringify(result, null, 2));
93
+ this.printJsonResult(result);
94
94
  return;
95
95
  }
96
96
  this.log(describeAskResolution(messageId, result));
@@ -140,7 +140,7 @@ class AgentMessageRetract extends base_command_1.BaseCommand {
140
140
  this.handleApiError(error);
141
141
  }
142
142
  if (flags.json) {
143
- this.log(JSON.stringify(result, null, 2));
143
+ this.printJsonResult(result);
144
144
  return;
145
145
  }
146
146
  this.log(describeRetraction(targetMessageId, result));
@@ -3,12 +3,6 @@ import { BaseCommand } from '../../../base-command';
3
3
  import { type ResolvedAgentIdentity } from '../../../lib/agent-resolver';
4
4
  import { type CanonicalDestinationKind, type CanonicalMessageDestination, type CanonicalMessageIntentRequest, type CanonicalMessageIntentResponse, type CommunicationPresentation, type MessageOperationOutcome, type OneVoiceOutcome } from '../../../lib/message-intent';
5
5
  import { type WireEmbedRejection } from '../../../lib/entity-embeds';
6
- /**
7
- * A reading-comfort prompt, not a protocol limit. The Gateway deliberately
8
- * permits much larger payloads; the sender remains responsible for choosing
9
- * meaningful conversational boundaries.
10
- */
11
- export declare const OWNER_DM_SEGMENTATION_SOFT_LIMIT = 320;
12
6
  declare const PROTOCOL_VERSION = 1;
13
7
  export type PrincipalKind = 'session' | 'human';
14
8
  export type AgentMessageSendPayload = {
@@ -38,6 +32,8 @@ export type CanonicalIntentEnvelope = {
38
32
  idempotencyKey: string;
39
33
  /** Requested Agent Chat Thread root (the server remains authoritative). */
40
34
  threadRootMessageId?: string;
35
+ /** The owner's messages this one answers, as requested (the server proved each one). */
36
+ replyTo?: string[];
41
37
  /** Sender-declared semantics echoed for auditability; not a delivery promise. */
42
38
  presentation?: CommunicationPresentation;
43
39
  /** Legacy app-DM reach ceiling echoed when explicitly supplied. */
@@ -110,6 +106,7 @@ export default class AgentMessageSend extends BaseCommand {
110
106
  channel: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
111
107
  'thread-ts': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
112
108
  'thread-root': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
109
+ 'reply-to': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
113
110
  'from-json': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
114
111
  supersedes: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
115
112
  'status-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -137,6 +134,8 @@ export default class AgentMessageSend extends BaseCommand {
137
134
  */
138
135
  private exitForDelivery;
139
136
  private readPayload;
137
+ /** A reply the server refused, in the CLI's words, with the ids it could not prove. */
138
+ private failOnReplyRefusal;
140
139
  private submitAsSession;
141
140
  private submitAsHuman;
142
141
  }
@@ -152,18 +151,13 @@ export type NormalizedIntentPayload = {
152
151
  presentation?: CommunicationPresentation;
153
152
  notificationPolicy?: 'normal' | 'silent';
154
153
  threadRootMessageId?: string;
154
+ replyTo?: string[];
155
155
  context?: {
156
156
  taskId?: string;
157
157
  spaceId?: string;
158
158
  goalId?: string;
159
159
  };
160
160
  };
161
- /** A long owner DM sent as one message. Silent once the sender split it with `--part`. */
162
- export declare function messageSegmentationAdvisory({ destination, text, followingParts, }: {
163
- destination: CanonicalMessageDestination;
164
- text: string;
165
- followingParts: string[];
166
- }): string | undefined;
167
161
  /** The two voice habits the doctrine names and a check can see: a label opener, named filler. */
168
162
  export declare function messageVoiceAdvisory({ destination, text, }: {
169
163
  destination: CanonicalMessageDestination;
@@ -251,7 +245,7 @@ export declare function normalizeIntentPayload({ agentId, jsonBody, merged, }: {
251
245
  jsonBody: Record<string, unknown>;
252
246
  merged: Record<string, unknown>;
253
247
  }): NormalizedIntentPayload;
254
- export declare function generateIdempotencyKey(agentId: string, payload: Pick<NormalizedIntentPayload, 'destination' | 'content' | 'presentation' | 'context' | 'threadRootMessageId'>, operation?: MessageOperation): string;
248
+ export declare function generateIdempotencyKey(agentId: string, payload: Pick<NormalizedIntentPayload, 'destination' | 'content' | 'presentation' | 'context' | 'threadRootMessageId' | 'replyTo'>, operation?: MessageOperation): string;
255
249
  /**
256
250
  * The app message a person's owner-DM send became, as the session path names it (`messageId`),
257
251
  * so the text output says `Message id: …` on this path too. Only a send that reached the chat
@@ -271,6 +265,7 @@ export declare function buildEnvelope(input: {
271
265
  };
272
266
  idempotencyKey: string;
273
267
  threadRootMessageId?: string;
268
+ replyTo?: string[];
274
269
  embeds?: EntityEmbed[];
275
270
  embedRejections?: WireEmbedRejection[];
276
271
  presentation?: CommunicationPresentation;
@@ -33,9 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.EXIT_DELIVERY_FAILED = exports.EXIT_DELIVERY_RETRYABLE = exports.OWNER_DM_SEGMENTATION_SOFT_LIMIT = void 0;
36
+ exports.EXIT_DELIVERY_FAILED = exports.EXIT_DELIVERY_RETRYABLE = void 0;
37
37
  exports.withSendWaitNotice = withSendWaitNotice;
38
- exports.messageSegmentationAdvisory = messageSegmentationAdvisory;
39
38
  exports.messageVoiceAdvisory = messageVoiceAdvisory;
40
39
  exports.resultReplyAdvisory = resultReplyAdvisory;
41
40
  exports.buildSequencedRequests = buildSequencedRequests;
@@ -61,6 +60,8 @@ const cli_runtime_1 = require("../../../lib/cli-runtime");
61
60
  const message_intent_1 = require("../../../lib/message-intent");
62
61
  const entity_embeds_1 = require("../../../lib/entity-embeds");
63
62
  const prompt_1 = require("../../../lib/prompt");
63
+ const http_error_1 = require("../../../lib/http-error");
64
+ const inbound_messages_1 = require("../../../lib/inbound-messages");
64
65
  const runtime_context_1 = require("../../../lib/runtime-context");
65
66
  const BUILD_DESTINATION_RE = /^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;
66
67
  // eslint-disable-next-line no-control-regex -- Reject control characters in mail headers.
@@ -69,12 +70,6 @@ const COMPACT_KEY_PART_RE = /[^A-Za-z0-9_.:-]/g;
69
70
  const MAX_TEXT_CHARS = 20000;
70
71
  const MAX_IDEMPOTENCY_KEY_CHARS = 240;
71
72
  const MAX_SEQUENCE_PARTS = data_provider_1.MAX_AGENT_MESSAGE_SEQUENCE_PARTS;
72
- /**
73
- * A reading-comfort prompt, not a protocol limit. The Gateway deliberately
74
- * permits much larger payloads; the sender remains responsible for choosing
75
- * meaningful conversational boundaries.
76
- */
77
- exports.OWNER_DM_SEGMENTATION_SOFT_LIMIT = data_provider_1.AGENT_MESSAGE_SEGMENTATION_SOFT_LIMIT;
78
73
  const PROTOCOL_VERSION = 1;
79
74
  /**
80
75
  * Canonical CLI entry for agent-authored messages.
@@ -185,7 +180,7 @@ class AgentMessageSend extends base_command_1.BaseCommand {
185
180
  multiple: true,
186
181
  }),
187
182
  'message-lint': core_1.Flags.boolean({
188
- description: 'Show a stderr advisory when a long owner DM may read better as a short --part sequence',
183
+ description: 'Show stderr advice about how an owner DM reads',
189
184
  allowNo: true,
190
185
  default: true,
191
186
  }),
@@ -207,6 +202,12 @@ class AgentMessageSend extends base_command_1.BaseCommand {
207
202
  'thread-root': core_1.Flags.string({
208
203
  description: 'Agent Chat Thread root message ID for app_owner_dm. Do not use this for Slack; use --thread-ts.',
209
204
  }),
205
+ 'reply-to': core_1.Flags.string({
206
+ description: "The owner's message this one answers (app_owner_dm only). Repeat it for up to 10. The " +
207
+ 'owner sees a quote of it above this message. Each must be one of their messages in the ' +
208
+ 'chat this one lands in, or nothing is sent. With --part, only the first part names it.',
209
+ multiple: true,
210
+ }),
210
211
  'from-json': core_1.Flags.string({
211
212
  description: 'Path to a canonical intent JSON payload, or "-" for stdin',
212
213
  }),
@@ -273,6 +274,7 @@ class AgentMessageSend extends base_command_1.BaseCommand {
273
274
  channelId: flags.channel,
274
275
  threadTs: flags['thread-ts'],
275
276
  threadRootMessageId: flags['thread-root'],
277
+ replyTo: flags['reply-to'],
276
278
  idempotencyKey: flags['idempotency-key'],
277
279
  communicationKind: flags.kind,
278
280
  phase: flags.phase,
@@ -341,6 +343,14 @@ class AgentMessageSend extends base_command_1.BaseCommand {
341
343
  });
342
344
  if (unsupported)
343
345
  this.failWithCliError({ ...unsupported, retryable: false });
346
+ if (operation.kind === 'retract' && payload.replyTo) {
347
+ this.failWithCliError({
348
+ message: 'A withdrawal takes a message back; it answers nothing. Drop --reply-to.',
349
+ code: 'reply_to_invalid',
350
+ exit: 1,
351
+ retryable: false,
352
+ });
353
+ }
344
354
  }
345
355
  // Manual task context accepts the same titles and references as task
346
356
  // commands. Managed sessions must leave the claim-derived context alone.
@@ -349,13 +359,6 @@ class AgentMessageSend extends base_command_1.BaseCommand {
349
359
  payload.context?.taskId) {
350
360
  payload.context.taskId = await this.resolveTaskReference(payload.context.taskId);
351
361
  }
352
- const segmentationAdvisory = messageSegmentationAdvisory({
353
- destination: payload.destination,
354
- text: payload.content.text,
355
- followingParts: flags.part || [],
356
- });
357
- if (flags['message-lint'] && segmentationAdvisory)
358
- this.warn(segmentationAdvisory);
359
362
  const voiceAdvisory = messageVoiceAdvisory({
360
363
  destination: payload.destination,
361
364
  text: payload.content.text,
@@ -397,6 +400,7 @@ class AgentMessageSend extends base_command_1.BaseCommand {
397
400
  notificationPolicy: payload.notificationPolicy,
398
401
  context: payload.context,
399
402
  threadRootMessageId: payload.threadRootMessageId,
403
+ replyTo: payload.replyTo,
400
404
  embeds,
401
405
  operation,
402
406
  });
@@ -527,12 +531,29 @@ class AgentMessageSend extends base_command_1.BaseCommand {
527
531
  });
528
532
  }
529
533
  }
534
+ /** A reply the server refused, in the CLI's words, with the ids it could not prove. */
535
+ failOnReplyRefusal(err) {
536
+ if (err instanceof Error && err.name === 'MessageIntentCliError')
537
+ return;
538
+ const refusal = (0, inbound_messages_1.agentReplyRefusalOf)(err);
539
+ if (!refusal)
540
+ return;
541
+ this.failWithCliError({
542
+ message: inbound_messages_1.AGENT_REPLY_REFUSAL_COPY[refusal.code],
543
+ code: refusal.code,
544
+ status: (0, http_error_1.httpStatusOf)(err),
545
+ exit: 1,
546
+ retryable: false,
547
+ ...(refusal.missing ? { details: { missing: refusal.missing } } : {}),
548
+ });
549
+ }
530
550
  async submitAsSession({ sessionContext, request, agentIdentity, principalSource, }) {
531
551
  let result;
532
552
  try {
533
553
  result = await (0, message_intent_1.submitSessionMessageIntent)({ context: sessionContext, request });
534
554
  }
535
555
  catch (err) {
556
+ this.failOnReplyRefusal(err);
536
557
  if (err instanceof Error && err.name === 'MessageIntentCliError') {
537
558
  this.failWithCliError({
538
559
  message: err.message,
@@ -554,6 +575,7 @@ class AgentMessageSend extends base_command_1.BaseCommand {
554
575
  content: request.content,
555
576
  idempotencyKey: request.idempotencyKey,
556
577
  threadRootMessageId: request.threadRootMessageId,
578
+ replyTo: request.replyTo,
557
579
  presentation: request.presentation,
558
580
  appliedPresentation: result.presentation,
559
581
  notificationPolicy: request.notificationPolicy,
@@ -594,11 +616,13 @@ class AgentMessageSend extends base_command_1.BaseCommand {
594
616
  ...(request.threadRootMessageId
595
617
  ? { threadRootMessageId: request.threadRootMessageId }
596
618
  : {}),
619
+ ...(request.replyTo ? { replyTo: request.replyTo } : {}),
597
620
  ...(request.embeds && request.embeds.length > 0 ? { embeds: request.embeds } : {}),
598
621
  ...(request.context || {}),
599
622
  });
600
623
  }
601
624
  catch (err) {
625
+ this.failOnReplyRefusal(err);
602
626
  this.handleApiError(err);
603
627
  }
604
628
  return buildEnvelope({
@@ -612,6 +636,7 @@ class AgentMessageSend extends base_command_1.BaseCommand {
612
636
  content: request.content,
613
637
  idempotencyKey: request.idempotencyKey,
614
638
  threadRootMessageId: request.threadRootMessageId,
639
+ replyTo: request.replyTo,
615
640
  presentation: request.presentation,
616
641
  notificationPolicy: request.notificationPolicy,
617
642
  embeds: request.embeds,
@@ -705,14 +730,6 @@ function cliAdviceLine(advice, suffix = LINT_SUFFIX) {
705
730
  const sentences = advice.map((note) => (0, data_provider_1.renderAgentMessageAdvice)(note, 'cli'));
706
731
  return `[skrr] ${[...sentences, suffix].filter(Boolean).join(' ')}`;
707
732
  }
708
- /** A long owner DM sent as one message. Silent once the sender split it with `--part`. */
709
- function messageSegmentationAdvisory({ destination, text, followingParts, }) {
710
- return cliAdviceLine((0, data_provider_1.adviseAgentMessage)({
711
- destinationKind: destination.kind,
712
- text,
713
- followingParts: followingParts.length,
714
- }).filter((note) => note.code === 'long_message'));
715
- }
716
733
  /** The two voice habits the doctrine names and a check can see: a label opener, named filler. */
717
734
  function messageVoiceAdvisory({ destination, text, }) {
718
735
  return cliAdviceLine((0, data_provider_1.adviseAgentMessage)({ destinationKind: destination.kind, text }).filter((note) => note.code === 'label_opener' || note.code === 'named_filler'));
@@ -753,8 +770,11 @@ function buildSequencedRequests(request, followingParts, hasExplicitIdempotencyK
753
770
  if (!hasExplicitIdempotencyKey) {
754
771
  throw new Error('A multi-message update requires an explicit --idempotency-key for safe retries.');
755
772
  }
773
+ // A reply is named once, on the part that begins the answer; the rest continue it.
774
+ const { replyTo, ...rest } = request;
756
775
  return parts.map((text, index) => ({
757
- ...request,
776
+ ...rest,
777
+ ...(index === 0 && replyTo ? { replyTo } : {}),
758
778
  content: { text },
759
779
  idempotencyKey: sequencePartKey(request.idempotencyKey, index),
760
780
  sequence: sequenceMetadata(request.idempotencyKey, index, parts.length),
@@ -983,6 +1003,13 @@ function normalizeIntentPayload({ agentId, jsonBody, merged, }) {
983
1003
  if (threadRootMessageId && destination.kind !== 'app_owner_dm') {
984
1004
  throw invalidIntent('threadRootMessageId only applies to app_owner_dm; use --thread-ts for Slack.');
985
1005
  }
1006
+ const replyTo = (0, inbound_messages_1.normalizeReplyTo)(merged.replyTo ?? jsonBody.replyTo);
1007
+ if (replyTo === 'invalid') {
1008
+ throw invalidIntent(inbound_messages_1.AGENT_REPLY_REFUSAL_COPY.reply_to_invalid, 'reply_to_invalid');
1009
+ }
1010
+ if (replyTo && destination.kind !== 'app_owner_dm') {
1011
+ throw invalidIntent(inbound_messages_1.AGENT_REPLY_REFUSAL_COPY.reply_to_destination_unsupported, 'reply_to_destination_unsupported');
1012
+ }
986
1013
  const jsonContext = jsonBody.context && typeof jsonBody.context === 'object' && !Array.isArray(jsonBody.context)
987
1014
  ? jsonBody.context
988
1015
  : {};
@@ -1011,6 +1038,7 @@ function normalizeIntentPayload({ agentId, jsonBody, merged, }) {
1011
1038
  presentation,
1012
1039
  notificationPolicy,
1013
1040
  ...(threadRootMessageId ? { threadRootMessageId } : {}),
1041
+ ...(replyTo ? { replyTo } : {}),
1014
1042
  ...(Object.keys(context).length > 0 ? { context } : {}),
1015
1043
  };
1016
1044
  }
@@ -1172,7 +1200,7 @@ function booleanFlagInput(argv, name, parsedValue) {
1172
1200
  void parsedValue;
1173
1201
  return undefined;
1174
1202
  }
1175
- function canonicalIntentFromDestination({ agentId, idempotencyKey, destination, text, presentation, notificationPolicy, context, threadRootMessageId, embeds, operation, }) {
1203
+ function canonicalIntentFromDestination({ agentId, idempotencyKey, destination, text, presentation, notificationPolicy, context, threadRootMessageId, replyTo, embeds, operation, }) {
1176
1204
  switch (destination.kind) {
1177
1205
  case 'agent_email':
1178
1206
  return {
@@ -1192,6 +1220,7 @@ function canonicalIntentFromDestination({ agentId, idempotencyKey, destination,
1192
1220
  presentation,
1193
1221
  notificationPolicy,
1194
1222
  threadRootMessageId,
1223
+ replyTo,
1195
1224
  embeds,
1196
1225
  operation,
1197
1226
  ...context,
@@ -1264,6 +1293,8 @@ function generateIdempotencyKey(agentId, payload, operation) {
1264
1293
  presentation: payload.presentation,
1265
1294
  context: payload.context,
1266
1295
  threadRootMessageId: payload.threadRootMessageId,
1296
+ // The same words answering another message are another send; absent, the key is unchanged.
1297
+ ...(payload.replyTo ? { replyTo: payload.replyTo } : {}),
1267
1298
  // The same words correcting another message are another send. Absent for an ordinary
1268
1299
  // send, so its key is the one it had before C10.
1269
1300
  ...(operation ? { operation } : {}),
@@ -1319,6 +1350,7 @@ function buildEnvelope(input) {
1319
1350
  content: input.content,
1320
1351
  idempotencyKey: input.idempotencyKey,
1321
1352
  ...(input.threadRootMessageId ? { threadRootMessageId: input.threadRootMessageId } : {}),
1353
+ ...(input.replyTo && input.replyTo.length > 0 ? { replyTo: input.replyTo } : {}),
1322
1354
  ...(presentation ? { presentation } : {}),
1323
1355
  ...(input.notificationPolicy ? { notificationPolicy: input.notificationPolicy } : {}),
1324
1356
  ...(input.embeds && input.embeds.length > 0 ? { embeds: input.embeds } : {}),
@@ -1531,8 +1563,8 @@ function describeDestination(destination) {
1531
1563
  }
1532
1564
  return destination.kind;
1533
1565
  }
1534
- function invalidIntent(message) {
1566
+ function invalidIntent(message, code = 'INVALID_MESSAGE_INTENT') {
1535
1567
  const err = new Error(message);
1536
- err.code = 'INVALID_MESSAGE_INTENT';
1568
+ err.code = code;
1537
1569
  return err;
1538
1570
  }
@@ -85,7 +85,7 @@ class AgentsAccessApprove extends agent_access_command_1.AgentAccessCommand {
85
85
  this.handleApiError(err);
86
86
  }
87
87
  if (flags.json) {
88
- this.log(JSON.stringify(result, null, 2));
88
+ this.printJsonResult(result);
89
89
  return;
90
90
  }
91
91
  this.log(`Approved. ${personName} is trusted from their next message (${result.trustedAsker?.id ?? 'saved'}).`);
@@ -26,7 +26,7 @@ class AgentsAccessDeny extends agent_access_command_1.AgentAccessCommand {
26
26
  this.handleApiError(err);
27
27
  }
28
28
  if (flags.json) {
29
- this.log(JSON.stringify(result, null, 2));
29
+ this.printJsonResult(result);
30
30
  return;
31
31
  }
32
32
  const who = result.request?.requesterName || result.request?.platformUserId || 'They';
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const data_provider_1 = require("@skrr-ai/data-provider");
4
4
  const agent_access_command_1 = require("../../../lib/agent-access-command");
5
5
  const agent_access_1 = require("../../../lib/agent-access");
6
+ const list_output_1 = require("../../../lib/list-output");
6
7
  /**
7
8
  * Who may ask an agent for work in its channels: the people you trusted and
8
9
  * what each may reach, and the requests waiting for you.
@@ -19,7 +20,8 @@ class AgentsAccessList extends agent_access_command_1.AgentAccessCommand {
19
20
  const agentId = await this.accessAgentId(flags.agent);
20
21
  const access = await this.readAccess(agentId);
21
22
  if (flags.json) {
22
- this.log(JSON.stringify(access, null, 2));
23
+ // Rows are the trusted people; `requests` and `trustedAskers` stay beside them.
24
+ this.printJsonResult((0, list_output_1.listResult)(access, 'trustedAskers'));
23
25
  return;
24
26
  }
25
27
  const pending = access.requests.filter((request) => request.state === 'pending');
@@ -42,7 +42,7 @@ class AgentsAccessReach extends agent_access_command_1.AgentAccessCommand {
42
42
  this.handleApiError(err);
43
43
  }
44
44
  if (flags.json) {
45
- this.log(JSON.stringify(result, null, 2));
45
+ this.printJsonResult(result);
46
46
  return;
47
47
  }
48
48
  this.log(`Reach is now: ${(0, agent_access_1.reachSummary)(result.trustedAsker.reach)}`);
@@ -40,7 +40,7 @@ class AgentsAccessRevoke extends agent_access_command_1.AgentAccessCommand {
40
40
  this.handleApiError(err);
41
41
  }
42
42
  if (flags.json) {
43
- this.log(JSON.stringify(result, null, 2));
43
+ this.printJsonResult(result);
44
44
  return;
45
45
  }
46
46
  const who = result.trustedAsker?.displayName || result.trustedAsker?.platformUserId || 'They';
@@ -37,3 +37,13 @@ export default class AgentsAlwaysOnRecoveryReview extends BaseCommand {
37
37
  * server, or a hold this server cannot close: no command is offered that would be refused.
38
38
  */
39
39
  export declare function closeLines(agentId: string, review: DutyRunRecoveryReview): string[];
40
+ /**
41
+ * How the Duty's owner can stop later held results from blocking it (OSK-33137), with what that accepts. Nothing when
42
+ * it is already on, when the reader cannot turn it on, or when the server does not say.
43
+ */
44
+ export declare function autoRecoveryLines(review: DutyRunRecoveryReview): string[];
45
+ /**
46
+ * Why a Run stopped at its effect boundary, as its worker recorded it (OSK-33242): the server's content-free codes, as
47
+ * sent. Nothing for a Run with no record, or an older server.
48
+ */
49
+ export declare function unprovenLine(review: DutyRunRecoveryReview): string | undefined;