@skrr-ai/cli 0.1.157 → 0.1.158

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.
@@ -0,0 +1,23 @@
1
+ import { BaseCommand } from '../../base-command';
2
+ /**
3
+ * `skrr activity scan-older <chat|group-chat>` — a separate, bounded read of older chat or group
4
+ * replies (`GET /api/agent-activity/chat/scan-older`, `.../group-chat/scan-older`).
5
+ *
6
+ * This is not the feed with another cursor. A scan does not depend on what the feed filtered out,
7
+ * its cursor is not a global time order or a has-more signal, and some history may be unavailable,
8
+ * so `--json` prints the server's own response (`scanOlderCursor` included) and is not reshaped into
9
+ * the list envelope, whose `has_more` would claim what the cursor does not.
10
+ */
11
+ export default class ActivityScanOlder extends BaseCommand {
12
+ static description: string;
13
+ static examples: string[];
14
+ static args: {
15
+ source: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
16
+ };
17
+ static flags: {
18
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
19
+ limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
20
+ cursor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
+ };
22
+ run(): Promise<void>;
23
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const base_command_1 = require("../../base-command");
5
+ const agent_activity_1 = require("../../lib/agent-activity");
6
+ /**
7
+ * `skrr activity scan-older <chat|group-chat>` — a separate, bounded read of older chat or group
8
+ * replies (`GET /api/agent-activity/chat/scan-older`, `.../group-chat/scan-older`).
9
+ *
10
+ * This is not the feed with another cursor. A scan does not depend on what the feed filtered out,
11
+ * its cursor is not a global time order or a has-more signal, and some history may be unavailable,
12
+ * so `--json` prints the server's own response (`scanOlderCursor` included) and is not reshaped into
13
+ * the list envelope, whose `has_more` would claim what the cursor does not.
14
+ */
15
+ class ActivityScanOlder extends base_command_1.BaseCommand {
16
+ static description = 'Scan for older chat or group replies the activity feed does not page to';
17
+ static examples = [
18
+ '<%= config.bin %> activity scan-older chat',
19
+ '<%= config.bin %> activity scan-older group-chat',
20
+ '<%= config.bin %> activity scan-older group-chat --cursor <scanOlderCursor>',
21
+ '<%= config.bin %> activity scan-older chat --limit 10 --json',
22
+ ];
23
+ static args = {
24
+ source: core_1.Args.string({
25
+ description: 'Which scan: chat (your own chat replies from your Agents) or group-chat (replies in Groups you can read)',
26
+ required: true,
27
+ options: ['chat', 'group-chat'],
28
+ }),
29
+ };
30
+ static flags = {
31
+ json: core_1.Flags.boolean({ description: 'Output the server response as JSON' }),
32
+ limit: core_1.Flags.integer({
33
+ description: 'Maximum records per scan (1–100)',
34
+ min: 1,
35
+ max: 100,
36
+ default: 30,
37
+ }),
38
+ cursor: core_1.Flags.string({
39
+ description: "Cursor from the preceding scan's scanOlderCursor, for the same source",
40
+ }),
41
+ };
42
+ async run() {
43
+ this.requireAuth();
44
+ const { args, flags } = await this.parse(ActivityScanOlder);
45
+ const source = args.source;
46
+ let response;
47
+ try {
48
+ response = await (0, agent_activity_1.scanOlderActivity)({ source, limit: flags.limit, ...(flags.cursor ? { cursor: flags.cursor } : {}) }, this.resolvedCredential);
49
+ }
50
+ catch (err) {
51
+ this.handleApiError(err);
52
+ }
53
+ // A body that is not the documented shape is an error, not an empty scan: "nothing older" is the
54
+ // reading that would reassure about exactly what this command exists to find.
55
+ const parsed = (0, agent_activity_1.parseActivityScan)(source, response);
56
+ if (!parsed) {
57
+ this.failWithCliError({
58
+ message: 'The server returned an activity scan response this CLI does not recognise.',
59
+ code: 'ACTIVITY_SCAN_RESPONSE_UNEXPECTED',
60
+ exit: 1,
61
+ retryable: false,
62
+ details: {
63
+ suggestion: `Update skrr, and check that the server is a release that serves GET /api/agent-activity/${source}/scan-older.`,
64
+ },
65
+ });
66
+ }
67
+ if (flags.json) {
68
+ this.printJsonResult(response);
69
+ return;
70
+ }
71
+ (0, agent_activity_1.renderActivityScan)(source, parsed, (line) => this.log(line));
72
+ }
73
+ }
74
+ exports.default = ActivityScanOlder;
@@ -1,6 +1,13 @@
1
1
  import { BaseCommand } from '../../base-command';
2
+ import { type GroupChatActivityDetail } from '../../lib/agent-activity';
2
3
  /** Render only content returned by the owner-authorized trigger detail API. */
3
4
  export declare function renderFireContent(detail: Record<string, unknown>, log: (line: string) => void): void;
5
+ /**
6
+ * Render one Group reply: the saved reply text and what the server says it does NOT have. Every
7
+ * string is the response's, so it goes through `terminalText`, and a state the server did not
8
+ * report is never filled in (an unrecognised availability is printed as itself, not as "empty").
9
+ */
10
+ export declare function renderGroupChatContent(detail: GroupChatActivityDetail, log: (line: string) => void): void;
4
11
  export default class ActivityShow extends BaseCommand {
5
12
  static description: string;
6
13
  static examples: string[];
@@ -11,6 +18,8 @@ export default class ActivityShow extends BaseCommand {
11
18
  duty: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
19
  task: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
20
  run: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
+ 'group-chat': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ message: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
23
  limit: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
24
  cursor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
25
  };
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderFireContent = renderFireContent;
4
+ exports.renderGroupChatContent = renderGroupChatContent;
4
5
  const core_1 = require("@oclif/core");
5
6
  const base_command_1 = require("../../base-command");
7
+ const agent_activity_1 = require("../../lib/agent-activity");
6
8
  const duties_1 = require("../../lib/duties");
9
+ const http_error_1 = require("../../lib/http-error");
7
10
  const triggers_1 = require("../../lib/triggers");
11
+ const workspace_header_1 = require("../../lib/workspace-header");
8
12
  const fire_detail_1 = require("../triggers/fire-detail");
9
13
  // Source text is untrusted. Preserve useful whitespace, but never send terminal
10
14
  // control sequences from a stored prompt or response to the caller's terminal.
@@ -35,17 +39,58 @@ function renderFireContent(detail, log) {
35
39
  else
36
40
  log('Response: unavailable');
37
41
  }
42
+ /**
43
+ * Render one Group reply: the saved reply text and what the server says it does NOT have. Every
44
+ * string is the response's, so it goes through `terminalText`, and a state the server did not
45
+ * report is never filled in (an unrecognised availability is printed as itself, not as "empty").
46
+ */
47
+ function renderGroupChatContent(detail, log) {
48
+ const { output } = detail;
49
+ const state = (entry) => entry?.availability
50
+ ? `${terminalText(entry.availability)}${entry.reason ? ` (${terminalText(entry.reason)})` : ''}`
51
+ : 'not reported';
52
+ log('Group chat reply');
53
+ if (detail.source?.groupChatId)
54
+ log(` Group chat: ${terminalText(detail.source.groupChatId)}`);
55
+ if (detail.source?.responseMessageId)
56
+ log(` Message: ${terminalText(detail.source.responseMessageId)}`);
57
+ log('');
58
+ const partial = output.availability === 'partial'
59
+ ? typeof output.originalLength === 'number' && typeof output.text === 'string'
60
+ ? ` (partial: first ${output.text.length} of ${output.originalLength} characters)`
61
+ : ' (partial)'
62
+ : '';
63
+ if (output.availability === 'complete' || output.availability === 'partial') {
64
+ log(`Agent reply${partial}:`);
65
+ log(output.text ? terminalText(output.text) : 'Empty message');
66
+ }
67
+ else if (output.availability === 'pending') {
68
+ log('Agent reply: still in progress');
69
+ }
70
+ else if (output.availability === 'unavailable') {
71
+ log('Agent reply: not available');
72
+ }
73
+ else {
74
+ log(`Agent reply: ${terminalText(output.availability)}`);
75
+ }
76
+ log('');
77
+ log(`Input: ${state(detail.input)}`);
78
+ log(`Full provider prompt: ${state(detail.fullProviderPrompt)}`);
79
+ if (detail.outputCoverage === 'partial')
80
+ log('Output coverage: partial. Attachments and other output may be missing.');
81
+ }
38
82
  class ActivityShow extends base_command_1.BaseCommand {
39
- static description = 'Inspect a source-linked trigger fire or a Duty trace';
83
+ static description = 'Inspect a source-linked trigger fire, a Duty trace or a Group reply';
40
84
  static examples = [
41
85
  '<%= config.bin %> activity show --trigger <trigger-id> --fire <occurrence-id>',
42
86
  '<%= config.bin %> activity show --duty <duty-id> --json',
87
+ '<%= config.bin %> activity show --group-chat <group-chat-id> --message <message-id>',
43
88
  ];
44
89
  static flags = {
45
90
  json: core_1.Flags.boolean({ description: 'Output the authorized source response as JSON' }),
46
91
  trigger: core_1.Flags.string({
47
92
  description: 'Trigger ID from source reference',
48
- exclusive: ['duty', 'task'],
93
+ exclusive: ['duty', 'task', 'group-chat'],
49
94
  }),
50
95
  fire: core_1.Flags.string({
51
96
  description: 'Fire occurrence ID or row ID; requires --trigger',
@@ -53,16 +98,25 @@ class ActivityShow extends base_command_1.BaseCommand {
53
98
  }),
54
99
  duty: core_1.Flags.string({
55
100
  description: 'Duty ID; show its independently authorized trace',
56
- exclusive: ['trigger', 'fire', 'task', 'run'],
101
+ exclusive: ['trigger', 'fire', 'task', 'run', 'group-chat', 'message'],
57
102
  }),
58
103
  task: core_1.Flags.string({
59
104
  description: 'Task ID from source reference',
60
- exclusive: ['trigger', 'fire', 'duty'],
105
+ exclusive: ['trigger', 'fire', 'duty', 'group-chat'],
61
106
  }),
62
107
  run: core_1.Flags.string({
63
108
  description: 'Task execution run ID; requires --task',
64
109
  dependsOn: ['task'],
65
- exclusive: ['trigger', 'fire', 'duty'],
110
+ exclusive: ['trigger', 'fire', 'duty', 'group-chat'],
111
+ }),
112
+ 'group-chat': core_1.Flags.string({
113
+ description: 'Group chat ID from a group_chat source reference; shows that Agent reply (requires --message)',
114
+ exclusive: ['trigger', 'fire', 'duty', 'task', 'run'],
115
+ }),
116
+ message: core_1.Flags.string({
117
+ description: 'Message ID of the Group reply from the same source reference; requires --group-chat',
118
+ dependsOn: ['group-chat'],
119
+ exclusive: ['trigger', 'fire', 'duty', 'task', 'run'],
66
120
  }),
67
121
  limit: core_1.Flags.integer({ description: 'Maximum Duty trace events (1–500)', min: 1, max: 500 }),
68
122
  cursor: core_1.Flags.string({ description: 'Continue a Duty trace using its own cursor' }),
@@ -70,19 +124,68 @@ class ActivityShow extends base_command_1.BaseCommand {
70
124
  async run() {
71
125
  this.requireAuth();
72
126
  const { flags } = await this.parse(ActivityShow);
127
+ const groupChat = flags['group-chat'];
73
128
  const chosen = Number(Boolean(flags.duty)) +
74
129
  Number(Boolean(flags.trigger || flags.fire)) +
75
- Number(Boolean(flags.task || flags.run));
130
+ Number(Boolean(flags.task || flags.run)) +
131
+ Number(Boolean(groupChat || flags.message));
76
132
  if (chosen > 1)
77
- this.error('Choose one source: Duty, trigger fire, or Task run.', { exit: 2 });
78
- if (!flags.duty && !(flags.trigger && flags.fire) && !(flags.task && flags.run)) {
79
- this.error('Provide --duty, both --trigger and --fire, or both --task and --run.', {
80
- exit: 2,
81
- });
133
+ this.error('Choose one source: Duty, trigger fire, Task run, or Group reply.', { exit: 2 });
134
+ if (!flags.duty &&
135
+ !(flags.trigger && flags.fire) &&
136
+ !(flags.task && flags.run) &&
137
+ !(groupChat && flags.message)) {
138
+ this.error('Provide --duty, both --trigger and --fire, both --task and --run, or both --group-chat and --message.', { exit: 2 });
82
139
  }
83
140
  if (!flags.duty && (flags.limit !== undefined || flags.cursor)) {
84
141
  this.error('--limit and --cursor apply only to a Duty trace.', { exit: 2 });
85
142
  }
143
+ if (groupChat && flags.message) {
144
+ // Fetch inside the try; the shape check sits outside it so a CLI error is not re-handled as an API one.
145
+ let detail;
146
+ try {
147
+ detail = await (0, agent_activity_1.getGroupChatActivityDetail)({ groupChatId: groupChat, messageId: flags.message }, this.resolvedCredential);
148
+ }
149
+ catch (err) {
150
+ // The API answers "no such reply", "not permitted" and "other workspace" with one 404, but it
151
+ // matches the workspace exactly, and only this process knows what the request named.
152
+ if ((0, http_error_1.httpStatusOf)(err) === 404) {
153
+ const sentWorkspaceId = (0, workspace_header_1.withWorkspaceHeader)({})['X-Workspace-Id'];
154
+ const unavailable = (0, agent_activity_1.groupReplyUnavailable)(sentWorkspaceId);
155
+ this.failWithCliError({
156
+ message: unavailable.message,
157
+ code: 'ACTIVITY_SOURCE_UNAVAILABLE',
158
+ status: 404,
159
+ exit: 4,
160
+ retryable: false,
161
+ details: {
162
+ suggestion: unavailable.suggestion,
163
+ ...(sentWorkspaceId ? { workspaceId: sentWorkspaceId } : {}),
164
+ },
165
+ });
166
+ }
167
+ this.handleApiError(err);
168
+ }
169
+ if (flags.json) {
170
+ this.log(JSON.stringify(detail, null, 2));
171
+ return;
172
+ }
173
+ const parsed = (0, agent_activity_1.parseGroupChatActivityDetail)(detail);
174
+ if (!parsed) {
175
+ // Not "Empty message": a body that is not the documented shape says nothing about the reply.
176
+ this.failWithCliError({
177
+ message: 'The server returned a Group reply response this CLI does not recognise.',
178
+ code: 'ACTIVITY_DETAIL_RESPONSE_UNEXPECTED',
179
+ exit: 1,
180
+ retryable: false,
181
+ details: {
182
+ suggestion: 'Update skrr, and check that the server is a release that serves GET /api/agent-activity/group-chat/:groupChatId/:messageId. --json prints what it returned.',
183
+ },
184
+ });
185
+ }
186
+ renderGroupChatContent(parsed, (line) => this.log(line));
187
+ return;
188
+ }
86
189
  try {
87
190
  if (flags.task && flags.run) {
88
191
  // The legacy replay ledger stores only logical Task and Run IDs. It
@@ -65,4 +65,89 @@ export declare function sourceLabel(ref: ActivitySourceRef | undefined): string;
65
65
  * Every value is untrusted text and goes through `formatCell`.
66
66
  */
67
67
  export declare function runtimeCell(item: ActivityItem): string;
68
+ /** The activity table, shared by the feed and the older-activity scans so the two never drift. */
69
+ export declare function renderActivityItems(items: ActivityItem[], log: (line: string) => void): void;
68
70
  export declare function renderAgentActivity(response: ActivityResponse, log: (line: string) => void): void;
71
+ export type ActivityScanSource = 'chat' | 'group-chat';
72
+ export interface ActivityScanResponse {
73
+ object: string;
74
+ items: ActivityItem[];
75
+ /** Absent when the server cannot continue the scan. */
76
+ scanOlderCursor?: string;
77
+ ordering?: string;
78
+ /** One object, unlike the feed's per-source array. */
79
+ coverage: {
80
+ source?: string;
81
+ state: string;
82
+ reason?: string;
83
+ };
84
+ }
85
+ /**
86
+ * Scan for older chat replies (yours) or older group replies. Agent-scoped group scans are not
87
+ * offered: the API answers them with an empty list and `unsupported` coverage, because historical
88
+ * agent identities cannot be verified, and the web says so instead of calling it.
89
+ */
90
+ export declare function scanOlderActivity(options: {
91
+ source: ActivityScanSource;
92
+ limit?: number;
93
+ cursor?: string;
94
+ }, credential?: ResolvedCredential): Promise<unknown>;
95
+ /**
96
+ * Accept a response only if it has the documented shape. A body that merely LOOKS empty (a proxy
97
+ * page, a server that answers a different contract) must not render as "no older activity": that is
98
+ * the reading that would reassure about exactly what a scan exists to find.
99
+ */
100
+ export declare function parseActivityScan(source: ActivityScanSource, value: unknown): ActivityScanResponse | null;
101
+ export declare function renderActivityScan(source: ActivityScanSource, response: ActivityScanResponse, log: (line: string) => void): void;
102
+ export interface GroupChatActivityDetail {
103
+ object: string;
104
+ source?: {
105
+ kind?: string;
106
+ groupChatId?: string;
107
+ responseMessageId?: string;
108
+ };
109
+ input?: {
110
+ availability?: string;
111
+ reason?: string;
112
+ };
113
+ output: {
114
+ kind?: string;
115
+ /** `complete`, `partial`, `pending` or `unavailable`; anything else is printed as itself. */
116
+ availability: string;
117
+ fidelity?: string;
118
+ text?: string;
119
+ /** Set when `text` was cut to the server's limit. */
120
+ originalLength?: number;
121
+ };
122
+ outputCoverage?: string;
123
+ fullProviderPrompt?: {
124
+ availability?: string;
125
+ reason?: string;
126
+ };
127
+ }
128
+ /**
129
+ * One Group reply, opened through the API that owns it. The caller needs current READ on the group
130
+ * at the reply's original time; an id that does not resolve and one the caller may not see answer
131
+ * the same 404.
132
+ */
133
+ export declare function getGroupChatActivityDetail(ref: {
134
+ groupChatId: string;
135
+ messageId: string;
136
+ }, credential?: ResolvedCredential): Promise<unknown>;
137
+ /**
138
+ * A reply whose text is `complete` or `partial` must carry that text. Without it the response is
139
+ * not the documented shape, and printing "Empty message" would say something the server did not.
140
+ */
141
+ export declare function parseGroupChatActivityDetail(value: unknown): GroupChatActivityDetail | null;
142
+ /**
143
+ * What to tell the caller when a Group reply answers 404. The API gives one answer to "no such
144
+ * reply", "you may not read it" and "the workspace is not the Group's own", on purpose, so the
145
+ * caller cannot probe for existence. It does check the workspace by EXACT match
146
+ * (`groupChatContent.usableGroup`: the Group's `workspaceId` must equal the request's, both
147
+ * absent included), and the CLI is the only party that knows what the request named, so it can
148
+ * name the one cause the caller can act on without revealing which of the three it was.
149
+ */
150
+ export declare function groupReplyUnavailable(sentWorkspaceId: string | null | undefined): {
151
+ message: string;
152
+ suggestion: string;
153
+ };
@@ -3,9 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listAgentActivity = listAgentActivity;
4
4
  exports.sourceLabel = sourceLabel;
5
5
  exports.runtimeCell = runtimeCell;
6
+ exports.renderActivityItems = renderActivityItems;
6
7
  exports.renderAgentActivity = renderAgentActivity;
8
+ exports.scanOlderActivity = scanOlderActivity;
9
+ exports.parseActivityScan = parseActivityScan;
10
+ exports.renderActivityScan = renderActivityScan;
11
+ exports.getGroupChatActivityDetail = getGroupChatActivityDetail;
12
+ exports.parseGroupChatActivityDetail = parseGroupChatActivityDetail;
13
+ exports.groupReplyUnavailable = groupReplyUnavailable;
7
14
  const api_fetch_1 = require("./api-fetch");
8
15
  const format_1 = require("./format");
16
+ const search_display_1 = require("./search-display");
9
17
  /** The API authorizes each source; a source reference is never an access grant. */
10
18
  function listAgentActivity(options, credential) {
11
19
  const query = new URLSearchParams({ scope: options.scope });
@@ -50,27 +58,31 @@ function runtimeCell(item) {
50
58
  parts.push(`hand-off ${(0, format_1.formatCell)(handoff)}`);
51
59
  return parts.join(' · ');
52
60
  }
61
+ /** The activity table, shared by the feed and the older-activity scans so the two never drift. */
62
+ function renderActivityItems(items, log) {
63
+ (0, format_1.renderTable)(items.map((item) => ({
64
+ when: (0, format_1.localTime)(item.timestamp),
65
+ source: (0, format_1.formatCell)(item.sourceKind),
66
+ status: (0, format_1.formatCell)(item.status, 'unknown'),
67
+ title: (0, format_1.formatCell)(item.title),
68
+ reference: sourceLabel(item.sourceRef),
69
+ runtime: runtimeCell(item),
70
+ content: (0, format_1.formatCell)(item.content?.state, 'unknown'),
71
+ })), [
72
+ { key: 'when', header: 'WHEN' },
73
+ { key: 'source', header: 'SOURCE' },
74
+ { key: 'status', header: 'STATUS' },
75
+ { key: 'title', header: 'ACTIVITY', maxWidth: 36 },
76
+ { key: 'reference', header: 'SOURCE REFERENCE', verbatim: true },
77
+ { key: 'runtime', header: 'RUNTIME' },
78
+ { key: 'content', header: 'CONTENT' },
79
+ ], log);
80
+ }
53
81
  function renderAgentActivity(response, log) {
54
82
  log(`Activity · ${response.scope}`);
55
83
  const items = Array.isArray(response.items) ? response.items : [];
56
84
  if (items.length) {
57
- (0, format_1.renderTable)(items.map((item) => ({
58
- when: (0, format_1.localTime)(item.timestamp),
59
- source: (0, format_1.formatCell)(item.sourceKind),
60
- status: (0, format_1.formatCell)(item.status, 'unknown'),
61
- title: (0, format_1.formatCell)(item.title),
62
- reference: sourceLabel(item.sourceRef),
63
- runtime: runtimeCell(item),
64
- content: (0, format_1.formatCell)(item.content?.state, 'unknown'),
65
- })), [
66
- { key: 'when', header: 'WHEN' },
67
- { key: 'source', header: 'SOURCE' },
68
- { key: 'status', header: 'STATUS' },
69
- { key: 'title', header: 'ACTIVITY', maxWidth: 36 },
70
- { key: 'reference', header: 'SOURCE REFERENCE', verbatim: true },
71
- { key: 'runtime', header: 'RUNTIME' },
72
- { key: 'content', header: 'CONTENT' },
73
- ], log);
85
+ renderActivityItems(items, log);
74
86
  }
75
87
  else {
76
88
  log('No activity returned for the available sources.');
@@ -83,6 +95,8 @@ function renderAgentActivity(response, log) {
83
95
  log(' or activity show --duty <dutyId>.');
84
96
  log('Task run content is not connected to Activity; open the Task for its authorized history.');
85
97
  log('Chat source: messages show <conversationId> <messageId> (subject to conversation access).');
98
+ log('Group reply: activity show --group-chat <groupChatId> --message <messageId>.');
99
+ log('Older chat or group rows the feed does not page to: activity scan-older chat|group-chat.');
86
100
  }
87
101
  log('');
88
102
  const coverage = Array.isArray(response.coverage) ? response.coverage : [];
@@ -104,3 +118,124 @@ function renderAgentActivity(response, log) {
104
118
  log('More activity may be available, but the server did not return a cursor.');
105
119
  }
106
120
  }
121
+ const SCAN_OBJECT = {
122
+ chat: 'personal_chat_activity_scan',
123
+ 'group-chat': 'group_chat_activity_scan',
124
+ };
125
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
126
+ /**
127
+ * Scan for older chat replies (yours) or older group replies. Agent-scoped group scans are not
128
+ * offered: the API answers them with an empty list and `unsupported` coverage, because historical
129
+ * agent identities cannot be verified, and the web says so instead of calling it.
130
+ */
131
+ function scanOlderActivity(options, credential) {
132
+ const query = new URLSearchParams();
133
+ if (options.source === 'group-chat')
134
+ query.set('scope', 'user');
135
+ if (options.limit !== undefined)
136
+ query.set('limit', String(options.limit));
137
+ if (options.cursor)
138
+ query.set('cursor', options.cursor);
139
+ return options.source === 'chat'
140
+ ? (0, api_fetch_1.apiFetch)(`/api/agent-activity/chat/scan-older?${query.toString()}`, { credential })
141
+ : (0, api_fetch_1.apiFetch)(`/api/agent-activity/group-chat/scan-older?${query.toString()}`, {
142
+ credential,
143
+ });
144
+ }
145
+ /**
146
+ * Accept a response only if it has the documented shape. A body that merely LOOKS empty (a proxy
147
+ * page, a server that answers a different contract) must not render as "no older activity": that is
148
+ * the reading that would reassure about exactly what a scan exists to find.
149
+ */
150
+ function parseActivityScan(source, value) {
151
+ if (!isRecord(value) || value.object !== SCAN_OBJECT[source])
152
+ return null;
153
+ if (!Array.isArray(value.items) || !value.items.every(isRecord))
154
+ return null;
155
+ if (!isRecord(value.coverage) || typeof value.coverage.state !== 'string')
156
+ return null;
157
+ if (value.scanOlderCursor !== undefined && typeof value.scanOlderCursor !== 'string')
158
+ return null;
159
+ return value;
160
+ }
161
+ function renderActivityScan(source, response, log) {
162
+ const label = source === 'chat' ? 'chat' : 'group';
163
+ log(`Earlier ${label} activity`);
164
+ if (response.items.length) {
165
+ renderActivityItems(response.items, log);
166
+ log('');
167
+ log(source === 'chat'
168
+ ? 'Chat source: messages show <conversationId> <messageId> (subject to conversation access).'
169
+ : 'Group reply: activity show --group-chat <groupChatId> --message <messageId>.');
170
+ }
171
+ else {
172
+ log(`No additional visible ${label} activity was found in this scan.`);
173
+ }
174
+ // Never present a scan as complete: say what it is, and print the server's own coverage.
175
+ log('');
176
+ log(source === 'chat'
177
+ ? 'A scan is a separate, bounded read of older chat replies. Its cursor is not a global time order or a has-more signal, and some history may be unavailable.'
178
+ : 'Groups are scanned separately, not in global time order. Some history may be unavailable.');
179
+ const coverage = response.coverage;
180
+ log(`Coverage: ${(0, format_1.formatCell)(coverage.source, label)}: ${(0, format_1.formatCell)(coverage.state, 'unknown')}${coverage.reason ? ` (${(0, format_1.formatCell)(coverage.reason)})` : ''}`);
181
+ log('');
182
+ const cursor = response.scanOlderCursor;
183
+ if (!cursor) {
184
+ log('The server returned no cursor, so this scan cannot be continued.');
185
+ }
186
+ else if (!(0, search_display_1.isPrintableSearchCursor)(cursor)) {
187
+ log('The server returned a cursor that cannot be printed safely; read it with --json.');
188
+ }
189
+ else {
190
+ log(`Next scan cursor: ${cursor}`);
191
+ log('Pass it with --cursor to scan further back. A scan with no rows does not prove nothing older exists.');
192
+ }
193
+ }
194
+ /**
195
+ * One Group reply, opened through the API that owns it. The caller needs current READ on the group
196
+ * at the reply's original time; an id that does not resolve and one the caller may not see answer
197
+ * the same 404.
198
+ */
199
+ function getGroupChatActivityDetail(ref, credential) {
200
+ return (0, api_fetch_1.apiFetch)(`/api/agent-activity/group-chat/${encodeURIComponent(ref.groupChatId)}/${encodeURIComponent(ref.messageId)}`, { credential });
201
+ }
202
+ /**
203
+ * A reply whose text is `complete` or `partial` must carry that text. Without it the response is
204
+ * not the documented shape, and printing "Empty message" would say something the server did not.
205
+ */
206
+ function parseGroupChatActivityDetail(value) {
207
+ if (!isRecord(value) || value.object !== 'group_chat_activity_detail')
208
+ return null;
209
+ const output = value.output;
210
+ if (!isRecord(output) || typeof output.availability !== 'string')
211
+ return null;
212
+ if ((output.availability === 'complete' || output.availability === 'partial') &&
213
+ typeof output.text !== 'string')
214
+ return null;
215
+ if (output.text !== undefined && typeof output.text !== 'string')
216
+ return null;
217
+ if (output.originalLength !== undefined && typeof output.originalLength !== 'number')
218
+ return null;
219
+ return value;
220
+ }
221
+ /**
222
+ * What to tell the caller when a Group reply answers 404. The API gives one answer to "no such
223
+ * reply", "you may not read it" and "the workspace is not the Group's own", on purpose, so the
224
+ * caller cannot probe for existence. It does check the workspace by EXACT match
225
+ * (`groupChatContent.usableGroup`: the Group's `workspaceId` must equal the request's, both
226
+ * absent included), and the CLI is the only party that knows what the request named, so it can
227
+ * name the one cause the caller can act on without revealing which of the three it was.
228
+ */
229
+ function groupReplyUnavailable(sentWorkspaceId) {
230
+ const sent = sentWorkspaceId?.trim();
231
+ return {
232
+ message: 'That Group reply is unavailable: it does not exist, you cannot read it, ' +
233
+ (sent
234
+ ? `or the Group is not in workspace ${sent}, which this request named. `
235
+ : 'or the Group belongs to a workspace and this request named none. ') +
236
+ 'The server answers all of these the same way.',
237
+ suggestion: 'A Group in a workspace is found only when that workspace is named (--workspace <workspace-id>, ' +
238
+ 'or `skrr workspaces use <workspace-id>`); a Group outside any workspace only when none is. ' +
239
+ '`skrr workspaces list` shows yours.',
240
+ };
241
+ }
@@ -1093,13 +1093,108 @@
1093
1093
  "list.js"
1094
1094
  ]
1095
1095
  },
1096
+ "activity:scan-older": {
1097
+ "aliases": [],
1098
+ "args": {
1099
+ "source": {
1100
+ "description": "Which scan: chat (your own chat replies from your Agents) or group-chat (replies in Groups you can read)",
1101
+ "name": "source",
1102
+ "options": [
1103
+ "chat",
1104
+ "group-chat"
1105
+ ],
1106
+ "required": true
1107
+ }
1108
+ },
1109
+ "description": "Scan for older chat or group replies the activity feed does not page to",
1110
+ "examples": [
1111
+ "<%= config.bin %> activity scan-older chat",
1112
+ "<%= config.bin %> activity scan-older group-chat",
1113
+ "<%= config.bin %> activity scan-older group-chat --cursor <scanOlderCursor>",
1114
+ "<%= config.bin %> activity scan-older chat --limit 10 --json"
1115
+ ],
1116
+ "flags": {
1117
+ "bare": {
1118
+ "description": "Bare mode — ignore keychain/file credential sources. Token must come from env or --token.",
1119
+ "name": "bare",
1120
+ "allowNo": false,
1121
+ "type": "boolean"
1122
+ },
1123
+ "token": {
1124
+ "description": "Bearer token for this invocation (debugging/impersonation). Overrides env and stored creds.",
1125
+ "name": "token",
1126
+ "hasDynamicHelp": false,
1127
+ "multiple": false,
1128
+ "type": "option"
1129
+ },
1130
+ "workspace": {
1131
+ "description": "Workspace ID for workspace-scoped requests (also sets X-Workspace-Id).",
1132
+ "name": "workspace",
1133
+ "hasDynamicHelp": false,
1134
+ "multiple": false,
1135
+ "type": "option"
1136
+ },
1137
+ "profile": {
1138
+ "description": "Which stored session to use. Each profile keeps its own credential and deployment, so signing into one does not sign you out of another. Also OVERSKY_PROFILE. List them with `profiles list`.",
1139
+ "name": "profile",
1140
+ "hasDynamicHelp": false,
1141
+ "multiple": false,
1142
+ "type": "option"
1143
+ },
1144
+ "raw": {
1145
+ "description": "With --json, keep the Mongo storage fields (_id next to id, __v) that the CLI otherwise strips. Also OVERSKY_CLI_RAW=1.",
1146
+ "name": "raw",
1147
+ "allowNo": false,
1148
+ "type": "boolean"
1149
+ },
1150
+ "json": {
1151
+ "description": "Output the server response as JSON",
1152
+ "name": "json",
1153
+ "allowNo": false,
1154
+ "type": "boolean"
1155
+ },
1156
+ "limit": {
1157
+ "description": "Maximum records per scan (1–100)",
1158
+ "name": "limit",
1159
+ "default": 30,
1160
+ "hasDynamicHelp": false,
1161
+ "multiple": false,
1162
+ "type": "option"
1163
+ },
1164
+ "cursor": {
1165
+ "description": "Cursor from the preceding scan's scanOlderCursor, for the same source",
1166
+ "name": "cursor",
1167
+ "hasDynamicHelp": false,
1168
+ "multiple": false,
1169
+ "type": "option"
1170
+ }
1171
+ },
1172
+ "hasDynamicHelp": false,
1173
+ "hiddenAliases": [],
1174
+ "id": "activity:scan-older",
1175
+ "pluginAlias": "@skrr-ai/cli",
1176
+ "pluginName": "@skrr-ai/cli",
1177
+ "pluginType": "core",
1178
+ "strict": true,
1179
+ "enableJsonFlag": false,
1180
+ "autonomousCredentialPolicy": "delegated",
1181
+ "resolveSpaceFlag": true,
1182
+ "isESM": false,
1183
+ "relativePath": [
1184
+ "dist",
1185
+ "commands",
1186
+ "activity",
1187
+ "scan-older.js"
1188
+ ]
1189
+ },
1096
1190
  "activity:show": {
1097
1191
  "aliases": [],
1098
1192
  "args": {},
1099
- "description": "Inspect a source-linked trigger fire or a Duty trace",
1193
+ "description": "Inspect a source-linked trigger fire, a Duty trace or a Group reply",
1100
1194
  "examples": [
1101
1195
  "<%= config.bin %> activity show --trigger <trigger-id> --fire <occurrence-id>",
1102
- "<%= config.bin %> activity show --duty <duty-id> --json"
1196
+ "<%= config.bin %> activity show --duty <duty-id> --json",
1197
+ "<%= config.bin %> activity show --group-chat <group-chat-id> --message <message-id>"
1103
1198
  ],
1104
1199
  "flags": {
1105
1200
  "bare": {
@@ -1145,7 +1240,8 @@
1145
1240
  "description": "Trigger ID from source reference",
1146
1241
  "exclusive": [
1147
1242
  "duty",
1148
- "task"
1243
+ "task",
1244
+ "group-chat"
1149
1245
  ],
1150
1246
  "name": "trigger",
1151
1247
  "hasDynamicHelp": false,
@@ -1168,7 +1264,9 @@
1168
1264
  "trigger",
1169
1265
  "fire",
1170
1266
  "task",
1171
- "run"
1267
+ "run",
1268
+ "group-chat",
1269
+ "message"
1172
1270
  ],
1173
1271
  "name": "duty",
1174
1272
  "hasDynamicHelp": false,
@@ -1180,7 +1278,8 @@
1180
1278
  "exclusive": [
1181
1279
  "trigger",
1182
1280
  "fire",
1183
- "duty"
1281
+ "duty",
1282
+ "group-chat"
1184
1283
  ],
1185
1284
  "name": "task",
1186
1285
  "hasDynamicHelp": false,
@@ -1195,13 +1294,45 @@
1195
1294
  "exclusive": [
1196
1295
  "trigger",
1197
1296
  "fire",
1198
- "duty"
1297
+ "duty",
1298
+ "group-chat"
1199
1299
  ],
1200
1300
  "name": "run",
1201
1301
  "hasDynamicHelp": false,
1202
1302
  "multiple": false,
1203
1303
  "type": "option"
1204
1304
  },
1305
+ "group-chat": {
1306
+ "description": "Group chat ID from a group_chat source reference; shows that Agent reply (requires --message)",
1307
+ "exclusive": [
1308
+ "trigger",
1309
+ "fire",
1310
+ "duty",
1311
+ "task",
1312
+ "run"
1313
+ ],
1314
+ "name": "group-chat",
1315
+ "hasDynamicHelp": false,
1316
+ "multiple": false,
1317
+ "type": "option"
1318
+ },
1319
+ "message": {
1320
+ "dependsOn": [
1321
+ "group-chat"
1322
+ ],
1323
+ "description": "Message ID of the Group reply from the same source reference; requires --group-chat",
1324
+ "exclusive": [
1325
+ "trigger",
1326
+ "fire",
1327
+ "duty",
1328
+ "task",
1329
+ "run"
1330
+ ],
1331
+ "name": "message",
1332
+ "hasDynamicHelp": false,
1333
+ "multiple": false,
1334
+ "type": "option"
1335
+ },
1205
1336
  "limit": {
1206
1337
  "description": "Maximum Duty trace events (1–500)",
1207
1338
  "name": "limit",
@@ -146896,5 +147027,5 @@
146896
147027
  ]
146897
147028
  }
146898
147029
  },
146899
- "version": "0.1.157"
147030
+ "version": "0.1.158"
146900
147031
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skrr-ai/cli",
3
- "version": "0.1.157",
3
+ "version": "0.1.158",
4
4
  "description": "Command-line interface for skrr",
5
5
  "license": "ISC",
6
6
  "author": "skrr",
@@ -690,5 +690,5 @@
690
690
  "engines": {
691
691
  "node": ">=20.0.0"
692
692
  },
693
- "gitHead": "3a453d7f73502bb70b2965fef3739305e0ae3ca7"
693
+ "gitHead": "877449e52536d27b434fd4f68462bb5a63407243"
694
694
  }