@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
@@ -5,7 +5,7 @@ const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const miniComputerCommand_1 = require("../../../lib/miniComputerCommand");
6
6
  const miniComputer_1 = require("../../../lib/miniComputer");
7
7
  class AgentsMiniComputerShow extends miniComputerCommand_1.MiniComputerCommand {
8
- static description = "Show an Agent's Mini Computer: the configuration set on each built-in app (an app with none is on its default) and the layout of the person you are signed in as, with what is waiting for them and the latest Agent change. The person chooses whether an Agent's layout change is applied or only proposed.";
8
+ static description = "Show an Agent's Mini Computer: the configuration set on each built-in app (an app with none is on its default) and the layout of the person you are signed in as, with what is waiting for them and the latest Agent change. JSON includes the stored layout and layoutSummary, the CLI's resolved built-in and stored app order (null if unreadable). The summary excludes widgets and page breaks; it may omit newly installed apps or include unavailable IDs, so it is not a complete rendered Home. The person chooses whether an Agent's layout change is applied or only proposed.";
9
9
  static examples = [
10
10
  '<%= config.bin %> agents mini-computer show <agent-id>',
11
11
  '<%= config.bin %> agents mini-computer show <agent-id> tasks',
@@ -40,7 +40,15 @@ class AgentsMiniComputerShow extends miniComputerCommand_1.MiniComputerCommand {
40
40
  data_provider_1.dataService.getMiniComputerLayout(args.agentId),
41
41
  ]);
42
42
  if (flags.json) {
43
- this.log(this.agentJson(args.agentId, { apps: apps.apps, layout }));
43
+ const read = (0, data_provider_1.parseMiniComputerLayoutRead)(layout);
44
+ const layoutSummary = read ? (0, data_provider_1.describeMiniComputerLayout)(read.layout) : null;
45
+ this.log(this.agentJson(args.agentId, {
46
+ apps: apps.apps, layout, layoutSummary,
47
+ ...(read && read.proposals.length > 0 ? {
48
+ review: { surface: 'agent_mini_computer_home', interactiveSessionRequired: true,
49
+ actions: ['apply', 'dismiss'], instructions: miniComputer_1.MINI_COMPUTER_REVIEW_GUIDANCE },
50
+ } : {}),
51
+ }));
44
52
  return;
45
53
  }
46
54
  if (apps.apps.length === 0)
@@ -56,7 +56,7 @@ class AgentsMiniComputerTasksView extends miniComputerCommand_1.MiniComputerComm
56
56
  after: core_1.Flags.string({ description: 'Window start, yyyy-mm-dd, inclusive' }),
57
57
  before: core_1.Flags.string({ description: 'Window end, yyyy-mm-dd, inclusive' }),
58
58
  'expected-rev': core_1.Flags.integer({
59
- description: 'Only write if Tasks is at this revision (0: nothing set yet)',
59
+ description: 'Only write or reset if Tasks is at this revision (0: never configured)',
60
60
  min: 0,
61
61
  }),
62
62
  };
@@ -73,7 +73,7 @@ class AgentsMiniComputerTasksView extends miniComputerCommand_1.MiniComputerComm
73
73
  }
74
74
  try {
75
75
  if (flags.reset) {
76
- const entry = await data_provider_1.dataService.resetMiniComputerAppConfig(args.agentId, 'tasks');
76
+ const entry = await data_provider_1.dataService.resetMiniComputerAppConfig(args.agentId, 'tasks', flags['expected-rev']);
77
77
  if (flags.json)
78
78
  this.log(this.agentJson(args.agentId, entry));
79
79
  else
@@ -0,0 +1,25 @@
1
+ import { BaseCommand } from '../../base-command';
2
+ export default class AgentSupervision extends BaseCommand {
3
+ static description: string;
4
+ static args: {
5
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ action: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static examples: string[];
9
+ static flags: {
10
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ watch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ cursor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'request-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ revision: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ mode: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ 'plan-revision': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ 'source-revision': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ root: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ at: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ condition: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
+ reason: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ 'recheck-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
23
+ };
24
+ run(): Promise<void>;
25
+ }
@@ -0,0 +1,129 @@
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 api_fetch_1 = require("../../lib/api-fetch");
6
+ const chat_supervision_1 = require("../../lib/chat-supervision");
7
+ class AgentSupervision extends base_command_1.BaseCommand {
8
+ static description = 'Manage this Agent’s chat follow-through, inspect current state, or schedule a condition check.';
9
+ static args = {
10
+ id: core_1.Args.string({ description: 'Agent ID', required: true, ignoreStdin: true }),
11
+ action: core_1.Args.string({
12
+ options: [
13
+ 'status',
14
+ 'preflight',
15
+ 'enable',
16
+ 'disable',
17
+ 'chats',
18
+ 'explain',
19
+ 'include',
20
+ 'exclude',
21
+ 'check-now',
22
+ 'inspect',
23
+ 'recheck',
24
+ 'cancel',
25
+ ],
26
+ default: 'status',
27
+ ignoreStdin: true,
28
+ }),
29
+ };
30
+ static examples = [
31
+ '<%= config.bin %> agents supervision <agent-id> preflight --json',
32
+ '<%= config.bin %> agents supervision <agent-id> enable --revision 0 --request-id <stable-key> --json',
33
+ '<%= config.bin %> agents supervision <agent-id> disable --revision 1 --request-id <new-stable-key> --json',
34
+ '<%= config.bin %> agents supervision <agent-id> exclude --watch <watch-id> --plan-revision 2 --json',
35
+ '<%= config.bin %> agents supervision <agent-id> explain --watch <watch-id> --json',
36
+ '<%= config.bin %> agents supervision <agent-id> check-now --json',
37
+ '<%= config.bin %> agents supervision <agent-id> chats --json',
38
+ '<%= config.bin %> agents supervision <agent-id> inspect --watch <watch-id> --json',
39
+ '<%= config.bin %> agents supervision <agent-id> recheck --watch <watch-id> --request-id <stable-key> --plan-revision 2 --source-revision <revision> --root <work-root> --at <ISO-instant> --condition progress_observed --reason "Confirm the work advanced" --json',
40
+ '<%= config.bin %> agents supervision <agent-id> cancel --watch <watch-id> --plan-revision 3 --recheck-id <check-id> --json',
41
+ ];
42
+ static flags = {
43
+ json: core_1.Flags.boolean({ description: 'Output the exact server receipt as JSON' }),
44
+ watch: core_1.Flags.string({ description: 'Exact Watch ID from chats' }),
45
+ cursor: core_1.Flags.string({ description: 'Opaque nextCursor from the previous chats page' }),
46
+ 'request-id': core_1.Flags.string({
47
+ description: 'Stable control/proposal key; reuse only to replay the same request',
48
+ }),
49
+ revision: core_1.Flags.integer({
50
+ min: 0,
51
+ description: 'Current configuration.revision from status/preflight for enable/disable',
52
+ }),
53
+ mode: core_1.Flags.string({
54
+ options: ['recover', 'shadow'],
55
+ description: 'Policy for enable/disable: recover (default) or observation-only shadow',
56
+ }),
57
+ 'plan-revision': core_1.Flags.integer({ min: 1, description: 'Current planRevision from inspect' }),
58
+ 'source-revision': core_1.Flags.string({ description: 'Current sourceRevision from inspect' }),
59
+ root: core_1.Flags.string({ description: 'Current workAnchorId from inspect' }),
60
+ at: core_1.Flags.string({ description: 'Future ISO instant with explicit timezone offset' }),
61
+ condition: core_1.Flags.string({
62
+ options: [...chat_supervision_1.CHAT_RECHECK_CONDITIONS],
63
+ description: 'Typed evidence to check',
64
+ }),
65
+ reason: core_1.Flags.string({ description: 'Why this chat needs this condition check' }),
66
+ 'recheck-id': core_1.Flags.string({ description: 'Exact current recheck.id to cancel' }),
67
+ };
68
+ async run() {
69
+ this.requireAuth();
70
+ const { args, flags } = await this.parse(AgentSupervision);
71
+ const required = (name) => {
72
+ const value = flags[name];
73
+ if (value == null || value === '')
74
+ this.error(`--${name} is required for ${args.action}. Read status/preflight or inspect for the relevant revision first.`);
75
+ return value;
76
+ };
77
+ try {
78
+ let receipt;
79
+ if (args.action === 'status')
80
+ receipt = await (0, api_fetch_1.apiFetch)((0, chat_supervision_1.chatSupervisionPath)(args.id));
81
+ else if (args.action === 'preflight')
82
+ receipt = await (0, api_fetch_1.apiFetch)((0, chat_supervision_1.chatSupervisionPath)(args.id, '/preflight'));
83
+ else if (['enable', 'disable'].includes(args.action))
84
+ receipt = await (0, chat_supervision_1.setChatSupervision)(args.id, {
85
+ enabled: args.action === 'enable',
86
+ expectedRevision: required('revision'),
87
+ controlId: required('request-id'),
88
+ mode: (flags.mode || 'recover'),
89
+ });
90
+ else if (args.action === 'check-now')
91
+ receipt = await (0, chat_supervision_1.requestChatInspection)(args.id);
92
+ else if (args.action === 'chats')
93
+ receipt = await (0, api_fetch_1.apiFetch)((0, chat_supervision_1.chatSupervisionPath)(args.id, `/chats${flags.cursor ? `?cursor=${encodeURIComponent(flags.cursor)}` : ''}`));
94
+ else {
95
+ const watch = required('watch');
96
+ if (args.action === 'explain')
97
+ receipt = await (0, api_fetch_1.apiFetch)((0, chat_supervision_1.chatSupervisionPath)(args.id, `/chats/${encodeURIComponent(watch)}`));
98
+ else if (['include', 'exclude'].includes(args.action))
99
+ receipt = await (0, chat_supervision_1.setChatSupervisionEnrollment)(args.id, watch, {
100
+ enrollment: args.action === 'include' ? 'active' : 'excluded',
101
+ expectedPlanRevision: required('plan-revision'),
102
+ });
103
+ else if (args.action === 'inspect')
104
+ receipt = await (0, api_fetch_1.apiFetch)((0, chat_supervision_1.chatRecheckPath)(args.id, watch));
105
+ else if (args.action === 'cancel')
106
+ receipt = await (0, chat_supervision_1.cancelChatRecheck)(args.id, watch, {
107
+ expectedPlanRevision: required('plan-revision'),
108
+ expectedRecheckId: required('recheck-id'),
109
+ });
110
+ else
111
+ receipt = await (0, chat_supervision_1.requestChatRecheck)(args.id, watch, {
112
+ controlId: required('request-id'),
113
+ expectedPlanRevision: required('plan-revision'),
114
+ expectedSourceRevision: required('source-revision'),
115
+ workAnchorId: required('root'),
116
+ dueAt: required('at'),
117
+ expectedCondition: required('condition'),
118
+ reason: required('reason'),
119
+ cancelWhen: 'superseded_or_stopped_or_resolved',
120
+ });
121
+ }
122
+ this.printJsonResult(receipt);
123
+ }
124
+ catch (error) {
125
+ this.handleApiError(error);
126
+ }
127
+ }
128
+ }
129
+ exports.default = AgentSupervision;
@@ -5,7 +5,7 @@ const base_command_1 = require("../../../base-command");
5
5
  const prompt_1 = require("../../../lib/prompt");
6
6
  const triggers_1 = require("../../../lib/triggers");
7
7
  class AgentsTriggersReplay extends base_command_1.BaseCommand {
8
- static description = "Replay a historical fire for one of an agent's triggers";
8
+ static description = 'Request historical trigger replay (currently refused when source identity is unverified)';
9
9
  static examples = [
10
10
  '<%= config.bin %> agents triggers replay <agent-id> <trigger-id> <fire-id>',
11
11
  '<%= config.bin %> agents triggers replay <agent-id> <trigger-id> <fire-id> --json',
@@ -1,9 +1,8 @@
1
1
  import { BaseCommand } from '../../../base-command';
2
2
  /**
3
3
  * `skrr agents triggers runs <agent-id> <trigger-id>` — the fire history for one
4
- * trigger (the Schedule Board's PastFiresStatusStrip). Pass `--fire <fireId>`
5
- * to drill into a single occurrence's full record (the TriggerFireDetailModal),
6
- * including its outcome and the conversation it produced.
4
+ * current trigger. Pass `--fire <fireId>` for one restricted summary. Neither
5
+ * the audit nor the summary proves the historical physical Agent or Trigger.
7
6
  */
8
7
  export default class AgentsTriggersRuns extends BaseCommand {
9
8
  static description: string;
@@ -5,12 +5,11 @@ const base_command_1 = require("../../../base-command");
5
5
  const triggers_1 = require("../../../lib/triggers");
6
6
  /**
7
7
  * `skrr agents triggers runs <agent-id> <trigger-id>` — the fire history for one
8
- * trigger (the Schedule Board's PastFiresStatusStrip). Pass `--fire <fireId>`
9
- * to drill into a single occurrence's full record (the TriggerFireDetailModal),
10
- * including its outcome and the conversation it produced.
8
+ * current trigger. Pass `--fire <fireId>` for one restricted summary. Neither
9
+ * the audit nor the summary proves the historical physical Agent or Trigger.
11
10
  */
12
11
  class AgentsTriggersRuns extends base_command_1.BaseCommand {
13
- static description = "Show fire history for one of an agent's triggers";
12
+ static description = "Show restricted fire summaries for one of an agent's current triggers";
14
13
  static examples = [
15
14
  '<%= config.bin %> agents triggers runs <agent-id> <trigger-id>',
16
15
  '<%= config.bin %> agents triggers runs <agent-id> <trigger-id> --limit 50',
@@ -23,7 +22,7 @@ class AgentsTriggersRuns extends base_command_1.BaseCommand {
23
22
  static flags = {
24
23
  json: core_1.Flags.boolean({ description: 'Output as JSON' }),
25
24
  fire: core_1.Flags.string({
26
- description: 'A fire id (or occurrenceId) to show in full instead of the list',
25
+ description: 'A fire id (or occurrenceId) for one restricted summary instead of the list',
27
26
  }),
28
27
  limit: core_1.Flags.integer({ description: 'Maximum rows to return', default: 20 }),
29
28
  before: core_1.Flags.string({ description: 'Pagination cursor/date for older rows' }),
@@ -4,7 +4,7 @@ const core_1 = require("@oclif/core");
4
4
  const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const apps_command_1 = require("../../lib/apps-command");
6
6
  class AppsAutoApply extends apps_command_1.AppsCommand {
7
- static description = "Let your agent's new versions of an app take effect by themselves (on), or have each one wait for you (off). It only ever applies a version that asks for nothing you have not already approved: one that adds a capability, widens who may write, changes a job or rewrites code that can reach outside waits for your approval as always. It is off until you turn it on, and only you can: an agent cannot switch it on for itself.";
7
+ static description = "Allow eligible versions to be applied automatically (on), or have each one wait for you (off). Turning it on may immediately apply an eligible version already waiting. Only versions created by the account associated with this setting or its agents are eligible; other authors' versions wait. The existing approval must cover the version. Changed capabilities, writers or jobs may require approval again; a changed bundle with external-reaching capabilities may too, even if those capabilities did not expand. Even an eligible, covered version may be held, for example while the installation is paused. Automatic updates are off until a person turns them on; an agent cannot switch them on for itself.";
8
8
  static examples = [
9
9
  '<%= config.bin %> apps auto-apply appi_abc on',
10
10
  '<%= config.bin %> apps auto-apply appi_abc off',
@@ -32,22 +32,43 @@ class AppsAutoApply extends apps_command_1.AppsCommand {
32
32
  async run() {
33
33
  this.requireAuth();
34
34
  const { args, flags } = await this.parse(AppsAutoApply);
35
+ let view;
35
36
  try {
36
- const view = await data_provider_1.dataService.setAppInstallationAutoApply(args.installation, {
37
+ view = await data_provider_1.dataService.setAppInstallationAutoApply(args.installation, {
37
38
  enabled: args.state === 'on',
38
39
  ...(flags.expected === undefined ? {} : { expectedEnabled: flags.expected === 'on' }),
39
40
  });
40
- if (flags.json) {
41
+ }
42
+ catch {
43
+ // A write or the immediate version move may have landed before a response was lost,
44
+ // or before the route's later read failed. A retry is not proof of the original outcome.
45
+ return this.failWithCliError({
46
+ message: 'The automatic-update request could not be confirmed. The setting or installed version may have changed and could still change. Check the current installation and version status before deciding what to do next.',
47
+ code: 'APP_AUTO_APPLY_UNCONFIRMED',
48
+ exit: 1,
49
+ retryable: false,
50
+ });
51
+ }
52
+ if (view?.installationId !== args.installation || typeof view?.autoApply?.enabled !== 'boolean') {
53
+ return this.failWithCliError({
54
+ message: 'The server answered, but the automatic-update status could not be confirmed for this installation. The setting or installed version may have changed and could still change. Check both before deciding what to do next.',
55
+ code: 'APP_AUTO_APPLY_UNCONFIRMED',
56
+ exit: 1,
57
+ retryable: false,
58
+ });
59
+ }
60
+ if (flags.json) {
61
+ try {
41
62
  this.printJsonResult(view);
42
- return;
43
63
  }
44
- this.log(view.autoApply.enabled
45
- ? `${view.installationId}: automatic updates are on. A new version that asks for nothing you have not approved takes effect by itself; anything else waits for you. Go back with \`${this.config.bin} apps rollback ${view.installationId}\`.`
46
- : `${view.installationId}: automatic updates are off. A new version waits for you to apply it.`);
47
- }
48
- catch (error) {
49
- this.failInstallation(error);
64
+ catch {
65
+ return this.failConfirmedDataOutput();
66
+ }
67
+ return;
50
68
  }
69
+ this.log(view.autoApply.enabled
70
+ ? 'After the request, the server reports automatic updates are on. Eligible versions covered by your approval may be applied automatically; some can be held. Check the versions view for the current status and available rollback options.'
71
+ : 'After the request, the server reports automatic updates are off. This setting will not automatically apply versions while it is off.');
51
72
  }
52
73
  }
53
74
  exports.default = AppsAutoApply;
@@ -22,6 +22,12 @@ const json_output_1 = require("../../lib/json-output");
22
22
  * default policy). A security finding is never an ERROR: drafts and private installs are not held back.
23
23
  */
24
24
  exports.APPS_CHECK_EXIT = { ok: 0, notOk: 1, unreadable: 2 };
25
+ /** Wait for queued output before oclif's exit handler calls process.exit(). */
26
+ async function flushOutput() {
27
+ await Promise.all([process.stdout, process.stderr].map((stream) => new Promise((resolve, reject) => {
28
+ stream.write('', (error) => error ? reject(error) : resolve());
29
+ })));
30
+ }
25
31
  class AppsCheck extends core_1.Command {
26
32
  static description = "Check an app's package in a local directory, offline: the manifest, the files it names, sizes, JavaScript syntax, what the frame would refuse, and the capability calls the script makes against the ones app.json declares. Needs no sign-in. A symbolic link in the directory is refused, never followed.";
27
33
  static examples = [
@@ -71,6 +77,7 @@ class AppsCheck extends core_1.Command {
71
77
  else {
72
78
  process.stderr.write(`error: ${message}\n`);
73
79
  }
80
+ await flushOutput();
74
81
  this.exit(exports.APPS_CHECK_EXIT.unreadable);
75
82
  }
76
83
  const report = (0, appsCheck_1.checkLocalFiles)(pkg.files, {
@@ -88,6 +95,7 @@ class AppsCheck extends core_1.Command {
88
95
  const warnings = report.issues.filter((i) => i.severity === 'warn' && i.tier !== 'info').length;
89
96
  const keptOut = flags.store && report.security !== undefined && !report.security.store.admitted;
90
97
  const failed = !report.ok || (flags.strict && warnings > 0) || keptOut;
98
+ await flushOutput();
91
99
  this.exit(failed ? exports.APPS_CHECK_EXIT.notOk : exports.APPS_CHECK_EXIT.ok);
92
100
  }
93
101
  }
@@ -5,7 +5,7 @@ const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const apps_command_1 = require("../../../lib/apps-command");
6
6
  const appData_1 = require("../../../lib/appData");
7
7
  class AppsDataBatch extends apps_command_1.AppsCommand {
8
- static description = 'Several writes to an installed app\'s own data that land TOGETHER or not at all, in one transaction. The writes are a JSON list (--writes, --from-file or --stdin) of { "op": "put" | "patch" | "delete", "collection": ..., ... } with the arguments each op takes on its own (put: id?, doc, expectedRev?; patch: id, set?, unset?, expectedRev?; delete: id, expectedRev?), at most 25, a document at most once. If one write cannot apply (it exists, is not there, or moved) NOTHING is written and the refusal names which write and the revision to retry from. A local coding agent names the revision on every put and delete. Every collection\'s write list must name your writer, and you need edit access on the agent the app is installed on.';
8
+ static description = 'Several writes to an installed app\'s own data that land TOGETHER or not at all, in one transaction. The writes are a JSON list (--writes, --from-file or --stdin) of { "op": "put" | "patch" | "delete", "collection": ..., ... } with the arguments each op takes on its own (put: id?, doc, expectedRev?; patch: id, set?, unset?, expectedRev?; delete: id, expectedRev?), at most 25, a document at most once. For a new document, supply an ID and expectedRev: 0 to help identify it if the response is lost. Without an ID, the server generates one that may be impossible to identify after an uncertain result. If one write cannot apply (it exists, is not there, or moved) NOTHING is written and the refusal names which write and the revision to retry from. A local coding agent names the revision on every put and delete. Every collection\'s write list must name your writer, and you need edit access on the agent the app is installed on.';
9
9
  static examples = [
10
10
  '<%= config.bin %> apps data batch appi_abc --writes \'[{"op":"put","collection":"checkins","id":"d1","doc":{"done":true},"expectedRev":0},{"op":"patch","collection":"habits","id":"h1","set":{"streak":2}}]\'',
11
11
  'cat writes.json | <%= config.bin %> apps data batch appi_abc --stdin',
@@ -33,26 +33,37 @@ class AppsDataBatch extends apps_command_1.AppsCommand {
33
33
  collection: '(batch)',
34
34
  verb: 'batch',
35
35
  };
36
+ let requestStarted = false;
37
+ let responseConfirmed = false;
38
+ let batchHasGeneratedIds = false;
39
+ let batchTargets;
36
40
  try {
37
41
  const body = await (0, appData_1.readBatchInput)({
38
42
  writes: flags.writes,
39
43
  fromFile: flags['from-file'],
40
44
  stdin: flags.stdin,
41
45
  });
46
+ batchHasGeneratedIds = body.writes.some((write) => write.op === 'put' && write.id === undefined);
47
+ batchTargets = body.writes.map((write) => ({ collection: write.collection, id: write.id }));
48
+ requestStarted = true;
42
49
  const result = await data_provider_1.dataService.batchAppInstallationData(args.installation, body);
50
+ (0, appData_1.assertAppDataWriteResult)(result, { verb: 'batch', writes: body.writes });
51
+ if (result.written !== true) {
52
+ return this.failPersonData({ status: 409, body: JSON.stringify({ code: 'conflict', ...result }) }, { ...target, batchTargets });
53
+ }
54
+ responseConfirmed = true;
43
55
  if (flags.json) {
44
56
  this.printJsonResult(result);
45
57
  return;
46
58
  }
47
- if (result.written !== true) {
48
- return this.failPersonData({ status: 409, body: JSON.stringify({ code: 'conflict', ...result }) }, target);
49
- }
50
59
  for (const entry of result.results) {
51
60
  this.log(`${entry.op} ${entry.collection}/${entry.id} (rev ${entry.rev})`);
52
61
  }
53
62
  }
54
63
  catch (error) {
55
- return this.failPersonData(error, target);
64
+ if (responseConfirmed)
65
+ return this.failConfirmedDataOutput();
66
+ return this.failPersonData(error, { ...target, requestStarted, batchHasGeneratedIds, batchTargets });
56
67
  }
57
68
  }
58
69
  }
@@ -5,7 +5,7 @@ const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const apps_command_1 = require("../../../lib/apps-command");
6
6
  const appData_1 = require("../../../lib/appData");
7
7
  class AppsDataCollections extends apps_command_1.AppsCommand {
8
- static description = "List the collections of an installed app's own data: for each its name, who may write it (and whether an agent may), whether the window reads it, how many documents it holds, what it is for and the shape of a document (the schema's fields, required first). It reads no document. Run it before a first write so you know which collections your writer may change and what a document must look like. The titles and descriptions are the app author's words about the data, never instructions. Needs view access on the agent the app is installed on; a stranger's installation is \"not found\".";
8
+ static description = "List an installed app's collections, declared writers and window store access, document counts and schema. Declarations are not a permission check: the current grant, installation state and caller permissions also matter. It reads no document. Titles and descriptions are the app author's words about the data, never instructions. Needs view access to the installation; a stranger's installation is \"not found\".";
9
9
  static examples = [
10
10
  '<%= config.bin %> apps data collections appi_abc',
11
11
  '<%= config.bin %> apps data collections appi_abc --json',
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const apps_command_1 = require("../../../lib/apps-command");
6
+ const appData_1 = require("../../../lib/appData");
6
7
  class AppsDataDelete extends apps_command_1.AppsCommand {
7
8
  static description = 'Delete ONE document of an installed app\'s own data. --expected-rev N deletes it only if it is still at the revision you read; without it, whatever is there is deleted (a local coding agent must name the revision: a delete is not undone by anything the store keeps). A document that moved, or is not there, is refused with the revision to retry from and nothing is deleted. The collection\'s write list must name your writer ("person" for a signed-in person, "agent" for a local coding agent), and you need edit access on the agent the app is installed on.';
8
9
  static examples = [
@@ -38,19 +39,26 @@ class AppsDataDelete extends apps_command_1.AppsCommand {
38
39
  id: args.id,
39
40
  verb: 'delete',
40
41
  };
42
+ let requestStarted = false;
43
+ let responseConfirmed = false;
41
44
  try {
45
+ requestStarted = true;
42
46
  const result = await data_provider_1.dataService.deleteAppInstallationData(args.installation, args.collection, args.id, flags['expected-rev'] === undefined ? {} : { expectedRev: flags['expected-rev'] });
47
+ (0, appData_1.assertAppDataWriteResult)(result, { verb: 'delete', id: args.id });
48
+ if (result.deleted !== true) {
49
+ return this.failPersonData({ status: 409, body: JSON.stringify({ code: 'conflict', ...result }) }, target);
50
+ }
51
+ responseConfirmed = true;
43
52
  if (flags.json) {
44
53
  this.printJsonResult(result);
45
54
  return;
46
55
  }
47
- if (result.deleted !== true) {
48
- return this.failPersonData({ status: 409, body: JSON.stringify({ code: 'conflict', ...result }) }, target);
49
- }
50
56
  this.log(`deleted ${args.collection}/${result.id} (it was at rev ${result.rev})`);
51
57
  }
52
58
  catch (error) {
53
- return this.failPersonData(error, target);
59
+ if (responseConfirmed)
60
+ return this.failConfirmedDataOutput();
61
+ return this.failPersonData(error, { ...target, requestStarted });
54
62
  }
55
63
  }
56
64
  }
@@ -46,24 +46,31 @@ class AppsDataPatch extends apps_command_1.AppsCommand {
46
46
  id: args.id,
47
47
  verb: 'patch',
48
48
  };
49
+ let requestStarted = false;
50
+ let responseConfirmed = false;
49
51
  try {
50
52
  const change = (0, appData_1.readPatchInput)({ set: flags.set, unset: flags.unset });
53
+ requestStarted = true;
51
54
  const result = await data_provider_1.dataService.patchAppInstallationData(args.installation, args.collection, args.id, {
52
55
  ...(change.set === undefined ? {} : { set: change.set }),
53
56
  ...(change.unset === undefined ? {} : { unset: change.unset }),
54
57
  ...(flags['expected-rev'] === undefined ? {} : { expectedRev: flags['expected-rev'] }),
55
58
  });
59
+ (0, appData_1.assertAppDataWriteResult)(result, { verb: 'patch', id: args.id });
60
+ if (result.written !== true) {
61
+ return this.failPersonData({ status: 409, body: JSON.stringify({ code: 'conflict', ...result }) }, target);
62
+ }
63
+ responseConfirmed = true;
56
64
  if (flags.json) {
57
65
  this.printJsonResult(result);
58
66
  return;
59
67
  }
60
- if (result.written !== true) {
61
- return this.failPersonData({ status: 409, body: JSON.stringify({ code: 'conflict', ...result }) }, target);
62
- }
63
68
  this.log(`patched ${args.collection}/${result.id} (rev ${result.rev})`);
64
69
  }
65
70
  catch (error) {
66
- return this.failPersonData(error, target);
71
+ if (responseConfirmed)
72
+ return this.failConfirmedDataOutput();
73
+ return this.failPersonData(error, { ...target, requestStarted });
67
74
  }
68
75
  }
69
76
  }
@@ -43,29 +43,36 @@ class AppsDataPut extends apps_command_1.AppsCommand {
43
43
  async run() {
44
44
  this.requireAuth();
45
45
  const { args, flags } = await this.parse(AppsDataPut);
46
- const target = { installation: args.installation, collection: args.collection, id: args.id };
46
+ const target = { installation: args.installation, collection: args.collection, id: args.id, verb: 'put' };
47
+ let requestStarted = false;
48
+ let responseConfirmed = false;
47
49
  try {
48
50
  const doc = await (0, appData_1.readDocumentInput)({
49
51
  doc: flags.doc,
50
52
  fromFile: flags['from-file'],
51
53
  stdin: flags.stdin,
52
54
  });
55
+ requestStarted = true;
53
56
  const result = await data_provider_1.dataService.putAppInstallationData(args.installation, args.collection, args.id, {
54
57
  doc: doc,
55
58
  ...(flags['expected-rev'] === undefined ? {} : { expectedRev: flags['expected-rev'] }),
56
59
  });
57
- if (flags.json) {
58
- this.printJsonResult(result);
59
- return;
60
- }
60
+ (0, appData_1.assertAppDataWriteResult)(result, { verb: 'put', id: args.id });
61
61
  if (result.written !== true) {
62
62
  // the route answers a conflict with a 409, which fails above; a 2xx that says "not written" is read the same way
63
63
  return this.failPersonData({ status: 409, body: JSON.stringify({ code: 'conflict', ...result }) }, target);
64
64
  }
65
+ responseConfirmed = true;
66
+ if (flags.json) {
67
+ this.printJsonResult(result);
68
+ return;
69
+ }
65
70
  this.log(`wrote ${args.collection}/${result.id} (rev ${result.rev}, ${result.created ? 'created' : 'replaced'})`);
66
71
  }
67
72
  catch (error) {
68
- return this.failPersonData(error, target);
73
+ if (responseConfirmed)
74
+ return this.failConfirmedDataOutput();
75
+ return this.failPersonData(error, { ...target, requestStarted });
69
76
  }
70
77
  }
71
78
  }
@@ -41,7 +41,7 @@ class AppsDataQuery extends apps_command_1.AppsCommand {
41
41
  max: appData_1.PERSON_DATA_QUERY_LIMIT_MAX,
42
42
  }),
43
43
  cursor: core_1.Flags.string({
44
- description: 'The cursor a previous page handed back, with the same filters',
44
+ description: 'A previous page’s cursor. Keep the same installation, collection, filters and sort: a server may not check they match. Changes between pages can skip or repeat documents. If the cursor is rejected, start again from the first page.',
45
45
  }),
46
46
  total: core_1.Flags.boolean({
47
47
  description: 'Also count the documents that match the whole query',
@@ -51,7 +51,7 @@ class AppsDataQuery extends apps_command_1.AppsCommand {
51
51
  async run() {
52
52
  this.requireAuth();
53
53
  const { args, flags } = await this.parse(AppsDataQuery);
54
- const target = { installation: args.installation, collection: args.collection };
54
+ const target = { installation: args.installation, collection: args.collection, operation: 'query' };
55
55
  try {
56
56
  if (flags.desc && flags['order-by'] === undefined) {
57
57
  throw new appData_1.AppDataInputError('APP_DATA_WHERE', '--desc needs --order-by <field>.');
@@ -73,7 +73,7 @@ class AppsDataQuery extends apps_command_1.AppsCommand {
73
73
  };
74
74
  const result = await data_provider_1.dataService.queryAppInstallationData(args.installation, args.collection, query);
75
75
  if (flags.json) {
76
- this.printJsonResult(result);
76
+ this.printJsonResult(result, { preserveAppData: true });
77
77
  return;
78
78
  }
79
79
  for (const line of (0, appData_1.formatQueryResult)(result, target, this.config.bin)) {