@skrr-ai/cli 0.1.204 → 0.1.207

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 (55) hide show
  1. package/bin/dev-fallback.js +47 -29
  2. package/bin/dev.cjs +6 -0
  3. package/dist/commands/agent/message/send.d.ts +7 -1
  4. package/dist/commands/agent/message/send.js +13 -0
  5. package/dist/commands/agents/models.d.ts +11 -0
  6. package/dist/commands/agents/models.js +51 -0
  7. package/dist/commands/balance/route-premiums.d.ts +9 -0
  8. package/dist/commands/balance/route-premiums.js +33 -0
  9. package/dist/commands/convos/transcript.d.ts +47 -0
  10. package/dist/commands/convos/transcript.js +460 -0
  11. package/dist/commands/goals/create.d.ts +1 -0
  12. package/dist/commands/goals/create.js +8 -0
  13. package/dist/commands/goals/creation-receipt.d.ts +10 -0
  14. package/dist/commands/goals/creation-receipt.js +43 -0
  15. package/dist/commands/goals/key-results/create.d.ts +2 -0
  16. package/dist/commands/goals/key-results/create.js +14 -0
  17. package/dist/commands/goals/key-results/creation-receipt.d.ts +13 -0
  18. package/dist/commands/goals/key-results/creation-receipt.js +51 -0
  19. package/dist/commands/harnesses/forget.d.ts +2 -0
  20. package/dist/commands/harnesses/forget.js +31 -0
  21. package/dist/commands/harnesses/removal-receipt.d.ts +11 -0
  22. package/dist/commands/harnesses/removal-receipt.js +32 -0
  23. package/dist/commands/harnesses/removal-review.d.ts +11 -0
  24. package/dist/commands/harnesses/removal-review.js +28 -0
  25. package/dist/commands/spaces/loops/release-receipt.d.ts +14 -0
  26. package/dist/commands/spaces/loops/release-receipt.js +48 -0
  27. package/dist/commands/spaces/loops/release.js +1 -1
  28. package/dist/commands/spaces/workflow-templates/archive.d.ts +1 -0
  29. package/dist/commands/spaces/workflow-templates/archive.js +9 -1
  30. package/dist/commands/spaces/workflow-templates/show.js +2 -0
  31. package/dist/commands/spaces/workflow-templates/update.d.ts +1 -0
  32. package/dist/commands/spaces/workflow-templates/update.js +12 -1
  33. package/dist/commands/spaces/workflows/publish.d.ts +1 -0
  34. package/dist/commands/spaces/workflows/publish.js +41 -2
  35. package/dist/commands/tasks/create.d.ts +2 -0
  36. package/dist/commands/tasks/create.js +19 -6
  37. package/dist/commands/tasks/creation-receipt.d.ts +12 -0
  38. package/dist/commands/tasks/creation-receipt.js +53 -0
  39. package/dist/commands/tasks/delete.d.ts +1 -0
  40. package/dist/commands/tasks/delete.js +22 -4
  41. package/dist/commands/tasks/deletion-receipt.d.ts +12 -0
  42. package/dist/commands/tasks/deletion-receipt.js +37 -0
  43. package/dist/lib/execution-target.d.ts +1 -1
  44. package/dist/lib/execution-target.js +4 -0
  45. package/dist/lib/harnesses.d.ts +25 -0
  46. package/dist/lib/harnesses.js +15 -0
  47. package/dist/lib/request-uuid.d.ts +2 -0
  48. package/dist/lib/request-uuid.js +10 -0
  49. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.d.ts +16 -15
  50. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.js +0 -22
  51. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.d.ts +16 -15
  52. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.js +0 -22
  53. package/dist/node_modules/@skrr-ai/data-provider/index.js +11498 -11396
  54. package/oclif.manifest.json +915 -2
  55. package/package.json +6 -3
@@ -15,6 +15,8 @@ export default class HarnessesForget extends BaseCommand {
15
15
  static flags: {
16
16
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
17
  yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
+ 'review-ref': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ 'operation-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
20
  };
19
21
  run(): Promise<void>;
20
22
  }
@@ -5,6 +5,7 @@ const base_command_1 = require("../../base-command");
5
5
  const harnesses_1 = require("../../lib/harnesses");
6
6
  const api_fetch_1 = require("../../lib/api-fetch");
7
7
  const show_1 = require("./show");
8
+ const request_uuid_1 = require("../../lib/request-uuid");
8
9
  const RUN_RE = /^[0-9a-f]{24}$/i;
9
10
  /**
10
11
  * Forget an harness — `forget`, not `delete`.
@@ -18,6 +19,7 @@ class HarnessesForget extends base_command_1.BaseCommand {
18
19
  static examples = [
19
20
  '<%= config.bin %> harnesses forget <harness-id>',
20
21
  '<%= config.bin %> harnesses forget <harness-id> --yes',
22
+ '<%= config.bin %> harnesses forget <harness-id> --review-ref <review-ref> --operation-id <uuid>',
21
23
  ];
22
24
  static args = {
23
25
  harness: core_1.Args.string({ ignoreStdin: true, description: 'Harness ID', required: true }),
@@ -25,10 +27,21 @@ class HarnessesForget extends base_command_1.BaseCommand {
25
27
  static flags = {
26
28
  json: core_1.Flags.boolean({ description: 'Output as JSON' }),
27
29
  yes: core_1.Flags.boolean({ description: 'Skip the confirmation' }),
30
+ 'review-ref': core_1.Flags.string({
31
+ description: 'Exact token from `harnesses removal-review` for a personal local registration',
32
+ dependsOn: ['operation-id'],
33
+ }),
34
+ 'operation-id': core_1.Flags.string({
35
+ description: 'Stable UUID for the reviewed removal, recoverable with `harnesses removal-receipt`',
36
+ dependsOn: ['review-ref'],
37
+ parse: request_uuid_1.parseRequestUuid,
38
+ }),
28
39
  };
29
40
  async run() {
30
41
  this.requireAuth();
31
42
  const { args, flags } = await this.parse(HarnessesForget);
43
+ const reviewRef = flags['review-ref'];
44
+ const operationId = flags['operation-id'];
32
45
  // Refuse a reference that cannot name a harness BEFORE asking anything.
33
46
  //
34
47
  // The confirmation used to run first, so `harnesses forget notanid` asked
@@ -47,6 +60,24 @@ class HarnessesForget extends base_command_1.BaseCommand {
47
60
  });
48
61
  return;
49
62
  }
63
+ if (reviewRef !== undefined || operationId !== undefined) {
64
+ if (!reviewRef?.trim() || !operationId) {
65
+ return this.error('Reviewed removal requires both a review ref and an operation UUID.', { exit: 2 });
66
+ }
67
+ if (!flags.yes && !(await this.confirm(`Remove reviewed personal registration ${args.harness}?`))) {
68
+ return this.error('Cancelled. The registration was kept.', { exit: 1 });
69
+ }
70
+ try {
71
+ const receipt = await (0, harnesses_1.forgetReviewedHarness)(args.harness, reviewRef, operationId);
72
+ if (flags.json)
73
+ return this.printJsonResult(receipt);
74
+ this.log(`Removed registration ${receipt.harnessId}. Operation ${receipt.operationId}.`);
75
+ }
76
+ catch (error) {
77
+ this.handleApiError(error, { subject: `reviewed removal of harness ${args.harness}` });
78
+ }
79
+ return;
80
+ }
50
81
  // Name it before removing it. An id alone does not tell the operator which
51
82
  // of their machines they are about to drop from the fleet.
52
83
  if (!flags.yes) {
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from '../../base-command';
2
+ export default class HarnessesRemovalReceipt extends BaseCommand {
3
+ static description: string;
4
+ static args: {
5
+ operationId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static flags: {
8
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,32 @@
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 harnesses_1 = require("../../lib/harnesses");
6
+ const request_uuid_1 = require("../../lib/request-uuid");
7
+ class HarnessesRemovalReceipt extends base_command_1.BaseCommand {
8
+ static description = 'Check the result of one reviewed Harness registration removal';
9
+ static args = {
10
+ operationId: core_1.Args.string({
11
+ description: 'UUID used with `harnesses forget`', required: true, ignoreStdin: true,
12
+ parse: request_uuid_1.parseRequestUuid,
13
+ }),
14
+ };
15
+ static flags = { json: core_1.Flags.boolean({ description: 'Output the receipt as JSON' }) };
16
+ async run() {
17
+ this.requireAuth();
18
+ const { args, flags } = await this.parse(HarnessesRemovalReceipt);
19
+ try {
20
+ const result = await (0, harnesses_1.getHarnessRemovalOperation)(args.operationId);
21
+ if (flags.json)
22
+ return this.printJsonResult(result);
23
+ this.log(result.state === 'committed'
24
+ ? `Registration ${result.receipt.harnessId} was removed at ${result.receipt.removedAt}.`
25
+ : 'The server could not confirm that registration removal.');
26
+ }
27
+ catch (error) {
28
+ this.handleApiError(error, { subject: `Harness removal operation ${args.operationId}` });
29
+ }
30
+ }
31
+ }
32
+ exports.default = HarnessesRemovalReceipt;
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from '../../base-command';
2
+ export default class HarnessesRemovalReview extends BaseCommand {
3
+ static description: string;
4
+ static args: {
5
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static flags: {
8
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,28 @@
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 harnesses_1 = require("../../lib/harnesses");
6
+ class HarnessesRemovalReview extends base_command_1.BaseCommand {
7
+ static description = 'Review removal of an unreferenced offline personal Harness registration';
8
+ static args = {
9
+ id: core_1.Args.string({ description: 'Harness ID', required: true, ignoreStdin: true }),
10
+ };
11
+ static flags = { json: core_1.Flags.boolean({ description: 'Output the review as JSON' }) };
12
+ async run() {
13
+ this.requireAuth();
14
+ const { args, flags } = await this.parse(HarnessesRemovalReview);
15
+ try {
16
+ const review = await (0, harnesses_1.getHarnessRemovalReview)(args.id);
17
+ if (flags.json)
18
+ return this.printJsonResult(review);
19
+ this.log(`Registration ${review.harnessId} passed the review. The review expires at ${review.expiresAt}.`);
20
+ this.log(`Review ref: ${review.reviewRef}`);
21
+ this.log(`Confirm with ${this.config.bin} harnesses forget ${review.harnessId} --review-ref <review-ref> --operation-id <uuid>.`);
22
+ }
23
+ catch (error) {
24
+ this.handleApiError(error, { subject: `Harness ${args.id} removal review` });
25
+ }
26
+ }
27
+ }
28
+ exports.default = HarnessesRemovalReview;
@@ -0,0 +1,14 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ export default class SpacesLoopsReleaseReceipt extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ duty: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ link: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ };
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const data_provider_1 = require("@skrr-ai/data-provider");
5
+ const base_command_1 = require("../../../base-command");
6
+ class SpacesLoopsReleaseReceipt extends base_command_1.BaseCommand {
7
+ static description = 'Read your recent Space Loop releases or check one exact home link';
8
+ static examples = [
9
+ '<%= config.bin %> spaces loops release-receipt <space-id>',
10
+ '<%= config.bin %> spaces loops release-receipt <space-id> --duty <duty-id> --link <home-link-id> --json',
11
+ ];
12
+ static args = {
13
+ id: core_1.Args.string({ description: 'Space ID or title', required: true, ignoreStdin: true }),
14
+ };
15
+ static flags = {
16
+ duty: core_1.Flags.string({ description: 'Duty ID from the original release', dependsOn: ['link'] }),
17
+ link: core_1.Flags.string({ description: 'Home link ID from the original release', dependsOn: ['duty'] }),
18
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
19
+ };
20
+ async run() {
21
+ this.requireAuth();
22
+ const { args, flags } = await this.parse(SpacesLoopsReleaseReceipt);
23
+ const spaceId = await this.resolveSpaceReference(args.id);
24
+ try {
25
+ if (flags.duty && flags.link) {
26
+ const receipt = await data_provider_1.dataService.getSpaceLoopReleaseReceipt(spaceId, flags.duty, flags.link);
27
+ if (flags.json)
28
+ return this.printJsonResult(receipt);
29
+ this.log(receipt.state === 'released'
30
+ ? `Recorded release for Duty ${receipt.dutyId} and home link ${receipt.linkId}.`
31
+ : 'The server could not confirm that release.');
32
+ return;
33
+ }
34
+ const history = await data_provider_1.dataService.listSpaceLoopReleaseReceipts(spaceId);
35
+ if (flags.json)
36
+ return this.printJsonResult(history);
37
+ if (history.receipts.length === 0)
38
+ this.log('No recent releases found for your account.');
39
+ for (const receipt of history.receipts) {
40
+ this.log(`${receipt.releasedAt} ${receipt.dutyId} ${receipt.linkId} cleanup ${receipt.cleanup}`);
41
+ }
42
+ }
43
+ catch (error) {
44
+ this.handleApiError(error, { subject: `Space ${spaceId} Loop release receipt` });
45
+ }
46
+ }
47
+ }
48
+ exports.default = SpacesLoopsReleaseReceipt;
@@ -28,7 +28,7 @@ class SpacesLoopsRelease extends base_command_1.BaseCommand {
28
28
  const links = await data_provider_1.dataService.listDutyWorkLinksForTarget({ targetType: 'space', targetId: spaceId });
29
29
  const homes = links.data.filter((link) => link.dutyId === flags.duty && link.status === 'active' && link.roles.includes('home'));
30
30
  if (homes.length !== 1) {
31
- this.error('No unique active home link found. Supply --link <home-link-id> to release a reviewed link or retry its receipt.', { exit: 2 });
31
+ this.error('No unique active home link found. Supply --link <home-link-id> to release a reviewed link, or use `spaces loops release-receipt` to check prior releases.', { exit: 2 });
32
32
  }
33
33
  linkId = homes[0].id;
34
34
  }
@@ -11,6 +11,7 @@ export default class SpacesWorkflowTemplatesArchive extends BaseCommand {
11
11
  static flags: {
12
12
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
13
  yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ 'expected-revision': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
15
  };
15
16
  run(): Promise<void>;
16
17
  }
@@ -19,6 +19,11 @@ class SpacesWorkflowTemplatesArchive extends base_command_1.BaseCommand {
19
19
  static flags = {
20
20
  json: core_1.Flags.boolean({ description: 'Output as JSON' }),
21
21
  yes: core_1.Flags.boolean({ char: 'y', description: 'Skip the confirmation prompt' }),
22
+ 'expected-revision': core_1.Flags.integer({
23
+ min: 0,
24
+ max: Number.MAX_SAFE_INTEGER,
25
+ description: 'Archive only if the reviewed revision from `workflow-templates show` still matches',
26
+ }),
22
27
  };
23
28
  async run() {
24
29
  this.requireAuth();
@@ -39,7 +44,10 @@ class SpacesWorkflowTemplatesArchive extends base_command_1.BaseCommand {
39
44
  return this.log('Cancelled.');
40
45
  let result;
41
46
  try {
42
- result = await data_provider_1.dataService.archiveSpaceWorkflowTemplate(args.spaceId, args.templateId);
47
+ const revision = flags['expected-revision'];
48
+ result = revision === undefined
49
+ ? await data_provider_1.dataService.archiveSpaceWorkflowTemplate(args.spaceId, args.templateId)
50
+ : await data_provider_1.dataService.archiveReviewedSpaceWorkflowTemplate(args.spaceId, args.templateId, revision);
43
51
  }
44
52
  catch (error) {
45
53
  this.handleApiError(error, { subject: `workflow template ${args.templateId}` });
@@ -70,6 +70,8 @@ class SpacesWorkflowTemplatesShow extends base_command_1.BaseCommand {
70
70
  this.log(`Title: ${template.title}`);
71
71
  this.log(`Scope: ${template.scope}${template.readOnly ? ' (read-only)' : ''}`);
72
72
  this.log(`Published version: ${template.currentVersion || 'not published'}`);
73
+ if (template.revision !== undefined)
74
+ this.log(`Authoring revision: ${template.revision}`);
73
75
  this.log(`Nodes / edges: ${template.nodeCount} / ${template.edgeCount}`);
74
76
  this.log(`Node types: ${template.nodeTypes.join(', ') || '-'}`);
75
77
  this.log(`Entry ports: ${template.ports.entry.join(', ') || '-'}`);
@@ -15,6 +15,7 @@ export default class SpacesWorkflowTemplatesUpdate extends BaseCommand {
15
15
  tags: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
16
  scope: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
17
  body: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ 'expected-revision': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
19
  };
19
20
  run(): Promise<void>;
20
21
  }
@@ -25,6 +25,11 @@ class SpacesWorkflowTemplatesUpdate extends base_command_1.BaseCommand {
25
25
  tags: core_1.Flags.string({ description: 'Comma list of tags (empty string clears them)' }),
26
26
  scope: core_1.Flags.string({ description: 'private, space, or workspace' }),
27
27
  body: core_1.Flags.string({ description: 'Path to replacement body JSON ("-" for stdin)' }),
28
+ 'expected-revision': core_1.Flags.integer({
29
+ min: 0,
30
+ max: Number.MAX_SAFE_INTEGER,
31
+ description: 'Apply the update only if the reviewed revision from `workflow-templates show` still matches',
32
+ }),
28
33
  };
29
34
  async run() {
30
35
  this.requireAuth();
@@ -51,7 +56,13 @@ class SpacesWorkflowTemplatesUpdate extends base_command_1.BaseCommand {
51
56
  this.failWithCliError({ ...plan.error, exit: 2, retryable: false });
52
57
  let template;
53
58
  try {
54
- template = await data_provider_1.dataService.updateSpaceWorkflowTemplate(args.spaceId, args.templateId, plan.payload);
59
+ const revision = flags['expected-revision'];
60
+ template = revision === undefined
61
+ ? await data_provider_1.dataService.updateSpaceWorkflowTemplate(args.spaceId, args.templateId, plan.payload)
62
+ : await data_provider_1.dataService.updateReviewedSpaceWorkflowTemplate(args.spaceId, args.templateId, {
63
+ ...plan.payload,
64
+ expectedRevision: revision,
65
+ });
55
66
  }
56
67
  catch (error) {
57
68
  this.handleApiError(error, { subject: `workflow template ${args.templateId}` });
@@ -8,6 +8,7 @@ export default class SpacesWorkflowsPublish extends BaseCommand {
8
8
  };
9
9
  static flags: {
10
10
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ 'reviewed-draft': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
12
  };
12
13
  run(): Promise<void>;
13
14
  }
@@ -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 base_command_1 = require("../../../base-command");
6
+ const prompt_1 = require("../../../lib/prompt");
6
7
  const space_output_1 = require("../../../lib/space-output");
7
8
  const workflow_issues_1 = require("../../../lib/workflow-issues");
8
9
  class SpacesWorkflowsPublish extends base_command_1.BaseCommand {
@@ -12,13 +13,48 @@ class SpacesWorkflowsPublish extends base_command_1.BaseCommand {
12
13
  spaceId: core_1.Args.string({ required: true, ignoreStdin: true }),
13
14
  workflowId: core_1.Args.string({ required: true, ignoreStdin: true }),
14
15
  };
15
- static flags = { json: core_1.Flags.boolean({ description: 'Output JSON' }) };
16
+ static flags = {
17
+ json: core_1.Flags.boolean({ description: 'Output JSON' }),
18
+ 'reviewed-draft': core_1.Flags.string({
19
+ description: 'Publish only the draft in a saved `workflows show --json` file ("-" for stdin)',
20
+ }),
21
+ };
16
22
  async run() {
17
23
  this.requireAuth();
18
24
  const { args, flags } = await this.parse(SpacesWorkflowsPublish);
25
+ let review;
26
+ if (flags['reviewed-draft'] !== undefined) {
27
+ try {
28
+ const snapshot = await (0, prompt_1.readJsonBody)(flags['reviewed-draft']);
29
+ if (snapshot.id !== args.workflowId || snapshot.spaceId !== args.spaceId) {
30
+ throw new Error('The reviewed draft must belong to this Space and workflow.');
31
+ }
32
+ const draft = snapshot.draft;
33
+ const semanticRevision = draft?.semanticRevision;
34
+ const presentationRevision = draft?.presentationRevision;
35
+ const { currentVersion } = snapshot;
36
+ const maxDurationMs = snapshot.maxDurationMs ?? null;
37
+ if (!isRevision(semanticRevision) || !isRevision(presentationRevision) ||
38
+ !isRevision(currentVersion) ||
39
+ (maxDurationMs !== null && (!isRevision(maxDurationMs) || maxDurationMs === 0))) {
40
+ throw new Error('The reviewed draft must include valid revisions, version, and run duration.');
41
+ }
42
+ review = { semanticRevision, presentationRevision, currentVersion, maxDurationMs };
43
+ }
44
+ catch (error) {
45
+ this.failWithCliError({
46
+ message: error.message,
47
+ code: 'WORKFLOW_REVIEWED_DRAFT_INVALID',
48
+ exit: 2,
49
+ retryable: false,
50
+ });
51
+ }
52
+ }
19
53
  let version;
20
54
  try {
21
- version = await data_provider_1.dataService.publishSpaceWorkflow(args.spaceId, args.workflowId);
55
+ version = review
56
+ ? await data_provider_1.dataService.publishReviewedSpaceWorkflow(args.spaceId, args.workflowId, review)
57
+ : await data_provider_1.dataService.publishSpaceWorkflow(args.spaceId, args.workflowId);
22
58
  }
23
59
  catch (error) {
24
60
  this.handleApiError(error);
@@ -44,3 +80,6 @@ class SpacesWorkflowsPublish extends base_command_1.BaseCommand {
44
80
  }
45
81
  }
46
82
  exports.default = SpacesWorkflowsPublish;
83
+ function isRevision(value) {
84
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
85
+ }
@@ -66,6 +66,7 @@ export default class TasksCreate extends BaseCommand {
66
66
  description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
67
67
  'description-format': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
68
68
  'external-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
69
+ 'request-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
69
70
  'default-agent': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
70
71
  priority: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
71
72
  parent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -109,6 +110,7 @@ export default class TasksCreate extends BaseCommand {
109
110
  * names API fields (OSK-10219); everything else is the uniform translation.
110
111
  */
111
112
  private failTaskCreate;
113
+ private sendCreateRequest;
112
114
  private createTaskOrRecover;
113
115
  /**
114
116
  * Predict the create route's `ASSIGNEE_NOT_IN_SPACE` degradation for a
@@ -11,6 +11,7 @@ const data_provider_1 = require("@skrr-ai/data-provider");
11
11
  const base_command_1 = require("../../base-command");
12
12
  const label_ref_1 = require("../../lib/label-ref");
13
13
  const prompt_1 = require("../../lib/prompt");
14
+ const request_uuid_1 = require("../../lib/request-uuid");
14
15
  const tasks_1 = require("../../lib/tasks");
15
16
  const task_instruction_offer_1 = require("../../lib/task-instruction-offer");
16
17
  const list_workspace_1 = require("../../lib/list-workspace");
@@ -187,6 +188,10 @@ class TasksCreate extends base_command_1.BaseCommand {
187
188
  'external-key': core_1.Flags.string({
188
189
  description: 'Stable caller-supplied idempotency key for create/upsert workflows',
189
190
  }),
191
+ 'request-id': core_1.Flags.string({
192
+ description: 'UUID for this exact create payload, recoverable with `tasks creation-receipt`',
193
+ parse: request_uuid_1.parseRequestUuid,
194
+ }),
190
195
  'default-agent': core_1.Flags.string({
191
196
  description: 'Override the automatic assignee with an Agent (it becomes the assignee that runs the task; ' +
192
197
  '--assignee-agent names one directly). Use "auto" to inherit the space lead ' +
@@ -467,7 +472,7 @@ class TasksCreate extends base_command_1.BaseCommand {
467
472
  }
468
473
  let instantiated;
469
474
  try {
470
- instantiated = (await data_provider_1.dataService.createTask(payload));
475
+ instantiated = (await this.sendCreateRequest(payload, flags['request-id']));
471
476
  }
472
477
  catch (err) {
473
478
  this.failTaskCreate(err, payload, flags.goal !== undefined);
@@ -595,7 +600,7 @@ class TasksCreate extends base_command_1.BaseCommand {
595
600
  let created;
596
601
  let createRecovery;
597
602
  try {
598
- const result = await this.createTaskOrRecover(payload);
603
+ const result = await this.createTaskOrRecover(payload, flags['request-id']);
599
604
  created = result.task;
600
605
  createRecovery = result.recovery;
601
606
  }
@@ -622,7 +627,9 @@ class TasksCreate extends base_command_1.BaseCommand {
622
627
  /* non-JSON body carries no code */
623
628
  }
624
629
  }
625
- if (!(defaultAgentResolution.applied && failureCode === 'ASSIGNEE_NOT_IN_SPACE')) {
630
+ // A caller who pins a request ID must be able to recover the exact original body.
631
+ if (flags['request-id'] ||
632
+ !(defaultAgentResolution.applied && failureCode === 'ASSIGNEE_NOT_IN_SPACE')) {
626
633
  this.failTaskCreate(err, payload, flags.goal !== undefined);
627
634
  }
628
635
  delete payload.assigneeAgentIds;
@@ -736,15 +743,21 @@ class TasksCreate extends base_command_1.BaseCommand {
736
743
  }
737
744
  this.handleApiError(err);
738
745
  }
739
- async createTaskOrRecover(payload) {
746
+ sendCreateRequest(payload, requestId) {
747
+ const data = payload;
748
+ return requestId
749
+ ? data_provider_1.dataService.createTask(data, { idempotencyKey: requestId })
750
+ : data_provider_1.dataService.createTask(data);
751
+ }
752
+ async createTaskOrRecover(payload, requestId) {
740
753
  try {
741
754
  return {
742
- task: await data_provider_1.dataService.createTask(payload),
755
+ task: await this.sendCreateRequest(payload, requestId),
743
756
  };
744
757
  }
745
758
  catch (error) {
746
759
  const externalKey = typeof payload.externalKey === 'string' ? payload.externalKey.trim() : '';
747
- if (!externalKey || !taskCreateMayHaveCommitted(error))
760
+ if (requestId || !externalKey || !taskCreateMayHaveCommitted(error))
748
761
  throw error;
749
762
  try {
750
763
  const existing = await (0, tasks_1.findTaskByExternalKey)({
@@ -0,0 +1,12 @@
1
+ import { BaseCommand } from '../../base-command';
2
+ export default class TasksCreationReceipt extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ 'request-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ 'from-json': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'create-and-start': import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const data_provider_1 = require("@skrr-ai/data-provider");
5
+ const base_command_1 = require("../../base-command");
6
+ const prompt_1 = require("../../lib/prompt");
7
+ const request_uuid_1 = require("../../lib/request-uuid");
8
+ class TasksCreationReceipt extends base_command_1.BaseCommand {
9
+ static description = 'Check whether the original Task creation request completed';
10
+ static examples = [
11
+ '<%= config.bin %> tasks creation-receipt --request-id <uuid> --from-json payload.json --workspace <workspace-id>',
12
+ ];
13
+ static flags = {
14
+ 'request-id': core_1.Flags.string({
15
+ description: 'UUID used for the original create request', required: true, parse: request_uuid_1.parseRequestUuid,
16
+ }),
17
+ 'from-json': core_1.Flags.string({
18
+ description: 'Original request body, such as .payload from `tasks create --dry-run --json` ("-" for stdin)',
19
+ required: true,
20
+ }),
21
+ 'create-and-start': core_1.Flags.boolean({ description: 'Look up a combined create-and-start request' }),
22
+ json: core_1.Flags.boolean({ description: 'Output the receipt as JSON' }),
23
+ };
24
+ async run() {
25
+ this.requireAuth();
26
+ const { flags } = await this.parse(TasksCreationReceipt);
27
+ let payload;
28
+ try {
29
+ payload = await (0, prompt_1.readJsonBody)(flags['from-json']);
30
+ }
31
+ catch (error) {
32
+ this.error(error.message, { exit: 2 });
33
+ }
34
+ try {
35
+ const receipt = await data_provider_1.dataService.getTaskCreationReceipt({
36
+ requestId: flags['request-id'],
37
+ payload,
38
+ ...(flags['create-and-start'] ? { action: 'create-and-start' } : {}),
39
+ });
40
+ if (flags.json)
41
+ return this.printJsonResult(receipt);
42
+ if (receipt.state === 'unknown')
43
+ return this.log('The server could not confirm that Task creation.');
44
+ this.log(`Created Task ${receipt.taskId}.`);
45
+ if (receipt.started !== undefined)
46
+ this.log(`Start accepted: ${receipt.started ? 'yes' : 'no'}`);
47
+ }
48
+ catch (error) {
49
+ this.handleApiError(error, { subject: 'Task creation receipt' });
50
+ }
51
+ }
52
+ }
53
+ exports.default = TasksCreationReceipt;
@@ -8,6 +8,7 @@ export default class TasksDelete extends BaseCommand {
8
8
  static flags: {
9
9
  yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
10
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ 'deletion-command-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
12
  };
12
13
  run(): Promise<void>;
13
14
  }
@@ -4,6 +4,7 @@ const core_1 = require("@oclif/core");
4
4
  const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const base_command_1 = require("../../base-command");
6
6
  const prompt_1 = require("../../lib/prompt");
7
+ const request_uuid_1 = require("../../lib/request-uuid");
7
8
  class TasksDelete extends base_command_1.BaseCommand {
8
9
  static description = 'Delete a task (irreversible)';
9
10
  static examples = [
@@ -20,11 +21,15 @@ class TasksDelete extends base_command_1.BaseCommand {
20
21
  // CLI_PARSE_ERROR, so a loop that discarded output — the normal shape for a
21
22
  // cleanup loop — deleted nothing and reported nothing.
22
23
  json: core_1.Flags.boolean({ description: 'Output as JSON' }),
24
+ 'deletion-command-id': core_1.Flags.string({
25
+ description: 'UUID for this deletion, recoverable with `tasks deletion-receipt`',
26
+ parse: request_uuid_1.parseRequestUuid,
27
+ }),
23
28
  };
24
29
  async run() {
25
30
  this.requireAuth();
26
31
  const { args, flags } = await this.parse(TasksDelete);
27
- const taskId = await this.resolveEntityRef('task', args.id);
32
+ let taskId = await this.resolveEntityRef('task', args.id);
28
33
  let confirmed;
29
34
  try {
30
35
  confirmed = await (0, prompt_1.confirmDestructive)(`Delete task ${taskId === args.id ? taskId : `${args.id} (${taskId})`}? This cannot be undone.`, flags.yes);
@@ -41,14 +46,27 @@ class TasksDelete extends base_command_1.BaseCommand {
41
46
  this.log('Cancelled.');
42
47
  return;
43
48
  }
49
+ const deletionCommandId = flags['deletion-command-id'];
44
50
  try {
45
- await data_provider_1.dataService.deleteTask(taskId);
51
+ if (deletionCommandId) {
52
+ const task = await data_provider_1.dataService.getTask(taskId);
53
+ if (!task.id)
54
+ throw new Error('The Task lookup returned no canonical ID.');
55
+ taskId = task.id;
56
+ this.logToStderr(`Check the deletion in the same workspace with ${this.config.bin} tasks deletion-receipt ${taskId} --deletion-command-id ${deletionCommandId}`);
57
+ await data_provider_1.dataService.deleteTask(taskId, { deletionCommandId });
58
+ }
59
+ else {
60
+ await data_provider_1.dataService.deleteTask(taskId);
61
+ }
46
62
  }
47
63
  catch (err) {
48
64
  this.handleApiError(err);
49
65
  }
50
- if (flags.json)
51
- return this.log(JSON.stringify({ deleted: true, id: taskId }, null, 2));
66
+ if (flags.json) {
67
+ const result = { deleted: true, id: taskId, ...(deletionCommandId ? { deletionCommandId } : {}) };
68
+ return this.log(JSON.stringify(result, null, 2));
69
+ }
52
70
  this.log(`Deleted task ${args.id}`);
53
71
  }
54
72
  }
@@ -0,0 +1,12 @@
1
+ import { BaseCommand } from '../../base-command';
2
+ export default class TasksDeletionReceipt extends BaseCommand {
3
+ static description: string;
4
+ static args: {
5
+ canonicalTaskId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static flags: {
8
+ 'deletion-command-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ run(): Promise<void>;
12
+ }