@amaster.ai/employee-runtime-connector 0.1.1-beta.4 → 0.1.1-beta.5

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.
@@ -2096,15 +2096,28 @@ export default function amasterEffectiveToolsAttestor(pi) {
2096
2096
  }
2097
2097
 
2098
2098
  const allTools = pi.getAllTools();
2099
+ if (allTools.some((tool) => typeof tool.name !== "string" || !tool.name)) {
2100
+ throw new Error("registered tool identity mismatch");
2101
+ }
2102
+ const activeToolNames = pi.getActiveTools();
2103
+ if (activeToolNames.some((name) => typeof name !== "string" || !name)) {
2104
+ throw new Error("active tool identity mismatch");
2105
+ }
2106
+ activeToolNames.sort();
2107
+ const activeToolNameSet = new Set(activeToolNames);
2099
2108
  const proxyPresent = allTools.some((tool) => tool.name === "mcp");
2109
+ const nonCatalogTools = activeToolNames.filter((name) => !expectedByName.has(name));
2100
2110
  const adapterTools = allTools.filter((tool) => sourceIsMcpAdapter(tool.sourceInfo));
2101
- const directTools = adapterTools.filter((tool) => tool.name !== "mcp").map((tool) => ({
2111
+ const directTools = adapterTools.filter((tool) => tool.name !== "mcp" && activeToolNameSet.has(tool.name)).map((tool) => ({
2102
2112
  name: tool.name,
2103
2113
  schemaHash: schemaHash(tool.parameters),
2104
2114
  }));
2105
2115
  const actualByName = new Map(directTools.map((entry) => [entry.name, entry]));
2106
- const missing = [...expectedByName.keys()].filter((name) => !actualByName.has(name)).sort();
2107
- const unexpected = [...actualByName.keys()].filter((name) => !expectedByName.has(name)).sort();
2116
+ const missing = [...expectedByName.keys()].filter((name) => !actualByName.has(name) || !activeToolNameSet.has(name)).sort();
2117
+ const unexpected = adapterTools
2118
+ .map((tool) => tool.name)
2119
+ .filter((name) => name !== "mcp" && !expectedByName.has(name))
2120
+ .sort();
2108
2121
  const schemaMismatches = [...expectedByName.entries()].flatMap(([name, expected]) => {
2109
2122
  const actual = actualByName.get(name);
2110
2123
  return actual && actual.schemaHash !== expected.effectiveSchemaHash
@@ -2112,8 +2125,8 @@ export default function amasterEffectiveToolsAttestor(pi) {
2112
2125
  : [];
2113
2126
  });
2114
2127
  const effectiveSetHash = toolSetHash(directTools);
2115
- if (proxyPresent || missing.length > 0 || unexpected.length > 0 || schemaMismatches.length > 0) {
2116
- throw new Error("effective tool surface mismatch: proxy=" + proxyPresent + " missing=" + missing.join(",") + " unexpected=" + unexpected.join(",") + " schemas=" + schemaMismatches.map((entry) => entry.name).join(","));
2128
+ if (proxyPresent || nonCatalogTools.length > 0 || missing.length > 0 || unexpected.length > 0 || schemaMismatches.length > 0) {
2129
+ throw new Error("effective tool surface mismatch: proxy=" + proxyPresent + " nonCatalog=" + nonCatalogTools.join(",") + " missing=" + missing.join(",") + " unexpected=" + unexpected.join(",") + " schemas=" + schemaMismatches.map((entry) => entry.name).join(","));
2117
2130
  }
2118
2131
  if (effectiveSetHash !== manifest.effectiveSetHash) throw new Error("effective tool set hash mismatch");
2119
2132
  receipt = {
@@ -2168,6 +2181,18 @@ var MANAGED_PI_MCP_TOOL_MODE = "proxy_only";
2168
2181
  var MANAGED_PI_DIRECT_TYPED_MCP_TOOL_MODE = "direct_typed";
2169
2182
  var MANAGED_PI_MCP_ARGS_NORMALIZATION = "json_string_control_characters_v1";
2170
2183
  var MANAGED_PI_MCP_ARGS_NORMALIZER_FILENAME = "amaster-mcp-args-normalizer.js";
2184
+ function applyManagedPiToolAllowlist(args, profile) {
2185
+ const toolAllowlist = Array.isArray(profile?.toolAllowlist) ? profile.toolAllowlist.filter((name) => typeof name === "string" && name) : [];
2186
+ if (toolAllowlist.length === 0) return [...args];
2187
+ const printArgIndex = Math.max(args.lastIndexOf("-p"), args.lastIndexOf("--print"));
2188
+ if (printArgIndex < 0) throw new Error("pi_managed_mcp_invocation_invalid: print mode argument missing");
2189
+ return [
2190
+ ...args.slice(0, printArgIndex),
2191
+ "--tools",
2192
+ toolAllowlist.join(","),
2193
+ ...args.slice(printArgIndex)
2194
+ ];
2195
+ }
2171
2196
  function createManagedPiMcpProfileApi(options = {}) {
2172
2197
  const spawnSyncImpl = typeof options.spawnSync === "function" ? options.spawnSync : spawnSync2;
2173
2198
  const nowImpl = typeof options.now === "function" ? options.now : Date.now;
@@ -2264,6 +2289,12 @@ function createManagedPiMcpProfileApi(options = {}) {
2264
2289
  ]);
2265
2290
  const FORBIDDEN_ARGV = /* @__PURE__ */ new Set([
2266
2291
  "--no-tools",
2292
+ "--no-builtin-tools",
2293
+ "-nbt",
2294
+ "--tools",
2295
+ "-t",
2296
+ "--exclude-tools",
2297
+ "-xt",
2267
2298
  "--no-extensions",
2268
2299
  "--no-skills",
2269
2300
  "--no-session",
@@ -2550,7 +2581,7 @@ function createManagedPiMcpProfileApi(options = {}) {
2550
2581
  if (!ALLOWED_COMMAND_ENV2.has(name)) throw new Error(`pi_managed_mcp_env_injection_blocked: ${name}`);
2551
2582
  }
2552
2583
  const args = Array.isArray(input.extraArgs) ? input.extraArgs.map(String) : [];
2553
- if (args.some((arg) => FORBIDDEN_ARGV.has(arg) || arg.startsWith("--session=") || arg.startsWith("--fork=") || arg.startsWith("--session-dir=") || arg.startsWith("--extension=") || arg.startsWith("--package=") || arg.startsWith("--settings="))) {
2584
+ if (args.some((arg) => FORBIDDEN_ARGV.has(arg) || arg.startsWith("--tools=") || arg.startsWith("--exclude-tools=") || arg.startsWith("--session=") || arg.startsWith("--fork=") || arg.startsWith("--session-dir=") || arg.startsWith("--extension=") || arg.startsWith("--package=") || arg.startsWith("--settings="))) {
2554
2585
  throw new Error("pi_managed_mcp_config_override_blocked: Pi config/tool/session argv is forbidden for governed runs");
2555
2586
  }
2556
2587
  }
@@ -3063,6 +3094,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3063
3094
  configPath,
3064
3095
  markerPath,
3065
3096
  env,
3097
+ toolAllowlist: directCatalog ? [...directToolNames] : null,
3066
3098
  protectedValues: [.../* @__PURE__ */ new Set([
3067
3099
  sessionToken,
3068
3100
  ...seededRuntime.protectedValues,
@@ -5781,6 +5813,14 @@ function piMessageText(message) {
5781
5813
  return readString(block.text) ?? readString(block.content) ?? "";
5782
5814
  }).filter(Boolean).join("\n").trim();
5783
5815
  }
5816
+ function piMessageHasToolCall(message) {
5817
+ const content = asRecord(message).content;
5818
+ if (!Array.isArray(content)) return false;
5819
+ return content.some((entry) => {
5820
+ const block = asRecord(entry);
5821
+ return block.type === "toolCall" && Boolean(readString(block.name));
5822
+ });
5823
+ }
5784
5824
  function appendUniqueText(values, text) {
5785
5825
  const normalized = typeof text === "string" ? text.trim() : "";
5786
5826
  if (!normalized) return false;
@@ -5868,7 +5908,7 @@ function maybeCapturePiMessage(event, messages, usage) {
5868
5908
  const message = asRecord(event.message);
5869
5909
  if (message.role === "assistant") {
5870
5910
  const text = piMessageText(message);
5871
- capturedAssistantOutput = capturePiAssistantText(text, messages) || capturedAssistantOutput;
5911
+ capturedAssistantOutput = capturePiAssistantText(text, messages) || piMessageHasToolCall(message) || capturedAssistantOutput;
5872
5912
  assignPiUsage(usage, piMessageUsage(message));
5873
5913
  }
5874
5914
  const eventMessages = Array.isArray(event.messages) ? event.messages : [];
@@ -5878,7 +5918,7 @@ function maybeCapturePiMessage(event, messages, usage) {
5878
5918
  continue;
5879
5919
  }
5880
5920
  const text = piMessageText(eventMessage);
5881
- capturedAssistantOutput = capturePiAssistantText(text, messages) || capturedAssistantOutput;
5921
+ capturedAssistantOutput = capturePiAssistantText(text, messages) || piMessageHasToolCall(eventMessage) || capturedAssistantOutput;
5882
5922
  assignPiUsage(usage, piMessageUsage(eventMessage));
5883
5923
  }
5884
5924
  return capturedAssistantOutput;
@@ -8695,7 +8735,7 @@ function assertSourceAcquisitionRuntimeAuthority({
8695
8735
  }
8696
8736
 
8697
8737
  // src/amaster-runtime-daemon.mjs
8698
- var CONNECTOR_VERSION = "0.1.1-beta.4";
8738
+ var CONNECTOR_VERSION = "0.1.1-beta.5";
8699
8739
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
8700
8740
  var SOURCE_ACQUISITION_CAPABILITY = "source_acquisition_v1";
8701
8741
  var SOURCE_ACQUISITION_PROFILE_VERSION = "source_acquisition_v1";
@@ -10478,6 +10518,14 @@ async function executeModelCallCommand(config, command, signal) {
10478
10518
  sourceWorkspacePath: process.cwd()
10479
10519
  });
10480
10520
  piModelCallProfile = executor.kind === "pi" ? preparePiModelCallProfile(command.commandId, baseEnv) : null;
10521
+ if (piModelCallProfile) {
10522
+ await syncPiExecutorProviderConfig(
10523
+ config,
10524
+ command,
10525
+ piModelCallProfile.env.PI_CODING_AGENT_DIR,
10526
+ resolvePiExecutorProviderConfig(config, command, baseEnv)
10527
+ );
10528
+ }
10481
10529
  execution = await runExecutor(invocation.command, invocation.args, {
10482
10530
  cwd: process.cwd(),
10483
10531
  env: piModelCallProfile?.env ?? baseEnv,
@@ -13162,6 +13210,7 @@ async function executeRunCommand(config, command) {
13162
13210
  }
13163
13211
  if (managedMcpProfile) {
13164
13212
  executorEnv = managedMcpProfile.env;
13213
+ if (executor.kind === "pi") invocation.args = applyManagedPiToolAllowlist(invocation.args, managedMcpProfile);
13165
13214
  await ingestLog(config, command, "system", "info", `Attested isolated ${executor.kind} managed MCP profile`, {
13166
13215
  presentationKind: "managed_mcp_attestation",
13167
13216
  ...managedMcpProfile.attestation
@@ -5,7 +5,7 @@ import { dirname, join, resolve } from "node:path";
5
5
  import { homedir, hostname } from "node:os";
6
6
  import { fileURLToPath } from "node:url";
7
7
 
8
- const CONNECTOR_VERSION = "0.1.1-beta.4";
8
+ const CONNECTOR_VERSION = "0.1.1-beta.5";
9
9
 
10
10
  const CAPABILITIES = [
11
11
  "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.4",
3
+ "version": "0.1.1-beta.5",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",