@amaster.ai/employee-runtime-connector 0.1.1-beta.24 → 0.1.1-beta.26
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 +68 -119
- package/dist/amaster-runtime.mjs +1 -4
- package/package.json +1 -1
|
@@ -1871,10 +1871,11 @@ import { spawnSync as spawnSync2 } from "node:child_process";
|
|
|
1871
1871
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
1872
1872
|
import { dirname as dirname2, join as join3 } from "node:path";
|
|
1873
1873
|
var AMASTER_API_KEY_ENV_REFERENCE = "${AMASTER_API_KEY}";
|
|
1874
|
+
var AMASTER_BILLING_TURN_HEADER_ENV_REFERENCE = "${AMASTER_BILLING_TURN_ID}";
|
|
1874
1875
|
var AMASTER_BILLING_HEADER_ENV_REFERENCES = Object.freeze({
|
|
1875
1876
|
"x-pi-agent-oauth-token": "${AMASTER_PLATFORM_OAUTH_TOKEN}",
|
|
1876
1877
|
"x-organization-id": "${AMASTER_PLATFORM_ORGANIZATION_ID}",
|
|
1877
|
-
"x-billing-turn-id":
|
|
1878
|
+
"x-billing-turn-id": AMASTER_BILLING_TURN_HEADER_ENV_REFERENCE
|
|
1878
1879
|
});
|
|
1879
1880
|
var MANAGED_PI_PROVIDER_ENV_NAMES = Object.freeze([
|
|
1880
1881
|
"AMASTER_MODEL_ACCESS_MODE",
|
|
@@ -1933,6 +1934,8 @@ function syncManagedBillingHeaders(value, executorEnv) {
|
|
|
1933
1934
|
const headers = withoutManagedBillingHeaders(value);
|
|
1934
1935
|
if (readString(executorEnv.AMASTER_MODEL_ACCESS_MODE) === "billing_gateway") {
|
|
1935
1936
|
Object.assign(headers, AMASTER_BILLING_HEADER_ENV_REFERENCES);
|
|
1937
|
+
} else if (readString(executorEnv.AMASTER_BILLING_TURN_ID)) {
|
|
1938
|
+
headers["x-billing-turn-id"] = AMASTER_BILLING_TURN_HEADER_ENV_REFERENCE;
|
|
1936
1939
|
}
|
|
1937
1940
|
return Object.keys(headers).length > 0 ? headers : void 0;
|
|
1938
1941
|
}
|
|
@@ -3232,12 +3235,23 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
3232
3235
|
}
|
|
3233
3236
|
return profile;
|
|
3234
3237
|
}
|
|
3235
|
-
function
|
|
3236
|
-
|
|
3237
|
-
const skillsDir = join4(cwd, ".pi", "skills");
|
|
3238
|
-
rmSync2(skillsDir, { recursive: true, force: true });
|
|
3238
|
+
function materializeManagedRoleSkills(piHome, skillsDir, skillProfiles) {
|
|
3239
|
+
if (existsSync3(skillsDir)) throw new Error("pi_managed_mcp_role_skills_exists");
|
|
3239
3240
|
const enabled = [];
|
|
3240
|
-
|
|
3241
|
+
const entriesByName = /* @__PURE__ */ new Map();
|
|
3242
|
+
for (const skillProfile of skillProfiles) {
|
|
3243
|
+
for (const entry of readSkillProfile(piHome, skillProfile)) {
|
|
3244
|
+
const existing = entriesByName.get(entry.name);
|
|
3245
|
+
if (existing) {
|
|
3246
|
+
if (realpathSync2(existing.source) !== realpathSync2(entry.source)) {
|
|
3247
|
+
throw new Error(`pi_managed_mcp_skill_profile_conflict:${entry.name}`);
|
|
3248
|
+
}
|
|
3249
|
+
continue;
|
|
3250
|
+
}
|
|
3251
|
+
entriesByName.set(entry.name, entry);
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
for (const entry of entriesByName.values()) {
|
|
3241
3255
|
const target = join4(skillsDir, entry.name);
|
|
3242
3256
|
copyTreeNoLinks(entry.source, target);
|
|
3243
3257
|
const skillFile = join4(target, "SKILL.md");
|
|
@@ -3248,6 +3262,19 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
3248
3262
|
}
|
|
3249
3263
|
return { skillsDir, enabled };
|
|
3250
3264
|
}
|
|
3265
|
+
function requestedSkillProfiles(input) {
|
|
3266
|
+
return [...new Set([
|
|
3267
|
+
...Array.isArray(input.skillProfiles) ? input.skillProfiles : [],
|
|
3268
|
+
input.skillProfile
|
|
3269
|
+
].filter((value) => typeof value === "string" && value.trim()).map((value) => value.trim()))];
|
|
3270
|
+
}
|
|
3271
|
+
function skillProfileAttestation(skillProfiles, enabledSkills) {
|
|
3272
|
+
if (skillProfiles.length === 0) return {};
|
|
3273
|
+
return {
|
|
3274
|
+
...skillProfiles.length === 1 ? { skillProfile: skillProfiles[0] } : { skillProfiles },
|
|
3275
|
+
enabledSkillsDigest: createHash3("sha256").update(JSON.stringify(enabledSkills)).digest("hex")
|
|
3276
|
+
};
|
|
3277
|
+
}
|
|
3251
3278
|
function seedDelegatedPiRuntime(sourceHome, agentDir) {
|
|
3252
3279
|
const source = resolve3(nonEmpty2(sourceHome, "sourcePiHome"));
|
|
3253
3280
|
const sourceStat = lstatSync3(source);
|
|
@@ -3351,6 +3378,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
3351
3378
|
function attestDirectPiTools(executorCommand, env, input, spawnIdentity = null) {
|
|
3352
3379
|
const result3 = spawnSyncImpl(executorCommand, [
|
|
3353
3380
|
"--no-session",
|
|
3381
|
+
"--no-approve",
|
|
3354
3382
|
"--no-skills",
|
|
3355
3383
|
"--no-context-files",
|
|
3356
3384
|
"--no-builtin-tools",
|
|
@@ -3556,23 +3584,19 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
3556
3584
|
}
|
|
3557
3585
|
const skillArgs = [];
|
|
3558
3586
|
let enabledRoleSkills = null;
|
|
3559
|
-
const
|
|
3560
|
-
if (
|
|
3561
|
-
const roleSkills =
|
|
3562
|
-
|
|
3587
|
+
const skillProfiles = requestedSkillProfiles(input);
|
|
3588
|
+
if (skillProfiles.length > 0) {
|
|
3589
|
+
const roleSkills = materializeManagedRoleSkills(
|
|
3590
|
+
sharedRuntime.home,
|
|
3591
|
+
join4(profileRoot, "role-skills"),
|
|
3592
|
+
skillProfiles
|
|
3593
|
+
);
|
|
3594
|
+
skillArgs.push("--no-approve", "--skill", roleSkills.skillsDir);
|
|
3563
3595
|
enabledRoleSkills = roleSkills.enabled;
|
|
3564
3596
|
}
|
|
3565
|
-
const providerEnv = {};
|
|
3566
|
-
for (const name of MANAGED_PI_PROVIDER_ENV_NAMES) {
|
|
3567
|
-
const commandValue = input.commandEnv?.[name];
|
|
3568
|
-
if (typeof commandValue === "string" && commandValue) continue;
|
|
3569
|
-
const value = input.baseEnv?.[name];
|
|
3570
|
-
if (typeof value === "string" && value) providerEnv[name] = value;
|
|
3571
|
-
}
|
|
3572
3597
|
const env = {
|
|
3573
3598
|
...sharedRuntime.settingsEnv,
|
|
3574
3599
|
...buildIsolatedEnvironment2(input.baseEnv, input.commandEnv),
|
|
3575
|
-
...providerEnv,
|
|
3576
3600
|
HOME: home,
|
|
3577
3601
|
PI_AGENT_HOME: piAgentHome,
|
|
3578
3602
|
PI_CODING_AGENT_SESSION_DIR: sessionsRoot,
|
|
@@ -3623,10 +3647,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
3623
3647
|
commandId: input.commandId,
|
|
3624
3648
|
runId,
|
|
3625
3649
|
sessionId: gateway.sessionId,
|
|
3626
|
-
...
|
|
3627
|
-
skillProfile,
|
|
3628
|
-
enabledSkillsDigest: createHash3("sha256").update(JSON.stringify(enabledRoleSkills)).digest("hex")
|
|
3629
|
-
} : {}
|
|
3650
|
+
...skillProfileAttestation(skillProfiles, enabledRoleSkills)
|
|
3630
3651
|
};
|
|
3631
3652
|
return {
|
|
3632
3653
|
profileRoot,
|
|
@@ -3644,7 +3665,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
3644
3665
|
protectedValues: [.../* @__PURE__ */ new Set([
|
|
3645
3666
|
sessionToken,
|
|
3646
3667
|
...sharedRuntime.protectedValues,
|
|
3647
|
-
...MANAGED_PI_PROVIDER_PROTECTED_ENV_NAMES.map((name) => input.commandEnv?.[name]
|
|
3668
|
+
...MANAGED_PI_PROVIDER_PROTECTED_ENV_NAMES.map((name) => input.commandEnv?.[name]).filter((value) => typeof value === "string" && value.length > 0)
|
|
3648
3669
|
])],
|
|
3649
3670
|
attestation: {
|
|
3650
3671
|
...attestationFacts,
|
|
@@ -3718,6 +3739,18 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
3718
3739
|
};
|
|
3719
3740
|
writePrivateFile2(configPath, `${JSON.stringify(config, null, 2)}
|
|
3720
3741
|
`);
|
|
3742
|
+
const skillProfiles = requestedSkillProfiles(input);
|
|
3743
|
+
const skillArgs = [];
|
|
3744
|
+
let enabledRoleSkills = null;
|
|
3745
|
+
if (skillProfiles.length > 0) {
|
|
3746
|
+
const roleSkills = materializeManagedRoleSkills(
|
|
3747
|
+
sourcePiHome,
|
|
3748
|
+
join4(profileRoot, "role-skills"),
|
|
3749
|
+
skillProfiles
|
|
3750
|
+
);
|
|
3751
|
+
skillArgs.push("--no-approve", "--skill", roleSkills.skillsDir);
|
|
3752
|
+
enabledRoleSkills = roleSkills.enabled;
|
|
3753
|
+
}
|
|
3721
3754
|
const env = {
|
|
3722
3755
|
...input.baseEnv,
|
|
3723
3756
|
...record6(input.commandEnv),
|
|
@@ -3746,7 +3779,8 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
3746
3779
|
sessionId: gateway.sessionId,
|
|
3747
3780
|
sourcePiHome,
|
|
3748
3781
|
piCodingAgentDir,
|
|
3749
|
-
configSha256: sha2562(readFileSync3(configPath))
|
|
3782
|
+
configSha256: sha2562(readFileSync3(configPath)),
|
|
3783
|
+
...skillProfileAttestation(skillProfiles, enabledRoleSkills)
|
|
3750
3784
|
};
|
|
3751
3785
|
return {
|
|
3752
3786
|
profileRoot,
|
|
@@ -3756,6 +3790,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
3756
3790
|
configPath,
|
|
3757
3791
|
markerPath,
|
|
3758
3792
|
env,
|
|
3793
|
+
skillArgs,
|
|
3759
3794
|
toolAllowlist: null,
|
|
3760
3795
|
protectedValues: [.../* @__PURE__ */ new Set([sessionToken, ...seededRuntime.protectedValues])],
|
|
3761
3796
|
attestation: {
|
|
@@ -6093,11 +6128,6 @@ var CAPABILITIES = [
|
|
|
6093
6128
|
];
|
|
6094
6129
|
var RUNNER_KIND_CLOUD_MANAGED = "cloud_managed";
|
|
6095
6130
|
var RUNNER_KIND_DESKTOP_DELEGATED = "desktop_delegated";
|
|
6096
|
-
var CREDENTIAL_SOURCE_EMPLOYEE_COMMAND_ENV = "employee_command_env";
|
|
6097
|
-
var CREDENTIAL_SOURCE_DESKTOP_PLATFORM_AUTH = "desktop_platform_auth";
|
|
6098
|
-
function credentialSourceForRunnerKind(runnerKind) {
|
|
6099
|
-
return runnerKind === RUNNER_KIND_DESKTOP_DELEGATED ? CREDENTIAL_SOURCE_DESKTOP_PLATFORM_AUTH : CREDENTIAL_SOURCE_EMPLOYEE_COMMAND_ENV;
|
|
6100
|
-
}
|
|
6101
6131
|
function readEnum(value, allowed, fallback, label) {
|
|
6102
6132
|
const text = String(value ?? "").trim();
|
|
6103
6133
|
if (!text) return fallback;
|
|
@@ -6243,7 +6273,6 @@ function buildConfig(env = process.env, flags = {}) {
|
|
|
6243
6273
|
RUNNER_KIND_CLOUD_MANAGED,
|
|
6244
6274
|
"AMASTER_RUNTIME_RUNNER_KIND"
|
|
6245
6275
|
);
|
|
6246
|
-
const credentialSource = credentialSourceForRunnerKind(runnerKind);
|
|
6247
6276
|
const agentInstructionSystemKernelMode = readEnum(
|
|
6248
6277
|
flags.agentInstructionSystemKernelMode ?? env.AMASTER_AGENT_INSTRUCTION_SYSTEM_KERNEL_MODE,
|
|
6249
6278
|
["shadow", "canary"],
|
|
@@ -6284,7 +6313,6 @@ function buildConfig(env = process.env, flags = {}) {
|
|
|
6284
6313
|
piExecutorUid,
|
|
6285
6314
|
piExecutorGid,
|
|
6286
6315
|
runnerKind,
|
|
6287
|
-
credentialSource,
|
|
6288
6316
|
agentInstructionSystemKernel: {
|
|
6289
6317
|
mode: agentInstructionSystemKernelMode,
|
|
6290
6318
|
agentIds: splitList(
|
|
@@ -6297,9 +6325,6 @@ function buildConfig(env = process.env, flags = {}) {
|
|
|
6297
6325
|
flags.agentInstructionSystemKernelSourceSha256Allowlist ?? env.AMASTER_AGENT_INSTRUCTION_SYSTEM_KERNEL_SOURCE_SHA256_ALLOWLIST ?? ""
|
|
6298
6326
|
).map((value) => value.toLowerCase())
|
|
6299
6327
|
},
|
|
6300
|
-
desktopPlatformSystemDataDir: String(
|
|
6301
|
-
flags.desktopPlatformSystemDataDir ?? env.AMASTER_RUNTIME_DESKTOP_PLATFORM_SYSTEM_DATA_DIR ?? ""
|
|
6302
|
-
).trim(),
|
|
6303
6328
|
capabilities: splitList(flags.capabilities ?? env.AMASTER_CAPABILITIES ?? CAPABILITIES.join(",")),
|
|
6304
6329
|
pollIntervalSeconds: Number(flags.pollIntervalSeconds ?? env.AMASTER_POLL_INTERVAL_SECONDS ?? 10),
|
|
6305
6330
|
maxConcurrentCommands: Math.min(
|
|
@@ -9280,7 +9305,7 @@ function assertSourceAcquisitionRuntimeAuthority({
|
|
|
9280
9305
|
}
|
|
9281
9306
|
|
|
9282
9307
|
// src/amaster-runtime-daemon.mjs
|
|
9283
|
-
var CONNECTOR_VERSION = "0.1.1-beta.
|
|
9308
|
+
var CONNECTOR_VERSION = "0.1.1-beta.26";
|
|
9284
9309
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
9285
9310
|
var SOURCE_ACQUISITION_CAPABILITY = "source_acquisition_v1";
|
|
9286
9311
|
var SOURCE_ACQUISITION_PROFILE_VERSION = "source_acquisition_v1";
|
|
@@ -9854,7 +9879,6 @@ function buildHeartbeatPayload(config, options = {}) {
|
|
|
9854
9879
|
const activeRunCommandList = Array.from(activeRunCommandById.values()).map((entry) => buildActiveRunCommandStatus(config, entry));
|
|
9855
9880
|
const activeRunCount = activeRunCommandList.filter(activeRunCommandCountsAsActive).length;
|
|
9856
9881
|
const executorReadiness = buildExecutorReadiness(config);
|
|
9857
|
-
const desktopPlatformCredential = desktopPlatformCredentialStatus(config);
|
|
9858
9882
|
const sourceAcquisition = sourceAcquisitionRuntimeReadiness(config);
|
|
9859
9883
|
const status = options.status === "offline" ? "offline" : "online";
|
|
9860
9884
|
const daemonStatus = status === "offline" ? "stopping" : "running";
|
|
@@ -9884,8 +9908,6 @@ function buildHeartbeatPayload(config, options = {}) {
|
|
|
9884
9908
|
stateFile: stateFilePath(process.env),
|
|
9885
9909
|
...executorReadiness.length > 0 ? { executorReadiness } : {},
|
|
9886
9910
|
runnerKind: config.runnerKind,
|
|
9887
|
-
credentialSource: config.credentialSource,
|
|
9888
|
-
...desktopPlatformCredential ? { desktopPlatformCredential } : {},
|
|
9889
9911
|
sourceAcquisition,
|
|
9890
9912
|
...versionDrift.versionDrift || versionDrift.bundleDrift ? versionDrift : {}
|
|
9891
9913
|
},
|
|
@@ -9897,52 +9919,6 @@ function buildHeartbeatPayload(config, options = {}) {
|
|
|
9897
9919
|
function desktopDelegatedRunnerEnabled(config) {
|
|
9898
9920
|
return config.runnerKind === RUNNER_KIND_DESKTOP_DELEGATED;
|
|
9899
9921
|
}
|
|
9900
|
-
function desktopPlatformCredentialEnabled(config) {
|
|
9901
|
-
return desktopDelegatedRunnerEnabled(config);
|
|
9902
|
-
}
|
|
9903
|
-
function desktopPlatformSystemDataDir(config) {
|
|
9904
|
-
const configured = readString(config.desktopPlatformSystemDataDir ?? process.env.AMASTER_RUNTIME_DESKTOP_PLATFORM_SYSTEM_DATA_DIR);
|
|
9905
|
-
return configured ? resolve9(expandHomePath(configured)) : null;
|
|
9906
|
-
}
|
|
9907
|
-
function readDesktopPlatformCredential(credentialsDir) {
|
|
9908
|
-
const pointer = readJsonFile2(join12(credentialsDir, "latest.json"));
|
|
9909
|
-
const credentialRef = readString(pointer.credentialRef);
|
|
9910
|
-
if (!credentialRef || !/^[a-f0-9]{64}$/i.test(credentialRef)) return null;
|
|
9911
|
-
const credential = readJsonFile2(join12(credentialsDir, `${credentialRef}.json`));
|
|
9912
|
-
const organizationId = readString(credential.organizationId);
|
|
9913
|
-
const apiKey = readString(credential.apiKey);
|
|
9914
|
-
if (credential.version !== 1 || !organizationId || !apiKey) return null;
|
|
9915
|
-
return {
|
|
9916
|
-
organizationId,
|
|
9917
|
-
apiKey,
|
|
9918
|
-
...readString(credential.baseUrl) ? { baseUrl: readString(credential.baseUrl) } : {}
|
|
9919
|
-
};
|
|
9920
|
-
}
|
|
9921
|
-
function desktopPlatformCredentials(config) {
|
|
9922
|
-
if (!desktopPlatformCredentialEnabled(config)) return [];
|
|
9923
|
-
const systemDataDir = desktopPlatformSystemDataDir(config);
|
|
9924
|
-
if (!systemDataDir) return [];
|
|
9925
|
-
const companiesDir = join12(systemDataDir, "companies");
|
|
9926
|
-
let entries = [];
|
|
9927
|
-
try {
|
|
9928
|
-
entries = readdirSync8(companiesDir, { withFileTypes: true });
|
|
9929
|
-
} catch {
|
|
9930
|
-
return [];
|
|
9931
|
-
}
|
|
9932
|
-
const credentialsByOrganizationId = /* @__PURE__ */ new Map();
|
|
9933
|
-
for (const entry of entries) {
|
|
9934
|
-
if (!entry.isDirectory()) continue;
|
|
9935
|
-
const credential = readDesktopPlatformCredential(join12(companiesDir, entry.name, "model-credentials"));
|
|
9936
|
-
if (credential) credentialsByOrganizationId.set(credential.organizationId, credential);
|
|
9937
|
-
}
|
|
9938
|
-
return [...credentialsByOrganizationId.values()];
|
|
9939
|
-
}
|
|
9940
|
-
function desktopPlatformCredentialStatus(config) {
|
|
9941
|
-
if (!desktopPlatformCredentialEnabled(config)) return null;
|
|
9942
|
-
return {
|
|
9943
|
-
readyOrganizationIds: desktopPlatformCredentials(config).map((credential) => credential.organizationId).sort()
|
|
9944
|
-
};
|
|
9945
|
-
}
|
|
9946
9922
|
function writeLocalRuntimeStatus(config, runtimeStatus) {
|
|
9947
9923
|
const currentState = readState(process.env);
|
|
9948
9924
|
writeState(process.env, {
|
|
@@ -10533,42 +10509,18 @@ function readJsonFile2(filePath) {
|
|
|
10533
10509
|
return {};
|
|
10534
10510
|
}
|
|
10535
10511
|
}
|
|
10536
|
-
function
|
|
10537
|
-
const desktopPlatformCredential = desktopPlatformCredentialForCommand(config, command);
|
|
10538
|
-
if (desktopPlatformCredentialEnabled(config) && !desktopPlatformCredential) {
|
|
10539
|
-
throw new Error("Desktop Platform credential is unavailable for this command organization");
|
|
10540
|
-
}
|
|
10541
|
-
return {
|
|
10542
|
-
providerConfig: desktopPlatformCredential ?? executorEnv,
|
|
10543
|
-
credentialSource: desktopPlatformCredential ? CREDENTIAL_SOURCE_DESKTOP_PLATFORM_AUTH : CREDENTIAL_SOURCE_EMPLOYEE_COMMAND_ENV
|
|
10544
|
-
};
|
|
10545
|
-
}
|
|
10546
|
-
async function syncPiExecutorProviderConfig(config, command, agentDir, resolvedProviderConfig) {
|
|
10512
|
+
async function syncPiExecutorProviderConfig(config, command, agentDir, providerConfig) {
|
|
10547
10513
|
if (!agentDir) return;
|
|
10548
|
-
const { providerConfig, credentialSource } = resolvedProviderConfig;
|
|
10549
10514
|
const { modelsSynced, settingsSynced } = syncAmasterProviderFiles(agentDir, providerConfig);
|
|
10550
10515
|
if (modelsSynced || settingsSynced) {
|
|
10551
10516
|
await ingestLog(config, command, "system", "info", "Synced AMaster provider config for pi executor", {
|
|
10552
10517
|
modelsSynced,
|
|
10553
10518
|
settingsSynced,
|
|
10554
|
-
credentialSource,
|
|
10519
|
+
credentialSource: "server_command_env",
|
|
10555
10520
|
providerBaseUrlConfigured: Boolean(readString(providerConfig.AMASTER_PROVIDER_BASE_URL))
|
|
10556
10521
|
});
|
|
10557
10522
|
}
|
|
10558
10523
|
}
|
|
10559
|
-
function desktopPlatformCredentialForCommand(config, command) {
|
|
10560
|
-
if (!desktopPlatformCredentialEnabled(config)) return null;
|
|
10561
|
-
const executionContext = asRecord(command.executionContext);
|
|
10562
|
-
const runtimeExecutionContext = asRecord(asRecord(command.runtimeAuth).executionContext);
|
|
10563
|
-
const organizationId = readString(executionContext.platformOrganizationId) ?? readString(runtimeExecutionContext.platformOrganizationId);
|
|
10564
|
-
if (!organizationId) return null;
|
|
10565
|
-
const credential = desktopPlatformCredentials(config).find((entry) => entry.organizationId === organizationId);
|
|
10566
|
-
if (!credential) return null;
|
|
10567
|
-
return {
|
|
10568
|
-
AMASTER_API_KEY: credential.apiKey,
|
|
10569
|
-
...credential.baseUrl ? { AMASTER_PROVIDER_BASE_URL: credential.baseUrl } : {}
|
|
10570
|
-
};
|
|
10571
|
-
}
|
|
10572
10524
|
function normalizeWorkspaceContext(workspace) {
|
|
10573
10525
|
if (typeof workspace === "string") {
|
|
10574
10526
|
return {
|
|
@@ -10753,6 +10705,7 @@ function buildExecutorEnv(config, command, workspace) {
|
|
|
10753
10705
|
const issueId = commandIssueId(command) ?? "";
|
|
10754
10706
|
const companyId = readString(runtimeAuth.companyId) ?? readString(asRecord(command.payload).companyId) ?? "";
|
|
10755
10707
|
const baseEnv = { ...process.env };
|
|
10708
|
+
for (const name of MANAGED_PI_PROVIDER_ENV_NAMES) delete baseEnv[name];
|
|
10756
10709
|
const executorPaths = readStringArray(config.executorPaths);
|
|
10757
10710
|
if (executorPaths.length > 0) {
|
|
10758
10711
|
baseEnv.PATH = [...executorPaths, baseEnv.PATH ?? ""].filter(Boolean).join(delimiter3);
|
|
@@ -13802,21 +13755,16 @@ async function executeRunCommand(config, command) {
|
|
|
13802
13755
|
cleanupManagedMcpProfile = cleanupManagedCodexMcpProfile;
|
|
13803
13756
|
}
|
|
13804
13757
|
if (executor.kind === "pi") {
|
|
13805
|
-
|
|
13806
|
-
for (const envName of MANAGED_PI_PROVIDER_ENV_NAMES) {
|
|
13807
|
-
delete executorEnv[envName];
|
|
13808
|
-
}
|
|
13809
|
-
}
|
|
13810
|
-
piResolvedProviderConfig = resolvePiExecutorProviderConfig(config, command, executorEnv);
|
|
13758
|
+
piResolvedProviderConfig = executorEnv;
|
|
13811
13759
|
for (const envName of ["AMASTER_API_KEY", "AMASTER_PLATFORM_OAUTH_TOKEN"]) {
|
|
13812
|
-
const protectedValue = readString(piResolvedProviderConfig
|
|
13760
|
+
const protectedValue = readString(piResolvedProviderConfig[envName]);
|
|
13813
13761
|
if (protectedValue && !providerProtectedValues.includes(protectedValue)) {
|
|
13814
13762
|
providerProtectedValues.push(protectedValue);
|
|
13815
13763
|
}
|
|
13816
13764
|
}
|
|
13817
13765
|
if (Object.keys(governedMcp).length > 0) {
|
|
13818
13766
|
const preparePiMcpProfile = desktopDelegatedRunnerEnabled(config) ? prepareDelegatedPiMcpProfile : prepareManagedPiMcpProfile;
|
|
13819
|
-
const piProfileCommandEnv =
|
|
13767
|
+
const piProfileCommandEnv = commandExecutorEnv(command);
|
|
13820
13768
|
managedMcpProfile = preparePiMcpProfile({
|
|
13821
13769
|
commandId: command.commandId,
|
|
13822
13770
|
runId: commandRunId(command),
|
|
@@ -13832,6 +13780,7 @@ async function executeRunCommand(config, command) {
|
|
|
13832
13780
|
extraArgs: sourceAcquisition ? [] : splitExtraArgs(process.env.AMASTER_PI_EXTRA_ARGS),
|
|
13833
13781
|
sourceAcquisition,
|
|
13834
13782
|
skillProfile: readString(asRecord(command.payload).skillProfile),
|
|
13783
|
+
skillProfiles: readStringArray(asRecord(command.payload).skillProfiles),
|
|
13835
13784
|
...config.piExecutorUid > 0 && !desktopDelegatedRunnerEnabled(config) ? {
|
|
13836
13785
|
prepareExecutorAccess: ({ profileRoot, workspaceRoot }) => preparePiExecutorAccess({
|
|
13837
13786
|
uid: config.piExecutorUid,
|
|
@@ -13882,7 +13831,7 @@ async function executeRunCommand(config, command) {
|
|
|
13882
13831
|
}
|
|
13883
13832
|
if (executor.kind === "pi" && piResolvedProviderConfig) {
|
|
13884
13833
|
const sharedPiHome = readString(process.env.PI_CODING_AGENT_DIR) ?? readString(process.env.PI_AGENT_HOME) ?? null;
|
|
13885
|
-
let agentDir = managedMcpProfile ? readString(managedMcpProfile.env.PI_CODING_AGENT_DIR) ?? readString(managedMcpProfile.env.PI_AGENT_HOME) ?? null :
|
|
13834
|
+
let agentDir = managedMcpProfile ? readString(managedMcpProfile.env.PI_CODING_AGENT_DIR) ?? readString(managedMcpProfile.env.PI_AGENT_HOME) ?? null : desktopDelegatedRunnerEnabled(config) ? readString(executorEnv.PI_AGENT_HOME) ?? readString(executorEnv.PI_CODING_AGENT_DIR) ?? null : readString(executorEnv.PI_CODING_AGENT_DIR) ?? readString(executorEnv.PI_AGENT_HOME) ?? null;
|
|
13886
13835
|
if (agentDir && sharedPiHome && resolve9(agentDir) === resolve9(sharedPiHome)) {
|
|
13887
13836
|
agentDir = null;
|
|
13888
13837
|
}
|
package/dist/amaster-runtime.mjs
CHANGED
|
@@ -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.
|
|
9
|
+
const CONNECTOR_VERSION = "0.1.1-beta.26";
|
|
10
10
|
|
|
11
11
|
const CAPABILITIES = [
|
|
12
12
|
"remote_registration",
|
|
@@ -55,7 +55,6 @@ const CONFIG_KEY_MAP = new Map([
|
|
|
55
55
|
["pi_agent_home", "PI_AGENT_HOME"],
|
|
56
56
|
["pi_agent_node", "PI_AGENT_NODE"],
|
|
57
57
|
["runner_kind", "AMASTER_RUNTIME_RUNNER_KIND"],
|
|
58
|
-
["desktop_platform_system_data_dir", "AMASTER_RUNTIME_DESKTOP_PLATFORM_SYSTEM_DATA_DIR"],
|
|
59
58
|
["heartbeat_log_mode", "AMASTER_HEARTBEAT_LOG_MODE"],
|
|
60
59
|
]);
|
|
61
60
|
|
|
@@ -84,7 +83,6 @@ const ENV_ORDER = [
|
|
|
84
83
|
"PI_AGENT_HOME",
|
|
85
84
|
"PI_AGENT_NODE",
|
|
86
85
|
"AMASTER_RUNTIME_RUNNER_KIND",
|
|
87
|
-
"AMASTER_RUNTIME_DESKTOP_PLATFORM_SYSTEM_DATA_DIR",
|
|
88
86
|
"AMASTER_HEARTBEAT_LOG_MODE",
|
|
89
87
|
];
|
|
90
88
|
|
|
@@ -459,7 +457,6 @@ function printConfig(config) {
|
|
|
459
457
|
["pi_agent_home", merged.PI_AGENT_HOME || "(default)"],
|
|
460
458
|
["pi_agent_node", merged.PI_AGENT_NODE || "(default)"],
|
|
461
459
|
["runner_kind", merged.AMASTER_RUNTIME_RUNNER_KIND || "cloud_managed"],
|
|
462
|
-
["desktop_platform_system_data_dir", merged.AMASTER_RUNTIME_DESKTOP_PLATFORM_SYSTEM_DATA_DIR ? "(configured)" : "(not configured)"],
|
|
463
460
|
["heartbeat_log_mode", merged.AMASTER_HEARTBEAT_LOG_MODE || "(compact)"],
|
|
464
461
|
["network_domains", merged.AMASTER_NETWORK_DOMAINS],
|
|
465
462
|
["capabilities", merged.AMASTER_CAPABILITIES],
|