@amaster.ai/employee-runtime-connector 0.1.0-beta.44 → 0.1.0-beta.46
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 +123 -18
- package/dist/amaster-runtime.mjs +1 -1
- package/package.json +1 -1
|
@@ -1876,6 +1876,8 @@ var piManagedMcpProfileApi = (() => {
|
|
|
1876
1876
|
const PROFILE_MARKER2 = ".amaster-managed-pi-profile.json";
|
|
1877
1877
|
const SESSION_ROLLOUT_MARKER2 = ".amaster-pi-session-rollout.json";
|
|
1878
1878
|
const DEFAULT_SESSION_ROLLOUT_TTL_MS2 = 24 * 60 * 60 * 1e3;
|
|
1879
|
+
const PI_ATTESTATION_TIMEOUT_MS = 1e4;
|
|
1880
|
+
const PI_ATTESTATION_MAX_ATTEMPTS = 2;
|
|
1879
1881
|
function record4(value) {
|
|
1880
1882
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1881
1883
|
}
|
|
@@ -2210,15 +2212,25 @@ var piManagedMcpProfileApi = (() => {
|
|
|
2210
2212
|
return { adapterVersion, protectedValues };
|
|
2211
2213
|
}
|
|
2212
2214
|
function attestPi(executorCommand, env, configPath, expectedConfig) {
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2215
|
+
let result2;
|
|
2216
|
+
for (let attempt = 1; attempt <= PI_ATTESTATION_MAX_ATTEMPTS; attempt += 1) {
|
|
2217
|
+
result2 = spawnSync2(executorCommand, ["--version"], {
|
|
2218
|
+
cwd: env.AMASTER_RUNTIME_EXECUTION_WORKDIR,
|
|
2219
|
+
env,
|
|
2220
|
+
encoding: "utf8",
|
|
2221
|
+
timeout: PI_ATTESTATION_TIMEOUT_MS,
|
|
2222
|
+
killSignal: "SIGKILL",
|
|
2223
|
+
maxBuffer: 1024 * 1024
|
|
2224
|
+
});
|
|
2225
|
+
if (result2.error?.code === "ETIMEDOUT" && attempt < PI_ATTESTATION_MAX_ATTEMPTS) continue;
|
|
2226
|
+
break;
|
|
2227
|
+
}
|
|
2228
|
+
if (result2.error) {
|
|
2229
|
+
const errorCode = typeof result2.error.code === "string" ? result2.error.code : "UNKNOWN";
|
|
2230
|
+
throw new Error(`pi_managed_mcp_attestation_failed: --version error=${errorCode}`);
|
|
2231
|
+
}
|
|
2232
|
+
if (result2.status !== 0) {
|
|
2233
|
+
throw new Error(`pi_managed_mcp_attestation_failed: --version exit=${result2.status ?? "unknown"}`);
|
|
2222
2234
|
}
|
|
2223
2235
|
const executorVersion = parseVersion(`${result2.stdout ?? ""}
|
|
2224
2236
|
${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
@@ -3793,6 +3805,16 @@ function classifyPiTerminalCleanupDisposition(parsed, runtimeArtifacts) {
|
|
|
3793
3805
|
diagnostics
|
|
3794
3806
|
};
|
|
3795
3807
|
}
|
|
3808
|
+
function classifyPiTurnLimitResult(parsed) {
|
|
3809
|
+
const stopReason = readString(parsed?.stopReason);
|
|
3810
|
+
if (parsed?.terminalEventType !== "agent_end" || !["toolUse", "tool_use"].includes(stopReason ?? "")) return null;
|
|
3811
|
+
return {
|
|
3812
|
+
errorCode: "max_turns_exhausted",
|
|
3813
|
+
errorFamily: "execution_limit",
|
|
3814
|
+
stopReason: "max_turns_exhausted",
|
|
3815
|
+
message: "Pi Agent exhausted its turn limit while waiting to continue tool work"
|
|
3816
|
+
};
|
|
3817
|
+
}
|
|
3796
3818
|
function codexMcpToolResults(event) {
|
|
3797
3819
|
if (event?.type !== "item.completed") return [];
|
|
3798
3820
|
const item = asRecord(event.item);
|
|
@@ -5051,7 +5073,79 @@ function normalizeRuntimeVersionText(value) {
|
|
|
5051
5073
|
const trimmed = value.trim();
|
|
5052
5074
|
return trimmed ? trimmed : null;
|
|
5053
5075
|
}
|
|
5054
|
-
|
|
5076
|
+
var EXACT_SEMVER_PATTERN = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;
|
|
5077
|
+
function isExactSemverVersion(value) {
|
|
5078
|
+
const normalized = normalizeRuntimeVersionText(value);
|
|
5079
|
+
const match = normalized?.match(EXACT_SEMVER_PATTERN);
|
|
5080
|
+
if (!match) return false;
|
|
5081
|
+
const prerelease = match[4]?.split(".") ?? [];
|
|
5082
|
+
return !prerelease.some(
|
|
5083
|
+
(identifier) => /^\d+$/.test(identifier) && identifier.length > 1 && identifier.startsWith("0")
|
|
5084
|
+
);
|
|
5085
|
+
}
|
|
5086
|
+
function compareNumericSemverIdentifiers(left, right) {
|
|
5087
|
+
if (left.length !== right.length) return left.length < right.length ? -1 : 1;
|
|
5088
|
+
if (left === right) return 0;
|
|
5089
|
+
return left < right ? -1 : 1;
|
|
5090
|
+
}
|
|
5091
|
+
function compareExactSemverVersions(current, recommended) {
|
|
5092
|
+
const normalizedCurrent = normalizeRuntimeVersionText(current);
|
|
5093
|
+
const normalizedRecommended = normalizeRuntimeVersionText(recommended);
|
|
5094
|
+
if (!normalizedCurrent || !normalizedRecommended || !isExactSemverVersion(normalizedCurrent) || !isExactSemverVersion(normalizedRecommended)) {
|
|
5095
|
+
return null;
|
|
5096
|
+
}
|
|
5097
|
+
const currentMatch = normalizedCurrent.match(EXACT_SEMVER_PATTERN);
|
|
5098
|
+
const recommendedMatch = normalizedRecommended.match(EXACT_SEMVER_PATTERN);
|
|
5099
|
+
if (!currentMatch || !recommendedMatch) return null;
|
|
5100
|
+
for (const index of [1, 2, 3]) {
|
|
5101
|
+
const comparison = compareNumericSemverIdentifiers(
|
|
5102
|
+
currentMatch[index],
|
|
5103
|
+
recommendedMatch[index]
|
|
5104
|
+
);
|
|
5105
|
+
if (comparison !== 0) return comparison;
|
|
5106
|
+
}
|
|
5107
|
+
const currentPrerelease = currentMatch[4]?.split(".");
|
|
5108
|
+
const recommendedPrerelease = recommendedMatch[4]?.split(".");
|
|
5109
|
+
if (!currentPrerelease && !recommendedPrerelease) return 0;
|
|
5110
|
+
if (!currentPrerelease) return 1;
|
|
5111
|
+
if (!recommendedPrerelease) return -1;
|
|
5112
|
+
const identifierCount = Math.max(
|
|
5113
|
+
currentPrerelease.length,
|
|
5114
|
+
recommendedPrerelease.length
|
|
5115
|
+
);
|
|
5116
|
+
for (let index = 0; index < identifierCount; index += 1) {
|
|
5117
|
+
const currentIdentifier = currentPrerelease[index];
|
|
5118
|
+
const recommendedIdentifier = recommendedPrerelease[index];
|
|
5119
|
+
if (currentIdentifier === void 0) return -1;
|
|
5120
|
+
if (recommendedIdentifier === void 0) return 1;
|
|
5121
|
+
if (currentIdentifier === recommendedIdentifier) continue;
|
|
5122
|
+
const currentIsNumeric = /^\d+$/.test(currentIdentifier);
|
|
5123
|
+
const recommendedIsNumeric = /^\d+$/.test(recommendedIdentifier);
|
|
5124
|
+
if (currentIsNumeric && recommendedIsNumeric) {
|
|
5125
|
+
return compareNumericSemverIdentifiers(
|
|
5126
|
+
currentIdentifier,
|
|
5127
|
+
recommendedIdentifier
|
|
5128
|
+
);
|
|
5129
|
+
}
|
|
5130
|
+
if (currentIsNumeric !== recommendedIsNumeric) {
|
|
5131
|
+
return currentIsNumeric ? -1 : 1;
|
|
5132
|
+
}
|
|
5133
|
+
return currentIdentifier < recommendedIdentifier ? -1 : 1;
|
|
5134
|
+
}
|
|
5135
|
+
return 0;
|
|
5136
|
+
}
|
|
5137
|
+
function versionPairRequiresUpgrade(current, recommended) {
|
|
5138
|
+
const normalizedCurrent = normalizeRuntimeVersionText(current);
|
|
5139
|
+
const normalizedRecommended = normalizeRuntimeVersionText(recommended);
|
|
5140
|
+
if (!normalizedCurrent || !normalizedRecommended) return false;
|
|
5141
|
+
const comparison = compareExactSemverVersions(
|
|
5142
|
+
normalizedCurrent,
|
|
5143
|
+
normalizedRecommended
|
|
5144
|
+
);
|
|
5145
|
+
if (comparison !== null) return comparison < 0;
|
|
5146
|
+
return false;
|
|
5147
|
+
}
|
|
5148
|
+
function normalizedTextPairDiffers(current, recommended) {
|
|
5055
5149
|
const normalizedCurrent = normalizeRuntimeVersionText(current);
|
|
5056
5150
|
const normalizedRecommended = normalizeRuntimeVersionText(recommended);
|
|
5057
5151
|
if (!normalizedCurrent || !normalizedRecommended) return false;
|
|
@@ -5060,10 +5154,10 @@ function versionPairDiffers(current, recommended) {
|
|
|
5060
5154
|
function summarizeAmasterRuntimeVersionDrift(input = {}) {
|
|
5061
5155
|
const versionMismatches = [];
|
|
5062
5156
|
const bundleMismatches = [];
|
|
5063
|
-
if (
|
|
5157
|
+
if (versionPairRequiresUpgrade(input.connectorVersion, input.recommendedConnectorVersion)) {
|
|
5064
5158
|
versionMismatches.push("connector package version differs from the recommended package");
|
|
5065
5159
|
}
|
|
5066
|
-
if (
|
|
5160
|
+
if (normalizedTextPairDiffers(input.buildCommit, input.recommendedBuildCommit)) {
|
|
5067
5161
|
bundleMismatches.push("build commit differs from the deployed connector package");
|
|
5068
5162
|
}
|
|
5069
5163
|
const recommendedConnectorVersion = normalizeRuntimeVersionText(input.recommendedConnectorVersion);
|
|
@@ -6159,7 +6253,7 @@ function readWorkspaceStatus(cwd, opts = {}) {
|
|
|
6159
6253
|
}
|
|
6160
6254
|
|
|
6161
6255
|
// src/amaster-runtime-daemon.mjs
|
|
6162
|
-
var CONNECTOR_VERSION = "0.1.0-beta.
|
|
6256
|
+
var CONNECTOR_VERSION = "0.1.0-beta.46";
|
|
6163
6257
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
6164
6258
|
var MAX_CHECKPOINT_BYTES = 20 * 1024 * 1024;
|
|
6165
6259
|
var CHECKPOINT_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -6437,7 +6531,10 @@ function piCapabilitySourcesDiagnostics() {
|
|
|
6437
6531
|
const piAgentHome = configuredPiAgentHome ?? piCodingAgentDir;
|
|
6438
6532
|
const piAgentHomeSource = configuredPiAgentHome ? "PI_AGENT_HOME" : piCodingAgentDirSource;
|
|
6439
6533
|
const userSkillsPath = piAgentHome ? join13(piAgentHome, "skills") : null;
|
|
6440
|
-
const
|
|
6534
|
+
const configuredMarketplaceSkillsPath = safeExpandPath(
|
|
6535
|
+
process.env.PI_AGENT_MARKETPLACE_SKILLS_DIR
|
|
6536
|
+
);
|
|
6537
|
+
const marketplaceSkillsPath = configuredMarketplaceSkillsPath ?? (piAgentHome ? join13(piAgentHome, "marketplace", "skills") : null);
|
|
6441
6538
|
const builtinSkillsPath = safeExpandPath(process.env.PI_AGENT_BUILTIN_SKILLS_DIR) ?? safeExpandPath(process.env.AMASTER_BUILTIN_SKILLS);
|
|
6442
6539
|
const mcpConfigPath = safeExpandPath(process.env.PI_AGENT_MCP_SERVERS_FILE) ?? (piAgentHome ? join13(piAgentHome, "mcp.json") : null);
|
|
6443
6540
|
const settingsConfigPath = piCodingAgentDir ? join13(piCodingAgentDir, "settings.json") : null;
|
|
@@ -6445,7 +6542,7 @@ function piCapabilitySourcesDiagnostics() {
|
|
|
6445
6542
|
safeSkillRootSummary("user", `${piAgentHomeSource}/skills`, userSkillsPath),
|
|
6446
6543
|
safeSkillRootSummary(
|
|
6447
6544
|
"marketplace",
|
|
6448
|
-
|
|
6545
|
+
configuredMarketplaceSkillsPath ? "PI_AGENT_MARKETPLACE_SKILLS_DIR" : `${piAgentHomeSource}/marketplace/skills`,
|
|
6449
6546
|
marketplaceSkillsPath
|
|
6450
6547
|
),
|
|
6451
6548
|
safeSkillRootSummary(
|
|
@@ -6455,7 +6552,9 @@ function piCapabilitySourcesDiagnostics() {
|
|
|
6455
6552
|
)
|
|
6456
6553
|
];
|
|
6457
6554
|
const visibleSkillCount = skillRoots.reduce((sum, root) => sum + readNumber(root.skillCount, 0), 0);
|
|
6458
|
-
const missingRootKinds = skillRoots.filter(
|
|
6555
|
+
const missingRootKinds = skillRoots.filter(
|
|
6556
|
+
(root) => root.configured === true && root.available !== true && (root.kind !== "marketplace" || configuredMarketplaceSkillsPath)
|
|
6557
|
+
).map((root) => root.kind);
|
|
6459
6558
|
const mcpConfig = safeJsonConfigSummary(
|
|
6460
6559
|
readString(process.env.PI_AGENT_MCP_SERVERS_FILE) ? "PI_AGENT_MCP_SERVERS_FILE" : `${piAgentHomeSource}/mcp.json`,
|
|
6461
6560
|
mcpConfigPath,
|
|
@@ -9724,12 +9823,13 @@ async function executeRunCommand(config, command) {
|
|
|
9724
9823
|
);
|
|
9725
9824
|
}
|
|
9726
9825
|
const parsedForValidation = cleanupDisposition ? { ...parsed, errorMessage: null } : parsed;
|
|
9826
|
+
const piTurnLimitFailure = executor.kind === "pi" && !cancelled && !hasOutputFlood && !hasMemoryLimit && execution.timedOut !== true && !execution.spawnError ? classifyPiTurnLimitResult(parsedForValidation) : null;
|
|
9727
9827
|
const piInvalidOutputError = executor.kind === "pi" ? piOutputValidationError(parsedForValidation, {
|
|
9728
9828
|
allowMissingTurnEnd: completionOutputStopped || Boolean(cleanupDisposition),
|
|
9729
9829
|
allowMissingAssistantOutput: execution.completionOutputType === "approval_required"
|
|
9730
9830
|
}) : null;
|
|
9731
9831
|
const piProviderFailure = executor.kind === "pi" && !cancelled && !hasOutputFlood && !hasMemoryLimit && execution.timedOut !== true && !execution.spawnError ? classifyPiProviderError(parsedForValidation) : null;
|
|
9732
|
-
const parsedErrorMessage = outputFloodError ?? memoryLimitError ?? piInvalidOutputError ?? nativeSessionRolloutError ?? nativeSessionRolloutCleanupError ?? parsedForValidation.errorMessage;
|
|
9832
|
+
const parsedErrorMessage = outputFloodError ?? memoryLimitError ?? piTurnLimitFailure?.message ?? piInvalidOutputError ?? nativeSessionRolloutError ?? nativeSessionRolloutCleanupError ?? parsedForValidation.errorMessage;
|
|
9733
9833
|
const codexTransientFailure = executor.kind === "codex" && (execution.exitCode ?? 0) !== 0 ? classifyCodexTransientUpstreamError({
|
|
9734
9834
|
stdout: execution.stdout,
|
|
9735
9835
|
stderr: execution.stderr,
|
|
@@ -9805,10 +9905,15 @@ async function executeRunCommand(config, command) {
|
|
|
9805
9905
|
...Array.isArray(execution.killedWorkspaceResidents) && execution.killedWorkspaceResidents.length > 0 ? {
|
|
9806
9906
|
killedWorkspaceResidents: execution.killedWorkspaceResidents
|
|
9807
9907
|
} : {},
|
|
9808
|
-
...piInvalidOutputError && !cancelled && !hasOutputFlood && !hasMemoryLimit && execution.timedOut !== true && !execution.spawnError && !piProviderFailure ? {
|
|
9908
|
+
...piInvalidOutputError && !cancelled && !hasOutputFlood && !hasMemoryLimit && execution.timedOut !== true && !execution.spawnError && !piTurnLimitFailure && !piProviderFailure ? {
|
|
9809
9909
|
errorCode: "pi_executor_invalid_output",
|
|
9810
9910
|
errorFamily: "validation"
|
|
9811
9911
|
} : {},
|
|
9912
|
+
...piTurnLimitFailure ? {
|
|
9913
|
+
errorCode: piTurnLimitFailure.errorCode,
|
|
9914
|
+
errorFamily: piTurnLimitFailure.errorFamily,
|
|
9915
|
+
stopReason: piTurnLimitFailure.stopReason
|
|
9916
|
+
} : {},
|
|
9812
9917
|
...piProviderFailure ? piProviderFailure : {},
|
|
9813
9918
|
...codexTransientFailure ? codexTransientFailure : {},
|
|
9814
9919
|
...piUsageDiagnostic && !piInvalidOutputError ? {
|
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.46";
|
|
9
9
|
|
|
10
10
|
const CAPABILITIES = [
|
|
11
11
|
"remote_registration",
|