@femtomc/mu-server 26.2.31 → 26.2.32

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.
@@ -1,4 +1,4 @@
1
- import { type Channel } from "@femtomc/mu-control-plane";
1
+ import { type Channel, type MessagingMetaAgentBackend, MessagingMetaAgentRuntime } from "@femtomc/mu-control-plane";
2
2
  export declare const ENV_VARS: {
3
3
  readonly slack: {
4
4
  readonly signingSecret: "MU_SLACK_SIGNING_SECRET";
@@ -12,6 +12,17 @@ export declare const ENV_VARS: {
12
12
  readonly botUsername: "MU_TELEGRAM_BOT_USERNAME";
13
13
  readonly tenantId: "MU_TELEGRAM_TENANT_ID";
14
14
  };
15
+ readonly metaAgent: {
16
+ readonly enabled: "MU_META_AGENT_ENABLED";
17
+ readonly enabledChannels: "MU_META_AGENT_ENABLED_CHANNELS";
18
+ readonly runTriggersEnabled: "MU_META_AGENT_RUN_TRIGGERS_ENABLED";
19
+ readonly provider: "MU_META_AGENT_PROVIDER";
20
+ readonly model: "MU_META_AGENT_MODEL";
21
+ readonly thinking: "MU_META_AGENT_THINKING";
22
+ readonly systemPrompt: "MU_META_AGENT_SYSTEM_PROMPT";
23
+ readonly timeoutMs: "MU_META_AGENT_TIMEOUT_MS";
24
+ readonly piBinary: "MU_META_AGENT_PI_BINARY";
25
+ };
15
26
  };
16
27
  export type ActiveAdapter = {
17
28
  name: Channel;
@@ -36,8 +47,11 @@ type DetectedAdapter = {
36
47
  tenantId: string | null;
37
48
  };
38
49
  export declare function detectAdapters(env: Record<string, string | undefined>): DetectedAdapter[];
39
- export declare function bootstrapControlPlane(opts: {
50
+ export type BootstrapControlPlaneOpts = {
40
51
  repoRoot: string;
41
52
  env?: Record<string, string | undefined>;
42
- }): Promise<ControlPlaneHandle | null>;
53
+ metaAgentRuntime?: MessagingMetaAgentRuntime | null;
54
+ metaAgentBackend?: MessagingMetaAgentBackend;
55
+ };
56
+ export declare function bootstrapControlPlane(opts: BootstrapControlPlaneOpts): Promise<ControlPlaneHandle | null>;
43
57
  export {};
@@ -1,4 +1,4 @@
1
- import { ControlPlaneRuntime, ControlPlaneCommandPipeline, ControlPlaneOutbox, ControlPlaneOutboxDispatcher, SlackControlPlaneAdapter, DiscordControlPlaneAdapter, TelegramControlPlaneAdapter, getControlPlanePaths, } from "@femtomc/mu-control-plane";
1
+ import { ApprovedCommandBroker, CommandContextResolver, ControlPlaneCommandPipeline, ControlPlaneOutbox, ControlPlaneOutboxDispatcher, ControlPlaneRuntime, DiscordControlPlaneAdapter, getControlPlanePaths, MessagingMetaAgentRuntime, PiMessagingMetaAgentBackend, SlackControlPlaneAdapter, TelegramControlPlaneAdapter, } from "@femtomc/mu-control-plane";
2
2
  export const ENV_VARS = {
3
3
  slack: { signingSecret: "MU_SLACK_SIGNING_SECRET" },
4
4
  discord: { signingSecret: "MU_DISCORD_SIGNING_SECRET" },
@@ -8,6 +8,17 @@ export const ENV_VARS = {
8
8
  botUsername: "MU_TELEGRAM_BOT_USERNAME",
9
9
  tenantId: "MU_TELEGRAM_TENANT_ID",
10
10
  },
11
+ metaAgent: {
12
+ enabled: "MU_META_AGENT_ENABLED",
13
+ enabledChannels: "MU_META_AGENT_ENABLED_CHANNELS",
14
+ runTriggersEnabled: "MU_META_AGENT_RUN_TRIGGERS_ENABLED",
15
+ provider: "MU_META_AGENT_PROVIDER",
16
+ model: "MU_META_AGENT_MODEL",
17
+ thinking: "MU_META_AGENT_THINKING",
18
+ systemPrompt: "MU_META_AGENT_SYSTEM_PROMPT",
19
+ timeoutMs: "MU_META_AGENT_TIMEOUT_MS",
20
+ piBinary: "MU_META_AGENT_PI_BINARY",
21
+ },
11
22
  };
12
23
  const ROUTE_MAP = {
13
24
  slack: "/webhooks/slack",
@@ -36,6 +47,66 @@ export function detectAdapters(env) {
36
47
  }
37
48
  return adapters;
38
49
  }
50
+ function parseBooleanEnv(value, defaultValue) {
51
+ if (value == null) {
52
+ return defaultValue;
53
+ }
54
+ const normalized = value.trim().toLowerCase();
55
+ if (["1", "true", "yes", "on", "enabled"].includes(normalized)) {
56
+ return true;
57
+ }
58
+ if (["0", "false", "no", "off", "disabled"].includes(normalized)) {
59
+ return false;
60
+ }
61
+ return defaultValue;
62
+ }
63
+ function parsePositiveIntEnv(value) {
64
+ if (!value) {
65
+ return undefined;
66
+ }
67
+ const parsed = Number.parseInt(value, 10);
68
+ if (!Number.isFinite(parsed) || parsed <= 0) {
69
+ return undefined;
70
+ }
71
+ return parsed;
72
+ }
73
+ function parseCsvEnv(value) {
74
+ if (!value) {
75
+ return undefined;
76
+ }
77
+ const tokens = value
78
+ .split(",")
79
+ .map((token) => token.trim().toLowerCase())
80
+ .filter((token) => token.length > 0);
81
+ return tokens.length > 0 ? tokens : undefined;
82
+ }
83
+ function buildMessagingMetaAgentRuntime(opts) {
84
+ const enabled = parseBooleanEnv(opts.env[ENV_VARS.metaAgent.enabled], true);
85
+ if (!enabled) {
86
+ return null;
87
+ }
88
+ const runTriggersEnabled = parseBooleanEnv(opts.env[ENV_VARS.metaAgent.runTriggersEnabled], true);
89
+ const enabledChannels = parseCsvEnv(opts.env[ENV_VARS.metaAgent.enabledChannels]);
90
+ const timeoutMs = parsePositiveIntEnv(opts.env[ENV_VARS.metaAgent.timeoutMs]);
91
+ const backend = opts.backend ??
92
+ new PiMessagingMetaAgentBackend({
93
+ provider: opts.env[ENV_VARS.metaAgent.provider],
94
+ model: opts.env[ENV_VARS.metaAgent.model],
95
+ thinking: opts.env[ENV_VARS.metaAgent.thinking],
96
+ systemPrompt: opts.env[ENV_VARS.metaAgent.systemPrompt],
97
+ timeoutMs,
98
+ piBinary: opts.env[ENV_VARS.metaAgent.piBinary],
99
+ });
100
+ return new MessagingMetaAgentRuntime({
101
+ backend,
102
+ broker: new ApprovedCommandBroker({
103
+ runTriggersEnabled,
104
+ contextResolver: new CommandContextResolver({ allowedRepoRoots: [opts.repoRoot] }),
105
+ }),
106
+ enabled,
107
+ enabledChannels,
108
+ });
109
+ }
39
110
  export async function bootstrapControlPlane(opts) {
40
111
  const env = opts.env ?? process.env;
41
112
  const detected = detectAdapters(env);
@@ -45,7 +116,14 @@ export async function bootstrapControlPlane(opts) {
45
116
  const paths = getControlPlanePaths(opts.repoRoot);
46
117
  const runtime = new ControlPlaneRuntime({ repoRoot: opts.repoRoot });
47
118
  await runtime.start();
48
- const pipeline = new ControlPlaneCommandPipeline({ runtime });
119
+ const metaAgent = opts.metaAgentRuntime !== undefined
120
+ ? opts.metaAgentRuntime
121
+ : buildMessagingMetaAgentRuntime({
122
+ repoRoot: opts.repoRoot,
123
+ env,
124
+ backend: opts.metaAgentBackend,
125
+ });
126
+ const pipeline = new ControlPlaneCommandPipeline({ runtime, metaAgent });
49
127
  await pipeline.start();
50
128
  const outbox = new ControlPlaneOutbox(paths.outboxPath);
51
129
  await outbox.load();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@femtomc/mu-server",
3
- "version": "26.2.31",
3
+ "version": "26.2.32",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -23,9 +23,9 @@
23
23
  "start": "bun run dist/cli.js"
24
24
  },
25
25
  "dependencies": {
26
- "@femtomc/mu-core": "26.2.31",
27
- "@femtomc/mu-issue": "26.2.31",
28
- "@femtomc/mu-forum": "26.2.31",
29
- "@femtomc/mu-control-plane": "26.2.31"
26
+ "@femtomc/mu-core": "26.2.32",
27
+ "@femtomc/mu-issue": "26.2.32",
28
+ "@femtomc/mu-forum": "26.2.32",
29
+ "@femtomc/mu-control-plane": "26.2.32"
30
30
  }
31
31
  }