omp-superagent 0.1.16 → 0.1.18

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 (47) hide show
  1. package/DESIGN.md +15 -12
  2. package/config.example.json +4 -1
  3. package/docs/OPERATIONS.en.md +119 -33
  4. package/docs/OPERATIONS.md +83 -23
  5. package/docs/design/execution.md +66 -17
  6. package/docs/design/messaging.md +134 -47
  7. package/docs/releases/0.1.17.md +10 -0
  8. package/docs/releases/0.1.18.md +10 -0
  9. package/gateway/bin/omp-gateway-darwin-arm64 +0 -0
  10. package/gateway/bin/omp-gateway-darwin-x64 +0 -0
  11. package/gateway/bin/omp-gateway-linux-arm64 +0 -0
  12. package/gateway/bin/omp-gateway-linux-x64 +0 -0
  13. package/host-owner/bin/omp-host-owner-darwin-arm64 +0 -0
  14. package/host-owner/bin/omp-host-owner-darwin-x64 +0 -0
  15. package/host-owner/bin/omp-host-owner-linux-arm64 +0 -0
  16. package/host-owner/bin/omp-host-owner-linux-x64 +0 -0
  17. package/package.json +1 -1
  18. package/skills/head/SKILL.md +2 -2
  19. package/skills/head/references/routing.md +17 -6
  20. package/src/config/config.ts +15 -0
  21. package/src/contracts.ts +49 -4
  22. package/src/cron/cron-jobs.ts +135 -92
  23. package/src/cron/cron-pr-intake.ts +18 -11
  24. package/src/extension.ts +15 -5
  25. package/src/gateway/gateway-client.ts +3 -1
  26. package/src/lane/workflow.ts +12 -6
  27. package/src/managed-super-probe.ts +21 -15
  28. package/src/messaging/messenger-command-catalog.json +1 -1
  29. package/src/messaging/messenger-commands.ts +8 -3
  30. package/src/messaging/slack-context.ts +50 -0
  31. package/src/omp/superkit-skills.ts +15 -2
  32. package/src/pr/pr-intake-order.ts +62 -0
  33. package/src/pr/pr-intake-review.ts +49 -31
  34. package/src/pr/pr-intake-work.ts +3 -2
  35. package/src/routing/message-order.ts +22 -1
  36. package/src/routing/topic-request.ts +41 -0
  37. package/src/runtime/controller.ts +515 -191
  38. package/src/runtime/deferred-routing.ts +12 -4
  39. package/src/runtime/dm-timeline.ts +3 -3
  40. package/src/storage/deferred-routing.ts +25 -4
  41. package/src/storage/store.ts +389 -60
  42. package/src/worker/worker-checkout.ts +38 -4
  43. package/src/worker/worker-host.ts +114 -24
  44. package/src/worker/worker-ledger.ts +28 -9
  45. package/src/worker/worker-repository.ts +13 -0
  46. package/src/worker/worker-service.ts +74 -17
  47. package/src/worker/worker-wire.ts +3 -1
@@ -1,9 +1,23 @@
1
1
  import { realpathSync, statSync } from "node:fs";
2
2
  import { basename, isAbsolute } from "node:path";
3
3
  import type { Lane } from "../contracts";
4
+ import { decodeSlackMrkdwn } from "../messaging/messenger-commands";
4
5
 
5
6
  export const TOPIC_CHOICE_WAIT_MS = 5 * 60_000;
6
7
 
8
+ /** Slack has no reply reference to an individual message inside a thread. */
9
+ function slackTopicChoice(text: string): { readonly source: string; readonly answer: string } | null {
10
+ const match = /^!choose[ \t]+(\d{1,20}\.\d{6})[ \t]+(\S[^\r\n\u2028\u2029]*)$/u.exec(text.trim());
11
+ return match ? { source: match[1], answer: decodeSlackMrkdwn(match[2]) } : null;
12
+ }
13
+
14
+ /** Interpret only a physical Slack workspace header; preserve task bytes. */
15
+ export function slackWorkspacePlacement(text: string, routingText: string | null | undefined): string {
16
+ const written = routingText !== undefined && routingText !== null && /^cwd:/iu.test(routingText) ? routingText : text;
17
+ // Match the same leading whitespace that topicRequest trims.
18
+ return written.replace(/^\s*cwd:[^\n]*/iu, decodeSlackMrkdwn);
19
+ }
20
+
7
21
  /** Only owner text, never a quote, attachment path, or channel description. */
8
22
  export function topicRequest(text: string) {
9
23
  const request = text.replace(/^\s*\/new(?:\s+|$)/, "");
@@ -14,6 +28,22 @@ export function topicRequest(text: string) {
14
28
  return { text: request.trimStart().slice(header[0].length), cwd: quoted?.[2] ?? path };
15
29
  }
16
30
 
31
+ /** The only answer forms that an original Slack message can supply to a workspace question. */
32
+ export function slackWorkspaceAnswer(
33
+ text: string, routingText: string | null | undefined, verified: unknown,
34
+ ): { text: string; cwd: string | null; source: string | null } | null {
35
+ if (verified !== true) return null;
36
+ if (/^!choose(?:\s|$)/u.test(text.trim())) {
37
+ const explicit = slackTopicChoice(text);
38
+ return explicit ? { text: explicit.answer, cwd: null, source: explicit.source } : null;
39
+ }
40
+ if (/^\s*\/new(?:\s|$)/u.test(text)) return null;
41
+ const request = topicRequest(slackWorkspacePlacement(text, routingText));
42
+ if (request.cwd !== null) return request.text.trim() ? null : { cwd: request.cwd, text: "", source: null };
43
+ const answer = (routingText ?? decodeSlackMrkdwn(text)).trim();
44
+ return answer && !/[\r\n\u2028\u2029]/u.test(answer) ? { cwd: null, text: answer, source: null } : null;
45
+ }
46
+
17
47
  /** Parse only the original Discord owner request body. An empty result asks for a task. */
18
48
  export function discordThreadSplit(text: string): string | null {
19
49
  const line = text.trim();
@@ -56,6 +86,17 @@ export function existingWorkspace(path: string): string | null {
56
86
  }
57
87
  }
58
88
 
89
+ /** A Slack history question accepts a number, a unique workspace name or an existing absolute path. */
90
+ export function matchingSlackHistoryChoice<T extends { readonly cwd: string }>(
91
+ answer: string, cwdHeader: string | null, choices: readonly T[],
92
+ ): T | undefined {
93
+ if (cwdHeader === null && /^[1-9]\d*$/u.test(answer)) return choices[Number(answer) - 1];
94
+ const cwd = existingWorkspace(cwdHeader ?? answer);
95
+ const matches = choices.filter(ref => cwd !== null ? ref.cwd === cwd
96
+ : cwdHeader === null && basename(ref.cwd).toLowerCase() === answer.toLowerCase());
97
+ return matches.length === 1 ? matches[0] : undefined;
98
+ }
99
+
59
100
  /** Match names of placed workspaces, not substrings of paths, filenames or longer repo names. */
60
101
  export function namedWorkspaces(text: string, lanes: readonly Lane[], nameOnly = false): Set<string> {
61
102
  const matches = new Set<string>();