@amaster.ai/employee-runtime-connector 0.1.1-beta.63 → 0.1.1-beta.65

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.
@@ -2776,6 +2776,124 @@ export default function amasterEffectiveToolsAttestor(pi) {
2776
2776
  `;
2777
2777
  }
2778
2778
 
2779
+ // src/amaster-runtime-daemon/pi-role-skills-visibility.mjs
2780
+ var MANAGED_PI_ROLE_SKILLS_VISIBILITY_FILENAME = "amaster-role-skills-visibility.js";
2781
+ function managedPiRoleSkillsVisibilityExtensionSource(expectedSkills) {
2782
+ return String.raw`import { readFileSync, realpathSync } from "node:fs";
2783
+
2784
+ const EXPECTED_SKILLS = ${JSON.stringify(expectedSkills)};
2785
+
2786
+ function escapeXml(value) {
2787
+ return String(value)
2788
+ .replace(/&/g, "&")
2789
+ .replace(/</g, "&lt;")
2790
+ .replace(/>/g, "&gt;")
2791
+ .replace(/\"/g, "&quot;")
2792
+ .replace(/'/g, "&apos;");
2793
+ }
2794
+
2795
+ function skillXml(skill) {
2796
+ return [
2797
+ " <skill>",
2798
+ " <name>" + escapeXml(skill.name) + "</name>",
2799
+ " <description>" + escapeXml(skill.description) + "</description>",
2800
+ " <location>" + escapeXml(skill.filePath) + "</location>",
2801
+ " </skill>",
2802
+ ].join("\n");
2803
+ }
2804
+
2805
+ function yamlString(value) {
2806
+ const trimmed = value.trim();
2807
+ if (trimmed.startsWith("\"") && trimmed.endsWith("\"")) {
2808
+ try {
2809
+ return JSON.parse(trimmed);
2810
+ } catch {}
2811
+ }
2812
+ if (trimmed.startsWith("'") && trimmed.endsWith("'")) {
2813
+ return trimmed.slice(1, -1).replace(/''/g, "'");
2814
+ }
2815
+ return trimmed;
2816
+ }
2817
+
2818
+ function frontmatterField(frontmatter, field) {
2819
+ const lines = frontmatter.split(/\r?\n/);
2820
+ const prefix = field + ":";
2821
+ const index = lines.findIndex((line) => line.startsWith(prefix));
2822
+ if (index < 0) return null;
2823
+ const value = lines[index].slice(prefix.length).trim();
2824
+ if (value !== ">" && value !== "|" && value !== ">-" && value !== "|-") {
2825
+ return yamlString(value);
2826
+ }
2827
+ const block = [];
2828
+ for (let lineIndex = index + 1; lineIndex < lines.length; lineIndex += 1) {
2829
+ const line = lines[lineIndex];
2830
+ if (line && !/^\s/.test(line)) break;
2831
+ block.push(line.trim());
2832
+ }
2833
+ return value.startsWith(">") ? block.join(" ").trim() : block.join("\n").trim();
2834
+ }
2835
+
2836
+ function readRoleSkill(expected) {
2837
+ const filePath = realpathSync(expected.filePath);
2838
+ const source = readFileSync(filePath, "utf8");
2839
+ const match = source.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
2840
+ if (!match) throw new Error("role skill frontmatter missing: " + expected.name);
2841
+ const name = frontmatterField(match[1], "name");
2842
+ const description = frontmatterField(match[1], "description");
2843
+ const hidden = frontmatterField(match[1], "disable-model-invocation")?.toLowerCase() === "true";
2844
+ if (name !== expected.name || !description || !hidden) {
2845
+ throw new Error("role skill metadata mismatch: " + expected.name);
2846
+ }
2847
+ return {
2848
+ name,
2849
+ description,
2850
+ filePath,
2851
+ };
2852
+ }
2853
+
2854
+ function appendPromotedSkills(systemPrompt, skills) {
2855
+ if (skills.length === 0) return systemPrompt;
2856
+ const entries = skills.map(skillXml).join("\n");
2857
+ const closingTag = "</available_skills>";
2858
+ const closingIndex = systemPrompt.lastIndexOf(closingTag);
2859
+ if (closingIndex >= 0) {
2860
+ return systemPrompt.slice(0, closingIndex) + entries + "\n" + systemPrompt.slice(closingIndex);
2861
+ }
2862
+ return systemPrompt + [
2863
+ "",
2864
+ "",
2865
+ "The following skills provide specialized instructions for specific tasks.",
2866
+ "Use the read tool to load a skill's file when the task matches its description.",
2867
+ "When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.",
2868
+ "",
2869
+ "<available_skills>",
2870
+ entries,
2871
+ closingTag,
2872
+ ].join("\n");
2873
+ }
2874
+
2875
+ export default function amasterRoleSkillsVisibility(pi) {
2876
+ pi.on("before_agent_start", (event) => {
2877
+ try {
2878
+ if (!Array.isArray(event.systemPromptOptions?.selectedTools)
2879
+ || !event.systemPromptOptions.selectedTools.includes("read")) {
2880
+ throw new Error("role skills require the read tool");
2881
+ }
2882
+ const promotedSkills = [];
2883
+ for (const expected of EXPECTED_SKILLS) {
2884
+ promotedSkills.push(readRoleSkill(expected));
2885
+ }
2886
+ const systemPrompt = appendPromotedSkills(event.systemPrompt, promotedSkills);
2887
+ return systemPrompt === event.systemPrompt ? undefined : { systemPrompt };
2888
+ } catch {
2889
+ process.stderr.write("pi_role_skills_visibility_rejected\n");
2890
+ process.exit(78);
2891
+ }
2892
+ });
2893
+ }
2894
+ `;
2895
+ }
2896
+
2779
2897
  // src/amaster-runtime-daemon/pi-managed-mcp-profile.mjs
2780
2898
  var MANAGED_PI_MCP_TOOL_MODE = "proxy_only";
2781
2899
  var MANAGED_PI_DIRECT_TYPED_MCP_TOOL_MODE = "direct_typed";
@@ -3425,23 +3543,6 @@ function createManagedPiMcpProfileApi(options = {}) {
3425
3543
  return { home, settingsEnv, protectedValues };
3426
3544
  }
3427
3545
  const SKILL_PROFILE_NAME = /^[a-z0-9-]+$/;
3428
- const DISABLE_MODEL_INVOCATION_LINE = /^[ \t]*disable-model-invocation:[ \t]*true[ \t]*\r?$/m;
3429
- function copyTreeNoLinks(source, target) {
3430
- const stat = lstatSync3(source);
3431
- if (stat.isSymbolicLink()) throw new Error("pi_managed_mcp_source_symlink_blocked");
3432
- if (stat.isDirectory()) {
3433
- mkdirSync3(target, { recursive: true, mode: 448 });
3434
- chmodSync3(target, 448);
3435
- for (const entry of readdirSync3(source)) {
3436
- copyTreeNoLinks(join4(source, entry), join4(target, entry));
3437
- }
3438
- return;
3439
- }
3440
- if (!stat.isFile()) throw new Error("pi_managed_mcp_source_type_blocked");
3441
- mkdirSync3(dirname3(target), { recursive: true, mode: 448 });
3442
- copyFileSync(source, target);
3443
- chmodSync3(target, 384 | stat.mode & 73);
3444
- }
3445
3546
  function readSkillProfile(piHome, skillProfile) {
3446
3547
  const agentsRoot = resolve3(piHome, "agents");
3447
3548
  const agentFile = resolve3(agentsRoot, `${skillProfile}.md`);
@@ -3472,9 +3573,7 @@ function createManagedPiMcpProfileApi(options = {}) {
3472
3573
  }
3473
3574
  return profile;
3474
3575
  }
3475
- function materializeManagedRoleSkills(piHome, skillsDir, skillProfiles) {
3476
- if (existsSync3(skillsDir)) throw new Error("pi_managed_mcp_role_skills_exists");
3477
- const enabled = [];
3576
+ function resolveManagedRoleSkills(piHome, skillProfiles) {
3478
3577
  const entriesByName = /* @__PURE__ */ new Map();
3479
3578
  for (const skillProfile of skillProfiles) {
3480
3579
  for (const entry of readSkillProfile(piHome, skillProfile)) {
@@ -3488,16 +3587,14 @@ function createManagedPiMcpProfileApi(options = {}) {
3488
3587
  entriesByName.set(entry.name, entry);
3489
3588
  }
3490
3589
  }
3491
- for (const entry of entriesByName.values()) {
3492
- const target = join4(skillsDir, entry.name);
3493
- copyTreeNoLinks(entry.source, target);
3494
- const skillFile = join4(target, "SKILL.md");
3495
- writeFileSync3(skillFile, readFileSync3(skillFile, "utf8").replace(DISABLE_MODEL_INVOCATION_LINE, ""), {
3496
- mode: 384
3497
- });
3498
- enabled.push(entry.name);
3499
- }
3500
- return { skillsDir, enabled };
3590
+ const entries = [...entriesByName.values()].map((entry) => ({
3591
+ name: entry.name,
3592
+ filePath: realpathSync2(join4(entry.source, "SKILL.md"))
3593
+ }));
3594
+ return {
3595
+ enabled: entries.map((entry) => entry.name),
3596
+ entries
3597
+ };
3501
3598
  }
3502
3599
  function requestedSkillProfiles(input) {
3503
3600
  return [...new Set(
@@ -3840,16 +3937,14 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3840
3937
  extensionArgs: [...extensionArgs]
3841
3938
  };
3842
3939
  }
3843
- const skillArgs = ["--no-approve"];
3844
3940
  let enabledRoleSkills = null;
3845
3941
  const skillProfiles = requestedSkillProfiles(input);
3846
3942
  if (skillProfiles.length > 0) {
3847
- const roleSkills = materializeManagedRoleSkills(
3848
- sharedRuntime.home,
3849
- join4(profileRoot, "role-skills"),
3850
- skillProfiles
3943
+ const roleSkills = resolveManagedRoleSkills(sharedRuntime.home, skillProfiles);
3944
+ writeProfileExtension(
3945
+ MANAGED_PI_ROLE_SKILLS_VISIBILITY_FILENAME,
3946
+ managedPiRoleSkillsVisibilityExtensionSource(roleSkills.entries)
3851
3947
  );
3852
- skillArgs.push("--skill", roleSkills.skillsDir);
3853
3948
  enabledRoleSkills = roleSkills.enabled;
3854
3949
  }
3855
3950
  const env = {
@@ -3916,7 +4011,6 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3916
4011
  markerPath,
3917
4012
  env,
3918
4013
  extensionArgs,
3919
- skillArgs,
3920
4014
  spawnIdentity,
3921
4015
  workspaceMcpConfigPath,
3922
4016
  ...directAttestationInput ? {
@@ -4107,16 +4201,19 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
4107
4201
  };
4108
4202
  writePrivateFile2(configPath, `${JSON.stringify(config, null, 2)}
4109
4203
  `);
4204
+ const extensionArgs = [];
4110
4205
  const skillProfiles = requestedSkillProfiles(input);
4111
- const skillArgs = ["--no-approve"];
4112
4206
  let enabledRoleSkills = null;
4113
4207
  if (skillProfiles.length > 0) {
4114
- const roleSkills = materializeManagedRoleSkills(
4115
- sourcePiHome,
4116
- join4(profileRoot, "role-skills"),
4117
- skillProfiles
4208
+ const roleSkills = resolveManagedRoleSkills(sourcePiHome, skillProfiles);
4209
+ const extensionsDir = join4(profileRoot, "extensions");
4210
+ const extensionPath = join4(extensionsDir, MANAGED_PI_ROLE_SKILLS_VISIBILITY_FILENAME);
4211
+ mkdirSync3(extensionsDir, { recursive: true, mode: 448 });
4212
+ writePrivateFile2(
4213
+ extensionPath,
4214
+ managedPiRoleSkillsVisibilityExtensionSource(roleSkills.entries)
4118
4215
  );
4119
- skillArgs.push("--skill", roleSkills.skillsDir);
4216
+ extensionArgs.push("--extension", extensionPath);
4120
4217
  enabledRoleSkills = roleSkills.enabled;
4121
4218
  }
4122
4219
  const env = {
@@ -4158,7 +4255,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
4158
4255
  configPath,
4159
4256
  markerPath,
4160
4257
  env,
4161
- skillArgs,
4258
+ extensionArgs,
4162
4259
  toolAllowlist: null,
4163
4260
  protectedValues: [.../* @__PURE__ */ new Set([sessionToken, ...seededRuntime.protectedValues])],
4164
4261
  attestation: {
@@ -10438,7 +10535,7 @@ var source_acquisition_compatibility_default = {
10438
10535
  };
10439
10536
 
10440
10537
  // src/amaster-runtime-daemon.mjs
10441
- var CONNECTOR_VERSION = "0.1.1-beta.63";
10538
+ var CONNECTOR_VERSION = "0.1.1-beta.65";
10442
10539
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
10443
10540
  var SOURCE_ACQUISITION_CAPABILITY = source_acquisition_compatibility_default.profileVersion;
10444
10541
  var SOURCE_ACQUISITION_PROFILE_VERSION = source_acquisition_compatibility_default.profileVersion;
@@ -15181,8 +15278,8 @@ async function executeRunCommand(config, command) {
15181
15278
  if (executor.kind === "pi" && Array.isArray(managedMcpProfile.extensionArgs) && managedMcpProfile.extensionArgs.length > 0) {
15182
15279
  invocation.args = [...invocation.args, ...managedMcpProfile.extensionArgs];
15183
15280
  }
15184
- if (executor.kind === "pi" && Array.isArray(managedMcpProfile.skillArgs) && managedMcpProfile.skillArgs.length > 0) {
15185
- invocation.args = [...invocation.args, ...managedMcpProfile.skillArgs];
15281
+ if (executor.kind === "pi") {
15282
+ invocation.args = [...invocation.args, "--no-approve"];
15186
15283
  }
15187
15284
  await ingestLog(config, command, "system", "info", desktopDelegatedRunnerEnabled(config) && executor.kind === "pi" ? "Prepared desktop delegated Pi runtime action bridge" : `Attested isolated ${executor.kind} managed MCP profile`, {
15188
15285
  presentationKind: "managed_mcp_attestation",
@@ -6,7 +6,7 @@ import { basename, dirname, join, resolve } from "node:path";
6
6
  import { homedir, hostname } from "node:os";
7
7
  import { fileURLToPath } from "node:url";
8
8
 
9
- const CONNECTOR_VERSION = "0.1.1-beta.63";
9
+ const CONNECTOR_VERSION = "0.1.1-beta.65";
10
10
 
11
11
  const CAPABILITIES = [
12
12
  "remote_registration",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/employee-runtime-connector",
3
- "version": "0.1.1-beta.63",
3
+ "version": "0.1.1-beta.65",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",