fix(pi): resolve packaged proxy token lazily
This commit is contained in:
@@ -89,8 +89,12 @@ import {
|
||||
resolveCodingPiRuntimePaths,
|
||||
} from '../api/coding-composition';
|
||||
import {
|
||||
finishFinalAsarProxyCompositionProof,
|
||||
finishFinalAsarPressureProof,
|
||||
getFinalAsarProxyCompositionStatus,
|
||||
releaseFinalAsarProxyCompositionChild,
|
||||
runFinalAsarExtensionProof,
|
||||
startFinalAsarProxyCompositionProof,
|
||||
startFinalAsarPressureProof,
|
||||
} from '../coding-runtime/pi/release-proof';
|
||||
|
||||
@@ -546,7 +550,7 @@ async function initialize(): Promise<void> {
|
||||
storage: codingProjectStorage,
|
||||
projectStore: codingProjectStore,
|
||||
browser: agentBrowser,
|
||||
localProxyCredential: getHostApiToken() || undefined,
|
||||
getLocalProxyCredential: () => getHostApiToken() || undefined,
|
||||
paths: {
|
||||
...resolveCodingPiRuntimePaths({
|
||||
isPackaged: app.isPackaged,
|
||||
@@ -882,6 +886,10 @@ export async function runLocalPreviewPreflightE2E(
|
||||
|
||||
type PiReleaseProofAction =
|
||||
| 'extension'
|
||||
| 'proxy.start'
|
||||
| 'proxy.status'
|
||||
| 'proxy.release-child'
|
||||
| 'proxy.finish'
|
||||
| 'pressure.start'
|
||||
| 'pressure.finish'
|
||||
| 'pressure.finish.inject-failure';
|
||||
@@ -897,6 +905,31 @@ export async function runPiReleaseProofE2E(action: PiReleaseProofAction) {
|
||||
if (action === 'extension') {
|
||||
return { action, packagedMain, extension: await runFinalAsarExtensionProof() };
|
||||
}
|
||||
if (action === 'proxy.start') {
|
||||
if (!codingProducts) throw new Error('Packaged Main coding composition is unavailable');
|
||||
const address = hostApiServer?.address();
|
||||
if (!address || typeof address === 'string') throw new Error('Packaged Main Host API is unavailable');
|
||||
return {
|
||||
action,
|
||||
packagedMain,
|
||||
proxy: await startFinalAsarProxyCompositionProof({
|
||||
composition: codingProducts,
|
||||
projectPath: join(app.getPath('userData'), 'pi-proxy-proof-project'),
|
||||
hostProxyBaseUrl: `http://127.0.0.1:${address.port}/api/ai-proxy/v1`,
|
||||
hostToken: getHostApiToken(),
|
||||
}),
|
||||
};
|
||||
}
|
||||
if (action === 'proxy.status') {
|
||||
return { action, packagedMain, proxy: await getFinalAsarProxyCompositionStatus() };
|
||||
}
|
||||
if (action === 'proxy.release-child') {
|
||||
releaseFinalAsarProxyCompositionChild();
|
||||
return { action, packagedMain, proxy: { released: 'child' } };
|
||||
}
|
||||
if (action === 'proxy.finish') {
|
||||
return { action, packagedMain, proxy: await finishFinalAsarProxyCompositionProof() };
|
||||
}
|
||||
if (action === 'pressure.start') {
|
||||
return { action, packagedMain, pressure: await startFinalAsarPressureProof() };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user