omp-superagent 0.0.0-stage → 0.1.1
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 +1361 -0
- package/LICENSE +21 -0
- package/README.ko.md +184 -0
- package/README.md +205 -2
- package/THIRD_PARTY_NOTICES.md +313 -0
- package/assets/architecture.mmd +24 -0
- package/assets/architecture.svg +126 -0
- package/assets/superagent-avatar.jpg +0 -0
- package/assets/superagent-mascot.webp +0 -0
- package/config.example.json +26 -0
- package/docs/OPERATIONS.md +1030 -0
- package/docs/releases/0.1.0.md +222 -0
- package/docs/releases/0.1.1.md +60 -0
- package/package.json +59 -4
- package/scripts/check-omp.ts +4 -0
- package/scripts/ci.ts +28 -0
- package/scripts/prepare-ulw.ts +18 -0
- package/scripts/release.ts +50 -0
- package/scripts/setup.sh +25 -0
- package/skills/head/SKILL.md +259 -0
- package/skills/head/references/model-selection.md +263 -0
- package/skills/head/references/routing.md +356 -0
- package/skills/head/references/supervision.md +312 -0
- package/skills/lane/SKILL.md +188 -0
- package/skills/lane/references/workflow.md +349 -0
- package/src/autostart.ts +295 -0
- package/src/board-extension.ts +217 -0
- package/src/board.ts +396 -0
- package/src/cli.ts +167 -0
- package/src/config.ts +191 -0
- package/src/contracts.ts +317 -0
- package/src/credentials.ts +172 -0
- package/src/delivery.ts +7 -0
- package/src/dialog.ts +73 -0
- package/src/discord-command-registration.ts +201 -0
- package/src/discord-commands.ts +29 -0
- package/src/discord-markdown.ts +172 -0
- package/src/discord.ts +745 -0
- package/src/extension.ts +289 -0
- package/src/gateway-client.ts +222 -0
- package/src/gateway-protocol.ts +85 -0
- package/src/gateway-restart.ts +151 -0
- package/src/gateway-server.ts +392 -0
- package/src/gateway-store.ts +237 -0
- package/src/gateway.ts +638 -0
- package/src/head-recovery.ts +61 -0
- package/src/host-extension.ts +449 -0
- package/src/host-owner.ts +350 -0
- package/src/host-protocol.ts +136 -0
- package/src/host.ts +414 -0
- package/src/installed-omp.ts +63 -0
- package/src/lane-extension.ts +179 -0
- package/src/lane-models.ts +75 -0
- package/src/lane-report.ts +70 -0
- package/src/managed-ulw-probe.ts +172 -0
- package/src/managed-ulw.ts +471 -0
- package/src/message-order.ts +21 -0
- package/src/messenger-commands.ts +16 -0
- package/src/messengers.ts +114 -0
- package/src/native-presets.ts +282 -0
- package/src/native-sessions.ts +32 -0
- package/src/native-settings.ts +129 -0
- package/src/repository.ts +12 -0
- package/src/runtime.ts +3864 -0
- package/src/setup-judge.ts +34 -0
- package/src/setup-memory.ts +39 -0
- package/src/setup-profiles.ts +84 -0
- package/src/setup.ts +300 -0
- package/src/slack-command-registration.ts +217 -0
- package/src/slack-commands.ts +18 -0
- package/src/slack.ts +776 -0
- package/src/store.ts +806 -0
- package/src/telegram-command-registration.ts +155 -0
- package/src/telegram.ts +661 -0
- package/src/workflow.ts +94 -0
- package/upstream/ulw.json +9 -0
package/src/workflow.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { WORKFLOW_NAMES, type WorkflowActivation, type WorkflowChoice, type WorkflowName } from "./contracts";
|
|
2
|
+
|
|
3
|
+
// Boundary contract inspected against omp-ulw/ulw.ts (2026-11-14). This bridge
|
|
4
|
+
// recognizes its six ULW workflows and native jevify, not arbitrary mentions or skill prose.
|
|
5
|
+
const aliases: Array<[WorkflowName, RegExp]> = [
|
|
6
|
+
["ulw-research", /^(?:ulw|mass[\s-]*ulw|ulw[\s-]*mass|mulw|meth)[\s-]*research\b/i],
|
|
7
|
+
["mass-ulw", /^(?:mass[\s-]*ulw|ulw[\s-]*mass|mulw|meth)\b/i],
|
|
8
|
+
["ulw-plan", /^ulw[\s-]*plan\b/i],
|
|
9
|
+
["ulw-loop", /^ulw[\s-]*loop\b/i],
|
|
10
|
+
["ulw-execute", /^ulw[\s-]*execute\b/i],
|
|
11
|
+
];
|
|
12
|
+
const identifierTail = /^(?:[-_][A-Za-z0-9]|\.[A-Za-z0-9]|[-_.]?[A-Za-z0-9]*[/\\])/;
|
|
13
|
+
const nativeWords = /(?<![\p{L}\p{N}_./\\-])(?<!::)(?:ultrathink|orchestrate|workflowz|jevify)(?![\p{L}\p{N}_/\\-])(?!\.[\p{L}\p{N}_-])(?!\()/u;
|
|
14
|
+
const nativeWord: Partial<Record<WorkflowName, string>> = {
|
|
15
|
+
"ulw-plan": "ultrathink", "ulw-loop": "orchestrate", "ulw-execute": "orchestrate",
|
|
16
|
+
"mass-ulw": "workflowz", "ulw-research": "workflowz",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Only the original authorized user's leading invocation is eligible. */
|
|
20
|
+
function invocation(text: string): { name: WorkflowName; length: number } | null {
|
|
21
|
+
// Unlike ULW commands, native jevify is lowercase prose, never a slash command.
|
|
22
|
+
const native = /^\s*jevify(?=$|[\s:.,!?])/.exec(text);
|
|
23
|
+
if (native && !identifierTail.test(text.slice(native[0].length))) return { name: "jevify", length: native[0].length };
|
|
24
|
+
const prefix = /^\s*\/?/.exec(text)![0].length;
|
|
25
|
+
const leading = text.slice(prefix);
|
|
26
|
+
for (const [name, expression] of aliases) {
|
|
27
|
+
const match = expression.exec(leading);
|
|
28
|
+
if (match && /^(?:[\s:.,!?]|$)/.test(leading.slice(match[0].length))
|
|
29
|
+
&& !identifierTail.test(leading.slice(match[0].length))) return { name, length: prefix + match[0].length };
|
|
30
|
+
}
|
|
31
|
+
const plain = /^(?:ultrawork|ulw)\b/i.exec(leading);
|
|
32
|
+
if (!plain) return null;
|
|
33
|
+
const tail = leading.slice(plain[0].length);
|
|
34
|
+
if (/^[-_.]?[A-Za-z0-9]*[/\\]/.test(tail)) return null;
|
|
35
|
+
// Native ULW permits a suffix only for its named workflow family; unsupported
|
|
36
|
+
// identifiers and paths are data. Do not search past quotes or negations.
|
|
37
|
+
if (identifierTail.test(tail) && !/^[-_](?:loop|plan|research|execute|mass)(?![-_.]?[A-Za-z0-9])/i.test(tail)) return null;
|
|
38
|
+
return { name: "ulw", length: prefix + plain[0].length };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function leadingWorkflow(text: string): WorkflowName | null {
|
|
42
|
+
return invocation(text)?.name ?? null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function workflowChoice(value: WorkflowChoice | undefined): WorkflowChoice | null {
|
|
46
|
+
if (value === undefined) return null;
|
|
47
|
+
if (!value || typeof value !== "object" || !WORKFLOW_NAMES.includes(value.name)
|
|
48
|
+
|| typeof value.reason !== "string" || !value.reason.trim()
|
|
49
|
+
|| Object.keys(value).some(key => key !== "name" && key !== "reason")) {
|
|
50
|
+
throw new Error("workflow requires a supported name and a nonempty reason");
|
|
51
|
+
}
|
|
52
|
+
return { name: value.name, reason: value.reason };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Head selection is typed authority; a brief/message is never a selector. */
|
|
56
|
+
export function headWorkflow(sourceId: string, originalText: string, choice: WorkflowChoice | undefined): WorkflowActivation | null {
|
|
57
|
+
const selected = workflowChoice(choice);
|
|
58
|
+
if (!selected) return null;
|
|
59
|
+
const user = leadingWorkflow(originalText);
|
|
60
|
+
if (user && user !== selected.name) throw new Error("Head workflow conflicts with the original user's workflow invocation");
|
|
61
|
+
return { ...selected, sourceId, provenance: "head" };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Native matchers must not treat routing/brief/report prose as user keywords. */
|
|
65
|
+
export function workflowContext(envelope: string): string {
|
|
66
|
+
let longest = 2;
|
|
67
|
+
for (const match of envelope.matchAll(/`+/g)) longest = Math.max(longest, match[0].length);
|
|
68
|
+
const fence = "`".repeat(longest + 1);
|
|
69
|
+
return `${fence}superagent-runtime-context\n${envelope}\n${fence}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Keep user native keywords (including quoted/negative ones) byte-for-byte. */
|
|
73
|
+
export function workflowPrompt(activation: WorkflowActivation | null, originalText: string, envelope: string): string {
|
|
74
|
+
if (!activation) return envelope;
|
|
75
|
+
const leading = invocation(originalText);
|
|
76
|
+
let request = leading?.name === activation.name ? originalText : `${activation.name}\n\n${originalText}`;
|
|
77
|
+
const selected = invocation(request)!;
|
|
78
|
+
const keyword = nativeWord[activation.name];
|
|
79
|
+
// Apply only the native bridge's default. A raw user mention, even quoted or
|
|
80
|
+
// negated, suppresses that default and is left for OMP's native prose matcher.
|
|
81
|
+
// Check before adding context, whose metadata must not change this decision.
|
|
82
|
+
if (keyword && !nativeWords.test(originalText.slice(leading?.length ?? 0))
|
|
83
|
+
&& /^(?:\s|$)/.test(request.slice(selected.length))) {
|
|
84
|
+
request = `${request.slice(0, selected.length)} ${keyword}${request.slice(selected.length)}`;
|
|
85
|
+
}
|
|
86
|
+
return `${request}\n\n${workflowContext(envelope)}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function advertisedWorkflow(value: unknown, name: WorkflowName): boolean {
|
|
90
|
+
if (!value || typeof value !== "object" || !("commands" in value) || !Array.isArray(value.commands)) return false;
|
|
91
|
+
return value.commands.some(command => command && typeof command === "object"
|
|
92
|
+
&& command.name === name && command.source === "extension"
|
|
93
|
+
&& command.description === `Run the OMP-adapted ${name} workflow`);
|
|
94
|
+
}
|