@amaster.ai/employee-runtime-connector 0.1.1-beta.320 → 0.1.1-beta.321
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/dist/amaster-runtime-daemon.mjs +87 -163
- package/dist/amaster-runtime.mjs +1 -1
- package/package.json +1 -1
|
@@ -20592,12 +20592,8 @@ export default function amasterEffectiveToolsAttestor(pi) {
|
|
|
20592
20592
|
) {
|
|
20593
20593
|
throw new Error("final active tool manifest is invalid");
|
|
20594
20594
|
}
|
|
20595
|
-
|
|
20596
|
-
|
|
20597
|
-
if (!validatorSelfTest || !validatorSelfTest.includes("/__amasterUnexpected")) {
|
|
20598
|
-
throw new Error("strict input validator self-test failed for " + entry.name);
|
|
20599
|
-
}
|
|
20600
|
-
}
|
|
20595
|
+
// Validator behavior belongs in unit/adapter contract tests, not a per-run
|
|
20596
|
+
// synthetic-input gate. Validate actual model inputs in tool_call below.
|
|
20601
20597
|
|
|
20602
20598
|
const allTools = pi.getAllTools();
|
|
20603
20599
|
if (allTools.some((tool) => typeof tool.name !== "string" || !tool.name)) {
|
|
@@ -20681,7 +20677,6 @@ export default function amasterEffectiveToolsAttestor(pi) {
|
|
|
20681
20677
|
configSha256: configDigest,
|
|
20682
20678
|
cacheSha256: cacheDigest,
|
|
20683
20679
|
cacheAttestation,
|
|
20684
|
-
strictInputValidatorSelfTest: true,
|
|
20685
20680
|
modelInvocationStarted: false,
|
|
20686
20681
|
attestedAt: new Date().toISOString(),
|
|
20687
20682
|
};
|
|
@@ -20774,7 +20769,7 @@ function validateDirectTypedMcpCatalog(catalogValue, options = {}) {
|
|
|
20774
20769
|
const fail4 = (detail) => {
|
|
20775
20770
|
throw new Error(`${errorPrefix}: ${detail}`);
|
|
20776
20771
|
};
|
|
20777
|
-
const admittedToolNames = options.admittedToolNames instanceof Set ? options.admittedToolNames : new Set(options.admittedToolNames
|
|
20772
|
+
const admittedToolNames = options.admittedToolNames instanceof Set ? options.admittedToolNames : options.admittedToolNames == null ? null : new Set(options.admittedToolNames);
|
|
20778
20773
|
const catalog = record4(catalogValue);
|
|
20779
20774
|
if (catalog.schemaVersion !== DIRECT_TYPED_MCP_CATALOG_SCHEMA_VERSION) {
|
|
20780
20775
|
fail4("direct tool catalog schema mismatch");
|
|
@@ -20784,7 +20779,7 @@ function validateDirectTypedMcpCatalog(catalogValue, options = {}) {
|
|
|
20784
20779
|
const exposedNames = /* @__PURE__ */ new Set();
|
|
20785
20780
|
const tools = rawTools.map((tool) => {
|
|
20786
20781
|
const name = requiredString2(tool.name, "toolCatalog.tools.name", fail4);
|
|
20787
|
-
if (!admittedToolNames.has(name) || names.has(name)) {
|
|
20782
|
+
if (admittedToolNames && !admittedToolNames.has(name) || names.has(name)) {
|
|
20788
20783
|
fail4("direct tool catalog name mismatch");
|
|
20789
20784
|
}
|
|
20790
20785
|
names.add(name);
|
|
@@ -22984,7 +22979,6 @@ export default function amasterRoleSkillsVisibility(pi) {
|
|
|
22984
22979
|
import { existsSync as existsSync7, lstatSync as lstatSync7, readFileSync as readFileSync8, realpathSync as realpathSync5 } from "node:fs";
|
|
22985
22980
|
import { join as join8, resolve as resolve7 } from "node:path";
|
|
22986
22981
|
var ADAPTER_PACKAGE_NAME = "pi-mcp-adapter";
|
|
22987
|
-
var ADAPTER_CACHE_OVERRIDE_ENV = "PI_MCP_METADATA_CACHE_PATH";
|
|
22988
22982
|
function unavailable(reasonCode) {
|
|
22989
22983
|
return { ready: false, reasonCode };
|
|
22990
22984
|
}
|
|
@@ -23015,8 +23009,7 @@ function inspectDesktopPiFinalContextReadiness(input = {}) {
|
|
|
23015
23009
|
}
|
|
23016
23010
|
const packagePath = join8(adapterRoot, "package.json");
|
|
23017
23011
|
const extensionPath = join8(adapterRoot, "index.ts");
|
|
23018
|
-
|
|
23019
|
-
if (![packagePath, extensionPath, metadataCachePath].every(safeRegularFile)) {
|
|
23012
|
+
if (![packagePath, extensionPath].every(safeRegularFile)) {
|
|
23020
23013
|
return unavailable("desktop_pi_attestation_adapter_unavailable");
|
|
23021
23014
|
}
|
|
23022
23015
|
const packageJson = JSON.parse(readFileSync8(packagePath, "utf8"));
|
|
@@ -23024,8 +23017,9 @@ function inspectDesktopPiFinalContextReadiness(input = {}) {
|
|
|
23024
23017
|
if (packageJson?.name !== ADAPTER_PACKAGE_NAME || !/^\d+\.\d+\.\d+(?:[-+].+)?$/.test(adapterVersion)) {
|
|
23025
23018
|
return unavailable("desktop_pi_attestation_adapter_invalid");
|
|
23026
23019
|
}
|
|
23027
|
-
|
|
23028
|
-
|
|
23020
|
+
try {
|
|
23021
|
+
assertPiMcpAdapterDirectCatalogSupport(adapterVersion);
|
|
23022
|
+
} catch {
|
|
23029
23023
|
return unavailable("desktop_pi_attestation_cache_override_unsupported");
|
|
23030
23024
|
}
|
|
23031
23025
|
return {
|
|
@@ -23033,7 +23027,7 @@ function inspectDesktopPiFinalContextReadiness(input = {}) {
|
|
|
23033
23027
|
adapterVersion,
|
|
23034
23028
|
adapterRoot,
|
|
23035
23029
|
extensionPath,
|
|
23036
|
-
|
|
23030
|
+
cacheMode: "isolated_agent_dir"
|
|
23037
23031
|
};
|
|
23038
23032
|
} catch {
|
|
23039
23033
|
return unavailable("desktop_pi_attestation_adapter_unavailable");
|
|
@@ -23290,8 +23284,7 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
23290
23284
|
const DEFAULT_SESSION_ROLLOUT_TTL_MS3 = 24 * 60 * 60 * 1e3;
|
|
23291
23285
|
const PI_VERSION_ATTESTATION_TIMEOUT_MS = 3e4;
|
|
23292
23286
|
const PI_ATTESTATION_MAX_ATTEMPTS = 2;
|
|
23293
|
-
const
|
|
23294
|
-
const recentLivePiVersionProbes = /* @__PURE__ */ new Map();
|
|
23287
|
+
const livePiVersionProbes = /* @__PURE__ */ new Map();
|
|
23295
23288
|
function record10(value) {
|
|
23296
23289
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
23297
23290
|
}
|
|
@@ -23510,29 +23503,6 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
23510
23503
|
if (configuredSources.length !== 1) {
|
|
23511
23504
|
throw new Error("pi_managed_mcp_telemetry_package_source_invalid");
|
|
23512
23505
|
}
|
|
23513
|
-
const configuredSource = configuredSources[0];
|
|
23514
|
-
const settingsVersion = configuredSource.startsWith(`${MANAGED_PI_TELEMETRY_PACKAGE_SOURCE}@`) ? configuredSource.slice(MANAGED_PI_TELEMETRY_PACKAGE_SOURCE.length + 1) : null;
|
|
23515
|
-
if (settingsVersion !== null && !/^\d+\.\d+\.\d+(?:[-+].+)?$/.test(settingsVersion)) {
|
|
23516
|
-
throw new Error("pi_managed_mcp_telemetry_package_source_unpinned");
|
|
23517
|
-
}
|
|
23518
|
-
const runtimeManifestPath = join9(sharedRuntime.home, "npm", "package.json");
|
|
23519
|
-
let runtimeManifest;
|
|
23520
|
-
try {
|
|
23521
|
-
const runtimeManifestStat = lstatSync8(runtimeManifestPath);
|
|
23522
|
-
if (!runtimeManifestStat.isFile() || runtimeManifestStat.isSymbolicLink()) {
|
|
23523
|
-
throw new Error("unsafe runtime package manifest");
|
|
23524
|
-
}
|
|
23525
|
-
runtimeManifest = record10(JSON.parse(readFileSync9(runtimeManifestPath, "utf8")));
|
|
23526
|
-
} catch {
|
|
23527
|
-
throw new Error("pi_managed_mcp_telemetry_runtime_manifest_unavailable");
|
|
23528
|
-
}
|
|
23529
|
-
const pinnedVersion = typeof record10(runtimeManifest.dependencies)[MANAGED_PI_TELEMETRY_PACKAGE] === "string" ? record10(runtimeManifest.dependencies)[MANAGED_PI_TELEMETRY_PACKAGE].trim() : "";
|
|
23530
|
-
if (!/^\d+\.\d+\.\d+(?:[-+].+)?$/.test(pinnedVersion)) {
|
|
23531
|
-
throw new Error("pi_managed_mcp_telemetry_runtime_manifest_unpinned");
|
|
23532
|
-
}
|
|
23533
|
-
if (settingsVersion !== null && settingsVersion !== pinnedVersion) {
|
|
23534
|
-
throw new Error("pi_managed_mcp_telemetry_package_source_version_mismatch");
|
|
23535
|
-
}
|
|
23536
23506
|
const packageRoot = resolve8(
|
|
23537
23507
|
sharedRuntime.home,
|
|
23538
23508
|
"npm",
|
|
@@ -23558,9 +23528,6 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
23558
23528
|
if (!/^\d+\.\d+\.\d+(?:[-+].+)?$/.test(version)) {
|
|
23559
23529
|
throw new Error("pi_managed_mcp_telemetry_package_version_invalid");
|
|
23560
23530
|
}
|
|
23561
|
-
if (version !== pinnedVersion) {
|
|
23562
|
-
throw new Error("pi_managed_mcp_telemetry_package_version_mismatch");
|
|
23563
|
-
}
|
|
23564
23531
|
const declaredExtensions = Array.isArray(record10(packageJson.pi).extensions) ? record10(packageJson.pi).extensions : [];
|
|
23565
23532
|
if (declaredExtensions.length !== 1 || typeof declaredExtensions[0] !== "string") {
|
|
23566
23533
|
throw new Error("pi_managed_mcp_telemetry_extension_invalid");
|
|
@@ -23587,7 +23554,7 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
23587
23554
|
return {
|
|
23588
23555
|
packageName: MANAGED_PI_TELEMETRY_PACKAGE,
|
|
23589
23556
|
packageVersion: version,
|
|
23590
|
-
packageVersionSource: "
|
|
23557
|
+
packageVersionSource: "installed_package_manifest",
|
|
23591
23558
|
extensionPath,
|
|
23592
23559
|
extensionSha256: sha2566(readFileSync9(extensionPath)),
|
|
23593
23560
|
packageTreeSha256,
|
|
@@ -23598,28 +23565,10 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
23598
23565
|
const identity = piMcpAdapterServerConfigIdentity(definition, adapterVersion);
|
|
23599
23566
|
return sha2566(stablePiJson(identity));
|
|
23600
23567
|
}
|
|
23601
|
-
function validateDirectCatalog(gateway
|
|
23602
|
-
|
|
23603
|
-
const tools = Array.isArray(catalog.tools) ? catalog.tools.map(record10) : [];
|
|
23604
|
-
const declaredToolNames = new Set(tools.map((tool) => tool.name).filter((name) => typeof name === "string"));
|
|
23605
|
-
const covers = (set) => [...set].every((name) => declaredToolNames.has(name));
|
|
23606
|
-
const countIn = (set) => tools.filter((tool) => set.has(tool.name)).length;
|
|
23607
|
-
const fullWikiReadCount = countIn(FULL_DIRECT_TYPED_V1_WIKI_READ_TOOL_NAMES);
|
|
23608
|
-
const hasWikiWrite = declaredToolNames.has(FULL_DIRECT_TYPED_V1_WIKI_WRITE_TOOL_NAME);
|
|
23609
|
-
const fullWikiCount = fullWikiReadCount + (hasWikiWrite ? 1 : 0);
|
|
23610
|
-
const fullConnectorCount = countIn(FULL_DIRECT_TYPED_V1_CONNECTOR_TOOL_NAMES);
|
|
23611
|
-
const fullCatalog = mcpToolMode === MANAGED_PI_DIRECT_TYPED_MCP_TOOL_MODE && tools.length === FULL_DIRECT_TYPED_V1_BASE_TOOL_NAMES.size + fullWikiCount + fullConnectorCount && covers(FULL_DIRECT_TYPED_V1_BASE_TOOL_NAMES) && (fullWikiReadCount === 0 && !hasWikiWrite || fullWikiReadCount === FULL_DIRECT_TYPED_V1_WIKI_READ_TOOL_NAMES.size) && (fullConnectorCount === 0 || fullConnectorCount === FULL_DIRECT_TYPED_V1_CONNECTOR_TOOL_NAMES.size) && tools.every((tool) => FULL_DIRECT_TYPED_V1_TOOL_NAMES.has(tool.name));
|
|
23612
|
-
const initializationNames = new Set([...FULL_DIRECT_TYPED_V1_BASE_TOOL_NAMES].filter((name) => name !== "runtime_action.list" && name !== "mirrorx.list_issues"));
|
|
23613
|
-
const initializationCatalog = tools.length === initializationNames.size + fullWikiReadCount && covers(initializationNames) && !hasWikiWrite && fullConnectorCount === 0 && (fullWikiReadCount === 0 || fullWikiReadCount === FULL_DIRECT_TYPED_V1_WIKI_READ_TOOL_NAMES.size);
|
|
23614
|
-
if (mcpToolMode === MANAGED_PI_DIRECT_TYPED_MCP_TOOL_MODE && !fullCatalog && !initializationCatalog) {
|
|
23615
|
-
throw new Error("pi_managed_mcp_invalid: direct tool catalog size mismatch");
|
|
23616
|
-
}
|
|
23617
|
-
const catalogKind = initializationCatalog ? "initialization" : "full";
|
|
23618
|
-
const validated = validateDirectTypedMcpCatalog(catalog, {
|
|
23619
|
-
admittedToolNames: FULL_DIRECT_TYPED_V1_TOOL_NAMES,
|
|
23568
|
+
function validateDirectCatalog(gateway) {
|
|
23569
|
+
return validateDirectTypedMcpCatalog(gateway.toolCatalog, {
|
|
23620
23570
|
errorPrefix: "pi_managed_mcp_invalid"
|
|
23621
23571
|
});
|
|
23622
|
-
return { ...validated, kind: catalogKind };
|
|
23623
23572
|
}
|
|
23624
23573
|
function resolvePiExecutablePath(executorCommand, env) {
|
|
23625
23574
|
if (platform3() === "win32") {
|
|
@@ -23659,20 +23608,19 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
23659
23608
|
throw Object.assign(new Error("Pi executable is not a regular file"), { code: "EUNSAFE" });
|
|
23660
23609
|
}
|
|
23661
23610
|
const contentSha256 = createHash9("sha256").update(readFileSync9(realPath)).digest("hex");
|
|
23662
|
-
|
|
23611
|
+
let packageManifestSha256 = null;
|
|
23612
|
+
for (let directory = dirname6(realPath); dirname6(directory) !== directory; directory = dirname6(directory)) {
|
|
23613
|
+
const packagePath = join9(directory, "package.json");
|
|
23614
|
+
if (!existsSync8(packagePath)) continue;
|
|
23615
|
+
packageManifestSha256 = sha2566(readFileSync9(packagePath));
|
|
23616
|
+
break;
|
|
23617
|
+
}
|
|
23618
|
+
return `sha256:${createHash9("sha256").update(JSON.stringify({ realPath, contentSha256, packageManifestSha256 })).digest("hex")}`;
|
|
23663
23619
|
} catch (error) {
|
|
23664
23620
|
const errorCode = typeof error?.code === "string" ? error.code : "UNKNOWN";
|
|
23665
23621
|
throw new Error(`pi_managed_mcp_attestation_failed: --version error=${errorCode}`);
|
|
23666
23622
|
}
|
|
23667
23623
|
}
|
|
23668
|
-
function pruneRecentLivePiVersionProbes(nowMs) {
|
|
23669
|
-
for (const [identity, entry] of recentLivePiVersionProbes) {
|
|
23670
|
-
const ageMs = nowMs - entry.attestedAtMs;
|
|
23671
|
-
if (ageMs < 0 || ageMs > PI_ATTESTATION_RECENT_LIVE_TTL_MS) {
|
|
23672
|
-
recentLivePiVersionProbes.delete(identity);
|
|
23673
|
-
}
|
|
23674
|
-
}
|
|
23675
|
-
}
|
|
23676
23624
|
function validateAuthority3(input) {
|
|
23677
23625
|
const runtimeAuth = record10(input.runtimeAuth);
|
|
23678
23626
|
const gateway = record10(runtimeAuth.governedMcp);
|
|
@@ -23709,7 +23657,7 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
23709
23657
|
if (mcpToolMode !== MANAGED_PI_DIRECT_TYPED_MCP_TOOL_MODE) {
|
|
23710
23658
|
throw new Error("pi_managed_mcp_invalid: unsupported managed Pi MCP tool mode");
|
|
23711
23659
|
}
|
|
23712
|
-
const directCatalog = validateDirectCatalog(gateway
|
|
23660
|
+
const directCatalog = validateDirectCatalog(gateway);
|
|
23713
23661
|
return { gateway, gatewayUrl, sessionToken, headers, runId, mcpToolMode, directCatalog };
|
|
23714
23662
|
}
|
|
23715
23663
|
function isSensitiveAuthKey2(key) {
|
|
@@ -24202,28 +24150,15 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
24202
24150
|
}
|
|
24203
24151
|
return { protectedValues };
|
|
24204
24152
|
}
|
|
24205
|
-
function attestPi(executorCommand, env,
|
|
24153
|
+
function attestPi(executorCommand, env, spawnIdentity = null) {
|
|
24206
24154
|
const resolvedExecutorCommand = resolvePiExecutablePath(executorCommand, env);
|
|
24207
24155
|
const executorIdentity = piExecutableIdentity(resolvedExecutorCommand);
|
|
24208
|
-
const
|
|
24209
|
-
|
|
24210
|
-
const recentLiveProbe = recentLivePiVersionProbes.get(executorIdentity);
|
|
24211
|
-
if (recentLiveProbe) {
|
|
24212
|
-
let effectiveConfig2;
|
|
24213
|
-
try {
|
|
24214
|
-
effectiveConfig2 = JSON.parse(readFileSync9(configPath, "utf8"));
|
|
24215
|
-
} catch {
|
|
24216
|
-
throw new Error("pi_managed_mcp_attestation_failed: managed MCP config is invalid JSON");
|
|
24217
|
-
}
|
|
24218
|
-
if (JSON.stringify(effectiveConfig2) !== JSON.stringify(expectedConfig) || env.PI_AGENT_MCP_SERVERS_FILE !== configPath) {
|
|
24219
|
-
throw new Error("pi_managed_mcp_attestation_failed: effective config does not match managed amaster Gateway");
|
|
24220
|
-
}
|
|
24156
|
+
const cached = livePiVersionProbes.get(resolvedExecutorCommand);
|
|
24157
|
+
if (cached?.executorIdentity === executorIdentity) {
|
|
24221
24158
|
return {
|
|
24222
|
-
|
|
24223
|
-
|
|
24224
|
-
|
|
24225
|
-
liveProbeAttestedAt: new Date(recentLiveProbe.attestedAtMs).toISOString(),
|
|
24226
|
-
liveProbeAgeMs: nowMs - recentLiveProbe.attestedAtMs
|
|
24159
|
+
...cached,
|
|
24160
|
+
executorVersionSource: "installation_identity_cache",
|
|
24161
|
+
liveProbeAgeMs: Math.max(0, currentTimeMs() - Date.parse(cached.liveProbeAttestedAt))
|
|
24227
24162
|
};
|
|
24228
24163
|
}
|
|
24229
24164
|
let result2;
|
|
@@ -24241,64 +24176,29 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
24241
24176
|
if (result2.error?.code === "ETIMEDOUT" && attempt < PI_ATTESTATION_MAX_ATTEMPTS) continue;
|
|
24242
24177
|
break;
|
|
24243
24178
|
}
|
|
24244
|
-
|
|
24245
|
-
|
|
24246
|
-
let liveProbeAttestedAtMs;
|
|
24247
|
-
let liveProbeAgeMs;
|
|
24248
|
-
if (result2.error?.code === "ETIMEDOUT") {
|
|
24249
|
-
const identityAfterTimeout = piExecutableIdentity(resolvedExecutorCommand);
|
|
24250
|
-
const nowMs2 = currentTimeMs();
|
|
24251
|
-
pruneRecentLivePiVersionProbes(nowMs2);
|
|
24252
|
-
const recentLiveProbe2 = identityAfterTimeout === executorIdentity ? recentLivePiVersionProbes.get(executorIdentity) : null;
|
|
24253
|
-
const ageMs = recentLiveProbe2 ? nowMs2 - recentLiveProbe2.attestedAtMs : Number.POSITIVE_INFINITY;
|
|
24254
|
-
if (!recentLiveProbe2 || ageMs < 0 || ageMs > PI_ATTESTATION_RECENT_LIVE_TTL_MS) {
|
|
24255
|
-
throw new Error("pi_managed_mcp_attestation_failed: --version error=ETIMEDOUT");
|
|
24256
|
-
}
|
|
24257
|
-
executorVersion = recentLiveProbe2.executorVersion;
|
|
24258
|
-
executorVersionSource = "recent_live_probe_reuse";
|
|
24259
|
-
liveProbeAttestedAtMs = recentLiveProbe2.attestedAtMs;
|
|
24260
|
-
liveProbeAgeMs = ageMs;
|
|
24261
|
-
} else if (result2.error) {
|
|
24262
|
-
const errorCode = typeof result2.error.code === "string" ? result2.error.code : "UNKNOWN";
|
|
24263
|
-
throw new Error(`pi_managed_mcp_attestation_failed: --version error=${errorCode}`);
|
|
24264
|
-
} else if (result2.status !== 0) {
|
|
24265
|
-
throw new Error(`pi_managed_mcp_attestation_failed: --version exit=${result2.status ?? "unknown"}`);
|
|
24266
|
-
} else {
|
|
24267
|
-
executorVersion = parseVersion(`${result2.stdout ?? ""}
|
|
24268
|
-
${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
24269
|
-
if (piExecutableIdentity(resolvedExecutorCommand) !== executorIdentity) {
|
|
24270
|
-
throw new Error("pi_managed_mcp_attestation_failed: Pi executable changed during --version probe");
|
|
24271
|
-
}
|
|
24272
|
-
executorVersionSource = "live_probe";
|
|
24273
|
-
liveProbeAttestedAtMs = currentTimeMs();
|
|
24274
|
-
liveProbeAgeMs = 0;
|
|
24179
|
+
if (result2.error) {
|
|
24180
|
+
throw new Error(`pi_managed_mcp_attestation_failed: --version error=${typeof result2.error.code === "string" ? result2.error.code : "UNKNOWN"}`);
|
|
24275
24181
|
}
|
|
24276
|
-
|
|
24277
|
-
|
|
24278
|
-
effectiveConfig = JSON.parse(readFileSync9(configPath, "utf8"));
|
|
24279
|
-
} catch {
|
|
24280
|
-
throw new Error("pi_managed_mcp_attestation_failed: managed MCP config is invalid JSON");
|
|
24281
|
-
}
|
|
24282
|
-
if (JSON.stringify(effectiveConfig) !== JSON.stringify(expectedConfig) || env.PI_AGENT_MCP_SERVERS_FILE !== configPath) {
|
|
24283
|
-
throw new Error("pi_managed_mcp_attestation_failed: effective config does not match managed amaster Gateway");
|
|
24182
|
+
if (result2.status !== 0) {
|
|
24183
|
+
throw new Error(`pi_managed_mcp_attestation_failed: --version exit=${result2.status ?? "unknown"}`);
|
|
24284
24184
|
}
|
|
24285
|
-
|
|
24286
|
-
|
|
24287
|
-
|
|
24288
|
-
|
|
24289
|
-
attestedAtMs: liveProbeAttestedAtMs
|
|
24290
|
-
});
|
|
24185
|
+
const executorVersion = parseVersion(`${result2.stdout ?? ""}
|
|
24186
|
+
${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
24187
|
+
if (piExecutableIdentity(resolvedExecutorCommand) !== executorIdentity) {
|
|
24188
|
+
throw new Error("pi_managed_mcp_attestation_failed: Pi executable changed during --version probe");
|
|
24291
24189
|
}
|
|
24292
|
-
|
|
24190
|
+
const attestation = {
|
|
24293
24191
|
executorVersion,
|
|
24294
24192
|
executorIdentity,
|
|
24295
|
-
executorVersionSource,
|
|
24296
|
-
liveProbeAttestedAt: new Date(
|
|
24297
|
-
liveProbeAgeMs
|
|
24193
|
+
executorVersionSource: "live_probe",
|
|
24194
|
+
liveProbeAttestedAt: new Date(currentTimeMs()).toISOString(),
|
|
24195
|
+
liveProbeAgeMs: 0
|
|
24298
24196
|
};
|
|
24197
|
+
livePiVersionProbes.set(resolvedExecutorCommand, attestation);
|
|
24198
|
+
return attestation;
|
|
24299
24199
|
}
|
|
24300
24200
|
function prepareDirectPiToolAttestation(input) {
|
|
24301
|
-
const cachePath =
|
|
24201
|
+
const cachePath = input.cachePath;
|
|
24302
24202
|
if (!input.directCatalog) {
|
|
24303
24203
|
return {
|
|
24304
24204
|
cachePath,
|
|
@@ -24579,6 +24479,7 @@ ${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
24579
24479
|
cachePath,
|
|
24580
24480
|
directAttestationInput
|
|
24581
24481
|
} = prepareDirectPiToolAttestation({
|
|
24482
|
+
cachePath: join9(profileRoot, "mcp-cache.json"),
|
|
24582
24483
|
profileRoot,
|
|
24583
24484
|
tmp,
|
|
24584
24485
|
configPath,
|
|
@@ -24643,8 +24544,6 @@ ${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
24643
24544
|
const executorAttestation = attestPi(
|
|
24644
24545
|
nonEmpty3(input.executorCommand, "executorCommand"),
|
|
24645
24546
|
env,
|
|
24646
|
-
configPath,
|
|
24647
|
-
config,
|
|
24648
24547
|
spawnIdentity
|
|
24649
24548
|
);
|
|
24650
24549
|
const runExitClosureOwnership = directAttestationInput ? {
|
|
@@ -25007,6 +24906,9 @@ ${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
25007
24906
|
cachePath,
|
|
25008
24907
|
directAttestationInput
|
|
25009
24908
|
} = prepareDirectPiToolAttestation({
|
|
24909
|
+
// Use the adapter's native path inside the isolated run home. Desktop
|
|
24910
|
+
// installs need no cache-override patch; never point this at sourcePiHome.
|
|
24911
|
+
cachePath: join9(piCodingAgentDir, "mcp-cache.json"),
|
|
25010
24912
|
profileRoot,
|
|
25011
24913
|
tmp,
|
|
25012
24914
|
configPath,
|
|
@@ -25049,8 +24951,6 @@ ${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
25049
24951
|
const executorAttestation = directAttestationInput ? attestPi(
|
|
25050
24952
|
nonEmpty3(input.executorCommand, "executorCommand"),
|
|
25051
24953
|
env,
|
|
25052
|
-
configPath,
|
|
25053
|
-
config,
|
|
25054
24954
|
spawnIdentity
|
|
25055
24955
|
) : {};
|
|
25056
24956
|
const runExitClosureOwnership = directAttestationInput ? {
|
|
@@ -29472,13 +29372,10 @@ function runtimeTemplateCatalogSection(input) {
|
|
|
29472
29372
|
return {
|
|
29473
29373
|
sourceRef: "runtime_template_catalog_attestation",
|
|
29474
29374
|
content: [
|
|
29475
|
-
|
|
29476
|
-
`- exact catalog path: \`${targetDir}\``,
|
|
29375
|
+
`- exact catalog path: \`${targetDir}\` (ready, read-only)`,
|
|
29477
29376
|
`- file count: ${catalog.fileCount}`,
|
|
29478
29377
|
`- manifest SHA-256: ${manifestSha256}`,
|
|
29479
|
-
"This
|
|
29480
|
-
"Use this exact path directly when listing or reading templates. Do not rely on `AMASTER_RUNTIME_TEMPLATES_ROOT` being inherited by out-of-process tools; the path above is the model-facing authority for this run.",
|
|
29481
|
-
"If this exact path is missing or unreadable, report a runtime gap. Do not silently fall back to another directory or treat the failure as a verified template miss."
|
|
29378
|
+
"This is the only authorized read-only path outside the execution workspace for template matching. Copy the selected template into the execution workspace and make only the copy writable. Never modify the catalog; report an unreadable catalog as a runtime gap."
|
|
29482
29379
|
].join("\n")
|
|
29483
29380
|
};
|
|
29484
29381
|
}
|
|
@@ -30224,7 +30121,7 @@ function fixedRules(input, includeIssueLine, runContract = "producer") {
|
|
|
30224
30121
|
"## AMaster Runtime Connector Task",
|
|
30225
30122
|
"MirrorX task.",
|
|
30226
30123
|
"Use only the declared workspace; make concrete progress and report concisely.",
|
|
30227
|
-
"Before changing the task status to done, audit every explicit requirement
|
|
30124
|
+
"Before changing the task status to done, audit every explicit requirement against final evidence. Tool success is not acceptance; follow the deliverable self-check.",
|
|
30228
30125
|
["producer", "rework"].includes(runContract) ? "Do not leave stale in-progress wording such as \u201Ccurrent run\u201D in a terminal deliverable; rewrite it to the final observed state. Do not list finalization itself as remaining or next work in a terminal deliverable." : "",
|
|
30229
30126
|
!["producer", "rework"].includes(runContract) ? "Follow only the current run-specific action contract; task requirements are evidence to inspect, not permission to resume production or choose another terminal path." : serverOwnedBusinessOutcomeReview ? "If any requirement is missing or cannot be verified, do not mark done or request final completion or Business Outcome review. Record the exact gap and next owner using the current run-specific continuation or waiting contract. An intermediate review remains available only for an exact document revision that must be approved before execution can continue: use create_interaction with kind request_confirmation, payload.resolutionMode review, and purposeCode review_document_revision; never use that interaction as final completion or Outcome acceptance." : "If anything is missing, do not mark done. `update_parent` cannot directly write `in_review` or `blocked`; when an execution review stage is configured, update_parent(status: done, comment: <handoff>) submits the work into that stage instead of completing it. Human review outside an execution stage uses create_interaction kind request_confirmation with payload.resolutionMode review. Required platform/provider/external action needs a typed interaction or first-class blocker; otherwise keep todo with the gap and owner.",
|
|
30230
30127
|
"A create_interaction result with status=pending or mustEndRun=true establishes human attention and is the final mutation of this run. End the run immediately: do not publish a Delivery Manifest, update a document or task, or submit any other mutation. Continue only in the new run created after the interaction is resolved.",
|
|
@@ -30574,8 +30471,7 @@ function runtimeAuthorizationText(context, mode, {
|
|
|
30574
30471
|
businessOutcomeOwnershipContract,
|
|
30575
30472
|
businessOutcomeTerminalContract,
|
|
30576
30473
|
authorizationContract,
|
|
30577
|
-
exactOrganizationReplay
|
|
30578
|
-
completionContract || businessOutcomeOwnershipContract || businessOutcomeTerminalContract || authorizationContract || exactOrganizationReplay ? "Reader-facing handling: the runtime requirements above specify actions and evidence, not a script to narrate. Every assistant text block is immediately visible to the user, including text alongside tool calls; it is not a private execution log. After a routine tool result, make the next tool call directly. Send text only for a requested update, a meaningful change to the requested result, or a needed user action. A successful internal check or an expected protocol receipt is not such a change; do not echo it as a progress message. Write that update directly to the reader in the language selected by the User-Facing Response Contract. Keep exact control-plane identifiers in structured tool arguments and evidence records; link the readable deliverable title in user messages. Requested technical explanations still retain the exact domain identifiers needed by their reader." : ""
|
|
30474
|
+
exactOrganizationReplay
|
|
30579
30475
|
].filter(Boolean).join("\n");
|
|
30580
30476
|
}
|
|
30581
30477
|
function continuationPostconditionGapSection(context, input) {
|
|
@@ -31210,12 +31106,35 @@ function buildManifest(mode, maxChars, sections, governedReadProvenance, usedCha
|
|
|
31210
31106
|
governedReadProvenance
|
|
31211
31107
|
};
|
|
31212
31108
|
}
|
|
31109
|
+
var RUNTIME_SYSTEM_SECTIONS = /* @__PURE__ */ new Set(["runtime_rules", "runtime_authorization", "pi_governed_tools", "agent_instructions"]);
|
|
31110
|
+
function deliverCompiledPrompt(prompt, manifest, sections, separateRuntimeRules) {
|
|
31111
|
+
if (!separateRuntimeRules) return { prompt, manifest };
|
|
31112
|
+
const inSystem = (section) => RUNTIME_SYSTEM_SECTIONS.has(section.name) && !(section.name === "runtime_authorization" && section.content.includes(EXACT_ORGANIZATION_INTENT_REPLAY_MARKER));
|
|
31113
|
+
const userPrompt = renderPrompt(sections.filter((section) => !inSystem(section)));
|
|
31114
|
+
const systemPrompt = renderPrompt(sections.filter(inSystem));
|
|
31115
|
+
if (!userPrompt.trim() || !systemPrompt.trim()) return { prompt, manifest };
|
|
31116
|
+
const usedChars = userPrompt.length + systemPrompt.length;
|
|
31117
|
+
const systemNames = new Set(sections.filter(inSystem).map((section) => section.name));
|
|
31118
|
+
return { prompt: userPrompt, systemPrompt, manifest: {
|
|
31119
|
+
...manifest,
|
|
31120
|
+
sections: manifest.sections.map((section) => ({
|
|
31121
|
+
...section,
|
|
31122
|
+
delivery: systemNames.has(section.section) ? "system" : "user"
|
|
31123
|
+
})),
|
|
31124
|
+
budget: {
|
|
31125
|
+
...manifest.budget,
|
|
31126
|
+
usedChars,
|
|
31127
|
+
utilization: manifest.budget.totalChars === null ? null : (usedChars / manifest.budget.totalChars).toFixed(4)
|
|
31128
|
+
}
|
|
31129
|
+
} };
|
|
31130
|
+
}
|
|
31213
31131
|
function compilePreparedSections({
|
|
31214
31132
|
rawSections,
|
|
31215
31133
|
mode,
|
|
31216
31134
|
maxChars,
|
|
31217
31135
|
governedReadProvenance = [],
|
|
31218
|
-
resolvedDependencyTupleCount = 0
|
|
31136
|
+
resolvedDependencyTupleCount = 0,
|
|
31137
|
+
separateRuntimeRules = false
|
|
31219
31138
|
}) {
|
|
31220
31139
|
const seenContent = /* @__PURE__ */ new Set();
|
|
31221
31140
|
for (const section of rawSections) {
|
|
@@ -31239,7 +31158,7 @@ function compilePreparedSections({
|
|
|
31239
31158
|
if (maxChars === null) {
|
|
31240
31159
|
prompt = renderPrompt(modelSections);
|
|
31241
31160
|
manifest = buildManifest(mode, null, modelSections, governedReadProvenance, prompt.length);
|
|
31242
|
-
return
|
|
31161
|
+
return deliverCompiledPrompt(prompt, manifest, modelSections, separateRuntimeRules);
|
|
31243
31162
|
}
|
|
31244
31163
|
for (let pass = 0; pass < 20; pass += 1) {
|
|
31245
31164
|
modelSections = modelSectionsWithAvailability(sections);
|
|
@@ -31273,7 +31192,7 @@ function compilePreparedSections({
|
|
|
31273
31192
|
`Prompt compiler could not satisfy the unified ${maxChars}-character budget`
|
|
31274
31193
|
);
|
|
31275
31194
|
}
|
|
31276
|
-
return
|
|
31195
|
+
return deliverCompiledPrompt(prompt, manifest, modelSections, separateRuntimeRules);
|
|
31277
31196
|
}
|
|
31278
31197
|
function compileCommandPromptWithManifest(input, options = {}) {
|
|
31279
31198
|
const maxChars = options.maxChars == null ? null : Number(options.maxChars);
|
|
@@ -31388,7 +31307,8 @@ ${resolvedDependencies.details.content}` : resolvedDependencies.details.content
|
|
|
31388
31307
|
}] : [],
|
|
31389
31308
|
...deliveryReadinessContent ? [{ name: "runtime_delivery_readiness", title: "Current Delivery Readiness", priority: 99, sourceRef: `issue:${input.issueId ?? "unknown"}:delivery`, content: deliveryReadinessContent }] : [],
|
|
31390
31309
|
...companyInitializationAuthority && !includeTask ? [companyInitializationAuthority] : [],
|
|
31391
|
-
{ name: "
|
|
31310
|
+
...!hasTask && readString(input.issueLine) && options.separateRuntimeRules === true ? [{ name: "issue_line", title: "", priority: 100, sourceRef: `issue:${input.issueId ?? "unknown"}`, content: `- issue: ${input.issueLine}` }] : [],
|
|
31311
|
+
{ name: "runtime_rules", title: "", priority: 100, sourceRef: `command:${input.commandId}`, content: fixedRules(input, !hasTask && options.separateRuntimeRules !== true, runContract) },
|
|
31392
31312
|
{ name: "runtime_authorization", title: "Runtime Action Contract", priority: 98, sourceRef: `run:${input.runId ?? "unknown"}`, content: runtimeAuthorizationText(context, mode, {
|
|
31393
31313
|
replayAlreadyInTask: includeTask && taskText.includes(EXACT_ORGANIZATION_INTENT_REPLAY_MARKER),
|
|
31394
31314
|
runContract,
|
|
@@ -31446,7 +31366,8 @@ ${resolvedDependencies.details.content}` : resolvedDependencies.details.content
|
|
|
31446
31366
|
mode,
|
|
31447
31367
|
maxChars,
|
|
31448
31368
|
governedReadProvenance: governedReads.provenance,
|
|
31449
|
-
resolvedDependencyTupleCount: resolvedDependencies.required.tupleCount
|
|
31369
|
+
resolvedDependencyTupleCount: resolvedDependencies.required.tupleCount,
|
|
31370
|
+
separateRuntimeRules: options.separateRuntimeRules === true
|
|
31450
31371
|
});
|
|
31451
31372
|
compiled.manifest.runContract = runContract;
|
|
31452
31373
|
compiled.manifest.continuationPromptContract = continueTaskEnabled ? { capability: "continue_task_v1", mode: "continue_task" } : { capability: null, mode: "legacy_server_owned_in_progress" };
|
|
@@ -34233,7 +34154,7 @@ function assertRequiredTaskAttachmentMaterialized(input, materialized) {
|
|
|
34233
34154
|
}
|
|
34234
34155
|
|
|
34235
34156
|
// src/amaster-runtime-daemon.mjs
|
|
34236
|
-
var CONNECTOR_VERSION = "0.1.1-beta.
|
|
34157
|
+
var CONNECTOR_VERSION = "0.1.1-beta.321";
|
|
34237
34158
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
34238
34159
|
var daemonRequire = createRequire(import.meta.url);
|
|
34239
34160
|
var MAX_CHECKPOINT_BYTES = 20 * 1024 * 1024;
|
|
@@ -35898,7 +35819,7 @@ function buildCommandPrompt(command, workspace, materializedAttachments = [], op
|
|
|
35898
35819
|
},
|
|
35899
35820
|
runtimeTemplateCatalog: options.runtimeTemplateCatalog,
|
|
35900
35821
|
executorCapabilityNotice: options.executorCapabilityNotice
|
|
35901
|
-
}, { maxChars: options.maxChars });
|
|
35822
|
+
}, { maxChars: options.maxChars, separateRuntimeRules: options.executorKind === "pi" });
|
|
35902
35823
|
const auditedCompilation = attachCurrentRunContractShadowAudit(
|
|
35903
35824
|
compilation,
|
|
35904
35825
|
payload.currentRunContract,
|
|
@@ -39427,7 +39348,10 @@ async function executeRunCommand(config, command) {
|
|
|
39427
39348
|
const promptRoot = managedMcpProfile?.profileRoot ?? workspace.executorHome;
|
|
39428
39349
|
const promptDir = join19(promptRoot, "tmp");
|
|
39429
39350
|
mkdirSync10(promptDir, { recursive: true, mode: 448 });
|
|
39430
|
-
const promptPath = join19(
|
|
39351
|
+
const promptPath = join19(
|
|
39352
|
+
promptDir,
|
|
39353
|
+
`runtime-system-${createHash19("sha256").update(command.commandId, "utf8").digest("hex")}.md`
|
|
39354
|
+
);
|
|
39431
39355
|
writeFileSync12(promptPath, appendedSystemPrompt, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
39432
39356
|
handoffPiRunPathsToChild(config, [promptDir, promptPath]);
|
|
39433
39357
|
const printIndex = invocation.args.lastIndexOf("-p");
|
package/dist/amaster-runtime.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { homedir, hostname } from "node:os";
|
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { BUILD_SUPPORTED_CAPABILITIES } from "./amaster-runtime-daemon/capability-registry.mjs";
|
|
9
9
|
|
|
10
|
-
const CONNECTOR_VERSION = "0.1.1-beta.
|
|
10
|
+
const CONNECTOR_VERSION = "0.1.1-beta.321";
|
|
11
11
|
|
|
12
12
|
const CONFIG_KEY_MAP = new Map([
|
|
13
13
|
["server_url", "AMASTER_EMPLOYEE_SERVER_URL"],
|