@amaster.ai/employee-runtime-connector 0.1.1-beta.122 → 0.1.1-beta.123
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 +158 -31
- package/dist/amaster-runtime.mjs +1 -1
- package/package.json +1 -1
|
@@ -5116,10 +5116,13 @@ var amasterRuntimeConnectorCompletionCheckResponseSchema = external_exports.unio
|
|
|
5116
5116
|
amasterRuntimeConnectorCompletionCheckV1ResponseSchema,
|
|
5117
5117
|
amasterRuntimeConnectorCompletionCheckV2ResponseSchema
|
|
5118
5118
|
]);
|
|
5119
|
+
var amasterRuntimeConnectorCommandResultSchema = external_exports.object({
|
|
5120
|
+
sessionId: external_exports.string().max(2048).optional()
|
|
5121
|
+
}).catchall(external_exports.unknown());
|
|
5119
5122
|
var amasterRuntimeConnectorCompleteCommandSchema = external_exports.object({
|
|
5120
5123
|
leaseId: external_exports.string().trim().min(1).optional(),
|
|
5121
5124
|
status: external_exports.enum(["succeeded", "failed", "cancelled"]),
|
|
5122
|
-
result:
|
|
5125
|
+
result: amasterRuntimeConnectorCommandResultSchema.optional(),
|
|
5123
5126
|
error: external_exports.string().trim().max(4e3).optional()
|
|
5124
5127
|
});
|
|
5125
5128
|
var amasterRuntimeConnectorLogIngestSchema = external_exports.object({
|
|
@@ -16791,12 +16794,16 @@ function findSessionRollout(sessionsRoot, sessionId) {
|
|
|
16791
16794
|
}
|
|
16792
16795
|
function restoreManagedCodexSessionRollout(input, codexHome, runDir, executorHome, authority) {
|
|
16793
16796
|
const session = record3(input.nativeSession);
|
|
16794
|
-
|
|
16797
|
+
const governedApprovalContinuation = session.mode === "governed_action_approval" && session.required === true;
|
|
16798
|
+
const governedTaskSessionContinuation = session.mode === "task_session" && session.required === false;
|
|
16799
|
+
if (!governedApprovalContinuation && !governedTaskSessionContinuation) return null;
|
|
16795
16800
|
const sessionId = nonEmpty(session.sessionId, "nativeSession.sessionId");
|
|
16796
16801
|
const sourceRunId = nonEmpty(session.sourceRunId, "nativeSession.sourceRunId");
|
|
16797
16802
|
const sourceCommandId = nonEmpty(session.sourceCommandId, "nativeSession.sourceCommandId");
|
|
16798
|
-
|
|
16799
|
-
|
|
16803
|
+
if (governedApprovalContinuation) {
|
|
16804
|
+
nonEmpty(session.actionRequestId, "nativeSession.actionRequestId");
|
|
16805
|
+
nonEmpty(session.invocationId, "nativeSession.invocationId");
|
|
16806
|
+
}
|
|
16800
16807
|
const sourceWorkspacePath = nonEmpty(session.cwd, "nativeSession.cwd");
|
|
16801
16808
|
const issueRoot = dirname(runDir);
|
|
16802
16809
|
const managedSourceRunDirName = `${sourceRunId}-${createHash("sha256").update(sourceRunId).digest("hex").slice(0, 8)}`;
|
|
@@ -16812,7 +16819,7 @@ function restoreManagedCodexSessionRollout(input, codexHome, runDir, executorHom
|
|
|
16812
16819
|
}
|
|
16813
16820
|
const marker = JSON.parse(readFileSync(markerPath, "utf8"));
|
|
16814
16821
|
if (marker?.version !== 1 || marker?.companyId !== authority.companyId || marker?.agentId !== authority.agentId || marker?.issueId !== authority.issueId || marker?.sourceRunId !== sourceRunId || marker?.sourceCommandId !== sourceCommandId || marker?.sessionId !== sessionId || marker?.sourceWorkspacePath !== sourceWorkspacePath) {
|
|
16815
|
-
throw new Error("codex_managed_mcp_session_rollout_authority_mismatch: source rollout does not match the
|
|
16822
|
+
throw new Error("codex_managed_mcp_session_rollout_authority_mismatch: source rollout does not match the governed continuation");
|
|
16816
16823
|
}
|
|
16817
16824
|
const sourceRollout = resolve2(cacheRoot, nonEmpty(marker.rolloutRelativePath, "rolloutRelativePath"));
|
|
16818
16825
|
if (!within(sourceRollout, cacheRoot) || lstatSync2(sourceRollout).isSymbolicLink() || !lstatSync2(sourceRollout).isFile()) {
|
|
@@ -16827,6 +16834,28 @@ function restoreManagedCodexSessionRollout(input, codexHome, runDir, executorHom
|
|
|
16827
16834
|
writePrivateFile(targetRollout, readFileSync(sourceRollout));
|
|
16828
16835
|
return { sessionId, sourceRunId, sourceCommandId, rolloutPath: targetRollout, cacheRoot };
|
|
16829
16836
|
}
|
|
16837
|
+
function resolveManagedCodexSessionRollout(input, codexHome, runDir, executorHome, authority) {
|
|
16838
|
+
try {
|
|
16839
|
+
return {
|
|
16840
|
+
restoredNativeSession: restoreManagedCodexSessionRollout(
|
|
16841
|
+
input,
|
|
16842
|
+
codexHome,
|
|
16843
|
+
runDir,
|
|
16844
|
+
executorHome,
|
|
16845
|
+
authority
|
|
16846
|
+
),
|
|
16847
|
+
nativeSessionRestoreSkippedReason: null
|
|
16848
|
+
};
|
|
16849
|
+
} catch (error) {
|
|
16850
|
+
if (record3(input.nativeSession).mode === "task_session" && error instanceof Error && error.message.startsWith("codex_managed_mcp_session_rollout_missing:")) {
|
|
16851
|
+
return {
|
|
16852
|
+
restoredNativeSession: null,
|
|
16853
|
+
nativeSessionRestoreSkippedReason: "native_session_rollout_missing"
|
|
16854
|
+
};
|
|
16855
|
+
}
|
|
16856
|
+
throw error;
|
|
16857
|
+
}
|
|
16858
|
+
}
|
|
16830
16859
|
function isSensitiveAuthKey(key) {
|
|
16831
16860
|
const normalized = String(key).trim().toLowerCase().replaceAll("-", "_");
|
|
16832
16861
|
return /^(?:(?:access|refresh|id)_)?token$/.test(normalized) || normalized.includes("api_key") || normalized.includes("secret") || normalized.includes("password") || normalized.includes("credential") || normalized.includes("authorization") || normalized.includes("cookie");
|
|
@@ -17144,7 +17173,10 @@ function prepareManagedCodexMcpProfile(input) {
|
|
|
17144
17173
|
runId,
|
|
17145
17174
|
commandId: input.commandId
|
|
17146
17175
|
});
|
|
17147
|
-
const
|
|
17176
|
+
const {
|
|
17177
|
+
restoredNativeSession,
|
|
17178
|
+
nativeSessionRestoreSkippedReason
|
|
17179
|
+
} = resolveManagedCodexSessionRollout(input, codexHome, runDir, executorHome, authority);
|
|
17148
17180
|
const auth = seedCodexAuth(input, codexHome);
|
|
17149
17181
|
const configPath = join2(codexHome, "config.toml");
|
|
17150
17182
|
const allHeaders = { Authorization: `Bearer ${sessionToken}`, ...headers };
|
|
@@ -17199,6 +17231,7 @@ function prepareManagedCodexMcpProfile(input) {
|
|
|
17199
17231
|
owner,
|
|
17200
17232
|
authority,
|
|
17201
17233
|
restoredNativeSession,
|
|
17234
|
+
nativeSessionRestoreSkippedReason,
|
|
17202
17235
|
protectedValues: [.../* @__PURE__ */ new Set([sessionToken, ...auth.protectedValues])],
|
|
17203
17236
|
attestation: {
|
|
17204
17237
|
...attestationFacts,
|
|
@@ -19102,12 +19135,16 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
19102
19135
|
}
|
|
19103
19136
|
function restoreManagedPiSessionRollout(input, sessionsRoot, runDir, executorHome, authority) {
|
|
19104
19137
|
const session = record8(input.nativeSession);
|
|
19105
|
-
|
|
19138
|
+
const governedApprovalContinuation = session.mode === "governed_action_approval" && session.required === true;
|
|
19139
|
+
const governedTaskSessionContinuation = session.mode === "task_session" && session.required === false;
|
|
19140
|
+
if (!governedApprovalContinuation && !governedTaskSessionContinuation) return null;
|
|
19106
19141
|
const sessionId = nonEmpty2(session.sessionId, "nativeSession.sessionId");
|
|
19107
19142
|
const sourceRunId = nonEmpty2(session.sourceRunId, "nativeSession.sourceRunId");
|
|
19108
19143
|
const sourceCommandId = nonEmpty2(session.sourceCommandId, "nativeSession.sourceCommandId");
|
|
19109
|
-
|
|
19110
|
-
|
|
19144
|
+
if (governedApprovalContinuation) {
|
|
19145
|
+
nonEmpty2(session.actionRequestId, "nativeSession.actionRequestId");
|
|
19146
|
+
nonEmpty2(session.invocationId, "nativeSession.invocationId");
|
|
19147
|
+
}
|
|
19111
19148
|
const sourceWorkspacePath = nonEmpty2(session.cwd, "nativeSession.cwd");
|
|
19112
19149
|
const issueRoot = dirname4(runDir);
|
|
19113
19150
|
const managedSourceRunDirName = `${sourceRunId}-${createHash5("sha256").update(sourceRunId).digest("hex").slice(0, 8)}`;
|
|
@@ -19122,7 +19159,7 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
19122
19159
|
}
|
|
19123
19160
|
const marker = JSON.parse(readFileSync5(markerPath, "utf8"));
|
|
19124
19161
|
if (marker?.version !== 1 || marker?.companyId !== authority.companyId || marker?.agentId !== authority.agentId || marker?.issueId !== authority.issueId || marker?.sourceRunId !== sourceRunId || marker?.sourceCommandId !== sourceCommandId || marker?.sessionId !== sessionId || marker?.sourceWorkspacePath !== sourceWorkspacePath) {
|
|
19125
|
-
throw new Error("pi_managed_mcp_session_rollout_authority_mismatch: source rollout does not match the
|
|
19162
|
+
throw new Error("pi_managed_mcp_session_rollout_authority_mismatch: source rollout does not match the governed continuation");
|
|
19126
19163
|
}
|
|
19127
19164
|
const sourceRollout = resolve3(cacheRoot, nonEmpty2(marker.rolloutRelativePath, "rolloutRelativePath"));
|
|
19128
19165
|
if (!within2(sourceRollout, cacheRoot) || lstatSync3(sourceRollout).isSymbolicLink() || !lstatSync3(sourceRollout).isFile()) {
|
|
@@ -19136,6 +19173,28 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
19136
19173
|
writePrivateFile2(targetRollout, readFileSync5(sourceRollout));
|
|
19137
19174
|
return { sessionId, sourceRunId, sourceCommandId, rolloutPath: targetRollout, cacheRoot };
|
|
19138
19175
|
}
|
|
19176
|
+
function resolveManagedPiSessionRollout(input, sessionsRoot, runDir, executorHome, authority) {
|
|
19177
|
+
try {
|
|
19178
|
+
return {
|
|
19179
|
+
restoredNativeSession: restoreManagedPiSessionRollout(
|
|
19180
|
+
input,
|
|
19181
|
+
sessionsRoot,
|
|
19182
|
+
runDir,
|
|
19183
|
+
executorHome,
|
|
19184
|
+
authority
|
|
19185
|
+
),
|
|
19186
|
+
nativeSessionRestoreSkippedReason: null
|
|
19187
|
+
};
|
|
19188
|
+
} catch (error) {
|
|
19189
|
+
if (record8(input.nativeSession).mode === "task_session" && error instanceof Error && error.message.startsWith("pi_managed_mcp_session_rollout_missing:")) {
|
|
19190
|
+
return {
|
|
19191
|
+
restoredNativeSession: null,
|
|
19192
|
+
nativeSessionRestoreSkippedReason: "native_session_rollout_missing"
|
|
19193
|
+
};
|
|
19194
|
+
}
|
|
19195
|
+
throw error;
|
|
19196
|
+
}
|
|
19197
|
+
}
|
|
19139
19198
|
function parseVersion(stdout, label, minimum) {
|
|
19140
19199
|
const pattern = label === "Pi" ? /^\s*(?:pi(?: coding agent)?\s+)?(\d+)\.(\d+)\.(\d+)(?:\s|$)/im : /^\s*(\d+)\.(\d+)\.(\d+)(?:\s|$)/;
|
|
19141
19200
|
const match = String(stdout).match(pattern);
|
|
@@ -20009,6 +20068,11 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
20009
20068
|
"--no-approve",
|
|
20010
20069
|
"--no-skills",
|
|
20011
20070
|
"--no-context-files",
|
|
20071
|
+
"--no-builtin-tools",
|
|
20072
|
+
// The probe attests only the governed adapter and run-owned attestor.
|
|
20073
|
+
// Ambient Pi extensions may fail independently and must not change this
|
|
20074
|
+
// measured tool surface; explicitly supplied extensions still load.
|
|
20075
|
+
"--no-extensions",
|
|
20012
20076
|
// The enforcement extensions live in the run profile, not an agent dir,
|
|
20013
20077
|
// so the probe must load them explicitly to measure the real run surface.
|
|
20014
20078
|
...Array.isArray(input.extensionArgs) ? input.extensionArgs : [],
|
|
@@ -20166,7 +20230,10 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
20166
20230
|
commandId: input.commandId
|
|
20167
20231
|
});
|
|
20168
20232
|
const sharedRuntime = sharedPiHomeSettingsEnv(input.baseEnv);
|
|
20169
|
-
const
|
|
20233
|
+
const {
|
|
20234
|
+
restoredNativeSession,
|
|
20235
|
+
nativeSessionRestoreSkippedReason
|
|
20236
|
+
} = resolveManagedPiSessionRollout(input, sessionsRoot, runDir, executorHome, authority);
|
|
20170
20237
|
const directToolNames = directCatalog?.tools.map((tool) => tool.exposedName) ?? [];
|
|
20171
20238
|
const serverConfig = {
|
|
20172
20239
|
type: "http",
|
|
@@ -20471,6 +20538,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
20471
20538
|
owner,
|
|
20472
20539
|
authority,
|
|
20473
20540
|
restoredNativeSession,
|
|
20541
|
+
nativeSessionRestoreSkippedReason,
|
|
20474
20542
|
configPath,
|
|
20475
20543
|
markerPath,
|
|
20476
20544
|
env,
|
|
@@ -20836,6 +20904,27 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
20836
20904
|
`);
|
|
20837
20905
|
return { status: "preserved", sessionId, rolloutPath: targetRollout, cacheRoot };
|
|
20838
20906
|
}
|
|
20907
|
+
function cleanupRestoredManagedPiSessionRollout2(profile) {
|
|
20908
|
+
const restored = profile?.restoredNativeSession;
|
|
20909
|
+
if (!restored?.cacheRoot) return { status: "not_restored" };
|
|
20910
|
+
const cacheRoot = resolve3(restored.cacheRoot);
|
|
20911
|
+
if (!existsSync4(cacheRoot)) return { status: "already_removed" };
|
|
20912
|
+
const cacheStat = lstatSync3(cacheRoot);
|
|
20913
|
+
if (!cacheStat.isDirectory() || cacheStat.isSymbolicLink()) {
|
|
20914
|
+
throw new Error("pi_managed_mcp_session_rollout_cleanup_unsafe: cache root is not a private directory");
|
|
20915
|
+
}
|
|
20916
|
+
const markerPath = join5(cacheRoot, SESSION_ROLLOUT_MARKER2);
|
|
20917
|
+
if (!existsSync4(markerPath) || lstatSync3(markerPath).isSymbolicLink() || !lstatSync3(markerPath).isFile()) {
|
|
20918
|
+
throw new Error("pi_managed_mcp_session_rollout_cleanup_unsafe: ownership marker is unavailable");
|
|
20919
|
+
}
|
|
20920
|
+
const marker = JSON.parse(readFileSync5(markerPath, "utf8"));
|
|
20921
|
+
if (marker?.companyId !== profile.authority.companyId || marker?.agentId !== profile.authority.agentId || marker?.issueId !== profile.authority.issueId || marker?.sourceRunId !== restored.sourceRunId || marker?.sourceCommandId !== restored.sourceCommandId || marker?.sessionId !== restored.sessionId) {
|
|
20922
|
+
throw new Error("pi_managed_mcp_session_rollout_cleanup_unsafe: ownership marker does not match restored authority");
|
|
20923
|
+
}
|
|
20924
|
+
rmSync3(cacheRoot, { recursive: true, force: false });
|
|
20925
|
+
if (existsSync4(cacheRoot)) throw new Error("pi_managed_mcp_session_rollout_cleanup_failed: cache root still exists");
|
|
20926
|
+
return { status: "removed" };
|
|
20927
|
+
}
|
|
20839
20928
|
function removeWorkspaceMcpConfig(configPath, profileRoot) {
|
|
20840
20929
|
const target = resolve3(configPath);
|
|
20841
20930
|
if (!workspaceMcpConfigBelongsToProfile(target, profileRoot)) {
|
|
@@ -20987,7 +21076,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
20987
21076
|
failures
|
|
20988
21077
|
};
|
|
20989
21078
|
}
|
|
20990
|
-
return { prepareManagedPiMcpProfile: prepareManagedPiMcpProfile2, prepareDelegatedPiMcpProfile: prepareDelegatedPiMcpProfile2, inspectManagedPiRunExitClosureAttestation: inspectManagedPiRunExitClosureAttestation2, restoreManagedPiRunExitClosureBaseline: restoreManagedPiRunExitClosureBaseline2, preserveManagedPiSessionRollout: preserveManagedPiSessionRollout2, cleanupManagedPiMcpProfile: cleanupManagedPiMcpProfile2, cleanupDelegatedPiMcpProfile: cleanupDelegatedPiMcpProfile2, reconcileManagedPiMcpProfiles: reconcileManagedPiMcpProfiles2 };
|
|
21079
|
+
return { prepareManagedPiMcpProfile: prepareManagedPiMcpProfile2, prepareDelegatedPiMcpProfile: prepareDelegatedPiMcpProfile2, inspectManagedPiRunExitClosureAttestation: inspectManagedPiRunExitClosureAttestation2, restoreManagedPiRunExitClosureBaseline: restoreManagedPiRunExitClosureBaseline2, preserveManagedPiSessionRollout: preserveManagedPiSessionRollout2, cleanupRestoredManagedPiSessionRollout: cleanupRestoredManagedPiSessionRollout2, cleanupManagedPiMcpProfile: cleanupManagedPiMcpProfile2, cleanupDelegatedPiMcpProfile: cleanupDelegatedPiMcpProfile2, reconcileManagedPiMcpProfiles: reconcileManagedPiMcpProfiles2 };
|
|
20991
21080
|
}
|
|
20992
21081
|
var piManagedMcpProfileApi = createManagedPiMcpProfileApi();
|
|
20993
21082
|
var prepareManagedPiMcpProfile = piManagedMcpProfileApi.prepareManagedPiMcpProfile;
|
|
@@ -20995,6 +21084,7 @@ var prepareDelegatedPiMcpProfile = piManagedMcpProfileApi.prepareDelegatedPiMcpP
|
|
|
20995
21084
|
var inspectManagedPiRunExitClosureAttestation = piManagedMcpProfileApi.inspectManagedPiRunExitClosureAttestation;
|
|
20996
21085
|
var restoreManagedPiRunExitClosureBaseline = piManagedMcpProfileApi.restoreManagedPiRunExitClosureBaseline;
|
|
20997
21086
|
var preserveManagedPiSessionRollout = piManagedMcpProfileApi.preserveManagedPiSessionRollout;
|
|
21087
|
+
var cleanupRestoredManagedPiSessionRollout = piManagedMcpProfileApi.cleanupRestoredManagedPiSessionRollout;
|
|
20998
21088
|
var cleanupManagedPiMcpProfile = piManagedMcpProfileApi.cleanupManagedPiMcpProfile;
|
|
20999
21089
|
var cleanupDelegatedPiMcpProfile = piManagedMcpProfileApi.cleanupDelegatedPiMcpProfile;
|
|
21000
21090
|
var reconcileManagedPiMcpProfiles = piManagedMcpProfileApi.reconcileManagedPiMcpProfiles;
|
|
@@ -28407,7 +28497,7 @@ function createSourceCompletionStopPolicy({
|
|
|
28407
28497
|
}
|
|
28408
28498
|
|
|
28409
28499
|
// src/amaster-runtime-daemon.mjs
|
|
28410
|
-
var CONNECTOR_VERSION = "0.1.1-beta.
|
|
28500
|
+
var CONNECTOR_VERSION = "0.1.1-beta.123";
|
|
28411
28501
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
28412
28502
|
var SOURCE_ACQUISITION_CAPABILITY2 = source_acquisition_compatibility_default.profileVersion;
|
|
28413
28503
|
var daemonRequire = createRequire(import.meta.url);
|
|
@@ -30260,7 +30350,7 @@ function sanitizePiExtraArgs(value) {
|
|
|
30260
30350
|
return splitExtraArgs(value).filter((entry) => !AMASTER_PI_PROHIBITED_EXTRA_ARGS.has(entry));
|
|
30261
30351
|
}
|
|
30262
30352
|
function nativeSessionResumeEnabled(session) {
|
|
30263
|
-
return process.env.AMASTER_RUNTIME_ENABLE_NATIVE_SESSION_RESUME === "true" || readString(session.mode) === "governed_action_approval" && session.required === true;
|
|
30353
|
+
return process.env.AMASTER_RUNTIME_ENABLE_NATIVE_SESSION_RESUME === "true" || readString(session.mode) === "task_session" || readString(session.mode) === "governed_action_approval" && session.required === true;
|
|
30264
30354
|
}
|
|
30265
30355
|
function modelCallResponseContract(payload) {
|
|
30266
30356
|
if (payload.responseContract === void 0) return null;
|
|
@@ -30377,8 +30467,8 @@ function buildExecutorInvocation(executor, command = {}, workspace = null, optio
|
|
|
30377
30467
|
const args = ["--mode", "json"];
|
|
30378
30468
|
const governedRun = Object.keys(asRecord(commandRuntimeAuth(command).governedMcp)).length > 0;
|
|
30379
30469
|
const nativeSessionRequest = asRecord(asRecord(command.payload).nativeSession);
|
|
30380
|
-
if (governedRun && nativeSession.used && (nativeSessionRequest.mode
|
|
30381
|
-
throw new Error("pi_managed_mcp_native_session_resume_blocked: governed Pi runs require exact
|
|
30470
|
+
if (governedRun && nativeSession.used && !(nativeSessionRequest.mode === "governed_action_approval" && nativeSessionRequest.required === true || nativeSessionRequest.mode === "task_session" && nativeSessionRequest.required === false)) {
|
|
30471
|
+
throw new Error("pi_managed_mcp_native_session_resume_blocked: governed Pi runs require exact continuation authority");
|
|
30382
30472
|
}
|
|
30383
30473
|
const provider = readString(process.env.AMASTER_PI_PROVIDER);
|
|
30384
30474
|
const model = readString(process.env.AMASTER_PI_MODEL);
|
|
@@ -33556,6 +33646,23 @@ async function executeRunCommand(config, command) {
|
|
|
33556
33646
|
}
|
|
33557
33647
|
}
|
|
33558
33648
|
if (managedMcpProfile) {
|
|
33649
|
+
if (nativeSessionRequest.mode === "task_session" && asRecord(invocation.nativeSession).used === true && !managedMcpProfile.restoredNativeSession) {
|
|
33650
|
+
const freshPayload = { ...asRecord(command.payload) };
|
|
33651
|
+
delete freshPayload.nativeSession;
|
|
33652
|
+
const freshInvocation = buildExecutorInvocation(
|
|
33653
|
+
executor,
|
|
33654
|
+
{ ...command, payload: freshPayload },
|
|
33655
|
+
workspace
|
|
33656
|
+
);
|
|
33657
|
+
invocation.args = freshInvocation.args;
|
|
33658
|
+
invocation.stdin = freshInvocation.stdin;
|
|
33659
|
+
invocation.nativeSession = {
|
|
33660
|
+
...asRecord(invocation.nativeSession),
|
|
33661
|
+
mode: "fresh",
|
|
33662
|
+
used: false,
|
|
33663
|
+
skippedReason: readString(managedMcpProfile.nativeSessionRestoreSkippedReason) ?? "native_session_rollout_missing"
|
|
33664
|
+
};
|
|
33665
|
+
}
|
|
33559
33666
|
executorEnv = managedMcpProfile.env;
|
|
33560
33667
|
if (executor.kind === "pi" && managedMcpProfile.spawnIdentity) {
|
|
33561
33668
|
piExecutorIdentity = managedMcpProfile.spawnIdentity;
|
|
@@ -33963,7 +34070,11 @@ async function executeRunCommand(config, command) {
|
|
|
33963
34070
|
parsed.hasAssistantOutput = true;
|
|
33964
34071
|
}
|
|
33965
34072
|
}
|
|
33966
|
-
const
|
|
34073
|
+
const approvalRequiredSession = mcpToolResults.some(
|
|
34074
|
+
(result4) => readString(result4.status) === "approval_required"
|
|
34075
|
+
);
|
|
34076
|
+
const piTerminalSessionCandidate = executor.kind === "pi" && parsed.hasAssistantOutput === true && ["agent_end", "turn_end"].includes(readString(parsed.terminalEventType) ?? "");
|
|
34077
|
+
const shouldPreserveNativeSession = managedMcpProfile && parsed.sessionId && (execution.exitCode === 0 || execution.completionOutputType === "approval_required" || piTerminalSessionCandidate) && !execution.timedOut && execution.cancelled !== true && !execution.spawnError && ["codex", "pi"].includes(executor.kind) && (execution.exitCode === 0 || approvalRequiredSession || piTerminalSessionCandidate);
|
|
33967
34078
|
if (shouldPreserveNativeSession) {
|
|
33968
34079
|
try {
|
|
33969
34080
|
const preserveSessionRollout = executor.kind === "pi" ? preserveManagedPiSessionRollout : preserveManagedCodexSessionRollout;
|
|
@@ -33971,7 +34082,7 @@ async function executeRunCommand(config, command) {
|
|
|
33971
34082
|
sessionId: parsed.sessionId,
|
|
33972
34083
|
sourceWorkspacePath: workspace.sourceWorkspacePath
|
|
33973
34084
|
});
|
|
33974
|
-
const checkpoint = await saveIssueCheckpoint(
|
|
34085
|
+
const checkpoint = approvalRequiredSession ? await saveIssueCheckpoint(
|
|
33975
34086
|
config,
|
|
33976
34087
|
command,
|
|
33977
34088
|
workspace,
|
|
@@ -33979,23 +34090,30 @@ async function executeRunCommand(config, command) {
|
|
|
33979
34090
|
rawPath: artifact.relativePath,
|
|
33980
34091
|
filePath: resolve13(cwd, artifact.relativePath)
|
|
33981
34092
|
}))
|
|
33982
|
-
);
|
|
34093
|
+
) : null;
|
|
33983
34094
|
nativeSessionRollout = {
|
|
33984
34095
|
status: preservedRollout.status,
|
|
33985
34096
|
sessionId: preservedRollout.sessionId,
|
|
33986
34097
|
...checkpoint ? { checkpoint: { fileCount: checkpoint.files.length, totalBytes: checkpoint.totalBytes } } : {}
|
|
33987
34098
|
};
|
|
33988
|
-
await ingestLog(config, command, "system", "info", `Preserved ${executor.kind} session rollout for
|
|
34099
|
+
await ingestLog(config, command, "system", "info", `Preserved ${executor.kind} session rollout for a governed continuation`, {
|
|
33989
34100
|
presentationKind: "managed_mcp_session_rollout",
|
|
33990
34101
|
status: nativeSessionRollout.status,
|
|
33991
34102
|
sessionId: parsed.sessionId
|
|
33992
34103
|
});
|
|
33993
34104
|
} catch (err) {
|
|
33994
|
-
|
|
33995
|
-
|
|
34105
|
+
const rolloutError = `${executor.kind}_managed_mcp_session_rollout_failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
34106
|
+
if (approvalRequiredSession) {
|
|
34107
|
+
nativeSessionRolloutError = rolloutError;
|
|
34108
|
+
} else {
|
|
34109
|
+
nativeSessionRollout = {
|
|
34110
|
+
status: "unavailable",
|
|
34111
|
+
skippedReason: "native_session_rollout_unavailable"
|
|
34112
|
+
};
|
|
34113
|
+
}
|
|
34114
|
+
await ingestLog(config, command, "system", approvalRequiredSession ? "error" : "warn", approvalRequiredSession ? rolloutError : `Could not preserve the optional ${executor.kind} task-session rollout`, {
|
|
33996
34115
|
presentationKind: "managed_mcp_session_rollout",
|
|
33997
|
-
status: "failed"
|
|
33998
|
-
sessionId: parsed.sessionId
|
|
34116
|
+
status: approvalRequiredSession ? "failed" : "unavailable"
|
|
33999
34117
|
});
|
|
34000
34118
|
}
|
|
34001
34119
|
}
|
|
@@ -34003,20 +34121,29 @@ async function executeRunCommand(config, command) {
|
|
|
34003
34121
|
if (approvedContinuationSucceeded) {
|
|
34004
34122
|
await clearIssueCheckpoint(config, command, workspace, "approved_action_succeeded");
|
|
34005
34123
|
}
|
|
34006
|
-
|
|
34124
|
+
const taskSessionContinuationSucceeded = nativeSessionRequest.mode === "task_session" && asRecord(invocation.nativeSession).used === true && shouldPreserveNativeSession && nativeSessionRollout?.status === "preserved";
|
|
34125
|
+
if (managedMcpProfile && (approvedContinuationSucceeded || taskSessionContinuationSucceeded)) {
|
|
34007
34126
|
try {
|
|
34008
|
-
|
|
34009
|
-
|
|
34127
|
+
const cleanupRestoredSessionRollout = executor.kind === "pi" ? cleanupRestoredManagedPiSessionRollout : cleanupRestoredManagedCodexSessionRollout;
|
|
34128
|
+
nativeSessionRolloutCleanup = cleanupRestoredSessionRollout(managedMcpProfile);
|
|
34129
|
+
await ingestLog(config, command, "system", "info", `Removed the consumed ${executor.kind} session rollout`, {
|
|
34010
34130
|
presentationKind: "managed_mcp_session_rollout_cleanup",
|
|
34011
34131
|
status: nativeSessionRolloutCleanup.status,
|
|
34012
34132
|
sessionId: readString(nativeSessionRequest.sessionId)
|
|
34013
34133
|
});
|
|
34014
34134
|
} catch (err) {
|
|
34015
|
-
|
|
34016
|
-
|
|
34135
|
+
const cleanupError = `${executor.kind}_managed_mcp_session_rollout_cleanup_failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
34136
|
+
if (approvedContinuationSucceeded) {
|
|
34137
|
+
nativeSessionRolloutCleanupError = cleanupError;
|
|
34138
|
+
} else {
|
|
34139
|
+
nativeSessionRolloutCleanup = {
|
|
34140
|
+
status: "failed",
|
|
34141
|
+
skippedReason: "native_session_rollout_cleanup_failed"
|
|
34142
|
+
};
|
|
34143
|
+
}
|
|
34144
|
+
await ingestLog(config, command, "system", approvedContinuationSucceeded ? "error" : "warn", approvedContinuationSucceeded ? cleanupError : `Could not clean the consumed optional ${executor.kind} task-session rollout`, {
|
|
34017
34145
|
presentationKind: "managed_mcp_session_rollout_cleanup",
|
|
34018
|
-
status: "failed"
|
|
34019
|
-
sessionId: readString(nativeSessionRequest.sessionId)
|
|
34146
|
+
status: "failed"
|
|
34020
34147
|
});
|
|
34021
34148
|
}
|
|
34022
34149
|
}
|
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.123";
|
|
10
10
|
|
|
11
11
|
const CAPABILITIES = [
|
|
12
12
|
"remote_registration",
|