@femtomc/mu-agent 26.2.49 → 26.2.51

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 +1 @@
1
- {"version":3,"file":"messaging-setup.d.ts","sourceRoot":"","sources":["../../src/extensions/messaging-setup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,YAAY,EAA6C,MAAM,+BAA+B,CAAC;AA2iC7G,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,YAAY,QA+PvD;AAED,eAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"messaging-setup.d.ts","sourceRoot":"","sources":["../../src/extensions/messaging-setup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,YAAY,EAA6C,MAAM,+BAA+B,CAAC;AAwiC7G,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,YAAY,QA0PvD;AAED,eAAe,uBAAuB,CAAC"}
@@ -761,19 +761,16 @@ function buildAgentSetupPrompt(opts) {
761
761
  const normalizedBase = normalizePublicBaseUrl(opts.publicBaseUrl);
762
762
  const webhookUrl = normalizedBase ? `${normalizedBase}${opts.plan.route}` : opts.plan.webhook_url;
763
763
  const verifyFlag = normalizedBase ? ` --public-base-url ${normalizedBase}` : "";
764
- const notesBlock = opts.check.notes.length > 0 ? `[Notes]\n${opts.check.notes.map((n) => `- ${n}`).join("\n")}` : "";
765
764
  return interpolateTemplate(MESSAGING_SETUP_BRIEF_TEMPLATE, {
766
765
  adapter_name: adapter.name,
767
- action: opts.action,
766
+ adapter_id: adapter.id,
768
767
  state: opts.check.state,
769
- support: opts.check.support,
768
+ config_path: opts.configPath ?? ".mu/config.json",
770
769
  route: opts.plan.route,
771
770
  webhook_url: webhookUrl ?? "(need public base URL)",
772
771
  missing_fields: opts.check.missing.join(", ") || "(none)",
773
- next_step: opts.check.next_step,
774
772
  provider_steps: adapter.providerSetupSteps.map((step, index) => `${index + 1}. ${step}`).join("\n"),
775
773
  field_status: adapterFieldStatusLines(adapter, opts.check).join("\n"),
776
- notes: notesBlock,
777
774
  verify_command: `/mu-setup verify ${adapter.id}${verifyFlag}`,
778
775
  });
779
776
  }
@@ -797,9 +794,9 @@ async function maybeDispatchAgentSetupBrief(opts) {
797
794
  return false;
798
795
  const plan = buildPlan(check, opts.parsed.publicBaseUrl);
799
796
  const prompt = buildAgentSetupPrompt({
800
- action: opts.parsed.action,
801
797
  check,
802
798
  plan,
799
+ configPath: opts.runtime.configPath,
803
800
  publicBaseUrl: opts.parsed.publicBaseUrl,
804
801
  });
805
802
  dispatchSetupPromptToAgent(opts.pi, opts.ctx, prompt);
@@ -879,11 +876,14 @@ export function messagingSetupExtension(pi) {
879
876
  public_base_url: Type.Optional(Type.String({
880
877
  description: "Optional public base URL used to compute expected webhook endpoints (e.g. https://example.ngrok.app)",
881
878
  })),
879
+ fields: Type.Optional(Type.Record(Type.String(), Type.String(), {
880
+ description: "Config field overrides for apply action. Keys are field names (e.g. bot_token, webhook_secret), values are the secrets/tokens to write.",
881
+ })),
882
882
  });
883
883
  pi.registerTool({
884
884
  name: "mu_messaging_setup",
885
885
  label: "Messaging Setup",
886
- description: "Messaging setup workflow. Actions: check/preflight/guide/plan/apply/verify. Use plan -> apply -> verify.",
886
+ description: "Messaging setup workflow. Actions: check/preflight/guide/plan/apply/verify. For apply, pass field values via the fields parameter (e.g. fields={bot_token:'...', webhook_secret:'...'}).",
887
887
  parameters: SetupParams,
888
888
  async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
889
889
  const adapterId = params.adapter ? normalizeAdapterId(params.adapter) : null;
@@ -915,9 +915,9 @@ export function messagingSetupExtension(pi) {
915
915
  }
916
916
  const plan = buildPlan(check, params.public_base_url);
917
917
  const brief = buildAgentSetupPrompt({
918
- action: params.action,
919
918
  check,
920
919
  plan,
920
+ configPath: runtime.configPath,
921
921
  publicBaseUrl: params.public_base_url,
922
922
  });
923
923
  return textResult(brief, { checks, runtime, adapter: adapterId, plan });
@@ -940,18 +940,14 @@ export function messagingSetupExtension(pi) {
940
940
  if (!check) {
941
941
  return textResult(`Unknown adapter: ${adapterId}`);
942
942
  }
943
- if (check.missing.length > 0) {
944
- return textResult(`Cannot apply ${adapterId}: missing required config fields (${check.missing.join(", ")}). Use /mu-setup apply ${adapterId} for guided input.`, { adapter: adapterId, missing_required_fields: check.missing });
945
- }
946
- if (!ctx.hasUI) {
947
- return textResult("Apply is blocked in non-interactive mode. Use `/mu-setup apply <adapter>` in an interactive `mu serve` session.", { adapter: adapterId, blocked: true });
948
- }
949
- const confirmed = await ctx.ui.confirm(`Apply ${adapterId} configuration?`, "This may write config and triggers control-plane reload.");
950
- if (!confirmed) {
951
- return textResult("Apply cancelled by user.", { adapter: adapterId, cancelled: true });
943
+ const overrides = params.fields ?? {};
944
+ const stillMissing = check.missing.filter((field) => !(field in overrides));
945
+ if (stillMissing.length > 0) {
946
+ return textResult(`Cannot apply ${adapterId}: missing required config fields (${stillMissing.join(", ")}). Pass them via the fields parameter or use /mu-setup apply ${adapterId} for guided input.`, { adapter: adapterId, missing_required_fields: stillMissing });
952
947
  }
953
948
  const outcome = await applyAdapterConfig({
954
949
  adapterId,
950
+ overrides,
955
951
  presence: runtime.configPresence,
956
952
  });
957
953
  if (!outcome.ok) {
@@ -1003,7 +999,7 @@ export function messagingSetupExtension(pi) {
1003
999
  }
1004
1000
  case "preflight": {
1005
1001
  const { checks, runtime } = await collectChecksCached(0);
1006
- if (await maybeDispatchAgentSetupBrief({ pi, ctx, parsed, checks })) {
1002
+ if (await maybeDispatchAgentSetupBrief({ pi, ctx, parsed, checks, runtime })) {
1007
1003
  if (runtime.fetchError) {
1008
1004
  ctx.ui.notify(`runtime note: ${runtime.fetchError}`, "warning");
1009
1005
  }
@@ -1016,7 +1012,7 @@ export function messagingSetupExtension(pi) {
1016
1012
  }
1017
1013
  case "guide": {
1018
1014
  const { checks, runtime } = await collectChecksCached(0);
1019
- if (await maybeDispatchAgentSetupBrief({ pi, ctx, parsed, checks })) {
1015
+ if (await maybeDispatchAgentSetupBrief({ pi, ctx, parsed, checks, runtime })) {
1020
1016
  if (runtime.fetchError) {
1021
1017
  ctx.ui.notify(`runtime note: ${runtime.fetchError}`, "warning");
1022
1018
  }
@@ -1031,8 +1027,8 @@ export function messagingSetupExtension(pi) {
1031
1027
  return;
1032
1028
  }
1033
1029
  case "plan": {
1034
- const { checks } = await collectChecksCached(0);
1035
- if (await maybeDispatchAgentSetupBrief({ pi, ctx, parsed, checks })) {
1030
+ const { checks, runtime } = await collectChecksCached(0);
1031
+ if (await maybeDispatchAgentSetupBrief({ pi, ctx, parsed, checks, runtime })) {
1036
1032
  await refreshMessagingStatus(ctx);
1037
1033
  return;
1038
1034
  }
@@ -1056,8 +1052,8 @@ export function messagingSetupExtension(pi) {
1056
1052
  return;
1057
1053
  }
1058
1054
  case "verify": {
1059
- const { checks } = await collectChecksCached(0);
1060
- if (await maybeDispatchAgentSetupBrief({ pi, ctx, parsed, checks })) {
1055
+ const { checks, runtime } = await collectChecksCached(0);
1056
+ if (await maybeDispatchAgentSetupBrief({ pi, ctx, parsed, checks, runtime })) {
1061
1057
  await refreshMessagingStatus(ctx);
1062
1058
  return;
1063
1059
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@femtomc/mu-agent",
3
- "version": "26.2.49",
3
+ "version": "26.2.51",
4
4
  "description": "Shared agent runtime for mu chat, orchestration roles, and serve extensions.",
5
5
  "keywords": [
6
6
  "mu",
@@ -23,7 +23,7 @@
23
23
  "prompts/**"
24
24
  ],
25
25
  "dependencies": {
26
- "@femtomc/mu-core": "26.2.49",
26
+ "@femtomc/mu-core": "26.2.51",
27
27
  "@mariozechner/pi-agent-core": "^0.52.12",
28
28
  "@mariozechner/pi-ai": "^0.52.12",
29
29
  "@mariozechner/pi-coding-agent": "^0.52.12",
@@ -1,24 +1,23 @@
1
- Help me set up {{adapter_name}} messaging integration for mu control-plane.
2
- Treat diagnostics below as authoritative and guide me step-by-step.
1
+ Set up {{adapter_name}} messaging for mu control-plane.
3
2
 
4
- [Live diagnostics]
5
- action: {{action}}
3
+ [Diagnostics]
6
4
  state: {{state}}
7
- support: {{support}}
5
+ config: {{config_path}}
8
6
  route: {{route}}
9
- expected webhook URL: {{webhook_url}}
10
- missing required config fields: {{missing_fields}}
11
- next step: {{next_step}}
7
+ webhook URL: {{webhook_url}}
8
+ missing fields: {{missing_fields}}
12
9
 
13
- [Provider setup checklist]
14
- {{provider_steps}}
15
-
16
- [Current config field status]
10
+ [Config field status]
17
11
  {{field_status}}
18
12
 
19
- {{notes}}
13
+ [Provider setup steps]
14
+ {{provider_steps}}
15
+
16
+ [Instructions]
17
+ 1) Ask the user ONLY for values you cannot generate: secrets from external providers (e.g. bot tokens from @BotFather), public base URL.
18
+ 2) Generate values you CAN create yourself (e.g. webhook_secret — run `openssl rand -hex 32` via Bash).
19
+ 3) Write config via mu_messaging_setup tool: call mu_messaging_setup(action="apply", adapter="{{adapter_id}}", fields={...}) with ALL missing field values. This writes config and reloads the control plane in one step.
20
+ 4) After config is applied, call provider APIs (e.g. Telegram setWebhook) via Bash/curl.
21
+ 5) Run {{verify_command}} to confirm everything works.
20
22
 
21
- [How you should respond]
22
- 1) Ask for any missing values (secrets, public base URL, etc).
23
- 2) Give exact provider-console steps and copy/paste commands.
24
- 3) Finish with verification instructions using: {{verify_command}}
23
+ Do NOT give the user copy-paste commands or tutorials. Do the work yourself.