@skrr-ai/cli 0.1.155 → 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.
Files changed (150) hide show
  1. package/dist/base-command.js +64 -16
  2. package/dist/commands/activity/list.d.ts +13 -0
  3. package/dist/commands/activity/list.js +50 -0
  4. package/dist/commands/activity/scan-older.d.ts +23 -0
  5. package/dist/commands/activity/scan-older.js +74 -0
  6. package/dist/commands/activity/show.d.ts +27 -0
  7. package/dist/commands/activity/show.js +228 -0
  8. package/dist/commands/agent/message/send.js +64 -19
  9. package/dist/commands/agents/always-on/held-messages.js +24 -1
  10. package/dist/commands/agents/always-on/status.js +6 -1
  11. package/dist/commands/agents/mini-computer/app/reset.d.ts +13 -0
  12. package/dist/commands/agents/mini-computer/app/reset.js +35 -0
  13. package/dist/commands/agents/mini-computer/app/set.d.ts +16 -0
  14. package/dist/commands/agents/mini-computer/app/set.js +70 -0
  15. package/dist/commands/agents/mini-computer/layout/change.d.ts +14 -0
  16. package/dist/commands/agents/mini-computer/layout/change.js +44 -0
  17. package/dist/commands/agents/mini-computer/layout/folder.d.ts +14 -0
  18. package/dist/commands/agents/mini-computer/layout/folder.js +35 -0
  19. package/dist/commands/agents/mini-computer/layout/move.d.ts +14 -0
  20. package/dist/commands/agents/mini-computer/layout/move.js +32 -0
  21. package/dist/commands/agents/mini-computer/layout/pin.d.ts +14 -0
  22. package/dist/commands/agents/mini-computer/layout/pin.js +35 -0
  23. package/dist/commands/agents/mini-computer/layout/remove.d.ts +13 -0
  24. package/dist/commands/agents/mini-computer/layout/remove.js +27 -0
  25. package/dist/commands/agents/mini-computer/layout/restore.d.ts +13 -0
  26. package/dist/commands/agents/mini-computer/layout/restore.js +27 -0
  27. package/dist/commands/agents/mini-computer/layout/unfolder.d.ts +13 -0
  28. package/dist/commands/agents/mini-computer/layout/unfolder.js +27 -0
  29. package/dist/commands/agents/mini-computer/layout/unpin.d.ts +14 -0
  30. package/dist/commands/agents/mini-computer/layout/unpin.js +34 -0
  31. package/dist/commands/agents/mini-computer/show.d.ts +13 -0
  32. package/dist/commands/agents/mini-computer/show.js +60 -0
  33. package/dist/commands/agents/mini-computer/tasks-view.d.ts +29 -0
  34. package/dist/commands/agents/mini-computer/tasks-view.js +100 -0
  35. package/dist/commands/apps/auto-apply.d.ts +14 -0
  36. package/dist/commands/apps/auto-apply.js +53 -0
  37. package/dist/commands/apps/check.js +4 -1
  38. package/dist/commands/apps/create.js +11 -6
  39. package/dist/commands/apps/data/batch.d.ts +15 -0
  40. package/dist/commands/apps/data/batch.js +59 -0
  41. package/dist/commands/apps/data/collections.d.ts +12 -0
  42. package/dist/commands/apps/data/collections.js +44 -0
  43. package/dist/commands/apps/data/delete.d.ts +15 -0
  44. package/dist/commands/apps/data/delete.js +57 -0
  45. package/dist/commands/apps/data/patch.d.ts +17 -0
  46. package/dist/commands/apps/data/patch.js +70 -0
  47. package/dist/commands/apps/data/put.js +1 -1
  48. package/dist/commands/apps/data/query.js +1 -1
  49. package/dist/commands/apps/installations/diff.d.ts +14 -0
  50. package/dist/commands/apps/installations/diff.js +45 -0
  51. package/dist/commands/apps/installations/events.d.ts +23 -0
  52. package/dist/commands/apps/installations/events.js +104 -0
  53. package/dist/commands/apps/installations/snapshot.d.ts +18 -0
  54. package/dist/commands/apps/installations/snapshot.js +60 -0
  55. package/dist/commands/apps/installations/versions.d.ts +12 -0
  56. package/dist/commands/apps/installations/versions.js +38 -0
  57. package/dist/commands/apps/logs.js +3 -0
  58. package/dist/commands/apps/preview.js +4 -2
  59. package/dist/commands/apps/pull.js +10 -1
  60. package/dist/commands/apps/push.js +36 -12
  61. package/dist/commands/apps/reference.d.ts +26 -0
  62. package/dist/commands/apps/reference.js +56 -0
  63. package/dist/commands/apps/rollback.d.ts +13 -0
  64. package/dist/commands/apps/rollback.js +47 -0
  65. package/dist/commands/apps/version/create.js +5 -0
  66. package/dist/commands/duties/accounting.js +6 -0
  67. package/dist/commands/duties/analytics/detail.js +6 -0
  68. package/dist/commands/duties/analytics/index.js +14 -0
  69. package/dist/commands/duties/analytics/replay.js +6 -0
  70. package/dist/commands/duties/cost.js +6 -0
  71. package/dist/commands/duties/delete.js +22 -19
  72. package/dist/commands/duties/doctor.d.ts +2 -1
  73. package/dist/commands/duties/doctor.js +17 -3
  74. package/dist/commands/duties/goals/link.js +4 -0
  75. package/dist/commands/duties/goals/unlink.js +4 -0
  76. package/dist/commands/duties/lineage.js +6 -1
  77. package/dist/commands/duties/links/list.js +6 -0
  78. package/dist/commands/duties/metrics.js +10 -0
  79. package/dist/commands/duties/observations.js +12 -0
  80. package/dist/commands/duties/operating-review.d.ts +4 -30
  81. package/dist/commands/duties/operating-review.js +28 -141
  82. package/dist/commands/duties/receipt-metrics.js +7 -0
  83. package/dist/commands/duties/receipt.js +7 -0
  84. package/dist/commands/duties/roster.js +14 -8
  85. package/dist/commands/duties/show.js +27 -9
  86. package/dist/commands/duties/status.js +18 -9
  87. package/dist/commands/duties/trigger-status.d.ts +2 -0
  88. package/dist/commands/duties/trigger-status.js +19 -1
  89. package/dist/commands/duties/wake-capabilities.d.ts +2 -0
  90. package/dist/commands/duties/wake-capabilities.js +32 -2
  91. package/dist/commands/followups/act.js +3 -0
  92. package/dist/commands/followups/remind.js +12 -3
  93. package/dist/commands/followups/show.js +6 -0
  94. package/dist/commands/harnesses/quota.js +1 -1
  95. package/dist/commands/spaces/notebook.d.ts +3 -7
  96. package/dist/commands/spaces/notebook.js +32 -8
  97. package/dist/commands/tasks/create.d.ts +2 -2
  98. package/dist/commands/tasks/create.js +3 -3
  99. package/dist/commands/tasks/list.d.ts +3 -41
  100. package/dist/commands/tasks/list.js +5 -53
  101. package/dist/generated/agent-guides.json +424 -101
  102. package/dist/generated/managed-instruction-guides.json +1 -1
  103. package/dist/lib/agent-activity.d.ts +153 -0
  104. package/dist/lib/agent-activity.js +241 -0
  105. package/dist/lib/always-on-runtime.d.ts +9 -0
  106. package/dist/lib/always-on-runtime.js +20 -0
  107. package/dist/lib/api-fetch.d.ts +10 -0
  108. package/dist/lib/api-fetch.js +12 -2
  109. package/dist/lib/appData.d.ts +28 -1
  110. package/dist/lib/appData.js +111 -9
  111. package/dist/lib/appInstallations.d.ts +9 -1
  112. package/dist/lib/appInstallations.js +100 -0
  113. package/dist/lib/apps-command.d.ts +1 -0
  114. package/dist/lib/apps-command.js +11 -0
  115. package/dist/lib/apps.d.ts +12 -0
  116. package/dist/lib/apps.js +28 -1
  117. package/dist/lib/appsAssets.d.ts +17 -0
  118. package/dist/lib/appsAssets.js +15 -0
  119. package/dist/lib/appsCheck.d.ts +1 -0
  120. package/dist/lib/appsCheck.js +1 -0
  121. package/dist/lib/appsFs.d.ts +18 -1
  122. package/dist/lib/appsFs.js +76 -19
  123. package/dist/lib/compasses.js +6 -0
  124. package/dist/lib/duties.d.ts +25 -2
  125. package/dist/lib/duties.js +58 -3
  126. package/dist/lib/duty-analytics.d.ts +2 -0
  127. package/dist/lib/duty-analytics.js +26 -0
  128. package/dist/lib/duty-goal-propagation.d.ts +2 -0
  129. package/dist/lib/duty-goal-propagation.js +18 -0
  130. package/dist/lib/duty-history-source.d.ts +4 -0
  131. package/dist/lib/duty-history-source.js +12 -0
  132. package/dist/lib/duty-ledgers.d.ts +4 -0
  133. package/dist/lib/duty-ledgers.js +4 -0
  134. package/dist/lib/duty-receipt-source.d.ts +4 -0
  135. package/dist/lib/duty-receipt-source.js +19 -0
  136. package/dist/lib/followups.d.ts +20 -0
  137. package/dist/lib/followups.js +10 -0
  138. package/dist/lib/held-messages.d.ts +22 -0
  139. package/dist/lib/held-messages.js +55 -0
  140. package/dist/lib/list-workspace.d.ts +40 -0
  141. package/dist/lib/list-workspace.js +58 -0
  142. package/dist/lib/miniComputer.d.ts +59 -0
  143. package/dist/lib/miniComputer.js +224 -0
  144. package/dist/lib/miniComputerCommand.d.ts +13 -0
  145. package/dist/lib/miniComputerCommand.js +48 -0
  146. package/dist/lib/roles.d.ts +3 -3
  147. package/dist/lib/space-notebook.js +15 -4
  148. package/dist/node_modules/@skrr-ai/data-provider/index.js +10465 -8383
  149. package/oclif.manifest.json +2849 -462
  150. package/package.json +14 -2
@@ -366,26 +366,26 @@ class BaseCommand extends core_1.Command {
366
366
  // state. The restricted session token (or a null credential when it is
367
367
  // missing) is the only adapter authority exposed to the command.
368
368
  const historySession = this.constructor.sessionReadPolicy === 'memory-history-v1' &&
369
- (0, memory_history_session_1.hasMemoryHistoryRuntime)() ? (0, memory_history_session_1.memoryHistorySession)() : null;
369
+ (0, memory_history_session_1.hasMemoryHistoryRuntime)()
370
+ ? (0, memory_history_session_1.memoryHistorySession)()
371
+ : null;
370
372
  let autonomousCredential = historySession
371
- ? { token: historySession.token, source: 'env-token', kind: (0, auth_core_1.classifyTokenKind)(historySession.token) }
373
+ ? {
374
+ token: historySession.token,
375
+ source: 'env-token',
376
+ kind: (0, auth_core_1.classifyTokenKind)(historySession.token),
377
+ }
372
378
  : (0, credential_resolver_1.resolveTrustedAutonomousCredential)();
373
379
  const boundSessionCommand = Boolean(autonomousCredential &&
374
380
  this.constructor.autonomousCredentialPolicy === 'bound-session');
375
381
  if ((0, delegated_cli_1.isDelegatedCliSession)() && !boundSessionCommand) {
382
+ // Only the fetch is inside the try. `failWithCliError` writes the envelope and then THROWS to
383
+ // exit, so a call to it inside the try was caught by the catch below and reported a second
384
+ // time with the exit signal as its cause: two JSON documents on stdout and a message ending
385
+ // in `EEXIT: 75` (OSK-23475).
386
+ let delegatedCredential;
376
387
  try {
377
- const delegatedCredential = await (0, delegated_cli_1.fetchDelegatedCliCredential)();
378
- if (!delegatedCredential) {
379
- this.failWithCliError({
380
- message: 'Daemon delegated skrr credential is unavailable.',
381
- code: 'DELEGATED_CLI_CREDENTIAL_UNAVAILABLE',
382
- exit: 75,
383
- retryable: true,
384
- });
385
- return;
386
- }
387
- autonomousCredential = delegatedCredential;
388
- this.credentialProvenance = { kind: 'daemon-delegated' };
388
+ delegatedCredential = await (0, delegated_cli_1.fetchDelegatedCliCredential)();
389
389
  }
390
390
  catch (err) {
391
391
  // OSK-15990 — a refusal only a new daemon sign-in repairs (e.g.
@@ -419,6 +419,16 @@ class BaseCommand extends core_1.Command {
419
419
  retryable: true,
420
420
  });
421
421
  }
422
+ if (!delegatedCredential) {
423
+ this.failWithCliError({
424
+ message: 'Daemon delegated skrr credential is unavailable.',
425
+ code: 'DELEGATED_CLI_CREDENTIAL_UNAVAILABLE',
426
+ exit: 75,
427
+ retryable: true,
428
+ });
429
+ }
430
+ autonomousCredential = delegatedCredential;
431
+ this.credentialProvenance = { kind: 'daemon-delegated' };
422
432
  }
423
433
  if (autonomousCredential) {
424
434
  // Parse for normal oclif flag validation, but intentionally ignore both
@@ -1591,6 +1601,42 @@ class BaseCommand extends core_1.Command {
1591
1601
  details: envelopeDetails(body),
1592
1602
  });
1593
1603
  }
1604
+ else if (bodyCode === 'DUTY_GOAL_LINK_UNAVAILABLE' ||
1605
+ stringProp(body, 'error') === 'DUTY_GOAL_LINK_UNAVAILABLE') {
1606
+ this.failWithCliError({
1607
+ message: say('Linking or unlinking a Goal and Duty is currently unavailable. No changes were made.'),
1608
+ code: 'DUTY_GOAL_LINK_UNAVAILABLE',
1609
+ status: e.status,
1610
+ exit: 1,
1611
+ retryable: false,
1612
+ details: envelopeDetails(body),
1613
+ });
1614
+ }
1615
+ else if (bodyCode === 'SOURCE_LINEAGE_UNVERIFIED') {
1616
+ this.failWithCliError({
1617
+ message: say('Preflight is unavailable because its historical sources cannot be verified.'),
1618
+ code: bodyCode,
1619
+ status: e.status,
1620
+ exit: 1,
1621
+ retryable: false,
1622
+ details: envelopeDetails(body),
1623
+ });
1624
+ }
1625
+ else if (bodyCode === 'DUTY_HISTORY_UNAVAILABLE' ||
1626
+ bodyCode === 'DUTY_HISTORY_SOURCE_UNVERIFIED' ||
1627
+ stringProp(body, 'error') === 'DUTY_HISTORY_UNAVAILABLE') {
1628
+ // The API deliberately withholds historical Duty data whose physical
1629
+ // source cannot be verified. Neither the current 409 nor an older 503
1630
+ // is a control-plane outage, and retrying cannot establish lineage.
1631
+ this.failWithCliError({
1632
+ message: say('Duty history is unavailable because its original source cannot be verified.'),
1633
+ code: bodyCode || 'DUTY_HISTORY_UNAVAILABLE',
1634
+ status: e.status,
1635
+ exit: 1,
1636
+ retryable: false,
1637
+ details: envelopeDetails(body),
1638
+ });
1639
+ }
1594
1640
  else if (bodyCode === 'GITHUB_APP_NOT_CONFIGURED') {
1595
1641
  this.failWithCliError({
1596
1642
  message: say(describeGitHubAppNotConfigured()),
@@ -2901,8 +2947,10 @@ function errorBodyMessage(body) {
2901
2947
  ? record.error.message
2902
2948
  : undefined;
2903
2949
  const reason = (0, api_error_reason_1.reasonOnlyCode)(record);
2904
- return text(record.message) ?? text(record.error) ?? text(nested) ??
2905
- (reason ? `Request refused: ${reason}` : undefined);
2950
+ return (text(record.message) ??
2951
+ text(record.error) ??
2952
+ text(nested) ??
2953
+ (reason ? `Request refused: ${reason}` : undefined));
2906
2954
  }
2907
2955
  /**
2908
2956
  * The `details` of a CLI error envelope, in ONE shape. The server's refusal body becomes the
@@ -0,0 +1,13 @@
1
+ import { BaseCommand } from '../../base-command';
2
+ export default class ActivityList extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ duty: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
10
+ cursor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,50 @@
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
+ const list_output_1 = require("../../lib/list-output");
7
+ class ActivityList extends base_command_1.BaseCommand {
8
+ static description = 'List source-linked activity for yourself, an agent, or a duty';
9
+ static examples = [
10
+ '<%= config.bin %> activity list',
11
+ '<%= config.bin %> activity list --agent agent_123',
12
+ '<%= config.bin %> activity list --duty duty_123 --json',
13
+ '<%= config.bin %> activity list --agent agent_123 --cursor <cursor>',
14
+ ];
15
+ static flags = {
16
+ json: core_1.Flags.boolean({ description: 'Output the server response as JSON' }),
17
+ agent: core_1.Flags.string({ description: 'Show activity for this Agent ID', exclusive: ['duty'] }),
18
+ duty: core_1.Flags.string({ description: 'Show activity for this Duty ID', exclusive: ['agent'] }),
19
+ limit: core_1.Flags.integer({
20
+ description: 'Maximum records per page (1–100)',
21
+ min: 1,
22
+ max: 100,
23
+ default: 30,
24
+ }),
25
+ cursor: core_1.Flags.string({ description: 'Cursor from the preceding page, with the same scope' }),
26
+ };
27
+ async run() {
28
+ this.requireAuth();
29
+ const { flags } = await this.parse(ActivityList);
30
+ const scope = flags.agent ? 'agent' : flags.duty ? 'duty' : 'user';
31
+ try {
32
+ const response = await (0, agent_activity_1.listAgentActivity)({
33
+ scope,
34
+ ...(flags.agent ? { agentId: flags.agent } : {}),
35
+ ...(flags.duty ? { dutyId: flags.duty } : {}),
36
+ limit: flags.limit,
37
+ ...(flags.cursor ? { cursor: flags.cursor } : {}),
38
+ }, this.resolvedCredential);
39
+ // Standard list envelope (`data`, `has_more`, `next_cursor`); per-source `coverage` is kept.
40
+ if (flags.json)
41
+ this.log(JSON.stringify((0, list_output_1.listResult)(response, 'items'), null, 2));
42
+ else
43
+ (0, agent_activity_1.renderAgentActivity)(response, (line) => this.log(line));
44
+ }
45
+ catch (err) {
46
+ this.handleApiError(err);
47
+ }
48
+ }
49
+ }
50
+ exports.default = ActivityList;
@@ -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;
@@ -0,0 +1,27 @@
1
+ import { BaseCommand } from '../../base-command';
2
+ import { type GroupChatActivityDetail } from '../../lib/agent-activity';
3
+ /** Render only content returned by the owner-authorized trigger detail API. */
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;
11
+ export default class ActivityShow extends BaseCommand {
12
+ static description: string;
13
+ static examples: string[];
14
+ static flags: {
15
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ trigger: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ fire: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ duty: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ task: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
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>;
23
+ limit: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
+ cursor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
+ };
26
+ run(): Promise<void>;
27
+ }
@@ -0,0 +1,228 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderFireContent = renderFireContent;
4
+ exports.renderGroupChatContent = renderGroupChatContent;
5
+ const core_1 = require("@oclif/core");
6
+ const base_command_1 = require("../../base-command");
7
+ const agent_activity_1 = require("../../lib/agent-activity");
8
+ const duties_1 = require("../../lib/duties");
9
+ const http_error_1 = require("../../lib/http-error");
10
+ const triggers_1 = require("../../lib/triggers");
11
+ const workspace_header_1 = require("../../lib/workspace-header");
12
+ const fire_detail_1 = require("../triggers/fire-detail");
13
+ // Source text is untrusted. Preserve useful whitespace, but never send terminal
14
+ // control sequences from a stored prompt or response to the caller's terminal.
15
+ function terminalText(value) {
16
+ // eslint-disable-next-line no-control-regex -- control characters are the subject: this strips them out of text bound for a terminal.
17
+ return value.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/g, '');
18
+ }
19
+ /** Render only content returned by the owner-authorized trigger detail API. */
20
+ function renderFireContent(detail, log) {
21
+ const input = detail.input;
22
+ const output = detail.output;
23
+ if (typeof input?.promptText === 'string') {
24
+ log('');
25
+ log(`Trigger input${input.truncated === true ? ' (excerpt; truncated)' : ''}:`);
26
+ log(terminalText(input.promptText));
27
+ log('This is the recorded trigger input; the runtime may add or change context.');
28
+ }
29
+ else
30
+ log('Trigger input: unavailable');
31
+ const fullText = typeof output?.fullText === 'string' ? output.fullText : undefined;
32
+ const excerpt = typeof output?.excerpt === 'string' ? output.excerpt : undefined;
33
+ const response = fullText ?? excerpt;
34
+ if (response !== undefined) {
35
+ log('');
36
+ log(`Response${!fullText && output?.truncated === true ? ' (excerpt; truncated)' : ''}:`);
37
+ log(terminalText(response));
38
+ }
39
+ else
40
+ log('Response: unavailable');
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
+ }
82
+ class ActivityShow extends base_command_1.BaseCommand {
83
+ static description = 'Inspect a source-linked trigger fire, a Duty trace or a Group reply';
84
+ static examples = [
85
+ '<%= config.bin %> activity show --trigger <trigger-id> --fire <occurrence-id>',
86
+ '<%= config.bin %> activity show --duty <duty-id> --json',
87
+ '<%= config.bin %> activity show --group-chat <group-chat-id> --message <message-id>',
88
+ ];
89
+ static flags = {
90
+ json: core_1.Flags.boolean({ description: 'Output the authorized source response as JSON' }),
91
+ trigger: core_1.Flags.string({
92
+ description: 'Trigger ID from source reference',
93
+ exclusive: ['duty', 'task', 'group-chat'],
94
+ }),
95
+ fire: core_1.Flags.string({
96
+ description: 'Fire occurrence ID or row ID; requires --trigger',
97
+ dependsOn: ['trigger'],
98
+ }),
99
+ duty: core_1.Flags.string({
100
+ description: 'Duty ID; show its independently authorized trace',
101
+ exclusive: ['trigger', 'fire', 'task', 'run', 'group-chat', 'message'],
102
+ }),
103
+ task: core_1.Flags.string({
104
+ description: 'Task ID from source reference',
105
+ exclusive: ['trigger', 'fire', 'duty', 'group-chat'],
106
+ }),
107
+ run: core_1.Flags.string({
108
+ description: 'Task execution run ID; requires --task',
109
+ dependsOn: ['task'],
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'],
120
+ }),
121
+ limit: core_1.Flags.integer({ description: 'Maximum Duty trace events (1–500)', min: 1, max: 500 }),
122
+ cursor: core_1.Flags.string({ description: 'Continue a Duty trace using its own cursor' }),
123
+ };
124
+ async run() {
125
+ this.requireAuth();
126
+ const { flags } = await this.parse(ActivityShow);
127
+ const groupChat = flags['group-chat'];
128
+ const chosen = Number(Boolean(flags.duty)) +
129
+ Number(Boolean(flags.trigger || flags.fire)) +
130
+ Number(Boolean(flags.task || flags.run)) +
131
+ Number(Boolean(groupChat || flags.message));
132
+ if (chosen > 1)
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 });
139
+ }
140
+ if (!flags.duty && (flags.limit !== undefined || flags.cursor)) {
141
+ this.error('--limit and --cursor apply only to a Duty trace.', { exit: 2 });
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
+ }
189
+ try {
190
+ if (flags.task && flags.run) {
191
+ // The legacy replay ledger stores only logical Task and Run IDs. It
192
+ // cannot establish that its contents belong to the physical Task and
193
+ // Run referenced by an Activity item after deletion/recreation.
194
+ const unavailable = {
195
+ source: 'task_execution',
196
+ state: 'unsupported',
197
+ reason: 'Task run content is not connected to Activity. Open the Task to view its authorized history.',
198
+ };
199
+ this.log(flags.json ? JSON.stringify(unavailable, null, 2) : unavailable.reason);
200
+ return;
201
+ }
202
+ if (flags.duty) {
203
+ const trace = await duties_1.dutyApi.trace(flags.duty, {
204
+ ...(flags.limit !== undefined ? { limit: flags.limit } : {}),
205
+ ...(flags.cursor ? { cursor: flags.cursor } : {}),
206
+ });
207
+ if (flags.json)
208
+ this.log(JSON.stringify(trace, null, 2));
209
+ else
210
+ (0, duties_1.renderDutyTrace)(trace, (line) => this.log(terminalText(line)));
211
+ return;
212
+ }
213
+ const detail = await triggers_1.triggerApi.fireDetail(flags.trigger, flags.fire);
214
+ if (flags.json)
215
+ this.log(JSON.stringify(detail, null, 2));
216
+ else {
217
+ const row = detail;
218
+ for (const line of (0, fire_detail_1.describeFireAuditDetail)(row, flags.fire, flags.trigger))
219
+ this.log(terminalText(line));
220
+ renderFireContent(row, (line) => this.log(line));
221
+ }
222
+ }
223
+ catch (err) {
224
+ this.handleApiError(err);
225
+ }
226
+ }
227
+ }
228
+ exports.default = ActivityShow;