@skrr-ai/cli 0.1.162 → 0.1.164

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 (95) hide show
  1. package/dist/base-command.d.ts +5 -2
  2. package/dist/base-command.js +108 -39
  3. package/dist/commands/activity/list.d.ts +7 -0
  4. package/dist/commands/activity/list.js +17 -0
  5. package/dist/commands/activity/scan-older.d.ts +2 -2
  6. package/dist/commands/activity/scan-older.js +6 -5
  7. package/dist/commands/activity/show.d.ts +0 -2
  8. package/dist/commands/activity/show.js +21 -42
  9. package/dist/commands/agents/always-on/release-run.d.ts +3 -3
  10. package/dist/commands/agents/always-on/release-run.js +5 -6
  11. package/dist/commands/agents/mini-computer/app/reset.d.ts +1 -0
  12. package/dist/commands/agents/mini-computer/app/reset.js +5 -2
  13. package/dist/commands/agents/mini-computer/app/set.js +1 -1
  14. package/dist/commands/agents/mini-computer/show.js +10 -2
  15. package/dist/commands/agents/mini-computer/tasks-view.js +2 -2
  16. package/dist/commands/agents/supervision.d.ts +25 -0
  17. package/dist/commands/agents/supervision.js +129 -0
  18. package/dist/commands/agents/triggers/replay.js +1 -1
  19. package/dist/commands/agents/triggers/runs.d.ts +2 -3
  20. package/dist/commands/agents/triggers/runs.js +4 -5
  21. package/dist/commands/apps/auto-apply.js +31 -10
  22. package/dist/commands/apps/check.js +8 -0
  23. package/dist/commands/apps/data/batch.js +16 -5
  24. package/dist/commands/apps/data/collections.js +1 -1
  25. package/dist/commands/apps/data/delete.js +12 -4
  26. package/dist/commands/apps/data/patch.js +11 -4
  27. package/dist/commands/apps/data/put.js +13 -6
  28. package/dist/commands/apps/data/query.js +3 -3
  29. package/dist/commands/apps/install.js +24 -7
  30. package/dist/commands/apps/installations/events.d.ts +1 -0
  31. package/dist/commands/apps/installations/events.js +63 -10
  32. package/dist/commands/apps/installations/show.js +26 -5
  33. package/dist/commands/apps/installations/snapshot.js +1 -1
  34. package/dist/commands/apps/installations/versions.js +25 -9
  35. package/dist/commands/apps/logs.js +4 -1
  36. package/dist/commands/apps/push.js +10 -2
  37. package/dist/commands/apps/reconsent.js +7 -1
  38. package/dist/commands/apps/rollback.js +2 -2
  39. package/dist/commands/apps/settings/set.js +81 -4
  40. package/dist/commands/apps/settings/show.js +38 -7
  41. package/dist/commands/duties/action-proposal.js +19 -11
  42. package/dist/commands/duties/cadence-decisions.js +7 -0
  43. package/dist/commands/duties/status.js +20 -15
  44. package/dist/commands/duties/trigger-status.js +2 -2
  45. package/dist/commands/duties/wake-capabilities.js +12 -6
  46. package/dist/commands/outbox/drop.js +21 -15
  47. package/dist/commands/outbox/list.d.ts +2 -1
  48. package/dist/commands/outbox/list.js +20 -11
  49. package/dist/commands/outbox/retry.d.ts +8 -11
  50. package/dist/commands/outbox/retry.js +135 -92
  51. package/dist/commands/spaces/create.js +1 -1
  52. package/dist/commands/tasks/comments/add.js +1 -1
  53. package/dist/commands/triggers/audit.js +3 -5
  54. package/dist/commands/triggers/fire-detail.js +7 -1
  55. package/dist/commands/triggers/replay.js +1 -1
  56. package/dist/commands/triggers/runs.d.ts +2 -4
  57. package/dist/commands/triggers/runs.js +3 -5
  58. package/dist/generated/agent-guides.json +19 -19
  59. package/dist/lib/agent-activity.d.ts +21 -1
  60. package/dist/lib/agent-activity.js +98 -29
  61. package/dist/lib/api-fetch.d.ts +2 -0
  62. package/dist/lib/api-fetch.js +5 -5
  63. package/dist/lib/appData.d.ts +43 -5
  64. package/dist/lib/appData.js +117 -25
  65. package/dist/lib/appInstallations.d.ts +5 -5
  66. package/dist/lib/appInstallations.js +232 -74
  67. package/dist/lib/appSettings.d.ts +2 -0
  68. package/dist/lib/appSettings.js +36 -3
  69. package/dist/lib/apps-command.d.ts +9 -0
  70. package/dist/lib/apps-command.js +191 -7
  71. package/dist/lib/appsCheck.js +40 -3
  72. package/dist/lib/appsFs.d.ts +1 -1
  73. package/dist/lib/chat-supervision.d.ts +21 -0
  74. package/dist/lib/chat-supervision.js +37 -0
  75. package/dist/lib/duties.d.ts +4 -0
  76. package/dist/lib/json-output.d.ts +4 -0
  77. package/dist/lib/json-output.js +38 -0
  78. package/dist/lib/miniComputer.d.ts +1 -0
  79. package/dist/lib/miniComputer.js +16 -4
  80. package/dist/lib/miniComputerCommand.js +4 -1
  81. package/dist/lib/node-adapter.js +35 -2
  82. package/dist/lib/outbox.d.ts +20 -5
  83. package/dist/lib/outbox.js +233 -76
  84. package/dist/lib/rate-limit-retry.d.ts +3 -2
  85. package/dist/lib/rate-limit-retry.js +3 -2
  86. package/dist/lib/roles.d.ts +1 -1
  87. package/dist/lib/triggers.d.ts +3 -0
  88. package/dist/lib/triggers.js +10 -0
  89. package/dist/lib/widgetCheck.js +30 -4
  90. package/dist/lib/widgetStaticScan.d.ts +17 -6
  91. package/dist/lib/widgetStaticScan.js +336 -94
  92. package/dist/node_modules/@skrr-ai/data-provider/APP_HTML_PARSER_LICENSES.txt +36 -0
  93. package/dist/node_modules/@skrr-ai/data-provider/index.js +15543 -10133
  94. package/oclif.manifest.json +334 -47
  95. package/package.json +5 -3
@@ -9,6 +9,8 @@ import { BaseCommand } from '../base-command';
9
9
  * know (forbidden, not found, the server being down) are the base command's to say.
10
10
  */
11
11
  export declare abstract class AppsCommand extends BaseCommand {
12
+ /** A successful response was already received; do not turn a synchronous output failure into a request failure. */
13
+ protected failConfirmedDataOutput(): never;
12
14
  /** The id of the app the person named (an id or a slug). */
13
15
  protected appId(ref: string): Promise<string>;
14
16
  /**
@@ -31,6 +33,13 @@ export declare abstract class AppsCommand extends BaseCommand {
31
33
  collection: string;
32
34
  id?: string;
33
35
  verb?: 'put' | 'patch' | 'delete' | 'batch';
36
+ operation?: 'query';
37
+ requestStarted?: boolean;
38
+ batchHasGeneratedIds?: boolean;
39
+ batchTargets?: Array<{
40
+ collection?: unknown;
41
+ id?: unknown;
42
+ }>;
34
43
  }): never;
35
44
  /**
36
45
  * Say what went wrong with a REPORT: the refusals only a report makes (a reason the Store does not take, a
@@ -17,6 +17,18 @@ const appData_1 = require("./appData");
17
17
  * know (forbidden, not found, the server being down) are the base command's to say.
18
18
  */
19
19
  class AppsCommand extends base_command_1.BaseCommand {
20
+ /** A successful response was already received; do not turn a synchronous output failure into a request failure. */
21
+ failConfirmedDataOutput() {
22
+ try {
23
+ process.stderr.write('The server returned a success response, but the CLI could not finish printing it. Do not resend blindly; inspect the current data before taking further action.\n');
24
+ }
25
+ catch {
26
+ // stderr may be unavailable too; the exit status still reports failure.
27
+ }
28
+ // Output may already contain a partial JSON success. Do not append another JSON error or expose
29
+ // an arbitrary output exception. BaseCommand drains pending stdio before handling this exit.
30
+ return this.exit(1);
31
+ }
20
32
  /** The id of the app the person named (an id or a slug). */
21
33
  async appId(ref) {
22
34
  try {
@@ -43,7 +55,7 @@ class AppsCommand extends base_command_1.BaseCommand {
43
55
  failInstallation(error, { subject } = {}) {
44
56
  const refusal = (0, apps_1.readAppsRefusal)(error);
45
57
  if (refusal && (0, data_provider_1.isAppInstallationConflict)(refusal.error)) {
46
- const words = (0, appInstallations_1.describeInstallationConflict)(refusal, this.config.bin);
58
+ const words = (0, appInstallations_1.describeInstallationConflict)(refusal, this.config.bin, subject);
47
59
  if (words !== null) {
48
60
  return this.failWithCliError({
49
61
  message: words,
@@ -71,6 +83,11 @@ class AppsCommand extends base_command_1.BaseCommand {
71
83
  * the channel does not say (the server being down, a sign-in that expired) is the base command's. Never returns.
72
84
  */
73
85
  failPersonData(error, target) {
86
+ if (error instanceof Error &&
87
+ ((0, base_command_1.isOclifExitError)(error) ||
88
+ typeof error.oclif?.exit === 'number')) {
89
+ throw error;
90
+ }
74
91
  if (error instanceof appData_1.AppDataInputError) {
75
92
  return this.failWithCliError({
76
93
  message: error.message,
@@ -82,9 +99,150 @@ class AppsCommand extends base_command_1.BaseCommand {
82
99
  if (error instanceof appsFs_1.AppsFsError) {
83
100
  return this.failApps(error);
84
101
  }
85
- const failure = (0, appData_1.readPersonDataFailure)(error);
86
- if (failure === null) {
87
- return this.failApps(error);
102
+ // A redirect or a write's 401 is not a confirmed app-data refusal, even
103
+ // if an intermediary supplies a body that happens to resemble one.
104
+ const responseStatus = error?.status;
105
+ const responseCode = error?.code;
106
+ const parsedFailure = (0, appData_1.readPersonDataFailure)(error);
107
+ const paused = parsedFailure?.kind === 'refusal' &&
108
+ parsedFailure.code === 'unavailable' &&
109
+ parsedFailure.reason === 'installation_suspended';
110
+ const confirmedPause = paused && (responseStatus === 403 || responseStatus === 503);
111
+ const knownForbidden = parsedFailure?.kind === 'refusal' &&
112
+ ['human_only', 'not_granted', 'forbidden_by_viewer'].includes(parsedFailure.code);
113
+ // The route's per-operation limit refuses before any write runs, so a 429 carrying the contract's
114
+ // `rate` body is a definite "not applied". Any other 429 proves nothing and stays unknown.
115
+ const confirmedRate = parsedFailure?.kind === 'refusal' && parsedFailure.code === 'rate' && responseStatus === 429;
116
+ const sentWrite = Boolean(target.verb) && target.requestStarted;
117
+ // An unrecognized body or a recognizable body with a different HTTP status is not a confirmed app-data response.
118
+ // Both sides use the shared contract. A conflict is an answer, not a refusal, and uses 409.
119
+ const expectedStatus = parsedFailure?.kind === 'conflict'
120
+ ? 409
121
+ : parsedFailure?.kind === 'refusal'
122
+ ? data_provider_1.APP_PERSON_DATA_REFUSAL_STATUS[parsedFailure.code]
123
+ : undefined;
124
+ const mismatchedFailure = sentWrite &&
125
+ typeof responseStatus === 'number' &&
126
+ responseStatus >= 400 &&
127
+ responseStatus <= 599 &&
128
+ !confirmedPause &&
129
+ expectedStatus !== responseStatus;
130
+ // A batch conflict identifies one submitted operation. An absent or out-of-range index cannot
131
+ // establish which request the response describes, so do not claim that nothing was written.
132
+ const invalidBatchConflict = sentWrite &&
133
+ target.verb === 'batch' &&
134
+ parsedFailure?.kind === 'conflict' &&
135
+ (!Array.isArray(target.batchTargets) ||
136
+ !Number.isSafeInteger(parsedFailure.index) ||
137
+ parsedFailure.index < 0 ||
138
+ parsedFailure.index >= target.batchTargets.length);
139
+ const unconfirmedResponse = invalidBatchConflict ||
140
+ (sentWrite && (responseStatus === undefined || responseStatus === 0)) ||
141
+ (typeof responseStatus === 'number' &&
142
+ ((responseStatus >= 300 && responseStatus <= 399) ||
143
+ mismatchedFailure ||
144
+ (sentWrite &&
145
+ (responseStatus === 401 ||
146
+ responseStatus === 408 ||
147
+ responseStatus === 425 ||
148
+ (responseStatus === 429 && !confirmedRate) ||
149
+ (!confirmedPause &&
150
+ ((responseStatus >= 500 && responseStatus <= 599) ||
151
+ (responseStatus === 403 && !knownForbidden))))) ||
152
+ (responseStatus >= 200 &&
153
+ responseStatus <= 299 &&
154
+ responseCode === 'NON_JSON_RESPONSE')));
155
+ const failure = unconfirmedResponse ? null : parsedFailure;
156
+ if (failure === null ||
157
+ (failure.kind === 'refusal' && (failure.code === 'unavailable' || failure.code === 'rate'))) {
158
+ const e = error;
159
+ const status = typeof e?.status === 'number' ? e.status : undefined;
160
+ const code = typeof e?.code === 'string' ? e.code : '';
161
+ const message = typeof e?.message === 'string' ? e.message : '';
162
+ let body;
163
+ try {
164
+ const parsed = typeof e?.body === 'string' ? JSON.parse(e.body) : undefined;
165
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
166
+ body = parsed;
167
+ }
168
+ catch {
169
+ /* Non-JSON responses have no structured diagnostic. */
170
+ }
171
+ const safe = (value) => typeof value === 'string' && /^[A-Za-z0-9._:-]{1,128}$/.test(value) ? value : undefined;
172
+ const requestId = safe(e?.requestId) ?? safe(body?.requestId);
173
+ if (target.verb &&
174
+ target.requestStarted &&
175
+ failure?.kind === 'refusal' &&
176
+ failure.code === 'unavailable' &&
177
+ failure.reason === 'installation_suspended') {
178
+ return this.failWithCliError({
179
+ code: appData_1.PERSON_DATA_REFUSAL_CODES.unavailable,
180
+ message: (0, appData_1.describePersonDataRefusal)(failure, this.config.bin),
181
+ ...(status === undefined ? {} : { status }),
182
+ ...(requestId ? { requestId } : {}),
183
+ exit: 1,
184
+ retryable: false,
185
+ details: {
186
+ reason: failure.reason,
187
+ retryability: 'after_state_change',
188
+ outcome: 'not_applied',
189
+ },
190
+ });
191
+ }
192
+ const uncertain = unconfirmedResponse ||
193
+ status === 0 ||
194
+ status === 401 ||
195
+ status === 408 ||
196
+ status === 425 ||
197
+ (status === 429 && !confirmedRate) ||
198
+ (status !== undefined && status >= 300 && status <= 399) ||
199
+ (status === 403 &&
200
+ (failure === null ||
201
+ (failure.kind === 'refusal' &&
202
+ (failure.code === 'rate' || failure.code === 'unavailable')))) ||
203
+ (status !== undefined && status >= 500 && status <= 599) ||
204
+ code === 'APP_DATA_UNCONFIRMED_RESPONSE' ||
205
+ code === 'NON_JSON_RESPONSE' ||
206
+ e?.name === 'SyntaxError' ||
207
+ (status === undefined &&
208
+ (e?.name === 'AbortError' ||
209
+ /^(ECONN|EPIPE|ETIMEDOUT|UND_ERR_)/.test(code) ||
210
+ /fetch failed|network error/i.test(message)));
211
+ if (target.verb && target.requestStarted && uncertain) {
212
+ const originalCode = safe(code) ?? safe(body?.code);
213
+ const retryAfterMs = parsedFailure?.kind === 'refusal' &&
214
+ parsedFailure.retryAfterMs !== undefined &&
215
+ Number.isFinite(parsedFailure.retryAfterMs) &&
216
+ parsedFailure.retryAfterMs >= 0
217
+ ? parsedFailure.retryAfterMs
218
+ : typeof e?.retryAfterMs === 'number' &&
219
+ Number.isFinite(e.retryAfterMs) &&
220
+ e.retryAfterMs >= 0
221
+ ? e.retryAfterMs
222
+ : undefined;
223
+ return this.failWithCliError({
224
+ code: 'APP_DATA_WRITE_OUTCOME_UNKNOWN',
225
+ message: (target.verb === 'batch' && target.batchHasGeneratedIds
226
+ ? 'The batch may have reached the server, but its outcome is unknown. One or more puts had no ID; if applied, their server-generated IDs may be impossible to identify from this response. Matching document content alone does not prove which write happened. Do not resend blindly; reconcile the batch and any concurrent changes before deciding what to do.'
227
+ : 'The write may have reached the server, but its outcome is unknown. Read the affected data and revisions before deciding what to do; for a batch, check each affected document. Reconcile concurrent changes before writing again.') +
228
+ (status === 401 ? ' A 401 response was received; check your sign-in separately.' : ''),
229
+ ...(status === undefined || status === 0 ? {} : { status }),
230
+ ...(requestId ? { requestId } : {}),
231
+ exit: 5,
232
+ retryable: false,
233
+ details: {
234
+ outcome: 'unknown',
235
+ operation: target.verb,
236
+ ...(target.verb === 'batch' && target.batchHasGeneratedIds
237
+ ? { generatedIdsMayBeUnknown: true }
238
+ : {}),
239
+ ...(retryAfterMs === undefined ? {} : { retryAfterMs }),
240
+ ...(originalCode ? { originalCode } : {}),
241
+ },
242
+ });
243
+ }
244
+ if (failure === null)
245
+ return this.failApps(error);
88
246
  }
89
247
  if (failure.kind === 'conflict') {
90
248
  return this.failWithCliError({
@@ -96,18 +254,44 @@ class AppsCommand extends base_command_1.BaseCommand {
96
254
  details: {
97
255
  conflict: failure.conflict,
98
256
  ...(failure.currentRev === undefined ? {} : { currentRev: failure.currentRev }),
257
+ ...(target.verb === 'batch' && failure.index !== undefined
258
+ ? { index: failure.index }
259
+ : {}),
99
260
  },
100
261
  });
101
262
  }
102
263
  return this.failWithCliError({
103
- message: (0, appData_1.describePersonDataRefusal)(failure, this.config.bin),
264
+ message: (0, appData_1.describePersonDataRefusal)(failure, this.config.bin, target.operation),
104
265
  code: appData_1.PERSON_DATA_REFUSAL_CODES[failure.code],
105
266
  ...(failure.status === undefined ? {} : { status: failure.status }),
106
267
  exit: (0, appData_1.personDataFailureExit)(failure),
107
268
  retryable: (0, appData_1.personDataFailureRetryable)(failure),
108
- ...(failure.retryAfterMs === undefined
269
+ ...(failure.retryAfterMs === undefined &&
270
+ failure.index === undefined &&
271
+ failure.code !== 'unavailable' &&
272
+ !(target.operation === 'query' &&
273
+ typeof data_provider_1.APP_STORE_CURSOR_INVALID_REASON === 'string' &&
274
+ failure.reason === data_provider_1.APP_STORE_CURSOR_INVALID_REASON)
109
275
  ? {}
110
- : { details: { retryAfterMs: failure.retryAfterMs } }),
276
+ : {
277
+ details: {
278
+ ...(failure.retryAfterMs === undefined ? {} : { retryAfterMs: failure.retryAfterMs }),
279
+ ...(failure.index === undefined ? {} : { index: failure.index }),
280
+ ...(target.operation === 'query' &&
281
+ typeof data_provider_1.APP_STORE_CURSOR_INVALID_REASON === 'string' &&
282
+ failure.reason === data_provider_1.APP_STORE_CURSOR_INVALID_REASON
283
+ ? { reason: data_provider_1.APP_STORE_CURSOR_INVALID_REASON }
284
+ : {}),
285
+ ...(failure.code !== 'unavailable'
286
+ ? {}
287
+ : {
288
+ retryability: failure.reason === 'installation_suspended'
289
+ ? 'after_state_change'
290
+ : 'unknown',
291
+ ...(failure.reason ? { reason: failure.reason } : {}),
292
+ }),
293
+ },
294
+ }),
111
295
  });
112
296
  }
113
297
  /**
@@ -71,8 +71,8 @@ function compileScript(source) {
71
71
  };
72
72
  }
73
73
  }
74
- function scanSandbox(sections) {
75
- const scan = (0, widgetStaticScan_1.scanWidgetSource)(sections);
74
+ function scanSandbox(sections, options) {
75
+ const scan = (0, widgetStaticScan_1.scanWidgetSource)(sections, options);
76
76
  return {
77
77
  findings: scan.findings.map((found) => ({
78
78
  severity: found.severity,
@@ -83,6 +83,8 @@ function scanSandbox(sections) {
83
83
  ...(found.fix ? { fix: found.fix } : {}),
84
84
  })),
85
85
  inlineScripts: scan.inlineScripts,
86
+ inlineModules: scan.inlineModules,
87
+ inlineCoverageComplete: scan.inlineCoverageComplete,
86
88
  };
87
89
  }
88
90
  /** Check a package that is already in memory. */
@@ -91,6 +93,7 @@ function checkLocalFiles(files, options = {}) {
91
93
  ...(options.expectedId === undefined ? {} : { expectedId: options.expectedId }),
92
94
  ...(options.assetBytes === undefined ? {} : { assetBytes: options.assetBytes }),
93
95
  checkScriptSyntax: compileScript,
96
+ checkModuleSyntax: widgetStaticScan_1.checkModuleSyntax,
94
97
  scanSandbox,
95
98
  });
96
99
  }
@@ -120,6 +123,22 @@ function placeOf(issue) {
120
123
  return '';
121
124
  return issue.line ? `${issue.path}:${issue.line}` : issue.path;
122
125
  }
126
+ // Only collapse warnings with the same meaning and file. Lines remain distinct
127
+ // in the full JSON report; errors are always shown individually.
128
+ function warningDisplayKey(issue) {
129
+ return JSON.stringify([
130
+ issue.source,
131
+ issue.code,
132
+ issue.path,
133
+ issue.at,
134
+ issue.message,
135
+ issue.fix,
136
+ issue.heuristic,
137
+ issue.tier,
138
+ issue.unanalyzable,
139
+ issue.evidence,
140
+ ]);
141
+ }
123
142
  /** The report as lines for a terminal: the verdict, then each finding with where it is and what to do. */
124
143
  function formatAppCheckReport(report) {
125
144
  const lines = [];
@@ -150,7 +169,22 @@ function formatAppCheckReport(report) {
150
169
  }
151
170
  }
152
171
  const explained = {};
172
+ const warningCounts = new Map();
173
+ const warningsShown = new Map();
174
+ for (const issue of report.issues) {
175
+ if (issue.severity !== 'warn')
176
+ continue;
177
+ const key = warningDisplayKey(issue);
178
+ warningCounts.set(key, (warningCounts.get(key) ?? 0) + 1);
179
+ }
153
180
  for (const issue of report.issues) {
181
+ const key = issue.severity === 'warn' ? warningDisplayKey(issue) : undefined;
182
+ const count = key === undefined ? 0 : (warningCounts.get(key) ?? 0);
183
+ const shown = key === undefined ? 0 : (warningsShown.get(key) ?? 0);
184
+ if (count > 5 && shown >= 3)
185
+ continue;
186
+ if (key !== undefined)
187
+ warningsShown.set(key, shown + 1);
154
188
  const place = placeOf(issue);
155
189
  const tag = issue.tier ? ` [${TIER_TAG[issue.tier]}]` : '';
156
190
  lines.push(`${issue.severity === 'error' ? 'error' : 'warn '} ${issue.code}${place ? ` ${place}` : ''}${issue.at ? ` (${issue.at})` : ''}${issue.heuristic ? ' [heuristic]' : ''}${tag}`);
@@ -164,11 +198,14 @@ function formatAppCheckReport(report) {
164
198
  }
165
199
  if (issue.fix)
166
200
  lines.push(` fix: ${issue.fix}`);
201
+ if (count > 5 && shown === 2) {
202
+ lines.push(` ${count - 3} more matching warning${count - 3 === 1 ? '' : 's'}. Run with --json to see every occurrence.`);
203
+ }
167
204
  }
168
205
  if (security) {
169
206
  lines.push('', security.limitations.headline);
170
207
  for (const point of security.limitations.points)
171
- lines.push(` - ${point}`);
208
+ lines.push(` - ${(0, data_provider_1.clarifyAppCheckLimitation)(point)}`);
172
209
  }
173
210
  lines.push('', report.heuristic);
174
211
  return lines;
@@ -1,6 +1,6 @@
1
1
  import type { AppDraftFile, AppPathProblem } from '@skrr-ai/data-provider';
2
2
  /** Why a read or a write of a package was refused. */
3
- export type AppsFsErrorCode = 'symlink' | 'not_regular' | 'too_large' | 'too_many' | 'not_text' | 'bad_path' | 'outside_root' | 'exists' | 'not_directory' | 'unreadable';
3
+ export type AppsFsErrorCode = 'symlink' | 'not_regular' | 'too_large' | 'too_many' | 'not_text' | 'invalid_asset' | 'bad_path' | 'outside_root' | 'exists' | 'not_directory' | 'unreadable';
4
4
  export declare class AppsFsError extends Error {
5
5
  readonly code: AppsFsErrorCode;
6
6
  /** The path (relative to the package, or as typed) the refusal is about. */
@@ -0,0 +1,21 @@
1
+ import { CHAT_RECHECK_CONDITIONS } from '@skrr-ai/data-provider';
2
+ import type { ChatRecheckCondition, ChatRecheckProposal, ChatSupervisionControl } from '@skrr-ai/data-provider';
3
+ export declare const chatSupervisionPath: (agentId: string, suffix?: string) => string;
4
+ export declare const chatRecheckPath: (agentId: string, watchId: string) => string;
5
+ /** All authority and current revisions are checked server-side. No CLI cache,
6
+ * ambient workspace, runtime header or response text is an execution grant. */
7
+ export declare function requestChatRecheck(agentId: string, watchId: string, input: ChatRecheckProposal): Promise<unknown>;
8
+ export declare function cancelChatRecheck(agentId: string, watchId: string, input: {
9
+ expectedPlanRevision: number;
10
+ expectedRecheckId: string;
11
+ }): Promise<unknown>;
12
+ export { CHAT_RECHECK_CONDITIONS };
13
+ export type { ChatRecheckCondition };
14
+ /** These are owner controls. Authenticated runtime actors remain subject to
15
+ * the API's owner provenance gate; this transport supplies no impersonation. */
16
+ export declare function setChatSupervision(agentId: string, input: ChatSupervisionControl): Promise<unknown>;
17
+ export declare function setChatSupervisionEnrollment(agentId: string, watchId: string, input: {
18
+ enrollment: 'active' | 'excluded';
19
+ expectedPlanRevision: number;
20
+ }): Promise<unknown>;
21
+ export declare function requestChatInspection(agentId: string): Promise<unknown>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CHAT_RECHECK_CONDITIONS = exports.chatRecheckPath = exports.chatSupervisionPath = void 0;
4
+ exports.requestChatRecheck = requestChatRecheck;
5
+ exports.cancelChatRecheck = cancelChatRecheck;
6
+ exports.setChatSupervision = setChatSupervision;
7
+ exports.setChatSupervisionEnrollment = setChatSupervisionEnrollment;
8
+ exports.requestChatInspection = requestChatInspection;
9
+ const data_provider_1 = require("@skrr-ai/data-provider");
10
+ Object.defineProperty(exports, "CHAT_RECHECK_CONDITIONS", { enumerable: true, get: function () { return data_provider_1.CHAT_RECHECK_CONDITIONS; } });
11
+ const api_fetch_1 = require("./api-fetch");
12
+ const chatSupervisionPath = (agentId, suffix = '') => `/api/agents/${encodeURIComponent(agentId)}/dm/supervision${suffix}`;
13
+ exports.chatSupervisionPath = chatSupervisionPath;
14
+ const chatRecheckPath = (agentId, watchId) => (0, exports.chatSupervisionPath)(agentId, `/chats/${encodeURIComponent(watchId)}/recheck`);
15
+ exports.chatRecheckPath = chatRecheckPath;
16
+ /** All authority and current revisions are checked server-side. No CLI cache,
17
+ * ambient workspace, runtime header or response text is an execution grant. */
18
+ function requestChatRecheck(agentId, watchId, input) {
19
+ return (0, api_fetch_1.apiFetch)((0, exports.chatRecheckPath)(agentId, watchId), { method: 'POST', body: input });
20
+ }
21
+ function cancelChatRecheck(agentId, watchId, input) {
22
+ return (0, api_fetch_1.apiFetch)((0, exports.chatRecheckPath)(agentId, watchId), { method: 'DELETE', body: input });
23
+ }
24
+ /** These are owner controls. Authenticated runtime actors remain subject to
25
+ * the API's owner provenance gate; this transport supplies no impersonation. */
26
+ function setChatSupervision(agentId, input) {
27
+ return (0, api_fetch_1.apiFetch)((0, exports.chatSupervisionPath)(agentId), { method: 'PUT', body: input });
28
+ }
29
+ function setChatSupervisionEnrollment(agentId, watchId, input) {
30
+ return (0, api_fetch_1.apiFetch)((0, exports.chatSupervisionPath)(agentId, `/chats/${encodeURIComponent(watchId)}`), {
31
+ method: 'PUT',
32
+ body: input,
33
+ });
34
+ }
35
+ function requestChatInspection(agentId) {
36
+ return (0, api_fetch_1.apiFetch)((0, exports.chatSupervisionPath)(agentId, '/inspect'), { method: 'POST', body: {} });
37
+ }
@@ -520,6 +520,10 @@ export declare const dutyApi: {
520
520
  }) => Promise<DutyListPage>;
521
521
  cadenceDecisions: (id: string, limit?: number) => Promise<{
522
522
  data: unknown[];
523
+ sourcePolicy?: {
524
+ status?: string;
525
+ reason?: string;
526
+ };
523
527
  }>;
524
528
  /**
525
529
  * What the NEXT check would decide, computed without taking it.
@@ -17,11 +17,15 @@
17
17
  * identifier would turn a cosmetic cleanup into data loss.
18
18
  */
19
19
  type Json = unknown;
20
+ /** Escape terminal controls in serialized JSON without changing its parsed value. */
21
+ export declare function escapeJsonForTerminal(text: string): string;
20
22
  /**
21
23
  * Returns the SAME reference when nothing needed stripping, so a caller can tell
22
24
  * "unchanged" apart from "rebuilt" and leave the original text alone.
23
25
  */
24
26
  export declare function stripStorageFields(value: Json): Json;
27
+ /** Strip query envelope metadata without interpreting app-owned `docs[].data` as platform metadata. */
28
+ export declare function stripAppDataQueryMetadata(value: Json): Json;
25
29
  /**
26
30
  * Apply {@link stripStorageFields} to one line of CLI output. Anything that is
27
31
  * not a JSON object/array (prose, a bare string, malformed text) is returned
@@ -18,10 +18,28 @@
18
18
  * identifier would turn a cosmetic cleanup into data loss.
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.escapeJsonForTerminal = escapeJsonForTerminal;
21
22
  exports.stripStorageFields = stripStorageFields;
23
+ exports.stripAppDataQueryMetadata = stripAppDataQueryMetadata;
22
24
  exports.stripStorageFieldsFromText = stripStorageFieldsFromText;
23
25
  exports.withOk = withOk;
24
26
  exports.withCliOperation = withCliOperation;
27
+ const JSON_TERMINAL_CONTROLS = /[\u007f-\u009f\u00ad\u034f\u061c\u115f\u1160\u17b4\u17b5\u180b-\u180e\u200b-\u200f\u2028-\u202e\u2060-\u206f\u2800\u3164\ufe00-\ufe0f\ufeff\uffa0\ufff9-\ufffb\u{1d173}-\u{1d17a}\u{e0000}-\u{e03ff}]/gu;
28
+ /** Escape terminal controls in serialized JSON without changing its parsed value. */
29
+ function escapeJsonForTerminal(text) {
30
+ const head = text.trimStart()[0];
31
+ if ((head !== '{' && head !== '[' && head !== '"') || text.search(JSON_TERMINAL_CONTROLS) === -1)
32
+ return text;
33
+ // Prose printed by a command in JSON mode is not necessarily a JSON document.
34
+ try {
35
+ JSON.parse(text);
36
+ }
37
+ catch {
38
+ return text;
39
+ }
40
+ // Do not escape C0: a serialized JSON string has already escaped it, while indentation uses newlines.
41
+ return text.replace(JSON_TERMINAL_CONTROLS, (char) => Array.from({ length: char.length }, (_, index) => `\\u${char.charCodeAt(index).toString(16).padStart(4, '0')}`).join(''));
42
+ }
25
43
  function usableId(value) {
26
44
  return (typeof value === 'string' && value.length > 0) || typeof value === 'number';
27
45
  }
@@ -57,6 +75,26 @@ function stripStorageFields(value) {
57
75
  }
58
76
  return changed ? next : value;
59
77
  }
78
+ /** Strip query envelope metadata without interpreting app-owned `docs[].data` as platform metadata. */
79
+ function stripAppDataQueryMetadata(value) {
80
+ if (!value || typeof value !== 'object' || Array.isArray(value))
81
+ return stripStorageFields(value);
82
+ const source = value;
83
+ if (!Array.isArray(source.docs))
84
+ return stripStorageFields(value);
85
+ const { docs, ...envelope } = source;
86
+ const cleanedEnvelope = stripStorageFields(envelope);
87
+ const cleanedDocs = docs.map((doc) => {
88
+ if (!doc || typeof doc !== 'object' || Array.isArray(doc))
89
+ return stripStorageFields(doc);
90
+ const row = doc;
91
+ if (!Object.prototype.hasOwnProperty.call(row, 'data'))
92
+ return stripStorageFields(row);
93
+ const { data, ...metadata } = row;
94
+ return { ...stripStorageFields(metadata), data };
95
+ });
96
+ return { ...cleanedEnvelope, docs: cleanedDocs };
97
+ }
60
98
  /**
61
99
  * Apply {@link stripStorageFields} to one line of CLI output. Anything that is
62
100
  * not a JSON object/array (prose, a bare string, malformed text) is returned
@@ -51,6 +51,7 @@ export declare const TASKS_VIEW_DATE_FIELDS: readonly import("@skrr-ai/data-prov
51
51
  export declare const TASKS_VIEW_DATE_PRESETS: readonly import("@skrr-ai/data-provider").DateFilterPreset[];
52
52
  /** One app's slot, in lines. */
53
53
  export declare function formatMiniAppConfig(raw: unknown): string[];
54
+ export declare const MINI_COMPUTER_REVIEW_GUIDANCE = "Review: sign in as the same person in a first-party app, open the Agent page with edit access, and go to Mini Computer Home. Suggestions appear one at a time; CLI credentials cannot decide them. Choose Apply or Dismiss on the suggestion.";
54
55
  /** The layout a person sees, in lines: the dock, the home grid, the folders, what is hidden, and what waits. */
55
56
  export declare function formatMiniComputerLayout(raw: unknown): string[];
56
57
  /** What a change answered, in lines for the Agent that asked. */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TASKS_VIEW_DATE_PRESETS = exports.TASKS_VIEW_DATE_FIELDS = exports.MINI_COMPUTER_REFUSAL_CODES = void 0;
3
+ exports.MINI_COMPUTER_REVIEW_GUIDANCE = exports.TASKS_VIEW_DATE_PRESETS = exports.TASKS_VIEW_DATE_FIELDS = exports.MINI_COMPUTER_REFUSAL_CODES = void 0;
4
4
  exports.readMiniComputerRefusal = readMiniComputerRefusal;
5
5
  exports.describeMiniComputerRefusal = describeMiniComputerRefusal;
6
6
  exports.tasksConfigFromFlags = tasksConfigFromFlags;
@@ -70,6 +70,12 @@ const REFUSAL_WORDS = {
70
70
  exit: 1,
71
71
  retryable: false,
72
72
  }),
73
+ revision_exhausted: () => ({
74
+ message: 'This app configuration has reached its revision limit. Nothing was changed; contact support.',
75
+ code: 'MINI_COMPUTER_REVISION_EXHAUSTED',
76
+ exit: 1,
77
+ retryable: false,
78
+ }),
73
79
  busy: () => ({
74
80
  message: 'Other changes kept landing at the same moment. Nothing was lost; run the command again.',
75
81
  code: 'MINI_COMPUTER_BUSY',
@@ -165,8 +171,9 @@ function formatMiniAppConfig(raw) {
165
171
  const entry = (0, data_provider_1.parseMiniAppConfigEntry)(raw);
166
172
  if (entry === null)
167
173
  return ['This configuration is not in a form this version of the CLI understands.'];
168
- if (entry.config === null)
169
- return [`${entry.appId}: default (nothing set)`];
174
+ if (entry.config === null) {
175
+ return [`${entry.appId}: default (nothing set), revision ${entry.rev}`];
176
+ }
170
177
  const view = entry.config.view;
171
178
  const lines = [
172
179
  `${entry.appId}: revision ${entry.rev}${entry.via ? `, set by ${entry.via}` : ''}`,
@@ -177,6 +184,9 @@ function formatMiniAppConfig(raw) {
177
184
  lines.push(` ${JSON.stringify(entry.config)}`);
178
185
  return lines;
179
186
  }
187
+ /** Review requires the person's first-party session, never a CLI approval. */
188
+ const MINI_COMPUTER_REVIEW_LOCATION = 'Review: sign in as the same person in a first-party app, open the Agent page with edit access, and go to Mini Computer Home. Suggestions appear one at a time; CLI credentials cannot decide them.';
189
+ exports.MINI_COMPUTER_REVIEW_GUIDANCE = `${MINI_COMPUTER_REVIEW_LOCATION} Choose Apply or Dismiss on the suggestion.`;
180
190
  /** The layout a person sees, in lines: the dock, the home grid, the folders, what is hidden, and what waits. */
181
191
  function formatMiniComputerLayout(raw) {
182
192
  const read = (0, data_provider_1.parseMiniComputerLayoutRead)(raw);
@@ -201,6 +211,8 @@ function formatMiniComputerLayout(raw) {
201
211
  for (const proposal of read.proposals) {
202
212
  lines.push(`Waiting for the person: ${proposal.summary.join('; ')}`);
203
213
  }
214
+ if (read.proposals.length > 0)
215
+ lines.push(exports.MINI_COMPUTER_REVIEW_GUIDANCE);
204
216
  const latest = read.changes[0];
205
217
  if (latest)
206
218
  lines.push(`Latest change: ${latest.summary.join('; ')}${latest.undoable ? ' (can be undone)' : ''}`);
@@ -212,7 +224,7 @@ function formatLayoutChangeResult(result) {
212
224
  ? result.summary.map((line) => ` ${line}`)
213
225
  : [' (no change: it already looks like that)'];
214
226
  const heading = { applied: 'Applied', proposed: 'Proposed', noop: 'Unchanged' }[result.outcome];
215
- return [`${heading}:`, ...lines, result.note];
227
+ return [`${heading}:`, ...lines, result.note, ...(result.outcome === 'proposed' ? [MINI_COMPUTER_REVIEW_LOCATION] : [])];
216
228
  }
217
229
  /** Operations from `--ops` or `--file` JSON text. Returns the raw array for the server to validate. */
218
230
  function parseOpsText(text) {
@@ -33,7 +33,10 @@ class MiniComputerCommand extends base_command_1.BaseCommand {
33
33
  try {
34
34
  const result = await data_provider_1.dataService.changeMiniComputerLayout(agentId, { ops });
35
35
  if (json) {
36
- this.log(this.agentJson(agentId, result));
36
+ this.log(this.agentJson(agentId, result.outcome === 'proposed'
37
+ ? { ...result, review: { surface: 'agent_mini_computer_home', interactiveSessionRequired: true,
38
+ actions: ['apply', 'dismiss'], instructions: miniComputer_1.MINI_COMPUTER_REVIEW_GUIDANCE } }
39
+ : result));
37
40
  return;
38
41
  }
39
42
  for (const line of (0, miniComputer_1.formatLayoutChangeResult)(result))