omp-superagent 0.1.17 → 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.
- package/DESIGN.md +15 -12
- package/config.example.json +4 -1
- package/docs/OPERATIONS.en.md +78 -29
- package/docs/OPERATIONS.md +59 -20
- package/docs/design/execution.md +30 -15
- package/docs/design/messaging.md +126 -43
- package/docs/releases/0.1.18.md +10 -0
- package/gateway/bin/omp-gateway-darwin-arm64 +0 -0
- package/gateway/bin/omp-gateway-darwin-x64 +0 -0
- package/gateway/bin/omp-gateway-linux-arm64 +0 -0
- package/gateway/bin/omp-gateway-linux-x64 +0 -0
- package/package.json +1 -1
- package/skills/head/SKILL.md +2 -2
- package/skills/head/references/routing.md +17 -6
- package/src/config/config.ts +15 -0
- package/src/contracts.ts +46 -3
- package/src/cron/cron-jobs.ts +135 -92
- package/src/cron/cron-pr-intake.ts +18 -11
- package/src/extension.ts +15 -5
- package/src/gateway/gateway-client.ts +3 -1
- package/src/lane/workflow.ts +12 -6
- package/src/managed-super-probe.ts +21 -15
- package/src/messaging/messenger-command-catalog.json +1 -1
- package/src/messaging/messenger-commands.ts +8 -3
- package/src/messaging/slack-context.ts +50 -0
- package/src/omp/superkit-skills.ts +15 -2
- package/src/pr/pr-intake-order.ts +62 -0
- package/src/pr/pr-intake-review.ts +49 -31
- package/src/pr/pr-intake-work.ts +3 -2
- package/src/routing/message-order.ts +22 -1
- package/src/routing/topic-request.ts +41 -0
- package/src/runtime/controller.ts +461 -178
- package/src/runtime/deferred-routing.ts +12 -4
- package/src/runtime/dm-timeline.ts +3 -3
- package/src/storage/deferred-routing.ts +25 -4
- package/src/storage/store.ts +367 -50
|
@@ -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>();
|