@amaster.ai/employee-runtime-connector 0.1.0-beta.29 → 0.1.0-beta.30
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.
|
@@ -4750,7 +4750,7 @@ function readWorkspaceStatus(cwd, opts = {}) {
|
|
|
4750
4750
|
}
|
|
4751
4751
|
|
|
4752
4752
|
// src/amaster-runtime-daemon.mjs
|
|
4753
|
-
var CONNECTOR_VERSION = "0.1.0-beta.
|
|
4753
|
+
var CONNECTOR_VERSION = "0.1.0-beta.30";
|
|
4754
4754
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
4755
4755
|
var MAX_CHECKPOINT_BYTES = 20 * 1024 * 1024;
|
|
4756
4756
|
var CHECKPOINT_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -5178,6 +5178,7 @@ function buildHeartbeatPayload(config, options = {}) {
|
|
|
5178
5178
|
}
|
|
5179
5179
|
const activeRunCommandList = Array.from(activeRunCommandById.values()).map((entry) => buildActiveRunCommandStatus(config, entry));
|
|
5180
5180
|
const executorReadiness = buildExecutorReadiness(config);
|
|
5181
|
+
const platformCredential = piAgentLocalPlatformCredentialStatus(config);
|
|
5181
5182
|
return {
|
|
5182
5183
|
status: "online",
|
|
5183
5184
|
workspaceBindings: config.workspaceBindings,
|
|
@@ -5202,6 +5203,7 @@ function buildHeartbeatPayload(config, options = {}) {
|
|
|
5202
5203
|
...Object.keys(orphanReaperSummary).length > 0 ? { orphanReaper: orphanReaperSummary } : {},
|
|
5203
5204
|
stateFile: stateFilePath(process.env),
|
|
5204
5205
|
...executorReadiness.length > 0 ? { executorReadiness } : {},
|
|
5206
|
+
...platformCredential ? { platformCredential } : {},
|
|
5205
5207
|
...versionDrift.versionDrift || versionDrift.bundleDrift ? versionDrift : {}
|
|
5206
5208
|
},
|
|
5207
5209
|
metadata: {
|
|
@@ -5209,6 +5211,56 @@ function buildHeartbeatPayload(config, options = {}) {
|
|
|
5209
5211
|
}
|
|
5210
5212
|
};
|
|
5211
5213
|
}
|
|
5214
|
+
var PI_AGENT_LOCAL_PLATFORM_RUNNER_MODE = "local_platform";
|
|
5215
|
+
function piAgentLocalPlatformRunnerEnabled(config) {
|
|
5216
|
+
return readString(config.AMASTER_PI_AGENT_RUNNER_MODE ?? process.env.AMASTER_PI_AGENT_RUNNER_MODE) === PI_AGENT_LOCAL_PLATFORM_RUNNER_MODE;
|
|
5217
|
+
}
|
|
5218
|
+
function piAgentSystemDataDir(config) {
|
|
5219
|
+
const configured = readString(config.AMASTER_PI_AGENT_SYSTEM_DATA_DIR ?? process.env.AMASTER_PI_AGENT_SYSTEM_DATA_DIR);
|
|
5220
|
+
return configured ? resolve8(expandHomePath(configured)) : null;
|
|
5221
|
+
}
|
|
5222
|
+
function readPiAgentLocalPlatformCredential(credentialsDir) {
|
|
5223
|
+
const pointer = readJsonFile(join10(credentialsDir, "latest.json"));
|
|
5224
|
+
const credentialRef = readString(pointer.credentialRef);
|
|
5225
|
+
if (!credentialRef || !/^[a-f0-9]{64}$/i.test(credentialRef)) return null;
|
|
5226
|
+
const credential = readJsonFile(join10(credentialsDir, `${credentialRef}.json`));
|
|
5227
|
+
const organizationId = readString(credential.organizationId);
|
|
5228
|
+
const apiKey = readString(credential.apiKey);
|
|
5229
|
+
if (credential.version !== 1 || !organizationId || !apiKey) return null;
|
|
5230
|
+
return {
|
|
5231
|
+
organizationId,
|
|
5232
|
+
apiKey,
|
|
5233
|
+
...readString(credential.baseUrl) ? { baseUrl: readString(credential.baseUrl) } : {},
|
|
5234
|
+
...readString(credential.defaultModel) ? { defaultModel: readString(credential.defaultModel) } : {},
|
|
5235
|
+
...readString(credential.flashModel) ? { flashModel: readString(credential.flashModel) } : {}
|
|
5236
|
+
};
|
|
5237
|
+
}
|
|
5238
|
+
function piAgentLocalPlatformCredentials(config) {
|
|
5239
|
+
if (!piAgentLocalPlatformRunnerEnabled(config)) return [];
|
|
5240
|
+
const systemDataDir = piAgentSystemDataDir(config);
|
|
5241
|
+
if (!systemDataDir) return [];
|
|
5242
|
+
const companiesDir = join10(systemDataDir, "companies");
|
|
5243
|
+
let entries = [];
|
|
5244
|
+
try {
|
|
5245
|
+
entries = readdirSync6(companiesDir, { withFileTypes: true });
|
|
5246
|
+
} catch {
|
|
5247
|
+
return [];
|
|
5248
|
+
}
|
|
5249
|
+
const credentialsByOrganizationId = /* @__PURE__ */ new Map();
|
|
5250
|
+
for (const entry of entries) {
|
|
5251
|
+
if (!entry.isDirectory()) continue;
|
|
5252
|
+
const credential = readPiAgentLocalPlatformCredential(join10(companiesDir, entry.name, "model-credentials"));
|
|
5253
|
+
if (credential) credentialsByOrganizationId.set(credential.organizationId, credential);
|
|
5254
|
+
}
|
|
5255
|
+
return [...credentialsByOrganizationId.values()];
|
|
5256
|
+
}
|
|
5257
|
+
function piAgentLocalPlatformCredentialStatus(config) {
|
|
5258
|
+
if (!piAgentLocalPlatformRunnerEnabled(config)) return null;
|
|
5259
|
+
return {
|
|
5260
|
+
mode: PI_AGENT_LOCAL_PLATFORM_RUNNER_MODE,
|
|
5261
|
+
readyOrganizationIds: piAgentLocalPlatformCredentials(config).map((credential) => credential.organizationId).sort()
|
|
5262
|
+
};
|
|
5263
|
+
}
|
|
5212
5264
|
function writeLocalRuntimeStatus(config, runtimeStatus) {
|
|
5213
5265
|
const currentState = readState(process.env);
|
|
5214
5266
|
writeState(process.env, {
|
|
@@ -5872,20 +5924,42 @@ function syncAmasterProviderSettings(agentDir, executorEnv) {
|
|
|
5872
5924
|
return true;
|
|
5873
5925
|
}
|
|
5874
5926
|
async function preparePiExecutorProviderConfig(config, command, executorEnv) {
|
|
5875
|
-
const
|
|
5927
|
+
const hasGovernedMcp = Object.keys(asRecord(commandRuntimeAuth(command).governedMcp)).length > 0;
|
|
5928
|
+
const agentDir = piAgentLocalPlatformRunnerEnabled(config) || hasGovernedMcp ? readString(executorEnv.PI_AGENT_HOME) ?? readString(executorEnv.PI_CODING_AGENT_DIR) : readString(executorEnv.PI_CODING_AGENT_DIR) ?? readString(executorEnv.PI_AGENT_HOME) ?? null;
|
|
5876
5929
|
if (!agentDir) return;
|
|
5877
|
-
const
|
|
5878
|
-
|
|
5930
|
+
const localPlatformCredential = piAgentLocalPlatformCredentialForCommand(config, command);
|
|
5931
|
+
if (piAgentLocalPlatformRunnerEnabled(config) && !localPlatformCredential) {
|
|
5932
|
+
throw new Error("Pi Agent local Platform credential is unavailable for this command organization");
|
|
5933
|
+
}
|
|
5934
|
+
const providerConfig = localPlatformCredential ?? executorEnv;
|
|
5935
|
+
const modelsSynced = syncAmasterProviderModels(agentDir, providerConfig);
|
|
5936
|
+
const settingsSynced = syncAmasterProviderSettings(agentDir, providerConfig);
|
|
5879
5937
|
if (modelsSynced || settingsSynced) {
|
|
5880
5938
|
await ingestLog(config, command, "system", "info", "Synced AMaster provider config for pi executor", {
|
|
5881
5939
|
modelsSynced,
|
|
5882
5940
|
settingsSynced,
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5941
|
+
credentialSource: localPlatformCredential ? "pi_agent_local_platform" : "command_executor_env",
|
|
5942
|
+
providerBaseUrlConfigured: Boolean(readString(providerConfig.AMASTER_PROVIDER_BASE_URL)),
|
|
5943
|
+
defaultModelConfigured: Boolean(readString(providerConfig.AMASTER_PROVIDER_DEFAULT_MODEL)),
|
|
5944
|
+
flashModelConfigured: Boolean(readString(providerConfig.AMASTER_PROVIDER_FLASH_MODEL))
|
|
5886
5945
|
});
|
|
5887
5946
|
}
|
|
5888
5947
|
}
|
|
5948
|
+
function piAgentLocalPlatformCredentialForCommand(config, command) {
|
|
5949
|
+
if (!piAgentLocalPlatformRunnerEnabled(config)) return null;
|
|
5950
|
+
const executionContext = asRecord(command.executionContext);
|
|
5951
|
+
const runtimeExecutionContext = asRecord(asRecord(command.runtimeAuth).executionContext);
|
|
5952
|
+
const organizationId = readString(executionContext.platformOrganizationId) ?? readString(runtimeExecutionContext.platformOrganizationId);
|
|
5953
|
+
if (!organizationId) return null;
|
|
5954
|
+
const credential = piAgentLocalPlatformCredentials(config).find((entry) => entry.organizationId === organizationId);
|
|
5955
|
+
if (!credential) return null;
|
|
5956
|
+
return {
|
|
5957
|
+
AMASTER_API_KEY: credential.apiKey,
|
|
5958
|
+
...credential.baseUrl ? { AMASTER_PROVIDER_BASE_URL: credential.baseUrl } : {},
|
|
5959
|
+
...credential.defaultModel ? { AMASTER_PROVIDER_DEFAULT_MODEL: credential.defaultModel } : {},
|
|
5960
|
+
...credential.flashModel ? { AMASTER_PROVIDER_FLASH_MODEL: credential.flashModel } : {}
|
|
5961
|
+
};
|
|
5962
|
+
}
|
|
5889
5963
|
function normalizeWorkspaceContext(workspace) {
|
|
5890
5964
|
if (typeof workspace === "string") {
|
|
5891
5965
|
return {
|
|
@@ -6012,6 +6086,9 @@ function companyPiAgentHome(baseEnv, companyId) {
|
|
|
6012
6086
|
if (!segment) return null;
|
|
6013
6087
|
return join10(companyPiHomeRoot(baseEnv), segment, ".pi");
|
|
6014
6088
|
}
|
|
6089
|
+
function commandUsesPiExecutor(command) {
|
|
6090
|
+
return readString(asRecord(command.payload).executorKind) === "pi";
|
|
6091
|
+
}
|
|
6015
6092
|
function buildExecutorEnv(config, command, workspace) {
|
|
6016
6093
|
const workspaceContext = normalizeWorkspaceContext(workspace);
|
|
6017
6094
|
const cwd = workspaceContext.cwd;
|
|
@@ -6021,6 +6098,7 @@ function buildExecutorEnv(config, command, workspace) {
|
|
|
6021
6098
|
const companyId = readString(runtimeAuth.companyId) ?? readString(asRecord(command.payload).companyId) ?? "";
|
|
6022
6099
|
const baseEnv = { ...process.env };
|
|
6023
6100
|
const piAgentHome = companyPiAgentHome(baseEnv, companyId);
|
|
6101
|
+
const hasGovernedMcp = Object.keys(asRecord(runtimeAuth.governedMcp)).length > 0;
|
|
6024
6102
|
const executorPaths = readStringArray(config.executorPaths);
|
|
6025
6103
|
if (executorPaths.length > 0) {
|
|
6026
6104
|
baseEnv.PATH = [...executorPaths, baseEnv.PATH ?? ""].filter(Boolean).join(delimiter2);
|
|
@@ -6029,6 +6107,10 @@ function buildExecutorEnv(config, command, workspace) {
|
|
|
6029
6107
|
...baseEnv,
|
|
6030
6108
|
...commandExecutorEnv(command),
|
|
6031
6109
|
...piAgentHome ? { PI_AGENT_HOME: piAgentHome } : {},
|
|
6110
|
+
...piAgentHome && commandUsesPiExecutor(command) && !piAgentLocalPlatformRunnerEnabled(config) && !hasGovernedMcp ? {
|
|
6111
|
+
PI_CODING_AGENT_DIR: piAgentHome,
|
|
6112
|
+
"AMASTER-CLI_CODING_AGENT_DIR": piAgentHome
|
|
6113
|
+
} : {},
|
|
6032
6114
|
AMASTER_RUNTIME_COMMAND_ID: command.commandId,
|
|
6033
6115
|
AMASTER_RUNTIME_RUN_ID: runId,
|
|
6034
6116
|
AMASTER_RUNTIME_ISSUE_ID: issueId,
|
|
@@ -7847,6 +7929,12 @@ async function executeRunCommand(config, command) {
|
|
|
7847
7929
|
cleanupManagedMcpProfile = cleanupManagedCodexMcpProfile;
|
|
7848
7930
|
}
|
|
7849
7931
|
if (executor.kind === "pi") {
|
|
7932
|
+
if (piAgentLocalPlatformRunnerEnabled(config)) {
|
|
7933
|
+
delete executorEnv.AMASTER_API_KEY;
|
|
7934
|
+
delete executorEnv.AMASTER_PROVIDER_BASE_URL;
|
|
7935
|
+
delete executorEnv.AMASTER_PROVIDER_DEFAULT_MODEL;
|
|
7936
|
+
delete executorEnv.AMASTER_PROVIDER_FLASH_MODEL;
|
|
7937
|
+
}
|
|
7850
7938
|
await preparePiExecutorProviderConfig(config, command, executorEnv);
|
|
7851
7939
|
if (Object.keys(governedMcp).length > 0) {
|
|
7852
7940
|
managedMcpProfile = prepareManagedPiMcpProfile({
|
package/dist/amaster-runtime.mjs
CHANGED
|
@@ -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.0-beta.
|
|
8
|
+
const CONNECTOR_VERSION = "0.1.0-beta.30";
|
|
9
9
|
|
|
10
10
|
const CAPABILITIES = [
|
|
11
11
|
"remote_registration",
|
|
@@ -52,6 +52,8 @@ const CONFIG_KEY_MAP = new Map([
|
|
|
52
52
|
["pi_coding_agent_dir", "PI_CODING_AGENT_DIR"],
|
|
53
53
|
["pi_agent_home", "PI_AGENT_HOME"],
|
|
54
54
|
["pi_agent_node", "PI_AGENT_NODE"],
|
|
55
|
+
["pi_agent_runner_mode", "AMASTER_PI_AGENT_RUNNER_MODE"],
|
|
56
|
+
["pi_agent_system_data_dir", "AMASTER_PI_AGENT_SYSTEM_DATA_DIR"],
|
|
55
57
|
["heartbeat_log_mode", "AMASTER_HEARTBEAT_LOG_MODE"],
|
|
56
58
|
]);
|
|
57
59
|
|
|
@@ -79,6 +81,8 @@ const ENV_ORDER = [
|
|
|
79
81
|
"PI_CODING_AGENT_DIR",
|
|
80
82
|
"PI_AGENT_HOME",
|
|
81
83
|
"PI_AGENT_NODE",
|
|
84
|
+
"AMASTER_PI_AGENT_RUNNER_MODE",
|
|
85
|
+
"AMASTER_PI_AGENT_SYSTEM_DATA_DIR",
|
|
82
86
|
"AMASTER_HEARTBEAT_LOG_MODE",
|
|
83
87
|
];
|
|
84
88
|
|
|
@@ -400,6 +404,8 @@ function printConfig(config) {
|
|
|
400
404
|
["pi_coding_agent_dir", merged.PI_CODING_AGENT_DIR || "(default)"],
|
|
401
405
|
["pi_agent_home", merged.PI_AGENT_HOME || "(default)"],
|
|
402
406
|
["pi_agent_node", merged.PI_AGENT_NODE || "(default)"],
|
|
407
|
+
["pi_agent_runner_mode", merged.AMASTER_PI_AGENT_RUNNER_MODE || "(disabled)"],
|
|
408
|
+
["pi_agent_system_data_dir", merged.AMASTER_PI_AGENT_SYSTEM_DATA_DIR ? "(configured)" : "(not configured)"],
|
|
403
409
|
["heartbeat_log_mode", merged.AMASTER_HEARTBEAT_LOG_MODE || "(compact)"],
|
|
404
410
|
["network_domains", merged.AMASTER_NETWORK_DOMAINS],
|
|
405
411
|
["capabilities", merged.AMASTER_CAPABILITIES],
|