@amaster.ai/employee-runtime-connector 0.1.1-beta.121 → 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 +166 -33
- 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({
|
|
@@ -9056,6 +9059,8 @@ var issueExecutionStageSchema = external_exports.object({
|
|
|
9056
9059
|
participants: external_exports.array(issueExecutionStageParticipantSchema).default([])
|
|
9057
9060
|
});
|
|
9058
9061
|
var issueExecutionMonitorPolicySchema = external_exports.object({
|
|
9062
|
+
effectId: external_exports.string().uuid().optional().nullable().default(null),
|
|
9063
|
+
executionEpoch: external_exports.number().int().positive().optional().nullable().default(null),
|
|
9059
9064
|
nextCheckAt: external_exports.string().datetime(),
|
|
9060
9065
|
notes: external_exports.string().max(500).optional().nullable().default(null),
|
|
9061
9066
|
scheduledBy: external_exports.enum(ISSUE_MONITOR_SCHEDULED_BY).optional().default("assignee"),
|
|
@@ -9322,7 +9327,8 @@ var externalWaitSnoozeSchema = external_exports.object({
|
|
|
9322
9327
|
var upsertIssueExternalWaitSchema = external_exports.object({
|
|
9323
9328
|
ownerType: external_exports.enum(["external", "user"]),
|
|
9324
9329
|
actionKind: external_exports.enum(["approval", "input", "dependency", "other"]),
|
|
9325
|
-
reasonCode: external_exports.string().trim().min(1).max(120)
|
|
9330
|
+
reasonCode: external_exports.string().trim().min(1).max(120),
|
|
9331
|
+
reviewAt: external_exports.string().datetime().nullable().optional()
|
|
9326
9332
|
}).strict();
|
|
9327
9333
|
var resolveIssueExternalWaitSchema = external_exports.object({
|
|
9328
9334
|
outcome: external_exports.enum(["completed", "cannot_complete", "external_input_change"]),
|
|
@@ -9705,7 +9711,8 @@ var chooseTaskDispositionOptionSchema = external_exports.object({
|
|
|
9705
9711
|
ownerType: external_exports.enum(["external", "user"]),
|
|
9706
9712
|
actionKind: external_exports.enum(["approval", "input", "dependency", "other"]),
|
|
9707
9713
|
reasonCode: external_exports.string().trim().min(1).max(120).regex(/^[a-z][a-z0-9_]*$/),
|
|
9708
|
-
resolutionCondition: external_exports.string().trim().min(1).max(1e3)
|
|
9714
|
+
resolutionCondition: external_exports.string().trim().min(1).max(1e3),
|
|
9715
|
+
reviewAt: external_exports.string().datetime({ offset: true }).optional()
|
|
9709
9716
|
}).strict().optional(),
|
|
9710
9717
|
monitor: external_exports.object({
|
|
9711
9718
|
checkAfterMinutes: external_exports.number().int().min(5).max(90 * 24 * 60),
|
|
@@ -9751,6 +9758,8 @@ var chooseTaskDispositionResultSchema = external_exports.object({
|
|
|
9751
9758
|
issueId: external_exports.string().uuid(),
|
|
9752
9759
|
effectId: external_exports.string().uuid(),
|
|
9753
9760
|
materializedAt: external_exports.string().datetime({ offset: true }),
|
|
9761
|
+
executionEpoch: external_exports.number().int().positive(),
|
|
9762
|
+
reviewAt: external_exports.string().datetime({ offset: true }).nullable().optional(),
|
|
9754
9763
|
nextCheckAt: external_exports.string().datetime({ offset: true }).nullable().optional()
|
|
9755
9764
|
}).strict()
|
|
9756
9765
|
}).strict();
|
|
@@ -16785,12 +16794,16 @@ function findSessionRollout(sessionsRoot, sessionId) {
|
|
|
16785
16794
|
}
|
|
16786
16795
|
function restoreManagedCodexSessionRollout(input, codexHome, runDir, executorHome, authority) {
|
|
16787
16796
|
const session = record3(input.nativeSession);
|
|
16788
|
-
|
|
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;
|
|
16789
16800
|
const sessionId = nonEmpty(session.sessionId, "nativeSession.sessionId");
|
|
16790
16801
|
const sourceRunId = nonEmpty(session.sourceRunId, "nativeSession.sourceRunId");
|
|
16791
16802
|
const sourceCommandId = nonEmpty(session.sourceCommandId, "nativeSession.sourceCommandId");
|
|
16792
|
-
|
|
16793
|
-
|
|
16803
|
+
if (governedApprovalContinuation) {
|
|
16804
|
+
nonEmpty(session.actionRequestId, "nativeSession.actionRequestId");
|
|
16805
|
+
nonEmpty(session.invocationId, "nativeSession.invocationId");
|
|
16806
|
+
}
|
|
16794
16807
|
const sourceWorkspacePath = nonEmpty(session.cwd, "nativeSession.cwd");
|
|
16795
16808
|
const issueRoot = dirname(runDir);
|
|
16796
16809
|
const managedSourceRunDirName = `${sourceRunId}-${createHash("sha256").update(sourceRunId).digest("hex").slice(0, 8)}`;
|
|
@@ -16806,7 +16819,7 @@ function restoreManagedCodexSessionRollout(input, codexHome, runDir, executorHom
|
|
|
16806
16819
|
}
|
|
16807
16820
|
const marker = JSON.parse(readFileSync(markerPath, "utf8"));
|
|
16808
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) {
|
|
16809
|
-
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");
|
|
16810
16823
|
}
|
|
16811
16824
|
const sourceRollout = resolve2(cacheRoot, nonEmpty(marker.rolloutRelativePath, "rolloutRelativePath"));
|
|
16812
16825
|
if (!within(sourceRollout, cacheRoot) || lstatSync2(sourceRollout).isSymbolicLink() || !lstatSync2(sourceRollout).isFile()) {
|
|
@@ -16821,6 +16834,28 @@ function restoreManagedCodexSessionRollout(input, codexHome, runDir, executorHom
|
|
|
16821
16834
|
writePrivateFile(targetRollout, readFileSync(sourceRollout));
|
|
16822
16835
|
return { sessionId, sourceRunId, sourceCommandId, rolloutPath: targetRollout, cacheRoot };
|
|
16823
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
|
+
}
|
|
16824
16859
|
function isSensitiveAuthKey(key) {
|
|
16825
16860
|
const normalized = String(key).trim().toLowerCase().replaceAll("-", "_");
|
|
16826
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");
|
|
@@ -17138,7 +17173,10 @@ function prepareManagedCodexMcpProfile(input) {
|
|
|
17138
17173
|
runId,
|
|
17139
17174
|
commandId: input.commandId
|
|
17140
17175
|
});
|
|
17141
|
-
const
|
|
17176
|
+
const {
|
|
17177
|
+
restoredNativeSession,
|
|
17178
|
+
nativeSessionRestoreSkippedReason
|
|
17179
|
+
} = resolveManagedCodexSessionRollout(input, codexHome, runDir, executorHome, authority);
|
|
17142
17180
|
const auth = seedCodexAuth(input, codexHome);
|
|
17143
17181
|
const configPath = join2(codexHome, "config.toml");
|
|
17144
17182
|
const allHeaders = { Authorization: `Bearer ${sessionToken}`, ...headers };
|
|
@@ -17193,6 +17231,7 @@ function prepareManagedCodexMcpProfile(input) {
|
|
|
17193
17231
|
owner,
|
|
17194
17232
|
authority,
|
|
17195
17233
|
restoredNativeSession,
|
|
17234
|
+
nativeSessionRestoreSkippedReason,
|
|
17196
17235
|
protectedValues: [.../* @__PURE__ */ new Set([sessionToken, ...auth.protectedValues])],
|
|
17197
17236
|
attestation: {
|
|
17198
17237
|
...attestationFacts,
|
|
@@ -19096,12 +19135,16 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
19096
19135
|
}
|
|
19097
19136
|
function restoreManagedPiSessionRollout(input, sessionsRoot, runDir, executorHome, authority) {
|
|
19098
19137
|
const session = record8(input.nativeSession);
|
|
19099
|
-
|
|
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;
|
|
19100
19141
|
const sessionId = nonEmpty2(session.sessionId, "nativeSession.sessionId");
|
|
19101
19142
|
const sourceRunId = nonEmpty2(session.sourceRunId, "nativeSession.sourceRunId");
|
|
19102
19143
|
const sourceCommandId = nonEmpty2(session.sourceCommandId, "nativeSession.sourceCommandId");
|
|
19103
|
-
|
|
19104
|
-
|
|
19144
|
+
if (governedApprovalContinuation) {
|
|
19145
|
+
nonEmpty2(session.actionRequestId, "nativeSession.actionRequestId");
|
|
19146
|
+
nonEmpty2(session.invocationId, "nativeSession.invocationId");
|
|
19147
|
+
}
|
|
19105
19148
|
const sourceWorkspacePath = nonEmpty2(session.cwd, "nativeSession.cwd");
|
|
19106
19149
|
const issueRoot = dirname4(runDir);
|
|
19107
19150
|
const managedSourceRunDirName = `${sourceRunId}-${createHash5("sha256").update(sourceRunId).digest("hex").slice(0, 8)}`;
|
|
@@ -19116,7 +19159,7 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
19116
19159
|
}
|
|
19117
19160
|
const marker = JSON.parse(readFileSync5(markerPath, "utf8"));
|
|
19118
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) {
|
|
19119
|
-
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");
|
|
19120
19163
|
}
|
|
19121
19164
|
const sourceRollout = resolve3(cacheRoot, nonEmpty2(marker.rolloutRelativePath, "rolloutRelativePath"));
|
|
19122
19165
|
if (!within2(sourceRollout, cacheRoot) || lstatSync3(sourceRollout).isSymbolicLink() || !lstatSync3(sourceRollout).isFile()) {
|
|
@@ -19130,6 +19173,28 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
19130
19173
|
writePrivateFile2(targetRollout, readFileSync5(sourceRollout));
|
|
19131
19174
|
return { sessionId, sourceRunId, sourceCommandId, rolloutPath: targetRollout, cacheRoot };
|
|
19132
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
|
+
}
|
|
19133
19198
|
function parseVersion(stdout, label, minimum) {
|
|
19134
19199
|
const pattern = label === "Pi" ? /^\s*(?:pi(?: coding agent)?\s+)?(\d+)\.(\d+)\.(\d+)(?:\s|$)/im : /^\s*(\d+)\.(\d+)\.(\d+)(?:\s|$)/;
|
|
19135
19200
|
const match = String(stdout).match(pattern);
|
|
@@ -20003,6 +20068,11 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
20003
20068
|
"--no-approve",
|
|
20004
20069
|
"--no-skills",
|
|
20005
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",
|
|
20006
20076
|
// The enforcement extensions live in the run profile, not an agent dir,
|
|
20007
20077
|
// so the probe must load them explicitly to measure the real run surface.
|
|
20008
20078
|
...Array.isArray(input.extensionArgs) ? input.extensionArgs : [],
|
|
@@ -20160,7 +20230,10 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
20160
20230
|
commandId: input.commandId
|
|
20161
20231
|
});
|
|
20162
20232
|
const sharedRuntime = sharedPiHomeSettingsEnv(input.baseEnv);
|
|
20163
|
-
const
|
|
20233
|
+
const {
|
|
20234
|
+
restoredNativeSession,
|
|
20235
|
+
nativeSessionRestoreSkippedReason
|
|
20236
|
+
} = resolveManagedPiSessionRollout(input, sessionsRoot, runDir, executorHome, authority);
|
|
20164
20237
|
const directToolNames = directCatalog?.tools.map((tool) => tool.exposedName) ?? [];
|
|
20165
20238
|
const serverConfig = {
|
|
20166
20239
|
type: "http",
|
|
@@ -20465,6 +20538,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
20465
20538
|
owner,
|
|
20466
20539
|
authority,
|
|
20467
20540
|
restoredNativeSession,
|
|
20541
|
+
nativeSessionRestoreSkippedReason,
|
|
20468
20542
|
configPath,
|
|
20469
20543
|
markerPath,
|
|
20470
20544
|
env,
|
|
@@ -20830,6 +20904,27 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
20830
20904
|
`);
|
|
20831
20905
|
return { status: "preserved", sessionId, rolloutPath: targetRollout, cacheRoot };
|
|
20832
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
|
+
}
|
|
20833
20928
|
function removeWorkspaceMcpConfig(configPath, profileRoot) {
|
|
20834
20929
|
const target = resolve3(configPath);
|
|
20835
20930
|
if (!workspaceMcpConfigBelongsToProfile(target, profileRoot)) {
|
|
@@ -20981,7 +21076,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
20981
21076
|
failures
|
|
20982
21077
|
};
|
|
20983
21078
|
}
|
|
20984
|
-
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 };
|
|
20985
21080
|
}
|
|
20986
21081
|
var piManagedMcpProfileApi = createManagedPiMcpProfileApi();
|
|
20987
21082
|
var prepareManagedPiMcpProfile = piManagedMcpProfileApi.prepareManagedPiMcpProfile;
|
|
@@ -20989,6 +21084,7 @@ var prepareDelegatedPiMcpProfile = piManagedMcpProfileApi.prepareDelegatedPiMcpP
|
|
|
20989
21084
|
var inspectManagedPiRunExitClosureAttestation = piManagedMcpProfileApi.inspectManagedPiRunExitClosureAttestation;
|
|
20990
21085
|
var restoreManagedPiRunExitClosureBaseline = piManagedMcpProfileApi.restoreManagedPiRunExitClosureBaseline;
|
|
20991
21086
|
var preserveManagedPiSessionRollout = piManagedMcpProfileApi.preserveManagedPiSessionRollout;
|
|
21087
|
+
var cleanupRestoredManagedPiSessionRollout = piManagedMcpProfileApi.cleanupRestoredManagedPiSessionRollout;
|
|
20992
21088
|
var cleanupManagedPiMcpProfile = piManagedMcpProfileApi.cleanupManagedPiMcpProfile;
|
|
20993
21089
|
var cleanupDelegatedPiMcpProfile = piManagedMcpProfileApi.cleanupDelegatedPiMcpProfile;
|
|
20994
21090
|
var reconcileManagedPiMcpProfiles = piManagedMcpProfileApi.reconcileManagedPiMcpProfiles;
|
|
@@ -28401,7 +28497,7 @@ function createSourceCompletionStopPolicy({
|
|
|
28401
28497
|
}
|
|
28402
28498
|
|
|
28403
28499
|
// src/amaster-runtime-daemon.mjs
|
|
28404
|
-
var CONNECTOR_VERSION = "0.1.1-beta.
|
|
28500
|
+
var CONNECTOR_VERSION = "0.1.1-beta.123";
|
|
28405
28501
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
28406
28502
|
var SOURCE_ACQUISITION_CAPABILITY2 = source_acquisition_compatibility_default.profileVersion;
|
|
28407
28503
|
var daemonRequire = createRequire(import.meta.url);
|
|
@@ -30254,7 +30350,7 @@ function sanitizePiExtraArgs(value) {
|
|
|
30254
30350
|
return splitExtraArgs(value).filter((entry) => !AMASTER_PI_PROHIBITED_EXTRA_ARGS.has(entry));
|
|
30255
30351
|
}
|
|
30256
30352
|
function nativeSessionResumeEnabled(session) {
|
|
30257
|
-
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;
|
|
30258
30354
|
}
|
|
30259
30355
|
function modelCallResponseContract(payload) {
|
|
30260
30356
|
if (payload.responseContract === void 0) return null;
|
|
@@ -30371,8 +30467,8 @@ function buildExecutorInvocation(executor, command = {}, workspace = null, optio
|
|
|
30371
30467
|
const args = ["--mode", "json"];
|
|
30372
30468
|
const governedRun = Object.keys(asRecord(commandRuntimeAuth(command).governedMcp)).length > 0;
|
|
30373
30469
|
const nativeSessionRequest = asRecord(asRecord(command.payload).nativeSession);
|
|
30374
|
-
if (governedRun && nativeSession.used && (nativeSessionRequest.mode
|
|
30375
|
-
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");
|
|
30376
30472
|
}
|
|
30377
30473
|
const provider = readString(process.env.AMASTER_PI_PROVIDER);
|
|
30378
30474
|
const model = readString(process.env.AMASTER_PI_MODEL);
|
|
@@ -33550,6 +33646,23 @@ async function executeRunCommand(config, command) {
|
|
|
33550
33646
|
}
|
|
33551
33647
|
}
|
|
33552
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
|
+
}
|
|
33553
33666
|
executorEnv = managedMcpProfile.env;
|
|
33554
33667
|
if (executor.kind === "pi" && managedMcpProfile.spawnIdentity) {
|
|
33555
33668
|
piExecutorIdentity = managedMcpProfile.spawnIdentity;
|
|
@@ -33957,7 +34070,11 @@ async function executeRunCommand(config, command) {
|
|
|
33957
34070
|
parsed.hasAssistantOutput = true;
|
|
33958
34071
|
}
|
|
33959
34072
|
}
|
|
33960
|
-
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);
|
|
33961
34078
|
if (shouldPreserveNativeSession) {
|
|
33962
34079
|
try {
|
|
33963
34080
|
const preserveSessionRollout = executor.kind === "pi" ? preserveManagedPiSessionRollout : preserveManagedCodexSessionRollout;
|
|
@@ -33965,7 +34082,7 @@ async function executeRunCommand(config, command) {
|
|
|
33965
34082
|
sessionId: parsed.sessionId,
|
|
33966
34083
|
sourceWorkspacePath: workspace.sourceWorkspacePath
|
|
33967
34084
|
});
|
|
33968
|
-
const checkpoint = await saveIssueCheckpoint(
|
|
34085
|
+
const checkpoint = approvalRequiredSession ? await saveIssueCheckpoint(
|
|
33969
34086
|
config,
|
|
33970
34087
|
command,
|
|
33971
34088
|
workspace,
|
|
@@ -33973,23 +34090,30 @@ async function executeRunCommand(config, command) {
|
|
|
33973
34090
|
rawPath: artifact.relativePath,
|
|
33974
34091
|
filePath: resolve13(cwd, artifact.relativePath)
|
|
33975
34092
|
}))
|
|
33976
|
-
);
|
|
34093
|
+
) : null;
|
|
33977
34094
|
nativeSessionRollout = {
|
|
33978
34095
|
status: preservedRollout.status,
|
|
33979
34096
|
sessionId: preservedRollout.sessionId,
|
|
33980
34097
|
...checkpoint ? { checkpoint: { fileCount: checkpoint.files.length, totalBytes: checkpoint.totalBytes } } : {}
|
|
33981
34098
|
};
|
|
33982
|
-
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`, {
|
|
33983
34100
|
presentationKind: "managed_mcp_session_rollout",
|
|
33984
34101
|
status: nativeSessionRollout.status,
|
|
33985
34102
|
sessionId: parsed.sessionId
|
|
33986
34103
|
});
|
|
33987
34104
|
} catch (err) {
|
|
33988
|
-
|
|
33989
|
-
|
|
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`, {
|
|
33990
34115
|
presentationKind: "managed_mcp_session_rollout",
|
|
33991
|
-
status: "failed"
|
|
33992
|
-
sessionId: parsed.sessionId
|
|
34116
|
+
status: approvalRequiredSession ? "failed" : "unavailable"
|
|
33993
34117
|
});
|
|
33994
34118
|
}
|
|
33995
34119
|
}
|
|
@@ -33997,20 +34121,29 @@ async function executeRunCommand(config, command) {
|
|
|
33997
34121
|
if (approvedContinuationSucceeded) {
|
|
33998
34122
|
await clearIssueCheckpoint(config, command, workspace, "approved_action_succeeded");
|
|
33999
34123
|
}
|
|
34000
|
-
|
|
34124
|
+
const taskSessionContinuationSucceeded = nativeSessionRequest.mode === "task_session" && asRecord(invocation.nativeSession).used === true && shouldPreserveNativeSession && nativeSessionRollout?.status === "preserved";
|
|
34125
|
+
if (managedMcpProfile && (approvedContinuationSucceeded || taskSessionContinuationSucceeded)) {
|
|
34001
34126
|
try {
|
|
34002
|
-
|
|
34003
|
-
|
|
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`, {
|
|
34004
34130
|
presentationKind: "managed_mcp_session_rollout_cleanup",
|
|
34005
34131
|
status: nativeSessionRolloutCleanup.status,
|
|
34006
34132
|
sessionId: readString(nativeSessionRequest.sessionId)
|
|
34007
34133
|
});
|
|
34008
34134
|
} catch (err) {
|
|
34009
|
-
|
|
34010
|
-
|
|
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`, {
|
|
34011
34145
|
presentationKind: "managed_mcp_session_rollout_cleanup",
|
|
34012
|
-
status: "failed"
|
|
34013
|
-
sessionId: readString(nativeSessionRequest.sessionId)
|
|
34146
|
+
status: "failed"
|
|
34014
34147
|
});
|
|
34015
34148
|
}
|
|
34016
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",
|